@eventvisor/sdk 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/dist/modulesManager.d.ts +2 -1
- package/lib/modulesManager.d.ts +2 -1
- package/package.json +3 -3
- package/src/instance.ts +2 -2
- package/src/modulesManager.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.5.0](https://github.com/eventvisor/eventvisor/compare/v0.4.0...v0.5.0) (2025-10-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* pass full error object to transports ([#7](https://github.com/eventvisor/eventvisor/issues/7)) ([e9f74f4](https://github.com/eventvisor/eventvisor/commit/e9f74f453411395608b82f33087f89094080199a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [0.4.0](https://github.com/eventvisor/eventvisor/compare/v0.3.0...v0.4.0) (2025-10-02)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @eventvisor/sdk
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [0.3.0](https://github.com/eventvisor/eventvisor/compare/v0.2.1...v0.3.0) (2025-10-01)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @eventvisor/sdk
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EventvisorSDK=t():e.EventvisorSDK=t()}(this,()=>(()=>{"use strict";var e={40:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]);var r=this.listeners[e];r.push(t);var n=!0;return function(){if(n){n=!1;var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.trigger=function(e,t){void 0===t&&(t={});var r=this.listeners[e];r&&r.forEach(function(e){try{e(t)}catch(e){console.error(e)}})},e.prototype.clearAll=function(){this.listeners={}},e}();t.Emitter=r},53:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};function i(e){return r(this,void 0,Promise,function(){var t,r,i,a,o,s,u;return n(this,function(n){switch(n.label){case 0:t=e.persists,r=e.entityName,i=e.conditionsChecker,a=e.payload,o=0,s=t,n.label=1;case 1:return o<s.length?(u=s[o]).conditions?[4,i.allAreMatched(u.conditions,{attributeName:r,effectName:r,payload:a})]:[2,u]:[3,4];case 2:if(n.sent())return[2,u];n.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}Object.defineProperty(t,"__esModule",{value:!0}),t.findPersist=i,t.initializeFromStorage=function(e){return r(this,arguments,Promise,function(e){var t,r,a,o,s,u,c,l,f,h=e.datafileReader,p=e.conditionsChecker,d=e.modulesManager,g=e.storageKeyPrefix,v=e.getEntityNames,y=e.getEntity;return n(this,function(e){switch(e.label){case 0:t=v(),r={},a=0,o=t,e.label=1;case 1:return a<o.length?(s=o[a],(u=y(s))&&(c=h.getPersists(u))?[4,i({persists:c,entityName:s,conditionsChecker:p,payload:{}})]:[3,4]):[3,5];case 2:return(l=e.sent())?[4,d.readFromStorage(l.storage,"".concat(g).concat(s))]:[3,4];case 3:null!=(f=e.sent())&&(r[s]=f),e.label=4;case 4:return a++,[3,1];case 5:return[2,r]}})})},t.persistEntity=function(e){return r(this,arguments,void 0,function(e){var t,r,a=e.datafileReader,o=e.conditionsChecker,s=e.modulesManager,u=e.storageKeyPrefix,c=e.entityName,l=e.entity,f=e.value;return n(this,function(e){switch(e.label){case 0:return l&&(t=a.getPersists(l))?[4,i({persists:t,entityName:c,conditionsChecker:o,payload:f})]:[2];case 1:return(r=e.sent())?[4,s.writeToStorage(r.storage,"".concat(u).concat(c),f)]:[2];case 2:return e.sent(),[2]}})})},t.removeEntity=function(e){return r(this,arguments,void 0,function(e){var t,r,a=e.datafileReader,o=e.conditionsChecker,s=e.modulesManager,u=e.storageKeyPrefix,c=e.entityName,l=e.entity;return n(this,function(e){switch(e.label){case 0:return l&&(t=a.getPersists(l))?[4,i({persists:t,entityName:c,conditionsChecker:o,payload:{}})]:[2];case 1:return(r=e.sent())?[4,s.removeFromStorage(r.storage,"".concat(u).concat(c))]:[2];case 2:return e.sent(),[2]}})})}},108:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.compareVersions=t.compareSegments=t.validateAndParse=t.semver=void 0,t.semver=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,t.validateAndParse=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");var r=e.match(t.semver);if(!r)throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"));return r.shift(),r};var r=function(e){return"*"===e||"x"===e||"X"===e},n=function(e){var t=parseInt(e,10);return isNaN(t)?e:t},i=function(e,t){if(r(e)||r(t))return 0;var i=function(e,t){return typeof e!=typeof t?[String(e),String(t)]:[e,t]}(n(e),n(t)),a=i[0],o=i[1];return a>o?1:a<o?-1:0};t.compareSegments=function(e,t){for(var r=0;r<Math.max(e.length,t.length);r++){var n=i(e[r]||"0",t[r]||"0");if(0!==n)return n}return 0},t.compareVersions=function(e,r){var n=(0,t.validateAndParse)(e),i=(0,t.validateAndParse)(r),a=n.pop(),o=i.pop(),s=(0,t.compareSegments)(n,i);return 0!==s?s:a&&o?(0,t.compareSegments)(a.split("."),o.split(".")):a||o?a?-1:1:0}},127:function(e,t){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function o(e,t){return t.reduce(function(e,t){return e[t]},e)}Object.defineProperty(t,"__esModule",{value:!0}),t.SourceResolver=void 0;var s=function(){function e(e){var t=e.logger,r=e.modulesManager,n=e.attributesManager,i=e.effectsManager;this.logger=t,this.modulesManager=r,this.attributesManager=n,this.effectsManager=i}return e.prototype.getPath=function(e){var t=e.split(".");return{name:t[0],path:t.slice(1),fullKey:e}},e.prototype.getOrigin=function(e){var t=this;if("string"==typeof e){var n=e.split(".");return{originType:n[0],name:n[1],path:n.slice(2),fullKey:e}}return"source"in e||"source"in e?this.getOrigin(e.source):"attribute"in e?r({originType:"attribute"},this.getPath(e.attribute)):"effect"in e?r({originType:"effect"},this.getPath(e.effect)):"payload"in e?Array.isArray(e.payload)?e.payload.map(function(e){return r({originType:"payload"},t.getPath(e))}):r({originType:"payload"},this.getPath(e.payload)):"lookup"in e?r({originType:"lookup"},this.getPath(e.lookup)):"state"in e?r({originType:"state"},this.getPath(e.state)):null},e.prototype.resolveByOrigin=function(e){return n(this,arguments,Promise,function(e,t){var r;return void 0===t&&(t={}),i(this,function(n){return null===e?[2,null]:"attributes"===e.originType?(r=e.name?this.attributesManager.getAttributeValue(e.name):this.attributesManager.getAttributesMap(),e.path.length>0?[2,o(r,e.path)]:[2,r]):"attribute"===e.originType?(r=this.attributesManager.getAttributeValue(e.name),e.path.length>0?[2,o(r,e.path)]:[2,r]):"effects"===e.originType?(r=e.name?this.effectsManager.getStateValue(e.name):this.effectsManager.getAllStates(),e.path.length>0?[2,o(r,e.path)]:[2,r]):"effect"===e.originType?(r=this.effectsManager.getStateValue(e.name),e.path.length>0?[2,o(r,e.path)]:[2,r]):"lookup"===e.originType?[2,this.modulesManager.lookup(e.fullKey)]:void 0!==t[e.originType]?[2,o(t[e.originType],a([e.name],e.path,!0).filter(Boolean))]:[2,null]})})},e.prototype.resolve=function(e){return n(this,arguments,Promise,function(e,t){var r,n=this;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return r=this.getOrigin(e),Array.isArray(r)?[2,Promise.all(r.map(function(e){return n.resolveByOrigin(e,t)}))]:[4,this.resolveByOrigin(r,t)];case 1:return[2,i.sent()]}})})},e}();t.SourceResolver=s},166:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(247),t),i(r(470),t),i(r(649),t),i(r(40),t),i(r(584),t),i(r(357),t),i(r(481),t),i(r(127),t),i(r(420),t),i(r(681),t),i(r(400),t),i(r(108),t)},186:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.ConditionsChecker=void 0;var a=r(108),o=function(){function e(e){this.getRegex=e.getRegex,this.sourceResolver=e.sourceResolver,this.logger=e.logger}return e.prototype.isMatched=function(e,t){return n(this,void 0,Promise,function(){var r,n,o,s,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=e.operator,n=e.value,o=e.regexFlags,[4,this.sourceResolver.resolve(e,t)];case 1:if(s=i.sent(),"equals"===r)return[2,s===n];if("notEquals"===r)return[2,s!==n];if("before"===r||"after"===r)return u=(l=s)instanceof Date?l:new Date(l),c=n instanceof Date?n:new Date(n),[2,"before"===r?u<c:u>c];if(!Array.isArray(n)||-1===["string","number"].indexOf(typeof s)&&null!==s)if("string"==typeof s&&"string"==typeof n){if(l=s,"contains"===r)return[2,-1!==l.indexOf(n)];if("notContains"===r)return[2,-1===l.indexOf(n)];if("startsWith"===r)return[2,l.startsWith(n)];if("endsWith"===r)return[2,l.endsWith(n)];if("semverEquals"===r)return[2,0===(0,a.compareVersions)(l,n)];if("semverNotEquals"===r)return[2,0!==(0,a.compareVersions)(l,n)];if("semverGreaterThan"===r)return[2,1===(0,a.compareVersions)(l,n)];if("semverGreaterThanOrEquals"===r)return[2,(0,a.compareVersions)(l,n)>=0];if("semverLessThan"===r)return[2,-1===(0,a.compareVersions)(l,n)];if("semverLessThanOrEquals"===r)return[2,(0,a.compareVersions)(l,n)<=0];if("matches"===r)return[2,this.getRegex(n,o||"").test(l)];if("notMatches"===r)return[2,!this.getRegex(n,o||"").test(l)]}else if("number"==typeof s&&"number"==typeof n){if(l=s,"greaterThan"===r)return[2,l>n];if("greaterThanOrEquals"===r)return[2,l>=n];if("lessThan"===r)return[2,l<n];if("lessThanOrEquals"===r)return[2,l<=n]}else{if("exists"===r)return[2,void 0!==s];if("notExists"===r)return[2,void 0===s];if(Array.isArray(s)&&"string"==typeof n){if(l=s,"includes"===r)return[2,l.indexOf(n)>-1];if("notIncludes"===r)return[2,-1===l.indexOf(n)]}}else{if(l=s,"in"===r)return[2,-1!==n.indexOf(l)];if("notIn"===r)return[2,-1===n.indexOf(l)]}return[2,!1]}})})},e.prototype._allAreMatched=function(e,t){return n(this,void 0,Promise,function(){var r,n,a,o,s,u,c,l,f,h;return i(this,function(i){switch(i.label){case 0:if("string"==typeof e)return"*"===e?[2,!0]:[2,!1];if("operator"in e)try{return[2,this.isMatched(e,t)]}catch(t){return this.logger.warn(t.message,{error:t,details:{condition:e}}),[2,!1]}if(!("and"in e)||!Array.isArray(e.and))return[3,5];r=0,n=e.and,i.label=1;case 1:return r<n.length?(h=n[r],[4,this._allAreMatched(h,t)]):[3,4];case 2:if(!i.sent())return[2,!1];i.label=3;case 3:return r++,[3,1];case 4:return[2,!0];case 5:if(!("or"in e)||!Array.isArray(e.or))return[3,10];a=0,o=e.or,i.label=6;case 6:return a<o.length?(h=o[a],[4,this._allAreMatched(h,t)]):[3,9];case 7:if(i.sent())return[2,!0];i.label=8;case 8:return a++,[3,6];case 9:return[2,!1];case 10:if(!("not"in e)||!Array.isArray(e.not))return[3,15];s=0,u=e.not,i.label=11;case 11:return s<u.length?(h=u[s],[4,this._allAreMatched(h,t)]):[3,14];case 12:if(i.sent())return[2,!1];i.label=13;case 13:return s++,[3,11];case 14:return[2,!0];case 15:if(!Array.isArray(e))return[3,20];c=!0,l=0,f=e,i.label=16;case 16:return l<f.length?(h=f[l],[4,this._allAreMatched(h,t)]):[3,19];case 17:if(!i.sent())return c=!1,[3,19];i.label=18;case 18:return l++,[3,16];case 19:return[2,c];case 20:return[2,!1]}})})},e.prototype.allAreMatched=function(e,t){return n(this,void 0,Promise,function(){var r;return i(this,function(n){return r=this.parseIfStringified(e),[2,this._allAreMatched(r,t)]})})},e.prototype.parseIfStringified=function(e){if("string"!=typeof e)return e;if("*"===e)return e;try{return JSON.parse(e)}catch(t){return this.logger.error("Error parsing conditions",{error:t,details:{conditions:e}}),e}},e}();t.ConditionsChecker=o},247:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Eventvisor=void 0,t.createInstance=function(e){return void 0===e&&(e={}),new v(e)};var a=r(649),o=r(584),s=r(40),u=r(470),c=r(420),l=r(127),f=r(186),h=r(481),p=r(357),d=r(972),g=r(681),v=function(){function e(e){void 0===e&&(e={});var t=this;if(this.ready=!1,this.queue=[],this.queueProcessing=!1,this.logger=e.logger||(0,o.createLogger)({level:e.logLevel||o.Logger.defaultLevel}),this.datafileReader=new a.DatafileReader({datafile:e.datafile||a.emptyDatafile,logger:this.logger}),this.emitter=new s.Emitter,this.modulesManager=new c.ModulesManager({logger:this.logger,getDatafileReader:function(){return t.datafileReader},getSourceResolver:function(){return t.sourceResolver}}),this.validator=new d.Validator({logger:this.logger,getSourceResolver:function(){return t.sourceResolver}}),this.attributesManager=new u.AttributesManager({logger:this.logger,emitter:this.emitter,validator:this.validator,getDatafileReader:function(){return t.datafileReader},getTransformer:function(){return t.transformer},getConditionsChecker:function(){return t.conditionsChecker},modulesManager:this.modulesManager}),this.effectsManager=new g.EffectsManager({logger:this.logger,getDatafileReader:function(){return t.datafileReader},getTransformer:function(){return t.transformer},getConditionsChecker:function(){return t.conditionsChecker},modulesManager:this.modulesManager}),this.sourceResolver=new l.SourceResolver({logger:this.logger,modulesManager:this.modulesManager,attributesManager:this.attributesManager,effectsManager:this.effectsManager}),this.conditionsChecker=new f.ConditionsChecker({logger:this.logger,getRegex:function(e,r){return t.datafileReader.getRegex(e,r)},sourceResolver:this.sourceResolver}),this.transformer=new p.Transformer({logger:this.logger,conditionsChecker:this.conditionsChecker,sourceResolver:this.sourceResolver}),this.bucketer=new h.Bucketer({logger:this.logger,sourceResolver:this.sourceResolver,conditionsChecker:this.conditionsChecker,transformer:this.transformer}),e.modules)for(var r=0,n=e.modules;r<n.length;r++){var i=n[r];this.modulesManager.registerModule(i)}Promise.all([this.effectsManager.initialize(),this.attributesManager.initialize()]).then(function(){t.ready=!0,t.emitter.trigger("ready"),t.logger.debug("Eventvisor SDK is ready")}).catch(function(e){t.logger.error("initialization failed",e)}),this.logger.info("Eventvisor SDK initialized")}return e.prototype.isReady=function(){return this.ready},e.prototype.onReady=function(){return n(this,void 0,Promise,function(){var e=this;return i(this,function(t){return this.ready?[2]:[2,new Promise(function(t){var r=e.emitter.on("ready",function(){r(),t()})})]})})},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.setLogLevel=function(e){return this.logger.setLevel(e)},e.prototype.setDatafile=function(e){try{var t=new a.DatafileReader({datafile:e,logger:this.logger});this.datafileReader=t,this.effectsManager.refresh(),this.emitter.trigger("datafile_set")}catch(e){this.logger.error("Error setting datafile",{error:e})}},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.addToQueue=function(e){this.queue.push(e)},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t;return i(this,function(r){switch(r.label){case 0:if(0===this.queue.length)return[2];if(this.queueProcessing)return[2];if(this.queueProcessing=!0,!(e=this.queue.shift()))return this.queueProcessing=!1,[2];r.label=1;case 1:return r.trys.push([1,10,,11]),"track"!==e.type?[3,3]:[4,this.trackAsync(e.name,e.value)];case 2:return r.sent(),[3,9];case 3:return"setAttribute"!==e.type?[3,5]:[4,this.setAttributeAsync(e.name,e.value)];case 4:return r.sent(),[3,9];case 5:return"removeAttribute"!==e.type?[3,7]:[4,this.removeAttributeAsync(e.name)];case 6:return r.sent(),[3,9];case 7:return"removeAttribute"!==e.type?[3,9]:[4,this.removeAttributeAsync(e.name)];case 8:r.sent(),r.label=9;case 9:return[3,11];case 10:return t=r.sent(),this.logger.error("Error processing queue",{error:t,action:e}),[3,11];case 11:return this.queueProcessing=!1,[4,this.processQueue()];case 12:return r.sent(),[2]}})})},e.prototype.setAttributeAsync=function(e,t){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,this.attributesManager.setAttribute(e,t)];case 1:return r=n.sent(),[4,this.effectsManager.dispatch({eventType:"attribute_set",name:e,value:r})];case 2:return n.sent(),[2,r]}})})},e.prototype.setAttribute=function(e,t){this.addToQueue({type:"setAttribute",name:e,value:t}),this.processQueue()},e.prototype.getAttributeValue=function(e){return this.attributesManager.getAttributeValue(e)},e.prototype.getAttributes=function(){return this.attributesManager.getAttributesMap()},e.prototype.isAttributeSet=function(e){return this.attributesManager.isAttributeSet(e)},e.prototype.removeAttributeAsync=function(e){return this.attributesManager.removeAttribute(e)},e.prototype.removeAttribute=function(e){this.addToQueue({type:"removeAttribute",name:e}),this.processQueue()},e.prototype.registerModule=function(e){return this.modulesManager.registerModule(e)},e.prototype.removeModule=function(e){return this.modulesManager.removeModule(e)},e.prototype.trackAsync=function(e,t){return n(this,void 0,Promise,function(){var r,n,a,o,s,u,c,l,f,h,p,d,g;return i(this,function(i){switch(i.label){case 0:return(r=this.datafileReader.getEvent(e))?(n=r.level||"info",r.deprecated&&this.logger.warn("Event is deprecated",{eventName:e}),[4,this.validator.validate(r,t)]):(this.logger.error("Event schema not found in datafile",{eventName:e}),[2,null]);case 1:return(a=i.sent()).valid?(o=a.value,r.conditions?[4,this.conditionsChecker.allAreMatched(r.conditions,{eventName:e,eventLevel:n,payload:o})]:[3,3]):(this.logger.warn("Event validation failed",{eventName:e,errors:a.errors}),[2,null]);case 2:if(!i.sent())return this.logger.debug("Event conditions not matched",{eventName:e,conditions:r.conditions}),[2,null];i.label=3;case 3:return r.sample?[4,this.bucketer.isSampled(r.sample,{eventName:e,eventLevel:n,payload:o})]:[3,5];case 4:if(!(g=i.sent()).isSampled)return this.logger.debug("Event sample not matched",{eventName:e,matchedSample:g.matchedSample,bucketedNumber:g.bucketedNumber,bucketKey:g.bucketKey}),[2,null];i.label=5;case 5:return s=o,r.transforms?[4,this.transformer.applyAll(o,r.transforms,{eventName:e,eventLevel:n,payload:o})]:[3,7];case 6:s=i.sent(),i.label=7;case 7:return[4,this.effectsManager.dispatch({eventType:"event_tracked",name:e,value:s})];case 8:i.sent(),u=this.datafileReader.getDestinationNames(),c=0,l=u,i.label=9;case 9:return c<l.length?(f=l[c],(h=this.datafileReader.getDestination(f))?this.modulesManager.transportExists(h.transport)?(p=s,r.destinations&&void 0!==r.destinations[f]?!1!==(d=r.destinations[f])?[3,10]:(this.logger.debug("Event has destination disabled",{eventName:e,destinationName:f}),[3,23]):[3,15]):(this.logger.error("Destination has no transport",{eventName:e,destinationName:f}),[3,23]):[3,23]):[3,24];case 10:return"object"!=typeof d?[3,15]:d.conditions?[4,this.conditionsChecker.allAreMatched(d.conditions,{eventName:e,eventLevel:n,payload:p})]:[3,15];case 11:return i.sent()?d.sample?[4,this.bucketer.isSampled(d.sample,{eventName:e,eventLevel:n,payload:p})]:[3,13]:(this.logger.debug("Destination conditions not matched for event",{eventName:e,destinationName:f}),[3,23]);case 12:if(!(g=i.sent()).isSampled)return this.logger.debug("Destination sample not matched for event",{eventName:e,destinationName:f,matchedSample:g.matchedSample,bucketedNumber:g.bucketedNumber,bucketKey:g.bucketKey}),[3,23];i.label=13;case 13:return d.transforms?[4,this.transformer.applyAll(s,d.transforms,{eventName:e,eventLevel:n,payload:p})]:[3,15];case 14:p=i.sent(),i.label=15;case 15:return h.conditions?[4,this.conditionsChecker.allAreMatched(h.conditions,{eventName:e,eventLevel:n,payload:s})]:[3,17];case 16:if(!i.sent())return this.logger.debug("Destination conditions not matched",{eventName:e,destinationName:f}),[3,23];i.label=17;case 17:return h.sample?[4,this.bucketer.isSampled(h.sample,{eventName:e,eventLevel:n,payload:p})]:[3,19];case 18:if(!(g=i.sent()).isSampled)return this.logger.debug("Destination sample not matched",{eventName:e,destinationName:f}),[3,23];i.label=19;case 19:return h.transforms?[4,this.transformer.applyAll(p,h.transforms,{eventName:e,eventLevel:n,payload:p,destinationName:f,attributes:this.attributesManager.getAttributesMap()})]:[3,21];case 20:p=i.sent(),i.label=21;case 21:return[4,this.modulesManager.transport(h.transport,f,e,p,n)];case 22:i.sent(),i.label=23;case 23:return c++,[3,9];case 24:return[2,s]}})})},e.prototype.track=function(e,t){this.addToQueue({type:"track",name:e,value:t}),this.processQueue()},e.prototype.getStateValue=function(e){return this.effectsManager.getStateValue(e)},e.prototype.spawn=function(){},e}();t.Eventvisor=v},357:function(e,t){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Transformer=void 0;var a=function(){function e(e){this.logger=e.logger,this.conditionsChecker=e.conditionsChecker,this.sourceResolver=e.sourceResolver}return e.prototype.applyAll=function(t,a){return n(this,arguments,Promise,function(t,n,a){var o,s,u,c,l,f;return void 0===a&&(a={}),i(this,function(h){switch(h.label){case 0:o=t,s=function(n){var s,c,l,f,h,p,d,g,v,y,m,b,w,M,A;return i(this,function(i){switch(i.label){case 0:return n.conditions?[4,u.conditionsChecker.allAreMatched(n.conditions,a)]:[3,2];case 1:if(!i.sent())return[2,"continue"];i.label=2;case 2:return[4,u.sourceResolver.resolve(n,a)];case 3:return null!=(s=i.sent())?[3,5]:n.target?[4,u.sourceResolver.resolve({payload:n.target},void 0===a.payload?r(r({},a),{payload:t}):a)]:[3,5];case 4:s=i.sent(),i.label=5;case 5:if(n.target)for(c=Array.isArray(n.target)?n.target:[n.target],l=0,f=c;l<f.length;l++)h=f[l],"string"==typeof s&&"trim"===n.type&&(o=e.setValueAtPath(o,h,s.trim())),Array.isArray(s)&&"concat"===n.type&&(p=n.separator||" ",o=e.setValueAtPath(o,h,s.join(p))),"set"===n.type&&(o="value"in n?e.setValueAtPath(o,h,n.value):e.setValueAtPath(o,h,s)),"remove"===n.type&&(o=e.removeValueAt(o,h)),"toInteger"===n.type?o=e.setValueAtPath(o,h,parseInt(String(s))):"toDouble"===n.type?o=e.setValueAtPath(o,h,parseFloat(String(s))):"toString"===n.type?o=e.setValueAtPath(o,h,String(s)||""):"toBoolean"===n.type&&(d=String(s).toLowerCase(),o=e.setValueAtPath(o,h,-1!==["true","1","checked","yes","on","y"].indexOf(d)||!0===s));else"set"===n.type&&"value"in n&&(o=n.value);if("spread"===n.type&&(n.target?(g=e.getValueAtPath(o,n.target),o=e.setValueAtPath(o,n.target,r(r({},g||{}),s||{}))):o=r(r({},o||{}),s||{})),"increment"===n.type?(v="number"==typeof n.value?n.value:1,n.target?o=e.setValueAtPath(o,n.target,Number(s)+v):o+=v):"decrement"===n.type&&(v="number"==typeof n.value?n.value:1,n.target?o=e.setValueAtPath(o,n.target,Number(s)-v):o-=v),n.targetMap){if(y=[],Array.isArray(n.targetMap))for(m=0,b=n.targetMap;m<b.length;m++)A=b[m],Object.entries(A).forEach(function(e){var t,r=e[0],n=e[1];y.push(((t={})[r]=n,t))});else Object.entries(n.targetMap).forEach(function(e){var t,r=e[0],n=e[1];y.push(((t={})[r]=n,t))});for(w=0,M=y;w<M.length;w++)A=M[w],"rename"===n.type&&(o=e.renameValueAt(o,A))}return[2]}})},u=this,c=0,l=n,h.label=1;case 1:return c<l.length?(f=l[c],[5,s(f)]):[3,4];case 2:h.sent(),h.label=3;case 3:return c++,[3,1];case 4:return[2,o]}})})},e.renameValueAt=function(t,r){if(!t||"object"!=typeof t)return t;if(!r||"object"!=typeof r)return t;var n=Object.entries(r);if(0===n.length)return t;var i=n[0],a=i[0],o=i[1];if(!a||!o)return t;var s=e.getValueAtPath(t,a);if(void 0===s)return t;for(var u=JSON.parse(JSON.stringify(t)),c=a.split("."),l=u,f=0;f<c.length-1;f++){var h=c[f];if(void 0===l[h])return u;l=l[h]}return delete l[c[c.length-1]],e.setValueAtPath(u,o,s)},e.getValueAtPath=function(e,t){if(t&&"string"==typeof t){for(var r=e,n=0,i=t.split(".");n<i.length;n++){var a=i[n];if(null==r)return;if("object"!=typeof r||Array.isArray(r)){if(!Array.isArray(r)||!/^\d+$/.test(a))return;r=r[parseInt(a)]}else r=r[a]}return r}},e.setValueAtPath=function(e,t,r){if(!t||"string"!=typeof t)return e;if(null==e)return e;for(var n=JSON.parse(JSON.stringify(e)),i=t.split("."),a=n,o=0;o<i.length-1;o++){var s=i[o];void 0===a[s]&&(/^\d+$/.test(i[o+1])?a[s]=[]:a[s]={}),a=a[s]}return a[i[i.length-1]]=r,n},e.removeValueAt=function(e,t){if(!t||"string"!=typeof t)return e;if(null==e)return e;for(var r=JSON.parse(JSON.stringify(e)),n=t.split("."),i=r,a=0;a<n.length-1;a++){var o=n[a];if(void 0===i[o])return r;i=i[o]}var s=n[n.length-1];return Array.isArray(i)?/^\d+$/.test(s)&&i.splice(parseInt(s),1):"object"==typeof i&&null!==i&&delete i[s],r},e}();t.Transformer=a},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHashV3=function(e,t){var n,i,a,o,s,u,c,l;for("string"==typeof e&&(e=r(e)),n=3&e.length,i=e.length-n,a=t,s=3432918353,u=461845907,l=0;l<i;)c=255&e[l]|(255&e[++l])<<8|(255&e[++l])<<16|(255&e[++l])<<24,++l,a=27492+(65535&(o=5*(65535&(a=(a^=c=(65535&(c=(c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295)<<15|c>>>17))*u+(((c>>>16)*u&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+(((o>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(255&e[l+2])<<16;case 2:c^=(255&e[l+1])<<8;case 1:a^=c=(65535&(c=(c=(65535&(c^=255&e[l]))*s+(((c>>>16)*s&65535)<<16)&4294967295)<<15|c>>>17))*u+(((c>>>16)*u&65535)<<16)&4294967295}return a^=e.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0};var r=function(e){return(new TextEncoder).encode(e)}},420:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.ModulesManager=void 0;var i=function(){function e(e){var t=e.logger,r=e.getDatafileReader,n=e.getSourceResolver;this.logger=t,this.getDatafileReader=r,this.getSourceResolver=n,this.modules=[]}return e.prototype.registerModule=function(e){this.modules.find(function(t){return t.name===e.name})?this.logger.error("Module ".concat(e.name," already registered")):this.modules.push(e)},e.prototype.getModule=function(e){return this.modules.find(function(t){return t.name===e})},e.prototype.removeModule=function(e){this.getModule(e)?this.modules=this.modules.filter(function(t){return t.name!==e}):this.logger.error("Module ".concat(e," not found"))},e.prototype.getModuleDependencies=function(){return{datafileReader:this.getDatafileReader(),logger:this.logger,sourceResolver:this.getSourceResolver()}},e.prototype.lookup=function(e){return r(this,void 0,Promise,function(){var t,r,i,a,o,s;return n(this,function(n){switch(n.label){case 0:if(t=e.split("."),r=t[0],i=t.slice(1),a=i.join("."),!(o=this.getModule(r))||!o.lookup)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,o.lookup({key:a},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return s=n.sent(),this.logger.error("Error in lookup",{moduleName:r,key:a,error:s}),[2,null];case 4:return this.logger.error('Module "'.concat(r,'" not found with "lookup" function')),[2,null]}})})},e.prototype.handle=function(e,t,i,a,o){return r(this,void 0,Promise,function(){var r,s,u,c;return n(this,function(n){switch(n.label){case 0:if(r=e.split("."),s=r[0],r[1],!(u=this.getModule(s))||!u.handle)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,u.handle({effectName:t,effect:i,step:a,payload:o},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return c=n.sent(),this.logger.error("Error in handle",{moduleName:s,effectName:t,error:c}),[2];case 4:return this.logger.error('Module "'.concat(s,'" not found with "handle" function')),[2]}})})},e.prototype.transportExists=function(e){var t=e.split("."),r=t[0],n=(t[1],this.getModule(r));return!(!n||!n.transport)},e.prototype.transport=function(e,t,i,a,o){return r(this,void 0,Promise,function(){var r,s,u,c;return n(this,function(n){switch(n.label){case 0:if(r=e.split("."),s=r[0],r[1],!(u=this.getModule(s))||!u.transport)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,u.transport({destinationName:t,eventName:i,eventLevel:o,payload:a},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return c=n.sent(),this.logger.error("Error in transport",{moduleName:s,destinationName:t,eventName:i,error:c}),[2];case 4:return this.logger.error('Module "'.concat(s,'" not found with "transport" function')),[2]}})})},e.prototype.readFromStorage=function(e,t){return r(this,void 0,Promise,function(){var r,i;return n(this,function(n){switch(n.label){case 0:if(!(r=this.getModule(e))||!r.readFromStorage)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.readFromStorage({key:t},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return i=n.sent(),this.logger.error("Error in readFromStorage",{moduleName:e,key:t,error:i}),[2,null];case 4:return this.logger.error('Module "'.concat(e,'" not found with "readFromStorage" function')),[2,null]}})})},e.prototype.writeToStorage=function(e,t,i){return r(this,void 0,Promise,function(){var r,a;return n(this,function(n){switch(n.label){case 0:if(!(r=this.getModule(e))||!r.writeToStorage)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.writeToStorage({key:t,value:i},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return a=n.sent(),this.logger.error("Error in writeToStorage",{moduleName:e,key:t,value:i,error:a}),[2];case 4:return this.logger.error('Module "'.concat(e,'" not found with "writeToStorage" function')),[2]}})})},e.prototype.removeFromStorage=function(e,t){return r(this,void 0,Promise,function(){var r,i;return n(this,function(n){switch(n.label){case 0:if(!(r=this.getModule(e))||!r.removeFromStorage)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.removeFromStorage({key:t},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return i=n.sent(),this.logger.error("Error in removeFromStorage",{moduleName:e,key:t,error:i}),[2];case 4:return this.logger.error('Module "'.concat(e,'" not found with "removeFromStorage" function')),[2]}})})},e}();t.ModulesManager=i},470:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.AttributesManager=void 0;var a=r(53),o=function(){function e(e){var t=e.logger,r=e.getDatafileReader,n=e.emitter,i=e.getTransformer,a=e.getConditionsChecker,o=e.validator,s=e.modulesManager;this.logger=t,this.getDatafileReader=r,this.emitter=n,this.getTransformer=i,this.getConditionsChecker=a,this.validator=o,this.modulesManager=s,this.attributesMap={}}return e.prototype.initialize=function(){return n(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.initializeFromStorage()];case 1:return e.sent(),[2]}})})},e.prototype.initializeFromStorage=function(){return n(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return e=this.getDatafileReader(),[4,(0,a.initializeFromStorage)({datafileReader:e,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"attributes_",getEntityNames:function(){return e.getAttributeNames()},getEntity:function(t){return e.getAttribute(t)}})];case 1:return t=r.sent(),this.attributesMap=t,[2]}})})},e.prototype.setAttribute=function(e,t){return n(this,void 0,Promise,function(){var r,n,o,s,u,c;return i(this,function(i){switch(i.label){case 0:return r=this.getDatafileReader(),(n=r.getAttribute(e))?(n.deprecated&&this.logger.warn("Attribute is deprecated",{attributeName:e}),[4,this.validator.validate(n,t)]):(this.logger.error("Attribute schema not found",{attributeName:e}),[2,null]);case 1:return(o=i.sent()).valid?(s=o.value,n.transforms?[4,this.getTransformer().applyAll(s,n.transforms,{payload:s,attributeName:e})]:[3,3]):(this.logger.warn("Attribute validation failed",{attributeName:e,errors:o.errors}),[2,null]);case 2:return c=i.sent(),[3,4];case 3:c=s,i.label=4;case 4:return u=c,this.attributesMap[e]=u,this.emitter.trigger("attribute_set",{attributeName:e}),this.logger.debug("Attribute set",{attributeName:e}),[4,(0,a.persistEntity)({datafileReader:r,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"attributes_",entityName:e,entity:n,value:t})];case 5:return i.sent(),[2,u]}})})},e.prototype.isAttributeSet=function(e){return void 0!==this.attributesMap[e]},e.prototype.getAttributesMap=function(){return this.attributesMap},e.prototype.getAttributeValue=function(e){return this.attributesMap[e]||null},e.prototype.removeAttribute=function(e){return n(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return t=this.getDatafileReader(),[4,(0,a.removeEntity)({datafileReader:t,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"attributes_",entityName:e,entity:t.getAttribute(e)})];case 1:return r.sent(),delete this.attributesMap[e],this.emitter.trigger("attribute_removed",{attributeName:e}),[2]}})})},e}();t.AttributesManager=o},481:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Bucketer=t.BucketerOptions=t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=u;var a=r(400),o=1,s=Math.pow(2,32);function u(e){var r=(0,a.MurmurHashV3)(e,o)/s;return Math.floor(r*t.MAX_BUCKETED_NUMBER)}t.MAX_BUCKETED_NUMBER=1e5;t.BucketerOptions=function(){};var c=function(){function e(e){this.logger=e.logger,this.sourceResolver=e.sourceResolver,this.conditionsChecker=e.conditionsChecker,this.transformer=e.transformer}return e.prototype.getBucketKey=function(e,t){return n(this,void 0,Promise,function(){var r,n,a,o,s,u,c;return i(this,function(i){switch(i.label){case 0:if("string"==typeof e)r="plain",n=[e];else if(Array.isArray(e))r="and",n=e;else if("object"==typeof e&&"or"in e&&Array.isArray(e.or))r="or",n=e.or;else{if("object"!=typeof e)throw this.logger.error("invalid sampleBy",{sampleBy:e}),new Error("invalid sampleBy");r="and",n=[e]}a=[],o=0,s=n,i.label=1;case 1:return o<s.length?(u=s[o],[4,this.sourceResolver.resolve(u,t)]):[3,4];case 2:if(void 0===(c=i.sent()))return[3,3];("plain"===r||"and"===r||0===a.length)&&a.push(String(c)),i.label=3;case 3:return o++,[3,1];case 4:return[2,a.join(".")]}})})},e.prototype.isSampled=function(e,t){return n(this,void 0,Promise,function(){var r,a,o,s,c=this;return i(this,function(l){switch(l.label){case 0:return r=Array.isArray(e)?e:[e],a=r.find(function(e){return n(c,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return e.conditions?[4,this.conditionsChecker.allAreMatched(e.conditions,t)]:[2,!0];case 1:return[2,r.sent()]}})})}),a?[4,this.getBucketKey(a.by,t)]:[3,2];case 1:if(o=l.sent(),s=u(o),a.percentage&&a.percentage>0&&s<a.percentage)return[2,{isSampled:!1,matchedSample:a,bucketedNumber:s,bucketKey:o}];if(a.range&&s<a.range[0]&&s>a.range[1])return[2,{isSampled:!1,matchedSample:a,bucketedNumber:s,bucketKey:o}];l.label=2;case 2:return[2,{isSampled:!0}]}})})},e}();t.Bucketer=c},584:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.loggerPrefix=void 0,t.createLogger=function(e){return void 0===e&&(e={}),new r(e)},t.loggerPrefix="[Eventvisor]",t.defaultLogHandler=function(e,r,n){void 0===n&&(n={});var i="log";"info"===e?i="info":"warn"===e?i="warn":"error"===e&&(i="error"),console[i](t.loggerPrefix,r,n)};var r=function(){function e(r){this.level=r.level||e.defaultLevel,this.handle=r.handler||t.defaultLogHandler}return e.prototype.setLevel=function(e){this.level=e},e.prototype.log=function(t,r,n){e.allLevels.indexOf(this.level)>=e.allLevels.indexOf(t)&&this.handle(t,r,n)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e.allLevels=["fatal","error","warn","info","debug"],e.defaultLevel="info",e}();t.Logger=r},649:(e,t)=>{function r(e){var t=[];if("string"==typeof e)t.push({storage:e});else if(Array.isArray(e))for(var n=0,i=e;n<i.length;n++){var a=r(i[n]);a&&(t=t.concat(a))}else"object"==typeof e&&t.push(e);return t}Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=t.emptyDatafile=void 0,t.getComplexPersists=r,t.emptyDatafile={schemaVersion:"1",revision:"0",attributes:{},events:{},destinations:{},effects:{}};var n=function(){function e(e){var t=e.datafile,r=e.logger;this.datafile=t,this.schemaVersion=t.schemaVersion,this.revision=t.revision,this.regexCache={},this.logger=r}return e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getRevision=function(){return this.revision},e.prototype.getAttribute=function(e){return this.datafile.attributes[e]},e.prototype.getAttributeNames=function(){return Object.keys(this.datafile.attributes)},e.prototype.getEvent=function(e){return this.datafile.events[e]},e.prototype.getDestination=function(e){return this.datafile.destinations[e]},e.prototype.getDestinationNames=function(){return Object.keys(this.datafile.destinations)},e.prototype.getEffect=function(e){return this.datafile.effects[e]},e.prototype.getEffectNames=function(){return Object.keys(this.datafile.effects)},e.prototype.getRegex=function(e,t){var r=t||"",n="".concat(e,"-").concat(r);if(this.regexCache[n])return this.regexCache[n];var i=new RegExp(e,r);return this.regexCache[n]=i,i},e.prototype.getPersists=function(e){return e&&e.persist?r(e.persist):null},e}();t.DatafileReader=n},681:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.EffectsManager=void 0;var a=r(53),o=function(){function e(e){this.statesByEffect={},this.logger=e.logger,this.getDatafileReader=e.getDatafileReader,this.getTransformer=e.getTransformer,this.getConditionsChecker=e.getConditionsChecker,this.modulesManager=e.modulesManager}return e.prototype.initialize=function(){return n(this,void 0,Promise,function(){var e,t,r,n,o,s,u;return i(this,function(i){switch(i.label){case 0:return e=this.getDatafileReader(),t=e.getEffectNames(),[4,(0,a.initializeFromStorage)({datafileReader:e,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"effects_",getEntityNames:function(){return e.getEffectNames()},getEntity:function(t){return e.getEffect(t)}})];case 1:for(r=i.sent(),n=0,o=t;n<o.length;n++)s=o[n],(u=e.getEffect(s))&&void 0===this.statesByEffect[s]&&(void 0!==r[s]?this.statesByEffect[s]=r[s]:void 0!==u.state&&void 0===this.statesByEffect[s]&&(this.statesByEffect[s]=u.state));return[2]}})})},e.prototype.dispatch=function(e){return n(this,void 0,void 0,function(){var t,r,n,o,s,u,c,l,f,h,p,d,g,v,y,m,b,w,M,A;return i(this,function(i){switch(i.label){case 0:t=e.eventType,r=e.name,n=e.value,o=this.getDatafileReader(),s=this.getConditionsChecker(),u=this.getTransformer(),c=o.getEffectNames(),l=0,f=c,i.label=1;case 1:if(!(l<f.length))return[3,16];if(h=f[l],!(p=o.getEffect(h)))return[3,15];if("event_tracked"===t){if(Array.isArray(p.on)&&!p.on.includes("event_tracked"))return[3,15];if("object"==typeof p.on&&!(null===(M=p.on.event_tracked)||void 0===M?void 0:M.includes(r)))return[3,15]}if("attribute_set"===t){if(Array.isArray(p.on)&&!p.on.includes("attribute_set"))return[3,15];if("object"==typeof p.on&&!(null===(A=p.on.attribute_set)||void 0===A?void 0:A.includes(r)))return[3,15]}return p.conditions?[4,s.allAreMatched(p.conditions,{payload:n,eventName:"event_tracked"===t?r:void 0,attributeName:"attribute_set"===t?r:void 0,state:this.statesByEffect[h]})]:[3,3];case 2:if(!i.sent())return[3,15];i.label=3;case 3:if(!p.steps)return[3,13];d=0,g=p.steps,i.label=4;case 4:return d<g.length?(v=g[d],y=!0,v.conditions?[4,this.getConditionsChecker().allAreMatched(v.conditions,{payload:n,eventName:"event_tracked"===t?r:void 0,attributeName:"attribute_set"===t?r:void 0,state:this.statesByEffect[h]})]:[3,6]):[3,13];case 5:if(!i.sent())return[3,12];i.label=6;case 6:if(!v.handler)return[3,10];i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.modulesManager.handle(v.handler,h,p,v,n)];case 8:return i.sent(),[3,10];case 9:return m=i.sent(),this.logger.error("Effect handler error",{effectName:h,step:v,error:m}),y=!1,[3,10];case 10:return y||"boolean"!=typeof v.continueOnError||v.continueOnError?v.transforms?(b=this.statesByEffect,w=h,[4,u.applyAll(this.statesByEffect[h],v.transforms,{eventName:"event_tracked"===t?r:void 0,attributeName:"attribute_set"===t?r:void 0,state:this.statesByEffect[h]})]):[3,12]:[3,13];case 11:b[w]=i.sent(),i.label=12;case 12:return d++,[3,4];case 13:return[4,(0,a.persistEntity)({datafileReader:o,conditionsChecker:s,modulesManager:this.modulesManager,storageKeyPrefix:"effects_",entityName:h,entity:p,value:this.statesByEffect[h]})];case 14:i.sent(),i.label=15;case 15:return l++,[3,1];case 16:return[2]}})})},e.prototype.refresh=function(){this.initialize()},e.prototype.getAllStates=function(){return this.statesByEffect},e.prototype.getStateValue=function(e){return this.statesByEffect[e]},e}();t.EffectsManager=o},972:function(e,t){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Validator=void 0,t.validate=o;var a=function(){function e(e){this.logger=e.logger,this.getSourceResolver=e.getSourceResolver}return e.prototype.validate=function(e,t){return o(e,t,{})},e}();function o(e,t,r){return n(this,void 0,Promise,function(){var n,a;return i(this,function(i){return void 0===(a=s(e,t,"",n=[],r))&&0===n.length&&void 0!==e.default?[2,{valid:!0,value:e.default,errors:[]}]:[2,{valid:0===n.length,errors:n.length>0?n:void 0,value:a}]})})}function s(e,t,n,i,a){var o,u;if(null===t){if("null"===e.type||(null===(o=e.enum)||void 0===o?void 0:o.includes(null)))return t;if(e.type&&"null"!==e.type)return void i.push({path:n,message:"Expected type ".concat(e.type,", got null"),schema:e,value:t})}if(void 0===t)return void 0!==e.default?e.default:e.type?void i.push({path:n,message:"Required field missing",schema:e,value:t}):void 0;if(e.type&&"integer"!==e.type){var c=function(e,t){switch(e){case"string":return"string"==typeof t;case"number":return"number"==typeof t;case"integer":return"number"==typeof t&&Number.isInteger(t);case"boolean":return"boolean"==typeof t;case"null":return null===t;case"object":return"object"==typeof t&&null!==t&&!Array.isArray(t);case"array":return Array.isArray(t);default:return!0}}(e.type,t);if(!c)return void i.push({path:n,message:"Expected type ".concat(e.type,", got ").concat(typeof t),schema:e,value:t})}if(void 0===e.const||t===e.const)if(!e.enum||e.enum.includes(t)){var l=t;if("object"==typeof t&&!Array.isArray(t)&&e.properties){var f;f=t instanceof Error?r({name:t.name,message:t.message,stack:t.stack},t):t;var h={};if(e.required)for(var p=0,d=e.required;p<d.length;p++){var g=d[p];g in f||(void 0!==(null===(u=e.properties[g])||void 0===u?void 0:u.default)?h[g]=e.properties[g].default:i.push({path:n?"".concat(n,".").concat(g):g,message:"Required property '".concat(g,"' is missing"),schema:e.properties[g],value:void 0}))}for(var v=0,y=Object.entries(f);v<y.length;v++){var m=y[v],b=m[0],w=m[1];if(e.properties&&e.properties[b]){var M=s(_=e.properties[b],w,n?"".concat(n,".").concat(b):b,i,a);void 0!==M&&(h[b]=M)}else h[b]=w}if(e.properties)for(var A=0,k=Object.entries(e.properties);A<k.length;A++){var x=k[A],_=(b=x[0],x[1]);b in h||void 0===_.default||(h[b]=_.default)}l=h}if(Array.isArray(t)){if(void 0!==e.minItems&&t.length<e.minItems)return void i.push({path:n,message:"Array must have at least ".concat(e.minItems," items, got ").concat(t.length),schema:e,value:t});if(void 0!==e.maxItems&&t.length>e.maxItems)return void i.push({path:n,message:"Array must have at most ".concat(e.maxItems," items, got ").concat(t.length),schema:e,value:t});if(e.items){var S=[];if(Array.isArray(e.items))for(var P=0;P<t.length;P++){var E=e.items[P];if(E){var N="".concat(n,"[").concat(P,"]");void 0!==(O=s(E,t[P],N,i,a))&&S.push(O)}else S.push(t[P])}else for(P=0;P<t.length;P++){var O;N="".concat(n,"[").concat(P,"]"),void 0!==(O=s(e.items,t[P],N,i,a))&&S.push(O)}l=S}else l=t}if("string"==typeof t){if(void 0!==e.minLength&&t.length<e.minLength)return void i.push({path:n,message:"String must be at least ".concat(e.minLength," characters long"),schema:e,value:t});if(void 0!==e.maxLength&&t.length>e.maxLength)return void i.push({path:n,message:"String must be at most ".concat(e.maxLength," characters long"),schema:e,value:t});if(e.pattern&&!new RegExp(e.pattern).test(t))return void i.push({path:n,message:"String must match pattern: ".concat(e.pattern),schema:e,value:t})}if("number"==typeof t){if(void 0!==e.minimum&&t<e.minimum)return void i.push({path:n,message:"Number must be at least ".concat(e.minimum),schema:e,value:t});if(void 0!==e.maximum&&t>e.maximum)return void i.push({path:n,message:"Number must be at most ".concat(e.maximum),schema:e,value:t});if("integer"===e.type&&!Number.isInteger(t))return void i.push({path:n,message:"Number must be an integer",schema:e,value:t})}if("integer"!==e.type||"number"==typeof t)return l;i.push({path:n,message:"Expected type integer, got ".concat(typeof t),schema:e,value:t})}else i.push({path:n,message:"Value must be one of: ".concat(e.enum.map(function(e){return JSON.stringify(e)}).join(", ")),schema:e,value:t});else i.push({path:n,message:"Value must be exactly ".concat(JSON.stringify(e.const)),schema:e,value:t})}t.Validator=a}},t={};return function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(166)})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EventvisorSDK=t():e.EventvisorSDK=t()}(this,()=>(()=>{"use strict";var e={40:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]);var r=this.listeners[e];r.push(t);var n=!0;return function(){if(n){n=!1;var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.trigger=function(e,t){void 0===t&&(t={});var r=this.listeners[e];r&&r.forEach(function(e){try{e(t)}catch(e){console.error(e)}})},e.prototype.clearAll=function(){this.listeners={}},e}();t.Emitter=r},53:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};function i(e){return r(this,void 0,Promise,function(){var t,r,i,a,o,s,u;return n(this,function(n){switch(n.label){case 0:t=e.persists,r=e.entityName,i=e.conditionsChecker,a=e.payload,o=0,s=t,n.label=1;case 1:return o<s.length?(u=s[o]).conditions?[4,i.allAreMatched(u.conditions,{attributeName:r,effectName:r,payload:a})]:[2,u]:[3,4];case 2:if(n.sent())return[2,u];n.label=3;case 3:return o++,[3,1];case 4:return[2]}})})}Object.defineProperty(t,"__esModule",{value:!0}),t.findPersist=i,t.initializeFromStorage=function(e){return r(this,arguments,Promise,function(e){var t,r,a,o,s,u,c,l,f,h=e.datafileReader,p=e.conditionsChecker,d=e.modulesManager,g=e.storageKeyPrefix,v=e.getEntityNames,y=e.getEntity;return n(this,function(e){switch(e.label){case 0:t=v(),r={},a=0,o=t,e.label=1;case 1:return a<o.length?(s=o[a],(u=y(s))&&(c=h.getPersists(u))?[4,i({persists:c,entityName:s,conditionsChecker:p,payload:{}})]:[3,4]):[3,5];case 2:return(l=e.sent())?[4,d.readFromStorage(l.storage,"".concat(g).concat(s))]:[3,4];case 3:null!=(f=e.sent())&&(r[s]=f),e.label=4;case 4:return a++,[3,1];case 5:return[2,r]}})})},t.persistEntity=function(e){return r(this,arguments,void 0,function(e){var t,r,a=e.datafileReader,o=e.conditionsChecker,s=e.modulesManager,u=e.storageKeyPrefix,c=e.entityName,l=e.entity,f=e.value;return n(this,function(e){switch(e.label){case 0:return l&&(t=a.getPersists(l))?[4,i({persists:t,entityName:c,conditionsChecker:o,payload:f})]:[2];case 1:return(r=e.sent())?[4,s.writeToStorage(r.storage,"".concat(u).concat(c),f)]:[2];case 2:return e.sent(),[2]}})})},t.removeEntity=function(e){return r(this,arguments,void 0,function(e){var t,r,a=e.datafileReader,o=e.conditionsChecker,s=e.modulesManager,u=e.storageKeyPrefix,c=e.entityName,l=e.entity;return n(this,function(e){switch(e.label){case 0:return l&&(t=a.getPersists(l))?[4,i({persists:t,entityName:c,conditionsChecker:o,payload:{}})]:[2];case 1:return(r=e.sent())?[4,s.removeFromStorage(r.storage,"".concat(u).concat(c))]:[2];case 2:return e.sent(),[2]}})})}},108:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.compareVersions=t.compareSegments=t.validateAndParse=t.semver=void 0,t.semver=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,t.validateAndParse=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");var r=e.match(t.semver);if(!r)throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"));return r.shift(),r};var r=function(e){return"*"===e||"x"===e||"X"===e},n=function(e){var t=parseInt(e,10);return isNaN(t)?e:t},i=function(e,t){if(r(e)||r(t))return 0;var i=function(e,t){return typeof e!=typeof t?[String(e),String(t)]:[e,t]}(n(e),n(t)),a=i[0],o=i[1];return a>o?1:a<o?-1:0};t.compareSegments=function(e,t){for(var r=0;r<Math.max(e.length,t.length);r++){var n=i(e[r]||"0",t[r]||"0");if(0!==n)return n}return 0},t.compareVersions=function(e,r){var n=(0,t.validateAndParse)(e),i=(0,t.validateAndParse)(r),a=n.pop(),o=i.pop(),s=(0,t.compareSegments)(n,i);return 0!==s?s:a&&o?(0,t.compareSegments)(a.split("."),o.split(".")):a||o?a?-1:1:0}},127:function(e,t){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function o(e,t){return t.reduce(function(e,t){return e[t]},e)}Object.defineProperty(t,"__esModule",{value:!0}),t.SourceResolver=void 0;var s=function(){function e(e){var t=e.logger,r=e.modulesManager,n=e.attributesManager,i=e.effectsManager;this.logger=t,this.modulesManager=r,this.attributesManager=n,this.effectsManager=i}return e.prototype.getPath=function(e){var t=e.split(".");return{name:t[0],path:t.slice(1),fullKey:e}},e.prototype.getOrigin=function(e){var t=this;if("string"==typeof e){var n=e.split(".");return{originType:n[0],name:n[1],path:n.slice(2),fullKey:e}}return"source"in e||"source"in e?this.getOrigin(e.source):"attribute"in e?r({originType:"attribute"},this.getPath(e.attribute)):"effect"in e?r({originType:"effect"},this.getPath(e.effect)):"payload"in e?Array.isArray(e.payload)?e.payload.map(function(e){return r({originType:"payload"},t.getPath(e))}):r({originType:"payload"},this.getPath(e.payload)):"lookup"in e?r({originType:"lookup"},this.getPath(e.lookup)):"state"in e?r({originType:"state"},this.getPath(e.state)):null},e.prototype.resolveByOrigin=function(e){return n(this,arguments,Promise,function(e,t){var r;return void 0===t&&(t={}),i(this,function(n){return null===e?[2,null]:"attributes"===e.originType?(r=e.name?this.attributesManager.getAttributeValue(e.name):this.attributesManager.getAttributesMap(),e.path.length>0?[2,o(r,e.path)]:[2,r]):"attribute"===e.originType?(r=this.attributesManager.getAttributeValue(e.name),e.path.length>0?[2,o(r,e.path)]:[2,r]):"effects"===e.originType?(r=e.name?this.effectsManager.getStateValue(e.name):this.effectsManager.getAllStates(),e.path.length>0?[2,o(r,e.path)]:[2,r]):"effect"===e.originType?(r=this.effectsManager.getStateValue(e.name),e.path.length>0?[2,o(r,e.path)]:[2,r]):"lookup"===e.originType?[2,this.modulesManager.lookup(e.fullKey)]:void 0!==t[e.originType]?[2,o(t[e.originType],a([e.name],e.path,!0).filter(Boolean))]:[2,null]})})},e.prototype.resolve=function(e){return n(this,arguments,Promise,function(e,t){var r,n=this;return void 0===t&&(t={}),i(this,function(i){switch(i.label){case 0:return r=this.getOrigin(e),Array.isArray(r)?[2,Promise.all(r.map(function(e){return n.resolveByOrigin(e,t)}))]:[4,this.resolveByOrigin(r,t)];case 1:return[2,i.sent()]}})})},e}();t.SourceResolver=s},166:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(247),t),i(r(470),t),i(r(649),t),i(r(40),t),i(r(584),t),i(r(357),t),i(r(481),t),i(r(127),t),i(r(420),t),i(r(681),t),i(r(400),t),i(r(108),t)},186:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.ConditionsChecker=void 0;var a=r(108),o=function(){function e(e){this.getRegex=e.getRegex,this.sourceResolver=e.sourceResolver,this.logger=e.logger}return e.prototype.isMatched=function(e,t){return n(this,void 0,Promise,function(){var r,n,o,s,u,c,l;return i(this,function(i){switch(i.label){case 0:return r=e.operator,n=e.value,o=e.regexFlags,[4,this.sourceResolver.resolve(e,t)];case 1:if(s=i.sent(),"equals"===r)return[2,s===n];if("notEquals"===r)return[2,s!==n];if("before"===r||"after"===r)return u=(l=s)instanceof Date?l:new Date(l),c=n instanceof Date?n:new Date(n),[2,"before"===r?u<c:u>c];if(!Array.isArray(n)||-1===["string","number"].indexOf(typeof s)&&null!==s)if("string"==typeof s&&"string"==typeof n){if(l=s,"contains"===r)return[2,-1!==l.indexOf(n)];if("notContains"===r)return[2,-1===l.indexOf(n)];if("startsWith"===r)return[2,l.startsWith(n)];if("endsWith"===r)return[2,l.endsWith(n)];if("semverEquals"===r)return[2,0===(0,a.compareVersions)(l,n)];if("semverNotEquals"===r)return[2,0!==(0,a.compareVersions)(l,n)];if("semverGreaterThan"===r)return[2,1===(0,a.compareVersions)(l,n)];if("semverGreaterThanOrEquals"===r)return[2,(0,a.compareVersions)(l,n)>=0];if("semverLessThan"===r)return[2,-1===(0,a.compareVersions)(l,n)];if("semverLessThanOrEquals"===r)return[2,(0,a.compareVersions)(l,n)<=0];if("matches"===r)return[2,this.getRegex(n,o||"").test(l)];if("notMatches"===r)return[2,!this.getRegex(n,o||"").test(l)]}else if("number"==typeof s&&"number"==typeof n){if(l=s,"greaterThan"===r)return[2,l>n];if("greaterThanOrEquals"===r)return[2,l>=n];if("lessThan"===r)return[2,l<n];if("lessThanOrEquals"===r)return[2,l<=n]}else{if("exists"===r)return[2,void 0!==s];if("notExists"===r)return[2,void 0===s];if(Array.isArray(s)&&"string"==typeof n){if(l=s,"includes"===r)return[2,l.indexOf(n)>-1];if("notIncludes"===r)return[2,-1===l.indexOf(n)]}}else{if(l=s,"in"===r)return[2,-1!==n.indexOf(l)];if("notIn"===r)return[2,-1===n.indexOf(l)]}return[2,!1]}})})},e.prototype._allAreMatched=function(e,t){return n(this,void 0,Promise,function(){var r,n,a,o,s,u,c,l,f,h;return i(this,function(i){switch(i.label){case 0:if("string"==typeof e)return"*"===e?[2,!0]:[2,!1];if("operator"in e)try{return[2,this.isMatched(e,t)]}catch(t){return this.logger.warn(t.message,{error:t,details:{condition:e}}),[2,!1]}if(!("and"in e)||!Array.isArray(e.and))return[3,5];r=0,n=e.and,i.label=1;case 1:return r<n.length?(h=n[r],[4,this._allAreMatched(h,t)]):[3,4];case 2:if(!i.sent())return[2,!1];i.label=3;case 3:return r++,[3,1];case 4:return[2,!0];case 5:if(!("or"in e)||!Array.isArray(e.or))return[3,10];a=0,o=e.or,i.label=6;case 6:return a<o.length?(h=o[a],[4,this._allAreMatched(h,t)]):[3,9];case 7:if(i.sent())return[2,!0];i.label=8;case 8:return a++,[3,6];case 9:return[2,!1];case 10:if(!("not"in e)||!Array.isArray(e.not))return[3,15];s=0,u=e.not,i.label=11;case 11:return s<u.length?(h=u[s],[4,this._allAreMatched(h,t)]):[3,14];case 12:if(i.sent())return[2,!1];i.label=13;case 13:return s++,[3,11];case 14:return[2,!0];case 15:if(!Array.isArray(e))return[3,20];c=!0,l=0,f=e,i.label=16;case 16:return l<f.length?(h=f[l],[4,this._allAreMatched(h,t)]):[3,19];case 17:if(!i.sent())return c=!1,[3,19];i.label=18;case 18:return l++,[3,16];case 19:return[2,c];case 20:return[2,!1]}})})},e.prototype.allAreMatched=function(e,t){return n(this,void 0,Promise,function(){var r;return i(this,function(n){return r=this.parseIfStringified(e),[2,this._allAreMatched(r,t)]})})},e.prototype.parseIfStringified=function(e){if("string"!=typeof e)return e;if("*"===e)return e;try{return JSON.parse(e)}catch(t){return this.logger.error("Error parsing conditions",{error:t,details:{conditions:e}}),e}},e}();t.ConditionsChecker=o},247:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Eventvisor=void 0,t.createInstance=function(e){return void 0===e&&(e={}),new v(e)};var a=r(649),o=r(584),s=r(40),u=r(470),c=r(420),l=r(127),f=r(186),h=r(481),p=r(357),d=r(972),g=r(681),v=function(){function e(e){void 0===e&&(e={});var t=this;if(this.ready=!1,this.queue=[],this.queueProcessing=!1,this.logger=e.logger||(0,o.createLogger)({level:e.logLevel||o.Logger.defaultLevel}),this.datafileReader=new a.DatafileReader({datafile:e.datafile||a.emptyDatafile,logger:this.logger}),this.emitter=new s.Emitter,this.modulesManager=new c.ModulesManager({logger:this.logger,getDatafileReader:function(){return t.datafileReader},getSourceResolver:function(){return t.sourceResolver}}),this.validator=new d.Validator({logger:this.logger,getSourceResolver:function(){return t.sourceResolver}}),this.attributesManager=new u.AttributesManager({logger:this.logger,emitter:this.emitter,validator:this.validator,getDatafileReader:function(){return t.datafileReader},getTransformer:function(){return t.transformer},getConditionsChecker:function(){return t.conditionsChecker},modulesManager:this.modulesManager}),this.effectsManager=new g.EffectsManager({logger:this.logger,getDatafileReader:function(){return t.datafileReader},getTransformer:function(){return t.transformer},getConditionsChecker:function(){return t.conditionsChecker},modulesManager:this.modulesManager}),this.sourceResolver=new l.SourceResolver({logger:this.logger,modulesManager:this.modulesManager,attributesManager:this.attributesManager,effectsManager:this.effectsManager}),this.conditionsChecker=new f.ConditionsChecker({logger:this.logger,getRegex:function(e,r){return t.datafileReader.getRegex(e,r)},sourceResolver:this.sourceResolver}),this.transformer=new p.Transformer({logger:this.logger,conditionsChecker:this.conditionsChecker,sourceResolver:this.sourceResolver}),this.bucketer=new h.Bucketer({logger:this.logger,sourceResolver:this.sourceResolver,conditionsChecker:this.conditionsChecker,transformer:this.transformer}),e.modules)for(var r=0,n=e.modules;r<n.length;r++){var i=n[r];this.modulesManager.registerModule(i)}Promise.all([this.effectsManager.initialize(),this.attributesManager.initialize()]).then(function(){t.ready=!0,t.emitter.trigger("ready"),t.logger.debug("Eventvisor SDK is ready")}).catch(function(e){t.logger.error("initialization failed",e)}),this.logger.info("Eventvisor SDK initialized")}return e.prototype.isReady=function(){return this.ready},e.prototype.onReady=function(){return n(this,void 0,Promise,function(){var e=this;return i(this,function(t){return this.ready?[2]:[2,new Promise(function(t){var r=e.emitter.on("ready",function(){r(),t()})})]})})},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.setLogLevel=function(e){return this.logger.setLevel(e)},e.prototype.setDatafile=function(e){try{var t=new a.DatafileReader({datafile:e,logger:this.logger});this.datafileReader=t,this.effectsManager.refresh(),this.emitter.trigger("datafile_set")}catch(e){this.logger.error("Error setting datafile",{error:e})}},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.addToQueue=function(e){this.queue.push(e)},e.prototype.processQueue=function(){return n(this,void 0,void 0,function(){var e,t;return i(this,function(r){switch(r.label){case 0:if(0===this.queue.length)return[2];if(this.queueProcessing)return[2];if(this.queueProcessing=!0,!(e=this.queue.shift()))return this.queueProcessing=!1,[2];r.label=1;case 1:return r.trys.push([1,8,,9]),"track"!==e.type?[3,3]:[4,this.trackAsync(e.name,e.value)];case 2:return r.sent(),[3,7];case 3:return"setAttribute"!==e.type?[3,5]:[4,this.setAttributeAsync(e.name,e.value)];case 4:return r.sent(),[3,7];case 5:return"removeAttribute"!==e.type?[3,7]:[4,this.removeAttributeAsync(e.name)];case 6:r.sent(),r.label=7;case 7:return[3,9];case 8:return t=r.sent(),this.logger.error("Error processing queue",{error:t,action:e}),[3,9];case 9:return this.queueProcessing=!1,[4,this.processQueue()];case 10:return r.sent(),[2]}})})},e.prototype.setAttributeAsync=function(e,t){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,this.attributesManager.setAttribute(e,t)];case 1:return r=n.sent(),[4,this.effectsManager.dispatch({eventType:"attribute_set",name:e,value:r})];case 2:return n.sent(),[2,r]}})})},e.prototype.setAttribute=function(e,t){this.addToQueue({type:"setAttribute",name:e,value:t}),this.processQueue()},e.prototype.getAttributeValue=function(e){return this.attributesManager.getAttributeValue(e)},e.prototype.getAttributes=function(){return this.attributesManager.getAttributesMap()},e.prototype.isAttributeSet=function(e){return this.attributesManager.isAttributeSet(e)},e.prototype.removeAttributeAsync=function(e){return this.attributesManager.removeAttribute(e)},e.prototype.removeAttribute=function(e){this.addToQueue({type:"removeAttribute",name:e}),this.processQueue()},e.prototype.registerModule=function(e){return this.modulesManager.registerModule(e)},e.prototype.removeModule=function(e){return this.modulesManager.removeModule(e)},e.prototype.trackAsync=function(e,t){return n(this,void 0,Promise,function(){var r,n,a,o,s,u,c,l,f,h,p,d,g,v;return i(this,function(i){switch(i.label){case 0:return(r=this.datafileReader.getEvent(e))?(n=r.level||"info",r.deprecated&&this.logger.warn("Event is deprecated",{eventName:e}),a=t instanceof Error?t:void 0,[4,this.validator.validate(r,t)]):(this.logger.error("Event schema not found in datafile",{eventName:e}),[2,null]);case 1:return(o=i.sent()).valid?(s=o.value,r.conditions?[4,this.conditionsChecker.allAreMatched(r.conditions,{eventName:e,eventLevel:n,payload:s})]:[3,3]):(this.logger.warn("Event validation failed",{eventName:e,errors:o.errors}),[2,null]);case 2:if(!i.sent())return this.logger.debug("Event conditions not matched",{eventName:e,conditions:r.conditions}),[2,null];i.label=3;case 3:return r.sample?[4,this.bucketer.isSampled(r.sample,{eventName:e,eventLevel:n,payload:s})]:[3,5];case 4:if(!(v=i.sent()).isSampled)return this.logger.debug("Event sample not matched",{eventName:e,matchedSample:v.matchedSample,bucketedNumber:v.bucketedNumber,bucketKey:v.bucketKey}),[2,null];i.label=5;case 5:return u=s,r.transforms?[4,this.transformer.applyAll(s,r.transforms,{eventName:e,eventLevel:n,payload:s})]:[3,7];case 6:u=i.sent(),i.label=7;case 7:return[4,this.effectsManager.dispatch({eventType:"event_tracked",name:e,value:u})];case 8:i.sent(),c=this.datafileReader.getDestinationNames(),l=0,f=c,i.label=9;case 9:return l<f.length?(h=f[l],(p=this.datafileReader.getDestination(h))?this.modulesManager.transportExists(p.transport)?(d=u,r.destinations&&void 0!==r.destinations[h]?!1!==(g=r.destinations[h])?[3,10]:(this.logger.debug("Event has destination disabled",{eventName:e,destinationName:h}),[3,23]):[3,15]):(this.logger.error("Destination has no transport",{eventName:e,destinationName:h}),[3,23]):[3,23]):[3,24];case 10:return"object"!=typeof g?[3,15]:g.conditions?[4,this.conditionsChecker.allAreMatched(g.conditions,{eventName:e,eventLevel:n,payload:d})]:[3,15];case 11:return i.sent()?g.sample?[4,this.bucketer.isSampled(g.sample,{eventName:e,eventLevel:n,payload:d})]:[3,13]:(this.logger.debug("Destination conditions not matched for event",{eventName:e,destinationName:h}),[3,23]);case 12:if(!(v=i.sent()).isSampled)return this.logger.debug("Destination sample not matched for event",{eventName:e,destinationName:h,matchedSample:v.matchedSample,bucketedNumber:v.bucketedNumber,bucketKey:v.bucketKey}),[3,23];i.label=13;case 13:return g.transforms?[4,this.transformer.applyAll(u,g.transforms,{eventName:e,eventLevel:n,payload:d})]:[3,15];case 14:d=i.sent(),i.label=15;case 15:return p.conditions?[4,this.conditionsChecker.allAreMatched(p.conditions,{eventName:e,eventLevel:n,payload:u})]:[3,17];case 16:if(!i.sent())return this.logger.debug("Destination conditions not matched",{eventName:e,destinationName:h}),[3,23];i.label=17;case 17:return p.sample?[4,this.bucketer.isSampled(p.sample,{eventName:e,eventLevel:n,payload:d})]:[3,19];case 18:if(!(v=i.sent()).isSampled)return this.logger.debug("Destination sample not matched",{eventName:e,destinationName:h}),[3,23];i.label=19;case 19:return p.transforms?[4,this.transformer.applyAll(d,p.transforms,{eventName:e,eventLevel:n,payload:d,destinationName:h,attributes:this.attributesManager.getAttributesMap()})]:[3,21];case 20:d=i.sent(),i.label=21;case 21:return[4,this.modulesManager.transport(p.transport,h,e,d,n,a)];case 22:i.sent(),i.label=23;case 23:return l++,[3,9];case 24:return[2,u]}})})},e.prototype.track=function(e,t){this.addToQueue({type:"track",name:e,value:t}),this.processQueue()},e.prototype.getStateValue=function(e){return this.effectsManager.getStateValue(e)},e.prototype.spawn=function(){},e}();t.Eventvisor=v},357:function(e,t){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Transformer=void 0;var a=function(){function e(e){this.logger=e.logger,this.conditionsChecker=e.conditionsChecker,this.sourceResolver=e.sourceResolver}return e.prototype.applyAll=function(t,a){return n(this,arguments,Promise,function(t,n,a){var o,s,u,c,l,f;return void 0===a&&(a={}),i(this,function(h){switch(h.label){case 0:o=t,s=function(n){var s,c,l,f,h,p,d,g,v,y,m,b,w,M,A;return i(this,function(i){switch(i.label){case 0:return n.conditions?[4,u.conditionsChecker.allAreMatched(n.conditions,a)]:[3,2];case 1:if(!i.sent())return[2,"continue"];i.label=2;case 2:return[4,u.sourceResolver.resolve(n,a)];case 3:return null!=(s=i.sent())?[3,5]:n.target?[4,u.sourceResolver.resolve({payload:n.target},void 0===a.payload?r(r({},a),{payload:t}):a)]:[3,5];case 4:s=i.sent(),i.label=5;case 5:if(n.target)for(c=Array.isArray(n.target)?n.target:[n.target],l=0,f=c;l<f.length;l++)h=f[l],"string"==typeof s&&"trim"===n.type&&(o=e.setValueAtPath(o,h,s.trim())),Array.isArray(s)&&"concat"===n.type&&(p=n.separator||" ",o=e.setValueAtPath(o,h,s.join(p))),"set"===n.type&&(o="value"in n?e.setValueAtPath(o,h,n.value):e.setValueAtPath(o,h,s)),"remove"===n.type&&(o=e.removeValueAt(o,h)),"toInteger"===n.type?o=e.setValueAtPath(o,h,parseInt(String(s))):"toDouble"===n.type?o=e.setValueAtPath(o,h,parseFloat(String(s))):"toString"===n.type?o=e.setValueAtPath(o,h,String(s)||""):"toBoolean"===n.type&&(d=String(s).toLowerCase(),o=e.setValueAtPath(o,h,-1!==["true","1","checked","yes","on","y"].indexOf(d)||!0===s));else"set"===n.type&&"value"in n&&(o=n.value);if("spread"===n.type&&(n.target?(g=e.getValueAtPath(o,n.target),o=e.setValueAtPath(o,n.target,r(r({},g||{}),s||{}))):o=r(r({},o||{}),s||{})),"increment"===n.type?(v="number"==typeof n.value?n.value:1,n.target?o=e.setValueAtPath(o,n.target,Number(s)+v):o+=v):"decrement"===n.type&&(v="number"==typeof n.value?n.value:1,n.target?o=e.setValueAtPath(o,n.target,Number(s)-v):o-=v),n.targetMap){if(y=[],Array.isArray(n.targetMap))for(m=0,b=n.targetMap;m<b.length;m++)A=b[m],Object.entries(A).forEach(function(e){var t,r=e[0],n=e[1];y.push(((t={})[r]=n,t))});else Object.entries(n.targetMap).forEach(function(e){var t,r=e[0],n=e[1];y.push(((t={})[r]=n,t))});for(w=0,M=y;w<M.length;w++)A=M[w],"rename"===n.type&&(o=e.renameValueAt(o,A))}return[2]}})},u=this,c=0,l=n,h.label=1;case 1:return c<l.length?(f=l[c],[5,s(f)]):[3,4];case 2:h.sent(),h.label=3;case 3:return c++,[3,1];case 4:return[2,o]}})})},e.renameValueAt=function(t,r){if(!t||"object"!=typeof t)return t;if(!r||"object"!=typeof r)return t;var n=Object.entries(r);if(0===n.length)return t;var i=n[0],a=i[0],o=i[1];if(!a||!o)return t;var s=e.getValueAtPath(t,a);if(void 0===s)return t;for(var u=JSON.parse(JSON.stringify(t)),c=a.split("."),l=u,f=0;f<c.length-1;f++){var h=c[f];if(void 0===l[h])return u;l=l[h]}return delete l[c[c.length-1]],e.setValueAtPath(u,o,s)},e.getValueAtPath=function(e,t){if(t&&"string"==typeof t){for(var r=e,n=0,i=t.split(".");n<i.length;n++){var a=i[n];if(null==r)return;if("object"!=typeof r||Array.isArray(r)){if(!Array.isArray(r)||!/^\d+$/.test(a))return;r=r[parseInt(a)]}else r=r[a]}return r}},e.setValueAtPath=function(e,t,r){if(!t||"string"!=typeof t)return e;if(null==e)return e;for(var n=JSON.parse(JSON.stringify(e)),i=t.split("."),a=n,o=0;o<i.length-1;o++){var s=i[o];void 0===a[s]&&(/^\d+$/.test(i[o+1])?a[s]=[]:a[s]={}),a=a[s]}return a[i[i.length-1]]=r,n},e.removeValueAt=function(e,t){if(!t||"string"!=typeof t)return e;if(null==e)return e;for(var r=JSON.parse(JSON.stringify(e)),n=t.split("."),i=r,a=0;a<n.length-1;a++){var o=n[a];if(void 0===i[o])return r;i=i[o]}var s=n[n.length-1];return Array.isArray(i)?/^\d+$/.test(s)&&i.splice(parseInt(s),1):"object"==typeof i&&null!==i&&delete i[s],r},e}();t.Transformer=a},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHashV3=function(e,t){var n,i,a,o,s,u,c,l;for("string"==typeof e&&(e=r(e)),n=3&e.length,i=e.length-n,a=t,s=3432918353,u=461845907,l=0;l<i;)c=255&e[l]|(255&e[++l])<<8|(255&e[++l])<<16|(255&e[++l])<<24,++l,a=27492+(65535&(o=5*(65535&(a=(a^=c=(65535&(c=(c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295)<<15|c>>>17))*u+(((c>>>16)*u&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+(((o>>>16)+58964&65535)<<16);switch(c=0,n){case 3:c^=(255&e[l+2])<<16;case 2:c^=(255&e[l+1])<<8;case 1:a^=c=(65535&(c=(c=(65535&(c^=255&e[l]))*s+(((c>>>16)*s&65535)<<16)&4294967295)<<15|c>>>17))*u+(((c>>>16)*u&65535)<<16)&4294967295}return a^=e.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0};var r=function(e){return(new TextEncoder).encode(e)}},420:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.ModulesManager=void 0;var i=function(){function e(e){var t=e.logger,r=e.getDatafileReader,n=e.getSourceResolver;this.logger=t,this.getDatafileReader=r,this.getSourceResolver=n,this.modules=[]}return e.prototype.registerModule=function(e){this.modules.find(function(t){return t.name===e.name})?this.logger.error("Module ".concat(e.name," already registered")):this.modules.push(e)},e.prototype.getModule=function(e){return this.modules.find(function(t){return t.name===e})},e.prototype.removeModule=function(e){this.getModule(e)?this.modules=this.modules.filter(function(t){return t.name!==e}):this.logger.error("Module ".concat(e," not found"))},e.prototype.getModuleDependencies=function(){return{datafileReader:this.getDatafileReader(),logger:this.logger,sourceResolver:this.getSourceResolver()}},e.prototype.lookup=function(e){return r(this,void 0,Promise,function(){var t,r,i,a,o,s;return n(this,function(n){switch(n.label){case 0:if(t=e.split("."),r=t[0],i=t.slice(1),a=i.join("."),!(o=this.getModule(r))||!o.lookup)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,o.lookup({key:a},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return s=n.sent(),this.logger.error("Error in lookup",{moduleName:r,key:a,error:s}),[2,null];case 4:return this.logger.error('Module "'.concat(r,'" not found with "lookup" function')),[2,null]}})})},e.prototype.handle=function(e,t,i,a,o){return r(this,void 0,Promise,function(){var r,s,u,c;return n(this,function(n){switch(n.label){case 0:if(r=e.split("."),s=r[0],r[1],!(u=this.getModule(s))||!u.handle)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,u.handle({effectName:t,effect:i,step:a,payload:o},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return c=n.sent(),this.logger.error("Error in handle",{moduleName:s,effectName:t,error:c}),[2];case 4:return this.logger.error('Module "'.concat(s,'" not found with "handle" function')),[2]}})})},e.prototype.transportExists=function(e){var t=e.split("."),r=t[0],n=(t[1],this.getModule(r));return!(!n||!n.transport)},e.prototype.transport=function(e,t,i,a,o,s){return r(this,void 0,Promise,function(){var r,u,c,l;return n(this,function(n){switch(n.label){case 0:if(r=e.split("."),u=r[0],r[1],!(c=this.getModule(u))||!c.transport)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,c.transport({destinationName:t,eventName:i,eventLevel:o,payload:a,error:s},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return l=n.sent(),this.logger.error("Error in transport",{moduleName:u,destinationName:t,eventName:i,error:l}),[2];case 4:return this.logger.error('Module "'.concat(u,'" not found with "transport" function')),[2]}})})},e.prototype.readFromStorage=function(e,t){return r(this,void 0,Promise,function(){var r,i;return n(this,function(n){switch(n.label){case 0:if(!(r=this.getModule(e))||!r.readFromStorage)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.readFromStorage({key:t},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return i=n.sent(),this.logger.error("Error in readFromStorage",{moduleName:e,key:t,error:i}),[2,null];case 4:return this.logger.error('Module "'.concat(e,'" not found with "readFromStorage" function')),[2,null]}})})},e.prototype.writeToStorage=function(e,t,i){return r(this,void 0,Promise,function(){var r,a;return n(this,function(n){switch(n.label){case 0:if(!(r=this.getModule(e))||!r.writeToStorage)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.writeToStorage({key:t,value:i},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return a=n.sent(),this.logger.error("Error in writeToStorage",{moduleName:e,key:t,value:i,error:a}),[2];case 4:return this.logger.error('Module "'.concat(e,'" not found with "writeToStorage" function')),[2]}})})},e.prototype.removeFromStorage=function(e,t){return r(this,void 0,Promise,function(){var r,i;return n(this,function(n){switch(n.label){case 0:if(!(r=this.getModule(e))||!r.removeFromStorage)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.removeFromStorage({key:t},this.getModuleDependencies())];case 2:return[2,n.sent()];case 3:return i=n.sent(),this.logger.error("Error in removeFromStorage",{moduleName:e,key:t,error:i}),[2];case 4:return this.logger.error('Module "'.concat(e,'" not found with "removeFromStorage" function')),[2]}})})},e}();t.ModulesManager=i},470:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.AttributesManager=void 0;var a=r(53),o=function(){function e(e){var t=e.logger,r=e.getDatafileReader,n=e.emitter,i=e.getTransformer,a=e.getConditionsChecker,o=e.validator,s=e.modulesManager;this.logger=t,this.getDatafileReader=r,this.emitter=n,this.getTransformer=i,this.getConditionsChecker=a,this.validator=o,this.modulesManager=s,this.attributesMap={}}return e.prototype.initialize=function(){return n(this,void 0,Promise,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.initializeFromStorage()];case 1:return e.sent(),[2]}})})},e.prototype.initializeFromStorage=function(){return n(this,void 0,Promise,function(){var e,t;return i(this,function(r){switch(r.label){case 0:return e=this.getDatafileReader(),[4,(0,a.initializeFromStorage)({datafileReader:e,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"attributes_",getEntityNames:function(){return e.getAttributeNames()},getEntity:function(t){return e.getAttribute(t)}})];case 1:return t=r.sent(),this.attributesMap=t,[2]}})})},e.prototype.setAttribute=function(e,t){return n(this,void 0,Promise,function(){var r,n,o,s,u,c;return i(this,function(i){switch(i.label){case 0:return r=this.getDatafileReader(),(n=r.getAttribute(e))?(n.deprecated&&this.logger.warn("Attribute is deprecated",{attributeName:e}),[4,this.validator.validate(n,t)]):(this.logger.error("Attribute schema not found",{attributeName:e}),[2,null]);case 1:return(o=i.sent()).valid?(s=o.value,n.transforms?[4,this.getTransformer().applyAll(s,n.transforms,{payload:s,attributeName:e})]:[3,3]):(this.logger.warn("Attribute validation failed",{attributeName:e,errors:o.errors}),[2,null]);case 2:return c=i.sent(),[3,4];case 3:c=s,i.label=4;case 4:return u=c,this.attributesMap[e]=u,this.emitter.trigger("attribute_set",{attributeName:e}),this.logger.debug("Attribute set",{attributeName:e}),[4,(0,a.persistEntity)({datafileReader:r,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"attributes_",entityName:e,entity:n,value:t})];case 5:return i.sent(),[2,u]}})})},e.prototype.isAttributeSet=function(e){return void 0!==this.attributesMap[e]},e.prototype.getAttributesMap=function(){return this.attributesMap},e.prototype.getAttributeValue=function(e){return this.attributesMap[e]||null},e.prototype.removeAttribute=function(e){return n(this,void 0,Promise,function(){var t;return i(this,function(r){switch(r.label){case 0:return t=this.getDatafileReader(),[4,(0,a.removeEntity)({datafileReader:t,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"attributes_",entityName:e,entity:t.getAttribute(e)})];case 1:return r.sent(),delete this.attributesMap[e],this.emitter.trigger("attribute_removed",{attributeName:e}),[2]}})})},e}();t.AttributesManager=o},481:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Bucketer=t.BucketerOptions=t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=u;var a=r(400),o=1,s=Math.pow(2,32);function u(e){var r=(0,a.MurmurHashV3)(e,o)/s;return Math.floor(r*t.MAX_BUCKETED_NUMBER)}t.MAX_BUCKETED_NUMBER=1e5;t.BucketerOptions=function(){};var c=function(){function e(e){this.logger=e.logger,this.sourceResolver=e.sourceResolver,this.conditionsChecker=e.conditionsChecker,this.transformer=e.transformer}return e.prototype.getBucketKey=function(e,t){return n(this,void 0,Promise,function(){var r,n,a,o,s,u,c;return i(this,function(i){switch(i.label){case 0:if("string"==typeof e)r="plain",n=[e];else if(Array.isArray(e))r="and",n=e;else if("object"==typeof e&&"or"in e&&Array.isArray(e.or))r="or",n=e.or;else{if("object"!=typeof e)throw this.logger.error("invalid sampleBy",{sampleBy:e}),new Error("invalid sampleBy");r="and",n=[e]}a=[],o=0,s=n,i.label=1;case 1:return o<s.length?(u=s[o],[4,this.sourceResolver.resolve(u,t)]):[3,4];case 2:if(void 0===(c=i.sent()))return[3,3];("plain"===r||"and"===r||0===a.length)&&a.push(String(c)),i.label=3;case 3:return o++,[3,1];case 4:return[2,a.join(".")]}})})},e.prototype.isSampled=function(e,t){return n(this,void 0,Promise,function(){var r,a,o,s,c=this;return i(this,function(l){switch(l.label){case 0:return r=Array.isArray(e)?e:[e],a=r.find(function(e){return n(c,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return e.conditions?[4,this.conditionsChecker.allAreMatched(e.conditions,t)]:[2,!0];case 1:return[2,r.sent()]}})})}),a?[4,this.getBucketKey(a.by,t)]:[3,2];case 1:if(o=l.sent(),s=u(o),a.percentage&&a.percentage>0&&s<a.percentage)return[2,{isSampled:!1,matchedSample:a,bucketedNumber:s,bucketKey:o}];if(a.range&&s<a.range[0]&&s>a.range[1])return[2,{isSampled:!1,matchedSample:a,bucketedNumber:s,bucketKey:o}];l.label=2;case 2:return[2,{isSampled:!0}]}})})},e}();t.Bucketer=c},584:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.loggerPrefix=void 0,t.createLogger=function(e){return void 0===e&&(e={}),new r(e)},t.loggerPrefix="[Eventvisor]",t.defaultLogHandler=function(e,r,n){void 0===n&&(n={});var i="log";"info"===e?i="info":"warn"===e?i="warn":"error"===e&&(i="error"),console[i](t.loggerPrefix,r,n)};var r=function(){function e(r){this.level=r.level||e.defaultLevel,this.handle=r.handler||t.defaultLogHandler}return e.prototype.setLevel=function(e){this.level=e},e.prototype.log=function(t,r,n){e.allLevels.indexOf(this.level)>=e.allLevels.indexOf(t)&&this.handle(t,r,n)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e.allLevels=["fatal","error","warn","info","debug"],e.defaultLevel="info",e}();t.Logger=r},649:(e,t)=>{function r(e){var t=[];if("string"==typeof e)t.push({storage:e});else if(Array.isArray(e))for(var n=0,i=e;n<i.length;n++){var a=r(i[n]);a&&(t=t.concat(a))}else"object"==typeof e&&t.push(e);return t}Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=t.emptyDatafile=void 0,t.getComplexPersists=r,t.emptyDatafile={schemaVersion:"1",revision:"0",attributes:{},events:{},destinations:{},effects:{}};var n=function(){function e(e){var t=e.datafile,r=e.logger;this.datafile=t,this.schemaVersion=t.schemaVersion,this.revision=t.revision,this.regexCache={},this.logger=r}return e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getRevision=function(){return this.revision},e.prototype.getAttribute=function(e){return this.datafile.attributes[e]},e.prototype.getAttributeNames=function(){return Object.keys(this.datafile.attributes)},e.prototype.getEvent=function(e){return this.datafile.events[e]},e.prototype.getDestination=function(e){return this.datafile.destinations[e]},e.prototype.getDestinationNames=function(){return Object.keys(this.datafile.destinations)},e.prototype.getEffect=function(e){return this.datafile.effects[e]},e.prototype.getEffectNames=function(){return Object.keys(this.datafile.effects)},e.prototype.getRegex=function(e,t){var r=t||"",n="".concat(e,"-").concat(r);if(this.regexCache[n])return this.regexCache[n];var i=new RegExp(e,r);return this.regexCache[n]=i,i},e.prototype.getPersists=function(e){return e&&e.persist?r(e.persist):null},e}();t.DatafileReader=n},681:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.EffectsManager=void 0;var a=r(53),o=function(){function e(e){this.statesByEffect={},this.logger=e.logger,this.getDatafileReader=e.getDatafileReader,this.getTransformer=e.getTransformer,this.getConditionsChecker=e.getConditionsChecker,this.modulesManager=e.modulesManager}return e.prototype.initialize=function(){return n(this,void 0,Promise,function(){var e,t,r,n,o,s,u;return i(this,function(i){switch(i.label){case 0:return e=this.getDatafileReader(),t=e.getEffectNames(),[4,(0,a.initializeFromStorage)({datafileReader:e,conditionsChecker:this.getConditionsChecker(),modulesManager:this.modulesManager,storageKeyPrefix:"effects_",getEntityNames:function(){return e.getEffectNames()},getEntity:function(t){return e.getEffect(t)}})];case 1:for(r=i.sent(),n=0,o=t;n<o.length;n++)s=o[n],(u=e.getEffect(s))&&void 0===this.statesByEffect[s]&&(void 0!==r[s]?this.statesByEffect[s]=r[s]:void 0!==u.state&&void 0===this.statesByEffect[s]&&(this.statesByEffect[s]=u.state));return[2]}})})},e.prototype.dispatch=function(e){return n(this,void 0,void 0,function(){var t,r,n,o,s,u,c,l,f,h,p,d,g,v,y,m,b,w,M,A;return i(this,function(i){switch(i.label){case 0:t=e.eventType,r=e.name,n=e.value,o=this.getDatafileReader(),s=this.getConditionsChecker(),u=this.getTransformer(),c=o.getEffectNames(),l=0,f=c,i.label=1;case 1:if(!(l<f.length))return[3,16];if(h=f[l],!(p=o.getEffect(h)))return[3,15];if("event_tracked"===t){if(Array.isArray(p.on)&&!p.on.includes("event_tracked"))return[3,15];if("object"==typeof p.on&&!(null===(M=p.on.event_tracked)||void 0===M?void 0:M.includes(r)))return[3,15]}if("attribute_set"===t){if(Array.isArray(p.on)&&!p.on.includes("attribute_set"))return[3,15];if("object"==typeof p.on&&!(null===(A=p.on.attribute_set)||void 0===A?void 0:A.includes(r)))return[3,15]}return p.conditions?[4,s.allAreMatched(p.conditions,{payload:n,eventName:"event_tracked"===t?r:void 0,attributeName:"attribute_set"===t?r:void 0,state:this.statesByEffect[h]})]:[3,3];case 2:if(!i.sent())return[3,15];i.label=3;case 3:if(!p.steps)return[3,13];d=0,g=p.steps,i.label=4;case 4:return d<g.length?(v=g[d],y=!0,v.conditions?[4,this.getConditionsChecker().allAreMatched(v.conditions,{payload:n,eventName:"event_tracked"===t?r:void 0,attributeName:"attribute_set"===t?r:void 0,state:this.statesByEffect[h]})]:[3,6]):[3,13];case 5:if(!i.sent())return[3,12];i.label=6;case 6:if(!v.handler)return[3,10];i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.modulesManager.handle(v.handler,h,p,v,n)];case 8:return i.sent(),[3,10];case 9:return m=i.sent(),this.logger.error("Effect handler error",{effectName:h,step:v,error:m}),y=!1,[3,10];case 10:return y||"boolean"!=typeof v.continueOnError||v.continueOnError?v.transforms?(b=this.statesByEffect,w=h,[4,u.applyAll(this.statesByEffect[h],v.transforms,{eventName:"event_tracked"===t?r:void 0,attributeName:"attribute_set"===t?r:void 0,state:this.statesByEffect[h]})]):[3,12]:[3,13];case 11:b[w]=i.sent(),i.label=12;case 12:return d++,[3,4];case 13:return[4,(0,a.persistEntity)({datafileReader:o,conditionsChecker:s,modulesManager:this.modulesManager,storageKeyPrefix:"effects_",entityName:h,entity:p,value:this.statesByEffect[h]})];case 14:i.sent(),i.label=15;case 15:return l++,[3,1];case 16:return[2]}})})},e.prototype.refresh=function(){this.initialize()},e.prototype.getAllStates=function(){return this.statesByEffect},e.prototype.getStateValue=function(e){return this.statesByEffect[e]},e}();t.EffectsManager=o},972:function(e,t){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=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.Validator=void 0,t.validate=o;var a=function(){function e(e){this.logger=e.logger,this.getSourceResolver=e.getSourceResolver}return e.prototype.validate=function(e,t){return o(e,t,{})},e}();function o(e,t,r){return n(this,void 0,Promise,function(){var n,a;return i(this,function(i){return void 0===(a=s(e,t,"",n=[],r))&&0===n.length&&void 0!==e.default?[2,{valid:!0,value:e.default,errors:[]}]:[2,{valid:0===n.length,errors:n.length>0?n:void 0,value:a}]})})}function s(e,t,n,i,a){var o,u;if(null===t){if("null"===e.type||(null===(o=e.enum)||void 0===o?void 0:o.includes(null)))return t;if(e.type&&"null"!==e.type)return void i.push({path:n,message:"Expected type ".concat(e.type,", got null"),schema:e,value:t})}if(void 0===t)return void 0!==e.default?e.default:e.type?void i.push({path:n,message:"Required field missing",schema:e,value:t}):void 0;if(e.type&&"integer"!==e.type){var c=function(e,t){switch(e){case"string":return"string"==typeof t;case"number":return"number"==typeof t;case"integer":return"number"==typeof t&&Number.isInteger(t);case"boolean":return"boolean"==typeof t;case"null":return null===t;case"object":return"object"==typeof t&&null!==t&&!Array.isArray(t);case"array":return Array.isArray(t);default:return!0}}(e.type,t);if(!c)return void i.push({path:n,message:"Expected type ".concat(e.type,", got ").concat(typeof t),schema:e,value:t})}if(void 0===e.const||t===e.const)if(!e.enum||e.enum.includes(t)){var l=t;if("object"==typeof t&&!Array.isArray(t)&&e.properties){var f;f=t instanceof Error?r({name:t.name,message:t.message,stack:t.stack},t):t;var h={};if(e.required)for(var p=0,d=e.required;p<d.length;p++){var g=d[p];g in f||(void 0!==(null===(u=e.properties[g])||void 0===u?void 0:u.default)?h[g]=e.properties[g].default:i.push({path:n?"".concat(n,".").concat(g):g,message:"Required property '".concat(g,"' is missing"),schema:e.properties[g],value:void 0}))}for(var v=0,y=Object.entries(f);v<y.length;v++){var m=y[v],b=m[0],w=m[1];if(e.properties&&e.properties[b]){var M=s(_=e.properties[b],w,n?"".concat(n,".").concat(b):b,i,a);void 0!==M&&(h[b]=M)}else h[b]=w}if(e.properties)for(var A=0,k=Object.entries(e.properties);A<k.length;A++){var x=k[A],_=(b=x[0],x[1]);b in h||void 0===_.default||(h[b]=_.default)}l=h}if(Array.isArray(t)){if(void 0!==e.minItems&&t.length<e.minItems)return void i.push({path:n,message:"Array must have at least ".concat(e.minItems," items, got ").concat(t.length),schema:e,value:t});if(void 0!==e.maxItems&&t.length>e.maxItems)return void i.push({path:n,message:"Array must have at most ".concat(e.maxItems," items, got ").concat(t.length),schema:e,value:t});if(e.items){var S=[];if(Array.isArray(e.items))for(var E=0;E<t.length;E++){var P=e.items[E];if(P){var N="".concat(n,"[").concat(E,"]");void 0!==(O=s(P,t[E],N,i,a))&&S.push(O)}else S.push(t[E])}else for(E=0;E<t.length;E++){var O;N="".concat(n,"[").concat(E,"]"),void 0!==(O=s(e.items,t[E],N,i,a))&&S.push(O)}l=S}else l=t}if("string"==typeof t){if(void 0!==e.minLength&&t.length<e.minLength)return void i.push({path:n,message:"String must be at least ".concat(e.minLength," characters long"),schema:e,value:t});if(void 0!==e.maxLength&&t.length>e.maxLength)return void i.push({path:n,message:"String must be at most ".concat(e.maxLength," characters long"),schema:e,value:t});if(e.pattern&&!new RegExp(e.pattern).test(t))return void i.push({path:n,message:"String must match pattern: ".concat(e.pattern),schema:e,value:t})}if("number"==typeof t){if(void 0!==e.minimum&&t<e.minimum)return void i.push({path:n,message:"Number must be at least ".concat(e.minimum),schema:e,value:t});if(void 0!==e.maximum&&t>e.maximum)return void i.push({path:n,message:"Number must be at most ".concat(e.maximum),schema:e,value:t});if("integer"===e.type&&!Number.isInteger(t))return void i.push({path:n,message:"Number must be an integer",schema:e,value:t})}if("integer"!==e.type||"number"==typeof t)return l;i.push({path:n,message:"Expected type integer, got ".concat(typeof t),schema:e,value:t})}else i.push({path:n,message:"Value must be one of: ".concat(e.enum.map(function(e){return JSON.stringify(e)}).join(", ")),schema:e,value:t});else i.push({path:n,message:"Value must be exactly ".concat(JSON.stringify(e.const)),schema:e,value:t})}t.Validator=a}},t={};return function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(166)})());
|
|
2
2
|
//# sourceMappingURL=index.js.map
|