UNPKG

@hackler/js-client-sdk

Version:

JavaScript Client(Web Browser) SDK

1 lines 119 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Hackle={})}(this,function(e){"use strict";var t,n,i,r,o,s,a,f,u,c,l,p,h,d,v,y,g,m,w,E,T,b,O,R,_,A,N,I,x,S,k,C,M,P,L,D,U,F,j,V,G,H,B,z,K,q,X,W,Y,$,Z,Q,J,ee,te,re=function(){return(re=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}).apply(this,arguments)},ne="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},ie={exports:{}};function oe(){}function se(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function ae(e,t,r){this.id=e,this.key=t,this.isDropped=r}function ue(e,t,r){this.seed=e,this.slotSize=t,this.slots=r}function ce(e,t){this.id=e,this.key=t}function fe(e){this.conditions=e}function le(e,t){this.key=e,this.match=t}function pe(e,t){this.type=e,this.name=t}function he(e,t,r,n){this.type=e,this.operator=t,this.valueType=r,this.values=n}function de(e,t,r){this.type=e,this.variationId=t,this.bucketId=r}function ve(e,t){this.target=e,this.action=t}function ye(e,t,r,n){this.id=e,this.key=t,this.type=r,this.targets=n}function ge(e,t){this.id=e,this.experiments=t}function me(e,t,r){this.id=e,this.bucketId=t,this.groups=r}function we(){this.identifiers={}}function Ee(){}function Te(e,t,r){this.startInclusive=e,this.endExclusive=t,this.variationId=r}function be(e,t,r,n,i,o,s,a,u,c,f,l,p,h){this.id=e,this.key=t,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=s,this.userOverrides=a,this.segmentOverrides=u,this.targetAudiences=c,this.targetRules=f,this.defaultRule=l,this.containerId=p,this._winnerVariationId=h}function Oe(){}function Re(e,t){this.isOn=e,this.reason=t}function _e(e,t){this.variation=e,this.reason=t}function Ae(e,t,r){void 0===t&&(t=1e3),void 0===r&&(r=Ae.DEFAULT_FLUSH_INTERVAL),this.flushInterval=Ae.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=r,this.queue=new ee(this.drainQueue.bind(this),At,t,r)}function Ne(e,t,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=e,this.maxQueueSize=r,this.batchComparator=t,this.timer=new J({callback:this.flush.bind(this),timeout:n}),this.started=!1}function Ie(e){var t=e.timeout,e=e.callback;this.timeout=Math.max(t,0),this.callback=e}function xe(e,t,r){this.evaluator=new x(new Z),this.workspaceFetcher=e,this.eventProcessor=t,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then(function(){return{success:!0}},function(e){return{success:!1,error:e}})}function Se(){var e=new L,t=new S(new C),r=new M(e),n=new Y(t,r),e=new $(e);this.abTestFlow=D.of(new U(n),new q,new K(e),new G(new X(t)),new F,new j,new V,new H(r)),this.featureFlagFlow=D.of(new F,new j,new V,new U(n),new q,new B(new W(t),r),new z(r))}function ke(e){this.bucketer=e}function Ce(e,t){this.targetMatcher=e,this.actionResolver=t}function Me(e){this.targetMatcher=e}function Pe(e){this.targetMatcher=e}function Le(){}function De(e){this.containerResolver=e}function Ue(e){this.actionResolver=e}function Fe(e,t){this.targetRuleDeterminer=e,this.actionResolver=t}function je(e){this.actionResolver=e}function Ve(e){this.experimentTargetDeterminer=e}function Ge(){}function He(){}function Be(){}function ze(e){this.overrideResolver=e}function Ke(e,t){void 0===t&&(t=void 0),this.flowEvaluator=e=void 0===e?void 0:e,this.nextFlow=t}function qe(){}function Xe(e){this.bucketer=e}function We(){}function Ye(e){this.userConditionMatcher=e}function $e(e){this.segmentMatcher=e}function Ze(){}function Qe(e,t){this.userValueResolver=e,this.valueOperatorMatcher=t}function Je(){}function et(){}function tt(){}function rt(){}function nt(){}function it(){}function ot(){}function st(){}function at(){}function ut(){}function ct(){}function ft(){}function lt(){}function pt(){}function ht(){}function dt(e,t){this.valueMatcherFactory=e,this.operatorMatcherFactory=t}function vt(e){this.conditionMatcherFactory=e}function yt(e){this.evaluationFlowFactory=e}function gt(e,t,r){this.variationId=e,this.variationKey=t,this.reason=r}function mt(e,t,r,n){t=p.call(this,e,t)||this;return t.eventType=r,t.event=n,t}function wt(e,t,r,n,i,o){t=h.call(this,e,t)||this;return t.experiment=r,t.variationId=n,t.variationKey=i,t.decisionReason=o,t}function Et(e,t){this.timestamp=e,this.user=t}function Tt(){}function bt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.supportedKeyTypes=e}function Ot(e){this.identifiers=e}function Rt(e,t,r){this.major=e,this.minor=t,this.patch=r}function _t(e,t,r){this.coreVersion=e,this.prerelease=t,this.build=r}function At(e,t){return e.timestamp==t.timestamp&&e.user.identifiers==t.user.identifiers&&e.user.properties==t.user.properties}function Nt(e,t,r,n,i,o){this.experiments=e,this.featureFlags=t,this.buckets=r,this.eventTypes=n,this.segments=i,this.containers=o}vn=ie.exports,Cn=vn,t={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},oe.setLogLevel=function(e){this.logLevel=e=void 0===e?t.INFO:e},oe._log=function(e,t){var r;switch(e){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(e,"] Hackle: ").concat(t),"color: ".concat(r))}catch(e){}},oe.logLevel=t.INFO,oe.log={error:function(e){t.ERROR<=oe.logLevel&&oe._log("ERROR",e)},warn:function(e){t.WARN<=oe.logLevel&&oe._log("WARN",e)},info:function(e){t.INFO<=oe.logLevel&&oe._log("INFO",e)},debug:function(e){t.DEBUG<=oe.logLevel&&oe._log("DEBUG",e)}},n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},i=function(){return(i=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}).apply(this,arguments)},r=(Sn=oe).log,_e.of=function(e,t){return new _e(e,t)},o=_e,Re.on=function(e){return new Re(!0,e)},Re.off=function(e){return new Re(!1,e)},s=Re,Oe.SDK_NOT_READY="SDK_NOT_READY",Oe.EXCEPTION="EXCEPTION",Oe.INVALID_INPUT="INVALID_INPUT",Oe.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",Oe.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",Oe.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",Oe.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",Oe.OVERRIDDEN="OVERRIDDEN",Oe.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",Oe.NOT_IN_MUTUAL_EXCLUSION_EXPERIMENT="NOT_IN_MUTUAL_EXCLUSION_EXPERIMENT",Oe.IDENTIFIER_NOT_FOUND="IDENTIFIER_NOT_FOUND",Oe.VARIATION_DROPPED="VARIATION_DROPPED",Oe.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",Oe.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",Oe.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",Oe.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",Oe.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",Oe.TARGET_RULE_MATCH="TARGET_RULE_MATCH",Oe.DEFAULT_RULE="DEFAULT_RULE",a=Oe,be.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},be.prototype._getVariationByIdOrNull=function(t){return this.variations.find(function(e){return e.id===t})},be.prototype._getVariationByKeyOrNull=function(t){return this.variations.find(function(e){return e.key===t})},f=be,Te.prototype.contains=function(e){return this.startInclusive<=e&&e<this.endExclusive},u=Te,Ee.ID="$id",Ee.USER="$userId",Ee.DEVICE="$deviceId",c=Ee,we.prototype.addIdentifiers=function(e){for(var t in e)this.add(t,e[t]);return this},we.prototype.add=function(e,t){return t&&this._isValid(e,t)?this.identifiers[e]=t:r.warn("Invalid user identifier [type=".concat(e,", value=").concat(t,"]")),this},we.prototype._isValid=function(e,t){return!(!e||"string"!=typeof e||128<e.length||!t||"string"!=typeof t||512<t.length)},we.prototype.build=function(){return this.identifiers},On=we,me.prototype.getGroupOrNull=function(t){return this.groups.find(function(e){return e.id===t})},l=me,_t.tryParse=function(e){var s=_t.regExp.exec(e);if(s){var t=function(e){var t="function"==typeof Symbol&&s[Symbol.iterator];if(!t)return s;var r,n,i=t.call(s),o=[];try{for(;(void 0===e||0<e--)&&!(r=i.next()).done;)o.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(n)throw n.error}}return o}(6);t[0];var r=t[1],n=t[2],i=void 0===n?"0":n,e=t[3],n=void 0===e?"0":e,e=t[4],t=t[5];return new _t(new v(parseInt(r,10),parseInt(i,10),parseInt(n,10)),y.parse(e),y.parse(t))}},_t.prototype.compareTo=function(e){return this.coreVersion.compareTo(e.coreVersion)||this.prerelease.compareTo(e.prerelease)},_t.prototype.isEqualTo=function(e){return 0===this.compareTo(e)},_t.prototype.isGreaterThan=function(e){return 0<this.compareTo(e)},_t.prototype.isGreaterThanOrEqualTo=function(e){return 0<=this.compareTo(e)},_t.prototype.isLessThan=function(e){return this.compareTo(e)<0},_t.prototype.isLessThanOrEqualTo=function(e){return this.compareTo(e)<=0},_t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,d=_t,Rt.prototype.compareTo=function(e){return this.major-e.major||this.minor-e.minor||this.patch-e.patch},v=Rt,Ot.parse=function(e){return e?new Ot(e.split(".")):Ot.EMPTY},Ot.prototype.isEmpty=function(){return 0===this.identifiers.length},Ot.prototype.isNotEmpty=function(){return!this.isEmpty()},Ot.prototype.compareTo=function(e){return this.isEmpty()&&e.isEmpty()?0:this.isEmpty()&&e.isNotEmpty()?1:this.isNotEmpty()&&e.isEmpty()?-1:this.compareIdentifiers(e)},Ot.prototype.compareIdentifiers=function(e){for(var t=Math.min(this.identifiers.length,e.identifiers.length),r=0;r<t;r++){var n=Ot.compareIdentifiers(this.identifiers[r],e.identifiers[r]);if(0!==n)return n}return this.identifiers.length-e.identifiers.length},Ot.compareIdentifiers=function(e,t){return Ot.numericIdentifierRegExp.test(e)&&Ot.numericIdentifierRegExp.test(t)?+e-+t:e===t?0:e<t?-1:1},Ot.EMPTY=new Ot([]),Ot.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,y=Ot,g=["MATCH","NOT_MATCH"],m=["STRING","NUMBER","BOOLEAN","VERSION"],w=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],E=["VARIATION","BUCKET"],T=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],b=["USER_ID","USER_PROPERTY"],bt.prototype.supports=function(e){return this.supportedKeyTypes.includes(e)},bt.IDENTIFIER=new bt("SEGMENT"),bt.PROPERTY=new bt("SEGMENT","USER_PROPERTY","HACKLE_PROPERTY"),bt.SEGMENT=new bt("USER_ID","USER_PROPERTY","HACKLE_PROPERTY"),O=bt,Tt.validate=function(e){if(e){if("object"!=typeof e)return!1;for(var t in e)if(!this.validProperty(t,e[t]))return!1}return!0},Tt.filteredProperties=function(r){var n=this;return Object.keys(r).filter(function(e){return n.validProperty(e,r[e])}).reduce(function(e,t){return i(i({},e),((e={})[t]=n.filteredPropertiesValue(r[t]),e))},{})},Tt.filteredPropertiesValue=function(e){return"string"==typeof e&&1024<e.length?e.slice(0,1024):e},Tt.validProperty=function(e,t){return!!e&&"string"==typeof e&&!(128<e.length)&&("string"==typeof t||"boolean"==typeof t||"number"==typeof t&&!isNaN(t)&&isFinite(t))},R=Tt,Et.exposure=function(e,t,r){return new A((new Date).getTime(),t,e,r.variationId,r.variationKey,r.reason)},Et.track=function(e,t,r){return new N((new Date).getTime(),r,e,t)},Et.isExposure=function(e){return void 0!==e.experiment},Et.isTrack=function(e){return void 0!==e.eventType},se(wt,h=_=Et),wt.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[c.ID],identifiers:this.user.identifiers,userProperties:R.filteredProperties(this.user.properties||{}),hackleProperties:R.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},A=wt,se(mt,p=_),mt.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[c.ID],identifiers:this.user.identifiers,userProperties:R.filteredProperties(this.user.properties||{}),hackleProperties:R.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:R.filteredProperties(this.event.properties||{})}},N=mt,gt.withVariation=function(e,t){return new gt(e.id,e.key,t)},gt.withKey=function(e,t){return new gt(void 0,e,t)},gt.of=function(e,t,r){e=e._getVariationByKeyOrNull(t);return e?gt.withVariation(e,r):gt.withKey(t,r)},I=gt,yt.prototype.evaluate=function(e,t,r,n){return this.evaluationFlowFactory.getFlow(t.type).evaluate(e,t,r,n)},x=yt,vt.prototype.matches=function(e,t,r){var n=this;return e.conditions.every(function(e){return n._matches(e,t,r)})},vt.prototype._matches=function(e,t,r){return this.conditionMatcherFactory.getMatcher(e.key.type).matches(e,t,r)},S=vt,dt.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),i=e.values.some(function(e){return r.matches(n,t,e)});return this._matches(e.type,i)},dt.prototype._matches=function(e,t){switch(e){case"MATCH":return t;case"NOT_MATCH":return!t}},dn=dt,ht.prototype.booleanMatches=function(e,t){return e===t},ht.prototype.numberMatches=function(e,t){return e===t},ht.prototype.stringMatches=function(e,t){return e===t},ht.prototype.versionMatches=function(e,t){return e.isEqualTo(t)},zr=ht,pt.prototype.booleanMatches=function(e,t){return!1},pt.prototype.numberMatches=function(e,t){return!1},pt.prototype.stringMatches=function(e,t){return e.includes(t)},pt.prototype.versionMatches=function(e,t){return!1},cn=pt,lt.prototype.booleanMatches=function(e,t){return!1},lt.prototype.numberMatches=function(e,t){return!1},lt.prototype.stringMatches=function(e,t){return e.startsWith(t)},lt.prototype.versionMatches=function(e,t){return!1},wn=lt,ft.prototype.booleanMatches=function(e,t){return!1},ft.prototype.numberMatches=function(e,t){return!1},ft.prototype.stringMatches=function(e,t){return e.endsWith(t)},ft.prototype.versionMatches=function(e,t){return!1},fn=ft,ct.prototype.booleanMatches=function(e,t){return!1},ct.prototype.numberMatches=function(e,t){return t<e},ct.prototype.stringMatches=function(e,t){return!1},ct.prototype.versionMatches=function(e,t){return e.isGreaterThan(t)},ln=ct,ut.prototype.booleanMatches=function(e,t){return!1},ut.prototype.numberMatches=function(e,t){return t<=e},ut.prototype.stringMatches=function(e,t){return!1},ut.prototype.versionMatches=function(e,t){return e.isGreaterThanOrEqualTo(t)},mn=ut,at.prototype.booleanMatches=function(e,t){return!1},at.prototype.numberMatches=function(e,t){return e<t},at.prototype.stringMatches=function(e,t){return!1},at.prototype.versionMatches=function(e,t){return e.isLessThan(t)},kn=at,st.prototype.booleanMatches=function(e,t){return!1},st.prototype.numberMatches=function(e,t){return e<=t},st.prototype.stringMatches=function(e,t){return!1},st.prototype.versionMatches=function(e,t){return e.isLessThanOrEqualTo(t)},vn=st,ot.prototype.getMatcher=function(e){switch(e){case"IN":return ot.IN_MATCHER;case"CONTAINS":return ot.CONTAINS_MATCHER;case"STARTS_WITH":return ot.STARTS_WITH_MATCHER;case"ENDS_WITH":return ot.ENDS_WITH_MATCHER;case"GT":return ot.GT_MATCHER;case"GTE":return ot.GTE_MATCHER;case"LT":return ot.LT_MATCHER;case"LTE":return ot.LTE_MATCHER}},ot.IN_MATCHER=new zr,ot.CONTAINS_MATCHER=new cn,ot.STARTS_WITH_MATCHER=new wn,ot.ENDS_WITH_MATCHER=new fn,ot.GT_MATCHER=new ln,ot.GTE_MATCHER=new mn,ot.LT_MATCHER=new kn,ot.LTE_MATCHER=new vn,wn=ot,it.prototype.matches=function(e,t,r){return"string"==typeof t&&"string"==typeof r&&e.stringMatches(t,r)},fn=it,nt.prototype.matches=function(e,t,r){return"number"==typeof t&&"number"==typeof r&&e.numberMatches(t,r)},ln=nt,rt.prototype.matches=function(e,t,r){return"boolean"==typeof t&&"boolean"==typeof r&&e.booleanMatches(t,r)},mn=rt,tt.prototype.matches=function(e,t,r){t=d.tryParse(t),r=d.tryParse(r);return!(!t||!r)&&e.versionMatches(t,r)},kn=tt,et.prototype.getMatcher=function(e){switch(e){case"STRING":return et.STRING_MATCHER;case"NUMBER":return et.NUMBER_MATCHER;case"BOOLEAN":return et.BOOLEAN_MATCHER;case"VERSION":return et.VERSION_MATCHER}},et.STRING_MATCHER=new fn,et.NUMBER_MATCHER=new ln,et.BOOLEAN_MATCHER=new mn,et.VERSION_MATCHER=new kn,vn=et,Je.isNullOrUndefined=function(e){return null==e},k=Je,Qe.prototype.matches=function(e,t,r){r=this.userValueResolver.resolveOrNull(r,e.key);return!k.isNullOrUndefined(r)&&this.valueOperatorMatcher.matches(r,e.match)},fn=Qe,Ze.prototype.resolveOrNull=function(e,t){switch(t.type){case"USER_ID":return e.identifiers[t.name];case"USER_PROPERTY":return e.properties[t.name];case"HACKLE_PROPERTY":return e.hackleProperties[t.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(t.type,"]"))}},ln=Ze,$e.prototype.matches=function(e,t,r){var n=this;if("SEGMENT"!=e.key.type)throw new Error("Unsupported TargetKeyType [".concat(e.key.type,"]"));var i=e.match.values.some(function(e){return n._matches(e,t,r)});switch(e.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},$e.prototype._matches=function(e,t,r){if("string"!=typeof e)throw new Error("SegmentKey[".concat(e,"]"));var n=t.getSegmentOrNull(e);if(!n)throw new Error("Segment[".concat(e,"]"));return this.segmentMatcher.matches(n,t,r)},mn=$e,Ye.prototype.matches=function(e,t,r){var n=this;return e.targets.some(function(e){return n._matches(e,t,r)})},Ye.prototype._matches=function(e,t,r){var n=this;return e.conditions.every(function(e){return n.userConditionMatcher.matches(e,t,r)})},kn=Ye,We.prototype.getMatcher=function(e){switch(e){case"USER_ID":case"USER_PROPERTY":case"HACKLE_PROPERTY":return We.USER_CONDITION_MATCHER;case"SEGMENT":return We.SEGMENT_CONDITION_MATCHER}},We.USER_CONDITION_MATCHER=new fn(new ln,new dn(new vn,new wn)),We.SEGMENT_CONDITION_MATCHER=new mn(new kn(We.USER_CONDITION_MATCHER)),C=We,Xe.prototype.resolveOrNull=function(e,t,r,n){switch(e.type){case"VARIATION":return this._resolveVariation(e,r);case"BUCKET":return this._resolveBucket(e,t,r,n)}},Xe.prototype._resolveVariation=function(e,t){return t._getVariationByIdOrNull(e.variationId)},Xe.prototype._resolveBucket=function(e,t,r,n){e=t.getBucketOrNull(e.bucketId),n=n.identifiers[r.identifierType];if(n){n=this.bucketer.bucketing(e,n);if(n)return r._getVariationByIdOrNull(n.variationId)}},M=Xe,P={murmurhash3_x86_32:function(e,t,r,n){for(var i,o=3432918353,s=461845907,a=-4&(n=void 0===n?e.length:n),u=t,c=0;c<a;c+=4)i=255&e.charCodeAt(c)|(255&e.charCodeAt(c+1))<<8|(255&e.charCodeAt(c+2))<<16|(255&e.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,u=5*((524287&(u^=i=this.mul32(i,s)))<<13|u>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&e.charCodeAt(2+a))<<16;case 2:i|=(255&e.charCodeAt(1+a))<<8;case 1:i|=255&e.charCodeAt(a),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,u^=i=this.mul32(i,s)}return u^=n,u=this.mul32(u^=u>>>16,2246822507),(u=this.mul32(u^=u>>>13,3266489909))^u>>>16},mul32:function(e,t){var r=65535&t;return((t-r)*e|0)+(r*e|0)|0}},qe.prototype.bucketing=function(e,t){var r=this.calculateSlotNumber(e.seed,e.slotSize,t);return e.slots.find(function(e){return e.contains(r)})},qe.prototype.calculateSlotNumber=function(e,t,r){e=P.murmurhash3_x86_32(r,e);return Math.abs(e)%Math.abs(t)},L=qe,Ke.prototype.evaluate=function(e,t,r,n){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(e,t,r,n,this.nextFlow):I.of(t,n,a.TRAFFIC_NOT_ALLOCATED)},Ke.of=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i=new Ke;try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&n>=e.length?void 0:e)&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(r.reverse()),s=o.next();!s.done;s=o.next())i=new Ke(s.value,i)}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return i},D=Ke,ze.prototype.evaluate=function(e,t,r,n,i){var o=this.overrideResolver.resolveOrNull(e,t,r);if(!o)return i.evaluate(e,t,r,n);switch(t.type){case"AB_TEST":return I.withVariation(o,a.OVERRIDDEN);case"FEATURE_FLAG":return I.withVariation(o,a.INDIVIDUAL_TARGET_MATCH)}},U=ze,Be.prototype.evaluate=function(e,t,r,n,i){return"DRAFT"===t.status?I.of(t,n,a.EXPERIMENT_DRAFT):i.evaluate(e,t,r,n)},F=Be,He.prototype.evaluate=function(e,t,r,n,i){if("PAUSED"!==t.status)return i.evaluate(e,t,r,n);switch(t.type){case"AB_TEST":return I.of(t,n,a.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return I.of(t,n,a.FEATURE_FLAG_INACTIVE)}},j=He,Ge.prototype.evaluate=function(e,t,r,n,i){if("COMPLETED"!==t.status)return i.evaluate(e,t,r,n);n=t._winnerVariationOrNull();if(!n)throw new Error("winner variation [".concat(t.id,"]"));return I.withVariation(n,a.EXPERIMENT_COMPLETED)},V=Ge,Ve.prototype.evaluate=function(e,t,r,n,i){if("AB_TEST"!==t.type)throw new Error("experiment type bust be AB_TEST [".concat(t.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(e,t,r)?i.evaluate(e,t,r,n):I.of(t,n,a.NOT_IN_EXPERIMENT_TARGET)},G=Ve,je.prototype.evaluate=function(e,t,r,n,i){if("RUNNING"!==t.status)throw new Error("experiment status must be RUNNING [".concat(t.id,"]"));if("AB_TEST"!==t.type)throw new Error("experiment type bust be AB_TEST [".concat(t.id,"]"));r=this.actionResolver.resolveOrNull(t.defaultRule,e,t,r);return r?r.isDropped?I.of(t,n,a.VARIATION_DROPPED):I.withVariation(r,a.TRAFFIC_ALLOCATED):I.of(t,n,a.TRAFFIC_NOT_ALLOCATED)},H=je,Fe.prototype.evaluate=function(e,t,r,n,i){if("RUNNING"!==t.status)throw new Error("experiment status must be RUNNING [".concat(t.id,"]"));if("FEATURE_FLAG"!==t.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(t.id,"]"));if(!r.identifiers[t.identifierType])return i.evaluate(e,t,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(e,t,r);if(!o)return i.evaluate(e,t,r,n);r=this.actionResolver.resolveOrNull(o.action,e,t,r);if(!r)throw new Error("FeatureFlag must decide the Variation [".concat(t.id,"]"));return I.withVariation(r,a.TARGET_RULE_MATCH)},B=Fe,Ue.prototype.evaluate=function(e,t,r,n,i){if("RUNNING"!==t.status)throw new Error("experiment status must be RUNNING [".concat(t.id,"]"));if("FEATURE_FLAG"!==t.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(t.id,"]"));if(!r.identifiers[t.identifierType])return I.of(t,n,a.DEFAULT_RULE);r=this.actionResolver.resolveOrNull(t.defaultRule,e,t,r);if(!r)throw new Error("FeatureFlag must decide the Variation [".concat(t.id,"]"));return I.withVariation(r,a.DEFAULT_RULE)},z=Ue,De.prototype.evaluate=function(e,t,r,n,i){var o=t.containerId;if(!o)return i.evaluate(e,t,r,n);var s=e.getContainerOrNull(o);if(!s)throw new Error("container[".concat(o,"]"));o=e.getBucketOrNull(s.bucketId);if(!o)throw new Error("bucket[".concat(s.bucketId,"]"));return this.containerResolver.isUserInContainerGroup(s,o,t,r)?i.evaluate(e,t,r,n):I.of(t,n,a.NOT_IN_MUTUAL_EXCLUSION_EXPERIMENT)},K=De,Le.prototype.evaluate=function(e,t,r,n,i){return r.identifiers[t.identifierType]?i.evaluate(e,t,r,n):I.of(t,n,a.IDENTIFIER_NOT_FOUND)},q=Le,Pe.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some(function(e){return n.targetMatcher.matches(e,t,r)})},X=Pe,Me.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find(function(e){return n.targetMatcher.matches(e.target,t,r)})},W=Me,Ce.prototype.resolveOrNull=function(e,t,r){return this._resolveUserOverride(t,r)||this._resolveSegmentOverride(e,t,r)},Ce.prototype._resolveUserOverride=function(e,t){t=t.identifiers[e.identifierType];if(t){t=e.userOverrides.get(t);if(t)return e._getVariationByIdOrNull(t)}},Ce.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find(function(e){return n.targetMatcher.matches(e.target,t,r)});if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},Y=Ce,ke.prototype.isUserInContainerGroup=function(e,t,r,n){n=n.identifiers[r.identifierType];if(!n)return!1;n=this.bucketer.bucketing(t,n);if(!n)return!1;e=e.getGroupOrNull(n.variationId);if(!e)throw new Error("ContainerGroup[".concat(n.variationId,"]"));return e.experiments.includes(r.id)},$=ke,Se.prototype.getFlow=function(e){switch(e){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},Z=Se,Q=Sn.log,xe.prototype._experiment=function(e,t,r){if(!e)return Q.error("experimentKey must not be empty"),o.of(r,a.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return Q.warn("SDK not ready."),o.of(r,a.SDK_NOT_READY);e=n.getExperimentOrNull(e);if(!e)return Q.warn("Experiment does not exist."),o.of(r,a.EXPERIMENT_NOT_FOUND);r=this.evaluator.evaluate(n,e,t,r);return this.eventProcessor.process(_.exposure(e,t,r)),o.of(r.variationKey,r.reason)},xe.prototype._featureFlag=function(e,t){if(!e)return Q.error("featureKey must not be empty"),s.off(a.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return Q.warn("SDK not ready."),s.off(a.SDK_NOT_READY);e=r.getFeatureFlagOrNull(e);if(!e)return Q.warn("FeatureFlag does not exist."),s.off(a.FEATURE_FLAG_NOT_FOUND);r=this.evaluator.evaluate(r,e,t,"A");return this.eventProcessor.process(_.exposure(e,t,r)),"A"===r.variationKey?s.off(r.reason):s.on(r.reason)},xe.prototype._track=function(e,t){var r;e?"object"==typeof e?"object"!=typeof e||e.key&&"string"==typeof e.key?(r=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(e.key))||new ce(0,e.key),this.eventProcessor.process(_.track(r,e,t))):Q.warn("Event key must be not null. or event key must be string type."):Q.warn("Event must be event type."):Q.warn("event must not be null.")},xe.prototype._onReady=function(e,t){this._onInitialized({timeout:t=void 0===t?3e3:t}).then(function(){return e()})},xe.prototype._onInitialized=function(e){var t,r=e.timeout,e=void 0===r?3e3:r;Q.debug("Start HackleClient initializing");var r=new Promise(function(e){t=e}),n=setTimeout(function(){t({success:!1})},e);return this.readyPromise.then(function(){clearTimeout(n),t({success:!0})},function(e){clearTimeout(n),t({success:!1,error:e})}),Promise.race([this.readyPromise,r]).then(function(e){return e.success?Q.debug("HackleClient onInitialized Success"):e.error instanceof Error?Q.error("HackleClient onInitialized Failed. ".concat(e.error.message)):Q.error("HackleClient onInitialized Failed. ".concat(e.error)),Promise.resolve({success:e.success})})},xe.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},wn=xe,Ie.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},Ie.prototype.refresh=function(){this.stop(),this.start()},Ie.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},J=Ie,Ne.prototype.start=function(){this.started=!0},Ne.prototype.stop=function(){this.started=!1;var e=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),e},Ne.prototype.enqueue=function(e){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(e),this.buffer.length>=this.maxQueueSize&&this.flush())},Ne.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},Ne.prototype.close=function(){this.stop()},ee=Ne,Ae.prototype.drainQueue=function(t,r){var n=this;return new Promise(function(e){0!==t.length?r?n.eventDispatcher.dispatchXhrOrBeacon(t,function(){e()}):n.eventDispatcher.dispatch(t,function(){e()}):e()})},Ae.prototype.process=function(e){this.queue.enqueue(e)},Ae.prototype.start=function(){return e=this,u=function(){return r=this,n=function(e){return this.queue.start(),[2]},a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(s=2&t[0]?o.return:t[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,t[1])).done)return s;switch(o=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,o=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!((s=0<(s=a.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],o=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}var r,n,i,o,s,a,t},new(a=(a=s=void 0)||Promise)(function(r,t){function n(e){try{o(u.next(e))}catch(e){t(e)}}function i(e){try{o(u.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}o((u=u.apply(e,s||[])).next())});var e,s,a,u},Ae.prototype.stop=function(){try{this.queue.close()}catch(e){}return Promise.resolve()},Ae.prototype.close=function(){this.stop()},Ae.DEFAULT_FLUSH_INTERVAL=1e4,mn=Ae,te=Sn.log,Nt.prototype.getExperimentOrNull=function(e){return this.experiments.get(e)},Nt.prototype.getFeatureFlagOrNull=function(e){return this.featureFlags.get(e)},Nt.prototype.getBucketOrNull=function(e){return this.buckets.get(e)},Nt.prototype.getEventTypeOrNull=function(e){return this.eventTypes.get(e)},Nt.prototype.getSegmentOrNull=function(e){return this.segments.get(e)},Nt.prototype.getContainerOrNull=function(e){return this.containers.get(e)},Nt.from=function(e){var t=this,r=Nt.associate(e.buckets,function(e){return[e.id,t.toBucket(e)]}),n=Nt.associateBy(Nt.mapNotUndefined(e.experiments,function(e){return t.toExperimentOrNull("AB_TEST",e)}),function(e){return e.key}),i=Nt.associateBy(Nt.mapNotUndefined(e.featureFlags,function(e){return t.toExperimentOrNull("FEATURE_FLAG",e)}),function(e){return e.key}),o=Nt.associate(e.events,function(e){return[e.key,new ce(e.id,e.key)]}),s=Nt.associateBy(Nt.mapNotUndefined(e.segments,function(e){return t.toSegmentOrNull(e)}),function(e){return e.key}),e=Nt.associate(e.containers,function(e){return[e.id,t.toContainer(e)]});return new Nt(n,i,r,o,s,e)},Nt.toBucket=function(e){return new ue(e.seed,e.slotSize,e.slots.map(function(e){var t=e.startInclusive,r=e.endExclusive,e=e.variationId;return new u(t,r,e)}))},Nt.toExperimentOrNull=function(e,t){var r=this,n=this.experimentStatusOrNull(t.execution.status),i=t.variations.map(function(e){return new ae(e.id,e.key,"DROPPED"===e.status)}),o=Nt.associate(t.execution.userOverrides,function(e){return[e.userId,e.variationId]}),s=Nt.mapNotUndefined(t.execution.segmentOverrides,function(e){return r.toTargetRuleOrNull(e,O.IDENTIFIER)}),a=Nt.mapNotUndefined(t.execution.targetAudiences,function(e){return r.toTargetOrNull(e,O.PROPERTY)}),u=Nt.mapNotUndefined(t.execution.targetRules,function(e){return r.toTargetRuleOrNull(e,O.PROPERTY)}),c=this.toTargetActionOrNull(t.execution.defaultRule);return n&&c&&new f(t.id,t.key,e,t.identifierType,n,t.version,i,o,s,a,u,c,t.containerId,t.winnerVariationId)},Nt.experimentStatusOrNull=function(e){switch(e){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void te.debug("Unsupported status [".concat(e,"]"))}},Nt.toTargetRuleOrNull=function(e,t){t=this.toTargetOrNull(e.target,t),e=this.toTargetActionOrNull(e.action);return t&&e&&new ve(t,e)},Nt.toTargetActionOrNull=function(e){var t=this.parseOrNull(E,e.type);return t&&new de(t,e.variationId,e.bucketId)},Nt.toTargetOrNull=function(e,t){var r=this,e=Nt.mapNotUndefined(e.conditions,function(e){return r.toConditionOrNull(e,t)});return new fe(e)},Nt.toConditionOrNull=function(e,t){var r=this.toTargetKeyOrNull(e.key);if(r&&t.supports(r.type)){e=this.toTargetMatchOrNull(e.match);return e&&new le(r,e)}},Nt.toTargetKeyOrNull=function(e){var t=this.parseOrNull(T,e.type);return t&&new pe(t,e.name)},Nt.toTargetMatchOrNull=function(e){var t=this.parseOrNull(g,e.type),r=this.parseOrNull(w,e.operator),n=this.parseOrNull(m,e.valueType);return t&&r&&n&&new he(t,r,n,e.values)},Nt.toSegmentOrNull=function(e){var t=this,r=this.parseOrNull(b,e.type);return r&&new ye(e.id,e.key,r,this.mapNotUndefined(e.targets,function(e){return t.toTargetOrNull(e,O.SEGMENT)}))},Nt.toContainer=function(e){var t=this;return new l(e.id,e.bucketId,e.groups.map(function(e){return t.toContainerGroup(e)}))},Nt.toContainerGroup=function(e){return new ge(e.id,e.experiments)},Nt.parseOrNull=function(e,t){e=e.find(function(e){return e===t});return e||te.debug("Unsupported type [".concat(t,"]. Please use the latest version of sdk.")),e},Nt.mapNotUndefined=function(e,r){return e.reduce(function(e,t){t=r(t);return t&&e.push(t),e},Array())},Nt.associateTo=function(e,t,r){return e.reduce(function(e,t){t=r(t);return e.set(t[0],t[1]),e},t)},Nt.associate=function(e,t){return Nt.associateTo(e,new Map,t)},Nt.associateBy=function(e,t){return this.associateTo(e,new Map,function(e){return[t(e),e]})},kn=Nt,Cn.Bucket=ue,Cn.Container=l,Cn.ContainerGroup=ge,Cn.CoreVersion=v,Cn.DEFAULT_ON_READY_TIMEOUT=3e3,Cn.Decision=o,Cn.DecisionReason=a,Cn.DefaultEventQueue=ee,Cn.Event=_,Cn.EventProcessor=mn,Cn.EventType=ce,Cn.Experiment=f,Cn.Exposure=A,Cn.FeatureFlagDecision=s,Cn.HackleInternalClient=wn,Cn.IdentifierType=c,Cn.IdentifiersBuilder=On,Cn.Logger=Sn,Cn.MATCH_OPERATORS=w,Cn.MATCH_TYPES=g,Cn.MATCH_VALUE_TYPES=m,Cn.MetaVersion=y,Cn.SEGMENT_TYPES=b,Cn.Segment=ye,Cn.Slot=u,Cn.TARGET_ACTION_TYPES=E,Cn.TARGET_KEY_TYPES=T,Cn.Target=fe,Cn.TargetAction=de,Cn.TargetCondition=le,Cn.TargetKey=pe,Cn.TargetMatch=he,Cn.TargetRule=ve,Cn.TargetingType=O,Cn.Track=N,Cn.Variation=ae,Cn.Version=d,Cn.Workspace=kn,Cn.logLevels=t,Cn.toPayload=function(e){var t=new Array,r=new Array;return e.forEach(function(e){_.isExposure(e)?t.push(e.toDto()):_.isTrack(e)&&r.push(e.toDto())}),{exposureEvents:t,trackEvents:r}},Object.defineProperty(Cn,"__esModule",{value:!0});var It="X-HACKLE-SDK-KEY",xt="X-HACKLE-SDK-NAME",St="X-HACKLE-SDK-VERSION",kt="X-HACKLE-SDK-TIME",Ct=[0,8,16,32,64,128,256,512],Mt="_hackle_hid",Pt="_hackle_id",Lt=ie.exports.Logger.log;function Dt(n,i){return{abort:function(){},responsePromise:new Promise(function(e,t){var r=new XMLHttpRequest;r.open("GET",n),r.onreadystatechange=function(){r.readyState===r.DONE&&(0!==r.status?e({statusCode:r.status,body:r.responseText}):t(new Error("Request error")))},r.setRequestHeader("content-type","application/json"),r.withCredentials=!0,Ut(r,i),r.send()})}}function Ut(e,t){for(var r in t)t.hasOwnProperty(r)&&e.setRequestHeader(r,t[r])}var Ft=(Ht.prototype.dispatch=function(e,t){this._post(e,t)},Ht.prototype.dispatchXhrOrBeacon=function(e,t){this.useBeacon?this._beacon(e,t):this._post(e,t)},Ht.prototype._post=function(e,t){var r,n,i=this._createRequest(e),o=i.payload,e=i.headers;i=this.dispatchUrl,e=e,r=t,o=JSON.stringify(o),(n=new XMLHttpRequest).open("POST",i),n.onreadystatechange=function(){n.readyState===n.DONE&&200<=n.status&&n.status<400&&r(n)},n.setRequestHeader("content-type","application/json"),n.withCredentials=!0,Ut(n,e),n.send(o)},Ht.prototype._beacon=function(e,t){var r=this._createRequest(e),n=r.payload,i=r.headers;e=this.beaconDispatchUrl,r=i,i=t,t=!1,(t="undefined"!=typeof window?window&&window.navigator&&window.navigator.sendBeacon&&!0:t)?(n=JSON.stringify(n),(t=new URLSearchParams).append("sdkName",r[xt]),t.append("sdkVersion",r[St]),t.append("sdkTime",r[kt]),t.append("data",n),window.navigator.sendBeacon(e,t)):Lt.error("Does not support sendBeacon"),i()},Ht.prototype._createRequest=function(e){return{payload:ie.exports.toPayload(e),headers:re(((e={})[It]=this.sdkKey,e[kt]=(new Date).getTime().toString(),e),this.headers)}},Ht),jt={exports:{}},Vt="object"==typeof Reflect?Reflect:null,Gt=Vt&&"function"==typeof Vt.apply?Vt.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function Ht(e,t){this.sdkKey=e,this.headers=t.headers,this.dispatchUrl=t.dispatchUrl,this.beaconDispatchUrl=t.beaconDispatchUrl||"",this.useBeacon=t.useBeacon}var Bt=Vt&&"function"==typeof Vt.ownKeys?Vt.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)},zt=Number.isNaN||function(e){return e!=e};function Kt(){Kt.init.call(this)}jt.exports=Kt,jt.exports.once=function(i,o){return new Promise(function(e,t){function r(e){i.removeListener(o,n),t(e)}function n(){"function"==typeof i.removeListener&&i.removeListener("error",r),e([].slice.call(arguments))}tr(i,o,n,{once:!0}),"error"===o||"function"==typeof i.on&&tr(i,"error",r,{once:!0})})},(Kt.EventEmitter=Kt).prototype._events=void 0,Kt.prototype._eventsCount=0,Kt.prototype._maxListeners=void 0;var qt,Xt=10;function Wt(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Yt(e){return void 0===e._maxListeners?Kt.defaultMaxListeners:e._maxListeners}function $t(e,t,r,n){var i,o;return Wt(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener||r),i=e._events),o=i[t]),void 0===o?(o=i[t]=r,++e._eventsCount):("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),0<(r=Yt(e))&&o.length>r&&!o.warned&&(o.warned=!0,(r=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit")).name="MaxListenersExceededWarning",r.emitter=e,r.type=t,r.count=o.length,console&&console.warn&&console.warn(r))),e}function Zt(e,t,r){e={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},t=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(e);return t.listener=r,e.wrapFn=t}function Qt(e,t,r){e=e._events;if(void 0===e)return[];t=e[t];return void 0===t?[]:"function"==typeof t?r?[t.listener||t]:[t]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):er(t,t.length)}function Jt(e){var t=this._events;if(void 0!==t){e=t[e];if("function"==typeof e)return 1;if(void 0!==e)return e.length}return 0}function er(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function tr(r,n,i,o){if("function"==typeof r.on)o.once?r.once(n,i):r.on(n,i);else{if("function"!=typeof r.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r);r.addEventListener(n,function e(t){o.once&&r.removeEventListener(n,e),i(t)})}}Object.defineProperty(Kt,"defaultMaxListeners",{enumerable:!0,get:function(){return Xt},set:function(e){if("number"!=typeof e||e<0||zt(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Xt=e}}),Kt.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Kt.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||zt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Kt.prototype.getMaxListeners=function(){return Yt(this)},Kt.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n,i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){if((n=0<t.length?t[0]:n)instanceof Error)throw n;i=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw i.context=n,i}e=o[e];if(void 0===e)return!1;if("function"==typeof e)Gt(e,this,t);else for(var s=e.length,a=er(e,s),r=0;r<s;++r)Gt(a[r],this,t);return!0},Kt.prototype.on=Kt.prototype.addListener=function(e,t){return $t(this,e,t,!1)},Kt.prototype.prependListener=function(e,t){return $t(this,e,t,!0)},Kt.prototype.once=function(e,t){return Wt(t),this.on(e,Zt(this,e,t)),this},Kt.prototype.prependOnceListener=function(e,t){return Wt(t),this.prependListener(e,Zt(this,e,t)),this},Kt.prototype.off=Kt.prototype.removeListener=function(e,t){var r,n,i,o,s;if(Wt(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;0<=o;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},Kt.prototype.removeAllListeners=function(e){var t,r;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(o=t.length-1;0<=o;o--)this.removeListener(e,t[o]);return this},Kt.prototype.listeners=function(e){return Qt(this,e,!0)},Kt.prototype.rawListeners=function(e){return Qt(this,e,!1)},Kt.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Jt.call(e,t)},Kt.prototype.listenerCount=Jt,Kt.prototype.eventNames=function(){return 0<this._eventsCount?Bt(this._events):[]};var rr=new Uint8Array(16);var nr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var ir=[],or=0;or<256;++or)ir.push((or+256).toString(16).substr(1));function sr(e,t,r){var n=(e=e||{}).random||(e.rng||function(){if(!qt&&!(qt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qt(rr)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e,t){var t=1<arguments.length&&void 0!==t?t:0,e=(ir[e[t+0]]+ir[e[t+1]]+ir[e[t+2]]+ir[e[t+3]]+"-"+ir[e[t+4]]+ir[e[t+5]]+"-"+ir[e[t+6]]+ir[e[t+7]]+"-"+ir[e[t+8]]+ir[e[t+9]]+"-"+ir[e[t+10]]+ir[e[t+11]]+ir[e[t+12]]+ir[e[t+13]]+ir[e[t+14]]+ir[e[t+15]]).toLowerCase();if("string"!=typeof(t=e)||!nr.test(t))throw TypeError("Stringified UUID is invalid");return e}(n)}var ar=(ur.get=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "==i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return decodeURIComponent(i.substring(t.length,i.length))}return null},ur.set=function(e,t,r,n,i,o){var s,a="",u="",c="";n&&(a=(s=function(e){var t=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,r=e.split("."),r=r[r.length-1];(4<r.length||"com"===r||"org"===r)&&(t=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i);t=e.match(t);return t?t[0]:""}(document.location.hostname))?"; domain=."+s:""),r&&((s=new Date).setTime(s.getTime()+24*r*60*60*1e3),u="; expires="+s.toUTCString()),o&&(i=!0,c="; SameSite=None"),i&&(c+="; secure");c=e+"="+encodeURIComponent(t)+u+"; path=/"+a+c;return document.cookie=c},ur.remove=function(e,t){ur.set(e,"",-1,t,!1,!1)},ur);function ur(){}var cr=(fr.initialize=function(){ar.get(Mt)||dr()},fr.reInitialize=function(){dr()},fr);function fr(){}function lr(){var e=ar.get(Pt);return e||ar.get(Mt)||dr()}function pr(e){ar.set(Pt,e,3650,!0)}function hr(){ar.remove(Pt,!0)}function dr(){var e=sr();return ar.set(Mt,e,3650,!0),e}function vr(e){return e&&e.Math==Math&&e}function yr(e){try{return!!e()}catch(e){return!0}}var gr="model",mr="name",wr="type",Er="vendor",Tr="version",br="architecture",Or="console",Rr="mobile",_r="tablet",Ar="smarttv",Nr="wearable",Ir=($r.parse=function(e){return{browser:$r.getBrowser(e),cpu:$r.getCPU(e),device:$r.getDevice(e),engine:$r.getEngine(e),os:$r.getOS(e)}},$r.getBrowser=function(e){var t={name:void 0,version:void 0,major:void 0};return $r.mapper.rgx.call(t,e,$r.regexes.browser),t.major=$r.util.major(t.version),t},$r.getCPU=function(e){var t={architecture:void 0};return $r.mapper.rgx.call(t,e,$r.regexes.cpu),t},$r.getDevice=function(e){var t={model:void 0,type:void 0,vendor:void 0};return $r.mapper.rgx.call(t,e,$r.regexes.device),t},$r.getEngine=function(e){var t={name:void 0,version:void 0};return $r.mapper.rgx.call(t,e,$r.regexes.os),t},$r.getOS=function(e){var t={name:void 0,version:void 0};return $r.mapper.rgx.call(t,e,$r.regexes.os),t},$r.util={extend:function(e,t){var r,n={};for(r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n},has:function(e,t){return"string"==typeof e&&-1!==t.toLowerCase().indexOf(e.toLowerCase())},lowerize:function(e){return e.toLowerCase()},major:function(e){return"string"==typeof e?e.replace(/[^\d\.]/g,"").split(".")[0]:void 0},trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},$r.regexes={browser:[[/(opera\smini)\/([\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i,/(opera).+version\/([\w\.]+)/i,/(opera)[\/\s]+([\w\.]+)/i],[mr,Tr],[/(opios)[\/\s]+([\w\.]+)/i],[[mr,"Opera Mini"],Tr],[/\s(opr)\/([\w\.]+)/i],[[mr,"Opera"],Tr],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,/(avant\s|iemobile|slim)(?:browser)?[\/\s]?([\w\.]*)/i,/(bidubrowser|baidubrowser)[\/\s]?([\w\.]+)/i,/(?:ms|\()(ie)\s([\w\.]+)/i,/(rekonq)\/([\w\.]*)/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i],[mr,Tr],[/(konqueror)\/([\w\.]+)/i],[[mr,"Konqueror"],Tr],[/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i],[[mr,"IE"],Tr],[/(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i],[[mr,"Edge"],Tr],[/(yabrowser)\/([\w\.]+)/i],[[mr,"Yandex"],Tr],[/(Avast)\/([\w\.]+)/i],[[mr,"Avast Secure Browser"],Tr],[/(AVG)\/([\w\.]+)/i],[[mr,"AVG Secure Browser"],Tr],[/(puffin)\/([\w\.]+)/i],[[mr,"Puffin"],Tr],[/(focus)\/([\w\.]+)/i],[[mr,"Firefox Focus"],Tr],[/(opt)\/([\w\.]+)/i],[[mr,"Opera Touch"],Tr],[/((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i],[[mr,"UCBrowser"],Tr],[/(comodo_dragon)\/([\w\.]+)/i],[[mr,/_/g," "],Tr],[/(windowswechat qbcore)\/([\w\.]+)/i],[[mr,"WeChat(Win) Desktop"],Tr],[/(micromessenger)\/([\w\.]+)/i],[[mr,"WeChat"],Tr],[/(brave)\/([\w\.]+)/i],[[mr,"Brave"],Tr],[/(whale)\/([\w\.]+)/i],[[mr,"Whale"],Tr],[/(qqbrowserlite)\/([\w\.]+)/i],[mr,Tr],[/(QQ)\/([\d\.]+)/i],[mr,Tr],[/m?(qqbrowser)[\/\s]?([\w\.]+)/i],[mr,Tr],[/(baiduboxapp)[\/\s]?([\w\.]+)/i],[mr,Tr],[/(2345Explorer)[\/\s]?([\w\.]+)/i],[mr,Tr],[/(MetaSr)[\/\s]?([\w\.]+)/i],[mr],[/(LBBROWSER)/i],[mr],[/xiaomi\/miuibrowser\/([\w\.]+)/i],[Tr,[mr,"MIUI Browser"]],[/;fbav\/([\w\.]+);/i],[Tr,[mr,"Facebook"]],[/safari\s(line)\/([\w\.]+)/i,/android.+(line)\/([\w\.]+)\/iab/i],[mr,Tr],[/headlesschrome(?:\/([\w\.]+)|\s)/i],[Tr,[mr,"Chrome Headless"]],[/\swv\).+(chrome)\/([\w\.]+)/i],[[mr,/(.+)/,"$1 WebView"],Tr],[/((?:oculus|samsung)browser)\/([\w\.]+)/i],[[mr,/(.+(?:g|us))(.+)/,"$1 $2"],Tr],[/((?:android.+)crmo|crios)\/([\w\.]+)/i,/android.+(chrome)\/([\w\.]+)\s+(?:mobile\s?safari)/i],[[mr,"Chrome Mobile"],Tr],[/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i],[Tr,[mr,"Android Browser"]],[/(sailfishbrowser)\/([\w\.]+)/i],[[mr,"Sailfish Browser"],Tr],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i],[mr,Tr],[/(dolfin)\/([\w\.]+)/i],[[mr,"Dolphin"],Tr],[/(qihu|qhbrowser|qihoobrowser|360browser)/i],[[mr,"360 Browser"]],[/(coast)\/([\w\.]+)/i],[[mr,"Opera Coast"],Tr],[/fxios\/([\w\.-]+)/i],[Tr,[mr,"Firefox"]],[/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i],[Tr,[mr,"Mobile Safari"]],[/version\/([\w\.]+).+?(mobile\s?safari|safari)/i],[Tr,mr],[/webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[[mr,"GSA"],Tr],[/webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i],[mr,[Tr,($r.mapper={rgx:function(e,t){for(var r,n,i,o,s,a=0;a<t.length&&!o;){for(var u=t[a],c=t[a+1],f=r=0;f<u.length&&!o;)if(o=u[f++].exec(e))for(n=0;n<c.length;n++)s=o[++r],"object"==typeof(i=c[n])&&0<i.length?2==i.length?"function"==typeof i[1]?this[i[0]]=i[1].call(this,s):this[i[0]]=i[1]:3==i.length?"function"!=typeof i[1]||i[1].exec&&i[1].test?this[i[0]]=s?s.replace(i[1],i[2]):void 0:this[i[0]]=s?i[1].call(this,s,i[2]):void 0:4==i.length&&(this[i[0]]=s?i[3].call(this,s.replace(i[1],i[2])):void 0):this[i]=s||void 0;a+=2}},str:function(e,t){for(var r in t)if("object"==typeof t[r]&&0<t[r].length){for(var n=0;n<t[r].length;n++)if($r.util.has(t[r][n],e))return"?"===r?void 0:r}else if($r.util.has(t[r],e))return"?"===r?void 0:r;return e}}).str,($r.maps={browser:{oldsafari:{version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}}},device:{amazon:{model:{"Fire Phone":["SD","KF"]}},sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME