(()=>{var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t),e.d(t,{experiments:()=>i});var r={};e.r(r),e.d(r,{getExperimentSupport:()=>l,getExperimentType:()=>c,getExperimentTypes:()=>p,getExperimentView:()=>m,getHelpString:()=>y,hasExperimentSupport:()=>u});var n={};e.r(n),e.d(n,{addExperimentTypes:()=>f,removeExperimentTypes:()=>E});var i={};e.r(i),e.d(i,{registerExperimentType:()=>h,store:()=>x});const o=window.wp.data,s=window.lodash,a=window.nab.utils;function p(e){return e.experimentTypes}function c(e,t){return e.experimentTypes[t]}const l=function(e,t,r){const n=d(e,t);return n?.supports[r]};function u(e,t,r){return!!l(e,t,r)}function m(e,t,r){const n=d(e,t);if(n)return n.views[r]}function y(e,t,r){const n=d(e,t);return n?.help[r]||""}const d=(e,t)=>"string"==typeof t?c(e,t):t;function f(e){return{type:"ADD_EXPERIMENT_TYPES",experimentTypes:(0,s.castArray)(e)}}function E(e){return{type:"REMOVE_EXPERIMENT_TYPES",names:(0,s.castArray)(e)}}const g={experimentTypes:{}},x=(0,o.createReduxStore)("nab/experiments",{reducer:function(e=g,t){return function(e,t){switch(t.type){case"ADD_EXPERIMENT_TYPES":{const r=t.experimentTypes.filter(t=>!(0,s.isEqual)(e.experimentTypes[t.name],t));return r.length?{...e,experimentTypes:{...e.experimentTypes,...(0,s.keyBy)(r,"name")}}:e}case"REMOVE_EXPERIMENT_TYPES":{const r=(0,s.omit)(e.experimentTypes,t.names);return(0,s.isEqual)(e.experimentTypes,r)?e:{...e,experimentTypes:r}}}}(e,t)??e},selectors:r,actions:n});function h(e,t){const r={description:"",supports:{},checks:P(t)?t.checks:{getControlError:()=>!1,getAlternativeError:()=>!1},...t,name:e};if("nab/heatmap"===e)return(0,o.dispatch)(x).addExperimentTypes(r),r;if("string"==typeof e)if(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(e))if((0,o.select)(x).getExperimentType(e))console.error(`Experiment type “${e}” is already registered.`);else if(P(r))if(T(r))if(v(r))if(b(r))if(w(r))if((0,a.isValidIcon)(t.icon))if(S(r)){if(_(r))return(0,o.dispatch)(x).addExperimentTypes(r),r;console.error(`The experiment “${e}” must specify original and alternative edit views.`)}else console.error(`The experiment “${e}” must specify original and alternative default values.`);else console.error("The icon passed is invalid. The icon should be an element or a function.");else console.error(`The experiment “${e}” must have an icon.`);else console.error(`The experiment “${e}” must have a title.`);else console.error(`The experiment “${e}” must have a valid category.`);else console.error(`The experiment “${e}” must provide help strings explaining the control version and its variants.`);else console.error(`Experiment type “${e}” must provide at least two checks: “getControlError” and “getAlternativeError”.`);else console.error("Experiment type names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-experiment");else console.error("Experiment type names must be strings.")}!function(e){(0,o.register)(e)}(x);const T=e=>!!e.help&&"string"==typeof e.help.original&&!!e.help.original&&"string"==typeof e.help.alternative&&!!e.help.alternative,v=e=>["page","global","woocommerce","other"].includes(e.category??""),b=e=>"string"==typeof e.title&&!!e.title,w=e=>"icon"in e,_=e=>(0,s.isFunction)(e.views?.original)&&(0,s.isFunction)(e.views?.alternative),P=e=>(0,s.isFunction)(e.checks?.getControlError)&&(0,s.isFunction)(e.checks?.getAlternativeError),S=e=>(0,s.isObject)(e.views?.original)&&(0,s.isObject)(e.defaults?.alternative)})();var r=nab="undefined"==typeof nab?{}:nab;for(var n in t)r[n]=t[n];t.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();