@launchdarkly/js-sdk-common 2.9.0 → 2.10.0

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 (210) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/api/platform/Requests.d.ts +5 -0
  3. package/dist/api/platform/Requests.d.ts.map +1 -1
  4. package/dist/datasource/DataSourceErrorKinds.d.ts +7 -0
  5. package/dist/datasource/DataSourceErrorKinds.d.ts.map +1 -0
  6. package/dist/datasource/errors.d.ts +17 -0
  7. package/dist/datasource/errors.d.ts.map +1 -0
  8. package/dist/datasource/index.d.ts +4 -0
  9. package/dist/datasource/index.d.ts.map +1 -0
  10. package/dist/errors.d.ts +0 -11
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/index.cjs +2477 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.mjs +2430 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/dist/internal/events/EventSender.d.ts.map +1 -1
  19. package/dist/internal/index.d.ts +1 -1
  20. package/dist/internal/index.d.ts.map +1 -1
  21. package/dist/internal/stream/StreamingProcessor.d.ts.map +1 -1
  22. package/dist/internal/stream/types.d.ts +1 -1
  23. package/dist/internal/stream/types.d.ts.map +1 -1
  24. package/package.json +18 -7
  25. package/dist/AttributeReference.js +0 -126
  26. package/dist/AttributeReference.js.map +0 -1
  27. package/dist/Context.js +0 -382
  28. package/dist/Context.js.map +0 -1
  29. package/dist/ContextFilter.js +0 -124
  30. package/dist/ContextFilter.js.map +0 -1
  31. package/dist/api/context/LDContext.js +0 -3
  32. package/dist/api/context/LDContext.js.map +0 -1
  33. package/dist/api/context/LDContextCommon.js +0 -3
  34. package/dist/api/context/LDContextCommon.js.map +0 -1
  35. package/dist/api/context/LDContextMeta.js +0 -3
  36. package/dist/api/context/LDContextMeta.js.map +0 -1
  37. package/dist/api/context/LDMultiKindContext.js +0 -3
  38. package/dist/api/context/LDMultiKindContext.js.map +0 -1
  39. package/dist/api/context/LDSingleKindContext.js +0 -3
  40. package/dist/api/context/LDSingleKindContext.js.map +0 -1
  41. package/dist/api/context/LDUser.js +0 -3
  42. package/dist/api/context/LDUser.js.map +0 -1
  43. package/dist/api/context/index.js +0 -23
  44. package/dist/api/context/index.js.map +0 -1
  45. package/dist/api/data/LDEvaluationDetail.js +0 -3
  46. package/dist/api/data/LDEvaluationDetail.js.map +0 -1
  47. package/dist/api/data/LDEvaluationReason.js +0 -3
  48. package/dist/api/data/LDEvaluationReason.js.map +0 -1
  49. package/dist/api/data/LDFlagSet.js +0 -3
  50. package/dist/api/data/LDFlagSet.js.map +0 -1
  51. package/dist/api/data/LDFlagValue.js +0 -3
  52. package/dist/api/data/LDFlagValue.js.map +0 -1
  53. package/dist/api/data/index.js +0 -21
  54. package/dist/api/data/index.js.map +0 -1
  55. package/dist/api/index.js +0 -24
  56. package/dist/api/index.js.map +0 -1
  57. package/dist/api/logging/BasicLoggerOptions.js +0 -3
  58. package/dist/api/logging/BasicLoggerOptions.js.map +0 -1
  59. package/dist/api/logging/LDLogLevel.js +0 -3
  60. package/dist/api/logging/LDLogLevel.js.map +0 -1
  61. package/dist/api/logging/LDLogger.js +0 -3
  62. package/dist/api/logging/LDLogger.js.map +0 -1
  63. package/dist/api/logging/index.js +0 -20
  64. package/dist/api/logging/index.js.map +0 -1
  65. package/dist/api/options/LDClientContext.js +0 -3
  66. package/dist/api/options/LDClientContext.js.map +0 -1
  67. package/dist/api/options/index.js +0 -4
  68. package/dist/api/options/index.js.map +0 -1
  69. package/dist/api/platform/AutoEnv.js +0 -20
  70. package/dist/api/platform/AutoEnv.js.map +0 -1
  71. package/dist/api/platform/Crypto.js +0 -3
  72. package/dist/api/platform/Crypto.js.map +0 -1
  73. package/dist/api/platform/Encoding.js +0 -3
  74. package/dist/api/platform/Encoding.js.map +0 -1
  75. package/dist/api/platform/EventSource.js +0 -3
  76. package/dist/api/platform/EventSource.js.map +0 -1
  77. package/dist/api/platform/Filesystem.js +0 -3
  78. package/dist/api/platform/Filesystem.js.map +0 -1
  79. package/dist/api/platform/Info.js +0 -3
  80. package/dist/api/platform/Info.js.map +0 -1
  81. package/dist/api/platform/Platform.js +0 -3
  82. package/dist/api/platform/Platform.js.map +0 -1
  83. package/dist/api/platform/Requests.js +0 -3
  84. package/dist/api/platform/Requests.js.map +0 -1
  85. package/dist/api/platform/Storage.js +0 -3
  86. package/dist/api/platform/Storage.js.map +0 -1
  87. package/dist/api/platform/index.js +0 -26
  88. package/dist/api/platform/index.js.map +0 -1
  89. package/dist/api/subsystem/LDContextDeduplicator.js +0 -3
  90. package/dist/api/subsystem/LDContextDeduplicator.js.map +0 -1
  91. package/dist/api/subsystem/LDEventProcessor.js +0 -3
  92. package/dist/api/subsystem/LDEventProcessor.js.map +0 -1
  93. package/dist/api/subsystem/LDEventSender.js +0 -15
  94. package/dist/api/subsystem/LDEventSender.js.map +0 -1
  95. package/dist/api/subsystem/LDStreamProcessor.js +0 -3
  96. package/dist/api/subsystem/LDStreamProcessor.js.map +0 -1
  97. package/dist/api/subsystem/index.js +0 -7
  98. package/dist/api/subsystem/index.js.map +0 -1
  99. package/dist/errors.js +0 -78
  100. package/dist/errors.js.map +0 -1
  101. package/dist/index.js +0 -31
  102. package/dist/index.js.map +0 -1
  103. package/dist/internal/context/index.js +0 -38
  104. package/dist/internal/context/index.js.map +0 -1
  105. package/dist/internal/diagnostics/DiagnosticsManager.js +0 -70
  106. package/dist/internal/diagnostics/DiagnosticsManager.js.map +0 -1
  107. package/dist/internal/diagnostics/index.js +0 -6
  108. package/dist/internal/diagnostics/index.js.map +0 -1
  109. package/dist/internal/diagnostics/types.js +0 -3
  110. package/dist/internal/diagnostics/types.js.map +0 -1
  111. package/dist/internal/evaluation/ErrorKinds.js +0 -15
  112. package/dist/internal/evaluation/ErrorKinds.js.map +0 -1
  113. package/dist/internal/evaluation/EventFactoryBase.js +0 -38
  114. package/dist/internal/evaluation/EventFactoryBase.js.map +0 -1
  115. package/dist/internal/evaluation/index.js +0 -8
  116. package/dist/internal/evaluation/index.js.map +0 -1
  117. package/dist/internal/events/ClientMessages.js +0 -14
  118. package/dist/internal/events/ClientMessages.js.map +0 -1
  119. package/dist/internal/events/EventProcessor.js +0 -263
  120. package/dist/internal/events/EventProcessor.js.map +0 -1
  121. package/dist/internal/events/EventSender.js +0 -77
  122. package/dist/internal/events/EventSender.js.map +0 -1
  123. package/dist/internal/events/EventSummarizer.js +0 -84
  124. package/dist/internal/events/EventSummarizer.js.map +0 -1
  125. package/dist/internal/events/InputClickEvent.js +0 -3
  126. package/dist/internal/events/InputClickEvent.js.map +0 -1
  127. package/dist/internal/events/InputCustomEvent.js +0 -22
  128. package/dist/internal/events/InputCustomEvent.js.map +0 -1
  129. package/dist/internal/events/InputEvalEvent.js +0 -38
  130. package/dist/internal/events/InputEvalEvent.js.map +0 -1
  131. package/dist/internal/events/InputEvent.js +0 -3
  132. package/dist/internal/events/InputEvent.js.map +0 -1
  133. package/dist/internal/events/InputEventBase.js +0 -11
  134. package/dist/internal/events/InputEventBase.js.map +0 -1
  135. package/dist/internal/events/InputIdentifyEvent.js +0 -12
  136. package/dist/internal/events/InputIdentifyEvent.js.map +0 -1
  137. package/dist/internal/events/InputMigrationEvent.js +0 -7
  138. package/dist/internal/events/InputMigrationEvent.js.map +0 -1
  139. package/dist/internal/events/InputPageViewEvent.js +0 -3
  140. package/dist/internal/events/InputPageViewEvent.js.map +0 -1
  141. package/dist/internal/events/LDInternalOptions.js +0 -3
  142. package/dist/internal/events/LDInternalOptions.js.map +0 -1
  143. package/dist/internal/events/LDInvalidSDKKeyError.js +0 -10
  144. package/dist/internal/events/LDInvalidSDKKeyError.js.map +0 -1
  145. package/dist/internal/events/NullEventProcessor.js +0 -11
  146. package/dist/internal/events/NullEventProcessor.js.map +0 -1
  147. package/dist/internal/events/SummaryCounter.js +0 -20
  148. package/dist/internal/events/SummaryCounter.js.map +0 -1
  149. package/dist/internal/events/guards.js +0 -20
  150. package/dist/internal/events/guards.js.map +0 -1
  151. package/dist/internal/events/index.js +0 -18
  152. package/dist/internal/events/index.js.map +0 -1
  153. package/dist/internal/events/sampling.js +0 -23
  154. package/dist/internal/events/sampling.js.map +0 -1
  155. package/dist/internal/index.js +0 -22
  156. package/dist/internal/index.js.map +0 -1
  157. package/dist/internal/stream/StreamingProcessor.js +0 -113
  158. package/dist/internal/stream/StreamingProcessor.js.map +0 -1
  159. package/dist/internal/stream/index.js +0 -6
  160. package/dist/internal/stream/index.js.map +0 -1
  161. package/dist/internal/stream/types.js +0 -3
  162. package/dist/internal/stream/types.js.map +0 -1
  163. package/dist/logging/BasicLogger.js +0 -97
  164. package/dist/logging/BasicLogger.js.map +0 -1
  165. package/dist/logging/SafeLogger.js +0 -63
  166. package/dist/logging/SafeLogger.js.map +0 -1
  167. package/dist/logging/createSafeLogger.js +0 -16
  168. package/dist/logging/createSafeLogger.js.map +0 -1
  169. package/dist/logging/format.js +0 -156
  170. package/dist/logging/format.js.map +0 -1
  171. package/dist/logging/index.js +0 -10
  172. package/dist/logging/index.js.map +0 -1
  173. package/dist/options/ApplicationTags.js +0 -55
  174. package/dist/options/ApplicationTags.js.map +0 -1
  175. package/dist/options/ClientContext.js +0 -20
  176. package/dist/options/ClientContext.js.map +0 -1
  177. package/dist/options/OptionMessages.js +0 -33
  178. package/dist/options/OptionMessages.js.map +0 -1
  179. package/dist/options/ServiceEndpoints.js +0 -77
  180. package/dist/options/ServiceEndpoints.js.map +0 -1
  181. package/dist/options/index.js +0 -15
  182. package/dist/options/index.js.map +0 -1
  183. package/dist/utils/VoidFunction.js +0 -3
  184. package/dist/utils/VoidFunction.js.map +0 -1
  185. package/dist/utils/cancelableTimedPromise.js +0 -30
  186. package/dist/utils/cancelableTimedPromise.js.map +0 -1
  187. package/dist/utils/clone.js +0 -10
  188. package/dist/utils/clone.js.map +0 -1
  189. package/dist/utils/date.js +0 -9
  190. package/dist/utils/date.js.map +0 -1
  191. package/dist/utils/debounce.js +0 -33
  192. package/dist/utils/debounce.js.map +0 -1
  193. package/dist/utils/deepCompact.js +0 -24
  194. package/dist/utils/deepCompact.js.map +0 -1
  195. package/dist/utils/fast-deep-equal/index.js +0 -90
  196. package/dist/utils/fast-deep-equal/index.js.map +0 -1
  197. package/dist/utils/http.js +0 -53
  198. package/dist/utils/http.js.map +0 -1
  199. package/dist/utils/index.js +0 -27
  200. package/dist/utils/index.js.map +0 -1
  201. package/dist/utils/isEmptyObject.js +0 -5
  202. package/dist/utils/isEmptyObject.js.map +0 -1
  203. package/dist/utils/noop.js +0 -4
  204. package/dist/utils/noop.js.map +0 -1
  205. package/dist/utils/sleep.js +0 -7
  206. package/dist/utils/sleep.js.map +0 -1
  207. package/dist/utils/timedPromise.js +0 -17
  208. package/dist/utils/timedPromise.js.map +0 -1
  209. package/dist/validators.js +0 -175
  210. package/dist/validators.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputIdentifyEvent.js","sourceRoot":"","sources":["../../../src/internal/events/InputIdentifyEvent.ts"],"names":[],"mappings":";;AAEA,MAAqB,kBAAkB;IAKrC,YACkB,OAAgB,EAChB,gBAAwB,CAAC;QADzB,YAAO,GAAP,OAAO,CAAS;QAChB,kBAAa,GAAb,aAAa,CAAY;QAN3B,SAAI,GAAG,UAAU,CAAC;QAQhC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;CACF;AAXD,qCAWC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- // Migration events are not currently supported by client-side SDKs, so this
3
- // shared implementation contains minimal typing. If/When migration events are
4
- // to be supported by client-side SDKs the appropriate types would be moved
5
- // to the common implementation.
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=InputMigrationEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputMigrationEvent.js","sourceRoot":"","sources":["../../../src/internal/events/InputMigrationEvent.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,gCAAgC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=InputPageViewEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputPageViewEvent.js","sourceRoot":"","sources":["../../../src/internal/events/InputPageViewEvent.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=LDInternalOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LDInternalOptions.js","sourceRoot":"","sources":["../../../src/internal/events/LDInternalOptions.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class LDInvalidSDKKeyError extends Error {
4
- constructor(message) {
5
- super(message);
6
- this.name = 'LaunchDarklyInvalidSDKKeyError';
7
- }
8
- }
9
- exports.default = LDInvalidSDKKeyError;
10
- //# sourceMappingURL=LDInvalidSDKKeyError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LDInvalidSDKKeyError.js","sourceRoot":"","sources":["../../../src/internal/events/LDInvalidSDKKeyError.ts"],"names":[],"mappings":";;AAAA,MAAqB,oBAAqB,SAAQ,KAAK;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AALD,uCAKC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class NullEventProcessor {
4
- close() { }
5
- async flush() {
6
- // empty comment to keep ts and eslint happy
7
- }
8
- sendEvent() { }
9
- }
10
- exports.default = NullEventProcessor;
11
- //# sourceMappingURL=NullEventProcessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NullEventProcessor.js","sourceRoot":"","sources":["../../../src/internal/events/NullEventProcessor.ts"],"names":[],"mappings":";;AAEA,MAAqB,kBAAkB;IACrC,KAAK,KAAI,CAAC;IAEV,KAAK,CAAC,KAAK;QACT,4CAA4C;IAC9C,CAAC;IAED,SAAS,KAAI,CAAC;CACf;AARD,qCAQC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @internal
5
- */
6
- class SummaryCounter {
7
- constructor(count, key, value, defValue, version, variation) {
8
- this.count = count;
9
- this.key = key;
10
- this.value = value;
11
- this.version = version;
12
- this.variation = variation;
13
- this.default = defValue;
14
- }
15
- increment() {
16
- this.count += 1;
17
- }
18
- }
19
- exports.default = SummaryCounter;
20
- //# sourceMappingURL=SummaryCounter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SummaryCounter.js","sourceRoot":"","sources":["../../../src/internal/events/SummaryCounter.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAqB,cAAc;IAGjC,YACS,KAAa,EACb,GAAW,EACX,KAAU,EACjB,QAAa,EACN,OAAgB,EAChB,SAAkB;QALlB,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAK;QAEV,YAAO,GAAP,OAAO,CAAS;QAChB,cAAS,GAAT,SAAS,CAAS;QAEzB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAClB,CAAC;CACF;AAjBD,iCAiBC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMigration = exports.isIdentify = exports.isCustom = exports.isFeature = void 0;
4
- function isFeature(u) {
5
- return u.kind === 'feature';
6
- }
7
- exports.isFeature = isFeature;
8
- function isCustom(u) {
9
- return u.kind === 'custom';
10
- }
11
- exports.isCustom = isCustom;
12
- function isIdentify(u) {
13
- return u.kind === 'identify';
14
- }
15
- exports.isIdentify = isIdentify;
16
- function isMigration(u) {
17
- return u.kind === 'migration_op';
18
- }
19
- exports.isMigration = isMigration;
20
- //# sourceMappingURL=guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../src/internal/events/guards.ts"],"names":[],"mappings":";;;AAKA,SAAgB,SAAS,CAAC,CAAM;IAC9B,OAAO,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;AAC9B,CAAC;AAFD,8BAEC;AAED,SAAgB,QAAQ,CAAC,CAAM;IAC7B,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC7B,CAAC;AAFD,4BAEC;AAED,SAAgB,UAAU,CAAC,CAAM;IAC/B,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;AAC/B,CAAC;AAFD,gCAEC;AAED,SAAgB,WAAW,CAAC,CAAM;IAChC,OAAO,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC;AACnC,CAAC;AAFD,kCAEC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NullEventProcessor = exports.shouldSample = exports.EventProcessor = exports.InputIdentifyEvent = exports.InputEvalEvent = exports.InputCustomEvent = exports.ClientMessages = void 0;
4
- const ClientMessages_1 = require("./ClientMessages");
5
- exports.ClientMessages = ClientMessages_1.default;
6
- const EventProcessor_1 = require("./EventProcessor");
7
- exports.EventProcessor = EventProcessor_1.default;
8
- const InputCustomEvent_1 = require("./InputCustomEvent");
9
- exports.InputCustomEvent = InputCustomEvent_1.default;
10
- const InputEvalEvent_1 = require("./InputEvalEvent");
11
- exports.InputEvalEvent = InputEvalEvent_1.default;
12
- const InputIdentifyEvent_1 = require("./InputIdentifyEvent");
13
- exports.InputIdentifyEvent = InputIdentifyEvent_1.default;
14
- const NullEventProcessor_1 = require("./NullEventProcessor");
15
- exports.NullEventProcessor = NullEventProcessor_1.default;
16
- const sampling_1 = require("./sampling");
17
- exports.shouldSample = sampling_1.default;
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/events/index.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAY5C,yBAZK,wBAAc,CAYL;AAXhB,qDAAyE;AAiBvE,yBAjBK,wBAAc,CAiBL;AAhBhB,yDAAkD;AAWhD,2BAXK,0BAAgB,CAWL;AAVlB,qDAA8C;AAW5C,yBAXK,wBAAc,CAWL;AAThB,6DAAsD;AAWpD,6BAXK,4BAAkB,CAWL;AARpB,6DAAsD;AAapD,6BAbK,4BAAkB,CAaL;AAZpB,yCAAsC;AAWpC,uBAXK,kBAAY,CAWL"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /**
3
- * The contents of this file are for event sampling. They are not used for
4
- * any purpose requiring cryptographic security.
5
- * */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- function shouldSample(ratio) {
8
- const truncated = Math.trunc(ratio);
9
- // A radio of 1 means 1 in 1. So that will always sample. No need
10
- // to draw a random number.
11
- if (truncated === 1) {
12
- return true;
13
- }
14
- if (truncated === 0) {
15
- return false;
16
- }
17
- // Math.random() * truncated) would return 0, 1, ... (ratio - 1).
18
- // Checking for any number in the range will have approximately a 1 in X
19
- // chance. So we check for 0 as it is part of any range.
20
- return Math.floor(Math.random() * truncated) === 0;
21
- }
22
- exports.default = shouldSample;
23
- //# sourceMappingURL=sampling.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../../src/internal/events/sampling.ts"],"names":[],"mappings":";AAAA;;;KAGK;;AAEL,SAAwB,YAAY,CAAC,KAAa;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,iEAAiE;IACjE,2BAA2B;IAC3B,IAAI,SAAS,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,SAAS,KAAK,CAAC,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,iEAAiE;IACjE,wEAAwE;IACxE,wDAAwD;IACxD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAhBD,+BAgBC"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./diagnostics"), exports);
18
- __exportStar(require("./evaluation"), exports);
19
- __exportStar(require("./events"), exports);
20
- __exportStar(require("./stream"), exports);
21
- __exportStar(require("./context"), exports);
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B"}
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const errors_1 = require("../../errors");
4
- const ServiceEndpoints_1 = require("../../options/ServiceEndpoints");
5
- const utils_1 = require("../../utils");
6
- const reportJsonError = (type, data, logger, errorHandler) => {
7
- logger === null || logger === void 0 ? void 0 : logger.error(`Stream received invalid data in "${type}" message`);
8
- logger === null || logger === void 0 ? void 0 : logger.debug(`Invalid JSON follows: ${data}`);
9
- errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler(new errors_1.LDStreamingError('Malformed JSON data in event stream'));
10
- };
11
- // TODO: SDK-156 - Move to Server SDK specific location
12
- class StreamingProcessor {
13
- constructor(clientContext, streamUriPath, parameters, listeners, baseHeaders, diagnosticsManager, errorHandler, streamInitialReconnectDelay = 1) {
14
- this.listeners = listeners;
15
- this.diagnosticsManager = diagnosticsManager;
16
- this.errorHandler = errorHandler;
17
- this.streamInitialReconnectDelay = streamInitialReconnectDelay;
18
- const { basicConfiguration, platform } = clientContext;
19
- const { logger } = basicConfiguration;
20
- const { requests } = platform;
21
- this.headers = Object.assign({}, baseHeaders);
22
- this.logger = logger;
23
- this.requests = requests;
24
- this.streamUri = (0, ServiceEndpoints_1.getStreamingUri)(basicConfiguration.serviceEndpoints, streamUriPath, parameters);
25
- }
26
- logConnectionStarted() {
27
- this.connectionAttemptStartTime = Date.now();
28
- }
29
- logConnectionResult(success) {
30
- if (this.connectionAttemptStartTime && this.diagnosticsManager) {
31
- this.diagnosticsManager.recordStreamInit(this.connectionAttemptStartTime, !success, Date.now() - this.connectionAttemptStartTime);
32
- }
33
- this.connectionAttemptStartTime = undefined;
34
- }
35
- /**
36
- * This is a wrapper around the passed errorHandler which adds additional
37
- * diagnostics and logging logic.
38
- *
39
- * @param err The error to be logged and handled.
40
- * @return boolean whether to retry the connection.
41
- *
42
- * @private
43
- */
44
- retryAndHandleError(err) {
45
- var _a, _b, _c;
46
- if (!(0, utils_1.shouldRetry)(err)) {
47
- this.logConnectionResult(false);
48
- (_a = this.errorHandler) === null || _a === void 0 ? void 0 : _a.call(this, new errors_1.LDStreamingError(err.message, err.status));
49
- (_b = this.logger) === null || _b === void 0 ? void 0 : _b.error((0, utils_1.httpErrorMessage)(err, 'streaming request'));
50
- return false;
51
- }
52
- (_c = this.logger) === null || _c === void 0 ? void 0 : _c.warn((0, utils_1.httpErrorMessage)(err, 'streaming request', 'will retry'));
53
- this.logConnectionResult(false);
54
- this.logConnectionStarted();
55
- return true;
56
- }
57
- start() {
58
- this.logConnectionStarted();
59
- // TLS is handled by the platform implementation.
60
- const eventSource = this.requests.createEventSource(this.streamUri, {
61
- headers: this.headers,
62
- errorFilter: (error) => this.retryAndHandleError(error),
63
- initialRetryDelayMillis: 1000 * this.streamInitialReconnectDelay,
64
- readTimeoutMillis: 5 * 60 * 1000,
65
- retryResetIntervalMillis: 60 * 1000,
66
- });
67
- this.eventSource = eventSource;
68
- eventSource.onclose = () => {
69
- var _a;
70
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info('Closed LaunchDarkly stream connection');
71
- };
72
- eventSource.onerror = () => {
73
- // The work is done by `errorFilter`.
74
- };
75
- eventSource.onopen = () => {
76
- var _a;
77
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info('Opened LaunchDarkly stream connection');
78
- };
79
- eventSource.onretrying = (e) => {
80
- var _a;
81
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(`Will retry stream connection in ${e.delayMillis} milliseconds`);
82
- };
83
- this.listeners.forEach(({ deserializeData, processJson }, eventName) => {
84
- eventSource.addEventListener(eventName, (event) => {
85
- var _a, _b;
86
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`Received ${eventName} event`);
87
- if (event === null || event === void 0 ? void 0 : event.data) {
88
- this.logConnectionResult(true);
89
- const { data } = event;
90
- const dataJson = deserializeData(data);
91
- if (!dataJson) {
92
- reportJsonError(eventName, data, this.logger, this.errorHandler);
93
- return;
94
- }
95
- processJson(dataJson);
96
- }
97
- else {
98
- (_b = this.errorHandler) === null || _b === void 0 ? void 0 : _b.call(this, new errors_1.LDStreamingError('Unexpected payload from event stream'));
99
- }
100
- });
101
- });
102
- }
103
- stop() {
104
- var _a;
105
- (_a = this.eventSource) === null || _a === void 0 ? void 0 : _a.close();
106
- this.eventSource = undefined;
107
- }
108
- close() {
109
- this.stop();
110
- }
111
- }
112
- exports.default = StreamingProcessor;
113
- //# sourceMappingURL=StreamingProcessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StreamingProcessor.js","sourceRoot":"","sources":["../../../src/internal/stream/StreamingProcessor.ts"],"names":[],"mappings":";;AASA,yCAAgD;AAEhD,qEAAiE;AACjE,uCAAuE;AAIvE,MAAM,eAAe,GAAG,CACtB,IAAY,EACZ,IAAY,EACZ,MAAiB,EACjB,YAAoC,EACpC,EAAE;IACF,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,oCAAoC,IAAI,WAAW,CAAC,CAAC;IACnE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;IAC/C,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,IAAI,yBAAgB,CAAC,qCAAqC,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC;AAEF,uDAAuD;AACvD,MAAM,kBAAkB;IAStB,YACE,aAA4B,EAC5B,aAAqB,EACrB,UAA4C,EAC3B,SAAgD,EACjE,WAAsB,EACL,kBAAuC,EACvC,YAAoC,EACpC,8BAA8B,CAAC;QAJ/B,cAAS,GAAT,SAAS,CAAuC;QAEhD,uBAAkB,GAAlB,kBAAkB,CAAqB;QACvC,iBAAY,GAAZ,YAAY,CAAwB;QACpC,gCAA2B,GAA3B,2BAA2B,CAAI;QAEhD,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC;QACtC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;QAE9B,IAAI,CAAC,OAAO,qBAAQ,WAAW,CAAE,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACz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IAAI,EAAE;oBACf,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;oBAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;oBACvB,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;oBAEvC,IAAI,CAAC,QAAQ,EAAE;wBACb,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;wBACjE,OAAO;qBACR;oBACD,WAAW,CAAC,QAAQ,CAAC,CAAC;iBACvB;qBAAM;oBACL,MAAA,IAAI,CAAC,YAAY,qDAAG,IAAI,yBAAgB,CAAC,sCAAsC,CAAC,CAAC,CAAC;iBACnF;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI;;QACF,MAAA,IAAI,CAAC,WAAW,0CAAE,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF;AAED,kBAAe,kBAAkB,CAAC"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamingProcessor = void 0;
4
- const StreamingProcessor_1 = require("./StreamingProcessor");
5
- exports.StreamingProcessor = StreamingProcessor_1.default;
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/stream/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AAG7C,6BAHF,4BAAkB,CAGE"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/internal/stream/types.ts"],"names":[],"mappings":""}
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const format_1 = require("./format");
4
- const LogPriority = {
5
- debug: 0,
6
- info: 1,
7
- warn: 2,
8
- error: 3,
9
- none: 4,
10
- };
11
- const LevelNames = ['debug', 'info', 'warn', 'error', 'none'];
12
- /**
13
- * A basic logger which handles filtering by level.
14
- *
15
- * With the default options it will write to `console.error`
16
- * and it will use the formatting provided by `console.error`.
17
- * If the destination is overwritten, then it will use an included
18
- * formatter similar to `util.format`.
19
- *
20
- * If a formatter is available, then that should be overridden
21
- * as well for performance.
22
- */
23
- class BasicLogger {
24
- /**
25
- * This should only be used as a default fallback and not as a convenient
26
- * solution. In most cases you should construct a new instance with the
27
- * appropriate options for your specific needs.
28
- */
29
- static get() {
30
- return new BasicLogger({});
31
- }
32
- constructor(options) {
33
- var _a, _b, _c;
34
- this.logLevel = (_b = LogPriority[(_a = options.level) !== null && _a !== void 0 ? _a : 'info']) !== null && _b !== void 0 ? _b : LogPriority.info;
35
- this.name = (_c = options.name) !== null && _c !== void 0 ? _c : 'LaunchDarkly';
36
- // eslint-disable-next-line no-console
37
- this.destination = options.destination;
38
- this.formatter = options.formatter;
39
- }
40
- tryFormat(...args) {
41
- var _a;
42
- try {
43
- if (this.formatter) {
44
- // In case the provided formatter fails.
45
- return (_a = this.formatter) === null || _a === void 0 ? void 0 : _a.call(this, ...args);
46
- }
47
- return (0, format_1.default)(...args);
48
- }
49
- catch (_b) {
50
- return (0, format_1.default)(...args);
51
- }
52
- }
53
- tryWrite(msg) {
54
- try {
55
- this.destination(msg);
56
- }
57
- catch (_a) {
58
- // eslint-disable-next-line no-console
59
- console.error(msg);
60
- }
61
- }
62
- log(level, args) {
63
- if (level >= this.logLevel) {
64
- const prefix = `${LevelNames[level]}: [${this.name}]`;
65
- try {
66
- if (this.destination) {
67
- this.tryWrite(`${prefix} ${this.tryFormat(...args)}`);
68
- }
69
- else {
70
- // `console.error` has its own formatter.
71
- // So we don't need to do anything.
72
- // eslint-disable-next-line no-console
73
- console.error(...args);
74
- }
75
- }
76
- catch (_a) {
77
- // If all else fails do not break.
78
- // eslint-disable-next-line no-console
79
- console.error(...args);
80
- }
81
- }
82
- }
83
- error(...args) {
84
- this.log(LogPriority.error, args);
85
- }
86
- warn(...args) {
87
- this.log(LogPriority.warn, args);
88
- }
89
- info(...args) {
90
- this.log(LogPriority.info, args);
91
- }
92
- debug(...args) {
93
- this.log(LogPriority.debug, args);
94
- }
95
- }
96
- exports.default = BasicLogger;
97
- //# sourceMappingURL=BasicLogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasicLogger.js","sourceRoot":"","sources":["../../src/logging/BasicLogger.ts"],"names":[],"mappings":";;AACA,qCAA8B;AAE9B,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAqB,WAAW;IAS9B;;;;OAIG;IACH,MAAM,CAAC,GAAG;QACR,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,YAAY,OAA2B;;QACrC,IAAI,CAAC,QAAQ,GAAG,MAAA,WAAW,CAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,MAAM,CAAC,mCAAI,WAAW,CAAC,IAAI,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,cAAc,CAAC;QAC3C,sCAAsC;QACtC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACrC,CAAC;IAEO,SAAS,CAAC,GAAG,IAAW;;QA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,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAlFD,8BAkFC"}
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const validators_1 = require("../validators");
4
- const loggerRequirements = {
5
- error: validators_1.TypeValidators.Function,
6
- warn: validators_1.TypeValidators.Function,
7
- info: validators_1.TypeValidators.Function,
8
- debug: validators_1.TypeValidators.Function,
9
- };
10
- /**
11
- * The safeLogger logic exists because we allow the application to pass in a custom logger, but
12
- * there is no guarantee that the logger works correctly and if it ever throws exceptions there
13
- * could be serious consequences (e.g. an uncaught exception within an error event handler, due
14
- * to the SDK trying to log the error, can terminate the application). An exception could result
15
- * from faulty logic in the logger implementation, or it could be that this is not a logger at
16
- * all but some other kind of object; the former is handled by a catch block that logs an error
17
- * message to the SDK's default logger, and we can at least partly guard against the latter by
18
- * checking for the presence of required methods at configuration time.
19
- */
20
- class SafeLogger {
21
- /**
22
- * Construct a safe logger with the specified logger.
23
- * @param logger The logger to use.
24
- * @param fallback A fallback logger to use in case an issue is encountered using
25
- * the provided logger.
26
- */
27
- constructor(logger, fallback) {
28
- Object.entries(loggerRequirements).forEach(([level, validator]) => {
29
- if (!validator.is(logger[level])) {
30
- throw new Error(`Provided logger instance must support logger.${level}(...) method`);
31
- // Note that the SDK normally does not throw exceptions to the application, but that rule
32
- // does not apply to LDClient.init() which will throw an exception if the parameters are so
33
- // invalid that we cannot proceed with creating the client. An invalid logger meets those
34
- // criteria since the SDK calls the logger during nearly all of its operations.
35
- }
36
- });
37
- this.logger = logger;
38
- this.fallback = fallback;
39
- }
40
- log(level, args) {
41
- try {
42
- this.logger[level](...args);
43
- }
44
- catch (_a) {
45
- // If all else fails do not break.
46
- this.fallback[level](...args);
47
- }
48
- }
49
- error(...args) {
50
- this.log('error', args);
51
- }
52
- warn(...args) {
53
- this.log('warn', args);
54
- }
55
- info(...args) {
56
- this.log('info', args);
57
- }
58
- debug(...args) {
59
- this.log('debug', args);
60
- }
61
- }
62
- exports.default = SafeLogger;
63
- //# sourceMappingURL=SafeLogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SafeLogger.js","sourceRoot":"","sources":["../../src/logging/SafeLogger.ts"],"names":[],"mappings":";;AACA,8CAA+C;AAE/C,MAAM,kBAAkB,GAAG;IACzB,KAAK,EAAE,2BAAc,CAAC,QAAQ;IAC9B,IAAI,EAAE,2BAAc,CAAC,QAAQ;IAC7B,IAAI,EAAE,2BAAc,CAAC,QAAQ;IAC7B,KAAK,EAAE,2BAAc,CAAC,QAAQ;CAC/B,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAqB,UAAU;IAK7B;;;;;OAKG;IACH,YAAY,MAAgB,EAAE,QAAkB;QAC9C,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE;YAChE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAE,MAAc,CAAC,KAAK,CAAC,CAAC,EAAE;gBACzC,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,cAAc,CAAC,CAAC;gBACrF,yFAAyF;gBACzF,2FAA2F;gBAC3F,yFAAyF;gBACzF,+EAA+E;aAChF;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEO,GAAG,CAAC,KAA0C,EAAE,IAAW;QACjE,IAAI;YACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;SAC7B;QAAC,WAAM;YACN,kCAAkC;YAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAjDD,6BAiDC"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const BasicLogger_1 = require("./BasicLogger");
4
- const format_1 = require("./format");
5
- const SafeLogger_1 = require("./SafeLogger");
6
- const createSafeLogger = (logger) => {
7
- const basicLogger = new BasicLogger_1.default({
8
- level: 'info',
9
- // eslint-disable-next-line no-console
10
- destination: console.error,
11
- formatter: format_1.default,
12
- });
13
- return logger ? new SafeLogger_1.default(logger, basicLogger) : basicLogger;
14
- };
15
- exports.default = createSafeLogger;
16
- //# sourceMappingURL=createSafeLogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSafeLogger.js","sourceRoot":"","sources":["../../src/logging/createSafeLogger.ts"],"names":[],"mappings":";;AACA,+CAAwC;AACxC,qCAA8B;AAC9B,6CAAsC;AAEtC,MAAM,gBAAgB,GAAG,CAAC,MAAiB,EAAE,EAAE;IAC7C,MAAM,WAAW,GAAG,IAAI,qBAAW,CAAC;QAClC,KAAK,EAAE,MAAM;QACb,sCAAsC;QACtC,WAAW,EAAE,OAAO,CAAC,KAAK;QAC1B,SAAS,EAAE,gBAAM;KAClB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,oBAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AACpE,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}