var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
let window = _____WB$wombat$assign$function_____("window");
let self = _____WB$wombat$assign$function_____("self");
let document = _____WB$wombat$assign$function_____("document");
let location = _____WB$wombat$assign$function_____("location");
let top = _____WB$wombat$assign$function_____("top");
let parent = _____WB$wombat$assign$function_____("parent");
let frames = _____WB$wombat$assign$function_____("frames");
let opens = _____WB$wombat$assign$function_____("opens");
/*! Licenses: https://cdn.shopify.com/shopifycloud/checkout-web/assets/LICENSE-c1-baseline.txt */
(self.webpackChunkcheckout_web=self.webpackChunkcheckout_web||[]).push([["vendors-node_modules_shopify_verdict_build_esm_runtimes_browser_index_mts_js"],{mmNF:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},ANhw:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],s=0;s<4;s++)8*r+6*s<=8*e.length?n.push(t.charAt(i>>>6*(3-s)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},BEtg:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},aCH8:(e,t,n)=>{var r,i,s,a,o;r=n("ANhw"),i=n("mmNF").utf8,s=n("BEtg"),a=n("mmNF").bin,(o=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?a.stringToBytes(e):i.stringToBytes(e):s(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),u=8*e.length,l=1732584193,h=-271733879,c=-1732584194,m=271733878,g=0;g<n.length;g++)n[g]=16711935&(n[g]<<8|n[g]>>>24)|4278255360&(n[g]<<24|n[g]>>>8);n[u>>>5]|=128<<u%32,n[14+(u+64>>>9<<4)]=u;var d=o._ff,p=o._gg,f=o._hh,x=o._ii;for(g=0;g<n.length;g+=16){var y=l,A=h,w=c,E=m;l=d(l,h,c,m,n[g+0],7,-680876936),m=d(m,l,h,c,n[g+1],12,-389564586),c=d(c,m,l,h,n[g+2],17,606105819),h=d(h,c,m,l,n[g+3],22,-1044525330),l=d(l,h,c,m,n[g+4],7,-176418897),m=d(m,l,h,c,n[g+5],12,1200080426),c=d(c,m,l,h,n[g+6],17,-1473231341),h=d(h,c,m,l,n[g+7],22,-45705983),l=d(l,h,c,m,n[g+8],7,1770035416),m=d(m,l,h,c,n[g+9],12,-1958414417),c=d(c,m,l,h,n[g+10],17,-42063),h=d(h,c,m,l,n[g+11],22,-1990404162),l=d(l,h,c,m,n[g+12],7,1804603682),m=d(m,l,h,c,n[g+13],12,-40341101),c=d(c,m,l,h,n[g+14],17,-1502002290),l=p(l,h=d(h,c,m,l,n[g+15],22,1236535329),c,m,n[g+1],5,-165796510),m=p(m,l,h,c,n[g+6],9,-1069501632),c=p(c,m,l,h,n[g+11],14,643717713),h=p(h,c,m,l,n[g+0],20,-373897302),l=p(l,h,c,m,n[g+5],5,-701558691),m=p(m,l,h,c,n[g+10],9,38016083),c=p(c,m,l,h,n[g+15],14,-660478335),h=p(h,c,m,l,n[g+4],20,-405537848),l=p(l,h,c,m,n[g+9],5,568446438),m=p(m,l,h,c,n[g+14],9,-1019803690),c=p(c,m,l,h,n[g+3],14,-187363961),h=p(h,c,m,l,n[g+8],20,1163531501),l=p(l,h,c,m,n[g+13],5,-1444681467),m=p(m,l,h,c,n[g+2],9,-51403784),c=p(c,m,l,h,n[g+7],14,1735328473),l=f(l,h=p(h,c,m,l,n[g+12],20,-1926607734),c,m,n[g+5],4,-378558),m=f(m,l,h,c,n[g+8],11,-2022574463),c=f(c,m,l,h,n[g+11],16,1839030562),h=f(h,c,m,l,n[g+14],23,-35309556),l=f(l,h,c,m,n[g+1],4,-1530992060),m=f(m,l,h,c,n[g+4],11,1272893353),c=f(c,m,l,h,n[g+7],16,-155497632),h=f(h,c,m,l,n[g+10],23,-1094730640),l=f(l,h,c,m,n[g+13],4,681279174),m=f(m,l,h,c,n[g+0],11,-358537222),c=f(c,m,l,h,n[g+3],16,-722521979),h=f(h,c,m,l,n[g+6],23,76029189),l=f(l,h,c,m,n[g+9],4,-640364487),m=f(m,l,h,c,n[g+12],11,-421815835),c=f(c,m,l,h,n[g+15],16,530742520),l=x(l,h=f(h,c,m,l,n[g+2],23,-995338651),c,m,n[g+0],6,-198630844),m=x(m,l,h,c,n[g+7],10,1126891415),c=x(c,m,l,h,n[g+14],15,-1416354905),h=x(h,c,m,l,n[g+5],21,-57434055),l=x(l,h,c,m,n[g+12],6,1700485571),m=x(m,l,h,c,n[g+3],10,-1894986606),c=x(c,m,l,h,n[g+10],15,-1051523),h=x(h,c,m,l,n[g+1],21,-2054922799),l=x(l,h,c,m,n[g+8],6,1873313359),m=x(m,l,h,c,n[g+15],10,-30611744),c=x(c,m,l,h,n[g+6],15,-1560198380),h=x(h,c,m,l,n[g+13],21,1309151649),l=x(l,h,c,m,n[g+4],6,-145523070),m=x(m,l,h,c,n[g+11],10,-1120210379),c=x(c,m,l,h,n[g+2],15,718787259),h=x(h,c,m,l,n[g+9],21,-343485551),l=l+y>>>0,h=h+A>>>0,c=c+w>>>0,m=m+E>>>0}return r.endian([l,h,c,m])})._ff=function(e,t,n,r,i,s,a){var o=e+(t&n|~t&r)+(i>>>0)+a;return(o<<s|o>>>32-s)+t},o._gg=function(e,t,n,r,i,s,a){var o=e+(t&r|n&~r)+(i>>>0)+a;return(o<<s|o>>>32-s)+t},o._hh=function(e,t,n,r,i,s,a){var o=e+(t^n^r)+(i>>>0)+a;return(o<<s|o>>>32-s)+t},o._ii=function(e,t,n,r,i,s,a){var o=e+(n^(t|~r))+(i>>>0)+a;return(o<<s|o>>>32-s)+t},o._blocksize=16,o._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(o(e,t));return t&&t.asBytes?n:t&&t.asString?a.bytesToString(n):r.bytesToHex(n)}},H1Tv:(e,t,n)=>{"use strict";n.d(t,{j8:()=>b});var r=n("aCH8");class i{constructor(e,t=10){this.value=16===t?`0x${e}`:e}modulo(e){return this.value=BigInt(this.value)%BigInt(e),this}toNumber(){return Number(this.value)}}const s=(e,t,n="")=>{const s=r(`${e}${t}${n}`);return new i(s,16).modulo(100).toNumber()};var a,o;!function(e){e.Draft="draft",e.Scheduled="scheduled",e.Running="running",e.Cooldown="cooldown",e.Ended="ended",e.Concluded="concluded"}(a||(a={})),function(e){e.Holdout="holdout",e.Exposure="exposure"}(o||(o={}));const u="{\n    handle\n    currentRollout {\n      salt\n      percentage\n    }\n    holdoutExperiments {\n     handle\n     variants {\n       handle\n       id\n       size\n     }\n    }\n    manualAssignments {\n      subjectId\n      variantHandle\n    }\n    shippedVariant { \n      handle\n      id\n      size\n    }\n    status\n    variants {\n      handle\n      id\n      size\n    }\n  }",l=`query experimentsByHandle($experimentHandles: [String!]!) {\n  experiments(handles: $experimentHandles) ${u}\n}`,h=`query experimentByHandle($experimentHandle: String!) {\n  experiment(handle: $experimentHandle) ${u}\n}`;class c{constructor(e,t){this.currentRequest=new Map,this.API_KEY=t,this.API_URL=`${e}/public/graphql`}async getExperimentByHandle(e){try{const t=await this.gqlRequest(h,{experimentHandle:e});if(t?.data?.experiment)return t.data.experiment;if(t.errors?.length)return null}catch(t){}return null}async getExperimentsByHandles(e){try{const t=await this.gqlRequest(l,{experimentHandles:e});if(t.data?.experiments)return t.data.experiments;if(t.errors?.length)return null}catch(t){}return null}gqlRequest(e,t){const n=JSON.stringify({query:e,variables:t});if(this.currentRequest.has(n))return this.currentRequest.get(n);const r=fetch(this.API_URL,{method:"POST",body:n,headers:{"content-type":"application/json",Authorization:`Token ${this.API_KEY}`}}).then((e=>e.json())).finally((()=>{this.currentRequest.delete(n)}));return this.currentRequest.set(n,r),r}}var m;!function(e){e.VariantFor="Verdict.experiment.variant_for",e.LookupVariantFor="Verdict.experiment.lookup_variant_for",e.Assign="Verdict.experiment.assign",e.ManualAssignmentFor="Verdict.experiment.manual_assignment_for",e.ShippedVariantAssignmentFor="Verdict.experiment.shipped_variant_assignment_for",e.PreviousAssignmentFor="Verdict.experiment.previous_assignment_for",e.InHoldout="Verdict.experiment.in_holdout",e.InRollout="Verdict.experiment.in_rollout",e.SubjectQualifies="Verdict.experiment.subject_qualifies",e.ExperimentNotFound="Verdict.experiment.fetcher.experiment_not_found",e.AssignmentConfigCache="Verdict.experiment.fetcher.assignment_config_cache",e.ExperimentsCache="Verdict.experiment.fetcher.experiments_cache"}(m||(m={}));const g={variant:null,isManualAssignment:!1};class d{constructor(e){this.assignmentLogQueue=new Set,this.experiment=e.rawExperiment,this.assignments=e.assignments,this.qualifier=e.qualifier,this.instrumentation=e.instrumentation}setQualifier(e){this.qualifier=e}removeQualifier(){this.qualifier=void 0}async variantFor(e){const{assignments:t,experiment:n}=this;this.flushAssignmentLogs();const r=await this.lookupVariantFor(e);if(r.variant)return r;if(!this.shouldAssignSubject(e))return g;if(!await this.qualify(e))return g;const i=this.getVariant(e);return i?(await t.store(n.handle,e,i,n?.currentRollout?.salt||""),this.assignmentLogQueue.add({isManualAssignment:!1,experimentHandle:this.experiment.handle,variant:i}),{variant:i,isManualAssignment:!1}):g}async lookupVariantFor(e){const t=this.manualAssignmentFor(e);if(t)return this.assignmentLogQueue.add({isManualAssignment:!0,experimentHandle:this.experiment.handle,variant:t.variant}),t;if(this.experiment.shippedVariant)return this.shippedVariantFor(this.experiment.shippedVariant,e);if(this.shouldReturnPreviousAssignment(e)){const t=await this.previousAssignment(e);if(t)return{variant:t,isManualAssignment:!1}}return g}subjectInRollout(e){const t=this.instrumentation?.mark();if(0===this.experiment.currentRollout?.percentage)return!1;if(!this.experiment.currentRollout?.percentage)return!0;const n=this.getDynamicRolloutHash(e),r=this.experiment.currentRollout?.percentage>n;return this.instrumentation?.notify({name:m.InRollout,tags:this.eventTags()},t),r}getVariant(e){return this.pickVariant(this.getHash(e),this.experiment.variants)}qualify(e){const t=this.instrumentation?.mark(),n=!this.qualifier||this.qualifier(e,this.experiment);return this.instrumentation?.notify({name:m.SubjectQualifies,tags:this.eventTags()},t),n}shouldReturnPreviousAssignment(e){return this.active()&&this.subjectInRollout(e)}shouldAssignSubject(e){return!(!this.active()||this.inCooldown()||!this.subjectInRollout(e)||this.assignHoldouts(e))}assignHoldouts(e){const t=this.instrumentation?.mark(),n=this.getHash(e);if(!this.hasHoldouts())return!1;let r=!1;for(const i of this.experiment.holdoutExperiments){const e=this.pickVariant(n,i.variants);e===o.Holdout&&(r=!0),this.assignmentLogQueue.add({isManualAssignment:!1,experimentHandle:i.handle,variant:e})}return this.instrumentation?.notify({name:m.InHoldout,tags:this.eventTags()},t),r}hasHoldouts(){return this.experiment.holdoutExperiments.length>0}flushAssignmentLogs(){this.assignmentLogQueue.clear()}assignmentLogs(){return Array.from(this.assignmentLogQueue.values())}async previousAssignment(e){const t=this.instrumentation?.mark(),{assignments:n,experiment:r}=this,i=await n.get(r.handle,e,r.currentRollout?.salt||"");return this.instrumentation?.notify({name:m.AssignmentConfigCache,tags:{hit:Boolean(i)}},t),i?i.variant:null}pickVariant(e,t){let n=0;for(const r of t)if(n+=r.size,n>e)return r.handle;return null}async shippedVariantFor(e,t){return this.assignHoldouts(t)?g:await this.qualify(t)?(this.instrumentation?.notify({name:m.ShippedVariantAssignmentFor,tags:this.eventTags()}),{variant:e.handle,isManualAssignment:!1}):g}manualAssignmentFor(e){const t=this.instrumentation?.mark(),n=this.experiment.manualAssignments.find((t=>t.subjectId===e));return this.instrumentation?.notify({name:m.ManualAssignmentFor,tags:this.eventTags()},t),n?{variant:n.variantHandle,isManualAssignment:!0}:null}getHash(e){const t=this.experiment.currentRollout?.salt||"";return s(this.experiment.handle,e,t)}getDynamicRolloutHash(e){return s(this.experiment.handle,e,"_in_beta")}eventTags(){return{handle:this.experiment.handle,num_qualifiers:this.qualifier?1:0,is_no_code_experiment:!1,is_holdout_experiment:!1}}active(){return this.experiment.status===a.Running||this.experiment.status===a.Cooldown}inCooldown(){return this.experiment.status===a.Cooldown}dehydrate(){return this.experiment}}function p(e){return 1e3*e}var f;!function(e){e.CacheFirst="cache-first",e.CacheOnly="cache-only",e.NetworkOnly="network-only"}(f||(f={}));class x{constructor(e){this.NAMESPACE="verdict:experiment",this.qualifiers=new Map,this.assignments=e.assignments,this.storageAdapter=e.storageAdapter,this.cacheConfiguration={cachePolicy:f.CacheFirst,cacheTTLSeconds:300,staleWhileRevalidateSeconds:60,staleIfErrorSeconds:300,...e.experimentCacheConfiguration||{}},this.networkFetcher=new c(e.apiHost,e.apiKey),this.instrumentation=e.instrumentation}async hydrate(e){await this.assignments.hydrate(e.assignments||[]);for(const t of e.experiments||[])await this.storeExperiment(t)}async dehydrate(){return{experiments:(await this.storageAdapter.getAll(this.NAMESPACE)).map((([,e])=>JSON.parse(e).experiment)),assignments:await this.assignments.dehydrate()||[]}}async lookupExperimentByHandle(e){if(this.cacheConfiguration.cachePolicy===f.CacheOnly)return(await this.getExperimentFromStorage(e))?.experiment||null;if(this.cacheConfiguration.cachePolicy===f.NetworkOnly)return this.fetchExperimentWithCacheFallback(e);if(this.cacheConfiguration.cachePolicy===f.CacheFirst){const t=await this.getExperimentFromStorage(e,!0);if(t?.experiment){const n=this.isCachedExperimentExpired(t),r=this.shouldServeStaleWhileRevalidate(t);return n&&r?(this.fetchAndStoreExperimentsInStorage([e]),t.experiment):n&&!r?this.fetchExperimentWithCacheFallback(e):t.experiment}return this.fetchExperimentWithCacheFallback(e)}return null}addQualifier(e,t){this.qualifiers.set(e,t)}removeQualifier(e){this.qualifiers.delete(e)}async fetchAndStoreExperimentsInStorage(e){const t=await this.getExperimentsFromNetwork(e);for(const n of t)await this.storeExperiment(n.experiment.dehydrate())}async fetchExperimentWithCacheFallback(e){try{const t=await this.getExperimentFromNetwork(e);if(!t?.experiment)throw new Error("Error Fetching Experiment");return await this.storeExperiment(t.experiment.dehydrate()),t.experiment}catch(t){const n=await this.getExperimentFromStorage(e,!0);return this.shouldServeStaleOnError(n)&&n?.experiment?n.experiment:null}}async getExperimentFromStorage(e,t){const n=await this.storageAdapter.get(this.keyFor(e));if(!n)return null;const r=JSON.parse(n);return this.isCachedExperimentExpired(r)&&!t?null:{experiment:new d({rawExperiment:r.experiment,assignments:this.assignments,qualifier:this.qualifiers.get(r.experiment.handle),instrumentation:this.instrumentation}),updatedAt:r.updatedAt}}async getExperimentFromNetwork(e){const t=await this.networkFetcher.getExperimentByHandle(e);return t?{experiment:new d({rawExperiment:t,assignments:this.assignments,qualifier:this.qualifiers.get(e)}),updatedAt:Date.now()}:null}async getExperimentsFromNetwork(e){const t=await this.networkFetcher.getExperimentsByHandles(e);return t?t.map((e=>({experiment:new d({rawExperiment:e,assignments:this.assignments,qualifier:this.qualifiers.get(e.handle)}),updatedAt:Date.now()}))):[]}storeExperiment(e){return this.storageAdapter.set(this.keyFor(e.handle),JSON.stringify({experiment:e,updatedAt:Date.now()}))}shouldServeStaleWhileRevalidate(e){return Date.now()-(e?.updatedAt||0)<p(this.cacheConfiguration.staleWhileRevalidateSeconds)}shouldServeStaleOnError(e){const t=this.storedExperimentAgeMilliseconds(e),n=p(this.cacheConfiguration.staleIfErrorSeconds);return this.cacheConfiguration.staleIfErrorSeconds>0&&t<n}storedExperimentAgeMilliseconds(e){return Date.now()-(e?.updatedAt||0)}isCachedExperimentExpired(e){return this.storedExperimentAgeMilliseconds(e)>p(this.cacheConfiguration.cacheTTLSeconds)}keyFor(e){return`${this.NAMESPACE}:${e}`}}class y extends Error{constructor(e){super(e),this.name="AssignmentStorageError"}}class A{constructor(e,t){this.logger=e,this.sourceApp=t||""}async logAssignment(e,t,n,r){const i={experiment:t,group:n,sourceApp:this.sourceApp,manualAssignment:r};"subjectId"in e?await this.logger.produce({schemaId:"experiment_assignments/1.2",payload:{subjectId:e.subjectId,...i}}):"shopId"in e&&"userToken"in e?await this.logger.produce({schemaId:"experiment_assignments_merchant_owned_pii/1.2",payload:{userToken:e.userToken,sessionToken:e.sessionToken,shopId:e.shopId,...i}}):"userToken"in e&&await this.logger.produce({schemaId:"experiment_assignments_shopify_owned_pii/1.2",payload:{userToken:e.userToken,sessionToken:e.sessionToken,...i}})}}function w(e){return"subjectId"in e?e.subjectId:"userToken"in e?e.userToken:null}class E{constructor(e){this.DEFAULT_TTL_SECONDS=15778476,this.NAMESPACE="verdict:assignment",this.storageAdapter=e}delete(e,t,n){return this.storageAdapter.delete(this.keyFor(e,t,n))}flush(){return this.storageAdapter.flush(this.NAMESPACE)}async hydrate(e){for(const[t,n]of e)await this.storageAdapter.set(t,n,this.DEFAULT_TTL_SECONDS)}async dehydrate(){return await this.storageAdapter.getAll(this.NAMESPACE)}async get(e,t,n){const r=await this.storageAdapter.get(this.keyFor(e,t,n));return r?JSON.parse(r):null}getAll(){return this.storageAdapter.getAll(this.NAMESPACE)}store(e,t,n,r,i){const s={variant:n,createdAt:Date.now()};return this.storageAdapter.set(this.keyFor(e,t,r),JSON.stringify(s),i||this.DEFAULT_TTL_SECONDS)}keyFor(e,t,n){return`${this.NAMESPACE}:${e}:${n}:${t}`}}class v{constructor(){this.storage=new Map}delete(e){return this.storage.delete(e),!0}get(e){return this.storage.get(e)||null}getAll(){return Array.from(this.storage.entries())}flush(){return this.storage.clear(),!0}set(e,t){return this.storage.set(e,t),!0}}class S extends Error{constructor(e,t){super(e),this.cause=t}}class _{produce(e){console.log(JSON.stringify(e))}}class k{constructor(e){this.configuration=this.buildVerdictConfiguration(e)}addQualifier(e,t){this.configuration.experiments.addQualifier(e,t)}removeQualifier(e){this.configuration.experiments.removeQualifier(e)}async assignVariant(e,t,n={shouldLogAssignment:!0}){try{const{logger:r}=this.configuration,i=w(t);if(!i)return null;const s=await this.lookupExperiment(e);if(!s)return null;const a=this.configuration.instrumentation?.mark(),{variant:o}=await s.variantFor(i);if(this.configuration.instrumentation?.notify({name:m.VariantFor,tags:this.defaultTags(e)},a),n.shouldLogAssignment){const e=s.assignmentLogs();await Promise.all(e.map((e=>r.logAssignment(t,e.experimentHandle,e.variant,e.isManualAssignment)))),s.flushAssignmentLogs()}return o||null}catch(r){return this.configuration.onError(new S(`Error assigning subject for experiment: ${e}`,r)),null}}assignAll(e,t,n={shouldLogAssignment:!0}){const r=new Set(e);return Promise.all(Array.from(r.values()).map((e=>new Promise((r=>{this.assignVariant(e,t,n).then((t=>{r([e,t])})).catch((t=>{this.configuration.onError(t),r([e,null])}))})))))}async lookupVariant(e,t){try{const n=w(t);if(!n)return null;const r=await this.lookupExperiment(e);if(!r)return null;const i=this.configuration.instrumentation?.mark(),{variant:s}=await r.lookupVariantFor(n);return this.configuration.instrumentation?.notify({name:m.LookupVariantFor,tags:this.defaultTags(e)},i),s||null}catch(n){return this.configuration.onError(new S(`Error looking up subject for experiment: ${e}`,n)),null}}async preload(e){try{await this.configuration.experiments.fetchAndStoreExperimentsInStorage(e)}catch(t){this.configuration.onError(new S("Error preloading experiments",t))}}async hydrate(e){try{await this.configuration.experiments.hydrate(e)}catch(t){this.configuration.onError(new S("Hydration error",t))}}async dehydrate(){try{return await this.configuration.experiments.dehydrate()}catch(e){return this.configuration.onError(new S("Dehydration error",e)),null}}async lookupExperiment(e){const t=this.configuration.instrumentation?.mark(),n=await this.configuration.experiments.lookupExperimentByHandle(e);return n?(this.configuration.instrumentation?.notify({name:m.ExperimentsCache,tags:this.defaultTags(e)},t),n):(this.configuration.instrumentation?.notify({name:m.ExperimentNotFound,tags:this.defaultTags(e)}),null)}buildVerdictConfiguration(e){const t={experiments:new x({apiKey:e?.apiKey||"",apiHost:e?.apiHost||"https://experiments.shopify.com",assignments:new E(e?.assignmentStorage||new v),storageAdapter:e?.experimentStorage||new v,experimentCacheConfiguration:e?.experimentCacheConfiguration||{},instrumentation:e?.instrumentation}),onError:e?.onError||console.error,logger:new A(e?.logger||new _,e?.appName)};return e?.instrumentation&&(t.instrumentation=e?.instrumentation),t}defaultTags(e){return{handle:e,is_no_code_experiment:!1,is_holdout_experiment:!1}}}class C{constructor(){if(!this.storageAvailable())throw new y("localStorage couldn't be initialized. It may be full or disabled in the current environment")}delete(e){try{return localStorage.removeItem(e),!0}catch(t){const n=t instanceof Error?t.message:"Unknown Error";throw new y(`Verdict failed to delete '${e}' from Assignment Local Storage. Original Error: ${n}`)}}get(e){try{return localStorage.getItem(e)}catch(t){const n=t instanceof Error?t.message:"Unknown Error";throw new y(`Verdict failed to read '${e}' from Assignment Local Storage. Original Error: ${n}`)}}getAll(e){return this.allValues(e)}set(e,t){try{return localStorage.setItem(e,t),!0}catch(n){const t=n instanceof Error?n.message:"Unknown Error";throw new y(`Verdict failed to set '${e}' to Assignment Local Storage. Original Error: ${t}`)}}flush(e){return this.allValues(e).forEach((([e])=>this.delete(e))),!0}allValues(e){const t=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r?.trim()?.startsWith(e)&&t.push([r,localStorage.getItem(r)])}return t}storageAvailable(){let e;try{e=window.localStorage;const t="__storage_test__";return e.setItem(t,t),e.removeItem(t),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}}class b extends k{constructor(e){const t={...e};t.apiHost||(t.apiHost="https://experiments.shopify.com"),t.assignmentStorage||(t.assignmentStorage=new C),t.experimentStorage||(t.experimentStorage=new C),super(t)}}}}]);
}