@aastrika_npmjs/sunbird-sdk 5.1.3 → 5.1.4

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 (757) hide show
  1. package/LICENSE +1 -1
  2. package/LICENSE:Zone.Identifier +1 -1
  3. package/README.md +1 -0
  4. package/README.md:Zone.Identifier +1 -1
  5. package/__test__/mocks.d.ts:Zone.Identifier +1 -1
  6. package/__test__/setup.d.ts:Zone.Identifier +1 -1
  7. package/api/api-service-impl.d.ts +18 -9
  8. package/api/api-service-impl.d.ts:Zone.Identifier +1 -1
  9. package/api/config/api-config.d.ts +1 -0
  10. package/api/config/api-config.d.ts:Zone.Identifier +1 -1
  11. package/api/config/app-config.d.ts:Zone.Identifier +1 -1
  12. package/api/def/api-request-handler.d.ts:Zone.Identifier +1 -1
  13. package/api/def/api-service.d.ts +4 -6
  14. package/api/def/api-service.d.ts:Zone.Identifier +1 -1
  15. package/api/handlers/api-token-handler.d.ts +2 -1
  16. package/api/handlers/api-token-handler.d.ts:Zone.Identifier +1 -1
  17. package/api/index.d.ts +2 -9
  18. package/api/index.d.ts:Zone.Identifier +1 -1
  19. package/api/network-queue/db/schema.d.ts:Zone.Identifier +1 -1
  20. package/api/network-queue/def/network-queue.d.ts:Zone.Identifier +1 -1
  21. package/api/network-queue/handlers/network-request-handler.d.ts:Zone.Identifier +1 -1
  22. package/api/network-queue/impl/network-queue-impl.d.ts:Zone.Identifier +1 -1
  23. package/api/network-queue/index.d.ts:Zone.Identifier +1 -1
  24. package/api/util/authenticators/bearer-token-refresh-interceptor.d.ts:Zone.Identifier +1 -1
  25. package/api/util/authenticators/user-token-refresh-interceptor.d.ts:Zone.Identifier +1 -1
  26. package/archive/def/archive-service.d.ts:Zone.Identifier +1 -1
  27. package/archive/export/def/archive-export-delegate.d.ts:Zone.Identifier +1 -1
  28. package/archive/export/def/telemetry-archive-package-meta.d.ts:Zone.Identifier +1 -1
  29. package/archive/export/error/export-assertion-error.d.ts:Zone.Identifier +1 -1
  30. package/archive/export/error/invalid-request-error.d.ts:Zone.Identifier +1 -1
  31. package/archive/export/error/object-not-found-error.d.ts:Zone.Identifier +1 -1
  32. package/archive/export/impl/telemetry-export-delegate.d.ts:Zone.Identifier +1 -1
  33. package/archive/export/index.d.ts:Zone.Identifier +1 -1
  34. package/archive/impl/archive-service-impl.d.ts +5 -1
  35. package/archive/impl/archive-service-impl.d.ts:Zone.Identifier +1 -1
  36. package/archive/import/def/archive-import-delegate.d.ts:Zone.Identifier +1 -1
  37. package/archive/import/error/import-assertion-error.d.ts:Zone.Identifier +1 -1
  38. package/archive/import/error/invalid-archive-error.d.ts:Zone.Identifier +1 -1
  39. package/archive/import/error/unknown-object-error.d.ts:Zone.Identifier +1 -1
  40. package/archive/import/impl/telemetry-import-delegate.d.ts +5 -1
  41. package/archive/import/impl/telemetry-import-delegate.d.ts:Zone.Identifier +1 -1
  42. package/archive/import/index.d.ts:Zone.Identifier +1 -1
  43. package/archive/index.d.ts:Zone.Identifier +1 -1
  44. package/auth/def/auth-end-points.d.ts:Zone.Identifier +1 -1
  45. package/auth/def/auth-event.d.ts:Zone.Identifier +1 -1
  46. package/auth/def/auth-service.d.ts +2 -1
  47. package/auth/def/auth-service.d.ts:Zone.Identifier +1 -1
  48. package/auth/def/o-auth-session.d.ts +2 -0
  49. package/auth/def/o-auth-session.d.ts:Zone.Identifier +1 -1
  50. package/auth/def/session-provider.d.ts:Zone.Identifier +1 -1
  51. package/auth/errors/auth-token-refresh-error.d.ts:Zone.Identifier +1 -1
  52. package/auth/errors/in-app-browser-exit-error.d.ts:Zone.Identifier +1 -1
  53. package/auth/errors/processing-error.d.ts:Zone.Identifier +1 -1
  54. package/auth/errors/sign-in-error.d.ts:Zone.Identifier +1 -1
  55. package/auth/impl/auth-service-impl.d.ts +3 -0
  56. package/auth/impl/auth-service-impl.d.ts:Zone.Identifier +1 -1
  57. package/auth/index.d.ts +7 -0
  58. package/auth/index.d.ts:Zone.Identifier +1 -1
  59. package/auth/util/auth-util.d.ts:Zone.Identifier +1 -1
  60. package/auth/util/native-apple-session-provider/impl/native-apple-session-provider.d.ts:Zone.Identifier +1 -1
  61. package/auth/util/native-custombrowser-session-provider/impl/native-custombrowser-session-provider.d.ts:Zone.Identifier +1 -1
  62. package/auth/util/native-google-session-provider/impl/native-google-session-provider.d.ts:Zone.Identifier +1 -1
  63. package/auth/util/native-keycloak-session-provider/impl/native-keycloak-session-provider.d.ts:Zone.Identifier +1 -1
  64. package/auth/util/webview-session-provider/def/webview-register-session-provider-config.d.ts:Zone.Identifier +1 -1
  65. package/auth/util/webview-session-provider/def/webview-runner.d.ts +1 -0
  66. package/auth/util/webview-session-provider/def/webview-runner.d.ts:Zone.Identifier +1 -1
  67. package/auth/util/webview-session-provider/def/webview-session-provider-config.d.ts:Zone.Identifier +1 -1
  68. package/auth/util/webview-session-provider/def/webview-state-session-provider-config.d.ts:Zone.Identifier +1 -1
  69. package/auth/util/webview-session-provider/errors/interrupt-error.d.ts:Zone.Identifier +1 -1
  70. package/auth/util/webview-session-provider/errors/no-inappbrowser-session-assertion-fail-error.d.ts:Zone.Identifier +1 -1
  71. package/auth/util/webview-session-provider/errors/param-not-captured-error.d.ts:Zone.Identifier +1 -1
  72. package/auth/util/webview-session-provider/errors/webview-runner-error.d.ts:Zone.Identifier +1 -1
  73. package/auth/util/webview-session-provider/impl/webview-auto-merge-session-provider.d.ts:Zone.Identifier +1 -1
  74. package/auth/util/webview-session-provider/impl/webview-base-session-provider.d.ts +2 -2
  75. package/auth/util/webview-session-provider/impl/webview-base-session-provider.d.ts:Zone.Identifier +1 -1
  76. package/auth/util/webview-session-provider/impl/webview-login-session-provider.d.ts +2 -1
  77. package/auth/util/webview-session-provider/impl/webview-login-session-provider.d.ts:Zone.Identifier +1 -1
  78. package/auth/util/webview-session-provider/impl/webview-manual-merge-session-provider.d.ts:Zone.Identifier +1 -1
  79. package/auth/util/webview-session-provider/impl/webview-runner-impl.d.ts +2 -1
  80. package/auth/util/webview-session-provider/impl/webview-runner-impl.d.ts:Zone.Identifier +1 -1
  81. package/auth/util/webview-session-provider/impl/webview-state-session-provider.d.ts:Zone.Identifier +1 -1
  82. package/certificate/config/certificate-service-config.d.ts:Zone.Identifier +1 -1
  83. package/certificate/db/schema.d.ts:Zone.Identifier +1 -1
  84. package/certificate/def/certificate-service.d.ts:Zone.Identifier +1 -1
  85. package/certificate/handlers/get-public-key-handler.d.ts +1 -1
  86. package/certificate/handlers/get-public-key-handler.d.ts:Zone.Identifier +1 -1
  87. package/certificate/impl/certificate-service-impl.d.ts +1 -1
  88. package/certificate/impl/certificate-service-impl.d.ts:Zone.Identifier +1 -1
  89. package/certificate/index.d.ts:Zone.Identifier +1 -1
  90. package/codepush-experiment/def/codepush-experiment-service.d.ts:Zone.Identifier +1 -1
  91. package/codepush-experiment/handler/codepush-experiment-handler.d.ts:Zone.Identifier +1 -1
  92. package/codepush-experiment/impl/codepush-experiment-service-impl.d.ts:Zone.Identifier +1 -1
  93. package/codepush-experiment/index.d.ts:Zone.Identifier +1 -1
  94. package/content/config/content-config.d.ts +2 -0
  95. package/content/config/content-config.d.ts:Zone.Identifier +1 -1
  96. package/content/db/schema.d.ts +11 -0
  97. package/content/db/schema.d.ts:Zone.Identifier +1 -1
  98. package/content/def/content-delete-listener.d.ts:Zone.Identifier +1 -1
  99. package/content/def/content-event.d.ts:Zone.Identifier +1 -1
  100. package/content/def/content-feedback-service.d.ts:Zone.Identifier +1 -1
  101. package/content/def/content-service.d.ts +17 -4
  102. package/content/def/content-service.d.ts:Zone.Identifier +1 -1
  103. package/content/def/content.d.ts +6 -3
  104. package/content/def/content.d.ts:Zone.Identifier +1 -1
  105. package/content/def/requests.d.ts +18 -1
  106. package/content/def/requests.d.ts:Zone.Identifier +1 -1
  107. package/content/def/response.d.ts +13 -2
  108. package/content/def/response.d.ts:Zone.Identifier +1 -1
  109. package/content/def/search-request.d.ts +5 -2
  110. package/content/def/search-request.d.ts:Zone.Identifier +1 -1
  111. package/content/handlers/content-aggregator.d.ts:Zone.Identifier +1 -1
  112. package/content/handlers/content-feedback-handler.d.ts:Zone.Identifier +1 -1
  113. package/content/handlers/content-marker-handler.d.ts:Zone.Identifier +1 -1
  114. package/content/handlers/content-storage-handler.d.ts:Zone.Identifier +1 -1
  115. package/content/handlers/delete-content-handler.d.ts:Zone.Identifier +1 -1
  116. package/content/handlers/export/clean-temp-loc.d.ts:Zone.Identifier +1 -1
  117. package/content/handlers/export/compress-content.d.ts:Zone.Identifier +1 -1
  118. package/content/handlers/export/copy-asset.d.ts +2 -3
  119. package/content/handlers/export/copy-asset.d.ts:Zone.Identifier +1 -1
  120. package/content/handlers/export/copy-to-destination.d.ts:Zone.Identifier +1 -1
  121. package/content/handlers/export/create-content-export-manifest.d.ts:Zone.Identifier +1 -1
  122. package/content/handlers/export/create-temp-loc.d.ts:Zone.Identifier +1 -1
  123. package/content/handlers/export/delete-temp-ecar.d.ts:Zone.Identifier +1 -1
  124. package/content/handlers/export/deletete-temp-dir.d.ts:Zone.Identifier +1 -1
  125. package/content/handlers/export/device-memory-check.d.ts:Zone.Identifier +1 -1
  126. package/content/handlers/export/ecar-bundle.d.ts:Zone.Identifier +1 -1
  127. package/content/handlers/export/generate-export-share-telemetry.d.ts:Zone.Identifier +1 -1
  128. package/content/handlers/export/write-manifest.d.ts:Zone.Identifier +1 -1
  129. package/content/handlers/get-child-contents-handler.d.ts +3 -1
  130. package/content/handlers/get-child-contents-handler.d.ts:Zone.Identifier +1 -1
  131. package/content/handlers/get-child-question-set-handler.d.ts:Zone.Identifier +1 -1
  132. package/content/handlers/get-content-details-handler.d.ts:Zone.Identifier +1 -1
  133. package/content/handlers/get-content-heirarchy-handler.d.ts +1 -1
  134. package/content/handlers/get-content-heirarchy-handler.d.ts:Zone.Identifier +1 -1
  135. package/content/handlers/get-contents-handler.d.ts +1 -1
  136. package/content/handlers/get-contents-handler.d.ts:Zone.Identifier +1 -1
  137. package/content/handlers/import/content-search-api-handler.d.ts:Zone.Identifier +1 -1
  138. package/content/handlers/import/create-content-import-manifest.d.ts:Zone.Identifier +1 -1
  139. package/content/handlers/import/create-hierarchy.d.ts:Zone.Identifier +1 -1
  140. package/content/handlers/import/device-memory-check.d.ts:Zone.Identifier +1 -1
  141. package/content/handlers/import/ecar-cleanup.d.ts:Zone.Identifier +1 -1
  142. package/content/handlers/import/extract-ecar.d.ts:Zone.Identifier +1 -1
  143. package/content/handlers/import/extract-payloads.d.ts +10 -1
  144. package/content/handlers/import/extract-payloads.d.ts:Zone.Identifier +1 -1
  145. package/content/handlers/import/generate-import-share-telemetry.d.ts:Zone.Identifier +1 -1
  146. package/content/handlers/import/generate-interact-telemetry.d.ts:Zone.Identifier +1 -1
  147. package/content/handlers/import/hierarchy-manifest-conversion.d.ts:Zone.Identifier +1 -1
  148. package/content/handlers/import/update-size-on-device.d.ts:Zone.Identifier +1 -1
  149. package/content/handlers/import/validate-ecar.d.ts:Zone.Identifier +1 -1
  150. package/content/handlers/import-n-export-handler.d.ts:Zone.Identifier +1 -1
  151. package/content/handlers/question-set-file-read-handler.d.ts +1 -1
  152. package/content/handlers/question-set-file-read-handler.d.ts:Zone.Identifier +1 -1
  153. package/content/handlers/search-content-handler.d.ts +10 -8
  154. package/content/handlers/search-content-handler.d.ts:Zone.Identifier +1 -1
  155. package/content/impl/content-feedback-service-impl.d.ts:Zone.Identifier +1 -1
  156. package/content/impl/content-service-impl.d.ts +34 -8
  157. package/content/impl/content-service-impl.d.ts:Zone.Identifier +1 -1
  158. package/content/index.d.ts +1 -0
  159. package/content/index.d.ts:Zone.Identifier +1 -1
  160. package/content/util/content-constants.d.ts +5 -1
  161. package/content/util/content-constants.d.ts:Zone.Identifier +1 -1
  162. package/content/util/content-mapper.d.ts:Zone.Identifier +1 -1
  163. package/content/util/content-util.d.ts +5 -1
  164. package/content/util/content-util.d.ts:Zone.Identifier +1 -1
  165. package/content/util/linked-list.d.ts +1 -1
  166. package/content/util/linked-list.d.ts:Zone.Identifier +1 -1
  167. package/content/util/stack.d.ts +1 -1
  168. package/content/util/stack.d.ts:Zone.Identifier +1 -1
  169. package/course/config/course-service-config.d.ts:Zone.Identifier +1 -1
  170. package/course/course-util.d.ts:Zone.Identifier +1 -1
  171. package/course/def/batch.d.ts +1 -1
  172. package/course/def/batch.d.ts:Zone.Identifier +1 -1
  173. package/course/def/course-batches-response.d.ts:Zone.Identifier +1 -1
  174. package/course/def/course-certificate-manager.d.ts:Zone.Identifier +1 -1
  175. package/course/def/course-service.d.ts +21 -4
  176. package/course/def/course-service.d.ts:Zone.Identifier +1 -1
  177. package/course/def/course.d.ts +1 -1
  178. package/course/def/course.d.ts:Zone.Identifier +1 -1
  179. package/course/def/download-certificate-request.d.ts +3 -2
  180. package/course/def/download-certificate-request.d.ts:Zone.Identifier +1 -1
  181. package/course/def/download-certificate-response.d.ts:Zone.Identifier +1 -1
  182. package/course/def/get-certificate-request.d.ts:Zone.Identifier +1 -1
  183. package/course/def/get-enrolled-course-response.d.ts:Zone.Identifier +1 -1
  184. package/course/def/get-learner-certificate-response.d.ts:Zone.Identifier +1 -1
  185. package/course/def/request-types.d.ts +29 -31
  186. package/course/def/request-types.d.ts:Zone.Identifier +1 -1
  187. package/course/def/unenrollCourseRequest.d.ts:Zone.Identifier +1 -1
  188. package/course/def/update-content-state-response.d.ts:Zone.Identifier +1 -1
  189. package/course/def/update-course-content-state-request.d.ts:Zone.Identifier +1 -1
  190. package/course/errors/certificate-already-downloaded.d.ts:Zone.Identifier +1 -1
  191. package/course/errors/no-certificate-found.d.ts:Zone.Identifier +1 -1
  192. package/course/handlers/enroll-course-handler.d.ts +1 -0
  193. package/course/handlers/enroll-course-handler.d.ts:Zone.Identifier +1 -1
  194. package/course/handlers/get-batch-details-handler.d.ts +1 -1
  195. package/course/handlers/get-batch-details-handler.d.ts:Zone.Identifier +1 -1
  196. package/course/handlers/get-content-state-handler.d.ts +10 -5
  197. package/course/handlers/get-content-state-handler.d.ts:Zone.Identifier +1 -1
  198. package/course/handlers/get-course-batches-handler.d.ts +1 -5
  199. package/course/handlers/get-course-batches-handler.d.ts:Zone.Identifier +1 -1
  200. package/course/handlers/get-enrolled-course-handler.d.ts +5 -1
  201. package/course/handlers/get-enrolled-course-handler.d.ts:Zone.Identifier +1 -1
  202. package/course/handlers/get-learner-certificate-handler.d.ts:Zone.Identifier +1 -1
  203. package/course/handlers/offline-content-state-handler.d.ts:Zone.Identifier +1 -1
  204. package/course/handlers/offline-course-cache-handler.d.ts:Zone.Identifier +1 -1
  205. package/course/handlers/sync-assessment-events-handler.d.ts +3 -3
  206. package/course/handlers/sync-assessment-events-handler.d.ts:Zone.Identifier +1 -1
  207. package/course/handlers/unenroll-course-handler.d.ts:Zone.Identifier +1 -1
  208. package/course/handlers/update-content-state-api-handler.d.ts +8 -6
  209. package/course/handlers/update-content-state-api-handler.d.ts:Zone.Identifier +1 -1
  210. package/course/handlers/update-enrolled-courses-handler.d.ts:Zone.Identifier +1 -1
  211. package/course/impl/course-certificate-manager-impl.d.ts:Zone.Identifier +1 -1
  212. package/course/impl/course-service-impl.d.ts +45 -13
  213. package/course/impl/course-service-impl.d.ts:Zone.Identifier +1 -1
  214. package/course/impl/offline-assessment-score-processor.d.ts:Zone.Identifier +1 -1
  215. package/course/index.d.ts +4 -0
  216. package/course/index.d.ts:Zone.Identifier +1 -1
  217. package/db/config/db-config.d.ts:Zone.Identifier +1 -1
  218. package/db/db-constants.d.ts:Zone.Identifier +1 -1
  219. package/db/def/db-constants.d.ts:Zone.Identifier +1 -1
  220. package/db/def/db-service.d.ts:Zone.Identifier +1 -1
  221. package/db/def/migration.d.ts +1 -0
  222. package/db/def/migration.d.ts:Zone.Identifier +1 -1
  223. package/db/def/query.d.ts:Zone.Identifier +1 -1
  224. package/db/impl/db-cordova-service.d.ts +2 -2
  225. package/db/impl/db-cordova-service.d.ts:Zone.Identifier +1 -1
  226. package/db/impl/db-web-sql-service.d.ts:Zone.Identifier +1 -1
  227. package/db/index.d.ts:Zone.Identifier +1 -1
  228. package/db/migrations/certificate-public-key-migration.d.ts:Zone.Identifier +1 -1
  229. package/db/migrations/content-dialcode-migration.d.ts:Zone.Identifier +1 -1
  230. package/db/migrations/content-generalization-migration.d.ts:Zone.Identifier +1 -1
  231. package/db/migrations/content-marker-migration.d.ts:Zone.Identifier +1 -1
  232. package/db/migrations/course-assessment-migration.d.ts:Zone.Identifier +1 -1
  233. package/db/migrations/error-stack-migration.d.ts:Zone.Identifier +1 -1
  234. package/db/migrations/framework-migration.d.ts +9 -0
  235. package/db/migrations/framework-migration.d.ts:Zone.Identifier +3 -0
  236. package/db/migrations/group-profile-migration.d.ts:Zone.Identifier +1 -1
  237. package/db/migrations/initial-migration.d.ts:Zone.Identifier +1 -1
  238. package/db/migrations/milliseconds-to-seconds-migration.d.ts:Zone.Identifier +1 -1
  239. package/db/migrations/network-queue-migration.d.ts:Zone.Identifier +1 -1
  240. package/db/migrations/offline-search-textbook-migration.d.ts:Zone.Identifier +1 -1
  241. package/db/migrations/player-config-data-migrations.d.ts:Zone.Identifier +1 -1
  242. package/db/migrations/profile-syllabus-migration.d.ts:Zone.Identifier +1 -1
  243. package/db/migrations/recently-viewed-migration.d.ts:Zone.Identifier +1 -1
  244. package/db/migrations/search-history-migration.d.ts:Zone.Identifier +1 -1
  245. package/db/util/query-builder.d.ts:Zone.Identifier +1 -1
  246. package/db/util/unique-id.d.ts:Zone.Identifier +1 -1
  247. package/debugging/def/debugging-service.d.ts:Zone.Identifier +1 -1
  248. package/debugging/handler/debugging-duration-handler.d.ts:Zone.Identifier +1 -1
  249. package/debugging/impl/debuggin-service-impl.d.ts +4 -2
  250. package/debugging/impl/debuggin-service-impl.d.ts:Zone.Identifier +1 -1
  251. package/debugging/index.d.ts:Zone.Identifier +1 -1
  252. package/device-register/config/device-register-config.d.ts:Zone.Identifier +1 -1
  253. package/device-register/def/device-register-service.d.ts:Zone.Identifier +1 -1
  254. package/device-register/def/request.d.ts:Zone.Identifier +1 -1
  255. package/device-register/def/response.d.ts +1 -10
  256. package/device-register/def/response.d.ts:Zone.Identifier +1 -1
  257. package/device-register/handler/device-register-handler.d.ts:Zone.Identifier +1 -1
  258. package/device-register/handler/get-device-profile-handler.d.ts:Zone.Identifier +1 -1
  259. package/device-register/impl/device-register-service-impl.d.ts:Zone.Identifier +1 -1
  260. package/device-register/index.d.ts:Zone.Identifier +1 -1
  261. package/discussion/def/discussion-service.d.ts:Zone.Identifier +1 -1
  262. package/discussion/impl/discussion-service.impl.d.ts +1 -1
  263. package/discussion/impl/discussion-service.impl.d.ts:Zone.Identifier +1 -1
  264. package/discussion/index.d.ts:Zone.Identifier +1 -1
  265. package/error/config/error-logger-config.d.ts:Zone.Identifier +1 -1
  266. package/error/db/schema.d.ts:Zone.Identifier +1 -1
  267. package/error/def/error-logger-service.d.ts:Zone.Identifier +1 -1
  268. package/error/def/error-stack.d.ts:Zone.Identifier +1 -1
  269. package/error/handlers/error-stack-sync-handler.d.ts:Zone.Identifier +1 -1
  270. package/error/handlers/error-stack-sync-request-decorator.d.ts:Zone.Identifier +1 -1
  271. package/error/impl/error-logger-service-impl.d.ts:Zone.Identifier +1 -1
  272. package/error/index.d.ts:Zone.Identifier +1 -1
  273. package/error/util/error-stack-mapper.d.ts:Zone.Identifier +1 -1
  274. package/errors/index.d.ts:Zone.Identifier +1 -1
  275. package/errors/validation-error.d.ts:Zone.Identifier +1 -1
  276. package/events-bus/config/events-bus-config.d.ts:Zone.Identifier +1 -1
  277. package/events-bus/def/emit-request.d.ts:Zone.Identifier +1 -1
  278. package/events-bus/def/error-event.d.ts +2 -1
  279. package/events-bus/def/error-event.d.ts:Zone.Identifier +1 -1
  280. package/events-bus/def/event-namespace.d.ts:Zone.Identifier +1 -1
  281. package/events-bus/def/event-observer.d.ts:Zone.Identifier +1 -1
  282. package/events-bus/def/events-bus-event.d.ts:Zone.Identifier +1 -1
  283. package/events-bus/def/events-bus-service.d.ts:Zone.Identifier +1 -1
  284. package/events-bus/def/register-observer-request.d.ts:Zone.Identifier +1 -1
  285. package/events-bus/impl/events-bus-service-impl.d.ts +1 -1
  286. package/events-bus/impl/events-bus-service-impl.d.ts:Zone.Identifier +1 -1
  287. package/events-bus/index.d.ts:Zone.Identifier +1 -1
  288. package/faq/config/faq-service-config.d.ts:Zone.Identifier +1 -1
  289. package/faq/def/faq-service.d.ts:Zone.Identifier +1 -1
  290. package/faq/def/faq.d.ts +1 -1
  291. package/faq/def/faq.d.ts:Zone.Identifier +1 -1
  292. package/faq/def/get-faq-request.d.ts:Zone.Identifier +1 -1
  293. package/faq/handler/get-faq-details-handler.d.ts:Zone.Identifier +1 -1
  294. package/faq/impl/faq-service-impl.d.ts:Zone.Identifier +1 -1
  295. package/faq/index.d.ts:Zone.Identifier +1 -1
  296. package/form/config/form-service-config.d.ts:Zone.Identifier +1 -1
  297. package/form/def/form-request.d.ts +1 -0
  298. package/form/def/form-request.d.ts:Zone.Identifier +1 -1
  299. package/form/def/form-service.d.ts +1 -1
  300. package/form/def/form-service.d.ts:Zone.Identifier +1 -1
  301. package/form/def/models.d.ts:Zone.Identifier +1 -1
  302. package/form/handle/get-form-handler.d.ts:Zone.Identifier +1 -1
  303. package/form/impl/form-service-impl.d.ts:Zone.Identifier +1 -1
  304. package/form/index.d.ts +1 -0
  305. package/form/index.d.ts:Zone.Identifier +1 -1
  306. package/framework/config/framework-service-config.d.ts +1 -0
  307. package/framework/config/framework-service-config.d.ts:Zone.Identifier +1 -1
  308. package/framework/def/channel.d.ts +1 -1
  309. package/framework/def/channel.d.ts:Zone.Identifier +1 -1
  310. package/framework/def/framework-category-code.d.ts +12 -1
  311. package/framework/def/framework-category-code.d.ts:Zone.Identifier +1 -1
  312. package/framework/def/framework-service.d.ts +7 -4
  313. package/framework/def/framework-service.d.ts:Zone.Identifier +1 -1
  314. package/framework/def/framework.d.ts +1 -1
  315. package/framework/def/framework.d.ts:Zone.Identifier +1 -1
  316. package/framework/def/organization.d.ts:Zone.Identifier +1 -1
  317. package/framework/def/requests.d.ts:Zone.Identifier +1 -1
  318. package/framework/def/responses.d.ts:Zone.Identifier +1 -1
  319. package/framework/def/suggested-framework.d.ts:Zone.Identifier +1 -1
  320. package/framework/errors/no-active-channel-found-error.d.ts:Zone.Identifier +1 -1
  321. package/framework/handler/get-channel-detail-handler.d.ts:Zone.Identifier +1 -1
  322. package/framework/handler/get-framework-category-terms-handler.d.ts:Zone.Identifier +1 -1
  323. package/framework/handler/get-framework-detail-handler.d.ts:Zone.Identifier +1 -1
  324. package/framework/impl/framework-service-impl.d.ts +13 -7
  325. package/framework/impl/framework-service-impl.d.ts:Zone.Identifier +1 -1
  326. package/framework/index.d.ts +3 -1
  327. package/framework/index.d.ts:Zone.Identifier +1 -1
  328. package/framework/util/framework-mapper.d.ts:Zone.Identifier +1 -1
  329. package/framework/util/framework-util-service-impl.d.ts +2 -2
  330. package/framework/util/framework-util-service-impl.d.ts:Zone.Identifier +1 -1
  331. package/framework/util/framework-util-service.d.ts +2 -2
  332. package/framework/util/framework-util-service.d.ts:Zone.Identifier +1 -1
  333. package/framework/util/requests.d.ts +7 -2
  334. package/framework/util/requests.d.ts:Zone.Identifier +1 -1
  335. package/group/def/group-activity-service.d.ts:Zone.Identifier +1 -1
  336. package/group/def/group-service.d.ts +22 -13
  337. package/group/def/group-service.d.ts:Zone.Identifier +1 -1
  338. package/group/def/models.d.ts:Zone.Identifier +1 -1
  339. package/group/def/requests.d.ts:Zone.Identifier +1 -1
  340. package/group/def/responses.d.ts:Zone.Identifier +1 -1
  341. package/group/impl/group-activity-service-impl.d.ts:Zone.Identifier +1 -1
  342. package/group/impl/group-service-impl.d.ts +30 -20
  343. package/group/impl/group-service-impl.d.ts:Zone.Identifier +1 -1
  344. package/group/index.d.ts +4 -6
  345. package/group/index.d.ts:Zone.Identifier +1 -1
  346. package/group-deprecated/db/schema.d.ts:Zone.Identifier +1 -1
  347. package/group-deprecated/def/get-all-group-request-deprecated.d.ts:Zone.Identifier +1 -1
  348. package/group-deprecated/def/group-service-deprecated.d.ts:Zone.Identifier +1 -1
  349. package/group-deprecated/def/group-session-deprecated.d.ts +3 -3
  350. package/group-deprecated/def/group-session-deprecated.d.ts:Zone.Identifier +1 -1
  351. package/group-deprecated/def/groupDeprecated.d.ts:Zone.Identifier +1 -1
  352. package/group-deprecated/def/profiles-to-group-request-deprecated.d.ts:Zone.Identifier +1 -1
  353. package/group-deprecated/error/no-active-group-session-error.d.ts:Zone.Identifier +1 -1
  354. package/group-deprecated/error/no-group-found-error.d.ts:Zone.Identifier +1 -1
  355. package/group-deprecated/impl/group-service-deprecated-impl.d.ts +1 -1
  356. package/group-deprecated/impl/group-service-deprecated-impl.d.ts:Zone.Identifier +1 -1
  357. package/group-deprecated/index.d.ts:Zone.Identifier +1 -1
  358. package/group-deprecated/util/group-mapper.d.ts:Zone.Identifier +1 -1
  359. package/group-deprecated/util/group-profile-mapper.d.ts:Zone.Identifier +1 -1
  360. package/index.d.ts +6 -0
  361. package/index.d.ts:Zone.Identifier +1 -1
  362. package/index.js +1 -8
  363. package/index.js:Zone.Identifier +1 -1
  364. package/injection-tokens.d.ts +19 -0
  365. package/injection-tokens.d.ts:Zone.Identifier +1 -1
  366. package/key-value-store/db/schema.d.ts:Zone.Identifier +1 -1
  367. package/key-value-store/def/cached-item-request.d.ts:Zone.Identifier +1 -1
  368. package/key-value-store/def/cached-item-store.d.ts +1 -0
  369. package/key-value-store/def/cached-item-store.d.ts:Zone.Identifier +1 -1
  370. package/key-value-store/def/key-value-store.d.ts:Zone.Identifier +1 -1
  371. package/key-value-store/impl/cached-item-store-impl.d.ts +1 -0
  372. package/key-value-store/impl/cached-item-store-impl.d.ts:Zone.Identifier +1 -1
  373. package/key-value-store/impl/key-value-store-impl.d.ts:Zone.Identifier +1 -1
  374. package/key-value-store/index.d.ts:Zone.Identifier +1 -1
  375. package/notification/db/schema.d.ts:Zone.Identifier +1 -1
  376. package/notification/def/notification-service.d.ts +8 -5
  377. package/notification/def/notification-service.d.ts:Zone.Identifier +1 -1
  378. package/notification/def/requests.d.ts +8 -2
  379. package/notification/def/requests.d.ts:Zone.Identifier +1 -1
  380. package/notification/handler/notification-handler.d.ts:Zone.Identifier +1 -1
  381. package/notification/impl/notification-service-impl.d.ts +18 -6
  382. package/notification/impl/notification-service-impl.d.ts:Zone.Identifier +1 -1
  383. package/notification/index.d.ts:Zone.Identifier +1 -1
  384. package/notification-v2/def/notification-service-v2.d.ts:Zone.Identifier +1 -1
  385. package/notification-v2/impl/notification-service-v2-impl.d.ts +1 -1
  386. package/notification-v2/impl/notification-service-v2-impl.d.ts:Zone.Identifier +1 -1
  387. package/notification-v2/index.d.ts:Zone.Identifier +1 -1
  388. package/open-rap-configurable.d.ts:Zone.Identifier +1 -1
  389. package/package.json +36 -33
  390. package/package.json:Zone.Identifier +1 -1
  391. package/page/config/page-service-config.d.ts:Zone.Identifier +1 -1
  392. package/page/def/page-assemble-service.d.ts +2 -1
  393. package/page/def/page-assemble-service.d.ts:Zone.Identifier +1 -1
  394. package/page/def/page-assemble.d.ts +5 -1
  395. package/page/def/page-assemble.d.ts:Zone.Identifier +1 -1
  396. package/page/def/requests.d.ts +16 -0
  397. package/page/def/requests.d.ts:Zone.Identifier +1 -1
  398. package/page/handle/delegates/course-request-delegate.d.ts:Zone.Identifier +1 -1
  399. package/page/handle/delegates/default-request-delegate.d.ts:Zone.Identifier +1 -1
  400. package/page/handle/delegates/dialcode-request-delegate.d.ts:Zone.Identifier +1 -1
  401. package/page/handle/page-assembler-factory.d.ts:Zone.Identifier +1 -1
  402. package/page/impl/page-assemble-service-impl.d.ts +13 -2
  403. package/page/impl/page-assemble-service-impl.d.ts:Zone.Identifier +1 -1
  404. package/page/index.d.ts:Zone.Identifier +1 -1
  405. package/partner/db/schema.d.ts:Zone.Identifier +1 -1
  406. package/player/db/schema.d.ts:Zone.Identifier +1 -1
  407. package/player/def/player-service.d.ts +2 -0
  408. package/player/def/player-service.d.ts:Zone.Identifier +1 -1
  409. package/player/def/response.d.ts:Zone.Identifier +1 -1
  410. package/player/impl/player-service-impl.d.ts +7 -2
  411. package/player/impl/player-service-impl.d.ts:Zone.Identifier +1 -1
  412. package/player/index.d.ts:Zone.Identifier +1 -1
  413. package/preference-keys.d.ts +4 -1
  414. package/preference-keys.d.ts:Zone.Identifier +1 -1
  415. package/profile/config/profile-service-config.d.ts +1 -0
  416. package/profile/config/profile-service-config.d.ts:Zone.Identifier +1 -1
  417. package/profile/db/schema.d.ts +3 -0
  418. package/profile/db/schema.d.ts:Zone.Identifier +1 -1
  419. package/profile/def/accept-terms-condition-request.d.ts +2 -0
  420. package/profile/def/accept-terms-condition-request.d.ts:Zone.Identifier +1 -1
  421. package/profile/def/add-managed-profile-request.d.ts:Zone.Identifier +1 -1
  422. package/profile/def/check-user-exists-request.d.ts:Zone.Identifier +1 -1
  423. package/profile/def/check-user-exists-response.d.ts:Zone.Identifier +1 -1
  424. package/profile/def/content-access-filter-criteria.d.ts:Zone.Identifier +1 -1
  425. package/profile/def/content-access.d.ts +1 -0
  426. package/profile/def/content-access.d.ts:Zone.Identifier +1 -1
  427. package/profile/def/delete-user-feed-request.d.ts:Zone.Identifier +1 -1
  428. package/profile/def/delete-user-request.d.ts +3 -0
  429. package/profile/def/delete-user-request.d.ts:Zone.Identifier +3 -0
  430. package/profile/def/export-profile-context.d.ts:Zone.Identifier +1 -1
  431. package/profile/def/generate-otp-request.d.ts:Zone.Identifier +1 -1
  432. package/profile/def/get-all-group-request.d.ts:Zone.Identifier +1 -1
  433. package/profile/def/get-all-profile-request.d.ts:Zone.Identifier +1 -1
  434. package/profile/def/get-managed-server-profiles-request.d.ts:Zone.Identifier +1 -1
  435. package/profile/def/import-profile-context.d.ts:Zone.Identifier +1 -1
  436. package/profile/def/is-profile-already-in-use-request.d.ts:Zone.Identifier +1 -1
  437. package/profile/def/location-search-criteria.d.ts +2 -1
  438. package/profile/def/location-search-criteria.d.ts:Zone.Identifier +1 -1
  439. package/profile/def/location-search-result.d.ts +1 -6
  440. package/profile/def/location-search-result.d.ts:Zone.Identifier +1 -1
  441. package/profile/def/merge-server-profiles-request.d.ts:Zone.Identifier +1 -1
  442. package/profile/def/profile-exists-response.d.ts:Zone.Identifier +1 -1
  443. package/profile/def/profile-export-request.d.ts:Zone.Identifier +1 -1
  444. package/profile/def/profile-export-response.d.ts:Zone.Identifier +1 -1
  445. package/profile/def/profile-import-request.d.ts:Zone.Identifier +1 -1
  446. package/profile/def/profile-import-response.d.ts:Zone.Identifier +1 -1
  447. package/profile/def/profile-service.d.ts +25 -6
  448. package/profile/def/profile-service.d.ts:Zone.Identifier +1 -1
  449. package/profile/def/profile-session.d.ts +2 -4
  450. package/profile/def/profile-session.d.ts:Zone.Identifier +1 -1
  451. package/profile/def/profile.d.ts +7 -1
  452. package/profile/def/profile.d.ts:Zone.Identifier +1 -1
  453. package/profile/def/profiles-to-group-request.d.ts:Zone.Identifier +1 -1
  454. package/profile/def/server-profile-details-request.d.ts +1 -0
  455. package/profile/def/server-profile-details-request.d.ts:Zone.Identifier +1 -1
  456. package/profile/def/server-profile.d.ts +1 -1
  457. package/profile/def/server-profile.d.ts:Zone.Identifier +1 -1
  458. package/profile/def/tenant-info-request.d.ts:Zone.Identifier +1 -1
  459. package/profile/def/tenant-info.d.ts:Zone.Identifier +1 -1
  460. package/profile/def/update-server-profile-declarations-request.d.ts:Zone.Identifier +1 -1
  461. package/profile/def/update-server-profile-declarations-response.d.ts:Zone.Identifier +1 -1
  462. package/profile/def/update-server-profile-info-request.d.ts +1 -16
  463. package/profile/def/update-server-profile-info-request.d.ts:Zone.Identifier +1 -1
  464. package/profile/def/update-server-profile-response.d.ts:Zone.Identifier +1 -1
  465. package/profile/def/update-user-feed-request.d.ts:Zone.Identifier +1 -1
  466. package/profile/def/user-migrate-request.d.ts:Zone.Identifier +1 -1
  467. package/profile/def/user-migrate-response.d.ts:Zone.Identifier +1 -1
  468. package/profile/def/verify-otp-request.d.ts +1 -0
  469. package/profile/def/verify-otp-request.d.ts:Zone.Identifier +1 -1
  470. package/profile/errors/invalid-profile-error.d.ts:Zone.Identifier +1 -1
  471. package/profile/errors/no-active-session-error.d.ts:Zone.Identifier +1 -1
  472. package/profile/errors/no-profile-found-error.d.ts:Zone.Identifier +1 -1
  473. package/profile/handler/accept-term-condition-handler.d.ts:Zone.Identifier +1 -1
  474. package/profile/handler/delete-account-handler.d.ts +11 -0
  475. package/profile/handler/delete-account-handler.d.ts:Zone.Identifier +3 -0
  476. package/profile/handler/delete-profile-data.handler.d.ts +8 -0
  477. package/profile/handler/delete-profile-data.handler.d.ts:Zone.Identifier +3 -0
  478. package/profile/handler/export/clean-up-exported-file.d.ts:Zone.Identifier +1 -1
  479. package/profile/handler/export/copy-database.d.ts:Zone.Identifier +1 -1
  480. package/profile/handler/export/create-metadata.d.ts:Zone.Identifier +1 -1
  481. package/profile/handler/export/generate-profile-export-telemetry.d.ts:Zone.Identifier +1 -1
  482. package/profile/handler/export/get-epar-file-path.d.ts:Zone.Identifier +1 -1
  483. package/profile/handler/generate-otp-handler.d.ts:Zone.Identifier +1 -1
  484. package/profile/handler/get-server-profile-details-handler.d.ts +6 -5
  485. package/profile/handler/get-server-profile-details-handler.d.ts:Zone.Identifier +1 -1
  486. package/profile/handler/import/generate-profile-import-telemetry.d.ts:Zone.Identifier +1 -1
  487. package/profile/handler/import/transport-assesments.d.ts:Zone.Identifier +1 -1
  488. package/profile/handler/import/transport-framework-n-channel.d.ts:Zone.Identifier +1 -1
  489. package/profile/handler/import/transport-group-profile.d.ts:Zone.Identifier +1 -1
  490. package/profile/handler/import/transport-group.d.ts:Zone.Identifier +1 -1
  491. package/profile/handler/import/transport-profiles.d.ts:Zone.Identifier +1 -1
  492. package/profile/handler/import/transport-user.d.ts:Zone.Identifier +1 -1
  493. package/profile/handler/import/update-imported-profile-metadata.d.ts:Zone.Identifier +1 -1
  494. package/profile/handler/import/validate-profile-metadata.d.ts:Zone.Identifier +1 -1
  495. package/profile/handler/is-profile-already-in-use-handler.d.ts +1 -2
  496. package/profile/handler/is-profile-already-in-use-handler.d.ts:Zone.Identifier +1 -1
  497. package/profile/handler/managed-profile-manager.d.ts:Zone.Identifier +1 -1
  498. package/profile/handler/profile-handler.d.ts:Zone.Identifier +1 -1
  499. package/profile/handler/search-location-handler.d.ts:Zone.Identifier +1 -1
  500. package/profile/handler/tenant-info-handler.d.ts:Zone.Identifier +1 -1
  501. package/profile/handler/user-migrate-handler.d.ts:Zone.Identifier +1 -1
  502. package/profile/handler/verify-otp-handler.d.ts +1 -2
  503. package/profile/handler/verify-otp-handler.d.ts:Zone.Identifier +1 -1
  504. package/profile/impl/profile-service-impl.d.ts +28 -9
  505. package/profile/impl/profile-service-impl.d.ts:Zone.Identifier +1 -1
  506. package/profile/index.d.ts +2 -2
  507. package/profile/index.d.ts:Zone.Identifier +1 -1
  508. package/profile/util/profile-db-entry-mapper.d.ts:Zone.Identifier +1 -1
  509. package/sdk-config.d.ts +2 -0
  510. package/sdk-config.d.ts:Zone.Identifier +1 -1
  511. package/sdk-service-on-init-delegate.d.ts:Zone.Identifier +1 -1
  512. package/sdk-service-pre-init-delegate.d.ts:Zone.Identifier +1 -1
  513. package/sdk.d.ts +49 -35
  514. package/sdk.d.ts:Zone.Identifier +1 -1
  515. package/segmentation/def/segmentation-service.d.ts:Zone.Identifier +1 -1
  516. package/segmentation/handler/fetch-segmentation-command-handler.d.ts:Zone.Identifier +1 -1
  517. package/segmentation/handler/fetch-segmentation-tags-handler.d.ts:Zone.Identifier +1 -1
  518. package/segmentation/handler/store-segmentation-command-handler.d.ts:Zone.Identifier +1 -1
  519. package/segmentation/handler/store-segmentation-tag-handler.d.ts:Zone.Identifier +1 -1
  520. package/segmentation/impl/segmentaion-service-impl.d.ts:Zone.Identifier +1 -1
  521. package/segmentation/index.d.ts:Zone.Identifier +1 -1
  522. package/storage/def/scan-requests.d.ts:Zone.Identifier +1 -1
  523. package/storage/def/storage-destination.d.ts:Zone.Identifier +1 -1
  524. package/storage/def/storage-event.d.ts:Zone.Identifier +1 -1
  525. package/storage/def/storage-requests.d.ts:Zone.Identifier +1 -1
  526. package/storage/def/storage-service.d.ts:Zone.Identifier +1 -1
  527. package/storage/errors/cancellation-error.d.ts:Zone.Identifier +1 -1
  528. package/storage/errors/duplicate-content-error.d.ts:Zone.Identifier +1 -1
  529. package/storage/errors/low-memory-error.d.ts:Zone.Identifier +1 -1
  530. package/storage/errors/transfer-failed-duplicate-content-error.d.ts:Zone.Identifier +1 -1
  531. package/storage/errors/transfer-failed-error.d.ts:Zone.Identifier +1 -1
  532. package/storage/handler/scan/get-modified-content-handler.d.ts:Zone.Identifier +1 -1
  533. package/storage/handler/scan/perform-actoin-on-content-handler.d.ts:Zone.Identifier +1 -1
  534. package/storage/handler/storage-handler.d.ts:Zone.Identifier +1 -1
  535. package/storage/handler/transfer/copy-content-from-source-to-destination.d.ts:Zone.Identifier +1 -1
  536. package/storage/handler/transfer/delete-destination-folder.d.ts:Zone.Identifier +1 -1
  537. package/storage/handler/transfer/delete-source-folder.d.ts:Zone.Identifier +1 -1
  538. package/storage/handler/transfer/device-memory-check.d.ts:Zone.Identifier +1 -1
  539. package/storage/handler/transfer/duplicate-content-check.d.ts:Zone.Identifier +1 -1
  540. package/storage/handler/transfer/store-destination-content-in-db.d.ts:Zone.Identifier +1 -1
  541. package/storage/handler/transfer/update-source-content-path-in-db.d.ts:Zone.Identifier +1 -1
  542. package/storage/handler/transfer/validate-destination-content.d.ts:Zone.Identifier +1 -1
  543. package/storage/handler/transfer/validate-destination-folder.d.ts:Zone.Identifier +1 -1
  544. package/storage/handler/transfer-content-handler.d.ts:Zone.Identifier +1 -1
  545. package/storage/impl/storage-service-impl.d.ts:Zone.Identifier +1 -1
  546. package/storage/index.d.ts:Zone.Identifier +1 -1
  547. package/summarizer/assesment-analyzer.d.ts +1 -1
  548. package/summarizer/assesment-analyzer.d.ts:Zone.Identifier +1 -1
  549. package/summarizer/db/schema.d.ts:Zone.Identifier +1 -1
  550. package/summarizer/def/request.d.ts:Zone.Identifier +1 -1
  551. package/summarizer/def/response.d.ts:Zone.Identifier +1 -1
  552. package/summarizer/def/summarizer-service.d.ts +2 -3
  553. package/summarizer/def/summarizer-service.d.ts:Zone.Identifier +1 -1
  554. package/summarizer/handler/summarizer-handler.d.ts:Zone.Identifier +1 -1
  555. package/summarizer/handler/summarizer-queries.d.ts +0 -1
  556. package/summarizer/handler/summarizer-queries.d.ts:Zone.Identifier +1 -1
  557. package/summarizer/handler/summary-telemetry-event-handler.d.ts +8 -9
  558. package/summarizer/handler/summary-telemetry-event-handler.d.ts:Zone.Identifier +1 -1
  559. package/summarizer/impl/summarizer-service-impl.d.ts +2 -2
  560. package/summarizer/impl/summarizer-service-impl.d.ts:Zone.Identifier +1 -1
  561. package/summarizer/index.d.ts:Zone.Identifier +1 -1
  562. package/sunbird-error.d.ts +1 -1
  563. package/sunbird-error.d.ts:Zone.Identifier +1 -1
  564. package/system-settings/config/system-settings-config.d.ts:Zone.Identifier +1 -1
  565. package/system-settings/def/request-types.d.ts:Zone.Identifier +1 -1
  566. package/system-settings/def/system-settings-org-ids.d.ts:Zone.Identifier +1 -1
  567. package/system-settings/def/system-settings-service.d.ts:Zone.Identifier +1 -1
  568. package/system-settings/def/system-settings.d.ts:Zone.Identifier +1 -1
  569. package/system-settings/handlers/get-system-settings-handler.d.ts:Zone.Identifier +1 -1
  570. package/system-settings/impl/system-settings-service-impl.d.ts:Zone.Identifier +1 -1
  571. package/system-settings/index.d.ts:Zone.Identifier +1 -1
  572. package/telemetry/config/telemetry-config.d.ts:Zone.Identifier +1 -1
  573. package/telemetry/db/schema.d.ts:Zone.Identifier +1 -1
  574. package/telemetry/def/requests.d.ts +37 -0
  575. package/telemetry/def/requests.d.ts:Zone.Identifier +1 -1
  576. package/telemetry/def/telemetry-constants.d.ts:Zone.Identifier +1 -1
  577. package/telemetry/def/telemetry-decorator.d.ts +3 -2
  578. package/telemetry/def/telemetry-decorator.d.ts:Zone.Identifier +1 -1
  579. package/telemetry/def/telemetry-event.d.ts:Zone.Identifier +1 -1
  580. package/telemetry/def/telemetry-model.d.ts +23 -3
  581. package/telemetry/def/telemetry-model.d.ts:Zone.Identifier +1 -1
  582. package/telemetry/def/telemetry-service.d.ts +7 -3
  583. package/telemetry/def/telemetry-service.d.ts:Zone.Identifier +1 -1
  584. package/telemetry/def/telemetry-stat.d.ts:Zone.Identifier +1 -1
  585. package/telemetry/def/telemetry-sync-preprocessor.d.ts:Zone.Identifier +1 -1
  586. package/telemetry/def/telemetry-sync-stat.d.ts:Zone.Identifier +1 -1
  587. package/telemetry/errors/invalid-input-for-sync-preprocessor-error.d.ts:Zone.Identifier +1 -1
  588. package/telemetry/handler/import/generate-import-telemetry-share.d.ts:Zone.Identifier +1 -1
  589. package/telemetry/handler/import/transport-processed-telemetry.d.ts:Zone.Identifier +1 -1
  590. package/telemetry/handler/import/update-imported-telemetry-metadata.d.ts:Zone.Identifier +1 -1
  591. package/telemetry/handler/import/validate-telemetry-metadata.d.ts:Zone.Identifier +1 -1
  592. package/telemetry/handler/telemetry-sync-handler.d.ts +7 -9
  593. package/telemetry/handler/telemetry-sync-handler.d.ts:Zone.Identifier +1 -1
  594. package/telemetry/impl/decorator-impl.d.ts +7 -6
  595. package/telemetry/impl/decorator-impl.d.ts:Zone.Identifier +1 -1
  596. package/telemetry/impl/process-event.d.ts:Zone.Identifier +1 -1
  597. package/telemetry/impl/string-to-byte-array-preprocessor.d.ts:Zone.Identifier +1 -1
  598. package/telemetry/impl/string-to-gzipped-string.d.ts:Zone.Identifier +1 -1
  599. package/telemetry/impl/telemetry-entries-to-string-preprocessor.d.ts:Zone.Identifier +1 -1
  600. package/telemetry/impl/telemetry-service-impl.d.ts +18 -6
  601. package/telemetry/impl/telemetry-service-impl.d.ts:Zone.Identifier +1 -1
  602. package/telemetry/index.d.ts +0 -6
  603. package/telemetry/index.d.ts:Zone.Identifier +1 -1
  604. package/telemetry/util/telemetry-auto-sync-modes.d.ts:Zone.Identifier +1 -1
  605. package/telemetry/util/telemetry-auto-sync-service-impl.d.ts +1 -14
  606. package/telemetry/util/telemetry-auto-sync-service-impl.d.ts:Zone.Identifier +1 -1
  607. package/telemetry/util/telemetry-auto-sync-service.d.ts:Zone.Identifier +1 -1
  608. package/telemetry/util/telemetry-logger.d.ts +1 -1
  609. package/telemetry/util/telemetry-logger.d.ts:Zone.Identifier +1 -1
  610. package/util/app/def/app-info.d.ts:Zone.Identifier +1 -1
  611. package/util/app/impl/app-info-impl.d.ts:Zone.Identifier +1 -1
  612. package/util/app/index.d.ts:Zone.Identifier +1 -1
  613. package/util/array-util.d.ts:Zone.Identifier +1 -1
  614. package/util/device/def/device-info.d.ts:Zone.Identifier +1 -1
  615. package/util/device/impl/device-info-impl.d.ts:Zone.Identifier +1 -1
  616. package/util/device/index.d.ts:Zone.Identifier +1 -1
  617. package/util/download/def/download-complete-delegate.d.ts:Zone.Identifier +1 -1
  618. package/util/download/def/download-event.d.ts:Zone.Identifier +1 -1
  619. package/util/download/def/download-service.d.ts +5 -2
  620. package/util/download/def/download-service.d.ts:Zone.Identifier +1 -1
  621. package/util/download/def/download-status.d.ts:Zone.Identifier +1 -1
  622. package/util/download/def/requests.d.ts +7 -0
  623. package/util/download/def/requests.d.ts:Zone.Identifier +1 -1
  624. package/util/download/def/response.d.ts:Zone.Identifier +1 -1
  625. package/util/download/impl/download-service-impl.d.ts +7 -2
  626. package/util/download/impl/download-service-impl.d.ts:Zone.Identifier +1 -1
  627. package/util/download/index.d.ts +1 -0
  628. package/util/download/index.d.ts:Zone.Identifier +1 -1
  629. package/util/encoders/encoder.d.ts:Zone.Identifier +1 -1
  630. package/util/encoders/utf8-to-b64-encoder.d.ts:Zone.Identifier +1 -1
  631. package/util/file/config/file-config.d.ts:Zone.Identifier +1 -1
  632. package/util/file/def/file-service.d.ts:Zone.Identifier +1 -1
  633. package/util/file/errors/no-file-found.d.ts:Zone.Identifier +1 -1
  634. package/util/file/impl/file-service-impl.d.ts:Zone.Identifier +1 -1
  635. package/util/file/index.d.ts:Zone.Identifier +1 -1
  636. package/util/file/util/file-util.d.ts:Zone.Identifier +1 -1
  637. package/util/file/util/path.d.ts +1 -0
  638. package/util/file/util/path.d.ts:Zone.Identifier +1 -1
  639. package/util/jwt-util.d.ts +4 -0
  640. package/util/jwt-util.d.ts:Zone.Identifier +3 -0
  641. package/util/list/comparator.d.ts:Zone.Identifier +1 -1
  642. package/util/list/linked-list.d.ts:Zone.Identifier +1 -1
  643. package/util/list/list-node.d.ts +4 -2
  644. package/util/list/list-node.d.ts:Zone.Identifier +1 -1
  645. package/util/network/def/network-info-service.d.ts:Zone.Identifier +1 -1
  646. package/util/network/def/network-status.d.ts:Zone.Identifier +1 -1
  647. package/util/network/impl/network-info-service-impl.d.ts:Zone.Identifier +1 -1
  648. package/util/network/index.d.ts:Zone.Identifier +1 -1
  649. package/util/number-util.d.ts:Zone.Identifier +1 -1
  650. package/util/object-util.d.ts +1 -0
  651. package/util/object-util.d.ts:Zone.Identifier +1 -1
  652. package/util/queue/queue.d.ts:Zone.Identifier +1 -1
  653. package/util/search-history/db/schema.d.ts:Zone.Identifier +1 -1
  654. package/util/search-history/def/requests.d.ts:Zone.Identifier +1 -1
  655. package/util/search-history/def/search-entry.d.ts:Zone.Identifier +1 -1
  656. package/util/search-history/def/search-history-service.d.ts:Zone.Identifier +1 -1
  657. package/util/search-history/impl/search-history-service-impl.d.ts:Zone.Identifier +1 -1
  658. package/util/search-history/index.d.ts:Zone.Identifier +1 -1
  659. package/util/search-history/util/search-history-db-entry-mapper.d.ts:Zone.Identifier +1 -1
  660. package/util/shared-preferences/config/shared-prefernces-config.d.ts:Zone.Identifier +1 -1
  661. package/util/shared-preferences/def/shared-preferences-set-collection.d.ts:Zone.Identifier +1 -1
  662. package/util/shared-preferences/def/shared-preferences.d.ts +2 -0
  663. package/util/shared-preferences/def/shared-preferences.d.ts:Zone.Identifier +1 -1
  664. package/util/shared-preferences/impl/shared-preferences-android.d.ts +3 -0
  665. package/util/shared-preferences/impl/shared-preferences-android.d.ts:Zone.Identifier +1 -1
  666. package/util/shared-preferences/impl/shared-preferences-local-storage.d.ts +3 -0
  667. package/util/shared-preferences/impl/shared-preferences-local-storage.d.ts:Zone.Identifier +1 -1
  668. package/util/shared-preferences/impl/shared-preferences-set-collection-impl.d.ts:Zone.Identifier +1 -1
  669. package/util/shared-preferences/index.d.ts:Zone.Identifier +1 -1
  670. package/util/zip/def/zip-service.d.ts:Zone.Identifier +1 -1
  671. package/util/zip/impl/zip-service-impl.d.ts:Zone.Identifier +1 -1
  672. package/api/def/authenticator.d.ts +0 -4
  673. package/api/def/authenticator.d.ts:Zone.Identifier +0 -3
  674. package/api/def/connection.d.ts +0 -6
  675. package/api/def/connection.d.ts:Zone.Identifier +0 -3
  676. package/api/def/http-client.d.ts +0 -13
  677. package/api/def/http-client.d.ts:Zone.Identifier +0 -3
  678. package/api/def/request-interceptor.d.ts +0 -5
  679. package/api/def/request-interceptor.d.ts:Zone.Identifier +0 -3
  680. package/api/def/request.d.ts +0 -46
  681. package/api/def/request.d.ts:Zone.Identifier +0 -3
  682. package/api/def/response-interceptor.d.ts +0 -6
  683. package/api/def/response-interceptor.d.ts:Zone.Identifier +0 -3
  684. package/api/def/response.d.ts +0 -14
  685. package/api/def/response.d.ts:Zone.Identifier +0 -3
  686. package/api/errors/http-client-error.d.ts +0 -6
  687. package/api/errors/http-client-error.d.ts:Zone.Identifier +0 -3
  688. package/api/errors/http-server-error.d.ts +0 -6
  689. package/api/errors/http-server-error.d.ts:Zone.Identifier +0 -3
  690. package/api/errors/network-error.d.ts +0 -4
  691. package/api/errors/network-error.d.ts:Zone.Identifier +0 -3
  692. package/api/errors/request-build-error.d.ts +0 -4
  693. package/api/errors/request-build-error.d.ts:Zone.Identifier +0 -3
  694. package/api/handlers/fetch-handler.d.ts +0 -17
  695. package/api/handlers/fetch-handler.d.ts:Zone.Identifier +0 -3
  696. package/api/impl/base-connection.d.ts +0 -20
  697. package/api/impl/base-connection.d.ts:Zone.Identifier +0 -3
  698. package/api/impl/http-client-browser.d.ts +0 -17
  699. package/api/impl/http-client-browser.d.ts:Zone.Identifier +0 -3
  700. package/api/impl/http-client-cordova.d.ts +0 -17
  701. package/api/impl/http-client-cordova.d.ts:Zone.Identifier +0 -3
  702. package/api/util/jwt.util.d.ts +0 -7
  703. package/api/util/jwt.util.d.ts:Zone.Identifier +0 -3
  704. package/course/handlers/content-states-sync-handler.d.ts +0 -16
  705. package/course/handlers/content-states-sync-handler.d.ts:Zone.Identifier +0 -3
  706. package/framework/def/request-types.d.ts +0 -14
  707. package/framework/def/request-types.d.ts:Zone.Identifier +0 -3
  708. package/group/db/schema.d.ts +0 -35
  709. package/group/db/schema.d.ts:Zone.Identifier +0 -3
  710. package/group/def/get-all-group-request.d.ts +0 -3
  711. package/group/def/get-all-group-request.d.ts:Zone.Identifier +0 -3
  712. package/group/def/group-session.d.ts +0 -9
  713. package/group/def/group-session.d.ts:Zone.Identifier +0 -3
  714. package/group/def/group.d.ts +0 -16
  715. package/group/def/group.d.ts:Zone.Identifier +0 -3
  716. package/group/def/profiles-to-group-request.d.ts +0 -4
  717. package/group/def/profiles-to-group-request.d.ts:Zone.Identifier +0 -3
  718. package/group/error/no-active-group-session-error.d.ts +0 -4
  719. package/group/error/no-active-group-session-error.d.ts:Zone.Identifier +0 -3
  720. package/group/error/no-group-found-error.d.ts +0 -4
  721. package/group/error/no-group-found-error.d.ts:Zone.Identifier +0 -3
  722. package/group/util/group-mapper.d.ts +0 -6
  723. package/group/util/group-mapper.d.ts:Zone.Identifier +0 -3
  724. package/group/util/group-profile-mapper.d.ts +0 -6
  725. package/group/util/group-profile-mapper.d.ts:Zone.Identifier +0 -3
  726. package/page/handle/page-assembler-handler.d.ts +0 -20
  727. package/page/handle/page-assembler-handler.d.ts:Zone.Identifier +0 -3
  728. package/profile/def/server-profile-search-criteria.d.ts +0 -9
  729. package/profile/def/server-profile-search-criteria.d.ts:Zone.Identifier +0 -3
  730. package/profile/def/user-feed-response.d.ts +0 -17
  731. package/profile/def/user-feed-response.d.ts:Zone.Identifier +0 -3
  732. package/profile/handler/get-userfeed-handler.d.ts +0 -14
  733. package/profile/handler/get-userfeed-handler.d.ts:Zone.Identifier +0 -3
  734. package/profile/handler/search-server-profile-handler.d.ts +0 -11
  735. package/profile/handler/search-server-profile-handler.d.ts:Zone.Identifier +0 -3
  736. package/profile/handler/update-server-profile-info-handler.d.ts +0 -10
  737. package/profile/handler/update-server-profile-info-handler.d.ts:Zone.Identifier +0 -3
  738. package/telemetry/decorators/decorator-factories.d.ts +0 -5
  739. package/telemetry/decorators/decorator-factories.d.ts:Zone.Identifier +0 -3
  740. package/telemetry/decorators/generate-end-telemetry-decorators.d.ts +0 -4
  741. package/telemetry/decorators/generate-end-telemetry-decorators.d.ts:Zone.Identifier +0 -3
  742. package/telemetry/decorators/generate-error-telemetry-decorators.d.ts +0 -2
  743. package/telemetry/decorators/generate-error-telemetry-decorators.d.ts:Zone.Identifier +0 -3
  744. package/telemetry/decorators/generate-impression-telemetry-decorators.d.ts +0 -4
  745. package/telemetry/decorators/generate-impression-telemetry-decorators.d.ts:Zone.Identifier +0 -3
  746. package/telemetry/decorators/generate-interact-telemetry-decorators.d.ts +0 -5
  747. package/telemetry/decorators/generate-interact-telemetry-decorators.d.ts:Zone.Identifier +0 -3
  748. package/telemetry/decorators/generate-log-telemetry-decorators.d.ts +0 -3
  749. package/telemetry/decorators/generate-log-telemetry-decorators.d.ts:Zone.Identifier +0 -3
  750. package/telemetry/decorators/generate-start-telemetry-decorators.d.ts +0 -4
  751. package/telemetry/decorators/generate-start-telemetry-decorators.d.ts:Zone.Identifier +0 -3
  752. package/telemetry/def/telemetry-error.d.ts +0 -6
  753. package/telemetry/def/telemetry-error.d.ts:Zone.Identifier +0 -3
  754. package/util/authenticators/impl/api-authenticator.d.ts +0 -15
  755. package/util/authenticators/impl/api-authenticator.d.ts:Zone.Identifier +0 -3
  756. package/util/authenticators/impl/session-authenticator.d.ts +0 -14
  757. package/util/authenticators/impl/session-authenticator.d.ts:Zone.Identifier +0 -3
package/index.js CHANGED
@@ -1,8 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("rxjs/operators"),require("rxjs"));else if("function"==typeof define&&define.amd)define(["rxjs/operators","rxjs"],t);else{var n="object"==typeof exports?t(require("rxjs/operators"),require("rxjs")):t(e.rxjs.operators,e.rxjs);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(__WEBPACK_EXTERNAL_MODULE__0__,__WEBPACK_EXTERNAL_MODULE__1__){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=253)}([function(e,t){e.exports=__WEBPACK_EXTERNAL_MODULE__0__},function(e,t){e.exports=__WEBPACK_EXTERNAL_MODULE__1__},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7);t.METADATA_KEY=r;var i=n(122);t.Container=i.Container;var o=n(18);t.BindingScopeEnum=o.BindingScopeEnum,t.BindingTypeEnum=o.BindingTypeEnum,t.TargetTypeEnum=o.TargetTypeEnum;var a=n(138);t.AsyncContainerModule=a.AsyncContainerModule,t.ContainerModule=a.ContainerModule;var c=n(139);t.injectable=c.injectable;var s=n(140);t.tagged=s.tagged;var u=n(141);t.named=u.named;var f=n(65);t.inject=f.inject,t.LazyServiceIdentifer=f.LazyServiceIdentifer;var l=n(142);t.optional=l.optional;var h=n(143);t.unmanaged=h.unmanaged;var d=n(144);t.multiInject=d.multiInject;var p=n(145);t.targetName=p.targetName;var b=n(146);t.postConstruct=b.postConstruct;var _=n(63);t.MetadataReader=_.MetadataReader;var E=n(22);t.id=E.id;var y=n(20);t.decorate=y.decorate;var v=n(68);t.traverseAncerstors=v.traverseAncerstors,t.taggedConstraint=v.taggedConstraint,t.namedConstraint=v.namedConstraint,t.typeConstraint=v.typeConstraint;var g=n(28);t.getServiceIdentifierAsString=g.getServiceIdentifierAsString;var m=n(147);t.multiBindToService=m.multiBindToService},function(e,t,n){var r=n(5),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=a),o(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){"use strict";(function(e){
2
- /*!
3
- * The buffer module from node.js, for the browser.
4
- *
5
- * @author Feross Aboukhadijeh <http://feross.org>
6
- * @license MIT
7
- */
8
- var r=n(149),i=n(150),o=n(70);function a(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function c(e,t){if(a()<t)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=s.prototype:(null===e&&(e=new s(t)),e.length=t),e}function s(e,t,n){if(!(s.TYPED_ARRAY_SUPPORT||this instanceof s))return new s(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);s.TYPED_ARRAY_SUPPORT?(e=t).__proto__=s.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!s.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),i=(e=c(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(s.isBuffer(t)){var n=0|d(t.length);return 0===(e=c(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?c(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=c(e,t<0?0:0|d(t)),!s.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|d(t.length);e=c(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function d(e){if(e>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function p(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(e).length;default:if(r)return F(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return N(this,t,n);case"ascii":return M(this,t,n);case"latin1":case"binary":return w(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function E(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=s.from(t,r)),s.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var o,a=1,c=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,c/=2,s/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var f=-1;for(o=n;o<c;o++)if(u(e,o)===u(t,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===s)return f*a}else-1!==f&&(o-=o-f),f=-1}else for(n+s>c&&(n=c-s),o=n;o>=0;o--){for(var l=!0,h=0;h<s;h++)if(u(e,o+h)!==u(t,h)){l=!1;break}if(l)return o}return-1}function v(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a<r;++a){var c=parseInt(t.substr(2*a,2),16);if(isNaN(c))return a;e[n+a]=c}return a}function g(e,t,n,r){return Y(F(t,e.length-n),e,n,r)}function m(e,t,n,r){return Y(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function S(e,t,n,r){return m(e,t,n,r)}function O(e,t,n,r){return Y(V(t),e,n,r)}function A(e,t,n,r){return Y(function(e,t){for(var n,r,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=e.charCodeAt(a),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function N(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,a,c,s,u=e[i],f=null,l=u>239?4:u>223?3:u>191?2:1;if(i+l<=n)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(o=e[i+1]))&&(s=(31&u)<<6|63&o)>127&&(f=s);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(s=(15&u)<<12|(63&o)<<6|63&a)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=e[i+1],a=e[i+2],c=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&c)&&(s=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&c)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=s,t.SlowBuffer=function(e){+e!=e&&(e=0);return s.alloc(+e)},t.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=a(),s.poolSize=8192,s._augment=function(e){return e.__proto__=s.prototype,e},s.from=function(e,t,n){return u(null,e,t,n)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(e,t,n){return function(e,t,n,r){return f(t),t<=0?c(e,t):void 0!==n?"string"==typeof r?c(e,t).fill(n,r):c(e,t).fill(n):c(e,t)}(null,e,t,n)},s.allocUnsafe=function(e){return l(null,e)},s.allocUnsafeSlow=function(e){return l(null,e)},s.isBuffer=function(e){return!(null==e||!e._isBuffer)},s.compare=function(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=s.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var a=e[n];if(!s.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},s.byteLength=p,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)_(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)_(this,t,t+3),_(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)_(this,t,t+7),_(this,t+1,t+6),_(this,t+2,t+5),_(this,t+3,t+4);return this},s.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?N(this,0,e):b.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},s.prototype.compare=function(e,t,n,r,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),c=Math.min(o,a),u=this.slice(r,i),f=e.slice(t,n),l=0;l<c;++l)if(u[l]!==f[l]){o=u[l],a=f[l];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},s.prototype.indexOf=function(e,t,n){return E(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return E(this,e,t,n,!1)},s.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return v(this,e,t,n);case"utf8":case"utf-8":return g(this,e,t,n);case"ascii":return m(this,e,t,n);case"latin1":case"binary":return S(this,e,t,n);case"base64":return O(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function M(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function w(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=B(e[o]);return i}function I(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function L(e,t,n,r,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function R(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function D(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function j(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,r,o){return o||j(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function k(e,t,n,r,o){return o||j(e,0,n,8),i.write(e,t,n,r,52,8),n+8}s.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),s.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=s.prototype;else{var i=t-e;n=new s(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},s.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},s.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},s.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},s.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},s.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},s.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);L(this,e,t,n,i-1,-i)}var o=0,a=1,c=0;for(this[t]=255&e;++o<n&&(a*=256);)e<0&&0===c&&0!==this[t+o-1]&&(c=1),this[t+o]=(e/a>>0)-c&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);L(this,e,t,n,i-1,-i)}var o=n-1,a=1,c=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===c&&0!==this[t+o+1]&&(c=1),this[t+o]=(e/a>>0)-c&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},s.prototype.writeDoubleLE=function(e,t,n){return k(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return k(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},s.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var a=s.isBuffer(e)?e:F(new s(e,r).toString()),c=a.length;for(o=0;o<n-t;++o)this[o+t]=a[o%c]}return this};var x=/[^+\/0-9A-Za-z-_]/g;function B(e){return e<16?"0"+e.toString(16):e.toString(16)}function F(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function V(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(x,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(19))},function(e,t,n){(function(e){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function o(e,t,n){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var a;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{a=n(189).Buffer}catch(e){}function c(e,t,n){for(var r=0,i=Math.min(e.length,n),o=t;o<i;o++){var a=e.charCodeAt(o)-48;r<<=4,r|=a>=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return r}function s(e,t,n,r){for(var i=0,o=Math.min(e.length,n),a=t;a<o;a++){var c=e.charCodeAt(a)-48;i*=r,i+=c>=49?c-49+10:c>=17?c-17+10:c}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},o.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},o.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,a,c=0;if("be"===n)for(i=e.length-1,o=0;i>=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<<c&67108863,this.words[o+1]=a>>>26-c&67108863,(c+=24)>=26&&(c-=26,o++);else if("le"===n)for(i=0,o=0;i<e.length;i+=3)a=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[o]|=a<<c&67108863,this.words[o+1]=a>>>26-c&67108863,(c+=24)>=26&&(c-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var r,i,o=0;for(n=e.length-6,r=0;n>=t;n-=6)i=c(e,n,n+6),this.words[r]|=i<<o&67108863,this.words[r+1]|=i>>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);n+6!==t&&(i=c(e,t,n+6),this.words[r]|=i<<o&67108863,this.words[r+1]|=i>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var o=e.length-n,a=o%r,c=Math.min(o,o-a)+n,u=0,f=n;f<c;f+=r)u=s(e,f,f+r,t),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var l=1;for(u=s(e,f,e.length,t),f=0;f<a;f++)l*=t;this.imuln(l),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,c=67108863&a,s=a/67108864|0;n.words[0]=c;for(var u=1;u<r;u++){for(var f=s>>>26,l=67108863&s,h=Math.min(u,t.length-1),d=Math.max(0,u-e.length+1);d<=h;d++){var p=u-d|0;f+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}n.words[u]=0|l,s=0|f}return 0!==s?n.words[u]=0|s:n.length--,n.strip()}o.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a<this.length;a++){var c=this.words[a],s=(16777215&(c<<i|o)).toString(16);n=0!==(o=c>>>24-i&16777215)||a!==this.length-1?u[6-s.length]+s+n:s+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=f[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?b+n:u[h-b.length]+b+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,c,s="le"===t,u=new e(o),f=this.clone();if(s){for(c=0;!f.isZero();c++)a=f.andln(255),f.iushrn(8),u[c]=a;for(;c<o;c++)u[c]=0}else{for(c=0;c<o-i;c++)u[c]=0;for(c=0;!f.isZero();c++)a=f.andln(255),f.iushrn(8),u[o-c-1]=a}return u},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},o.prototype.ior=function(e){return r(0==(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this.strip()},o.prototype.iand=function(e){return r(0==(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this.strip()},o.prototype.ixor=function(e){return r(0==(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,o=0;o<r.length;o++)t=(0|n.words[o])+(0|r.words[o])+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<n.length;o++)t=(0|n.words[o])+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;o<n.length;o++)this.words[o]=n.words[o];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=e):(n=e,r=this);for(var o=0,a=0;a<r.length;a++)o=(t=(0|n.words[a])-(0|r.words[a])+o)>>26,this.words[a]=67108863&t;for(;0!==o&&a<n.length;a++)o=(t=(0|n.words[a])+o)>>26,this.words[a]=67108863&t;if(0===o&&a<n.length&&n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this.length=Math.max(this.length,a),n!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var d=function(e,t,n){var r,i,o,a=e.words,c=t.words,s=n.words,u=0,f=0|a[0],l=8191&f,h=f>>>13,d=0|a[1],p=8191&d,b=d>>>13,_=0|a[2],E=8191&_,y=_>>>13,v=0|a[3],g=8191&v,m=v>>>13,S=0|a[4],O=8191&S,A=S>>>13,T=0|a[5],N=8191&T,M=T>>>13,w=0|a[6],C=8191&w,I=w>>>13,P=0|a[7],L=8191&P,R=P>>>13,D=0|a[8],j=8191&D,U=D>>>13,k=0|a[9],x=8191&k,B=k>>>13,F=0|c[0],V=8191&F,Y=F>>>13,G=0|c[1],H=8191&G,q=G>>>13,z=0|c[2],K=8191&z,W=z>>>13,X=0|c[3],J=8191&X,Q=X>>>13,$=0|c[4],Z=8191&$,ee=$>>>13,te=0|c[5],ne=8191&te,re=te>>>13,ie=0|c[6],oe=8191&ie,ae=ie>>>13,ce=0|c[7],se=8191&ce,ue=ce>>>13,fe=0|c[8],le=8191&fe,he=fe>>>13,de=0|c[9],pe=8191&de,be=de>>>13;n.negative=e.negative^t.negative,n.length=19;var _e=(u+(r=Math.imul(l,V))|0)+((8191&(i=(i=Math.imul(l,Y))+Math.imul(h,V)|0))<<13)|0;u=((o=Math.imul(h,Y))+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(p,V),i=(i=Math.imul(p,Y))+Math.imul(b,V)|0,o=Math.imul(b,Y);var Ee=(u+(r=r+Math.imul(l,H)|0)|0)+((8191&(i=(i=i+Math.imul(l,q)|0)+Math.imul(h,H)|0))<<13)|0;u=((o=o+Math.imul(h,q)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(E,V),i=(i=Math.imul(E,Y))+Math.imul(y,V)|0,o=Math.imul(y,Y),r=r+Math.imul(p,H)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,q)|0;var ye=(u+(r=r+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,K)|0))<<13)|0;u=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(g,V),i=(i=Math.imul(g,Y))+Math.imul(m,V)|0,o=Math.imul(m,Y),r=r+Math.imul(E,H)|0,i=(i=i+Math.imul(E,q)|0)+Math.imul(y,H)|0,o=o+Math.imul(y,q)|0,r=r+Math.imul(p,K)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,W)|0;var ve=(u+(r=r+Math.imul(l,J)|0)|0)+((8191&(i=(i=i+Math.imul(l,Q)|0)+Math.imul(h,J)|0))<<13)|0;u=((o=o+Math.imul(h,Q)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(O,V),i=(i=Math.imul(O,Y))+Math.imul(A,V)|0,o=Math.imul(A,Y),r=r+Math.imul(g,H)|0,i=(i=i+Math.imul(g,q)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,q)|0,r=r+Math.imul(E,K)|0,i=(i=i+Math.imul(E,W)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,W)|0,r=r+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Q)|0;var ge=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Z)|0))<<13)|0;u=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(N,V),i=(i=Math.imul(N,Y))+Math.imul(M,V)|0,o=Math.imul(M,Y),r=r+Math.imul(O,H)|0,i=(i=i+Math.imul(O,q)|0)+Math.imul(A,H)|0,o=o+Math.imul(A,q)|0,r=r+Math.imul(g,K)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,W)|0,r=r+Math.imul(E,J)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Q)|0,r=r+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,ee)|0;var me=(u+(r=r+Math.imul(l,ne)|0)|0)+((8191&(i=(i=i+Math.imul(l,re)|0)+Math.imul(h,ne)|0))<<13)|0;u=((o=o+Math.imul(h,re)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(C,V),i=(i=Math.imul(C,Y))+Math.imul(I,V)|0,o=Math.imul(I,Y),r=r+Math.imul(N,H)|0,i=(i=i+Math.imul(N,q)|0)+Math.imul(M,H)|0,o=o+Math.imul(M,q)|0,r=r+Math.imul(O,K)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,W)|0,r=r+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Q)|0)+Math.imul(m,J)|0,o=o+Math.imul(m,Q)|0,r=r+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,ee)|0,r=r+Math.imul(p,ne)|0,i=(i=i+Math.imul(p,re)|0)+Math.imul(b,ne)|0,o=o+Math.imul(b,re)|0;var Se=(u+(r=r+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;u=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(L,V),i=(i=Math.imul(L,Y))+Math.imul(R,V)|0,o=Math.imul(R,Y),r=r+Math.imul(C,H)|0,i=(i=i+Math.imul(C,q)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,q)|0,r=r+Math.imul(N,K)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,W)|0,r=r+Math.imul(O,J)|0,i=(i=i+Math.imul(O,Q)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,Q)|0,r=r+Math.imul(g,Z)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,ee)|0,r=r+Math.imul(E,ne)|0,i=(i=i+Math.imul(E,re)|0)+Math.imul(y,ne)|0,o=o+Math.imul(y,re)|0,r=r+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Oe=(u+(r=r+Math.imul(l,se)|0)|0)+((8191&(i=(i=i+Math.imul(l,ue)|0)+Math.imul(h,se)|0))<<13)|0;u=((o=o+Math.imul(h,ue)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(j,V),i=(i=Math.imul(j,Y))+Math.imul(U,V)|0,o=Math.imul(U,Y),r=r+Math.imul(L,H)|0,i=(i=i+Math.imul(L,q)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,q)|0,r=r+Math.imul(C,K)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(I,K)|0,o=o+Math.imul(I,W)|0,r=r+Math.imul(N,J)|0,i=(i=i+Math.imul(N,Q)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,Q)|0,r=r+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,ee)|0,r=r+Math.imul(g,ne)|0,i=(i=i+Math.imul(g,re)|0)+Math.imul(m,ne)|0,o=o+Math.imul(m,re)|0,r=r+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0,r=r+Math.imul(p,se)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(b,se)|0,o=o+Math.imul(b,ue)|0;var Ae=(u+(r=r+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;u=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(x,V),i=(i=Math.imul(x,Y))+Math.imul(B,V)|0,o=Math.imul(B,Y),r=r+Math.imul(j,H)|0,i=(i=i+Math.imul(j,q)|0)+Math.imul(U,H)|0,o=o+Math.imul(U,q)|0,r=r+Math.imul(L,K)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,W)|0,r=r+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Q)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,Q)|0,r=r+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,ee)|0,r=r+Math.imul(O,ne)|0,i=(i=i+Math.imul(O,re)|0)+Math.imul(A,ne)|0,o=o+Math.imul(A,re)|0,r=r+Math.imul(g,oe)|0,i=(i=i+Math.imul(g,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0,r=r+Math.imul(E,se)|0,i=(i=i+Math.imul(E,ue)|0)+Math.imul(y,se)|0,o=o+Math.imul(y,ue)|0,r=r+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Te=(u+(r=r+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,be)|0)+Math.imul(h,pe)|0))<<13)|0;u=((o=o+Math.imul(h,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(B,H)|0,o=Math.imul(B,q),r=r+Math.imul(j,K)|0,i=(i=i+Math.imul(j,W)|0)+Math.imul(U,K)|0,o=o+Math.imul(U,W)|0,r=r+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Q)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Q)|0,r=r+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,ee)|0,r=r+Math.imul(N,ne)|0,i=(i=i+Math.imul(N,re)|0)+Math.imul(M,ne)|0,o=o+Math.imul(M,re)|0,r=r+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,r=r+Math.imul(g,se)|0,i=(i=i+Math.imul(g,ue)|0)+Math.imul(m,se)|0,o=o+Math.imul(m,ue)|0,r=r+Math.imul(E,le)|0,i=(i=i+Math.imul(E,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Ne=(u+(r=r+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;u=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,r=Math.imul(x,K),i=(i=Math.imul(x,W))+Math.imul(B,K)|0,o=Math.imul(B,W),r=r+Math.imul(j,J)|0,i=(i=i+Math.imul(j,Q)|0)+Math.imul(U,J)|0,o=o+Math.imul(U,Q)|0,r=r+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,ee)|0,r=r+Math.imul(C,ne)|0,i=(i=i+Math.imul(C,re)|0)+Math.imul(I,ne)|0,o=o+Math.imul(I,re)|0,r=r+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,r=r+Math.imul(O,se)|0,i=(i=i+Math.imul(O,ue)|0)+Math.imul(A,se)|0,o=o+Math.imul(A,ue)|0,r=r+Math.imul(g,le)|0,i=(i=i+Math.imul(g,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Me=(u+(r=r+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,be)|0)+Math.imul(y,pe)|0))<<13)|0;u=((o=o+Math.imul(y,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(x,J),i=(i=Math.imul(x,Q))+Math.imul(B,J)|0,o=Math.imul(B,Q),r=r+Math.imul(j,Z)|0,i=(i=i+Math.imul(j,ee)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,ee)|0,r=r+Math.imul(L,ne)|0,i=(i=i+Math.imul(L,re)|0)+Math.imul(R,ne)|0,o=o+Math.imul(R,re)|0,r=r+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,r=r+Math.imul(N,se)|0,i=(i=i+Math.imul(N,ue)|0)+Math.imul(M,se)|0,o=o+Math.imul(M,ue)|0,r=r+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var we=(u+(r=r+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,be)|0)+Math.imul(m,pe)|0))<<13)|0;u=((o=o+Math.imul(m,be)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(x,Z),i=(i=Math.imul(x,ee))+Math.imul(B,Z)|0,o=Math.imul(B,ee),r=r+Math.imul(j,ne)|0,i=(i=i+Math.imul(j,re)|0)+Math.imul(U,ne)|0,o=o+Math.imul(U,re)|0,r=r+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,r=r+Math.imul(C,se)|0,i=(i=i+Math.imul(C,ue)|0)+Math.imul(I,se)|0,o=o+Math.imul(I,ue)|0,r=r+Math.imul(N,le)|0,i=(i=i+Math.imul(N,he)|0)+Math.imul(M,le)|0,o=o+Math.imul(M,he)|0;var Ce=(u+(r=r+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,be)|0)+Math.imul(A,pe)|0))<<13)|0;u=((o=o+Math.imul(A,be)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(x,ne),i=(i=Math.imul(x,re))+Math.imul(B,ne)|0,o=Math.imul(B,re),r=r+Math.imul(j,oe)|0,i=(i=i+Math.imul(j,ae)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,ae)|0,r=r+Math.imul(L,se)|0,i=(i=i+Math.imul(L,ue)|0)+Math.imul(R,se)|0,o=o+Math.imul(R,ue)|0,r=r+Math.imul(C,le)|0,i=(i=i+Math.imul(C,he)|0)+Math.imul(I,le)|0,o=o+Math.imul(I,he)|0;var Ie=(u+(r=r+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(M,pe)|0))<<13)|0;u=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(x,oe),i=(i=Math.imul(x,ae))+Math.imul(B,oe)|0,o=Math.imul(B,ae),r=r+Math.imul(j,se)|0,i=(i=i+Math.imul(j,ue)|0)+Math.imul(U,se)|0,o=o+Math.imul(U,ue)|0,r=r+Math.imul(L,le)|0,i=(i=i+Math.imul(L,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Pe=(u+(r=r+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,be)|0)+Math.imul(I,pe)|0))<<13)|0;u=((o=o+Math.imul(I,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(x,se),i=(i=Math.imul(x,ue))+Math.imul(B,se)|0,o=Math.imul(B,ue),r=r+Math.imul(j,le)|0,i=(i=i+Math.imul(j,he)|0)+Math.imul(U,le)|0,o=o+Math.imul(U,he)|0;var Le=(u+(r=r+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,be)|0)+Math.imul(R,pe)|0))<<13)|0;u=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,r=Math.imul(x,le),i=(i=Math.imul(x,he))+Math.imul(B,le)|0,o=Math.imul(B,he);var Re=(u+(r=r+Math.imul(j,pe)|0)|0)+((8191&(i=(i=i+Math.imul(j,be)|0)+Math.imul(U,pe)|0))<<13)|0;u=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var De=(u+(r=Math.imul(x,pe))|0)+((8191&(i=(i=Math.imul(x,be))+Math.imul(B,pe)|0))<<13)|0;return u=((o=Math.imul(B,be))+(i>>>13)|0)+(De>>>26)|0,De&=67108863,s[0]=_e,s[1]=Ee,s[2]=ye,s[3]=ve,s[4]=ge,s[5]=me,s[6]=Se,s[7]=Oe,s[8]=Ae,s[9]=Te,s[10]=Ne,s[11]=Me,s[12]=we,s[13]=Ce,s[14]=Ie,s[15]=Pe,s[16]=Le,s[17]=Re,s[18]=De,0!==u&&(s[19]=u,n.length++),n};function p(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(d=h),o.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):n<63?h(this,e,t):n<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,o=0;o<n.length-1;o++){var a=i;i=0;for(var c=67108863&r,s=Math.min(o,t.length-1),u=Math.max(0,o-e.length+1);u<=s;u++){var f=o-u,l=(0|e.words[f])*(0|t.words[u]),h=67108863&l;c=67108863&(h=h+c|0),i+=(a=(a=a+(l/67108864|0)|0)+(h>>>26)|0)>>>26,a&=67108863}n.words[o]=c,r=a,a=i}return 0!==r?n.words[o]=r:n.length--,n.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=o.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},b.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(1&e)<<t-i-1,e>>=1;return r},b.prototype.permute=function(e,t,n,r,i,o){for(var a=0;a<o;a++)r[a]=t[e[a]],i[a]=n[e[a]]},b.prototype.transform=function(e,t,n,r,i,o){this.permute(o,e,t,n,r,i);for(var a=1;a<i;a<<=1)for(var c=a<<1,s=Math.cos(2*Math.PI/c),u=Math.sin(2*Math.PI/c),f=0;f<i;f+=c)for(var l=s,h=u,d=0;d<a;d++){var p=n[f+d],b=r[f+d],_=n[f+d+a],E=r[f+d+a],y=l*_-h*E;E=l*E+h*_,_=y,n[f+d]=p+_,r[f+d]=b+E,n[f+d+a]=p-_,r[f+d+a]=b-E,d!==c&&(y=s*l-u*h,h=s*h+u*l,l=y)}},b.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},b.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},b.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&i,n=i<67108864?0:i/67108864|0}return e},b.prototype.convert13b=function(e,t,n,i){for(var o=0,a=0;a<t;a++)o+=0|e[a],n[2*a]=8191&o,o>>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a<i;++a)n[a]=0;r(0===o),r(0==(-8192&o))},b.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},b.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),o=this.stub(r),a=new Array(r),c=new Array(r),s=new Array(r),u=new Array(r),f=new Array(r),l=new Array(r),h=n.words;h.length=r,this.convert13b(e.words,e.length,a,r),this.convert13b(t.words,t.length,u,r),this.transform(a,o,c,s,r,i),this.transform(u,o,f,l,r,i);for(var d=0;d<r;d++){var p=c[d]*f[d]-s[d]*l[d];s[d]=c[d]*l[d]+s[d]*f[d],c[d]=p}return this.conjugate(c,s,r),this.transform(c,s,h,o,r,i),this.conjugate(h,o,r),this.normalize13b(h,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n.strip()},o.prototype.mul=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},o.prototype.mulf=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),p(this,e,t)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){r("number"==typeof e),r(e<67108864);for(var t=0,n=0;n<this.length;n++){var i=(0|this.words[n])*e,o=(67108863&i)+(67108863&t);t>>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=(e.words[r]&1<<i)>>>i}return t}(e);if(0===t.length)return new o(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var i=n.sqr();r<t.length;r++,i=i.sqr())0!==t[r]&&(n=n.mul(i));return n},o.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t<this.length;t++){var c=this.words[t]&o,s=(0|this.words[t])-c<<n;this.words[t]=s|a,a=c>>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t<i;t++)this.words[t]=0;this.length+=i}return this.strip()},o.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},o.prototype.iushrn=function(e,t,n){var i;r("number"==typeof e&&e>=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),c=67108863^67108863>>>o<<o,s=n;if(i-=a,i=Math.max(0,i),s){for(var u=0;u<a;u++)s.words[u]=this.words[u];s.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=i);u--){var l=0|this.words[u];this.words[u]=f<<26-o|l>>>o,f=l&c}return s&&0!==f&&(s.words[s.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<<t;return!(this.length<=n)&&!!(this.words[n]&i)},o.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,t,n){var i,o,a=e.length+n;this._expand(a);var c=0;for(i=0;i<e.length;i++){o=(0|this.words[i+n])+c;var s=(0|e.words[i])*t;c=((o-=67108863&s)>>26)-(s/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)c=(o=(0|this.words[i+n])+c)>>26,this.words[i+n]=67108863&o;if(0===c)return this.strip();for(r(-1===c),c=0,i=0;i<this.length;i++)c=(o=-(0|this.words[i])+c)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),i=e,a=0|i.words[i.length-1];0!==(n=26-this._countBits(a))&&(i=i.ushln(n),r.iushln(n),a=0|i.words[i.length-1]);var c,s=r.length-i.length;if("mod"!==t){(c=new o(null)).length=s+1,c.words=new Array(c.length);for(var u=0;u<c.length;u++)c.words[u]=0}var f=r.clone()._ishlnsubmul(i,1,s);0===f.negative&&(r=f,c&&(c.words[s]=1));for(var l=s-1;l>=0;l--){var h=67108864*(0|r.words[i.length+l])+(0|r.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),r._ishlnsubmul(i,h,l);0!==r.negative;)h--,r.negative=0,r._ishlnsubmul(i,1,l),r.isZero()||(r.negative^=1);c&&(c.words[l]=h)}return c&&c.strip(),r.strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:c||null,mod:r}},o.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(c=this.neg().divmod(e,t),"mod"!==t&&(i=c.div.neg()),"div"!==t&&(a=c.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(c=this.divmod(e.neg(),t),"mod"!==t&&(i=c.div.neg()),{div:i,mod:c.mod}):0!=(this.negative&e.negative)?(c=this.neg().divmod(e.neg(),t),"div"!==t&&(a=c.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:c.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,c},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),i=e.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},o.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),c=new o(0),s=new o(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var f=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(f),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(n.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(c.isOdd()||s.isOdd())&&(c.iadd(f),s.isub(l)),c.iushrn(1),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),i.isub(c),a.isub(s)):(n.isub(t),c.isub(i),s.isub(a))}return{a:c,b:s,gcd:n.iushln(u)}},o.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),c=new o(0),s=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,f=1;0==(t.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)c.isOdd()&&c.iadd(s),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(c)):(n.isub(t),c.isub(a))}return(i=0===t.cmpn(1)?a:c).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var o=t;t=n,n=o}else if(0===i||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,a=n;0!==o&&a<this.length;a++){var c=0|this.words[a];o=(c+=o)>>>26,c&=67108863,this.words[a]=c}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:i<e?-1:1}return 0!==this.negative?0|-t:t},o.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],i=0|e.words[n];if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new S(e)},o.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var _={k256:null,p224:null,p192:null,p25519:null};function E(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){E.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){E.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function g(){E.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function m(){E.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}E.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},E.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):n.strip(),n},E.prototype.split=function(e,t){e.iushrn(this.n,0,t)},E.prototype.imulK=function(e){return e.imul(this.k)},i(y,E),y.prototype.split=function(e,t){for(var n=Math.min(e.length,9),r=0;r<n;r++)t.words[r]=e.words[r];if(t.length=n,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=4194303&i,r=10;r<e.length;r++){var o=0|e.words[r];e.words[r-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,e.words[r-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},y.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},i(v,E),i(g,E),i(m,E),m.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,i=67108863&r;r>>>=26,e.words[n]=i,t=r}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(_[e])return _[e];var t;if("k256"===e)t=new y;else if("p224"===e)t=new v;else if("p192"===e)t=new g;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new m}return _[e]=t,t},S.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);r(!i.isZero());var c=new o(1).toRed(this),s=c.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(s);)f.redIAdd(s);for(var l=this.pow(f,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(c);){for(var b=d,_=0;0!==b.cmp(c);_++)b=b.redSqr();r(_<p);var E=this.pow(l,new o(1).iushln(p-_-1));h=h.redMul(E),l=E.redSqr(),d=d.redMul(l),p=_}return h},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new o(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var i=n[0],a=0,c=0,s=t.bitLength()%26;for(0===s&&(s=26),r=t.length-1;r>=0;r--){for(var u=t.words[r],f=s-1;f>=0;f--){var l=u>>f&1;i!==n[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++c||0===r&&0===f)&&(i=this.mul(i,n[a]),c=0,a=0)):c=0}s=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new O(e)},i(O,S),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,n(188)(e))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NAMED_TAG="named",t.NAME_TAG="name",t.UNMANAGED_TAG="unmanaged",t.OPTIONAL_TAG="optional",t.INJECT_TAG="inject",t.MULTI_INJECT_TAG="multi_inject",t.TAGGED="inversify:tagged",t.TAGGED_PROP="inversify:tagged_props",t.PARAM_TYPES="inversify:paramtypes",t.DESIGN_PARAM_TYPES="design:paramtypes",t.POST_CONSTRUCT="post_construct"},function(e,t,n){e.exports=function(){"use strict";var e="millisecond",t="second",n="minute",r="hour",i="day",o="week",a="month",c="quarter",s="year",u=/^(\d{4})-?(\d{1,2})-?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d{1,3})?$/,f=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,l=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},h={s:l,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+l(r,2,"0")+":"+l(i,2,"0")},m:function(e,t){var n=12*(t.year()-e.year())+(t.month()-e.month()),r=e.clone().add(n,a),i=t-r<0,o=e.clone().add(n+(i?-1:1),a);return Number(-(n+(t-r)/(i?r-o:o-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(u){return{M:a,y:s,w:o,d:i,h:r,m:n,s:t,ms:e,Q:c}[u]||String(u||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},d={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},p="en",b={};b[p]=d;var _=function(e){return e instanceof g},E=function(e,t,n){var r;if(!e)return p;if("string"==typeof e)b[e]&&(r=e),t&&(b[e]=t,r=e);else{var i=e.name;b[i]=e,r=i}return n||(p=r),r},y=function(e,t,n){if(_(e))return e.clone();var r=t?"string"==typeof t?{format:t,pl:n}:t:{};return r.date=e,new g(r)},v=h;v.l=E,v.i=_,v.w=function(e,t){return y(e,{locale:t.$L,utc:t.$u,$offset:t.$offset})};var g=function(){function l(e){this.$L=this.$L||E(e.locale,null,!0),this.parse(e)}var h=l.prototype;return h.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(v.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(u);if(r)return n?new Date(Date.UTC(r[1],r[2]-1,r[3]||1,r[4]||0,r[5]||0,r[6]||0,r[7]||0)):new Date(r[1],r[2]-1,r[3]||1,r[4]||0,r[5]||0,r[6]||0,r[7]||0)}return new Date(t)}(e),this.init()},h.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},h.$utils=function(){return v},h.isValid=function(){return!("Invalid Date"===this.$d.toString())},h.isSame=function(e,t){var n=y(e);return this.startOf(t)<=n&&n<=this.endOf(t)},h.isAfter=function(e,t){return y(e)<this.startOf(t)},h.isBefore=function(e,t){return this.endOf(t)<y(e)},h.$g=function(e,t,n){return v.u(e)?this[t]:this.set(n,e)},h.year=function(e){return this.$g(e,"$y",s)},h.month=function(e){return this.$g(e,"$M",a)},h.day=function(e){return this.$g(e,"$W",i)},h.date=function(e){return this.$g(e,"$D","date")},h.hour=function(e){return this.$g(e,"$H",r)},h.minute=function(e){return this.$g(e,"$m",n)},h.second=function(e){return this.$g(e,"$s",t)},h.millisecond=function(t){return this.$g(t,"$ms",e)},h.unix=function(){return Math.floor(this.valueOf()/1e3)},h.valueOf=function(){return this.$d.getTime()},h.startOf=function(e,c){var u=this,f=!!v.u(c)||c,l=v.p(e),h=function(e,t){var n=v.w(u.$u?Date.UTC(u.$y,t,e):new Date(u.$y,t,e),u);return f?n:n.endOf(i)},d=function(e,t){return v.w(u.toDate()[e].apply(u.toDate(),(f?[0,0,0,0]:[23,59,59,999]).slice(t)),u)},p=this.$W,b=this.$M,_=this.$D,E="set"+(this.$u?"UTC":"");switch(l){case s:return f?h(1,0):h(31,11);case a:return f?h(1,b):h(0,b+1);case o:var y=this.$locale().weekStart||0,g=(p<y?p+7:p)-y;return h(f?_-g:_+(6-g),b);case i:case"date":return d(E+"Hours",0);case r:return d(E+"Minutes",1);case n:return d(E+"Seconds",2);case t:return d(E+"Milliseconds",3);default:return this.clone()}},h.endOf=function(e){return this.startOf(e,!1)},h.$set=function(o,c){var u,f=v.p(o),l="set"+(this.$u?"UTC":""),h=(u={},u[i]=l+"Date",u.date=l+"Date",u[a]=l+"Month",u[s]=l+"FullYear",u[r]=l+"Hours",u[n]=l+"Minutes",u[t]=l+"Seconds",u[e]=l+"Milliseconds",u)[f],d=f===i?this.$D+(c-this.$W):c;if(f===a||f===s){var p=this.clone().set("date",1);p.$d[h](d),p.init(),this.$d=p.set("date",Math.min(this.$D,p.daysInMonth())).toDate()}else h&&this.$d[h](d);return this.init(),this},h.set=function(e,t){return this.clone().$set(e,t)},h.get=function(e){return this[v.p(e)]()},h.add=function(e,c){var u,f=this;e=Number(e);var l=v.p(c),h=function(t){var n=y(f);return v.w(n.date(n.date()+Math.round(t*e)),f)};if(l===a)return this.set(a,this.$M+e);if(l===s)return this.set(s,this.$y+e);if(l===i)return h(1);if(l===o)return h(7);var d=(u={},u[n]=6e4,u[r]=36e5,u[t]=1e3,u)[l]||1,p=this.$d.getTime()+e*d;return v.w(p,this)},h.subtract=function(e,t){return this.add(-1*e,t)},h.format=function(e){var t=this;if(!this.isValid())return"Invalid Date";var n=e||"YYYY-MM-DDTHH:mm:ssZ",r=v.z(this),i=this.$locale(),o=this.$H,a=this.$m,c=this.$M,s=i.weekdays,u=i.months,l=function(e,r,i,o){return e&&(e[r]||e(t,n))||i[r].substr(0,o)},h=function(e){return v.s(o%12||12,e,"0")},d=i.meridiem||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r},p={YY:String(this.$y).slice(-2),YYYY:this.$y,M:c+1,MM:v.s(c+1,2,"0"),MMM:l(i.monthsShort,c,u,3),MMMM:u[c]||u(this,n),D:this.$D,DD:v.s(this.$D,2,"0"),d:String(this.$W),dd:l(i.weekdaysMin,this.$W,s,2),ddd:l(i.weekdaysShort,this.$W,s,3),dddd:s[this.$W],H:String(o),HH:v.s(o,2,"0"),h:h(1),hh:h(2),a:d(o,a,!0),A:d(o,a,!1),m:String(a),mm:v.s(a,2,"0"),s:String(this.$s),ss:v.s(this.$s,2,"0"),SSS:v.s(this.$ms,3,"0"),Z:r};return n.replace(f,(function(e,t){return t||p[e]||r.replace(":","")}))},h.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},h.diff=function(e,u,f){var l,h=v.p(u),d=y(e),p=6e4*(d.utcOffset()-this.utcOffset()),b=this-d,_=v.m(this,d);return _=(l={},l[s]=_/12,l[a]=_,l[c]=_/3,l[o]=(b-p)/6048e5,l[i]=(b-p)/864e5,l[r]=b/36e5,l[n]=b/6e4,l[t]=b/1e3,l)[h]||b,f?_:v.a(_)},h.daysInMonth=function(){return this.endOf(a).$D},h.$locale=function(){return b[this.$L]},h.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=E(e,t,!0);return r&&(n.$L=r),n},h.clone=function(){return v.w(this.$d,this)},h.toDate=function(){return new Date(this.valueOf())},h.toJSON=function(){return this.isValid()?this.toISOString():null},h.toISOString=function(){return this.$d.toISOString()},h.toString=function(){return this.$d.toUTCString()},l}();return y.prototype=g.prototype,y.extend=function(e,t){return e(t,g,y),y},y.locale=E,y.isDayjs=_,y.unix=function(e){return y(1e3*e)},y.en=b[p],y.Ls=b,y}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DUPLICATED_INJECTABLE_DECORATOR="Cannot apply @injectable decorator multiple times.",t.DUPLICATED_METADATA="Metadata key was used more than once in a parameter:",t.NULL_ARGUMENT="NULL argument",t.KEY_NOT_FOUND="Key Not Found",t.AMBIGUOUS_MATCH="Ambiguous match found for serviceIdentifier:",t.CANNOT_UNBIND="Could not unbind serviceIdentifier:",t.NOT_REGISTERED="No matching bindings found for serviceIdentifier:",t.MISSING_INJECTABLE_ANNOTATION="Missing required @injectable annotation in:",t.MISSING_INJECT_ANNOTATION="Missing required @inject or @multiInject annotation in:",t.UNDEFINED_INJECT_ANNOTATION=function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifer to overcome this limitation."},t.CIRCULAR_DEPENDENCY="Circular dependency found:",t.NOT_IMPLEMENTED="Sorry, this feature is not fully implemented yet.",t.INVALID_BINDING_TYPE="Invalid binding type:",t.NO_MORE_SNAPSHOTS_AVAILABLE="No snapshot available to restore.",t.INVALID_MIDDLEWARE_RETURN="Invalid return type in middleware. Middleware must return!",t.INVALID_FUNCTION_BINDING="Value provided to function binding must be a function!",t.INVALID_TO_SELF_VALUE="The toSelf function can only be applied when a constructor is used as service identifier",t.INVALID_DECORATOR_OPERATION="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",t.ARGUMENTS_LENGTH_MISMATCH=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."},t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT="Invalid Container constructor argument. Container options must be an object.",t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE="Invalid Container option. Default scope must be a string ('singleton' or 'transient').",t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE="Invalid Container option. Auto bind injectable must be a boolean",t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK="Invalid Container option. Skip base check must be a boolean",t.MULTIPLE_POST_CONSTRUCT_METHODS="Cannot apply @postConstruct decorator multiple times in the same class",t.POST_CONSTRUCT_ERROR=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"@postConstruct error in class "+e[0]+": "+e[1]},t.CIRCULAR_DEPENDENCY_IN_FACTORY=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"It looks like there is a circular dependency in one of the '"+e[0]+"' bindings. Please investigate bindings withservice identifier '"+e[1]+"'."},t.STACK_OVERFLOW="Maximum call stack size exceeded"},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var s,u=[],f=!1,l=-1;function h(){f&&s&&(f=!1,s.length?u=s.concat(u):l=-1,u.length&&d())}function d(){if(!f){var e=c(h);f=!0;for(var t=u.length;t;){for(s=u,u=[];++l<t;)s&&s[l].run();l=-1,t=u.length}s=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function b(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new p(e,t)),1!==u.length||f||c(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=b,i.addListener=b,i.once=b,i.off=b,i.removeListener=b,i.removeAllListeners=b,i.emit=b,i.prependListener=b,i.prependOnceListener=b,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t){function n(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=n,n.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)}},function(e,t,n){"use strict";var r=t,i=n(6),o=n(11),a=n(96);r.assert=o,r.toArray=a.toArray,r.zero2=a.zero2,r.toHex=a.toHex,r.encode=a.encode,r.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var i=1<<t+1,o=e.clone(),a=0;a<r.length;a++){var c,s=o.andln(i-1);o.isOdd()?(c=s>(i>>1)-1?(i>>1)-s:s,o.isubn(c)):c=0,r[a]=c,o.iushrn(1)}return r},r.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r=0,i=0;e.cmpn(-r)>0||t.cmpn(-i)>0;){var o,a,c,s=e.andln(3)+r&3,u=t.andln(3)+i&3;if(3===s&&(s=-1),3===u&&(u=-1),0==(1&s))o=0;else o=3!==(c=e.andln(7)+r&7)&&5!==c||2!==u?s:-s;if(n[0].push(o),0==(1&u))a=0;else a=3!==(c=t.andln(7)+i&7)&&5!==c||2!==s?u:-u;n[1].push(a),2*r===o+1&&(r=1-r),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n},r.cachedProperty=function(e,t,n){var r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return this.key===r.NAMED_TAG?"named: "+this.value.toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+this.value+" }"},e}();t.Metadata=i},function(e,t,n){"use strict";var r=n(246),i=n(247),o=n(114);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17),i=n(116),o=n(250),a=function(){function e(e){this.dictionary=new o.default(e)}return e.prototype.contains=function(e){return this.dictionary.containsKey(e)},e.prototype.add=function(e){return!this.contains(e)&&!r.isUndefined(e)&&(this.dictionary.setValue(e,e),!0)},e.prototype.intersection=function(e){var t=this;this.forEach((function(n){return e.contains(n)||t.remove(n),!0}))},e.prototype.union=function(e){var t=this;e.forEach((function(e){return t.add(e),!0}))},e.prototype.difference=function(e){var t=this;e.forEach((function(e){return t.remove(e),!0}))},e.prototype.isSubsetOf=function(e){if(this.size()>e.size())return!1;var t=!0;return this.forEach((function(n){return!!e.contains(n)||(t=!1,!1)})),t},e.prototype.remove=function(e){return!!this.contains(e)&&(this.dictionary.remove(e),!0)},e.prototype.forEach=function(e){this.dictionary.forEach((function(t,n){return e(n)}))},e.prototype.toArray=function(){return this.dictionary.values()},e.prototype.isEmpty=function(){return this.dictionary.isEmpty()},e.prototype.size=function(){return this.dictionary.size()},e.prototype.clear=function(){this.dictionary.clear()},e.prototype.toString=function(){return i.toString(this.toArray())},e}();t.default=a},function(e,t,n){"use strict";var r=n(11),i=n(4);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function c(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i<e.length;i+=2)n.push(parseInt(e[i]+e[i+1],16))}else for(var r=0,i=0;i<e.length;i++){var a=e.charCodeAt(i);a<128?n[r++]=a:a<2048?(n[r++]=a>>6|192,n[r++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),n[r++]=a>>18|240,n[r++]=a>>12&63|128,n[r++]=a>>6&63|128,n[r++]=63&a|128):(n[r++]=a>>12|224,n[r++]=a>>6&63|128,n[r++]=63&a|128)}else for(i=0;i<e.length;i++)n[i]=0|e[i];return n},t.toHex=function(e){for(var t="",n=0;n<e.length;n++)t+=c(e[n].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var n="",r=0;r<e.length;r++){var i=e[r];"little"===t&&(i=a(i)),n+=s(i.toString(16))}return n},t.zero2=c,t.zero8=s,t.join32=function(e,t,n,i){var o=n-t;r(o%4==0);for(var a=new Array(o/4),c=0,s=t;c<a.length;c++,s+=4){var u;u="big"===i?e[s]<<24|e[s+1]<<16|e[s+2]<<8|e[s+3]:e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s],a[c]=u>>>0}return a},t.split32=function(e,t){for(var n=new Array(4*e.length),r=0,i=0;r<e.length;r++,i+=4){var o=e[r];"big"===t?(n[i]=o>>>24,n[i+1]=o>>>16&255,n[i+2]=o>>>8&255,n[i+3]=255&o):(n[i+3]=o>>>24,n[i+2]=o>>>16&255,n[i+1]=o>>>8&255,n[i]=255&o)}return n},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,n){return e+t+n>>>0},t.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},t.sum32_5=function(e,t,n,r,i){return e+t+n+r+i>>>0},t.sum64=function(e,t,n,r){var i=e[t],o=r+e[t+1]>>>0,a=(o<r?1:0)+n+i;e[t]=a>>>0,e[t+1]=o},t.sum64_hi=function(e,t,n,r){return(t+r>>>0<t?1:0)+e+n>>>0},t.sum64_lo=function(e,t,n,r){return t+r>>>0},t.sum64_4_hi=function(e,t,n,r,i,o,a,c){var s=0,u=t;return s+=(u=u+r>>>0)<t?1:0,s+=(u=u+o>>>0)<o?1:0,e+n+i+a+(s+=(u=u+c>>>0)<c?1:0)>>>0},t.sum64_4_lo=function(e,t,n,r,i,o,a,c){return t+r+o+c>>>0},t.sum64_5_hi=function(e,t,n,r,i,o,a,c,s,u){var f=0,l=t;return f+=(l=l+r>>>0)<t?1:0,f+=(l=l+o>>>0)<o?1:0,f+=(l=l+c>>>0)<c?1:0,e+n+i+a+s+(f+=(l=l+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,n,r,i,o,a,c,s,u){return t+r+o+c+u>>>0},t.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},t.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},t.shr64_hi=function(e,t,n){return e>>>n},t.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty;function i(e){return"function"==typeof e}function o(e){return void 0===e}function a(e){return"[object String]"===Object.prototype.toString.call(e)}t.has=function(e,t){return r.call(e,t)},t.defaultCompare=function(e,t){return e<t?-1:e===t?0:1},t.defaultEquals=function(e,t){return e===t},t.defaultToString=function(e){return null===e?"COLLECTION_NULL":o(e)?"COLLECTION_UNDEFINED":a(e)?"$s"+e:"$o"+e.toString()},t.makeString=function(e,n){if(void 0===n&&(n=","),null===e)return"COLLECTION_NULL";if(o(e))return"COLLECTION_UNDEFINED";if(a(e))return e.toString();var r="{",i=!0;for(var c in e)t.has(e,c)&&(i?i=!1:r+=n,r=r+c+":"+e[c]);return r+"}"},t.isFunction=i,t.isUndefined=o,t.isString=a,t.reverseCompareFunction=function(e){return o(e)||!i(e)?function(e,t){return e<t?1:e===t?0:-1}:function(t,n){return-1*e(t,n)}},t.compareToEquals=function(e){return function(t,n){return 0===e(t,n)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BindingScopeEnum={Request:"Request",Singleton:"Singleton",Transient:"Transient"};t.BindingTypeEnum={ConstantValue:"ConstantValue",Constructor:"Constructor",DynamicValue:"DynamicValue",Factory:"Factory",Function:"Function",Instance:"Instance",Invalid:"Invalid",Provider:"Provider"};t.TargetTypeEnum={ClassProperty:"ClassProperty",ConstructorArgument:"ConstructorArgument",Variable:"Variable"}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(7);function o(e,t,n,i,o){var a={},c="number"==typeof o,s=void 0!==o&&c?o.toString():n;if(c&&void 0!==n)throw new Error(r.INVALID_DECORATOR_OPERATION);Reflect.hasOwnMetadata(e,t)&&(a=Reflect.getMetadata(e,t));var u=a[s];if(Array.isArray(u))for(var f=0,l=u;f<l.length;f++){var h=l[f];if(h.key===i.key)throw new Error(r.DUPLICATED_METADATA+" "+h.key.toString())}else u=[];u.push(i),a[s]=u,Reflect.defineMetadata(e,a,t)}function a(e,t){Reflect.decorate(e,t)}function c(e,t){return function(n,r){t(n,r,e)}}t.tagParameter=function(e,t,n,r){o(i.TAGGED,e,t,r,n)},t.tagProperty=function(e,t,n){o(i.TAGGED_PROP,e.constructor,t,n)},t.decorate=function(e,t,n){"number"==typeof n?a([c(n,e)],t):"string"==typeof n?Reflect.decorate([e],t,n):a([e],t)}},function(e,t,n){var r=n(3).Buffer,i=n(24).Transform,o=n(48).StringDecoder;function a(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}n(4)(a,i),a.prototype.update=function(e,t,n){"string"==typeof e&&(e=r.from(e,t));var i=this._update(e);return this.hashMode?this:(n&&(i=this._toString(i,n)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,n){var r;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){r=e}finally{n(r)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||r.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,n){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var r=this._decoder.write(e);return n&&(r+=this._decoder.end()),r},e.exports=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=0;t.id=function(){return r++}},function(e,t,n){"use strict";var r=n(35),i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=l;var o=Object.create(n(29));o.inherits=n(4);var a=n(72),c=n(47);o.inherits(l,a);for(var s=i(c.prototype),u=0;u<s.length;u++){var f=s[u];l.prototype[f]||(l.prototype[f]=c.prototype[f])}function l(e){if(!(this instanceof l))return new l(e);a.call(this,e),c.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",h)}function h(){this.allowHalfOpen||this._writableState.ended||r.nextTick(d,this)}function d(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),l.prototype._destroy=function(e,t){this.push(null),this.end(),r.nextTick(t,e)}},function(e,t,n){e.exports=i;var r=n(45).EventEmitter;function i(){r.call(this)}n(4)(i,r),i.Readable=n(46),i.Writable=n(158),i.Duplex=n(159),i.Transform=n(160),i.PassThrough=n(161),i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(n.on("end",c),n.on("close",s));var a=!1;function c(){a||(a=!0,e.end())}function s(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function u(e){if(f(),0===r.listenerCount(this,"error"))throw e}function f(){n.removeListener("data",i),e.removeListener("drain",o),n.removeListener("end",c),n.removeListener("close",s),n.removeListener("error",u),e.removeListener("error",u),n.removeListener("end",f),n.removeListener("close",f),e.removeListener("close",f)}return n.on("error",u),e.on("error",u),n.on("end",f),n.on("close",f),e.on("close",f),e.emit("pipe",n),e}},function(e,t,n){"use strict";(function(t,r){var i=n(3).Buffer,o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var n=i.allocUnsafe(e);if(e>0)if(e>65536)for(var a=0;a<e;a+=65536)o.getRandomValues(n.slice(a,a+65536));else o.getRandomValues(n);if("function"==typeof t)return r.nextTick((function(){t(null,n)}));return n}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,n(19),n(10))},function(e,t,n){var r=n(3).Buffer;function i(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var n=this._block,i=this._blockSize,o=e.length,a=this._len,c=0;c<o;){for(var s=a%i,u=Math.min(o-c,i-s),f=0;f<u;f++)n[s+f]=e[c+f];c+=u,(a+=u)%i==0&&this._update(n)}return this._len+=o,this},i.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=8*this._len;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var r=(4294967295&n)>>>0,i=(n-r)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=i},function(e,t,n){var r,i,o,a,c,s,u,f;e.exports=(f=n(115),i=(r=f).lib,o=i.WordArray,a=i.Hasher,c=r.algo,s=[],u=c.SHA1=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],c=n[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var f=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=f<<1|f>>>31}var l=(r<<5|r>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=a._createHelper(u),r.HmacSHA1=a._createHmacHelper(u),f.SHA1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9);function i(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function o(e){if(e.name)return e.name;var t=e.toString(),n=t.match(/^function\s*([^\s(]+)/);return n?n[1]:"Anonymous function: "+t}t.getServiceIdentifierAsString=i,t.listRegisteredBindingsForServiceIdentifier=function(e,t,n){var r="",i=n(e,t);return 0!==i.length&&(r="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=o(e.implementationType)),r=r+"\n "+t,e.constraint.metaData&&(r=r+" - "+e.constraint.metaData)}))),r},t.circularDependencyToException=function e(t){t.childRequests.forEach((function(t){if(function e(t,n){return null!==t.parentRequest&&(t.parentRequest.serviceIdentifier===n||e(t.parentRequest,n))}(t,t.serviceIdentifier)){var n=function(e){return function e(t,n){void 0===n&&(n=[]);var r=i(t.serviceIdentifier);return n.push(r),null!==t.parentRequest?e(t.parentRequest,n):n}(e).reverse().join(" --\x3e ")}(t);throw new Error(r.CIRCULAR_DEPENDENCY+" "+n)}e(t)}))},t.listMetadataForTarget=function(e,t){if(t.isTagged()||t.isNamed()){var n="",r=t.getNamedTag(),i=t.getCustomTags();return null!==r&&(n+=r.toString()+"\n"),null!==i&&i.forEach((function(e){n+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+n}return" "+e},t.getFunctionName=o},function(e,t,n){(function(e){function n(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===n(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===n(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===n(e)},t.isError=function(e){return"[object Error]"===n(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,n(5).Buffer)},function(e,t,n){"use strict";var r=n(4),i=n(49),o=n(50),a=n(51),c=n(21);function s(e){c.call(this,"digest"),this._hash=e}r(s,c),s.prototype._update=function(e){this._hash.update(e)},s.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new i:"rmd160"===e||"ripemd160"===e?new o:new s(a(e))}},function(e,t,n){(function(t){e.exports=function(e,n){for(var r=Math.min(e.length,n.length),i=new t(r),o=0;o<r;++o)i[o]=e[o]^n[o];return i}}).call(this,n(5).Buffer)},function(e,t,n){"use strict";var r=n(16),i=n(11);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-n,this.endian);for(var i=0;i<e.length;i+=this._delta32)this._update(e,i,i+this._delta32)}return this},o.prototype.digest=function(e){return this.update(this._pad()),i(null===this.pending),this._digest(e)},o.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,n=t-(e+this.padLength)%t,r=new Array(n+this.padLength);r[0]=128;for(var i=1;i<n;i++)r[i]=0;if(e<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)r[i++]=0;r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=e>>>24&255,r[i++]=e>>>16&255,r[i++]=e>>>8&255,r[i++]=255&e}else for(r[i++]=255&e,r[i++]=e>>>8&255,r[i++]=e>>>16&255,r[i++]=e>>>24&255,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,o=8;o<this.padLength;o++)r[i++]=0;return r}},function(e,t,n){var r=t;r.bignum=n(6),r.define=n(214).define,r.base=n(34),r.constants=n(102),r.decoders=n(219),r.encoders=n(221)},function(e,t,n){var r=t;r.Reporter=n(216).Reporter,r.DecoderBuffer=n(101).DecoderBuffer,r.EncoderBuffer=n(101).EncoderBuffer,r.Node=n(217)},function(e,t,n){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,c=arguments.length;switch(c){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,n)}));case 3:return t.nextTick((function(){e.call(null,n,r)}));case 4:return t.nextTick((function(){e.call(null,n,r,i)}));default:for(o=new Array(c-1),a=0;a<o.length;)o[a++]=arguments[a];return t.nextTick((function(){e.apply(null,o)}))}}}:e.exports=t}).call(this,n(10))},function(e,t,n){(function(e){var r=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},i=/%[sdj%]/g;t.format=function(e){if(!E(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(c(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,a=String(e).replace(i,(function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<o;s=r[++n])b(s)||!g(s)?a+=" "+s:a+=" "+c(s);return a},t.deprecate=function(n,r){if(void 0!==e&&!0===e.noDeprecation)return n;if(void 0===e)return function(){return t.deprecate(n,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(e.throwDeprecation)throw new Error(r);e.traceDeprecation?console.trace(r):console.error(r),i=!0}return n.apply(this,arguments)}};var o,a={};function c(e,n){var r={seen:[],stylize:u};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),p(n)?r.showHidden=n:n&&t._extend(r,n),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),f(r,e,r.depth)}function s(e,t){var n=c.styles[t];return n?"["+c.colors[n][0]+"m"+e+"["+c.colors[n][1]+"m":e}function u(e,t){return e}function f(e,n,r){if(e.customInspect&&n&&O(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return E(i)||(i=f(e,i,r)),i}var o=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(E(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(_(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,n);if(o)return o;var a=Object.keys(n),c=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),S(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(n);if(0===a.length){if(O(n)){var s=n.name?": "+n.name:"";return e.stylize("[Function"+s+"]","special")}if(v(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(m(n))return e.stylize(Date.prototype.toString.call(n),"date");if(S(n))return l(n)}var u,g="",A=!1,T=["{","}"];(d(n)&&(A=!0,T=["[","]"]),O(n))&&(g=" [Function"+(n.name?": "+n.name:"")+"]");return v(n)&&(g=" "+RegExp.prototype.toString.call(n)),m(n)&&(g=" "+Date.prototype.toUTCString.call(n)),S(n)&&(g=" "+l(n)),0!==a.length||A&&0!=n.length?r<0?v(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),u=A?function(e,t,n,r,i){for(var o=[],a=0,c=t.length;a<c;++a)w(t,String(a))?o.push(h(e,t,n,r,String(a),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))})),o}(e,n,r,c,a):a.map((function(t){return h(e,n,r,c,t,A)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(u,g,T)):T[0]+g+T[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var a,c,s;if((s=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?c=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(c=e.stylize("[Setter]","special")),w(r,i)||(a="["+i+"]"),c||(e.seen.indexOf(s.value)<0?(c=b(n)?f(e,s.value,null):f(e,s.value,n-1)).indexOf("\n")>-1&&(c=o?c.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+c.split("\n").map((function(e){return" "+e})).join("\n")):c=e.stylize("[Circular]","special")),y(a)){if(o&&i.match(/^\d+$/))return c;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+c}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function _(e){return"number"==typeof e}function E(e){return"string"==typeof e}function y(e){return void 0===e}function v(e){return g(e)&&"[object RegExp]"===A(e)}function g(e){return"object"==typeof e&&null!==e}function m(e){return g(e)&&"[object Date]"===A(e)}function S(e){return g(e)&&("[object Error]"===A(e)||e instanceof Error)}function O(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(y(o)&&(o=e.env.NODE_DEBUG||""),n=n.toUpperCase(),!a[n])if(new RegExp("\\b"+n+"\\b","i").test(o)){var r=e.pid;a[n]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",n,r,e)}}else a[n]=function(){};return a[n]},t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=p,t.isNull=b,t.isNullOrUndefined=function(e){return null==e},t.isNumber=_,t.isString=E,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=y,t.isRegExp=v,t.isObject=g,t.isDate=m,t.isError=S,t.isFunction=O,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(162);var N=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(){var e=new Date,t=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":");return[e.getDate(),N[e.getMonth()],t].join(" ")}function w(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",M(),t.format.apply(t,arguments))},t.inherits=n(4),t._extend=function(e,t){if(!t||!g(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var C="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function I(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(C&&e[C]){var t;if("function"!=typeof(t=e[C]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,C,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),C&&Object.defineProperty(t,C,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,r(e))},t.promisify.custom=C,t.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var i=n.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,n).then((function(t){e.nextTick(a,null,t)}),(function(t){e.nextTick(I,t,a)}))}return Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.defineProperties(n,r(t)),n}}).call(this,n(10))},function(e,t,n){var r=n(3).Buffer;function i(e){r.isBuffer(e)||(e=r.from(e));for(var t=e.length/4|0,n=new Array(t),i=0;i<t;i++)n[i]=e.readUInt32BE(4*i);return n}function o(e){for(;0<e.length;e++)e[0]=0}function a(e,t,n,r,i){for(var o,a,c,s,u=n[0],f=n[1],l=n[2],h=n[3],d=e[0]^t[0],p=e[1]^t[1],b=e[2]^t[2],_=e[3]^t[3],E=4,y=1;y<i;y++)o=u[d>>>24]^f[p>>>16&255]^l[b>>>8&255]^h[255&_]^t[E++],a=u[p>>>24]^f[b>>>16&255]^l[_>>>8&255]^h[255&d]^t[E++],c=u[b>>>24]^f[_>>>16&255]^l[d>>>8&255]^h[255&p]^t[E++],s=u[_>>>24]^f[d>>>16&255]^l[p>>>8&255]^h[255&b]^t[E++],d=o,p=a,b=c,_=s;return o=(r[d>>>24]<<24|r[p>>>16&255]<<16|r[b>>>8&255]<<8|r[255&_])^t[E++],a=(r[p>>>24]<<24|r[b>>>16&255]<<16|r[_>>>8&255]<<8|r[255&d])^t[E++],c=(r[b>>>24]<<24|r[_>>>16&255]<<16|r[d>>>8&255]<<8|r[255&p])^t[E++],s=(r[_>>>24]<<24|r[d>>>16&255]<<16|r[p>>>8&255]<<8|r[255&b])^t[E++],[o>>>=0,a>>>=0,c>>>=0,s>>>=0]}var c=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var n=[],r=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,c=0,s=0;s<256;++s){var u=c^c<<1^c<<2^c<<3^c<<4;u=u>>>8^255&u^99,n[a]=u,r[u]=a;var f=e[a],l=e[f],h=e[l],d=257*e[u]^16843008*u;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*h^65537*l^257*f^16843008*a,o[0][u]=d<<24|d>>>8,o[1][u]=d<<16|d>>>16,o[2][u]=d<<8|d>>>24,o[3][u]=d,0===a?a=c=1:(a=f^e[e[e[h^f]]],c^=e[e[c]])}return{SBOX:n,INV_SBOX:r,SUB_MIX:i,INV_SUB_MIX:o}}();function u(e){this._key=i(e),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var e=this._key,t=e.length,n=t+6,r=4*(n+1),i=[],o=0;o<t;o++)i[o]=e[o];for(o=t;o<r;o++){var a=i[o-1];o%t==0?(a=a<<8|a>>>24,a=s.SBOX[a>>>24]<<24|s.SBOX[a>>>16&255]<<16|s.SBOX[a>>>8&255]<<8|s.SBOX[255&a],a^=c[o/t|0]<<24):t>6&&o%t==4&&(a=s.SBOX[a>>>24]<<24|s.SBOX[a>>>16&255]<<16|s.SBOX[a>>>8&255]<<8|s.SBOX[255&a]),i[o]=i[o-t]^a}for(var u=[],f=0;f<r;f++){var l=r-f,h=i[l-(f%4?0:4)];u[f]=f<4||l<=4?h:s.INV_SUB_MIX[0][s.SBOX[h>>>24]]^s.INV_SUB_MIX[1][s.SBOX[h>>>16&255]]^s.INV_SUB_MIX[2][s.SBOX[h>>>8&255]]^s.INV_SUB_MIX[3][s.SBOX[255&h]]}this._nRounds=n,this._keySchedule=i,this._invKeySchedule=u},u.prototype.encryptBlockRaw=function(e){return a(e=i(e),this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},u.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),n=r.allocUnsafe(16);return n.writeUInt32BE(t[0],0),n.writeUInt32BE(t[1],4),n.writeUInt32BE(t[2],8),n.writeUInt32BE(t[3],12),n},u.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var n=a(e,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),o=r.allocUnsafe(16);return o.writeUInt32BE(n[0],0),o.writeUInt32BE(n[3],4),o.writeUInt32BE(n[2],8),o.writeUInt32BE(n[1],12),o},u.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},e.exports.AES=u},function(e,t,n){var r=n(3).Buffer,i=n(49);e.exports=function(e,t,n,o){if(r.isBuffer(e)||(e=r.from(e,"binary")),t&&(r.isBuffer(t)||(t=r.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var a=n/8,c=r.alloc(a),s=r.alloc(o||0),u=r.alloc(0);a>0||o>0;){var f=new i;f.update(u),f.update(e),t&&f.update(t),u=f.digest();var l=0;if(a>0){var h=c.length-a;l=Math.min(a,u.length),u.copy(c,h,0,l),a-=l}if(l<u.length&&o>0){var d=s.length-o,p=Math.min(o,u.length-l);u.copy(s,d,l,l+p),o-=p}}return u.fill(0),{key:c,iv:s}}},function(e,t,n){"use strict";var r=n(6),i=n(12),o=i.getNAF,a=i.getJSF,c=i.assert;function s(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=s,s.prototype.point=function(){throw new Error("Not implemented")},s.prototype.validate=function(){throw new Error("Not implemented")},s.prototype._fixedNafMul=function(e,t){c(e.precomputed);var n=e._getDoubles(),r=o(t,1,this._bitLength),i=(1<<n.step+1)-(n.step%2==0?2:1);i/=3;for(var a=[],s=0;s<r.length;s+=n.step){var u=0;for(t=s+n.step-1;t>=s;t--)u=(u<<1)+r[t];a.push(u)}for(var f=this.jpoint(null,null,null),l=this.jpoint(null,null,null),h=i;h>0;h--){for(s=0;s<a.length;s++){(u=a[s])===h?l=l.mixedAdd(n.points[s]):u===-h&&(l=l.mixedAdd(n.points[s].neg()))}f=f.add(l)}return f.toP()},s.prototype._wnafMul=function(e,t){var n=4,r=e._getNAFPoints(n);n=r.wnd;for(var i=r.points,a=o(t,n,this._bitLength),s=this.jpoint(null,null,null),u=a.length-1;u>=0;u--){for(t=0;u>=0&&0===a[u];u--)t++;if(u>=0&&t++,s=s.dblp(t),u<0)break;var f=a[u];c(0!==f),s="affine"===e.type?f>0?s.mixedAdd(i[f-1>>1]):s.mixedAdd(i[-f-1>>1].neg()):f>0?s.add(i[f-1>>1]):s.add(i[-f-1>>1].neg())}return"affine"===e.type?s.toP():s},s.prototype._wnafMulAdd=function(e,t,n,r,i){for(var c=this._wnafT1,s=this._wnafT2,u=this._wnafT3,f=0,l=0;l<r;l++){var h=(T=t[l])._getNAFPoints(e);c[l]=h.wnd,s[l]=h.points}for(l=r-1;l>=1;l-=2){var d=l-1,p=l;if(1===c[d]&&1===c[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var _=[-3,-1,-5,-7,0,7,5,1,3],E=a(n[d],n[p]);f=Math.max(E[0].length,f),u[d]=new Array(f),u[p]=new Array(f);for(var y=0;y<f;y++){var v=0|E[0][y],g=0|E[1][y];u[d][y]=_[3*(v+1)+(g+1)],u[p][y]=0,s[d]=b}}else u[d]=o(n[d],c[d],this._bitLength),u[p]=o(n[p],c[p],this._bitLength),f=Math.max(u[d].length,f),f=Math.max(u[p].length,f)}var m=this.jpoint(null,null,null),S=this._wnafT4;for(l=f;l>=0;l--){for(var O=0;l>=0;){var A=!0;for(y=0;y<r;y++)S[y]=0|u[y][l],0!==S[y]&&(A=!1);if(!A)break;O++,l--}if(l>=0&&O++,m=m.dblp(O),l<0)break;for(y=0;y<r;y++){var T,N=S[y];0!==N&&(N>0?T=s[y][N-1>>1]:N<0&&(T=s[y][-N-1>>1].neg()),m="affine"===T.type?m.mixedAdd(T):m.add(T))}}for(l=0;l<r;l++)s[l]=null;return i?m:m.toP()},s.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},s.prototype.decodePoint=function(e,t){e=i.toArray(e,t);var n=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*n)return 6===e[0]?c(e[e.length-1]%2==0):7===e[0]&&c(e[e.length-1]%2==1),this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));if((2===e[0]||3===e[0])&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),3===e[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(e){return this.encode(e,!0)},u.prototype._encode=function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},u.prototype.encode=function(e,t){return i.encode(this._encode(t),e)},u.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},u.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,i=0;i<t;i+=e){for(var o=0;o<e;o++)r=r.dbl();n.push(r)}return{step:e,points:n}},u.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,r=1===n?null:this.dbl(),i=1;i<n;i++)t[i]=t[i-1].add(r);return{wnd:e,points:t}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t}},function(e,t,n){var r=n(213),i=n(224),o=n(225),a=n(53),c=n(83),s=n(3).Buffer;function u(e){var t;"object"!=typeof e||s.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=s.from(e));var n,u,f=o(e,t),l=f.tag,h=f.data;switch(l){case"CERTIFICATE":u=r.certificate.decode(h,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(u||(u=r.PublicKey.decode(h,"der")),n=u.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return r.RSAPublicKey.decode(u.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return u.subjectPrivateKey=u.subjectPublicKey,{type:"ec",data:u};case"1.2.840.10040.4.1":return u.algorithm.params.pub_key=r.DSAparam.decode(u.subjectPublicKey.data,"der"),{type:"dsa",data:u.algorithm.params};default:throw new Error("unknown key id "+n)}throw new Error("unknown key type "+l);case"ENCRYPTED PRIVATE KEY":h=function(e,t){var n=e.algorithm.decrypt.kde.kdeparams.salt,r=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),o=i[e.algorithm.decrypt.cipher.algo.join(".")],u=e.algorithm.decrypt.cipher.iv,f=e.subjectPrivateKey,l=parseInt(o.split("-")[1],10)/8,h=c.pbkdf2Sync(t,n,r,l,"sha1"),d=a.createDecipheriv(o,h,u),p=[];return p.push(d.update(f)),p.push(d.final()),s.concat(p)}(h=r.EncryptedPrivateKey.decode(h,"der"),t);case"PRIVATE KEY":switch(n=(u=r.PrivateKey.decode(h,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return r.RSAPrivateKey.decode(u.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:u.algorithm.curve,privateKey:r.ECPrivateKey.decode(u.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return u.algorithm.params.priv_key=r.DSAparam.decode(u.subjectPrivateKey,"der"),{type:"dsa",params:u.algorithm.params};default:throw new Error("unknown key id "+n)}throw new Error("unknown key type "+l);case"RSA PUBLIC KEY":return r.RSAPublicKey.decode(h,"der");case"RSA PRIVATE KEY":return r.RSAPrivateKey.decode(h,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:r.DSAPrivateKey.decode(h,"der")};case"EC PRIVATE KEY":return{curve:(h=r.ECPrivateKey.decode(h,"der")).parameters.value,privateKey:h.privateKey};default:throw new Error("unknown key type "+l)}}e.exports=u,u.signature=r.signature},function(e,t){var n=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(n.prototype=Object.create(Error.prototype)).constructor=n,e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(43),i=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new r.BindingWhenSyntax(this._binding)},e}();t.BindingOnSyntax=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(42),i=n(68),o=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=i.namedConstraint(e),new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e.target&&!e.target.isNamed()&&!e.target.isTagged()},new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=i.taggedConstraint(e)(t),new r.BindingOnSyntax(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return i.typeConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return i.namedConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(n){return i.taggedConstraint(e)(t)(n.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(n){return i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(n){return!i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e}();t.BindingWhenSyntax=o},function(e,t,n){var r=n(148),i=n(234);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=r.sign,t.verify=i.verify,t.decode=i.decode,t.isValid=i.isValid,t.createSign=function(e){return new r(e)},t.createVerify=function(e){return new i(e)}},function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function c(){c.init.call(this)}e.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var s=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function f(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var i,o,a,c;if(u(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"==typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=f(e))>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=a.length,c=s,console&&console.warn&&console.warn(c)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=h.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):_(i,i.length)}function b(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function _(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return f(this)},c.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)o(s,this,t);else{var u=s.length,f=_(s,u);for(n=0;n<u;++n)o(f[n],this,t)}return!0},c.prototype.addListener=function(e,t){return l(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return l(this,e,t,!0)},c.prototype.once=function(e,t){return u(t),this.on(e,d(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,d(this,e,t)),this},c.prototype.removeListener=function(e,t){var n,r,i,o,a;if(u(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,a||t)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},c.prototype.listeners=function(e){return p(this,e,!0)},c.prototype.rawListeners=function(e){return p(this,e,!1)},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):b.call(e,t)},c.prototype.listenerCount=b,c.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){(t=e.exports=n(72)).Stream=t,t.Readable=t,t.Writable=n(47),t.Duplex=n(23),t.Transform=n(75),t.PassThrough=n(157)},function(e,t,n){"use strict";(function(t,r,i){var o=n(35);function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=y;var c,s=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?r:o.nextTick;y.WritableState=E;var u=Object.create(n(29));u.inherits=n(4);var f={deprecate:n(156)},l=n(73),h=n(3).Buffer,d=i.Uint8Array||function(){};var p,b=n(74);function _(){}function E(e,t){c=c||n(23),e=e||{};var r=t instanceof c;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(A,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),A(e,t))}(e,n,r,t,i);else{var a=S(n);a||n.corked||n.bufferProcessing||!n.bufferedRequest||m(e,n),r?s(g,e,n,a,i):g(e,n,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function y(e){if(c=c||n(23),!(p.call(y,this)||this instanceof c))return new y(e);this._writableState=new E(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function v(e,t,n,r,i,o,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),A(e,t)}function m(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var c=0,s=!0;n;)i[c]=n,n.isBuf||(s=!1),n=n.next,c+=1;i.allBuffers=s,v(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var u=n.chunk,f=n.encoding,l=n.callback;if(v(e,t,!1,t.objectMode?1:u.length,u,f,l),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function O(e,t){e._final((function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),A(e,t)}))}function A(e,t){var n=S(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(O,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}u.inherits(y,l),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===y&&(e&&e._writableState instanceof E)}})):p=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,c=!i.objectMode&&(r=e,h.isBuffer(r)||r instanceof d);return c&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(n=t,t=null),c?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=_),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(c||function(e,t,n,r){var i=!0,a=!1;return null===n?a=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(r,a),i=!1),i}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,o){if(!n){var a=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n));return t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var c=t.objectMode?1:r.length;t.length+=c;var s=t.length<t.highWaterMark;s||(t.needDrain=!0);if(t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else v(e,t,!1,c,r,i,o);return s}(this,i,c,e,t,n)),a},y.prototype.cork=function(){this._writableState.corked++},y.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||m(this,e))},y.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(e,t,n){t.ending=!0,A(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=b.destroy,y.prototype._undestroy=b.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,n(10),n(154).setImmediate,n(19))},function(e,t,n){"use strict";var r=n(3).Buffer,i=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=s,this.end=u,t=4;break;case"utf8":this.fillLast=c,t=4;break;case"base64":this.text=f,this.end=l,t=3;break;default:return this.write=h,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function c(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function s(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function f(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=a(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if((i=a(t[r]))>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if((i=a(t[r]))>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,n){"use strict";var r=n(4),i=n(77),o=n(3).Buffer,a=new Array(16);function c(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(e,t){return e<<t|e>>>32-t}function u(e,t,n,r,i,o,a){return s(e+(t&n|~t&r)+i+o|0,a)+t|0}function f(e,t,n,r,i,o,a){return s(e+(t&r|n&~r)+i+o|0,a)+t|0}function l(e,t,n,r,i,o,a){return s(e+(t^n^r)+i+o|0,a)+t|0}function h(e,t,n,r,i,o,a){return s(e+(n^(t|~r))+i+o|0,a)+t|0}r(c,i),c.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,r=this._b,i=this._c,o=this._d;n=u(n,r,i,o,e[0],3614090360,7),o=u(o,n,r,i,e[1],3905402710,12),i=u(i,o,n,r,e[2],606105819,17),r=u(r,i,o,n,e[3],3250441966,22),n=u(n,r,i,o,e[4],4118548399,7),o=u(o,n,r,i,e[5],1200080426,12),i=u(i,o,n,r,e[6],2821735955,17),r=u(r,i,o,n,e[7],4249261313,22),n=u(n,r,i,o,e[8],1770035416,7),o=u(o,n,r,i,e[9],2336552879,12),i=u(i,o,n,r,e[10],4294925233,17),r=u(r,i,o,n,e[11],2304563134,22),n=u(n,r,i,o,e[12],1804603682,7),o=u(o,n,r,i,e[13],4254626195,12),i=u(i,o,n,r,e[14],2792965006,17),n=f(n,r=u(r,i,o,n,e[15],1236535329,22),i,o,e[1],4129170786,5),o=f(o,n,r,i,e[6],3225465664,9),i=f(i,o,n,r,e[11],643717713,14),r=f(r,i,o,n,e[0],3921069994,20),n=f(n,r,i,o,e[5],3593408605,5),o=f(o,n,r,i,e[10],38016083,9),i=f(i,o,n,r,e[15],3634488961,14),r=f(r,i,o,n,e[4],3889429448,20),n=f(n,r,i,o,e[9],568446438,5),o=f(o,n,r,i,e[14],3275163606,9),i=f(i,o,n,r,e[3],4107603335,14),r=f(r,i,o,n,e[8],1163531501,20),n=f(n,r,i,o,e[13],2850285829,5),o=f(o,n,r,i,e[2],4243563512,9),i=f(i,o,n,r,e[7],1735328473,14),n=l(n,r=f(r,i,o,n,e[12],2368359562,20),i,o,e[5],4294588738,4),o=l(o,n,r,i,e[8],2272392833,11),i=l(i,o,n,r,e[11],1839030562,16),r=l(r,i,o,n,e[14],4259657740,23),n=l(n,r,i,o,e[1],2763975236,4),o=l(o,n,r,i,e[4],1272893353,11),i=l(i,o,n,r,e[7],4139469664,16),r=l(r,i,o,n,e[10],3200236656,23),n=l(n,r,i,o,e[13],681279174,4),o=l(o,n,r,i,e[0],3936430074,11),i=l(i,o,n,r,e[3],3572445317,16),r=l(r,i,o,n,e[6],76029189,23),n=l(n,r,i,o,e[9],3654602809,4),o=l(o,n,r,i,e[12],3873151461,11),i=l(i,o,n,r,e[15],530742520,16),n=h(n,r=l(r,i,o,n,e[2],3299628645,23),i,o,e[0],4096336452,6),o=h(o,n,r,i,e[7],1126891415,10),i=h(i,o,n,r,e[14],2878612391,15),r=h(r,i,o,n,e[5],4237533241,21),n=h(n,r,i,o,e[12],1700485571,6),o=h(o,n,r,i,e[3],2399980690,10),i=h(i,o,n,r,e[10],4293915773,15),r=h(r,i,o,n,e[1],2240044497,21),n=h(n,r,i,o,e[8],1873313359,6),o=h(o,n,r,i,e[15],4264355552,10),i=h(i,o,n,r,e[6],2734768916,15),r=h(r,i,o,n,e[13],1309151649,21),n=h(n,r,i,o,e[4],4149444226,6),o=h(o,n,r,i,e[11],3174756917,10),i=h(i,o,n,r,e[2],718787259,15),r=h(r,i,o,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+r|0,this._c=this._c+i|0,this._d=this._d+o|0},c.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=c},function(e,t,n){"use strict";var r=n(5).Buffer,i=n(4),o=n(77),a=new Array(16),c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],s=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function d(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<<t|e>>>32-t}function b(e,t,n,r,i,o,a,c){return p(e+(t^n^r)+o+a|0,c)+i|0}function _(e,t,n,r,i,o,a,c){return p(e+(t&n|~t&r)+o+a|0,c)+i|0}function E(e,t,n,r,i,o,a,c){return p(e+((t|~n)^r)+o+a|0,c)+i|0}function y(e,t,n,r,i,o,a,c){return p(e+(t&r|n&~r)+o+a|0,c)+i|0}function v(e,t,n,r,i,o,a,c){return p(e+(t^(n|~r))+o+a|0,c)+i|0}i(d,o),d.prototype._update=function(){for(var e=a,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,d=0|this._e,g=0|this._a,m=0|this._b,S=0|this._c,O=0|this._d,A=0|this._e,T=0;T<80;T+=1){var N,M;T<16?(N=b(n,r,i,o,d,e[c[T]],l[0],u[T]),M=v(g,m,S,O,A,e[s[T]],h[0],f[T])):T<32?(N=_(n,r,i,o,d,e[c[T]],l[1],u[T]),M=y(g,m,S,O,A,e[s[T]],h[1],f[T])):T<48?(N=E(n,r,i,o,d,e[c[T]],l[2],u[T]),M=E(g,m,S,O,A,e[s[T]],h[2],f[T])):T<64?(N=y(n,r,i,o,d,e[c[T]],l[3],u[T]),M=_(g,m,S,O,A,e[s[T]],h[3],f[T])):(N=v(n,r,i,o,d,e[c[T]],l[4],u[T]),M=b(g,m,S,O,A,e[s[T]],h[4],f[T])),n=d,d=o,o=p(i,10),i=r,r=N,g=A,A=O,O=p(S,10),S=m,m=M}var w=this._b+i+O|0;this._b=this._c+o+A|0,this._c=this._d+d+g|0,this._d=this._e+n+m|0,this._e=this._a+r+S|0,this._a=w},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=r.alloc?r.alloc(20):new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=d},function(e,t,n){(t=e.exports=function(e){e=e.toLowerCase();var n=t[e];if(!n)throw new Error(e+" is not supported (we accept pull requests)");return new n}).sha=n(165),t.sha1=n(166),t.sha224=n(167),t.sha256=n(78),t.sha384=n(168),t.sha512=n(79)},function(e,t,n){"use strict";var r=n(11);function i(e){this.options=e,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=i,i.prototype._init=function(){},i.prototype.update=function(e){return 0===e.length?[]:"decrypt"===this.type?this._updateDecrypt(e):this._updateEncrypt(e)},i.prototype._buffer=function(e,t){for(var n=Math.min(this.buffer.length-this.bufferOff,e.length-t),r=0;r<n;r++)this.buffer[this.bufferOff+r]=e[t+r];return this.bufferOff+=n,n},i.prototype._flushBuffer=function(e,t){return this._update(this.buffer,0,e,t),this.bufferOff=0,this.blockSize},i.prototype._updateEncrypt=function(e){var t=0,n=0,r=(this.bufferOff+e.length)/this.blockSize|0,i=new Array(r*this.blockSize);0!==this.bufferOff&&(t+=this._buffer(e,t),this.bufferOff===this.buffer.length&&(n+=this._flushBuffer(i,n)));for(var o=e.length-(e.length-t)%this.blockSize;t<o;t+=this.blockSize)this._update(e,t,i,n),n+=this.blockSize;for(;t<e.length;t++,this.bufferOff++)this.buffer[this.bufferOff]=e[t];return i},i.prototype._updateDecrypt=function(e){for(var t=0,n=0,r=Math.ceil((this.bufferOff+e.length)/this.blockSize)-1,i=new Array(r*this.blockSize);r>0;r--)t+=this._buffer(e,t),n+=this._flushBuffer(i,n);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,n;return e&&(t=this.update(e)),n="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(n):n},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t<e.length;)e[t++]=0;return!0},i.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var e=new Array(this.blockSize);return this._update(this.buffer,0,e,0),e},i.prototype._unpad=function(e){return e},i.prototype._finalDecrypt=function(){r.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var e=new Array(this.blockSize);return this._flushBuffer(e,0),this._unpad(e)}},function(e,t,n){var r=n(177),i=n(185),o=n(91);t.createCipher=t.Cipher=r.createCipher,t.createCipheriv=t.Cipheriv=r.createCipheriv,t.createDecipher=t.Decipher=i.createDecipher,t.createDecipheriv=t.Decipheriv=i.createDecipheriv,t.listCiphers=t.getCiphers=function(){return Object.keys(o)}},function(e,t,n){var r={ECB:n(178),CBC:n(179),CFB:n(180),CFB8:n(181),CFB1:n(182),OFB:n(183),CTR:n(89),GCM:n(89)},i=n(91);for(var o in i)i[o].module=r[i[o].mode];e.exports=i},function(e,t,n){var r;function i(e){this.rand=e}if(e.exports=function(e){return r||(r=new i(null)),r.generate(e)},e.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n<t.length;n++)t[n]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(i.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var o=n(190);if("function"!=typeof o.randomBytes)throw new Error("Not supported");i.prototype._rand=function(e){return o.randomBytes(e)}}catch(e){}},function(e,t,n){(function(t){var r=n(6),i=n(25);function o(e,n){var i=function(e){var t=a(e);return{blinder:t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(n),o=n.modulus.byteLength(),c=(r.mont(n.modulus),new r(e).mul(i.blinder).umod(n.modulus)),s=c.toRed(r.mont(n.prime1)),u=c.toRed(r.mont(n.prime2)),f=n.coefficient,l=n.prime1,h=n.prime2,d=s.redPow(n.exponent1),p=u.redPow(n.exponent2);d=d.fromRed(),p=p.fromRed();var b=d.isub(p).imul(f).umod(l);return b.imul(h),p.iadd(b),new t(p.imul(i.unblinder).umod(n.modulus).toArray(!1,o))}function a(e){for(var t=e.modulus.byteLength(),n=new r(i(t));n.cmp(e.modulus)>=0||!n.umod(e.prime1)||!n.umod(e.prime2);)n=new r(i(t));return n}e.exports=o,o.getr=a}).call(this,n(5).Buffer)},function(e,t,n){"use strict";var r=t;r.version=n(195).version,r.utils=n(12),r.rand=n(55),r.curve=n(97),r.curves=n(58),r.ec=n(206),r.eddsa=n(210)},function(e,t,n){"use strict";var r,i=t,o=n(59),a=n(97),c=n(12).assert;function s(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,c(this.g.validate(),"Invalid curve"),c(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var n=new s(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:n}),n}})}i.PresetCurve=s,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=n(205)}catch(e){r=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},function(e,t,n){var r=t;r.utils=n(16),r.common=n(32),r.sha=n(199),r.ripemd=n(203),r.hmac=n(204),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,i=Array.isArray,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),a=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:a,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r<t.length;++r)for(var o=t[r],a=o.obj[o.prop],c=Object.keys(a),s=0;s<c.length;++s){var u=c[s],f=a[u];"object"==typeof f&&null!==f&&-1===n.indexOf(f)&&(t.push({obj:a,prop:u}),n.push(f))}return function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(i(n)){for(var r=[],o=0;o<n.length;++o)void 0!==n[o]&&r.push(n[o]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n){if(0===e.length)return e;var r=e;if("symbol"==typeof e?r=Symbol.prototype.toString.call(e):"string"!=typeof e&&(r=String(e)),"iso-8859-1"===n)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var i="",a=0;a<r.length;++a){var c=r.charCodeAt(a);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122?i+=r.charAt(a):c<128?i+=o[c]:c<2048?i+=o[192|c>>6]+o[128|63&c]:c<55296||c>=57344?i+=o[224|c>>12]+o[128|c>>6&63]+o[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&r.charCodeAt(a)),i+=o[240|c>>18]+o[128|c>>12&63]+o[128|c>>6&63]+o[128|63&c])}return i},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,n,o){if(!n)return t;if("object"!=typeof n){if(i(t))t.push(n);else{if(!t||"object"!=typeof t)return[t,n];(o&&(o.plainObjects||o.allowPrototypes)||!r.call(Object.prototype,n))&&(t[n]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(n);var c=t;return i(t)&&!i(n)&&(c=a(t,o)),i(t)&&i(n)?(n.forEach((function(n,i){if(r.call(t,i)){var a=t[i];a&&"object"==typeof a&&n&&"object"==typeof n?t[i]=e(a,n,o):t.push(n)}else t[i]=n})),t):Object.keys(n).reduce((function(t,i){var a=n[i];return r.call(t,i)?t[i]=e(t[i],a,o):t[i]=a,t}),c)}}},function(e,t,n){window,e.exports=function(){return n={},e.m=t=[function(e,t,n){"use strict";var r,i;n.r(t),(i=r=r||{}).BOARD="board",i.MEDIUM="medium",i.GRADE_LEVEL="gradeLevel",i.SUBJECT="subject",i.TOPIC="topic",i.PURPOSE="purpose";var o=(a.DEFAULT_FRAMEWORK_CATEGORIES=[r.BOARD,r.MEDIUM,r.GRADE_LEVEL,r.SUBJECT],a.COURSE_FRAMEWORK_CATEGORIES=[r.TOPIC,r.PURPOSE,r.MEDIUM,r.GRADE_LEVEL,r.SUBJECT],a);function a(){}n.d(t,"FrameworkCategoryCode",(function(){return r})),n.d(t,"FrameworkCategoryCodesGroup",(function(){return o}))}],e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(e){return t[e]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.p="",e(e.s=0);function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var t,n}()},function(e,t,n){e.exports={decode:n(69),verify:n(235),sign:n(238),JsonWebTokenError:n(41),NotBeforeError:n(110),TokenExpiredError:n(111)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata(r.PARAM_TYPES,e),userGeneratedMetadata:Reflect.getMetadata(r.TAGGED,e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata(r.TAGGED_PROP,e)||[]},e}();t.MetadataReader=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9);t.isStackOverflowExeption=function(e){return e instanceof RangeError||e.message===r.STACK_OVERFLOW}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(7),o=n(13),a=n(20),c=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}();t.LazyServiceIdentifer=c,t.inject=function(e){return function(t,n,c){if(void 0===e)throw new Error(r.UNDEFINED_INJECT_ANNOTATION(t.name));var s=new o.Metadata(i.INJECT_TAG,e);"number"==typeof c?a.tagParameter(t,n,c,s):a.tagProperty(t,n,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(22),o=n(13),a=n(129),c=function(){function e(e,t,n,c){this.id=i.id(),this.type=e,this.serviceIdentifier=n,this.name=new a.QueryableString(t||""),this.metadata=new Array;var s=null;"string"==typeof c?s=new o.Metadata(r.NAMED_TAG,c):c instanceof o.Metadata&&(s=c),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,n=this.metadata;t<n.length;t++){if(n[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag(r.MULTI_INJECT_TAG)},e.prototype.matchesArray=function(e){return this.matchesTag(r.MULTI_INJECT_TAG)(e)},e.prototype.isNamed=function(){return this.hasTag(r.NAMED_TAG)},e.prototype.isTagged=function(){return this.metadata.some((function(e){return e.key!==r.INJECT_TAG&&e.key!==r.MULTI_INJECT_TAG&&e.key!==r.NAME_TAG&&e.key!==r.UNMANAGED_TAG&&e.key!==r.NAMED_TAG}))},e.prototype.isOptional=function(){return this.matchesTag(r.OPTIONAL_TAG)(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return e.key===r.NAMED_TAG}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return e.key!==r.INJECT_TAG&&e.key!==r.MULTI_INJECT_TAG&&e.key!==r.NAME_TAG&&e.key!==r.UNMANAGED_TAG&&e.key!==r.NAMED_TAG})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag(r.NAMED_TAG)(e)},e.prototype.matchesTag=function(e){var t=this;return function(n){for(var r=0,i=t.metadata;r<i.length;r++){var o=i[r];if(o.key===e&&o.value===n)return!0}return!1}},e}();t.Target=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(42),i=n(43),o=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new i.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new r.BindingOnSyntax(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingWhenOnSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(13),o=function(e,t){var n=e.parentRequest;return null!==n&&(!!t(n)||o(n,t))};t.traverseAncerstors=o;var a=function(e){return function(t){var n=function(n){return null!==n&&null!==n.target&&n.target.matchesTag(e)(t)};return n.metaData=new i.Metadata(e,t),n}};t.taggedConstraint=a;var c=a(r.NAMED_TAG);t.namedConstraint=c;t.typeConstraint=function(e){return function(t){var n=null;if(null!==t){if(n=t.bindings[0],"string"==typeof e)return n.serviceIdentifier===e;var r=t.bindings[0].implementationType;return e===r}return!1}}},function(e,t,n){var r=n(44);e.exports=function(e,t){t=t||{};var n=r.decode(e,t);if(!n)return null;var i=n.payload;if("string"==typeof i)try{var o=JSON.parse(i);null!==o&&"object"==typeof o&&(i=o)}catch(e){}return!0===t.complete?{header:n.header,payload:i,signature:n.signature}:i}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){(function(t){var r=n(3).Buffer,i=n(24);function o(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=r.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=r.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,t.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(36).inherits(o,i),o.prototype.write=function(e){this.buffer=r.concat([this.buffer,r.from(e)]),this.emit("data",e)},o.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=o}).call(this,n(10))},function(e,t,n){"use strict";(function(t,r){var i=n(35);e.exports=v;var o,a=n(70);v.ReadableState=y;n(45).EventEmitter;var c=function(e,t){return e.listeners(t).length},s=n(73),u=n(3).Buffer,f=t.Uint8Array||function(){};var l=Object.create(n(29));l.inherits=n(4);var h=n(151),d=void 0;d=h&&h.debuglog?h.debuglog("stream"):function(){};var p,b=n(152),_=n(74);l.inherits(v,s);var E=["error","close","destroy","pause","resume"];function y(e,t){e=e||{};var r=t instanceof(o=o||n(23));this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,a=e.readableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(a||0===a)?a:c,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new b,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(p||(p=n(48).StringDecoder),this.decoder=new p(e.encoding),this.encoding=e.encoding)}function v(e){if(o=o||n(23),!(this instanceof v))return new v(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function g(e,t,n,r,i){var o,a=e._readableState;null===t?(a.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,O(e)}(e,a)):(i||(o=function(e,t){var n;r=t,u.isBuffer(r)||r instanceof f||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(a,t)),o?e.emit("error",o):a.objectMode||t&&t.length>0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),r?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):m(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?m(e,a,t,!1):T(e,a)):m(e,a,t,!1))):r||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(a)}function m(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&O(e)),T(e,t)}Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),v.prototype.destroy=_.destroy,v.prototype._undestroy=_.undestroy,v.prototype._destroy=function(e,t){this.push(null),t(e)},v.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=u.from(e,t),t=""),n=!0),g(this,e,t,!1,n)},v.prototype.unshift=function(e){return g(this,e,null,!0,!1)},v.prototype.isPaused=function(){return!1===this._readableState.flowing},v.prototype.setEncoding=function(e){return p||(p=n(48).StringDecoder),this._readableState.decoder=new p(e),this._readableState.encoding=e,this};function S(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function O(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(A,e):A(e))}function A(e){d("emit readable"),e.emit("readable"),C(e)}function T(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(N,e,t))}function N(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(d("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function M(e){d("readable nexttick read 0"),e.read(0)}function w(e,t){t.reading||(d("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),C(e),t.flowing&&!t.reading&&e.read(0)}function C(e){var t=e._readableState;for(d("flow",t.flowing);t.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,r=1,i=n.data;e-=i.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=u.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,a=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,a),0===(e-=a)){a===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function P(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(L,t,e))}function L(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}v.prototype.read=function(e){d("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?P(this):O(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&P(this),null;var r,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&d("length less than watermark",i=!0),t.ended||t.reading?d("reading or ended",i=!1):i&&(d("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=S(n,t))),null===(r=e>0?I(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&P(this)),null!==r&&this.emit("data",r),r},v.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var s=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:v;function u(t,r){d("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,d("cleanup"),e.removeListener("close",E),e.removeListener("finish",y),e.removeListener("drain",l),e.removeListener("error",_),e.removeListener("unpipe",u),n.removeListener("end",f),n.removeListener("end",v),n.removeListener("data",b),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function f(){d("onend"),e.end()}o.endEmitted?i.nextTick(s):n.once("end",s),e.on("unpipe",u);var l=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&c(e,"data")&&(t.flowing=!0,C(e))}}(n);e.on("drain",l);var h=!1;var p=!1;function b(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==R(o.pipes,e))&&!h&&(d("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function _(t){d("onerror",t),v(),e.removeListener("error",_),0===c(e,"error")&&e.emit("error",t)}function E(){e.removeListener("finish",y),v()}function y(){d("onfinish"),e.removeListener("close",E),v()}function v(){d("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",_),e.once("close",E),e.once("finish",y),e.emit("pipe",n),o.flowing||(d("pipe resume"),n.resume()),e},v.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,n);return this}var a=R(t.pipes,e);return-1===a?this:(t.pipes.splice(a,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},v.prototype.on=function(e,t){var n=s.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&O(this):i.nextTick(M,this))}return n},v.prototype.addListener=v.prototype.on,v.prototype.resume=function(){var e=this._readableState;return e.flowing||(d("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(w,e,t))}(this,e)),this},v.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this},v.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",(function(){if(d("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(d("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<E.length;o++)e.on(E[o],this.emit.bind(this,E[o]));return this._read=function(t){d("wrapped _read",t),r&&(r=!1,e.resume())},this},Object.defineProperty(v.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),v._fromList=I}).call(this,n(19),n(10))},function(e,t,n){e.exports=n(45).EventEmitter},function(e,t,n){"use strict";var r=n(35);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,o=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return o||a?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?(r.nextTick(i,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";e.exports=a;var r=n(23),i=Object.create(n(29));function o(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function a(e){if(!(this instanceof a))return new a(e);r.call(this,e),this._transformState={afterTransform:o.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",c)}function c(){var e=this;"function"==typeof this._flush?this._flush((function(t,n){s(e,t,n)})):s(this,null,null)}function s(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}i.inherits=n(4),i.inherits(a,r),a.prototype.push=function(e,t){return this._transformState.needTransform=!1,r.prototype.push.call(this,e,t)},a.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},a.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},a.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},a.prototype._destroy=function(e,t){var n=this;r.prototype._destroy.call(this,e,(function(e){t(e),n.emit("close")}))}},function(e,t,n){var r=n(163),i=n(3).Buffer,o=n(164),a=n(232),c=n(36),s="secret must be a string or buffer",u="key must be a string or a buffer",f="function"==typeof o.createPublicKey;function l(e){if(!i.isBuffer(e)&&"string"!=typeof e){if(!f)throw b(u);if("object"!=typeof e)throw b(u);if("string"!=typeof e.type)throw b(u);if("string"!=typeof e.asymmetricKeyType)throw b(u);if("function"!=typeof e.export)throw b(u)}}function h(e){if(!i.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw b("key must be a string, a buffer or an object")}function d(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function b(e){var t=[].slice.call(arguments,1),n=c.format.bind(c,e).apply(null,t);return new TypeError(n)}function _(e){var t;return t=e,i.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function E(e){return function(t,n){!function(e){if(!i.isBuffer(e)){if("string"==typeof e)return e;if(!f)throw b(s);if("object"!=typeof e)throw b(s);if("secret"!==e.type)throw b(s);if("function"!=typeof e.export)throw b(s)}}(n),t=_(t);var r=o.createHmac("sha"+e,n);return d((r.update(t),r.digest("base64")))}}function y(e){return function(t,n,o){var a=E(e)(t,o);return r(i.from(n),i.from(a))}}function v(e){return function(t,n){h(n),t=_(t);var r=o.createSign("RSA-SHA"+e);return d((r.update(t),r.sign(n,"base64")))}}function g(e){return function(t,n,r){l(r),t=_(t),n=p(n);var i=o.createVerify("RSA-SHA"+e);return i.update(t),i.verify(r,n,"base64")}}function m(e){return function(t,n){h(n),t=_(t);var r=o.createSign("RSA-SHA"+e);return d((r.update(t),r.sign({key:n,padding:o.constants.RSA_PKCS1_PSS_PADDING,saltLength:o.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function S(e){return function(t,n,r){l(r),t=_(t),n=p(n);var i=o.createVerify("RSA-SHA"+e);return i.update(t),i.verify({key:r,padding:o.constants.RSA_PKCS1_PSS_PADDING,saltLength:o.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function O(e){var t=v(e);return function(){var n=t.apply(null,arguments);return n=a.derToJose(n,"ES"+e)}}function A(e){var t=g(e);return function(n,r,i){return r=a.joseToDer(r,"ES"+e).toString("base64"),t(n,r,i)}}function T(){return function(){return""}}function N(){return function(e,t){return""===t}}f&&(u+=" or a KeyObject",s+="or a KeyObject"),e.exports=function(e){var t={hs:E,rs:v,ps:m,es:O,none:T},n={hs:y,rs:g,ps:S,es:A,none:N},r=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!r)throw b('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var i=(r[1]||r[3]).toLowerCase(),o=r[2];return{sign:t[i](o),verify:n[i](o)}}},function(e,t,n){"use strict";var r=n(3).Buffer,i=n(24).Transform;function o(e){i.call(this),this._block=r.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}n(4)(o,i),o.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!r.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");r.isBuffer(e)||(e=r.from(e,t));for(var n=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)n[this._blockOffset++]=e[i++];for(var a=0,c=8*e.length;c>0;++a)this._length[a]+=c,(c=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*c);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=o},function(e,t,n){var r=n(4),i=n(26),o=n(3).Buffer,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],c=new Array(64);function s(){this.init(),this._w=c,i.call(this,64,56)}function u(e,t,n){return n^e&(t^n)}function f(e,t,n){return e&t|n&(e|t)}function l(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}r(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,c=0|this._d,s=0|this._e,p=0|this._f,b=0|this._g,_=0|this._h,E=0;E<16;++E)n[E]=e.readInt32BE(4*E);for(;E<64;++E)n[E]=0|(((t=n[E-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+n[E-7]+d(n[E-15])+n[E-16];for(var y=0;y<64;++y){var v=_+h(s)+u(s,p,b)+a[y]+n[y]|0,g=l(r)+f(r,i,o)|0;_=b,b=p,p=s,s=c+v|0,c=o,o=i,i=r,r=v+g|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=c+this._d|0,this._e=s+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=_+this._h|0},s.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=s},function(e,t,n){var r=n(4),i=n(26),o=n(3).Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],c=new Array(160);function s(){this.init(),this._w=c,i.call(this,128,112)}function u(e,t,n){return n^e&(t^n)}function f(e,t,n){return e&t|n&(e|t)}function l(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function _(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function E(e,t){return e>>>0<t>>>0?1:0}r(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(e){for(var t=this._w,n=0|this._ah,r=0|this._bh,i=0|this._ch,o=0|this._dh,c=0|this._eh,s=0|this._fh,y=0|this._gh,v=0|this._hh,g=0|this._al,m=0|this._bl,S=0|this._cl,O=0|this._dl,A=0|this._el,T=0|this._fl,N=0|this._gl,M=0|this._hl,w=0;w<32;w+=2)t[w]=e.readInt32BE(4*w),t[w+1]=e.readInt32BE(4*w+4);for(;w<160;w+=2){var C=t[w-30],I=t[w-30+1],P=d(C,I),L=p(I,C),R=b(C=t[w-4],I=t[w-4+1]),D=_(I,C),j=t[w-14],U=t[w-14+1],k=t[w-32],x=t[w-32+1],B=L+U|0,F=P+j+E(B,L)|0;F=(F=F+R+E(B=B+D|0,D)|0)+k+E(B=B+x|0,x)|0,t[w]=F,t[w+1]=B}for(var V=0;V<160;V+=2){F=t[V],B=t[V+1];var Y=f(n,r,i),G=f(g,m,S),H=l(n,g),q=l(g,n),z=h(c,A),K=h(A,c),W=a[V],X=a[V+1],J=u(c,s,y),Q=u(A,T,N),$=M+K|0,Z=v+z+E($,M)|0;Z=(Z=(Z=Z+J+E($=$+Q|0,Q)|0)+W+E($=$+X|0,X)|0)+F+E($=$+B|0,B)|0;var ee=q+G|0,te=H+Y+E(ee,q)|0;v=y,M=N,y=s,N=T,s=c,T=A,c=o+Z+E(A=O+$|0,O)|0,o=i,O=S,i=r,S=m,r=n,m=g,n=Z+te+E(g=$+ee|0,$)|0}this._al=this._al+g|0,this._bl=this._bl+m|0,this._cl=this._cl+S|0,this._dl=this._dl+O|0,this._el=this._el+A|0,this._fl=this._fl+T|0,this._gl=this._gl+N|0,this._hl=this._hl+M|0,this._ah=this._ah+n+E(this._al,g)|0,this._bh=this._bh+r+E(this._bl,m)|0,this._ch=this._ch+i+E(this._cl,S)|0,this._dh=this._dh+o+E(this._dl,O)|0,this._eh=this._eh+c+E(this._el,A)|0,this._fh=this._fh+s+E(this._fl,T)|0,this._gh=this._gh+y+E(this._gl,N)|0,this._hh=this._hh+v+E(this._hl,M)|0},s.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=s},function(e,t,n){"use strict";var r=n(4),i=n(169),o=n(21),a=n(3).Buffer,c=n(81),s=n(50),u=n(51),f=a.alloc(128);function l(e,t){o.call(this,"digest"),"string"==typeof t&&(t=a.from(t));var n="sha512"===e||"sha384"===e?128:64;(this._alg=e,this._key=t,t.length>n)?t=("rmd160"===e?new s:u(e)).update(t).digest():t.length<n&&(t=a.concat([t,f],n));for(var r=this._ipad=a.allocUnsafe(n),i=this._opad=a.allocUnsafe(n),c=0;c<n;c++)r[c]=54^t[c],i[c]=92^t[c];this._hash="rmd160"===e?new s:u(e),this._hash.update(r)}r(l,o),l.prototype._update=function(e){this._hash.update(e)},l.prototype._final=function(){var e=this._hash.digest();return("rmd160"===this._alg?new s:u(this._alg)).update(this._opad).update(e).digest()},e.exports=function(e,t){return"rmd160"===(e=e.toLowerCase())||"ripemd160"===e?new l("rmd160",t):"md5"===e?new i(c,t):new l(e,t)}},function(e,t,n){var r=n(49);e.exports=function(e){return(new r).update(e).digest()}},function(e){e.exports=JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}')},function(e,t,n){t.pbkdf2=n(171),t.pbkdf2Sync=n(86)},function(e,t,n){(function(t){var n=Math.pow(2,30)-1;function r(e,n){if("string"!=typeof e&&!t.isBuffer(e))throw new TypeError(n+" must be a buffer or string")}e.exports=function(e,t,i,o){if(r(e,"Password"),r(t,"Salt"),"number"!=typeof i)throw new TypeError("Iterations not a number");if(i<0)throw new TypeError("Bad iterations");if("number"!=typeof o)throw new TypeError("Key length not a number");if(o<0||o>n||o!=o)throw new TypeError("Bad key length")}}).call(this,n(5).Buffer)},function(e,t,n){(function(t){var n;t.browser?n="utf-8":n=parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary";e.exports=n}).call(this,n(10))},function(e,t,n){var r=n(81),i=n(50),o=n(51),a=n(84),c=n(85),s=n(3).Buffer,u=s.alloc(128),f={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(e,t,n){var a=function(e){function t(t){return o(e).update(t).digest()}return"rmd160"===e||"ripemd160"===e?function(e){return(new i).update(e).digest()}:"md5"===e?r:t}(e),c="sha512"===e||"sha384"===e?128:64;t.length>c?t=a(t):t.length<c&&(t=s.concat([t,u],c));for(var l=s.allocUnsafe(c+f[e]),h=s.allocUnsafe(c+f[e]),d=0;d<c;d++)l[d]=54^t[d],h[d]=92^t[d];var p=s.allocUnsafe(c+n+4);l.copy(p,0,0,c),this.ipad1=p,this.ipad2=l,this.opad=h,this.alg=e,this.blocksize=c,this.hash=a,this.size=f[e]}l.prototype.run=function(e,t){return e.copy(t,this.blocksize),this.hash(t).copy(this.opad,this.blocksize),this.hash(this.opad)},e.exports=function(e,t,n,r,i){a(e,t,n,r),s.isBuffer(e)||(e=s.from(e,c)),s.isBuffer(t)||(t=s.from(t,c));var o=new l(i=i||"sha1",e,t.length),u=s.allocUnsafe(r),h=s.allocUnsafe(t.length+4);t.copy(h,0,0,t.length);for(var d=0,p=f[i],b=Math.ceil(r/p),_=1;_<=b;_++){h.writeUInt32BE(_,t.length);for(var E=o.run(h,o.ipad1),y=E,v=1;v<n;v++){y=o.run(y,o.ipad2);for(var g=0;g<p;g++)E[g]^=y[g]}E.copy(u,d),d+=p}return u}},function(e,t,n){"use strict";t.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},t.writeUInt32BE=function(e,t,n){e[0+n]=t>>>24,e[1+n]=t>>>16&255,e[2+n]=t>>>8&255,e[3+n]=255&t},t.ip=function(e,t,n,r){for(var i=0,o=0,a=6;a>=0;a-=2){for(var c=0;c<=24;c+=8)i<<=1,i|=t>>>c+a&1;for(c=0;c<=24;c+=8)i<<=1,i|=e>>>c+a&1}for(a=6;a>=0;a-=2){for(c=1;c<=25;c+=8)o<<=1,o|=t>>>c+a&1;for(c=1;c<=25;c+=8)o<<=1,o|=e>>>c+a&1}n[r+0]=i>>>0,n[r+1]=o>>>0},t.rip=function(e,t,n,r){for(var i=0,o=0,a=0;a<4;a++)for(var c=24;c>=0;c-=8)i<<=1,i|=t>>>c+a&1,i<<=1,i|=e>>>c+a&1;for(a=4;a<8;a++)for(c=24;c>=0;c-=8)o<<=1,o|=t>>>c+a&1,o<<=1,o|=e>>>c+a&1;n[r+0]=i>>>0,n[r+1]=o>>>0},t.pc1=function(e,t,n,r){for(var i=0,o=0,a=7;a>=5;a--){for(var c=0;c<=24;c+=8)i<<=1,i|=t>>c+a&1;for(c=0;c<=24;c+=8)i<<=1,i|=e>>c+a&1}for(c=0;c<=24;c+=8)i<<=1,i|=t>>c+a&1;for(a=1;a<=3;a++){for(c=0;c<=24;c+=8)o<<=1,o|=t>>c+a&1;for(c=0;c<=24;c+=8)o<<=1,o|=e>>c+a&1}for(c=0;c<=24;c+=8)o<<=1,o|=e>>c+a&1;n[r+0]=i>>>0,n[r+1]=o>>>0},t.r28shl=function(e,t){return e<<t&268435455|e>>>28-t};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(e,t,n,i){for(var o=0,a=0,c=r.length>>>1,s=0;s<c;s++)o<<=1,o|=e>>>r[s]&1;for(s=c;s<r.length;s++)a<<=1,a|=t>>>r[s]&1;n[i+0]=o>>>0,n[i+1]=a>>>0},t.expand=function(e,t,n){var r=0,i=0;r=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)r<<=6,r|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[n+0]=r>>>0,t[n+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(e,t){for(var n=0,r=0;r<4;r++){n<<=4,n|=i[64*r+(e>>>18-6*r&63)]}for(r=0;r<4;r++){n<<=4,n|=i[256+64*r+(t>>>18-6*r&63)]}return n>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(e){for(var t=0,n=0;n<o.length;n++)t<<=1,t|=e>>>o[n]&1;return t>>>0},t.padSplit=function(e,t,n){for(var r=e.toString(2);r.length<t;)r="0"+r;for(var i=[],o=0;o<t;o+=n)i.push(r.slice(o,o+n));return i.join(" ")}},function(e,t,n){"use strict";var r=n(11),i=n(4),o=n(87),a=n(52);function c(){this.tmp=new Array(2),this.keys=null}function s(e){a.call(this,e);var t=new c;this._desState=t,this.deriveKeys(t,e.key)}i(s,a),e.exports=s,s.create=function(e){return new s(e)};var u=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];s.prototype.deriveKeys=function(e,t){e.keys=new Array(32),r.equal(t.length,this.blockSize,"Invalid key length");var n=o.readUInt32BE(t,0),i=o.readUInt32BE(t,4);o.pc1(n,i,e.tmp,0),n=e.tmp[0],i=e.tmp[1];for(var a=0;a<e.keys.length;a+=2){var c=u[a>>>1];n=o.r28shl(n,c),i=o.r28shl(i,c),o.pc2(n,i,e.keys,a)}},s.prototype._update=function(e,t,n,r){var i=this._desState,a=o.readUInt32BE(e,t),c=o.readUInt32BE(e,t+4);o.ip(a,c,i.tmp,0),a=i.tmp[0],c=i.tmp[1],"encrypt"===this.type?this._encrypt(i,a,c,i.tmp,0):this._decrypt(i,a,c,i.tmp,0),a=i.tmp[0],c=i.tmp[1],o.writeUInt32BE(n,a,r),o.writeUInt32BE(n,c,r+4)},s.prototype._pad=function(e,t){for(var n=e.length-t,r=t;r<e.length;r++)e[r]=n;return!0},s.prototype._unpad=function(e){for(var t=e[e.length-1],n=e.length-t;n<e.length;n++)r.equal(e[n],t);return e.slice(0,e.length-t)},s.prototype._encrypt=function(e,t,n,r,i){for(var a=t,c=n,s=0;s<e.keys.length;s+=2){var u=e.keys[s],f=e.keys[s+1];o.expand(c,e.tmp,0),u^=e.tmp[0],f^=e.tmp[1];var l=o.substitute(u,f),h=c;c=(a^o.permute(l))>>>0,a=h}o.rip(c,a,r,i)},s.prototype._decrypt=function(e,t,n,r,i){for(var a=n,c=t,s=e.keys.length-2;s>=0;s-=2){var u=e.keys[s],f=e.keys[s+1];o.expand(a,e.tmp,0),u^=e.tmp[0],f^=e.tmp[1];var l=o.substitute(u,f),h=a;a=(c^o.permute(l))>>>0,c=h}o.rip(a,c,r,i)}},function(e,t,n){var r=n(31),i=n(3).Buffer,o=n(90);function a(e){var t=e._cipher.encryptBlockRaw(e._prev);return o(e._prev),t}t.encrypt=function(e,t){var n=Math.ceil(t.length/16),o=e._cache.length;e._cache=i.concat([e._cache,i.allocUnsafe(16*n)]);for(var c=0;c<n;c++){var s=a(e),u=o+16*c;e._cache.writeUInt32BE(s[0],u+0),e._cache.writeUInt32BE(s[1],u+4),e._cache.writeUInt32BE(s[2],u+8),e._cache.writeUInt32BE(s[3],u+12)}var f=e._cache.slice(0,t.length);return e._cache=e._cache.slice(t.length),r(t,f)}},function(e,t){e.exports=function(e){for(var t,n=e.length;n--;){if(255!==(t=e.readUInt8(n))){t++,e.writeUInt8(t,n);break}e.writeUInt8(0,n)}}},function(e){e.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},function(e,t,n){var r=n(37),i=n(3).Buffer,o=n(21),a=n(4),c=n(184),s=n(31),u=n(90);function f(e,t,n,a){o.call(this);var s=i.alloc(4,0);this._cipher=new r.AES(t);var f=this._cipher.encryptBlock(s);this._ghash=new c(f),n=function(e,t,n){if(12===t.length)return e._finID=i.concat([t,i.from([0,0,0,1])]),i.concat([t,i.from([0,0,0,2])]);var r=new c(n),o=t.length,a=o%16;r.update(t),a&&(a=16-a,r.update(i.alloc(a,0))),r.update(i.alloc(8,0));var s=8*o,f=i.alloc(8);f.writeUIntBE(s,0,8),r.update(f),e._finID=r.state;var l=i.from(e._finID);return u(l),l}(this,n,f),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(f,o),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=i.alloc(t,0),this._ghash.update(t))}this._called=!0;var n=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(n),this._len+=e.length,n},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=s(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var n=0;e.length!==t.length&&n++;for(var r=Math.min(e.length,t.length),i=0;i<r;++i)n+=e[i]^t[i];return n}(e,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=e,this._cipher.scrub()},f.prototype.getAuthTag=function(){if(this._decrypt||!i.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag},f.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e},f.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length},e.exports=f},function(e,t,n){var r=n(37),i=n(3).Buffer,o=n(21);function a(e,t,n,a){o.call(this),this._cipher=new r.AES(t),this._prev=i.from(n),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._mode=e}n(4)(a,o),a.prototype._update=function(e){return this._mode.encrypt(this,e,this._decrypt)},a.prototype._final=function(){this._cipher.scrub()},e.exports=a},function(e,t,n){var r=n(25);e.exports=y,y.simpleSieve=_,y.fermatTest=E;var i=n(6),o=new i(24),a=new(n(95)),c=new i(1),s=new i(2),u=new i(5),f=(new i(16),new i(8),new i(10)),l=new i(3),h=(new i(7),new i(11)),d=new i(4),p=(new i(12),null);function b(){if(null!==p)return p;var e=[];e[0]=2;for(var t=1,n=3;n<1048576;n+=2){for(var r=Math.ceil(Math.sqrt(n)),i=0;i<t&&e[i]<=r&&n%e[i]!=0;i++);t!==i&&e[i]<=r||(e[t++]=n)}return p=e,e}function _(e){for(var t=b(),n=0;n<t.length;n++)if(0===e.modn(t[n]))return 0===e.cmpn(t[n]);return!0}function E(e){var t=i.mont(e);return 0===s.toRed(t).redPow(e.subn(1)).fromRed().cmpn(1)}function y(e,t){if(e<16)return new i(2===t||5===t?[140,123]:[140,39]);var n,p;for(t=new i(t);;){for(n=new i(r(Math.ceil(e/8)));n.bitLength()>e;)n.ishrn(1);if(n.isEven()&&n.iadd(c),n.testn(1)||n.iadd(s),t.cmp(s)){if(!t.cmp(u))for(;n.mod(f).cmp(l);)n.iadd(d)}else for(;n.mod(o).cmp(h);)n.iadd(d);if(_(p=n.shrn(1))&&_(n)&&E(p)&&E(n)&&a.test(p)&&a.test(n))return n}}},function(e,t,n){var r=n(6),i=n(55);function o(e){this.rand=e||new i.Rand}e.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),n=Math.ceil(t/8);do{var i=new r(this.rand.generate(n))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var n=t.sub(e);return e.add(this._randbelow(n))},o.prototype.test=function(e,t,n){var i=e.bitLength(),o=r.mont(e),a=new r(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var c=e.subn(1),s=0;!c.testn(s);s++);for(var u=e.shrn(s),f=c.toRed(o);t>0;t--){var l=this._randrange(new r(2),c);n&&n(l);var h=l.toRed(o).redPow(u);if(0!==h.cmp(a)&&0!==h.cmp(f)){for(var d=1;d<s;d++){if(0===(h=h.redSqr()).cmp(a))return!1;if(0===h.cmp(f))break}if(d===s)return!1}}return!0},o.prototype.getDivisor=function(e,t){var n=e.bitLength(),i=r.mont(e),o=new r(1).toRed(i);t||(t=Math.max(1,n/48|0));for(var a=e.subn(1),c=0;!a.testn(c);c++);for(var s=e.shrn(c),u=a.toRed(i);t>0;t--){var f=this._randrange(new r(2),a),l=e.gcd(f);if(0!==l.cmpn(1))return l;var h=f.toRed(i).redPow(s);if(0!==h.cmp(o)&&0!==h.cmp(u)){for(var d=1;d<c;d++){if(0===(h=h.redSqr()).cmp(o))return h.fromRed().subn(1).gcd(e);if(0===h.cmp(u))break}if(d===c)return(h=h.redSqr()).fromRed().subn(1).gcd(e)}}return!1}},function(e,t,n){"use strict";var r=t;function i(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",n=0;n<e.length;n++)t+=i(e[n].toString(16));return t}r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r<e.length;r++)n[r]=0|e[r];return n}if("hex"===t){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(r=0;r<e.length;r+=2)n.push(parseInt(e[r]+e[r+1],16))}else for(r=0;r<e.length;r++){var i=e.charCodeAt(r),o=i>>8,a=255&i;o?n.push(o,a):n.push(a)}return n},r.zero2=i,r.toHex=o,r.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,n){"use strict";var r=t;r.base=n(39),r.short=n(196),r.mont=n(197),r.edwards=n(198)},function(e,t,n){"use strict";var r=n(16).rotr32;function i(e,t,n){return e&t^~e&n}function o(e,t,n){return e&t^e&n^t&n}function a(e,t,n){return e^t^n}t.ft_1=function(e,t,n,r){return 0===e?i(t,n,r):1===e||3===e?a(t,n,r):2===e?o(t,n,r):void 0},t.ch32=i,t.maj32=o,t.p32=a,t.s0_256=function(e){return r(e,2)^r(e,13)^r(e,22)},t.s1_256=function(e){return r(e,6)^r(e,11)^r(e,25)},t.g0_256=function(e){return r(e,7)^r(e,18)^e>>>3},t.g1_256=function(e){return r(e,17)^r(e,19)^e>>>10}},function(e,t,n){"use strict";var r=n(16),i=n(32),o=n(98),a=n(11),c=r.sum32,s=r.sum32_4,u=r.sum32_5,f=o.ch32,l=o.maj32,h=o.s0_256,d=o.s1_256,p=o.g0_256,b=o.g1_256,_=i.BlockHash,E=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function y(){if(!(this instanceof y))return new y;_.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=E,this.W=new Array(64)}r.inherits(y,_),e.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=s(b(n[r-2]),n[r-7],p(n[r-15]),n[r-16]);var i=this.h[0],o=this.h[1],_=this.h[2],E=this.h[3],y=this.h[4],v=this.h[5],g=this.h[6],m=this.h[7];for(a(this.k.length===n.length),r=0;r<n.length;r++){var S=u(m,d(y),f(y,v,g),this.k[r],n[r]),O=c(h(i),l(i,o,_));m=g,g=v,v=y,y=c(E,S),E=_,_=o,o=i,i=c(S,O)}this.h[0]=c(this.h[0],i),this.h[1]=c(this.h[1],o),this.h[2]=c(this.h[2],_),this.h[3]=c(this.h[3],E),this.h[4]=c(this.h[4],y),this.h[5]=c(this.h[5],v),this.h[6]=c(this.h[6],g),this.h[7]=c(this.h[7],m)},y.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(e,t,n){"use strict";var r=n(16),i=n(32),o=n(11),a=r.rotr64_hi,c=r.rotr64_lo,s=r.shr64_hi,u=r.shr64_lo,f=r.sum64,l=r.sum64_hi,h=r.sum64_lo,d=r.sum64_4_hi,p=r.sum64_4_lo,b=r.sum64_5_hi,_=r.sum64_5_lo,E=i.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;E.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function g(e,t,n,r,i){var o=e&n^~e&i;return o<0&&(o+=4294967296),o}function m(e,t,n,r,i,o){var a=t&r^~t&o;return a<0&&(a+=4294967296),a}function S(e,t,n,r,i){var o=e&n^e&i^n&i;return o<0&&(o+=4294967296),o}function O(e,t,n,r,i,o){var a=t&r^t&o^r&o;return a<0&&(a+=4294967296),a}function A(e,t){var n=a(e,t,28)^a(t,e,2)^a(t,e,7);return n<0&&(n+=4294967296),n}function T(e,t){var n=c(e,t,28)^c(t,e,2)^c(t,e,7);return n<0&&(n+=4294967296),n}function N(e,t){var n=a(e,t,14)^a(e,t,18)^a(t,e,9);return n<0&&(n+=4294967296),n}function M(e,t){var n=c(e,t,14)^c(e,t,18)^c(t,e,9);return n<0&&(n+=4294967296),n}function w(e,t){var n=a(e,t,1)^a(e,t,8)^s(e,t,7);return n<0&&(n+=4294967296),n}function C(e,t){var n=c(e,t,1)^c(e,t,8)^u(e,t,7);return n<0&&(n+=4294967296),n}function I(e,t){var n=a(e,t,19)^a(t,e,29)^s(e,t,6);return n<0&&(n+=4294967296),n}function P(e,t){var n=c(e,t,19)^c(t,e,29)^u(e,t,6);return n<0&&(n+=4294967296),n}r.inherits(v,E),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(e,t){for(var n=this.W,r=0;r<32;r++)n[r]=e[t+r];for(;r<n.length;r+=2){var i=I(n[r-4],n[r-3]),o=P(n[r-4],n[r-3]),a=n[r-14],c=n[r-13],s=w(n[r-30],n[r-29]),u=C(n[r-30],n[r-29]),f=n[r-32],l=n[r-31];n[r]=d(i,o,a,c,s,u,f,l),n[r+1]=p(i,o,a,c,s,u,f,l)}},v.prototype._update=function(e,t){this._prepareBlock(e,t);var n=this.W,r=this.h[0],i=this.h[1],a=this.h[2],c=this.h[3],s=this.h[4],u=this.h[5],d=this.h[6],p=this.h[7],E=this.h[8],y=this.h[9],v=this.h[10],w=this.h[11],C=this.h[12],I=this.h[13],P=this.h[14],L=this.h[15];o(this.k.length===n.length);for(var R=0;R<n.length;R+=2){var D=P,j=L,U=N(E,y),k=M(E,y),x=g(E,y,v,w,C),B=m(E,y,v,w,C,I),F=this.k[R],V=this.k[R+1],Y=n[R],G=n[R+1],H=b(D,j,U,k,x,B,F,V,Y,G),q=_(D,j,U,k,x,B,F,V,Y,G);D=A(r,i),j=T(r,i),U=S(r,i,a,c,s),k=O(r,i,a,c,s,u);var z=l(D,j,U,k),K=h(D,j,U,k);P=C,L=I,C=v,I=w,v=E,w=y,E=l(d,p,H,q),y=h(p,p,H,q),d=s,p=u,s=a,u=c,a=r,c=i,r=l(H,q,z,K),i=h(H,q,z,K)}f(this.h,0,r,i),f(this.h,2,a,c),f(this.h,4,s,u),f(this.h,6,d,p),f(this.h,8,E,y),f(this.h,10,v,w),f(this.h,12,C,I),f(this.h,14,P,L)},v.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(e,t,n){var r=n(4),i=n(34).Reporter,o=n(5).Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function c(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return e instanceof c||(e=new c(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}r(a,i),t.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var n=new a(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.EncoderBuffer=c,c.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach((function(n){n.join(e,t),t+=n.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},function(e,t,n){var r=t;r._reverse=function(e){var t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);var r=e[n];t[r]=n})),t},r.der=n(218)},function(e,t,n){var r=n(4),i=n(33),o=i.base,a=i.bignum,c=i.constants.der;function s(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new u,this.tree._init(e.body)}function u(e){o.Node.call(this,"der",e)}function f(e,t){var n=e.readUInt8(t);if(e.isError(n))return n;var r=c.tagClass[n>>6],i=0==(32&n);if(31==(31&n)){var o=n;for(n=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;n<<=7,n|=127&o}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:c.tag[n]}}function l(e,t,n){var r=e.readUInt8(n);if(e.isError(r))return r;if(!t&&128===r)return null;if(0==(128&r))return r;var i=127&r;if(i>4)return e.error("length octect is too long");r=0;for(var o=0;o<i;o++){r<<=8;var a=e.readUInt8(n);if(e.isError(a))return a;r|=a}return r}e.exports=s,s.prototype.decode=function(e,t){return e instanceof o.DecoderBuffer||(e=new o.DecoderBuffer(e,t)),this.tree._decode(e,t)},r(u,o.Node),u.prototype._peekTag=function(e,t,n){if(e.isEmpty())return!1;var r=e.save(),i=f(e,'Failed to peek tag: "'+t+'"');return e.isError(i)?i:(e.restore(r),i.tag===t||i.tagStr===t||i.tagStr+"of"===t||n)},u.prototype._decodeTag=function(e,t,n){var r=f(e,'Failed to decode tag of "'+t+'"');if(e.isError(r))return r;var i=l(e,r.primitive,'Failed to get length of "'+t+'"');if(e.isError(i))return i;if(!n&&r.tag!==t&&r.tagStr!==t&&r.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(r.primitive||null!==i)return e.skip(i,'Failed to match body of: "'+t+'"');var o=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(i=e.offset-o.offset,e.restore(o),e.skip(i,'Failed to match body of: "'+t+'"'))},u.prototype._skipUntilEnd=function(e,t){for(;;){var n=f(e,t);if(e.isError(n))return n;var r,i=l(e,n.primitive,t);if(e.isError(i))return i;if(r=n.primitive||null!==i?e.skip(i):this._skipUntilEnd(e,t),e.isError(r))return r;if("end"===n.tagStr)break}},u.prototype._decodeList=function(e,t,n,r){for(var i=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var a=n.decode(e,"der",r);if(e.isError(a)&&o)break;i.push(a)}return i},u.prototype._decodeStr=function(e,t){if("bitstr"===t){var n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}if("bmpstr"===t){var r=e.raw();if(r.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var i="",o=0;o<r.length/2;o++)i+=String.fromCharCode(r.readUInt16BE(2*o));return i}if("numstr"===t){var a=e.raw().toString("ascii");return this._isNumstr(a)?a:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var c=e.raw().toString("ascii");return this._isPrintstr(c)?c:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},u.prototype._decodeObjid=function(e,t,n){for(var r,i=[],o=0;!e.isEmpty();){var a=e.readUInt8();o<<=7,o|=127&a,0==(128&a)&&(i.push(o),o=0)}128&a&&i.push(o);var c=i[0]/40|0,s=i[0]%40;if(r=n?i:[c,s].concat(i.slice(1)),t){var u=t[r.join(" ")];void 0===u&&(u=t[r.join(".")]),void 0!==u&&(r=u)}return r},u.prototype._decodeTime=function(e,t){var n=e.raw().toString();if("gentime"===t)var r=0|n.slice(0,4),i=0|n.slice(4,6),o=0|n.slice(6,8),a=0|n.slice(8,10),c=0|n.slice(10,12),s=0|n.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");r=0|n.slice(0,2),i=0|n.slice(2,4),o=0|n.slice(4,6),a=0|n.slice(6,8),c=0|n.slice(8,10),s=0|n.slice(10,12);r=r<70?2e3+r:1900+r}return Date.UTC(r,i-1,o,a,c,s,0)},u.prototype._decodeNull=function(e){return null},u.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},u.prototype._decodeInt=function(e,t){var n=e.raw(),r=new a(n);return t&&(r=t[r.toString(10)]||r),r},u.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},function(e,t,n){var r=n(4),i=n(5).Buffer,o=n(33),a=o.base,c=o.constants.der;function s(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new u,this.tree._init(e.body)}function u(e){a.Node.call(this,"der",e)}function f(e){return e<10?"0"+e:e}e.exports=s,s.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},r(u,a.Node),u.prototype._encodeComposite=function(e,t,n,r){var o,a=function(e,t,n,r){var i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(c.tagByName.hasOwnProperty(e))i=c.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return r.error("Unknown tag: "+e);i=e}if(i>=31)return r.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=c.tagClassByName[n||"universal"]<<6}(e,t,n,this.reporter);if(r.length<128)return(o=new i(2))[0]=a,o[1]=r.length,this._createEncoderBuffer([o,r]);for(var s=1,u=r.length;u>=256;u>>=8)s++;(o=new i(2+s))[0]=a,o[1]=128|s;u=1+s;for(var f=r.length;f>0;u--,f>>=8)o[u]=255&f;return this._createEncoderBuffer([o,r])},u.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var n=new i(2*e.length),r=0;r<e.length;r++)n.writeUInt16BE(e.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)?this._createEncoderBuffer(e):"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},u.prototype._encodeObjid=function(e,t,n){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var r=0;r<e.length;r++)e[r]|=0}else if(Array.isArray(e)){e=e.slice();for(r=0;r<e.length;r++)e[r]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(r=0;r<e.length;r++){var a=e[r];for(o++;a>=128;a>>=7)o++}var c=new i(o),s=c.length-1;for(r=e.length-1;r>=0;r--){a=e[r];for(c[s--]=127&a;(a>>=7)>0;)c[s--]=128|127&a}return this._createEncoderBuffer(c)},u.prototype._encodeTime=function(e,t){var n,r=new Date(e);return"gentime"===t?n=[f(r.getFullYear()),f(r.getUTCMonth()+1),f(r.getUTCDate()),f(r.getUTCHours()),f(r.getUTCMinutes()),f(r.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[f(r.getFullYear()%100),f(r.getUTCMonth()+1),f(r.getUTCDate()),f(r.getUTCHours()),f(r.getUTCMinutes()),f(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var n=e.toArray();!e.sign&&128&n[0]&&n.unshift(0),e=new i(n)}if(i.isBuffer(e)){var r=e.length;0===e.length&&r++;var o=new i(r);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);r=1;for(var a=e;a>=256;a>>=8)r++;for(a=(o=new Array(r)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},u.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},u.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},u.prototype._skipDefault=function(e,t,n){var r,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,n).join()),o.length!==i.defaultBuffer.length)return!1;for(r=0;r<o.length;r++)if(o[r]!==i.defaultBuffer[r])return!1;return!0}},function(e){e.exports=JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}')},function(e,t,n){var r=n(30),i=n(3).Buffer;function o(e){var t=i.allocUnsafe(4);return t.writeUInt32BE(e,0),t}e.exports=function(e,t){for(var n,a=i.alloc(0),c=0;a.length<t;)n=o(c++),a=i.concat([a,r("sha1").update(e).update(n).digest()]);return a.slice(0,t)}},function(e,t){e.exports=function(e,t){for(var n=e.length,r=-1;++r<n;)e[r]^=t[r];return e}},function(e,t,n){var r=n(6),i=n(3).Buffer;e.exports=function(e,t){return i.from(e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed().toArray())}},function(e,t,n){var r=n(5).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||r.isBuffer(e)?e.toString():JSON.stringify(e)}},function(e,t,n){var r=n(41),i=function(e,t){r.call(this,e),this.name="NotBeforeError",this.date=t};(i.prototype=Object.create(r.prototype)).constructor=i,e.exports=i},function(e,t,n){var r=n(41),i=function(e,t){r.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(i.prototype=Object.create(r.prototype)).constructor=i,e.exports=i},function(e,t,n){var r=n(236);e.exports=function(e,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var i=r(e);if(void 0===i)return;return Math.floor(n+i/1e3)}return"number"==typeof e?n+e:void 0}},function(e,t,n){(function(t){var r=n(237);e.exports=r.satisfies(t.version,"^6.12.0 || >=8.0.0")}).call(this,n(10))},function(e,t,n){"use strict";var r=String.prototype.replace,i=/%20/g,o=n(60),a={RFC1738:"RFC1738",RFC3986:"RFC3986"};e.exports=o.assign({default:a.RFC3986,formatters:{RFC1738:function(e){return r.call(e,i,"+")},RFC3986:function(e){return String(e)}}},a)},function(e,t,n){var r;e.exports=(r=r||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},i=r.lib={},o=i.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},a=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||s).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var a=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=a<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)t[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],i=function(t){t=t;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var c=i(4294967296*(n||e.random()));n=987654071*c(),r.push(4294967296*c()|0)}return new a.init(r,t)}}),c=r.enc={},s=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},u=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},f=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,c=i/(4*o),s=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*o,u=e.min(4*s,i);if(s){for(var f=0;f<s;f+=o)this._doProcessBlock(r,f);var l=r.splice(0,s);n.sigBytes-=u}return new a.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h=(i.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17);function i(e,t,n){for(var i=n||r.defaultEquals,o=e.length,a=0;a<o;a++)if(i(e[a],t))return a;return-1}t.indexOf=i,t.lastIndexOf=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length-1;o>=0;o--)if(i(e[o],t))return o;return-1},t.contains=function(e,t,n){return i(e,t,n)>=0},t.remove=function(e,t,n){var r=i(e,t,n);return!(r<0)&&(e.splice(r,1),!0)},t.frequency=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length,a=0,c=0;c<o;c++)i(e[c],t)&&a++;return a},t.equals=function(e,t,n){var i=n||r.defaultEquals;if(e.length!==t.length)return!1;for(var o=e.length,a=0;a<o;a++)if(!i(e[a],t[a]))return!1;return!0},t.copy=function(e){return e.concat()},t.swap=function(e,t,n){if(t<0||t>=e.length||n<0||n>=e.length)return!1;var r=e[t];return e[t]=e[n],e[n]=r,!0},t.toString=function(e){return"["+e.toString()+"]"},t.forEach=function(e,t){for(var n=0,r=e;n<r.length;n++){if(!1===t(r[n]))return}}},function(e,t,n){var r=n(248),i=n(249);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var c=0;c<16;++c)t[o+c]=a[c];return t||i(a)}},function(e,t,n){e.exports=function e(t,n,r){function i(a,c){if(!n[a]){if(!t[a]){if(o)return o(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return i(t[a][1][e]||e)}),u,u.exports,e,t,n,r)}return n[a].exports}for(var o=!1,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,a;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(a=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],a.set(o,i),i+=o.length;return a}},a={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,a))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var a=new r.Buf8(256),c=0;c<256;c++)a[c]=c>=252?6:c>=248?5:c>=240?4:c>=224?3:c>=192?2:1;function s(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",a=0;a<t;a++)n+=String.fromCharCode(e[a]);return n}a[254]=a[254]=1,n.string2buf=function(e){var t,n,i,o,a,c=e.length,s=0;for(o=0;o<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<c&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(s),a=0,o=0;a<s;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<c&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t},n.buf2binstring=function(e){return s(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,c=t||e.length,u=new Array(2*c);for(r=0,n=0;n<c;)if((i=e[n++])<128)u[r++]=i;else if((o=a[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<c;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return s(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0?t:0===n?t:n+a[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==n;){n-=a=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,a=i+n;e^=-1;for(var c=i;c<a;c++)e=e>>>8^o[255&(e^t[c])];return-1^e}},{}],5:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),a=e("./adler32"),c=e("./crc32"),s=e("./messages");function u(e,t){return e.msg=s[t],t}function f(e){return(e<<1)-(e>4?9:0)}function l(e){for(var t=e.length;--t>=0;)e[t]=0}function h(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function d(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,h(e.strm)}function p(e,t){e.pending_buf[e.pending++]=t}function b(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function _(e,t){var n,r,i=e.max_chain_length,o=e.strstart,a=e.prev_length,c=e.nice_match,s=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,u=e.window,f=e.w_mask,l=e.prev,h=e.strstart+258,d=u[o+a-1],p=u[o+a];e.prev_length>=e.good_match&&(i>>=2),c>e.lookahead&&(c=e.lookahead);do{if(u[(n=t)+a]===p&&u[n+a-1]===d&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&o<h);if(r=258-(h-o),o=h-258,r>a){if(e.match_start=t,a=r,r>=c)break;d=u[o+a-1],p=u[o+a]}}}while((t=l[t&f])>s&&0!=--i);return a<=e.lookahead?a:e.lookahead}function E(e){var t,n,r,o,s,u,f,l,h,d,p=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=p+(p-262)){i.arraySet(e.window,e.window,p,p,0),e.match_start-=p,e.strstart-=p,e.block_start-=p,t=n=e.hash_size;do{r=e.head[--t],e.head[t]=r>=p?r-p:0}while(--n);t=n=p;do{r=e.prev[--t],e.prev[t]=r>=p?r-p:0}while(--n);o+=p}if(0===e.strm.avail_in)break;if(u=e.strm,f=e.window,l=e.strstart+e.lookahead,h=o,d=void 0,(d=u.avail_in)>h&&(d=h),n=0===d?0:(u.avail_in-=d,i.arraySet(f,u.input,u.next_in,d,l),1===u.state.wrap?u.adler=a(u.adler,f,d,l):2===u.state.wrap&&(u.adler=c(u.adler,f,d,l)),u.next_in+=d,u.total_in+=d,d),e.lookahead+=n,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+3-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function y(e,t){for(var n,r;;){if(e.lookahead<262){if(E(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n)),e.match_length>=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(d(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(d(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?1:2}function v(e,t){for(var n,r,i;;){if(e.lookahead<262){if(E(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(d(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=o._tr_tally(e,0,e.window[e.strstart-1]))&&d(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=o._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(d(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?1:2}function g(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}function m(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),l(this.dyn_ltree),l(this.dyn_dtree),l(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),l(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),l(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function S(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=0,o._tr_init(t),0):u(e,-2)}function O(e){var t,n=S(e);return 0===n&&((t=e.state).window_size=2*t.w_size,l(t.head),t.max_lazy_match=r[t.level].max_lazy,t.good_match=r[t.level].good_length,t.nice_match=r[t.level].nice_length,t.max_chain_length=r[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),n}function A(e,t,n,r,o,a){if(!e)return-2;var c=1;if(-1===t&&(t=6),r<0?(c=0,r=-r):r>15&&(c=2,r-=16),o<1||o>9||8!==n||r<8||r>15||t<0||t>9||a<0||a>4)return u(e,-2);8===r&&(r=9);var s=new m;return e.state=s,s.strm=e,s.wrap=c,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=o+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new i.Buf8(2*s.w_size),s.head=new i.Buf16(s.hash_size),s.prev=new i.Buf16(s.w_size),s.lit_bufsize=1<<o+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new i.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=n,O(e)}r=[new g(0,0,0,0,(function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(E(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,d(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(d(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(d(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(d(e,!1),e.strm.avail_out),1)})),new g(4,4,8,4,y),new g(4,5,16,8,y),new g(4,6,32,32,y),new g(4,4,16,16,v),new g(8,16,32,32,v),new g(8,16,128,128,v),new g(8,32,128,256,v),new g(32,128,258,1024,v),new g(32,258,258,4096,v)],n.deflateInit=function(e,t){return A(e,t,8,15,8,0)},n.deflateInit2=A,n.deflateReset=O,n.deflateResetKeep=S,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?-2:(e.state.gzhead=t,0):-2},n.deflate=function(e,t){var n,i,a,s;if(!e||!e.state||t>5||t<0)return e?u(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return u(e,0===e.avail_out?-5:-2);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,p(i,31),p(i,139),p(i,8),i.gzhead?(p(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),p(i,255&i.gzhead.time),p(i,i.gzhead.time>>8&255),p(i,i.gzhead.time>>16&255),p(i,i.gzhead.time>>24&255),p(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),p(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(p(i,255&i.gzhead.extra.length),p(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=c(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(p(i,0),p(i,0),p(i,0),p(i,0),p(i,0),p(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),p(i,3),i.status=113);else{var _=8+(i.w_bits-8<<4)<<8;_|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(_|=32),_+=31-_%31,i.status=113,b(i,_),0!==i.strstart&&(b(i,e.adler>>>16),b(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(e.adler=c(e.adler,i.pending_buf,i.pending-a,a)),h(e),a=i.pending,i.pending!==i.pending_buf_size));)p(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(e.adler=c(e.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=c(e.adler,i.pending_buf,i.pending-a,a)),h(e),a=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,p(i,s)}while(0!==s);i.gzhead.hcrc&&i.pending>a&&(e.adler=c(e.adler,i.pending_buf,i.pending-a,a)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(e.adler=c(e.adler,i.pending_buf,i.pending-a,a)),h(e),a=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,p(i,s)}while(0!==s);i.gzhead.hcrc&&i.pending>a&&(e.adler=c(e.adler,i.pending_buf,i.pending-a,a)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&h(e),i.pending+2<=i.pending_buf_size&&(p(i,255&e.adler),p(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(h(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&f(t)<=f(n)&&4!==t)return u(e,-5);if(666===i.status&&0!==e.avail_in)return u(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var y=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(E(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(d(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(d(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,a,c=e.window;;){if(e.lookahead<=258){if(E(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=c[i=e.strstart-1])===c[++i]&&r===c[++i]&&r===c[++i]){a=e.strstart+258;do{}while(r===c[++i]&&r===c[++i]&&r===c[++i]&&r===c[++i]&&r===c[++i]&&r===c[++i]&&r===c[++i]&&r===c[++i]&&i<a);e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(d(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(d(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(d(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==y&&4!==y||(i.status=666),1===y||3===y)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===y&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(l(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),h(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(p(i,255&e.adler),p(i,e.adler>>8&255),p(i,e.adler>>16&255),p(i,e.adler>>24&255),p(i,255&e.total_in),p(i,e.total_in>>8&255),p(i,e.total_in>>16&255),p(i,e.total_in>>24&255)):(b(i,e.adler>>>16),b(i,65535&e.adler)),h(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?u(e,-2):(e.state=null,113===t?u(e,-3):0):-2},n.deflateSetDictionary=function(e,t){var n,r,o,c,s,u,f,h,d=t.length;if(!e||!e.state)return-2;if(2===(c=(n=e.state).wrap)||1===c&&42!==n.status||n.lookahead)return-2;for(1===c&&(e.adler=a(e.adler,t,d,0)),n.wrap=0,d>=n.w_size&&(0===c&&(l(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,d-n.w_size,n.w_size,0),t=h,d=n.w_size),s=e.avail_in,u=e.next_in,f=e.input,e.avail_in=d,e.next_in=0,e.input=t,E(n);n.lookahead>=3;){r=n.strstart,o=n.lookahead-2;do{n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+3-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++}while(--o);n.strstart=r,n.lookahead=2,E(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=u,e.input=f,e.avail_in=s,n.wrap=c,0},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":4,"./messages":6,"./trees":7}],6:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],7:[function(e,t,n){"use strict";var r=e("../utils/common");function i(e){for(var t=e.length;--t>=0;)e[t]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],s=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);i(u);var f=new Array(60);i(f);var l=new Array(512);i(l);var h=new Array(256);i(h);var d=new Array(29);i(d);var p,b,_,E=new Array(30);function y(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function v(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function g(e){return e<256?l[e]:l[256+(e>>>7)]}function m(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function S(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,m(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function O(e,t,n){S(e,n[2*t],n[2*t+1])}function A(e,t){var n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}function T(e,t,n){var r,i,o=new Array(16),a=0;for(r=1;r<=15;r++)o[r]=a=a+n[r-1]<<1;for(i=0;i<=t;i++){var c=e[2*i+1];0!==c&&(e[2*i]=A(o[c]++,c))}}function N(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function M(e){e.bi_valid>8?m(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function w(e,t,n,r){var i=2*t,o=2*n;return e[i]<e[o]||e[i]===e[o]&&r[t]<=r[n]}function C(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&w(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!w(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function I(e,t,n){var r,i,c,s,u=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*u]<<8|e.pending_buf[e.d_buf+2*u+1],i=e.pending_buf[e.l_buf+u],u++,0===r?O(e,i,t):(O(e,(c=h[i])+256+1,t),0!==(s=o[c])&&S(e,i-=d[c],s),O(e,c=g(--r),n),0!==(s=a[c])&&S(e,r-=E[c],s))}while(u<e.last_lit);O(e,256,t)}function P(e,t){var n,r,i,o=t.dyn_tree,a=t.stat_desc.static_tree,c=t.stat_desc.has_stree,s=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<s;n++)0!==o[2*n]?(e.heap[++e.heap_len]=u=n,e.depth[n]=0):o[2*n+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,c&&(e.static_len-=a[2*i+1]);for(t.max_code=u,n=e.heap_len>>1;n>=1;n--)C(e,o,n);i=s;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],C(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,C(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,a,c,s=t.dyn_tree,u=t.max_code,f=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,b=0;for(o=0;o<=15;o++)e.bl_count[o]=0;for(s[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(o=s[2*s[2*(r=e.heap[n])+1]+1]+1)>p&&(o=p,b++),s[2*r+1]=o,r>u||(e.bl_count[o]++,a=0,r>=d&&(a=h[r-d]),c=s[2*r],e.opt_len+=c*(o+a),l&&(e.static_len+=c*(f[2*r+1]+a)));if(0!==b){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,b-=2}while(b>0);for(o=p;0!==o;o--)for(r=e.bl_count[o];0!==r;)(i=e.heap[--n])>u||(s[2*i+1]!==o&&(e.opt_len+=(o-s[2*i+1])*s[2*i],s[2*i+1]=o),r--)}}(e,t),T(o,u,e.bl_count)}function L(e,t,n){var r,i,o=-1,a=t[1],c=0,s=7,u=4;for(0===a&&(s=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=a,a=t[2*(r+1)+1],++c<s&&i===a||(c<u?e.bl_tree[2*i]+=c:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):c<=10?e.bl_tree[34]++:e.bl_tree[36]++,c=0,o=i,0===a?(s=138,u=3):i===a?(s=6,u=3):(s=7,u=4))}function R(e,t,n){var r,i,o=-1,a=t[1],c=0,s=7,u=4;for(0===a&&(s=138,u=3),r=0;r<=n;r++)if(i=a,a=t[2*(r+1)+1],!(++c<s&&i===a)){if(c<u)do{O(e,i,e.bl_tree)}while(0!=--c);else 0!==i?(i!==o&&(O(e,i,e.bl_tree),c--),O(e,16,e.bl_tree),S(e,c-3,2)):c<=10?(O(e,17,e.bl_tree),S(e,c-3,3)):(O(e,18,e.bl_tree),S(e,c-11,7));c=0,o=i,0===a?(s=138,u=3):i===a?(s=6,u=3):(s=7,u=4)}}i(E);var D=!1;function j(e,t,n,i){S(e,0+(i?1:0),3),function(e,t,n,i){M(e),i&&(m(e,n),m(e,~n)),r.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n,!0)}n._tr_init=function(e){D||(function(){var e,t,n,r,i,s=new Array(16);for(n=0,r=0;r<28;r++)for(d[r]=n,e=0;e<1<<o[r];e++)h[n++]=r;for(h[n-1]=r,i=0,r=0;r<16;r++)for(E[r]=i,e=0;e<1<<a[r];e++)l[i++]=r;for(i>>=7;r<30;r++)for(E[r]=i<<7,e=0;e<1<<a[r]-7;e++)l[256+i++]=r;for(t=0;t<=15;t++)s[t]=0;for(e=0;e<=143;)u[2*e+1]=8,e++,s[8]++;for(;e<=255;)u[2*e+1]=9,e++,s[9]++;for(;e<=279;)u[2*e+1]=7,e++,s[7]++;for(;e<=287;)u[2*e+1]=8,e++,s[8]++;for(T(u,287,s),e=0;e<30;e++)f[2*e+1]=5,f[2*e]=A(e,5);p=new y(u,o,257,286,15),b=new y(f,a,0,30,15),_=new y(new Array(0),c,0,19,7)}(),D=!0),e.l_desc=new v(e.dyn_ltree,p),e.d_desc=new v(e.dyn_dtree,b),e.bl_desc=new v(e.bl_tree,_),e.bi_buf=0,e.bi_valid=0,N(e)},n._tr_stored_block=j,n._tr_flush_block=function(e,t,n,r){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),P(e,e.l_desc),P(e,e.d_desc),a=function(e){var t;for(L(e,e.dyn_ltree,e.l_desc.max_code),L(e,e.dyn_dtree,e.d_desc.max_code),P(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*s[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?j(e,t,n,r):4===e.strategy||o===i?(S(e,2+(r?1:0),3),I(e,u,f)):(S(e,4+(r?1:0),3),function(e,t,n,r){var i;for(S(e,t-257,5),S(e,n-1,5),S(e,r-4,4),i=0;i<r;i++)S(e,e.bl_tree[2*s[i]+1],3);R(e,e.dyn_ltree,t-1),R(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),I(e,e.dyn_ltree,e.dyn_dtree)),N(e),r&&M(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(h[n]+256+1)]++,e.dyn_dtree[2*g(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){S(e,2,3),O(e,256,u),function(e){16===e.bi_valid?(m(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":1}],8:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/deflate.js":[function(e,t,n){"use strict";var r=e("./zlib/deflate"),i=e("./utils/common"),o=e("./utils/strings"),a=e("./zlib/messages"),c=e("./zlib/zstream"),s=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(a[n]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var f;if(f="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===s.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=r.deflateSetDictionary(this.strm,f)))throw new Error(a[n]);this._dict_set=!0}}function f(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}u.prototype.push=function(e,t){var n,a,c=this.strm,u=this.options.chunkSize;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=o.string2buf(e):"[object ArrayBuffer]"===s.call(e)?c.input=new Uint8Array(e):c.input=e,c.next_in=0,c.avail_in=c.input.length;do{if(0===c.avail_out&&(c.output=new i.Buf8(u),c.next_out=0,c.avail_out=u),1!==(n=r.deflate(c,a))&&0!==n)return this.onEnd(n),this.ended=!0,!1;0!==c.avail_out&&(0!==c.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(o.buf2binstring(i.shrinkBuf(c.output,c.next_out))):this.onData(i.shrinkBuf(c.output,c.next_out)))}while((c.avail_in>0||0===c.avail_out)&&1!==n);return 4===a?(n=r.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==a||(this.onEnd(0),c.avail_out=0,!0)},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=u,n.deflate=f,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,f(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,f(e,t)}},{"./utils/common":1,"./utils/strings":2,"./zlib/deflate":5,"./zlib/messages":6,"./zlib/zstream":8}]},{},[])("/lib/deflate.js")},function(e,t,n){var r;e.exports=(r=n(115),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,c=[];!function(){for(var t=0;t<64;t++)c[t]=4294967296*e.abs(e.sin(t+1))|0}();var s=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],s=e[t+1],d=e[t+2],p=e[t+3],b=e[t+4],_=e[t+5],E=e[t+6],y=e[t+7],v=e[t+8],g=e[t+9],m=e[t+10],S=e[t+11],O=e[t+12],A=e[t+13],T=e[t+14],N=e[t+15],M=o[0],w=o[1],C=o[2],I=o[3];M=u(M,w,C,I,a,7,c[0]),I=u(I,M,w,C,s,12,c[1]),C=u(C,I,M,w,d,17,c[2]),w=u(w,C,I,M,p,22,c[3]),M=u(M,w,C,I,b,7,c[4]),I=u(I,M,w,C,_,12,c[5]),C=u(C,I,M,w,E,17,c[6]),w=u(w,C,I,M,y,22,c[7]),M=u(M,w,C,I,v,7,c[8]),I=u(I,M,w,C,g,12,c[9]),C=u(C,I,M,w,m,17,c[10]),w=u(w,C,I,M,S,22,c[11]),M=u(M,w,C,I,O,7,c[12]),I=u(I,M,w,C,A,12,c[13]),C=u(C,I,M,w,T,17,c[14]),M=f(M,w=u(w,C,I,M,N,22,c[15]),C,I,s,5,c[16]),I=f(I,M,w,C,E,9,c[17]),C=f(C,I,M,w,S,14,c[18]),w=f(w,C,I,M,a,20,c[19]),M=f(M,w,C,I,_,5,c[20]),I=f(I,M,w,C,m,9,c[21]),C=f(C,I,M,w,N,14,c[22]),w=f(w,C,I,M,b,20,c[23]),M=f(M,w,C,I,g,5,c[24]),I=f(I,M,w,C,T,9,c[25]),C=f(C,I,M,w,p,14,c[26]),w=f(w,C,I,M,v,20,c[27]),M=f(M,w,C,I,A,5,c[28]),I=f(I,M,w,C,d,9,c[29]),C=f(C,I,M,w,y,14,c[30]),M=l(M,w=f(w,C,I,M,O,20,c[31]),C,I,_,4,c[32]),I=l(I,M,w,C,v,11,c[33]),C=l(C,I,M,w,S,16,c[34]),w=l(w,C,I,M,T,23,c[35]),M=l(M,w,C,I,s,4,c[36]),I=l(I,M,w,C,b,11,c[37]),C=l(C,I,M,w,y,16,c[38]),w=l(w,C,I,M,m,23,c[39]),M=l(M,w,C,I,A,4,c[40]),I=l(I,M,w,C,a,11,c[41]),C=l(C,I,M,w,p,16,c[42]),w=l(w,C,I,M,E,23,c[43]),M=l(M,w,C,I,g,4,c[44]),I=l(I,M,w,C,O,11,c[45]),C=l(C,I,M,w,N,16,c[46]),M=h(M,w=l(w,C,I,M,d,23,c[47]),C,I,a,6,c[48]),I=h(I,M,w,C,y,10,c[49]),C=h(C,I,M,w,T,15,c[50]),w=h(w,C,I,M,_,21,c[51]),M=h(M,w,C,I,O,6,c[52]),I=h(I,M,w,C,p,10,c[53]),C=h(C,I,M,w,m,15,c[54]),w=h(w,C,I,M,s,21,c[55]),M=h(M,w,C,I,v,6,c[56]),I=h(I,M,w,C,N,10,c[57]),C=h(C,I,M,w,E,15,c[58]),w=h(w,C,I,M,A,21,c[59]),M=h(M,w,C,I,b,6,c[60]),I=h(I,M,w,C,S,10,c[61]),C=h(C,I,M,w,d,15,c[62]),w=h(w,C,I,M,g,21,c[63]),o[0]=o[0]+M|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+I|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296),a=r;n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(n.length+1),this._process();for(var c=this._hash,s=c.words,u=0;u<4;u++){var f=s[u];s[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,i,o,a){var c=e+(t&n|~t&r)+i+a;return(c<<o|c>>>32-o)+t}function f(e,t,n,r,i,o,a){var c=e+(t&r|n&~r)+i+a;return(c<<o|c>>>32-o)+t}function l(e,t,n,r,i,o,a){var c=e+(t^n^r)+i+a;return(c<<o|c>>>32-o)+t}function h(e,t,n,r,i,o,a){var c=e+(n^(t|~r))+i+a;return(c<<o|c>>>32-o)+t}t.MD5=o._createHelper(s),t.HmacMD5=o._createHmacHelper(s)}(Math),r.MD5)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(251),i=function(){function e(){this.list=new r.default}return e.prototype.enqueue=function(e){return this.list.add(e)},e.prototype.add=function(e){return this.list.add(e)},e.prototype.dequeue=function(){if(0!==this.list.size()){var e=this.list.first();return this.list.removeElementAtIndex(0),e}},e.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},e.prototype.size=function(){return this.list.size()},e.prototype.contains=function(e,t){return this.list.contains(e,t)},e.prototype.isEmpty=function(){return this.list.size()<=0},e.prototype.clear=function(){this.list.clear()},e.prototype.forEach=function(e){this.list.forEach(e)},e}();t.default=i},function(e,t,n){var r=n(252);function i(){}function o(e,t,n){null==n&&(n=a),cordova.exec((function(){var e=Array.prototype.slice.call(arguments);e.unshift(null),n.apply(null,e)}),(function(e){e=e instanceof Error?e:new Error(e),n(e)}),"DownloadManagerPlugin",e,t||[])}function a(){}e.exports=new i,i.prototype.enqueue=function(e,t){"string"==typeof e&&(e={uri:e}),e.url&&(e.uri=e.url),r("string"==typeof e.uri,"req.uri must be string"),r(null==t||"function"==typeof t,"cb must be function"),r(null==e.title||"string"==typeof e.title,"req.title must be string"),r(null==e.description||"string"==typeof e.description,"req.description must be string"),r(null==e.mimeType||"string"==typeof e.mimeType,"req.mimeType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.dirType,"req.destinationInExternalFilesDir.dirType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.subPath,"req.destinationInExternalFilesDir.subPath must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.dirType,"req.destinationInExternalPublicDir.dirType must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.subPath,"req.destinationInExternalPublicDir.subPath must be string"),r(null==e.destinationUri||"string"==typeof e.destinationUri,"req.destinationUri must be string"),r(null==e.visibleInDownloadsUi||"boolean"==typeof e.visibleInDownloadsUi,"req.visibleInDownloadsUi must be boolean"),r(null==e.notificationVisibility||Number.isSafeInteger(e.notificationVisibility),"req.notificationVisibility must be safe integer"),o("enqueue",[e],t)},i.prototype.query=function(e,t){"function"==typeof e&&(t=e,e=null),null==e&&(e={}),r("function"==typeof t,"cb must be function"),o("query",[e],t)},i.prototype.remove=function(e,t){r(Array.isArray(e),"ids must be array"),r(null==t||"function"==typeof t,"cb must be function"),o("remove",e,t)},i.prototype.addCompletedDownload=function(e,t){o("addCompletedDownload",[e],t)},i.prototype.fetchSpeedLog=function(e){o("fetchSpeedLog",[],e)}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(123),a=n(9),c=n(18),s=n(7),u=n(63),f=n(124),l=n(131),h=n(133),d=n(22),p=n(28),b=n(136),_=n(137),E=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error(""+a.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);if(void 0===t.defaultScope)t.defaultScope=c.BindingScopeEnum.Transient;else if(t.defaultScope!==c.BindingScopeEnum.Singleton&&t.defaultScope!==c.BindingScopeEnum.Transient&&t.defaultScope!==c.BindingScopeEnum.Request)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=d.id(),this._bindingDictionary=new _.Lookup,this._snapshots=[],this._middleware=null,this.parent=null,this._metadataReader=new u.MetadataReader}return e.merge=function(t,n){var r=new e,i=f.getBindingDictionary(r),o=f.getBindingDictionary(t),a=f.getBindingDictionary(n);function c(e,t){e.traverse((function(e,n){n.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return c(o,i),c(a,i),r},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=this._getContainerModuleHelpersFactory(),r=0,i=e;r<i.length;r++){var o=i[r],a=n(o.id);o.registry(a.bindFunction,a.unbindFunction,a.isboundFunction,a.rebindFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:t=this._getContainerModuleHelpersFactory(),n=0,r=e,i.label=1;case 1:return n<r.length?(o=r[n],a=t(o.id),[4,o.registry(a.bindFunction,a.unbindFunction,a.isboundFunction,a.rebindFunction)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=function(e){return function(t){return t.moduleId===e}};t.forEach((function(t){var n=r(t.id);e._bindingDictionary.removeByCondition(n)}))},e.prototype.bind=function(e){var t=this.options.defaultScope||c.BindingScopeEnum.Transient,n=new o.Binding(e,t);return this._bindingDictionary.add(e,n),new h.BindingToSyntax(n)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.unbind=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error(a.CANNOT_UNBIND+" "+p.getServiceIdentifierAsString(e))}},e.prototype.unbindAll=function(){this._bindingDictionary=new _.Lookup},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,s.NAMED_TAG,t)},e.prototype.isBoundTagged=function(e,t,n){var r=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),o=f.createMockRequest(this,e,t,n);r=i.some((function(e){return e.constraint(o)}))}return!r&&this.parent&&(r=this.parent.isBoundTagged(e,t,n)),r},e.prototype.snapshot=function(){this._snapshots.push(b.ContainerSnapshot.of(this._bindingDictionary.clone(),this._middleware))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error(a.NO_MORE_SNAPSHOTS_AVAILABLE);this._bindingDictionary=e.bindings,this._middleware=e.middleware},e.prototype.createChild=function(t){var n=new e(t||this.options);return n.parent=this,n},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),n)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){return this._get(!1,!1,c.TargetTypeEnum.Variable,e)},e.prototype.getTagged=function(e,t,n){return this._get(!1,!1,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getNamed=function(e,t){return this.getTagged(e,s.NAMED_TAG,t)},e.prototype.getAll=function(e){return this._get(!0,!0,c.TargetTypeEnum.Variable,e)},e.prototype.getAllTagged=function(e,t,n){return this._get(!1,!0,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,s.NAMED_TAG,t)},e.prototype.resolve=function(e){var t=this.createChild();return t.bind(e).toSelf(),t.get(e)},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},n=function(n){return function(r){var i=e.rebind.bind(e)(r);return t(i,n),i}};return function(r){return{bindFunction:(i=r,function(n){var r=e.bind.bind(e)(n);return t(r,i),r}),isboundFunction:function(t){return e.isBound.bind(e)(t)},rebindFunction:n(r),unbindFunction:function(t){e.unbind.bind(e)(t)}};var i}},e.prototype._get=function(e,t,n,r,i,o){var c=null,s={avoidConstraints:e,contextInterceptor:function(e){return e},isMultiInject:t,key:i,serviceIdentifier:r,targetType:n,value:o};if(this._middleware){if(null==(c=this._middleware(s)))throw new Error(a.INVALID_MIDDLEWARE_RETURN)}else c=this._planAndResolve()(s);return c},e.prototype._planAndResolve=function(){var e=this;return function(t){var n=f.plan(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return n=t.contextInterceptor(n),l.resolve(n)}},e}();t.Container=E},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(18),i=n(22),o=function(){function e(e,t){this.id=i.id(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=r.BindingTypeEnum.Invalid,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=!1,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.cache=this.cache,t},e}();t.Binding=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(125),i=n(9),o=n(18),a=n(7),c=n(64),s=n(28),u=n(126),f=n(13),l=n(127),h=n(128),d=n(130),p=n(66);function b(e){return e._bindingDictionary}function _(e,t,n,o,a){var c=E(n.container,a.serviceIdentifier),u=[];return c.length===r.BindingCount.NoBindingsAvailable&&n.container.options.autoBindInjectable&&"function"==typeof a.serviceIdentifier&&e.getConstructorMetadata(a.serviceIdentifier).compilerGeneratedMetadata&&(n.container.bind(a.serviceIdentifier).toSelf(),c=E(n.container,a.serviceIdentifier)),u=t?c:c.filter((function(e){var t=new d.Request(e.serviceIdentifier,n,o,e,a);return e.constraint(t)})),function(e,t,n,o){switch(t.length){case r.BindingCount.NoBindingsAvailable:if(n.isOptional())return t;var a=s.getServiceIdentifierAsString(e),c=i.NOT_REGISTERED;throw c+=s.listMetadataForTarget(a,n),c+=s.listRegisteredBindingsForServiceIdentifier(o,a,E),new Error(c);case r.BindingCount.OnlyOneBindingAvailable:if(!n.isArray())return t;case r.BindingCount.MultipleBindingsAvailable:default:if(n.isArray())return t;a=s.getServiceIdentifierAsString(e),c=i.AMBIGUOUS_MATCH+" "+a;throw c+=s.listRegisteredBindingsForServiceIdentifier(o,a,E),new Error(c)}}(a.serviceIdentifier,u,a,n.container),u}function E(e,t){var n=[],r=b(e);return r.hasKey(t)?n=r.get(t):null!==e.parent&&(n=E(e.parent,t)),n}t.getBindingDictionary=b,t.plan=function(e,t,n,r,b,E,y,v){void 0===v&&(v=!1);var g=new u.Context(t),m=function(e,t,n,r,i,o){var c=e?a.MULTI_INJECT_TAG:a.INJECT_TAG,s=new f.Metadata(c,n),u=new p.Target(t,r,n,s);if(void 0!==i){var l=new f.Metadata(i,o);u.metadata.push(l)}return u}(n,r,b,"",E,y);try{return function e(t,n,r,a,c,s){var u,f;if(null===c){u=_(t,n,a,null,s),f=new d.Request(r,a,null,u,s);var p=new l.Plan(a,f);a.addPlan(p)}else u=_(t,n,a,c,s),f=c.addChildRequest(s.serviceIdentifier,u,s);u.forEach((function(n){var r=null;if(s.isArray())r=f.addChildRequest(n.serviceIdentifier,n,s);else{if(n.cache)return;r=f}if(n.type===o.BindingTypeEnum.Instance&&null!==n.implementationType){var c=h.getDependencies(t,n.implementationType);if(!a.container.options.skipBaseClassChecks){var u=h.getBaseClassDependencyCount(t,n.implementationType);if(c.length<u){var l=i.ARGUMENTS_LENGTH_MISMATCH(h.getFunctionName(n.implementationType));throw new Error(l)}}c.forEach((function(n){e(t,!1,n.serviceIdentifier,a,r,n)}))}}))}(e,v,b,g,null,m),g}catch(e){throw c.isStackOverflowExeption(e)&&g.plan&&s.circularDependencyToException(g.plan.rootRequest),e}},t.createMockRequest=function(e,t,n,r){var i=new p.Target(o.TargetTypeEnum.Variable,"",t,new f.Metadata(n,r)),a=new u.Context(e);return new d.Request(t,a,null,[],i)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BindingCount={MultipleBindingsAvailable:2,NoBindingsAvailable:0,OnlyOneBindingAvailable:1}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22),i=function(){function e(e){this.id=r.id(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}();t.Context=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t){this.parentContext=e,this.rootRequest=t};t.Plan=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(65),i=n(9),o=n(18),a=n(7),c=n(28);t.getFunctionName=c.getFunctionName;var s=n(66);function u(e,t,n,r){var a=e.getConstructorMetadata(n),c=a.compilerGeneratedMetadata;if(void 0===c){var u=i.MISSING_INJECTABLE_ANNOTATION+" "+t+".";throw new Error(u)}var h=a.userGeneratedMetadata,d=Object.keys(h),p=function(e,t,n,r,i){for(var o=[],a=0;a<i;a++){var c=f(a,e,t,n,r);null!==c&&o.push(c)}return o}(r,t,c,h,0===n.length&&d.length>0?d.length:n.length),b=function e(t,n){for(var r=t.getPropertiesMetadata(n),i=[],a=Object.keys(r),c=0,u=a;c<u.length;c++){var f=u[c],h=r[f],d=l(r[f]),p=d.targetName||f,b=d.inject||d.multiInject,_=new s.Target(o.TargetTypeEnum.ClassProperty,p,b);_.metadata=h,i.push(_)}var E=Object.getPrototypeOf(n.prototype).constructor;if(E!==Object){var y=e(t,E);i=i.concat(y)}return i}(e,n);return p.concat(b)}function f(e,t,n,a,c){var u=c[e.toString()]||[],f=l(u),h=!0!==f.unmanaged,d=a[e],p=f.inject||f.multiInject;if((d=p||d)instanceof r.LazyServiceIdentifer&&(d=d.unwrap()),h){if(!t&&(d===Object||d===Function||void 0===d)){var b=i.MISSING_INJECT_ANNOTATION+" argument "+e+" in class "+n+".";throw new Error(b)}var _=new s.Target(o.TargetTypeEnum.ConstructorArgument,f.targetName,d);return _.metadata=u,_}return null}function l(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t[a.INJECT_TAG],multiInject:t[a.MULTI_INJECT_TAG],targetName:t[a.NAME_TAG],unmanaged:t[a.UNMANAGED_TAG]}}t.getDependencies=function(e,t){return u(e,c.getFunctionName(t),t,!1)},t.getBaseClassDependencyCount=function e(t,n){var r=Object.getPrototypeOf(n.prototype).constructor;if(r!==Object){var i=u(t,c.getFunctionName(r),r,!0),o=i.map((function(e){return e.metadata.filter((function(e){return e.key===a.UNMANAGED_TAG}))})),s=[].concat.apply([],o).length,f=i.length-s;return f>0?f:e(t,r)}return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,n=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},n)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}();t.QueryableString=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22),i=function(){function e(e,t,n,i,o){this.id=r.id(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=n,this.target=o,this.childRequests=[],this.bindings=Array.isArray(i)?i:[i],this.requestScope=null===n?new Map:null}return e.prototype.addChildRequest=function(t,n,r){var i=new e(t,this.parentContext,this,n,r);return this.childRequests.push(i),i},e}();t.Request=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(18),o=n(64),a=n(28),c=n(132),s=function(e,t,n){try{return n()}catch(n){throw o.isStackOverflowExeption(n)?new Error(r.CIRCULAR_DEPENDENCY_IN_FACTORY(e,t.toString())):n}},u=function(e){return function(t){t.parentContext.setCurrentRequest(t);var n=t.bindings,o=t.childRequests,f=t.target&&t.target.isArray(),l=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(f&&l)return o.map((function(t){return u(e)(t)}));var h=null;if(!t.target.isOptional()||0!==n.length){var d=n[0],p=d.scope===i.BindingScopeEnum.Singleton,b=d.scope===i.BindingScopeEnum.Request;if(p&&d.activated)return d.cache;if(b&&null!==e&&e.has(d.id))return e.get(d.id);if(d.type===i.BindingTypeEnum.ConstantValue)h=d.cache;else if(d.type===i.BindingTypeEnum.Function)h=d.cache;else if(d.type===i.BindingTypeEnum.Constructor)h=d.implementationType;else if(d.type===i.BindingTypeEnum.DynamicValue&&null!==d.dynamicValue)h=s("toDynamicValue",d.serviceIdentifier,(function(){return d.dynamicValue(t.parentContext)}));else if(d.type===i.BindingTypeEnum.Factory&&null!==d.factory)h=s("toFactory",d.serviceIdentifier,(function(){return d.factory(t.parentContext)}));else if(d.type===i.BindingTypeEnum.Provider&&null!==d.provider)h=s("toProvider",d.serviceIdentifier,(function(){return d.provider(t.parentContext)}));else{if(d.type!==i.BindingTypeEnum.Instance||null===d.implementationType){var _=a.getServiceIdentifierAsString(t.serviceIdentifier);throw new Error(r.INVALID_BINDING_TYPE+" "+_)}h=c.resolveInstance(d.implementationType,o,u(e))}return"function"==typeof d.onActivation&&(h=d.onActivation(t.parentContext,h)),p&&(d.cache=h,d.activated=!0),b&&null!==e&&!e.has(d.id)&&e.set(d.id,h),h}}};t.resolve=function(e){return u(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(18),o=n(7);t.resolveInstance=function(e,t,n){var a,c,s=null;if(t.length>0){var u=t.filter((function(e){return null!==e.target&&e.target.type===i.TargetTypeEnum.ConstructorArgument})).map(n);c=u,s=function(e,t,n){var r=t.filter((function(e){return null!==e.target&&e.target.type===i.TargetTypeEnum.ClassProperty})),o=r.map(n);return r.forEach((function(t,n){var r;r=t.target.name.value();var i=o[n];e[r]=i})),e}(s=new((a=e).bind.apply(a,[void 0].concat(c))),t,n)}else s=new e;return function(e,t){if(Reflect.hasMetadata(o.POST_CONSTRUCT,e)){var n=Reflect.getMetadata(o.POST_CONSTRUCT,e);try{t[n.value]()}catch(t){throw new Error(r.POST_CONSTRUCT_ERROR(e.name,t.message))}}}(e,s),s}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(18),o=n(134),a=n(67),c=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=i.BindingTypeEnum.Instance,this._binding.implementationType=e,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error(""+r.INVALID_TO_SELF_VALUE);var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=i.BindingTypeEnum.ConstantValue,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,new a.BindingWhenOnSyntax(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=i.BindingTypeEnum.DynamicValue,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=i.BindingTypeEnum.Constructor,this._binding.implementationType=e,new a.BindingWhenOnSyntax(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=e,new a.BindingWhenOnSyntax(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error(r.INVALID_FUNCTION_BINDING);var t=this.toConstantValue(e);return this._binding.type=i.BindingTypeEnum.Function,t},e.prototype.toAutoFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=function(t){return function(){return t.container.get(e)}},new a.BindingWhenOnSyntax(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=i.BindingTypeEnum.Provider,this._binding.provider=e,new a.BindingWhenOnSyntax(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}();t.BindingToSyntax=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(135),i=n(42),o=n(43),a=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new o.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new i.BindingOnSyntax(this._binding),this._bindingInSyntax=new r.BindingInSyntax(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingInWhenOnSyntax=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(18),i=n(67),o=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=r.BindingScopeEnum.Request,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=r.BindingScopeEnum.Singleton,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=r.BindingScopeEnum.Transient,new i.BindingWhenOnSyntax(this._binding)},e}();t.BindingInSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.of=function(t,n){var r=new e;return r.bindings=t,r.middleware=n,r},e}();t.ContainerSnapshot=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error(r.NULL_ARGUMENT);if(null==t)throw new Error(r.NULL_ARGUMENT);var n=this._map.get(e);void 0!==n?(n.push(t),this._map.set(e,n)):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);var t=this._map.get(e);if(void 0!==t)return t;throw new Error(r.KEY_NOT_FOUND)},e.prototype.remove=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);if(!this._map.delete(e))throw new Error(r.KEY_NOT_FOUND)},e.prototype.removeByCondition=function(e){var t=this;this._map.forEach((function(n,r){var i=n.filter((function(t){return!e(t)}));i.length>0?t._map.set(r,i):t._map.delete(r)}))},e.prototype.hasKey=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,n){e.forEach((function(e){return t.add(n,e.clone())}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,n){e(n,t)}))},e}();t.Lookup=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(22),i=function(e){this.id=r.id(),this.registry=e};t.ContainerModule=i;var o=function(e){this.id=r.id(),this.registry=e};t.AsyncContainerModule=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(7);t.injectable=function(){return function(e){if(Reflect.hasOwnMetadata(i.PARAM_TYPES,e))throw new Error(r.DUPLICATED_INJECTABLE_DECORATOR);var t=Reflect.getMetadata(i.DESIGN_PARAM_TYPES,e)||[];return Reflect.defineMetadata(i.PARAM_TYPES,t,e),e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(13),i=n(20);t.tagged=function(e,t){return function(n,o,a){var c=new r.Metadata(e,t);"number"==typeof a?i.tagParameter(n,o,a,c):i.tagProperty(n,o,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(13),o=n(20);t.named=function(e){return function(t,n,a){var c=new i.Metadata(r.NAMED_TAG,e);"number"==typeof a?o.tagParameter(t,n,a,c):o.tagProperty(t,n,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(13),o=n(20);t.optional=function(){return function(e,t,n){var a=new i.Metadata(r.OPTIONAL_TAG,!0);"number"==typeof n?o.tagParameter(e,t,n,a):o.tagProperty(e,t,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(13),o=n(20);t.unmanaged=function(){return function(e,t,n){var a=new i.Metadata(r.UNMANAGED_TAG,!0);o.tagParameter(e,t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(13),o=n(20);t.multiInject=function(e){return function(t,n,a){var c=new i.Metadata(r.MULTI_INJECT_TAG,e);"number"==typeof a?o.tagParameter(t,n,a,c):o.tagProperty(t,n,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),i=n(13),o=n(20);t.targetName=function(e){return function(t,n,a){var c=new i.Metadata(r.NAME_TAG,e);o.tagParameter(t,n,a,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=n(7),o=n(13);t.postConstruct=function(){return function(e,t,n){var a=new o.Metadata(i.POST_CONSTRUCT,t);if(Reflect.hasOwnMetadata(i.POST_CONSTRUCT,e.constructor))throw new Error(r.MULTIPLE_POST_CONSTRUCT_METHODS);Reflect.defineMetadata(i.POST_CONSTRUCT,a,e.constructor)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=function(e){return function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.forEach((function(n){return e.bind(n).toService(t)}))}}}},function(e,t,n){var r=n(3).Buffer,i=n(71),o=n(76),a=n(24),c=n(109),s=n(36);function u(e,t){return r.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(e){var t=e.header,n=e.payload,r=e.secret||e.privateKey,i=e.encoding,a=o(t.alg),f=function(e,t,n){n=n||"utf8";var r=u(c(e),"binary"),i=u(c(t),n);return s.format("%s.%s",r,i)}(t,n,i),l=a.sign(f,r);return s.format("%s.%s",f,l)}function l(e){var t=e.secret||e.privateKey||e.key,n=new i(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new i(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}s.inherits(l,a),l.prototype.sign=function(){try{var e=f({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},l.sign=f,e.exports=l},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),a=r[0],c=r[1],s=new o(function(e,t,n){return 3*(t+n)/4-n}(0,a,c)),f=0,l=c>0?a-4:a;for(n=0;n<l;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],s[f++]=t>>16&255,s[f++]=t>>8&255,s[f++]=255&t;2===c&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,s[f++]=255&t);1===c&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,s[f++]=t>>8&255,s[f++]=255&t);return s},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],a=0,c=n-i;a<c;a+=16383)o.push(f(e,a,a+16383>c?c:a+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,s=a.length;c<s;++c)r[c]=a[c],i[a.charCodeAt(c)]=c;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function f(e,t,n){for(var i,o,a=[],c=t;c<n;c+=3)i=(e[c]<<16&16711680)+(e[c+1]<<8&65280)+(255&e[c+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,a,c=8*i-r-1,s=(1<<c)-1,u=s>>1,f=-7,l=n?i-1:0,h=n?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=c;f>0;o=256*o+e[t+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+e[t+l],l+=h,f-=8);if(0===o)o=1-u;else{if(o===s)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),o-=u}return(d?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,c,s,u=8*o-i-1,f=(1<<u)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),(t+=a+l>=1?h/s:h*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(c=0,a=f):a+l>=1?(c=(t*s-1)*Math.pow(2,i),a+=l):(c=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;e[n+d]=255&c,d+=p,c/=256,i-=8);for(a=a<<i|c,u+=i;u>0;e[n+d]=255&a,d+=p,a/=256,u-=8);e[n+d-p]|=128*b}},function(e,t){},function(e,t,n){"use strict";var r=n(3).Buffer,i=n(153);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,c=0;a;)t=a.data,n=o,i=c,t.copy(n,i),c+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(155),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(19))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,a,c,s=1,u={},f=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},r=function(e){o.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,r=function(e){var t=l.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(p,0,e)}:(a="setImmediate$"+Math.random()+"$",c=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&p(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",c,!1):e.attachEvent("onmessage",c),r=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return u[s]=i,r(s),s++},h.clearImmediate=d}function d(e){delete u[e]}function p(e){if(f)setTimeout(p,0,e);else{var t=u[e];if(t){f=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(void 0,n)}}(t)}finally{d(e),f=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(19),n(10))},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(19))},function(e,t,n){"use strict";e.exports=o;var r=n(75),i=Object.create(n(29));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(4),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){e.exports=n(47)},function(e,t,n){e.exports=n(23)},function(e,t,n){e.exports=n(46).Transform},function(e,t,n){e.exports=n(46).PassThrough},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,n){"use strict";var r=n(5).Buffer,i=n(5).SlowBuffer;function o(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,i=0;i<e.length;i++)n|=e[i]^t[i];return 0===n}e.exports=o,o.install=function(){r.prototype.equal=i.prototype.equal=function(e){return o(this,e)}};var a=r.prototype.equal,c=i.prototype.equal;o.restore=function(){r.prototype.equal=a,i.prototype.equal=c}},function(e,t,n){"use strict";t.randomBytes=t.rng=t.pseudoRandomBytes=t.prng=n(25),t.createHash=t.Hash=n(30),t.createHmac=t.Hmac=n(80);var r=n(170),i=Object.keys(r),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(i);t.getHashes=function(){return o};var a=n(83);t.pbkdf2=a.pbkdf2,t.pbkdf2Sync=a.pbkdf2Sync;var c=n(172);t.Cipher=c.Cipher,t.createCipher=c.createCipher,t.Cipheriv=c.Cipheriv,t.createCipheriv=c.createCipheriv,t.Decipher=c.Decipher,t.createDecipher=c.createDecipher,t.Decipheriv=c.Decipheriv,t.createDecipheriv=c.createDecipheriv,t.getCiphers=c.getCiphers,t.listCiphers=c.listCiphers;var s=n(187);t.DiffieHellmanGroup=s.DiffieHellmanGroup,t.createDiffieHellmanGroup=s.createDiffieHellmanGroup,t.getDiffieHellman=s.getDiffieHellman,t.createDiffieHellman=s.createDiffieHellman,t.DiffieHellman=s.DiffieHellman;var u=n(193);t.createSign=u.createSign,t.Sign=u.Sign,t.createVerify=u.createVerify,t.Verify=u.Verify,t.createECDH=n(227);var f=n(228);t.publicEncrypt=f.publicEncrypt,t.privateEncrypt=f.privateEncrypt,t.publicDecrypt=f.publicDecrypt,t.privateDecrypt=f.privateDecrypt;var l=n(231);t.randomFill=l.randomFill,t.randomFillSync=l.randomFillSync,t.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join("\n"))},t.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},function(e,t,n){var r=n(4),i=n(26),o=n(3).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],c=new Array(80);function s(){this.init(),this._w=c,i.call(this,64,56)}function u(e){return e<<30|e>>>2}function f(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}r(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,c=0|this._d,s=0|this._e,l=0;l<16;++l)n[l]=e.readInt32BE(4*l);for(;l<80;++l)n[l]=n[l-3]^n[l-8]^n[l-14]^n[l-16];for(var h=0;h<80;++h){var d=~~(h/20),p=0|((t=r)<<5|t>>>27)+f(d,i,o,c)+s+n[h]+a[d];s=c,c=o,o=u(i),i=r,r=p}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=c+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=s},function(e,t,n){var r=n(4),i=n(26),o=n(3).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],c=new Array(80);function s(){this.init(),this._w=c,i.call(this,64,56)}function u(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function l(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}r(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,c=0|this._d,s=0|this._e,h=0;h<16;++h)n[h]=e.readInt32BE(4*h);for(;h<80;++h)n[h]=(t=n[h-3]^n[h-8]^n[h-14]^n[h-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(r)+l(p,i,o,c)+s+n[d]+a[p]|0;s=c,c=o,o=f(i),i=r,r=b}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=c+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=s},function(e,t,n){var r=n(4),i=n(78),o=n(26),a=n(3).Buffer,c=new Array(64);function s(){this.init(),this._w=c,o.call(this,64,56)}r(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=s},function(e,t,n){var r=n(4),i=n(79),o=n(26),a=n(3).Buffer,c=new Array(160);function s(){this.init(),this._w=c,o.call(this,128,112)}r(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=s},function(e,t,n){"use strict";var r=n(4),i=n(3).Buffer,o=n(21),a=i.alloc(128);function c(e,t){o.call(this,"digest"),"string"==typeof t&&(t=i.from(t)),this._alg=e,this._key=t,t.length>64?t=e(t):t.length<64&&(t=i.concat([t,a],64));for(var n=this._ipad=i.allocUnsafe(64),r=this._opad=i.allocUnsafe(64),c=0;c<64;c++)n[c]=54^t[c],r[c]=92^t[c];this._hash=[n]}r(c,o),c.prototype._update=function(e){this._hash.push(e)},c.prototype._final=function(){var e=this._alg(i.concat(this._hash));return this._alg(i.concat([this._opad,e]))},e.exports=c},function(e,t,n){e.exports=n(82)},function(e,t,n){(function(t,r){var i,o=n(84),a=n(85),c=n(86),s=n(3).Buffer,u=t.crypto&&t.crypto.subtle,f={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},l=[];function h(e,t,n,r,i){return u.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return u.deriveBits({name:"PBKDF2",salt:t,iterations:n,hash:{name:i}},e,r<<3)})).then((function(e){return s.from(e)}))}e.exports=function(e,n,d,p,b,_){"function"==typeof b&&(_=b,b=void 0);var E=f[(b=b||"sha1").toLowerCase()];if(!E||"function"!=typeof t.Promise)return r.nextTick((function(){var t;try{t=c(e,n,d,p,b)}catch(e){return _(e)}_(null,t)}));if(o(e,n,d,p),"function"!=typeof _)throw new Error("No callback provided to pbkdf2");s.isBuffer(e)||(e=s.from(e,a)),s.isBuffer(n)||(n=s.from(n,a)),function(e,t){e.then((function(e){r.nextTick((function(){t(null,e)}))}),(function(e){r.nextTick((function(){t(e)}))}))}(function(e){if(t.process&&!t.process.browser)return Promise.resolve(!1);if(!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(void 0!==l[e])return l[e];var n=h(i=i||s.alloc(8),i,10,128,e).then((function(){return!0})).catch((function(){return!1}));return l[e]=n,n}(E).then((function(t){return t?h(e,n,d,p,E):c(e,n,d,p,b)})),_)}}).call(this,n(19),n(10))},function(e,t,n){var r=n(173),i=n(53),o=n(54),a=n(186),c=n(38);function s(e,t,n){if(e=e.toLowerCase(),o[e])return i.createCipheriv(e,t,n);if(a[e])return new r({key:t,iv:n,mode:e});throw new TypeError("invalid suite type")}function u(e,t,n){if(e=e.toLowerCase(),o[e])return i.createDecipheriv(e,t,n);if(a[e])return new r({key:t,iv:n,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}t.createCipher=t.Cipher=function(e,t){var n,r;if(e=e.toLowerCase(),o[e])n=o[e].key,r=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");n=8*a[e].key,r=a[e].iv}var i=c(t,!1,n,r);return s(e,i.key,i.iv)},t.createCipheriv=t.Cipheriv=s,t.createDecipher=t.Decipher=function(e,t){var n,r;if(e=e.toLowerCase(),o[e])n=o[e].key,r=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");n=8*a[e].key,r=a[e].iv}var i=c(t,!1,n,r);return u(e,i.key,i.iv)},t.createDecipheriv=t.Decipheriv=u,t.listCiphers=t.getCiphers=function(){return Object.keys(a).concat(i.getCiphers())}},function(e,t,n){var r=n(21),i=n(174),o=n(4),a=n(3).Buffer,c={"des-ede3-cbc":i.CBC.instantiate(i.EDE),"des-ede3":i.EDE,"des-ede-cbc":i.CBC.instantiate(i.EDE),"des-ede":i.EDE,"des-cbc":i.CBC.instantiate(i.DES),"des-ecb":i.DES};function s(e){r.call(this);var t,n=e.mode.toLowerCase(),i=c[n];t=e.decrypt?"decrypt":"encrypt";var o=e.key;a.isBuffer(o)||(o=a.from(o)),"des-ede"!==n&&"des-ede-cbc"!==n||(o=a.concat([o,o.slice(0,8)]));var s=e.iv;a.isBuffer(s)||(s=a.from(s)),this._des=i.create({key:o,iv:s,type:t})}c.des=c["des-cbc"],c.des3=c["des-ede3-cbc"],e.exports=s,o(s,r),s.prototype._update=function(e){return a.from(this._des.update(e))},s.prototype._final=function(){return a.from(this._des.final())}},function(e,t,n){"use strict";t.utils=n(87),t.Cipher=n(52),t.DES=n(88),t.CBC=n(175),t.EDE=n(176)},function(e,t,n){"use strict";var r=n(11),i=n(4),o={};function a(e){r.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t<this.iv.length;t++)this.iv[t]=e[t]}t.instantiate=function(e){function t(t){e.call(this,t),this._cbcInit()}i(t,e);for(var n=Object.keys(o),r=0;r<n.length;r++){var a=n[r];t.prototype[a]=o[a]}return t.create=function(e){return new t(e)},t},o._cbcInit=function(){var e=new a(this.options.iv);this._cbcState=e},o._update=function(e,t,n,r){var i=this._cbcState,o=this.constructor.super_.prototype,a=i.iv;if("encrypt"===this.type){for(var c=0;c<this.blockSize;c++)a[c]^=e[t+c];o._update.call(this,a,0,n,r);for(c=0;c<this.blockSize;c++)a[c]=n[r+c]}else{o._update.call(this,e,t,n,r);for(c=0;c<this.blockSize;c++)n[r+c]^=a[c];for(c=0;c<this.blockSize;c++)a[c]=e[t+c]}}},function(e,t,n){"use strict";var r=n(11),i=n(4),o=n(52),a=n(88);function c(e,t){r.equal(t.length,24,"Invalid key length");var n=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[a.create({type:"encrypt",key:n}),a.create({type:"decrypt",key:i}),a.create({type:"encrypt",key:o})]:[a.create({type:"decrypt",key:o}),a.create({type:"encrypt",key:i}),a.create({type:"decrypt",key:n})]}function s(e){o.call(this,e);var t=new c(this.type,this.options.key);this._edeState=t}i(s,o),e.exports=s,s.create=function(e){return new s(e)},s.prototype._update=function(e,t,n,r){var i=this._edeState;i.ciphers[0]._update(e,t,n,r),i.ciphers[1]._update(n,r,n,r),i.ciphers[2]._update(n,r,n,r)},s.prototype._pad=a.prototype._pad,s.prototype._unpad=a.prototype._unpad},function(e,t,n){var r=n(54),i=n(92),o=n(3).Buffer,a=n(93),c=n(21),s=n(37),u=n(38);function f(e,t,n){c.call(this),this._cache=new h,this._cipher=new s.AES(t),this._prev=o.from(n),this._mode=e,this._autopadding=!0}n(4)(f,c),f.prototype._update=function(e){var t,n;this._cache.add(e);for(var r=[];t=this._cache.get();)n=this._mode.encrypt(this,t),r.push(n);return o.concat(r)};var l=o.alloc(16,16);function h(){this.cache=o.allocUnsafe(0)}function d(e,t,n){var c=r[e.toLowerCase()];if(!c)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==c.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof n&&(n=o.from(n)),"GCM"!==c.mode&&n.length!==c.iv)throw new TypeError("invalid iv length "+n.length);return"stream"===c.type?new a(c.module,t,n):"auth"===c.type?new i(c.module,t,n):new f(c.module,t,n)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(l))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=o.concat([this.cache,e])},h.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},h.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),n=-1;++n<e;)t.writeUInt8(e,n);return o.concat([this.cache,t])},t.createCipheriv=d,t.createCipher=function(e,t){var n=r[e.toLowerCase()];if(!n)throw new TypeError("invalid suite type");var i=u(t,!1,n.key,n.iv);return d(e,i.key,i.iv)}},function(e,t){t.encrypt=function(e,t){return e._cipher.encryptBlock(t)},t.decrypt=function(e,t){return e._cipher.decryptBlock(t)}},function(e,t,n){var r=n(31);t.encrypt=function(e,t){var n=r(t,e._prev);return e._prev=e._cipher.encryptBlock(n),e._prev},t.decrypt=function(e,t){var n=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return r(i,n)}},function(e,t,n){var r=n(3).Buffer,i=n(31);function o(e,t,n){var o=t.length,a=i(t,e._cache);return e._cache=e._cache.slice(o),e._prev=r.concat([e._prev,n?t:a]),a}t.encrypt=function(e,t,n){for(var i,a=r.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=r.allocUnsafe(0)),!(e._cache.length<=t.length)){a=r.concat([a,o(e,t,n)]);break}i=e._cache.length,a=r.concat([a,o(e,t.slice(0,i),n)]),t=t.slice(i)}return a}},function(e,t,n){var r=n(3).Buffer;function i(e,t,n){var i=e._cipher.encryptBlock(e._prev)[0]^t;return e._prev=r.concat([e._prev.slice(1),r.from([n?t:i])]),i}t.encrypt=function(e,t,n){for(var o=t.length,a=r.allocUnsafe(o),c=-1;++c<o;)a[c]=i(e,t[c],n);return a}},function(e,t,n){var r=n(3).Buffer;function i(e,t,n){for(var r,i,a=-1,c=0;++a<8;)r=t&1<<7-a?128:0,c+=(128&(i=e._cipher.encryptBlock(e._prev)[0]^r))>>a%8,e._prev=o(e._prev,n?r:i);return c}function o(e,t){var n=e.length,i=-1,o=r.allocUnsafe(e.length);for(e=r.concat([e,r.from([t])]);++i<n;)o[i]=e[i]<<1|e[i+1]>>7;return o}t.encrypt=function(e,t,n){for(var o=t.length,a=r.allocUnsafe(o),c=-1;++c<o;)a[c]=i(e,t[c],n);return a}},function(e,t,n){(function(e){var r=n(31);function i(e){return e._prev=e._cipher.encryptBlock(e._prev),e._prev}t.encrypt=function(t,n){for(;t._cache.length<n.length;)t._cache=e.concat([t._cache,i(t)]);var o=t._cache.slice(0,n.length);return t._cache=t._cache.slice(n.length),r(n,o)}}).call(this,n(5).Buffer)},function(e,t,n){var r=n(3).Buffer,i=r.alloc(16,0);function o(e){var t=r.allocUnsafe(16);return t.writeUInt32BE(e[0]>>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=r.alloc(16,0),this.cache=r.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t<e.length;)this.state[t]^=e[t];this._multiply()},a.prototype._multiply=function(){for(var e,t,n,r=[(e=this.h).readUInt32BE(0),e.readUInt32BE(4),e.readUInt32BE(8),e.readUInt32BE(12)],i=[0,0,0,0],a=-1;++a<128;){for(0!=(this.state[~~(a/8)]&1<<7-a%8)&&(i[0]^=r[0],i[1]^=r[1],i[2]^=r[2],i[3]^=r[3]),n=0!=(1&r[3]),t=3;t>0;t--)r[t]=r[t]>>>1|(1&r[t-1])<<31;r[0]=r[0]>>>1,n&&(r[0]=r[0]^225<<24)}this.state=o(i)},a.prototype.update=function(e){var t;for(this.cache=r.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(r.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},e.exports=a},function(e,t,n){var r=n(92),i=n(3).Buffer,o=n(54),a=n(93),c=n(21),s=n(37),u=n(38);function f(e,t,n){c.call(this),this._cache=new l,this._last=void 0,this._cipher=new s.AES(t),this._prev=i.from(n),this._mode=e,this._autopadding=!0}function l(){this.cache=i.allocUnsafe(0)}function h(e,t,n){var c=o[e.toLowerCase()];if(!c)throw new TypeError("invalid suite type");if("string"==typeof n&&(n=i.from(n)),"GCM"!==c.mode&&n.length!==c.iv)throw new TypeError("invalid iv length "+n.length);if("string"==typeof t&&(t=i.from(t)),t.length!==c.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===c.type?new a(c.module,t,n,!0):"auth"===c.type?new r(c.module,t,n,!0):new f(c.module,t,n)}n(4)(f,c),f.prototype._update=function(e){var t,n;this._cache.add(e);for(var r=[];t=this._cache.get(this._autopadding);)n=this._mode.decrypt(this,t),r.push(n);return i.concat(r)},f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");var n=-1;for(;++n<t;)if(e[n+(16-t)]!==t)throw new Error("unable to decrypt data");if(16===t)return;return e.slice(0,16-t)}(this._mode.decrypt(this,e));if(e)throw new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=i.concat([this.cache,e])},l.prototype.get=function(e){var t;if(e){if(this.cache.length>16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},l.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(e,t){var n=o[e.toLowerCase()];if(!n)throw new TypeError("invalid suite type");var r=u(t,!1,n.key,n.iv);return h(e,r.key,r.iv)},t.createDecipheriv=h},function(e,t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}},function(e,t,n){(function(e){var r=n(94),i=n(191),o=n(192);var a={binary:!0,hex:!0,base64:!0};t.DiffieHellmanGroup=t.createDiffieHellmanGroup=t.getDiffieHellman=function(t){var n=new e(i[t].prime,"hex"),r=new e(i[t].gen,"hex");return new o(n,r)},t.createDiffieHellman=t.DiffieHellman=function t(n,i,c,s){return e.isBuffer(i)||void 0===a[i]?t(n,"binary",i,c):(i=i||"binary",s=s||"binary",c=c||new e([2]),e.isBuffer(c)||(c=new e(c,s)),"number"==typeof n?new o(r(n,c),c,!0):(e.isBuffer(n)||(n=new e(n,i)),new o(n,c,!0)))}}).call(this,n(5).Buffer)},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){},function(e,t){},function(e){e.exports=JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}')},function(e,t,n){(function(t){var r=n(6),i=new(n(95)),o=new r(24),a=new r(11),c=new r(10),s=new r(3),u=new r(7),f=n(94),l=n(25);function h(e,n){return n=n||"utf8",t.isBuffer(e)||(e=new t(e,n)),this._pub=new r(e),this}function d(e,n){return n=n||"utf8",t.isBuffer(e)||(e=new t(e,n)),this._priv=new r(e),this}e.exports=b;var p={};function b(e,t,n){this.setGenerator(t),this.__prime=new r(e),this._prime=r.mont(this.__prime),this._primeLen=e.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,n?(this.setPublicKey=h,this.setPrivateKey=d):this._primeCode=8}function _(e,n){var r=new t(e.toArray());return n?r.toString(n):r}Object.defineProperty(b.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(e,t){var n=t.toString("hex"),r=[n,e.toString(16)].join("_");if(r in p)return p[r];var l,h=0;if(e.isEven()||!f.simpleSieve||!f.fermatTest(e)||!i.test(e))return h+=1,h+="02"===n||"05"===n?8:4,p[r]=h,h;switch(i.test(e.shrn(1))||(h+=2),n){case"02":e.mod(o).cmp(a)&&(h+=8);break;case"05":(l=e.mod(c)).cmp(s)&&l.cmp(u)&&(h+=8);break;default:h+=4}return p[r]=h,h}(this.__prime,this.__gen)),this._primeCode}}),b.prototype.generateKeys=function(){return this._priv||(this._priv=new r(l(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},b.prototype.computeSecret=function(e){var n=(e=(e=new r(e)).toRed(this._prime)).redPow(this._priv).fromRed(),i=new t(n.toArray()),o=this.getPrime();if(i.length<o.length){var a=new t(o.length-i.length);a.fill(0),i=t.concat([a,i])}return i},b.prototype.getPublicKey=function(e){return _(this._pub,e)},b.prototype.getPrivateKey=function(e){return _(this._priv,e)},b.prototype.getPrime=function(e){return _(this.__prime,e)},b.prototype.getGenerator=function(e){return _(this._gen,e)},b.prototype.setGenerator=function(e,n){return n=n||"utf8",t.isBuffer(e)||(e=new t(e,n)),this.__gen=e,this._gen=new r(e),this}}).call(this,n(5).Buffer)},function(e,t,n){(function(t){var r=n(30),i=n(24),o=n(4),a=n(194),c=n(226),s=n(82);function u(e){i.Writable.call(this);var t=s[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){i.Writable.call(this);var t=s[e];if(!t)throw new Error("Unknown message digest");this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function l(e){return new u(e)}function h(e){return new f(e)}Object.keys(s).forEach((function(e){s[e].id=new t(s[e].id,"hex"),s[e.toLowerCase()]=s[e]})),o(u,i.Writable),u.prototype._write=function(e,t,n){this._hash.update(e),n()},u.prototype.update=function(e,n){return"string"==typeof e&&(e=new t(e,n)),this._hash.update(e),this},u.prototype.sign=function(e,t){this.end();var n=this._hash.digest(),r=a(n,e,this._hashType,this._signType,this._tag);return t?r.toString(t):r},o(f,i.Writable),f.prototype._write=function(e,t,n){this._hash.update(e),n()},f.prototype.update=function(e,n){return"string"==typeof e&&(e=new t(e,n)),this._hash.update(e),this},f.prototype.verify=function(e,n,r){"string"==typeof n&&(n=new t(n,r)),this.end();var i=this._hash.digest();return c(n,i,e,this._signType,this._tag)},e.exports={Sign:l,Verify:h,createSign:l,createVerify:h}}).call(this,n(5).Buffer)},function(e,t,n){(function(t){var r=n(80),i=n(56),o=n(57).ec,a=n(6),c=n(40),s=n(105);function u(e,n,i,o){if((e=new t(e.toArray())).length<n.byteLength()){var a=new t(n.byteLength()-e.length);a.fill(0),e=t.concat([a,e])}var c=i.length,s=function(e,n){e=(e=f(e,n)).mod(n);var r=new t(e.toArray());if(r.length<n.byteLength()){var i=new t(n.byteLength()-r.length);i.fill(0),r=t.concat([i,r])}return r}(i,n),u=new t(c);u.fill(1);var l=new t(c);return l.fill(0),l=r(o,l).update(u).update(new t([0])).update(e).update(s).digest(),u=r(o,l).update(u).digest(),{k:l=r(o,l).update(u).update(new t([1])).update(e).update(s).digest(),v:u=r(o,l).update(u).digest()}}function f(e,t){var n=new a(e),r=(e.length<<3)-t.bitLength();return r>0&&n.ishrn(r),n}function l(e,n,i){var o,a;do{for(o=new t(0);8*o.length<e.bitLength();)n.v=r(i,n.k).update(n.v).digest(),o=t.concat([o,n.v]);a=f(o,e),n.k=r(i,n.k).update(n.v).update(new t([0])).digest(),n.v=r(i,n.k).update(n.v).digest()}while(-1!==a.cmp(e));return a}function h(e,t,n,r){return e.toRed(a.mont(n)).redPow(t).fromRed().mod(r)}e.exports=function(e,n,r,d,p){var b=c(n);if(b.curve){if("ecdsa"!==d&&"ecdsa/rsa"!==d)throw new Error("wrong private key type");return function(e,n){var r=s[n.curve.join(".")];if(!r)throw new Error("unknown curve "+n.curve.join("."));var i=new o(r).keyFromPrivate(n.privateKey).sign(e);return new t(i.toDER())}(e,b)}if("dsa"===b.type){if("dsa"!==d)throw new Error("wrong private key type");return function(e,n,r){var i,o=n.params.priv_key,c=n.params.p,s=n.params.q,d=n.params.g,p=new a(0),b=f(e,s).mod(s),_=!1,E=u(o,s,e,r);for(;!1===_;)i=l(s,E,r),p=h(d,i,c,s),0===(_=i.invm(s).imul(b.add(o.mul(p))).mod(s)).cmpn(0)&&(_=!1,p=new a(0));return function(e,n){e=e.toArray(),n=n.toArray(),128&e[0]&&(e=[0].concat(e));128&n[0]&&(n=[0].concat(n));var r=[48,e.length+n.length+4,2,e.length];return r=r.concat(e,[2,n.length],n),new t(r)}(p,_)}(e,b,r)}if("rsa"!==d&&"ecdsa/rsa"!==d)throw new Error("wrong private key type");e=t.concat([p,e]);for(var _=b.modulus.byteLength(),E=[0,1];e.length+E.length+1<_;)E.push(255);E.push(0);for(var y=-1;++y<e.length;)E.push(e[y]);return i(E,b)},e.exports.getKey=u,e.exports.makeKey=l}).call(this,n(5).Buffer)},function(e){e.exports=JSON.parse('{"_args":[["elliptic@6.5.2","/Users/devarfath/Desktop/sunbird-mobile-sdk"]],"_development":true,"_from":"elliptic@6.5.2","_id":"elliptic@6.5.2","_inBundle":false,"_integrity":"sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==","_location":"/elliptic","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"elliptic@6.5.2","name":"elliptic","escapedName":"elliptic","rawSpec":"6.5.2","saveSpec":null,"fetchSpec":"6.5.2"},"_requiredBy":["/browserify-sign","/create-ecdh"],"_resolved":"https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz","_spec":"6.5.2","_where":"/Users/devarfath/Desktop/sunbird-mobile-sdk","author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"bugs":{"url":"https://github.com/indutny/elliptic/issues"},"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},"description":"EC cryptography","devDependencies":{"brfs":"^1.4.3","coveralls":"^3.0.8","grunt":"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.2","jscs":"^3.0.7","jshint":"^2.10.3","mocha":"^6.2.2"},"files":["lib"],"homepage":"https://github.com/indutny/elliptic","keywords":["EC","Elliptic","curve","Cryptography"],"license":"MIT","main":"lib/elliptic.js","name":"elliptic","repository":{"type":"git","url":"git+ssh://git@github.com/indutny/elliptic.git"},"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","test":"npm run lint && npm run unit","unit":"istanbul test _mocha --reporter=spec test/index.js","version":"grunt dist && git add dist/"},"version":"6.5.2"}')},function(e,t,n){"use strict";var r=n(12),i=n(6),o=n(4),a=n(39),c=r.assert;function s(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,n,r){a.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,n,r){a.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(n,16),this.z=new i(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(s,a),e.exports=s,s.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);t=(t=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(e.lambda)n=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?n=o[0]:(n=o[1],c(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:n,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(n)}}},s.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),n=new i(2).toRed(t).redInvm(),r=n.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(n);return[r.redAdd(o).fromRed(),r.redSub(o).fromRed()]},s.prototype._getEndoBasis=function(e){for(var t,n,r,o,a,c,s,u,f,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=e,d=this.n.clone(),p=new i(1),b=new i(0),_=new i(0),E=new i(1),y=0;0!==h.cmpn(0);){var v=d.div(h);u=d.sub(v.mul(h)),f=_.sub(v.mul(p));var g=E.sub(v.mul(b));if(!r&&u.cmp(l)<0)t=s.neg(),n=p,r=u.neg(),o=f;else if(r&&2==++y)break;s=u,d=h,h=u,_=p,p=f,E=b,b=g}a=u.neg(),c=f;var m=r.sqr().add(o.sqr());return a.sqr().add(c.sqr()).cmp(m)>=0&&(a=t,c=n),r.negative&&(r=r.neg(),o=o.neg()),a.negative&&(a=a.neg(),c=c.neg()),[{a:r,b:o},{a:a,b:c}]},s.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],i=r.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=i.mul(n.a),c=o.mul(r.a),s=i.mul(n.b),u=o.mul(r.b);return{k1:e.sub(a).sub(c),k2:s.add(u).neg()}},s.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var o=r.fromRed().isOdd();return(t&&!o||!t&&o)&&(r=r.redNeg()),this.point(e,r)},s.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(i).cmpn(0)},s.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,i=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(t[o]),c=e[o],s=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),s=s.neg(!0)),r[2*o]=c,r[2*o+1]=s,i[2*o]=a.k1,i[2*o+1]=a.k2}for(var u=this._wnafMulAdd(1,r,i,2*o,n),f=0;f<2*o;f++)r[f]=null,i[f]=null;return u},o(u,a.BasePoint),s.prototype.point=function(e,t,n){return new u(this,e,t,n)},s.prototype.pointFromJSON=function(e,t){return u.fromJSON(this,e,t)},u.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,r=function(e){return n.point(e.x.redMul(n.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(r)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(r)}}}return t}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(e,t,n){"string"==typeof t&&(t=JSON.parse(t));var r=e.point(t[0],t[1],n);if(!t[2])return r;function i(t){return e.point(t[0],t[1],n)}var o=t[2];return r.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[r].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[r].concat(o.naf.points.map(i))}},r},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),r=e.redInvm(),i=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){var r=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i):this.curve._wnafMulAdd(1,r,i,2)},u.prototype.jmulAdd=function(e,t,n){var r=[this,t],i=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,i,!0):this.curve._wnafMulAdd(1,r,i,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,a.BasePoint),s.prototype.jpoint=function(e,t,n){return new f(this,e,t,n)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),i=e.x.redMul(n),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),c=r.redSub(i),s=o.redSub(a);if(0===c.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),f=u.redMul(c),l=r.redMul(u),h=s.redSqr().redIAdd(f).redISub(l).redISub(l),d=s.redMul(l.redISub(h)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(h,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=n.redSub(r),c=i.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=a.redSqr(),u=s.redMul(a),f=n.redMul(s),l=c.redSqr().redIAdd(u).redISub(f).redISub(f),h=c.redMul(f.redISub(l)).redISub(i.redMul(u)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,n=0;n<e;n++)t=t.dbl();return t}var r=this.curve.a,i=this.curve.tinv,o=this.x,a=this.y,c=this.z,s=c.redSqr().redSqr(),u=a.redAdd(a);for(n=0;n<e;n++){var f=o.redSqr(),l=u.redSqr(),h=l.redSqr(),d=f.redAdd(f).redIAdd(f).redIAdd(r.redMul(s)),p=o.redMul(l),b=d.redSqr().redISub(p.redAdd(p)),_=p.redISub(b),E=d.redMul(_);E=E.redIAdd(E).redISub(h);var y=u.redMul(c);n+1<e&&(s=s.redMul(h)),o=b,c=y,u=E}return this.curve.jpoint(o,u.redMul(i),c)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),a=this.x.redAdd(i).redSqr().redISub(r).redISub(o);a=a.redIAdd(a);var c=r.redAdd(r).redIAdd(r),s=c.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=s,t=c.redMul(a.redISub(s)).redISub(u),n=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),l=this.y.redSqr(),h=l.redSqr(),d=this.x.redAdd(l).redSqr().redISub(f).redISub(h);d=d.redIAdd(d);var p=f.redAdd(f).redIAdd(f),b=p.redSqr(),_=h.redIAdd(h);_=(_=_.redIAdd(_)).redIAdd(_),e=b.redISub(d).redISub(d),t=p.redMul(d.redISub(e)).redISub(_),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(e,t,n)},f.prototype._threeDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),a=this.x.redAdd(i).redSqr().redISub(r).redISub(o);a=a.redIAdd(a);var c=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),s=c.redSqr().redISub(a).redISub(a);e=s;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=c.redMul(a.redISub(s)).redISub(u),n=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),l=this.y.redSqr(),h=this.x.redMul(l),d=this.x.redSub(f).redMul(this.x.redAdd(f));d=d.redAdd(d).redIAdd(d);var p=h.redIAdd(h),b=(p=p.redIAdd(p)).redAdd(p);e=d.redSqr().redISub(b),n=this.y.redAdd(this.z).redSqr().redISub(l).redISub(f);var _=l.redSqr();_=(_=(_=_.redIAdd(_)).redIAdd(_)).redIAdd(_),t=d.redMul(p.redISub(e)).redISub(_)}return this.curve.jpoint(e,t,n)},f.prototype._dbl=function(){var e=this.curve.a,t=this.x,n=this.y,r=this.z,i=r.redSqr().redSqr(),o=t.redSqr(),a=n.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(i)),s=t.redAdd(t),u=(s=s.redIAdd(s)).redMul(a),f=c.redSqr().redISub(u.redAdd(u)),l=u.redISub(f),h=a.redSqr();h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var d=c.redMul(l).redISub(h),p=n.redAdd(n).redMul(r);return this.curve.jpoint(f,d,p)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),r=t.redSqr(),i=e.redAdd(e).redIAdd(e),o=i.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(r),c=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(o)).redSqr(),s=r.redIAdd(r);s=(s=(s=s.redIAdd(s)).redIAdd(s)).redIAdd(s);var u=i.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(s),f=t.redMul(u);f=(f=f.redIAdd(f)).redIAdd(f);var l=this.x.redMul(c).redISub(f);l=(l=l.redIAdd(l)).redIAdd(l);var h=this.y.redMul(u.redMul(s.redISub(u)).redISub(a.redMul(c)));h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var d=this.z.redAdd(a).redSqr().redISub(n).redISub(c);return this.curve.jpoint(l,h,d)},f.prototype.mul=function(e,t){return e=new i(e,t),this.curve._wnafMul(this,e)},f.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(0!==this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0))return!1;var r=t.redMul(this.z),i=n.redMul(e.z);return 0===this.y.redMul(i).redISub(e.y.redMul(r)).cmpn(0)},f.prototype.eqXToP=function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(n))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(t);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(i),0===this.x.cmp(n))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,n){"use strict";var r=n(6),i=n(4),o=n(39),a=n(12);function c(e){o.call(this,"mont",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function s(e,t,n){o.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(t,16),this.z=new r(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(c,o),e.exports=c,c.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},i(s,o.BasePoint),c.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},c.prototype.point=function(e,t){return new s(this,e,t)},c.prototype.pointFromJSON=function(e){return s.fromJSON(this,e)},s.prototype.precompute=function(){},s.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},s.fromJSON=function(e,t){return new s(e,t[0],t[1]||e.one)},s.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},s.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),i=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,i)},s.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(n),a=i.redMul(r),c=t.z.redMul(o.redAdd(a).redSqr()),s=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(c,s)},s.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},s.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},s.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},s.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,n){"use strict";var r=n(12),i=n(6),o=n(4),a=n(39),c=r.assert;function s(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,n,r,o){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(n,16),this.z=r?new i(r,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(s,a),e.exports=s,s.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},s.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},s.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},s.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),o=this.one.redSub(this.c2.redMul(this.d).redMul(n)),a=r.redMul(o.redInvm()),c=a.redSqrt();if(0!==c.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var s=c.fromRed().isOdd();return(t&&!s||!t&&s)&&(c=c.redNeg()),this.point(e,c)},s.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),o=n.redMul(this.d).redMul(this.c2).redSub(this.a),a=r.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var c=a.redSqrt();if(0!==c.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return c.fromRed().isOdd()!==t&&(c=c.redNeg()),this.point(c,e)},s.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(i)},o(u,a.BasePoint),s.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},s.prototype.point=function(e,t,n,r){return new u(this,e,t,n,r)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=r.redAdd(t),a=o.redSub(n),c=r.redSub(t),s=i.redMul(a),u=o.redMul(c),f=i.redMul(c),l=a.redMul(o);return this.curve.point(s,u,l,f)},u.prototype._projDbl=function(){var e,t,n,r=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(u=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=r.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(u.redSub(o)),n=a.redSqr().redSub(a).redSub(a);else{var c=this.z.redSqr(),s=a.redSub(c).redISub(c);e=r.redSub(i).redISub(o).redMul(s),t=a.redMul(u.redSub(o)),n=a.redMul(s)}}else{var u=i.redAdd(o);c=this.curve._mulC(this.z).redSqr(),s=u.redSub(c).redSub(c);e=this.curve._mulC(r.redISub(u)).redMul(s),t=this.curve._mulC(u).redMul(i.redISub(o)),n=u.redMul(s)}return this.curve.point(e,t,n)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=n.redSub(t),a=i.redSub(r),c=i.redAdd(r),s=n.redAdd(t),u=o.redMul(a),f=c.redMul(s),l=o.redMul(s),h=a.redMul(c);return this.curve.point(u,f,h,l)},u.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),i=r.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),c=this.curve.d.redMul(o).redMul(a),s=i.redSub(c),u=i.redAdd(c),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),l=r.redMul(s).redMul(f);return this.curve.twisted?(t=r.redMul(u).redMul(a.redSub(this.curve._mulA(o))),n=s.redMul(u)):(t=r.redMul(u).redMul(a.redSub(o)),n=this.curve._mulC(s).redMul(u)),this.curve.point(l,t,n)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},u.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(e,t,n){"use strict";t.sha1=n(200),t.sha224=n(201),t.sha256=n(99),t.sha384=n(202),t.sha512=n(100)},function(e,t,n){"use strict";var r=n(16),i=n(32),o=n(98),a=r.rotl32,c=r.sum32,s=r.sum32_5,u=o.ft_1,f=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(h,f),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=a(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var i=this.h[0],o=this.h[1],f=this.h[2],h=this.h[3],d=this.h[4];for(r=0;r<n.length;r++){var p=~~(r/20),b=s(a(i,5),u(p,o,f,h),d,n[r],l[p]);d=h,h=f,f=a(o,30),o=i,i=b}this.h[0]=c(this.h[0],i),this.h[1]=c(this.h[1],o),this.h[2]=c(this.h[2],f),this.h[3]=c(this.h[3],h),this.h[4]=c(this.h[4],d)},h.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},function(e,t,n){"use strict";var r=n(16),i=n(99);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(o,i),e.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},function(e,t,n){"use strict";var r=n(16),i=n(100);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(o,i),e.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},function(e,t,n){"use strict";var r=n(16),i=n(32),o=r.rotl32,a=r.sum32,c=r.sum32_3,s=r.sum32_4,u=i.BlockHash;function f(){if(!(this instanceof f))return new f;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(e,t,n,r){return e<=15?t^n^r:e<=31?t&n|~t&r:e<=47?(t|~n)^r:e<=63?t&r|n&~r:t^(n|~r)}function h(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function d(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}r.inherits(f,u),t.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(e,t){for(var n=this.h[0],r=this.h[1],i=this.h[2],u=this.h[3],f=this.h[4],y=n,v=r,g=i,m=u,S=f,O=0;O<80;O++){var A=a(o(s(n,l(O,r,i,u),e[p[O]+t],h(O)),_[O]),f);n=f,f=u,u=o(i,10),i=r,r=A,A=a(o(s(y,l(79-O,v,g,m),e[b[O]+t],d(O)),E[O]),S),y=S,S=m,m=o(g,10),g=v,v=A}A=c(this.h[1],i,m),this.h[1]=c(this.h[2],u,S),this.h[2]=c(this.h[3],f,y),this.h[3]=c(this.h[4],n,v),this.h[4]=c(this.h[0],r,g),this.h[0]=A},f.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],_=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],E=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},function(e,t,n){"use strict";var r=n(16),i=n(11);function o(e,t,n){if(!(this instanceof o))return new o(e,t,n);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(t,n))}e.exports=o,o.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},o.prototype.update=function(e,t){return this.inner.update(e,t),this},o.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},function(e,t){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,n){"use strict";var r=n(6),i=n(207),o=n(12),a=n(58),c=n(55),s=o.assert,u=n(208),f=n(209);function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(s(a.hasOwnProperty(e),"Unknown curve "+e),e=a[e]),e instanceof a.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=l,l.prototype.keyPair=function(e){return new u(this,e)},l.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},l.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},l.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||c(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),o=this.n.sub(new r(2));;){var a=new r(t.generate(n));if(!(a.cmp(o)>0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,n,o){"object"==typeof n&&(o=n,n=null),o||(o={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new r(e,16));for(var a=this.n.byteLength(),c=t.getPrivate().toArray("be",a),s=e.toArray("be",a),u=new i({hash:this.hash,entropy:c,nonce:s,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new r(1)),h=0;;h++){var d=o.k?o.k(h):new r(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(l)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),_=b.umod(this.n);if(0!==_.cmpn(0)){var E=d.invm(this.n).mul(_.mul(t.getPrivate()).iadd(e));if(0!==(E=E.umod(this.n)).cmpn(0)){var y=(p.getY().isOdd()?1:0)|(0!==b.cmp(_)?2:0);return o.canonical&&E.cmp(this.nh)>0&&(E=this.n.sub(E),y^=1),new f({r:_,s:E,recoveryParam:y})}}}}}},l.prototype.verify=function(e,t,n,i){e=this._truncateToN(new r(e,16)),n=this.keyFromPublic(n,i);var o=(t=new f(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c,s=a.invm(this.n),u=s.mul(e).umod(this.n),l=s.mul(o).umod(this.n);return this.curve._maxwellTrick?!(c=this.g.jmulAdd(u,n.getPublic(),l)).isInfinity()&&c.eqXToP(o):!(c=this.g.mulAdd(u,n.getPublic(),l)).isInfinity()&&0===c.getX().umod(this.n).cmp(o)},l.prototype.recoverPubKey=function(e,t,n,i){s((3&n)===n,"The recovery param is more than two bits"),t=new f(t,i);var o=this.n,a=new r(e),c=t.r,u=t.s,l=1&n,h=n>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");c=h?this.curve.pointFromX(c.add(this.curve.n),l):this.curve.pointFromX(c,l);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),b=u.mul(d).umod(o);return this.g.mulAdd(p,c,b)},l.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new f(t,r)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(n))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,n){"use strict";var r=n(59),i=n(96),o=n(11);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),n=i.toArray(e.nonce,e.nonceEnc||"hex"),r=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new r.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,n,r){"string"!=typeof t&&(r=n,n=t,t=null),e=i.toArray(e,t),n=i.toArray(n,r),o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},a.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(r=n,n=t,t=null),n&&(n=i.toArray(n,r||"hex"),this._update(n));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var a=o.slice(0,e);return this._update(n),this._reseed++,i.encode(a,t)}},function(e,t,n){"use strict";var r=n(6),i=n(12).assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=o,o.fromPublic=function(e,t,n){return t instanceof o?t:new o(e,{pub:t,pubEnc:n})},o.fromPrivate=function(e,t,n){return t instanceof o?t:new o(e,{priv:t,privEnc:n})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new r(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(e,t,n){"use strict";var r=n(6),i=n(12),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function c(){this.place=0}function s(e,t){var n=e[t.place++];if(!(128&n))return n;for(var r=15&n,i=0,o=0,a=t.place;o<r;o++,a++)i<<=8,i|=e[a];return t.place=a,i}function u(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t<n;)t++;return 0===t?e:e.slice(t)}function f(e,t){if(t<128)e.push(t);else{var n=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var n=new c;if(48!==e[n.place++])return!1;if(s(e,n)+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var o=s(e,n),a=e.slice(n.place,o+n.place);if(n.place+=o,2!==e[n.place++])return!1;var u=s(e,n);if(e.length!==u+n.place)return!1;var f=e.slice(n.place,u+n.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===f[0]&&128&f[1]&&(f=f.slice(1)),this.r=new r(a),this.s=new r(f),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=u(t),n=u(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];f(r,t.length),(r=r.concat(t)).push(2),f(r,n.length);var o=r.concat(n),a=[48];return f(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,n){"use strict";var r=n(59),i=n(58),o=n(12),a=o.assert,c=o.parseBytes,s=n(211),u=n(212);function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=f,f.prototype.sign=function(e,t){e=c(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),i=this.g.mul(r),o=this.encodePoint(i),a=this.hashInt(o,n.pubBytes(),e).mul(n.priv()),s=r.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:o})},f.prototype.verify=function(e,t,n){e=c(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),i=this.hashInt(t.Rencoded(),r.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(r.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return o.intFromLE(e.digest()).umod(this.curve.n)},f.prototype.keyFromPublic=function(e){return s.fromPublic(this,e)},f.prototype.keyFromSecret=function(e){return s.fromSecret(this,e)},f.prototype.makeSignature=function(e){return e instanceof u?e:new u(this,e)},f.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},f.prototype.decodePoint=function(e){var t=(e=o.parseBytes(e)).length-1,n=e.slice(0,t).concat(-129&e[t]),r=0!=(128&e[t]),i=o.intFromLE(n);return this.curve.pointFromY(i,r)},f.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},f.prototype.decodeInt=function(e){return o.intFromLE(e)},f.prototype.isPoint=function(e){return e instanceof this.pointClass}},function(e,t,n){"use strict";var r=n(12),i=r.assert,o=r.parseBytes,a=r.cachedProperty;function c(e,t){this.eddsa=e,this._secret=o(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=o(t.pub)}c.fromPublic=function(e,t){return t instanceof c?t:new c(e,{pub:t})},c.fromSecret=function(e,t){return t instanceof c?t:new c(e,{secret:t})},c.prototype.secret=function(){return this._secret},a(c,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),a(c,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),a(c,"privBytes",(function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r})),a(c,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),a(c,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),a(c,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),c.prototype.sign=function(e){return i(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},c.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},c.prototype.getSecret=function(e){return i(this._secret,"KeyPair is public only"),r.encode(this.secret(),e)},c.prototype.getPublic=function(e){return r.encode(this.pubBytes(),e)},e.exports=c},function(e,t,n){"use strict";var r=n(6),i=n(12),o=i.assert,a=i.cachedProperty,c=i.parseBytes;function s(e,t){this.eddsa=e,"object"!=typeof t&&(t=c(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),o(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof r&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(s,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),a(s,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),a(s,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),a(s,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),s.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},s.prototype.toHex=function(){return i.encode(this.toBytes(),"hex").toUpperCase()},e.exports=s},function(e,t,n){"use strict";var r=n(33);t.certificate=n(223);var i=r.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));t.RSAPrivateKey=i;var o=r.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));t.RSAPublicKey=o;var a=r.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(c),this.key("subjectPublicKey").bitstr())}));t.PublicKey=a;var c=r.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),s=r.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(c),this.key("subjectPrivateKey").octstr())}));t.PrivateKey=s;var u=r.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));t.EncryptedPrivateKey=u;var f=r.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));t.DSAPrivateKey=f,t.DSAparam=r.define("DSAparam",(function(){this.int()}));var l=r.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(h),this.key("publicKey").optional().explicit(1).bitstr())}));t.ECPrivateKey=l;var h=r.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})}));t.signature=r.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},function(e,t,n){var r=n(33),i=n(4);function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){var t;try{t=n(215).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return i(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,n){return this._getDecoder(t).decode(e,n)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(r.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,n){return this._getEncoder(t).encode(e,n)}},function(module,exports){var indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t(e[n],n,e)},defineProp=function(){try{return Object.defineProperty({},"_",{}),function(e,t,n){Object.defineProperty(e,t,{writable:!0,enumerable:!1,configurable:!0,value:n})}}catch(e){return function(e,t,n){e[t]=n}}}(),globals=["Array","Boolean","Date","Error","EvalError","Function","Infinity","JSON","Math","NaN","Number","Object","RangeError","ReferenceError","RegExp","String","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","eval","isFinite","isNaN","parseFloat","parseInt","undefined","unescape"];function Context(){}Context.prototype={};var Script=exports.Script=function(e){if(!(this instanceof Script))return new Script(e);this.code=e};Script.prototype.runInContext=function(e){if(!(e instanceof Context))throw new TypeError("needs a 'context' argument.");var t=document.createElement("iframe");t.style||(t.style={}),t.style.display="none",document.body.appendChild(t);var n=t.contentWindow,r=n.eval,i=n.execScript;!r&&i&&(i.call(n,"null"),r=n.eval),forEach(Object_keys(e),(function(t){n[t]=e[t]})),forEach(globals,(function(t){e[t]&&(n[t]=e[t])}));var o=Object_keys(n),a=r.call(n,this.code);return forEach(Object_keys(n),(function(t){(t in e||-1===indexOf(o,t))&&(e[t]=n[t])})),forEach(globals,(function(t){t in e||defineProp(e,t,n[t])})),document.body.removeChild(t),a},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(e){var t=Script.createContext(e),n=this.runInContext(t);return e&&forEach(Object_keys(t),(function(n){e[n]=t[n]})),n},forEach(Object_keys(Script.prototype),(function(e){exports[e]=Script[e]=function(t){var n=Script(t);return n[e].apply(n,[].slice.call(arguments,1))}})),exports.isContext=function(e){return e instanceof Context},exports.createScript=function(e){return exports.Script(e)},exports.createContext=Script.createContext=function(e){var t=new Context;return"object"==typeof e&&forEach(Object_keys(e),(function(n){t[n]=e[n]})),t}},function(e,t,n){var r=n(4);function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,n){var r=this._reporterState;this.exitKey(e),null!==r.obj&&(r.obj[t]=n)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,n=t.obj;return t.obj=e,n},i.prototype.error=function(e){var t,n=this._reporterState,r=e instanceof o;if(t=r?e:new o(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return r||n.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},r(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},function(e,t,n){var r=n(34).Reporter,i=n(34).EncoderBuffer,o=n(34).DecoderBuffer,a=n(11),c=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],s=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(c);function u(e,t){var n={};this._baseState=n,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}e.exports=u;var f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){var e=this._baseState,t={};f.forEach((function(n){t[n]=e[n]}));var n=new this.constructor(t.parent);return n._baseState=t,n},u.prototype._wrap=function(){var e=this._baseState;s.forEach((function(t){this[t]=function(){var n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}}),this)},u.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),a.equal(t.children.length,1,"Root node can have only one child")},u.prototype._useArgs=function(e){var t=this._baseState,n=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==n.length&&(a(null===t.children),t.children=n,n.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(n){n==(0|n)&&(n|=0);var r=e[n];t[r]=n})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){u.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),c.forEach((function(e){u.prototype[e]=function(){var t=this._baseState,n=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(n),this}})),u.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},u.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},u.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},u.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},u.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},u.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},u.prototype._decode=function(e,t){var n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));var r,i=n.default,a=!0,c=null;if(null!==n.key&&(c=e.enterKey(n.key)),n.optional){var s=null;if(null!==n.explicit?s=n.explicit:null!==n.implicit?s=n.implicit:null!==n.tag&&(s=n.tag),null!==s||n.any){if(a=this._peekTag(e,s,n.any),e.isError(a))return a}else{var u=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(u)}}if(n.obj&&a&&(r=e.enterObject()),a){if(null!==n.explicit){var f=this._decodeTag(e,n.explicit);if(e.isError(f))return f;e=f}var l=e.offset;if(null===n.use&&null===n.choice){if(n.any)u=e.save();var h=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(h))return h;n.any?i=e.raw(u):e=h}if(t&&t.track&&null!==n.tag&&t.track(e.path(),l,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),i=n.any?i:null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(n){n._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){var d=new o(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(d,t)}}return n.obj&&a&&(i=e.leaveObject(r)),null===n.key||null===i&&!0!==a?null!==c&&e.exitKey(c):e.leaveKey(c,n.key,i),i},u.prototype._decodeGeneric=function(e,t,n){var r=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,r.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):"objid"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1],n):"objid"===e?this._decodeObjid(t,null,null,n):"gentime"===e||"utctime"===e?this._decodeTime(t,e,n):"null_"===e?this._decodeNull(t,n):"bool"===e?this._decodeBool(t,n):"objDesc"===e?this._decodeStr(t,e,n):"int"===e||"enum"===e?this._decodeInt(t,r.args&&r.args[0],n):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t,n):t.error("unknown tag: "+e)},u.prototype._getUse=function(e,t){var n=this._baseState;return n.useDecoder=this._use(e,t),a(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},u.prototype._decodeChoice=function(e,t){var n=this._baseState,r=null,i=!1;return Object.keys(n.choice).some((function(o){var a=e.save(),c=n.choice[o];try{var s=c._decode(e,t);if(e.isError(s))return!1;r={type:o,value:s},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?r:e.error("Choice not matched")},u.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},u.prototype._encode=function(e,t,n){var r=this._baseState;if(null===r.default||r.default!==e){var i=this._encodeValue(e,t,n);if(void 0!==i&&!this._skipDefault(i,t,n))return i}},u.prototype._encodeValue=function(e,t,n){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new r);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,c=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,n)._encode(e,t),c=!0;else if(i.children)a=i.children.map((function(n){if("null_"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error("Child should have a key");var r=t.enterKey(n._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=n._encode(e[n._baseState.key],t,e);return t.leaveKey(r),i}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var s=this.clone();s._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(n){var r=this._baseState;return this._getUse(r.args[0],e)._encode(n,t)}),s))}else null!==i.use?o=this._getUse(i.use,n)._encode(e,t):(a=this._encodePrimitive(i.tag,e),c=!0);if(!i.any&&null===i.choice){var u=null!==i.implicit?i.implicit:i.tag,f=null===i.implicit?"universal":"context";null===u?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(u,c,f,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},u.prototype._encodeChoice=function(e,t){var n=this._baseState,r=n.choice[e.type];return r||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),r._encode(e.value,t)},u.prototype._encodePrimitive=function(e,t){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},u.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},u.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},function(e,t,n){var r=n(102);t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=r._reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=r._reverse(t.tag)},function(e,t,n){var r=t;r.der=n(103),r.pem=n(220)},function(e,t,n){var r=n(4),i=n(5).Buffer,o=n(103);function a(e){o.call(this,e),this.enc="pem"}r(a,o),e.exports=a,a.prototype.decode=function(e,t){for(var n=e.toString().split(/[\r\n]+/g),r=t.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,c=-1,s=-1,u=0;u<n.length;u++){var f=n[u].match(a);if(null!==f&&f[2]===r){if(-1!==c){if("END"!==f[1])break;s=u;break}if("BEGIN"!==f[1])break;c=u}}if(-1===c||-1===s)throw new Error("PEM section not found for: "+r);var l=n.slice(c+1,s).join("");l.replace(/[^a-z0-9\+\/=]+/gi,"");var h=new i(l,"base64");return o.prototype.decode.call(this,h,t)}},function(e,t,n){var r=t;r.der=n(104),r.pem=n(222)},function(e,t,n){var r=n(4),i=n(104);function o(e){i.call(this,e),this.enc="pem"}r(o,i),e.exports=o,o.prototype.encode=function(e,t){for(var n=i.prototype.encode.call(this,e).toString("base64"),r=["-----BEGIN "+t.label+"-----"],o=0;o<n.length;o+=64)r.push(n.slice(o,o+64));return r.push("-----END "+t.label+"-----"),r.join("\n")}},function(e,t,n){"use strict";var r=n(33),i=r.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),o=r.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),a=r.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),c=r.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(a),this.key("subjectPublicKey").bitstr())})),s=r.define("RelativeDistinguishedName",(function(){this.setof(o)})),u=r.define("RDNSequence",(function(){this.seqof(s)})),f=r.define("Name",(function(){this.choice({rdnSequence:this.use(u)})})),l=r.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(i),this.key("notAfter").use(i))})),h=r.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),d=r.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(a),this.key("issuer").use(f),this.key("validity").use(l),this.key("subject").use(f),this.key("subjectPublicKeyInfo").use(c),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(h).optional())})),p=r.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(a),this.key("signatureValue").bitstr())}));e.exports=p},function(e){e.exports=JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}')},function(e,t,n){var r=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m,i=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,o=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m,a=n(38),c=n(53),s=n(3).Buffer;e.exports=function(e,t){var n,u=e.toString(),f=u.match(r);if(f){var l="aes"+f[1],h=s.from(f[2],"hex"),d=s.from(f[3].replace(/[\r\n]/g,""),"base64"),p=a(t,h.slice(0,8),parseInt(f[1],10)).key,b=[],_=c.createDecipheriv(l,p,h);b.push(_.update(d)),b.push(_.final()),n=s.concat(b)}else{var E=u.match(o);n=new s(E[2].replace(/[\r\n]/g,""),"base64")}return{tag:u.match(i)[1],data:n}}},function(e,t,n){(function(t){var r=n(6),i=n(57).ec,o=n(40),a=n(105);function c(e,t){if(e.cmpn(0)<=0)throw new Error("invalid sig");if(e.cmp(t)>=t)throw new Error("invalid sig")}e.exports=function(e,n,s,u,f){var l=o(s);if("ec"===l.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(e,t,n){var r=a[n.data.algorithm.curve.join(".")];if(!r)throw new Error("unknown curve "+n.data.algorithm.curve.join("."));var o=new i(r),c=n.data.subjectPrivateKey.data;return o.verify(t,e,c)}(e,n,l)}if("dsa"===l.type){if("dsa"!==u)throw new Error("wrong public key type");return function(e,t,n){var i=n.data.p,a=n.data.q,s=n.data.g,u=n.data.pub_key,f=o.signature.decode(e,"der"),l=f.s,h=f.r;c(l,a),c(h,a);var d=r.mont(i),p=l.invm(a);return 0===s.toRed(d).redPow(new r(t).mul(p).mod(a)).fromRed().mul(u.toRed(d).redPow(h.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(h)}(e,n,l)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");n=t.concat([f,n]);for(var h=l.modulus.byteLength(),d=[1],p=0;n.length+d.length+2<h;)d.push(255),p++;d.push(0);for(var b=-1;++b<n.length;)d.push(n[b]);d=new t(d);var _=r.mont(l.modulus);e=(e=new r(e).toRed(_)).redPow(new r(l.publicExponent)),e=new t(e.fromRed().toArray());var E=p<8?1:0;for(h=Math.min(e.length,d.length),e.length!==d.length&&(E=1),b=-1;++b<h;)E|=e[b]^d[b];return 0===E}}).call(this,n(5).Buffer)},function(e,t,n){(function(t){var r=n(57),i=n(6);e.exports=function(e){return new a(e)};var o={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function a(e){this.curveType=o[e],this.curveType||(this.curveType={name:e}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function c(e,n,r){Array.isArray(e)||(e=e.toArray());var i=new t(e);if(r&&i.length<r){var o=new t(r-i.length);o.fill(0),i=t.concat([o,i])}return n?i.toString(n):i}o.p224=o.secp224r1,o.p256=o.secp256r1=o.prime256v1,o.p192=o.secp192r1=o.prime192v1,o.p384=o.secp384r1,o.p521=o.secp521r1,a.prototype.generateKeys=function(e,t){return this.keys=this.curve.genKeyPair(),this.getPublicKey(e,t)},a.prototype.computeSecret=function(e,n,r){return n=n||"utf8",t.isBuffer(e)||(e=new t(e,n)),c(this.curve.keyFromPublic(e).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},a.prototype.getPublicKey=function(e,t){var n=this.keys.getPublic("compressed"===t,!0);return"hybrid"===t&&(n[n.length-1]%2?n[0]=7:n[0]=6),c(n,e)},a.prototype.getPrivateKey=function(e){return c(this.keys.getPrivate(),e)},a.prototype.setPublicKey=function(e,n){return n=n||"utf8",t.isBuffer(e)||(e=new t(e,n)),this.keys._importPublic(e),this},a.prototype.setPrivateKey=function(e,n){n=n||"utf8",t.isBuffer(e)||(e=new t(e,n));var r=new i(e);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}}).call(this,n(5).Buffer)},function(e,t,n){t.publicEncrypt=n(229),t.privateDecrypt=n(230),t.privateEncrypt=function(e,n){return t.publicEncrypt(e,n,!0)},t.publicDecrypt=function(e,n){return t.privateDecrypt(e,n,!0)}},function(e,t,n){var r=n(40),i=n(25),o=n(30),a=n(106),c=n(107),s=n(6),u=n(108),f=n(56),l=n(3).Buffer;e.exports=function(e,t,n){var h;h=e.padding?e.padding:n?1:4;var d,p=r(e);if(4===h)d=function(e,t){var n=e.modulus.byteLength(),r=t.length,u=o("sha1").update(l.alloc(0)).digest(),f=u.length,h=2*f;if(r>n-h-2)throw new Error("message too long");var d=l.alloc(n-r-h-2),p=n-f-1,b=i(f),_=c(l.concat([u,d,l.alloc(1,1),t],p),a(b,p)),E=c(b,a(_,f));return new s(l.concat([l.alloc(1),E,_],n))}(p,t);else if(1===h)d=function(e,t,n){var r,o=t.length,a=e.modulus.byteLength();if(o>a-11)throw new Error("message too long");r=n?l.alloc(a-o-3,255):function(e){var t,n=l.allocUnsafe(e),r=0,o=i(2*e),a=0;for(;r<e;)a===o.length&&(o=i(2*e),a=0),(t=o[a++])&&(n[r++]=t);return n}(a-o-3);return new s(l.concat([l.from([0,n?1:2]),r,l.alloc(1),t],a))}(p,t,n);else{if(3!==h)throw new Error("unknown padding");if((d=new s(t)).cmp(p.modulus)>=0)throw new Error("data too long for modulus")}return n?f(d,p):u(d,p)}},function(e,t,n){var r=n(40),i=n(106),o=n(107),a=n(6),c=n(56),s=n(30),u=n(108),f=n(3).Buffer;e.exports=function(e,t,n){var l;l=e.padding?e.padding:n?1:4;var h,d=r(e),p=d.modulus.byteLength();if(t.length>p||new a(t).cmp(d.modulus)>=0)throw new Error("decryption error");h=n?u(new a(t),d):c(t,d);var b=f.alloc(p-h.length);if(h=f.concat([b,h],p),4===l)return function(e,t){var n=e.modulus.byteLength(),r=s("sha1").update(f.alloc(0)).digest(),a=r.length;if(0!==t[0])throw new Error("decryption error");var c=t.slice(1,a+1),u=t.slice(a+1),l=o(c,i(u,a)),h=o(u,i(l,n-a-1));if(function(e,t){e=f.from(e),t=f.from(t);var n=0,r=e.length;e.length!==t.length&&(n++,r=Math.min(e.length,t.length));var i=-1;for(;++i<r;)n+=e[i]^t[i];return n}(r,h.slice(0,a)))throw new Error("decryption error");var d=a;for(;0===h[d];)d++;if(1!==h[d++])throw new Error("decryption error");return h.slice(d)}(d,h);if(1===l)return function(e,t,n){var r=t.slice(0,2),i=2,o=0;for(;0!==t[i++];)if(i>=t.length){o++;break}var a=t.slice(2,i-1);("0002"!==r.toString("hex")&&!n||"0001"!==r.toString("hex")&&n)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,h,n);if(3===l)return h;throw new Error("unknown padding")}},function(e,t,n){"use strict";(function(e,r){function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=n(3),a=n(25),c=o.Buffer,s=o.kMaxLength,u=e.crypto||e.msCrypto,f=Math.pow(2,32)-1;function l(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>s||e>t)throw new RangeError("offset out of range")}function h(e,t,n){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>n||e>s)throw new RangeError("buffer too small")}function d(e,t,n,i){if(r.browser){var o=e.buffer,c=new Uint8Array(o,t,n);return u.getRandomValues(c),i?void r.nextTick((function(){i(null,e)})):e}if(!i)return a(n).copy(e,t),e;a(n,(function(n,r){if(n)return i(n);r.copy(e,t),i(null,e)}))}u&&u.getRandomValues||!r.browser?(t.randomFill=function(t,n,r,i){if(!(c.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof n)i=n,n=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-n;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return l(n,t.length),h(r,n,t.length),d(t,n,r,i)},t.randomFillSync=function(t,n,r){void 0===n&&(n=0);if(!(c.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');l(n,t.length),void 0===r&&(r=t.length-n);return h(r,n,t.length),d(t,n,r)}):(t.randomFill=i,t.randomFillSync=i)}).call(this,n(19),n(10))},function(e,t,n){"use strict";var r=n(3).Buffer,i=n(233);function o(e){if(r.isBuffer(e))return e;if("string"==typeof e)return r.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function a(e,t,n){for(var r=0;t+r<n&&0===e[t+r];)++r;return e[t+r]>=128&&--r,r}e.exports={derToJose:function(e,t){e=o(e);var n=i(t),a=n+1,c=e.length,s=0;if(48!==e[s++])throw new Error('Could not find expected "seq"');var u=e[s++];if(129===u&&(u=e[s++]),c-s<u)throw new Error('"seq" specified length of "'+u+'", only "'+(c-s)+'" remaining');if(2!==e[s++])throw new Error('Could not find expected "int" for "r"');var f=e[s++];if(c-s-2<f)throw new Error('"r" specified length of "'+f+'", only "'+(c-s-2)+'" available');if(a<f)throw new Error('"r" specified length of "'+f+'", max of "'+a+'" is acceptable');var l=s;if(s+=f,2!==e[s++])throw new Error('Could not find expected "int" for "s"');var h=e[s++];if(c-s!==h)throw new Error('"s" specified length of "'+h+'", expected "'+(c-s)+'"');if(a<h)throw new Error('"s" specified length of "'+h+'", max of "'+a+'" is acceptable');var d=s;if((s+=h)!==c)throw new Error('Expected to consume entire buffer, but "'+(c-s)+'" bytes remain');var p=n-f,b=n-h,_=r.allocUnsafe(p+f+b+h);for(s=0;s<p;++s)_[s]=0;e.copy(_,s,l+Math.max(-p,0),l+f);for(var E=s=n;s<E+b;++s)_[s]=0;return e.copy(_,s,d+Math.max(-b,0),d+h),_=(_=_.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=o(e);var n=i(t),c=e.length;if(c!==2*n)throw new TypeError('"'+t+'" signatures must be "'+2*n+'" bytes, saw "'+c+'"');var s=a(e,0,n),u=a(e,n,e.length),f=n-s,l=n-u,h=2+f+1+1+l,d=h<128,p=r.allocUnsafe((d?2:3)+h),b=0;return p[b++]=48,d?p[b++]=h:(p[b++]=129,p[b++]=255&h),p[b++]=2,p[b++]=f,s<0?(p[b++]=0,b+=e.copy(p,b,0,n)):b+=e.copy(p,b,s,n),p[b++]=2,p[b++]=l,u<0?(p[b++]=0,e.copy(p,b,n)):e.copy(p,b,n+u),p}}},function(e,t,n){"use strict";function r(e){return(e/8|0)+(e%8==0?0:1)}var i={ES256:r(256),ES384:r(384),ES512:r(521)};e.exports=function(e){var t=i[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},function(e,t,n){var r=n(3).Buffer,i=n(71),o=n(76),a=n(24),c=n(109),s=n(36),u=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function f(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}function l(e){var t=e.split(".",1)[0];return f(r.from(t,"base64").toString("binary"))}function h(e){return e.split(".")[2]}function d(e){return u.test(e)&&!!l(e)}function p(e,t,n){if(!t){var r=new Error("Missing algorithm parameter for jws.verify");throw r.code="MISSING_ALGORITHM",r}var i=h(e=c(e)),a=function(e){return e.split(".",2).join(".")}(e);return o(t).verify(a,i,n)}function b(e,t){if(t=t||{},!d(e=c(e)))return null;var n=l(e);if(!n)return null;var i=function(e,t){t=t||"utf8";var n=e.split(".")[1];return r.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(i=JSON.parse(i,t.encoding)),{header:n,payload:i,signature:h(e)}}function _(e){var t=(e=e||{}).secret||e.publicKey||e.key,n=new i(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new i(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}s.inherits(_,a),_.prototype.verify=function(){try{var e=p(this.signature.buffer,this.algorithm,this.key.buffer),t=b(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},_.decode=b,_.isValid=d,_.verify=p,e.exports=_},function(e,t,n){var r=n(41),i=n(110),o=n(111),a=n(69),c=n(112),s=n(113),u=n(44),f=["RS256","RS384","RS512","ES256","ES384","ES512"],l=["RS256","RS384","RS512"],h=["HS256","HS384","HS512"];s&&(f.splice(3,0,"PS256","PS384","PS512"),l.splice(3,0,"PS256","PS384","PS512")),e.exports=function(e,t,n,s){var d;if("function"!=typeof n||s||(s=n,n={}),n||(n={}),n=Object.assign({},n),d=s||function(e,t){if(e)throw e;return t},n.clockTimestamp&&"number"!=typeof n.clockTimestamp)return d(new r("clockTimestamp must be a number"));if(void 0!==n.nonce&&("string"!=typeof n.nonce||""===n.nonce.trim()))return d(new r("nonce must be a non-empty string"));var p=n.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return d(new r("jwt must be provided"));if("string"!=typeof e)return d(new r("jwt must be a string"));var b,_=e.split(".");if(3!==_.length)return d(new r("jwt malformed"));try{b=a(e,{complete:!0})}catch(e){return d(e)}if(!b)return d(new r("invalid token"));var E,y=b.header;if("function"==typeof t){if(!s)return d(new r("verify must be called asynchronous if secret or public key is provided as a callback"));E=t}else E=function(e,n){return n(null,t)};return E(y,(function(t,a){if(t)return d(new r("error in secret or public key callback: "+t.message));var s,E=""!==_[2].trim();if(!E&&a)return d(new r("jwt signature is required"));if(E&&!a)return d(new r("secret or public key must be provided"));if(E||n.algorithms||(n.algorithms=["none"]),n.algorithms||(n.algorithms=~a.toString().indexOf("BEGIN CERTIFICATE")||~a.toString().indexOf("BEGIN PUBLIC KEY")?f:~a.toString().indexOf("BEGIN RSA PUBLIC KEY")?l:h),!~n.algorithms.indexOf(b.header.alg))return d(new r("invalid algorithm"));try{s=u.verify(e,b.header.alg,a)}catch(e){return d(e)}if(!s)return d(new r("invalid signature"));var v=b.payload;if(void 0!==v.nbf&&!n.ignoreNotBefore){if("number"!=typeof v.nbf)return d(new r("invalid nbf value"));if(v.nbf>p+(n.clockTolerance||0))return d(new i("jwt not active",new Date(1e3*v.nbf)))}if(void 0!==v.exp&&!n.ignoreExpiration){if("number"!=typeof v.exp)return d(new r("invalid exp value"));if(p>=v.exp+(n.clockTolerance||0))return d(new o("jwt expired",new Date(1e3*v.exp)))}if(n.audience){var g=Array.isArray(n.audience)?n.audience:[n.audience];if(!(Array.isArray(v.aud)?v.aud:[v.aud]).some((function(e){return g.some((function(t){return t instanceof RegExp?t.test(e):t===e}))})))return d(new r("jwt audience invalid. expected: "+g.join(" or ")))}if(n.issuer&&("string"==typeof n.issuer&&v.iss!==n.issuer||Array.isArray(n.issuer)&&-1===n.issuer.indexOf(v.iss)))return d(new r("jwt issuer invalid. expected: "+n.issuer));if(n.subject&&v.sub!==n.subject)return d(new r("jwt subject invalid. expected: "+n.subject));if(n.jwtid&&v.jti!==n.jwtid)return d(new r("jwt jwtid invalid. expected: "+n.jwtid));if(n.nonce&&v.nonce!==n.nonce)return d(new r("jwt nonce invalid. expected: "+n.nonce));if(n.maxAge){if("number"!=typeof v.iat)return d(new r("iat required when maxAge is specified"));var m=c(n.maxAge,v.iat);if(void 0===m)return d(new r('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(p>=m+(n.clockTolerance||0))return d(new o("maxAge exceeded",new Date(1e3*m)))}if(!0===n.complete){var S=b.signature;return d(null,{header:y,payload:v,signature:S})}return d(null,v)}))}},function(e,t){var n=1e3,r=6e4,i=36e5,o=24*i;function a(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,t){t=t||{};var c=typeof e;if("string"===c&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===c&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return a(e,t,o,"day");if(t>=i)return a(e,t,i,"hour");if(t>=r)return a(e,t,r,"minute");if(t>=n)return a(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(n){var r;t=e.exports=K,r="object"==typeof n&&n.env&&n.env.NODE_DEBUG&&/\bsemver\b/i.test(n.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},t.SEMVER_SPEC_VERSION="2.0.0";var i=Number.MAX_SAFE_INTEGER||9007199254740991,o=t.re=[],a=t.src=[],c=0,s=c++;a[s]="0|[1-9]\\d*";var u=c++;a[u]="[0-9]+";var f=c++;a[f]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var l=c++;a[l]="("+a[s]+")\\.("+a[s]+")\\.("+a[s]+")";var h=c++;a[h]="("+a[u]+")\\.("+a[u]+")\\.("+a[u]+")";var d=c++;a[d]="(?:"+a[s]+"|"+a[f]+")";var p=c++;a[p]="(?:"+a[u]+"|"+a[f]+")";var b=c++;a[b]="(?:-("+a[d]+"(?:\\."+a[d]+")*))";var _=c++;a[_]="(?:-?("+a[p]+"(?:\\."+a[p]+")*))";var E=c++;a[E]="[0-9A-Za-z-]+";var y=c++;a[y]="(?:\\+("+a[E]+"(?:\\."+a[E]+")*))";var v=c++,g="v?"+a[l]+a[b]+"?"+a[y]+"?";a[v]="^"+g+"$";var m="[v=\\s]*"+a[h]+a[_]+"?"+a[y]+"?",S=c++;a[S]="^"+m+"$";var O=c++;a[O]="((?:<|>)?=?)";var A=c++;a[A]=a[u]+"|x|X|\\*";var T=c++;a[T]=a[s]+"|x|X|\\*";var N=c++;a[N]="[v=\\s]*("+a[T]+")(?:\\.("+a[T]+")(?:\\.("+a[T]+")(?:"+a[b]+")?"+a[y]+"?)?)?";var M=c++;a[M]="[v=\\s]*("+a[A]+")(?:\\.("+a[A]+")(?:\\.("+a[A]+")(?:"+a[_]+")?"+a[y]+"?)?)?";var w=c++;a[w]="^"+a[O]+"\\s*"+a[N]+"$";var C=c++;a[C]="^"+a[O]+"\\s*"+a[M]+"$";var I=c++;a[I]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var P=c++;a[P]="(?:~>?)";var L=c++;a[L]="(\\s*)"+a[P]+"\\s+",o[L]=new RegExp(a[L],"g");var R=c++;a[R]="^"+a[P]+a[N]+"$";var D=c++;a[D]="^"+a[P]+a[M]+"$";var j=c++;a[j]="(?:\\^)";var U=c++;a[U]="(\\s*)"+a[j]+"\\s+",o[U]=new RegExp(a[U],"g");var k=c++;a[k]="^"+a[j]+a[N]+"$";var x=c++;a[x]="^"+a[j]+a[M]+"$";var B=c++;a[B]="^"+a[O]+"\\s*("+m+")$|^$";var F=c++;a[F]="^"+a[O]+"\\s*("+g+")$|^$";var V=c++;a[V]="(\\s*)"+a[O]+"\\s*("+m+"|"+a[N]+")",o[V]=new RegExp(a[V],"g");var Y=c++;a[Y]="^\\s*("+a[N]+")\\s+-\\s+("+a[N]+")\\s*$";var G=c++;a[G]="^\\s*("+a[M]+")\\s+-\\s+("+a[M]+")\\s*$";var H=c++;a[H]="(<|>)?=?\\s*\\*";for(var q=0;q<35;q++)r(q,a[q]),o[q]||(o[q]=new RegExp(a[q]));function z(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof K)return e;if("string"!=typeof e)return null;if(e.length>256)return null;if(!(t.loose?o[S]:o[v]).test(e))return null;try{return new K(e,t)}catch(e){return null}}function K(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof K){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>256)throw new TypeError("version is longer than 256 characters");if(!(this instanceof K))return new K(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var n=e.trim().match(t.loose?o[S]:o[v]);if(!n)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}t.parse=z,t.valid=function(e,t){var n=z(e,t);return n?n.version:null},t.clean=function(e,t){var n=z(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null},t.SemVer=K,K.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},K.prototype.toString=function(){return this.version},K.prototype.compare=function(e){return r("SemVer.compare",this.version,this.options,e),e instanceof K||(e=new K(e,this.options)),this.compareMain(e)||this.comparePre(e)},K.prototype.compareMain=function(e){return e instanceof K||(e=new K(e,this.options)),X(this.major,e.major)||X(this.minor,e.minor)||X(this.patch,e.patch)},K.prototype.comparePre=function(e){if(e instanceof K||(e=new K(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var t=0;do{var n=this.prerelease[t],i=e.prerelease[t];if(r("prerelease compare",t,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return X(n,i)}while(++t)},K.prototype.inc=function(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var n=this.prerelease.length;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);-1===n&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,n,r){"string"==typeof n&&(r=n,n=void 0);try{return new K(e,n).inc(t,r).version}catch(e){return null}},t.diff=function(e,t){if(Z(e,t))return null;var n=z(e),r=z(t);if(n.prerelease.length||r.prerelease.length){for(var i in n)if(("major"===i||"minor"===i||"patch"===i)&&n[i]!==r[i])return"pre"+i;return"prerelease"}for(var i in n)if(("major"===i||"minor"===i||"patch"===i)&&n[i]!==r[i])return i},t.compareIdentifiers=X;var W=/^[0-9]+$/;function X(e,t){var n=W.test(e),r=W.test(t);return n&&r&&(e=+e,t=+t),n&&!r?-1:r&&!n?1:e<t?-1:e>t?1:0}function J(e,t,n){return new K(e,n).compare(new K(t,n))}function Q(e,t,n){return J(e,t,n)>0}function $(e,t,n){return J(e,t,n)<0}function Z(e,t,n){return 0===J(e,t,n)}function ee(e,t,n){return 0!==J(e,t,n)}function te(e,t,n){return J(e,t,n)>=0}function ne(e,t,n){return J(e,t,n)<=0}function re(e,t,n,r){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),i=e===n;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),i=e!==n;break;case"":case"=":case"==":i=Z(e,n,r);break;case"!=":i=ee(e,n,r);break;case">":i=Q(e,n,r);break;case">=":i=te(e,n,r);break;case"<":i=$(e,n,r);break;case"<=":i=ne(e,n,r);break;default:throw new TypeError("Invalid operator: "+t)}return i}function ie(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ie){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ie))return new ie(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===oe?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return X(t,e)},t.major=function(e,t){return new K(e,t).major},t.minor=function(e,t){return new K(e,t).minor},t.patch=function(e,t){return new K(e,t).patch},t.compare=J,t.compareLoose=function(e,t){return J(e,t,!0)},t.rcompare=function(e,t,n){return J(t,e,n)},t.sort=function(e,n){return e.sort((function(e,r){return t.compare(e,r,n)}))},t.rsort=function(e,n){return e.sort((function(e,r){return t.rcompare(e,r,n)}))},t.gt=Q,t.lt=$,t.eq=Z,t.neq=ee,t.gte=te,t.lte=ne,t.cmp=re,t.Comparator=ie;var oe={};function ae(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ae)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new ae(e.raw,t);if(e instanceof ie)return new ae(e.value,t);if(!(this instanceof ae))return new ae(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map((function(e){return this.parseRange(e.trim())}),this).filter((function(e){return e.length})),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function ce(e){return!e||"x"===e.toLowerCase()||"*"===e}function se(e,t,n,r,i,o,a,c,s,u,f,l,h){return((t=ce(n)?"":ce(r)?">="+n+".0.0":ce(i)?">="+n+"."+r+".0":">="+t)+" "+(c=ce(s)?"":ce(u)?"<"+(+s+1)+".0.0":ce(f)?"<"+s+"."+(+u+1)+".0":l?"<="+s+"."+u+"."+f+"-"+l:"<="+c)).trim()}function ue(e,t,n){for(var i=0;i<e.length;i++)if(!e[i].test(t))return!1;if(n||(n={}),t.prerelease.length&&!n.includePrerelease){for(i=0;i<e.length;i++)if(r(e[i].semver),e[i].semver!==oe&&e[i].semver.prerelease.length>0){var o=e[i].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0}function fe(e,t,n){try{t=new ae(t,n)}catch(e){return!1}return t.test(e)}function le(e,t,n,r){var i,o,a,c,s;switch(e=new K(e,r),t=new ae(t,r),n){case">":i=Q,o=ne,a=$,c=">",s=">=";break;case"<":i=$,o=te,a=Q,c="<",s="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(fe(e,t,r))return!1;for(var u=0;u<t.set.length;++u){var f=t.set[u],l=null,h=null;if(f.forEach((function(e){e.semver===oe&&(e=new ie(">=0.0.0")),l=l||e,h=h||e,i(e.semver,l.semver,r)?l=e:a(e.semver,h.semver,r)&&(h=e)})),l.operator===c||l.operator===s)return!1;if((!h.operator||h.operator===c)&&o(e,h.semver))return!1;if(h.operator===s&&a(e,h.semver))return!1}return!0}ie.prototype.parse=function(e){var t=this.options.loose?o[B]:o[F],n=e.match(t);if(!n)throw new TypeError("Invalid comparator: "+e);this.operator=n[1],"="===this.operator&&(this.operator=""),n[2]?this.semver=new K(n[2],this.options.loose):this.semver=oe},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===oe||("string"==typeof e&&(e=new K(e,this.options)),re(e,this.operator,this.semver,this.options))},ie.prototype.intersects=function(e,t){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var n;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return n=new ae(e.value,t),fe(this.value,n,t);if(""===e.operator)return n=new ae(this.value,t),fe(e.semver,n,t);var r=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),o=this.semver.version===e.semver.version,a=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),c=re(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),s=re(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return r||i||o&&a||c||s},t.Range=ae,ae.prototype.format=function(){return this.range=this.set.map((function(e){return e.join(" ").trim()})).join("||").trim(),this.range},ae.prototype.toString=function(){return this.range},ae.prototype.parseRange=function(e){var t=this.options.loose;e=e.trim();var n=t?o[G]:o[Y];e=e.replace(n,se),r("hyphen replace",e),e=e.replace(o[V],"$1$2$3"),r("comparator trim",e,o[V]),e=(e=(e=e.replace(o[L],"$1~")).replace(o[U],"$1^")).split(/\s+/).join(" ");var i=t?o[B]:o[F],a=e.split(" ").map((function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){r("caret",e,t),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?o[x]:o[k];return e.replace(n,(function(t,n,i,o,a){var c;return r("caret",e,t,n,i,o,a),ce(n)?c="":ce(i)?c=">="+n+".0.0 <"+(+n+1)+".0.0":ce(o)?c="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":a?(r("replaceCaret pr",a),"-"!==a.charAt(0)&&(a="-"+a),c="0"===n?"0"===i?">="+n+"."+i+"."+o+a+" <"+n+"."+i+"."+(+o+1):">="+n+"."+i+"."+o+a+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+o+a+" <"+(+n+1)+".0.0"):(r("no pr"),c="0"===n?"0"===i?">="+n+"."+i+"."+o+" <"+n+"."+i+"."+(+o+1):">="+n+"."+i+"."+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+o+" <"+(+n+1)+".0.0"),r("caret return",c),c}))}(e,t)})).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?o[D]:o[R];return e.replace(n,(function(t,n,i,o,a){var c;return r("tilde",e,t,n,i,o,a),ce(n)?c="":ce(i)?c=">="+n+".0.0 <"+(+n+1)+".0.0":ce(o)?c=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":a?(r("replaceTilde pr",a),"-"!==a.charAt(0)&&(a="-"+a),c=">="+n+"."+i+"."+o+a+" <"+n+"."+(+i+1)+".0"):c=">="+n+"."+i+"."+o+" <"+n+"."+(+i+1)+".0",r("tilde return",c),c}))}(e,t)})).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map((function(e){return function(e,t){e=e.trim(),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?o[C]:o[w];return e.replace(n,(function(t,n,i,o,a,c){r("xRange",e,t,n,i,o,a,c);var s=ce(i),u=s||ce(o),f=u||ce(a);return"="===n&&f&&(n=""),s?t=">"===n||"<"===n?"<0.0.0":"*":n&&f?(u&&(o=0),f&&(a=0),">"===n?(n=">=",u?(i=+i+1,o=0,a=0):f&&(o=+o+1,a=0)):"<="===n&&(n="<",u?i=+i+1:o=+o+1),t=n+i+"."+o+"."+a):u?t=">="+i+".0.0 <"+(+i+1)+".0.0":f&&(t=">="+i+"."+o+".0 <"+i+"."+(+o+1)+".0"),r("xRange return",t),t}))}(e,t)})).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(o[H],"")}(e,t),r("stars",e),e}(e,this.options)}),this).join(" ").split(/\s+/);return this.options.loose&&(a=a.filter((function(e){return!!e.match(i)}))),a=a.map((function(e){return new ie(e,this.options)}),this)},ae.prototype.intersects=function(e,t){if(!(e instanceof ae))throw new TypeError("a Range is required");return this.set.some((function(n){return n.every((function(n){return e.set.some((function(e){return e.every((function(e){return n.intersects(e,t)}))}))}))}))},t.toComparators=function(e,t){return new ae(e,t).set.map((function(e){return e.map((function(e){return e.value})).join(" ").trim().split(" ")}))},ae.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new K(e,this.options));for(var t=0;t<this.set.length;t++)if(ue(this.set[t],e,this.options))return!0;return!1},t.satisfies=fe,t.maxSatisfying=function(e,t,n){var r=null,i=null;try{var o=new ae(t,n)}catch(e){return null}return e.forEach((function(e){o.test(e)&&(r&&-1!==i.compare(e)||(i=new K(r=e,n)))})),r},t.minSatisfying=function(e,t,n){var r=null,i=null;try{var o=new ae(t,n)}catch(e){return null}return e.forEach((function(e){o.test(e)&&(r&&1!==i.compare(e)||(i=new K(r=e,n)))})),r},t.validRange=function(e,t){try{return new ae(e,t).range||"*"}catch(e){return null}},t.ltr=function(e,t,n){return le(e,t,"<",n)},t.gtr=function(e,t,n){return le(e,t,">",n)},t.outside=le,t.prerelease=function(e,t){var n=z(e,t);return n&&n.prerelease.length?n.prerelease:null},t.intersects=function(e,t,n){return e=new ae(e,n),t=new ae(t,n),e.intersects(t)},t.coerce=function(e){if(e instanceof K)return e;if("string"!=typeof e)return null;var t=e.match(o[I]);return null==t?null:z((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}).call(this,n(10))},function(e,t,n){(function(t){var r=n(112),i=n(113),o=n(44),a=n(239),c=n(240),s=n(241),u=n(242),f=n(243),l=n(244),h=n(245),d=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];i&&d.splice(3,0,"PS256","PS384","PS512");var p={expiresIn:{isValid:function(e){return s(e)||l(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return s(e)||l(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return l(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:a.bind(null,d),message:'"algorithm" must be a valid string enum value'},header:{isValid:f,message:'"header" must be an object'},encoding:{isValid:l,message:'"encoding" must be a string'},issuer:{isValid:l,message:'"issuer" must be a string'},subject:{isValid:l,message:'"subject" must be a string'},jwtid:{isValid:l,message:'"jwtid" must be a string'},noTimestamp:{isValid:c,message:'"noTimestamp" must be a boolean'},keyid:{isValid:l,message:'"keyid" must be a string'},mutatePayload:{isValid:c,message:'"mutatePayload" must be a boolean'}},b={iat:{isValid:u,message:'"iat" should be a number of seconds'},exp:{isValid:u,message:'"exp" should be a number of seconds'},nbf:{isValid:u,message:'"nbf" should be a number of seconds'}};function _(e,t,n,r){if(!f(n))throw new Error('Expected "'+r+'" to be a plain object.');Object.keys(n).forEach((function(i){var o=e[i];if(o){if(!o.isValid(n[i]))throw new Error(o.message)}else if(!t)throw new Error('"'+i+'" is not allowed in "'+r+'"')}))}var E={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},y=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];e.exports=function(e,n,i,a){"function"==typeof i?(a=i,i={}):i=i||{};var c="object"==typeof e&&!t.isBuffer(e),s=Object.assign({alg:i.algorithm||"HS256",typ:c?"JWT":void 0,kid:i.keyid},i.header);function u(e){if(a)return a(e);throw e}if(!n&&"none"!==i.algorithm)return u(new Error("secretOrPrivateKey must have a value"));if(void 0===e)return u(new Error("payload is required"));if(c){try{!function(e){_(b,!0,e,"payload")}(e)}catch(e){return u(e)}i.mutatePayload||(e=Object.assign({},e))}else{var f=y.filter((function(e){return void 0!==i[e]}));if(f.length>0)return u(new Error("invalid "+f.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==i.expiresIn)return u(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==i.notBefore)return u(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){_(p,!1,e,"options")}(i)}catch(e){return u(e)}var l=e.iat||Math.floor(Date.now()/1e3);if(i.noTimestamp?delete e.iat:c&&(e.iat=l),void 0!==i.notBefore){try{e.nbf=r(i.notBefore,l)}catch(e){return u(e)}if(void 0===e.nbf)return u(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==i.expiresIn&&"object"==typeof e){try{e.exp=r(i.expiresIn,l)}catch(e){return u(e)}if(void 0===e.exp)return u(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(E).forEach((function(t){var n=E[t];if(void 0!==i[t]){if(void 0!==e[n])return u(new Error('Bad "options.'+t+'" option. The payload already has an "'+n+'" property.'));e[n]=i[t]}}));var d=i.encoding||"utf8";if("function"!=typeof a)return o.sign({header:s,payload:e,secret:n,encoding:d});a=a&&h(a),o.createSign({header:s,privateKey:n,payload:e,encoding:d}).once("error",a).once("done",(function(e){a(null,e)}))}}).call(this,n(5).Buffer)},function(e,t){var n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=/^(?:0|[1-9]\d*)$/,c=parseInt;function s(e){return e!=e}function u(e,t){return function(e,t){for(var n=-1,r=e?e.length:0,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}(t,(function(t){return e[t]}))}var f,l,h=Object.prototype,d=h.hasOwnProperty,p=h.toString,b=h.propertyIsEnumerable,_=(f=Object.keys,l=Object,function(e){return f(l(e))}),E=Math.max;function y(e,t){var n=m(e)||function(e){return function(e){return A(e)&&S(e)}(e)&&d.call(e,"callee")&&(!b.call(e,"callee")||"[object Arguments]"==p.call(e))}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,i=!!r;for(var o in e)!t&&!d.call(e,o)||i&&("length"==o||g(o,r))||n.push(o);return n}function v(e){if(n=(t=e)&&t.constructor,r="function"==typeof n&&n.prototype||h,t!==r)return _(e);var t,n,r,i=[];for(var o in Object(e))d.call(e,o)&&"constructor"!=o&&i.push(o);return i}function g(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||a.test(e))&&e>-1&&e%1==0&&e<t}var m=Array.isArray;function S(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}(e.length)&&!function(e){var t=O(e)?p.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function O(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function A(e){return!!e&&"object"==typeof e}e.exports=function(e,t,a,f){var l;e=S(e)?e:(l=e)?u(l,function(e){return S(e)?y(e):v(e)}(l)):[],a=a&&!f?function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||A(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(O(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=O(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var a=i.test(e);return a||o.test(e)?c(e.slice(2),a?2:8):r.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),a=t%1;return t==t?a?t-a:t:0}(a):0;var h=e.length;return a<0&&(a=E(h+a,0)),function(e){return"string"==typeof e||!m(e)&&A(e)&&"[object String]"==p.call(e)}(e)?a<=h&&e.indexOf(t,a)>-1:!!h&&function(e,t,n){if(t!=t)return function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}(e,s,n);for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}(e,t,a)>-1}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==n.call(e)}},function(e,t){var n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt,c=Object.prototype.toString;function s(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return"number"==typeof e&&e==function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==c.call(e)}(e))return NaN;if(s(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=s(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var u=i.test(e);return u||o.test(e)?a(e.slice(2),u?2:8):r.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),u=t%1;return t==t?u?t-u:t:0}(e)}},function(e,t){var n=Object.prototype.toString;e.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==n.call(e)}},function(e,t){var n,r,i=Function.prototype,o=Object.prototype,a=i.toString,c=o.hasOwnProperty,s=a.call(Object),u=o.toString,f=(n=Object.getPrototypeOf,r=Object,function(e){return n(r(e))});e.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=u.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=f(e);if(null===t)return!0;var n=c.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&a.call(n)==s}},function(e,t){var n=Object.prototype.toString,r=Array.isArray;e.exports=function(e){return"string"==typeof e||!r(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==n.call(e)}},function(e,t){var n=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt,c=Object.prototype.toString;function s(e,t){var s;if("function"!=typeof t)throw new TypeError("Expected a function");return e=function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==c.call(e)}(e))return NaN;if(u(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=u(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var s=i.test(e);return s||o.test(e)?a(e.slice(2),s?2:8):r.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),s=t%1;return t==t?s?t-s:t:0}(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=void 0),s}}function u(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return s(2,e)}},function(e,t,n){"use strict";var r=n(60),i=n(114),o=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},c=Array.isArray,s=Array.prototype.push,u=function(e,t){s.apply(e,c(t)?t:[t])},f=Date.prototype.toISOString,l=i.default,h={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:r.encode,encodeValuesOnly:!1,format:l,formatter:i.formatters[l],indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},d=function e(t,n,i,o,a,s,f,l,d,p,b,_,E){var y,v=t;if("function"==typeof f?v=f(n,v):v instanceof Date?v=p(v):"comma"===i&&c(v)&&(v=v.join(",")),null===v){if(o)return s&&!_?s(n,h.encoder,E,"key"):n;v=""}if("string"==typeof(y=v)||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||r.isBuffer(v))return s?[b(_?n:s(n,h.encoder,E,"key"))+"="+b(s(v,h.encoder,E,"value"))]:[b(n)+"="+b(String(v))];var g,m=[];if(void 0===v)return m;if(c(f))g=f;else{var S=Object.keys(v);g=l?S.sort(l):S}for(var O=0;O<g.length;++O){var A=g[O];a&&null===v[A]||(c(v)?u(m,e(v[A],"function"==typeof i?i(n,A):n,i,o,a,s,f,l,d,p,b,_,E)):u(m,e(v[A],n+(d?"."+A:"["+A+"]"),i,o,a,s,f,l,d,p,b,_,E)))}return m};e.exports=function(e,t){var n,r=e,s=function(e){if(!e)return h;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||h.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=i.default;if(void 0!==e.format){if(!o.call(i.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=i.formatters[n],a=h.filter;return("function"==typeof e.filter||c(e.filter))&&(a=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:h.addQueryPrefix,allowDots:void 0===e.allowDots?h.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:h.charsetSentinel,delimiter:void 0===e.delimiter?h.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:h.encode,encoder:"function"==typeof e.encoder?e.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:h.encodeValuesOnly,filter:a,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:h.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:h.strictNullHandling}}(t);"function"==typeof s.filter?r=(0,s.filter)("",r):c(s.filter)&&(n=s.filter);var f,l=[];if("object"!=typeof r||null===r)return"";f=t&&t.arrayFormat in a?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=a[f];n||(n=Object.keys(r)),s.sort&&n.sort(s.sort);for(var b=0;b<n.length;++b){var _=n[b];s.skipNulls&&null===r[_]||u(l,d(r[_],_,p,s.strictNullHandling,s.skipNulls,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.formatter,s.encodeValuesOnly,s.charset))}var E=l.join(s.delimiter),y=!0===s.addQueryPrefix?"?":"";return s.charsetSentinel&&("iso-8859-1"===s.charset?y+="utf8=%26%2310003%3B&":y+="utf8=%E2%9C%93&"),E.length>0?y+E:""}},function(e,t,n){"use strict";var r=n(60),i=Object.prototype.hasOwnProperty,o=Array.isArray,a={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},c=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},s=function(e,t,n){if(e){var r=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(r),c=a?r.slice(0,a.index):r,s=[];if(c){if(!n.plainObjects&&i.call(Object.prototype,c)&&!n.allowPrototypes)return;s.push(c)}for(var u=0;n.depth>0&&null!==(a=o.exec(r))&&u<n.depth;){if(u+=1,!n.plainObjects&&i.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;s.push(a[1])}return a&&s.push("["+r.slice(a.index)+"]"),function(e,t,n){for(var r=t,i=e.length-1;i>=0;--i){var o,a=e[i];if("[]"===a&&n.parseArrays)o=[].concat(r);else{o=n.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,s=parseInt(c,10);n.parseArrays||""!==c?!isNaN(s)&&a!==c&&String(s)===c&&s>=0&&n.parseArrays&&s<=n.arrayLimit?(o=[])[s]=r:o[c]=r:o={0:r}}r=o}return r}(s,t,n)}};e.exports=function(e,t){var n=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new Error("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var u="string"==typeof e?function(e,t){var n,s={},u=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,f=t.parameterLimit===1/0?void 0:t.parameterLimit,l=u.split(t.delimiter,f),h=-1,d=t.charset;if(t.charsetSentinel)for(n=0;n<l.length;++n)0===l[n].indexOf("utf8=")&&("utf8=%E2%9C%93"===l[n]?d="utf-8":"utf8=%26%2310003%3B"===l[n]&&(d="iso-8859-1"),h=n,n=l.length);for(n=0;n<l.length;++n)if(n!==h){var p,b,_=l[n],E=_.indexOf("]="),y=-1===E?_.indexOf("="):E+1;-1===y?(p=t.decoder(_,a.decoder,d,"key"),b=t.strictNullHandling?null:""):(p=t.decoder(_.slice(0,y),a.decoder,d,"key"),b=t.decoder(_.slice(y+1),a.decoder,d,"value")),b&&t.interpretNumericEntities&&"iso-8859-1"===d&&(b=c(b)),b&&"string"==typeof b&&t.comma&&b.indexOf(",")>-1&&(b=b.split(",")),_.indexOf("[]=")>-1&&(b=o(b)?[b]:b),i.call(s,p)?s[p]=r.combine(s[p],b):s[p]=b}return s}(e,n):e,f=n.plainObjects?Object.create(null):{},l=Object.keys(u),h=0;h<l.length;++h){var d=l[h],p=s(d,u[d],n);f=r.merge(f,p,n)}return r.compact(f)}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17),i=function(){function e(e){this.table={},this.nElements=0,this.toStr=e||r.defaultToString}return e.prototype.getValue=function(e){var t=this.table["$"+this.toStr(e)];if(!r.isUndefined(t))return t.value},e.prototype.setValue=function(e,t){if(!r.isUndefined(e)&&!r.isUndefined(t)){var n,i="$"+this.toStr(e),o=this.table[i];return r.isUndefined(o)?(this.nElements++,n=void 0):n=o.value,this.table[i]={key:e,value:t},n}},e.prototype.remove=function(e){var t="$"+this.toStr(e),n=this.table[t];if(!r.isUndefined(n))return delete this.table[t],this.nElements--,n.value},e.prototype.keys=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.key)}return e},e.prototype.values=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.value)}return e},e.prototype.forEach=function(e){for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];if(!1===e(n.key,n.value))return}},e.prototype.containsKey=function(e){return!r.isUndefined(this.getValue(e))},e.prototype.clear=function(){this.table={},this.nElements=0},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){var e="{";return this.forEach((function(t,n){e+="\n\t"+t+" : "+n})),e+"\n}"},e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17),i=n(116),o=function(){function e(){this.firstNode=null,this.lastNode=null,this.nElements=0}return e.prototype.add=function(e,t){if(r.isUndefined(t)&&(t=this.nElements),t<0||t>this.nElements||r.isUndefined(e))return!1;var n=this.createNode(e);if(0===this.nElements||null===this.lastNode)this.firstNode=n,this.lastNode=n;else if(t===this.nElements)this.lastNode.next=n,this.lastNode=n;else if(0===t)n.next=this.firstNode,this.firstNode=n;else{var i=this.nodeAtIndex(t-1);if(null===i)return!1;n.next=i.next,i.next=n}return this.nElements++,!0},e.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},e.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},e.prototype.elementAtIndex=function(e){var t=this.nodeAtIndex(e);if(null!==t)return t.element},e.prototype.indexOf=function(e,t){var n=t||r.defaultEquals;if(r.isUndefined(e))return-1;for(var i=this.firstNode,o=0;null!==i;){if(n(i.element,e))return o;o++,i=i.next}return-1},e.prototype.contains=function(e,t){return this.indexOf(e,t)>=0},e.prototype.remove=function(e,t){var n=t||r.defaultEquals;if(this.nElements<1||r.isUndefined(e))return!1;for(var i=null,o=this.firstNode;null!==o;){if(n(o.element,e))return null===i?(this.firstNode=o.next,o===this.lastNode&&(this.lastNode=null)):o===this.lastNode?(this.lastNode=i,i.next=o.next,o.next=null):(i.next=o.next,o.next=null),this.nElements--,!0;i=o,o=o.next}return!1},e.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},e.prototype.equals=function(t,n){var i=n||r.defaultEquals;return t instanceof e&&(this.size()===t.size()&&this.equalsAux(this.firstNode,t.firstNode,i))},e.prototype.equalsAux=function(e,t,n){for(;null!==e&&null!==t;){if(!n(e.element,t.element))return!1;e=e.next,t=t.next}return!0},e.prototype.removeElementAtIndex=function(e){if(!(e<0||e>=this.nElements||null===this.firstNode||null===this.lastNode)){var t;if(1===this.nElements)t=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var n=this.nodeAtIndex(e-1);null===n?(t=this.firstNode.element,this.firstNode=this.firstNode.next):n.next===this.lastNode&&(t=this.lastNode.element,this.lastNode=n),null!==n&&null!==n.next&&(t=n.next.element,n.next=n.next.next)}return this.nElements--,t}},e.prototype.forEach=function(e){for(var t=this.firstNode;null!==t&&!1!==e(t.element);)t=t.next},e.prototype.reverse=function(){for(var e=null,t=this.firstNode,n=null;null!==t;)n=t.next,t.next=e,e=t,t=n;n=this.firstNode,this.firstNode=this.lastNode,this.lastNode=n},e.prototype.toArray=function(){for(var e=[],t=this.firstNode;null!==t;)e.push(t.element),t=t.next;return e},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){return i.toString(this.toArray())},e.prototype.nodeAtIndex=function(e){if(e<0||e>=this.nElements)return null;if(e===this.nElements-1)return this.lastNode;for(var t=this.firstNode,n=0;n<e&&null!==t;n++)t=t.next;return t},e.prototype.createNode=function(e){return{element:e,next:null}},e}();t.default=o},function(e,t){function n(e,t){if(!e)throw new Error(t||"AssertionError")}n.notEqual=function(e,t,r){n(e!=t,r)},n.notOk=function(e,t){n(!e,t)},n.equal=function(e,t,r){n(e==t,r)},n.ok=n,e.exports=n},function(e,t,n){"use strict";n.r(t);var r="URLSearchParams"in self,i="Symbol"in self&&"iterator"in Symbol,o="FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(e){return!1}}(),a="FormData"in self,c="ArrayBuffer"in self;if(c)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function f(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function b(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function _(e){var t=new FileReader,n=b(t);return t.readAsArrayBuffer(e),n}function E(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=E(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=E(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(_)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=b(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=f(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},d.prototype.delete=function(e){delete this.map[f(e)]},d.prototype.get=function(e){return e=f(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(f(e))},d.prototype.set=function(e,t){this.map[f(e)]=l(t)},d.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),h(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),h(e)},i&&(d.prototype[Symbol.iterator]=d.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(e,t){var n,r,i=(t=t||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),v.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function S(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},y.call(g.prototype),y.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:0,statusText:""});return e.type="error",e};var O=[301,302,303,307,308];S.redirect=function(e,t){if(-1===O.indexOf(t))throw new RangeError("Invalid status code");return new S(null,{status:t,headers:{location:e}})};var A=self.DOMException;try{new A}catch(e){(A=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),A.prototype.constructor=A}function T(e,t){return new Promise((function(n,r){var i=new g(e,t);if(i.signal&&i.signal.aborted)return r(new A("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new S(i,r))},a.onerror=function(){r(new TypeError("Network request failed"))},a.ontimeout=function(){r(new TypeError("Network request failed"))},a.onabort=function(){r(new A("Aborted","AbortError"))},a.open(i.method,i.url,!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),i.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),i.signal&&(i.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&i.signal.removeEventListener("abort",c)}),a.send(void 0===i._bodyInit?null:i._bodyInit)}))}T.polyfill=!0,self.fetch||(self.fetch=T,self.Headers=d,self.Request=g,self.Response=S);var N,M=function(){function e(){}return e.DATE_TYPE="DATE",e.TEXT_TYPE="TEXT",e.INT_TYPE="INTEGER",e.REAL_TYPE="REAL",e.COMMA_SEP=",",e.SPACE=" ",e.MAX_NUM_OF_EVENTS=1e3,e.MAX_NUM_OF_PROCESSED_EVENTS=1,e.ERROR="DB_ERROR",e.BLOB_TYPE="BLOB",e.NOT_NULL="NOT NULL",e.NULL="NULL",e}(),w=function(){function e(e,t){this.targetDbVersion=t,this.migrationNumber=e}return e.prototype.required=function(e,t){return e<this.targetDbVersion&&this.targetDbVersion<=t},e}(),C=function(){},I=n(2);!function(e){e[e.HTTP_UNAUTHORISED=401]="HTTP_UNAUTHORISED",e[e.HTTP_FORBIDDEN=403]="HTTP_FORBIDDEN",e[e.HTTP_SUCCESS=200]="HTTP_SUCCESS",e[e.HTTP_BAD_REQUEST=400]="HTTP_BAD_REQUEST"}(N||(N={}));var P,L,R,D=function(){function e(){}return Object.defineProperty(e.prototype,"responseCode",{get:function(){return this._responseCode},set:function(e){this._responseCode=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorMesg",{get:function(){return this._errorMesg},set:function(e){this._errorMesg=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},set:function(e){this._body=e},enumerable:!0,configurable:!0}),e}(),j=(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),U=function(e){function t(n,r){var i=e.call(this,n)||this;return i._code=r,Object.setPrototypeOf(i,t.prototype),i}return j(t,e),Object.defineProperty(t.prototype,"code",{get:function(){return this._code},enumerable:!0,configurable:!0}),t}(Error),k=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),x=function(e){function t(n){var r=e.call(this,n,"REQUEST_BUILD_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return k(t,e),t}(U);!function(e){e.JSON="json",e.URLENCODED="urlencoded",e.UTF8="utf8",e.RAW="raw"}(L||(L={})),function(e){e.GET="GET",e.POST="POST",e.PATCH="PATCH"}(R||(R={}));var B,F=function(){function e(){this._serializer=L.JSON,this._responseInterceptors=[],this._withApiToken=!1,this._authenticators=[],this._headers={},this._body={},this._parameters={},this._withSessionToken=!1,this._requestInterceptors=[]}return Object.defineProperty(e.prototype,"serializer",{get:function(){return this._serializer},set:function(e){this._serializer=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"withApiToken",{get:function(){return this._withApiToken},set:function(e){this._withApiToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},set:function(e){this._body=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._path},set:function(e){this._path=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responseInterceptors",{get:function(){return this._responseInterceptors},set:function(e){this._responseInterceptors=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){return this._headers},set:function(e){this._headers=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parameters",{get:function(){return this._parameters},set:function(e){this._parameters=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"withSessionToken",{get:function(){return this._withSessionToken},set:function(e){this._withSessionToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"requestInterceptors",{get:function(){return this._requestInterceptors},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authenticators",{get:function(){return this._authenticators},set:function(e){this._authenticators=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"host",{get:function(){return this._host},enumerable:!0,configurable:!0}),e.Builder=function(){function t(){this.request=new e}return t.prototype.withHost=function(e){return this.request._host=e,this},t.prototype.withPath=function(e){return this.request._path=e,this},t.prototype.withType=function(e){return this.request._type=e,this},t.prototype.withAuthenticator=function(e){return this.request._authenticators.push(e),this},t.prototype.withResponseInterceptor=function(e){return this.request._responseInterceptors.push(e),this},t.prototype.withRequestInterceptor=function(e){return this.request._requestInterceptors.push(e),this},t.prototype.withHeaders=function(e){return this.request._headers=e,this},t.prototype.withBody=function(e){return this.request._body=e,this},t.prototype.withParameters=function(e){return this.request._parameters=e,this},t.prototype.withApiToken=function(e){return this.request.withApiToken=e,this},t.prototype.withSessionToken=function(e){return this.request.withSessionToken=e,this},t.prototype.withSerializer=function(e){return this.request._serializer=e,this},t.prototype.build=function(){if(!this.request._path)throw new x("withPath() is required");if(!this.request._type)throw new x("withType() is required");return this.request},t}(),e}(),V=function(){},Y=n(62);!function(e){e.HS256="HS256"}(B||(B={}));var G,H,q,z,K,W,X,J,Q,$,Z,ee,te,ne,re=function(){function e(){}return e.createJWToken=function(e,t,n){return void 0===n&&(n=B.HS256),Y.sign(e,t,{algorithm:n})},e.getJWTPayload=function(e){return Y.decode(e,{json:!0})},e}(),ie=n(1),oe=function(){function e(){this.http=cordova.plugin.http}return e.prototype.setSerializer=function(e){this.http.setDataSerializer(e)},e.prototype.addHeaders=function(e){for(var t in e)e.hasOwnProperty(t)&&this.http.setHeader("*",t,e[t])},e.prototype.addHeader=function(e,t){this.http.setHeader("*",e,t)},e.prototype.get=function(e,t,n,r){return this.invokeRequest(R.GET,e+t,r,n)},e.prototype.patch=function(e,t,n,r){return this.invokeRequest(R.PATCH,e+t,r,n)},e.prototype.post=function(e,t,n,r){return this.invokeRequest(R.POST,e+t,r,n)},e.prototype.invokeRequest=function(e,t,n,r){var i=new ie.Subject;return this.http[e.toLowerCase()](t,n,r,(function(e){var t=new D;try{t.body=JSON.parse(e.data)}catch(n){t.body=e.data}t.responseCode=e.status,t.errorMesg="",i.next(t),i.complete()}),(function(e){var n=new D;if(0===e.status)return i.error(new Fe("\n "+t+" -\n "+(e.error||"")+"\n ")),void i.complete();try{n.body=JSON.parse(e.error),n.responseCode=e.status,n.errorMesg="SERVER_ERROR",n.responseCode===N.HTTP_UNAUTHORISED||n.responseCode===N.HTTP_FORBIDDEN?(i.next(n),i.complete()):n.responseCode>=400&&n.responseCode<=499?i.error(new De("\n "+t+" -\n "+(e.error||"")+"\n ",n)):i.error(new Le("\n "+t+" -\n "+(e.error||"")+"\n ",n))}catch(n){i.error(new Fe("\n "+t+" -\n "+(e.error||"")+"\n ")),i.complete()}})),i},e}(),ae=n(14),ce=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},se=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ue=function(){function e(e,t,n,r,i,o){this.http=e,this.apiConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.defaultApiAuthenticators=i,this.defaultSessionAuthenticators=o,this.addGlobalHeader()}return e.prototype.invoke=function(e){var t=this;this.buildInterceptorsFromAuthenticators(e);var n=ce(t,void 0,void 0,(function(){return se(this,(function(t){switch(t.label){case 0:return[4,this.interceptRequest(e)];case 1:switch((e=t.sent()).type){case R.GET:return[3,2];case R.PATCH:return[3,4];case R.POST:return[3,6]}return[3,8];case 2:return[4,this.http.get(e.host||this.apiConfig.host,e.path,e.headers,e.parameters).toPromise()];case 3:return n=t.sent(),[3,8];case 4:return[4,this.http.patch(e.host||this.apiConfig.host,e.path,e.headers,e.body).toPromise()];case 5:return n=t.sent(),[3,8];case 6:return[4,this.http.post(e.host||this.apiConfig.host,e.path,e.headers,e.body).toPromise()];case 7:return n=t.sent(),[3,8];case 8:return[4,this.interceptResponse(e,n)];case 9:return[2,n=t.sent()]}}))}));return Object(ie.from)(n)},e.prototype.addGlobalHeader=function(){var e={"X-Channel-Id":this.apiConfig.api_authentication.channelId,"X-App-Id":this.apiConfig.api_authentication.producerId,"X-Device-Id":this.deviceInfo.getDeviceID(),Accept:"application/json","Content-Type":"application/json","Access-Control-Allow-Origin":"*"};this.http.addHeaders(e)},e.prototype.buildInterceptorsFromAuthenticators=function(e){if(e.withApiToken)for(var t=0,n=this.defaultApiAuthenticators;t<n.length;t++){var r=n[t];e.authenticators.push(r)}if(e.withSessionToken)for(var i=0,o=this.defaultSessionAuthenticators;i<o.length;i++){r=o[i];e.authenticators.push(r)}e.authenticators.forEach((function(t){e.requestInterceptors.push(t),e.responseInterceptors.push(t)})),this.http.setSerializer(e.serializer)===L.URLENCODED&&(e.body=ae.stringify(e.body)),this.http.setSerializer(e.serializer)},e.prototype.interceptRequest=function(e){return ce(this,void 0,void 0,(function(){var t,n,r;return se(this,(function(i){switch(i.label){case 0:t=e.requestInterceptors,n=0,r=t,i.label=1;case 1:return n<r.length?[4,r[n].interceptRequest(e).toPromise()]:[3,4];case 2:e=i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},e.prototype.interceptResponse=function(e,t){return ce(this,void 0,void 0,(function(){var n,r,i;return se(this,(function(o){switch(o.label){case 0:n=e.responseInterceptors,r=0,i=n,o.label=1;case 1:return r<i.length?[4,i[r].interceptResponse(e,t).toPromise()]:[3,4];case 2:t=o.sent(),o.label=3;case 3:return r++,[3,1];case 4:if(t.responseCode!==N.HTTP_SUCCESS)throw t;return[2,t]}}))}))},e}(),fe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},le=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},he=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},de=function(){function e(){this.headers={}}return e.mapError=function(e,t){return le(this,void 0,void 0,(function(){return he(this,(function(n){if(t instanceof Le||t instanceof Fe)throw t;throw new Fe("\n "+e+" -\n "+(t||"")+"\n ")}))}))},e.mapResponse=function(e){return le(this,void 0,void 0,(function(){var t,n;return he(this,(function(r){switch(r.label){case 0:return(t=new D).responseCode=e.status,n=t,[4,e.json()];case 1:if(n.body=r.sent(),"object"!=typeof t.body)throw new Fe("\n "+e.url+" -\n "+(t.body||"")+"\n ");if(e.ok)return[2,t];if(t.errorMesg="SERVER_ERROR",e.status===N.HTTP_UNAUTHORISED||e.status===N.HTTP_FORBIDDEN)return[2,t];throw new Le("\n "+e.url+"\n ",t)}}))}))},e.prototype.setSerializer=function(e){this.serializer=e},e.prototype.addHeader=function(e,t){this.headers[e]=t},e.prototype.addHeaders=function(e){this.headers=fe({},this.headers,e)},e.prototype.get=function(t,n,r,i){var o=new URL(t+n);return"object"==typeof i&&Object.keys(i).forEach((function(e){o.searchParams.append(e,i[e])})),Object(ie.from)(window.fetch(o.toString(),{method:"GET",headers:new Headers(fe({},this.headers,r))}).then(e.mapResponse).catch((function(t){return e.mapError(o.toString(),t)})))},e.prototype.patch=function(t,n,r,i){var o=new URL(t+n);return this.serializer===L.URLENCODED&&"object"==typeof i?(this.addHeader("content-type","application/x-www-form-urlencoded"),i=ae.stringify(i)):"object"==typeof i&&(this.addHeader("content-type","application/x-www-form-urlencoded"),i=JSON.stringify(i)),Object(ie.from)(window.fetch(o.toString(),{method:"PATCH",headers:new Headers(fe({},this.headers,r)),body:i}).then(e.mapResponse).catch((function(t){return e.mapError(o.toString(),t)})))},e.prototype.post=function(t,n,r,i){var o=new URL(t+n);return this.serializer===L.URLENCODED&&"object"==typeof i?(this.addHeader("content-type","application/x-www-form-urlencoded"),i=ae.stringify(i)):"object"==typeof i&&(this.addHeader("content-type","application/x-www-form-urlencoded"),i=JSON.stringify(i)),Object(ie.from)(window.fetch(o.toString(),{method:"POST",headers:new Headers(fe({},this.headers,r)),body:i}).then(e.mapResponse).catch((function(t){return e.mapError(o.toString(),t)})))},e}(),pe=function(){function e(e,t,n,r,i,o){var a;switch(this.request=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.defaultApiAuthenticators=i,this.defaultSessionAuthenticators=o,t.platform){case"cordova":a=new oe;break;case"web":a=new de;break;default:throw new Error("FATAL_ERROR: Invalid platform")}this.baseConnection=new ue(a,this.sdkConfig.apiConfig,this.deviceInfo,this.sharedPreferences,this.defaultApiAuthenticators,this.defaultSessionAuthenticators)}return e.prototype.doFetch=function(){return this.baseConnection.invoke(this.request)},e}(),be={CONTAINER:Symbol.for("CONTAINER"),DB_VERSION:Symbol.for("DB_VERSION"),DB_MIGRATION_LIST:Symbol.for("DB_MIGRATION_LIST"),SDK_CONFIG:Symbol.for("SDK_CONFIG"),DEVICE_INFO:Symbol.for("DEVICE_INFO"),SHARED_PREFERENCES:Symbol.for("SHARED_PREFERENCES"),EVENTS_BUS_SERVICE:Symbol.for("EVENTS_BUS_SERVICE"),DB_SERVICE:Symbol.for("DB_SERVICE"),APP_INFO:Symbol.for("APP_INFO"),API_SERVICE:Symbol.for("API_SERVICE"),AUTH_SERVICE:Symbol.for("AUTH_SERVICE"),FILE_SERVICE:Symbol.for("FILE_SERVICE"),SYSTEM_SETTINGS_SERVICE:Symbol.for("SYSTEM_SETTINGS_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("FRAMEWORK_SERVICE"),PROFILE_SERVICE:Symbol.for("PROFILE_SERVICE"),GROUP_SERVICE:Symbol.for("GROUP_SERVICE"),ZIP_SERVICE:Symbol.for("ZIP_SERVICE"),TELEMETRY_SERVICE:Symbol.for("TELEMETRY_SERVICE"),CONTENT_FEEDBACK_SERVICE:Symbol.for("CONTENT_FEEDBACK_SERVICE"),FORM_SERVICE:Symbol.for("FORM_SERVICE"),PAGE_ASSEMBLE_SERVICE:Symbol.for("PAGE_ASSEMBLE_SERVICE"),FRAMEWORK_UTIL_SERVICE:Symbol.for("FRAMEWORK_UTIL_SERVICE"),DOWNLOAD_SERVICE:Symbol.for("DOWNLOAD_SERVICE"),CONTENT_SERVICE:Symbol.for("CONTENT_SERVICE"),COURSE_SERVICE:Symbol.for("COURSE_SERVICE"),SUMMARIZER_SERVICE:Symbol.for("SUMMARIZER_SERVICE"),PLAYER_SERVICE:Symbol.for("PLAYER_SERVICE"),CACHED_ITEM_STORE:Symbol.for("CACHED_ITEM_STORE"),KEY_VALUE_STORE:Symbol.for("KEY_VALUE_STORE"),TELEMETRY_DECORATOR:Symbol.for("TELEMETRY_DECORATOR"),STORAGE_SERVICE:Symbol.for("STORAGE_SERVICE"),NOTIFICATION_SERVICE:Symbol.for("NOTIFICATION_SERVICE"),ERROR_LOGGER_SERVICE:Symbol.for("ERROR_LOGGER_SERVICE"),NETWORKINFO_SERVICE:Symbol.for("NETWORKINFO_SERVICE"),SEARCH_HISTORY_SERVICE:Symbol.for("SEARCH_HISTORY_SERVICE"),CODEPUSH_EXPERIMENT_SERVICE:Symbol.for("CODEPUSH_EXPERIMENT_SERVICE"),FAQ_SERVICE:Symbol.for("FAQ_SERVICE"),DEVICE_REGISTER_SERVICE:Symbol.for("DEVICE_REGISTER_SERVICE"),CONTENT_RATING_SERVICE:Symbol.for("CONTENT_RATING_SERVICE"),ARCHIVE_SERVICE:Symbol.for("ARCHIVE_SERVICE")};!function(e){e.KEY_FIRST_ACCESS_TIMESTAMP="first_access_timestamp"}(G||(G={})),function(e){e.KEY_API_TOKEN="api_bearer_token"}(H||(H={})),function(e){e.KEY_OAUTH_SESSION="oauth_token"}(q||(q={})),function(e){e.KEY_GROUP_SESSION="group_session"}(z||(z={})),function(e){e.KEY_USER_SESSION="session"}(K||(K={})),function(e){e.KEY_ACTIVE_CHANNEL_ID="channelId",e.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID="sunbirdcurrent_framework_id"}(W||(W={})),function(e){e.KEY_TO_DOWNLOAD_LIST="to_download_list"}(X||(X={})),function(e){e.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL="is_update_size_on_device_successful",e.KEY_CONTENT_DELETE_REQUEST_LIST="content_delete_request_list",e.KEY_LAST_MODIFIED="last_modified",e.UPDATE_CONTENT_STATE="update_content_state",e.COURSE_CONTEXT="sunbirdcontent_context"}(J||(J={})),function(e){e.KEY_STORAGE_DESTINATION="storage_destination",e.KEY_TO_TRANSFER_LIST="to_transfer_list"}(Q||(Q={})),function(e){e.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP="error_log_last_synced_time_stamp"}($||($={})),function(e){e.DEPLOYMENT_KEY="deployment_key"}(Z||(Z={})),function(e){e.DEFAULT_DEPLOYMENT_KEY="default_deployment_key",e.EXPERIMENT_KEY="experiment_key",e.EXPERIMENT_APP_VERSION="emperiment_app_version"}(ee||(ee={})),function(e){e.DEVICE_LOCATION="device_location_new"}(te||(te={})),function(e){e.KEY_LAST_SYNCED_TIME_STAMP="telemetry_last_synced_time_stamp",e.KEY_AUTO_SYNC_MODE="telemetry_auto_sync_mode"}(ne||(ne={}));var _e,Ee,ye=n(8),ve=n.n(ye),ge=n(0),me=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Se=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Oe=function(){function e(e,t,n){this.config=e,this.apiService=t,this.deviceInfo=n}return e.prototype.refreshAuthToken=function(){var e=this;return Object(ie.from)(this.getMobileDeviceConsumerSecret()).pipe(Object(ge.map)((function(t){return re.createJWToken({iss:e.getMobileDeviceConsumerKey()},t,B.HS256)})))},e.prototype.getMobileDeviceConsumerKey=function(){return this.config.api_authentication.producerId+"-"+this.deviceInfo.getDeviceID()},e.prototype.buildGetMobileDeviceConsumerSecretAPIRequest=function(){return(new F.Builder).withPath("/api/api-manager/v1/consumer/"+this.config.api_authentication.mobileAppConsumer+"/credential/register").withType(R.POST).withHeaders({"Content-Encoding":"gzip",Authorization:"Bearer "+this.generateMobileAppConsumerBearerToken()}).withBody({id:e.ID,ver:e.VERSION,ts:ye().format(),request:{key:this.getMobileDeviceConsumerKey()}}).build()},e.prototype.getMobileDeviceConsumerSecret=function(){return me(this,void 0,void 0,(function(){return Se(this,(function(e){return[2,this.apiService.fetch(this.buildGetMobileDeviceConsumerSecretAPIRequest()).toPromise().then((function(e){return e.body.result.secret}))]}))}))},e.prototype.generateMobileAppConsumerBearerToken=function(){var e=this.config.api_authentication.mobileAppKey,t=this.config.api_authentication.mobileAppSecret;return re.createJWToken({iss:e},t,B.HS256)},e.VERSION="1.0",e.ID="ekstep.genie.device.register",e}();!function(e){e.AUTH="AUTH",e.TELEMETRY="TELEMETRY",e.DOWNLOADS="DOWNLOADS",e.CONTENT="CONTENT",e.ERROR="ERROR",e.STORAGE="STORAGE"}(_e||(_e={})),function(e){e.HTTP_SERVER_ERROR="HTTP_SERVER_ERROR",e.HTTP_CLIENT_ERROR="HTTP_CLIENT_ERROR",e.AUTH_TOKEN_REFRESH_ERROR="AUTH_TOKEN_REFRESH_ERROR"}(Ee||(Ee={}));var Ae,Te,Ne,Me,we,Ce,Ie,Pe=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Le=function(e){function t(n,r){var i=e.call(this,n,"HTTP_SERVER_ERROR")||this;return i.response=r,Object.setPrototypeOf(i,t.prototype),i}return Pe(t,e),t}(U),Re=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),De=function(e){function t(n,r){var i=e.call(this,n,"HTTP_CLIENT_ERROR")||this;return i.response=r,Object.setPrototypeOf(i,t.prototype),i}return Re(t,e),t}(U),je=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Ue=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ke=function(e,t){return function(n,r){t(n,r,e)}},xe=function(){function e(e,t,n,r){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.eventsBusService=r,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.onInit=function(){var e=this;return this.sharedPreferences.getString(H.KEY_API_TOKEN).pipe(Object(ge.mergeMap)((function(t){return t?Object(ie.of)(void 0):new Oe(e.apiConfig,e,e.deviceInfo).refreshAuthToken().pipe(Object(ge.mergeMap)((function(t){return e.sharedPreferences.putString(H.KEY_API_TOKEN,t)})),Object(ge.catchError)((function(){return Object(ie.of)(void 0)})))})))},e.prototype.fetch=function(e){var t=this;return new pe(e,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.defaultApiAuthenticators,this.defaultSessionAuthenticators).doFetch().pipe(Object(ge.catchError)((function(e){return e instanceof Le?t.eventsBusService.emit({namespace:_e.ERROR,event:{type:Ee.HTTP_SERVER_ERROR,payload:e}}):e instanceof De&&t.eventsBusService.emit({namespace:_e.ERROR,event:{type:Ee.HTTP_CLIENT_ERROR,payload:e}}),Object(ie.throwError)(e)})))},e.prototype.setDefaultApiAuthenticators=function(e){this.defaultApiAuthenticators=e},e.prototype.setDefaultSessionAuthenticators=function(e){this.defaultSessionAuthenticators=e},e=je([Object(I.injectable)(),ke(0,Object(I.inject)(be.SDK_CONFIG)),ke(1,Object(I.inject)(be.DEVICE_INFO)),ke(2,Object(I.inject)(be.SHARED_PREFERENCES)),ke(3,Object(I.inject)(be.EVENTS_BUS_SERVICE)),Ue("design:paramtypes",[Object,Object,Object,Object])],e)}(),Be=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Fe=function(e){function t(n){var r=e.call(this,n,"NETWORK_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return Be(t,e),t}(U),Ve=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ye=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ge=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},He=function(){function e(e,t,n,r,i,o,a){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=a,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.handle=function(e){return this.registerDevice(e)},e.prototype.registerDevice=function(t){var n=this;return Object(ie.zip)(this.deviceInfo.getDeviceSpec(),this.frameworkService.getActiveChannelId(),this.appInfoService.getFirstAccessTimestamp(),this.sharedPreferences.getString(te.DEVICE_LOCATION)).pipe(Object(ge.mergeMap)((function(r){return Ye(n,void 0,void 0,(function(){var n,i,o,a,c,s,u,f=this;return Ge(this,(function(l){switch(l.label){case 0:if(n=r[0],i=r[1],o=r[2],a=r[3],(t=Ve({},t||{},{dspec:n,channel:i,fcmToken:this.deviceRegisterConfig.fcmToken,producer:this.apiConfig.api_authentication.producerId,first_access:Number(o)})).userDeclaredLocation||!a)return[3,4];if(t.userDeclaredLocation=JSON.parse(a),t.userDeclaredLocation.declaredOffline)return[3,4];l.label=1;case 1:return l.trys.push([1,3,,4]),[4,this.getDeviceProfileHandler.handle().toPromise()];case 2:return(c=l.sent()).userDeclaredLocation&&c.userDeclaredLocation.state&&c.userDeclaredLocation.district||(delete t.userDeclaredLocation,this.sharedPreferences.putString(te.DEVICE_LOCATION,"").toPromise()),[3,4];case 3:return s=l.sent(),console.error(s),delete t.userDeclaredLocation,[3,4];case 4:return t.userDeclaredLocation&&delete t.userDeclaredLocation.declaredOffline,u=(new F.Builder).withType(R.POST).withPath(this.deviceRegisterConfig.apiPath+e.DEVICE_REGISTER_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withApiToken(!0).withBody({request:t}).build(),[2,this.apiService.fetch(u).pipe(Object(ge.map)((function(e){return e.body})),Object(ge.tap)((function(){t.userDeclaredLocation&&f.sharedPreferences.putString(te.DEVICE_LOCATION,JSON.stringify(t.userDeclaredLocation)).toPromise()}))).toPromise()]}}))}))})))},e.DEVICE_REGISTER_ENDPOINT="/register",e}(),qe=function(){function e(e,t,n){this.sdkConfig=e,this.deviceInfo=t,this.apiService=n,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.handle=function(){return this.fetchFromServer()},e.prototype.fetchFromServer=function(){return this.apiService.fetch((new F.Builder).withType(R.GET).withPath(this.deviceRegisterConfig.apiPath+e.GET_DEVICE_PROFILE_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withApiToken(!0).build()).pipe(Object(ge.map)((function(e){return e.body.result})))},e.GET_DEVICE_PROFILE_ENDPOINT="/profile",e}(),ze=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Ke=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},We=function(e,t){return function(n,r){t(n,r,e)}},Xe=function(){function e(e,t,n,r,i,o){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=new qe(this.sdkConfig,this.deviceInfo,this.apiService),this.deviceRegisterHandler=new He(this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.frameworkService,this.appInfoService,this.apiService,this.getDeviceProfileHandler)}return e.prototype.registerDevice=function(e){return this.deviceRegisterHandler.handle(e)},e.prototype.getDeviceProfile=function(){return this.getDeviceProfileHandler.handle()},e=ze([Object(I.injectable)(),We(0,Object(I.inject)(be.SDK_CONFIG)),We(1,Object(I.inject)(be.DEVICE_INFO)),We(2,Object(I.inject)(be.SHARED_PREFERENCES)),We(3,Object(I.inject)(be.FRAMEWORK_SERVICE)),We(4,Object(I.inject)(be.APP_INFO)),We(5,Object(I.inject)(be.API_SERVICE)),Ke("design:paramtypes",[Object,Object,Object,Object,Object,Object])],e)}(),Je=function(){};!function(e){e.NOTIFICATION="notification",e.USER="User",e.GROUP="Group",e.CONTENT="Content",e.QUESTION="Question"}(Ae||(Ae={})),function(e){e.PLAY="play"}(Te||(Te={})),function(e){e.NOTIFICATION="notification"}(Ne||(Ne={})),function(e){e.TRACE="TRACE",e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL"}(Me||(Me={})),function(e){e.IN="In",e.OUT="Out"}(we||(we={})),function(e){e.FILE="File",e.MESSAGE="Message",e.LINK="Link"}(Ce||(Ce={})),function(e){e.CONTENT="CONTENT",e.EXPLODEDCONTENT="EXPLODEDCONTENT",e.TELEMETRY="TELEMETRY",e.PROFILE="PROFILE"}(Ie||(Ie={}));var Qe,$e,Ze,et,tt=function(){this.RECEIVED="Received",this.DISPLAYED="Displayed"};!function(e){e.TOUCH="TOUCH",e.OTHER="OTHER"}(Qe||(Qe={})),function(e){e.NETWORK_SPEED="network-speed",e.SUBTYPE_SPINE="spine",e.ONLINE="online",e.FULL="full",e.CONTENT_VARIANT="content-variant-download",e.DEVICE_TIME_OFFSET_FOUND="device-time-offset-found",e.CONTENT_DOWNLOAD_INITIATE="ContentDownload-Initiate",e.CONTENT_DOWNLOAD_SUCCESS="ContentDownload-Success",e.CONTENT_DOWNLOAD_CANCEL="ContentDownload-Cancel"}($e||($e={})),function(e){e.ERR_DOWNLOAD_FAILED="ERR_DOWNLOAD_FAILED"}(Ze||(Ze={})),function(e){e.SYSTEM="SYSTEM"}(et||(et={}));var nt,rt,it=function(){function e(){}return e.toFixed=function(e){return Number(e.toFixed(2))},e.parseInt=function(e){return e?parseInt(e,10):0},e.round=function(e){return Number(Math.round(parseFloat(e+"e4"))+"e-4")},e}(),ot=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),at=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ct=function(){function e(){this.type=e.TYPE_USER}return e.TYPE_SYSTEM="System",e.TYPE_USER="User",e}(),st=function(){},ut=function(){this.os="",this.make="",this.id="",this.mem=-1,this.idisk=-1,this.edisk=-1,this.scrn=-1,this.cpu="",this.sims=-1,this.cap=[]},ft=function(){},lt=function(){},ht=function(){},dt=function(){},pt=function(){},bt=function(){},_t=function(){function e(){}return e.prototype.ProducerData=function(){this.id="",this.pid="",this.ver=""},e}(),Et=function(){},yt=function(){function e(e,t,n){this.id=e,this.type=t,this.version=n}return e.prototype.setRollup=function(e){this.rollup=e},e}(),vt=function(){};!function(e){e.AUDIT_CREATED="Created",e.AUDIT_UPDATED="Updated",e.AUDIT_DELETED="Deleted"}(nt||(nt={})),function(e){var t=function(){function e(t){this.ver=e.TELEMETRY_VERSION,this.eid=t,this.ets=Date.now(),this.actor=new ct,this.context=new st,this.edata={}}return e.TELEMETRY_VERSION="3.0",e}();e.Telemetry=t;var n=function(e){function t(n,r,i,o,a,c,s,u,f,l,h){void 0===s&&(s=""),void 0===u&&(u=""),void 0===f&&(f=""),void 0===l&&(l={}),void 0===h&&(h=[]);var d=e.call(this,t.EID)||this;return d.edata=at({},n?{type:n}:{},i?{duration:i}:{},o?{pageid:o}:{},r?{mode:r}:{},a?{summaryList:a}:{}),d.context.cdata=h,d.context.env=c,d.object=new yt(s,u,f),d.object.rollup=l,d}return ot(t,e),t.EID="END",t}(t);e.End=n;var r=function(e){function t(n,r,i,o,a,c,s,u,f,l,h,d){void 0===n&&(n=""),void 0===u&&(u=""),void 0===f&&(f=""),void 0===l&&(l=""),void 0===h&&(h={}),void 0===d&&(d=[]);var p=e.call(this,t.EID)||this;return p.edata=at({},n?{type:n}:{type:""},r?{dspec:r}:{},i?{loc:i}:{},o?{mode:o}:{},a?{mode:o}:{},c?{pageid:c}:{}),p.context.cdata=d,p.context.env=s,p.object=new yt(u,f,l),p.object.rollup=h||{},p}return ot(t,e),t.EID="START",t}(t);e.Start=r;var i=function(e){function t(n,r,i,o,a,c,s,u,f,l,h,d){void 0===u&&(u=""),void 0===f&&(f=""),void 0===l&&(l=""),void 0===h&&(h={}),void 0===d&&(d=[]);var p=e.call(this,t.EID)||this;return p.edata=at({type:n},{subtype:r},i?{id:i}:{},o?{pageid:o}:{},{extra:at({},a?{pos:a}:{},c?{values:[c]}:{})}),p.context.cdata=d,p.context.env=s,p.object=new yt(u,f,l),p.object.rollup=h||{},p}return ot(t,e),t.EID="INTERACT",t}(t);e.Interact=i;var o=function(e){function t(n,r,i,o,a,c,s,u,f,l){void 0===c&&(c=""),void 0===s&&(s=""),void 0===u&&(u=""),void 0===f&&(f={}),void 0===l&&(l=[]);var h=e.call(this,t.EID)||this;return h.edata=at({},n?{type:n}:{type:""},r?{subtype:r}:{},i?{pageid:i}:{},i?{uri:i}:{},o?{visits:o}:{}),h.context.cdata=l,h.context.env=a,h.object=new yt(c||"",s||"",u||""),h.object.rollup=f||{},h}return ot(t,e),t.EID="IMPRESSION",t}(t);e.Impression=o;var a=function(e){function t(n,r,i,o,a,c,s){var u=e.call(this,t.EID)||this;u.edata=at({},n?{type:n}:{type:""},r?{level:r}:{},i?{message:i}:{},o?{pageid:o}:{},a?{params:a}:{}),u.context.env=c;var f=new ct;return f.type=s,u.actor=f,u}return ot(t,e),t.EID="LOG",t}(t);e.Log=a;var c=function(e){function t(n,r,i,o){var a=e.call(this,t.EID)||this;return a.edata=at({},n?{err:n}:{},r?{errtype:r}:{},i?{stacktrace:i}:{},o?{pageid:o}:{}),a}return ot(t,e),t.EID="ERROR",t}(t);e.Error=c;var s=function(e){function t(n,r){var i=e.call(this,t.EID)||this;return i.edata=at({type:n},r?{pageid:r}:{}),i}return ot(t,e),t.EID="INTERRUPT",t}(t);e.Interrupt=s;var u=function(e){function t(n,r,i,o,a,c,s,u){void 0===o&&(o=[]),void 0===a&&(a=""),void 0===c&&(c=""),void 0===s&&(s=""),void 0===u&&(u=new pt);var f=e.call(this,t.EID)||this;return f.edata=at({},n?{dir:n}:{},r?{type:r}:{},i?{items:i}:{}),f.context.cdata=o,f.object=new yt(a||"",c||"",s||""),f.object.rollup=u,f}return ot(t,e),t.prototype.addItem=function(e,t,n,r,i,o){var a={};if(a.origin=t,a.id=n,a.type=this.capitalize(e.valueOf()),e.valueOf()===Ie.CONTENT.valueOf()||e.valueOf()===Ie.EXPLODEDCONTENT.valueOf()){a.ver=r.toString();var c=[],s={};s.transfers=it.parseInt(i),s.size=o,c.push(s),a.params=c}var u={};u.id=t,u.type="Device",a.origin=u,this.edata.items.push(a)},t.prototype.capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},t.EID="SHARE",t}(t);e.Share=u;var f=function(e){function t(n,r,i,o,a,c,s,u){void 0===o&&(o=""),void 0===a&&(a=""),void 0===c&&(c="");var f=e.call(this,t.EID)||this;return f.edata=at({},n?{rating:n}:{},s?{commentid:s}:{},u?{commenttxt:u}:{},r?{comments:r}:{}),f.context.env=i,f.object=new yt(o,a,c),f.object.rollup={},f}return ot(t,e),t.EID="FEEDBACK",t}(t);e.Feedback=f;var l=function(e){function t(n,r,i,o,a,c,s,u){void 0===a&&(a=""),void 0===c&&(c=""),void 0===s&&(s=""),void 0===u&&(u=[]);var f=e.call(this,t.EID)||this;return f.edata=at({state:i},o?{props:o}:{}),f.context.cdata=u,f.context.env=n,f.object=new yt(a,c,s),f.object.rollup={},f.actor=r,f}return ot(t,e),t.EID="AUDIT",t}(t);e.Audit=l}(rt||(rt={}));var gt,mt,St,Ot,At,Tt,Nt,Mt,wt,Ct,It,Pt,Lt,Rt,Dt,jt,Ut,kt,xt,Bt,Ft,Vt,Yt,Gt,Ht,qt,zt,Kt,Wt,Xt,Jt,Qt,$t,Zt,en,tn,nn,rn,on,an,cn,sn,un,fn,ln,hn,dn=function(){this.pos=[]},pn=function(){},bn=function(){},_n=function(){},En=function(){},yn=function(){},vn=function(){},gn=function(){},mn=function(){this.items=[]},Sn=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),On=function(e){function t(n,r){var i=e.call(this,n+r)||this;return i.errorCode=n,i.errorType=r,Object.setPrototypeOf(i,t.prototype),i}return Sn(t,e),t}(Error),An=function(e,t){var n=e.value;return e.value=function(){n.apply(this,arguments),t()},e},Tn=function(e,t){var n=e.value;return e.value=function(){t(),n.apply(this,arguments)},e},Nn=function(e,t){var n=e.value;return e.value=function(){n.apply(this,arguments).then((function(e){return t(),Promise.resolve(e)}))},e};(mt=gt||(gt={}))._ID="_id",mt.TABLE_NAME="telemetry",mt.COLUMN_NAME_EVENT_TYPE="event_type",mt.COLUMN_NAME_EVENT="event",mt.COLUMN_NAME_TIMESTAMP="timestamp",mt.COLUMN_NAME_PRIORITY="priority",mt.getCreateEntry=function(){return"CREATE TABLE "+mt.TABLE_NAME+" ("+mt._ID+M.SPACE+" INTEGER PRIMARY KEY,"+mt.COLUMN_NAME_EVENT_TYPE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+mt.COLUMN_NAME_EVENT+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+mt.COLUMN_NAME_TIMESTAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+mt.COLUMN_NAME_PRIORITY+M.SPACE+M.INT_TYPE+" )"},mt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+mt.TABLE_NAME},(Ot=St||(St={}))._ID="_id",Ot.TABLE_NAME="processed_telemetry",Ot.COLUMN_NAME_MSG_ID="msg_id",Ot.COLUMN_NAME_DATA="data",Ot.COLUMN_NAME_NUMBER_OF_EVENTS="event_count",Ot.COLUMN_NAME_PRIORITY="priority",Ot.getCreateEntry=function(){return"CREATE TABLE "+Ot.TABLE_NAME+" ("+Ot._ID+" INTEGER PRIMARY KEY,"+Ot.COLUMN_NAME_MSG_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Ot.COLUMN_NAME_DATA+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Ot.COLUMN_NAME_NUMBER_OF_EVENTS+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Ot.COLUMN_NAME_PRIORITY+M.SPACE+M.INT_TYPE+" )"},Ot.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Ot.TABLE_NAME},(Tt=At||(At={}))._ID="_id",Tt.TABLE_NAME="event_priority",Tt.COLUMN_NAME_EVENT="event",Tt.COLUMN_NAME_PRIORITY="priority",Tt.getCreateEntry=function(){return"CREATE TABLE "+Tt.TABLE_NAME+" ("+Tt._ID+" INTEGER PRIMARY KEY,"+Tt.COLUMN_NAME_EVENT+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Tt.COLUMN_NAME_PRIORITY+M.SPACE+M.INT_TYPE+" )"},Tt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Tt.TABLE_NAME},(Mt=Nt||(Nt={}))._ID="_id",Mt.TABLE_NAME="telemetry_tags",Mt.COLUMN_NAME_NAME="name",Mt.COLUMN_NAME_HASH="hash",Mt.COLUMN_NAME_DESCRIPTION="description",Mt.COLUMN_NAME_START_DATE="start_date",Mt.COLUMN_NAME_END_DATE="end_date",Mt.getCreateEntry=function(){return"CREATE TABLE "+Mt.TABLE_NAME+" ("+Mt._ID+" INTEGER PRIMARY KEY,"+Mt.COLUMN_NAME_NAME+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Mt.COLUMN_NAME_HASH+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Mt.COLUMN_NAME_DESCRIPTION+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Mt.COLUMN_NAME_START_DATE+M.SPACE+M.DATE_TYPE+M.COMMA_SEP+Mt.COLUMN_NAME_END_DATE+M.SPACE+M.DATE_TYPE+" )"},Mt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Mt.TABLE_NAME},(Ct=wt||(wt={}))._ID="_id",Ct.TABLE_NAME="meta_data",Ct.COLUMN_NAME_MSG_ID="key",Ct.COLUMN_NAME_DATA="value",Ct.getCreateEntry=function(){return"CREATE TABLE "+Ct.TABLE_NAME+" ("+Ct._ID+" INTEGER PRIMARY KEY,"+Ct.COLUMN_NAME_MSG_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Ct.COLUMN_NAME_DATA+M.SPACE+M.TEXT_TYPE+" )"},Ct.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Ct.TABLE_NAME},(Pt=It||(It={}))._ID="_id",Pt.TABLE_NAME="profiles",Pt.COLUMN_NAME_UID="uid",Pt.COLUMN_NAME_HANDLE="handle",Pt.COLUMN_NAME_AVATAR="avatar",Pt.COLUMN_NAME_AGE="age",Pt.COLUMN_NAME_GENDER="gender",Pt.COLUMN_NAME_STANDARD="standard",Pt.COLUMN_NAME_LANGUAGE="language",Pt.COLUMN_NAME_DAY="day",Pt.COLUMN_NAME_MONTH="month",Pt.COLUMN_NAME_IS_GROUP_USER="is_group_user",Pt.COLUMN_NAME_CREATED_AT="created_at",Pt.COLUMN_NAME_MEDIUM="medium",Pt.COLUMN_NAME_BOARD="board",Pt.COLUMN_NAME_PROFILE_IMAGE="profile_image",Pt.COLUMN_NAME_SUBJECT="subject",Pt.COLUMN_NAME_PROFILE_TYPE="profile_type",Pt.COLUMN_NAME_GRADE="grade",Pt.COLUMN_NAME_SYLLABUS="syllabus",Pt.COLUMN_NAME_SOURCE="source",Pt.COLUMN_NAME_GRADE_VALUE="grade_value",Pt.COLUMN_VALUE="value",Pt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Pt.TABLE_NAME+"("+Pt._ID+M.SPACE+"INTEGER PRIMARY KEY,"+Pt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" UNIQUE NOT NULL"+M.COMMA_SEP+Pt.COLUMN_NAME_HANDLE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_AVATAR+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_AGE+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_GENDER+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_STANDARD+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_LANGUAGE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_DAY+M.SPACE+M.INT_TYPE+" NOT NULL DEFAULT -1"+M.COMMA_SEP+Pt.COLUMN_NAME_MONTH+M.SPACE+M.INT_TYPE+" NOT NULL DEFAULT -1"+M.COMMA_SEP+Pt.COLUMN_NAME_IS_GROUP_USER+M.SPACE+M.INT_TYPE+" NOT NULL DEFAULT 0"+M.COMMA_SEP+Pt.COLUMN_NAME_CREATED_AT+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_MEDIUM+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_BOARD+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_SUBJECT+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_PROFILE_IMAGE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_PROFILE_TYPE+M.SPACE+M.TEXT_TYPE+' DEFAULT "teacher"'+M.COMMA_SEP+Pt.COLUMN_NAME_GRADE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_SYLLABUS+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_NAME_SOURCE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Pt.COLUMN_VALUE+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+Pt.COLUMN_NAME_GRADE_VALUE+M.SPACE+M.TEXT_TYPE+")"},Pt.deleteTable=function(){return"DROP TABLE IF EXISTS "+Pt.TABLE_NAME},Pt.getAlterEntryForProfileSyllabus=function(){return"ALTER TABLE "+Pt.TABLE_NAME+" ADD COLUMN "+M.SPACE+Pt.COLUMN_NAME_SYLLABUS+M.TEXT_TYPE+" DEFAULT '';"},(Rt=Lt||(Lt={}))._ID="_id",Rt.TABLE_NAME="users",Rt.COLUMN_NAME_UID="uid",Rt.getCreateEntry=function(){return"CREATE TABLE "+Rt.TABLE_NAME+" ("+Rt._ID+" INTEGER PRIMARY KEY,"+Rt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" )"},Rt.deleteTable=function(){return"DROP TABLE IF EXISTS "+Rt.TABLE_NAME},(jt=Dt||(Dt={})).TABLE_NAME="group_profile",jt._ID="_id",jt.COLUMN_NAME_UID="uid",jt.COLUMN_NAME_GID="gid",jt.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",jt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+jt.TABLE_NAME+" ("+jt._ID+" INTEGER PRIMARY KEY"+M.COMMA_SEP+jt.COLUMN_NAME_GID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+jt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+jt.COLUMN_NAME_EPOCH_TIMESTAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+"UNIQUE ("+jt.COLUMN_NAME_GID+M.COMMA_SEP+jt.COLUMN_NAME_UID+") ON CONFLICT REPLACE)"},jt.deleteTable=function(){return"DROP TABLE IF EXISTS"+jt.TABLE_NAME},(kt=Ut||(Ut={})).TABLE_NAME="groups",kt._ID="_id",kt.COLUMN_NAME_GID="gid",kt.COLUMN_NAME_NAME="name",kt.COLUMN_NAME_SYLLABUS="syllabus",kt.COLUMN_NAME_GRADE="grade",kt.COLUMN_NAME_GRADE_VALUE="grade_value",kt.COLUMN_NAME_CREATED_AT="created_at",kt.COLUMN_NAME_UPDATED_AT="updated_at",kt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+kt.TABLE_NAME+" ("+kt._ID+" INTEGER PRIMARY KEY"+M.COMMA_SEP+kt.COLUMN_NAME_GID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+kt.COLUMN_NAME_NAME+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+kt.COLUMN_NAME_SYLLABUS+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+kt.COLUMN_NAME_GRADE+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+kt.COLUMN_NAME_GRADE_VALUE+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+kt.COLUMN_NAME_CREATED_AT+" INTEGER"+M.COMMA_SEP+kt.COLUMN_NAME_UPDATED_AT+" INTEGER )"},kt.deleteTable=function(){return"DROP TABLE IF EXISTS"+kt.TABLE_NAME},(Bt=xt||(xt={}))._ID="_id",Bt.TABLE_NAME="imported_metadata",Bt.COLUMN_NAME_IMPORTED_ID="imported_id",Bt.COLUMN_NAME_DEVICE_ID="device_id",Bt.COLUMN_NAME_COUNT="count",Bt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Bt.TABLE_NAME+" ("+Bt._ID+" INTEGER PRIMARY KEY,"+Bt.COLUMN_NAME_IMPORTED_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Bt.COLUMN_NAME_DEVICE_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Bt.COLUMN_NAME_COUNT+M.SPACE+M.INT_TYPE+" )"},Bt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Bt.TABLE_NAME},(Vt=Ft||(Ft={}))._ID="_id",Vt.TABLE_NAME="learner_assessments",Vt.COLUMN_NAME_UID="uid",Vt.COLUMN_NAME_CONTENT_ID="content_id",Vt.COLUMN_NAME_QID="qid",Vt.COLUMN_NAME_Q_INDEX="qindex",Vt.COLUMN_NAME_CORRECT="correct",Vt.COLUMN_NAME_SCORE="score",Vt.COLUMN_NAME_MAX_SCORE="max_score",Vt.COLUMN_NAME_TIME_SPENT="time_spent",Vt.COLUMN_NAME_RES="res",Vt.COLUMN_NAME_TIMESTAMP="timestamp",Vt.COLUMN_NAME_Q_DESC="qdesc",Vt.COLUMN_NAME_Q_TITLE="qtitle",Vt.COLUMN_NAME_HIERARCHY_DATA="h_data",Vt.COLUMN_NAME_TOTAL_TS="total_ts",Vt.COLUMN_NAME_MARKS="marks",Vt.COLUMN_NAME_COUNT="occurence_count",Vt.COLUMN_NAME_TOTAL_MAX_SCORE="sum_max_score",Vt.COLUMN_NAME_USERS_COUNT="users_count",Vt.COLUMN_NAME_HANDLE="handle",Vt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Vt.TABLE_NAME+" ("+Vt._ID+" INTEGER PRIMARY KEY,"+Vt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Vt.COLUMN_NAME_CONTENT_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_QID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_Q_INDEX+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_CORRECT+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_SCORE+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_MAX_SCORE+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_TIME_SPENT+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_RES+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_TIMESTAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_Q_DESC+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_Q_TITLE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Vt.COLUMN_NAME_HIERARCHY_DATA+M.SPACE+M.TEXT_TYPE+" DEFAULT '' )"},Vt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Vt.TABLE_NAME},(Gt=Yt||(Yt={}))._ID="_id",Gt.TABLE_NAME="learner_content_summary",Gt.COLUMN_NAME_UID="uid",Gt.COLUMN_NAME_CONTENT_ID="content_id",Gt.COLUMN_NAME_AVG_TS="avg_ts",Gt.COLUMN_NAME_SESSIONS="sessions",Gt.COLUMN_NAME_TOTAL_TS="total_ts",Gt.COLUMN_NAME_LAST_UPDATED_ON="last_updated_on",Gt.COLUMN_NAME_HIERARCHY_DATA="h_data",Gt.COLUMN_NAME_NO_OF_QUESTIONS="no_of_questions",Gt.COLUMN_NAME_CORRECT_ANSWERS="correct_answers",Gt.COLUMN_NAME_TOTAL_TIME_SPENT="total_time_spent",Gt.COLUMN_NAME_TOTAL_MAX_SCORE="total_max_score",Gt.COLUMN_NAME_TOTAL_SCORE="total_score",Gt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Gt.TABLE_NAME+" ("+Gt._ID+" INTEGER PRIMARY KEY,"+Gt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Gt.COLUMN_NAME_CONTENT_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Gt.COLUMN_NAME_AVG_TS+M.SPACE+M.REAL_TYPE+M.COMMA_SEP+Gt.COLUMN_NAME_SESSIONS+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Gt.COLUMN_NAME_TOTAL_TS+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Gt.COLUMN_NAME_LAST_UPDATED_ON+M.SPACE+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Gt.COLUMN_NAME_HIERARCHY_DATA+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+" UNIQUE ("+Gt.COLUMN_NAME_UID+M.SPACE+M.COMMA_SEP+Gt.COLUMN_NAME_CONTENT_ID+M.COMMA_SEP+Gt.COLUMN_NAME_HIERARCHY_DATA+") ON CONFLICT REPLACE )"},Gt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Gt.TABLE_NAME},function(e){e.TABLE_NAME="group_profile",e._ID="_id",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+M.COMMA_SEP+e.COLUMN_NAME_GID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+e.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+"UNIQUE ("+e.COLUMN_NAME_GID+M.COMMA_SEP+e.COLUMN_NAME_UID+") ON CONFLICT REPLACE)"},e.deleteTable=function(){return"DROP TABLE IF EXISTS"+e.TABLE_NAME}}(Ht||(Ht={})),function(e){e.TABLE_NAME="groups",e._ID="_id",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_NAME="name",e.COLUMN_NAME_SYLLABUS="syllabus",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_GRADE_VALUE="grade_value",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_UPDATED_AT="updated_at",e.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+M.COMMA_SEP+e.COLUMN_NAME_GID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+e.COLUMN_NAME_NAME+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+e.COLUMN_NAME_SYLLABUS+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+e.COLUMN_NAME_GRADE+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+e.COLUMN_NAME_GRADE_VALUE+M.SPACE+M.TEXT_TYPE+' DEFAULT ""'+M.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+" INTEGER"+M.COMMA_SEP+e.COLUMN_NAME_UPDATED_AT+" INTEGER )"},e.deleteTable=function(){return"DROP TABLE IF EXISTS"+e.TABLE_NAME}}(qt||(qt={})),(Kt=zt||(zt={}))._ID="_id",Kt.TABLE_NAME="partners",Kt.COLUMN_NAME_PARTNER_ID="partnerID",Kt.COLUMN_NAME_KEY="publicKey",Kt.COLUMN_NAME_KEY_ID="publicKeyID",Kt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Kt.TABLE_NAME+" ("+Kt._ID+" INTEGER PRIMARY KEY,"+Kt.COLUMN_NAME_PARTNER_ID+M.SPACE+M.TEXT_TYPE+" UNIQUE NOT NULL"+M.COMMA_SEP+Kt.COLUMN_NAME_KEY+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Kt.COLUMN_NAME_KEY_ID+M.SPACE+M.INT_TYPE+" NOT NULL )"},Kt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Kt.TABLE_NAME},(Xt=Wt||(Wt={})).TABLE_NAME="content",Xt._ID="_id",Xt.COLUMN_NAME_IDENTIFIER="identifier",Xt.COLUMN_NAME_SERVER_DATA="server_data",Xt.COLUMN_NAME_LOCAL_DATA="local_data",Xt.COLUMN_NAME_MIME_TYPE="mime_type",Xt.COLUMN_NAME_PATH="path",Xt.COLUMN_NAME_INDEX="search_index",Xt.COLUMN_NAME_VISIBILITY="visibility",Xt.COLUMN_NAME_SERVER_LAST_UPDATED_ON="server_last_updated_on",Xt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON="local_last_updated_on",Xt.COLUMN_NAME_MANIFEST_VERSION="manifest_version",Xt.COLUMN_NAME_REF_COUNT="ref_count",Xt.COLUMN_NAME_CONTENT_STATE="content_state",Xt.COLUMN_NAME_CONTENT_TYPE="content_type",Xt.COLUMN_NAME_AUDIENCE="audience",Xt.COLUMN_NAME_PRAGMA="pragma",Xt.COLUMN_NAME_UID="uid",Xt.COLUMN_NAME_SIZE_ON_DEVICE="size_on_device",Xt.COLUMN_NAME_BOARD="board",Xt.COLUMN_NAME_MEDIUM="medium",Xt.COLUMN_NAME_GRADE="grade",Xt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Xt.TABLE_NAME+" ("+Xt._ID+" INTEGER PRIMARY KEY,"+Xt.COLUMN_NAME_IDENTIFIER+M.SPACE+M.TEXT_TYPE+" UNIQUE NOT NULL"+M.COMMA_SEP+Xt.COLUMN_NAME_SERVER_DATA+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_LOCAL_DATA+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_MIME_TYPE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_PATH+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_INDEX+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_VISIBILITY+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_SERVER_LAST_UPDATED_ON+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_REF_COUNT+M.SPACE+M.INT_TYPE+" NOT NULL DEFAULT 1"+M.COMMA_SEP+Xt.COLUMN_NAME_CONTENT_STATE+M.SPACE+M.INT_TYPE+" NOT NULL DEFAULT 2"+M.COMMA_SEP+Xt.COLUMN_NAME_CONTENT_TYPE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Xt.COLUMN_NAME_AUDIENCE+M.SPACE+M.TEXT_TYPE+" DEFAULT 'Learner'"+M.COMMA_SEP+Xt.COLUMN_NAME_SIZE_ON_DEVICE+M.SPACE+M.INT_TYPE+" NOT NULL DEFAULT 0"+M.COMMA_SEP+Xt.COLUMN_NAME_PRAGMA+M.SPACE+M.TEXT_TYPE+" DEFAULT ''"+M.COMMA_SEP+Xt.COLUMN_NAME_BOARD+M.SPACE+M.TEXT_TYPE+" DEFAULT ''"+M.COMMA_SEP+Xt.COLUMN_NAME_MEDIUM+M.SPACE+M.TEXT_TYPE+" DEFAULT ''"+M.COMMA_SEP+Xt.COLUMN_NAME_GRADE+M.SPACE+M.TEXT_TYPE+" DEFAULT ''"+M.COMMA_SEP+Xt.COLUMN_NAME_MANIFEST_VERSION+M.SPACE+M.TEXT_TYPE+" )"},Xt.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+Xt.TABLE_NAME},Xt.getAlterEntryForContentSize=function(){return"ALTER TABLE "+Xt.TABLE_NAME+" ADD COLUMN "+Xt.COLUMN_NAME_SIZE_ON_DEVICE+M.INT_TYPE+" NOT NULL DEFAULT 0;"},Xt.getAlterEntryForPragma=function(){return"ALTER TABLE "+Xt.TABLE_NAME+" ADD COLUMN "+Xt.COLUMN_NAME_PRAGMA+M.TEXT_TYPE+" DEFAULT '';"},Xt.getAlterEntryForBoard=function(){return"ALTER TABLE "+Xt.TABLE_NAME+" ADD COLUMN "+Xt.COLUMN_NAME_BOARD+" TEXT DEFAULT ''"},Xt.getAlterEntryForMedium=function(){return"ALTER TABLE "+Xt.TABLE_NAME+" ADD COLUMN "+Xt.COLUMN_NAME_MEDIUM+" TEXT DEFAULT ''"},Xt.getAlterEntryForGrade=function(){return"ALTER TABLE "+Xt.TABLE_NAME+" ADD COLUMN "+Xt.COLUMN_NAME_GRADE+" TEXT DEFAULT ''"},(Qt=Jt||(Jt={}))._ID="_id",Qt.TABLE_NAME="content_access",Qt.COLUMN_NAME_UID="uid",Qt.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",Qt.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",Qt.COLUMN_NAME_STATUS="status",Qt.COLUMN_NAME_CONTENT_TYPE="content_type",Qt.COLUMN_NAME_LEARNER_STATE="learner_state",Qt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Qt.TABLE_NAME+" ("+Qt._ID+" INTEGER PRIMARY KEY,"+Qt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Qt.COLUMN_NAME_CONTENT_IDENTIFIER+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Qt.COLUMN_NAME_EPOCH_TIMESTAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Qt.COLUMN_NAME_STATUS+M.SPACE+M.INT_TYPE+M.COMMA_SEP+Qt.COLUMN_NAME_CONTENT_TYPE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+Qt.COLUMN_NAME_LEARNER_STATE+M.SPACE+M.BLOB_TYPE+" )"},Qt.deleteTable=function(){return"DROP TABLE IF EXISTS "+Qt.TABLE_NAME},(Zt=$t||($t={}))._ID="_id",Zt.TABLE_NAME="feedback",Zt.COLUMN_NAME_CONTENT_ID="identifier",Zt.COLUMN_NAME_UID="uid",Zt.COLUMN_NAME_RATING="rating",Zt.COLUMN_NAME_COMMENTS="comments",Zt.COLUMN_NAME_CREATED_AT="createdAt",Zt.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+Zt.TABLE_NAME+" ("+Zt._ID+" INTEGER PRIMARY KEY,"+Zt.COLUMN_NAME_CONTENT_ID+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Zt.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Zt.COLUMN_NAME_RATING+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Zt.COLUMN_NAME_COMMENTS+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+Zt.COLUMN_NAME_CREATED_AT+M.SPACE+M.INT_TYPE+" )"},Zt.deleteTable=function(){return"DROP TABLE IF EXISTS "+Zt.TABLE_NAME},(tn=en||(en={}))._ID="_id",tn.TABLE_NAME="content_marker",tn.COLUMN_NAME_UID="uid",tn.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",tn.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",tn.COLUMN_NAME_DATA="data",tn.COLUMN_NAME_EXTRA_INFO="extra_info",tn.COLUMN_NAME_MARKER="marker",tn.COLUMN_NAME_MIME_TYPE="mime_type",tn.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+tn.TABLE_NAME+" ("+tn._ID+" INTEGER PRIMARY KEY,"+tn.COLUMN_NAME_UID+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+tn.COLUMN_NAME_CONTENT_IDENTIFIER+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+tn.COLUMN_NAME_EPOCH_TIMESTAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+tn.COLUMN_NAME_DATA+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+tn.COLUMN_NAME_EXTRA_INFO+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+tn.COLUMN_NAME_MIME_TYPE+M.SPACE+M.TEXT_TYPE+" DEFAULT ''"+M.COMMA_SEP+tn.COLUMN_NAME_MARKER+M.SPACE+M.INT_TYPE+" )"},tn.deleteTable=function(){return"DROP TABLE IF EXISTS "+tn.TABLE_NAME},tn.getAlterEntryForMimeType=function(){return"ALTER TABLE "+tn.TABLE_NAME+" ADD COLUMN "+tn.COLUMN_NAME_MIME_TYPE+" TEXT DEFAULT ''"},(rn=nn||(nn={}))._ID="_id",rn.TABLE_NAME="notifications",rn.COLUMN_NAME_MESSAGE_ID="message_id",rn.COLUMN_NAME_EXPIRY_TIME="expiry_time",rn.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME="display_time",rn.COLUMN_NAME_NOTIFICATION_RECEIVED_AT="received_at",rn.COLUMN_NAME_NOTIFICATION_JSON="notification_json",rn.COLUMN_NAME_IS_READ="is_read",rn.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+rn.TABLE_NAME+" ("+rn._ID+" INTEGER PRIMARY KEY,"+rn.COLUMN_NAME_MESSAGE_ID+M.SPACE+M.INT_TYPE+M.COMMA_SEP+rn.COLUMN_NAME_EXPIRY_TIME+M.SPACE+M.INT_TYPE+M.COMMA_SEP+rn.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+M.SPACE+M.INT_TYPE+M.COMMA_SEP+rn.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+M.SPACE+M.INT_TYPE+M.COMMA_SEP+rn.COLUMN_NAME_NOTIFICATION_JSON+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+rn.COLUMN_NAME_IS_READ+M.SPACE+M.INT_TYPE+" )"},rn.deleteTable=function(){return"DROP TABLE IF EXISTS "+rn.TABLE_NAME},(an=on||(on={}))._ID="_id",an.TABLE_NAME="no_sql",an.COLUMN_NAME_KEY="key",an.COLUMN_NAME_VALUE="value",an.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+an.TABLE_NAME+" ("+an._ID+" INTEGER PRIMARY KEY,"+an.COLUMN_NAME_KEY+M.SPACE+M.TEXT_TYPE+" NOT NULL"+M.COMMA_SEP+an.COLUMN_NAME_VALUE+M.SPACE+M.TEXT_TYPE+" )"},an.getDeleteEntry=function(){return"DROP TABLE IF EXISTS "+an.TABLE_NAME},(sn=cn||(cn={})).TABLE_NAME="error_stack",sn._ID="_id",sn.COLUMN_NAME_APP_VERSION="app_version",sn.COLUMN_NAME_PAGE_ID="page_id",sn.COLUMN_NAME_TIME_STAMP="time_stamp",sn.COLUMN_NAME_ERROR_LOG="error_log",sn.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+sn.TABLE_NAME+" ("+sn._ID+" INTEGER PRIMARY KEY"+M.COMMA_SEP+sn.COLUMN_NAME_APP_VERSION+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+sn.COLUMN_NAME_PAGE_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+sn.COLUMN_NAME_TIME_STAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+sn.COLUMN_NAME_ERROR_LOG+M.SPACE+M.TEXT_TYPE+" )"},sn.deleteTable=function(){return"DROP TABLE IF EXISTS"+sn.TABLE_NAME},(fn=un||(un={})).TABLE_NAME="search_history",fn._ID="_id",fn.COLUMN_NAME_USER_ID="uid",fn.COLUMN_NAME_QUERY="query",fn.COLUMN_NAME_TIME_STAMP="time_stamp",fn.COLUMN_NAME_NAMESPACE="namespace",fn.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS "+fn.TABLE_NAME+" ("+fn._ID+" INTEGER PRIMARY KEY"+M.COMMA_SEP+fn.COLUMN_NAME_USER_ID+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+fn.COLUMN_NAME_QUERY+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+fn.COLUMN_NAME_TIME_STAMP+M.SPACE+M.INT_TYPE+M.COMMA_SEP+fn.COLUMN_NAME_NAMESPACE+M.SPACE+M.TEXT_TYPE+M.COMMA_SEP+"UNIQUE ("+fn.COLUMN_NAME_USER_ID+M.COMMA_SEP+fn.COLUMN_NAME_QUERY+") ON CONFLICT REPLACE )"},fn.deleteTable=function(){return"DROP TABLE IF EXISTS"+fn.TABLE_NAME},(hn=ln||(ln={})).TABLE_NAME="course_assessment",hn._ID="_id",hn.COLUMN_NAME_ASSESSMENT_EVENT="assessment_event",hn.COLUMN_NAME_CREATED_AT="created_at",hn.COLUMN_NAME_USER_ID="user_id",hn.COLUMN_NAME_CONTENT_ID="content_id",hn.COLUMN_NAME_COURSE_ID="course_id",hn.COLUMN_NAME_BATCH_ID="batch_id",hn.getCreateEntry=function(){return"CREATE TABLE IF NOT EXISTS"+M.SPACE+hn.TABLE_NAME+M.SPACE+"("+hn._ID+M.SPACE+"INTEGER PRIMARY KEY,"+hn.COLUMN_NAME_ASSESSMENT_EVENT+M.SPACE+M.TEXT_TYPE+","+hn.COLUMN_NAME_CREATED_AT+M.SPACE+M.INT_TYPE+","+hn.COLUMN_NAME_USER_ID+M.SPACE+M.TEXT_TYPE+","+hn.COLUMN_NAME_CONTENT_ID+M.SPACE+M.TEXT_TYPE+","+hn.COLUMN_NAME_COURSE_ID+M.SPACE+M.TEXT_TYPE+","+hn.COLUMN_NAME_BATCH_ID+M.SPACE+M.TEXT_TYPE+")"},hn.deleteTable=function(){return"DROP TABLE IF EXISTS"+hn.TABLE_NAME};var Mn,wn,Cn,In,Pn,Ln,Rn,Dn,jn,Un,kn,xn,Bn,Fn,Vn,Yn,Gn,Hn=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),qn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},zn=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Kn=function(e){function t(){return e.call(this,1,16)||this}return Hn(t,e),t.prototype.apply=function(e){return qn(this,void 0,void 0,(function(){return zn(this,(function(t){switch(t.label){case 0:return[4,Promise.all(this.queries().map((function(t){return e.execute(t).toPromise()})))];case 1:return t.sent(),[2]}}))}))},t.prototype.queries=function(){return[gt.getCreateEntry(),St.getCreateEntry(),Nt.getCreateEntry(),At.getCreateEntry(),Lt.getCreateEntry(),It.getCreateEntry(),xt.getCreateEntry(),zt.getCreateEntry(),Wt.getCreateEntry(),Ft.getCreateEntry(),Yt.getCreateEntry(),Jt.getCreateEntry(),$t.getCreateEntry(),nn.getCreateEntry(),qt.getCreateEntry(),Ht.getCreateEntry(),on.getCreateEntry(),en.getCreateEntry(),cn.getCreateEntry(),un.getCreateEntry(),ln.getCreateEntry()]},t}(w),Wn=function(){function e(){this.query=""}return e.prototype.where=function(t){return this.query+=t.trim(),new e.WhereDecorator(this)},e.prototype.build=function(){return this.query},e.ConstraintDecorator=function(){function e(e){this.queryBuilder=e}return e.prototype.and=function(){return this.queryBuilder.query+=" AND ",this.queryBuilder},e.prototype.or=function(){return this.queryBuilder.query+=" OR ",this.queryBuilder},e.prototype.end=function(){return this.queryBuilder},e}(),e.WhereDecorator=function(){function t(e){this.queryBuilder=e}return t.prototype.args=function(t){var n=this;return t.forEach((function(e){n.interpolate(e)})),new e.ConstraintDecorator(this.queryBuilder)},t.prototype.interpolate=function(e){isNaN(e)&&(e='"'+e+'"'),this.queryBuilder.query=this.queryBuilder.query.replace("?",e)},t}(),e}(),Xn=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Jn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Qn=function(e,t){return function(n,r){t(n,r,e)}},$n=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Zn=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},er=function(){function e(e,t,n){this.sdkConfig=e,this.dBVersion=t,this.appMigrationList=n,this.context=this.sdkConfig.dbConfig}return e.prototype.update=function(e){return new ie.Observable((function(t){db.update(e.table,e.selection||"",e.selectionArgs||[],e.modelJson,e.useExternalDb||!1,(function(e){t.next(e),t.complete()}),(function(e){t.error(e)}))}))},e.prototype.init=function(){return $n(this,void 0,void 0,(function(){var e=this;return Zn(this,(function(t){return[2,new Promise((function(t){db.init(e.context.dbName,e.dBVersion,[],(function(t){return $n(e,void 0,void 0,(function(){return Zn(this,(function(e){switch(e.label){case 0:return"onCreate"!==t.method?[3,2]:[4,this.onCreate()];case 1:return e.sent(),[3,4];case 2:return"onUpgrade"!==t.method?[3,4]:[4,this.onUpgrade(t.oldVersion,t.newVersion)];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))})),e.hasInitialized().subscribe((function(){t()}))}))]}))}))},e.prototype.hasInitialized=function(){return this.execute("DROP TABLE IF EXISTS dummy_init_table")},e.prototype.delete=function(e){var t="\n DELETE FROM "+e.table+"\n WHERE "+(new Wn).where(e.selection).args(e.selectionArgs).end().build()+"\n ";return new ie.Observable((function(n){db.execute(t,e.useExternalDb||!1,(function(e){n.next(e),n.complete()}),(function(e){n.error(e)}))}))},e.prototype.onCreate=function(){return $n(this,void 0,void 0,(function(){return Zn(this,(function(e){return[2,(new Kn).apply(this)]}))}))},e.prototype.onUpgrade=function(e,t){return $n(this,void 0,void 0,(function(){var n,r,i;return Zn(this,(function(o){switch(o.label){case 0:n=0,r=this.appMigrationList,o.label=1;case 1:return n<r.length?(i=r[n]).required(e,t)?[4,i.apply(this)]:[3,3]:[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},e.prototype.execute=function(e,t){return new ie.Observable((function(n){db.execute(e,t||!1,(function(e){n.next(e),n.complete()}),(function(e){n.error(e)}))}))},e.prototype.read=function(e){return new ie.Observable((function(t){db.read(!!e.distinct,e.table,e.columns||[],e.selection||"",e.selectionArgs||[],e.groupBy||"",e.having||"",e.orderBy||"",e.limit||"",e.useExternalDb||!1,(function(e){t.next(e),t.complete()}),(function(e){t.error(e)}))}))},e.prototype.insert=function(e){return new ie.Observable((function(t){db.insert(e.table,e.modelJson,e.useExternalDb||!1,(function(e){t.next(e),t.complete()}),(function(e){t.error(e)}))}))},e.prototype.beginTransaction=function(){db.beginTransaction()},e.prototype.endTransaction=function(e,t){db.endTransaction(e,t||!1)},e.prototype.copyDatabase=function(e){return new ie.Observable((function(t){db.copyDatabase(e,(function(e){t.next(e),t.complete()}),(function(e){t.error(e)}))}))},e.prototype.open=function(e){return new Promise((function(t,n){db.open(e,(function(e){t()}),(function(e){n()}))}))},e=Xn([Object(I.injectable)(),Qn(0,Object(I.inject)(be.SDK_CONFIG)),Qn(1,Object(I.inject)(be.DB_VERSION)),Qn(2,Object(I.inject)(be.DB_MIGRATION_LIST)),Jn("design:paramtypes",[Object,Number,Array])],e)}(),tr=n(117),nr=function(){function e(){}return e.generateUniqueId=function(){return tr()},e}(),rr=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},ir=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},or=function(e,t){return function(n,r){t(n,r,e)}},ar=function(){function e(e,t,n,r){this.sdkConfig=e,this.deviceInfo=t,this.appInfo=n,this.codePushExperimentService=r,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.decorate=function(e,t,n,r,i,o){return void 0===i&&(i=0),e.ets+=i,e.mid||(e.mid=nr.generateUniqueId()),t?this.patchActor(e,t):this.patchActor(e,""),this.patchContext(e,n,o),e},e.prototype.patchActor=function(e,t){e.actor||(e.actor=new ct);var n=e.actor;n.id||(n.id=t),n.type||(n.type=ct.TYPE_USER)},e.prototype.patchContext=function(e,t,n){e.context||(e.context=new st),e.context=this.buildContext(t,n,e.context)},e.prototype.patchPData=function(e){e.pdata||(e.pdata=new _t);var t=e.pdata;t.id||(t.id=this.apiConfig.api_authentication.producerId);var n=t.pid;n?t.pid=n:this.apiConfig.api_authentication.producerUniqueId?t.pid=this.apiConfig.api_authentication.producerUniqueId:t.pid="sunbird.android",t.ver||(t.ver=this.appInfo.getVersionName())},e.prototype.prepare=function(e,t){return{event:JSON.stringify(e),event_type:e.eid,timestamp:Date.now(),priority:1}},e.prototype.buildContext=function(e,t,n){n.channel=t,this.patchPData(n),n.env||(n.env="app");var r=this.codePushExperimentService.getExperimentKey();return"string"==typeof r&&(n.pdata.pid=n.pdata.pid+"-"+r),n.sid=e,n.did=this.deviceInfo.getDeviceID(),t!==this.apiConfig.api_authentication.channelId&&(n.rollup={l1:t}),n},e=rr([Object(I.injectable)(),or(0,Object(I.inject)(be.SDK_CONFIG)),or(1,Object(I.inject)(be.DEVICE_INFO)),or(2,Object(I.inject)(be.APP_INFO)),or(3,Object(I.inject)(be.CODEPUSH_EXPERIMENT_SERVICE)),ir("design:paramtypes",[Object,Object,Object,Object])],e)}(),cr=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),sr=function(e){function t(n){var r=e.call(this,n,"INVALID_INPUT_FOR_SYNC_PREPROCESSOR")||this;return Object.setPrototypeOf(r,t.prototype),r}return cr(t,e),t}(U),ur=n(118),fr=function(){function e(){}return e.prototype.process=function(e){if("string"!=typeof e)throw new sr('StringToGzippedString expects input of type "string"');return Object(ur.gzip)(e,{to:"string"})},e}(),lr=function(){function e(){}return e.prototype.process=function(e){if("object"!=typeof e)throw new sr('TelemetryEntriesToStringPreprocessor expects input of type "object"');return JSON.stringify(e)},e}(),hr=function(){function e(){}return Object.defineProperty(e,"log",{get:function(){return Lh.instance.telemetryService},enumerable:!0,configurable:!0}),e}(),dr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},pr=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},br=function(){function e(e,t,n,r,i,o,a,c){this.dbService=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.appInfoService=i,this.deviceRegisterService=o,this.keyValueStore=a,this.apiService=c,this.preprocessors=[new lr,new fr],this.telemetryConfig=this.sdkConfig.telemetryConfig,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.resetDeviceRegisterTTL=function(){return Object(ie.zip)(this.keyValueStore.setValue(e.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,""),this.keyValueStore.setValue(e.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,"")).pipe(Object(ge.mapTo)(void 0))},e.prototype.handle=function(e){var t=this,n=e.ignoreSyncThreshold,r=e.ignoreAutoSyncMode;return this.registerDevice().pipe(Object(ge.catchError)((function(){return n=!0,Object(ie.of)(void 0)})),Object(ge.mergeMap)((function(){return t.hasTelemetryThresholdCrossed().pipe(Object(ge.mergeMap)((function(e){return e||n?t.processEventsBatch().pipe(Object(ge.expand)((function(e){return e?t.processEventsBatch():ie.EMPTY})),Object(ge.reduce)((function(){}),void 0),Object(ge.mergeMap)((function(){return t.handleProcessedEventsBatch(r)})),Object(ge.expand)((function(e){return e.syncedEventCount?t.handleProcessedEventsBatch(r):ie.EMPTY})),Object(ge.reduce)((function(e,t){return{syncedEventCount:e.syncedEventCount+t.syncedEventCount,syncTime:Date.now(),syncedFileSize:e.syncedFileSize+t.syncedFileSize,error:t.error?t.error:e.error}}),{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0})):Object(ie.of)({syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0})})))})))},e.prototype.processEventsBatch=function(){var e=this;return this.fetchEvents().pipe(Object(ge.mergeMap)((function(t){return e.processEvents(t).pipe(Object(ge.mergeMap)((function(n){return e.persistProcessedEvents(n,n.processedEventsSize).pipe(Object(ge.mergeMap)((function(){return e.deleteEvents(t)})),Object(ge.mapTo)(t.length))})))})))},e.prototype.registerDevice=function(){var t=this;return Object(ie.zip)(this.keyValueStore.getValue(e.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY),this.keyValueStore.getValue(e.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY)).pipe(Object(ge.mergeMap)((function(n){var r=n[0],i=n[1];if(r&&i){var o="false"===i?e.REGISTER_API_FAILURE_TTL:e.REGISTER_API_SUCCESS_TTL;if(Math.abs(parseInt(r,10)-Date.now())<o)return Object(ie.of)(void 0)}return t.deviceRegisterService.registerDevice().pipe(Object(ge.tap)((function(n){return dr(t,void 0,void 0,(function(){var t,r,i,o,a=this;return pr(this,(function(c){switch(c.label){case 0:return n.result.actions.forEach((function(e){"experiment"===e.type&&e.key&&a.sharedPreferences.putString(Z.DEPLOYMENT_KEY,e.data.key).toPromise()})),t=new Date(n.ts).getTime(),r=Date.now(),i=t-r,(o=Math.abs(i)>this.telemetryConfig.telemetryLogMinAllowedOffset?i:0)?[4,hr.log.interact({type:Qe.OTHER,subType:$e.DEVICE_TIME_OFFSET_FOUND,env:"sdk",pageId:"sdk",id:"sdk",valueMap:{deviceTime:r,offsetTime:o}}).toPromise()]:[3,3];case 1:return c.sent(),[4,this.keyValueStore.setValue(e.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY,o+"").toPromise()];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))})),Object(ge.mergeMap)((function(){return Object(ie.zip)(t.keyValueStore.setValue(e.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),t.keyValueStore.setValue(e.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"true")).pipe(Object(ge.mapTo)(void 0))})),Object(ge.catchError)((function(n){return Object(ie.zip)(t.keyValueStore.setValue(e.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),t.keyValueStore.setValue(e.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"false")).pipe(Object(ge.mergeMap)((function(){throw console.error(n),new Error("Device Registration Failed")})))})))})))},e.prototype.hasTelemetryThresholdCrossed=function(){var e=this;return this.dbService.execute("\n SELECT count(*) as COUNT FROM "+gt.TABLE_NAME).pipe(Object(ge.map)((function(t){return!!(t&&t[0]&&t[0].COUNT>=e.telemetryConfig.telemetrySyncThreshold)})))},e.prototype.fetchEvents=function(){return this.dbService.execute("\n SELECT * FROM "+gt.TABLE_NAME+"\n WHERE "+gt.COLUMN_NAME_PRIORITY+" = (SELECT MIN ("+gt.COLUMN_NAME_PRIORITY+")\n FROM "+gt.TABLE_NAME+")\n ORDER BY "+gt.COLUMN_NAME_TIMESTAMP+"\n LIMIT "+this.telemetryConfig.telemetrySyncBandwidth)},e.prototype.processEvents=function(e){if(!e.length)return Object(ie.of)({processedEventsSize:0});var t=nr.generateUniqueId();return Object(ie.of)({processedEvents:this.preprocessors.reduce((function(e,t){return t.process(e)}),{id:"ekstep.telemetry",ver:"1.0",ts:ve()().format("YYYY-MM-DDTHH:mm:ss[Z]"),events:e.map((function(e){return JSON.parse(e[gt.COLUMN_NAME_EVENT])})),params:{did:this.deviceInfo.getDeviceID(),msgid:t,key:"",requesterId:""}}),processedEventsSize:e.length,messageId:t})},e.prototype.persistProcessedEvents=function(e,t){var n,r=e.processedEvents,i=e.messageId;if(!r)return Object(ie.of)(void 0);var o={table:St.TABLE_NAME,modelJson:(n={},n[St.COLUMN_NAME_MSG_ID]=i,n[St.COLUMN_NAME_NUMBER_OF_EVENTS]=t,n[gt.COLUMN_NAME_PRIORITY]=1,n[St.COLUMN_NAME_DATA]=r,n)};return this.dbService.insert(o).pipe(Object(ge.mapTo)(void 0))},e.prototype.deleteEvents=function(e){return e.length?this.dbService.execute("\n DELETE FROM "+gt.TABLE_NAME+"\n WHERE "+gt._ID+" IN ("+e.map((function(e){return e[gt._ID]})).join(",")+")\n "):Object(ie.of)(void 0)},e.prototype.handleProcessedEventsBatch=function(e){var t=this;return Object(ie.iif)((function(){return!!e}),Object(ie.of)(void 0),this.sharedPreferences.getString(ne.KEY_AUTO_SYNC_MODE).pipe(Object(ge.catchError)((function(){return Object(ie.of)("")})),Object(ge.mergeMap)((function(e){switch(e){case ih.OFF:throw new Error("AUTO_SYNC_MODE: "+ih.OFF);case ih.OVER_WIFI:if(navigator.connection.type===Connection.WIFI)return Object(ie.of)(void 0);throw new Error("AUTO_SYNC_MODE: "+ih.OVER_WIFI);case ih.ALWAYS_ON:default:return Object(ie.of)(void 0)}})))).pipe(Object(ge.mergeMap)((function(){return t.fetchProcessedEventsBatch().pipe(Object(ge.mergeMap)((function(e){return t.syncProcessedEvent(e).pipe(Object(ge.mergeMap)((function(n){return t.deleteProcessedEvent(e).pipe(Object(ge.mapTo)(n||{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0}))})))})))})),Object(ge.catchError)((function(e){return Object(ie.of)({syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:e})})))},e.prototype.fetchProcessedEventsBatch=function(){return this.dbService.read({table:St.TABLE_NAME,selection:"",selectionArgs:[],limit:"1"}).pipe(Object(ge.map)((function(e){return e&&e[0]})))},e.prototype.syncProcessedEvent=function(t){var n=this;if(!t)return Object(ie.of)(void 0);var r=t[St.COLUMN_NAME_DATA].split("").map((function(e){return e.charCodeAt(0)})),i=new Uint8Array(r),o=(new F.Builder).withSerializer(L.RAW).withHost(this.telemetryConfig.host).withType(R.POST).withPath(this.telemetryConfig.apiPath+e.TELEMETRY_ENDPOINT).withHeaders({"Content-Type":"application/json","Content-Encoding":"gzip"}).withBody(i).withApiToken(!0).build();return this.apiService.fetch(o).pipe(Object(ge.tap)((function(t){return dr(n,void 0,void 0,(function(){var n,r,i,o;return pr(this,(function(a){switch(a.label){case 0:return[4,this.keyValueStore.getValue(e.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY).toPromise()];case 1:return"false"!==a.sent()?[3,3]:(n=new Date(t.body.ets).getTime(),r=Date.now(),i=n-r,(o=Math.abs(i)>this.telemetryConfig.telemetryLogMinAllowedOffset?i:0)?[4,this.keyValueStore.setValue(e.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY,o+"").toPromise()]:[3,3]);case 2:a.sent(),a.label=3;case 3:return[2]}}))}))})),Object(ge.map)((function(){return{syncedEventCount:t[St.COLUMN_NAME_NUMBER_OF_EVENTS],syncTime:Date.now(),syncedFileSize:(new TextEncoder).encode(t[St.COLUMN_NAME_DATA]).length}})),Object(ge.catchError)((function(e){if(e instanceof De&&e.response.responseCode===N.HTTP_BAD_REQUEST)return Object(ie.of)({syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:e});throw e})))},e.prototype.deleteProcessedEvent=function(e){return e?this.dbService.delete({table:St.TABLE_NAME,selection:"_id = ?",selectionArgs:[e[St._ID]]}):Object(ie.of)(void 0)},e.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY="telemetry_log_min_allowed_offset_key",e.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY="last_synced_device_register_attempt_time_stamp",e.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY="last_synced_device_register_is_successful",e.TELEMETRY_ENDPOINT="/telemetry",e.REGISTER_API_SUCCESS_TTL=864e5,e.REGISTER_API_FAILURE_TTL=36e5,e}();!function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.DELETED_SUCCESSFULLY=1]="DELETED_SUCCESSFULLY"}(Mn||(Mn={})),function(e){e.ASC="asc",e.DESC="desc"}(wn||(wn={})),function(e){e[e.NOTHING=0]="NOTHING",e[e.PREVIEWED=1]="PREVIEWED",e[e.BOOKMARKED=2]="BOOKMARKED"}(Cn||(Cn={})),function(e){e.SEARCH="search",e.FILTER="filter"}(In||(In={})),function(e){e[e.ALL=0]="ALL",e[e.DOWNLOADED=1]="DOWNLOADED",e[e.SPINE=2]="SPINE"}(Pn||(Pn={})),function(e){e[e.SEEN_BUT_NOT_AVAILABLE=0]="SEEN_BUT_NOT_AVAILABLE",e[e.ONLY_SPINE=1]="ONLY_SPINE",e[e.ARTIFACT_AVAILABLE=2]="ARTIFACT_AVAILABLE"}(Ln||(Ln={})),function(e){e.APK="application/vnd.android.package-archive",e.ECML="application/vnd.ekstep.ecml-archive",e.HTML="application/vnd.ekstep.html-archive",e.COLLECTION="application/vnd.ekstep.content-collection",e.H5P="application/vnd.ekstep.h5p-archive",e.VIDEO="video/mp4",e.YOUTUBE="video/x-youtube",e.WEBM="video/webm",e.ZIP="application/zip",e.TXT="text/plain",e.ECAR="application/ecar",e.EPAR="application/epar"}(Rn||(Rn={})),function(e){e.DEFAULT="Default",e.PARENT="Parent"}(Dn||(Dn={})),function(e){e.LIVE="Live",e.DRAFT="Draft"}(jn||(jn={})),function(e){e.GZIP="gzip",e.IDENTITY="identity"}(Un||(Un={})),function(e){e.ATTACHMENT="attachment",e.INLINE="inline",e.ONLINE="online"}(kn||(kn={})),function(e){e.CONTENT="ecar",e.PROFILE="epar",e.TELEMETRY="gsa"}(xn||(xn={})),function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.ENQUEUED_FOR_DOWNLOAD=0]="ENQUEUED_FOR_DOWNLOAD",e[e.DOWNLOAD_STARTED=1]="DOWNLOAD_STARTED",e[e.DOWNLOAD_FAILED=2]="DOWNLOAD_FAILED",e[e.DOWNLOAD_COMPLETED=3]="DOWNLOAD_COMPLETED",e[e.IMPORT_STARTED=4]="IMPORT_STARTED",e[e.IMPORT_FAILED=5]="IMPORT_FAILED",e[e.NOT_COMPATIBLE=6]="NOT_COMPATIBLE",e[e.CONTENT_EXPIRED=7]="CONTENT_EXPIRED",e[e.ALREADY_EXIST=8]="ALREADY_EXIST",e[e.IMPORT_COMPLETED=100]="IMPORT_COMPLETED"}(Bn||(Bn={})),function(e){e.NO_DATA_FOUND="NO_DATA_FOUND",e.INVALID_FILE="INVALID_FILE",e.ECAR_NOT_FOUND="ECAR_NOT_FOUND",e.IMPORT_FAILED_DEVICE_MEMORY_FULL="IMPORT_FAILED_DEVICE_MEMORY_FULL",e.IMPORT_FAILED_EXTRACT_ECAR="IMPORT_FAILED_EXTRACTION",e.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND="IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND",e.IMPORT_FAILED_UNSUPPORTED_MANIFEST="IMPORT_FAILED_UNSUPPORTED_MANIFEST",e.IMPORT_FAILED_NO_CONTENT_METADATA="IMPORT_FAILED_NO_CONTENT_METADATA",e.DUPLICATE_CONTENT="DUPLICATE_CONTENT",e.IMPORT_FILE_EXIST="IMPORT_FILE_EXIST",e.ECAR_CLEANUP_FAILED="ECAR_CLEANUP_FAILED",e.EXPORT_FAILED_COPY_ASSET="EXPORT_FAILED_COPY_ASSET",e.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT="EXPORT_FAILED_MEMORY_NOT_SUFFICIENT",e.EXPORT_FAILED_WRITING_MANIFEST="EXPORT_FAILED_WRITE_MANIFEST",e.EXPORT_FAILED_ECAR_BUNDLE="EXPORT_FAILED_ECAR_BUNDLE",e.EXPORT_FAILED_NOTHING_TO_EXPORT="EXPORT_FAILED_NOTHING_TO_EXPORT",e.EXPORT_FAILED_DELETING_ECAR="EXPORT_FAILED_DELETING_ECAR"}(Fn||(Fn={})),function(e){e.EXPORT_FAILED="EXPORT_FAILED",e.IMPORT_FAILED="IMPORT_FAILED"}(Vn||(Vn={})),function(e){e.MANIFEST="manifest.json"}(Yn||(Yn={})),function(e){e.UPDATE="UPDATE",e.IMPORT_COMPLETED="IMPORT_COMPLETED",e.IMPORT_PROGRESS="IMPORT_PROGRESS",e.SERVER_CONTENT_DATA="SERVER_CONTENT_DATA",e.COURSE_STATE_UPDATED="COURSE_STATE_UPDATED",e.CONTENT_EXTRACT_COMPLETED="CONTENT_EXTRACT_COMPLETED"}(Gn||(Gn={}));var _r,Er=function(){function e(){}return e.joinPreservingQuotes=function(e){return e.map((function(e){return"'"+e+"'"})).join(",")},e.isEmpty=function(e){return!e||0===e.length},e.contains=function(e,t){return e&&-1!==e.indexOf(t)},e.deDupe=function(e){return e.filter((function(e,t,n){return n.indexOf(e)===t}))},e}(),yr=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.open(e.sourceDBFilePath).then((function(){return t.dbService.read({table:wt.TABLE_NAME,useExternalDb:!0}).toPromise()})).then((function(r){if(!r||!r.length)throw n.errorMesg=Vn.IMPORT_FAILED.valueOf(),n;var i={};r.forEach((function(e){i[e.key]=e.value})),e.metadata=i;var o=t.getImportTypes(i);if(o&&Er.contains(o,"telemetry")){var a=i.export_id,c=i.did;return t.dbService.read({table:xt.TABLE_NAME,selection:xt.COLUMN_NAME_IMPORTED_ID+" = ?\n AND "+xt.COLUMN_NAME_DEVICE_ID+" = ?",selectionArgs:[a,c]}).toPromise()}throw n.errorMesg=Vn.IMPORT_FAILED.valueOf(),n})).then((function(t){if(t&&t.length)throw n.errorMesg=Vn.IMPORT_FAILED.valueOf(),n;return n.body=e,n}))},e.prototype.getImportTypes=function(e){var t=[];return e.hasOwnProperty("types")&&(t=e.types),t},e}();!function(e){e.SAVE="SAVE"}(_r||(_r={}));var vr,gr,mr,Sr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Or=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ar=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:St.TABLE_NAME,useExternalDb:!0}).toPromise().then((function(e){return t.saveProccessedTelemetryToDB(e)})).then((function(){return n.body=e,n}))},e.prototype.saveProccessedTelemetryToDB=function(e){return Sr(this,void 0,void 0,(function(){var t=this;return Or(this,(function(n){return e.forEach((function(e){return Sr(t,void 0,void 0,(function(){return Or(this,(function(t){switch(t.label){case 0:return[4,this.dbService.insert({table:St.TABLE_NAME,modelJson:e})];case 1:return t.sent(),[2]}}))}))})),[2]}))}))},e}(),Tr=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D,r=e.metadata.export_id,i=e.metadata.did,o={imported_id:r,device_id:i,count:e.metadata.events_count};return this.dbService.read({table:xt.TABLE_NAME,selection:xt.COLUMN_NAME_IMPORTED_ID+" = ? AND "+xt.COLUMN_NAME_DEVICE_ID+" = ?",selectionArgs:[r,i],limit:"1"}).toPromise().then((function(e){return e&&e.length?t.dbService.update({table:xt.TABLE_NAME,modelJson:o}).toPromise():t.dbService.insert({table:xt.TABLE_NAME,modelJson:o}).toPromise()})).then((function(){return n.body=e,n}))},e}(),Nr=function(){function e(e,t){this.dbService=e,this.telemetryService=t}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:xt.TABLE_NAME}).toPromise().then((function(e){var n=[];e.forEach((function(e){var t={type:Ie.TELEMETRY,origin:e[xt.COLUMN_NAME_DEVICE_ID],identifier:e[xt.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};n.push(t)}));var r={dir:we.IN,type:Ce.FILE.valueOf(),items:n,env:"sdk"};return t.telemetryService.share(r).toPromise()})).then((function(){return n.body=e,n}))},e}();!function(e){e.ONLINE="ONLINE",e.OFFLINE="OFFLINE"}(vr||(vr={})),function(e){e.STUDENT="student",e.TEACHER="teacher"}(gr||(gr={})),function(e){e.SERVER="server",e.LOCAL="local"}(mr||(mr={}));var Mr,wr=function(){function e(e){this._uid=e,this._sid=nr.generateUniqueId(),this._createdTime=Date.now()}return Object.defineProperty(e.prototype,"uid",{get:function(){return this._uid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sid",{get:function(){return this._sid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"createdTime",{get:function(){return this._createdTime},enumerable:!0,configurable:!0}),e}(),Cr=function(){};!function(e){e[e.NOT_PLAYED=0]="NOT_PLAYED",e[e.PLAYED=1]="PLAYED"}(Mr||(Mr={}));var Ir,Pr=function(){function e(e,t){this.apiService=e,this.tenantServiceConfig=t,this.GET_TENANT_INFO_ENDPOINT="/info"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.tenantServiceConfig.tenantApiPath+this.GET_TENANT_INFO_ENDPOINT+"/"+e.slug).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result})))},e}(),Lr=function(){function e(e,t){this.apiService=e,this.updateUserInfoConfig=t,this.GET_SERVER_PROFILE_INFO_API="/update"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.PATCH).withPath(this.updateUserInfoConfig.profileApiPath+this.GET_SERVER_PROFILE_INFO_API).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result})))},e}(),Rr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Dr=function(){function e(e,t){this.apiService=e,this.searchServiceConfig=t,this.GET_SEARCH_USER_ENDPOINT="/search"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.searchServiceConfig.profileApiPath+this.GET_SEARCH_USER_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:Rr({},e,{filters:{identifier:e.filters.identifier?Array.from(e.filters.identifier):[]}})}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result.response.content})))},e}();!function(e){e.SERVER="server",e.CACHE="cache"}(Ir||(Ir={}));var jr,Ur,kr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},xr=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Br=function(){function e(e,t,n,r){this.apiService=e,this.profileServiceConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.GET_SERVER_PROFILE_DETAILS_ENDPOINT="/read",this.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails"}return e.prototype.handle=function(e){var t=this;return e.from=e.from||Ir.CACHE,Object(ie.of)(e.from).pipe(Object(ge.mergeMap)((function(n){return n===Ir.SERVER?t.fetchFromServer(e).pipe(Object(ge.tap)((function(e){return kr(t,void 0,void 0,(function(){return xr(this,(function(t){return[2,this.keyValueStore.setValue(this.USER_PROFILE_DETAILS_KEY_PREFIX+"-"+e.id,JSON.stringify(e)).toPromise()]}))}))})),Object(ge.catchError)((function(){return t.fetchFromCache(e)}))):t.fetchFromCache(e)})))},e.prototype.fetchFromServer=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.profileServiceConfig.profileApiPath_V2+this.GET_SERVER_PROFILE_DETAILS_ENDPOINT+"/"+e.userId).withParameters({fields:e.requiredFields.join(",")}).withApiToken(!0).withSessionToken(!0).withBody(e).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result.response})))},e.prototype.fetchFromCache=function(e){var t=this;return this.cachedItemStore.getCached(e.userId,this.USER_PROFILE_DETAILS_KEY_PREFIX,this.USER_PROFILE_DETAILS_KEY_PREFIX,(function(){return t.fetchFromServer(e)}))},e}(),Fr=function(){function e(){}return e.mapProfileDBEntryToProfile=function(e){return{uid:e[It.COLUMN_NAME_UID],handle:e[It.COLUMN_NAME_HANDLE],createdAt:e[It.COLUMN_NAME_CREATED_AT],medium:e[It.COLUMN_NAME_MEDIUM]?e[It.COLUMN_NAME_MEDIUM].split(","):[],board:e[It.COLUMN_NAME_BOARD]?e[It.COLUMN_NAME_BOARD].split(","):[],subject:e[It.COLUMN_NAME_SUBJECT]?e[It.COLUMN_NAME_SUBJECT].split(","):[],profileType:e[It.COLUMN_NAME_PROFILE_TYPE],grade:e[It.COLUMN_NAME_GRADE]?e[It.COLUMN_NAME_GRADE].split(","):[],syllabus:e[It.COLUMN_NAME_SYLLABUS]?e[It.COLUMN_NAME_SYLLABUS].split(","):[],source:e[It.COLUMN_NAME_SOURCE],gradeValue:e[It.COLUMN_NAME_GRADE_VALUE]&&JSON.parse(e[It.COLUMN_NAME_GRADE_VALUE])}},e.mapProfileToProfileDBEntry=function(e){var t;return(t={})[It.COLUMN_NAME_UID]=e.uid,t[It.COLUMN_NAME_HANDLE]=e.handle,t[It.COLUMN_NAME_CREATED_AT]=Number(e.createdAt),t[It.COLUMN_NAME_MEDIUM]=e.medium?e.medium.join(","):"",t[It.COLUMN_NAME_BOARD]=e.board?e.board.join(","):"",t[It.COLUMN_NAME_SUBJECT]=e.subject?e.subject.join(","):"",t[It.COLUMN_NAME_PROFILE_TYPE]=e.profileType,t[It.COLUMN_NAME_GRADE]=e.grade?e.grade.join(","):"",t[It.COLUMN_NAME_SYLLABUS]=e.syllabus?e.syllabus.join(","):"",t[It.COLUMN_NAME_SOURCE]=e.source,t[It.COLUMN_NAME_GRADE_VALUE]=e.gradeValue?JSON.stringify(e.gradeValue):"",t},e}(),Vr=function(){function e(e,t){this.apiService=e,this.acceptTermsConditionApiConfig=t,this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT="/tnc/accept"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.acceptTermsConditionApiConfig.profileApiPath+this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return"SUCCESS"===e.body.result.response})))},e}(),Yr=function(){function e(){}return e.mapDBEntryToContenetAccess=function(e){var t=e[Jt.COLUMN_NAME_LEARNER_STATE];return{status:Number(e[Jt.COLUMN_NAME_STATUS]),contentId:e[Jt.COLUMN_NAME_CONTENT_IDENTIFIER],contentType:e[Jt.COLUMN_NAME_CONTENT_TYPE],contentLearnerState:{learnerState:t&&JSON.parse(t)}}},e}(),Gr=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Hr=function(e){function t(n){var r=e.call(this,n,"INVALID_PROFILE_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return Gr(t,e),t}(U),qr=function(){function e(e,t){this.apiService=e,this.profileAlreadyInUseConfig=t,this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT="/get"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.profileAlreadyInUseConfig.profileApiPath+this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT+"/"+e.type+"/"+e.key).withApiToken(!0).withSessionToken(!0).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result})))},e}(),zr=function(){function e(e,t){this.apiService=e,this.otpServiceConfig=t,this.GET_GENERATE_OTP_ENDPOINT="/generate"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.otpServiceConfig.otpApiPath+this.GET_GENERATE_OTP_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return"SUCCESS"===e.body.result.response})))},e}(),Kr=function(){function e(e,t){this.apiService=e,this.optServiceConfig=t,this.GET_VERIFY_OTP_ENDPOINT="/verify"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.optServiceConfig.otpApiPath+this.GET_VERIFY_OTP_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:{key:e.key,type:e.type,otp:e.otp}}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return"SUCCESS"===e.body.result.response})))},e}(),Wr=function(){function e(){}return e.dirPathFromFilePath=function(e){return e.substring(0,e.lastIndexOf("/"))},e.fileNameFromFilePath=function(e){return e.substring(e.lastIndexOf("/")+1)},e.ASSETS_PATH="file:///android_asset/www/assets",e}(),Xr=function(){function e(e,t,n,r){this.apiService=e,this.profileServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.LOCATION_LOCAL_KEY="location-"}return e.prototype.handle=function(t){var n=this,r=t.filters.type;return t.filters.parentId&&(r=r+"_"+t.filters.parentId),this.cachedItemStore.getCached(r,this.LOCATION_LOCAL_KEY,"ttl_"+this.LOCATION_LOCAL_KEY,(function(){return n.fetchFromServer(t)}),(function(){return n.fetchFromFile(t)}),e.LOCATION_TTL)},e.prototype.fetchFromServer=function(t){var n=(new F.Builder).withType(R.POST).withPath(this.profileServiceConfig.searchLocationApiPath+e.GET_SEARCH_LOCATION_ENDPOINT).withApiToken(!0).withSessionToken(!1).withBody({request:t}).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return e.body.result.response})))},e.prototype.fetchFromFile=function(e){var t=Wr.ASSETS_PATH+this.profileServiceConfig.locationDirPath,n=e.filters.type;return e.filters.parentId&&(n=n+"-"+e.filters.parentId),n+=".json",Object(ie.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(ge.map)((function(e){return JSON.parse(e).result.response})))},e.GET_SEARCH_LOCATION_ENDPOINT="/location/search",e.LOCATION_TTL=864e5,e}(),Jr=function(){function e(){}return e.isAvailableLocally=function(e){return e===Ln.ARTIFACT_AVAILABLE},e.isUpdateAvailable=function(e,t){var n=-1,r=-1;return e&&e.pkgVersion&&(r=parseFloat(e.pkgVersion)),t&&t.pkgVersion&&(n=parseFloat(t.pkgVersion)),r>0&&n>0&&r>n},e.hasChildren=function(e){return!!e&&("string"==typeof e&&(e=JSON.parse(e)),e&&e.children)},e.getContentRollup=function(e,t){var n,r,i,o;if(t&&0!==t.length)for(var a=0;a<t.length;a++)if(0===a)n=t[a].identifier;else if(1===a)r=t[a].identifier;else if(2===a)i=t[a].identifier;else{if(3!==a)break;o=t[a].identifier}else n=e;return{l1:n,l2:r,l3:i,l4:o}},e.getChildContentsIdentifiers=function(e){var t=[],n=("string"==typeof e?JSON.parse(e):e).children;return n&&n.length&&n.forEach((function(e){t.push(e.identifier)})),t},e.getFirstPartOfThePathNameOnLastDelimiter=function(e){var t=e.lastIndexOf("/");if(t>0&&t<e.length)return e.substring(0,t)},e.hasPreRequisites=function(e){return JSON.parse(e).pre_requisites},e.readVisibility=function(e){var t=e.visibility;return t||Dn.DEFAULT},e.isCompatible=function(e,t){return t>=e.minCompatibilityLevel&&t<=e.maxCompatibilityLevel},e.readCompatibilityLevel=function(e){var t=e.compatibilityLevel;return t||this.defaultCompatibilityLevel},e.isDraftContent=function(e){return e&&e===jn.DRAFT.valueOf()},e.isExpired=function(e){if(e){var t=new Date(e).getTime();if((new Date).getTime()>t)return!0}return!1},e.isDuplicateCheckRequired=function(e,t){return e&&0===t},e.isImportFileExist=function(t,n){if(!t||!n)return!1;var r=!1,i=t[Wt.COLUMN_NAME_IDENTIFIER],o=n.identifier,a=t[Wt.COLUMN_NAME_VISIBILITY],c=e.readVisibility(n);return i===o&&a===c&&(r=this.readPkgVersion(JSON.parse(t[Wt.COLUMN_NAME_LOCAL_DATA]))>=this.readPkgVersion(n)),r},e.readPkgVersion=function(e){return e.pkgVersion},e.readContentType=function(e){var t=e.contentType;return t&&(t=t.toLowerCase()),t},e.readAudience=function(e){var t=e.audience,n=[];return"string"==typeof t&&n.push(t),n&&n.length||n.push("Learner"),n.sort(),n.join(",")},e.readPragma=function(e){var t=e.pragma;return t||(t=[]),t.join(",")},e.doesContentExist=function(t,n,r,i){if(!t)return!1;var o=!1,a=t[Wt.COLUMN_NAME_IDENTIFIER],c=JSON.parse(t[Wt.COLUMN_NAME_LOCAL_DATA]);if(a===n){var s=!1;i?s=!(e.readPkgVersion(c)<r):e.readPkgVersion(c)<r&&(s=!0),o=!(s||!i&&t[Wt.COLUMN_NAME_CONTENT_STATE]!==Ln.ARTIFACT_AVAILABLE.valueOf())}return o},e.getContentRootDir=function(e){return e.concat("content")},e.addOrUpdateViralityMetadata=function(t,n){if(e.isContentMetadataAbsent(t)){(i={}).origin=n,i.transferCount=e.INITIAL_VALUE_FOR_TRANSFER_COUNT;var r={};r.virality=i,t.contentMetadata=r}else if(e.isContentMetadataPresentWithoutViralityMetadata(t)){(i={}).origin=n,i.transferCount=e.INITIAL_VALUE_FOR_TRANSFER_COUNT,t.contentMetaData.virality=i}else{var i;(i=t.contentMetaData.virality).transferCount=e.transferCount(i)+1}},e.addViralityMetadataIfMissing=function(t,n){t.contentMetaData||(t.contentMetaData={});var r=t.contentMetaData;r.virality||(r.virality={});var i=t.virality;i||(i={}),i.origin||(i.origin=n),i.transferCount||(i.transferCount=e.INITIAL_VALUE_FOR_TRANSFER_COUNT)},e.isInlineIdentity=function(e,t){return e&&t&&kn.INLINE.valueOf()===e&&Un.IDENTITY===t},e.isOnlineContent=function(e){var t=e.contentDisposition;return t&&kn.ONLINE.valueOf()===t},e.addOrUpdateDialcodeMapping=function(e,t,n){var r;(r=e?JSON.parse(e):{}).hasOwnProperty("identifier")||(r.identifier=t);var i=new Set;return r.hasOwnProperty("rootNodes")&&r.forEach((function(e){i.add(e)})),i.add(n),r.rootNodes=i,JSON.stringify(r)},e.deDupe=function(e,t){return e.filter((function(e,n,r){return r.map((function(e){return e[t]})).indexOf(e[t])===n}))},e.getExportedFileName=function(t,n){var r,i="blank.ecar",o=0;t.length>0&&(r=t[0]);if(t.forEach((function(e){Dn.DEFAULT.valueOf()===e[Wt.COLUMN_NAME_VISIBILITY]&&o++})),o>1&&"".concat((o-1).toString()),r){var a=JSON.parse(r[Wt.COLUMN_NAME_LOCAL_DATA]),c=a.name;c&&c.length>e.MAX_CONTENT_NAME&&(c=c.substring(0,e.MAX_CONTENT_NAME-3)+"...");var s=a.pkgVersion;i=n.toLowerCase()+"_"+c+"-v"+s+".ecar"}return i},e.readOriginFromContentMap=function(e){var t=e.contentMetadata,n=t&&t.virality;return n?n.origin:""},e.readTransferCountFromContentMap=function(e){var t=e.contentMetadata,n=t&&t.virality;return n?it.parseInt(n.transferCount):0},e.readSizeFromContentMap=function(e){return e.size?e.size:""},e.getUidnIdentifierFiler=function(e,t){var n=e&&"uid = '"+e+"'",r=t&&"identifier = '"+t+"'",i="";return n&&r?i="WHERE ("+r+" AND "+n+")":r?i="WHERE ("+r+")":n&&(i="WHERE ("+n+")"),i},e.getBasePath=function(e){return e?e=-1!==e.indexOf("file://")?e.replace("file://",""):"file://".concat(e):""},e.getRollup=function(e,t){var n,r,i,o;if(t){var a=void 0;for(a=0;a<t.length;a++)switch(a){case 0:n=t[a].identifier;break;case 1:r=t[a].identifier;break;case 2:i=t[a].identifier;break;case 3:o=t[a].identifier}}else n=e;return{l1:n,l2:r,l3:i,l4:o}},e.addOrUpdateRefCount=function(e){return e<0&&(e=0),e},e.isNotUnit=function(e,t){return!(Rn.COLLECTION.valueOf()===e&&Dn.PARENT.valueOf()===t)},e.getContentAttribute=function(e){var t=[];if(e&&("string"==typeof e?t.push(e):t=e,t&&t.length)){t.sort();for(var n="",r=0;r<t.length;r++)n=r<t.length-1?n.concat("~",t[r]):n.concat("~",t[r],"~");return n.toLowerCase().trim()}return""},e.getFindAllContentsWithIdentifierQuery=function(e){var t=Er.joinPreservingQuotes(e),n=" order by "+Wt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON+" desc, "+Wt.COLUMN_NAME_SERVER_LAST_UPDATED_ON+" desc",r=" where "+Wt.COLUMN_NAME_IDENTIFIER+" in ("+t+") AND "+Wt.COLUMN_NAME_REF_COUNT+" > 0";return"select * from "+Wt.TABLE_NAME+" "+r+" "+n},e.getFindAllContentsQuery=function(){return"select * from "+Wt.TABLE_NAME+" where "+Wt.COLUMN_NAME_REF_COUNT+" > 0"},e.constructContentDBModel=function(t,n,r,i,o,a,c,s,u,f,l,h,d,p,b){var _;return(_={})[Wt.COLUMN_NAME_IDENTIFIER]=t,_[Wt.COLUMN_NAME_SERVER_DATA]="",_[Wt.COLUMN_NAME_PATH]=e.getBasePath(c),_[Wt.COLUMN_NAME_REF_COUNT]=s,_[Wt.COLUMN_NAME_CONTENT_STATE]=u,_[Wt.COLUMN_NAME_SIZE_ON_DEVICE]=h,_[Wt.COLUMN_NAME_MANIFEST_VERSION]=n,_[Wt.COLUMN_NAME_LOCAL_DATA]=r,_[Wt.COLUMN_NAME_MIME_TYPE]=i,_[Wt.COLUMN_NAME_CONTENT_TYPE]=o,_[Wt.COLUMN_NAME_VISIBILITY]=a,_[Wt.COLUMN_NAME_AUDIENCE]=f,_[Wt.COLUMN_NAME_PRAGMA]=l,_[Wt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]=ye().format(),_[Wt.COLUMN_NAME_BOARD]=e.getContentAttribute(d),_[Wt.COLUMN_NAME_MEDIUM]=e.getContentAttribute(p),_[Wt.COLUMN_NAME_GRADE]=e.getContentAttribute(b),_},e.getReferenceCount=function(e,t){var n;return e?(n=e[Wt.COLUMN_NAME_REF_COUNT],Dn.DEFAULT.valueOf()===e[Wt.COLUMN_NAME_VISIBILITY]&&Dn.DEFAULT.valueOf()===t||(n+=1)):n=1,n},e.getContentVisibility=function(e,t,n){var r;return"Library"===t?r=Dn.PARENT.valueOf():e&&!Dn.PARENT.valueOf()===e[Wt.COLUMN_NAME_VISIBILITY]&&(r=e[Wt.COLUMN_NAME_VISIBILITY]),r||n},e.getContentState=function(e,t){return e&&e[Wt.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[Wt.COLUMN_NAME_CONTENT_STATE]),t},e.isFreeSpaceAvailable=function(e,t,n){var r=10240;return n>0&&(r=n),e>0&&e>t+r},e.transferCount=function(e){var t=e.transferCount;return parseInt(t,0)},e.isContentMetadataAbsent=function(e){return!Boolean(e.contentMetaData)},e.isContentMetadataPresentWithoutViralityMetadata=function(e){return!Boolean(e.contentMetaData.virality)},e.defaultCompatibilityLevel=1,e.DEFAULT_PACKAGE_VERSION=-1,e.INITIAL_VALUE_FOR_TRANSFER_COUNT=0,e.MAX_CONTENT_NAME=30,e}(),Qr=function(){function e(e){this.fileService=e}return e.prototype.execute=function(e){var t=this,n=new D,r="profiles_"+ye().format("YYYYMMDDhhmmss")+".epar";return this.fileService.createDir(e.destinationFolder.concat("Profile"),!1).then((function(e){return t.fileService.createFile(e.nativeURL,r,!0)})).then((function(t){return e.destinationDBFilePath=t.nativeURL,n.body=e,n}))},e}(),$r=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Zr=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ei=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){return $r(this,void 0,void 0,(function(){var t;return Zr(this,(function(n){return t=new D,[2,this.dbService.copyDatabase(e.destinationDBFilePath).toPromise().then((function(n){return t.body=e,t})).then((function(){return t.body=e,t}))]}))}))},e}(),ti=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ni=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ri=function(){function e(e,t,n){this.dbService=e,this.fileService=t,this.deviceInfo=n}return e.prototype.execute=function(e){return ti(this,void 0,void 0,(function(){var t,n,r=this;return ni(this,(function(i){return t=new D,n=this.generateMetaData(e.userIds,e.groupIds),[2,this.dbService.open(e.destinationDBFilePath).then((function(){return r.dbService.execute(wt.getCreateEntry(),!0).toPromise()})).then((function(){return r.populateMetaData(n)})).then((function(){return t.body=e,t})).catch((function(e){throw console.log("error",e),t}))]}))}))},e.prototype.generateMetaData=function(e,t){var n={version:20};return n.types=JSON.stringify(["userprofile"]),n.did=this.deviceInfo.getDeviceID(),n.export_id=nr.generateUniqueId(),t||(t=[]),n.profiles_count=e.length+t.length,n},e.prototype.populateMetaData=function(e){return ti(this,void 0,void 0,(function(){var t=this;return ni(this,(function(n){return Object.keys(e).forEach((function(n){return ti(t,void 0,void 0,(function(){var t;return ni(this,(function(r){switch(r.label){case 0:return t={key:n,value:e[n]},[4,this.dbService.insert({table:wt.TABLE_NAME,modelJson:t,useExternalDb:!0}).toPromise()];case 1:return r.sent(),[2]}}))}))})),[2]}))}))},e}(),ii=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},oi=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ai=function(){function e(e,t){this.dbService=e,this.fileService=t}return e.prototype.execute=function(e){return ii(this,void 0,void 0,(function(){var t,n=this;return oi(this,(function(r){return t=new D,[2,this.getAllTables().then((function(e){var t=e.map((function(e){return e.name}));return n.removeTables(t,n.getAllTablesToExclude())})).then((function(){return n.deleteUnwantedProfilesAndUsers(e.userIds)})).then((function(){return n.deleteUnwantedProfileSummary(e.userIds)})).then((function(){return n.deleteUnwantedGroups(e.groupIds)})).then((function(){return n.deleteUnwantedGroupProfiles(e.groupIds)})).then((function(){return n.keepAllFrameworknChannel()})).then((function(){return n.fileService.getMetaData(e.destinationDBFilePath)})).then((function(t){return e.size=t.size.toString(),n.populateMetaData({FILE_SIZE:t.size})})).then((function(){return n.fileService.removeFile(e.destinationDBFilePath.concat("-journal"))})).then((function(){return t.body=e,t})).catch((function(e){throw t.errorMesg=Vn.EXPORT_FAILED,t}))]}))}))},e.prototype.getAllTables=function(){return this.dbService.execute("SELECT name FROM sqlite_master WHERE type = 'table'",!0).toPromise()},e.prototype.getAllTablesToExclude=function(){return[wt.TABLE_NAME,Lt.TABLE_NAME,It.TABLE_NAME,Ft.TABLE_NAME,Yt.TABLE_NAME,qt.TABLE_NAME,Ht.TABLE_NAME,on.TABLE_NAME]},e.prototype.removeTables=function(e,t){return ii(this,void 0,void 0,(function(){var n,r,i;return oi(this,(function(o){switch(o.label){case 0:n=0,r=e,o.label=1;case 1:return n<r.length?(i=r[n],Er.contains(t,i)?[3,3]:[4,this.dbService.execute("DROP TABLE IF EXISTS "+i,!0).toPromise()]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2,!0]}}))}))},e.prototype.populateMetaData=function(e){return ii(this,void 0,void 0,(function(){var t=this;return oi(this,(function(n){return Object.keys(e).forEach((function(n){return ii(t,void 0,void 0,(function(){var t;return oi(this,(function(r){switch(r.label){case 0:return t={key:n,value:e[n]},[4,this.dbService.insert({table:wt.TABLE_NAME,modelJson:t,useExternalDb:!0}).toPromise()];case 1:return r.sent(),[2]}}))}))})),[2]}))}))},e.prototype.deleteUnwantedProfilesAndUsers=function(e){return ii(this,void 0,void 0,(function(){var t,n,r,i,o,a,c;return oi(this,(function(s){switch(s.label){case 0:t=[],n=[],r=0,i=e,s.label=1;case 1:return r<i.length?(o=i[r],[4,this.dbService.read({table:It.TABLE_NAME,useExternalDb:!0,selection:It.COLUMN_NAME_UID+"=?",selectionArgs:[o],limit:"1"}).toPromise()]):[3,5];case 2:return(a=s.sent())&&a.length&&t.push(a[0][It.COLUMN_NAME_UID]),[4,this.dbService.read({table:Lt.TABLE_NAME,useExternalDb:!0,selection:Lt.COLUMN_NAME_UID+"=?",selectionArgs:[o],limit:"1"}).toPromise()];case 3:(c=s.sent())&&c.length&&n.push(c[0][Lt.COLUMN_NAME_UID]),s.label=4;case 4:return r++,[3,1];case 5:return[4,this.cleanTable(It.TABLE_NAME,It.COLUMN_NAME_UID,t)];case 6:return s.sent(),[4,this.cleanTable(Lt.TABLE_NAME,Lt.COLUMN_NAME_UID,t)];case 7:return s.sent(),[2]}}))}))},e.prototype.deleteUnwantedProfileSummary=function(e){return ii(this,void 0,void 0,(function(){return oi(this,(function(t){switch(t.label){case 0:return[4,this.cleanTable(Ft.TABLE_NAME,Ft.COLUMN_NAME_UID,e)];case 1:return t.sent(),[4,this.cleanTable(Yt.TABLE_NAME,Yt.COLUMN_NAME_UID,e)];case 2:return t.sent(),[2]}}))}))},e.prototype.deleteUnwantedGroups=function(e){return ii(this,void 0,void 0,(function(){var t,n,r,i,o;return oi(this,(function(a){switch(a.label){case 0:if(!e||!e.length)return[2];t=[],n=0,r=e,a.label=1;case 1:return n<r.length?(i=r[n],[4,this.dbService.read({table:qt.TABLE_NAME,useExternalDb:!0,selection:qt.COLUMN_NAME_GID+"=?",selectionArgs:[i],limit:"1"}).toPromise()]):[3,4];case 2:(o=a.sent())&&o.length&&t.push(o[0][Ht.COLUMN_NAME_GID]),a.label=3;case 3:return n++,[3,1];case 4:return[4,this.cleanTable(qt.TABLE_NAME,qt.COLUMN_NAME_GID,t)];case 5:return a.sent(),[2]}}))}))},e.prototype.deleteUnwantedGroupProfiles=function(e){return ii(this,void 0,void 0,(function(){var t,n,r,i,o;return oi(this,(function(a){switch(a.label){case 0:if(!e||!e.length)return[2];t=[],n=0,r=e,a.label=1;case 1:return n<r.length?(i=r[n],[4,this.dbService.read({table:Ht.TABLE_NAME,useExternalDb:!0,selection:Ht.COLUMN_NAME_GID+"=?",selectionArgs:[i],limit:"1"}).toPromise()]):[3,4];case 2:(o=a.sent())&&o.length&&t.push(o[0][It.COLUMN_NAME_UID]),a.label=3;case 3:return n++,[3,1];case 4:return[4,this.cleanTable(qt.TABLE_NAME,qt.COLUMN_NAME_GID,e)];case 5:return a.sent(),[2]}}))}))},e.prototype.keepAllFrameworknChannel=function(){return ii(this,void 0,void 0,(function(){var e,t,n=this;return oi(this,(function(r){switch(r.label){case 0:return e="SELECT * FROM "+on.TABLE_NAME+"\n WHERE "+on.COLUMN_NAME_KEY+" LIKE 'channel_details_key-%'\n OR "+on.COLUMN_NAME_KEY+" LIKE 'framework_details_key-%'\n OR "+on.COLUMN_NAME_KEY+" LIKE 'form-%'",[4,this.dbService.execute(e,!0).toPromise()];case 1:return t=r.sent(),[4,this.dbService.execute("DELETE FROM "+on.TABLE_NAME,!0)];case 2:return r.sent(),t.forEach((function(e){return ii(n,void 0,void 0,(function(){return oi(this,(function(t){switch(t.label){case 0:return[4,this.dbService.insert({table:on.TABLE_NAME,useExternalDb:!0,modelJson:e})];case 1:return t.sent(),[2]}}))}))})),[2]}}))}))},e.prototype.cleanTable=function(e,t,n){return ii(this,void 0,void 0,(function(){var r,i;return oi(this,(function(o){switch(o.label){case 0:return n&&n.length?(r=Er.joinPreservingQuotes(n),i="DELETE FROM "+e+"\n WHERE "+t+" NOT IN("+r+")",[4,this.dbService.execute(i,!0).toPromise()]):[2];case 1:return o.sent(),[2]}}))}))},e}(),ci=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=new D;return this.dbService.read({table:xt.TABLE_NAME}).toPromise().then((function(e){var t=[];e.forEach((function(e){var n={type:Ie.PROFILE,origin:e[xt.COLUMN_NAME_DEVICE_ID],identifier:e[xt.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)}));var n={dir:we.IN,type:Ce.FILE.valueOf(),items:t,env:"sdk"};return hr.log.share(n).toPromise()})).then((function(){return t.body=e,t}))},e}(),si=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=new D;return this.dbService.read({table:xt.TABLE_NAME}).toPromise().then((function(e){var t=[];e.forEach((function(e){var n={type:Ie.PROFILE,origin:e[xt.COLUMN_NAME_DEVICE_ID],identifier:e[xt.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)}));var n={dir:we.OUT,type:Ce.FILE.valueOf(),items:t,env:"sdk"};return hr.log.share(n).toPromise()})).then((function(){return t.body=e,t}))},e}(),ui=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.open(e.sourceDBFilePath).then((function(){return t.dbService.read({table:wt.TABLE_NAME,useExternalDb:!0}).toPromise()})).then((function(r){if(!r||!r.length)throw n.errorMesg=Vn.IMPORT_FAILED.valueOf(),n;var i={};r.forEach((function(e){i[e.key]=e.value})),e.metadata=i;var o=t.getImportTypes(i);if(o&&!Er.contains(o,"userprofile"))throw n.errorMesg=Vn.IMPORT_FAILED.valueOf(),n;return n.body=e,n}))},e.prototype.getImportTypes=function(e){var t=[];return e.hasOwnProperty("types")&&(t=JSON.parse(e.types)),t},e}(),fi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},li=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},hi=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:Lt.TABLE_NAME,useExternalDb:!0}).toPromise().then((function(n){return t.saveUsersToDb(e,n)})).then((function(){return n.body=e,n}))},e.prototype.saveUsersToDb=function(e,t){return fi(this,void 0,void 0,(function(){var e=this;return li(this,(function(n){return t.forEach((function(t){return fi(e,void 0,void 0,(function(){var e;return li(this,(function(n){switch(n.label){case 0:return delete t[Lt._ID],[4,this.dbService.read({table:It.TABLE_NAME,selection:Lt.COLUMN_NAME_UID+" = ?",selectionArgs:[t[Lt.COLUMN_NAME_UID]],limit:"1"}).toPromise()];case 1:return(e=n.sent())&&e.length?[3,3]:[4,this.dbService.insert({table:Lt.TABLE_NAME,modelJson:t}).toPromise()];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))})),[2]}))}))},e}(),di=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},pi=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},bi=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:qt.TABLE_NAME,useExternalDb:!0}).toPromise().then((function(n){return t.saveGroupsToDb(e,n)})).then((function(){return n.body=e,n}))},e.prototype.saveGroupsToDb=function(e,t){return di(this,void 0,void 0,(function(){var n,r,i=this;return pi(this,(function(o){return n=0,r=0,t.forEach((function(e){return di(i,void 0,void 0,(function(){var t;return pi(this,(function(i){switch(i.label){case 0:return[4,this.dbService.read({table:qt.TABLE_NAME,selection:qt.COLUMN_NAME_GID+" = ?",selectionArgs:[e[qt.COLUMN_NAME_GID]],limit:"1"}).toPromise()];case 1:return(t=i.sent())&&t.length?[3,3]:(e[qt.COLUMN_NAME_CREATED_AT]||(e[qt.COLUMN_NAME_CREATED_AT]=Date.now()),[4,this.dbService.insert({table:qt.TABLE_NAME,modelJson:e}).toPromise()]);case 2:return i.sent(),n++,[3,4];case 3:r++,i.label=4;case 4:return[2]}}))}))})),e.failed=e.failed?e.failed+r:r,e.imported=e.imported?e.imported+n:n,[2]}))}))},e}(),_i=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ei=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},yi=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:Ht.TABLE_NAME,useExternalDb:!0}).toPromise().then((function(n){return t.saveGroupProfilesToDb(e,n)})).then((function(){return n.body=e,n}))},e.prototype.saveGroupProfilesToDb=function(e,t){return _i(this,void 0,void 0,(function(){var e=this;return Ei(this,(function(n){return t.forEach((function(n){return _i(e,void 0,void 0,(function(){var e;return Ei(this,(function(r){switch(r.label){case 0:return delete n[Ht._ID],[4,this.dbService.read({table:Ht.TABLE_NAME,selection:Ht.COLUMN_NAME_GID+" = ? AND "+Ht.COLUMN_NAME_UID+" = ?",selectionArgs:[t[Ht.COLUMN_NAME_GID],n[Ht.COLUMN_NAME_UID]],limit:"1"}).toPromise()];case 1:return(e=r.sent())&&e.length?[3,3]:[4,this.dbService.insert({table:Ht.TABLE_NAME,modelJson:n})];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))})),[2]}))}))},e}(),vi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},gi=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},mi=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:on.TABLE_NAME,useExternalDb:!0}).toPromise().then((function(e){return t.saveNoSqlEntryToDb(e)})).then((function(){return n.body=e,n}))},e.prototype.saveNoSqlEntryToDb=function(e){return vi(this,void 0,void 0,(function(){var t=this;return gi(this,(function(n){return e.forEach((function(e){return vi(t,void 0,void 0,(function(){var t;return gi(this,(function(n){switch(n.label){case 0:return delete e[on._ID],[4,this.dbService.read({table:on.TABLE_NAME,selection:on.COLUMN_NAME_KEY+" = ?",selectionArgs:[e[on.COLUMN_NAME_KEY]],limit:"1"}).toPromise()];case 1:return(t=n.sent())&&t.length?[3,3]:[4,this.dbService.insert({table:on.TABLE_NAME,modelJson:e}).toPromise()];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))})),[2]}))}))},e}(),Si=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Oi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ai=function(e,t){return function(n,r){t(n,r,e)}},Ti=function(){function e(e,t,n,r,i,o){this.dbService=e,this.contenService=t,this.eventsBusService=n,this.courseService=r,this.sharedPreference=i,this.profileService=o,this.summarizerTelemetryHandler=new fo(this.courseService,this.sharedPreference,this,this.eventsBusService,this.contenService,this.profileService,this.dbService)}return e.prototype.onInit=function(){return this.eventsBusService.registerObserver({namespace:_e.TELEMETRY,observer:this}),Object(ie.of)(void 0)},e.prototype.getDetailsPerQuestion=function(e){var t=Ci.getQuetsionDetailsQuery(e.uids,e.contentId,e.qId);return this.dbService.execute(t).pipe(Object(ge.map)((function(e){return wi.mapDBEntriesToQuestionDetails(e)})))},e.prototype.getLearnerAssessmentDetails=function(e){var t=Ci.getDetailReportsQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(ge.map)((function(e){return wi.mapDBEntriesToLearnerAssesmentDetails(e)})))},e.prototype.getReportByQuestions=function(e){var t=this,n=Ci.getQuestionReportsQuery(e.uids,e.contentId),r=Ci.getReportAccuracyQuery(e.uids,e.contentId);return this.dbService.execute(r).pipe(Object(ge.map)((function(e){return wi.mapDBEntriesToAccuracy(e)})),Object(ge.mergeMap)((function(e){return t.dbService.execute(n).pipe(Object(ge.map)((function(t){return wi.mapDBEntriesToQuestionReports(e,t)})))})))},e.prototype.getReportsByUser=function(e){var t=Ci.getReportsByUserQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(ge.map)((function(e){return wi.mapDBEntriesToUserReports(e)})))},e.prototype.getSummary=function(e){var t,n=this;return e.uids?t=Ci.getChildProgressQuery(e.uids):e.contentId&&(t=Ci.getContentProgressQuery(e.contentId)),this.getContentCache(e.uids).pipe(Object(ge.mergeMap)((function(e){return n.dbService.execute(t).pipe(Object(ge.map)((function(t){return wi.mapDBEntriesToLearnerAssesmentSummary(t,e)})))})))},e.prototype.getContentCache=function(e){var t=this;if(this.contentMap&&Object.keys(this.contentMap).length)return Object(ie.of)(this.contentMap);this.contentMap=new Map;var n={resourcesOnly:!0,contentTypes:[],uid:e};return this.contenService.getContents(n).pipe(Object(ge.map)((function(e){return e.forEach((function(e){var n=new Ni;n.name=e.contentData&&e.contentData.name,n.totalScore=e.contentData&&e.contentData.totalScore,n.lastUsedTime=e.lastUsedTime,n.identifier=e.identifier,t.contentMap.set(e.identifier,n)})),t.contentMap})))},e.prototype.saveLearnerAssessmentDetails=function(e){var t=this,n=wi.mapTelemetryToLearnerAssesmentDetails(e),r=wi.mapLearnerAssesmentDetailsToDbEntries(n),i=Ci.getFilterForLearnerAssessmentDetails(n.qid,n.uid,n.contentId,n.hierarchyData),o=Ci.getLearnerAssessmentsQuery(i);return this.dbService.execute(o).pipe(Object(ge.mergeMap)((function(e){return e&&e.length?t.dbService.update({table:Ft.TABLE_NAME,selection:Ci.getUpdateSelection(),selectionArgs:[n.uid,n.contentId,n.hierarchyData?n.hierarchyData:"",n.qid],modelJson:r}).pipe(Object(ge.map)((function(e){return e>0}))):n.qid?t.dbService.insert({table:Ft.TABLE_NAME,modelJson:r}).pipe(Object(ge.map)((function(e){return e>0}))):Object(ie.of)(!1)})))},e.prototype.saveLearnerContentSummaryDetails=function(e){var t=this,n=wi.mapTelemetryToContentSummaryDetails(e),r=wi.mapContentSummaryDetailsToDbEntries(n);return this.dbService.read({table:Yt.TABLE_NAME,selection:Ci.getLearnerSummaryReadSelection(n.hierarchyData),selectionArgs:[n.uid,n.contentId,n.hierarchyData]}).pipe(Object(ge.mergeMap)((function(e){return e&&e.length?(r.sessions=e[0][Yt.COLUMN_NAME_SESSIONS]+1,r.avg_ts=it.toFixed(n.timespent/n.sessions),r.total_ts=n.timespent,r.last_updated_on=n.timestamp,t.dbService.update({table:Yt.TABLE_NAME,selection:Ci.getLearnerSummaryReadSelection(n.hierarchyData),selectionArgs:[n.uid,n.contentId,n.hierarchyData],modelJson:r}).pipe(Object(ge.map)((function(e){return e>0})))):(r.avg_ts=n.timespent,r.sessions=1,r.total_ts=n.timespent,r.last_updated_on=n.timestamp,t.dbService.insert({table:Yt.TABLE_NAME,modelJson:r}).pipe(Object(ge.map)((function(e){return e>0}))))})))},e.prototype.deletePreviousAssessmentDetails=function(e,t){var n=this;return this.dbService.read({table:Yt.TABLE_NAME,selection:Yt.COLUMN_NAME_CONTENT_ID+" = ? AND "+Yt.COLUMN_NAME_UID+" = ?",selectionArgs:[t,e]}).pipe(Object(ge.mergeMap)((function(r){return r&&r.length?n.dbService.delete({table:Yt.TABLE_NAME,selection:Yt.COLUMN_NAME_CONTENT_ID+" = ? AND "+Yt.COLUMN_NAME_UID+" = ?",selectionArgs:[t,e]}):Object(ie.of)(void 0)})),Object(ge.mergeMap)((function(){return n.dbService.read({table:Ft.TABLE_NAME,selection:Ft.COLUMN_NAME_CONTENT_ID+" = ? AND "+Ft.COLUMN_NAME_UID+" = ?",selectionArgs:[t,e]})})),Object(ge.mergeMap)((function(r){return r&&r.length?n.dbService.delete({table:Ft.TABLE_NAME,selection:Ft.COLUMN_NAME_CONTENT_ID+" = ? AND "+Ft.COLUMN_NAME_UID+" = ?",selectionArgs:[t,e]}):Object(ie.of)(void 0)})))},e.prototype.onEvent=function(e){return e.type===_r.SAVE?this.summarizerTelemetryHandler.handle(e.payload):Object(ie.of)(void 0)},e=Si([Object(I.injectable)(),Ai(0,Object(I.inject)(be.DB_SERVICE)),Ai(1,Object(I.inject)(be.CONTENT_SERVICE)),Ai(2,Object(I.inject)(be.EVENTS_BUS_SERVICE)),Ai(3,Object(I.inject)(be.COURSE_SERVICE)),Ai(4,Object(I.inject)(be.SHARED_PREFERENCES)),Ai(5,Object(I.inject)(be.PROFILE_SERVICE)),Oi("design:paramtypes",[C,Object,Object,Object,Object,Object])],e)}(),Ni=function(){},Mi=function(){this.reportDetailsList=[]},wi=function(){function e(){}return e.mapLearnerAssesmentDetailsToDbEntries=function(e){var t;return(t={})[Ft.COLUMN_NAME_UID]=e.uid,t[Ft.COLUMN_NAME_CONTENT_ID]=e.contentId,t[Ft.COLUMN_NAME_QID]=e.qid,t[Ft.COLUMN_NAME_Q_INDEX]=e.qindex,t[Ft.COLUMN_NAME_CORRECT]=e.correct,t[Ft.COLUMN_NAME_SCORE]=e.score,t[Ft.COLUMN_NAME_TIME_SPENT]=e.timespent,t[Ft.COLUMN_NAME_RES]=e.res,t[Ft.COLUMN_NAME_TIMESTAMP]=e.timestamp,t[Ft.COLUMN_NAME_Q_DESC]=e.qdesc,t[Ft.COLUMN_NAME_Q_TITLE]=e.qtitle,t[Ft.COLUMN_NAME_MAX_SCORE]=e.maxScore,t[Ft.COLUMN_NAME_HIERARCHY_DATA]=e.hierarchyData,t},e.mapContentSummaryDetailsToDbEntries=function(e){var t;return(t={})[Yt.COLUMN_NAME_UID]=e.uid,t[Yt.COLUMN_NAME_CONTENT_ID]=e.contentId,t[Yt.COLUMN_NAME_AVG_TS]=e.avgts,t[Yt.COLUMN_NAME_TOTAL_TS]=e.totalts,t[Yt.COLUMN_NAME_LAST_UPDATED_ON]=e.lastUpdated,t[Ft.COLUMN_NAME_HIERARCHY_DATA]=e.hierarchyData,t},e.mapDBEntriesToLearnerAssesmentSummary=function(e,t){return e.map((function(e){var n=t.get(e[Yt.COLUMN_NAME_CONTENT_ID]);return{uid:e[Yt.COLUMN_NAME_UID].toString(),contentId:e[Yt.COLUMN_NAME_CONTENT_ID].toString(),noOfQuestions:it.parseInt(e[Yt.COLUMN_NAME_NO_OF_QUESTIONS]),correctAnswers:it.parseInt(e[Yt.COLUMN_NAME_CORRECT_ANSWERS]),totalTimespent:Number(e[Yt.COLUMN_NAME_TOTAL_TIME_SPENT]),hierarchyData:e[Yt.COLUMN_NAME_HIERARCHY_DATA].toString(),totalMaxScore:it.toFixed(e[Yt.COLUMN_NAME_TOTAL_MAX_SCORE]),totalScore:it.toFixed(e[Yt.COLUMN_NAME_TOTAL_SCORE]),totalQuestionsScore:n?n.totalScore:0,name:n?n.name:e[Yt.COLUMN_NAME_CONTENT_ID]}}))},e.mapDBEntriesToLearnerAssesmentDetails=function(e){var t=new Map;return e.map((function(e){var n={uid:e[Ft.COLUMN_NAME_UID],contentId:e[Ft.COLUMN_NAME_CONTENT_ID],qid:e[Ft.COLUMN_NAME_QID],qindex:Number(e[Ft.COLUMN_NAME_Q_INDEX]),correct:it.parseInt(e[Ft.COLUMN_NAME_CORRECT]),score:it.toFixed(e[Ft.COLUMN_NAME_SCORE]),timespent:Number(e[Ft.COLUMN_NAME_TIME_SPENT]),res:e[Ft[Ft.COLUMN_NAME_RES]],timestamp:Number(e[Ft.COLUMN_NAME_TIMESTAMP]),qdesc:e[Ft.COLUMN_NAME_Q_DESC],qtitle:e[Ft.COLUMN_NAME_Q_TITLE],maxScore:it.toFixed(e[Ft.COLUMN_NAME_MAX_SCORE]),hierarchyData:e[Ft.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(e[Ft.COLUMN_NAME_TOTAL_TS])},r=t.get(n.uid);void 0===r&&((r=new Mi).uid=n.uid,r.totalScore=0,r.maxTotalScore=0),r.reportDetailsList.push(n),r.totalScore+=n.score,r.totalTime=n.total_ts,r.maxTotalScore+=n.maxScore,r.totalScore=parseFloat(r.totalScore.toFixed(2)),t.set(n.uid,r)})),t},e.mapDBEntriesToQuestionReports=function(e,t){return t.map((function(t){var n=t[Ft.COLUMN_NAME_QID],r=0;return e.hasOwnProperty(n)&&(r=it.parseInt(e[n])),{uid:t[Ft.COLUMN_NAME_UID],contentId:t[Ft.COLUMN_NAME_CONTENT_ID],qid:t[Ft.COLUMN_NAME_QID],qindex:Number(t[Ft.COLUMN_NAME_Q_INDEX]),correct:it.parseInt(t[Ft.COLUMN_NAME_CORRECT]),score:it.toFixed(t[Ft.COLUMN_NAME_SCORE]),timespent:Number(t[Ft.COLUMN_NAME_TIME_SPENT]),res:t[Ft[Ft.COLUMN_NAME_RES]],timestamp:Number(t[Ft.COLUMN_NAME_TIMESTAMP]),qdesc:t[Ft.COLUMN_NAME_Q_DESC],qtitle:t[Ft.COLUMN_NAME_Q_TITLE],maxScore:it.toFixed(t[Ft.COLUMN_NAME_MAX_SCORE]),hierarchyData:t[Ft.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(t[Ft.COLUMN_NAME_TOTAL_TS]),marks:Number(t[Ft.COLUMN_NAME_MARKS]),occurenceCount:t[Ft.COLUMN_NAME_COUNT],sum_max_score:Number(t[Ft.COLUMN_NAME_TOTAL_MAX_SCORE]),correct_users_count:r}}))},e.mapDBEntriesToAccuracy=function(e){var t={};return e.map((function(e){t[e[Ft.COLUMN_NAME_QID]]=it.parseInt(e[Ft.COLUMN_NAME_USERS_COUNT])})),t},e.mapDBEntriesToQuestionDetails=function(e){return e.map((function(e){return{uid:e.uid,time:Number(e.time),result:it.round(e.result),max_score:it.parseInt(e.max_score)}}))},e.mapDBEntriesToUserReports=function(e){return e.map((function(e){return{totalTimespent:Number(e[Ft.COLUMN_NAME_TOTAL_TS]),score:it.toFixed(e[Ft.COLUMN_NAME_SCORE]),hData:e[Ft.COLUMN_NAME_HIERARCHY_DATA],contentId:e[Ft.COLUMN_NAME_CONTENT_ID],uid:e[Ft.COLUMN_NAME_UID],userName:e[Ft.COLUMN_NAME_HANDLE],timespent:Number(e[Ft.COLUMN_NAME_TIME_SPENT])}}))},e.mapTelemetryToContentSummaryDetails=function(e){var t=e.edata,n=(t.item,e.context.cdata);return{uid:e.actor.id,contentId:e.object.id,timespent:Number(t.duration),timestamp:e.ets,hierarchyData:this.getHierarchyData(n)}},e.mapTelemetryToLearnerAssesmentDetails=function(e){var t=e.edata,n=t.item,r=e.context.cdata;return{uid:e.actor.id,contentId:e.object.id,qid:n&&n.id,qindex:Number(t.index),correct:"Yes"===t.pass?1:0,score:Number(t.score),timespent:Number(t.duration),timestamp:e.ets,res:JSON.stringify(t.resvalues),qdesc:n&&n.desc,qtitle:n&&n.title,maxScore:n&&Number(n.maxscore),hierarchyData:this.getHierarchyData(r)}},e.getHierarchyData=function(e){return e&&e.forEach((function(e){if("Collection"===e.type||"TextBook"===e.type)return e.id})),""},e}(),Ci=function(){function e(){}return e.getChildProgressQuery=function(e){return"SELECT "+Ft.COLUMN_NAME_UID+", "+Ft.COLUMN_NAME_CONTENT_ID+",\n COUNT ("+Ft.COLUMN_NAME_QID+") AS no_of_questions,\n SUM ("+Ft.COLUMN_NAME_CORRECT+") AS correct_answers,\n SUM ("+Ft.COLUMN_NAME_TIME_SPENT+") AS total_time_spent, h_data ,\n SUM ("+Ft.COLUMN_NAME_MAX_SCORE+") AS total_max_score,\n SUM ("+Ft.COLUMN_NAME_SCORE+") AS total_score\n FROM "+Ft.TABLE_NAME+"\n WHERE "+Ft.COLUMN_NAME_UID+" IN ("+Er.joinPreservingQuotes(e)+")\n GROUP BY "+Ft.COLUMN_NAME_CONTENT_ID+" "},e.getContentProgressQuery=function(e){return"SELECT "+Ft.COLUMN_NAME_UID+", "+Ft.COLUMN_NAME_CONTENT_ID+",\n COUNT ("+Ft.COLUMN_NAME_QID+") AS no_of_questions,\n SUM ("+Ft.COLUMN_NAME_CORRECT+") AS correct_answers,\n SUM ("+Ft.COLUMN_NAME_TIME_SPENT+") AS total_time_spent, h_data ,\n SUM ("+Ft.COLUMN_NAME_MAX_SCORE+") AS total_max_score,\n FROM "+Ft.TABLE_NAME+"\n WHERE "+Ft.COLUMN_NAME_CONTENT_ID+" = '"+e+"'\n GROUP BY "+Ft.COLUMN_NAME_UID+" "},e.getDetailReportsQuery=function(e,t){return"SELECT *, lcs."+Yt.COLUMN_NAME_TOTAL_TS+"\n FROM "+Ft.TABLE_NAME+" la\n LEFT JOIN "+Yt.TABLE_NAME+" lcs\n ON (la."+Yt.COLUMN_NAME_UID+" = lcs."+Ft.COLUMN_NAME_UID+")\n AND la."+Yt.COLUMN_NAME_CONTENT_ID+" = lcs."+Ft.COLUMN_NAME_CONTENT_ID+"\n WHERE la."+Ft.COLUMN_NAME_UID+" IN("+Er.joinPreservingQuotes(e)+")\n AND la."+Ft.COLUMN_NAME_CONTENT_ID+"='"+t+"'"},e.getReportsByUserQuery=function(e,t){return"SELECT lcs."+Yt.COLUMN_NAME_TOTAL_TS+",\n SUM ("+Ft.COLUMN_NAME_SCORE+") AS score,\n la."+Ft.COLUMN_NAME_HIERARCHY_DATA+",la."+Ft.COLUMN_NAME_CONTENT_ID+",\n la."+Ft.COLUMN_NAME_UID+",p."+It.COLUMN_NAME_HANDLE+",\n la."+Ft.COLUMN_NAME_TIME_SPENT+"\n FROM "+Ft.TABLE_NAME+" la\n LEFT JOIN "+Yt.TABLE_NAME+" lcs\n ON (la."+Yt.COLUMN_NAME_UID+" = lcs."+Ft.COLUMN_NAME_UID+")\n LEFT JOIN "+It.TABLE_NAME+" p\n ON (la."+Ft.COLUMN_NAME_UID+" = p."+It.COLUMN_NAME_UID+")\n WHERE la."+Ft.COLUMN_NAME_UID+" IN("+Er.joinPreservingQuotes(e)+")\n AND la."+Ft.COLUMN_NAME_CONTENT_ID+"='"+t+"'\n GROUP BY la."+Ft.COLUMN_NAME_UID},e.getQuetsionDetailsQuery=function(e,t,n){return"SELECT "+Ft.COLUMN_NAME_UID+", "+Ft.COLUMN_NAME_TIME_SPENT+" as time,\n "+Ft.COLUMN_NAME_SCORE+" as result,\n "+Ft.COLUMN_NAME_MAX_SCORE+" as max_score\n FROM "+Ft.TABLE_NAME+"\n WHERE "+Ft.COLUMN_NAME_UID+" IN("+Er.joinPreservingQuotes(e)+")\n AND "+Ft.COLUMN_NAME_CONTENT_ID+"='"+t+"'\n AND "+Ft.COLUMN_NAME_QID+"='"+n+"'"},e.getReportAccuracyQuery=function(e,t){return"SELECT "+Ft.COLUMN_NAME_QID+", COUNT (*) as users_count\n FROM "+Ft.TABLE_NAME+"\n WHERE "+Ft.COLUMN_NAME_UID+" IN("+Er.joinPreservingQuotes(e)+")\n AND "+Ft.COLUMN_NAME_CONTENT_ID+"='"+t+"'\n AND "+Ft.COLUMN_NAME_SCORE+" > 0\n GROUP BY "+Ft.COLUMN_NAME_QID},e.getQuestionReportsQuery=function(e,t){return"SELECT *, SUM("+Ft.COLUMN_NAME_SCORE+") as marks,\n COUNT ("+Ft.COLUMN_NAME_Q_INDEX+") as occurence_count,\n SUM ("+Ft.COLUMN_NAME_MAX_SCORE+") as sum_max_score\n FROM "+Ft.TABLE_NAME+"\n WHERE "+Ft.COLUMN_NAME_UID+" IN("+Er.joinPreservingQuotes(e)+")\n AND "+Ft.COLUMN_NAME_CONTENT_ID+"='"+t+"'\n GROUP BY "+Ft.COLUMN_NAME_QID},e.getFilterForLearnerAssessmentDetails=function(e,t,n,r){var i=Ft.COLUMN_NAME_QID+" = '"+e+"'";return"WHERE "+(Ft.COLUMN_NAME_UID+" = '"+t+"'")+" AND "+(Ft.COLUMN_NAME_CONTENT_ID+" = '"+n+"'")+" AND "+(Ft.COLUMN_NAME_HIERARCHY_DATA+" = '"+(r||"")+"'")+" "+(e?" AND "+i:"")},e.getLearnerAssessmentsQuery=function(e){return"SELECT * from "+Ft.TABLE_NAME+" "+e+"\n ORDER BY "+Ft.COLUMN_NAME_Q_INDEX},e.getUpdateSelection=function(){return Ft.COLUMN_NAME_UID+" = ? AND\n "+Ft.COLUMN_NAME_CONTENT_ID+" = ? AND\n "+Ft.COLUMN_NAME_HIERARCHY_DATA+" = ? AND\n "+Ft.COLUMN_NAME_QID+" = ? "},e.getLearnerSummaryReadSelection=function(e){return Ft.COLUMN_NAME_UID+" = ? AND\n "+Ft.COLUMN_NAME_CONTENT_ID+" = ? AND\n "+Ft.COLUMN_NAME_HIERARCHY_DATA+" = ? "},e}(),Ii=function(){function e(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_BATCH_DETAILS_ENDPOINT="/batch/read/"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.courseServiceConfig.apiPath+this.GET_BATCH_DETAILS_ENDPOINT+e.batchId).withApiToken(!0).withSessionToken(!0).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result.response})))},e}(),Pi=function(){function e(e,t){this.apiService=e,this.courseServiceConfig=t,this.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.PATCH).withPath(this.courseServiceConfig.apiPath+this.UPDATE_CONTENT_STATE_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result})))},e}(),Li=function(){function e(e,t,n,r){this.apiService=e,this.courseServiceConfig=t,this.profileService=n,this.authService=r,this.GET_COURSE_BATCHES="/batch/list"}return e.prototype.handle=function(e){var t=this,n=(new F.Builder).withType(R.POST).withPath(this.courseServiceConfig.apiPath+this.GET_COURSE_BATCHES).withApiToken(!0).withSessionToken(!1).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return Array.from(new Set(e.body.result.response.content))})),Object(ge.switchMap)((function(e){return t.authService.getSession().pipe(Object(ge.mergeMap)((function(n){return n?t.profileService.getServerProfiles({limit:e.length,filters:{identifier:new Set(e.map((function(e){return e.createdBy})))},fields:["firstName","lastName","identifier"]}).pipe(Object(ge.map)((function(t){return e.forEach((function(e){e.creatorFirstName=t.find((function(t){return t.identifier===e.createdBy})).firstName,e.creatorLastName=t.find((function(t){return t.identifier===e.createdBy})).lastName})),e}))):Object(ie.of)(e)})))})))},e}(),Ri=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Di=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ji=function(){function e(e,t,n,r){this.keyValueStore=e,this.apiService=t,this.courseServiceConfig=n,this.sharedPreference=r,this.GET_ENROLLED_COURSES_ENDPOINT="/user/enrollment/list/",this.STORED_ENROLLED_COURSES_PREFIX="enrolledCourses"}return e.prototype.handle=function(e){var t=this;return this.keyValueStore.getValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId).pipe(Object(ge.mergeMap)((function(n){if(n){if(e.returnFreshCourses)return t.fetchFromServer(e).pipe(Object(ge.mergeMap)((function(n){return t.keyValueStore.setValue(t.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(n)).pipe(Object(ge.mapTo)(n.result.courses),Object(ge.tap)((function(e){return Object(ie.from)(t.updateLastPlayedContent(e))})))})),Object(ge.catchError)((function(){var e,t=JSON.parse(n),r=t.result;return e=r&&r.hasOwnProperty("courses")?r.courses:t.courses,Object(ie.of)(e)})));var r=JSON.parse(n),i=r.result,o=void 0;return o=i&&i.hasOwnProperty("courses")?i.courses:r.courses,Object(ie.of)(o)}return t.fetchFromServer(e).pipe(Object(ge.mergeMap)((function(n){return t.keyValueStore.setValue(t.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(n)).pipe(Object(ge.mapTo)(n.result.courses),Object(ge.tap)((function(e){return Object(ie.from)(t.updateLastPlayedContent(e))})))})))})))},e.prototype.updateLastPlayedContent=function(e){return Ri(this,void 0,void 0,(function(){var t,n,r,i,o;return Di(this,(function(a){switch(a.label){case 0:t=0,n=e,a.label=1;case 1:return t<n.length?(r=n[t],i=ao.LAST_READ_CONTENTID_PREFIX.concat("_").concat(r.userId).concat("_").concat(r.contentId).concat("_").concat(r.batchId),o=r.lastReadContentId,r.lastReadContentId?[4,this.sharedPreference.putString(i,o).toPromise()]:[3,3]):[3,4];case 2:a.sent(),a.label=3;case 3:return t++,[3,1];case 4:return[2,Promise.resolve(!0)]}}))}))},e.prototype.fetchFromServer=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.courseServiceConfig.apiPath+this.GET_ENROLLED_COURSES_ENDPOINT+e.userId+"?orgdetails=orgName,email&fields=contentType,topic,name,channel,pkgVersion&batchDetails=name,endDate,startDate,status,enrollmentType,createdBy,certificates").withApiToken(!0).withSessionToken(!0).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body})))},e}(),Ui=function(){function e(e,t){this.apiService=e,this.courseServiceConfig=t,this.ENROL_ENDPOINT="/enrol"}return e.prototype.handle=function(e){delete e.batchStatus;var t=(new F.Builder).withType(R.POST).withPath(this.courseServiceConfig.apiPath+this.ENROL_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return"SUCCESS"===e.body.result.response})))},e}(),ki=function(){function e(e,t){this.apiService=e,this.unenrollCourseServiceApiConfig=t,this.GET_UNENROLL_COURSE_ENDPOINT="/unenrol"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.unenrollCourseServiceApiConfig.apiPath+this.GET_UNENROLL_COURSE_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return"SUCCESS"===e.body.result.response})))},e}(),xi=function(){function e(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_CONTENT_STATE_KEY_PREFIX="getContentState",this.GET_CONTENT_STATE_ENDPOINT="/content/state/read"}return e.prototype.handle=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.courseServiceConfig.apiPath+this.GET_CONTENT_STATE_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body})))},e}(),Bi=function(){function e(e,t){this.keyValueStore=e,this.offlineContentStateHandler=t}return e.prototype.updateEnrollCourses=function(t){var n=this,r=e.GET_ENROLLED_COURSES_KEY_PREFIX.concat(t.userId);return this.offlineContentStateHandler.getLocalContentStateResponse(t).pipe(Object(ge.mergeMap)((function(e){return n.keyValueStore.getValue(r).pipe(Object(ge.mergeMap)((function(i){if(i){var o=JSON.parse(i),a=o.result,c=void 0,s=(c=a&&a.hasOwnProperty("courses")?a.courses:o.courses).slice();return c.forEach((function(n){if(n.courseId===t.courseIds[0]&&n.batchId===t.batchId){var r=n;e.contentList.forEach((function(e){if(2===e.status){var t=n.contentsPlayedOffline;t||(t=[]),t.push(e.contentId),r.contentsPlayedOffline=Er.deDupe(t)}}));var i=s.findIndex((function(e){return e.contentId===n.contentId&&e.batchId===n.batchId}));s.splice(i,1,r)}})),s&&s.length?(a&&a.hasOwnProperty("courses")?a.courses=s:o.courses=s,n.keyValueStore.setValue(r,JSON.stringify(o)).pipe(Object(ge.map)((function(){return e})))):Object(ie.of)(e)}return Object(ie.of)(e)})))})))},e.GET_ENROLLED_COURSES_KEY_PREFIX="enrolledCourses",e}(),Fi=function(){function e(e){this.keyValueStore=e}return e.prototype.getLocalContentStateResponse=function(e){var t=ao.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseIds[0]);return this.keyValueStore.getValue(t).pipe(Object(ge.map)((function(e){var t={contentList:[]};if(e){var n=JSON.parse(e),r=n.result;return r&&r.hasOwnProperty("contentList")?(t.contentList=r.contentList,t):(t.contentList=n.contentList,t)}return t})))},e.prototype.manipulateEnrolledCoursesResponseLocally=function(e){var t=this,n=ao.GET_ENROLLED_COURSE_KEY_PREFIX.concat(e.userId);return this.keyValueStore.getValue(n).pipe(Object(ge.mergeMap)((function(r){if(r){var i=JSON.parse(r),o=i.result,a=void 0;if((a=o&&o.hasOwnProperty("courses")?o.courses:i.courses)&&a.length){var c=a.slice();return a.forEach((function(n){if(n.courseId===e.courseId&&n.batchId===e.batchId&&(n.contentsPlayedOffline&&n.contentsPlayedOffline.length||(n.contentsPlayedOffline=[]),1!==e.status&&(0===n.contentsPlayedOffline.length||n.contentsPlayedOffline.length>0&&!Er.contains(n.contentsPlayedOffline,e.contentId)))){n.progress=n.progress?n.progress:0,n.progress=n.progress+1,n.completionPercentage=t.getCourseCompletionPercentage(n.leafNodesCount,n.progress);var r=n,i=r.contentsPlayedOffline;i||(i=[]),i.push(e.contentId),r.contentsPlayedOffline=i,r.progress=n.progress,r.completionPercentage=n.completionPercentage;var o=c.findIndex((function(e){return e.contentId===n.contentId||e.batchId===n.batchId}));c.splice(o,1,r)}})),c&&c.length?(o&&o.hasOwnProperty("courses")?o.courses=c:i.courses=c,t.keyValueStore.setValue(n,JSON.stringify(i))):Object(ie.of)(!1)}return Object(ie.of)(!1)}return Object(ie.of)(!1)})))},e.prototype.manipulateGetContentStateResponseLocally=function(e){var t=this,n=ao.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(n).pipe(Object(ge.mergeMap)((function(r){if(r){var i={contentList:[]},o=JSON.parse(r),a=o.result;if(a&&a.hasOwnProperty("contentList")?i.contentList=a.contentList:i.contentList=o.contentList,i){var c,s=i.contentList;return s&&s.length?(s.forEach((function(n){n.contentId===e.contentId?n.status!==e.status&&(c=t.getContentState(e),s=s.filter((function(e){return e.contentId!==n.contentId}))):c=t.getContentState(e)})),c?(s.push(c),i.contentList=s,t.keyValueStore.setValue(n,JSON.stringify(i))):Object(ie.of)(!1)):(c=t.getContentState(e),(s=[]).push(c),i.contentList=s,t.keyValueStore.setValue(n,JSON.stringify(i)))}return Object(ie.of)(!1)}return Object(ie.of)(!1)})))},e.prototype.getCourseCompletionPercentage=function(e,t){if(0===e||void 0===e)return 0;var n=t/e*100;return isNaN(n)?0:n>100?100:Math.floor(n)},e.prototype.getContentState=function(e){var t={};return t.id=e.userId,t.courseId=e.courseId,t.contentId=e.contentId,t.batchId=e.batchId,t.result=e.result,t.grade=e.grade,t.score=e.score,t.status=e.status,t.progress=e.progress,t},e}(),Vi=function(){function e(){}return e.getUpdateContentStateRequest=function(e){var t=[];return t.push(this.getRequestMap(e)),{userId:e.userId,contents:t}},e.getUpdateContentStateListRequest=function(e,t){var n=this,r=[];return t.forEach((function(e){r.push(n.getRequestMap(e))})),{userId:e,contents:r}},e.getRequestMap=function(e){var t={};return t.contentId=e.contentId,t.courseId=e.courseId,t.batchId=e.batchId,t.status=e.status,t.progress=e.progress,e.result&&(t.result=e.result),e.grade&&(t.grade=e.grade),e.score&&(t.score=e.score),t},e}(),Yi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Gi=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Hi=function(){function e(e,t,n,r){this.updateContentStateHandler=e,this.dbService=t,this.sharedPreferences=n,this.keyValueStore=r}return e.prototype.updateContentState=function(){var e=this;return this.prepareContentStateRequest().pipe(Object(ge.mergeMap)((function(t){return Object(ie.from)(e.invokeContentStateAPI(t))})))},e.prototype.prepareContentStateRequest=function(){var e="SELECT * FROM "+on.TABLE_NAME+"\n WHERE "+on.COLUMN_NAME_KEY+"\n LIKE '%%"+ao.UPDATE_CONTENT_STATE_KEY_PREFIX+"%%'";return this.dbService.execute(e).pipe(Object(ge.map)((function(e){var t={};return e.forEach((function(e){var n=JSON.parse(e.value);if(n&&n.userId)if(t.hasOwnProperty(n.userId))t[n.userId].push(n);else{t[n.userId]=[n]}})),t})))},e.prototype.invokeContentStateAPI=function(e){return Yi(this,void 0,void 0,(function(){var t,n,r,i;return Gi(this,(function(o){switch(o.label){case 0:t=0,n=Object.keys(e),o.label=1;case 1:if(!(t<n.length))return[3,8];r=n[t],o.label=2;case 2:return o.trys.push([2,6,,7]),[4,this.updateContentStateHandler.handle(Vi.getUpdateContentStateListRequest(r,e[r])).toPromise()];case 3:return(i=o.sent())?[4,this.deleteContentState(e[r],i)]:[3,5];case 4:o.sent(),o.label=5;case 5:return[3,7];case 6:return o.sent(),[3,7];case 7:return t++,[3,1];case 8:return[2,Promise.resolve(!0)]}}))}))},e.prototype.deleteContentState=function(e,t){return Yi(this,void 0,void 0,(function(){var n,r,i,o,a,c=this;return Gi(this,(function(s){switch(s.label){case 0:n=function(e){var n;return Gi(this,(function(i){switch(i.label){case 0:return t.hasOwnProperty(e.contentId)||t[e.contentId]&&"FAILED"!==t[e.contentId]?(n=ao.UPDATE_CONTENT_STATE_KEY_PREFIX.concat(e.userId).concat(e.courseId).concat(e.contentId).concat(e.batchId),[4,r.keyValueStore.getValue(n).pipe(Object(ge.map)((function(e){if(e){var t="DELETE FROM "+on.TABLE_NAME+"\n WHERE "+on.COLUMN_NAME_KEY+" = '"+n+"' ";return c.dbService.execute(t).pipe(Object(ge.mapTo)(!0))}return Object(ie.of)(!0)}))).toPromise()]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))},r=this,i=0,o=e,s.label=1;case 1:return i<o.length?(a=o[i],[5,n(a)]):[3,4];case 2:s.sent(),s.label=3;case 3:return i++,[3,1];case 4:return[2,Promise.resolve(!0)]}}))}))},e}(),qi=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zi=function(e){function t(n){var r=e.call(this,n,"PROCESSING_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return qi(t,e),t}(U),Ki=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Wi=function(e){function t(n){var r=e.call(this,n,"NO_CERTIFICATE_FOUND")||this;return Object.setPrototypeOf(r,t.prototype),r}return Ki(t,e),t}(U),Xi=function(){function e(){}return e.getFileExtension=function(e){var t=e.substring(e.lastIndexOf(".")+1,e.length);return t||""},e.getFileName=function(e){return e.substring(e.lastIndexOf("/")+1)},e.getParentDir=function(e){return e.substr(0,e.lastIndexOf("/",e.length-2)).concat("/")},e.getDirectoryName=function(e){var t=e.split("/");return t[t.length-2]},e.getTempDirPath=function(e){return e+"/tmp"},e.isFreeSpaceAvailable=function(e,t,n){var r=10240;return n>0&&(r=n),e>0&&e>t+r},e.getDirecory=function(e){return e.substr(0,e.lastIndexOf("/"))},e}();!function(e){e.START="START",e.PROGRESS="PROGRESS",e.END="END"}(jr||(jr={})),function(e){e[e.STATUS_FAILED=16]="STATUS_FAILED",e[e.STATUS_PAUSED=4]="STATUS_PAUSED",e[e.STATUS_PENDING=1]="STATUS_PENDING",e[e.STATUS_RUNNING=2]="STATUS_RUNNING",e[e.STATUS_SUCCESSFUL=8]="STATUS_SUCCESSFUL"}(Ur||(Ur={}));var Ji,Qi,$i=n(119),Zi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},eo=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},to=function(){function e(e,t,n,r){this.courseService=e,this.sdkConfig=t,this.apiService=n,this.dbService=r,this.capturedAssessmentEvents={}}return e.prototype.handle=function(e){var t=this;return this.capturedAssessmentEvents=e,Object(ie.from)(this.syncCapturedAssessmentEvents().then((function(){t.capturedAssessmentEvents={}})).then((function(){return t.syncPersistedAssessmentEvents()})).catch((function(){Object.keys(t.capturedAssessmentEvents).forEach((function(e){var n=JSON.parse(e);t.capturedAssessmentEvents[e].forEach((function(e){2!==n.batchStatus&&t.persistAssessEvent(e,n).toPromise()}))}))}))).pipe(Object(ge.mapTo)(void 0))},e.prototype.invokeSyncApi=function(t){var n=(new F.Builder).withPath(this.sdkConfig.courseServiceConfig.apiPath+e.UPDATE_CONTENT_STATE_ENDPOINT).withType(R.PATCH).withBody({request:t}).withApiToken(!0).withSessionToken(!0).build();return this.apiService.fetch(n).toPromise()},e.prototype.persistAssessEvent=function(e,t){var n;return this.dbService.insert({table:ln.TABLE_NAME,modelJson:(n={},n[ln.COLUMN_NAME_ASSESSMENT_EVENT]=JSON.stringify(e),n[ln.COLUMN_NAME_CONTENT_ID]=e.object.id,n[ln.COLUMN_NAME_CREATED_AT]=e.ets,n[ln.COLUMN_NAME_USER_ID]=t.userId,n[ln.COLUMN_NAME_COURSE_ID]=t.courseId,n[ln.COLUMN_NAME_BATCH_ID]=t.batchId,n)}).pipe(Object(ge.mapTo)(void 0))},e.prototype.syncCapturedAssessmentEvents=function(){return Zi(this,void 0,void 0,(function(){var e,t=this;return eo(this,(function(n){return(e={assessments:Object.keys(this.capturedAssessmentEvents).map((function(e){var n=JSON.parse(e),r=t.capturedAssessmentEvents[e];return{assessmentTs:r.reduce((function(e,t){return t.ets<e?t.ets:e}),r[0].ets),userId:n.userId,contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,attemptId:t.courseService.generateAssessmentAttemptId({courseId:n.courseId,batchId:n.batchId,contentId:r[0].object.id,userId:n.userId}),events:r}}))}).assessments.length?[2,this.invokeSyncApi(e)]:[2]}))}))},e.prototype.syncPersistedAssessmentEvents=function(){return Zi(this,void 0,void 0,(function(){var e=this;return eo(this,(function(t){return this.dbService.execute("\n SELECT\n "+ln.COLUMN_NAME_USER_ID+",\n "+ln.COLUMN_NAME_CONTENT_ID+",\n "+ln.COLUMN_NAME_COURSE_ID+",\n "+ln.COLUMN_NAME_BATCH_ID+",\n MIN("+ln.COLUMN_NAME_CREATED_AT+") as first_ts,\n GROUP_CONCAT("+ln.COLUMN_NAME_ASSESSMENT_EVENT+",',') as events\n FROM "+ln.TABLE_NAME+"\n GROUP BY\n "+ln.COLUMN_NAME_USER_ID+",\n "+ln.COLUMN_NAME_CONTENT_ID+",\n "+ln.COLUMN_NAME_COURSE_ID+",\n "+ln.COLUMN_NAME_BATCH_ID+"\n ORDER BY "+ln.COLUMN_NAME_CREATED_AT+"\n ").pipe(Object(ge.map)((function(e){return e.map((function(e){return{userId:e[ln.COLUMN_NAME_USER_ID],contentId:e[ln.COLUMN_NAME_CONTENT_ID],courseId:e[ln.COLUMN_NAME_COURSE_ID],batchId:e[ln.COLUMN_NAME_BATCH_ID],firstTs:e.first_ts,events:JSON.parse("["+e.events+"]")}}))})),Object(ge.mergeMap)((function(t){if(!t.length)return Object(ie.of)(void 0);var n={assessments:t.map((function(t){var n=t.firstTs,r=t.userId,i=t.contentId,o=t.courseId,a=t.batchId,c=t.events;return{assessmentTs:n,userId:r,contentId:i,courseId:o,batchId:a,attemptId:e.courseService.generateAssessmentAttemptId({courseId:o,batchId:a,contentId:i,userId:r}),events:c}}))};return e.invokeSyncApi(n)})),Object(ge.tap)((function(){return Zi(e,void 0,void 0,(function(){return eo(this,(function(e){switch(e.label){case 0:return[4,this.dbService.execute("DELETE FROM "+ln.TABLE_NAME).toPromise()];case 1:return[2,e.sent()]}}))}))})),Object(ge.mapTo)(void 0)).toPromise(),[2]}))}))},e.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update",e}(),no=function(){function e(){}return e.equals=function(e,t){var n=function(e){var t=0;for(var n in e)e.hasOwnProperty(n)&&t++;return t},r=function(e,t){if(typeof e!=typeof t)return!1;if("function"==typeof e)return e.toString()===t.toString();if(e instanceof Object&&t instanceof Object){if(n(e)!==n(t))return!1;for(var i in e)if(!r(e[i],t[i]))return!1;return!0}return e===t};return r(e,t)},e.getPropDiff=function(t,n){return Object.keys(t).reduce((function(r,i){return e.equals(t[i],n[i])?r:(r.push(i),r)}),[])},e.getTruthyProps=function(e){return Object.keys(e).filter((function(t){return!!e[t]}))},e.toOrderedString=function(e){return JSON.stringify(Object.keys(e).sort().reduce((function(t,n){return t[n]=e[n],t}),{}))},e}(),ro=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},io=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},oo=function(e,t){return function(n,r){t(n,r,e)}},ao=function(){function e(e,t,n,r,i,o,a,c){this.sdkConfig=e,this.apiService=t,this.profileService=n,this.keyValueStore=r,this.dbService=i,this.sharedPreferences=o,this.authService=a,this.appInfo=c,this.capturedAssessmentEvents={},this.courseServiceConfig=this.sdkConfig.courseServiceConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.syncAssessmentEventsHandler=new to(this,this.sdkConfig,this.apiService,this.dbService)}var t;return t=e,e.prototype.getBatchDetails=function(e){return new Ii(this.apiService,this.courseServiceConfig).handle(e)},e.prototype.updateContentState=function(e){var n=this,r=new Fi(this.keyValueStore);return new Pi(this.apiService,this.courseServiceConfig).handle(Vi.getUpdateContentStateRequest(e)).pipe(Object(ge.map)((function(t){if(t.hasOwnProperty(e.contentId)||"FAILED"!==t[e.contentId])return!0;throw new zi("Request processing failed")})),Object(ge.catchError)((function(r){var i=t.UPDATE_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId,e.contentId,e.batchId);return n.keyValueStore.getValue(i).pipe(Object(ge.mergeMap)((function(t){return n.keyValueStore.setValue(i,JSON.stringify(e))})))})),Object(ge.mergeMap)((function(){return r.manipulateEnrolledCoursesResponseLocally(e)})),Object(ge.mergeMap)((function(){return r.manipulateGetContentStateResponseLocally(e)})))},e.prototype.getCourseBatches=function(e){return new Li(this.apiService,this.courseServiceConfig,this.profileService,this.authService).handle(e)},e.prototype.getEnrolledCourses=function(e){var t=this,n=new Pi(this.apiService,this.courseServiceConfig);return Object(ie.zip)(this.syncAssessmentEvents(),new Hi(n,this.dbService,this.sharedPreferences,this.keyValueStore).updateContentState()).pipe(Object(ge.mergeMap)((function(){return new ji(t.keyValueStore,t.apiService,t.courseServiceConfig,t.sharedPreferences).handle(e)})))},e.prototype.enrollCourse=function(e){var t=this;return new Ui(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(ge.mergeMap)((function(){var n={};return n.userId=e.userId,n.batchStatus=e.batchStatus,t.sharedPreferences.putString(J.COURSE_CONTEXT,JSON.stringify(n))})),Object(ge.delay)(2e3),Object(ge.concatMap)((function(){return t.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})})),Object(ge.mapTo)(!0))},e.prototype.getContentState=function(e){var n=this,r=t.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseIds[0]),i=new Fi(this.keyValueStore),o=new Bi(this.keyValueStore,i);return this.keyValueStore.getValue(r).pipe(Object(ge.mergeMap)((function(t){return t?e.returnRefreshedContentStates?new xi(n.apiService,n.courseServiceConfig).handle(e).pipe(Object(ge.mergeMap)((function(t){return t?n.keyValueStore.setValue(r,JSON.stringify(t)).pipe(Object(ge.mergeMap)((function(){return i.getLocalContentStateResponse(e)})),Object(ge.mergeMap)((function(){return o.updateEnrollCourses(e)}))):Object(ie.of)(void 0)})),Object(ge.catchError)((function(t){return i.getLocalContentStateResponse(e).pipe(Object(ge.mergeMap)((function(){return o.updateEnrollCourses(e)})))}))):i.getLocalContentStateResponse(e):new xi(n.apiService,n.courseServiceConfig).handle(e).pipe(Object(ge.mergeMap)((function(t){return t?n.keyValueStore.setValue(r,JSON.stringify(t)).pipe(Object(ge.mergeMap)((function(){return i.getLocalContentStateResponse(e)})),Object(ge.mergeMap)((function(){return o.updateEnrollCourses(e)}))):Object(ie.of)(void 0)})),Object(ge.catchError)((function(t){return i.getLocalContentStateResponse(e).pipe(Object(ge.mergeMap)((function(){return o.updateEnrollCourses(e)})))})))})))},e.prototype.unenrollCourse=function(e){var t=this;return new ki(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(ge.delay)(2e3),Object(ge.concatMap)((function(){return t.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})})),Object(ge.mapTo)(!0))},e.prototype.downloadCurrentProfileCourseCertificate=function(e){var n=this;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(e){var t={userId:e.uid,refreshEnrolledCourses:!1,returnRefreshedEnrolledCourses:!0};return n.getEnrolledCourses(t)})),Object(ge.map)((function(t){return t.filter((function(e){return e.status&&2===e.status})).find((function(t){return t.courseId===e.courseId}))})),Object(ge.map)((function(e){if(!e.certificates||!e.certificates.length)throw new Wi("No certificate found for "+e.identifier);var t=e.certificates[0];if(!t)throw new Wi("No certificate found for "+e.identifier);return{certificate:t,course:e}})),Object(ge.mergeMap)((function(e){var r=e.certificate,i=e.course,o=(new F.Builder).withType(R.POST).withPath(t.CERTIFICATE_SIGN_ENDPOINT).withApiToken(!0).withSessionToken(!0).withBody({request:{pdfUrl:r.url}}).build();return n.apiService.fetch(o).pipe(Object(ge.map)((function(e){return{certificate:r,course:i,signedPdfUrl:e.body.result.signedUrl}})))})),Object(ge.mergeMap)((function(e){var t=e.certificate,r=(e.course,{uri:e.signedPdfUrl,title:t.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalFilesDir:{dirType:"Download",subPath:"/"+n.appInfo.getVersionName()+"/"+Xi.getFileName(t.url)},headers:[]});return new ie.Observable((function(e){downloadManager.enqueue(r,(function(t,n){if(t)return e.error(t);e.next(n)}))}))})),Object(ge.mergeMap)((function(e){return Object(ie.interval)(1e3).pipe(Object(ge.mergeMap)((function(){return new ie.Observable((function(t){downloadManager.query({ids:[e]},(function(e,n){return e?t.error(e):t.next(n[0])}))}))})),Object(ge.filter)((function(e){return e.status===Ur.STATUS_SUCCESSFUL})),Object(ge.take)(1))})),Object(ge.map)((function(e){return{path:e.localUri}})))},e.prototype.hasCapturedAssessmentEvent=function(e){var t=e.courseContext,n=no.toOrderedString(t);return!!this.capturedAssessmentEvents[n]},e.prototype.captureAssessmentEvent=function(e){var t=e.event,n=e.courseContext,r=no.toOrderedString(n);this.capturedAssessmentEvents[r]||(this.capturedAssessmentEvents[r]=[]),this.capturedAssessmentEvents[r].push(t)},e.prototype.syncAssessmentEvents=function(e){void 0===e&&(e={persistedOnly:!1});var t={};return e.persistedOnly||(t=this.capturedAssessmentEvents,this.resetCapturedAssessmentEvents()),this.syncAssessmentEventsHandler.handle(t)},e.prototype.resetCapturedAssessmentEvents=function(){this.capturedAssessmentEvents={}},e.prototype.generateAssessmentAttemptId=function(e){return $i([e.courseId,e.batchId,e.contentId,e.userId,Date.now()].join("-")).toString()},e.GET_CONTENT_STATE_KEY_PREFIX="getContentState",e.GET_ENROLLED_COURSE_KEY_PREFIX="enrolledCourses",e.UPDATE_CONTENT_STATE_KEY_PREFIX="updateContentState",e.LAST_READ_CONTENTID_PREFIX="lastReadContentId",e.CERTIFICATE_SIGN_ENDPOINT="/api/certreg/v1/certs/download",e=t=ro([Object(I.injectable)(),oo(0,Object(I.inject)(be.SDK_CONFIG)),oo(1,Object(I.inject)(be.API_SERVICE)),oo(2,Object(I.inject)(be.PROFILE_SERVICE)),oo(3,Object(I.inject)(be.KEY_VALUE_STORE)),oo(4,Object(I.inject)(be.DB_SERVICE)),oo(5,Object(I.inject)(be.SHARED_PREFERENCES)),oo(6,Object(I.inject)(be.AUTH_SERVICE)),oo(7,Object(I.inject)(be.APP_INFO)),io("design:paramtypes",[Object,Object,Object,Object,C,Object,Object,Object])],e)}();!function(e){e.OPEN="open",e.INVITE_ONLY="invite-only"}(Ji||(Ji={})),function(e){e.NOT_STARTED="0",e.IN_PROGRESS="1",e.COMPLETED="2"}(Qi||(Qi={}));var co,so=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},uo=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},fo=function(){function e(e,t,n,r,i,o,a){this.courseService=e,this.sharedPreference=t,this.summarizerService=n,this.eventBusService=r,this.contentService=i,this.profileService=o,this.dbService=a,this.currentUID=void 0,this.currentContentID=void 0,this.courseContext={}}return e.checkPData=function(t){return null!=t&&null!==t.pid&&-1!==t.pid.indexOf(e.CONTENT_PLAYER_PID)},e.checkIsCourse=function(e){return!(null==e.object||!e.object.type||"course"!==e.object.type.toLowerCase())},e.prototype.setCourseContextEmpty=function(){return this.courseContext={},this.sharedPreference.putString(J.COURSE_CONTEXT,"")},e.prototype.updateContentState=function(e){var t=this;return this.getCourseContext().pipe(Object(ge.mergeMap)((function(n){var r=n.userId,i=n.courseId,o=n.batchId,a=0;n.hasOwnProperty("batchStatus")&&(a=n.batchStatus);if(1===a){var c=e.object.id;return t.checkStatusOfContent(r,i,o,c).pipe(Object(ge.mergeMap)((function(a){if("START"===e.eid&&0===a){var s={userId:r,contentId:c,courseId:i,batchId:o,status:1,progress:5};return t.courseService.updateContentState(s).pipe(Object(ge.mapTo)(void 0))}if("END"===e.eid&&0===a||"END"===e.eid&&1===a){var u={userId:r,contentId:c,courseId:i,batchId:o,status:2,progress:100};return t.validEndEvent(e,n).pipe(Object(ge.mergeMap)((function(e){return e?t.courseService.updateContentState(u).pipe(Object(ge.tap)((function(){t.eventBusService.emit({namespace:_e.CONTENT,event:{type:Gn.COURSE_STATE_UPDATED,payload:{contentId:u.courseId}}})})),Object(ge.mapTo)(void 0)):Object(ie.of)(void 0)})))}return Object(ie.of)(void 0)})),Object(ge.tap)((function(){t.updateLastReadContentId(r,i,o,c).toPromise()})))}return Object(ie.of)(void 0)})))},e.prototype.validEndEvent=function(e,t){var n=this,r=(e.actor.id,{contentId:e.object.id});return this.contentService.getContentDetails(r).pipe(Object(ge.delay)(2e3),Object(ge.map)((function(r){var i=e.edata.summary,o=r.mimeType;return("selfassess"!==r.contentType.toLowerCase()||!t||!n.courseService.hasCapturedAssessmentEvent({courseContext:t}))&&(!(!n.findValidProgress(i,20)||!Er.contains([Rn.YOUTUBE,Rn.VIDEO,Rn.WEBM],o))||(!(!n.findValidProgress(i,0)||!Er.contains([Rn.H5P,Rn.HTML],o))||!!n.findValidProgress(i,100)))})),Object(ge.tap)((function(){return n.courseService.resetCapturedAssessmentEvents()})))},e.prototype.isProgressValid=function(e,t){return e&&e.progress>=t},e.prototype.findValidProgress=function(e,t){var n=this;return e.find((function(e){return n.isProgressValid(e,t)}))},e.prototype.updateLastReadContentId=function(e,t,n,r){var i=ao.LAST_READ_CONTENTID_PREFIX.concat("_").concat(e).concat("_").concat(t).concat("_").concat(n);return this.sharedPreference.putString(i,r)},e.prototype.handle=function(t){var n=this;return"START"===t.eid&&e.checkPData(t.context.pdata)?(this.courseService.resetCapturedAssessmentEvents(),this.processOEStart(t).pipe(Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){return uo(this,(function(e){switch(e.label){case 0:return[4,this.summarizerService.saveLearnerAssessmentDetails(t).pipe(Object(ge.mapTo)(void 0)).toPromise()];case 1:return e.sent(),[2]}}))}))})),Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){var e=this;return uo(this,(function(n){switch(n.label){case 0:return[4,this.getCourseContext().pipe(Object(ge.mergeMap)((function(){return e.updateContentState(t)}))).toPromise()];case 1:return n.sent(),[2]}}))}))})),Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){return uo(this,(function(e){switch(e.label){case 0:return[4,this.markContentAsPlayed(t).toPromise()];case 1:return e.sent(),[2]}}))}))})))):"START"===t.eid&&e.checkIsCourse(t)?this.getCourseContext().pipe(Object(ge.mapTo)(void 0)):"ASSESS"===t.eid&&e.checkPData(t.context.pdata)?this.processOEAssess(t).pipe(Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){var e;return uo(this,(function(n){switch(n.label){case 0:return[4,this.getCourseContext().toPromise()];case 1:return e=n.sent(),t.context.cdata.find((function(e){return"AttemptId"===e.type}))&&e.userId&&e.courseId&&e.batchId?[4,this.courseService.captureAssessmentEvent({event:t,courseContext:e})]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))})),Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){return uo(this,(function(e){switch(e.label){case 0:return[4,this.summarizerService.saveLearnerAssessmentDetails(t).pipe(Object(ge.mapTo)(void 0)).toPromise()];case 1:return e.sent(),[2]}}))}))}))):"END"===t.eid&&e.checkPData(t.context.pdata)?this.processOEEnd(t).pipe(Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){return uo(this,(function(e){switch(e.label){case 0:return[4,this.summarizerService.saveLearnerContentSummaryDetails(t).pipe(Object(ge.mapTo)(void 0)).toPromise()];case 1:return e.sent(),[2]}}))}))})),Object(ge.tap)((function(){return so(n,void 0,void 0,(function(){var e=this;return uo(this,(function(n){switch(n.label){case 0:return[4,this.getCourseContext().pipe(Object(ge.mergeMap)((function(){return e.updateContentState(t)}))).toPromise()];case 1:return n.sent(),[2]}}))}))}))):"END"===t.eid&&e.checkIsCourse(t)?this.setCourseContextEmpty():Object(ie.of)(void 0)},e.prototype.markContentAsPlayed=function(e){var t=this,n=e.actor.id,r=e.object.id,i={contentId:r};return this.contentService.getContentDetails(i).pipe(Object(ge.mergeMap)((function(e){var i={status:Mr.PLAYED,contentId:r,contentType:e.contentType};return t.profileService.addContentAccess(i).pipe(Object(ge.mergeMap)((function(){var i={uid:n,contentId:r,data:JSON.stringify(e.contentData),marker:Cn.PREVIEWED,isMarked:!0,extraInfo:{}};return t.contentService.setContentMarker(i).pipe(Object(ge.mapTo)(!0))})))})))},e.prototype.getCourseContext=function(){return this.sharedPreference.getString(J.COURSE_CONTEXT).pipe(Object(ge.map)((function(e){return e?JSON.parse(e):{}})))},e.prototype.checkStatusOfContent=function(e,t,n,r){var i=this,o={userId:e,batchId:n,contentIds:[r],courseIds:[t]};return this.courseService.getContentState(o).pipe(Object(ge.map)((function(e){var t=e&&e.contentList;return i.getStatus(t,r)})))},e.prototype.getStatus=function(e,t){void 0===e&&(e=[]);var n=e.find((function(e){return e.contentId===t}));return n&&n.status||0},e.prototype.processOEStart=function(e){return this.currentUID=e.actor.id,this.currentContentID=e.object.id,Object(ie.of)(void 0)},e.prototype.processOEAssess=function(e){var t=this;return this.currentUID&&this.currentContentID&&this.currentUID.toLocaleLowerCase()===e.actor.id.toLocaleLowerCase()&&this.currentContentID.toLocaleLowerCase()===e.object.id.toLocaleLowerCase()?this.summarizerService.deletePreviousAssessmentDetails(this.currentUID,this.currentContentID).pipe(Object(ge.tap)((function(){t.currentUID=void 0,t.currentContentID=void 0})),Object(ge.mapTo)(void 0)):Object(ie.of)(void 0)},e.prototype.processOEEnd=function(e){return Object(ie.of)(void 0)},e.CONTENT_PLAYER_PID="contentplayer",e}(),lo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ho=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},po=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:It.TABLE_NAME,orderBy:It.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then((function(e){var n=e.map((function(e){return e[It.COLUMN_NAME_UID]}));return t.deleteUnwantedAssesments(n)})).then((function(){return t.saveLearnerAssesmentDetails()})).then((function(){return t.saveLearnerSummary()})).then((function(){return n.body=e,n}))},e.prototype.deleteUnwantedAssesments=function(e){return lo(this,void 0,void 0,(function(){var t,n,r;return ho(this,(function(i){switch(i.label){case 0:return t=Er.joinPreservingQuotes(e),n="DELETE FROM "+Ft.TABLE_NAME+"\n WHERE "+Ft.COLUMN_NAME_UID+" NOT IN("+t+")",r="DELETE FROM "+Yt.TABLE_NAME+"\n WHERE "+Yt.COLUMN_NAME_UID+" NOT IN("+t+")",[4,this.dbService.execute(n,!0).toPromise()];case 1:return i.sent(),[4,this.dbService.execute(r,!0).toPromise()];case 2:return i.sent(),[2]}}))}))},e.prototype.saveLearnerAssesmentDetails=function(){return lo(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,c;return ho(this,(function(s){switch(s.label){case 0:return[4,this.dbService.read({table:Ft.TABLE_NAME,orderBy:""+Ft.COLUMN_NAME_Q_INDEX,useExternalDb:!0}).toPromise()];case 1:e=s.sent(),t=0,n=e,s.label=2;case 2:return t<n.length?(r=n[t],i=r,o=Ci.getFilterForLearnerAssessmentDetails(i[Ft.COLUMN_NAME_QID],i[Ft.COLUMN_NAME_UID],i[Ft.COLUMN_NAME_CONTENT_ID],i[Ft.COLUMN_NAME_HIERARCHY_DATA]),a=Ci.getLearnerAssessmentsQuery(o),[4,this.dbService.execute(a).toPromise()]):[3,8];case 3:return(c=s.sent())&&c.length?[4,this.dbService.update({table:Ft.TABLE_NAME,selection:Ft.COLUMN_NAME_CONTENT_ID+" = ?\n AND "+Ft.COLUMN_NAME_UID+" = ?\n AND "+Ft.COLUMN_NAME_QID+" = ?",selectionArgs:[i[Ft.COLUMN_NAME_CONTENT_ID],i[Ft.COLUMN_NAME_UID],i[Ft.COLUMN_NAME_QID]],modelJson:i}).toPromise()]:[3,5];case 4:return s.sent(),[3,7];case 5:return[4,this.dbService.insert({table:Ft.TABLE_NAME,modelJson:i}).toPromise()];case 6:s.sent(),s.label=7;case 7:return t++,[3,2];case 8:return[2]}}))}))},e.prototype.saveLearnerSummary=function(){return lo(this,void 0,void 0,(function(){var e,t,n,r,i,o,a=this;return ho(this,(function(c){switch(c.label){case 0:return[4,this.dbService.read({table:Yt.TABLE_NAME,useExternalDb:!0}).toPromise()];case 1:e=c.sent(),t=0,n=e,c.label=2;case 2:return t<n.length?(r=n[t],i=r,[4,this.dbService.read({table:Yt.TABLE_NAME,selection:Yt.COLUMN_NAME_CONTENT_ID+" = ? AND "+Yt.COLUMN_NAME_UID+" = ?",selectionArgs:[i[Ft.COLUMN_NAME_CONTENT_ID],i[Ft.COLUMN_NAME_UID]]}).toPromise()]):[3,8];case 3:return(o=c.sent())&&o.length?[4,this.dbService.update({table:Yt.TABLE_NAME,selection:Yt.COLUMN_NAME_CONTENT_ID+" = ? AND "+Yt.COLUMN_NAME_UID+" = ?",selectionArgs:[i[Ft.COLUMN_NAME_CONTENT_ID],i[Ft.COLUMN_NAME_UID]],modelJson:i}).toPromise()]:[3,5];case 4:return c.sent(),[3,7];case 5:return[4,this.dbService.insert({table:Yt.TABLE_NAME,modelJson:i}).toPromise()];case 6:c.sent(),c.label=7;case 7:return t++,[3,2];case 8:return e.forEach((function(e){return lo(a,void 0,void 0,(function(){var t,n,r;return ho(this,(function(i){switch(i.label){case 0:return t=Ci.getFilterForLearnerAssessmentDetails(e[Ft.COLUMN_NAME_QID],e[Ft.COLUMN_NAME_UID],e[Ft.COLUMN_NAME_CONTENT_ID],e[Ft.COLUMN_NAME_HIERARCHY_DATA]),n=Ci.getLearnerAssessmentsQuery(t),[4,this.dbService.execute(n).toPromise()];case 1:return(r=i.sent())&&r.length?[4,this.dbService.update({table:Yt.TABLE_NAME,modelJson:r[0]}).toPromise()]:[3,3];case 2:return i.sent(),[3,5];case 3:return[4,this.dbService.insert({table:Yt.TABLE_NAME,modelJson:r[0]}).toPromise()];case 4:i.sent(),i.label=5;case 5:return[2]}}))}))})),[2]}}))}))},e}(),bo=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D,r=e.metadata.export_id,i=e.metadata.did,o={imported_id:r,device_id:i,count:e.metadata.profiles_count};return this.dbService.read({table:xt.TABLE_NAME,selection:xt.COLUMN_NAME_IMPORTED_ID+" =? AND "+xt.COLUMN_NAME_DEVICE_ID+" = ?",selectionArgs:[r,i],limit:"1"}).toPromise().then((function(e){return e&&e.length?t.dbService.update({table:xt.TABLE_NAME,modelJson:o,selection:xt.COLUMN_NAME_IMPORTED_ID+" =? AND "+xt.COLUMN_NAME_DEVICE_ID+" =?",selectionArgs:[r,i]}).toPromise():t.dbService.insert({table:xt.TABLE_NAME,modelJson:o}).toPromise()})).then((function(){return n.body=e,n}))},e}(),_o=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Eo=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},yo=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this,n=new D;return this.dbService.read({table:It.TABLE_NAME,orderBy:It.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then((function(n){return t.saveProfilesToDb(e,n)})).then((function(){return n.body=e,n}))},e.prototype.saveProfilesToDb=function(e,t){return _o(this,void 0,void 0,(function(){var n,r,i,o,a,c;return Eo(this,(function(s){switch(s.label){case 0:n=0,r=0,i=0,o=t,s.label=1;case 1:return i<o.length?(a=o[i],[4,this.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[a[It.COLUMN_NAME_UID]],limit:"1"}).toPromise()]):[3,6];case 2:return(c=s.sent())&&c.length?[3,4]:(a[It.COLUMN_NAME_CREATED_AT]||(a[It.COLUMN_NAME_CREATED_AT]=(new Date).getTime()),delete a[It._ID],[4,this.dbService.insert({table:It.TABLE_NAME,modelJson:a}).toPromise()]);case 3:return s.sent(),n++,e.imported=n,[3,5];case 4:r++,e.failed=r,s.label=5;case 5:return i++,[3,1];case 6:return e.failed=r,e.imported=n,[2]}}))}))},e}(),vo=function(){function e(e,t){this.sdkConfig=e,this.apiService=t,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.handle=function(e){return this.fetchFromServer(e)},e.prototype.fetchFromServer=function(t){return this.apiService.fetch((new F.Builder).withHost(this.apiConfig.host).withType(R.GET).withPath(this.profileServiceConfig.profileApiPath+e.GET_USER_FEED+"/"+t).withApiToken(!0).withSessionToken(!0).build()).pipe(Object(ge.map)((function(e){return console.log("Response",e),e.body.result.response.userFeed})))},e.GET_USER_FEED="/feed",e}(),go=function(){function e(e,t){this.sdkConfig=e,this.apiService=t,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.apiConfig=this.sdkConfig.apiConfig}return e.prototype.handle=function(e){return this.fetchFromServer(e)},e.prototype.fetchFromServer=function(t){console.log("Request",t);var n=(new F.Builder).withHost(this.apiConfig.host).withType(R.POST).withPath(this.profileServiceConfig.profileApiPath+e.USER_MIGRATE).withApiToken(!0).withSessionToken(!0).withBody({request:t}).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return console.log("sucees",e),e.body})))},e.USER_MIGRATE="/migrate",e}(),mo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},So=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Oo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ao=function(e,t){return function(n,r){t(n,r,e)}},To=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},No=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Mo=function(){function e(e,t,n,r,i,o,a,c,s,u,f){this.container=e,this.sdkConfig=t,this.dbService=n,this.apiService=r,this.cachedItemStore=i,this.keyValueStore=o,this.sharedPreferences=a,this.frameworkService=c,this.fileService=s,this.deviceInfo=u,this.authService=f,this.apiConfig=this.sdkConfig.apiConfig}var t;return t=e,Object.defineProperty(e.prototype,"telemetryService",{get:function(){return this.container.get(be.TELEMETRY_SERVICE)},enumerable:!0,configurable:!0}),e.prototype.preInit=function(){var e=this;return this.sharedPreferences.getString(t.KEY_USER_SESSION).pipe(Object(ge.map)((function(e){return e&&JSON.parse(e)})),Object(ge.mergeMap)((function(t){if(!t){var n={uid:"",handle:"",profileType:gr.TEACHER,source:mr.LOCAL};return e.createProfile(n).pipe(Object(ge.mergeMap)((function(t){return e.setActiveSessionForProfile(t.uid)})),Object(ge.mapTo)(void 0))}return e.setActiveSessionForProfile(t.uid).pipe(Object(ge.mapTo)(void 0))})))},e.prototype.createProfile=function(e,t){var n=this;switch(void 0===t&&(t=mr.LOCAL),t){case mr.LOCAL:if(e.source!==mr.LOCAL)throw new Hr("Invalid value supplied for field 'source': "+e.source);if(e.serverProfile)throw new Hr("Invalid value supplied for field 'serverProfile': "+e.serverProfile);e.uid=nr.generateUniqueId();break;case mr.SERVER:if(e.source!==mr.SERVER)throw new Hr("Invalid value supplied for field 'source': "+e.source);if(!e.serverProfile)throw new Hr("Invalid value supplied for field 'serverProfile': "+e.serverProfile);if(!e.uid)throw new Hr("Invalid value supplied for field 'uid': "+e.uid)}return e.createdAt=Date.now(),this.dbService.insert({table:It.TABLE_NAME,modelJson:Fr.mapProfileToProfileDBEntry(e)}).pipe(Object(ge.tap)((function(){return To(n,void 0,void 0,(function(){var t=this;return No(this,(function(n){switch(n.label){case 0:return[4,this.getActiveProfileSession().pipe(Object(ge.map)((function(e){return e.uid})),Object(ge.catchError)((function(t){return t instanceof Co?Object(ie.of)(e.uid):Object(ie.throwError)(t)})),Object(ge.mergeMap)((function(n){var r=new ct;r.id=n,r.type=ct.TYPE_SYSTEM;var i={env:"sdk",actor:r,currentState:nt.AUDIT_CREATED,updatedProperties:no.getTruthyProps(e),objId:e.uid,objType:Ae.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return t.telemetryService.audit(i)}))).toPromise()];case 1:return n.sent(),[2]}}))}))})),Object(ge.mergeMap)((function(){return Object(ie.of)(e)})))},e.prototype.deleteProfile=function(e){var t=this;return this.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).pipe(Object(ge.map)((function(t){if(!t||!t[0])throw new Po("No Profile found with ID "+e);return Fr.mapProfileDBEntryToProfile(t[0])})),Object(ge.tap)((function(n){return To(t,void 0,void 0,(function(){var t=this;return No(this,(function(r){switch(r.label){case 0:return[4,this.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(r){var i=new ct;i.id=r.uid,i.type=ct.TYPE_SYSTEM;var o={env:"sdk",actor:i,currentState:nt.AUDIT_DELETED,objId:e,objType:Ae.USER,correlationData:[{id:n.profileType,type:"UserRole"}]};return t.telemetryService.audit(o)}))).toPromise()];case 1:return[2,r.sent()]}}))}))})),Object(ge.mergeMap)((function(){return t.dbService.delete({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})})))},e.prototype.updateProfile=function(e){var t=this;return this.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid]}).pipe(Object(ge.map)((function(t){if(!t||!t[0])throw new Po("No Profile found with ID "+e.uid);return Fr.mapProfileDBEntryToProfile(t[0])})),Object(ge.tap)((function(n){return To(t,void 0,void 0,(function(){var t=this;return No(this,(function(r){switch(r.label){case 0:return[4,this.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(r){var i=new ct;i.id=r.uid,i.type=ct.TYPE_SYSTEM;var o={env:"sdk",actor:i,currentState:nt.AUDIT_UPDATED,updatedProperties:no.getPropDiff(e,n),objId:e.uid,objType:Ae.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return t.telemetryService.audit(o)}))).toPromise()];case 1:return r.sent(),[2]}}))}))})),Object(ge.mergeMap)((function(){var n=Fr.mapProfileToProfileDBEntry(e);return delete n[It.COLUMN_NAME_CREATED_AT],t.dbService.update({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid],modelJson:n}).pipe(Object(ge.mergeMap)((function(){return Object(ie.of)(e)})))})))},e.prototype.updateServerProfile=function(e){return new Lr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.getServerProfiles=function(e){return new Dr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.getTenantInfo=function(e){return new Pr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.getAllProfiles=function(e){var t=this;return e?e.groupId?e.groupId&&(e.local||e.server)?this.dbService.execute("\n SELECT * FROM "+It.TABLE_NAME+" LEFT JOIN "+Dt.TABLE_NAME+"\n ON "+It.TABLE_NAME+"."+It.COLUMN_NAME_UID+" =\n "+Dt.TABLE_NAME+"."+Dt.COLUMN_NAME_UID+"\n WHERE "+Dt.COLUMN_NAME_GID+' = "'+e.groupId+'" AND\n '+It.COLUMN_NAME_SOURCE+' = "'+(e.local?mr.LOCAL:mr.SERVER)+'"\n ').pipe(Object(ge.map)((function(e){return t.mapDbProfileEntriesToProfiles(e)}))):this.dbService.execute("\n SELECT * FROM "+It.TABLE_NAME+"\n LEFT JOIN "+Dt.TABLE_NAME+" ON\n "+It.TABLE_NAME+"."+It.COLUMN_NAME_UID+" =\n "+Dt.TABLE_NAME+"."+Dt.COLUMN_NAME_UID+"\n WHERE "+Dt.TABLE_NAME+"."+Dt.COLUMN_NAME_GID+' = "'+e.groupId+'"\n ').pipe(Object(ge.map)((function(e){return t.mapDbProfileEntriesToProfiles(e)}))):this.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_SOURCE+" = ?",selectionArgs:[e.local?mr.LOCAL:mr.SERVER],columns:[]}).pipe(Object(ge.map)((function(e){return t.mapDbProfileEntriesToProfiles(e)}))):this.dbService.read({table:It.TABLE_NAME,columns:[]}).pipe(Object(ge.map)((function(e){return t.mapDbProfileEntriesToProfiles(e)})))},e.prototype.getServerProfilesDetails=function(e){return new Br(this.apiService,this.sdkConfig.profileServiceConfig,this.cachedItemStore,this.keyValueStore).handle(e)},e.prototype.getActiveSessionProfile=function(e){var t=this,n=e.requiredFields;return this.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(e){return t.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid]}).pipe(Object(ge.map)((function(t){var n=t&&t[0];if(!n)throw new Po("No profile found for profileSession with uid "+e.uid);return Fr.mapProfileDBEntryToProfile(n)})),Object(ge.mergeMap)((function(e){return e.source===mr.SERVER?t.getServerProfilesDetails({userId:e.uid,requiredFields:n}).pipe(Object(ge.map)((function(t){return mo({},e,{handle:t.firstName+(t.lastName?" "+t.lastName:""),serverProfile:t})}))):Object(ie.of)(e)})))})))},e.prototype.setActiveSessionForProfile=function(e){var n=this;return Object(ie.defer)((function(){return n.generateSessionEndTelemetry()})).pipe(Object(ge.mergeMap)((function(){return n.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})})),Object(ge.map)((function(e){return e&&e[0]&&Fr.mapProfileDBEntryToProfile(e[0])})),Object(ge.map)((function(e){if(!e)throw new Po("No Profile found");return e})),Object(ge.mergeMap)((function(e){return Object(ie.iif)((function(){return e.source===mr.SERVER}),Object(ie.defer)((function(){return n.getServerProfilesDetails({userId:e.uid,requiredFields:[]}).pipe(Object(ge.map)((function(t){return mo({},e,{serverProfile:t})})),Object(ge.mergeMap)((function(e){return n.frameworkService.setActiveChannelId(e.serverProfile.rootOrg.hashTagId)})),Object(ge.catchError)((function(){return Object(ie.of)(void 0)})))})),n.frameworkService.setActiveChannelId(n.sdkConfig.apiConfig.api_authentication.channelId).pipe(Object(ge.mapTo)(void 0))).pipe(Object(ge.mapTo)(e))})),Object(ge.mergeMap)((function(e){var r=new wr(e.uid);return n.sharedPreferences.putString(t.KEY_USER_SESSION,JSON.stringify({uid:r.uid,sid:r.sid,createdTime:r.createdTime})).pipe(Object(ge.mapTo)(!0))})),Object(ge.tap)((function(){return To(n,void 0,void 0,(function(){return No(this,(function(e){switch(e.label){case 0:return[4,this.generateSessionStartTelemetry()];case 1:return[2,e.sent()]}}))}))})))},e.prototype.getActiveProfileSession=function(){return this.sharedPreferences.getString(t.KEY_USER_SESSION).pipe(Object(ge.map)((function(e){if(e)return JSON.parse(e);throw new Co("No active session available")})))},e.prototype.acceptTermsAndConditions=function(e){return new Vr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.isProfileAlreadyInUse=function(e){return new qr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.generateOTP=function(e){return new zr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.verifyOTP=function(e){return new Kr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)},e.prototype.searchLocation=function(e){return new Xr(this.apiService,this.sdkConfig.profileServiceConfig,this.fileService,this.cachedItemStore).handle(e)},e.prototype.getAllContentAccess=function(e){var t="SELECT * FROM "+Jt.TABLE_NAME+" "+Jr.getUidnIdentifierFiler(e.uid,e.contentId);return this.dbService.execute(t).pipe(Object(ge.map)((function(e){return e.map((function(e){return Yr.mapDBEntryToContenetAccess(e)}))})))},e.prototype.addContentAccess=function(e){var t=this;return this.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(n){var r=n.uid;return t.dbService.read({table:Jt.TABLE_NAME,selection:Jt.COLUMN_NAME_UID+"= ? AND "+Jt.COLUMN_NAME_CONTENT_IDENTIFIER+"= ?",selectionArgs:[r,e.contentId],orderBy:Jt.COLUMN_NAME_EPOCH_TIMESTAMP+" DESC",limit:"1"}).pipe(Object(ge.mergeMap)((function(n){var i={uid:r,identifier:e.contentId,epoch_timestamp:Date.now(),status:Mr.PLAYED.valueOf(),content_type:e.contentType.toLowerCase(),learner_state:e.contentLearnerState&&JSON.stringify(e.contentLearnerState.learnerState)};return n&&n.length?(i.status=n[0][Jt.COLUMN_NAME_STATUS],t.dbService.update({table:Jt.TABLE_NAME,selection:Jt.COLUMN_NAME_UID+"= ? AND "+Jt.COLUMN_NAME_CONTENT_IDENTIFIER+"= ?",selectionArgs:[r,e.contentId],modelJson:i}).pipe(Object(ge.map)((function(e){return e>0})))):t.dbService.insert({table:Jt.TABLE_NAME,modelJson:i}).pipe(Object(ge.map)((function(e){return e>0})))})))})))},e.prototype.exportProfile=function(e){var t=this,n={userIds:e.userIds,destinationFolder:e.destinationFolder,groupIds:e.groupIds};return Object(ie.from)(new Qr(this.fileService).execute(n).then((function(e){return new ei(t.dbService).execute(e.body)})).then((function(e){return new ri(t.dbService,t.fileService,t.deviceInfo).execute(e.body)})).then((function(e){return new ai(t.dbService,t.fileService).execute(e.body).catch((function(){return e}))})).then((function(e){return new si(t.dbService).execute(e.body)})).then((function(e){return{exportedFilePath:e.body.destinationDBFilePath}})))},e.prototype.importProfile=function(e){var t=this,n={sourceDBFilePath:e.sourceFilePath};return Object(ie.from)(new ui(this.dbService).execute(n).then((function(e){return new hi(t.dbService).execute(e.body)})).then((function(e){return new yo(t.dbService).execute(e.body)})).then((function(e){return new bi(t.dbService).execute(e.body)})).then((function(e){return new yi(t.dbService).execute(e.body)})).then((function(e){return new mi(t.dbService).execute(e.body)})).then((function(e){return new po(t.dbService).execute(e.body)})).then((function(e){return new bo(t.dbService).execute(e.body)})).then((function(e){return new ci(t.dbService).execute(e.body)})).then((function(e){return{failed:e.body.failed,imported:e.body.imported}})))},e.prototype.mergeServerProfiles=function(e){var n=this,r=(new F.Builder).withType(R.PATCH).withPath(t.MERGE_SERVER_PROFILES_PATH).withApiToken(!0).withHeaders({"x-source-user-token":e.from.accessToken,"x-authenticated-user-token":e.to.accessToken}).withBody({request:{fromAccountId:e.from.userId,toAccountId:e.to.userId}}).build();return this.apiService.fetch(r).pipe(Object(ge.map)((function(e){console.log(e)})),Object(ge.finalize)((function(){var e=n.sdkConfig.apiConfig.user_authentication.mergeUserHost+n.sdkConfig.apiConfig.user_authentication.authUrl+"/logout?redirect_uri="+n.sdkConfig.apiConfig.host+"/oauth2callback",t=cordova.InAppBrowser.open(e,"_blank","zoom=no,hidden=yes");t.addEventListener("loadstart",(function(e){return To(n,void 0,void 0,(function(){return No(this,(function(n){return e.url.indexOf("/oauth2callback")>-1&&t.close(),[2]}))}))}))})))},e.prototype.isDefaultChannelProfile=function(){return Object(ie.zip)(this.frameworkService.getDefaultChannelId(),this.frameworkService.getActiveChannelId()).pipe(Object(ge.map)((function(e){return e[0]===e[1]})))},e.prototype.mapDbProfileEntriesToProfiles=function(e){return e.map((function(e){return Fr.mapProfileDBEntryToProfile(e)}))},e.prototype.generateSessionStartTelemetry=function(){return To(this,void 0,void 0,(function(){return No(this,(function(e){return[2,hr.log.start({type:"session",env:"sdk"}).toPromise()]}))}))},e.prototype.generateSessionEndTelemetry=function(){return To(this,void 0,void 0,(function(){var e,n;return No(this,(function(r){switch(r.label){case 0:return[4,this.sharedPreferences.getString(t.KEY_USER_SESSION).toPromise()];case 1:return(e=r.sent())?(n=JSON.parse(e),[4,hr.log.end({type:"session",env:"sdk",duration:Math.floor((Date.now()-n.createdTime)/1e3)}).toPromise()]):[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.getUserFeed=function(){var e=this;return this.authService.getSession().pipe(Object(ge.mergeMap)((function(t){if(!t)throw new Co("No Active Session Found");return new vo(e.sdkConfig,e.apiService).handle(t.userToken)})))},e.prototype.userMigrate=function(e){return new go(this.sdkConfig,this.apiService).handle(e)},e.KEY_USER_SESSION=K.KEY_USER_SESSION,e.MERGE_SERVER_PROFILES_PATH="/api/user/v1/account/merge",e=t=So([Object(I.injectable)(),Ao(0,Object(I.inject)(be.CONTAINER)),Ao(1,Object(I.inject)(be.SDK_CONFIG)),Ao(2,Object(I.inject)(be.DB_SERVICE)),Ao(3,Object(I.inject)(be.API_SERVICE)),Ao(4,Object(I.inject)(be.CACHED_ITEM_STORE)),Ao(5,Object(I.inject)(be.KEY_VALUE_STORE)),Ao(6,Object(I.inject)(be.SHARED_PREFERENCES)),Ao(7,Object(I.inject)(be.FRAMEWORK_SERVICE)),Ao(8,Object(I.inject)(be.FILE_SERVICE)),Ao(9,Object(I.inject)(be.DEVICE_INFO)),Ao(10,Object(I.inject)(be.AUTH_SERVICE)),Oo("design:paramtypes",[I.Container,Object,C,Object,Object,Object,Object,Object,Object,Object,Object])],e)}(),wo=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Co=function(e){function t(n){var r=e.call(this,n,"NO_ACTIVE_SESSION")||this;return Object.setPrototypeOf(r,t.prototype),r}return wo(t,e),t}(U),Io=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Po=function(e){function t(n){var r=e.call(this,n,"NO_PROFILE_FOUND")||this;return Object.setPrototypeOf(r,t.prototype),r}return Io(t,e),t}(U),Lo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ro=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Do=function(){function e(e,t,n,r,i,o,a,c){this.telemetryService=e,this.sharedPreferences=t,this.profileService=n,this.courseService=r,this.sdkConfig=i,this.apiService=o,this.dbService=a,this.keyValueStore=c,this.shouldSync=!1}return e.generateDownloadSpeedTelemetry=function(e){return Lo(this,void 0,void 0,(function(){var t,n,r;return Ro(this,(function(i){switch(i.label){case 0:return[4,new Promise((function(e,t){downloadManager.fetchSpeedLog?downloadManager.fetchSpeedLog(e,t):cordova.exec(e,t,"DownloadManagerPlugin","fetchSpeedLog",[])}))];case 1:return t=i.sent(),n={32:"0-32",64:"32-64",128:"64-128",256:"128-256",512:"256-512",1024:"512-1024",1536:"1024-1536",2048:"1536-2048",2560:"2048-2560",3072:"2560-3072",3584:"3072-3584",4096:"3584-above"},Object.keys(t.distributionInKBPS).length?(r={duration:e/1e3,totalKBDownloaded:t.totalKBdownloaded,distributionInKBPS:Object.keys(n).reduce((function(e,r){return t.distributionInKBPS[r]?e[n[r]]=t.distributionInKBPS[r]:e[n[r]]=0,e}),{})},[2,hr.log.interact({type:Qe.OTHER,subType:$e.NETWORK_SPEED,env:"sdk",pageId:"sdk",id:"sdk",valueMap:r}).pipe(Object(ge.mapTo)(void 0)).toPromise()]):[2,void 0]}}))}))},e.prototype.getSyncMode=function(){return this.sharedPreferences.getString(ne.KEY_AUTO_SYNC_MODE).pipe(Object(ge.map)((function(e){return e})))},e.prototype.setSyncMode=function(e){return this.sharedPreferences.putString(ne.KEY_AUTO_SYNC_MODE,e)},e.prototype.start=function(t){var n=this;return this.shouldSync=!0,Object(ie.interval)(t).pipe(Object(ge.tap)((function(n){n*t%e.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL==0&&e.generateDownloadSpeedTelemetry(t)})),Object(ge.tap)((function(){return Lo(n,void 0,void 0,(function(){return Ro(this,(function(e){switch(e.label){case 0:return[4,this.syncAllCourseProgressAndAssessmentEvents()];case 1:return[2,e.sent()]}}))}))})),Object(ge.filter)((function(){return n.shouldSync})),Object(ge.tap)((function(){return n.telemetryService.sync().pipe(Object(ge.tap)((function(e){console.log("AUTO_SYNC_INVOKED_SYNC----------------------------------------------",e)})),Object(ge.catchError)((function(e){return console.error(e),Object(ie.of)(void 0)}))).toPromise()})),Object(ge.mapTo)(void 0))},e.prototype.pause=function(){this.shouldSync=!1},e.prototype.continue=function(){this.shouldSync=!0},e.prototype.syncAllCourseProgressAndAssessmentEvents=function(){return Lo(this,void 0,void 0,(function(){return Ro(this,(function(e){switch(e.label){case 0:return[4,this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise()];case 1:return e.sent().source!==mr.SERVER?[2]:[4,Object(ie.zip)(this.courseService.syncAssessmentEvents({persistedOnly:!0}),new Hi(new Pi(this.apiService,this.sdkConfig.courseServiceConfig),this.dbService,this.sharedPreferences,this.keyValueStore).updateContentState()).toPromise()];case 2:return e.sent(),[2]}}))}))},e.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL=6e4,e}(),jo=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Uo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ko=function(e,t){return function(n,r){t(n,r,e)}},xo=function(){function e(e,t,n,r,i,o,a,c,s,u,f,l,h,d,p,b,_){this.dbService=e,this.decorator=t,this.profileService=n,this.groupService=r,this.keyValueStore=i,this.apiService=o,this.sdkConfig=a,this.deviceInfo=c,this.eventsBusService=s,this.fileService=u,this.frameworkService=f,this.networkInfoService=l,this.errorLoggerService=h,this.sharedPreferences=d,this.appInfoService=p,this.deviceRegisterService=b,this.courseService=_,this.telemetryConfig=this.sdkConfig.telemetryConfig,this._lastSyncedTimestamp$=new ie.BehaviorSubject(void 0)}return Object.defineProperty(e.prototype,"autoSync",{get:function(){return this.telemetryAutoSyncService||(this.telemetryAutoSyncService=new Do(this,this.sharedPreferences,this.profileService,this.courseService,this.sdkConfig,this.apiService,this.dbService,this.keyValueStore)),this.telemetryAutoSyncService},enumerable:!0,configurable:!0}),e.prototype.onInit=function(){var e=this;return this.sharedPreferences.getString(ne.KEY_LAST_SYNCED_TIME_STAMP).pipe(Object(ge.tap)((function(t){if(t)try{e._lastSyncedTimestamp$.next(parseInt(t,10))}catch(e){console.error(e)}})),Object(ge.mapTo)(void 0))},e.prototype.saveTelemetry=function(e){var t=this;return Object(ie.defer)((function(){try{var n=JSON.parse(e);return t.decorateAndPersist(n)}catch(e){return console.error(e),Object(ie.of)(!1)}}))},e.prototype.audit=function(e){var t=e.env,n=e.actor,r=e.currentState,i=e.updatedProperties,o=e.objId,a=e.objType,c=e.objVer,s=e.correlationData,u=new rt.Audit(t,n,r,i,o,a,c,s);return this.decorateAndPersist(u)},e.prototype.end=function(e){var t=e.type,n=e.mode,r=e.duration,i=e.pageId,o=e.summaryList,a=e.env,c=e.objId,s=e.objType,u=e.objVer,f=e.rollup,l=e.correlationData,h=new rt.End(t,n,r,i,o,a,c,s,u,f,l);return this.decorateAndPersist(h)},e.prototype.error=function(e){var t=new rt.Error(e.errorCode,e.errorType,e.stacktrace,e.pageId);return this.errorLoggerService.logError(e).toPromise().catch((function(e){return console.error(e)})),this.decorateAndPersist(t)},e.prototype.impression=function(e){var t=e.type,n=e.subType,r=e.pageId,i=e.visits,o=e.env,a=e.objId,c=e.objType,s=e.objVer,u=e.rollup,f=e.correlationData,l=new rt.Impression(t,n,r,i,o,a,c,s,u,f);return this.decorateAndPersist(l)},e.prototype.interact=function(e){var t=e.type,n=e.subType,r=e.id,i=e.pageId,o=e.pos,a=e.env,c=e.rollup,s=e.valueMap,u=e.correlationData,f=e.objId,l=e.objType,h=e.objVer,d=new rt.Interact(t,n,r,i,o,s,a,f,l,h,c,u);return this.decorateAndPersist(d)},e.prototype.log=function(e){var t=e.type,n=e.level,r=e.message,i=e.pageId,o=e.params,a=e.env,c=e.actorType,s=new rt.Log(t,n,r,i,o,a,c);return this.decorateAndPersist(s)},e.prototype.share=function(e){var t=e.dir,n=e.type,r=e.items,i=e.correlationData,o=e.objId,a=e.objType,c=e.objVer,s=e.rollUp,u=new rt.Share(t,n,[],i,o,a,c,s);return r.forEach((function(e){u.addItem(e.type,e.origin,e.identifier,e.pkgVersion,e.transferCount,e.size)})),this.decorateAndPersist(u)},e.prototype.feedback=function(e){var t=e.rating,n=e.comments,r=e.env,i=e.objId,o=e.objType,a=e.objVer,c=e.commentid,s=e.commenttxt,u=new rt.Feedback(t,n,r,i,o,a,c,s);return this.decorateAndPersist(u)},e.prototype.start=function(e){var t=e.type,n=e.deviceSpecification,r=e.loc,i=e.mode,o=e.duration,a=e.pageId,c=e.env,s=e.objId,u=e.objType,f=e.objVer,l=e.rollup,h=e.correlationData,d=new rt.Start(t,n,r,i,o,a,c,s,u,f,l,h);return this.decorateAndPersist(d)},e.prototype.interrupt=function(e){var t=e.type,n=e.pageId,r=new rt.Interrupt(t,n);return this.decorateAndPersist(r)},e.prototype.importTelemetry=function(e){var t=this,n={sourceDBFilePath:e.sourceFilePath};return Object(ie.from)(new yr(this.dbService).execute(n).then((function(e){return new Ar(t.dbService).execute(e.body)})).then((function(e){return new Tr(t.dbService).execute(e.body)})).then((function(e){return new Tr(t.dbService).execute(e.body)})).then((function(e){return new Nr(t.dbService,t).execute(e.body)})).then((function(e){return!0})).catch((function(e){return console.error(e),!1})))},e.prototype.getTelemetryStat=function(){var e="\n SELECT COUNT(*) as TELEMETRY_COUNT\n FROM "+gt.TABLE_NAME+"\n ",t="\n SELECT SUM("+St.COLUMN_NAME_NUMBER_OF_EVENTS+") as PROCESSED_TELEMETRY_COUNT\n FROM "+St.TABLE_NAME+"\n ";return Object(ie.zip)(this.dbService.execute(e),this.dbService.execute(t),this.keyValueStore.getValue(ne.KEY_LAST_SYNCED_TIME_STAMP)).pipe(Object(ge.map)((function(e){return{unSyncedEventCount:e[0][0].TELEMETRY_COUNT+e[1][0].PROCESSED_TELEMETRY_COUNT,lastSyncTime:e[2]?parseInt(e[2],10):0}})))},e.prototype.resetDeviceRegisterTTL=function(){return new br(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService).resetDeviceRegisterTTL()},e.prototype.sync=function(e){var t=this;return void 0===e&&(e={ignoreSyncThreshold:!1,ignoreAutoSyncMode:!1}),this.networkInfoService.networkStatus$.pipe(Object(ge.take)(1),Object(ge.mergeMap)((function(t){return t===vr.ONLINE&&(e.ignoreSyncThreshold=!0),Object(ie.of)(e)})),Object(ge.mergeMap)((function(e){return new br(t.dbService,t.sdkConfig,t.deviceInfo,t.sharedPreferences,t.appInfoService,t.deviceRegisterService,t.keyValueStore,t.apiService).handle(e).pipe(Object(ge.tap)((function(e){if(!e.error&&e.syncedEventCount){var n=Date.now();t.sharedPreferences.putString(ne.KEY_LAST_SYNCED_TIME_STAMP,n+"").toPromise(),t._lastSyncedTimestamp$.next(n)}})))})))},e.prototype.lastSyncedTimestamp=function(){return this._lastSyncedTimestamp$.asObservable()},e.prototype.buildContext=function(){var e=this;return this.profileService.getActiveProfileSession().pipe(Object(ge.map)((function(t){return e.decorator.buildContext(t.sid,e.frameworkService.activeChannelId,new st)})))},e.prototype.decorateAndPersist=function(e){var t=this;return Object(ie.zip)(this.profileService.getActiveProfileSession(),this.groupService.getActiveGroupSession()).pipe(Object(ge.mergeMap)((function(n){var r=n[0],i=n[1];return t.keyValueStore.getValue(br.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY).pipe(Object(ge.mergeMap)((function(n){n=n||"0";var o={table:gt.TABLE_NAME,modelJson:t.decorator.prepare(t.decorator.decorate(e,r.uid,r.sid,i&&i.gid,Number(n),t.frameworkService.activeChannelId),1)};return t.dbService.insert(o).pipe(Object(ge.tap)((function(){return t.eventsBusService.emit({namespace:_e.TELEMETRY,event:{type:_r.SAVE,payload:e}})})),Object(ge.map)((function(e){return e>1})))})))})))},e=jo([Object(I.injectable)(),ko(0,Object(I.inject)(be.DB_SERVICE)),ko(1,Object(I.inject)(be.TELEMETRY_DECORATOR)),ko(2,Object(I.inject)(be.PROFILE_SERVICE)),ko(3,Object(I.inject)(be.GROUP_SERVICE)),ko(4,Object(I.inject)(be.KEY_VALUE_STORE)),ko(5,Object(I.inject)(be.API_SERVICE)),ko(6,Object(I.inject)(be.SDK_CONFIG)),ko(7,Object(I.inject)(be.DEVICE_INFO)),ko(8,Object(I.inject)(be.EVENTS_BUS_SERVICE)),ko(9,Object(I.inject)(be.FILE_SERVICE)),ko(10,Object(I.inject)(be.FRAMEWORK_SERVICE)),ko(11,Object(I.inject)(be.NETWORKINFO_SERVICE)),ko(12,Object(I.inject)(be.ERROR_LOGGER_SERVICE)),ko(13,Object(I.inject)(be.SHARED_PREFERENCES)),ko(14,Object(I.inject)(be.APP_INFO)),ko(15,Object(I.inject)(be.DEVICE_REGISTER_SERVICE)),ko(16,Object(I.inject)(be.COURSE_SERVICE)),Uo("design:paramtypes",[C,Je,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object])],e)}(),Bo=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Fo=function(e){function t(n){var r=e.call(this,n,"AUTH_TOKEN_REFRESH_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return Bo(t,e),t}(U),Vo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Yo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Go=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ho=function(){function e(e,t,n,r){this.apiConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r}return e.prototype.refreshSession=function(){return Yo(this,void 0,void 0,(function(){var e,t,n,r=this;return Go(this,(function(i){switch(i.label){case 0:return[4,this.getSessionData()];case 1:if(!(e=i.sent()))throw new Co("No Active Sessions found");t=(new F.Builder).withPath("/auth/v1/refresh/token").withType(R.POST).withSerializer(L.URLENCODED).withApiToken(!0).withBody({refresh_token:e.refresh_token}).build(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.apiService.fetch(t).toPromise().catch((function(e){if(e instanceof De&&e.response.responseCode===N.HTTP_BAD_REQUEST)throw new Fo(e.message);throw e})).then((function(t){if(t.body.result.access_token&&t.body.result.refresh_token){var n=re.getJWTPayload(t.body.result.access_token),i=3===n.sub.split(":").length?n.sub.split(":").pop():n.sub;return e=Vo({},t.body.result,{userToken:i}),r.startSession(e)}throw new Fo("No token found in server response")}))];case 3:return i.sent(),[3,5];case 4:throw(n=i.sent())instanceof Fo&&this.eventsBusService.emit({namespace:_e.ERROR,event:{type:Ee.AUTH_TOKEN_REFRESH_ERROR,payload:n}}),n;case 5:return[2]}}))}))},e.prototype.startSession=function(e){return Yo(this,void 0,void 0,(function(){return Go(this,(function(t){switch(t.label){case 0:return[4,this.sharedPreferences.putString(q.KEY_OAUTH_SESSION,JSON.stringify(e)).toPromise()];case 1:return t.sent(),[2]}}))}))},e.prototype.endSession=function(){return Yo(this,void 0,void 0,(function(){return Go(this,(function(e){switch(e.label){case 0:return[4,this.sharedPreferences.putString(q.KEY_OAUTH_SESSION,"").toPromise()];case 1:return e.sent(),[2]}}))}))},e.prototype.getSessionData=function(){return Yo(this,void 0,void 0,(function(){var e;return Go(this,(function(t){switch(t.label){case 0:return[4,this.sharedPreferences.getString(q.KEY_OAUTH_SESSION).toPromise()];case 1:return(e=t.sent())?[2,JSON.parse(e)]:[2,void 0]}}))}))},e}(),qo=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},zo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ko=function(e,t){return function(n,r){t(n,r,e)}},Wo=function(){function e(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r,this.apiConfig=this.sdkConfig.apiConfig,this.authUtil=new Ho(this.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService)}return e.prototype.setSession=function(e){var t=this;return Object(ie.from)(e.provide().then((function(e){t.authUtil.startSession(e)})))},e.prototype.getSession=function(){return Object(ie.from)(this.authUtil.getSessionData())},e.prototype.resignSession=function(){return Object(ie.from)(this.authUtil.endSession())},e.prototype.refreshSession=function(){return Object(ie.from)(this.authUtil.refreshSession())},e=qo([Object(I.injectable)(),Ko(0,Object(I.inject)(be.SDK_CONFIG)),Ko(1,Object(I.inject)(be.API_SERVICE)),Ko(2,Object(I.inject)(be.SHARED_PREFERENCES)),Ko(3,Object(I.inject)(be.EVENTS_BUS_SERVICE)),zo("design:paramtypes",[Object,Object,Object,Object])],e)}(),Xo=function(){function e(e,t,n,r){this.apiService=e,this.frameworkServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.CHANNEL_FILE_KEY_PREFIX="channel-",this.CHANNEL_LOCAL_KEY="channel-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}return e.prototype.handle=function(e){var t=this;return this.cachedItemStore.getCached(e.channelId,this.CHANNEL_LOCAL_KEY,"ttl_"+this.CHANNEL_LOCAL_KEY,(function(){return t.fetchFromServer(e)}),(function(){return t.fetchFromFile(e)})).pipe(Object(ge.map)((function(e){if(e.frameworks){var t=e.frameworks.reduce((function(e,t){return t.index&&t.index>e?t.index:e}),0);e.frameworks.sort((function(e,n){return(e.index||t+1)-(n.index||t+1)}))}return e})))},e.prototype.fetchFromServer=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.frameworkServiceConfig.channelApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.channelId).withApiToken(!0).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result.channel})))},e.prototype.fetchFromFile=function(e){var t=Wr.ASSETS_PATH+this.frameworkServiceConfig.channelConfigDirPath,n=this.CHANNEL_FILE_KEY_PREFIX+e.channelId+".json";return Object(ie.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(ge.map)((function(e){return JSON.parse(e).result.channel})))},e}(),Jo=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Qo=function(){function e(){}return e.prepareFrameworkCategoryAssociations=function(e){return e.categories?(e.categories=e.categories.map((function(t,n){return t.terms?Jo({},t,{terms:t.terms.map((function(t){return t.associations?(t.associations=t.associations.filter((function(t){return n>=e.categories.length-1||t.category===e.categories[n+1].code})),t):t}))}):t})),Jo({},e)):e},e.prepareFrameworkTranslations=function(t,n){return t.name=e.getTranslatedValue(t.translations,n,t.name),t.categories&&(t.categories=t.categories.map((function(t){return t.name=e.getTranslatedValue(t.translations,n,t.name),t.terms&&(t.terms=t.terms.map((function(t){return t.name=e.getTranslatedValue(t.translations,n,t.name),t}))),t}))),t},e.prepareFrameworkCategoryTranslations=function(t,n){return t.name=e.getTranslatedValue(t.translations,n,t.name),t.terms&&(t.terms=t.terms.map((function(t){return t.name=e.getTranslatedValue(t.translations,n,t.name),t}))),t},e.getTranslatedValue=function(e,t,n){return e&&JSON.parse(e)[t]||n},e}(),$o=function(){function e(e,t,n,r,i){this.frameworkService=e,this.apiService=t,this.frameworkServiceConfig=n,this.fileService=r,this.cachedItemStore=i,this.FRAMEWORK_FILE_KEY_PREFIX="framework-",this.FRAMEWORK_LOCAL_KEY="framework-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}return e.prototype.handle=function(e){var t=this;return Object(ie.iif)((function(){return!!e.frameworkId}),Object(ie.defer)((function(){return t.cachedItemStore.getCached(e.frameworkId,t.FRAMEWORK_LOCAL_KEY,"ttl_"+t.FRAMEWORK_LOCAL_KEY,(function(){return t.fetchFromServer(e)}),(function(){return t.fetchFromFile(e)}))})),Object(ie.defer)((function(){return t.frameworkService.getDefaultChannelDetails().pipe(Object(ge.mergeMap)((function(n){return t.frameworkService.getFrameworkDetails({frameworkId:n.defaultFramework,requiredCategories:e.requiredCategories})})))})))},e.prototype.fetchFromServer=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.frameworkServiceConfig.frameworkApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.frameworkId).withParameters({categories:e.requiredCategories.join(",")}).withApiToken(!0).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result.framework})),Object(ge.map)((function(e){return Qo.prepareFrameworkCategoryAssociations(e)})))},e.prototype.fetchFromFile=function(e){var t=Wr.ASSETS_PATH+this.frameworkServiceConfig.frameworkConfigDirPath,n=this.FRAMEWORK_FILE_KEY_PREFIX+e.frameworkId+".json";return Object(ie.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(ge.map)((function(e){return JSON.parse(e).result.framework})),Object(ge.map)((function(e){return Qo.prepareFrameworkCategoryAssociations(e)})))},e}(),Zo=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ea=function(e){function t(n){var r=e.call(this,n,"NO_ACTIVE_CHANNEL_FOUND_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return Zo(t,e),t}(U),ta=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},na=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ra=function(e,t){return function(n,r){t(n,r,e)}},ia=function(){function e(e,t,n,r,i,o){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r,this.sharedPreferences=i,this.systemSettingsService=o}var t;return t=e,Object.defineProperty(e.prototype,"activeChannelId",{get:function(){return this._activeChannelId},enumerable:!0,configurable:!0}),e.prototype.preInit=function(){var e=this;return this.getActiveChannelId().pipe(Object(ge.tap)((function(t){return e._activeChannelId=t})),Object(ge.mapTo)(void 0),Object(ge.catchError)((function(t){if(t instanceof ea)return e.setActiveChannelId(e.sdkConfig.apiConfig.api_authentication.channelId);throw t})))},e.prototype.getDefaultChannelId=function(){return this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(ge.map)((function(e){return e.value})))},e.prototype.getDefaultChannelDetails=function(){var e=this;return this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(ge.map)((function(e){return e.value})),Object(ge.mergeMap)((function(t){return e.getChannelDetails({channelId:t})})))},e.prototype.getChannelDetails=function(e){return new Xo(this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)},e.prototype.getFrameworkDetails=function(e){return new $o(this,this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)},e.prototype.searchOrganization=function(e){var n=(new F.Builder).withType(R.POST).withPath(this.sdkConfig.frameworkServiceConfig.searchOrganizationApiPath+t.SEARCH_ORGANIZATION_ENDPOINT).withBody({request:e}).withApiToken(!0).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return e.body.result.response})))},e.prototype.getActiveChannelId=function(){return this.sharedPreferences.getString(t.KEY_ACTIVE_CHANNEL_ID).pipe(Object(ge.map)((function(e){if(!e)throw new ea("No Active channel ID set in preferences");return e})))},e.prototype.setActiveChannelId=function(e){return this._activeChannelId=e,this.sharedPreferences.putString(t.KEY_ACTIVE_CHANNEL_ID,e)},e.KEY_ACTIVE_CHANNEL_ID=W.KEY_ACTIVE_CHANNEL_ID,e.SEARCH_ORGANIZATION_ENDPOINT="/search",e=t=ta([Object(I.injectable)(),ra(0,Object(I.inject)(be.SDK_CONFIG)),ra(1,Object(I.inject)(be.FILE_SERVICE)),ra(2,Object(I.inject)(be.API_SERVICE)),ra(3,Object(I.inject)(be.CACHED_ITEM_STORE)),ra(4,Object(I.inject)(be.SHARED_PREFERENCES)),ra(5,Object(I.inject)(be.SYSTEM_SETTINGS_SERVICE)),na("design:paramtypes",[Object,Object,Object,Object,Object,Object])],e)}(),oa=n(61),aa=n(15),ca=n.n(aa),sa=n(17),ua=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},fa=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},la=function(){function e(e,t,n){this.frameworkUtilService=e,this.frameworkService=t,this.sharedPreferences=n}return e.prototype.handle=function(e){var t=this;return(e.frameworkId?t.getTranslatedFrameworkDetails(e.frameworkId,e.requiredCategories,e.language):t.getActiveChannelTranslatedDefaultFrameworkDetails(e.requiredCategories,e.language)).pipe(Object(ge.tap)((function(e){return ua(t,void 0,void 0,(function(){return fa(this,(function(t){switch(t.label){case 0:return[4,this.sharedPreferences.putString(W.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID,e.identifier).toPromise()];case 1:return[2,t.sent()]}}))}))})),Object(ge.map)((function(n){var r=[],i=(r=!e.prevCategoryCode&&e.currentCategoryCode?t.getCategoryTerms(n,e).toArray():t.getCategoryAssociationTerms(n,e).toArray()).reduce((function(e,t){return t.index&&t.index>e?t.index:e}),0);return r.sort((function(e,t){return(e.index||i+1)-(t.index||i+1)})),r})))},e.prototype.getActiveChannelTranslatedDefaultFrameworkDetails=function(e,t){var n=this;return this.frameworkUtilService.getActiveChannel().pipe(Object(ge.mergeMap)((function(r){return n.getTranslatedFrameworkDetails(r.defaultFramework,e,t)})))},e.prototype.getTranslatedFrameworkDetails=function(e,t,n){return this.frameworkService.getFrameworkDetails({frameworkId:e,requiredCategories:t}).pipe(Object(ge.map)((function(e){return Qo.prepareFrameworkTranslations(e,n)})))},e.prototype.getAllCategoriesTermsSet=function(e){return e.categories?e.categories.reduce((function(e,t){return e.concat([t.terms||[]])}),[]).reduce((function(e,t){return e.concat(t)}),[]).reduce((function(e,t){return e.add(t),e}),new ca.a((function(e){return Object(sa.makeString)(e)}))):new ca.a},e.prototype.getCategoryTerms=function(e,t){return e.categories.find((function(e){return e.code===t.currentCategoryCode})).terms.reduce((function(e,t){return e.add(t),e}),new ca.a((function(e){return Object(sa.makeString)(e)})))},e.prototype.getCategoryAssociationTerms=function(e,t){var n=this;if(!e.categories)return new ca.a;var r=e.categories.find((function(e){return e.code===t.prevCategoryCode})).terms;if(!r)return new ca.a;var i=r.filter((function(e){return t.selectedTermsCodes.find((function(t){return t===e.code}))})).map((function(e){return e.associations||[]}));return i.some((function(e){return 0===e.length}))?e.categories.find((function(e){return e.code===t.currentCategoryCode})).terms.reduce((function(e,t){return e.add(t),e}),new ca.a((function(e){return Object(sa.makeString)(e)}))):i.reduce((function(e,t){return e.concat(t)}),[]).reduce((function(e,t){return e.add(t),e}),new ca.a((function(e){return Object(sa.makeString)(e)}))).toArray().map((function(t){return n.getAllCategoriesTermsSet(e).toArray().find((function(e){return e.identifier===t.identifier}))})).reduce((function(e,t){return e.add(t),e}),new ca.a((function(e){return Object(sa.makeString)(e)})))},e}(),ha=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},da=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},pa=function(e,t){return function(n,r){t(n,r,e)}},ba=function(){function e(e,t,n){this.sharedPreferences=e,this.frameworkService=t,this.profileService=n}return e.prototype.getActiveChannel=function(){var e=this;return this.frameworkService.getActiveChannelId().pipe(Object(ge.mergeMap)((function(t){return e.frameworkService.getChannelDetails({channelId:t})})))},e.prototype.getActiveChannelSuggestedFrameworkList=function(e){var t=this;return this.profileService.getActiveSessionProfile({requiredFields:[]}).pipe(Object(ge.mergeMap)((function(n){return Object(ie.iif)((function(){return!!n.serverProfile&&!e.ignoreActiveChannel}),Object(ie.defer)((function(){return t.getActiveChannel()})),Object(ie.defer)((function(){return t.frameworkService.getDefaultChannelDetails()})))})),Object(ge.mergeMap)((function(n){return n.frameworks?Object(ie.of)(n.frameworks).pipe(Object(ge.map)((function(t){return t.map((function(e){return Qo.prepareFrameworkCategoryAssociations(e)})).map((function(t){return Qo.prepareFrameworkTranslations(t,e.language)}))}))):t.frameworkService.getFrameworkDetails({frameworkId:n.defaultFramework,requiredCategories:e.requiredCategories}).pipe(Object(ge.map)((function(e){return e.index=0,[e]})))})))},e.prototype.getFrameworkCategoryTerms=function(e){return new la(this,this.frameworkService,this.sharedPreferences).handle(e)},e=ha([Object(I.injectable)(),pa(0,Object(I.inject)(be.SHARED_PREFERENCES)),pa(1,Object(I.inject)(be.FRAMEWORK_SERVICE)),pa(2,Object(I.inject)(be.PROFILE_SERVICE)),da("design:paramtypes",[Object,Object,Object])],e)}(),_a=function(){function e(){}return e.mapContentDataToContentDBEntry=function(e,t){var n,r,i,o;return t?o=JSON.stringify(e):(r=e.lastUpdatedOn,i=JSON.stringify(e)),(n={})[Wt.COLUMN_NAME_IDENTIFIER]=e.identifier,n[Wt.COLUMN_NAME_SERVER_DATA]=i,n[Wt.COLUMN_NAME_SERVER_LAST_UPDATED_ON]=r,n[Wt.COLUMN_NAME_MANIFEST_VERSION]=t,n[Wt.COLUMN_NAME_LOCAL_DATA]=o,n[Wt.COLUMN_NAME_MIME_TYPE]=e.mimeType,n[Wt.COLUMN_NAME_CONTENT_TYPE]=Jr.readContentType(e),n[Wt.COLUMN_NAME_VISIBILITY]=Jr.readVisibility(e),n[Wt.COLUMN_NAME_AUDIENCE]=Jr.readAudience(e),n[Wt.COLUMN_NAME_PRAGMA]=Jr.readPragma(e),n},e.mapServerResponseToContent=function(e,t){var n,r;return t?r=e:(e.lastUpdatedOn,n=e),{identifier:e.identifier,contentData:e,isUpdateAvailable:Jr.isUpdateAvailable(n,r),mimeType:e.mimeType,basePath:"",contentType:Jr.readContentType(e),isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0}},e.mapContentDBEntryToContent=function(e,t){var n,r=e[Wt.COLUMN_NAME_SERVER_DATA],i=e[Wt.COLUMN_NAME_LOCAL_DATA],o=r&&JSON.parse(r),a=i&&JSON.parse(i),c=e[Wt.COLUMN_NAME_IDENTIFIER],s=e[Wt.COLUMN_NAME_MIME_TYPE],u=(e[Wt.COLUMN_NAME_VISIBILITY],e[Wt.COLUMN_NAME_CONTENT_TYPE]),f=0;e.hasOwnProperty(Jt.COLUMN_NAME_EPOCH_TIMESTAMP)&&(f=e[Jt.COLUMN_NAME_EPOCH_TIMESTAMP]),e.hasOwnProperty(en.COLUMN_NAME_DATA)&&(a||(a=JSON.parse(e[en.COLUMN_NAME_DATA])),a&&(c=a.identifier,s=a.mimeType,Jr.readVisibility(a),u=Jr.readContentType(a))),a&&(n=a),o&&(a&&Jr.isAvailableLocally(e[Wt.COLUMN_NAME_CONTENT_STATE])?(a.streamingUrl||(a.streamingUrl=o.streamingUrl),a.previewUrl||(a.previewUrl=o.previewUrl),a.me_totalRatingsCount||(a.me_totalRatingsCount=o.me_totalRatingsCount),a.me_averageRating||(a.me_averageRating=o.me_averageRating),a.size||(a.size=o.size),a.licenseDetails||(a.licenseDetails=o.licenseDetails)):n=o);var l=0,h=e[Wt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON];h&&(l=new Date(h).getTime());var d=Number(e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]),p=d||Number(o?o.size:0),b=e[Wt.COLUMN_NAME_PATH]||"";return{identifier:c,contentData:n,isUpdateAvailable:Jr.isUpdateAvailable(o,a),mimeType:s,basePath:t?"/_app_file_"+b:b,contentType:u,isAvailableLocally:Jr.isAvailableLocally(e[Wt.COLUMN_NAME_CONTENT_STATE]),referenceCount:Number(e[Wt.COLUMN_NAME_REF_COUNT])||0,sizeOnDevice:p,lastUsedTime:f||0,lastUpdatedTime:l}},e}(),Ea=function(){function e(e){this.dbService=e}return e.prototype.getContentMarker=function(e,t){var n=this,r="SELECT * FROM "+en.TABLE_NAME+"\n "+Jr.getUidnIdentifierFiler(t,e)+"\n ORDER BY "+en.COLUMN_NAME_EPOCH_TIMESTAMP+" DESC ";return this.dbService.execute(r).pipe(Object(ge.map)((function(e){return n.mapDBEntriesToContentMarkerDetails(e)})))},e.prototype.mapDBEntriesToContentMarkerDetails=function(e){return e.map((function(e){return{contentId:e[en.COLUMN_NAME_CONTENT_IDENTIFIER],uid:e[en.COLUMN_NAME_UID],extraInfoMap:e[en.COLUMN_NAME_EXTRA_INFO]&&JSON.parse(e[en.COLUMN_NAME_EXTRA_INFO]),marker:e[en.COLUMN_NAME_MARKER]}}))},e}(),ya=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},va=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ga=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ma=Wt.COLUMN_NAME_MIME_TYPE,Sa=Wt.COLUMN_NAME_VISIBILITY,Oa=function(){function e(e,t,n,r,i,o){this.contentFeedbackService=e,this.profileService=t,this.apiService=n,this.contentServiceConfig=r,this.dbService=i,this.eventsBusService=o,this.GET_CONTENT_DETAILS_ENDPOINT="/read"}return e.getReadContentQuery=function(e){return{table:Wt.TABLE_NAME,selection:(new Wn).where("? = ?").args([Wt.COLUMN_NAME_IDENTIFIER,e]).end().build(),limit:"1"}},e.isUnit=function(e){return e[ma]===Rn.COLLECTION&&e[Sa]===Dn.PARENT},e.prototype.handle=function(t){var n=this;return t.emitUpdateIfAny=void 0===t.emitUpdateIfAny||t.emitUpdateIfAny,this.fetchFromDB(t.contentId).pipe(Object(ge.mergeMap)((function(r){return r?Object(ie.of)(_a.mapContentDBEntryToContent(r)).pipe(Object(ge.mergeMap)((function(e){return"string"==typeof e.contentData.originData&&(e.contentData.originData=JSON.parse(e.contentData.originData)),n.decorateContent({content:e,attachFeedback:t.attachFeedback,attachContentAccess:t.attachContentAccess,attachContentMarker:t.attachContentMarker})})),Object(ge.tap)((function(i){return va(n,void 0,void 0,(function(){var n,o;return ga(this,(function(a){switch(a.label){case 0:return!t.emitUpdateIfAny||e.isUnit(r)?[2]:(!1,(n=r[Wt.COLUMN_NAME_SERVER_DATA]&&JSON.parse(r[Wt.COLUMN_NAME_SERVER_DATA]))&&n.streamingUrl||!0,[4,this.fetchFromServer(t).toPromise()]);case 1:return o=a.sent(),r[Wt.COLUMN_NAME_SERVER_DATA]=JSON.stringify(o),r[Wt.COLUMN_NAME_SERVER_LAST_UPDATED_ON]=o.lastUpdatedOn,r[Wt.COLUMN_NAME_AUDIENCE]=Jr.readAudience(o),[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[r[Wt.COLUMN_NAME_IDENTIFIER]],modelJson:r}).toPromise()];case 2:return a.sent(),Jr.isUpdateAvailable(o,i.contentData)&&this.eventsBusService.emit({namespace:_e.CONTENT,event:{type:Gn.UPDATE,payload:{contentId:i.contentData.identifier,size:o.size}}}),o&&this.eventsBusService.emit({namespace:_e.CONTENT,event:{type:Gn.SERVER_CONTENT_DATA,payload:{contentId:o.identifier,streamingUrl:o.streamingUrl,licenseDetails:o.licenseDetails,size:o.size}}}),[2]}}))}))}))):n.fetchAndDecorate(t)})))},e.prototype.fetchFromDB=function(e){return this.dbService.read({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e],limit:"1"}).pipe(Object(ge.map)((function(e){return e[0]})))},e.prototype.fetchFromDBForAll=function(e){return this.dbService.read({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" IN ("+e+")"})},e.prototype.fetchFromServer=function(e){return this.apiService.fetch((new F.Builder).withHost(this.contentServiceConfig.host).withType(R.GET).withPath(this.contentServiceConfig.apiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withParameters({licenseDetails:"name,url,description"}).withApiToken(!0).build()).pipe(Object(ge.map)((function(e){return e.body.result.content})))},e.prototype.fetchAndDecorate=function(e){var t=this;return this.fetchFromServer(e).pipe(Object(ge.map)((function(e){return _a.mapServerResponseToContent(e)})),Object(ge.mergeMap)((function(n){return t.decorateContent({content:n,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker})})))},e.prototype.decorateContent=function(e){var t=this;return Object(ie.of)(e.content).pipe(Object(ge.mergeMap)((function(n){return e.attachContentAccess?t.attachContentAccess(n):Object(ie.of)(n)})),Object(ge.mergeMap)((function(n){return e.attachFeedback?t.attachFeedback(n):Object(ie.of)(n)})),Object(ge.mergeMap)((function(n){return e.attachContentMarker?t.attachContentMarker(n):Object(ie.of)(n)})))},e.prototype.attachContentAccess=function(e){var t=this;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(n){var r=n.uid;return t.profileService.getAllContentAccess({contentId:e.identifier,uid:r}).pipe(Object(ge.map)((function(t){return ya({},e,{contentAccess:t})})))})))},e.prototype.attachFeedback=function(e){var t=this;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(n){var r=n.uid;return t.contentFeedbackService.getFeedback({contentId:e.identifier,uid:r}).pipe(Object(ge.map)((function(t){return ya({},e,{contentFeedback:t})})))})))},e.prototype.attachContentMarker=function(e){var t=this;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(n){var r=n.uid;return new Ea(t.dbService).getContentMarker(e.identifier,r).pipe(Object(ge.map)((function(t){return ya({},e,{contentMarkers:t})})))})))},e}(),Aa=function(){function e(e){this._stack=e||[]}return Object.defineProperty(e.prototype,"count",{get:function(){return this._stack.length},enumerable:!0,configurable:!0}),e.prototype.push=function(e){this._stack.push(e)},e.prototype.pop=function(){return this._stack.pop()},e.prototype.clear=function(){this._stack=[]},e.prototype.isEmpty=function(){return 0===this._stack.length},e.prototype.addAll=function(e){this._stack=this._stack.concat(e)},e}(),Ta=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Na=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ma=function(){function e(e,t,n){this.dbService=e,this.getContentDetailsHandler=t,this.fileService=n}return e.prototype.fetchChildrenOfContent=function(e,t,n,r,i){return Ta(this,void 0,void 0,(function(){var o,a,c,s,u,f,l,h,d;return Na(this,(function(p){switch(p.label){case 0:return o=_a.mapContentDBEntryToContent(e),[4,this.getSortedChildrenList(e[Wt.COLUMN_NAME_LOCAL_DATA],Pn.ALL,t)];case 1:if(!(a=p.sent())||!a.length)return[3,7];if((c=(c=[]).concat(i)).push({identifier:e[Wt.COLUMN_NAME_IDENTIFIER],contentType:e[Wt.COLUMN_NAME_CONTENT_TYPE]}),o.hierarchyInfo=c,!(-1===r||n<=r))return[3,6];s=[],u=0,f=a,p.label=2;case 2:return u<f.length?(l=f[u],h=l,[4,this.fetchChildrenOfContent(h,t,n+1,r,c)]):[3,5];case 3:d=p.sent(),s.push(d),p.label=4;case 4:return u++,[3,2];case 5:o.children=s,p.label=6;case 6:return[3,8];case 7:o.hierarchyInfo=i,p.label=8;case 8:return[2,o]}}))}))},e.prototype.getContentsKeyList=function(e){return Ta(this,void 0,void 0,(function(){var t,n,r,i,o,a,c,s;return Na(this,(function(u){switch(u.label){case 0:t=[],n=new Aa,r=[],i="",n.push(e),u.label=1;case 1:return n.isEmpty()?[3,4]:(o=n.pop(),Jr.hasChildren(o[Wt.COLUMN_NAME_LOCAL_DATA])?[4,this.getSortedChildrenListOld(o[Wt.COLUMN_NAME_LOCAL_DATA],Pn.ALL)]:[3,3]);case 2:u.sent().forEach((function(e){n.push(e),r.push(o[Wt.COLUMN_NAME_IDENTIFIER].concat("/",e[Wt.COLUMN_NAME_IDENTIFIER]))})),u.label=3;case 3:if(i){for(a=void 0,c=i.split("/").length-1;c>=0&&(s=i.split("/")[c],!Er.contains(r,s.concat("/",o[Wt.COLUMN_NAME_IDENTIFIER])));c--)i=i.substring(0,i.lastIndexOf("/"));Rn.COLLECTION.valueOf()===o[Wt.COLUMN_NAME_MIME_TYPE]?i=i+"/"+o[Wt.COLUMN_NAME_IDENTIFIER]:(a=i+"/"+o[Wt.COLUMN_NAME_IDENTIFIER],t.push(a))}else i=o[Wt.COLUMN_NAME_IDENTIFIER];return[3,1];case 4:return[2,t]}}))}))},e.prototype.getContentFromDB=function(e,t,n){return Ta(this,void 0,void 0,(function(){var e,r,i,o,a,c,s,u;return Na(this,(function(f){switch(f.label){case 0:if(e=[],!t)return[3,6];i=t.split("/"),o=i.length,a=!0,c=0,f.label=1;case 1:return c<o-1?[4,this.getContentDetailsHandler.fetchFromDB(i[c]).toPromise()]:[3,4];case 2:if(!(s=f.sent()))return a=!1,[3,4];e.push({identifier:s[Wt.COLUMN_NAME_IDENTIFIER],contentType:s[Wt.COLUMN_NAME_CONTENT_TYPE]}),f.label=3;case 3:return c++,[3,1];case 4:return a?[4,this.getContentDetailsHandler.fetchFromDB(i[o-1]).toPromise()]:[3,6];case 5:(u=f.sent())&&((r=_a.mapContentDBEntryToContent(u,n)).hierarchyInfo=e,r.rollup=Jr.getContentRollup(r.identifier,r.hierarchyInfo)),f.label=6;case 6:return[2,r]}}))}))},e.prototype.getNextContentIdentifier=function(e,t,n){var r,i="";e.forEach((function(e){i=i?i.concat("/",e.identifier):e.identifier})),i=i.concat("/",t);var o=n.indexOf(i);return o>0&&(r=n[o-1]),r},e.prototype.getPreviousContentIdentifier=function(e,t,n){var r,i="";e.forEach((function(e){i=i?i.concat("/",e.identifier):e.identifier})),i=i.concat("/",t);var o=n.indexOf(i);return-1!==o&&o<n.length-1&&(r=n[o+1]),r},e.prototype.getSortedChildrenListOld=function(e,t){return Ta(this,void 0,void 0,(function(){var n,r,i,o,a,c,s,u;return Na(this,(function(f){if(n=JSON.parse(e),!(r=n.children)||!r.length)return[2,[]];switch(r=r.sort((function(e,t){return e.index-t.index})),i=[],o="",a=0,r.forEach((function(e){i.push(e.identifier),o=o.concat(" WHEN '"+e.identifier+"' THEN "+a),a+=1})),c="",a>0&&(c=c.concat(" ORDER BY CASE "+Wt.COLUMN_NAME_IDENTIFIER+" "+o+" END")),s="",t){case Pn.DOWNLOADED.valueOf():s=" AND "+Wt.COLUMN_NAME_CONTENT_STATE+"='"+Ln.ARTIFACT_AVAILABLE+"'";break;case Pn.SPINE.valueOf():s=" AND "+Wt.COLUMN_NAME_CONTENT_STATE+"='"+Ln.ONLY_SPINE+"'";break;case Pn.ALL.valueOf():default:s=""}return u="SELECT * FROM "+Wt.TABLE_NAME+"\n WHERE "+Wt.COLUMN_NAME_IDENTIFIER+"\n IN ("+Er.joinPreservingQuotes(i)+") "+s+" "+c,[2,this.dbService.execute(u).toPromise()]}))}))},e.prototype.getSortedChildrenList=function(e,t,n){return Ta(this,void 0,void 0,(function(){var r,i,o,a,c,s,u,f,l;return Na(this,(function(h){switch(h.label){case 0:if(r=JSON.parse(e),!(i=r.children)||!i.length)return[2,[]];i=i.sort((function(e,t){return e.index-t.index})),o=[],a=0,c=i,h.label=1;case 1:return a<c.length?(s=c[a],(u=n.get(s.identifier))?(o.push(u),[3,4]):[3,2]):[3,5];case 2:return f="SELECT * FROM "+Wt.TABLE_NAME+"\n WHERE "+Wt.COLUMN_NAME_IDENTIFIER+" = '"+s.identifier+"'",[4,this.dbService.execute(f).toPromise()];case 3:(l=h.sent()).length&&o.push(l[0]),h.label=4;case 4:return a++,[3,1];case 5:switch(t){case Pn.DOWNLOADED.valueOf():o=o.filter((function(e){return e[Wt.COLUMN_NAME_CONTENT_STATE]=Ln.ARTIFACT_AVAILABLE}));break;case Pn.SPINE.valueOf():o=o.filter((function(e){return e[Wt.COLUMN_NAME_CONTENT_STATE]=Ln.ONLY_SPINE}));break;case Pn.ALL.valueOf():}return[2,o]}}))}))},e.prototype.getChildIdentifiersFromManifest=function(e){return Ta(this,void 0,void 0,(function(){var t,n,r=this;return Na(this,(function(i){switch(i.label){case 0:return t="file:///"+e,n=[],[4,this.fileService.readAsText(t,Yn.MANIFEST.valueOf()).then((function(e){return Ta(r,void 0,void 0,(function(){var t;return Na(this,(function(r){return console.log("fileContents",JSON.parse(e)),(t=JSON.parse(e).archive.items).shift(),t.forEach((function(e){n.push(e.identifier)})),[2,n]}))}))})).catch((function(e){console.log("getChildIdentifiersFromManifest err",e)}))];case 1:return i.sent(),[2,n]}}))}))},e}(),wa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ca=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ia=function(){function e(e,t,n){this.dbService=e,this.fileService=t,this.sharedPreferences=n,this.updateNewContentModels=[],this.fileMapList=[]}return e.prototype.deleteAllChildren=function(e,t){return wa(this,void 0,void 0,(function(){var n,r,i,o,a,c,s,u,f,l=this;return Ca(this,(function(h){switch(h.label){case 0:return n=!1,r=Jr.getBasePath(e[Wt.COLUMN_NAME_PATH]),[4,this.fileService.readAsText(r,Yn.MANIFEST.valueOf()).then((function(e){return wa(l,void 0,void 0,(function(){var r,i,o=this;return Ca(this,(function(a){switch(a.label){case 0:return(r=JSON.parse(e).archive.items).shift(),i=[],r.forEach((function(e){i.push(e.identifier)})),[4,this.findAllContentsFromDbWithIdentifiers(i)];case 1:return a.sent().forEach((function(e){return wa(o,void 0,void 0,(function(){var r;return Ca(this,(function(i){switch(i.label){case 0:return[4,this.deleteOrUpdateContent(e,!0,t)];case 1:if(i.sent(),n=!0,(r=e[Wt.COLUMN_NAME_PATH])&&n&&Jr.getFirstPartOfThePathNameOnLastDelimiter(r))try{this.sharedPreferences.putString(J.KEY_LAST_MODIFIED,(new Date).getMilliseconds()+"").toPromise()}catch(e){console.log("Error",e)}return[2]}}))}))})),[2]}}))}))})).catch((function(e){console.log("fileread err",e)}))];case 1:return h.sent(),[4,this.getMetaData(this.fileMapList)];case 2:if(i=h.sent(),!this.updateNewContentModels.length)return[3,7];this.dbService.beginTransaction(),o=0,a=this.updateNewContentModels,h.label=3;case 3:return o<a.length?(c=a[o],u=(s=c)[Wt.COLUMN_NAME_IDENTIFIER],f=0,i&&(f=i[u]?i[u].size:0),s[Wt.COLUMN_NAME_SIZE_ON_DEVICE]=f,[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[u],modelJson:s}).toPromise()]):[3,6];case 4:h.sent(),h.label=5;case 5:return o++,[3,3];case 6:this.dbService.endTransaction(!0),h.label=7;case 7:return[2]}}))}))},e.prototype.deleteOrUpdateContent=function(e,t,n){return wa(this,void 0,void 0,(function(){var r,i,o,a,c,s,u,f,l,h;return Ca(this,(function(d){switch(d.label){case 0:return r=e[Wt.COLUMN_NAME_REF_COUNT],o=e[Wt.COLUMN_NAME_VISIBILITY],a=e[Wt.COLUMN_NAME_MIME_TYPE],c=e[Wt.COLUMN_NAME_PATH],n?(r>1&&o===Dn.DEFAULT.valueOf()&&(r-=1,o=Dn.PARENT.valueOf()),i=a===Rn.COLLECTION?Ln.ARTIFACT_AVAILABLE.valueOf():Ln.ONLY_SPINE.valueOf()):(a===Rn.COLLECTION.valueOf()&&r>1?i=Ln.ARTIFACT_AVAILABLE.valueOf():r>1&&t?i=Ln.ARTIFACT_AVAILABLE.valueOf():(o===Dn.DEFAULT.valueOf()&&(o=Dn.PARENT.valueOf()),i=Ln.ONLY_SPINE.valueOf()),r-=1),c?(i===Ln.ONLY_SPINE.valueOf()&&(s=e[Wt.COLUMN_NAME_LOCAL_DATA],u=s&&JSON.parse(s),f="",l="",s&&(f=u.appIcon?Xi.getFileName(u.appIcon):"",l=u.itemSetPreviewUrl?Xi.getFileName(u.itemSetPreviewUrl):""),this.rm(Jr.getBasePath(c),[f,l].join(":"))),e[Wt.COLUMN_NAME_VISIBILITY]=o,e[Wt.COLUMN_NAME_REF_COUNT]=Jr.addOrUpdateRefCount(r),e[Wt.COLUMN_NAME_CONTENT_STATE]=i,t?[3,2]:(e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]=0,[4,this.dbService.update({table:Wt.TABLE_NAME,modelJson:e,selection:Wt.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[e[Wt.COLUMN_NAME_IDENTIFIER]]}).pipe(Object(ge.map)((function(e){return e>0}))).toPromise()])):[3,3];case 1:return d.sent(),[3,3];case 2:(h={}).identifier=e[Wt.COLUMN_NAME_IDENTIFIER],h.path=Jr.getBasePath(c),this.fileMapList.push(h),this.updateNewContentModels.push(e),d.label=3;case 3:return[2]}}))}))},e.prototype.findAllContentsFromDbWithIdentifiers=function(e){var t=Er.joinPreservingQuotes(e),n=" WHERE "+Wt.COLUMN_NAME_IDENTIFIER+" IN ("+t+") AND "+Wt.COLUMN_NAME_REF_COUNT+" > 0",r="SELECT * FROM "+Wt.TABLE_NAME+" "+n;return this.dbService.execute(r).toPromise()},e.prototype.rm=function(e,t){return new Promise((function(n,r){try{sbutility.rm(e,t,(function(e){n(e)}),(function(e){console.error(e),r(!1)}))}catch(e){console.error(e),r(!1)}}))},e.prototype.getMetaData=function(e){return wa(this,void 0,void 0,(function(){return Ca(this,(function(t){return[2,new Promise((function(t,n){sbutility.getMetaData(e,(function(e){t(e)}),(function(e){console.error(e),n(e)}))}))]}))}))},e}(),Pa=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},La=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ra=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Da=function(){function e(e,t,n){this.appConfig=e,this.contentServiceConfig=t,this.telemetryService=n}return e.prototype.getSearchCriteria=function(e){var t,n=this,r=e.request,i=r.query,o=r.exists,a=r.limit,c=r.offset;r.hasOwnProperty("mode")&&"soft"===r.mode&&(t="soft");var s=[];if(r.hasOwnProperty("sort_by")){var u=r.sort_by;Object.keys(u).forEach((function(e){var t={sortAttribute:e,sortOrder:n.getSortOrder(String(u[e]))};s.push(t)}))}var f,l,h,d=Pa({},i?{query:i}:{},o?{exists:o}:{},{mode:t,sortCriteria:s,searchType:this.getSearchType(String(r.searchType)),offset:c||0,limit:a||100});if(r.hasOwnProperty("filters")){var p=r.filters;p.contentType&&(f=p.contentType),l=this.mapFilterValues(p,d),d.impliedFilters=l,d.contentTypes=f}return r.hasOwnProperty("facets")&&(h=r.facets,d.facets=h),d},e.prototype.getSearchContentRequest=function(e){return{query:e.query,offset:e.offset,limit:e.limit,mode:e.mode,exists:e.exists&&e.exists.length>0?e.exists:[],facets:e.facets&&e.facets.length>0?e.facets:[],sort_by:this.getSortByRequest(e.sortCriteria),filters:this.getSearchFilter(e),fields:e.fields}},e.prototype.getSearchFilter=function(e){return e.searchType.valueOf()===In.SEARCH.valueOf()?this.getSearchRequest(e):e.searchType.valueOf()===In.FILTER.valueOf()?this.getFilterRequest(e):{}},e.prototype.getFilterRequest=function(e){var t={compatibilityLevel:this.getCompatibilityLevelFilter(),contentType:e.contentTypes&&e.contentTypes.length>0?e.contentTypes:[]};return this.addFiltersToRequest(t,e.facetFilters),this.addFiltersToRequest(t,e.impliedFilters),e.impliedFiltersMap&&e.impliedFiltersMap.length>0&&e.impliedFiltersMap.forEach((function(e){t=Pa({},t,e)})),t},e.prototype.addFiltersToRequest=function(e,t){t&&t.length&&t.forEach((function(t){var n=[];t.values.forEach((function(e){e.apply&&n.push(e.name)})),n.length&&(e[t.name]=n)}))},e.prototype.getSearchRequest=function(e){return Pa({compatibilityLevel:this.getCompatibilityLevelFilter(),status:e.contentStatusArray,objectType:["Content"],contentType:e.contentTypes&&e.contentTypes.length>0?e.contentTypes:[]},e.keywords&&e.keywords.length?{keywords:e.keywords}:{},e.dialCodes&&e.dialCodes.length?{dialcodes:e.dialCodes}:{},e.createdBy&&e.createdBy.length?{createdBy:e.createdBy}:{},e.grade&&e.grade.length?{gradeLevel:e.grade}:{},{medium:e.medium&&e.medium.length>0?e.medium:[],board:e.board&&e.board.length>0?e.board:[],language:e.language&&e.language.length>0?e.language:[],topic:e.topic&&e.topic.length>0?e.topic:[],purpose:e.purpose&&e.purpose.length>0?e.purpose:[],channel:e.channel&&e.channel.length>0?e.channel:[],mimeType:e.mimeType&&e.mimeType.length>0?e.mimeType:[],subject:e.subject&&e.subject.length>0?e.subject:[]})},e.prototype.getSortByRequest=function(e){if(!e||!e.length)return{};var t=e[0].sortAttribute,n=e[0].sortOrder,r={};return r[t]=n,r},e.prototype.getCompatibilityLevelFilter=function(){return{min:1,max:this.appConfig.maxCompatibilityLevel}},e.prototype.createFilterCriteria=function(e,t,n){var r=this,i=[],o={query:e.query,limit:e.limit,offset:e.offset,facets:e.facets,contentTypes:e.contentTypes,sortCriteria:e.sortCriteria&&e.sortCriteria.length?e.sortCriteria:[],mode:"soft"===e.mode?"soft":"hard"};return t?(t.forEach((function(e){var t=n?n[e.name]:[],o=e.values,a=r.getSortedFilterValuesWithAppliedFilters(o,t);if(e.name){var c={name:e.name,values:a};i.push(c)}delete n[e.name]})),o.facetFilters=i,o.impliedFilters=this.mapFilterValues(n,o),o):o},e.prototype.addFilterValue=function(e,t){e&&e.length>0&&e.forEach((function(e){var n=e.name;e.values,t[n]}))},e.prototype.getFilterValuesWithAppliedFilter=function(e,t){return e.forEach((function(e){var n=!1;t&&t.indexOf(name)>-1&&(n=!0),e.apply=n})),e},e.prototype.mapSearchResponse=function(e,t,n){return{id:t.id,responseMessageId:t.params.resmsgid,filterCriteria:this.createFilterCriteria(e,t.result.facets,n.filters),request:n,contentDataList:t.result.content,collectionDataList:t.result.collections?t.result.collections:[]}},e.prototype.getContentSearchFilter=function(e,t,n){return void 0===n&&(n=[]),{filters:{compatibilityLevel:this.getCompatibilityLevelFilter(),identifier:e.filter((function(t,n){return e.indexOf(t)===n})),status:t,objectType:["Content"]},fields:n.concat(["downloadUrl","variants","mimeType","contentType","pkgVersion"])}},e.prototype.getDownloadUrl=function(e,t){return La(this,void 0,void 0,(function(){var n,r,i;return Ra(this,(function(o){switch(o.label){case 0:return e.mimeType!==Rn.COLLECTION.valueOf()?[3,4]:(r=e.variants)&&r.online?(i=r.online,n=i&&i.ecarUrl,[4,this.buildContentLoadingEvent("online",t,e.contentType,e.pkgVersion)]):[3,2];case 1:return o.sent(),[3,4];case 2:return r&&r.spine?(i=r.spine,n=i&&i.ecarUrl,[4,this.buildContentLoadingEvent("spine",t,e.contentType,e.pkgVersion)]):[3,4];case 3:o.sent(),o.label=4;case 4:return n?[3,6]:(n=e.downloadUrl.trim(),[4,this.buildContentLoadingEvent("full",t,e.contentType,e.pkgVersion)]);case 5:o.sent(),o.label=6;case 6:return[2,n]}}))}))},e.prototype.buildContentLoadingEvent=function(e,t,n,r){var i=new dn;return i.type=Qe.OTHER,i.subType=e,i.pageId="ImportContent",i.id="ImportContent",i.objId=t.contentId,i.objType=n,i.objVer=r,i.rollup=t.rollUp,i.correlationData=t.correlationData,this.telemetryService.interact(i).toPromise()},e.prototype.getSortOrder=function(e){return"asc"===e?wn.ASC:wn.DESC},e.prototype.getSearchType=function(e){return"search"===e?In.SEARCH:"filter"===e?In.FILTER:In.SEARCH},e.prototype.getSortedFilterValuesWithAppliedFilters=function(e,t){return e.forEach((function(e){var n=!1;t&&t.forEach((function(t){t&&e.name&&e.name===t.toLowerCase()&&(n=!0)})),e.apply=n,e.count=it.parseInt(e.count)})),e},e.prototype.mapFilterValues=function(e,t){var n=[],r=[];return Object.keys(e).forEach((function(t){var i=e[t];if(Array.isArray(i)&&i.length){var o=[];i.forEach((function(e){var t={name:e,apply:!0};o.push(t)})),n.push({name:t,values:o})}else if(i){var a={};a[t]=i,r.push(a)}})),t.impliedFiltersMap=r,n},e}(),ja=function(){function e(){}return e.prototype.getAllLocalContentQuery=function(e){e.contentTypes&&e.contentTypes.length||(e.contentTypes=["Story","Worksheet","Game","Resource","Collection","TextBook"]);var t=e.uid,n=e.resourcesOnly?"":"c."+Wt.COLUMN_NAME_VISIBILITY+" = '"+Dn.DEFAULT.valueOf()+"' AND",r="c."+Wt.COLUMN_NAME_CONTENT_STATE+" = '"+Ln.ARTIFACT_AVAILABLE.valueOf()+"'",i=n+" "+r;if(e.resourcesOnly){i=i+" AND ("+("c."+Wt.COLUMN_NAME_MIME_TYPE+" != '"+Rn.COLLECTION.valueOf()+"'")+")"}else{var o=Er.joinPreservingQuotes(e.contentTypes);i=i+" AND ("+("c."+Wt.COLUMN_NAME_CONTENT_TYPE+" IN("+o.toLowerCase()+")")+")"}var a=this.getAudienceFilter(e.audience),c=this.getPragmaFilter(e.exclPragma,e.pragma),s=this.generateBoardMediumGradeQuery(e);a&&(i=i+" AND ("+a+")"),c&&(i=i+" AND ("+c+")"),s&&(i=i+" AND ("+s+")");var u="WHERE ("+i+")",f="",l=e.resourcesOnly?"":this.generateSortByQuery(e.sortCriteria,t);return e.recentlyViewed?t&&(u="WHERE ("+(i=e.localOnly?"ca."+Jt.COLUMN_NAME_UID+" = '"+t+"' AND "+r+"\n AND cm."+Wt.COLUMN_NAME_MIME_TYPE+" NOT IN ('"+Rn.COLLECTION.valueOf()+"', '')":"ca."+Jt.COLUMN_NAME_UID+" = '"+t+"'\n AND cm."+Wt.COLUMN_NAME_MIME_TYPE+" NOT IN ('"+Rn.COLLECTION.valueOf()+"', '')")+")",f=this.getRecentlyViewedQuery(u,l,e.limit)):f=t?this.getLocalOnlyQuery(u,l,t):"SELECT c.* FROM "+Wt.TABLE_NAME+" c "+u+" "+l,f},e.prototype.getAudienceFilter=function(e){var t="";return e&&e.forEach((function(e){t=t.concat(t.length>0?" OR ":"","c."+Wt.COLUMN_NAME_AUDIENCE+" LIKE '%%"+e+"%%'")})),t},e.prototype.getPragmaFilter=function(e,t){var n="";return e?e.forEach((function(e){n=n.concat(n.length>0?" OR ":"","c."+Wt.COLUMN_NAME_PRAGMA+" NOT LIKE '%%"+e+"%%'")})):t&&t.forEach((function(e){n=n.concat(n.length>0?" OR ":"","c."+Wt.COLUMN_NAME_PRAGMA+" LIKE '%%"+e+"%%'")})),n},e.prototype.getRecentlyViewedQuery=function(e,t,n){return"SELECT c.*, ca."+Jt.COLUMN_NAME_EPOCH_TIMESTAMP+",\n cm."+en.COLUMN_NAME_DATA+" FROM "+Jt.TABLE_NAME+" ca LEFT JOIN\n "+en.TABLE_NAME+" cm ON\n (cm."+en.COLUMN_NAME_UID+" = ca."+Jt.COLUMN_NAME_UID+"\n AND cm."+en.COLUMN_NAME_CONTENT_IDENTIFIER+" = ca."+Jt.COLUMN_NAME_CONTENT_IDENTIFIER+")\n LEFT JOIN "+Wt.TABLE_NAME+" c ON\n c."+Wt.COLUMN_NAME_IDENTIFIER+" = ca."+Jt.COLUMN_NAME_CONTENT_IDENTIFIER+"\n "+e+" "+t+" LIMIT "+n},e.prototype.getLocalOnlyQuery=function(e,t,n){var r="";return r=Array.isArray(n)?"ca."+Jt.COLUMN_NAME_UID+" IN ("+Er.joinPreservingQuotes(n)+")":"ca."+Jt.COLUMN_NAME_UID+" ='"+n+"'","SELECT c.*, ca."+Jt.COLUMN_NAME_EPOCH_TIMESTAMP+"\n FROM "+Wt.TABLE_NAME+" c LEFT JOIN "+Jt.TABLE_NAME+" ca\n ON c."+Wt.COLUMN_NAME_IDENTIFIER+" = ca."+Jt.COLUMN_NAME_CONTENT_IDENTIFIER+"\n AND "+r+"\n "+e+" "+t},e.prototype.generateSortByQuery=function(e,t){var n=this,r="",i=0;return e||((e=[]).push({sortAttribute:"lastUsedOn",sortOrder:wn.DESC}),e.push({sortAttribute:"localLastUpdatedOn",sortOrder:wn.DESC})),e.forEach((function(e){e&&("lastUsedOn"===e.sortAttribute.valueOf()&&t?(r=n.generateOrderByQuery(i,r," ca."+Jt.COLUMN_NAME_EPOCH_TIMESTAMP,e.sortOrder.valueOf()),i++):"localLastUpdatedOn"===e.sortAttribute.valueOf()?(r=n.generateOrderByQuery(i,r," c."+Wt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON,e.sortOrder.valueOf()),i++):"sizeOnDevice"===e.sortAttribute.valueOf()&&(r=n.generateOrderByQuery(i,r," c."+Wt.COLUMN_NAME_SIZE_ON_DEVICE,e.sortOrder.valueOf()),i++))})),r},e.prototype.generateOrderByQuery=function(e,t,n,r){return(e>0?t.concat(","):t.concat("ORDER BY")).concat(n+" "+r)},e.prototype.generateBoardMediumGradeQuery=function(e){var t="";return e.board&&e.board.length&&(t=t.concat(this.generateLikeQuery(e.board,Wt.COLUMN_NAME_BOARD))),e.medium&&e.medium.length&&(t&&(t=t.concat(" AND ")),t=t.concat(this.generateLikeQuery(e.medium,Wt.COLUMN_NAME_MEDIUM))),e.grade&&e.grade.length&&(t&&(t=t.concat(" AND ")),t=t.concat(this.generateLikeQuery(e.grade,Wt.COLUMN_NAME_GRADE))),t},e.prototype.generateLikeQuery=function(e,t){for(var n="",r=t+" LIKE ",i=0;i<e.length;i++)n=i<e.length-1?n.concat(r,"'%%~"+e[i].toLowerCase().trim()+"~%%' OR "):n.concat(r,"'%%~"+e[i].toLowerCase().trim()+"~%%' ");return n},e}(),Ua=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ka=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},xa=Wt.COLUMN_NAME_LOCAL_DATA,Ba=Wt.COLUMN_NAME_IDENTIFIER,Fa=Wt.COLUMN_NAME_REF_COUNT,Va=function(){function e(e,t,n){this.deviceInfo=e,this.dbService=t,this.fileService=n}return e.prototype.populateItems=function(e){var t=this,n=[],r=[],i=[],o={};e.forEach((function(e){var n=JSON.parse(e[xa]);if(o[e[Ba]]=n,Jr.addViralityMetadataIfMissing(n,t.deviceInfo.getDeviceID()),Jr.hasChildren(n)){var a=Jr.getChildContentsIdentifiers(n);i=i.concat(a)}r.push(e[Ba])}));try{r.forEach((function(e){var t=o[e];Er.contains(i,e)&&(t.visibility=Dn.PARENT.valueOf()),n.push(t)}))}catch(e){console.log(e)}return n},e.prototype.populateItemList=function(e){var t=this,n=[],r=[],i=[],o={};e.forEach((function(e){if(o[e.identifier]=e,Jr.addViralityMetadataIfMissing(e,t.deviceInfo.getDeviceID()),Jr.hasChildren(e)){var n=Jr.getChildContentsIdentifiers(e);i=i.concat(n)}r.push(e.identifier)}));try{r.forEach((function(e){var t=o[e];Er.contains(i,e)&&(t.visibility=Dn.PARENT.valueOf()),n.push(t)}))}catch(e){console.log(e)}return n},e.prototype.getContentExportDBModelToExport=function(e){return Ua(this,void 0,void 0,(function(){var t,n,r,i=this;return ka(this,(function(o){switch(o.label){case 0:return t=[],[4,this.findAllContentsWithIdentifiers(e)];case 1:return n=o.sent(),r=Jr.getBasePath(n[0][Wt.COLUMN_NAME_PATH]),[4,this.fileService.readAsText(r,Yn.MANIFEST.valueOf()).then((function(e){return Ua(i,void 0,void 0,(function(){var n,r;return ka(this,(function(i){switch(i.label){case 0:return n=JSON.parse(e).archive.items,r=[],n.forEach((function(e){r.push(e.identifier)})),[4,this.findAllContentsWithIdentifiers(r,!0)];case 1:return t=i.sent(),[2]}}))}))})).catch((function(e){console.log("fileRead error",e)}))];case 2:return o.sent(),[2,Promise.resolve(Jr.deDupe(t,"identifier"))]}}))}))},e.prototype.generateManifestForArchive=function(t){var n={},r={ttl:24};return r.count=t.length,r.items=t,n.id=e.EKSTEP_CONTENT_ARCHIVE,n.ver=e.SUPPORTED_MANIFEST_VERSION,n.ts=ye().format("YYYY-MM-DDTHH:mm:ss[Z]"),n.archive=r,n},e.prototype.findAllContentsWithIdentifiers=function(e,t){var n="";t&&e.length&&(n=e.reduce((function(e,t,n){return e+" WHEN '"+t+"' THEN "+n})," ORDER BY CASE "+Ba)+" END");var r=Er.joinPreservingQuotes(e),i=" where "+Ba+" in ("+r+") AND "+Fa+" > 0",o="select * from "+Wt.TABLE_NAME+" "+i+" "+n;return this.dbService.execute(o).toPromise()},e.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",e.SUPPORTED_MANIFEST_VERSION="1.1",e}(),Ya=function(){function e(e,t){this.dbService=e,this.exportHandler=t}return e.prototype.execute=function(t){var n=new D,r=this.exportHandler.populateItems(t.contentModelsToExport);t.items=[],t.manifest={},t.items=t.items.concat(r);var i={ttl:24};return i.count=t.items.length,i.items=t.items,t.manifest.id=e.EKSTEP_CONTENT_ARCHIVE,t.manifest.ver=e.SUPPORTED_MANIFEST_VERSION,t.manifest.ts=ye().format(),t.manifest.archive=i,n.body=t,Promise.resolve(n)},e.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",e.SUPPORTED_MANIFEST_VERSION="1.1",e}(),Ga=function(){function e(e,t){this.fileService=e,this.deviceInfo=t}return e.prototype.execute=function(e){var t=this,n=new D;return this.deviceInfo.getAvailableInternalMemorySize().toPromise().then((function(r){var i=Number(r);if(i>0&&i<1048576)throw n.errorMesg=Fn.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT,n;return t.fileService.writeFile(e.tmpLocationPath,Yn.MANIFEST.valueOf(),JSON.stringify(e.manifest),{replace:!0})})).then((function(){return n.body=e,Promise.resolve(n)})).catch((function(){return n.errorMesg=Fn.EXPORT_FAILED_WRITING_MANIFEST,Promise.reject(n)}))},e}(),Ha=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},qa=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},za=function(){function e(e){this.zipService=e}return e.prototype.execute=function(e){return Ha(this,void 0,void 0,(function(){var t,n,r,i,o,a=this;return qa(this,(function(c){switch(c.label){case 0:t=new D,n=function(t){var n,r,i,o,c,s,u;return qa(this,(function(f){switch(f.label){case 0:return n=t,r=JSON.parse(n[Wt.COLUMN_NAME_LOCAL_DATA]),!Jr.isAvailableLocally(n[Wt.COLUMN_NAME_CONTENT_STATE])||Jr.isOnlineContent(r)||Jr.isInlineIdentity(r.contentDisposition,r.contentEncoding)?[2,"continue"]:(i=r.artifactUrl)?(o=e.tmpLocationPath.concat(i),c=n[Wt.COLUMN_NAME_PATH],u=[],(s=[]).push(n[Wt.COLUMN_NAME_IDENTIFIER]),u.push(n[Wt.COLUMN_NAME_IDENTIFIER].concat("/",Yn.MANIFEST.valueOf())),[4,new Promise((function(e,t){a.zipService.zip(c,{target:o},s,u,(function(){e()}),(function(){t()}))}))]):[3,2];case 1:f.sent(),f.label=2;case 2:return[2]}}))},r=0,i=e.contentModelsToExport,c.label=1;case 1:return r<i.length?(o=i[r],[5,n(o)]):[3,4];case 2:c.sent(),c.label=3;case 3:return r++,[3,1];case 4:return t.body=e,[2,Promise.resolve(t)]}}))}))},e}(),Ka=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Wa=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Xa=function(){function e(e){this.fileService=e}return e.prototype.execute=function(e){return Ka(this,void 0,void 0,(function(){var t,n=this;return Wa(this,(function(r){return t=new D,[2,this.fileService.getFreeDiskSpace().then((function(r){n.getFileSize(e.items);return t.body=e,t}))]}))}))},e.prototype.getFileSize=function(e){var t=0;return e&&e.forEach((function(e){e.size&&(t+=Number(e.size))})),t},e}(),Ja=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Qa=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},$a=function(){function e(e){this.fileService=e}return e.prototype.execute=function(e){return Ja(this,void 0,void 0,(function(){var t,n,r,i,o,a,c,s,u,f,l,h,d,p,b,_,E;return Qa(this,(function(y){switch(y.label){case 0:t=new D,y.label=1;case 1:y.trys.push([1,15,,16]),n=0,r=0,i=e.contentModelsToExport,y.label=2;case 2:if(!(r<i.length))return[3,14];o=i[r],a=o,c=e.items[n],s=c.appIcon,u=c.itemSetPreviewUrl,f=0,l=[s,u],y.label=3;case 3:if(!(f<l.length))return[3,8];if(!(h=l[f])||h.startsWith("https:"))return[3,7];y.label=4;case 4:return y.trys.push([4,6,,7]),[4,this.copyFile(a[Wt.COLUMN_NAME_PATH],e.tmpLocationPath,h)];case 5:return y.sent(),[3,7];case 6:return d=y.sent(),console.error(d),[3,7];case 7:return f++,[3,3];case 8:if(p=c.contentDisposition,b=c.contentEncoding,!Jr.isInlineIdentity(p,b))return[3,12];if(!(_=c.artifactUrl))return[3,12];y.label=9;case 9:return y.trys.push([9,11,,12]),[4,this.copyFile(a[Wt.COLUMN_NAME_PATH],e.tmpLocationPath,_)];case 10:return y.sent(),[3,12];case 11:return E=y.sent(),console.error(E),[3,12];case 12:n++,y.label=13;case 13:return r++,[3,2];case 14:return t.body=e,[2,t];case 15:throw y.sent(),t.errorMesg=Fn.EXPORT_FAILED_COPY_ASSET,t;case 16:return[2]}}))}))},e.prototype.copyFile=function(e,t,n){return Ja(this,void 0,void 0,(function(){return Qa(this,(function(r){return[2,new Promise((function(r,i){sbutility.copyFile(e,t,n,(function(){r()}),(function(e){console.error(e),r(e)}))}))]}))}))},e}(),Za=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ec=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},tc=function(){function e(e,t){this.fileService=e,this.zipService=t}return e.prototype.execute=function(t){return Za(this,void 0,void 0,(function(){var n,r,i=this;return ec(this,(function(o){switch(o.label){case 0:return n=new D,[4,new Promise((function(e,r){i.zipService.zip(t.tmpLocationPath,{target:t.ecarFilePath},[],[],(function(){e()}),(function(){throw n.errorMesg=Fn.EXPORT_FAILED_ECAR_BUNDLE,n}))}))];case 1:return o.sent(),[4,this.fileService.getMetaData(t.ecarFilePath)];case 2:return r=o.sent(),t.metadata[e.FILE_SIZE]=r.size,n.body=t,[2,n]}}))}))},e.FILE_SIZE="FILE_SIZE",e}(),nc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},rc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ic=function(){function e(e,t){this.fileService=e,this.zipService=t,this.FILE_SIZE="FILE_SIZE"}return e.prototype.execute=function(e){var t,n=this,r=new D;return this.fileService.getMetaData(e.ecarFilePath).then((function(r){return t=r.size,n.fileService.createDir(e.tmpLocation.concat(nr.generateUniqueId()),!0)})).then((function(i){return nc(n,void 0,void 0,(function(){var n=this;return rc(this,(function(o){switch(o.label){case 0:return e.tmpLocation=i.nativeURL,[4,new Promise((function(t,r){n.zipService.unzip(e.ecarFilePath,{target:i.nativeURL},(function(){t()}),(function(e){r(e)}))}))];case 1:return o.sent(),e.metadata={},e.metadata.FILE_SIZE=t,r.body=e,[2,Promise.resolve(r)]}}))}))})).catch((function(e){return r.errorMesg=Fn.IMPORT_FAILED_EXTRACT_ECAR.valueOf(),Promise.reject(r)}))},e}(),oc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ac=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},cc=function(){function e(e,t,n,r){this.fileService=e,this.dbService=t,this.appConfig=n,this.getContentDetailsHandler=r}return e.prototype.execute=function(e){return oc(this,void 0,void 0,(function(){var t,n,r,i,o,a,c,s,u,f,l,h,d,p,b,_,E,y,v,g,m,S,O,A,T;return ac(this,(function(N){switch(N.label){case 0:return t=new D,[4,this.fileService.readAsText(e.tmpLocation,Yn.MANIFEST.valueOf())];case 1:return(n=N.sent())?[3,3]:(t.errorMesg=Fn.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND.valueOf(),[4,this.fileService.removeRecursively(e.tmpLocation)]);case 2:throw N.sent(),t;case 3:return 1!==(r=JSON.parse(n)).ver?[3,5]:(t.errorMesg=Fn.IMPORT_FAILED_UNSUPPORTED_MANIFEST.valueOf(),[4,this.fileService.removeRecursively(e.tmpLocation)]);case 4:throw N.sent(),t;case 5:return(i=r.archive).items?[3,7]:(t.errorMesg=Fn.IMPORT_FAILED_NO_CONTENT_METADATA.valueOf(),[4,this.fileService.removeRecursively(e.tmpLocation)]);case 6:throw N.sent(),t;case 7:for(e.manifestVersion=r.ver,e.items=[],o=i.items,a=[],c=0,s=o;c<s.length;c++)b=s[c],E=(_=b).identifier,a.push(E);return u=Er.joinPreservingQuotes(a),[4,this.getContentDetailsHandler.fetchFromDBForAll(u).toPromise()];case 8:for(f=N.sent(),l=f.reduce((function(e,t){return e[t.identifier]=t,e}),{}),h=!1,e.existedContentIdentifiers={},d=0,p=o;d<p.length;d++)b=p[d],E=(_=b).identifier,y=Jr.readVisibility(_),v=Jr.readCompatibilityLevel(_),y!==Dn.DEFAULT||Jr.isCompatible(this.appConfig,v)?(g=_.status,(m=Jr.isDraftContent(g))&&Jr.isExpired(_.expires)?this.skipContent(e,E,y,Bn.CONTENT_EXPIRED,o):(y===Dn.DEFAULT.valueOf()&&(h=!1),S=l[E],O=void 0,S&&(A=S[Wt.COLUMN_NAME_REF_COUNT],(O=S[Wt.COLUMN_NAME_PATH])&&y===Dn.DEFAULT.valueOf()&&A&&A>0&&(h=!0,(T=JSON.parse(S[Wt.COLUMN_NAME_LOCAL_DATA]))&&_.pkgVersion>T.pkgVersion&&T.childNodes&&T.childNodes.length>0&&(e.contentIdsToDelete=new Set(T.childNodes)))),O&&y===Dn.DEFAULT.valueOf()&&!Jr.isDuplicateCheckRequired(m,_.pkgVersion)&&Jr.isImportFileExist(S,_)?(e.rootIdentifier=E,this.skipContent(e,E,y,Bn.ALREADY_EXIST,o)):(h&&e.contentIdsToDelete.delete(E)&&(e.existedContentIdentifiers[E]=!0),e.items.push(_)))):this.skipContent(e,E,y,Bn.NOT_COMPATIBLE,o);return t.body=e,[2,t]}}))}))},e.prototype.skipContent=function(e,t,n,r,i){n===Dn.DEFAULT&&(r===Bn.ALREADY_EXIST?i&&1===i.length&&e.contentImportResponseList.push({identifier:t,status:r}):e.contentImportResponseList.push({identifier:t,status:r})),e.skippedItemsIdentifier.push(t)},e}(),sc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},uc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},fc=function(){function e(e,t,n){this.dbService=e,this.sharedPreferences=t,this.fileService=n}return e.prototype.execute=function(){return this.updateAllRootContentSize().toPromise()},e.prototype.findAllChildContents=function(e){var t="SELECT * FROM "+Wt.TABLE_NAME+"\n WHERE "+Wt.COLUMN_NAME_IDENTIFIER+" IN ("+Er.joinPreservingQuotes(e)+")\n AND "+Wt.COLUMN_NAME_REF_COUNT+" > 0";return this.dbService.execute(t).toPromise()},e.prototype.updateAllRootContentSize=function(){var e=this,t="SELECT * FROM "+Wt.TABLE_NAME+" WHERE "+Wt.COLUMN_NAME_REF_COUNT+" > 0\n AND "+Wt.COLUMN_NAME_VISIBILITY+" = '"+Dn.DEFAULT.valueOf()+"'";return this.dbService.execute(t).pipe(Object(ge.tap)((function(){return sc(e,void 0,void 0,(function(){return uc(this,(function(e){return[2,this.sharedPreferences.putBoolean(J.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()]}))}))})),Object(ge.mergeMap)((function(t){return sc(e,void 0,void 0,(function(){var e,n=this;return uc(this,(function(r){switch(r.label){case 0:return e=[],[4,Promise.all(t.map((function(t){return sc(n,void 0,void 0,(function(){var n,r;return uc(this,(function(i){switch(i.label){case 0:return[4,this.getSizeOnDevice(t)];case 1:return n=i.sent(),(r=JSON.parse(t[Wt.COLUMN_NAME_LOCAL_DATA]).childNodes)?[4,this.findAllChildContents(r)]:[3,3];case 2:i.sent().forEach((function(e){n+=e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]||0})),t[Wt.COLUMN_NAME_SIZE_ON_DEVICE]=n,e.push(t),i.label=3;case 3:return[2]}}))}))})))];case 1:return r.sent(),this.updateInDb(e),[2]}}))}))})),Object(ge.tap)((function(){return sc(e,void 0,void 0,(function(){return uc(this,(function(e){return[2,this.sharedPreferences.putBoolean(J.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()]}))}))})))},e.prototype.getSizeOnDevice=function(e){return sc(this,void 0,void 0,(function(){var t,n,r,i,o;return uc(this,(function(a){switch(a.label){case 0:return t=0,e[Wt.COLUMN_NAME_MIME_TYPE]!==Rn.COLLECTION.valueOf()?[3,3]:e[Wt.COLUMN_NAME_VISIBILITY]!==Dn.DEFAULT.valueOf()?[3,2]:(n=[],r={},i=e[Wt.COLUMN_NAME_IDENTIFIER],r.identifier=i,r.path=e[Wt.COLUMN_NAME_PATH],n.push(r),[4,this.getMetaData(n)]);case 1:o=a.sent(),t=o[i]?o[i].size:0,a.label=2;case 2:return[3,4];case 3:t=e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]?e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]:0,a.label=4;case 4:return[2,Promise.resolve(t||0)]}}))}))},e.prototype.updateInDb=function(e){return sc(this,void 0,void 0,(function(){var t,n,r,i,o;return uc(this,(function(a){for(this.dbService.beginTransaction(),t=0,n=e;t<n.length;t++)r=n[t],o=(i=r)[Wt.COLUMN_NAME_IDENTIFIER],this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[o],modelJson:i}).toPromise();return this.dbService.endTransaction(!0),[2]}))}))},e.prototype.getMetaData=function(e){return sc(this,void 0,void 0,(function(){return uc(this,(function(t){return[2,new Promise((function(t,n){sbutility.getMetaData(e,(function(e){t(e)}),(function(e){console.error(e),n(e)}))}))]}))}))},e.prototype.updateTextBookSize=function(e){var t=this;console.log("in updateAllRootContentSize");var n="SELECT * FROM "+Wt.TABLE_NAME+" WHERE "+Wt.COLUMN_NAME_IDENTIFIER+" == "+e;return this.dbService.execute(n).pipe(Object(ge.tap)((function(){return sc(t,void 0,void 0,(function(){return uc(this,(function(e){return[2,this.sharedPreferences.putBoolean(J.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()]}))}))})),Object(ge.mergeMap)((function(e){return sc(t,void 0,void 0,(function(){var t,n=this;return uc(this,(function(r){switch(r.label){case 0:return t=[],[4,Promise.all(e.map((function(e){return sc(n,void 0,void 0,(function(){var n,r;return uc(this,(function(i){switch(i.label){case 0:return[4,this.getSizeOnDevice(e)];case 1:return n=i.sent(),(r=JSON.parse(e[Wt.COLUMN_NAME_LOCAL_DATA]).childNodes)?[4,this.findAllChildContents(r)]:[3,3];case 2:i.sent().forEach((function(e){n+=e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]||0})),e[Wt.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e),i.label=3;case 3:return[2]}}))}))})))];case 1:return r.sent(),this.updateInDb(t),[2]}}))}))})),Object(ge.tap)((function(){return sc(t,void 0,void 0,(function(){return uc(this,(function(e){return[2,this.sharedPreferences.putBoolean(J.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()]}))}))})))},e}(),lc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},hc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},dc=Wt.COLUMN_NAME_VISIBILITY,pc=function(){function e(e,t,n,r,i,o,a,c){this.fileService=e,this.zipService=t,this.appConfig=n,this.dbService=r,this.deviceInfo=i,this.getContentDetailsHandler=o,this.eventsBusService=a,this.sharedPreferences=c}return e.prototype.execute=function(e){return lc(this,void 0,void 0,(function(){var t,n,r,i,o,a,c,s,u,f,l,h,d,p,b,_,E,y,v,g,m,S,O,A,T,N=this;return hc(this,(function(M){switch(M.label){case 0:for(t=new D,e.identifiers=[],n=[],r=[],i=new Map,o=new Map,c=0,this.postImportProgressEvent(c,e.items.length),s=[],u=[],f=[],l=0,h=e.items;l<h.length;l++)T=h[l],p=(d=T).identifier,b=Jr.readVisibility(d),_=d.appIcon,Jr.isNotUnit(d.mimeType,b)&&(u.push(p),_&&!_.startsWith("https:")&&f.push(p+"/"+_.substring(0,_.lastIndexOf("/")))),s.push(p);return[4,this.createDirectories(Jr.getContentRootDir(e.destinationFolder),u)];case 1:return E=M.sent(),[4,this.createDirectories(Jr.getContentRootDir(e.destinationFolder),f)];case 2:return M.sent(),y=Er.joinPreservingQuotes(s),[4,this.getContentDetailsHandler.fetchFromDBForAll(y).toPromise()];case 3:v=M.sent(),g=v.reduce((function(e,t){return e[t.identifier]=t,e}),{}),m=function(t){var s,u,f,l,h,d,p,b,_,y,v,m,O,A,T,M,w,C,I,P,L,R,D,j,U,k,x,B;return hc(this,(function(F){switch(F.label){case 0:return u=(s=t).identifier,e.skippedItemsIdentifier&&e.skippedItemsIdentifier.indexOf(u)>-1?[2,"continue"]:(f=s.mimeType,l=s.contentEncoding,h=s.contentDisposition,d=Jr.readContentType(s),p=Jr.readVisibility(s),b=Jr.readAudience(s),_=Jr.readPragma(s),y=Jr.readCompatibilityLevel(s),v=s.pkgVersion,m=s.artifactUrl,O=s.appIcon,A=s.itemSetPreviewUrl,T=s.board,M=s.medium,w=s.gradeLevel,C=Ln.ONLY_SPINE.valueOf(),P=g[u],L=void 0,P&&(L=Jr.getBasePath(P[Wt.COLUMN_NAME_PATH])),void 0,p===Dn.DEFAULT.valueOf()&&u,Jr.isNotUnit(f,p)?E[u]&&E[u].path?(I=E[u].path,[3,3]):[3,1]:[3,3]);case 1:return[4,S.fileService.createDir(Jr.getContentRootDir(e.destinationFolder).concat("/",u),!1)];case 2:R=F.sent(),I=R.nativeURL,F.label=3;case 3:return D=!1,(j=Jr.doesContentExist(P,u,v,!1))&&s.status!==jn.DRAFT.valueOf()?(P[dc]===Dn.DEFAULT.valueOf()&&(s=JSON.parse(P[Wt.COLUMN_NAME_LOCAL_DATA])),[3,14]):[3,4];case 4:return j=!1,Jr.isCompatible(S.appConfig,y)?m?h&&l&&(h!==kn.INLINE.valueOf()||l!==Un.GZIP.valueOf())?[3,6]:(U=e.tmpLocation.concat(m),[4,new Promise((function(e,t){N.zipService.unzip(U,{target:I},(function(){D=!0,e()}),(function(){e()}))}))]):[3,12]:[3,13];case 5:return F.sent(),[3,12];case 6:if(!Jr.isInlineIdentity(h,l))return[3,11];F.label=7;case 7:return F.trys.push([7,9,,10]),[4,S.copyAssets(e.tmpLocation,m,I)];case 8:return F.sent(),D=!0,[3,10];case 9:return F.sent(),D=!1,[3,10];case 10:return[3,12];case 11:kn.ONLINE.valueOf()===h&&(D=!0),F.label=12;case 12:C=D||Rn.COLLECTION.valueOf()===f?Ln.ARTIFACT_AVAILABLE.valueOf():Ln.ONLY_SPINE.valueOf(),F.label=13;case 13:if(Jr.isNotUnit(f,p))try{O.startsWith("https:")||S.copyAssets(e.tmpLocation,O,I,!0)}catch(e){}try{A.startsWith("https:")||S.copyAssets(e.tmpLocation,A,I,!1)}catch(e){}F.label=14;case 14:return k=S.getBasePath(I,j,L),p===Dn.DEFAULT.valueOf()?(a=k,e.rootIdentifier=u):Jr.isNotUnit(f,p)&&e.identifiers.push(u),x=S.getReferenceCount(P,p,e.isChildContent,e.existedContentIdentifiers),p=S.getContentVisibility(P,s.objectType,e.isChildContent,p),Jr.addOrUpdateViralityMetadata(s,S.deviceInfo.getDeviceID().toString()),0,Jr.isNotUnit(f,p)&&o.set(u,I),B=S.constructContentDBModel(u,e.manifestVersion,JSON.stringify(s),f,d,p,k,x,C,b,_,0,T,M,w),P?S.getContentState(P,C)===Ln.ONLY_SPINE.valueOf()||D||Rn.COLLECTION.valueOf()===f?r.push(B):B[Wt.COLUMN_NAME_CONTENT_STATE]=S.getContentState(P,C):n.push(B),i.set(u,B),++c%20!=0&&c!==e.items.length||S.postImportProgressEvent(c,e.items.length),[2]}}))},S=this,O=0,A=e.items,M.label=4;case 4:return O<A.length?(T=A[O],[5,m(T)]):[3,7];case 5:M.sent(),M.label=6;case 6:return O++,[3,4];case 7:return this.updateContentDB(n,r),setTimeout((function(){N.updateContentFileSizeInDB(e,i,o,g)}),5e3),a?[4,this.fileService.copyFile(e.tmpLocation,Yn.MANIFEST.valueOf(),a,Yn.MANIFEST.valueOf())]:[3,9];case 8:M.sent(),M.label=9;case 9:return t.body=e,[2,Promise.resolve(t)]}}))}))},e.prototype.updateContentFileSizeInDB=function(e,t,n,r){return lc(this,void 0,void 0,(function(){var i,o,a,c,s,u,f,l,h;return hc(this,(function(d){switch(d.label){case 0:i=[],o=0,a=e.items,d.label=1;case 1:if(!(o<a.length))return[3,6];if(c=a[o],s=c.identifier,u=t.get(s).mimeType,f=t.get(s).visibility,l=n.get(s),h=0,r[s],!Jr.isNotUnit(u,f))return[3,5];d.label=2;case 2:return d.trys.push([2,4,,5]),[4,this.fileService.getDirectorySize(l)];case 3:return h=d.sent(),t.get(s).size_on_device=h,i.push(t.get(s)),[3,5];case 4:return d.sent(),[3,5];case 5:return o++,[3,1];case 6:return this.updateContentDB([],i,!0),[2]}}))}))},e.prototype.updateContentDB=function(e,t,n){return lc(this,void 0,void 0,(function(){var r,i,o,a,c,s;return hc(this,(function(u){switch(u.label){case 0:if(!e.length&&!t.length)return[3,9];this.dbService.beginTransaction(),r=0,i=e,u.label=1;case 1:return r<i.length?(c=i[r],s=c,[4,this.dbService.insert({table:Wt.TABLE_NAME,modelJson:s}).toPromise()]):[3,4];case 2:u.sent(),u.label=3;case 3:return r++,[3,1];case 4:o=0,a=t,u.label=5;case 5:return o<a.length?(c=a[o],s=c,[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[s[Wt.COLUMN_NAME_IDENTIFIER]],modelJson:s}).toPromise()]):[3,8];case 6:u.sent(),u.label=7;case 7:return o++,[3,5];case 8:this.dbService.endTransaction(!0),u.label=9;case 9:return n&&new fc(this.dbService,this.sharedPreferences,this.fileService).execute(),[2]}}))}))},e.prototype.copyAssets=function(e,t,n,r){return lc(this,void 0,void 0,(function(){var i,o;return hc(this,(function(a){switch(a.label){case 0:return a.trys.push([0,5,,6]),t?(i=t.substring(0,t.lastIndexOf("/")),r?[3,2]:[4,this.fileService.createDir(n.concat(i),!1)]):[3,4];case 1:a.sent(),a.label=2;case 2:return[4,this.fileService.copyFile(e.concat(i),Xi.getFileName(t),n.concat(i),Xi.getFileName(t))];case 3:a.sent(),a.label=4;case 4:return[3,6];case 5:throw o=a.sent(),console.error("Cannot Copy Asset"),o;case 6:return[2]}}))}))},e.prototype.getContentVisibility=function(e,t,n,r){var i;return"Library"===t?i=Dn.PARENT.valueOf():e&&(n||Dn.PARENT.valueOf()!==e[dc])&&(i=e[dc]),i||r},e.prototype.getContentState=function(e,t){return e&&e[Wt.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[Wt.COLUMN_NAME_CONTENT_STATE]),t},e.prototype.getBasePath=function(e,t,n){return e&&!t?e:n},e.prototype.getReferenceCount=function(e,t,n,r){var i;e?(i=e[Wt.COLUMN_NAME_REF_COUNT],(r?r[e[Wt.COLUMN_NAME_IDENTIFIER]]:void 0)||n||Dn.DEFAULT.valueOf()===e[dc]&&Dn.DEFAULT.valueOf()===t||(i+=1)):i=1;return i},e.prototype.postImportProgressEvent=function(e,t){this.eventsBusService.emit({namespace:_e.CONTENT,event:{type:Gn.IMPORT_PROGRESS,payload:{totalCount:t,currentCount:e}}})},e.prototype.constructContentDBModel=function(e,t,n,r,i,o,a,c,s,u,f,l,h,d,p){var b;return(b={})[Wt.COLUMN_NAME_IDENTIFIER]=e,b[Wt.COLUMN_NAME_SERVER_DATA]="",b[Wt.COLUMN_NAME_PATH]=Jr.getBasePath(a),b[Wt.COLUMN_NAME_REF_COUNT]=c,b[Wt.COLUMN_NAME_CONTENT_STATE]=s,b[Wt.COLUMN_NAME_SIZE_ON_DEVICE]=l,b[Wt.COLUMN_NAME_MANIFEST_VERSION]=t,b[Wt.COLUMN_NAME_LOCAL_DATA]=n,b[Wt.COLUMN_NAME_MIME_TYPE]=r,b[Wt.COLUMN_NAME_CONTENT_TYPE]=i,b[Wt.COLUMN_NAME_VISIBILITY]=o,b[Wt.COLUMN_NAME_AUDIENCE]=u,b[Wt.COLUMN_NAME_PRAGMA]=f,b[Wt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]=ye(Date.now()).format(),b[Wt.COLUMN_NAME_BOARD]=Jr.getContentAttribute(h),b[Wt.COLUMN_NAME_MEDIUM]=Jr.getContentAttribute(d),b[Wt.COLUMN_NAME_GRADE]=Jr.getContentAttribute(p),b},e.prototype.createDirectories=function(e,t){return lc(this,void 0,void 0,(function(){return hc(this,(function(n){return[2,new Promise((function(n,r){sbutility.createDirectories(Jr.getBasePath(e),t,(function(e){n(e)}),(function(e){console.error(e),r(e)}))}))]}))}))},e}(),bc=n(120),_c=n.n(bc),Ec=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},yc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},vc=function(){function e(e,t,n){this.dbService=e,this.deviceInfo=t,this.fileService=n,this.contentDataMap={}}return e.prototype.execute=function(e){return Ec(this,void 0,void 0,(function(){var t,n,r,i,o,a=this;return yc(this,(function(c){switch(c.label){case 0:return[4,this.fileService.readAsText(e.tmpLocation,Yn.MANIFEST.valueOf())];case 1:t=c.sent(),n=JSON.parse(t),r=n.archive,r.items.forEach((function(e){a.contentDataMap[e.identifier]=e})),i=new D,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,this.createnWriteManifest(e.identifiers,e.destinationFolder)];case 3:return c.sent(),i.body=e,[2,Promise.resolve(i)];case 4:return o=c.sent(),console.error(o),[2,Promise.reject(i)];case 5:return[2]}}))}))},e.prototype.createnWriteManifest=function(e,t){return Ec(this,void 0,void 0,(function(){var n,r,i,o,a,c,s,u=this;return yc(this,(function(f){switch(f.label){case 0:for(n=new Va(this.deviceInfo),r=[],i=function(e){var i=o.contentDataMap[e],a=new _c.a;a.add(i);var c=void 0,s=[];s.push(i);for(var f=function(){if(c=a.dequeue(),Jr.hasChildren(c)){var e=Jr.getChildContentsIdentifiers(c);if(e&&e.length){var t=[];e.forEach((function(e){var n=u.contentDataMap[e];n&&(a.add(n),t.push(n))})),s=s.concat(t)}}};!a.isEmpty();)f();var l=n.populateItemList(s),h=n.generateManifestForArchive(l),d={};d.path=Jr.getBasePath(Jr.getContentRootDir(t).concat("/",e,"/")),d.fileName=Yn.MANIFEST.valueOf(),d.data=JSON.stringify(h),r.push(d)},o=this,a=0,c=e;a<c.length;a++)s=c[a],i(s);return[4,this.writeFile(r)];case 1:return f.sent(),[2]}}))}))},e.prototype.writeFile=function(e){return Ec(this,void 0,void 0,(function(){return yc(this,(function(t){return[2,new Promise((function(t,n){sbutility.writeFile(e,(function(e){t()}),(function(e){console.error(e),n(e)}))}))]}))}))},e}(),gc=function(){function e(e){this.fileService=e}return e.prototype.execute=function(e){var t=new D;return this.fileService.removeRecursively(e.tmpLocation).then((function(){return t.body=e,Promise.resolve(t)})).catch((function(){return Promise.reject(t)}))},e}(),mc=function(){function e(e){this.fileService=e}return e.prototype.execute=function(e){var t=new D;return this.fileService.createDir(e.tmpLocationPath.concat(nr.generateUniqueId()),!1).then((function(n){return e.tmpLocationPath=n.nativeURL,t.body=e,Promise.resolve(t)})).catch((function(){return Promise.reject(t)}))},e}(),Sc=function(){function e(e,t,n,r){this.apiService=e,this.contentServiceConfig=t,this.framework=n,this.langCode=r,this.SEARCH_ENDPOINT="/search"}return e.prototype.handle=function(e){var t=this.framework&&this.langCode&&"?framework="+this.framework+"&lang="+this.langCode,n=(new F.Builder).withHost(this.contentServiceConfig.host).withType(R.POST).withPath(this.contentServiceConfig.searchApiPath.concat(this.SEARCH_ENDPOINT).concat(t||"")).withApiToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return e.body})))},e}(),Oc=function(){function e(e){this.telemetryService=e}return e.prototype.execute=function(e){e.metadata;for(var t=[],n=0,r=e.items;n<r.length;n++){var i=r[n],o={type:Jr.readContentType(i),origin:Jr.readOriginFromContentMap(i),identifier:i.identifier,pkgVersion:Number(i.pkgVersion),transferCount:Jr.readTransferCountFromContentMap(i),size:Jr.readSizeFromContentMap(i)};t.push(o)}var a={dir:we.IN,type:Ce.FILE.valueOf(),items:t,env:"sdk",correlationData:e.correlationData,objId:e.items&&e.items.length?e.items[0].identifier:"",objType:e.items&&e.items.length?e.items[0].contentType:"",objVer:e.items&&e.items.length?Jr.readPkgVersion(e.items[0])+"":"",rollUp:e.rollUp},c=new D;return this.telemetryService.share(a).toPromise().then((function(){return c.body=e,Promise.resolve(c)})).catch((function(){return Promise.reject(c)}))},e}(),Ac=function(){function e(e){this.telemetryService=e}return e.prototype.execute=function(e,t,n){for(var r=new D,i=0,o=e.items;i<o.length;i++){var a=o[i];Ie.CONTENT,Jr.readOriginFromContentMap(a),a.identifier,Number(a.pkgVersion),Jr.readTransferCountFromContentMap(a),Jr.readSizeFromContentMap(a)}var c={dir:we.OUT,type:Ce.FILE.valueOf(),items:[],env:"sdk"};return this.telemetryService.share(c).toPromise().then((function(){var e={exportedFilePath:n.saveLocally?n.destinationFolder.concat(t):cordova.file.externalCacheDirectory.concat(t)};return r.body=e,Promise.resolve(r)})).catch((function(){return Promise.reject(r)}))},e}(),Tc=function(){function e(e){this.telemetryService=e}return e.prototype.execute=function(e,t){var n=e.items&&e.items.length?e.items[0].identifier:"",r=new dn;r.type=Qe.OTHER,r.subType=t,r.pageId="ImportContent",r.id="ImportContent",r.env="sdk",r.objId=n||e.identifier,r.objType=e.items&&e.items.length?e.items[0].contentType:"",r.objVer=e.items&&e.items.length?Jr.readPkgVersion(e.items[0])+"":"",r.correlationData=e.correlationData;var i=new D;return i.body=e,this.telemetryService.interact(r).pipe(Object(ge.map)((function(){return i}))).toPromise()},e}(),Nc=n(27),Mc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},wc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Cc=function(){function e(e){this.dbService=e}return e.prototype.getUsgaeSpace=function(e){var t="SELECT SUM("+Wt.COLUMN_NAME_SIZE_ON_DEVICE+") as total_size\n FROM "+Wt.TABLE_NAME+"\n WHERE "+Wt.COLUMN_NAME_VISIBILITY+" = '"+Dn.DEFAULT.valueOf()+"'\n AND "+Wt.COLUMN_NAME_PATH+" LIKE '"+e.replace("file://","")+"%'";return this.dbService.execute(t).pipe(Object(ge.map)((function(e){return e[0].total_size||0})))},e.prototype.getContentUsageSummary=function(e){return Mc(this,void 0,void 0,(function(){var t,n,r,i,o;return wc(this,(function(a){switch(a.label){case 0:t=[],n=0,r=e,a.label=1;case 1:return n<r.length?(i=r[n],[4,this.getUsgaeSpace(i).toPromise()]):[3,4];case 2:o=a.sent(),t.push({path:i,sizeOnDevice:o}),a.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))},e}(),Ic=function(){function e(e,t,n){this.sharedPreferences=e,this.key=t,this.toStringFunction=n,this.changes=new ie.BehaviorSubject(void 0)}return e.prototype.addAll=function(e){var t=this;return this.asSet().pipe(Object(ge.mergeMap)((function(n){return e.forEach((function(e){return n.add(e)})),t.sharedPreferences.putString(t.key,JSON.stringify(n.toArray())).pipe(Object(ge.mapTo)(void 0))})),Object(ge.tap)((function(){return t.changes.next(void 0)})))},e.prototype.add=function(e){var t=this;return this.asSet().pipe(Object(ge.mergeMap)((function(n){return n.add(e),t.sharedPreferences.putString(t.key,JSON.stringify(n.toArray())).pipe(Object(ge.mapTo)(void 0))})),Object(ge.tap)((function(){return t.changes.next(void 0)})))},e.prototype.clear=function(){var e=this;return this.sharedPreferences.putString(this.key,"[]").pipe(Object(ge.mapTo)(void 0),Object(ge.tap)((function(){return e.changes.next(void 0)})))},e.prototype.remove=function(e){var t=this;return this.asSet().pipe(Object(ge.mergeMap)((function(n){var r=n.remove(e);return t.sharedPreferences.putString(t.key,JSON.stringify(n.toArray())).pipe(Object(ge.mapTo)(r))})),Object(ge.tap)((function(){return t.changes.next(void 0)})))},e.prototype.contains=function(e){return this.asSet().pipe(Object(ge.map)((function(t){return t.contains(e)})))},e.prototype.asList=function(){return this.sharedPreferences.getString(this.key).pipe(Object(ge.map)((function(e){return e?JSON.parse(e):[]})))},e.prototype.asSet=function(){var e=this;return this.asList().pipe(Object(ge.map)((function(t){return t.reduce((function(e,t){return e.add(t),e}),new ca.a(e.toStringFunction))})))},e.prototype.asListChanges=function(){var e=this;return this.changes.asObservable().pipe(Object(ge.mergeMap)((function(){return e.asList()})))},e}(),Pc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Lc=function(){function e(e,t){this.apiService=e,this.contentServiceConfig=t,this.GET_CONTENT_HEIRARCHY_ENDPOINT="/hierarchy"}return e.prototype.handle=function(e){var t=this,n=(new F.Builder).withType(R.GET).withPath(this.contentServiceConfig.contentHeirarchyAPIPath+this.GET_CONTENT_HEIRARCHY_ENDPOINT+"/"+e.contentId).withApiToken(!0).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return t.mapContentFromContentHeirarchyData(e.body.result.content)})))},e.prototype.mapContentFromContentHeirarchyData=function(e){var t=this;return e.contentData=Pc({},e),e.children&&e.children.length&&(e.children=e.children.map((function(e){return t.mapContentFromContentHeirarchyData(Pc({},e))}))),e},e}(),Rc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Dc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},jc=function(){function e(){}return e.prototype.execute=function(e,t){return Rc(this,void 0,void 0,(function(){return Dc(this,(function(n){return[2,new Promise((function(n,r){var i;i=t.saveLocally?t.destinationFolder:cordova.file.externalCacheDirectory,sbutility.copyFile(Xi.getDirecory(e.body.ecarFilePath),i,Xi.getFileName(e.body.ecarFilePath),(function(){n(e)}),(function(e){console.error(e),n(e)}))}))]}))}))},e}(),Uc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},kc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},xc=function(){function e(){}return e.prototype.execute=function(e){return Uc(this,void 0,void 0,(function(){var t;return kc(this,(function(n){return t=new D,[2,new Promise((function(n,r){var i=e.destinationFolder.concat("tmp/");sbutility.rm(i,"",(function(){t.body=e,n(t)}),(function(r){t.body=e,n(t)}))}))]}))}))},e}(),Bc=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Fc=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Vc=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Yc=function(e,t){return function(n,r){t(n,r,e)}},Gc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Hc=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},qc=function(){function e(e,n,r,i,o,a,c,s,u,f,l,h,d,p){this.sdkConfig=e,this.apiService=n,this.dbService=r,this.profileService=i,this.fileService=o,this.zipService=a,this.deviceInfo=c,this.telemetryService=s,this.contentFeedbackService=u,this.downloadService=f,this.sharedPreferences=l,this.eventsBusService=h,this.cachedItemStore=d,this.appInfo=p,this.SEARCH_CONTENT_GROUPED_BY_PAGE_SECTION_KEY="group_by_page",this.contentServiceConfig=this.sdkConfig.contentServiceConfig,this.appConfig=this.sdkConfig.appConfig,this.getContentDetailsHandler=new Oa(this.contentFeedbackService,this.profileService,this.apiService,this.contentServiceConfig,this.dbService,this.eventsBusService),this.getContentHeirarchyHandler=new Lc(this.apiService,this.contentServiceConfig),this.contentDeleteRequestSet=new Ic(this.sharedPreferences,t.KEY_CONTENT_DELETE_REQUEST_LIST,(function(e){return e.contentId}))}var t;return t=e,e.getIdForDb=function(e){var t={framework:e.framework||"",board:e.board||"",medium:e.medium||"",grade:e.grade||""};return Nc(JSON.stringify(t)).toString()},e.prototype.onInit=function(){return this.downloadService.registerOnDownloadCompleteDelegate(this),Object(ie.combineLatest)([this.handleContentDeleteRequestSetChanges(),this.handleUpdateSizeOnDeviceFail()]).pipe(Object(ge.mapTo)(void 0))},e.prototype.getContentDetails=function(e){return this.getContentDetailsHandler.handle(e)},e.prototype.getContentHeirarchy=function(e){return this.getContentHeirarchyHandler.handle(e)},e.prototype.getContents=function(e){var t=this,n=(new ja).getAllLocalContentQuery(e);return this.dbService.execute(n).pipe(Object(ge.mergeMap)((function(n){return Object(ie.defer)((function(){return Gc(t,void 0,void 0,(function(){var t,r,i,o,a,c,s;return Hc(this,(function(u){switch(u.label){case 0:t=[],r=0,i=n,u.label=1;case 1:return r<i.length?(o=i[r],a=_a.mapContentDBEntryToContent(o),[4,this.getContentDetailsHandler.decorateContent({content:a,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentAccess,attachFeedback:e.attachFeedback}).toPromise()]):[3,4];case 2:a=u.sent(),t.push(a),u.label=3;case 3:return r++,[3,1];case 4:return e.resourcesOnly?(c=e.uid,s="SELECT * FROM "+en.TABLE_NAME+"\n WHERE UID IN ("+Er.joinPreservingQuotes(c)+")",[4,this.dbService.execute(s).toPromise()]):[3,6];case 5:u.sent().forEach((function(e){var n={identifier:e[en.COLUMN_NAME_CONTENT_IDENTIFIER],contentData:e[en.COLUMN_NAME_DATA]&&JSON.parse(e[en.COLUMN_NAME_DATA]),isUpdateAvailable:!1,mimeType:"",basePath:"",contentType:"",isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0};t.push(n)})),u.label=6;case 6:return[2,t]}}))}))}))})))},e.prototype.cancelImport=function(e){return this.downloadService.cancel({identifier:e})},e.prototype.deleteContent=function(e){var t=this;return Object(ie.defer)((function(){return Gc(t,void 0,void 0,(function(){var t,n,r,i,o,a;return Hc(this,(function(c){switch(c.label){case 0:t=[],n=new Ia(this.dbService,this.fileService,this.sharedPreferences),r=0,i=e.contentDeleteList,c.label=1;case 1:return r<i.length?(o=i[r],[4,this.getContentDetailsHandler.fetchFromDB(o.contentId).toPromise()]):[3,8];case 2:return(a=c.sent())?(t.push({identifier:o.contentId,status:Mn.DELETED_SUCCESSFULLY}),Jr.hasChildren(a[Wt.COLUMN_NAME_LOCAL_DATA])?[4,n.deleteAllChildren(a,o.isChildContent)]:[3,4]):[3,6];case 3:c.sent(),c.label=4;case 4:return[4,n.deleteOrUpdateContent(a,!1,o.isChildContent)];case 5:return c.sent(),[3,7];case 6:t.push({identifier:o.contentId,status:Mn.NOT_FOUND}),c.label=7;case 7:return r++,[3,1];case 8:return new fc(this.dbService,this.sharedPreferences,this.fileService).execute(),[2,t]}}))}))}))},e.prototype.enqueueContentDelete=function(e){return this.contentDeleteRequestSet.addAll(e.contentDeleteList)},e.prototype.clearContentDeleteQueue=function(){return this.contentDeleteRequestSet.clear()},e.prototype.getContentDeleteQueue=function(){return this.contentDeleteRequestSet.asListChanges()},e.prototype.exportContent=function(e){var t=this,n=new Va(this.deviceInfo,this.dbService,this.fileService);return Object(ie.from)(n.getContentExportDBModelToExport(e.contentIds).then((function(r){return t.fileService.getTempLocation(e.destinationFolder).then((function(n){var i={},o=Jr.getExportedFileName(r,t.appInfo.getAppName());i.content_count=r.length;var a={metadata:i,ecarFilePath:n.nativeURL.concat(o),destinationFolder:e.destinationFolder,contentModelsToExport:r,tmpLocationPath:n.nativeURL};return new mc(t.fileService).execute(a)})).then((function(e){return new Ya(t.dbService,n).execute(e.body)})).then((function(e){return new Ga(t.fileService,t.deviceInfo).execute(e.body)})).then((function(e){return new za(t.zipService).execute(e.body)})).then((function(e){return new Xa(t.fileService).execute(e.body)})).then((function(e){return new $a(t.fileService).execute(e.body)})).then((function(e){return new tc(t.fileService,t.zipService).execute(e.body)})).then((function(t){return(new jc).execute(t,e)})).then((function(e){return(new xc).execute(e.body)})).then((function(n){var i=Jr.getExportedFileName(r,t.appInfo.getAppName());return new Ac(t.telemetryService).execute(n.body,i,e)})).then((function(e){return e.body}))})))},e.prototype.getChildContents=function(e){var t=this;e.level||(e.level=-1);var n=new Ma(this.dbService,this.getContentDetailsHandler),r=e.hierarchyInfo;if(r){if(r.length>0&&r[r.length-1].identifier===e.contentId){var i=r.length;r.splice(i-1,1)}}else r=[];return this.dbService.read(Oa.getReadContentQuery(e.contentId)).pipe(Object(ge.mergeMap)((function(i){return Gc(t,void 0,void 0,(function(){var t,o,a,c;return Hc(this,(function(s){switch(s.label){case 0:return t=new Map,o=JSON.parse(i[0][Wt.COLUMN_NAME_LOCAL_DATA]),a=o.childNodes,console.log("childIdentifiers",a),a?(c="SELECT * FROM "+Wt.TABLE_NAME+"\n WHERE "+Wt.COLUMN_NAME_IDENTIFIER+"\n IN ("+Er.joinPreservingQuotes(a)+")",[4,this.dbService.execute(c).toPromise()]):[3,2];case 1:s.sent().forEach((function(e){t.set(e.identifier,e)})),s.label=2;case 2:return[2,n.fetchChildrenOfContent(i[0],t,0,e.level,r)]}}))}))})))},e.prototype.getDownloadState=function(){throw new Error("Not Implemented yet")},e.prototype.importContent=function(e){var t=this,n=new Da(this.appConfig,this.contentServiceConfig,this.telemetryService),r=Er.deDupe(e.contentImportArray.map((function(e){return e.contentId}))),i=n.getContentSearchFilter(r,e.contentStatusArray,e.fields);return new Sc(this.apiService,this.contentServiceConfig).handle(i).pipe(Object(ge.map)((function(e){return e.result.content})),Object(ge.mergeMap)((function(i){return Object(ie.defer)((function(){return Gc(t,void 0,void 0,(function(){var t,o,a,c,s,u;return Hc(this,(function(f){switch(f.label){case 0:if(t=[],!i||!i.length)return[3,5];o=[],a=function(r){var a,c,s,u,f;return Hc(this,(function(l){switch(l.label){case 0:return(a=i.find((function(e){return e.identifier===r})))?(c=e.contentImportArray.find((function(e){return e.contentId===r})),[4,n.getDownloadUrl(a,c)]):[3,2];case 1:s=l.sent(),u=Bn.NOT_FOUND,s&&Xi.getFileExtension(s)===xn.CONTENT.valueOf()&&(u=Bn.ENQUEUED_FOR_DOWNLOAD,f={identifier:r,downloadUrl:s,mimeType:Rn.ECAR,destinationFolder:c.destinationFolder,isChildContent:c.isChildContent,filename:r.concat(".",xn.CONTENT),correlationData:c.correlationData,rollUp:c.rollUp,contentMeta:a,withPriority:e.withPriority||(a.mimeType===Rn.COLLECTION.valueOf()?1:0)},o.push(f)),t.push({identifier:r,status:u}),l.label=2;case 2:return[2]}}))},c=0,s=r,f.label=1;case 1:return c<s.length?(u=s[c],[5,a(u)]):[3,4];case 2:f.sent(),f.label=3;case 3:return c++,[3,1];case 4:this.downloadService.download(o).toPromise().then(),f.label=5;case 5:return[2,t]}}))}))}))})))},e.prototype.importEcar=function(e){var t=this;return Object(ie.from)(this.fileService.exists(e.sourceFilePath).then((function(n){var r={isChildContent:e.isChildContent,ecarFilePath:e.sourceFilePath,destinationFolder:e.destinationFolder,skippedItemsIdentifier:[],items:[],contentImportResponseList:[],correlationData:e.correlationData||[],rollUp:e.rollUp||new pt,contentIdsToDelete:new Set,identifier:e.identifier};return new Tc(t.telemetryService).execute(r,"ContentImport-Initiated").then((function(){return t.fileService.getTempLocation(e.destinationFolder)})).then((function(e){return r.tmpLocation=e.nativeURL,new ic(t.fileService,t.zipService).execute(r)})).then((function(e){return new cc(t.fileService,t.dbService,t.appConfig,t.getContentDetailsHandler).execute(e.body)})).then((function(e){return new pc(t.fileService,t.zipService,t.appConfig,t.dbService,t.deviceInfo,t.getContentDetailsHandler,t.eventsBusService,t.sharedPreferences).execute(e.body)})).then((function(e){t.eventsBusService.emit({namespace:_e.CONTENT,event:{type:Gn.CONTENT_EXTRACT_COMPLETED,payload:{contentId:r.rootIdentifier?r.rootIdentifier:r.identifiers[0]}}});new D;return new vc(t.dbService,t.deviceInfo,t.fileService).execute(e.body)})).then((function(e){return new gc(t.fileService).execute(e.body)})).then((function(e){var n=new D;return t.cleanupContent(r).toPromise().then((function(){return n.body=r,Promise.resolve(n)})).catch((function(){return Promise.reject(n)}))})).then((function(e){return new Oc(t.telemetryService).execute(e.body)})).then((function(e){return new Tc(t.telemetryService).execute(e.body,"ContentImport-Success")})).then((function(e){return t.eventsBusService.emit({namespace:_e.CONTENT,event:{type:Gn.IMPORT_COMPLETED,payload:{contentId:r.rootIdentifier?r.rootIdentifier:r.identifiers[0]}}}),e.body.contentImportResponseList}))})).catch((function(e){return console.log("error",e),[{identifier:"",status:Bn.NOT_FOUND}]})))},e.prototype.nextContent=function(e,t,n){var r=this,i=new Ma(this.dbService,this.getContentDetailsHandler);return this.dbService.read(Oa.getReadContentQuery(e[0].identifier)).pipe(Object(ge.mergeMap)((function(o){return Gc(r,void 0,void 0,(function(){var r,a;return Hc(this,(function(c){switch(c.label){case 0:return[4,i.getContentsKeyList(o[0])];case 1:return r=c.sent(),a=i.getNextContentIdentifier(e,t,r),[2,i.getContentFromDB(e,a,n)]}}))}))})))},e.prototype.prevContent=function(e,t,n){var r=this,i=new Ma(this.dbService,this.getContentDetailsHandler);return this.dbService.read(Oa.getReadContentQuery(e[0].identifier)).pipe(Object(ge.mergeMap)((function(o){return Gc(r,void 0,void 0,(function(){var r,a;return Hc(this,(function(c){switch(c.label){case 0:return[4,i.getContentsKeyList(o[0])];case 1:return r=c.sent(),a=i.getPreviousContentIdentifier(e,t,r),[2,i.getContentFromDB(e,a,n)]}}))}))})))},e.prototype.getRelevantContent=function(e){var t=this,n={};return Object(ie.of)(n).pipe(Object(ge.mergeMap)((function(r){return e.next?t.nextContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(ge.map)((function(e){return n.nextContent=e,n}))):Object(ie.of)(n)})),Object(ge.mergeMap)((function(r){return e.prev?t.prevContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(ge.map)((function(e){return n.previousContent=e,n}))):Object(ie.of)(n)})),Object(ge.map)((function(e){var t={};return t.next=e.nextContent?{content:e.nextContent}:void 0,t.prev=e.previousContent?{content:e.previousContent}:void 0,t})))},e.prototype.subscribeForImportStatus=function(e){throw new Error("Not Implemented yet")},e.prototype.searchContent=function(e,t){var n=this,r=new Da(this.appConfig,this.contentServiceConfig,this.telemetryService);t?e=r.getSearchCriteria(t):(e.limit=e.limit?e.limit:100,e.offset=e.offset?e.offset:0);var i=r.getSearchContentRequest(e);return this.sharedPreferences.getString(W.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID).pipe(Object(ge.mergeMap)((function(t){return new Sc(n.apiService,n.contentServiceConfig,t,e.languageCode).handle(i).pipe(Object(ge.map)((function(t){return r.mapSearchResponse(e,t,i)})))})))},e.prototype.cancelDownload=function(e){return this.downloadService.cancel({identifier:e})},e.prototype.setContentMarker=function(e){var t=this,n="SELECT * FROM "+en.TABLE_NAME+"\n WHERE "+en.COLUMN_NAME_UID+" = '"+e.uid+"'\n AND "+en.COLUMN_NAME_CONTENT_IDENTIFIER+"='"+e.contentId+"'\n AND "+en.COLUMN_NAME_MARKER+" = "+e.marker;return this.dbService.execute(n).pipe(Object(ge.mergeMap)((function(n){var r={uid:e.uid,identifier:e.contentId,epoch_timestamp:Date.now(),data:e.data,extra_info:JSON.stringify(e.extraInfo),marker:e.marker.valueOf(),mime_type:t.getMimeType(e.data)};return Er.isEmpty(n)?t.dbService.insert({table:en.TABLE_NAME,modelJson:r}).pipe(Object(ge.map)((function(e){return e>0}))):e.isMarked?t.dbService.update({table:en.TABLE_NAME,selection:en.COLUMN_NAME_UID+"= ? AND "+en.COLUMN_NAME_CONTENT_IDENTIFIER+"= ? AND "+en.COLUMN_NAME_MARKER+"= ?",selectionArgs:[e.uid,e.contentId,e.marker.valueOf().toString()],modelJson:r}).pipe(Object(ge.map)((function(e){return e>0}))):t.dbService.delete({table:en.TABLE_NAME,selection:en.COLUMN_NAME_UID+" = ? AND "+en.COLUMN_NAME_CONTENT_IDENTIFIER+" = ? AND "+en.COLUMN_NAME_MARKER+" = ?",selectionArgs:[e.uid,e.contentId,""+e.marker]}).pipe(Object(ge.map)((function(e){return e})))})))},e.prototype.searchContentGroupedByPageSection=function(e){var n=this,r=this.getContents({contentTypes:["TextBook"],board:e.board,medium:e.medium,grade:e.grade}).pipe(Object(ge.map)((function(e){return e.map((function(e){return e.contentData.appIcon&&!e.contentData.appIcon.startsWith("https://")&&(e.contentData.appIcon=e.basePath+e.contentData.appIcon),e.contentData}))}))),i=this.cachedItemStore.getCached(t.getIdForDb(e),this.SEARCH_CONTENT_GROUPED_BY_PAGE_SECTION_KEY,"ttl_"+this.SEARCH_CONTENT_GROUPED_BY_PAGE_SECTION_KEY,(function(){return n.searchContent(e)}),void 0,void 0,(function(e){return!e||!e.contentDataList||0===e.contentDataList.length})).pipe(Object(ge.catchError)((function(t){return console.error(t),Object(ie.of)({id:"OFFLINE_RESPONSE_ID",responseMessageId:"OFFLINE_RESPONSE_ID",filterCriteria:e,contentDataList:[]})})));return this.searchContentAndGroupByPageSection(r.pipe(Object(ge.take)(1)),i.pipe(Object(ge.take)(1)))},e.prototype.onDownloadCompletion=function(e){var t=this,n={isChildContent:e.isChildContent,sourceFilePath:e.downloadedFilePath,destinationFolder:e.destinationFolder,correlationData:e.correlationData,rollUp:e.rollUp,identifier:e.identifier};return this.importEcar(n).pipe(Object(ge.mergeMap)((function(){return t.downloadService.cancel({identifier:e.identifier},!1)})),Object(ge.catchError)((function(){return t.downloadService.cancel({identifier:e.identifier},!1)})),Object(ge.mapTo)(void 0))},e.prototype.getContentSpaceUsageSummary=function(e){var t=new Cc(this.dbService);return Object(ie.from)(t.getContentUsageSummary(e.paths))},e.prototype.cleanupContent=function(e){for(var t=[],n=0,r=Array.from(e.contentIdsToDelete.values());n<r.length;n++){var i={contentId:r[n],isChildContent:!1};t.push(i)}return this.deleteContent({contentDeleteList:t}).pipe(Object(ge.mapTo)(void 0))},e.prototype.getMimeType=function(e){var t="";e&&(t=JSON.parse(e).mimeType);return t},e.prototype.searchContentAndGroupByPageSection=function(e,t){return Object(ie.zip)(e,t).pipe(Object(ge.map)((function(e){var t=e[0],n=e[1].contentDataList.filter((function(e){return!t.find((function(t){return t.identifier===e.identifier}))}));return Bc({},e[1],{contentDataList:t.concat(n)})})),Object(ge.map)((function(e){var t=e.contentDataList.reduce((function(e,t){if(Array.isArray(t.subject))t.subject.forEach((function(n){n=n.toLowerCase().trim(),e[n]?e[n].push(t):e[n]=[t]}));else{var n=t.subject?t.subject.toLowerCase().trim():"";e[n]?e[n].push(t):e[n]=[t]}return e}),{});return{name:"Resource",sections:Object.keys(t).map((function(e){return{contents:t[e],name:e.charAt(0).toUpperCase()+e.slice(1),display:{name:{en:e}}}}))}})))},e.prototype.handleContentDeleteRequestSetChanges=function(){var e=this;return this.contentDeleteRequestSet.asListChanges().pipe(Object(ge.mergeMap)((function(t){var n=t[0];return n?e.deleteContent({contentDeleteList:[n]}).pipe(Object(ge.mergeMap)((function(){return e.contentDeleteRequestSet.remove(n)})),Object(ge.mapTo)(void 0)):Object(ie.of)(void 0)})))},e.prototype.handleUpdateSizeOnDeviceFail=function(){var e=this;return this.sharedPreferences.getBoolean(t.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL).pipe(Object(ge.mergeMap)((function(t){return t?Object(ie.of)(void 0):Object(ie.from)(new fc(e.dbService,e.sharedPreferences,e.fileService).execute()).pipe(Object(ge.mapTo)(void 0))})))},e.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL=J.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,e.KEY_CONTENT_DELETE_REQUEST_LIST=J.KEY_CONTENT_DELETE_REQUEST_LIST,e=t=Fc([Object(I.injectable)(),Yc(0,Object(I.inject)(be.SDK_CONFIG)),Yc(1,Object(I.inject)(be.API_SERVICE)),Yc(2,Object(I.inject)(be.DB_SERVICE)),Yc(3,Object(I.inject)(be.PROFILE_SERVICE)),Yc(4,Object(I.inject)(be.FILE_SERVICE)),Yc(5,Object(I.inject)(be.ZIP_SERVICE)),Yc(6,Object(I.inject)(be.DEVICE_INFO)),Yc(7,Object(I.inject)(be.TELEMETRY_SERVICE)),Yc(8,Object(I.inject)(be.CONTENT_FEEDBACK_SERVICE)),Yc(9,Object(I.inject)(be.DOWNLOAD_SERVICE)),Yc(10,Object(I.inject)(be.SHARED_PREFERENCES)),Yc(11,Object(I.inject)(be.EVENTS_BUS_SERVICE)),Yc(12,Object(I.inject)(be.CACHED_ITEM_STORE)),Yc(13,Object(I.inject)(be.APP_INFO)),Vc("design:paramtypes",[Object,Object,C,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object])],e)}(),zc=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Kc=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Wc=function(e,t){return function(n,r){t(n,r,e)}},Xc=function(){function e(e){this.dbService=e}return e.prototype.getValue=function(e){return this.dbService.read({table:on.TABLE_NAME,columns:[],selection:on.COLUMN_NAME_KEY+" = ?",selectionArgs:[e]}).pipe(Object(ge.map)((function(e){return e[0]&&e[0].value})))},e.prototype.setValue=function(e,t){var n=this;return this.getValue(e).pipe(Object(ge.mergeMap)((function(r){var i,o;return r?n.dbService.update({table:on.TABLE_NAME,selection:on.COLUMN_NAME_KEY+" = ?",selectionArgs:[e],modelJson:(i={},i[on.COLUMN_NAME_KEY]=e,i[on.COLUMN_NAME_VALUE]=t,i)}).pipe(Object(ge.map)((function(e){return e>0}))):n.dbService.insert({table:on.TABLE_NAME,modelJson:(o={},o[on.COLUMN_NAME_KEY]=e,o[on.COLUMN_NAME_VALUE]=t,o)}).pipe(Object(ge.map)((function(e){return e>0})))})))},e=zc([Object(I.injectable)(),Wc(0,Object(I.inject)(be.DB_SERVICE)),Kc("design:paramtypes",[C])],e)}(),Jc=function(){function e(e,t,n,r){this.apiService=e,this.formServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.FORM_FILE_KEY_PREFIX="form-",this.FORM_LOCAL_KEY="form-",this.GET_FORM_DETAILS_ENDPOINT="/read"}return e.getIdForRequest=function(e){var t=e.type+"_"+e.subType+"_"+e.action;return e.rootOrgId&&(t+="_"+e.rootOrgId),t},e.prototype.handle=function(t){var n=this;return t.from&&t.from===Ir.SERVER?this.fetchFormServer(t).pipe(Object(ge.map)((function(e){return e.form}))):this.cachedItemStore.getCached(e.getIdForRequest(t),this.FORM_LOCAL_KEY,"ttl_"+this.FORM_LOCAL_KEY,(function(){return n.fetchFormServer(t)}),(function(){return n.fetchFromFile(t)}))},e.prototype.fetchFormServer=function(e){var t=(new F.Builder).withType(R.POST).withPath(this.formServiceConfig.apiPath+this.GET_FORM_DETAILS_ENDPOINT).withApiToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result})))},e.prototype.fetchFromFile=function(t){var n=Wr.ASSETS_PATH+this.formServiceConfig.formConfigDirPath,r=this.FORM_FILE_KEY_PREFIX+e.getIdForRequest(t)+".json";return Object(ie.from)(this.fileService.readFileFromAssets(n.concat("/",r))).pipe(Object(ge.map)((function(e){return JSON.parse(e).result})))},e}(),Qc=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},$c=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Zc=function(e,t){return function(n,r){t(n,r,e)}},es=function(){function e(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedItemStore=r,this.formServiceConfig=this.sdkConfig.formServiceConfig}return e.prototype.getForm=function(e){return new Jc(this.apiService,this.formServiceConfig,this.fileService,this.cachedItemStore).handle(e)},e=Qc([Object(I.injectable)(),Zc(0,Object(I.inject)(be.SDK_CONFIG)),Zc(1,Object(I.inject)(be.API_SERVICE)),Zc(2,Object(I.inject)(be.FILE_SERVICE)),Zc(3,Object(I.inject)(be.CACHED_ITEM_STORE)),$c("design:paramtypes",[Object,Object,Object,Object])],e)}(),ts=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},ns=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},rs=function(e,t){return function(n,r){t(n,r,e)}},is=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},os=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},as=function(){function e(e,t,n){this.sdkConfig=e,this.keyValueStore=t,this.sharedPreferences=n,this.apiConfig=this.sdkConfig.apiConfig}var t;return t=e,e.isItemEmpty=function(e){return!(!Array.isArray(e)||0!==e.length)||"object"==typeof e&&0===Object.keys(e).length},e.prototype.getCached=function(e,t,n,r,i,o,a){var c=this;return this.isItemCachedInDb(n,e).pipe(Object(ge.mergeMap)((function(s){return s?c.isItemTTLExpired(n,e,isNaN(o)?c.apiConfig.cached_requests.timeToLive:o).pipe(Object(ge.mergeMap)((function(i){return i?c.keyValueStore.getValue(t+"-"+e).pipe(Object(ge.map)((function(e){return JSON.parse(e)})),Object(ge.tap)((function(){return is(c,void 0,void 0,(function(){var i,o=this;return os(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,r().pipe(Object(ge.switchMap)((function(r){return o.saveItem(e,n,t,r,a)}))).toPromise()];case 1:return c.sent(),[3,3];case 2:return i=c.sent(),console.error(i),[3,3];case 3:return[2]}}))}))}))):c.keyValueStore.getValue(t+"-"+e).pipe(Object(ge.map)((function(e){return JSON.parse(e)})))}))):i?i().pipe(Object(ge.switchMap)((function(r){return c.saveItem(e,n,t,r,a)})),Object(ge.catchError)((function(i){return r().pipe(Object(ge.switchMap)((function(r){return c.saveItem(e,n,t,r,a)})))}))):r().pipe(Object(ge.switchMap)((function(r){return c.saveItem(e,n,t,r,a)})))})))},e.prototype.isItemCachedInDb=function(e,t){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(ge.mergeMap)((function(e){return Object(ie.iif)((function(){return!!e}),Object(ie.defer)((function(){return Object(ie.of)(!0)})),Object(ie.defer)((function(){return Object(ie.of)(!1)})))})))},e.prototype.isItemTTLExpired=function(e,t,n){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(ge.map)((function(e){var t=Number(e);return!(Date.now()-t<n)})))},e.prototype.saveItem=function(e,n,r,i,o){return t.isItemEmpty(i)||o&&o(i)?Object(ie.of)(i):Object(ie.zip)(this.saveItemTTL(e,n),this.saveItemToDb(e,r,i)).pipe(Object(ge.switchMap)((function(){return Object(ie.of)(i)})))},e.prototype.saveItemTTL=function(e,t){return this.sharedPreferences.putString(t+"-"+e,Date.now()+"").pipe(Object(ge.mergeMap)((function(e){return Object(ie.of)(!0)})))},e.prototype.saveItemToDb=function(e,t,n){return this.keyValueStore.setValue(t+"-"+e,JSON.stringify(n))},e=t=ts([Object(I.injectable)(),rs(0,Object(I.inject)(be.SDK_CONFIG)),rs(1,Object(I.inject)(be.KEY_VALUE_STORE)),rs(2,Object(I.inject)(be.SHARED_PREFERENCES)),ns("design:paramtypes",[Object,Object,Object])],e)}();!function(e){e.RESOURCE="Resource",e.COURSE="Course",e.DIAL_CODE="DIAL Code Consumption"}(co||(co={}));var cs,ss=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},us=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},fs=function(){function e(e,t,n,r,i){this.apiService=e,this.pageApiServiceConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.PAGE_ASSEMBLE_LOCAL_KEY="page_assemble-",this.PAGE_ASSEMBLE_ENDPOINT="/page/assemble",this.DIALCODE_ASSEMBLE_ENDPOINT="/dial/assemble"}return e.getIdForDb=function(e){return e.name+(e.source||"app")+(e.mode||"")+e.filters?Nc(JSON.stringify(e.filters)).toString():""},e.prototype.handle=function(t){var n=this;return t.from=t.from||Ir.CACHE,Object(ie.of)(t.from).pipe(Object(ge.mergeMap)((function(r){return r===Ir.SERVER?n.fetchFromServer(t).pipe(Object(ge.tap)((function(r){return ss(n,void 0,void 0,(function(){var n;return us(this,(function(i){switch(i.label){case 0:return n=JSON.stringify(r),[4,this.sharedPreferences.putString("ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+e.getIdForDb(t),Date.now()+"").toPromise()];case 1:return i.sent(),[4,this.keyValueStore.setValue(this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+e.getIdForDb(t),n).toPromise()];case 2:return i.sent(),[2]}}))}))})),Object(ge.catchError)((function(){return n.fetchFromCache(t)}))):n.fetchFromCache(t)})))},e.prototype.fetchFromServer=function(e){var t=e.name===co.DIAL_CODE?this.DIALCODE_ASSEMBLE_ENDPOINT:this.PAGE_ASSEMBLE_ENDPOINT,n=(new F.Builder).withHost(this.pageApiServiceConfig.host).withType(R.POST).withPath(this.pageApiServiceConfig.apiPath+t).withApiToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(ge.map)((function(e){return e.body.result.response})))},e.prototype.fetchFromCache=function(t){var n=this;return this.cachedItemStore.getCached(e.getIdForDb(t),this.PAGE_ASSEMBLE_LOCAL_KEY,"ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY,(function(){return n.fetchFromServer(t)}))},e}(),ls=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},hs=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ds=function(e,t){return function(n,r){t(n,r,e)}},ps=function(){function e(e,t,n,r,i){this.apiService=e,this.sdkConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.pageAssembleServiceConfig=this.sdkConfig.pageServiceConfig}return e.prototype.getPageAssemble=function(e){return new fs(this.apiService,this.pageAssembleServiceConfig,this.cachedItemStore,this.keyValueStore,this.sharedPreferences).handle(e)},e=ls([Object(I.injectable)(),ds(0,Object(I.inject)(be.API_SERVICE)),ds(1,Object(I.inject)(be.SDK_CONFIG)),ds(2,Object(I.inject)(be.CACHED_ITEM_STORE)),ds(3,Object(I.inject)(be.KEY_VALUE_STORE)),ds(4,Object(I.inject)(be.SHARED_PREFERENCES)),hs("design:paramtypes",[Object,Object,Object,Object,Object])],e)}(),bs=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},_s=function(){function e(){}return e.prototype.getString=function(e){return Object(ie.defer)((function(){return Object(ie.of)(localStorage.getItem(e)).pipe(Object(ge.map)((function(e){return e||void 0})))}))},e.prototype.putString=function(e,t){return Object(ie.defer)((function(){return Object(ie.of)(localStorage.setItem(e,t)).pipe(Object(ge.mapTo)(void 0))}))},e.prototype.putBoolean=function(e,t){return Object(ie.defer)((function(){return Object(ie.of)(localStorage.setItem(e,t+"")).pipe(Object(ge.mapTo)(!0))}))},e.prototype.getBoolean=function(e){return Object(ie.defer)((function(){return Object(ie.of)("true"===localStorage.getItem(e))}))},e=bs([Object(I.injectable)()],e)}(),Es=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},ys=function(){function e(){this.sharedPreferences=plugins.SharedPreferences.getInstance(t.sharedPreferncesName)}var t;return t=e,e.prototype.getString=function(e){var t=this,n=localStorage.getItem(e);return n?(localStorage.removeItem(e),this.putString(e,n).pipe(Object(ge.mapTo)(n))):new ie.Observable((function(n){t.sharedPreferences.getString(e,"",(function(e){n.next(e),n.complete()}),(function(e){n.error(e)}))}))},e.prototype.putString=function(e,t){var n=this;return new ie.Observable((function(r){n.sharedPreferences.putString(e,t,(function(){r.next(void 0),r.complete()}),(function(e){r.error(e)}))}))},e.prototype.putBoolean=function(e,t){var n=this;return new ie.Observable((function(r){n.sharedPreferences.putBoolean(e,t,(function(){r.next(!0),r.complete()}),(function(e){r.error(e)}))}))},e.prototype.getBoolean=function(e){var t=this,n=localStorage.getItem(e);return n?(localStorage.removeItem(e),this.putBoolean(e,"true"===n).pipe(Object(ge.mapTo)("true"===n))):new ie.Observable((function(n){t.sharedPreferences.getBoolean(e,!1,(function(e){n.next(e),n.complete()}),(function(e){n.error(e)}))}))},e.sharedPreferncesName="org.ekstep.genieservices.preference_file",e=t=Es([Object(I.injectable)()],e)}();!function(e){e[e.PERSISTENT=1]="PERSISTENT",e[e.TEMPORARY=0]="TEMPORARY"}(cs||(cs={}));var vs,gs,ms,Ss=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Os=function(){function e(){this.initialized=!1}return e.prototype.init=function(){var e=this;file.requestFileSystem(cs.PERSISTENT,0,(function(t){e.initialized=!0,e.fileSystem=t}),(function(){}))},e.prototype.readAsText=function(e,t){return this.readFile(e,t,"Text")},e.prototype.readAsBinaryString=function(e,t){return this.readFile(e,t,"BinaryString")},e.prototype.readFileFromAssets=function(e){return new Promise((function(t,n){try{sbutility.readFromAssets(e,(function(e){t(e)}),(function(e){n(e)}))}catch(e){n(e)}}))},e.prototype.writeFile=function(e,t,n,r){var i=this;void 0===r&&(r={});var o={create:!r.append,exclusive:!r.replace};return this.resolveDirectoryUrl(e).then((function(e){return i.getFile(e,t,o)})).then((function(e){return i.writeFileEntry(e,n,r)}))},e.prototype.createFile=function(e,t,n){var r=this,i={create:!0};return n||(i.exclusive=!0),this.resolveDirectoryUrl(e).then((function(e){return r.getFile(e,t,i)}))},e.prototype.getFile=function(e,t,n){return new Promise((function(r,i){try{e.getFile(t,n,(function(e){r(e)}),(function(e){i(e)}))}catch(e){i(e)}}))},e.prototype.removeFile=function(e){var t=this,n=Xi.getParentDir(e),r=Xi.getFileName(e).replace("/","");return this.resolveDirectoryUrl(n).then((function(e){return t.getFile(e,r,{create:!1})})).then((function(e){return t.remove(e)}))},e.prototype.createDir=function(e,t){var n=this,r={create:!0};t||(r.exclusive=!0);var i=Xi.getParentDir(e),o=Xi.getFileName(e).replace("/","");return this.exists(e).then((function(){return n.resolveDirectoryUrl(e)})).catch((function(){return n.resolveDirectoryUrl(i).then((function(e){return n.getDirectory(e,o,r)}))}))},e.prototype.listDir=function(e){var t=this;return this.resolveDirectoryUrl(Xi.getDirecory(e)).then((function(n){return t.getDirectory(n,Xi.getFileName(e),{create:!1,exclusive:!1})})).then((function(e){var n=e.createReader();return t.readEntries(n)}))},e.prototype.removeDir=function(e,t){var n=this;return this.resolveDirectoryUrl(e).then((function(e){return n.getDirectory(e,t,{create:!1})})).then((function(e){return n.remove(e)}))},e.prototype.removeRecursively=function(e){var t=this;e=e.endsWith("/")?e.substring(0,e.length-1):e;var n=Xi.getParentDir(e),r=Xi.getFileName(e).replace("/","");return this.resolveDirectoryUrl(n).then((function(e){return t.getDirectory(e,r,{create:!1})})).then((function(e){return t.rimraf(e)}))},e.prototype.copyDir=function(e,t,n,r){var i=this;return this.resolveDirectoryUrl(e).then((function(e){return i.getDirectory(e,t,{create:!1})})).then((function(e){return i.resolveDirectoryUrl(n).then((function(t){return i.copy(e,t,r)}))}))},e.prototype.copyFile=function(e,t,n,r){var i=this;return r=r||t,this.resolveDirectoryUrl(e).then((function(e){return i.getFile(e,t,{create:!1})})).then((function(e){return i.resolveDirectoryUrl(n).then((function(t){return i.copy(e,t,r)}))}))},e.prototype.exists=function(e){return this.resolveLocalFilesystemUrl(e)},e.prototype.getTempLocation=function(e){var t=this;return this.resolveDirectoryUrl(e).then((function(n){return t.resolveDirectoryUrl(e.concat("tmp"))})).catch((function(){return t.createDir(e.concat("tmp"),!1)}))},e.prototype.getFreeDiskSpace=function(){return new Promise((function(e,t){cordova.exec(e,t,"File","getFreeDiskSpace",[])}))},e.prototype.resolveLocalFilesystemUrl=function(e){return new Promise((function(t,n){try{resolveLocalFileSystemURL(e,(function(e){t(e)}),(function(e){n(e)}))}catch(e){n(e)}}))},e.prototype.getMetaData=function(e){var t=this;if("string"==typeof e)return this.resolveLocalFilesystemUrl(e).then((function(e){return t.getMetaData(e)}));var n=e;return new Promise((function(e){n.getMetadata((function(t){e(t)}),(function(){return e()}))}))},e.prototype.getExternalApplicationStorageDirectory=function(){return file.externalApplicationStorageDirectory},e.prototype.getDirectorySize=function(e){var t=this;return this.resolveDirectoryUrl(e).then((function(e){return t.size(e)})).catch((function(){return 0}))},e.prototype.size=function(e){var t=this;return e.isFile?new Promise((function(t,n){e.getMetadata((function(e){return t(e.size)}),(function(e){return n(e)}))})):e.isDirectory?new Promise((function(n,r){e.createReader().readEntries((function(e){Promise.all(e.map((function(e){return t.size(e)}))).then((function(e){var t=e.reduce((function(e,t){return e+t}),0);n(t)})).catch((function(e){return r(e)}))}),(function(e){return r(e)}))})):Promise.resolve(0)},e.prototype.readEntries=function(e){return new Promise((function(t,n){e.readEntries((function(e){t(e)}),(function(e){n(e)}))}))},e.prototype.readFile=function(e,t,n){var r=this;return this.resolveDirectoryUrl(e).then((function(e){return r.getFile(e,t,{create:!1})})).then((function(e){var t=new FileReader;return new Promise((function(r,i){t.onloadend=function(){void 0!==t.result||null!==t.result?r(t.result):void 0!==t.error||null!==t.error?i(t.error):i({code:null,message:"READER_ONLOADEND_ERR"})},e.file((function(e){t["readAs"+n].call(t,e)}),(function(e){i(e)}))}))})).catch((function(e){throw e}))},e.prototype.resolveDirectoryUrl=function(e){return this.resolveLocalFilesystemUrl(e).then((function(e){return e.isDirectory?e:Promise.reject("input is not a directory")}))},e.prototype.remove=function(e){return new Promise((function(t,n){e.remove((function(){t({success:!0,fileRemoved:e})}),(function(e){n(e)}))}))},e.prototype.copy=function(e,t,n){return new Promise((function(r,i){e.copyTo(t,n,(function(e){r(e)}),(function(e){i(e)}))}))},e.prototype.getDirectory=function(e,t,n){return new Promise((function(r,i){try{e.getDirectory(t,n,(function(e){r(e)}),(function(e){i(e)}))}catch(e){i(e)}}))},e.prototype.rimraf=function(e){return new Promise((function(t,n){e.removeRecursively((function(){t({success:!0,fileRemoved:e})}),(function(e){n(e)}))}))},e.prototype.createWriter=function(e){return new Promise((function(t,n){e.createWriter((function(e){t(e)}),(function(e){n(e)}))}))},e.prototype.writeFileEntry=function(e,t,n){var r=this;return this.createWriter(e).then((function(e){return n.append&&e.seek(e.length),n.truncate&&e.truncate(n.truncate),r.write(e,t)})).then((function(){return e}))},e.prototype.write=function(e,t){return new Promise((function(n,r){e.onwriteend=function(t){e.error?r(e.error):n(t)},e.write(t)}))},e=Ss([Object(I.injectable)()],e)}(),As=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ts=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ns=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ms=function(e){function t(){return e.call(this,2,17)||this}return As(t,e),t.prototype.apply=function(e){return Ts(this,void 0,void 0,(function(){var t=this;return Ns(this,(function(n){return this.queries().forEach((function(n){return Ts(t,void 0,void 0,(function(){return Ns(this,(function(t){switch(t.label){case 0:return[4,e.execute(n).toPromise()];case 1:return t.sent(),[2]}}))}))})),[2,void 0]}))}))},t.prototype.queries=function(){return[It.getAlterEntryForProfileSyllabus()]},t}(w),ws=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Cs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Is=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ps=function(e){function t(){return e.call(this,3,18)||this}return ws(t,e),t.prototype.apply=function(e){return Cs(this,void 0,void 0,(function(){var t=this;return Is(this,(function(n){switch(n.label){case 0:return this.queries().forEach((function(n){return Cs(t,void 0,void 0,(function(){return Is(this,(function(t){switch(t.label){case 0:return[4,e.execute(n).toPromise()];case 1:return t.sent(),[2]}}))}))})),[4,e.read({table:It.TABLE_NAME,columns:[]}).pipe(Object(ge.map)((function(n){n.forEach((function(n){return Cs(t,void 0,void 0,(function(){return Is(this,(function(t){switch(t.label){case 0:return n[It.COLUMN_NAME_UID],n[It.COLUMN_NAME_HANDLE],n[It.COLUMN_NAME_SOURCE]=mr.SERVER.valueOf(),[4,e.update({table:It.TABLE_NAME,modelJson:n}).toPromise()];case 1:return t.sent(),[2]}}))}))}))}))).toPromise()];case 1:return n.sent(),[2,void 0]}}))}))},t.prototype.queries=function(){return[Dt.getCreateEntry(),Ut.getCreateEntry()]},t.prototype.updateProfileTable=function(){},t}(w),Ls=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ds=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},js=function(e){function t(){return e.call(this,4,19)||this}return Ls(t,e),t.prototype.apply=function(e){return Rs(this,void 0,void 0,(function(){var t=this;return Ds(this,(function(n){switch(n.label){case 0:return[4,e.read({table:Ft.TABLE_NAME,columns:[]}).pipe(Object(ge.map)((function(n){n.forEach((function(n){return Rs(t,void 0,void 0,(function(){var t;return Ds(this,(function(r){switch(r.label){case 0:return t=Number(n[Yt.COLUMN_NAME_TOTAL_TS]),n[Yt.COLUMN_NAME_TOTAL_TS]=Math.round(t/1e3),[4,e.update({table:Yt.TABLE_NAME,modelJson:n}).toPromise()];case 1:return r.sent(),[2]}}))}))}))}))).toPromise()];case 1:return n.sent(),[2,void 0]}}))}))},t.prototype.queries=function(){return[]},t}(w),Us=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ks=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},xs=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Bs=function(e){function t(){return e.call(this,7,22)||this}return Us(t,e),t.prototype.apply=function(e){return ks(this,void 0,void 0,(function(){var t=this;return xs(this,(function(n){return this.queries().forEach((function(n){return ks(t,void 0,void 0,(function(){return xs(this,(function(t){switch(t.label){case 0:return[4,e.execute(n).toPromise()];case 1:return t.sent(),[2]}}))}))})),[2,void 0]}))}))},t.prototype.queries=function(){return[cn.getCreateEntry()]},t}(w),Fs=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Vs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ys=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Gs=function(e){function t(){return e.call(this,5,20)||this}return Fs(t,e),t.prototype.apply=function(e){return Vs(this,void 0,void 0,(function(){var t=this;return Ys(this,(function(n){return this.queries().forEach((function(n){return Vs(t,void 0,void 0,(function(){return Ys(this,(function(t){switch(t.label){case 0:return[4,e.execute(n).toPromise()];case 1:return t.sent(),[2]}}))}))})),[2,void 0]}))}))},t.prototype.queries=function(){return[en.getCreateEntry()]},t}(w),Hs=function(){function e(e){this._gid=e,this._sid=nr.generateUniqueId(),this._createdTime=Date.now()}return Object.defineProperty(e.prototype,"gid",{get:function(){return this._gid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sid",{get:function(){return this._sid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"createdTime",{get:function(){return this._createdTime},enumerable:!0,configurable:!0}),e}(),qs=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zs=function(e){function t(n){var r=e.call(this,n,"NO_GROUP_FOUND")||this;return Object.setPrototypeOf(r,t.prototype),r}return qs(t,e),t}(U),Ks=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ws=function(e){function t(n){var r=e.call(this,n,"NO_ACTIVE_SESSION")||this;return Object.setPrototypeOf(r,t.prototype),r}return Ks(t,e),t}(U),Xs=function(){function e(){}return e.mapGroupDBEntryToGroup=function(e){return{gid:e[qt.COLUMN_NAME_GID],name:e[qt.COLUMN_NAME_NAME],syllabus:e[qt.COLUMN_NAME_SYLLABUS].split(","),grade:e[qt.COLUMN_NAME_GRADE].split(","),gradeValue:JSON.parse(e[qt.COLUMN_NAME_GRADE_VALUE]),createdAt:e[qt.COLUMN_NAME_CREATED_AT],updatedAt:e[qt.COLUMN_NAME_UPDATED_AT]}},e.mapGroupToGroupDBEntry=function(e){var t;return(t={})[qt.COLUMN_NAME_GID]=e.gid,t[qt.COLUMN_NAME_SYLLABUS]=e.syllabus?e.syllabus.join(","):"",t[qt.COLUMN_NAME_GRADE]=e.grade?e.grade.join(","):"",t[qt.COLUMN_NAME_NAME]=e.name,t[qt.COLUMN_NAME_GRADE_VALUE]=JSON.stringify(e.gradeValue),t[qt.COLUMN_NAME_CREATED_AT]=e.createdAt,t[qt.COLUMN_NAME_UPDATED_AT]=e.updatedAt,t},e}(),Js=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Qs=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},$s=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Zs=function(e,t){return function(n,r){t(n,r,e)}},eu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},tu=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},nu=function(){function e(e,t,n,r){this.container=e,this.dbService=t,this.profileService=n,this.sharedPreferences=r}var t;return t=e,Object.defineProperty(e.prototype,"telemetryService",{get:function(){return this.container.get(be.TELEMETRY_SERVICE)},enumerable:!0,configurable:!0}),e.prototype.createGroup=function(e){var t=this;return e.gid=nr.generateUniqueId(),e.createdAt=Date.now(),e.updatedAt=Date.now(),this.dbService.insert({table:qt.TABLE_NAME,modelJson:Xs.mapGroupToGroupDBEntry(e)}).pipe(Object(ge.tap)((function(){return eu(t,void 0,void 0,(function(){var t=this;return tu(this,(function(n){switch(n.label){case 0:return[4,this.profileService.getActiveProfileSession().pipe(Object(ge.map)((function(e){return e.uid})),Object(ge.mergeMap)((function(n){var r=new ct;r.id=n,r.type=ct.TYPE_SYSTEM;var i={env:"sdk",actor:r,currentState:nt.AUDIT_CREATED,updatedProperties:no.getTruthyProps(e),objId:e.gid,objType:Ae.GROUP};return t.telemetryService.audit(i)}))).toPromise()];case 1:return n.sent(),[2]}}))}))})),Object(ge.map)((function(){return e})))},e.prototype.deleteGroup=function(e){var t=this;return Object(ie.defer)((function(){return Object(ie.of)(t.dbService.beginTransaction())})).pipe(Object(ge.mergeMap)((function(){return Object(ie.zip)(t.dbService.delete({table:qt.TABLE_NAME,selection:qt.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}),t.dbService.delete({table:Ht.TABLE_NAME,selection:Ht.COLUMN_NAME_GID+" = ?",selectionArgs:[e]})).pipe(Object(ge.mapTo)(void 0))})),Object(ge.tap)((function(){t.dbService.endTransaction(!0)})),Object(ge.tap)((function(){return eu(t,void 0,void 0,(function(){var t=this;return tu(this,(function(n){switch(n.label){case 0:return[4,this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(n){var r=new ct;r.id=n.uid,r.type=ct.TYPE_SYSTEM;var i={env:"sdk",actor:r,currentState:nt.AUDIT_DELETED,objId:e,objType:Ae.GROUP};return t.telemetryService.audit(i)}))).toPromise()];case 1:return n.sent(),[2]}}))}))})),Object(ge.catchError)((function(e){return t.dbService.endTransaction(!1),ie.Observable.throw(e)})))},e.prototype.updateGroup=function(e){var t=this;return this.dbService.read({table:qt.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid]}).pipe(Object(ge.map)((function(t){return t&&t[0]?Xs.mapGroupDBEntryToGroup(t[0]):ie.Observable.throw(new zs("No Group found with ID "+e.gid))})),Object(ge.tap)((function(n){return eu(t,void 0,void 0,(function(){var t=this;return tu(this,(function(r){switch(r.label){case 0:return[4,this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(r){var i=new ct;i.id=r.uid,i.type=ct.TYPE_SYSTEM;var o={env:"sdk",actor:i,currentState:nt.AUDIT_UPDATED,updatedProperties:no.getPropDiff(e,n),objId:e.gid,objType:Ae.GROUP};return t.telemetryService.audit(o)}))).toPromise()];case 1:return r.sent(),[2]}}))}))})),Object(ge.mergeMap)((function(){var n;return t.dbService.update({table:qt.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid],modelJson:(n={},n[qt.COLUMN_NAME_NAME]=e.name,n[qt.COLUMN_NAME_SYLLABUS]=e.syllabus.join(","),n[qt.COLUMN_NAME_UPDATED_AT]=Date.now(),n[qt.COLUMN_NAME_GRADE]=e.grade.join(","),n[qt.COLUMN_NAME_GRADE_VALUE]=JSON.stringify(e.gradeValue),n)}).pipe(Object(ge.mapTo)(e))})))},e.prototype.getActiveSessionGroup=function(){var e=this;return this.getActiveGroupSession().pipe(Object(ge.map)((function(e){if(!e)throw new Ws("No active session available");return e})),Object(ge.mergeMap)((function(t){return e.dbService.read({table:qt.TABLE_NAME,selection:qt.COLUMN_NAME_GID+" = ?",selectionArgs:[t.gid]}).pipe(Object(ge.map)((function(e){return e&&e[0]})))})))},e.prototype.setActiveSessionForGroup=function(e){var n=this;return this.dbService.read({table:qt.TABLE_NAME,selection:qt.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}).pipe(Object(ge.map)((function(e){return e&&e[0]&&Xs.mapGroupDBEntryToGroup(e[0])})),Object(ge.map)((function(e){if(!e)throw new zs("No Profile found");return e})),Object(ge.mergeMap)((function(e){var r=new Hs(e.gid);return n.sharedPreferences.putString(t.KEY_GROUP_SESSION,JSON.stringify({gid:r.gid,sid:r.sid,createdTime:r.createdTime})).pipe(Object(ge.mapTo)(!0))})))},e.prototype.getActiveGroupSession=function(){return this.sharedPreferences.getString(t.KEY_GROUP_SESSION).pipe(Object(ge.map)((function(e){if(e)return JSON.parse(e)})))},e.prototype.getAllGroups=function(e){var t=this;return Object(ie.defer)((function(){return e?t.dbService.execute("\n SELECT * FROM "+qt.TABLE_NAME+"\n LEFT JOIN "+Ht.TABLE_NAME+" ON\n "+qt.TABLE_NAME+"."+qt.COLUMN_NAME_GID+" =\n "+Ht.TABLE_NAME+"."+Ht.COLUMN_NAME_GID+"\n WHERE "+Ht.COLUMN_NAME_UID+' = "'+e.uid+'"').pipe(Object(ge.map)((function(e){return e.map((function(e){return Xs.mapGroupDBEntryToGroup(e)}))}))):t.dbService.read({table:qt.TABLE_NAME,columns:[]}).pipe(Object(ge.map)((function(e){return e.map((function(e){return Xs.mapGroupDBEntryToGroup(e)}))})))})).pipe(Object(ge.mergeMap)((function(e){return Object(ie.from)(e)})),Object(ge.mergeMap)((function(e){return t.profileService.getAllProfiles({groupId:e.gid}).pipe(Object(ge.map)((function(t){return Js({},e,{profilesCount:t.length})})))})),Object(ge.reduce)((function(e,t){return e.concat([t])}),[]))},e.prototype.addProfilesToGroup=function(e){var t=this;return Object(ie.defer)((function(){return Object(ie.of)(t.dbService.beginTransaction())})).pipe(Object(ge.mergeMap)((function(){return t.dbService.delete({table:Ht.TABLE_NAME,selection:Ht.COLUMN_NAME_GID+" = ?",selectionArgs:[e.groupId]})})),Object(ge.mergeMap)((function(){return e.uidList.length?ie.zip.apply(void 0,e.uidList.map((function(n){var r;return t.dbService.insert({table:Ht.TABLE_NAME,modelJson:(r={},r[Ht.COLUMN_NAME_GID]=e.groupId,r[Ht.COLUMN_NAME_UID]=n,r)})}))).pipe(Object(ge.mapTo)(e.uidList.length)):Object(ie.of)(0)})),Object(ge.tap)((function(){t.dbService.endTransaction(!0)})),Object(ge.catchError)((function(e){return t.dbService.endTransaction(!1),Object(ie.throwError)(e)})))},e.prototype.removeActiveGroupSession=function(){var e=this;return this.getActiveGroupSession().pipe(Object(ge.mergeMap)((function(n){return n?e.sharedPreferences.putString(t.KEY_GROUP_SESSION,""):Object(ie.of)(void 0)})))},e.KEY_GROUP_SESSION=z.KEY_GROUP_SESSION,e=t=Qs([Object(I.injectable)(),Zs(0,Object(I.inject)(be.CONTAINER)),Zs(1,Object(I.inject)(be.DB_SERVICE)),Zs(2,Object(I.inject)(be.PROFILE_SERVICE)),Zs(3,Object(I.inject)(be.SHARED_PREFERENCES)),$s("design:paramtypes",[I.Container,C,Object,Object])],e)}(),ru=function(){function e(e,t,n,r){this.apiService=e,this.systemSettingsConfig=t,this.fileservice=n,this.cachedItemStore=r,this.SYSTEM_SETTINGS_FILE_KEY_PREFIX="system-setting-",this.SYSTEM_SETTINGS_LOCAL_KEY="system-settings-",this.GET_SYSTEM_SETTINGS_ENDPOINT="/system/settings/get"}return e.prototype.handle=function(e){var t=this;return this.cachedItemStore.getCached(e.id,this.SYSTEM_SETTINGS_LOCAL_KEY,"ttl_"+this.SYSTEM_SETTINGS_LOCAL_KEY,(function(){return t.fetchFromServer(e)}),(function(){return t.fetchFromFile(e)}))},e.prototype.fetchFromServer=function(e){var t=(new F.Builder).withType(R.GET).withPath(this.systemSettingsConfig.systemSettingsApiPath+this.GET_SYSTEM_SETTINGS_ENDPOINT+"/"+e.id).withApiToken(!0).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){return e.body.result.response})))},e.prototype.fetchFromFile=function(e){var t=Wr.ASSETS_PATH+this.systemSettingsConfig.systemSettingsDirPath,n=this.SYSTEM_SETTINGS_FILE_KEY_PREFIX+e.id+".json";return Object(ie.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(ge.map)((function(e){return JSON.parse(e).result.response})))},e}(),iu=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},ou=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},au=function(e,t){return function(n,r){t(n,r,e)}},cu=function(){function e(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedChannelItemStore=r,this.systemSettingsConfig=this.sdkConfig.systemSettingsConfig}return e.prototype.getSystemSettings=function(e){return new ru(this.apiService,this.systemSettingsConfig,this.fileService,this.cachedChannelItemStore).handle(e)},e=iu([Object(I.injectable)(),au(0,Object(I.inject)(be.SDK_CONFIG)),au(1,Object(I.inject)(be.API_SERVICE)),au(2,Object(I.inject)(be.FILE_SERVICE)),au(3,Object(I.inject)(be.CACHED_ITEM_STORE)),ou("design:paramtypes",[Object,Object,Object,Object])],e)}(),su=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},uu=function(){function e(){}return e.prototype.unzip=function(e,t,n,r){JJzip.unzip(e,t,(function(){n&&n()}),(function(e){r&&r(e)}))},e.prototype.zip=function(e,t,n,r,i,o){JJzip.zip(e,t,n,r,(function(){i&&i()}),(function(e){o&&o(e)}))},e=su([Object(I.injectable)()],e)}();!function(e){e.INTERNAL_STORAGE="INTERNAL_STORAGE",e.EXTERNAL_STORAGE="EXTERNAL_STORAGE"}(vs||(vs={})),function(e){e.TRANSFER_PROGRESS="TRANSFER_PROGRESS",e.TRANSFER_COMPLETED="TRANSFER_COMPLETED",e.TRANSFER_REVERT_COMPLETED="TRANSFER_REVERT_COMPLETED",e.TRANSFER_FAILED_DUPLICATE_CONTENT="TRANSFER_FAILED_DUPLICATE_CONTENT",e.TRANSFER_FAILED_LOW_MEMORY="TRANSFER_FAILED_LOW_MEMORY"}(gs||(gs={})),function(e){e.IGNORE="IGNORE",e.KEEP_HIGER_VERSION="KEEP_HIGER_VERSION",e.KEEP_LOWER_VERSION="KEEP_LOWER_VERSION",e.KEEP_SOURCE="KEEP_SOURCE",e.KEEP_DESTINATION="KEEP_DESTINATION"}(ms||(ms={}));var fu,lu=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),hu=function(e){function t(n){var r=e.call(this,n,"TRANSFER_FAILED_DUPLICATE_CONTENT_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return lu(t,e),t}(U),du=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),pu=function(e){function t(n,r){var i=e.call(this,n,"TRANSFER_FAILED_ERROR")||this;return i.directory=r,Object.setPrototypeOf(i,t.prototype),i}return du(t,e),t}(U),bu=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},_u=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Eu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yu=function(){function e(){this.deviceId=Nc(window.device.uuid).toString()}return e.prototype.getDeviceID=function(){return this.deviceId},e.prototype.getDeviceSpec=function(){var e=this;return this.deviceSpec?Object(ie.of)(this.deviceSpec):new ie.Observable((function(t){sbutility.getDeviceSpec((function(n){e.deviceSpec=n,t.next(n),t.complete()}))}))},e.prototype.getAvailableInternalMemorySize=function(){return new ie.Observable((function(e){sbutility.getAvailableInternalMemorySize((function(t){e.next(t),e.complete()}),(function(t){e.error(t)}))}))},e.prototype.getStorageVolumes=function(){return ie.Observable.create((function(e){sbutility.getStorageVolumes((function(t){e.next(t.map((function(e){return e.isRemovable?{storageDestination:vs.EXTERNAL_STORAGE,info:bu({},e)}:{storageDestination:vs.INTERNAL_STORAGE,info:bu({},e)}}))),e.complete()}),(function(t){e.error(t)}))}))},e.prototype.isKeyboardShown=function(){var e,t,n;return new ie.Observable((function(r){e=function(){return r.next(!0)},t=function(){return r.next(!0)},n=function(){return r.next(!1)},function(){return r.next(!1)},window.addEventListener("native.keyboardshow",e),window.addEventListener("keyboardWillShow",t),window.addEventListener("native.keyboardhide",n),window.addEventListener("keyboardWillHide",n)})).pipe(Object(ge.distinctUntilChanged)(),Object(ge.tap)((function(){console.log("Subscribed isKeyboardShown event")})),Object(ge.finalize)((function(){console.log("Unsubscribed isKeyboardShown event"),window.removeEventListener("native.keyboardshow",e),window.removeEventListener("keyboardWillShow",t),window.removeEventListener("native.keyboardhide",n),window.removeEventListener("keyboardWillHide",n)})))},e=_u([Object(I.injectable)(),Eu("design:paramtypes",[])],e)}(),vu=function(){function e(){}return e.mapFeedbackDBEntrytoResponseFeedback=function(e){return{contentId:e[$t.COLUMN_NAME_CONTENT_ID],rating:Number(e[$t.COLUMN_NAME_RATING]),comments:e[$t.COLUMN_NAME_COMMENTS],createdAt:Number(e[$t.COLUMN_NAME_CREATED_AT]),stageId:"",contentVersion:""}},e}(),gu=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},mu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Su=function(e,t){return function(n,r){t(n,r,e)}},Ou=function(){function e(e,t,n){this.dbService=e,this.profileService=t,this.telemetryService=n}return e.prototype.getFeedback=function(e){var t="SELECT * FROM "+$t.TABLE_NAME+" "+Jr.getUidnIdentifierFiler(e.uid,e.contentId);return this.dbService.execute(t).pipe(Object(ge.map)((function(e){return e.map((function(e){return vu.mapFeedbackDBEntrytoResponseFeedback(e)}))})))},e.prototype.sendFeedback=function(e){var t=this;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(n){var r={table:$t.TABLE_NAME,selection:(new Wn).where("? = ? AND ? = ?").args([$t.COLUMN_NAME_CONTENT_ID,e.contentId,$t.COLUMN_NAME_UID,n.uid]).end().build(),limit:"1"},i={uid:n.uid,identifier:e.contentId,rating:e.rating,comments:e.comments,createdAt:Date.now()};return t.telemetryService.feedback({env:"sdk",rating:e.rating,comments:e.comments,objId:e.contentId,objType:Ie.CONTENT.valueOf(),objVer:e.contentVersion}).pipe(Object(ge.mergeMap)((function(){return t.dbService.read(r).pipe(Object(ge.mergeMap)((function(r){return r&&r.length?t.dbService.update({table:$t.TABLE_NAME,selection:$t.COLUMN_NAME_UID+"= ? AND "+$t.COLUMN_NAME_CONTENT_ID+"= ?",selectionArgs:[n.uid,e.contentId],modelJson:i}).pipe(Object(ge.map)((function(e){return e>0}))):t.dbService.insert({table:$t.TABLE_NAME,modelJson:i}).pipe(Object(ge.map)((function(e){return e>0})))})))})))})))},e=gu([Object(I.injectable)(),Su(0,Object(I.inject)(be.DB_SERVICE)),Su(1,Object(I.inject)(be.PROFILE_SERVICE)),Su(2,Object(I.inject)(be.TELEMETRY_SERVICE)),mu("design:paramtypes",[C,Object,Object])],e)}(),Au=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Tu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Nu=function(e,t){return function(n,r){t(n,r,e)}},Mu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},wu=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Cu=function(){function e(e){this.sdkConfig=e,this.eventsBus=new ie.Subject,this.eventDelegates=[],this.eventsBusConfig=this.sdkConfig.eventsBusConfig}return e.prototype.onInit=function(){var e=this;return this.eventsBus.pipe(Object(ge.tap)((function(t){e.eventsBusConfig.debugMode&&console.log("SDK Telemetry Events",t)})),Object(ge.tap)((function(t){return Mu(e,void 0,void 0,(function(){var e,n;return wu(this,(function(r){switch(r.label){case 0:e=this.eventDelegates.filter((function(e){return e.namespace===t.namespace})).map((function(e){return e.observer.onEvent(t.event).pipe(Object(ge.take)(1),Object(ge.catchError)((function(t){return console.error("Error: ",t,"EventObserver: ",e),Object(ie.of)(void 0)})))})),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,ie.zip.apply(void 0,e).toPromise()];case 2:return r.sent(),[3,4];case 3:return n=r.sent(),console.error("EVENT_BUS_DELEGATE_ERROR",n),[3,4];case 4:return[2]}}))}))})),Object(ge.mapTo)(void 0))},e.prototype.events=function(e){return this.eventsBus.asObservable().pipe(Object(ge.filter)((function(t){return!e||t.namespace===e})),Object(ge.map)((function(e){return e.event})))},e.prototype.emit=function(e){var t=e.namespace,n=e.event;this.eventsBus.next({namespace:t,event:n})},e.prototype.registerObserver=function(e){var t=e.namespace,n=e.observer;this.eventDelegates.push({namespace:t,observer:n})},e=Au([Object(I.injectable)(),Nu(0,Object(I.inject)(be.SDK_CONFIG)),Tu("design:paramtypes",[Object])],e)}(),Iu=n(121),Pu=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Lu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ru=function(e,t){return function(n,r){t(n,r,e)}},Du=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ju=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Uu=function(){function e(e,n){this.eventsBusService=e,this.sharedPreferences=n,this.currentDownloadRequest$=new ie.BehaviorSubject(void 0),window.downloadManager=Iu,this.sharedPreferencesSetCollection=new Ic(this.sharedPreferences,t.KEY_TO_DOWNLOAD_LIST,(function(e){return e.identifier}))}var t;return t=e,e.generateDownloadStartTelemetry=function(e){return Du(this,void 0,void 0,(function(){return ju(this,(function(t){return[2,hr.log.interact({type:Qe.OTHER,subType:$e.CONTENT_DOWNLOAD_INITIATE,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.contentType?e.contentMeta.contentType:"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(ge.mapTo)(void 0)).toPromise()]}))}))},e.generateDownloadCompleteTelemetry=function(e){return Du(this,void 0,void 0,(function(){return ju(this,(function(t){return[2,hr.log.interact({type:Qe.OTHER,subType:$e.CONTENT_DOWNLOAD_SUCCESS,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.contentType?e.contentMeta.contentType:"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(ge.mapTo)(void 0)).toPromise()]}))}))},e.generateDownloadCancelTelemetry=function(e){return Du(this,void 0,void 0,(function(){return ju(this,(function(t){return[2,hr.log.interact({type:Qe.OTHER,subType:$e.CONTENT_DOWNLOAD_CANCEL,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.contentType?e.contentMeta.contentType:"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(ge.mapTo)(void 0)).toPromise()]}))}))},e.prototype.onInit=function(){var e=this;return this.switchToNextDownloadRequest().pipe(Object(ge.mergeMap)((function(){return e.listenForDownloadProgressChanges()})))},e.prototype.download=function(e){var t=this;return this.currentDownloadRequest$.pipe(Object(ge.take)(1),Object(ge.mergeMap)((function(n){return n?t.addToDownloadList(e):t.addToDownloadList(e).pipe(Object(ge.tap)((function(){return t.switchToNextDownloadRequest().toPromise()})))})))},e.prototype.cancel=function(e,t){var n=this;return void 0===t&&(t=!0),this.currentDownloadRequest$.pipe(Object(ge.take)(1),Object(ge.mergeMap)((function(r){return r&&r.identifier===e.identifier?new ie.Observable((function(e){downloadManager.remove([r.downloadId],(function(t,n){t&&e.error(t),e.next(!!n),e.complete()}))})).pipe(Object(ge.mergeMap)((function(){return n.removeFromDownloadList(e,t)})),Object(ge.tap)((function(){return n.switchToNextDownloadRequest().toPromise()}))):n.removeFromDownloadList(e,t)})))},e.prototype.cancelAll=function(){var e=this;return this.currentDownloadRequest$.pipe(Object(ge.take)(1),Object(ge.mergeMap)((function(t){return t?new ie.Observable((function(e){downloadManager.remove([t.downloadId],(function(t,n){t&&e.error(t),e.next(!!n),e.complete()}))})).pipe(Object(ge.mergeMap)((function(){return e.removeAllFromDownloadList()})),Object(ge.mergeMap)((function(){return e.switchToNextDownloadRequest()}))):e.removeAllFromDownloadList()})))},e.prototype.registerOnDownloadCompleteDelegate=function(e){this.downloadCompleteDelegate=e},e.prototype.getActiveDownloadRequests=function(){return this.sharedPreferencesSetCollection.asListChanges().pipe(Object(ge.map)((function(e){return e.sort((function(e,t){var n=e.withPriority||0;return(t.withPriority||0)-n}))})))},e.prototype.switchToNextDownloadRequest=function(){var e=this;return this.sharedPreferencesSetCollection.asSet().pipe(Object(ge.mergeMap)((function(n){if(!n.size())return Object(ie.of)(void 0).pipe(Object(ge.tap)((function(){return e.currentDownloadRequest$.next(void 0)})));var r=n.toArray().sort((function(e,t){var n=e.withPriority||0;return(t.withPriority||0)-n})).shift();return new ie.Observable((function(e){downloadManager.enqueue({uri:r.downloadUrl,title:r.filename,description:"",mimeType:r.mimeType,visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalFilesDir:{dirType:t.DOWNLOAD_DIR_NAME,subPath:r.filename},headers:[]},(function(t,n){if(t)return e.error(t);e.next(n)}))})).pipe(Object(ge.tap)((function(n){r.downloadedFilePath=cordova.file.externalDataDirectory+t.DOWNLOAD_DIR_NAME+"/"+r.filename,r.downloadId=n,e.currentDownloadRequest$.next(r)})),Object(ge.tap)((function(){return Du(e,void 0,void 0,(function(){return ju(this,(function(e){switch(e.label){case 0:return[4,t.generateDownloadStartTelemetry(r)];case 1:return[2,e.sent()]}}))}))})),Object(ge.mapTo)(void 0),Object(ge.catchError)((function(){return e.cancel({identifier:r.identifier})})))})))},e.prototype.addToDownloadList=function(e){return this.sharedPreferencesSetCollection.addAll(e).pipe(Object(ge.mapTo)(void 0))},e.prototype.removeFromDownloadList=function(e,n){var r=this;return this.sharedPreferencesSetCollection.asList().pipe(Object(ge.mergeMap)((function(i){var o=i.find((function(t){return t.identifier===e.identifier}));return o?r.sharedPreferencesSetCollection.remove(o).pipe(Object(ge.mapTo)(void 0),Object(ge.tap)((function(){return Du(r,void 0,void 0,(function(){var e;return ju(this,(function(r){switch(r.label){case 0:return(e=n)?[4,t.generateDownloadCancelTelemetry(o)]:[3,2];case 1:e=r.sent(),r.label=2;case 2:return[2,e]}}))}))}))):Object(ie.of)(void 0)})))},e.prototype.removeAllFromDownloadList=function(){var e=this;return this.sharedPreferencesSetCollection.asList().pipe(Object(ge.take)(1),Object(ge.mergeMap)((function(n){return e.sharedPreferencesSetCollection.clear().pipe(Object(ge.mergeMap)((function(){return Object(ie.from)(n).pipe(Object(ge.tap)((function(n){return Du(e,void 0,void 0,(function(){return ju(this,(function(e){switch(e.label){case 0:return[4,t.generateDownloadCancelTelemetry(n)];case 1:return[2,e.sent()]}}))}))})),Object(ge.concatMapTo)(Object(ie.of)(void 0)))})))})))},e.prototype.handleDownloadCompletion=function(e){var n=this;return this.currentDownloadRequest$.pipe(Object(ge.take)(1),Object(ge.mergeMap)((function(r){return e.payload.status===Ur.STATUS_SUCCESSFUL?Object(ie.iif)((function(){return!!n.downloadCompleteDelegate}),Object(ie.defer)((function(){return Du(n,void 0,void 0,(function(){return ju(this,(function(e){return t.generateDownloadCompleteTelemetry(r),this.downloadCompleteDelegate.onDownloadCompletion(r).toPromise(),[2]}))}))})),Object(ie.defer)((function(){return Object(ie.of)(void 0)}))).pipe(Object(ge.mapTo)(void 0)):Object(ie.of)(void 0)})))},e.prototype.emitProgressInEventBus=function(e){var t=this;return Object(ie.defer)((function(){return Object(ie.of)(t.eventsBusService.emit({namespace:_e.DOWNLOADS,event:e})).pipe(Object(ge.mapTo)(void 0))}))},e.prototype.getDownloadProgress=function(e){var t=this;return new ie.Observable((function(n){downloadManager.query({ids:[e.downloadId]},(function(r,i){if(r)return n.next({type:jr.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:-1,bytesDownloaded:0,totalSizeInBytes:0,status:Ur.STATUS_FAILED}}),n.complete(),void t.cancel({identifier:e.identifier}).toPromise();var o=i[0];n.next({type:jr.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:Math.round(o.totalSizeBytes>=0?o.bytesDownloadedSoFar/o.totalSizeBytes*100:-1),bytesDownloaded:o.bytesDownloadedSoFar,totalSizeInBytes:o.totalSizeBytes,status:o.status}}),n.complete()}))}))},e.prototype.listenForDownloadProgressChanges=function(){var e=this;return this.currentDownloadRequest$.pipe(Object(ge.switchMap)((function(t){return t?(e.eventsBusService.emit({namespace:_e.DOWNLOADS,event:{type:jr.START,payload:void 0}}),Object(ie.interval)(1e3).pipe(Object(ge.mergeMap)((function(){return e.getDownloadProgress(t)})),Object(ge.distinctUntilChanged)((function(e,t){return JSON.stringify(e)===JSON.stringify(t)})),Object(ge.mergeMap)((function(t){return Object(ie.zip)(e.handleDownloadCompletion(t),e.emitProgressInEventBus(t)).pipe(Object(ge.mapTo)(t))})),Object(ge.tap)((function(t){t.payload.status!==Ur.STATUS_FAILED&&t.payload.status!==Ur.STATUS_SUCCESSFUL||e.eventsBusService.emit({namespace:_e.DOWNLOADS,event:{type:jr.END,payload:void 0}})})),Object(ge.mapTo)(void 0))):Object(ie.of)(void 0)})))},e.KEY_TO_DOWNLOAD_LIST=X.KEY_TO_DOWNLOAD_LIST,e.DOWNLOAD_DIR_NAME="Download",e=t=Pu([Object(I.injectable)(),Ru(0,Object(I.inject)(be.EVENTS_BUS_SERVICE)),Ru(1,Object(I.inject)(be.SHARED_PREFERENCES)),Lu("design:paramtypes",[Object,Object])],e)}(),ku=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},xu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Bu=function(e,t){return function(n,r){t(n,r,e)}},Fu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Vu=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Yu=function(){function e(e,t){var n=this;this.sdkConfig=e,this.sharedPreferences=t,"cordova"!==e.platform&&(this.versionName="sunbird-debug"),cordova.getAppVersion.getAppName((function(e){return n.appName=e}))}return e.prototype.getVersionName=function(){return this.versionName},e.prototype.getAppName=function(){return this.appName},e.prototype.init=function(){return Fu(this,void 0,void 0,(function(){var e,t=this;return Vu(this,(function(n){switch(n.label){case 0:return[4,this.setFirstAccessTimestamp()];case 1:return n.sent(),"cordova"!==this.sdkConfig.platform?[2,void 0]:(e=this.sdkConfig.appConfig.buildConfigPackage?this.sdkConfig.appConfig.buildConfigPackage:"org.sunbird.app",[2,this.getBuildConfigValue(e,"REAL_VERSION_NAME").then((function(e){t.versionName=e,console.log("version name",t.versionName)}))])}}))}))},e.prototype.getBuildConfigValue=function(e,t){return new Promise((function(n,r){try{sbutility.getBuildConfigValue(e,t,(function(e){n(e)}),(function(e){console.error(e),r(e)}))}catch(e){console.error(e),r(e)}}))},e.prototype.getFirstAccessTimestamp=function(){return this.sharedPreferences.getString(G.KEY_FIRST_ACCESS_TIMESTAMP).pipe(Object(ge.map)((function(e){return e})))},e.prototype.setFirstAccessTimestamp=function(){return Fu(this,void 0,void 0,(function(){return Vu(this,(function(e){switch(e.label){case 0:return[4,this.sharedPreferences.getString(G.KEY_FIRST_ACCESS_TIMESTAMP).toPromise()];case 1:return e.sent()?[3,3]:[4,this.sharedPreferences.putString(G.KEY_FIRST_ACCESS_TIMESTAMP,Date.now()+"").toPromise()];case 2:return e.sent(),[2,!0];case 3:return[2,!1]}}))}))},e=ku([Object(I.injectable)(),Bu(0,Object(I.inject)(be.SDK_CONFIG)),Bu(1,Object(I.inject)(be.SHARED_PREFERENCES)),xu("design:paramtypes",[Object,Object])],e)}(),Gu=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Hu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},qu=function(e,t){return function(n,r){t(n,r,e)}},zu=function(){function e(e,t,n,r,i,o){this.profileService=e,this.groupService=t,this.config=n,this.frameworkService=r,this.deviceInfo=i,this.appInfo=o}return e.prototype.getPlayerConfig=function(e,t){var n=this,r={};r.did=this.deviceInfo.getDeviceID(),r.origin=this.config.apiConfig.host;var i=new _t;i.id=this.config.apiConfig.api_authentication.producerId,i.pid=this.config.apiConfig.api_authentication.producerUniqueId,i.ver=this.appInfo.getVersionName(),r.pdata=i;var o={};return e.rollup=Jr.getRollup(e.identifier,e.hierarchyInfo),r.objectRollup=e.rollup,e.basePath=e.basePath.replace(/\/$/,""),e.isAvailableLocally&&(e.contentData.streamingUrl=e.basePath,e.contentData.previewUrl=e.basePath),o.metadata=e,o.config=this.config.playerConfig,this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(e){r.sid=e?e.sid:"";var t=new ct;t.id=e?e.uid:"",r.actor=t;var i=n.config.appConfig.deepLinkBasePath;return r.deeplinkBasePath=i||"",n.profileService.getActiveSessionProfile({requiredFields:[]})})),Object(ge.mergeMap)((function(e){if(e&&e.serverProfile){var t=e.serverProfile.organisations;if(t){var i=t[0]&&t[0].organisationId;r.contextRollup={l1:i}}}return n.groupService.getActiveGroupSession()})),Object(ge.mergeMap)((function(e){var i=[];e&&e.gid&&i.push({id:e.gid,type:"group"});var a=t&&t.hasOwnProperty("streaming"),c=t.correlationData;c&&c.length&&(i=i.concat(c)),i.push({id:a?"streaming":"offline",type:"PlayerLaunch"}),r.cdata=i,o.context=r;var s={local:!0,server:!1};return s.groupId=e?e.gid:"",o.appContext=s,n.frameworkService.getActiveChannelId()})),Object(ge.mergeMap)((function(e){return r.channel=e||n.config.apiConfig.api_authentication.channelId,o.context=r,Object(ie.of)(o)})))},e=Gu([Object(I.injectable)(),qu(0,Object(I.inject)(be.PROFILE_SERVICE)),qu(1,Object(I.inject)(be.GROUP_SERVICE)),qu(2,Object(I.inject)(be.SDK_CONFIG)),qu(3,Object(I.inject)(be.FRAMEWORK_SERVICE)),qu(4,Object(I.inject)(be.DEVICE_INFO)),qu(5,Object(I.inject)(be.APP_INFO)),Hu("design:paramtypes",[Object,Object,Object,Object,Object,Object])],e)}(),Ku=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Wu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Xu=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ju=function(e){function t(){return e.call(this,6,21)||this}return Ku(t,e),t.prototype.apply=function(e){return Wu(this,void 0,void 0,(function(){var t=this;return Xu(this,(function(n){switch(n.label){case 0:return[4,Promise.all(this.queries().map((function(t){return e.execute(t).toPromise()})))];case 1:return n.sent(),[4,e.read({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_CONTENT_TYPE+" = ?",selectionArgs:["textbook"]}).pipe(Object(ge.map)((function(n){n.forEach((function(n){return Wu(t,void 0,void 0,(function(){var t,r;return Xu(this,(function(i){switch(i.label){case 0:return(t=n[Wt.COLUMN_NAME_LOCAL_DATA])?(r=JSON.parse(t),n[Wt.COLUMN_NAME_BOARD]=Jr.getContentAttribute(r.board),n[Wt.COLUMN_NAME_MEDIUM]=Jr.getContentAttribute(r.medium),n[Wt.COLUMN_NAME_GRADE]=Jr.getContentAttribute(r.gradeLevel),[4,e.update({table:Wt.TABLE_NAME,modelJson:n,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n[Wt.COLUMN_NAME_IDENTIFIER]]}).toPromise()]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))}))}))).toPromise()];case 2:return n.sent(),[2,void 0]}}))}))},t.prototype.queries=function(){return[Wt.getAlterEntryForBoard(),Wt.getAlterEntryForMedium(),Wt.getAlterEntryForGrade()]},t}(w),Qu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},$u=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Zu=function(){function e(e,t,n,r){this.sharedPreferences=e,this.apiConfig=t,this.deviceInfo=n,this.apiService=r,this.apiTokenHandler=new Oe(this.apiConfig,this.apiService,this.deviceInfo)}return e.prototype.interceptRequest=function(e){return this.sharedPreferences.getString(H.KEY_API_TOKEN).pipe(Object(ge.map)((function(t){if(t){var n=e.headers;n.Authorization="Bearer "+t,e.headers=n}return e})))},e.prototype.interceptResponse=function(e,t){var n=this;return t.responseCode===N.HTTP_UNAUTHORISED&&"Unauthorized"===t.body.message||t.responseCode===N.HTTP_FORBIDDEN?this.apiTokenHandler.refreshAuthToken().pipe(Object(ge.tap)((function(e){return Qu(n,void 0,void 0,(function(){return $u(this,(function(t){switch(t.label){case 0:return[4,this.sharedPreferences.putString(H.KEY_API_TOKEN,e).toPromise()];case 1:return t.sent(),[2]}}))}))})),Object(ge.mergeMap)((function(){return n.apiService.fetch(e)}))):Object(ie.of)(t)},e}(),ef=function(){function e(e,t,n,r){this.sharedPreferences=e,this.apiConfig=t,this.apiService=n,this.authService=r}return e.prototype.interceptRequest=function(e){return this.sharedPreferences.getString(q.KEY_OAUTH_SESSION).pipe(Object(ge.map)((function(t){if(!t)throw new Error("No Session Found");var n=JSON.parse(t),r=e.headers;return r["X-Authenticated-User-Token"]=n.access_token,e.headers=r,e})))},e.prototype.interceptResponse=function(e,t){var n=this;return t.responseCode!==N.HTTP_UNAUTHORISED?Object(ie.of)(t):t.body.message?Object(ie.of)(t):this.invokeRefreshSessionTokenApi().pipe(Object(ge.mergeMap)((function(){return n.apiService.fetch(e)})))},e.prototype.invokeRefreshSessionTokenApi=function(){return this.authService.refreshSession()},e}(),tf=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),nf=function(e){function t(n){var r=e.call(this,n,"LOW_MEMORY")||this;return Object.setPrototypeOf(r,t.prototype),r}return tf(t,e),t}(U),rf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},of=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},af=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return rf(t,void 0,void 0,(function(){var t,n,r;return of(this,(function(i){switch(i.label){case 0:return[4,this.getFreeUsableSpace(e.destinationFolder)];case 1:return t=i.sent(),[4,new Cc(this.dbService).getContentUsageSummary([e.sourceFolder])];case 2:if(n=i.sent(),r=0,n&&n.length&&(r=n[0].sizeOnDevice),Jr.isFreeSpaceAvailable(t,r,0))return[2,e];throw new nf("Available memory not sufficient for transfer operation")}}))}))}))},e.prototype.getFreeUsableSpace=function(e){return rf(this,void 0,void 0,(function(){return of(this,(function(t){return[2,new Promise((function(t,n){sbutility.getFreeUsableSpace(e,(function(e){t(Number(e))}),(function(e){n(e)}))}))]}))}))},e}(),cf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},sf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},uf=function(){function e(e,t){this.fileService=e,this.appConfig=t}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return cf(t,void 0,void 0,(function(){var t,n=this;return sf(this,(function(r){switch(r.label){case 0:return t=e,[4,this.getSubdirectoriesEntries(e.destinationFolder).then((function(e){return n.extractValidContentIdsInDestination(e)}))];case 1:return t.validContentIdsInDestination=r.sent(),[2,e]}}))}))}))},e.prototype.getSubdirectoriesEntries=function(e){return cf(this,void 0,void 0,(function(){return sf(this,(function(t){return[2,this.fileService.listDir(e.replace(/\/$/,"")).then((function(e){return e.filter((function(e){return e.isDirectory}))}))]}))}))},e.prototype.extractValidContentIdsInDestination=function(e){return cf(this,void 0,void 0,(function(){var t,n,r,i,o,a,c,s,u;return sf(this,(function(f){switch(f.label){case 0:t=[],n=0,r=e,f.label=1;case 1:if(!(n<r.length))return[3,7];if(!(i=r[n]).isDirectory)return[3,6];o=void 0,f.label=2;case 2:return f.trys.push([2,4,,5]),[4,this.extractManifest(i)];case 3:return o=f.sent(),[3,5];case 4:return f.sent(),[3,5];case 5:if(!o)return[3,6];for(a=o.archive.items,c=0,s=a;c<s.length;c++)u=s[c],Jr.readVisibility(u)!==Dn.PARENT&&Jr.isCompatible(this.appConfig,Jr.readCompatibilityLevel(u))&&(Jr.isDraftContent(u.status)&&Jr.isExpired(u.expires)||t.push(i.name));f.label=6;case 6:return n++,[3,1];case 7:return[2,t]}}))}))},e.prototype.extractManifest=function(e){return cf(this,void 0,void 0,(function(){var t;return sf(this,(function(n){switch(n.label){case 0:return[4,this.fileService.readAsText(e.nativeURL,Yn.MANIFEST.valueOf())];case 1:return t=n.sent(),[2,JSON.parse(t)]}}))}))},e}(),ff=function(){function e(){}return e.prototype.execute=function(e){return Object(ie.of)(e)},e}(),lf=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),hf=function(e){function t(n){var r=e.call(this,n,"DUPLICATE_CONTENT")||this;return Object.setPrototypeOf(r,t.prototype),r}return lf(t,e),t}(U),df=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},pf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},bf=Wt.COLUMN_NAME_IDENTIFIER,_f=Wt.COLUMN_NAME_LOCAL_DATA,Ef=function(){function e(e,t){this.dbService=e,this.fileService=t}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return df(t,void 0,void 0,(function(){var t,n,r;return pf(this,(function(i){switch(i.label){case 0:return[4,this.getContentsInDb(e.contentIds)];case 1:return t=i.sent(),n=[],e.validContentIdsInDestination&&e.validContentIdsInDestination.length?[4,this.getContentsInDb(e.validContentIdsInDestination)]:[3,3];case 2:n=i.sent(),i.label=3;case 3:return[4,this.generateMoveContentResponses(e,n)];case 4:if(r=i.sent().moveContentDupContentList,e.contentsInSource=t,e.duplicateContents=r,e.duplicateContents.length&&!e.shouldMergeInDestination)throw new hf("context.shouldMergeInDestination is false");return[2]}}))}))})).pipe(Object(ge.mapTo)(e))},e.prototype.getContentsInDb=function(e){return df(this,void 0,void 0,(function(){return pf(this,(function(t){return e.length?[2,this.dbService.execute(Jr.getFindAllContentsWithIdentifierQuery(e)).toPromise()]:[2,this.dbService.execute(Jr.getFindAllContentsQuery()).toPromise()]}))}))},e.prototype.getPkgVersionFromFile=function(e,t){return this.fileService.readAsText(e.concat(t),Yn.MANIFEST.valueOf()).then((function(e){var n=JSON.parse(e).archive.items;return n?n.find((function(e){return e.identifier===t})).pkgVersion:0})).catch((function(){return-1}))},e.prototype.generateMoveContentResponses=function(e,t){return df(this,void 0,void 0,(function(){var n,r,i,o,a,c,s,u;return pf(this,(function(f){switch(f.label){case 0:n=[],r=[],i=0,o=t,f.label=1;case 1:return i<o.length?(a=o[i],[4,this.getPkgVersionFromFile(e.destinationFolder,a[bf])]):[3,4];case 2:c=f.sent(),s=Jr.readPkgVersion(JSON.parse(a[_f])),-1!==c&&(c>s?(u={identifier:a[bf],status:fu.HIGHER_VERSION_IN_DESTINATION},n.push(u),r.push(u)):c<s?(u={identifier:a[bf],status:fu.LOWER_VERSION_IN_DESTINATION},n.push(u),r.push(u)):(u={identifier:a[bf],status:fu.SAME_VERSION_IN_BOTH},r.push(u))),f.label=3;case 3:return i++,[3,1];case 4:return[2,{moveContentDiffPkgList:n,moveContentDupContentList:r}]}}))}))},e}(),yf=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),vf=function(e){function t(n){var r=e.call(this,n,"CANCELLED")||this;return Object.setPrototypeOf(r,t.prototype),r}return yf(t,e),t}(U),gf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},mf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Sf=Wt.COLUMN_NAME_IDENTIFIER,Of=Wt.COLUMN_NAME_PATH,Af=function(){function e(e){this.eventsBusService=e,this.contentsTransferred=0}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return gf(t,void 0,void 0,(function(){var t,n,r,i,o;return mf(this,(function(a){switch(a.label){case 0:t=function(t){var r,i;return mf(this,(function(o){switch(o.label){case 0:return e.hasTransferCancelled?[4,n.deleteFolder(e.destinationFolder.concat("temp","/"))]:[3,2];case 1:throw o.sent(),new vf("CANCELLED");case 2:if((r=e.duplicateContents.find((function(e){return e.identifier===t[Sf]})))&&!Er.isEmpty(e.duplicateContents))return[3,7];i=e.destinationFolder.concat("temp","/"),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,n.copyFolder(t[Of],i+t[Sf])];case 4:return o.sent(),[3,6];case 5:return o.sent(),[3,6];case 6:return n.emitContentTransferProgress(e),[2,"continue"];case 7:if(!e.existingContentAction)return n.emitContentTransferProgress(e),[2,"continue"];if(r.status===fu.SAME_VERSION_IN_BOTH)return n.emitContentTransferProgress(e),[2,"continue"];switch(e.existingContentAction){case ms.KEEP_HIGER_VERSION:return[3,8];case ms.KEEP_LOWER_VERSION:return[3,11];case ms.KEEP_SOURCE:return[3,14];case ms.IGNORE:case ms.KEEP_DESTINATION:return[3,17]}return[3,17];case 8:return r.status===fu.HIGHER_VERSION_IN_DESTINATION?[3,17]:[4,n.copyToTempDestination(e,t,r)];case 9:return o.sent(),[4,n.removeSourceAndDestination(e,t,r)];case 10:return o.sent(),[3,17];case 11:return r.status===fu.LOWER_VERSION_IN_DESTINATION?[3,17]:[4,n.copyToTempDestination(e,t,r)];case 12:return o.sent(),[4,n.removeSourceAndDestination(e,t,r)];case 13:return o.sent(),[3,17];case 14:return[4,n.copyToTempDestination(e,t,r)];case 15:return o.sent(),[4,n.removeSourceAndDestination(e,t,r)];case 16:return o.sent(),[3,17];case 17:return n.emitContentTransferProgress(e),[2]}}))},n=this,r=0,i=e.contentsInSource,a.label=1;case 1:return r<i.length?(o=i[r],[5,t(o)]):[3,4];case 2:a.sent(),a.label=3;case 3:return r++,[3,1];case 4:return[2,e]}}))}))}))},e.prototype.emitContentTransferProgress=function(e){this.eventsBusService.emit({namespace:_e.STORAGE,event:{type:gs.TRANSFER_PROGRESS,payload:{progress:{transferredCount:++this.contentsTransferred,totalCount:e.contentsInSource.length}}}})},e.prototype.deleteFolder=function(e){return gf(this,void 0,void 0,(function(){return mf(this,(function(t){return e?[2,new Promise((function(t,n){sbutility.rm(e,"",(function(){t()}),(function(e){n(e)}))}))]:[2]}))}))},e.prototype.copyFolder=function(e,t){return gf(this,void 0,void 0,(function(){return mf(this,(function(n){return e&&t?[2,new Promise((function(n,r){sbutility.copyDirectory(e,t,(function(){n()}),(function(e){r(e)}))}))]:[2]}))}))},e.prototype.renameFolder=function(e,t){return gf(this,void 0,void 0,(function(){return mf(this,(function(n){return e?[2,new Promise((function(n,r){sbutility.renameDirectory(e,t,(function(){n()}),(function(e){r(e)}))}))]:[2]}))}))},e.prototype.copyToTempDestination=function(e,t,n){return gf(this,void 0,void 0,(function(){return mf(this,(function(r){switch(r.label){case 0:return[4,this.renameFolder(e.destinationFolder,n.identifier)];case 1:return r.sent(),[4,this.copyFolder(t[Of],e.destinationFolder+t[Sf])];case 2:return r.sent(),[2]}}))}))},e.prototype.removeSourceAndDestination=function(e,t,n){return gf(this,void 0,void 0,(function(){return mf(this,(function(r){switch(r.label){case 0:return[4,this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp"))];case 1:return r.sent(),[4,this.deleteFolder(t[Of])];case 2:return r.sent(),[2]}}))}))},e}(),Tf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Nf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Mf=Wt.COLUMN_NAME_PATH,wf=Wt.COLUMN_NAME_IDENTIFIER,Cf=function(){function e(e){this.dbService=e}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return Tf(t,void 0,void 0,(function(){var t,n,r;return Nf(this,(function(i){switch(i.label){case 0:this.dbService.beginTransaction(),i.label=1;case 1:i.trys.push([1,6,,7]),t=0,n=e.contentsInSource,i.label=2;case 2:return t<n.length?((r=n[t])[Mf]=Jr.getBasePath(e.destinationFolder.concat(r[wf],"/")),[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[r[Wt.COLUMN_NAME_IDENTIFIER]],modelJson:r}).toPromise()]):[3,5];case 3:i.sent(),i.label=4;case 4:return t++,[3,2];case 5:return this.dbService.endTransaction(!0),[3,7];case 6:return i.sent(),this.dbService.endTransaction(!1),[3,7];case 7:return[2]}}))}))})).pipe(Object(ge.mapTo)(e))},e}(),If=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Pf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Lf=function(){function e(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return If(t,void 0,void 0,(function(){var t,n,r,i,o,a,c;return Pf(this,(function(s){switch(s.label){case 0:for(n=0,r=e.duplicateContents;n<r.length;n++)switch(i=r[n],e.existingContentAction||ms.IGNORE){case ms.KEEP_HIGER_VERSION:i.status===fu.HIGHER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(i.identifier,e.destinationFolder,!1);break;case ms.KEEP_LOWER_VERSION:i.status===fu.LOWER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(i.identifier,e.destinationFolder,!0);break;case ms.KEEP_DESTINATION:case ms.IGNORE:i.status===fu.LOWER_VERSION_IN_DESTINATION?this.addDestinationContentInDb(i.identifier,e.destinationFolder,!0):this.addDestinationContentInDb(i.identifier,e.destinationFolder,!1)}if(e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&e.duplicateContents&&e.duplicateContents.length?t=this.getNewlyAddedContents(e.validContentIdsInDestination,e.duplicateContents.map((function(e){return e.identifier}))):e.validContentIdsInDestination&&e.duplicateContents.length||!e.validContentIdsInDestination||!e.validContentIdsInDestination.length||(t=e.validContentIdsInDestination),!t)return[3,4];o=0,a=t,s.label=1;case 1:return o<a.length?(c=a[o],[4,this.addDestinationContentInDb(c,e.destinationFolder,!1)]):[3,4];case 2:s.sent(),s.label=3;case 3:return o++,[3,1];case 4:return[2]}}))}))}))},e.prototype.getNewlyAddedContents=function(e,t){return e.filter((function(e){return t.find((function(t){return t!==e}))}))},e.prototype.addDestinationContentInDb=function(e,t,n){var r=this,i=t.concat(e);return this.fileService.readAsText(t.concat(e),Yn.MANIFEST.valueOf()).then((function(e){var t=JSON.parse(e),o=t.archive.items;return r.extractContentFromItem(o,i.concat("/"),t.ver,n)})).catch((function(e){console.error(e)}))},e.prototype.extractContentFromItem=function(e,t,n,r){return If(this,void 0,void 0,(function(){var i,o,a,c,s,u,f,l,h,d,p,b,_,E,y,v,g,m,S,O,A,T,N,M,w,C,I,P,L;return Pf(this,(function(R){switch(R.label){case 0:i=[],o=[],a=0,c=e,R.label=1;case 1:return a<c.length?(P=c[a],u=(s=P).identifier,f=s.mimeType,l=Jr.readContentType(s),h=Jr.readVisibility(s),d=Jr.readAudience(s),p=Jr.readPragma(s),b=Jr.readCompatibilityLevel(s),_=s.pkgVersion,E=Ln.ONLY_SPINE.valueOf(),y=s.board,v=s.medium,g=s.gradeLevel,[4,this.dbService.read({table:Wt.TABLE_NAME,columns:[],selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[u]}).toPromise()]):[3,5];case 2:return m=R.sent()[0],S=m&&Jr.getBasePath(m[Wt.COLUMN_NAME_PATH]),(O=Jr.doesContentExist(m,u,_,r))&&s.status!==jn.DRAFT.valueOf()?m[Wt.COLUMN_NAME_VISIBILITY]===Dn.DEFAULT.valueOf()&&(s=JSON.parse(m[Wt.COLUMN_NAME_LOCAL_DATA])):(O=!1,Jr.isCompatible(this.appConfig,b)&&(E=(Rn.COLLECTION.valueOf(),Ln.ARTIFACT_AVAILABLE.valueOf()))),A=Jr.getReferenceCount(m,h),h=Jr.getContentVisibility(m,s.objectType,h),E=Jr.getContentState(m,E),T=O?S:t,[4,this.fileService.getDirectorySize(T)];case 3:N=R.sent(),Jr.addOrUpdateViralityMetadata(s,this.deviceInfo.getDeviceID().toString()),L=Jr.constructContentDBModel(u,n,JSON.stringify(s),f,l,h,T,A,E,d,p,N,y,v,g),m?o.push(L):i.push(L),R.label=4;case 4:return a++,[3,1];case 5:if(!i.length&&!o.length)return[3,14];this.dbService.beginTransaction(),M=0,w=i,R.label=6;case 6:return M<w.length?(P=w[M],L=P,[4,this.dbService.insert({table:Wt.TABLE_NAME,modelJson:L}).toPromise()]):[3,9];case 7:R.sent(),R.label=8;case 8:return M++,[3,6];case 9:C=0,I=o,R.label=10;case 10:return C<I.length?(P=I[C],L=P,[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[L[Wt.COLUMN_NAME_IDENTIFIER]],modelJson:L}).toPromise()]):[3,13];case 11:R.sent(),R.label=12;case 12:return C++,[3,10];case 13:this.dbService.endTransaction(!0),R.label=14;case 14:return[2]}}))}))},e}(),Rf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Df=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},jf=function(){function e(e){this.fileService=e}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return Rf(t,void 0,void 0,(function(){var t,n=this;return Df(this,(function(r){switch(r.label){case 0:return t=e,[4,this.validate(e.destinationFolder).then((function(e){return n.createDirectory(e)}))];case 1:return t.destinationFolder=r.sent(),[2,e]}}))}))}))},e.prototype.validate=function(e){return this.canWrite(e).then((function(){return e.endsWith("content/")||(e=e.concat("content")),e})).catch((function(){throw Error("Destination is not writable")}))},e.prototype.createDirectory=function(e){var t=this;return this.fileService.exists(e).then((function(e){return e.nativeURL})).catch((function(){return t.fileService.createDir(e,!1).then((function(e){return e.nativeURL}))}))},e.prototype.canWrite=function(e){return Rf(this,void 0,void 0,(function(){return Df(this,(function(t){return[2,new Promise((function(t,n){sbutility.canWrite(e,(function(){t()}),(function(e){n(e)}))}))]}))}))},e}(),Uf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},kf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},xf=Wt.COLUMN_NAME_IDENTIFIER,Bf=Wt.COLUMN_NAME_PATH,Ff=function(){function e(e){this.eventsBusService=e}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return Uf(t,void 0,void 0,(function(){var t,n,r;return kf(this,(function(i){switch(i.label){case 0:t=function(t){var r,i,o;return kf(this,(function(a){switch(a.label){case 0:if(r=e.contentsInSource[t],i=e.duplicateContents.find((function(e){return e.identifier===r[xf]})),o=e.destinationFolder.concat("temp","/"),i&&!Er.isEmpty(e.duplicateContents))return[3,9];a.label=1;case 1:return a.trys.push([1,7,,8]),[4,n.copyFolder(o.concat(r[xf]),e.destinationFolder+r[xf])];case 2:return a.sent(),[4,n.deleteFolder(o.concat(r[xf]))];case 3:return a.sent(),[4,n.deleteFolder(r[Bf])];case 4:return a.sent(),t!==e.contentsInSource.length-1?[3,6]:[4,n.deleteFolder(o)];case 5:a.sent(),a.label=6;case 6:return[3,8];case 7:return a.sent(),[3,8];case 8:return[2,"continue"];case 9:if(!e.existingContentAction)return[2,"continue"];if(i.status===fu.SAME_VERSION_IN_BOTH)return[2,"continue"];switch(e.existingContentAction){case ms.KEEP_HIGER_VERSION:return[3,10];case ms.KEEP_LOWER_VERSION:return[3,12];case ms.KEEP_SOURCE:return[3,14];case ms.IGNORE:case ms.KEEP_DESTINATION:return[3,16]}return[3,16];case 10:return i.status===fu.HIGHER_VERSION_IN_DESTINATION?[3,16]:[4,n.removeSourceAndDestination(e,r,i)];case 11:return a.sent(),[3,16];case 12:return i.status===fu.LOWER_VERSION_IN_DESTINATION?[3,16]:[4,n.removeSourceAndDestination(e,r,i)];case 13:return a.sent(),[3,16];case 14:return[4,n.removeSourceAndDestination(e,r,i)];case 15:return a.sent(),[3,16];case 16:return t!==e.contentsInSource.length-1?[3,18]:[4,n.deleteFolder(o)];case 17:a.sent(),a.label=18;case 18:return[2]}}))},n=this,r=0,i.label=1;case 1:return r<e.contentsInSource.length?[5,t(r)]:[3,4];case 2:i.sent(),i.label=3;case 3:return r++,[3,1];case 4:return[2,e]}}))}))}))},e.prototype.deleteFolder=function(e){return Uf(this,void 0,void 0,(function(){return kf(this,(function(t){return e?[2,new Promise((function(t,n){sbutility.rm(e,"",(function(){t()}),(function(e){n(e)}))}))]:[2]}))}))},e.prototype.copyFolder=function(e,t){return Uf(this,void 0,void 0,(function(){return kf(this,(function(n){return e&&t?[2,new Promise((function(n,r){sbutility.copyDirectory(e,t,(function(){n()}),(function(e){r(e)}))}))]:[2]}))}))},e.prototype.renameFolder=function(e,t){return Uf(this,void 0,void 0,(function(){return kf(this,(function(n){return e?[2,new Promise((function(n,r){sbutility.renameDirectory(e,t,(function(){n()}),(function(e){r(e)}))}))]:[2]}))}))},e.prototype.removeSourceAndDestination=function(e,t,n){return Uf(this,void 0,void 0,(function(){return kf(this,(function(r){switch(r.label){case 0:return[4,this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp"))];case 1:return r.sent(),[4,this.deleteFolder(t[Bf])];case 2:return r.sent(),[2]}}))}))},e}(),Vf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Yf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}};!function(e){e.SAME_VERSION_IN_BOTH="SAME_VERSION_IN_BOTH",e.HIGHER_VERSION_IN_DESTINATION="HIGHER_VERSION_IN_DESTINATION",e.LOWER_VERSION_IN_DESTINATION="LOWER_VERSION_IN_DESTINATION"}(fu||(fu={}));var Gf,Hf=function(){function e(e,t,n,r,i){this.sdkConfig=e,this.fileService=t,this.dbService=n,this.eventsBusService=r,this.deviceInfo=i,this.context={}}return e.prototype.transfer=function(e){var t=this,n=e.contentIds,r=e.existingContentAction,i=e.deleteDestination,o=e.destinationFolder,a=e.shouldMergeInDestination,c=e.sourceFolder;return this.context.hasTransferCancelled=!1,this.context.shouldMergeInDestination=a,this.context.contentIds=n,this.context.existingContentAction=r,this.context.deleteDestination=i,this.context.destinationFolder=o,this.context.sourceFolder=c,new jf(this.fileService).execute(this.context).pipe(Object(ge.mergeMap)((function(e){return(new ff).execute(e)})),Object(ge.mergeMap)((function(e){return new af(t.dbService).execute(e)})),Object(ge.mergeMap)((function(e){return new uf(t.fileService,t.sdkConfig.appConfig).execute(e)})),Object(ge.mergeMap)((function(e){return new Ef(t.dbService,t.fileService).execute(e)})),Object(ge.mergeMap)((function(e){return new Af(t.eventsBusService).execute(e)})),Object(ge.mergeMap)((function(e){return new Ff(t.eventsBusService).execute(e)})),Object(ge.mergeMap)((function(e){return new Cf(t.dbService).execute(e)})),Object(ge.mergeMap)((function(e){return new Lf(t.sdkConfig.appConfig,t.fileService,t.dbService,t.deviceInfo).execute(e)}))).pipe(Object(ge.tap)((function(){t.eventsBusService.emit({namespace:_e.STORAGE,event:{type:gs.TRANSFER_COMPLETED}})})),Object(ge.mapTo)(void 0),Object(ge.catchError)((function(e){return e instanceof vf?t.eventsBusService.emit({namespace:_e.STORAGE,event:{type:gs.TRANSFER_REVERT_COMPLETED}}):e instanceof hf?t.eventsBusService.emit({namespace:_e.STORAGE,event:{type:gs.TRANSFER_FAILED_DUPLICATE_CONTENT}}):e instanceof nf&&t.eventsBusService.emit({namespace:_e.STORAGE,event:{type:gs.TRANSFER_FAILED_LOW_MEMORY}}),console.error("Error",e),Object(ie.throwError)(e)})))},e.prototype.cancel=function(){var e=this;return Object(ie.defer)((function(){return Vf(e,void 0,void 0,(function(){return Yf(this,(function(e){return this.context.hasTransferCancelled=!0,[2]}))}))})).pipe(Object(ge.mapTo)(void 0))},e}(),qf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},zf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Kf=function(){function e(e,t){this.fileService=e,this.dbService=t}return e.prototype.execute=function(e){var t=this;return Object(ie.defer)((function(){return qf(t,void 0,void 0,(function(){var t,n,r,i,o;return zf(this,(function(a){switch(a.label){case 0:return[4,this.getContentsInDb()];case 1:return t=a.sent(),e.currentStoragePath?(n=Jr.getContentRootDir(e.currentStoragePath).concat("/"),[4,this.getFolderList(n)]):[3,5];case 2:return r=a.sent(),i=e,[4,this.getNewlyAddedContents(r,t)];case 3:return i.newlyAddedIdentifiers=a.sent(),o=e,[4,this.getDeletedContents(r,t)];case 4:return o.deletedIdentifiers=a.sent(),[3,6];case 5:e.newlyAddedIdentifiers=[],e.deletedIdentifiers=t,a.label=6;case 6:return[2]}}))}))})).pipe(Object(ge.mapTo)(e))},e.prototype.doesDestinationStorageExist=function(e){return this.fileService.exists(e).then((function(e){return!0})).catch((function(){return!1}))},e.prototype.getContentsInDb=function(){return qf(this,void 0,void 0,(function(){return zf(this,(function(e){return[2,this.dbService.execute(Jr.getFindAllContentsQuery()).pipe(Object(ge.map)((function(e){return e.filter((function(e){return"textbookunit"!==e[Wt.COLUMN_NAME_CONTENT_TYPE].toLowerCase()})).map((function(e){return e[Wt.COLUMN_NAME_IDENTIFIER]}))}))).toPromise()]}))}))},e.prototype.getNewlyAddedContents=function(e,t){return e.filter((function(e){return!Er.contains(t,e)}))},e.prototype.getDeletedContents=function(e,t){return t.filter((function(t){return!Er.contains(e,t)}))},e.prototype.getFolderList=function(e){return this.fileService.listDir(e.replace(/\/$/,"")).then((function(e){return e.map((function(e){return e.name}))})).catch((function(){return[]}))},e}(),Wf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Xf=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Jf=function(){function e(e){this.storageHandler=e}return e.prototype.exexute=function(e){var t=this;return Object(ie.defer)((function(){return Wf(t,void 0,void 0,(function(){var t,n,r;return Xf(this,(function(i){switch(i.label){case 0:return e.deletedIdentifiers.length?[4,this.storageHandler.deleteContentsFromDb(e.deletedIdentifiers)]:[3,2];case 1:i.sent(),i.label=2;case 2:if(!e.newlyAddedIdentifiers.length)return[3,6];t=0,n=e.newlyAddedIdentifiers,i.label=3;case 3:return t<n.length?(r=n[t],[4,this.storageHandler.addDestinationContentInDb(r,Jr.getContentRootDir(e.currentStoragePath).concat("/"),!1)]):[3,6];case 4:i.sent(),i.label=5;case 5:return t++,[3,3];case 6:return[2]}}))}))})).pipe(Object(ge.mapTo)(e))},e}(),Qf=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},$f=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Zf=function(){function e(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}return e.prototype.addDestinationContentInDb=function(e,t,n){return Qf(this,void 0,void 0,(function(){var r,i=this;return $f(this,(function(o){return r=t.concat(e),this.fileService.readAsText(t.concat(e),Yn.MANIFEST.valueOf()).then((function(e){var t=JSON.parse(e),o=t.archive.items;return i.extractContentFromItem(o,r.concat("/"),t.ver,n)})).catch((function(e){console.error(e)})),[2]}))}))},e.prototype.deleteContentsFromDb=function(e){return Qf(this,void 0,void 0,(function(){var t,n,r,i,o,a,c,s;return $f(this,(function(u){switch(u.label){case 0:return[4,this.dbService.execute(Jr.getFindAllContentsWithIdentifierQuery(e)).toPromise()];case 1:for(t=u.sent(),n=0,r=t;n<r.length;n++)c=r[n],(s=c)[Wt.COLUMN_NAME_MIME_TYPE]===Rn.COLLECTION&&s[Wt.COLUMN_NAME_REF_COUNT]>1?s[Wt.COLUMN_NAME_CONTENT_STATE]=Ln.ARTIFACT_AVAILABLE:s[Wt.COLUMN_NAME_CONTENT_STATE]=Ln.ONLY_SPINE,s[Wt.COLUMN_NAME_VISIBILITY]===Dn.DEFAULT&&s[Wt.COLUMN_NAME_REF_COUNT]>0&&(i=s[Wt.COLUMN_NAME_REF_COUNT],s[Wt.COLUMN_NAME_REF_COUNT]=Jr.addOrUpdateRefCount(i-1)),s[Wt.COLUMN_NAME_VISIBILITY]=Dn.PARENT;this.dbService.beginTransaction(),o=0,a=t,u.label=2;case 2:return o<a.length?(c=a[o],s=c,[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[s[Wt.COLUMN_NAME_IDENTIFIER]],modelJson:s}).toPromise()]):[3,5];case 3:u.sent(),u.label=4;case 4:return o++,[3,2];case 5:return this.dbService.endTransaction(!0),[2]}}))}))},e.prototype.extractContentFromItem=function(e,t,n,r){return Qf(this,void 0,void 0,(function(){var i,o,a,c,s,u,f,l,h,d,p,b,_,E,y,v,g,m,S,O,A,T,N,M,w,C,I,P,L;return $f(this,(function(R){switch(R.label){case 0:i=[],o=[],a=0,c=e,R.label=1;case 1:return a<c.length?(P=c[a],u=(s=P).identifier,f=s.mimeType,l=Jr.readContentType(s),h=Jr.readVisibility(s),d=Jr.readAudience(s),p=Jr.readPragma(s),b=Jr.readCompatibilityLevel(s),_=s.pkgVersion,E=Ln.ONLY_SPINE.valueOf(),y=s.board,v=s.medium,g=s.gradeLevel,[4,this.dbService.read({table:Wt.TABLE_NAME,columns:[],selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[u]}).toPromise()]):[3,5];case 2:return m=R.sent()[0],S=m&&Jr.getBasePath(m[Wt.COLUMN_NAME_PATH]),(O=Jr.doesContentExist(m,u,_,r))&&s.status!==jn.DRAFT.valueOf()?m[Wt.COLUMN_NAME_VISIBILITY]===Dn.DEFAULT.valueOf()&&(s=JSON.parse(m[Wt.COLUMN_NAME_LOCAL_DATA])):(O=!1,Jr.isCompatible(this.appConfig,b)&&(E=(Rn.COLLECTION.valueOf(),Ln.ARTIFACT_AVAILABLE.valueOf()))),A=Jr.getReferenceCount(m,h),h=Jr.getContentVisibility(m,s.objectType,h),E=Jr.getContentState(m,E),T=O?S:t,[4,this.fileService.getDirectorySize(T)];case 3:N=R.sent(),Jr.addOrUpdateViralityMetadata(s,this.deviceInfo.getDeviceID().toString()),L=Jr.constructContentDBModel(u,n,JSON.stringify(s),f,l,h,T,A,E,d,p,N,y,v,g),m?o.push(L):i.push(L),R.label=4;case 4:return a++,[3,1];case 5:if(!i.length&&!o.length)return[3,14];this.dbService.beginTransaction(),M=0,w=i,R.label=6;case 6:return M<w.length?(P=w[M],L=P,[4,this.dbService.insert({table:Wt.TABLE_NAME,modelJson:L}).toPromise()]):[3,9];case 7:R.sent(),R.label=8;case 8:return M++,[3,6];case 9:C=0,I=o,R.label=10;case 10:return C<I.length?(P=I[C],L=P,[4,this.dbService.update({table:Wt.TABLE_NAME,selection:Wt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[L[Wt.COLUMN_NAME_IDENTIFIER]],modelJson:L}).toPromise()]):[3,13];case 11:R.sent(),R.label=12;case 12:return C++,[3,10];case 13:this.dbService.endTransaction(!0),R.label=14;case 14:return[2]}}))}))},e}(),el=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},tl=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},nl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},rl=function(e,t){return function(n,r){t(n,r,e)}},il=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},ol=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},al=function(){function e(e,t,n,r,i,o){this.eventsBusService=e,this.sharedPreferences=t,this.dbService=n,this.deviceInfo=r,this.fileService=i,this.sdkConfig=o,this.contentsToTransfer=new Ic(this.sharedPreferences,Q.KEY_TO_TRANSFER_LIST,(function(e){return e})),this.transferContentHandler=new Hf(this.sdkConfig,this.fileService,this.dbService,this.eventsBusService,this.deviceInfo)}var t;return t=e,e.prototype.onInit=function(){var e=this;return Object(ie.zip)(this.deviceInfo.getStorageVolumes(),this.getStorageDestination()).pipe(Object(ge.tap)((function(t){e.availableStorageVolumes=t[0],e.currentStorageDestination=t[1],e.scanStorage().toPromise()})),Object(ge.mapTo)(void 0))},e.prototype.getStorageDestinationDirectoryPath=function(){var e=this,t=this.availableStorageVolumes.find((function(t){return t.storageDestination===e.currentStorageDestination}));return t&&t.info.contentStoragePath},e.prototype.cancelTransfer=function(){return this.transferContentHandler.cancel()},e.prototype.getStorageDestination=function(){return this.sharedPreferences.getString(t.STORAGE_DESTINATION).pipe(Object(ge.map)((function(e){return e||vs.INTERNAL_STORAGE})))},e.prototype.getStorageDestinationVolumeInfo=function(){var e=this;return this.getStorageDestination().pipe(Object(ge.map)((function(t){return e.availableStorageVolumes.find((function(e){return e.storageDestination===t}))})))},e.prototype.getToTransferContents=function(){return Object(ie.of)([])},e.prototype.getTransferringContent=function(){return Object(ie.of)(void 0)},e.prototype.retryCurrentTransfer=function(){return this.lastTransferContentsRequest?this.transferContents(el({},this.lastTransferContentsRequest,{shouldMergeInDestination:!0})):Object(ie.of)(void 0)},e.prototype.transferContents=function(e){var n=this;return this.lastTransferContentsRequest=e,e.sourceFolder=this.getStorageDestinationDirectoryPath(),this.transferContentHandler.transfer(e).pipe(Object(ge.mergeMap)((function(){return n.getStorageDestination()})),Object(ge.map)((function(e){return e===vs.EXTERNAL_STORAGE?vs.INTERNAL_STORAGE:vs.EXTERNAL_STORAGE})),Object(ge.tap)((function(e){n.currentStorageDestination=e})),Object(ge.mergeMap)((function(e){return n.sharedPreferences.putString(t.STORAGE_DESTINATION,e)})))},e.prototype.scanStorage=function(){var e=this,t=this.getStorageDestinationDirectoryPath(),n={currentStoragePath:t};return t||this.resetStorageDestination(),new Kf(this.fileService,this.dbService).execute(n).pipe(Object(ge.mergeMap)((function(t){var n=new Zf(e.sdkConfig.appConfig,e.fileService,e.dbService,e.deviceInfo);return new Jf(n).exexute(t)})),Object(ge.mapTo)(!0))},e.prototype.resetStorageDestination=function(){return il(this,void 0,void 0,(function(){return ol(this,(function(e){return this.currentStorageDestination=vs.INTERNAL_STORAGE,[2,this.sharedPreferences.putString(t.STORAGE_DESTINATION,vs.INTERNAL_STORAGE).toPromise()]}))}))},e.STORAGE_DESTINATION=Q.KEY_STORAGE_DESTINATION,e=t=tl([Object(I.injectable)(),rl(0,Object(I.inject)(be.EVENTS_BUS_SERVICE)),rl(1,Object(I.inject)(be.SHARED_PREFERENCES)),rl(2,Object(I.inject)(be.DB_SERVICE)),rl(3,Object(I.inject)(be.DEVICE_INFO)),rl(4,Object(I.inject)(be.FILE_SERVICE)),rl(5,Object(I.inject)(be.SDK_CONFIG)),nl("design:paramtypes",[Object,Object,C,Object,Object,Object])],e)}();!function(e){e.READ="read",e.UNREAD="unread",e.ALL="all"}(Gf||(Gf={}));var cl,sl=function(){function e(){}return e.constructNotificationDBModel=function(e){return{message_id:e.id,expiry_time:e.expiry,display_time:e.displayTime,received_at:Date.now(),notification_json:JSON.stringify(e),is_read:e.isRead}},e.getFilterForNotification=function(e){switch(e.notificationStatus){case Gf.ALL:nn.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+" <= ?\n AND "+nn.COLUMN_NAME_EXPIRY_TIME+" > ?",[Date.now().toString(),Date.now().toString()];break;case Gf.UNREAD:nn.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+" <= ?\n AND "+nn.COLUMN_NAME_EXPIRY_TIME+" > ? AND\n AND "+nn.COLUMN_NAME_IS_READ+" > ?",[Date.now().toString(),Date.now().toString(),0];break;case Gf.READ:default:nn.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+" <= ?\n AND "+nn.COLUMN_NAME_EXPIRY_TIME+" > ?\n AND "+nn.COLUMN_NAME_IS_READ+" > ?",[Date.now().toString(),Date.now().toString(),1]}return{table:nn.TABLE_NAME,orderBy:nn.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+" desc"}},e}(),ul=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},fl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ll=function(e,t){return function(n,r){t(n,r,e)}},hl=nn.COLUMN_NAME_NOTIFICATION_JSON,dl=function(){function e(e,t){this.dbService=e,this.sharedPreferences=t}return e.prototype.addNotification=function(e){var t=this;return e.actionData&&"codePush"===e.actionData.actionType&&e.actionData.deploymentKey&&this.sharedPreferences.putString(Z.DEPLOYMENT_KEY,e.actionData.deploymentKey),this.dbService.read({table:nn.TABLE_NAME,selection:nn.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(ge.mergeMap)((function(n){return n&&n.length?t.dbService.update({table:nn.TABLE_NAME,selection:nn.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:sl.constructNotificationDBModel(e)}).pipe(Object(ge.mapTo)(!0)):t.dbService.insert({table:nn.TABLE_NAME,modelJson:sl.constructNotificationDBModel(e)}).pipe(Object(ge.mapTo)(!0))})))},e.prototype.deleteNotification=function(e){var t=("DELETE FROM "+nn.TABLE_NAME+" ").concat(e?"WHERE "+nn.COLUMN_NAME_MESSAGE_ID+" = "+e:"");return this.dbService.execute(t).pipe(Object(ge.mapTo)(!0))},e.prototype.getAllNotifications=function(e){return this.dbService.read(sl.getFilterForNotification(e)).pipe(Object(ge.map)((function(e){return e.map((function(e){var t=JSON.parse(e[hl]);return t.isRead=e[nn.COLUMN_NAME_IS_READ],t}))})))},e.prototype.updateNotification=function(e){var t=this;return this.dbService.read({table:nn.TABLE_NAME,selection:nn.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(ge.mergeMap)((function(n){return n&&n.length?t.dbService.update({table:nn.TABLE_NAME,selection:nn.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:sl.constructNotificationDBModel(e)}).pipe(Object(ge.mapTo)(!0)):Object(ie.of)(!1)})))},e=ul([Object(I.injectable)(),ll(0,Object(I.inject)(be.DB_SERVICE)),ll(1,Object(I.inject)(be.SHARED_PREFERENCES)),fl("design:paramtypes",[C,Object])],e)}();!function(e){e.CUSTODIAN_ORG_ID="custodianOrgId",e.COURSE_FRAMEWORK_ID="courseFrameworkId",e.ERROR_LOG_SYNC_SETTINGS="errorLogSyncSettings"}(cl||(cl={}));var pl,bl=function(){function e(){}return e.mapErrorSatckDBEntryToErrorStack=function(e){return{appver:e[cn.COLUMN_NAME_APP_VERSION],pageid:e[cn.COLUMN_NAME_PAGE_ID],ts:e[cn.COLUMN_NAME_TIME_STAMP],log:e[cn.COLUMN_NAME_ERROR_LOG]}},e.mapErrorStackToErrorStackDBEntry=function(e){var t;return(t={})[cn.COLUMN_NAME_APP_VERSION]=e.appver,t[cn.COLUMN_NAME_PAGE_ID]=e.pageid,t[cn.COLUMN_NAME_TIME_STAMP]=e.ts,t[cn.COLUMN_NAME_ERROR_LOG]=e.log,t},e}(),_l=cn._ID,El=function(){function e(e,t,n,r,i){this.apiService=e,this.dbService=t,this.errorLoggerConfig=n,this.networkInfoService=r,this.errorStackSyncRequestDecorator=i}return e.prototype.handle=function(e){var t=this;return this.processBatch(e).pipe(Object(ge.expand)((function(n){return n>0?t.processBatch(e):ie.EMPTY})),Object(ge.mapTo)(void 0),Object(ge.catchError)((function(){return Object(ie.of)(void 0)})))},e.prototype.processBatch=function(e){var t=this;return this.getErrorStackBatch(e).pipe(Object(ge.mergeMap)((function(e){return t.sync(e)})),Object(ge.mergeMap)((function(e){return t.clearLogs(e)})),Object(ge.map)((function(e){return e.length})))},e.prototype.getErrorStackBatch=function(e){return this.dbService.execute("\n SELECT * FROM "+cn.TABLE_NAME+"\n LIMIT "+e+"\n ")},e.prototype.clearLogs=function(e){return e.length?this.dbService.execute("\n DELETE FROM "+cn.TABLE_NAME+"\n WHERE "+cn._ID+" IN ("+e.map((function(e){return e[_l]})).join(",")+")\n ").pipe(Object(ge.mapTo)(e)):Object(ie.of)(e)},e.prototype.sync=function(e){var t=this;return e.length?this.networkInfoService.networkStatus$.pipe(Object(ge.mergeMap)((function(n){if(n===vr.OFFLINE)return Object(ie.throwError)(new Error("Fake Error"));var r={pdata:void 0,context:void 0,logs:e.map((function(e){return bl.mapErrorSatckDBEntryToErrorStack(e)}))};return t.errorStackSyncRequestDecorator.decorate(r).pipe(Object(ge.mergeMap)((function(){var e=(new F.Builder).withType(R.POST).withPath(t.errorLoggerConfig.errorLoggerApiPath).withApiToken(!0).withBody({request:r}).build();return t.apiService.fetch(e)})))})),Object(ge.mapTo)(e)):Object(ie.of)(e)},e}(),yl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},vl=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},gl=function(){function e(e,t,n){this.apiConfig=e,this.deviceInfo=t,this.appInfo=n}return e.prototype.decorate=function(e){var t=this;return Object(ie.defer)((function(){return yl(t,void 0,void 0,(function(){return vl(this,(function(t){switch(t.label){case 0:return this.patchPData(e),[4,this.patchContext(e)];case 1:return t.sent(),[2,e]}}))}))}))},e.prototype.patchContext=function(e){return yl(this,void 0,void 0,(function(){var t,n;return vl(this,(function(r){switch(r.label){case 0:return t=e,n={did:this.deviceInfo.getDeviceID()},[4,this.deviceInfo.getDeviceSpec().toPromise()];case 1:return t.context=(n.spec=r.sent(),n),[2]}}))}))},e.prototype.patchPData=function(e){e.pdata=new _t,e.pdata.id=this.apiConfig.api_authentication.producerId;var t=e.pdata.pid;t?e.pdata.pid=t:this.apiConfig.api_authentication.producerUniqueId?e.pdata.pid=this.apiConfig.api_authentication.producerUniqueId:e.pdata.pid="sunbird.android",e.pdata.ver||(e.pdata.ver=this.appInfo.getVersionName())},e}(),ml=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Sl=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Ol=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Al=function(e,t){return function(n,r){t(n,r,e)}},Tl=function(){function e(e,t,n,r,i,o,a,c){this.systemSettingsService=e,this.dbService=t,this.appInfo=n,this.apiService=r,this.sdkConfig=i,this.errorLoggerService=o,this.deviceInfo=a,this.sharedPreferences=c,this.errorLoggerConfig=this.sdkConfig.errorLoggerConfig,this.errorStackSyncRequestDecorator=new gl(this.sdkConfig.apiConfig,this.deviceInfo,this.appInfo),this.errorStackSyncHandler=new El(this.apiService,this.dbService,this.errorLoggerConfig,this.errorLoggerService,this.errorStackSyncRequestDecorator)}var t;return t=e,e.prototype.onInit=function(){var e=this;return this.sharedPreferences.getString($.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(ge.mergeMap)((function(t){return t?Object(ie.of)(void 0):e.sharedPreferences.putString($.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+"")})))},e.prototype.logError=function(e){var t=this,n={appver:this.appInfo.getVersionName(),pageid:e.pageId,ts:Date.now(),log:e.stacktrace};return this.dbService.insert({table:cn.TABLE_NAME,modelJson:bl.mapErrorStackToErrorStackDBEntry(n)}).pipe(Object(ge.mergeMap)((function(){return t.getErrorCount()})),Object(ge.mergeMap)((function(e){return t.getErrorLogSyncSettings().pipe(Object(ge.map)((function(t){return ml({},t,{errorCount:e})})))})),Object(ge.map)((function(e){return{errorCount:e.errorCount,errorLogSyncFrequency:e.frequency,errorLogSyncBandwidth:e.bandwidth}})),Object(ge.mergeMap)((function(e){var n=e.errorCount,r=e.errorLogSyncFrequency,i=e.errorLogSyncBandwidth;return t.hasErrorLogSyncFrequencyCrossed(n,r).pipe(Object(ge.map)((function(e){return{shouldSync:e,errorLogSyncBandwidth:i}})))})),Object(ge.mergeMap)((function(e){var n=e.shouldSync,r=e.errorLogSyncBandwidth;return n?t.errorStackSyncHandler.handle(r).pipe(Object(ge.mergeMap)((function(){return t.sharedPreferences.putString($.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+"")}))):Object(ie.of)(void 0)})))},e.prototype.hasErrorLogSyncFrequencyCrossed=function(e,t){return this.sharedPreferences.getString($.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(ge.map)((function(e){return parseInt(e,10)})),Object(ge.map)((function(e){return e+t<Date.now()})))},e.prototype.getErrorCount=function(){return this.dbService.execute("SELECT COUNT(*) as count FROM "+cn.TABLE_NAME).pipe(Object(ge.map)((function(e){return e[0].count})))},e.prototype.getErrorLogSyncSettings=function(){var e={id:t.ERROR_LOG_SYNC_SETTINGS};return this.systemSettingsService.getSystemSettings(e).pipe(Object(ge.map)((function(e){return JSON.parse(e.value)})))},e.ERROR_LOG_SYNC_SETTINGS=cl.ERROR_LOG_SYNC_SETTINGS,e=t=Sl([Object(I.injectable)(),Al(0,Object(I.inject)(be.SYSTEM_SETTINGS_SERVICE)),Al(1,Object(I.inject)(be.DB_SERVICE)),Al(2,Object(I.inject)(be.APP_INFO)),Al(3,Object(I.inject)(be.API_SERVICE)),Al(4,Object(I.inject)(be.SDK_CONFIG)),Al(5,Object(I.inject)(be.NETWORKINFO_SERVICE)),Al(6,Object(I.inject)(be.DEVICE_INFO)),Al(7,Object(I.inject)(be.SHARED_PREFERENCES)),Ol("design:paramtypes",[Object,C,Object,Object,Object,Object,Object,Object])],e)}(),Nl=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Ml=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},wl=function(){function e(){var e=this;navigator.connection.type===Connection.NONE?this.networkStatusSource=new ie.BehaviorSubject(vr.OFFLINE):this.networkStatusSource=new ie.BehaviorSubject(vr.ONLINE),window.addEventListener("online",(function(){e.networkStatusSource.next(vr.ONLINE)}),!1),window.addEventListener("offline",(function(){e.networkStatusSource.next(vr.OFFLINE)}),!1),this.networkStatus$=this.networkStatusSource.asObservable()}return e=Nl([Object(I.injectable)(),Ml("design:paramtypes",[])],e)}(),Cl=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Il=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Pl=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ll=function(e){function t(){return e.call(this,8,23)||this}return Cl(t,e),t.prototype.apply=function(e){return Il(this,void 0,void 0,(function(){var t=this;return Pl(this,(function(n){return this.queries().forEach((function(n){return Il(t,void 0,void 0,(function(){return Pl(this,(function(t){switch(t.label){case 0:return[4,e.execute(n).toPromise()];case 1:return t.sent(),[2]}}))}))})),[2,void 0]}))}))},t.prototype.queries=function(){return[un.getCreateEntry()]},t}(w),Rl=un.COLUMN_NAME_USER_ID,Dl=un.COLUMN_NAME_QUERY,jl=un.COLUMN_NAME_TIME_STAMP,Ul=function(){function e(){}return e.mapSearchHistoryDbEntryToSearchEntry=function(e){return{uid:e[Rl],query:e[Dl],timestamp:e[jl]}},e}(),kl=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},xl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Bl=function(e,t){return function(n,r){t(n,r,e)}},Fl=function(){function e(e,t){this.dbService=e,this.profileService=t}var t;return t=e,e.prototype.addEntry=function(e){var n=this,r=e.query,i=e.namespace;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(e){var t,o=e.uid;return n.dbService.insert({table:un.TABLE_NAME,modelJson:(t={},t[un.COLUMN_NAME_QUERY]=r.trim(),t[un.COLUMN_NAME_NAMESPACE]=i,t[un.COLUMN_NAME_USER_ID]=o,t[un.COLUMN_NAME_TIME_STAMP]=Date.now(),t)}).pipe(Object(ge.mapTo)(o))})),Object(ge.mergeMap)((function(e){return n.dbService.execute("\n DELETE FROM "+un.TABLE_NAME+" WHERE\n "+un._ID+" IN (SELECT "+un._ID+" FROM "+un.TABLE_NAME+" WHERE\n "+un.COLUMN_NAME_USER_ID+' = "'+e+'" AND\n '+un.COLUMN_NAME_NAMESPACE+' = "'+i+'"\n ORDER BY '+un.COLUMN_NAME_TIME_STAMP+" DESC\n LIMIT -1 OFFSET "+t.MAX_USER_SEARCH_HISTORY_ENTRIES+")\n ")})),Object(ge.mapTo)(void 0))},e.prototype.getEntries=function(e){var t=this,n=e.like,r=e.limit,i=e.namespace;return this.profileService.getActiveProfileSession().pipe(Object(ge.mergeMap)((function(e){var o=e.uid,a="";return n&&(a="AND "+un.COLUMN_NAME_QUERY+' LIKE "%'+n.trim()+'%"'),t.dbService.execute("\n SELECT * FROM "+un.TABLE_NAME+" WHERE\n "+un.COLUMN_NAME_USER_ID+' = "'+o+'" AND\n '+un.COLUMN_NAME_NAMESPACE+' = "'+i+'"\n '+a+"\n ORDER BY "+un.COLUMN_NAME_TIME_STAMP+" DESC\n LIMIT "+r+"\n ")})),Object(ge.map)((function(e){return e.map((function(e){return Ul.mapSearchHistoryDbEntryToSearchEntry(e)}))})))},e.MAX_USER_SEARCH_HISTORY_ENTRIES=10,e=t=kl([Object(I.injectable)(),Bl(0,Object(I.inject)(be.DB_SERVICE)),Bl(1,Object(I.inject)(be.PROFILE_SERVICE)),xl("design:paramtypes",[C,Object])],e)}(),Vl=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Yl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Gl=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Hl=function(e){function t(){return e.call(this,9,24)||this}return Vl(t,e),t.prototype.apply=function(e){return Yl(this,void 0,void 0,(function(){var t=this;return Gl(this,(function(n){switch(n.label){case 0:return[4,Promise.all(this.queries().map((function(t){return e.execute(t).toPromise()})))];case 1:return n.sent(),[4,e.read({table:en.TABLE_NAME}).pipe(Object(ge.map)((function(n){n.forEach((function(n){return Yl(t,void 0,void 0,(function(){var t,r;return Gl(this,(function(i){switch(i.label){case 0:return(t=n[en.COLUMN_NAME_DATA])?(r=JSON.parse(t),n[Wt.COLUMN_NAME_MIME_TYPE]=r.mimeType,[4,e.update({table:en.TABLE_NAME,modelJson:n,selection:en.COLUMN_NAME_CONTENT_IDENTIFIER+" = ?",selectionArgs:[n[en.COLUMN_NAME_CONTENT_IDENTIFIER]]}).toPromise()]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))}))}))).toPromise()];case 2:return n.sent(),[2,void 0]}}))}))},t.prototype.queries=function(){return[en.getAlterEntryForMimeType()]},t}(w),ql=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Kl=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Wl=function(e){function t(){return e.call(this,10,25)||this}return ql(t,e),t.prototype.apply=function(e){return zl(this,void 0,void 0,(function(){var t,n,r;return Kl(this,(function(i){switch(i.label){case 0:t=0,n=this.queries(),i.label=1;case 1:return t<n.length?(r=n[t],[4,e.execute(r).toPromise()]):[3,4];case 2:i.sent(),i.label=3;case 3:return t++,[3,1];case 4:return[2,void 0]}}))}))},t.prototype.queries=function(){return[ln.getCreateEntry()]},t}(w),Xl=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Jl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ql=function(e,t){return function(n,r){t(n,r,e)}},$l=function(){function e(e){this.sharedPreferences=e}return e.prototype.setDefaultDeploymentKey=function(e){return this.sharedPreferences.putString(ee.DEFAULT_DEPLOYMENT_KEY,e)},e.prototype.getDefaultDeploymentKey=function(){return this.sharedPreferences.getString(ee.DEFAULT_DEPLOYMENT_KEY)},e.prototype.setExperimentKey=function(e){var t=this;return this.sharedPreferences.putString(ee.EXPERIMENT_KEY,e).pipe(Object(ge.tap)((function(){t.experimentKey||(t.experimentKey=e)})))},e.prototype.getExperimentKey=function(){var e=this;return this.experimentKey?this.experimentKey:this.sharedPreferences.getString(ee.EXPERIMENT_KEY).pipe(Object(ge.tap)((function(t){return e.experimentKey=t,t})))},e.prototype.setExperimentAppVersion=function(e){return this.sharedPreferences.putString(ee.EXPERIMENT_APP_VERSION,e)},e.prototype.getExperimentAppVersion=function(){return this.sharedPreferences.getString(ee.EXPERIMENT_APP_VERSION)},e=Xl([Object(I.injectable)(),Ql(0,Object(I.inject)(be.SHARED_PREFERENCES)),Jl("design:paramtypes",[Object])],e)}(),Zl=function(){function e(e,t,n,r){this.apiService=e,this.faqServiceConfig=t,this.fileservice=n,this.cachedItemStore=r,this.FAQ_FILE_KEY_PREFIX="faq-",this.FAQ_LOCAL_KEY="faq-"}return e.prototype.handle=function(e){var t=this;return this.cachedItemStore.getCached(e.language,this.FAQ_LOCAL_KEY,"ttl_"+this.FAQ_LOCAL_KEY,(function(){return t.fetchFromServer(e)}),(function(){return t.fetchFromFile(e.language)}))},e.prototype.fetchFromServer=function(e){var t=(new F.Builder).withType(R.GET).withHost(e.faqUrl).withPath("/faq-"+e.language+".json").withApiToken(!1).build();return this.apiService.fetch(t).pipe(Object(ge.map)((function(e){var t;try{t=JSON.parse(e.body.trim())}catch(n){t=e.body}return t})))},e.prototype.fetchFromFile=function(e){var t=Wr.ASSETS_PATH+this.faqServiceConfig.faqConfigDirPath,n=this.FAQ_FILE_KEY_PREFIX+e+".json";return Object(ie.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(ge.map)((function(e){return JSON.parse(e)})))},e}(),eh=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},th=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},nh=function(e,t){return function(n,r){t(n,r,e)}},rh=function(){function e(e,t,n,r){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r}return e.prototype.getFaqDetails=function(e){return new Zl(this.apiService,this.sdkConfig.faqServiceConfig,this.fileService,this.cachedItemStore).handle(e)},e=eh([Object(I.injectable)(),nh(0,Object(I.inject)(be.SDK_CONFIG)),nh(1,Object(I.inject)(be.FILE_SERVICE)),nh(2,Object(I.inject)(be.API_SERVICE)),nh(3,Object(I.inject)(be.CACHED_ITEM_STORE)),th("design:paramtypes",[Object,Object,Object,Object])],e)}();!function(e){e.CONTENT="content",e.PROFILE="profile",e.TELEMETRY="telemetry"}(pl||(pl={}));var ih,oh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ah=function(e){function t(n,r){var i=e.call(this,n,"ASSERTION_ERROR_"+r)||this;return Object.setPrototypeOf(i,t.prototype),i}return oh(t,e),t}(U),ch=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),sh=function(e){function t(n){var r=e.call(this,n,"INVALID_REQUEST")||this;return Object.setPrototypeOf(r,t.prototype),r}return ch(t,e),t}(ah),uh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fh=function(e){function t(n){var r=e.call(this,n,"OBJECT_NOT_FOUND")||this;return Object.setPrototypeOf(r,t.prototype),r}return uh(t,e),t}(ah),lh=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},hh=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},dh=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ph=function(){function e(e,t){this.dbService=e,this.fileService=t}return e.prototype.export=function(e,t){var n=this;return new ie.Observable((function(e){hh(n,void 0,void 0,(function(){var n,r,i,o,a;return dh(this,(function(c){switch(c.label){case 0:n={task:"",completed:[]},e.next(n=lh({},n,{task:"VALIDATING"})),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.validate()];case 2:return c.sent(),[3,4];case 3:return r=c.sent(),e.error(r),[2];case 4:return e.next(n=lh({},n,{task:"PREPARING"})),[4,this.prepare(t)];case 5:return c.sent(),e.next(n=lh({},n,{task:"INITIALIZING"})),[4,this.createWorkspace()];case 6:return c.sent(),[4,this.getMessageIds()];case 7:i=c.sent(),c.label=8;case 8:c.trys.push([8,12,,13]),c.label=9;case 9:return i.length?(o=i.pop(),[4,this.processBatch(o).then((function(t){if(t){var r=t.file,i=t.mid,o=t.eventsCount,a=t.size;e.next(n=lh({},n,{task:"BUILDING_BATCH",completed:n.completed.concat([{file:r,mid:i,eventsCount:o,size:a,objectType:pl.TELEMETRY,contentEncoding:"gzip",explodedSize:-1}])}))}else e.next(n=lh({},n,{task:"SKIPPING_BATCH"}))}))]):[3,11];case 10:return c.sent(),[3,9];case 11:return[3,13];case 12:return a=c.sent(),e.error(a),[2];case 13:return e.next(n=lh({},n,{task:"OBJECT_ARCHIVE_COMPLETE"})),e.complete(),[2]}}))}))}))},e.prototype.validate=function(){return hh(this,void 0,void 0,(function(){return dh(this,(function(e){switch(e.label){case 0:return[4,this.dbService.execute(("\n SELECT count(*) as COUNT FROM "+St.TABLE_NAME+"\n ").trim()).pipe(Object(ge.map)((function(e){return e&&e[0]&&e[0].COUNT}))).toPromise()];case 1:if(!e.sent())throw new fh("No telemetry to export");return[2]}}))}))},e.prototype.prepare=function(e){return hh(this,void 0,void 0,(function(){return dh(this,(function(t){return this.workspaceSubPath=""+e.workspacePath,[2]}))}))},e.prototype.createWorkspace=function(){return hh(this,void 0,void 0,(function(){return dh(this,(function(e){return[2,this.fileService.createDir(this.workspaceSubPath,!1)]}))}))},e.prototype.getMessageIds=function(){return hh(this,void 0,void 0,(function(){return dh(this,(function(e){switch(e.label){case 0:return[4,this.dbService.read({table:St.TABLE_NAME,columns:[St.COLUMN_NAME_MSG_ID],distinct:!0}).toPromise()];case 1:return[2,e.sent().map((function(e){return e[St.COLUMN_NAME_MSG_ID]}))]}}))}))},e.prototype.processBatch=function(e){return hh(this,void 0,void 0,(function(){var t;return dh(this,(function(n){switch(n.label){case 0:return[4,this.dbService.read({table:St.TABLE_NAME,selection:St.COLUMN_NAME_MSG_ID+" = ?",selectionArgs:[e]}).toPromise()];case 1:return(t=n.sent()[0])?[4,this.fileService.writeFile(this.workspaceSubPath,t[St.COLUMN_NAME_MSG_ID],t[St.COLUMN_NAME_DATA],{replace:!0})]:[2];case 2:return n.sent(),[2,{size:[St.COLUMN_NAME_DATA].length,eventsCount:t[St.COLUMN_NAME_NUMBER_OF_EVENTS],mid:t[St.COLUMN_NAME_MSG_ID],file:""+t[St.COLUMN_NAME_MSG_ID]}]}}))}))},e}(),bh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_h=function(e){function t(n,r){var i=e.call(this,n,"ASSERTION_ERROR_"+r)||this;return Object.setPrototypeOf(i,t.prototype),i}return bh(t,e),t}(U),Eh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),yh=function(e){function t(n){var r=e.call(this,n,"UNKNOWN_OBJECT_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return Eh(t,e),t}(_h),vh=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},gh=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},mh=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Sh=function(){function e(e,t){this.dbService=e,this.fileService=t}return e.prototype.import=function(e,t){var n=this;return new ie.Observable((function(e){gh(n,void 0,void 0,(function(){var n,r,i,o;return mh(this,(function(a){switch(a.label){case 0:return n={task:"",pending:[]},r=t.items,e.next({task:"PREPARING",pending:r.slice()}),[4,this.prepare(t)];case 1:a.sent(),a.label=2;case 2:a.trys.push([2,6,,7]),a.label=3;case 3:return r.length?"gzip"!==(i=r.pop()).contentEncoding?(e.error(new yh("Unknown content encoding "+i.contentEncoding)),[2]):[4,this.processBatch(i).then((function(){e.next(n=vh({},n,{task:"IMPORTING_BATCH",pending:r.slice()}))}))]:[3,5];case 4:return a.sent(),[3,3];case 5:return[3,7];case 6:return o=a.sent(),e.error(o),[2];case 7:return e.next(n=vh({},n,{task:"OBJECT_IMPORT_COMPLETE"})),e.complete(),[2]}}))}))}))},e.prototype.prepare=function(e){return gh(this,void 0,void 0,(function(){return mh(this,(function(t){return this.workspaceSubPath=""+e.workspacePath,[2]}))}))},e.prototype.processBatch=function(e){return gh(this,void 0,void 0,(function(){var t=this;return mh(this,(function(n){return[2,this.fileService.readAsBinaryString(this.workspaceSubPath,e.file).then((function(n){var r;t.dbService.insert({table:St.TABLE_NAME,modelJson:(r={},r[St.COLUMN_NAME_MSG_ID]=e.mid,r[St.COLUMN_NAME_NUMBER_OF_EVENTS]=e.eventsCount,r[gt.COLUMN_NAME_PRIORITY]=1,r[St.COLUMN_NAME_DATA]=n,r)}).toPromise()}))]}))}))},e}(),Oh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ah=function(e){function t(n){var r=e.call(this,n,"INVALID_ARCHIVE")||this;return Object.setPrototypeOf(r,t.prototype),r}return Oh(t,e),t}(_h),Th=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Nh=function(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},Mh=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},wh=function(e,t){return function(n,r){t(n,r,e)}},Ch=function(){function e(e,t,n,r,i){this.fileService=e,this.dbService=t,this.telemetryService=n,this.zipService=r,this.deviceInfo=i}var t;return t=e,e.reduceObjectProgressToArchiveObjectExportProgress=function(e){return e.reduce((function(e,t){var n=t.type,r=t.progress;return e.set(n,r),e}),new Map)},e.reduceObjectProgressToArchiveObjectImportProgress=function(e){return e.reduce((function(e,t){var n=t.type,r=t.progress;return e.set(n,r),e}),new Map)},e.prototype.export=function(e){var n,r=this,i=""+cordova.file.externalCacheDirectory+nr.generateUniqueId();return e.objects.length?Object(ie.concat)(Object(ie.defer)((function(){return Object(ie.from)(r.fileService.createDir(i,!1))})).pipe(Object(ge.concatMap)((function(){return Object(ie.combineLatest)(e.objects.map((function(t){switch(t.type){case pl.CONTENT:case pl.PROFILE:throw new Error("To be implemented");case pl.TELEMETRY:return new ph(r.dbService,r.fileService).export({filePath:e.filePath},{workspacePath:i}).pipe(Object(ge.map)((function(e){return{type:pl.TELEMETRY,progress:e}})))}})))})),Object(ge.map)((function(e){return{task:"BUILDING",progress:t.reduceObjectProgressToArchiveObjectExportProgress(e)}})),Object(ge.tap)((function(e){return n=e}))),Object(ie.defer)((function(){return r.generateManifestFile(n,i)})),Object(ie.defer)((function(){return r.generateZipArchive(n,i)})),Object(ie.defer)((function(){return r.generateExportTelemetries(n,i)}))):Object(ie.throwError)(new sh("No archive objects to export"))},e.prototype.generateExportTelemetries=function(e,t){var n=this;return e.progress.forEach((function(e,t){switch(t){case pl.CONTENT:case pl.PROFILE:throw new Error("To be implemented");case pl.TELEMETRY:var r={dir:we.OUT,type:Ce.FILE,items:[],env:"sdk"};n.telemetryService.share(r).toPromise()}})),Object(ie.of)(Th({},e))},e.prototype.generateZipArchive=function(e,t){var n=this,r=cordova.file.externalCacheDirectory+"archive-"+(new Date).toISOString()+".zip";return new ie.Observable((function(e){n.zipService.zip(t,{target:r},[],[],(function(){e.next(),e.complete()}),(function(t){e.error(t)}))})).pipe(Object(ge.mapTo)(Th({},e,{task:"COMPLETE",filePath:r})))},e.prototype.generateManifestFile=function(e,n){var r=this,i=e.progress;return this.telemetryService.buildContext().pipe(Object(ge.map)((function(e){return e.pdata})),Object(ge.concatMap)((function(e){var o=Array.from(i.entries()).reduce((function(e,t){t[0];var n=t[1];return e.concat(n.completed)}),[]);return Object(ie.from)(r.fileService.writeFile(n,"manifest.json",JSON.stringify({id:t.ARCHIVE_ID,ver:t.ARCHIVE_VERSION,ts:(new Date).toISOString(),producer:e,archive:{count:o.length,items:o}}),{replace:!0}))})),Object(ge.mapTo)({progress:i,task:"BUILDING_MANIFEST"}))},e.prototype.import=function(e){var n=this,r=""+cordova.file.externalCacheDirectory+nr.generateUniqueId();if(!e.objects.length)return Object(ie.throwError)(new sh("No archive objects to export"));var i={task:"",progress:new Map,filePath:e.filePath};return Object(ie.concat)(Object(ie.defer)((function(){return Object(ie.from)(n.fileService.createDir(r,!1))})).pipe(Object(ge.concatMap)((function(){return n.extractZipArchive(i,r)}))),Object(ie.defer)((function(){return n.readManifestFile(i,r,e.objects.map((function(e){return e.type})))})),Object(ie.defer)((function(){return n.generateImportTelemetries(i,r)})),Object(ie.defer)((function(){return Object(ie.combineLatest)(e.objects.map((function(t){switch(t.type){case pl.CONTENT:case pl.PROFILE:throw new Error("To be implemented");case pl.TELEMETRY:return new Sh(n.dbService,n.fileService).import({filePath:e.filePath},{workspacePath:r,items:i.progress.get(pl.TELEMETRY).pending}).pipe(Object(ge.map)((function(e){return{type:pl.TELEMETRY,progress:e}})))}}))).pipe(Object(ge.map)((function(e){return{task:"IMPORTING",progress:t.reduceObjectProgressToArchiveObjectImportProgress(e)}})))})),Object(ie.of)(Th({},i,{task:"COMPLETE"}))).pipe(Object(ge.tap)((function(e){return i=e})))},e.prototype.generateImportTelemetries=function(e,t){var n=this;return e.progress.forEach((function(e,t){switch(t){case pl.CONTENT:case pl.PROFILE:throw new Error("To be implemented");case pl.TELEMETRY:var r={dir:we.IN,type:Ce.FILE.valueOf(),items:[],env:"sdk"};n.telemetryService.share(r).toPromise()}})),Object(ie.of)(Th({},e))},e.prototype.extractZipArchive=function(e,t){var n=this,r=e.filePath;return new ie.Observable((function(e){sbutility.copyFile(Xi.getDirecory(r),t+"/",Xi.getFileName(r),(function(){n.zipService.unzip(t+"/"+Xi.getFileName(r),{target:t+"/"},(function(){e.next(),e.complete()}),(function(t){return e.error(t)}))}),(function(t){console.error(t),e.error(t)}))})).pipe(Object(ge.mapTo)(Th({},e,{task:"EXTRACTING"})))},e.prototype.readManifestFile=function(e,t,n){return Object(ie.from)(this.fileService.readAsText(t,"manifest.json")).pipe(Object(ge.map)((function(e){try{return JSON.parse(e)}catch(e){throw new Ah("Invalid manfiest.json")}})),Object(ge.map)((function(t){return Th({},e,{progress:(n.forEach((function(n){var r=t.archive.items.filter((function(e){return e.objectType===n}));if(!r.length)throw new Ah("Nothing to import");e.progress.set(n,{task:"INITIALISING",pending:r})})),e.progress),task:"VALIDATING"})})))},e.ARCHIVE_ID="sunbird.data.archive",e.ARCHIVE_VERSION="1.0",e=t=Nh([Object(I.injectable)(),wh(0,Object(I.inject)(be.FILE_SERVICE)),wh(1,Object(I.inject)(be.DB_SERVICE)),wh(2,Object(I.inject)(be.TELEMETRY_SERVICE)),wh(3,Object(I.inject)(be.ZIP_SERVICE)),wh(4,Object(I.inject)(be.DEVICE_INFO)),Mh("design:paramtypes",[Object,C,Object,Object,Object])],e)}(),Ih=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Ph=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Lh=function(){function e(){this._isInitialised=!1}return Object.defineProperty(e,"instance",{get:function(){return e._instance||(e._instance=new e),e._instance},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isInitialised",{get:function(){return this._isInitialised},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sdkConfig",{get:function(){return this._container.get(be.SDK_CONFIG)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"appInfo",{get:function(){return this._container.get(be.APP_INFO)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pageAssembleService",{get:function(){return this._container.get(be.PAGE_ASSEMBLE_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dbService",{get:function(){return this._container.get(be.DB_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"telemetryService",{get:function(){return this._container.get(be.TELEMETRY_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authService",{get:function(){return this._container.get(be.AUTH_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"apiService",{get:function(){return this._container.get(be.API_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"keyValueStore",{get:function(){return this._container.get(be.KEY_VALUE_STORE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"profileService",{get:function(){return this._container.get(be.PROFILE_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groupService",{get:function(){return this._container.get(be.GROUP_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contentService",{get:function(){return this._container.get(be.CONTENT_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contentFeedbackService",{get:function(){return this._container.get(be.CONTENT_FEEDBACK_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"courseService",{get:function(){return this._container.get(be.COURSE_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formService",{get:function(){return this._container.get(be.FORM_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frameworkService",{get:function(){return this._container.get(be.FRAMEWORK_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frameworkUtilService",{get:function(){return this._container.get(be.FRAMEWORK_UTIL_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sharedPreferences",{get:function(){return this._container.get(be.SHARED_PREFERENCES)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"systemSettingsService",{get:function(){return this._container.get(be.SYSTEM_SETTINGS_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventsBusService",{get:function(){return this._container.get(be.EVENTS_BUS_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"summarizerService",{get:function(){return this._container.get(be.SUMMARIZER_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"downloadService",{get:function(){return this._container.get(be.DOWNLOAD_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playerService",{get:function(){return this._container.get(be.PLAYER_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceInfo",{get:function(){return this._container.get(be.DEVICE_INFO)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"storageService",{get:function(){return this._container.get(be.STORAGE_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"notificationService",{get:function(){return this._container.get(be.NOTIFICATION_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorLoggerService",{get:function(){return this._container.get(be.ERROR_LOGGER_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"networkInfoService",{get:function(){return this._container.get(be.NETWORKINFO_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchHistoryService",{get:function(){return this._container.get(be.SEARCH_HISTORY_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"codePushExperimentService",{get:function(){return this._container.get(be.CODEPUSH_EXPERIMENT_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"faqService",{get:function(){return this._container.get(be.FAQ_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceRegisterService",{get:function(){return this._container.get(be.DEVICE_REGISTER_SERVICE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"archiveService",{get:function(){return this._container.get(be.ARCHIVE_SERVICE)},enumerable:!0,configurable:!0}),e.prototype.init=function(e){return Ih(this,void 0,void 0,(function(){return Ph(this,(function(t){switch(t.label){case 0:switch(this._container=new I.Container,this._container.bind(be.CONTAINER).toConstantValue(this._container),this._container.bind(be.DB_VERSION).toConstantValue(25),this._container.bind(be.DB_MIGRATION_LIST).toConstantValue([new Ms,new Ps,new js,new Gs,new Ju,new Bs,new Ll,new Hl,new Wl]),e.platform){case"cordova":this._container.bind(be.SHARED_PREFERENCES).to(ys).inSingletonScope();break;case"web":this._container.bind(be.SHARED_PREFERENCES).to(_s).inSingletonScope();break;default:throw new Error("FATAL_ERROR: Invalid platform")}return this._container.bind(be.DB_SERVICE).to(er).inSingletonScope(),this._container.bind(be.FILE_SERVICE).to(Os).inSingletonScope(),this._container.bind(be.SDK_CONFIG).toConstantValue(e),this._container.bind(be.DEVICE_INFO).to(yu).inSingletonScope(),this._container.bind(be.EVENTS_BUS_SERVICE).to(Cu).inSingletonScope(),this._container.bind(be.APP_INFO).to(Yu).inSingletonScope(),this._container.bind(be.API_SERVICE).to(xe).inSingletonScope(),this._container.bind(be.AUTH_SERVICE).to(Wo).inSingletonScope(),this._container.bind(be.KEY_VALUE_STORE).to(Xc).inSingletonScope(),this._container.bind(be.SYSTEM_SETTINGS_SERVICE).to(cu).inSingletonScope(),this._container.bind(be.FRAMEWORK_SERVICE).to(ia).inSingletonScope(),this._container.bind(be.PROFILE_SERVICE).to(Mo).inSingletonScope(),this._container.bind(be.GROUP_SERVICE).to(nu).inSingletonScope(),this._container.bind(be.ERROR_LOGGER_SERVICE).to(Tl).inSingletonScope(),this._container.bind(be.ZIP_SERVICE).to(uu).inSingletonScope(),this._container.bind(be.TELEMETRY_SERVICE).to(xo).inSingletonScope(),this._container.bind(be.CONTENT_FEEDBACK_SERVICE).to(Ou).inSingletonScope(),this._container.bind(be.FORM_SERVICE).to(es).inSingletonScope(),this._container.bind(be.PAGE_ASSEMBLE_SERVICE).to(ps).inSingletonScope(),this._container.bind(be.FRAMEWORK_UTIL_SERVICE).to(ba).inSingletonScope(),this._container.bind(be.DOWNLOAD_SERVICE).to(Uu).inSingletonScope(),this._container.bind(be.CONTENT_SERVICE).to(qc).inSingletonScope(),this._container.bind(be.COURSE_SERVICE).to(ao).inSingletonScope(),this._container.bind(be.SUMMARIZER_SERVICE).to(Ti).inSingletonScope(),this._container.bind(be.PLAYER_SERVICE).to(zu).inSingletonScope(),this._container.bind(be.CACHED_ITEM_STORE).to(as).inSingletonScope(),this._container.bind(be.TELEMETRY_DECORATOR).to(ar).inSingletonScope(),this._container.bind(be.STORAGE_SERVICE).to(al).inSingletonScope(),this._container.bind(be.NOTIFICATION_SERVICE).to(dl).inSingletonScope(),this._container.bind(be.NETWORKINFO_SERVICE).to(wl).inSingletonScope(),this._container.bind(be.SEARCH_HISTORY_SERVICE).to(Fl).inSingletonScope(),this._container.bind(be.CODEPUSH_EXPERIMENT_SERVICE).to($l).inSingletonScope(),this._container.bind(be.DEVICE_REGISTER_SERVICE).to(Xe).inSingletonScope(),this._container.bind(be.FAQ_SERVICE).to(rh).inSingletonScope(),this._container.bind(be.ARCHIVE_SERVICE).to(Ch).inSingletonScope(),this.apiService.setDefaultApiAuthenticators([new Zu(this.sharedPreferences,this.sdkConfig.apiConfig,this.deviceInfo,this.apiService)]),this.apiService.setDefaultSessionAuthenticators([new ef(this.sharedPreferences,this.sdkConfig.apiConfig,this.apiService,this.authService)]),[4,this.dbService.init()];case 1:return t.sent(),[4,this.appInfo.init()];case 2:return t.sent(),[4,this.preInit().toPromise()];case 3:return t.sent(),this._isInitialised=!0,this.postInit().subscribe(),[2]}}))}))},e.prototype.updateTelemetryConfig=function(e){for(var t in e)e.hasOwnProperty(t)&&(this.sdkConfig.telemetryConfig[t]=e[t])},e.prototype.updateDeviceRegisterConfig=function(e){for(var t in e)e.hasOwnProperty(t)&&(this.sdkConfig.deviceRegisterConfig[t]=e[t])},e.prototype.updateContentServiceConfig=function(e){for(var t in e)e.hasOwnProperty(t)&&(this.sdkConfig.contentServiceConfig[t]=e[t],"fcmToken"===t&&this.telemetryService.resetDeviceRegisterTTL())},e.prototype.updatePageServiceConfig=function(e){for(var t in e)e.hasOwnProperty(t)&&(this.sdkConfig.pageServiceConfig[t]=e[t])},e.prototype.preInit=function(){var e=this;return this.frameworkService.preInit().pipe(Object(ge.concatMap)((function(){return e.profileService.preInit()})))},e.prototype.postInit=function(){return Object(ie.combineLatest)([this.apiService.onInit(),this.summarizerService.onInit(),this.errorLoggerService.onInit(),this.eventsBusService.onInit(),this.downloadService.onInit(),this.contentService.onInit(),this.storageService.onInit(),this.telemetryService.onInit()])},e}(),Rh=function(e){return function(t,n,r){return function(e,t){var n=e.value;return e.value=function(){try{n.apply(this,arguments)}catch(e){throw t(e),e}},e}(r,(function(t){t instanceof On&&Lh.instance.telemetryService.error(e).subscribe()}))}},Dh=function(e){Lh.instance.telemetryService.interact(e).subscribe()},jh=function(e){return function(t,n,r){return An(r,(function(){Dh(e)}))}},Uh=function(e){return function(t,n,r){return Tn(r,(function(){Dh(e)}))}},kh=function(e){return function(t,n,r){return Nn(r,(function(){Dh(e)}))}},xh=function(e){return function(t,n,r){return function(e,t){var n=e.value;return e.value=function(){n.apply(this,arguments).catch((function(e){return t(),Promise.reject(e)}))},e}(r,(function(){Dh(e)}))}},Bh=function(e){Lh.instance.telemetryService.impression(e).subscribe()},Fh=function(e){return function(t,n,r){return An(r,(function(){Bh(e)}))}},Vh=function(e){return function(t,n,r){return Tn(r,(function(){Bh(e)}))}},Yh=function(e){return function(t,n,r){return Nn(r,(function(){Bh(e)}))}},Gh=function(e){Lh.instance.telemetryService.log(e).subscribe()},Hh=function(e){return function(t,n,r){return Tn(r,(function(){Gh(e)}))}},qh=function(e){return function(t,n,r){return Nn(r,(function(){Gh(e)}))}},zh=function(e){Lh.instance.telemetryService.start(e).subscribe()},Kh=function(e){return function(t,n,r){return An(r,(function(){zh(e)}))}},Wh=function(e){return function(t,n,r){return Tn(r,(function(){zh(e)}))}},Xh=function(e){return function(t,n,r){return Nn(r,(function(){zh(e)}))}};!function(e){e.OFF="OFF",e.OVER_WIFI="OVER_WIFI",e.ALWAYS_ON="ALWAYS_ON"}(ih||(ih={}));var Jh,Qh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),$h=function(e){function t(n){var r=e.call(this,n,"SIGN_IN_ERROR")||this;return Object.setPrototypeOf(r,t.prototype),r}return Qh(t,e),t}(U);!function(e){e.AUTO_MIGRATE_SUCCESS="AUTO_MIGRATE_SUCCESS",e.AUTO_MIGRATE_FAIL="AUTO_MIGRATE_FAIL"}(Jh||(Jh={}));var Zh=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ed=function(e){function t(n,r){var i=e.call(this,n,r)||this;return Object.setPrototypeOf(i,t.prototype),i}return Zh(t,e),t}(U),td=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),nd=function(e){function t(t){var n=e.call(this,t,"NO_INAPPBROWSER_SESSION_ASSERTION_FAIL")||this;return Object.setPrototypeOf(n,ed.prototype),n}return td(t,e),t}(ed),rd=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),id=function(e){function t(n){var r=e.call(this,n,"PARAM_NOT_CAPTURED")||this;return Object.setPrototypeOf(r,t.prototype),r}return rd(t,e),t}(ed),od=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ad=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},cd=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},sd=function(){function e(){this.extras={},this.captured={}}return e.buildUrl=function(e,t,n){return""+e+t+"?"+ae.stringify(n)},e.prototype.resetInAppBrowserEventListeners=function(){var e=this;if(!this.inAppBrowser)throw new nd("InAppBrowser Session not found when resetInAppBrowserEventListeners()");var t=function(t){n.inAppBrowser.listeners.hasOwnProperty(t)&&(n.inAppBrowser.listeners[t].forEach((function(n){e.inAppBrowser.ref.removeEventListener(t,n)})),n.inAppBrowser.listeners[t].clear())},n=this;for(var r in this.inAppBrowser.listeners)t(r)},e.prototype.launchWebview=function(t){var n=t.host,r=t.path,i=t.params;return ad(this,void 0,void 0,(function(){var t,o=this;return cd(this,(function(a){return this.inAppBrowser={ref:cordova.InAppBrowser.open(e.buildUrl(n,r,i),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes"),listeners:{loadstart:new Set,exit:new Set}},t=function(){o.resetInAppBrowserEventListeners(),o.inAppBrowser=void 0},this.inAppBrowser.listeners.exit.add(t),this.inAppBrowser.ref.addEventListener("exit",t),[2]}))}))},e.prototype.closeWebview=function(){return ad(this,void 0,void 0,(function(){return cd(this,(function(e){if(!this.inAppBrowser)throw new nd("InAppBrowser Session not found");return this.inAppBrowser.ref.close(),[2]}))}))},e.prototype.any=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ie.race.apply(void 0,e).pipe(Object(ge.take)(1)).toPromise()},e.prototype.all=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ie.zip.apply(void 0,e).pipe(Object(ge.take)(1),Object(ge.mapTo)(void 0)).toPromise()},e.prototype.launchCustomTab=function(t){var n=this,r=t.host,i=t.path,o=t.params,a=e.buildUrl(r,i,o);return new Promise((function(e,t){customtabs.isAvailable((function(){customtabs.launch(a,(function(t){n.captured=od({},n.captured,ae.parse(t)),e()}),(function(e){t(e)}))}),(function(){customtabs.launchInBrowser(a,(function(t){n.captured=od({},n.captured,ae.parse(t)),e()}),(function(e){t(e)}))}))}))},e.prototype.capture=function(e){var t=this,n=e.host,r=e.path,i=e.params;if(!this.inAppBrowser)throw new nd("InAppBrowser Session not found");return new Promise((function(e){var o=function(a){if(a.url){var c=new URL(a.url);c.origin===n&&function(e){return e.pathname===r}(c)&&function(e){return i.map((function(e){return e})).every((function(t){return"false"===t.exists?!e.searchParams.has(t.key):t.match?e.searchParams.has(t.key)&&e.searchParams.get(t.key)===t.match:e.searchParams.has(t.key)}))}(c)&&(t.captured=od({},t.captured,i.reduce((function(e,t){return e[t.resolveTo]=c.searchParams.get(t.key),e}),{})),t.extras={},i.map((function(e){return e.key})).forEach((function(e){return c.searchParams.delete(e)})),c.searchParams.forEach((function(e,n){t.extras[n]=e})),t.inAppBrowser&&(t.inAppBrowser.listeners.loadstart.delete(o),t.inAppBrowser.ref.removeEventListener("loadstart",o)),e())}};t.inAppBrowser&&(t.inAppBrowser.listeners.loadstart.add(o),t.inAppBrowser.ref.addEventListener("loadstart",o))}))},e.prototype.resolveCaptured=function(e){return ad(this,void 0,void 0,(function(){return cd(this,(function(t){if(!this.captured[e])throw new id(e+" was not captured");return[2,this.captured[e]]}))}))},e.prototype.clearCapture=function(){return ad(this,void 0,void 0,(function(){return cd(this,(function(e){return this.captured={},[2]}))}))},e.prototype.redirectTo=function(t){var n=t.host,r=t.path,i=t.params;return ad(this,void 0,void 0,(function(){return cd(this,(function(t){if(!this.inAppBrowser)throw new nd("InAppBrowser Session not found");return this.inAppBrowser.ref.executeScript({code:"(() => {\n window.location.href = `"+e.buildUrl(n,r,i)+"`;\n })()"}),[2]}))}))},e.prototype.success=function(){return ad(this,void 0,void 0,(function(){return cd(this,(function(e){return[2,od({},this.captured)]}))}))},e.prototype.fail=function(){return ad(this,void 0,void 0,(function(){return cd(this,(function(e){throw od({},this.captured)}))}))},e.prototype.getCaptureExtras=function(){return ad(this,void 0,void 0,(function(){return cd(this,(function(e){return[2,od({},this.extras)]}))}))},e}(),ud=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},fd=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},ld=function(){function e(e,t,n){this.apiConfig=e,this.apiService=t,this.eventsBusService=n}return e.parseUserTokenFromAccessToken=function(e){var t=re.getJWTPayload(e);return 3===t.sub.split(":").length?t.sub.split(":").pop():t.sub},e.prototype.buildGoogleTargetUrl=function(e,t){var n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach((function(e){return n.searchParams.set(e,t[e])})),n},e.prototype.buildPasswordSessionProvider=function(e,t){var n=this;return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then((function(){return e.closeWebview()})).then((function(){return e.success()})).then((function(e){return n.resolvePasswordSession(e)}))},e.prototype.buildStateSessionProvider=function(e,t){var n=this;return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then((function(){return e.closeWebview()})).then((function(){return e.success()})).then((function(e){return n.resolveStateSession(e)}))},e.prototype.buildGoogleSessionProvider=function(e,t){var n=this;return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then((function(){return e.closeWebview()})).then((function(){return e.success()})).then((function(t){return e.getCaptureExtras().then((function(r){var i=n.buildGoogleTargetUrl(t,r);return e.launchCustomTab({host:i.origin,path:i.pathname,params:ae.parse(i.searchParams.toString(),{ignoreQueryPrefix:!0})}).then((function(){return e.success()})).then((function(e){return n.resolveGoogleSession(e)}))}))}))},e.prototype.resolvePasswordSession=function(t){var n=(new F.Builder).withType(R.POST).withPath(this.apiConfig.user_authentication.authUrl+"/token").withBody({redirect_uri:this.apiConfig.host+"/oauth2callback",code:t.code,grant_type:"authorization_code",client_id:"android"}).withHeaders({"Content-Type":"application/x-www-form-urlencoded"}).withSerializer(L.URLENCODED).withApiToken(!1).withSessionToken(!1).build();return this.apiService.fetch(n).toPromise().then((function(t){if(t.body.access_token&&t.body.refresh_token){var n=e.parseUserTokenFromAccessToken(t.body.access_token);return{access_token:t.body.access_token,refresh_token:t.body.refresh_token,userToken:n}}throw new $h("Server Error")})).catch((function(){throw new $h("Server Error")}))},e.prototype.resolveStateSession=function(t){var n=(new F.Builder).withType(R.GET).withPath("/v1/sso/create/session?id="+t.id).withSessionToken(!1).withApiToken(!1).build();return this.apiService.fetch(n).toPromise().then((function(t){if(t.body.access_token&&t.body.refresh_token){var n=e.parseUserTokenFromAccessToken(t.body.access_token);return{access_token:t.body.access_token,refresh_token:t.body.refresh_token,userToken:n}}throw new $h("Server Error")})).catch((function(){throw new $h("Server Error")}))},e.prototype.resolveGoogleSession=function(t){return ud(this,void 0,void 0,(function(){var n;return fd(this,(function(r){if(t.access_token&&t.refresh_token)return n=e.parseUserTokenFromAccessToken(t.access_token),[2,{access_token:t.access_token,refresh_token:t.refresh_token,userToken:n}];if(t.error_message)throw new $h(t.error_message);throw new $h("Server Error")}))}))},e}(),hd=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),dd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},pd=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},bd=function(e){function t(t,n,r){var i=e.call(this,Lh.instance.sdkConfig.apiConfig,Lh.instance.apiService,Lh.instance.eventsBusService)||this;return i.autoMergeConfig=t,i.webviewRunner=n,i.captured=r,i.telemetryService=Lh.instance.telemetryService,i}return hd(t,e),t.prototype.provide=function(){return dd(this,void 0,void 0,(function(){var e,t,n=this;return pd(this,(function(r){switch(r.label){case 0:return e=this.webviewRunner,[4,this.telemetryService.buildContext().toPromise()];case 1:return t=r.sent(),this.autoMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),Object.keys(this.captured).forEach((function(e){n.autoMergeConfig.target.params.push({key:e,value:n.captured[e]})})),[2,e.redirectTo({host:this.autoMergeConfig.target.host,path:this.autoMergeConfig.target.path,params:this.autoMergeConfig.target.params.reduce((function(e,t){return e[t.key]=t.value,e}),{})}).then((function(){return e.any.apply(e,n.autoMergeConfig.return.reduce((function(t,r){switch(r.type){case"password":t.push(n.buildPasswordSessionProvider(e,r).then((function(e){return n.performAutoMerge({payload:n.captured.payload,session:e})})));break;case"state":t.push(n.buildStateSessionProvider(e,r));break;case"google":t.push(n.buildGoogleSessionProvider(e,r).then((function(e){return n.performAutoMerge({payload:n.captured.payload,session:e})})))}return t}),[]))}))]}}))}))},t.prototype.performAutoMerge=function(e){var t=this,n=e.payload,r=e.session,i=(new F.Builder).withType(R.GET).withPath(this.apiConfig.user_authentication.autoMergeApiPath).withParameters({client_id:"android"}).withHeaders({"x-authenticated-user-token":r.access_token,"x-authenticated-user-data":n}).build();return this.apiService.fetch(i).pipe(Object(ge.mapTo)(void 0)).toPromise().then((function(){return t.eventsBusService.emit({namespace:_e.AUTH,event:{type:Jh.AUTO_MIGRATE_SUCCESS,payload:void 0}}),r})).catch((function(e){return console.error(e),t.eventsBusService.emit({namespace:_e.AUTH,event:{type:Jh.AUTO_MIGRATE_FAIL,payload:void 0}}),r}))},t}(ld),_d=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ed=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},yd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},vd=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},gd=function(e){function t(t,n,r){var i=e.call(this,Lh.instance.sdkConfig.apiConfig,Lh.instance.apiService,Lh.instance.eventsBusService)||this;return i.loginConfig=t,i.autoMergeConfig=n,i.telemetryService=Lh.instance.telemetryService,i.webviewRunner=r||new sd,i}return _d(t,e),t.prototype.provide=function(){return yd(this,void 0,void 0,(function(){var e,t,n=this;return vd(this,(function(r){switch(r.label){case 0:return e=this.webviewRunner,[4,this.telemetryService.buildContext().toPromise()];case 1:return t=r.sent(),this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),[2,e.launchWebview({host:this.loginConfig.target.host,path:this.loginConfig.target.path,params:this.loginConfig.target.params.reduce((function(e,t){return e[t.key]=t.value,e}),Ed({},this.resetParams))}).then((function(){return e.any.apply(e,n.loginConfig.return.reduce((function(t,r){switch(r.type){case"password":t.push(n.buildPasswordSessionProvider(e,r));break;case"state":t.push(n.buildStateSessionProvider(e,r));break;case"google":t.push(n.buildGoogleSessionProvider(e,r));break;case"state-error":t.push(e.capture({host:r.when.host,path:r.when.path,params:r.when.params}).then((function(){return e.closeWebview().then((function(){return e.resolveCaptured("error_message").catch((function(){throw new $h("Server Error")})).then((function(e){throw new $h(e)}))}))})));break;case"migrate":t.push(e.capture({host:r.when.host,path:r.when.path,params:r.when.params}).then((function(){return e.success()})).then((function(t){return e.resetInAppBrowserEventListeners(),e.clearCapture().then((function(){return new bd(n.autoMergeConfig,n.webviewRunner,t).provide()}))})));break;case"reset":t.push(e.capture({host:r.when.host,path:r.when.path,params:r.when.params.concat([{key:"client_id",resolveTo:"client_id",match:"portal"},{key:"automerge",resolveTo:"automerge",exists:"false"}])}).then((function(){return e.getCaptureExtras().then((function(t){return n.resetParams=t,e.closeWebview().then((function(){return new Promise((function(e){return setTimeout(e,500)})).then((function(){return n.provide()}))}))}))})))}return t}),[]))}))]}}))}))},t}(ld),md=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Sd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,c)}s((r=r.apply(e,t||[])).next())}))},Od=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=r[2&o[0]?"return":o[0]?"throw":"next"])&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[0,i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Ad=function(e){function t(t,n){var r=e.call(this,Lh.instance.sdkConfig.apiConfig,Lh.instance.apiService,Lh.instance.eventsBusService)||this;return r.manualMergeConfig=t,r.telemetryService=Lh.instance.telemetryService,r.webviewRunner=n||new sd,r}return md(t,e),t.prototype.provide=function(){return Sd(this,void 0,void 0,(function(){var e,t,n=this;return Od(this,(function(r){switch(r.label){case 0:return e=this.webviewRunner,[4,this.telemetryService.buildContext().toPromise()];case 1:return t=r.sent(),this.manualMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),[2,e.launchWebview({host:this.manualMergeConfig.target.host,path:this.manualMergeConfig.target.path,params:this.manualMergeConfig.target.params.reduce((function(e,t){return e[t.key]=t.value,e}),{})}).then((function(){return e.any.apply(e,n.manualMergeConfig.return.reduce((function(t,r){switch(r.type){case"password":t.push(n.buildPasswordSessionProvider(e,r));break;case"google":t.push(n.buildGoogleSessionProvider(e,r));break;case"exit":t.push(e.capture({host:r.when.host,path:r.when.path,params:r.when.params}).then((function(){return e.closeWebview().then((function(){return e.clearCapture().then((function(){return Sd(n,void 0,void 0,(function(){return Od(this,(function(e){throw new Nd("EXIT param found")}))}))}))}))})))}return t}),[]))}))]}}))}))},t}(ld),Td=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Nd=function(e){function t(t){var n=e.call(this,t,"INTERRUPT_ERROR")||this;return Object.setPrototypeOf(n,ed.prototype),n}return Td(t,e),t}(ed);n.d(t,"DbConstants",(function(){return M})),n.d(t,"Migration",(function(){return w})),n.d(t,"DbService",(function(){return C})),n.d(t,"DeviceRegisterServiceImpl",(function(){return Xe})),n.d(t,"ResponseCode",(function(){return N})),n.d(t,"Response",(function(){return D})),n.d(t,"HttpSerializer",(function(){return L})),n.d(t,"HttpRequestType",(function(){return R})),n.d(t,"Request",(function(){return F})),n.d(t,"HttpClient",(function(){return V})),n.d(t,"JWTokenType",(function(){return B})),n.d(t,"JWTUtil",(function(){return re})),n.d(t,"ApiServiceImpl",(function(){return xe})),n.d(t,"NetworkError",(function(){return Fe})),n.d(t,"HttpServerError",(function(){return Le})),n.d(t,"HttpClientError",(function(){return De})),n.d(t,"TelemetryDecorator",(function(){return Je})),n.d(t,"Actor",(function(){return ct})),n.d(t,"Context",(function(){return st})),n.d(t,"DeviceSpecification",(function(){return ut})),n.d(t,"Etags",(function(){return ft})),n.d(t,"ExData",(function(){return lt})),n.d(t,"GameData",(function(){return ht})),n.d(t,"CorrelationData",(function(){return dt})),n.d(t,"Rollup",(function(){return pt})),n.d(t,"Visit",(function(){return bt})),n.d(t,"ProducerData",(function(){return _t})),n.d(t,"Search",(function(){return Et})),n.d(t,"TelemetryObject",(function(){return yt})),n.d(t,"ProcessedEventModel",(function(){return vt})),n.d(t,"AuditState",(function(){return nt})),n.d(t,"SunbirdTelemetry",(function(){return rt})),n.d(t,"ObjectType",(function(){return Ae})),n.d(t,"Mode",(function(){return Te})),n.d(t,"LogType",(function(){return Ne})),n.d(t,"LogLevel",(function(){return Me})),n.d(t,"ShareDirection",(function(){return we})),n.d(t,"ShareType",(function(){return Ce})),n.d(t,"ShareItemType",(function(){return Ie})),n.d(t,"LogMessage",(function(){return tt})),n.d(t,"InteractType",(function(){return Qe})),n.d(t,"InteractSubType",(function(){return $e})),n.d(t,"TelemetryErrorCode",(function(){return Ze})),n.d(t,"ErrorType",(function(){return et})),n.d(t,"TelemetryInteractRequest",(function(){return dn})),n.d(t,"TelemetryErrorRequest",(function(){return pn})),n.d(t,"TelemetryInterruptRequest",(function(){return bn})),n.d(t,"TelemetryImpressionRequest",(function(){return _n})),n.d(t,"TelemetryStartRequest",(function(){return En})),n.d(t,"TelemetryEndRequest",(function(){return yn})),n.d(t,"TelemetryFeedbackRequest",(function(){return vn})),n.d(t,"TelemetryLogRequest",(function(){return gn})),n.d(t,"TelemetryShareRequest",(function(){return mn})),n.d(t,"TelemetryError",(function(){return On})),n.d(t,"GenerateErrorTelemetryAfterMethodThrows",(function(){return Rh})),n.d(t,"GenerateInteractTelemetryAfterMethod",(function(){return jh})),n.d(t,"GenerateInteractTelemetryBeforeMethod",(function(){return Uh})),n.d(t,"GenerateInteractTelemetryAfterMethodResolves",(function(){return kh})),n.d(t,"GenerateInteractTelemetryAfterMethodRejects",(function(){return xh})),n.d(t,"GenerateImpressionTelemetryAfterMethod",(function(){return Fh})),n.d(t,"GenerateImpressionTelemetryBeforeMethod",(function(){return Vh})),n.d(t,"GenerateImpressionTelemetryAfterMethodResolves",(function(){return Yh})),n.d(t,"GenerateLogTelemetryBeforeMethod",(function(){return Hh})),n.d(t,"GenerateLogTelemetryAfterMethodResolves",(function(){return qh})),n.d(t,"GenerateStartTelemetryAfterMethod",(function(){return Kh})),n.d(t,"GenerateStartTelemetryBeforeMethod",(function(){return Wh})),n.d(t,"GenerateStartTelemetryAfterMethodResolves",(function(){return Xh})),n.d(t,"TelemetryAutoSyncModes",(function(){return ih})),n.d(t,"SignInError",(function(){return $h})),n.d(t,"AuthEventType",(function(){return Jh})),n.d(t,"WebviewLoginSessionProvider",(function(){return gd})),n.d(t,"WebviewManualMergeSessionProvider",(function(){return Ad})),n.d(t,"WebviewAutoMergeSessionProvider",(function(){return bd})),n.d(t,"WebviewRunnerError",(function(){return ed})),n.d(t,"InterruptError",(function(){return Nd})),n.d(t,"NoInappbrowserSessionAssertionFailError",(function(){return nd})),n.d(t,"ParamNotCapturedError",(function(){return id})),n.d(t,"CourseServiceImpl",(function(){return ao})),n.d(t,"CourseEnrollmentType",(function(){return Ji})),n.d(t,"CourseBatchStatus",(function(){return Qi})),n.d(t,"FrameworkServiceImpl",(function(){return ia})),n.d(t,"FrameworkCategoryCode",(function(){return oa.FrameworkCategoryCode})),n.d(t,"FrameworkCategoryCodesGroup",(function(){return oa.FrameworkCategoryCodesGroup})),n.d(t,"FrameworkUtilServiceImpl",(function(){return ba})),n.d(t,"ContentDeleteStatus",(function(){return Mn})),n.d(t,"SortOrder",(function(){return wn})),n.d(t,"MarkerType",(function(){return Cn})),n.d(t,"SearchType",(function(){return In})),n.d(t,"ChildContents",(function(){return Pn})),n.d(t,"State",(function(){return Ln})),n.d(t,"MimeType",(function(){return Rn})),n.d(t,"Visibility",(function(){return Dn})),n.d(t,"ContentStatus",(function(){return jn})),n.d(t,"ContentEncoding",(function(){return Un})),n.d(t,"ContentDisposition",(function(){return kn})),n.d(t,"FileExtension",(function(){return xn})),n.d(t,"ContentImportStatus",(function(){return Bn})),n.d(t,"ContentErrorCode",(function(){return Fn})),n.d(t,"ErrorCode",(function(){return Vn})),n.d(t,"FileName",(function(){return Yn})),n.d(t,"ContentEventType",(function(){return Gn})),n.d(t,"ProfileType",(function(){return gr})),n.d(t,"ProfileSource",(function(){return mr})),n.d(t,"ProfileSession",(function(){return wr})),n.d(t,"ContentAccess",(function(){return Cr})),n.d(t,"ContentAccessStatus",(function(){return Mr})),n.d(t,"ProfileServiceImpl",(function(){return Mo})),n.d(t,"NoActiveSessionError",(function(){return Co})),n.d(t,"NoProfileFoundError",(function(){return Po})),n.d(t,"GroupSession",(function(){return Hs})),n.d(t,"NoGroupFoundError",(function(){return zs})),n.d(t,"NoActiveGroupSessionError",(function(){return Ws})),n.d(t,"PageName",(function(){return co})),n.d(t,"SunbirdSdk",(function(){return Lh})),n.d(t,"EventNamespace",(function(){return _e})),n.d(t,"ErrorEventType",(function(){return Ee})),n.d(t,"SystemSettingsServiceImpl",(function(){return cu})),n.d(t,"SummarizerServiceImpl",(function(){return Ti})),n.d(t,"ContentCache",(function(){return Ni})),n.d(t,"ReportDetailPerUser",(function(){return Mi})),n.d(t,"SummarizerHandler",(function(){return wi})),n.d(t,"SummarizerQueries",(function(){return Ci})),n.d(t,"SummaryTelemetryEventHandler",(function(){return fo})),n.d(t,"CachedItemRequestSourceFrom",(function(){return Ir})),n.d(t,"StorageDestination",(function(){return vs})),n.d(t,"StorageEventType",(function(){return gs})),n.d(t,"ExistingContentAction",(function(){return ms})),n.d(t,"TransferFailedDuplicateContentError",(function(){return hu})),n.d(t,"TransferFailedError",(function(){return pu})),n.d(t,"NotificationStatus",(function(){return Gf})),n.d(t,"CodePUshExperimentServiceImpl",(function(){return $l})),n.d(t,"FaqServiceImpl",(function(){return rh})),n.d(t,"ArchiveObjectType",(function(){return pl})),n.d(t,"ExportAssertionError",(function(){return ah})),n.d(t,"InvalidRequestError",(function(){return sh})),n.d(t,"ObjectNotFoundError",(function(){return fh})),n.d(t,"DownloadEventType",(function(){return jr})),n.d(t,"DownloadStatus",(function(){return Ur})),n.d(t,"PlayerServiceImpl",(function(){return zu})),n.d(t,"NetworkStatus",(function(){return vr}))}])}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("rxjs/operators"),require("rxjs"),require("@project-sunbird/client-services"),require("@project-sunbird/client-services/core/http-service"),require("@project-sunbird/client-services/models/content/index"),require("@project-sunbird/client-services/services/content/utilities/primary-category-mapper"),require("@project-sunbird/client-services/services/content"),require("@project-sunbird/client-services/core"),require("@project-sunbird/client-services/core/http-service/utilities/interceptors"),require("@project-sunbird/client-services/models/group"),require("@project-sunbird/client-services/models/user"),require("@project-sunbird/client-services/services/content/utilities/content-group-generator"),require("@project-sunbird/client-services/services/content/utilities/content-progress-calculator"),require("@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator"));else if("function"==typeof define&&define.amd)define(["rxjs/operators","rxjs","@project-sunbird/client-services","@project-sunbird/client-services/core/http-service","@project-sunbird/client-services/models/content/index","@project-sunbird/client-services/services/content/utilities/primary-category-mapper","@project-sunbird/client-services/services/content","@project-sunbird/client-services/core","@project-sunbird/client-services/core/http-service/utilities/interceptors","@project-sunbird/client-services/models/group","@project-sunbird/client-services/models/user","@project-sunbird/client-services/services/content/utilities/content-group-generator","@project-sunbird/client-services/services/content/utilities/content-progress-calculator","@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator"],t);else{var n="object"==typeof exports?t(require("rxjs/operators"),require("rxjs"),require("@project-sunbird/client-services"),require("@project-sunbird/client-services/core/http-service"),require("@project-sunbird/client-services/models/content/index"),require("@project-sunbird/client-services/services/content/utilities/primary-category-mapper"),require("@project-sunbird/client-services/services/content"),require("@project-sunbird/client-services/core"),require("@project-sunbird/client-services/core/http-service/utilities/interceptors"),require("@project-sunbird/client-services/models/group"),require("@project-sunbird/client-services/models/user"),require("@project-sunbird/client-services/services/content/utilities/content-group-generator"),require("@project-sunbird/client-services/services/content/utilities/content-progress-calculator"),require("@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator")):t(e.rxjs.operators,e.rxjs,e["@project-sunbird"]["client-services"],e["@project-sunbird"]["client-services"].core["http-service"],e["@project-sunbird"]["client-services"].models.content.index,e["@project-sunbird"]["client-services"].services.content.utilities["primary-category-mapper"],e["@project-sunbird"]["client-services"].services.content,e["@project-sunbird"]["client-services"].core,e["@project-sunbird"]["client-services"].core["http-service"].utilities.interceptors,e["@project-sunbird"]["client-services"].models.group,e["@project-sunbird"]["client-services"].models.user,e["@project-sunbird"]["client-services"].services.content.utilities["content-group-generator"],e["@project-sunbird"]["client-services"].services.content.utilities["content-progress-calculator"],e["@project-sunbird"]["client-services"].services.content.utilities["mime-type-facet-to-mime-type-category-aggregator"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(e,t,n,r,i,o,s,a,c,u,d,l,f,h){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=304)}([function(t,n){t.exports=e},function(e,t,n){"use strict";n.r(t);var r=n(110);n.d(t,"DbConstants",(function(){return r.a}));var i=n(111);for(var o in i)["default","DbConstants"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(82);n.d(t,"Migration",(function(){return s.a}));var a=n(112);for(var o in a)["default","DbConstants","Migration"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var c=n(113);n.d(t,"DbService",(function(){return c.a}))},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"d",(function(){return s}));var r,i,o,s,a=n(1);!function(e){e.TABLE_NAME="content",e._ID="_id",e.COLUMN_NAME_IDENTIFIER="identifier",e.COLUMN_NAME_SERVER_DATA="server_data",e.COLUMN_NAME_LOCAL_DATA="local_data",e.COLUMN_NAME_MIME_TYPE="mime_type",e.COLUMN_NAME_PATH="path",e.COLUMN_NAME_INDEX="search_index",e.COLUMN_NAME_VISIBILITY="visibility",e.COLUMN_NAME_SERVER_LAST_UPDATED_ON="server_last_updated_on",e.COLUMN_NAME_LOCAL_LAST_UPDATED_ON="local_last_updated_on",e.COLUMN_NAME_MANIFEST_VERSION="manifest_version",e.COLUMN_NAME_REF_COUNT="ref_count",e.COLUMN_NAME_CONTENT_STATE="content_state",e.COLUMN_NAME_CONTENT_TYPE="content_type",e.COLUMN_NAME_AUDIENCE="audience",e.COLUMN_NAME_PRAGMA="pragma",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_SIZE_ON_DEVICE="size_on_device",e.COLUMN_NAME_BOARD="board",e.COLUMN_NAME_MEDIUM="medium",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_DIALCODES="dialcodes",e.COLUMN_NAME_CHILD_NODES="child_nodes",e.COLUMN_NAME_PRIMARY_CATEGORY="primary_category",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_IDENTIFIER+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" UNIQUE NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_SERVER_DATA+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_LOCAL_DATA+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_MIME_TYPE+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_PATH+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_INDEX+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_VISIBILITY+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_SERVER_LAST_UPDATED_ON+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_LOCAL_LAST_UPDATED_ON+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_REF_COUNT+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+" NOT NULL DEFAULT 1"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_STATE+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+" NOT NULL DEFAULT 2"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_TYPE+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_AUDIENCE+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT 'Learner'"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_SIZE_ON_DEVICE+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+" NOT NULL DEFAULT 0"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_PRAGMA+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_BOARD+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_MEDIUM+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_MANIFEST_VERSION+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_DIALCODES+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CHILD_NODES+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_PRIMARY_CATEGORY+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT '' )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME,e.getAlterEntryForContentSize=()=>"ALTER TABLE "+e.TABLE_NAME+" ADD COLUMN "+e.COLUMN_NAME_SIZE_ON_DEVICE+a.DbConstants.INT_TYPE+" NOT NULL DEFAULT 0;",e.getAlterEntryForPragma=()=>"ALTER TABLE "+e.TABLE_NAME+" ADD COLUMN "+e.COLUMN_NAME_PRAGMA+a.DbConstants.TEXT_TYPE+" DEFAULT '';",e.getAlterEntryForBoard=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_BOARD} TEXT DEFAULT ''`,e.getAlterEntryForMedium=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_MEDIUM} TEXT DEFAULT ''`,e.getAlterEntryForGrade=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_GRADE} TEXT DEFAULT ''`,e.getAlterEntryForDialCode=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_DIALCODES} TEXT DEFAULT ''`,e.getAlterEntryForChildNodes=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_CHILD_NODES} TEXT DEFAULT ''`,e.getAlterEntryForPrimaryCategory=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_PRIMARY_CATEGORY} TEXT DEFAULT ''`}(r||(r={})),function(e){e._ID="_id",e.TABLE_NAME="content_access",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.COLUMN_NAME_STATUS="status",e.COLUMN_NAME_CONTENT_TYPE="content_type",e.COLUMN_NAME_LEARNER_STATE="learner_state",e.COLUMN_NAME_PRIMARY_CATEGORY="primary_category",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_UID+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_IDENTIFIER+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_STATUS+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_TYPE+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_LEARNER_STATE+a.DbConstants.SPACE+a.DbConstants.BLOB_TYPE+" )",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME,e.getAlterEntryForPrimaryCategory=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_PRIMARY_CATEGORY} TEXT DEFAULT ''`}(i||(i={})),function(e){e._ID="_id",e.TABLE_NAME="feedback",e.COLUMN_NAME_CONTENT_ID="identifier",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_RATING="rating",e.COLUMN_NAME_COMMENTS="comments",e.COLUMN_NAME_CREATED_AT="createdAt",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_CONTENT_ID+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_UID+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_RATING+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_COMMENTS+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+" )",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(o||(o={})),function(e){e._ID="_id",e.TABLE_NAME="content_marker",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.COLUMN_NAME_DATA="data",e.COLUMN_NAME_EXTRA_INFO="extra_info",e.COLUMN_NAME_MARKER="marker",e.COLUMN_NAME_MIME_TYPE="mime_type",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_UID+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" NOT NULL"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_IDENTIFIER+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_DATA+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_EXTRA_INFO+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_MIME_TYPE+a.DbConstants.SPACE+a.DbConstants.TEXT_TYPE+" DEFAULT ''"+a.DbConstants.COMMA_SEP+e.COLUMN_NAME_MARKER+a.DbConstants.SPACE+a.DbConstants.INT_TYPE+" )",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME,e.getAlterEntryForMimeType=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_NAME_MIME_TYPE} TEXT DEFAULT ''`}(s||(s={}))},function(e,n){e.exports=t},function(e,t,n){"use strict";n.d(t,"f",(function(){return r})),n.d(t,"g",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return s})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return c})),n.d(t,"e",(function(){return u}));var r,i,o,s,a,c,u,d=n(1);!function(e){e._ID="_id",e.TABLE_NAME="profiles",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_HANDLE="handle",e.COLUMN_NAME_AVATAR="avatar",e.COLUMN_NAME_AGE="age",e.COLUMN_NAME_GENDER="gender",e.COLUMN_NAME_STANDARD="standard",e.COLUMN_NAME_LANGUAGE="language",e.COLUMN_NAME_DAY="day",e.COLUMN_NAME_MONTH="month",e.COLUMN_NAME_IS_GROUP_USER="is_group_user",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_MEDIUM="medium",e.COLUMN_NAME_BOARD="board",e.COLUMN_NAME_PROFILE_IMAGE="profile_image",e.COLUMN_NAME_SUBJECT="subject",e.COLUMN_NAME_PROFILE_TYPE="profile_type",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_SYLLABUS="syllabus",e.COLUMN_NAME_SOURCE="source",e.COLUMN_NAME_GRADE_VALUE="grade_value",e.COLUMN_VALUE="value",e.COLUMN_NAME_CATEGORIES="categories",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+"("+e._ID+d.DbConstants.SPACE+"INTEGER PRIMARY KEY,"+e.COLUMN_NAME_UID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" UNIQUE NOT NULL"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_HANDLE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_AVATAR+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_AGE+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GENDER+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_STANDARD+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_LANGUAGE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_DAY+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+" NOT NULL DEFAULT -1"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_MONTH+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+" NOT NULL DEFAULT -1"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_IS_GROUP_USER+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+" NOT NULL DEFAULT 0"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_MEDIUM+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_BOARD+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_SUBJECT+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_PROFILE_IMAGE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_PROFILE_TYPE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+' DEFAULT "teacher"'+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CATEGORIES+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" DEFAULT ''"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_SYLLABUS+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_SOURCE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_VALUE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+' DEFAULT ""'+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE_VALUE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+")",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME,e.getAlterEntryForProfileSyllabus=()=>"ALTER TABLE "+e.TABLE_NAME+" ADD COLUMN "+d.DbConstants.SPACE+e.COLUMN_NAME_SYLLABUS+d.DbConstants.TEXT_TYPE+" DEFAULT '';",e.getAlterEntryForProfileCategories=()=>"ALTER TABLE "+e.TABLE_NAME+" ADD COLUMN "+d.DbConstants.SPACE+e.COLUMN_NAME_CATEGORIES+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" DEFAULT '';"}(r||(r={})),function(e){e._ID="_id",e.TABLE_NAME="users",e.COLUMN_NAME_UID="uid",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_UID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" )",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(i||(i={})),function(e){e.TABLE_NAME="group_profile",e._ID="_id",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_UID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+"UNIQUE ("+e.COLUMN_NAME_GID+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_UID+") ON CONFLICT REPLACE)",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(o||(o={})),function(e){e.TABLE_NAME="groups",e._ID="_id",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_NAME="name",e.COLUMN_NAME_SYLLABUS="syllabus",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_GRADE_VALUE="grade_value",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_UPDATED_AT="updated_at",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_NAME+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_SYLLABUS+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+' DEFAULT ""'+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+' DEFAULT ""'+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE_VALUE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+' DEFAULT ""'+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+" INTEGER"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_UPDATED_AT+" INTEGER )",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(s||(s={})),function(e){e._ID="_id",e.TABLE_NAME="imported_metadata",e.COLUMN_NAME_IMPORTED_ID="imported_id",e.COLUMN_NAME_DEVICE_ID="device_id",e.COLUMN_NAME_COUNT="count",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_IMPORTED_ID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_DEVICE_ID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_COUNT+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(a||(a={})),function(e){e._ID="_id",e.TABLE_NAME="learner_assessments",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_CONTENT_ID="content_id",e.COLUMN_NAME_QID="qid",e.COLUMN_NAME_Q_INDEX="qindex",e.COLUMN_NAME_CORRECT="correct",e.COLUMN_NAME_SCORE="score",e.COLUMN_NAME_MAX_SCORE="max_score",e.COLUMN_NAME_TIME_SPENT="time_spent",e.COLUMN_NAME_RES="res",e.COLUMN_NAME_TIMESTAMP="timestamp",e.COLUMN_NAME_Q_DESC="qdesc",e.COLUMN_NAME_Q_TITLE="qtitle",e.COLUMN_NAME_HIERARCHY_DATA="h_data",e.COLUMN_NAME_TOTAL_TS="total_ts",e.COLUMN_NAME_MARKS="marks",e.COLUMN_NAME_COUNT="occurence_count",e.COLUMN_NAME_TOTAL_MAX_SCORE="sum_max_score",e.COLUMN_NAME_USERS_COUNT="users_count",e.COLUMN_NAME_HANDLE="handle",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_UID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" NOT NULL"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_ID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_QID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_Q_INDEX+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CORRECT+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_SCORE+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_MAX_SCORE+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_TIME_SPENT+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_RES+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_TIMESTAMP+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_Q_DESC+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_Q_TITLE+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_HIERARCHY_DATA+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" DEFAULT '' )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(c||(c={})),function(e){e._ID="_id",e.TABLE_NAME="learner_content_summary",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_CONTENT_ID="content_id",e.COLUMN_NAME_AVG_TS="avg_ts",e.COLUMN_NAME_SESSIONS="sessions",e.COLUMN_NAME_TOTAL_TS="total_ts",e.COLUMN_NAME_LAST_UPDATED_ON="last_updated_on",e.COLUMN_NAME_HIERARCHY_DATA="h_data",e.COLUMN_NAME_NO_OF_QUESTIONS="no_of_questions",e.COLUMN_NAME_CORRECT_ANSWERS="correct_answers",e.COLUMN_NAME_TOTAL_TIME_SPENT="total_time_spent",e.COLUMN_NAME_TOTAL_MAX_SCORE="total_max_score",e.COLUMN_NAME_TOTAL_SCORE="total_score",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_UID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+" NOT NULL"+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_ID+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_AVG_TS+d.DbConstants.SPACE+d.DbConstants.REAL_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_SESSIONS+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_TOTAL_TS+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_LAST_UPDATED_ON+d.DbConstants.SPACE+d.DbConstants.SPACE+d.DbConstants.INT_TYPE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_HIERARCHY_DATA+d.DbConstants.SPACE+d.DbConstants.TEXT_TYPE+d.DbConstants.COMMA_SEP+" UNIQUE ("+e.COLUMN_NAME_UID+d.DbConstants.SPACE+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONTENT_ID+d.DbConstants.COMMA_SEP+e.COLUMN_NAME_HIERARCHY_DATA+") ON CONFLICT REPLACE )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(u||(u={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}));const r={HTTP_SERVICE:Symbol.for("CS_HTTP_SERVICE"),GROUP_SERVICE:Symbol.for("CS_GROUP_SERVICE"),COURSE_SERVICE:Symbol.for("CS_COURSE_SERVICE"),USER_SERVICE:Symbol.for("CS_USER_SERVICE"),DISCUSSION_SERVICE:Symbol.for("CS_DISCUSSION_SERVICE"),CONTENT_SERVICE:Symbol.for("CS_CONTENT_SERVICE"),NOTIFICATION_SERVICE_V2:Symbol.for("CS_NOTIFICATION_SERVICE"),CERTIFICATE_SERVICE:Symbol.for("CS_CERTIFICATE_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("CS_FRAMEWORK_SERVICE")},i={CONTAINER:Symbol.for("CONTAINER"),DB_VERSION:Symbol.for("DB_VERSION"),DB_MIGRATION_LIST:Symbol.for("DB_MIGRATION_LIST"),SDK_CONFIG:Symbol.for("SDK_CONFIG"),DEVICE_INFO:Symbol.for("DEVICE_INFO"),SHARED_PREFERENCES:Symbol.for("SHARED_PREFERENCES"),EVENTS_BUS_SERVICE:Symbol.for("EVENTS_BUS_SERVICE"),DB_SERVICE:Symbol.for("DB_SERVICE"),APP_INFO:Symbol.for("APP_INFO"),API_SERVICE:Symbol.for("API_SERVICE"),AUTH_SERVICE:Symbol.for("AUTH_SERVICE"),FILE_SERVICE:Symbol.for("FILE_SERVICE"),SYSTEM_SETTINGS_SERVICE:Symbol.for("SYSTEM_SETTINGS_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("FRAMEWORK_SERVICE"),PROFILE_SERVICE:Symbol.for("PROFILE_SERVICE"),GROUP_SERVICE:Symbol.for("GROUP_SERVICE"),GROUP_SERVICE_DEPRECATED:Symbol.for("GROUP_SERVICE_DEPRECATED"),ZIP_SERVICE:Symbol.for("ZIP_SERVICE"),TELEMETRY_SERVICE:Symbol.for("TELEMETRY_SERVICE"),CONTENT_FEEDBACK_SERVICE:Symbol.for("CONTENT_FEEDBACK_SERVICE"),FORM_SERVICE:Symbol.for("FORM_SERVICE"),PAGE_ASSEMBLE_SERVICE:Symbol.for("PAGE_ASSEMBLE_SERVICE"),FRAMEWORK_UTIL_SERVICE:Symbol.for("FRAMEWORK_UTIL_SERVICE"),DOWNLOAD_SERVICE:Symbol.for("DOWNLOAD_SERVICE"),CONTENT_SERVICE:Symbol.for("CONTENT_SERVICE"),COURSE_SERVICE:Symbol.for("COURSE_SERVICE"),SUMMARIZER_SERVICE:Symbol.for("SUMMARIZER_SERVICE"),PLAYER_SERVICE:Symbol.for("PLAYER_SERVICE"),CACHED_ITEM_STORE:Symbol.for("CACHED_ITEM_STORE"),KEY_VALUE_STORE:Symbol.for("KEY_VALUE_STORE"),TELEMETRY_DECORATOR:Symbol.for("TELEMETRY_DECORATOR"),STORAGE_SERVICE:Symbol.for("STORAGE_SERVICE"),NOTIFICATION_SERVICE:Symbol.for("NOTIFICATION_SERVICE"),ERROR_LOGGER_SERVICE:Symbol.for("ERROR_LOGGER_SERVICE"),NETWORKINFO_SERVICE:Symbol.for("NETWORKINFO_SERVICE"),SEARCH_HISTORY_SERVICE:Symbol.for("SEARCH_HISTORY_SERVICE"),CODEPUSH_EXPERIMENT_SERVICE:Symbol.for("CODEPUSH_EXPERIMENT_SERVICE"),FAQ_SERVICE:Symbol.for("FAQ_SERVICE"),DEVICE_REGISTER_SERVICE:Symbol.for("DEVICE_REGISTER_SERVICE"),CONTENT_RATING_SERVICE:Symbol.for("CONTENT_RATING_SERVICE"),ARCHIVE_SERVICE:Symbol.for("ARCHIVE_SERVICE"),NETWORK_QUEUE:Symbol.for("NETWORK_QUEUE"),CLASS_ROOM_SERVICE:Symbol.for("CLASS_ROOM_SERVICE"),DISCUSSION_SERVICE:Symbol.for("DISCUSSION_SERVICE"),SEGMENTATION_SERVICE:Symbol.for("SEGMENTATION_SERVICE"),DEBUGGING_SERVICE:Symbol.for("DEBUGGING_SERVICE"),NOTIFICATION_SERVICE_V2:Symbol.for("NOTIFICATION_SERVICE_V2"),CERTIFICATE_SERVICE:Symbol.for("CERTIFICATE_SERVICE")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=t.getServiceIdentifierAsString=t.typeConstraint=t.namedConstraint=t.taggedConstraint=t.traverseAncerstors=t.decorate=t.id=t.MetadataReader=t.postConstruct=t.targetName=t.multiInject=t.unmanaged=t.optional=t.LazyServiceIdentifer=t.inject=t.named=t.tagged=t.injectable=t.ContainerModule=t.AsyncContainerModule=t.TargetTypeEnum=t.BindingTypeEnum=t.BindingScopeEnum=t.Container=t.METADATA_KEY=void 0;var r=n(35);t.METADATA_KEY=r;var i=n(306);Object.defineProperty(t,"Container",{enumerable:!0,get:function(){return i.Container}});var o=n(54);Object.defineProperty(t,"BindingScopeEnum",{enumerable:!0,get:function(){return o.BindingScopeEnum}}),Object.defineProperty(t,"BindingTypeEnum",{enumerable:!0,get:function(){return o.BindingTypeEnum}}),Object.defineProperty(t,"TargetTypeEnum",{enumerable:!0,get:function(){return o.TargetTypeEnum}});var s=n(322);Object.defineProperty(t,"AsyncContainerModule",{enumerable:!0,get:function(){return s.AsyncContainerModule}}),Object.defineProperty(t,"ContainerModule",{enumerable:!0,get:function(){return s.ContainerModule}});var a=n(323);Object.defineProperty(t,"injectable",{enumerable:!0,get:function(){return a.injectable}});var c=n(324);Object.defineProperty(t,"tagged",{enumerable:!0,get:function(){return c.tagged}});var u=n(325);Object.defineProperty(t,"named",{enumerable:!0,get:function(){return u.named}});var d=n(120);Object.defineProperty(t,"inject",{enumerable:!0,get:function(){return d.inject}}),Object.defineProperty(t,"LazyServiceIdentifer",{enumerable:!0,get:function(){return d.LazyServiceIdentifer}});var l=n(326);Object.defineProperty(t,"optional",{enumerable:!0,get:function(){return l.optional}});var f=n(327);Object.defineProperty(t,"unmanaged",{enumerable:!0,get:function(){return f.unmanaged}});var h=n(328);Object.defineProperty(t,"multiInject",{enumerable:!0,get:function(){return h.multiInject}});var E=n(329);Object.defineProperty(t,"targetName",{enumerable:!0,get:function(){return E.targetName}});var p=n(330);Object.defineProperty(t,"postConstruct",{enumerable:!0,get:function(){return p.postConstruct}});var _=n(118);Object.defineProperty(t,"MetadataReader",{enumerable:!0,get:function(){return _.MetadataReader}});var S=n(65);Object.defineProperty(t,"id",{enumerable:!0,get:function(){return S.id}});var b=n(56);Object.defineProperty(t,"decorate",{enumerable:!0,get:function(){return b.decorate}});var O=n(123);Object.defineProperty(t,"traverseAncerstors",{enumerable:!0,get:function(){return O.traverseAncerstors}}),Object.defineProperty(t,"taggedConstraint",{enumerable:!0,get:function(){return O.taggedConstraint}}),Object.defineProperty(t,"namedConstraint",{enumerable:!0,get:function(){return O.namedConstraint}}),Object.defineProperty(t,"typeConstraint",{enumerable:!0,get:function(){return O.typeConstraint}});var v=n(76);Object.defineProperty(t,"getServiceIdentifierAsString",{enumerable:!0,get:function(){return v.getServiceIdentifierAsString}});var C=n(331);Object.defineProperty(t,"multiBindToService",{enumerable:!0,get:function(){return C.multiBindToService}})},function(e,t,n){"use strict";n.r(t);var r=n(32);n.d(t,"HttpRequestType",(function(){return r.CsHttpRequestType})),n.d(t,"ResponseCode",(function(){return r.CsHttpResponseCode})),n.d(t,"HttpSerializer",(function(){return r.CsHttpSerializer})),n.d(t,"Request",(function(){return r.CsRequest})),n.d(t,"Response",(function(){return r.CsResponse})),n.d(t,"NetworkError",(function(){return r.CsNetworkError})),n.d(t,"HttpClientError",(function(){return r.CsHttpClientError})),n.d(t,"HttpServerError",(function(){return r.CsHttpServerError}));var i=n(124);for(var o in i)["default","HttpRequestType","ResponseCode","HttpSerializer","Request","Response","NetworkError","HttpClientError","HttpServerError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(125);for(var o in s)["default","HttpRequestType","ResponseCode","HttpSerializer","Request","Response","NetworkError","HttpClientError","HttpServerError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(o);var a=n(126);for(var o in a)["default","HttpRequestType","ResponseCode","HttpSerializer","Request","Response","NetworkError","HttpClientError","HttpServerError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var c=n(293);n.d(t,"ApiServiceImpl",(function(){return c.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var r=n(85),i=n(16),o=n(2),s=n(30),a=n(14),c=n(38),u=n.n(c),d=n(62),l=n(63);class f{static isAvailableLocally(e){return e===i.l.ARTIFACT_AVAILABLE}static isUpdateAvailable(e,t){let n=-1,r=-1;return e&&e.pkgVersion&&(r=parseFloat(e.pkgVersion)),t&&t.pkgVersion&&(n=parseFloat(t.pkgVersion)),r>0&&n>0&&r>n}static hasChildren(e){return!!e&&("string"==typeof e&&(e=JSON.parse(e)),e&&e.children)}static getContentRollup(e,t){let n,r,i,o;if(t&&0!==t.length)for(let e=0;e<t.length;e++)if(0===e)n=t[e].identifier;else if(1===e)r=t[e].identifier;else if(2===e)i=t[e].identifier;else{if(3!==e)break;o=t[e].identifier}else n=e;return{l1:n,l2:r,l3:i,l4:o}}static getChildContentsIdentifiers(e){const t=[];let n;n="string"==typeof e?JSON.parse(e):e;const r=n.children;return r&&r.length&&r.forEach(e=>{t.push(e.identifier)}),t}static getFirstPartOfThePathNameOnLastDelimiter(e){const t=e.lastIndexOf("/");if(t>0&&t<e.length)return e.substring(0,t)}static hasPreRequisites(e){return JSON.parse(e).pre_requisites}static readVisibility(e){const t=e.visibility;return t||i.m.DEFAULT}static isCompatible(e,t){return t>=e.minCompatibilityLevel&&t<=e.maxCompatibilityLevel}static readCompatibilityLevel(e){const t=e.compatibilityLevel;return t||this.defaultCompatibilityLevel}static isDraftContent(e){return e&&e===i.f.DRAFT.valueOf()}static isExpired(e){if(e){const t=new Date(e).getTime();if((new Date).getTime()>t)return!0}return!1}static isDuplicateCheckRequired(e,t){return e&&0===t}static isImportFileExist(e,t){if(!e||!t)return!1;let n=!1;const r=e[o.b.COLUMN_NAME_IDENTIFIER],i=t.identifier,s=e[o.b.COLUMN_NAME_VISIBILITY],a=f.readVisibility(t);return r===i&&s===a&&(n=this.readPkgVersion(JSON.parse(e[o.b.COLUMN_NAME_LOCAL_DATA]))>=this.readPkgVersion(t)),n}static readPkgVersion(e){return e.pkgVersion}static readContentType(e){let t=e.contentType;return t&&(t=t.toLowerCase()),t}static readPrimaryCategory(e){let t=e.primaryCategory;return t=t?t.toLowerCase():d.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType).toLowerCase(),t}static readPrimaryCategoryServer(e){let t=e.primaryCategory;return t=t||d.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType),t}static readAudience(e){const t=e.audience,n=[];return"string"==typeof t&&n.push(t),n&&n.length||n.push("Learner"),n.sort(),n.join(",")}static readPragma(e){let t=e.pragma;return t||(t=[]),t.join(",")}static doesContentExist(e,t,n,r){if(!e)return!1;let s=!1;const a=e[o.b.COLUMN_NAME_IDENTIFIER],c=JSON.parse(e[o.b.COLUMN_NAME_LOCAL_DATA]);if(a===t){let t=!1;r?t=!(f.readPkgVersion(c)<n):f.readPkgVersion(c)<n&&(t=!0),s=!(t||!r&&e[o.b.COLUMN_NAME_CONTENT_STATE]!==i.l.ARTIFACT_AVAILABLE.valueOf())}return s}static getContentRootDir(e){return"ios"===window.device.platform.toLowerCase()?e.concat("content/"):e.concat("content")}static addOrUpdateViralityMetadata(e,t){if(f.isContentMetadataAbsent(e)){const n={};n.origin=t,n.transferCount=f.INITIAL_VALUE_FOR_TRANSFER_COUNT;const r={};r.virality=n,e.contentMetadata=r}else if(f.isContentMetadataPresentWithoutViralityMetadata(e)){const n={};n.origin=t,n.transferCount=f.INITIAL_VALUE_FOR_TRANSFER_COUNT,e.contentMetaData.virality=n}else{const t=e.contentMetaData.virality;t.transferCount=f.transferCount(t)+1}}static addViralityMetadataIfMissing(e,t){e.contentMetaData||(e.contentMetaData={});const n=e.contentMetaData;n.virality||(n.virality={});let r=e.virality;r||(r={}),r.origin||(r.origin=t),r.transferCount||(r.transferCount=f.INITIAL_VALUE_FOR_TRANSFER_COUNT)}static isInlineIdentity(e,t){return e&&t&&i.b.INLINE.valueOf()===e&&i.c.IDENTITY.valueOf()===t}static isOnlineContent(e){const t=e.contentDisposition;return t&&i.b.ONLINE.valueOf()===t}static addOrUpdateDialcodeMapping(e,t,n){let r;r=e?JSON.parse(e):{},r.hasOwnProperty("identifier")||(r.identifier=t);const i=new Set;return r.hasOwnProperty("rootNodes")&&r.forEach(e=>{i.add(e)}),i.add(n),r.rootNodes=i,JSON.stringify(r)}static deDupe(e,t){return e.filter((e,n,r)=>r.map(e=>e[t]).indexOf(e[t])===n)}static getExportedFileName(e,t){let n,r="blank.ecar",s=0;e.length>0&&(n=e[0]);if(e.forEach(e=>{i.m.DEFAULT.valueOf()===e[o.b.COLUMN_NAME_VISIBILITY]&&s++}),s>1&&"".concat((s-1).toString()),n){const e=JSON.parse(n[o.b.COLUMN_NAME_LOCAL_DATA]);let i=e.name;i&&i.length>f.MAX_CONTENT_NAME&&(i=i.substring(0,f.MAX_CONTENT_NAME-3)+"...");const s=e.pkgVersion;r=`${t.toLowerCase()}_${i}-v${s}.ecar`}return r}static readOriginFromContentMap(e){const t=e.contentMetadata,n=t&&t.virality;return n?n.origin:""}static readTransferCountFromContentMap(e){const t=e.contentMetadata,n=t&&t.virality;return n?s.a.parseInt(n.transferCount):0}static readSizeFromContentMap(e){return e.size?e.size:""}static getUidnIdentifierFiler(e,t){const n=e&&`uid = '${e}'`,r=t&&`identifier = '${t}'`;let i="";return n&&r?i=`WHERE (${r} AND ${n})`:r?i=`WHERE (${r})`:n&&(i=`WHERE (${n})`),i}static getBasePath(e){return e?e=-1!==e.indexOf("file://")?e.replace("file://",""):"file://".concat(e):""}static getRollup(e,t){let n,r,i,o;if(t){let e;for(e=0;e<t.length;e++)switch(e){case 0:n=t[e].identifier;break;case 1:r=t[e].identifier;break;case 2:i=t[e].identifier;break;case 3:o=t[e].identifier}}else n=e;return{l1:n,l2:r,l3:i,l4:o}}static addOrUpdateRefCount(e){return e<0&&(e=0),e}static isNotUnit(e,t){return!(i.j.COLLECTION.valueOf()===e&&i.m.PARENT.valueOf()===t)}static getContentAttribute(e){let t=[];if(e&&("string"==typeof e?t.push(e):t=e,t&&t.length)){t.sort();let e="";for(let n=0;n<t.length;n++)e=n<t.length-1?e.concat("~",t[n]):e.concat("~",t[n],"~");return e.toLowerCase().trim()}return""}static getFindAllContentsWithIdentifierQuery(e){const t=a.a.joinPreservingQuotes(e),n=` order by ${o.b.COLUMN_NAME_LOCAL_LAST_UPDATED_ON} desc, ${o.b.COLUMN_NAME_SERVER_LAST_UPDATED_ON} desc`,r=` where ${o.b.COLUMN_NAME_IDENTIFIER} in (${t}) AND ${o.b.COLUMN_NAME_REF_COUNT} > 0`;return`select * from ${o.b.TABLE_NAME} ${r} ${n}`}static getFindAllContentsQuery(){return`select * from ${o.b.TABLE_NAME} where ${o.b.COLUMN_NAME_REF_COUNT} > 0`}static constructContentDBModel(e,t,n,r,i,s,a,c,d,l,h,E,p,_,S,b){return{[o.b.COLUMN_NAME_IDENTIFIER]:e,[o.b.COLUMN_NAME_SERVER_DATA]:"",[o.b.COLUMN_NAME_PATH]:f.getBasePath(a),[o.b.COLUMN_NAME_REF_COUNT]:c,[o.b.COLUMN_NAME_CONTENT_STATE]:d,[o.b.COLUMN_NAME_SIZE_ON_DEVICE]:E,[o.b.COLUMN_NAME_MANIFEST_VERSION]:t,[o.b.COLUMN_NAME_LOCAL_DATA]:n,[o.b.COLUMN_NAME_MIME_TYPE]:r,[o.b.COLUMN_NAME_CONTENT_TYPE]:i,[o.b.COLUMN_NAME_VISIBILITY]:s,[o.b.COLUMN_NAME_AUDIENCE]:l,[o.b.COLUMN_NAME_PRAGMA]:h,[o.b.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]:u()().format(),[o.b.COLUMN_NAME_BOARD]:f.getContentAttribute(p),[o.b.COLUMN_NAME_MEDIUM]:f.getContentAttribute(_),[o.b.COLUMN_NAME_GRADE]:f.getContentAttribute(S),[o.b.COLUMN_NAME_PRIMARY_CATEGORY]:b}}static getReferenceCount(e,t){let n;return e?(n=e[o.b.COLUMN_NAME_REF_COUNT],i.m.DEFAULT.valueOf()===e[o.b.COLUMN_NAME_VISIBILITY]&&i.m.DEFAULT.valueOf()===t||(n+=1)):n=1,n}static getContentVisibility(e,t,n){let r;return"Library"===t?r=i.m.PARENT.valueOf():e&&!i.m.PARENT.valueOf()===e[o.b.COLUMN_NAME_VISIBILITY]&&(r=e[o.b.COLUMN_NAME_VISIBILITY]),r||n}static getContentState(e,t){return e&&e[o.b.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[o.b.COLUMN_NAME_CONTENT_STATE]),t}static isFreeSpaceAvailable(e,t,n){let r=10240;return n>0&&(r=n),e>0&&e>t+r}static transferCount(e){const t=e.transferCount;return parseInt(t,0)}static isContentMetadataAbsent(e){return!Boolean(e.contentMetaData)}static isContentMetadataPresentWithoutViralityMetadata(e){return!Boolean(e.contentMetaData.virality)}static isTrackable(e){return e.trackable&&"string"==typeof e.trackable&&(e.trackable=JSON.parse(e.trackable)),e.trackable&&e.trackable.enabled?e.trackable.enabled===r.a.YES?1:e.mimeType===i.j.COLLECTION?0:-1:e.contentType.toLowerCase()===l.CsContentType.COURSE.toLowerCase()?1:e.mimeType===i.j.COLLECTION?0:-1}static getParseErrorObject(e){try{return JSON.parse(e)}catch(e){return}}}f.defaultCompatibilityLevel=1,f.DEFAULT_PACKAGE_VERSION=-1,f.INITIAL_VALUE_FOR_TRANSFER_COUNT=0,f.MAX_CONTENT_NAME=30},function(e,t,n){"use strict";n.r(t);var r=n(85);n.d(t,"TrackingEnabled",(function(){return r.a}));var i=n(148);n.d(t,"ContentDeleteStatus",(function(){return i.a}));var o=n(149);for(var s in o)["default","TrackingEnabled","ContentDeleteStatus"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);var a=n(150);n.d(t,"SortOrder",(function(){return a.b})),n.d(t,"MarkerType",(function(){return a.a}));var c=n(151);for(var s in c)["default","TrackingEnabled","ContentDeleteStatus","SortOrder","MarkerType"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(s);var u=n(152);for(var s in u)["default","TrackingEnabled","ContentDeleteStatus","SortOrder","MarkerType"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(s);var d=n(16);n.d(t,"SearchType",(function(){return d.k})),n.d(t,"ChildContents",(function(){return d.a})),n.d(t,"State",(function(){return d.l})),n.d(t,"MimeType",(function(){return d.j})),n.d(t,"Visibility",(function(){return d.m})),n.d(t,"ContentStatus",(function(){return d.f})),n.d(t,"ContentEncoding",(function(){return d.c})),n.d(t,"ContentDisposition",(function(){return d.b})),n.d(t,"FileExtension",(function(){return d.h})),n.d(t,"ContentImportStatus",(function(){return d.e})),n.d(t,"ContentErrorCode",(function(){return d.d})),n.d(t,"ErrorCode",(function(){return d.g})),n.d(t,"FileName",(function(){return d.i}));var l=n(153);n.d(t,"ContentEventType",(function(){return l.a}));var f=n(42);n.d(t,"ContentMapper",(function(){return f.a}))},function(e,t,n){"use strict";n.r(t);var r=n(131);n.d(t,"TelemetryDecorator",(function(){return r.a}));var i=n(132);n.d(t,"Actor",(function(){return i.a})),n.d(t,"Context",(function(){return i.c})),n.d(t,"DeviceSpecification",(function(){return i.e})),n.d(t,"Etags",(function(){return i.f})),n.d(t,"ExData",(function(){return i.g})),n.d(t,"GameData",(function(){return i.h})),n.d(t,"CorrelationData",(function(){return i.d})),n.d(t,"Rollup",(function(){return i.k})),n.d(t,"Visit",(function(){return i.o})),n.d(t,"ProducerData",(function(){return i.j})),n.d(t,"Search",(function(){return i.l})),n.d(t,"TelemetryObject",(function(){return i.n})),n.d(t,"ProcessedEventModel",(function(){return i.i})),n.d(t,"AuditState",(function(){return i.b})),n.d(t,"SunbirdTelemetry",(function(){return i.m}));var o=n(133);for(var s in o)["default","TelemetryDecorator","Actor","Context","DeviceSpecification","Etags","ExData","GameData","CorrelationData","Rollup","Visit","ProducerData","Search","TelemetryObject","ProcessedEventModel","AuditState","SunbirdTelemetry"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(s);var a=n(134);for(var s in a)["default","TelemetryDecorator","Actor","Context","DeviceSpecification","Etags","ExData","GameData","CorrelationData","Rollup","Visit","ProducerData","Search","TelemetryObject","ProcessedEventModel","AuditState","SunbirdTelemetry"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(s);var c=n(135);for(var s in c)["default","TelemetryDecorator","Actor","Context","DeviceSpecification","Etags","ExData","GameData","CorrelationData","Rollup","Visit","ProducerData","Search","TelemetryObject","ProcessedEventModel","AuditState","SunbirdTelemetry"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(s);var u=n(78);n.d(t,"ObjectType",(function(){return u.h})),n.d(t,"Mode",(function(){return u.g})),n.d(t,"LogType",(function(){return u.f})),n.d(t,"LogLevel",(function(){return u.d})),n.d(t,"ShareDirection",(function(){return u.i})),n.d(t,"ShareType",(function(){return u.k})),n.d(t,"ShareItemType",(function(){return u.j})),n.d(t,"LogMessage",(function(){return u.e})),n.d(t,"InteractType",(function(){return u.c})),n.d(t,"InteractSubType",(function(){return u.b})),n.d(t,"TelemetryErrorCode",(function(){return u.l})),n.d(t,"ErrorType",(function(){return u.a}));var d=n(136);n.d(t,"TelemetryInteractRequest",(function(){return d.e})),n.d(t,"TelemetryErrorRequest",(function(){return d.b})),n.d(t,"TelemetryInterruptRequest",(function(){return d.f})),n.d(t,"TelemetryImpressionRequest",(function(){return d.d})),n.d(t,"TelemetryStartRequest",(function(){return d.i})),n.d(t,"TelemetrySummaryRequest",(function(){return d.j})),n.d(t,"TelemetryEndRequest",(function(){return d.a})),n.d(t,"TelemetryFeedbackRequest",(function(){return d.c})),n.d(t,"TelemetryLogRequest",(function(){return d.g})),n.d(t,"TelemetryShareRequest",(function(){return d.h}));var l=n(137);for(var s in l)["default","TelemetryDecorator","Actor","Context","DeviceSpecification","Etags","ExData","GameData","CorrelationData","Rollup","Visit","ProducerData","Search","TelemetryObject","ProcessedEventModel","AuditState","SunbirdTelemetry","ObjectType","Mode","LogType","LogLevel","ShareDirection","ShareType","ShareItemType","LogMessage","InteractType","InteractSubType","TelemetryErrorCode","ErrorType","TelemetryInteractRequest","TelemetryErrorRequest","TelemetryInterruptRequest","TelemetryImpressionRequest","TelemetryStartRequest","TelemetrySummaryRequest","TelemetryEndRequest","TelemetryFeedbackRequest","TelemetryLogRequest","TelemetryShareRequest"].indexOf(s)<0&&function(e){n.d(t,e,(function(){return l[e]}))}(s);var f=n(138);n.d(t,"TelemetryAutoSyncModes",(function(){return f.a}))},function(e,t,n){"use strict";var r,i,o,s,a,c,u,d,l,f,h,E,p,_,S;n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"k",(function(){return s})),n.d(t,"m",(function(){return a})),n.d(t,"j",(function(){return c})),n.d(t,"h",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"n",(function(){return l})),n.d(t,"i",(function(){return f})),n.d(t,"d",(function(){return h})),n.d(t,"e",(function(){return E})),n.d(t,"g",(function(){return p})),n.d(t,"o",(function(){return _})),n.d(t,"l",(function(){return S})),function(e){e.KEY_FIRST_ACCESS_TIMESTAMP="first_access_timestamp"}(r||(r={})),function(e){e.KEY_API_TOKEN="api_bearer_token_v2"}(i||(i={})),function(e){e.KEY_OAUTH_SESSION="oauth_token"}(o||(o={})),function(e){e.KEY_GROUP_SESSION="group_session"}(s||(s={})),function(e){e.KEY_USER_SESSION="session"}(a||(a={})),function(e){e.KEY_ACTIVE_CHANNEL_ID="channelId",e.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID="sunbirdcurrent_framework_id"}(c||(c={})),function(e){e.KEY_TO_DOWNLOAD_LIST="to_download_list"}(u||(u={})),function(e){e.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL="is_update_size_on_device_successful",e.KEY_CONTENT_DELETE_REQUEST_LIST="content_delete_request_list",e.KEY_LAST_MODIFIED="last_modified",e.UPDATE_CONTENT_STATE="update_content_state",e.COURSE_CONTEXT="sunbirdcontent_context"}(d||(d={})),function(e){e.KEY_STORAGE_DESTINATION="storage_destination",e.KEY_TO_TRANSFER_LIST="to_transfer_list"}(l||(l={})),function(e){e.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP="error_log_last_synced_time_stamp"}(f||(f={})),function(e){e.DEPLOYMENT_KEY="deployment_key"}(h||(h={})),function(e){e.DEFAULT_DEPLOYMENT_KEY="default_deployment_key",e.EXPERIMENT_KEY="experiment_key",e.EXPERIMENT_APP_VERSION="emperiment_app_version"}(E||(E={})),function(e){e.DEVICE_LOCATION="device_location_new"}(p||(p={})),function(e){e.KEY_LAST_SYNCED_TIME_STAMP="telemetry_last_synced_time_stamp",e.KEY_AUTO_SYNC_MODE="telemetry_auto_sync_mode"}(_||(_={})),function(e){e.KEY_ORGANISATION_ID="page_assemble_organisation_id"}(S||(S={}))},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r,i,o=n(1);!function(e){e.TABLE_NAME="group_profile",e._ID="_id",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_GID+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_UID+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+o.DbConstants.SPACE+o.DbConstants.INT_TYPE+o.DbConstants.COMMA_SEP+"UNIQUE ("+e.COLUMN_NAME_GID+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_UID+") ON CONFLICT REPLACE)",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(r||(r={})),function(e){e.TABLE_NAME="groups",e._ID="_id",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_NAME="name",e.COLUMN_NAME_SYLLABUS="syllabus",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_GRADE_VALUE="grade_value",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_UPDATED_AT="updated_at",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_GID+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_NAME+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_SYLLABUS+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+' DEFAULT ""'+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+' DEFAULT ""'+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_GRADE_VALUE+o.DbConstants.SPACE+o.DbConstants.TEXT_TYPE+' DEFAULT ""'+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+" INTEGER"+o.DbConstants.COMMA_SEP+e.COLUMN_NAME_UPDATED_AT+" INTEGER )",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(i||(i={}))},function(e,t){e.exports=n},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{static joinPreservingQuotes(e){return e.map(e=>`'${e}'`).join(",")}static isEmpty(e){return!e||0===e.length}static contains(e,t){return e&&-1!==e.indexOf(t)}static deDupe(e){return e.filter((e,t,n)=>n.indexOf(e)===t)}}},function(e,t,n){"use strict";n.r(t);var r=n(156);n.d(t,"UserFeedCategory",(function(){return r.c})),n.d(t,"UserFeedStatus",(function(){return r.d})),n.d(t,"ProfileType",(function(){return r.b})),n.d(t,"ProfileSource",(function(){return r.a}));var i=n(157);for(var o in i)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(158);for(var o in s)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(o);var a=n(159);n.d(t,"ProfileSession",(function(){return a.a}));var c=n(160);n.d(t,"ContentAccess",(function(){return c.a})),n.d(t,"ContentAccessStatus",(function(){return c.b}));var u=n(289);n.d(t,"ProfileServiceImpl",(function(){return u.a}));var d=n(187);for(var o in d)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var l=n(188);for(var o in l)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return l[e]}))}(o);var f=n(189);for(var o in f)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var h=n(190);n.d(t,"NoActiveSessionError",(function(){return h.a}));var E=n(191);n.d(t,"NoProfileFoundError",(function(){return E.a}));var p=n(192);for(var o in p)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return p[e]}))}(o);var _=n(193);for(var o in _)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return _[e]}))}(o);var S=n(194);for(var o in S)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return S[e]}))}(o);var b=n(195);for(var o in b)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return b[e]}))}(o);var O=n(196);for(var o in O)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return O[e]}))}(o);var v=n(197);for(var o in v)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return v[e]}))}(o);var C=n(198);for(var o in C)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return C[e]}))}(o);var g=n(199);for(var o in g)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return g[e]}))}(o);var A=n(200);for(var o in A)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return A[e]}))}(o);var T=n(201);for(var o in T)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return T[e]}))}(o);var N=n(202);for(var o in N)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return N[e]}))}(o);var y=n(203);for(var o in y)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return y[e]}))}(o);var m=n(204);for(var o in m)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return m[e]}))}(o);var I=n(205);for(var o in I)["default","UserFeedCategory","UserFeedStatus","ProfileType","ProfileSource","ProfileSession","ContentAccess","ContentAccessStatus","ProfileServiceImpl","NoActiveSessionError","NoProfileFoundError"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return I[e]}))}(o)},function(e,t,n){"use strict";var r,i,o,s,a,c,u,d,l,f,h,E,p;n.d(t,"k",(function(){return r})),n.d(t,"a",(function(){return i})),n.d(t,"l",(function(){return o})),n.d(t,"j",(function(){return s})),n.d(t,"m",(function(){return a})),n.d(t,"f",(function(){return c})),n.d(t,"c",(function(){return u})),n.d(t,"b",(function(){return d})),n.d(t,"h",(function(){return l})),n.d(t,"e",(function(){return f})),n.d(t,"d",(function(){return h})),n.d(t,"g",(function(){return E})),n.d(t,"i",(function(){return p})),function(e){e.SEARCH="search",e.FILTER="filter"}(r||(r={})),function(e){e[e.ALL=0]="ALL",e[e.DOWNLOADED=1]="DOWNLOADED",e[e.SPINE=2]="SPINE"}(i||(i={})),function(e){e[e.SEEN_BUT_NOT_AVAILABLE=0]="SEEN_BUT_NOT_AVAILABLE",e[e.ONLY_SPINE=1]="ONLY_SPINE",e[e.ARTIFACT_AVAILABLE=2]="ARTIFACT_AVAILABLE"}(o||(o={})),function(e){e.APK="application/vnd.android.package-archive",e.ECML="application/vnd.ekstep.ecml-archive",e.HTML="application/vnd.ekstep.html-archive",e.COLLECTION="application/vnd.ekstep.content-collection",e.H5P="application/vnd.ekstep.h5p-archive",e.VIDEO="video/mp4",e.YOUTUBE="video/x-youtube",e.WEBM="video/webm",e.QUESTION="application/vnd.sunbird.question",e.QUESTION_SET="application/vnd.sunbird.questionset",e.EPUB="application/epub",e.ZIP="application/zip",e.TXT="text/plain",e.ECAR="application/ecar",e.EPAR="application/epar"}(s||(s={})),function(e){e.DEFAULT="Default",e.PARENT="Parent"}(a||(a={})),function(e){e.LIVE="Live",e.DRAFT="Draft"}(c||(c={})),function(e){e.GZIP="gzip",e.IDENTITY="identity"}(u||(u={})),function(e){e.ATTACHMENT="attachment",e.INLINE="inline",e.ONLINE="online"}(d||(d={})),function(e){e.CONTENT="ecar",e.PROFILE="epar",e.TELEMETRY="gsa"}(l||(l={})),function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.ENQUEUED_FOR_DOWNLOAD=0]="ENQUEUED_FOR_DOWNLOAD",e[e.DOWNLOAD_STARTED=1]="DOWNLOAD_STARTED",e[e.DOWNLOAD_FAILED=2]="DOWNLOAD_FAILED",e[e.DOWNLOAD_COMPLETED=3]="DOWNLOAD_COMPLETED",e[e.IMPORT_STARTED=4]="IMPORT_STARTED",e[e.IMPORT_FAILED=5]="IMPORT_FAILED",e[e.NOT_COMPATIBLE=6]="NOT_COMPATIBLE",e[e.CONTENT_EXPIRED=7]="CONTENT_EXPIRED",e[e.ALREADY_EXIST=8]="ALREADY_EXIST",e[e.IMPORT_COMPLETED=100]="IMPORT_COMPLETED"}(f||(f={})),function(e){e.NO_DATA_FOUND="NO_DATA_FOUND",e.INVALID_FILE="INVALID_FILE",e.ECAR_NOT_FOUND="ECAR_NOT_FOUND",e.IMPORT_FAILED_DEVICE_MEMORY_FULL="IMPORT_FAILED_DEVICE_MEMORY_FULL",e.IMPORT_FAILED_EXTRACT_ECAR="IMPORT_FAILED_EXTRACTION",e.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND="IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND",e.IMPORT_FAILED_UNSUPPORTED_MANIFEST="IMPORT_FAILED_UNSUPPORTED_MANIFEST",e.IMPORT_FAILED_NO_CONTENT_METADATA="IMPORT_FAILED_NO_CONTENT_METADATA",e.DUPLICATE_CONTENT="DUPLICATE_CONTENT",e.IMPORT_FILE_EXIST="IMPORT_FILE_EXIST",e.ECAR_CLEANUP_FAILED="ECAR_CLEANUP_FAILED",e.EXPORT_FAILED_COPY_ASSET="EXPORT_FAILED_COPY_ASSET",e.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT="EXPORT_FAILED_MEMORY_NOT_SUFFICIENT",e.EXPORT_FAILED_WRITING_MANIFEST="EXPORT_FAILED_WRITE_MANIFEST",e.EXPORT_FAILED_ECAR_BUNDLE="EXPORT_FAILED_ECAR_BUNDLE",e.EXPORT_FAILED_NOTHING_TO_EXPORT="EXPORT_FAILED_NOTHING_TO_EXPORT",e.EXPORT_FAILED_DELETING_ECAR="EXPORT_FAILED_DELETING_ECAR"}(h||(h={})),function(e){e.EXPORT_FAILED="EXPORT_FAILED",e.IMPORT_FAILED="IMPORT_FAILED"}(E||(E={})),function(e){e.MANIFEST="manifest.json",e.HIERARCHY="hierarchy.json"}(p||(p={}))},function(e,t,n){"use strict";n.d(t,"c",(function(){return r})),n.d(t,"d",(function(){return i})),n.d(t,"a",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"b",(function(){return a}));var r,i,o,s,a,c=n(1);!function(e){e._ID="_id",e.TABLE_NAME="telemetry",e.COLUMN_NAME_EVENT_TYPE="event_type",e.COLUMN_NAME_EVENT="event",e.COLUMN_NAME_TIMESTAMP="timestamp",e.COLUMN_NAME_PRIORITY="priority",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+c.DbConstants.SPACE+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_EVENT_TYPE+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_EVENT+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_TIMESTAMP+c.DbConstants.SPACE+c.DbConstants.INT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_PRIORITY+c.DbConstants.SPACE+c.DbConstants.INT_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(r||(r={})),function(e){e._ID="_id",e.TABLE_NAME="processed_telemetry",e.COLUMN_NAME_MSG_ID="msg_id",e.COLUMN_NAME_DATA="data",e.COLUMN_NAME_NUMBER_OF_EVENTS="event_count",e.COLUMN_NAME_PRIORITY="priority",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_MSG_ID+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_DATA+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_NUMBER_OF_EVENTS+c.DbConstants.SPACE+c.DbConstants.INT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_PRIORITY+c.DbConstants.SPACE+c.DbConstants.INT_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(i||(i={})),function(e){e._ID="_id",e.TABLE_NAME="event_priority",e.COLUMN_NAME_EVENT="event",e.COLUMN_NAME_PRIORITY="priority",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_EVENT+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_PRIORITY+c.DbConstants.SPACE+c.DbConstants.INT_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(o||(o={})),function(e){e._ID="_id",e.TABLE_NAME="telemetry_tags",e.COLUMN_NAME_NAME="name",e.COLUMN_NAME_HASH="hash",e.COLUMN_NAME_DESCRIPTION="description",e.COLUMN_NAME_START_DATE="start_date",e.COLUMN_NAME_END_DATE="end_date",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_NAME+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_HASH+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_DESCRIPTION+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_START_DATE+c.DbConstants.SPACE+c.DbConstants.DATE_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_END_DATE+c.DbConstants.SPACE+c.DbConstants.DATE_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(s||(s={})),function(e){e._ID="_id",e.TABLE_NAME="meta_data",e.COLUMN_NAME_MSG_ID="key",e.COLUMN_NAME_DATA="value",e.getCreateEntry=()=>"CREATE TABLE "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_MSG_ID+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+c.DbConstants.COMMA_SEP+e.COLUMN_NAME_DATA+c.DbConstants.SPACE+c.DbConstants.TEXT_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(a||(a={}))},function(e,t,n){"use strict";n.r(t);var r=n(127);n.d(t,"EventNamespace",(function(){return r.a}));var i=n(128);for(var o in i)["default","EventNamespace"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(129);for(var o in s)["default","EventNamespace"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(o);var a=n(130);n.d(t,"ErrorEventType",(function(){return a.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r extends Error{constructor(e,t){super(e),this._code=t,Object.setPrototypeOf(this,r.prototype)}get code(){return this._code}}},function(e,t,n){"use strict";n.r(t);var r=n(225);n.d(t,"StorageDestination",(function(){return r.a}));var i=n(226);for(var o in i)["default","StorageDestination"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(227);n.d(t,"StorageEventType",(function(){return s.a}));var a=n(228);n.d(t,"ExistingContentAction",(function(){return a.a}));var c=n(229);n.d(t,"TransferFailedDuplicateContentError",(function(){return c.a}));var u=n(230);n.d(t,"TransferFailedError",(function(){return u.a}))},function(e,t,n){"use strict";n.r(t);var r=n(161);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(162);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(163);n.d(t,"CachedItemRequestSourceFrom",(function(){return s.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i.a})),n.d(t,"b",(function(){return r}));var r,i=n(69);!function(e){e.TELEMETRY="telemetry",e.COURSE_PROGRESS="course_progress",e.COURSE_ASSESMENT="course_assesment"}(r||(r={}))},function(e,t,n){"use strict";n.r(t);var r=n(164);n.d(t,"SummarizerServiceImpl",(function(){return r.a}));var i=n(165);for(var o in i)["default","SummarizerServiceImpl"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(166);n.d(t,"ContentCache",(function(){return s.a})),n.d(t,"ReportDetailPerUser",(function(){return s.b}));var a=n(167);for(var o in a)["default","SummarizerServiceImpl","ContentCache","ReportDetailPerUser"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var c=n(168);n.d(t,"SummarizerHandler",(function(){return c.a}));var u=n(169);n.d(t,"SummarizerQueries",(function(){return u.a}));var d=n(170);n.d(t,"SummaryTelemetryEventHandler",(function(){return d.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r,i=n(1);!function(e){e._ID="_id",e.TABLE_NAME="no_sql",e.COLUMN_NAME_KEY="key",e.COLUMN_NAME_VALUE="value",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_KEY+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+" NOT NULL"+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_VALUE+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+" )",e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return as}));var r,i,o=n(7),s=n(1),a=n(17),c=n(4),u=n(12);(i=r||(r={}))._ID="_id",i.TABLE_NAME="partners",i.COLUMN_NAME_PARTNER_ID="partnerID",i.COLUMN_NAME_KEY="publicKey",i.COLUMN_NAME_KEY_ID="publicKeyID",i.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+i.TABLE_NAME+" ("+i._ID+" INTEGER PRIMARY KEY,"+i.COLUMN_NAME_PARTNER_ID+s.DbConstants.SPACE+s.DbConstants.TEXT_TYPE+" UNIQUE NOT NULL"+s.DbConstants.COMMA_SEP+i.COLUMN_NAME_KEY+s.DbConstants.SPACE+s.DbConstants.TEXT_TYPE+" NOT NULL"+s.DbConstants.COMMA_SEP+i.COLUMN_NAME_KEY_ID+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+" NOT NULL )",i.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+i.TABLE_NAME;var d,l,f=n(2);(l=d||(d={}))._ID="_id",l.TABLE_NAME="notifications",l.COLUMN_NAME_MESSAGE_ID="message_id",l.COLUMN_NAME_EXPIRY_TIME="expiry_time",l.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME="display_time",l.COLUMN_NAME_NOTIFICATION_RECEIVED_AT="received_at",l.COLUMN_NAME_NOTIFICATION_JSON="notification_json",l.COLUMN_NAME_IS_READ="is_read",l.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+l.TABLE_NAME+" ("+l._ID+" INTEGER PRIMARY KEY,"+l.COLUMN_NAME_MESSAGE_ID+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+s.DbConstants.COMMA_SEP+l.COLUMN_NAME_EXPIRY_TIME+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+s.DbConstants.COMMA_SEP+l.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+s.DbConstants.COMMA_SEP+l.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+s.DbConstants.COMMA_SEP+l.COLUMN_NAME_NOTIFICATION_JSON+s.DbConstants.SPACE+s.DbConstants.TEXT_TYPE+s.DbConstants.COMMA_SEP+l.COLUMN_NAME_IS_READ+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+" )",l.deleteTable=()=>"DROP TABLE IF EXISTS "+l.TABLE_NAME;var h,E,p=n(24);(E=h||(h={})).TABLE_NAME="error_stack",E._ID="_id",E.COLUMN_NAME_APP_VERSION="app_version",E.COLUMN_NAME_PAGE_ID="page_id",E.COLUMN_NAME_TIME_STAMP="time_stamp",E.COLUMN_NAME_ERROR_LOG="error_log",E.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+E.TABLE_NAME+" ("+E._ID+" INTEGER PRIMARY KEY"+s.DbConstants.COMMA_SEP+E.COLUMN_NAME_APP_VERSION+s.DbConstants.SPACE+s.DbConstants.TEXT_TYPE+s.DbConstants.COMMA_SEP+E.COLUMN_NAME_PAGE_ID+s.DbConstants.SPACE+s.DbConstants.TEXT_TYPE+s.DbConstants.COMMA_SEP+E.COLUMN_NAME_TIME_STAMP+s.DbConstants.SPACE+s.DbConstants.INT_TYPE+s.DbConstants.COMMA_SEP+E.COLUMN_NAME_ERROR_LOG+s.DbConstants.SPACE+s.DbConstants.TEXT_TYPE+" )",E.deleteTable=()=>"DROP TABLE IF EXISTS"+E.TABLE_NAME;var _=n(26),S=n(27),b=n(22),O=n(28),v=n(53),C=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class g extends s.Migration{constructor(){super(1,16)}apply(e){return C(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise()))}))}queries(){return[a.c.getCreateEntry(),a.d.getCreateEntry(),a.e.getCreateEntry(),a.a.getCreateEntry(),c.g.getCreateEntry(),c.f.getCreateEntry(),c.c.getCreateEntry(),r.getCreateEntry(),f.b.getCreateEntry(),c.d.getCreateEntry(),c.e.getCreateEntry(),f.a.getCreateEntry(),f.c.getCreateEntry(),d.getCreateEntry(),u.a.getCreateEntry(),u.b.getCreateEntry(),p.a.getCreateEntry(),f.d.getCreateEntry(),h.getCreateEntry(),_.a.getCreateEntry(),S.a.getCreateEntry(),b.a.getCreateEntry(),O.a.getCreateEntry(),v.a.getCreateEntry()]}}class A{constructor(){this.query=""}where(e){return this.query+=e.trim(),new A.WhereDecorator(this)}build(){return this.query}}A.ConstraintDecorator=class{constructor(e){this.queryBuilder=e}and(){return this.queryBuilder.query+=" AND ",this.queryBuilder}or(){return this.queryBuilder.query+=" OR ",this.queryBuilder}end(){return this.queryBuilder}},A.WhereDecorator=class{constructor(e){this.queryBuilder=e}args(e){return e.forEach(e=>{this.interpolate(e)}),new A.ConstraintDecorator(this.queryBuilder)}interpolate(e){isNaN(e)&&(e='"'+e+'"'),this.queryBuilder.query=this.queryBuilder.query.replace("?",e)}};var T=n(6),N=n(5),y=n(3),m=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},I=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},M=function(e,t){return function(n,r){t(n,r,e)}},D=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let R=class{constructor(e,t,n){this.sdkConfig=e,this.dBVersion=t,this.appMigrationList=n,this.context=this.sdkConfig.dbConfig}update(e){return new y.Observable(t=>{db.update(e.table,e.selection||"",e.selectionArgs||[],e.modelJson,e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}init(){return D(this,void 0,void 0,(function*(){return new Promise(e=>{db.init(this.context.dbName,this.dBVersion,[],e=>D(this,void 0,void 0,(function*(){"onCreate"===e.method?yield this.onCreate():"onUpgrade"===e.method&&(yield this.onUpgrade(e.oldVersion,e.newVersion))}))),this.hasInitialized().subscribe(()=>{e(void 0)})})}))}hasInitialized(){return this.execute("DROP TABLE IF EXISTS dummy_init_table")}delete(e){const t=`\n DELETE FROM ${e.table}\n WHERE ${(new A).where(e.selection).args(e.selectionArgs).end().build()}\n `;return new y.Observable(n=>{db.execute(t,e.useExternalDb||!1,e=>{n.next(e),n.complete()},e=>{n.error(e)})})}onCreate(){return D(this,void 0,void 0,(function*(){return(new g).apply(this)}))}onUpgrade(e,t){return D(this,void 0,void 0,(function*(){for(const n of this.appMigrationList){let r;r=n instanceof s.Migration?n:n(),console.log("Migration",r),r.required(e,t)&&(yield r.apply(this))}}))}execute(e,t){return new y.Observable(n=>{db.execute(e,t||!1,e=>{n.next(e),n.complete()},e=>{n.error(e)})})}read(e){return new y.Observable(t=>{db.read(!!e.distinct,e.table,e.columns||[],e.selection||"",e.selectionArgs||[],e.groupBy||"",e.having||"",e.orderBy||"",e.limit||"",e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}insert(e){return new y.Observable(t=>{db.insert(e.table,e.modelJson,e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}beginTransaction(){db.beginTransaction()}endTransaction(e,t){db.endTransaction(e,t||!1)}copyDatabase(e){return new y.Observable(t=>{db.copyDatabase(e,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}open(e){return new Promise((t,n)=>{db.open(e,e=>{t(e)},e=>{n()})})}};R=m([Object(T.injectable)(),M(0,Object(T.inject)(N.b.SDK_CONFIG)),M(1,Object(T.inject)(N.b.DB_VERSION)),M(2,Object(T.inject)(N.b.DB_MIGRATION_LIST)),I("design:paramtypes",[Object,Number,Array])],R);var P=n(10),L=n(29),w=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},U=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},j=function(e,t){return function(n,r){t(n,r,e)}};let F=class{constructor(e,t,n,r){this.sdkConfig=e,this.deviceInfo=t,this.appInfo=n,this.codePushExperimentService=r,this.apiConfig=this.sdkConfig.apiConfig}decorate(e,t,n,r=0,i,o,s){const{uid:a,sid:c}=t;return e.ets+=r,e.mid||(e.mid=L.a.generateUniqueId()),a?this.patchActor(e,a):this.patchActor(e,""),this.patchContext(e,c,i,o,s),e.context.cdata=[...e.context.cdata,{id:t.managedSession?t.managedSession.sid:t.sid,type:"UserSession"}],e}patchActor(e,t){e.actor||(e.actor=new P.Actor);const n=e.actor;n.id||(n.id=t),n.type||(n.type=P.Actor.TYPE_USER)}patchContext(e,t,n,r,i){e.context||(e.context=new P.Context),e.context=this.buildContext(t,n,e.context,r,i)}patchPData(e){e.pdata||(e.pdata=new P.ProducerData);const t=e.pdata;t.id||(t.id=this.apiConfig.api_authentication.producerId);const n=t.pid;n?t.pid=n:this.apiConfig.api_authentication.producerUniqueId?t.pid=this.apiConfig.api_authentication.producerUniqueId:t.pid="sunbird.android",t.ver||(t.ver=this.appInfo.getVersionName())}prepare(e,t){return{event:JSON.stringify(e),event_type:e.eid,timestamp:Date.now(),priority:1}}buildContext(e,t,n,r,i){n.channel=t,this.patchPData(n),n.env||(n.env="app");const o=this.codePushExperimentService.getExperimentKey();return"string"==typeof o&&(n.pdata.pid=n.pdata.pid+"-"+o),n.sid=e,n.did=this.deviceInfo.getDeviceID(),t!==this.apiConfig.api_authentication.channelId&&(n.rollup={l1:t}),n.cdata=n.cdata?n.cdata.concat(r||[]):r||[],n.cdata=n.cdata?n.cdata.concat(i||[]):i||[],n}};F=w([Object(T.injectable)(),j(0,Object(T.inject)(N.b.SDK_CONFIG)),j(1,Object(T.inject)(N.b.DEVICE_INFO)),j(2,Object(T.inject)(N.b.APP_INFO)),j(3,Object(T.inject)(N.b.CODEPUSH_EXPERIMENT_SERVICE)),U("design:paramtypes",[Object,Object,Object,Object])],F);var x=n(75),k=n(18),B=n(9),V=n(14);class Y{constructor(e){this.dbService=e}execute(e){const t=new o.Response;return this.dbService.open(e.sourceDBFilePath).then(()=>this.dbService.read({table:a.b.TABLE_NAME,useExternalDb:!0}).toPromise()).then(n=>{if(!n||!n.length)throw t.errorMesg=B.ErrorCode.IMPORT_FAILED.valueOf(),t;const r={};n.forEach(e=>{r[e.key]=e.value}),e.metadata=r;const i=this.getImportTypes(r);if(i&&V.a.contains(i,"telemetry")){const e=r.export_id,t=r.did;return this.dbService.read({table:c.c.TABLE_NAME,selection:`${c.c.COLUMN_NAME_IMPORTED_ID} = ?\n AND ${c.c.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[e,t]}).toPromise()}throw t.errorMesg=B.ErrorCode.IMPORT_FAILED.valueOf(),t}).then(n=>{if(n&&n.length)throw t.errorMesg=B.ErrorCode.IMPORT_FAILED.valueOf(),t;return t.body=e,t})}getImportTypes(e){let t=[];return e.hasOwnProperty("types")&&(t=e.types),t}}var G=n(101),H=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class q{constructor(e){this.dbService=e}execute(e){const t=new o.Response;return this.dbService.read({table:a.d.TABLE_NAME,useExternalDb:!0}).toPromise().then(e=>this.saveProccessedTelemetryToDB(e)).then(()=>(t.body=e,t))}saveProccessedTelemetryToDB(e){return H(this,void 0,void 0,(function*(){e.forEach(e=>H(this,void 0,void 0,(function*(){yield this.dbService.insert({table:a.d.TABLE_NAME,modelJson:e})})))}))}}class ${constructor(e){this.dbService=e}execute(e){const t=new o.Response,n=e.metadata.export_id,r=e.metadata.did,i={imported_id:n,device_id:r,count:e.metadata.events_count};return this.dbService.read({table:c.c.TABLE_NAME,selection:`${c.c.COLUMN_NAME_IMPORTED_ID} = ? AND ${c.c.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[n,r],limit:"1"}).toPromise().then(e=>e&&e.length?this.dbService.update({table:c.c.TABLE_NAME,modelJson:i}).toPromise():this.dbService.insert({table:c.c.TABLE_NAME,modelJson:i}).toPromise()).then(()=>(t.body=e,t))}}class K{constructor(e,t){this.dbService=e,this.telemetryService=t}execute(e){const t=new o.Response;return this.dbService.read({table:c.c.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:P.ShareItemType.TELEMETRY,origin:e[c.c.COLUMN_NAME_DEVICE_ID],identifier:e[c.c.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:P.ShareDirection.IN,type:P.ShareType.FILE.valueOf(),items:t,env:"sdk"};return this.telemetryService.share(n).toPromise()}).then(()=>(t.body=e,t))}}var z=n(43),W=n(0),X=n(11),J=n(33),Q=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Z{constructor(e,t){this.telemetryService=e,this.sharedPreferences=t,this.shouldSync=!1}static generateDownloadSpeedTelemetry(e){return Q(this,void 0,void 0,(function*(){const t=yield new Promise((e,t)=>{downloadManager.fetchSpeedLog?downloadManager.fetchSpeedLog((t,n)=>e(n),t):cordova.exec(e,t,"DownloadManagerPlugin","fetchSpeedLog",[])}),n={32:"0-32",64:"32-64",128:"64-128",256:"128-256",512:"256-512",1024:"512-1024",1536:"1024-1536",2048:"1536-2048",2560:"2048-2560",3072:"2560-3072",3584:"3072-3584",4096:"3584-above"};if(!Object.keys(null==t?void 0:t.distributionInKBPS).length)return;const r={duration:e/1e3,totalKBDownloaded:null==t?void 0:t.totalKBdownloaded,distributionInKBPS:Object.keys(n).reduce((e,r)=>((null==t?void 0:t.distributionInKBPS[r])?e[n[r]]=t.distributionInKBPS[r]:e[n[r]]=0,e),{})};return J.a.log.interact({type:P.InteractType.OTHER,subType:P.InteractSubType.NETWORK_SPEED,env:"sdk",pageId:"sdk",id:"sdk",valueMap:r}).pipe(Object(W.mapTo)(void 0)).toPromise()}))}getSyncMode(){return this.sharedPreferences.getString(X.o.KEY_AUTO_SYNC_MODE).pipe(Object(W.map)(e=>e))}setSyncMode(e){return this.sharedPreferences.putString(X.o.KEY_AUTO_SYNC_MODE,e)}start(e){return this.shouldSync=!0,Object(y.interval)(e).pipe(Object(W.tap)(t=>{t*e%Z.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL==0&&"ios"!==window.device.platform.toLowerCase()&&Z.generateDownloadSpeedTelemetry(e)}),Object(W.filter)(()=>this.shouldSync),Object(W.tap)(()=>this.telemetryService.sync().pipe(Object(W.tap)(e=>{console.log("AUTO_SYNC_INVOKED_SYNC----------------------------------------------",e)}),Object(W.catchError)(e=>(console.error(e),Object(y.of)(void 0)))).toPromise()),Object(W.mapTo)(void 0))}pause(){this.shouldSync=!1}continue(){this.shouldSync=!0}}Z.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL=6e4;var ee=n(72),te=n(15),ne=n(19);class re extends ne.a{constructor(e){super(e,"AUTH_TOKEN_REFRESH_ERROR"),Object.setPrototypeOf(this,re.prototype)}}var ie=n(36),oe=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class se{constructor(e,t,n,r){this.apiConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r}refreshSession(){return oe(this,void 0,void 0,(function*(){let e,t=yield this.getSessionData();if(!t)throw new te.NoActiveSessionError("No Active Sessions found");e="ios"===window.device.platform.toLowerCase()?(new o.Request.Builder).withPath("/auth/v1/refresh/token").withType(o.HttpRequestType.POST).withSerializer(o.HttpSerializer.URLENCODED).withHeaders({"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}).withBearerToken(!0).withBody({refresh_token:t.refresh_token}).build():(new o.Request.Builder).withPath("/auth/v1/refresh/token").withType(o.HttpRequestType.POST).withSerializer(o.HttpSerializer.URLENCODED).withBearerToken(!0).withBody({refresh_token:t.refresh_token}).build();try{yield this.apiService.fetch(e).toPromise().catch(e=>{if(o.HttpClientError.isInstance(e)&&e.response.responseCode===o.ResponseCode.HTTP_BAD_REQUEST)throw new re(e.message);throw e}).then(e=>oe(this,void 0,void 0,(function*(){if(e.body.result.access_token&&e.body.result.refresh_token){let n=yield ie.a.decodeJWT(e.body.result.access_token);const r=JSON.parse(n),i=3===r.sub.split(":").length?r.sub.split(":").pop():r.sub,o=yield this.getSessionData();return t=Object.assign(Object.assign({},e.body.result),{userToken:o?o.userToken:i,managed_access_token:o?o.managed_access_token:void 0,accessTokenExpiresOn:1e3*r.exp}),yield this.sharedPreferences.putString(X.c.KEY_OAUTH_SESSION,JSON.stringify(t)).toPromise()}throw new re("No token found in server response")})))}catch(e){throw e instanceof re&&this.eventsBusService.emit({namespace:k.EventNamespace.ERROR,event:{type:k.ErrorEventType.AUTH_TOKEN_REFRESH_ERROR,payload:e}}),e}}))}startSession(e){return oe(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(X.c.KEY_OAUTH_SESSION,JSON.stringify(e)).toPromise()}))}endSession(){return oe(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(X.c.KEY_OAUTH_SESSION,"").toPromise()}))}getSessionData(){return oe(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(X.c.KEY_OAUTH_SESSION).toPromise();if(e)return JSON.parse(e)}))}}var ae=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ce=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ue=function(e,t){return function(n,r){t(n,r,e)}},de=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let le=class{constructor(e,t,n,r,i,o,s,a,c,u,d,l,f,h,E,p,_,S){this.dbService=e,this.decorator=t,this.profileService=n,this.groupService=r,this.keyValueStore=i,this.apiService=o,this.sdkConfig=s,this.deviceInfo=a,this.eventsBusService=c,this.fileService=u,this.frameworkService=d,this.networkInfoService=l,this.errorLoggerService=f,this.sharedPreferences=h,this.appInfoService=E,this.deviceRegisterService=p,this.courseService=_,this.networkQueue=S,this.campaignParameters=[],this.globalCdata=[],this.telemetryConfig=this.sdkConfig.telemetryConfig,this._lastSyncedTimestamp$=new y.BehaviorSubject(void 0)}get autoSync(){return this.telemetryAutoSyncService||(this.telemetryAutoSyncService=new Z(this,this.sharedPreferences)),this.telemetryAutoSyncService}preInit(){return Object(y.defer)(()=>de(this,void 0,void 0,(function*(){this.getInitialUtmParameters().then(e=>{e&&e.length&&this.updateCampaignParameters(e)})})))}onInit(){return Object(y.combineLatest)([Object(y.defer)(()=>de(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(X.o.KEY_LAST_SYNCED_TIME_STAMP).toPromise();if(e)try{this._lastSyncedTimestamp$.next(parseInt(e,10))}catch(e){console.error(e)}}))),new y.Observable(e=>{sbsync.onAuthorizationError(t=>de(this,void 0,void 0,(function*(){const n=t.network_queue_error;n&&e.next(n)})),e=>de(this,void 0,void 0,(function*(){})))}).pipe(Object(W.mergeMap)(e=>"API_TOKEN_EXPIRED"===e?new ee.a(this.sdkConfig.apiConfig,this.apiService,this.deviceInfo).refreshAuthToken().pipe(Object(W.mergeMap)(e=>this.sharedPreferences.putString(X.a.KEY_API_TOKEN,e)),Object(W.catchError)(()=>Object(y.of)(void 0))):Object(y.from)(new se(this.sdkConfig.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService).refreshSession()).pipe(Object(W.catchError)(()=>Object(y.of)(void 0)))))]).pipe(Object(W.mapTo)(void 0))}saveTelemetry(e){return Object(y.defer)(()=>{try{const t=JSON.parse(e);return this.decorateAndPersist(t)}catch(e){return console.error(e),Object(y.of)(!1)}})}audit({env:e,actor:t,currentState:n,updatedProperties:r,type:i,objId:o,objType:s,objVer:a,correlationData:c,rollUp:u}){const d=new P.SunbirdTelemetry.Audit(e,t,n,r,i,o,s,a,c,u);return this.decorateAndPersist(d)}end({type:e,mode:t,duration:n,pageId:r,summaryList:i,env:o,objId:s,objType:a,objVer:c,rollup:u,correlationData:d}){const l=new P.SunbirdTelemetry.End(e,t,n,r,i,o,s,a,c,u,d);return this.decorateAndPersist(l)}error(e){const t=new P.SunbirdTelemetry.Error(e.errorCode,e.errorType,e.stacktrace,e.pageId);return this.errorLoggerService.logError(e).toPromise().catch(e=>console.error(e)),this.decorateAndPersist(t)}impression({type:e,subType:t,pageId:n,visits:r,env:i,objId:o,objType:s,objVer:a,rollup:c,correlationData:u}){const d=new P.SunbirdTelemetry.Impression(e,t,n,r,i,o,s,a,c,u);return this.decorateAndPersist(d)}interact({type:e,subType:t,id:n,pageId:r,pos:i,env:o,rollup:s,valueMap:a,correlationData:c,objId:u,objType:d,objVer:l}){const f=new P.SunbirdTelemetry.Interact(e,t,n,r,i,a,o,u,d,l,s,c);return this.decorateAndPersist(f)}log({type:e,level:t,message:n,pageId:r,params:i,env:o,actorType:s}){const a=new P.SunbirdTelemetry.Log(e,t,n,r,i,o,s);return this.decorateAndPersist(a)}share({dir:e,type:t,items:n,correlationData:r,objId:i,objType:o,objVer:s,rollUp:a}){const c=new P.SunbirdTelemetry.Share(e,t,[],r,i,o,s,a);return n.forEach(e=>{c.addItem(e.type,e.origin,e.identifier,e.pkgVersion,e.transferCount,e.size)}),this.decorateAndPersist(c)}feedback({rating:e,comments:t,env:n,objId:r,objType:i,objVer:o,commentid:s,commenttxt:a}){const c=new P.SunbirdTelemetry.Feedback(e,t,n,r,i,o,s,a);return this.decorateAndPersist(c)}start({type:e,deviceSpecification:t,loc:n,mode:r,duration:i,pageId:o,env:s,objId:a,objType:c,objVer:u,rollup:d,correlationData:l}){const f=new P.SunbirdTelemetry.Start(e,t,n,r,i,o,s,a,c,u,d,l);return this.decorateAndPersist(f)}summary({type:e,starttime:t,endtime:n,timespent:r,pageviews:i,interactions:o,env:s,mode:a,envsummary:c,eventsummary:u,pagesummary:d,extra:l,correlationData:f,objId:h,objType:E,objVer:p,rollup:_}){const S=new P.SunbirdTelemetry.Summary(e,t,n,r,i,o,s,a,c,u,d,l,f,h,E,p,_);return this.decorateAndPersist(S)}interrupt({type:e,pageId:t}){const n=new P.SunbirdTelemetry.Interrupt(e,t);return this.decorateAndPersist(n)}importTelemetry(e){const t={sourceDBFilePath:e.sourceFilePath};return Object(y.from)(new Y(this.dbService).execute(t).then(e=>new q(this.dbService).execute(e.body)).then(e=>new $(this.dbService).execute(e.body)).then(e=>new $(this.dbService).execute(e.body)).then(e=>new K(this.dbService,this).execute(e.body)).then(e=>!0).catch(e=>(console.error(e),!1)))}getTelemetryStat(){const e=`\n SELECT COUNT(*) as TELEMETRY_COUNT\n FROM ${a.c.TABLE_NAME}\n `,t=`\n SELECT SUM(${a.d.COLUMN_NAME_NUMBER_OF_EVENTS}) as PROCESSED_TELEMETRY_COUNT\n FROM ${a.d.TABLE_NAME}\n `;return Object(y.zip)(this.dbService.execute(e),this.dbService.execute(t),this.keyValueStore.getValue(X.o.KEY_LAST_SYNCED_TIME_STAMP)).pipe(Object(W.map)(e=>({unSyncedEventCount:e[0][0].TELEMETRY_COUNT+e[1][0].PROCESSED_TELEMETRY_COUNT,lastSyncTime:e[2]?parseInt(e[2],10):0})))}resetDeviceRegisterTTL(){return new x.a(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService,this.networkQueue).resetDeviceRegisterTTL()}sync(e={ignoreSyncThreshold:!1,ignoreAutoSyncMode:!1}){return this.networkInfoService.networkStatus$.pipe(Object(W.take)(1),Object(W.mergeMap)(t=>(t===z.NetworkStatus.ONLINE&&(e.ignoreSyncThreshold=!0),Object(y.of)(e))),Object(W.mergeMap)(e=>new x.a(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService,this.networkQueue).handle(e).pipe(Object(W.tap)(e=>{if(!e.error&&e.syncedEventCount){const e=Date.now();this.sharedPreferences.putString(X.o.KEY_LAST_SYNCED_TIME_STAMP,e+"").toPromise(),this._lastSyncedTimestamp$.next(e)}}))))}lastSyncedTimestamp(){return this._lastSyncedTimestamp$.asObservable()}buildContext(){return this.profileService.getActiveProfileSession().pipe(Object(W.map)(e=>this.decorator.buildContext(e.sid,this.frameworkService.activeChannelId,new P.Context)))}decorateAndPersist(e){return Object(y.zip)(this.profileService.getActiveProfileSession(),this.groupService.getActiveGroupSession()).pipe(Object(W.mergeMap)(t=>{const n=t[0],r=t[1];return this.keyValueStore.getValue(x.a.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY).pipe(Object(W.mergeMap)(t=>{t=t||"0";const i={table:a.c.TABLE_NAME,modelJson:this.decorator.prepare(this.decorator.decorate(e,n,r&&r.gid,Number(t),this.frameworkService.activeChannelId,this.campaignParameters,this.globalCdata),1)};return this.dbService.insert(i).pipe(Object(W.tap)(()=>this.eventsBusService.emit({namespace:k.EventNamespace.TELEMETRY,event:{type:G.a.SAVE,payload:e}})),Object(W.map)(e=>e>1))}))}))}updateCampaignParameters(e){this.campaignParameters=e}populateGlobalCorRelationData(e){this.globalCdata=e}getInitialUtmParameters(){return new Promise((e,t)=>{try{sbutility.getUtmInfo(t=>{e(t.val)},e=>{t(e)})}catch(e){t(e)}})}};le=ae([Object(T.injectable)(),ue(0,Object(T.inject)(N.b.DB_SERVICE)),ue(1,Object(T.inject)(N.b.TELEMETRY_DECORATOR)),ue(2,Object(T.inject)(N.b.PROFILE_SERVICE)),ue(3,Object(T.inject)(N.b.GROUP_SERVICE_DEPRECATED)),ue(4,Object(T.inject)(N.b.KEY_VALUE_STORE)),ue(5,Object(T.inject)(N.b.API_SERVICE)),ue(6,Object(T.inject)(N.b.SDK_CONFIG)),ue(7,Object(T.inject)(N.b.DEVICE_INFO)),ue(8,Object(T.inject)(N.b.EVENTS_BUS_SERVICE)),ue(9,Object(T.inject)(N.b.FILE_SERVICE)),ue(10,Object(T.inject)(N.b.FRAMEWORK_SERVICE)),ue(11,Object(T.inject)(N.b.NETWORKINFO_SERVICE)),ue(12,Object(T.inject)(N.b.ERROR_LOGGER_SERVICE)),ue(13,Object(T.inject)(N.b.SHARED_PREFERENCES)),ue(14,Object(T.inject)(N.b.APP_INFO)),ue(15,Object(T.inject)(N.b.DEVICE_REGISTER_SERVICE)),ue(16,Object(T.inject)(N.b.COURSE_SERVICE)),ue(17,Object(T.inject)(N.b.NETWORK_QUEUE)),ce("design:paramtypes",[s.DbService,P.TelemetryDecorator,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object])],le);var fe,he=n(13),Ee=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},pe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},_e=function(e,t){return function(n,r){t(n,r,e)}},Se=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let be=fe=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r,this.apiConfig=this.sdkConfig.apiConfig,this.authUtil=new se(this.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService)}onInit(){return this.sharedPreferences.addListener(X.c.KEY_OAUTH_SESSION,e=>Se(this,void 0,void 0,(function*(){if(e)try{const t=JSON.parse(yield this.sharedPreferences.getString(X.m.KEY_USER_SESSION).toPromise()),n=JSON.parse(e);he.CsModule.instance.config.core.api.authentication.userToken=n.access_token,he.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?n.managed_access_token:void 0}catch(e){console.error(e),he.CsModule.instance.config.core.api.authentication.userToken=void 0,he.CsModule.instance.config.core.api.authentication.managedUserToken=void 0}else he.CsModule.instance.config.core.api.authentication.userToken=void 0,he.CsModule.instance.config.core.api.authentication.managedUserToken=void 0;he.CsModule.instance.updateConfig(he.CsModule.instance.config)}))),this.sharedPreferences.addListener(X.m.KEY_USER_SESSION,e=>Se(this,void 0,void 0,(function*(){if(e)try{const t=JSON.parse(e),n=JSON.parse(yield this.sharedPreferences.getString(X.c.KEY_OAUTH_SESSION).toPromise());he.CsModule.instance.config.core.api.authentication.userToken=n.access_token,he.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?n.managed_access_token:void 0}catch(e){console.error(e),he.CsModule.instance.config.core.api.authentication.userToken=void 0,he.CsModule.instance.config.core.api.authentication.managedUserToken=void 0}else he.CsModule.instance.config.core.api.authentication.userToken=void 0,he.CsModule.instance.config.core.api.authentication.managedUserToken=void 0;he.CsModule.instance.updateConfig(he.CsModule.instance.config)}))),Object(y.combineLatest)([Object(y.defer)(()=>this.getSession()).pipe(Object(W.mergeMap)(e=>Se(this,void 0,void 0,(function*(){if(!e)return;const t=JSON.parse(yield this.sharedPreferences.getString(X.m.KEY_USER_SESSION).toPromise());he.CsModule.instance.config.core.api.authentication.userToken=e.access_token,he.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?e.managed_access_token:void 0,he.CsModule.instance.updateConfig(he.CsModule.instance.config)})))),Object(y.defer)(()=>this.onAccessTokenNearingExpiry()).pipe(Object(W.mergeMap)(e=>Se(this,void 0,void 0,(function*(){if(e)return this.refreshSession().toPromise()}))))]).pipe(Object(W.mapTo)(void 0))}setSession(e){return Object(y.from)(e.provide().then(e=>{if(!e.access_token)throw this.authUtil.endSession(),e;this.authUtil.startSession(e),this.authUtil.refreshSession()}))}getSession(){return Object(y.from)(this.authUtil.getSessionData())}resignSession(){return Object(y.from)(this.authUtil.endSession())}refreshSession(){return Object(y.from)(this.authUtil.refreshSession())}onAccessTokenNearingExpiry(){const e=Object(y.defer)(()=>this.getSession()),t=new y.Observable(e=>{document.addEventListener("resume",()=>{setTimeout(()=>{e.next()},0)},!1)}).pipe(Object(W.mergeMap)(()=>this.getSession()));return Object(y.merge)(e,t).pipe(Object(W.map)(e=>!(!e||!e.accessTokenExpiresOn)&&e.accessTokenExpiresOn-Date.now()<fe.ACCESS_TOKEN_NEARING_EXPIRY_DELTA),Object(W.distinctUntilChanged)())}};be.ACCESS_TOKEN_NEARING_EXPIRY_DELTA=36e5,be=fe=Ee([Object(T.injectable)(),_e(0,Object(T.inject)(N.b.SDK_CONFIG)),_e(1,Object(T.inject)(N.b.API_SERVICE)),_e(2,Object(T.inject)(N.b.SHARED_PREFERENCES)),_e(3,Object(T.inject)(N.b.EVENTS_BUS_SERVICE)),pe("design:paramtypes",[Object,Object,Object,Object])],be);var Oe=n(34),ve=n(79),Ce=n(42),ge=n(8);class Ae{constructor(e){this.dbService=e}getContentMarker(e,t){const n=`SELECT * FROM ${f.d.TABLE_NAME}\n ${ge.a.getUidnIdentifierFiler(t,e)}\n ORDER BY ${f.d.COLUMN_NAME_EPOCH_TIMESTAMP} DESC `;return this.dbService.execute(n).pipe(Object(W.map)(e=>this.mapDBEntriesToContentMarkerDetails(e)))}mapDBEntriesToContentMarkerDetails(e){return e.map(e=>({contentId:e[f.d.COLUMN_NAME_CONTENT_IDENTIFIER],uid:e[f.d.COLUMN_NAME_UID],extraInfoMap:e[f.d.COLUMN_NAME_EXTRA_INFO]&&JSON.parse(e[f.d.COLUMN_NAME_EXTRA_INFO]),marker:e[f.d.COLUMN_NAME_MARKER]}))}}var Te=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},Ne=f.b.COLUMN_NAME_MIME_TYPE,ye=f.b.COLUMN_NAME_VISIBILITY;class me{constructor(e,t,n,r,i,o){this.contentFeedbackService=e,this.profileService=t,this.apiService=n,this.contentServiceConfig=r,this.dbService=i,this.eventsBusService=o,this.GET_CONTENT_DETAILS_ENDPOINT="/read"}static getReadContentQuery(e){return{table:f.b.TABLE_NAME,selection:(new A).where("? = ?").args([f.b.COLUMN_NAME_IDENTIFIER,e]).end().build(),limit:"1"}}static isUnit(e){return e[Ne]===B.MimeType.COLLECTION&&e[ye]===B.Visibility.PARENT}handle(e){return e.emitUpdateIfAny=void 0===e.emitUpdateIfAny||e.emitUpdateIfAny,this.fetchFromDB(e.contentId).pipe(Object(W.mergeMap)(t=>t?Object(y.of)(Ce.a.mapContentDBEntryToContent(t)).pipe(Object(W.mergeMap)(t=>("string"==typeof t.contentData.originData&&(t.contentData.originData=ge.a.getParseErrorObject(t.contentData.originData)),t.contentData.trackable&&"string"==typeof t.contentData.trackable&&(t.contentData.trackable=JSON.parse(t.contentData.trackable)),this.decorateContent({content:t,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker}))),Object(W.tap)(n=>Te(this,void 0,void 0,(function*(){if(!e.emitUpdateIfAny||me.isUnit(t))return;let r=!1;const i=t[f.b.COLUMN_NAME_SERVER_DATA]&&JSON.parse(t[f.b.COLUMN_NAME_SERVER_DATA]);i&&i.streamingUrl||(r=!0);const o=yield this.fetchFromServer(e).toPromise();t[f.b.COLUMN_NAME_SERVER_DATA]=JSON.stringify(o),t[f.b.COLUMN_NAME_SERVER_LAST_UPDATED_ON]=o.lastUpdatedOn,t[f.b.COLUMN_NAME_AUDIENCE]=ge.a.readAudience(o),yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise(),ge.a.isUpdateAvailable(o,n.contentData)&&this.eventsBusService.emit({namespace:k.EventNamespace.CONTENT,event:{type:B.ContentEventType.UPDATE,payload:{contentId:n.contentData.identifier,size:o.size}}}),o&&this.eventsBusService.emit({namespace:k.EventNamespace.CONTENT,event:{type:B.ContentEventType.SERVER_CONTENT_DATA,payload:{contentId:o.identifier,streamingUrl:o.streamingUrl,licenseDetails:o.licenseDetails,size:o.size,serverContentData:o}}})})))):this.fetchAndDecorate(e)))}fetchFromDB(e){return this.dbService.read({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e],limit:"1"}).pipe(Object(W.map)(e=>e[0]))}fetchFromDBForAll(e){return this.dbService.read({table:f.b.TABLE_NAME,selection:`${f.b.COLUMN_NAME_IDENTIFIER} IN (${e})`})}fetchFromServer(e){switch(e.objectType){case"QuestionSet":return this.apiService.fetch((new o.Request.Builder).withHost(this.contentServiceConfig.host).withType(o.HttpRequestType.GET).withPath(this.contentServiceConfig.questionSetReadApiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withBearerToken(!1).build()).pipe(Object(W.map)(e=>e.body.result.questionset));case"Question":return this.apiService.fetch((new o.Request.Builder).withHost(this.contentServiceConfig.host).withType(o.HttpRequestType.GET).withPath(this.contentServiceConfig.questionReadApiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withBearerToken(!1).build()).pipe(Object(W.map)(e=>e.body.result.question));default:return this.apiService.fetch((new o.Request.Builder).withHost(this.contentServiceConfig.host).withType(o.HttpRequestType.GET).withPath(this.contentServiceConfig.apiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withParameters({licenseDetails:"name,url,description"}).withBearerToken(!0).build()).pipe(Object(W.map)(e=>e.body.result.content))}}fetchAndDecorate(e){return this.fetchFromServer(e).pipe(Object(W.map)(e=>Ce.a.mapServerResponseToContent(e)),Object(W.mergeMap)(t=>this.decorateContent({content:t,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker})))}decorateContent(e){return Object(y.of)(e.content).pipe(Object(W.mergeMap)(t=>e.attachContentAccess?this.attachContentAccess(t):Object(y.of)(t)),Object(W.mergeMap)(t=>e.attachFeedback?this.attachFeedback(t):Object(y.of)(t)),Object(W.mergeMap)(t=>e.attachContentMarker?this.attachContentMarker(t):Object(y.of)(t)))}attachContentAccess(e){return this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(({uid:t})=>this.profileService.getAllContentAccess({contentId:e.identifier,uid:t}).pipe(Object(W.map)(t=>Object.assign(Object.assign({},e),{contentAccess:t})))))}attachFeedback(e){return this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(({uid:t})=>this.contentFeedbackService.getFeedback({contentId:e.identifier,uid:t}).pipe(Object(W.map)(t=>Object.assign(Object.assign({},e),{contentFeedback:t})))))}attachContentMarker(e){return this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(({uid:t})=>new Ae(this.dbService).getContentMarker(e.identifier,t).pipe(Object(W.map)(t=>Object.assign(Object.assign({},e),{contentMarkers:t})))))}}var Ie=n(16);class Me{constructor(e){this._stack=e||[]}get count(){return this._stack.length}push(e){this._stack.push(e)}pop(){return this._stack.pop()}clear(){this._stack=[]}isEmpty(){return 0===this._stack.length}addAll(e){this._stack=[...this._stack,...e]}}var De=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Re{constructor(e,t,n,r){this.dbService=e,this.getContentDetailsHandler=t,this.appConfig=n,this.fileService=r}fetchChildrenOfContent(e,t,n,r,i){return De(this,void 0,void 0,(function*(){const o=Ce.a.mapContentDBEntryToContent(e),s=yield this.getSortedChildrenList(e[f.b.COLUMN_NAME_LOCAL_DATA],Ie.a.ALL,t);if(s&&s.length){let a=[];if(a=a.concat(i),a.push({identifier:e[f.b.COLUMN_NAME_IDENTIFIER],contentType:e[f.b.COLUMN_NAME_CONTENT_TYPE],primaryCategory:e[f.b.COLUMN_NAME_PRIMARY_CATEGORY]}),o.hierarchyInfo=a,-1===r||n<=r){const e=[];for(const i of s){const o=i,s=yield this.fetchChildrenOfContent(o,t,n+1,r,a);s.contentData.appIcon&&!s.contentData.appIcon.startsWith("http")&&(s.contentData.appIcon="_app_file_".concat(s.basePath).concat(s.contentData.appIcon)),"application/json"===s.contentData.mimeType&&(s.contentData.artifactUrl="_app_file_".concat(s.basePath).concat(s.contentData.artifactUrl)),e.push(s)}o.children=e}}else o.hierarchyInfo=i;return o}))}getContentsKeyList(e){return De(this,void 0,void 0,(function*(){const t=[],n=new Me,r=[];let i,o="";for(n.push(e);!n.isEmpty();){if(i=n.pop(),ge.a.hasChildren(i[f.b.COLUMN_NAME_LOCAL_DATA])){(yield this.getSortedChildrenListOld(i[f.b.COLUMN_NAME_LOCAL_DATA],Ie.a.ALL)).forEach(e=>{n.push(e),r.push(i[f.b.COLUMN_NAME_IDENTIFIER].concat("/",e[f.b.COLUMN_NAME_IDENTIFIER]))})}if(o){let e;for(let e=o.split("/").length-1;e>=0;e--){const t=o.split("/")[e];if(V.a.contains(r,t.concat("/",i[f.b.COLUMN_NAME_IDENTIFIER])))break;o=o.substring(0,o.lastIndexOf("/"))}Ie.j.COLLECTION.valueOf()===i[f.b.COLUMN_NAME_MIME_TYPE]?o=o+"/"+i[f.b.COLUMN_NAME_IDENTIFIER]:(e=o+"/"+i[f.b.COLUMN_NAME_IDENTIFIER],t.push(e))}else o=i[f.b.COLUMN_NAME_IDENTIFIER]}return t}))}getContentFromDB(e,t,n){return De(this,void 0,void 0,(function*(){const e=[];let r;if(t){const i=t.split("/"),o=i.length;let s=!0;for(let t=0;t<o-1;t++){const n=yield this.getContentDetailsHandler.fetchFromDB(i[t]).toPromise();if(!n){s=!1;break}e.push({identifier:n[f.b.COLUMN_NAME_IDENTIFIER],contentType:n[f.b.COLUMN_NAME_CONTENT_TYPE],primaryCategory:n[f.b.COLUMN_NAME_PRIMARY_CATEGORY]})}if(s){const t=yield this.getContentDetailsHandler.fetchFromDB(i[o-1]).toPromise();if(t){r=Ce.a.mapContentDBEntryToContent(t,n),r.hierarchyInfo=e,r.rollup=ge.a.getContentRollup(r.identifier,r.hierarchyInfo);const i=ge.a.readCompatibilityLevel(r.contentData),o=ge.a.isCompatible(this.appConfig,i);r.isCompatible=o;const s=e.map(e=>e.identifier),a=V.a.joinPreservingQuotes(s);let c=yield this.getContentDetailsHandler.fetchFromDBForAll(a).toPromise();c=c.sort((e,t)=>s.indexOf(e.identifier)-s.indexOf(t.identifier));for(let t=0;t<c.length;t++){const n=c[t],i=JSON.parse(n[f.b.COLUMN_NAME_LOCAL_DATA]),o=ge.a.isTrackable(i);if(0===t&&1===o)break;if(1===o){n.identifier;let i=JSON.parse(JSON.stringify(e));i&&(i=i.slice(0,t),r.trackableParentInfo={identifier:n.identifier,hierarchyInfo:i});break}}}}}return r}))}getNextContentIdentifier(e,t,n){let r,i="";e.forEach(e=>{i=i?i.concat("/",e.identifier):e.identifier}),i=i.concat("/",t);const o=n.indexOf(i);return o>0&&(r=n[o-1]),r}getPreviousContentIdentifier(e,t,n){let r,i="";e.forEach(e=>{i=i?i.concat("/",e.identifier):e.identifier}),i=i.concat("/",t);const o=n.indexOf(i);return-1!==o&&o<n.length-1&&(r=n[o+1]),r}getSortedChildrenListOld(e,t){return De(this,void 0,void 0,(function*(){let n=JSON.parse(e).children;if(!n||!n.length)return[];n=n.sort((e,t)=>e.index-t.index);const r=[];let i="",o=0;n.forEach(e=>{r.push(e.identifier),i=i.concat(` WHEN '${e.identifier}' THEN ${o}`),o+=1});let s="";o>0&&(s=s.concat(` ORDER BY CASE ${f.b.COLUMN_NAME_IDENTIFIER} ${i} END`));let a="";switch(t){case Ie.a.DOWNLOADED.valueOf():a=" AND "+f.b.COLUMN_NAME_CONTENT_STATE+"='"+Ie.l.ARTIFACT_AVAILABLE+"'";break;case Ie.a.SPINE.valueOf():a=" AND "+f.b.COLUMN_NAME_CONTENT_STATE+"='"+Ie.l.ONLY_SPINE+"'";break;case Ie.a.ALL.valueOf():default:a=""}const c=`SELECT * FROM ${f.b.TABLE_NAME}\n WHERE ${f.b.COLUMN_NAME_IDENTIFIER}\n IN (${V.a.joinPreservingQuotes(r)}) ${a} ${s}`;return this.dbService.execute(c).toPromise()}))}getSortedChildrenList(e,t,n){return De(this,void 0,void 0,(function*(){let r=JSON.parse(e).children;if(!r||!r.length)return[];r=r.sort((e,t)=>e.index-t.index);let i=[];for(const e of r){const t=n.get(e.identifier);if(t)i.push(t);else{const t=`SELECT * FROM ${f.b.TABLE_NAME}\n WHERE ${f.b.COLUMN_NAME_IDENTIFIER} = '${e.identifier}'`,n=yield this.dbService.execute(t).toPromise();n.length&&i.push(n[0])}}switch(t){case Ie.a.DOWNLOADED.valueOf():i=i.filter(e=>e[f.b.COLUMN_NAME_CONTENT_STATE]=Ie.l.ARTIFACT_AVAILABLE);break;case Ie.a.SPINE.valueOf():i=i.filter(e=>e[f.b.COLUMN_NAME_CONTENT_STATE]=Ie.l.ONLY_SPINE);break;case Ie.a.ALL.valueOf():}return i}))}getChildIdentifiersFromManifest(e){return De(this,void 0,void 0,(function*(){const t="file:///"+e,n=[];return yield this.fileService.readAsText(t,Ie.i.MANIFEST.valueOf()).then(e=>De(this,void 0,void 0,(function*(){console.log("fileContents",JSON.parse(e));const t=JSON.parse(e).archive.items;return t.shift(),t.forEach(e=>{n.push(e.identifier)}),n}))).catch(e=>{console.log("getChildIdentifiersFromManifest err",e)}),n}))}}class Pe{static getFileExtension(e){const t=e.substring(e.lastIndexOf(".")+1,e.length);return t||""}static getFileName(e){return e.substring(e.lastIndexOf("/")+1)}static getParentDir(e){return e.substr(0,e.lastIndexOf("/",e.length-2)).concat("/")}static getDirectoryName(e){const t=e.split("/");return t[t.length-2]}static getTempDirPath(e){return e+"/tmp"}static isFreeSpaceAvailable(e,t,n){let r=10240;return n>0&&(r=n),e>0&&e>t+r}static getDirecory(e){return e.substr(0,e.lastIndexOf("/"))}}var Le=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class we{constructor(e,t,n){this.dbService=e,this.fileService=t,this.sharedPreferences=n,this.updateNewContentModels=[],this.fileMapList=[]}deleteAllChildren(e,t){return Le(this,void 0,void 0,(function*(){let n=!1;const r=ge.a.getBasePath(e[f.b.COLUMN_NAME_PATH]);yield this.fileService.readAsText(r,B.FileName.MANIFEST.valueOf()).then(e=>Le(this,void 0,void 0,(function*(){const r=JSON.parse(e).archive.items;r.shift();const i=[];r.forEach(e=>{i.push(e.identifier)});(yield this.findAllContentsFromDbWithIdentifiers(i)).forEach(e=>Le(this,void 0,void 0,(function*(){yield this.deleteOrUpdateContent(e,!0,t),n=!0;const r=e[f.b.COLUMN_NAME_PATH];if(r&&n){if(ge.a.getFirstPartOfThePathNameOnLastDelimiter(r))try{this.sharedPreferences.putString(X.f.KEY_LAST_MODIFIED,(new Date).getMilliseconds()+"").toPromise()}catch(e){console.log("Error",e)}}})))}))).catch(e=>{console.log("fileread err",e)});const i=yield this.getMetaData(this.fileMapList);if(this.updateNewContentModels.length){this.dbService.beginTransaction();for(const e of this.updateNewContentModels){const t=e,n=t[f.b.COLUMN_NAME_IDENTIFIER];let r=0;i&&(r=i[n]?i[n].size:0),t[f.b.COLUMN_NAME_SIZE_ON_DEVICE]=r,yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}deleteOrUpdateContent(e,t,n){return Le(this,void 0,void 0,(function*(){let r,i=e[f.b.COLUMN_NAME_REF_COUNT],o=e[f.b.COLUMN_NAME_VISIBILITY];const s=e[f.b.COLUMN_NAME_MIME_TYPE],a=e[f.b.COLUMN_NAME_PATH];if(n?(i>1&&o===B.Visibility.DEFAULT.valueOf()&&(i-=1,o=B.Visibility.PARENT.valueOf()),r=s===B.MimeType.COLLECTION?B.State.ARTIFACT_AVAILABLE.valueOf():B.State.ONLY_SPINE.valueOf()):(s===B.MimeType.COLLECTION.valueOf()&&i>1||i>1&&t?r=B.State.ARTIFACT_AVAILABLE.valueOf():(o===B.Visibility.DEFAULT.valueOf()&&(o=B.Visibility.PARENT.valueOf()),r=B.State.ONLY_SPINE.valueOf()),i-=1),a){if(r===B.State.ONLY_SPINE.valueOf()){const t=e[f.b.COLUMN_NAME_LOCAL_DATA],n=t&&JSON.parse(t);let r="",i="";t&&(r=n.appIcon?Pe.getFileName(n.appIcon):"",i=n.itemSetPreviewUrl?Pe.getFileName(n.itemSetPreviewUrl):""),this.rm(ge.a.getBasePath(a),[r,i].join(":"))}if(e[f.b.COLUMN_NAME_VISIBILITY]=o,e[f.b.COLUMN_NAME_REF_COUNT]=ge.a.addOrUpdateRefCount(i),e[f.b.COLUMN_NAME_CONTENT_STATE]=r,t){const t={};t.identifier=e[f.b.COLUMN_NAME_IDENTIFIER],t.path=ge.a.getBasePath(a),this.fileMapList.push(t),this.updateNewContentModels.push(e)}else e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]=0,yield this.dbService.update({table:f.b.TABLE_NAME,modelJson:e,selection:f.b.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[e[f.b.COLUMN_NAME_IDENTIFIER]]}).pipe(Object(W.map)(e=>e>0)).toPromise()}}))}findAllContentsFromDbWithIdentifiers(e){const t=V.a.joinPreservingQuotes(e),n=` WHERE ${f.b.COLUMN_NAME_IDENTIFIER} IN (${t}) AND ${f.b.COLUMN_NAME_REF_COUNT} > 0`,r=`SELECT * FROM ${f.b.TABLE_NAME} ${n}`;return this.dbService.execute(r).toPromise()}rm(e,t){return new Promise((n,r)=>{try{sbutility.rm(e,t,e=>{n(e)},e=>{console.error(e),r(!1)})}catch(e){console.error(e),r(!1)}})}getMetaData(e){return Le(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getMetaData(e,e=>{t(e)},e=>{console.error(e),n(e)})})}))}}var Ue=n(30),je=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Fe{constructor(e,t,n){this.appConfig=e,this.contentServiceConfig=t,this.telemetryService=n}getSearchCriteria(e){const t=e.request,n=t.query,r=t.exists,i=t.limit,o=t.offset;let s;t.hasOwnProperty("mode")&&"soft"===t.mode&&(s="soft");const a=[];if(t.hasOwnProperty("sort_by")){const e=t.sort_by;Object.keys(e).forEach(t=>{const n={sortAttribute:t,sortOrder:this.getSortOrder(String(e[t]))};a.push(n)})}const c=Object.assign(Object.assign(Object.assign({},n?{query:n}:{}),r?{exists:r}:{}),{mode:s,sortCriteria:a,searchType:this.getSearchType(String(t.searchType)),offset:o||0,limit:i||100});let u,d,l,f;if(t.hasOwnProperty("filters")){const e=t.filters;e.contentType&&(u=e.contentType),e.primaryCategory&&(d=e.primaryCategory),l=this.mapFilterValues(e,c),c.impliedFilters=l,c.contentTypes=u,c.primaryCategories=d}return t.hasOwnProperty("facets")&&(f=t.facets,c.facets=f),c}getSearchContentRequest(e){return{query:e.query,offset:e.offset,limit:e.limit,mode:e.mode,exists:e.exists&&e.exists.length>0?e.exists:[],facets:e.facets&&e.facets.length>0?e.facets:[],sort_by:this.getSortByRequest(e.sortCriteria),filters:this.getSearchFilter(e),fields:e.fields}}getSearchFilter(e){return e.searchType.valueOf()===B.SearchType.SEARCH.valueOf()?this.getSearchRequest(e):e.searchType.valueOf()===B.SearchType.FILTER.valueOf()?this.getFilterRequest(e):{}}getFilterRequest(e){let t={};return this.addFiltersToRequest(t,e.facetFilters),this.addFiltersToRequest(t,e.impliedFilters),e.impliedFiltersMap&&e.impliedFiltersMap.length>0&&e.impliedFiltersMap.forEach(e=>{t=Object.assign(Object.assign({},t),e)}),t}addFiltersToRequest(e,t){t&&t.length&&t.forEach(t=>{const n=[];if(t.values.forEach(e=>{e.apply&&n.push(e.name)}),n.length){let r=t.name;if(t.alternative)switch(t.name){case"board":r="se_boards";break;case"medium":r="se_mediums";break;case"gradeLevel":case"grade":r="se_gradeLevels"}e[r]=n}})}getSearchRequest(e){const t=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({audience:e.audience&&e.audience.length>0?e.audience:[],status:e.contentStatusArray,objectType:["Content","QuestionSet"],contentType:e.contentTypes&&e.contentTypes.length>0?e.contentTypes:[],primaryCategory:e.primaryCategories&&e.primaryCategories.length>0?e.primaryCategories:[]},e.keywords&&e.keywords.length?{keywords:e.keywords}:{}),e.dialCodes&&e.dialCodes.length?{dialcodes:e.dialCodes}:{}),e.createdBy&&e.createdBy.length?{createdBy:e.createdBy}:{}),e.grade&&e.grade.length?{se_gradeLevels:e.grade}:{}),{se_mediums:e.medium&&e.medium.length>0?e.medium:[],se_boards:e.board&&e.board.length>0?e.board:[],language:e.language&&e.language.length>0?e.language:[],topic:e.topic&&e.topic.length>0?e.topic:[],purpose:e.purpose&&e.purpose.length>0?e.purpose:[],channel:e.channel&&e.channel.length>0?e.channel:[],mimeType:e.mimeType&&e.mimeType.length>0?e.mimeType:[],subject:e.subject&&e.subject.length>0?e.subject:[]});return e.impliedFiltersMap&&e.impliedFiltersMap.forEach(e=>{Object.keys(e).forEach(n=>{t[n]=e[n]})}),e.impliedFilters&&e.impliedFilters.forEach(e=>{Object.keys(e).forEach(n=>{const r=e.values,i=e.name,o=this.getImpliedFilterValues(r);if(t[i]||(t[i]=[]),t[i]){const e=t[i].concat(o);e&&(t[i]=e.filter((t,n)=>e.indexOf(t)===n))}})}),t}getImpliedFilterValues(e){const t=[];return e?(e.forEach(e=>{e.apply&&t.push(e.name)}),t):[]}getSortByRequest(e){return e?e.reduce((e,t)=>(e[t.sortAttribute]=t.sortOrder,e),{}):{}}createFilterCriteria(e,t,n){const r=[],i={query:e.query,limit:e.limit,offset:e.offset,facets:e.facets,contentTypes:e.contentTypes,primaryCategories:e.primaryCategories,sortCriteria:e.sortCriteria&&e.sortCriteria.length?e.sortCriteria:[],mode:"soft"===e.mode?"soft":"hard"};return t?(t.forEach(e=>{const t=n?n[e.name]:[],i=e.values,o=this.getSortedFilterValuesWithAppliedFilters(i,t);if(e.name){const t={name:e.name,values:o};r.push(t)}delete n[e.name]}),i.facetFilters=r,i.impliedFilters=this.mapFilterValues(n,i),i):i}addFilterValue(e,t){e&&e.length>0&&e.forEach(e=>{const n=e.name;e.values,t[n]})}getFilterValuesWithAppliedFilter(e,t){return e.forEach(e=>{let n=!1;t&&t.indexOf(name)>-1&&(n=!0),e.apply=n}),e}mapSearchResponse(e,t,n){const r=(t.result.content||[]).concat(t.result.QuestionSet||[]);return{id:t.id,responseMessageId:t.params.resmsgid,filterCriteria:this.createFilterCriteria(e,t.result.facets,n.filters),request:n,contentDataList:r,count:t.result.count,collectionDataList:t.result.collections?t.result.collections:[]}}getContentSearchFilter(e,t,n=[]){return{filters:{identifier:e.filter((t,n)=>e.indexOf(t)===n),status:t,objectType:["Content"]},fields:[...n,"downloadUrl","variants","mimeType","contentType","primaryCategory","pkgVersion"]}}getDownloadUrl(e,t){return je(this,void 0,void 0,(function*(){let n,r,i;try{i=e.variants&&"string"==typeof e.variants?JSON.parse(e.variants):e.variants}catch(t){i=e.variants}if(e.mimeType===B.MimeType.COLLECTION.valueOf()?i&&i.online?r="online":i&&i.spine&&(r="spine"):e.mimeType===B.MimeType.QUESTION_SET&&(i&&i.full?r="full":i&&i.online&&(r="online")),i&&r&&i[r]){const o=i[r];n=o&&o.ecarUrl,yield this.buildContentLoadingEvent(r,t,e.primaryCategory||e.contentType,e.pkgVersion)}return n||(n=e.downloadUrl.trim(),yield this.buildContentLoadingEvent("full",t,e.primaryCategory||e.contentType,e.pkgVersion)),n}))}buildContentLoadingEvent(e,t,n,r){const i=new P.TelemetryInteractRequest;return i.type=P.InteractType.OTHER,i.subType=e,i.pageId="ImportContent",i.id="ImportContent",i.objId=t.contentId,i.objType=n,i.objVer=r,i.rollup=t.rollUp,i.correlationData=t.correlationData,this.telemetryService.interact(i).toPromise()}getSortOrder(e){let t;return t="asc"===e?B.SortOrder.ASC:B.SortOrder.DESC,t}getSearchType(e){let t;return t="search"===e?B.SearchType.SEARCH:"filter"===e?B.SearchType.FILTER:B.SearchType.SEARCH,t}getSortedFilterValuesWithAppliedFilters(e,t){return e.forEach(e=>{let n=!1;t&&t.forEach(t=>{t&&e.name&&e.name.toLowerCase()===t.toLowerCase()&&(n=!0)}),e.apply=n,e.count=Ue.a.parseInt(e.count)}),e}mapFilterValues(e,t){const n=[],r=[];return Object.keys(e).forEach(t=>{const i=e[t];if(Array.isArray(i)&&i.length){const e=[];i.forEach(t=>{const n={name:t,apply:!0};e.push(n)}),n.push({name:t,values:e})}else if(i){const e={};e[t]=i,r.push(e)}}),t.impliedFiltersMap=r,n}}class xe{getAllLocalContentQuery(e){e.primaryCategories&&e.primaryCategories.length||(e.primaryCategories=["Course","Learning Resource","Explanation Content","Teacher Resource","Content Playlist","Digital Textbook","Practice Question Set","eTextBook","Course Assessment"]);const t=e.uid,n=e.resourcesOnly?"":`c.${f.b.COLUMN_NAME_VISIBILITY} = '${B.Visibility.DEFAULT.valueOf()}' AND`,r=`c.${f.b.COLUMN_NAME_CONTENT_STATE} = '${B.State.ARTIFACT_AVAILABLE.valueOf()}'`;let i=`${n} ${r}`;if(e.resourcesOnly){i=`${i} AND (${`c.${f.b.COLUMN_NAME_MIME_TYPE} != '${B.MimeType.COLLECTION.valueOf()}'`})`}else{const t=V.a.joinPreservingQuotes(e.primaryCategories);i=`${i} AND (${`c.${f.b.COLUMN_NAME_PRIMARY_CATEGORY} IN(${t.toLowerCase()})`})`}const o=this.getAudienceFilter(e.audience),s=this.getPragmaFilter(e.exclPragma,e.pragma),a=this.generateFieldMatchQuery(e);o&&(i=`${i} AND (${o})`),s&&(i=`${i} AND (${s})`),a&&(i=`${i} AND (${a})`);let c=`WHERE (${i})`,u="";const d=e.resourcesOnly?"":this.generateSortByQuery(e.sortCriteria,t);return e.recentlyViewed?t&&(i=e.localOnly?`ca.${f.a.COLUMN_NAME_UID} = '${t}' AND ${r}\n AND cm.${f.b.COLUMN_NAME_MIME_TYPE} NOT IN ('${B.MimeType.COLLECTION.valueOf()}', '')`:`ca.${f.a.COLUMN_NAME_UID} = '${t}'\n AND cm.${f.b.COLUMN_NAME_MIME_TYPE} NOT IN ('${B.MimeType.COLLECTION.valueOf()}', '')`,c=`WHERE (${i})`,u=this.getRecentlyViewedQuery(c,d,e.limit)):u=t?this.getLocalOnlyQuery(c,d,t):`SELECT c.* FROM ${f.b.TABLE_NAME} c ${c} ${d}`,u}getAudienceFilter(e){let t="";return e&&e.forEach(e=>{t=t.concat(t.length>0?" OR ":"",`c.${f.b.COLUMN_NAME_AUDIENCE} LIKE '%%${e}%%'`)}),t}getPragmaFilter(e,t){let n="";return e?e.forEach(e=>{n=n.concat(n.length>0?" OR ":"",`c.${f.b.COLUMN_NAME_PRAGMA} NOT LIKE '%%${e}%%'`)}):t&&t.forEach(e=>{n=n.concat(n.length>0?" OR ":"",`c.${f.b.COLUMN_NAME_PRAGMA} LIKE '%%${e}%%'`)}),n}getRecentlyViewedQuery(e,t,n){return`SELECT c.*, ca.${f.a.COLUMN_NAME_EPOCH_TIMESTAMP},\n cm.${f.d.COLUMN_NAME_DATA} FROM ${f.a.TABLE_NAME} ca LEFT JOIN\n ${f.d.TABLE_NAME} cm ON\n (cm.${f.d.COLUMN_NAME_UID} = ca.${f.a.COLUMN_NAME_UID}\n AND cm.${f.d.COLUMN_NAME_CONTENT_IDENTIFIER} = ca.${f.a.COLUMN_NAME_CONTENT_IDENTIFIER})\n LEFT JOIN ${f.b.TABLE_NAME} c ON\n c.${f.b.COLUMN_NAME_IDENTIFIER} = ca.${f.a.COLUMN_NAME_CONTENT_IDENTIFIER}\n ${e} ${t} LIMIT ${n}`}getLocalOnlyQuery(e,t,n){let r="";return r=Array.isArray(n)?`ca.${f.a.COLUMN_NAME_UID} IN (${V.a.joinPreservingQuotes(n)})`:`ca.${f.a.COLUMN_NAME_UID} ='${n}'`,`SELECT c.*, ca.${f.a.COLUMN_NAME_EPOCH_TIMESTAMP}\n FROM ${f.b.TABLE_NAME} c LEFT JOIN ${f.a.TABLE_NAME} ca\n ON c.${f.b.COLUMN_NAME_IDENTIFIER} = ca.${f.a.COLUMN_NAME_CONTENT_IDENTIFIER}\n AND ${r}\n ${e} ${t}`}generateSortByQuery(e,t){let n="",r=0;return e||((e=[]).push({sortAttribute:"lastUsedOn",sortOrder:B.SortOrder.DESC}),e.push({sortAttribute:"localLastUpdatedOn",sortOrder:B.SortOrder.DESC})),e.forEach(e=>{e&&("lastUsedOn"===e.sortAttribute.valueOf()&&t?(n=this.generateOrderByQuery(r,n," ca."+f.a.COLUMN_NAME_EPOCH_TIMESTAMP,e.sortOrder.valueOf()),r++):"localLastUpdatedOn"===e.sortAttribute.valueOf()?(n=this.generateOrderByQuery(r,n," c."+f.b.COLUMN_NAME_LOCAL_LAST_UPDATED_ON,e.sortOrder.valueOf()),r++):"sizeOnDevice"===e.sortAttribute.valueOf()&&(n=this.generateOrderByQuery(r,n," c."+f.b.COLUMN_NAME_SIZE_ON_DEVICE,e.sortOrder.valueOf()),r++))}),n}generateOrderByQuery(e,t,n,r){let i="";return i=e>0?t.concat(","):t.concat("ORDER BY"),i=i.concat(`${n} ${r}`),i}generateFieldMatchQuery(e){return[{field:"board",column:f.b.COLUMN_NAME_BOARD},{field:"medium",column:f.b.COLUMN_NAME_MEDIUM},{field:"grade",column:f.b.COLUMN_NAME_GRADE},{field:"dialcodes",column:f.b.COLUMN_NAME_DIALCODES},{field:"childNodes",column:f.b.COLUMN_NAME_CHILD_NODES}].reduce((t,{field:n,column:r})=>(e[n]&&e[n].length&&t.push(this.generateLikeQuery(e[n],r)),t),[]).join(" AND ")}generateLikeQuery(e,t){let n="";const r=t+" LIKE ";for(let t=0;t<e.length;t++)n=t<e.length-1?n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' OR `):n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' `);return`(${n})`}}var ke=n(38),Be=n.n(ke),Ve=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},Ye=f.b.COLUMN_NAME_LOCAL_DATA,Ge=f.b.COLUMN_NAME_IDENTIFIER,He=f.b.COLUMN_NAME_REF_COUNT;class qe{constructor(e,t,n){this.deviceInfo=e,this.dbService=t,this.fileService=n}populateItems(e){const t=[],n=[];let r=[];const i={};e.forEach(e=>{const t=JSON.parse(e[Ye]);if(i[e[Ge]]=t,ge.a.addViralityMetadataIfMissing(t,this.deviceInfo.getDeviceID()),ge.a.hasChildren(t)){const e=ge.a.getChildContentsIdentifiers(t);r=r.concat(e)}n.push(e[Ge])});try{n.forEach(e=>{const n=i[e];V.a.contains(r,e)&&(n.visibility=B.Visibility.PARENT.valueOf()),t.push(n)})}catch(e){console.log(e)}return t}populateItemList(e){const t=[],n=[];let r=[];const i={};e.forEach(e=>{if(i[e.identifier]=e,ge.a.addViralityMetadataIfMissing(e,this.deviceInfo.getDeviceID()),ge.a.hasChildren(e)){const t=ge.a.getChildContentsIdentifiers(e);r=r.concat(t)}n.push(e.identifier)});try{n.forEach(e=>{const n=i[e];V.a.contains(r,e)&&(n.visibility=B.Visibility.PARENT.valueOf()),t.push(n)})}catch(e){console.log(e)}return t}getContentExportDBModelToExport(e){return Ve(this,void 0,void 0,(function*(){let t=[];const n=yield this.findAllContentsWithIdentifiers(e),r=ge.a.getBasePath(n[0][f.b.COLUMN_NAME_PATH]);return yield this.fileService.readAsText(r,B.FileName.MANIFEST.valueOf()).then(e=>Ve(this,void 0,void 0,(function*(){const n=JSON.parse(e).archive.items,r=[];n.forEach(e=>{r.push(e.identifier)}),t=yield this.findAllContentsWithIdentifiers(r,!0)}))).catch(e=>{console.log("fileRead error",e)}),Promise.resolve(ge.a.deDupe(t,"identifier"))}))}generateManifestForArchive(e){const t={},n={ttl:24};return n.count=e.length,n.items=e,t.id=qe.EKSTEP_CONTENT_ARCHIVE,t.ver=qe.SUPPORTED_MANIFEST_VERSION,t.ts=Be()().format("YYYY-MM-DDTHH:mm:ss[Z]"),t.archive=n,t}findAllContentsWithIdentifiers(e,t){let n="";t&&e.length&&(n=e.reduce((e,t,n)=>e+` WHEN '${t}' THEN ${n}`," ORDER BY CASE "+Ge)+" END");const r=V.a.joinPreservingQuotes(e),i=` where ${Ge} in (${r}) AND ${He} > 0`,o=`select * from ${f.b.TABLE_NAME} ${i} ${n}`;return this.dbService.execute(o).toPromise()}}qe.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",qe.SUPPORTED_MANIFEST_VERSION="1.1";class $e{constructor(e,t){this.dbService=e,this.exportHandler=t}execute(e){const t=new o.Response,n=this.exportHandler.populateItems(e.contentModelsToExport);e.items=[],e.manifest={},e.items=e.items.concat(n);const r={ttl:24};return r.count=e.items.length,r.items=e.items,e.manifest.id=$e.EKSTEP_CONTENT_ARCHIVE,e.manifest.ver=$e.SUPPORTED_MANIFEST_VERSION,e.manifest.ts=Be()().format(),e.manifest.archive=r,t.body=e,Promise.resolve(t)}}$e.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",$e.SUPPORTED_MANIFEST_VERSION="1.1";class Ke{constructor(e,t){this.fileService=e,this.deviceInfo=t}execute(e){const t=new o.Response;return this.deviceInfo.getAvailableInternalMemorySize().toPromise().then(n=>{const r=Number(n);if(r>0&&r<1048576)throw t.errorMesg=Ie.d.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT,t;return this.fileService.writeFile(e.tmpLocationPath,Ie.i.MANIFEST.valueOf(),JSON.stringify(e.manifest),{replace:!0})}).then(()=>(t.body=e,Promise.resolve(t))).catch(()=>(t.errorMesg=Ie.d.EXPORT_FAILED_WRITING_MANIFEST,Promise.reject(t)))}}var ze=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class We{constructor(e){this.zipService=e}execute(e){return ze(this,void 0,void 0,(function*(){const t=new o.Response;for(const t of e.contentModelsToExport){const n=t,r=JSON.parse(n[f.b.COLUMN_NAME_LOCAL_DATA]);if(!ge.a.isAvailableLocally(n[f.b.COLUMN_NAME_CONTENT_STATE])||ge.a.isOnlineContent(r)||ge.a.isInlineIdentity(r.contentDisposition,r.contentEncoding))continue;const i=r.artifactUrl;if(i){const t=e.tmpLocationPath.concat(i),r=n[f.b.COLUMN_NAME_PATH],o=[],s=[];o.push(n[f.b.COLUMN_NAME_IDENTIFIER]),s.push(n[f.b.COLUMN_NAME_IDENTIFIER].concat("/",B.FileName.MANIFEST.valueOf())),yield new Promise((e,n)=>{this.zipService.zip(r,{target:t},o,s,()=>{e()},()=>{n()})})}}return t.body=e,Promise.resolve(t)}))}}var Xe=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Je{constructor(e){this.fileService=e}execute(e){return Xe(this,void 0,void 0,(function*(){const t=new o.Response;return this.fileService.getFreeDiskSpace().then(n=>{this.getFileSize(e.items);return t.body=e,t})}))}getFileSize(e){let t=0;return e&&e.forEach(e=>{e.size&&(t+=Number(e.size))}),t}}var Qe=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Ze{constructor(){}execute(e){return Qe(this,void 0,void 0,(function*(){const t=new o.Response;try{let n=0,r=[];null!=e.subContentIds&&e.subContentIds.length>0&&(r=this.excludeContentForSubModule(e.contentModelsToExport,e.subContentIds));let i=e.contentModelsToExport;r&&r.length>0&&(i=r);for(const t of i){const r=t,i=e.items[n],o=i.appIcon,s=i.itemSetPreviewUrl;for(const t of[o,s])if(t&&!t.startsWith("https:"))try{yield this.copyFile(r[f.b.COLUMN_NAME_PATH],e.tmpLocationPath,t)}catch(e){console.error(e)}const a=i.contentDisposition,c=i.contentEncoding;if(ge.a.isInlineIdentity(a,c)){const t=i.artifactUrl;if(t)try{yield this.copyFile(r[f.b.COLUMN_NAME_PATH],e.tmpLocationPath,t)}catch(e){console.error(e)}}n++}return t.body=e,t}catch(e){throw t.errorMesg=B.ContentErrorCode.EXPORT_FAILED_COPY_ASSET,t}}))}excludeContentForSubModule(e,t){const n=[];return e.forEach(e=>{const r=e.identifier;t&&t.indexOf(r)>-1&&n.push(e)}),n}copyFile(e,t,n){return Qe(this,void 0,void 0,(function*(){return new Promise((r,i)=>{sbutility.copyFile(e,t,n,()=>{r(!0)},e=>{console.error(e),r(e)})})}))}}var et=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class tt{constructor(e,t){this.fileService=e,this.zipService=t}execute(e){return et(this,void 0,void 0,(function*(){const t=new o.Response;yield new Promise((n,r)=>{this.zipService.zip(e.tmpLocationPath,{target:e.ecarFilePath},[],[],()=>{n()},()=>{throw t.errorMesg=Ie.d.EXPORT_FAILED_ECAR_BUNDLE,t})});const n=yield this.fileService.getMetaData(e.ecarFilePath);return e.metadata[tt.FILE_SIZE]=n.size,t.body=e,t}))}}tt.FILE_SIZE="FILE_SIZE";var nt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class rt{constructor(e,t){this.fileService=e,this.zipService=t,this.FILE_SIZE="FILE_SIZE"}execute(e){const t=new o.Response;let n;return this.fileService.getMetaData(e.ecarFilePath).then(t=>(n=t.size,this.fileService.createDir(e.tmpLocation.concat(L.a.generateUniqueId()),!0))).then(r=>nt(this,void 0,void 0,(function*(){return e.tmpLocation=r.nativeURL,yield new Promise((t,n)=>{this.zipService.unzip(e.ecarFilePath,{target:r.nativeURL},()=>{t()},e=>{n(e)})}),e.metadata={},e.metadata.FILE_SIZE=n,t.body=e,Promise.resolve(t)}))).catch(e=>(t.errorMesg=Ie.d.IMPORT_FAILED_EXTRACT_ECAR.valueOf(),Promise.reject(t)))}}class it{constructor(){this.identifierList=new Set}hierarchyToManifestConversion(e){this.identifierList=new Set,this.archive={count:0,items:[]};const t=this.reorderData(e,1);return t&&(this.archive.count+=1,this.archive.items.push(t)),e.children&&e.children.length&&this.recurssiveFunc(e.children,1),this.archive}recurssiveFunc(e,t){for(let n=0;n<e.length;n++){const r=this.reorderData(e[n],t+1,B.Visibility.PARENT.valueOf());r&&(this.archive.count+=1,this.archive.items.push(r)),e[n].children&&e[n].children.length&&this.recurssiveFunc(e[n].children,t+1)}}reorderData(e,t,n){if(this.identifierList.has(e.identifier))return null;const r=[],i=JSON.parse(JSON.stringify(e));if(i.children&&i.children.length){for(let e=0;e<i.children.length;e++)r.push({name:i.children[e].name,identifier:i.children[e].identifier,objectType:i.children[e].objectType,depth:t,index:e});i.children=r}return i.visibility=n||i.visibility,this.identifierList.add(i.identifier),i}}var ot=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class st{constructor(e,t,n,r){this.fileService=e,this.dbService=t,this.appConfig=n,this.getContentDetailsHandler=r}execute(e){return ot(this,void 0,void 0,(function*(){const t=new o.Response;let n;try{if(n=yield this.fileService.readAsText(e.tmpLocation,B.FileName.HIERARCHY.valueOf()),n){const e=JSON.parse(n);e.archive=(new it).hierarchyToManifestConversion(e.content),delete e.content,n=JSON.stringify(e)}}catch(t){n=yield this.fileService.readAsText(e.tmpLocation,B.FileName.MANIFEST.valueOf())}if(!n)throw t.errorMesg=B.ContentErrorCode.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;const r=JSON.parse(n);if(1===r.ver)throw t.errorMesg=B.ContentErrorCode.IMPORT_FAILED_UNSUPPORTED_MANIFEST.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;const i=r.archive;if(!i.items)throw t.errorMesg=B.ContentErrorCode.IMPORT_FAILED_NO_CONTENT_METADATA.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;e.manifestVersion=r.ver,e.items=[];const s=i.items,a=[];for(const e of s){const t=e.identifier;a.push(t)}const c=V.a.joinPreservingQuotes(a),u=(yield this.getContentDetailsHandler.fetchFromDBForAll(c).toPromise()).reduce((e,t)=>(e[t.identifier]=t,e),{});let d=!1;e.existedContentIdentifiers={};for(const t of s){const n=t,r=n.identifier,i=ge.a.readVisibility(n),o=n.status,a=ge.a.isDraftContent(o);if(a&&ge.a.isExpired(n.expires)){this.skipContent(e,r,i,B.ContentImportStatus.CONTENT_EXPIRED,s);continue}i===B.Visibility.DEFAULT.valueOf()&&(d=!1);const c=u[r];let l;if(c){const t=c[f.b.COLUMN_NAME_REF_COUNT];if(l=c[f.b.COLUMN_NAME_PATH],l&&i===B.Visibility.DEFAULT.valueOf()&&t&&t>0){d=!0;const t=JSON.parse(c[f.b.COLUMN_NAME_LOCAL_DATA]);t&&n.pkgVersion>t.pkgVersion&&t.childNodes&&t.childNodes.length>0&&(e.contentIdsToDelete=new Set(t.childNodes))}}l&&i===B.Visibility.DEFAULT.valueOf()&&!ge.a.isDuplicateCheckRequired(a,n.pkgVersion)&&ge.a.isImportFileExist(c,n)?(e.rootIdentifier=r,this.skipContent(e,r,i,B.ContentImportStatus.ALREADY_EXIST,s)):(d&&e.contentIdsToDelete.delete(r)&&(e.existedContentIdentifiers[r]=!0),e.items.push(n))}return t.body=e,t}))}skipContent(e,t,n,r,i){n===B.Visibility.DEFAULT&&(r===B.ContentImportStatus.ALREADY_EXIST?i&&1===i.length&&e.contentImportResponseList.push({identifier:t,status:r}):e.contentImportResponseList.push({identifier:t,status:r})),e.skippedItemsIdentifier.push(t)}}var at=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class ct{constructor(e,t,n){this.dbService=e,this.sharedPreferences=t,this.fileService=n}execute(){return this.updateAllRootContentSize().toPromise()}findAllChildContents(e){const t=`SELECT * FROM ${f.b.TABLE_NAME}\n WHERE ${f.b.COLUMN_NAME_IDENTIFIER} IN (${V.a.joinPreservingQuotes(e)})\n AND ${f.b.COLUMN_NAME_REF_COUNT} > 0`;return this.dbService.execute(t).toPromise()}updateAllRootContentSize(){const e=`SELECT * FROM ${f.b.TABLE_NAME} WHERE ${f.b.COLUMN_NAME_REF_COUNT} > 0\n AND ${f.b.COLUMN_NAME_VISIBILITY} = '${B.Visibility.DEFAULT.valueOf()}'`;return this.dbService.execute(e).pipe(Object(W.tap)(()=>at(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(X.f.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()}))),Object(W.mergeMap)(e=>at(this,void 0,void 0,(function*(){const t=[];yield Promise.all(e.map(e=>at(this,void 0,void 0,(function*(){let n=yield this.getSizeOnDevice(e);const r=JSON.parse(e[f.b.COLUMN_NAME_LOCAL_DATA]).childNodes;if(r){(yield this.findAllChildContents(r)).forEach(e=>{n+=e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]||0}),e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e)}})))),this.updateInDb(t)}))),Object(W.tap)(()=>at(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(X.f.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()}))))}getSizeOnDevice(e){return at(this,void 0,void 0,(function*(){let t=0;if(e[f.b.COLUMN_NAME_MIME_TYPE]===B.MimeType.COLLECTION.valueOf()){if(e[f.b.COLUMN_NAME_VISIBILITY]===B.Visibility.DEFAULT.valueOf()){const n=[],r={},i=e[f.b.COLUMN_NAME_IDENTIFIER];r.identifier=i,r.path=e[f.b.COLUMN_NAME_PATH],n.push(r);const o=yield this.getMetaData(n);t=o[i]?o[i].size:0}}else t=e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]?e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]:0;return Promise.resolve(t||0)}))}updateInDb(e){return at(this,void 0,void 0,(function*(){this.dbService.beginTransaction();for(const t of e){const e=t,n=e[f.b.COLUMN_NAME_IDENTIFIER];this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n],modelJson:e}).toPromise()}this.dbService.endTransaction(!0)}))}getMetaData(e){return at(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getMetaData(e,e=>{t(e)},e=>{console.error(e),n(e)})})}))}updateTextBookSize(e){console.log("in updateAllRootContentSize");const t=`SELECT * FROM ${f.b.TABLE_NAME} WHERE ${f.b.COLUMN_NAME_IDENTIFIER} == ${e}`;return this.dbService.execute(t).pipe(Object(W.tap)(()=>at(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(X.f.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()}))),Object(W.mergeMap)(e=>at(this,void 0,void 0,(function*(){const t=[];yield Promise.all(e.map(e=>at(this,void 0,void 0,(function*(){let n=yield this.getSizeOnDevice(e);const r=JSON.parse(e[f.b.COLUMN_NAME_LOCAL_DATA]).childNodes;if(r){(yield this.findAllChildContents(r)).forEach(e=>{n+=e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]||0}),e[f.b.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e)}})))),this.updateInDb(t)}))),Object(W.tap)(()=>at(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(X.f.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()}))))}}var ut=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},dt=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}},lt=f.b.COLUMN_NAME_VISIBILITY;class ft{constructor(e,t,n,r,i,o,s,a){this.fileService=e,this.zipService=t,this.appConfig=n,this.dbService=r,this.deviceInfo=i,this.getContentDetailsHandler=o,this.eventsBusService=s,this.sharedPreferences=a}execute(e){return ut(this,void 0,void 0,(function*(){const t=new o.Response;e.identifiers=[];const n=[],r=[],i=new Map,s=new Map;let a,c=0;this.postImportProgressEvent(c,e.items.length);const u=[],d=[],l=[];for(const t of e.items){const e=t,n=e.identifier,r=ge.a.readVisibility(e),i=e.appIcon;ge.a.isNotUnit(e.mimeType,r)&&(d.push(n),i&&!i.startsWith("https:")&&l.push(n+"/"+i.substring(0,i.lastIndexOf("/")))),u.push(n)}const h=ge.a.getContentRootDir(e.destinationFolder);let E;E=e.items[0].mimeType===B.MimeType.QUESTION_SET?yield this.segregateQuestions(h,JSON.parse(JSON.stringify(e.items))):yield this.createDirectories(h,d);yield this.createDirectories(h,l);const p=V.a.joinPreservingQuotes(u),_=(yield this.getContentDetailsHandler.fetchFromDBForAll(p).toPromise()).reduce((e,t)=>(e[t.identifier]=t,e),{});for(const t of e.items){let o=t;const u=o.identifier;if(e.skippedItemsIdentifier&&e.skippedItemsIdentifier.indexOf(u)>-1)continue;const d=o.mimeType,l=o.contentEncoding,h=o.contentDisposition,p=ge.a.readContentType(o),S=ge.a.readPrimaryCategory(o);let b=ge.a.readVisibility(o);const O=ge.a.readAudience(o),v=ge.a.readPragma(o),C=o.pkgVersion,g=o.artifactUrl,A=o.appIcon,T=o.itemSetPreviewUrl,N=o.board,y=o.medium,m=o.gradeLevel,I=o.dialcodes,M=o.childNodes;let D,R=B.State.ONLY_SPINE.valueOf();const P=_[u];let L,w;if(P&&(L=ge.a.getBasePath(P[f.b.COLUMN_NAME_PATH])),b===B.Visibility.DEFAULT.valueOf()&&(w=u),ge.a.isNotUnit(d,b))if(E[u]&&E[u].path)D="ios"===window.device.platform.toLowerCase()?E[u].path.concat("/"):E[u].path;else{let t="ios"===window.device.platform.toLowerCase()?ge.a.getContentRootDir(e.destinationFolder).concat(u):ge.a.getContentRootDir(e.destinationFolder).concat("/",u);const n=yield this.fileService.createDir(t,!1);D=n.nativeURL}let U=!1,j=ge.a.doesContentExist(P,u,C,!1);if(j=!1,j&&o.status!==B.ContentStatus.DRAFT.valueOf())P[lt]===B.Visibility.DEFAULT.valueOf()&&(o=JSON.parse(P[f.b.COLUMN_NAME_LOCAL_DATA]));else{if(j=!1,g){if(!ge.a.isInlineIdentity(h,l)&&d===B.MimeType.EPUB)try{yield this.copyAssets(e.tmpLocation,g,D),U=!0}catch(e){U=!1}if(!h||!l||h===B.ContentDisposition.INLINE.valueOf()&&l===B.ContentEncoding.GZIP.valueOf()){const t=e.tmpLocation.concat(g);yield new Promise((e,n)=>{this.zipService.unzip(t,{target:D},()=>{U=!0,e()},()=>{e()})})}else if(ge.a.isInlineIdentity(h,l))try{yield this.copyAssets(e.tmpLocation,g,D),U=!0}catch(e){U=!1}else B.ContentDisposition.ONLINE.valueOf()===h&&(U=!0)}if(R=U||this.shouldDownloadQuestionSet(e.items,o)||B.MimeType.COLLECTION.valueOf()===d?B.State.ARTIFACT_AVAILABLE.valueOf():B.State.ONLY_SPINE.valueOf(),ge.a.isNotUnit(d,b))try{A.startsWith("https:")||this.copyAssets(e.tmpLocation,A,D,!0)}catch(e){}try{T.startsWith("https:")||this.copyAssets(e.tmpLocation,T,D,!1)}catch(e){}}const F=this.getBasePath(D,j,L);b===B.Visibility.DEFAULT.valueOf()?(a=F,e.rootIdentifier=u):ge.a.isNotUnit(d,b)&&e.identifiers.push(u);const x=this.getReferenceCount(P,b,e.isChildContent,e.existedContentIdentifiers);b=this.getContentVisibility(P,o.objectType,e.isChildContent,b),ge.a.addOrUpdateViralityMetadata(o,this.deviceInfo.getDeviceID().toString());const k=0;ge.a.isNotUnit(d,b)&&s.set(u,D);const V=this.constructContentDBModel(u,e.manifestVersion,JSON.stringify(o),d,p,b,F,x,R,O,v,k,N,y,m,I,M,S);if(P){this.getContentState(P,R)===B.State.ONLY_SPINE.valueOf()||U||B.MimeType.COLLECTION.valueOf()===d?r.push(V):V[f.b.COLUMN_NAME_CONTENT_STATE]=this.getContentState(P,R)}else n.push(V);i.set(u,V),c++,c%20!=0&&c!==e.items.length||this.postImportProgressEvent(c,e.items.length)}this.updateContentDB(n,r);const S=setTimeout(()=>{this.updateContentFileSizeInDB(e,i,s,_)},5e3);if(a)try{yield this.fileService.copyFile(e.tmpLocation,B.FileName.MANIFEST.valueOf(),a,B.FileName.MANIFEST.valueOf())}catch(e){console.log("Exception Raised During Import")}return t.body=e,Promise.resolve([t,S])}))}updateContentFileSizeInDB(e,t,n,r){return ut(this,void 0,void 0,(function*(){const i=[];for(const o of e.items){const e=o.identifier,s=t.get(e).mimeType,a=t.get(e).visibility,c=n.get(e);let u=0;r[e];if(ge.a.isNotUnit(s,a))try{u=yield this.fileService.getDirectorySize(c),t.get(e).size_on_device=u,i.push(t.get(e))}catch(e){}}this.updateContentDB([],i,!0)}))}updateContentDB(e,t,n){return ut(this,void 0,void 0,(function*(){if(e=e&&e.length?this.filterQuestionSetContent(e):e,t=t&&t.length?this.filterQuestionSetContent(t):t,e.length||t.length){this.dbService.beginTransaction();for(const t of e){const e=t;yield this.dbService.insert({table:f.b.TABLE_NAME,modelJson:e}).toPromise()}for(const e of t){const t=e;yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}n&&new ct(this.dbService,this.sharedPreferences,this.fileService).execute()}))}copyAssets(e,t,n,r){return ut(this,void 0,void 0,(function*(){console.log("tempLocationPath-",e),console.log("asset-",t),console.log("payloadDestinationPath-",n),console.log("useSubDirectories-",r),console.log("FileUtil.getFileName(asset),-",Pe.getFileName(t));try{if(t&&!t.startsWith("http://")&&!t.startsWith("https://")){let i=t.substring(0,t.lastIndexOf("/"));if(!r){let e=yield this.fileService.createDir(n.concat(i),!1);console.log("createRe-",e)}"ios"===window.device.platform.toLowerCase()&&(yield this.fileService.exists(n.concat("/",t)).then(e=>{e&&this.fileService.removeFile(n.concat("/",t)).then()}).catch(e=>{console.log("Error =>",e)}));let o=yield Pe.getFileName(t),s="";try{s=yield this.fileService.exists(e.concat(o))}catch(e){s=""}console.log("pathExist-",s),""!==s?yield this.fileService.copyFile(e.concat(o),o,n.concat(i),o):yield this.fileService.copyFile(e.concat(i),Pe.getFileName(t),n.concat(i),Pe.getFileName(t))}}catch(e){throw console.error("Cannot Copy Asset---000011---",e),e}}))}getContentVisibility(e,t,n,r){let i;return"Library"===t?i=B.Visibility.PARENT.valueOf():e&&(n||B.Visibility.PARENT.valueOf()!==e[lt])&&(i=e[lt]),i||r}getContentState(e,t){return e&&e[f.b.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[f.b.COLUMN_NAME_CONTENT_STATE]),t}getBasePath(e,t,n){let r;return r=e&&!t?e:n,r}getReferenceCount(e,t,n,r){let i;if(e){i=e[f.b.COLUMN_NAME_REF_COUNT];(r?r[e[f.b.COLUMN_NAME_IDENTIFIER]]:void 0)||n||B.Visibility.DEFAULT.valueOf()===e[lt]&&B.Visibility.DEFAULT.valueOf()===t||(i+=1)}else i=1;return i}postImportProgressEvent(e,t){this.eventsBusService.emit({namespace:k.EventNamespace.CONTENT,event:{type:B.ContentEventType.IMPORT_PROGRESS,payload:{totalCount:t,currentCount:e}}})}constructContentDBModel(e,t,n,r,i,o,s,a,c,u,d,l,h,E,p,_,S,b){return{[f.b.COLUMN_NAME_IDENTIFIER]:e,[f.b.COLUMN_NAME_SERVER_DATA]:"",[f.b.COLUMN_NAME_PATH]:ge.a.getBasePath(s),[f.b.COLUMN_NAME_REF_COUNT]:a,[f.b.COLUMN_NAME_CONTENT_STATE]:c,[f.b.COLUMN_NAME_SIZE_ON_DEVICE]:l,[f.b.COLUMN_NAME_MANIFEST_VERSION]:t,[f.b.COLUMN_NAME_LOCAL_DATA]:n,[f.b.COLUMN_NAME_MIME_TYPE]:r,[f.b.COLUMN_NAME_CONTENT_TYPE]:i,[f.b.COLUMN_NAME_VISIBILITY]:o,[f.b.COLUMN_NAME_AUDIENCE]:u,[f.b.COLUMN_NAME_PRAGMA]:d,[f.b.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]:Be()(Date.now()).format(),[f.b.COLUMN_NAME_BOARD]:ge.a.getContentAttribute(h),[f.b.COLUMN_NAME_MEDIUM]:ge.a.getContentAttribute(E),[f.b.COLUMN_NAME_GRADE]:ge.a.getContentAttribute(p),[f.b.COLUMN_NAME_DIALCODES]:ge.a.getContentAttribute(_),[f.b.COLUMN_NAME_CHILD_NODES]:ge.a.getContentAttribute(S),[f.b.COLUMN_NAME_PRIMARY_CATEGORY]:b}}createDirectories(e,t){return ut(this,void 0,void 0,(function*(){return new Promise((n,r)=>{e="ios"===window.device.platform.toLowerCase()?e.concat("/"):e,sbutility.createDirectories(ge.a.getBasePath(e),t,e=>{n(e)},e=>{console.error(e),r(e)})})}))}filterQuestionSetContent(e){return e.filter(e=>e.mimeType!==B.MimeType.QUESTION&&e.mime_type!==B.MimeType.QUESTION)}segregateQuestions(e,t){var n,r;return ut(this,void 0,void 0,(function*(){let i={};for(let e=0;e<t.length;e++)t[e].mimeType!==B.MimeType.QUESTION_SET||i[t[e].identifier]?t[e].mimeType===B.MimeType.QUESTION&&(i[t[e].parent]?i[t[e].parent].push(t[e].identifier):i[t[e].identifier]=[t[e].identifier]):i[t[e].identifier]=[];const o=Object.keys(i);let s=yield this.createDirectories(e,o);const a=[];for(const t in i)a.push({idArr:i[t],dir:`${e}/${t}`});try{for(var c,u=dt(a);!(c=yield u.next()).done;){const e=c.value,t=yield this.createDirectories(e.dir,e.idArr);s=Object.assign(Object.assign({},s),t)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&(yield r.call(u))}finally{if(n)throw n.error}}return s}))}shouldDownloadQuestionSet(e,t){return t.mimeType===B.MimeType.QUESTION_SET&&ge.a.readVisibility(t)===B.Visibility.DEFAULT.valueOf()||this.checkParentQustionSet(e,t)}checkParentQustionSet(e,t){if(!t||!t.parent)return!1;const n=e.find(e=>e.identifier===t.parent);return!(!n||n.mimeType!==B.MimeType.QUESTION_SET)&&(n.mimeType===B.MimeType.QUESTION_SET&&ge.a.readVisibility(n)===B.Visibility.DEFAULT.valueOf()||this.checkParentQustionSet(e,n))}}var ht=n(301),Et=n.n(ht),pt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class _t{constructor(e,t,n){this.dbService=e,this.deviceInfo=t,this.fileService=n,this.contentDataMap={}}execute(e){return pt(this,void 0,void 0,(function*(){const t=yield this.fileService.readAsText(e.tmpLocation,B.FileName.MANIFEST.valueOf());JSON.parse(t).archive.items.forEach(e=>{this.contentDataMap[e.identifier]=e});const n=new o.Response;try{return yield this.createnWriteManifest(e.identifiers,e.destinationFolder),n.body=e,Promise.resolve(n)}catch(e){return console.error(e),Promise.reject(n)}}))}createnWriteManifest(e,t){return pt(this,void 0,void 0,(function*(){const n=new qe(this.deviceInfo),r=[];for(const i of e){const e=this.contentDataMap[i],o=new Et.a;let s;o.add(e);let a=[];for(a.push(e);!o.isEmpty();)if(s=o.dequeue(),ge.a.hasChildren(s)){const e=ge.a.getChildContentsIdentifiers(s);if(e&&e.length){const t=[];e.forEach(e=>{const n=this.contentDataMap[e];n&&(o.add(n),t.push(n))}),a=a.concat(t)}}const c=n.populateItemList(a),u=n.generateManifestForArchive(c),d={};c&&c[0]&&c[0].parent&&c[0].mimeType===Ie.j.QUESTION?d.path=ge.a.getBasePath(ge.a.getContentRootDir(t).concat("/",c[0].parent,"/",i,"/")):d.path=ge.a.getBasePath(ge.a.getContentRootDir(t).concat("/",i,"/")),d.fileName=B.FileName.MANIFEST.valueOf(),d.data=JSON.stringify(u),r.push(d)}yield this.writeFile(r)}))}writeFile(e){return pt(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.writeFile(e,e=>{t()},e=>{console.error(e),n(e)})})}))}}class St{constructor(e){this.fileService=e}execute(e){const t=new o.Response;return this.fileService.removeRecursively(e.tmpLocation).then(()=>(t.body=e,Promise.resolve(t))).catch(()=>Promise.reject(t))}}class bt{constructor(e){this.fileService=e}execute(e){const t=new o.Response;return this.fileService.createDir(e.tmpLocationPath.concat(L.a.generateUniqueId()),!1).then(n=>(e.tmpLocationPath=n.nativeURL,t.body=e,Promise.resolve(t))).catch(()=>Promise.reject(t))}}class Ot{constructor(e,t,n,r){this.apiService=e,this.contentServiceConfig=t,this.framework=n,this.langCode=r,this.SEARCH_ENDPOINT="/search"}handle(e){const t=this.framework&&this.langCode&&`?framework=${this.framework}&lang=${this.langCode}&orgdetails=orgName`,n=(new o.Request.Builder).withHost(this.contentServiceConfig.host).withType(o.HttpRequestType.POST).withPath(this.contentServiceConfig.searchApiPath.concat(this.SEARCH_ENDPOINT).concat(t||"")).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(W.map)(e=>e.body))}}class vt{constructor(e){this.telemetryService=e}execute(e){e.metadata;const t=[];for(const n of e.items){const e={type:ge.a.readPrimaryCategoryServer(n),origin:ge.a.readOriginFromContentMap(n),identifier:n.identifier,pkgVersion:Number(n.pkgVersion),transferCount:ge.a.readTransferCountFromContentMap(n),size:ge.a.readSizeFromContentMap(n)};t.push(e)}const n={dir:P.ShareDirection.IN,type:P.ShareType.FILE.valueOf(),items:t,env:"sdk",correlationData:e.correlationData,objId:e.items&&e.items.length?e.items[0].identifier:"",objType:e.items&&e.items.length?ge.a.readPrimaryCategoryServer(e.items[0]):"",objVer:e.items&&e.items.length?ge.a.readPkgVersion(e.items[0])+"":"",rollUp:e.rollUp},r=new o.Response;return this.telemetryService.share(n).toPromise().then(()=>(r.body=e,Promise.resolve(r))).catch(()=>Promise.reject(r))}}class Ct{constructor(e){this.telemetryService=e}execute(e,t,n){const r=new o.Response;for(const t of e.items){P.ShareItemType.CONTENT,ge.a.readOriginFromContentMap(t),t.identifier,Number(t.pkgVersion),ge.a.readTransferCountFromContentMap(t),ge.a.readSizeFromContentMap(t)}const i={dir:P.ShareDirection.OUT,type:P.ShareType.FILE.valueOf(),items:[],env:"sdk"};return this.telemetryService.share(i).toPromise().then(()=>{let e;if(n.saveLocally)e=n.destinationFolder.concat(t);else{e=("ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory).concat(t)}const i={exportedFilePath:e};return r.body=i,Promise.resolve(r)}).catch(()=>Promise.reject(r))}}class gt{constructor(e){this.telemetryService=e}execute(e,t){const n=e.items&&e.items.length?e.items[0].identifier:"",r=new P.TelemetryInteractRequest;r.type=P.InteractType.OTHER,r.subType=t,r.pageId="ImportContent",r.id="ImportContent",r.env="sdk",r.objId=n||e.identifier,r.objType=e.items&&e.items.length?ge.a.readPrimaryCategoryServer(e.items[0]):"",r.objVer=e.items&&e.items.length?ge.a.readPkgVersion(e.items[0])+"":"",r.correlationData=e.correlationData;const i=new o.Response;return i.body=e,this.telemetryService.interact(r).pipe(Object(W.map)(()=>i)).toPromise()}}var At=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Tt{constructor(e){this.dbService=e}getUsgaeSpace(e){const t=`SELECT SUM(${f.b.COLUMN_NAME_SIZE_ON_DEVICE}) as total_size\n FROM ${f.b.TABLE_NAME}\n WHERE ${f.b.COLUMN_NAME_VISIBILITY} = '${B.Visibility.DEFAULT.valueOf()}'\n AND ${f.b.COLUMN_NAME_PATH} LIKE '${e.replace("file://","")}%'`;return this.dbService.execute(t).pipe(Object(W.map)(e=>e[0].total_size||0))}getContentUsageSummary(e){return At(this,void 0,void 0,(function*(){const t=[];for(const n of e){const e=yield this.getUsgaeSpace(n).toPromise();t.push({path:n,sizeOnDevice:e})}return t}))}}var Nt=n(44),yt=n.n(Nt);class mt{constructor(e,t,n){this.sharedPreferences=e,this.key=t,this.toStringFunction=n,this.changes=new y.BehaviorSubject(void 0)}addAll(e){return this.asSet().pipe(Object(W.mergeMap)(t=>(e.forEach(e=>t.add(e)),this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(W.mapTo)(void 0)))),Object(W.tap)(()=>this.changes.next(void 0)))}add(e){return this.asSet().pipe(Object(W.mergeMap)(t=>(t.add(e),this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(W.mapTo)(void 0)))),Object(W.tap)(()=>this.changes.next(void 0)))}clear(){return this.sharedPreferences.putString(this.key,"[]").pipe(Object(W.mapTo)(void 0),Object(W.tap)(()=>this.changes.next(void 0)))}remove(e){return this.asSet().pipe(Object(W.mergeMap)(t=>{const n=t.remove(e);return this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(W.mapTo)(n))}),Object(W.tap)(()=>this.changes.next(void 0)))}contains(e){return this.asSet().pipe(Object(W.map)(t=>t.contains(e)))}asList(){return this.sharedPreferences.getString(this.key).pipe(Object(W.map)(e=>e?JSON.parse(e):[]))}asSet(){return this.asList().pipe(Object(W.map)(e=>e.reduce((e,t)=>(e.add(t),e),new yt.a(this.toStringFunction))))}asListChanges(){return this.changes.asObservable().pipe(Object(W.mergeMap)(()=>this.asList()))}}var It=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Mt{constructor(){}execute(e,t){return It(this,void 0,void 0,(function*(){return new Promise((n,r)=>{let i;i=t.saveLocally?t.destinationFolder:"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory,sbutility.copyFile(Pe.getDirecory(e.body.ecarFilePath),i,Pe.getFileName(e.body.ecarFilePath),()=>{n(e)},e=>{console.error(e),n(e)})})}))}}class Dt{constructor(e,t){this.apiService=e,this.contentServiceConfig=t,this.GET_CONTENT_HEIRARCHY_ENDPOINT="/hierarchy"}handle(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.GET).withPath(this.contentServiceConfig.contentHeirarchyAPIPath+this.GET_CONTENT_HEIRARCHY_ENDPOINT+"/"+e.contentId).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(W.map)(e=>this.mapContentFromContentHeirarchyData(e.body.result.content)))}mapContentFromContentHeirarchyData(e){return e.contentData=Object.assign({},e),e.children&&e.children.length&&(e.children=e.children.map(e=>this.mapContentFromContentHeirarchyData(Object.assign({},e)))),e}}var Rt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Pt{constructor(){}execute(e){return Rt(this,void 0,void 0,(function*(){const t=new o.Response;return new Promise((n,r)=>{const i=e.destinationFolder.concat("tmp/");sbutility.rm(i,"",()=>{t.body=e,n(t)},r=>{t.body=e,n(t)})})}))}}var Lt=n(108),wt=n(37),Ut=n(55),jt=n(39),Ft=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class xt{constructor(e,t,n,r,i,o,s,a){this.searchContentHandler=e,this.formService=t,this.contentService=n,this.cachedItemStore=r,this.courseService=i,this.profileService=o,this.apiService=s,this.networkInfoService=a}static buildRequestHash(e){return Ut(JSON.stringify(wt.a.withDeeplyOrderedKeys(e))).toString()}aggregate(e,t,n,r,i=!1){return Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){if(!n&&!r)throw new Error("formRequest or formFields required");let o=[];n?(n.from=e.from,o=yield this.formService.getForm(n).toPromise().then(e=>e.form.data.fields)):r&&(o=r,i=!1),o=o.filter(e=>-1===t.indexOf(e.dataSrc.type));const s=o.map(t=>Ft(this,void 0,void 0,(function*(){if(!t.dataSrc)throw new Error("INVALID_CONFIG");switch(t.dataSrc.type){case"CONTENT_FACETS":return yield this.buildFacetsTask(t,e);case"RECENTLY_VIEWED_CONTENTS":return yield this.buildRecentlyViewedTask(t,e);case"CONTENTS":return yield this.buildContentSearchTask(t,e);case"TRACKABLE_COLLECTIONS":return yield this.buildTrackableCollectionsTask(t,e);case"CONTENT_DISCOVERY_BANNER":return yield this.buildContentDiscoveryBannerTask(t);default:return console.error("UNKNOWN_DATA_SRC"),{requestHash:"",task:Object(y.of)([])}}}))),a=yield Promise.all(s),c=a.map(e=>e.requestHash).join("-"),u=Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){const e=yield this.networkInfoService.networkStatus$.pipe(Object(W.take)(1)).toPromise();if(i&&e===z.NetworkStatus.OFFLINE)throw new Error("ContentAggregator: offline request");return Promise.all(a.map(e=>e.task.toPromise())).then(e=>e.reduce((e,t)=>[...e,...t],[]).sort((e,t)=>e.index-t.index))})));return Object(y.defer)(()=>i?this.cachedItemStore.get(c,xt.CONTENT_AGGREGATION_KEY,"ttl_"+xt.CONTENT_AGGREGATION_KEY,()=>u):u).pipe(Object(W.map)(e=>({result:e}))).toPromise()})))}buildRecentlyViewedTask(e,t){return Ft(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n={uid:t.managedSession?t.managedSession.uid:t.uid,primaryCategories:[],recentlyViewed:!0,limit:20};return{requestHash:"RECENTLY_VIEWED_CONTENTS_"+xt.buildRequestHash(n),task:Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){const t=yield this.contentService.getContents(n).toPromise();return e.sections.map(n=>({index:n.index,title:n.title,data:{name:n.index+"",sections:[{name:n.index+"",count:t.length,contents:t.map(e=>(e.contentData.cardImg=e.contentData.appIcon,e))}]},dataSrc:e.dataSrc,theme:n.theme,description:n.description,landingDetails:n.landingDetails,isEnabled:n.isEnabled}))})))}}))}buildContentDiscoveryBannerTask(e){return Ft(this,void 0,void 0,(function*(){return{requestHash:"CONTENT_DISCOVERY_BANNER"+xt.buildRequestHash(e.dataSrc.type),task:Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){return e.sections.map(t=>({index:t.index,code:t.code,title:t.title,data:e.dataSrc.values.filter(e=>Number(e.expiry)>Math.floor(Date.now()/1e3)),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}))})))}}))}buildFacetsTask(e,t){return Ft(this,void 0,void 0,(function*(){if(e.dataSrc.values)return{requestHash:"",task:Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){return e.sections.map(t=>({index:t.index,code:t.code,title:t.title,data:e.dataSrc.values.sort((e,t)=>e.index-t.index),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}))})))};const{searchRequest:n,searchCriteria:r}=this.buildSearchRequestAndCriteria(e,t);return r.facets=e.dataSrc.mapping.map(e=>e.facet),n.facets=r.facets,n.limit=0,n.offset=0,{requestHash:"CONTENT_FACETS_"+xt.buildRequestHash(n),task:Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){const i=yield this.searchContents(e,r,n);return e.sections.map((n,o)=>{var s,a,c;let u=null!==(s=i.filterCriteria.facetFilters)&&void 0!==s?s:[];const d=[];u.map(t=>{var n,r;const i=null===(r=null===(n=e.dataSrc.params)||void 0===n?void 0:n.config)||void 0===r?void 0:r.find(e=>e.name===t.name);i&&i.mergeableAttributes.map(e=>{d.push(e);const n=u.find(t=>t.name===e);t.values=t.values.filter(e=>i.values.find(t=>t.code===e.name.replace(/\s+/g,"").toLowerCase()));const r=i.values.filter(t=>t.type=e);n&&(n.values=n.values.filter(e=>r.find(t=>t.code===e.name.replace(/\s+/g,""))),t.values=t.values.concat(n.values))})}),u=u.filter(e=>-1===d.indexOf(e.name));const l=u.find(t=>{var n;return t.name===(null===(n=e.dataSrc.mapping[o])||void 0===n?void 0:n.facet)});if(l){const i=null===(c=null===(a=e.dataSrc.params)||void 0===a?void 0:a.config)||void 0===c?void 0:c.find(e=>e.name===l.name);return{index:n.index,title:n.title,code:n.code,data:l.values.map(t=>{var n;const s=i?i.values.find(e=>e.code===t.name.replace(/\s+/g,"").toLowerCase()):[];return{facet:(null==s?void 0:s.name)?s.name:t.name,searchCriteria:Object.assign(Object.assign({},r),{primaryCategories:[],impliedFilters:(null===(n=null==s?void 0:s.searchCriteria)||void 0===n?void 0:n.impliedFilters)?s.searchCriteria.impliedFilters:[{name:l.name,values:[{name:t.name,apply:!0}]}]}),aggregate:e.dataSrc.mapping[o].aggregate,filterPillBy:e.dataSrc.mapping[o].filterPillBy}}).sort((e,n)=>{if(t.userPreferences){const r=t.userPreferences[l.name];if(!r||Array.isArray(r)&&r.indexOf(e.facet)>-1&&r.indexOf(n.facet)>-1||r===e.facet&&r===n.facet)return e.facet.localeCompare(n.facet);if(Array.isArray(r)&&r.indexOf(e.facet)>-1||r===e.facet)return-1;if(Array.isArray(r)&&r.indexOf(n.facet)>-1||r===n.facet)return 1}return e.facet.localeCompare(n.facet)}),dataSrc:e.dataSrc,theme:n.theme,description:n.description,landingDetails:n.landingDetails,isEnabled:n.isEnabled}}return{index:n.index,title:n.title,code:n.code,data:[],dataSrc:e.dataSrc,theme:n.theme,description:n.description,isEnabled:n.isEnabled}})})))}}))}buildTrackableCollectionsTask(e,t){return Ft(this,void 0,void 0,(function*(){const t=this.apiService,n=yield this.profileService.getActiveProfileSession().toPromise();return{requestHash:"TRACKABLE_COLLECTIONS_"+xt.buildRequestHash({userId:n.managedSession?n.managedSession.uid:n.uid}),task:Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){const r=yield this.courseService.getEnrolledCourses({userId:n.managedSession?n.managedSession.uid:n.uid,returnFreshCourses:!0},new class{handle({userId:n}){e.dataSrc.request.path&&(e.dataSrc.request.path=e.dataSrc.request.path.replace("${userId}",n));const r=o.Request.fromJSON(e.dataSrc.request);return t.fetch(r).pipe(Object(W.map)(e=>e.body))}}).toPromise();return e.sections.map((t,n)=>{if(e.dataSrc.mapping[n]&&e.dataSrc.mapping[n].aggregate){const i=e.dataSrc.mapping[n].aggregate;return{index:t.index,title:t.title,data:Lt.CsContentsGroupGenerator.generate({contents:r,groupBy:i.groupBy,sortBy:i.sortBy?this.buildSortByCriteria(i.sortBy):[],filterBy:i.filterBy?this.buildFilterByCriteria(i.filterBy):[],groupSortBy:i.groupSortBy?this.buildSortByCriteria(i.groupSortBy):[],groupFilterBy:i.groupFilterBy?this.buildFilterByCriteria(i.groupFilterBy):[],includeSearchable:!1}),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}}return{index:t.index,title:t.title,data:{name:t.index+"",sections:[{name:t.index+"",count:r.length,contents:r}]},dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}})})))}}))}buildContentSearchTask(e,t){return Ft(this,void 0,void 0,(function*(){const{searchRequest:n,searchCriteria:r}=this.buildSearchRequestAndCriteria(e,t);return{requestHash:"CONTENTS_"+xt.buildRequestHash(n),task:Object(y.defer)(()=>Ft(this,void 0,void 0,(function*(){const i=yield(()=>Ft(this,void 0,void 0,(function*(){return n.filters&&n.filters.primaryCategory||r.primaryCategories&&0===r.primaryCategories.length?[]:this.contentService.getContents({primaryCategories:r.primaryCategories&&r.primaryCategories.length&&r.primaryCategories||n.filters&&n.filters.primaryCategory||[],board:r.board,medium:r.medium,grade:r.grade}).pipe(Object(W.map)(e=>e.map(e=>(e.contentData.appIcon&&!e.contentData.appIcon.startsWith("https://")&&(e.contentData.appIcon=e.basePath+e.contentData.appIcon),e.contentData)))).toPromise()})))(),o=yield this.searchContents(e,r,n),s=(o.contentDataList||[]).filter(e=>!i.find(t=>t.identifier===e.identifier)),a=i.concat(s).map(e=>(e.cardImg=e.appIcon,e));return a.sort((e,t)=>e.lastPublishedOn>t.lastPublishedOn?-1:1),e.sections.map((i,s)=>{if(e.dataSrc.mapping[s]&&e.dataSrc.mapping[s].aggregate){const c=e.dataSrc.mapping[s].aggregate,u=(()=>{const n=Lt.CsContentsGroupGenerator.generate({contents:a,groupBy:c.groupBy,sortBy:c.sortBy?this.buildSortByCriteria(c.sortBy):[],filterBy:c.filterBy?this.buildFilterByCriteria(c.filterBy):[],groupSortBy:c.groupSortBy?this.buildSortByCriteria(c.groupSortBy):[],groupFilterBy:c.groupFilterBy?this.buildFilterByCriteria(c.groupFilterBy):[],combination:e.dataSrc.mapping[s].applyFirstAvailableCombination&&t.applyFirstAvailableCombination,includeSearchable:!1});if(t.userPreferences&&t.userPreferences[c.groupBy]&&n.sections.sort((e,n)=>t.userPreferences[c.groupBy].indexOf(e.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1&&t.userPreferences[c.groupBy].indexOf(n.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?e.name.localeCompare(n.name):t.userPreferences[c.groupBy].indexOf(e.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?-1:t.userPreferences[c.groupBy].indexOf(n.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?1:0),n.name){(o.filterCriteria.facetFilters||[]).map(e=>{let t=e.name==n.name?e.values:[];return n.sections.filter(e=>t.some(t=>(e.name.toLocaleLowerCase()===t.name.toLowerCase()&&(e.totalCount=t.count),e.name===t.name)))})}return n})();return{index:i.index,title:i.title,meta:{searchCriteria:r,filterCriteria:o.filterCriteria,searchRequest:n},data:u,dataSrc:e.dataSrc,theme:i.theme,description:i.description,landingDetails:i.landingDetails,isEnabled:i.isEnabled}}return{index:i.index,title:i.title,meta:{searchCriteria:r,filterCriteria:o.filterCriteria,searchRequest:n},data:{name:i.index+"",sections:[{count:a.length,contents:a}]},dataSrc:e.dataSrc,theme:i.theme,description:i.description,landingDetails:i.landingDetails,isEnabled:i.isEnabled}})})))}}))}buildFilterByCriteria(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>e.push({filterAttribute:n,filterCondition:{operation:t[n].operation,value:t[n].value}})),e),[])}buildSortByCriteria(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>e.push({sortAttribute:n,sortOrder:t[n]})),e),[])}buildSearchRequestAndCriteria(e,t){const n=e=>this.searchContentHandler.getSearchCriteria(e),r=e.dataSrc.request&&e.dataSrc.request.body?Object.assign({filters:{}},e.dataSrc.request.body.request):{filters:{}},i=t.interceptSearchCriteria?t.interceptSearchCriteria(n({request:r})):n({request:r});return{searchRequest:(e=>this.searchContentHandler.getSearchContentRequest(e))(i),searchCriteria:i}}searchContents(e,t,n){const r=this.apiService;return this.contentService.searchContent(t,void 0,new class{handle(t){if(n&&n.filters&&n.filters.mimeType){const e=(e,t)=>jt.MimeTypeCategoryMapping[t]?e.concat(jt.MimeTypeCategoryMapping[t]):e.concat([t]);n.filters.mimeType=n.filters.mimeType.reduce(e,[])}e.dataSrc.request&&e.dataSrc.request.body&&e.dataSrc.request.body.request?e.dataSrc.request.body={request:Object.assign(Object.assign({},e.dataSrc.request.body.request),n)}:e.dataSrc.request.body={request:n};const i=JSON.stringify(wt.a.withDeeplyOrderedKeys(e.dataSrc.request));if(xt.searchContentCache.has(i))return Object(y.of)(xt.searchContentCache.get(i)).pipe(Object(W.map)(e=>e.body));const s=o.Request.fromJSON(e.dataSrc.request);return r.fetch(s).pipe(Object(W.tap)(e=>{xt.searchContentCache.set(i,e)}),Object(W.map)(e=>e.body))}},!0).pipe(Object(W.catchError)(e=>(console.error(e),Object(y.of)({id:"OFFLINE_RESPONSE_ID",responseMessageId:"OFFLINE_RESPONSE_ID",filterCriteria:t,contentDataList:[]})))).toPromise()}}xt.searchContentCache=new Map,xt.CONTENT_AGGREGATION_KEY="content-aggregation";var kt=n(302),Bt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Vt{constructor(e,t){this.storageService=e,this.fileService=t}getLocallyAvailableQuestion(e,t){const n=this.storageService.getStorageDestinationDirectoryPath();let r=[];return e.forEach(e=>Bt(this,void 0,void 0,(function*(){const i=this.fileService.readAsText("ios"===window.device.platform.toLowerCase()?`${n}/content/${t}/${e}`:`${n}content/${t}/${e}`,"index.json");r.push(i)}))),Object(y.from)(Promise.all(r)).pipe(Object(W.map)(e=>({questions:e.map(e=>{if(e&&"string"==typeof e){return JSON.parse(e).archive.items[0]}return e}),count:e.length})))}}var Yt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},Gt=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}};class Ht{constructor(e,t,n,r){this.contentService=e,this.dbService=t,this.storageService=n,this.fileService=r}handle(e){return Yt(this,void 0,void 0,(function*(){const t=this.getQuery(e);let n;if(n=yield this.getQuestionSetFromQuery(t),!n||!n.isAvailableLocally)return yield this.fetchServerChildQuestions(e);if(!n.children)return[];const r=this.storageService.getStorageDestinationDirectoryPath();try{n=yield this.fetchDBChildQuestions(n,r)}catch(e){return n.children}return n.children}))}fetchDBChildQuestions(e,t){var n,r;return Yt(this,void 0,void 0,(function*(){if(!e||!e.children)return e;const i=[];try{for(var o,s=Gt(e.children);!(o=yield s.next()).done;){const n=o.value;if("QuestionSet"===n.objectType){let e;const r=this.getQuery(n.identifier);e=yield this.getQuestionSetFromQuery(r),e&&e.children&&(e=yield this.fetchDBChildQuestions(e,t),i.push(e))}else if("Question"===n.objectType){const r=yield this.fileService.readAsText(`${t}content/${e.identifier}/${n.identifier}`,"index.json");if(r&&"string"==typeof r){const e=JSON.parse(r);e&&e.archive&&e.archive.items.length&&i.push(e.archive.items[0])}}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=s.return)&&(yield r.call(s))}finally{if(n)throw n.error}}return e.children=i,e}))}getQuery(e){return`SELECT * FROM ${f.b.TABLE_NAME} WHERE (${f.b.COLUMN_NAME_IDENTIFIER} = '${e}')`}getQuestionSetFromQuery(e){return Yt(this,void 0,void 0,(function*(){try{const t=yield this.dbService.execute(e).toPromise();if(t&&t.length&&t[0][f.b.COLUMN_NAME_LOCAL_DATA]){const e=JSON.parse(t[0][f.b.COLUMN_NAME_LOCAL_DATA]);return e.isAvailableLocally=ge.a.isAvailableLocally(t[0][f.b.COLUMN_NAME_CONTENT_STATE]),e}return null}catch(e){return null}}))}fetchServerChildQuestions(e){return Yt(this,void 0,void 0,(function*(){const t=yield this.contentService.getQuestionSetHierarchy(e).toPromise();return t&&t.questionset&&t.questionset.children?t.questionset.children:[]}))}}var qt,$t=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Kt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zt=function(e,t){return function(n,r){t(n,r,e)}},Wt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let Xt=qt=class{constructor(e,t,n,r,i,o,s,a,c,u,d,l,f,h,E,p,_){this.sdkConfig=e,this.apiService=t,this.dbService=n,this.profileService=r,this.fileService=i,this.zipService=o,this.deviceInfo=s,this.telemetryService=a,this.contentFeedbackService=c,this.downloadService=u,this.sharedPreferences=d,this.eventsBusService=l,this.cachedItemStore=f,this.appInfo=h,this.networkInfoService=E,this.container=p,this.storageService=_,this.contentUpdateSizeOnDeviceTimeoutRef=new Map,this.contentServiceConfig=this.sdkConfig.contentServiceConfig,this.appConfig=this.sdkConfig.appConfig,this.getContentDetailsHandler=new me(this.contentFeedbackService,this.profileService,this.apiService,this.contentServiceConfig,this.dbService,this.eventsBusService),this.getContentHeirarchyHandler=new Dt(this.apiService,this.contentServiceConfig),this.questionSetFileReadHandler=new Vt(this.storageService,this.fileService),this.getChildQuestionSetHandler=new Ht(this,this.dbService,this.storageService,this.fileService),this.contentDeleteRequestSet=new mt(this.sharedPreferences,qt.KEY_CONTENT_DELETE_REQUEST_LIST,e=>e.contentId)}onInit(){return this.downloadService.registerOnDownloadCompleteDelegate(this),Object(y.combineLatest)([this.handleContentDeleteRequestSetChanges(),this.handleUpdateSizeOnDeviceFail()]).pipe(Object(W.mapTo)(void 0))}getContentDetails(e){return this.getContentDetailsHandler.handle(e)}getContentHeirarchy(e){return this.getContentHeirarchyHandler.handle(e)}getContents(e){const t=(new xe).getAllLocalContentQuery(e);return this.dbService.execute(t).pipe(Object(W.mergeMap)(t=>Object(y.defer)(()=>Wt(this,void 0,void 0,(function*(){const n=[];for(const r of t){let t=Ce.a.mapContentDBEntryToContent(r);t=yield this.getContentDetailsHandler.decorateContent({content:t,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentAccess,attachFeedback:e.attachFeedback}).toPromise(),n.push(t)}if(e.resourcesOnly){const t=e.uid,r=`SELECT * FROM ${f.d.TABLE_NAME}\n WHERE UID IN (${V.a.joinPreservingQuotes(t)})`;(yield this.dbService.execute(r).toPromise()).forEach(e=>{const t={identifier:e[f.d.COLUMN_NAME_CONTENT_IDENTIFIER],name:"",contentData:e[f.d.COLUMN_NAME_DATA]&&JSON.parse(e[f.d.COLUMN_NAME_DATA]),isUpdateAvailable:!1,mimeType:"",basePath:"",contentType:"",primaryCategory:"",isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0};n.push(t)})}return n})))))}cancelImport(e){return this.downloadService.cancel({identifier:e})}deleteContent(e){return Object(y.defer)(()=>Wt(this,void 0,void 0,(function*(){e.contentDeleteList.forEach(e=>{const t=this.contentUpdateSizeOnDeviceTimeoutRef.get(e.contentId);t&&(clearTimeout(t),this.contentUpdateSizeOnDeviceTimeoutRef.delete(e.contentId))});const t=[],n=new we(this.dbService,this.fileService,this.sharedPreferences);for(const r of e.contentDeleteList){const e=yield this.getContentDetailsHandler.fetchFromDB(r.contentId).toPromise();e?(t.push({identifier:r.contentId,status:B.ContentDeleteStatus.DELETED_SUCCESSFULLY}),ge.a.hasChildren(e[f.b.COLUMN_NAME_LOCAL_DATA])&&(yield n.deleteAllChildren(e,r.isChildContent)),yield n.deleteOrUpdateContent(e,!1,r.isChildContent)):t.push({identifier:r.contentId,status:B.ContentDeleteStatus.NOT_FOUND})}return new ct(this.dbService,this.sharedPreferences,this.fileService).execute(),t}))).pipe(Object(W.tap)(()=>e.contentDeleteList.forEach(e=>{this.downloadService.onContentDelete(e.contentId)})))}enqueueContentDelete(e){return this.contentDeleteRequestSet.addAll(e.contentDeleteList)}clearContentDeleteQueue(){return this.contentDeleteRequestSet.clear()}getContentDeleteQueue(){return this.contentDeleteRequestSet.asListChanges()}exportContent(e){const t=new qe(this.deviceInfo,this.dbService,this.fileService);return Object(y.from)(t.getContentExportDBModelToExport(e.contentIds).then(n=>this.fileService.getTempLocation(e.destinationFolder).then(t=>{const r={},i=ge.a.getExportedFileName(n,this.appInfo.getAppName());r.content_count=n.length;const o={metadata:r,ecarFilePath:t.nativeURL.concat(i),destinationFolder:e.destinationFolder,contentModelsToExport:n,tmpLocationPath:t.nativeURL,subContentIds:e.subContentIds};return new bt(this.fileService).execute(o)}).then(e=>new $e(this.dbService,t).execute(e.body)).then(e=>new Ke(this.fileService,this.deviceInfo).execute(e.body)).then(e=>new We(this.zipService).execute(e.body)).then(e=>new Je(this.fileService).execute(e.body)).then(e=>(new Ze).execute(e.body)).then(e=>new tt(this.fileService,this.zipService).execute(e.body)).then(t=>(new Mt).execute(t,e)).then(e=>(new Pt).execute(e.body)).then(t=>{const r=ge.a.getExportedFileName(n,this.appInfo.getAppName());return new Ct(this.telemetryService).execute(t.body,r,e)}).then(e=>e.body)))}getChildContents(e){e.level||(e.level=-1);const t=new Re(this.dbService,this.getContentDetailsHandler,this.appConfig);let n=e.hierarchyInfo;if(n){if(n.length>0&&n[n.length-1].identifier===e.contentId){const e=n.length;n.splice(e-1,1)}}else n=[];return this.dbService.read(me.getReadContentQuery(e.contentId)).pipe(Object(W.mergeMap)(r=>Wt(this,void 0,void 0,(function*(){const i=new Map,o=JSON.parse(r[0][f.b.COLUMN_NAME_LOCAL_DATA]).childNodes;if(console.log("childIdentifiers",o),o){const e=`SELECT * FROM ${f.b.TABLE_NAME}\n WHERE ${f.b.COLUMN_NAME_IDENTIFIER}\n IN (${V.a.joinPreservingQuotes(o)})`;(yield this.dbService.execute(e).toPromise()).forEach(e=>{i.set(e.identifier,e)})}let s=yield t.fetchChildrenOfContent(r[0],i,0,e.level,n);return console.log("childContentHandler-",s),s}))))}getDownloadState(){throw new Error("Not Implemented yet")}importContent(e){const t=new Fe(this.appConfig,this.contentServiceConfig,this.telemetryService),n=V.a.deDupe(e.contentImportArray.map(e=>e.contentId)),r=t.getContentSearchFilter(n,e.contentStatusArray,e.fields);return new Ot(this.apiService,this.contentServiceConfig).handle(r).pipe(Object(W.map)(e=>e.result.content&&e.result.content.length&&e.result.QuestionSet&&e.result.QuestionSet.length?e.result.content.concat(e.result.QuestionSet):e.result.content||e.result.QuestionSet),Object(W.mergeMap)(r=>Object(y.defer)(()=>Wt(this,void 0,void 0,(function*(){const i=[];if(r&&r.length){const o=[];for(const s of n){const n=r.find(e=>e.identifier===s);if(n){const r=e.contentImportArray.find(e=>e.contentId===s),a=yield t.getDownloadUrl(n,r);let c=B.ContentImportStatus.NOT_FOUND;if(a&&Pe.getFileExtension(a)===B.FileExtension.CONTENT.valueOf()){c=B.ContentImportStatus.ENQUEUED_FOR_DOWNLOAD;const t={identifier:s,downloadUrl:a,mimeType:B.MimeType.ECAR,destinationFolder:r.destinationFolder,isChildContent:r.isChildContent,filename:s.concat(".",B.FileExtension.CONTENT),correlationData:r.correlationData,rollUp:r.rollUp,contentMeta:n,withPriority:e.withPriority||(n.mimeType===B.MimeType.COLLECTION.valueOf()?1:0),title:n.name?n.name.concat(".",B.FileExtension.CONTENT):s.concat(".",B.FileExtension.CONTENT)};o.push(t),console.log("downloadRequestList-",o)}i.push({identifier:s,status:c})}}this.downloadService.download(o).toPromise().then()}return i})))))}importEcar(e){return Object(y.from)(this.fileService.exists(e.sourceFilePath).then(t=>{const n={isChildContent:e.isChildContent,ecarFilePath:e.sourceFilePath,destinationFolder:e.destinationFolder,skippedItemsIdentifier:[],items:[],contentImportResponseList:[],correlationData:e.correlationData||[],rollUp:e.rollUp||new P.Rollup,contentIdsToDelete:new Set,identifier:e.identifier};return new gt(this.telemetryService).execute(n,"ContentImport-Initiated").then(()=>this.fileService.getTempLocation(e.destinationFolder)).then(e=>(n.tmpLocation=e.nativeURL,new rt(this.fileService,this.zipService).execute(n))).then(e=>new st(this.fileService,this.dbService,this.appConfig,this.getContentDetailsHandler).execute(e.body)).then(e=>new ft(this.fileService,this.zipService,this.appConfig,this.dbService,this.deviceInfo,this.getContentDetailsHandler,this.eventsBusService,this.sharedPreferences).execute(e.body)).then(([e,t])=>{this.contentUpdateSizeOnDeviceTimeoutRef.set(n.rootIdentifier?n.rootIdentifier:n.identifiers[0],t),this.eventsBusService.emit({namespace:k.EventNamespace.CONTENT,event:{type:B.ContentEventType.CONTENT_EXTRACT_COMPLETED,payload:{contentId:n.rootIdentifier?n.rootIdentifier:n.identifiers[0]}}});new o.Response;return new _t(this.dbService,this.deviceInfo,this.fileService).execute(e.body)}).then(e=>new St(this.fileService).execute(e.body)).then(e=>{const t=new o.Response;return this.cleanupContent(n).toPromise().then(()=>(t.body=n,Promise.resolve(t))).catch(()=>Promise.reject(t))}).then(e=>new vt(this.telemetryService).execute(e.body)).then(e=>new gt(this.telemetryService).execute(e.body,"ContentImport-Success")).then(e=>(this.eventsBusService.emit({namespace:k.EventNamespace.CONTENT,event:{type:B.ContentEventType.IMPORT_COMPLETED,payload:{contentId:n.rootIdentifier?n.rootIdentifier:n.identifiers[0]}}}),e.body.contentImportResponseList))}).catch(e=>(console.log("error",e),[{identifier:"",status:B.ContentImportStatus.NOT_FOUND}])))}nextContent(e,t,n){const r=new Re(this.dbService,this.getContentDetailsHandler,this.appConfig);return this.dbService.read(me.getReadContentQuery(e[0].identifier)).pipe(Object(W.mergeMap)(i=>Wt(this,void 0,void 0,(function*(){const o=yield r.getContentsKeyList(i[0]),s=r.getNextContentIdentifier(e,t,o);return r.getContentFromDB(e,s,n)}))))}prevContent(e,t,n){const r=new Re(this.dbService,this.getContentDetailsHandler,this.appConfig);return this.dbService.read(me.getReadContentQuery(e[0].identifier)).pipe(Object(W.mergeMap)(i=>Wt(this,void 0,void 0,(function*(){const o=yield r.getContentsKeyList(i[0]),s=r.getPreviousContentIdentifier(e,t,o);return r.getContentFromDB(e,s,n)}))))}getRelevantContent(e){const t={};return Object(y.of)(t).pipe(Object(W.mergeMap)(n=>e.next?this.nextContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(W.map)(e=>(t.nextContent=e,t))):Object(y.of)(t)),Object(W.mergeMap)(n=>e.prev?this.prevContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(W.map)(e=>(t.previousContent=e,t))):Object(y.of)(t)),Object(W.map)(e=>{const t={};return t.next=e.nextContent?{content:e.nextContent}:void 0,t.prev=e.previousContent?{content:e.previousContent}:void 0,t}))}subscribeForImportStatus(e){throw new Error("Not Implemented yet")}searchContent(e,t,n,r){if((e=JSON.parse(JSON.stringify(e))).facetFilters){const t=e.facetFilters.find(e=>"mimeType"===e.name);t&&(t.values=t.values.filter(e=>e.apply).reduce((e,t)=>e=e.concat(t.values.map(e=>Object.assign(Object.assign({},e),{apply:!0}))),[]))}const i=new Fe(this.appConfig,this.contentServiceConfig,this.telemetryService),o=e.languageCode;t?(e=i.getSearchCriteria(t),o&&(e.languageCode=o)):(e.limit=e.limit?e.limit:100,e.offset=e.offset?e.offset:0);const s=i.getSearchContentRequest(e);return this.sharedPreferences.getString(X.j.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID).pipe(Object(W.mergeMap)(t=>(n||(n=new Ot(this.apiService,this.contentServiceConfig,t,e.languageCode)),n.handle(s).pipe(Object(W.map)(t=>(e.facetFilters||e.searchType!==B.SearchType.SEARCH||(r||(s.filters.contentType=[],s.filters.primaryCategory=[]),s.filters.audience=[]),i.mapSearchResponse(e,t,s))),Object(W.map)(t=>{if(!t.filterCriteria.facetFilters)return t;const n=t.filterCriteria.facetFilters.find(e=>"mimeType"===e.name);return n&&(n.values=kt.CsMimeTypeFacetToMimeTypeCategoryAggregator.aggregate(n.values,"filter"===e.searchType?[jt.MimeTypeCategory.ALL]:[])),t})))))}cancelDownload(e){return this.downloadService.cancel({identifier:e})}setContentMarker(e){const t=`SELECT * FROM ${f.d.TABLE_NAME}\n WHERE ${f.d.COLUMN_NAME_UID} = '${e.uid}'\n AND ${f.d.COLUMN_NAME_CONTENT_IDENTIFIER}='${e.contentId}'\n AND ${f.d.COLUMN_NAME_MARKER} = ${e.marker}`;return this.dbService.execute(t).pipe(Object(W.mergeMap)(t=>{const n={uid:e.uid,identifier:e.contentId,epoch_timestamp:Date.now(),data:e.data,extra_info:JSON.stringify(e.extraInfo),marker:e.marker.valueOf(),mime_type:this.getMimeType(e.data)};return V.a.isEmpty(t)?this.dbService.insert({table:f.d.TABLE_NAME,modelJson:n}).pipe(Object(W.map)(e=>e>0)):e.isMarked?this.dbService.update({table:f.d.TABLE_NAME,selection:`${f.d.COLUMN_NAME_UID}= ? AND ${f.d.COLUMN_NAME_CONTENT_IDENTIFIER}= ? AND ${f.d.COLUMN_NAME_MARKER}= ?`,selectionArgs:[e.uid,e.contentId,e.marker.valueOf().toString()],modelJson:n}).pipe(Object(W.map)(e=>e>0)):this.dbService.delete({table:f.d.TABLE_NAME,selection:`${f.d.COLUMN_NAME_UID} = ? AND ${f.d.COLUMN_NAME_CONTENT_IDENTIFIER} = ? AND ${f.d.COLUMN_NAME_MARKER} = ?`,selectionArgs:[e.uid,e.contentId,""+e.marker]}).pipe(Object(W.map)(e=>e))}))}onDownloadCompletion(e){const t={isChildContent:e.isChildContent,sourceFilePath:e.downloadedFilePath,destinationFolder:e.destinationFolder,correlationData:e.correlationData,rollUp:e.rollUp,identifier:e.identifier};return this.importEcar(t).pipe(Object(W.mergeMap)(()=>this.downloadService.cancel({identifier:e.identifier},!1)),Object(W.catchError)(()=>this.downloadService.cancel({identifier:e.identifier},!1)),Object(W.mapTo)(void 0))}getContentSpaceUsageSummary(e){const t=new Tt(this.dbService);return Object(y.from)(t.getContentUsageSummary(e.paths))}buildContentAggregator(e,t,n){return new xt(new Fe(this.appConfig,this.contentServiceConfig,this.telemetryService),e,this,this.cachedItemStore,t,n,this.apiService,this.networkInfoService)}getQuestionList(e,t){return this.getContentDetails({contentId:t,objectType:"QuestionSet"}).pipe(Object(W.switchMap)(n=>n.isAvailableLocally&&t?this.questionSetFileReadHandler.getLocallyAvailableQuestion(e,t):this.contentServiceDelegate.getQuestionList(e)),Object(W.catchError)(t=>this.contentServiceDelegate.getQuestionList(e)))}getQuestionSetHierarchy(e){return this.contentServiceDelegate.getQuestionSetHierarchy(e)}getQuestionSetRead(e,t){return this.contentServiceDelegate.getQuestionSetRead(e,t)}getQuestionSetChildren(e){return Wt(this,void 0,void 0,(function*(){try{return yield this.getChildQuestionSetHandler.handle(e)}catch(e){return[]}}))}formatSearchCriteria(e){return new Fe(this.appConfig,this.contentServiceConfig,this.telemetryService).getSearchCriteria(e)}cleanupContent(e){const t=[];for(const n of Array.from(e.contentIdsToDelete.values())){const e={contentId:n,isChildContent:!1};t.push(e)}return this.deleteContent({contentDeleteList:t}).pipe(Object(W.mapTo)(void 0))}getMimeType(e){let t="";if(e){t=JSON.parse(e).mimeType}return t}handleContentDeleteRequestSetChanges(){return this.contentDeleteRequestSet.asListChanges().pipe(Object(W.mergeMap)(e=>{const t=e[0];return t?this.deleteContent({contentDeleteList:[t]}).pipe(Object(W.mergeMap)(()=>this.contentDeleteRequestSet.remove(t)),Object(W.mapTo)(void 0)):Object(y.of)(void 0)}))}handleUpdateSizeOnDeviceFail(){return this.sharedPreferences.getBoolean(qt.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL).pipe(Object(W.mergeMap)(e=>e?Object(y.of)(void 0):Object(y.from)(new ct(this.dbService,this.sharedPreferences,this.fileService).execute()).pipe(Object(W.mapTo)(void 0))))}get contentServiceDelegate(){return this.container.get(N.a.CONTENT_SERVICE)}downloadTranscriptFile(e){const t="ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalDataDirectory+qt.DOWNLOAD_DIR_NAME;return this.createTranscriptDir(e,t).then(()=>{const n={uri:e.downloadUrl,title:e.fileName,description:"",mimeType:"",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:e.fileName},headers:[],destinationUri:e.destinationUrl};return this.downloadTranscript(n).toPromise().then(n=>{if(n&&n.path)return this.copyFile(n.path.split(/\/(?=[^\/]+$)/)[0],t.concat("/"+e.identifier),e.fileName).then(()=>{this.deleteFolder(n.path)}),n.path})})}createTranscriptDir(e,t){return this.fileService.exists(t.concat("/"+e.identifier)).then(e=>e.nativeURL).catch(()=>this.fileService.createDir(t,!1).then(n=>{this.fileService.createDir(t.concat("/"+e.identifier),!1).then(e=>e.nativeURL)}))}downloadTranscript(e){return new y.Observable(t=>{downloadManager.enqueue(e,(e,n)=>{if(e)return t.error(e);t.next(n),t.complete()})}).pipe(Object(W.mergeMap)(e=>Object(y.interval)(1e3).pipe(Object(W.mergeMap)(()=>new y.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||16===n[0].status?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(W.filter)(e=>8===e.status),Object(W.take)(1))),Object(W.map)(e=>({path:e.localUri})))}copyFile(e,t,n){return Wt(this,void 0,void 0,(function*(){return new Promise((r,i)=>{sbutility.copyFile(e,t,n,()=>{r(!0)},e=>{console.error(e),r(e)})})}))}deleteFolder(e){return Wt(this,void 0,void 0,(function*(){if(!e)return;return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}};Xt.DOWNLOAD_DIR_NAME="transcript",Xt.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL=X.f.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,Xt.KEY_CONTENT_DELETE_REQUEST_LIST=X.f.KEY_CONTENT_DELETE_REQUEST_LIST,Xt=qt=$t([Object(T.injectable)(),zt(0,Object(T.inject)(N.b.SDK_CONFIG)),zt(1,Object(T.inject)(N.b.API_SERVICE)),zt(2,Object(T.inject)(N.b.DB_SERVICE)),zt(3,Object(T.inject)(N.b.PROFILE_SERVICE)),zt(4,Object(T.inject)(N.b.FILE_SERVICE)),zt(5,Object(T.inject)(N.b.ZIP_SERVICE)),zt(6,Object(T.inject)(N.b.DEVICE_INFO)),zt(7,Object(T.inject)(N.b.TELEMETRY_SERVICE)),zt(8,Object(T.inject)(N.b.CONTENT_FEEDBACK_SERVICE)),zt(9,Object(T.inject)(N.b.DOWNLOAD_SERVICE)),zt(10,Object(T.inject)(N.b.SHARED_PREFERENCES)),zt(11,Object(T.inject)(N.b.EVENTS_BUS_SERVICE)),zt(12,Object(T.inject)(N.b.CACHED_ITEM_STORE)),zt(13,Object(T.inject)(N.b.APP_INFO)),zt(14,Object(T.inject)(N.b.NETWORKINFO_SERVICE)),zt(15,Object(T.inject)(N.b.CONTAINER)),zt(16,Object(T.inject)(N.b.STORAGE_SERVICE)),Kt("design:paramtypes",[Object,Object,s.DbService,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,T.Container,Object])],Xt);var Jt=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Qt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Zt=function(e,t){return function(n,r){t(n,r,e)}};let en=class{constructor(e){this.dbService=e}getValue(e){return this.dbService.read({table:p.a.TABLE_NAME,columns:[],selection:p.a.COLUMN_NAME_KEY+" = ?",selectionArgs:[e]}).pipe(Object(W.map)(e=>e[0]&&e[0].value))}setValue(e,t){return this.getValue(e).pipe(Object(W.mergeMap)(n=>n?this.dbService.update({table:p.a.TABLE_NAME,selection:p.a.COLUMN_NAME_KEY+" = ?",selectionArgs:[e],modelJson:{[p.a.COLUMN_NAME_KEY]:e,[p.a.COLUMN_NAME_VALUE]:t}}).pipe(Object(W.map)(e=>e>0)):this.dbService.insert({table:p.a.TABLE_NAME,modelJson:{[p.a.COLUMN_NAME_KEY]:e,[p.a.COLUMN_NAME_VALUE]:t}}).pipe(Object(W.map)(e=>e>0))))}};en=Jt([Object(T.injectable)(),Zt(0,Object(T.inject)(N.b.DB_SERVICE)),Qt("design:paramtypes",[s.DbService])],en);var tn=n(21),nn=n(45);class rn{constructor(e,t,n,r){this.apiService=e,this.formServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.FORM_FILE_KEY_PREFIX="form-",this.FORM_LOCAL_KEY="form-",this.GET_FORM_DETAILS_ENDPOINT="/read"}static getIdForRequest(e){let t=`${e.type}_${e.subType}_${e.action}`;return e.rootOrgId&&"*"!==e.rootOrgId&&(t+="_"+e.rootOrgId),e.framework&&(t+="_"+e.framework),e.component&&(t+="_"+e.component),t}handle(e){return this.cachedItemStore[e.from===tn.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](rn.getIdForRequest(e),this.FORM_LOCAL_KEY,"ttl_"+this.FORM_LOCAL_KEY,()=>this.fetchFormServer(e),()=>this.fetchFromFile(e))}fetchFormServer(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(this.formServiceConfig.apiPath+this.GET_FORM_DETAILS_ENDPOINT).withBearerToken(!0).withHeaders({"X-Platform-Id":window.device.platform}).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(W.map)(e=>e.body.result))}fetchFromFile(e){const t=nn.a.getAssetPath()+this.formServiceConfig.formConfigDirPath,n=this.FORM_FILE_KEY_PREFIX+rn.getIdForRequest(e)+".json";return Object(y.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(W.map)(e=>JSON.parse(e).result))}}var on=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},sn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},an=function(e,t){return function(n,r){t(n,r,e)}};let cn=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedItemStore=r,this.formServiceConfig=this.sdkConfig.formServiceConfig}getForm(e){return new rn(this.apiService,this.formServiceConfig,this.fileService,this.cachedItemStore).handle(e)}};cn=on([Object(T.injectable)(),an(0,Object(T.inject)(N.b.SDK_CONFIG)),an(1,Object(T.inject)(N.b.API_SERVICE)),an(2,Object(T.inject)(N.b.FILE_SERVICE)),an(3,Object(T.inject)(N.b.CACHED_ITEM_STORE)),sn("design:paramtypes",[Object,Object,Object,Object])],cn);var un,dn=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ln=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},fn=function(e,t){return function(n,r){t(n,r,e)}},hn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let En=un=class{constructor(e,t,n){this.sdkConfig=e,this.keyValueStore=t,this.sharedPreferences=n,this.apiConfig=this.sdkConfig.apiConfig}static isItemEmpty(e){return!(!Array.isArray(e)||0!==e.length)||"object"==typeof e&&0===Object.keys(e).length}get(e,t,n,r,i,o,s){return r().pipe(Object(W.tap)(r=>{this.saveItemTTL(e,n).toPromise(),this.saveItemToDb(e,t,r).toPromise()}),Object(W.catchError)(()=>this.getCached(e,t,n,r,i,o,s)))}getCached(e,t,n,r,i,o,s){return this.isItemCachedInDb(n,e).pipe(Object(W.mergeMap)(a=>a?this.isItemTTLExpired(n,e,isNaN(o)?this.apiConfig.cached_requests.timeToLive:o).pipe(Object(W.mergeMap)(i=>i?this.keyValueStore.getValue(t+"-"+e).pipe(Object(W.map)(e=>JSON.parse(e)),Object(W.tap)(()=>hn(this,void 0,void 0,(function*(){try{yield r().pipe(Object(W.switchMap)(r=>this.saveItem(e,n,t,r,s))).toPromise()}catch(e){console.error(e)}})))):this.keyValueStore.getValue(t+"-"+e).pipe(Object(W.map)(e=>JSON.parse(e))))):i?i().pipe(Object(W.switchMap)(r=>this.saveItem(e,n,t,r,s)),Object(W.catchError)(i=>r().pipe(Object(W.switchMap)(r=>this.saveItem(e,n,t,r,s))))):r().pipe(Object(W.switchMap)(r=>this.saveItem(e,n,t,r,s)))))}isItemCachedInDb(e,t){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(W.mergeMap)(e=>Object(y.iif)(()=>!!e,Object(y.defer)(()=>Object(y.of)(!0)),Object(y.defer)(()=>Object(y.of)(!1)))))}isItemTTLExpired(e,t,n){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(W.map)(e=>{const t=Number(e);return!(Date.now()-t<n)}))}saveItem(e,t,n,r,i){return un.isItemEmpty(r)||i&&i(r)?Object(y.of)(r):Object(y.zip)(this.saveItemTTL(e,t),this.saveItemToDb(e,n,r)).pipe(Object(W.switchMap)(()=>Object(y.of)(r)))}saveItemTTL(e,t){return this.sharedPreferences.putString(t+"-"+e,Date.now()+"").pipe(Object(W.mergeMap)(e=>Object(y.of)(!0)))}saveItemToDb(e,t,n){return this.keyValueStore.setValue(t+"-"+e,JSON.stringify(n))}};En=un=dn([Object(T.injectable)(),fn(0,Object(T.inject)(N.b.SDK_CONFIG)),fn(1,Object(T.inject)(N.b.KEY_VALUE_STORE)),fn(2,Object(T.inject)(N.b.SHARED_PREFERENCES)),ln("design:paramtypes",[Object,Object,Object])],En);var pn=n(59),_n=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Sn{constructor(e,t,n,r,i,o,s,a){this.apiService=e,this.pageApiServiceConfig=t,this.sharedPreferences=n,this.cachedItemStore=r,this.keyValueStore=i,this.authService=o,this.profileService=s,this.systemSettingsService=a,this.PAGE_ASSEMBLE_LOCAL_KEY="page_assemble-",this.PAGE_ASSEMBLE_ENDPOINT="/page/assemble?orgdetails=orgName",this.DIALCODE_ASSEMBLE_ENDPOINT="/dial/assemble"}static getIdForDb(e){return e.name+"-"+(e.organisationId||"")+"-"+(e.source||"app")+"-"+(e.mode||"")+"-"+(e.filters?Ut(JSON.stringify(e.filters)).toString():"")+(e.sections?Ut(JSON.stringify(e.sections)).toString():"")}handle(e){return e.from=e.from||tn.CachedItemRequestSourceFrom.CACHE,Object(y.defer)(()=>_n(this,void 0,void 0,(function*(){if(e.name!==pn.PageName.COURSE)return e;const t=yield this.sharedPreferences.getString(X.l.KEY_ORGANISATION_ID).toPromise();if(!t)return e;if(yield(()=>_n(this,void 0,void 0,(function*(){const e=!!(yield this.authService.getSession().toPromise()),t=yield this.profileService.isDefaultChannelProfile().toPromise();return e&&!t})))())return e;const n=yield this.systemSettingsService.getSystemSettings({id:Sn.SYSTEM_SETTINGS_TENANT_COURSE_PAGE_ID}).toPromise().then(e=>{try{return JSON.parse(e.value)}catch(e){return console.error(e),[]}});e.organisationId=t;const r=n.find(e=>e.channelId===t);return r&&(e.name=r.page),e}))).pipe(Object(W.mergeMap)(e=>e.from===tn.CachedItemRequestSourceFrom.SERVER?this.fetchFromServer(e).pipe(Object(W.catchError)(()=>this.fetchFromCache(e))):this.fetchFromCache(e)))}fetchFromServer(e){const t=e.name===pn.PageName.DIAL_CODE?this.DIALCODE_ASSEMBLE_ENDPOINT:this.PAGE_ASSEMBLE_ENDPOINT,n=(new o.Request.Builder).withHost(this.pageApiServiceConfig.host).withType(o.HttpRequestType.POST).withPath(this.pageApiServiceConfig.apiPath+t).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(W.map)(e=>e.body.result.response),Object(W.tap)(t=>{const n=JSON.stringify(t);this.sharedPreferences.putString("ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+Sn.getIdForDb(e),Date.now()+"").toPromise(),this.keyValueStore.setValue(this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+Sn.getIdForDb(e),n).toPromise()}))}fetchFromCache(e){return this.cachedItemStore.getCached(Sn.getIdForDb(e),this.PAGE_ASSEMBLE_LOCAL_KEY,"ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY,()=>this.fetchFromServer(e))}}Sn.SYSTEM_SETTINGS_TENANT_COURSE_PAGE_ID="tenantCoursePage";var bn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class On{constructor(e,t){this.defaultDelegate=e,this.dbService=t}handle(e){return Object(y.defer)(()=>bn(this,void 0,void 0,(function*(){let t;try{t=yield this.defaultDelegate.handle(e).toPromise()}catch(e){console.error(e)}if(e.filters&&e.filters.dialcodes){const n=`SELECT c.* FROM content c WHERE ref_count > 0 AND dialcodes LIKE '%%~${e.filters.dialcodes}~%%'`,r=(yield this.dbService.execute(n).toPromise()).map(e=>Ce.a.mapContentDBEntryToContent(e).contentData);t&&t.sections[0]&&r.length?t=yield this.mergePageAssembleWithLocalContents(t,r):!t&&r.length&&(t=yield this.buildPageAssembleWithLocalContents(r))}if(!t)throw new Error("NO_DATA");return t})))}buildPageAssembleWithLocalContents(e){return bn(this,void 0,void 0,(function*(){const t={name:"",id:"",sections:[{display:"",count:0,index:0,sectionDataType:"",resmsgId:"",searchQuery:"",name:"",id:"",apiId:"",group:0,contents:e}]};return this.mergePageAssembleWithLocalCollections(t,e)}))}mergePageAssembleWithLocalContents(e,t){return bn(this,void 0,void 0,(function*(){const n=e.sections[0];if(n.contents&&n.contents.length){const r=t.filter(e=>!n.contents.find(t=>t.identifier===e.identifier));r.length&&(n.contents=[...r,...n.contents],e=yield this.mergePageAssembleWithLocalCollections(e,r))}else n.contents=t,e=yield this.mergePageAssembleWithLocalCollections(e,t);return e}))}mergePageAssembleWithLocalCollections(e,t){return bn(this,void 0,void 0,(function*(){const n=e.sections[0];n.collections||(n.collections=[]);for(const e of t){const t=`SELECT c.* FROM content c WHERE c.visibility = 'Default' AND ref_count > 0 AND child_nodes LIKE '%%~${e.identifier}~%%'`,r=(yield this.dbService.execute(t).toPromise()).map(e=>Ce.a.mapContentDBEntryToContent(e).contentData);if(r.length)for(const t of r){const r=n.collections.find(e=>e.identifier===t.identifier);r?r.childNodes.indexOf(e.identifier)>=0||r.childNodes.push(e.identifier):n.collections.push(Object.assign(Object.assign({},t),{childNodes:[e.identifier]}))}}return e}))}}var vn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Cn{constructor(e,t,n,r){this.defaultDelegate=e,this.authService=t,this.frameworkService=n,this.systemSettingsService=r,this.ssoSectionIdMap=new Map}handle(e){return Object(y.defer)(()=>vn(this,void 0,void 0,(function*(){if(!!!(yield this.authService.getSession().toPromise()))return e;const t=yield this.frameworkService.getDefaultChannelId().toPromise(),n=this.frameworkService.activeChannelId;if(!(n===t)){let t;try{const e=yield this.systemSettingsService.getSystemSettings({id:Cn.SSO_COURSE_SECTION_ID}).toPromise();t=e&&e.value}catch(e){console.error(e)}t&&(e.sections={[t]:{filters:{"batches.createdFor":[n]}}},this.ssoSectionIdMap.set(e.name+"-"+n,t))}return e}))).pipe(Object(W.mergeMap)(e=>this.defaultDelegate.handle(e)),Object(W.map)(t=>{const n=this.ssoSectionIdMap.get(e.name+"-"+this.frameworkService.activeChannelId);return n&&(t.ssoSectionId=n),t}))}}Cn.SSO_COURSE_SECTION_ID="ssoCourseSection";class gn{constructor(e,t,n,r,i,o,s,a,c,u){this.apiService=e,this.pageApiServiceConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.frameworkService=o,this.authService=s,this.systemSettingsService=a,this.dbService=c,this.profileService=u,this.defaultRequestDelegate=new Sn(e,t,i,n,r,s,u,a),this.dialcodeRequestDelegate=new On(this.defaultRequestDelegate,c),this.courseRequestDelegate=new Cn(this.defaultRequestDelegate,s,o,a)}handle(e){switch(e.from=e.from||tn.CachedItemRequestSourceFrom.CACHE,e.name){case pn.PageName.COURSE:return this.courseRequestDelegate.handle(e);case pn.PageName.DIAL_CODE:return this.dialcodeRequestDelegate.handle(e);default:return this.defaultRequestDelegate.handle(e)}}}var An=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Tn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Nn=function(e,t){return function(n,r){t(n,r,e)}};let yn=class{constructor(e,t,n,r,i,o,s,a,c,u){this.apiService=e,this.sdkConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.frameworkService=o,this.authService=s,this.systemSettingsService=a,this.dbService=c,this.profileService=u,this.pageAssembleServiceConfig=this.sdkConfig.pageServiceConfig}setPageAssembleChannel(e){this.sharedPreferences.putString(X.l.KEY_ORGANISATION_ID,e.channelId).toPromise()}getPageAssemble(e){return new gn(this.apiService,this.pageAssembleServiceConfig,this.cachedItemStore,this.keyValueStore,this.sharedPreferences,this.frameworkService,this.authService,this.systemSettingsService,this.dbService,this.profileService).handle(e)}};yn=An([Object(T.injectable)(),Nn(0,Object(T.inject)(N.b.API_SERVICE)),Nn(1,Object(T.inject)(N.b.SDK_CONFIG)),Nn(2,Object(T.inject)(N.b.CACHED_ITEM_STORE)),Nn(3,Object(T.inject)(N.b.KEY_VALUE_STORE)),Nn(4,Object(T.inject)(N.b.SHARED_PREFERENCES)),Nn(5,Object(T.inject)(N.b.FRAMEWORK_SERVICE)),Nn(6,Object(T.inject)(N.b.AUTH_SERVICE)),Nn(7,Object(T.inject)(N.b.SYSTEM_SETTINGS_SERVICE)),Nn(8,Object(T.inject)(N.b.DB_SERVICE)),Nn(9,Object(T.inject)(N.b.PROFILE_SERVICE)),Tn("design:paramtypes",[Object,Object,Object,Object,Object,Object,Object,Object,s.DbService,Object])],yn);var mn=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let In=class{constructor(){this.listeners=new Map}getString(e){return Object(y.defer)(()=>Object(y.of)(localStorage.getItem(e)).pipe(Object(W.map)(e=>e||void 0)))}putString(e,t){return Object(y.defer)(()=>Object(y.of)(localStorage.setItem(e,t)).pipe(Object(W.mapTo)(void 0)))}putBoolean(e,t){return Object(y.defer)(()=>Object(y.of)(localStorage.setItem(e,t+"")).pipe(Object(W.mapTo)(!0)))}getBoolean(e){return Object(y.defer)(()=>Object(y.of)("true"===localStorage.getItem(e)))}addListener(e,t){const n=this.listeners.get(e)||[];n.push(t),this.listeners.set(e,n)}removeListener(e,t){const n=this.listeners.get(e)||[];this.listeners.set(e,n.filter(e=>e!==t))}};In=mn([Object(T.injectable)()],In);var Mn,Dn=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Rn=Mn=class{constructor(){this.listeners=new Map,this.sharedPreferences=plugins.SharedPreferences.getInstance(Mn.sharedPreferncesName)}getString(e){const t=localStorage.getItem(e);return t?(localStorage.removeItem(e),this.putString(e,t).pipe(Object(W.mapTo)(t))):new y.Observable(t=>{this.sharedPreferences.getString(e,"",e=>{t.next(e),t.complete()},e=>{t.error(e)})})}putString(e,t){return new y.Observable(n=>{this.sharedPreferences.putString(e,t,()=>{(this.listeners.get(e)||[]).forEach(e=>e(t)),n.next(void 0),n.complete()},e=>{n.error(e)})})}putBoolean(e,t){return new y.Observable(n=>{this.sharedPreferences.putBoolean(e,t,()=>{(this.listeners.get(e)||[]).forEach(e=>e(t)),n.next(!0),n.complete()},e=>{n.error(e)})})}getBoolean(e){const t=localStorage.getItem(e);return t?(localStorage.removeItem(e),this.putBoolean(e,"true"===t).pipe(Object(W.mapTo)("true"===t))):new y.Observable(t=>{this.sharedPreferences.getBoolean(e,!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}addListener(e,t){const n=this.listeners.get(e)||[];n.push(t),this.listeners.set(e,n)}removeListener(e,t){const n=this.listeners.get(e)||[];this.listeners.set(e,n.filter(e=>e!==t))}};var Pn;Rn.sharedPreferncesName="org.ekstep.genieservices.preference_file",Rn=Mn=Dn([Object(T.injectable)()],Rn),function(e){e[e.PERSISTENT=1]="PERSISTENT",e[e.TEMPORARY=0]="TEMPORARY"}(Pn||(Pn={}));var Ln=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let wn=class{constructor(){this.initialized=!1}init(){file.requestFileSystem(Pn.PERSISTENT,0,e=>{this.initialized=!0,this.fileSystem=e},()=>{})}readAsText(e,t){return this.readFile(e,t,"Text")}readAsBinaryString(e,t){return this.readFile(e,t,"BinaryString")}readFileFromAssets(e){return new Promise((t,n)=>{try{sbutility.readFromAssets(e,e=>{t(e)},e=>{n(e)})}catch(e){n(e)}})}writeFile(e,t,n,r={}){const i={create:!r.append,exclusive:!r.replace};return this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,i)).then(e=>this.writeFileEntry(e,n,r))}createFile(e,t,n){const r={create:!0};return n||(r.exclusive=!0),this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,r))}getFile(e,t,n){return new Promise((r,i)=>{try{e.getFile(t,n,e=>{r(e)},e=>{i(e)})}catch(e){i(e)}})}removeFile(e){const t=Pe.getParentDir(e),n=Pe.getFileName(e).replace("/","");return this.resolveDirectoryUrl(t).then(e=>this.getFile(e,n,{create:!1})).then(e=>this.remove(e))}createDir(e,t){const n={create:!0};t||(n.exclusive=!0);const r=Pe.getParentDir(e),i=Pe.getFileName(e).replace("/","");return this.exists(e).then(()=>this.resolveDirectoryUrl(e)).catch(()=>this.resolveDirectoryUrl(r).then(e=>this.getDirectory(e,i,n)))}listDir(e){return this.resolveDirectoryUrl(Pe.getDirecory(e)).then(t=>this.getDirectory(t,Pe.getFileName(e),{create:!1,exclusive:!1})).then(e=>{const t=e.createReader();return this.readEntries(t)})}removeDir(e,t){return this.resolveDirectoryUrl(e).then(e=>this.getDirectory(e,t,{create:!1})).then(e=>this.remove(e))}removeRecursively(e){e=e.endsWith("/")?e.substring(0,e.length-1):e;const t=Pe.getParentDir(e),n=Pe.getFileName(e).replace("/","");return this.resolveDirectoryUrl(t).then(e=>this.getDirectory(e,n,{create:!1})).then(e=>this.rimraf(e))}copyDir(e,t,n,r){return this.resolveDirectoryUrl(e).then(e=>this.getDirectory(e,t,{create:!1})).then(e=>this.resolveDirectoryUrl(n).then(t=>this.copy(e,t,r)))}copyFile(e,t,n,r){return r=r||t,this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,{create:!1})).then(e=>this.resolveDirectoryUrl(n).then(t=>this.copy(e,t,r)))}exists(e){return this.resolveLocalFilesystemUrl(e)}getTempLocation(e){return this.resolveDirectoryUrl(e).then(t=>this.resolveDirectoryUrl(e.concat("tmp"))).catch(()=>this.createDir(e.concat("tmp"),!1))}getFreeDiskSpace(){return new Promise((e,t)=>{let n=e;cordova.exec(n,t,"File","getFreeDiskSpace",[])})}resolveLocalFilesystemUrl(e){return e.includes("file://")||(e="file://"+e),console.log(e),new Promise((t,n)=>{try{resolveLocalFileSystemURL(e,e=>{t(e)},e=>{n(e)})}catch(e){n(e)}})}getMetaData(e){if("string"==typeof e)return this.resolveLocalFilesystemUrl(e).then(e=>this.getMetaData(e));const t=e;return new Promise(e=>{t.getMetadata(t=>{e(t)},()=>e(""))})}getExternalApplicationStorageDirectory(){return file.externalApplicationStorageDirectory}getDirectorySize(e){return this.resolveDirectoryUrl(e).then(e=>this.size(e)).catch(()=>0)}size(e){return e.isFile?new Promise((t,n)=>{e.getMetadata(e=>t(e.size),e=>n(e))}):e.isDirectory?new Promise((t,n)=>{e.createReader().readEntries(e=>{Promise.all(e.map(e=>this.size(e))).then(e=>{const n=e.reduce((e,t)=>e+t,0);t(n)}).catch(e=>n(e))},e=>n(e))}):Promise.resolve(0)}readEntries(e){return new Promise((t,n)=>{e.readEntries(e=>{t(e)},e=>{n(e)})})}readFile(e,t,n){return this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,{create:!1})).then(e=>{const t=new FileReader;return new Promise((r,i)=>{t.onloadend=()=>{void 0!==t.result||null!==t.result?r(t.result):void 0!==t.error||null!==t.error?i(t.error):i({code:null,message:"READER_ONLOADEND_ERR"})},e.file(e=>{t["readAs"+n].call(t,e)},e=>{i(e)})})}).catch(e=>{throw e})}resolveDirectoryUrl(e){return this.resolveLocalFilesystemUrl(e).then(e=>e.isDirectory?e:Promise.reject("input is not a directory"))}remove(e){return new Promise((t,n)=>{e.remove(()=>{t({success:!0,fileRemoved:e})},e=>{n(e)})})}copy(e,t,n){return new Promise((r,i)=>{e.copyTo(t,n,e=>{r(e)},e=>{i(e)})})}getDirectory(e,t,n){return new Promise((r,i)=>{try{e.getDirectory(t,n,e=>{r(e)},e=>{i(e)})}catch(e){i(e)}})}rimraf(e){return new Promise((t,n)=>{e.removeRecursively(()=>{t({success:!0,fileRemoved:e})},e=>{n(e)})})}createWriter(e){return new Promise((t,n)=>{e.createWriter(e=>{t(e)},e=>{n(e)})})}writeFileEntry(e,t,n){return this.createWriter(e).then(e=>(n.append&&e.seek(e.length),n.truncate&&e.truncate(n.truncate),this.write(e,t))).then(()=>e)}write(e,t){return new Promise((n,r)=>{e.onwriteend=t=>{e.error?r(e.error):n(t)},e.write(t)})}};wn=Ln([Object(T.injectable)()],wn);var Un=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class jn extends s.Migration{constructor(){super(2,17)}apply(e){return Un(this,void 0,void 0,(function*(){this.queries().forEach(t=>Un(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[c.f.getAlterEntryForProfileSyllabus()]}}var Fn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class xn extends s.Migration{constructor(){super(3,18)}apply(e){return Fn(this,void 0,void 0,(function*(){this.queries().forEach(t=>Fn(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()}))),yield e.read({table:c.f.TABLE_NAME,columns:[]}).pipe(Object(W.map)(t=>{t.forEach(t=>Fn(this,void 0,void 0,(function*(){t[c.f.COLUMN_NAME_UID]===t[c.f.COLUMN_NAME_HANDLE]?t[c.f.COLUMN_NAME_SOURCE]=te.ProfileSource.SERVER.valueOf():t[c.f.COLUMN_NAME_SOURCE]=te.ProfileSource.LOCAL.valueOf(),yield e.update({table:c.f.TABLE_NAME,modelJson:t}).toPromise()})))})).toPromise()}))}queries(){return[c.b.getCreateEntry(),c.a.getCreateEntry()]}updateProfileTable(){}}var kn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Bn extends s.Migration{constructor(){super(4,19)}apply(e){return kn(this,void 0,void 0,(function*(){yield e.read({table:c.d.TABLE_NAME,columns:[]}).pipe(Object(W.map)(t=>{t.forEach(t=>kn(this,void 0,void 0,(function*(){const n=Number(t[c.e.COLUMN_NAME_TOTAL_TS]);t[c.e.COLUMN_NAME_TOTAL_TS]=Math.round(n/1e3),yield e.update({table:c.e.TABLE_NAME,modelJson:t}).toPromise()})))})).toPromise()}))}queries(){return[]}}var Vn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Yn extends s.Migration{constructor(){super(7,22)}apply(e){return Vn(this,void 0,void 0,(function*(){this.queries().forEach(t=>Vn(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[h.getCreateEntry()]}}var Gn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Hn extends s.Migration{constructor(){super(18,31)}apply(e){return Gn(this,void 0,void 0,(function*(){this.queries().forEach(t=>Gn(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()}))),this.updateProfileDB(e)}))}queries(){return[c.f.getAlterEntryForProfileCategories()]}updateProfileDB(e){return Gn(this,void 0,void 0,(function*(){try{(yield e.read({table:c.f.TABLE_NAME}).toPromise()).forEach(t=>Gn(this,void 0,void 0,(function*(){const n=this.getUpdateQueries(t),r={};r[c.f.COLUMN_NAME_CATEGORIES]=JSON.stringify(n),yield e.update({table:c.f.TABLE_NAME,selection:c.f.COLUMN_NAME_UID+" = ?",selectionArgs:[t.uid],modelJson:r}).toPromise()})))}catch(e){console.log("error",e)}}))}getUpdateQueries(e){const t={};return t.fwCategory1=e.board,t.fwCategory2=e.medium,t.fwCategory3=e.grade,t.fwCategory4=e.subject,t}}var qn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class $n extends s.Migration{constructor(){super(5,20)}apply(e){return qn(this,void 0,void 0,(function*(){this.queries().forEach(t=>qn(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[f.d.getCreateEntry()]}}var Kn=n(86),zn=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Wn=class{unzip(e,t,n,r){JJzip.unzip(e,t,()=>{n&&n()},e=>{r&&r(e)})}zip(e,t,n,r,i,o){JJzip.zip(e,t,n,r,()=>{i&&i()},e=>{o&&o(e)})}};Wn=zn([Object(T.injectable)()],Wn);var Xn=n(20),Jn=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Qn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Zn=class{constructor(){this.deviceId=Ut(window.device.uuid).toString()}getDeviceID(){return this.deviceId}getDeviceSpec(){return this.deviceSpec?Object(y.of)(this.deviceSpec):new y.Observable(e=>{sbutility.getDeviceSpec(t=>{this.deviceSpec=t,e.next(t),e.complete()})})}getAvailableInternalMemorySize(){return new y.Observable(e=>{sbutility.getAvailableInternalMemorySize(t=>{e.next(t),e.complete()},t=>{e.error(t)})})}getStorageVolumes(){return y.Observable.create(e=>{sbutility.getStorageVolumes(t=>{e.next(t.map(e=>e.isRemovable?{storageDestination:Xn.StorageDestination.EXTERNAL_STORAGE,info:Object.assign({},e)}:{storageDestination:Xn.StorageDestination.INTERNAL_STORAGE,info:Object.assign({},e)})),e.complete()},t=>{e.error(t)})})}isKeyboardShown(){let e,t,n,r;return new y.Observable(i=>{e=()=>i.next(!0),t=()=>i.next(!0),n=()=>i.next(!1),r=()=>i.next(!1),window.addEventListener("native.keyboardshow",e),window.addEventListener("keyboardWillShow",t),window.addEventListener("native.keyboardhide",n),window.addEventListener("keyboardWillHide",n)}).pipe(Object(W.distinctUntilChanged)(),Object(W.tap)(()=>{console.log("Subscribed isKeyboardShown event")}),Object(W.finalize)(()=>{console.log("Unsubscribed isKeyboardShown event"),window.removeEventListener("native.keyboardshow",e),window.removeEventListener("keyboardWillShow",t),window.removeEventListener("native.keyboardhide",n),window.removeEventListener("keyboardWillHide",n)}))}};Zn=Jn([Object(T.injectable)(),Qn("design:paramtypes",[])],Zn);var er=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},tr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},nr=function(e,t){return function(n,r){t(n,r,e)}};let rr=class{constructor(e,t,n){this.dbService=e,this.profileService=t,this.telemetryService=n}getFeedback(e){const t=`SELECT * FROM ${f.c.TABLE_NAME} ${ge.a.getUidnIdentifierFiler(e.uid,e.contentId)}`;return this.dbService.execute(t).pipe(Object(W.map)(e=>e.map(e=>class{static mapFeedbackDBEntrytoResponseFeedback(e){return{contentId:e[f.c.COLUMN_NAME_CONTENT_ID],rating:Number(e[f.c.COLUMN_NAME_RATING]),comments:e[f.c.COLUMN_NAME_COMMENTS],createdAt:Number(e[f.c.COLUMN_NAME_CREATED_AT]),stageId:"",contentVersion:""}}}.mapFeedbackDBEntrytoResponseFeedback(e))))}sendFeedback(e){return this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(t=>{const n={table:f.c.TABLE_NAME,selection:(new A).where("? = ? AND ? = ?").args([f.c.COLUMN_NAME_CONTENT_ID,e.contentId,f.c.COLUMN_NAME_UID,t.uid]).end().build(),limit:"1"},r={uid:t.uid,identifier:e.contentId,rating:e.rating,comments:e.comments,createdAt:Date.now()};return this.telemetryService.feedback({env:"sdk",rating:e.rating,comments:e.comments,objId:e.contentId,objType:P.ShareItemType.CONTENT.valueOf(),objVer:e.contentVersion}).pipe(Object(W.mergeMap)(()=>this.dbService.read(n).pipe(Object(W.mergeMap)(n=>n&&n.length?this.dbService.update({table:f.c.TABLE_NAME,selection:`${f.c.COLUMN_NAME_UID}= ? AND ${f.c.COLUMN_NAME_CONTENT_ID}= ?`,selectionArgs:[t.uid,e.contentId],modelJson:r}).pipe(Object(W.map)(e=>e>0)):this.dbService.insert({table:f.c.TABLE_NAME,modelJson:r}).pipe(Object(W.map)(e=>e>0))))))}))}};rr=er([Object(T.injectable)(),nr(0,Object(T.inject)(N.b.DB_SERVICE)),nr(1,Object(T.inject)(N.b.PROFILE_SERVICE)),nr(2,Object(T.inject)(N.b.TELEMETRY_SERVICE)),tr("design:paramtypes",[s.DbService,Object,Object])],rr);var ir=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},or=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},sr=function(e,t){return function(n,r){t(n,r,e)}},ar=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let cr=class{constructor(e){this.sdkConfig=e,this.eventsBus=new y.Subject,this.eventDelegates=[],this.eventsBusConfig=this.sdkConfig.eventsBusConfig}onInit(){return this.eventsBus.pipe(Object(W.tap)(e=>{this.eventsBusConfig.debugMode&&console.log("SDK Telemetry Events",e)}),Object(W.tap)(e=>ar(this,void 0,void 0,(function*(){const t=this.eventDelegates.filter(t=>t.namespace===e.namespace).map(t=>t.observer.onEvent(e.event).pipe(Object(W.take)(1),Object(W.catchError)(e=>(console.error("Error: ",e,"EventObserver: ",t),Object(y.of)(void 0)))));try{yield Object(y.zip)(...t).toPromise()}catch(e){console.error("EVENT_BUS_DELEGATE_ERROR",e)}}))),Object(W.mapTo)(void 0))}events(e){return this.eventsBus.asObservable().pipe(Object(W.filter)(t=>!e||t.namespace===e),Object(W.map)(e=>e.event))}emit({namespace:e,event:t}){this.eventsBus.next({namespace:e,event:t})}registerObserver({namespace:e,observer:t}){this.eventDelegates.push({namespace:e,observer:t})}};cr=ir([Object(T.injectable)(),sr(0,Object(T.inject)(N.b.SDK_CONFIG)),or("design:paramtypes",[Object])],cr);var ur,dr=n(23),lr=n(40),fr=n(303),hr=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Er=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},pr=function(e,t){return function(n,r){t(n,r,e)}},_r=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let Sr=ur=class{constructor(e,t){this.eventsBusService=e,this.sharedPreferences=t,this.currentDownloadRequest$=new y.BehaviorSubject(void 0),this.completedDownloadRequestsCache=new yt.a(e=>e.identifier),window.downloadManager=fr,this.sharedPreferencesSetCollection=new mt(this.sharedPreferences,ur.KEY_TO_DOWNLOAD_LIST,e=>e.identifier)}static generateDownloadStartTelemetry(e){return _r(this,void 0,void 0,(function*(){return J.a.log.interact({type:P.InteractType.OTHER,subType:P.InteractSubType.CONTENT_DOWNLOAD_INITIATE,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?ge.a.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(W.mapTo)(void 0)).toPromise()}))}static generateDownloadCompleteTelemetry(e){return _r(this,void 0,void 0,(function*(){return J.a.log.interact({type:P.InteractType.OTHER,subType:P.InteractSubType.CONTENT_DOWNLOAD_SUCCESS,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?ge.a.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(W.mapTo)(void 0)).toPromise()}))}static generateDownloadCancelTelemetry(e){return _r(this,void 0,void 0,(function*(){return J.a.log.interact({type:P.InteractType.OTHER,subType:P.InteractSubType.CONTENT_DOWNLOAD_CANCEL,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?ge.a.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(W.mapTo)(void 0)).toPromise()}))}onInit(){return this.switchToNextDownloadRequest().pipe(Object(W.mergeMap)(()=>this.listenForDownloadProgressChanges()))}download(e){return this.currentDownloadRequest$.pipe(Object(W.take)(1),Object(W.mergeMap)(t=>t?this.addToDownloadList(e):(console.log("SDK download downloadRequests -",e),this.addToDownloadList(e).pipe(Object(W.tap)(()=>this.switchToNextDownloadRequest().toPromise())))))}cancel(e,t=!0){return this.currentDownloadRequest$.pipe(Object(W.take)(1),Object(W.mergeMap)(n=>n&&n.identifier===e.identifier?new y.Observable(e=>{downloadManager.remove([n.downloadId],(t,n)=>{t&&e.error(t),e.next(!!n),e.complete()})}).pipe(Object(W.mergeMap)(()=>this.removeFromDownloadList(e,t)),Object(W.tap)(()=>this.switchToNextDownloadRequest().toPromise())):this.removeFromDownloadList(e,t)))}cancelAll(){return this.currentDownloadRequest$.pipe(Object(W.take)(1),Object(W.mergeMap)(e=>e?new y.Observable(t=>{downloadManager.remove([e.downloadId],(e,n)=>{e&&t.error(e),t.next(!!n),t.complete()})}).pipe(Object(W.mergeMap)(()=>this.removeAllFromDownloadList()),Object(W.mergeMap)(()=>this.switchToNextDownloadRequest())):this.removeAllFromDownloadList()))}registerOnDownloadCompleteDelegate(e){this.downloadCompleteDelegate=e}getActiveDownloadRequests(){return this.sharedPreferencesSetCollection.asListChanges().pipe(Object(W.map)(e=>e.sort((e,t)=>{const n=e.withPriority||0;return(t.withPriority||0)-n})))}switchToNextDownloadRequest(){return this.sharedPreferencesSetCollection.asSet().pipe(Object(W.mergeMap)(e=>{if(!e.size())return Object(y.of)(void 0).pipe(Object(W.tap)(()=>this.currentDownloadRequest$.next(void 0)));const t=e.toArray().sort((e,t)=>{const n=e.withPriority||0;return(t.withPriority||0)-n}).shift();return new y.Observable(e=>{downloadManager.enqueue({uri:t.downloadUrl,title:t.filename,description:"",mimeType:t.mimeType,visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalFilesDir:{dirType:ur.DOWNLOAD_DIR_NAME,subPath:t.filename},headers:[]},(t,n)=>{if(t)return e.error(t);e.next(n)})}).pipe(Object(W.tap)(e=>{let n="ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalDataDirectory;t.downloadedFilePath=n+ur.DOWNLOAD_DIR_NAME+"/"+t.filename,t.downloadId=e,this.currentDownloadRequest$.next(t)}),Object(W.tap)(()=>_r(this,void 0,void 0,(function*(){return yield ur.generateDownloadStartTelemetry(t)}))),Object(W.mapTo)(void 0),Object(W.catchError)(()=>this.cancel({identifier:t.identifier})))}))}addToDownloadList(e){return console.log("addToDownloadList rq -",e),this.sharedPreferencesSetCollection.addAll(e).pipe(Object(W.mapTo)(void 0))}removeFromDownloadList(e,t){return this.sharedPreferencesSetCollection.asList().pipe(Object(W.mergeMap)(n=>{const r=n.find(t=>t.identifier===e.identifier);return r?this.sharedPreferencesSetCollection.remove(r).pipe(Object(W.mapTo)(void 0),Object(W.tap)(()=>_r(this,void 0,void 0,(function*(){return t&&(yield ur.generateDownloadCancelTelemetry(r))})))):Object(y.of)(void 0)}))}removeAllFromDownloadList(){return this.sharedPreferencesSetCollection.asList().pipe(Object(W.take)(1),Object(W.mergeMap)(e=>this.sharedPreferencesSetCollection.clear().pipe(Object(W.mergeMap)(()=>Object(y.from)(e).pipe(Object(W.tap)(e=>_r(this,void 0,void 0,(function*(){return yield ur.generateDownloadCancelTelemetry(e)}))),Object(W.concatMapTo)(Object(y.of)(void 0)))))))}handleDownloadCompletion(e){return this.currentDownloadRequest$.pipe(Object(W.take)(1),Object(W.mergeMap)(t=>e.payload.status===lr.DownloadStatus.STATUS_SUCCESSFUL?(this.completedDownloadRequestsCache.add(t),Object(y.iif)(()=>!!this.downloadCompleteDelegate,Object(y.defer)(()=>_r(this,void 0,void 0,(function*(){ur.generateDownloadCompleteTelemetry(t),this.downloadCompleteDelegate.onDownloadCompletion(t).toPromise()}))),Object(y.defer)(()=>Object(y.of)(void 0))).pipe(Object(W.mapTo)(void 0))):Object(y.of)(void 0)))}emitProgressInEventBus(e){return Object(y.defer)(()=>Object(y.of)(this.eventsBusService.emit({namespace:k.EventNamespace.DOWNLOADS,event:e})).pipe(Object(W.mapTo)(void 0)))}getDownloadProgress(e){return new y.Observable(t=>{downloadManager.query({ids:[e.downloadId]},(n,r)=>{if(n)return t.next({type:lr.DownloadEventType.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:-1,bytesDownloaded:0,totalSizeInBytes:0,status:lr.DownloadStatus.STATUS_FAILED}}),t.complete(),void this.cancel({identifier:e.identifier}).toPromise();const i=r[0];t.next({type:lr.DownloadEventType.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:Math.round(i.totalSizeBytes>=0?i.bytesDownloadedSoFar/i.totalSizeBytes*100:-1),bytesDownloaded:i.bytesDownloadedSoFar,totalSizeInBytes:i.totalSizeBytes,status:i.status}}),t.complete()})})}listenForDownloadProgressChanges(){return this.currentDownloadRequest$.pipe(Object(W.switchMap)(e=>e?(this.eventsBusService.emit({namespace:k.EventNamespace.DOWNLOADS,event:{type:lr.DownloadEventType.START,payload:void 0}}),Object(y.interval)(1e3).pipe(Object(W.mergeMap)(()=>this.getDownloadProgress(e)),Object(W.distinctUntilChanged)((e,t)=>JSON.stringify(e)===JSON.stringify(t)),Object(W.mergeMap)(e=>Object(y.zip)(this.handleDownloadCompletion(e),this.emitProgressInEventBus(e)).pipe(Object(W.mapTo)(e))),Object(W.tap)(e=>{e.payload.status!==lr.DownloadStatus.STATUS_FAILED&&e.payload.status!==lr.DownloadStatus.STATUS_SUCCESSFUL||this.eventsBusService.emit({namespace:k.EventNamespace.DOWNLOADS,event:{type:lr.DownloadEventType.END,payload:void 0}})}),Object(W.mapTo)(void 0))):Object(y.of)(void 0)))}trackDownloads(e){return e.groupBy.fieldPath&&e.groupBy.value?this.getActiveDownloadRequests().pipe(Object(W.map)(t=>{const n=t=>e.groupBy.value===e.groupBy.fieldPath.split(".").reduce((e,t)=>{if(e&&e[t])return e[t]},t);return{completed:this.completedDownloadRequestsCache.size()?this.completedDownloadRequestsCache.toArray().filter(n):[],queued:t.length?t.filter(n):[]}})):y.EMPTY}onContentDelete(e){this.completedDownloadRequestsCache.remove({identifier:e})}};Sr.KEY_TO_DOWNLOAD_LIST=X.h.KEY_TO_DOWNLOAD_LIST,Sr.DOWNLOAD_DIR_NAME="Download",Sr=ur=hr([Object(T.injectable)(),pr(0,Object(T.inject)(N.b.EVENTS_BUS_SERVICE)),pr(1,Object(T.inject)(N.b.SHARED_PREFERENCES)),Er("design:paramtypes",[Object,Object])],Sr);var br=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Or=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},vr=function(e,t){return function(n,r){t(n,r,e)}},Cr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let gr=class{constructor(e,t){this.sdkConfig=e,this.sharedPreferences=t,"cordova"!==e.platform&&(this.versionName="sunbird-debug"),window.Capacitor.Plugins.App.getInfo().then(e=>{this.appName=e.name})}getVersionName(){return this.versionName}getAppName(){return this.appName}init(){return Cr(this,void 0,void 0,(function*(){if(yield this.setFirstAccessTimestamp(),"cordova"!==this.sdkConfig.platform)return;this.sdkConfig.appConfig.buildConfigPackage&&this.sdkConfig.appConfig.buildConfigPackage;this.versionName="6.0-local",he.CsModule.instance.isInitialised&&he.CsModule.instance.updateConfig(Object.assign(Object.assign({},he.CsModule.instance.config),{core:Object.assign(Object.assign({},he.CsModule.instance.config.core),{global:Object.assign(Object.assign({},he.CsModule.instance.config.core.global),{appVersion:"6.0-local"})})})),console.log("version name",this.versionName)}))}getBuildConfigValue(e,t){return new Promise((n,r)=>{try{window.sbutility.getBuildConfigValue(e,t,e=>{n(e)},e=>{console.error(e),r(e)})}catch(e){console.error(e),r(e)}})}getFirstAccessTimestamp(){return this.sharedPreferences.getString(X.b.KEY_FIRST_ACCESS_TIMESTAMP).pipe(Object(W.map)(e=>e))}setFirstAccessTimestamp(){return Cr(this,void 0,void 0,(function*(){return!(yield this.sharedPreferences.getString(X.b.KEY_FIRST_ACCESS_TIMESTAMP).toPromise())&&(yield this.sharedPreferences.putString(X.b.KEY_FIRST_ACCESS_TIMESTAMP,Date.now()+"").toPromise(),!0)}))}};gr=br([Object(T.injectable)(),vr(0,Object(T.inject)(N.b.SDK_CONFIG)),vr(1,Object(T.inject)(N.b.SHARED_PREFERENCES)),Or("design:paramtypes",[Object,Object])],gr);var Ar=n(87),Tr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Nr extends s.Migration{constructor(){super(6,21)}apply(e){return Tr(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_CONTENT_TYPE+" = ?",selectionArgs:["textbook"]}).pipe(Object(W.map)(t=>{t.forEach(t=>Tr(this,void 0,void 0,(function*(){const n=t[f.b.COLUMN_NAME_LOCAL_DATA];if(n){const r=JSON.parse(n);t[f.b.COLUMN_NAME_BOARD]=ge.a.getContentAttribute(r.board),t[f.b.COLUMN_NAME_MEDIUM]=ge.a.getContentAttribute(r.medium),t[f.b.COLUMN_NAME_GRADE]=ge.a.getContentAttribute(r.gradeLevel),yield e.update({table:f.b.TABLE_NAME,modelJson:t,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]]}).toPromise()}})))})).toPromise()}))}queries(){return[f.b.getAlterEntryForBoard(),f.b.getAlterEntryForMedium(),f.b.getAlterEntryForGrade()]}}class yr extends ne.a{constructor(e){super(e,"LOW_MEMORY"),Object.setPrototypeOf(this,yr.prototype)}}var mr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Ir{constructor(e){this.dbService=e}execute(e){return Object(y.defer)(()=>mr(this,void 0,void 0,(function*(){const t=yield this.getFreeUsableSpace(e.destinationFolder),n=new Tt(this.dbService),r=yield n.getContentUsageSummary([e.sourceFolder]);let i=0;if(r&&r.length&&(i=r[0].sizeOnDevice),ge.a.isFreeSpaceAvailable(t,i,0))return e;throw new yr("Available memory not sufficient for transfer operation")})))}getFreeUsableSpace(e){return mr(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getFreeUsableSpace(e,e=>{t(Number(e))},e=>{n(e)})})}))}}var Mr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Dr{constructor(e,t){this.fileService=e,this.appConfig=t}execute(e){return Object(y.defer)(()=>Mr(this,void 0,void 0,(function*(){return e.validContentIdsInDestination=yield this.getSubdirectoriesEntries(e.destinationFolder).then(e=>this.extractValidContentIdsInDestination(e)),e})))}getSubdirectoriesEntries(e){return Mr(this,void 0,void 0,(function*(){return this.fileService.listDir(e.replace(/\/$/,"")).then(e=>e.filter(e=>e.isDirectory))}))}extractValidContentIdsInDestination(e){return Mr(this,void 0,void 0,(function*(){const t=[];for(const n of e)if(n.isDirectory){let e;try{e=yield this.extractManifest(n)}catch(e){}if(!e)continue;const r=e.archive.items;for(const e of r)ge.a.readVisibility(e)!==B.Visibility.PARENT&&(ge.a.isDraftContent(e.status)&&ge.a.isExpired(e.expires)||t.push(n.name))}return t}))}extractManifest(e){return Mr(this,void 0,void 0,(function*(){const t=yield this.fileService.readAsText(e.nativeURL,B.FileName.MANIFEST.valueOf());return JSON.parse(t)}))}}class Rr{constructor(){}execute(e){return Object(y.of)(e)}}class Pr extends ne.a{constructor(e){super(e,"DUPLICATE_CONTENT"),Object.setPrototypeOf(this,Pr.prototype)}}var Lr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},wr=f.b.COLUMN_NAME_IDENTIFIER,Ur=f.b.COLUMN_NAME_LOCAL_DATA;class jr{constructor(e,t){this.dbService=e,this.fileService=t}execute(e){return Object(y.defer)(()=>Lr(this,void 0,void 0,(function*(){const t=yield this.getContentsInDb(e.contentIds);let n=[];e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&(n=yield this.getContentsInDb(e.validContentIdsInDestination));const r=(yield this.generateMoveContentResponses(e,n)).moveContentDupContentList;if(e.contentsInSource=t,e.duplicateContents=r,e.duplicateContents.length&&!e.shouldMergeInDestination)throw new Pr("context.shouldMergeInDestination is false")}))).pipe(Object(W.mapTo)(e))}getContentsInDb(e){return Lr(this,void 0,void 0,(function*(){return e.length?this.dbService.execute(ge.a.getFindAllContentsWithIdentifierQuery(e)).toPromise():this.dbService.execute(ge.a.getFindAllContentsQuery()).toPromise()}))}getPkgVersionFromFile(e,t){return this.fileService.readAsText(e.concat(t),B.FileName.MANIFEST.valueOf()).then(e=>{const n=JSON.parse(e).archive.items;if(n){return n.find(e=>e.identifier===t).pkgVersion}return 0}).catch(()=>-1)}generateMoveContentResponses(e,t){return Lr(this,void 0,void 0,(function*(){const n=[],r=[];for(const i of t){const t=yield this.getPkgVersionFromFile(e.destinationFolder,i[wr]),o=ge.a.readPkgVersion(JSON.parse(i[Ur]));if(-1!==t)if(t>o){const e={identifier:i[wr],status:ei.HIGHER_VERSION_IN_DESTINATION};n.push(e),r.push(e)}else if(t<o){const e={identifier:i[wr],status:ei.LOWER_VERSION_IN_DESTINATION};n.push(e),r.push(e)}else{const e={identifier:i[wr],status:ei.SAME_VERSION_IN_BOTH};r.push(e)}}return{moveContentDiffPkgList:n,moveContentDupContentList:r}}))}}class Fr extends ne.a{constructor(e){super(e,"CANCELLED"),Object.setPrototypeOf(this,Fr.prototype)}}var xr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},kr=f.b.COLUMN_NAME_IDENTIFIER,Br=f.b.COLUMN_NAME_PATH;class Vr{constructor(e){this.eventsBusService=e,this.contentsTransferred=0}execute(e){return Object(y.defer)(()=>xr(this,void 0,void 0,(function*(){for(const t of e.contentsInSource){if(e.hasTransferCancelled)throw yield this.deleteFolder(e.destinationFolder.concat("temp","/")),new Fr("CANCELLED");const n=e.duplicateContents.find(e=>e.identifier===t[kr]);if(n&&!V.a.isEmpty(e.duplicateContents))if(e.existingContentAction)if(n.status!==ei.SAME_VERSION_IN_BOTH){switch(e.existingContentAction){case Xn.ExistingContentAction.KEEP_HIGER_VERSION:if(n.status===ei.HIGHER_VERSION_IN_DESTINATION)break;yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Xn.ExistingContentAction.KEEP_LOWER_VERSION:if(n.status===ei.LOWER_VERSION_IN_DESTINATION)break;yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Xn.ExistingContentAction.KEEP_SOURCE:yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Xn.ExistingContentAction.IGNORE:case Xn.ExistingContentAction.KEEP_DESTINATION:}this.emitContentTransferProgress(e)}else this.emitContentTransferProgress(e);else this.emitContentTransferProgress(e);else{const n=e.destinationFolder.concat("temp","/");try{yield this.copyFolder(t[Br],n+t[kr])}catch(e){}this.emitContentTransferProgress(e)}}return e})))}emitContentTransferProgress(e){this.eventsBusService.emit({namespace:k.EventNamespace.STORAGE,event:{type:Xn.StorageEventType.TRANSFER_PROGRESS,payload:{progress:{transferredCount:++this.contentsTransferred,totalCount:e.contentsInSource.length}}}})}deleteFolder(e){return xr(this,void 0,void 0,(function*(){if(e)return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}copyFolder(e,t){return xr(this,void 0,void 0,(function*(){if(e&&t)return new Promise((n,r)=>{sbutility.copyDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}renameFolder(e,t){return xr(this,void 0,void 0,(function*(){if(e)return new Promise((n,r)=>{sbutility.renameDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}copyToTempDestination(e,t,n){return xr(this,void 0,void 0,(function*(){yield this.renameFolder(e.destinationFolder,n.identifier),yield this.copyFolder(t[Br],e.destinationFolder+t[kr])}))}removeSourceAndDestination(e,t,n){return xr(this,void 0,void 0,(function*(){yield this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp")),yield this.deleteFolder(t[Br])}))}}var Yr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},Gr=f.b.COLUMN_NAME_PATH,Hr=f.b.COLUMN_NAME_IDENTIFIER;class qr{constructor(e){this.dbService=e}execute(e){return Object(y.defer)(()=>Yr(this,void 0,void 0,(function*(){this.dbService.beginTransaction();try{for(const t of e.contentsInSource)t[Gr]=ge.a.getBasePath(e.destinationFolder.concat(t[Hr],"/")),yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise();this.dbService.endTransaction(!0)}catch(e){this.dbService.endTransaction(!1)}}))).pipe(Object(W.mapTo)(e))}}var $r=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Kr{constructor(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}execute(e){return Object(y.defer)(()=>$r(this,void 0,void 0,(function*(){let t;for(const t of e.duplicateContents)switch(e.existingContentAction||Xn.ExistingContentAction.IGNORE){case Xn.ExistingContentAction.KEEP_HIGER_VERSION:t.status===ei.HIGHER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(t.identifier,e.destinationFolder,!1);break;case Xn.ExistingContentAction.KEEP_LOWER_VERSION:t.status===ei.LOWER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(t.identifier,e.destinationFolder,!0);break;case Xn.ExistingContentAction.KEEP_DESTINATION:case Xn.ExistingContentAction.IGNORE:t.status===ei.LOWER_VERSION_IN_DESTINATION?this.addDestinationContentInDb(t.identifier,e.destinationFolder,!0):this.addDestinationContentInDb(t.identifier,e.destinationFolder,!1)}if(e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&e.duplicateContents&&e.duplicateContents.length?t=this.getNewlyAddedContents(e.validContentIdsInDestination,e.duplicateContents.map(e=>e.identifier)):e.validContentIdsInDestination&&e.duplicateContents.length||!e.validContentIdsInDestination||!e.validContentIdsInDestination.length||(t=e.validContentIdsInDestination),t)for(const n of t)yield this.addDestinationContentInDb(n,e.destinationFolder,!1)})))}getNewlyAddedContents(e,t){return e.filter(e=>t.find(t=>t!==e))}addDestinationContentInDb(e,t,n){const r=t.concat(e);return this.fileService.readAsText(t.concat(e),B.FileName.MANIFEST.valueOf()).then(e=>{const t=JSON.parse(e),i=t.archive.items;return this.extractContentFromItem(i,r.concat("/"),t.ver,n)}).catch(e=>{console.error(e)})}extractContentFromItem(e,t,n,r){return $r(this,void 0,void 0,(function*(){const i=[],o=[];for(const s of e){let e=s;const a=e.identifier,c=e.mimeType,u=ge.a.readContentType(e),d=ge.a.readPrimaryCategory(e);let l=ge.a.readVisibility(e);const h=ge.a.readAudience(e),E=ge.a.readPragma(e),p=e.pkgVersion;let _=B.State.ONLY_SPINE.valueOf();const S=e.board,b=e.medium,O=e.gradeLevel,v=(yield this.dbService.read({table:f.b.TABLE_NAME,columns:[],selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[a]}).toPromise())[0],C=v&&ge.a.getBasePath(v[f.b.COLUMN_NAME_PATH]);let g=ge.a.doesContentExist(v,a,p,r);g&&e.status!==B.ContentStatus.DRAFT.valueOf()?v[f.b.COLUMN_NAME_VISIBILITY]===B.Visibility.DEFAULT.valueOf()&&(e=JSON.parse(v[f.b.COLUMN_NAME_LOCAL_DATA])):(g=!1,_=(B.MimeType.COLLECTION.valueOf(),B.State.ARTIFACT_AVAILABLE.valueOf()));const A=ge.a.getReferenceCount(v,l);l=ge.a.getContentVisibility(v,e.objectType,l),_=ge.a.getContentState(v,_);const T=g?C:t,N=yield this.fileService.getDirectorySize(T);ge.a.addOrUpdateViralityMetadata(e,this.deviceInfo.getDeviceID().toString());const y=ge.a.constructContentDBModel(a,n,JSON.stringify(e),c,u,l,T,A,_,h,E,N,S,b,O,d);v?o.push(y):i.push(y)}if(i.length||o.length){this.dbService.beginTransaction();for(const e of i){const t=e;yield this.dbService.insert({table:f.b.TABLE_NAME,modelJson:t}).toPromise()}for(const e of o){const t=e;yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}}var zr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Wr{constructor(e){this.fileService=e}execute(e){return Object(y.defer)(()=>zr(this,void 0,void 0,(function*(){return e.destinationFolder=yield this.validate(e.destinationFolder).then(e=>this.createDirectory(e)),e})))}validate(e){return this.canWrite(e).then(()=>(e.endsWith("content/")||(e=e.concat("content")),e)).catch(()=>{throw Error("Destination is not writable")})}createDirectory(e){return this.fileService.exists(e).then(e=>e.nativeURL).catch(()=>this.fileService.createDir(e,!1).then(e=>e.nativeURL))}canWrite(e){return zr(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.canWrite(e,()=>{t(void 0)},e=>{n(e)})})}))}}var Xr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},Jr=f.b.COLUMN_NAME_IDENTIFIER,Qr=f.b.COLUMN_NAME_PATH;class Zr{constructor(e){this.eventsBusService=e}execute(e){return Object(y.defer)(()=>Xr(this,void 0,void 0,(function*(){for(let t=0;t<e.contentsInSource.length;t++){const n=e.contentsInSource[t],r=e.duplicateContents.find(e=>e.identifier===n[Jr]),i=e.destinationFolder.concat("temp","/");if(r&&!V.a.isEmpty(e.duplicateContents)){if(e.existingContentAction&&r.status!==ei.SAME_VERSION_IN_BOTH){switch(e.existingContentAction){case Xn.ExistingContentAction.KEEP_HIGER_VERSION:if(r.status===ei.HIGHER_VERSION_IN_DESTINATION)break;yield this.removeSourceAndDestination(e,n,r);break;case Xn.ExistingContentAction.KEEP_LOWER_VERSION:if(r.status===ei.LOWER_VERSION_IN_DESTINATION)break;yield this.removeSourceAndDestination(e,n,r);break;case Xn.ExistingContentAction.KEEP_SOURCE:yield this.removeSourceAndDestination(e,n,r);break;case Xn.ExistingContentAction.IGNORE:case Xn.ExistingContentAction.KEEP_DESTINATION:}t===e.contentsInSource.length-1&&(yield this.deleteFolder(i))}}else try{yield this.copyFolder(i.concat(n[Jr]),e.destinationFolder+n[Jr]),yield this.deleteFolder(i.concat(n[Jr])),yield this.deleteFolder(n[Qr]),t===e.contentsInSource.length-1&&(yield this.deleteFolder(i))}catch(e){}}return e})))}deleteFolder(e){return Xr(this,void 0,void 0,(function*(){if(e)return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}copyFolder(e,t){return Xr(this,void 0,void 0,(function*(){if(e&&t)return new Promise((n,r)=>{sbutility.copyDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}renameFolder(e,t){return Xr(this,void 0,void 0,(function*(){if(e)return new Promise((n,r)=>{sbutility.renameDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}removeSourceAndDestination(e,t,n){return Xr(this,void 0,void 0,(function*(){yield this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp")),yield this.deleteFolder(t[Qr])}))}}var ei,ti=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};!function(e){e.SAME_VERSION_IN_BOTH="SAME_VERSION_IN_BOTH",e.HIGHER_VERSION_IN_DESTINATION="HIGHER_VERSION_IN_DESTINATION",e.LOWER_VERSION_IN_DESTINATION="LOWER_VERSION_IN_DESTINATION"}(ei||(ei={}));class ni{constructor(e,t,n,r,i){this.sdkConfig=e,this.fileService=t,this.dbService=n,this.eventsBusService=r,this.deviceInfo=i,this.context={}}transfer({contentIds:e,existingContentAction:t,deleteDestination:n,destinationFolder:r,shouldMergeInDestination:i,sourceFolder:o}){return this.context.hasTransferCancelled=!1,this.context.shouldMergeInDestination=i,this.context.contentIds=e,this.context.existingContentAction=t,this.context.deleteDestination=n,this.context.destinationFolder=r,this.context.sourceFolder=o,new Wr(this.fileService).execute(this.context).pipe(Object(W.mergeMap)(e=>(new Rr).execute(e)),Object(W.mergeMap)(e=>new Ir(this.dbService).execute(e)),Object(W.mergeMap)(e=>new Dr(this.fileService,this.sdkConfig.appConfig).execute(e)),Object(W.mergeMap)(e=>new jr(this.dbService,this.fileService).execute(e)),Object(W.mergeMap)(e=>new Vr(this.eventsBusService).execute(e)),Object(W.mergeMap)(e=>new Zr(this.eventsBusService).execute(e)),Object(W.mergeMap)(e=>new qr(this.dbService).execute(e)),Object(W.mergeMap)(e=>new Kr(this.sdkConfig.appConfig,this.fileService,this.dbService,this.deviceInfo).execute(e))).pipe(Object(W.tap)(()=>{this.eventsBusService.emit({namespace:k.EventNamespace.STORAGE,event:{type:Xn.StorageEventType.TRANSFER_COMPLETED}})}),Object(W.mapTo)(void 0),Object(W.catchError)(e=>(e instanceof Fr?this.eventsBusService.emit({namespace:k.EventNamespace.STORAGE,event:{type:Xn.StorageEventType.TRANSFER_REVERT_COMPLETED}}):e instanceof Pr?this.eventsBusService.emit({namespace:k.EventNamespace.STORAGE,event:{type:Xn.StorageEventType.TRANSFER_FAILED_DUPLICATE_CONTENT}}):e instanceof yr&&this.eventsBusService.emit({namespace:k.EventNamespace.STORAGE,event:{type:Xn.StorageEventType.TRANSFER_FAILED_LOW_MEMORY}}),console.error("Error",e),Object(y.throwError)(e))))}cancel(){return Object(y.defer)(()=>ti(this,void 0,void 0,(function*(){this.context.hasTransferCancelled=!0}))).pipe(Object(W.mapTo)(void 0))}}var ri=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class ii{constructor(e,t){this.fileService=e,this.dbService=t}execute(e){return Object(y.defer)(()=>ri(this,void 0,void 0,(function*(){const t=yield this.getContentsInDb();if(e.currentStoragePath){let n=ge.a.getContentRootDir(e.currentStoragePath).concat("/");"ios"===window.device.platform.toLowerCase()&&(n="file://"+n);const r=yield this.getFolderList(n);e.newlyAddedIdentifiers=yield this.getNewlyAddedContents(r,t),e.deletedIdentifiers=yield this.getDeletedContents(r,t)}else e.newlyAddedIdentifiers=[],e.deletedIdentifiers=t}))).pipe(Object(W.mapTo)(e))}doesDestinationStorageExist(e){return this.fileService.exists(e).then(()=>!0).catch(()=>!1)}getContentsInDb(){return ri(this,void 0,void 0,(function*(){return this.dbService.execute(ge.a.getFindAllContentsQuery()).pipe(Object(W.map)(e=>e.filter(e=>"textbookunit"!==e[f.b.COLUMN_NAME_CONTENT_TYPE].toLowerCase()).map(e=>e[f.b.COLUMN_NAME_IDENTIFIER]))).toPromise()}))}getNewlyAddedContents(e,t){return e.filter(e=>!V.a.contains(t,e))}getDeletedContents(e,t){return t.filter(t=>!V.a.contains(e,t))}getFolderList(e){return this.fileService.listDir(e.replace(/\/$/,"")).then(e=>e.map(e=>e.name)).catch(()=>[])}}var oi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class si{constructor(e){this.storageHandler=e}exexute(e){return Object(y.defer)(()=>oi(this,void 0,void 0,(function*(){if(e.deletedIdentifiers.length&&(yield this.storageHandler.deleteContentsFromDb(e.deletedIdentifiers)),e.newlyAddedIdentifiers.length)for(const t of e.newlyAddedIdentifiers)yield this.storageHandler.addDestinationContentInDb(t,ge.a.getContentRootDir(e.currentStoragePath).concat("/"),!1)}))).pipe(Object(W.mapTo)(e))}}var ai=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class ci{constructor(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}addDestinationContentInDb(e,t,n){return ai(this,void 0,void 0,(function*(){const r=t.concat(e);this.fileService.readAsText(t.concat(e),B.FileName.MANIFEST.valueOf()).then(e=>{const t=JSON.parse(e),i=t.archive.items;return this.extractContentFromItem(i,r.concat("/"),t.ver,n)}).catch(e=>{console.error(e)})}))}deleteContentsFromDb(e){return ai(this,void 0,void 0,(function*(){const t=yield this.dbService.execute(ge.a.getFindAllContentsWithIdentifierQuery(e)).toPromise();for(const e of t){const t=e;if(t[f.b.COLUMN_NAME_MIME_TYPE]===B.MimeType.COLLECTION&&t[f.b.COLUMN_NAME_REF_COUNT]>1?t[f.b.COLUMN_NAME_CONTENT_STATE]=B.State.ARTIFACT_AVAILABLE:t[f.b.COLUMN_NAME_CONTENT_STATE]=B.State.ONLY_SPINE,t[f.b.COLUMN_NAME_VISIBILITY]===B.Visibility.DEFAULT&&t[f.b.COLUMN_NAME_REF_COUNT]>0){const e=t[f.b.COLUMN_NAME_REF_COUNT];t[f.b.COLUMN_NAME_REF_COUNT]=ge.a.addOrUpdateRefCount(e-1)}t[f.b.COLUMN_NAME_VISIBILITY]=B.Visibility.PARENT}this.dbService.beginTransaction();for(const e of t){const t=e;yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}))}extractContentFromItem(e,t,n,r){return ai(this,void 0,void 0,(function*(){const i=[],o=[];for(const s of e){let e=s;const a=e.identifier,c=e.mimeType,u=ge.a.readContentType(e),d=ge.a.readPrimaryCategory(e);let l=ge.a.readVisibility(e);const h=ge.a.readAudience(e),E=ge.a.readPragma(e),p=e.pkgVersion;let _=B.State.ONLY_SPINE.valueOf();const S=e.board,b=e.medium,O=e.gradeLevel,v=(yield this.dbService.read({table:f.b.TABLE_NAME,columns:[],selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[a]}).toPromise())[0],C=v&&ge.a.getBasePath(v[f.b.COLUMN_NAME_PATH]);let g=ge.a.doesContentExist(v,a,p,r);g&&e.status!==B.ContentStatus.DRAFT.valueOf()?v[f.b.COLUMN_NAME_VISIBILITY]===B.Visibility.DEFAULT.valueOf()&&(e=JSON.parse(v[f.b.COLUMN_NAME_LOCAL_DATA])):(g=!1,_=(B.MimeType.COLLECTION.valueOf(),B.State.ARTIFACT_AVAILABLE.valueOf()));const A=ge.a.getReferenceCount(v,l);l=ge.a.getContentVisibility(v,e.objectType,l),_=ge.a.getContentState(v,_);const T=g?C:t,N=yield this.fileService.getDirectorySize(T);ge.a.addOrUpdateViralityMetadata(e,this.deviceInfo.getDeviceID().toString());const y=ge.a.constructContentDBModel(a,n,JSON.stringify(e),c,u,l,T,A,_,h,E,N,S,b,O,d);v?o.push(y):i.push(y)}if(i.length||o.length){this.dbService.beginTransaction();for(const e of i){const t=e;yield this.dbService.insert({table:f.b.TABLE_NAME,modelJson:t}).toPromise()}for(const e of o){const t=e;yield this.dbService.update({table:f.b.TABLE_NAME,selection:f.b.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[f.b.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}}var ui,di=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},li=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},fi=function(e,t){return function(n,r){t(n,r,e)}},hi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let Ei=ui=class{constructor(e,t,n,r,i,o){this.eventsBusService=e,this.sharedPreferences=t,this.dbService=n,this.deviceInfo=r,this.fileService=i,this.sdkConfig=o,this.contentsToTransfer=new mt(this.sharedPreferences,X.n.KEY_TO_TRANSFER_LIST,e=>e),this.transferContentHandler=new ni(this.sdkConfig,this.fileService,this.dbService,this.eventsBusService,this.deviceInfo)}onInit(){return Object(y.zip)(this.deviceInfo.getStorageVolumes(),this.getStorageDestination()).pipe(Object(W.tap)(e=>{this.availableStorageVolumes=e[0],this.currentStorageDestination=e[1],this.scanStorage().toPromise()}),Object(W.mapTo)(void 0))}getStorageDestinationDirectoryPath(){const e=this.availableStorageVolumes.find(e=>e.storageDestination===this.currentStorageDestination);return e&&e.info.contentStoragePath}cancelTransfer(){return this.transferContentHandler.cancel()}getStorageDestination(){return this.sharedPreferences.getString(ui.STORAGE_DESTINATION).pipe(Object(W.map)(e=>e||Xn.StorageDestination.INTERNAL_STORAGE))}getStorageDestinationVolumeInfo(){return this.getStorageDestination().pipe(Object(W.map)(e=>this.availableStorageVolumes.find(t=>t.storageDestination===e)))}getToTransferContents(){return Object(y.of)([])}getTransferringContent(){return Object(y.of)(void 0)}retryCurrentTransfer(){return this.lastTransferContentsRequest?this.transferContents(Object.assign(Object.assign({},this.lastTransferContentsRequest),{shouldMergeInDestination:!0})):Object(y.of)(void 0)}transferContents(e){return this.lastTransferContentsRequest=e,e.sourceFolder=this.getStorageDestinationDirectoryPath(),this.transferContentHandler.transfer(e).pipe(Object(W.mergeMap)(()=>this.getStorageDestination()),Object(W.map)(e=>e===Xn.StorageDestination.EXTERNAL_STORAGE?Xn.StorageDestination.INTERNAL_STORAGE:Xn.StorageDestination.EXTERNAL_STORAGE),Object(W.tap)(e=>{this.currentStorageDestination=e}),Object(W.mergeMap)(e=>this.sharedPreferences.putString(ui.STORAGE_DESTINATION,e)))}scanStorage(){const e=this.getStorageDestinationDirectoryPath(),t={currentStoragePath:e};return e||this.resetStorageDestination(),new ii(this.fileService,this.dbService).execute(t).pipe(Object(W.mergeMap)(e=>{const t=new ci(this.sdkConfig.appConfig,this.fileService,this.dbService,this.deviceInfo);return new si(t).exexute(e)}),Object(W.mapTo)(!0))}resetStorageDestination(){return hi(this,void 0,void 0,(function*(){return this.currentStorageDestination=Xn.StorageDestination.INTERNAL_STORAGE,this.sharedPreferences.putString(ui.STORAGE_DESTINATION,Xn.StorageDestination.INTERNAL_STORAGE).toPromise()}))}};Ei.STORAGE_DESTINATION=X.n.KEY_STORAGE_DESTINATION,Ei=ui=di([Object(T.injectable)(),fi(0,Object(T.inject)(N.b.EVENTS_BUS_SERVICE)),fi(1,Object(T.inject)(N.b.SHARED_PREFERENCES)),fi(2,Object(T.inject)(N.b.DB_SERVICE)),fi(3,Object(T.inject)(N.b.DEVICE_INFO)),fi(4,Object(T.inject)(N.b.FILE_SERVICE)),fi(5,Object(T.inject)(N.b.SDK_CONFIG)),li("design:paramtypes",[Object,Object,s.DbService,Object,Object,Object])],Ei);var pi=n(60);class _i{static constructNotificationDBModel(e){return{message_id:e.id,expiry_time:e.expiry,display_time:e.displayTime,received_at:Date.now(),notification_json:JSON.stringify(e),is_read:e.isRead}}static getFilterForNotification(e){let t,n;switch(e.notificationStatus){case pi.NotificationStatus.ALL:t=`${d.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${d.COLUMN_NAME_EXPIRY_TIME} > ?`,n=[Date.now().toString(),Date.now().toString()];break;case pi.NotificationStatus.UNREAD:t=`${d.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${d.COLUMN_NAME_EXPIRY_TIME} > ? AND\n AND ${d.COLUMN_NAME_IS_READ} > ?`,n=[Date.now().toString(),Date.now().toString(),0];break;case pi.NotificationStatus.READ:default:t=`${d.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${d.COLUMN_NAME_EXPIRY_TIME} > ?\n AND ${d.COLUMN_NAME_IS_READ} > ?`,n=[Date.now().toString(),Date.now().toString(),1]}return{table:d.TABLE_NAME,orderBy:d.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+" desc"}}}var Si,bi=n(58),Oi=n(73),vi=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ci=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},gi=function(e,t){return function(n,r){t(n,r,e)}},Ai=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},Ti=d.COLUMN_NAME_NOTIFICATION_JSON;let Ni=Si=class{constructor(e,t,n,r){this.dbService=e,this.sharedPreferences=t,this.profileService=n,this.keyValueStore=r,this._notifications$=new y.BehaviorSubject([]),this._notificationTrigger$=new y.Subject}get notifications$(){return this._notifications$}onInit(){const e=Object(y.interval)(36e5).pipe(Object(W.startWith)(null),Object(W.mapTo)(null)),t=this._notificationTrigger$.pipe(Object(W.startWith)(null),Object(W.throttleTime)(1e3));return Object(y.combineLatest)([e,t]).pipe(Object(W.switchMap)(()=>Object(y.defer)(()=>Ai(this,void 0,void 0,(function*(){try{const e=yield this.fetchNotificationAndUserFeed();this._notifications$.next(e)}catch(e){console.error(e)}})))),Object(W.mapTo)(void 0))}addNotification(e){return e.actionData&&"codePush"===e.actionData.actionType&&e.actionData.deploymentKey&&this.sharedPreferences.putString(X.d.DEPLOYMENT_KEY,e.actionData.deploymentKey),this.dbService.read({table:d.TABLE_NAME,selection:d.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(W.mergeMap)(t=>t&&t.length?this.dbService.update({table:d.TABLE_NAME,selection:d.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:_i.constructNotificationDBModel(e)}).pipe(Object(W.mapTo)(!0)):this.dbService.insert({table:d.TABLE_NAME,modelJson:_i.constructNotificationDBModel(e)}).pipe(Object(W.mapTo)(!0))),Object(W.tap)(()=>this.triggerNotificationChange()))}deleteNotification(e){if("USER_FEED"===e.source)return this.profileService.deleteUserFeedEntry({feedEntryId:e.id,category:te.UserFeedCategory.NOTIFICATION}).pipe(Object(W.tap)(()=>this.triggerNotificationChange()));const t=`DELETE FROM ${d.TABLE_NAME} `.concat(e.id?`WHERE ${d.COLUMN_NAME_MESSAGE_ID} = ${e.id}`:"");return this.dbService.execute(t).pipe(Object(W.mapTo)(!0),Object(W.tap)(()=>this.triggerNotificationChange()))}getAllNotifications(e){return this.dbService.read(_i.getFilterForNotification(e)).pipe(Object(W.map)(e=>e.map(e=>{const t=JSON.parse(e[Ti]);return t.isRead=e[d.COLUMN_NAME_IS_READ],t})))}updateNotification(e){return"USER_FEED"===e.source?this.profileService.updateUserFeedEntry({feedEntryId:e.id,category:te.UserFeedCategory.NOTIFICATION,request:{status:e.isRead?te.UserFeedStatus.READ:te.UserFeedStatus.UNREAD}}).pipe(Object(W.tap)(()=>this.triggerNotificationChange())):this.dbService.read({table:d.TABLE_NAME,selection:d.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(W.mergeMap)(t=>t&&t.length?this.dbService.update({table:d.TABLE_NAME,selection:d.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:_i.constructNotificationDBModel(e)}).pipe(Object(W.mapTo)(!0)):Object(y.of)(!1)),Object(W.tap)(()=>this.triggerNotificationChange()))}deleteAllNotifications(){return Object(y.defer)(()=>Ai(this,void 0,void 0,(function*(){const e=this._notifications$.getValue();try{return yield Promise.all(e.map(e=>this.deleteNotification(e).toPromise())),!0}catch(e){return console.error(e),!1}})))}fetchNotificationAndUserFeed(){return Ai(this,void 0,void 0,(function*(){const e=yield Promise.all([(()=>Ai(this,void 0,void 0,(function*(){return this.getAllNotifications({notificationStatus:pi.NotificationStatus.ALL}).toPromise()})))(),(()=>Ai(this,void 0,void 0,(function*(){try{const e=yield this.profileService.getActiveProfileSession().toPromise(),t=`${Si.USER_NOTIFICATION_FEED_KEY}_${e.managedSession?e.managedSession.uid:e.uid}`;try{const e=yield this.profileService.getUserFeed().toPromise().then(e=>e.filter(e=>e.category===te.UserFeedCategory.NOTIFICATION));return this.keyValueStore.setValue(t,Object(bi.gzip)(JSON.stringify(e))).toPromise(),e}catch(e){return this.keyValueStore.getValue(t).toPromise().then(e=>JSON.parse(Object(Oi.ungzip)(e,{to:"string"}))).catch(e=>(console.error(e),[]))}}catch(e){return[]}})))()]),t=e[0],n=e[1];return t.concat(n.map(e=>({id:e.id,source:"USER_FEED",displayTime:new Date(e.createdOn).getTime(),expiry:e.expireOn?new Date(e.expireOn).getTime():0,isRead:"read"===e.status?1:0,actionData:e.data}))).sort((e,t)=>new Date(t.displayTime).getTime()-new Date(e.displayTime).getTime())}))}triggerNotificationChange(){return Ai(this,void 0,void 0,(function*(){this._notificationTrigger$.next(null)}))}};var yi;Ni.USER_NOTIFICATION_FEED_KEY="user_notification_feed",Ni=Si=vi([Object(T.injectable)(),gi(0,Object(T.inject)(N.b.DB_SERVICE)),gi(1,Object(T.inject)(N.b.SHARED_PREFERENCES)),gi(2,Object(T.inject)(N.b.PROFILE_SERVICE)),gi(3,Object(T.inject)(N.b.KEY_VALUE_STORE)),Ci("design:paramtypes",[s.DbService,Object,Object,Object])],Ni),function(e){e.CUSTODIAN_ORG_ID="custodianOrgId",e.COURSE_FRAMEWORK_ID="courseFrameworkId",e.ERROR_LOG_SYNC_SETTINGS="errorLogSyncSettings"}(yi||(yi={}));class mi{static mapErrorSatckDBEntryToErrorStack(e){return{appver:e[h.COLUMN_NAME_APP_VERSION],pageid:e[h.COLUMN_NAME_PAGE_ID],ts:e[h.COLUMN_NAME_TIME_STAMP],log:e[h.COLUMN_NAME_ERROR_LOG]}}static mapErrorStackToErrorStackDBEntry(e){return{[h.COLUMN_NAME_APP_VERSION]:e.appver,[h.COLUMN_NAME_PAGE_ID]:e.pageid,[h.COLUMN_NAME_TIME_STAMP]:e.ts,[h.COLUMN_NAME_ERROR_LOG]:e.log}}}var Ii=h._ID;class Mi{constructor(e,t,n,r,i){this.apiService=e,this.dbService=t,this.errorLoggerConfig=n,this.networkInfoService=r,this.errorStackSyncRequestDecorator=i}handle(e){return this.processBatch(e).pipe(Object(W.expand)(t=>t>0?this.processBatch(e):y.EMPTY),Object(W.mapTo)(void 0),Object(W.catchError)(()=>Object(y.of)(void 0)))}processBatch(e){return this.getErrorStackBatch(e).pipe(Object(W.mergeMap)(e=>this.sync(e)),Object(W.mergeMap)(e=>this.clearLogs(e)),Object(W.map)(e=>e.length))}getErrorStackBatch(e){return this.dbService.execute(`\n SELECT * FROM ${h.TABLE_NAME}\n LIMIT ${e}\n `)}clearLogs(e){return e.length?this.dbService.execute(`\n DELETE FROM ${h.TABLE_NAME}\n WHERE ${h._ID} IN (${e.map(e=>e[Ii]).join(",")})\n `).pipe(Object(W.mapTo)(e)):Object(y.of)(e)}sync(e){return e.length?this.networkInfoService.networkStatus$.pipe(Object(W.mergeMap)(t=>{if(t===z.NetworkStatus.OFFLINE)return Object(y.throwError)(new Error("Fake Error"));const n={pdata:void 0,context:void 0,logs:e.map(e=>mi.mapErrorSatckDBEntryToErrorStack(e))};return this.errorStackSyncRequestDecorator.decorate(n).pipe(Object(W.mergeMap)(()=>{const e=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(this.errorLoggerConfig.errorLoggerApiPath).withBearerToken(!0).withBody({request:n}).build();return this.apiService.fetch(e)}))}),Object(W.mapTo)(e)):Object(y.of)(e)}}var Di=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Ri{constructor(e,t,n){this.apiConfig=e,this.deviceInfo=t,this.appInfo=n}decorate(e){return Object(y.defer)(()=>Di(this,void 0,void 0,(function*(){return this.patchPData(e),yield this.patchContext(e),e})))}patchContext(e){return Di(this,void 0,void 0,(function*(){e.context={did:this.deviceInfo.getDeviceID(),spec:yield this.deviceInfo.getDeviceSpec().toPromise()}}))}patchPData(e){e.pdata=new P.ProducerData,e.pdata.id=this.apiConfig.api_authentication.producerId;const t=e.pdata.pid;t?e.pdata.pid=t:this.apiConfig.api_authentication.producerUniqueId?e.pdata.pid=this.apiConfig.api_authentication.producerUniqueId:e.pdata.pid="sunbird.android",e.pdata.ver||(e.pdata.ver=this.appInfo.getVersionName())}}var Pi,Li=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},wi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ui=function(e,t){return function(n,r){t(n,r,e)}};let ji=Pi=class{constructor(e,t,n,r,i,o,s,a){this.systemSettingsService=e,this.dbService=t,this.appInfo=n,this.apiService=r,this.sdkConfig=i,this.errorLoggerService=o,this.deviceInfo=s,this.sharedPreferences=a,this.errorLoggerConfig=this.sdkConfig.errorLoggerConfig,this.errorStackSyncRequestDecorator=new Ri(this.sdkConfig.apiConfig,this.deviceInfo,this.appInfo),this.errorStackSyncHandler=new Mi(this.apiService,this.dbService,this.errorLoggerConfig,this.errorLoggerService,this.errorStackSyncRequestDecorator)}onInit(){return this.sharedPreferences.getString(X.i.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(W.mergeMap)(e=>e?Object(y.of)(void 0):this.sharedPreferences.putString(X.i.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+"")))}logError(e){const t={appver:this.appInfo.getVersionName(),pageid:e.pageId,ts:Date.now(),log:e.stacktrace};return this.dbService.insert({table:h.TABLE_NAME,modelJson:mi.mapErrorStackToErrorStackDBEntry(t)}).pipe(Object(W.mergeMap)(()=>this.getErrorCount()),Object(W.mergeMap)(e=>this.getErrorLogSyncSettings().pipe(Object(W.map)(t=>Object.assign(Object.assign({},t),{errorCount:e})))),Object(W.map)(({errorCount:e,frequency:t,bandwidth:n})=>({errorCount:e,errorLogSyncFrequency:t,errorLogSyncBandwidth:n})),Object(W.mergeMap)(({errorCount:e,errorLogSyncFrequency:t,errorLogSyncBandwidth:n})=>this.hasErrorLogSyncFrequencyCrossed(e,t).pipe(Object(W.map)(e=>({shouldSync:e,errorLogSyncBandwidth:n})))),Object(W.mergeMap)(({shouldSync:e,errorLogSyncBandwidth:t})=>e?this.errorStackSyncHandler.handle(t).pipe(Object(W.mergeMap)(()=>this.sharedPreferences.putString(X.i.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+""))):Object(y.of)(void 0)))}hasErrorLogSyncFrequencyCrossed(e,t){return this.sharedPreferences.getString(X.i.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(W.map)(e=>parseInt(e,10)),Object(W.map)(e=>e+t<Date.now()))}getErrorCount(){return this.dbService.execute("SELECT COUNT(*) as count FROM "+h.TABLE_NAME).pipe(Object(W.map)(e=>e[0].count))}getErrorLogSyncSettings(){const e={id:Pi.ERROR_LOG_SYNC_SETTINGS};return this.systemSettingsService.getSystemSettings(e).pipe(Object(W.map)(e=>JSON.parse(e.value)))}};ji.ERROR_LOG_SYNC_SETTINGS=yi.ERROR_LOG_SYNC_SETTINGS,ji=Pi=Li([Object(T.injectable)(),Ui(0,Object(T.inject)(N.b.SYSTEM_SETTINGS_SERVICE)),Ui(1,Object(T.inject)(N.b.DB_SERVICE)),Ui(2,Object(T.inject)(N.b.APP_INFO)),Ui(3,Object(T.inject)(N.b.API_SERVICE)),Ui(4,Object(T.inject)(N.b.SDK_CONFIG)),Ui(5,Object(T.inject)(N.b.NETWORKINFO_SERVICE)),Ui(6,Object(T.inject)(N.b.DEVICE_INFO)),Ui(7,Object(T.inject)(N.b.SHARED_PREFERENCES)),wi("design:paramtypes",[Object,s.DbService,Object,Object,Object,Object,Object,Object])],ji);var Fi=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},xi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let ki=class{constructor(){"none"===navigator.connection.type?this.networkStatusSource=new y.BehaviorSubject(z.NetworkStatus.OFFLINE):this.networkStatusSource=new y.BehaviorSubject(z.NetworkStatus.ONLINE),window.addEventListener("online",()=>{this.networkStatusSource.next(z.NetworkStatus.ONLINE)},!1),window.addEventListener("offline",()=>{this.networkStatusSource.next(z.NetworkStatus.OFFLINE)},!1),this.networkStatus$=this.networkStatusSource.asObservable()}};ki=Fi([Object(T.injectable)(),xi("design:paramtypes",[])],ki);var Bi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Vi extends s.Migration{constructor(){super(8,23)}apply(e){return Bi(this,void 0,void 0,(function*(){this.queries().forEach(t=>Bi(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[_.a.getCreateEntry()]}}var Yi=_.a.COLUMN_NAME_USER_ID,Gi=_.a.COLUMN_NAME_QUERY,Hi=_.a.COLUMN_NAME_TIME_STAMP;var qi,$i=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ki=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zi=function(e,t){return function(n,r){t(n,r,e)}};let Wi=qi=class{constructor(e,t){this.dbService=e,this.profileService=t}addEntry({query:e,namespace:t}){return this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(({uid:n})=>this.dbService.insert({table:_.a.TABLE_NAME,modelJson:{[_.a.COLUMN_NAME_QUERY]:e.trim(),[_.a.COLUMN_NAME_NAMESPACE]:t,[_.a.COLUMN_NAME_USER_ID]:n,[_.a.COLUMN_NAME_TIME_STAMP]:Date.now()}}).pipe(Object(W.mapTo)(n))),Object(W.mergeMap)(e=>this.dbService.execute(`\n DELETE FROM ${_.a.TABLE_NAME} WHERE\n ${_.a._ID} IN (SELECT ${_.a._ID} FROM ${_.a.TABLE_NAME} WHERE\n ${_.a.COLUMN_NAME_USER_ID} = "${e}" AND\n ${_.a.COLUMN_NAME_NAMESPACE} = "${t}"\n ORDER BY ${_.a.COLUMN_NAME_TIME_STAMP} DESC\n LIMIT -1 OFFSET ${qi.MAX_USER_SEARCH_HISTORY_ENTRIES})\n `)),Object(W.mapTo)(void 0))}getEntries({like:e,limit:t,namespace:n}){return this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(({uid:r})=>{let i="";return e&&(i=`AND ${_.a.COLUMN_NAME_QUERY} LIKE "%${e.trim()}%"`),this.dbService.execute(`\n SELECT * FROM ${_.a.TABLE_NAME} WHERE\n ${_.a.COLUMN_NAME_USER_ID} = "${r}" AND\n ${_.a.COLUMN_NAME_NAMESPACE} = "${n}"\n ${i}\n ORDER BY ${_.a.COLUMN_NAME_TIME_STAMP} DESC\n LIMIT ${t}\n `)}),Object(W.map)(e=>e.map(e=>class{static mapSearchHistoryDbEntryToSearchEntry(e){return{uid:e[Yi],query:e[Gi],timestamp:e[Hi]}}}.mapSearchHistoryDbEntryToSearchEntry(e))))}};Wi.MAX_USER_SEARCH_HISTORY_ENTRIES=10,Wi=qi=$i([Object(T.injectable)(),zi(0,Object(T.inject)(N.b.DB_SERVICE)),zi(1,Object(T.inject)(N.b.PROFILE_SERVICE)),Ki("design:paramtypes",[s.DbService,Object])],Wi);var Xi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Ji extends s.Migration{constructor(){super(9,24)}apply(e){return Xi(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:f.d.TABLE_NAME}).pipe(Object(W.map)(t=>{t.forEach(t=>Xi(this,void 0,void 0,(function*(){const n=t[f.d.COLUMN_NAME_DATA];if(n){const r=JSON.parse(n);t[f.b.COLUMN_NAME_MIME_TYPE]=r.mimeType,yield e.update({table:f.d.TABLE_NAME,modelJson:t,selection:f.d.COLUMN_NAME_CONTENT_IDENTIFIER+" = ?",selectionArgs:[t[f.d.COLUMN_NAME_CONTENT_IDENTIFIER]]}).toPromise()}})))})).toPromise()}))}queries(){return[f.d.getAlterEntryForMimeType()]}}var Qi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Zi extends s.Migration{constructor(){super(10,25)}apply(e){return Qi(this,void 0,void 0,(function*(){for(const t of this.queries())yield e.execute(t).toPromise()}))}queries(){return[S.a.getCreateEntry()]}}var eo=n(88),to=n(89),no=n(83),ro=n(31),io=n(90),oo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class so{constructor(e,t){this.dbService=e,this.fileService=t}export(e,t){return new y.Observable(e=>{(()=>{oo(this,void 0,void 0,(function*(){let n={task:"",completed:[]};e.next(n=Object.assign(Object.assign({},n),{task:"VALIDATING"}));try{yield this.validate()}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"PREPARING"})),yield this.prepare(t),e.next(n=Object.assign(Object.assign({},n),{task:"INITIALIZING"})),yield this.createWorkspace();const r=yield this.getMessageIds();try{for(;r.length;){const t=r.pop();yield this.processBatch(t).then(t=>{if(!t)return void e.next(n=Object.assign(Object.assign({},n),{task:"SKIPPING_BATCH"}));const{file:r,mid:i,eventsCount:o,size:s}=t;e.next(n=Object.assign(Object.assign({},n),{task:"BUILDING_BATCH",completed:[...n.completed,{file:r,mid:i,eventsCount:o,size:s,objectType:ro.a.TELEMETRY,contentEncoding:"gzip",explodedSize:-1}]}))})}}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"OBJECT_ARCHIVE_COMPLETE"})),e.complete()}))})()})}validate(){return oo(this,void 0,void 0,(function*(){if(!(yield this.dbService.execute(`\n SELECT count(*) as COUNT FROM ${b.a.TABLE_NAME} WHERE ${b.a.COLUMN_NAME_TYPE} = '${b.b.TELEMETRY}'\n `.trim()).pipe(Object(W.map)(e=>e&&e[0]&&e[0].COUNT)).toPromise()))throw new io.a("No telemetry to export")}))}prepare(e){return oo(this,void 0,void 0,(function*(){this.workspaceSubPath=""+e.workspacePath}))}createWorkspace(){return oo(this,void 0,void 0,(function*(){return this.fileService.createDir(this.workspaceSubPath,!1)}))}getMessageIds(){return oo(this,void 0,void 0,(function*(){return(yield this.dbService.read({table:b.a.TABLE_NAME,columns:[b.a.COLUMN_NAME_MSG_ID],selection:b.a.COLUMN_NAME_TYPE+" = ?",selectionArgs:[b.b.TELEMETRY],distinct:!0}).toPromise()).map(e=>e[b.a.COLUMN_NAME_MSG_ID])}))}processBatch(e){return oo(this,void 0,void 0,(function*(){const t=(yield this.dbService.read({table:b.a.TABLE_NAME,selection:`${b.a.COLUMN_NAME_MSG_ID} = ? AND ${b.a.COLUMN_NAME_TYPE} = ?`,selectionArgs:[e,b.b.TELEMETRY]}).toPromise())[0];if(t)return yield this.fileService.writeFile(this.workspaceSubPath,t[b.a.COLUMN_NAME_MSG_ID],t[b.a.COLUMN_NAME_DATA],{replace:!0}),{size:[b.a.COLUMN_NAME_DATA].length,eventsCount:t[b.a.COLUMN_NAME_NUMBER_OF_ITEM],mid:t[b.a.COLUMN_NAME_MSG_ID],file:""+t[b.a.COLUMN_NAME_MSG_ID]}}))}}class ao extends ne.a{constructor(e,t){super(e,"ASSERTION_ERROR_"+t),Object.setPrototypeOf(this,ao.prototype)}}class co extends ao{constructor(e){super(e,"UNKNOWN_OBJECT_ERROR"),Object.setPrototypeOf(this,co.prototype)}}var uo=n(50),lo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class fo{constructor(e,t,n,r){this.dbService=e,this.fileService=t,this.networkQueue=n,this.sdkConfig=r}import(e,t){return new y.Observable(e=>{(()=>{lo(this,void 0,void 0,(function*(){let n={task:"",pending:[]};const r=t.items;e.next({task:"PREPARING",pending:[...r]}),yield this.prepare(t);try{for(;r.length;){const t=r.pop();if("gzip"!==t.contentEncoding)return void e.error(new co("Unknown content encoding "+t.contentEncoding));yield this.processBatch(t).then(()=>{e.next(n=Object.assign(Object.assign({},n),{task:"IMPORTING_BATCH",pending:[...r]}))})}}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"OBJECT_IMPORT_COMPLETE"})),e.complete()}))})()})}prepare(e){return lo(this,void 0,void 0,(function*(){this.workspaceSubPath=""+e.workspacePath}))}processBatch(e){return lo(this,void 0,void 0,(function*(){return this.fileService.readAsBinaryString(this.workspaceSubPath,e.file).then(t=>{this.networkQueue.enqueue(new uo.a(this.sdkConfig).generateNetworkQueueRequest(b.b.TELEMETRY,t,e.mid,e.eventsCount,!1),!1).toPromise()})}))}}class ho extends ao{constructor(e){super(e,"INVALID_ARCHIVE"),Object.setPrototypeOf(this,ho.prototype)}}var Eo,po=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},_o=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},So=function(e,t){return function(n,r){t(n,r,e)}};let bo=Eo=class{constructor(e,t,n,r,i,o,s){this.fileService=e,this.dbService=t,this.telemetryService=n,this.zipService=r,this.deviceInfo=i,this.networkQueue=o,this.sdkConfig=s}static reduceObjectProgressToArchiveObjectExportProgress(e){return e.reduce((e,{type:t,progress:n})=>(e.set(t,n),e),new Map)}static reduceObjectProgressToArchiveObjectImportProgress(e){return e.reduce((e,{type:t,progress:n})=>(e.set(t,n),e),new Map)}export(e){const t=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}${L.a.generateUniqueId()}`;let n;return e.objects.length?Object(y.concat)(Object(y.defer)(()=>Object(y.from)(this.fileService.createDir(t,!1))).pipe(Object(W.concatMap)(()=>Object(y.combineLatest)(e.objects.map(n=>{switch(n.type){case ro.a.CONTENT:case ro.a.PROFILE:throw new Error("To be implemented");case ro.a.TELEMETRY:return new so(this.dbService,this.fileService).export({filePath:e.filePath},{workspacePath:t}).pipe(Object(W.map)(e=>({type:ro.a.TELEMETRY,progress:e})))}}))),Object(W.map)(e=>({task:"BUILDING",progress:Eo.reduceObjectProgressToArchiveObjectExportProgress(e)})),Object(W.tap)(e=>n=e)),Object(y.defer)(()=>this.generateManifestFile(n,t)),Object(y.defer)(()=>this.generateZipArchive(n,t)),Object(y.defer)(()=>this.generateExportTelemetries(n,t))).pipe(Object(W.tap)(e=>n=e)):Object(y.throwError)(new ro.c("No archive objects to export"))}generateExportTelemetries(e,t){return e.progress.forEach((e,t)=>{switch(t){case ro.a.CONTENT:case ro.a.PROFILE:throw new Error("To be implemented");case ro.a.TELEMETRY:{const e={dir:P.ShareDirection.OUT,type:P.ShareType.FILE,items:[],env:"sdk"};this.telemetryService.share(e).toPromise()}}}),Object(y.of)(Object.assign({},e))}generateZipArchive(e,t){const n=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}archive-${(new Date).toISOString()}.zip`;return new y.Observable(e=>{this.zipService.zip(t,{target:n},[],[],()=>{e.next(),e.complete()},t=>{e.error(t)})}).pipe(Object(W.mapTo)(Object.assign(Object.assign({},e),{task:"COMPLETE",filePath:n})))}generateManifestFile({progress:e},t){return this.telemetryService.buildContext().pipe(Object(W.map)(e=>e.pdata),Object(W.concatMap)(n=>{const r=Array.from(e.entries()).reduce((e,[t,n])=>e.concat(n.completed),[]);return Object(y.from)(this.fileService.writeFile(t,"manifest.json",JSON.stringify({id:Eo.ARCHIVE_ID,ver:Eo.ARCHIVE_VERSION,ts:(new Date).toISOString(),producer:n,archive:{count:r.length,items:r}}),{replace:!0}))}),Object(W.mapTo)({progress:e,task:"BUILDING_MANIFEST"}))}import(e){const t=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}${L.a.generateUniqueId()}`;if(!e.objects.length)return Object(y.throwError)(new ro.c("No archive objects to export"));let n={task:"",progress:new Map,filePath:e.filePath};return Object(y.concat)(Object(y.defer)(()=>Object(y.from)(this.fileService.createDir(t,!1))).pipe(Object(W.concatMap)(()=>this.extractZipArchive(n,t))),Object(y.defer)(()=>this.readManifestFile(n,t,e.objects.map(e=>e.type))),Object(y.defer)(()=>this.generateImportTelemetries(n,t)),Object(y.defer)(()=>Object(y.combineLatest)(e.objects.map(r=>{switch(r.type){case ro.a.CONTENT:case ro.a.PROFILE:throw new Error("To be implemented");case ro.a.TELEMETRY:return new fo(this.dbService,this.fileService,this.networkQueue,this.sdkConfig).import({filePath:e.filePath},{workspacePath:t,items:n.progress.get(ro.a.TELEMETRY).pending}).pipe(Object(W.map)(e=>({type:ro.a.TELEMETRY,progress:e})))}})).pipe(Object(W.map)(e=>({task:"IMPORTING",progress:Eo.reduceObjectProgressToArchiveObjectImportProgress(e)})))),Object(y.of)(Object.assign(Object.assign({},n),{task:"COMPLETE"}))).pipe(Object(W.tap)(e=>n=e))}generateImportTelemetries(e,t){return e.progress.forEach((e,t)=>{switch(t){case ro.a.CONTENT:case ro.a.PROFILE:throw new Error("To be implemented");case ro.a.TELEMETRY:{const e={dir:P.ShareDirection.IN,type:P.ShareType.FILE.valueOf(),items:[],env:"sdk"};this.telemetryService.share(e).toPromise()}}}),Object(y.of)(Object.assign({},e))}extractZipArchive(e,t){const n=e.filePath;return new y.Observable(e=>{sbutility.copyFile(Pe.getDirecory(n),t+"/",Pe.getFileName(n),()=>{this.zipService.unzip(`${t}/${Pe.getFileName(n)}`,{target:t+"/"},()=>{e.next(),e.complete()},t=>e.error(t))},t=>{console.error(t),e.error(t)})}).pipe(Object(W.mapTo)(Object.assign(Object.assign({},e),{task:"EXTRACTING"})))}readManifestFile(e,t,n){return Object(y.from)(this.fileService.readAsText(t,"manifest.json")).pipe(Object(W.map)(e=>{try{return JSON.parse(e)}catch(e){throw new ho("Invalid manfiest.json")}}),Object(W.map)(t=>Object.assign(Object.assign({},e),{progress:(n.forEach(n=>{const r=t.archive.items.filter(e=>e.objectType===n);if(!r.length)throw new ho("Nothing to import");e.progress.set(n,{task:"INITIALISING",pending:r})}),e.progress),task:"VALIDATING"})))}};bo.ARCHIVE_ID="sunbird.data.archive",bo.ARCHIVE_VERSION="1.0",bo=Eo=po([Object(T.injectable)(),So(0,Object(T.inject)(N.b.FILE_SERVICE)),So(1,Object(T.inject)(N.b.DB_SERVICE)),So(2,Object(T.inject)(N.b.TELEMETRY_SERVICE)),So(3,Object(T.inject)(N.b.ZIP_SERVICE)),So(4,Object(T.inject)(N.b.DEVICE_INFO)),So(5,Object(T.inject)(N.b.NETWORK_QUEUE)),So(6,Object(T.inject)(N.b.SDK_CONFIG)),_o("design:paramtypes",[Object,s.DbService,Object,Object,Object,Object,Object])],bo);var Oo=n(69),vo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Co extends s.Migration{constructor(e,t){super(14,27),this.sdkConfig=e,this.networkQueue=t}apply(e){return vo(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:a.d.TABLE_NAME,selection:"",selectionArgs:[]}).pipe(Object(W.map)(t=>{const n=new uo.a(this.sdkConfig);t.forEach(t=>vo(this,void 0,void 0,(function*(){if(t){const r=t[a.d.COLUMN_NAME_MSG_ID],i=t[a.d.COLUMN_NAME_DATA],o=t[a.d.COLUMN_NAME_NUMBER_OF_EVENTS];yield this.networkQueue.enqueue(n.generateNetworkQueueRequest(b.b.TELEMETRY,i,r,o,!1),!1).toPromise(),yield e.execute(`DELETE FROM ${a.d.TABLE_NAME} WHERE ${a.d.COLUMN_NAME_MSG_ID}='${r}'`).toPromise()}})))})).toPromise()}))}queries(){return[Oo.a.getCreateEntry()]}}var go=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ao=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},To=function(e,t){return function(n,r){t(n,r,e)}},No=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let yo=class{constructor(e,t,n,r){this.dbService=e,this.sharedPreferences=t,this.deviceInfo=n,this.sdkConfig=r}enqueue(e,t){const n="Uint8Array"===this.getTypeOf(e.networkRequest.body)?e.networkRequest.body.buffer:e.networkRequest.body;return new y.Observable(r=>{(()=>{No(this,void 0,void 0,(function*(){e.networkRequest=yield this.interceptRequest(e.networkRequest).toPromise(),sbsync.enqueue(n,Oo.a.Mapper.networkQueueRequestToEntry(e),t,()=>{r.next(void 0),r.complete()},e=>{r.error(e)})}))})()})}interceptRequest(e){return this.sharedPreferences.getString(X.a.KEY_API_TOKEN).pipe(Object(W.map)(t=>{if(t){const n=e.headers;n.Authorization="Bearer "+t,e.headers=n}return e}),Object(W.mergeMap)(()=>this.sharedPreferences.getString(X.c.KEY_OAUTH_SESSION).pipe(Object(W.map)(t=>{if(t){const n=JSON.parse(t),r=e.headers;r["X-Authenticated-User-Token"]=n.access_token,n.managed_access_token&&(r["X-Authenticated-For"]=n.managed_access_token),e.headers=r}return e}))),Object(W.map)(()=>{e.headers["X-Channel-Id"]=this.sdkConfig.apiConfig.api_authentication.channelId,e.headers["X-App-Id"]=this.sdkConfig.apiConfig.api_authentication.producerId,e.headers["X-Device-Id"]=this.deviceInfo.getDeviceID(),e.headers.Accept="application/json",e.headers["Content-Type"]="application/json",e.headers["Access-Control-Allow-Origin"]="*",e.body={};return(new o.Request.Builder).withSerializer(e.serializer).withHost(this.sdkConfig.apiConfig.host).withType(e.type).withPath(e.path).withHeaders(e.headers).withBody({}).withBearerToken(!0).build()}))}getTypeOf(e){switch(Object.prototype.toString.call(e)){case"[object Uint8Array]":return"Uint8Array";default:return"Unknown"}}};yo=go([Object(T.injectable)(),To(0,Object(T.inject)(N.b.DB_SERVICE)),To(1,Object(T.inject)(N.b.SHARED_PREFERENCES)),To(2,Object(T.inject)(N.b.DEVICE_INFO)),To(3,Object(T.inject)(N.b.SDK_CONFIG)),Ao("design:paramtypes",[s.DbService,Object,Object,Object])],yo);class mo{constructor(e,t){this.groupActivityService=e,this.cachedItemStore=t}getDataAggregation(e){return this.cachedItemStore[e.from===tn.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](`group-${e.groupId}-activity-${e.activity.id}-${e.activity.type}`,mo.GROUP_ACTIVITY_DATA_AGGREGATION_KEY,"ttl_"+mo.GROUP_ACTIVITY_DATA_AGGREGATION_KEY,()=>this.groupActivityService.getDataAggregation(e.groupId,e.activity,e.mergeGroup,e.leafNodesCount))}getDataForDashlets(e,t){return this.groupActivityService.getDataForDashlets(e,t)}}mo.GROUP_ACTIVITY_DATA_AGGREGATION_KEY="GROUP_ACTIVITY_DATA_AGGREGATION-";var Io,Mo=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Do=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ro=function(e,t){return function(n,r){t(n,r,e)}};let Po=Io=class{constructor(e,t){this.container=e,this.cachedItemStore=t}get activityService(){return this._groupActivityService||(this._groupActivityService=new mo(this.groupServiceDelegate.activityService,this.cachedItemStore)),this._groupActivityService}get groupServiceDelegate(){return this.container.get(N.a.GROUP_SERVICE)}create(e){return this.groupServiceDelegate.create(e)}getById(e){return this.cachedItemStore[e.from===tn.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](`${e.id}-${e.userId}`+(e.options&&e.options.includeMembers?"-includeMembers:"+e.options.includeMembers:"")+(e.options&&e.options.includeActivities?"-includeActivities:"+e.options.includeActivities:"")+(e.options&&e.options.groupActivities?"-groupActivities:"+e.options.groupActivities:""),Io.GROUP_LOCAL_KEY,"ttl_"+Io.GROUP_LOCAL_KEY,()=>this.groupServiceDelegate.getById(e.id,e.options))}search({request:e,from:t}){return this.cachedItemStore[t===tn.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](""+e.filters.userId,Io.GROUP_SEARCH_LOCAL_KEY,"ttl_"+Io.GROUP_SEARCH_LOCAL_KEY,()=>this.groupServiceDelegate.search(e))}updateById(e){return this.groupServiceDelegate.updateById(e.id,e.updateRequest)}deleteById(e){return this.groupServiceDelegate.deleteById(e.id)}addMembers(e){return this.groupServiceDelegate.addMembers(e.groupId,e.addMembersRequest)}updateMembers(e){return this.groupServiceDelegate.updateMembers(e.groupId,e.updateMembersRequest)}removeMembers(e){return this.groupServiceDelegate.removeMembers(e.groupId,e.removeMembersRequest)}addActivities(e){return this.groupServiceDelegate.addActivities(e.groupId,e.addActivitiesRequest)}updateActivities(e){return this.groupServiceDelegate.updateActivities(e.groupId,e.updateActivitiesRequest)}removeActivities(e){return this.groupServiceDelegate.removeActivities(e.groupId,e.removeActivitiesRequest)}getSupportedActivities(){return this.groupServiceDelegate.getSupportedActivities()}suspendById(e){return this.groupServiceDelegate.suspendById(e.id)}reactivateById(e){return this.groupServiceDelegate.reactivateById(e.id)}updateGroupGuidelines(e){return this.groupServiceDelegate.updateGroupGuidelines(e)}};Po.GROUP_LOCAL_KEY="GROUP-",Po.GROUP_SEARCH_LOCAL_KEY="GROUP_SEARCH-",Po=Io=Mo([Object(T.injectable)(),Ro(0,Object(T.inject)(N.b.CONTAINER)),Ro(1,Object(T.inject)(N.b.CACHED_ITEM_STORE)),Do("design:paramtypes",[T.Container,Object])],Po);var Lo=n(67);class wo{static mapGroupDBEntryToGroup(e){return{gid:e[u.a.COLUMN_NAME_GID],name:e[u.a.COLUMN_NAME_NAME],syllabus:e[u.a.COLUMN_NAME_SYLLABUS].split(","),grade:e[u.a.COLUMN_NAME_GRADE].split(","),gradeValue:JSON.parse(e[u.a.COLUMN_NAME_GRADE_VALUE]),createdAt:e[u.a.COLUMN_NAME_CREATED_AT],updatedAt:e[u.a.COLUMN_NAME_UPDATED_AT]}}static mapGroupToGroupDBEntry(e){return{[u.a.COLUMN_NAME_GID]:e.gid,[u.a.COLUMN_NAME_SYLLABUS]:e.syllabus?e.syllabus.join(","):"",[u.a.COLUMN_NAME_GRADE]:e.grade?e.grade.join(","):"",[u.a.COLUMN_NAME_NAME]:e.name,[u.a.COLUMN_NAME_GRADE_VALUE]:JSON.stringify(e.gradeValue),[u.a.COLUMN_NAME_CREATED_AT]:e.createdAt,[u.a.COLUMN_NAME_UPDATED_AT]:e.updatedAt}}}var Uo,jo=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Fo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},xo=function(e,t){return function(n,r){t(n,r,e)}},ko=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let Bo=Uo=class{constructor(e,t,n,r){this.container=e,this.dbService=t,this.profileService=n,this.sharedPreferences=r}get telemetryService(){return this.container.get(N.b.TELEMETRY_SERVICE)}createGroup(e){return e.gid=L.a.generateUniqueId(),e.createdAt=Date.now(),e.updatedAt=Date.now(),this.dbService.insert({table:u.a.TABLE_NAME,modelJson:wo.mapGroupToGroupDBEntry(e)}).pipe(Object(W.tap)(()=>ko(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(W.map)(e=>e.uid),Object(W.mergeMap)(t=>{const n=new P.Actor;n.id=t,n.type=P.Actor.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:P.AuditState.AUDIT_CREATED,updatedProperties:wt.a.getTruthyProps(e),objId:e.gid,objType:P.ObjectType.GROUP};return this.telemetryService.audit(r)})).toPromise()}))),Object(W.map)(()=>e))}deleteGroup(e){return Object(y.defer)(()=>Object(y.of)(this.dbService.beginTransaction())).pipe(Object(W.mergeMap)(()=>Object(y.zip)(this.dbService.delete({table:u.a.TABLE_NAME,selection:u.a.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:u.b.TABLE_NAME,selection:u.b.COLUMN_NAME_GID+" = ?",selectionArgs:[e]})).pipe(Object(W.mapTo)(void 0))),Object(W.tap)(()=>{this.dbService.endTransaction(!0)}),Object(W.tap)(()=>ko(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(t=>{const n=new P.Actor;n.id=t.uid,n.type=P.Actor.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:P.AuditState.AUDIT_DELETED,objId:e,objType:P.ObjectType.GROUP};return this.telemetryService.audit(r)})).toPromise()}))),Object(W.catchError)(e=>(this.dbService.endTransaction(!1),y.Observable.throw(e))))}updateGroup(e){return this.dbService.read({table:u.a.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid]}).pipe(Object(W.map)(t=>t&&t[0]?wo.mapGroupDBEntryToGroup(t[0]):y.Observable.throw(new Lo.NoGroupFoundError("No Group found with ID "+e.gid))),Object(W.tap)(t=>ko(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(W.mergeMap)(n=>{const r=new P.Actor;r.id=n.uid,r.type=P.Actor.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:P.AuditState.AUDIT_UPDATED,updatedProperties:wt.a.getPropDiff(e,t),objId:e.gid,objType:P.ObjectType.GROUP};return this.telemetryService.audit(i)})).toPromise()}))),Object(W.mergeMap)(()=>this.dbService.update({table:u.a.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid],modelJson:{[u.a.COLUMN_NAME_NAME]:e.name,[u.a.COLUMN_NAME_SYLLABUS]:e.syllabus.join(","),[u.a.COLUMN_NAME_UPDATED_AT]:Date.now(),[u.a.COLUMN_NAME_GRADE]:e.grade.join(","),[u.a.COLUMN_NAME_GRADE_VALUE]:JSON.stringify(e.gradeValue)}}).pipe(Object(W.mapTo)(e))))}getActiveSessionGroup(){return this.getActiveGroupSession().pipe(Object(W.map)(e=>{if(!e)throw new Lo.NoActiveGroupSessionError("No active session available");return e}),Object(W.mergeMap)(e=>this.dbService.read({table:u.a.TABLE_NAME,selection:u.a.COLUMN_NAME_GID+" = ?",selectionArgs:[e.gid]}).pipe(Object(W.map)(e=>e&&e[0]))))}setActiveSessionForGroup(e){return this.dbService.read({table:u.a.TABLE_NAME,selection:u.a.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}).pipe(Object(W.map)(e=>e&&e[0]&&wo.mapGroupDBEntryToGroup(e[0])),Object(W.map)(e=>{if(!e)throw new Lo.NoGroupFoundError("No Profile found");return e}),Object(W.mergeMap)(e=>{const t=new Lo.GroupSessionDeprecated(e.gid);return this.sharedPreferences.putString(Uo.KEY_GROUP_SESSION,JSON.stringify({gid:t.gid,sid:t.sid,createdTime:t.createdTime})).pipe(Object(W.mapTo)(!0))}))}getActiveGroupSession(){return this.sharedPreferences.getString(Uo.KEY_GROUP_SESSION).pipe(Object(W.map)(e=>{if(e)return JSON.parse(e)}))}getAllGroups(e){return Object(y.defer)(()=>e?this.dbService.execute(`\n SELECT * FROM ${u.a.TABLE_NAME}\n LEFT JOIN ${u.b.TABLE_NAME} ON\n ${u.a.TABLE_NAME}.${u.a.COLUMN_NAME_GID} =\n ${u.b.TABLE_NAME}.${u.b.COLUMN_NAME_GID}\n WHERE ${u.b.COLUMN_NAME_UID} = "${e.uid}"`).pipe(Object(W.map)(e=>e.map(e=>wo.mapGroupDBEntryToGroup(e)))):this.dbService.read({table:u.a.TABLE_NAME,columns:[]}).pipe(Object(W.map)(e=>e.map(e=>wo.mapGroupDBEntryToGroup(e))))).pipe(Object(W.mergeMap)(e=>Object(y.from)(e)),Object(W.mergeMap)(e=>this.profileService.getAllProfiles({groupId:e.gid}).pipe(Object(W.map)(t=>Object.assign(Object.assign({},e),{profilesCount:t.length})))),Object(W.reduce)((e,t)=>[...e,t],[]))}addProfilesToGroup(e){return Object(y.defer)(()=>Object(y.of)(this.dbService.beginTransaction())).pipe(Object(W.mergeMap)(()=>this.dbService.delete({table:u.b.TABLE_NAME,selection:u.b.COLUMN_NAME_GID+" = ?",selectionArgs:[e.groupId]})),Object(W.mergeMap)(()=>e.uidList.length?Object(y.zip)(...e.uidList.map(t=>this.dbService.insert({table:u.b.TABLE_NAME,modelJson:{[u.b.COLUMN_NAME_GID]:e.groupId,[u.b.COLUMN_NAME_UID]:t}}))).pipe(Object(W.mapTo)(e.uidList.length)):Object(y.of)(0)),Object(W.tap)(()=>{this.dbService.endTransaction(!0)}),Object(W.catchError)(e=>(this.dbService.endTransaction(!1),Object(y.throwError)(e))))}removeActiveGroupSession(){return this.getActiveGroupSession().pipe(Object(W.mergeMap)(e=>e?this.sharedPreferences.putString(Uo.KEY_GROUP_SESSION,""):Object(y.of)(void 0)))}};Bo.KEY_GROUP_SESSION=X.k.KEY_GROUP_SESSION,Bo=Uo=jo([Object(T.injectable)(),xo(0,Object(T.inject)(N.b.CONTAINER)),xo(1,Object(T.inject)(N.b.DB_SERVICE)),xo(2,Object(T.inject)(N.b.PROFILE_SERVICE)),xo(3,Object(T.inject)(N.b.SHARED_PREFERENCES)),Fo("design:paramtypes",[T.Container,s.DbService,Object,Object])],Bo);var Vo=n(62),Yo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Go extends s.Migration{constructor(){super(15,28)}apply(e){return Yo(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield this.updateContentTable(e)}))}updateContentTable(e){return Yo(this,void 0,void 0,(function*(){e.beginTransaction();try{const t=(yield e.read({table:f.b.TABLE_NAME}).toPromise()).reduce((e,t)=>{let n;t[f.b.COLUMN_NAME_LOCAL_DATA]&&ge.a.isAvailableLocally(t[f.b.COLUMN_NAME_CONTENT_STATE])?n=JSON.parse(t[f.b.COLUMN_NAME_LOCAL_DATA]):t[f.b.COLUMN_NAME_SERVER_DATA]&&(n=JSON.parse(t[f.b.COLUMN_NAME_SERVER_DATA]));const r=n?n.resourceType:void 0,i=Vo.CsPrimaryCategoryMapper.getPrimaryCategory(t[f.b.COLUMN_NAME_CONTENT_TYPE],t[f.b.COLUMN_NAME_MIME_TYPE],r).toLowerCase();return e.set(t[f.b.COLUMN_NAME_IDENTIFIER],i),e},new Map);if(!t.size)return void e.endTransaction(!0);const n=this.buildPrimaryCategoryCases(t),r=`UPDATE ${f.b.TABLE_NAME} SET ${n};`.trim();yield e.execute(r).toPromise(),e.endTransaction(!0)}catch(t){throw console.error(t),e.endTransaction(!1),t}}))}buildPrimaryCategoryCases(e){return Array.from(e.entries()).reduce((e,[t,n])=>n?e.concat(` WHEN '${t}' THEN '${n}' `):e,` ${f.b.COLUMN_NAME_PRIMARY_CATEGORY} = CASE ${f.b.COLUMN_NAME_IDENTIFIER} `).concat(" ELSE '' END ")}queries(){return[f.b.getAlterEntryForPrimaryCategory()]}}var Ho=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},qo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$o=function(e,t){return function(n,r){t(n,r,e)}};let Ko=class{constructor(e){this.container=e}get discussionServiceDelegate(){return this.container.get(N.a.DISCUSSION_SERVICE)}getForumIds(e){return this.discussionServiceDelegate.getForumIds(e)}createUser(e){return this.discussionServiceDelegate.createUser(e)}attachForum(e){return this.discussionServiceDelegate.attachForum(e)}removeForum(e){return this.discussionServiceDelegate.removeForum(e)}createForum(e){return this.discussionServiceDelegate.createForum(e)}};Ko=Ho([Object(T.injectable)(),$o(0,Object(T.inject)(N.b.CONTAINER)),qo("design:paramtypes",[T.Container])],Ko);var zo=n(91),Wo=n(96),Xo=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Jo=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Qo=function(e,t){return function(n,r){t(n,r,e)}};let Zo=class{constructor(e){this.container=e}get NotificationServiceV2Delegate(){return this.container.get(N.a.NOTIFICATION_SERVICE_V2)}notificationRead(e){return this.NotificationServiceV2Delegate.notificationRead(e)}notificationUpdate(e){return this.NotificationServiceV2Delegate.notificationUpdate(e)}notificationDelete(e){return this.NotificationServiceV2Delegate.notificationDelete(e)}};Zo=Xo([Object(T.injectable)(),Qo(0,Object(T.inject)(N.b.CONTAINER)),Jo("design:paramtypes",[T.Container])],Zo);var es=n(82),ts=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class ns extends es.a{constructor(){super(16,29)}apply(e){return ts(this,void 0,void 0,(function*(){this.queries().forEach(t=>ts(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[O.a.getAlterEntryForPlayerConfig()]}}var rs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class is extends s.Migration{constructor(){super(17,30)}apply(e){return rs(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise()))}))}queries(){return[v.a.getCreateEntry()]}}var os=n(98),ss=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class as{constructor(){this._isInitialised=!1}static get instance(){return as._instance||(as._instance=new as),as._instance}get isInitialised(){return this._isInitialised}get sdkConfig(){return this._container.get(N.b.SDK_CONFIG)}get appInfo(){return this._container.get(N.b.APP_INFO)}get pageAssembleService(){return this._container.get(N.b.PAGE_ASSEMBLE_SERVICE)}get dbService(){return this._container.get(N.b.DB_SERVICE)}get telemetryService(){return this._container.get(N.b.TELEMETRY_SERVICE)}get authService(){return this._container.get(N.b.AUTH_SERVICE)}get apiService(){return this._container.get(N.b.API_SERVICE)}get keyValueStore(){return this._container.get(N.b.KEY_VALUE_STORE)}get profileService(){return this._container.get(N.b.PROFILE_SERVICE)}get groupService(){return this._container.get(N.b.GROUP_SERVICE)}get groupServiceDeprecated(){return this._container.get(N.b.GROUP_SERVICE_DEPRECATED)}get contentService(){return this._container.get(N.b.CONTENT_SERVICE)}get contentFeedbackService(){return this._container.get(N.b.CONTENT_FEEDBACK_SERVICE)}get courseService(){return this._container.get(N.b.COURSE_SERVICE)}get formService(){return this._container.get(N.b.FORM_SERVICE)}get frameworkService(){return this._container.get(N.b.FRAMEWORK_SERVICE)}get frameworkUtilService(){return this._container.get(N.b.FRAMEWORK_UTIL_SERVICE)}get sharedPreferences(){return this._container.get(N.b.SHARED_PREFERENCES)}get systemSettingsService(){return this._container.get(N.b.SYSTEM_SETTINGS_SERVICE)}get eventsBusService(){return this._container.get(N.b.EVENTS_BUS_SERVICE)}get summarizerService(){return this._container.get(N.b.SUMMARIZER_SERVICE)}get downloadService(){return this._container.get(N.b.DOWNLOAD_SERVICE)}get playerService(){return this._container.get(N.b.PLAYER_SERVICE)}get deviceInfo(){return this._container.get(N.b.DEVICE_INFO)}get storageService(){return this._container.get(N.b.STORAGE_SERVICE)}get notificationService(){return this._container.get(N.b.NOTIFICATION_SERVICE)}get errorLoggerService(){return this._container.get(N.b.ERROR_LOGGER_SERVICE)}get networkInfoService(){return this._container.get(N.b.NETWORKINFO_SERVICE)}get searchHistoryService(){return this._container.get(N.b.SEARCH_HISTORY_SERVICE)}get codePushExperimentService(){return this._container.get(N.b.CODEPUSH_EXPERIMENT_SERVICE)}get faqService(){return this._container.get(N.b.FAQ_SERVICE)}get deviceRegisterService(){return this._container.get(N.b.DEVICE_REGISTER_SERVICE)}get archiveService(){return this._container.get(N.b.ARCHIVE_SERVICE)}get networkQueueService(){return this._container.get(N.b.NETWORK_QUEUE)}get discussionService(){return this._container.get(N.b.DISCUSSION_SERVICE)}get segmentationService(){return this._container.get(N.b.SEGMENTATION_SERVICE)}get debuggingService(){return this._container.get(N.b.DEBUGGING_SERVICE)}get notificationServiceV2(){return this._container.get(N.b.NOTIFICATION_SERVICE_V2)}get certificateService(){return this._container.get(N.b.CERTIFICATE_SERVICE)}init(e){return ss(this,void 0,void 0,(function*(){switch(this._container=new T.Container,this._container.bind(N.b.CONTAINER).toConstantValue(this._container),this._container.bind(N.b.DB_VERSION).toConstantValue(31),this._container.bind(N.b.DB_MIGRATION_LIST).toConstantValue([new jn,new xn,new Bn,new $n,new Nr,new Yn,new Vi,new Ji,new Zi,()=>new Co(e,this._container.get(N.b.NETWORK_QUEUE)),new Go,new ns,new is,new Hn]),e.platform){case"cordova":this._container.bind(N.b.SHARED_PREFERENCES).to(Rn).inSingletonScope();break;case"web":this._container.bind(N.b.SHARED_PREFERENCES).to(In).inSingletonScope();break;default:throw new Error("FATAL_ERROR: Invalid platform")}this._container.bind(N.b.DB_SERVICE).to(R).inSingletonScope(),this._container.bind(N.b.FILE_SERVICE).to(wn).inSingletonScope(),this._container.bind(N.b.SDK_CONFIG).toConstantValue(e),this._container.bind(N.b.DEVICE_INFO).to(Zn).inSingletonScope(),this._container.bind(N.b.EVENTS_BUS_SERVICE).to(cr).inSingletonScope(),this._container.bind(N.b.APP_INFO).to(gr).inSingletonScope(),this._container.bind(N.b.API_SERVICE).to(o.ApiServiceImpl).inSingletonScope(),this._container.bind(N.b.AUTH_SERVICE).to(be).inSingletonScope(),this._container.bind(N.b.KEY_VALUE_STORE).to(en).inSingletonScope(),this._container.bind(N.b.SYSTEM_SETTINGS_SERVICE).to(Kn.SystemSettingsServiceImpl).inSingletonScope(),this._container.bind(N.b.FRAMEWORK_SERVICE).to(ve.FrameworkServiceImpl).inSingletonScope(),this._container.bind(N.b.PROFILE_SERVICE).to(te.ProfileServiceImpl).inSingletonScope(),this._container.bind(N.b.GROUP_SERVICE).to(Po).inSingletonScope(),this._container.bind(N.b.GROUP_SERVICE_DEPRECATED).to(Bo).inSingletonScope(),this._container.bind(N.b.ERROR_LOGGER_SERVICE).to(ji).inSingletonScope(),this._container.bind(N.b.ZIP_SERVICE).to(Wn).inSingletonScope(),this._container.bind(N.b.TELEMETRY_SERVICE).to(le).inSingletonScope(),this._container.bind(N.b.CONTENT_FEEDBACK_SERVICE).to(rr).inSingletonScope(),this._container.bind(N.b.FORM_SERVICE).to(cn).inSingletonScope(),this._container.bind(N.b.PAGE_ASSEMBLE_SERVICE).to(yn).inSingletonScope(),this._container.bind(N.b.FRAMEWORK_UTIL_SERVICE).to(ve.FrameworkUtilServiceImpl).inSingletonScope(),this._container.bind(N.b.DOWNLOAD_SERVICE).to(Sr).inSingletonScope(),this._container.bind(N.b.CONTENT_SERVICE).to(Xt).inSingletonScope(),this._container.bind(N.b.COURSE_SERVICE).to(Oe.CourseServiceImpl).inSingletonScope(),this._container.bind(N.b.SUMMARIZER_SERVICE).to(dr.SummarizerServiceImpl).inSingletonScope(),this._container.bind(N.b.PLAYER_SERVICE).to(Ar.PlayerServiceImpl).inSingletonScope(),this._container.bind(N.b.CACHED_ITEM_STORE).to(En).inSingletonScope(),this._container.bind(N.b.TELEMETRY_DECORATOR).to(F).inSingletonScope(),this._container.bind(N.b.STORAGE_SERVICE).to(Ei).inSingletonScope(),this._container.bind(N.b.NOTIFICATION_SERVICE).to(Ni).inSingletonScope(),this._container.bind(N.b.NETWORKINFO_SERVICE).to(ki).inSingletonScope(),this._container.bind(N.b.SEARCH_HISTORY_SERVICE).to(Wi).inSingletonScope(),this._container.bind(N.b.CODEPUSH_EXPERIMENT_SERVICE).to(eo.CodePUshExperimentServiceImpl).inSingletonScope(),this._container.bind(N.b.DEVICE_REGISTER_SERVICE).to(no.DeviceRegisterServiceImpl).inSingletonScope(),this._container.bind(N.b.FAQ_SERVICE).to(to.FaqServiceImpl).inSingletonScope(),this._container.bind(N.b.ARCHIVE_SERVICE).to(bo).inSingletonScope(),this._container.bind(N.b.NETWORK_QUEUE).to(yo).inSingletonScope(),this._container.bind(N.b.DISCUSSION_SERVICE).to(Ko).inSingletonScope(),this._container.bind(N.b.SEGMENTATION_SERVICE).to(zo.SegmentationServiceImpl).inSingletonScope(),this._container.bind(N.b.DEBUGGING_SERVICE).to(Wo.DebuggingServiceImpl).inSingletonScope(),this._container.bind(N.b.NOTIFICATION_SERVICE_V2).to(Zo).inSingletonScope(),this._container.bind(N.b.CERTIFICATE_SERVICE).to(os.CertificateServiceImpl).inSingletonScope();const t=this.sharedPreferences;yield he.CsModule.instance.init({core:{httpAdapter:"web"===e.platform?"HttpClientBrowserAdapter":"HttpClientCordovaAdapter",global:{channelId:e.apiConfig.api_authentication.channelId,producerId:e.apiConfig.api_authentication.producerId,deviceId:Ut(window.device.uuid).toString()},api:{host:e.apiConfig.host,authentication:{}}},services:{contentServiceConfig:{hierarchyApiPath:"/api/questionset/v2",questionListApiPath:"/api/question/v2"},courseServiceConfig:{apiPath:"/api/course/v1",certRegistrationApiPath:"/api/certreg/v2/certs"},groupServiceConfig:{apiPath:"/api/group/v1",dataApiPath:"/api/data/v1/group",updateGroupGuidelinesApiPath:"/api/group/membership/v1"},userServiceConfig:{apiPath:"/api/user/v2"},formServiceConfig:{apiPath:"/api/data/v1/form"},discussionServiceConfig:{apiPath:"/discussion"},notificationServiceConfig:{apiPath:"/api/notification/v1/feed"},certificateServiceConfig:{apiPath:e.certificateServiceConfig.apiPath,apiPathLegacy:e.certificateServiceConfig.apiPathLegacy,rcApiPath:e.certificateServiceConfig.rcApiPath},frameworkServiceConfig:{apiPath:"/api/framework/v1"}}},(()=>{this._container.rebind(N.a.HTTP_SERVICE).toConstantValue(he.CsModule.instance.httpService),this._container.rebind(N.a.GROUP_SERVICE).toConstantValue(he.CsModule.instance.groupService),this._container.rebind(N.a.COURSE_SERVICE).toConstantValue(he.CsModule.instance.courseService),this._container.rebind(N.a.USER_SERVICE).toConstantValue(he.CsModule.instance.userService),this._container.rebind(N.a.DISCUSSION_SERVICE).toConstantValue(he.CsModule.instance.discussionService),this._container.rebind(N.a.CONTENT_SERVICE).toConstantValue(he.CsModule.instance.contentService),this._container.rebind(N.a.NOTIFICATION_SERVICE_V2).toConstantValue(he.CsModule.instance.notificationService),this._container.rebind(N.a.CERTIFICATE_SERVICE).toConstantValue(he.CsModule.instance.certificateService),this._container.rebind(N.a.FRAMEWORK_SERVICE).toConstantValue(he.CsModule.instance.frameworkService)}).bind(this),new class{setItem(e,n){return t.putString(e,n).toPromise()}getItem(e){return t.getString(e).toPromise()}}),this._container.bind(N.a.HTTP_SERVICE).toConstantValue(he.CsModule.instance.httpService),this._container.bind(N.a.GROUP_SERVICE).toConstantValue(he.CsModule.instance.groupService),this._container.bind(N.a.COURSE_SERVICE).toConstantValue(he.CsModule.instance.courseService),this._container.bind(N.a.USER_SERVICE).toConstantValue(he.CsModule.instance.userService),this._container.bind(N.a.DISCUSSION_SERVICE).toConstantValue(he.CsModule.instance.discussionService),this._container.bind(N.a.CONTENT_SERVICE).toConstantValue(he.CsModule.instance.contentService),this._container.bind(N.a.NOTIFICATION_SERVICE_V2).toConstantValue(he.CsModule.instance.notificationService),this._container.bind(N.a.CERTIFICATE_SERVICE).toConstantValue(he.CsModule.instance.certificateService),this._container.bind(N.a.FRAMEWORK_SERVICE).toConstantValue(he.CsModule.instance.frameworkService),yield this.dbService.init(),yield this.appInfo.init(),yield this.preInit().toPromise(),this._isInitialised=!0,this.postInit().subscribe()}))}updateTelemetryConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.telemetryConfig[t]=e[t])}updateDeviceRegisterConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.deviceRegisterConfig[t]=e[t],"fcmToken"===t&&this.telemetryService.resetDeviceRegisterTTL())}updateContentServiceConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.contentServiceConfig[t]=e[t])}updatePageServiceConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.pageServiceConfig[t]=e[t])}preInit(){return this.telemetryService.preInit().pipe(Object(W.concatMap)(()=>this.frameworkService.preInit().pipe(Object(W.concatMap)(()=>this.profileService.preInit()))))}postInit(){return Object(y.combineLatest)([this.apiService.onInit(),this.authService.onInit(),this.summarizerService.onInit(),this.errorLoggerService.onInit(),this.eventsBusService.onInit(),this.downloadService.onInit(),this.contentService.onInit(),this.storageService.onInit(),this.telemetryService.onInit(),this.notificationService.onInit()])}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r,i=n(1);!function(e){e.TABLE_NAME="search_history",e._ID="_id",e.COLUMN_NAME_USER_ID="uid",e.COLUMN_NAME_QUERY="query",e.COLUMN_NAME_TIME_STAMP="time_stamp",e.COLUMN_NAME_NAMESPACE="namespace",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_USER_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_QUERY+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_TIME_STAMP+i.DbConstants.SPACE+i.DbConstants.INT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_NAMESPACE+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+"UNIQUE ("+e.COLUMN_NAME_USER_ID+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_QUERY+") ON CONFLICT REPLACE )",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r,i=n(1);!function(e){e.TABLE_NAME="course_assessment",e._ID="_id",e.COLUMN_NAME_ASSESSMENT_EVENT="assessment_event",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_USER_ID="user_id",e.COLUMN_NAME_CONTENT_ID="content_id",e.COLUMN_NAME_COURSE_ID="course_id",e.COLUMN_NAME_BATCH_ID="batch_id",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS"+i.DbConstants.SPACE+e.TABLE_NAME+i.DbConstants.SPACE+"("+e._ID+i.DbConstants.SPACE+"INTEGER PRIMARY KEY,"+e.COLUMN_NAME_ASSESSMENT_EVENT+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+","+e.COLUMN_NAME_CREATED_AT+i.DbConstants.SPACE+i.DbConstants.INT_TYPE+","+e.COLUMN_NAME_USER_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+","+e.COLUMN_NAME_CONTENT_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+","+e.COLUMN_NAME_COURSE_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+","+e.COLUMN_NAME_BATCH_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+")",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));var r,i=n(1);!function(e){e.TABLE_NAME="player_data",e._ID="_id",e.COLUMN_NAME_USER_ID="user_id",e.COLUMN_PARENT_IDENTIFIER="parent_identifier",e.COLUMN_IDENTIFIER="identifier",e.COLUMN_PLAYER_CONFIG="player_config",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_USER_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_PARENT_IDENTIFIER+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_IDENTIFIER+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_PLAYER_CONFIG+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+")",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME,e.getAlterEntryForPlayerConfig=()=>`ALTER TABLE ${e.TABLE_NAME} ADD COLUMN ${e.COLUMN_PLAYER_CONFIG} TEXT DEFAULT ''`}(r||(r={}));class o{static mapPlayerDbEntryToPlayer(e){return{userId:e[r.COLUMN_NAME_USER_ID],parentId:e[r.COLUMN_PARENT_IDENTIFIER],contentId:e[r.COLUMN_IDENTIFIER],saveState:e[r.COLUMN_PLAYER_CONFIG]}}static mapPlayerStateToPlayerDbEntry(e,t,n,i){return{[r.COLUMN_NAME_USER_ID]:e,[r.COLUMN_PARENT_IDENTIFIER]:t,[r.COLUMN_IDENTIFIER]:n,[r.COLUMN_PLAYER_CONFIG]:i}}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(298);class i{static generateUniqueId(){return r()}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{static toFixed(e){return Number(e.toFixed(2))}static parseInt(e){return e?parseInt(e,10):0}static round(e){return Number(Math.round(parseFloat(e+"e4"))+"e-4")}}},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i.a})),n.d(t,"c",(function(){return o})),n.d(t,"d",(function(){return s.a})),function(e){e.CONTENT="content",e.PROFILE="profile",e.TELEMETRY="telemetry"}(r||(r={}));var i=n(70);class o extends i.a{constructor(e){super(e,"INVALID_REQUEST"),Object.setPrototypeOf(this,o.prototype)}}var s=n(90)},function(e,t){e.exports=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(25);class i{static get log(){return r.a.instance.telemetryService}}},function(e,t,n){"use strict";n.r(t);var r=n(171);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(290);n.d(t,"CourseServiceImpl",(function(){return o.a}));var s=n(178);for(var i in s)["default","CourseServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(179);for(var i in a)["default","CourseServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(180);for(var i in c)["default","CourseServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(i);var u=n(181);for(var i in u)["default","CourseServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(i);var d=n(182);n.d(t,"UpdateContentStateTarget",(function(){return d.c})),n.d(t,"CourseEnrollmentType",(function(){return d.b})),n.d(t,"CourseBatchStatus",(function(){return d.a}));var l=n(183);for(var i in l)["default","CourseServiceImpl","UpdateContentStateTarget","CourseEnrollmentType","CourseBatchStatus"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return l[e]}))}(i);var f=n(184);n.d(t,"CertificateAlreadyDownloaded",(function(){return f.a}));var h=n(185);for(var i in h)["default","CourseServiceImpl","UpdateContentStateTarget","CourseEnrollmentType","CourseBatchStatus","CertificateAlreadyDownloaded"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return h[e]}))}(i);var E=n(186);for(var i in E)["default","CourseServiceImpl","UpdateContentStateTarget","CourseEnrollmentType","CourseBatchStatus","CertificateAlreadyDownloaded"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return E[e]}))}(i)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NON_CUSTOM_TAG_KEYS=t.POST_CONSTRUCT=t.DESIGN_PARAM_TYPES=t.PARAM_TYPES=t.TAGGED_PROP=t.TAGGED=t.MULTI_INJECT_TAG=t.INJECT_TAG=t.OPTIONAL_TAG=t.UNMANAGED_TAG=t.NAME_TAG=t.NAMED_TAG=void 0,t.NAMED_TAG="named",t.NAME_TAG="name",t.UNMANAGED_TAG="unmanaged",t.OPTIONAL_TAG="optional",t.INJECT_TAG="inject",t.MULTI_INJECT_TAG="multi_inject",t.TAGGED="inversify:tagged",t.TAGGED_PROP="inversify:tagged_props",t.PARAM_TYPES="inversify:paramtypes",t.DESIGN_PARAM_TYPES="design:paramtypes",t.POST_CONSTRUCT="post_construct",t.NON_CUSTOM_TAG_KEYS=[t.INJECT_TAG,t.MULTI_INJECT_TAG,t.NAME_TAG,t.UNMANAGED_TAG,t.NAMED_TAG,t.OPTIONAL_TAG]},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{static decodeJWT(e){return new Promise((t,n)=>sbutility.decodeJWTToken(e,e=>{t(e)},e=>{n(e)}))}static createJWTToken(e,t){return new Promise((n,r)=>{sbutility.getJWTToken(e,t,e=>{n(e)},e=>{r(e)})})}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{static equals(e,t){const n=e=>{let t=0;for(const n in e)e.hasOwnProperty(n)&&t++;return t},r=(e,t)=>{if(typeof e!=typeof t)return!1;if("function"==typeof e)return e.toString()===t.toString();if(e instanceof Object&&t instanceof Object){if(n(e)!==n(t))return!1;let i=!0;for(const n in e)if(i=r(e[n],t[n]),!i)return!1;return!0}return e===t};return r(e,t)}static getPropDiff(e,t){return Object.keys(e).reduce((n,i)=>(r.equals(e[i],t[i])||n.push(i),n),[])}static getTruthyProps(e){return Object.keys(e).filter(t=>!!e[t])}static toOrderedString(e){return JSON.stringify(Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{}))}static withDeeplyOrderedKeys(e){return Object.keys(e).sort().reduce((t,n)=>("object"!=typeof e[n]||Array.isArray(e[n])?t[n]=e[n]:t[n]=r.withDeeplyOrderedKeys(e[n]),t),{})}}},function(e,t,n){e.exports=function(){"use strict";var e=6e4,t=36e5,n="millisecond",r="second",i="minute",o="hour",s="day",a="week",c="month",u="quarter",d="year",l="date",f="Invalid Date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,E=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},S={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+_(r,2,"0")+":"+_(i,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,c),o=n-i<0,s=t.clone().add(r+(o?-1:1),c);return+(-(r+(n-i)/(o?i-s:s-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:d,w:a,d:s,D:l,h:o,m:i,s:r,ms:n,Q:u}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},b="en",O={};O[b]=p;var v="$isDayjsObject",C=function(e){return e instanceof N||!(!e||!e[v])},g=function e(t,n,r){var i;if(!t)return b;if("string"==typeof t){var o=t.toLowerCase();O[o]&&(i=o),n&&(O[o]=n,i=o);var s=t.split("-");if(!i&&s.length>1)return e(s[0])}else{var a=t.name;O[a]=t,i=a}return!r&&i&&(b=i),i||!r&&b},A=function(e,t){if(C(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new N(n)},T=S;T.l=g,T.i=C,T.w=function(e,t){return A(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var N=function(){function p(e){this.$L=g(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[v]=!0}var _=p.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(h);if(r){var i=r[2]-1||0,o=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return!(this.$d.toString()===f)},_.isSame=function(e,t){var n=A(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return A(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<A(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,u=!!T.u(t)||t,f=T.p(e),h=function(e,t){var r=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return u?r:r.endOf(s)},E=function(e,t){return T.w(n.toDate()[e].apply(n.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},p=this.$W,_=this.$M,S=this.$D,b="set"+(this.$u?"UTC":"");switch(f){case d:return u?h(1,0):h(31,11);case c:return u?h(1,_):h(0,_+1);case a:var O=this.$locale().weekStart||0,v=(p<O?p+7:p)-O;return h(u?S-v:S+(6-v),_);case s:case l:return E(b+"Hours",0);case o:return E(b+"Minutes",1);case i:return E(b+"Seconds",2);case r:return E(b+"Milliseconds",3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var a,u=T.p(e),f="set"+(this.$u?"UTC":""),h=(a={},a[s]=f+"Date",a[l]=f+"Date",a[c]=f+"Month",a[d]=f+"FullYear",a[o]=f+"Hours",a[i]=f+"Minutes",a[r]=f+"Seconds",a[n]=f+"Milliseconds",a)[u],E=u===s?this.$D+(t-this.$W):t;if(u===c||u===d){var p=this.clone().set(l,1);p.$d[h](E),p.init(),this.$d=p.set(l,Math.min(this.$D,p.daysInMonth())).$d}else h&&this.$d[h](E);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(n,u){var l,f=this;n=Number(n);var h=T.p(u),E=function(e){var t=A(f);return T.w(t.date(t.date()+Math.round(e*n)),f)};if(h===c)return this.set(c,this.$M+n);if(h===d)return this.set(d,this.$y+n);if(h===s)return E(1);if(h===a)return E(7);var p=(l={},l[i]=e,l[o]=t,l[r]=1e3,l)[h]||1,_=this.$d.getTime()+n*p;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||f;var r=e||"YYYY-MM-DDTHH:mm:ssZ",i=T.z(this),o=this.$H,s=this.$m,a=this.$M,c=n.weekdays,u=n.months,d=n.meridiem,l=function(e,n,i,o){return e&&(e[n]||e(t,r))||i[n].slice(0,o)},h=function(e){return T.s(o%12||12,e,"0")},p=d||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(E,(function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return T.s(t.$y,4,"0");case"M":return a+1;case"MM":return T.s(a+1,2,"0");case"MMM":return l(n.monthsShort,a,u,3);case"MMMM":return l(u,a);case"D":return t.$D;case"DD":return T.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return l(n.weekdaysMin,t.$W,c,2);case"ddd":return l(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(o);case"HH":return T.s(o,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return p(o,s,!0);case"A":return p(o,s,!1);case"m":return String(s);case"mm":return T.s(s,2,"0");case"s":return String(t.$s);case"ss":return T.s(t.$s,2,"0");case"SSS":return T.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(n,l,f){var h,E=this,p=T.p(l),_=A(n),S=(_.utcOffset()-this.utcOffset())*e,b=this-_,O=function(){return T.m(E,_)};switch(p){case d:h=O()/12;break;case c:h=O();break;case u:h=O()/3;break;case a:h=(b-S)/6048e5;break;case s:h=(b-S)/864e5;break;case o:h=b/t;break;case i:h=b/e;break;case r:h=b/1e3;break;default:h=b}return f?h:T.a(h)},_.daysInMonth=function(){return this.endOf(c).$D},_.$locale=function(){return O[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=g(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},p}(),y=N.prototype;return A.prototype=y,[["$ms",n],["$s",r],["$m",i],["$H",o],["$W",s],["$M",c],["$y",d],["$D",l]].forEach((function(e){y[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),A.extend=function(e,t){return e.$i||(e(t,N,A),e.$i=!0),A},A.locale=g,A.isDayjs=C,A.unix=function(e){return A(1e3*e)},A.en=O[b],A.Ls=O,A.p={},A}()},function(e,t){e.exports=i},function(e,t,n){"use strict";n.r(t);var r=n(172);n.d(t,"DownloadEventType",(function(){return r.a}));var i=n(173);for(var o in i)["default","DownloadEventType"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var s=n(174);n.d(t,"DownloadStatus",(function(){return s.a}));var a=n(175);for(var o in a)["default","DownloadEventType","DownloadStatus"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var c=n(176);for(var o in c)["default","DownloadEventType","DownloadStatus"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(o)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.STACK_OVERFLOW=t.CIRCULAR_DEPENDENCY_IN_FACTORY=t.POST_CONSTRUCT_ERROR=t.MULTIPLE_POST_CONSTRUCT_METHODS=t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK=t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE=t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE=t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT=t.ARGUMENTS_LENGTH_MISMATCH=t.INVALID_DECORATOR_OPERATION=t.INVALID_TO_SELF_VALUE=t.INVALID_FUNCTION_BINDING=t.INVALID_MIDDLEWARE_RETURN=t.NO_MORE_SNAPSHOTS_AVAILABLE=t.INVALID_BINDING_TYPE=t.NOT_IMPLEMENTED=t.CIRCULAR_DEPENDENCY=t.UNDEFINED_INJECT_ANNOTATION=t.MISSING_INJECT_ANNOTATION=t.MISSING_INJECTABLE_ANNOTATION=t.NOT_REGISTERED=t.CANNOT_UNBIND=t.AMBIGUOUS_MATCH=t.KEY_NOT_FOUND=t.NULL_ARGUMENT=t.DUPLICATED_METADATA=t.DUPLICATED_INJECTABLE_DECORATOR=void 0,t.DUPLICATED_INJECTABLE_DECORATOR="Cannot apply @injectable decorator multiple times.",t.DUPLICATED_METADATA="Metadata key was used more than once in a parameter:",t.NULL_ARGUMENT="NULL argument",t.KEY_NOT_FOUND="Key Not Found",t.AMBIGUOUS_MATCH="Ambiguous match found for serviceIdentifier:",t.CANNOT_UNBIND="Could not unbind serviceIdentifier:",t.NOT_REGISTERED="No matching bindings found for serviceIdentifier:",t.MISSING_INJECTABLE_ANNOTATION="Missing required @injectable annotation in:",t.MISSING_INJECT_ANNOTATION="Missing required @inject or @multiInject annotation in:";t.UNDEFINED_INJECT_ANNOTATION=function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifer to overcome this limitation."},t.CIRCULAR_DEPENDENCY="Circular dependency found:",t.NOT_IMPLEMENTED="Sorry, this feature is not fully implemented yet.",t.INVALID_BINDING_TYPE="Invalid binding type:",t.NO_MORE_SNAPSHOTS_AVAILABLE="No snapshot available to restore.",t.INVALID_MIDDLEWARE_RETURN="Invalid return type in middleware. Middleware must return!",t.INVALID_FUNCTION_BINDING="Value provided to function binding must be a function!",t.INVALID_TO_SELF_VALUE="The toSelf function can only be applied when a constructor is used as service identifier",t.INVALID_DECORATOR_OPERATION="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.";t.ARGUMENTS_LENGTH_MISMATCH=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."},t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT="Invalid Container constructor argument. Container options must be an object.",t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE="Invalid Container option. Default scope must be a string ('singleton' or 'transient').",t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE="Invalid Container option. Auto bind injectable must be a boolean",t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK="Invalid Container option. Skip base check must be a boolean",t.MULTIPLE_POST_CONSTRUCT_METHODS="Cannot apply @postConstruct decorator multiple times in the same class";t.POST_CONSTRUCT_ERROR=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"@postConstruct error in class "+e[0]+": "+e[1]};t.CIRCULAR_DEPENDENCY_IN_FACTORY=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"It looks like there is a circular dependency in one of the '"+e[0]+"' bindings. Please investigate bindings withservice identifier '"+e[1]+"'."},t.STACK_OVERFLOW="Maximum call stack size exceeded"},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(2),i=n(8),o=n(63),s=n(39),a=n(62);class c{static mapContentDataToContentDBEntry(e,t){let n,o,s;return t?s=JSON.stringify(e):(n=e.lastUpdatedOn,o=JSON.stringify(e)),{[r.b.COLUMN_NAME_IDENTIFIER]:e.identifier,[r.b.COLUMN_NAME_SERVER_DATA]:o,[r.b.COLUMN_NAME_SERVER_LAST_UPDATED_ON]:n,[r.b.COLUMN_NAME_MANIFEST_VERSION]:t,[r.b.COLUMN_NAME_LOCAL_DATA]:s,[r.b.COLUMN_NAME_MIME_TYPE]:e.mimeType,[r.b.COLUMN_NAME_CONTENT_TYPE]:i.a.readContentType(e),[r.b.COLUMN_NAME_VISIBILITY]:i.a.readVisibility(e),[r.b.COLUMN_NAME_AUDIENCE]:i.a.readAudience(e),[r.b.COLUMN_NAME_PRAGMA]:i.a.readPragma(e),[r.b.COLUMN_NAME_PRIMARY_CATEGORY]:i.a.readPrimaryCategory(e)}}static mapServerResponseToContent(e,t){let n,r,c;t?c=e:(n=e.lastUpdatedOn,r=e),!e.primaryCategory&&e.contentType&&e.mimeType&&(e.primaryCategory=a.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType));const u=e.primaryCategory?e.primaryCategory:e.contentType;return!e.trackable&&u&&u.toLowerCase()===o.CsContentType.COURSE.toLowerCase()&&(e.trackable={enabled:s.TrackingEnabled.YES}),e.trackable||(e.trackable={enabled:s.TrackingEnabled.NO}),{identifier:e.identifier,name:e.name,contentData:e,isUpdateAvailable:i.a.isUpdateAvailable(r,c),mimeType:e.mimeType,basePath:"",contentType:i.a.readContentType(e),primaryCategory:i.a.readPrimaryCategory(e),isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0}}static mapContentDBEntryToContent(e,t){let n;const c=e[r.b.COLUMN_NAME_SERVER_DATA],u=e[r.b.COLUMN_NAME_LOCAL_DATA],d=c&&JSON.parse(c);let l,f=u&&JSON.parse(u),h=e[r.b.COLUMN_NAME_IDENTIFIER],E=e[r.b.COLUMN_NAME_MIME_TYPE],p=e[r.b.COLUMN_NAME_VISIBILITY],_=e[r.b.COLUMN_NAME_CONTENT_TYPE],S=e[r.b.COLUMN_NAME_PRIMARY_CATEGORY],b=0;e.hasOwnProperty(r.a.COLUMN_NAME_EPOCH_TIMESTAMP)&&(b=e[r.a.COLUMN_NAME_EPOCH_TIMESTAMP]),e.hasOwnProperty(r.d.COLUMN_NAME_DATA)&&(f||(f=JSON.parse(e[r.d.COLUMN_NAME_DATA])),f&&(h=f.identifier,E=f.mimeType,l=f.resourceType,p=i.a.readVisibility(f),_=i.a.readContentType(f),S=i.a.readPrimaryCategory(f))),f&&(n=f),d&&(f&&i.a.isAvailableLocally(e[r.b.COLUMN_NAME_CONTENT_STATE])?(f.streamingUrl||(f.streamingUrl=d.streamingUrl),f.previewUrl||(f.previewUrl=d.previewUrl),d.me_totalRatingsCount&&(f.me_totalRatingsCount=d.me_totalRatingsCount),d.me_averageRating&&(f.me_averageRating=d.me_averageRating),f.size||(f.size=d.size),d.licenseDetails&&(f.licenseDetails=d.licenseDetails),d.forumId&&(f.forumId=d.forumId)):n=d);let O=0;const v=e[r.b.COLUMN_NAME_LOCAL_LAST_UPDATED_ON];v&&(O=new Date(v).getTime());const C=Number(e[r.b.COLUMN_NAME_SIZE_ON_DEVICE]),g=C||Number(d?d.size:0);!n.trackable&&S&&S.toLowerCase()===o.CsContentType.COURSE.toLowerCase()&&(n.trackable={enabled:s.TrackingEnabled.YES}),n.trackable||(n.trackable={enabled:s.TrackingEnabled.NO}),l=n.resourceType,!n.primaryCategory&&_&&(n.primaryCategory=a.CsPrimaryCategoryMapper.getPrimaryCategory(_.toLowerCase(),E,l));const A=e[r.b.COLUMN_NAME_PATH]||"";return"string"==typeof n.originData&&(n.originData=i.a.getParseErrorObject(n.originData)),n.trackable&&"string"==typeof n.trackable&&(n.trackable=JSON.parse(n.trackable)),{identifier:h,name:n.name,contentData:n,isUpdateAvailable:i.a.isUpdateAvailable(d,f),mimeType:E,basePath:t?"/_app_file_"+A:A,primaryCategory:S,contentType:_,isAvailableLocally:i.a.isAvailableLocally(e[r.b.COLUMN_NAME_CONTENT_STATE]),referenceCount:Number(e[r.b.COLUMN_NAME_REF_COUNT])||0,sizeOnDevice:g,lastUsedTime:b||0,lastUpdatedTime:O}}}},function(e,t,n){"use strict";n.r(t);var r=n(154);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(155);n.d(t,"NetworkStatus",(function(){return o.a}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(51),i=n(215),o=n(354),s=function(){function e(e){this.dictionary=new o.default(e)}return e.prototype.contains=function(e){return this.dictionary.containsKey(e)},e.prototype.add=function(e){return!this.contains(e)&&!r.isUndefined(e)&&(this.dictionary.setValue(e,e),!0)},e.prototype.intersection=function(e){var t=this;this.forEach((function(n){return e.contains(n)||t.remove(n),!0}))},e.prototype.union=function(e){var t=this;e.forEach((function(e){return t.add(e),!0}))},e.prototype.difference=function(e){var t=this;e.forEach((function(e){return t.remove(e),!0}))},e.prototype.isSubsetOf=function(e){if(this.size()>e.size())return!1;var t=!0;return this.forEach((function(n){return!!e.contains(n)||(t=!1,!1)})),t},e.prototype.remove=function(e){return!!this.contains(e)&&(this.dictionary.remove(e),!0)},e.prototype.forEach=function(e){this.dictionary.forEach((function(t,n){return e(n)}))},e.prototype.toArray=function(){return this.dictionary.values()},e.prototype.isEmpty=function(){return this.dictionary.isEmpty()},e.prototype.size=function(){return this.dictionary.size()},e.prototype.clear=function(){this.dictionary.clear()},e.prototype.toString=function(){return i.toString(this.toArray())},e}();t.default=s},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{static dirPathFromFilePath(e){return e.substring(0,e.lastIndexOf("/"))}static fileNameFromFilePath(e){return e.substring(e.lastIndexOf("/")+1)}static getAssetPath(){return"ios"===window.device.platform.toLowerCase()?cordova.file.applicationDirectory+"www/assets":r.ASSETS_PATH}}r.ASSETS_PATH="file:///android_asset/www/assets"},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"SIGN_IN_ERROR"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var r=n(35),i=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return this.key===r.NAMED_TAG?"named: "+this.value.toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+this.value+" }"},e}();t.Metadata=i},function(e,t,n){"use strict";n.r(t);var r=n(139);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(140);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(141);for(var i in s)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(46);n.d(t,"SignInError",(function(){return a.a}));var c=n(142);n.d(t,"AuthEventType",(function(){return c.a}));var u=n(143);for(var i in u)["default","SignInError","AuthEventType"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(i);var d=n(144);n.d(t,"WebviewLoginSessionProvider",(function(){return d.a}));var l=n(254);n.d(t,"WebviewManualMergeSessionProvider",(function(){return l.a}));var f=n(71);n.d(t,"WebviewAutoMergeSessionProvider",(function(){return f.a}));var h=n(49);n.d(t,"WebviewRunnerError",(function(){return h.a}));var E=n(255);n.d(t,"InterruptError",(function(){return E.a}));var p=n(66);n.d(t,"NoInappbrowserSessionAssertionFailError",(function(){return p.a}));var _=n(84);n.d(t,"ParamNotCapturedError",(function(){return _.a}));var S=n(256);n.d(t,"NativeGoogleSessionProvider",(function(){return S.a}));var b=n(257);n.d(t,"NativeAppleSessionProvider",(function(){return b.a}));var O=n(258);n.d(t,"WebviewStateSessionProvider",(function(){return O.a}));var v=n(259);for(var i in v)["default","SignInError","AuthEventType","WebviewLoginSessionProvider","WebviewManualMergeSessionProvider","WebviewAutoMergeSessionProvider","WebviewRunnerError","InterruptError","NoInappbrowserSessionAssertionFailError","ParamNotCapturedError","NativeGoogleSessionProvider","NativeAppleSessionProvider","WebviewStateSessionProvider"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return v[e]}))}(i);var C=n(260);for(var i in C)["default","SignInError","AuthEventType","WebviewLoginSessionProvider","WebviewManualMergeSessionProvider","WebviewAutoMergeSessionProvider","WebviewRunnerError","InterruptError","NoInappbrowserSessionAssertionFailError","ParamNotCapturedError","NativeGoogleSessionProvider","NativeAppleSessionProvider","WebviewStateSessionProvider"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return C[e]}))}(i);var g=n(261);n.d(t,"NativeKeycloakSessionProvider",(function(){return g.a}));var A=n(262);n.d(t,"NativeCustomBrowserSessionProvider",(function(){return A.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e,t){super(e,t),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(7),i=n(22),o=n(75),s=n(100);class a{constructor(e){this.config=e}generateNetworkQueueRequest(e,t,n,a,c){let u,d;if(e===i.b.TELEMETRY){const e=t.split("").map(e=>e.charCodeAt(0));u=new Uint8Array(e),d=(new r.Request.Builder).withSerializer(r.HttpSerializer.RAW).withHost(this.config.telemetryConfig.host).withType(r.HttpRequestType.POST).withPath(this.config.telemetryConfig.apiPath+o.a.TELEMETRY_ENDPOINT).withHeaders({"Content-Type":"application/json","Content-Encoding":"gzip"}).withBody(u).withBearerToken(!0).build()}else u=t,d=(new r.Request.Builder).withType(r.HttpRequestType.PATCH).withPath(this.config.courseServiceConfig.apiPath+s.a.UPDATE_CONTENT_STATE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody(u).build();return{msgId:n,data:e===i.b.TELEMETRY?t:JSON.stringify(t),networkRequest:d,priority:e===i.b.TELEMETRY?2:1,itemCount:a,type:e,config:JSON.stringify({shouldPublishResult:c}),ts:Date.now()}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty;function i(e){return"function"==typeof e}function o(e){return void 0===e}function s(e){return"[object String]"===Object.prototype.toString.call(e)}t.has=function(e,t){return r.call(e,t)},t.defaultCompare=function(e,t){return e<t?-1:e===t?0:1},t.defaultEquals=function(e,t){return e===t},t.defaultToString=function(e){return null===e?"COLLECTION_NULL":o(e)?"COLLECTION_UNDEFINED":s(e)?"$s"+e:"$o"+e.toString()},t.makeString=function(e,n){if(void 0===n&&(n=","),null===e)return"COLLECTION_NULL";if(o(e))return"COLLECTION_UNDEFINED";if(s(e))return e.toString();var r="{",i=!0;for(var a in e)t.has(e,a)&&(i?i=!1:r+=n,r=r+a+":"+e[a]);return r+"}"},t.isFunction=i,t.isUndefined=o,t.isString=s,t.reverseCompareFunction=function(e){return o(e)||!i(e)?function(e,t){return e<t?1:e===t?0:-1}:function(t,n){return-1*e(t,n)}},t.compareToEquals=function(e){return function(t,n){return 0===e(t,n)}}},function(e,t,n){"use strict";var r=n(332),i=n(351),o=n(106);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r,i=n(1);!function(e){e._ID="_id",e.TABLE_NAME="certificate_public_key",e.COLUMN_NAME_IDENTIFIER="identifier",e.COLUMN_NAME_PUBLIC_KEY="public_key",e.COLUMN_NAME_ALGORITHM="alg",e.COLUMN_NAME_OWNER="owner",e.COLUMN_NAME_EXPIRY_TIME="expiry_time",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY,"+e.COLUMN_NAME_IDENTIFIER+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_PUBLIC_KEY+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_ALGORITHM+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_OWNER+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_EXPIRY_TIME+i.DbConstants.SPACE+i.DbConstants.INT_TYPE+" )",e.deleteTable=()=>"DROP TABLE IF EXISTS "+e.TABLE_NAME}(r||(r={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TargetTypeEnum=t.BindingTypeEnum=t.BindingScopeEnum=void 0;t.BindingScopeEnum={Request:"Request",Singleton:"Singleton",Transient:"Transient"};t.BindingTypeEnum={ConstantValue:"ConstantValue",Constructor:"Constructor",DynamicValue:"DynamicValue",Factory:"Factory",Function:"Function",Instance:"Instance",Invalid:"Invalid",Provider:"Provider"};t.TargetTypeEnum={ClassProperty:"ClassProperty",ConstructorArgument:"ConstructorArgument",Variable:"Variable"}},function(e,t,n){var r,i,o,s,a,c,u,d;e.exports=(d=n(177),i=(r=d).lib,o=i.WordArray,s=i.Hasher,a=r.algo,c=[],u=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var d=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=d<<1|d>>>31}var l=(r<<5|r>>>27)+a+c[u];l+=u<20?1518500249+(i&o|~i&s):u<40?1859775393+(i^o^s):u<60?(i&o|i&s|o&s)-1894007588:(i^o^s)-899497514,a=s,s=o,o=i<<30|i>>>2,i=r,r=l}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=s._createHelper(u),r.HmacSHA1=s._createHmacHelper(u),d.SHA1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagProperty=t.tagParameter=t.decorate=void 0;var r=n(41),i=n(35);function o(e,t,n,i,o){var s={},a="number"==typeof o,c=void 0!==o&&a?o.toString():n;if(a&&void 0!==n)throw new Error(r.INVALID_DECORATOR_OPERATION);Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var u=s[c];if(Array.isArray(u))for(var d=0,l=u;d<l.length;d++){var f=l[d];if(f.key===i.key)throw new Error(r.DUPLICATED_METADATA+" "+f.key.toString())}else u=[];u.push(i),s[c]=u,Reflect.defineMetadata(e,s,t)}function s(e,t){Reflect.decorate(e,t)}function a(e,t){return function(n,r){t(n,r,e)}}t.tagParameter=function(e,t,n,r){o(i.TAGGED,e,t,r,n)},t.tagProperty=function(e,t,n){o(i.TAGGED_PROP,e.constructor,t,n)},t.decorate=function(e,t,n){"number"==typeof n?s([a(n,e)],t):"string"==typeof n?Reflect.decorate([e],t,n):s([e],t)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(52),i=n(3),o=n(66),s=n(84),a=n(0),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(){this.extras={},this.captured={}}static buildUrl(e,t,n){return`${e}${t}?${r.stringify(n)}`}resetInAppBrowserEventListeners(){if(!this.inAppBrowser)throw new o.a("InAppBrowser Session not found when resetInAppBrowserEventListeners()");for(const e in this.inAppBrowser.listeners)this.inAppBrowser.listeners.hasOwnProperty(e)&&(this.inAppBrowser.listeners[e].forEach(t=>{this.inAppBrowser.ref.removeEventListener(e,t)}),this.inAppBrowser.listeners[e].clear())}launchWebview({host:e,path:t,params:n}){return c(this,void 0,void 0,(function*(){this.inAppBrowser={ref:cordova.InAppBrowser.open(u.buildUrl(e,t,n),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes"),listeners:{loadstart:new Set,exit:new Set}};const r=()=>{this.resetInAppBrowserEventListeners(),this.inAppBrowser=void 0};this.inAppBrowser.listeners.exit.add(r),this.inAppBrowser.ref.addEventListener("exit",r)}))}closeWebview(){return c(this,void 0,void 0,(function*(){if(!this.inAppBrowser)throw new o.a("InAppBrowser Session not found");this.inAppBrowser.ref.close()}))}any(...e){return Object(i.race)(...e).pipe(Object(a.take)(1)).toPromise()}all(...e){return Object(i.zip)(...e).pipe(Object(a.take)(1),Object(a.mapTo)(void 0)).toPromise()}launchCustomTab({host:e,path:t,params:n,extraParams:i}){const o=u.buildUrl(e,t,n);return new Promise((e,t)=>{customtabs.isAvailable(()=>{customtabs.launch(o,t=>{this.captured=Object.assign(Object.assign({},this.captured),r.parse(t)),e()},e=>{t(e)})},()=>{customtabs.launchInBrowser(o,i,t=>{this.captured=Object.assign(Object.assign({},this.captured),r.parse(t)),e()},e=>{t(e)})})})}capture({host:e,path:t,params:n}){if(!this.inAppBrowser)throw new o.a("InAppBrowser Session not found");return new Promise(r=>{const i=o=>{if(o.url){const s=new URL(o.url);(t=>t.origin===e)(s)&&(e=>e.pathname===t)(s)&&(e=>n.map(e=>e).every(t=>"false"===t.exists?!e.searchParams.has(t.key):t.match?e.searchParams.has(t.key)&&e.searchParams.get(t.key)===t.match:e.searchParams.has(t.key)))(s)&&(this.captured=Object.assign(Object.assign({},this.captured),n.reduce((e,t)=>(e[t.resolveTo]=s.searchParams.get(t.key),e),{})),this.extras={},n.map(e=>e.key).forEach(e=>s.searchParams.delete(e)),s.searchParams.forEach((e,t)=>{this.extras[t]=e}),this.inAppBrowser&&(this.inAppBrowser.listeners.loadstart.delete(i),this.inAppBrowser.ref.removeEventListener("loadstart",i)),r())}};this.inAppBrowser&&(this.inAppBrowser.listeners.loadstart.add(i),this.inAppBrowser.ref.addEventListener("loadstart",i))})}resolveCaptured(e){return c(this,void 0,void 0,(function*(){if(!this.captured[e])throw new s.a(e+" was not captured");return this.captured[e]}))}clearCapture(){return c(this,void 0,void 0,(function*(){this.captured={}}))}redirectTo({host:e,path:t,params:n}){return c(this,void 0,void 0,(function*(){if(!this.inAppBrowser)throw new o.a("InAppBrowser Session not found");this.inAppBrowser.ref.executeScript({code:"(() => {\n window.location.href = `"+u.buildUrl(e,t,n)+"`;\n })()"})}))}success(){return c(this,void 0,void 0,(function*(){return Object.assign({},this.captured)}))}fail(){return c(this,void 0,void 0,(function*(){throw Object.assign({},this.captured)}))}getCaptureExtras(){return c(this,void 0,void 0,(function*(){return Object.assign({},this.extras)}))}}},function(e,t,n){e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=!1,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,s;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(s=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],s.set(o,i),i+=o.length;return s}},s={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var s=new r.Buf8(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}s[254]=s[254]=1,n.string2buf=function(e){var t,n,i,o,s,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(c),s=0,o=0;s<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,a=t||e.length,u=new Array(2*a);for(r=0,n=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if((o=s[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<a;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],5:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),c=e("./messages");function u(e,t){return e.msg=c[t],t}function d(e){return(e<<1)-(e>4?9:0)}function l(e){for(var t=e.length;--t>=0;)e[t]=0}function f(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function h(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,f(e.strm)}function E(e,t){e.pending_buf[e.pending++]=t}function p(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function _(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,u=e.window,d=e.w_mask,l=e.prev,f=e.strstart+258,h=u[o+s-1],E=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+s]===E&&u[n+s-1]===h&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&o<f);if(r=258-(f-o),o=f-258,r>s){if(e.match_start=t,s=r,r>=a)break;h=u[o+s-1],E=u[o+s]}}}while((t=l[t&d])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead}function S(e){var t,n,r,o,c,u,d,l,f,h,E=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=E+(E-262)){i.arraySet(e.window,e.window,E,E,0),e.match_start-=E,e.strstart-=E,e.block_start-=E,t=n=e.hash_size;do{r=e.head[--t],e.head[t]=r>=E?r-E:0}while(--n);t=n=E;do{r=e.prev[--t],e.prev[t]=r>=E?r-E:0}while(--n);o+=E}if(0===e.strm.avail_in)break;if(u=e.strm,d=e.window,l=e.strstart+e.lookahead,f=o,h=void 0,(h=u.avail_in)>f&&(h=f),n=0===h?0:(u.avail_in-=h,i.arraySet(d,u.input,u.next_in,h,l),1===u.state.wrap?u.adler=s(u.adler,d,h,l):2===u.state.wrap&&(u.adler=a(u.adler,d,h,l)),u.next_in+=h,u.total_in+=h,h),e.lookahead+=n,e.lookahead+e.insert>=3)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+3-1])&e.hash_mask,e.prev[c&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=c,c++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function b(e,t){for(var n,r;;){if(e.lookahead<262){if(S(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n)),e.match_length>=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(h(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(h(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(h(e,!1),0===e.strm.avail_out)?1:2}function O(e,t){for(var n,r,i;;){if(e.lookahead<262){if(S(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(h(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=o._tr_tally(e,0,e.window[e.strstart-1]))&&h(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=o._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(h(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(h(e,!1),0===e.strm.avail_out)?1:2}function v(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}function C(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),l(this.dyn_ltree),l(this.dyn_dtree),l(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),l(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),l(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function g(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=0,o._tr_init(t),0):u(e,-2)}function A(e){var t,n=g(e);return 0===n&&((t=e.state).window_size=2*t.w_size,l(t.head),t.max_lazy_match=r[t.level].max_lazy,t.good_match=r[t.level].good_length,t.nice_match=r[t.level].nice_length,t.max_chain_length=r[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),n}function T(e,t,n,r,o,s){if(!e)return-2;var a=1;if(-1===t&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),o<1||o>9||8!==n||r<8||r>15||t<0||t>9||s<0||s>4)return u(e,-2);8===r&&(r=9);var c=new C;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=o+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new i.Buf8(2*c.w_size),c.head=new i.Buf16(c.hash_size),c.prev=new i.Buf16(c.w_size),c.lit_bufsize=1<<o+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new i.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=s,c.method=n,A(e)}r=[new v(0,0,0,0,(function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(S(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,h(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(h(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(h(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(h(e,!1),e.strm.avail_out),1)})),new v(4,4,8,4,b),new v(4,5,16,8,b),new v(4,6,32,32,b),new v(4,4,16,16,O),new v(8,16,32,32,O),new v(8,16,128,128,O),new v(8,32,128,256,O),new v(32,128,258,1024,O),new v(32,258,258,4096,O)],n.deflateInit=function(e,t){return T(e,t,8,15,8,0)},n.deflateInit2=T,n.deflateReset=A,n.deflateResetKeep=g,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?-2:(e.state.gzhead=t,0):-2},n.deflate=function(e,t){var n,i,s,c;if(!e||!e.state||t>5||t<0)return e?u(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return u(e,0===e.avail_out?-5:-2);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,E(i,31),E(i,139),E(i,8),i.gzhead?(E(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),E(i,255&i.gzhead.time),E(i,i.gzhead.time>>8&255),E(i,i.gzhead.time>>16&255),E(i,i.gzhead.time>>24&255),E(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),E(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(E(i,255&i.gzhead.extra.length),E(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(E(i,0),E(i,0),E(i,0),E(i,0),E(i,0),E(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),E(i,3),i.status=113);else{var _=8+(i.w_bits-8<<4)<<8;_|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(_|=32),_+=31-_%31,i.status=113,p(i,_),0!==i.strstart&&(p(i,e.adler>>>16),p(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),f(e),s=i.pending,i.pending!==i.pending_buf_size));)E(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),f(e),s=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,E(i,c)}while(0!==c);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===c&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),f(e),s=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,E(i,c)}while(0!==c);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===c&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&f(e),i.pending+2<=i.pending_buf_size&&(E(i,255&e.adler),E(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(f(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&d(t)<=d(n)&&4!==t)return u(e,-5);if(666===i.status&&0!==e.avail_in)return u(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var b=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(S(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(h(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(h(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(h(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=258){if(S(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=a[i=e.strstart-1])===a[++i]&&r===a[++i]&&r===a[++i]){s=e.strstart+258;do{}while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&i<s);e.match_length=258-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(h(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(h(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(h(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==b&&4!==b||(i.status=666),1===b||3===b)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===b&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(l(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),f(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(E(i,255&e.adler),E(i,e.adler>>8&255),E(i,e.adler>>16&255),E(i,e.adler>>24&255),E(i,255&e.total_in),E(i,e.total_in>>8&255),E(i,e.total_in>>16&255),E(i,e.total_in>>24&255)):(p(i,e.adler>>>16),p(i,65535&e.adler)),f(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?u(e,-2):(e.state=null,113===t?u(e,-3):0):-2},n.deflateSetDictionary=function(e,t){var n,r,o,a,c,u,d,f,h=t.length;if(!e||!e.state)return-2;if(2===(a=(n=e.state).wrap)||1===a&&42!==n.status||n.lookahead)return-2;for(1===a&&(e.adler=s(e.adler,t,h,0)),n.wrap=0,h>=n.w_size&&(0===a&&(l(n.head),n.strstart=0,n.block_start=0,n.insert=0),f=new i.Buf8(n.w_size),i.arraySet(f,t,h-n.w_size,n.w_size,0),t=f,h=n.w_size),c=e.avail_in,u=e.next_in,d=e.input,e.avail_in=h,e.next_in=0,e.input=t,S(n);n.lookahead>=3;){r=n.strstart,o=n.lookahead-2;do{n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+3-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++}while(--o);n.strstart=r,n.lookahead=2,S(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=u,e.input=d,e.avail_in=c,n.wrap=a,0},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":4,"./messages":6,"./trees":7}],6:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],7:[function(e,t,n){"use strict";var r=e("../utils/common");function i(e){for(var t=e.length;--t>=0;)e[t]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],s=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);i(u);var d=new Array(60);i(d);var l=new Array(512);i(l);var f=new Array(256);i(f);var h=new Array(29);i(h);var E,p,_,S=new Array(30);function b(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function O(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function v(e){return e<256?l[e]:l[256+(e>>>7)]}function C(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function g(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,C(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function A(e,t,n){g(e,n[2*t],n[2*t+1])}function T(e,t){var n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}function N(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=15;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=T(o[a]++,a))}}function y(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function m(e){e.bi_valid>8?C(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function I(e,t,n,r){var i=2*t,o=2*n;return e[i]<e[o]||e[i]===e[o]&&r[t]<=r[n]}function M(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&I(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!I(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function D(e,t,n){var r,i,a,c,u=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*u]<<8|e.pending_buf[e.d_buf+2*u+1],i=e.pending_buf[e.l_buf+u],u++,0===r?A(e,i,t):(A(e,(a=f[i])+256+1,t),0!==(c=o[a])&&g(e,i-=h[a],c),A(e,a=v(--r),n),0!==(c=s[a])&&g(e,r-=S[a],c))}while(u<e.last_lit);A(e,256,t)}function R(e,t){var n,r,i,o=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<c;n++)0!==o[2*n]?(e.heap[++e.heap_len]=u=n,e.depth[n]=0):o[2*n+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=s[2*i+1]);for(t.max_code=u,n=e.heap_len>>1;n>=1;n--)M(e,o,n);i=c;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,M(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,E=t.stat_desc.max_length,p=0;for(o=0;o<=15;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)>E&&(o=E,p++),c[2*r+1]=o,r>u||(e.bl_count[o]++,s=0,r>=h&&(s=f[r-h]),a=c[2*r],e.opt_len+=a*(o+s),l&&(e.static_len+=a*(d[2*r+1]+s)));if(0!==p){do{for(o=E-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[E]--,p-=2}while(p>0);for(o=E;0!==o;o--)for(r=e.bl_count[o];0!==r;)(i=e.heap[--n])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),r--)}}(e,t),N(o,u,e.bl_count)}function P(e,t,n){var r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a<c&&i===s||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,o=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4))}function L(e,t,n){var r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a<c&&i===s)){if(a<u)do{A(e,i,e.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(A(e,i,e.bl_tree),a--),A(e,16,e.bl_tree),g(e,a-3,2)):a<=10?(A(e,17,e.bl_tree),g(e,a-3,3)):(A(e,18,e.bl_tree),g(e,a-11,7));a=0,o=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4)}}i(S);var w=!1;function U(e,t,n,i){g(e,0+(i?1:0),3),function(e,t,n,i){m(e),i&&(C(e,n),C(e,~n)),r.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n,!0)}n._tr_init=function(e){w||(function(){var e,t,n,r,i,c=new Array(16);for(n=0,r=0;r<28;r++)for(h[r]=n,e=0;e<1<<o[r];e++)f[n++]=r;for(f[n-1]=r,i=0,r=0;r<16;r++)for(S[r]=i,e=0;e<1<<s[r];e++)l[i++]=r;for(i>>=7;r<30;r++)for(S[r]=i<<7,e=0;e<1<<s[r]-7;e++)l[256+i++]=r;for(t=0;t<=15;t++)c[t]=0;for(e=0;e<=143;)u[2*e+1]=8,e++,c[8]++;for(;e<=255;)u[2*e+1]=9,e++,c[9]++;for(;e<=279;)u[2*e+1]=7,e++,c[7]++;for(;e<=287;)u[2*e+1]=8,e++,c[8]++;for(N(u,287,c),e=0;e<30;e++)d[2*e+1]=5,d[2*e]=T(e,5);E=new b(u,o,257,286,15),p=new b(d,s,0,30,15),_=new b(new Array(0),a,0,19,7)}(),w=!0),e.l_desc=new O(e.dyn_ltree,E),e.d_desc=new O(e.dyn_dtree,p),e.bl_desc=new O(e.bl_tree,_),e.bi_buf=0,e.bi_valid=0,y(e)},n._tr_stored_block=U,n._tr_flush_block=function(e,t,n,r){var i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),s=function(e){var t;for(P(e,e.dyn_ltree,e.l_desc.max_code),P(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*c[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||o===i?(g(e,2+(r?1:0),3),D(e,u,d)):(g(e,4+(r?1:0),3),function(e,t,n,r){var i;for(g(e,t-257,5),g(e,n-1,5),g(e,r-4,4),i=0;i<r;i++)g(e,e.bl_tree[2*c[i]+1],3);L(e,e.dyn_ltree,t-1),L(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),D(e,e.dyn_ltree,e.dyn_dtree)),y(e),r&&m(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(f[n]+256+1)]++,e.dyn_dtree[2*v(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){g(e,2,3),A(e,256,u),function(e){16===e.bi_valid?(C(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":1}],8:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/deflate.js":[function(e,t,n){"use strict";var r=e("./zlib/deflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/messages"),a=e("./zlib/zstream"),c=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var n=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(s[n]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var d;if(d="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=r.deflateSetDictionary(this.strm,d)))throw new Error(s[n]);this._dict_set=!0}}function d(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||s[n.err];return n.result}u.prototype.push=function(e,t){var n,s,a=this.strm,u=this.options.chunkSize;if(this.ended)return!1;s=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=o.string2buf(e):"[object ArrayBuffer]"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(u),a.next_out=0,a.avail_out=u),1!==(n=r.deflate(a,s))&&0!==n)return this.onEnd(n),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==s&&2!==s)||("string"===this.options.to?this.onData(o.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==n);return 4===s?(n=r.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==s||(this.onEnd(0),a.avail_out=0,!0)},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=u,n.deflate=d,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,d(e,t)}},{"./utils/common":1,"./utils/strings":2,"./zlib/deflate":5,"./zlib/messages":6,"./zlib/zstream":8}]},{},[])("/lib/deflate.js")},function(e,t,n){"use strict";n.r(t);var r=n(217);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(218);n.d(t,"PageName",(function(){return o.a}));var s=n(219);for(var i in s)["default","PageName"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(220);for(var i in a)["default","PageName"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i)},function(e,t,n){"use strict";n.r(t);var r=n(233);n.d(t,"NotificationType",(function(){return r.b})),n.d(t,"NotificationStatus",(function(){return r.a}));var i=n(234);for(var o in i)["default","NotificationType","NotificationStatus"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(7),i=n(52),o=n(46),s=n(36),a=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class c{constructor(e,t,n){this.apiConfig=e,this.apiService=t,this.eventsBusService=n}static parseAccessToken(e){return a(this,void 0,void 0,(function*(){let t=yield s.a.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}buildGoogleTargetUrl(e,t){const n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach(e=>n.searchParams.set(e,t[e])),n}buildPasswordSessionProvider(e,t){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(e=>this.resolvePasswordSession(e))}buildStateSessionProvider(e,t){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(e=>this.resolveStateSession(e))}buildGoogleSessionProvider(e,t,n){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(t=>e.getCaptureExtras().then(r=>{const o=this.buildGoogleTargetUrl(t,r);return e.launchCustomTab({host:o.origin,path:o.pathname,params:i.parse(o.searchParams.toString(),{ignoreQueryPrefix:!0}),extraParams:n.get("extraParam")}).then(()=>e.success()).then(e=>this.resolveGoogleSession(e))}))}resolvePasswordSession(e){const t=(new r.Request.Builder).withType(r.HttpRequestType.POST).withPath(this.apiConfig.user_authentication.authUrl+"/token").withBody({redirect_uri:this.apiConfig.host+"/oauth2callback",code:e.code,grant_type:"authorization_code",client_id:"android"}).withHeaders({"Content-Type":"application/x-www-form-urlencoded"}).withSerializer(r.HttpSerializer.URLENCODED).withBearerToken(!1).withUserToken(!1).build();return this.apiService.fetch(t).toPromise().then(e=>a(this,void 0,void 0,(function*(){if(e.body.access_token&&e.body.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield c.parseAccessToken(e.body.access_token);return{access_token:e.body.access_token,refresh_token:e.body.refresh_token,accessTokenExpiresOn:n,userToken:t}}throw new o.a("Server Error")}))).catch(()=>{throw new o.a("Server Error")})}resolveStateSession(e){const t="/v1/sso/create/session?id="+("ios"===window.device.platform.toLowerCase()?encodeURIComponent(e.id):e.id),n=(new r.Request.Builder).withType(r.HttpRequestType.GET).withPath(t).withUserToken(!1).withBearerToken(!1).build();return this.apiService.fetch(n).toPromise().then(e=>a(this,void 0,void 0,(function*(){if(e.body.access_token&&e.body.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield c.parseAccessToken(e.body.access_token);return{access_token:e.body.access_token,refresh_token:e.body.refresh_token,accessTokenExpiresOn:n,userToken:t}}throw new o.a("Server Error")}))).catch(()=>{throw new o.a("Server Error")})}resolveGoogleSession(e){return a(this,void 0,void 0,(function*(){if(e.access_token&&e.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield c.parseAccessToken(e.access_token);return{access_token:e.access_token,refresh_token:e.refresh_token,accessTokenExpiresOn:n,userToken:t}}if(e.error_message)throw new o.a(e.error_message);throw new o.a("Server Error")}))}}},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{static prepareFrameworkCategoryAssociations(e){return e.categories?(e.categories=e.categories.map((t,n)=>t.terms?Object.assign(Object.assign({},t),{terms:t.terms.map(t=>t.associations?(t.associations.length&&(t.associations=t.associations.filter(t=>n>=e.categories.length-1||t.category===e.categories[n+1].code)),t):t)}):t),Object.assign({},e)):e}static prepareFrameworkTranslations(e,t){return e.name=r.getTranslatedValue(e.translations,t,e.name),e.categories&&(e.categories=e.categories.map(e=>(e.name=r.getTranslatedValue(e.translations,t,e.name),e.terms&&(e.terms=e.terms.map(e=>(e.name=r.getTranslatedValue(e.translations,t,e.name),e))),e))),e}static prepareFrameworkCategoryTranslations(e,t){return e.name=r.getTranslatedValue(e.translations,t,e.name),e.terms&&(e.terms=e.terms.map(e=>(e.name=r.getTranslatedValue(e.translations,t,e.name),e))),e}static getTranslatedValue(e,t,n){if(!e)return n;return JSON.parse(e)[t]||n}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.id=void 0;var r=0;t.id=function(){return r++}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(49);class i extends r.a{constructor(e){super(e,"NO_INAPPBROWSER_SESSION_ASSERTION_FAIL"),Object.setPrototypeOf(this,r.a.prototype)}}},function(e,t,n){"use strict";n.r(t);var r=n(241);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(242);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(243);n.d(t,"GroupSessionDeprecated",(function(){return s.a}));var a=n(244);for(var i in a)["default","GroupSessionDeprecated"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(245);for(var i in c)["default","GroupSessionDeprecated"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(i);var u=n(246);n.d(t,"NoGroupFoundError",(function(){return u.a}));var d=n(247);n.d(t,"NoActiveGroupSessionError",(function(){return d.a}))},function(e,t,n){"use strict";var r=n(334),i=n(335),o=n(336),s=n(337),a=n(145),c=n(77),u=n(338),d=Function,l=function(e){try{return d('"use strict"; return ('+e+").constructor;")()}catch(e){}},f=Object.getOwnPropertyDescriptor;if(f)try{f({},"")}catch(e){f=null}var h=function(){throw new c},E=f?function(){try{return h}catch(e){try{return f(arguments,"callee").get}catch(e){return h}}}():h,p=n(339)(),_=n(341)(),S=Object.getPrototypeOf||(_?function(e){return e.__proto__}:null),b={},O="undefined"!=typeof Uint8Array&&S?S(Uint8Array):void 0,v={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":p&&S?S([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":b,"%AsyncGenerator%":b,"%AsyncGeneratorFunction%":b,"%AsyncIteratorPrototype%":b,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":i,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":d,"%GeneratorFunction%":b,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":p&&S?S(S([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&p&&S?S((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&p&&S?S((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":p&&S?S(""[Symbol.iterator]()):void 0,"%Symbol%":p?Symbol:void 0,"%SyntaxError%":a,"%ThrowTypeError%":E,"%TypedArray%":O,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet};if(S)try{null.error}catch(e){var C=S(S(e));v["%Error.prototype%"]=C}var g={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},A=n(104),T=n(343),N=A.call(Function.call,Array.prototype.concat),y=A.call(Function.apply,Array.prototype.splice),m=A.call(Function.call,String.prototype.replace),I=A.call(Function.call,String.prototype.slice),M=A.call(Function.call,RegExp.prototype.exec),D=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,R=/\\(\\)?/g,P=function(e){var t=I(e,0,1),n=I(e,-1);if("%"===t&&"%"!==n)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new a("invalid intrinsic syntax, expected opening `%`");var r=[];return m(e,D,(function(e,t,n,i){r[r.length]=n?m(i,R,"$1"):t||e})),r},L=function(e,t){var n,r=e;if(T(g,r)&&(r="%"+(n=g[r])[0]+"%"),T(v,r)){var i=v[r];if(i===b&&(i=function e(t){var n;if("%AsyncFunction%"===t)n=l("async function () {}");else if("%GeneratorFunction%"===t)n=l("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=l("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&S&&(n=S(i.prototype))}return v[t]=n,n}(r)),void 0===i&&!t)throw new c("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:i}}throw new a("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new c('"allowMissing" argument must be a boolean');if(null===M(/^%?[^%]*%?$/,e))throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=P(e),r=n.length>0?n[0]:"",i=L("%"+r+"%",t),o=i.name,s=i.value,u=!1,d=i.alias;d&&(r=d[0],y(n,N([0,1],d)));for(var l=1,h=!0;l<n.length;l+=1){var E=n[l],p=I(E,0,1),_=I(E,-1);if(('"'===p||"'"===p||"`"===p||'"'===_||"'"===_||"`"===_)&&p!==_)throw new a("property names with quotes must have matching quotes");if("constructor"!==E&&h||(u=!0),T(v,o="%"+(r+="."+E)+"%"))s=v[o];else if(null!=s){if(!(E in s)){if(!t)throw new c("base intrinsic for "+e+" exists, but the property is not available.");return}if(f&&l+1>=n.length){var S=f(s,E);s=(h=!!S)&&"get"in S&&!("originalValue"in S.get)?S.get:s[E]}else h=T(s,E),s=s[E];h&&!u&&(v[o]=s)}}return s}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r,i=n(1);!function(e){e.TABLE_NAME="network_queue",e._ID="_id",e.COLUMN_NAME_MSG_ID="msg_id",e.COLUMN_NAME_PRIORITY="priority",e.COLUMN_NAME_TIMESTAMP="timestamp",e.COLUMN_NAME_DATA="data",e.COLUMN_NAME_REQUEST="request",e.COLUMN_NAME_NUMBER_OF_ITEM="item_count",e.COLUMN_NAME_CONFIG="config",e.COLUMN_NAME_TYPE="type",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_MSG_ID+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_PRIORITY+i.DbConstants.SPACE+i.DbConstants.INT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_TIMESTAMP+i.DbConstants.SPACE+i.DbConstants.INT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_DATA+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_NUMBER_OF_ITEM+i.DbConstants.SPACE+i.DbConstants.INT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_CONFIG+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_TYPE+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+i.DbConstants.COMMA_SEP+e.COLUMN_NAME_REQUEST+i.DbConstants.SPACE+i.DbConstants.TEXT_TYPE+")",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME;e.Mapper=class{static networkQueueRequestToEntry(t){return{[e.COLUMN_NAME_MSG_ID]:t.msgId,[e.COLUMN_NAME_PRIORITY]:t.priority,[e.COLUMN_NAME_TIMESTAMP]:t.ts,[e.COLUMN_NAME_DATA]:t.data,[e.COLUMN_NAME_NUMBER_OF_ITEM]:t.itemCount,[e.COLUMN_NAME_CONFIG]:t.config,[e.COLUMN_NAME_TYPE]:t.type,[e.COLUMN_NAME_REQUEST]:t.networkRequest.toJSON()}}}}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e,t){super(e,"ASSERTION_ERROR_"+t),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(48),i=n(61),o=n(25),s=n(7),a=n(18),c=n(0),u=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class d extends i.a{constructor(e,t,n){super(o.a.instance.sdkConfig.apiConfig,o.a.instance.apiService,o.a.instance.eventsBusService),this.autoMergeConfig=e,this.webviewRunner=t,this.captured=n,this.telemetryService=o.a.instance.telemetryService}provide(){return u(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.autoMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),Object.keys(this.captured).forEach(e=>{this.autoMergeConfig.target.params.push({key:e,value:this.captured[e]})}),e.redirectTo({host:this.autoMergeConfig.target.host,path:this.autoMergeConfig.target.path,params:this.autoMergeConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),{})}).then(()=>e.any(...this.autoMergeConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n).then(e=>this.performAutoMerge({payload:this.captured.payload,session:e})));break;case"state":t.push(this.buildStateSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n).then(e=>this.performAutoMerge({payload:this.captured.payload,session:e})))}return t},[])))}))}performAutoMerge({payload:e,session:t}){const n=(new s.Request.Builder).withType(s.HttpRequestType.GET).withPath(this.apiConfig.user_authentication.autoMergeApiPath).withParameters({client_id:"android"}).withHeaders({"x-authenticated-user-token":t.access_token,"x-authenticated-user-data":e}).build();return this.apiService.fetch(n).pipe(Object(c.mapTo)(void 0)).toPromise().then(()=>(this.eventsBusService.emit({namespace:a.EventNamespace.AUTH,event:{type:r.AuthEventType.AUTO_MIGRATE_SUCCESS,payload:void 0}}),t)).catch(e=>(console.error(e),this.eventsBusService.emit({namespace:a.EventNamespace.AUTH,event:{type:r.AuthEventType.AUTO_MIGRATE_FAIL,payload:void 0}}),t))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(7),i=n(3),o=n(38),s=n.n(o),a=n(32),c=n(36),u=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class d{constructor(e,t,n){this.config=e,this.apiService=t,this.deviceInfo=n}refreshAuthToken(){return Object(i.from)(this.getBearerTokenFromKongV2())}getMobileDeviceConsumerKey(){return this.config.api_authentication.producerId+"-"+this.deviceInfo.getDeviceID()}buildGetMobileDeviceConsumerSecretAPIRequest(e){return u(this,void 0,void 0,(function*(){return(new a.CsRequest.Builder).withPath(e).withType(a.CsHttpRequestType.POST).withHeaders({"Content-Encoding":"gzip",Authorization:"Bearer "+(yield this.generateMobileAppConsumerBearerToken())}).withBody({id:d.ID,ver:d.VERSION,ts:s()().format(),request:{key:this.getMobileDeviceConsumerKey()}}).build()}))}getBearerTokenFromKongV2(){return u(this,void 0,void 0,(function*(){const e=`/api/api-manager/v2/consumer/${this.config.api_authentication.mobileAppConsumer}/credential/register`;let t=yield this.buildGetMobileDeviceConsumerSecretAPIRequest(e);return this.apiService.fetch(t).toPromise().then(e=>e.body.result.token).catch(e=>{if(!a.CsNetworkError.isInstance(e)){const t=`/api/api-manager/v1/consumer/${this.config.api_authentication.mobileAppConsumer}/credential/register`;if(e.response.responseCode===r.ResponseCode.HTTP_KONG_FAILURE){const n=e.response.headers,r=n?n.location:t;return this.getBearerTokenFromFallback(r||t)}return this.getBearerTokenFromFallback(t)}throw e})}))}getBearerTokenFromFallback(e){return u(this,void 0,void 0,(function*(){let t=yield this.buildGetMobileDeviceConsumerSecretAPIRequest(e);return this.apiService.fetch(t).toPromise().then(e=>u(this,void 0,void 0,(function*(){const t=e.body.result;return t.token?t.token:yield c.a.createJWTToken(this.getMobileDeviceConsumerKey(),t.secret)}))).catch(e=>{console.log("e ",e)})}))}generateMobileAppConsumerBearerToken(){return u(this,void 0,void 0,(function*(){const e=this.config.api_authentication.mobileAppKey,t=this.config.api_authentication.mobileAppSecret;return yield c.a.createJWTToken(e,t)}))}}d.VERSION="1.0",d.ID="ekstep.genie.device.register"},function(e,t,n){e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=!1,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,s;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(s=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],s.set(o,i),i+=o.length;return s}},s={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var s=new r.Buf8(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}s[254]=s[254]=1,n.string2buf=function(e){var t,n,i,o,s,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(c),s=0,o=0;s<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,a=t||e.length,u=new Array(2*a);for(r=0,n=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if((o=s[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<a;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],6:[function(e,t,n){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,n){"use strict";t.exports=function(e,t){var n,r,i,o,s,a,c,u,d,l,f,h,E,p,_,S,b,O,v,C,g,A,T,N,y;n=e.state,r=e.next_in,N=e.input,i=r+(e.avail_in-5),o=e.next_out,y=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=n.dmax,u=n.wsize,d=n.whave,l=n.wnext,f=n.window,h=n.hold,E=n.bits,p=n.lencode,_=n.distcode,S=(1<<n.lenbits)-1,b=(1<<n.distbits)-1;e:do{E<15&&(h+=N[r++]<<E,E+=8,h+=N[r++]<<E,E+=8),O=p[h&S];t:for(;;){if(h>>>=v=O>>>24,E-=v,0==(v=O>>>16&255))y[o++]=65535&O;else{if(!(16&v)){if(0==(64&v)){O=p[(65535&O)+(h&(1<<v)-1)];continue t}if(32&v){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}C=65535&O,(v&=15)&&(E<v&&(h+=N[r++]<<E,E+=8),C+=h&(1<<v)-1,h>>>=v,E-=v),E<15&&(h+=N[r++]<<E,E+=8,h+=N[r++]<<E,E+=8),O=_[h&b];n:for(;;){if(h>>>=v=O>>>24,E-=v,!(16&(v=O>>>16&255))){if(0==(64&v)){O=_[(65535&O)+(h&(1<<v)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(g=65535&O,E<(v&=15)&&(h+=N[r++]<<E,(E+=8)<v&&(h+=N[r++]<<E,E+=8)),(g+=h&(1<<v)-1)>c){e.msg="invalid distance too far back",n.mode=30;break e}if(h>>>=v,E-=v,g>(v=o-s)){if((v=g-v)>d&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(A=0,T=f,0===l){if(A+=u-v,v<C){C-=v;do{y[o++]=f[A++]}while(--v);A=o-g,T=y}}else if(l<v){if(A+=u+l-v,(v-=l)<C){C-=v;do{y[o++]=f[A++]}while(--v);if(A=0,l<C){C-=v=l;do{y[o++]=f[A++]}while(--v);A=o-g,T=y}}}else if(A+=l-v,v<C){C-=v;do{y[o++]=f[A++]}while(--v);A=o-g,T=y}for(;C>2;)y[o++]=T[A++],y[o++]=T[A++],y[o++]=T[A++],C-=3;C&&(y[o++]=T[A++],C>1&&(y[o++]=T[A++]))}else{A=o-g;do{y[o++]=y[A++],y[o++]=y[A++],y[o++]=y[A++],C-=3}while(C>2);C&&(y[o++]=y[A++],C>1&&(y[o++]=y[A++]))}break}}break}}while(r<i&&o<a);r-=C=E>>3,h&=(1<<(E-=C<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=o<a?a-o+257:257-(o-a),n.hold=h,n.bits=E}},{}],8:[function(e,t,n){"use strict";var r=e("../utils/common"),i=e("./adler32"),o=e("./crc32"),s=e("./inffast"),a=e("./inftrees");function c(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):-2}function l(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):-2}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,l(e))):-2}function h(e,t){var n,r;return e?(r=new u,e.state=r,r.window=null,0!==(n=f(e,t))&&(e.state=null),n):-2}var E,p,_=!0;function S(e){if(_){var t;for(E=new r.Buf32(512),p=new r.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,E,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,p,0,e.work,{bits:5}),_=!1}e.lencode=E,e.lenbits=9,e.distcode=p,e.distbits=5}function b(e,t,n,i){var o,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new r.Buf8(s.wsize)),i>=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((o=s.wsize-s.wnext)>i&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0}n.inflateReset=l,n.inflateReset2=f,n.inflateResetKeep=d,n.inflateInit=function(e){return h(e,15)},n.inflateInit2=h,n.inflate=function(e,t){var n,u,d,l,f,h,E,p,_,O,v,C,g,A,T,N,y,m,I,M,D,R,P,L,w=0,U=new r.Buf8(4),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(n=e.state).mode&&(n.mode=13),f=e.next_out,d=e.output,E=e.avail_out,l=e.next_in,u=e.input,h=e.avail_in,p=n.hold,_=n.bits,O=h,v=E,R=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;_<16;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(2&n.wrap&&35615===p){n.check=0,U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0),p=0,_=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&p)<<8)+(p>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&p)){e.msg="unknown compression method",n.mode=30;break}if(_-=4,D=8+(15&(p>>>=4)),0===n.wbits)n.wbits=D;else if(D>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<D,e.adler=n.check=1,n.mode=512&p?10:12,p=0,_=0;break;case 2:for(;_<16;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(n.flags=p,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=p>>8&1),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0,n.mode=3;case 3:for(;_<32;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}n.head&&(n.head.time=p),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,U[2]=p>>>16&255,U[3]=p>>>24&255,n.check=o(n.check,U,4,0)),p=0,_=0,n.mode=4;case 4:for(;_<16;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}n.head&&(n.head.xflags=255&p,n.head.os=p>>8),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0,n.mode=5;case 5:if(1024&n.flags){for(;_<16;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}n.length=p,n.head&&(n.head.extra_len=p),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((C=n.length)>h&&(C=h),C&&(n.head&&(D=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,l,C,D)),512&n.flags&&(n.check=o(n.check,u,C,l)),h-=C,l+=C,n.length-=C),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===h)break e;C=0;do{D=u[l+C++],n.head&&D&&n.length<65536&&(n.head.name+=String.fromCharCode(D))}while(D&&C<h);if(512&n.flags&&(n.check=o(n.check,u,C,l)),h-=C,l+=C,D)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===h)break e;C=0;do{D=u[l+C++],n.head&&D&&n.length<65536&&(n.head.comment+=String.fromCharCode(D))}while(D&&C<h);if(512&n.flags&&(n.check=o(n.check,u,C,l)),h-=C,l+=C,D)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;_<16;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(p!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}p=0,_=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;_<32;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}e.adler=n.check=c(p),p=0,_=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=f,e.avail_out=E,e.next_in=l,e.avail_in=h,n.hold=p,n.bits=_,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){p>>>=7&_,_-=7&_,n.mode=27;break}for(;_<3;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}switch(n.last=1&p,_-=1,3&(p>>>=1)){case 0:n.mode=14;break;case 1:if(S(n),n.mode=20,6===t){p>>>=2,_-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}p>>>=2,_-=2;break;case 14:for(p>>>=7&_,_-=7&_;_<32;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if((65535&p)!=(p>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&p,p=0,_=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(C=n.length){if(C>h&&(C=h),C>E&&(C=E),0===C)break e;r.arraySet(d,u,l,C,f),h-=C,l+=C,E-=C,f+=C,n.length-=C;break}n.mode=12;break;case 17:for(;_<14;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(n.nlen=257+(31&p),p>>>=5,_-=5,n.ndist=1+(31&p),p>>>=5,_-=5,n.ncode=4+(15&p),p>>>=4,_-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;_<3;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}n.lens[j[n.have++]]=7&p,p>>>=3,_-=3}for(;n.have<19;)n.lens[j[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},R=a(0,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,R){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;N=(w=n.lencode[p&(1<<n.lenbits)-1])>>>16&255,y=65535&w,!((T=w>>>24)<=_);){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(y<16)p>>>=T,_-=T,n.lens[n.have++]=y;else{if(16===y){for(L=T+2;_<L;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(p>>>=T,_-=T,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}D=n.lens[n.have-1],C=3+(3&p),p>>>=2,_-=2}else if(17===y){for(L=T+3;_<L;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}_-=T,D=0,C=3+(7&(p>>>=T)),p>>>=3,_-=3}else{for(L=T+7;_<L;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}_-=T,D=0,C=11+(127&(p>>>=T)),p>>>=7,_-=7}if(n.have+C>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;C--;)n.lens[n.have++]=D}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,P={bits:n.lenbits},R=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,R){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},R=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,R){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(h>=6&&E>=258){e.next_out=f,e.avail_out=E,e.next_in=l,e.avail_in=h,n.hold=p,n.bits=_,s(e,v),f=e.next_out,d=e.output,E=e.avail_out,l=e.next_in,u=e.input,h=e.avail_in,p=n.hold,_=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;N=(w=n.lencode[p&(1<<n.lenbits)-1])>>>16&255,y=65535&w,!((T=w>>>24)<=_);){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(N&&0==(240&N)){for(m=T,I=N,M=y;N=(w=n.lencode[M+((p&(1<<m+I)-1)>>m)])>>>16&255,y=65535&w,!(m+(T=w>>>24)<=_);){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}p>>>=m,_-=m,n.back+=m}if(p>>>=T,_-=T,n.back+=T,n.length=y,0===N){n.mode=26;break}if(32&N){n.back=-1,n.mode=12;break}if(64&N){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&N,n.mode=22;case 22:if(n.extra){for(L=n.extra;_<L;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}n.length+=p&(1<<n.extra)-1,p>>>=n.extra,_-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;N=(w=n.distcode[p&(1<<n.distbits)-1])>>>16&255,y=65535&w,!((T=w>>>24)<=_);){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(0==(240&N)){for(m=T,I=N,M=y;N=(w=n.distcode[M+((p&(1<<m+I)-1)>>m)])>>>16&255,y=65535&w,!(m+(T=w>>>24)<=_);){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}p>>>=m,_-=m,n.back+=m}if(p>>>=T,_-=T,n.back+=T,64&N){e.msg="invalid distance code",n.mode=30;break}n.offset=y,n.extra=15&N,n.mode=24;case 24:if(n.extra){for(L=n.extra;_<L;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}n.offset+=p&(1<<n.extra)-1,p>>>=n.extra,_-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===E)break e;if(C=v-E,n.offset>C){if((C=n.offset-C)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}C>n.wnext?(C-=n.wnext,g=n.wsize-C):g=n.wnext-C,C>n.length&&(C=n.length),A=n.window}else A=d,g=f-n.offset,C=n.length;C>E&&(C=E),E-=C,n.length-=C;do{d[f++]=A[g++]}while(--C);0===n.length&&(n.mode=21);break;case 26:if(0===E)break e;d[f++]=n.length,E--,n.mode=21;break;case 27:if(n.wrap){for(;_<32;){if(0===h)break e;h--,p|=u[l++]<<_,_+=8}if(v-=E,e.total_out+=v,n.total+=v,v&&(e.adler=n.check=n.flags?o(n.check,d,v,f-v):i(n.check,d,v,f-v)),v=E,(n.flags?p:c(p))!==n.check){e.msg="incorrect data check",n.mode=30;break}p=0,_=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;_<32;){if(0===h)break e;h--,p+=u[l++]<<_,_+=8}if(p!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}p=0,_=0}n.mode=29;case 29:R=1;break e;case 30:R=-3;break e;case 31:return-4;case 32:default:return-2}return e.next_out=f,e.avail_out=E,e.next_in=l,e.avail_in=h,n.hold=p,n.bits=_,(n.wsize||v!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&b(e,e.output,e.next_out,v-e.avail_out)?(n.mode=31,-4):(O-=e.avail_in,v-=e.avail_out,e.total_in+=O,e.total_out+=v,n.total+=v,n.wrap&&v&&(e.adler=n.check=n.flags?o(n.check,d,v,e.next_out-v):i(n.check,d,v,e.next_out-v)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===O&&0===v||4===t)&&0===R&&(R=-5),R)},n.inflateEnd=function(e){if(!e||!e.state)return-2;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state?0==(2&(n=e.state).wrap)?-2:(n.head=t,t.done=!1,0):-2},n.inflateSetDictionary=function(e,t){var n,r=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?-2:11===n.mode&&i(1,t,r,0)!==n.check?-3:b(e,t,r,r)?(n.mode=31,-4):(n.havedict=1,0):-2},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,n){"use strict";var r=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,c,u,d,l,f){var h,E,p,_,S,b,O,v,C,g=f.bits,A=0,T=0,N=0,y=0,m=0,I=0,M=0,D=0,R=0,P=0,L=null,w=0,U=new r.Buf16(16),j=new r.Buf16(16),F=null,x=0;for(A=0;A<=15;A++)U[A]=0;for(T=0;T<c;T++)U[t[n+T]]++;for(m=g,y=15;y>=1&&0===U[y];y--);if(m>y&&(m=y),0===y)return u[d++]=20971520,u[d++]=20971520,f.bits=1,0;for(N=1;N<y&&0===U[N];N++);for(m<N&&(m=N),D=1,A=1;A<=15;A++)if(D<<=1,(D-=U[A])<0)return-1;if(D>0&&(0===e||1!==y))return-1;for(j[1]=0,A=1;A<15;A++)j[A+1]=j[A]+U[A];for(T=0;T<c;T++)0!==t[n+T]&&(l[j[t[n+T]]++]=T);if(0===e?(L=F=l,b=19):1===e?(L=i,w-=257,F=o,x-=257,b=256):(L=s,F=a,b=-1),P=0,T=0,A=N,S=d,I=m,M=0,p=-1,_=(R=1<<m)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){O=A-M,l[T]<b?(v=0,C=l[T]):l[T]>b?(v=F[x+l[T]],C=L[w+l[T]]):(v=96,C=0),h=1<<A-M,N=E=1<<I;do{u[S+(P>>M)+(E-=h)]=O<<24|v<<16|C|0}while(0!==E);for(h=1<<A-1;P&h;)h>>=1;if(0!==h?(P&=h-1,P+=h):P=0,T++,0==--U[A]){if(A===y)break;A=t[n+l[T]]}if(A>m&&(P&_)!==p){for(0===M&&(M=m),S+=N,D=1<<(I=A-M);I+M<y&&!((D-=U[I+M])<=0);)I++,D<<=1;if(R+=1<<I,1===e&&R>852||2===e&&R>592)return 1;u[p=P&_]=m<<24|I<<16|S-d|0}}return 0!==P&&(u[S+P]=A-M<<24|64<<16|0),f.bits=m,0}},{"../utils/common":1}],10:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,n){"use strict";var r=e("./zlib/inflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),u=e("./zlib/gzheader"),d=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=r.inflateInit2(this.strm,t.windowBits);if(n!==s.Z_OK)throw new Error(a[n]);if(this.header=new u,r.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=o.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=r.inflateSetDictionary(this.strm,t.dictionary))!==s.Z_OK))throw new Error(a[n])}function f(e,t){var n=new l(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}l.prototype.push=function(e,t){var n,a,c,u,l,f=this.strm,h=this.options.chunkSize,E=this.options.dictionary,p=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,"string"==typeof e?f.input=o.binstring2buf(e):"[object ArrayBuffer]"===d.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new i.Buf8(h),f.next_out=0,f.avail_out=h),(n=r.inflate(f,s.Z_NO_FLUSH))===s.Z_NEED_DICT&&E&&(n=r.inflateSetDictionary(this.strm,E)),n===s.Z_BUF_ERROR&&!0===p&&(n=s.Z_OK,p=!1),n!==s.Z_STREAM_END&&n!==s.Z_OK)return this.onEnd(n),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&n!==s.Z_STREAM_END&&(0!==f.avail_in||a!==s.Z_FINISH&&a!==s.Z_SYNC_FLUSH)||("string"===this.options.to?(c=o.utf8border(f.output,f.next_out),u=f.next_out-c,l=o.buf2string(f.output,c),f.next_out=u,f.avail_out=h-u,u&&i.arraySet(f.output,f.output,c,u,0),this.onData(l)):this.onData(i.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(p=!0)}while((f.avail_in>0||0===f.avail_out)&&n!==s.Z_STREAM_END);return n===s.Z_STREAM_END&&(a=s.Z_FINISH),a===s.Z_FINISH?(n=r.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===s.Z_OK):a!==s.Z_SYNC_FLUSH||(this.onEnd(s.Z_OK),f.avail_out=0,!0)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===s.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=l,n.inflate=f,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,f(e,t)},n.ungzip=f},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")},function(e,t){e.exports=a},function(e,t,n){"use strict";n.d(t,"a",(function(){return v}));var r=n(10),i=n(19);class o extends i.a{constructor(e){super(e,"INVALID_INPUT_FOR_SYNC_PREPROCESSOR"),Object.setPrototypeOf(this,o.prototype)}}var s=n(58);class a{process(e){if("string"!=typeof e)throw new o('StringToGzippedString expects input of type "string"');return Object(s.gzip)(e,{to:"string"})}}class c{process(e){if("object"!=typeof e)throw new o('TelemetryEntriesToStringPreprocessor expects input of type "object"');return JSON.stringify(e)}}var u=n(17),d=n(29),l=n(38),f=n.n(l),h=n(33),E=n(11),p=n(3),_=n(0),S=n(22),b=n(50),O=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class v{constructor(e,t,n,r,i,o,s,u,d){this.dbService=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.appInfoService=i,this.deviceRegisterService=o,this.keyValueStore=s,this.apiService=u,this.networkQueue=d,this.preprocessors=[new c,new a],this.telemetryConfig=this.sdkConfig.telemetryConfig,this.apiConfig=this.sdkConfig.apiConfig}resetDeviceRegisterTTL(){return Object(p.zip)(this.keyValueStore.setValue(v.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,""),this.keyValueStore.setValue(v.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,"")).pipe(Object(_.mapTo)(void 0))}handle({ignoreSyncThreshold:e,ignoreAutoSyncMode:t}){const n=!(!e||!t);return this.registerDevice().pipe(Object(_.catchError)(()=>(e=!0,Object(p.of)(void 0))),Object(_.mergeMap)(()=>this.hasTelemetryThresholdCrossed().pipe(Object(_.mergeMap)(t=>t||e?Object(p.defer)(()=>O(this,void 0,void 0,(function*(){switch(yield this.sharedPreferences.getString(E.o.KEY_AUTO_SYNC_MODE).toPromise()){case r.TelemetryAutoSyncModes.OFF:return{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:new Error("AUTO_SYNC_MODE: "+r.TelemetryAutoSyncModes.OFF)};case r.TelemetryAutoSyncModes.OVER_WIFI:if(navigator.connection.type!==Connection.WIFI)return{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:new Error("AUTO_SYNC_MODE: "+r.TelemetryAutoSyncModes.OVER_WIFI)};break;case r.TelemetryAutoSyncModes.ALWAYS_ON:}let e,t={syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0};do{try{e=yield this.processEventsBatch(n).toPromise(),t={syncedEventCount:t.syncedEventCount+e,syncTime:Date.now(),syncedFileSize:0}}catch(e){t={syncedEventCount:t.syncedEventCount,syncTime:Date.now(),syncedFileSize:0,error:e}}}while(e&&!t.error);return t}))):Object(p.of)({syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0})))))}processEventsBatch(e){return this.fetchEvents().pipe(Object(_.mergeMap)(t=>this.processEvents(t).pipe(Object(_.mergeMap)(n=>this.persistinNetworkQueue(n,n.processedEventsSize,e).pipe(Object(_.mergeMap)(()=>this.deleteEvents(t)),Object(_.mapTo)(t.length))))))}registerDevice(){return Object(p.zip)(this.keyValueStore.getValue(v.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY),this.keyValueStore.getValue(v.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY)).pipe(Object(_.mergeMap)(e=>{const t=e[0],n=e[1];if(t&&n){const e="false"===n?v.REGISTER_API_FAILURE_TTL:v.REGISTER_API_SUCCESS_TTL;if(Math.abs(parseInt(t,10)-Date.now())<e)return Object(p.of)(void 0)}return this.deviceRegisterService.registerDevice().pipe(Object(_.tap)(e=>O(this,void 0,void 0,(function*(){e.result.actions.forEach(e=>{"experiment"===e.type&&e.key&&this.sharedPreferences.putString(E.d.DEPLOYMENT_KEY,e.data.key).toPromise()});const t=new Date(e.ts).getTime(),n=Date.now(),i=t-n,o=Math.abs(i)>this.telemetryConfig.telemetryLogMinAllowedOffset?i:0;o&&(yield h.a.log.interact({type:r.InteractType.OTHER,subType:r.InteractSubType.DEVICE_TIME_OFFSET_FOUND,env:"sdk",pageId:"sdk",id:"sdk",valueMap:{deviceTime:n,offsetTime:o}}).toPromise(),yield this.keyValueStore.setValue(v.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY,o+"").toPromise())}))),Object(_.mergeMap)(()=>Object(p.zip)(this.keyValueStore.setValue(v.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),this.keyValueStore.setValue(v.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"true")).pipe(Object(_.mapTo)(void 0))),Object(_.catchError)(e=>Object(p.zip)(this.keyValueStore.setValue(v.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),this.keyValueStore.setValue(v.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"false")).pipe(Object(_.mergeMap)(()=>{throw console.error(e),new Error("Device Registration Failed")}))))}))}hasTelemetryThresholdCrossed(){return this.dbService.execute("\n SELECT count(*) as COUNT FROM "+u.c.TABLE_NAME).pipe(Object(_.map)(e=>!!(e&&e[0]&&e[0].COUNT>=this.telemetryConfig.telemetrySyncThreshold)))}fetchEvents(){return this.dbService.execute(`\n SELECT * FROM ${u.c.TABLE_NAME}\n WHERE ${u.c.COLUMN_NAME_PRIORITY} = (SELECT MIN (${u.c.COLUMN_NAME_PRIORITY})\n FROM ${u.c.TABLE_NAME})\n ORDER BY ${u.c.COLUMN_NAME_TIMESTAMP}\n LIMIT ${this.telemetryConfig.telemetrySyncBandwidth}`)}processEvents(e){if(!e.length)return Object(p.of)({processedEventsSize:0});const t=d.a.generateUniqueId();return Object(p.of)({processedEvents:this.preprocessors.reduce((e,t)=>t.process(e),{id:"ekstep.telemetry",ver:"1.0",ts:f()().format("YYYY-MM-DDTHH:mm:ss[Z]"),events:e.map(e=>JSON.parse(e[u.c.COLUMN_NAME_EVENT])),params:{did:this.deviceInfo.getDeviceID(),msgid:t,key:"",requesterId:""}}),processedEventsSize:e.length,messageId:t})}persistinNetworkQueue({processedEvents:e,messageId:t},n,r){return e?this.networkQueue.enqueue(new b.a(this.sdkConfig).generateNetworkQueueRequest(S.b.TELEMETRY,e,t,n,r),!0).pipe(Object(_.mapTo)(void 0)):Object(p.of)(void 0)}deleteEvents(e){return e.length?this.dbService.execute(`\n DELETE FROM ${u.c.TABLE_NAME}\n WHERE ${u.c._ID} IN (${e.map(e=>e[u.c._ID]).join(",")})\n `):Object(p.of)(void 0)}}v.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY="telemetry_log_min_allowed_offset_key",v.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY="last_synced_device_register_attempt_time_stamp",v.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY="last_synced_device_register_is_successful",v.TELEMETRY_ENDPOINT="/telemetry",v.REGISTER_API_SUCCESS_TTL=864e5,v.REGISTER_API_FAILURE_TTL=36e5},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.circularDependencyToException=t.listMetadataForTarget=t.listRegisteredBindingsForServiceIdentifier=t.getServiceIdentifierAsString=t.getFunctionName=void 0;var r=n(41);function i(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function o(e){if(e.name)return e.name;var t=e.toString(),n=t.match(/^function\s*([^\s(]+)/);return n?n[1]:"Anonymous function: "+t}t.getServiceIdentifierAsString=i,t.listRegisteredBindingsForServiceIdentifier=function(e,t,n){var r="",i=n(e,t);return 0!==i.length&&(r="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=o(e.implementationType)),r=r+"\n "+t,e.constraint.metaData&&(r=r+" - "+e.constraint.metaData)}))),r},t.circularDependencyToException=function e(t){t.childRequests.forEach((function(t){if(function e(t,n){return null!==t.parentRequest&&(t.parentRequest.serviceIdentifier===n||e(t.parentRequest,n))}(t,t.serviceIdentifier)){var n=function(e){return function e(t,n){void 0===n&&(n=[]);var r=i(t.serviceIdentifier);return n.push(r),null!==t.parentRequest?e(t.parentRequest,n):n}(e).reverse().join(" --\x3e ")}(t);throw new Error(r.CIRCULAR_DEPENDENCY+" "+n)}e(t)}))},t.listMetadataForTarget=function(e,t){if(t.isTagged()||t.isNamed()){var n="",r=t.getNamedTag(),i=t.getCustomTags();return null!==r&&(n+=r.toString()+"\n"),null!==i&&i.forEach((function(e){n+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+n}return" "+e},t.getFunctionName=o},function(e,t,n){"use strict";e.exports=TypeError},function(e,t,n){"use strict";var r,i,o,s,a,c,u,d,l,f,h;n.d(t,"h",(function(){return r})),n.d(t,"g",(function(){return i})),n.d(t,"f",(function(){return o})),n.d(t,"d",(function(){return s})),n.d(t,"i",(function(){return a})),n.d(t,"k",(function(){return c})),n.d(t,"j",(function(){return u})),n.d(t,"e",(function(){return E})),n.d(t,"c",(function(){return d})),n.d(t,"b",(function(){return l})),n.d(t,"l",(function(){return f})),n.d(t,"a",(function(){return h})),function(e){e.NOTIFICATION="notification",e.USER="User",e.GROUP="Group",e.CONTENT="Content",e.QUESTION="Question"}(r||(r={})),function(e){e.PLAY="play"}(i||(i={})),function(e){e.NOTIFICATION="notification"}(o||(o={})),function(e){e.TRACE="TRACE",e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL"}(s||(s={})),function(e){e.IN="In",e.OUT="Out"}(a||(a={})),function(e){e.FILE="File",e.MESSAGE="Message",e.LINK="Link"}(c||(c={})),function(e){e.CONTENT="CONTENT",e.EXPLODEDCONTENT="EXPLODEDCONTENT",e.TELEMETRY="TELEMETRY",e.PROFILE="PROFILE"}(u||(u={}));class E{constructor(){this.RECEIVED="Received",this.DISPLAYED="Displayed"}}!function(e){e.TOUCH="TOUCH",e.OTHER="OTHER"}(d||(d={})),function(e){e.NETWORK_SPEED="network-speed",e.SUBTYPE_SPINE="spine",e.ONLINE="online",e.FULL="full",e.CONTENT_VARIANT="content-variant-download",e.DEVICE_TIME_OFFSET_FOUND="device-time-offset-found",e.CONTENT_DOWNLOAD_INITIATE="ContentDownload-Initiate",e.CONTENT_DOWNLOAD_SUCCESS="ContentDownload-Success",e.CONTENT_DOWNLOAD_CANCEL="ContentDownload-Cancel"}(l||(l={})),function(e){e.ERR_DOWNLOAD_FAILED="ERR_DOWNLOAD_FAILED"}(f||(f={})),function(e){e.SYSTEM="SYSTEM"}(h||(h={}))},function(e,t,n){"use strict";n.r(t);var r=n(206);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(291);n.d(t,"FrameworkServiceImpl",(function(){return o.a}));var s=n(207);for(var i in s)["default","FrameworkServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(208);for(var i in a)["default","FrameworkServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(209);for(var i in c)["default","FrameworkServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(i);var u=n(210);for(var i in u)["default","FrameworkServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(i);var d=n(211);for(var i in d)["default","FrameworkServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return d[e]}))}(i);var l=n(212);n.d(t,"FrameworkCategoryCode",(function(){return l.a})),n.d(t,"FrameworkCategoryCodesGroup",(function(){return l.b}));var f=n(213);for(var i in f)["default","FrameworkServiceImpl","FrameworkCategoryCode","FrameworkCategoryCodesGroup"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return f[e]}))}(i);var h=n(214);for(var i in h)["default","FrameworkServiceImpl","FrameworkCategoryCode","FrameworkCategoryCodesGroup"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return h[e]}))}(i);var E=n(294);n.d(t,"FrameworkUtilServiceImpl",(function(){return E.a}));var p=n(216);for(var i in p)["default","FrameworkServiceImpl","FrameworkCategoryCode","FrameworkCategoryCodesGroup","FrameworkUtilServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return p[e]}))}(i)},function(e,t){e.exports=c},function(e,t){e.exports=u},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{constructor(e,t){this.targetDbVersion=t,this.migrationNumber=e}required(e,t){return e<this.targetDbVersion&&this.targetDbVersion<=t}}},function(e,t,n){"use strict";n.r(t);var r=n(114);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(115);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(116);for(var i in s)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(117);for(var i in a)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(292);n.d(t,"DeviceRegisterServiceImpl",(function(){return c.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(49);class i extends r.a{constructor(e){super(e,"PARAM_NOT_CAPTURED"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";var r=n(39);n.d(t,"a",(function(){return r.TrackingEnabled}))},function(e,t,n){"use strict";n.r(t);var r=n(221);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(222);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(223);for(var i in s)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(224);for(var i in a)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(295);n.d(t,"SystemSettingsServiceImpl",(function(){return c.a}))},function(e,t,n){"use strict";n.r(t);var r=n(231);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(232);n.d(t,"PlayerServiceImpl",(function(){return o.a}))},function(e,t,n){"use strict";n.r(t);var r=n(235);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(236);n.d(t,"CodePUshExperimentServiceImpl",(function(){return o.a}))},function(e,t,n){"use strict";n.r(t);var r=n(237);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(296);n.d(t,"FaqServiceImpl",(function(){return o.a}));var s=n(238);for(var i in s)["default","FaqServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(239);for(var i in a)["default","FaqServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(240);for(var i in c)["default","FaqServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(i)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(70);class i extends r.a{constructor(e){super(e,"OBJECT_NOT_FOUND"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.r(t);var r=n(248);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(92);n.d(t,"FetchSegmentationTagHandler",(function(){return o.a}));var s=n(93);n.d(t,"FetchSegmentationCommandHandler",(function(){return s.a}));var a=n(94);n.d(t,"StoreSegmentationTagHandler",(function(){return a.a}));var c=n(95);n.d(t,"StoreSegmentationCommandHandler",(function(){return c.a}));var u=n(249);n.d(t,"SegmentationServiceImpl",(function(){return u.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0);class i{constructor(e){this.keyValueStore=e,this.TAG_KEY="segment-tag_"}handle(e){return this.keyValueStore.getValue(this.TAG_KEY+e).pipe(Object(r.map)(e=>e||null))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0);class i{constructor(e){this.keyValueStore=e,this.COMMAND_KEY="segment-command_"}handle(e){return this.keyValueStore.getValue(this.COMMAND_KEY+e).pipe(Object(r.map)(e=>e||null))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{constructor(e){this.keyValueStore=e,this.TAG_KEY="segment-tag_"}handle(e,t){return this.keyValueStore.setValue(this.TAG_KEY+t,e)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{constructor(e){this.keyValueStore=e,this.COMMAND_KEY="segment-command_"}handle(e,t){return this.keyValueStore.setValue(this.COMMAND_KEY+t,e)}}},function(e,t,n){"use strict";n.r(t);var r=n(250);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(97);n.d(t,"DebuggingDurationHandler",(function(){return o.a}));var s=n(251);n.d(t,"DebuggingServiceImpl",(function(){return s.a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(74),i=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class o{constructor(e,t){this.sharedPreferences=e,this.debuggingServiceImpl=t}handle(e){return i(this,void 0,void 0,(function*(){let t=yield this.sharedPreferences.getString("debug_started_at").toPromise();if(console.log(t),t){let n=setInterval(()=>i(this,void 0,void 0,(function*(){var i=((new Date).getTime()-new Date(parseInt(t)).getTime())/1e3;i/=60,console.log("diff",Math.abs(Math.round(i))),Math.abs(Math.round(i))>=10?(this.sharedPreferences.putString("debug_started_at","").toPromise(),this.debuggingServiceImpl.disableDebugging(),yield this.sharedPreferences.putString(r.CsClientStorage.TRACE_ID,"").toPromise(),e.next(!1),e.complete(),clearInterval(n),this.debuggingServiceImpl.watcher.interval=null,this.debuggingServiceImpl.watcher.observer=null,this.debuggingServiceImpl.watcher.debugStatus=!1):e.next(!0)})),6e4);this.debuggingServiceImpl.watcher.interval=n,this.debuggingServiceImpl.watcher.observer=e,this.debuggingServiceImpl.watcher.debugStatus=!0}else e.next(!1),e.complete()}))}}},function(e,t,n){"use strict";n.r(t);var r=n(252);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(297);n.d(t,"CertificateServiceImpl",(function(){return o.a}));var s=n(253);for(var i in s)["default","CertificateServiceImpl"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"VALIDATION_ERROR"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(3),i=n(0),o=n(22),s=n(50),a=n(29),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(e,t){this.networkQueue=e,this.sdkConfig=t}handle(e){return this.networkQueue.enqueue(new s.a(this.sdkConfig).generateNetworkQueueRequest(o.b.COURSE_PROGRESS,{request:e},a.a.generateUniqueId(),e.contents?e.contents.length:0,!0),!0).pipe(Object(i.mergeMap)(()=>new r.Observable(e=>{sbsync.onSyncSucces(t=>c(this,void 0,void 0,(function*(){const n=t.courseProgressResponse,r=t.course_progress_error;n?e.next(n):r&&e.error(r),e.complete()})),t=>c(this,void 0,void 0,(function*(){e.error(t)})))})))}}u.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update"},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.SAVE="SAVE"}(r||(r={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingOnSyntax=void 0;var r=n(103),i=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new r.BindingWhenSyntax(this._binding)},e}();t.BindingOnSyntax=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingWhenSyntax=void 0;var r=n(102),i=n(123),o=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=i.namedConstraint(e),new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e.target&&!e.target.isNamed()&&!e.target.isTagged()},new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=i.taggedConstraint(e)(t),new r.BindingOnSyntax(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return i.typeConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return i.namedConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(n){return i.taggedConstraint(e)(t)(n.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(n){return i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(n){return!i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e}();t.BindingWhenSyntax=o},function(e,t,n){"use strict";var r=n(342);e.exports=Function.prototype.bind||r},function(e,t,n){"use strict";var r=n(68)("%Object.defineProperty%",!0)||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}e.exports=r},function(e,t,n){"use strict";var r=String.prototype.replace,i=/%20/g,o="RFC1738",s="RFC3986";e.exports={default:s,formatters:{RFC1738:function(e){return r.call(e,i,"+")},RFC3986:function(e){return String(e)}},RFC1738:o,RFC3986:s}},function(e,t){e.exports=d},function(e,t){e.exports=l},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{}r.DATE_TYPE="DATE",r.TEXT_TYPE="TEXT",r.INT_TYPE="INTEGER",r.REAL_TYPE="REAL",r.COMMA_SEP=",",r.SPACE=" ",r.MAX_NUM_OF_EVENTS=1e3,r.MAX_NUM_OF_PROCESSED_EVENTS=1,r.ERROR="DB_ERROR",r.BLOB_TYPE="BLOB",r.NOT_NULL="NOT NULL",r.NULL="NULL"},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{}},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataReader=void 0;var r=n(35),i=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata(r.PARAM_TYPES,e),userGeneratedMetadata:Reflect.getMetadata(r.TAGGED,e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata(r.TAGGED_PROP,e)||[]},e}();t.MetadataReader=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isStackOverflowExeption=void 0;var r=n(41);t.isStackOverflowExeption=function(e){return e instanceof RangeError||e.message===r.STACK_OVERFLOW}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inject=t.LazyServiceIdentifer=void 0;var r=n(41),i=n(35),o=n(47),s=n(56),a=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}();t.LazyServiceIdentifer=a,t.inject=function(e){return function(t,n,a){if(void 0===e)throw new Error(r.UNDEFINED_INJECT_ANNOTATION(t.name));var c=new o.Metadata(i.INJECT_TAG,e);"number"==typeof a?s.tagParameter(t,n,a,c):s.tagProperty(t,n,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Target=void 0;var r=n(35),i=n(65),o=n(47),s=n(313),a=function(){function e(e,t,n,a){this.id=i.id(),this.type=e,this.serviceIdentifier=n,this.name=new s.QueryableString(t||""),this.metadata=new Array;var c=null;"string"==typeof a?c=new o.Metadata(r.NAMED_TAG,a):a instanceof o.Metadata&&(c=a),null!==c&&this.metadata.push(c)}return e.prototype.hasTag=function(e){for(var t=0,n=this.metadata;t<n.length;t++){if(n[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag(r.MULTI_INJECT_TAG)},e.prototype.matchesArray=function(e){return this.matchesTag(r.MULTI_INJECT_TAG)(e)},e.prototype.isNamed=function(){return this.hasTag(r.NAMED_TAG)},e.prototype.isTagged=function(){return this.metadata.some((function(e){return r.NON_CUSTOM_TAG_KEYS.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag(r.OPTIONAL_TAG)(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return e.key===r.NAMED_TAG}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return r.NON_CUSTOM_TAG_KEYS.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag(r.NAMED_TAG)(e)},e.prototype.matchesTag=function(e){var t=this;return function(n){for(var r=0,i=t.metadata;r<i.length;r++){var o=i[r];if(o.key===e&&o.value===n)return!0}return!1}},e}();t.Target=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingWhenOnSyntax=void 0;var r=n(102),i=n(103),o=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new i.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new r.BindingOnSyntax(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingWhenOnSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.typeConstraint=t.namedConstraint=t.taggedConstraint=t.traverseAncerstors=void 0;var r=n(35),i=n(47),o=function(e,t){var n=e.parentRequest;return null!==n&&(!!t(n)||o(n,t))};t.traverseAncerstors=o;var s=function(e){return function(t){var n=function(n){return null!==n&&null!==n.target&&n.target.matchesTag(e)(t)};return n.metaData=new i.Metadata(e,t),n}};t.taggedConstraint=s;var a=s(r.NAMED_TAG);t.namedConstraint=a;t.typeConstraint=function(e){return function(t){var n=null;if(null!==t){if(n=t.bindings[0],"string"==typeof e)return n.serviceIdentifier===e;var r=t.bindings[0].implementationType;return e===r}return!1}}},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.AUTH="AUTH",e.TELEMETRY="TELEMETRY",e.DOWNLOADS="DOWNLOADS",e.CONTENT="CONTENT",e.ERROR="ERROR",e.STORAGE="STORAGE"}(r||(r={}))},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.HTTP_SERVER_ERROR="HTTP_SERVER_ERROR",e.HTTP_CLIENT_ERROR="HTTP_CLIENT_ERROR",e.AUTH_TOKEN_REFRESH_ERROR="AUTH_TOKEN_REFRESH_ERROR",e.PLANNED_MAINTENANCE_PERIOD="PLANNED_MAINTENANCE_PERIOD"}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));class r{}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"c",(function(){return c})),n.d(t,"e",(function(){return u})),n.d(t,"f",(function(){return d})),n.d(t,"g",(function(){return l})),n.d(t,"h",(function(){return f})),n.d(t,"d",(function(){return h})),n.d(t,"k",(function(){return E})),n.d(t,"o",(function(){return p})),n.d(t,"j",(function(){return _})),n.d(t,"l",(function(){return S})),n.d(t,"n",(function(){return b})),n.d(t,"i",(function(){return O})),n.d(t,"b",(function(){return r})),n.d(t,"m",(function(){return i}));var r,i,o=n(78),s=n(30);class a{constructor(){this.type=a.TYPE_USER}}a.TYPE_SYSTEM="System",a.TYPE_USER="User";class c{}class u{constructor(){this.os="",this.make="",this.id="",this.mem=-1,this.idisk=-1,this.edisk=-1,this.scrn=-1,this.cpu="",this.sims=-1,this.cap=[]}}class d{}class l{}class f{}class h{}class E{}class p{}class _{ProducerData(){this.id="",this.pid="",this.ver=""}}class S{}class b{constructor(e,t,n){this.id=e,this.type=t,this.version=n}setRollup(e){this.rollup=e}}class O{}!function(e){e.AUDIT_CREATED="Created",e.AUDIT_UPDATED="Updated",e.AUDIT_DELETED="Deleted"}(r||(r={})),function(e){class t{constructor(e){this.ver=t.TELEMETRY_VERSION,this.eid=e,this.ets=Date.now(),this.actor=new a,this.context=new c,this.edata={}}}t.TELEMETRY_VERSION="3.0",e.Telemetry=t;class n extends t{constructor(e,t,r,i,o,s,a="",c="",u="",d={},l=[]){super(n.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{}),r?{duration:r}:{}),i?{pageid:i}:{}),t?{mode:t}:{}),o?{summaryList:o}:{}),this.context.cdata=l,this.context.env=s,this.object=new b(a,c,u),this.object.rollup=d}}n.EID="END",e.End=n;class r extends t{constructor(e="",t,n,i,o,s,a,c="",u="",d="",l={},f=[]){super(r.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{dspec:t}:{}),n?{loc:n}:{}),i?{mode:i}:{}),o?{mode:i}:{}),s?{pageid:s}:{}),this.context.cdata=f,this.context.env=a,this.object=new b(c,u,d),this.object.rollup=l||{}}}r.EID="START",e.Start=r;class i extends t{constructor(e,t,n,r,o,s,a,c,u,d,l,f,h=[],E="",p="",_="",S={}){super(i.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({type:e,starttime:t,endtime:n,timespent:r,pageviews:o,interactions:s},c?{mode:c}:{}),u?{envsummary:u}:{}),d?{eventsummary:d}:{}),l?{pagesummary:l}:{}),f?{extra:f}:{}),this.context.cdata=h,this.context.env=a,this.object=new b(E,p,_),this.object.rollup=S||{}}}i.EID="SUMMARY",e.Summary=i;class u extends t{constructor(e,t,n,r,i,o,s,a="",c="",d="",l={},f=[]){super(u.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({type:e},{subtype:t}),n?{id:n}:{}),r?{pageid:r}:{}),{extra:Object.assign(Object.assign({},i?{pos:i}:{}),o?{values:[o]}:{})}),this.context.cdata=f,this.context.env=s,this.object=new b(a,c,d),this.object.rollup=l||{}}}u.EID="INTERACT",e.Interact=u;class d extends t{constructor(e,t,n,r,i,o="",s="",a="",c={},u=[]){super(d.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{subtype:t}:{}),n?{pageid:n}:{}),n?{uri:n}:{}),r?{visits:r}:{}),this.context.cdata=u,this.context.env=i,this.object=new b(o||"",s||"",a||""),this.object.rollup=c||{}}}d.EID="IMPRESSION",e.Impression=d;class l extends t{constructor(e,t,n,r,i,o,s){super(l.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{level:t}:{}),n?{message:n}:{}),r?{pageid:r}:{}),i?{params:i}:{}),this.context.env=o;const c=new a;c.type=s,this.actor=c}}l.EID="LOG",e.Log=l;class f extends t{constructor(e,t,n,r){super(f.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({},e?{err:e}:{}),t?{errtype:t}:{}),n?{stacktrace:n}:{}),r?{pageid:r}:{})}}f.EID="ERROR",e.Error=f;class h extends t{constructor(e,t){super(h.EID),this.edata=Object.assign({type:e},t?{pageid:t}:{})}}h.EID="INTERRUPT",e.Interrupt=h;class p extends t{constructor(e,t,n,r=[],i="",o="",s="",a=new E){super(p.EID),this.edata=Object.assign(Object.assign(Object.assign({},e?{dir:e}:{}),t?{type:t}:{}),n?{items:n}:{}),this.context.cdata=r,this.object=new b(i||"",o||"",s||""),this.object.rollup=a}addItem(e,t,n,r,i,a){const c={};if(c.origin=t,c.id=n,c.type=this.capitalize(e.valueOf()),e.valueOf()===o.j.CONTENT.valueOf()||e.valueOf()===o.j.EXPLODEDCONTENT.valueOf()){c.ver=r.toString();const e=[],t={};t.transfers=s.a.parseInt(i),t.size=a,e.push(t),c.params=e}const u={};u.id=t,u.type="Device",c.origin=u,this.edata.items.push(c)}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}p.EID="SHARE",e.Share=p;class _ extends t{constructor(e,t,n,r="",i="",o="",s,a){super(_.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({},e?{rating:e}:{}),s?{commentid:s}:{}),a?{commenttxt:a}:{}),t?{comments:t}:{}),this.context.env=n,this.object=new b(r,i,o),this.object.rollup={}}}_.EID="FEEDBACK",e.Feedback=_;class S extends t{constructor(e,t,n,r,i,o="",s="",a="",c=[],u={}){super(S.EID),this.edata=Object.assign(Object.assign({state:n},r?{props:r}:{}),{type:i}),this.context.cdata=c,this.context.env=e,this.object=new b(o,s,a),this.object.rollup=u||{},this.actor=t}}S.EID="AUDIT",e.Audit=S}(i||(i={}))},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"e",(function(){return r})),n.d(t,"b",(function(){return i})),n.d(t,"f",(function(){return o})),n.d(t,"d",(function(){return s})),n.d(t,"i",(function(){return a})),n.d(t,"j",(function(){return c})),n.d(t,"a",(function(){return u})),n.d(t,"c",(function(){return d})),n.d(t,"g",(function(){return l})),n.d(t,"h",(function(){return f}));class r{constructor(){this.pos=[]}}class i{}class o{}class s{}class a{}class c{}class u{}class d{}class l{}class f{constructor(){this.items=[]}}},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.OFF="OFF",e.OVER_WIFI="OVER_WIFI",e.ALWAYS_ON="ALWAYS_ON"}(r||(r={}))},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.AUTO_MIGRATE_SUCCESS="AUTO_MIGRATE_SUCCESS",e.AUTO_MIGRATE_FAIL="AUTO_MIGRATE_FAIL"}(r||(r={}))},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(48),i=n(57),o=n(25),s=n(71),a=n(61),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u extends a.a{constructor(e,t,n,r){super(o.a.instance.sdkConfig.apiConfig,o.a.instance.apiService,o.a.instance.eventsBusService),this.loginConfig=e,this.autoMergeConfig=t,this.customWebViewConfig=n,this.telemetryService=o.a.instance.telemetryService,this.webviewRunner=r||new i.a}provide(){return c(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return"password"==this.loginConfig.context&&(this.loginConfig.target.path="/recover/identify/account"),this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),"ios"===window.device.platform.toLowerCase()&&"login"===this.loginConfig.context&&(yield e.launchWebview({host:this.loginConfig.target.host,path:"logoff",params:this.loginConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))})),e.launchWebview({host:this.loginConfig.target.host,path:this.loginConfig.target.path,params:this.loginConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))}).then(()=>e.any(...this.loginConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n)),this.resetParams&&"password"==this.loginConfig.context&&e.closeWebview();break;case"state":t.push(this.buildStateSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n,this.customWebViewConfig));break;case"state-error":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.resolveCaptured("error_message").catch(()=>{throw new r.SignInError("Server Error")}).then(e=>{throw new r.SignInError(e)}))));break;case"migrate":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.success()).then(t=>(e.resetInAppBrowserEventListeners(),e.clearCapture().then(()=>new s.a(this.autoMergeConfig,this.webviewRunner,t).provide()))));break;case"reset":t.push(e.capture({host:n.when.host,path:n.when.path,params:[...n.when.params,{key:"client_id",resolveTo:"client_id",match:"portal"},{key:"automerge",resolveTo:"automerge",exists:"false"}]}).then(()=>e.getCaptureExtras().then(t=>(this.resetParams=t,e.closeWebview().then(()=>new Promise(e=>setTimeout(e,500)).then(()=>this.provide()))))))}return t},[])))}))}}},function(e,t,n){"use strict";e.exports=SyntaxError},function(e,t,n){"use strict";var r=n(68)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},function(e,t,n){"use strict";var r=n(106),i=Object.prototype.hasOwnProperty,o=Array.isArray,s=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),a=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:a,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r<t.length;++r)for(var i=t[r],s=i.obj[i.prop],a=Object.keys(s),c=0;c<a.length;++c){var u=a[c],d=s[u];"object"==typeof d&&null!==d&&-1===n.indexOf(d)&&(t.push({obj:s,prop:u}),n.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(o(n)){for(var r=[],i=0;i<n.length;++i)void 0!==n[i]&&r.push(n[i]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n,i,o){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===n)return escape(a).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var c="",u=0;u<a.length;u+=1024){for(var d=a.length>=1024?a.slice(u,u+1024):a,l=[],f=0;f<d.length;++f){var h=d.charCodeAt(f);45===h||46===h||95===h||126===h||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||o===r.RFC1738&&(40===h||41===h)?l[l.length]=d.charAt(f):h<128?l[l.length]=s[h]:h<2048?l[l.length]=s[192|h>>6]+s[128|63&h]:h<55296||h>=57344?l[l.length]=s[224|h>>12]+s[128|h>>6&63]+s[128|63&h]:(f+=1,h=65536+((1023&h)<<10|1023&d.charCodeAt(f)),l[l.length]=s[240|h>>18]+s[128|h>>12&63]+s[128|h>>6&63]+s[128|63&h])}c+=l.join("")}return c},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(o(e)){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)},merge:function e(t,n,r){if(!n)return t;if("object"!=typeof n){if(o(t))t.push(n);else{if(!t||"object"!=typeof t)return[t,n];(r&&(r.plainObjects||r.allowPrototypes)||!i.call(Object.prototype,n))&&(t[n]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(n);var s=t;return o(t)&&!o(n)&&(s=a(t,r)),o(t)&&o(n)?(n.forEach((function(n,o){if(i.call(t,o)){var s=t[o];s&&"object"==typeof s&&n&&"object"==typeof n?t[o]=e(s,n,r):t.push(n)}else t[o]=n})),t):Object.keys(n).reduce((function(t,o){var s=n[o];return i.call(t,o)?t[o]=e(t[o],s,r):t[o]=s,t}),s)}}},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.DELETED_SUCCESSFULLY=1]="DELETED_SUCCESSFULLY"}(r||(r={}))},function(e,t){},function(e,t,n){"use strict";var r,i;n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i})),function(e){e.ASC="asc",e.DESC="desc"}(r||(r={})),function(e){e[e.NOTHING=0]="NOTHING",e[e.PREVIEWED=1]="PREVIEWED",e[e.BOOKMARKED=2]="BOOKMARKED"}(i||(i={}))},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.UPDATE="UPDATE",e.IMPORT_COMPLETED="IMPORT_COMPLETED",e.IMPORT_PROGRESS="IMPORT_PROGRESS",e.SERVER_CONTENT_DATA="SERVER_CONTENT_DATA",e.COURSE_STATE_UPDATED="COURSE_STATE_UPDATED",e.CONTENT_EXTRACT_COMPLETED="CONTENT_EXTRACT_COMPLETED"}(r||(r={}))},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.ONLINE="ONLINE",e.OFFLINE="OFFLINE"}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i}));var r,i,o=n(107);n.d(t,"c",(function(){return o.UserFeedCategory})),n.d(t,"d",(function(){return o.UserFeedStatus})),function(e){e.STUDENT="student",e.TEACHER="teacher",e.ADMIN="administrator",e.PARENT="parent",e.OTHER="other",e.NONE="none"}(r||(r={})),function(e){e.SERVER="server",e.LOCAL="local"}(i||(i={}))},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(29);class i{constructor(e,t){this.uid=e,this.sid=r.a.generateUniqueId(),this.createdTime=Date.now(),this.managedSession=t}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}));class r{}var i;!function(e){e[e.NOT_PLAYED=0]="NOT_PLAYED",e[e.PLAYED=1]="PLAYED"}(i||(i={}))},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.SERVER="server",e.CACHE="cache"}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return S}));var r=n(23),i=n(1),o=n(4),s=n(30),a=n(18),c=n(101),u=n(6),d=n(5),l=n(3),f=n(0),h=n(99),E=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},p=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},_=function(e,t){return function(n,r){t(n,r,e)}};let S=class{constructor(e,t,n,i,o,s){this.dbService=e,this.contenService=t,this.eventsBusService=n,this.courseService=i,this.sharedPreference=o,this.profileService=s,this.summarizerTelemetryHandler=new r.SummaryTelemetryEventHandler(this.courseService,this.sharedPreference,this,this.eventsBusService,this.contenService,this.profileService)}onInit(){return this.eventsBusService.registerObserver({namespace:a.EventNamespace.TELEMETRY,observer:this}),Object(l.of)(void 0)}getDetailsPerQuestion(e){const t=r.SummarizerQueries.getQuetsionDetailsQuery(e.uids,e.contentId,e.qId);return this.dbService.execute(t).pipe(Object(f.map)(e=>r.SummarizerHandler.mapDBEntriesToQuestionDetails(e)))}getLearnerAssessmentDetails(e){const t=r.SummarizerQueries.getDetailReportsQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(f.map)(e=>r.SummarizerHandler.mapDBEntriesToLearnerAssesmentDetails(e)))}getReportByQuestions(e){const t=r.SummarizerQueries.getQuestionReportsQuery(e.uids,e.contentId),n=r.SummarizerQueries.getReportAccuracyQuery(e.uids,e.contentId);return this.dbService.execute(n).pipe(Object(f.map)(e=>r.SummarizerHandler.mapDBEntriesToAccuracy(e)),Object(f.mergeMap)(e=>this.dbService.execute(t).pipe(Object(f.map)(t=>r.SummarizerHandler.mapDBEntriesToQuestionReports(e,t)))))}getReportsByUser(e){const t=r.SummarizerQueries.getReportsByUserQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(f.map)(e=>r.SummarizerHandler.mapDBEntriesToUserReports(e)))}getSummary(e){if(!e.uids)throw new h.a("uids are mandatory");const t=r.SummarizerQueries.getChildProgressQuery(e.uids);return this.getContentCache(e.uids).pipe(Object(f.mergeMap)(e=>this.dbService.execute(t).pipe(Object(f.map)(t=>r.SummarizerHandler.mapDBEntriesToLearnerAssesmentSummary(t,e)))))}getContentCache(e){if(this.contentMap&&Object.keys(this.contentMap).length)return Object(l.of)(this.contentMap);{this.contentMap=new Map;const t={resourcesOnly:!0,primaryCategories:[],uid:e};return this.contenService.getContents(t).pipe(Object(f.map)(e=>(e.forEach(e=>{const t=new r.ContentCache;t.name=e.contentData&&e.contentData.name,t.totalScore=e.contentData&&e.contentData.totalScore,t.lastUsedTime=e.lastUsedTime,t.identifier=e.identifier,this.contentMap.set(e.identifier,t)}),this.contentMap)))}}saveLearnerAssessmentDetails(e){const t=r.SummarizerHandler.mapTelemetryToLearnerAssesmentDetails(e),n=r.SummarizerHandler.mapLearnerAssesmentDetailsToDbEntries(t),i=r.SummarizerQueries.getFilterForLearnerAssessmentDetails(t.qid,t.uid,t.contentId,t.hierarchyData),s=r.SummarizerQueries.getLearnerAssessmentsQuery(i);return this.dbService.execute(s).pipe(Object(f.mergeMap)(e=>e&&e.length?this.dbService.update({table:o.d.TABLE_NAME,selection:r.SummarizerQueries.getUpdateSelection(),selectionArgs:[t.uid,t.contentId,t.hierarchyData?t.hierarchyData:"",t.qid],modelJson:n}).pipe(Object(f.map)(e=>e>0)):t.qid?this.dbService.insert({table:o.d.TABLE_NAME,modelJson:n}).pipe(Object(f.map)(e=>e>0)):Object(l.of)(!1)))}saveLearnerContentSummaryDetails(e){const t=r.SummarizerHandler.mapTelemetryToContentSummaryDetails(e),n=r.SummarizerHandler.mapContentSummaryDetailsToDbEntries(t);return this.dbService.read({table:o.e.TABLE_NAME,selection:r.SummarizerQueries.getLearnerSummaryReadSelection(t.hierarchyData),selectionArgs:[t.uid,t.contentId,t.hierarchyData]}).pipe(Object(f.mergeMap)(e=>e&&e.length?(n.sessions=e[0][o.e.COLUMN_NAME_SESSIONS]+1,n.avg_ts=s.a.toFixed(t.timespent/t.sessions),n.total_ts=t.timespent,n.last_updated_on=t.timestamp,this.dbService.update({table:o.e.TABLE_NAME,selection:r.SummarizerQueries.getLearnerSummaryReadSelection(t.hierarchyData),selectionArgs:[t.uid,t.contentId,t.hierarchyData],modelJson:n}).pipe(Object(f.map)(e=>e>0))):(n.avg_ts=t.timespent,n.sessions=1,n.total_ts=t.timespent,n.last_updated_on=t.timestamp,this.dbService.insert({table:o.e.TABLE_NAME,modelJson:n}).pipe(Object(f.map)(e=>e>0)))))}deletePreviousAssessmentDetails(e,t){return this.dbService.read({table:o.e.TABLE_NAME,selection:`${o.e.COLUMN_NAME_CONTENT_ID} = ? AND ${o.e.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}).pipe(Object(f.mergeMap)(n=>n&&n.length?this.dbService.delete({table:o.e.TABLE_NAME,selection:`${o.e.COLUMN_NAME_CONTENT_ID} = ? AND ${o.e.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}):Object(l.of)(void 0)),Object(f.mergeMap)(()=>this.dbService.read({table:o.d.TABLE_NAME,selection:`${o.d.COLUMN_NAME_CONTENT_ID} = ? AND ${o.d.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]})),Object(f.mergeMap)(n=>n&&n.length?this.dbService.delete({table:o.d.TABLE_NAME,selection:`${o.d.COLUMN_NAME_CONTENT_ID} = ? AND ${o.d.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}):Object(l.of)(void 0)))}onEvent(e){return e.type===c.a.SAVE?this.summarizerTelemetryHandler.handle(e.payload):Object(l.of)(void 0)}};S=E([Object(u.injectable)(),_(0,Object(u.inject)(d.b.DB_SERVICE)),_(1,Object(u.inject)(d.b.CONTENT_SERVICE)),_(2,Object(u.inject)(d.b.EVENTS_BUS_SERVICE)),_(3,Object(u.inject)(d.b.COURSE_SERVICE)),_(4,Object(u.inject)(d.b.SHARED_PREFERENCES)),_(5,Object(u.inject)(d.b.PROFILE_SERVICE)),p("design:paramtypes",[i.DbService,Object,Object,Object,Object,Object])],S)},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i}));class r{}class i{constructor(){this.reportDetailsList=[]}}},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(4),i=n(23),o=n(30);class s{constructor(){}static mapLearnerAssesmentDetailsToDbEntries(e){return{[r.d.COLUMN_NAME_UID]:e.uid,[r.d.COLUMN_NAME_CONTENT_ID]:e.contentId,[r.d.COLUMN_NAME_QID]:e.qid,[r.d.COLUMN_NAME_Q_INDEX]:e.qindex,[r.d.COLUMN_NAME_CORRECT]:e.correct,[r.d.COLUMN_NAME_SCORE]:e.score,[r.d.COLUMN_NAME_TIME_SPENT]:e.timespent,[r.d.COLUMN_NAME_RES]:e.res,[r.d.COLUMN_NAME_TIMESTAMP]:e.timestamp,[r.d.COLUMN_NAME_Q_DESC]:e.qdesc,[r.d.COLUMN_NAME_Q_TITLE]:e.qtitle,[r.d.COLUMN_NAME_MAX_SCORE]:e.maxScore,[r.d.COLUMN_NAME_HIERARCHY_DATA]:e.hierarchyData}}static mapContentSummaryDetailsToDbEntries(e){return{[r.e.COLUMN_NAME_UID]:e.uid,[r.e.COLUMN_NAME_CONTENT_ID]:e.contentId,[r.e.COLUMN_NAME_AVG_TS]:e.avgts,[r.e.COLUMN_NAME_TOTAL_TS]:e.totalts,[r.e.COLUMN_NAME_LAST_UPDATED_ON]:e.lastUpdated,[r.d.COLUMN_NAME_HIERARCHY_DATA]:e.hierarchyData}}static mapDBEntriesToLearnerAssesmentSummary(e,t){return e.map(e=>{const n=t.get(e[r.e.COLUMN_NAME_CONTENT_ID]);return{uid:e[r.e.COLUMN_NAME_UID].toString(),contentId:e[r.e.COLUMN_NAME_CONTENT_ID].toString(),noOfQuestions:o.a.parseInt(e[r.e.COLUMN_NAME_NO_OF_QUESTIONS]),correctAnswers:o.a.parseInt(e[r.e.COLUMN_NAME_CORRECT_ANSWERS]),totalTimespent:Number(e[r.e.COLUMN_NAME_TOTAL_TIME_SPENT]),hierarchyData:e[r.e.COLUMN_NAME_HIERARCHY_DATA].toString(),totalMaxScore:o.a.toFixed(e[r.e.COLUMN_NAME_TOTAL_MAX_SCORE]),totalScore:o.a.toFixed(e[r.e.COLUMN_NAME_TOTAL_SCORE]),totalQuestionsScore:n?n.totalScore:0,name:n?n.name:e[r.e.COLUMN_NAME_CONTENT_ID]}})}static mapDBEntriesToLearnerAssesmentDetails(e){const t=new Map;return e.map(e=>{const n={uid:e[r.d.COLUMN_NAME_UID],contentId:e[r.d.COLUMN_NAME_CONTENT_ID],qid:e[r.d.COLUMN_NAME_QID],qindex:Number(e[r.d.COLUMN_NAME_Q_INDEX]),correct:o.a.parseInt(e[r.d.COLUMN_NAME_CORRECT]),score:o.a.toFixed(e[r.d.COLUMN_NAME_SCORE]),timespent:Number(e[r.d.COLUMN_NAME_TIME_SPENT]),res:e[r.d[r.d.COLUMN_NAME_RES]],timestamp:Number(e[r.d.COLUMN_NAME_TIMESTAMP]),qdesc:e[r.d.COLUMN_NAME_Q_DESC],qtitle:e[r.d.COLUMN_NAME_Q_TITLE],maxScore:o.a.toFixed(e[r.d.COLUMN_NAME_MAX_SCORE]),hierarchyData:e[r.d.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(e[r.d.COLUMN_NAME_TOTAL_TS])};let s=t.get(n.uid);void 0===s&&(s=new i.ReportDetailPerUser,s.uid=n.uid,s.totalScore=0,s.maxTotalScore=0),s.reportDetailsList.push(n),s.totalScore+=n.score,s.totalTime=n.total_ts,s.maxTotalScore+=n.maxScore,s.totalScore=parseFloat(s.totalScore.toFixed(2)),t.set(n.uid,s)}),t}static mapDBEntriesToQuestionReports(e,t){return t.map(t=>{const n=t[r.d.COLUMN_NAME_QID];let i=0;return e.hasOwnProperty(n)&&(i=o.a.parseInt(e[n])),{uid:t[r.d.COLUMN_NAME_UID],contentId:t[r.d.COLUMN_NAME_CONTENT_ID],qid:t[r.d.COLUMN_NAME_QID],qindex:Number(t[r.d.COLUMN_NAME_Q_INDEX]),correct:o.a.parseInt(t[r.d.COLUMN_NAME_CORRECT]),score:o.a.toFixed(t[r.d.COLUMN_NAME_SCORE]),timespent:Number(t[r.d.COLUMN_NAME_TIME_SPENT]),res:t[r.d[r.d.COLUMN_NAME_RES]],timestamp:Number(t[r.d.COLUMN_NAME_TIMESTAMP]),qdesc:t[r.d.COLUMN_NAME_Q_DESC],qtitle:t[r.d.COLUMN_NAME_Q_TITLE],maxScore:o.a.toFixed(t[r.d.COLUMN_NAME_MAX_SCORE]),hierarchyData:t[r.d.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(t[r.d.COLUMN_NAME_TOTAL_TS]),marks:Number(t[r.d.COLUMN_NAME_MARKS]),occurenceCount:t[r.d.COLUMN_NAME_COUNT],sum_max_score:Number(t[r.d.COLUMN_NAME_TOTAL_MAX_SCORE]),correct_users_count:i}})}static mapDBEntriesToAccuracy(e){const t={};return e.map(e=>{t[e[r.d.COLUMN_NAME_QID]]=o.a.parseInt(e[r.d.COLUMN_NAME_USERS_COUNT])}),t}static mapDBEntriesToQuestionDetails(e){return e.map(e=>({uid:e.uid,time:Number(e.time),result:o.a.round(e.result),max_score:o.a.parseInt(e.max_score)}))}static mapDBEntriesToUserReports(e){return e.map(e=>({totalTimespent:Number(e[r.d.COLUMN_NAME_TOTAL_TS]),score:o.a.toFixed(e[r.d.COLUMN_NAME_SCORE]),hData:e[r.d.COLUMN_NAME_HIERARCHY_DATA],contentId:e[r.d.COLUMN_NAME_CONTENT_ID],uid:e[r.d.COLUMN_NAME_UID],userName:e[r.d.COLUMN_NAME_HANDLE],timespent:Number(e[r.d.COLUMN_NAME_TIME_SPENT])}))}static mapTelemetryToContentSummaryDetails(e){const t=e.edata,n=(t.item,e.context.cdata);return{uid:e.actor.id,contentId:e.object.id,timespent:Number(t.duration),timestamp:e.ets,hierarchyData:this.getHierarchyData(n)}}static mapTelemetryToLearnerAssesmentDetails(e){const t=e.edata,n=t.item,r=e.context.cdata;return{uid:e.actor.id,contentId:e.object.id,qid:n&&n.id,qindex:Number(t.index),correct:"Yes"===t.pass?1:0,score:Number(t.score),timespent:Number(t.duration),timestamp:e.ets,res:JSON.stringify(t.resvalues),qdesc:n&&n.desc,qtitle:n&&n.title,maxScore:n&&Number(n.maxscore),hierarchyData:this.getHierarchyData(r)}}static getHierarchyData(e){let t="";return e&&e.forEach(e=>{if("Collection"===e.type||"TextBook"===e.type)return t=e.id}),""}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(4),i=n(14);class o{static getChildProgressQuery(e){return`SELECT ${r.d.COLUMN_NAME_UID}, ${r.d.COLUMN_NAME_CONTENT_ID},\n COUNT (${r.d.COLUMN_NAME_QID}) AS no_of_questions,\n SUM (${r.d.COLUMN_NAME_CORRECT}) AS correct_answers,\n SUM (${r.d.COLUMN_NAME_TIME_SPENT}) AS total_time_spent, h_data ,\n SUM (${r.d.COLUMN_NAME_MAX_SCORE}) AS total_max_score,\n SUM (${r.d.COLUMN_NAME_SCORE}) AS total_score\n FROM ${r.d.TABLE_NAME}\n WHERE ${r.d.COLUMN_NAME_UID} IN (${i.a.joinPreservingQuotes(e)})\n GROUP BY ${r.d.COLUMN_NAME_CONTENT_ID} `}static getDetailReportsQuery(e,t){return`SELECT *, lcs.${r.e.COLUMN_NAME_TOTAL_TS}\n FROM ${r.d.TABLE_NAME} la\n LEFT JOIN ${r.e.TABLE_NAME} lcs\n ON (la.${r.e.COLUMN_NAME_UID} = lcs.${r.d.COLUMN_NAME_UID})\n AND la.${r.e.COLUMN_NAME_CONTENT_ID} = lcs.${r.d.COLUMN_NAME_CONTENT_ID}\n WHERE la.${r.d.COLUMN_NAME_UID} IN(${i.a.joinPreservingQuotes(e)})\n AND la.${r.d.COLUMN_NAME_CONTENT_ID}='${t}'`}static getReportsByUserQuery(e,t){return`SELECT lcs.${r.e.COLUMN_NAME_TOTAL_TS},\n SUM (${r.d.COLUMN_NAME_SCORE}) AS score,\n la.${r.d.COLUMN_NAME_HIERARCHY_DATA},la.${r.d.COLUMN_NAME_CONTENT_ID},\n la.${r.d.COLUMN_NAME_UID},p.${r.f.COLUMN_NAME_HANDLE},\n la.${r.d.COLUMN_NAME_TIME_SPENT}\n FROM ${r.d.TABLE_NAME} la\n LEFT JOIN ${r.e.TABLE_NAME} lcs\n ON (la.${r.e.COLUMN_NAME_UID} = lcs.${r.d.COLUMN_NAME_UID})\n LEFT JOIN ${r.f.TABLE_NAME} p\n ON (la.${r.d.COLUMN_NAME_UID} = p.${r.f.COLUMN_NAME_UID})\n WHERE la.${r.d.COLUMN_NAME_UID} IN(${i.a.joinPreservingQuotes(e)})\n AND la.${r.d.COLUMN_NAME_CONTENT_ID}='${t}'\n GROUP BY la.${r.d.COLUMN_NAME_UID}`}static getQuetsionDetailsQuery(e,t,n){return`SELECT ${r.d.COLUMN_NAME_UID}, ${r.d.COLUMN_NAME_TIME_SPENT} as time,\n ${r.d.COLUMN_NAME_SCORE} as result,\n ${r.d.COLUMN_NAME_MAX_SCORE} as max_score\n FROM ${r.d.TABLE_NAME}\n WHERE ${r.d.COLUMN_NAME_UID} IN(${i.a.joinPreservingQuotes(e)})\n AND ${r.d.COLUMN_NAME_CONTENT_ID}='${t}'\n AND ${r.d.COLUMN_NAME_QID}='${n}'`}static getReportAccuracyQuery(e,t){return`SELECT ${r.d.COLUMN_NAME_QID}, COUNT (*) as users_count\n FROM ${r.d.TABLE_NAME}\n WHERE ${r.d.COLUMN_NAME_UID} IN(${i.a.joinPreservingQuotes(e)})\n AND ${r.d.COLUMN_NAME_CONTENT_ID}='${t}'\n AND ${r.d.COLUMN_NAME_SCORE} > 0\n GROUP BY ${r.d.COLUMN_NAME_QID}`}static getQuestionReportsQuery(e,t){return`SELECT *, SUM(${r.d.COLUMN_NAME_SCORE}) as marks,\n COUNT (${r.d.COLUMN_NAME_Q_INDEX}) as occurence_count,\n SUM (${r.d.COLUMN_NAME_MAX_SCORE}) as sum_max_score\n FROM ${r.d.TABLE_NAME}\n WHERE ${r.d.COLUMN_NAME_UID} IN(${i.a.joinPreservingQuotes(e)})\n AND ${r.d.COLUMN_NAME_CONTENT_ID}='${t}'\n GROUP BY ${r.d.COLUMN_NAME_QID}`}static getFilterForLearnerAssessmentDetails(e,t,n,i){const o=`${r.d.COLUMN_NAME_QID} = '${e}'`;return`WHERE ${`${r.d.COLUMN_NAME_UID} = '${t}'`} AND ${`${r.d.COLUMN_NAME_CONTENT_ID} = '${n}'`} AND ${`${r.d.COLUMN_NAME_HIERARCHY_DATA} = '${i||""}'`} ${e?" AND "+o:""}`}static getLearnerAssessmentsQuery(e){return`SELECT * from ${r.d.TABLE_NAME} ${e}\n ORDER BY ${r.d.COLUMN_NAME_Q_INDEX}`}static getUpdateSelection(){return r.d.COLUMN_NAME_UID+" = ? AND "+r.d.COLUMN_NAME_CONTENT_ID+" = ? AND "+r.d.COLUMN_NAME_HIERARCHY_DATA+" = ? AND "+r.d.COLUMN_NAME_QID+" = ? "}static getLearnerSummaryReadSelection(e){return r.d.COLUMN_NAME_UID+" = ? AND "+r.d.COLUMN_NAME_CONTENT_ID+" = ? AND "+r.d.COLUMN_NAME_HIERARCHY_DATA+" = ? "}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return S}));var r=n(10),i=n(34),o=n(11),s=n(18),a=n(9),c=n(15),u=n(3),d=n(0),l=n(300),f=n(33),h=n(63),E=n(39),p=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class _{constructor(e){this.contentService=e}provide(e,t){return e.objectType=_.getCategoryMapper(t),this.trackableSessionContentCache?Object(u.iif)(()=>!!this.trackableSessionContentCache[e.contentId],Object(u.defer)(()=>Object(u.of)(this.trackableSessionContentCache[e.contentId])),Object(u.defer)(()=>this.contentService.getContentDetails(e).pipe(Object(d.tap)(t=>this.trackableSessionContentCache[e.contentId]=t)))):this.contentService.getContentDetails(e)}cache(e){this.trackableSessionContentCache&&(this.trackableSessionContentCache[e.identifier]=e)}init(){this.trackableSessionContentCache={}}dispose(){this.trackableSessionContentCache=void 0}static getCategoryMapper(e){switch(e){case h.CsPrimaryCategory.PRACTICE_QUESTION_SET:return"QuestionSet";case"Multiple Choice Question":return"Question"}}}class S{constructor(e,t,n,r,i,o){this.courseService=e,this.sharedPreference=t,this.summarizerService=n,this.eventBusService=r,this.contentService=i,this.profileService=o,this.currentUID=void 0,this.currentContentID=void 0,this.courseContext={},this.trackableSessionProxyContentProvider=new _(this.contentService)}static checkPData(e){return null!=e&&null!==e.pid&&-1!==e.pid.indexOf(S.CONTENT_PLAYER_PID)}static isContentTrackable(e){return!!e.contentData.trackable&&e.contentData.trackable.enabled===E.TrackingEnabled.YES}static isCourseAssessmentContent(e){return e.primaryCategory&&e.primaryCategory.toLowerCase()===h.CsPrimaryCategory.COURSE_ASSESSMENT.toLowerCase()}updateContentState(e){return this.getCourseContext().pipe(Object(d.mergeMap)(t=>{const n=t.userId,r=t.courseId,o=t.batchId;let c=0;t.hasOwnProperty("batchStatus")&&(c=t.batchStatus);if(1===c){const c=e.object.id;return this.checkStatusOfContent(n,r,o,c).pipe(Object(d.mergeMap)(f=>{if("START"===e.eid&&0===f){const e={userId:n,contentId:c,courseId:r,batchId:o,status:1,progress:5};return this.courseService.updateContentState(e).pipe(Object(d.mapTo)(void 0))}return"END"===e.eid&&0===f||"END"===e.eid&&1===f?this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).pipe(Object(d.mergeMap)(c=>this.validEndEvent(e,c,t).pipe(Object(d.mergeMap)(t=>{if(t){const t=l.CsContentProgressCalculator.calculate(e.edata.summary,c.mimeType),u={userId:n,contentId:c.identifier,courseId:r,batchId:o,status:100===t?2:1,progress:t,target:S.isCourseAssessmentContent(c)?[i.UpdateContentStateTarget.LOCAL]:[i.UpdateContentStateTarget.LOCAL,i.UpdateContentStateTarget.SERVER]};return this.generateAuditTelemetry(n,r,o,c,e.object?e.object.rollup:{}),this.courseService.updateContentState(u).pipe(Object(d.tap)(()=>{this.eventBusService.emit({namespace:s.EventNamespace.CONTENT,event:{type:a.ContentEventType.COURSE_STATE_UPDATED,payload:{contentId:u.courseId}}})}),Object(d.mapTo)(void 0))}return Object(u.of)(void 0)})))):Object(u.of)(void 0)}),Object(d.tap)(()=>{this.updateLastReadContentId(n,r,o,c).toPromise()}))}return Object(u.of)(void 0)}))}handle(e){return Object(u.defer)(()=>p(this,void 0,void 0,(function*(){if("START"===e.eid){if(S.checkPData(e.context.pdata))return this.courseService.resetCapturedAssessmentEvents(),this.processOEStart(e).pipe(Object(d.tap)(()=>p(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerAssessmentDetails(e).pipe(Object(d.mapTo)(void 0)).toPromise()}))),Object(d.tap)(()=>p(this,void 0,void 0,(function*(){yield this.getCourseContext().pipe(Object(d.mergeMap)(()=>this.updateContentState(e))).toPromise()}))),Object(d.tap)(()=>p(this,void 0,void 0,(function*(){yield this.markContentAsPlayed(e).toPromise()})))).toPromise();if(e.object&&e.object.id){const t=yield this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).toPromise();if(S.isContentTrackable(t))return this.trackableSessionProxyContentProvider.init(),this.trackableSessionProxyContentProvider.cache(t),this.getCourseContext().pipe(Object(d.mapTo)(void 0)).toPromise()}}else{if("ASSESS"===e.eid&&S.checkPData(e.context.pdata))return this.processOEAssess(e).pipe(Object(d.tap)(()=>p(this,void 0,void 0,(function*(){const t=yield this.getCourseContext().toPromise();e.context.cdata.find(e=>"AttemptId"===e.type)&&t.userId&&t.courseId&&t.batchId&&(yield this.courseService.captureAssessmentEvent({event:e,courseContext:t}))}))),Object(d.tap)(()=>p(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerAssessmentDetails(e).pipe(Object(d.mapTo)(void 0)).toPromise()})))).toPromise();if("END"===e.eid){if(S.checkPData(e.context.pdata))return this.processOEEnd(e).pipe(Object(d.tap)(()=>p(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerContentSummaryDetails(e).pipe(Object(d.mapTo)(void 0)).toPromise()}))),Object(d.tap)(()=>p(this,void 0,void 0,(function*(){yield this.getCourseContext().pipe(Object(d.mergeMap)(()=>this.updateContentState(e))).toPromise()})))).toPromise();if(e.object&&e.object.id){const t=yield this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).toPromise();if(S.isContentTrackable(t))return this.trackableSessionProxyContentProvider.dispose(),this.setCourseContextEmpty().toPromise()}}}})))}setCourseContextEmpty(){return this.courseContext={},this.sharedPreference.putString(o.f.COURSE_CONTEXT,"")}validEndEvent(e,t,n){const r=()=>n&&(S.isCourseAssessmentContent(t)||t.contentType&&"onboardingresource"===t.contentType.toLowerCase()||t.primaryCategory&&"onboardingresource"===t.primaryCategory.toLowerCase())&&this.courseService.hasCapturedAssessmentEvent({courseContext:n});return Object(u.defer)(()=>Object(u.of)(void 0)).pipe(Object(d.delay)(2e3),Object(d.map)(()=>!r()&&(e.edata.summary&&!!e.edata.summary.find(e=>e.progress))),Object(d.tap)(()=>this.courseService.resetCapturedAssessmentEvents()))}updateLastReadContentId(e,t,n,r){const o=i.CourseServiceImpl.LAST_READ_CONTENTID_PREFIX.concat("_").concat(e).concat("_").concat(t).concat("_").concat(n);return this.sharedPreference.putString(o,r)}markContentAsPlayed(e){const t=e.actor.id,n=e.object.id,r={contentId:n};return this.trackableSessionProxyContentProvider.provide(r,e.object.type).pipe(Object(d.mergeMap)(e=>{const r={status:c.ContentAccessStatus.PLAYED,contentId:n,contentType:e.contentType||e.primaryCategory};return this.profileService.addContentAccess(r).pipe(Object(d.mergeMap)(()=>{const r={uid:t,contentId:n,data:JSON.stringify(e.contentData),marker:a.MarkerType.PREVIEWED,isMarked:!0,extraInfo:{}};return this.contentService.setContentMarker(r).pipe(Object(d.mapTo)(!0))}))}))}getCourseContext(){return this.sharedPreference.getString(o.f.COURSE_CONTEXT).pipe(Object(d.map)(e=>e?JSON.parse(e):{}))}checkStatusOfContent(e,t,n,r){const i={userId:e,batchId:n,contentIds:[r],courseId:t};return this.courseService.getContentState(i).pipe(Object(d.map)(e=>{const t=e&&e.contentList;return this.getStatus(t,r)}))}getStatus(e=[],t){const n=e.find(e=>e.contentId===t);return n&&n.status||0}processOEStart(e){return this.currentUID=e.actor.id,this.currentContentID=e.object.id,Object(u.of)(void 0)}processOEAssess(e){return this.currentUID&&this.currentContentID&&this.currentUID.toLocaleLowerCase()===e.actor.id.toLocaleLowerCase()&&this.currentContentID.toLocaleLowerCase()===e.object.id.toLocaleLowerCase()?this.summarizerService.deletePreviousAssessmentDetails(this.currentUID,this.currentContentID).pipe(Object(d.tap)(()=>{this.currentUID=void 0,this.currentContentID=void 0}),Object(d.mapTo)(void 0)):Object(u.of)(void 0)}processOEEnd(e){return Object(u.of)(void 0)}generateAuditTelemetry(e,t,n,i,o){const s=new r.Actor;s.id=e,s.type=r.Actor.TYPE_USER;const a=[{type:"CourseId",id:t||""},{type:"BatchId",id:n||""},{type:"UserId",id:e||""},{type:"ContentId",id:i.identifier||""}],c={env:"course",actor:s,currentState:r.AuditState.AUDIT_UPDATED,updatedProperties:["progress"],objId:i.identifier,objType:i.contentData.contentType||"",objVer:i.contentData.pkgVersion||"",rollUp:o||{},correlationData:a,type:"content-progress"};f.a.log.audit(c).toPromise()}}S.CONTENT_PLAYER_PID="contentplayer"},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.START="START",e.PROGRESS="PROGRESS",e.END="END"}(r||(r={}))},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e[e.STATUS_FAILED=16]="STATUS_FAILED",e[e.STATUS_PAUSED=4]="STATUS_PAUSED",e[e.STATUS_PENDING=1]="STATUS_PENDING",e[e.STATUS_RUNNING=2]="STATUS_RUNNING",e[e.STATUS_SUCCESSFUL=8]="STATUS_SUCCESSFUL"}(r||(r={}))},function(e,t){},function(e,t){},function(e,t,n){var r;e.exports=(r=r||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},i=r.lib={},o=i.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)t[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],i=function(t){t=t;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=i(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},d=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var d=0;d<c;d+=o)this._doProcessBlock(r,d);var l=r.splice(0,c);n.sigBytes-=u}return new s.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(i.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new f.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r,i,o;n.d(t,"c",(function(){return r})),n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return o})),function(e){e.LOCAL="LOCAL",e.SERVER="SERVER"}(r||(r={})),function(e){e.OPEN="open",e.INVITE_ONLY="invite-only"}(i||(i={})),function(e){e.NOT_STARTED="0",e.IN_PROGRESS="1",e.COMPLETED="2"}(o||(o={}))},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e,t){super(e,"CERTIFICATE_ALREADY_DOWNLOADED"),this.filePath=t,Object.setPrototypeOf(this,i.prototype)}}},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"NO_ACTIVE_SESSION"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"NO_PROFILE_FOUND"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return i})),function(e){e.BOARD="board",e.MEDIUM="medium",e.GRADE_LEVEL="gradeLevel",e.SUBJECT="subject",e.TOPIC="topic",e.PURPOSE="purpose"}(r||(r={}));class i{}i.DEFAULT_FRAMEWORK_CATEGORIES=[r.BOARD,r.MEDIUM,r.GRADE_LEVEL,r.SUBJECT],i.COURSE_FRAMEWORK_CATEGORIES=[r.TOPIC,r.PURPOSE,r.MEDIUM,r.GRADE_LEVEL,r.SUBJECT]},function(e,t){},function(e,t){},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(51);function i(e,t,n){for(var i=n||r.defaultEquals,o=e.length,s=0;s<o;s++)if(i(e[s],t))return s;return-1}t.indexOf=i,t.lastIndexOf=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length-1;o>=0;o--)if(i(e[o],t))return o;return-1},t.contains=function(e,t,n){return i(e,t,n)>=0},t.remove=function(e,t,n){var r=i(e,t,n);return!(r<0)&&(e.splice(r,1),!0)},t.frequency=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length,s=0,a=0;a<o;a++)i(e[a],t)&&s++;return s},t.equals=function(e,t,n){var i=n||r.defaultEquals;if(e.length!==t.length)return!1;for(var o=e.length,s=0;s<o;s++)if(!i(e[s],t[s]))return!1;return!0},t.copy=function(e){return e.concat()},t.swap=function(e,t,n){if(t<0||t>=e.length||n<0||n>=e.length)return!1;var r=e[t];return e[t]=e[n],e[n]=r,!0},t.toString=function(e){return"["+e.toString()+"]"},t.forEach=function(e,t){for(var n=0,r=e;n<r.length;n++){if(!1===t(r[n]))return}}},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.RESOURCE="Resource",e.COURSE="Course",e.ANONYMOUS_COURSE="AnonymousCourse",e.DIAL_CODE="DIAL Code Consumption"}(r||(r={}))},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.INTERNAL_STORAGE="INTERNAL_STORAGE",e.EXTERNAL_STORAGE="EXTERNAL_STORAGE"}(r||(r={}))},function(e,t){},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.TRANSFER_PROGRESS="TRANSFER_PROGRESS",e.TRANSFER_COMPLETED="TRANSFER_COMPLETED",e.TRANSFER_REVERT_COMPLETED="TRANSFER_REVERT_COMPLETED",e.TRANSFER_FAILED_DUPLICATE_CONTENT="TRANSFER_FAILED_DUPLICATE_CONTENT",e.TRANSFER_FAILED_LOW_MEMORY="TRANSFER_FAILED_LOW_MEMORY"}(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",(function(){return r})),function(e){e.IGNORE="IGNORE",e.KEEP_HIGER_VERSION="KEEP_HIGER_VERSION",e.KEEP_LOWER_VERSION="KEEP_LOWER_VERSION",e.KEEP_SOURCE="KEEP_SOURCE",e.KEEP_DESTINATION="KEEP_DESTINATION"}(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"TRANSFER_FAILED_DUPLICATE_CONTENT_ERROR"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e,t){super(e,"TRANSFER_FAILED_ERROR"),this.directory=t,Object.setPrototypeOf(this,i.prototype)}}},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return p}));var r=n(10),i=n(8),o=n(6),s=n(5),a=n(3),c=n(0),u=n(1),d=n(28),l=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},f=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},h=function(e,t){return function(n,r){t(n,r,e)}},E=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let p=class{constructor(e,t,n,r,i,o,s){this.profileService=e,this.groupService=t,this.config=n,this.frameworkService=r,this.deviceInfo=i,this.appInfo=o,this.dbService=s}getPlayerConfig(e,t){const n={};n.did=this.deviceInfo.getDeviceID(),n.origin=this.config.apiConfig.host;const o=new r.ProducerData;o.id=this.config.apiConfig.api_authentication.producerId,o.pid=this.config.apiConfig.api_authentication.producerUniqueId,o.ver=this.appInfo.getVersionName(),n.pdata=o;const s={};return e.rollup=i.a.getRollup(e.identifier,e.hierarchyInfo),n.objectRollup=e.rollup,"ios"===window.device.platform.toLowerCase()?e.basePath=(e.basePath||(e.basePath="")).replace(/\/$/,""):e.basePath=e.basePath.replace(/\/$/,""),e.isAvailableLocally&&(e.contentData.streamingUrl=e.basePath,e.contentData.previewUrl=e.basePath),s.metadata=e,s.config=this.config.playerConfig,this.profileService.getActiveProfileSession().pipe(Object(c.mergeMap)(t=>{n.sid=t?t.sid:"";const i=new r.Actor;i.id=t?t.uid:"",n.actor=i;const o=this.config.appConfig.deepLinkBasePath;n.deeplinkBasePath=o||"";const a=e.rollup&&e.rollup.l1?e.rollup.l1:e.identifier;return this.fetchPlayerState(i.id,a,e.identifier).then(e=>{e&&s.config&&(s.config=Object.assign(Object.assign({},s.config),JSON.parse(e.saveState)))}),this.profileService.getActiveSessionProfile({requiredFields:[]})}),Object(c.mergeMap)(e=>{if(e&&e.serverProfile){const t=e.serverProfile.organisations;if(t){const e=t[0]&&t[0].organisationId;n.contextRollup={l1:e}}}return e&&e.profileType&&(t.correlationData=(t.correlationData||[]).concat([{id:e.profileType,type:"UserType"}])),this.groupService.getActiveGroupSession()}),Object(c.mergeMap)(e=>{let r=[];e&&e.gid&&r.push({id:e.gid,type:"group"});const i=t&&t.hasOwnProperty("streaming"),o=t.correlationData;o&&o.length&&(r=r.concat(o)),r.push({id:i?"streaming":"offline",type:"PlayerLaunch"}),n.cdata=r,s.context=n;const a={local:!0,server:!1};return a.groupId=e?e.gid:"",s.appContext=a,this.frameworkService.getActiveChannelId()}),Object(c.mergeMap)(e=>(n.channel=e||this.config.apiConfig.api_authentication.channelId,s.context=n,Object(a.of)(s))))}savePlayerState(e,t,n,r){return this.dbService.read({table:d.a.TABLE_NAME,selection:`${d.a.COLUMN_NAME_USER_ID} = ? AND ${d.a.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${d.a.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise().then(i=>E(this,void 0,void 0,(function*(){return i&&i.length?this.dbService.update({table:d.a.TABLE_NAME,selection:`${d.a.COLUMN_NAME_USER_ID} = ? AND ${d.a.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${d.a.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n],modelJson:d.b.mapPlayerStateToPlayerDbEntry(e,t,n,r)}).toPromise():this.dbService.insert({table:d.a.TABLE_NAME,modelJson:d.b.mapPlayerStateToPlayerDbEntry(e,t,n,r)}).toPromise()})))}fetchPlayerState(e,t,n){return this.dbService.read({table:d.a.TABLE_NAME,selection:`${d.a.COLUMN_NAME_USER_ID} = ? AND ${d.a.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${d.a.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise().then(e=>e&&e[0]&&d.b.mapPlayerDbEntryToPlayer(e[0]))}deletePlayerSaveState(e,t,n){return this.dbService.delete({table:d.a.TABLE_NAME,selection:`${d.a.COLUMN_NAME_USER_ID} =? AND ${d.a.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${d.a.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise()}};p=l([Object(o.injectable)(),h(0,Object(o.inject)(s.b.PROFILE_SERVICE)),h(1,Object(o.inject)(s.b.GROUP_SERVICE_DEPRECATED)),h(2,Object(o.inject)(s.b.SDK_CONFIG)),h(3,Object(o.inject)(s.b.FRAMEWORK_SERVICE)),h(4,Object(o.inject)(s.b.DEVICE_INFO)),h(5,Object(o.inject)(s.b.APP_INFO)),h(6,Object(o.inject)(s.b.DB_SERVICE)),f("design:paramtypes",[Object,Object,Object,Object,Object,Object,u.DbService])],p)},function(e,t,n){"use strict";var r,i;n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return i})),function(e){e[e.ACTIONABLE_NOTIFICATION=1]="ACTIONABLE_NOTIFICATION",e[e.NOTIFY=2]="NOTIFY",e[e.CONFIG=3]="CONFIG"}(r||(r={})),function(e){e.READ="read",e.UNREAD="unread",e.ALL="all"}(i||(i={}))},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var r=n(6),i=n(5),o=n(11),s=n(0),a=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},c=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=function(e,t){return function(n,r){t(n,r,e)}};let d=class{constructor(e){this.sharedPreferences=e}setDefaultDeploymentKey(e){return this.sharedPreferences.putString(o.e.DEFAULT_DEPLOYMENT_KEY,e)}getDefaultDeploymentKey(){return this.sharedPreferences.getString(o.e.DEFAULT_DEPLOYMENT_KEY)}setExperimentKey(e){return this.sharedPreferences.putString(o.e.EXPERIMENT_KEY,e).pipe(Object(s.tap)(()=>{this.experimentKey||(this.experimentKey=e)}))}getExperimentKey(){return this.experimentKey?this.experimentKey:this.sharedPreferences.getString(o.e.EXPERIMENT_KEY).pipe(Object(s.tap)(e=>(this.experimentKey=e,e)))}setExperimentAppVersion(e){return this.sharedPreferences.putString(o.e.EXPERIMENT_APP_VERSION,e)}getExperimentAppVersion(){return this.sharedPreferences.getString(o.e.EXPERIMENT_APP_VERSION)}};d=a([Object(r.injectable)(),u(0,Object(r.inject)(i.b.SHARED_PREFERENCES)),c("design:paramtypes",[Object])],d)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(29);class i{constructor(e){this._gid=e,this._sid=r.a.generateUniqueId(),this._createdTime=Date.now()}get gid(){return this._gid}get sid(){return this._sid}get createdTime(){return this._createdTime}}},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"NO_GROUP_FOUND"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(19);class i extends r.a{constructor(e){super(e,"NO_ACTIVE_SESSION"),Object.setPrototypeOf(this,i.prototype)}}},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var r=n(6),i=n(5),o=n(93),s=n(92),a=n(95),c=n(94),u=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},d=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},l=function(e,t){return function(n,r){t(n,r,e)}};let f=class{constructor(e){this.keyValueStore=e}saveTags(e,t){return new c.a(this.keyValueStore).handle(e,t)}getTags(e){return new s.a(this.keyValueStore).handle(e)}removeTagsForId(e){throw new Error("Method not implemented.")}clearAllTags(){throw new Error("Method not implemented.")}saveCommandList(e,t){return new a.a(this.keyValueStore).handle(e,t)}getCommand(e){return new o.a(this.keyValueStore).handle(e)}};f=u([Object(r.injectable)(),l(0,Object(r.inject)(i.b.KEY_VALUE_STORE)),d("design:paramtypes",[Object])],f)},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var r=n(6),i=n(3),o=n(5),s=n(97),a=n(74),c=n(36),u=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},d=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},l=function(e,t){return function(n,r){t(n,r,e)}},f=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let h=class{constructor(e,t){this.sharedPreferences=e,this.profileService=t,this.watcher={interval:null,observer:null,debugStatus:!1}}set userId(e){this._userId=e}get userId(){return this._userId}set deviceId(e){this._deviceId=e}get deviceId(){return this._deviceId}enableDebugging(e){return new i.Observable(t=>{this.profileService.getActiveProfileSession().toPromise().then(n=>f(this,void 0,void 0,(function*(){if(null==n?void 0:n.uid){this._userId=n.uid;const r=yield c.a.createJWTToken(this._deviceId,this.userId);e?yield this.sharedPreferences.putString(a.CsClientStorage.TRACE_ID,e).toPromise():yield this.sharedPreferences.putString(a.CsClientStorage.TRACE_ID,r).toPromise(),new s.a(this.sharedPreferences,this).handle(t),console.log("Watcher Value:",this.watcher)}})))})}disableDebugging(){return this.watcher.debugStatus?(clearTimeout(this.watcher.interval),this.watcher.observer.complete(),this.watcher={interval:null,observer:null,debugStatus:!1},this.sharedPreferences.putString("debug_started_at","").toPromise(),this.sharedPreferences.putString(a.CsClientStorage.TRACE_ID,"").toPromise(),Object(i.of)(!0)):Object(i.of)(!1)}isDebugOn(){return!!this.watcher.debugStatus}};h=u([Object(r.injectable)(),l(0,Object(r.inject)(o.b.SHARED_PREFERENCES)),l(1,Object(r.inject)(o.b.PROFILE_SERVICE)),d("design:paramtypes",[Object,Object])],h)},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(61),i=n(25),o=n(57),s=n(48),a=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class c extends r.a{constructor(e,t){super(i.a.instance.sdkConfig.apiConfig,i.a.instance.apiService,i.a.instance.eventsBusService),this.manualMergeConfig=e,this.telemetryService=i.a.instance.telemetryService,this.webviewRunner=t||new o.a}provide(){return a(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.manualMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),e.launchWebview({host:this.manualMergeConfig.target.host,path:this.manualMergeConfig.target.path,params:this.manualMergeConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),{})}).then(()=>e.any(...this.manualMergeConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n));break;case"exit":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.clearCapture().then(()=>a(this,void 0,void 0,(function*(){throw new s.InterruptError("EXIT param found")}))))))}return t},[])))}))}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(49);class i extends r.a{constructor(e){super(e,"INTERRUPT_ERROR"),Object.setPrototypeOf(this,r.a.prototype)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(7),i=n(0),o=n(25),s=n(13),a=n(36),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(e){this.nativeGoogleTokenProvider=e,this.apiService=o.a.instance.apiService}static parseAccessToken(e){return c(this,void 0,void 0,(function*(){let t=yield a.a.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return c(this,void 0,void 0,(function*(){const e=yield this.nativeGoogleTokenProvider();return this.callGoogleNativeLogin(e.idToken,e.email).toPromise()}))}callGoogleNativeLogin(e,t){const n="ios"===window.device.platform.toLowerCase()?"ios":null,o=(new r.Request.Builder).withType(r.HttpRequestType.POST).withPath(u.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody({emailId:t,platform:n}).withHeaders({"X-GOOGLE-ID-TOKEN":e}).build();return this.apiService.fetch(o).pipe(Object(i.map)(e=>c(this,void 0,void 0,(function*(){return e.body&&s.CsModule.instance.updateAuthTokenConfig(e.body.access_token),{access_token:e.body.access_token,refresh_token:e.body.refresh_token,userToken:(yield u.parseAccessToken(e.body.access_token)).userToken}}))))}}u.LOGIN_API_ENDPOINT="/google/auth/android"},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(7),i=n(0),o=n(25),s=n(13),a=n(36),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(e){this.nativeAppleTokenProvider=e,this.apiService=o.a.instance.apiService,console.log(this.apiService)}static parseAccessToken(e){return c(this,void 0,void 0,(function*(){let t=yield a.a.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return c(this,void 0,void 0,(function*(){const e=yield this.nativeAppleTokenProvider();return this.callAppleNativeLogin(e).toPromise()}))}callAppleNativeLogin(e){const t="ios"===window.device.platform.toLowerCase()?"ios":null,n=(new r.Request.Builder).withType(r.HttpRequestType.POST).withPath(u.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody(Object.assign({emailId:e.email,platform:t},e)).build();return this.apiService.fetch(n).pipe(Object(i.map)(e=>c(this,void 0,void 0,(function*(){return e.body&&s.CsModule.instance.updateAuthTokenConfig(e.body.sessionId.access_token),{access_token:e.body.sessionId.access_token,refresh_token:e.body.sessionId.refresh_token,userToken:(yield u.parseAccessToken(e.body.sessionId.access_token)).userToken}}))))}}u.LOGIN_API_ENDPOINT="/apple/auth/ios"},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(61),i=n(25),o=n(57),s=n(46),a=n(71),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u extends r.a{constructor(e,t,n){super(i.a.instance.sdkConfig.apiConfig,i.a.instance.apiService,i.a.instance.eventsBusService),this.stateSessionConfig=e,this.autoMergeConfig=t,this.telemetryService=i.a.instance.telemetryService,this.webViewRunner=n||new o.a}provide(){return c(this,void 0,void 0,(function*(){const e=this.webViewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.stateSessionConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),e.launchWebview({host:this.stateSessionConfig.target.host,path:this.stateSessionConfig.target.path,params:this.stateSessionConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))}).then(()=>e.any(...this.stateSessionConfig.return.reduce((t,n)=>{switch(n.type){case"state":t.push(this.buildStateSessionProvider(e,n));break;case"state-error":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.resolveCaptured("error_message").catch(()=>{throw new s.a("Server Error")}).then(e=>{throw new s.a(e)}))));break;case"migrate":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.success()).then(t=>(e.resetInAppBrowserEventListeners(),e.clearCapture().then(()=>new a.a(this.autoMergeConfig,this.webViewRunner,t).provide()))))}return t},[])))}))}}},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(7),i=n(0),o=n(25),s=n(13),a=n(36),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(e,t){this.loginConfig=e,this.nativeKeycloakTokenProvider=t,this.apiService=o.a.instance.apiService}static parseAccessToken(e){return c(this,void 0,void 0,(function*(){let t=yield a.a.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return c(this,void 0,void 0,(function*(){return this.callKeycloakNativeLogin(this.nativeKeycloakTokenProvider.username,this.nativeKeycloakTokenProvider.password).toPromise()}))}callKeycloakNativeLogin(e,t){const n="ios"===window.device.platform.toLowerCase()?"ios":window.device.platform.toLowerCase(),o=(new r.Request.Builder).withType(r.HttpRequestType.POST).withPath(u.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody({client_id:n,emailId:e,password:t,loginConfig:this.loginConfig.target}).build();return this.apiService.fetch(o).pipe(Object(i.map)(e=>c(this,void 0,void 0,(function*(){var t;return(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.access_token)?(s.CsModule.instance.updateAuthTokenConfig(e.body.access_token),{access_token:e.body.access_token,refresh_token:e.body.refresh_token,userToken:(yield u.parseAccessToken(e.body.access_token)).userToken}):e.body}))))}}u.LOGIN_API_ENDPOINT="/keycloak/login"},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(25),i=n(57),o=n(52),s=n(36),a=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class c{constructor(e,t,n){this.loginConfig=e,this.customWebViewConfig=t,this.apiConfig=r.a.instance.sdkConfig.apiConfig,this.telemetryService=r.a.instance.telemetryService,this.webviewRunner=n||new i.a}static parseAccessToken(e){return a(this,void 0,void 0,(function*(){let t=yield s.a.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}buildGoogleTargetUrl(e,t){const n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach(e=>n.searchParams.set(e,t[e])),n}provide(){return a(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)});let n="",r={};this.loginConfig.target.params.forEach(e=>{"redirect_uri"==e.key&&(n=e.value),r[e.key]=e.value});const i=this.buildGoogleTargetUrl({googleRedirectUrl:`${this.loginConfig.target.host}/${c.LOGIN_API_ENDPOINT}?redirect_uri=${n}`},r);return e.launchCustomTab({host:i.origin,path:i.pathname,params:o.parse(i.searchParams.toString(),{ignoreQueryPrefix:!0}),extraParams:this.customWebViewConfig.get("extraParam")}).then(()=>e.success()).then(e=>a(this,void 0,void 0,(function*(){return{access_token:e.access_token,refresh_token:e.refresh_token,userToken:(yield c.parseAccessToken(e.access_token)).userToken}})))}))}}c.LOGIN_API_ENDPOINT="/google/auth"},function(e,t,n){"use strict";n.r(t);var r=n(264);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(265);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(266);for(var i in s)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(267);for(var i in a)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(269);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(270);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(271);for(var i in s)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(272);for(var i in a)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(273);n.d(t,"GroupMembershipType",(function(){return c.c})),n.d(t,"GroupMemberRole",(function(){return c.b})),n.d(t,"GroupEntityStatus",(function(){return c.a}))},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r=n(81);n.d(t,"c",(function(){return r.GroupMembershipType})),n.d(t,"b",(function(){return r.GroupMemberRole})),n.d(t,"a",(function(){return r.GroupEntityStatus}))},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(276);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i)},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(278);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i)},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(280);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(281);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i)},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(283);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i)},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(285);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i)},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(287);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(288);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i)},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.d(t,"a",(function(){return ge}));var r=n(15),i=n(1),o=n(4),s=n(7),a=n(0);class c{constructor(e,t){this.apiService=e,this.tenantServiceConfig=t,this.GET_TENANT_INFO_ENDPOINT="/info"}handle(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.GET).withPath(this.tenantServiceConfig.tenantApiPath+this.GET_TENANT_INFO_ENDPOINT+"/"+e.slug).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>e.body.result))}}var u=n(21),d=n(3),l=n(5),f=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class h{constructor(e,t,n,r){this.cachedItemStore=e,this.keyValueStore=t,this.container=n,this.profileServiceConfig=r,this.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails"}get csUserService(){return this.container.get(l.a.USER_SERVICE)}handle(e){return e.from=e.from||u.CachedItemRequestSourceFrom.CACHE,Object(d.of)(e.from).pipe(Object(a.mergeMap)(t=>t===u.CachedItemRequestSourceFrom.SERVER?this.fetchFromServer(e).pipe(Object(a.tap)(e=>f(this,void 0,void 0,(function*(){return this.keyValueStore.setValue(this.USER_PROFILE_DETAILS_KEY_PREFIX+"-"+e.id,JSON.stringify(e)).toPromise()}))),Object(a.catchError)(t=>{if(e.forceRefresh)throw t;return this.fetchFromCache(e)})):this.fetchFromCache(e)))}fetchFromServer(e){return this.csUserService.getProfileDetails(e,{apiPath:this.profileServiceConfig.profileApiPath_V5})}fetchFromCache(e){return this.cachedItemStore.getCached(e.userId,this.USER_PROFILE_DETAILS_KEY_PREFIX,this.USER_PROFILE_DETAILS_KEY_PREFIX,()=>this.fetchFromServer(e))}}class E{static mapProfileDBEntryToProfile(e){return{uid:e[o.f.COLUMN_NAME_UID],handle:e[o.f.COLUMN_NAME_HANDLE],createdAt:e[o.f.COLUMN_NAME_CREATED_AT],medium:e[o.f.COLUMN_NAME_MEDIUM]?e[o.f.COLUMN_NAME_MEDIUM].split(","):[],board:e[o.f.COLUMN_NAME_BOARD]?e[o.f.COLUMN_NAME_BOARD].split(","):[],subject:e[o.f.COLUMN_NAME_SUBJECT]?e[o.f.COLUMN_NAME_SUBJECT].split(","):[],profileType:e[o.f.COLUMN_NAME_PROFILE_TYPE],grade:e[o.f.COLUMN_NAME_GRADE]?e[o.f.COLUMN_NAME_GRADE].split(","):[],syllabus:e[o.f.COLUMN_NAME_SYLLABUS]?e[o.f.COLUMN_NAME_SYLLABUS].split(","):[],source:e[o.f.COLUMN_NAME_SOURCE],gradeValue:e[o.f.COLUMN_NAME_GRADE_VALUE]&&JSON.parse(e[o.f.COLUMN_NAME_GRADE_VALUE]),categories:e[o.f.COLUMN_NAME_CATEGORIES]}}static mapProfileToProfileDBEntry(e){return{[o.f.COLUMN_NAME_UID]:e.uid,[o.f.COLUMN_NAME_HANDLE]:e.handle,[o.f.COLUMN_NAME_CREATED_AT]:Number(e.createdAt),[o.f.COLUMN_NAME_MEDIUM]:e.medium?e.medium.join(","):"",[o.f.COLUMN_NAME_BOARD]:e.board?e.board.join(","):"",[o.f.COLUMN_NAME_SUBJECT]:e.subject?e.subject.join(","):"",[o.f.COLUMN_NAME_PROFILE_TYPE]:e.profileType,[o.f.COLUMN_NAME_GRADE]:e.grade?e.grade.join(","):"",[o.f.COLUMN_NAME_SYLLABUS]:e.syllabus?e.syllabus.join(","):"",[o.f.COLUMN_NAME_SOURCE]:e.source,[o.f.COLUMN_NAME_GRADE_VALUE]:e.gradeValue?JSON.stringify(e.gradeValue):"",[o.f.COLUMN_NAME_CATEGORIES]:e.categories?JSON.stringify(e.categories):""}}}class p{constructor(e,t){this.apiService=e,this.acceptTermsConditionApiConfig=t,this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT="/tnc/accept"}handle(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.POST).withPath(this.acceptTermsConditionApiConfig.profileApiPath+this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>"SUCCESS"===e.body.result.response))}}var _=n(2);var S=n(19);class b extends S.a{constructor(e){super(e,"INVALID_PROFILE_ERROR"),Object.setPrototypeOf(this,b.prototype)}}var O=n(29);class v{constructor(e,t){this.apiService=e,this.profileAlreadyInUseConfig=t,this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT="/get"}handle(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.GET).withPath(this.profileAlreadyInUseConfig.profileApiPath_V2+this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT+"/"+e.type+"/"+e.key).withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>e.body.result))}}class C{constructor(e,t){this.apiService=e,this.otpServiceConfig=t,this.GET_GENERATE_OTP_ENDPOINT="/generate"}handle(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.POST).withPath(this.otpServiceConfig.otpApiPath+this.GET_GENERATE_OTP_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>"SUCCESS"===e.body.result.response))}}class g{constructor(e,t){this.apiService=e,this.optServiceConfig=t,this.GET_VERIFY_OTP_ENDPOINT="/verify"}handle(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.POST).withPath(this.optServiceConfig.otpApiPath+this.GET_VERIFY_OTP_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>"SUCCESS"===e.body.result.response))}}var A=n(45);class T{constructor(e,t,n,r){this.apiService=e,this.profileServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.LOCATION_LOCAL_KEY="location-"}handle(e){let t=e.filters.type;return e.filters.parentId&&(t=t+"_"+e.filters.parentId),this.cachedItemStore[e.from===u.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](t,this.LOCATION_LOCAL_KEY,"ttl_"+this.LOCATION_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e),T.LOCATION_TTL)}fetchFromServer(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.POST).withPath(this.profileServiceConfig.searchLocationApiPath+T.GET_SEARCH_LOCATION_ENDPOINT).withBearerToken(!0).withUserToken(!1).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>e.body.result.response))}fetchFromFile(e){const t=A.a.getAssetPath()+this.profileServiceConfig.locationDirPath;let n=e.filters.type;return e.filters.parentId&&(n=n+"-"+e.filters.parentId),n+=".json",Object(d.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(a.map)(e=>JSON.parse(e).result.response))}}T.GET_SEARCH_LOCATION_ENDPOINT="/location/search",T.LOCATION_TTL=864e5;var N=n(8),y=n(11),m=n(33),I=n(38),M=n.n(I);class D{constructor(e){this.fileService=e}execute(e){const t=new s.Response,n=`profiles_${M()().format("YYYYMMDDhhmmss")}.epar`;return this.fileService.createDir(e.destinationFolder.concat("Profile"),!1).then(e=>this.fileService.createFile(e.nativeURL,n,!0)).then(n=>(e.destinationDBFilePath=n.nativeURL,t.body=e,t))}}var R=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class P{constructor(e){this.dbService=e}execute(e){return R(this,void 0,void 0,(function*(){const t=new s.Response;return this.dbService.copyDatabase(e.destinationDBFilePath).toPromise().then(n=>(t.body=e,t)).then(()=>(t.body=e,t))}))}}var L=n(17),w=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class U{constructor(e,t,n){this.dbService=e,this.fileService=t,this.deviceInfo=n}execute(e){return w(this,void 0,void 0,(function*(){const t=new s.Response,n=this.generateMetaData(e.userIds,e.groupIds);return this.dbService.open(e.destinationDBFilePath).then(()=>this.dbService.execute(L.b.getCreateEntry(),!0).toPromise()).then(()=>this.populateMetaData(n)).then(()=>(t.body=e,t)).catch(e=>{throw console.log("error",e),t})}))}generateMetaData(e,t){const n={version:20};return n.types=JSON.stringify(["userprofile"]),n.did=this.deviceInfo.getDeviceID(),n.export_id=O.a.generateUniqueId(),t||(t=[]),n.profiles_count=e.length+t.length,n}populateMetaData(e){return w(this,void 0,void 0,(function*(){Object.keys(e).forEach(t=>w(this,void 0,void 0,(function*(){const n={key:t,value:e[t]};yield this.dbService.insert({table:L.b.TABLE_NAME,modelJson:n,useExternalDb:!0}).toPromise()})))}))}}var j=n(14),F=n(9),x=n(12),k=n(24),B=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class V{constructor(e,t){this.dbService=e,this.fileService=t}execute(e){return B(this,void 0,void 0,(function*(){const t=new s.Response;return this.getAllTables().then(e=>{const t=e.map(e=>e.name);return this.removeTables(t,this.getAllTablesToExclude())}).then(()=>this.deleteUnwantedProfilesAndUsers(e.userIds)).then(()=>this.deleteUnwantedProfileSummary(e.userIds)).then(()=>this.deleteUnwantedGroups(e.groupIds)).then(()=>this.deleteUnwantedGroupProfiles(e.groupIds)).then(()=>this.keepAllFrameworknChannel()).then(()=>this.fileService.getMetaData(e.destinationDBFilePath)).then(t=>(e.size=t.size.toString(),this.populateMetaData({FILE_SIZE:t.size}))).then(()=>this.fileService.removeFile(e.destinationDBFilePath.concat("-journal"))).then(()=>(t.body=e,t)).catch(e=>{throw t.errorMesg=F.ErrorCode.EXPORT_FAILED,t})}))}getAllTables(){return this.dbService.execute("SELECT name FROM sqlite_master WHERE type = 'table'",!0).toPromise()}getAllTablesToExclude(){return[L.b.TABLE_NAME,o.g.TABLE_NAME,o.f.TABLE_NAME,o.d.TABLE_NAME,o.e.TABLE_NAME,x.a.TABLE_NAME,x.b.TABLE_NAME,k.a.TABLE_NAME]}removeTables(e,t){return B(this,void 0,void 0,(function*(){for(const n of e)j.a.contains(t,n)||(yield this.dbService.execute("DROP TABLE IF EXISTS "+n,!0).toPromise());return!0}))}populateMetaData(e){return B(this,void 0,void 0,(function*(){Object.keys(e).forEach(t=>B(this,void 0,void 0,(function*(){const n={key:t,value:e[t]};yield this.dbService.insert({table:L.b.TABLE_NAME,modelJson:n,useExternalDb:!0}).toPromise()})))}))}deleteUnwantedProfilesAndUsers(e){return B(this,void 0,void 0,(function*(){const t=[],n=[];for(const r of e){const e=yield this.dbService.read({table:o.f.TABLE_NAME,useExternalDb:!0,selection:o.f.COLUMN_NAME_UID+"=?",selectionArgs:[r],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][o.f.COLUMN_NAME_UID]);const i=yield this.dbService.read({table:o.g.TABLE_NAME,useExternalDb:!0,selection:o.g.COLUMN_NAME_UID+"=?",selectionArgs:[r],limit:"1"}).toPromise();i&&i.length&&n.push(i[0][o.g.COLUMN_NAME_UID])}yield this.cleanTable(o.f.TABLE_NAME,o.f.COLUMN_NAME_UID,t),yield this.cleanTable(o.g.TABLE_NAME,o.g.COLUMN_NAME_UID,t)}))}deleteUnwantedProfileSummary(e){return B(this,void 0,void 0,(function*(){yield this.cleanTable(o.d.TABLE_NAME,o.d.COLUMN_NAME_UID,e),yield this.cleanTable(o.e.TABLE_NAME,o.e.COLUMN_NAME_UID,e)}))}deleteUnwantedGroups(e){return B(this,void 0,void 0,(function*(){if(!e||!e.length)return;const t=[];for(const n of e){const e=yield this.dbService.read({table:x.a.TABLE_NAME,useExternalDb:!0,selection:x.a.COLUMN_NAME_GID+"=?",selectionArgs:[n],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][x.b.COLUMN_NAME_GID])}yield this.cleanTable(x.a.TABLE_NAME,x.a.COLUMN_NAME_GID,t)}))}deleteUnwantedGroupProfiles(e){return B(this,void 0,void 0,(function*(){if(!e||!e.length)return;const t=[];for(const n of e){const e=yield this.dbService.read({table:x.b.TABLE_NAME,useExternalDb:!0,selection:x.b.COLUMN_NAME_GID+"=?",selectionArgs:[n],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][o.f.COLUMN_NAME_UID])}yield this.cleanTable(x.a.TABLE_NAME,x.a.COLUMN_NAME_GID,e)}))}keepAllFrameworknChannel(){return B(this,void 0,void 0,(function*(){const e=`SELECT * FROM ${k.a.TABLE_NAME}\n WHERE ${k.a.COLUMN_NAME_KEY} LIKE 'channel_details_key-%'\n OR ${k.a.COLUMN_NAME_KEY} LIKE 'framework_details_key-%'\n OR ${k.a.COLUMN_NAME_KEY} LIKE 'form-%'`,t=yield this.dbService.execute(e,!0).toPromise();yield this.dbService.execute("DELETE FROM "+k.a.TABLE_NAME,!0),t.forEach(e=>B(this,void 0,void 0,(function*(){yield this.dbService.insert({table:k.a.TABLE_NAME,useExternalDb:!0,modelJson:e})})))}))}cleanTable(e,t,n){return B(this,void 0,void 0,(function*(){if(!n||!n.length)return;const r=j.a.joinPreservingQuotes(n),i=`DELETE FROM ${e}\n WHERE ${t} NOT IN(${r})`;yield this.dbService.execute(i,!0).toPromise()}))}}var Y=n(10);class G{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:o.c.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:Y.ShareItemType.PROFILE,origin:e[o.c.COLUMN_NAME_DEVICE_ID],identifier:e[o.c.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:Y.ShareDirection.IN,type:Y.ShareType.FILE.valueOf(),items:t,env:"sdk"};return m.a.log.share(n).toPromise()}).then(()=>(t.body=e,t))}}class H{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:o.c.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:Y.ShareItemType.PROFILE,origin:e[o.c.COLUMN_NAME_DEVICE_ID],identifier:e[o.c.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:Y.ShareDirection.OUT,type:Y.ShareType.FILE.valueOf(),items:t,env:"sdk"};return m.a.log.share(n).toPromise()}).then(()=>(t.body=e,t))}}class q{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.open(e.sourceDBFilePath).then(()=>this.dbService.read({table:L.b.TABLE_NAME,useExternalDb:!0}).toPromise()).then(n=>{if(!n||!n.length)throw t.errorMesg=F.ErrorCode.IMPORT_FAILED.valueOf(),t;const r={};n.forEach(e=>{r[e.key]=e.value}),e.metadata=r;const i=this.getImportTypes(r);if(i&&!j.a.contains(i,"userprofile"))throw t.errorMesg=F.ErrorCode.IMPORT_FAILED.valueOf(),t;return t.body=e,t})}getImportTypes(e){let t=[];return e.hasOwnProperty("types")&&(t=JSON.parse(e.types)),t}}var $=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class K{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:o.g.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveUsersToDb(e,t)).then(()=>(t.body=e,t))}saveUsersToDb(e,t){return $(this,void 0,void 0,(function*(){t.forEach(e=>$(this,void 0,void 0,(function*(){delete e[o.g._ID];const t=yield this.dbService.read({table:o.f.TABLE_NAME,selection:o.g.COLUMN_NAME_UID+" = ?",selectionArgs:[e[o.g.COLUMN_NAME_UID]],limit:"1"}).toPromise();t&&t.length||(yield this.dbService.insert({table:o.g.TABLE_NAME,modelJson:e}).toPromise())})))}))}}var z=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class W{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:x.a.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveGroupsToDb(e,t)).then(()=>(t.body=e,t))}saveGroupsToDb(e,t){return z(this,void 0,void 0,(function*(){let n=0,r=0;t.forEach(e=>z(this,void 0,void 0,(function*(){const t=yield this.dbService.read({table:x.a.TABLE_NAME,selection:x.a.COLUMN_NAME_GID+" = ?",selectionArgs:[e[x.a.COLUMN_NAME_GID]],limit:"1"}).toPromise();t&&t.length?r++:(e[x.a.COLUMN_NAME_CREATED_AT]||(e[x.a.COLUMN_NAME_CREATED_AT]=Date.now()),yield this.dbService.insert({table:x.a.TABLE_NAME,modelJson:e}).toPromise(),n++)}))),e.failed=e.failed?e.failed+r:r,e.imported=e.imported?e.imported+n:n}))}}var X=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class J{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:x.b.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveGroupProfilesToDb(e,t)).then(()=>(t.body=e,t))}saveGroupProfilesToDb(e,t){return X(this,void 0,void 0,(function*(){t.forEach(e=>X(this,void 0,void 0,(function*(){delete e[x.b._ID];const n=yield this.dbService.read({table:x.b.TABLE_NAME,selection:`${x.b.COLUMN_NAME_GID} = ? AND ${x.b.COLUMN_NAME_UID} = ?`,selectionArgs:[t[x.b.COLUMN_NAME_GID],e[x.b.COLUMN_NAME_UID]],limit:"1"}).toPromise();n&&n.length||(yield this.dbService.insert({table:x.b.TABLE_NAME,modelJson:e}))})))}))}}var Q=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Z{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:k.a.TABLE_NAME,useExternalDb:!0}).toPromise().then(e=>this.saveNoSqlEntryToDb(e)).then(()=>(t.body=e,t))}saveNoSqlEntryToDb(e){return Q(this,void 0,void 0,(function*(){e.forEach(e=>Q(this,void 0,void 0,(function*(){delete e[k.a._ID];const t=yield this.dbService.read({table:k.a.TABLE_NAME,selection:k.a.COLUMN_NAME_KEY+" = ?",selectionArgs:[e[k.a.COLUMN_NAME_KEY]],limit:"1"}).toPromise();t&&t.length||(yield this.dbService.insert({table:k.a.TABLE_NAME,modelJson:e}).toPromise())})))}))}}var ee=n(23),te=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class ne{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:o.f.TABLE_NAME,orderBy:o.f.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then(e=>{const t=e.map(e=>e[o.f.COLUMN_NAME_UID]);return this.deleteUnwantedAssesments(t)}).then(()=>this.saveLearnerAssesmentDetails()).then(()=>this.saveLearnerSummary()).then(()=>(t.body=e,t))}deleteUnwantedAssesments(e){return te(this,void 0,void 0,(function*(){const t=j.a.joinPreservingQuotes(e),n=`DELETE FROM ${o.d.TABLE_NAME}\n WHERE ${o.d.COLUMN_NAME_UID} NOT IN(${t})`,r=`DELETE FROM ${o.e.TABLE_NAME}\n WHERE ${o.e.COLUMN_NAME_UID} NOT IN(${t})`;yield this.dbService.execute(n,!0).toPromise(),yield this.dbService.execute(r,!0).toPromise()}))}saveLearnerAssesmentDetails(){return te(this,void 0,void 0,(function*(){const e=yield this.dbService.read({table:o.d.TABLE_NAME,orderBy:""+o.d.COLUMN_NAME_Q_INDEX,useExternalDb:!0}).toPromise();for(const t of e){const e=t,n=ee.SummarizerQueries.getFilterForLearnerAssessmentDetails(e[o.d.COLUMN_NAME_QID],e[o.d.COLUMN_NAME_UID],e[o.d.COLUMN_NAME_CONTENT_ID],e[o.d.COLUMN_NAME_HIERARCHY_DATA]),r=ee.SummarizerQueries.getLearnerAssessmentsQuery(n),i=yield this.dbService.execute(r).toPromise();i&&i.length?yield this.dbService.update({table:o.d.TABLE_NAME,selection:`${o.d.COLUMN_NAME_CONTENT_ID} = ?\n AND ${o.d.COLUMN_NAME_UID} = ?\n AND ${o.d.COLUMN_NAME_QID} = ?`,selectionArgs:[e[o.d.COLUMN_NAME_CONTENT_ID],e[o.d.COLUMN_NAME_UID],e[o.d.COLUMN_NAME_QID]],modelJson:e}).toPromise():yield this.dbService.insert({table:o.d.TABLE_NAME,modelJson:e}).toPromise()}}))}saveLearnerSummary(){return te(this,void 0,void 0,(function*(){const e=yield this.dbService.read({table:o.e.TABLE_NAME,useExternalDb:!0}).toPromise();for(const t of e){const e=t,n=yield this.dbService.read({table:o.e.TABLE_NAME,selection:`${o.e.COLUMN_NAME_CONTENT_ID} = ? AND ${o.e.COLUMN_NAME_UID} = ?`,selectionArgs:[e[o.d.COLUMN_NAME_CONTENT_ID],e[o.d.COLUMN_NAME_UID]]}).toPromise();n&&n.length?yield this.dbService.update({table:o.e.TABLE_NAME,selection:`${o.e.COLUMN_NAME_CONTENT_ID} = ? AND ${o.e.COLUMN_NAME_UID} = ?`,selectionArgs:[e[o.d.COLUMN_NAME_CONTENT_ID],e[o.d.COLUMN_NAME_UID]],modelJson:e}).toPromise():yield this.dbService.insert({table:o.e.TABLE_NAME,modelJson:e}).toPromise()}e.forEach(e=>te(this,void 0,void 0,(function*(){const t=ee.SummarizerQueries.getFilterForLearnerAssessmentDetails(e[o.d.COLUMN_NAME_QID],e[o.d.COLUMN_NAME_UID],e[o.d.COLUMN_NAME_CONTENT_ID],e[o.d.COLUMN_NAME_HIERARCHY_DATA]),n=ee.SummarizerQueries.getLearnerAssessmentsQuery(t),r=yield this.dbService.execute(n).toPromise();r&&r.length?yield this.dbService.update({table:o.e.TABLE_NAME,modelJson:r[0]}).toPromise():yield this.dbService.insert({table:o.e.TABLE_NAME,modelJson:r[0]}).toPromise()})))}))}}class re{constructor(e){this.dbService=e}execute(e){const t=new s.Response,n=e.metadata.export_id,r=e.metadata.did,i={imported_id:n,device_id:r,count:e.metadata.profiles_count};return this.dbService.read({table:o.c.TABLE_NAME,selection:`${o.c.COLUMN_NAME_IMPORTED_ID} =? AND ${o.c.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[n,r],limit:"1"}).toPromise().then(e=>e&&e.length?this.dbService.update({table:o.c.TABLE_NAME,modelJson:i,selection:`${o.c.COLUMN_NAME_IMPORTED_ID} =? AND ${o.c.COLUMN_NAME_DEVICE_ID} =?`,selectionArgs:[n,r]}).toPromise():this.dbService.insert({table:o.c.TABLE_NAME,modelJson:i}).toPromise()).then(()=>(t.body=e,t))}}var ie=n(37),oe=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class se{constructor(e){this.dbService=e}execute(e){const t=new s.Response;return this.dbService.read({table:o.f.TABLE_NAME,orderBy:o.f.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then(t=>this.saveProfilesToDb(e,t)).then(()=>(t.body=e,t))}saveProfilesToDb(e,t){return oe(this,void 0,void 0,(function*(){let n=0,r=0;for(const i of t){const t=yield this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[i[o.f.COLUMN_NAME_UID]],limit:"1"}).toPromise();t&&t.length?(r++,e.failed=r):(i[o.f.COLUMN_NAME_CREATED_AT]||(i[o.f.COLUMN_NAME_CREATED_AT]=(new Date).getTime()),delete i[o.f._ID],yield this.dbService.insert({table:o.f.TABLE_NAME,modelJson:i}).toPromise(),n++,e.imported=n)}e.failed=r,e.imported=n}))}}var ae=n(6);class ce{constructor(e,t){this.sdkConfig=e,this.apiService=t,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(e){return this.fetchFromServer(e)}fetchFromServer(e){console.log("Request",e);const t=(new s.Request.Builder).withHost(this.apiConfig.host).withType(s.HttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath_V5+ce.USER_MIGRATE).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>(console.log("sucees",e),e.body)))}}ce.USER_MIGRATE="/migrate";var ue=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class de{constructor(e,t,n,r,i,o,s,a){this.profileService=e,this.authService=t,this.profileServiceConfig=n,this.apiService=r,this.cachedItemStore=i,this.dbService=o,this.frameworkService=s,this.sharedPreferences=a,this.managedProfileAdded$=new d.Subject}addManagedProfile(e){return Object(d.defer)(()=>ue(this,void 0,void 0,(function*(){if(!(yield this.isLoggedInUser()))throw new r.NoActiveSessionError("No active LoggedIn Session found");const{uid:t}=yield this.createManagedProfile(e);return setTimeout(()=>{this.managedProfileAdded$.next(!0)},1e3),{uid:t}})))}getManagedServerProfiles(e){return this.managedProfileAdded$.pipe(Object(a.startWith)(!1),Object(a.mergeMap)(t=>Object(d.defer)(()=>ue(this,void 0,void 0,(function*(){if(!(yield this.isLoggedInUser()))throw new r.NoActiveSessionError("No active LoggedIn Session found");e.from!==u.CachedItemRequestSourceFrom.SERVER&&(e.from=t?u.CachedItemRequestSourceFrom.SERVER:u.CachedItemRequestSourceFrom.CACHE);const n=yield this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise(),i=n.serverProfile&&n.serverProfile.managedBy?n.serverProfile.managedBy:n.uid,c=()=>Object(d.defer)(()=>ue(this,void 0,void 0,(function*(){const t=n.serverProfile&&!n.serverProfile.managedBy?n.serverProfile:yield this.profileService.getServerProfilesDetails({userId:n.serverProfile.managedBy,requiredFields:e.requiredFields}).toPromise(),r=(new s.Request.Builder).withType(s.HttpRequestType.GET).withPath(`${this.profileServiceConfig.profileApiPath}/managed/${i}`).withParameters({withTokens:"true",sortBy:"createdDate",order:"desc"}).withBearerToken(!0).withUserToken(!0).build();return yield this.apiService.fetch(r).toPromise().then(e=>[t,...e.body.result.response.content.sort((e,t)=>new Date(t.createdDate).getTime()-new Date(e.createdDate).getTime())])}))).pipe(Object(a.tap)(e=>ue(this,void 0,void 0,(function*(){const t=yield this.dbService.execute(`\n SELECT * from ${o.f.TABLE_NAME}\n WHERE ${o.f.COLUMN_NAME_UID}\n IN (${j.a.joinPreservingQuotes(e.map(e=>e.id))})\n `).toPromise().then(e=>e.map(e=>E.mapProfileDBEntryToProfile(e))),n=e.filter(e=>!t.find(t=>t.uid===e.id));for(const e of n)this.persistManagedProfile(e)}))));return this.cachedItemStore[e.from===u.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](i,de.MANGED_SERVER_PROFILES_LOCAL_KEY,"ttl_"+de.MANGED_SERVER_PROFILES_LOCAL_KEY,()=>c()).toPromise()})))))}switchSessionToManagedProfile({uid:e}){return Object(d.defer)(()=>ue(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=Object.assign({},t);yield m.a.log.end({type:"session",env:"sdk",mode:"switch-user",duration:Math.floor((Date.now()-(n.managedSession||n).createdTime)/1e3),correlationData:[{type:"InitiatorId",id:n.managedSession?n.managedSession.uid:n.uid},{type:"ManagedUserId",id:e}]}).toPromise();const i=yield(()=>ue(this,void 0,void 0,(function*(){return this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).toPromise().then(e=>e&&e[0]&&E.mapProfileDBEntryToProfile(e[0]))})))();if(!i)throw new r.NoProfileFoundError("No Profile found with uid="+e);if(i.source!==r.ProfileSource.SERVER)throw new r.NoProfileFoundError("No Server Profile found with uid="+e);if(t.uid===e){t.managedSession=void 0;const e=yield this.authService.getSession().toPromise();e.managed_access_token=void 0,yield this.authService.setSession(new class{provide(){return ue(this,void 0,void 0,(function*(){return e}))}}).toPromise()}else{t.managedSession=new r.ProfileSession(e);const n=(yield this.getManagedServerProfiles({from:u.CachedItemRequestSourceFrom.CACHE,requiredFields:[]}).pipe(Object(a.take)(1)).toPromise()).find(t=>t.id===e),i=yield this.authService.getSession().toPromise();i.managed_access_token=n.managedToken,yield this.authService.setSession(new class{provide(){return ue(this,void 0,void 0,(function*(){return i}))}}).toPromise()}yield this.sharedPreferences.putString(y.m.KEY_USER_SESSION,JSON.stringify(t)).toPromise(),m.a.log.start({type:"session",env:"sdk",mode:"switch-user",correlationData:[{type:"InitiatorId",id:n.managedSession?n.managedSession.uid:n.uid},{type:"ManagedUserId",id:t.managedSession?t.managedSession.uid:t.uid}]}).toPromise()}))).pipe(Object(a.mergeMap)(()=>this.authService.getSession().pipe(Object(a.mergeMap)(t=>this.authService.setSession(new class{provide(){return ue(this,void 0,void 0,(function*(){return Object.assign(Object.assign({},t),{userToken:e})}))}})))),Object(a.mergeMap)(()=>ue(this,void 0,void 0,(function*(){const t=yield this.profileService.getServerProfilesDetails({userId:e,requiredFields:[]}).toPromise(),n=t.rootOrg?t.rootOrg.hashTagId:t.rootOrgId;return this.frameworkService.setActiveChannelId(n).toPromise()}))),Object(a.mapTo)(void 0))}persistManagedProfile(e){return ue(this,void 0,void 0,(function*(){e.userId=e.id,e.rootOrg={hashTagId:e.rootOrgId},this.profileService.createProfile({uid:e.id,profileType:r.ProfileType.STUDENT,source:r.ProfileSource.SERVER,handle:e.firstName,board:e.framework&&e.framework.board||[],medium:e.framework&&e.framework.medium||[],grade:e.framework&&e.framework.gradeLevel||[],gradeValue:e.framework&&e.framework.gradeValue||"",subject:e.framework&&e.framework.subject||[],serverProfile:e},r.ProfileSource.SERVER).toPromise(),this.cachedItemStore.getCached(e.id,de.USER_PROFILE_DETAILS_KEY_PREFIX,de.USER_PROFILE_DETAILS_KEY_PREFIX,()=>Object(d.of)(e)).toPromise()}))}createManagedProfile(e){return ue(this,void 0,void 0,(function*(){if((yield this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise()).source!==r.ProfileSource.SERVER)throw new r.NoActiveSessionError("No active session available");const t=(new s.Request.Builder).withType(s.HttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath_V2+"/managed/create").withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return yield this.apiService.fetch(t).toPromise().then(e=>({uid:e.body.result.userId}))}))}isLoggedInUser(){return ue(this,void 0,void 0,(function*(){return!!(yield this.authService.getSession().toPromise())}))}}de.MANGED_SERVER_PROFILES_LOCAL_KEY="managed_server_profiles-",de.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails";var le=n(13),fe=n(28),he=n(26),Ee=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class pe{constructor(e){this.dbService=e}delete(e){return Object(d.defer)(()=>Object(d.of)(this.dbService.beginTransaction())).pipe(Object(a.mergeMap)(()=>Object(d.zip)(this.dbService.delete({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:_.d.TABLE_NAME,selection:_.d.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:_.a.TABLE_NAME,selection:_.a.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:o.d.TABLE_NAME,selection:o.d.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:o.e.TABLE_NAME,selection:o.e.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:_.c.TABLE_NAME,selection:_.c.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:he.a.TABLE_NAME,selection:he.a.COLUMN_NAME_USER_ID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:o.b.TABLE_NAME,selection:o.b.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:o.g.TABLE_NAME,selection:o.g.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:fe.a.TABLE_NAME,selection:fe.a.COLUMN_NAME_USER_ID+" = ?",selectionArgs:[e]}),this.dbService.execute(`DELETE FROM ${k.a.TABLE_NAME} \n WHERE ${k.a.COLUMN_NAME_KEY} \n LIKE '%%${e}%%'`)).pipe(Object(a.mapTo)(!0))),Object(a.tap)(()=>Ee(this,void 0,void 0,(function*(){yield this.dbService.execute(`SELECT * FROM ${k.a.TABLE_NAME} \n WHERE ${k.a.COLUMN_NAME_KEY} \n LIKE '%%userProfileDetails%%'`).pipe(Object(a.map)(t=>t.filter(t=>JSON.parse(t.value).managedBy===e).map(e=>JSON.parse(e.value).userId)),Object(a.mergeMap)(e=>{const t=this.dbService.execute(`DELETE FROM ${k.a.TABLE_NAME} \n WHERE ${this.generateLikeQuery(e,k.a.COLUMN_NAME_KEY)}`);return e.length?t.pipe(Object(a.mapTo)(e)):Object(d.of)(!0).pipe(Object(a.mapTo)(e))}),Object(a.mergeMap)(e=>{const t=this.dbService.execute(`DELETE FROM ${o.f.TABLE_NAME} \n WHERE ${this.generateLikeQuery(e,o.f.COLUMN_NAME_UID)}`);return e.length?t.pipe(Object(a.mapTo)(!0)):Object(d.of)(!0).pipe(Object(a.mapTo)(!0))})).toPromise()}))),Object(a.tap)(()=>{this.dbService.endTransaction(!0)}),Object(a.catchError)(e=>(console.error(e),this.dbService.endTransaction(!1),Object(d.of)(!1))))}generateLikeQuery(e,t){let n="";const r=t+" LIKE ";for(let t=0;t<e.length;t++)n=t<e.length-1?n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' OR `):n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' `);return`(${n})`}}class _e{constructor(e,t){this.apiService=e,this.profileServiceConfig=t,this.DELETE_ENDPOINT="/delete"}handle(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath+this.DELETE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>"SUCCESS"===e.body.result.response))}}var Se,be=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Oe=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ve=function(e,t){return function(n,r){t(n,r,e)}},Ce=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let ge=Se=class{constructor(e,t,n,r,i,o,s,a,c,u,d,l){this.container=e,this.sdkConfig=t,this.dbService=n,this.apiService=r,this.cachedItemStore=i,this.keyValueStore=o,this.sharedPreferences=s,this.frameworkService=a,this.fileService=c,this.deviceInfo=u,this.authService=d,this.userService=l,this.apiConfig=this.sdkConfig.apiConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.managedProfileManager=new de(this,this.authService,this.sdkConfig.profileServiceConfig,this.apiService,this.cachedItemStore,this.dbService,this.frameworkService,this.sharedPreferences)}get telemetryService(){return this.container.get(l.b.TELEMETRY_SERVICE)}preInit(){return this.sharedPreferences.getString(Se.KEY_USER_SESSION).pipe(Object(a.map)(e=>e&&JSON.parse(e)),Object(a.mergeMap)(e=>{if(!e){const e={uid:"",handle:"",profileType:r.ProfileType.TEACHER,source:r.ProfileSource.LOCAL};return this.createProfile(e).pipe(Object(a.mergeMap)(e=>this.setActiveSessionForProfile(e.uid)),Object(a.mapTo)(void 0))}return e.managedSession?this.managedProfileManager.switchSessionToManagedProfile({uid:e.managedSession.uid}):this.setActiveSessionForProfile(e.uid).pipe(Object(a.mapTo)(void 0))}))}checkServerProfileExists(e){return this.userService.checkUserExists(e.matching,e.captchaResponseToken?{token:e.captchaResponseToken,app:"1"}:void 0)}createProfile(e,t=r.ProfileSource.LOCAL){switch(t){case r.ProfileSource.LOCAL:if(e.source!==r.ProfileSource.LOCAL)throw new b("Invalid value supplied for field 'source': "+e.source);if(e.serverProfile)throw new b("Invalid value supplied for field 'serverProfile': "+e.serverProfile);e.uid=O.a.generateUniqueId();break;case r.ProfileSource.SERVER:if(e.source!==r.ProfileSource.SERVER)throw new b("Invalid value supplied for field 'source': "+e.source);if(!e.serverProfile)throw new b("Invalid value supplied for field 'serverProfile': "+e.serverProfile);if(!e.uid)throw new b("Invalid value supplied for field 'uid': "+e.uid)}return e.createdAt=Date.now(),this.dbService.insert({table:o.f.TABLE_NAME,modelJson:E.mapProfileToProfileDBEntry(e)}).pipe(Object(a.tap)(()=>Ce(this,void 0,void 0,(function*(){yield this.getActiveProfileSession().pipe(Object(a.map)(e=>e.uid),Object(a.catchError)(t=>t instanceof r.NoActiveSessionError?Object(d.of)(e.uid):Object(d.throwError)(t)),Object(a.mergeMap)(t=>{const n=new Y.Actor;n.id=t,n.type=Y.Actor.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:Y.AuditState.AUDIT_CREATED,updatedProperties:ie.a.getTruthyProps(e),objId:e.uid,objType:Y.ObjectType.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return this.telemetryService.audit(r)})).toPromise()}))),Object(a.mergeMap)(()=>Object(d.of)(e)))}deleteProfile(e){return this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).pipe(Object(a.map)(t=>{if(!t||!t[0])throw new r.NoProfileFoundError("No Profile found with ID "+e);return E.mapProfileDBEntryToProfile(t[0])}),Object(a.tap)(t=>Ce(this,void 0,void 0,(function*(){return yield this.getActiveProfileSession().pipe(Object(a.mergeMap)(n=>{const r=new Y.Actor;r.id=n.uid,r.type=Y.Actor.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:Y.AuditState.AUDIT_DELETED,objId:e,objType:Y.ObjectType.USER,correlationData:[{id:t.profileType,type:"UserRole"}]};return this.telemetryService.audit(i)})).toPromise()}))),Object(a.mergeMap)(()=>this.dbService.delete({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})))}updateProfile(e){return this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid]}).pipe(Object(a.map)(t=>{if(!t||!t[0])throw new r.NoProfileFoundError("No Profile found with ID "+e.uid);return E.mapProfileDBEntryToProfile(t[0])}),Object(a.tap)(t=>Ce(this,void 0,void 0,(function*(){yield this.getActiveProfileSession().pipe(Object(a.mergeMap)(n=>{const r=new Y.Actor;r.id=n.uid,r.type=Y.Actor.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:Y.AuditState.AUDIT_UPDATED,updatedProperties:ie.a.getPropDiff(e,t),objId:e.uid,objType:Y.ObjectType.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return this.telemetryService.audit(i)})).toPromise()}))),Object(a.mergeMap)(()=>{const t=E.mapProfileToProfileDBEntry(e);return delete t[o.f.COLUMN_NAME_CREATED_AT],this.dbService.update({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid],modelJson:t}).pipe(Object(a.mergeMap)(()=>Object(d.of)(e)))}))}updateServerProfile(e){return this.userService.updateProfile(e,{apiPath:"/api/user/v3"})}getTenantInfo(e){return new c(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}getAllProfiles(e){return e?e.groupId?e.groupId&&(e.local||e.server)?this.dbService.execute(`\n SELECT * FROM ${o.f.TABLE_NAME} LEFT JOIN ${o.b.TABLE_NAME}\n ON ${o.f.TABLE_NAME}.${o.f.COLUMN_NAME_UID} =\n ${o.b.TABLE_NAME}.${o.b.COLUMN_NAME_UID}\n WHERE ${o.b.COLUMN_NAME_GID} = "${e.groupId}" AND\n ${o.f.COLUMN_NAME_SOURCE} = "${e.local?r.ProfileSource.LOCAL:r.ProfileSource.SERVER}"\n `).pipe(Object(a.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.execute(`\n SELECT * FROM ${o.f.TABLE_NAME}\n LEFT JOIN ${o.b.TABLE_NAME} ON\n ${o.f.TABLE_NAME}.${o.f.COLUMN_NAME_UID} =\n ${o.b.TABLE_NAME}.${o.b.COLUMN_NAME_UID}\n WHERE ${o.b.TABLE_NAME}.${o.b.COLUMN_NAME_GID} = "${e.groupId}"\n `).pipe(Object(a.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_SOURCE+" = ?",selectionArgs:[e.local?r.ProfileSource.LOCAL:r.ProfileSource.SERVER],columns:[]}).pipe(Object(a.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.read({table:o.f.TABLE_NAME,columns:[]}).pipe(Object(a.map)(e=>this.mapDbProfileEntriesToProfiles(e)))}getServerProfilesDetails(e){return new h(this.cachedItemStore,this.keyValueStore,this.container,this.profileServiceConfig).handle(e)}getActiveSessionProfile({requiredFields:e}){return this.getActiveProfileSession().pipe(Object(a.mergeMap)(t=>this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[t.managedSession?t.managedSession.uid:t.uid]}).pipe(Object(a.map)(e=>{const n=e&&e[0];if(!n)throw new r.NoProfileFoundError("No profile found for profileSession with uid "+(t.managedSession?t.managedSession.uid:t.uid));return E.mapProfileDBEntryToProfile(n)}),Object(a.mergeMap)(t=>t.source===r.ProfileSource.SERVER?this.getServerProfilesDetails({userId:t.uid,requiredFields:e}).pipe(Object(a.map)(e=>Object.assign(Object.assign({},t),{handle:e.firstName+(e.lastName?" "+e.lastName:""),serverProfile:e}))):Object(d.of)(t)))))}setActiveSessionForProfile(e){return Object(d.defer)(()=>this.generateSessionEndTelemetry()).pipe(Object(a.mergeMap)(()=>this.dbService.read({table:o.f.TABLE_NAME,selection:o.f.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})),Object(a.map)(e=>e&&e[0]&&E.mapProfileDBEntryToProfile(e[0])),Object(a.map)(e=>{if(!e)throw new r.NoProfileFoundError("No Profile found");return e}),Object(a.mergeMap)(e=>Object(d.iif)(()=>e.source===r.ProfileSource.SERVER,Object(d.defer)(()=>this.getServerProfilesDetails({userId:e.uid,requiredFields:[]}).pipe(Object(a.map)(t=>Object.assign(Object.assign({},e),{serverProfile:t})),Object(a.mergeMap)(e=>this.frameworkService.setActiveChannelId(e.serverProfile.rootOrg.hashTagId)),Object(a.catchError)(()=>Object(d.of)(void 0)))),this.frameworkService.setActiveChannelId(this.sdkConfig.apiConfig.api_authentication.channelId).pipe(Object(a.mapTo)(void 0))).pipe(Object(a.mapTo)(e))),Object(a.mergeMap)(e=>{const t=new r.ProfileSession(e.uid);return le.CsModule.instance.isInitialised&&le.CsModule.instance.updateConfig(Object.assign(Object.assign({},le.CsModule.instance.config),{core:Object.assign(Object.assign({},le.CsModule.instance.config.core),{global:Object.assign(Object.assign({},le.CsModule.instance.config.core.global),{sessionId:t.sid})})})),this.sharedPreferences.putString(Se.KEY_USER_SESSION,JSON.stringify(t)).pipe(Object(a.mapTo)(!0))}),Object(a.tap)(()=>Ce(this,void 0,void 0,(function*(){return yield this.generateSessionStartTelemetry()}))))}getActiveProfileSession(){return this.sharedPreferences.getString(Se.KEY_USER_SESSION).pipe(Object(a.map)(e=>{if(e)return JSON.parse(e);throw new r.NoActiveSessionError("No active session available")}))}acceptTermsAndConditions(e){return new p(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}isProfileAlreadyInUse(e){return new v(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}generateOTP(e){return new C(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}verifyOTP(e){return new g(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}searchLocation(e){return new T(this.apiService,this.sdkConfig.profileServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getAllContentAccess(e){const t=`SELECT * FROM ${_.a.TABLE_NAME} ${N.a.getUidnIdentifierFiler(e.uid,e.contentId)}`;return this.dbService.execute(t).pipe(Object(a.map)(e=>e.map(e=>class{static mapDBEntryToContenetAccess(e){const t=e[_.a.COLUMN_NAME_LEARNER_STATE];return{status:Number(e[_.a.COLUMN_NAME_STATUS]),contentId:e[_.a.COLUMN_NAME_CONTENT_IDENTIFIER],contentType:e[_.a.COLUMN_NAME_CONTENT_TYPE],contentLearnerState:{learnerState:t&&JSON.parse(t)}}}}.mapDBEntryToContenetAccess(e))))}addContentAccess(e){return this.getActiveProfileSession().pipe(Object(a.mergeMap)(({uid:t})=>this.dbService.read({table:_.a.TABLE_NAME,selection:`${_.a.COLUMN_NAME_UID}= ? AND ${_.a.COLUMN_NAME_CONTENT_IDENTIFIER}= ?`,selectionArgs:[t,e.contentId],orderBy:_.a.COLUMN_NAME_EPOCH_TIMESTAMP+" DESC",limit:"1"}).pipe(Object(a.mergeMap)(n=>{const i={uid:t,identifier:e.contentId,epoch_timestamp:Date.now(),status:r.ContentAccessStatus.PLAYED.valueOf(),content_type:e.contentType&&e.contentType.toLowerCase(),learner_state:e.contentLearnerState&&JSON.stringify(e.contentLearnerState.learnerState)};return n&&n.length?(i.status=n[0][_.a.COLUMN_NAME_STATUS],this.dbService.update({table:_.a.TABLE_NAME,selection:`${_.a.COLUMN_NAME_UID}= ? AND ${_.a.COLUMN_NAME_CONTENT_IDENTIFIER}= ?`,selectionArgs:[t,e.contentId],modelJson:i}).pipe(Object(a.map)(e=>e>0))):this.dbService.insert({table:_.a.TABLE_NAME,modelJson:i}).pipe(Object(a.map)(e=>e>0))}))))}exportProfile(e){const t={userIds:e.userIds,destinationFolder:e.destinationFolder,groupIds:e.groupIds};return Object(d.from)(new D(this.fileService).execute(t).then(e=>new P(this.dbService).execute(e.body)).then(e=>new U(this.dbService,this.fileService,this.deviceInfo).execute(e.body)).then(e=>new V(this.dbService,this.fileService).execute(e.body).catch(()=>e)).then(e=>new H(this.dbService).execute(e.body)).then(e=>({exportedFilePath:e.body.destinationDBFilePath})))}importProfile(e){const t={sourceDBFilePath:e.sourceFilePath};return Object(d.from)(new q(this.dbService).execute(t).then(e=>new K(this.dbService).execute(e.body)).then(e=>new se(this.dbService).execute(e.body)).then(e=>new W(this.dbService).execute(e.body)).then(e=>new J(this.dbService).execute(e.body)).then(e=>new Z(this.dbService).execute(e.body)).then(e=>new ne(this.dbService).execute(e.body)).then(e=>new re(this.dbService).execute(e.body)).then(e=>new G(this.dbService).execute(e.body)).then(e=>({failed:e.body.failed,imported:e.body.imported})))}mergeServerProfiles(e){const t=(new s.Request.Builder).withType(s.HttpRequestType.PATCH).withPath(Se.MERGE_SERVER_PROFILES_PATH).withBearerToken(!0).withHeaders({"x-source-user-token":e.from.accessToken,"x-authenticated-user-token":e.to.accessToken}).withBody({request:{fromAccountId:e.from.userId,toAccountId:e.to.userId}}).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>{console.log(e)}),Object(a.finalize)(()=>{const e=this.sdkConfig.apiConfig.user_authentication.mergeUserHost+this.sdkConfig.apiConfig.user_authentication.authUrl+"/logout?redirect_uri="+this.sdkConfig.apiConfig.host+"/oauth2callback",t=cordova.InAppBrowser.open(e,"_blank","zoom=no,hidden=yes");t.addEventListener("loadstart",e=>Ce(this,void 0,void 0,(function*(){e.url.indexOf("/oauth2callback")>-1&&t.close()})))}))}isDefaultChannelProfile(){return Object(d.zip)(this.frameworkService.getDefaultChannelId(),this.frameworkService.getActiveChannelId()).pipe(Object(a.map)(e=>e[0]===e[1]))}getUserFeed(){return this.getActiveProfileSession().pipe(Object(a.mergeMap)(e=>this.userService.getUserFeed(e.managedSession?e.managedSession.uid:e.uid,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath_V5})))}updateUserFeedEntry(e){return this.getActiveProfileSession().pipe(Object(a.mergeMap)(t=>this.userService.updateUserFeedEntry(t.managedSession?t.managedSession.uid:t.uid,e.feedEntryId,e.category,e.request,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath_V5}).pipe(Object(a.mapTo)(!0),Object(a.catchError)(()=>Object(d.of)(!1)))))}deleteUserFeedEntry(e){return this.getActiveProfileSession().pipe(Object(a.mergeMap)(t=>this.userService.deleteUserFeedEntry(t.managedSession?t.managedSession.uid:t.uid,e.feedEntryId,e.category,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath}).pipe(Object(a.mapTo)(!0),Object(a.catchError)(()=>Object(d.of)(!1)))))}userMigrate(e){return new ce(this.sdkConfig,this.apiService).handle(e)}updateServerProfileDeclarations(e){return this.userService.updateUserDeclarations(e.declarations,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}getConsent(e){return this.userService.getConsent(e,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}updateConsent(e){return this.userService.updateConsent(e,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}mapDbProfileEntriesToProfiles(e){return e.map(e=>E.mapProfileDBEntryToProfile(e))}generateSessionStartTelemetry(){return Ce(this,void 0,void 0,(function*(){return m.a.log.start({type:"session",env:"sdk"}).toPromise()}))}generateSessionEndTelemetry(){return Ce(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(Se.KEY_USER_SESSION).toPromise();if(e){const t=JSON.parse(e);yield m.a.log.end({type:"session",env:"sdk",duration:Math.floor((Date.now()-t.createdTime)/1e3)}).toPromise()}}))}deleteProfileData(e){return new pe(this.dbService).delete(e)}deleteUser(e){return new _e(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}};ge.KEY_USER_SESSION=y.m.KEY_USER_SESSION,ge.MERGE_SERVER_PROFILES_PATH="/api/user/v1/account/merge",ge=Se=be([Object(ae.injectable)(),ve(0,Object(ae.inject)(l.b.CONTAINER)),ve(1,Object(ae.inject)(l.b.SDK_CONFIG)),ve(2,Object(ae.inject)(l.b.DB_SERVICE)),ve(3,Object(ae.inject)(l.b.API_SERVICE)),ve(4,Object(ae.inject)(l.b.CACHED_ITEM_STORE)),ve(5,Object(ae.inject)(l.b.KEY_VALUE_STORE)),ve(6,Object(ae.inject)(l.b.SHARED_PREFERENCES)),ve(7,Object(ae.inject)(l.b.FRAMEWORK_SERVICE)),ve(8,Object(ae.inject)(l.b.FILE_SERVICE)),ve(9,Object(ae.inject)(l.b.DEVICE_INFO)),ve(10,Object(ae.inject)(l.b.AUTH_SERVICE)),ve(11,Object(ae.inject)(l.a.USER_SERVICE)),Oe("design:paramtypes",[ae.Container,Object,i.DbService,Object,Object,Object,Object,Object,Object,Object,Object,Object])],ge)},function(e,t,n){"use strict";n.d(t,"a",(function(){return z}));var r=n(34),i=n(3),o=n(7),s=n(0);class a{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_BATCH_DETAILS_ENDPOINT="/batch/read/"}handle(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.GET).withPath(this.courseServiceConfig.apiPath+this.GET_BATCH_DETAILS_ENDPOINT+e.batchId).withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>e.body.result.response))}}var c=n(100);class u{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_COURSE_BATCHES="/batch/list?creatorDetails"}handle(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(this.courseServiceConfig.apiPath+this.GET_COURSE_BATCHES).withBearerToken(!0).withUserToken(!1).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>Array.from(new Set(e.body.result.response.content))))}}var d=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class l{constructor(e,t,n,r,i){this.keyValueStore=e,this.apiService=t,this.courseServiceConfig=n,this.sharedPreference=r,this.apiHandler=i,this.GET_ENROLLED_COURSES_ENDPOINT="/user/enrollment/list/",this.STORED_ENROLLED_COURSES_PREFIX="enrolledCourses"}handle(e){return this.keyValueStore.getValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId).pipe(Object(s.mergeMap)(t=>{if(t){if(e.returnFreshCourses)return this.fetchFromServer(e).pipe(Object(s.mergeMap)(t=>this.keyValueStore.setValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(t)).pipe(Object(s.mapTo)(t.result.courses),Object(s.tap)(e=>Object(i.from)(this.updateLastPlayedContent(e))))),Object(s.catchError)(()=>{const e=JSON.parse(t),n=e.result;let r;return r=n&&n.hasOwnProperty("courses")?n.courses:e.courses,Object(i.of)(r)}));{const e=JSON.parse(t),n=e.result;let r;return r=n&&n.hasOwnProperty("courses")?n.courses:e.courses,Object(i.of)(r)}}return this.fetchFromServer(e).pipe(Object(s.mergeMap)(t=>this.keyValueStore.setValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(t)).pipe(Object(s.mapTo)(t.result.courses),Object(s.tap)(e=>Object(i.from)(this.updateLastPlayedContent(e))))))}))}updateLastPlayedContent(e){return d(this,void 0,void 0,(function*(){for(const t of e){const e=r.CourseServiceImpl.LAST_READ_CONTENTID_PREFIX.concat("_").concat(t.userId).concat("_").concat(t.contentId).concat("_").concat(t.batchId),n=t.lastReadContentId;t.lastReadContentId&&(yield this.sharedPreference.putString(e,n).toPromise())}return Promise.resolve(!0)}))}fetchFromServer(e){if(this.apiHandler)return this.apiHandler.handle(e);const t=(new o.Request.Builder).withType(o.HttpRequestType.GET).withPath(this.courseServiceConfig.apiPath+this.GET_ENROLLED_COURSES_ENDPOINT+e.userId+"?orgdetails=orgName,email&fields=contentType,topic,name,channel,pkgVersion,primaryCategory,trackable&batchDetails=name,endDate,startDate,status,enrollmentType,createdBy,certificates").withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>e.body))}}var f=n(33),h=n(10);class E{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.ENROL_ENDPOINT="/enrol"}handle(e){delete e.batchStatus;const t=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(this.courseServiceConfig.apiPath+this.ENROL_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>"SUCCESS"===e.body.result.response),Object(s.tap)(()=>{this.generateAuditTelemetry(e)}))}generateAuditTelemetry(e){const t=new h.Actor;t.id=e.userId,t.type=h.Actor.TYPE_USER;const n=[{type:"CourseId",id:e.courseId},{type:"BatchId",id:e.batchId},{type:"UserId",id:e.userId}],r={env:"course",actor:t,currentState:h.AuditState.AUDIT_CREATED,updatedProperties:["courseId","userId","batchId"],objId:e.courseId,objType:"Course",rollUp:{l1:e.courseId},correlationData:n,type:"enrollment"};f.a.log.audit(r).toPromise()}}var p=n(21);class _{constructor(e,t){this.apiService=e,this.unenrollCourseServiceApiConfig=t,this.GET_UNENROLL_COURSE_ENDPOINT="/unenrol"}handle(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(this.unenrollCourseServiceApiConfig.apiPath+this.GET_UNENROLL_COURSE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>"SUCCESS"===e.body.result.response))}}var S=n(1),b=n(11),O=n(5),v=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class C{constructor(e,t,n){this.apiService=e,this.courseServiceConfig=t,this.container=n}get csCourseService(){return this.container.get(O.a.COURSE_SERVICE)}get contentService(){return this.container.get(O.b.CONTENT_SERVICE)}handle(e){return delete e.returnRefreshedContentStates,Object(i.iif)(()=>!e.contentIds||!e.contentIds.length,Object(i.defer)(()=>v(this,void 0,void 0,(function*(){return e.contentIds=yield this.contentService.getContentDetails({contentId:e.courseId}).toPromise().then(e=>e.contentData.leafNodes||[]),this.fetchFromApi(e).toPromise()}))),Object(i.defer)(()=>this.fetchFromApi(e)))}fetchFromApi(e){return e.contentIds&&!e.contentIds.length&&delete e.contentIds,this.csCourseService.getContentState(e).pipe(Object(s.map)(e=>({contentList:e})))}}var g=n(14);class A{constructor(e,t){this.keyValueStore=e,this.offlineContentStateHandler=t}updateEnrollCourses(e){const t=A.GET_ENROLLED_COURSES_KEY_PREFIX.concat(e.userId);return this.offlineContentStateHandler.getLocalContentStateResponse(e).pipe(Object(s.mergeMap)(n=>this.keyValueStore.getValue(t).pipe(Object(s.mergeMap)(r=>{if(r){const o=JSON.parse(r),a=o.result;let c;c=a&&a.hasOwnProperty("courses")?a.courses:o.courses;const u=[...c];return c.forEach(t=>{if(t.courseId===e.courseId&&t.batchId===e.batchId){const e=t;n.contentList.forEach(n=>{if(2===n.status){let r=t.contentsPlayedOffline;r||(r=[]),r.push(n.contentId),e.contentsPlayedOffline=g.a.deDupe(r)}});const r=u.findIndex(e=>e.contentId===t.contentId&&e.batchId===t.batchId);u.splice(r,1,e)}}),u&&u.length?(a&&a.hasOwnProperty("courses")?a.courses=u:o.courses=u,this.keyValueStore.setValue(t,JSON.stringify(o)).pipe(Object(s.map)(()=>n))):Object(i.of)(n)}return Object(i.of)(n)}))))}}A.GET_ENROLLED_COURSES_KEY_PREFIX="enrolledCourses";class T{constructor(e){this.keyValueStore=e}getLocalContentStateResponse(e){const t=r.CourseServiceImpl.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(t).pipe(Object(s.map)(e=>{const t={contentList:[]};if(e){const n=JSON.parse(e),r=n.result;return r&&r.hasOwnProperty("contentList")?(t.contentList=r.contentList,t):(t.contentList=n.contentList,t)}return t.contentList=t.contentList.map(e=>("string"==typeof e.score&&(e.score=void 0),e)),t}))}manipulateEnrolledCoursesResponseLocally(e){const t=r.CourseServiceImpl.GET_ENROLLED_COURSE_KEY_PREFIX.concat(e.userId);return this.keyValueStore.getValue(t).pipe(Object(s.mergeMap)(n=>{if(n){const r=JSON.parse(n),o=r.result;let s;if(s=o&&o.hasOwnProperty("courses")?o.courses:r.courses,s&&s.length){const n=[...s];return s.forEach(t=>{if(t.courseId===e.courseId&&t.batchId===e.batchId&&(t.contentsPlayedOffline&&t.contentsPlayedOffline.length||(t.contentsPlayedOffline=[]),1!==e.status&&(0===t.contentsPlayedOffline.length||t.contentsPlayedOffline.length>0&&!g.a.contains(t.contentsPlayedOffline,e.contentId)))){t.progress=t.progress?t.progress:0,t.progress=t.progress+1,t.completionPercentage=this.getCourseCompletionPercentage(t.leafNodesCount,t.progress);const r=t;let i=r.contentsPlayedOffline;i||(i=[]),i.push(e.contentId),r.contentsPlayedOffline=i,r.progress=t.progress,r.completionPercentage=t.completionPercentage;const o=n.findIndex(e=>e.contentId===t.contentId||e.batchId===t.batchId);n.splice(o,1,r)}}),n&&n.length?(o&&o.hasOwnProperty("courses")?o.courses=n:r.courses=n,this.keyValueStore.setValue(t,JSON.stringify(r))):Object(i.of)(!1)}return Object(i.of)(!1)}return Object(i.of)(!1)}))}manipulateGetContentStateResponseLocally(e){const t=r.CourseServiceImpl.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(t).pipe(Object(s.mergeMap)(n=>{if(n){const r={contentList:[]},o=JSON.parse(n),s=o.result;if(s&&s.hasOwnProperty("contentList")?r.contentList=s.contentList:r.contentList=o.contentList,r){let n,o=r.contentList;return o&&o.length?(o.forEach(t=>{t.contentId===e.contentId?t.status!==e.status&&(e.score=t.score,e.bestScore=t.bestScore,n=this.getContentState(e),o=o.filter(e=>e.contentId!==t.contentId)):n=this.getContentState(e)}),n?(o.push(n),r.contentList=o,this.keyValueStore.setValue(t,JSON.stringify(r))):Object(i.of)(!1)):(n=this.getContentState(e),o=[],o.push(n),r.contentList=o,this.keyValueStore.setValue(t,JSON.stringify(r)))}return Object(i.of)(!1)}return Object(i.of)(!1)}))}getCourseCompletionPercentage(e,t){if(0===e||void 0===e)return 0;const n=t/e*100;return isNaN(n)?0:n>100?100:Math.floor(n)}getContentState(e){return{id:e.userId,userId:e.userId,courseId:e.courseId,contentId:e.contentId,batchId:e.batchId,result:e.result,grade:e.grade,score:e.score,bestScore:e.bestScore,status:e.status,progress:e.progress}}}var N=n(6),y=n(40),m=n(299),I=n(27),M=n(22),D=n(50),R=n(29),P=n(37),L=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class w{constructor(e,t,n,r){this.courseService=e,this.sdkConfig=t,this.dbService=n,this.networkQueue=r,this.capturedAssessmentEvents={}}handle(e){return this.capturedAssessmentEvents=e,Object(i.from)(this.syncCapturedAssessmentEvents().then(()=>{this.capturedAssessmentEvents={}}).then(()=>this.syncPersistedAssessmentEvents()).catch(e=>{Object.keys(this.capturedAssessmentEvents).forEach(e=>{const t=JSON.parse(e);this.capturedAssessmentEvents[e].forEach(e=>{2!==t.batchStatus&&this.persistAssessEvent(e,t).toPromise()})})})).pipe(Object(s.mapTo)(void 0))}invokeSyncApi(e){return console.log("COURSE_ASSESSMENT_INVOKED_SYNC----------------------------------------------",e.assessments.map(e=>({assessmentTs:e.assessmentTs,userId:e.userId,contentId:e.contentId,courseId:e.courseId,batchId:e.batchId,attemptId:e.attemptId,events:e.events.length}))),this.networkQueue.enqueue(new D.a(this.sdkConfig).generateNetworkQueueRequest(M.b.COURSE_ASSESMENT,{request:e},R.a.generateUniqueId(),0,!0),!0).pipe(Object(s.mergeMap)(()=>new i.Observable(e=>{sbsync.onSyncSucces(t=>L(this,void 0,void 0,(function*(){const n=t.courseAssesmentResponse,r=t.course_assesment_error;n?e.next(n):r&&e.error(r),e.complete()})),t=>L(this,void 0,void 0,(function*(){e.error(t)})))}))).toPromise()}persistAssessEvent(e,t){return this.dbService.insert({table:I.a.TABLE_NAME,modelJson:{[I.a.COLUMN_NAME_ASSESSMENT_EVENT]:JSON.stringify(e),[I.a.COLUMN_NAME_CONTENT_ID]:e.object.id,[I.a.COLUMN_NAME_CREATED_AT]:e.ets,[I.a.COLUMN_NAME_USER_ID]:t.userId,[I.a.COLUMN_NAME_COURSE_ID]:t.courseId,[I.a.COLUMN_NAME_BATCH_ID]:t.batchId}}).pipe(Object(s.mapTo)(void 0))}syncCapturedAssessmentEvents(){return L(this,void 0,void 0,(function*(){const e=Object.keys(this.capturedAssessmentEvents).reduce((e,t)=>{const n=JSON.parse(t),r=this.capturedAssessmentEvents[t];e.userId||(e.userId=n.userId);const i={contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,status:2};e.contents.find(e=>P.a.equals(e,i))||e.contents.push(i);const o=r.reduce((e,t)=>t.ets<e?t.ets:e,r[0].ets);return e.assessments.push({assessmentTs:o,userId:n.userId,contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,attemptId:this.courseService.generateAssessmentAttemptId({courseId:n.courseId,batchId:n.batchId,contentId:r[0].object.id,userId:n.userId,date:o}),events:r}),e},{userId:"",contents:[],assessments:[]});if(e.userId&&e.contents.length&&e.assessments.length)return this.invokeSyncApi(e)}))}syncPersistedAssessmentEvents(){return L(this,void 0,void 0,(function*(){this.dbService.execute(`\n SELECT\n ${I.a.COLUMN_NAME_USER_ID},\n ${I.a.COLUMN_NAME_CONTENT_ID},\n ${I.a.COLUMN_NAME_COURSE_ID},\n ${I.a.COLUMN_NAME_BATCH_ID},\n MIN(${I.a.COLUMN_NAME_CREATED_AT}) as first_ts,\n GROUP_CONCAT(${I.a.COLUMN_NAME_ASSESSMENT_EVENT},',') as events\n FROM ${I.a.TABLE_NAME}\n GROUP BY\n ${I.a.COLUMN_NAME_USER_ID},\n ${I.a.COLUMN_NAME_CONTENT_ID},\n ${I.a.COLUMN_NAME_COURSE_ID},\n ${I.a.COLUMN_NAME_BATCH_ID}\n ORDER BY ${I.a.COLUMN_NAME_CREATED_AT}\n `).pipe(Object(s.map)(e=>e.map(e=>({userId:e[I.a.COLUMN_NAME_USER_ID],contentId:e[I.a.COLUMN_NAME_CONTENT_ID],courseId:e[I.a.COLUMN_NAME_COURSE_ID],batchId:e[I.a.COLUMN_NAME_BATCH_ID],firstTs:e.first_ts,events:JSON.parse("["+e.events+"]")}))),Object(s.mergeMap)(e=>{if(!e.length)return Object(i.of)(void 0);const t=e.reduce((e,{firstTs:t,userId:n,contentId:r,courseId:i,batchId:o,events:s})=>{e.userId||(e.userId=n);const a={contentId:r,courseId:i,batchId:o,status:2};return e.contents.find(e=>P.a.equals(e,a))||e.contents.push(a),e.assessments.push({assessmentTs:t,userId:n,contentId:r,courseId:i,batchId:o,attemptId:this.courseService.generateAssessmentAttemptId({courseId:i,batchId:o,contentId:r,userId:n}),events:s}),e},{userId:"",contents:[],assessments:[]});return this.invokeSyncApi(t)}),Object(s.tap)(()=>L(this,void 0,void 0,(function*(){return yield this.dbService.execute("DELETE FROM "+I.a.TABLE_NAME).toPromise()}))),Object(s.mapTo)(void 0)).toPromise()}))}}w.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update";var U=n(52);class j{constructor(e,t){this.apiService=e,this.cachedItemStore=t}handle(e){return this.cachedItemStore.get(e.userId,j.GET_LEARNER_CERTIFICATE_LOCAL_KEY,"ttl_"+j.GET_LEARNER_CERTIFICATE_LOCAL_KEY,()=>this.fetchFromServer(e))}fetchFromServer(e){let t=Object.assign(Object.assign({},e.size?{size:e.size}:null),{_source:["data.badge.issuer.name","pdfUrl","data.issuedOn","data.badge.name","related.courseId","related.Id"],query:{bool:{must:[{match_phrase:{"recipient.id":e.userId}}]}}});const n=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(j.CERTIFICATE_SEARCH_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:t}).build();return this.apiService.fetch(n).pipe(Object(s.map)(e=>e.body.result.response))}}j.CERTIFICATE_SEARCH_ENDPOINT="/api/certreg/v1/certs/search",j.GET_LEARNER_CERTIFICATE_LOCAL_KEY="learner-certificate";var F=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class x{constructor(e,t){this.keyValueStore=e,this.sharedPreference=t}process(e){return F(this,void 0,void 0,(function*(){if(1===(yield this.getCourseContext().toPromise()).batchStatus)for(const t of Object.keys(e)){const n=JSON.parse(t),r=e[t];if(!r)continue;const i=z.GET_CONTENT_STATE_KEY_PREFIX.concat(n.userId,n.courseId),o=yield this.keyValueStore.getValue(i).toPromise(),s=o?JSON.parse(o):{contentList:[]},a=r.reduce((e,t)=>{try{const r=t.context.cdata.find(e=>"AttemptId"===e.type).id,i=t.object.id,o=t.edata.item.maxscore,a=t.edata.score;if(e[i]){const t=e[i];t.attemptId=r,t.lastAttemptedOn=Date.now()+"",t.totalMaxScore+=o,t.totalScore+=a}else e[i]={attemptId:r,lastAttemptedOn:Date.now()+"",totalMaxScore:o,totalScore:a};s.contentList.find(e=>e.contentId===i)||s.contentList.push({lastAccessTime:"2021-01-14 07:09:32:602+0000",contentId:i,progress:100,batchId:n.batchId,courseId:n.courseId,collectionId:n.courseId,lastCompletedTime:"2021-01-14 07:09:32:810+0000",status:2})}catch(e){console.error(e)}return e},{});s.contentList=s.contentList.map(e=>e.score&&e.score.length?a[e.contentId]?(e.score.push(a[e.contentId]),e.bestScore&&e.bestScore.totalScore<a[e.contentId].totalScore&&(e.bestScore=a[e.contentId]),e):e:(e.score=a[e.contentId]?[a[e.contentId]]:[],e.bestScore=e.score.reduce((e,t)=>e?e.totalScore<t.totalScore?t:e:t,void 0),e)),console.log(s),yield this.keyValueStore.setValue(i,JSON.stringify(s)).toPromise()}}))}getCourseContext(){return this.sharedPreference.getString(b.f.COURSE_CONTEXT).pipe(Object(s.map)(e=>e?JSON.parse(e):{}))}}var k=n(58),B=n(73),V=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class Y{constructor(e,t,n,r){this.profileService=e,this.fileService=t,this.keyValueStore=n,this.csCourseService=r}isCertificateCached(e){return Object(i.defer)(()=>V(this,void 0,void 0,(function*(){try{return!!(yield this.getCertificateFromCache(e))}catch(e){return console.error(e),!1}})))}getCertificate(e){return this.csCourseService.getSignedCourseCertificate(e.certificate.identifier).pipe(Object(s.tap)(t=>V(this,void 0,void 0,(function*(){yield this.keyValueStore.setValue(yield this.buildCertificatePersistenceId(e),Object(k.gzip)(t.printUri,{to:"string"})).toPromise()}))),Object(s.map)(e=>e.printUri),Object(s.catchError)(t=>Object(i.defer)(()=>V(this,void 0,void 0,(function*(){const n=yield this.getCertificateFromCache(e);if(n)return n;throw t})))))}downloadCertificate({fileName:e,blob:t}){return Object(i.defer)(()=>V(this,void 0,void 0,(function*(){return this.fileService.writeFile(cordova.file.externalDataDirectory,e,t,{replace:!0}).then(()=>({path:`${cordova.file.externalDataDirectory}${e}`}))})))}buildCertificatePersistenceId(e){return V(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;return`certificate_${e.certificate.identifier}_${e.courseId}_${n}`}))}getCertificateFromCache(e){return V(this,void 0,void 0,(function*(){const t=yield this.keyValueStore.getValue(yield this.buildCertificatePersistenceId(e)).toPromise();return t?Object(B.ungzip)(t,{to:"string"}):void 0}))}}var G,H=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},q=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$=function(e,t){return function(n,r){t(n,r,e)}},K=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let z=G=class{constructor(e,t,n,r,i,o,s,a,c,u,d,l,f){this.sdkConfig=e,this.apiService=t,this.profileService=n,this.keyValueStore=r,this.dbService=i,this.sharedPreferences=o,this.appInfo=s,this.fileService=a,this.cachedItemStore=c,this.csCourseService=u,this.networkQueue=d,this.container=l,this.authService=f,this.capturedAssessmentEvents={},this.courseServiceConfig=this.sdkConfig.courseServiceConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.syncAssessmentEventsHandler=new w(this,this.sdkConfig,this.dbService,this.networkQueue),this.offlineAssessmentScoreProcessor=new x(this.keyValueStore,this.sharedPreferences)}get certificateManager(){return this._certificateManager||(this._certificateManager=new Y(this.profileService,this.fileService,this.keyValueStore,this.csCourseService)),this._certificateManager}static buildUrl(e,t,n){return`${e}${t}?${U.stringify(n)}`}getBatchDetails(e){return new a(this.apiService,this.courseServiceConfig).handle(e)}updateContentState(e){return e.target||(e.target=[r.UpdateContentStateTarget.LOCAL,r.UpdateContentStateTarget.SERVER]),Object(i.defer)(()=>K(this,void 0,void 0,(function*(){const t=new T(this.keyValueStore);if(e.target.indexOf(r.UpdateContentStateTarget.SERVER)>-1)try{yield new c.a(this.networkQueue,this.sdkConfig).handle(class{static getUpdateContentStateRequest(e){const t=[];return t.push(this.getRequestMap(e)),{userId:e.userId,contents:t}}static getUpdateContentStateListRequest(e,t){const n=[];return t.forEach(e=>{n.push(this.getRequestMap(e))}),{userId:e,contents:n}}static getRequestMap(e){const t={userId:e.userId,contentId:e.contentId,courseId:e.courseId,batchId:e.batchId,status:e.status,progress:e.progress};return e.result&&(t.result=e.result),e.grade&&(t.grade=e.grade),e.score&&(t.score=e.score),t}}.getUpdateContentStateRequest(e)).toPromise()}catch(e){}return e.target.indexOf(r.UpdateContentStateTarget.LOCAL)>-1&&(yield t.manipulateEnrolledCoursesResponseLocally(e).toPromise(),yield t.manipulateGetContentStateResponseLocally(e).toPromise()),!0})))}getCourseBatches(e){return new u(this.apiService,this.courseServiceConfig).handle(e)}getEnrolledCourses(e,t){return new l(this.keyValueStore,this.apiService,this.courseServiceConfig,this.sharedPreferences,t).handle(e)}getUserEnrolledCourses({request:e,from:t}){return this.cachedItemStore[t===p.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](e.userId+(e.filters?"_"+JSON.stringify(e.filters):""),G.USER_ENROLLMENT_LIST_KEY_PREFIX,"ttl_"+G.USER_ENROLLMENT_LIST_KEY_PREFIX,()=>this.csCourseService.getUserEnrolledCourses(e,{},{apiPath:"/api/course/v2",certRegistrationApiPath:""}))}enrollCourse(e){return new E(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(s.mergeMap)(t=>{if(t){const n={};return n.userId=e.userId,n.batchStatus=e.batchStatus,this.sharedPreferences.putString(b.f.COURSE_CONTEXT,JSON.stringify(n)).pipe(Object(s.delay)(2e3),Object(s.concatMap)(()=>this.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})),Object(s.mapTo)(t))}return Object(i.of)(t)}))}getContentState(e){const t=G.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId),n=new T(this.keyValueStore),r=new A(this.keyValueStore,n);return this.keyValueStore.getValue(t).pipe(Object(s.mergeMap)(o=>!o||e.returnRefreshedContentStates?new C(this.apiService,this.courseServiceConfig,this.container).handle(e).pipe(Object(s.mergeMap)(o=>o?this.keyValueStore.setValue(t,JSON.stringify(o)).pipe(Object(s.mergeMap)(()=>n.getLocalContentStateResponse(e)),Object(s.mergeMap)(()=>r.updateEnrollCourses(e))):Object(i.of)(void 0)),Object(s.catchError)(t=>n.getLocalContentStateResponse(e).pipe(Object(s.mergeMap)(()=>r.updateEnrollCourses(e))))):n.getLocalContentStateResponse(e)))}unenrollCourse(e){return new _(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(s.delay)(2e3),Object(s.concatMap)(()=>this.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})),Object(s.mapTo)(!0))}downloadCurrentProfileCourseCertificate(e){return Object(i.defer)(()=>K(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalRootDirectory,e.certificate.name,e.courseId;return{userId:n}}))).pipe(Object(s.mergeMap)(({userId:t})=>{const n=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(G.CERTIFICATE_SIGN_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:{pdfUrl:e.certificate.url}}).build();return this.apiService.fetch(n).pipe(Object(s.map)(e=>({signedPdfUrl:e.body.result.signedUrl,userId:t})))}),Object(s.mergeMap)(({signedPdfUrl:t,userId:n})=>{const r={uri:t,title:e.certificate.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:`/${e.certificate.name}_${e.courseId}_${n}.pdf`},headers:[]};return new i.Observable(e=>{downloadManager.enqueue(r,(t,n)=>{if(t)return e.error(t);e.next(n),e.complete()})})}),Object(s.mergeMap)(e=>Object(i.interval)(1e3).pipe(Object(s.mergeMap)(()=>new i.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||n[0].status===y.DownloadStatus.STATUS_FAILED?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(s.filter)(e=>e.status===y.DownloadStatus.STATUS_SUCCESSFUL),Object(s.take)(1))),Object(s.map)(e=>({path:e.localUri})))}hasCapturedAssessmentEvent({courseContext:e}){const t=P.a.toOrderedString(e);return!!this.capturedAssessmentEvents[t]}captureAssessmentEvent({event:e,courseContext:t}){const n=P.a.toOrderedString(t);this.capturedAssessmentEvents[n]||(this.capturedAssessmentEvents[n]=[]),this.capturedAssessmentEvents[n].push(e)}syncAssessmentEvents(e={persistedOnly:!1}){let t={};return e.persistedOnly||(t=this.capturedAssessmentEvents,this.resetCapturedAssessmentEvents()),this.offlineAssessmentScoreProcessor.process(t),this.syncAssessmentEventsHandler.handle(t)}resetCapturedAssessmentEvents(){this.capturedAssessmentEvents={}}generateAssessmentAttemptId(e){return m([e.courseId,e.batchId,e.contentId,e.userId,e.date?e.date:Date.now()].join("-")).toString()}displayDiscussionForum(e){return Object(i.defer)(()=>K(this,void 0,void 0,(function*(){const t=yield this.authService.getSession().toPromise();if(!t)return!1;const n=t.managed_access_token||t.access_token;return cordova.InAppBrowser.open(G.buildUrl(this.sdkConfig.apiConfig.host,G.DISCUSSION_FORUM_ENDPOINT,{access_token:n,returnTo:"/category/"+e.forumId}),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes,hideurlbar=yes,hidenavigationbuttons=true"),!0})))}getLearnerCertificates(e){return new j(this.apiService,this.cachedItemStore).handle(e)}syncCourseProgress(e){return this.csCourseService.updateContentState(e,{apiPath:"/api/course/v1"})}clearAssessments(){return this.sharedPreferences.getString(b.f.COURSE_CONTEXT).pipe(Object(s.map)(e=>{const t=e?JSON.parse(e):{};if(t){const e=P.a.toOrderedString(t);this.capturedAssessmentEvents[e]&&(this.capturedAssessmentEvents[e]=[])}}))}};z.USER_ENROLLMENT_LIST_KEY_PREFIX="userEnrollmentList",z.GET_CONTENT_STATE_KEY_PREFIX="getContentState",z.GET_ENROLLED_COURSE_KEY_PREFIX="enrolledCourses",z.UPDATE_CONTENT_STATE_KEY_PREFIX="updateContentState",z.LAST_READ_CONTENTID_PREFIX="lastReadContentId",z.CERTIFICATE_SIGN_ENDPOINT="/api/certreg/v1/certs/download",z.DISCUSSION_FORUM_ENDPOINT="/discussions/auth/sunbird-oidc/callback",z=G=H([Object(N.injectable)(),$(0,Object(N.inject)(O.b.SDK_CONFIG)),$(1,Object(N.inject)(O.b.API_SERVICE)),$(2,Object(N.inject)(O.b.PROFILE_SERVICE)),$(3,Object(N.inject)(O.b.KEY_VALUE_STORE)),$(4,Object(N.inject)(O.b.DB_SERVICE)),$(5,Object(N.inject)(O.b.SHARED_PREFERENCES)),$(6,Object(N.inject)(O.b.APP_INFO)),$(7,Object(N.inject)(O.b.FILE_SERVICE)),$(8,Object(N.inject)(O.b.CACHED_ITEM_STORE)),$(9,Object(N.inject)(O.a.COURSE_SERVICE)),$(10,Object(N.inject)(O.b.NETWORK_QUEUE)),$(11,Object(N.inject)(O.b.CONTAINER)),$(12,Object(N.inject)(O.b.AUTH_SERVICE)),q("design:paramtypes",[Object,Object,Object,Object,S.DbService,Object,Object,Object,Object,Object,Object,N.Container,Object])],z)},function(e,t,n){"use strict";n.d(t,"a",(function(){return C}));var r=n(21),i=n(45),o=n(7),s=n(3),a=n(0);class c{constructor(e,t,n,r){this.apiService=e,this.frameworkServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.CHANNEL_FILE_KEY_PREFIX="channel-",this.CHANNEL_LOCAL_KEY="channel-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}handle(e){return this.cachedItemStore[e.from===r.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](e.channelId,this.CHANNEL_LOCAL_KEY,"ttl_"+this.CHANNEL_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e)).pipe(Object(a.map)(e=>(e.frameworks&&e.frameworks.sort((e,t)=>e.name.localeCompare(t.name)),e)))}fetchFromServer(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.GET).withPath(this.frameworkServiceConfig.channelApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.channelId).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>e.body.result.channel))}fetchFromFile(e){const t=i.a.getAssetPath()+this.frameworkServiceConfig.channelConfigDirPath,n=this.CHANNEL_FILE_KEY_PREFIX+e.channelId+".json";return Object(s.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(a.map)(e=>JSON.parse(e).result.channel))}}var u=n(64);class d{constructor(e,t,n,r,i){this.frameworkService=e,this.apiService=t,this.frameworkServiceConfig=n,this.fileService=r,this.cachedItemStore=i,this.FRAMEWORK_FILE_KEY_PREFIX="framework-",this.FRAMEWORK_LOCAL_KEY="framework-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}handle(e){return Object(s.iif)(()=>!!e.frameworkId,Object(s.defer)(()=>this.cachedItemStore[e.from===r.CachedItemRequestSourceFrom.SERVER?"get":"getCached"](e.frameworkId,this.FRAMEWORK_LOCAL_KEY,"ttl_"+this.FRAMEWORK_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e))),Object(s.defer)(()=>this.frameworkService.getDefaultChannelDetails().pipe(Object(a.mergeMap)(t=>this.frameworkService.getFrameworkDetails({from:e.from,frameworkId:t.defaultFramework,requiredCategories:e.requiredCategories})))))}fetchFromServer(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.GET).withPath(this.frameworkServiceConfig.frameworkApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.frameworkId).withParameters({categories:e.requiredCategories.join(",")}).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>e.body.result.framework),Object(a.map)(e=>u.a.prepareFrameworkCategoryAssociations(e)))}fetchFromFile(e){const t=i.a.getAssetPath()+this.frameworkServiceConfig.frameworkConfigDirPath,n=this.FRAMEWORK_FILE_KEY_PREFIX+e.frameworkId+".json";return Object(s.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(a.map)(e=>JSON.parse(e).result.framework),Object(a.map)(e=>u.a.prepareFrameworkCategoryAssociations(e)))}}var l=n(19);class f extends l.a{constructor(e){super(e,"NO_ACTIVE_CHANNEL_FOUND_ERROR"),Object.setPrototypeOf(this,f.prototype)}}var h,E=n(11),p=n(6),_=n(5),S=n(13),b=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},O=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},v=function(e,t){return function(n,r){t(n,r,e)}};let C=h=class{constructor(e,t,n,r,i,o,s){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r,this.sharedPreferences=i,this.systemSettingsService=o,this.csFrameworkService=s}get activeChannelId(){return this._activeChannelId}preInit(){return this.getActiveChannelId().pipe(Object(a.tap)(e=>this._activeChannelId=e),Object(a.mapTo)(void 0),Object(a.catchError)(e=>{if(e instanceof f)return this.setActiveChannelId(this.sdkConfig.apiConfig.api_authentication.channelId);throw e}))}getDefaultChannelId(){return Object(s.iif)(()=>!this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId,Object(s.defer)(()=>this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(a.map)(e=>e.value))),Object(s.defer)(()=>Object(s.of)(this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId)))}getDefaultChannelDetails(e={from:r.CachedItemRequestSourceFrom.CACHE}){return this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(a.map)(e=>e.value),Object(a.mergeMap)(t=>this.getChannelDetails({from:e.from,channelId:this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId||t})))}getChannelDetails(e){return new c(this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getFrameworkDetails(e){return new d(this,this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getFrameworkConfig(e,t){let n;return t&&(n={type:t.type,subType:t.subType,action:t.action,rootOrgId:t.rootOrgId,framework:t.framework,component:t.component}),this.csFrameworkService.getFrameworkConfig(e,{apiPath:"/api/framework/v1"},{apiPath:"/api/data/v1/form",params:n})}searchOrganization(e){const t=(new o.Request.Builder).withType(o.HttpRequestType.POST).withPath(this.sdkConfig.frameworkServiceConfig.searchOrganizationApiPath+h.SEARCH_ORGANIZATION_ENDPOINT).withBody({request:e}).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(a.map)(e=>e.body.result.response))}getActiveChannelId(){return this.sharedPreferences.getString(h.KEY_ACTIVE_CHANNEL_ID).pipe(Object(a.map)(e=>{if(!e)throw new f("No Active channel ID set in preferences");return e}))}setActiveChannelId(e){return this._activeChannelId=e,S.CsModule.instance.isInitialised&&S.CsModule.instance.updateConfig(Object.assign(Object.assign({},S.CsModule.instance.config),{core:Object.assign(Object.assign({},S.CsModule.instance.config.core),{global:Object.assign(Object.assign({},S.CsModule.instance.config.core.global),{channelId:e})})})),this.sharedPreferences.putString(h.KEY_ACTIVE_CHANNEL_ID,e)}};C.KEY_ACTIVE_CHANNEL_ID=E.j.KEY_ACTIVE_CHANNEL_ID,C.SEARCH_ORGANIZATION_ENDPOINT="/search",C=h=b([Object(p.injectable)(),v(0,Object(p.inject)(_.b.SDK_CONFIG)),v(1,Object(p.inject)(_.b.FILE_SERVICE)),v(2,Object(p.inject)(_.b.API_SERVICE)),v(3,Object(p.inject)(_.b.CACHED_ITEM_STORE)),v(4,Object(p.inject)(_.b.SHARED_PREFERENCES)),v(5,Object(p.inject)(_.b.SYSTEM_SETTINGS_SERVICE)),v(6,Object(p.inject)(_.a.FRAMEWORK_SERVICE)),O("design:paramtypes",[Object,Object,Object,Object,Object,Object,Object])],C)},function(e,t,n){"use strict";n.d(t,"a",(function(){return p}));var r=n(6),i=n(7),o=n(3),s=n(11),a=n(0),c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(e,t,n,r,i,o,s){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=s,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(e){return this.registerDevice(e)}registerDevice(e){return Object(o.zip)(this.deviceInfo.getDeviceSpec(),this.frameworkService.getActiveChannelId(),this.appInfoService.getFirstAccessTimestamp(),this.sharedPreferences.getString(s.g.DEVICE_LOCATION)).pipe(Object(a.mergeMap)(t=>c(this,void 0,void 0,(function*(){const n=t[0],r=t[1],o=t[2],c=t[3];if(!(e=Object.assign(Object.assign({},e||{}),{dspec:n,channel:r,fcmToken:this.deviceRegisterConfig.fcmToken,producer:this.apiConfig.api_authentication.producerId,first_access:Number(o)})).userDeclaredLocation&&c&&(e.userDeclaredLocation=JSON.parse(c),!e.userDeclaredLocation.declaredOffline))try{const t=yield this.getDeviceProfileHandler.handle().toPromise();t.userDeclaredLocation&&t.userDeclaredLocation.state&&t.userDeclaredLocation.district||(delete e.userDeclaredLocation,this.sharedPreferences.putString(s.g.DEVICE_LOCATION,"").toPromise())}catch(t){console.error(t),delete e.userDeclaredLocation}e.userDeclaredLocation&&delete e.userDeclaredLocation.declaredOffline;const d=(new i.Request.Builder).withType(i.HttpRequestType.POST).withPath(this.deviceRegisterConfig.apiPath+u.DEVICE_REGISTER_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(d).pipe(Object(a.map)(e=>e.body),Object(a.tap)(()=>{e.userDeclaredLocation&&this.sharedPreferences.putString(s.g.DEVICE_LOCATION,JSON.stringify(e.userDeclaredLocation)).toPromise()})).toPromise()}))))}}u.DEVICE_REGISTER_ENDPOINT="/register";var d=n(5);class l{constructor(e,t,n){this.sdkConfig=e,this.deviceInfo=t,this.apiService=n,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(){return this.fetchFromServer()}fetchFromServer(){return this.apiService.fetch((new i.Request.Builder).withType(i.HttpRequestType.GET).withPath(this.deviceRegisterConfig.apiPath+l.GET_DEVICE_PROFILE_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withBearerToken(!0).build()).pipe(Object(a.map)(e=>e.body.result))}}l.GET_DEVICE_PROFILE_ENDPOINT="/profile";var f=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},h=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},E=function(e,t){return function(n,r){t(n,r,e)}};let p=class{constructor(e,t,n,r,i,o){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=new l(this.sdkConfig,this.deviceInfo,this.apiService),this.deviceRegisterHandler=new u(this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.frameworkService,this.appInfoService,this.apiService,this.getDeviceProfileHandler)}registerDevice(e){return this.deviceRegisterHandler.handle(e)}getDeviceProfile(){return this.getDeviceProfileHandler.handle()}};p=f([Object(r.injectable)(),E(0,Object(r.inject)(d.b.SDK_CONFIG)),E(1,Object(r.inject)(d.b.DEVICE_INFO)),E(2,Object(r.inject)(d.b.SHARED_PREFERENCES)),E(3,Object(r.inject)(d.b.FRAMEWORK_SERVICE)),E(4,Object(r.inject)(d.b.APP_INFO)),E(5,Object(r.inject)(d.b.API_SERVICE)),h("design:paramtypes",[Object,Object,Object,Object,Object,Object])],p)},function(e,t,n){"use strict";n.d(t,"a",(function(){return v}));var r=n(3),i=n(6),o=n(5),s=n(11),a=n(72),c=n(18),u=n(0),d=n(32),l=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class f{constructor(e,t,n,r){this.sharedPreferences=e,this.apiConfig=t,this.deviceInfo=n,this.apiService=r,this.apiTokenHandler=new a.a(this.apiConfig,this.apiService,this.deviceInfo)}interceptResponse(e,t){return t.responseCode===d.CsHttpResponseCode.HTTP_UNAUTHORISED&&"Unauthorized"===t.body.message||t.responseCode===d.CsHttpResponseCode.HTTP_FORBIDDEN?this.apiTokenHandler.refreshAuthToken().pipe(Object(u.tap)(e=>l(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(s.a.KEY_API_TOKEN,e).toPromise()}))),Object(u.mergeMap)(()=>this.apiService.fetch(e))):Object(r.of)(t)}}class h{constructor(e,t){this.apiService=e,this.authService=t}interceptResponse(e,t){return t.responseCode!==d.CsHttpResponseCode.HTTP_UNAUTHORISED||t.body.message?Object(r.of)(t):this.invokeRefreshSessionTokenApi().pipe(Object(u.mergeMap)(()=>this.apiService.fetch(e)))}invokeRefreshSessionTokenApi(){return this.authService.refreshSession()}}var E,p=n(13),_=n(80),S=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},b=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},O=function(e,t){return function(n,r){t(n,r,e)}};let v=E=class{constructor(e,t,n,r,i,o){this.container=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.eventsBusService=i,this.httpService=o,this.hasEmittedPlannedMaintenanceErrorEvent=!1,this.defaultRequestInterceptors=[],this.defaultResponseInterceptors=[],this.apiConfig=this.sdkConfig.apiConfig,this.apiConfig.debugMode&&(this.defaultRequestInterceptors=[new _.CsRequestLoggerInterceptor],this.defaultResponseInterceptors=[new _.CsResponseLoggerInterceptor])}get bearerTokenRefreshInterceptor(){return this._bearerTokenRefreshInterceptor||(this._bearerTokenRefreshInterceptor=new f(this.container.get(o.b.SHARED_PREFERENCES),this.container.get(o.b.SDK_CONFIG).apiConfig,this.container.get(o.b.DEVICE_INFO),this.container.get(o.b.API_SERVICE))),this._bearerTokenRefreshInterceptor}get userTokenRefreshInterceptor(){return this._userTokenRefreshInterceptor||(this._userTokenRefreshInterceptor=new h(this.container.get(o.b.API_SERVICE),this.container.get(o.b.AUTH_SERVICE))),this._userTokenRefreshInterceptor}onInit(){return this.sharedPreferences.addListener(s.a.KEY_API_TOKEN,e=>{p.CsModule.instance.config.core.api.authentication.bearerToken=e||void 0,p.CsModule.instance.updateConfig(p.CsModule.instance.config)}),this.sharedPreferences.getString(s.a.KEY_API_TOKEN).pipe(Object(u.mergeMap)(e=>e?(p.CsModule.instance.config.core.api.authentication.bearerToken=e,p.CsModule.instance.updateConfig(p.CsModule.instance.config),Object(r.of)(void 0)):new a.a(this.apiConfig,this,this.deviceInfo).refreshAuthToken().pipe(Object(u.mergeMap)(e=>this.sharedPreferences.putString(s.a.KEY_API_TOKEN,e)),Object(u.catchError)(()=>Object(r.of)(void 0)))))}fetch(e){if(this.defaultRequestInterceptors.forEach(t=>{-1===e.requestInterceptors.indexOf(t)&&e.requestInterceptors.push(t)}),this.defaultResponseInterceptors.forEach(t=>{-1===e.responseInterceptors.indexOf(t)&&e.responseInterceptors.push(t)}),e.withBearerToken){const t=e.responseInterceptors.indexOf(this.bearerTokenRefreshInterceptor);-1===t?e.responseInterceptors.push(this.bearerTokenRefreshInterceptor):e.responseInterceptors.splice(t,1)}if(e.withUserToken){const t=e.responseInterceptors.indexOf(this.userTokenRefreshInterceptor);-1===t?e.responseInterceptors.push(this.userTokenRefreshInterceptor):e.responseInterceptors.splice(t,1)}return this.httpService.fetch(e).pipe(Object(u.catchError)(e=>(d.CsHttpServerError.isInstance(e)?(this.eventsBusService.emit({namespace:c.EventNamespace.ERROR,event:{type:c.ErrorEventType.HTTP_SERVER_ERROR,payload:e}}),e.response.responseCode===E.PLANNED_MAINTENANCE_ERROR_CODE&&(this.hasEmittedPlannedMaintenanceErrorEvent||(this.hasEmittedPlannedMaintenanceErrorEvent=!0,this.eventsBusService.emit({namespace:c.EventNamespace.ERROR,event:{type:c.ErrorEventType.PLANNED_MAINTENANCE_PERIOD,payload:e}})))):d.CsHttpClientError.isInstance(e)&&this.eventsBusService.emit({namespace:c.EventNamespace.ERROR,event:{type:c.ErrorEventType.HTTP_CLIENT_ERROR,payload:e}}),Object(r.throwError)(e))))}setDefaultRequestInterceptors(e){this.defaultRequestInterceptors=e,this.apiConfig.debugMode&&this.defaultRequestInterceptors.push(new _.CsRequestLoggerInterceptor)}setDefaultResponseInterceptors(e){this.defaultResponseInterceptors=e,this.apiConfig.debugMode&&this.defaultResponseInterceptors.push(new _.CsResponseLoggerInterceptor)}};v.PLANNED_MAINTENANCE_ERROR_CODE=531,v=E=S([Object(i.injectable)(),O(0,Object(i.inject)(o.b.CONTAINER)),O(1,Object(i.inject)(o.b.SDK_CONFIG)),O(2,Object(i.inject)(o.b.DEVICE_INFO)),O(3,Object(i.inject)(o.b.SHARED_PREFERENCES)),O(4,Object(i.inject)(o.b.EVENTS_BUS_SERVICE)),O(5,Object(i.inject)(o.a.HTTP_SERVICE)),b("design:paramtypes",[i.Container,Object,Object,Object,Object,Object])],v)},function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var r=n(3),i=n(64),o=n(44),s=n.n(o),a=n(51),c=n(11),u=n(0),d=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};class l{constructor(e,t,n){this.frameworkUtilService=e,this.frameworkService=t,this.sharedPreferences=n}handle(e){return(()=>e.frameworkId?this.getTranslatedFrameworkDetails(e.frameworkId,e.requiredCategories,e.language):this.getActiveChannelTranslatedDefaultFrameworkDetails(e))().pipe(Object(u.tap)(e=>d(this,void 0,void 0,(function*(){return yield this.sharedPreferences.putString(c.j.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID,e.identifier).toPromise()}))),Object(u.map)(t=>{let n=[];if(n=!e.prevCategoryCode&&e.currentCategoryCode?this.getCategoryTerms(t,e).toArray():this.getCategoryAssociationTerms(t,e).toArray(),"gradeLevel"===e.currentCategoryCode){const e=n.reduce((e,t)=>t.index&&t.index>e?t.index:e,0);n.sort((t,n)=>(t.index||e+1)-(n.index||e+1))}else n.sort((e,t)=>e.name.localeCompare(t.name));const r=n.indexOf(n.find(e=>"Others"===e.name));if(r>=0&&r!==n.length){const e=n[n.length-1];n[n.length-1]=n[r],n[r]=e}return n}))}getActiveChannelTranslatedDefaultFrameworkDetails(e){return this.frameworkUtilService.getActiveChannel({from:e.from}).pipe(Object(u.mergeMap)(t=>this.getTranslatedFrameworkDetails(t.defaultFramework,e.requiredCategories,e.language,e.from)))}getTranslatedFrameworkDetails(e,t,n,r){return this.frameworkService.getFrameworkDetails({from:r,frameworkId:e,requiredCategories:t}).pipe(Object(u.map)(e=>i.a.prepareFrameworkTranslations(e,n)))}getAllCategoriesTermsSet(e){return e.categories?e.categories.reduce((e,t)=>[...e,t.terms||[]],[]).reduce((e,t)=>e.concat(t),[]).reduce((e,t)=>(e.add(t),e),new s.a(e=>Object(a.makeString)(e))):new s.a}getCategoryTerms(e,t){return e.categories.find(e=>e.code===t.currentCategoryCode).terms.reduce((e,t)=>(e.add(t),e),new s.a(e=>Object(a.makeString)(e)))}getCategoryAssociationTerms(e,t){if(!e.categories)return new s.a;const n=e.categories.find(e=>e.code===t.prevCategoryCode).terms;if(!n)return new s.a;const r=n.filter(e=>t.selectedTermsCodes.find(t=>t===e.code)).map(e=>e.associations||[]);return r.some(e=>0===e.length)?e.categories.find(e=>e.code===t.currentCategoryCode).terms.reduce((e,t)=>(e.add(t),e),new s.a(e=>Object(a.makeString)(e))):r.reduce((e,t)=>e.concat(t),[]).reduce((e,t)=>(e.add(t),e),new s.a(e=>Object(a.makeString)(e))).toArray().map(t=>this.getAllCategoriesTermsSet(e).toArray().find(e=>e.identifier===t.identifier)).reduce((e,t)=>(e.add(t),e),new s.a(e=>Object(a.makeString)(e)))}}var f=n(6),h=n(5),E=n(21),p=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},_=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},S=function(e,t){return function(n,r){t(n,r,e)}};let b=class{constructor(e,t,n){this.sharedPreferences=e,this.frameworkService=t,this.profileService=n}getActiveChannel(e={from:E.CachedItemRequestSourceFrom.CACHE}){return this.frameworkService.getActiveChannelId().pipe(Object(u.mergeMap)(t=>this.frameworkService.getChannelDetails({from:e.from,channelId:t})))}getActiveChannelSuggestedFrameworkList(e){return this.profileService.getActiveSessionProfile({requiredFields:[]}).pipe(Object(u.mergeMap)(t=>Object(r.iif)(()=>!!t.serverProfile&&!e.ignoreActiveChannel,Object(r.defer)(()=>this.getActiveChannel({from:e.from})),Object(r.defer)(()=>this.frameworkService.getDefaultChannelDetails({from:e.from})))),Object(u.mergeMap)(t=>t.frameworks?Object(r.of)(t.frameworks).pipe(Object(u.map)(t=>t.map(e=>i.a.prepareFrameworkCategoryAssociations(e)).map(t=>i.a.prepareFrameworkTranslations(t,e.language)))):this.frameworkService.getFrameworkDetails({from:e.from,frameworkId:t.defaultFramework,requiredCategories:e.requiredCategories}).pipe(Object(u.map)(e=>(e.index=0,[e])))))}getFrameworkCategoryTerms(e){return new l(this,this.frameworkService,this.sharedPreferences).handle(e)}};b=p([Object(f.injectable)(),S(0,Object(f.inject)(h.b.SHARED_PREFERENCES)),S(1,Object(f.inject)(h.b.FRAMEWORK_SERVICE)),S(2,Object(f.inject)(h.b.PROFILE_SERVICE)),_("design:paramtypes",[Object,Object,Object])],b)},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var r=n(45),i=n(7),o=n(3),s=n(0);class a{constructor(e,t,n,r){this.apiService=e,this.systemSettingsConfig=t,this.fileservice=n,this.cachedItemStore=r,this.SYSTEM_SETTINGS_FILE_KEY_PREFIX="system-setting-",this.SYSTEM_SETTINGS_LOCAL_KEY="system-settings-",this.GET_SYSTEM_SETTINGS_ENDPOINT="/system/settings/get"}handle(e){return this.cachedItemStore.getCached(e.id,this.SYSTEM_SETTINGS_LOCAL_KEY,"ttl_"+this.SYSTEM_SETTINGS_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e))}fetchFromServer(e){const t=(new i.Request.Builder).withType(i.HttpRequestType.GET).withPath(this.systemSettingsConfig.systemSettingsApiPath+this.GET_SYSTEM_SETTINGS_ENDPOINT+"/"+e.id).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>e.body.result.response))}fetchFromFile(e){const t=r.a.getAssetPath()+this.systemSettingsConfig.systemSettingsDirPath,n=this.SYSTEM_SETTINGS_FILE_KEY_PREFIX+e.id+".json";return Object(o.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(s.map)(e=>JSON.parse(e).result.response))}}var c=n(6),u=n(5),d=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},l=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},f=function(e,t){return function(n,r){t(n,r,e)}};let h=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedChannelItemStore=r,this.systemSettingsConfig=this.sdkConfig.systemSettingsConfig}getSystemSettings(e){return new a(this.apiService,this.systemSettingsConfig,this.fileService,this.cachedChannelItemStore).handle(e)}};h=d([Object(c.injectable)(),f(0,Object(c.inject)(u.b.SDK_CONFIG)),f(1,Object(c.inject)(u.b.API_SERVICE)),f(2,Object(c.inject)(u.b.FILE_SERVICE)),f(3,Object(c.inject)(u.b.CACHED_ITEM_STORE)),l("design:paramtypes",[Object,Object,Object,Object])],h)},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var r=n(45),i=n(7),o=n(3),s=n(0);class a{constructor(e,t,n,r){this.apiService=e,this.faqServiceConfig=t,this.fileservice=n,this.cachedItemStore=r,this.FAQ_FILE_KEY_PREFIX="faq-",this.FAQ_LOCAL_KEY="faq-new-"}handle(e){return this.cachedItemStore.getCached(e.language,this.FAQ_LOCAL_KEY,"ttl_"+this.FAQ_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e.language))}fetchFromServer(e){const t=(new i.Request.Builder).withType(i.HttpRequestType.GET).withHost(e.faqUrl).withPath("/faq-"+e.language+".json").withBearerToken(!1).build();return this.apiService.fetch(t).pipe(Object(s.map)(e=>{let t;try{t=JSON.parse(e.body.trim())}catch(n){t=e.body}return t}))}fetchFromFile(e){const t=r.a.getAssetPath()+this.faqServiceConfig.faqConfigDirPath,n=this.FAQ_FILE_KEY_PREFIX+e+".json";return Object(o.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(s.map)(e=>JSON.parse(e)))}}var c=n(6),u=n(5),d=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},l=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},f=function(e,t){return function(n,r){t(n,r,e)}};let h=class{constructor(e,t,n,r){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r}getFaqDetails(e){return new a(this.apiService,this.sdkConfig.faqServiceConfig,this.fileService,this.cachedItemStore).handle(e)}};h=d([Object(c.injectable)(),f(0,Object(c.inject)(u.b.SDK_CONFIG)),f(1,Object(c.inject)(u.b.FILE_SERVICE)),f(2,Object(c.inject)(u.b.API_SERVICE)),f(3,Object(c.inject)(u.b.CACHED_ITEM_STORE)),l("design:paramtypes",[Object,Object,Object,Object])],h)},function(e,t,n){"use strict";n.d(t,"a",(function(){return _}));var r=n(6),i=n(3),o=n(0),s=n(5),a=n(1),c=n(53);class u{constructor(e,t,n,r){this.dbService=e,this.container=t,this.certificateServiceConfig=n,this.apiConfig=r}get csCertificateService(){return this.container.get(s.a.CERTIFICATE_SERVICE)}handle(e){return this.dbService.read({table:c.a.TABLE_NAME,selection:c.a.COLUMN_NAME_IDENTIFIER+"= ?",selectionArgs:[e.osid.toString()]}).pipe(Object(o.mergeMap)(t=>t&&t.length?t[0].expiry_time<Date.now()?this.fetchFromServer(e).pipe(Object(o.mergeMap)(e=>this.updatePublicKey(e))):Object(i.of)({osid:t[0].identifier,value:t[0].public_key,alg:t[0].alg,osOwner:t[0].owner?t[0].owner.split(","):[]}):this.fetchFromServer(e).pipe(Object(o.mergeMap)(e=>this.insertPublicKey(e)))))}updatePublicKey(e){return this.dbService.update({table:c.a.TABLE_NAME,selection:c.a.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e.osid],modelJson:{identifier:e.osid,public_key:e.value,alg:e.alg,owner:e.osOwner&&e.osOwner.length?e.osOwner.join(","):"",expiry_time:Date.now()+this.apiConfig.cached_requests.timeToLive}}).pipe(Object(o.mapTo)(e))}insertPublicKey(e){return this.dbService.insert({table:c.a.TABLE_NAME,modelJson:{identifier:e.osid,public_key:e.value,alg:e.alg,owner:e.osOwner&&e.osOwner.length?e.osOwner.join(","):"",expiry_time:Date.now()+this.apiConfig.cached_requests.timeToLive}}).pipe(Object(o.mapTo)(e))}fetchFromServer(e){return this.csCertificateService.getPublicKey(e)}}var d=n(58),l=n(73),f=function(e,t,n,r){var i,o=arguments.length,s=o<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 a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},h=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},E=function(e,t){return function(n,r){t(n,r,e)}},p=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))};let _=class{constructor(e,t,n,r,i,o){this.container=e,this.dbService=t,this.sdkConfig=n,this.profileService=r,this.keyValueStore=i,this.fileService=o}getCertificates(e){return this.csCertificateService.fetchCertificates(e)}getPublicKey(e){return new u(this.dbService,this.container,this.sdkConfig.certificateServiceConfig,this.sdkConfig.apiConfig).handle(e)}getCertificate(e){return this.csCertificateService.getCerificateDownloadURI({certificateId:e.certificate.identifier,type:e.certificate.type,schemaName:"certificate",templateUrl:e.certificate.templateUrl}).pipe(Object(o.tap)(t=>p(this,void 0,void 0,(function*(){yield this.keyValueStore.setValue(yield this.buildCertificatePersistenceId(e),Object(d.gzip)(t.printUri,{to:"string"})).toPromise()}))),Object(o.map)(e=>e.printUri),Object(o.catchError)(t=>Object(i.defer)(()=>p(this,void 0,void 0,(function*(){const n=yield this.getCertificateFromCache(e);if(n)return n;throw t})))))}downloadCertificate({fileName:e,blob:t}){return Object(i.defer)(()=>p(this,void 0,void 0,(function*(){return this.fileService.writeFile(cordova.file.externalDataDirectory,e,t,{replace:!0}).then(()=>({path:`${cordova.file.externalDataDirectory}${e}`}))})))}downloadLegacyeCertificate(e){return Object(i.defer)(()=>p(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalRootDirectory,e.certificate.name,e.courseId;return{userId:n}}))).pipe(Object(o.mergeMap)(({userId:t})=>this.csCertificateService.getLegacyCerificateDownloadURI({pdfUrl:e.certificate.url}).pipe(Object(o.map)(e=>({signedPdfUrl:e.signedUrl,userId:t})))),Object(o.mergeMap)(({signedPdfUrl:t,userId:n})=>{const r={uri:t,title:e.certificate.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:`/${e.certificate.name}_${e.courseId}_${n}.pdf`},headers:[]};return new i.Observable(e=>{downloadManager.enqueue(r,(t,n)=>{if(t)return e.error(t);e.next(n),e.complete()})})}),Object(o.mergeMap)(e=>Object(i.interval)(1e3).pipe(Object(o.mergeMap)(()=>new i.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||n[0].status===DownloadStatus.STATUS_FAILED?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(o.filter)(e=>e.status===DownloadStatus.STATUS_SUCCESSFUL),Object(o.take)(1))),Object(o.map)(e=>({path:e.localUri})))}isCertificateCached(e){return Object(i.defer)(()=>p(this,void 0,void 0,(function*(){try{return!!(yield this.getCertificateFromCache(e))}catch(e){return console.error(e),!1}})))}getEncodedData(e){return this.csCertificateService.getEncodedData(e)}verifyCertificate(e){return this.csCertificateService.verifyCertificate(e)}get csCertificateService(){return this.container.get(s.a.CERTIFICATE_SERVICE)}buildCertificatePersistenceId(e){return p(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;return`certificate_${e.certificate.identifier}_${e.courseId}_${n}`}))}getCertificateFromCache(e){return p(this,void 0,void 0,(function*(){const t=yield this.keyValueStore.getValue(yield this.buildCertificatePersistenceId(e)).toPromise();return t?Object(l.ungzip)(t,{to:"string"}):void 0}))}};_=f([Object(r.injectable)(),E(0,Object(r.inject)(s.b.CONTAINER)),E(1,Object(r.inject)(s.b.DB_SERVICE)),E(2,Object(r.inject)(s.b.SDK_CONFIG)),E(3,Object(r.inject)(s.b.PROFILE_SERVICE)),E(4,Object(r.inject)(s.b.KEY_VALUE_STORE)),E(5,Object(r.inject)(s.b.FILE_SERVICE)),h("design:paramtypes",[r.Container,a.DbService,Object,Object,Object,Object])],_)},function(e,t,n){var r=n(352),i=n(353);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){var r;e.exports=(r=n(177),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],h=e[t+2],E=e[t+3],p=e[t+4],_=e[t+5],S=e[t+6],b=e[t+7],O=e[t+8],v=e[t+9],C=e[t+10],g=e[t+11],A=e[t+12],T=e[t+13],N=e[t+14],y=e[t+15],m=o[0],I=o[1],M=o[2],D=o[3];m=u(m,I,M,D,s,7,a[0]),D=u(D,m,I,M,c,12,a[1]),M=u(M,D,m,I,h,17,a[2]),I=u(I,M,D,m,E,22,a[3]),m=u(m,I,M,D,p,7,a[4]),D=u(D,m,I,M,_,12,a[5]),M=u(M,D,m,I,S,17,a[6]),I=u(I,M,D,m,b,22,a[7]),m=u(m,I,M,D,O,7,a[8]),D=u(D,m,I,M,v,12,a[9]),M=u(M,D,m,I,C,17,a[10]),I=u(I,M,D,m,g,22,a[11]),m=u(m,I,M,D,A,7,a[12]),D=u(D,m,I,M,T,12,a[13]),M=u(M,D,m,I,N,17,a[14]),m=d(m,I=u(I,M,D,m,y,22,a[15]),M,D,c,5,a[16]),D=d(D,m,I,M,S,9,a[17]),M=d(M,D,m,I,g,14,a[18]),I=d(I,M,D,m,s,20,a[19]),m=d(m,I,M,D,_,5,a[20]),D=d(D,m,I,M,C,9,a[21]),M=d(M,D,m,I,y,14,a[22]),I=d(I,M,D,m,p,20,a[23]),m=d(m,I,M,D,v,5,a[24]),D=d(D,m,I,M,N,9,a[25]),M=d(M,D,m,I,E,14,a[26]),I=d(I,M,D,m,O,20,a[27]),m=d(m,I,M,D,T,5,a[28]),D=d(D,m,I,M,h,9,a[29]),M=d(M,D,m,I,b,14,a[30]),m=l(m,I=d(I,M,D,m,A,20,a[31]),M,D,_,4,a[32]),D=l(D,m,I,M,O,11,a[33]),M=l(M,D,m,I,g,16,a[34]),I=l(I,M,D,m,N,23,a[35]),m=l(m,I,M,D,c,4,a[36]),D=l(D,m,I,M,p,11,a[37]),M=l(M,D,m,I,b,16,a[38]),I=l(I,M,D,m,C,23,a[39]),m=l(m,I,M,D,T,4,a[40]),D=l(D,m,I,M,s,11,a[41]),M=l(M,D,m,I,E,16,a[42]),I=l(I,M,D,m,S,23,a[43]),m=l(m,I,M,D,v,4,a[44]),D=l(D,m,I,M,A,11,a[45]),M=l(M,D,m,I,y,16,a[46]),m=f(m,I=l(I,M,D,m,h,23,a[47]),M,D,s,6,a[48]),D=f(D,m,I,M,b,10,a[49]),M=f(M,D,m,I,N,15,a[50]),I=f(I,M,D,m,_,21,a[51]),m=f(m,I,M,D,A,6,a[52]),D=f(D,m,I,M,E,10,a[53]),M=f(M,D,m,I,C,15,a[54]),I=f(I,M,D,m,c,21,a[55]),m=f(m,I,M,D,O,6,a[56]),D=f(D,m,I,M,y,10,a[57]),M=f(M,D,m,I,S,15,a[58]),I=f(I,M,D,m,T,21,a[59]),m=f(m,I,M,D,p,6,a[60]),D=f(D,m,I,M,g,10,a[61]),M=f(M,D,m,I,h,15,a[62]),I=f(I,M,D,m,v,21,a[63]),o[0]=o[0]+m|0,o[1]=o[1]+I|0,o[2]=o[2]+M|0,o[3]=o[3]+D|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296),s=r;n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+i+s;return(a<<o|a>>>32-o)+t}function d(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+i+s;return(a<<o|a>>>32-o)+t}function l(e,t,n,r,i,o,s){var a=e+(t^n^r)+i+s;return(a<<o|a>>>32-o)+t}function f(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+i+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)},function(e,t){e.exports=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(355),i=function(){function e(){this.list=new r.default}return e.prototype.enqueue=function(e){return this.list.add(e)},e.prototype.add=function(e){return this.list.add(e)},e.prototype.dequeue=function(){if(0!==this.list.size()){var e=this.list.first();return this.list.removeElementAtIndex(0),e}},e.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},e.prototype.size=function(){return this.list.size()},e.prototype.contains=function(e,t){return this.list.contains(e,t)},e.prototype.isEmpty=function(){return this.list.size()<=0},e.prototype.clear=function(){this.list.clear()},e.prototype.forEach=function(e){this.list.forEach(e)},e}();t.default=i},function(e,t){e.exports=h},function(e,t,n){var r=n(356);function i(){}function o(e,t,n){null==n&&(n=s),cordova.exec((function(){var e=Array.prototype.slice.call(arguments);e.unshift(null),n.apply(null,e)}),(function(e){e=e instanceof Error?e:new Error(e),n(e)}),"DownloadManagerPlugin",e,t||[])}function s(){}e.exports=new i,i.prototype.enqueue=function(e,t){"string"==typeof e&&(e={uri:e}),e.url&&(e.uri=e.url),r("string"==typeof e.uri,"req.uri must be string"),r(null==t||"function"==typeof t,"cb must be function"),r(null==e.title||"string"==typeof e.title,"req.title must be string"),r(null==e.description||"string"==typeof e.description,"req.description must be string"),r(null==e.mimeType||"string"==typeof e.mimeType,"req.mimeType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.dirType,"req.destinationInExternalFilesDir.dirType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.subPath,"req.destinationInExternalFilesDir.subPath must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.dirType,"req.destinationInExternalPublicDir.dirType must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.subPath,"req.destinationInExternalPublicDir.subPath must be string"),r(null==e.destinationUri||"string"==typeof e.destinationUri,"req.destinationUri must be string"),r(null==e.visibleInDownloadsUi||"boolean"==typeof e.visibleInDownloadsUi,"req.visibleInDownloadsUi must be boolean"),r(null==e.notificationVisibility||Number.isSafeInteger(e.notificationVisibility),"req.notificationVisibility must be safe integer"),o("enqueue",[e],t)},i.prototype.query=function(e,t){"function"==typeof e&&(t=e,e=null),null==e&&(e={}),r("function"==typeof t,"cb must be function"),o("query",[e],t)},i.prototype.remove=function(e,t){r(Array.isArray(e),"ids must be array"),r(null==t||"function"==typeof t,"cb must be function"),o("remove",e,t)},i.prototype.addCompletedDownload=function(e,t){o("addCompletedDownload",[e],t)},i.prototype.fetchSpeedLog=function(e){o("fetchSpeedLog",[],e)}},function(e,t,n){"use strict";n.r(t);n(305);var r=n(1);for(var i in r)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(83);for(var i in o)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var s=n(7);for(var i in s)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return s[e]}))}(i);var a=n(10);for(var i in a)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(i);var c=n(48);for(var i in c)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return c[e]}))}(i);var u=n(34);for(var i in u)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return u[e]}))}(i);var d=n(79);for(var i in d)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return d[e]}))}(i);var l=n(263);for(var i in l)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return l[e]}))}(i);var f=n(9);for(var i in f)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return f[e]}))}(i);var h=n(15);for(var i in h)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return h[e]}))}(i);var E=n(268);for(var i in E)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return E[e]}))}(i);var p=n(67);for(var i in p)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return p[e]}))}(i);var _=n(59);for(var i in _)["default"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return _[e]}))}(i);var S=n(25);n.d(t,"SunbirdSdk",(function(){return S.a}));var b=n(274);for(var i in b)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return b[e]}))}(i);var O=n(18);for(var i in O)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return O[e]}))}(i);var v=n(86);for(var i in v)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return v[e]}))}(i);var C=n(23);for(var i in C)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return C[e]}))}(i);var g=n(21);for(var i in g)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return g[e]}))}(i);var A=n(20);for(var i in A)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return A[e]}))}(i);var T=n(60);for(var i in T)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return T[e]}))}(i);var N=n(275);for(var i in N)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return N[e]}))}(i);var y=n(88);for(var i in y)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return y[e]}))}(i);var m=n(89);for(var i in m)["default","SunbirdSdk"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return m[e]}))}(i);var I=n(31);n.d(t,"ArchiveObjectType",(function(){return I.a})),n.d(t,"ExportAssertionError",(function(){return I.b})),n.d(t,"InvalidRequestError",(function(){return I.c})),n.d(t,"ObjectNotFoundError",(function(){return I.d}));var M=n(277);for(var i in M)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return M[e]}))}(i);var D=n(91);for(var i in D)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return D[e]}))}(i);var R=n(96);for(var i in R)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return R[e]}))}(i);var P=n(98);for(var i in P)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return P[e]}))}(i);var L=n(279);for(var i in L)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return L[e]}))}(i);var w=n(40);for(var i in w)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return w[e]}))}(i);var U=n(282);for(var i in U)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return U[e]}))}(i);var j=n(87);for(var i in j)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return j[e]}))}(i);var F=n(284);for(var i in F)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return F[e]}))}(i);var x=n(286);for(var i in x)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return x[e]}))}(i);var k=n(43);for(var i in k)["default","SunbirdSdk","ArchiveObjectType","ExportAssertionError","InvalidRequestError","ObjectNotFoundError"].indexOf(i)<0&&function(e){n.d(t,e,(function(){return k[e]}))}(i);var B=n(99);n.d(t,"ValidationError",(function(){return B.a}))},function(e,t,n){"use strict";(function(e){var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e&&e||{},n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function d(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function h(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function E(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function p(e){var t=new FileReader,n=E(t);return t.readAsArrayBuffer(e),n}function _(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function S(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=_(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=_(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=h(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=h(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i)return this.blob().then(p);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,i,o=h(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=E(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=r?r[1]:"utf-8",t.readAsText(e,i),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(v)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=u(e),t=d(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[u(e)]},f.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},f.prototype.set=function(e,t){this.map[u(e)]=d(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),l(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),l(e)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var b=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function O(e,n){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,o=(n=n||{}).body;if(e instanceof O){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,n.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=n.credentials||this.credentials||"same-origin",!n.headers&&this.headers||(this.headers=new f(n.headers)),this.method=(r=n.method||this.method||"GET",i=r.toUpperCase(),b.indexOf(i)>-1?i:r),this.mode=n.mode||this.mode||null,this.signal=n.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==n.cache&&"no-cache"!==n.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function v(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function C(e,t){if(!(this instanceof C))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}O.prototype.clone=function(){return new O(this,{body:this._bodyInit})},S.call(O.prototype),S.call(C.prototype),C.prototype.clone=function(){return new C(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},C.error=function(){var e=new C(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var g=[301,302,303,307,308];C.redirect=function(e,t){if(-1===g.indexOf(t))throw new RangeError("Invalid status code");return new C(null,{status:t,headers:{location:e}})};var A=t.DOMException;try{new A}catch(e){(A=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),A.prototype.constructor=A}function T(e,n){return new Promise((function(r,o){var a=new O(e,n);if(a.signal&&a.signal.aborted)return o(new A("Aborted","AbortError"));var c=new XMLHttpRequest;function l(){c.abort()}if(c.onload=function(){var e,t,n={statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();try{t.append(r,i)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(c.status<200||c.status>599)?n.status=200:n.status=c.status,n.url="responseURL"in c?c.responseURL:n.headers.get("X-Request-URL");var i="response"in c?c.response:c.responseText;setTimeout((function(){r(new C(i,n))}),0)},c.onerror=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){o(new TypeError("Network request timed out"))}),0)},c.onabort=function(){setTimeout((function(){o(new A("Aborted","AbortError"))}),0)},c.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?c.withCredentials=!0:"omit"===a.credentials&&(c.withCredentials=!1),"responseType"in c&&(i?c.responseType="blob":s&&(c.responseType="arraybuffer")),n&&"object"==typeof n.headers&&!(n.headers instanceof f||t.Headers&&n.headers instanceof t.Headers)){var h=[];Object.getOwnPropertyNames(n.headers).forEach((function(e){h.push(u(e)),c.setRequestHeader(e,d(n.headers[e]))})),a.headers.forEach((function(e,t){-1===h.indexOf(t)&&c.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){c.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",l),c.onreadystatechange=function(){4===c.readyState&&a.signal.removeEventListener("abort",l)}),c.send(void 0===a._bodyInit?null:a._bodyInit)}))}T.polyfill=!0,t.fetch||(t.fetch=T,t.Headers=f,t.Request=O,t.Response=C)}).call(this,n(109))},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(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,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Container=void 0;var s=n(307),a=n(41),c=n(54),u=n(35),d=n(118),l=n(308),f=n(315),h=n(317),E=n(65),p=n(76),_=n(320),S=n(321),b=function(){function e(e){this._appliedMiddleware=[];var t=e||{};if("object"!=typeof t)throw new Error(""+a.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);if(void 0===t.defaultScope)t.defaultScope=c.BindingScopeEnum.Transient;else if(t.defaultScope!==c.BindingScopeEnum.Singleton&&t.defaultScope!==c.BindingScopeEnum.Transient&&t.defaultScope!==c.BindingScopeEnum.Request)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=E.id(),this._bindingDictionary=new S.Lookup,this._snapshots=[],this._middleware=null,this.parent=null,this._metadataReader=new d.MetadataReader}return e.merge=function(t,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var s=new e,a=o([t,n],r).map((function(e){return l.getBindingDictionary(e)})),c=l.getBindingDictionary(s);function u(e,t){e.traverse((function(e,n){n.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return a.forEach((function(e){u(e,c)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=this._getContainerModuleHelpersFactory(),r=0,i=e;r<i.length;r++){var o=i[r],s=n(o.id);o.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,o,s;return i(this,(function(i){switch(i.label){case 0:t=this._getContainerModuleHelpersFactory(),n=0,r=e,i.label=1;case 1:return n<r.length?(o=r[n],s=t(o.id),[4,o.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=function(e){return function(t){return t.moduleId===e}};t.forEach((function(t){var n=r(t.id);e._bindingDictionary.removeByCondition(n)}))},e.prototype.bind=function(e){var t=this.options.defaultScope||c.BindingScopeEnum.Transient,n=new s.Binding(e,t);return this._bindingDictionary.add(e,n),new h.BindingToSyntax(n)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.unbind=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error(a.CANNOT_UNBIND+" "+p.getServiceIdentifierAsString(e))}},e.prototype.unbindAll=function(){this._bindingDictionary=new S.Lookup},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,u.NAMED_TAG,t)},e.prototype.isBoundTagged=function(e,t,n){var r=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),o=l.createMockRequest(this,e,t,n);r=i.some((function(e){return e.constraint(o)}))}return!r&&this.parent&&(r=this.parent.isBoundTagged(e,t,n)),r},e.prototype.snapshot=function(){this._snapshots.push(_.ContainerSnapshot.of(this._bindingDictionary.clone(),this._middleware))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error(a.NO_MORE_SNAPSHOTS_AVAILABLE);this._bindingDictionary=e.bindings,this._middleware=e.middleware},e.prototype.createChild=function(t){var n=new e(t||this.options);return n.parent=this,n},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._appliedMiddleware=this._appliedMiddleware.concat(e);var n=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),n)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){return this._get(!1,!1,c.TargetTypeEnum.Variable,e)},e.prototype.getTagged=function(e,t,n){return this._get(!1,!1,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getNamed=function(e,t){return this.getTagged(e,u.NAMED_TAG,t)},e.prototype.getAll=function(e){return this._get(!0,!0,c.TargetTypeEnum.Variable,e)},e.prototype.getAllTagged=function(e,t,n){return this._get(!1,!0,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,u.NAMED_TAG,t)},e.prototype.resolve=function(e){var t=this.createChild();return t.bind(e).toSelf(),this._appliedMiddleware.forEach((function(e){t.applyMiddleware(e)})),t.get(e)},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},n=function(n){return function(r){var i=e.rebind.bind(e)(r);return t(i,n),i}};return function(r){return{bindFunction:(i=r,function(n){var r=e.bind.bind(e)(n);return t(r,i),r}),isboundFunction:function(t){return e.isBound.bind(e)(t)},rebindFunction:n(r),unbindFunction:function(t){e.unbind.bind(e)(t)}};var i}},e.prototype._get=function(e,t,n,r,i,o){var s=null,c={avoidConstraints:e,contextInterceptor:function(e){return e},isMultiInject:t,key:i,serviceIdentifier:r,targetType:n,value:o};if(this._middleware){if(null==(s=this._middleware(c)))throw new Error(a.INVALID_MIDDLEWARE_RETURN)}else s=this._planAndResolve()(c);return s},e.prototype._planAndResolve=function(){var e=this;return function(t){var n=l.plan(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return n=t.contextInterceptor(n),f.resolve(n)}},e}();t.Container=b},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Binding=void 0;var r=n(54),i=n(65),o=function(){function e(e,t){this.id=i.id(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=r.BindingTypeEnum.Invalid,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===r.BindingScopeEnum.Singleton&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.cache=this.cache,t},e}();t.Binding=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBindingDictionary=t.createMockRequest=t.plan=void 0;var r=n(309),i=n(41),o=n(54),s=n(35),a=n(119),c=n(76),u=n(310),d=n(47),l=n(311),f=n(312),h=n(314),E=n(121);function p(e){return e._bindingDictionary}function _(e,t,n,o,s){var a=S(n.container,s.serviceIdentifier),u=[];return a.length===r.BindingCount.NoBindingsAvailable&&n.container.options.autoBindInjectable&&"function"==typeof s.serviceIdentifier&&e.getConstructorMetadata(s.serviceIdentifier).compilerGeneratedMetadata&&(n.container.bind(s.serviceIdentifier).toSelf(),a=S(n.container,s.serviceIdentifier)),u=t?a:a.filter((function(e){var t=new h.Request(e.serviceIdentifier,n,o,e,s);return e.constraint(t)})),function(e,t,n,o){switch(t.length){case r.BindingCount.NoBindingsAvailable:if(n.isOptional())return t;var s=c.getServiceIdentifierAsString(e),a=i.NOT_REGISTERED;throw a+=c.listMetadataForTarget(s,n),a+=c.listRegisteredBindingsForServiceIdentifier(o,s,S),new Error(a);case r.BindingCount.OnlyOneBindingAvailable:if(!n.isArray())return t;case r.BindingCount.MultipleBindingsAvailable:default:if(n.isArray())return t;s=c.getServiceIdentifierAsString(e),a=i.AMBIGUOUS_MATCH+" "+s;throw a+=c.listRegisteredBindingsForServiceIdentifier(o,s,S),new Error(a)}}(s.serviceIdentifier,u,s,n.container),u}function S(e,t){var n=[],r=p(e);return r.hasKey(t)?n=r.get(t):null!==e.parent&&(n=S(e.parent,t)),n}t.getBindingDictionary=p,t.plan=function(e,t,n,r,p,S,b,O){void 0===O&&(O=!1);var v=new u.Context(t),C=function(e,t,n,r,i,o){var a=e?s.MULTI_INJECT_TAG:s.INJECT_TAG,c=new d.Metadata(a,n),u=new E.Target(t,r,n,c);if(void 0!==i){var l=new d.Metadata(i,o);u.metadata.push(l)}return u}(n,r,p,"",S,b);try{return function e(t,n,r,s,a,c){var u,d;if(null===a){u=_(t,n,s,null,c),d=new h.Request(r,s,null,u,c);var E=new l.Plan(s,d);s.addPlan(E)}else u=_(t,n,s,a,c),d=a.addChildRequest(c.serviceIdentifier,u,c);u.forEach((function(n){var r=null;if(c.isArray())r=d.addChildRequest(n.serviceIdentifier,n,c);else{if(n.cache)return;r=d}if(n.type===o.BindingTypeEnum.Instance&&null!==n.implementationType){var a=f.getDependencies(t,n.implementationType);if(!s.container.options.skipBaseClassChecks){var u=f.getBaseClassDependencyCount(t,n.implementationType);if(a.length<u){var l=i.ARGUMENTS_LENGTH_MISMATCH(f.getFunctionName(n.implementationType));throw new Error(l)}}a.forEach((function(n){e(t,!1,n.serviceIdentifier,s,r,n)}))}}))}(e,O,p,v,null,C),v}catch(e){throw a.isStackOverflowExeption(e)&&v.plan&&c.circularDependencyToException(v.plan.rootRequest),e}},t.createMockRequest=function(e,t,n,r){var i=new E.Target(o.TargetTypeEnum.Variable,"",t,new d.Metadata(n,r)),s=new u.Context(e);return new h.Request(t,s,null,[],i)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingCount=void 0;t.BindingCount={MultipleBindingsAvailable:2,NoBindingsAvailable:0,OnlyOneBindingAvailable:1}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;var r=n(65),i=function(){function e(e){this.id=r.id(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}();t.Context=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Plan=void 0;var r=function(e,t){this.parentContext=e,this.rootRequest=t};t.Plan=r},function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionName=t.getBaseClassDependencyCount=t.getDependencies=void 0;var i=n(120),o=n(41),s=n(54),a=n(35),c=n(76);Object.defineProperty(t,"getFunctionName",{enumerable:!0,get:function(){return c.getFunctionName}});var u=n(121);function d(e,t,n,i){var a=e.getConstructorMetadata(n),c=a.compilerGeneratedMetadata;if(void 0===c){var d=o.MISSING_INJECTABLE_ANNOTATION+" "+t+".";throw new Error(d)}var h=a.userGeneratedMetadata,E=Object.keys(h),p=0===n.length&&E.length>0,_=E.length>n.length,S=function(e,t,n,r,i){for(var o=[],s=0;s<i;s++){var a=l(s,e,t,n,r);null!==a&&o.push(a)}return o}(i,t,c,h,p||_?E.length:n.length),b=function e(t,n){for(var i=t.getPropertiesMetadata(n),o=[],a=Object.keys(i),c=0,d=a;c<d.length;c++){var l=d[c],h=i[l],E=f(i[l]),p=E.targetName||l,_=E.inject||E.multiInject,S=new u.Target(s.TargetTypeEnum.ClassProperty,p,_);S.metadata=h,o.push(S)}var b=Object.getPrototypeOf(n.prototype).constructor;if(b!==Object){var O=e(t,b);o=r(r([],o),O)}return o}(e,n);return r(r([],S),b)}function l(e,t,n,r,a){var c=a[e.toString()]||[],d=f(c),l=!0!==d.unmanaged,h=r[e],E=d.inject||d.multiInject;if((h=E||h)instanceof i.LazyServiceIdentifer&&(h=h.unwrap()),l){if(!t&&(h===Object||h===Function||void 0===h)){var p=o.MISSING_INJECT_ANNOTATION+" argument "+e+" in class "+n+".";throw new Error(p)}var _=new u.Target(s.TargetTypeEnum.ConstructorArgument,d.targetName,h);return _.metadata=c,_}return null}function f(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t[a.INJECT_TAG],multiInject:t[a.MULTI_INJECT_TAG],targetName:t[a.NAME_TAG],unmanaged:t[a.UNMANAGED_TAG]}}t.getDependencies=function(e,t){return d(e,c.getFunctionName(t),t,!1)},t.getBaseClassDependencyCount=function e(t,n){var r=Object.getPrototypeOf(n.prototype).constructor;if(r!==Object){var i=d(t,c.getFunctionName(r),r,!0),o=i.map((function(e){return e.metadata.filter((function(e){return e.key===a.UNMANAGED_TAG}))})),s=[].concat.apply([],o).length,u=i.length-s;return u>0?u:e(t,r)}return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QueryableString=void 0;var r=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,n=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},n)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}();t.QueryableString=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Request=void 0;var r=n(65),i=function(){function e(e,t,n,i,o){this.id=r.id(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=n,this.target=o,this.childRequests=[],this.bindings=Array.isArray(i)?i:[i],this.requestScope=null===n?new Map:null}return e.prototype.addChildRequest=function(t,n,r){var i=new e(t,this.parentContext,this,n,r);return this.childRequests.push(i),i},e}();t.Request=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolve=void 0;var r=n(41),i=n(54),o=n(119),s=n(76),a=n(316),c=function(e,t,n){try{return n()}catch(n){throw o.isStackOverflowExeption(n)?new Error(r.CIRCULAR_DEPENDENCY_IN_FACTORY(e,t.toString())):n}},u=function(e){return function(t){t.parentContext.setCurrentRequest(t);var n=t.bindings,o=t.childRequests,d=t.target&&t.target.isArray(),l=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(d&&l)return o.map((function(t){return u(e)(t)}));var f=null;if(!t.target.isOptional()||0!==n.length){var h=n[0],E=h.scope===i.BindingScopeEnum.Singleton,p=h.scope===i.BindingScopeEnum.Request;if(E&&h.activated)return h.cache;if(p&&null!==e&&e.has(h.id))return e.get(h.id);if(h.type===i.BindingTypeEnum.ConstantValue)f=h.cache,h.activated=!0;else if(h.type===i.BindingTypeEnum.Function)f=h.cache,h.activated=!0;else if(h.type===i.BindingTypeEnum.Constructor)f=h.implementationType;else if(h.type===i.BindingTypeEnum.DynamicValue&&null!==h.dynamicValue)f=c("toDynamicValue",h.serviceIdentifier,(function(){return h.dynamicValue(t.parentContext)}));else if(h.type===i.BindingTypeEnum.Factory&&null!==h.factory)f=c("toFactory",h.serviceIdentifier,(function(){return h.factory(t.parentContext)}));else if(h.type===i.BindingTypeEnum.Provider&&null!==h.provider)f=c("toProvider",h.serviceIdentifier,(function(){return h.provider(t.parentContext)}));else{if(h.type!==i.BindingTypeEnum.Instance||null===h.implementationType){var _=s.getServiceIdentifierAsString(t.serviceIdentifier);throw new Error(r.INVALID_BINDING_TYPE+" "+_)}f=a.resolveInstance(h.implementationType,o,u(e))}return"function"==typeof h.onActivation&&(f=h.onActivation(t.parentContext,f)),E&&(h.cache=f,h.activated=!0),p&&null!==e&&!e.has(h.id)&&e.set(h.id,f),f}}};t.resolve=function(e){return u(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}},function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveInstance=void 0;var i=n(41),o=n(54),s=n(35);t.resolveInstance=function(e,t,n){var a,c,u=null;if(t.length>0){var d=t.filter((function(e){return null!==e.target&&e.target.type===o.TargetTypeEnum.ConstructorArgument})).map(n);c=d,u=function(e,t,n){var r=t.filter((function(e){return null!==e.target&&e.target.type===o.TargetTypeEnum.ClassProperty})),i=r.map(n);return r.forEach((function(t,n){var r;r=t.target.name.value();var o=i[n];e[r]=o})),e}(u=new((a=e).bind.apply(a,r([void 0],c))),t,n)}else u=new e;return function(e,t){if(Reflect.hasMetadata(s.POST_CONSTRUCT,e)){var n=Reflect.getMetadata(s.POST_CONSTRUCT,e);try{t[n.value]()}catch(t){throw new Error(i.POST_CONSTRUCT_ERROR(e.name,t.message))}}}(e,u),u}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingToSyntax=void 0;var r=n(41),i=n(54),o=n(318),s=n(122),a=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=i.BindingTypeEnum.Instance,this._binding.implementationType=e,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error(""+r.INVALID_TO_SELF_VALUE);var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=i.BindingTypeEnum.ConstantValue,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=i.BindingTypeEnum.DynamicValue,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=i.BindingTypeEnum.Constructor,this._binding.implementationType=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error(r.INVALID_FUNCTION_BINDING);var t=this.toConstantValue(e);return this._binding.type=i.BindingTypeEnum.Function,this._binding.scope=i.BindingScopeEnum.Singleton,t},e.prototype.toAutoFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=i.BindingTypeEnum.Provider,this._binding.provider=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}();t.BindingToSyntax=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingInWhenOnSyntax=void 0;var r=n(319),i=n(102),o=n(103),s=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new o.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new i.BindingOnSyntax(this._binding),this._bindingInSyntax=new r.BindingInSyntax(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingInWhenOnSyntax=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingInSyntax=void 0;var r=n(54),i=n(122),o=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=r.BindingScopeEnum.Request,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=r.BindingScopeEnum.Singleton,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=r.BindingScopeEnum.Transient,new i.BindingWhenOnSyntax(this._binding)},e}();t.BindingInSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContainerSnapshot=void 0;var r=function(){function e(){}return e.of=function(t,n){var r=new e;return r.bindings=t,r.middleware=n,r},e}();t.ContainerSnapshot=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lookup=void 0;var r=n(41),i=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error(r.NULL_ARGUMENT);if(null==t)throw new Error(r.NULL_ARGUMENT);var n=this._map.get(e);void 0!==n?(n.push(t),this._map.set(e,n)):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);var t=this._map.get(e);if(void 0!==t)return t;throw new Error(r.KEY_NOT_FOUND)},e.prototype.remove=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);if(!this._map.delete(e))throw new Error(r.KEY_NOT_FOUND)},e.prototype.removeByCondition=function(e){var t=this;this._map.forEach((function(n,r){var i=n.filter((function(t){return!e(t)}));i.length>0?t._map.set(r,i):t._map.delete(r)}))},e.prototype.hasKey=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,n){e.forEach((function(e){return t.add(n,e.clone())}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,n){e(n,t)}))},e}();t.Lookup=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContainerModule=t.ContainerModule=void 0;var r=n(65),i=function(e){this.id=r.id(),this.registry=e};t.ContainerModule=i;var o=function(e){this.id=r.id(),this.registry=e};t.AsyncContainerModule=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.injectable=void 0;var r=n(41),i=n(35);t.injectable=function(){return function(e){if(Reflect.hasOwnMetadata(i.PARAM_TYPES,e))throw new Error(r.DUPLICATED_INJECTABLE_DECORATOR);var t=Reflect.getMetadata(i.DESIGN_PARAM_TYPES,e)||[];return Reflect.defineMetadata(i.PARAM_TYPES,t,e),e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagged=void 0;var r=n(47),i=n(56);t.tagged=function(e,t){return function(n,o,s){var a=new r.Metadata(e,t);"number"==typeof s?i.tagParameter(n,o,s,a):i.tagProperty(n,o,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.named=void 0;var r=n(35),i=n(47),o=n(56);t.named=function(e){return function(t,n,s){var a=new i.Metadata(r.NAMED_TAG,e);"number"==typeof s?o.tagParameter(t,n,s,a):o.tagProperty(t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optional=void 0;var r=n(35),i=n(47),o=n(56);t.optional=function(){return function(e,t,n){var s=new i.Metadata(r.OPTIONAL_TAG,!0);"number"==typeof n?o.tagParameter(e,t,n,s):o.tagProperty(e,t,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unmanaged=void 0;var r=n(35),i=n(47),o=n(56);t.unmanaged=function(){return function(e,t,n){var s=new i.Metadata(r.UNMANAGED_TAG,!0);o.tagParameter(e,t,n,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiInject=void 0;var r=n(35),i=n(47),o=n(56);t.multiInject=function(e){return function(t,n,s){var a=new i.Metadata(r.MULTI_INJECT_TAG,e);"number"==typeof s?o.tagParameter(t,n,s,a):o.tagProperty(t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.targetName=void 0;var r=n(35),i=n(47),o=n(56);t.targetName=function(e){return function(t,n,s){var a=new i.Metadata(r.NAME_TAG,e);o.tagParameter(t,n,s,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postConstruct=void 0;var r=n(41),i=n(35),o=n(47);t.postConstruct=function(){return function(e,t,n){var s=new o.Metadata(i.POST_CONSTRUCT,t);if(Reflect.hasOwnMetadata(i.POST_CONSTRUCT,e.constructor))throw new Error(r.MULTIPLE_POST_CONSTRUCT_METHODS);Reflect.defineMetadata(i.POST_CONSTRUCT,s,e.constructor)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=void 0;t.multiBindToService=function(e){return function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.forEach((function(n){return e.bind(n).toService(t)}))}}}},function(e,t,n){"use strict";var r=n(333),i=n(147),o=n(106),s=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},c=Array.isArray,u=Array.prototype.push,d=function(e,t){u.apply(e,c(t)?t:[t])},l=Date.prototype.toISOString,f=o.default,h={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:i.encode,encodeValuesOnly:!1,format:f,formatter:o.formatters[f],indices:!1,serializeDate:function(e){return l.call(e)},skipNulls:!1,strictNullHandling:!1},E={},p=function e(t,n,o,s,a,u,l,f,p,_,S,b,O,v,C,g,A,T){for(var N,y=t,m=T,I=0,M=!1;void 0!==(m=m.get(E))&&!M;){var D=m.get(t);if(I+=1,void 0!==D){if(D===I)throw new RangeError("Cyclic object value");M=!0}void 0===m.get(E)&&(I=0)}if("function"==typeof _?y=_(n,y):y instanceof Date?y=O(y):"comma"===o&&c(y)&&(y=i.maybeMap(y,(function(e){return e instanceof Date?O(e):e}))),null===y){if(u)return p&&!g?p(n,h.encoder,A,"key",v):n;y=""}if("string"==typeof(N=y)||"number"==typeof N||"boolean"==typeof N||"symbol"==typeof N||"bigint"==typeof N||i.isBuffer(y))return p?[C(g?n:p(n,h.encoder,A,"key",v))+"="+C(p(y,h.encoder,A,"value",v))]:[C(n)+"="+C(String(y))];var R,P=[];if(void 0===y)return P;if("comma"===o&&c(y))g&&p&&(y=i.maybeMap(y,p)),R=[{value:y.length>0?y.join(",")||null:void 0}];else if(c(_))R=_;else{var L=Object.keys(y);R=S?L.sort(S):L}var w=f?n.replace(/\./g,"%2E"):n,U=s&&c(y)&&1===y.length?w+"[]":w;if(a&&c(y)&&0===y.length)return U+"[]";for(var j=0;j<R.length;++j){var F=R[j],x="object"==typeof F&&void 0!==F.value?F.value:y[F];if(!l||null!==x){var k=b&&f?F.replace(/\./g,"%2E"):F,B=c(y)?"function"==typeof o?o(U,k):U:U+(b?"."+k:"["+k+"]");T.set(t,I);var V=r();V.set(E,T),d(P,e(x,B,o,s,a,u,l,f,"comma"===o&&g&&c(y)?null:p,_,S,b,O,v,C,g,A,V))}}return P};e.exports=function(e,t){var n,i=e,u=function(e){if(!e)return h;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||h.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=o.default;if(void 0!==e.format){if(!s.call(o.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r,i=o.formatters[n],u=h.filter;if(("function"==typeof e.filter||c(e.filter))&&(u=e.filter),r=e.arrayFormat in a?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":h.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var d=void 0===e.allowDots?!0===e.encodeDotInKeys||h.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:h.addQueryPrefix,allowDots:d,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:h.allowEmptyArrays,arrayFormat:r,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:h.charsetSentinel,commaRoundTrip:e.commaRoundTrip,delimiter:void 0===e.delimiter?h.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:h.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:h.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:h.encodeValuesOnly,filter:u,format:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:h.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:h.strictNullHandling}}(t);"function"==typeof u.filter?i=(0,u.filter)("",i):c(u.filter)&&(n=u.filter);var l=[];if("object"!=typeof i||null===i)return"";var f=a[u.arrayFormat],E="comma"===f&&u.commaRoundTrip;n||(n=Object.keys(i)),u.sort&&n.sort(u.sort);for(var _=r(),S=0;S<n.length;++S){var b=n[S];u.skipNulls&&null===i[b]||d(l,p(i[b],b,f,E,u.allowEmptyArrays,u.strictNullHandling,u.skipNulls,u.encodeDotInKeys,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,_))}var O=l.join(u.delimiter),v=!0===u.addQueryPrefix?"?":"";return u.charsetSentinel&&("iso-8859-1"===u.charset?v+="utf8=%26%2310003%3B&":v+="utf8=%E2%9C%93&"),O.length>0?v+O:""}},function(e,t,n){"use strict";var r=n(68),i=n(344),o=n(349),s=n(77),a=r("%WeakMap%",!0),c=r("%Map%",!0),u=i("WeakMap.prototype.get",!0),d=i("WeakMap.prototype.set",!0),l=i("WeakMap.prototype.has",!0),f=i("Map.prototype.get",!0),h=i("Map.prototype.set",!0),E=i("Map.prototype.has",!0),p=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n};e.exports=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new s("Side channel does not contain "+o(e))},get:function(r){if(a&&r&&("object"==typeof r||"function"==typeof r)){if(e)return u(e,r)}else if(c){if(t)return f(t,r)}else if(n)return function(e,t){var n=p(e,t);return n&&n.value}(n,r)},has:function(r){if(a&&r&&("object"==typeof r||"function"==typeof r)){if(e)return l(e,r)}else if(c){if(t)return E(t,r)}else if(n)return function(e,t){return!!p(e,t)}(n,r);return!1},set:function(r,i){a&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new a),d(e,r,i)):c?(t||(t=new c),h(t,r,i)):(n||(n={key:{},next:null}),function(e,t,n){var r=p(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,i))}};return r}},function(e,t,n){"use strict";e.exports=Error},function(e,t,n){"use strict";e.exports=EvalError},function(e,t,n){"use strict";e.exports=RangeError},function(e,t,n){"use strict";e.exports=ReferenceError},function(e,t,n){"use strict";e.exports=URIError},function(e,t,n){"use strict";var r="undefined"!=typeof Symbol&&Symbol,i=n(340);e.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&i())))}},function(e,t,n){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(e,t,n){"use strict";var r={__proto__:null,foo:{}},i=Object;e.exports=function(){return{__proto__:r}.foo===r.foo&&!(r instanceof i)}},function(e,t,n){"use strict";var r="Function.prototype.bind called on incompatible ",i=Object.prototype.toString,o=Math.max,s=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},a=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},c=function(e,t){for(var n="",r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};e.exports=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==i.apply(t))throw new TypeError(r+t);for(var n,u=a(arguments,1),d=function(){if(this instanceof n){var r=t.apply(this,s(u,arguments));return Object(r)===r?r:this}return t.apply(e,s(u,arguments))},l=o(0,t.length-u.length),f=[],h=0;h<l;h++)f[h]="$"+h;if(n=Function("binder","return function ("+c(f,",")+"){ return binder.apply(this,arguments); }")(d),t.prototype){var E=function(){};E.prototype=t.prototype,n.prototype=new E,E.prototype=null}return n}},function(e,t,n){"use strict";var r=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=n(104);e.exports=o.call(r,i)},function(e,t,n){"use strict";var r=n(68),i=n(345),o=i(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&o(e,".prototype.")>-1?i(n):n}},function(e,t,n){"use strict";var r=n(104),i=n(68),o=n(346),s=n(77),a=i("%Function.prototype.apply%"),c=i("%Function.prototype.call%"),u=i("%Reflect.apply%",!0)||r.call(c,a),d=n(105),l=i("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new s("a function is required");var t=u(r,c,arguments);return o(t,1+l(0,e.length-(arguments.length-1)),!0)};var f=function(){return u(r,a,arguments)};d?d(e.exports,"apply",{value:f}):e.exports.apply=f},function(e,t,n){"use strict";var r=n(68),i=n(347),o=n(348)(),s=n(146),a=n(77),c=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new a("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||c(t)!==t)throw new a("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,u=!0;if("length"in e&&s){var d=s(e,"length");d&&!d.configurable&&(r=!1),d&&!d.writable&&(u=!1)}return(r||u||!n)&&(o?i(e,"length",t,!0,!0):i(e,"length",t)),e}},function(e,t,n){"use strict";var r=n(105),i=n(145),o=n(77),s=n(146);e.exports=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new o("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,d=arguments.length>6&&arguments[6],l=!!s&&s(e,t);if(r)r(e,t,{configurable:null===u&&l?l.configurable:!u,enumerable:null===a&&l?l.enumerable:!a,value:n,writable:null===c&&l?l.writable:!c});else{if(!d&&(a||c||u))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}}},function(e,t,n){"use strict";var r=n(105),i=function(){return!!r};i.hasArrayLengthDefineBug=function(){if(!r)return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=i},function(e,t,n){(function(t){var r="function"==typeof Map&&Map.prototype,i=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,o=r&&i&&"function"==typeof i.get?i.get:null,s=r&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,c=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,u=a&&c&&"function"==typeof c.get?c.get:null,d=a&&Set.prototype.forEach,l="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,f="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,h="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,E=Boolean.prototype.valueOf,p=Object.prototype.toString,_=Function.prototype.toString,S=String.prototype.match,b=String.prototype.slice,O=String.prototype.replace,v=String.prototype.toUpperCase,C=String.prototype.toLowerCase,g=RegExp.prototype.test,A=Array.prototype.concat,T=Array.prototype.join,N=Array.prototype.slice,y=Math.floor,m="function"==typeof BigInt?BigInt.prototype.valueOf:null,I=Object.getOwnPropertySymbols,M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,D="function"==typeof Symbol&&"object"==typeof Symbol.iterator,R="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===D||"symbol")?Symbol.toStringTag:null,P=Object.prototype.propertyIsEnumerable,L=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function w(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||g.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-y(-e):y(e);if(r!==e){var i=String(r),o=b.call(t,i.length+1);return O.call(i,n,"$&_")+"."+O.call(O.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return O.call(t,n,"$&_")}var U=n(350),j=U.custom,F=Y(j)?j:null;function x(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function k(e){return O.call(String(e),/"/g,"&quot;")}function B(e){return!("[object Array]"!==q(e)||R&&"object"==typeof e&&R in e)}function V(e){return!("[object RegExp]"!==q(e)||R&&"object"==typeof e&&R in e)}function Y(e){if(D)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!M)return!1;try{return M.call(e),!0}catch(e){}return!1}e.exports=function e(n,r,i,a){var c=r||{};if(H(c,"quoteStyle")&&"single"!==c.quoteStyle&&"double"!==c.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(H(c,"maxStringLength")&&("number"==typeof c.maxStringLength?c.maxStringLength<0&&c.maxStringLength!==1/0:null!==c.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var p=!H(c,"customInspect")||c.customInspect;if("boolean"!=typeof p&&"symbol"!==p)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(H(c,"indent")&&null!==c.indent&&"\t"!==c.indent&&!(parseInt(c.indent,10)===c.indent&&c.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(H(c,"numericSeparator")&&"boolean"!=typeof c.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var v=c.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return function e(t,n){if(t.length>n.maxStringLength){var r=t.length-n.maxStringLength,i="... "+r+" more character"+(r>1?"s":"");return e(b.call(t,0,n.maxStringLength),n)+i}return x(O.call(O.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,K),"single",n)}(n,c);if("number"==typeof n){if(0===n)return 1/0/n>0?"0":"-0";var g=String(n);return v?w(n,g):g}if("bigint"==typeof n){var y=String(n)+"n";return v?w(n,y):y}var I=void 0===c.depth?5:c.depth;if(void 0===i&&(i=0),i>=I&&I>0&&"object"==typeof n)return B(n)?"[Array]":"[Object]";var j=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=T.call(Array(e.indent+1)," ")}return{base:n,prev:T.call(Array(t+1),n)}}(c,i);if(void 0===a)a=[];else if($(a,n)>=0)return"[Circular]";function G(t,n,r){if(n&&(a=N.call(a)).push(n),r){var o={depth:c.depth};return H(c,"quoteStyle")&&(o.quoteStyle=c.quoteStyle),e(t,o,i+1,a)}return e(t,c,i+1,a)}if("function"==typeof n&&!V(n)){var Z=function(e){if(e.name)return e.name;var t=S.call(_.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(n),ee=Q(n,G);return"[Function"+(Z?": "+Z:" (anonymous)")+"]"+(ee.length>0?" { "+T.call(ee,", ")+" }":"")}if(Y(n)){var te=D?O.call(String(n),/^(Symbol\(.*\))_[^)]*$/,"$1"):M.call(n);return"object"!=typeof n||D?te:z(te)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(n)){for(var ne="<"+C.call(String(n.nodeName)),re=n.attributes||[],ie=0;ie<re.length;ie++)ne+=" "+re[ie].name+"="+x(k(re[ie].value),"double",c);return ne+=">",n.childNodes&&n.childNodes.length&&(ne+="..."),ne+="</"+C.call(String(n.nodeName))+">"}if(B(n)){if(0===n.length)return"[]";var oe=Q(n,G);return j&&!function(e){for(var t=0;t<e.length;t++)if($(e[t],"\n")>=0)return!1;return!0}(oe)?"["+J(oe,j)+"]":"[ "+T.call(oe,", ")+" ]"}if(function(e){return!("[object Error]"!==q(e)||R&&"object"==typeof e&&R in e)}(n)){var se=Q(n,G);return"cause"in Error.prototype||!("cause"in n)||P.call(n,"cause")?0===se.length?"["+String(n)+"]":"{ ["+String(n)+"] "+T.call(se,", ")+" }":"{ ["+String(n)+"] "+T.call(A.call("[cause]: "+G(n.cause),se),", ")+" }"}if("object"==typeof n&&p){if(F&&"function"==typeof n[F]&&U)return U(n,{depth:I-i});if("symbol"!==p&&"function"==typeof n.inspect)return n.inspect()}if(function(e){if(!o||!e||"object"!=typeof e)return!1;try{o.call(e);try{u.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(n)){var ae=[];return s&&s.call(n,(function(e,t){ae.push(G(t,n,!0)+" => "+G(e,n))})),X("Map",o.call(n),ae,j)}if(function(e){if(!u||!e||"object"!=typeof e)return!1;try{u.call(e);try{o.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(n)){var ce=[];return d&&d.call(n,(function(e){ce.push(G(e,n))})),X("Set",u.call(n),ce,j)}if(function(e){if(!l||!e||"object"!=typeof e)return!1;try{l.call(e,l);try{f.call(e,f)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(n))return W("WeakMap");if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{f.call(e,f);try{l.call(e,l)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(n))return W("WeakSet");if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{return h.call(e),!0}catch(e){}return!1}(n))return W("WeakRef");if(function(e){return!("[object Number]"!==q(e)||R&&"object"==typeof e&&R in e)}(n))return z(G(Number(n)));if(function(e){if(!e||"object"!=typeof e||!m)return!1;try{return m.call(e),!0}catch(e){}return!1}(n))return z(G(m.call(n)));if(function(e){return!("[object Boolean]"!==q(e)||R&&"object"==typeof e&&R in e)}(n))return z(E.call(n));if(function(e){return!("[object String]"!==q(e)||R&&"object"==typeof e&&R in e)}(n))return z(G(String(n)));if("undefined"!=typeof window&&n===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&n===globalThis||void 0!==t&&n===t)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==q(e)||R&&"object"==typeof e&&R in e)}(n)&&!V(n)){var ue=Q(n,G),de=L?L(n)===Object.prototype:n instanceof Object||n.constructor===Object,le=n instanceof Object?"":"null prototype",fe=!de&&R&&Object(n)===n&&R in n?b.call(q(n),8,-1):le?"Object":"",he=(de||"function"!=typeof n.constructor?"":n.constructor.name?n.constructor.name+" ":"")+(fe||le?"["+T.call(A.call([],fe||[],le||[]),": ")+"] ":"");return 0===ue.length?he+"{}":j?he+"{"+J(ue,j)+"}":he+"{ "+T.call(ue,", ")+" }"}return String(n)};var G=Object.prototype.hasOwnProperty||function(e){return e in this};function H(e,t){return G.call(e,t)}function q(e){return p.call(e)}function $(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function K(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+v.call(t.toString(16))}function z(e){return"Object("+e+")"}function W(e){return e+" { ? }"}function X(e,t,n,r){return e+" ("+t+") {"+(r?J(n,r):T.call(n,", "))+"}"}function J(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+T.call(e,","+n)+"\n"+t.prev}function Q(e,t){var n=B(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=H(e,i)?t(e[i],e):""}var o,s="function"==typeof I?I(e):[];if(D){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in e)H(e,c)&&(n&&String(Number(c))===c&&c<e.length||D&&o["$"+c]instanceof Symbol||(g.call(/[^\w$]/,c)?r.push(t(c,e)+": "+t(e[c],e)):r.push(c+": "+t(e[c],e))));if("function"==typeof I)for(var u=0;u<s.length;u++)P.call(e,s[u])&&r.push("["+t(s[u])+"]: "+t(e[s[u]],e));return r}}).call(this,n(109))},function(e,t){},function(e,t,n){"use strict";var r=n(147),i=Object.prototype.hasOwnProperty,o=Array.isArray,s={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:r.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},a=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},c=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},u=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),u=a?o.slice(0,a.index):o,d=[];if(u){if(!n.plainObjects&&i.call(Object.prototype,u)&&!n.allowPrototypes)return;d.push(u)}for(var l=0;n.depth>0&&null!==(a=s.exec(o))&&l<n.depth;){if(l+=1,!n.plainObjects&&i.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;d.push(a[1])}if(a){if(!0===n.strictDepth)throw new RangeError("Input depth exceeded depth option of "+n.depth+" and strictDepth is true");d.push("["+o.slice(a.index)+"]")}return function(e,t,n,r){for(var i=r?t:c(t,n),o=e.length-1;o>=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=n.allowEmptyArrays&&(""===i||n.strictNullHandling&&null===i)?[]:[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,d=n.decodeDotInKeys?u.replace(/%2E/g,"."):u,l=parseInt(d,10);n.parseArrays||""!==d?!isNaN(l)&&a!==d&&String(l)===d&&l>=0&&n.parseArrays&&l<=n.arrayLimit?(s=[])[l]=i:"__proto__"!==d&&(s[d]=i):s={0:i}}i=s}return i}(d,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return s;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?s.charset:e.charset,n=void 0===e.duplicates?s.duplicates:e.duplicates;if("combine"!==n&&"first"!==n&&"last"!==n)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||s.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:s.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:s.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:s.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:s.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:s.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:s.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:s.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:s.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:s.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:s.depth,duplicates:n,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:s.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:s.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:s.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:s.strictDepth,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var d="string"==typeof e?function(e,t){var n={__proto__:null},u=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;u=u.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var d,l=t.parameterLimit===1/0?void 0:t.parameterLimit,f=u.split(t.delimiter,l),h=-1,E=t.charset;if(t.charsetSentinel)for(d=0;d<f.length;++d)0===f[d].indexOf("utf8=")&&("utf8=%E2%9C%93"===f[d]?E="utf-8":"utf8=%26%2310003%3B"===f[d]&&(E="iso-8859-1"),h=d,d=f.length);for(d=0;d<f.length;++d)if(d!==h){var p,_,S=f[d],b=S.indexOf("]="),O=-1===b?S.indexOf("="):b+1;-1===O?(p=t.decoder(S,s.decoder,E,"key"),_=t.strictNullHandling?null:""):(p=t.decoder(S.slice(0,O),s.decoder,E,"key"),_=r.maybeMap(c(S.slice(O+1),t),(function(e){return t.decoder(e,s.decoder,E,"value")}))),_&&t.interpretNumericEntities&&"iso-8859-1"===E&&(_=a(_)),S.indexOf("[]=")>-1&&(_=o(_)?[_]:_);var v=i.call(n,p);v&&"combine"===t.duplicates?n[p]=r.combine(n[p],_):v&&"last"!==t.duplicates||(n[p]=_)}return n}(e,n):e,l=n.plainObjects?Object.create(null):{},f=Object.keys(d),h=0;h<f.length;++h){var E=f[h],p=u(E,d[E],n,"string"==typeof e);l=r.merge(l,p,n)}return!0===n.allowSparse?l:r.compact(l)}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(51),i=function(){function e(e){this.table={},this.nElements=0,this.toStr=e||r.defaultToString}return e.prototype.getValue=function(e){var t=this.table["$"+this.toStr(e)];if(!r.isUndefined(t))return t.value},e.prototype.setValue=function(e,t){if(!r.isUndefined(e)&&!r.isUndefined(t)){var n,i="$"+this.toStr(e),o=this.table[i];return r.isUndefined(o)?(this.nElements++,n=void 0):n=o.value,this.table[i]={key:e,value:t},n}},e.prototype.remove=function(e){var t="$"+this.toStr(e),n=this.table[t];if(!r.isUndefined(n))return delete this.table[t],this.nElements--,n.value},e.prototype.keys=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.key)}return e},e.prototype.values=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.value)}return e},e.prototype.forEach=function(e){for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];if(!1===e(n.key,n.value))return}},e.prototype.containsKey=function(e){return!r.isUndefined(this.getValue(e))},e.prototype.clear=function(){this.table={},this.nElements=0},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){var e="{";return this.forEach((function(t,n){e+="\n\t"+t+" : "+n})),e+"\n}"},e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(51),i=n(215),o=function(){function e(){this.firstNode=null,this.lastNode=null,this.nElements=0}return e.prototype.add=function(e,t){if(r.isUndefined(t)&&(t=this.nElements),t<0||t>this.nElements||r.isUndefined(e))return!1;var n=this.createNode(e);if(0===this.nElements||null===this.lastNode)this.firstNode=n,this.lastNode=n;else if(t===this.nElements)this.lastNode.next=n,this.lastNode=n;else if(0===t)n.next=this.firstNode,this.firstNode=n;else{var i=this.nodeAtIndex(t-1);if(null===i)return!1;n.next=i.next,i.next=n}return this.nElements++,!0},e.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},e.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},e.prototype.elementAtIndex=function(e){var t=this.nodeAtIndex(e);if(null!==t)return t.element},e.prototype.indexOf=function(e,t){var n=t||r.defaultEquals;if(r.isUndefined(e))return-1;for(var i=this.firstNode,o=0;null!==i;){if(n(i.element,e))return o;o++,i=i.next}return-1},e.prototype.contains=function(e,t){return this.indexOf(e,t)>=0},e.prototype.remove=function(e,t){var n=t||r.defaultEquals;if(this.nElements<1||r.isUndefined(e))return!1;for(var i=null,o=this.firstNode;null!==o;){if(n(o.element,e))return null===i?(this.firstNode=o.next,o===this.lastNode&&(this.lastNode=null)):o===this.lastNode?(this.lastNode=i,i.next=o.next,o.next=null):(i.next=o.next,o.next=null),this.nElements--,!0;i=o,o=o.next}return!1},e.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},e.prototype.equals=function(t,n){var i=n||r.defaultEquals;return t instanceof e&&(this.size()===t.size()&&this.equalsAux(this.firstNode,t.firstNode,i))},e.prototype.equalsAux=function(e,t,n){for(;null!==e&&null!==t;){if(!n(e.element,t.element))return!1;e=e.next,t=t.next}return!0},e.prototype.removeElementAtIndex=function(e){if(!(e<0||e>=this.nElements||null===this.firstNode||null===this.lastNode)){var t;if(1===this.nElements)t=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var n=this.nodeAtIndex(e-1);null===n?(t=this.firstNode.element,this.firstNode=this.firstNode.next):n.next===this.lastNode&&(t=this.lastNode.element,this.lastNode=n),null!==n&&null!==n.next&&(t=n.next.element,n.next=n.next.next)}return this.nElements--,t}},e.prototype.forEach=function(e){for(var t=this.firstNode;null!==t&&!1!==e(t.element);)t=t.next},e.prototype.reverse=function(){for(var e=null,t=this.firstNode,n=null;null!==t;)n=t.next,t.next=e,e=t,t=n;n=this.firstNode,this.firstNode=this.lastNode,this.lastNode=n},e.prototype.toArray=function(){for(var e=[],t=this.firstNode;null!==t;)e.push(t.element),t=t.next;return e},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){return i.toString(this.toArray())},e.prototype.nodeAtIndex=function(e){if(e<0||e>=this.nElements)return null;if(e===this.nElements-1)return this.lastNode;for(var t=this.firstNode,n=0;n<e&&null!==t;n++)t=t.next;return t},e.prototype.createNode=function(e){return{element:e,next:null}},e}();t.default=o},function(e,t){function n(e,t){if(!e)throw new Error(t||"AssertionError")}n.notEqual=function(e,t,r){n(e!=t,r)},n.notOk=function(e,t){n(!e,t)},n.equal=function(e,t,r){n(e==t,r)},n.ok=n,e.exports=n}])}));