rox-config-fetcher
Version:
CloudBees Feature Management ROX JS SDK flag config fetcher
119 lines • 88 kB
JavaScript
import e from 'axios';
import t from 'url';
import r from 'events';
import n from 'https';
import i from 'http';
import o from 'util';
import s from 'crypto';
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
function a(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}});}});}),Object.freeze(e)}var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c,d={exports:{}};c=e=>(()=>{var t=[,(e,t,r)=>{r.r(t),r.d(t,{FlagsSetter:()=>n.default});var n=r(2);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var n=r(3);class i{constructor(e,t){this.flagRepo=e,this.experimentsRepo=t;}prepareFlagsWithExperiments(){const e=this.experimentsRepo.experiments||[];n.default.debug(`Set experiments ${JSON.stringify(e)}`);const t=[];e.forEach(e=>{e&&e.flags.forEach(r=>{if(!r)return;const n=this.flagRepo.flagWithName(r.name);n&&(t.push(n),this.connectExperimentToFlag(n,e.deploymentConfiguration.condition));});}),this.flagRepo.flags.forEach(e=>{t.some(t=>t===e)||this.connectExperimentToFlag(e,void 0);});}setAddedFlag(e){const t=this.experimentsRepo.experimentForFlag(e);t&&this.connectExperimentToFlag(e,t.deploymentConfiguration.condition);}connectExperimentToFlag(e,t){e.condition=t;}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const n={debug:0,info:1,warn:2,error:3};let i="error",o=new class{constructor(){this.debug=(e,...t)=>{n[i]<=n.debug&&console&&console.log(e,...t);},this.info=(e,...t)=>{n[i]<=n.info&&console&&console.info(e,...t);},this.warn=(e,...t)=>{n[i]<=n.warn&&console&&console.warn(e,...t);},this.error=(e,...t)=>{console&&console.error(e,...t);},this.setVerboseMode=e=>{"verbose"===e?(i="debug",this.debug("Active verbose mode")):i="error";},this.setLogger=e=>{o=e;};}};const s=o;},(e,t,r)=>{r.r(t),r.d(t,{CustomProperties:()=>n.default,Experiments:()=>i.default,Flags:()=>o.default,TargetGroups:()=>s.default});var n=r(5),i=r(6),o=r(7),s=r(8);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const n=new class{constructor(){this.store=new Map;}has(e){return this.store.has(e.name)}get(e){return this.store.get(e)}set(e){this.store.set(e.name,e);}setIfNotExists(e){this.has(e)||this.set(e);}clear(){this.store.clear();}get items(){return Array.from(this.store.values())}};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const n=new class{constructor(){this.map={};}setExperiments(e){this.map={},(e=e||[]).forEach(function(e){this.map[e.identifier]=e;},this);}experimentWithName(e){return this.map[e]}get experiments(){return Object.keys(this.map).map(e=>this.map[e])}experimentForFlagName(e){return this.experiments.find(t=>t.flags&&t.flags.some(t=>t.name===e))}experimentForFlag(e){return this.experimentForFlagName(e.name)}};},(e,t,r)=>{r.r(t),r.d(t,{RoxFlagRepository:()=>o,default:()=>s});var n=r(2),i=r(6);class o{constructor(){this.map={};}addFlag(e,t){t.name=e,this.map[e]=t,new n.default(this,i.default).setAddedFlag(t);}flagWithName(e){return this.map[e]}get flags(){return Object.keys(this.map).map(e=>this.map[e])}get items(){return this.flags}}const s=new o;},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const n=new class{constructor(){this.map={};}addTargetGroup(e){this.map[e.identifier]=e;}setTargetGroups(e){this.map={},(e=e||[]).forEach(function(e){this.map[e.identifier]=e;},this);}targetGroupWithName(e){return this.map[e]}get targetGroups(){return Object.keys(this.map).map(e=>this.map[e])}};},(e,t,r)=>{r.r(t),r.d(t,{ConfigurationParser:()=>i.default,RoxxParser:()=>n.default});var n=r(10),i=r(23);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var n=r(11),i=r(3),o=r(13),s=r(20),a=r(21);class u{constructor(e){this._tokenizer=new n.RoxxTokenizer,this._cache=e||{};}_argsArrayForOperator(e,t){const r=[],n=e.length;for(let e=0;e<n;e++){const e=t.pop();r.push(e);}return r}_modifyArgsHook({operator:e,args:t,context:r,callContext:n}){let i=t;return r&&o.operatorsWithContext.includes(e)&&(i=[...t,r]),n?[...i,n]:i}compileExpression(e){let t=this._cache[e];return t||(t=this._tokenizer.tokenize(e).reverse(),this._cache[e]=t),t}evaluateExpression(e,t={},r={},u){var l;const c=[],d=this.compileExpression(e);let h;const f=d.length;try{for(let e=0;e<f;e++){const s=d[e];if(s.type==n.RoxxTokenTypeRand)c.push(s.value);else {if(s.type!=n.RoxxTokenTypeRator){c.push(void 0);break}{const e=o[s.value];let n=this._argsArrayForOperator(e,c);n=this._modifyArgsHook({operator:e,args:n,context:r,callContext:t});const a=e.apply(this,n);c.push(a);const l=`${s.value}(${JSON.stringify(n)}) => ${a}`;u&&u.push(l),i.default.debug(`Roxx: ${l}`);}}}h=c.pop();}catch(t){const r=`Uh oh! An error occurred during Roxx evaluation. ${e}`;t.isUserError?s.default.invoke(t.trigger,t):null===(l=a.default.getErrorReporter())||void 0===l||l.error(r,t),i.default.error(r,t),h=!1;}finally{return h}}}},(e,t,r)=>{r.r(t),r.d(t,{RoxxTokenTypeRand:()=>c,RoxxTokenTypeRator:()=>l,RoxxTokenizer:()=>d});var n=r(12),i=r(13);const o=Object.keys(i),s="\\RO_Q",a='"',u='{}[]():, \t\r\n"',l="operator",c="operand";class d{constructor(){this.tokenArray=[],this.arrayAccumulator=void 0,this.dictionaryAccumulator=void 0,this.dictKey=void 0;}_stringToRoxx(e){return o.includes(e)?{type:l,value:e}:"true"==e?{type:c,value:!0}:"false"==e?{type:c,value:!1}:"undefined"==e?{type:c,value:void 0}:'"'==e.charAt(0)&&'"'==e.charAt(e.length-1)?{type:c,value:e.substr(1,e.length-2)}:isNaN(e)?{type:"UNKNOWN"}:{type:c,value:+e}}push(e){this.dictionaryAccumulator&&!this.dictKey?this.dictKey=e.value:this.dictionaryAccumulator&&this.dictKey?(this.dictionaryAccumulator[this.dictKey]=e.value,this.dictKey=void 0):this.arrayAccumulator?this.arrayAccumulator.push(e.value):this.tokenArray.push(e);}tokenize(e){this.tokenArray=[],this.arrayAccumulator=void 0,this.dictionaryAccumulator=void 0;let t=u;const r=e.replace('\\"',s),i=new n.default(r,t,!0);let o,l;for(;i.hasMoreTokens();)switch(l=o,o=i.nextTokenWithDelimiters(t),o){case"{":this.dictionaryAccumulator={};break;case"}":this.tokenArray.push({type:c,value:this.dictionaryAccumulator}),this.dictionaryAccumulator=void 0;break;case"[":this.arrayAccumulator=[];break;case"]":this.tokenArray.push({type:c,value:this.arrayAccumulator}),this.arrayAccumulator=void 0;break;case a:l==a&&this.push({type:c,value:""}),t=t==a?u:a;break;default:t==a?this.push({type:c,value:o.replace(s,'\\"')}):-1==u.indexOf(o)&&this.push(this._stringToRoxx(o));}return this.tokenArray}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t,r){this._string=e,this._delimiters=t,this._returnDelim=r,this._position=0;}countTokens(){let e=0,t=!1;for(let r=this._position,n=this._string.length;r<n;r++)-1!=this._delimiters.indexOf(this._string.charAt(r))?(this._returnDelim&&e++,t&&(e++,t=!1)):t=!0;return t&&e++,e}hasMoreElements(){return this.hasMoreTokens()}hasMoreTokens(){if(!this._delimiters)return !1;const e=this._string.length;if(this._position<e){if(this._returnDelim)return !0;for(let t=this._position;t<e;t++)if(-1==this._delimiters.indexOf(this._string.charAt(t)))return !0}return !1}nextElement(){return this.nextToken()}nextToken(){if(!this._delimiters)return;let e=this._position;const t=this._string.length;if(e<t){if(this._returnDelim){if(-1!=this._delimiters.indexOf(this._string.charAt(this._position)))return this._string.charAt(this._position++);for(this._position++;this._position<t;this._position++)if(-1!=this._delimiters.indexOf(this._string.charAt(this._position)))return this._string.substr(e,this._position-e);return this._string.substr(e)}for(;e<t&&-1!=this._delimiters.indexOf(this._string.charAt(this._position));)e++;if(this._position=e,e<t){for(this._position++;this._position<t;this._position++)if(-1!=this._delimiters.indexOf(this._string.charAt(this._position)))return this._string.substr(e,this._position-e);return this._string.substr(e)}}}nextTokenWithDelimiters(e){return this._delimiters=e,this.nextToken()}}},(e,t,r)=>{r.r(t),r.d(t,{and:()=>m,b64d:()=>G,concat:()=>J,eq:()=>_,flagValue:()=>$,gt:()=>O,gte:()=>A,ifThen:()=>P,inArray:()=>z,isInPercentage:()=>L,isInPercentageRange:()=>M,isInTargetGroup:()=>B,isTargetGroupPaired:()=>H,isUndefined:()=>g,lt:()=>S,lte:()=>E,match:()=>C,md5:()=>K,mergeSeed:()=>j,ne:()=>b,not:()=>x,now:()=>y,numeq:()=>R,numne:()=>N,operatorsWithContext:()=>q,or:()=>v,property:()=>V,semverEq:()=>F,semverGt:()=>D,semverGte:()=>k,semverLt:()=>T,semverLte:()=>I,semverNe:()=>U,tsToNum:()=>w});var n=r(8),i=r(5),o=r(7),s=r(6),a=r(10),u=r(14),l=r.n(u),c=r(18),d=r(19),h=r(20);function f(e,t,r={zeroExtend:!0,lexicographical:!0}){const n=r&&r.lexicographical,i=r&&r.zeroExtend;let o=e.split("."),s=t.split(".");function a(e){return (n?/[0-9A-Za-z_-]+$/:/^\d+$/).test(e)}if(!o.every(a)||!s.every(a))return NaN;if(i){for(;o.length<s.length;)o.push("0");for(;s.length<o.length;)s.push("0");}n||(o=o.map(Number),s=s.map(Number));for(let e=0;e<o.length;++e){if(s.length==e)return 1;if(o[e]!=s[e])return o[e]>s[e]?1:-1}return o.length!=s.length?-1:0}const p=e=>{let t=l()(e,{asBytes:!0});return t=(255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24)>>>0,t/(Math.pow(2,32)-1)},g=e=>void 0===e,y=()=>Date.now(),m=(e,t)=>e&&t,v=(e,t)=>e||t,b=(e,t)=>(!g(e)&&e)!==(!g(t)&&t),_=(e,t)=>(!g(e)&&e)===(!g(t)&&t),x=e=>!e,P=(e,t,r)=>e?t:r,S=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e<t)),E=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e<=t)),w=e=>{if(!g(e))return e instanceof Date?e.getTime()/1e3:void 0},O=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e>t)),N=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||e===t),R=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||e!==t),A=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e>=t)),C=(e,t,r)=>{const n=e;return !!new RegExp(t,r).exec(n)},T=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})<0,I=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})<=0,D=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})>0,k=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})>=0,F=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&0==f(e,t),U=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&0!=f(e,t),j=(e,t)=>e+"."+t,L=(e,t)=>p(t)<=e,M=(e,t,r)=>{const n=p(r);return n>=e&&n<=t},$=(e,t={},r={})=>{const n=o.default.flagWithName(e);if(n){const e=Object.assign({},r);return n.getInternalValue(e,t),e.isPeek||e.result.isOverride||e.result.isFreezed||n._flagImpression(e.result.value,e.result.usedContext),e.result.value}const i=s.default.experimentForFlagName(e);return i&&i.deploymentConfiguration&&(new a.default).evaluateExpression(i.deploymentConfiguration.condition,r,t)||"false"},B=(e,t={},r={})=>{const i=n.default.targetGroupWithName(e);return !!i&&(new a.default).evaluateExpression(i.condition,r,t)},H=()=>!1,V=(e,t={})=>{const r=i.default.get(e);if(r)return r.getValue(t);{const r=d.DynamicPropertiesHandler&&(0, d.DynamicPropertiesHandler)();let n;if(r)if(r._isUserDefined)try{n=r(e,t);}catch(e){throw e.isUserError=!0,e.trigger=h.ExceptionTrigger.DYNAMIC_PROPERTIES_RULE,e}else n=r(e,t);return n}},z=(e,t)=>!!t&&t.includes(e),K=e=>{if("string"==typeof e)return l()(e)},J=(e,t)=>{if("string"==typeof e&&"string"==typeof t)return `${e}${t}`},G=e=>{if("string"==typeof e)return decodeURIComponent((0, c.decode)(e))},q=[B,$,V];},(e,t,r)=>{var n,i,o,s,a;n=r(15),i=r(16).utf8,o=r(17),s=r(16).bin,(a=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?s.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var r=n.bytesToWords(e),u=8*e.length,l=1732584193,c=-271733879,d=-1732584194,h=271733878,f=0;f<r.length;f++)r[f]=16711935&(r[f]<<8|r[f]>>>24)|4278255360&(r[f]<<24|r[f]>>>8);r[u>>>5]|=128<<u%32,r[14+(u+64>>>9<<4)]=u;var p=a._ff,g=a._gg,y=a._hh,m=a._ii;for(f=0;f<r.length;f+=16){var v=l,b=c,_=d,x=h;l=p(l,c,d,h,r[f+0],7,-680876936),h=p(h,l,c,d,r[f+1],12,-389564586),d=p(d,h,l,c,r[f+2],17,606105819),c=p(c,d,h,l,r[f+3],22,-1044525330),l=p(l,c,d,h,r[f+4],7,-176418897),h=p(h,l,c,d,r[f+5],12,1200080426),d=p(d,h,l,c,r[f+6],17,-1473231341),c=p(c,d,h,l,r[f+7],22,-45705983),l=p(l,c,d,h,r[f+8],7,1770035416),h=p(h,l,c,d,r[f+9],12,-1958414417),d=p(d,h,l,c,r[f+10],17,-42063),c=p(c,d,h,l,r[f+11],22,-1990404162),l=p(l,c,d,h,r[f+12],7,1804603682),h=p(h,l,c,d,r[f+13],12,-40341101),d=p(d,h,l,c,r[f+14],17,-1502002290),l=g(l,c=p(c,d,h,l,r[f+15],22,1236535329),d,h,r[f+1],5,-165796510),h=g(h,l,c,d,r[f+6],9,-1069501632),d=g(d,h,l,c,r[f+11],14,643717713),c=g(c,d,h,l,r[f+0],20,-373897302),l=g(l,c,d,h,r[f+5],5,-701558691),h=g(h,l,c,d,r[f+10],9,38016083),d=g(d,h,l,c,r[f+15],14,-660478335),c=g(c,d,h,l,r[f+4],20,-405537848),l=g(l,c,d,h,r[f+9],5,568446438),h=g(h,l,c,d,r[f+14],9,-1019803690),d=g(d,h,l,c,r[f+3],14,-187363961),c=g(c,d,h,l,r[f+8],20,1163531501),l=g(l,c,d,h,r[f+13],5,-1444681467),h=g(h,l,c,d,r[f+2],9,-51403784),d=g(d,h,l,c,r[f+7],14,1735328473),l=y(l,c=g(c,d,h,l,r[f+12],20,-1926607734),d,h,r[f+5],4,-378558),h=y(h,l,c,d,r[f+8],11,-2022574463),d=y(d,h,l,c,r[f+11],16,1839030562),c=y(c,d,h,l,r[f+14],23,-35309556),l=y(l,c,d,h,r[f+1],4,-1530992060),h=y(h,l,c,d,r[f+4],11,1272893353),d=y(d,h,l,c,r[f+7],16,-155497632),c=y(c,d,h,l,r[f+10],23,-1094730640),l=y(l,c,d,h,r[f+13],4,681279174),h=y(h,l,c,d,r[f+0],11,-358537222),d=y(d,h,l,c,r[f+3],16,-722521979),c=y(c,d,h,l,r[f+6],23,76029189),l=y(l,c,d,h,r[f+9],4,-640364487),h=y(h,l,c,d,r[f+12],11,-421815835),d=y(d,h,l,c,r[f+15],16,530742520),l=m(l,c=y(c,d,h,l,r[f+2],23,-995338651),d,h,r[f+0],6,-198630844),h=m(h,l,c,d,r[f+7],10,1126891415),d=m(d,h,l,c,r[f+14],15,-1416354905),c=m(c,d,h,l,r[f+5],21,-57434055),l=m(l,c,d,h,r[f+12],6,1700485571),h=m(h,l,c,d,r[f+3],10,-1894986606),d=m(d,h,l,c,r[f+10],15,-1051523),c=m(c,d,h,l,r[f+1],21,-2054922799),l=m(l,c,d,h,r[f+8],6,1873313359),h=m(h,l,c,d,r[f+15],10,-30611744),d=m(d,h,l,c,r[f+6],15,-1560198380),c=m(c,d,h,l,r[f+13],21,1309151649),l=m(l,c,d,h,r[f+4],6,-145523070),h=m(h,l,c,d,r[f+11],10,-1120210379),d=m(d,h,l,c,r[f+2],15,718787259),c=m(c,d,h,l,r[f+9],21,-343485551),l=l+v>>>0,c=c+b>>>0,d=d+_>>>0,h=h+x>>>0;}return n.endian([l,c,d,h])})._ff=function(e,t,r,n,i,o,s){var a=e+(t&r|~t&n)+(i>>>0)+s;return (a<<o|a>>>32-o)+t},a._gg=function(e,t,r,n,i,o,s){var a=e+(t&n|r&~n)+(i>>>0)+s;return (a<<o|a>>>32-o)+t},a._hh=function(e,t,r,n,i,o,s){var a=e+(t^r^n)+(i>>>0)+s;return (a<<o|a>>>32-o)+t},a._ii=function(e,t,r,n,i,o,s){var a=e+(r^(t|~n))+(i>>>0)+s;return (a<<o|a>>>32-o)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var r=n.wordsToBytes(a(e,t));return t&&t.asBytes?r:t&&t.asString?s.bytesToString(r):n.bytesToHex(r)};},e=>{var t,r;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&r.rotl(e,8)|4278255360&r.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=r.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r<e.length;r++,n+=8)t[n>>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},bytesToBase64:function(e){for(var r=[],n=0;n<e.length;n+=3)for(var i=e[n]<<16|e[n+1]<<8|e[n+2],o=0;o<4;o++)8*n+6*o<=8*e.length?r.push(t.charAt(i>>>6*(3-o)&63)):r.push("=");return r.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var r=[],n=0,i=0;n<e.length;i=++n%4)0!=i&&r.push((t.indexOf(e.charAt(n-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(n))>>>6-2*i);return r}},e.exports=r;},e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}};e.exports=t;},e=>{function t(e){return !!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
e.exports=function(e){return null!=e&&(t(e)||function(e){return "function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)};},(e,t,r)=>{r.r(t),r.d(t,{Base64:()=>$,VERSION:()=>i,atob:()=>A,atobPolyfill:()=>R,btoa:()=>y,btoaPolyfill:()=>g,btou:()=>N,decode:()=>k,encode:()=>S,encodeURI:()=>E,encodeURL:()=>E,extendBuiltins:()=>M,extendString:()=>j,extendUint8Array:()=>L,fromBase64:()=>k,fromUint8Array:()=>v,isValid:()=>F,toBase64:()=>S,toUint8Array:()=>T,utob:()=>x,version:()=>n});const n="3.7.8",i=n,o="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,a="function"==typeof TextEncoder?new TextEncoder:void 0,u=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),l=(e=>{let t={};return e.forEach((e,r)=>t[e]=r),t})(u),c=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,d=String.fromCharCode.bind(String),h="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),f=e=>e.replace(/=/g,"").replace(/[+\/]/g,e=>"+"==e?"-":"_"),p=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),g=e=>{let t,r,n,i,o="";const s=e.length%3;for(let s=0;s<e.length;){if((r=e.charCodeAt(s++))>255||(n=e.charCodeAt(s++))>255||(i=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,o+=u[t>>18&63]+u[t>>12&63]+u[t>>6&63]+u[63&t];}return s?o.slice(0,s-3)+"===".substring(s):o},y="function"==typeof btoa?e=>btoa(e):o?e=>Buffer.from(e,"binary").toString("base64"):g,m=o?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,n=e.length;r<n;r+=4096)t.push(d.apply(null,e.subarray(r,r+4096)));return y(t.join(""))},v=(e,t=!1)=>t?f(m(e)):m(e),b=e=>{if(e.length<2)return (t=e.charCodeAt(0))<128?e:t<2048?d(192|t>>>6)+d(128|63&t):d(224|t>>>12&15)+d(128|t>>>6&63)+d(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return d(240|t>>>18&7)+d(128|t>>>12&63)+d(128|t>>>6&63)+d(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,x=e=>e.replace(_,b),P=o?e=>Buffer.from(e,"utf8").toString("base64"):a?e=>m(a.encode(e)):e=>y(x(e)),S=(e,t=!1)=>t?f(P(e)):P(e),E=e=>S(e,!0),w=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,O=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return d((t>>>10)+55296)+d(56320+(1023&t));case 3:return d((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return d((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},N=e=>e.replace(w,O),R=e=>{if(e=e.replace(/\s+/g,""),!c.test(e))throw new TypeError("malformed base64.");let t,r,n;e+="==".slice(2-(3&e.length));let i=[];for(let o=0;o<e.length;)t=l[e.charAt(o++)]<<18|l[e.charAt(o++)]<<12|(r=l[e.charAt(o++)])<<6|(n=l[e.charAt(o++)]),64===r?i.push(d(t>>16&255)):64===n?i.push(d(t>>16&255,t>>8&255)):i.push(d(t>>16&255,t>>8&255,255&t));return i.join("")},A="function"==typeof atob?e=>atob(p(e)):o?e=>Buffer.from(e,"base64").toString("binary"):R,C=o?e=>h(Buffer.from(e,"base64")):e=>h(A(e).split("").map(e=>e.charCodeAt(0))),T=e=>C(D(e)),I=o?e=>Buffer.from(e,"base64").toString("utf8"):s?e=>s.decode(C(e)):e=>N(A(e)),D=e=>p(e.replace(/[-_]/g,e=>"-"==e?"+":"/")),k=e=>I(D(e)),F=e=>{if("string"!=typeof e)return !1;const t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return !/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},U=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),j=function(){const e=(e,t)=>Object.defineProperty(String.prototype,e,U(t));e("fromBase64",function(){return k(this)}),e("toBase64",function(e){return S(this,e)}),e("toBase64URI",function(){return S(this,!0)}),e("toBase64URL",function(){return S(this,!0)}),e("toUint8Array",function(){return T(this)});},L=function(){const e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,U(t));e("toBase64",function(e){return v(this,e)}),e("toBase64URI",function(){return v(this,!0)}),e("toBase64URL",function(){return v(this,!0)});},M=()=>{j(),L();},$={version:n,VERSION:i,atob:A,atobPolyfill:R,btoa:y,btoaPolyfill:g,fromBase64:k,toBase64:S,encode:S,encodeURI:E,encodeURL:E,utob:x,btou:N,decode:k,isValid:F,fromUint8Array:v,toUint8Array:T,extendString:j,extendUint8Array:L,extendBuiltins:M};},(e,t,r)=>{r.r(t),r.d(t,{DynamicPropertiesHandler:()=>a,defaultDynamicPropertyHandler:()=>o,setDynamicPropertyHandler:()=>s});const n=(e,t)=>t?t[e]:void 0;let i=n;function o(){return n}function s(e){i=e,e&&(i._isUserDefined=!0);}function a(){return i}},(e,t,r)=>{r.r(t),r.d(t,{ExceptionTrigger:()=>i,default:()=>o});var n=r(3);const i={DYNAMIC_PROPERTIES_RULE:"DYNAMIC_PROPERTIES_RULE",CONFIGURATION_FETCHED_HANDLER:"CONFIGURATION_FETCHED_HANDLER",IMPRESSION_HANDLER:"IMPRESSION_HANDLER",CUSTOM_PROPERTY_GENERATOR:"CUSTOM_PROPERTY_GENERATOR"},o=new class{invoke(e,t){if(this.userUnhandledErrorHandler)try{this.userUnhandledErrorHandler(e,t);}catch(e){n.default.error("User Unhandled Error Handler itself threw an exception. original exception:"+t,e);}else n.default.error("User Unhandled Error Occured, no fallback handler was set, exception ignored.",t);}setHandler(e){e instanceof Function?this.userUnhandledErrorHandler=e:n.default.warn("UserspaceUnhandledErrorHandler must be a function. default will be used.");}};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var n,i=r(22);!function(e){e.RolloutEu="eu",e.Platform="platform";}(n||(n={}));const o="x-api.rollout.io";let s=new i.default;const a=e=>{let t=o;e==n.RolloutEu&&(t=`eu-${o}`);const r={API_HOST:t,CD_API_ENDPOINT:`https://${t}/device/get_configuration`,CD_S3_ENDPOINT:"https://conf.rollout.io/",SS_API_ENDPOINT:`https://${t}/device/update_state_store/`,SS_S3_ENDPOINT:"https://statestore.rollout.io/",CLIENT_DATA_CACHE_KEY:"client_data",NOTIFICATIONS_ENDPOINT:"https://push.rollout.io/sse",ANALYTICS_ENDPOINT:"https://analytic.rollout.io",ERROR_REPORTER:void 0};return e==n.Platform&&(r.API_HOST="api.cloudbees.io",r.CD_API_ENDPOINT="https://api.cloudbees.io/device/get_configuration",r.CD_S3_ENDPOINT="https://rox-conf.cloudbees.io/",r.SS_API_ENDPOINT="https://api.cloudbees.io/device/update_state_store/",r.SS_S3_ENDPOINT="https://rox-state.cloudbees.io/",r.ANALYTICS_ENDPOINT="https://fm-analytics.cloudbees.io",r.NOTIFICATIONS_ENDPOINT="https://sdk-notification-service.cloudbees.io/sse"),r};let u=Object.assign({},a());const l={get:e=>u[e],set:(e,t)=>{u[e]=t;},setActive:function(e){u=Object.assign({},e);},setProxy:function(e){s=new i.default(e);},getProxy:()=>s,setHosting:function(e){e===n.RolloutEu&&(u=Object.assign({},a("eu-"))),e===n.Platform&&(u=Object.assign({},a(e)));},setSelfManagedMode:function(e){u=Object.assign({},a(),(({analyticsURL:e,serverURL:t,pushUpdateURL:r,configurationURL:n,stateURL:i})=>({CD_API_ENDPOINT:`${t}/device/get_configuration`,SS_API_ENDPOINT:`${t}/device/update_state_store/`,CLIENT_DATA_CACHE_KEY:"client_data",ANALYTICS_ENDPOINT:e,NOTIFICATIONS_ENDPOINT:`${r}/sse`,CD_S3_ENDPOINT:n,SS_S3_ENDPOINT:i,ERROR_REPORTER:void 0}))(e));},setErrorReporter:function(e){u.ERROR_REPORTER=e;},getErrorReporter:()=>u.ERROR_REPORTER};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(18);const i="roxTargetUrl",o="roxAuth";class s{constructor(e){this._proxyUrl="",this._proxyAuthHeader="",this._proxySettings=!1,e&&(this._proxySettings=Object.assign({},e),this._proxyUrl=`${this._proxySettings.protocol}://${this._proxySettings.host}${this._proxySettings.port?`:${this._proxySettings.port}`:""}`,this._proxySettings.auth&&this._proxySettings.auth.username&&this._proxySettings.auth.password&&(this._proxyAuthHeader=`Basic ${(0, n.encode)(`${this._proxySettings.auth.username}:${this._proxySettings.auth.password}`)}`,this._proxyAuthHeaderEncoded=encodeURIComponent(this._proxyAuthHeader)));}applyProxyToRequest(e){if(this._proxySettings){e.options=e.options?Object.assign({},e.options):{};const t=e.options;t.params=t.params||{},t.params[i]=e.url,this._proxyAuthHeader&&(t.params[o]=this._proxyAuthHeader),e.url=this._proxyUrl;}}applyProxyToSseRequest(e){this._proxySettings&&(e.url=`${this._proxyUrl}?${i}=${encodeURIComponent(e.url)}`,this._proxyAuthHeaderEncoded&&(e.url=`${e.url}&${o}=${this._proxyAuthHeaderEncoded}`));}get proxyUrl(){return this._proxyUrl}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var n=r(24),i=r(27);const o="data",s="application",a="experiments",u="targetGroups",l="signed_date";class c{constructor(e,t,r=!0){if(!e||"object"!=typeof e)throw new Error(`ConfigurationParser should be constructed with JSON object. Received ${e}`);if(!t||"string"!=typeof t)throw new Error(`ConfigurationParser should be constructed with app key string. Received ${t}`);this._json=e,this._appKey=t,this._validateAppKey=r;}parse(){const e=this._extractInnerJson(this._json);return this._validateAppKey&&e[s]!==this._appKey?null:(this._parseExperiments(e[a]),this._parseTargetGroups(e[u]),this._signedDate=new Date(this._json[l]),this)}experiments(){return this._experiments||[]}targetGroups(){return this._targetGroups||[]}signedDate(){return this._signedDate}_extractInnerJson(e){return JSON.parse(e[o])}_parseExperiments(e){this._experiments=new n.default(e).parse();}_parseTargetGroups(e){this._targetGroups=new i.default(e).parse();}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var n=r(25),i=r(26);const o="deploymentConfiguration",s="condition",a="archived",u="sticky",l="_id",c="name",d="featureFlags",h="labels",f="stickinessProperty";class p{constructor(e){this._json=e;}parse(){if(!this._json||!this._json.length)return [];const e=[];return this._json.forEach(t=>{if(!(t&&t[o]&&t[l]&&t[c]&&t[d]))return;const r=t[o];if(!r[s])return;const p=t[h]||[],g=new n.default(r[s]);e.push(new i.default(t[l],t[c],!!t[a],!!t[u],g,t[d],p,t[f]));}),e}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e){this.condition=e;}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t,r,n,i,o,s,a){this.identifier=e,this.name=t,this.archived=r,this.sticky=n,this.deploymentConfiguration=i,this.flags=o,this.labels=s,this.stickinessProperty=a;}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(28);const i="_id",o="condition";class s{constructor(e){this._json=e;}parse(){if(!this._json||!this._json.length)return [];const e=[];return this._json.forEach(t=>{t&&t[i]&&t[o]&&e.push(new n.default(t[i],t[o]));}),e}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t){this.identifier=e,this.condition=t;}}},(e,t,r)=>{r.r(t),r.d(t,{CallContextTypes:()=>u.callContextTypes,CustomProperty:()=>n.default,DeploymentConfiguration:()=>o.default,DeviceProperty:()=>i.default,Experiment:()=>s.default,FlagTypes:()=>u.FlagTypes,RoxStringBase:()=>u.default,TargetGroup:()=>a.default});var n=r(30),i=r(31),o=r(25),s=r(26),a=r(28),u=r(32);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var n=r(20);const i="Semver";class o{constructor(e,t,r){t===i&&(this._isSemver=!0,t=String),function(e){if(void 0===e||""===e)throw new Error("Custom property must be initialized with a name.")}(e),this._name=e,"function"==typeof r?(function(e){if(e.length>1)throw new Error("Dynamic value of a custom property should be a function with maximum 1 argument")}(r),r.isDynamic=!0,this._value=r):(function(e,t){if(t&&t.constructor!==e&&t.constructor!==Function)throw new Error(`Custom property initialized with an invalid type / value combination. (Type: ${e}, Value: ${t})`)}(t,r),this._value=()=>r),this._type=t;}get type(){return this.externalType}get externalType(){return this._isSemver?i:this._type.name==Date.name?o.dateTypeName:this._type.name}get name(){return this._name}getValue(e={}){if(this._value&&this._value.isDynamic)try{return this._value(e)}catch(e){throw e.isUserError=!0,e.trigger=n.ExceptionTrigger.CUSTOM_PROPERTY_GENERATOR,e}return this._value(e)}static get dateTypeName(){return "DateTime"}static get semverTypeName(){return i}get value(){return this._value()}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var n=r(30);class i extends n.default{get name(){return `rox.${super.name}`}}},(e,t,r)=>{r.r(t),r.d(t,{FlagTypes:()=>o,callContextTypes:()=>i,default:()=>s});var n=r(33);const i={frozenOrCalc:"frozenValueOrOneTimeEval",oneTimeCalc:"oneTimeEval",default:"useFrozen"},o={boolean:"boolean",number:"number",string:"string"};class s{constructor(e,t,r){this._type=r;const n=this._validateDefault(e);if(Array.isArray(t))this._validateOptions(t),this._options=t.map(e=>e.toString());else {if(null!=t)throw new Error("RoxStringBase wrong variations type");this._options=[];}-1===this._options.indexOf(n)&&this._options.push(n),this._value=this._defaultValue=n,this._frozen=!1,this._freezable=!0;}_validateDefault(e){if(typeof e!==this._type)throw new Error(`RoxStringBase default value must be of ${this._type} type. Received '${e}'`);return e.toString()}_validateOptions(e){const t=new Error(`RoxStringBase options must be a non-empty array of ${this._type}. Received '${e}'`);if(!e.every(e=>typeof e===this._type))throw t}get defaultValue(){return this._defaultValue}get overridenValue(){if(this.overrider.hasOverride(this.name))return this.overrider.getOverride(this.name)}get overrider(){throw new Error("Not implemented")}getInternalValue(e,t){throw Error("not implemented")}get externalType(){switch(this._type){case o.boolean:return Boolean.name;case o.number:return Number.name;case o.string:default:return String.name}}set name(e){this._name=e;}get name(){return this._name}_getNameDetails(){if(!this.name)return;const e=this.name.split(".");return {name:e.pop(),namespace:e.join(".")||"default"}}dump(){const e={type:i.frozenOrCalc};return this.getInternalValue(e),{name:this.name,type:this._type,nameDetails:this._getNameDetails(),options:[...this._options],defaultValue:this.defaultValue,originalValue:this._originalValue(),overridingValue:this.overridenValue,value:e.result.value}}getActiveValue(e,t){throw new Error("Not implemented")}_originalValue(){const e={type:i.frozenOrCalc};return this.getActiveValue(e),e.result.value}_flagImpression(e,t){(0, n.invokeImpression)(e,this,t);}static _normalizeString(e){return e}static _normalizeNumber(e){return Number(e)}static _normalizeBoolean(e){return "boolean"==typeof e?e:"true"===e}}},(e,t,r)=>{r.r(t),r.d(t,{invokeImpression:()=>c,setAnalytics:()=>h,setHandler:()=>d});var n=r(3),i=r(34),o=r(6),s=r(5),a=r(20);let u=null,l=null;function c(e,t,r){const c=o.default.experimentForFlag(t);try{if(l&&(0,i.isEnabled)("rox.internal.analytics")){const n=c&&c.stickinessProperty;let i=n&&s.default.get(n);i=i||s.default.get("rox.distinct_id");const o=i?i.getValue(r):"";l.track({flag:t.name,value:e,distinctId:o,type:"IMPRESSION",time:(new Date).getTime()});}}catch(e){n.default.error("Failed to send analytics",e);}if("function"!=typeof u)return;const d=!!c;try{u({name:t.name,value:e,targeting:d},r);}catch(e){a.default.invoke(a.ExceptionTrigger.IMPRESSION_HANDLER,e);}}function d(e){u=e;}function h(e){l=e;}},(e,t,r)=>{r.r(t),r.d(t,{getNumber:()=>l,isEnabled:()=>a,setDefaultsMode:()=>c,value:()=>u});var n=r(10),i=r(6);let o=!1;const s={"rox.internal.pushUpdates":"true","rox.internal.considerThrottleInPush":"false","rox.internal.throttleFetchInSeconds":"0","rox.internal.analytics":"true"};function a(e){const t=u(e);return "boolean"==typeof t?t:"true"===t}function u(e){if(o&&Object.prototype.hasOwnProperty.call(s,e))return s[e];const t=i.default.experimentForFlagName(e);return t&&t.deploymentConfiguration?(new n.default).evaluateExpression(t.deploymentConfiguration.condition):""}function l(e){const t=u(e);return parseInt(t)||0}function c(e){o=e;}},(e,t,r)=>{r.r(t),r.d(t,{Actions:()=>n,Manager:()=>i});var n=r(36),i=r(37);},(e,t,r)=>{r.r(t),r.d(t,{getMergedContext:()=>i,getMergedContextWithGlobal:()=>o});var n=r(37);function i(e,t){return e?Object.assign({},e,t):Object.assign({},t)}function o(e){const t=n.getContext();return e?Object.assign({},t,e):Object.assign({},t)}},(e,t,r)=>{r.r(t),r.d(t,{getContext:()=>i,setContext:()=>o});let n={};function i(){return n}function o(e){n=e;}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t){this.cache=e,this._uuid=t,this.distinct_id=this.generateDistinctId(),this.app_release="0.0",this.distinctIdSetExplicitly=!1;}setPlatform(e){this.platform=e;}setRealPlatform(e){this.realPlatform=e;}setDistinctId(e){this.distinctIdSetExplicitly=!0,this.distinct_id=e;}setAppRelease(e){this.app_release=e;}uuid(){return this._uuid()}generateDistinctId(){let e=this.cache.get("distinctId");return e||(e=this.uuid(),this.cache.set("distinctId",e)),e}}},(e,t,r)=>{r.r(t),r.d(t,{Client:()=>R,createRoxClient:()=>C});var n=r(40),i=r(41),o=r(49),s=r(3),a=r(5),u=r(6),l=r(7),c=r(8),d=r(50),h=r(21),f=r(30),p=r(10),g=r(33),y=r(20),m=r(51),v=r(52),b=r(34),_=r(19),x=r(53),P=r.n(x),S=r(47),E=r(67),w=r(70),O=r(71);let N={ClassRegister:o.default};class R{constructor(e=5e3){this.classRegisterer=new N.ClassRegister,this.sendStateDebounceNoCheck=P()(()=>{this._sendState();},e,{maxWait:e,leading:!1,trailing:!0}),this.sendStateDebounced=()=>{this.appKey&&this.sendStateDebounceNoCheck();},this.onConfigurationFetched=this.onConfigurationFetched.bind(this);}get dynamicApi(){return this._dynamicApi}get appKey(){return this.app_key}setKey(e,t){const r=/^[a-f\d]{24}$/i.test(e),n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e);if(!r&&!n)throw Error("invalid rollout apikey");this.app_key=e,n&&(h.default.setHosting("platform"),t.disableSignatureVerification=!0);}setup(e){var t;try{this.handleOptions(e),N.DeviceProperties=N.DeviceProperties.create?N.DeviceProperties.create(N):N.DeviceProperties,this.app_release&&N.DeviceProperties.setAppRelease(this.app_release),this.distinct_id&&N.DeviceProperties.setDistinctId(this.distinct_id),this.platform&&N.DeviceProperties.setPlatform(this.platform),this.deviceProperties=N.DeviceProperties,this.deviceProperties.setRealPlatform(this.realPlatform),this.selfManagedMode&&h.default.setErrorReporter(new n.BugsnagReporter(this.appKey,N.DeviceProperties,this.networkOptions,this.networkApi)),this.configurationFetcher=new i.default(this.appKey,this.deviceProperties,this.devModeSecret,N,this.embeddedConfiguration,{roxyUrl:this.roxyUrl,selfManagedMode:this.selfManagedMode,disableSignatureVerification:this.disableSignatureVerification},this.networkOptions,this.networkApi),this.roxyUrl||(this.stateSender=new E.default(this.appKey,this.deviceProperties,this.devModeSecret,this.networkOptions,{selfManagedMode:this.selfManagedMode},this.disableSignatureVerification,this.networkApi),this.disableNetwork||(0,g.setAnalytics)(new m.default(this.appKey,Object.assign({},this.analyticsOptions),N.DeviceProperties,this.networkOptions,this.networkApi))),N.getDefaultCustomProperties(this.deviceProperties,this.appKey).map(a.default.setIfNotExists.bind(a.default));}catch(e){const r="Uh oh! An error occurred during setup.";s.default.error(r,e),null===(t=h.default.getErrorReporter())||void 0===t||t.error(r,e);}return Promise.resolve(this)}handleOptions(e){const t=N.DefaultSetupOptions.platform,r=Object.assign({},N.DefaultSetupOptions,e);if(r.selfManaged&&"object"==typeof r.selfManaged){if(!r.selfManaged.analyticsURL)throw new Error("analyticsURL is required on self managed mode");if(!r.selfManaged.serverURL)throw new Error("serverURL is required on self managed mode");e.selfManaged.configurationURL&&(r.selfManaged.configurationURL=e.selfManaged.configurationURL.endsWith("/")?e.selfManaged.configurationURL:`${e.selfManaged.configurationURL}/`),e.selfManaged.stateURL&&(r.selfManaged.stateURL=e.selfManaged.stateURL.endsWith("/")?e.selfManaged.stateURL:`${e.selfManaged.stateURL}/`),h.default.setSelfManagedMode(r.selfManaged),(0, b.setDefaultsMode)(!0),this.selfManagedMode=!0;}r.configuration&&r.configuration.disableNetwork&&(this.disableNetwork=!0),this.embeddedConfiguration=r.embedded,this.fetchIntervalInSec=r.fetchIntervalInSec,this.disablePushUpdateListener=!!(this.disableNetwork||this.selfManagedMode&&!r.selfManaged.pushUpdateURL)||r.disablePushUpdateListener,this.configurationFetchedHandler=r.configurationFetchedHandler,this.impressionHandler=r.impressionHandler,this.dynamicPropertyRuleHandler=r.dynamicPropertyRuleHandler,this.app_release=r.version,this.distinct_id=r.distinctId,this.devModeSecret=r.devModeSecret,this.platform=r.platform,this.fetchFunction=r.fetchFunction,this.networkApi=r.networkApi,this.networkApi?s.default.debug("network: using custom"):this.fetchFunction?(s.default.debug("network: using fetch"),this.networkApi=new w.FetchNetwork(this.fetchFunction)):(s.default.debug("network: using axios"),this.networkApi=new O.AxiosNetwork),this.realPlatform=t,this.roxyUrl=r.roxy,this.networkOptions={httpAgent:r.httpAgent,httpsAgent:r.httpsAgent},this.disableSignatureVerification=r.disableSignatureVerification||!1,this.analyticsOptions=r.analytics,this.eventSourceImpl=r.eventSourceImpl,(0, g.setHandler)(this.impressionHandler),e.logger&&s.default.setLogger(e.logger),this.dynamicPropertyRuleHandler&&(0, _.setDynamicPropertyHandler)(this.dynamicPropertyRuleHandler);}fetchPeriodically(){if(!this.app_key)return s.default.warn("no app key"),Promise.reject();if(this.fetchIntervalInSec<=0)return Promise.resolve();this.fetchIntervalInSec<30&&(this.fetchIntervalInSec=30);const e=this._fetch({useCache:!1});return this.configurationFetcher.dispatchPeriodically({handler:this.onConfigurationFetched,periodTimeInSec:this.fetchIntervalInSec}),e}fetchCacheOnly(){return this._fetch({useCache:!0,skipNetwork:!0})}fetchWithCacheAndProceed(){return this._fetch({useCache:!0})}fetch(){return this._fetch({useCache:!1})}_fetchFromPush(){return this._fetch({useCache:!1,source:"push"})}sendState(){this._sendState();}_sendState(){this.sendStateDebounceNoCheck.cancel(),this.app_key&&(this.disableNetwork?s.default.debug("send state - disabled network"):this.stateSender&&this.stateSender.send());}_fetch(e={}){if(this.app_key){if(this.configurationFetcher)return this.disableNetwork&&(s.default.debug("fetch - disabling network"),e.skipNetwork=!0),this.configurationFetcher.dispatch({handler:this.onConfigurationFetched,options:e})}else s.default.warn("no app key");}register(e,t){void 0===t&&"object"==typeof e&&null!==e&&(t=e,e=""),s.default.debug(`Registering container '${e}' = ${JSON.stringify(t)}`),this.classRegisterer.handleContainer(e,t),this.sendStateDebounced();}setSemverCustomProperty(e,t){this.setCustomProperty(e,f.default.semverTypeName,t);}setCustomProperty(e,t,r){const n=new f.default(e,t,r),i=!a.default.has(n);a.default.set(n),i&&this.sendStateDebounced();}unfreeze(e,t){l.default.flags.filter(t=>{if(!t.name||"string"!=typeof e)return !0;const r=t.name.split(".");return 1===r.length&&""===e||r.slice(0,r.length-1).join(".")===e}).forEach(e=>{e.unfreeze(t);});}get metadata(){const e=new p.default;return {targetGroups:c.default.targetGroups.map(t=>({name:t.name,isEnabled:e.evaluateExpression(t.condition)})),experiments:u.default.experiments.map(t=>{return {name:t.name,isEnabled:(r=e.evaluateExpression(t.deploymentConfiguration.condition),"true"===r)};var r;}),flags:l.default.flags.map(e=>({name:e.name,value:e._peek()}))}}onConfigurationFetched(e){try{e.fetcherStatus!==S.FetcherStatus.ERROR_FETCH_FAILED&&this.startOrStopPushUpdatesListener();}catch(e){s.default.warn(`Cound not start or stop push notification listener. exception: ${e}`);}if(this.configurationFetchedHandler instanceof Function)try{return this.configurationFetchedHandler(e)}catch(e){y.default.invoke(y.ExceptionTrigger.CONFIGURATION_FETCHED_HANDLER,e);}}startOrStopPushUpdatesListener(){!this.disablePushUpdateListener&&(0, b.isEnabled)("rox.internal.pushUpdates")?this.app_key&&(this.pushUpdatesListener||(this.pushUpdatesListener=new v.default(h.default.get("NOTIFICATIONS_ENDPOINT"),this.app_key,this.eventSourceImpl,this.networkOptions),this.pushUpdatesListener.on("changed",()=>{this._fetchFromPush();}))):this.pushUpdatesListener&&(this.pushUpdatesListener.stop(),this.pushUpdatesListener=null);}setUserspaceUnhandledErrorHandler(e){y.default.setHandler(e);}get cacheURL(){if(!this.configurationFetcher||!this.configurationFetcher.cacheURL)throw new Error("Rox was not initialized. Please call setup() before calling cacheURL()");return this.configurationFetcher.cacheURL}}const A=new R;function C(e={}){return N=Object.assign({},N,e),A._dynamicApi=new d.default(e.EntitiesProvider,l.default,A),A}},(e,t,r)=>{r.r(t),r.d(t,{BugsnagReporter:()=>o});var n=r(3),i=r(21);class o{constructor(e,t,r,n){const i=t.getProperties(),{distinct_id:o,app_release:s,platform:a,api_version:u,lib_version:l}=i,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);}return r}(i,["distinct_id","app_release","platform","api_version","lib_version"]);this.device=c,this.header={apiKey:"abbf3bd9c6e80eb1e8c0566c35b08748",notifier:{name:"Rollout JavaScript SDK",version:l,url:"undefined"!=typeof window&&window.location&&window.location.href||void 0}},this.networkOptions=r,this.networkSender=n,this.user={distinct_id:o,app_release:s,app_key:e,platform:a},this.app={api_version:u,lib_version:l};}error(e,t){return this._notify("error",e,t)}_notify(e,t,r){const n={payloadVersion:4,exceptions:[],app:this.app,user:this.user,device:this.device,metaData:{data:{message:t,exception:r.toString()}},severity:e};return r instanceof Error?(n.exceptions.push({errorClass:r.name,message:t+"\n"+r.message,stacktrace:r.stack||""}),n.groupingHash=r.fileName):n.exceptions.push({errorClass:"Error",message:t,stacktrace:[]}),this._send([n])}_send(e){const t=Object.assign({events:e},this.header);n.default.debug("Sending bugsnag error report.");const r={url:"https://notify.bugsnag.com",data:t,options:this.networkOptions};i.default.getProxy().applyProxyToRequest(r);try{this.networkSender.post(r.url,r.data,r.options).then(()=>{n.default.debug("Successfully sent error report.");}).catch(e=>{n.default.debug("Failed to send error report",e);});}catch(e){n.default.debug("Failed to send error report.",e);}}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var n=r(42),i=r(45),o=r(23),s=r(2),a=r(34),u=r(21),l=r(8),c=r(6),d=r(7),h=r(3),f=r(47),p=r(48);const g=u.default.get("CLIENT_DATA_CACHE_KEY");let y=!1;const m=class{constructor(e,t,r,n,i,o,s,a){this.cache=n.RoxCache,this.crypto=n.RoxCrypto,this.embdeddedJSON=this.fetchFromEmbedded(i),this.appKey=e,this.deviceProperties=t,this.devModeSecret=r,this.options=o||{},this.networkOptions=s,this.networkSender=a,this.lastResponse=null;}runHandler(e,t){var r;if(t.errorDetails&&(null===(r=u.default.getErrorReporter())||void 0===r||r.error("Configuration fetcher returned with "+t.fetcherStatus,t.errorDetails)),e instanceof Function)try{e(t);}catch(e){}}dispatch({handler:e,options:t}){try{h.default.debug("dispatch();");const r=[];if(t.useCache){if(this.embdeddedJSON)if(this.verifyPayload(this.embdeddedJSON)){const e=this.parsePayload(this.embdeddedJSON);e&&r.push({payload:this.embdeddedJSON,parser:e,status:f.FetcherStatus.APPLIED_FROM_EMBEDDED});}else h.default.error("The embdeddedJSON was corrupted or its authenticity cannot be securely verified. skipping embedded");const e=this.fetchFromCache();if(e)if(this.verifyPayload(e)){const t=this.parsePayload(e);t&&r.push({payload:e,parser:t,status:f.FetcherStatus.APPLIED_FROM_CACHE});}else h.default.error("The cachedPayload was corrupted or its authenticity cannot be securely verified. skipping cache");}if(r.length>0){const t=r.reduce((e,t)=>e&&e.parser.signedDate()>t.parser.signedDate()?e:t,null);(!this.lastApplied||this.lastApplied.signedDate()<t.parser.signedDate())&&(this.lastResponse=t.payload,this.apply(t.parser,t.status,!1,e,t.payload));}if(t.skipNetwork)return;return this.shouldSkipFetch(t.source)?void h.default.debug("Skipping fetch - kill switch"):this._dispatch({handler:e,storeInCache:!0})}catch(e){h.default.error("Unexpected error in dispatch",e);}}shouldSkipFetch(e){const t="push"===e,r=(0, a.getNumber)("rox.internal.throttleFetchInSeconds");if(r>0&&(!t||(0, a.isEnabled)("rox.internal.considerThrottleInPush"))){const e=+Date.now();if(this.lastFetchTryTime&&e<this.lastFetchTryTime+1e3*r)return !0;this.lastFetchTryTime=e;}return !1}dispatchPeriodically({handler:e,periodTimeInSec:t}){if(y)return h.default.debug("Dispatch Periodically already running"),Promise.resolve();y=!0,h.default.debug("Dispatch Periodically"),setInterval(()=>{this._dispatch({handler:e});},1e3*t);}_dispatch({handler:e,storeInCache:t}){return this.fetchFromNetwork().then(r=>{const n=this.isNewResponse(r);return this.process(r,f.FetcherStatus.APPLIED_FROM_NETWORK,n,e).then(()=>{t&&this.storeInCache(r),this.lastResponse=r;})}).catch(t=>{this.runHandler(e,new f.FetcherResults(f.FetcherStatus.ERROR_FETCH_FAILED,null,!1,t));})}fetchFromNetwork(){h.default.debug(`fetch from network for appKey ${this.appKey}`);const e=(0, i.buildRequestConfiguration)({appKey:this.appKey,deviceProperties:this.deviceProperties,devModeSecret:this.devModeSecret});return this.rc=e,this.options.roxyUrl?(0, n.fetchRemoteConfigurationWithRoxy)(this.networkSender,e,this.options.roxyUrl,this.networkOptions):(0, n.fetchRemoteConfiguration)(this.networkSender,e,this.networkOptions,this.options)}fetchFromCache(){h.default.debug("fetch From Cache");let e,t=this.cache.get(this.cacheKey());if(t||(t=this.cache.get(g)),t){try{e=JSON.parse(t);}catch(e){h.default.warn(`Configuration retrieved from cache, but is corrupted. Aborting. (Error: ${e})`);}if(e&&e.constructor===Object)return h.default.debug(`Parsed cached = ${JSON.stringify(e)}`),e}}cacheKey(){return `${g}-${this.appKey}`}fetchFromEmbedded(e){let t;if(e){try{t=JSON.parse(e);}catch(e){h.default.warn("Received embdedded configuration, but it is corrupted. Aborting. Error: ",e);}if(t&&t.constructor===Object)return h.default.debug(`Parsed embedded = ${JSON.stringify(t)}`),t}if(p.default&&"object"==typeof p.default)return p.default}storeInCache(e){h.default.debug(`Store in cache response = ${JSON.stringify(e)}`),this.cache.set(this.cacheKey(),JSON.stringify(e));}process(e,t,r,n){if(!e)return Promise.reject("Empty configuration");if(!this.verifyPayload(e))return Promise.reject("The payload has corrupted or its authenticity cannot be securely verified.");const i=this.parsePayload(e);return i?this.apply(i,t,r,n,e):Promise.reject("Failed to parse configuration")}apply(e,t,r,n,i){if(e)return this.calculatePayload(e),this.lastApplied=e,new Promise(o=>{const s=new f.FetcherResults(t,e.signedDate(),r,void 0,i);this.runHandler(n,s),o();})}parsePayload(e){const t=!this.options.roxyUrl,r=new o.default(e,this.appKey,t);return r.parse()?r:(h.default.debug(`failed to parse payload. response = ${JSON.stringify(e)} deviceProps = ${this.deviceProperties} app_key = ${this.appKey}`),null)}verifyPayload(e){const{signature_v0:t,data:r}=e;return !!(this.options.roxyUrl||this.options.selfManagedMode||this.options.disableSignatureVerification)||this.crypto.verify(r,t)}calculatePayload(e){if(e)return l.default.setTargetGroups(e.targetGroups()),c.default.setExperiments(e.experiments()),new s.default(d.default,c.default).prepareFlagsWithExperiments(),e}isNewResponse(e){return JSON.stringify(this.lastResponse)!==JSON.stringify(e)}get cacheURL(){return this.rc&&this.rc.cache_url}};},(e,t,r)=>{r.r(t),r.d(t,{fetchRemoteConfiguration:()=>l,fetchRemoteConfigurationWithRoxy:()=>u});var n=r(43),i=r(44),o=r(3),s=r(21);function a(e){return e.catch(e=>{throw e.message="Unable to fetch rox configuration!\n"+e.message,o.default.error(e),e})}function u(e,t,r,o){const s=(0, n.buildAPIURL)(t,r);return a((0, i.fetchFromRoxyAPI)(e,s.url,o))}function l(e,t,r,o={}){const u=`${t.cache_url}?distinct_id=${t.distinct_id}&platform=${t.realPlatform}&lib_version=${t.lib_version}`;if(o.selfManagedMode&&!s.default.get("CD_S3_ENDPOINT")){const o=(0, n.buildAPIURL)(t);return a((0, i.fetchFromAPI)(e,o.url,o.body,r))}return a((0, i.fetchFromCDN)(e,u,r).catch(()=>{const o=(0, n.buildAPIURL)(t);return (0, i.fetchFromAPI)(e,o.url,o.body,r)}))}},(e,t,r)=>{r.r(t),r.d(t,{buildAPIURL:()=>i,buildSetStateAPIURL:()=>s,buildSetStateS3URL:()=>o});var n=r(21);const i=function(e,t=null){const{app_key:r,buid:i,relative_url:o}=e,s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);}return r}(e,["app_key","buid","relative_url"]);s.cache_miss_relative_url=o;const a=`${n.default.get("CD_API_ENDPOINT")}/${r}/${i}`;return {url:t||a,body:s}},o=function(e){return `${n.default.get("SS_S3_ENDPOINT")}${e.app_key}/${e.md5}`},s=function(e,t=null){return {url:t||`${n.default.get("SS_API_ENDPOINT")}${e.app_key}/${e.md5}`,body:{platform:e.platform,feature_flags:e.feature_flags,custom_properties:e.custom_properties,devModeSecret:e.devModeSecret}}};},(e,t,r)=>{r.r(t),r.d(t,{fetchFromAPI:()=>a,fetchFromCDN:()=>o,fetchFromRoxyAPI:()=>u,setStateToAPI:()=>c,stateFromCDN:()=>l});var n=r(3),i=r(21);function o(e,t,r){const o={url:t,options:r};return i.default.getProxy().applyProxyToRequest(o),e.get(o.url,o.options).then(({data:e,status:t})=>{if(200===t&&e&&"object"==typeof e){if(404===e.result){n.default.debug("succeed fetch from CDN, but it was missing");const e=new Error("missing from CDN");return e.missing=!0,Promise.reject(e)}return n.default.debug("succeed fetch from CDN"),e}}).catch(e=>{if(e.missing||e.response&&(404==e.response.status||403==e.response.status))return Promise.reject();n.default.debug(`Unexpected error calling get configuration, status code returned different from 403 or 404. error: ${e}`);})}function s(e){const{data:t,status:r}=e;return 200===r&&t&&"object"==typeof t?(n.default.debug("succeed fetch from API"),t):Promise.reject(new Error("Unexpected response from ROX API"))}function a(e,t,r,n){const o={url:t,data:r,options:n};return i.default.getProxy().applyProxyToRequest(o),e.post(o.url,o.data,o.options).then(s)}function u(e,t,r){const n={url:t,options:r};return i.default.getProxy().applyProxyToRequest(n),e.get(n.url,n.options).then(s)}function l(e,t,r){const o={url:t,options:r};return i.default.getProxy().applyProxyToRequest(o),e.get(o.url,o.options).then(({data:e,status:t})=>{if(200===t&&e&&"object"==typeof e){if(404===e.result){n.default.debug("succeed setState from CDN, but it was missing");const e=new Error("missing from CDN");return e.missing=!0,Promise.reject(e)}if(200===e.result)return void n.default.debug("succeed setState from CDN")}n.default.debug("succeed setState, but with unexpected response");}).catch(e=>{if(e.missing||e.response&&(404==e.response.status||403==e.response.status))return Promise.reject();n.default.debug(`Unexpected error calling setState, status code returned different from 403 or 404. error: ${e}`);})}function c(e,t,r,o){const s={url:t,data:r,options:o};return i.default.getProxy().applyProxyToRequest(s),e.post(s.url,s.data,s.options).then(({status:e})=>{if(200!==e)return Promise.reject(new Error("Unexpected response from ROX API"));n.default.debug("succeed setState from API");})}},(e,t,r)=>{r.r(t),r.d(t,{buildRequestConfiguration:()=>o});var n=r(21),i=r(46);const o=function({appKey:e,deviceProperties:t,devModeSecret:r}){const o=t.getProperties();return o.app_key=e,o.buid=i.generateBuid(o),o.buid_generators_list=i.BUID_GENERATOR_LIST.join(","),o.relative_url=`${e}/${o.buid}`,o.cache_url=`${n.default.get("CD_S3_ENDPOINT")}${o.relative_url}`,o.devModeSecret=r,o};},(e,t,r)=>{r.r(t),r.d(t,{BUID_GENERATOR_LIST:()=>o,STATE_GENERATOR_LIST:()=>s,generateBuid:()=>l,generateStateMd5:()=>u});var n=r(14),i=r.n(n);const o=["lib_version","api_version","platform","app_key","customSigningCertificate"],s=["platform","app_key","feature_flags","custom_properties","devModeSecret"];function a(e={},t=[]){const r=t.map(t=>{const r=e[t];return r?r.constructor===Object||r.constructor===Array?JSON.stringify(r):r:t});return i()(r.join("|"))}function u(e={},t=s){return a(e,t)}function l(e={},t=o){return a(e,t)}},(e,t,r)=>{r.r(t),r.d(t,{FetcherResults:()=>i,FetcherStatus:()=>n});const n={APPLIED_FROM_EMBEDDED:"APPLIED_FROM_EMBEDDED",APPLIED_FROM_CACHE:"APPLIED_FROM_CACHE",APPLIED_FROM_NETWORK:"APPLIED_FROM_NETWORK",ERROR_FETCH_FAILED:"ERROR_FETCH_FAILED"};class i{constructor(e,t,r,n,i){this.fetcherStatus=e,this.creationDate=t,this.hasChanges=r,this.errorDetails=n,this.clientData=i;}}},(e,t,r)=>{let n,i;r.r(t),r.d(t,{default:()=>o});try{i=$__ROX_EMBEDDED_CONTENT;}catch(e){}if(i&&"string"==typeof i)try{i=JSON.parse(i);}catch(e){i=void 0;}i&&i.constructor===Object&&i.signed_date&&(n=i);const o=n;},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(7),i=r(32);const o={flagsRepository:n.default};class s{constructor(e={}){this.options=Object.assign({},o,e),this._flagsRepository=this.options.flagsRepository,this._namespaceStore=new Set;}handleContainer(e,t){if("[object String]"!==Object.prototype.toString.call(e))throw new Error("InvalidNamespace: Namespace must be a string (non-nullable).");if(this._namespaceStore.has(e))throw new Error(`InvalidNamespace: A namespace must be unique. A container with the given namespace ('${e}') has already been registered.`);this._namespaceStore.add(e);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const n=e?`${e}.${r}`:r,o=t[r];o instanceof i.default&&this._flagsRepository.addFlag(n,o);}}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var n=r(32);class i{constructor(e,t,r){this.entityProvider=e,this.flagRepository=t,this.client=r;}genericValue(e,t,r,i,o=n.FlagTypes.string,s=this.entityProvider.createString,a=n.default._normalizeString){if("string"!=typeof e)throw new Error("DynamicApi error - name must be a string");if(typeof t!==o)throw new Error(`DynamicApi default value must be of ${o} type. Received '${t}'`);let u=this.flagRepository.flagWithName(e);u||(u=s(t,r),this.flagRepository.addFlag(e,u),this.client.sendStateDebounced());const l={alternativeDefaultValue:t.toString()};u.getInternalValue(l,i);const c=a(l.result.value);return l.result.isFreezed||l.result.isOverride||u._flagImpression(c.toString(),l.result.usedContext),c}isEnabled(e,t,r){return this.genericValue(e,t,null,r,n.FlagTypes.boolean,this.entityProvider.createFlag,n.default._normalizeBoolean)}value(e,t,r,n){return Array.isArray(r)||(n=r,r=null),this.genericValue(e,t,r,n)}getNumber(e,t,r,i){return Array.isArray(r)||(i=r,r=null),this.genericValue(e,t,r,i,n.FlagTypes.number,this.entityProvider.createNumber,n.default._normalizeNumber)}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(21);const i=e=>{setTimeout(e,5);},o=()=>{},s=class{constructor(e,t,r,i,o){if(t=t||{},this.queue=[],this.writeKey=e,this.host=t.host||n.default.get("ANALYTICS_ENDPOINT"),this.timeout=t.timeout||!1,this.flushAt=Math.max(t.flushAt||20,1),this.flushInterval=t.flushInterval||1e4,this.flushed=!1,this.version=r.getProperties().lib_version||"0.0",void 0===r.getProperties().platform)throw new Error("Platform must be provided");this.platform=r.getProperties().platform||"",this.networkOptions=i,this.networkSender=o,Object.defineProperty(this,"enable",{configurable:!1,writable:!1,enumerable:!0,value:"boolean"!=typeof t.enable||t.enable});}identify(e,t){return this.enqueue("identify",e,t),this}group(e,t){return this.enqueue("group",e,t),this}track(e,t){return this.enqueue("track",e,t),this}page(e,t){return this.enqueue("page",e,t),this}screen(e,t){return this.enqueue("screen",e,t),this}alias(e,t){return this.enqueue("alias",e,t),this}enqueue(e,t,r){return r=r||o,this.enable?(t=Object.assign({},t),this.queue.push({message:t,callback:r}),this.flushed?(this.queue.length>=this.flushAt&&this.flush(),void(this.flushInterval&&!this.timer&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval)))):(this.flushed=!0,void this.flush())):i(r)}flush(e){if(e=e||o,!this.enable)return i(e);if(this.timer&&(clearTimeout(this.timer),this.timer=null),!this.queue.length)return i(e);const t=this.queue.splice(0,this.flushAt),r=t.map(e=>e.callback),s=t.map(e=>e.message),a={analyticsVersion:"1.0.0",sdkVersion:this.version,time:(new Date).getTime(),platform:this.platform,rolloutKey:this.writeKey,events:s},u=t=>{r.forEach(e=>e(t)),e(t,a);},l=`${this.host}/impression/${this.writeKey}`,c={httpsAgent:this.networkOptions.httpsAgent,httpAgent:this.networkOptions.httpAgent};this.timeout&&(c.timeout=this.timeout);const d={url:l,data:a,options:c};n.default.getProxy().applyProxyToRequest(d),this.networkSender.post(d.url,d.data,d.options).then(()=>u()).catch(e=>{if(e.response){const t=new Error(e.response.statusText);return u(t)}u(e);});}};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(3),i=r(21);const o="object"==typeof window&&window.EventSource;class s{constructor(e,t,r,s){const a=`${e}${e.endsWith("/")?"":"/"}${t}`;n.default.info(`Starting push notification listener to ${a}`);const u={url:a,options:s};i.default.getProxy().applyProxyToSseRequest(u),r?this.eventSource=new r(u.url,u.options):o&&(this.eventSource=new o(u.url));}on(e,t){this.eventSource&&this.eventSource.addEventListener(e,e=>{try{t(e);}catch(e){}});}stop(){this.eventSource&&this.eventSource.close();}}},(e,t,r)=>{var n=r(54),i=r(55),o=r(58),s=Math.max,a=Math.min;e.exports=function(e,t,r){var u,l,c,d,h,f,p=0,g=!1,y=!1,m=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var r=u,n=l;return u=l=void 0,p=t,d=e.apply(n,r)}function b(e){var r=e-f;return void 0===f||r>=t||r<0||y&&e-p>=c}function _(){var e=i();if(b(e))return x(e);h=setTimeout(_,function(e){var r=t-(e-f);return y?a(r,c-(e-p)):r}(e));}function x(e){return h=void 0,m&&u?v(e):(u=l=void 0,d)}function P(){var e=i(),r=b(e);if(u=arguments,l=this,f=e,r){if(void 0===h)return function(e){return p=e,h=setTimeout(_,t),g?v(e):d}(f);if(y)return clearTimeout(h),h=setTimeout(_,t),v(f)}return void 0===h&&(h=setTimeout(_,t)),d}return t=o(t)||0,n(r)&&(g=!!r.leading,c=(y="maxWait"in r)?s(o(r.maxWait)||0,t):c,m="trailing"in r?!!r.trailing:m),P.cancel=function(){void 0!==h&&clearTimeout(h),p=0,u=f=l=h=void 0;},P.flush=function(){return void 0===h?d:x(i())},P};},e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};},(e,t,r)=>{var n=r(56);e.exports=function(){return n.Date.now()};},(e,t,r)=>{var n=r(57),i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")();e.exports=o;},e=>{var t="object"==typeof u&&u&&u.Object===Object&&u;e.exports=t;},(e,t,r)=>{var n=r(59),i=r(54),o=r(61),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return NaN;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t;}if("string"!=typeof e)return 0===e?e:+e;e=n(e);var r=a.test(e);return r||u.test(e)?l(e.slice(2),r?2:8):s.test(e)?NaN:+e};},(e,t,r)=>{var n=r(60),i=/^\s+/;e.exports=function(e){return e?e.slice(0,n(e)+1).replace(i,""):e};},e=>{var t=/\s/;e.exports=function(e){for(var r=e.length;r--&&t.test(e.charAt(r)););return r};},(e,t,r)=>{var n=r(62),i=r(66);e.exports=function(e){return "symbol"==typeof e||i(e)&&"[object Symbol]"==n(e)};},(e,t,r)=>{var n=r(63),i=r(64),o=r(65),s=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?i(e):o(e)};},(e,t,r)=>{var n=r(56).Symbol;e.exports=n;},(e,t,r)=>{var n=r(63),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),r=e[a];try{e[a]=void 0;var n=!0;}catch(e){}var i=s.call(e);return n&&(t?e[a]=r:delete e[a]),i};},e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)};},e=>{e.exports=function(e){return null!=e&&"object"==typeof e};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var n=r(68),i=r(46),o=r(3),s=r(69);const a=class{constructor(e,t,r,n,i,o,a){this.appKey=e,this.deviceProperties=t,this.devModeSecret=r,this.networkOptions=n,this.options=i,this.registry=new s.default(o),this.networkSender=a;}send(){o.default.debug(`check for cached state for appKey ${this.appKey}`);const e=this.buildSetState();try{(0,n.sendStateNetwork)(this.networkSender,e,this.networkOptions,this.options).catch(e=>{o.default.error("failed to send state (promise)",e);});}catch(e){o.default.error("failed to send state",e);}}sortItemsByName(e){return e.sort((e,t)=>e.name>t.name?-1:1)}buildSetState(){const e=this.deviceProperties.getProperties();return e.app_key=this.appKey,e.feature_flags=this.sortItemsByName(this.registry.featureFlags),e.custom_properties=this.sortItemsByName(this.registry.customProperties),e.devModeSecret=this.devModeSecret,e.md5=i.generateStateMd5(e),e}};},(e,t,r)=>{r.r(t),r.d(t,{sendStateNetwork:()=>a});var n=r(44),i=r(43),o=r(21);function s(e){return e.catch(e=>{throw e.message="Unable to send state!\n"+e.message,e})}function a(e,t,r,a={}){const u=(0, i.buildSetStateS3URL)(t);if(a.selfManagedMode&&!o.default.get("SS_S3_ENDPOINT")){const o=(0, i.buildSetStateAPIURL)(t);return s((0, n.setStateToAPI)(e,o.url,o.body,r))}return s((0, n.stateFromCDN)(e,u,r).catch(()=>{const o=(0, i.buildSetStateAPIURL)(t);return (0, n.setStateToAPI)(e,o.url,o.body,r)}))}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(7),i=r(5),o=r(30);class s{constructor(e=!1){this.includePlatformChanges=e;}get customProperties(){const e=[];return i.default.items.forEach(t=>{if(t.externalType!==o.default.dateTypeName||this.includePlatformChanges){const r={name:t.name,externalType:t.externalType};r.type=t.type,e.push(r);}}),e}get featureFlags(){const e=[];return n.default.items.forEach(t=>{const r={name:t.name,defaultValue:t.defaultValue,options:t._options};this.includePlatformChanges&&(r.externalType=t.externalType),e.push(r);}),e}}},(e,t,r)=>{r.r(t),r.d(t,{FetchNetwork:()=>i,HttpResponse:()=>n});class n{constructor(e,t,r){this.status=e,this.data=t,this.headers=r;}}class i{constructor(e){this.fetch=e;}get(e,t){const r=Object.assign({method:"GET"},t);return this.fetch(e,r).then(this.handleFetch)}post(e,t,r){const{headers:n}=r,i=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);}return r}(r,["headers"]),o=Object.assign({method:"POST",body:JSON.stringify(t),headers:Object.assign({"Content-Type":"application/json"},n)},i);return this.fetch(e,o).then(this.handleFetch)}handleFetch(e){if(!e.ok){const t=new Error("network returned non 2xx response");return t.response=e,Promise.reject(t)}const t=e.headers.get("content-type");return t&&t.includes("application/json")?e.json().then(t=>new n(e.status,t,e.headers)):e.text().then(t=>new n(e.status,t,e.headers))}}},(e,t,r)=>{r.r(t),r.d(t,{AxiosNetwork:()=>s});var n=r(72),i=r.n(n),o=r(70);class s{get(e,t){return i().get(e,t).then(e=>new o.HttpResponse(e.status,e.data,e.headers))}post(e,t,r){return i().post(e,t,r).then(e=>new o.HttpResponse(e.status,e.data,e.headers))}}},t=>{t.exports=e;}],r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]});},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});};var i={};return (()=>{n.r(i),n.d(i,{Client:()=>l.Client,Config:()=>c.default,ConfigurationParser:()=>p.default,Context:()=>s,DeviceProperties:()=>a.default,DynamicApi:()=>y.default,Entities:()=>o,Experiments:()=>f.default,Flags:()=>g.default,FlagsSetter:()=>h.default,Parsers:()=>r,Repositories:()=>t,RoxLogger:()=>u.default,Setters:()=>e,TargetGroups:()=>m.default,createRoxClient:()=>l.createRoxClient,flagValue:()=>d.flagValue});var e=n(1),t=n(4),r=n(9),o=n(29),s=n(35),a=n(38),u=n(3),l=n(39),c=n(21),d=n(13),h=n(2),f=n(6),p=n(23),g=n(7),y=n(50),m=n(8);})(),i})(),d.exports=c(e);var h=a({__proto__:null,default:l(d.exports)},[d.exports]);function f(e,t,r){return t=m(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,b()?Reflect.construct(t,r||[],m(e).constructor):t.apply(e,r))}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,x(n.key),n);}}function y(e,t,r){return t&&g(e.prototype,t),r&&g(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_(e,t);}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){}return (b=function(){return !!e})()}function _(e,t){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_(e,t)}function x(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}const P=[];for(let e=0;e<256;++e)P.push((e+256).toString(16).slice(1));let S;const E=new Uint8Array(16);var w={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function O(e,t,r){if(w.randomUUID&&!t&&!e)return w.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!S){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");S=crypto.getRandomValues.bind(crypto);}return S(E)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return (P[e[t+0]]+P[e[t+1]]+P[e[t+2]]+P[e[t+3]]+"-"+P[e[t+4]]+P[e[t+5]]+"-"+P[e[t+6]]+P[e[t+7]]+"-"+P[e[t+8]]+P[e[t+9]]+"-"+P[e[t+10]]+P[e[t+11]]+P[e[t+12]]+P[e[t+13]]+P[e[t+14]]+P[e[t+15]]).toLowerCase()}(n)}var N={api_version:"1.9.0",lib_version:"6.0.15"},R=new(function(){return y(function e(){p(this,e);},[{key:"set",value:function(){}},{key:"get",value:function(){}}])}()),{api_version:A,lib_version:C}=N,T=new(function(){function e(){return p(this,e),f(this,e,arguments)}return v(e,d.exports.DeviceProperties),y(e,[{key:"getNodeVersion",value:function(){return process&&process.versions&&process.versions.node}},{key:"getProperties",value:function(){var{distinct_id:e,app_release:t,platform:r,realPlatform:n}=this;return {app_release:t,api_version:A,lib_version:C,distinct_id:e,platform:r,realPlatform:n,platformVersion:this.getNodeVersion(),customSigningCertificate:"5659eb0ca47811395ef85f0b09be63b7",anticache:+Date.now()}}}])}())(R,O),I=t.parse,D=r,k=n,F=i,U=["pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","secureProtocol","servername","checkServerIdentity"],j=[239,187,191],L=262144,M=/^(cookie|authorization)$/i;function $(e,t){var r=$.CONNECTING,n=t&&t.headers,i=!1;Object.defineProperty(this,"readyState",{get:function(){return r}}),Object.defineProperty(this,"url",{get:function(){return e}});var o,s=this;function a(t){r!==$.CLOSED&&(r=$.CONNECTING,p("error",new H("error",{message:t})),h&&(e=h,h=null,i=!1),setTimeout(function(){r!==$.CONNECTING||s.connectionInProgress||(s.connectionInProgress=!0,f());},s.reconnectInterval));}s.reconnectInterval=1e3,s.connectionInProgress=!1;var u="";n&&n["Last-Event-ID"]&&(u=n["Last-Event-ID"],delete n["Last-Event-ID"]);var l=!1,c="",d="",h=null;function f(){var c=I(e),d="https:"===c.protocol;if(c.headers={"Cache-Control":"no-cache",Accept:"text/event-stream"},u&&(c.headers["Last-Event-ID"]=u),n){var y=i?function(e){var t={};for(var r in e)M.test(r)||(t[r]=e[r]);return t}(n):n;for(var m in y){var v=y[m];v&&(c.headers[m]=v);}}if(c.rejectUnauthorized=!(t&&!t.rejectUnauthorized),t&&void 0!==t.createConnection&&(c.createConnection=t.createConnection),t&&t.proxy){var b=I(t.proxy);d="https:"===b.protocol,c.protocol=d?"https:":"http:",c.path=e,c.headers.Host=c.host,c.hostname=b.hostname,c.host=b.host,c.port=b.port;}if(t&&t.https)for(var _ in t.https)if(-1!==U.indexOf(_)){var x=t.https[_];void 0!==x&&(c[_]=x);}t&&void 0!==t.withCredentials&&(c.withCredentials=t.withCredentials),o=(d?k:F).request(c,function(t){if(s.connectionInProgress=!1,500===t.statusCode||502===t.statusCode||503===t.statusCode||504===t.statusCode)return p("error",new H("error",{status:t.statusCode,message:t.statusMessage})),void a();if(301===t.statusCode||302===t.statusCode||307===t.statusCode){var n=t.headers.location;if(!n)return void p("error",new H("error",{status:t.statusCode,message:t.statusMessage}));var o=new URL(e).origin,u=new URL(n).origin;return i=o!==u,307===t.statusCode&&(h=e),e=n,void process.nextTick(f)}if(200!==t.statusCode)return p("error",new H("error",{status:t.statusCode,message:t.statusMessage})),s.close();var c,d;r=$.OPEN,t.on("close",function(){t.removeAllListeners("close"),t.removeAllListeners("end"),a();}),t.on("end",function(){t.removeAllListeners("close"),t.removeAllListeners("end"),a();}),p("open",new H("open"));var y=0,m=-1,v=0,b=0;t.on("data",function(e){c?(e.length>c.length-b&&((v=2*c.length+e.length)>L&&(v=c.length+e.length+L),d=Buffer.alloc(v),c.copy(d,0,0,b),c=d),e.copy(c,b),b+=e.length):(function(e){return j.every(function(t,r){return e[r]===t})}(c=e)&&(c=c.slice(j.length)),b=c.length);for(var t=0,r=b;t<r;){l&&(10===c[t]&&++t,l=!1);for(var n,i=-1,o=m,s=y;i<0&&s<r;++s)58===(n=c[s])?o<0&&(o=s-t):13===n?(l=!0,i=s-t):10===n&&(i=s-t);if(i<0){y=r-t,m=o;break}y=0,m=-1,g(c,t,o,i),t+=i+1;}t===r?(c=void 0,b=0):t>0&&(c=c.slice(t,b),b=c.length);});}),o.on("error",function(e){s.connectionInProgress=!1,a(e.message);}),o.setNoDelay&&o.setNoDelay(!0),o.end();}function p(){s.listeners(arguments[0]).length>0&&s.emit.apply(s,arguments);}function g(t,r,n,i){if(0===i){if(c.length>0){var o=d||"message";p(o,new V(o,{data:c.slice(0,-1),lastEventId:u,origin:new URL(e).origin})),c="";}d=void 0;}else if(n>0){var a=n<0,l=0,h=t.slice(r,r+(a?i:n)).toString();r+=l=a?i:32!==t[r+n+1]?n+1:n+2;var f=i-l,g=t.slice(r,r+f).toString();if("data"===h)c+=g+"\n";else if("event"===h)d=g;else if("id"===h)u=g;else if("retry"===h){var y=parseInt(g,10);Number.isNaN(y)||(s.reconnectInterval=y);}}}f(),this._close=function(){r!==$.CLOSED&&(r=$.CLOSED,o.abort&&o.abort(),o.xhr&&o.xhr.abort&&o.xhr.abort());};}var B=$;function H(e,t){if(Object.defineProperty(this,"type",{writable:!1,value:e,enumerable:!0}),t)for(var r in t)t.hasOwnProperty(r)&&Object.defineProperty(this,r,{writable:!1,value:t[r],enumerable:!0});}function V(e,t){for(var r in Object.defineProperty(this,"type",{writable:!1,value:e,enumerable:!0}),t)t.hasOwnProperty(r)&&Object.defineProperty(this,r,{writable:!1,value:t[r],enumerable:!0});}o.inherits($,D.EventEmitter),$.prototype.constructor=$,["open","error","message"].forEach(function(e){Object.defineProperty($.prototype,"on"+e,{get:function(){var t=this.listeners(e)[0];return t?t._listener?t._listener:t:void 0},set:function(t){this.removeAllListeners(e),this.addEventListener(e,t);}});}),Object.defineProperty($,"CONNECTING",{enumerable:!0,value:0}),Object.defineProperty($,"OPEN",{enumerable:!0,value:1}),Object.defineProperty($,"CLOSED",{enumerable:!0,value:2}),$.prototype.CONNECTING=0,$.prototype.OPEN=1,$.prototype.CLOSED=2,$.prototype.close=function(){this._close();},$.prototype.addEventListener=function(e,t){"function"==typeof t&&(t._listener=t,this.on(e,t));},$.prototype.dispatchEvent=function(e){if(!e.type)throw new Error("UNSPECIFIED_EVENT_TYPE_ERR");this.emit(e.type,e.detail);},$.prototype.removeEventListener=function(e,t){"function"==typeof t&&(t._listener=void 0,this.removeListener(e,t));};var z={distinctId:null,version:"0",configurationFetchedHandler:function(){},eventSourceImpl:B,impressionHandler:null,fetchIntervalInSec:60,devModeSecret:null,platform:"NodeJS"},{CustomProperty:K}=d.exports.Entities;function J(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,G(n.key),n);}}function G(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:t+""}var q=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);},r=[{key:"verify",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SHA256";e.constructor!==String&&(e=JSON.stringify(e));var n=s.createVerify(r);return n.update(e,"utf-8"),n.verify("-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEA6vBjERS8mkFQxHXB5WJuzZxqwKoSz9hP9u1ttck0Hop+6/BTk/+4\nydDy6XBi8P98w0+cMyCdzrRcuB1q3toZ+8JrfmyPm20v/ZCq5qpKYwI9fj8JweJY\nRGndu5aJTArs+abq6ottPZO6udSDHX6tPzrez/wZqfiwTbNheIzLD2MWVFGJFUwJ\nj6oJ8MblqCWWp/zhjY7Y/ThoPHjnDn3MsQuBg0f2GopfpIbeCPxx3rEl1bpKl57b\nG3YJ1yhZF+vNk7hT3N6XfJcvujejklqWzVfFJhFWcoJ8Vk978QU9k1rxXsW1udij\nhWPdcCJI7fiDxDDyQTzw4jfSdp7rbb3zKQIDAQAB\n-----END RSA PUBLIC KEY-----",t,"base64")}}],(t=null)&&J(e.prototype,t),r&&J(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r;}(),W="roxOverrideValues",Y=R.get(W);function Z(e){R.set(W,JSON.stringify(e));}function X(e,t){if(!e)throw new Error("Missing name");Y[e]=t,Z(Y);}function Q(e){if(!e)throw new Error("Missing name");Y[e]=void 0,delete Y[e],Z(Y);}function ee(){Z(Y={});}Y=Y?JSON.parse(Y):{};var te=Object.freeze({__proto__:null,hasOverride:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return void 0!==e&&void 0!==Y[e]},getOverride:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)throw new Error("Missing name");return Y[e]},setOverride:X,clearOverride:Q,clearAllOverrides:ee,getOriginalValue:function(e){if(!e)throw new Error("Missing name");var t=d.exports.Repositories.Flags.flagWithName(e);return t?t._originalValue():null}}),{FlagTypes:re,RoxStringBase:ne}=d.exports.Entities,{RoxxParser:ie}=d.exports.Parsers,oe=d.exports.Context,se=new ie,ae=function(){function e(t,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:re.string;return p(this,e),(n=f(this,e,[t,r,i]))._freezable=!1,n}return v(e,ne),y(e,[{key:"getActiveValue",value:function(e,t){var r=null!=e.alternativeDefaultValue?e.alternativeDefaultValue:this._defaultValue,n=t,i=!1;if(this.condition){var o=oe.Actions.getMergedContextWithGlobal(t);n=o;var s=se.evaluateExpression(this.condition,e,o),a=s&&s.toString?s.toString():s;void 0!==a&&(i=!0,r=a);}e.result={usedContext:n,value:r,isExperimenting:i};}},{key:"getInternalValue",value:function(e,t){var r=this.overridenValue;r?e.result={isExperimenting:!0,isOverride:!0,usedContext:t,value:r}:this.getActiveValue(e,t);}},{key:"getValue",value:function(e){var t={};return this.getInternalValue(t,e),t.result.isOverride||this._flagImpression(t.result.value,t.result.usedContext),t.result.value}},{key:"peek",value:function(e){var t={isPeek:!0};return this.getInternalValue(t,e),t.result.value}},{key:"overrider",get:function(){return te}}])}(),{FlagTypes:ue,RoxStringBase:le}=d.exports.Entities,ce=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return p(this,e),f(this,e,[t,[!1,!0],ue.boolean])}return v(e,ae),y(e,[{key:"isEnabled",value:function(e){var t={};this.getInternalValue(t,e);var r=le._normalizeBoolean(t.result.value);return t.result.isOverride||this._flagImpression(r.toString(),t.result.usedContext),r}}])}(),{FlagTypes:de,RoxStringBase:he}=d.exports.Entities,fe=function(){function e(t,r){return p(this,e),f(this,e,[t,r,de.number])}return v(e,ae),y(e,[{key:"getValue",value:function(e){var t={};this.getInternalValue(t,e);var r=he._normalizeNumber(t.result.value);return t.result.isOverride||this._flagImpression(r.toString(),t.result.usedContext),r}}])}(),pe=new(function(){return y(function e(){p(this,e);},[{key:"createFlag",value:function(e){return new ce(e)}},{key:"createString",value:function(e,t){return new ae(e,t)}},{key:"createNumber",value:function(e,t){return new fe(e,t)}}])}()),{createRoxClient:ge}=h,ye=ge({DeviceProperties:T,getDefaultCustomProperties:function(e,t){var r=e.distinct_id;e.distinctIdSetExplicitly||(r=t=>e.generateDistinctId());var n=e.getProperties();return [new K("rox.app_release",K.semverTypeName,n.app_release),new K("rox.platform",String,n.platform),new K("rox.distinct_id",String,r),new K("rox.internal.realPlatform",String,"NodeJS"),new K("rox.internal.customPlatform",String,n.platform),new K("rox.internal.appKey",String,t),new K("rox.internal.distinct_id",String,()=>O()),new K("rox.now",Date,()=>new Date)]},DefaultSetupOptions:z,RoxCache:R,RoxCrypto:q,EntitiesProvider:pe}),{RoxLogger:me,Config:ve,Repositories:be}=h,_e=new(function(){return y(function e(){p(this,e);},[{key:"setup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return me.setVerboseMode(t.debugLevel),t.proxy&&ve.setProxy(t.proxy),ye.setKey(e,t),t.configuration?ve.setActive(t.configuration):t.hosting&&ve.setHosting(t.hosting),ye.setup(t).then(()=>ye.disableNetwork?ye.fetchCacheOnly():(ye.sendState(),ye.fetchPeriodically()))}},{key:"setCustomStringProperty",value:function(e,t){ye.setCustomProperty(e,String,t);}},{key:"setCustomDateProperty",value:function(e,t){ye.setCustomProperty(e,Date,t);}},{key:"setCustomNumberProperty",value:function(e,t){ye.setCustomProperty(e,Number,t);}},{key:"setCustomBooleanProperty",value:function(e,t){ye.setCustomProperty(e,Boolean,t);}},{key:"setCustomSemverProperty",value:function(e,t){ye.setSemverCustomProperty(e,t);}},{key:"register",value:function(e,t){ye.register(e,t);}},{key:"fetch",value:function(){ye&&ye.fetch();}},{key:"flags",get:function(){return be.Flags.flags}},{key:"dynamicApi",get:function(){return ye.dynamicApi}},{key:"setUserspaceUnhandledErrorHandler",value:function(e){ye.setUserspaceUnhandledErrorHandler(e);}},{key:"cacheURL",get:function(){return ye.cacheURL}}])}()),xe="text/html; charset=utf-8",Pe="application/json",Se="GET",Ee="POST",we="DELETE",Oe="/api/flags",Ne=new RegExp("^".concat(Oe,"/?(.+)?")),Re=function(){return {body:d.exports.Repositories.Flags.flags.map(e=>e.dump()),type:Pe}},Ae="//connect.rollout.io/".concat("v0"),Ce=function(e){return e.url===Oe?function(e){return new Promise((t,r)=>{try{var n="";e.on("readable",()=>{var t=e.read();n=t?n+t:n;}),e.on("end",()=>t(n)),e.on("close",()=>t(""));}catch(e){r(e);}})}(e).then(e=>("string"==typeof e&&(e=JSON.parse(e)),e instanceof Array||(e=[e]),e.forEach(e=>{var{name:t,value:r}=e;t&&r&&X(t,r);}),Re())):Promise.resolve({code:404,body:""})},Te=function(e,t){var r=Promise.resolve({body:""}),{method:n,url:i}=e;switch(n){case Se:r=Promise.resolve(function(e){return e===Oe?Re():{body:'<!DOCTYPE html> <html lang="en"><head><meta charset="utf-8" /><title>ROXBoard</title><link rel="stylesheet" href="'.concat(Ae,'/styles.css" /><script>\nvar initialData = ').concat(JSON.stringify(Re().body),';\n<\/script>\n</head><body><div id="root"></div></body><script src="').concat(Ae,'/bundle.js"><\/script></html>'),type:xe}}(i));break;case Ee:r=Promise.resolve(Ce(e));break;case we:r=Promise.resolve(function(e){var t=e.url.match(Ne);return t?(t[1]?Q(t[1]):ee(),{body:""}):{code:404,body:""}}(e));}r.then(e=>{var{body:r,type:n,code:i}=e,o="string"==typeof r?r:JSON.stringify(r);t.writeHead(i||200,{"Content-Length":Buffer.byteLength(o||""),"Content-Type":n||"text/plain"}),t.write(o);}).catch(e=>{t.statusCode=500,console.error(e);}).then(()=>t.end());};_e.startAdminServer=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3e3,t=i.createServer(Te);return new Promise((r,n)=>{t.listen(e,e=>e?(console.error(e),n(e)):r(t));})},_e.setContext=d.exports.Context.Manager.setContext,_e.RoxString=ae,_e.RoxNumber=fe,_e.Flag=ce,_e.overrides=te;
/**
* Fetch the client data for the specified environment key.
* The feature flag configuration data for the 'Browser' platform will be returned (as well as the default platform) by
* default, but can be overridden by providing an alternate platform value when fetching.
* See https://docs.cloudbees.com/docs/cloudbees-feature-management/latest/feature-flags/multiplatform-feature-flags for
* more information on platforms.
*
* @param envKey the environment key. Visit 'App settings'->'Environments' in the Feature Management console for values.
* @param platform optional platform to fetch feature flag configuration for. If not specified, the default is 'Browser'.
* @return the client data
*/
var fetchClientData = function (envKey, platform, options) {
if (platform === void 0) { platform = 'Browser'; }
if (options === void 0) { options = {}; }
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
_e.setup(envKey, __assign(__assign({}, options), { platform: platform, configurationFetchedHandler: function (fetcherResult) {
if (fetcherResult.fetcherStatus === 'APPLIED_FROM_NETWORK' &&
fetcherResult.clientData.data) {
resolve(JSON.stringify(fetcherResult.clientData));
}
else {
reject("something went wrong see ".concat(fetcherResult.fetcherStatus));
}
} }));
})];
});
});
};
export { fetchClientData };