diff --git a/.github/workflows/update-license-year.yml b/.github/workflows/update-notice-year.yml similarity index 81% rename from .github/workflows/update-license-year.yml rename to .github/workflows/update-notice-year.yml index ef86df4..440dacb 100644 --- a/.github/workflows/update-license-year.yml +++ b/.github/workflows/update-notice-year.yml @@ -1,4 +1,4 @@ -name: Update License Year +name: Update Notice Year on: schedule: @@ -23,23 +23,23 @@ jobs: - name: Set Previous Year run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV" - - name: Update LICENSE + - name: Update NOTICE uses: jacobtomlinson/gha-find-replace@v3 with: find: ${{ env.PREVIOUS }} replace: ${{ env.CURRENT }} - include: "**/LICENSE" + include: "NOTICE" regex: false - name: Commit files run: | git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' - git commit -m "Updated License Year" -a + git commit -m "Updated Notice Year" -a - name: Create Pull Request uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} - title: Update License Year - branch: update-license + title: Update Notice Year + branch: update-notice diff --git a/CONTRIBUTORS-GUIDE.md b/CONTRIBUTORS-GUIDE.md index dfe5b77..dbd38a3 100644 --- a/CONTRIBUTORS-GUIDE.md +++ b/CONTRIBUTORS-GUIDE.md @@ -26,6 +26,10 @@ Run unit tests in Android & iOS packages with `flutter test`. Run unit tests in Web package with `flutter test --platform chrome`. +### Linting and other useful checks + +Run the static code analyzer (`flutter analyze`) to fix any errors, warnings, lints, or formatting issues. + # Contact If you have any other questions or need to contact us directly in a private manner send us a note at sdks@split.io diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..b2af76c --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Harness Feature Management Flutter SDK Copyright 2024-2026 Harness Inc. + +This product includes software developed at Harness Inc. (https://harness.io/). + +This product includes software originally developed by Split Software, Inc. (https://www.split.io/). Copyright 2022-2024 Split Software, Inc. diff --git a/splitio/CHANGELOG.md b/splitio/CHANGELOG.md index 7a35a9b..371938a 100644 --- a/splitio/CHANGELOG.md +++ b/splitio/CHANGELOG.md @@ -1,15 +1,26 @@ +# 1.2.1 (Jan 28, 2026) +* Bug fix: corrected asset path for loading the Browser SDK. + +# 1.2.1-rc.1 (Jan 28, 2026) + +# 1.2.0 (Jan 28, 2026) +* Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs. +* Updated Android SDK to `5.4.2`, iOS SDK to `3.6.0`, and Browser SDK to `1.6.1` + +# 1.2.0-rc.1 (Jan 28, 2026) + # 1.1.0 (Jan 16, 2026) -- Added Web support via the `splitio_web` package, the Web implementation of `splitio` based on the Split Browser SDK v1.6.0. +* Added Web support via the `splitio_web` package, the Web implementation of `splitio` based on the Split Browser SDK `1.6.0`. # 1.1.0-rc.1 (Jan 15, 2026) # 1.0.0 (Aug 14, 2025) -- Updated Android SDK to `5.3.1` & iOS SDK to `3.3.2` -- Added support for rule-based segments. These segments determine membership at runtime by evaluating their configured rules against the user attributes provided to the SDK. -- Added support for feature flag prerequisites. This allows customers to define dependency conditions between flags, which are evaluated before any allowlists or targeting rules. -- Added two new configuration options to control the behavior of the persisted rollout plan cache. Use `rolloutCacheConfiguration` in the config. -- Added a new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impressions sent to Split backend. Read more in our docs. -- Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on SplitView type objects. Read more in our docs. +* Updated Android SDK to `5.3.1` & iOS SDK to `3.3.2` +* Added support for rule-based segments. These segments determine membership at runtime by evaluating their configured rules against the user attributes provided to the SDK. +* Added support for feature flag prerequisites. This allows customers to define dependency conditions between flags, which are evaluated before any allowlists or targeting rules. +* Added two new configuration options to control the behavior of the persisted rollout plan cache. Use `rolloutCacheConfiguration` in the config. +* Added a new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impressions sent to Split backend. Read more in our docs. +* Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on SplitView type objects. Read more in our docs. # 1.0.0-rc.1 (Aug 14, 2025) diff --git a/splitio/analysis_options.yaml b/splitio/analysis_options.yaml index a5744c1..5cf0db1 100644 --- a/splitio/analysis_options.yaml +++ b/splitio/analysis_options.yaml @@ -2,3 +2,7 @@ include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + +linter: + rules: + - public_member_api_docs diff --git a/splitio/example/ios/Podfile.lock b/splitio/example/ios/Podfile.lock index e004592..c23d777 100644 --- a/splitio/example/ios/Podfile.lock +++ b/splitio/example/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - Flutter (1.0.0) - - Split (3.3.2) - - splitio_ios (0.8.0): + - Split (3.6.0) + - splitio_ios (0.9.0): - Flutter - - Split (~> 3.3.2) + - Split (~> 3.6.0) DEPENDENCIES: - Flutter (from `Flutter`) @@ -20,9 +20,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/splitio_ios/ios" SPEC CHECKSUMS: - Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - Split: 0d4962a6c15180e1857c1a3753e1ae9c91a6150b - splitio_ios: 438ad21d0dfe467670f8b9508773b77b16a71d6b + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 + Split: 1e2176aacd6421029bea41413401389d86e3d50a + splitio_ios: ad4f484a6c478bf7285e417ea8252371f66b54ff PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 diff --git a/splitio/example/lib/main.dart b/splitio/example/lib/main.dart index 998a90b..a27a0a5 100644 --- a/splitio/example/lib/main.dart +++ b/splitio/example/lib/main.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'package:flutter/material.dart'; import 'package:splitio/splitio.dart'; diff --git a/splitio/example/pubspec.lock b/splitio/example/pubspec.lock index 2e7d49c..c944234 100644 --- a/splitio/example/pubspec.lock +++ b/splitio/example/pubspec.lock @@ -171,39 +171,39 @@ packages: path: ".." relative: true source: path - version: "1.1.0" + version: "1.2.1" splitio_android: dependency: transitive description: name: splitio_android - sha256: "344bf82de6694cffb8dd80a96ee734e31bb838d2b4693fb046e0fc98e31512ca" + sha256: "7c0e5ad4ccdf4990120a7a6a2f067d274c107ab9830fd20b1d54bf3f0392ac02" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.0" splitio_ios: dependency: transitive description: name: splitio_ios - sha256: "1c078bc49bf7b30df6ca50accb6a9eecf592ec607e20e77b1c6ecdabc7a44dc9" + sha256: c15cd7dfd195df107ae07c030fd742dcabb0610c769466d6d7e3890d22a91bc2 url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.0" splitio_platform_interface: dependency: transitive description: name: splitio_platform_interface - sha256: "8bcb1cab9f5fffb7b79cfeeaf6c80d82f8ede55c8d6ca7578ec78653f3f9e499" + sha256: faa022814c7b2fc7b5f68b80b088e1638e06783419075176d1adadcf787897db url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.0" splitio_web: dependency: transitive description: name: splitio_web - sha256: "29dc1a55d80c026afb0f0bad378c81e44ee1e9da5faaf9e931f35b5dfd3ff5f3" + sha256: "656cf71d4ec900cf1ad1b9eae20bbabe797de5c99f49584672161de9fe133afb" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.1" stack_trace: dependency: transitive description: diff --git a/splitio/lib/split_client.dart b/splitio/lib/split_client.dart index 883a9f4..cfa2c00 100644 --- a/splitio/lib/split_client.dart +++ b/splitio/lib/split_client.dart @@ -1,5 +1,6 @@ import 'package:splitio_platform_interface/splitio_platform_interface.dart'; +/// Abstract class representing a Split client. abstract class SplitClient { /// Performs an evaluation for the [featureFlagName] feature flag. /// @@ -187,11 +188,13 @@ abstract class SplitClient { Future whenTimeout(); } +/// Default implementation of the Split client. class DefaultSplitClient implements SplitClient { final SplitioPlatform _platform; final String _matchingKey; final String? _bucketingKey; + /// Creates a new instance of the Split client. DefaultSplitClient(this._platform, this._matchingKey, this._bucketingKey); @override diff --git a/splitio/lib/splitio.dart b/splitio/lib/splitio.dart index 82e4bfa..ae56ab1 100644 --- a/splitio/lib/splitio.dart +++ b/splitio/lib/splitio.dart @@ -12,9 +12,13 @@ export 'package:splitio_platform_interface/split_view.dart'; export 'package:splitio_platform_interface/split_certificate_pinning_configuration.dart'; export 'package:splitio_platform_interface/split_evaluation_options.dart'; export 'package:splitio_platform_interface/split_rollout_cache_configuration.dart'; +export 'package:splitio_platform_interface/split_fallback_treatment.dart'; +export 'package:splitio_platform_interface/split_fallback_treatments_configuration.dart'; +/// Callback function type for client readiness events. typedef ClientReadinessCallback = void Function(SplitClient splitClient); +/// Main class for interacting with the Split Flutter SDK. class Splitio { final String _sdkKey; @@ -77,7 +81,11 @@ class Splitio { ClientReadinessCallback? onReadyFromCache, ClientReadinessCallback? onUpdated, ClientReadinessCallback? onTimeout}) { - String? key = matchingKey ?? _defaultMatchingKey; + String key = matchingKey ?? _defaultMatchingKey; + if (matchingKey == null && bucketingKey == null) { + bucketingKey = _defaultBucketingKey; + } + _platform.getClient(matchingKey: key, bucketingKey: bucketingKey); var client = DefaultSplitClient(_platform, key, bucketingKey); @@ -108,12 +116,14 @@ class Splitio { return client; } + /// Gets the list of all feature flag names. Future> splitNames() async { List splitNames = await _platform.splitNames(); return splitNames; } + /// Gets the list of all feature flag views. Future> splits() async { return _platform.splits(); } @@ -124,14 +134,22 @@ class Splitio { return _platform.impressionsStream(); } + /// Gets a specific feature flag view. + /// + /// Returns null if the provided feature flag name is not found. Future split(String splitName) async { return _platform.split(splitName: splitName); } + /// Gets the user consent status. Future getUserConsent() async { return _platform.getUserConsent(); } + /// Sets the user consent status. + /// + /// [enabled] is a boolean that enables (`UserConsent.granted`) + /// or disables (`UserConsent.declined`) data collection. Future setUserConsent(bool enabled) async { return _platform.setUserConsent(enabled); } diff --git a/splitio/pubspec.yaml b/splitio/pubspec.yaml index a762f9f..89f2b62 100644 --- a/splitio/pubspec.yaml +++ b/splitio/pubspec.yaml @@ -1,6 +1,6 @@ name: splitio description: Official plugin for split.io, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience. -version: 1.1.0 +version: 1.2.1 homepage: https://split.io/ repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio/ @@ -21,10 +21,10 @@ flutter: dependencies: flutter: sdk: flutter - splitio_android: ^1.0.0 - splitio_ios: ^1.0.0 - splitio_web: ^1.0.0 - splitio_platform_interface: ^2.0.0 + splitio_android: ^1.1.0 + splitio_ios: ^1.1.0 + splitio_web: ^1.1.1 + splitio_platform_interface: ^2.1.0 dev_dependencies: flutter_test: sdk: flutter diff --git a/splitio/test/splitio_platform_stub.dart b/splitio/test/splitio_platform_stub.dart index 001d7b3..5fb3af6 100644 --- a/splitio/test/splitio_platform_stub.dart +++ b/splitio/test/splitio_platform_stub.dart @@ -1,6 +1,5 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'package:splitio_platform_interface/splitio_platform_interface.dart'; -import 'package:splitio_platform_interface/split_evaluation_options.dart'; class SplitioPlatformStub with MockPlatformInterfaceMixin diff --git a/splitio_android/CHANGELOG.md b/splitio_android/CHANGELOG.md index 6f47087..aa4545a 100644 --- a/splitio_android/CHANGELOG.md +++ b/splitio_android/CHANGELOG.md @@ -1,5 +1,11 @@ +# 1.1.0 (Jan 28, 2026) +* Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs. +* Updated Android SDK to `5.4.2`. + +# 1.1.0-rc.1 (Jan 28, 2026) + # 1.0.0 (Aug 14, 2025) -- Updated Android SDK to `5.3.1`. +* Updated Android SDK to `5.3.1`. # 1.0.0-rc.1 (Aug 14, 2025) diff --git a/splitio_android/analysis_options.yaml b/splitio_android/analysis_options.yaml index a5744c1..5cf0db1 100644 --- a/splitio_android/analysis_options.yaml +++ b/splitio_android/analysis_options.yaml @@ -2,3 +2,7 @@ include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + +linter: + rules: + - public_member_api_docs diff --git a/splitio_android/android/build.gradle b/splitio_android/android/build.gradle index 0cd5200..723d466 100644 --- a/splitio_android/android/build.gradle +++ b/splitio_android/android/build.gradle @@ -38,7 +38,7 @@ android { } dependencies { - implementation 'io.split.client:android-client:5.3.1' + implementation 'io.split.client:android-client:5.4.2' testImplementation 'junit:junit:4.13.2' testImplementation 'org.mockito:mockito-core:3.12.4' diff --git a/splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java b/splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java index 2df8e0d..da35b35 100644 --- a/splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java +++ b/splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java @@ -19,6 +19,8 @@ import io.split.android.client.network.CertificatePinningConfiguration; import io.split.android.client.shared.UserConsent; import io.split.android.client.utils.logger.SplitLogLevel; +import io.split.android.client.fallback.FallbackTreatmentsConfiguration; +import io.split.android.client.fallback.FallbackTreatment; class SplitClientConfigHelper { @@ -55,6 +57,11 @@ class SplitClientConfigHelper { private static final String ROLLOUT_CACHE_CONFIGURATION = "rolloutCacheConfiguration"; private static final String ROLLOUT_CACHE_CONFIGURATION_EXPIRATION = "expirationDays"; private static final String ROLLOUT_CACHE_CONFIGURATION_CLEAR_ON_INIT = "clearOnInit"; + private static final String FALLBACK_TREATMENTS = "fallbackTreatments"; + private static final String FALLBACK_TREATMENTS_GLOBAL = "global"; + private static final String FALLBACK_TREATMENTS_BY_FLAG = "byFlag"; + private static final String FALLBACK_TREATMENT_VALUE = "treatment"; + private static final String FALLBACK_TREATMENT_CONFIG = "config"; /** * Creates a {@link SplitClientConfig} object from a map. @@ -262,6 +269,29 @@ static SplitClientConfig fromMap(@NonNull Map configurationMap, } } + Map fallbackTreatments = getObjectMap(configurationMap, FALLBACK_TREATMENTS); + if (fallbackTreatments != null) { + Map global = getObjectMap(fallbackTreatments, FALLBACK_TREATMENTS_GLOBAL); + Map byFlag = getObjectMap(fallbackTreatments, FALLBACK_TREATMENTS_BY_FLAG); + if (global != null || byFlag != null) { + FallbackTreatmentsConfiguration.Builder fallbackTreatmentsBuilder = FallbackTreatmentsConfiguration.builder(); + if (global != null) { + fallbackTreatmentsBuilder.global(new FallbackTreatment(getString(global, FALLBACK_TREATMENT_VALUE), getString(global, FALLBACK_TREATMENT_CONFIG))); + } + if (byFlag != null) { + Map byFlagMap = new HashMap<>(); + for (Map.Entry entry : byFlag.entrySet()) { + Map byFlagFallbackTreatment = getObjectMap(byFlag, entry.getKey()); + if (byFlagFallbackTreatment != null) { + byFlagMap.put(entry.getKey(), new FallbackTreatment(getString(byFlagFallbackTreatment, FALLBACK_TREATMENT_VALUE), getString(byFlagFallbackTreatment, FALLBACK_TREATMENT_CONFIG))); + } + } + fallbackTreatmentsBuilder.byFlag(byFlagMap); + } + builder.fallbackTreatments(fallbackTreatmentsBuilder.build()); + } + } + return builder.serviceEndpoints(serviceEndpointsBuilder.build()).build(); } diff --git a/splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java b/splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java index 23a5215..ebd20f6 100644 --- a/splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java +++ b/splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java @@ -27,6 +27,8 @@ import io.split.android.client.utils.logger.LogPrinter; import io.split.android.client.utils.logger.Logger; import io.split.android.client.utils.logger.SplitLogLevel; +import io.split.android.client.fallback.FallbackTreatmentsConfiguration; +import io.split.android.client.fallback.FallbackTreatment; public class SplitClientConfigHelperTest { @@ -235,4 +237,33 @@ public void rolloutCacheConfigurationValuesAreMappedCorrectly() { assertEquals(5, splitClientConfig.rolloutCacheConfiguration().getExpirationDays()); assertTrue(splitClientConfig.rolloutCacheConfiguration().isClearOnInit()); } + + @Test + public void fallbackTreatmentsValuesAreMappedCorrectly() { + Map globalFallbackTreatment = new HashMap<>(); + globalFallbackTreatment.put("treatment", "global-control"); + globalFallbackTreatment.put("config", "global-config"); + + Map feature1FallbackTreatment = new HashMap<>(); + feature1FallbackTreatment.put("treatment", "feature1-control"); + feature1FallbackTreatment.put("config", null); + + Map byFlagFallbackTreatments = new HashMap<>(); + byFlagFallbackTreatments.put("feature1", feature1FallbackTreatment); + + Map fallbackTreatmentsValues = new HashMap<>(); + fallbackTreatmentsValues.put("global", globalFallbackTreatment); + fallbackTreatmentsValues.put("byFlag", byFlagFallbackTreatments); + + Map configValues = new HashMap<>(); + configValues.put("fallbackTreatments", fallbackTreatmentsValues); + + SplitClientConfig splitClientConfig = SplitClientConfigHelper + .fromMap(configValues, mock(ImpressionListener.class)); + + FallbackTreatmentsConfiguration fallbackTreatmentsConfiguration = splitClientConfig.fallbackTreatments(); + + assertEquals(new FallbackTreatment("global-control", "global-config"), fallbackTreatmentsConfiguration.getGlobal()); + assertEquals(Map.of("feature1", new FallbackTreatment("feature1-control", null)), fallbackTreatmentsConfiguration.getByFlag()); + } } diff --git a/splitio_android/pubspec.yaml b/splitio_android/pubspec.yaml index fc2bbbe..772cc56 100644 --- a/splitio_android/pubspec.yaml +++ b/splitio_android/pubspec.yaml @@ -1,7 +1,7 @@ name: splitio_android description: The official Android implementation of splitio Flutter plugin. repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio_android -version: 1.0.0 +version: 1.1.0 environment: sdk: ">=2.16.2 <4.0.0" @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - splitio_platform_interface: ^2.0.0 + splitio_platform_interface: ^2.1.0 dev_dependencies: flutter_test: diff --git a/splitio_ios/CHANGELOG.md b/splitio_ios/CHANGELOG.md index d0935b9..6262687 100644 --- a/splitio_ios/CHANGELOG.md +++ b/splitio_ios/CHANGELOG.md @@ -1,5 +1,11 @@ +# 1.1.0 (Jan 28, 2026) +* Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs. +* Updated iOS SDK to `3.6.0`. + +# 1.1.0-rc.1 (Jan 28, 2026) + # 1.0.0 (Aug 14, 2025) -- iOS SDK to `3.3.2` +* Updated iOS SDK to `3.3.2` # 1.0.0-rc.1 (Aug 14, 2025) diff --git a/splitio_ios/analysis_options.yaml b/splitio_ios/analysis_options.yaml index a5744c1..5cf0db1 100644 --- a/splitio_ios/analysis_options.yaml +++ b/splitio_ios/analysis_options.yaml @@ -2,3 +2,7 @@ include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + +linter: + rules: + - public_member_api_docs diff --git a/splitio_ios/example/ios/Podfile.lock b/splitio_ios/example/ios/Podfile.lock index ea8a88c..5b23eda 100644 --- a/splitio_ios/example/ios/Podfile.lock +++ b/splitio_ios/example/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - Flutter (1.0.0) - - Split (3.3.2) - - splitio_ios (0.8.0): + - Split (3.6.0) + - splitio_ios (0.9.0): - Flutter - - Split (~> 3.3.2) + - Split (~> 3.6.0) DEPENDENCIES: - Flutter (from `Flutter`) @@ -20,10 +20,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/splitio_ios/ios" SPEC CHECKSUMS: - Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - Split: 0d4962a6c15180e1857c1a3753e1ae9c91a6150b - splitio_ios: 438ad21d0dfe467670f8b9508773b77b16a71d6b + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 + Split: 1e2176aacd6421029bea41413401389d86e3d50a + splitio_ios: ad4f484a6c478bf7285e417ea8252371f66b54ff -PODFILE CHECKSUM: aed42fc5c94ade572556b7ed357c5c57f1bd83a2 +PODFILE CHECKSUM: ba5baa820782b9e142d3ba97a6b84de9feaaceda COCOAPODS: 1.16.2 diff --git a/splitio_ios/example/ios/SplitTests/SplitClientConfigHelperTests.swift b/splitio_ios/example/ios/SplitTests/SplitClientConfigHelperTests.swift index 2c29a06..8475535 100644 --- a/splitio_ios/example/ios/SplitTests/SplitClientConfigHelperTests.swift +++ b/splitio_ios/example/ios/SplitTests/SplitClientConfigHelperTests.swift @@ -154,4 +154,29 @@ class SplitClientConfigHelperTests: XCTestCase { XCTAssertEqual(5, actualConfig.expirationDays) XCTAssertTrue(actualConfig.clearOnInit) } + + func testFallbackTreatmentsConfigurationValuesAreMappedCorrectly() { + let configValues = [ + "fallbackTreatments": [ + "global": [ + "treatment": "on", + "config": "{\"key\": \"value\"}" + ], + "byFlag": [ + "feature1": [ + "treatment": "off", + "config": nil + ] + ] + ] + ] + + let splitClientConfig: SplitClientConfig = SplitClientConfigHelper.fromMap(configurationMap: configValues, impressionListener: nil) + let actualConfig = splitClientConfig.fallbackTreatments + + XCTAssertEqual("on", actualConfig.global?.treatment) + XCTAssertEqual("{\"key\": \"value\"}", actualConfig.global?.config) + XCTAssertEqual("off", actualConfig.byFlag["feature1"]?.treatment) + XCTAssertNil(actualConfig.byFlag["feature1"]?.config) + } } diff --git a/splitio_ios/ios/Classes/SplitClientConfigHelper.swift b/splitio_ios/ios/Classes/SplitClientConfigHelper.swift index abe76d0..63c8d22 100644 --- a/splitio_ios/ios/Classes/SplitClientConfigHelper.swift +++ b/splitio_ios/ios/Classes/SplitClientConfigHelper.swift @@ -36,6 +36,11 @@ class SplitClientConfigHelper { static private let ROLLOUT_CACHE_CONFIGURATION = "rolloutCacheConfiguration" static private let ROLLOUT_CACHE_CONFIGURATION_EXPIRATION = "expirationDays" static private let ROLLOUT_CACHE_CONFIGURATION_CLEAR_ON_INIT = "clearOnInit" + static private let FALLBACK_TREATMENTS = "fallbackTreatments"; + static private let FALLBACK_TREATMENTS_GLOBAL = "global"; + static private let FALLBACK_TREATMENTS_BY_FLAG = "byFlag"; + static private let FALLBACK_TREATMENT_VALUE = "treatment"; + static private let FALLBACK_TREATMENT_CONFIG = "config"; static func fromMap(configurationMap: [String: Any?], impressionListener: SplitImpressionListener?) -> SplitClientConfig { let config = SplitClientConfig() @@ -253,6 +258,30 @@ class SplitClientConfigHelper { config.rolloutCacheConfiguration = rolloutCacheConfigurationBuilder.build() } + if let fallbackTreatmentConfig = configurationMap[FALLBACK_TREATMENTS] as? [String: Any?] { + let fallbackTreatmentConfiguration = FallbackTreatmentsConfig.builder() + + if let globalTreatment = fallbackTreatmentConfig[FALLBACK_TREATMENTS_GLOBAL] as? [String: Any?] { + fallbackTreatmentConfiguration.global(FallbackTreatment( + treatment: globalTreatment[FALLBACK_TREATMENT_VALUE] as! String, + config: globalTreatment[FALLBACK_TREATMENT_CONFIG] as? String + )) + } + + if let byFlagTreatments = fallbackTreatmentConfig[FALLBACK_TREATMENTS_BY_FLAG] as? [String: [String: Any?]] { + var byFlag: [String: FallbackTreatment] = [:] + for (key, value) in byFlagTreatments { + byFlag[key] = FallbackTreatment( + treatment: value[FALLBACK_TREATMENT_VALUE] as! String, + config: value[FALLBACK_TREATMENT_CONFIG] as? String + ) + } + fallbackTreatmentConfiguration.byFlag(byFlag) + } + + config.fallbackTreatments = fallbackTreatmentConfiguration.build() + } + return config } diff --git a/splitio_ios/ios/splitio_ios.podspec b/splitio_ios/ios/splitio_ios.podspec index bb24308..cdbf4e7 100644 --- a/splitio_ios/ios/splitio_ios.podspec +++ b/splitio_ios/ios/splitio_ios.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'splitio_ios' - s.version = '0.8.0' + s.version = '0.9.0' s.summary = 'split.io official Flutter plugin.' s.description = <<-DESC split.io official Flutter plugin. @@ -15,7 +15,7 @@ split.io official Flutter plugin. s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'Split', '~> 3.3.2' + s.dependency 'Split', '~> 3.6.0' s.platform = :ios, '9.0' # Flutter.framework does not contain a i386 slice. diff --git a/splitio_ios/pubspec.yaml b/splitio_ios/pubspec.yaml index 8c6637b..5035e48 100644 --- a/splitio_ios/pubspec.yaml +++ b/splitio_ios/pubspec.yaml @@ -1,7 +1,7 @@ name: splitio_ios description: The official iOS implementation of splitio Flutter plugin. repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio_ios -version: 1.0.0 +version: 1.1.0 environment: sdk: ">=2.16.2 <4.0.0" @@ -18,7 +18,7 @@ flutter: dependencies: flutter: sdk: flutter - splitio_platform_interface: ^2.0.0 + splitio_platform_interface: ^2.1.0 dev_dependencies: flutter_test: diff --git a/splitio_platform_interface/CHANGELOG.md b/splitio_platform_interface/CHANGELOG.md index cf67b5e..7088e82 100644 --- a/splitio_platform_interface/CHANGELOG.md +++ b/splitio_platform_interface/CHANGELOG.md @@ -1,3 +1,8 @@ +# 2.1.0 (Jan 28, 2026) +* Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs. + +# 2.1.0-rc.1 (Jan 28, 2026) + # 2.0.0 (Aug 14, 2025) # 2.0.0-rc.1 (Aug 14, 2025) diff --git a/splitio_platform_interface/analysis_options.yaml b/splitio_platform_interface/analysis_options.yaml index a5744c1..5cf0db1 100644 --- a/splitio_platform_interface/analysis_options.yaml +++ b/splitio_platform_interface/analysis_options.yaml @@ -2,3 +2,7 @@ include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + +linter: + rules: + - public_member_api_docs diff --git a/splitio_platform_interface/lib/events/split_method_call_handler.dart b/splitio_platform_interface/lib/events/split_method_call_handler.dart index 6a0db02..4c58431 100644 --- a/splitio_platform_interface/lib/events/split_method_call_handler.dart +++ b/splitio_platform_interface/lib/events/split_method_call_handler.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:splitio_platform_interface/method_call_handler.dart'; +/// Handler for Split SDK events class SplitEventMethodCallHandler implements MethodCallHandler { static const String _eventClientReady = 'clientReady'; static const String _eventClientReadyFromCache = 'clientReadyFromCache'; @@ -24,6 +25,7 @@ class SplitEventMethodCallHandler implements MethodCallHandler { _eventClientTimeout: false, }; + /// Creates a new instance of the Split event method call handler. SplitEventMethodCallHandler(this._matchingKey, this._bucketingKey); @override @@ -48,26 +50,32 @@ class SplitEventMethodCallHandler implements MethodCallHandler { } } + /// Returns Future that is completed when the SDK client is ready. Future onReady() { return _onEvent(_eventClientReady); } + /// Returns Future that is completed when the SDK client is ready from cache. Future onReadyFromCache() { return _onEvent(_eventClientReadyFromCache); } + /// Returns Stream that emits when the SDK client is updated. Stream onUpdated() { return _updateStreamCompleter.stream; } + /// Returns Future that is completed when the SDK client times out. Future onTimeout() { return _onEvent(_eventClientTimeout); } + /// Cleans up resources. void destroy() { _updateStreamCompleter.close(); } + /// Returns Future that is completed when the specified SDK event occurs. Future _onEvent(String sdkEvent) { if (_triggeredClientEvents.containsKey(sdkEvent) && _triggeredClientEvents[sdkEvent] == true) { diff --git a/splitio_platform_interface/lib/impressions/impressions_method_call_handler.dart b/splitio_platform_interface/lib/impressions/impressions_method_call_handler.dart index ea4e4a4..c68e8fd 100644 --- a/splitio_platform_interface/lib/impressions/impressions_method_call_handler.dart +++ b/splitio_platform_interface/lib/impressions/impressions_method_call_handler.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:splitio_platform_interface/method_call_handler.dart'; import 'package:splitio_platform_interface/split_impression.dart'; +/// Handles impressions method calls. class ImpressionsMethodCallHandler extends StreamMethodCallHandler { final _streamController = StreamController(); diff --git a/splitio_platform_interface/lib/method_call_handler.dart b/splitio_platform_interface/lib/method_call_handler.dart index 6ef88ac..3a28da6 100644 --- a/splitio_platform_interface/lib/method_call_handler.dart +++ b/splitio_platform_interface/lib/method_call_handler.dart @@ -1,7 +1,11 @@ +/// Abstract class for handling method calls. abstract class MethodCallHandler { + /// Handles a method call with the given method name and arguments. Future handle(String methodName, dynamic methodArguments); } +/// Abstract class for handling stream method calls. abstract class StreamMethodCallHandler extends MethodCallHandler { + /// Returns a stream of the given type. Stream stream(); } diff --git a/splitio_platform_interface/lib/method_channel_platform.dart b/splitio_platform_interface/lib/method_channel_platform.dart index aaf0b2c..0d66439 100644 --- a/splitio_platform_interface/lib/method_channel_platform.dart +++ b/splitio_platform_interface/lib/method_channel_platform.dart @@ -6,7 +6,9 @@ const String _controlTreatment = 'control'; const SplitResult _controlResult = SplitResult(_controlTreatment, null); const MethodChannel _methodChannel = MethodChannel('splitio'); +/// Method channel platform implementation. class MethodChannelPlatform extends SplitioPlatform { + /// Returns the method channel. MethodChannel get methodChannel => _methodChannel; final Map _handlers = {}; @@ -15,6 +17,8 @@ class MethodChannelPlatform extends SplitioPlatform { ImpressionsMethodCallHandler(); @visibleForTesting + + /// Handles method calls from the platform. Future handle(MethodCall call) async { _impressionsMethodCallHandler.handle(call.method, call.arguments); for (MethodCallHandler handler in _handlers.values) { diff --git a/splitio_platform_interface/lib/split_certificate_pinning_configuration.dart b/splitio_platform_interface/lib/split_certificate_pinning_configuration.dart index 78b9a0b..0c9f839 100644 --- a/splitio_platform_interface/lib/split_certificate_pinning_configuration.dart +++ b/splitio_platform_interface/lib/split_certificate_pinning_configuration.dart @@ -1,9 +1,11 @@ +/// Certificate pinning configuration. class CertificatePinningConfiguration { - final Map> _pins = {}; + /// Returns the pins. Map> get pins => _pins; + /// Adds a pin for the given host. CertificatePinningConfiguration addPin(String host, String pin) { pin = pin.trim(); if (pin.isEmpty) { @@ -17,4 +19,4 @@ class CertificatePinningConfiguration { _pins[host]?.add(pin); return this; } -} \ No newline at end of file +} diff --git a/splitio_platform_interface/lib/split_configuration.dart b/splitio_platform_interface/lib/split_configuration.dart index 1d54fdd..90ce1be 100644 --- a/splitio_platform_interface/lib/split_configuration.dart +++ b/splitio_platform_interface/lib/split_configuration.dart @@ -1,8 +1,11 @@ import 'package:splitio_platform_interface/split_certificate_pinning_configuration.dart'; +import 'package:splitio_platform_interface/split_fallback_treatments_configuration.dart'; import 'package:splitio_platform_interface/split_sync_config.dart'; import 'package:splitio_platform_interface/split_rollout_cache_configuration.dart'; +/// Split configuration. class SplitConfiguration { + /// The configuration map. final Map configurationMap = {}; /// Initializes the Split configuration. @@ -48,6 +51,10 @@ class SplitConfiguration { /// [readyTimeout] Maximum amount of time in seconds to wait before firing the SDK_READY_TIMED_OUT event. Defaults to 10 seconds. /// /// [certificatePinningConfiguration] Certificate pinning configuration. Pins need to have the format of a base64 SHA-256 or base64 SHA-1 hashes of the SPKI (ex.: "sha256/7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y="). Not supported in Web. + /// + /// [rolloutCacheConfiguration] Rollout cache configuration. + /// + /// [fallbackTreatments] Fallback treatments configuration. SplitConfiguration({ int? featuresRefreshRate, int? segmentsRefreshRate, @@ -76,6 +83,7 @@ class SplitConfiguration { int? readyTimeout = 10, CertificatePinningConfiguration? certificatePinningConfiguration, RolloutCacheConfiguration? rolloutCacheConfiguration, + FallbackTreatmentsConfiguration? fallbackTreatments, }) { if (featuresRefreshRate != null) { configurationMap['featuresRefreshRate'] = featuresRefreshRate; @@ -195,19 +203,59 @@ class SplitConfiguration { 'clearOnInit': rolloutCacheConfiguration.clearOnInit }; } + + if (fallbackTreatments != null) { + configurationMap['fallbackTreatments'] = { + 'global': fallbackTreatments.global, + 'byFlag': fallbackTreatments.byFlag + }; + } } } +/// Impressions mode. enum ImpressionsMode { + /// Debug impressions mode. debug, + + /// Optimized impressions mode. optimized, + + /// None impressions mode. none, } +/// User consent. enum UserConsent { + /// The user grants consent for tracking events and impressions. The SDK sends them to Split cloud. granted, + + /// The user declines consent for tracking events and impressions. The SDK does not send them to Split cloud. declined, + + /// The user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its + /// internal storage, and eventually either sends them or not if the consent status is updated to 'GRANTED' or + /// 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method. unknown, } -enum SplitLogLevel { verbose, debug, info, warning, error, none } +/// Split log level. +enum SplitLogLevel { + /// Verbose log level. + verbose, + + /// Debug log level. + debug, + + /// Info log level. + info, + + /// Warning log level. + warning, + + /// Error log level. + error, + + /// None log level. + none +} diff --git a/splitio_platform_interface/lib/split_evaluation_options.dart b/splitio_platform_interface/lib/split_evaluation_options.dart index 2a603a8..9986514 100644 --- a/splitio_platform_interface/lib/split_evaluation_options.dart +++ b/splitio_platform_interface/lib/split_evaluation_options.dart @@ -1,17 +1,22 @@ import 'dart:collection'; +/// Options for evaluation. class EvaluationOptions { final Map _properties; + /// Impression properties. Map get properties => UnmodifiableMapView(_properties); + /// Creates a new EvaluationOptions instance. const EvaluationOptions.empty() : _properties = const {}; + /// Creates a new EvaluationOptions instance. factory EvaluationOptions([Map properties = const {}]) { return EvaluationOptions._( Map.unmodifiable(Map.from(properties))); } + /// Converts the EvaluationOptions to a JSON map. Map toJson() => { 'properties': _properties, }; diff --git a/splitio_platform_interface/lib/split_fallback_treatment.dart b/splitio_platform_interface/lib/split_fallback_treatment.dart new file mode 100644 index 0000000..bca1dc5 --- /dev/null +++ b/splitio_platform_interface/lib/split_fallback_treatment.dart @@ -0,0 +1,11 @@ +/// Fallback treatment for when the feature flag cannot be evaluated. +class FallbackTreatment { + /// The treatment value. + final String treatment; + + /// The treatment configuration. + final String? config; + + /// Creates a new FallbackTreatment instance. + const FallbackTreatment(this.treatment, [this.config]); +} diff --git a/splitio_platform_interface/lib/split_fallback_treatments_configuration.dart b/splitio_platform_interface/lib/split_fallback_treatments_configuration.dart new file mode 100644 index 0000000..3281ae5 --- /dev/null +++ b/splitio_platform_interface/lib/split_fallback_treatments_configuration.dart @@ -0,0 +1,23 @@ +import 'package:splitio_platform_interface/split_fallback_treatment.dart'; + +/// Configuration for fallback treatments. +class FallbackTreatmentsConfiguration { + Map? _global; + Map>? _byFlag; + + /// Global fallback treatment. + Map? get global => _global; + + /// Fallback treatments by flag. + Map>? get byFlag => _byFlag; + + /// Creates a new FallbackTreatmentsConfiguration instance. + FallbackTreatmentsConfiguration( + {FallbackTreatment? global, Map? byFlag}) { + _global = global != null + ? {'treatment': global.treatment, 'config': global.config} + : null; + _byFlag = byFlag?.map((key, value) => + MapEntry(key, {'treatment': value.treatment, 'config': value.config})); + } +} diff --git a/splitio_platform_interface/lib/split_impression.dart b/splitio_platform_interface/lib/split_impression.dart index 3bfdf4e..de7c15b 100644 --- a/splitio_platform_interface/lib/split_impression.dart +++ b/splitio_platform_interface/lib/split_impression.dart @@ -1,23 +1,41 @@ +/// Represents an impression when a feature flag is evaluated. class Impression { + /// The traffic matching key. final String? key; + + /// The traffic bucketing key. final String? bucketingKey; + + /// The name of the feature flag. final String? split; + + /// The treatment value. final String? treatment; + + /// The impression timestamp. final num? time; + + /// The rule label. final String? appliedRule; + + /// The version of the feature flag. final num? changeNumber; + + /// The attributes. final Map attributes; + + /// The impression properties. final Map? properties; + /// Creates a new Impression instance. Impression(this.key, this.bucketingKey, this.split, this.treatment, this.time, this.appliedRule, this.changeNumber, this.attributes, this.properties); + /// Creates a new Impression instance from a map. static Impression fromMap(Map map) { - var properties = null; + Map? properties; if (map['properties'] != null) { properties = Map.from(map['properties'] as Map); - } else { - properties = null; } return Impression( map['key'] as String?, diff --git a/splitio_platform_interface/lib/split_prerequisite.dart b/splitio_platform_interface/lib/split_prerequisite.dart index b8be081..02e47df 100644 --- a/splitio_platform_interface/lib/split_prerequisite.dart +++ b/splitio_platform_interface/lib/split_prerequisite.dart @@ -1,15 +1,20 @@ +/// Prerequisite class. class Prerequisite { final String _name; final Set _treatments; + /// The feature flag name of the prerequisite. String get name => _name; + /// The treatments of the prerequisite. Set get treatments => _treatments; + /// Creates a new Prerequisite instance. Prerequisite(this._name, this._treatments); - static Prerequisite fromEntry(el) { + /// Creates a Prerequisite instance from a map. + static Prerequisite fromEntry(Map el) { final String name = (el['n'] ?? el['n:'] ?? '').toString(); final List rawTreatments = (el['t'] as List?) ?? []; final Set treatments = @@ -26,7 +31,8 @@ class Prerequisite { }'''; } - equals(Prerequisite other) { + /// Checks if this Prerequisite is equal to another Prerequisite. + bool equals(Prerequisite other) { return name == other.name && treatments == other.treatments; } diff --git a/splitio_platform_interface/lib/split_result.dart b/splitio_platform_interface/lib/split_result.dart index f1c0896..fe6c4fc 100644 --- a/splitio_platform_interface/lib/split_result.dart +++ b/splitio_platform_interface/lib/split_result.dart @@ -4,9 +4,13 @@ /// /// The [config] contains the configuration for the split, if any. May be null. class SplitResult { + /// The treatment of the split. final String treatment; + + /// The configuration of the split, if any. May be null. final String? config; + /// Creates a new SplitResult instance. const SplitResult(this.treatment, this.config); @override diff --git a/splitio_platform_interface/lib/split_rollout_cache_configuration.dart b/splitio_platform_interface/lib/split_rollout_cache_configuration.dart index 9c2b0f3..340bc5d 100644 --- a/splitio_platform_interface/lib/split_rollout_cache_configuration.dart +++ b/splitio_platform_interface/lib/split_rollout_cache_configuration.dart @@ -1,12 +1,17 @@ +/// Rollout cache configuration class. class RolloutCacheConfiguration { - late int _expirationDays; late bool _clearOnInit; + /// The expiration days of the cache. int get expirationDays => _expirationDays; + + /// Whether to clear the cache on initialization. bool get clearOnInit => _clearOnInit; - RolloutCacheConfiguration({int expirationDays = 10, bool clearOnInit = false}) { + /// Creates a new RolloutCacheConfiguration instance. + RolloutCacheConfiguration( + {int expirationDays = 10, bool clearOnInit = false}) { if (expirationDays < 1) { expirationDays = 10; } diff --git a/splitio_platform_interface/lib/split_sync_config.dart b/splitio_platform_interface/lib/split_sync_config.dart index bc47f8d..1b0ed05 100644 --- a/splitio_platform_interface/lib/split_sync_config.dart +++ b/splitio_platform_interface/lib/split_sync_config.dart @@ -1,14 +1,19 @@ +/// Sync configuration class for controlling which feature flags to fetch. class SyncConfig { late Set _names; late Set _prefixes; late Set _sets; + /// Names of the feature flags to fetch. Set get names => _names; + /// Prefixes of the feature flags to fetch. Set get prefixes => _prefixes; + /// Flag sets of the feature flags to fetch. Set get sets => _sets; + /// Creates a new SyncConfig instance passing an optional list of names and prefixes. SyncConfig( {List names = const [], List prefixes = const []}) { _names = names.toSet(); @@ -16,12 +21,14 @@ class SyncConfig { _sets = {}; } + /// Creates a new SyncConfig instance passing an optional set of names and prefixes. SyncConfig.fromSet( {Set names = const {}, Set prefixes = const {}}) { _names = names; _prefixes = prefixes; } + /// Creates a new SyncConfig instance passing a list of flag sets. SyncConfig.flagSets(List sets) { _sets = sets.toSet(); _names = {}; diff --git a/splitio_platform_interface/lib/split_view.dart b/splitio_platform_interface/lib/split_view.dart index 8908cf6..b4a2244 100644 --- a/splitio_platform_interface/lib/split_view.dart +++ b/splitio_platform_interface/lib/split_view.dart @@ -2,6 +2,7 @@ import 'dart:core'; import 'package:splitio_platform_interface/split_prerequisite.dart'; +/// Represents a feature flag class SplitView { static const String _keyName = 'name'; static const String _keyTrafficType = 'trafficType'; @@ -14,17 +15,37 @@ class SplitView { static const String _keyImpressionsDisabled = 'impressionsDisabled'; static const String _keyPrerequisites = 'prerequisites'; + /// The name of the feature flag. String name; + + /// The traffic type of the feature flag. String trafficType; + + /// Whether the feature flag is killed. bool killed = false; + + /// The treatments of the feature flag. List treatments = []; + + /// The change number of the feature flag. int? changeNumber; + + /// The configurations per treatment of the feature flag. Map configs = {}; + + /// The default treatment of the feature flag. String defaultTreatment; + + /// The sets of the feature flag. List sets = []; + + /// Whether impressions are disabled for the feature flag. bool impressionsDisabled = false; + + /// The prerequisites of the feature flag. Set prerequisites = {}; + /// Creates a new SplitView instance. SplitView(this.name, this.trafficType, this.killed, this.treatments, this.changeNumber, this.configs, [this.defaultTreatment = '', @@ -32,6 +53,7 @@ class SplitView { this.impressionsDisabled = false, this.prerequisites = const {}]); + /// Creates a SplitView instance from a map entry. static SplitView? fromEntry(Map? entry) { if (entry == null || entry.isEmpty) { return null; diff --git a/splitio_platform_interface/lib/splitio_platform_interface.dart b/splitio_platform_interface/lib/splitio_platform_interface.dart index 247c3a2..435c1a2 100644 --- a/splitio_platform_interface/lib/splitio_platform_interface.dart +++ b/splitio_platform_interface/lib/splitio_platform_interface.dart @@ -222,12 +222,14 @@ abstract class _ClientPlatform { /// [SplitioPlatform] methods. abstract class SplitioPlatform extends PlatformInterface with _FactoryPlatform, _ClientPlatform { + /// Creates a new SplitioPlatform instance. SplitioPlatform() : super(token: _token); static SplitioPlatform _instance = MethodChannelPlatform(); static final Object _token = Object(); + /// The instance of SplitioPlatform that is used to communicate with the native platform. static SplitioPlatform get instance => _instance; /// Platform-specific plugins should set this with their own platform-specific diff --git a/splitio_platform_interface/pubspec.yaml b/splitio_platform_interface/pubspec.yaml index 6b2a0e1..411ef85 100644 --- a/splitio_platform_interface/pubspec.yaml +++ b/splitio_platform_interface/pubspec.yaml @@ -2,7 +2,7 @@ name: splitio_platform_interface description: A common platform interface for the splitio plugin. # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.0.0 +version: 2.1.0 repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio_platform_interface environment: diff --git a/splitio_platform_interface/test/split_fallback_treatments_configuration_test.dart b/splitio_platform_interface/test/split_fallback_treatments_configuration_test.dart new file mode 100644 index 0000000..2dd3990 --- /dev/null +++ b/splitio_platform_interface/test/split_fallback_treatments_configuration_test.dart @@ -0,0 +1,39 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:splitio_platform_interface/split_fallback_treatment.dart'; +import 'package:splitio_platform_interface/split_fallback_treatments_configuration.dart'; + +void main() { + test('global and by flag fallback treatments', () { + var config = FallbackTreatmentsConfiguration( + global: const FallbackTreatment('custom-treatment')); + + expect(config.global, + equals({'treatment': 'custom-treatment', 'config': null})); + expect(config.byFlag, null); + + config = FallbackTreatmentsConfiguration(byFlag: { + 'flag1': const FallbackTreatment('custom-treatment-1', 'custom-config-1'), + 'flag2': const FallbackTreatment('custom-treatment-2', 'custom-config-2') + }); + expect( + config.byFlag, + equals({ + 'flag1': { + 'treatment': 'custom-treatment-1', + 'config': 'custom-config-1' + }, + 'flag2': { + 'treatment': 'custom-treatment-2', + 'config': 'custom-config-2' + } + })); + expect(config.global, null); + }); + + test('default values', () { + var config = FallbackTreatmentsConfiguration(); + + expect(config.global, null); + expect(config.byFlag, null); + }); +} diff --git a/splitio_platform_interface/test/splitio_configuration_test.dart b/splitio_platform_interface/test/splitio_configuration_test.dart index 64b758c..c627edb 100644 --- a/splitio_platform_interface/test/splitio_configuration_test.dart +++ b/splitio_platform_interface/test/splitio_configuration_test.dart @@ -1,6 +1,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:splitio_platform_interface/split_certificate_pinning_configuration.dart'; import 'package:splitio_platform_interface/split_configuration.dart'; +import 'package:splitio_platform_interface/split_fallback_treatment.dart'; +import 'package:splitio_platform_interface/split_fallback_treatments_configuration.dart'; import 'package:splitio_platform_interface/split_rollout_cache_configuration.dart'; import 'package:splitio_platform_interface/split_sync_config.dart'; @@ -36,7 +38,16 @@ void main() { .addPin('host1', 'pin1') .addPin('host2', 'pin3') .addPin('host1', 'pin2'), - rolloutCacheConfiguration: RolloutCacheConfiguration(expirationDays: 15, clearOnInit: true)); + rolloutCacheConfiguration: + RolloutCacheConfiguration(expirationDays: 15, clearOnInit: true), + fallbackTreatments: FallbackTreatmentsConfiguration( + global: const FallbackTreatment('custom-treatment'), + byFlag: { + 'flag1': const FallbackTreatment( + 'custom-treatment-flag1', 'config-flag1'), + 'flag2': const FallbackTreatment('custom-treatment-flag2'), + }, + )); expect(config.configurationMap['eventFlushInterval'], 2000); expect(config.configurationMap['eventsPerPush'], 300); @@ -73,8 +84,22 @@ void main() { 'host1': ['pin1', 'pin2'], 'host2': ['pin3'] }); - expect(config.configurationMap['rolloutCacheConfiguration']['expirationDays'], 15); - expect(config.configurationMap['rolloutCacheConfiguration']['clearOnInit'], true); + expect( + config.configurationMap['rolloutCacheConfiguration']['expirationDays'], + 15); + expect(config.configurationMap['rolloutCacheConfiguration']['clearOnInit'], + true); + expect(config.configurationMap['fallbackTreatments']['global'], + equals({'treatment': 'custom-treatment', 'config': null})); + expect( + config.configurationMap['fallbackTreatments']['byFlag'], + equals({ + 'flag1': { + 'treatment': 'custom-treatment-flag1', + 'config': 'config-flag1' + }, + 'flag2': {'treatment': 'custom-treatment-flag2', 'config': null} + })); }); test('no special values leaves map empty', () async { diff --git a/splitio_web/CHANGELOG.md b/splitio_web/CHANGELOG.md index a1985a7..1ef2281 100644 --- a/splitio_web/CHANGELOG.md +++ b/splitio_web/CHANGELOG.md @@ -1,4 +1,15 @@ -# 1.0.0 (January 16, 2026) -- Initial release. Web implementation of `splitio` based on Split Browser SDK v1.6.0. +# 1.1.1 (Jan 28, 2026) +* Bug fix: corrected asset path for loading the Browser SDK. -# 1.0.0-rc.1 (January 15, 2026) +# 1.1.1-rc.1 (Jan 28, 2026) + +# 1.1.0 (Jan 28, 2026) +* Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs. +* Updated Browser SDK to `1.6.1`. + +# 1.1.0-rc.1 (Jan 28, 2026) + +# 1.0.0 (Jan 16, 2026) +* Initial release. Web implementation of `splitio` based on Split Browser SDK `1.6.0`. + +# 1.0.0-rc.1 (Jan 15, 2026) diff --git a/splitio_web/analysis_options.yaml b/splitio_web/analysis_options.yaml index a5744c1..5cf0db1 100644 --- a/splitio_web/analysis_options.yaml +++ b/splitio_web/analysis_options.yaml @@ -2,3 +2,7 @@ include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + +linter: + rules: + - public_member_api_docs diff --git a/splitio_web/lib/splitio_web.dart b/splitio_web/lib/splitio_web.dart index 6a0102f..0e77822 100644 --- a/splitio_web/lib/splitio_web.dart +++ b/splitio_web/lib/splitio_web.dart @@ -91,7 +91,7 @@ class SplitioWeb extends SplitioPlatform { final script = document.createElement('script') as HTMLScriptElement; script.type = 'text/javascript'; script.src = - 'assets/packages/splitio_web/web/split-browser-1.6.0.full.min.js'; + 'assets/packages/splitio_web/web/split-browser.full.min.js'; // Wait for script to load final completer = Completer(); @@ -321,6 +321,12 @@ class SplitioWeb extends SplitioPlatform { config.impressionListener = impressionListener; } + + if (configuration.configurationMap['fallbackTreatments'] != null) { + final fallbackTreatments = configuration.configurationMap['fallbackTreatments'] as Map; + // FallbackTreatmentsConfiguration has a compatible structure with JSFallbackTreatmentsConfiguration + config.fallbackTreatments = fallbackTreatments.jsify() as JSFallbackTreatmentsConfiguration; + } } return config; diff --git a/splitio_web/lib/src/js_interop.dart b/splitio_web/lib/src/js_interop.dart index df58d6e..42bf8d1 100644 --- a/splitio_web/lib/src/js_interop.dart +++ b/splitio_web/lib/src/js_interop.dart @@ -3,6 +3,7 @@ import 'package:splitio_platform_interface/splitio_platform_interface.dart'; // JS SDK types +/// SplitIO.ImpressionDTO @JS() extension type JSImpressionDTO._(JSObject _) implements JSObject { external JSString feature; @@ -16,6 +17,7 @@ extension type JSImpressionDTO._(JSObject _) implements JSObject { external JSString? properties; } +/// SplitIO.ImpressionData @JS() extension type JSImpressionData._(JSObject _) implements JSObject { external JSImpressionDTO impression; @@ -25,30 +27,43 @@ extension type JSImpressionData._(JSObject _) implements JSObject { external JSString sdkLanguageVersion; } +/// SplitIO.ILogger @JS() extension type JSILogger._(JSObject _) implements JSObject { + /// Log a debug level message external JSAny? debug(JSString message); + + /// Log an info level message external JSAny? info(JSString message); + + /// Log a warning level message external JSAny? warn(JSString message); + + /// Log an error level message external JSAny? error(JSString message); } +/// SplitIO.IImpressionListener @JS() extension type JSImpressionListener._(JSObject _) implements JSObject { + /// Log an impression external JSVoid logImpression(JSImpressionData impression); } +/// SplitIO.IClientSideSettings['core'] @JS() extension type JSConfigurationCore._(JSObject _) implements JSObject { external JSString authorizationKey; external JSAny key; // string | SplitKey } +/// SplitIO.IClientSideSettings['startup'] @JS() extension type JSConfigurationStartup._(JSObject _) implements JSObject { external JSNumber? readyTimeout; } +/// SplitIO.IClientSideSettings['scheduler'] @JS() extension type JSConfigurationScheduler._(JSObject _) implements JSObject { external JSNumber? featuresRefreshRate; @@ -61,6 +76,7 @@ extension type JSConfigurationScheduler._(JSObject _) implements JSObject { external JSNumber? eventsPushRate; } +/// SplitIO.IClientSideSettings['urls'] @JS() extension type JSConfigurationUrls._(JSObject _) implements JSObject { external JSString? sdk; @@ -70,12 +86,14 @@ extension type JSConfigurationUrls._(JSObject _) implements JSObject { external JSString? telemetry; } +/// SplitIO.IClientSideSettings['sync']['splitFilters'] @JS() extension type JSSplitFilter._(JSObject _) implements JSObject { external JSString type; external JSArray values; } +/// SplitIO.IClientSideSettings['sync'] @JS() extension type JSConfigurationSync._(JSObject _) implements JSObject { external JSString? impressionsMode; @@ -83,6 +101,7 @@ extension type JSConfigurationSync._(JSObject _) implements JSObject { external JSArray? splitFilters; } +/// SplitIO.IClientSideSettings['storage'] @JS() extension type JSConfigurationStorage._(JSObject _) implements JSObject { external JSString? type; @@ -90,6 +109,15 @@ extension type JSConfigurationStorage._(JSObject _) implements JSObject { external JSBoolean? clearOnInit; } +/// SplitIO.IClientSideSettings['fallbackTreatments'] +@JS() +extension type JSFallbackTreatmentsConfiguration._(JSObject _) + implements JSObject { + external JSTreatmentWithConfig? global; + external JSObject? byFlag; +} + +/// SplitIO.IClientSideSettings @JS() extension type JSConfiguration._(JSObject _) implements JSObject { external JSConfigurationCore core; @@ -102,20 +130,27 @@ extension type JSConfiguration._(JSObject _) implements JSObject { external JSImpressionListener? impressionListener; external JSAny? debug; external JSAny? storage; + external JSFallbackTreatmentsConfiguration? fallbackTreatments; } +/// SplitIO.ISettings @JS() extension type JSISettings._(JSObject _) implements JSConfiguration { external JSILogger log; external JSImpressionListener? impressionListener; } +/// SplitIO.IUserConsentAPI @JS() extension type JSIUserConsentAPI._(JSObject _) implements JSObject { + /// SplitIO.IUserConsentAPI['setStatus'] external JSBoolean setStatus(JSBoolean userConsent); + + /// SplitIO.IUserConsentAPI['getStatus'] external JSString getStatus(); } +/// SplitIO.EventConsts @JS() extension type JSEventConsts._(JSObject _) implements JSObject { // ignore: non_constant_identifier_names @@ -128,6 +163,7 @@ extension type JSEventConsts._(JSObject _) implements JSObject { external JSString SDK_UPDATE; } +/// SplitIO.ReadinessStatus @JS() extension type JSReadinessStatus._(JSObject _) implements JSObject { external JSBoolean isReady; @@ -135,18 +171,21 @@ extension type JSReadinessStatus._(JSObject _) implements JSObject { external JSBoolean hasTimedout; } +/// SplitIO.TreatmentWithConfig @JS() extension type JSTreatmentWithConfig._(JSObject _) implements JSObject { external JSString treatment; external JSString? config; } +/// SplitIO.SplitView['prerequisites'] @JS() extension type JSPrerequisite._(JSObject _) implements JSObject { external JSString flagName; external JSArray treatments; } +/// SplitIO.SplitView @JS() extension type JSSplitView._(JSObject _) implements JSObject { external JSString name; @@ -161,73 +200,132 @@ extension type JSSplitView._(JSObject _) implements JSObject { external JSArray prerequisites; } +/// SplitIO.EvaluationOptions @JS() extension type JSEvaluationOptions._(JSObject _) implements JSObject { external JSObject properties; } +/// SplitIO.IBrowserClient @JS() extension type JSIBrowserClient._(JSObject _) implements JSObject { + /// SplitIO.IBrowserClient['getTreatment'] external JSString getTreatment(JSString flagName, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatments'] external JSObject getTreatments(JSArray flagNames, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatmentWithConfig'] external JSTreatmentWithConfig getTreatmentWithConfig(JSString flagName, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatmentsWithConfig'] external JSObject getTreatmentsWithConfig(JSArray flagNames, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatmentsByFlagSet'] external JSObject getTreatmentsByFlagSet(JSString flagSetName, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatmentsByFlagSets'] external JSObject getTreatmentsByFlagSets(JSArray flagSetNames, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatmentsWithConfigByFlagSet'] external JSObject getTreatmentsWithConfigByFlagSet(JSString flagSetName, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['getTreatmentsWithConfigByFlagSets'] external JSObject getTreatmentsWithConfigByFlagSets( JSArray flagSetNames, JSObject attributes, JSEvaluationOptions evaluationOptions); + + /// SplitIO.IBrowserClient['track'] external JSBoolean track(JSString? trafficType, JSString eventType, JSNumber? value, JSObject? attributes); + + /// SplitIO.IBrowserClient['setAttribute'] external JSBoolean setAttribute( JSString attributeName, JSAny? attributeValue); + + /// SplitIO.IBrowserClient['getAttribute'] external JSAny getAttribute(JSString attributeName); + + /// SplitIO.IBrowserClient['removeAttribute'] external JSBoolean removeAttribute(JSString attributeName); + + /// SplitIO.IBrowserClient['setAttributes'] external JSBoolean setAttributes(JSObject attributes); + + /// SplitIO.IBrowserClient['getAttributes'] external JSObject getAttributes(); + + /// SplitIO.IBrowserClient['clearAttributes'] external JSBoolean clearAttributes(); + + /// SplitIO.IBrowserClient['flush'] external JSPromise flush(); + + /// SplitIO.IBrowserClient['destroy'] external JSPromise destroy(); + + /// SplitIO.IBrowserClient['on'] external JSVoid on(JSString event, JSFunction listener); + + /// SplitIO.IBrowserClient['off'] external JSVoid off(JSString event, JSFunction listener); + + /// SplitIO.IBrowserClient['emit'] external JSVoid emit(JSString event); // ignore: non_constant_identifier_names external JSEventConsts Event; + + /// SplitIO.IBrowserClient['getStatus'] external JSReadinessStatus getStatus(); } +/// SplitIO.IManager @JS() extension type JSIManager._(JSObject _) implements JSObject { + /// SplitIO.IManager['names'] external JSArray names(); + + /// SplitIO.IManager['split'] external JSSplitView? split(JSString name); + + /// SplitIO.IManager['splits'] external JSArray splits(); } +/// SplitIO.IBrowserSDK @JS() extension type JSIBrowserSDK._(JSObject _) implements JSObject { + /// SplitIO.IBrowserSDK['client'] external JSIBrowserClient client(JSAny? key); + + /// SplitIO.IBrowserSDK['manager'] external JSIManager manager(); + + /// SplitIO.IBrowserSDK['settings'] external JSISettings settings; // ignore: non_constant_identifier_names external JSIUserConsentAPI UserConsent; } +/// SplitIO.LoggerFactory @JS() extension type JSLoggerFactory._(JSFunction _) implements JSFunction { + /// A callable function external JSObject call(); } +/// Type of the `window.splitio` object @JS() extension type JSBrowserSDKPackage._(JSObject _) implements JSObject { + /// Browser SDK factory constructor // ignore: non_constant_identifier_names external JSIBrowserSDK SplitFactory(JSConfiguration config); // ignore: non_constant_identifier_names @@ -244,41 +342,52 @@ extension type JSBrowserSDKPackage._(JSObject _) implements JSObject { // Conversion utils: JS to Dart types +/// Get the keys of a JavaScript object @JS('Object.keys') external JSArray objectKeys(JSObject obj); +/// Get a property from a JavaScript object @JS('Reflect.get') external JSAny? reflectGet(JSObject target, JSString propertyKey); +/// Set a property on a JavaScript object @JS('Reflect.set') external JSAny? reflectSet(JSObject target, JSString propertyKey, JSAny? value); +/// Parse a JSON string into a JavaScript object @JS('JSON.parse') external JSObject jsonParse(JSString obj); +/// Convert a JavaScript array to a Dart list List jsArrayToList(JSArray obj) => (obj.dartify() as List).cast(); +/// Convert a JavaScript object to a Dart map Map jsObjectToMap(JSObject obj) => (obj.dartify() as Map).cast(); +/// Convert a JavaScript value to a Dart value Object? jsAnyToDart(JSAny? value) => value.dartify(); // Conversion utils: JS SDK to Flutter SDK types +/// Convert a JavaScript SplitIO.Treatments object to a Dart map Map jsTreatmentsToMap(JSObject obj) { return jsObjectToMap(obj).map((k, v) => MapEntry(k, v as String)); } +/// Convert a JavaScript SplitIO.TreatmentsWithConfig object to a Dart map Map jsTreatmentsWithConfigToMap(JSObject obj) { return jsObjectToMap(obj).map((k, v) => MapEntry( k, SplitResult(v['treatment'] as String, v['config'] as String?))); } +/// Convert a JavaScript SplitIO.TreatmentWithConfig object to a Dart SplitResult SplitResult jsTreatmentWithConfigToSplitResult(JSTreatmentWithConfig obj) { return SplitResult(obj.treatment.toDart, obj.config?.toDart); } +/// Convert a JavaScript prerequisite object to a Dart Prerequisite Prerequisite jsPrerequisiteToPrerequisite(JSPrerequisite obj) { return Prerequisite( obj.flagName.toDart, @@ -286,6 +395,7 @@ Prerequisite jsPrerequisiteToPrerequisite(JSPrerequisite obj) { ); } +/// Convert a JavaScript SplitIO.SplitView object to a Dart SplitView SplitView jsSplitViewToSplitView(JSSplitView obj) { return SplitView( obj.name.toDart, @@ -300,6 +410,7 @@ SplitView jsSplitViewToSplitView(JSSplitView obj) { obj.prerequisites.toDart.map(jsPrerequisiteToPrerequisite).toSet()); } +/// Convert a JavaScript SplitIO.ImpressionData object to a Dart Impression Impression jsImpressionDataToImpression(JSImpressionData obj) { return Impression( obj.impression.keyName.toDart, @@ -316,6 +427,7 @@ Impression jsImpressionDataToImpression(JSImpressionData obj) { ); } +/// Build a JavaScript SplitIO.SplitKey object from a matching key and optional bucketing key JSAny buildJsKey(String matchingKey, String? bucketingKey) { if (bucketingKey != null) { return { @@ -326,6 +438,7 @@ JSAny buildJsKey(String matchingKey, String? bucketingKey) { return matchingKey.toJS; } +/// Build a string index from a matching key and optional bucketing key String buildKeyString(String matchingKey, String? bucketingKey) { return bucketingKey == null ? matchingKey : '${matchingKey}_$bucketingKey'; } diff --git a/splitio_web/pubspec.yaml b/splitio_web/pubspec.yaml index da52a6b..452b2d2 100644 --- a/splitio_web/pubspec.yaml +++ b/splitio_web/pubspec.yaml @@ -1,7 +1,7 @@ name: splitio_web description: The official Web implementation of splitio Flutter plugin. repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio_web -version: 1.0.0 +version: 1.1.1 environment: sdk: ">=3.3.0 <4.0.0" # using Dart 3.3+ extension types for JS interop @@ -15,12 +15,12 @@ flutter: pluginClass: SplitioWeb fileName: splitio_web.dart assets: - - web/split-browser-1.6.0.full.min.js + - web/split-browser.full.min.js dependencies: flutter: sdk: flutter - splitio_platform_interface: ^2.0.0 + splitio_platform_interface: ^2.1.0 flutter_web_plugins: sdk: flutter web: ">=0.5.0 <2.0.0" diff --git a/splitio_web/test/splitio_web_test.dart b/splitio_web/test/splitio_web_test.dart index 13c386e..44151c7 100644 --- a/splitio_web/test/splitio_web_test.dart +++ b/splitio_web/test/splitio_web_test.dart @@ -7,6 +7,8 @@ import 'package:splitio_web/src/js_interop.dart'; import 'package:splitio_platform_interface/split_certificate_pinning_configuration.dart'; import 'package:splitio_platform_interface/split_sync_config.dart'; import 'package:splitio_platform_interface/split_rollout_cache_configuration.dart'; +import 'package:splitio_platform_interface/split_fallback_treatment.dart'; +import 'package:splitio_platform_interface/split_fallback_treatments_configuration.dart'; import 'utils/js_interop_test_utils.dart'; extension on web.Window { @@ -685,39 +687,47 @@ void main() { matchingKey: 'matching-key', bucketingKey: 'bucketing-key', sdkConfiguration: SplitConfiguration( - featuresRefreshRate: 1, - segmentsRefreshRate: 2, - impressionsRefreshRate: 3, - telemetryRefreshRate: 4, - eventsQueueSize: 5, - impressionsQueueSize: 6, - eventFlushInterval: 7, - eventsPerPush: 8, // unsupported in Web - trafficType: 'user', - // ignore: deprecated_member_use - enableDebug: false, // deprecated, logLevel has precedence - streamingEnabled: false, - persistentAttributesEnabled: true, // unsupported in Web - impressionListener: true, - sdkEndpoint: 'https://sdk.domain/api', - eventsEndpoint: 'https://events.domain/api', - authServiceEndpoint: 'https://auth.domain/api/v2', - streamingServiceEndpoint: 'https://streaming.domain/sse', - telemetryServiceEndpoint: 'https://telemetry.domain/api/v1', - syncConfig: SyncConfig( - names: ['flag_1', 'flag_2'], prefixes: ['prefix_1']), - impressionsMode: ImpressionsMode.none, - syncEnabled: true, - userConsent: UserConsent.granted, - encryptionEnabled: true, // unsupported in Web - logLevel: SplitLogLevel.info, - readyTimeout: 1, - certificatePinningConfiguration: CertificatePinningConfiguration() - .addPin('host', 'pin'), // unsupported in Web - rolloutCacheConfiguration: RolloutCacheConfiguration( - expirationDays: 100, - clearOnInit: true, - ))); + featuresRefreshRate: 1, + segmentsRefreshRate: 2, + impressionsRefreshRate: 3, + telemetryRefreshRate: 4, + eventsQueueSize: 5, + impressionsQueueSize: 6, + eventFlushInterval: 7, + eventsPerPush: 8, // unsupported in Web + trafficType: 'user', + // ignore: deprecated_member_use + enableDebug: false, // deprecated, logLevel has precedence + streamingEnabled: false, + persistentAttributesEnabled: true, // unsupported in Web + impressionListener: true, + sdkEndpoint: 'https://sdk.domain/api', + eventsEndpoint: 'https://events.domain/api', + authServiceEndpoint: 'https://auth.domain/api/v2', + streamingServiceEndpoint: 'https://streaming.domain/sse', + telemetryServiceEndpoint: 'https://telemetry.domain/api/v1', + syncConfig: + SyncConfig(names: ['flag_1', 'flag_2'], prefixes: ['prefix_1']), + impressionsMode: ImpressionsMode.none, + syncEnabled: true, + userConsent: UserConsent.granted, + encryptionEnabled: true, // unsupported in Web + logLevel: SplitLogLevel.info, + readyTimeout: 1, + certificatePinningConfiguration: CertificatePinningConfiguration() + .addPin('host', 'pin'), // unsupported in Web + rolloutCacheConfiguration: RolloutCacheConfiguration( + expirationDays: 100, + clearOnInit: true, + ), + fallbackTreatments: FallbackTreatmentsConfiguration( + global: const FallbackTreatment('global-treatment'), + byFlag: { + 'flag_1': const FallbackTreatment('fallback_1', 'config_1'), + 'flag_2': const FallbackTreatment('fallback_2', null) + }, + ), + )); expect(mock.calls[mock.calls.length - 5].methodName, 'SplitFactory'); final actual = @@ -776,6 +786,13 @@ void main() { 'impressionListener': { 'logImpression': (actual as Map)['impressionListener'] ['logImpression'] + }, + 'fallbackTreatments': { + 'global': {'treatment': 'global-treatment', 'config': null}, + 'byFlag': { + 'flag_1': {'treatment': 'fallback_1', 'config': 'config_1'}, + 'flag_2': {'treatment': 'fallback_2', 'config': null} + } } })); diff --git a/splitio_web/web/split-browser-1.6.0.full.min.js b/splitio_web/web/split-browser-1.6.0.full.min.js deleted file mode 100644 index d6b1c75..0000000 --- a/splitio_web/web/split-browser-1.6.0.full.min.js +++ /dev/null @@ -1,9 +0,0 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).splitio=t()}(this,(function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function n(e,t){var n;if(c(e))for(var r=Object.keys(e),i=0;i0)return t;e.error(vn,[n,r])}else e.error(mn,[n,r]);return!1}function Qn(e,t,n,r,i){if(void 0===r&&(r="feature flag names"),void 0===i&&(i="feature flag name"),Array.isArray(t)&&t.length>0){var s=[];if(t.forEach((function(t){var r=Hn(e,t,n,i);r&&s.push(r)})),s.length)return m(s)}return e.error(yn,[n,r]),!1}var Vn=Object.assign||function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");e=Object(e);for(var t=1;t0}))}function er(e,t,n){var r,i,s={validFilters:[],queryString:null,groupedFilters:{bySet:[],byName:[],byPrefix:[]}};return t?Ie(n)?(e.warn(jt),s):Array.isArray(t)&&0!==t.length?(s.validFilters=t.filter((function(t,n){return t&&(r=t.type,Jn.some((function(e){return e.type===r})))&&Array.isArray(t.values)?(s.groupedFilters[t.type]=s.groupedFilters[t.type].concat(t.values),!0):(e.warn(qt,[n]),!1);var r})),Jn.forEach((function(t){var n=t.type,r=t.maxLength;s.groupedFilters[n].length>0&&(s.groupedFilters[n]=function(e,t,n,r){var i=Qn(e,n,wn,t+" filter",t+" filter value");if(i){if("bySet"===t&&(i=Zn(e,i,wn)),i.length>r)throw new Error(r+" unique values can be specified at most for '"+t+"' filter. You passed "+i.length+". Please consider reducing the amount or using other filter.");i.sort()}return i||[]}(e,n,s.groupedFilters[n],r))})),Xn(s.validFilters,"bySet")&&((Xn(s.validFilters,"byName")||Xn(s.validFilters,"byPrefix"))&&e.error(kn),Vn(s.groupedFilters,{byName:[],byPrefix:[]})),s.queryString=(r=s.groupedFilters,i=[],Jn.forEach((function(e){var t=e.type,n=e.queryParam,s=r[t];s.length>0&&i.push(n+s.map((function(e){return encodeURIComponent(e)})).join(","))})),i.length>0?"&"+i.join("&"):null),e.debug(Ve,[s.queryString]),s):(e.warn(zt),s):s}var tr,nr=250;function rr(e,t,n,r){if(null==t)return e.error(pn,[n,r]),!1;if(a(t))return e.warn(Mt,[n,r,t]),d(t);if(l(t)){if((t=t.trim()).length>0&&t.length<=nr)return t;0===t.length?e.error(vn,[n,r]):t.length>nr&&e.error(gn,[n,r])}else e.error(mn,[n,r]);return!1}function ir(e,t,n){if(c(t)){var r=rr(e,t.matchingKey,n,"matchingKey"),i=rr(e,t.bucketingKey,n,"bucketingKey");return r&&i?{matchingKey:r,bucketingKey:i}:(e.error(dn,[n]),!1)}return rr(e,t,n,"key")}function sr(e,t,n,r){var i=n.splits,s=n.rbSegments,o=n.segments,a=n.largeSegments,u=t.splitChanges,c=u.ff,l=u.rbs;e.debug("storage: set feature flags and segments"+(r?" for key "+r:"")),i&&c&&(i.clear(),i.update(c.d,[],c.t)),s&&l&&(s.clear(),s.update(l.d,[],l.t));var f=t.segmentChanges;if(r){var h=t.memberships&&t.memberships[r];!h&&f&&(h={ms:{k:f.filter((function(e){return e.added.indexOf(r)>-1})).map((function(e){return{n:e.name}}))}}),h&&(h.ms&&o.resetSegments(h.ms),h.ls&&a&&a.resetSegments(h.ls))}else f&&(o.clear(),f.forEach((function(e){o.update(e.name,e.added,e.removed,e.till)})))}!function(e){e.FlagName="Invalid flag name (max 100 chars, no spaces)",e.Treatment="Invalid treatment (max 100 chars and must match pattern)"}(tr||(tr={}));var or=/^[0-9]+[.a-zA-Z0-9_-]*$|^[a-zA-Z]+[a-zA-Z0-9_-]*$/;function ar(e){var t=c(e)?e.treatment:e;return!(!l(t)||t.length>100)&&or.test(t)}function ur(e,t){if(void 0!==t){if(ar(t))return t;e.error("Fallback treatments - Discarded fallback: "+tr.Treatment)}}function cr(e,t){var n={};return c(t)?(Object.keys(t).forEach((function(r){var i,s=t[r];(i=r).length<=100&&!i.includes(" ")?ar(s)?n[r]=s:e.error("Fallback treatments - Discarded treatment for flag '"+r+"': "+tr.Treatment):e.error("Fallback treatments - Discarded flag '"+r+"': "+tr.FlagName)})),n):n}var lr={mode:k,core:{authorizationKey:void 0,key:void 0,labelsEnabled:!0,IPAddressesEnabled:void 0},scheduler:{featuresRefreshRate:60,segmentsRefreshRate:60,telemetryRefreshRate:3600,impressionsRefreshRate:300,offlineRefreshRate:15,eventsPushRate:60,eventsQueueSize:500,impressionsQueueSize:3e4,pushRetryBackoffBase:1},urls:{sdk:"https://sdk.split.io/api",events:"https://events.split.io/api",auth:"https://auth.split.io/api",streaming:"https://streaming.split.io",telemetry:"https://telemetry.split.io/api"},storage:void 0,debug:void 0,impressionListener:void 0,version:void 0,integrations:void 0,streamingEnabled:!0,sync:{splitFilters:void 0,impressionsMode:E,enabled:!0,flagSpecVersion:Ce},log:void 0};function fr(e){return Math.round(1e3*e)}function hr(e,t){var n=t.defaults,r=t.runtime,i=t.storage,o=t.integrations,a=t.logger,u=t.consent,l=t.flagSpec,p=h({},lr,n,e);p.features=s(e,"features");var g=a(p);p.log=g;var d=p.sync;d.impressionsMode=function(e,t){return t=f(t),[b,E,T].indexOf(t)>-1?t:(e.error(Sn,["impressionsMode",[b,E,T],E]),E)}(g,d.impressionsMode);var m,v,y,S=p.scheduler,_=p.startup;S.featuresRefreshRate=fr(S.featuresRefreshRate),S.segmentsRefreshRate=fr(S.segmentsRefreshRate),S.offlineRefreshRate=fr(S.offlineRefreshRate),S.eventsPushRate=fr(S.eventsPushRate),S.telemetryRefreshRate=fr((m="telemetryRefreshRate",(v=S.telemetryRefreshRate)>=(y=60)?v:(g.error(Tn,[m,y]),y))),void 0===s(e,"scheduler.impressionsRefreshRate")&&d.impressionsMode===b&&(S.impressionsRefreshRate=60),S.impressionsRefreshRate=fr(S.impressionsRefreshRate),S.metricsRefreshRate&&g.warn("`metricsRefreshRate` will be deprecated soon. For configuring telemetry rates, update `telemetryRefreshRate` value in configs"),_.requestTimeoutBeforeReady=fr(_.requestTimeoutBeforeReady),_.readyTimeout=fr(_.readyTimeout),_.eventsFirstPushWindow=fr(_.eventsFirstPushWindow),p.mode=function(e,t){if("localhost"===e)return R;if(-1===[k,C,w,N].indexOf(t))throw Error("Invalid mode provided");return t}(p.core.authorizationKey,p.mode),i&&(p.storage=i(p)),p.initialRolloutPlan&&(p.initialRolloutPlan=function(e,t){var n=t.mode,r=t.initialRolloutPlan;if(!Ie(n))return c(r)&&c(r.splitChanges)?r:void e.error("storage: invalid rollout plan provided");e.warn("storage: initial rollout plan is ignored in consumer mode")}(g,p));var A=p.core.key;t.acceptKey?p.mode===R&&void 0===A?p.core.key="localhost_key":p.core.key=ir(g,A,_n):(void 0!==A&&g.warn("Provided `key` is ignored in server-side SDK."),p.core.key=void 0),p.runtime=r(p),o&&(p.integrations=o(p)),!1!==p.streamingEnabled&&(p.streamingEnabled=!0,S.pushRetryBackoffBase=fr(S.pushRetryBackoffBase)),!1!==d.enabled&&(d.enabled=!0);var I=er(g,d.splitFilters,p.mode);return d.splitFilters=I.validFilters,d.__splitFiltersValidation=I,d.flagSpecVersion=l?l(p):Ce,p.userConsent=u?u(p):void 0,p.fallbackTreatments=p.fallbackTreatments?function(e,t){if(c(t))return{global:ur(e,t.global),byFlag:cr(e,t.byFlag)};e.error("Fallback treatments - Discarded configuration: it must be an object with optional `global` and `byFlag` properties")}(g,p.fallbackTreatments):void 0,p}function pr(e){return null!==e&&"object"==typeof e&&"function"==typeof e.debug&&"function"==typeof e.info&&"function"==typeof e.warn&&"function"==typeof e.error}var gr={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",NONE:"NONE"},dr={DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},mr={debug:function(e){console.log("[DEBUG] "+e)},info:function(e){console.log("[INFO] "+e)},warn:function(e){console.log("[WARN] "+e)},error:function(e){console.log("[ERROR] "+e)}};function vr(e){return!!n(gr,(function(t){return e===t}))}function yr(e,t){void 0===e&&(e=""),void 0===t&&(t=[]);var n=0;return e.replace(/%s/g,(function(){var e=t[n++];if(c(e)||Array.isArray(e))try{e=JSON.stringify(e)}catch(e){}return e}))}var Sr,br={prefix:"splitio",logLevel:gr.NONE},Er=function(){function e(e,t){this.options=Vn({},br,e),this.codes=t||new Map,this.logLevel=dr[this.options.logLevel]}return e.prototype.setLogLevel=function(e){this.options.logLevel=e,this.logLevel=dr[e]},e.prototype.setLogger=function(e){if(e){if(pr(e))return void(this.logger=e);this.error("Invalid `logger` instance. It must be an object with `debug`, `info`, `warn` and `error` methods. Defaulting to `console.log`")}this.logger=void 0},e.prototype.debug=function(e,t){this._shouldLog(dr.DEBUG)&&this._log("debug",e,t)},e.prototype.info=function(e,t){this._shouldLog(dr.INFO)&&this._log("info",e,t)},e.prototype.warn=function(e,t){this._shouldLog(dr.WARN)&&this._log("warn",e,t)},e.prototype.error=function(e,t){this._shouldLog(dr.ERROR)&&this._log("error",e,t)},e.prototype._log=function(e,t,n){if("number"==typeof t){var r=this.codes.get(t);t=r?yr(r,n):"Message code "+t+(n?", with args: "+n.toString():"")}else n&&(t=yr(t,n));if(this.options.prefix&&(t=this.options.prefix+" => "+t),this.logger)try{return void this.logger[e](t)}catch(e){}mr[e](t)},e.prototype._shouldLog=function(e){return e>=this.logLevel},e}();try{var Tr=localStorage.getItem("splitio_debug")||"";Sr=/^(enabled?|on)/i.test(Tr)?gr.DEBUG:vr(Tr)?Tr:gr.NONE}catch(Ei){}var Rr={startup:{requestTimeoutBeforeReady:5,retriesOnFailureBeforeReady:1,readyTimeout:10,eventsFirstPushWindow:10},userConsent:O,version:"browserjs-1.6.0",debug:Sr};var kr=function(){function e(){}return e.prototype.update=function(e,t,n){var r=this;this.setChangeNumber(n);var i=e.map((function(e){return r.addSplit(e)})).some((function(e){return e}));return t.map((function(e){return r.removeSplit(e.name)})).some((function(e){return e}))||i},e.prototype.getSplits=function(e){var t=this,n={};return e.forEach((function(e){n[e]=t.getSplit(e)})),n},e.prototype.getAll=function(){var e=this;return this.getSplitNames().map((function(t){return e.getSplit(t)}))},e.prototype.killLocally=function(e,t,n){var r=this.getSplit(e);if(r&&(!r.changeNumber||r.changeNumber0)}function wr(e){return e.splits.usesSegments()||e.rbSegments.usesSegments()}var Nr=function(e){function n(t){var n=e.call(this)||this;return n.splitsCache={},n.ttCache={},n.changeNumber=-1,n.segmentsCount=0,n.flagSetsCache={},n.flagSetsFilter=t?t.groupedFilters.bySet:[],n}return t(n,e),n.prototype.clear=function(){this.splitsCache={},this.ttCache={},this.changeNumber=-1,this.segmentsCount=0,this.flagSetsCache={}},n.prototype.addSplit=function(e){var t=e.name,n=this.getSplit(t);if(n){var r=n.trafficTypeName;this.ttCache[r]--,this.ttCache[r]||delete this.ttCache[r],this.removeFromFlagSets(n.name,n.sets),Cr(n)&&this.segmentsCount--}this.splitsCache[t]=e;var i=e.trafficTypeName;return this.ttCache[i]=(this.ttCache[i]||0)+1,this.addToFlagSets(e),Cr(e)&&this.segmentsCount++,!0},n.prototype.removeSplit=function(e){var t=this.getSplit(e);if(!t)return!1;delete this.splitsCache[e];var n=t.trafficTypeName;return this.ttCache[n]--,this.ttCache[n]||delete this.ttCache[n],this.removeFromFlagSets(t.name,t.sets),Cr(t)&&this.segmentsCount--,!0},n.prototype.getSplit=function(e){return this.splitsCache[e]||null},n.prototype.setChangeNumber=function(e){return this.changeNumber=e,!0},n.prototype.getChangeNumber=function(){return this.changeNumber},n.prototype.getSplitNames=function(){return Object.keys(this.splitsCache)},n.prototype.trafficTypeExists=function(e){return a(this.ttCache[e])&&this.ttCache[e]>0},n.prototype.usesSegments=function(){return-1===this.getChangeNumber()||this.segmentsCount>0},n.prototype.getNamesByFlagSets=function(e){var t=this;return e.map((function(e){return t.flagSetsCache[e]||new Set}))},n.prototype.addToFlagSets=function(e){var t=this;e.sets&&e.sets.forEach((function(n){t.flagSetsFilter.length>0&&!t.flagSetsFilter.some((function(e){return e===n}))||(t.flagSetsCache[n]||(t.flagSetsCache[n]=new Set([])),t.flagSetsCache[n].add(e.name))}))},n.prototype.removeFromFlagSets=function(e,t){var n=this;t&&t.forEach((function(t){n.removeNames(t,e)}))},n.prototype.removeNames=function(e,t){this.flagSetsCache[e]&&(this.flagSetsCache[e].delete(t),0===this.flagSetsCache[e].size&&delete this.flagSetsCache[e])},n}(kr),_r=function(){function e(){}return e.prototype.clear=function(){this.resetSegments({})},e.prototype.registerSegments=function(){return!1},e.prototype.update=function(){return!1},e.prototype.resetSegments=function(e){var t=this;this.setChangeNumber(e.cn);var n=e,r=n.added,i=n.removed;if(r&&i){var s=!1;return r.forEach((function(e){s=t.addSegment(e)||s})),i.forEach((function(e){s=t.removeSegment(e)||s})),s}var o=(e.k||[]).map((function(e){return e.n})).sort(),a=this.getRegisteredSegments().sort();if(!o.length&&!a.length)return!1;for(var u=0;u0&&this.queue.length>=this.maxQueue&&this.onFullQueue&&this.onFullQueue()},e.prototype.clear=function(){this.queue=[]},e.prototype.pop=function(e){var t=this.queue;return this.clear(),e?e.concat(t):t},e.prototype.isEmpty=function(){return 0===this.queue.length},e}(),Or=function(){function e(e){void 0===e&&(e=0),this.name="events",this.maxQueue=e,this.queue=[],this.queueByteSize=0}return e.prototype.setOnFullQueueCb=function(e){this.onFullQueue=e},e.prototype.track=function(e,t){return void 0===t&&(t=0),this.queueByteSize+=t,this.queue.push(e),this._checkForFlush(),!0},e.prototype.clear=function(){this.queue=[],this.queueByteSize=0},e.prototype.pop=function(e){var t=this.queue;return this.clear(),e?e.concat(t):t},e.prototype.isEmpty=function(){return 0===this.queue.length},e.prototype._checkForFlush=function(){(this.queueByteSize>5242880||this.maxQueue>0&&this.queue.length>=this.maxQueue)&&this.onFullQueue&&this.onFullQueue()},e}(),Fr=36e5;function Lr(e){return e-e%Fr}var Dr=function(){function e(e){void 0===e&&(e=3e4),this.name="impression counts",this.cache={},this.cacheSize=0,this.maxStorage=e}return e.prototype._makeKey=function(e,t){return e+"::"+Lr(t)},e.prototype.track=function(e,t,n){var r=this._makeKey(e,t),i=this.cache[r];this.cache[r]=i?i+n:n,this.onFullQueue&&(this.cacheSize=this.cacheSize+n,this.cacheSize>=this.maxStorage&&this.onFullQueue())},e.prototype.pop=function(e){var t=this.cache;return this.clear(),e?(Object.keys(t).forEach((function(n){e[n]?e[n]+=t[n]:e[n]=t[n]})),e):t},e.prototype.clear=function(){this.cache={},this.cacheSize=0},e.prototype.isEmpty=function(){return 0===Object.keys(this.cache).length},e}();function Mr(e){return c(e)?e.matchingKey:e}function Kr(e){return c(e)?{matchingKey:e.matchingKey,bucketingKey:e.bucketingKey}:{matchingKey:e,bucketingKey:e}}function xr(e){return!e.core.key}function Pr(e){var t=Math.min(22,Math.max(0,Math.ceil(Math.log(e)/Math.log(1.5))));return u(t)?0:t}var Ur=.001;function Br(e){var t=e.settings;return t.mode!==R&&(xr(t)||Math.random()<=Ur)}var jr=function(){function e(e,t,n){this.splits=e,this.segments=t,this.largeSegments=n,this.name="telemetry stats",this.e=!0,this.notReadyUsage=0,this.impressionStats=[0,0,0],this.eventStats=[0,0],this.lastSync={},this.httpErrors={},this.httpLatencies={},this.authRejections=0,this.tokenRefreshes=0,this.streamingEvents=[],this.tags=[],this.exceptions={},this.latencies={},this.updatesFromSSE={}}return e.prototype.isEmpty=function(){return this.e},e.prototype.clear=function(){},e.prototype.pop=function(){return this.e=!0,{lS:this.getLastSynchronization(),mL:this.popLatencies(),mE:this.popExceptions(),hE:this.popHttpErrors(),hL:this.popHttpLatencies(),tR:this.popTokenRefreshes(),aR:this.popAuthRejections(),iQ:this.getImpressionStats(H),iDe:this.getImpressionStats(V),iDr:this.getImpressionStats(Q),spC:this.splits&&this.splits.getSplitNames().length,seC:this.segments&&this.segments.getRegisteredSegments().length,skC:this.segments&&this.segments.getKeysCount(),lsC:this.largeSegments&&this.largeSegments.getRegisteredSegments().length,lskC:this.largeSegments&&this.largeSegments.getKeysCount(),sL:this.getSessionLength(),eQ:this.getEventStats(H),eD:this.getEventStats(Q),sE:this.popStreamingEvents(),t:this.popTags(),ufs:this.popUpdatesFromSSE()}},e.prototype.getTimeUntilReady=function(){return this.timeUntilReady},e.prototype.recordTimeUntilReady=function(e){this.timeUntilReady=e},e.prototype.getTimeUntilReadyFromCache=function(){return this.timeUntilReadyFromCache},e.prototype.recordTimeUntilReadyFromCache=function(e){this.timeUntilReadyFromCache=e},e.prototype.getNonReadyUsage=function(){return this.notReadyUsage},e.prototype.recordNonReadyUsage=function(){this.notReadyUsage++},e.prototype.getImpressionStats=function(e){return this.impressionStats[e]},e.prototype.recordImpressionStats=function(e,t){this.impressionStats[e]+=t,this.e=!1},e.prototype.getEventStats=function(e){return this.eventStats[e]},e.prototype.recordEventStats=function(e,t){this.eventStats[e]+=t,this.e=!1},e.prototype.getLastSynchronization=function(){return this.lastSync},e.prototype.recordSuccessfulSync=function(e,t){this.lastSync[e]=t,this.e=!1},e.prototype.popHttpErrors=function(){var e=this.httpErrors;return this.httpErrors={},e},e.prototype.recordHttpError=function(e,t){var n=this.httpErrors[e]=this.httpErrors[e]||{};n[t]=(n[t]||0)+1,this.e=!1},e.prototype.popHttpLatencies=function(){var e=this.httpLatencies;return this.httpLatencies={},e},e.prototype.recordHttpLatency=function(e,t){(this.httpLatencies[e]=this.httpLatencies[e]||[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])[Pr(t)]++,this.e=!1},e.prototype.popAuthRejections=function(){var e=this.authRejections;return this.authRejections=0,e},e.prototype.recordAuthRejections=function(){this.authRejections++,this.e=!1},e.prototype.popTokenRefreshes=function(){var e=this.tokenRefreshes;return this.tokenRefreshes=0,e},e.prototype.recordTokenRefreshes=function(){this.tokenRefreshes++,this.e=!1},e.prototype.popStreamingEvents=function(){return this.streamingEvents.splice(0)},e.prototype.recordStreamingEvents=function(e){this.streamingEvents.length<20&&this.streamingEvents.push(e),this.e=!1},e.prototype.popTags=function(){return this.tags.splice(0)},e.prototype.addTag=function(e){this.tags.length<10&&this.tags.push(e),this.e=!1},e.prototype.getSessionLength=function(){return this.sessionLength},e.prototype.recordSessionLength=function(e){this.sessionLength=e,this.e=!1},e.prototype.popExceptions=function(){var e=this.exceptions;return this.exceptions={},e},e.prototype.recordException=function(e){this.exceptions[e]=(this.exceptions[e]||0)+1,this.e=!1},e.prototype.popLatencies=function(){var e=this.latencies;return this.latencies={},e},e.prototype.recordLatency=function(e,t){(this.latencies[e]=this.latencies[e]||[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])[Pr(t)]++,this.e=!1},e.prototype.popUpdatesFromSSE=function(){var e=this.updatesFromSSE;return this.updatesFromSSE={},e},e.prototype.recordUpdatesFromSSE=function(e){this.updatesFromSSE[e]=(this.updatesFromSSE[e]||0)+1,this.e=!1},e}();function qr(e){if(Array.from)return Array.from(e);var t=[];return e.forEach((function(e){t.push(e)})),t}var zr=function(){function e(e){void 0===e&&(e=3e4),this.name="unique keys",this.uniqueTrackerSize=0,this.uniqueKeysTracker={},this.maxStorage=e}return e.prototype.setOnFullQueueCb=function(e){this.onFullQueue=e},e.prototype.track=function(e,t){this.uniqueKeysTracker[e]||(this.uniqueKeysTracker[e]=new Set);var n=this.uniqueKeysTracker[e];n.has(t)||(n.add(t),this.uniqueTrackerSize++),this.uniqueTrackerSize>=this.maxStorage&&this.onFullQueue&&this.onFullQueue()},e.prototype.clear=function(){this.uniqueTrackerSize=0,this.uniqueKeysTracker={}},e.prototype.pop=function(){var e=this.uniqueKeysTracker;return this.clear(),this.fromUniqueKeysCollector(e)},e.prototype.isEmpty=function(){return 0===Object.keys(this.uniqueKeysTracker).length},e.prototype.fromUniqueKeysCollector=function(e){for(var t=[],n=Object.keys(e),r=0;r0},e}();function Gr(e){var t=e.settings,n=t.scheduler,r=n.impressionsQueueSize,i=n.eventsQueueSize,s=t.sync.__splitFiltersValidation,o=new Nr(s),a=new Wr,u=new Ar,c={splits:o,rbSegments:a,segments:u,largeSegments:new Ar,impressions:new Ir(r),impressionCounts:new Dr,events:new Or(i),telemetry:Br(e)?new jr(o,u):void 0,uniqueKeys:new zr,destroy:function(){},shared:function(){return{splits:this.splits,rbSegments:this.rbSegments,segments:new Ar,largeSegments:new Ar,impressions:this.impressions,impressionCounts:this.impressionCounts,events:this.events,telemetry:this.telemetry,uniqueKeys:this.uniqueKeys,destroy:function(){}}}};if(e.settings.mode===R){var l=function(){return!0};c.impressions.track=l,c.events.track=l,c.impressionCounts.track=l,c.uniqueKeys.track=l}return c}function Hr(e){var t=Gr(e);return t.validateCache=function(){return Promise.resolve(!0)},t}Gr.type=_,Hr.type=_;var Qr=gr.NONE;var Vr=[F,O,L];var Jr={defaults:Rr,acceptKey:!0,runtime:function(){return{ip:!1,hostname:!1}},storage:function(e){var t=e.storage,n=void 0===t?Gr:t,r=e.log,i=e.mode;if("function"==typeof n&&-1!==[_,A,I].indexOf(n.type)||(n=Gr,r.error(324)),i===R&&n.type===A)return Hr;if(-1===[R,k].indexOf(i)){if(n.type!==I)throw new Error("A PluggableStorage instance is required on consumer mode")}else n.type===I&&(n=Gr,r.error(324,[" It requires consumer mode."]));return n},integrations:function(e){return function(e,t,n){var r=e.integrations,i=e.log;if(!Array.isArray(r)||0===r.length)return[];var s=r.filter(t),o=r.length-s.length;return o&&i.warn(Bt,[o,n||""]),s}(e,(function(e){return"function"==typeof e}),"Integration items must be functions that initialize the integrations")},logger:function(e){var t,n=e.debug,r=e.logger,i=Qr;if(void 0!==n){if(function(e){return pr(e)&&"function"==typeof e.setLogLevel}(n))return n.setLogger(r),n;i="boolean"==typeof(t=e.debug)?t?gr.DEBUG:gr.NONE:"string"==typeof t&&vr(t)?t:void 0}var s=new Er({logLevel:i||Qr});return s.setLogger(r),i||s._log("error","Invalid `debug` value at config. Logs will be disabled."),s},consent:function(e){var t=e.userConsent,n=e.log;return t=f(t),Vr.indexOf(t)>-1?t:(n.error(Sn,["userConsent",Vr,O]),O)}};var Yr=new Set(["splitsdkclientkey","splitsdkversion","splitsdkmachineip","splitsdkmachinename","splitsdkimpressionsmode","host","referrer","content-type","content-length","content-encoding","accept","keep-alive","x-fastly-debug"]);function $r(e,t){var n;if(null===(n=e.sync.requestOptions)||void 0===n?void 0:n.getHeaderOverrides)try{var r=e.sync.requestOptions.getHeaderOverrides({headers:Vn({},t)});Object.keys(r).filter((function(e){return!Yr.has(e.toLowerCase())})).forEach((function(e){return t[e]=r[e]}))}catch(t){e.log.error("Problem adding custom headers to request decorator: "+t)}return t}function Zr(e,t){return e<1?t:new Promise((function(n,r){var i=setTimeout((function(){r(new Error("Operation timed out because it exceeded the configured time limit of "+e+" ms."))}),e);t.then((function(e){clearTimeout(i),n(e)}),(function(e){clearTimeout(i),r(e)}))}))}var Xr=100,ei="Global fetch API is not available.";var ti={headers:{"Cache-Control":"no-cache"}};function ni(e){return"users="+encodeURIComponent(e)}function ri(e,t,n){var r=e.urls,i=e.sync.__splitFiltersValidation&&e.sync.__splitFiltersValidation.queryString,s=e.sync.impressionsMode,o=function(e,t){var n=t.getOptions,r=t.getFetch,i=e.log,s=e.core.authorizationKey,o=e.version,a=e.runtime,u=a.ip,c=a.hostname,l=n&&n(e),f=r&&r(e);f||i.error(en,[ei]);var h={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+s,SplitSDKVersion:o};return u&&(h.SplitSDKMachineIP=u),c&&(h.SplitSDKMachineName=c.replace(/[^\x00-\xFF]/g,"")),function(t,n,r,s){void 0===n&&(n={}),void 0===r&&(r=function(){}),void 0===s&&(s=!1);var o=Vn({headers:$r(e,Vn({},h,n.headers||{})),method:n.method||"GET",body:n.body},l);return f?f(t,o).then((function(e){return e.ok?(r(),e):Zr(Xr,e.text()).then((function(t){return Promise.reject({response:e,message:t})}),(function(){return Promise.reject({response:e})}))})).catch((function(e){var n=e&&e.response,o="";o=n?404===n.status?"Invalid SDK key or resource not found.":e.message:e.message||"Network Error",n&&403===n.status||i[s?"info":"error"](bn,[n?"status code "+n.status:"no status code",t,o]);var a=new Error(o);throw a.statusCode=n&&n.status,r(a),a})):Promise.reject(new Error(ei))}}(e,t);return{getSdkAPIHealthCheck:function(){var e=r.sdk+"/version";return o(e).then((function(){return!0})).catch((function(){return!1}))},getEventsAPIHealthCheck:function(){var e=r.events+"/version";return o(e).then((function(){return!0})).catch((function(){return!1}))},fetchAuth:function(t){var i=r.auth+"/v2/auth?s="+e.sync.flagSpecVersion;if(t){var s=t.map(ni).join("&");s&&(i+="&"+s)}return o(i,void 0,n.trackHttp(ee))},fetchSplitChanges:function(t,s,a,u){var c=r.sdk+"/splitChanges?s="+e.sync.flagSpecVersion+"&since="+t+(u?"&rbSince="+u:"")+(i||"")+(a?"&till="+a:"");return o(c,s?ti:void 0,n.trackHttp(J)).catch((function(t){throw 414===t.statusCode&&e.log.error(Rn),t}))},fetchSegmentChanges:function(e,t,i,s){var a=r.sdk+"/segmentChanges/"+t+"?since="+e+(s?"&till="+s:"");return o(a,i?ti:void 0,n.trackHttp(te))},fetchMemberships:function(e,t,i){var s=r.sdk+"/memberships/"+encodeURIComponent(e)+(i?"?till="+i:"");return o(s,t?ti:void 0,n.trackHttp(ne))},postEventsBulk:function(e,t){var i=r.events+"/events/bulk";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(Z))},postTestImpressionsBulk:function(e,t){var i=r.events+"/testImpressions/bulk";return o(i,{method:"POST",body:e,headers:Vn({SplitSDKImpressionsMode:s},t)},n.trackHttp(Y))},postTestImpressionsCount:function(e,t){var i=r.events+"/testImpressions/count";return o(i,{method:"POST",body:e,headers:t},n.trackHttp($))},postUniqueKeysBulkCs:function(e,t){var i=r.telemetry+"/v1/keys/cs";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(X))},postUniqueKeysBulkSs:function(e,t){var i=r.telemetry+"/v1/keys/ss";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(X))},postMetricsConfig:function(e,t){var i=r.telemetry+"/v1/metrics/config";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(X),!0)},postMetricsUsage:function(e,t){var i=r.telemetry+"/v1/metrics/usage";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(X),!0)}}}function ii(e,t,n,r){void 0===r&&(r="task");var i,s,o,a=0,u=!1,c=0;function l(){for(var n=[],s=0;s0},start:function(){for(var t=[],i=0;i0&&(a=oi(a,i)),o.setOnFullQueueCb((function(){a.isRunning()&&(n.info(ht,[o.name]),a.execute())})),a}function ui(e,t){var n=function(e,t){var n={};if(Array.isArray(e)&&l(t))for(var r=0;r0?n=t:e.error(vn,[Nn,bi]):e.error(mn,[Nn,bi]),n}(e,t);return n&&(ki[n]?(e.warn(Wt,[ki[n]+" factory/ies with this SDK Key"]),ki[n]++):(ki[n]=1,Object.keys(ki).length>1&&e.warn(Wt,["an instance of the Split factory"]))),n}function wi(e){var t=e();return function(){return Math.round(e()-t)}}var Ni=((Ei={})[k]=0,Ei[w]=1,Ei[N]=2,Ei),_i=((Ti={})[E]=0,Ti[b]=1,Ti[T]=2,Ti),Ai=((Ri={})[L]=1,Ri[O]=2,Ri[F]=3,Ri);function Ii(e,t){return{name:"telemetry config",isEmpty:function(){return!1},clear:function(){},pop:function(){var n,r,i=t.urls,s=t.scheduler,o=xr(t),a=function(e){var t=0;e.validFilters.forEach((function(e){"bySet"===e.type&&(t+=e.values.length)}));var n=e.groupedFilters.bySet.length;return{flagSetsTotal:t,flagSetsIgnored:t-n}}(t.sync.__splitFiltersValidation),u=a.flagSetsTotal,c=a.flagSetsIgnored;return Vn((n=t.mode,r=t.storage.type,{oM:Ni[n],st:r.toLowerCase(),aF:Object.keys(ki).length,rF:Object.keys(ki).reduce((function(e,t){return e+ki[t]-1}),0)}),{sE:t.streamingEnabled,rR:{sp:s.featuresRefreshRate/1e3,se:o?s.segmentsRefreshRate/1e3:void 0,ms:o?void 0:s.segmentsRefreshRate/1e3,im:s.impressionsRefreshRate/1e3,ev:s.eventsPushRate/1e3,te:s.telemetryRefreshRate/1e3},uO:{s:i.sdk!==lr.urls.sdk,e:i.events!==lr.urls.events,a:i.auth!==lr.urls.auth,st:i.streaming!==lr.urls.streaming,t:i.telemetry!==lr.urls.telemetry},iQ:s.impressionsQueueSize,eQ:s.eventsQueueSize,iM:_i[t.sync.impressionsMode],iL:!!t.impressionListener,hP:!1,tR:e.getTimeUntilReady(),tC:e.getTimeUntilReadyFromCache(),nR:e.getNonReadyUsage(),t:e.popTags(),i:t.integrations&&t.integrations.map((function(e){return e.type})),uC:t.userConsent?Ai[t.userConsent]:0,fsT:u,fsI:c})}}}var Oi=9e5;function Fi(e){var t=e.settings,n=t.log,r=t.core.key,i=e.splitApi,s=i.postUniqueKeysBulkCs,o=i.postUniqueKeysBulkSs,a=e.storage.uniqueKeys,u=si(n,void 0!==r?s:o,a,Oi);return a.setOnFullQueueCb((function(){u.isRunning()&&(n.info(ht,[a.name]),u.execute())})),u}function Li(e){var t=[ci(e),ai(e),hi(e),Fi(e)],n=function(e){var t=e.storage.telemetry,n=e.platform.now;if(t&&n){var r=e.settings,i=e.settings,s=i.log,o=i.scheduler.telemetryRefreshRate,a=e.splitApi,u=e.readiness,c=e.sdkReadinessManager,l=wi(n),f=oi(si(s,a.postMetricsUsage,t,o,void 0,0,!0),o);return u.gate.once(yi,(function(){t.recordTimeUntilReadyFromCache(l())})),c.incInternalReadyCbCount(),u.gate.once(vi,(function(){t.recordTimeUntilReady(l()),f.isRunning()&&si(s,a.postMetricsConfig,Ii(t,r),0,void 0,0,!0).execute()})),f}}(e);return{start:function(e){e||t.forEach((function(e){return e.start()})),n&&n.start()},stop:function(e){t.forEach((function(e){return e.stop()})),!e&&n&&n.stop()},isRunning:function(){return t.some((function(e){return e.isRunning()}))},execute:function(e){var r=e?[]:t.map((function(e){return e.execute()}));return n&&r.push(n.execute()),Promise.all(r).then((()=>{}))},isExecuting:function(){return t.some((function(e){return e.isExecuting()}))}}}var Di,Mi=600,Ki="PUSH_NONRETRYABLE_ERROR",xi="PUSH_RETRYABLE_ERROR",Pi="PUSH_SUBSYSTEM_UP",Ui="PUSH_SUBSYSTEM_DOWN",Bi="MEMBERSHIPS_MS_UPDATE",ji="MEMBERSHIPS_LS_UPDATE",qi="SEGMENT_UPDATE",zi="SPLIT_KILL",Wi="SPLIT_UPDATE",Gi="RB_SEGMENT_UPDATE",Hi="CONTROL",Qi="OCCUPANCY";function Vi(e){var t=e.userConsent;return!t||t===O}function Ji(e,t){return function(n){var r=n.settings,i=n.settings,s=i.log,o=i.streamingEnabled,a=i.sync.enabled,u=n.telemetryTracker,c=n.storage,l=n.readiness,f=e&&e(n),h=a&&o&&f&&t?t(n,f):void 0,p=Li(n);h&&(h.on(Pi,(function(){s.info(mt),f.isRunning()&&(f.stop(),u.streamingEvent(ve,Se)),f.syncAll()})),h.on(Ui,(function(){f.isRunning()?s.info(dt):(s.info(gt),f.start(),u.streamingEvent(ve,be))})));var g=!1,d=!0;return{pollingManager:f,pushManager:h,submitterManager:p,start:function(){return g=!0,p.start(!Vi(r)),Promise.resolve(!!c.validateCache&&c.validateCache()).then((function(e){g&&(d&&e&&l.splits.emit(gi),f&&(a?h?(d&&f.syncAll(),h.start()):f.start():d&&f.syncAll()),d=!1)}))},stop:function(){g=!1,h&&h.stop(),f&&f.isRunning()&&f.stop(),p.stop()},isRunning:function(){return g},flush:function(){return p.execute(!Vi(r))},shared:function(e,t,n){if(f){var r=f.add(e,t,n);return a&&h&&h.add(e,r),g&&(a?h?f.isRunning()?wr(n)&&r.start():r.execute():wr(n)&&r.start():t.isReady()||r.execute()),{stop:function(){var t=f.get(e);t&&(h&&h.remove(e),t.isRunning()&&t.stop(),f.remove(e))},flush:function(){return Promise.resolve()}}}}}}}!function(e){e.STREAMING_DISABLED="STREAMING_DISABLED",e.STREAMING_PAUSED="STREAMING_PAUSED",e.STREAMING_RESUMED="STREAMING_RESUMED",e.STREAMING_RESET="STREAMING_RESET"}(Di||(Di={}));var Yi=function(){function e(t,n,r){this.baseMillis=e.__TEST__BASE_MILLIS||n||e.DEFAULT_BASE_MILLIS,this.maxMillis=e.__TEST__MAX_MILLIS||r||e.DEFAULT_MAX_MILLIS,this.attempts=0,this.cb=t}return e.prototype.scheduleCall=function(){var e=this,t=Math.min(this.baseMillis*Math.pow(2,this.attempts),this.maxMillis);return this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout((function(){e.timeoutID=void 0,e.cb()}),t),this.attempts++,t},e.prototype.reset=function(){this.attempts=0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=void 0)},e.DEFAULT_BASE_MILLIS=1e3,e.DEFAULT_MAX_MILLIS=18e5,e}();var $i=[/control_pri$/,/control_sec$/],Zi=[10,20];function Xi(e,t,n){var r=function(e,t){var n=$i.map((function(e){return{regex:e,hasPublishers:!0,oTime:-1,cTime:-1}})),r=!0,i=!0;return{handleOpen:function(){t.streamingEvent(he),e.emit(Pi)},isStreamingUp:function(){return i&&r},handleOccupancyEvent:function(s,o,a){for(var u=0;uc.oTime){c.oTime=a,c.hasPublishers=0!==s;var l=n.some((function(e){return e.hasPublishers}));i&&(!l&&r?e.emit(Ui):l&&!r&&e.emit(Pi)),r=l}return}}},handleControlEvent:function(s,o,a){if(s!==Di.STREAMING_RESET)for(var u=0;uc.cTime&&(c.cTime=a,s===Di.STREAMING_DISABLED?(t.streamingEvent(pe,Te),e.emit(Ki)):r&&(s===Di.STREAMING_PAUSED&&i?(t.streamingEvent(pe,ke),e.emit(Ui)):s!==Di.STREAMING_RESUMED||i||(t.streamingEvent(pe,Re),e.emit(Pi))),i=s===Di.STREAMING_RESUMED))}else e.emit(s)}}}(t,n);return{handleOpen:function(){r.handleOpen()},handleError:function(r){var i=r;try{i=function(e){return l(e.data)&&(e.parsedData=JSON.parse(e.data)),e}(r)}catch(t){e.warn(_t,[t])}var s=i.parsedData&&i.parsedData.message||i.message;e.error(nn,[s]),!function(e){if(e.parsedData&&e.parsedData.code){var t=e.parsedData.code;if(n.streamingEvent(me,t),40140<=t&&t<=40149)return!0;if(4e4<=t&&t<=49999)return!1}else n.streamingEvent(ge,Ee);return!0}(i)?t.emit(Ki):t.emit(xi)},handleMessage:function(n){var i;try{if(i=function(e){if(e.data){var t=JSON.parse(e.data);return t.parsedData=JSON.parse(t.data),t.name&&"[meta]occupancy"===t.name&&(t.parsedData.type=Qi),t}}(n),!i)return}catch(t){return void e.warn(At,[t])}var s=i.parsedData,o=i.data,a=i.channel,u=i.timestamp;if(e.debug(We,[o]),r.isStreamingUp()||-1!==[Qi,Hi].indexOf(s.type))switch(s.type){case Wi:case qi:case Bi:case ji:case zi:case Gi:t.emit(s.type,s);break;case Qi:r.handleOccupancyEvent(s.metrics.publishers,a,u);break;case Hi:r.handleControlEvent(s.controlType,a,u)}}}}var es=1e4,ts=6e4,ns=10;function rs(e,t,n,r){var i,s,o;function a(t){var i,a,u,c=0,l=-1,f=!1,h=new Yi(p);function p(){if(i=!0,c>Math.max(l,t.getChangeNumber())){f=!1;var g=c;(s?new Promise((function(e){o=setTimeout((function(){s=void 0,n.execute(u,!0,a?c:void 0).then(e)}),s)})):n.execute(u,!0,a?c:void 0)).then((function(n){if(i){if(!1!==n){var s=t.getChangeNumber();l=s>-1?s:Math.max(l,g)}if(f)p();else{u&&r.trackUpdatesFromSSE(ne);var o=h.attempts+1;if(c<=l)return e.debug("Refresh completed"+(a?" bypassing the CDN":"")+" in "+o+" attempts."),void(i=!1);if(o(n.getChangeNumber(r)||-1)?(a=!1,t.execute(!1,r,!0,s?o:void 0).then((function(){if(i)if(a)c();else{var t=u.attempts+1;if(o<=(n.getChangeNumber(r)||-1))return e.debug("Refresh completed"+(s?" bypassing the CDN":"")+" in "+t+" attempts."),void(i=!1);if(t>>1|(21845&h)<<1;p=(61680&(p=(52428&p)>>>2|(13107&p)<<2))>>>4|(3855&p)<<4,f[h]=((65280&p)>>>8|(255&p)<<8)>>>1}var g=function(e,n,r){for(var i=e.length,s=0,o=new t(n);s>>c]=l}else for(a=new t(i),s=0;s>>15-e[s]);return a},d=new e(288);for(h=0;h<144;++h)d[h]=8;for(h=144;h<256;++h)d[h]=9;for(h=256;h<280;++h)d[h]=7;for(h=280;h<288;++h)d[h]=8;var m=new e(32);for(h=0;h<32;++h)m[h]=5;var v=g(d,9,1),y=g(m,5,1),S=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},b=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},E=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},T=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],R=function(e,t,n){var r=new Error(t||T[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,R),!n)throw r;return r},k=function(o,a,c){var f=o.length;if(!f||c&&c.f&&!c.l)return a||new e(0);var h=!a||c,p=!c||c.i;c||(c={}),a||(a=new e(3*f));var d=function(t){var n=a.length;if(t>n){var r=new e(Math.max(2*n,t));r.set(a),a=r}},m=c.f||0,T=c.p||0,k=c.b||0,C=c.l,w=c.d,N=c.m,_=c.n,A=8*f;do{if(!C){m=b(o,T,1);var I=b(o,T+1,3);if(T+=3,!I){var O=o[(q=4+((T+7)/8|0))-4]|o[q-3]<<8,F=q+O;if(F>f){p&&R(0);break}h&&d(k+O),a.set(o.subarray(q,F),k),c.b=k+=O,c.p=T=8*F,c.f=m;continue}if(1==I)C=v,w=y,N=9,_=5;else if(2==I){var L=b(o,T,31)+257,D=b(o,T+10,15)+4,M=L+b(o,T+5,31)+1;T+=14;for(var K=new e(M),x=new e(19),P=0;P>>4)<16)K[P++]=q;else{var W=0,G=0;for(16==q?(G=3+b(o,T,3),T+=2,W=K[P-1]):17==q?(G=3+b(o,T,7),T+=3):18==q&&(G=11+b(o,T,127),T+=7);G--;)K[P++]=W}}var H=K.subarray(0,L),Q=K.subarray(L);N=S(H),_=S(Q),C=g(H,N,1),w=g(Q,_,1)}else R(1);if(T>A){p&&R(0);break}}h&&d(k+131072);for(var V=(1<>>4;if((T+=15&W)>A){p&&R(0);break}if(W||R(2),$<256)a[k++]=$;else{if(256==$){Y=T,C=null;break}var Z=$-254;if($>264){var X=r[P=$-257];Z=b(o,T,(1<>>4;ee||R(3),T+=15ⅇQ=l[te];if(te>3){X=i[te];Q+=E(o,T)&(1<A){p&&R(0);break}h&&d(k+131072);for(var ne=k+Z;kr.length)&&(s=r.length);var o=new(r instanceof t?t:r instanceof n?n:e)(s-i);return o.set(r.subarray(i,s)),o}(a,0,k)};return{gunzipSync:function(t,n){return k(t.subarray(function(e){31==e[0]&&139==e[1]&&8==e[2]||R(6,"invalid gzip data");var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)}(t),-8),n||new e((i=(r=t).length,(r[i-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0)));var r,i},unzlibSync:function(e,t){return k(((8!=(15&(n=e)[0])||n[0]>>>4>7||(n[0]<<8|n[1])%31)&&R(6,"invalid zlib data"),32&n[1]&&R(6,"invalid zlib data: preset dictionaries not supported"),e.subarray(2,-4)),t);var n}}}(),os="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function as(e){var t=String(e).replace(/[=]+$/,"");if(t.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var n="",r=0,i=void 0,s=void 0,o=0;s=t.charAt(o++);~s&&(i=r%4?64*i+s:s,r++%4)?n+=String.fromCharCode(255&i>>(-2*r&6)):0)s=os.indexOf(s);return n}var us=String.fromCharCode;function cs(e){var t,n,r,i,s;return n=function(e){if("string"!=typeof e)throw TypeError("Illegal argument: "+typeof e);var t=0;return function(){return t>=e.length?null:e.charCodeAt(t++)}}(e),i=[],s=[],r=t=function(){if(0===arguments.length)return s.join("")+us.apply(String,i);i.length+arguments.length>1024&&(s.push(us.apply(String,i)),i.length=0),Array.prototype.push.apply(i,arguments)},function(e,t){for(var n,r=null;null!==(n=null!==r?r:e());)n>=55296&&n<=57343&&null!==(r=e())&&r>=56320&&r<=57343?(t(1024*(n-55296)+r-56320+65536),r=null):t(n);null!==r&&t(r)}(n,(function(e){!function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<128?t(127&n):n<2048?(t(n>>6&31|192),t(63&n|128)):n<65536?(t(n>>12&15|224),t(n>>6&63|128),t(63&n|128)):(t(n>>18&7|240),t(n>>12&63|128),t(n>>6&63|128),t(63&n|128)),n=null}(e,r)})),t()} -/*! - * +----------------------------------------------------------------------------------+ - * | murmurHash3.js v3.0.0 (http://github.com/karanlyons/murmurHash3.js) | - * | A TypeScript/JavaScript implementation of MurmurHash3's hashing algorithms. | - * |----------------------------------------------------------------------------------| - * | Copyright (c) 2012-2020 Karan Lyons. Freely distributable under the MIT license. | - * +----------------------------------------------------------------------------------+ - */function ls(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function fs(e,t){return e<>>32-t}function hs(e,t){t=t||0;for(var n,r=(e=e||"").length%4,i=e.length-r,s=t,o=0,a=3432918353,u=461845907,c=0;c>>16,2246822507),(s=(n=ls(n^=n>>>13,3266489909))^n>>>16)>>>0}function ps(e,t){return hs(cs(e),t>>>0)}function gs(e,t){return Math.abs(ps(e,t)%100)+1}var ds=1,ms=2;function vs(e,t){var n,r=as(e),i=(n=r.split("").map((function(e){return e.charCodeAt(0)})),new Uint8Array(n));if("string"==typeof ss)throw new Error(ss);if(t===ds)return ss.gunzipSync(i);if(t===ms)return ss.unzlibSync(i);throw new Error("Invalid compression algorithm #"+t)}function ys(e,t,n){void 0===n&&(n=!0);var r,i=vs(e,t),s=(r=i,String.fromCharCode.apply(null,r));return n&&(s=s.replace(/\d+/g,'"$&"')),JSON.parse(s)}var Ss=6e4;function bs(e,t){if(0===e.h)return 0;var n=e.i||Ss;return ps(t,e.s||0)%n}function Es(e,t,n,r,i,s){var o=u(t.splits),a=u(t.rbSegments);function u(t){var r,u,c,l=-1,f=!1,h=new Yi(p,es,ts);function p(){r=!0,l>t.getChangeNumber()?(f=!1,n.execute(!0,u?l:void 0,c).then((function(){if(r)if(f)p();else{c&&i.trackUpdatesFromSSE(J),s&&s.execute(!0);var t=h.attempts+1;if(o.isSync()&&a.isSync())return e.debug("Refresh completed"+(u?" bypassing the CDN":"")+" in "+t+" attempts."),void(r=!1);if(t0?ys(i,r,!1):JSON.parse(as(i)));if(n)return void(t.type===Gi?a:o).put(t,n)}catch(n){e.warn(Ht,[t.type,n])}var r,i;(t.type===Gi?a:o).put(t)},killSplit:function(e){var n=e.changeNumber,i=e.splitName,s=e.defaultTreatment;t.splits.killLocally(i,s,n)&&r.emit(pi,!0),o.put({changeNumber:n})},stop:function(){o.stop(),a.stop()}}}function Ts(e){return function(t){return e(t).then((function(e){return e.json()})).then((function(e){if(e.token){var t=(r=e.token,i=r.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(as(i).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join("")),JSON.parse(s));if("number"!=typeof t.iat||"number"!=typeof t.exp)throw new Error('token properties "issuedAt" (iat) or "expiration" (exp) are missing or invalid');var n=JSON.parse(t["x-ably-capability"]);return Vn({decodedToken:t,channels:n},e)}var r,i,s;return e}))}}function Rs(e){return function(e){for(var t=String(e),n="",r=void 0,i=void 0,s=0,o=os;t.charAt(0|s)||(o="=",s%1);n+=o.charAt(63&r>>8-s%1*8)){if((i=t.charCodeAt(s+=3/4))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|i}return n}(ps(e,0).toString())}var ks=/^control_/;var Cs,ws,Ns=function(){function e(e,t){var n=t.getEventSource,r=t.getOptions;if(this.settings=e,this.eventSource=n&&n(e),!this.eventSource)throw new Error("EventSource API is not available.");this.headers=function(e){var t={SplitSDKClientKey:l(e.core.authorizationKey)?e.core.authorizationKey.slice(-4):"",SplitSDKVersion:e.version},n=e.runtime,r=n.ip,i=n.hostname;return r&&(t.SplitSDKMachineIP=r),i&&(t.SplitSDKMachineName=i),t}(e),this.options=r&&r(e)}return e.prototype.setEventHandler=function(e){this.handler=e},e.prototype.open=function(e){var t;this.close();var n=Object.keys(e.channels).map((function(e){var t=ks.test(e)?"[?occupancy=metrics.publishers]":"";return encodeURIComponent(t+e)})).join(","),r=this.settings.urls.streaming+"/sse?channels="+n+"&accessToken="+e.token+"&v=1.1&heartbeats=true",i=xr(this.settings);this.connection=new this.eventSource(i?r:r+"&SplitSDKVersion="+this.headers.SplitSDKVersion+"&SplitSDKClientKey="+this.headers.SplitSDKClientKey,Vn(i?{headers:$r(this.settings,this.headers)}:(null===(t=this.settings.sync.requestOptions)||void 0===t?void 0:t.getHeaderOverrides)?{headers:$r(this.settings,{})}:{},this.options)),this.handler&&(this.connection.addEventListener("open",this.handler.handleOpen),this.connection.addEventListener("message",this.handler.handleMessage),this.connection.addEventListener("error",this.handler.handleError))},e.prototype.close=function(){this.connection&&this.connection.close()},e}();function _s(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var n=[0,0,0,0];return n[3]+=e[3]+t[3],n[2]+=n[3]>>>16,n[3]&=65535,n[2]+=e[2]+t[2],n[1]+=n[2]>>>16,n[2]&=65535,n[1]+=e[1]+t[1],n[0]+=n[1]>>>16,n[1]&=65535,n[0]+=e[0]+t[0],n[0]&=65535,[n[0]<<16|n[1],n[2]<<16|n[3]]}function As(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var n=[0,0,0,0];return n[3]+=e[3]*t[3],n[2]+=n[3]>>>16,n[3]&=65535,n[2]+=e[2]*t[3],n[1]+=n[2]>>>16,n[2]&=65535,n[2]+=e[3]*t[2],n[1]+=n[2]>>>16,n[2]&=65535,n[1]+=e[1]*t[3],n[0]+=n[1]>>>16,n[1]&=65535,n[1]+=e[2]*t[2],n[0]+=n[1]>>>16,n[1]&=65535,n[1]+=e[3]*t[1],n[0]+=n[1]>>>16,n[1]&=65535,n[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],n[0]&=65535,[n[0]<<16|n[1],n[2]<<16|n[3]]}function Is(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])}function Os(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=Fs(e=As(e,[4283543511,3981806797]),[0,e[0]>>>1]),e=Fs(e=As(e,[3301882366,444984403]),[0,e[0]>>>1])}function Ds(e,t){return function(e,t){t=t||0;for(var n=(e=e||"").length%16,r=e.length-n,i=[0,t],s=[0,t],o=[0,0],a=[0,0],u=[2277735313,289559509],c=[1291169091,658871167],l=0;l>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)+("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)}(cs(e),t>>>0)}function Ms(e){var t,n,r,i=[0];for(t=0;t=0;n-=1)i[n]=16*i[n]+r,r=i[n]/10|0,i[n]%=10;for(;r>0;)i.unshift(r%10),r=r/10|0}return i.join("")}function Ks(e,t){var n,r=e.settings,s=e.storage,o=e.splitApi,a=e.readiness,u=e.platform,c=e.telemetryTracker,l=xr(r)?void 0:Mr(r.core.key),f=r.log;try{n=new Ns(r,u)}catch(e){return void f.warn(It,[e])}var h=Ts(o.fetchAuth),p=new u.EventEmitter,g=Xi(f,p,c);n.setEventHandler(g);var d,m,v,y,S=l?void 0:is(f,t.segmentsSyncTask,s.segments),b=Es(f,s,t.splitsSyncTask,a.splits,c,l?void 0:t.segmentsSyncTask),E={},T={},R=!1,k=new Yi(C,r.scheduler.pushRetryBackoffBase);function C(){if(!d){f.info(ct),d=!1;var e=l?Object.keys(T):void 0;h(e).then((function(t){if(!d)return t.pushEnabled?void(e&&e.length=0?e.connDelay:60;f.info(at,[r,i]),v=setTimeout(C,1e3*r),y=setTimeout((function(){d||n.open(e)}),1e3*i),c.streamingEvent(de,t.exp)}(t)):(f.info(lt),void p.emit(Ki))})).catch((function(e){if(!d){if(f.error(rn,[e.message]),e.statusCode>=400&&e.statusCode<500)return c.streamingEvent(ye),void p.emit(Ki);p.emit(xi)}}))}}function w(){d||(d=!0,n.close(),f.info(ft),v&&clearTimeout(v),y&&clearTimeout(y),k.reset(),N())}function N(){b.stop(),l?i(T,(function(e){return e.worker.stop()})):S.stop()}function _(e){switch(e.u){case ws.BoundedFetchRequest:var t;try{o=e.d,a=e.c,t=vs(o,a)}catch(e){f.warn(Gt,["BoundedFetchRequest",e]);break}return void i(T,(function(n,r){var i,s,o,a,u=n.hash64,c=n.worker;i=t,s=u.hex,o=parseInt(s.slice(8),16)%(8*i.length),a=o%8,(i[Math.floor(o/8)]&1<0&&c.put(e,void 0,bs(e,r))}));case ws.KeyList:var n,r,s=void 0;try{s=ys(e.d,e.c),n=new Set(s.a),r=new Set(s.r)}catch(e){f.warn(Gt,["KeyList",e]);break}if(!e.n||!e.n.length){f.warn(Gt,["KeyList","No segment name was provided"]);break}return void i(T,(function(t){var i=t.hash64,s=t.worker,o=!!n.has(i.dec)||!r.has(i.dec)&&void 0;void 0!==o&&s.put(e,{added:o?[e.n[0]]:[],removed:o?[]:[e.n[0]]})}));case ws.SegmentRemoval:if(!e.n||!e.n.length){f.warn(Gt,["SegmentRemoval","No segment name was provided"]);break}return void i(T,(function(t){t.worker.put(e,{added:[],removed:e.n})}))}var o,a;i(T,(function(t,n){t.worker.put(e,void 0,bs(e,n))}))}return p.on(Ui,N),p.on(Pi,(function(){k.reset()})),p.on(Ki,(function(){m=!0,w(),p.emit(Ui)})),p.on(xi,(function(){n.close();var e=k.scheduleCall();f.info(ut,[e/1e3]),p.emit(Ui)})),p.on(Di.STREAMING_RESET,(function(){d||(v&&clearTimeout(v),C())})),p.on(zi,b.killSplit),p.on(Wi,b.put),p.on(Gi,b.put),l?(p.on(Bi,_),p.on(ji,_)):p.on(qi,S.put),Vn(Object.create(p),{stop:function(){w(),l&&this.remove(l)},start:function(){m||!1===d||(d=!1,l?this.add(l,t.segmentsSyncTask):setTimeout(C))},isRunning:function(){return!1===d},add:function(e,t){var n,r,i=Rs(e);E[i]||(E[i]=e,T[e]={hash64:(n=e,r=Ds(n).slice(0,16),{hex:r,dec:Ms(r)}),worker:rs(f,s,t,c)},R=!0,this.isRunning()&&setTimeout((function(){R&&(R=!1,C())}),0))},remove:function(e){var t=Rs(e);delete E[t],delete T[e]}})}function xs(e,t,n,r,i,s,o){var a=n.segments,u=n.largeSegments,c=!0,l=!0;function f(e){return l&&(e=Zr(i,e)),e}function h(e){var t;void 0!==e.type?t=e.type===ji?u.resetSegments(e):a.resetSegments(e):(t=a.resetSegments(e.ms||{}),t=u.resetSegments(e.ls||{})||t),n.save&&n.save(),wr(n)&&(t||c)&&(c=!1,r.emit(di))}function p(n,r,i,a){var u=r?new Promise((function(e){h(r),e(!0)})):t(o,i,a,f).then((function(e){return l=!1,h(e),!0}));return u.catch((function(t){return l&&s>n?(n+=1,e.warn(wt,[n,t]),p(n)):(l=!1,!1)}))}return function(e,t,n){return p(0,e,t,n)}}!function(e){e[e.None=0]="None",e[e.Gzip=1]="Gzip",e[e.Zlib=2]="Zlib"}(Cs||(Cs={})),function(e){e[e.UnboundedFetchRequest=0]="UnboundedFetchRequest",e[e.BoundedFetchRequest=1]="BoundedFetchRequest",e[e.KeyList=2]="KeyList",e[e.SegmentRemoval=3]="SegmentRemoval"}(ws||(ws={}));var Ps=36e5,Us=24*Ps;function Bs(e,t,n){var r,i=t.log,s=xr(t)?Us:Ps;return function o(a,u,c,l,f){r&&Date.now()-r>s&&(t.sync.flagSpecVersion=Ce);var h=e(a,u,c,t.sync.flagSpecVersion===Ce?l:void 0).catch((function(n){if((!n.statusCode||400===n.statusCode)&&function(e){return e.urls.sdk!==lr.urls.sdk}(t)&&t.sync.flagSpecVersion===Ce)return i.error(xn+"Proxy error detected. Retrying with spec 1.2. If you are using Split Proxy, please upgrade to latest version"),r=Date.now(),t.sync.flagSpecVersion="1.2",e(a,u,c);throw n}));return f&&(h=f(h)),h.then((function(e){return e.json()})).then((function(e){return e.splits?{ff:{d:e.splits,s:e.since,t:e.till}}:r?(i.info(xn+"Proxy error recovered"),r=void 0,o(-1,void 0,void 0,-1).then((function(e){return Promise.all([n.splits.clear(),n.rbSegments.clear()]).then((function(){return e}))}))):e}))}}function js(e,t){void 0===t&&(t=we);var n=e,r=n.conditions,i=void 0===r?[]:r,s=n.excluded,o=new Set;s&&s.segments&&s.segments.forEach((function(e){var n=e.type,r=e.name;(n===_e&&t===we||n===Ae&&t===Ne)&&o.add(r)}));for(var a=0;a0)return e.sets&&e.sets.some((function(e){return r.indexOf(e)>-1}));var o=i.length>0,a=s.length>0;if(!o&&!a)return!0;var u=o&&i.indexOf(e.name)>-1,c=a&&s.some((function(t){return p(e.name,t)}));return u||c}(r,n)?e.removed.push(r):(e.added.push(r),js(r).forEach((function(e){t.add(e)}))),e}),{added:[],removed:[]})}function zs(e,t,n,r,i,s,o,a){void 0===s&&(s=0),void 0===o&&(o=0);var u=n.splits,c=n.rbSegments,l=n.segments,f=!0;function h(e){return f&&s&&(e=Zr(s,e)),e}return function(s,p,g){return Promise.all([u.getChangeNumber(),c.getChangeNumber()]).then((function d(m,v){void 0===v&&(v=0);var y=m[0],S=m[1];return e.debug(je,m),Promise.resolve(g?g.type===Wi?Promise.resolve(c.contains(js(g.payload,Ne))).then((function(e){return e?{ff:{d:[g.payload],t:g.changeNumber}}:t(y,s,p,S,h)})):{rbs:{d:[g.payload],t:g.changeNumber}}:t(y,s,p,S,h)).then((function(t){f=!1;var s=new Set,o=!1;if(t.ff){var h=qs(t.ff.d,s,r),p=h.added,g=h.removed;e.debug(qe,[p.length,g.length]),o=u.update(p,g,t.ff.t)}var d=!1;if(t.rbs){var m=qs(t.rbs.d,s);p=m.added,g=m.removed;e.debug(ze,[p.length,g.length]),d=c.update(p,g,t.rbs.t)}return Promise.all([o,d,l.registerSegments(qr(s))]).then((function(e){var t=e[0],r=e[1];return n.save&&n.save(),!i||Promise.resolve(!i.splitsArrived||(t||r)&&(a||function(e){return Promise.resolve(e.getRegisteredSegments()).then((function(t){return Promise.all(t.map((function(t){return e.getChangeNumber(t)}))).then((function(e){return e.every((function(e){return void 0!==e}))}))}))}(l))).catch((function(){return!1})).then((function(e){return e&&i.emit(pi),!0}))}))})).catch((function(t){return e.warn(Nt,[t]),f&&o>v?(v+=1,e.info(ot,[v,t]),d(m,v)):(f=!1,!1)}))}))}}function Ws(e){var t=e.splitApi,n=e.storage,r=e.readiness,s=e.settings,o=s.log,a=function(e,t,n,r,i){return ii(r.log,zs(r.log,Bs(e,r,t),t,r.sync.__splitFiltersValidation,n.splits,r.startup.requestTimeoutBeforeReady,r.startup.retriesOnFailureBeforeReady,i),r.scheduler.featuresRefreshRate,"splitChangesUpdater")}(t.fetchSplitChanges,n,r,s,!0),u={},c=h(Mr(s.core.key),r,n);function l(){i(u,(function(e){e.start()}))}function f(){i(u,(function(e){e.isRunning()&&e.stop()}))}function h(e,n,r){var i=function(e,t,n,r,i){return ii(r.log,xs(r.log,function(e){return function(t,n,r,i){var s=e(t,n,r);return i&&(s=i(s)),s.then((function(e){return e.json()}))}}(e),t,n.segments,r.startup.requestTimeoutBeforeReady,r.startup.retriesOnFailureBeforeReady,i),r.scheduler.segmentsRefreshRate,"mySegmentsUpdater")}(t.fetchMemberships,r,n,s,e);function o(){n.isReady()||wr(r)||n.segments.emit(di)}return wr(r)?n.splits.once(pi,o):setTimeout(o,0),u[e]=i,i}return r.splits.on(pi,(function(){if(a.isRunning()){var e=wr(n);e!==c.isRunning()&&(o.info(rt,[e?"ON":"OFF"]),e?l():f())}})),{splitsSyncTask:a,segmentsSyncTask:c,start:function(){o.info(it),a.start(),wr(n)&&l()},stop:function(){o.info(st),a.isRunning()&&a.stop(),f()},isRunning:a.isRunning,syncAll:function(){var e=[a.execute()];return i(u,(function(t){e.push(t.execute())})),Promise.all(e)},add:h,remove:function(e){delete u[e]},get:function(e){return u[e]}}}function Gs(e){return null!=e&&"function"==typeof e.then}function Hs(e,t,n){return null==t||c(t)?t:(e.error(cn,[n,"attributes"]),!1)}function Qs(e,t,n){if(!Hs(e,t,n))return!1;var r=!0;return Object.keys(t).forEach((function(i){(function(e,t,n,r){if(!l(t)||0===t.length)return e.warn(r+": you passed an invalid attribute name, attribute name must be a non-empty string."),!1;var i=l(n),s=a(n),u=o(n),c=Array.isArray(n);return!!(i||s||u||c)||(e.warn(r+": you passed an invalid attribute value for "+t+". Acceptable types are: string, number, boolean and array of strings."),!1)})(e,i,t[i],n)||(r=!1)})),r}var Vs=/^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/,Js="event_type";var Ys={NULL:0,STRING:2,BOOLEAN:4,NUMBER:8},$s=300,Zs=32768,Xs=1024;function eo(e,t,n){if(null==t)return{properties:null,size:Xs};if(!c(t))return e.error(cn,[n,"properties"]),{properties:!1,size:Xs};var r=Object.keys(t),i=Vn({},t),s={properties:i,size:Xs};r.length>$s&&e.warn(Dt,[n]);for(var u=0;uZs){e.error(ln,[n]),s.properties=!1;break}}return s}var to=/[A-Z]/,no="traffic_type";function ro(e,t,n){return!t.isDestroyed()||(e.error(hn,[n]),!1)}function io(e,t,n,r){return!!t.isReadyFromCache()||(e.warn(Ct,[n,r?" for feature flag "+r.toString():""]),!1)}function so(e,t,n,r){return ro(e,t,n)&&io(e,t,n,r)}var oo="fallback - ",ao=function(){function e(e){void 0===e&&(e={}),this.fallbacks=e}return e.prototype.resolve=function(e,t){var n,r=null===(n=this.fallbacks.byFlag)||void 0===n?void 0:n[e];return r?this.copyWithLabel(r,t):this.fallbacks.global?this.copyWithLabel(this.fallbacks.global,t):{treatment:v,config:null,label:t}},e.prototype.copyWithLabel=function(e,t){return l(e)?{treatment:e,config:null,label:""+oo+t}:{treatment:e.treatment,config:e.config,label:""+oo+t}},e}(),uo="killed",co="default rule",lo="definition not found",fo="not ready",ho="exception",po="archived",go="not in split",mo="targeting rule type unsupported by sdk",vo="prerequisites not met",yo=oo+lo;function So(e,t,n,r,i){return!t.isReady()||r!==lo&&r!==yo&&null!=r||(e.warn(xt,[i,n]),!1)}function bo(e,t,n){e.warn(Ut,[n,t])}function Eo(e){var t=e.conditions,r=n(t,(function(e){return"ROLLOUT"===e.conditionType}));return r||(r=t[0]),r?r.partitions.map((function(e){return e.treatment})):[]}function To(e){return e?{name:e.name,trafficType:e.trafficTypeName,killed:e.killed,changeNumber:e.changeNumber||0,treatments:Eo(e),configs:e.configurations||{},sets:e.sets||[],defaultTreatment:e.defaultTreatment,impressionsDisabled:!0===e.impressionsDisabled,prerequisites:(e.prerequisites||[]).map((function(e){return{flagName:e.n,treatments:e.ts}}))}:null}function Ro(e){var t=[];return e.forEach((function(e){var n=To(e);n&&t.push(n)})),t}function ko(e,t,n){var r=n.readinessManager,i=n.sdkStatus,s=e.log,o=Ie(e.mode);return Vn(Object.create(i),{split:function(e){var n=Hn(s,e,z);if(!so(s,r,z)||!n)return o?Promise.resolve(null):null;var i=t.getSplit(n);return Gs(i)?i.catch((function(){return null})).then((function(e){return So(s,r,n,e,z),To(e)})):(So(s,r,n,i,z),To(i))},splits:function(){if(!so(s,r,W))return o?Promise.resolve([]):[];var e=t.getAll();return Gs(e)?e.catch((function(){return[]})).then(Ro):Ro(e)},names:function(){if(!so(s,r,G))return o?Promise.resolve([]):[];var e=t.getSplitNames();return Gs(e)?e.catch((function(){return[]})):e}})}var Co=function(){function e(){this.attributesCache={}}return e.prototype.setAttribute=function(e,t){return this.attributesCache[e]=t,!0},e.prototype.getAttribute=function(e){return this.attributesCache[e]},e.prototype.setAttributes=function(e){return this.attributesCache=Vn(this.attributesCache,e),!0},e.prototype.getAll=function(){return this.attributesCache},e.prototype.removeAttribute=function(e){return Object.keys(this.attributesCache).indexOf(e)>=0&&(delete this.attributesCache[e],!0)},e.prototype.clear=function(){return this.attributesCache={},!0},e}();function wo(e,t,n){var r=function(e,t){var n=new Co,r=t.getTreatment,i=t.getTreatmentWithConfig,s=t.getTreatments,o=t.getTreatmentsWithConfig,a=t.getTreatmentsByFlagSets,u=t.getTreatmentsWithConfigByFlagSets,c=t.getTreatmentsByFlagSet,l=t.getTreatmentsWithConfigByFlagSet;function f(e){var t=n.getAll();return Object.keys(t).length>0?Vn({},t,e):e}return Vn(t,{getTreatment:function(e,t,n,i){return r(e,t,f(n),i)},getTreatmentWithConfig:function(e,t,n,r){return i(e,t,f(n),r)},getTreatments:function(e,t,n,r){return s(e,t,f(n),r)},getTreatmentsWithConfig:function(e,t,n,r){return o(e,t,f(n),r)},getTreatmentsByFlagSets:function(e,t,n,r){return a(e,t,f(n),r)},getTreatmentsWithConfigByFlagSets:function(e,t,n,r){return u(e,t,f(n),r)},getTreatmentsByFlagSet:function(e,t,n,r){return c(e,t,f(n),r)},getTreatmentsWithConfigByFlagSet:function(e,t,n,r){return l(e,t,f(n),r)},setAttribute:function(t,r){var i={};return i[t]=r,!!Qs(e,i,"setAttribute")&&(e.debug("stored "+r+" for attribute "+t),n.setAttribute(t,r))},getAttribute:function(t){return e.debug("retrieved attribute "+t),n.getAttribute(t+"")},setAttributes:function(t){return!!Qs(e,t,"setAttributes")&&n.setAttributes(t)},getAttributes:function(){return n.getAll()},removeAttribute:function(t){return e.debug("removed attribute "+t),n.removeAttribute(t+"")},clearAttributes:function(){return n.clear()}})}(e,t);return Vn(r,{getTreatment:r.getTreatment.bind(r,n),getTreatmentWithConfig:r.getTreatmentWithConfig.bind(r,n),getTreatments:r.getTreatments.bind(r,n),getTreatmentsWithConfig:r.getTreatmentsWithConfig.bind(r,n),getTreatmentsByFlagSets:r.getTreatmentsByFlagSets.bind(r,n),getTreatmentsWithConfigByFlagSets:r.getTreatmentsWithConfigByFlagSets.bind(r,n),getTreatmentsByFlagSet:r.getTreatmentsByFlagSet.bind(r,n),getTreatmentsWithConfigByFlagSet:r.getTreatmentsWithConfigByFlagSet.bind(r,n),track:r.track.bind(r,n),isClientSide:!0,key:n})}var No={UNDEFINED:0,ALL_KEYS:1,IN_SEGMENT:2,WHITELIST:3,EQUAL_TO:4,GREATER_THAN_OR_EQUAL_TO:5,LESS_THAN_OR_EQUAL_TO:6,BETWEEN:7,EQUAL_TO_SET:8,CONTAINS_ANY_OF_SET:9,CONTAINS_ALL_OF_SET:10,PART_OF_SET:11,ENDS_WITH:12,STARTS_WITH:13,CONTAINS_STRING:14,IN_SPLIT_TREATMENT:15,EQUAL_TO_BOOLEAN:16,MATCHES_STRING:17,EQUAL_TO_SEMVER:18,GREATER_THAN_OR_EQUAL_TO_SEMVER:19,LESS_THAN_OR_EQUAL_TO_SEMVER:20,BETWEEN_SEMVER:21,IN_LIST_SEMVER:22,IN_LARGE_SEGMENT:23,IN_RULE_BASED_SEGMENT:24},_o={BOOLEAN:"BOOLEAN",STRING:"STRING",NUMBER:"NUMBER",SET:"SET",DATETIME:"DATETIME",NOT_SPECIFIED:"NOT_SPECIFIED"};function Ao(e){return e?e.segmentName||e.largeSegmentName:void 0}function Io(e){return e&&e.whitelist}function Oo(e){return e.value}function Fo(e){return new Date(e).setUTCHours(0,0,0,0)}function Lo(e){return new Date(e).setUTCSeconds(0,0)}function Do(e){var t=e.map((function(e){var t,n=e.matcherType,r=e.negate,i=e.keySelector,s=e.userDefinedSegmentMatcherData,o=e.userDefinedLargeSegmentMatcherData,a=e.whitelistMatcherData,u=e.unaryNumericMatcherData,c=e.betweenMatcherData,l=e.dependencyMatcherData,f=e.booleanMatcherData,h=e.stringMatcherData,p=e.betweenStringMatcherData,g=i&&i.attribute,d=function(e){var t=No[e];return t||No.UNDEFINED}(n),m=_o.STRING;return d===No.IN_SEGMENT?t=Ao(s):d===No.IN_LARGE_SEGMENT?t=Ao(o):d===No.EQUAL_TO?(t=Oo(u),m=_o.NUMBER,"DATETIME"===u.dataType&&(t=Fo(t),m=_o.DATETIME)):d===No.GREATER_THAN_OR_EQUAL_TO||d===No.LESS_THAN_OR_EQUAL_TO?(t=Oo(u),m=_o.NUMBER,"DATETIME"===u.dataType&&(t=Lo(t),m=_o.DATETIME)):d===No.BETWEEN?(t=c,m=_o.NUMBER,"DATETIME"===t.dataType&&(t=function(e){return{dataType:e.dataType,start:Lo(e.start),end:Lo(e.end)}}(t),m=_o.DATETIME)):d===No.BETWEEN_SEMVER?t=p:d===No.EQUAL_TO_SET||d===No.CONTAINS_ANY_OF_SET||d===No.CONTAINS_ALL_OF_SET||d===No.PART_OF_SET?(t=Io(a),m=_o.SET):d===No.WHITELIST||d===No.IN_LIST_SEMVER||d===No.STARTS_WITH||d===No.ENDS_WITH||d===No.CONTAINS_STRING?t=Io(a):d===No.IN_SPLIT_TREATMENT?(t=l,m=_o.NOT_SPECIFIED):d===No.EQUAL_TO_BOOLEAN?(m=_o.BOOLEAN,t=f):d===No.MATCHES_STRING||d===No.EQUAL_TO_SEMVER||d===No.GREATER_THAN_OR_EQUAL_TO_SEMVER||d===No.LESS_THAN_OR_EQUAL_TO_SEMVER?t=h:d===No.IN_RULE_BASED_SEGMENT&&(t=Ao(s),m=_o.NOT_SPECIFIED),{attribute:g,negate:r,type:d,name:n,value:t,dataType:m}}));return-1===r(t,(function(e){return e.type===No.UNDEFINED}))?t:[]}var Mo=function(){function e(e,t){if(100!==e[e.length-1])throw new RangeError("Provided invalid dataset as input");this._ranges=e,this._treatments=t}return e.parse=function(t){var n=t.reduce((function(e,t){var n=t.size,r=t.treatment;return e.ranges.push(e.inc+=n),e.treatments.push(r),e}),{inc:0,ranges:[],treatments:[]});return new e(n.ranges,n.treatments)},e.prototype.getTreatmentFor=function(e){if(e<0||e>100)throw new RangeError("Please provide a value between 0 and 100");var t=r(this._ranges,(function(t){return e<=t}));return this._treatments[t]},e}();var Ko=/^[0-9]+$/,xo=".";function Po(e,t){if(Ko.test(e)&&Ko.test(t)){var n=e.length-t.length;if(0!==n)return n}return et?1:0}function Uo(e){return e.replace(/^0+(?=\d)/,"")}function Bo(e){throw new Error("Unable to convert to Semver, incorrect format: "+e)}var jo=function(){function e(e){l(e)||Bo(e);var t=e.indexOf("+"),n=-1===t?[e]:[e.slice(0,t),e.slice(t+1)],r=n[0],i=n[1];""===i&&Bo(e),-1===(t=r.indexOf("-"))?(this._isStable=!0,this._preRelease=[]):(this._isStable=!1,this._preRelease=r.slice(t+1).split(xo).map((function(t){return t||Bo(e),Ko.test(t)?Uo(t):t})),r=r.slice(0,t));var s=r.split(xo).map((function(t){return t&&Ko.test(t)||Bo(e),Uo(t)}));3!==s.length&&Bo(e),this._major=s[0],this._minor=s[1],this._patch=s[2],this.version=s.join(xo),this._preRelease.length&&(this.version+="-"+this._preRelease.join(xo)),i&&(this.version+="+"+i)}return e.prototype.compare=function(e){if(this.version===e.version)return 0;var t=Po(this._major,e._major);if(0!==t)return t;if(0!==(t=Po(this._minor,e._minor)))return t;if(0!==(t=Po(this._patch,e._patch)))return t;if(!this._isStable&&e._isStable)return-1;if(this._isStable&&!e._isStable)return 1;for(var n=0,r=Math.min(this._preRelease.length,e._preRelease.length);n=e}},function(e){return function(t){return t<=e}},function(e){return function(t){return t>=e.start&&t<=e.end}},function(e){return function(t){for(var n=t.length===e.length,i=function(i){r(e,(function(e){return e===t[i]}))<0&&(n=!1)},s=0;s=0&&(n=!0)},s=0;s-1}))}},function(e,t,n){var r=e.split,i=e.treatments;function s(e,t,r){var i=!1;return Array.isArray(t)&&(i=-1!==t.indexOf(e.treatment)),n.debug(10,[r,e.treatment,e.label,r,t,i]),i}return function(e,o){var a=e.key,u=e.attributes;n.debug(11,[r,JSON.stringify(a),u?"\n attributes: "+JSON.stringify(u):""]);var c=o(n,a,r,u,t);return Gs(c)?c.then((function(e){return s(e,i,r)})):s(c,i,r)}},function(e){return function(t){return e===t}},function(e){var t=new RegExp(e);return function(e){return t.test(e)}},function(e){var t=new jo(e);return function(e){var n=new jo(e);return t.version===n.version}},function(e){var t=new jo(e);return function(e){return new jo(e).compare(t)>=0}},function(e){var t=new jo(e);return function(e){return new jo(e).compare(t)<=0}},function(e){var t=new jo(e.start),n=new jo(e.end);return function(e){var r=new jo(e);return t.compare(r)<=0&&n.compare(r)>=0}},function(e){if(!e||0===e.length)throw new Error("whitelistMatcherData is required for IN_LIST_SEMVER matcher type");var t=new Set(e.map((function(e){return new jo(e).version})));return function(e){var n=new jo(e).version;return t.has(n)}},function(e,t){return function(n){return!!t.largeSegments&&t.largeSegments.isInSegment(e,n)}},function e(t,n,r){return function(i,s){var o=i.key,a=i.attributes,u=Mr(o);function c(e){var t=e.conditions||[];if(!t.length)return!1;var i=$o(r,t,n)(Kr(o),void 0,void 0,void 0,a,s);return Gs(i)?i.then((function(e){return!!e})):!!i}function l(t){var i=t.type,c=t.name;return i===_e?n.segments.isInSegment(c,u):i===Ae?e(c,n,r)({key:o,attributes:a},s):!("large"!==i||!n.largeSegments)&&n.largeSegments.isInSegment(c,u)}function f(e){if(!e)return!1;var t=function(e){var t=e.excluded||{};return!(!t.keys||-1===t.keys.indexOf(u))||(t.segments||[]).reduce((function(e,t){return Gs(e)?e.then((function(e){return e||l(t)})):e||l(t)}),!1)}(e);return Gs(t)?t.then((function(t){return!t&&c(e)})):!t&&c(e)}var h=n.rbSegments.get(t);return Gs(h)?h.then(f):f(h)}}];function zo(e,t,n){var r,i=t.type,s=t.value;return qo[i]&&(r=qo[i](s,n,e)),r}function Wo(e,t){return{key:e,attributes:t}}function Go(e,t,n,r,i){var s,o,a=function(e,t){switch(e){case No.EQUAL_TO:return"DATETIME"===t?Fo:void 0;case No.GREATER_THAN_OR_EQUAL_TO:case No.LESS_THAN_OR_EQUAL_TO:case No.BETWEEN:return"DATETIME"===t?Lo:void 0;case No.IN_SPLIT_TREATMENT:case No.IN_RULE_BASED_SEGMENT:return Wo;default:return}}(t,r);switch(r){case _o.NUMBER:case _o.DATETIME:o=g(n),s=isNaN(o)?void 0:o;break;case _o.STRING:s=function(e){var t=e;return c(e)&&(t=e.matchingKey?e.matchingKey:void 0),d(t)||void 0}(n);break;case _o.SET:s=function(e){var t=Array.isArray(e)?m(e.map((function(e){return e+""}))):[];return t.length?t:void 0}(n);break;case _o.BOOLEAN:s=function(e){if(!0===e||!1===e)return e;if("string"==typeof e){var t=e.toLocaleLowerCase();if("true"===t)return!0;if("false"===t)return!1}}(n);break;case _o.NOT_SPECIFIED:s=n;break;default:s=void 0}return a&&(s=a(s,i)),e.debug(Ke,[n,r,s instanceof Object?JSON.stringify(s):s]),s}function Ho(e,t,n,r){var i=n.attribute,s=function(e,t,n,r){var i=void 0;return n?r?(i=r[n],e.debug(Me,[n,i])):e.warn(Rt,[n]):i=t,i}(e,t,i,r),o=Go(e,n.type,s,n.dataType,r);return void 0!==o?o:void e.warn(Tt,[s+(i?" for attribute "+i:"")])}function Qo(e,t,n,r){var i=gs(t,n),s=r.getTreatmentFor(i);return e.debug(De,[i,t,n,s]),s}function Vo(e,t,n,r,i,s){if(t)return!i||{treatment:Qo(e,n,r,i),label:s}}function Jo(e,t,n,r,i){return function(s,o,a,u,c,l){if("ROLLOUT"===i&&!function(e,t,n){return!(e<100&&gs(t,n)>e)}(a,s.bucketingKey,u))return{treatment:void 0,label:go};var f=t(s,c,l);return Gs(f)?f.then((function(t){return Vo(e,t,s.bucketingKey,o,n,r)})):Vo(e,f,s.bucketingKey,o,n,r)}}function Yo(e,t){function n(t){var n=t.every((function(e){return e}));return e.debug(Oe,[n]),n}return function(e,i,s){var o=t.map((function(t){return t(e,i,s)}));return-1!==r(o,Gs)?Promise.all(o).then(n):n(o)}}function $o(e,t,n){for(var i=[],s=0;s0?Promise.all(a).then((function(){return o})):o}var oa={treatment:v,label:fo};function aa(e){var t={};return e.forEach((function(e){t[e]=oa})),t}function ua(e){if(e&&e.properties)try{return JSON.stringify(e.properties)}catch(e){}}function ca(e){var t=e.sdkReadinessManager.readinessManager,n=e.storage,r=e.settings,i=e.impressionsTracker,s=e.eventTracker,o=e.telemetryTracker,a=e.fallbackTreatmentsCalculator,u=r.log,l=r.mode,f=Ie(l);function h(e,r,s,a,c,l){void 0===c&&(c=!1),void 0===l&&(l=D);var h=o.trackEval(c?se:re),p=function(t){var n=[],o=d(t,r,e,ua(a),c,l,n);return i.track(n,s),h(n[0]&&n[0].imp.label),o},g=t.isReadyFromCache()?na(u,e,r,s,n):f?Promise.resolve(oa):oa;return Gs(g)?g.then((function(e){return p(e)})):p(g)}function p(e,r,s,a,c,l){void 0===c&&(c=!1),void 0===l&&(l=M);var h=o.trackEval(c?oe:ie),p=function(t){var n=[],r={},o=ua(a);return Object.keys(t).forEach((function(i){r[i]=d(t[i],i,e,o,c,l,n)})),i.track(n,s),h(n[0]&&n[0].imp.label),r},g=t.isReadyFromCache()?ra(u,e,r,s,n):f?Promise.resolve(aa(r)):aa(r);return Gs(g)?g.then((function(e){return p(e)})):p(g)}function g(e,r,s,a,c,l,h){void 0===c&&(c=!1),void 0===l&&(l=ue),void 0===h&&(h=U);var p=o.trackEval(l),g=function(t){var n=[],r={},o=ua(a);return Object.keys(t).forEach((function(i){r[i]=d(t[i],i,e,o,c,h,n)})),i.track(n,s),p(n[0]&&n[0].imp.label),r},m=t.isReadyFromCache()?function(e,t,n,r,i,s){var o;function a(o){for(var a,u=new Set,c=0;c-1?function(e,t,n,r){var i=Qn(e,n,t,"flag sets","flag set"),s=i?Zn(e,i,t):[];return r.length>0&&(s=s.filter((function(n){return r.indexOf(n)>-1||(e.warn(Jt,[t,n]),!1)}))),!!s.length&&s}(i,t,s,e.sync.__splitFiltersValidation.groupedFilters.bySet):p(t,M)?Qn(i,s,t):Hn(i,s,t),f=Hs(i,o,t),h=ro(i,n,t),g=function(e,t,n){if(c(t)){var r=eo(e,t.properties,n).properties;return r&&Object.keys(r).length>0?{properties:r}:void 0}t&&e.error(cn,[n,"evaluation options"])}(i,a,t);return io(i,n,t,l),{valid:h&&u&&l&&!1!==f,key:u,nameOrNames:l,attributes:f,options:g}}function u(e,t){var n=r.resolve(e,""),i=n.treatment,s=n.config;return t?{treatment:i,config:s}:i}function f(e){return s?Promise.resolve(e):e}return{getTreatment:function(e,n,r,i){var s=o(D,e,n,r,i);return s.valid?t.getTreatment(s.key,s.nameOrNames,s.attributes,s.options):f(u(s.nameOrNames,!1))},getTreatmentWithConfig:function(e,n,r,i){var s=o(K,e,n,r,i);return s.valid?t.getTreatmentWithConfig(s.key,s.nameOrNames,s.attributes,s.options):f(u(s.nameOrNames,!0))},getTreatments:function(e,n,r,i){var s=o(M,e,n,r,i);if(s.valid)return t.getTreatments(s.key,s.nameOrNames,s.attributes,s.options);var a={};return s.nameOrNames&&s.nameOrNames.forEach((function(e){return a[e]=u(e,!1)})),f(a)},getTreatmentsWithConfig:function(e,n,r,i){var s=o(x,e,n,r,i);if(s.valid)return t.getTreatmentsWithConfig(s.key,s.nameOrNames,s.attributes,s.options);var a={};return s.nameOrNames&&s.nameOrNames.forEach((function(e){return a[e]=u(e,!0)})),f(a)},getTreatmentsByFlagSets:function(e,n,r,i){var s=o(U,e,n,r,i);return s.valid?t.getTreatmentsByFlagSets(s.key,s.nameOrNames,s.attributes,s.options):f({})},getTreatmentsWithConfigByFlagSets:function(e,n,r,i){var s=o(j,e,n,r,i);return s.valid?t.getTreatmentsWithConfigByFlagSets(s.key,s.nameOrNames,s.attributes,s.options):f({})},getTreatmentsByFlagSet:function(e,n,r,i){var s=o(P,e,[n],r,i);return s.valid?t.getTreatmentsByFlagSet(s.key,s.nameOrNames[0],s.attributes,s.options):f({})},getTreatmentsWithConfigByFlagSet:function(e,n,r,i){var s=o(B,e,[n],r,i);return s.valid?t.getTreatmentsWithConfigByFlagSet(s.key,s.nameOrNames[0],s.attributes,s.options):f({})},track:function(e,r,o,u,c){var f=ir(i,e,q),h=function(e,t,n){if(null==t)e.error(pn,[n,no]);else if(l(t)){if(0!==t.length)return to.test(t)&&(e.warn(Pt,[n]),t=t.toLowerCase()),t;e.error(vn,[n,no])}else e.error(mn,[n,no]);return!1}(i,r,q),p=function(e,t,n){if(null==t)e.error(pn,[n,Js]);else if(l(t))if(0===t.length)e.error(vn,[n,Js]);else{if(Vs.test(t))return t;e.error(un,[n,t])}else e.error(mn,[n,Js]);return!1}(i,o,q),g=function(e,t,n){return a(t)||null==t?t:(e.error(fn,[n]),!1)}(i,u,q),d=eo(i,c,q),m=d.properties,v=d.size;return ro(i,n,q)&&f&&h&&p&&!1!==g&&!1!==m?t.track(f,h,p,g,m,v):!!s&&Promise.resolve(!1)}}}var fa=1e3;function ha(e,t){var n=e.sdkReadinessManager,r=e.syncManager,i=e.storage,s=e.signalListener,o=e.settings,a=e.telemetryTracker,u=e.uniqueKeysTracker,c=0;function l(){return r?r.flush():Promise.resolve()}return Vn(Object.create(n.sdkStatus),la(o,ca(e),n.readinessManager,e.fallbackTreatmentsCalculator),{flush:function(){return function(e,t){var n=Date.now(),r=n-c;return ra?e:a+1}var c=!1;n.splitsCacheLoaded?c=!0:n.once(gi,(function(){if(c=!0,!h&&!g)try{u(),o.emit(yi,h)}catch(e){setTimeout((function(){throw e}),0)}}));var l=!1;function f(){l||h||(l=!0,u(),o.emit(mi,"Split SDK emitted SDK_READY_TIMED_OUT event."))}var h=!1;n.on(pi,m),s.on(di,m);var p,g=!1;function d(){g=!1,i>0&&!h&&(p=setTimeout(f,i))}function m(e){if(!g)if(h)try{u(),o.emit(Si,e)}catch(e){setTimeout((function(){throw e}),0)}else if(n.splitsArrived&&s.segmentsArrived){clearTimeout(p),h=!0;try{u(),c||(c=!0,o.emit(yi,h)),o.emit(vi)}catch(e){setTimeout((function(){throw e}),0)}}}return n.initCallbacks.push(d),n.hasInit&&d(),{splits:n,segments:s,gate:o,shared:function(){return xa(e,t,n,!0)},timeout:f,setDestroyed:function(){g=!0},init:function(){n.hasInit||(n.hasInit=!0,n.initCallbacks.forEach((function(e){return e()})))},destroy:function(){g=!0,u(),clearTimeout(p),r||(n.hasInit=!1)},isReady:function(){return h},isReadyFromCache:function(){return c},isTimedout:function(){return l&&!h},hasTimedout:function(){return l},isDestroyed:function(){return g},isOperational:function(){return(h||c)&&!g},lastUpdate:function(){return a}}}var Pa="newListener",Ua="removeListener",Ba=new Error(mi);function ja(e,t,n){void 0===n&&(n=xa(e,t));var r=t.log,i=0,s=0;n.gate.on(Ua,(function(e){e===vi&&s--})),n.gate.on(Pa,(function(e){e===vi||e===mi?n.isReady()?r.error(Xt,[e===vi?"SDK_READY":"SDK_READY_TIMED_OUT"]):e===vi&&s++:e===yi&&n.isReadyFromCache()&&r.error(Xt,["SDK_READY_FROM_CACHE"])}));var o,a=o=Ka(new Promise((function(e,t){n.gate.once(vi,(function(){r.info(Ze),s!==i||o.hasOnFulfilled()||r.warn(kt),e()})),n.gate.once(mi,(function(e){t(new Error(e))}))})),u);function u(e){r.error(e&&e.message)}function c(){return{isReady:n.isReady(),isReadyFromCache:n.isReadyFromCache(),isTimedout:n.isTimedout(),hasTimedout:n.hasTimedout(),isDestroyed:n.isDestroyed(),isOperational:n.isOperational(),lastUpdate:n.lastUpdate()}}return n.gate.once(yi,(function(){r.info($e)})),{readinessManager:n,shared:function(){return ja(e,t,n.shared())},incInternalReadyCbCount:function(){i++},sdkStatus:Vn(Object.create(n.gate),{Event:{SDK_READY:vi,SDK_READY_FROM_CACHE:yi,SDK_UPDATE:Si,SDK_READY_TIMED_OUT:mi},ready:function(){return n.hasTimedout()?n.isReady()?Promise.resolve():Ka(Promise.reject(new Error("Split SDK has emitted SDK_READY_TIMED_OUT event.")),u):a},whenReady:function(){return new Promise((function(e,t){n.isReady()?e():n.hasTimedout()?t(Ba):(n.gate.once(vi,e),n.gate.once(mi,(function(){return t(Ba)})))}))},whenReadyFromCache:function(){return new Promise((function(e,t){n.isReadyFromCache()?e(n.isReady()):n.hasTimedout()?t(Ba):(n.gate.once(yi,(function(){return e(n.isReady())})),n.gate.once(mi,(function(){return t(Ba)})))}))},getStatus:c,__getStatus:c})}}function qa(e){function t(t){vr(t)?e.setLogLevel(t):e.error(Zt)}return{enable:function(){t(gr.DEBUG)},setLogLevel:t,setLogger:function(t){e.setLogger(t)},disable:function(){t(gr.NONE)},LogLevel:gr}}var za={add:function(){return!0},contains:function(){return!0},clear:function(){}};function Wa(e){var t=e.settings,n=e.platform,r=e.storageFactory,i=e.splitApiFactory,s=e.extraProps,o=e.syncManagerFactory,a=e.SignalListener,u=e.impressionsObserverFactory,c=e.integrationsManagerFactory,l=e.sdkManagerFactory,f=e.sdkClientMethodFactory,h=e.filterAdapterFactory,p=e.lazyInit,g=t.log,d=t.sync.impressionsMode,m=t.initialRolloutPlan,v=t.core.key,y=!1,S=[];function T(e){y?e():S.push(e)}var R=ja(n.EventEmitter,t),k=R.readinessManager,C=r({settings:t,onReadyCb:function(e){e?k.timeout():(k.splits.emit(pi),k.segments.emit(di))},onReadyFromCacheCb:function(){k.splits.emit(gi)}}),w=new ao(t.fallbackTreatments);m&&(sr(g,m,C,v&&Mr(v)),C.splits.getChangeNumber()>-1&&k.splits.emit(gi));var N,_,A={},I=function(e,t){if(e&&t){var n=wi(t);return{trackEval:function(n){var r=wi(t);return function(t){switch(t){case ho:return void e.recordException(n);case fo:e.recordNonReadyUsage&&e.recordNonReadyUsage()}e.recordLatency(n,r())}},trackHttp:function(n){var r=wi(t);return function(t){e.recordHttpLatency(n,r()),t&&t.statusCode?e.recordHttpError(n,t.statusCode):e.recordSuccessfulSync(n,Date.now())}},sessionLength:function(){e.recordSessionLength&&e.recordSessionLength(n())},streamingEvent:function(t,n){t===ye?e.recordAuthRejections():(e.recordStreamingEvents({e:t,d:n,t:Date.now()}),t===de&&e.recordTokenRefreshes())},addTag:function(t){e.addTag&&e.addTag(t)},trackUpdatesFromSSE:function(t){e.recordUpdatesFromSSE(t)}}}var r=function(){return function(){}};return{trackEval:r,trackHttp:r,sessionLength:function(){},streamingEvent:function(){},addTag:function(){},trackUpdatesFromSSE:function(){}}}(C.telemetry,n.now),O=c&&c({settings:t,storage:C,telemetryTracker:I}),L=u(),D=function(e,t,n){var r;return void 0===n&&(n=za),{track:function(r,i){n.add(r,i)?t.track(r,i):e.debug(zn+"The feature "+i+" and key "+r+" exist in the filter")},start:function(){n.refreshRate&&(r=setInterval(n.clear,n.refreshRate))},stop:function(){clearInterval(r)}}}(g,C.uniqueKeys,h&&h()),M=function(e,t){return{process:function(n){var r=Date.now();return e.track(n.feature,r,1),t.track(n.keyName,n.feature),!1}}}(C.impressionCounts,D),K=d===E?(N=L,_=C.impressionCounts,{process:function(e){if(e.properties)return!0;e.pt=N.testAndSet(e);var t=Date.now();return e.pt&&_.track(e.feature,t,1),!e.pt||e.pt0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)Qa(a,this,t);else for(var u=a.length,c=function(e,t){for(var n=new Array(t),r=0;r=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this};var $a={getFetch:function(){return"function"==typeof fetch?fetch:Ga},getEventSource:function(){return"function"==typeof EventSource?EventSource:void 0},EventEmitter:Va,now:"object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):Date.now};function Za(e,t){var n=function(e){return hr(e,Jr)}(e),r=function(e,t){La||(La=Ji(Ws,Ks));var n={settings:e,platform:t,storageFactory:e.storage,splitApiFactory:ri,syncManagerFactory:La,sdkManagerFactory:ko,sdkClientMethodFactory:ga,SignalListener:ya,integrationsManagerFactory:e.integrations&&e.integrations.length>0?wa.bind(null,e.integrations):void 0,impressionsObserverFactory:Ca,extraProps:function(e){return{UserConsent:_a(e)}}};switch(e.mode){case R:n.splitApiFactory=void 0,n.syncManagerFactory=Ma,n.SignalListener=void 0;break;case w:n.syncManagerFactory=void 0;break;case N:Da||(Da=Ji(void 0,void 0)),n.syncManagerFactory=Da}return n}(n,$a);return t&&t(r),Wa(r)}var Xa=/[^.]+$/;var eu=function(e){function n(t,n){var r=e.call(this,t)||this;return r.matchingKey=n,r.regexSplitsCacheKey=new RegExp("^"+t+"\\.(splits?|trafficType|flagSet)\\."),r}return t(n,e),n.prototype.buildSegmentNameKey=function(e){return this.prefix+"."+this.matchingKey+".segment."+e},n.prototype.extractSegmentName=function(e){var t=this.prefix+"."+this.matchingKey+".segment.";if(p(e,t))return e.slice(t.length)},n.prototype.buildLastUpdatedKey=function(){return this.prefix+".splits.lastUpdated"},n.prototype.isSplitsCacheKey=function(e){return this.regexSplitsCacheKey.test(e)},n.prototype.buildTillKey=function(){return this.prefix+"."+this.matchingKey+".segments.till"},n.prototype.isSplitKey=function(e){return p(e,this.prefix+".split.")},n.prototype.isRBSegmentKey=function(e){return p(e,this.prefix+".rbsegment.")},n.prototype.buildSplitsWithSegmentCountKey=function(){return this.prefix+".splits.usingSegments"},n.prototype.buildLastClear=function(){return this.prefix+".lastClear"},n}(function(){function e(e){void 0===e&&(e="SPLITIO"),this.prefix=e}return e.prototype.buildTrafficTypeKey=function(e){return this.prefix+".trafficType."+e},e.prototype.buildFlagSetKey=function(e){return this.prefix+".flagSet."+e},e.prototype.buildSplitKey=function(e){return this.prefix+".split."+e},e.prototype.buildSplitsTillKey=function(){return this.prefix+".splits.till"},e.prototype.buildSplitKeyPrefix=function(){return this.prefix+".split."},e.prototype.buildRBSegmentKey=function(e){return this.prefix+".rbsegment."+e},e.prototype.buildRBSegmentsTillKey=function(){return this.prefix+".rbsegments.till"},e.prototype.buildRBSegmentKeyPrefix=function(){return this.prefix+".rbsegment."},e.prototype.buildSegmentNameKey=function(e){return this.prefix+".segment."+e},e.prototype.buildSegmentTillKey=function(e){return this.prefix+".segment."+e+".till"},e.prototype.extractKey=function(e){var t=e.match(Xa);if(t&&t.length)return t[0];throw new Error("Invalid latency key provided")},e.prototype.buildHashKey=function(){return this.prefix+".hash"},e}());function tu(e,t){return{buildSegmentNameKey:function(n){return e+"."+t+".largeSegment."+n},extractSegmentName:function(n){var r=e+"."+t+".largeSegment.";if(p(n,r))return n.slice(r.length)},buildTillKey:function(){return e+"."+t+".largeSegments.till"}}}var nu="storage:localstorage: ",ru="1",iu=function(e){function n(t,n,r){var i=e.call(this)||this;return i.keys=n,i.log=t.log,i.flagSetsFilter=t.sync.__splitFiltersValidation.groupedFilters.bySet,i.storage=r,i}return t(n,e),n.prototype._decrementCount=function(e){var t=g(this.storage.getItem(e))-1;t>0?this.storage.setItem(e,t+""):this.storage.removeItem(e)},n.prototype._decrementCounts=function(e){try{var t=this.keys.buildTrafficTypeKey(e.trafficTypeName);if(this._decrementCount(t),Cr(e)){var n=this.keys.buildSplitsWithSegmentCountKey();this._decrementCount(n)}}catch(e){this.log.error(nu+e)}},n.prototype._incrementCounts=function(e){try{var t=this.keys.buildTrafficTypeKey(e.trafficTypeName);if(this.storage.setItem(t,g(this.storage.getItem(t))+1+""),Cr(e)){var n=this.keys.buildSplitsWithSegmentCountKey();this.storage.setItem(n,g(this.storage.getItem(n))+1+"")}}catch(e){this.log.error(nu+e)}},n.prototype.clear=function(){for(var e=this,t=this.storage.length,n=[],r=0;r0},n.prototype.usesSegments=function(){if(!this.hasSync)return!0;var e=this.storage.getItem(this.keys.buildSplitsWithSegmentCountKey()),t=null===e?0:g(e);return!a(t)||t>0},n.prototype.getNamesByFlagSets=function(e){var t=this;return e.map((function(e){var n=t.keys.buildFlagSetKey(e),r=t.storage.getItem(n);return new Set(r?JSON.parse(r):[])}))},n.prototype.addToFlagSets=function(e){var t=this;e.sets&&e.sets.forEach((function(n){if(!(t.flagSetsFilter.length>0)||t.flagSetsFilter.some((function(e){return e===n}))){var r=t.keys.buildFlagSetKey(n),i=t.storage.getItem(r),s=new Set(i?JSON.parse(i):[]);s.add(e.name),t.storage.setItem(r,JSON.stringify(qr(s)))}}))},n.prototype.removeFromFlagSets=function(e,t){var n=this;t&&t.forEach((function(t){n.removeNames(t,e)}))},n.prototype.removeNames=function(e,t){var n=this.keys.buildFlagSetKey(e),r=this.storage.getItem(n);if(r){var i=new Set(JSON.parse(r));i.delete(t),0!==i.size?this.storage.setItem(n,JSON.stringify(qr(i))):this.storage.removeItem(n)}},n}(kr),su=function(){function e(e,t,n){this.keys=t,this.log=e.log,this.storage=n}return e.prototype.clear=function(){var e=this;this.getNames().forEach((function(t){return e.remove(t)})),this.storage.removeItem(this.keys.buildRBSegmentsTillKey())},e.prototype.update=function(e,t,n){var r=this;this.setChangeNumber(n);var i=e.map((function(e){return r.add(e)})).some((function(e){return e}));return t.map((function(e){return r.remove(e.name)})).some((function(e){return e}))||i},e.prototype.setChangeNumber=function(e){try{this.storage.setItem(this.keys.buildRBSegmentsTillKey(),e+""),this.storage.setItem(this.keys.buildLastUpdatedKey(),Date.now()+"")}catch(e){this.log.error(nu+e)}},e.prototype.updateSegmentCount=function(e){var t=this.keys.buildSplitsWithSegmentCountKey(),n=g(this.storage.getItem(t))+e;n>0?this.storage.setItem(t,n+""):this.storage.removeItem(t)},e.prototype.add=function(e){try{var t=e.name,n=this.keys.buildRBSegmentKey(t),r=this.storage.getItem(n),i=r?JSON.parse(r):null;this.storage.setItem(n,JSON.stringify(e));var s=0;return i&&Cr(i)&&s--,Cr(e)&&s++,0!==s&&this.updateSegmentCount(s),!0}catch(e){return this.log.error(nu+e),!1}},e.prototype.remove=function(e){try{var t=this.get(e);return!!t&&(this.storage.removeItem(this.keys.buildRBSegmentKey(e)),Cr(t)&&this.updateSegmentCount(-1),!0)}catch(e){return this.log.error(nu+e),!1}},e.prototype.getNames=function(){for(var e=this.storage.length,t=[],n=0;n0},e}(),ou=function(e){function n(t,n,r){var i=e.call(this)||this;return i.log=t,i.keys=n,i.storage=r,i}return t(n,e),n.prototype.addSegment=function(e){var t=this.keys.buildSegmentNameKey(e);try{return this.storage.getItem(t)!==ru&&(this.storage.setItem(t,ru),!0)}catch(e){return this.log.error(nu+e),!1}},n.prototype.removeSegment=function(e){var t=this.keys.buildSegmentNameKey(e);try{return this.storage.getItem(t)===ru&&(this.storage.removeItem(t),!0)}catch(e){return this.log.error(nu+e),!1}},n.prototype.isInSegment=function(e){return this.storage.getItem(this.keys.buildSegmentNameKey(e))===ru},n.prototype.getRegisteredSegments=function(){for(var e=[],t=0,n=this.storage.length;t=1?e.expirationDays:au;if(l %s"],[Je,On+"[%s] Result: %s. Rule value: %s. Evaluation value: %s"],[Ye,An+"Evaluates to default treatment. %s"],[25,Wn+"Registering cleanup handler %s"],[26,Wn+"Deregistering cleanup handler %s"],[xe,"Retrieving default SDK client."],[Pe,"Retrieving existing SDK client."],[Ue,"Retrieving manager instance."],[Be,Mn+"Feature flags data: \n%s"],[je,xn+"Spin up feature flags update using since = %s and rbSince = %s."],[qe,xn+"New feature flags: %s. Removed feature flags: %s."],[ze,xn+"New rule-based segments: %s. Removed rule-based segments: %s."],[We,Kn+"New SSE message received, with data: %s."],[Ge,Ln+": Starting %s. Running each %s millis"],[He,Ln+": Running %s"],[Qe,Ln+": Stopping %s"],[Ve,wn+': feature flags filtering criteria is "%s".']]);return Za.SplitFactory=Za,Za.InLocalStorage=function(e){void 0===e&&(e={});var t=function(e){return e?e+".SPLITIO":"SPLITIO"}(e.prefix);function n(n){var r=n.settings,i=n.settings,s=i.log,o=i.scheduler,a=o.impressionsQueueSize,u=o.eventsQueueSize,c=lu(s,t,e.wrapper);if(!c)return Gr(n);var l,f=Mr(r.core.key),h=new eu(t,f),p=new iu(r,h,c),g=new su(r,h,c),d=new ou(s,h,c),m=new ou(s,tu(t,f),c);return{splits:p,rbSegments:g,segments:d,largeSegments:m,impressions:new Ir(a),impressionCounts:new Dr,events:new Or(u),telemetry:Br(n)?new jr(p,d):void 0,uniqueKeys:new zr,validateCache:function(){return l||(l=function(e,t,n,r,i,s,o,a){return Promise.resolve(t.load&&t.load()).then((function(){var u=Date.now(),c=i.getChangeNumber()>-1;if(cu(e,t,n,r,u,c)){i.clear(),s.clear(),o.clear(),a.clear();try{t.setItem(r.buildLastClear(),u+"")}catch(e){n.log.error(nu+e)}return t.save&&t.save(),!1}return c}))}(e,c,r,h,p,g,d,m))},save:function(){return c.save&&c.save()},destroy:function(){return c.whenSaved&&c.whenSaved()},shared:function(e){return{splits:this.splits,rbSegments:this.rbSegments,segments:new ou(s,new eu(t,e),c),largeSegments:new ou(s,tu(t,e),c),impressions:this.impressions,impressionCounts:this.impressionCounts,events:this.events,telemetry:this.telemetry,uniqueKeys:this.uniqueKeys,destroy:function(){}}}}}return n.type=A,n},Za.ErrorLogger=function(){return new Er({logLevel:"ERROR"},new Map(fu))},Za.WarnLogger=function(){return new Er({logLevel:"WARN"},new Map(hu))},Za.InfoLogger=function(){return new Er({logLevel:"INFO"},new Map(gu))},Za.DebugLogger=function(){return new Er({logLevel:"DEBUG"},new Map(du))},Za})); diff --git a/splitio_web/web/split-browser.full.min.js b/splitio_web/web/split-browser.full.min.js new file mode 100644 index 0000000..cb75fde --- /dev/null +++ b/splitio_web/web/split-browser.full.min.js @@ -0,0 +1,9 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).splitio=t()}(this,(function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0)return t;e.error(yn,[n,r])}else e.error(vn,[n,r]);return!1}function Vn(e,t,n,r,i){if(void 0===r&&(r="feature flag names"),void 0===i&&(i="feature flag name"),Array.isArray(t)&&t.length>0){var s=[];if(t.forEach((function(t){var r=Qn(e,t,n,i);r&&s.push(r)})),s.length)return v(s)}return e.error(Sn,[n,r]),!1}var Jn=Object.assign||function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");e=Object(e);for(var t=1;t0}))}function tr(e,t,n){var r,i,s={validFilters:[],queryString:null,groupedFilters:{bySet:[],byName:[],byPrefix:[]}};return t?Oe(n)?(e.warn(qt),s):Array.isArray(t)&&0!==t.length?(s.validFilters=t.filter((function(t,n){return t&&(r=t.type,Yn.some((function(e){return e.type===r})))&&Array.isArray(t.values)?(s.groupedFilters[t.type]=s.groupedFilters[t.type].concat(t.values),!0):(e.warn(zt,[n]),!1);var r})),Yn.forEach((function(t){var n=t.type,r=t.maxLength;s.groupedFilters[n].length>0&&(s.groupedFilters[n]=function(e,t,n,r){var i=Vn(e,n,Nn,t+" filter",t+" filter value");if(i){if("bySet"===t&&(i=Xn(e,i,Nn)),i.length>r)throw new Error(r+" unique values can be specified at most for '"+t+"' filter. You passed "+i.length+". Please consider reducing the amount or using other filter.");i.sort()}return i||[]}(e,n,s.groupedFilters[n],r))})),er(s.validFilters,"bySet")&&((er(s.validFilters,"byName")||er(s.validFilters,"byPrefix"))&&e.error(Cn),Jn(s.groupedFilters,{byName:[],byPrefix:[]})),s.queryString=(r=s.groupedFilters,i=[],Yn.forEach((function(e){var t=e.type,n=e.queryParam,s=r[t];s.length>0&&i.push(n+s.map((function(e){return encodeURIComponent(e)})).join(","))})),i.length>0?"&"+i.join("&"):null),e.debug(Je,[s.queryString]),s):(e.warn(Wt),s):s}var nr,rr=250;function ir(e,t,n,r){if(null==t)return e.error(gn,[n,r]),!1;if(u(t))return e.warn(Kt,[n,r,t]),m(t);if(f(t)){if((t=t.trim()).length>0&&t.length<=rr)return t;0===t.length?e.error(yn,[n,r]):t.length>rr&&e.error(dn,[n,r])}else e.error(vn,[n,r]);return!1}function sr(e,t,n){if(l(t)){var r=ir(e,t.matchingKey,n,"matchingKey"),i=ir(e,t.bucketingKey,n,"bucketingKey");return r&&i?{matchingKey:r,bucketingKey:i}:(e.error(mn,[n]),!1)}return ir(e,t,n,"key")}function or(e,t,n,r){var i=n.splits,s=n.rbSegments,o=n.segments,a=n.largeSegments,u=t.splitChanges,c=u.ff,l=u.rbs;e.debug("storage: set feature flags and segments"+(r?" for key "+r:"")),i&&c&&(i.clear(),i.update(c.d,[],c.t)),s&&l&&(s.clear(),s.update(l.d,[],l.t));var f=t.segmentChanges;if(r){var h=t.memberships&&t.memberships[r];!h&&f&&(h={ms:{k:f.filter((function(e){return e.added.indexOf(r)>-1})).map((function(e){return{n:e.name}}))}}),h&&(h.ms&&o.resetSegments(h.ms),h.ls&&a&&a.resetSegments(h.ls))}else f&&(o.clear(),f.forEach((function(e){o.update(e.name,e.added,e.removed,e.till)})))}!function(e){e.FlagName="Invalid flag name (max 100 chars, no spaces)",e.Treatment="Invalid treatment (max 100 chars and must match pattern)"}(nr||(nr={}));var ar=/^[0-9]+[.a-zA-Z0-9_-]*$|^[a-zA-Z]+[a-zA-Z0-9_-]*$/;function ur(e){var t=l(e)?e.treatment:e;return!(!f(t)||t.length>100)&&ar.test(t)}function cr(e,t){if(void 0!==t){if(ur(t))return t;e.error("Fallback treatments - Discarded fallback: "+nr.Treatment)}}function lr(e,t){var n={};return l(t)?(Object.keys(t).forEach((function(r){var i,s=t[r];(i=r).length<=100&&!i.includes(" ")?ur(s)?n[r]=s:e.error("Fallback treatments - Discarded treatment for flag '"+r+"': "+nr.Treatment):e.error("Fallback treatments - Discarded flag '"+r+"': "+nr.FlagName)})),n):n}var fr={mode:C,core:{authorizationKey:void 0,key:void 0,labelsEnabled:!0,IPAddressesEnabled:void 0},scheduler:{featuresRefreshRate:60,segmentsRefreshRate:60,telemetryRefreshRate:3600,impressionsRefreshRate:300,offlineRefreshRate:15,eventsPushRate:60,eventsQueueSize:500,impressionsQueueSize:3e4,pushRetryBackoffBase:1},urls:{sdk:"https://sdk.split.io/api",events:"https://events.split.io/api",auth:"https://auth.split.io/api",streaming:"https://streaming.split.io",telemetry:"https://telemetry.split.io/api"},storage:void 0,debug:void 0,impressionListener:void 0,version:void 0,integrations:void 0,streamingEnabled:!0,sync:{splitFilters:void 0,impressionsMode:T,enabled:!0,flagSpecVersion:we},log:void 0};function hr(e){return Math.round(1e3*e)}function pr(e,t){var n=t.defaults,r=t.runtime,i=t.storage,s=t.integrations,a=t.logger,u=t.consent,c=t.flagSpec,f=p({},fr,n,e);f.features=o(e,"features");var g=a(f);f.log=g;var d=f.sync;d.impressionsMode=function(e,t){return t=h(t),[E,T,R].indexOf(t)>-1?t:(e.error(bn,["impressionsMode",[E,T,R],T]),T)}(g,d.impressionsMode);var m,v,y,S=f.scheduler,b=f.startup;S.featuresRefreshRate=hr(S.featuresRefreshRate),S.segmentsRefreshRate=hr(S.segmentsRefreshRate),S.offlineRefreshRate=hr(S.offlineRefreshRate),S.eventsPushRate=hr(S.eventsPushRate),S.telemetryRefreshRate=hr((m="telemetryRefreshRate",(v=S.telemetryRefreshRate)>=(y=60)?v:(g.error(Rn,[m,y]),y))),void 0===o(e,"scheduler.impressionsRefreshRate")&&d.impressionsMode===E&&(S.impressionsRefreshRate=60),S.impressionsRefreshRate=hr(S.impressionsRefreshRate),S.metricsRefreshRate&&g.warn("`metricsRefreshRate` will be deprecated soon. For configuring telemetry rates, update `telemetryRefreshRate` value in configs"),b.requestTimeoutBeforeReady=hr(b.requestTimeoutBeforeReady),b.readyTimeout=hr(b.readyTimeout),b.eventsFirstPushWindow=hr(b.eventsFirstPushWindow),f.mode=function(e,t){if("localhost"===e)return k;if(-1===[C,w,N,_].indexOf(t))throw Error("Invalid mode provided");return t}(f.core.authorizationKey,f.mode),i&&(f.storage=i(f)),f.initialRolloutPlan&&(f.initialRolloutPlan=function(e,t){var n=t.mode,r=t.initialRolloutPlan;if(!Oe(n))return l(r)&&l(r.splitChanges)?r:void e.error("storage: invalid rollout plan provided");e.warn("storage: initial rollout plan is ignored in consumer mode")}(g,f));var A=f.core.key;t.acceptKey?f.mode===k&&void 0===A?f.core.key="localhost_key":f.core.key=sr(g,A,An):(void 0!==A&&g.warn("Provided `key` is ignored in server-side SDK."),f.core.key=void 0),f.runtime=r(f),s&&(f.integrations=s(f)),!1!==f.streamingEnabled&&(f.streamingEnabled=!0,S.pushRetryBackoffBase=hr(S.pushRetryBackoffBase)),!1!==d.enabled&&(d.enabled=!0);var I=tr(g,d.splitFilters,f.mode);return d.splitFilters=I.validFilters,d.__splitFiltersValidation=I,d.flagSpecVersion=c?c(f):we,f.userConsent=u?u(f):void 0,f.fallbackTreatments=f.fallbackTreatments?function(e,t){if(l(t))return{global:cr(e,t.global),byFlag:lr(e,t.byFlag)};e.error("Fallback treatments - Discarded configuration: it must be an object with optional `global` and `byFlag` properties")}(g,f.fallbackTreatments):void 0,f}function gr(e){return null!==e&&"object"==typeof e&&"function"==typeof e.debug&&"function"==typeof e.info&&"function"==typeof e.warn&&"function"==typeof e.error}var dr={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",NONE:"NONE"},mr={DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},vr={debug:function(e){console.log("[DEBUG] "+e)},info:function(e){console.log("[INFO] "+e)},warn:function(e){console.log("[WARN] "+e)},error:function(e){console.log("[ERROR] "+e)}};function yr(e){return!!r(dr,(function(t){return e===t}))}function Sr(e,t){void 0===e&&(e=""),void 0===t&&(t=[]);var n=0;return e.replace(/%s/g,(function(){var e=t[n++];if(l(e)||Array.isArray(e))try{e=JSON.stringify(e)}catch(e){}return e}))}var br,Er={prefix:"splitio",logLevel:dr.NONE},Tr=function(){function e(e,t){this.options=Jn({},Er,e),this.codes=t||new Map,this.logLevel=mr[this.options.logLevel]}return e.prototype.setLogLevel=function(e){this.options.logLevel=e,this.logLevel=mr[e]},e.prototype.setLogger=function(e){if(e){if(gr(e))return void(this.logger=e);this.error("Invalid `logger` instance. It must be an object with `debug`, `info`, `warn` and `error` methods. Defaulting to `console.log`")}this.logger=void 0},e.prototype.debug=function(e,t){this._shouldLog(mr.DEBUG)&&this._log("debug",e,t)},e.prototype.info=function(e,t){this._shouldLog(mr.INFO)&&this._log("info",e,t)},e.prototype.warn=function(e,t){this._shouldLog(mr.WARN)&&this._log("warn",e,t)},e.prototype.error=function(e,t){this._shouldLog(mr.ERROR)&&this._log("error",e,t)},e.prototype._log=function(e,t,n){if("number"==typeof t){var r=this.codes.get(t);t=r?Sr(r,n):"Message code "+t+(n?", with args: "+n.toString():"")}else n&&(t=Sr(t,n));if(this.options.prefix&&(t=this.options.prefix+" => "+t),this.logger)try{return void this.logger[e](t)}catch(e){}vr[e](t)},e.prototype._shouldLog=function(e){return e>=this.logLevel},e}();try{var Rr=localStorage.getItem("splitio_debug")||"";br=/^(enabled?|on)/i.test(Rr)?dr.DEBUG:yr(Rr)?Rr:dr.NONE}catch(Ti){}var kr={startup:{requestTimeoutBeforeReady:5,retriesOnFailureBeforeReady:1,readyTimeout:10,eventsFirstPushWindow:10},userConsent:F,version:"browserjs-1.6.1",debug:br};var Cr=function(){function e(){}return e.prototype.update=function(e,t,n){var r=this,i=e.map((function(e){return r.addSplit(e)})).some((function(e){return e}));return i=t.map((function(e){return r.removeSplit(e.name)})).some((function(e){return e}))||i,this.setChangeNumber(n),i},e.prototype.getSplits=function(e){var t=this,n={};return e.forEach((function(e){n[e]=t.getSplit(e)})),n},e.prototype.getAll=function(){var e=this;return this.getSplitNames().map((function(t){return e.getSplit(t)}))},e.prototype.killLocally=function(e,t,n){var r=this.getSplit(e);if(r&&(!r.changeNumber||r.changeNumber0)}function Nr(e){return e.splits.usesSegments()||e.rbSegments.usesSegments()}var _r=function(e){function n(t){var n=e.call(this)||this;return n.splitsCache={},n.ttCache={},n.changeNumber=-1,n.segmentsCount=0,n.flagSetsCache={},n.flagSetsFilter=t?t.groupedFilters.bySet:[],n}return t(n,e),n.prototype.clear=function(){this.splitsCache={},this.ttCache={},this.changeNumber=-1,this.segmentsCount=0,this.flagSetsCache={}},n.prototype.addSplit=function(e){var t=e.name,n=this.getSplit(t);if(n){var r=n.trafficTypeName;this.ttCache[r]--,this.ttCache[r]||delete this.ttCache[r],this.removeFromFlagSets(n.name,n.sets),wr(n)&&this.segmentsCount--}this.splitsCache[t]=e;var i=e.trafficTypeName;return this.ttCache[i]=(this.ttCache[i]||0)+1,this.addToFlagSets(e),wr(e)&&this.segmentsCount++,!0},n.prototype.removeSplit=function(e){var t=this.getSplit(e);if(!t)return!1;delete this.splitsCache[e];var n=t.trafficTypeName;return this.ttCache[n]--,this.ttCache[n]||delete this.ttCache[n],this.removeFromFlagSets(t.name,t.sets),wr(t)&&this.segmentsCount--,!0},n.prototype.getSplit=function(e){return this.splitsCache[e]||null},n.prototype.setChangeNumber=function(e){return this.changeNumber=e,!0},n.prototype.getChangeNumber=function(){return this.changeNumber},n.prototype.getSplitNames=function(){return Object.keys(this.splitsCache)},n.prototype.trafficTypeExists=function(e){return u(this.ttCache[e])&&this.ttCache[e]>0},n.prototype.usesSegments=function(){return-1===this.getChangeNumber()||this.segmentsCount>0},n.prototype.getNamesByFlagSets=function(e){var t=this;return e.map((function(e){return t.flagSetsCache[e]||new Set}))},n.prototype.addToFlagSets=function(e){var t=this;e.sets&&e.sets.forEach((function(n){t.flagSetsFilter.length>0&&!t.flagSetsFilter.some((function(e){return e===n}))||(t.flagSetsCache[n]||(t.flagSetsCache[n]=new Set([])),t.flagSetsCache[n].add(e.name))}))},n.prototype.removeFromFlagSets=function(e,t){var n=this;t&&t.forEach((function(t){n.removeNames(t,e)}))},n.prototype.removeNames=function(e,t){this.flagSetsCache[e]&&(this.flagSetsCache[e].delete(t),0===this.flagSetsCache[e].size&&delete this.flagSetsCache[e])},n}(Cr),Ar=function(){function e(){}return e.prototype.clear=function(){this.resetSegments({})},e.prototype.registerSegments=function(){return!1},e.prototype.update=function(){return!1},e.prototype.resetSegments=function(e){var t=this,n=!1,r=e,i=r.added,s=r.removed;if(i&&s)i.forEach((function(e){n=t.addSegment(e)||n})),s.forEach((function(e){n=t.removeSegment(e)||n}));else{var o=(e.k||[]).map((function(e){return e.n})).sort(),a=this.getRegisteredSegments().sort();if(o.length||a.length){for(var u=0;u0&&this.queue.length>=this.maxQueue&&this.onFullQueue&&this.onFullQueue()},e.prototype.clear=function(){this.queue=[]},e.prototype.pop=function(e){var t=this.queue;return this.clear(),e?e.concat(t):t},e.prototype.isEmpty=function(){return 0===this.queue.length},e}(),Fr=function(){function e(e){void 0===e&&(e=0),this.name="events",this.maxQueue=e,this.queue=[],this.queueByteSize=0}return e.prototype.setOnFullQueueCb=function(e){this.onFullQueue=e},e.prototype.track=function(e,t){return void 0===t&&(t=0),this.queueByteSize+=t,this.queue.push(e),this._checkForFlush(),!0},e.prototype.clear=function(){this.queue=[],this.queueByteSize=0},e.prototype.pop=function(e){var t=this.queue;return this.clear(),e?e.concat(t):t},e.prototype.isEmpty=function(){return 0===this.queue.length},e.prototype._checkForFlush=function(){(this.queueByteSize>5242880||this.maxQueue>0&&this.queue.length>=this.maxQueue)&&this.onFullQueue&&this.onFullQueue()},e}(),Lr=36e5;function Dr(e){return e-e%Lr}var Mr=function(){function e(e){void 0===e&&(e=3e4),this.name="impression counts",this.cache={},this.cacheSize=0,this.maxStorage=e}return e.prototype._makeKey=function(e,t){return e+"::"+Dr(t)},e.prototype.track=function(e,t,n){var r=this._makeKey(e,t),i=this.cache[r];this.cache[r]=i?i+n:n,this.onFullQueue&&(this.cacheSize=this.cacheSize+n,this.cacheSize>=this.maxStorage&&this.onFullQueue())},e.prototype.pop=function(e){var t=this.cache;return this.clear(),e?(Object.keys(t).forEach((function(n){e[n]?e[n]+=t[n]:e[n]=t[n]})),e):t},e.prototype.clear=function(){this.cache={},this.cacheSize=0},e.prototype.isEmpty=function(){return 0===Object.keys(this.cache).length},e}();function Kr(e){return l(e)?e.matchingKey:e}function xr(e){return l(e)?{matchingKey:e.matchingKey,bucketingKey:e.bucketingKey}:{matchingKey:e,bucketingKey:e}}function Pr(e){return!e.core.key}function Ur(e){var t=Math.min(22,Math.max(0,Math.ceil(Math.log(e)/Math.log(1.5))));return c(t)?0:t}var Br=.001;function jr(e){var t=e.settings;return t.mode!==k&&(Pr(t)||Math.random()<=Br)}var qr=function(){function e(e,t,n){this.splits=e,this.segments=t,this.largeSegments=n,this.name="telemetry stats",this.e=!0,this.notReadyUsage=0,this.impressionStats=[0,0,0],this.eventStats=[0,0],this.lastSync={},this.httpErrors={},this.httpLatencies={},this.authRejections=0,this.tokenRefreshes=0,this.streamingEvents=[],this.tags=[],this.exceptions={},this.latencies={},this.updatesFromSSE={}}return e.prototype.isEmpty=function(){return this.e},e.prototype.clear=function(){},e.prototype.pop=function(){return this.e=!0,{lS:this.getLastSynchronization(),mL:this.popLatencies(),mE:this.popExceptions(),hE:this.popHttpErrors(),hL:this.popHttpLatencies(),tR:this.popTokenRefreshes(),aR:this.popAuthRejections(),iQ:this.getImpressionStats(Q),iDe:this.getImpressionStats(J),iDr:this.getImpressionStats(V),spC:this.splits&&this.splits.getSplitNames().length,seC:this.segments&&this.segments.getRegisteredSegments().length,skC:this.segments&&this.segments.getKeysCount(),lsC:this.largeSegments&&this.largeSegments.getRegisteredSegments().length,lskC:this.largeSegments&&this.largeSegments.getKeysCount(),sL:this.getSessionLength(),eQ:this.getEventStats(Q),eD:this.getEventStats(V),sE:this.popStreamingEvents(),t:this.popTags(),ufs:this.popUpdatesFromSSE()}},e.prototype.getTimeUntilReady=function(){return this.timeUntilReady},e.prototype.recordTimeUntilReady=function(e){this.timeUntilReady=e},e.prototype.getTimeUntilReadyFromCache=function(){return this.timeUntilReadyFromCache},e.prototype.recordTimeUntilReadyFromCache=function(e){this.timeUntilReadyFromCache=e},e.prototype.getNonReadyUsage=function(){return this.notReadyUsage},e.prototype.recordNonReadyUsage=function(){this.notReadyUsage++},e.prototype.getImpressionStats=function(e){return this.impressionStats[e]},e.prototype.recordImpressionStats=function(e,t){this.impressionStats[e]+=t,this.e=!1},e.prototype.getEventStats=function(e){return this.eventStats[e]},e.prototype.recordEventStats=function(e,t){this.eventStats[e]+=t,this.e=!1},e.prototype.getLastSynchronization=function(){return this.lastSync},e.prototype.recordSuccessfulSync=function(e,t){this.lastSync[e]=t,this.e=!1},e.prototype.popHttpErrors=function(){var e=this.httpErrors;return this.httpErrors={},e},e.prototype.recordHttpError=function(e,t){var n=this.httpErrors[e]=this.httpErrors[e]||{};n[t]=(n[t]||0)+1,this.e=!1},e.prototype.popHttpLatencies=function(){var e=this.httpLatencies;return this.httpLatencies={},e},e.prototype.recordHttpLatency=function(e,t){(this.httpLatencies[e]=this.httpLatencies[e]||[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])[Ur(t)]++,this.e=!1},e.prototype.popAuthRejections=function(){var e=this.authRejections;return this.authRejections=0,e},e.prototype.recordAuthRejections=function(){this.authRejections++,this.e=!1},e.prototype.popTokenRefreshes=function(){var e=this.tokenRefreshes;return this.tokenRefreshes=0,e},e.prototype.recordTokenRefreshes=function(){this.tokenRefreshes++,this.e=!1},e.prototype.popStreamingEvents=function(){return this.streamingEvents.splice(0)},e.prototype.recordStreamingEvents=function(e){this.streamingEvents.length<20&&this.streamingEvents.push(e),this.e=!1},e.prototype.popTags=function(){return this.tags.splice(0)},e.prototype.addTag=function(e){this.tags.length<10&&this.tags.push(e),this.e=!1},e.prototype.getSessionLength=function(){return this.sessionLength},e.prototype.recordSessionLength=function(e){this.sessionLength=e,this.e=!1},e.prototype.popExceptions=function(){var e=this.exceptions;return this.exceptions={},e},e.prototype.recordException=function(e){this.exceptions[e]=(this.exceptions[e]||0)+1,this.e=!1},e.prototype.popLatencies=function(){var e=this.latencies;return this.latencies={},e},e.prototype.recordLatency=function(e,t){(this.latencies[e]=this.latencies[e]||[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])[Ur(t)]++,this.e=!1},e.prototype.popUpdatesFromSSE=function(){var e=this.updatesFromSSE;return this.updatesFromSSE={},e},e.prototype.recordUpdatesFromSSE=function(e){this.updatesFromSSE[e]=(this.updatesFromSSE[e]||0)+1,this.e=!1},e}();function zr(e){if(Array.from)return Array.from(e);var t=[];return e.forEach((function(e){t.push(e)})),t}var Wr=function(){function e(e){void 0===e&&(e=3e4),this.name="unique keys",this.uniqueTrackerSize=0,this.uniqueKeysTracker={},this.maxStorage=e}return e.prototype.setOnFullQueueCb=function(e){this.onFullQueue=e},e.prototype.track=function(e,t){this.uniqueKeysTracker[e]||(this.uniqueKeysTracker[e]=new Set);var n=this.uniqueKeysTracker[e];n.has(t)||(n.add(t),this.uniqueTrackerSize++),this.uniqueTrackerSize>=this.maxStorage&&this.onFullQueue&&this.onFullQueue()},e.prototype.clear=function(){this.uniqueTrackerSize=0,this.uniqueKeysTracker={}},e.prototype.pop=function(){var e=this.uniqueKeysTracker;return this.clear(),this.fromUniqueKeysCollector(e)},e.prototype.isEmpty=function(){return 0===Object.keys(this.uniqueKeysTracker).length},e.prototype.fromUniqueKeysCollector=function(e){for(var t=[],n=Object.keys(e),r=0;r0},e}();function Hr(e){var t=e.settings,n=t.scheduler,r=n.impressionsQueueSize,i=n.eventsQueueSize,s=t.sync.__splitFiltersValidation,o=new _r(s),a=new Gr,u=new Ir,c={splits:o,rbSegments:a,segments:u,largeSegments:new Ir,impressions:new Or(r),impressionCounts:new Mr,events:new Fr(i),telemetry:jr(e)?new qr(o,u):void 0,uniqueKeys:new Wr,destroy:function(){},shared:function(){return{splits:this.splits,rbSegments:this.rbSegments,segments:new Ir,largeSegments:new Ir,impressions:this.impressions,impressionCounts:this.impressionCounts,events:this.events,telemetry:this.telemetry,uniqueKeys:this.uniqueKeys,destroy:function(){}}}};if(e.settings.mode===k){var l=function(){return!0};c.impressions.track=l,c.events.track=l,c.impressionCounts.track=l,c.uniqueKeys.track=l}return c}function Qr(e){var t=Hr(e);return t.validateCache=function(){return Promise.resolve(!0)},t}Hr.type=A,Qr.type=A;var Vr=dr.NONE;var Jr=[L,F,D];var Yr={defaults:kr,acceptKey:!0,runtime:function(){return{ip:!1,hostname:!1}},storage:function(e){var t=e.storage,n=void 0===t?Hr:t,r=e.log,i=e.mode;if("function"==typeof n&&-1!==[A,I,O].indexOf(n.type)||(n=Hr,r.error(324)),i===k&&n.type===I)return Qr;if(-1===[k,C].indexOf(i)){if(n.type!==O)throw new Error("A PluggableStorage instance is required on consumer mode")}else n.type===O&&(n=Hr,r.error(324,[" It requires consumer mode."]));return n},integrations:function(e){return function(e,t,n){var r=e.integrations,i=e.log;if(!Array.isArray(r)||0===r.length)return[];var s=r.filter(t),o=r.length-s.length;return o&&i.warn(jt,[o,n||""]),s}(e,(function(e){return"function"==typeof e}),"Integration items must be functions that initialize the integrations")},logger:function(e){var t,n=e.debug,r=e.logger,i=Vr;if(void 0!==n){if(function(e){return gr(e)&&"function"==typeof e.setLogLevel}(n))return n.setLogger(r),n;i="boolean"==typeof(t=e.debug)?t?dr.DEBUG:dr.NONE:"string"==typeof t&&yr(t)?t:void 0}var s=new Tr({logLevel:i||Vr});return s.setLogger(r),i||s._log("error","Invalid `debug` value at config. Logs will be disabled."),s},consent:function(e){var t=e.userConsent,n=e.log;return t=h(t),Jr.indexOf(t)>-1?t:(n.error(bn,["userConsent",Jr,F]),F)}};var $r=new Set(["splitsdkclientkey","splitsdkversion","splitsdkmachineip","splitsdkmachinename","splitsdkimpressionsmode","host","referrer","content-type","content-length","content-encoding","accept","keep-alive","x-fastly-debug"]);function Zr(e,t){var n;if(null===(n=e.sync.requestOptions)||void 0===n?void 0:n.getHeaderOverrides)try{var r=e.sync.requestOptions.getHeaderOverrides({headers:Jn({},t)});Object.keys(r).filter((function(e){return!$r.has(e.toLowerCase())})).forEach((function(e){return t[e]=r[e]}))}catch(t){e.log.error("Problem adding custom headers to request decorator: "+t)}return t}function Xr(e,t){return e<1?t:new Promise((function(n,r){var i=setTimeout((function(){r(new Error("Operation timed out because it exceeded the configured time limit of "+e+" ms."))}),e);t.then((function(e){clearTimeout(i),n(e)}),(function(e){clearTimeout(i),r(e)}))}))}var ei=100,ti="Global fetch API is not available.";var ni={headers:{"Cache-Control":"no-cache"}};function ri(e){return"users="+encodeURIComponent(e)}function ii(e,t,n){var r=e.urls,i=e.sync.__splitFiltersValidation&&e.sync.__splitFiltersValidation.queryString,s=e.sync.impressionsMode,o=function(e,t){var n=t.getOptions,r=t.getFetch,i=e.log,s=e.core.authorizationKey,o=e.version,a=e.runtime,u=a.ip,c=a.hostname,l=n&&n(e),f=r&&r(e);f||i.error(tn,[ti]);var h={Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+s,SplitSDKVersion:o};return u&&(h.SplitSDKMachineIP=u),c&&(h.SplitSDKMachineName=c.replace(/[^\x00-\xFF]/g,"")),function(t,n,r,s){void 0===n&&(n={}),void 0===r&&(r=function(){}),void 0===s&&(s=!1);var o=Jn({headers:Zr(e,Jn({},h,n.headers||{})),method:n.method||"GET",body:n.body},l);return f?f(t,o).then((function(e){return e.ok?(r(),e):Xr(ei,e.text()).then((function(t){return Promise.reject({response:e,message:t})}),(function(){return Promise.reject({response:e})}))})).catch((function(e){var n=e&&e.response,o="";o=n?404===n.status?"Invalid SDK key or resource not found.":e.message:e.message||"Network Error",n&&403===n.status||i[s?"info":"error"](En,[n?"status code "+n.status:"no status code",t,o]);var a=new Error(o);throw a.statusCode=n&&n.status,r(a),a})):Promise.reject(new Error(ti))}}(e,t);return{getSdkAPIHealthCheck:function(){var e=r.sdk+"/version";return o(e).then((function(){return!0})).catch((function(){return!1}))},getEventsAPIHealthCheck:function(){var e=r.events+"/version";return o(e).then((function(){return!0})).catch((function(){return!1}))},fetchAuth:function(t){var i=r.auth+"/v2/auth?s="+e.sync.flagSpecVersion;if(t){var s=t.map(ri).join("&");s&&(i+="&"+s)}return o(i,void 0,n.trackHttp(te))},fetchSplitChanges:function(t,s,a,u){var c=r.sdk+"/splitChanges?s="+e.sync.flagSpecVersion+"&since="+t+(u?"&rbSince="+u:"")+(i||"")+(a?"&till="+a:"");return o(c,s?ni:void 0,n.trackHttp(Y)).catch((function(t){throw 414===t.statusCode&&e.log.error(kn),t}))},fetchSegmentChanges:function(e,t,i,s){var a=r.sdk+"/segmentChanges/"+t+"?since="+e+(s?"&till="+s:"");return o(a,i?ni:void 0,n.trackHttp(ne))},fetchMemberships:function(e,t,i){var s=r.sdk+"/memberships/"+encodeURIComponent(e)+(i?"?till="+i:"");return o(s,t?ni:void 0,n.trackHttp(re))},postEventsBulk:function(e,t){var i=r.events+"/events/bulk";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(X))},postTestImpressionsBulk:function(e,t){var i=r.events+"/testImpressions/bulk";return o(i,{method:"POST",body:e,headers:Jn({SplitSDKImpressionsMode:s},t)},n.trackHttp($))},postTestImpressionsCount:function(e,t){var i=r.events+"/testImpressions/count";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(Z))},postUniqueKeysBulkCs:function(e,t){var i=r.telemetry+"/v1/keys/cs";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(ee))},postUniqueKeysBulkSs:function(e,t){var i=r.telemetry+"/v1/keys/ss";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(ee))},postMetricsConfig:function(e,t){var i=r.telemetry+"/v1/metrics/config";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(ee),!0)},postMetricsUsage:function(e,t){var i=r.telemetry+"/v1/metrics/usage";return o(i,{method:"POST",body:e,headers:t},n.trackHttp(ee),!0)}}}function si(e,t,n,r){void 0===r&&(r="task");var i,s,o,a=0,u=!1,c=0;function l(){for(var n=[],s=0;s0},start:function(){for(var t=[],i=0;i0&&(a=ai(a,i)),o.setOnFullQueueCb((function(){a.isRunning()&&(n.info(pt,[o.name]),a.execute())})),a}function ci(e,t){var n=function(e,t){var n={};if(Array.isArray(e)&&f(t))for(var r=0;r0?n=t:e.error(yn,[_n,Ei]):e.error(vn,[_n,Ei]),n}(e,t);return n&&(Ci[n]?(e.warn(Gt,[Ci[n]+" factory/ies with this SDK Key"]),Ci[n]++):(Ci[n]=1,Object.keys(Ci).length>1&&e.warn(Gt,["an instance of the Split factory"]))),n}function Ni(e){var t=e();return function(){return Math.round(e()-t)}}var _i=((Ti={})[C]=0,Ti[N]=1,Ti[_]=2,Ti),Ai=((Ri={})[T]=0,Ri[E]=1,Ri[R]=2,Ri),Ii=((ki={})[D]=1,ki[F]=2,ki[L]=3,ki);function Oi(e,t){return{name:"telemetry config",isEmpty:function(){return!1},clear:function(){},pop:function(){var n,r,i=t.urls,s=t.scheduler,o=Pr(t),a=function(e){var t=0;e.validFilters.forEach((function(e){"bySet"===e.type&&(t+=e.values.length)}));var n=e.groupedFilters.bySet.length;return{flagSetsTotal:t,flagSetsIgnored:t-n}}(t.sync.__splitFiltersValidation),u=a.flagSetsTotal,c=a.flagSetsIgnored;return Jn((n=t.mode,r=t.storage.type,{oM:_i[n],st:r.toLowerCase(),aF:Object.keys(Ci).length,rF:Object.keys(Ci).reduce((function(e,t){return e+Ci[t]-1}),0)}),{sE:t.streamingEnabled,rR:{sp:s.featuresRefreshRate/1e3,se:o?s.segmentsRefreshRate/1e3:void 0,ms:o?void 0:s.segmentsRefreshRate/1e3,im:s.impressionsRefreshRate/1e3,ev:s.eventsPushRate/1e3,te:s.telemetryRefreshRate/1e3},uO:{s:i.sdk!==fr.urls.sdk,e:i.events!==fr.urls.events,a:i.auth!==fr.urls.auth,st:i.streaming!==fr.urls.streaming,t:i.telemetry!==fr.urls.telemetry},iQ:s.impressionsQueueSize,eQ:s.eventsQueueSize,iM:Ai[t.sync.impressionsMode],iL:!!t.impressionListener,hP:!1,tR:e.getTimeUntilReady(),tC:e.getTimeUntilReadyFromCache(),nR:e.getNonReadyUsage(),t:e.popTags(),i:t.integrations&&t.integrations.map((function(e){return e.type})),uC:t.userConsent?Ii[t.userConsent]:0,fsT:u,fsI:c})}}}var Fi=9e5;function Li(e){var t=e.settings,n=t.log,r=t.core.key,i=e.splitApi,s=i.postUniqueKeysBulkCs,o=i.postUniqueKeysBulkSs,a=e.storage.uniqueKeys,u=oi(n,void 0!==r?s:o,a,Fi);return a.setOnFullQueueCb((function(){u.isRunning()&&(n.info(pt,[a.name]),u.execute())})),u}function Di(e){var t=[li(e),ui(e),pi(e),Li(e)],n=function(e){var t=e.storage.telemetry,n=e.platform.now;if(t&&n){var r=e.settings,i=e.settings,s=i.log,o=i.scheduler.telemetryRefreshRate,a=e.splitApi,u=e.readiness,c=e.sdkReadinessManager,l=Ni(n),f=ai(oi(s,a.postMetricsUsage,t,o,void 0,0,!0),o);return u.gate.once(Si,(function(){t.recordTimeUntilReadyFromCache(l())})),c.incInternalReadyCbCount(),u.gate.once(yi,(function(){t.recordTimeUntilReady(l()),f.isRunning()&&oi(s,a.postMetricsConfig,Oi(t,r),0,void 0,0,!0).execute()})),f}}(e);return{start:function(e){e||t.forEach((function(e){return e.start()})),n&&n.start()},stop:function(e){t.forEach((function(e){return e.stop()})),!e&&n&&n.stop()},isRunning:function(){return t.some((function(e){return e.isRunning()}))},execute:function(e){var r=e?[]:t.map((function(e){return e.execute()}));return n&&r.push(n.execute()),Promise.all(r)},isExecuting:function(){return t.some((function(e){return e.isExecuting()}))}}}var Mi,Ki=600,xi="PUSH_NONRETRYABLE_ERROR",Pi="PUSH_RETRYABLE_ERROR",Ui="PUSH_SUBSYSTEM_UP",Bi="PUSH_SUBSYSTEM_DOWN",ji="MEMBERSHIPS_MS_UPDATE",qi="MEMBERSHIPS_LS_UPDATE",zi="SEGMENT_UPDATE",Wi="SPLIT_KILL",Gi="SPLIT_UPDATE",Hi="RB_SEGMENT_UPDATE",Qi="CONTROL",Vi="OCCUPANCY";function Ji(e){var t=e.userConsent;return!t||t===F}function Yi(e,t){return function(n){var r=n.settings,i=n.settings,s=i.log,o=i.streamingEnabled,a=i.sync.enabled,u=n.telemetryTracker,c=n.storage,l=n.readiness,f=e&&e(n),h=a&&o&&f&&t?t(n,f):void 0,p=Di(n);h&&(h.on(Ui,(function(){s.info(vt),f.isRunning()&&(f.stop(),u.streamingEvent(ye,be)),f.syncAll()})),h.on(Bi,(function(){f.isRunning()?s.info(mt):(s.info(dt),f.start(),u.streamingEvent(ye,Ee))})));var g=!1,d=!0;return{pollingManager:f,pushManager:h,submitterManager:p,start:function(){return g=!0,p.start(!Ji(r)),Promise.resolve(!!c.validateCache&&c.validateCache()).then((function(e){g&&(d&&e&&l.splits.emit(di),f&&(a?h?(d&&f.syncAll(),h.start()):f.start():d&&f.syncAll()),d=!1)}))},stop:function(){g=!1,h&&h.stop(),f&&f.isRunning()&&f.stop(),p.stop()},isRunning:function(){return g},flush:function(){return p.execute(!Ji(r))},shared:function(e,t,n){if(f){var r=f.add(e,t,n);return a&&h&&h.add(e,r),g&&(a?h?f.isRunning()?Nr(n)&&r.start():r.execute():Nr(n)&&r.start():t.isReady()||r.execute()),{stop:function(){var t=f.get(e);t&&(h&&h.remove(e),t.isRunning()&&t.stop(),f.remove(e))},flush:function(){return Promise.resolve()}}}}}}}!function(e){e.STREAMING_DISABLED="STREAMING_DISABLED",e.STREAMING_PAUSED="STREAMING_PAUSED",e.STREAMING_RESUMED="STREAMING_RESUMED",e.STREAMING_RESET="STREAMING_RESET"}(Mi||(Mi={}));var $i=function(){function e(t,n,r){this.baseMillis=e.__TEST__BASE_MILLIS||n||e.DEFAULT_BASE_MILLIS,this.maxMillis=e.__TEST__MAX_MILLIS||r||e.DEFAULT_MAX_MILLIS,this.attempts=0,this.cb=t}return e.prototype.scheduleCall=function(){var e=this,t=Math.min(this.baseMillis*Math.pow(2,this.attempts),this.maxMillis);return this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout((function(){e.timeoutID=void 0,e.cb()}),t),this.attempts++,t},e.prototype.reset=function(){this.attempts=0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=void 0)},e.DEFAULT_BASE_MILLIS=1e3,e.DEFAULT_MAX_MILLIS=18e5,e}();var Zi=[/control_pri$/,/control_sec$/],Xi=[10,20];function es(e,t,n){var r=function(e,t){var n=Zi.map((function(e){return{regex:e,hasPublishers:!0,oTime:-1,cTime:-1}})),r=!0,i=!0;return{handleOpen:function(){t.streamingEvent(pe),e.emit(Ui)},isStreamingUp:function(){return i&&r},handleOccupancyEvent:function(s,o,a){for(var u=0;uc.oTime){c.oTime=a,c.hasPublishers=0!==s;var l=n.some((function(e){return e.hasPublishers}));i&&(!l&&r?e.emit(Bi):l&&!r&&e.emit(Ui)),r=l}return}}},handleControlEvent:function(s,o,a){if(s!==Mi.STREAMING_RESET)for(var u=0;uc.cTime&&(c.cTime=a,s===Mi.STREAMING_DISABLED?(t.streamingEvent(ge,Re),e.emit(xi)):r&&(s===Mi.STREAMING_PAUSED&&i?(t.streamingEvent(ge,Ce),e.emit(Bi)):s!==Mi.STREAMING_RESUMED||i||(t.streamingEvent(ge,ke),e.emit(Ui))),i=s===Mi.STREAMING_RESUMED))}else e.emit(s)}}}(t,n);return{handleOpen:function(){r.handleOpen()},handleError:function(r){var i=r;try{i=function(e){return f(e.data)&&(e.parsedData=JSON.parse(e.data)),e}(r)}catch(t){e.warn(At,[t])}var s=i.parsedData&&i.parsedData.message||i.message;e.error(rn,[s]),!function(e){if(e.parsedData&&e.parsedData.code){var t=e.parsedData.code;if(n.streamingEvent(ve,t),40140<=t&&t<=40149)return!0;if(4e4<=t&&t<=49999)return!1}else n.streamingEvent(de,Te);return!0}(i)?t.emit(xi):t.emit(Pi)},handleMessage:function(n){var i;try{if(i=function(e){if(e.data){var t=JSON.parse(e.data);return t.parsedData=JSON.parse(t.data),t.name&&"[meta]occupancy"===t.name&&(t.parsedData.type=Vi),t}}(n),!i)return}catch(t){return void e.warn(It,[t])}var s=i.parsedData,o=i.data,a=i.channel,u=i.timestamp;if(e.debug(Ge,[o]),r.isStreamingUp()||-1!==[Vi,Qi].indexOf(s.type))switch(s.type){case Gi:case zi:case ji:case qi:case Wi:case Hi:t.emit(s.type,s);break;case Vi:r.handleOccupancyEvent(s.metrics.publishers,a,u);break;case Qi:r.handleControlEvent(s.controlType,a,u)}}}}var ts=1e4,ns=6e4,rs=10;function is(e,t,n,r){var i,s,o;function a(t){var i,a,u,c=0,l=-1,f=!1,h=new $i(p);function p(){if(i=!0,c>Math.max(l,t.getChangeNumber())){f=!1;var g=c;(s?new Promise((function(e){o=setTimeout((function(){s=void 0,n.execute(u,!0,a?c:void 0).then(e)}),s)})):n.execute(u,!0,a?c:void 0)).then((function(n){if(i){if(!1!==n){var s=t.getChangeNumber();l=s>-1?s:Math.max(l,g)}if(f)p();else{u&&r.trackUpdatesFromSSE(re);var o=h.attempts+1;if(c<=l)return e.debug("Refresh completed"+(a?" bypassing the CDN":"")+" in "+o+" attempts."),void(i=!1);if(o(n.getChangeNumber(r)||-1)?(a=!1,t.execute(!1,r,!0,s?o:void 0).then((function(){if(i)if(a)c();else{var t=u.attempts+1;if(o<=(n.getChangeNumber(r)||-1))return e.debug("Refresh completed"+(s?" bypassing the CDN":"")+" in "+t+" attempts."),void(i=!1);if(t>>1|(21845&h)<<1;p=(61680&(p=(52428&p)>>>2|(13107&p)<<2))>>>4|(3855&p)<<4,f[h]=((65280&p)>>>8|(255&p)<<8)>>>1}var g=function(e,n,r){for(var i=e.length,s=0,o=new t(n);s>>c]=l}else for(a=new t(i),s=0;s>>15-e[s]);return a},d=new e(288);for(h=0;h<144;++h)d[h]=8;for(h=144;h<256;++h)d[h]=9;for(h=256;h<280;++h)d[h]=7;for(h=280;h<288;++h)d[h]=8;var m=new e(32);for(h=0;h<32;++h)m[h]=5;var v=g(d,9,1),y=g(m,5,1),S=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},b=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},E=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},T=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],R=function(e,t,n){var r=new Error(t||T[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,R),!n)throw r;return r},k=function(o,a,c){var f=o.length;if(!f||c&&c.f&&!c.l)return a||new e(0);var h=!a||c,p=!c||c.i;c||(c={}),a||(a=new e(3*f));var d=function(t){var n=a.length;if(t>n){var r=new e(Math.max(2*n,t));r.set(a),a=r}},m=c.f||0,T=c.p||0,k=c.b||0,C=c.l,w=c.d,N=c.m,_=c.n,A=8*f;do{if(!C){m=b(o,T,1);var I=b(o,T+1,3);if(T+=3,!I){var O=o[(q=4+((T+7)/8|0))-4]|o[q-3]<<8,F=q+O;if(F>f){p&&R(0);break}h&&d(k+O),a.set(o.subarray(q,F),k),c.b=k+=O,c.p=T=8*F,c.f=m;continue}if(1==I)C=v,w=y,N=9,_=5;else if(2==I){var L=b(o,T,31)+257,D=b(o,T+10,15)+4,M=L+b(o,T+5,31)+1;T+=14;for(var K=new e(M),x=new e(19),P=0;P>>4)<16)K[P++]=q;else{var W=0,G=0;for(16==q?(G=3+b(o,T,3),T+=2,W=K[P-1]):17==q?(G=3+b(o,T,7),T+=3):18==q&&(G=11+b(o,T,127),T+=7);G--;)K[P++]=W}}var H=K.subarray(0,L),Q=K.subarray(L);N=S(H),_=S(Q),C=g(H,N,1),w=g(Q,_,1)}else R(1);if(T>A){p&&R(0);break}}h&&d(k+131072);for(var V=(1<>>4;if((T+=15&W)>A){p&&R(0);break}if(W||R(2),$<256)a[k++]=$;else{if(256==$){Y=T,C=null;break}var Z=$-254;if($>264){var X=r[P=$-257];Z=b(o,T,(1<>>4;ee||R(3),T+=15ⅇQ=l[te];if(te>3){X=i[te];Q+=E(o,T)&(1<A){p&&R(0);break}h&&d(k+131072);for(var ne=k+Z;kr.length)&&(s=r.length);var o=new(r instanceof t?t:r instanceof n?n:e)(s-i);return o.set(r.subarray(i,s)),o}(a,0,k)};return{gunzipSync:function(t,n){return k(t.subarray(function(e){31==e[0]&&139==e[1]&&8==e[2]||R(6,"invalid gzip data");var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)}(t),-8),n||new e((i=(r=t).length,(r[i-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0)));var r,i},unzlibSync:function(e,t){return k(((8!=(15&(n=e)[0])||n[0]>>>4>7||(n[0]<<8|n[1])%31)&&R(6,"invalid zlib data"),32&n[1]&&R(6,"invalid zlib data: preset dictionaries not supported"),e.subarray(2,-4)),t);var n}}}(),as="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function us(e){var t=String(e).replace(/[=]+$/,"");if(t.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var n="",r=0,i=void 0,s=void 0,o=0;s=t.charAt(o++);~s&&(i=r%4?64*i+s:s,r++%4)?n+=String.fromCharCode(255&i>>(-2*r&6)):0)s=as.indexOf(s);return n}var cs=String.fromCharCode;function ls(e){var t,n,r,i,s;return n=function(e){if("string"!=typeof e)throw TypeError("Illegal argument: "+typeof e);var t=0;return function(){return t>=e.length?null:e.charCodeAt(t++)}}(e),i=[],s=[],r=t=function(){if(0===arguments.length)return s.join("")+cs.apply(String,i);i.length+arguments.length>1024&&(s.push(cs.apply(String,i)),i.length=0),Array.prototype.push.apply(i,arguments)},function(e,t){for(var n,r=null;null!==(n=null!==r?r:e());)n>=55296&&n<=57343&&null!==(r=e())&&r>=56320&&r<=57343?(t(1024*(n-55296)+r-56320+65536),r=null):t(n);null!==r&&t(r)}(n,(function(e){!function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<128?t(127&n):n<2048?(t(n>>6&31|192),t(63&n|128)):n<65536?(t(n>>12&15|224),t(n>>6&63|128),t(63&n|128)):(t(n>>18&7|240),t(n>>12&63|128),t(n>>6&63|128),t(63&n|128)),n=null}(e,r)})),t()} +/*! + * +----------------------------------------------------------------------------------+ + * | murmurHash3.js v3.0.0 (http://github.com/karanlyons/murmurHash3.js) | + * | A TypeScript/JavaScript implementation of MurmurHash3's hashing algorithms. | + * |----------------------------------------------------------------------------------| + * | Copyright (c) 2012-2020 Karan Lyons. Freely distributable under the MIT license. | + * +----------------------------------------------------------------------------------+ + */function fs(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function hs(e,t){return e<>>32-t}function ps(e,t){t=t||0;for(var n,r=(e=e||"").length%4,i=e.length-r,s=t,o=0,a=3432918353,u=461845907,c=0;c>>16,2246822507),(s=(n=fs(n^=n>>>13,3266489909))^n>>>16)>>>0}function gs(e,t){return ps(ls(e),t>>>0)}function ds(e,t){return Math.abs(gs(e,t)%100)+1}var ms=1,vs=2;function ys(e,t){var n,r=us(e),i=(n=r.split("").map((function(e){return e.charCodeAt(0)})),new Uint8Array(n));if("string"==typeof os)throw new Error(os);if(t===ms)return os.gunzipSync(i);if(t===vs)return os.unzlibSync(i);throw new Error("Invalid compression algorithm #"+t)}function Ss(e,t,n){void 0===n&&(n=!0);var r,i=ys(e,t),s=(r=i,String.fromCharCode.apply(null,r));return n&&(s=s.replace(/\d+/g,'"$&"')),JSON.parse(s)}var bs=6e4;function Es(e,t){if(0===e.h)return 0;var n=e.i||bs;return gs(t,e.s||0)%n}function Ts(e,t,n,r,i,s){var o=u(t.splits),a=u(t.rbSegments);function u(t){var r,u,c,l=-1,f=!1,h=new $i(p,ts,ns);function p(){r=!0,l>t.getChangeNumber()?(f=!1,n.execute(!0,u?l:void 0,c).then((function(){if(r)if(f)p();else{c&&i.trackUpdatesFromSSE(Y),s&&s.execute(!0);var t=h.attempts+1;if(o.isSync()&&a.isSync())return e.debug("Refresh completed"+(u?" bypassing the CDN":"")+" in "+t+" attempts."),void(r=!1);if(t0?Ss(i,r,!1):JSON.parse(us(i)));if(n)return void(t.type===Hi?a:o).put(t,n)}catch(n){e.warn(Qt,[t.type,n])}var r,i;(t.type===Hi?a:o).put(t)},killSplit:function(e){var n=e.changeNumber,i=e.splitName,s=e.defaultTreatment;t.splits.killLocally(i,s,n)&&r.emit(gi,!0),o.put({changeNumber:n})},stop:function(){o.stop(),a.stop()}}}function Rs(e){return function(t){return e(t).then((function(e){return e.json()})).then((function(e){if(e.token){var t=(r=e.token,i=r.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(us(i).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join("")),JSON.parse(s));if("number"!=typeof t.iat||"number"!=typeof t.exp)throw new Error('token properties "issuedAt" (iat) or "expiration" (exp) are missing or invalid');var n=JSON.parse(t["x-ably-capability"]);return Jn({decodedToken:t,channels:n},e)}var r,i,s;return e}))}}function ks(e){return function(e){for(var t=String(e),n="",r=void 0,i=void 0,s=0,o=as;t.charAt(0|s)||(o="=",s%1);n+=o.charAt(63&r>>8-s%1*8)){if((i=t.charCodeAt(s+=3/4))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|i}return n}(gs(e,0).toString())}var Cs=/^control_/;var ws,Ns,_s=function(){function e(e,t){var n=t.getEventSource,r=t.getOptions;if(this.settings=e,this.eventSource=n&&n(e),!this.eventSource)throw new Error("EventSource API is not available.");this.headers=function(e){var t={SplitSDKClientKey:f(e.core.authorizationKey)?e.core.authorizationKey.slice(-4):"",SplitSDKVersion:e.version},n=e.runtime,r=n.ip,i=n.hostname;return r&&(t.SplitSDKMachineIP=r),i&&(t.SplitSDKMachineName=i),t}(e),this.options=r&&r(e)}return e.prototype.setEventHandler=function(e){this.handler=e},e.prototype.open=function(e){var t;this.close();var n=Object.keys(e.channels).map((function(e){var t=Cs.test(e)?"[?occupancy=metrics.publishers]":"";return encodeURIComponent(t+e)})).join(","),r=this.settings.urls.streaming+"/sse?channels="+n+"&accessToken="+e.token+"&v=1.1&heartbeats=true",i=Pr(this.settings);this.connection=new this.eventSource(i?r:r+"&SplitSDKVersion="+this.headers.SplitSDKVersion+"&SplitSDKClientKey="+this.headers.SplitSDKClientKey,Jn(i?{headers:Zr(this.settings,this.headers)}:(null===(t=this.settings.sync.requestOptions)||void 0===t?void 0:t.getHeaderOverrides)?{headers:Zr(this.settings,{})}:{},this.options)),this.handler&&(this.connection.addEventListener("open",this.handler.handleOpen),this.connection.addEventListener("message",this.handler.handleMessage),this.connection.addEventListener("error",this.handler.handleError))},e.prototype.close=function(){this.connection&&this.connection.close()},e}();function As(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var n=[0,0,0,0];return n[3]+=e[3]+t[3],n[2]+=n[3]>>>16,n[3]&=65535,n[2]+=e[2]+t[2],n[1]+=n[2]>>>16,n[2]&=65535,n[1]+=e[1]+t[1],n[0]+=n[1]>>>16,n[1]&=65535,n[0]+=e[0]+t[0],n[0]&=65535,[n[0]<<16|n[1],n[2]<<16|n[3]]}function Is(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var n=[0,0,0,0];return n[3]+=e[3]*t[3],n[2]+=n[3]>>>16,n[3]&=65535,n[2]+=e[2]*t[3],n[1]+=n[2]>>>16,n[2]&=65535,n[2]+=e[3]*t[2],n[1]+=n[2]>>>16,n[2]&=65535,n[1]+=e[1]*t[3],n[0]+=n[1]>>>16,n[1]&=65535,n[1]+=e[2]*t[2],n[0]+=n[1]>>>16,n[1]&=65535,n[1]+=e[3]*t[1],n[0]+=n[1]>>>16,n[1]&=65535,n[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],n[0]&=65535,[n[0]<<16|n[1],n[2]<<16|n[3]]}function Os(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])}function Fs(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=Ls(e=Is(e,[4283543511,3981806797]),[0,e[0]>>>1]),e=Ls(e=Is(e,[3301882366,444984403]),[0,e[0]>>>1])}function Ms(e,t){return function(e,t){t=t||0;for(var n=(e=e||"").length%16,r=e.length-n,i=[0,t],s=[0,t],o=[0,0],a=[0,0],u=[2277735313,289559509],c=[1291169091,658871167],l=0;l>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)+("00000000"+(s[0]>>>0).toString(16)).slice(-8)+("00000000"+(s[1]>>>0).toString(16)).slice(-8)}(ls(e),t>>>0)}function Ks(e){var t,n,r,i=[0];for(t=0;t=0;n-=1)i[n]=16*i[n]+r,r=i[n]/10|0,i[n]%=10;for(;r>0;)i.unshift(r%10),r=r/10|0}return i.join("")}function xs(e,t){var n,r=e.settings,i=e.storage,o=e.splitApi,a=e.readiness,u=e.platform,c=e.telemetryTracker,l=Pr(r)?void 0:Kr(r.core.key),f=r.log;try{n=new _s(r,u)}catch(e){return void f.warn(Ot,[e])}var h=Rs(o.fetchAuth),p=new u.EventEmitter,g=es(f,p,c);n.setEventHandler(g);var d,m,v,y,S=l?void 0:ss(f,t.segmentsSyncTask,i.segments),b=Ts(f,i,t.splitsSyncTask,a.splits,c,l?void 0:t.segmentsSyncTask),E={},T={},R=!1,k=new $i(C,r.scheduler.pushRetryBackoffBase);function C(){if(!d){f.info(lt),d=!1;var e=l?Object.keys(T):void 0;h(e).then((function(t){if(!d)return t.pushEnabled?void(e&&e.length=0?e.connDelay:60;f.info(ut,[r,i]),v=setTimeout(C,1e3*r),y=setTimeout((function(){d||n.open(e)}),1e3*i),c.streamingEvent(me,t.exp)}(t)):(f.info(ft),void p.emit(xi))})).catch((function(e){if(!d){if(f.error(sn,[e.message]),e.statusCode>=400&&e.statusCode<500)return c.streamingEvent(Se),void p.emit(xi);p.emit(Pi)}}))}}function w(){d||(d=!0,n.close(),f.info(ht),v&&clearTimeout(v),y&&clearTimeout(y),k.reset(),N())}function N(){b.stop(),l?s(T,(function(e){return e.worker.stop()})):S.stop()}function _(e){switch(e.u){case Ns.BoundedFetchRequest:var t;try{o=e.d,a=e.c,t=ys(o,a)}catch(e){f.warn(Ht,["BoundedFetchRequest",e]);break}return void s(T,(function(n,r){var i,s,o,a,u=n.hash64,c=n.worker;i=t,s=u.hex,o=parseInt(s.slice(8),16)%(8*i.length),a=o%8,(i[Math.floor(o/8)]&1<0&&c.put(e,void 0,Es(e,r))}));case Ns.KeyList:var n,r,i=void 0;try{i=Ss(e.d,e.c),n=new Set(i.a),r=new Set(i.r)}catch(e){f.warn(Ht,["KeyList",e]);break}if(!e.n||!e.n.length){f.warn(Ht,["KeyList","No segment name was provided"]);break}return void s(T,(function(t){var i=t.hash64,s=t.worker,o=!!n.has(i.dec)||!r.has(i.dec)&&void 0;void 0!==o&&s.put(e,{added:o?[e.n[0]]:[],removed:o?[]:[e.n[0]]})}));case Ns.SegmentRemoval:if(!e.n||!e.n.length){f.warn(Ht,["SegmentRemoval","No segment name was provided"]);break}return void s(T,(function(t){t.worker.put(e,{added:[],removed:e.n})}))}var o,a;s(T,(function(t,n){t.worker.put(e,void 0,Es(e,n))}))}return p.on(Bi,N),p.on(Ui,(function(){k.reset()})),p.on(xi,(function(){m=!0,w(),p.emit(Bi)})),p.on(Pi,(function(){n.close();var e=k.scheduleCall();f.info(ct,[e/1e3]),p.emit(Bi)})),p.on(Mi.STREAMING_RESET,(function(){d||(v&&clearTimeout(v),C())})),p.on(Wi,b.killSplit),p.on(Gi,b.put),p.on(Hi,b.put),l?(p.on(ji,_),p.on(qi,_)):p.on(zi,S.put),Jn(Object.create(p),{stop:function(){w(),l&&this.remove(l)},start:function(){m||!1===d||(d=!1,l?this.add(l,t.segmentsSyncTask):setTimeout(C))},isRunning:function(){return!1===d},add:function(e,t){var n,r,s=ks(e);E[s]||(E[s]=e,T[e]={hash64:(n=e,r=Ms(n).slice(0,16),{hex:r,dec:Ks(r)}),worker:is(f,i,t,c)},R=!0,this.isRunning()&&setTimeout((function(){R&&(R=!1,C())}),0))},remove:function(e){var t=ks(e);delete E[t],delete T[e]}})}function Ps(e,t,n,r,i,s,o){var a=n.segments,u=n.largeSegments,c=!0,l=!0;function f(e){return l&&(e=Xr(i,e)),e}function h(e){var t;void 0!==e.type?t=e.type===qi?u.resetSegments(e):a.resetSegments(e):(t=a.resetSegments(e.ms||{}),t=u.resetSegments(e.ls||{})||t),n.save&&n.save(),Nr(n)&&(t||c)&&(c=!1,r.emit(mi))}function p(n,r,i,a){var u=r?new Promise((function(e){h(r),e(!0)})):t(o,i,a,f).then((function(e){return h(e),l=!1,!0}));return u.catch((function(t){return l&&s>n?(n+=1,e.warn(Nt,[n,t]),p(n)):(l=!1,!1)}))}return function(e,t,n){return p(0,e,t,n)}}!function(e){e[e.None=0]="None",e[e.Gzip=1]="Gzip",e[e.Zlib=2]="Zlib"}(ws||(ws={})),function(e){e[e.UnboundedFetchRequest=0]="UnboundedFetchRequest",e[e.BoundedFetchRequest=1]="BoundedFetchRequest",e[e.KeyList=2]="KeyList",e[e.SegmentRemoval=3]="SegmentRemoval"}(Ns||(Ns={}));var Us=36e5,Bs=24*Us;function js(e,t,n){var r,i=t.log,s=Pr(t)?Bs:Us;return function o(a,u,c,l,f){r&&Date.now()-r>s&&(t.sync.flagSpecVersion=we);var h=e(a,u,c,t.sync.flagSpecVersion===we?l:void 0).catch((function(n){if((!n.statusCode||400===n.statusCode)&&function(e){return e.urls.sdk!==fr.urls.sdk}(t)&&t.sync.flagSpecVersion===we)return i.error(Pn+"Proxy error detected. Retrying with spec 1.2. If you are using Split Proxy, please upgrade to latest version"),r=Date.now(),t.sync.flagSpecVersion="1.2",e(a,u,c);throw n}));return f&&(h=f(h)),h.then((function(e){return e.json()})).then((function(e){return e.splits?{ff:{d:e.splits,s:e.since,t:e.till}}:r?(i.info(Pn+"Proxy error recovered"),r=void 0,o(-1,void 0,void 0,-1).then((function(e){return Promise.all([n.splits.clear(),n.rbSegments.clear()]).then((function(){return e}))}))):e}))}}function qs(e,t){void 0===t&&(t=Ne);var n=e,r=n.conditions,i=void 0===r?[]:r,s=n.excluded,o=new Set;s&&s.segments&&s.segments.forEach((function(e){var n=e.type,r=e.name;(n===Ae&&t===Ne||n===Ie&&t===_e)&&o.add(r)}));for(var a=0;a0)return e.sets&&e.sets.some((function(e){return r.indexOf(e)>-1}));var o=i.length>0,a=s.length>0;if(!o&&!a)return!0;var u=o&&i.indexOf(e.name)>-1,c=a&&s.some((function(t){return g(e.name,t)}));return u||c}(r,n)?e.removed.push(r):(e.added.push(r),qs(r).forEach((function(e){t.add(e)}))),e}),{added:[],removed:[]})}function Ws(e,t,n,r,i,s,o,a){void 0===s&&(s=0),void 0===o&&(o=0);var u=n.splits,c=n.rbSegments,l=n.segments,f=!0;function h(e){return f&&s&&(e=Xr(s,e)),e}return function(s,p,g){return Promise.all([u.getChangeNumber(),c.getChangeNumber()]).then((function d(m,v){void 0===v&&(v=0);var y=m[0],S=m[1];return e.debug(qe,m),Promise.resolve(g?g.type===Gi?Promise.resolve(c.contains(qs(g.payload,_e))).then((function(e){return e?{ff:{d:[g.payload],t:g.changeNumber}}:t(y,s,p,S,h)})):{rbs:{d:[g.payload],t:g.changeNumber}}:t(y,s,p,S,h)).then((function(t){var s=new Set,o=!1;if(t.ff){var h=zs(t.ff.d,s,r),p=h.added,g=h.removed;e.debug(ze,[p.length,g.length]),o=u.update(p,g,t.ff.t)}var d=!1;if(t.rbs){var m=zs(t.rbs.d,s);p=m.added,g=m.removed;e.debug(We,[p.length,g.length]),d=c.update(p,g,t.rbs.t)}return Promise.all([o,d,l.registerSegments(zr(s))]).then((function(e){var t=e[0],r=e[1];return n.save&&n.save(),f=!1,!i||Promise.resolve(!i.splitsArrived||(t||r)&&(a||function(e){return Promise.resolve(e.getRegisteredSegments()).then((function(t){return Promise.all(t.map((function(t){return e.getChangeNumber(t)}))).then((function(e){return e.every((function(e){return void 0!==e}))}))}))}(l))).catch((function(){return!1})).then((function(e){return e&&i.emit(gi),!0}))}))})).catch((function(t){return f&&o>v?(v+=1,e.warn(at,[v,t]),d(m,v)):(f=!1,e.warn(_t,[t]),!1)}))}))}}function Gs(e){var t=e.splitApi,n=e.storage,r=e.readiness,i=e.settings,o=i.log,a=function(e,t,n,r,i){return si(r.log,Ws(r.log,js(e,r,t),t,r.sync.__splitFiltersValidation,n.splits,r.startup.requestTimeoutBeforeReady,r.startup.retriesOnFailureBeforeReady,i),r.scheduler.featuresRefreshRate,"splitChangesUpdater")}(t.fetchSplitChanges,n,r,i,!0),u={},c=h(Kr(i.core.key),r,n);function l(){s(u,(function(e){e.start()}))}function f(){s(u,(function(e){e.isRunning()&&e.stop()}))}function h(e,n,r){var s=function(e,t,n,r,i){return si(r.log,Ps(r.log,function(e){return function(t,n,r,i){var s=e(t,n,r);return i&&(s=i(s)),s.then((function(e){return e.json()}))}}(e),t,n.segments,r.startup.requestTimeoutBeforeReady,r.startup.retriesOnFailureBeforeReady,i),r.scheduler.segmentsRefreshRate,"mySegmentsUpdater")}(t.fetchMemberships,r,n,i,e);function o(){n.isReady()||Nr(r)||n.segments.emit(mi)}return Nr(r)?n.splits.once(gi,o):setTimeout(o,0),u[e]=s,s}return r.splits.on(gi,(function(){if(a.isRunning()){var e=Nr(n);e!==c.isRunning()&&(o.info(it,[e?"ON":"OFF"]),e?l():f())}})),{splitsSyncTask:a,segmentsSyncTask:c,start:function(){o.info(st),a.start(),Nr(n)&&l()},stop:function(){o.info(ot),a.isRunning()&&a.stop(),f()},isRunning:a.isRunning,syncAll:function(){var e=[a.execute()];return s(u,(function(t){e.push(t.execute())})),Promise.all(e)},add:h,remove:function(e){delete u[e]},get:function(e){return u[e]}}}function Hs(e){return null!=e&&"function"==typeof e.then}function Qs(e,t,n){return null==t||l(t)?t:(e.error(ln,[n,"attributes"]),!1)}function Vs(e,t,n){if(!Qs(e,t,n))return!1;var r=!0;return Object.keys(t).forEach((function(i){(function(e,t,n,r){if(!f(t)||0===t.length)return e.warn(r+": you passed an invalid attribute name, attribute name must be a non-empty string."),!1;var i=f(n),s=u(n),o=a(n),c=Array.isArray(n);return!!(i||s||o||c)||(e.warn(r+": you passed an invalid attribute value for "+t+". Acceptable types are: string, number, boolean and array of strings."),!1)})(e,i,t[i],n)||(r=!1)})),r}var Js=/^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/,Ys="event_type";var $s={NULL:0,STRING:2,BOOLEAN:4,NUMBER:8},Zs=300,Xs=32768,eo=1024;function to(e,t,n){if(null==t)return{properties:null,size:eo};if(!l(t))return e.error(ln,[n,"properties"]),{properties:!1,size:eo};var r=Object.keys(t),i=Jn({},t),s={properties:i,size:eo};r.length>Zs&&e.warn(Mt,[n]);for(var o=0;oXs){e.error(fn,[n]),s.properties=!1;break}}return s}var no=/[A-Z]/,ro="traffic_type";function io(e,t,n){return!t.isDestroyed()||(e.error(pn,[n]),!1)}function so(e,t,n,r){return!!t.isReadyFromCache()||(e.warn(wt,[n,r?" for feature flag "+r.toString():""]),!1)}function oo(e,t,n,r){return io(e,t,n)&&so(e,t,n,r)}var ao="fallback - ",uo=function(){function e(e){void 0===e&&(e={}),this.fallbacks=e}return e.prototype.resolve=function(e,t){var n,r=null===(n=this.fallbacks.byFlag)||void 0===n?void 0:n[e];return r?this.copyWithLabel(r,t):this.fallbacks.global?this.copyWithLabel(this.fallbacks.global,t):{treatment:y,config:null,label:t}},e.prototype.copyWithLabel=function(e,t){return f(e)?{treatment:e,config:null,label:""+ao+t}:{treatment:e.treatment,config:e.config,label:""+ao+t}},e}(),co="killed",lo="default rule",fo="definition not found",ho="not ready",po="exception",go="archived",mo="not in split",vo="targeting rule type unsupported by sdk",yo="prerequisites not met",So=ao+fo;function bo(e,t,n,r,i){return!t.isReady()||r!==fo&&r!==So&&null!=r||(e.warn(Pt,[i,n]),!1)}function Eo(e,t,n){e.warn(Bt,[n,t])}function To(e){var t=e.conditions,n=r(t,(function(e){return"ROLLOUT"===e.conditionType}));return n||(n=t[0]),n?n.partitions.map((function(e){return e.treatment})):[]}function Ro(e){return e?{name:e.name,trafficType:e.trafficTypeName,killed:e.killed,changeNumber:e.changeNumber||0,treatments:To(e),configs:e.configurations||{},sets:e.sets||[],defaultTreatment:e.defaultTreatment,impressionsDisabled:!0===e.impressionsDisabled,prerequisites:(e.prerequisites||[]).map((function(e){return{flagName:e.n,treatments:e.ts}}))}:null}function ko(e){var t=[];return e.forEach((function(e){var n=Ro(e);n&&t.push(n)})),t}function Co(e,t,n){var r=n.readinessManager,i=n.sdkStatus,s=e.log,o=Oe(e.mode);return Jn(Object.create(i),{split:function(e){var n=Qn(s,e,W);if(!oo(s,r,W)||!n)return o?Promise.resolve(null):null;var i=t.getSplit(n);return Hs(i)?i.catch((function(){return null})).then((function(e){return bo(s,r,n,e,W),Ro(e)})):(bo(s,r,n,i,W),Ro(i))},splits:function(){if(!oo(s,r,G))return o?Promise.resolve([]):[];var e=t.getAll();return Hs(e)?e.catch((function(){return[]})).then(ko):ko(e)},names:function(){if(!oo(s,r,H))return o?Promise.resolve([]):[];var e=t.getSplitNames();return Hs(e)?e.catch((function(){return[]})):e}})}var wo=function(){function e(){this.attributesCache={}}return e.prototype.setAttribute=function(e,t){return this.attributesCache[e]=t,!0},e.prototype.getAttribute=function(e){return this.attributesCache[e]},e.prototype.setAttributes=function(e){return this.attributesCache=Jn(this.attributesCache,e),!0},e.prototype.getAll=function(){return this.attributesCache},e.prototype.removeAttribute=function(e){return Object.keys(this.attributesCache).indexOf(e)>=0&&(delete this.attributesCache[e],!0)},e.prototype.clear=function(){return this.attributesCache={},!0},e}();function No(e,t,n){var r=function(e,t){var n=new wo,r=t.getTreatment,i=t.getTreatmentWithConfig,s=t.getTreatments,o=t.getTreatmentsWithConfig,a=t.getTreatmentsByFlagSets,u=t.getTreatmentsWithConfigByFlagSets,c=t.getTreatmentsByFlagSet,l=t.getTreatmentsWithConfigByFlagSet;function f(e){var t=n.getAll();return Object.keys(t).length>0?Jn({},t,e):e}return Jn(t,{getTreatment:function(e,t,n,i){return r(e,t,f(n),i)},getTreatmentWithConfig:function(e,t,n,r){return i(e,t,f(n),r)},getTreatments:function(e,t,n,r){return s(e,t,f(n),r)},getTreatmentsWithConfig:function(e,t,n,r){return o(e,t,f(n),r)},getTreatmentsByFlagSets:function(e,t,n,r){return a(e,t,f(n),r)},getTreatmentsWithConfigByFlagSets:function(e,t,n,r){return u(e,t,f(n),r)},getTreatmentsByFlagSet:function(e,t,n,r){return c(e,t,f(n),r)},getTreatmentsWithConfigByFlagSet:function(e,t,n,r){return l(e,t,f(n),r)},setAttribute:function(t,r){var i={};return i[t]=r,!!Vs(e,i,"setAttribute")&&(e.debug("stored "+r+" for attribute "+t),n.setAttribute(t,r))},getAttribute:function(t){return e.debug("retrieved attribute "+t),n.getAttribute(t+"")},setAttributes:function(t){return!!Vs(e,t,"setAttributes")&&n.setAttributes(t)},getAttributes:function(){return n.getAll()},removeAttribute:function(t){return e.debug("removed attribute "+t),n.removeAttribute(t+"")},clearAttributes:function(){return n.clear()}})}(e,t);return Jn(r,{getTreatment:r.getTreatment.bind(r,n),getTreatmentWithConfig:r.getTreatmentWithConfig.bind(r,n),getTreatments:r.getTreatments.bind(r,n),getTreatmentsWithConfig:r.getTreatmentsWithConfig.bind(r,n),getTreatmentsByFlagSets:r.getTreatmentsByFlagSets.bind(r,n),getTreatmentsWithConfigByFlagSets:r.getTreatmentsWithConfigByFlagSets.bind(r,n),getTreatmentsByFlagSet:r.getTreatmentsByFlagSet.bind(r,n),getTreatmentsWithConfigByFlagSet:r.getTreatmentsWithConfigByFlagSet.bind(r,n),track:r.track.bind(r,n),isClientSide:!0,key:n})}var _o={UNDEFINED:0,ALL_KEYS:1,IN_SEGMENT:2,WHITELIST:3,EQUAL_TO:4,GREATER_THAN_OR_EQUAL_TO:5,LESS_THAN_OR_EQUAL_TO:6,BETWEEN:7,EQUAL_TO_SET:8,CONTAINS_ANY_OF_SET:9,CONTAINS_ALL_OF_SET:10,PART_OF_SET:11,ENDS_WITH:12,STARTS_WITH:13,CONTAINS_STRING:14,IN_SPLIT_TREATMENT:15,EQUAL_TO_BOOLEAN:16,MATCHES_STRING:17,EQUAL_TO_SEMVER:18,GREATER_THAN_OR_EQUAL_TO_SEMVER:19,LESS_THAN_OR_EQUAL_TO_SEMVER:20,BETWEEN_SEMVER:21,IN_LIST_SEMVER:22,IN_LARGE_SEGMENT:23,IN_RULE_BASED_SEGMENT:24},Ao={BOOLEAN:"BOOLEAN",STRING:"STRING",NUMBER:"NUMBER",SET:"SET",DATETIME:"DATETIME",NOT_SPECIFIED:"NOT_SPECIFIED"};function Io(e){return e?e.segmentName||e.largeSegmentName:void 0}function Oo(e){return e&&e.whitelist}function Fo(e){return e.value}function Lo(e){return new Date(e).setUTCHours(0,0,0,0)}function Do(e){return new Date(e).setUTCSeconds(0,0)}function Mo(e){var t=e.map((function(e){var t,n=e.matcherType,r=e.negate,i=e.keySelector,s=e.userDefinedSegmentMatcherData,o=e.userDefinedLargeSegmentMatcherData,a=e.whitelistMatcherData,u=e.unaryNumericMatcherData,c=e.betweenMatcherData,l=e.dependencyMatcherData,f=e.booleanMatcherData,h=e.stringMatcherData,p=e.betweenStringMatcherData,g=i&&i.attribute,d=function(e){var t=_o[e];return t||_o.UNDEFINED}(n),m=Ao.STRING;return d===_o.IN_SEGMENT?t=Io(s):d===_o.IN_LARGE_SEGMENT?t=Io(o):d===_o.EQUAL_TO?(t=Fo(u),m=Ao.NUMBER,"DATETIME"===u.dataType&&(t=Lo(t),m=Ao.DATETIME)):d===_o.GREATER_THAN_OR_EQUAL_TO||d===_o.LESS_THAN_OR_EQUAL_TO?(t=Fo(u),m=Ao.NUMBER,"DATETIME"===u.dataType&&(t=Do(t),m=Ao.DATETIME)):d===_o.BETWEEN?(t=c,m=Ao.NUMBER,"DATETIME"===t.dataType&&(t=function(e){return{dataType:e.dataType,start:Do(e.start),end:Do(e.end)}}(t),m=Ao.DATETIME)):d===_o.BETWEEN_SEMVER?t=p:d===_o.EQUAL_TO_SET||d===_o.CONTAINS_ANY_OF_SET||d===_o.CONTAINS_ALL_OF_SET||d===_o.PART_OF_SET?(t=Oo(a),m=Ao.SET):d===_o.WHITELIST||d===_o.IN_LIST_SEMVER||d===_o.STARTS_WITH||d===_o.ENDS_WITH||d===_o.CONTAINS_STRING?t=Oo(a):d===_o.IN_SPLIT_TREATMENT?(t=l,m=Ao.NOT_SPECIFIED):d===_o.EQUAL_TO_BOOLEAN?(m=Ao.BOOLEAN,t=f):d===_o.MATCHES_STRING||d===_o.EQUAL_TO_SEMVER||d===_o.GREATER_THAN_OR_EQUAL_TO_SEMVER||d===_o.LESS_THAN_OR_EQUAL_TO_SEMVER?t=h:d===_o.IN_RULE_BASED_SEGMENT&&(t=Io(s),m=Ao.NOT_SPECIFIED),{attribute:g,negate:r,type:d,name:n,value:t,dataType:m}}));return-1===i(t,(function(e){return e.type===_o.UNDEFINED}))?t:[]}var Ko=function(){function e(e,t){if(100!==e[e.length-1])throw new RangeError("Provided invalid dataset as input");this._ranges=e,this._treatments=t}return e.parse=function(t){var n=t.reduce((function(e,t){var n=t.size,r=t.treatment;return e.ranges.push(e.inc+=n),e.treatments.push(r),e}),{inc:0,ranges:[],treatments:[]});return new e(n.ranges,n.treatments)},e.prototype.getTreatmentFor=function(e){if(e<0||e>100)throw new RangeError("Please provide a value between 0 and 100");var t=i(this._ranges,(function(t){return e<=t}));return this._treatments[t]},e}();var xo=/^[0-9]+$/,Po=".";function Uo(e,t){if(xo.test(e)&&xo.test(t)){var n=e.length-t.length;if(0!==n)return n}return et?1:0}function Bo(e){return e.replace(/^0+(?=\d)/,"")}function jo(e){throw new Error("Unable to convert to Semver, incorrect format: "+e)}var qo=function(){function e(e){f(e)||jo(e);var t=e.indexOf("+"),n=-1===t?[e]:[e.slice(0,t),e.slice(t+1)],r=n[0],i=n[1];""===i&&jo(e),-1===(t=r.indexOf("-"))?(this._isStable=!0,this._preRelease=[]):(this._isStable=!1,this._preRelease=r.slice(t+1).split(Po).map((function(t){return t||jo(e),xo.test(t)?Bo(t):t})),r=r.slice(0,t));var s=r.split(Po).map((function(t){return t&&xo.test(t)||jo(e),Bo(t)}));3!==s.length&&jo(e),this._major=s[0],this._minor=s[1],this._patch=s[2],this.version=s.join(Po),this._preRelease.length&&(this.version+="-"+this._preRelease.join(Po)),i&&(this.version+="+"+i)}return e.prototype.compare=function(e){if(this.version===e.version)return 0;var t=Uo(this._major,e._major);if(0!==t)return t;if(0!==(t=Uo(this._minor,e._minor)))return t;if(0!==(t=Uo(this._patch,e._patch)))return t;if(!this._isStable&&e._isStable)return-1;if(this._isStable&&!e._isStable)return 1;for(var n=0,r=Math.min(this._preRelease.length,e._preRelease.length);n=e}},function(e){return function(t){return t<=e}},function(e){return function(t){return t>=e.start&&t<=e.end}},function(e){return function(t){for(var n=t.length===e.length,r=function(r){i(e,(function(e){return e===t[r]}))<0&&(n=!1)},s=0;s=0&&(n=!0)},s=0;s-1}))}},function(e,t,n){var r=e.split,i=e.treatments;function s(e,t,r){var i=!1;return Array.isArray(t)&&(i=-1!==t.indexOf(e.treatment)),n.debug(10,[r,e.treatment,e.label,r,t,i]),i}return function(e,o){var a=e.key,u=e.attributes;n.debug(11,[r,JSON.stringify(a),u?"\n attributes: "+JSON.stringify(u):""]);var c=o(n,a,r,u,t);return Hs(c)?c.then((function(e){return s(e,i,r)})):s(c,i,r)}},function(e){return function(t){return e===t}},function(e){var t=new RegExp(e);return function(e){return t.test(e)}},function(e){var t=new qo(e);return function(e){var n=new qo(e);return t.version===n.version}},function(e){var t=new qo(e);return function(e){return new qo(e).compare(t)>=0}},function(e){var t=new qo(e);return function(e){return new qo(e).compare(t)<=0}},function(e){var t=new qo(e.start),n=new qo(e.end);return function(e){var r=new qo(e);return t.compare(r)<=0&&n.compare(r)>=0}},function(e){if(!e||0===e.length)throw new Error("whitelistMatcherData is required for IN_LIST_SEMVER matcher type");var t=new Set(e.map((function(e){return new qo(e).version})));return function(e){var n=new qo(e).version;return t.has(n)}},function(e,t){return function(n){return!!t.largeSegments&&t.largeSegments.isInSegment(e,n)}},function e(t,n,r){return function(i,s){var o=i.key,a=i.attributes,u=Kr(o);function c(e){var t=e.conditions||[];if(!t.length)return!1;var i=Zo(r,t,n)(xr(o),void 0,void 0,void 0,a,s);return Hs(i)?i.then((function(e){return!!e})):!!i}function l(t){var i=t.type,c=t.name;return i===Ae?n.segments.isInSegment(c,u):i===Ie?e(c,n,r)({key:o,attributes:a},s):!("large"!==i||!n.largeSegments)&&n.largeSegments.isInSegment(c,u)}function f(e){if(!e)return!1;var t=function(e){var t=e.excluded||{};return!(!t.keys||-1===t.keys.indexOf(u))||(t.segments||[]).reduce((function(e,t){return Hs(e)?e.then((function(e){return e||l(t)})):e||l(t)}),!1)}(e);return Hs(t)?t.then((function(t){return!t&&c(e)})):!t&&c(e)}var h=n.rbSegments.get(t);return Hs(h)?h.then(f):f(h)}}];function Wo(e,t,n){var r,i=t.type,s=t.value;return zo[i]&&(r=zo[i](s,n,e)),r}function Go(e,t){return{key:e,attributes:t}}function Ho(e,t,n,r,i){var s,o,a=function(e,t){switch(e){case _o.EQUAL_TO:return"DATETIME"===t?Lo:void 0;case _o.GREATER_THAN_OR_EQUAL_TO:case _o.LESS_THAN_OR_EQUAL_TO:case _o.BETWEEN:return"DATETIME"===t?Do:void 0;case _o.IN_SPLIT_TREATMENT:case _o.IN_RULE_BASED_SEGMENT:return Go;default:return}}(t,r);switch(r){case Ao.NUMBER:case Ao.DATETIME:o=d(n),s=isNaN(o)?void 0:o;break;case Ao.STRING:s=function(e){var t=e;return l(e)&&(t=e.matchingKey?e.matchingKey:void 0),m(t)||void 0}(n);break;case Ao.SET:s=function(e){var t=Array.isArray(e)?v(e.map((function(e){return e+""}))):[];return t.length?t:void 0}(n);break;case Ao.BOOLEAN:s=function(e){if(!0===e||!1===e)return e;if("string"==typeof e){var t=e.toLocaleLowerCase();if("true"===t)return!0;if("false"===t)return!1}}(n);break;case Ao.NOT_SPECIFIED:s=n;break;default:s=void 0}return a&&(s=a(s,i)),e.debug(xe,[n,r,s instanceof Object?JSON.stringify(s):s]),s}function Qo(e,t,n,r){var i=n.attribute,s=function(e,t,n,r){var i=void 0;return n?r?(i=r[n],e.debug(Ke,[n,i])):e.warn(kt,[n]):i=t,i}(e,t,i,r),o=Ho(e,n.type,s,n.dataType,r);return void 0!==o?o:void e.warn(Rt,[s+(i?" for attribute "+i:"")])}function Vo(e,t,n,r){var i=ds(t,n),s=r.getTreatmentFor(i);return e.debug(Me,[i,t,n,s]),s}function Jo(e,t,n,r,i,s){if(t)return!i||{treatment:Vo(e,n,r,i),label:s}}function Yo(e,t,n,r,i){return function(s,o,a,u,c,l){if("ROLLOUT"===i&&!function(e,t,n){return!(e<100&&ds(t,n)>e)}(a,s.bucketingKey,u))return{treatment:void 0,label:mo};var f=t(s,c,l);return Hs(f)?f.then((function(t){return Jo(e,t,s.bucketingKey,o,n,r)})):Jo(e,f,s.bucketingKey,o,n,r)}}function $o(e,t){function n(t){var n=t.every((function(e){return e}));return e.debug(Fe,[n]),n}return function(e,r,s){var o=t.map((function(t){return t(e,r,s)}));return-1!==i(o,Hs)?Promise.all(o).then(n):n(o)}}function Zo(e,t,n){for(var r=[],s=0;s0?Promise.all(u).then((function(){return a})):a}var aa={treatment:y,label:ho};function ua(e){var t={};return e.forEach((function(e){t[e]=aa})),t}function ca(e){if(e&&e.properties)try{return JSON.stringify(e.properties)}catch(e){}}function la(e){var t=e.sdkReadinessManager.readinessManager,n=e.storage,r=e.settings,i=e.impressionsTracker,s=e.eventTracker,o=e.telemetryTracker,a=e.fallbackTreatmentsCalculator,u=r.log,c=r.mode,f=Oe(c);function h(e,r,s,a,c,l){void 0===c&&(c=!1),void 0===l&&(l=M);var h=o.trackEval(c?oe:ie),p=function(t){var n=[],o=d(t,r,e,ca(a),c,l,n);return i.track(n,s),h(n[0]&&n[0].imp.label),o},g=t.isReadyFromCache()?ra(u,e,r,s,n,a):f?Promise.resolve(aa):aa;return Hs(g)?g.then((function(e){return p(e)})):p(g)}function p(e,r,s,a,c,l){void 0===c&&(c=!1),void 0===l&&(l=K);var h=o.trackEval(c?ae:se),p=function(t){var n=[],r={},o=ca(a);return Object.keys(t).forEach((function(i){r[i]=d(t[i],i,e,o,c,l,n)})),i.track(n,s),h(n[0]&&n[0].imp.label),r},g=t.isReadyFromCache()?ia(u,e,r,s,n,a):f?Promise.resolve(ua(r)):ua(r);return Hs(g)?g.then((function(e){return p(e)})):p(g)}function g(e,r,s,a,c,l,h){void 0===c&&(c=!1),void 0===l&&(l=ce),void 0===h&&(h=B);var p=o.trackEval(l),g=function(t){var n=[],r={},o=ca(a);return Object.keys(t).forEach((function(i){r[i]=d(t[i],i,e,o,c,h,n)})),i.track(n,s),p(n[0]&&n[0].imp.label),r},m=t.isReadyFromCache()?function(e,t,n,r,i,s,o){var a;function u(a){for(var u,c=new Set,l=0;l-1?function(e,t,n,r){var i=Vn(e,n,t,"flag sets","flag set"),s=i?Xn(e,i,t):[];return r.length>0&&(s=s.filter((function(n){return r.indexOf(n)>-1||(e.warn(Yt,[t,n]),!1)}))),!!s.length&&s}(s,t,o,e.sync.__splitFiltersValidation.groupedFilters.bySet):g(t,K)?Vn(s,o,t):Qn(s,o,t),h=Qs(s,a,t),p=io(s,r,t),d=function(e,t,r){if(l(t)){var i=to(e,t.properties,r).properties,s=i&&Object.keys(i).length>0?{properties:i}:void 0,o=t.impressionsDisabled;return o?s?n(n({},s),{impressionsDisabled:o}):{impressionsDisabled:o}:s}t&&e.error(ln,[r,"evaluation options"])}(s,u,t);return so(s,r,t,f),{valid:p&&c&&f&&!1!==h,key:c,nameOrNames:f,attributes:h,options:d}}function c(e,t){var n=i.resolve(e,""),r=n.treatment,s=n.config;return t?{treatment:r,config:s}:r}function h(e){return o?Promise.resolve(e):e}return{getTreatment:function(e,n,r,i){var s=a(M,e,n,r,i);return s.valid?t.getTreatment(s.key,s.nameOrNames,s.attributes,s.options):h(c(s.nameOrNames,!1))},getTreatmentWithConfig:function(e,n,r,i){var s=a(x,e,n,r,i);return s.valid?t.getTreatmentWithConfig(s.key,s.nameOrNames,s.attributes,s.options):h(c(s.nameOrNames,!0))},getTreatments:function(e,n,r,i){var s=a(K,e,n,r,i);if(s.valid)return t.getTreatments(s.key,s.nameOrNames,s.attributes,s.options);var o={};return s.nameOrNames&&s.nameOrNames.forEach((function(e){return o[e]=c(e,!1)})),h(o)},getTreatmentsWithConfig:function(e,n,r,i){var s=a(P,e,n,r,i);if(s.valid)return t.getTreatmentsWithConfig(s.key,s.nameOrNames,s.attributes,s.options);var o={};return s.nameOrNames&&s.nameOrNames.forEach((function(e){return o[e]=c(e,!0)})),h(o)},getTreatmentsByFlagSets:function(e,n,r,i){var s=a(B,e,n,r,i);return s.valid?t.getTreatmentsByFlagSets(s.key,s.nameOrNames,s.attributes,s.options):h({})},getTreatmentsWithConfigByFlagSets:function(e,n,r,i){var s=a(q,e,n,r,i);return s.valid?t.getTreatmentsWithConfigByFlagSets(s.key,s.nameOrNames,s.attributes,s.options):h({})},getTreatmentsByFlagSet:function(e,n,r,i){var s=a(U,e,[n],r,i);return s.valid?t.getTreatmentsByFlagSet(s.key,s.nameOrNames[0],s.attributes,s.options):h({})},getTreatmentsWithConfigByFlagSet:function(e,n,r,i){var s=a(j,e,[n],r,i);return s.valid?t.getTreatmentsWithConfigByFlagSet(s.key,s.nameOrNames[0],s.attributes,s.options):h({})},track:function(e,n,i,a,c){var l=sr(s,e,z),h=function(e,t,n){if(null==t)e.error(gn,[n,ro]);else if(f(t)){if(0!==t.length)return no.test(t)&&(e.warn(Ut,[n]),t=t.toLowerCase()),t;e.error(yn,[n,ro])}else e.error(vn,[n,ro]);return!1}(s,n,z),p=function(e,t,n){if(null==t)e.error(gn,[n,Ys]);else if(f(t))if(0===t.length)e.error(yn,[n,Ys]);else{if(Js.test(t))return t;e.error(cn,[n,t])}else e.error(vn,[n,Ys]);return!1}(s,i,z),g=function(e,t,n){return u(t)||null==t?t:(e.error(hn,[n]),!1)}(s,a,z),d=to(s,c,z),m=d.properties,v=d.size;return io(s,r,z)&&l&&h&&p&&!1!==g&&!1!==m?t.track(l,h,p,g,m,v):!!o&&Promise.resolve(!1)}}}var ha=1e3;function pa(e,t){var n=e.sdkReadinessManager,r=e.syncManager,i=e.storage,s=e.signalListener,o=e.settings,a=e.telemetryTracker,u=e.uniqueKeysTracker,c=0;function l(){return r?r.flush():Promise.resolve()}return Jn(Object.create(n.sdkStatus),fa(o,la(e),n.readinessManager,e.fallbackTreatmentsCalculator),{flush:function(){return function(e,t){var n=Date.now(),r=n-c;return ra?e:a+1}var c=!1;n.splitsCacheLoaded?c=!0:n.once(di,(function(){if(c=!0,!h&&!g)try{u(),o.emit(Si,h)}catch(e){setTimeout((function(){throw e}),0)}}));var l=!1;function f(){l||h||(l=!0,u(),o.emit(vi,"Split SDK emitted SDK_READY_TIMED_OUT event."))}var h=!1;n.on(gi,m),s.on(mi,m);var p,g=!1;function d(){g=!1,i>0&&!h&&(p=setTimeout(f,i))}function m(e){if(!g)if(h)try{u(),o.emit(bi,e)}catch(e){setTimeout((function(){throw e}),0)}else if(n.splitsArrived&&s.segmentsArrived){clearTimeout(p),h=!0;try{u(),c||(c=!0,o.emit(Si,h)),o.emit(yi)}catch(e){setTimeout((function(){throw e}),0)}}}return n.initCallbacks.push(d),n.hasInit&&d(),{splits:n,segments:s,gate:o,shared:function(){return Pa(e,t,n,!0)},timeout:f,setDestroyed:function(){g=!0},init:function(){n.hasInit||(n.hasInit=!0,n.initCallbacks.forEach((function(e){return e()})))},destroy:function(){g=!0,u(),clearTimeout(p),r||(n.hasInit=!1)},isReady:function(){return h},isReadyFromCache:function(){return c},isTimedout:function(){return l&&!h},hasTimedout:function(){return l},isDestroyed:function(){return g},isOperational:function(){return(h||c)&&!g},lastUpdate:function(){return a}}}var Ua="newListener",Ba="removeListener",ja=new Error(vi);function qa(e,t,n){void 0===n&&(n=Pa(e,t));var r=t.log,i=0,s=0;n.gate.on(Ba,(function(e){e===yi&&s--})),n.gate.on(Ua,(function(e){e===yi||e===vi?n.isReady()?r.error(en,[e===yi?"SDK_READY":"SDK_READY_TIMED_OUT"]):e===yi&&s++:e===Si&&n.isReadyFromCache()&&r.error(en,["SDK_READY_FROM_CACHE"])}));var o,a=o=xa(new Promise((function(e,t){n.gate.once(yi,(function(){r.info(Xe),s!==i||o.hasOnFulfilled()||r.warn(Ct),e()})),n.gate.once(vi,(function(e){t(new Error(e))}))})),u);function u(e){r.error(e&&e.message)}function c(){return{isReady:n.isReady(),isReadyFromCache:n.isReadyFromCache(),isTimedout:n.isTimedout(),hasTimedout:n.hasTimedout(),isDestroyed:n.isDestroyed(),isOperational:n.isOperational(),lastUpdate:n.lastUpdate()}}return n.gate.once(Si,(function(){r.info(Ze)})),{readinessManager:n,shared:function(){return qa(e,t,n.shared())},incInternalReadyCbCount:function(){i++},sdkStatus:Jn(Object.create(n.gate),{Event:{SDK_READY:yi,SDK_READY_FROM_CACHE:Si,SDK_UPDATE:bi,SDK_READY_TIMED_OUT:vi},ready:function(){return n.hasTimedout()?n.isReady()?Promise.resolve():xa(Promise.reject(new Error("Split SDK has emitted SDK_READY_TIMED_OUT event.")),u):a},whenReady:function(){return new Promise((function(e,t){n.isReady()?e():n.hasTimedout()?t(ja):(n.gate.once(yi,e),n.gate.once(vi,(function(){return t(ja)})))}))},whenReadyFromCache:function(){return new Promise((function(e,t){n.isReadyFromCache()?e(n.isReady()):n.hasTimedout()?t(ja):(n.gate.once(Si,(function(){return e(n.isReady())})),n.gate.once(vi,(function(){return t(ja)})))}))},getStatus:c,__getStatus:c})}}function za(e){function t(t){yr(t)?e.setLogLevel(t):e.error(Xt)}return{enable:function(){t(dr.DEBUG)},setLogLevel:t,setLogger:function(t){e.setLogger(t)},disable:function(){t(dr.NONE)},LogLevel:dr}}var Wa={add:function(){return!0},contains:function(){return!0},clear:function(){}};function Ga(e){var t=e.settings,n=e.platform,r=e.storageFactory,i=e.splitApiFactory,s=e.extraProps,o=e.syncManagerFactory,a=e.SignalListener,u=e.impressionsObserverFactory,c=e.integrationsManagerFactory,l=e.sdkManagerFactory,f=e.sdkClientMethodFactory,h=e.filterAdapterFactory,p=e.lazyInit,g=t.log,d=t.sync.impressionsMode,m=t.initialRolloutPlan,v=t.core.key,y=!1,S=[];function b(e){y?e():S.push(e)}var R=qa(n.EventEmitter,t),k=R.readinessManager,C=r({settings:t,onReadyCb:function(e){e?k.timeout():(k.splits.emit(gi),k.segments.emit(mi))},onReadyFromCacheCb:function(){k.splits.emit(di)}}),w=new uo(t.fallbackTreatments);m&&(or(g,m,C,v&&Kr(v)),C.splits.getChangeNumber()>-1&&k.splits.emit(di));var N,_,A={},I=function(e,t){if(e&&t){var n=Ni(t);return{trackEval:function(n){var r=Ni(t);return function(t){switch(t){case po:return void e.recordException(n);case ho:e.recordNonReadyUsage&&e.recordNonReadyUsage()}e.recordLatency(n,r())}},trackHttp:function(n){var r=Ni(t);return function(t){e.recordHttpLatency(n,r()),t&&t.statusCode?e.recordHttpError(n,t.statusCode):e.recordSuccessfulSync(n,Date.now())}},sessionLength:function(){e.recordSessionLength&&e.recordSessionLength(n())},streamingEvent:function(t,n){t===Se?e.recordAuthRejections():(e.recordStreamingEvents({e:t,d:n,t:Date.now()}),t===me&&e.recordTokenRefreshes())},addTag:function(t){e.addTag&&e.addTag(t)},trackUpdatesFromSSE:function(t){e.recordUpdatesFromSSE(t)}}}var r=function(){return function(){}};return{trackEval:r,trackHttp:r,sessionLength:function(){},streamingEvent:function(){},addTag:function(){},trackUpdatesFromSSE:function(){}}}(C.telemetry,n.now),O=c&&c({settings:t,storage:C,telemetryTracker:I}),F=u(),D=function(e,t,n){var r;return void 0===n&&(n=Wa),{track:function(r,i){n.add(r,i)?t.track(r,i):e.debug(Wn+"The feature "+i+" and key "+r+" exist in the filter")},start:function(){n.refreshRate&&(r=setInterval(n.clear,n.refreshRate))},stop:function(){clearInterval(r)}}}(g,C.uniqueKeys,h&&h()),M=function(e,t){return{process:function(n){var r=Date.now();return e.track(n.feature,r,1),t.track(n.keyName,n.feature),!1}}}(C.impressionCounts,D),K=d===T?(N=F,_=C.impressionCounts,{process:function(e){if(e.properties)return!0;e.pt=N.testAndSet(e);var t=Date.now();return e.pt&&_.track(e.feature,t,1),!e.pt||e.pt0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)Va(a,this,t);else for(var u=a.length,c=function(e,t){for(var n=new Array(t),r=0;r=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this};var Za={getFetch:function(){return"function"==typeof fetch?fetch:Ha},getEventSource:function(){return"function"==typeof EventSource?EventSource:void 0},EventEmitter:Ja,now:"object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):Date.now};function Xa(e,t){var n=function(e){return pr(e,Yr)}(e),r=function(e,t){Da||(Da=Yi(Gs,xs));var n={settings:e,platform:t,storageFactory:e.storage,splitApiFactory:ii,syncManagerFactory:Da,sdkManagerFactory:Co,sdkClientMethodFactory:da,SignalListener:Sa,integrationsManagerFactory:e.integrations&&e.integrations.length>0?Na.bind(null,e.integrations):void 0,impressionsObserverFactory:wa,extraProps:function(e){return{UserConsent:Aa(e)}}};switch(e.mode){case k:n.splitApiFactory=void 0,n.syncManagerFactory=Ka,n.SignalListener=void 0;break;case N:n.syncManagerFactory=void 0;break;case _:Ma||(Ma=Yi(void 0,void 0)),n.syncManagerFactory=Ma}return n}(n,Za);return t&&t(r),Ga(r)}var eu=/[^.]+$/;var tu=function(e){function n(t,n){var r=e.call(this,t)||this;return r.matchingKey=n,r.regexSplitsCacheKey=new RegExp("^"+t+"\\.(splits?|trafficType|flagSet)\\."),r}return t(n,e),n.prototype.buildSegmentNameKey=function(e){return this.prefix+"."+this.matchingKey+".segment."+e},n.prototype.extractSegmentName=function(e){var t=this.prefix+"."+this.matchingKey+".segment.";if(g(e,t))return e.slice(t.length)},n.prototype.buildLastUpdatedKey=function(){return this.prefix+".splits.lastUpdated"},n.prototype.isSplitsCacheKey=function(e){return this.regexSplitsCacheKey.test(e)},n.prototype.buildTillKey=function(){return this.prefix+"."+this.matchingKey+".segments.till"},n.prototype.isSplitKey=function(e){return g(e,this.prefix+".split.")},n.prototype.isRBSegmentKey=function(e){return g(e,this.prefix+".rbsegment.")},n.prototype.buildSplitsWithSegmentCountKey=function(){return this.prefix+".splits.usingSegments"},n.prototype.buildLastClear=function(){return this.prefix+".lastClear"},n}(function(){function e(e){void 0===e&&(e="SPLITIO"),this.prefix=e}return e.prototype.buildTrafficTypeKey=function(e){return this.prefix+".trafficType."+e},e.prototype.buildFlagSetKey=function(e){return this.prefix+".flagSet."+e},e.prototype.buildSplitKey=function(e){return this.prefix+".split."+e},e.prototype.buildSplitsTillKey=function(){return this.prefix+".splits.till"},e.prototype.buildSplitKeyPrefix=function(){return this.prefix+".split."},e.prototype.buildRBSegmentKey=function(e){return this.prefix+".rbsegment."+e},e.prototype.buildRBSegmentsTillKey=function(){return this.prefix+".rbsegments.till"},e.prototype.buildRBSegmentKeyPrefix=function(){return this.prefix+".rbsegment."},e.prototype.buildSegmentNameKey=function(e){return this.prefix+".segment."+e},e.prototype.buildSegmentTillKey=function(e){return this.prefix+".segment."+e+".till"},e.prototype.extractKey=function(e){var t=e.match(eu);if(t&&t.length)return t[0];throw new Error("Invalid latency key provided")},e.prototype.buildHashKey=function(){return this.prefix+".hash"},e}());function nu(e,t){return{buildSegmentNameKey:function(n){return e+"."+t+".largeSegment."+n},extractSegmentName:function(n){var r=e+"."+t+".largeSegment.";if(g(n,r))return n.slice(r.length)},buildTillKey:function(){return e+"."+t+".largeSegments.till"}}}var ru="storage:localstorage: ",iu="1",su=function(e){function n(t,n,r){var i=e.call(this)||this;return i.keys=n,i.log=t.log,i.flagSetsFilter=t.sync.__splitFiltersValidation.groupedFilters.bySet,i.storage=r,i}return t(n,e),n.prototype._decrementCount=function(e){var t=d(this.storage.getItem(e))-1;t>0?this.storage.setItem(e,t+""):this.storage.removeItem(e)},n.prototype._decrementCounts=function(e){try{var t=this.keys.buildTrafficTypeKey(e.trafficTypeName);if(this._decrementCount(t),wr(e)){var n=this.keys.buildSplitsWithSegmentCountKey();this._decrementCount(n)}}catch(e){this.log.error(ru+e)}},n.prototype._incrementCounts=function(e){try{var t=this.keys.buildTrafficTypeKey(e.trafficTypeName);if(this.storage.setItem(t,d(this.storage.getItem(t))+1+""),wr(e)){var n=this.keys.buildSplitsWithSegmentCountKey();this.storage.setItem(n,d(this.storage.getItem(n))+1+"")}}catch(e){this.log.error(ru+e)}},n.prototype.clear=function(){for(var e=this,t=this.storage.length,n=[],r=0;r0},n.prototype.usesSegments=function(){if(!this.hasSync)return!0;var e=this.storage.getItem(this.keys.buildSplitsWithSegmentCountKey()),t=null===e?0:d(e);return!u(t)||t>0},n.prototype.getNamesByFlagSets=function(e){var t=this;return e.map((function(e){var n=t.keys.buildFlagSetKey(e),r=t.storage.getItem(n);return new Set(r?JSON.parse(r):[])}))},n.prototype.addToFlagSets=function(e){var t=this;e.sets&&e.sets.forEach((function(n){if(!(t.flagSetsFilter.length>0)||t.flagSetsFilter.some((function(e){return e===n}))){var r=t.keys.buildFlagSetKey(n),i=t.storage.getItem(r),s=new Set(i?JSON.parse(i):[]);s.has(e.name)||(s.add(e.name),t.storage.setItem(r,JSON.stringify(zr(s))))}}))},n.prototype.removeFromFlagSets=function(e,t){var n=this;t&&t.forEach((function(t){n.removeNames(t,e)}))},n.prototype.removeNames=function(e,t){var n=this.keys.buildFlagSetKey(e),r=this.storage.getItem(n);if(r){var i=new Set(JSON.parse(r));i.delete(t),0!==i.size?this.storage.setItem(n,JSON.stringify(zr(i))):this.storage.removeItem(n)}},n}(Cr),ou=function(){function e(e,t,n){this.keys=t,this.log=e.log,this.storage=n}return e.prototype.clear=function(){var e=this;this.getNames().forEach((function(t){return e.remove(t)})),this.storage.removeItem(this.keys.buildRBSegmentsTillKey())},e.prototype.update=function(e,t,n){var r=this,i=e.map((function(e){return r.add(e)})).some((function(e){return e}));return i=t.map((function(e){return r.remove(e.name)})).some((function(e){return e}))||i,this.setChangeNumber(n),i},e.prototype.setChangeNumber=function(e){try{this.storage.setItem(this.keys.buildRBSegmentsTillKey(),e+""),this.storage.setItem(this.keys.buildLastUpdatedKey(),Date.now()+"")}catch(e){this.log.error(ru+e)}},e.prototype.updateSegmentCount=function(e){var t=this.keys.buildSplitsWithSegmentCountKey(),n=d(this.storage.getItem(t))+e;n>0?this.storage.setItem(t,n+""):this.storage.removeItem(t)},e.prototype.add=function(e){var t=e.name,n=this.keys.buildRBSegmentKey(t),r=this.storage.getItem(n),i=r?JSON.parse(r):null;this.storage.setItem(n,JSON.stringify(e));var s=0;return i&&wr(i)&&s--,wr(e)&&s++,0!==s&&this.updateSegmentCount(s),!0},e.prototype.remove=function(e){var t=this.get(e);return!!t&&(this.storage.removeItem(this.keys.buildRBSegmentKey(e)),wr(t)&&this.updateSegmentCount(-1),!0)},e.prototype.getNames=function(){for(var e=this.storage.length,t=[],n=0;n0},e}(),au=function(e){function n(t,n,r){var i=e.call(this)||this;return i.log=t,i.keys=n,i.storage=r,i}return t(n,e),n.prototype.addSegment=function(e){var t=this.keys.buildSegmentNameKey(e);return this.storage.getItem(t)!==iu&&(this.storage.setItem(t,iu),!0)},n.prototype.removeSegment=function(e){var t=this.keys.buildSegmentNameKey(e);return this.storage.getItem(t)===iu&&(this.storage.removeItem(t),!0)},n.prototype.isInSegment=function(e){return this.storage.getItem(this.keys.buildSegmentNameKey(e))===iu},n.prototype.getRegisteredSegments=function(){for(var e=[],t=0,n=this.storage.length;t=1?e.expirationDays:uu;if(l %s"],[Ye,Fn+"[%s] Result: %s. Rule value: %s. Evaluation value: %s"],[$e,In+"Evaluates to default treatment. %s"],[25,Gn+"Registering cleanup handler %s"],[26,Gn+"Deregistering cleanup handler %s"],[Pe,"Retrieving default SDK client."],[Ue,"Retrieving existing SDK client."],[Be,"Retrieving manager instance."],[je,Kn+"Feature flags data: \n%s"],[qe,Pn+"Spin up feature flags update using since = %s and rbSince = %s."],[ze,Pn+"New feature flags: %s. Removed feature flags: %s."],[We,Pn+"New rule-based segments: %s. Removed rule-based segments: %s."],[Ge,xn+"New SSE message received, with data: %s."],[He,Dn+": Starting %s. Running each %s millis"],[Qe,Dn+": Running %s"],[Ve,Dn+": Stopping %s"],[Je,Nn+': feature flags filtering criteria is "%s".']]);return Xa.SplitFactory=Xa,Xa.InLocalStorage=function(e){void 0===e&&(e={});var t=function(e){return e?e+".SPLITIO":"SPLITIO"}(e.prefix);function n(n){var r=n.settings,i=n.settings,s=i.log,o=i.scheduler,a=o.impressionsQueueSize,u=o.eventsQueueSize,c=fu(s,t,e.wrapper);if(!c)return Hr(n);var l,f=Kr(r.core.key),h=new tu(t,f),p=new su(r,h,c),g=new ou(r,h,c),d=new au(s,h,c),m=new au(s,nu(t,f),c);return{splits:p,rbSegments:g,segments:d,largeSegments:m,impressions:new Or(a),impressionCounts:new Mr,events:new Fr(u),telemetry:jr(n)?new qr(p,d):void 0,uniqueKeys:new Wr,validateCache:function(){return l||(l=function(e,t,n,r,i,s,o,a){return Promise.resolve(t.load&&t.load()).then((function(){var u=Date.now(),c=i.getChangeNumber()>-1;if(lu(e,t,n,r,u,c)){i.clear(),s.clear(),o.clear(),a.clear();try{t.setItem(r.buildLastClear(),u+"")}catch(e){n.log.error(ru+e)}return t.save&&t.save(),!1}return c}))}(e,c,r,h,p,g,d,m))},save:function(){return c.save&&c.save()},destroy:function(){return c.whenSaved&&c.whenSaved()},shared:function(e){return{splits:this.splits,rbSegments:this.rbSegments,segments:new au(s,new tu(t,e),c),largeSegments:new au(s,nu(t,e),c),impressions:this.impressions,impressionCounts:this.impressionCounts,events:this.events,telemetry:this.telemetry,uniqueKeys:this.uniqueKeys,destroy:function(){}}}}}return n.type=I,n},Xa.ErrorLogger=function(){return new Tr({logLevel:"ERROR"},new Map(hu))},Xa.WarnLogger=function(){return new Tr({logLevel:"WARN"},new Map(pu))},Xa.InfoLogger=function(){return new Tr({logLevel:"INFO"},new Map(du))},Xa.DebugLogger=function(){return new Tr({logLevel:"DEBUG"},new Map(mu))},Xa})); \ No newline at end of file