@featurevisor/sdk 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,16 +23,16 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">84.61% </span>
26
+ <span class="strong">100% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>11/13</span>
28
+ <span class='fraction'>11/11</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">71.42% </span>
33
+ <span class="strong">85.71% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>10/14</span>
35
+ <span class='fraction'>12/14</span>
36
36
  </div>
37
37
 
38
38
 
@@ -44,9 +44,9 @@
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">84.61% </span>
47
+ <span class="strong">100% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>11/13</span>
49
+ <span class='fraction'>11/11</span>
50
50
  </div>
51
51
 
52
52
 
@@ -91,75 +91,60 @@
91
91
  <a name='L26'></a><a href='#L26'>26</a>
92
92
  <a name='L27'></a><a href='#L27'>27</a>
93
93
  <a name='L28'></a><a href='#L28'>28</a>
94
- <a name='L29'></a><a href='#L29'>29</a>
95
- <a name='L30'></a><a href='#L30'>30</a>
96
- <a name='L31'></a><a href='#L31'>31</a>
97
- <a name='L32'></a><a href='#L32'>32</a>
98
- <a name='L33'></a><a href='#L33'>33</a>
99
- <a name='L34'></a><a href='#L34'>34</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
100
- <span class="cline-any cline-neutral">&nbsp;</span>
94
+ <a name='L29'></a><a href='#L29'>29</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
101
95
  <span class="cline-any cline-neutral">&nbsp;</span>
102
96
  <span class="cline-any cline-neutral">&nbsp;</span>
103
97
  <span class="cline-any cline-neutral">&nbsp;</span>
104
- <span class="cline-any cline-yes">2x</span>
105
- <span class="cline-any cline-yes">20x</span>
106
- <span class="cline-any cline-yes">20x</span>
107
- <span class="cline-any cline-no">&nbsp;</span>
108
98
  <span class="cline-any cline-neutral">&nbsp;</span>
99
+ <span class="cline-any cline-yes">3x</span>
100
+ <span class="cline-any cline-yes">31x</span>
101
+ <span class="cline-any cline-yes">1x</span>
109
102
  <span class="cline-any cline-neutral">&nbsp;</span>
110
- <span class="cline-any cline-yes">20x</span>
111
103
  <span class="cline-any cline-neutral">&nbsp;</span>
112
- <span class="cline-any cline-yes">6x</span>
104
+ <span class="cline-any cline-yes">30x</span>
113
105
  <span class="cline-any cline-neutral">&nbsp;</span>
114
- <span class="cline-any cline-yes">2x</span>
106
+ <span class="cline-any cline-yes">10x</span>
115
107
  <span class="cline-any cline-neutral">&nbsp;</span>
116
- <span class="cline-any cline-yes">2x</span>
108
+ <span class="cline-any cline-yes">3x</span>
117
109
  <span class="cline-any cline-neutral">&nbsp;</span>
118
- <span class="cline-any cline-yes">4x</span>
110
+ <span class="cline-any cline-yes">3x</span>
119
111
  <span class="cline-any cline-neutral">&nbsp;</span>
120
- <span class="cline-any cline-yes">2x</span>
112
+ <span class="cline-any cline-yes">5x</span>
121
113
  <span class="cline-any cline-neutral">&nbsp;</span>
122
- <span class="cline-any cline-yes">2x</span>
114
+ <span class="cline-any cline-yes">3x</span>
123
115
  <span class="cline-any cline-neutral">&nbsp;</span>
116
+ <span class="cline-any cline-yes">3x</span>
124
117
  <span class="cline-any cline-neutral">&nbsp;</span>
125
- <span class="cline-any cline-yes">2x</span>
126
118
  <span class="cline-any cline-neutral">&nbsp;</span>
127
- <span class="cline-any cline-neutral">&nbsp;</span>
128
- <span class="cline-any cline-neutral">&nbsp;</span>
129
- <span class="cline-any cline-no">&nbsp;</span>
119
+ <span class="cline-any cline-yes">3x</span>
130
120
  <span class="cline-any cline-neutral">&nbsp;</span>
131
121
  <span class="cline-any cline-neutral">&nbsp;</span>
132
122
  <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import type { VariableType, VariableValue } from "@featurevisor/types";
133
123
  &nbsp;
134
124
  type FieldType = string | VariableType;
135
- type ValueType = VariableValue;
125
+ export type ValueType = VariableValue;
136
126
  &nbsp;
137
127
  export function getValueByType(value: ValueType, fieldType: FieldType): ValueType {
138
- try {
139
- <span class="missing-if-branch" title="if path not taken" >I</span>if (value === undefined) {
140
- <span class="cstat-no" title="statement not covered" > return null;</span>
141
- }
128
+ if (value === undefined) {
129
+ return null;
130
+ }
142
131
  &nbsp;
143
- switch (fieldType) {
144
- case "string":
145
- return typeof value === "string" ? value : <span class="branch-1 cbranch-no" title="branch not covered" >null;</span>
146
- case "integer":
147
- return parseInt(value as string, 10);
148
- case "double":
149
- return parseFloat(value as string);
150
- case "boolean":
151
- return value === true;
152
- case "array":
153
- return Array.isArray(value) ? value : <span class="branch-1 cbranch-no" title="branch not covered" >null;</span>
154
- case "object":
155
- return typeof value === "object" ? value : <span class="branch-1 cbranch-no" title="branch not covered" >null;</span>
156
- // @NOTE: `json` is not handled here intentionally
157
- default:
158
- return value;
159
- }
160
- // eslint-disable-next-line
161
- } catch (e) {
162
- <span class="cstat-no" title="statement not covered" > return null;</span>
132
+ switch (fieldType) {
133
+ case "string":
134
+ return typeof value === "string" ? value : null;
135
+ case "integer":
136
+ return parseInt(value as string, 10);
137
+ case "double":
138
+ return parseFloat(value as string);
139
+ case "boolean":
140
+ return value === true;
141
+ case "array":
142
+ return Array.isArray(value) ? value : <span class="branch-1 cbranch-no" title="branch not covered" >null;</span>
143
+ case "object":
144
+ return typeof value === "object" ? value : <span class="branch-1 cbranch-no" title="branch not covered" >null;</span>
145
+ // @NOTE: `json` is not handled here intentionally
146
+ default:
147
+ return value;
163
148
  }
164
149
  }
165
150
  &nbsp;</pre></td></tr></table></pre>
@@ -169,7 +154,7 @@ export function getValueByType(value: ValueType, fieldType: FieldType): ValueTyp
169
154
  <div class='footer quiet pad2 space-top1 center small'>
170
155
  Code coverage generated by
171
156
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
172
- at 2025-11-06T19:55:42.800Z
157
+ at 2025-11-19T22:30:12.056Z
173
158
  </div>
174
159
  <script src="prettify.js"></script>
175
160
  <script>
@@ -337,7 +337,7 @@ export class HooksManager {
337
337
  <div class='footer quiet pad2 space-top1 center small'>
338
338
  Code coverage generated by
339
339
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
340
- at 2025-11-06T19:55:42.800Z
340
+ at 2025-11-19T22:30:12.056Z
341
341
  </div>
342
342
  <script src="prettify.js"></script>
343
343
  <script>
@@ -23,16 +23,16 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">90.66% </span>
26
+ <span class="strong">90.92% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>641/707</span>
28
+ <span class='fraction'>641/705</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">84.49% </span>
33
+ <span class="strong">84.93% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>387/458</span>
35
+ <span class='fraction'>389/458</span>
36
36
  </div>
37
37
 
38
38
 
@@ -44,9 +44,9 @@
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">90.79% </span>
47
+ <span class="strong">91.05% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>631/695</span>
49
+ <span class='fraction'>631/693</span>
50
50
  </div>
51
51
 
52
52
 
@@ -185,17 +185,17 @@
185
185
 
186
186
  <tr>
187
187
  <td class="file high" data-value="helpers.ts"><a href="helpers.ts.html">helpers.ts</a></td>
188
- <td data-value="84.61" class="pic high">
189
- <div class="chart"><div class="cover-fill" style="width: 84%"></div><div class="cover-empty" style="width: 16%"></div></div>
188
+ <td data-value="100" class="pic high">
189
+ <div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
190
190
  </td>
191
- <td data-value="84.61" class="pct high">84.61%</td>
192
- <td data-value="13" class="abs high">11/13</td>
193
- <td data-value="71.42" class="pct medium">71.42%</td>
194
- <td data-value="14" class="abs medium">10/14</td>
191
+ <td data-value="100" class="pct high">100%</td>
192
+ <td data-value="11" class="abs high">11/11</td>
193
+ <td data-value="85.71" class="pct high">85.71%</td>
194
+ <td data-value="14" class="abs high">12/14</td>
195
195
  <td data-value="100" class="pct high">100%</td>
196
196
  <td data-value="1" class="abs high">1/1</td>
197
- <td data-value="84.61" class="pct high">84.61%</td>
198
- <td data-value="13" class="abs high">11/13</td>
197
+ <td data-value="100" class="pct high">100%</td>
198
+ <td data-value="11" class="abs high">11/11</td>
199
199
  </tr>
200
200
 
201
201
  <tr>
@@ -251,7 +251,7 @@
251
251
  <div class='footer quiet pad2 space-top1 center small'>
252
252
  Code coverage generated by
253
253
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
254
- at 2025-11-06T19:55:42.800Z
254
+ at 2025-11-19T22:30:12.056Z
255
255
  </div>
256
256
  <script src="prettify.js"></script>
257
257
  <script>
@@ -1402,7 +1402,7 @@ export function createInstance(options: InstanceOptions = <span class="branch-0
1402
1402
  <div class='footer quiet pad2 space-top1 center small'>
1403
1403
  Code coverage generated by
1404
1404
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1405
- at 2025-11-06T19:55:42.800Z
1405
+ at 2025-11-19T22:30:12.056Z
1406
1406
  </div>
1407
1407
  <script src="prettify.js"></script>
1408
1408
  <script>
@@ -340,7 +340,7 @@ export function createLogger(options: CreateLoggerOptions = {}): Logger {
340
340
  <div class='footer quiet pad2 space-top1 center small'>
341
341
  Code coverage generated by
342
342
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
343
- at 2025-11-06T19:55:42.800Z
343
+ at 2025-11-19T22:30:12.056Z
344
344
  </div>
345
345
  <script src="prettify.js"></script>
346
346
  <script>
@@ -1101,38 +1101,36 @@ SF:src/helpers.ts
1101
1101
  FN:6,getValueByType
1102
1102
  FNF:1
1103
1103
  FNH:1
1104
- FNDA:20,getValueByType
1105
- DA:6,2
1106
- DA:7,20
1107
- DA:8,20
1108
- DA:9,0
1109
- DA:12,20
1110
- DA:14,6
1111
- DA:16,2
1112
- DA:18,2
1113
- DA:20,4
1114
- DA:22,2
1115
- DA:24,2
1116
- DA:27,2
1117
- DA:31,0
1118
- LF:13
1104
+ FNDA:31,getValueByType
1105
+ DA:6,3
1106
+ DA:7,31
1107
+ DA:8,1
1108
+ DA:11,30
1109
+ DA:13,10
1110
+ DA:15,3
1111
+ DA:17,3
1112
+ DA:19,5
1113
+ DA:21,3
1114
+ DA:23,3
1115
+ DA:26,3
1116
+ LF:11
1119
1117
  LH:11
1120
- BRDA:8,0,0,0
1121
- BRDA:12,1,0,6
1122
- BRDA:12,1,1,2
1123
- BRDA:12,1,2,2
1124
- BRDA:12,1,3,4
1125
- BRDA:12,1,4,2
1126
- BRDA:12,1,5,2
1127
- BRDA:12,1,6,2
1128
- BRDA:14,2,0,6
1129
- BRDA:14,2,1,0
1130
- BRDA:22,3,0,2
1131
- BRDA:22,3,1,0
1132
- BRDA:24,4,0,2
1133
- BRDA:24,4,1,0
1118
+ BRDA:7,0,0,1
1119
+ BRDA:11,1,0,10
1120
+ BRDA:11,1,1,3
1121
+ BRDA:11,1,2,3
1122
+ BRDA:11,1,3,5
1123
+ BRDA:11,1,4,3
1124
+ BRDA:11,1,5,3
1125
+ BRDA:11,1,6,3
1126
+ BRDA:13,2,0,7
1127
+ BRDA:13,2,1,3
1128
+ BRDA:21,3,0,3
1129
+ BRDA:21,3,1,0
1130
+ BRDA:23,4,0,3
1131
+ BRDA:23,4,1,0
1134
1132
  BRF:14
1135
- BRH:10
1133
+ BRH:12
1136
1134
  end_of_record
1137
1135
  TN:
1138
1136
  SF:src/hooks.ts
package/dist/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { VariableType, VariableValue } from "@featurevisor/types";
2
2
  type FieldType = string | VariableType;
3
- type ValueType = VariableValue;
3
+ export type ValueType = VariableValue;
4
4
  export declare function getValueByType(value: ValueType, fieldType: FieldType): ValueType;
5
5
  export {};
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{"use strict";var e={481:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=function(e){var r=(0,i.MurmurHashV3)(e,n)/o;return Math.floor(r*t.MAX_BUCKETED_NUMBER)},t.getBucketKey=function(e){var t,r,i=e.featureKey,n=e.bucketBy,o=e.context,u=e.logger;if("string"==typeof n)t="plain",r=[n];else if(Array.isArray(n))t="and",r=n;else{if("object"!=typeof n||!Array.isArray(n.or))throw u.error("invalid bucketBy",{featureKey:i,bucketBy:n}),new Error("invalid bucketBy");t="or",r=n.or}var l=[];return r.forEach((function(e){var r=(0,a.getValueFromContext)(o,e);void 0!==r&&("plain"===t||"and"===t||0===l.length)&&l.push(r)})),l.push(i),l.join(s)};var a=r(186),i=r(400),n=1,o=Math.pow(2,32);t.MAX_BUCKETED_NUMBER=1e5;var s="."},608:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorChildInstance=void 0;var i=r(40),n=r(985),o=function(){function e(e){this.parent=e.parent,this.context=e.context,this.sticky=e.sticky||{},this.emitter=new i.Emitter}return e.prototype.on=function(e,t){return"context_set"===e||"sticky_set"===e?this.emitter.on(e,t):this.parent.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return this.parent.getContext(a(a({},this.context),e))},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,n.getParamsForStickySetEvent)(r,this.sticky,t);this.emitter.trigger("sticky_set",i)},e.prototype.isEnabled=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.isEnabled(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.getVariation(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariable(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableBoolean=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableBoolean(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableString=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableString(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableInteger=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableInteger(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableDouble=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableDouble(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableArray=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableArray(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableObject=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableObject(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableJSON=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableJSON(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getAllEvaluations=function(e,t,r){return void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={}),this.parent.getAllEvaluations(a(a({},this.context),e),t,a({sticky:this.sticky},r))},e}();t.FeaturevisorChildInstance=o},108:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.compareVersions=t.compareSegments=t.validateAndParse=t.semver=void 0,t.semver=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,t.validateAndParse=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");var r=e.match(t.semver);if(!r)throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"));return r.shift(),r};var r=function(e){return"*"===e||"x"===e||"X"===e},a=function(e){var t=parseInt(e,10);return isNaN(t)?e:t},i=function(e,t){if(r(e)||r(t))return 0;var i=function(e,t){return typeof e!=typeof t?[String(e),String(t)]:[e,t]}(a(e),a(t)),n=i[0],o=i[1];return n>o?1:n<o?-1:0};t.compareSegments=function(e,t){for(var r=0;r<Math.max(e.length,t.length);r++){var a=i(e[r]||"0",t[r]||"0");if(0!==a)return a}return 0},t.compareVersions=function(e,r){var a=(0,t.validateAndParse)(e),i=(0,t.validateAndParse)(r),n=a.pop(),o=i.pop(),s=(0,t.compareSegments)(a,i);return 0!==s?s:n&&o?(0,t.compareSegments)(n.split("."),o.split(".")):n||o?n?-1:1:0}},186:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueFromContext=i,t.conditionIsMatched=function(e,t,r){var n=e.attribute,o=e.operator,s=e.value,u=e.regexFlags,l=i(t,n);if("equals"===o)return l===s;if("notEquals"===o)return l!==s;if("before"===o||"after"===o){var c=(d=l)instanceof Date?d:new Date(d),f=s instanceof Date?s:new Date(s);return"before"===o?c<f:c>f}if(!Array.isArray(s)||-1===["string","number"].indexOf(typeof l)&&null!==l)if("string"==typeof l&&"string"==typeof s){if(d=l,"contains"===o)return-1!==d.indexOf(s);if("notContains"===o)return-1===d.indexOf(s);if("startsWith"===o)return d.startsWith(s);if("endsWith"===o)return d.endsWith(s);if("semverEquals"===o)return 0===(0,a.compareVersions)(d,s);if("semverNotEquals"===o)return 0!==(0,a.compareVersions)(d,s);if("semverGreaterThan"===o)return 1===(0,a.compareVersions)(d,s);if("semverGreaterThanOrEquals"===o)return(0,a.compareVersions)(d,s)>=0;if("semverLessThan"===o)return-1===(0,a.compareVersions)(d,s);if("semverLessThanOrEquals"===o)return(0,a.compareVersions)(d,s)<=0;if("matches"===o)return r(s,u||"").test(d);if("notMatches"===o)return!r(s,u||"").test(d)}else if("number"==typeof l&&"number"==typeof s){if(d=l,"greaterThan"===o)return d>s;if("greaterThanOrEquals"===o)return d>=s;if("lessThan"===o)return d<s;if("lessThanOrEquals"===o)return d<=s}else{if("exists"===o)return void 0!==l;if("notExists"===o)return void 0===l;if(Array.isArray(l)&&"string"==typeof s){if(d=l,"includes"===o)return d.indexOf(s)>-1;if("notIncludes"===o)return-1===d.indexOf(s)}}else{var d=l;if("in"===o)return-1!==s.indexOf(d);if("notIn"===o)return-1===s.indexOf(d)}return!1};var a=r(108);function i(e,t){return-1===t.indexOf(".")?e[t]:t.split(".").reduce((function(e,t){return e?e[t]:void 0}),e)}},649:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0;var a=r(186),i=function(){function e(e){var t=e.datafile,r=e.logger;this.logger=r,this.schemaVersion=t.schemaVersion,this.revision=t.revision,this.segments=t.segments,this.features=t.features,this.regexCache={}}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getSegment=function(e){var t=this.segments[e];if(t)return t.conditions=this.parseConditionsIfStringified(t.conditions),t},e.prototype.getFeatureKeys=function(){return Object.keys(this.features)},e.prototype.getFeature=function(e){return this.features[e]},e.prototype.getVariableKeys=function(e){var t=this.getFeature(e);return t?Object.keys(t.variablesSchema||{}):[]},e.prototype.hasVariations=function(e){var t=this.getFeature(e);return!!t&&Array.isArray(t.variations)&&t.variations.length>0},e.prototype.getRegex=function(e,t){var r=t||"",a="".concat(e,"-").concat(r);if(this.regexCache[a])return this.regexCache[a];var i=new RegExp(e,r);return this.regexCache[a]=i,i},e.prototype.allConditionsAreMatched=function(e,t){var r=this;if("string"==typeof e)return"*"===e;if("attribute"in e)try{return(0,a.conditionIsMatched)(e,t,(function(e,t){return r.getRegex(e,t)}))}catch(r){return this.logger.warn(r.message,{error:r,details:{condition:e,context:t}}),!1}return"and"in e&&Array.isArray(e.and)?e.and.every((function(e){return r.allConditionsAreMatched(e,t)})):"or"in e&&Array.isArray(e.or)?e.or.some((function(e){return r.allConditionsAreMatched(e,t)})):"not"in e&&Array.isArray(e.not)?e.not.every((function(){return!1===r.allConditionsAreMatched({and:e.not},t)})):!!Array.isArray(e)&&e.every((function(e){return r.allConditionsAreMatched(e,t)}))},e.prototype.segmentIsMatched=function(e,t){return this.allConditionsAreMatched(e.conditions,t)},e.prototype.allSegmentsAreMatched=function(e,t){var r=this;if("*"===e)return!0;if("string"==typeof e){var a=this.getSegment(e);return!!a&&this.segmentIsMatched(a,t)}if("object"==typeof e){if("and"in e&&Array.isArray(e.and))return e.and.every((function(e){return r.allSegmentsAreMatched(e,t)}));if("or"in e&&Array.isArray(e.or))return e.or.some((function(e){return r.allSegmentsAreMatched(e,t)}));if("not"in e&&Array.isArray(e.not))return e.not.every((function(e){return!1===r.allSegmentsAreMatched(e,t)}))}return!!Array.isArray(e)&&e.every((function(e){return r.allSegmentsAreMatched(e,t)}))},e.prototype.getMatchedTraffic=function(e,t){var r=this;return e.find((function(e){return!!r.allSegmentsAreMatched(r.parseSegmentsIfStringified(e.segments),t)}))},e.prototype.getMatchedAllocation=function(e,t){if(e.allocation)for(var r=0,a=e.allocation;r<a.length;r++){var i=a[r],n=i.range,o=n[0],s=n[1];if(i.range&&o<=t&&s>=t)return i}},e.prototype.getMatchedForce=function(e,t){var r={force:void 0,forceIndex:void 0},a="string"==typeof e?this.getFeature(e):e;if(!a||!a.force)return r;for(var i=0;i<a.force.length;i++){var n=a.force[i];if(n.conditions&&this.allConditionsAreMatched(this.parseConditionsIfStringified(n.conditions),t)){r.force=n,r.forceIndex=i;break}if(n.segments&&this.allSegmentsAreMatched(this.parseSegmentsIfStringified(n.segments),t)){r.force=n,r.forceIndex=i;break}}return r},e.prototype.parseConditionsIfStringified=function(e){if("string"!=typeof e)return e;if("*"===e)return e;try{return JSON.parse(e)}catch(t){return this.logger.error("Error parsing conditions",{error:t,details:{conditions:e}}),e}},e.prototype.parseSegmentsIfStringified=function(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e},e}();t.DatafileReader=i},40:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]);var r=this.listeners[e];r.push(t);var a=!0;return function(){if(a){a=!1;var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.trigger=function(e,t){void 0===t&&(t={});var r=this.listeners[e];r&&r.forEach((function(e){try{e(t)}catch(e){console.error(e)}}))},e.prototype.clearAll=function(){this.listeners={}},e}();t.Emitter=r},335:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.EvaluationReason=void 0,t.evaluateWithHooks=function(e){try{for(var t=e.hooksManager,r=t.getAll(),a=e,n=0,s=t.getAll();n<s.length;n++)(f=s[n]).before&&(a=f.before(a));var u=o(a);void 0!==a.defaultVariationValue&&"variation"===u.type&&void 0===u.variationValue&&(u.variationValue=a.defaultVariationValue),void 0!==a.defaultVariableValue&&"variable"===u.type&&void 0===u.variableValue&&(u.variableValue=a.defaultVariableValue);for(var l=0,c=r;l<c.length;l++){var f;(f=c[l]).after&&(u=f.after(u,a))}return u}catch(t){var d=e.type,v=e.featureKey,y=e.variableKey,g=e.logger;return u={type:d,featureKey:v,variableKey:y,reason:i.ERROR,error:t},g.error("error during evaluation",u),u}},t.evaluate=o;var i,n=r(481);function o(e){var t,r=e.type,s=e.featureKey,u=e.variableKey,l=e.context,c=e.logger,f=e.datafileReader,d=e.sticky,v=e.hooksManager.getAll();try{if("flag"!==r&&!1===o(a(a({},e),{type:"flag"})).enabled){t={type:r,featureKey:s,reason:i.DISABLED};var y=f.getFeature(s);if("variable"===r&&y&&u&&y.variablesSchema&&y.variablesSchema[u]){var g=y.variablesSchema[u];void 0!==g.disabledValue?t={type:r,featureKey:s,reason:i.VARIABLE_DISABLED,variableKey:u,variableValue:g.disabledValue,variableSchema:g,enabled:!1}:g.useDefaultWhenDisabled&&(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,variableKey:u,variableValue:g.defaultValue,variableSchema:g,enabled:!1})}return"variation"===r&&y&&y.disabledVariationValue&&(t={type:r,featureKey:s,reason:i.VARIATION_DISABLED,variationValue:y.disabledVariationValue,enabled:!1}),c.debug("feature is disabled",t),t}if(d&&d[s]){if("flag"===r&&void 0!==d[s].enabled)return t={type:r,featureKey:s,reason:i.STICKY,sticky:d[s],enabled:d[s].enabled},c.debug("using sticky enabled",t),t;if("variation"===r){var h=d[s].variation;if(void 0!==h)return t={type:r,featureKey:s,reason:i.STICKY,variationValue:h},c.debug("using sticky variation",t),t}if(u){var p=d[s].variables;if(p){var b=p[u];if(void 0!==b)return t={type:r,featureKey:s,reason:i.STICKY,variableKey:u,variableValue:b},c.debug("using sticky variable",t),t}}}var V="string"==typeof s?f.getFeature(s):s;if(!V)return t={type:r,featureKey:s,reason:i.FEATURE_NOT_FOUND},c.warn("feature not found",t),t;"flag"===r&&V.deprecated&&c.warn("feature is deprecated",{featureKey:s});var k=void 0;if(u){if(V.variablesSchema&&V.variablesSchema[u]&&(k=V.variablesSchema[u]),!k)return t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u},c.warn("variable schema not found",t),t;k.deprecated&&c.warn("variable is deprecated",{featureKey:s,variableKey:u})}if("variation"===r&&(!V.variations||0===V.variations.length))return t={type:r,featureKey:s,reason:i.NO_VARIATIONS},c.warn("no variations",t),t;var m=f.getMatchedForce(V,l),A=m.force,K=m.forceIndex;if(A){if("flag"===r&&void 0!==A.enabled)return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,enabled:A.enabled},c.debug("forced enabled found",t),t;if("variation"===r&&A.variation&&V.variations&&(T=V.variations.find((function(e){return e.value===A.variation}))))return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variation:T},c.debug("forced variation found",t),t;if(u&&A.variables&&void 0!==A.variables[u])return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variableKey:u,variableSchema:k,variableValue:A.variables[u]},c.debug("forced variable",t),t}if("flag"===r&&V.required&&V.required.length>0){var x=V.required.every((function(t){var r,i;if("string"==typeof t?r=t:(r=t.key,i=t.variation),!o(a(a({},e),{type:"flag",featureKey:r})).enabled)return!1;if(void 0!==i){var n=o(a(a({},e),{type:"variation",featureKey:r})),s=void 0;return n.variationValue?s=n.variationValue:n.variation&&(s=n.variation.value),s===i}return!0}));if(!x)return t={type:r,featureKey:s,reason:i.REQUIRED,required:V.required,enabled:x},c.debug("required features not enabled",t),t}for(var O=(0,n.getBucketKey)({featureKey:s,bucketBy:V.bucketBy,context:l,logger:c}),E=0,_=v;E<_.length;E++)(L=_[E]).bucketKey&&(O=L.bucketKey({featureKey:s,context:l,bucketBy:V.bucketBy,bucketKey:O}));for(var S,R,M=(0,n.getBucketedNumber)(O),I=0,D=v;I<D.length;I++){var L;(L=D[I]).bucketValue&&(M=L.bucketValue({featureKey:s,bucketKey:O,context:l,bucketValue:M}))}if("flag"!==r?(S=f.getMatchedTraffic(V.traffic,l))&&(R=f.getMatchedAllocation(S,M)):S=f.getMatchedTraffic(V.traffic,l),S){if(0===S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!1},c.debug("matched rule with 0 percentage",t),t;if("flag"===r){if(V.ranges&&V.ranges.length>0)return V.ranges.find((function(e){return M>=e[0]&&M<e[1]}))?(t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:void 0===S.enabled||S.enabled},c.debug("matched",t),t):(t={type:r,featureKey:s,reason:i.OUT_OF_RANGE,bucketKey:O,bucketValue:M,enabled:!1},c.debug("not matched",t),t);if(void 0!==S.enabled)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:S.enabled},c.debug("override from rule",t),t;if(M<=S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!0},c.debug("matched traffic",t),t}if("variation"===r&&V.variations){if(S.variation&&(T=V.variations.find((function(e){return e.value===S.variation}))))return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("override from rule",t),t;if(R&&R.variation&&(T=V.variations.find((function(e){return e.value===R.variation}))))return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("allocated variation",t),t}}if("variable"===r&&u){if(S&&S.variables&&void 0!==S.variables[u])return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:S.variables[u]},c.debug("override from rule",t),t;var F;if(A&&A.variation?F=A.variation:S&&S.variation?F=S.variation:R&&R.variation&&(F=R.variation),F&&Array.isArray(V.variations)){var T;if((T=V.variations.find((function(e){return e.value===F})))&&T.variableOverrides&&T.variableOverrides[u]){var C=T.variableOverrides[u].find((function(e){return e.conditions?f.allConditionsAreMatched("string"==typeof e.conditions&&"*"!==e.conditions?JSON.parse(e.conditions):e.conditions,l):!!e.segments&&f.allSegmentsAreMatched(f.parseSegmentsIfStringified(e.segments),l)}));if(C)return t={type:r,featureKey:s,reason:i.VARIABLE_OVERRIDE,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:C.value},c.debug("variable override",t),t}if(T&&T.variables&&void 0!==T.variables[u])return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:T.variables[u]},c.debug("allocated variable",t),t}}return"variation"===r?(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M},c.debug("no matched variation",t),t):"variable"===r?k?(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,bucketKey:O,bucketValue:M,variableKey:u,variableSchema:k,variableValue:k.defaultValue},c.debug("using default value",t),t):(t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u,bucketKey:O,bucketValue:M},c.debug("variable not found",t),t):(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M,enabled:!1},c.debug("nothing matched",t),t)}catch(e){return t={type:r,featureKey:s,variableKey:u,reason:i.ERROR,error:e},c.error("error",t),t}}!function(e){e.FEATURE_NOT_FOUND="feature_not_found",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.NO_VARIATIONS="no_variations",e.VARIATION_DISABLED="variation_disabled",e.VARIABLE_NOT_FOUND="variable_not_found",e.VARIABLE_DEFAULT="variable_default",e.VARIABLE_DISABLED="variable_disabled",e.VARIABLE_OVERRIDE="variable_override",e.NO_MATCH="no_match",e.FORCED="forced",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.ERROR="error"}(i||(t.EvaluationReason=i={}))},985:function(e,t){var r=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var a,i=0,n=t.length;i<n;i++)!a&&i in t||(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.getParamsForStickySetEvent=function(e,t,a){void 0===e&&(e={}),void 0===t&&(t={});var i=Object.keys(e),n=Object.keys(t),o=r(r([],i,!0),n,!0);return{features:o.filter((function(e,t){return o.indexOf(e)===t})),replaced:a}},t.getParamsForDatafileSetEvent=function(e,t){for(var a=e.getRevision(),i=e.getFeatureKeys(),n=t.getRevision(),o=t.getFeatureKeys(),s=[],u=[],l=[],c=0,f=i;c<f.length;c++){var d=f[c];if(-1!==o.indexOf(d)){var v=e.getFeature(d),y=t.getFeature(d);(null==v?void 0:v.hash)!==(null==y?void 0:y.hash)&&u.push(d)}else s.push(d)}for(var g=0,h=o;g<h.length;g++){var p=h[g];-1===i.indexOf(p)&&l.push(p)}return{revision:n,previousRevision:a,revisionChanged:a!==n,features:r(r(r([],s,!0),u,!0),l,!0).filter((function(e,t,r){return r.indexOf(e)===t}))}}},943:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueByType=function(e,t){try{if(void 0===e)return null;switch(t){case"string":return"string"==typeof e?e:null;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:null;case"object":return"object"==typeof e?e:null;default:return e}}catch(e){return null}}},438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HooksManager=void 0;var r=function(){function e(e){var t=this;this.hooks=[],this.logger=e.logger,e.hooks&&e.hooks.forEach((function(e){t.add(e)}))}return e.prototype.add=function(e){var t=this;if(!this.hooks.some((function(t){return t.name===e.name})))return this.hooks.push(e),function(){t.remove(e.name)};this.logger.error('Hook with name "'.concat(e.name,'" already exists.'),{name:e.name,hook:e})},e.prototype.remove=function(e){this.hooks=this.hooks.filter((function(t){return t.name!==e}))},e.prototype.getAll=function(){return this.hooks},e}();t.HooksManager=r},166:function(e,t,r){var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(481),t),i(r(247),t),i(r(584),t),i(r(186),t),i(r(335),t),i(r(649),t),i(r(608),t)},247:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=void 0,t.createInstance=function(e){return void 0===e&&(e={}),new v(e)};var i=r(584),n=r(438),o=r(40),s=r(649),u=r(335),l=r(608),c=r(985),f=r(943),d={schemaVersion:"2",revision:"unknown",segments:{},features:{}},v=function(){function e(e){this.context={},this.context=e.context||{},this.logger=e.logger||(0,i.createLogger)({level:e.logLevel||i.Logger.defaultLevel}),this.hooksManager=new n.HooksManager({hooks:e.hooks||[],logger:this.logger}),this.emitter=new o.Emitter,this.sticky=e.sticky,this.datafileReader=new s.DatafileReader({datafile:d,logger:this.logger}),e.datafile&&(this.datafileReader=new s.DatafileReader({datafile:"string"==typeof e.datafile?JSON.parse(e.datafile):e.datafile,logger:this.logger})),this.logger.info("Featurevisor SDK initialized")}return e.prototype.setLogLevel=function(e){this.logger.setLevel(e)},e.prototype.setDatafile=function(e){try{var t=new s.DatafileReader({datafile:"string"==typeof e?JSON.parse(e):e,logger:this.logger}),r=(0,c.getParamsForDatafileSetEvent)(this.datafileReader,t);this.datafileReader=t,this.logger.info("datafile set",r),this.emitter.trigger("datafile_set",r)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,c.getParamsForStickySetEvent)(r,this.sticky,t);this.logger.info("sticky features set",i),this.emitter.trigger("sticky_set",i)},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return this.datafileReader.getFeature(e)},e.prototype.addHook=function(e){return this.hooksManager.add(e)},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t}),this.logger.debug(t?"context replaced":"context updated",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return e?a(a({},this.context),e):this.context},e.prototype.spawn=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),new l.FeaturevisorChildInstance({parent:this,context:this.getContext(e),sticky:t.sticky})},e.prototype.getEvaluationDependencies=function(e,t){return void 0===t&&(t={}),{context:this.getContext(e),logger:this.logger,hooksManager:this.hooksManager,datafileReader:this.datafileReader,sticky:t.sticky?a(a({},this.sticky),t.sticky):this.sticky,defaultVariationValue:t.defaultVariationValue,defaultVariableValue:t.defaultVariableValue}},e.prototype.evaluateFlag=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"flag",featureKey:e}))},e.prototype.isEnabled=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{return!0===this.evaluateFlag(e,t,r).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"variation",featureKey:e}))},e.prototype.getVariation=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{var a=this.evaluateVariation(e,t,r);return void 0!==a.variationValue?a.variationValue:a.variation?a.variation.value:null}catch(t){return this.logger.error("getVariation",{featureKey:e,error:t}),null}},e.prototype.evaluateVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(r,i)),{type:"variable",featureKey:e,variableKey:t}))},e.prototype.getVariable=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});try{var i=this.evaluateVariable(e,t,r,a);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:null}catch(r){return this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r}),null}},e.prototype.getVariableBoolean=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"boolean")},e.prototype.getVariableString=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"string")},e.prototype.getVariableInteger=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"integer")},e.prototype.getVariableDouble=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"double")},e.prototype.getVariableArray=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"array")},e.prototype.getVariableObject=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"object")},e.prototype.getVariableJSON=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"json")},e.prototype.getAllEvaluations=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={});for(var a={},i=0,n=t.length>0?t:this.datafileReader.getFeatureKeys();i<n.length;i++){var o=n[i],s={enabled:this.isEnabled(o,e,r)};if(this.datafileReader.hasVariations(o)){var u=this.getVariation(o,e,r);u&&(s.variation=u)}var l=this.datafileReader.getVariableKeys(o);if(l.length>0){s.variables={};for(var c=0,f=l;c<f.length;c++){var d=f[c];s.variables[d]=this.getVariable(o,d,e,r)}}a[o]=s}return a},e}();t.FeaturevisorInstance=v},584:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.loggerPrefix=void 0,t.createLogger=function(e){return void 0===e&&(e={}),new r(e)},t.loggerPrefix="[Featurevisor]",t.defaultLogHandler=function(e,r,a){void 0===a&&(a={});var i="log";"info"===e?i="info":"warn"===e?i="warn":"error"===e&&(i="error"),console[i](t.loggerPrefix,r,a)};var r=function(){function e(r){this.level=r.level||e.defaultLevel,this.handle=r.handler||t.defaultLogHandler}return e.prototype.setLevel=function(e){this.level=e},e.prototype.log=function(t,r,a){e.allLevels.indexOf(this.level)>=e.allLevels.indexOf(t)&&this.handle(t,r,a)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e.allLevels=["fatal","error","warn","info","debug"],e.defaultLevel="info",e}();t.Logger=r},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHashV3=function(e,t){var a,i,n,o,s,u,l,c;for("string"==typeof e&&(e=r(e)),a=3&e.length,i=e.length-a,n=t,s=3432918353,u=461845907,c=0;c<i;)l=255&e[c]|(255&e[++c])<<8|(255&e[++c])<<16|(255&e[++c])<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,a){case 3:l^=(255&e[c+2])<<16;case 2:l^=(255&e[c+1])<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e[c]))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};var r=function(e){return(new TextEncoder).encode(e)}}},t={};return function r(a){var i=t[a];if(void 0!==i)return i.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,r),n.exports}(166)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{"use strict";var e={481:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=function(e){var r=(0,i.MurmurHashV3)(e,n)/o;return Math.floor(r*t.MAX_BUCKETED_NUMBER)},t.getBucketKey=function(e){var t,r,i=e.featureKey,n=e.bucketBy,o=e.context,u=e.logger;if("string"==typeof n)t="plain",r=[n];else if(Array.isArray(n))t="and",r=n;else{if("object"!=typeof n||!Array.isArray(n.or))throw u.error("invalid bucketBy",{featureKey:i,bucketBy:n}),new Error("invalid bucketBy");t="or",r=n.or}var l=[];return r.forEach((function(e){var r=(0,a.getValueFromContext)(o,e);void 0!==r&&("plain"===t||"and"===t||0===l.length)&&l.push(r)})),l.push(i),l.join(s)};var a=r(186),i=r(400),n=1,o=Math.pow(2,32);t.MAX_BUCKETED_NUMBER=1e5;var s="."},608:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorChildInstance=void 0;var i=r(40),n=r(985),o=function(){function e(e){this.parent=e.parent,this.context=e.context,this.sticky=e.sticky||{},this.emitter=new i.Emitter}return e.prototype.on=function(e,t){return"context_set"===e||"sticky_set"===e?this.emitter.on(e,t):this.parent.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return this.parent.getContext(a(a({},this.context),e))},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,n.getParamsForStickySetEvent)(r,this.sticky,t);this.emitter.trigger("sticky_set",i)},e.prototype.isEnabled=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.isEnabled(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.getVariation(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariable(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableBoolean=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableBoolean(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableString=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableString(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableInteger=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableInteger(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableDouble=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableDouble(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableArray=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableArray(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableObject=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableObject(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableJSON=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableJSON(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getAllEvaluations=function(e,t,r){return void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={}),this.parent.getAllEvaluations(a(a({},this.context),e),t,a({sticky:this.sticky},r))},e}();t.FeaturevisorChildInstance=o},108:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.compareVersions=t.compareSegments=t.validateAndParse=t.semver=void 0,t.semver=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,t.validateAndParse=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");var r=e.match(t.semver);if(!r)throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"));return r.shift(),r};var r=function(e){return"*"===e||"x"===e||"X"===e},a=function(e){var t=parseInt(e,10);return isNaN(t)?e:t},i=function(e,t){if(r(e)||r(t))return 0;var i=function(e,t){return typeof e!=typeof t?[String(e),String(t)]:[e,t]}(a(e),a(t)),n=i[0],o=i[1];return n>o?1:n<o?-1:0};t.compareSegments=function(e,t){for(var r=0;r<Math.max(e.length,t.length);r++){var a=i(e[r]||"0",t[r]||"0");if(0!==a)return a}return 0},t.compareVersions=function(e,r){var a=(0,t.validateAndParse)(e),i=(0,t.validateAndParse)(r),n=a.pop(),o=i.pop(),s=(0,t.compareSegments)(a,i);return 0!==s?s:n&&o?(0,t.compareSegments)(n.split("."),o.split(".")):n||o?n?-1:1:0}},186:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueFromContext=i,t.conditionIsMatched=function(e,t,r){var n=e.attribute,o=e.operator,s=e.value,u=e.regexFlags,l=i(t,n);if("equals"===o)return l===s;if("notEquals"===o)return l!==s;if("before"===o||"after"===o){var c=(d=l)instanceof Date?d:new Date(d),f=s instanceof Date?s:new Date(s);return"before"===o?c<f:c>f}if(!Array.isArray(s)||-1===["string","number"].indexOf(typeof l)&&null!==l)if("string"==typeof l&&"string"==typeof s){if(d=l,"contains"===o)return-1!==d.indexOf(s);if("notContains"===o)return-1===d.indexOf(s);if("startsWith"===o)return d.startsWith(s);if("endsWith"===o)return d.endsWith(s);if("semverEquals"===o)return 0===(0,a.compareVersions)(d,s);if("semverNotEquals"===o)return 0!==(0,a.compareVersions)(d,s);if("semverGreaterThan"===o)return 1===(0,a.compareVersions)(d,s);if("semverGreaterThanOrEquals"===o)return(0,a.compareVersions)(d,s)>=0;if("semverLessThan"===o)return-1===(0,a.compareVersions)(d,s);if("semverLessThanOrEquals"===o)return(0,a.compareVersions)(d,s)<=0;if("matches"===o)return r(s,u||"").test(d);if("notMatches"===o)return!r(s,u||"").test(d)}else if("number"==typeof l&&"number"==typeof s){if(d=l,"greaterThan"===o)return d>s;if("greaterThanOrEquals"===o)return d>=s;if("lessThan"===o)return d<s;if("lessThanOrEquals"===o)return d<=s}else{if("exists"===o)return void 0!==l;if("notExists"===o)return void 0===l;if(Array.isArray(l)&&"string"==typeof s){if(d=l,"includes"===o)return d.indexOf(s)>-1;if("notIncludes"===o)return-1===d.indexOf(s)}}else{var d=l;if("in"===o)return-1!==s.indexOf(d);if("notIn"===o)return-1===s.indexOf(d)}return!1};var a=r(108);function i(e,t){return-1===t.indexOf(".")?e[t]:t.split(".").reduce((function(e,t){return e?e[t]:void 0}),e)}},649:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0;var a=r(186),i=function(){function e(e){var t=e.datafile,r=e.logger;this.logger=r,this.schemaVersion=t.schemaVersion,this.revision=t.revision,this.segments=t.segments,this.features=t.features,this.regexCache={}}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getSegment=function(e){var t=this.segments[e];if(t)return t.conditions=this.parseConditionsIfStringified(t.conditions),t},e.prototype.getFeatureKeys=function(){return Object.keys(this.features)},e.prototype.getFeature=function(e){return this.features[e]},e.prototype.getVariableKeys=function(e){var t=this.getFeature(e);return t?Object.keys(t.variablesSchema||{}):[]},e.prototype.hasVariations=function(e){var t=this.getFeature(e);return!!t&&Array.isArray(t.variations)&&t.variations.length>0},e.prototype.getRegex=function(e,t){var r=t||"",a="".concat(e,"-").concat(r);if(this.regexCache[a])return this.regexCache[a];var i=new RegExp(e,r);return this.regexCache[a]=i,i},e.prototype.allConditionsAreMatched=function(e,t){var r=this;if("string"==typeof e)return"*"===e;if("attribute"in e)try{return(0,a.conditionIsMatched)(e,t,(function(e,t){return r.getRegex(e,t)}))}catch(r){return this.logger.warn(r.message,{error:r,details:{condition:e,context:t}}),!1}return"and"in e&&Array.isArray(e.and)?e.and.every((function(e){return r.allConditionsAreMatched(e,t)})):"or"in e&&Array.isArray(e.or)?e.or.some((function(e){return r.allConditionsAreMatched(e,t)})):"not"in e&&Array.isArray(e.not)?e.not.every((function(){return!1===r.allConditionsAreMatched({and:e.not},t)})):!!Array.isArray(e)&&e.every((function(e){return r.allConditionsAreMatched(e,t)}))},e.prototype.segmentIsMatched=function(e,t){return this.allConditionsAreMatched(e.conditions,t)},e.prototype.allSegmentsAreMatched=function(e,t){var r=this;if("*"===e)return!0;if("string"==typeof e){var a=this.getSegment(e);return!!a&&this.segmentIsMatched(a,t)}if("object"==typeof e){if("and"in e&&Array.isArray(e.and))return e.and.every((function(e){return r.allSegmentsAreMatched(e,t)}));if("or"in e&&Array.isArray(e.or))return e.or.some((function(e){return r.allSegmentsAreMatched(e,t)}));if("not"in e&&Array.isArray(e.not))return e.not.every((function(e){return!1===r.allSegmentsAreMatched(e,t)}))}return!!Array.isArray(e)&&e.every((function(e){return r.allSegmentsAreMatched(e,t)}))},e.prototype.getMatchedTraffic=function(e,t){var r=this;return e.find((function(e){return!!r.allSegmentsAreMatched(r.parseSegmentsIfStringified(e.segments),t)}))},e.prototype.getMatchedAllocation=function(e,t){if(e.allocation)for(var r=0,a=e.allocation;r<a.length;r++){var i=a[r],n=i.range,o=n[0],s=n[1];if(i.range&&o<=t&&s>=t)return i}},e.prototype.getMatchedForce=function(e,t){var r={force:void 0,forceIndex:void 0},a="string"==typeof e?this.getFeature(e):e;if(!a||!a.force)return r;for(var i=0;i<a.force.length;i++){var n=a.force[i];if(n.conditions&&this.allConditionsAreMatched(this.parseConditionsIfStringified(n.conditions),t)){r.force=n,r.forceIndex=i;break}if(n.segments&&this.allSegmentsAreMatched(this.parseSegmentsIfStringified(n.segments),t)){r.force=n,r.forceIndex=i;break}}return r},e.prototype.parseConditionsIfStringified=function(e){if("string"!=typeof e)return e;if("*"===e)return e;try{return JSON.parse(e)}catch(t){return this.logger.error("Error parsing conditions",{error:t,details:{conditions:e}}),e}},e.prototype.parseSegmentsIfStringified=function(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e},e}();t.DatafileReader=i},40:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]);var r=this.listeners[e];r.push(t);var a=!0;return function(){if(a){a=!1;var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.trigger=function(e,t){void 0===t&&(t={});var r=this.listeners[e];r&&r.forEach((function(e){try{e(t)}catch(e){console.error(e)}}))},e.prototype.clearAll=function(){this.listeners={}},e}();t.Emitter=r},335:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.EvaluationReason=void 0,t.evaluateWithHooks=function(e){try{for(var t=e.hooksManager,r=t.getAll(),a=e,n=0,s=t.getAll();n<s.length;n++)(f=s[n]).before&&(a=f.before(a));var u=o(a);void 0!==a.defaultVariationValue&&"variation"===u.type&&void 0===u.variationValue&&(u.variationValue=a.defaultVariationValue),void 0!==a.defaultVariableValue&&"variable"===u.type&&void 0===u.variableValue&&(u.variableValue=a.defaultVariableValue);for(var l=0,c=r;l<c.length;l++){var f;(f=c[l]).after&&(u=f.after(u,a))}return u}catch(t){var d=e.type,v=e.featureKey,y=e.variableKey,g=e.logger;return u={type:d,featureKey:v,variableKey:y,reason:i.ERROR,error:t},g.error("error during evaluation",u),u}},t.evaluate=o;var i,n=r(481);function o(e){var t,r=e.type,s=e.featureKey,u=e.variableKey,l=e.context,c=e.logger,f=e.datafileReader,d=e.sticky,v=e.hooksManager.getAll();try{if("flag"!==r&&!1===o(a(a({},e),{type:"flag"})).enabled){t={type:r,featureKey:s,reason:i.DISABLED};var y=f.getFeature(s);if("variable"===r&&y&&u&&y.variablesSchema&&y.variablesSchema[u]){var g=y.variablesSchema[u];void 0!==g.disabledValue?t={type:r,featureKey:s,reason:i.VARIABLE_DISABLED,variableKey:u,variableValue:g.disabledValue,variableSchema:g,enabled:!1}:g.useDefaultWhenDisabled&&(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,variableKey:u,variableValue:g.defaultValue,variableSchema:g,enabled:!1})}return"variation"===r&&y&&y.disabledVariationValue&&(t={type:r,featureKey:s,reason:i.VARIATION_DISABLED,variationValue:y.disabledVariationValue,enabled:!1}),c.debug("feature is disabled",t),t}if(d&&d[s]){if("flag"===r&&void 0!==d[s].enabled)return t={type:r,featureKey:s,reason:i.STICKY,sticky:d[s],enabled:d[s].enabled},c.debug("using sticky enabled",t),t;if("variation"===r){var h=d[s].variation;if(void 0!==h)return t={type:r,featureKey:s,reason:i.STICKY,variationValue:h},c.debug("using sticky variation",t),t}if(u){var p=d[s].variables;if(p){var b=p[u];if(void 0!==b)return t={type:r,featureKey:s,reason:i.STICKY,variableKey:u,variableValue:b},c.debug("using sticky variable",t),t}}}var V="string"==typeof s?f.getFeature(s):s;if(!V)return t={type:r,featureKey:s,reason:i.FEATURE_NOT_FOUND},c.warn("feature not found",t),t;"flag"===r&&V.deprecated&&c.warn("feature is deprecated",{featureKey:s});var k=void 0;if(u){if(V.variablesSchema&&V.variablesSchema[u]&&(k=V.variablesSchema[u]),!k)return t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u},c.warn("variable schema not found",t),t;k.deprecated&&c.warn("variable is deprecated",{featureKey:s,variableKey:u})}if("variation"===r&&(!V.variations||0===V.variations.length))return t={type:r,featureKey:s,reason:i.NO_VARIATIONS},c.warn("no variations",t),t;var m=f.getMatchedForce(V,l),A=m.force,K=m.forceIndex;if(A){if("flag"===r&&void 0!==A.enabled)return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,enabled:A.enabled},c.debug("forced enabled found",t),t;if("variation"===r&&A.variation&&V.variations&&(T=V.variations.find((function(e){return e.value===A.variation}))))return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variation:T},c.debug("forced variation found",t),t;if(u&&A.variables&&void 0!==A.variables[u])return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variableKey:u,variableSchema:k,variableValue:A.variables[u]},c.debug("forced variable",t),t}if("flag"===r&&V.required&&V.required.length>0){var x=V.required.every((function(t){var r,i;if("string"==typeof t?r=t:(r=t.key,i=t.variation),!o(a(a({},e),{type:"flag",featureKey:r})).enabled)return!1;if(void 0!==i){var n=o(a(a({},e),{type:"variation",featureKey:r})),s=void 0;return n.variationValue?s=n.variationValue:n.variation&&(s=n.variation.value),s===i}return!0}));if(!x)return t={type:r,featureKey:s,reason:i.REQUIRED,required:V.required,enabled:x},c.debug("required features not enabled",t),t}for(var O=(0,n.getBucketKey)({featureKey:s,bucketBy:V.bucketBy,context:l,logger:c}),E=0,_=v;E<_.length;E++)(L=_[E]).bucketKey&&(O=L.bucketKey({featureKey:s,context:l,bucketBy:V.bucketBy,bucketKey:O}));for(var S,R,M=(0,n.getBucketedNumber)(O),I=0,D=v;I<D.length;I++){var L;(L=D[I]).bucketValue&&(M=L.bucketValue({featureKey:s,bucketKey:O,context:l,bucketValue:M}))}if("flag"!==r?(S=f.getMatchedTraffic(V.traffic,l))&&(R=f.getMatchedAllocation(S,M)):S=f.getMatchedTraffic(V.traffic,l),S){if(0===S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!1},c.debug("matched rule with 0 percentage",t),t;if("flag"===r){if(V.ranges&&V.ranges.length>0)return V.ranges.find((function(e){return M>=e[0]&&M<e[1]}))?(t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:void 0===S.enabled||S.enabled},c.debug("matched",t),t):(t={type:r,featureKey:s,reason:i.OUT_OF_RANGE,bucketKey:O,bucketValue:M,enabled:!1},c.debug("not matched",t),t);if(void 0!==S.enabled)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:S.enabled},c.debug("override from rule",t),t;if(M<=S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!0},c.debug("matched traffic",t),t}if("variation"===r&&V.variations){if(S.variation&&(T=V.variations.find((function(e){return e.value===S.variation}))))return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("override from rule",t),t;if(R&&R.variation&&(T=V.variations.find((function(e){return e.value===R.variation}))))return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("allocated variation",t),t}}if("variable"===r&&u){if(S&&S.variables&&void 0!==S.variables[u])return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:S.variables[u]},c.debug("override from rule",t),t;var F;if(A&&A.variation?F=A.variation:S&&S.variation?F=S.variation:R&&R.variation&&(F=R.variation),F&&Array.isArray(V.variations)){var T;if((T=V.variations.find((function(e){return e.value===F})))&&T.variableOverrides&&T.variableOverrides[u]){var C=T.variableOverrides[u].find((function(e){return e.conditions?f.allConditionsAreMatched("string"==typeof e.conditions&&"*"!==e.conditions?JSON.parse(e.conditions):e.conditions,l):!!e.segments&&f.allSegmentsAreMatched(f.parseSegmentsIfStringified(e.segments),l)}));if(C)return t={type:r,featureKey:s,reason:i.VARIABLE_OVERRIDE,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:C.value},c.debug("variable override",t),t}if(T&&T.variables&&void 0!==T.variables[u])return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:T.variables[u]},c.debug("allocated variable",t),t}}return"variation"===r?(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M},c.debug("no matched variation",t),t):"variable"===r?k?(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,bucketKey:O,bucketValue:M,variableKey:u,variableSchema:k,variableValue:k.defaultValue},c.debug("using default value",t),t):(t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u,bucketKey:O,bucketValue:M},c.debug("variable not found",t),t):(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M,enabled:!1},c.debug("nothing matched",t),t)}catch(e){return t={type:r,featureKey:s,variableKey:u,reason:i.ERROR,error:e},c.error("error",t),t}}!function(e){e.FEATURE_NOT_FOUND="feature_not_found",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.NO_VARIATIONS="no_variations",e.VARIATION_DISABLED="variation_disabled",e.VARIABLE_NOT_FOUND="variable_not_found",e.VARIABLE_DEFAULT="variable_default",e.VARIABLE_DISABLED="variable_disabled",e.VARIABLE_OVERRIDE="variable_override",e.NO_MATCH="no_match",e.FORCED="forced",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.ERROR="error"}(i||(t.EvaluationReason=i={}))},985:function(e,t){var r=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var a,i=0,n=t.length;i<n;i++)!a&&i in t||(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.getParamsForStickySetEvent=function(e,t,a){void 0===e&&(e={}),void 0===t&&(t={});var i=Object.keys(e),n=Object.keys(t),o=r(r([],i,!0),n,!0);return{features:o.filter((function(e,t){return o.indexOf(e)===t})),replaced:a}},t.getParamsForDatafileSetEvent=function(e,t){for(var a=e.getRevision(),i=e.getFeatureKeys(),n=t.getRevision(),o=t.getFeatureKeys(),s=[],u=[],l=[],c=0,f=i;c<f.length;c++){var d=f[c];if(-1!==o.indexOf(d)){var v=e.getFeature(d),y=t.getFeature(d);(null==v?void 0:v.hash)!==(null==y?void 0:y.hash)&&u.push(d)}else s.push(d)}for(var g=0,h=o;g<h.length;g++){var p=h[g];-1===i.indexOf(p)&&l.push(p)}return{revision:n,previousRevision:a,revisionChanged:a!==n,features:r(r(r([],s,!0),u,!0),l,!0).filter((function(e,t,r){return r.indexOf(e)===t}))}}},943:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueByType=function(e,t){if(void 0===e)return null;switch(t){case"string":return"string"==typeof e?e:null;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:null;case"object":return"object"==typeof e?e:null;default:return e}}},438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HooksManager=void 0;var r=function(){function e(e){var t=this;this.hooks=[],this.logger=e.logger,e.hooks&&e.hooks.forEach((function(e){t.add(e)}))}return e.prototype.add=function(e){var t=this;if(!this.hooks.some((function(t){return t.name===e.name})))return this.hooks.push(e),function(){t.remove(e.name)};this.logger.error('Hook with name "'.concat(e.name,'" already exists.'),{name:e.name,hook:e})},e.prototype.remove=function(e){this.hooks=this.hooks.filter((function(t){return t.name!==e}))},e.prototype.getAll=function(){return this.hooks},e}();t.HooksManager=r},166:function(e,t,r){var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(481),t),i(r(247),t),i(r(584),t),i(r(186),t),i(r(335),t),i(r(649),t),i(r(608),t)},247:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=void 0,t.createInstance=function(e){return void 0===e&&(e={}),new v(e)};var i=r(584),n=r(438),o=r(40),s=r(649),u=r(335),l=r(608),c=r(985),f=r(943),d={schemaVersion:"2",revision:"unknown",segments:{},features:{}},v=function(){function e(e){this.context={},this.context=e.context||{},this.logger=e.logger||(0,i.createLogger)({level:e.logLevel||i.Logger.defaultLevel}),this.hooksManager=new n.HooksManager({hooks:e.hooks||[],logger:this.logger}),this.emitter=new o.Emitter,this.sticky=e.sticky,this.datafileReader=new s.DatafileReader({datafile:d,logger:this.logger}),e.datafile&&(this.datafileReader=new s.DatafileReader({datafile:"string"==typeof e.datafile?JSON.parse(e.datafile):e.datafile,logger:this.logger})),this.logger.info("Featurevisor SDK initialized")}return e.prototype.setLogLevel=function(e){this.logger.setLevel(e)},e.prototype.setDatafile=function(e){try{var t=new s.DatafileReader({datafile:"string"==typeof e?JSON.parse(e):e,logger:this.logger}),r=(0,c.getParamsForDatafileSetEvent)(this.datafileReader,t);this.datafileReader=t,this.logger.info("datafile set",r),this.emitter.trigger("datafile_set",r)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,c.getParamsForStickySetEvent)(r,this.sticky,t);this.logger.info("sticky features set",i),this.emitter.trigger("sticky_set",i)},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return this.datafileReader.getFeature(e)},e.prototype.addHook=function(e){return this.hooksManager.add(e)},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t}),this.logger.debug(t?"context replaced":"context updated",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return e?a(a({},this.context),e):this.context},e.prototype.spawn=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),new l.FeaturevisorChildInstance({parent:this,context:this.getContext(e),sticky:t.sticky})},e.prototype.getEvaluationDependencies=function(e,t){return void 0===t&&(t={}),{context:this.getContext(e),logger:this.logger,hooksManager:this.hooksManager,datafileReader:this.datafileReader,sticky:t.sticky?a(a({},this.sticky),t.sticky):this.sticky,defaultVariationValue:t.defaultVariationValue,defaultVariableValue:t.defaultVariableValue}},e.prototype.evaluateFlag=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"flag",featureKey:e}))},e.prototype.isEnabled=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{return!0===this.evaluateFlag(e,t,r).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"variation",featureKey:e}))},e.prototype.getVariation=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{var a=this.evaluateVariation(e,t,r);return void 0!==a.variationValue?a.variationValue:a.variation?a.variation.value:null}catch(t){return this.logger.error("getVariation",{featureKey:e,error:t}),null}},e.prototype.evaluateVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(r,i)),{type:"variable",featureKey:e,variableKey:t}))},e.prototype.getVariable=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});try{var i=this.evaluateVariable(e,t,r,a);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:null}catch(r){return this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r}),null}},e.prototype.getVariableBoolean=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"boolean")},e.prototype.getVariableString=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"string")},e.prototype.getVariableInteger=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"integer")},e.prototype.getVariableDouble=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"double")},e.prototype.getVariableArray=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"array")},e.prototype.getVariableObject=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"object")},e.prototype.getVariableJSON=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"json")},e.prototype.getAllEvaluations=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={});for(var a={},i=0,n=t.length>0?t:this.datafileReader.getFeatureKeys();i<n.length;i++){var o=n[i],s={enabled:this.isEnabled(o,e,r)};if(this.datafileReader.hasVariations(o)){var u=this.getVariation(o,e,r);u&&(s.variation=u)}var l=this.datafileReader.getVariableKeys(o);if(l.length>0){s.variables={};for(var c=0,f=l;c<f.length;c++){var d=f[c];s.variables[d]=this.getVariable(o,d,e,r)}}a[o]=s}return a},e}();t.FeaturevisorInstance=v},584:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.loggerPrefix=void 0,t.createLogger=function(e){return void 0===e&&(e={}),new r(e)},t.loggerPrefix="[Featurevisor]",t.defaultLogHandler=function(e,r,a){void 0===a&&(a={});var i="log";"info"===e?i="info":"warn"===e?i="warn":"error"===e&&(i="error"),console[i](t.loggerPrefix,r,a)};var r=function(){function e(r){this.level=r.level||e.defaultLevel,this.handle=r.handler||t.defaultLogHandler}return e.prototype.setLevel=function(e){this.level=e},e.prototype.log=function(t,r,a){e.allLevels.indexOf(this.level)>=e.allLevels.indexOf(t)&&this.handle(t,r,a)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e.allLevels=["fatal","error","warn","info","debug"],e.defaultLevel="info",e}();t.Logger=r},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHashV3=function(e,t){var a,i,n,o,s,u,l,c;for("string"==typeof e&&(e=r(e)),a=3&e.length,i=e.length-a,n=t,s=3432918353,u=461845907,c=0;c<i;)l=255&e[c]|(255&e[++c])<<8|(255&e[++c])<<16|(255&e[++c])<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,a){case 3:l^=(255&e[c+2])<<16;case 2:l^=(255&e[c+1])<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e[c]))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};var r=function(e){return(new TextEncoder).encode(e)}}},t={};return function r(a){var i=t[a];if(void 0!==i)return i.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,r),n.exports}(166)})()));
2
2
  //# sourceMappingURL=index.js.map