diff --git a/splitio/CHANGELOG.md b/splitio/CHANGELOG.md index 3ed9258..057ee4c 100644 --- a/splitio/CHANGELOG.md +++ b/splitio/CHANGELOG.md @@ -1,3 +1,13 @@ +# 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. + +# 1.0.0-rc.1 (Aug 14, 2025) + # 0.2.0 (Nov 6, 2024) * Added support for targeting rules based on large segments. * BREAKING CHANGE (for Split Proxy users): diff --git a/splitio/example/pubspec.lock b/splitio/example/pubspec.lock index 624c7f2..31b9465 100644 --- a/splitio/example/pubspec.lock +++ b/splitio/example/pubspec.lock @@ -75,30 +75,35 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" leak_tracker: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" lints: dependency: transitive description: @@ -127,10 +132,10 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" path: dependency: transitive description: @@ -166,28 +171,38 @@ packages: path: ".." relative: true source: path - version: "1.0.0-rc.1" + version: "1.0.0" splitio_android: dependency: transitive description: - path: "../../splitio_android" - relative: true - source: path - version: "1.0.0-rc.1" + name: splitio_android + sha256: "344bf82de6694cffb8dd80a96ee734e31bb838d2b4693fb046e0fc98e31512ca" + url: "https://pub.dev" + source: hosted + version: "1.0.0" splitio_ios: dependency: transitive description: - path: "../../splitio_ios" - relative: true - source: path - version: "1.0.0-rc.1" + name: splitio_ios + sha256: "1c078bc49bf7b30df6ca50accb6a9eecf592ec607e20e77b1c6ecdabc7a44dc9" + url: "https://pub.dev" + source: hosted + version: "1.0.0" splitio_platform_interface: dependency: transitive description: - path: "../../splitio_platform_interface" + name: splitio_platform_interface + sha256: "8bcb1cab9f5fffb7b79cfeeaf6c80d82f8ede55c8d6ca7578ec78653f3f9e499" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + splitio_web: + dependency: transitive + description: + path: "../../splitio_web" relative: true source: path - version: "2.0.0-rc.1" + version: "1.0.0" stack_trace: dependency: transitive description: @@ -224,18 +239,18 @@ packages: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.7" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: @@ -244,6 +259,14 @@ packages: url: "https://pub.dev" source: hosted version: "15.0.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" sdks: - dart: ">=3.7.0-0 <4.0.0" + dart: ">=3.8.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/splitio/example/web/favicon.png b/splitio/example/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/splitio/example/web/favicon.png differ diff --git a/splitio/example/web/icons/Icon-192.png b/splitio/example/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/splitio/example/web/icons/Icon-192.png differ diff --git a/splitio/example/web/icons/Icon-512.png b/splitio/example/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/splitio/example/web/icons/Icon-512.png differ diff --git a/splitio/example/web/icons/Icon-maskable-192.png b/splitio/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/splitio/example/web/icons/Icon-maskable-192.png differ diff --git a/splitio/example/web/icons/Icon-maskable-512.png b/splitio/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/splitio/example/web/icons/Icon-maskable-512.png differ diff --git a/splitio/example/web/index.html b/splitio/example/web/index.html new file mode 100644 index 0000000..6d72a53 --- /dev/null +++ b/splitio/example/web/index.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + splitio_example + + + + + + + diff --git a/splitio/example/web/manifest.json b/splitio/example/web/manifest.json new file mode 100644 index 0000000..142b95a --- /dev/null +++ b/splitio/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "splitio_example", + "short_name": "splitio_example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/splitio/pubspec.yaml b/splitio/pubspec.yaml index 634f85e..c7d1672 100644 --- a/splitio/pubspec.yaml +++ b/splitio/pubspec.yaml @@ -1,7 +1,6 @@ -publish_to: none # TODO 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.0.0-rc.1 +version: 1.0.0 homepage: https://split.io/ repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio/ @@ -16,16 +15,17 @@ flutter: default_package: splitio_android ios: default_package: splitio_ios + web: + default_package: splitio_web dependencies: flutter: sdk: flutter - splitio_android: # ^1.0.0-rc.1 - path: ../splitio_android - splitio_ios: # ^1.0.0-rc.1 - path: ../splitio_ios - splitio_platform_interface: # ^2.0.0-rc.1 - path: ../splitio_platform_interface + splitio_android: ^1.0.0 + splitio_ios: ^1.0.0 + splitio_web: # ^1.0.0 + path: ../splitio_web # @TODO remove when splitio_web is published + splitio_platform_interface: ^2.0.0 dev_dependencies: flutter_test: sdk: flutter diff --git a/splitio_android/CHANGELOG.md b/splitio_android/CHANGELOG.md index 4093fab..6f47087 100644 --- a/splitio_android/CHANGELOG.md +++ b/splitio_android/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.0.0 (Aug 14, 2025) +- Updated Android SDK to `5.3.1`. + +# 1.0.0-rc.1 (Aug 14, 2025) + # 0.2.0 (Nov 6, 2024) * Updated Android SDK to `5.0.0` diff --git a/splitio_android/pubspec.yaml b/splitio_android/pubspec.yaml index 05d4e96..fc2bbbe 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-rc.1 +version: 1.0.0 environment: sdk: ">=2.16.2 <4.0.0" @@ -19,8 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - splitio_platform_interface: # ^2.0.0-rc.1 - path: ../splitio_platform_interface + splitio_platform_interface: ^2.0.0 dev_dependencies: flutter_test: diff --git a/splitio_ios/CHANGELOG.md b/splitio_ios/CHANGELOG.md index d8e08de..d0935b9 100644 --- a/splitio_ios/CHANGELOG.md +++ b/splitio_ios/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.0.0 (Aug 14, 2025) +- iOS SDK to `3.3.2` + +# 1.0.0-rc.1 (Aug 14, 2025) + # 0.2.0 (Nov 6, 2024) * Updated iOS SDK to `3.0.0` diff --git a/splitio_ios/pubspec.yaml b/splitio_ios/pubspec.yaml index ae0269e..8c6637b 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-rc.1 +version: 1.0.0 environment: sdk: ">=2.16.2 <4.0.0" @@ -18,8 +18,7 @@ flutter: dependencies: flutter: sdk: flutter - splitio_platform_interface: # ^2.0.0-rc.1 - path: ../splitio_platform_interface + splitio_platform_interface: ^2.0.0 dev_dependencies: flutter_test: diff --git a/splitio_platform_interface/CHANGELOG.md b/splitio_platform_interface/CHANGELOG.md index 3e5e7e1..cf67b5e 100644 --- a/splitio_platform_interface/CHANGELOG.md +++ b/splitio_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.0.0 (Aug 14, 2025) + +# 2.0.0-rc.1 (Aug 14, 2025) + # 1.5.0 (Oct 18, 2024) * Added certificate pinning functionality. This feature allows you to pin a certificate to the SDK, ensuring that the SDK only communicates with servers that present this certificate. Read more in our documentation. diff --git a/splitio_platform_interface/lib/split_view.dart b/splitio_platform_interface/lib/split_view.dart index 9cc2916..8908cf6 100644 --- a/splitio_platform_interface/lib/split_view.dart +++ b/splitio_platform_interface/lib/split_view.dart @@ -32,7 +32,7 @@ class SplitView { this.impressionsDisabled = false, this.prerequisites = const {}]); - static SplitView? fromEntry(Map? entry) { + static SplitView? fromEntry(Map? entry) { if (entry == null || entry.isEmpty) { return null; } diff --git a/splitio_platform_interface/pubspec.yaml b/splitio_platform_interface/pubspec.yaml index 3465a95..6b2a0e1 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-rc.1 +version: 2.0.0 repository: https://github.com/splitio/flutter-sdk-plugin/tree/main/splitio_platform_interface environment: diff --git a/splitio_web/.gitignore b/splitio_web/.gitignore new file mode 100644 index 0000000..9be145f --- /dev/null +++ b/splitio_web/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/splitio_web/LICENSE b/splitio_web/LICENSE new file mode 100644 index 0000000..af74bff --- /dev/null +++ b/splitio_web/LICENSE @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright © 2025 Split Software, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/splitio_web/lib/splitio_web.dart b/splitio_web/lib/splitio_web.dart new file mode 100644 index 0000000..cc9bdfb --- /dev/null +++ b/splitio_web/lib/splitio_web.dart @@ -0,0 +1,101 @@ +import 'dart:async'; +import 'dart:js_interop'; +import 'dart:js_interop_unsafe'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart' show Registrar; +import 'package:splitio_platform_interface/splitio_platform_interface.dart'; +import 'package:splitio_web/src/js_interop.dart'; +import 'package:web/web.dart'; + +extension on Window { + @JS() + external JS_BrowserSDKPackage? splitio; +} + +/// Web implementation of [SplitioPlatform]. +class SplitioWeb extends SplitioPlatform { + /// Registers this class as the default platform implementation. + static void registerWith(Registrar registrar) { + SplitioPlatform.instance = SplitioWeb(); + } + + // Future to queue method calls until SDK is initialized + Future? _initFuture; + + late JS_IBrowserSDK _factory; + + @override + Future init({ + required String apiKey, + required String matchingKey, + required String? bucketingKey, + SplitConfiguration? sdkConfiguration, + }) async { + if (_initFuture == null) { + _initFuture = this._init(apiKey: apiKey, matchingKey: matchingKey, bucketingKey: bucketingKey, sdkConfiguration: sdkConfiguration); + } + return _initFuture; + } + + Future _init({ + required String apiKey, + required String matchingKey, + required String? bucketingKey, + SplitConfiguration? sdkConfiguration, + }) async { + await _loadSplitSdk(); + + final config = _buildConfig(apiKey, matchingKey, bucketingKey, sdkConfiguration); + + // Create factory instance + this._factory = window.splitio!.SplitFactory.callAsFunction(null, config) as JS_IBrowserSDK; + + return; + } + + // Checks whether the Split Browser SDK was manually loaded (`window.splitio != null`). + // If not, loads it by injecting a script tag. + static Future _loadSplitSdk() async { + if (window.splitio != null) { + return; // Already loaded + } + + // Create and inject script tag + final script = document.createElement('script') as HTMLScriptElement; + script.type = 'text/javascript'; + script.src = 'packages/splitio_web/web/split-browser-1.6.0.full.min.js'; + + // Wait for script to load + final completer = Completer(); + + script.onload = (Event event) { + completer.complete(); + }.toJS; + + script.onerror = (Event event) { + completer.completeError(Exception('Failed to load Split SDK')); + }.toJS; + + document.head!.appendChild(script); + + await completer.future; + + if (window.splitio == null) { + throw Exception('Split Browser SDK failed to initialize after loading'); + } + } + + // Map SplitConfiguration to JS equivalent object + JSObject _buildConfig(String apiKey, String matchingKey, String? bucketingKey, SplitConfiguration? configuration) { + final core = JSObject(); + core.setProperty('authorizationKey'.toJS, apiKey.toJS); + // @TODO: set bucketingKey if provided + core.setProperty('key'.toJS, matchingKey.toJS); + + final config = JSObject(); + config.setProperty('core'.toJS, core); + + // @TODO: complete config + return config; + } + +} diff --git a/splitio_web/lib/src/js_interop.dart b/splitio_web/lib/src/js_interop.dart new file mode 100644 index 0000000..28192c0 --- /dev/null +++ b/splitio_web/lib/src/js_interop.dart @@ -0,0 +1,9 @@ +import 'dart:js_interop'; + +@JS() +extension type JS_IBrowserSDK._(JSObject _) implements JSObject {} + +@JS() +extension type JS_BrowserSDKPackage._(JSObject _) implements JSObject { + external JSFunction SplitFactory; +} diff --git a/splitio_web/pubspec.yaml b/splitio_web/pubspec.yaml new file mode 100644 index 0000000..d5abf73 --- /dev/null +++ b/splitio_web/pubspec.yaml @@ -0,0 +1,31 @@ +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 + +environment: + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.16.0" + +flutter: + plugin: + implements: splitio + platforms: + web: + pluginClass: SplitioWeb + fileName: splitio_web.dart + assets: + - web/split-browser-1.6.0.full.min.js + +dependencies: + flutter: + sdk: flutter + splitio_platform_interface: ^2.0.0 + flutter_web_plugins: + sdk: flutter + web: ^0.5.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 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 new file mode 100644 index 0000000..e8b2dae --- /dev/null +++ b/splitio_web/web/split-browser-1.6.0.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)}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)},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}));