View file File name : index.js Content :/*! For license information please see index.js.LICENSE.txt */ (()=>{"use strict";var e={792:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(790),i=n(609);const o={isEligible:!0};function a(e){const t=(t,n={})=>{const r={...o,...n},[,a]=(0,i.useReducer)((e=>e+1),0),s=(0,i.useRef)(t);if((0,i.useEffect)((()=>{let n=!0;return r.isEligible&&e.loadExperimentAssignment(t).then((()=>{n&&a()})),()=>{n=!1}}),[t,r.isEligible]),t===s.current||s.current.startsWith("explat_test")||e.config.logError({message:"[ExPlat] useExperiment: experimentName should never change between renders!"}),!r.isEligible)return[!1,null];const m=e.dangerouslyGetMaybeLoadedExperimentAssignment(t);return[!m,m]};return{useExperiment:t,Experiment:({defaultExperience:e,treatmentExperience:n,loadingExperience:i,name:o,options:a})=>{const[s,m]=t(o,a);return s?(0,r.jsx)(r.Fragment,{children:i}):m?.variationName?(0,r.jsx)(r.Fragment,{children:n}):(0,r.jsx)(r.Fragment,{children:e})},ProvideExperimentData:({children:e,name:n,options:r})=>{const[i,o]=t(n,r);return e(i,o)}}}},517:(e,t,n)=>{n.d(t,{kU:()=>c,pg:()=>p});var r=n(689),i=n(808),o=n(738),a=n(762),s=n(626);const m=1e4;Error;function c(e){if("undefined"==typeof window)throw new Error("Running outside of a browser context.");const t={},n=(...t)=>{try{e.logError(...t)}catch(e){}};try{(0,r.bZ)()}catch(e){n({message:e.message,source:"removeExpiredExperimentAssignments-error"})}return{loadExperimentAssignment:async c=>{try{if(!s.Eo(c))throw new Error(`Invalid experimentName: "${c}"`);const n=(0,r.B1)(c);if(n&&i.H2(n))return n;void 0===t[c]&&(t[c]=(t=>a.MC((async()=>{const n=await o.FI(e,t);return(0,r.a2)(n),n})))(c));let p=m;Math.random()>.5&&(p=5e3);const l=await a.BK(t[c](),p);if(!l)throw new Error("Could not fetch ExperimentAssignment");return l}catch(e){n({message:e.message,experimentName:c,source:"loadExperimentAssignment-initialError"})}try{const e=(0,r.B1)(c);if(e)return e;const t=(0,i.fj)(c);return(0,r.a2)(t),t}catch(e){return n({message:e.message,experimentName:c,source:"loadExperimentAssignment-fallbackError"}),(0,i.fj)(c)}},dangerouslyGetExperimentAssignment:t=>{try{if(!s.Eo(t))throw new Error(`Invalid experimentName: ${t}`);const i=(0,r.B1)(t);if(!i)throw new Error("Trying to dangerously get an ExperimentAssignment that hasn't loaded.");return e.isDevelopmentMode&&i&&a.XZ()-i.retrievedTimestamp<1e3&&n({message:"Warning: Trying to dangerously get an ExperimentAssignment too soon after loading it.",experimentName:t,source:"dangerouslyGetExperimentAssignment"}),i}catch(r){return e.isDevelopmentMode&&n({message:r.message,experimentName:t,source:"dangerouslyGetExperimentAssignment-error"}),(0,i.fj)(t)}},dangerouslyGetMaybeLoadedExperimentAssignment:t=>{try{if(!s.Eo(t))throw new Error(`Invalid experimentName: ${t}`);const e=(0,r.B1)(t);return e||null}catch(r){return e.isDevelopmentMode&&n({message:r.message,experimentName:t,source:"dangerouslyGetMaybeLoadedExperimentAssignment-error"}),(0,i.fj)(t)}},config:e}}function p(e){return{loadExperimentAssignment:async t=>(e.logError({message:"Attempting to load ExperimentAssignment in SSR context",experimentName:t}),(0,i.fj)(t)),dangerouslyGetExperimentAssignment:t=>(e.logError({message:"Attempting to dangerously get ExperimentAssignment in SSR context",experimentName:t}),(0,i.fj)(t)),dangerouslyGetMaybeLoadedExperimentAssignment:t=>(e.logError({message:"Attempting to dangerously get ExperimentAssignment in SSR context",experimentName:t}),(0,i.fj)(t)),config:e}}},226:(e,t,n)=>{n.d(t,{k:()=>i});var r=n(517);const i="undefined"==typeof window?r.pg:r.kU},689:(e,t,n)=>{n.d(t,{B1:()=>c,a2:()=>m,bZ:()=>d});var r=n(808),i=n(765),o=n(626);const a="explat-experiment-",s=e=>`${a}-${e}`;function m(e){o.zV(e);const t=c(e.experimentName);if(t&&e.retrievedTimestamp<t.retrievedTimestamp)throw new Error("Trying to store an older experiment assignment than is present in the store, likely a race condition.");i.A.setItem(s(e.experimentName),JSON.stringify(e))}function c(e){const t=i.A.getItem(s(e));if(t)return o.zV(JSON.parse(t))}const p=e=>[...Array(e).keys()];function l(e){return e.startsWith(a)}function u(e){return e.slice(a.length+1)}function d(){p(i.A.length).map((e=>i.A.key(e))).filter(l).map(u).filter((e=>{try{if(r.H2(c(e)))return!1}catch(e){}return!0})).map(s).map((e=>i.A.removeItem(e)))}},808:(e,t,n)=>{n.d(t,{H2:()=>i,fj:()=>a,fn:()=>o});var r=n(762);function i(e){return r.XZ()<e.ttl*r.If+e.retrievedTimestamp}const o=60,a=(e,t=o)=>({experimentName:e,variationName:null,retrievedTimestamp:r.XZ(),ttl:Math.max(o,t),isFallbackExperimentAssignment:!0})},765:(e,t,n)=>{n.d(t,{A:()=>i});let r={_data:{},setItem:function(e,t){this._data[e]=t},getItem:function(e){return this._data.hasOwnProperty(e)?this._data[e]:null},removeItem:function(e){delete this._data[e]},clear:function(){this._data={}},get length(){return Object.keys(this._data).length},key:function(e){const t=Object.keys(this._data);return e in t?t[e]:null}};try{window.localStorage&&(r=window.localStorage)}catch(e){}const i=r},738:(e,t,n)=>{n.d(t,{FI:()=>l});var r=n(808),i=n(765),o=n(762),a=n(626);function s(e){if(function(e){return(0,a.Gv)(e)&&(0,a.Gv)(e.variations)&&"number"==typeof e.ttl&&0<e.ttl}(e))return e;throw new Error("Invalid FetchExperimentAssignmentResponse")}const m="explat-last-anon-id",c="explat-last-anon-id-retrieval-time",p=async e=>{const t=await e();if(t)return i.A.setItem(m,t),i.A.setItem(c,String((0,o.XZ)())),t;const n=i.A.getItem(m),r=i.A.getItem(c);return n&&r&&(0,o.XZ)()-parseInt(r,10)<864e5?n:null};async function l(e,t){const n=(0,o.XZ)(),{variations:i,ttl:m}=s(await e.fetchExperimentAssignment({anonId:await p(e.getAnonId),experimentName:t})),c=Math.max(r.fn,m),l=Object.entries(i).map((([e,t])=>({experimentName:e,variationName:t,retrievedTimestamp:n,ttl:c}))).map(a.zV);if(l.length>1)throw new Error("Received multiple experiment assignments while trying to fetch exactly one.");if(0===l.length)return r.fj(t,c);const u=l[0];if(u.experimentName!==t)throw new Error("Newly fetched ExperimentAssignment's experiment name does not match request.");if(!r.H2(u))throw new Error("Newly fetched experiment isn't alive.");return u}},762:(e,t,n)=>{n.d(t,{BK:()=>a,If:()=>r,MC:()=>s,XZ:()=>o});const r=1e3;let i=Date.now();function o(){const e=Date.now();return i=i<e?e:i+1,i}function a(e,t){return Promise.race([e,new Promise(((e,n)=>setTimeout((()=>n(new Error(`Promise has timed-out after ${t}ms.`))),t)))])}function s(e){let t=null;return()=>(t||(t=e().finally((()=>{t=null}))),t)}},626:(e,t,n)=>{function r(e){return"object"==typeof e&&null!==e}function i(e){return"string"==typeof e&&""!==e&&/^[a-z0-9_]*$/.test(e)}function o(e){if(!function(e){return r(e)&&i(e.experimentName)&&(i(e.variationName)||null===e.variationName)&&"number"==typeof e.retrievedTimestamp&&"number"==typeof e.ttl&&0!==e.ttl}(e))throw new Error("Invalid ExperimentAssignment");return e}n.d(t,{Eo:()=>i,Gv:()=>r,zV:()=>o})},767:(e,t)=>{t.parse=function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var n={},r=e.length,i=r-2;if(i<0)return n;var o=t&&t.decode||c,a=0,p=0,u=0;do{if(-1===(p=e.indexOf("=",a)))break;if(-1===(u=e.indexOf(";",a)))u=r;else if(p>u){a=e.lastIndexOf(";",p-1)+1;continue}var d=s(e,a,p),f=m(e,p,d),g=e.slice(d,f);if(void 0===n[g]){var x=s(e,p+1,u),h=m(e,u,x);34===e.charCodeAt(x)&&34===e.charCodeAt(h-1)&&(x++,h--);var w=e.slice(x,h);n[g]=l(w,o)}a=u+1}while(a<i);return n},t.serialize=function(e,t,s){var m=s||{},c=m.encode||p;if("function"!=typeof c)throw new TypeError("option encode is invalid");if(!r.test(e))throw new TypeError("argument name is invalid");var l=c(t);if(l&&!i.test(l))throw new TypeError("argument val is invalid");var u=e+"="+l;if(null!=m.maxAge){var d=m.maxAge-0;if(!isFinite(d))throw new TypeError("option maxAge is invalid");u+="; Max-Age="+Math.floor(d)}if(m.domain){if(!o.test(m.domain))throw new TypeError("option domain is invalid");u+="; Domain="+m.domain}if(m.path){if(!a.test(m.path))throw new TypeError("option path is invalid");u+="; Path="+m.path}if(m.expires){var f=m.expires;if(!function(e){return"[object Date]"===n.call(e)||e instanceof Date}(f)||isNaN(f.valueOf()))throw new TypeError("option expires is invalid");u+="; Expires="+f.toUTCString()}m.httpOnly&&(u+="; HttpOnly");m.secure&&(u+="; Secure");m.partitioned&&(u+="; Partitioned");if(m.priority){switch("string"==typeof m.priority?m.priority.toLowerCase():m.priority){case"low":u+="; Priority=Low";break;case"medium":u+="; Priority=Medium";break;case"high":u+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(m.sameSite){switch("string"==typeof m.sameSite?m.sameSite.toLowerCase():m.sameSite){case!0:u+="; SameSite=Strict";break;case"lax":u+="; SameSite=Lax";break;case"strict":u+="; SameSite=Strict";break;case"none":u+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return u};var n=Object.prototype.toString,r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,i=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,o=/^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,a=/^[\u0020-\u003A\u003D-\u007E]*$/;function s(e,t,n){do{var r=e.charCodeAt(t);if(32!==r&&9!==r)return t}while(++t<n);return n}function m(e,t,n){for(;t>n;){var r=e.charCodeAt(--t);if(32!==r&&9!==r)return t+1}return n}function c(e){return-1!==e.indexOf("%")?decodeURIComponent(e):e}function p(e){return encodeURIComponent(e)}function l(e,t){try{return t(e)}catch(t){return e}}},889:(e,t,n)=>{n.d(t,{Ck:()=>a,wf:()=>o});var r=n(767);let i=null;const o=async()=>{let e=0;return i=new Promise((t=>{const n=()=>{const i=r.parse(document.cookie).tk_ai||null;"string"!=typeof i||""===i?99<=e?t(null):(e+=1,setTimeout(n,50)):t(i)};n()})),i},a=async()=>await i},222:(e,t,n)=>{n.d(t,{V:()=>m,z:()=>s});var r=n(455),i=n.n(r),o=n(832);const a=(e=!1)=>async({experimentName:t,anonId:n})=>{if(!n)throw new Error("Tracking is disabled, can't fetch experimentAssignment");const r={experiment_name:t,anon_id:n??void 0,as_connected_user:e},a=(0,o.addQueryArgs)("jetpack/v4/explat/assignments",r);return await i()({path:a})},s=a(!1),m=a(!0)},69:(e,t,n)=>{n.d(t,{v:()=>i});var r=n(382);const i=e=>{const t=e=>{r.D&&console.error("[ExPlat] Unable to send error to server:",e)};try{const{message:n,...i}=e,o={message:n,properties:{...i,context:"explat",explat_client:"jetpack"}};if(r.D)console.error("[ExPlat] ",e.message,e);else{const e=new window.FormData;e.append("error",JSON.stringify(o)),window.fetch("https://public-api.wordpress.com/rest/v1.1/js-error",{method:"POST",body:e}).catch(t)}}catch(e){t(e)}}},382:(e,t,n)=>{n.d(t,{D:()=>r});const r=!1},609:e=>{e.exports=window.React},790:e=>{e.exports=window.ReactJSXRuntime},455:e=>{e.exports=window.wp.apiFetch},832:e=>{e.exports=window.wp.url}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=n(226),i=n(792),o=n(889),a=n(222),s=n(69),m=n(382);(0,o.wf)().catch((e=>(0,s.v)({message:e.message})));const c=(0,r.k)({fetchExperimentAssignment:a.z,getAnonId:o.Ck,logError:s.v,isDevelopmentMode:m.D}),{loadExperimentAssignment:p,dangerouslyGetExperimentAssignment:l}=c,{useExperiment:u,Experiment:d,ProvideExperimentData:f}=(0,i.A)(c),g=(0,r.k)({fetchExperimentAssignment:a.V,getAnonId:o.Ck,logError:s.v,isDevelopmentMode:m.D}),{loadExperimentAssignment:x,dangerouslyGetExperimentAssignment:h}=g,{useExperiment:w,Experiment:E,ProvideExperimentData:y}=(0,i.A)(g)})();