a()(e).isValid(),b=(e,a)=>{if("start"===a)return e.startOf("day").format(p);if("now"===a)return e.format(p);if("end"===a)return e.endOf("day").format(p);throw new Error("appendTimestamp requires second parameter to be either `start`, `now` or `end`")};function M(e,r){if(a().isMoment(r))return r.isValid()?r:null;if("string"==typeof r){const o=a()(r,[c,e],!0);return o.isValid()?o:null}throw new Error("toMoment requires a string to be passed as an argument")}function l(e,a){const r=e.year()===a.year(),o=r&&e.month()===a.month(),t=r&&o&&e.isSame(a,"day"),n=(0,i.__)("MMM D, YYYY","woocommerce");if(t)return e.format(n);if(o){const r=e.date();return e.format(n).replace(String(r),`${r} - ${a.date()}`)}if(r){const r=(0,i.__)("MMM D","woocommerce");return`${e.format(r)} - ${a.format(n)}`}return`${e.format(n)} - ${a.format(n)}`}function f(){return window.wcSettings&&window.wcSettings.timeZone?["+","-"].includes(window.wcSettings.timeZone.charAt(0))?a()().utcOffset(window.wcSettings.timeZone):a()().tz(window.wcSettings.timeZone):a()()}function d(e,r){const o=f().startOf(e).subtract(1,e),t=o.clone().endOf(e);let i,n;if("previous_period"===r)if("year"===e)i=a()().startOf(e).subtract(2,e),n=i.clone().endOf(e);else{const e=t.diff(o,"days");n=o.clone().subtract(1,"days"),i=n.clone().subtract(e,"days")}else"week"===e?(i=o.clone().subtract(1,"years"),n=t.clone().subtract(1,"years")):(i=o.clone().subtract(1,"years"),n=i.clone().endOf(e));return"month"===e&&(n=n.clone().endOf("month")),{primaryStart:o,primaryEnd:t,secondaryStart:i,secondaryEnd:n}}function z(e,a){const r=f().startOf(e),o=f(),t=o.diff(r,"days");let i,n;return"previous_period"===a?(i=r.clone().subtract(1,e),n=o.clone().subtract(1,e)):(i=r.clone().subtract(1,"years"),n=i.clone().add(t+1,"days").subtract(1,"seconds")),{primaryStart:r,primaryEnd:o,secondaryStart:i,secondaryEnd:n}}const m=(0,t.memoize)(((e,a,r,o)=>{switch(e){case"today":return z("day",a);case"yesterday":return d("day",a);case"week":return z("week",a);case"last_week":return d("week",a);case"month":return z("month",a);case"last_month":return d("month",a);case"quarter":return z("quarter",a);case"last_quarter":return d("quarter",a);case"year":return z("year",a);case"last_year":return d("year",a);case"custom":if(!r||!o)throw Error("Custom date range requires both after and before dates.");const e=o.diff(r,"days");if("previous_period"===a){const a=r.clone().subtract(1,"days");return{primaryStart:r,primaryEnd:o,secondaryStart:a.clone().subtract(e,"days"),secondaryEnd:a}}return{primaryStart:r,primaryEnd:o,secondaryStart:r.clone().subtract(1,"years"),secondaryEnd:o.clone().subtract(1,"years")}}}),((e,a,r,o)=>[e,a,r&&r.format(),o&&o.format()].join(":"))),O=(0,t.memoize)(((e,r,o,t,i)=>{if(e&&r)return{period:e,compare:r,after:o?a()(o):null,before:t?a()(t):null};const c=(0,n.parse)(i.replace(/&/g,"&"));return"string"!=typeof c.period&&(console.warn(`Unexpected default period type ${c.period}`),c.period=""),"string"!=typeof c.compare&&(console.warn(`Unexpected default compare type ${c.compare}`),c.compare=""),{period:c.period,compare:c.compare,after:c.after&&s(c.after)?a()(c.after):null,before:c.before&&s(c.before)?a()(c.before):null}}),((e,a,r,o,t)=>[e,a,r,o,t].join(":"))),y=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"period=month&compare=previous_year";const{period:r,compare:o,after:t,before:i}=e;return O(r,o,t,i,a)},q=(0,t.memoize)(((e,a,r,o,i,n)=>{const c=(0,t.find)(A,(a=>a.value===e));if(!c)throw new Error(`Cannot find period: ${e}`);const p=(0,t.find)(u,(e=>e.value===a));if(!p)throw new Error(`Cannot find compare: ${a}`);return{primary:{label:c.label,range:l(r,o),after:r,before:o},secondary:{label:p.label,range:l(i,n),after:i,before:n}}}),((e,a,r,o,t,i)=>[e,a,r&&r.format(),o&&o.format(),t&&t.format(),i&&i.format()].join(":"))),h=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"period=month&compare=previous_year";const{period:r,compare:o,after:t,before:i}=y(e,a),n=m(r,o,t,i);if(!n)throw Error("Invalid date range");const{primaryStart:c,primaryEnd:p,secondaryStart:A,secondaryEnd:u}=n;return q(r,o,c,p,A,u)},g=(e,r)=>{const o=a()(e),t=a()(r);return o.diff(t,"days")},W=(e,r,o,t,i)=>{const n=a()(e);if("previous_year"===t)return n.clone().subtract(1,"years");const c=a()(r),p=a()(o),A=c.diff(p,i);return n.clone().subtract(A,i)};function E(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"period=&compare=previous_year";const{period:r}=y(e,a);let o=[];if("custom"===r){const{primary:a}=h(e),r=g(a.before,a.after);o=r>=365?["day","week","month","quarter","year"]:r>=90?["day","week","month","quarter"]:r>=28?["day","week","month"]:r>=7?["day","week"]:r>1&&r<7?["day"]:["hour","day"]}else switch(r){case"today":case"yesterday":o=["hour","day"];break;case"week":case"last_week":default:o=["day"];break;case"month":case"last_month":o=["day","week"];break;case"quarter":case"last_quarter":o=["day","week","month"];break;case"year":case"last_year":o=["day","week","month","quarter"]}return o}function S(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"period=&compare=previous_year";const r=E(e,a),o=r[0];let t=e.interval||o;return e.interval&&!r.includes(e.interval)&&(t=o),t}function B(e){let{chartType:a}=e;return void 0!==a&&["line","bar"].includes(a)?a:"line"}const P=63,T=9,_="m/d/Y";function v(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r="%B %-d, %Y",o="%B %-d, %Y",t="%Y-%m-%d",n="%b %Y",c=_;switch(e){case"hour":r="%_I%p %B %-d, %Y",o="%_I%p %b %-d, %Y",t="%_I%p",n="%b %-d, %Y",c="h A";break;case"day":a1&&void 0!==arguments[1]?arguments[1]:0,r="F j, Y",o="F j, Y",t="Y-m-d",n="M Y",c=_;switch(e){case"hour":r="gA F j, Y",o="gA M j, Y",t="gA",n="M j, Y",c="h A";break;case"day":a
1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{type:"d3"};return"php"===r.type?L(e,a):v(e,a)}function X(e){let{userLocale:r,weekdaysShort:o}=e;"en"!==a().locale()&&a().updateLocale(r,{longDateFormat:{L:(0,i.__)("MM/DD/YYYY","woocommerce"),LL:(0,i.__)("MMMM D, YYYY","woocommerce"),LLL:(0,i.__)("D MMMM YYYY LT","woocommerce"),LLLL:(0,i.__)("dddd, D MMMM YYYY LT","woocommerce"),LT:(0,i.__)("HH:mm","woocommerce"),LTS:"h:mm:ss A"},weekdaysMin:o})}const N={invalid:(0,i.__)("Invalid date","woocommerce"),future:(0,i.__)("Select a date in the past","woocommerce"),startAfterEnd:(0,i.__)("Start date must be before end date","woocommerce"),endBeforeStart:(0,i.__)("Start date must be before end date","woocommerce")};function w(e,r,o,t,i){const n=M(i,r);return n?a()().isBefore(n,"day")?{date:null,error:N.future}:"after"===e&&o&&n.isAfter(o,"day")?{date:null,error:N.startAfterEnd}:"before"===e&&t&&n.isBefore(t,"day")?{date:null,error:N.endBeforeStart}:{date:n}:{date:null,error:N.invalid}}}(),(window.wc=window.wc||{}).date=o}();