vwo-fme-node-sdk
Version:
VWO Node/JavaScript SDK for Feature Management and Experimentation
25 lines • 193 kB
JavaScript
/*!
* vwo-fme-javascript-sdk - v1.21.0
* URL - https://github.com/wingify/vwo-node-sdk
*
* Copyright 2024-2025 Wingify Software Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Dependencies used -
* 1. murmurhash - ^2.0.1
* 2. superstruct - ^0.14.x
* 3. uuid - ^9.0.1
* 4. vwo-fme-sdk-log-messages - ^1.*.*
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vwoSdk=t():e.vwoSdk=t()}(this,(()=>(()=>{var e={11:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendGetCall=function(e){return i(r.HttpMethodEnum.GET,e)},t.sendPostCall=function(e){return i(r.HttpMethodEnum.POST,e)};var r=n(8202),o=n(8667);function i(e,t){var n="".concat(t.scheme,"://").concat(t.hostname).concat(t.path);return new Promise((function(i,a){e===r.HttpMethodEnum.POST&&(t.body=JSON.stringify(t.body)),fetch(n,t).then((function(t){return t.text().then((function(n){var s={};try{s=e===r.HttpMethodEnum.GET?JSON.parse(n):n}catch(e){console.info("VWO-SDK - [INFO]: ".concat((0,o.getCurrentTime)()," VWO didn't send JSON response which is expected: ").concat(e))}if(200===t.status)i(s);else{var u="";e===r.HttpMethodEnum.GET?u="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," Request failed for fetching account settings. Got Status Code: ").concat(t.status):e===r.HttpMethodEnum.POST&&(u="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," Request failed while making a POST request. Got Status Code: ").concat(t.status)),console.error(u),a(u)}}))})).catch((function(t){var n="";e===r.HttpMethodEnum.GET?n="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," GET request failed for fetching account settings. Error: ").concat(t):e===r.HttpMethodEnum.POST&&(n="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," POST request failed while sending data. Error: ").concat(t)),console.error(n),a(n)}))}))}},162:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.createAndSendImpressionForVariationShown=void 0;var i=n(8925),a=n(9693),s=n(4140);t.createAndSendImpressionForVariationShown=function(e,t,n,u){return r(void 0,void 0,void 0,(function(){var r,c;return o(this,(function(o){switch(o.label){case 0:return r=(0,i.getEventsBaseProperties)(a.EventEnum.VWO_VARIATION_SHOWN,encodeURIComponent(u.getUserAgent()),u.getIpAddress()),c=(0,i.getTrackUserPayloadData)(e,u.getId(),a.EventEnum.VWO_VARIATION_SHOWN,t,n,u.getUserAgent(),u.getIpAddress()),s.BatchEventsQueue.Instance?(s.BatchEventsQueue.Instance.enqueue(c),[3,3]):[3,1];case 1:return[4,(0,i.sendPostApiRequest)(r,c,u.getId())];case 2:o.sent(),o.label=3;case 3:return[2]}}))}))}},324:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RuleModel=void 0;var n=function(){function e(){}return e.prototype.modelFromDictionary=function(e){return this.type=e.type,this.status=e.status,this.variationId=e.variationId,this.campaignId=e.campaignId,this.ruleKey=e.ruleKey,this},e.prototype.getCampaignId=function(){return this.campaignId},e.prototype.getVariationId=function(){return this.variationId},e.prototype.getStatus=function(){return this.status},e.prototype.getType=function(){return this.type},e.prototype.getRuleKey=function(){return this.ruleKey},e}();t.RuleModel=n},362:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsAndAddCampaignsToRules=function(e,t){t.settings=new r.SettingsModel(e),t.originalSettings=e;var n=t.settings.getCampaigns();n.forEach((function(e,t){(0,o.setVariationAllocation)(e),n[t]=e})),(0,i.addLinkedCampaignsToSettings)(t.settings),(0,a.addIsGatewayServiceRequiredFlag)(t.settings)};var r=n(6130),o=n(9181),i=n(8667),a=n(2898)},415:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestHandler=void 0;var n=function(){function e(){}return e.prototype.createRequest=function(e,t){if(!(null!==t.getBaseUrl()&&void 0!==t.getBaseUrl()||null!==e.getUrl()&&void 0!==e.getUrl()))return null;e.setUrl(e.getUrl()||t.getBaseUrl()),e.setTimeout(e.getTimeout()||t.getTimeout()),e.setBody(e.getBody()||t.getBody()),e.setHeaders(e.getHeaders()||t.getHeaders());var n=e.getQuery()||{},r=t.getQuery()||{};for(var o in r)Object.prototype.hasOwnProperty.call(n,o)||(n[o]=r[o]);return e.setQuery(n),e},e}();t.RequestHandler=n},470:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsService=void 0;var a=n(9401),s=n(4580),u=n(6710),c=n(4782),l=n(5399),g=n(2346),p=n(8202),d=n(7128),f=n(9846),h=n(8754),v=n(8925),y=function(){function e(t){var n,r,o,i,a;if(this.isGatewayServiceProvided=!1,this.sdkKey=t.sdkKey,this.accountId=t.accountId,this.expiry=(null===(n=null==t?void 0:t.settings)||void 0===n?void 0:n.expiry)||l.Constants.SETTINGS_EXPIRY,this.networkTimeout=(null===(r=null==t?void 0:t.settings)||void 0===r?void 0:r.timeout)||l.Constants.SETTINGS_TIMEOUT,"undefined"!=typeof XMLHttpRequest&&(this.isGatewayServiceProvided=!0),null===(o=null==t?void 0:t.gatewayService)||void 0===o?void 0:o.url){var u=void 0;this.isGatewayServiceProvided=!0,u=t.gatewayService.url.startsWith(g.HTTP_PROTOCOL)||t.gatewayService.url.startsWith(g.HTTPS_PROTOCOL)?new URL("".concat(t.gatewayService.url)):(null===(i=t.gatewayService)||void 0===i?void 0:i.protocol)?new URL("".concat(t.gatewayService.protocol,"://").concat(t.gatewayService.url)):new URL("".concat(g.HTTPS_PROTOCOL).concat(t.gatewayService.url)),this.hostname=u.hostname,this.protocol=u.protocol.replace(":",""),u.port?this.port=parseInt(u.port):(null===(a=t.gatewayService)||void 0===a?void 0:a.port)&&(this.port=t.gatewayService.port)}else this.hostname=l.Constants.HOST_NAME;s.LogManager.Instance.debug((0,h.buildMessage)(d.DebugLogMessagesEnum.SERVICE_INITIALIZED,{service:"Settings Manager"})),e.instance=this}return Object.defineProperty(e,"Instance",{get:function(){return e.instance},enumerable:!1,configurable:!0}),e.prototype.setSettingsExpiry=function(){var e=this,t=setTimeout((function(){e.fetchSettingsAndCacheInStorage().then((function(){clearTimeout(t),e.setSettingsExpiry()}))}),this.expiry)},e.prototype.normalizeSettings=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){return(t=r({},e)).features&&0!==Object.keys(t.features).length||(t.features=[]),t.campaigns&&0!==Object.keys(t.campaigns).length||(t.campaigns=[]),[2,t]}))}))},e.prototype.handleBrowserEnvironment=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),[4,e.getSettingsFromStorage(this.sdkKey,this.accountId)];case 1:return(n=i.sent())?(s.LogManager.Instance.info((0,h.buildMessage)(d.InfoLogMessagesEnum.SETTINGS_FETCH_FROM_CACHE)),t.resolve(n)):s.LogManager.Instance.info((0,h.buildMessage)(d.InfoLogMessagesEnum.SETTINGS_CACHE_MISS)),[4,this.fetchSettings()];case 2:return r=i.sent(),[4,this.normalizeSettings(r)];case 3:return o=i.sent(),(new f.SettingsSchema).isSettingsValid(o)?[4,e.setSettingsInStorage(o)]:[3,5];case 4:i.sent(),i.label=5;case 5:return n?s.LogManager.Instance.info((0,h.buildMessage)(d.InfoLogMessagesEnum.SETTINGS_BACKGROUND_UPDATE)):(s.LogManager.Instance.info((0,h.buildMessage)(d.InfoLogMessagesEnum.SETTINGS_FETCH_SUCCESS)),t.resolve(o)),[3,7];case 6:return a=i.sent(),s.LogManager.Instance.error((0,h.buildMessage)(d.ErrorLogMessagesEnum.SETTINGS_FETCH_ERROR,{err:JSON.stringify(a)})),t.resolve(null),[3,7];case 7:return[2]}}))}))},e.prototype.handleServerEnvironment=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.fetchSettings()];case 1:return t=o.sent(),[4,this.normalizeSettings(t)];case 2:return n=o.sent(),e.resolve(n),[3,4];case 3:return r=o.sent(),s.LogManager.Instance.error((0,h.buildMessage)(d.ErrorLogMessagesEnum.SETTINGS_FETCH_ERROR,{err:JSON.stringify(r)})),e.resolve(null),[3,4];case 4:return[2]}}))}))},e.prototype.fetchSettingsAndCacheInStorage=function(){var e=new c.Deferred,t=a.Storage.Instance.getConnector();return"undefined"!=typeof XMLHttpRequest?this.handleBrowserEnvironment(t,e):this.handleServerEnvironment(e),e.promise},e.prototype.fetchSettings=function(e){void 0===e&&(e=!1);var t=new c.Deferred;this.sdkKey&&this.accountId||t.reject(new Error("sdkKey is required for fetching account settings. Aborting!"));var n=u.NetworkManager.Instance,r=(0,v.getSettingsPath)(this.sdkKey,this.accountId),o=n.getRetryConfig();r.platform=l.Constants.PLATFORM,r["api-version"]=l.Constants.API_VERSION,n.getConfig().getDevelopmentMode()||(r.s="prod");var i=l.Constants.SETTINTS_ENDPOINT;e&&(i=l.Constants.WEBHOOK_SETTINTS_ENDPOINT);try{var a=new u.RequestModel(this.hostname,p.HttpMethodEnum.GET,i,r,null,null,this.protocol,this.port,o);return a.setTimeout(this.networkTimeout),n.get(a).then((function(e){t.resolve(e.getData())})).catch((function(e){t.reject(e)})),t.promise}catch(e){return s.LogManager.Instance.error((0,h.buildMessage)(d.ErrorLogMessagesEnum.SETTINGS_FETCH_ERROR,{err:JSON.stringify(e)})),t.reject(e),t.promise}},e.prototype.getSettings=function(e){void 0===e&&(e=!1);var t=new c.Deferred;return e?this.fetchSettingsAndCacheInStorage().then((function(e){t.resolve(e)})):this.fetchSettingsAndCacheInStorage().then((function(e){(new f.SettingsSchema).isSettingsValid(e)?(s.LogManager.Instance.info(d.InfoLogMessagesEnum.SETTINGS_FETCH_SUCCESS),t.resolve(e)):(s.LogManager.Instance.error(d.ErrorLogMessagesEnum.SETTINGS_SCHEMA_INVALID),t.resolve({}))})),t.promise},e}();t.SettingsService=y},502:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VariableModel=void 0;var n=function(){function e(e,t,n,r){this.value=r,this.type=t,this.key=n,this.id=e}return e.modelFromDictionary=function(t){var n,r,o;return new e(null!==(n=t.i)&&void 0!==n?n:t.id,t.type,null!==(r=t.k)&&void 0!==r?r:t.key,null!==(o=t.val)&&void 0!==o?o:t.value)},e.prototype.setValue=function(e){this.value=e},e.prototype.setKey=function(e){this.key=e},e.prototype.setType=function(e){this.type=e},e.prototype.getId=function(){return this.id},e.prototype.getValue=function(){return this.value},e.prototype.getType=function(){return this.type},e.prototype.getKey=function(){return this.key},e}();t.VariableModel=n},805:e=>{"use strict";e.exports=JSON.parse('{"API_CALLED":"API - {apiName} called","SERVICE_INITIALIZED":"VWO {service} initialized while creating an instance of SDK","EXPERIMENTS_EVALUATION_WHEN_ROLLOUT_PASSED":"Rollout rule got passed for user {userId}. Hence, evaluating experiments","EXPERIMENTS_EVALUATION_WHEN_NO_ROLLOUT_PRESENT":"No Rollout rules present for the feature. Hence, checking experiment rules","USER_BUCKET_TO_VARIATION":"User ID:{userId} for experiment:{campaignKey} having percent traffic:{percentTraffic} got bucket-value:{bucketValue} and hash-value:{hashValue}","IMPRESSION_FOR_TRACK_USER":"Impression built for vwo_variationShown(VWO standard event for tracking user) event haivng Account ID:{accountId}, User ID:{userId}, and experiment ID:{campaignId}","IMPRESSION_FOR_TRACK_GOAL":"Impression built for event:{eventName} event having Account ID:{accountId}, and user ID:{userId}","IMPRESSION_FOR_SYNC_VISITOR_PROP":"Impression built for {eventName}(VWO internal event) event for Account ID:{accountId}, and user ID:{userId}","CONFIG_BATCH_EVENT_LIMIT_EXCEEDED":"Impression event - {endPoint} failed due to exceeding payload size. Parameter eventsPerRequest in batchEvents config in launch API has value:{eventsPerRequest} for account ID:{accountId}. Please read the official documentation for knowing the size limits","EVENT_BATCH_BEFORE_FLUSHING":"Flushing event queue {manually} having {length} events for Account ID:{accountId}. {timer}","EVENT_BATCH_FLUSH":"Manually flushing batch events for Account ID:{accountId} having {queueLength} events","BATCH_QUEUE_EMPTY":"Batch queue is empty. Nothing to flush."}')},973:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CampaignDecisionService=void 0;var i=n(6775),a=n(4580),s=n(4986),u=n(5399),c=n(4273),l=n(7128),g=n(1359),p=n(8754),d=function(){function e(){}return e.prototype.isUserPartOfCampaign=function(e,t){if(!t||!e)return!1;var n=t.getType()===c.CampaignTypeEnum.ROLLOUT||t.getType()===c.CampaignTypeEnum.PERSONALIZE,r=n?t.getVariations()[0].getSalt():t.getSalt(),o=n?t.getVariations()[0].getWeight():t.getTraffic(),s=r?"".concat(r,"_").concat(e):"".concat(t.getId(),"_").concat(e),u=(new i.DecisionMaker).getBucketValueForUser(s),g=0!==u&&u<=o;return a.LogManager.Instance.info((0,p.buildMessage)(l.InfoLogMessagesEnum.USER_PART_OF_CAMPAIGN,{userId:e,notPart:g?"":"not",campaignKey:t.getType()===c.CampaignTypeEnum.AB?t.getKey():t.getName()+"_"+t.getRuleKey()})),g},e.prototype.getVariation=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(t>=r.getStartRangeVariation()&&t<=r.getEndRangeVariation())return r}return null},e.prototype.checkInRange=function(e,t){if(t>=e.getStartRangeVariation()&&t<=e.getEndRangeVariation())return e},e.prototype.bucketUserToVariation=function(e,t,n){var r;if(!n||!e)return null;n.getTraffic()&&(r=1);var o=n.getTraffic(),s=n.getSalt(),c=s?"".concat(s,"_").concat(t,"_").concat(e):"".concat(n.getId(),"_").concat(t,"_").concat(e),g=(new i.DecisionMaker).generateHashValue(c),d=(new i.DecisionMaker).generateBucketValue(g,u.Constants.MAX_TRAFFIC_VALUE,r);return a.LogManager.Instance.debug((0,p.buildMessage)(l.DebugLogMessagesEnum.USER_BUCKET_TO_VARIATION,{userId:e,campaignKey:n.getKey(),percentTraffic:o,bucketValue:d,hashValue:g})),this.getVariation(n.getVariations(),d)},e.prototype.getPreSegmentationDecision=function(e,t){return r(this,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return n=e.getType(),r={},n===c.CampaignTypeEnum.ROLLOUT||n===c.CampaignTypeEnum.PERSONALIZE?r=e.getVariations()[0].getSegments():n===c.CampaignTypeEnum.AB&&(r=e.getSegments()),!(0,g.isObject)(r)||Object.keys(r).length?[3,1]:(a.LogManager.Instance.info((0,p.buildMessage)(l.InfoLogMessagesEnum.SEGMENTATION_SKIP,{userId:t.getId(),campaignKey:e.getType()===c.CampaignTypeEnum.AB?e.getKey():e.getName()+"_"+e.getRuleKey()})),[2,!0]);case 1:return[4,s.SegmentationManager.Instance.validateSegmentation(r,t.getCustomVariables())];case 2:return o.sent()?(a.LogManager.Instance.info((0,p.buildMessage)(l.InfoLogMessagesEnum.SEGMENTATION_STATUS,{userId:t.getId(),campaignKey:e.getType()===c.CampaignTypeEnum.AB?e.getKey():e.getName()+"_"+e.getRuleKey(),status:"passed"})),[2,!0]):(a.LogManager.Instance.info((0,p.buildMessage)(l.InfoLogMessagesEnum.SEGMENTATION_STATUS,{userId:t.getId(),campaignKey:e.getType()===c.CampaignTypeEnum.AB?e.getKey():e.getName()+"_"+e.getRuleKey(),status:"failed"})),[2,!1])}}))}))},e.prototype.getVariationAlloted=function(e,t,n){var r=this.isUserPartOfCampaign(e,n);return n.getType()===c.CampaignTypeEnum.ROLLOUT||n.getType()===c.CampaignTypeEnum.PERSONALIZE?r?n.getVariations()[0]:null:r?this.bucketUserToVariation(e,t,n):null},e}();t.CampaignDecisionService=d},977:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.TrackApi=void 0;var i=n(4237),a=n(7128),s=n(4580),u=n(8667),c=n(8754),l=n(4140),g=n(8925),p=function(){function e(){}return e.prototype.track=function(e,t,n,l,p){return r(this,void 0,void 0,(function(){var r,f;return o(this,(function(o){switch(o.label){case 0:return(0,u.doesEventBelongToAnyFeature)(t,e)?(0,g.getShouldWaitForTrackingCalls)()?[4,d(e,t,n,l)]:[3,2]:[3,4];case 1:return o.sent(),[3,3];case 2:d(e,t,n,l),o.label=3;case 3:return p.set({eventName:t,api:i.ApiEnum.TRACK_EVENT}),p.execute(p.get()),[2,(r={},r[t]=!0,r)];case 4:return s.LogManager.Instance.error((0,c.buildMessage)(a.ErrorLogMessagesEnum.EVENT_NOT_FOUND,{eventName:t})),[2,(f={},f[t]=!1,f)]}}))}))},e}();t.TrackApi=p;var d=function(e,t,n,i){return r(void 0,void 0,void 0,(function(){var r,a;return o(this,(function(o){switch(o.label){case 0:return r=(0,g.getEventsBaseProperties)(t,encodeURIComponent(n.getUserAgent()),n.getIpAddress()),a=(0,g.getTrackGoalPayloadData)(e,n.getId(),t,i,null==n?void 0:n.getUserAgent(),null==n?void 0:n.getIpAddress()),l.BatchEventsQueue.Instance?(l.BatchEventsQueue.Instance.enqueue(a),[3,3]):[3,1];case 1:return[4,(0,g.sendPostApiRequest)(r,a,n.getId())];case 2:o.sent(),o.label=3;case 3:return[2]}}))}))}},1172:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.StorageEnum=void 0,function(e){e[e.STORAGE_UNDEFINED=0]="STORAGE_UNDEFINED",e[e.INCORRECT_DATA=1]="INCORRECT_DATA",e[e.NO_DATA_FOUND=2]="NO_DATA_FOUND",e[e.CAMPAIGN_PAUSED=3]="CAMPAIGN_PAUSED",e[e.VARIATION_NOT_FOUND=4]="VARIATION_NOT_FOUND",e[e.WHITELISTED_VARIATION=5]="WHITELISTED_VARIATION"}(n||(t.StorageEnum=n={}))},1198:e=>{"use strict";e.exports=JSON.parse('{"INIT_OPTIONS_ERROR":"[ERROR]: VWO-SDK {date} Options should be of type object","INIT_OPTIONS_SDK_KEY_ERROR":"[ERROR]: VWO-SDK {date} Please provide the sdkKey in the options and should be a of type string","INIT_OPTIONS_ACCOUNT_ID_ERROR":"[ERROR]: VWO-SDK {date} Please provide VWO account ID in the options and should be a of type string|number","INIT_OPTIONS_INVALID":"Invalid key:{key} passed in options. Should be of type:{correctType} and greater than equal to 1000","SETTINGS_FETCH_ERROR":"Settings could not be fetched. Error:{err}","SETTINGS_SCHEMA_INVALID":"Settings are not valid. Failed schema validation","POLLING_FETCH_SETTINGS_FAILED":"Error while fetching VWO settings with polling","API_THROW_ERROR":"API - {apiName} failed to execute. Trace:{err}","API_INVALID_PARAM":"Key:{key} passed to API:{apiName} is not of valid type. Got type:{type}, should be:{correctType}","API_SETTING_INVALID":"Settings are not valid. Contact VWO Support","API_CONTEXT_INVALID":"Context should be an object and must contain a mandatory key - id, which is User ID","FEATURE_NOT_FOUND":"Feature not found for the key:{featureKey}","EVENT_NOT_FOUND":"Event:{eventName} not found in any of the features\' metrics","STORED_DATA_ERROR":"Error in getting data from storage. Error:{err}","STORING_DATA_ERROR":"Key:{featureKey} is not valid. Not able to store data into storage","GATEWAY_URL_ERROR":"Please provide a valid URL for VWO Gateway Service while initializing the SDK","NETWORK_CALL_FAILED":"Error occurred while sending {method} request. Error:{err}","SETTINGS_FETCH_FAILED":"Failed to fetch settings and hence VWO client instance couldn\'t be updated when API: {apiName} got called having isViaWebhook param as {isViaWebhook}. Error: {err}","NETWORK_CALL_RETRY_ATTEMPT":"Request failed for {endPoint}, Error: {err}. Retrying in {delay} seconds, attempt {attempt} of {maxRetries}","NETWORK_CALL_RETRY_FAILED":"Max retries reached. Request failed for {endPoint}, Error: {err}","CONFIG_PARAMETER_INVALID":"{parameter} paased in {api} API is not correct. It should be of type:{type}}","BATCH_QUEUE_EMPTY":"No batch queue present for account:{accountId} when calling flushEvents API. Check batchEvents config in launch API","RETRY_CONFIG_INVALID":"Retry config is invalid. Please check the vwo documentation for more details. Using retry config: {retryConfig}"}')},1263:(e,t,n)=>{"use strict";t.w=void 0;var r=n(11),o=n(4782),i=n(5573),a=function(){function e(){}return e.prototype.GET=function(e){var t=new o.Deferred,n=e.getOptions(),a=new i.ResponseModel;return(0,r.sendGetCall)(n).then((function(e){a.setData(e),t.resolve(a)})).catch((function(e){a.setError(e),t.reject(a)})),t.promise},e.prototype.POST=function(e){var t=new o.Deferred,n=e.getOptions(),a=new i.ResponseModel;return(0,r.sendPostCall)(n).then((function(e){a.setData(e),t.resolve(a)})).catch((function(e){a.setError(e),t.reject(a)})),t.promise},e}();t.w=a},1274:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserStorageConnector=void 0;var a=n(5399),s=n(4782),u=n(4580),c=n(470),l=n(9846),g=n(1359),p=function(){function e(e){this.SETTINGS_KEY=a.Constants.DEFAULT_SETTINGS_STORAGE_KEY,this.storageKey=(null==e?void 0:e.key)||a.Constants.DEFAULT_LOCAL_STORAGE_KEY,this.storage=(null==e?void 0:e.provider)||window.localStorage,this.isDisabled=(null==e?void 0:e.isDisabled)||!1,this.alwaysUseCachedSettings=(null==e?void 0:e.alwaysUseCachedSettings)||!1,!(0,g.isNumber)(null==e?void 0:e.ttl)||e.ttl<a.Constants.MIN_TTL_MS?(u.LogManager.Instance.debug("TTL is not passed or invalid (less than 1 minute), using default value of 2 hours"),this.ttl=a.Constants.SETTINGS_TTL):this.ttl=(null==e?void 0:e.ttl)||a.Constants.SETTINGS_TTL,(0,g.isBoolean)(null==e?void 0:e.alwaysUseCachedSettings)?this.alwaysUseCachedSettings=(null==e?void 0:e.alwaysUseCachedSettings)||!1:(u.LogManager.Instance.debug("AlwaysUseCachedSettings is not passed or invalid, using default value of false"),this.alwaysUseCachedSettings=!1)}return e.prototype.getStoredData=function(){if(this.isDisabled)return{};try{var e=this.storage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return u.LogManager.Instance.error("Error reading from storage: ".concat(e)),{}}},e.prototype.storeData=function(e){if(!this.isDisabled)try{var t=JSON.stringify(e);this.storage.setItem(this.storageKey,t)}catch(e){u.LogManager.Instance.error("Error writing to storage: ".concat(e))}},e.prototype.set=function(e){var t=new s.Deferred;if(this.isDisabled)t.resolve();else try{var n=this.getStoredData(),r="".concat(e.featureKey,"_").concat(e.userId);n[r]=e,this.storeData(n),u.LogManager.Instance.info("Stored data in storage for key: ".concat(r)),t.resolve()}catch(e){u.LogManager.Instance.error("Error storing data: ".concat(e)),t.reject(e)}return t.promise},e.prototype.get=function(e,t){var n,r=new s.Deferred;if(this.isDisabled)r.resolve({});else try{var o=this.getStoredData(),i="".concat(e,"_").concat(t),a=null!==(n=o[i])&&void 0!==n?n:{};u.LogManager.Instance.info("Retrieved data from storage for key: ".concat(i)),r.resolve(a)}catch(e){u.LogManager.Instance.error("Error retrieving data: ".concat(e)),r.resolve({})}return r.promise},e.prototype.getSettingsFromStorage=function(e,t){var n,r=new s.Deferred;if(this.isDisabled)r.resolve(null);else try{var o=this.getStoredData()[this.SETTINGS_KEY];if(!o)return r.resolve(null),r.promise;var i=o.data,a=o.timestamp,c=Date.now();if(i&&i.sdkKey)try{i.sdkKey=atob(i.sdkKey)}catch(e){u.LogManager.Instance.error("Failed to decode sdkKey from storage")}if(!i||i.sdkKey!==e||String(null!==(n=i.accountId)&&void 0!==n?n:i.a)!==String(t))return u.LogManager.Instance.info("Cached settings do not match sdkKey/accountId, treating as cache miss"),r.resolve(null),r.promise;if(this.alwaysUseCachedSettings)return u.LogManager.Instance.info("Using cached settings as alwaysUseCachedSettings is enabled"),r.resolve(i),r.promise;if(c-a>this.ttl)u.LogManager.Instance.info("Settings have expired, need to fetch new settings"),r.resolve(null);else{if(u.LogManager.Instance.info("Retrieved valid settings from storage"),this.setFreshSettingsInStorage(),i&&i.sdkKey)try{i.sdkKey=atob(i.sdkKey)}catch(e){u.LogManager.Instance.error("Failed to decode sdkKey from storage")}r.resolve(i)}}catch(e){u.LogManager.Instance.error("Error retrieving settings: ".concat(e)),r.resolve(null)}return r.promise},e.prototype.setFreshSettingsInStorage=function(){var e=this,t=c.SettingsService.Instance;t&&t.fetchSettings().then((function(t){return o(e,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return t&&(new l.SettingsSchema).isSettingsValid(t)?[4,this.setSettingsInStorage(t)]:[3,2];case 1:e.sent(),u.LogManager.Instance.info("Settings updated with fresh data from server"),e.label=2;case 2:return[2]}}))}))})).catch((function(e){u.LogManager.Instance.error("Error fetching fresh settings: ".concat(e))}))},e.prototype.setSettingsInStorage=function(e){var t=new s.Deferred;if(this.isDisabled)t.resolve();else try{var n=this.getStoredData(),o=r({},e);o.sdkKey&&(o.sdkKey=btoa(o.sdkKey)),n[this.SETTINGS_KEY]={data:o,timestamp:Date.now()},this.storeData(n),u.LogManager.Instance.info("Settings stored successfully in storage"),t.resolve()}catch(e){u.LogManager.Instance.error("Error storing settings: ".concat(e)),t.reject(e)}return t.promise},e}();t.BrowserStorageConnector=p},1359:(e,t)=>{"use strict";function n(e){return"[object Object]"===Object.prototype.toString.call(e)}function r(e){return"[object Array]"===Object.prototype.toString.call(e)}function o(e){return"[object Null]"===Object.prototype.toString.call(e)}function i(e){return"[object Undefined]"===Object.prototype.toString.call(e)}function a(e){return"[object Number]"===Object.prototype.toString.call(e)}function s(e){return"[object String]"===Object.prototype.toString.call(e)}function u(e){return"[object Boolean]"===Object.prototype.toString.call(e)}function c(e){return"[object Function]"===Object.prototype.toString.call(e)}function l(e){return"[object Promise]"===Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=n,t.isArray=r,t.isNull=o,t.isUndefined=i,t.isNumber=a,t.isString=s,t.isBoolean=u,t.isFunction=c,t.isPromise=l,t.getType=function(e){return n(e)?"Object":r(e)?"Array":o(e)?"Null":i(e)?"Undefined":a(e)?"Number":s(e)?"String":u(e)?"Boolean":c(e)?"Function":l(e)?"Promise":"Unknown Type"}},1522:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.VWOClient=void 0;var i=n(4580),a=n(6612),s=n(8164),u=n(977),c=n(7128),l=n(4140),g=n(9846),p=n(9752),d=n(7675),f=n(8694),h=n(1359),v=n(8754),y=n(4782),m=n(362),E=n(2365),I=n(8925),b=n(470),_=n(4237),S=function(){function e(e,t){return this.options=t,(0,m.setSettingsAndAddCampaignsToRules)(e,this),f.UrlUtil.init({collectionPrefix:this.settings.getCollectionPrefix()}),(0,I.setShouldWaitForTrackingCalls)(this.options.shouldWaitForTrackingCalls||!1),i.LogManager.Instance.info(c.InfoLogMessagesEnum.CLIENT_INITIALIZED),this.vwoClientInstance=this,this}return e.prototype.getFlag=function(e,t){var n=_.ApiEnum.GET_FLAG,r=new y.Deferred,o=new a.Flag(!1,new E.VariationModel);try{var s=new d.default(this.options);if(i.LogManager.Instance.debug((0,v.buildMessage)(c.DebugLogMessagesEnum.API_CALLED,{apiName:n})),!(0,h.isString)(e))throw i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_INVALID_PARAM,{apiName:n,key:"featureKey",type:(0,h.getType)(e),correctType:"string"})),new TypeError("TypeError: featureKey should be a string");if(!(new g.SettingsSchema).isSettingsValid(this.originalSettings))throw i.LogManager.Instance.error(c.ErrorLogMessagesEnum.API_SETTING_INVALID),new Error("TypeError: Invalid Settings");if(!t||!t.id)throw i.LogManager.Instance.error(c.ErrorLogMessagesEnum.API_CONTEXT_INVALID),new TypeError("TypeError: Invalid context");var u=(new p.ContextModel).modelFromDictionary(t);a.FlagApi.get(e,this.settings,u,s).then((function(e){r.resolve(e)})).catch((function(){r.resolve(o)}))}catch(e){i.LogManager.Instance.info((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_THROW_ERROR,{apiName:n,err:e})),r.resolve(o)}return r.promise},e.prototype.trackEvent=function(e,t,n){var r;void 0===n&&(n={});var o=_.ApiEnum.TRACK_EVENT,a=new y.Deferred;try{var s=new d.default(this.options);if(i.LogManager.Instance.debug((0,v.buildMessage)(c.DebugLogMessagesEnum.API_CALLED,{apiName:o})),!(0,h.isString)(e))throw i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_INVALID_PARAM,{apiName:o,key:"eventName",type:(0,h.getType)(e),correctType:"string"})),new TypeError("TypeError: Event-name should be a string");if(!(0,h.isObject)(n))throw i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_INVALID_PARAM,{apiName:o,key:"eventProperties",type:(0,h.getType)(n),correctType:"object"})),new TypeError("TypeError: eventProperties should be an object");if(!(new g.SettingsSchema).isSettingsValid(this.originalSettings))throw i.LogManager.Instance.error(c.ErrorLogMessagesEnum.API_SETTING_INVALID),new Error("TypeError: Invalid Settings");if(!t||!t.id)throw i.LogManager.Instance.error(c.ErrorLogMessagesEnum.API_CONTEXT_INVALID),new TypeError("TypeError: Invalid context");var l=(new p.ContextModel).modelFromDictionary(t);(new u.TrackApi).track(this.settings,e,l,n,s).then((function(e){a.resolve(e)})).catch((function(){var t;a.resolve(((t={})[e]=!1,t))}))}catch(t){i.LogManager.Instance.info((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_THROW_ERROR,{apiName:o,err:t})),a.resolve(((r={})[e]=!1,r))}return a.promise},e.prototype.setAttribute=function(e,t,n){return r(this,void 0,void 0,(function(){var r,a,u,l,g,d,f,y;return o(this,(function(o){switch(o.label){case 0:r=_.ApiEnum.SET_ATTRIBUTE,o.label=1;case 1:if(o.trys.push([1,6,,7]),!(0,h.isObject)(e))return[3,3];if(i.LogManager.Instance.debug((0,v.buildMessage)(c.DebugLogMessagesEnum.API_CALLED,{apiName:r})),Object.entries(e).length<1)throw i.LogManager.Instance.error((0,v.buildMessage)("Attributes map must contain atleast 1 key-value pair",{apiName:r,key:"attributes",type:(0,h.getType)(e),correctType:"object"})),new TypeError("TypeError: Attributes should be an object containing atleast 1 key-value pair");if(a=e,!(0,h.isObject)(a))throw new TypeError("TypeError: attributes should be an object containing key-value pairs");return Object.entries(a).forEach((function(e){var t=e[0],n=e[1];if("boolean"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_INVALID_PARAM,{apiName:r,key:t,type:(0,h.getType)(n),correctType:" boolean, string or number"})),new TypeError('Invalid attribute type for key "'.concat(t,'". Expected boolean, string or number, but got ').concat((0,h.getType)(n)));if(Array.isArray(n)||"object"==typeof n&&null!==n)throw i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_INVALID_PARAM,{apiName:r,key:t,type:(0,h.getType)(n),correctType:" boolean | string | number | null"})),new TypeError('Invalid attribute value for key "'.concat(t,'". Arrays and objects are not supported.'))})),!n&&t&&(n=t),n&&n.id||i.LogManager.Instance.error(c.ErrorLogMessagesEnum.API_CONTEXT_INVALID),g=(new p.ContextModel).modelFromDictionary(n),[4,(new s.SetAttributeApi).setAttribute(this.settings,a,g)];case 2:return o.sent(),[3,5];case 3:if(u=e,l=t,!(0,h.isString)(u))throw new TypeError("attributeKey should be a string");if(!(0,h.isBoolean)(l)&&!(0,h.isString)(l)&&!(0,h.isNumber)(l))throw new TypeError("attributeValue should be a boolean, string, or number");if(!n||!n.id)throw new TypeError("Invalid context");return g=(new p.ContextModel).modelFromDictionary(n),(y={})[u]=l,d=y,[4,(new s.SetAttributeApi).setAttribute(this.settings,d,g)];case 4:o.sent(),o.label=5;case 5:return[3,7];case 6:return f=o.sent(),i.LogManager.Instance.info((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_THROW_ERROR,{apiName:r,err:f})),[3,7];case 7:return[2]}}))}))},e.prototype.updateSettings=function(e){return r(this,arguments,void 0,(function(e,t){var n,r,a,s;return void 0===t&&(t=!0),o(this,(function(o){switch(o.label){case 0:n=_.ApiEnum.UPDATE_SETTINGS,o.label=1;case 1:return o.trys.push([1,5,,6]),i.LogManager.Instance.debug((0,v.buildMessage)(c.DebugLogMessagesEnum.API_CALLED,{apiName:n})),e&&0!==Object.keys(e).length?[3,3]:[4,b.SettingsService.Instance.fetchSettings(t)];case 2:return a=o.sent(),[3,4];case 3:a=e,o.label=4;case 4:if(r=a,!(new g.SettingsSchema).isSettingsValid(r))throw new Error("TypeError: Invalid Settings schema");return(0,m.setSettingsAndAddCampaignsToRules)(r,this.vwoClientInstance),i.LogManager.Instance.info((0,v.buildMessage)(c.InfoLogMessagesEnum.SETTINGS_UPDATED,{apiName:n,isViaWebhook:t})),[3,6];case 5:return s=o.sent(),i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.SETTINGS_FETCH_FAILED,{apiName:n,isViaWebhook:t,err:JSON.stringify(s)})),[3,6];case 6:return[2]}}))}))},e.prototype.flushEvents=function(){var e=_.ApiEnum.FLUSH_EVENTS,t=new y.Deferred;try{if(i.LogManager.Instance.debug((0,v.buildMessage)(c.DebugLogMessagesEnum.API_CALLED,{apiName:e})),l.BatchEventsQueue.Instance)return l.BatchEventsQueue.Instance.flushAndClearTimer();i.LogManager.Instance.error("Batching is not enabled. Pass batchEventData in the SDK configuration while invoking init API."),t.resolve({status:"error",events:[]})}catch(n){i.LogManager.Instance.error((0,v.buildMessage)(c.ErrorLogMessagesEnum.API_THROW_ERROR,{apiName:e,err:n})),t.resolve({status:"error",events:[]})}return t.promise},e}();t.VWOClient=S},1703:(e,t,n)=>{"use strict";t.o=void 0;var r=n(3890),o=n(4782),i=n(5573),a=function(){function e(){}return e.prototype.GET=function(e){var t=new o.Deferred,n=e.getOptions(),a=new i.ResponseModel;return(0,r.sendGetCall)({networkOptions:n,successCallback:function(e){a.setData(e),t.resolve(a)},errorCallback:function(e){a.setError(e),t.reject(a)}}),t.promise},e.prototype.POST=function(e){var t=new o.Deferred,n=e.getOptions(),a=new i.ResponseModel;return(0,r.sendPostCall)({networkOptions:n,successCallback:function(e){a.setStatusCode(200),a.setData(e),t.resolve(a)},errorCallback:function(e){a.setStatusCode(400),a.setError(e),t.reject(a)}}),t.promise},e}();t.o=a},1720:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRandomUUID=function(e){var t=(0,i.v5)(e,i.v5.DNS);return(0,i.v5)((0,o.v4)(),t)},t.getUUID=function(e,t){var n=(0,i.v5)(r.SEED_URL,i.v5.URL);e=String(e);var o=a(t=String(t),n),s=a(e,o);return null==s?void 0:s.replace(/-/gi,"").toUpperCase()},t.generateUUID=a;var r=n(2346),o=n(2831),i=n(2831);function a(e,t){if(e&&t)return(0,i.v5)(e,t)}},1880:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextVWOModel=void 0;var n=function(){function e(){}return e.prototype.modelFromDictionary=function(e){return(null==e?void 0:e.location)&&(this.location=e.location),(null==e?void 0:e.userAgent)&&(this.userAgent=e.userAgent),this},e.prototype.getLocation=function(){return this.location},e.prototype.getUaInfo=function(){return this.userAgent},e}();t.ContextVWOModel=n},2144:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CampaignModel=void 0;var r=n(9094),o=n(502),i=n(2365),a=function(){function e(){this.variations=[],this.metrics=[],this.variables=[]}return e.prototype.copy=function(e){this.metrics=e.metrics,this.variations=e.variations,this.variables=e.variables,this.processCampaignKeys(e)},e.prototype.modelFromDictionary=function(e){return this.processCampaignProperties(e),this.processCampaignKeys(e),this},e.prototype.processCampaignProperties=function(e){var t=this;e.variables&&(e.variables.constructor==={}.constructor?this.variables=[]:e.variables.forEach((function(e){t.variables.push(o.VariableModel.modelFromDictionary(e))}))),e.variations&&(e.variations.constructor==={}.constructor?this.variations=[]:e.variations.forEach((function(e){t.variations.push((new i.VariationModel).modelFromDictionary(e))}))),e.metrics&&(e.metrics&&e.metrics.constructor==={}.constructor?this.metrics=[]:(e.metrics||[]).forEach((function(e){t.metrics.push((new r.MetricModel).modelFromDictionary(e))})))},e.prototype.processCampaignKeys=function(e){this.id=e.id,this.percentTraffic=e.percentTraffic,this.name=e.name,this.variationId=e.variationId,this.campaignId=e.campaignId,this.ruleKey=e.ruleKey,this.isForcedVariationEnabled=e.isForcedVariationEnabled,this.isUserListEnabled=e.isUserListEnabled,this.segments=e.segments,this.key=e.key,this.type=e.type,this.salt=e.salt},e.prototype.getId=function(){return this.id},e.prototype.getName=function(){return this.name},e.prototype.getSegments=function(){return this.segments},e.prototype.getTraffic=function(){return this.percentTraffic},e.prototype.getType=function(){return this.type},e.prototype.getIsForcedVariationEnabled=function(){return this.isForcedVariationEnabled},e.prototype.getIsUserListEnabled=function(){return this.isUserListEnabled},e.prototype.getKey=function(){return this.key},e.prototype.getMetrics=function(){return this.metrics},e.prototype.getVariations=function(){return this.variations},e.prototype.getVariables=function(){return this.variables},e.prototype.getRuleKey=function(){return this.ruleKey},e.prototype.getSalt=function(){return this.salt},e}();t.CampaignModel=a},2245:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateTrafficAndGetVariation=t.checkWhitelistingAndPreSeg=void 0;var i=n(1359),a=n(4273),s=n(9217),u=n(7128),c=n(6775),l=n(4580),g=n(4986),p=n(973),d=n(1359),f=n(5399),h=n(9181),v=n(8667),y=n(8754),m=n(7928),E=n(1720),I=n(3780);t.checkWhitelistingAndPreSeg=function(e,t,n,i,s,c,g,d){return r(void 0,void 0,void 0,(function(){var r,v,_,S,T,O,A,M;return o(this,(function(o){switch(o.label){case 0:return r=(0,E.getUUID)(i.getId(),e.getAccountId()),v=n.getId(),n.getType()!==a.CampaignTypeEnum.AB?[3,3]:(i.setVariationTargetingVariables(Object.assign({},i.getVariationTargetingVariables(),{_vwoUserId:n.getIsUserListEnabled()?r:i.getId()})),Object.assign(d,{variationTargetingVariables:i.getVariationTargetingVariables()}),n.getIsForcedVariationEnabled()?[4,b(n,i)]:[3,2]);case 1:return(_=o.sent())&&Object.keys(_).length>0?[2,[!0,_]]:[3,3];case 2:l.LogManager.Instance.info((0,y.buildMessage)(u.InfoLogMessagesEnum.WHITELISTING_SKIP,{campaignKey:n.getRuleKey(),userId:i.getId()})),o.label=3;case 3:if(i.setCustomVariables(Object.assign({},i.getCustomVariables(),{_vwoUserId:n.getIsUserListEnabled()?r:i.getId()})),Object.assign(d,{customVariables:i.getCustomVariables()}),S=(0,h.getGroupDetailsIfCampaignPartOfIt)(e,n.getId(),n.getType()===a.CampaignTypeEnum.PERSONALIZE?n.getVariations()[0].getId():null).groupId,!(T=null==c?void 0:c.get(S)))return[3,4];if(n.getType()===a.CampaignTypeEnum.AB){if(T===v)return[2,[!0,null]]}else if(n.getType()===a.CampaignTypeEnum.PERSONALIZE&&T===v+"_"+n.getVariations()[0].getId())return[2,[!0,null]];return[2,[!1,null]];case 4:return S?[4,(new I.StorageDecorator).getFeatureFromStorage("".concat(f.Constants.VWO_META_MEG_KEY).concat(S),i,g)]:[3,6];case 5:if((O=o.sent())&&O.experimentKey&&O.experimentId)return l.LogManager.Instance.info((0,y.buildMessage)(u.InfoLogMessagesEnum.MEG_CAMPAIGN_FOUND_IN_STORAGE,{campaignKey:O.experimentKey,userId:i.getId()})),O.experimentId===v?n.getType()===a.CampaignTypeEnum.PERSONALIZE?O.experimentVariationId===n.getVariations()[0].getId()?[2,[!0,null]]:(c.set(S,O.experimentId+"_"+O.experimentVariationId),[2,[!1,null]]):[2,[!0,null]]:(-1!=O.experimentVariationId?c.set(S,O.experimentId+"_"+O.experimentVariationId):c.set(S,O.experimentId),[2,[!1,null]]);o.label=6;case 6:return[4,(new p.CampaignDecisionService).getPreSe