@flarehr/apollo-benefits 2.89.56619 → 2.90.56957
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{datadog-c27a43eb.js → datadog-eeb687f6.js} +1 -1
- package/dist/assets/{date-fns-20ad091e.js → date-fns-1aaef347.js} +1 -1
- package/dist/assets/{framer-motion-04a96014.js → framer-motion-7d482d44.js} +1 -1
- package/dist/assets/{index-9ce2ee20.js → index-5d2a90a4.js} +9 -9
- package/dist/assets/index-81650659.js +32 -0
- package/dist/assets/{vendor-1c5ad091.js → vendor-fefcaaa7.js} +23 -23
- package/dist/config.json +1 -2
- package/dist/index.html +5 -6
- package/package.json +1 -2
- package/dist/assets/@splitsoftware-dc67820b.js +0 -18
- package/dist/assets/index-a3cf435b.js +0 -32
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var es=Object.defineProperty;var ts=(t,e,r)=>e in t?es(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var O=(t,e,r)=>(ts(t,typeof e!="symbol"?e+"":e,r),r);import{
|
|
1
|
+
var es=Object.defineProperty;var ts=(t,e,r)=>e in t?es(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var O=(t,e,r)=>(ts(t,typeof e!="symbol"?e+"":e,r),r);import{u as s,aL as rs,aM as ns,j as se,aB as zr,p as M,k as is,G as as,q as _i,h as X,l as A,T as R,F as Tt,y as ss,aN as Pi,S as ls,x as Wr,z as Yr,C as os,at as cs,K as xe,Q as ds,aO as Ii,an as Mt,v as j,I as ke,D as Hr,P as B,w as Kr,aP as On,aQ as us,aR as fs,ag as hs,aS as $i,aT as nt,aU as Li,ah as Vi,A as Ri,J as Te,aV as ms,B as gs,aW as _n,am as ue,aX as ps,aY as ae,aZ as Fr,a_ as ys,a$ as vs,H as ji,b0 as bs,aj as Bi,ak as it,al as Ae,s as Ui,b1 as zi,b2 as Wi,Y as wt,X as ws,U as xs,b3 as ks,b4 as Es,b5 as Ds,aw as Fs,ax as Ns,ay as xt}from"./vendor-fefcaaa7.js";import{B as at,u as Ss,U as Cs,M as qr,L as pt,a as Gr,g as Yi,b as yt,w as Ee,c as $,d as Hi,e as st,f as As,P as zt,h as Ki,i as qi,j as Pn,s as In,p as $n,D as Ts,k as Gi,l as Ln,m as T,n as Ms,o as Os,I as dr,q as ur,r as Vn,t as _s,v as lt,x as Ot,y as Ps,H as Is,z as $s,A as Ls}from"./index-81650659.js";import{g as Xr,d as Rn,t as Xi,e as jn,f as Vs,h as _t,m as Ji,j as Rs,k as js,s as Bn}from"./lodash-5d893f8c.js";import{m as Ve,L as Jr}from"./framer-motion-7d482d44.js";import{p as kt,i as fr,b as Un}from"./date-fns-1aaef347.js";import"./oidc-client-6f6e47c2.js";import"./datadog-eeb687f6.js";const Wt=t=>s("div",{className:"lg:flex lg:items-center lg:justify-between",children:[s("div",{className:"flex-1 min-w-0",children:s("div",{className:"relative",children:[s("h3",{className:"text-2xl font-extrabold text-gray-900 tracking-tight sm:text-3xl",children:t.title}),s("p",{className:"mt-3 text-lg text-gray-500",children:t.subTitle})]})}),t.buttonTitle&&s("div",{className:"mt-5 flex lg:mt-0 lg:ml-4 self-end",children:s("span",{children:s("button",{type:"button",disabled:t.isLoading,className:"inline-flex items-center px-4 py-2 border border-transparent disabled:opacity-50 rounded-md shadow-sm text-sm font-medium text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",onClick:t.handleButtonClick,children:[s(rs,{className:"-ml-1 mr-2 h-5 w-5","aria-hidden":"true"}),t.buttonTitle]})})})]});var Bs=function(e){return Us(e)&&!zs(e)};function Us(t){return!!t&&typeof t=="object"}function zs(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||Hs(t)}var Ws=typeof Symbol=="function"&&Symbol.for,Ys=Ws?Symbol.for("react.element"):60103;function Hs(t){return t.$$typeof===Ys}function Ks(t){return Array.isArray(t)?[]:{}}function Pt(t,e){return e.clone!==!1&&e.isMergeableObject(t)?ut(Ks(t),t,e):t}function qs(t,e,r){return t.concat(e).map(function(n){return Pt(n,r)})}function Gs(t,e,r){var n={};return r.isMergeableObject(t)&&Object.keys(t).forEach(function(i){n[i]=Pt(t[i],r)}),Object.keys(e).forEach(function(i){!r.isMergeableObject(e[i])||!t[i]?n[i]=Pt(e[i],r):n[i]=ut(t[i],e[i],r)}),n}function ut(t,e,r){r=r||{},r.arrayMerge=r.arrayMerge||qs,r.isMergeableObject=r.isMergeableObject||Bs;var n=Array.isArray(e),i=Array.isArray(t),a=n===i;return a?n?r.arrayMerge(t,e,r):Gs(t,e,r):Pt(e,r)}ut.all=function(e,r){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,i){return ut(n,i,r)},{})};var Nr=ut,zn=Array.isArray,Wn=Object.keys,Xs=Object.prototype.hasOwnProperty,Js=typeof Element<"u";function Sr(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=zn(t),n=zn(e),i,a,l;if(r&&n){if(a=t.length,a!=e.length)return!1;for(i=a;i--!==0;)if(!Sr(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var o=t instanceof Date,c=e instanceof Date;if(o!=c)return!1;if(o&&c)return t.getTime()==e.getTime();var d=t instanceof RegExp,f=e instanceof RegExp;if(d!=f)return!1;if(d&&f)return t.toString()==e.toString();var h=Wn(t);if(a=h.length,a!==Wn(e).length)return!1;for(i=a;i--!==0;)if(!Xs.call(e,h[i]))return!1;if(Js&&t instanceof Element&&e instanceof Element)return t===e;for(i=a;i--!==0;)if(l=h[i],!(l==="_owner"&&t.$$typeof)&&!Sr(t[l],e[l]))return!1;return!0}return t!==t&&e!==e}var Qs=function(e,r){try{return Sr(e,r)}catch(n){if(n.message&&n.message.match(/stack|recursion/i)||n.number===-2146828260)return console.warn("Warning: react-fast-compare does not handle circular references.",n.name,n.message),!1;throw n}};const ge=Xr(Qs);var Zs=!0;function Qr(t,e){if(!Zs){if(t)return;var r="Warning: "+e;typeof console<"u"&&console.warn(r);try{throw Error(r)}catch{}}}var Qi={exports:{}},I={};/** @license React v16.13.1
|
|
2
2
|
* react-is.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/var z=typeof Symbol=="function"&&Symbol.for,rn=z?Symbol.for("react.element"):60103,nn=z?Symbol.for("react.portal"):60106,Ht=z?Symbol.for("react.fragment"):60107,Yt=z?Symbol.for("react.strict_mode"):60108,Kt=z?Symbol.for("react.profiler"):60114,qt=z?Symbol.for("react.provider"):60109,Gt=z?Symbol.for("react.context"):60110,an=z?Symbol.for("react.async_mode"):60111,Xt=z?Symbol.for("react.concurrent_mode"):60111,Jt=z?Symbol.for("react.forward_ref"):60112,Qt=z?Symbol.for("react.suspense"):60113,Zs=z?Symbol.for("react.suspense_list"):60120,Zt=z?Symbol.for("react.memo"):60115,er=z?Symbol.for("react.lazy"):60116,el=z?Symbol.for("react.block"):60121,tl=z?Symbol.for("react.fundamental"):60117,rl=z?Symbol.for("react.responder"):60118,nl=z?Symbol.for("react.scope"):60119;function Q(t){if(typeof t=="object"&&t!==null){var e=t.$$typeof;switch(e){case rn:switch(t=t.type,t){case an:case Xt:case Ht:case Kt:case Yt:case Qt:return t;default:switch(t=t&&t.$$typeof,t){case Gt:case Jt:case er:case Zt:case qt:return t;default:return e}}case nn:return e}}}function Zi(t){return Q(t)===Xt}I.AsyncMode=an;I.ConcurrentMode=Xt;I.ContextConsumer=Gt;I.ContextProvider=qt;I.Element=rn;I.ForwardRef=Jt;I.Fragment=Ht;I.Lazy=er;I.Memo=Zt;I.Portal=nn;I.Profiler=Kt;I.StrictMode=Yt;I.Suspense=Qt;I.isAsyncMode=function(t){return Zi(t)||Q(t)===an};I.isConcurrentMode=Zi;I.isContextConsumer=function(t){return Q(t)===Gt};I.isContextProvider=function(t){return Q(t)===qt};I.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===rn};I.isForwardRef=function(t){return Q(t)===Jt};I.isFragment=function(t){return Q(t)===Ht};I.isLazy=function(t){return Q(t)===er};I.isMemo=function(t){return Q(t)===Zt};I.isPortal=function(t){return Q(t)===nn};I.isProfiler=function(t){return Q(t)===Kt};I.isStrictMode=function(t){return Q(t)===Yt};I.isSuspense=function(t){return Q(t)===Qt};I.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===Ht||t===Xt||t===Kt||t===Yt||t===Qt||t===Zs||typeof t=="object"&&t!==null&&(t.$$typeof===er||t.$$typeof===Zt||t.$$typeof===qt||t.$$typeof===Gt||t.$$typeof===Jt||t.$$typeof===tl||t.$$typeof===rl||t.$$typeof===nl||t.$$typeof===el)};I.typeOf=Q;Qi.exports=I;var il=Qi.exports,sn=il,al={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},sl={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},ll={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},ea={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ln={};ln[sn.ForwardRef]=ll;ln[sn.Memo]=ea;function qn(t){return sn.isMemo(t)?ea:ln[t.$$typeof]||al}var ol=Object.defineProperty,cl=Object.getOwnPropertyNames,Gn=Object.getOwnPropertySymbols,dl=Object.getOwnPropertyDescriptor,ul=Object.getPrototypeOf,Xn=Object.prototype;function ta(t,e,r){if(typeof e!="string"){if(Xn){var n=ul(e);n&&n!==Xn&&ta(t,n,r)}var i=cl(e);Gn&&(i=i.concat(Gn(e)));for(var a=qn(t),l=qn(e),o=0;o<i.length;++o){var c=i[o];if(!sl[c]&&!(r&&r[c])&&!(l&&l[c])&&!(a&&a[c])){var d=dl(e,c);try{ol(t,c,d)}catch{}}}}return t}var fl=ta;const hl=Zr(fl);function P(){return P=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},P.apply(this,arguments)}function ra(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function ye(t,e){if(t==null)return{};var r={},n=Object.keys(t),i,a;for(a=0;a<n.length;a++)i=n[a],!(e.indexOf(i)>=0)&&(r[i]=t[i]);return r}function Jn(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var tr=as(void 0);tr.displayName="FormikContext";var ml=tr.Provider,gl=tr.Consumer;function bt(){var t=Wr(tr);return t||tn(!1),t}var Qn=function(e){return Array.isArray(e)&&e.length===0},W=function(e){return typeof e=="function"},Ke=function(e){return e!==null&&typeof e=="object"},pl=function(e){return String(Math.floor(Number(e)))===e},hr=function(e){return Object.prototype.toString.call(e)==="[object String]"},na=function(e){return zr.count(e)===0},mr=function(e){return Ke(e)&&W(e.then)};function V(t,e,r,n){n===void 0&&(n=0);for(var i=Xi(e);t&&n<i.length;)t=t[i[n++]];return n!==i.length&&!t||t===void 0?r:t}function ce(t,e,r){for(var n=zn(t),i=n,a=0,l=Xi(e);a<l.length-1;a++){var o=l[a],c=V(t,l.slice(0,a+1));if(c&&(Ke(c)||Array.isArray(c)))i=i[o]=zn(c);else{var d=l[a+1];i=i[o]=pl(d)&&Number(d)>=0?[]:{}}}return(a===0?t:i)[l[a]]===r?t:(r===void 0?delete i[l[a]]:i[l[a]]=r,a===0&&r===void 0&&delete n[l[a]],n)}function ia(t,e,r,n){r===void 0&&(r=new WeakMap),n===void 0&&(n={});for(var i=0,a=Object.keys(t);i<a.length;i++){var l=a[i],o=t[l];Ke(o)?r.get(o)||(r.set(o,!0),n[l]=Array.isArray(o)?[]:{},ia(o,e,r,n[l])):n[l]=e}return n}function yl(t,e){switch(e.type){case"SET_VALUES":return P({},t,{values:e.payload});case"SET_TOUCHED":return P({},t,{touched:e.payload});case"SET_ERRORS":return ge(t.errors,e.payload)?t:P({},t,{errors:e.payload});case"SET_STATUS":return P({},t,{status:e.payload});case"SET_ISSUBMITTING":return P({},t,{isSubmitting:e.payload});case"SET_ISVALIDATING":return P({},t,{isValidating:e.payload});case"SET_FIELD_VALUE":return P({},t,{values:ce(t.values,e.payload.field,e.payload.value)});case"SET_FIELD_TOUCHED":return P({},t,{touched:ce(t.touched,e.payload.field,e.payload.value)});case"SET_FIELD_ERROR":return P({},t,{errors:ce(t.errors,e.payload.field,e.payload.value)});case"RESET_FORM":return P({},t,e.payload);case"SET_FORMIK_STATE":return e.payload(t);case"SUBMIT_ATTEMPT":return P({},t,{touched:ia(t.values,!0),isSubmitting:!0,submitCount:t.submitCount+1});case"SUBMIT_FAILURE":return P({},t,{isSubmitting:!1});case"SUBMIT_SUCCESS":return P({},t,{isSubmitting:!1});default:return t}}var Fe={},Dt={};function vl(t){var e=t.validateOnChange,r=e===void 0?!0:e,n=t.validateOnBlur,i=n===void 0?!0:n,a=t.validateOnMount,l=a===void 0?!1:a,o=t.isInitialValid,c=t.enableReinitialize,d=c===void 0?!1:c,f=t.onSubmit,h=ye(t,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),u=P({validateOnChange:r,validateOnBlur:i,validateOnMount:l,onSubmit:f},h),y=X(u.initialValues),g=X(u.initialErrors||Fe),p=X(u.initialTouched||Dt),D=X(u.initialStatus),E=X(!1),F=X({});M(function(){return E.current=!0,function(){E.current=!1}},[]);var b=A(0),L=b[1],q=X({values:u.initialValues,errors:u.initialErrors||Fe,touched:u.initialTouched||Dt,status:u.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),k=q.current,S=R(function(m){var v=q.current;q.current=yl(v,m),v!==q.current&&L(function(w){return w+1})},[]),De=R(function(m,v){return new Promise(function(w,x){var N=u.validate(m,v);N==null?w(Fe):mr(N)?N.then(function(_){w(_||Fe)},function(_){x(_)}):w(N)})},[u.validate]),qe=R(function(m,v){var w=u.validationSchema,x=W(w)?w(v):w,N=v&&x.validateAt?x.validateAt(v,m):wl(m,x);return new Promise(function(_,B){N.then(function(){_(Fe)},function(de){de.name==="ValidationError"?_(bl(de)):B(de)})})},[u.validationSchema]),C=R(function(m,v){return new Promise(function(w){return w(F.current[m].validate(v))})},[]),H=R(function(m){var v=Object.keys(F.current).filter(function(x){return W(F.current[x].validate)}),w=v.length>0?v.map(function(x){return C(x,V(m,x))}):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(w).then(function(x){return x.reduce(function(N,_,B){return _==="DO_NOT_DELETE_YOU_WILL_BE_FIRED"||_&&(N=ce(N,v[B],_)),N},{})})},[C]),Ge=R(function(m){return Promise.all([H(m),u.validationSchema?qe(m):{},u.validate?De(m):{}]).then(function(v){var w=v[0],x=v[1],N=v[2],_=Nr.all([w,x,N],{arrayMerge:xl});return _})},[u.validate,u.validationSchema,H,De,qe]),Y=Z(function(m){return m===void 0&&(m=k.values),S({type:"SET_ISVALIDATING",payload:!0}),Ge(m).then(function(v){return E.current&&(S({type:"SET_ISVALIDATING",payload:!1}),S({type:"SET_ERRORS",payload:v})),v})});M(function(){l&&E.current===!0&&ge(y.current,u.initialValues)&&Y(y.current)},[l,Y]);var Xe=R(function(m){var v=m&&m.values?m.values:y.current,w=m&&m.errors?m.errors:g.current?g.current:u.initialErrors||{},x=m&&m.touched?m.touched:p.current?p.current:u.initialTouched||{},N=m&&m.status?m.status:D.current?D.current:u.initialStatus;y.current=v,g.current=w,p.current=x,D.current=N;var _=function(){S({type:"RESET_FORM",payload:{isSubmitting:!!m&&!!m.isSubmitting,errors:w,touched:x,status:N,values:v,isValidating:!!m&&!!m.isValidating,submitCount:m&&m.submitCount&&typeof m.submitCount=="number"?m.submitCount:0}})};if(u.onReset){var B=u.onReset(k.values,_n);mr(B)?B.then(_):_()}else _()},[u.initialErrors,u.initialStatus,u.initialTouched,u.onReset]);M(function(){E.current===!0&&!ge(y.current,u.initialValues)&&d&&(y.current=u.initialValues,Xe(),l&&Y(y.current))},[d,u.initialValues,Xe,l,Y]),M(function(){d&&E.current===!0&&!ge(g.current,u.initialErrors)&&(g.current=u.initialErrors||Fe,S({type:"SET_ERRORS",payload:u.initialErrors||Fe}))},[d,u.initialErrors]),M(function(){d&&E.current===!0&&!ge(p.current,u.initialTouched)&&(p.current=u.initialTouched||Dt,S({type:"SET_TOUCHED",payload:u.initialTouched||Dt}))},[d,u.initialTouched]),M(function(){d&&E.current===!0&&!ge(D.current,u.initialStatus)&&(D.current=u.initialStatus,S({type:"SET_STATUS",payload:u.initialStatus}))},[d,u.initialStatus,u.initialTouched]);var Dn=Z(function(m){if(F.current[m]&&W(F.current[m].validate)){var v=V(k.values,m),w=F.current[m].validate(v);return mr(w)?(S({type:"SET_ISVALIDATING",payload:!0}),w.then(function(x){return x}).then(function(x){S({type:"SET_FIELD_ERROR",payload:{field:m,value:x}}),S({type:"SET_ISVALIDATING",payload:!1})})):(S({type:"SET_FIELD_ERROR",payload:{field:m,value:w}}),Promise.resolve(w))}else if(u.validationSchema)return S({type:"SET_ISVALIDATING",payload:!0}),qe(k.values,m).then(function(x){return x}).then(function(x){S({type:"SET_FIELD_ERROR",payload:{field:m,value:V(x,m)}}),S({type:"SET_ISVALIDATING",payload:!1})});return Promise.resolve()}),Ba=R(function(m,v){var w=v.validate;F.current[m]={validate:w}},[]),za=R(function(m){delete F.current[m]},[]),Fn=Z(function(m,v){S({type:"SET_TOUCHED",payload:m});var w=v===void 0?i:v;return w?Y(k.values):Promise.resolve()}),Nn=R(function(m){S({type:"SET_ERRORS",payload:m})},[]),Sn=Z(function(m,v){var w=W(m)?m(k.values):m;S({type:"SET_VALUES",payload:w});var x=v===void 0?r:v;return x?Y(w):Promise.resolve()}),wt=R(function(m,v){S({type:"SET_FIELD_ERROR",payload:{field:m,value:v}})},[]),$e=Z(function(m,v,w){S({type:"SET_FIELD_VALUE",payload:{field:m,value:v}});var x=w===void 0?r:w;return x?Y(ce(k.values,m,v)):Promise.resolve()}),Cn=R(function(m,v){var w=v,x=m,N;if(!hr(m)){m.persist&&m.persist();var _=m.target?m.target:m.currentTarget,B=_.type,de=_.name,or=_.id,cr=_.value,Qa=_.checked,Zc=_.outerHTML,Pn=_.options,Za=_.multiple;w=v||de||or,x=/number|range/.test(B)?(N=parseFloat(cr),isNaN(N)?"":N):/checkbox/.test(B)?El(V(k.values,w),Qa,cr):Pn&&Za?kl(Pn):cr}w&&$e(w,x)},[$e,k.values]),ir=Z(function(m){if(hr(m))return function(v){return Cn(v,m)};Cn(m)}),Le=Z(function(m,v,w){v===void 0&&(v=!0),S({type:"SET_FIELD_TOUCHED",payload:{field:m,value:v}});var x=w===void 0?i:w;return x?Y(k.values):Promise.resolve()}),An=R(function(m,v){m.persist&&m.persist();var w=m.target,x=w.name,N=w.id,_=w.outerHTML,B=v||x||N;Le(B,!0)},[Le]),ar=Z(function(m){if(hr(m))return function(v){return An(v,m)};An(m)}),Tn=R(function(m){W(m)?S({type:"SET_FORMIK_STATE",payload:m}):S({type:"SET_FORMIK_STATE",payload:function(){return m}})},[]),Mn=R(function(m){S({type:"SET_STATUS",payload:m})},[]),On=R(function(m){S({type:"SET_ISSUBMITTING",payload:m})},[]),sr=Z(function(){return S({type:"SUBMIT_ATTEMPT"}),Y().then(function(m){var v=m instanceof Error,w=!v&&Object.keys(m).length===0;if(w){var x;try{if(x=Ha(),x===void 0)return}catch(N){throw N}return Promise.resolve(x).then(function(N){return E.current&&S({type:"SUBMIT_SUCCESS"}),N}).catch(function(N){if(E.current)throw S({type:"SUBMIT_FAILURE"}),N})}else if(E.current&&(S({type:"SUBMIT_FAILURE"}),v))throw m})}),Wa=Z(function(m){m&&m.preventDefault&&W(m.preventDefault)&&m.preventDefault(),m&&m.stopPropagation&&W(m.stopPropagation)&&m.stopPropagation(),sr().catch(function(v){console.warn("Warning: An unhandled error was caught from submitForm()",v)})}),_n={resetForm:Xe,validateForm:Y,validateField:Dn,setErrors:Nn,setFieldError:wt,setFieldTouched:Le,setFieldValue:$e,setStatus:Mn,setSubmitting:On,setTouched:Fn,setValues:Sn,setFormikState:Tn,submitForm:sr},Ha=Z(function(){return f(k.values,_n)}),Ya=Z(function(m){m&&m.preventDefault&&W(m.preventDefault)&&m.preventDefault(),m&&m.stopPropagation&&W(m.stopPropagation)&&m.stopPropagation(),Xe()}),Ka=R(function(m){return{value:V(k.values,m),error:V(k.errors,m),touched:!!V(k.touched,m),initialValue:V(y.current,m),initialTouched:!!V(p.current,m),initialError:V(g.current,m)}},[k.errors,k.touched,k.values]),qa=R(function(m){return{setValue:function(w,x){return $e(m,w,x)},setTouched:function(w,x){return Le(m,w,x)},setError:function(w){return wt(m,w)}}},[$e,Le,wt]),Ga=R(function(m){var v=Ke(m),w=v?m.name:m,x=V(k.values,w),N={name:w,value:x,onChange:ir,onBlur:ar};if(v){var _=m.type,B=m.value,de=m.as,or=m.multiple;_==="checkbox"?B===void 0?N.checked=!!x:(N.checked=!!(Array.isArray(x)&&~x.indexOf(B)),N.value=B):_==="radio"?(N.checked=x===B,N.value=B):de==="select"&&or&&(N.value=N.value||[],N.multiple=!0)}return N},[ar,ir,k.values]),lr=ut(function(){return!ge(y.current,k.values)},[y.current,k.values]),Xa=ut(function(){return typeof o<"u"?lr?k.errors&&Object.keys(k.errors).length===0:o!==!1&&W(o)?o(u):o:k.errors&&Object.keys(k.errors).length===0},[o,lr,k.errors,u]),Ja=P({},k,{initialValues:y.current,initialErrors:g.current,initialTouched:p.current,initialStatus:D.current,handleBlur:ar,handleChange:ir,handleReset:Ya,handleSubmit:Wa,resetForm:Xe,setErrors:Nn,setFormikState:Tn,setFieldTouched:Le,setFieldValue:$e,setFieldError:wt,setStatus:Mn,setSubmitting:On,setTouched:Fn,setValues:Sn,submitForm:sr,validateForm:Y,validateField:Dn,isValid:Xa,dirty:lr,unregisterField:za,registerField:Ba,getFieldProps:Ga,getFieldMeta:Ka,getFieldHelpers:qa,validateOnBlur:i,validateOnChange:r,validateOnMount:l});return Ja}function aa(t){var e=vl(t),r=t.component,n=t.children,i=t.render,a=t.innerRef;return ns(a,function(){return e}),se(ml,{value:e},r?se(r,e):i?i(e):n?W(n)?n(e):na(n)?null:zr.only(n):null)}function bl(t){var e={};if(t.inner){if(t.inner.length===0)return ce(e,t.path,t.message);for(var i=t.inner,r=Array.isArray(i),n=0,i=r?i:i[Symbol.iterator]();;){var a;if(r){if(n>=i.length)break;a=i[n++]}else{if(n=i.next(),n.done)break;a=n.value}var l=a;V(e,l.path)||(e=ce(e,l.path,l.message))}}return e}function wl(t,e,r,n){r===void 0&&(r=!1);var i=Cr(t);return e[r?"validateSync":"validate"](i,{abortEarly:!1,context:n||i})}function Cr(t){var e=Array.isArray(t)?[]:{};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var n=String(r);Array.isArray(t[n])===!0?e[n]=t[n].map(function(i){return Array.isArray(i)===!0||Bn(i)?Cr(i):i!==""?i:void 0}):Bn(t[n])?e[n]=Cr(t[n]):e[n]=t[n]!==""?t[n]:void 0}return e}function xl(t,e,r){var n=t.slice();return e.forEach(function(a,l){if(typeof n[l]>"u"){var o=r.clone!==!1,c=o&&r.isMergeableObject(a);n[l]=c?Nr(Array.isArray(a)?[]:{},a,r):a}else r.isMergeableObject(a)?n[l]=Nr(t[l],a,r):t.indexOf(a)===-1&&n.push(a)}),n}function kl(t){return Array.from(t).filter(function(e){return e.selected}).map(function(e){return e.value})}function El(t,e,r){if(typeof t=="boolean")return!!e;var n=[],i=!1,a=-1;if(Array.isArray(t))n=t,a=t.indexOf(r),i=a>=0;else if(!r||r=="true"||r=="false")return!!e;return e&&r&&!i?n.concat(r):i?n.slice(0,a).concat(n.slice(a+1)):n}var Dl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?ss:M;function Z(t){var e=X(t);return Dl(function(){e.current=t}),R(function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return e.current.apply(void 0,n)},[])}function on(t){var e=bt(),r=e.getFieldProps,n=e.getFieldMeta,i=e.getFieldHelpers,a=e.registerField,l=e.unregisterField,o=Ke(t),c=o?t:{name:t},d=c.name,f=c.validate;M(function(){return d&&a(d,{validate:f}),function(){d&&l(d)}},[a,l,d,f]),d||tn(!1);var h=ut(function(){return i(d)},[i,d]);return[r(c),n(d),h]}function oe(t){var e=t.validate,r=t.name,n=t.render,i=t.children,a=t.as,l=t.component,o=t.className,c=ye(t,["validate","name","render","children","as","component","className"]),d=bt(),f=ye(d,["validate","validationSchema"]),h=f.registerField,u=f.unregisterField;M(function(){return h(r,{validate:e}),function(){u(r)}},[h,u,r,e]);var y=f.getFieldProps(P({name:r},c)),g=f.getFieldMeta(r),p={field:y,form:f};if(n)return n(P({},p,{meta:g}));if(W(i))return i(P({},p,{meta:g}));if(l){if(typeof l=="string"){var D=c.innerRef,E=ye(c,["innerRef"]);return se(l,P({ref:D},y,E,{className:o}),i)}return se(l,P({field:y,form:f},c,{className:o}),i)}var F=a||"input";if(typeof F=="string"){var b=c.innerRef,L=ye(c,["innerRef"]);return se(F,P({ref:b},y,L,{className:o}),i)}return se(F,P({},y,c,{className:o}),i)}var cn=is(function(t,e){var r=t.action,n=ye(t,["action"]),i=r??"#",a=bt(),l=a.handleReset,o=a.handleSubmit;return se("form",P({onSubmit:o,ref:e,onReset:l,action:i},n))});cn.displayName="Form";function Fl(t){var e=function(i){return se(gl,null,function(a){return a||tn(!1),se(t,P({},i,{formik:a}))})},r=t.displayName||t.name||t.constructor&&t.constructor.name||"Component";return e.WrappedComponent=t,e.displayName="FormikConnect("+r+")",hl(e,t)}var Nl=function(e,r,n){var i=Oe(e),a=i[r];return i.splice(r,1),i.splice(n,0,a),i},Sl=function(e,r,n){var i=Oe(e),a=i[r];return i[r]=i[n],i[n]=a,i},gr=function(e,r,n){var i=Oe(e);return i.splice(r,0,n),i},Cl=function(e,r,n){var i=Oe(e);return i[r]=n,i},Oe=function(e){if(e){if(Array.isArray(e))return[].concat(e);var r=Object.keys(e).map(function(n){return parseInt(n)}).reduce(function(n,i){return i>n?i:n},0);return Array.from(P({},e,{length:r+1}))}else return[]},Zn=function(e,r){var n=typeof e=="function"?e:r;return function(i){if(Array.isArray(i)||Ke(i)){var a=Oe(i);return n(a)}return i}},Al=function(t){ra(e,t);function e(n){var i;return i=t.call(this,n)||this,i.updateArrayField=function(a,l,o){var c=i.props,d=c.name,f=c.formik.setFormikState;f(function(h){var u=Zn(o,a),y=Zn(l,a),g=ce(h.values,d,a(V(h.values,d))),p=o?u(V(h.errors,d)):void 0,D=l?y(V(h.touched,d)):void 0;return Qn(p)&&(p=void 0),Qn(D)&&(D=void 0),P({},h,{values:g,errors:o?ce(h.errors,d,p):h.errors,touched:l?ce(h.touched,d,D):h.touched})})},i.push=function(a){return i.updateArrayField(function(l){return[].concat(Oe(l),[Ls(a)])},!1,!1)},i.handlePush=function(a){return function(){return i.push(a)}},i.swap=function(a,l){return i.updateArrayField(function(o){return Sl(o,a,l)},!0,!0)},i.handleSwap=function(a,l){return function(){return i.swap(a,l)}},i.move=function(a,l){return i.updateArrayField(function(o){return Nl(o,a,l)},!0,!0)},i.handleMove=function(a,l){return function(){return i.move(a,l)}},i.insert=function(a,l){return i.updateArrayField(function(o){return gr(o,a,l)},function(o){return gr(o,a,null)},function(o){return gr(o,a,null)})},i.handleInsert=function(a,l){return function(){return i.insert(a,l)}},i.replace=function(a,l){return i.updateArrayField(function(o){return Cl(o,a,l)},!1,!1)},i.handleReplace=function(a,l){return function(){return i.replace(a,l)}},i.unshift=function(a){var l=-1;return i.updateArrayField(function(o){var c=o?[a].concat(o):[a];return l=c.length,c},function(o){return o?[null].concat(o):[null]},function(o){return o?[null].concat(o):[null]}),l},i.handleUnshift=function(a){return function(){return i.unshift(a)}},i.handleRemove=function(a){return function(){return i.remove(a)}},i.handlePop=function(){return function(){return i.pop()}},i.remove=i.remove.bind(Jn(i)),i.pop=i.pop.bind(Jn(i)),i}var r=e.prototype;return r.componentDidUpdate=function(i){this.props.validateOnChange&&this.props.formik.validateOnChange&&!ge(V(i.formik.values,i.name),V(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},r.remove=function(i){var a;return this.updateArrayField(function(l){var o=l?Oe(l):[];return a||(a=o[i]),W(o.splice)&&o.splice(i,1),W(o.every)&&o.every(function(c){return c===void 0})?[]:o},!0,!0),a},r.pop=function(){var i;return this.updateArrayField(function(a){var l=a.slice();return i||(i=l&&l.pop&&l.pop()),l},!0,!0),i},r.render=function(){var i={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},a=this.props,l=a.component,o=a.render,c=a.children,d=a.name,f=a.formik,h=ye(f,["validate","validationSchema"]),u=P({},i,{form:h,name:d});return l?se(l,u):o?o(u):c?typeof c=="function"?c(u):na(c)?null:zr.only(c):null},e}($i);Al.defaultProps={validateOnChange:!0};var Tl=function(t){ra(e,t);function e(){return t.apply(this,arguments)||this}var r=e.prototype;return r.shouldComponentUpdate=function(i){return V(this.props.formik.errors,this.props.name)!==V(i.formik.errors,this.props.name)||V(this.props.formik.touched,this.props.name)!==V(i.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(i).length},r.render=function(){var i=this.props,a=i.component,l=i.formik,o=i.render,c=i.children,d=i.name,f=ye(i,["component","formik","render","children","name"]),h=V(l.touched,d),u=V(l.errors,d);return h&&u?o?W(o)?o(u):null:c?W(c)?c(u):null:a?se(a,f,u):u:null},e}($i),Ml=Fl(Tl);class Ol{async getEditorProfiles(){return await at.instance.url("users/editors").get().json()}async assignRole(e,r){const n={command:{assignRole:r}};return at.instance.url(`users/${e}`).post(n).badRequest(()=>{throw new Error("Failed to execute user command")}).res()}}const Ar=new Ol;var ei,ti;function _l(){return{editorProfiles:[]}}let Pl=(ei=Hr({name:"access-manager",resettable:!0,producerFn:Yr}),ei(ti=class extends ls{constructor(){super(_l())}})||ti);const sa=new Pl;class Il{async getBasicProfileByEmail(e){const r=await Ss.getBasicProfileByEmail(e);return os(r,cs(n=>n))}async getEditorProfiles(){const e=(await Ar.getEditorProfiles()).map(Cs.toDomain);sa.update(r=>{r.editorProfiles=e})}async addEditorByEmail(e){const r=await this.getBasicProfileByEmail(e);return xe(r)&&(await Ar.assignRole(r.value.profileId,"accountEditor"),await this.getEditorProfiles()),r}}const Tr=new Il;class $l extends ds{constructor(r){super(r);O(this,"editorProfiles$",this.select(r=>r.editorProfiles));this.store=r}}const Ll=new $l(sa),Vl=({open:t,onRemoveConfirmed:e,onClose:r})=>s(Gr,{isOpen:t,onClose:r,children:s("div",{className:"px-4 pt-5 pb-4 sm:max-w-lg sm:w-full sm:p-6",children:[s("div",{className:"sm:flex sm:items-start ",children:[s("div",{className:"mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10",children:s(Li,{className:"h-6 w-6 text-red-600","aria-hidden":"true"})}),s("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[s(Mt.Title,{as:"h3",className:"text-lg leading-6 font-medium text-gray-900",children:"Remove Editor"}),s("div",{className:"mt-2",children:[s("p",{className:"text-sm text-gray-500 leading-5 font-semibold",children:"Are you sure you want to remove this person?"}),s("p",{className:"text-sm text-gray-500 leading-5 font-normal",children:"If you proceed, this person will not be able to edit or manage benefits anymore."})]})]})]}),s("div",{className:"mt-5 sm:mt-4 sm:flex sm:flex-row-reverse",children:[s("button",{type:"button",className:"w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm",onClick:e,children:"Remove"}),s("button",{type:"button",className:"mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:w-auto sm:text-sm",onClick:r,children:"Cancel"})]})]})}),Rl=({editorProfile:t,index:e,isLoading:r,isRemoveDisabled:n,onRemoveClicked:i})=>{const{basicProfile:a,benefitsProfile:l}=t,o=c=>{switch(c){case"accountAdmin":return"Admin";case"accountEditor":return"Editor";case"user":return"User";default:return"Unknown"}};return s("tr",{children:[s("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dd-privacy-mask",children:[a.firstName," ",a.lastName]}),s("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dd-privacy-mask",children:a.email}),s("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:o(l.role)}),s("td",{className:"flex justify-end px-6 py-4",children:s("div",{className:"grid justify-items-center w-16",children:r?s(yt,{}):s("button",{type:"button",className:"text-primary text-sm font-medium disabled:text-gray-400 disabled:cursor-not-allowed",disabled:n,onClick:i,children:"Remove"})})})]},e)},jl=({editorProfiles:t})=>{const[e,r]=A(!1),[n,i]=A(!1),[a,l]=A(j),{service:o}=Xr(),c=f=>{l(ke(f)),r(!0)},d=async()=>{r(!1),i(!0);const f=vt(a),h="user";await Ee(Ar.assignRole(f.basicProfile.profileId,h),300),await Tr.getEditorProfiles(),i(!1),await o.trackRoleAssignedAsync({role:h,targetProfileId:f.basicProfile.profileId})};return s("div",{className:"flex flex-col",children:[s("div",{className:"-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8",children:s("div",{className:"py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8",children:s("div",{className:"shadow overflow-hidden border border-gray-200 sm:rounded-lg",children:s("table",{className:"min-w-full divide-y divide-gray-200",children:[s("thead",{className:"bg-gray-50",children:s("tr",{children:[s("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Name"}),s("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Email"}),s("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Role"}),s("th",{scope:"col",className:"relative px-6 py-3",children:s("span",{className:"sr-only",children:"Edit"})})]})}),s("tbody",{className:"bg-white divide-y divide-gray-200",children:t.length>0?t.map((f,h)=>s(Rl,{editorProfile:f,index:h,isLoading:n&&f===Jr(a),isRemoveDisabled:n,onRemoveClicked:()=>c(f)})):s("tr",{children:s("td",{colSpan:4,className:"px-6 py-4 whitespace-nowrap text-base font-medium text-gray-400 text-center",children:"The list is currently empty"})})})]})})})}),s(Vl,{open:e,onRemoveConfirmed:d,onClose:()=>r(!1)})]})},Ul=()=>{const[t,e]=A([]),{service:r}=Xr();M(()=>{(async()=>await Tr.getEditorProfiles())();const i=[Ll.editorProfiles$.subscribe(e)];return()=>{i.map(a=>a.unsubscribe())}},[]);const n=/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i;return s(U,{children:[s("div",{className:"pt-4 pb-3 border-b border-gray-200",children:s("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Editors"})}),s("div",{className:"pt-3",children:s(aa,{initialValues:{email:""},onSubmit:async({email:i},{setErrors:a,setFieldValue:l})=>{if(!n.test(i)){a({email:"Invalid email address"});return}const o=await Ee(Tr.addEditorByEmail(i),300);Kr(o)?a({email:"User not found"}):(l("email",""),await r.trackRoleAssignedAsync({role:"accountEditor",targetProfileId:o.value.profileId}))},children:({isSubmitting:i,setErrors:a})=>s(cn,{children:[s("label",{className:"block text-sm leading-5 font-medium text-gray-700",children:"Add new editor"}),s("div",{className:"flex items-center relative mt-1",children:[s("div",{className:"flex relative",children:[s(oe,{name:"email",className:"shadow-sm block text-sm border-gray-300 rounded-md pr-10",type:"text",placeholder:"Enter email address",onBlur:()=>null,onFocus:()=>a({})}),s("div",{className:$(i?"":"hidden","absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none"),children:s(yt,{})})]}),s("button",{type:"submit",className:"ml-6 bg-primary text-white font-bold py-2 px-4 rounded disabled:opacity-50 disabled:cursor-not-allowed",disabled:i,children:s("div",{className:"flex items-center justify-center",children:[s("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:s("path",{d:"M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"})}),s("span",{className:"pl-2",children:"Add"})]})}),s("div",{className:"ml-4 text-red-500",children:s(Ml,{name:"email"})})]})]})})}),s("div",{className:"pt-6",children:s(jl,{editorProfiles:t})})]})},Bl=t=>{const{user:{basicProfile:e}}=t;return s(U,{children:[s("div",{className:"pb-3 border-b border-gray-200",children:s("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Owner"})}),s("div",{className:"rounded-lg bg-white overflow-hidden border border-gray-200 mt-3",children:s("div",{className:"bg-white py-2 px-6",children:s("div",{className:"sm:flex sm:items-center sm:justify-between",children:s("div",{className:"sm:flex sm:items-center sm:space-x-5",children:[s("div",{className:"flex-shrink-0",children:t.imgUrl?s("img",{className:"mx-auto h-20 w-20 rounded-full",src:t.imgUrl,alt:""}):s("div",{className:"sm:flex sm:items-center text-center",children:s("span",{className:"inline-block h-20 w-20 rounded-full overflow-hidden bg-gray-100",children:s("svg",{className:"h-full w-full text-gray-300",fill:"currentColor",viewBox:"0 0 24 24",children:s("path",{d:"M24 20.993V24H0v-2.996A14.977 14.977 0 0112.004 15c4.904 0 9.26 2.354 11.996 5.993zM16.002 8.999a4 4 0 11-8 0 4 4 0 018 0z"})})})})}),s("div",{className:"mt-2 text-center sm:mt-0 sm:text-left",children:[s("p",{className:"text-lg leading-6 font-medium text-gray-900 dd-privacy-mask",children:`${e.firstName} ${e.lastName}`}),s("p",{className:"text-sm leading-5 font-normal text-gray-500 dd-privacy-mask",children:e.email})]})]})})})})]})},zl=()=>{const t=vt(qr.useContext(Qr));return s("div",{className:"max-w-5xl",children:[s(Wt,{title:" Access Manager",subTitle:"Specify which staff has permissions to edit and manage benefits.",isLoading:!1}),s("div",{className:"mt-4",children:s(Bl,{user:t})}),s("div",{className:"mt-4",children:s(Ul,{})})]})};var ve=(t=>(t[t.Information=0]="Information",t[t.Error=1]="Error",t[t.Success=2]="Success",t))(ve||{});const Wl={actionMessages:[],setActionMessages:()=>({})},rr=qr.createContext(Wl),dn=()=>{const t=Wr(rr),[e,r]=A([]);return M(()=>{r(t.actionMessages)},[t.actionMessages]),[e,a=>t.setActionMessages([a,...t.actionMessages]),a=>{if(a>=0&&a<t.actionMessages.length){const l=t.actionMessages.filter((o,c)=>c!==a);t.setActionMessages(l)}}]},un=t=>{const[e,r,n]=dn(),i=e.map((a,l)=>{let o="",c=s(In,{});switch(a.level){case 0:{o="bg-secondary text-primary",c=s(In,{className:"text-blue-400"});break}case 2:{o="bg-green-50 text-green-800",c=s(fs,{className:"text-green-400"});break}case 1:{o="bg-red-50 text-red-800",c=s(us,{className:"text-red-400"});break}}return s(Ve.li,{className:`p-4 rounded-md relative ${o}`,layoutId:l.toString(),layout:"position",children:[s("div",{className:"absolute left-0 top-0 bottom-0 my-auto w-4 h-4 ml-4",children:c}),s("p",{className:"text-sm leading-5 font-medium mx-8 w-100",children:a.message}),s("button",{className:"absolute right-0 top-0 bottom-0 my-auto w-4 h-4 mr-4",onClick:()=>n(l),children:s(hs,{})})]},l)});return s("ul",{className:`space-y-4 ${t.className}`,children:i})},fn=t=>{const[e,r]=A(0),{tabs:n}=t;M(()=>r(n.findIndex(a=>a.filterKey===t.filterKey)),[t.filterKey,n]),M(()=>t.onFilterChanged(n[e].filterKey),[e]);const i=a=>{r(n.findIndex(l=>l.filterKey===a.currentTarget.value))};return s("div",{children:[s("div",{className:"sm:hidden",children:[s("label",{htmlFor:"tabs",className:"sr-only",children:"Select a tab"}),s("select",{id:"tabs",name:"tabs",className:"block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm rounded-md",value:n[e].filterKey,onChange:i,children:n.map(a=>s("option",{value:a.filterKey,children:a.name}))})]}),s("div",{className:"hidden sm:block",children:s("div",{className:"border-b border-gray-200",children:s("nav",{className:"-mb-px flex space-x-8","aria-label":"Tabs",children:n.map((a,l)=>s(U,{children:[s("div",{className:$(l===e?"border-primary text-primary":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-200","whitespace-nowrap flex py-4 px-1 border-b-2 font-medium text-sm cursor-pointer"),"aria-current":l===e?"page":void 0,onClick:()=>r(l),children:[a.name,a.getCount()!==void 0&&s("span",{className:$(l===e?"bg-secondary text-primary":"bg-gray-100 text-gray-900","hidden ml-3 py-0.5 px-2.5 rounded-full text-xs font-medium md:inline-block"),children:`${a.getCount()}`})]},a.name),a.showDivider&&s("div",{className:"my-4 border-l-2 border-grey-900"})]}))})})})]})},hn=()=>{const t=()=>s("div",{class:"border border-gray-100 shadow rounded-md px-4 py-2 sm:px-6 w-full mx-auto",children:s("div",{class:"animate-pulse flex items-center justify-start",children:[s("div",{className:"flex items-center justify-start text-gray-300",children:s(Vi,{className:"mr-1.5 h-6 w-6","aria-hidden":"true"})}),s("div",{class:"rounded-full bg-gray-300 h-12 w-12 mx-6"}),s("div",{class:"flex-1 space-y-2 py-1",children:[s("div",{class:"h-4 bg-gray-300 rounded w-3/4"}),s("div",{class:"space-y-2",children:[s("div",{class:"h-3 bg-gray-300 rounded"}),s("div",{class:"h-3 bg-gray-300 rounded w-5/6"})]})]})]})});return s("div",{className:"space-y-3",children:[...Array(5).keys()].map(t)})};class Hl{save(e,r){const n={visibility:r};return st.instance.url(`collections/${e??""}/visibility`).post(n).badRequest(()=>{throw new Error("Failed to execute event save")}).res()}enableCollection(e){return this.save(e,"visible")}disableCollection(e){return this.save(e,"hidden")}getHiddenCollectionsAsync(){return st.instance.url("collections").get().json()}}const Mr=new Hl,Yl=(t,e)=>{const r=[];return t.forEach(n=>{const i={...n,state:e.hiddenCollections.includes(n.id)?"hidden":"visible"};r.push(i)}),r},Kl=(t,e)=>{const r=t.findIndex(n=>n.id===e.id);return[...t.slice(0,r),e,...t.slice(r+1)]},ql=async()=>{const t=await Ee(As.loadCollectionsAsync(),700),e=await Ee(Mr.getHiddenCollectionsAsync(),700);return Yl(t,e)},pr=t=>t==="visible",Gl=t=>s("ul",{className:"divide-y divide-gray-200",children:t.collectionList.map(e=>s("li",{className:"relative bg-white py-3 focus-within:bg-yellow-100 hover:bg-gray-50 cursor-pointer",onClick:()=>{t.onCollectionClicked(e)},children:s("div",{className:"px-1 py-1 sm:px-6 flex flex-row justify-between space-x-3 ",children:[s("div",{className:"min-w-0 flex-1",children:s("a",{href:"#/admin/collections",className:"focus:outline-none",children:[s("span",{className:"absolute inset-0","aria-hidden":"true"}),s("p",{className:"truncate text-lg leading-6 font-semibold text-gray-900 ",children:e.title}),s("p",{className:"mt-1 text-sm leading-5 font-normal text-gray-500 line-clamp-2",children:e.description}),s("div",{className:"mt-1 flex-shrink-0 flex",children:s(zt,{name:e.pillar,size:"xs"})})]})}),s("div",{className:"flex self-center",children:s(nt,{checked:pr(e.state),onChange:()=>{t.onToggleClicked(e)},className:$(pr(e.state)?"bg-primary":"bg-gray-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"),children:[s("span",{className:"sr-only",children:"Toggle collection visibility"}),s("span",{"aria-hidden":"true",className:$(pr(e.state)?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200")})]})})]})},e.id))}),Xl=t=>{const e=t.articles.map(r=>s("li",{className:"space-y-2",children:[s("img",{src:r.coverPhotoUrl,className:"object-cover w-full h-36"}),s("h4",{className:"text-base leading-6 font-medium",children:r.title}),s("p",{className:"text-sm leading-5 font-normal",children:Ki(r.primaryContentType)})]},r.title));return s("div",{className:"space-y-3",children:[s("h2",{className:"text-2xl leading-8 font-bold",children:t.title}),s(zt,{name:t.pillar}),s("img",{src:t.coverPhotoUrl,className:"object-cover w-full h-52 rounded-md"}),s("p",{className:"text-sm leading-4 font-normal",children:t.description}),s("ul",{className:"grid grid-cols-1 gap-y-4 sm:grid-cols-2 sm:gap-x-6 sm:gap-y-10 lg:gap-x-8 xl:grid-cols-3 pt-6",children:e})]})},Je=(t,e)=>t.filter(r=>r.pillar===e).length,Jl=()=>{const[t,e]=A(!0),[r,n]=A([]),[i,a]=A([]),[l,o]=A(),[c,d]=A("money"),[f,h]=A([]);M(()=>{n([{message:"Articles within a collection can not be individually turned off.",level:ve.Information}])},[]),M(()=>{(async()=>{const D=await ql();a(D),e(!1)})()},[t]),M(()=>{h(i.filter(p=>p.pillar===c))},[i,c]);const u=[{name:"Money",filterKey:"money",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"money")},{name:"Mind",filterKey:"mind",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"mind")},{name:"Body",filterKey:"body",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"body")},{name:"Work",filterKey:"work",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"work")},{name:"Life",filterKey:"life",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"life")}],y=p=>{o(p.id)},g=async p=>{const D={...p,state:p.state==="visible"?"hidden":"visible"};a(Kl(i,D));try{p.state==="visible"?await Mr.disableCollection(p.id):await Mr.enableCollection(p.id)}catch{e(!0)}};return s(rr.Provider,{value:{actionMessages:r,setActionMessages:n},children:[s(Wt,{title:"Collections",subTitle:"Choose which content collections to provide your workforce and enhance their well being offering",isLoading:t}),s("div",{className:"pt-4",children:s(fn,{tabs:u,filterKey:c,onFilterChanged:p=>{d(p)}})}),s(en,{children:[t&&s(hn,{}),!t&&s("div",{className:"mt-4 grid grid-cols-12 min-h-[80vh]",children:[s("div",{className:"md:col-span-4 col-span-12 border-l border-t border-b border-gray-200",children:[s(un,{}),s(Gl,{collectionList:f,onCollectionClicked:y,onToggleClicked:g})]}),s("div",{className:"border border-gray-200 p-4 col-span-8 hidden md:block rounded-r-lg",children:f&&f.length>0&&s(Xl,{...f.find(p=>p.id===l)??f[0]})})]})]})]})},ri={eventName:"CalendarEventModal"},ni={eventName:"CalendarEvents"},Ne={eventName:"CalendarEvent"},Ql={eventName:"CalendarEventTemplates"},la={eventName:"CalendarEventTemplate"};var ii,ai,si,Qe;function Zl(t,e,r,n,i){var a={};return Object.keys(n).forEach(function(l){a[l]=n[l]}),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce(function(l,o){return o(t,e,l)||l},a),i&&a.initializer!==void 0&&(a.value=a.initializer?a.initializer.call(i):void 0,a.initializer=void 0),a.initializer===void 0?(Object.defineProperty(t,e,a),null):a}function eo(){return{filter:"Upcoming",editableItemType:"customEvent",featuredItems:[],selectedItem:j,editDialog:{screen:"hidden"}}}let to=(ii=Hr({name:"events-manager",cache:{ttl:"3600000"},resettable:!0,producerFn:Yr}),ai=Ri(),ii(si=(Qe=class extends ji{constructor(){super(eo())}removeFromFeatured(e){this.update(e,r=>{r.visibility.isFeatured=!1}),this.update(r=>{r.featuredItems.splice(r.featuredItems.indexOf(e),1)})}},Zl(Qe.prototype,"removeFromFeatured",[ai],Object.getOwnPropertyDescriptor(Qe.prototype,"removeFromFeatured"),Qe.prototype),Qe))||si);const ne=new to,ot=ne;var Or;try{Or=Map}catch{}var _r;try{_r=Set}catch{}function oa(t,e,r){if(!t||typeof t!="object"||typeof t=="function")return t;if(t.nodeType&&"cloneNode"in t)return t.cloneNode(!0);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t);if(Array.isArray(t))return t.map(Pr);if(Or&&t instanceof Or)return new Map(Array.from(t.entries()));if(_r&&t instanceof _r)return new Set(Array.from(t.values()));if(t instanceof Object){e.push(t);var n=Object.create(t);r.push(n);for(var i in t){var a=e.findIndex(function(l){return l===t[i]});n[i]=a>-1?r[a]:oa(t[i],e,r)}return n}return t}function Pr(t){return oa(t,[],[])}const ro=Object.prototype.toString,no=Error.prototype.toString,io=RegExp.prototype.toString,ao=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",so=/^Symbol\((.*)\)(.*)$/;function lo(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function li(t,e=!1){if(t==null||t===!0||t===!1)return""+t;const r=typeof t;if(r==="number")return lo(t);if(r==="string")return e?`"${t}"`:t;if(r==="function")return"[Function "+(t.name||"anonymous")+"]";if(r==="symbol")return ao.call(t).replace(so,"Symbol($1)");const n=ro.call(t).slice(8,-1);return n==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):n==="Error"||t instanceof Error?"["+no.call(t)+"]":n==="RegExp"?io.call(t):null}function ht(t,e){let r=li(t,e);return r!==null?r:JSON.stringify(t,function(n,i){let a=li(this[n],e);return a!==null?a:i},2)}let Se={default:"${path} is invalid",required:"${path} is a required field",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:r,originalValue:n})=>{let i=n!=null&&n!==r,a=`${t} must be a \`${e}\` type, but the final value was: \`${ht(r,!0)}\``+(i?` (cast from the value \`${ht(n,!0)}\`).`:".");return r===null&&(a+='\n If "null" is intended as an empty value be sure to mark the schema as `.nullable()`'),a},defined:"${path} must be defined"},te={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},oo={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Ir={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},$r={isValue:"${path} field must be ${value}"},Lr={noUnknown:"${path} field has unspecified keys: ${unknown}"},co={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"};Object.assign(Object.create(null),{mixed:Se,string:te,number:oo,date:Ir,object:Lr,array:co,boolean:$r});const ca=t=>t&&t.__isYupSchema__;class uo{constructor(e,r){if(this.fn=void 0,this.refs=e,this.refs=e,typeof r=="function"){this.fn=r;return}if(!_t(r,"is"))throw new TypeError("`is:` is required for `when()` conditions");if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:i,otherwise:a}=r,l=typeof n=="function"?n:(...o)=>o.every(c=>c===n);this.fn=function(...o){let c=o.pop(),d=o.pop(),f=l(...o)?i:a;if(f)return typeof f=="function"?f(d):d.concat(f.resolve(c))}}resolve(e,r){let n=this.refs.map(a=>a.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),i=this.fn.apply(e,n.concat(e,r));if(i===void 0||i===e)return e;if(!ca(i))throw new TypeError("conditions must return a schema object");return i.resolve(r)}}function da(t){return t==null?[]:[].concat(t)}function Vr(){return Vr=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Vr.apply(this,arguments)}let fo=/\$\{\s*(\w+)\s*\}/g;class J extends Error{static formatError(e,r){const n=r.label||r.path||"this";return n!==r.path&&(r=Vr({},r,{path:n})),typeof e=="string"?e.replace(fo,(i,a)=>ht(r[a])):typeof e=="function"?e(r):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,r,n,i){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=r,this.path=n,this.type=i,this.errors=[],this.inner=[],da(e).forEach(a=>{J.isError(a)?(this.errors.push(...a.errors),this.inner=this.inner.concat(a.inner.length?a.inner:a)):this.errors.push(a)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,J)}}const ho=t=>{let e=!1;return(...r)=>{e||(e=!0,t(...r))}};function Rr(t,e){let{endEarly:r,tests:n,args:i,value:a,errors:l,sort:o,path:c}=t,d=ho(e),f=n.length;const h=[];if(l=l||[],!f)return l.length?d(new J(l,a,c)):d(null,a);for(let u=0;u<n.length;u++){const y=n[u];y(i,function(p){if(p){if(!J.isError(p))return d(p,a);if(r)return p.value=a,d(p,a);h.push(p)}if(--f<=0){if(h.length&&(o&&h.sort(o),l.length&&h.push(...l),l=h),l.length){d(new J(l,a,c),a);return}d(null,a)}})}}function Pe(t){this._maxSize=t,this.clear()}Pe.prototype.clear=function(){this._size=0,this._values=Object.create(null)};Pe.prototype.get=function(t){return this._values[t]};Pe.prototype.set=function(t,e){return this._size>=this._maxSize&&this.clear(),t in this._values||this._size++,this._values[t]=e};var mo=/[^.^\]^[]+|(?=\[\]|\.\.)/g,ua=/^\d+$/,go=/^\d/,po=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,yo=/^\s*(['"]?)(.*?)(\1)\s*$/,mn=512,oi=new Pe(mn),ci=new Pe(mn),di=new Pe(mn),nr={Cache:Pe,split:jr,normalizePath:yr,setter:function(t){var e=yr(t);return ci.get(t)||ci.set(t,function(n,i){for(var a=0,l=e.length,o=n;a<l-1;){var c=e[a];if(c==="__proto__"||c==="constructor"||c==="prototype")return n;o=o[e[a++]]}o[e[a]]=i})},getter:function(t,e){var r=yr(t);return di.get(t)||di.set(t,function(i){for(var a=0,l=r.length;a<l;)if(i!=null||!e)i=i[r[a++]];else return;return i})},join:function(t){return t.reduce(function(e,r){return e+(gn(r)||ua.test(r)?"["+r+"]":(e?".":"")+r)},"")},forEach:function(t,e,r){vo(Array.isArray(t)?t:jr(t),e,r)}};function yr(t){return oi.get(t)||oi.set(t,jr(t).map(function(e){return e.replace(yo,"$2")}))}function jr(t){return t.match(mo)||[""]}function vo(t,e,r){var n=t.length,i,a,l,o;for(a=0;a<n;a++)i=t[a],i&&(xo(i)&&(i='"'+i+'"'),o=gn(i),l=!o&&/^\d+$/.test(i),e.call(r,i,o,l,a,t))}function gn(t){return typeof t=="string"&&t&&["'",'"'].indexOf(t.charAt(0))!==-1}function bo(t){return t.match(go)&&!t.match(ua)}function wo(t){return po.test(t)}function xo(t){return!gn(t)&&(bo(t)||wo(t))}const Ft={context:"$",value:"."};class be{constructor(e,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Ft.context,this.isValue=this.key[0]===Ft.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?Ft.context:this.isValue?Ft.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&nr.getter(this.path,!0),this.map=r.map}getValue(e,r,n){let i=this.isContext?n:this.isValue?e:r;return this.getter&&(i=this.getter(i||{})),this.map&&(i=this.map(i)),i}cast(e,r){return this.getValue(e,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}be.prototype.__isYupRef=!0;function It(){return It=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},It.apply(this,arguments)}function ko(t,e){if(t==null)return{};var r={},n=Object.keys(t),i,a;for(a=0;a<n.length;a++)i=n[a],!(e.indexOf(i)>=0)&&(r[i]=t[i]);return r}function Nt(t){function e(r,n){let{value:i,path:a="",label:l,options:o,originalValue:c,sync:d}=r,f=ko(r,["value","path","label","options","originalValue","sync"]);const{name:h,test:u,params:y,message:g}=t;let{parent:p,context:D}=o;function E(k){return be.isRef(k)?k.getValue(i,p,D):k}function F(k={}){const S=Ji(It({value:i,originalValue:c,label:l,path:k.path||a},y,k.params),E),De=new J(J.formatError(k.message||g,S),i,S.path,k.type||h);return De.params=S,De}let b=It({path:a,parent:p,type:h,createError:F,resolve:E,options:o,originalValue:c},f);if(!d){try{Promise.resolve(u.call(b,i,b)).then(k=>{J.isError(k)?n(k):k?n(null,k):n(F())}).catch(n)}catch(k){n(k)}return}let L;try{var q;if(L=u.call(b,i,b),typeof((q=L)==null?void 0:q.then)=="function")throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(k){n(k);return}J.isError(L)?n(L):L?n(null,L):n(F())}return e.OPTIONS=t,e}let Eo=t=>t.substr(0,t.length-1).substr(1);function Do(t,e,r,n=r){let i,a,l;return e?(nr.forEach(e,(o,c,d)=>{let f=c?Eo(o):o;if(t=t.resolve({context:n,parent:i,value:r}),t.innerType){let h=d?parseInt(f,10):0;if(r&&h>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${e}. because there is no value at that index. `);i=r,r=r&&r[h],t=t.innerType}if(!d){if(!t.fields||!t.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${l} which is a type: "${t._type}")`);i=r,r=r&&r[f],t=t.fields[f]}a=f,l=c?"["+o+"]":"."+o}),{schema:t,parent:i,parentPath:a}):{parent:i,parentPath:e,schema:t}}class $t{constructor(){this.list=void 0,this.refs=void 0,this.list=new Set,this.refs=new Map}get size(){return this.list.size+this.refs.size}describe(){const e=[];for(const r of this.list)e.push(r);for(const[,r]of this.refs)e.push(r.describe());return e}toArray(){return Array.from(this.list).concat(Array.from(this.refs.values()))}resolveAll(e){return this.toArray().reduce((r,n)=>r.concat(be.isRef(n)?e(n):n),[])}add(e){be.isRef(e)?this.refs.set(e.key,e):this.list.add(e)}delete(e){be.isRef(e)?this.refs.delete(e.key):this.list.delete(e)}clone(){const e=new $t;return e.list=new Set(this.list),e.refs=new Map(this.refs),e}merge(e,r){const n=this.clone();return e.list.forEach(i=>n.add(i)),e.refs.forEach(i=>n.add(i)),r.list.forEach(i=>n.delete(i)),r.refs.forEach(i=>n.delete(i)),n}}function ee(){return ee=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(this,arguments)}class K{constructor(e){this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this._typeError=void 0,this._whitelist=new $t,this._blacklist=new $t,this.exclusiveTests=Object.create(null),this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Se.notType)}),this.type=(e==null?void 0:e.type)||"mixed",this.spec=ee({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,presence:"optional"},e==null?void 0:e.spec)}get _type(){return this.type}_typeCheck(e){return!0}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeError=this._typeError,r._whitelistError=this._whitelistError,r._blacklistError=this._blacklistError,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.exclusiveTests=ee({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=Pr(ee({},this.spec,e)),r}label(e){let r=this.clone();return r.spec.label=e,r}meta(...e){if(e.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},e[0]),r}withMutation(e){let r=this._mutate;this._mutate=!0;let n=e(this);return this._mutate=r,n}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let r=this,n=e.clone();const i=ee({},r.spec,n.spec);return n.spec=i,n._typeError||(n._typeError=r._typeError),n._whitelistError||(n._whitelistError=r._whitelistError),n._blacklistError||(n._blacklistError=r._blacklistError),n._whitelist=r._whitelist.merge(e._whitelist,e._blacklist),n._blacklist=r._blacklist.merge(e._blacklist,e._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(a=>{e.tests.forEach(l=>{a.test(l.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(e){return this.spec.nullable&&e===null?!0:this._typeCheck(e)}resolve(e){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((i,a)=>a.resolve(i,e),r),r=r.resolve(e)}return r}cast(e,r={}){let n=this.resolve(ee({value:e},r)),i=n._cast(e,r);if(e!==void 0&&r.assert!==!1&&n.isType(i)!==!0){let a=ht(e),l=ht(i);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n._type}".
|
|
8
|
+
*/var z=typeof Symbol=="function"&&Symbol.for,Zr=z?Symbol.for("react.element"):60103,en=z?Symbol.for("react.portal"):60106,Yt=z?Symbol.for("react.fragment"):60107,Ht=z?Symbol.for("react.strict_mode"):60108,Kt=z?Symbol.for("react.profiler"):60114,qt=z?Symbol.for("react.provider"):60109,Gt=z?Symbol.for("react.context"):60110,tn=z?Symbol.for("react.async_mode"):60111,Xt=z?Symbol.for("react.concurrent_mode"):60111,Jt=z?Symbol.for("react.forward_ref"):60112,Qt=z?Symbol.for("react.suspense"):60113,el=z?Symbol.for("react.suspense_list"):60120,Zt=z?Symbol.for("react.memo"):60115,er=z?Symbol.for("react.lazy"):60116,tl=z?Symbol.for("react.block"):60121,rl=z?Symbol.for("react.fundamental"):60117,nl=z?Symbol.for("react.responder"):60118,il=z?Symbol.for("react.scope"):60119;function Q(t){if(typeof t=="object"&&t!==null){var e=t.$$typeof;switch(e){case Zr:switch(t=t.type,t){case tn:case Xt:case Yt:case Kt:case Ht:case Qt:return t;default:switch(t=t&&t.$$typeof,t){case Gt:case Jt:case er:case Zt:case qt:return t;default:return e}}case en:return e}}}function Zi(t){return Q(t)===Xt}I.AsyncMode=tn;I.ConcurrentMode=Xt;I.ContextConsumer=Gt;I.ContextProvider=qt;I.Element=Zr;I.ForwardRef=Jt;I.Fragment=Yt;I.Lazy=er;I.Memo=Zt;I.Portal=en;I.Profiler=Kt;I.StrictMode=Ht;I.Suspense=Qt;I.isAsyncMode=function(t){return Zi(t)||Q(t)===tn};I.isConcurrentMode=Zi;I.isContextConsumer=function(t){return Q(t)===Gt};I.isContextProvider=function(t){return Q(t)===qt};I.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===Zr};I.isForwardRef=function(t){return Q(t)===Jt};I.isFragment=function(t){return Q(t)===Yt};I.isLazy=function(t){return Q(t)===er};I.isMemo=function(t){return Q(t)===Zt};I.isPortal=function(t){return Q(t)===en};I.isProfiler=function(t){return Q(t)===Kt};I.isStrictMode=function(t){return Q(t)===Ht};I.isSuspense=function(t){return Q(t)===Qt};I.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===Yt||t===Xt||t===Kt||t===Ht||t===Qt||t===el||typeof t=="object"&&t!==null&&(t.$$typeof===er||t.$$typeof===Zt||t.$$typeof===qt||t.$$typeof===Gt||t.$$typeof===Jt||t.$$typeof===rl||t.$$typeof===nl||t.$$typeof===il||t.$$typeof===tl)};I.typeOf=Q;Qi.exports=I;var al=Qi.exports,rn=al,sl={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},ll={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},ol={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},ea={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},nn={};nn[rn.ForwardRef]=ol;nn[rn.Memo]=ea;function Yn(t){return rn.isMemo(t)?ea:nn[t.$$typeof]||sl}var cl=Object.defineProperty,dl=Object.getOwnPropertyNames,Hn=Object.getOwnPropertySymbols,ul=Object.getOwnPropertyDescriptor,fl=Object.getPrototypeOf,Kn=Object.prototype;function ta(t,e,r){if(typeof e!="string"){if(Kn){var n=fl(e);n&&n!==Kn&&ta(t,n,r)}var i=dl(e);Hn&&(i=i.concat(Hn(e)));for(var a=Yn(t),l=Yn(e),o=0;o<i.length;++o){var c=i[o];if(!ll[c]&&!(r&&r[c])&&!(l&&l[c])&&!(a&&a[c])){var d=ul(e,c);try{cl(t,c,d)}catch{}}}}return t}var hl=ta;const ml=Xr(hl);function P(){return P=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},P.apply(this,arguments)}function ra(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function ye(t,e){if(t==null)return{};var r={},n=Object.keys(t),i,a;for(a=0;a<n.length;a++)i=n[a],!(e.indexOf(i)>=0)&&(r[i]=t[i]);return r}function qn(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var tr=as(void 0);tr.displayName="FormikContext";var gl=tr.Provider,pl=tr.Consumer;function vt(){var t=_i(tr);return t||Qr(!1),t}var Gn=function(e){return Array.isArray(e)&&e.length===0},W=function(e){return typeof e=="function"},Ke=function(e){return e!==null&&typeof e=="object"},yl=function(e){return String(Math.floor(Number(e)))===e},hr=function(e){return Object.prototype.toString.call(e)==="[object String]"},na=function(e){return zr.count(e)===0},mr=function(e){return Ke(e)&&W(e.then)};function V(t,e,r,n){n===void 0&&(n=0);for(var i=Xi(e);t&&n<i.length;)t=t[i[n++]];return n!==i.length&&!t||t===void 0?r:t}function ce(t,e,r){for(var n=jn(t),i=n,a=0,l=Xi(e);a<l.length-1;a++){var o=l[a],c=V(t,l.slice(0,a+1));if(c&&(Ke(c)||Array.isArray(c)))i=i[o]=jn(c);else{var d=l[a+1];i=i[o]=yl(d)&&Number(d)>=0?[]:{}}}return(a===0?t:i)[l[a]]===r?t:(r===void 0?delete i[l[a]]:i[l[a]]=r,a===0&&r===void 0&&delete n[l[a]],n)}function ia(t,e,r,n){r===void 0&&(r=new WeakMap),n===void 0&&(n={});for(var i=0,a=Object.keys(t);i<a.length;i++){var l=a[i],o=t[l];Ke(o)?r.get(o)||(r.set(o,!0),n[l]=Array.isArray(o)?[]:{},ia(o,e,r,n[l])):n[l]=e}return n}function vl(t,e){switch(e.type){case"SET_VALUES":return P({},t,{values:e.payload});case"SET_TOUCHED":return P({},t,{touched:e.payload});case"SET_ERRORS":return ge(t.errors,e.payload)?t:P({},t,{errors:e.payload});case"SET_STATUS":return P({},t,{status:e.payload});case"SET_ISSUBMITTING":return P({},t,{isSubmitting:e.payload});case"SET_ISVALIDATING":return P({},t,{isValidating:e.payload});case"SET_FIELD_VALUE":return P({},t,{values:ce(t.values,e.payload.field,e.payload.value)});case"SET_FIELD_TOUCHED":return P({},t,{touched:ce(t.touched,e.payload.field,e.payload.value)});case"SET_FIELD_ERROR":return P({},t,{errors:ce(t.errors,e.payload.field,e.payload.value)});case"RESET_FORM":return P({},t,e.payload);case"SET_FORMIK_STATE":return e.payload(t);case"SUBMIT_ATTEMPT":return P({},t,{touched:ia(t.values,!0),isSubmitting:!0,submitCount:t.submitCount+1});case"SUBMIT_FAILURE":return P({},t,{isSubmitting:!1});case"SUBMIT_SUCCESS":return P({},t,{isSubmitting:!1});default:return t}}var Fe={},Et={};function bl(t){var e=t.validateOnChange,r=e===void 0?!0:e,n=t.validateOnBlur,i=n===void 0?!0:n,a=t.validateOnMount,l=a===void 0?!1:a,o=t.isInitialValid,c=t.enableReinitialize,d=c===void 0?!1:c,f=t.onSubmit,h=ye(t,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),u=P({validateOnChange:r,validateOnBlur:i,validateOnMount:l,onSubmit:f},h),y=X(u.initialValues),g=X(u.initialErrors||Fe),p=X(u.initialTouched||Et),D=X(u.initialStatus),E=X(!1),F=X({});M(function(){return E.current=!0,function(){E.current=!1}},[]);var b=A(0),L=b[1],q=X({values:u.initialValues,errors:u.initialErrors||Fe,touched:u.initialTouched||Et,status:u.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),k=q.current,S=R(function(m){var v=q.current;q.current=vl(v,m),v!==q.current&&L(function(w){return w+1})},[]),De=R(function(m,v){return new Promise(function(w,x){var N=u.validate(m,v);N==null?w(Fe):mr(N)?N.then(function(_){w(_||Fe)},function(_){x(_)}):w(N)})},[u.validate]),qe=R(function(m,v){var w=u.validationSchema,x=W(w)?w(v):w,N=v&&x.validateAt?x.validateAt(v,m):xl(m,x);return new Promise(function(_,U){N.then(function(){_(Fe)},function(de){de.name==="ValidationError"?_(wl(de)):U(de)})})},[u.validationSchema]),C=R(function(m,v){return new Promise(function(w){return w(F.current[m].validate(v))})},[]),Y=R(function(m){var v=Object.keys(F.current).filter(function(x){return W(F.current[x].validate)}),w=v.length>0?v.map(function(x){return C(x,V(m,x))}):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(w).then(function(x){return x.reduce(function(N,_,U){return _==="DO_NOT_DELETE_YOU_WILL_BE_FIRED"||_&&(N=ce(N,v[U],_)),N},{})})},[C]),Ge=R(function(m){return Promise.all([Y(m),u.validationSchema?qe(m):{},u.validate?De(m):{}]).then(function(v){var w=v[0],x=v[1],N=v[2],_=Nr.all([w,x,N],{arrayMerge:kl});return _})},[u.validate,u.validationSchema,Y,De,qe]),H=Z(function(m){return m===void 0&&(m=k.values),S({type:"SET_ISVALIDATING",payload:!0}),Ge(m).then(function(v){return E.current&&(S({type:"SET_ISVALIDATING",payload:!1}),S({type:"SET_ERRORS",payload:v})),v})});M(function(){l&&E.current===!0&&ge(y.current,u.initialValues)&&H(y.current)},[l,H]);var Xe=R(function(m){var v=m&&m.values?m.values:y.current,w=m&&m.errors?m.errors:g.current?g.current:u.initialErrors||{},x=m&&m.touched?m.touched:p.current?p.current:u.initialTouched||{},N=m&&m.status?m.status:D.current?D.current:u.initialStatus;y.current=v,g.current=w,p.current=x,D.current=N;var _=function(){S({type:"RESET_FORM",payload:{isSubmitting:!!m&&!!m.isSubmitting,errors:w,touched:x,status:N,values:v,isValidating:!!m&&!!m.isValidating,submitCount:m&&m.submitCount&&typeof m.submitCount=="number"?m.submitCount:0}})};if(u.onReset){var U=u.onReset(k.values,Tn);mr(U)?U.then(_):_()}else _()},[u.initialErrors,u.initialStatus,u.initialTouched,u.onReset]);M(function(){E.current===!0&&!ge(y.current,u.initialValues)&&d&&(y.current=u.initialValues,Xe(),l&&H(y.current))},[d,u.initialValues,Xe,l,H]),M(function(){d&&E.current===!0&&!ge(g.current,u.initialErrors)&&(g.current=u.initialErrors||Fe,S({type:"SET_ERRORS",payload:u.initialErrors||Fe}))},[d,u.initialErrors]),M(function(){d&&E.current===!0&&!ge(p.current,u.initialTouched)&&(p.current=u.initialTouched||Et,S({type:"SET_TOUCHED",payload:u.initialTouched||Et}))},[d,u.initialTouched]),M(function(){d&&E.current===!0&&!ge(D.current,u.initialStatus)&&(D.current=u.initialStatus,S({type:"SET_STATUS",payload:u.initialStatus}))},[d,u.initialStatus,u.initialTouched]);var xn=Z(function(m){if(F.current[m]&&W(F.current[m].validate)){var v=V(k.values,m),w=F.current[m].validate(v);return mr(w)?(S({type:"SET_ISVALIDATING",payload:!0}),w.then(function(x){return x}).then(function(x){S({type:"SET_FIELD_ERROR",payload:{field:m,value:x}}),S({type:"SET_ISVALIDATING",payload:!1})})):(S({type:"SET_FIELD_ERROR",payload:{field:m,value:w}}),Promise.resolve(w))}else if(u.validationSchema)return S({type:"SET_ISVALIDATING",payload:!0}),qe(k.values,m).then(function(x){return x}).then(function(x){S({type:"SET_FIELD_ERROR",payload:{field:m,value:V(x,m)}}),S({type:"SET_ISVALIDATING",payload:!1})});return Promise.resolve()}),Ua=R(function(m,v){var w=v.validate;F.current[m]={validate:w}},[]),za=R(function(m){delete F.current[m]},[]),kn=Z(function(m,v){S({type:"SET_TOUCHED",payload:m});var w=v===void 0?i:v;return w?H(k.values):Promise.resolve()}),En=R(function(m){S({type:"SET_ERRORS",payload:m})},[]),Dn=Z(function(m,v){var w=W(m)?m(k.values):m;S({type:"SET_VALUES",payload:w});var x=v===void 0?r:v;return x?H(w):Promise.resolve()}),bt=R(function(m,v){S({type:"SET_FIELD_ERROR",payload:{field:m,value:v}})},[]),$e=Z(function(m,v,w){S({type:"SET_FIELD_VALUE",payload:{field:m,value:v}});var x=w===void 0?r:w;return x?H(ce(k.values,m,v)):Promise.resolve()}),Fn=R(function(m,v){var w=v,x=m,N;if(!hr(m)){m.persist&&m.persist();var _=m.target?m.target:m.currentTarget,U=_.type,de=_.name,or=_.id,cr=_.value,Qa=_.checked,Zc=_.outerHTML,Mn=_.options,Za=_.multiple;w=v||de||or,x=/number|range/.test(U)?(N=parseFloat(cr),isNaN(N)?"":N):/checkbox/.test(U)?Dl(V(k.values,w),Qa,cr):Mn&&Za?El(Mn):cr}w&&$e(w,x)},[$e,k.values]),ir=Z(function(m){if(hr(m))return function(v){return Fn(v,m)};Fn(m)}),Le=Z(function(m,v,w){v===void 0&&(v=!0),S({type:"SET_FIELD_TOUCHED",payload:{field:m,value:v}});var x=w===void 0?i:w;return x?H(k.values):Promise.resolve()}),Nn=R(function(m,v){m.persist&&m.persist();var w=m.target,x=w.name,N=w.id,_=w.outerHTML,U=v||x||N;Le(U,!0)},[Le]),ar=Z(function(m){if(hr(m))return function(v){return Nn(v,m)};Nn(m)}),Sn=R(function(m){W(m)?S({type:"SET_FORMIK_STATE",payload:m}):S({type:"SET_FORMIK_STATE",payload:function(){return m}})},[]),Cn=R(function(m){S({type:"SET_STATUS",payload:m})},[]),An=R(function(m){S({type:"SET_ISSUBMITTING",payload:m})},[]),sr=Z(function(){return S({type:"SUBMIT_ATTEMPT"}),H().then(function(m){var v=m instanceof Error,w=!v&&Object.keys(m).length===0;if(w){var x;try{if(x=Ya(),x===void 0)return}catch(N){throw N}return Promise.resolve(x).then(function(N){return E.current&&S({type:"SUBMIT_SUCCESS"}),N}).catch(function(N){if(E.current)throw S({type:"SUBMIT_FAILURE"}),N})}else if(E.current&&(S({type:"SUBMIT_FAILURE"}),v))throw m})}),Wa=Z(function(m){m&&m.preventDefault&&W(m.preventDefault)&&m.preventDefault(),m&&m.stopPropagation&&W(m.stopPropagation)&&m.stopPropagation(),sr().catch(function(v){console.warn("Warning: An unhandled error was caught from submitForm()",v)})}),Tn={resetForm:Xe,validateForm:H,validateField:xn,setErrors:En,setFieldError:bt,setFieldTouched:Le,setFieldValue:$e,setStatus:Cn,setSubmitting:An,setTouched:kn,setValues:Dn,setFormikState:Sn,submitForm:sr},Ya=Z(function(){return f(k.values,Tn)}),Ha=Z(function(m){m&&m.preventDefault&&W(m.preventDefault)&&m.preventDefault(),m&&m.stopPropagation&&W(m.stopPropagation)&&m.stopPropagation(),Xe()}),Ka=R(function(m){return{value:V(k.values,m),error:V(k.errors,m),touched:!!V(k.touched,m),initialValue:V(y.current,m),initialTouched:!!V(p.current,m),initialError:V(g.current,m)}},[k.errors,k.touched,k.values]),qa=R(function(m){return{setValue:function(w,x){return $e(m,w,x)},setTouched:function(w,x){return Le(m,w,x)},setError:function(w){return bt(m,w)}}},[$e,Le,bt]),Ga=R(function(m){var v=Ke(m),w=v?m.name:m,x=V(k.values,w),N={name:w,value:x,onChange:ir,onBlur:ar};if(v){var _=m.type,U=m.value,de=m.as,or=m.multiple;_==="checkbox"?U===void 0?N.checked=!!x:(N.checked=!!(Array.isArray(x)&&~x.indexOf(U)),N.value=U):_==="radio"?(N.checked=x===U,N.value=U):de==="select"&&or&&(N.value=N.value||[],N.multiple=!0)}return N},[ar,ir,k.values]),lr=Tt(function(){return!ge(y.current,k.values)},[y.current,k.values]),Xa=Tt(function(){return typeof o<"u"?lr?k.errors&&Object.keys(k.errors).length===0:o!==!1&&W(o)?o(u):o:k.errors&&Object.keys(k.errors).length===0},[o,lr,k.errors,u]),Ja=P({},k,{initialValues:y.current,initialErrors:g.current,initialTouched:p.current,initialStatus:D.current,handleBlur:ar,handleChange:ir,handleReset:Ha,handleSubmit:Wa,resetForm:Xe,setErrors:En,setFormikState:Sn,setFieldTouched:Le,setFieldValue:$e,setFieldError:bt,setStatus:Cn,setSubmitting:An,setTouched:kn,setValues:Dn,submitForm:sr,validateForm:H,validateField:xn,isValid:Xa,dirty:lr,unregisterField:za,registerField:Ua,getFieldProps:Ga,getFieldMeta:Ka,getFieldHelpers:qa,validateOnBlur:i,validateOnChange:r,validateOnMount:l});return Ja}function aa(t){var e=bl(t),r=t.component,n=t.children,i=t.render,a=t.innerRef;return ns(a,function(){return e}),se(gl,{value:e},r?se(r,e):i?i(e):n?W(n)?n(e):na(n)?null:zr.only(n):null)}function wl(t){var e={};if(t.inner){if(t.inner.length===0)return ce(e,t.path,t.message);for(var i=t.inner,r=Array.isArray(i),n=0,i=r?i:i[Symbol.iterator]();;){var a;if(r){if(n>=i.length)break;a=i[n++]}else{if(n=i.next(),n.done)break;a=n.value}var l=a;V(e,l.path)||(e=ce(e,l.path,l.message))}}return e}function xl(t,e,r,n){r===void 0&&(r=!1);var i=Cr(t);return e[r?"validateSync":"validate"](i,{abortEarly:!1,context:n||i})}function Cr(t){var e=Array.isArray(t)?[]:{};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var n=String(r);Array.isArray(t[n])===!0?e[n]=t[n].map(function(i){return Array.isArray(i)===!0||Rn(i)?Cr(i):i!==""?i:void 0}):Rn(t[n])?e[n]=Cr(t[n]):e[n]=t[n]!==""?t[n]:void 0}return e}function kl(t,e,r){var n=t.slice();return e.forEach(function(a,l){if(typeof n[l]>"u"){var o=r.clone!==!1,c=o&&r.isMergeableObject(a);n[l]=c?Nr(Array.isArray(a)?[]:{},a,r):a}else r.isMergeableObject(a)?n[l]=Nr(t[l],a,r):t.indexOf(a)===-1&&n.push(a)}),n}function El(t){return Array.from(t).filter(function(e){return e.selected}).map(function(e){return e.value})}function Dl(t,e,r){if(typeof t=="boolean")return!!e;var n=[],i=!1,a=-1;if(Array.isArray(t))n=t,a=t.indexOf(r),i=a>=0;else if(!r||r=="true"||r=="false")return!!e;return e&&r&&!i?n.concat(r):i?n.slice(0,a).concat(n.slice(a+1)):n}var Fl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?ss:M;function Z(t){var e=X(t);return Fl(function(){e.current=t}),R(function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return e.current.apply(void 0,n)},[])}function an(t){var e=vt(),r=e.getFieldProps,n=e.getFieldMeta,i=e.getFieldHelpers,a=e.registerField,l=e.unregisterField,o=Ke(t),c=o?t:{name:t},d=c.name,f=c.validate;M(function(){return d&&a(d,{validate:f}),function(){d&&l(d)}},[a,l,d,f]),d||Qr(!1);var h=Tt(function(){return i(d)},[i,d]);return[r(c),n(d),h]}function oe(t){var e=t.validate,r=t.name,n=t.render,i=t.children,a=t.as,l=t.component,o=t.className,c=ye(t,["validate","name","render","children","as","component","className"]),d=vt(),f=ye(d,["validate","validationSchema"]),h=f.registerField,u=f.unregisterField;M(function(){return h(r,{validate:e}),function(){u(r)}},[h,u,r,e]);var y=f.getFieldProps(P({name:r},c)),g=f.getFieldMeta(r),p={field:y,form:f};if(n)return n(P({},p,{meta:g}));if(W(i))return i(P({},p,{meta:g}));if(l){if(typeof l=="string"){var D=c.innerRef,E=ye(c,["innerRef"]);return se(l,P({ref:D},y,E,{className:o}),i)}return se(l,P({field:y,form:f},c,{className:o}),i)}var F=a||"input";if(typeof F=="string"){var b=c.innerRef,L=ye(c,["innerRef"]);return se(F,P({ref:b},y,L,{className:o}),i)}return se(F,P({},y,c,{className:o}),i)}var sn=is(function(t,e){var r=t.action,n=ye(t,["action"]),i=r??"#",a=vt(),l=a.handleReset,o=a.handleSubmit;return se("form",P({onSubmit:o,ref:e,onReset:l,action:i},n))});sn.displayName="Form";function Nl(t){var e=function(i){return se(pl,null,function(a){return a||Qr(!1),se(t,P({},i,{formik:a}))})},r=t.displayName||t.name||t.constructor&&t.constructor.name||"Component";return e.WrappedComponent=t,e.displayName="FormikConnect("+r+")",ml(e,t)}var Sl=function(e,r,n){var i=Oe(e),a=i[r];return i.splice(r,1),i.splice(n,0,a),i},Cl=function(e,r,n){var i=Oe(e),a=i[r];return i[r]=i[n],i[n]=a,i},gr=function(e,r,n){var i=Oe(e);return i.splice(r,0,n),i},Al=function(e,r,n){var i=Oe(e);return i[r]=n,i},Oe=function(e){if(e){if(Array.isArray(e))return[].concat(e);var r=Object.keys(e).map(function(n){return parseInt(n)}).reduce(function(n,i){return i>n?i:n},0);return Array.from(P({},e,{length:r+1}))}else return[]},Xn=function(e,r){var n=typeof e=="function"?e:r;return function(i){if(Array.isArray(i)||Ke(i)){var a=Oe(i);return n(a)}return i}},Tl=function(t){ra(e,t);function e(n){var i;return i=t.call(this,n)||this,i.updateArrayField=function(a,l,o){var c=i.props,d=c.name,f=c.formik.setFormikState;f(function(h){var u=Xn(o,a),y=Xn(l,a),g=ce(h.values,d,a(V(h.values,d))),p=o?u(V(h.errors,d)):void 0,D=l?y(V(h.touched,d)):void 0;return Gn(p)&&(p=void 0),Gn(D)&&(D=void 0),P({},h,{values:g,errors:o?ce(h.errors,d,p):h.errors,touched:l?ce(h.touched,d,D):h.touched})})},i.push=function(a){return i.updateArrayField(function(l){return[].concat(Oe(l),[Vs(a)])},!1,!1)},i.handlePush=function(a){return function(){return i.push(a)}},i.swap=function(a,l){return i.updateArrayField(function(o){return Cl(o,a,l)},!0,!0)},i.handleSwap=function(a,l){return function(){return i.swap(a,l)}},i.move=function(a,l){return i.updateArrayField(function(o){return Sl(o,a,l)},!0,!0)},i.handleMove=function(a,l){return function(){return i.move(a,l)}},i.insert=function(a,l){return i.updateArrayField(function(o){return gr(o,a,l)},function(o){return gr(o,a,null)},function(o){return gr(o,a,null)})},i.handleInsert=function(a,l){return function(){return i.insert(a,l)}},i.replace=function(a,l){return i.updateArrayField(function(o){return Al(o,a,l)},!1,!1)},i.handleReplace=function(a,l){return function(){return i.replace(a,l)}},i.unshift=function(a){var l=-1;return i.updateArrayField(function(o){var c=o?[a].concat(o):[a];return l=c.length,c},function(o){return o?[null].concat(o):[null]},function(o){return o?[null].concat(o):[null]}),l},i.handleUnshift=function(a){return function(){return i.unshift(a)}},i.handleRemove=function(a){return function(){return i.remove(a)}},i.handlePop=function(){return function(){return i.pop()}},i.remove=i.remove.bind(qn(i)),i.pop=i.pop.bind(qn(i)),i}var r=e.prototype;return r.componentDidUpdate=function(i){this.props.validateOnChange&&this.props.formik.validateOnChange&&!ge(V(i.formik.values,i.name),V(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},r.remove=function(i){var a;return this.updateArrayField(function(l){var o=l?Oe(l):[];return a||(a=o[i]),W(o.splice)&&o.splice(i,1),W(o.every)&&o.every(function(c){return c===void 0})?[]:o},!0,!0),a},r.pop=function(){var i;return this.updateArrayField(function(a){var l=a.slice();return i||(i=l&&l.pop&&l.pop()),l},!0,!0),i},r.render=function(){var i={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},a=this.props,l=a.component,o=a.render,c=a.children,d=a.name,f=a.formik,h=ye(f,["validate","validationSchema"]),u=P({},i,{form:h,name:d});return l?se(l,u):o?o(u):c?typeof c=="function"?c(u):na(c)?null:zr.only(c):null},e}(Pi);Tl.defaultProps={validateOnChange:!0};var Ml=function(t){ra(e,t);function e(){return t.apply(this,arguments)||this}var r=e.prototype;return r.shouldComponentUpdate=function(i){return V(this.props.formik.errors,this.props.name)!==V(i.formik.errors,this.props.name)||V(this.props.formik.touched,this.props.name)!==V(i.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(i).length},r.render=function(){var i=this.props,a=i.component,l=i.formik,o=i.render,c=i.children,d=i.name,f=ye(i,["component","formik","render","children","name"]),h=V(l.touched,d),u=V(l.errors,d);return h&&u?o?W(o)?o(u):null:c?W(c)?c(u):null:a?se(a,f,u):u:null},e}(Pi),Ol=Nl(Ml);class _l{async getEditorProfiles(){return await at.instance.url("users/editors").get().json()}async assignRole(e,r){const n={command:{assignRole:r}};return at.instance.url(`users/${e}`).post(n).badRequest(()=>{throw new Error("Failed to execute user command")}).res()}}const Ar=new _l;var Jn,Qn;function Pl(){return{editorProfiles:[]}}let Il=(Jn=Wr({name:"access-manager",resettable:!0,producerFn:Yr}),Jn(Qn=class extends ls{constructor(){super(Pl())}})||Qn);const sa=new Il;class $l{async getBasicProfileByEmail(e){const r=await Ss.getBasicProfileByEmail(e);return os(r,cs(n=>n))}async getEditorProfiles(){const e=(await Ar.getEditorProfiles()).map(Cs.toDomain);sa.update(r=>{r.editorProfiles=e})}async addEditorByEmail(e){const r=await this.getBasicProfileByEmail(e);return xe(r)&&(await Ar.assignRole(r.value.profileId,"accountEditor"),await this.getEditorProfiles()),r}}const Tr=new $l;class Ll extends ds{constructor(r){super(r);O(this,"editorProfiles$",this.select(r=>r.editorProfiles));this.store=r}}const Vl=new Ll(sa),Rl=({open:t,onRemoveConfirmed:e,onClose:r})=>s(qr,{isOpen:t,onClose:r,children:s("div",{className:"px-4 pt-5 pb-4 sm:max-w-lg sm:w-full sm:p-6",children:[s("div",{className:"sm:flex sm:items-start ",children:[s("div",{className:"mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10",children:s(Ii,{className:"h-6 w-6 text-red-600","aria-hidden":"true"})}),s("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[s(Mt.Title,{as:"h3",className:"text-lg leading-6 font-medium text-gray-900",children:"Remove Editor"}),s("div",{className:"mt-2",children:[s("p",{className:"text-sm text-gray-500 leading-5 font-semibold",children:"Are you sure you want to remove this person?"}),s("p",{className:"text-sm text-gray-500 leading-5 font-normal",children:"If you proceed, this person will not be able to edit or manage benefits anymore."})]})]})]}),s("div",{className:"mt-5 sm:mt-4 sm:flex sm:flex-row-reverse",children:[s("button",{type:"button",className:"w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm",onClick:e,children:"Remove"}),s("button",{type:"button",className:"mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:w-auto sm:text-sm",onClick:r,children:"Cancel"})]})]})}),jl=({editorProfile:t,index:e,isLoading:r,isRemoveDisabled:n,onRemoveClicked:i})=>{const{basicProfile:a,benefitsProfile:l}=t,o=c=>{switch(c){case"accountAdmin":return"Admin";case"accountEditor":return"Editor";case"user":return"User";default:return"Unknown"}};return s("tr",{children:[s("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dd-privacy-mask",children:[a.firstName," ",a.lastName]}),s("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dd-privacy-mask",children:a.email}),s("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:o(l.role)}),s("td",{className:"flex justify-end px-6 py-4",children:s("div",{className:"grid justify-items-center w-16",children:r?s(pt,{}):s("button",{type:"button",className:"text-primary text-sm font-medium disabled:text-gray-400 disabled:cursor-not-allowed",disabled:n,onClick:i,children:"Remove"})})})]},e)},Bl=({editorProfiles:t})=>{const[e,r]=A(!1),[n,i]=A(!1),[a,l]=A(j),{service:o}=Gr(),c=f=>{l(ke(f)),r(!0)},d=async()=>{r(!1),i(!0);const f=yt(a),h="user";await Ee(Ar.assignRole(f.basicProfile.profileId,h),300),await Tr.getEditorProfiles(),i(!1),await o.trackRoleAssignedAsync({role:h,targetProfileId:f.basicProfile.profileId})};return s("div",{className:"flex flex-col",children:[s("div",{className:"-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8",children:s("div",{className:"py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8",children:s("div",{className:"shadow overflow-hidden border border-gray-200 sm:rounded-lg",children:s("table",{className:"min-w-full divide-y divide-gray-200",children:[s("thead",{className:"bg-gray-50",children:s("tr",{children:[s("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Name"}),s("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Email"}),s("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Role"}),s("th",{scope:"col",className:"relative px-6 py-3",children:s("span",{className:"sr-only",children:"Edit"})})]})}),s("tbody",{className:"bg-white divide-y divide-gray-200",children:t.length>0?t.map((f,h)=>s(jl,{editorProfile:f,index:h,isLoading:n&&f===Yi(a),isRemoveDisabled:n,onRemoveClicked:()=>c(f)})):s("tr",{children:s("td",{colSpan:4,className:"px-6 py-4 whitespace-nowrap text-base font-medium text-gray-400 text-center",children:"The list is currently empty"})})})]})})})}),s(Rl,{open:e,onRemoveConfirmed:d,onClose:()=>r(!1)})]})},Ul=()=>{const[t,e]=A([]),{service:r}=Gr();M(()=>{(async()=>await Tr.getEditorProfiles())();const i=[Vl.editorProfiles$.subscribe(e)];return()=>{i.map(a=>a.unsubscribe())}},[]);const n=/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i;return s(B,{children:[s("div",{className:"pt-4 pb-3 border-b border-gray-200",children:s("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Editors"})}),s("div",{className:"pt-3",children:s(aa,{initialValues:{email:""},onSubmit:async({email:i},{setErrors:a,setFieldValue:l})=>{if(!n.test(i)){a({email:"Invalid email address"});return}const o=await Ee(Tr.addEditorByEmail(i),300);Hr(o)?a({email:"User not found"}):(l("email",""),await r.trackRoleAssignedAsync({role:"accountEditor",targetProfileId:o.value.profileId}))},children:({isSubmitting:i,setErrors:a})=>s(sn,{children:[s("label",{className:"block text-sm leading-5 font-medium text-gray-700",children:"Add new editor"}),s("div",{className:"flex items-center relative mt-1",children:[s("div",{className:"flex relative",children:[s(oe,{name:"email",className:"shadow-sm block text-sm border-gray-300 rounded-md pr-10",type:"text",placeholder:"Enter email address",onBlur:()=>null,onFocus:()=>a({})}),s("div",{className:$(i?"":"hidden","absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none"),children:s(pt,{})})]}),s("button",{type:"submit",className:"ml-6 bg-primary text-white font-bold py-2 px-4 rounded disabled:opacity-50 disabled:cursor-not-allowed",disabled:i,children:s("div",{className:"flex items-center justify-center",children:[s("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:s("path",{d:"M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"})}),s("span",{className:"pl-2",children:"Add"})]})}),s("div",{className:"ml-4 text-red-500",children:s(Ol,{name:"email"})})]})]})})}),s("div",{className:"pt-6",children:s(Bl,{editorProfiles:t})})]})},zl=t=>{const{user:{basicProfile:e}}=t;return s(B,{children:[s("div",{className:"pb-3 border-b border-gray-200",children:s("h3",{className:"text-lg leading-6 font-medium text-gray-900",children:"Owner"})}),s("div",{className:"rounded-lg bg-white overflow-hidden border border-gray-200 mt-3",children:s("div",{className:"bg-white py-2 px-6",children:s("div",{className:"sm:flex sm:items-center sm:justify-between",children:s("div",{className:"sm:flex sm:items-center sm:space-x-5",children:[s("div",{className:"flex-shrink-0",children:t.imgUrl?s("img",{className:"mx-auto h-20 w-20 rounded-full",src:t.imgUrl,alt:""}):s("div",{className:"sm:flex sm:items-center text-center",children:s("span",{className:"inline-block h-20 w-20 rounded-full overflow-hidden bg-gray-100",children:s("svg",{className:"h-full w-full text-gray-300",fill:"currentColor",viewBox:"0 0 24 24",children:s("path",{d:"M24 20.993V24H0v-2.996A14.977 14.977 0 0112.004 15c4.904 0 9.26 2.354 11.996 5.993zM16.002 8.999a4 4 0 11-8 0 4 4 0 018 0z"})})})})}),s("div",{className:"mt-2 text-center sm:mt-0 sm:text-left",children:[s("p",{className:"text-lg leading-6 font-medium text-gray-900 dd-privacy-mask",children:`${e.firstName} ${e.lastName}`}),s("p",{className:"text-sm leading-5 font-normal text-gray-500 dd-privacy-mask",children:e.email})]})]})})})})]})},Wl=()=>{const t=yt(Kr.useContext(Hi));return s("div",{className:"max-w-5xl",children:[s(Wt,{title:" Access Manager",subTitle:"Specify which staff has permissions to edit and manage benefits.",isLoading:!1}),s("div",{className:"mt-4",children:s(zl,{user:t})}),s("div",{className:"mt-4",children:s(Ul,{})})]})};var ve=(t=>(t[t.Information=0]="Information",t[t.Error=1]="Error",t[t.Success=2]="Success",t))(ve||{});const Yl={actionMessages:[],setActionMessages:()=>({})},rr=Kr.createContext(Yl),ln=()=>{const t=_i(rr),[e,r]=A([]);return M(()=>{r(t.actionMessages)},[t.actionMessages]),[e,a=>t.setActionMessages([a,...t.actionMessages]),a=>{if(a>=0&&a<t.actionMessages.length){const l=t.actionMessages.filter((o,c)=>c!==a);t.setActionMessages(l)}}]},on=t=>{const[e,r,n]=ln(),i=e.map((a,l)=>{let o="",c=s(On,{});switch(a.level){case 0:{o="bg-secondary text-primary",c=s(On,{className:"text-blue-400"});break}case 2:{o="bg-green-50 text-green-800",c=s(fs,{className:"text-green-400"});break}case 1:{o="bg-red-50 text-red-800",c=s(us,{className:"text-red-400"});break}}return s(Ve.li,{className:`p-4 rounded-md relative ${o}`,layoutId:l.toString(),layout:"position",children:[s("div",{className:"absolute left-0 top-0 bottom-0 my-auto w-4 h-4 ml-4",children:c}),s("p",{className:"text-sm leading-5 font-medium mx-8 w-100",children:a.message}),s("button",{className:"absolute right-0 top-0 bottom-0 my-auto w-4 h-4 mr-4",onClick:()=>n(l),children:s(hs,{})})]},l)});return s("ul",{className:`space-y-4 ${t.className}`,children:i})},cn=t=>{const[e,r]=A(0),{tabs:n}=t;M(()=>r(n.findIndex(a=>a.filterKey===t.filterKey)),[t.filterKey,n]),M(()=>t.onFilterChanged(n[e].filterKey),[e]);const i=a=>{r(n.findIndex(l=>l.filterKey===a.currentTarget.value))};return s("div",{children:[s("div",{className:"sm:hidden",children:[s("label",{htmlFor:"tabs",className:"sr-only",children:"Select a tab"}),s("select",{id:"tabs",name:"tabs",className:"block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm rounded-md",value:n[e].filterKey,onChange:i,children:n.map(a=>s("option",{value:a.filterKey,children:a.name}))})]}),s("div",{className:"hidden sm:block",children:s("div",{className:"border-b border-gray-200",children:s("nav",{className:"-mb-px flex space-x-8","aria-label":"Tabs",children:n.map((a,l)=>s(B,{children:[s("div",{className:$(l===e?"border-primary text-primary":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-200","whitespace-nowrap flex py-4 px-1 border-b-2 font-medium text-sm cursor-pointer"),"aria-current":l===e?"page":void 0,onClick:()=>r(l),children:[a.name,a.getCount()!==void 0&&s("span",{className:$(l===e?"bg-secondary text-primary":"bg-gray-100 text-gray-900","hidden ml-3 py-0.5 px-2.5 rounded-full text-xs font-medium md:inline-block"),children:`${a.getCount()}`})]},a.name),a.showDivider&&s("div",{className:"my-4 border-l-2 border-grey-900"})]}))})})})]})},dn=()=>{const t=()=>s("div",{class:"border border-gray-100 shadow rounded-md px-4 py-2 sm:px-6 w-full mx-auto",children:s("div",{class:"animate-pulse flex items-center justify-start",children:[s("div",{className:"flex items-center justify-start text-gray-300",children:s($i,{className:"mr-1.5 h-6 w-6","aria-hidden":"true"})}),s("div",{class:"rounded-full bg-gray-300 h-12 w-12 mx-6"}),s("div",{class:"flex-1 space-y-2 py-1",children:[s("div",{class:"h-4 bg-gray-300 rounded w-3/4"}),s("div",{class:"space-y-2",children:[s("div",{class:"h-3 bg-gray-300 rounded"}),s("div",{class:"h-3 bg-gray-300 rounded w-5/6"})]})]})]})});return s("div",{className:"space-y-3",children:[...Array(5).keys()].map(t)})};class Hl{save(e,r){const n={visibility:r};return st.instance.url(`collections/${e??""}/visibility`).post(n).badRequest(()=>{throw new Error("Failed to execute event save")}).res()}enableCollection(e){return this.save(e,"visible")}disableCollection(e){return this.save(e,"hidden")}getHiddenCollectionsAsync(){return st.instance.url("collections").get().json()}}const Mr=new Hl,Kl=(t,e)=>{const r=[];return t.forEach(n=>{const i={...n,state:e.hiddenCollections.includes(n.id)?"hidden":"visible"};r.push(i)}),r},ql=(t,e)=>{const r=t.findIndex(n=>n.id===e.id);return[...t.slice(0,r),e,...t.slice(r+1)]},Gl=async()=>{const t=await Ee(As.loadCollectionsAsync(),700),e=await Ee(Mr.getHiddenCollectionsAsync(),700);return Kl(t,e)},pr=t=>t==="visible",Xl=t=>s("ul",{className:"divide-y divide-gray-200",children:t.collectionList.map(e=>s("li",{className:"relative bg-white py-3 focus-within:bg-yellow-100 hover:bg-gray-50 cursor-pointer",onClick:()=>{t.onCollectionClicked(e)},children:s("div",{className:"px-1 py-1 sm:px-6 flex flex-row justify-between space-x-3 ",children:[s("div",{className:"min-w-0 flex-1",children:s("a",{href:"#/admin/collections",className:"focus:outline-none",children:[s("span",{className:"absolute inset-0","aria-hidden":"true"}),s("p",{className:"truncate text-lg leading-6 font-semibold text-gray-900 ",children:e.title}),s("p",{className:"mt-1 text-sm leading-5 font-normal text-gray-500 line-clamp-2",children:e.description}),s("div",{className:"mt-1 flex-shrink-0 flex",children:s(zt,{name:e.pillar,size:"xs"})})]})}),s("div",{className:"flex self-center",children:s(nt,{checked:pr(e.state),onChange:()=>{t.onToggleClicked(e)},className:$(pr(e.state)?"bg-primary":"bg-gray-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"),children:[s("span",{className:"sr-only",children:"Toggle collection visibility"}),s("span",{"aria-hidden":"true",className:$(pr(e.state)?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200")})]})})]})},e.id))}),Jl=t=>{const e=t.articles.map(r=>s("li",{className:"space-y-2",children:[s("img",{src:r.coverPhotoUrl,className:"object-cover w-full h-36"}),s("h4",{className:"text-base leading-6 font-medium",children:r.title}),s("p",{className:"text-sm leading-5 font-normal",children:Ki(r.primaryContentType)})]},r.title));return s("div",{className:"space-y-3",children:[s("h2",{className:"text-2xl leading-8 font-bold",children:t.title}),s(zt,{name:t.pillar}),s("img",{src:t.coverPhotoUrl,className:"object-cover w-full h-52 rounded-md"}),s("p",{className:"text-sm leading-4 font-normal",children:t.description}),s("ul",{className:"grid grid-cols-1 gap-y-4 sm:grid-cols-2 sm:gap-x-6 sm:gap-y-10 lg:gap-x-8 xl:grid-cols-3 pt-6",children:e})]})},Je=(t,e)=>t.filter(r=>r.pillar===e).length,Ql=()=>{const[t,e]=A(!0),[r,n]=A([]),[i,a]=A([]),[l,o]=A(),[c,d]=A("money"),[f,h]=A([]);M(()=>{n([{message:"Articles within a collection can not be individually turned off.",level:ve.Information}])},[]),M(()=>{(async()=>{const D=await Gl();a(D),e(!1)})()},[t]),M(()=>{h(i.filter(p=>p.pillar===c))},[i,c]);const u=[{name:"Money",filterKey:"money",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"money")},{name:"Mind",filterKey:"mind",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"mind")},{name:"Body",filterKey:"body",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"body")},{name:"Work",filterKey:"work",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"work")},{name:"Life",filterKey:"life",showDivider:!1,emptyMessage:"",getCount:()=>Je(i,"life")}],y=p=>{o(p.id)},g=async p=>{const D={...p,state:p.state==="visible"?"hidden":"visible"};a(ql(i,D));try{p.state==="visible"?await Mr.disableCollection(p.id):await Mr.enableCollection(p.id)}catch{e(!0)}};return s(rr.Provider,{value:{actionMessages:r,setActionMessages:n},children:[s(Wt,{title:"Collections",subTitle:"Choose which content collections to provide your workforce and enhance their well being offering",isLoading:t}),s("div",{className:"pt-4",children:s(cn,{tabs:u,filterKey:c,onFilterChanged:p=>{d(p)}})}),s(Jr,{children:[t&&s(dn,{}),!t&&s("div",{className:"mt-4 grid grid-cols-12 min-h-[80vh]",children:[s("div",{className:"md:col-span-4 col-span-12 border-l border-t border-b border-gray-200",children:[s(on,{}),s(Xl,{collectionList:f,onCollectionClicked:y,onToggleClicked:g})]}),s("div",{className:"border border-gray-200 p-4 col-span-8 hidden md:block rounded-r-lg",children:f&&f.length>0&&s(Jl,{...f.find(p=>p.id===l)??f[0]})})]})]})]})},Zn={eventName:"CalendarEventModal"},ei={eventName:"CalendarEvents"},Ne={eventName:"CalendarEvent"},Zl={eventName:"CalendarEventTemplates"},la={eventName:"CalendarEventTemplate"};var ti,ri,ni,Qe;function eo(t,e,r,n,i){var a={};return Object.keys(n).forEach(function(l){a[l]=n[l]}),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce(function(l,o){return o(t,e,l)||l},a),i&&a.initializer!==void 0&&(a.value=a.initializer?a.initializer.call(i):void 0,a.initializer=void 0),a.initializer===void 0?(Object.defineProperty(t,e,a),null):a}function to(){return{filter:"Upcoming",editableItemType:"customEvent",featuredItems:[],selectedItem:j,editDialog:{screen:"hidden"}}}let ro=(ti=Wr({name:"events-manager",cache:{ttl:"3600000"},resettable:!0,producerFn:Yr}),ri=Li(),ti(ni=(Qe=class extends Vi{constructor(){super(to())}removeFromFeatured(e){this.update(e,r=>{r.visibility.isFeatured=!1}),this.update(r=>{r.featuredItems.splice(r.featuredItems.indexOf(e),1)})}},eo(Qe.prototype,"removeFromFeatured",[ri],Object.getOwnPropertyDescriptor(Qe.prototype,"removeFromFeatured"),Qe.prototype),Qe))||ni);const ne=new ro,ot=ne;var Or;try{Or=Map}catch{}var _r;try{_r=Set}catch{}function oa(t,e,r){if(!t||typeof t!="object"||typeof t=="function")return t;if(t.nodeType&&"cloneNode"in t)return t.cloneNode(!0);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t);if(Array.isArray(t))return t.map(Pr);if(Or&&t instanceof Or)return new Map(Array.from(t.entries()));if(_r&&t instanceof _r)return new Set(Array.from(t.values()));if(t instanceof Object){e.push(t);var n=Object.create(t);r.push(n);for(var i in t){var a=e.findIndex(function(l){return l===t[i]});n[i]=a>-1?r[a]:oa(t[i],e,r)}return n}return t}function Pr(t){return oa(t,[],[])}const no=Object.prototype.toString,io=Error.prototype.toString,ao=RegExp.prototype.toString,so=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",lo=/^Symbol\((.*)\)(.*)$/;function oo(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function ii(t,e=!1){if(t==null||t===!0||t===!1)return""+t;const r=typeof t;if(r==="number")return oo(t);if(r==="string")return e?`"${t}"`:t;if(r==="function")return"[Function "+(t.name||"anonymous")+"]";if(r==="symbol")return so.call(t).replace(lo,"Symbol($1)");const n=no.call(t).slice(8,-1);return n==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):n==="Error"||t instanceof Error?"["+io.call(t)+"]":n==="RegExp"?ao.call(t):null}function ft(t,e){let r=ii(t,e);return r!==null?r:JSON.stringify(t,function(n,i){let a=ii(this[n],e);return a!==null?a:i},2)}let Se={default:"${path} is invalid",required:"${path} is a required field",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:r,originalValue:n})=>{let i=n!=null&&n!==r,a=`${t} must be a \`${e}\` type, but the final value was: \`${ft(r,!0)}\``+(i?` (cast from the value \`${ft(n,!0)}\`).`:".");return r===null&&(a+='\n If "null" is intended as an empty value be sure to mark the schema as `.nullable()`'),a},defined:"${path} must be defined"},te={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},co={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Ir={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},$r={isValue:"${path} field must be ${value}"},Lr={noUnknown:"${path} field has unspecified keys: ${unknown}"},uo={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"};Object.assign(Object.create(null),{mixed:Se,string:te,number:co,date:Ir,object:Lr,array:uo,boolean:$r});const ca=t=>t&&t.__isYupSchema__;class fo{constructor(e,r){if(this.fn=void 0,this.refs=e,this.refs=e,typeof r=="function"){this.fn=r;return}if(!_t(r,"is"))throw new TypeError("`is:` is required for `when()` conditions");if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:i,otherwise:a}=r,l=typeof n=="function"?n:(...o)=>o.every(c=>c===n);this.fn=function(...o){let c=o.pop(),d=o.pop(),f=l(...o)?i:a;if(f)return typeof f=="function"?f(d):d.concat(f.resolve(c))}}resolve(e,r){let n=this.refs.map(a=>a.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),i=this.fn.apply(e,n.concat(e,r));if(i===void 0||i===e)return e;if(!ca(i))throw new TypeError("conditions must return a schema object");return i.resolve(r)}}function da(t){return t==null?[]:[].concat(t)}function Vr(){return Vr=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Vr.apply(this,arguments)}let ho=/\$\{\s*(\w+)\s*\}/g;class J extends Error{static formatError(e,r){const n=r.label||r.path||"this";return n!==r.path&&(r=Vr({},r,{path:n})),typeof e=="string"?e.replace(ho,(i,a)=>ft(r[a])):typeof e=="function"?e(r):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,r,n,i){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=r,this.path=n,this.type=i,this.errors=[],this.inner=[],da(e).forEach(a=>{J.isError(a)?(this.errors.push(...a.errors),this.inner=this.inner.concat(a.inner.length?a.inner:a)):this.errors.push(a)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,J)}}const mo=t=>{let e=!1;return(...r)=>{e||(e=!0,t(...r))}};function Rr(t,e){let{endEarly:r,tests:n,args:i,value:a,errors:l,sort:o,path:c}=t,d=mo(e),f=n.length;const h=[];if(l=l||[],!f)return l.length?d(new J(l,a,c)):d(null,a);for(let u=0;u<n.length;u++){const y=n[u];y(i,function(p){if(p){if(!J.isError(p))return d(p,a);if(r)return p.value=a,d(p,a);h.push(p)}if(--f<=0){if(h.length&&(o&&h.sort(o),l.length&&h.push(...l),l=h),l.length){d(new J(l,a,c),a);return}d(null,a)}})}}function Pe(t){this._maxSize=t,this.clear()}Pe.prototype.clear=function(){this._size=0,this._values=Object.create(null)};Pe.prototype.get=function(t){return this._values[t]};Pe.prototype.set=function(t,e){return this._size>=this._maxSize&&this.clear(),t in this._values||this._size++,this._values[t]=e};var go=/[^.^\]^[]+|(?=\[\]|\.\.)/g,ua=/^\d+$/,po=/^\d/,yo=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,vo=/^\s*(['"]?)(.*?)(\1)\s*$/,un=512,ai=new Pe(un),si=new Pe(un),li=new Pe(un),nr={Cache:Pe,split:jr,normalizePath:yr,setter:function(t){var e=yr(t);return si.get(t)||si.set(t,function(n,i){for(var a=0,l=e.length,o=n;a<l-1;){var c=e[a];if(c==="__proto__"||c==="constructor"||c==="prototype")return n;o=o[e[a++]]}o[e[a]]=i})},getter:function(t,e){var r=yr(t);return li.get(t)||li.set(t,function(i){for(var a=0,l=r.length;a<l;)if(i!=null||!e)i=i[r[a++]];else return;return i})},join:function(t){return t.reduce(function(e,r){return e+(fn(r)||ua.test(r)?"["+r+"]":(e?".":"")+r)},"")},forEach:function(t,e,r){bo(Array.isArray(t)?t:jr(t),e,r)}};function yr(t){return ai.get(t)||ai.set(t,jr(t).map(function(e){return e.replace(vo,"$2")}))}function jr(t){return t.match(go)||[""]}function bo(t,e,r){var n=t.length,i,a,l,o;for(a=0;a<n;a++)i=t[a],i&&(ko(i)&&(i='"'+i+'"'),o=fn(i),l=!o&&/^\d+$/.test(i),e.call(r,i,o,l,a,t))}function fn(t){return typeof t=="string"&&t&&["'",'"'].indexOf(t.charAt(0))!==-1}function wo(t){return t.match(po)&&!t.match(ua)}function xo(t){return yo.test(t)}function ko(t){return!fn(t)&&(wo(t)||xo(t))}const Dt={context:"$",value:"."};class be{constructor(e,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Dt.context,this.isValue=this.key[0]===Dt.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?Dt.context:this.isValue?Dt.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&nr.getter(this.path,!0),this.map=r.map}getValue(e,r,n){let i=this.isContext?n:this.isValue?e:r;return this.getter&&(i=this.getter(i||{})),this.map&&(i=this.map(i)),i}cast(e,r){return this.getValue(e,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}be.prototype.__isYupRef=!0;function It(){return It=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},It.apply(this,arguments)}function Eo(t,e){if(t==null)return{};var r={},n=Object.keys(t),i,a;for(a=0;a<n.length;a++)i=n[a],!(e.indexOf(i)>=0)&&(r[i]=t[i]);return r}function Ft(t){function e(r,n){let{value:i,path:a="",label:l,options:o,originalValue:c,sync:d}=r,f=Eo(r,["value","path","label","options","originalValue","sync"]);const{name:h,test:u,params:y,message:g}=t;let{parent:p,context:D}=o;function E(k){return be.isRef(k)?k.getValue(i,p,D):k}function F(k={}){const S=Ji(It({value:i,originalValue:c,label:l,path:k.path||a},y,k.params),E),De=new J(J.formatError(k.message||g,S),i,S.path,k.type||h);return De.params=S,De}let b=It({path:a,parent:p,type:h,createError:F,resolve:E,options:o,originalValue:c},f);if(!d){try{Promise.resolve(u.call(b,i,b)).then(k=>{J.isError(k)?n(k):k?n(null,k):n(F())}).catch(n)}catch(k){n(k)}return}let L;try{var q;if(L=u.call(b,i,b),typeof((q=L)==null?void 0:q.then)=="function")throw new Error(`Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(k){n(k);return}J.isError(L)?n(L):L?n(null,L):n(F())}return e.OPTIONS=t,e}let Do=t=>t.substr(0,t.length-1).substr(1);function Fo(t,e,r,n=r){let i,a,l;return e?(nr.forEach(e,(o,c,d)=>{let f=c?Do(o):o;if(t=t.resolve({context:n,parent:i,value:r}),t.innerType){let h=d?parseInt(f,10):0;if(r&&h>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${e}. because there is no value at that index. `);i=r,r=r&&r[h],t=t.innerType}if(!d){if(!t.fields||!t.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${l} which is a type: "${t._type}")`);i=r,r=r&&r[f],t=t.fields[f]}a=f,l=c?"["+o+"]":"."+o}),{schema:t,parent:i,parentPath:a}):{parent:i,parentPath:e,schema:t}}class $t{constructor(){this.list=void 0,this.refs=void 0,this.list=new Set,this.refs=new Map}get size(){return this.list.size+this.refs.size}describe(){const e=[];for(const r of this.list)e.push(r);for(const[,r]of this.refs)e.push(r.describe());return e}toArray(){return Array.from(this.list).concat(Array.from(this.refs.values()))}resolveAll(e){return this.toArray().reduce((r,n)=>r.concat(be.isRef(n)?e(n):n),[])}add(e){be.isRef(e)?this.refs.set(e.key,e):this.list.add(e)}delete(e){be.isRef(e)?this.refs.delete(e.key):this.list.delete(e)}clone(){const e=new $t;return e.list=new Set(this.list),e.refs=new Map(this.refs),e}merge(e,r){const n=this.clone();return e.list.forEach(i=>n.add(i)),e.refs.forEach(i=>n.add(i)),r.list.forEach(i=>n.delete(i)),r.refs.forEach(i=>n.delete(i)),n}}function ee(){return ee=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(this,arguments)}class K{constructor(e){this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this._typeError=void 0,this._whitelist=new $t,this._blacklist=new $t,this.exclusiveTests=Object.create(null),this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Se.notType)}),this.type=(e==null?void 0:e.type)||"mixed",this.spec=ee({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,presence:"optional"},e==null?void 0:e.spec)}get _type(){return this.type}_typeCheck(e){return!0}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeError=this._typeError,r._whitelistError=this._whitelistError,r._blacklistError=this._blacklistError,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.exclusiveTests=ee({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=Pr(ee({},this.spec,e)),r}label(e){let r=this.clone();return r.spec.label=e,r}meta(...e){if(e.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},e[0]),r}withMutation(e){let r=this._mutate;this._mutate=!0;let n=e(this);return this._mutate=r,n}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let r=this,n=e.clone();const i=ee({},r.spec,n.spec);return n.spec=i,n._typeError||(n._typeError=r._typeError),n._whitelistError||(n._whitelistError=r._whitelistError),n._blacklistError||(n._blacklistError=r._blacklistError),n._whitelist=r._whitelist.merge(e._whitelist,e._blacklist),n._blacklist=r._blacklist.merge(e._blacklist,e._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(a=>{e.tests.forEach(l=>{a.test(l.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(e){return this.spec.nullable&&e===null?!0:this._typeCheck(e)}resolve(e){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((i,a)=>a.resolve(i,e),r),r=r.resolve(e)}return r}cast(e,r={}){let n=this.resolve(ee({value:e},r)),i=n._cast(e,r);if(e!==void 0&&r.assert!==!1&&n.isType(i)!==!0){let a=ft(e),l=ft(i);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n._type}".
|
|
9
9
|
|
|
10
10
|
attempted value: ${a}
|
|
11
|
-
`+(l!==a?`result of cast: ${l}`:""))}return i}_cast(e,r){let n=e===void 0?e:this.transforms.reduce((i,a)=>a.call(this,i,e,this),e);return n===void 0&&(n=this.getDefault()),n}_validate(e,r={},n){let{sync:i,path:a,from:l=[],originalValue:o=e,strict:c=this.spec.strict,abortEarly:d=this.spec.abortEarly}=r,f=e;c||(f=this._cast(f,ee({assert:!1},r)));let h={value:f,path:a,options:r,originalValue:o,schema:this,label:this.spec.label,sync:i,from:l},u=[];this._typeError&&u.push(this._typeError);let y=[];this._whitelistError&&y.push(this._whitelistError),this._blacklistError&&y.push(this._blacklistError),Rr({args:h,value:f,path:a,sync:i,tests:u,endEarly:d},g=>{if(g)return void n(g,f);Rr({tests:this.tests.concat(y),args:h,path:a,sync:i,value:f,endEarly:d},n)})}validate(e,r,n){let i=this.resolve(ee({},r,{value:e}));return typeof n=="function"?i._validate(e,r,n):new Promise((a,l)=>i._validate(e,r,(o,c)=>{o?l(o):a(c)}))}validateSync(e,r){let n=this.resolve(ee({},r,{value:e})),i;return n._validate(e,ee({},r,{sync:!0}),(a,l)=>{if(a)throw a;i=l}),i}isValid(e,r){return this.validate(e,r).then(()=>!0,n=>{if(J.isError(n))return!1;throw n})}isValidSync(e,r){try{return this.validateSync(e,r),!0}catch(n){if(J.isError(n))return!1;throw n}}_getDefault(){let e=this.spec.default;return e==null?e:typeof e=="function"?e.call(this):Pr(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){let r=this.clone();return r.spec.strict=e,r}_isPresent(e){return e!=null}defined(e=Se.defined){return this.test({message:e,name:"defined",exclusive:!0,test(r){return r!==void 0}})}required(e=Se.required){return this.clone({presence:"required"}).withMutation(r=>r.test({message:e,name:"required",exclusive:!0,test(n){return this.schema._isPresent(n)}}))}notRequired(){let e=this.clone({presence:"optional"});return e.tests=e.tests.filter(r=>r.OPTIONS.name!=="required"),e}nullable(e=!0){return this.clone({nullable:e!==!1})}transform(e){let r=this.clone();return r.transforms.push(e),r}test(...e){let r;if(e.length===1?typeof e[0]=="function"?r={test:e[0]}:r=e[0]:e.length===2?r={name:e[0],test:e[1]}:r={name:e[0],message:e[1],test:e[2]},r.message===void 0&&(r.message=Se.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),i=Nt(r),a=r.exclusive||r.name&&n.exclusiveTests[r.name]===!0;if(r.exclusive&&!r.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return r.name&&(n.exclusiveTests[r.name]=!!r.exclusive),n.tests=n.tests.filter(l=>!(l.OPTIONS.name===r.name&&(a||l.OPTIONS.test===i.OPTIONS.test))),n.tests.push(i),n}when(e,r){!Array.isArray(e)&&typeof e!="string"&&(r=e,e=".");let n=this.clone(),i=da(e).map(a=>new be(a));return i.forEach(a=>{a.isSibling&&n.deps.push(a.key)}),n.conditions.push(new uo(i,r)),n}typeError(e){let r=this.clone();return r._typeError=Nt({message:e,name:"typeError",test(n){return n!==void 0&&!this.schema.isType(n)?this.createError({params:{type:this.schema._type}}):!0}}),r}oneOf(e,r=Se.oneOf){let n=this.clone();return e.forEach(i=>{n._whitelist.add(i),n._blacklist.delete(i)}),n._whitelistError=Nt({message:r,name:"oneOf",test(i){if(i===void 0)return!0;let a=this.schema._whitelist,l=a.resolveAll(this.resolve);return l.includes(i)?!0:this.createError({params:{values:a.toArray().join(", "),resolved:l}})}}),n}notOneOf(e,r=Se.notOneOf){let n=this.clone();return e.forEach(i=>{n._blacklist.add(i),n._whitelist.delete(i)}),n._blacklistError=Nt({message:r,name:"notOneOf",test(i){let a=this.schema._blacklist,l=a.resolveAll(this.resolve);return l.includes(i)?this.createError({params:{values:a.toArray().join(", "),resolved:l}}):!0}}),n}strip(e=!0){let r=this.clone();return r.spec.strip=e,r}describe(){const e=this.clone(),{label:r,meta:n}=e.spec;return{meta:n,label:r,type:e.type,oneOf:e._whitelist.describe(),notOneOf:e._blacklist.describe(),tests:e.tests.map(a=>({name:a.OPTIONS.name,params:a.OPTIONS.params})).filter((a,l,o)=>o.findIndex(c=>c.name===a.name)===l)}}}K.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])K.prototype[`${t}At`]=function(e,r,n={}){const{parent:i,parentPath:a,schema:l}=Do(this,e,r,n.context);return l[t](i&&i[a],ee({},n,{parent:i,path:e}))};for(const t of["equals","is"])K.prototype[t]=K.prototype.oneOf;for(const t of["not","nope"])K.prototype[t]=K.prototype.notOneOf;K.prototype.optional=K.prototype.notRequired;const fa=K;function rt(){return new fa}rt.prototype=fa.prototype;const G=t=>t==null;function ha(){return new ma}class ma extends K{constructor(){super({type:"boolean"}),this.withMutation(()=>{this.transform(function(e){if(!this.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}_typeCheck(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}isTrue(e=$r.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return G(r)||r===!0}})}isFalse(e=$r.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return G(r)||r===!1}})}}ha.prototype=ma.prototype;let Fo=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,No=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,So=/^(?:[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,Co=t=>G(t)||t===t.trim(),Ao={}.toString();function re(){return new ga}class ga extends K{constructor(){super({type:"string"}),this.withMutation(()=>{this.transform(function(e){if(this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===Ao?e:r})})}_typeCheck(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}_isPresent(e){return super._isPresent(e)&&!!e.length}length(e,r=te.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:e},test(n){return G(n)||n.length===this.resolve(e)}})}min(e,r=te.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:e},test(n){return G(n)||n.length>=this.resolve(e)}})}max(e,r=te.max){return this.test({name:"max",exclusive:!0,message:r,params:{max:e},test(n){return G(n)||n.length<=this.resolve(e)}})}matches(e,r){let n=!1,i,a;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:i,name:a}=r:i=r),this.test({name:a||"matches",message:i||te.matches,params:{regex:e},test:l=>G(l)||l===""&&n||l.search(e)!==-1})}email(e=te.email){return this.matches(Fo,{name:"email",message:e,excludeEmptyString:!0})}url(e=te.url){return this.matches(No,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=te.uuid){return this.matches(So,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=te.trim){return this.transform(r=>r!=null?r.trim():r).test({message:e,name:"trim",test:Co})}lowercase(e=te.lowercase){return this.transform(r=>G(r)?r:r.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,test:r=>G(r)||r===r.toLowerCase()})}uppercase(e=te.uppercase){return this.transform(r=>G(r)?r:r.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,test:r=>G(r)||r===r.toUpperCase()})}}re.prototype=ga.prototype;var To=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function Mo(t){var e=[1,4,5,6,7,10,11],r=0,n,i;if(i=To.exec(t)){for(var a=0,l;l=e[a];++a)i[l]=+i[l]||0;i[2]=(+i[2]||1)-1,i[3]=+i[3]||1,i[7]=i[7]?String(i[7]).substr(0,3):0,(i[8]===void 0||i[8]==="")&&(i[9]===void 0||i[9]==="")?n=+new Date(i[1],i[2],i[3],i[4],i[5],i[6],i[7]):(i[8]!=="Z"&&i[9]!==void 0&&(r=i[10]*60+i[11],i[9]==="+"&&(r=0-r)),n=Date.UTC(i[1],i[2],i[3],i[4],i[5]+r,i[6],i[7]))}else n=Date.parse?Date.parse(t):NaN;return n}let pa=new Date(""),Oo=t=>Object.prototype.toString.call(t)==="[object Date]";class ya extends K{constructor(){super({type:"date"}),this.withMutation(()=>{this.transform(function(e){return this.isType(e)?e:(e=Mo(e),isNaN(e)?pa:new Date(e))})})}_typeCheck(e){return Oo(e)&&!isNaN(e.getTime())}prepareParam(e,r){let n;if(be.isRef(e))n=e;else{let i=this.cast(e);if(!this._typeCheck(i))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=i}return n}min(e,r=Ir.min){let n=this.prepareParam(e,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:e},test(i){return G(i)||i>=this.resolve(n)}})}max(e,r=Ir.max){let n=this.prepareParam(e,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:e},test(i){return G(i)||i<=this.resolve(n)}})}}ya.INVALID_DATE=pa;ya.prototype;var pn={exports:{}};pn.exports=function(t){return va(_o(t),t)};pn.exports.array=va;function va(t,e){var r=t.length,n=new Array(r),i={},a=r,l=Po(e),o=Io(t);for(e.forEach(function(d){if(!o.has(d[0])||!o.has(d[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});a--;)i[a]||c(t[a],a,new Set);return n;function c(d,f,h){if(h.has(d)){var u;try{u=", node was:"+JSON.stringify(d)}catch{u=""}throw new Error("Cyclic dependency"+u)}if(!o.has(d))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(d));if(!i[f]){i[f]=!0;var y=l.get(d)||new Set;if(y=Array.from(y),f=y.length){h.add(d);do{var g=y[--f];c(g,o.get(g),h)}while(f);h.delete(d)}n[--r]=d}}}function _o(t){for(var e=new Set,r=0,n=t.length;r<n;r++){var i=t[r];e.add(i[0]),e.add(i[1])}return Array.from(e)}function Po(t){for(var e=new Map,r=0,n=t.length;r<n;r++){var i=t[r];e.has(i[0])||e.set(i[0],new Set),e.has(i[1])||e.set(i[1],new Set),e.get(i[0]).add(i[1])}return e}function Io(t){for(var e=new Map,r=0,n=t.length;r<n;r++)e.set(t[r],r);return e}var $o=pn.exports;const Lo=Zr($o);function Vo(t,e=[]){let r=[],n=new Set,i=new Set(e.map(([l,o])=>`${l}-${o}`));function a(l,o){let c=nr.split(l)[0];n.add(c),i.has(`${o}-${c}`)||r.push([o,c])}for(const l in t)if(_t(t,l)){let o=t[l];n.add(l),be.isRef(o)&&o.isSibling?a(o.path,l):ca(o)&&"deps"in o&&o.deps.forEach(c=>a(c,l))}return Lo.array(Array.from(n),r).reverse()}function ui(t,e){let r=1/0;return t.some((n,i)=>{var a;if(((a=e.path)==null?void 0:a.indexOf(n))!==-1)return r=i,!0}),r}function ba(t){return(e,r)=>ui(t,e)-ui(t,r)}function Ue(){return Ue=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Ue.apply(this,arguments)}let fi=t=>Object.prototype.toString.call(t)==="[object Object]";function Ro(t,e){let r=Object.keys(t.fields);return Object.keys(e).filter(n=>r.indexOf(n)===-1)}const jo=ba([]);class wa extends K{constructor(e){super({type:"object"}),this.fields=Object.create(null),this._sortErrors=jo,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{this.transform(function(n){if(typeof n=="string")try{n=JSON.parse(n)}catch{n=null}return this.isType(n)?n:null}),e&&this.shape(e)})}_typeCheck(e){return fi(e)||typeof e=="function"}_cast(e,r={}){var n;let i=super._cast(e,r);if(i===void 0)return this.getDefault();if(!this._typeCheck(i))return i;let a=this.fields,l=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,o=this._nodes.concat(Object.keys(i).filter(h=>this._nodes.indexOf(h)===-1)),c={},d=Ue({},r,{parent:c,__validating:r.__validating||!1}),f=!1;for(const h of o){let u=a[h],y=_t(i,h);if(u){let g,p=i[h];d.path=(r.path?`${r.path}.`:"")+h,u=u.resolve({value:p,context:r.context,parent:c});let D="spec"in u?u.spec:void 0,E=D==null?void 0:D.strict;if(D!=null&&D.strip){f=f||h in i;continue}g=!r.__validating||!E?u.cast(i[h],d):i[h],g!==void 0&&(c[h]=g)}else y&&!l&&(c[h]=i[h]);c[h]!==i[h]&&(f=!0)}return f?c:i}_validate(e,r={},n){let i=[],{sync:a,from:l=[],originalValue:o=e,abortEarly:c=this.spec.abortEarly,recursive:d=this.spec.recursive}=r;l=[{schema:this,value:o},...l],r.__validating=!0,r.originalValue=o,r.from=l,super._validate(e,r,(f,h)=>{if(f){if(!J.isError(f)||c)return void n(f,h);i.push(f)}if(!d||!fi(h)){n(i[0]||null,h);return}o=o||h;let u=this._nodes.map(y=>(g,p)=>{let D=y.indexOf(".")===-1?(r.path?`${r.path}.`:"")+y:`${r.path||""}["${y}"]`,E=this.fields[y];if(E&&"validate"in E){E.validate(h[y],Ue({},r,{path:D,from:l,strict:!0,parent:h,originalValue:o[y]}),p);return}p(null)});Rr({sync:a,tests:u,value:h,errors:i,endEarly:c,sort:this._sortErrors,path:r.path},n)})}clone(e){const r=super.clone(e);return r.fields=Ue({},this.fields),r._nodes=this._nodes,r._excludedEdges=this._excludedEdges,r._sortErrors=this._sortErrors,r}concat(e){let r=super.concat(e),n=r.fields;for(let[i,a]of Object.entries(this.fields)){const l=n[i];l===void 0?n[i]=a:l instanceof K&&a instanceof K&&(n[i]=a.concat(l))}return r.withMutation(()=>r.shape(n,this._excludedEdges))}getDefaultFromShape(){let e={};return this._nodes.forEach(r=>{const n=this.fields[r];e[r]="default"in n?n.getDefault():void 0}),e}_getDefault(){if("default"in this.spec)return super._getDefault();if(this._nodes.length)return this.getDefaultFromShape()}shape(e,r=[]){let n=this.clone(),i=Object.assign(n.fields,e);return n.fields=i,n._sortErrors=ba(Object.keys(i)),r.length&&(Array.isArray(r[0])||(r=[r]),n._excludedEdges=[...n._excludedEdges,...r]),n._nodes=Vo(i,n._excludedEdges),n}pick(e){const r={};for(const n of e)this.fields[n]&&(r[n]=this.fields[n]);return this.clone().withMutation(n=>(n.fields={},n.shape(r)))}omit(e){const r=this.clone(),n=r.fields;r.fields={};for(const i of e)delete n[i];return r.withMutation(()=>r.shape(n))}from(e,r,n){let i=nr.getter(e,!0);return this.transform(a=>{if(a==null)return a;let l=a;return _t(a,e)&&(l=Ue({},a),n||delete l[e],l[r]=i(a)),l})}noUnknown(e=!0,r=Lr.noUnknown){typeof e=="string"&&(r=e,e=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(i){if(i==null)return!0;const a=Ro(this.schema,i);return!e||a.length===0||this.createError({params:{unknown:a.join(", ")}})}});return n.spec.noUnknown=e,n}unknown(e=!0,r=Lr.noUnknown){return this.noUnknown(!e,r)}transformKeys(e){return this.transform(r=>r&&Vs(r,(n,i)=>e(i)))}camelCase(){return this.transformKeys(Rs)}snakeCase(){return this.transformKeys(Wn)}constantCase(){return this.transformKeys(e=>Wn(e).toUpperCase())}describe(){let e=super.describe();return e.fields=Ji(this.fields,r=>r.describe()),e}}function xa(t){return new wa(t)}xa.prototype=wa.prototype;const Uo=/^(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,yn=xa().shape({type:rt().default("customPerk").required(),title:re().default("").required("Field is required").max(30,"Maximum 30 characters"),subtitle:re().default("").required("Field is required").max(60,"Maximum 60 characters"),category:re().default("").required("Category is required").oneOf([...qi],"Category is required"),startDate:re().when("type",(t,e)=>t==="customEvent"?e.default("").required("Start date is missing").test("past-start-date","Start date cannot be in the past",r=>{if(!r)return!1;const n=Ln(new Date),i=Et(r,"dd/MM/yyyy",new Date);return!fr(i,n)}):e.optional()),endDate:re().when("type",(t,e)=>t==="customEvent"?e.default("").required("End date is missing").test("past-end-date","End date cannot be in the past",r=>{if(!r)return!1;const n=Ln(new Date),i=Et(r,"dd/MM/yyyy",new Date);return!fr(i,n)}).when("startDate",(r,n)=>r?n.test("end-before-start-date","End date cannot be before start date",i=>{if(!i)return!1;const a=Et(i,"dd/MM/yyyy",new Date),l=Et(i,"dd/MM/yyyy",new Date);return!fr(a,l)}):n):e.optional()),startTime:re().optional(),location:re().max(30,"Maximum 30 characters").optional(),description:re().default("").required("Field is required").max(1e3,"Maximum 1000 characters"),link:re().transform(function(t,e){if(this.isType(t)&&t){const r=t;return r.startsWith("https://")?r.substr(8):r}else return t}).matches(Uo,{excludeEmptyString:!0,message:"Provide a valid URL"}).when("linkLabel",(t,e)=>t&&t.length>0?e.required("URL is missing"):e.optional()),linkLabel:re().when("link",(t,e)=>t&&t.length>0?e.required("Button label is missing"):e.optional()),attachment:rt().default(()=>j).required(),coverPhoto:rt().default(()=>j).required(),icon:rt().default(()=>j).required(),enableAfterSave:ha().default(!0).required()},[["link","linkLabel"]]),Bo=yn.getDefault(),ka=t=>{var i;const e=t.data.dateRange?Vn(Hn(t.data.dateRange.start),t.data.dateRange.allDay):void 0,r=t.data.dateRange?Vn(Hn(t.data.dateRange.end),t.data.dateRange.allDay):void 0,n=(i=t.data.url)==null?void 0:i.replace("https://","");return yn.cast({title:t.data.title,category:t.data.category,subtitle:t.data.subtitle,description:t.data.description??"",link:n,linkLabel:t.data.linkLabel??"",startDate:(e==null?void 0:e.date)??"",endDate:(r==null?void 0:r.date)??"",location:t.data.location??"",startTime:(e==null?void 0:e.time)??"",attachment:Ui.pipe(Te(t.data.attachments),ms(a=>a.length>0?a[0]:null)),icon:Te(t.data.icon),coverPhoto:Te(t.data.backdrop),enableAfterSave:t.visibility.isEnabled})},hi=t=>{const e=t.startDate&&t.endDate?{start:Rn(t.startDate,t.startTime),end:Rn(t.endDate,t.startTime),allDay:!t.startTime}:void 0;return{title:t.title,category:t.category,subtitle:t.subtitle,dateRange:e,description:t.description,url:t.link?`https://${t.link}`:void 0,linkLabel:t.linkLabel,location:t.location,attachments:Ui.pipe(t.attachment,gs(()=>[],r=>[r])),icon:$n(t.icon),backdrop:$n(t.coverPhoto),isDeleted:!1}},Ea=(t,e)=>{t.update(r=>{r.selectedItem=ke(e.id),r.editDialog={screen:"form",editMode:"edit",initialValues:ke(ka(e))}})},zo=(t,e)=>{t.update(r=>{r.editDialog={screen:"form",editMode:"add",initialValues:ke(ka(e))}})},Da=t=>{t.update(e=>{e.editDialog={screen:"form",editMode:"add",initialValues:j}})},Wo=t=>{t.update(e=>{e.editDialog=ue.match([e.editDialog,e.selectedItem]).with([{screen:"preview"},ue.when(xe)],([r,n])=>({screen:"form",editMode:"edit",initialValues:ke(r.formData),selectedItem:e.selectedItem})).with([{screen:"preview"},ue.when(Kr)],([r,n])=>({screen:"form",editMode:"add",initialValues:ke(r.formData),selectedItem:j})).with([{screen:"form"},ue.__],()=>({screen:"hidden"})).with([{screen:"readonly-preview"},ue.__],()=>({screen:"hidden"})).with([{screen:"template-preview"},ue.__],()=>({screen:"hidden"})).with(ue.__,()=>{throw Error("Unreachable state")}).exhaustive()})},Ho=t=>{t.getValue().editDialog.screen==="form"&&t.update(e=>{e.editDialog={screen:"hidden"},e.selectedItem=j})},Yo=(t,e)=>{t.update(r=>{r.editDialog={screen:"preview",formData:e}})},Fa=(t,e)=>{t.update(r=>{r.editDialog={screen:"readonly-preview",itemData:e}})},Ko=(t,e)=>{t.update(r=>{r.editDialog={screen:"template-preview",templateData:e}})},qo=async(t,e,r)=>{const n=vt(e);t.update(i=>{i.editDialog={screen:"hidden"},i.selectedItem=j}),await r(n),t.remove(n)},Go=async(t,e,r,n,i,a)=>{const l=e;Kr(l)?await Ee(n(r,void 0,a),600):await Ee(n(r,l.value,a),600),t.update(o=>{o.editDialog={screen:"hidden"},o.selectedItem=j}),i()},Xo=t=>{var e;return s("div",{onClick:t.onClick,className:"flex flex-col cursor-pointer",children:[s("div",{className:"w-96 h-40",children:s("img",{className:"rounded-t-lg h-40 w-full object-cover",src:((e=t.item.data.backdrop)==null?void 0:e.downloadUrl)??Ts})}),s("div",{className:"w-96 h-40 rounded-b-lg shadow-lg p-4 flex flex-col",children:[s("h3",{className:"text-lg leading-6 font-bold text-gray-900 truncate pb-2",children:t.item.data.title}),s("p",{className:"text-sm leading-5 font-normal text-gray-500 truncate pb-1",children:t.item.data.dateRange?Gi(t.item.data.dateRange.start,t.item.data.dateRange.end,t.item.data.dateRange.allDay):""}),s("p",{className:"text-sm leading-5 font-normal text-gray-500 break-words pb-1",children:t.item.data.subtitle}),s("div",{className:"block",children:s(zt,{name:t.item.data.category})})]})]})},mi=t=>{var i,a;const e=t.item.visibility.isFeatured,r=t.item.visibility.isEnabled,n=t.item.type==="customEvent"||t.item.type==="eventTemplate";return s("div",{className:$("px-4 py-2 sm:px-6 flex flex-row overflow-hidden rounded-md hover:bg-gray-50 cursor-pointer border shadow border-gray-100"),onClick:()=>{t.onPreviewClicked!==void 0&&t.onPreviewClicked(t.item)},children:[t.onFeatureClicked&&s("div",{className:$("flex items-center justify-start hover:text-yellow-500 cursor-pointer",e?"text-yellow-500":"text-gray-300",(r||e)&&!t.hideFeatureToggle?"visible":"invisible"),onClick:l=>{var o;l.stopPropagation(),(o=t.onFeatureClicked)==null||o.call(t,t.item)},children:s(Vi,{className:"mr-1.5 h-6 w-6","aria-hidden":"true"})}),s("div",{className:"flex items-center justify-start flex-shrink-0 px-4",children:n?s("img",{className:"inline-block object-contain h-16 w-16 rounded-md",src:((i=t.item.data.backdrop)==null?void 0:i.downloadUrl)??"https://via.placeholder.com/500",alt:""}):s("img",{className:"inline-block object-contain h-16 w-16 rounded-md",src:((a=t.item.data.icon)==null?void 0:a.downloadUrl)??"https://via.placeholder.com/500",alt:""})}),s("div",{className:"flex flex-grow flex-col",children:[s("p",{className:"text-lg leading-6 font-medium text-gray-900 truncate",children:t.item.data.title}),s("p",{className:"relative text-sm leading-5 font-normal text-gray-500 truncate flex-grow pb-1",children:[n&&t.item.data.dateRange?Gi(t.item.data.dateRange.start,t.item.data.dateRange.end,t.item.data.dateRange.allDay):t.item.data.subtitle,n&&t.item.data.location&&s(U,{children:[s("span",{className:"pipe mx-3"}),s("span",{children:t.item.data.location})]})]}),s("div",{className:"flex-shrink-0 flex",children:s(zt,{name:t.item.data.category,size:"xs"})})]}),(t.item.type==="customPerk"||t.item.type==="customEvent")&&s("div",{className:"flex self-center mr-8",children:s("button",{type:"button",className:"inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",onClick:l=>{l.stopPropagation(),t.onEditClicked!==void 0&&t.onEditClicked(t.item)},children:[s(ps,{className:"mr-1.5 h-3 w-3","aria-hidden":"true"}),"Edit"]})}),t.onToggleClicked&&s("div",{className:"flex self-center",onClick:l=>{l.stopPropagation()},children:s(nt,{checked:t.item.visibility.isEnabled,onChange:()=>{var l;(l=t.onToggleClicked)==null||l.call(t,t.item)},className:$(t.item.visibility.isEnabled?"bg-primary":"bg-gray-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"),children:[s("span",{className:"sr-only",children:"Use setting"}),s("span",{"aria-hidden":"true",className:$(t.item.visibility.isEnabled?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200")})]})})]})},Na=t=>{const r=72-24*(t.featuredItems?t.featuredItems.totalCount:0);return s(U,{children:[t.featuredItems&&t.featuredDescription&&s("h2",{className:"text-lg leading-6 font-medium text-gray-900 mb-3 mt-3",children:t.featuredDescription}),t.featuredItems&&t.featuredItems.filtered.length>0&&s("div",{className:"mb-4",children:s("ul",{className:"space-y-3",children:t.featuredItems.filtered.map(n=>s(Ve.li,{layoutId:n.id,layout:"position",children:s(mi,{item:n,onFeatureClicked:t.onFeatureClicked,onToggleClicked:t.onToggleClicked,onEditClicked:t.onEditClicked,onPreviewClicked:t.onPreviewClicked,hideFeatureToggle:!1})},n.id))})}),t.featuredItems&&t.filteredItems.length>0&&t.featuredItems.totalCount<3&&s(Ve.div,{layout:"position",className:`flex flex-col justify-center items-center mb-4 border border-gray-200 bg-gray-50 rounded-lg h-${r}`,children:[s("p",{className:"text-md font-medium text-gray-600 tracking-tight",children:"Click on the star icon to feature a specific item"}),s("p",{className:"text-xs mt-2 leading-4 text-gray-400 font-medium tracking-wide uppercase",children:[3-t.featuredItems.totalCount," out of 3 remaining"]})]}),t.filteredDescription&&s("h2",{className:"text-lg leading-6 font-medium text-gray-900 mb-3 mt-6",children:t.filteredDescription}),!t.showLargeListItem&&t.filteredItems.length>0&&s("ul",{className:"space-y-3",children:t.filteredItems.map((n,i)=>{const a=t.showYear?jn(t.filteredItems,i,Ms):void 0;return s(U,{children:s(Ve.li,{layoutId:n.id,layout:"position",children:[a&&s("h2",{className:`text-lg leading-6 font-medium text-gray-900 mb-3 ${i===0?"mt-3":"mt-6"}`,children:a}),s(mi,{item:n,onFeatureClicked:t.onFeatureClicked,onToggleClicked:t.onToggleClicked,onEditClicked:t.onEditClicked,onPreviewClicked:t.onPreviewClicked,hideFeatureToggle:t.featuredItems?t.featuredItems.totalCount===t.maxFeaturedItems:!0})]},n.id)})})}),t.showLargeListItem&&t.filteredItems.length>0&&s("ul",{className:"flex flex-row flex-wrap pt-4",children:t.filteredItems.map((n,i)=>{const a=jn(t.filteredItems,i,Os);return s(U,{children:[a&&s("h2",{className:`w-full text-lg leading-6 font-medium text-gray-900 mb-3 mr-5 ${i===0?"mt-3":"mt-6"}`,children:s("span",{children:a})}),s(Ve.li,{className:"mt-0 mb-4 mr-4",layoutId:n.id,layout:"position",children:s(Xo,{onClick:()=>{Ko(ot,n),T.trackEvent({...la,eventAction:"Viewed",templateTitle:n.data.title})},item:n})},n.id)]})})}),t.filteredItems.length==0&&(!t.featuredItems||t.featuredItems.filtered.length===0)&&s(Ve.div,{layout:"position",className:"flex flex-col justify-center items-center mb-4 border border-gray-200 bg-gray-50 rounded-lg h-24 mt-3",children:s("p",{className:"text-md font-medium text-gray-600 tracking-tight",children:t.emptyMessage})})]})},Jo=({isOpen:t,onConfirm:e,onCancel:r})=>s(Gr,{isOpen:t,onClose:r,children:s("div",{className:"px-4 pt-5 pb-4 sm:max-w-lg sm:w-full sm:p-6",children:[s("div",{className:"sm:flex sm:items-start ",children:[s("div",{className:"mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10",children:s(Li,{className:"h-6 w-6 text-red-600","aria-hidden":"true"})}),s("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[s(Mt.Title,{as:"h3",className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Item"}),s("div",{className:"mt-2",children:[s("p",{className:"text-sm text-gray-500 leading-5 font-semibold",children:"Are you sure you want to delete this item?"}),s("p",{className:"text-sm text-gray-500 leading-5 font-normal",children:"If you proceed, this item will be removed from the list and will not be visible to anyone anymore."})]})]})]}),s("div",{className:"mt-5 sm:mt-4 sm:flex sm:flex-row-reverse",children:[s("button",{type:"button",className:"w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm",onClick:e,children:"Delete"}),s("button",{type:"button",className:"mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:w-auto sm:text-sm",onClick:r,children:"Cancel"})]})]})});function he(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function vn(t){return t[t.length-1]}function _e(t,...e){return e.forEach(r=>{t.includes(r)||t.push(r)}),t}function vr(t,e){return t?t.split(e):[]}function bn(t,e,r){const n=e===void 0||t>=e,i=r===void 0||t<=r;return n&&i}function Sa(t,e,r){return t<e?e:t>r?r:t}function Ye(t,e,r={},n=0,i=""){const a=Object.keys(r).reduce((o,c)=>{let d=r[c];return typeof d=="function"&&(d=d(n)),`${o} ${c}="${d}"`},t);i+=`<${a}></${t}>`;const l=n+1;return l<e?Ye(t,e,r,l,i):i}function wn(t){return t.replace(/>\s+/g,">").replace(/\s+</,"<")}function Ur(t){return new Date(t).setHours(0,0,0,0)}function Ie(){return new Date().setHours(0,0,0,0)}function we(...t){switch(t.length){case 0:return Ie();case 1:return Ur(t[0])}const e=new Date(0);return e.setFullYear(...t),e.setHours(0,0,0,0)}function Be(t,e){const r=new Date(t);return r.setDate(r.getDate()+e)}function Qo(t,e){return Be(t,e*7)}function Lt(t,e){const r=new Date(t),n=r.getMonth()+e;let i=n%12;i<0&&(i+=12);const a=r.setMonth(n);return r.getMonth()!==i?r.setDate(0):a}function ze(t,e){const r=new Date(t),n=r.getMonth(),i=r.setFullYear(r.getFullYear()+e);return n===1&&r.getMonth()===2?r.setDate(0):i}function gi(t,e){return(t-e+7)%7}function Vt(t,e,r=0){const n=new Date(t).getDay();return Be(t,gi(e,r)-gi(n,r))}function Zo(t){const e=Vt(t,4,1),r=Vt(new Date(e).setMonth(0,4),4,1);return Math.round((e-r)/6048e5)+1}function Ce(t,e){const r=new Date(t).getFullYear();return Math.floor(r/e)*e}const Br=/dd?|DD?|mm?|MM?|yy?(?:yy)?/,ec=/[\s!-/:-@[-`{-~年月日]+/;let br={};const pi={y(t,e){return new Date(t).setFullYear(parseInt(e,10))},m(t,e,r){const n=new Date(t);let i=parseInt(e,10)-1;if(isNaN(i)){if(!e)return NaN;const a=e.toLowerCase(),l=o=>o.toLowerCase().startsWith(a);if(i=r.monthsShort.findIndex(l),i<0&&(i=r.months.findIndex(l)),i<0)return NaN}return n.setMonth(i),n.getMonth()!==Ca(i)?n.setDate(0):n.getTime()},d(t,e){return new Date(t).setDate(parseInt(e,10))}},tc={d(t){return t.getDate()},dd(t){return St(t.getDate(),2)},D(t,e){return e.daysShort[t.getDay()]},DD(t,e){return e.days[t.getDay()]},m(t){return t.getMonth()+1},mm(t){return St(t.getMonth()+1,2)},M(t,e){return e.monthsShort[t.getMonth()]},MM(t,e){return e.months[t.getMonth()]},y(t){return t.getFullYear()},yy(t){return St(t.getFullYear(),2).slice(-2)},yyyy(t){return St(t.getFullYear(),4)}};function Ca(t){return t>-1?t%12:Ca(t+12)}function St(t,e){return t.toString().padStart(e,"0")}function Aa(t){if(typeof t!="string")throw new Error("Invalid date format.");if(t in br)return br[t];const e=t.split(Br),r=t.match(new RegExp(Br,"g"));if(e.length===0||!r)throw new Error("Invalid date format.");const n=r.map(a=>tc[a]),i=Object.keys(pi).reduce((a,l)=>(r.find(c=>c[0]!=="D"&&c[0].toLowerCase()===l)&&a.push(l),a),[]);return br[t]={parser(a,l){const o=a.split(ec).reduce((c,d,f)=>{if(d.length>0&&r[f]){const h=r[f][0];h==="M"?c.m=d:h!=="D"&&(c[h]=d)}return c},{});return i.reduce((c,d)=>{const f=pi[d](c,o[d],l);return isNaN(f)?c:f},Ie())},formatter(a,l){let o=n.reduce((c,d,f)=>c+=`${e[f]}${d(a,l)}`,"");return o+=vn(e)}}}function mt(t,e,r){if(t instanceof Date||typeof t=="number"){const n=Ur(t);return isNaN(n)?void 0:n}if(t){if(t==="today")return Ie();if(e&&e.toValue){const n=e.toValue(t,e,r);return isNaN(n)?void 0:Ur(n)}return Aa(e).parser(t,r)}}function gt(t,e,r){if(isNaN(t)||!t&&t!==0)return"";const n=typeof t=="number"?new Date(t):t;return e.toDisplay?e.toDisplay(n,e,r):Aa(e).formatter(n,r)}const Rt=new WeakMap,{addEventListener:rc,removeEventListener:nc}=EventTarget.prototype;function xn(t,e){let r=Rt.get(t);r||(r=[],Rt.set(t,r)),e.forEach(n=>{rc.call(...n),r.push(n)})}function Ta(t){let e=Rt.get(t);e&&(e.forEach(r=>{nc.call(...r)}),Rt.delete(t))}if(!Event.prototype.composedPath){const t=(e,r=[])=>{r.push(e);let n;return e.parentNode?n=e.parentNode:e.host?n=e.host:e.defaultView&&(n=e.defaultView),n?t(n,r):r};Event.prototype.composedPath=function(){return t(this.target)}}function Ma(t,e,r,n=0){const i=t[n];return e(i)?i:i===r||!i.parentElement?void 0:Ma(t,e,r,n+1)}function Oa(t,e){const r=typeof e=="function"?e:n=>n.matches(e);return Ma(t.composedPath(),r,t.currentTarget)}const Ze={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",titleFormat:"MM y"}},kn={autohide:!1,beforeShowDay:null,beforeShowDecade:null,beforeShowMonth:null,beforeShowYear:null,calendarWeeks:!1,clearBtn:!1,dateDelimiter:",",datesDisabled:[],daysOfWeekDisabled:[],daysOfWeekHighlighted:[],defaultViewDate:void 0,disableTouchKeyboard:!1,format:"mm/dd/yyyy",language:"en",maxDate:null,maxNumberOfDates:1,maxView:3,minDate:null,nextArrow:'<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>',orientation:"auto",pickLevel:0,prevArrow:'<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd"></path></svg>',showDaysOfWeek:!0,showOnClick:!0,showOnFocus:!0,startView:0,title:"",todayBtn:!1,todayBtnMode:0,todayHighlight:!1,updateOnBlur:!0,weekStart:0},ic=document.createRange();function me(t){return ic.createContextualFragment(t)}function ct(t){t.style.display!=="none"&&(t.style.display&&(t.dataset.styleDisplay=t.style.display),t.style.display="none")}function dt(t){t.style.display==="none"&&(t.dataset.styleDisplay?(t.style.display=t.dataset.styleDisplay,delete t.dataset.styleDisplay):t.style.display="")}function jt(t){t.firstChild&&(t.removeChild(t.firstChild),jt(t))}function ac(t,e){jt(t),e instanceof DocumentFragment?t.appendChild(e):typeof e=="string"?t.appendChild(me(e)):typeof e.forEach=="function"&&e.forEach(r=>{t.appendChild(r)})}const{language:wr,format:sc,weekStart:lc}=kn;function yi(t,e){return t.length<6&&e>=0&&e<7?_e(t,e):t}function vi(t){return(t+6)%7}function bi(t,e,r,n){const i=mt(t,e,r);return i!==void 0?i:n}function xr(t,e,r=3){const n=parseInt(t,10);return n>=0&&n<=r?n:e}function kr(t,e){const r=Object.assign({},t),n={},i=e.constructor.locales;let{format:a,language:l,locale:o,maxDate:c,maxView:d,minDate:f,pickLevel:h,startView:u,weekStart:y}=e.config||{};if(r.language){let b;if(r.language!==l&&(i[r.language]?b=r.language:(b=r.language.split("-")[0],i[b]===void 0&&(b=!1))),delete r.language,b){l=n.language=b;const L=o||i[wr];o=Object.assign({format:sc,weekStart:lc},i[wr]),l!==wr&&Object.assign(o,i[l]),n.locale=o,a===L.format&&(a=n.format=o.format),y===L.weekStart&&(y=n.weekStart=o.weekStart,n.weekEnd=vi(o.weekStart))}}if(r.format){const b=typeof r.format.toDisplay=="function",L=typeof r.format.toValue=="function",q=Br.test(r.format);(b&&L||q)&&(a=n.format=r.format),delete r.format}let g=f,p=c;if(r.minDate!==void 0&&(g=r.minDate===null?we(0,0,1):bi(r.minDate,a,o,g),delete r.minDate),r.maxDate!==void 0&&(p=r.maxDate===null?void 0:bi(r.maxDate,a,o,p),delete r.maxDate),p<g?(f=n.minDate=p,c=n.maxDate=g):(f!==g&&(f=n.minDate=g),c!==p&&(c=n.maxDate=p)),r.datesDisabled&&(n.datesDisabled=r.datesDisabled.reduce((b,L)=>{const q=mt(L,a,o);return q!==void 0?_e(b,q):b},[]),delete r.datesDisabled),r.defaultViewDate!==void 0){const b=mt(r.defaultViewDate,a,o);b!==void 0&&(n.defaultViewDate=b),delete r.defaultViewDate}if(r.weekStart!==void 0){const b=Number(r.weekStart)%7;isNaN(b)||(y=n.weekStart=b,n.weekEnd=vi(b)),delete r.weekStart}if(r.daysOfWeekDisabled&&(n.daysOfWeekDisabled=r.daysOfWeekDisabled.reduce(yi,[]),delete r.daysOfWeekDisabled),r.daysOfWeekHighlighted&&(n.daysOfWeekHighlighted=r.daysOfWeekHighlighted.reduce(yi,[]),delete r.daysOfWeekHighlighted),r.maxNumberOfDates!==void 0){const b=parseInt(r.maxNumberOfDates,10);b>=0&&(n.maxNumberOfDates=b,n.multidate=b!==1),delete r.maxNumberOfDates}r.dateDelimiter&&(n.dateDelimiter=String(r.dateDelimiter),delete r.dateDelimiter);let D=h;r.pickLevel!==void 0&&(D=xr(r.pickLevel,2),delete r.pickLevel),D!==h&&(h=n.pickLevel=D);let E=d;r.maxView!==void 0&&(E=xr(r.maxView,d),delete r.maxView),E=h>E?h:E,E!==d&&(d=n.maxView=E);let F=u;if(r.startView!==void 0&&(F=xr(r.startView,F),delete r.startView),F<h?F=h:F>d&&(F=d),F!==u&&(n.startView=F),r.prevArrow){const b=me(r.prevArrow);b.childNodes.length>0&&(n.prevArrow=b.childNodes),delete r.prevArrow}if(r.nextArrow){const b=me(r.nextArrow);b.childNodes.length>0&&(n.nextArrow=b.childNodes),delete r.nextArrow}if(r.disableTouchKeyboard!==void 0&&(n.disableTouchKeyboard="ontouchstart"in document&&!!r.disableTouchKeyboard,delete r.disableTouchKeyboard),r.orientation){const b=r.orientation.toLowerCase().split(/\s+/g);n.orientation={x:b.find(L=>L==="left"||L==="right")||"auto",y:b.find(L=>L==="top"||L==="bottom")||"auto"},delete r.orientation}if(r.todayBtnMode!==void 0){switch(r.todayBtnMode){case 0:case 1:n.todayBtnMode=r.todayBtnMode}delete r.todayBtnMode}return Object.keys(r).forEach(b=>{r[b]!==void 0&&he(kn,b)&&(n[b]=r[b])}),n}const oc=wn(`<div class="datepicker hidden">
|
|
11
|
+
`+(l!==a?`result of cast: ${l}`:""))}return i}_cast(e,r){let n=e===void 0?e:this.transforms.reduce((i,a)=>a.call(this,i,e,this),e);return n===void 0&&(n=this.getDefault()),n}_validate(e,r={},n){let{sync:i,path:a,from:l=[],originalValue:o=e,strict:c=this.spec.strict,abortEarly:d=this.spec.abortEarly}=r,f=e;c||(f=this._cast(f,ee({assert:!1},r)));let h={value:f,path:a,options:r,originalValue:o,schema:this,label:this.spec.label,sync:i,from:l},u=[];this._typeError&&u.push(this._typeError);let y=[];this._whitelistError&&y.push(this._whitelistError),this._blacklistError&&y.push(this._blacklistError),Rr({args:h,value:f,path:a,sync:i,tests:u,endEarly:d},g=>{if(g)return void n(g,f);Rr({tests:this.tests.concat(y),args:h,path:a,sync:i,value:f,endEarly:d},n)})}validate(e,r,n){let i=this.resolve(ee({},r,{value:e}));return typeof n=="function"?i._validate(e,r,n):new Promise((a,l)=>i._validate(e,r,(o,c)=>{o?l(o):a(c)}))}validateSync(e,r){let n=this.resolve(ee({},r,{value:e})),i;return n._validate(e,ee({},r,{sync:!0}),(a,l)=>{if(a)throw a;i=l}),i}isValid(e,r){return this.validate(e,r).then(()=>!0,n=>{if(J.isError(n))return!1;throw n})}isValidSync(e,r){try{return this.validateSync(e,r),!0}catch(n){if(J.isError(n))return!1;throw n}}_getDefault(){let e=this.spec.default;return e==null?e:typeof e=="function"?e.call(this):Pr(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){let r=this.clone();return r.spec.strict=e,r}_isPresent(e){return e!=null}defined(e=Se.defined){return this.test({message:e,name:"defined",exclusive:!0,test(r){return r!==void 0}})}required(e=Se.required){return this.clone({presence:"required"}).withMutation(r=>r.test({message:e,name:"required",exclusive:!0,test(n){return this.schema._isPresent(n)}}))}notRequired(){let e=this.clone({presence:"optional"});return e.tests=e.tests.filter(r=>r.OPTIONS.name!=="required"),e}nullable(e=!0){return this.clone({nullable:e!==!1})}transform(e){let r=this.clone();return r.transforms.push(e),r}test(...e){let r;if(e.length===1?typeof e[0]=="function"?r={test:e[0]}:r=e[0]:e.length===2?r={name:e[0],test:e[1]}:r={name:e[0],message:e[1],test:e[2]},r.message===void 0&&(r.message=Se.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),i=Ft(r),a=r.exclusive||r.name&&n.exclusiveTests[r.name]===!0;if(r.exclusive&&!r.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return r.name&&(n.exclusiveTests[r.name]=!!r.exclusive),n.tests=n.tests.filter(l=>!(l.OPTIONS.name===r.name&&(a||l.OPTIONS.test===i.OPTIONS.test))),n.tests.push(i),n}when(e,r){!Array.isArray(e)&&typeof e!="string"&&(r=e,e=".");let n=this.clone(),i=da(e).map(a=>new be(a));return i.forEach(a=>{a.isSibling&&n.deps.push(a.key)}),n.conditions.push(new fo(i,r)),n}typeError(e){let r=this.clone();return r._typeError=Ft({message:e,name:"typeError",test(n){return n!==void 0&&!this.schema.isType(n)?this.createError({params:{type:this.schema._type}}):!0}}),r}oneOf(e,r=Se.oneOf){let n=this.clone();return e.forEach(i=>{n._whitelist.add(i),n._blacklist.delete(i)}),n._whitelistError=Ft({message:r,name:"oneOf",test(i){if(i===void 0)return!0;let a=this.schema._whitelist,l=a.resolveAll(this.resolve);return l.includes(i)?!0:this.createError({params:{values:a.toArray().join(", "),resolved:l}})}}),n}notOneOf(e,r=Se.notOneOf){let n=this.clone();return e.forEach(i=>{n._blacklist.add(i),n._whitelist.delete(i)}),n._blacklistError=Ft({message:r,name:"notOneOf",test(i){let a=this.schema._blacklist,l=a.resolveAll(this.resolve);return l.includes(i)?this.createError({params:{values:a.toArray().join(", "),resolved:l}}):!0}}),n}strip(e=!0){let r=this.clone();return r.spec.strip=e,r}describe(){const e=this.clone(),{label:r,meta:n}=e.spec;return{meta:n,label:r,type:e.type,oneOf:e._whitelist.describe(),notOneOf:e._blacklist.describe(),tests:e.tests.map(a=>({name:a.OPTIONS.name,params:a.OPTIONS.params})).filter((a,l,o)=>o.findIndex(c=>c.name===a.name)===l)}}}K.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])K.prototype[`${t}At`]=function(e,r,n={}){const{parent:i,parentPath:a,schema:l}=Fo(this,e,r,n.context);return l[t](i&&i[a],ee({},n,{parent:i,path:e}))};for(const t of["equals","is"])K.prototype[t]=K.prototype.oneOf;for(const t of["not","nope"])K.prototype[t]=K.prototype.notOneOf;K.prototype.optional=K.prototype.notRequired;const fa=K;function rt(){return new fa}rt.prototype=fa.prototype;const G=t=>t==null;function ha(){return new ma}class ma extends K{constructor(){super({type:"boolean"}),this.withMutation(()=>{this.transform(function(e){if(!this.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}_typeCheck(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}isTrue(e=$r.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return G(r)||r===!0}})}isFalse(e=$r.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return G(r)||r===!1}})}}ha.prototype=ma.prototype;let No=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,So=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Co=/^(?:[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,Ao=t=>G(t)||t===t.trim(),To={}.toString();function re(){return new ga}class ga extends K{constructor(){super({type:"string"}),this.withMutation(()=>{this.transform(function(e){if(this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===To?e:r})})}_typeCheck(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}_isPresent(e){return super._isPresent(e)&&!!e.length}length(e,r=te.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:e},test(n){return G(n)||n.length===this.resolve(e)}})}min(e,r=te.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:e},test(n){return G(n)||n.length>=this.resolve(e)}})}max(e,r=te.max){return this.test({name:"max",exclusive:!0,message:r,params:{max:e},test(n){return G(n)||n.length<=this.resolve(e)}})}matches(e,r){let n=!1,i,a;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:i,name:a}=r:i=r),this.test({name:a||"matches",message:i||te.matches,params:{regex:e},test:l=>G(l)||l===""&&n||l.search(e)!==-1})}email(e=te.email){return this.matches(No,{name:"email",message:e,excludeEmptyString:!0})}url(e=te.url){return this.matches(So,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=te.uuid){return this.matches(Co,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=te.trim){return this.transform(r=>r!=null?r.trim():r).test({message:e,name:"trim",test:Ao})}lowercase(e=te.lowercase){return this.transform(r=>G(r)?r:r.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,test:r=>G(r)||r===r.toLowerCase()})}uppercase(e=te.uppercase){return this.transform(r=>G(r)?r:r.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,test:r=>G(r)||r===r.toUpperCase()})}}re.prototype=ga.prototype;var Mo=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function Oo(t){var e=[1,4,5,6,7,10,11],r=0,n,i;if(i=Mo.exec(t)){for(var a=0,l;l=e[a];++a)i[l]=+i[l]||0;i[2]=(+i[2]||1)-1,i[3]=+i[3]||1,i[7]=i[7]?String(i[7]).substr(0,3):0,(i[8]===void 0||i[8]==="")&&(i[9]===void 0||i[9]==="")?n=+new Date(i[1],i[2],i[3],i[4],i[5],i[6],i[7]):(i[8]!=="Z"&&i[9]!==void 0&&(r=i[10]*60+i[11],i[9]==="+"&&(r=0-r)),n=Date.UTC(i[1],i[2],i[3],i[4],i[5]+r,i[6],i[7]))}else n=Date.parse?Date.parse(t):NaN;return n}let pa=new Date(""),_o=t=>Object.prototype.toString.call(t)==="[object Date]";class ya extends K{constructor(){super({type:"date"}),this.withMutation(()=>{this.transform(function(e){return this.isType(e)?e:(e=Oo(e),isNaN(e)?pa:new Date(e))})})}_typeCheck(e){return _o(e)&&!isNaN(e.getTime())}prepareParam(e,r){let n;if(be.isRef(e))n=e;else{let i=this.cast(e);if(!this._typeCheck(i))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=i}return n}min(e,r=Ir.min){let n=this.prepareParam(e,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:e},test(i){return G(i)||i>=this.resolve(n)}})}max(e,r=Ir.max){let n=this.prepareParam(e,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:e},test(i){return G(i)||i<=this.resolve(n)}})}}ya.INVALID_DATE=pa;ya.prototype;var hn={exports:{}};hn.exports=function(t){return va(Po(t),t)};hn.exports.array=va;function va(t,e){var r=t.length,n=new Array(r),i={},a=r,l=Io(e),o=$o(t);for(e.forEach(function(d){if(!o.has(d[0])||!o.has(d[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});a--;)i[a]||c(t[a],a,new Set);return n;function c(d,f,h){if(h.has(d)){var u;try{u=", node was:"+JSON.stringify(d)}catch{u=""}throw new Error("Cyclic dependency"+u)}if(!o.has(d))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(d));if(!i[f]){i[f]=!0;var y=l.get(d)||new Set;if(y=Array.from(y),f=y.length){h.add(d);do{var g=y[--f];c(g,o.get(g),h)}while(f);h.delete(d)}n[--r]=d}}}function Po(t){for(var e=new Set,r=0,n=t.length;r<n;r++){var i=t[r];e.add(i[0]),e.add(i[1])}return Array.from(e)}function Io(t){for(var e=new Map,r=0,n=t.length;r<n;r++){var i=t[r];e.has(i[0])||e.set(i[0],new Set),e.has(i[1])||e.set(i[1],new Set),e.get(i[0]).add(i[1])}return e}function $o(t){for(var e=new Map,r=0,n=t.length;r<n;r++)e.set(t[r],r);return e}var Lo=hn.exports;const Vo=Xr(Lo);function Ro(t,e=[]){let r=[],n=new Set,i=new Set(e.map(([l,o])=>`${l}-${o}`));function a(l,o){let c=nr.split(l)[0];n.add(c),i.has(`${o}-${c}`)||r.push([o,c])}for(const l in t)if(_t(t,l)){let o=t[l];n.add(l),be.isRef(o)&&o.isSibling?a(o.path,l):ca(o)&&"deps"in o&&o.deps.forEach(c=>a(c,l))}return Vo.array(Array.from(n),r).reverse()}function oi(t,e){let r=1/0;return t.some((n,i)=>{var a;if(((a=e.path)==null?void 0:a.indexOf(n))!==-1)return r=i,!0}),r}function ba(t){return(e,r)=>oi(t,e)-oi(t,r)}function Be(){return Be=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Be.apply(this,arguments)}let ci=t=>Object.prototype.toString.call(t)==="[object Object]";function jo(t,e){let r=Object.keys(t.fields);return Object.keys(e).filter(n=>r.indexOf(n)===-1)}const Bo=ba([]);class wa extends K{constructor(e){super({type:"object"}),this.fields=Object.create(null),this._sortErrors=Bo,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{this.transform(function(n){if(typeof n=="string")try{n=JSON.parse(n)}catch{n=null}return this.isType(n)?n:null}),e&&this.shape(e)})}_typeCheck(e){return ci(e)||typeof e=="function"}_cast(e,r={}){var n;let i=super._cast(e,r);if(i===void 0)return this.getDefault();if(!this._typeCheck(i))return i;let a=this.fields,l=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,o=this._nodes.concat(Object.keys(i).filter(h=>this._nodes.indexOf(h)===-1)),c={},d=Be({},r,{parent:c,__validating:r.__validating||!1}),f=!1;for(const h of o){let u=a[h],y=_t(i,h);if(u){let g,p=i[h];d.path=(r.path?`${r.path}.`:"")+h,u=u.resolve({value:p,context:r.context,parent:c});let D="spec"in u?u.spec:void 0,E=D==null?void 0:D.strict;if(D!=null&&D.strip){f=f||h in i;continue}g=!r.__validating||!E?u.cast(i[h],d):i[h],g!==void 0&&(c[h]=g)}else y&&!l&&(c[h]=i[h]);c[h]!==i[h]&&(f=!0)}return f?c:i}_validate(e,r={},n){let i=[],{sync:a,from:l=[],originalValue:o=e,abortEarly:c=this.spec.abortEarly,recursive:d=this.spec.recursive}=r;l=[{schema:this,value:o},...l],r.__validating=!0,r.originalValue=o,r.from=l,super._validate(e,r,(f,h)=>{if(f){if(!J.isError(f)||c)return void n(f,h);i.push(f)}if(!d||!ci(h)){n(i[0]||null,h);return}o=o||h;let u=this._nodes.map(y=>(g,p)=>{let D=y.indexOf(".")===-1?(r.path?`${r.path}.`:"")+y:`${r.path||""}["${y}"]`,E=this.fields[y];if(E&&"validate"in E){E.validate(h[y],Be({},r,{path:D,from:l,strict:!0,parent:h,originalValue:o[y]}),p);return}p(null)});Rr({sync:a,tests:u,value:h,errors:i,endEarly:c,sort:this._sortErrors,path:r.path},n)})}clone(e){const r=super.clone(e);return r.fields=Be({},this.fields),r._nodes=this._nodes,r._excludedEdges=this._excludedEdges,r._sortErrors=this._sortErrors,r}concat(e){let r=super.concat(e),n=r.fields;for(let[i,a]of Object.entries(this.fields)){const l=n[i];l===void 0?n[i]=a:l instanceof K&&a instanceof K&&(n[i]=a.concat(l))}return r.withMutation(()=>r.shape(n,this._excludedEdges))}getDefaultFromShape(){let e={};return this._nodes.forEach(r=>{const n=this.fields[r];e[r]="default"in n?n.getDefault():void 0}),e}_getDefault(){if("default"in this.spec)return super._getDefault();if(this._nodes.length)return this.getDefaultFromShape()}shape(e,r=[]){let n=this.clone(),i=Object.assign(n.fields,e);return n.fields=i,n._sortErrors=ba(Object.keys(i)),r.length&&(Array.isArray(r[0])||(r=[r]),n._excludedEdges=[...n._excludedEdges,...r]),n._nodes=Ro(i,n._excludedEdges),n}pick(e){const r={};for(const n of e)this.fields[n]&&(r[n]=this.fields[n]);return this.clone().withMutation(n=>(n.fields={},n.shape(r)))}omit(e){const r=this.clone(),n=r.fields;r.fields={};for(const i of e)delete n[i];return r.withMutation(()=>r.shape(n))}from(e,r,n){let i=nr.getter(e,!0);return this.transform(a=>{if(a==null)return a;let l=a;return _t(a,e)&&(l=Be({},a),n||delete l[e],l[r]=i(a)),l})}noUnknown(e=!0,r=Lr.noUnknown){typeof e=="string"&&(r=e,e=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(i){if(i==null)return!0;const a=jo(this.schema,i);return!e||a.length===0||this.createError({params:{unknown:a.join(", ")}})}});return n.spec.noUnknown=e,n}unknown(e=!0,r=Lr.noUnknown){return this.noUnknown(!e,r)}transformKeys(e){return this.transform(r=>r&&Rs(r,(n,i)=>e(i)))}camelCase(){return this.transformKeys(js)}snakeCase(){return this.transformKeys(Bn)}constantCase(){return this.transformKeys(e=>Bn(e).toUpperCase())}describe(){let e=super.describe();return e.fields=Ji(this.fields,r=>r.describe()),e}}function xa(t){return new wa(t)}xa.prototype=wa.prototype;const Uo=/^(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,mn=xa().shape({type:rt().default("customPerk").required(),title:re().default("").required("Field is required").max(30,"Maximum 30 characters"),subtitle:re().default("").required("Field is required").max(60,"Maximum 60 characters"),category:re().default("").required("Category is required").oneOf([...qi],"Category is required"),startDate:re().when("type",(t,e)=>t==="customEvent"?e.default("").required("Start date is missing").test("past-start-date","Start date cannot be in the past",r=>{if(!r)return!1;const n=Pn(new Date),i=kt(r,"dd/MM/yyyy",new Date);return!fr(i,n)}):e.optional()),endDate:re().when("type",(t,e)=>t==="customEvent"?e.default("").required("End date is missing").test("past-end-date","End date cannot be in the past",r=>{if(!r)return!1;const n=Pn(new Date),i=kt(r,"dd/MM/yyyy",new Date);return!fr(i,n)}).when("startDate",(r,n)=>r?n.test("end-before-start-date","End date cannot be before start date",i=>{if(!i)return!1;const a=kt(i,"dd/MM/yyyy",new Date),l=kt(i,"dd/MM/yyyy",new Date);return!fr(a,l)}):n):e.optional()),startTime:re().optional(),location:re().max(30,"Maximum 30 characters").optional(),description:re().default("").required("Field is required").max(1e3,"Maximum 1000 characters"),link:re().transform(function(t,e){if(this.isType(t)&&t){const r=t;return r.startsWith("https://")?r.substr(8):r}else return t}).matches(Uo,{excludeEmptyString:!0,message:"Provide a valid URL"}).when("linkLabel",(t,e)=>t&&t.length>0?e.required("URL is missing"):e.optional()),linkLabel:re().when("link",(t,e)=>t&&t.length>0?e.required("Button label is missing"):e.optional()),attachment:rt().default(()=>j).required(),coverPhoto:rt().default(()=>j).required(),icon:rt().default(()=>j).required(),enableAfterSave:ha().default(!0).required()},[["link","linkLabel"]]),zo=mn.getDefault(),ka=t=>{var i;const e=t.data.dateRange?In(Un(t.data.dateRange.start),t.data.dateRange.allDay):void 0,r=t.data.dateRange?In(Un(t.data.dateRange.end),t.data.dateRange.allDay):void 0,n=(i=t.data.url)==null?void 0:i.replace("https://","");return mn.cast({title:t.data.title,category:t.data.category,subtitle:t.data.subtitle,description:t.data.description??"",link:n,linkLabel:t.data.linkLabel??"",startDate:(e==null?void 0:e.date)??"",endDate:(r==null?void 0:r.date)??"",location:t.data.location??"",startTime:(e==null?void 0:e.time)??"",attachment:Ri.pipe(Te(t.data.attachments),ms(a=>a.length>0?a[0]:null)),icon:Te(t.data.icon),coverPhoto:Te(t.data.backdrop),enableAfterSave:t.visibility.isEnabled})},di=t=>{const e=t.startDate&&t.endDate?{start:$n(t.startDate,t.startTime),end:$n(t.endDate,t.startTime),allDay:!t.startTime}:void 0;return{title:t.title,category:t.category,subtitle:t.subtitle,dateRange:e,description:t.description,url:t.link?`https://${t.link}`:void 0,linkLabel:t.linkLabel,location:t.location,attachments:Ri.pipe(t.attachment,gs(()=>[],r=>[r])),icon:_n(t.icon),backdrop:_n(t.coverPhoto),isDeleted:!1}},Ea=(t,e)=>{t.update(r=>{r.selectedItem=ke(e.id),r.editDialog={screen:"form",editMode:"edit",initialValues:ke(ka(e))}})},Wo=(t,e)=>{t.update(r=>{r.editDialog={screen:"form",editMode:"add",initialValues:ke(ka(e))}})},Da=t=>{t.update(e=>{e.editDialog={screen:"form",editMode:"add",initialValues:j}})},Yo=t=>{t.update(e=>{e.editDialog=ue.match([e.editDialog,e.selectedItem]).with([{screen:"preview"},ue.when(xe)],([r,n])=>({screen:"form",editMode:"edit",initialValues:ke(r.formData),selectedItem:e.selectedItem})).with([{screen:"preview"},ue.when(Hr)],([r,n])=>({screen:"form",editMode:"add",initialValues:ke(r.formData),selectedItem:j})).with([{screen:"form"},ue.__],()=>({screen:"hidden"})).with([{screen:"readonly-preview"},ue.__],()=>({screen:"hidden"})).with([{screen:"template-preview"},ue.__],()=>({screen:"hidden"})).with(ue.__,()=>{throw Error("Unreachable state")}).exhaustive()})},Ho=t=>{t.getValue().editDialog.screen==="form"&&t.update(e=>{e.editDialog={screen:"hidden"},e.selectedItem=j})},Ko=(t,e)=>{t.update(r=>{r.editDialog={screen:"preview",formData:e}})},Fa=(t,e)=>{t.update(r=>{r.editDialog={screen:"readonly-preview",itemData:e}})},qo=(t,e)=>{t.update(r=>{r.editDialog={screen:"template-preview",templateData:e}})},Go=async(t,e,r)=>{const n=yt(e);t.update(i=>{i.editDialog={screen:"hidden"},i.selectedItem=j}),await r(n),t.remove(n)},Xo=async(t,e,r,n,i,a)=>{const l=e;Hr(l)?await Ee(n(r,void 0,a),600):await Ee(n(r,l.value,a),600),t.update(o=>{o.editDialog={screen:"hidden"},o.selectedItem=j}),i()},Jo=t=>{var e;return s("div",{onClick:t.onClick,className:"flex flex-col cursor-pointer",children:[s("div",{className:"w-96 h-40",children:s("img",{className:"rounded-t-lg h-40 w-full object-cover",src:((e=t.item.data.backdrop)==null?void 0:e.downloadUrl)??Ts})}),s("div",{className:"w-96 h-40 rounded-b-lg shadow-lg p-4 flex flex-col",children:[s("h3",{className:"text-lg leading-6 font-bold text-gray-900 truncate pb-2",children:t.item.data.title}),s("p",{className:"text-sm leading-5 font-normal text-gray-500 truncate pb-1",children:t.item.data.dateRange?Gi(t.item.data.dateRange.start,t.item.data.dateRange.end,t.item.data.dateRange.allDay):""}),s("p",{className:"text-sm leading-5 font-normal text-gray-500 break-words pb-1",children:t.item.data.subtitle}),s("div",{className:"block",children:s(zt,{name:t.item.data.category})})]})]})},ui=t=>{var i,a;const e=t.item.visibility.isFeatured,r=t.item.visibility.isEnabled,n=t.item.type==="customEvent"||t.item.type==="eventTemplate";return s("div",{className:$("px-4 py-2 sm:px-6 flex flex-row overflow-hidden rounded-md hover:bg-gray-50 cursor-pointer border shadow border-gray-100"),onClick:()=>{t.onPreviewClicked!==void 0&&t.onPreviewClicked(t.item)},children:[t.onFeatureClicked&&s("div",{className:$("flex items-center justify-start hover:text-yellow-500 cursor-pointer",e?"text-yellow-500":"text-gray-300",(r||e)&&!t.hideFeatureToggle?"visible":"invisible"),onClick:l=>{var o;l.stopPropagation(),(o=t.onFeatureClicked)==null||o.call(t,t.item)},children:s($i,{className:"mr-1.5 h-6 w-6","aria-hidden":"true"})}),s("div",{className:"flex items-center justify-start flex-shrink-0 px-4",children:n?s("img",{className:"inline-block object-contain h-16 w-16 rounded-md",src:((i=t.item.data.backdrop)==null?void 0:i.downloadUrl)??"https://via.placeholder.com/500",alt:""}):s("img",{className:"inline-block object-contain h-16 w-16 rounded-md",src:((a=t.item.data.icon)==null?void 0:a.downloadUrl)??"https://via.placeholder.com/500",alt:""})}),s("div",{className:"flex flex-grow flex-col",children:[s("p",{className:"text-lg leading-6 font-medium text-gray-900 truncate",children:t.item.data.title}),s("p",{className:"relative text-sm leading-5 font-normal text-gray-500 truncate flex-grow pb-1",children:[n&&t.item.data.dateRange?Gi(t.item.data.dateRange.start,t.item.data.dateRange.end,t.item.data.dateRange.allDay):t.item.data.subtitle,n&&t.item.data.location&&s(B,{children:[s("span",{className:"pipe mx-3"}),s("span",{children:t.item.data.location})]})]}),s("div",{className:"flex-shrink-0 flex",children:s(zt,{name:t.item.data.category,size:"xs"})})]}),(t.item.type==="customPerk"||t.item.type==="customEvent")&&s("div",{className:"flex self-center mr-8",children:s("button",{type:"button",className:"inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",onClick:l=>{l.stopPropagation(),t.onEditClicked!==void 0&&t.onEditClicked(t.item)},children:[s(ps,{className:"mr-1.5 h-3 w-3","aria-hidden":"true"}),"Edit"]})}),t.onToggleClicked&&s("div",{className:"flex self-center",onClick:l=>{l.stopPropagation()},children:s(nt,{checked:t.item.visibility.isEnabled,onChange:()=>{var l;(l=t.onToggleClicked)==null||l.call(t,t.item)},className:$(t.item.visibility.isEnabled?"bg-primary":"bg-gray-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"),children:[s("span",{className:"sr-only",children:"Use setting"}),s("span",{"aria-hidden":"true",className:$(t.item.visibility.isEnabled?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200")})]})})]})},Na=t=>{const r=72-24*(t.featuredItems?t.featuredItems.totalCount:0);return s(B,{children:[t.featuredItems&&t.featuredDescription&&s("h2",{className:"text-lg leading-6 font-medium text-gray-900 mb-3 mt-3",children:t.featuredDescription}),t.featuredItems&&t.featuredItems.filtered.length>0&&s("div",{className:"mb-4",children:s("ul",{className:"space-y-3",children:t.featuredItems.filtered.map(n=>s(Ve.li,{layoutId:n.id,layout:"position",children:s(ui,{item:n,onFeatureClicked:t.onFeatureClicked,onToggleClicked:t.onToggleClicked,onEditClicked:t.onEditClicked,onPreviewClicked:t.onPreviewClicked,hideFeatureToggle:!1})},n.id))})}),t.featuredItems&&t.filteredItems.length>0&&t.featuredItems.totalCount<3&&s(Ve.div,{layout:"position",className:`flex flex-col justify-center items-center mb-4 border border-gray-200 bg-gray-50 rounded-lg h-${r}`,children:[s("p",{className:"text-md font-medium text-gray-600 tracking-tight",children:"Click on the star icon to feature a specific item"}),s("p",{className:"text-xs mt-2 leading-4 text-gray-400 font-medium tracking-wide uppercase",children:[3-t.featuredItems.totalCount," out of 3 remaining"]})]}),t.filteredDescription&&s("h2",{className:"text-lg leading-6 font-medium text-gray-900 mb-3 mt-6",children:t.filteredDescription}),!t.showLargeListItem&&t.filteredItems.length>0&&s("ul",{className:"space-y-3",children:t.filteredItems.map((n,i)=>{const a=t.showYear?Ln(t.filteredItems,i,Ms):void 0;return s(B,{children:s(Ve.li,{layoutId:n.id,layout:"position",children:[a&&s("h2",{className:`text-lg leading-6 font-medium text-gray-900 mb-3 ${i===0?"mt-3":"mt-6"}`,children:a}),s(ui,{item:n,onFeatureClicked:t.onFeatureClicked,onToggleClicked:t.onToggleClicked,onEditClicked:t.onEditClicked,onPreviewClicked:t.onPreviewClicked,hideFeatureToggle:t.featuredItems?t.featuredItems.totalCount===t.maxFeaturedItems:!0})]},n.id)})})}),t.showLargeListItem&&t.filteredItems.length>0&&s("ul",{className:"flex flex-row flex-wrap pt-4",children:t.filteredItems.map((n,i)=>{const a=Ln(t.filteredItems,i,Os);return s(B,{children:[a&&s("h2",{className:`w-full text-lg leading-6 font-medium text-gray-900 mb-3 mr-5 ${i===0?"mt-3":"mt-6"}`,children:s("span",{children:a})}),s(Ve.li,{className:"mt-0 mb-4 mr-4",layoutId:n.id,layout:"position",children:s(Jo,{onClick:()=>{qo(ot,n),T.trackEvent({...la,eventAction:"Viewed",templateTitle:n.data.title})},item:n})},n.id)]})})}),t.filteredItems.length==0&&(!t.featuredItems||t.featuredItems.filtered.length===0)&&s(Ve.div,{layout:"position",className:"flex flex-col justify-center items-center mb-4 border border-gray-200 bg-gray-50 rounded-lg h-24 mt-3",children:s("p",{className:"text-md font-medium text-gray-600 tracking-tight",children:t.emptyMessage})})]})},Qo=({isOpen:t,onConfirm:e,onCancel:r})=>s(qr,{isOpen:t,onClose:r,children:s("div",{className:"px-4 pt-5 pb-4 sm:max-w-lg sm:w-full sm:p-6",children:[s("div",{className:"sm:flex sm:items-start ",children:[s("div",{className:"mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10",children:s(Ii,{className:"h-6 w-6 text-red-600","aria-hidden":"true"})}),s("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[s(Mt.Title,{as:"h3",className:"text-lg leading-6 font-medium text-gray-900",children:"Delete Item"}),s("div",{className:"mt-2",children:[s("p",{className:"text-sm text-gray-500 leading-5 font-semibold",children:"Are you sure you want to delete this item?"}),s("p",{className:"text-sm text-gray-500 leading-5 font-normal",children:"If you proceed, this item will be removed from the list and will not be visible to anyone anymore."})]})]})]}),s("div",{className:"mt-5 sm:mt-4 sm:flex sm:flex-row-reverse",children:[s("button",{type:"button",className:"w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm",onClick:e,children:"Delete"}),s("button",{type:"button",className:"mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:w-auto sm:text-sm",onClick:r,children:"Cancel"})]})]})});function he(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function gn(t){return t[t.length-1]}function _e(t,...e){return e.forEach(r=>{t.includes(r)||t.push(r)}),t}function vr(t,e){return t?t.split(e):[]}function pn(t,e,r){const n=e===void 0||t>=e,i=r===void 0||t<=r;return n&&i}function Sa(t,e,r){return t<e?e:t>r?r:t}function He(t,e,r={},n=0,i=""){const a=Object.keys(r).reduce((o,c)=>{let d=r[c];return typeof d=="function"&&(d=d(n)),`${o} ${c}="${d}"`},t);i+=`<${a}></${t}>`;const l=n+1;return l<e?He(t,e,r,l,i):i}function yn(t){return t.replace(/>\s+/g,">").replace(/\s+</,"<")}function Br(t){return new Date(t).setHours(0,0,0,0)}function Ie(){return new Date().setHours(0,0,0,0)}function we(...t){switch(t.length){case 0:return Ie();case 1:return Br(t[0])}const e=new Date(0);return e.setFullYear(...t),e.setHours(0,0,0,0)}function Ue(t,e){const r=new Date(t);return r.setDate(r.getDate()+e)}function Zo(t,e){return Ue(t,e*7)}function Lt(t,e){const r=new Date(t),n=r.getMonth()+e;let i=n%12;i<0&&(i+=12);const a=r.setMonth(n);return r.getMonth()!==i?r.setDate(0):a}function ze(t,e){const r=new Date(t),n=r.getMonth(),i=r.setFullYear(r.getFullYear()+e);return n===1&&r.getMonth()===2?r.setDate(0):i}function fi(t,e){return(t-e+7)%7}function Vt(t,e,r=0){const n=new Date(t).getDay();return Ue(t,fi(e,r)-fi(n,r))}function ec(t){const e=Vt(t,4,1),r=Vt(new Date(e).setMonth(0,4),4,1);return Math.round((e-r)/6048e5)+1}function Ce(t,e){const r=new Date(t).getFullYear();return Math.floor(r/e)*e}const Ur=/dd?|DD?|mm?|MM?|yy?(?:yy)?/,tc=/[\s!-/:-@[-`{-~年月日]+/;let br={};const hi={y(t,e){return new Date(t).setFullYear(parseInt(e,10))},m(t,e,r){const n=new Date(t);let i=parseInt(e,10)-1;if(isNaN(i)){if(!e)return NaN;const a=e.toLowerCase(),l=o=>o.toLowerCase().startsWith(a);if(i=r.monthsShort.findIndex(l),i<0&&(i=r.months.findIndex(l)),i<0)return NaN}return n.setMonth(i),n.getMonth()!==Ca(i)?n.setDate(0):n.getTime()},d(t,e){return new Date(t).setDate(parseInt(e,10))}},rc={d(t){return t.getDate()},dd(t){return Nt(t.getDate(),2)},D(t,e){return e.daysShort[t.getDay()]},DD(t,e){return e.days[t.getDay()]},m(t){return t.getMonth()+1},mm(t){return Nt(t.getMonth()+1,2)},M(t,e){return e.monthsShort[t.getMonth()]},MM(t,e){return e.months[t.getMonth()]},y(t){return t.getFullYear()},yy(t){return Nt(t.getFullYear(),2).slice(-2)},yyyy(t){return Nt(t.getFullYear(),4)}};function Ca(t){return t>-1?t%12:Ca(t+12)}function Nt(t,e){return t.toString().padStart(e,"0")}function Aa(t){if(typeof t!="string")throw new Error("Invalid date format.");if(t in br)return br[t];const e=t.split(Ur),r=t.match(new RegExp(Ur,"g"));if(e.length===0||!r)throw new Error("Invalid date format.");const n=r.map(a=>rc[a]),i=Object.keys(hi).reduce((a,l)=>(r.find(c=>c[0]!=="D"&&c[0].toLowerCase()===l)&&a.push(l),a),[]);return br[t]={parser(a,l){const o=a.split(tc).reduce((c,d,f)=>{if(d.length>0&&r[f]){const h=r[f][0];h==="M"?c.m=d:h!=="D"&&(c[h]=d)}return c},{});return i.reduce((c,d)=>{const f=hi[d](c,o[d],l);return isNaN(f)?c:f},Ie())},formatter(a,l){let o=n.reduce((c,d,f)=>c+=`${e[f]}${d(a,l)}`,"");return o+=gn(e)}}}function ht(t,e,r){if(t instanceof Date||typeof t=="number"){const n=Br(t);return isNaN(n)?void 0:n}if(t){if(t==="today")return Ie();if(e&&e.toValue){const n=e.toValue(t,e,r);return isNaN(n)?void 0:Br(n)}return Aa(e).parser(t,r)}}function mt(t,e,r){if(isNaN(t)||!t&&t!==0)return"";const n=typeof t=="number"?new Date(t):t;return e.toDisplay?e.toDisplay(n,e,r):Aa(e).formatter(n,r)}const Rt=new WeakMap,{addEventListener:nc,removeEventListener:ic}=EventTarget.prototype;function vn(t,e){let r=Rt.get(t);r||(r=[],Rt.set(t,r)),e.forEach(n=>{nc.call(...n),r.push(n)})}function Ta(t){let e=Rt.get(t);e&&(e.forEach(r=>{ic.call(...r)}),Rt.delete(t))}if(!Event.prototype.composedPath){const t=(e,r=[])=>{r.push(e);let n;return e.parentNode?n=e.parentNode:e.host?n=e.host:e.defaultView&&(n=e.defaultView),n?t(n,r):r};Event.prototype.composedPath=function(){return t(this.target)}}function Ma(t,e,r,n=0){const i=t[n];return e(i)?i:i===r||!i.parentElement?void 0:Ma(t,e,r,n+1)}function Oa(t,e){const r=typeof e=="function"?e:n=>n.matches(e);return Ma(t.composedPath(),r,t.currentTarget)}const Ze={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",titleFormat:"MM y"}},bn={autohide:!1,beforeShowDay:null,beforeShowDecade:null,beforeShowMonth:null,beforeShowYear:null,calendarWeeks:!1,clearBtn:!1,dateDelimiter:",",datesDisabled:[],daysOfWeekDisabled:[],daysOfWeekHighlighted:[],defaultViewDate:void 0,disableTouchKeyboard:!1,format:"mm/dd/yyyy",language:"en",maxDate:null,maxNumberOfDates:1,maxView:3,minDate:null,nextArrow:'<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>',orientation:"auto",pickLevel:0,prevArrow:'<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd"></path></svg>',showDaysOfWeek:!0,showOnClick:!0,showOnFocus:!0,startView:0,title:"",todayBtn:!1,todayBtnMode:0,todayHighlight:!1,updateOnBlur:!0,weekStart:0},ac=document.createRange();function me(t){return ac.createContextualFragment(t)}function ct(t){t.style.display!=="none"&&(t.style.display&&(t.dataset.styleDisplay=t.style.display),t.style.display="none")}function dt(t){t.style.display==="none"&&(t.dataset.styleDisplay?(t.style.display=t.dataset.styleDisplay,delete t.dataset.styleDisplay):t.style.display="")}function jt(t){t.firstChild&&(t.removeChild(t.firstChild),jt(t))}function sc(t,e){jt(t),e instanceof DocumentFragment?t.appendChild(e):typeof e=="string"?t.appendChild(me(e)):typeof e.forEach=="function"&&e.forEach(r=>{t.appendChild(r)})}const{language:wr,format:lc,weekStart:oc}=bn;function mi(t,e){return t.length<6&&e>=0&&e<7?_e(t,e):t}function gi(t){return(t+6)%7}function pi(t,e,r,n){const i=ht(t,e,r);return i!==void 0?i:n}function xr(t,e,r=3){const n=parseInt(t,10);return n>=0&&n<=r?n:e}function kr(t,e){const r=Object.assign({},t),n={},i=e.constructor.locales;let{format:a,language:l,locale:o,maxDate:c,maxView:d,minDate:f,pickLevel:h,startView:u,weekStart:y}=e.config||{};if(r.language){let b;if(r.language!==l&&(i[r.language]?b=r.language:(b=r.language.split("-")[0],i[b]===void 0&&(b=!1))),delete r.language,b){l=n.language=b;const L=o||i[wr];o=Object.assign({format:lc,weekStart:oc},i[wr]),l!==wr&&Object.assign(o,i[l]),n.locale=o,a===L.format&&(a=n.format=o.format),y===L.weekStart&&(y=n.weekStart=o.weekStart,n.weekEnd=gi(o.weekStart))}}if(r.format){const b=typeof r.format.toDisplay=="function",L=typeof r.format.toValue=="function",q=Ur.test(r.format);(b&&L||q)&&(a=n.format=r.format),delete r.format}let g=f,p=c;if(r.minDate!==void 0&&(g=r.minDate===null?we(0,0,1):pi(r.minDate,a,o,g),delete r.minDate),r.maxDate!==void 0&&(p=r.maxDate===null?void 0:pi(r.maxDate,a,o,p),delete r.maxDate),p<g?(f=n.minDate=p,c=n.maxDate=g):(f!==g&&(f=n.minDate=g),c!==p&&(c=n.maxDate=p)),r.datesDisabled&&(n.datesDisabled=r.datesDisabled.reduce((b,L)=>{const q=ht(L,a,o);return q!==void 0?_e(b,q):b},[]),delete r.datesDisabled),r.defaultViewDate!==void 0){const b=ht(r.defaultViewDate,a,o);b!==void 0&&(n.defaultViewDate=b),delete r.defaultViewDate}if(r.weekStart!==void 0){const b=Number(r.weekStart)%7;isNaN(b)||(y=n.weekStart=b,n.weekEnd=gi(b)),delete r.weekStart}if(r.daysOfWeekDisabled&&(n.daysOfWeekDisabled=r.daysOfWeekDisabled.reduce(mi,[]),delete r.daysOfWeekDisabled),r.daysOfWeekHighlighted&&(n.daysOfWeekHighlighted=r.daysOfWeekHighlighted.reduce(mi,[]),delete r.daysOfWeekHighlighted),r.maxNumberOfDates!==void 0){const b=parseInt(r.maxNumberOfDates,10);b>=0&&(n.maxNumberOfDates=b,n.multidate=b!==1),delete r.maxNumberOfDates}r.dateDelimiter&&(n.dateDelimiter=String(r.dateDelimiter),delete r.dateDelimiter);let D=h;r.pickLevel!==void 0&&(D=xr(r.pickLevel,2),delete r.pickLevel),D!==h&&(h=n.pickLevel=D);let E=d;r.maxView!==void 0&&(E=xr(r.maxView,d),delete r.maxView),E=h>E?h:E,E!==d&&(d=n.maxView=E);let F=u;if(r.startView!==void 0&&(F=xr(r.startView,F),delete r.startView),F<h?F=h:F>d&&(F=d),F!==u&&(n.startView=F),r.prevArrow){const b=me(r.prevArrow);b.childNodes.length>0&&(n.prevArrow=b.childNodes),delete r.prevArrow}if(r.nextArrow){const b=me(r.nextArrow);b.childNodes.length>0&&(n.nextArrow=b.childNodes),delete r.nextArrow}if(r.disableTouchKeyboard!==void 0&&(n.disableTouchKeyboard="ontouchstart"in document&&!!r.disableTouchKeyboard,delete r.disableTouchKeyboard),r.orientation){const b=r.orientation.toLowerCase().split(/\s+/g);n.orientation={x:b.find(L=>L==="left"||L==="right")||"auto",y:b.find(L=>L==="top"||L==="bottom")||"auto"},delete r.orientation}if(r.todayBtnMode!==void 0){switch(r.todayBtnMode){case 0:case 1:n.todayBtnMode=r.todayBtnMode}delete r.todayBtnMode}return Object.keys(r).forEach(b=>{r[b]!==void 0&&he(bn,b)&&(n[b]=r[b])}),n}const cc=yn(`<div class="datepicker hidden">
|
|
12
12
|
<div class="datepicker-picker inline-block rounded-lg bg-white dark:bg-gray-700 shadow-lg p-4">
|
|
13
13
|
<div class="datepicker-header">
|
|
14
14
|
<div class="datepicker-title bg-white dark:bg-gray-700 dark:text-white px-2 py-3 text-center font-semibold"></div>
|
|
@@ -26,10 +26,10 @@ attempted value: ${a}
|
|
|
26
26
|
</div>
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
|
-
</div>`),
|
|
30
|
-
<div class="days-of-week grid grid-cols-7 mb-1">${
|
|
31
|
-
<div class="datepicker-grid w-64 grid grid-cols-7">${
|
|
32
|
-
</div>`),
|
|
29
|
+
</div>`),dc=yn(`<div class="days">
|
|
30
|
+
<div class="days-of-week grid grid-cols-7 mb-1">${He("span",7,{class:"dow block flex-1 leading-9 border-0 rounded-lg cursor-default text-center text-gray-900 font-semibold text-sm"})}</div>
|
|
31
|
+
<div class="datepicker-grid w-64 grid grid-cols-7">${He("span",42,{class:"block flex-1 leading-9 border-0 rounded-lg cursor-default text-center text-gray-900 font-semibold text-sm h-6 leading-6 text-sm font-medium text-gray-500 dark:text-gray-400"})}</div>
|
|
32
|
+
</div>`),uc=yn(`<div class="calendar-weeks">
|
|
33
33
|
<div class="days-of-week flex"><span class="dow h-6 leading-6 text-sm font-medium text-gray-500 dark:text-gray-400"></span></div>
|
|
34
|
-
<div class="weeks">${
|
|
35
|
-
</div>`);class En{constructor(e,r){Object.assign(this,r,{picker:e,element:me('<div class="datepicker-view flex"></div>').firstChild,selected:[]}),this.init(this.picker.datepicker.config)}init(e){e.pickLevel!==void 0&&(this.isMinView=this.id===e.pickLevel),this.setOptions(e),this.updateFocus(),this.updateSelection()}performBeforeHook(e,r,n){let i=this.beforeShow(new Date(n));switch(typeof i){case"boolean":i={enabled:i};break;case"string":i={classes:i}}if(i){if(i.enabled===!1&&(e.classList.add("disabled"),_e(this.disabled,r)),i.classes){const a=i.classes.split(/\s+/);e.classList.add(...a),a.includes("disabled")&&_e(this.disabled,r)}i.content&&ac(e,i.content)}}}class uc extends En{constructor(e){super(e,{id:0,name:"days",cellClass:"day"})}init(e,r=!0){if(r){const n=me(cc).firstChild;this.dow=n.firstChild,this.grid=n.lastChild,this.element.appendChild(n)}super.init(e)}setOptions(e){let r;if(he(e,"minDate")&&(this.minDate=e.minDate),he(e,"maxDate")&&(this.maxDate=e.maxDate),e.datesDisabled&&(this.datesDisabled=e.datesDisabled),e.daysOfWeekDisabled&&(this.daysOfWeekDisabled=e.daysOfWeekDisabled,r=!0),e.daysOfWeekHighlighted&&(this.daysOfWeekHighlighted=e.daysOfWeekHighlighted),e.todayHighlight!==void 0&&(this.todayHighlight=e.todayHighlight),e.weekStart!==void 0&&(this.weekStart=e.weekStart,this.weekEnd=e.weekEnd,r=!0),e.locale){const n=this.locale=e.locale;this.dayNames=n.daysMin,this.switchLabelFormat=n.titleFormat,r=!0}if(e.beforeShowDay!==void 0&&(this.beforeShow=typeof e.beforeShowDay=="function"?e.beforeShowDay:void 0),e.calendarWeeks!==void 0)if(e.calendarWeeks&&!this.calendarWeeks){const n=me(dc).firstChild;this.calendarWeeks={element:n,dow:n.firstChild,weeks:n.lastChild},this.element.insertBefore(n,this.element.firstChild)}else this.calendarWeeks&&!e.calendarWeeks&&(this.element.removeChild(this.calendarWeeks.element),this.calendarWeeks=null);e.showDaysOfWeek!==void 0&&(e.showDaysOfWeek?(dt(this.dow),this.calendarWeeks&&dt(this.calendarWeeks.dow)):(ct(this.dow),this.calendarWeeks&&ct(this.calendarWeeks.dow))),r&&Array.from(this.dow.children).forEach((n,i)=>{const a=(this.weekStart+i)%7;n.textContent=this.dayNames[a],n.className=this.daysOfWeekDisabled.includes(a)?"dow disabled text-center h-6 leading-6 text-sm font-medium text-gray-500 dark:text-gray-400 cursor-not-allowed":"dow text-center h-6 leading-6 text-sm font-medium text-gray-500 dark:text-gray-400"})}updateFocus(){const e=new Date(this.picker.viewDate),r=e.getFullYear(),n=e.getMonth(),i=we(r,n,1),a=Vt(i,this.weekStart,this.weekStart);this.first=i,this.last=we(r,n+1,0),this.start=a,this.focused=this.picker.viewDate}updateSelection(){const{dates:e,rangepicker:r}=this.picker.datepicker;this.selected=e,r&&(this.range=r.dates)}render(){this.today=this.todayHighlight?Ie():void 0,this.disabled=[...this.datesDisabled];const e=gt(this.focused,this.switchLabelFormat,this.locale);if(this.picker.setViewSwitchLabel(e),this.picker.setPrevBtnDisabled(this.first<=this.minDate),this.picker.setNextBtnDisabled(this.last>=this.maxDate),this.calendarWeeks){const r=Vt(this.first,1,1);Array.from(this.calendarWeeks.weeks.children).forEach((n,i)=>{n.textContent=Zo(Qo(r,i))})}Array.from(this.grid.children).forEach((r,n)=>{const i=r.classList,a=Be(this.start,n),l=new Date(a),o=l.getDay();if(r.className=`datepicker-cell hover:bg-gray-100 dark:hover:bg-gray-600 block flex-1 leading-9 border-0 rounded-lg cursor-pointer text-center text-gray-900 dark:text-white font-semibold text-sm ${this.cellClass}`,r.dataset.date=a,r.textContent=l.getDate(),a<this.first?i.add("prev","text-gray-500","dark:text-white"):a>this.last&&i.add("next","text-gray-500","dark:text-white"),this.today===a&&i.add("today","bg-gray-100","dark:bg-gray-600"),(a<this.minDate||a>this.maxDate||this.disabled.includes(a))&&i.add("disabled","cursor-not-allowed"),this.daysOfWeekDisabled.includes(o)&&(i.add("disabled","cursor-not-allowed"),_e(this.disabled,a)),this.daysOfWeekHighlighted.includes(o)&&i.add("highlighted"),this.range){const[c,d]=this.range;a>c&&a<d&&(i.add("range","bg-gray-200","dark:bg-gray-600"),i.remove("rounded-lg","rounded-l-lg","rounded-r-lg")),a===c&&(i.add("range-start","bg-gray-100","dark:bg-gray-600","rounded-l-lg"),i.remove("rounded-lg","rounded-r-lg")),a===d&&(i.add("range-end","bg-gray-100","dark:bg-gray-600","rounded-r-lg"),i.remove("rounded-lg","rounded-l-lg"))}this.selected.includes(a)&&(i.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),i.remove("text-gray-900","text-gray-500","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600","dark:bg-gray-600","bg-gray-100","bg-gray-200")),a===this.focused&&i.add("focused"),this.beforeShow&&this.performBeforeHook(r,a,a)})}refresh(){const[e,r]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach(n=>{n.classList.remove("range","range-start","range-end","selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white","focused"),n.classList.add("text-gray-900","rounded-lg","dark:text-white")}),Array.from(this.grid.children).forEach(n=>{const i=Number(n.dataset.date),a=n.classList;a.remove("bg-gray-200","dark:bg-gray-600","rounded-l-lg","rounded-r-lg"),i>e&&i<r&&(a.add("range","bg-gray-200","dark:bg-gray-600"),a.remove("rounded-lg")),i===e&&(a.add("range-start","bg-gray-200","dark:bg-gray-600","rounded-l-lg"),a.remove("rounded-lg","rounded-r-lg")),i===r&&(a.add("range-end","bg-gray-200","dark:bg-gray-600","rounded-r-lg"),a.remove("rounded-lg","rounded-l-lg")),this.selected.includes(i)&&(a.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),a.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600","bg-gray-100","bg-gray-200","dark:bg-gray-600")),i===this.focused&&a.add("focused")})}refreshFocus(){const e=Math.round((this.focused-this.start)/864e5);this.grid.querySelectorAll(".focused").forEach(r=>{r.classList.remove("focused")}),this.grid.children[e].classList.add("focused")}}function wi(t,e){if(!t||!t[0]||!t[1])return;const[[r,n],[i,a]]=t;if(!(r>e||i<e))return[r===e?n:-1,i===e?a:12]}class fc extends En{constructor(e){super(e,{id:1,name:"months",cellClass:"month"})}init(e,r=!0){r&&(this.grid=this.element,this.element.classList.add("months","datepicker-grid","w-64","grid","grid-cols-4"),this.grid.appendChild(me(Ye("span",12,{"data-month":n=>n})))),super.init(e)}setOptions(e){if(e.locale&&(this.monthNames=e.locale.monthsShort),he(e,"minDate"))if(e.minDate===void 0)this.minYear=this.minMonth=this.minDate=void 0;else{const r=new Date(e.minDate);this.minYear=r.getFullYear(),this.minMonth=r.getMonth(),this.minDate=r.setDate(1)}if(he(e,"maxDate"))if(e.maxDate===void 0)this.maxYear=this.maxMonth=this.maxDate=void 0;else{const r=new Date(e.maxDate);this.maxYear=r.getFullYear(),this.maxMonth=r.getMonth(),this.maxDate=we(this.maxYear,this.maxMonth+1,0)}e.beforeShowMonth!==void 0&&(this.beforeShow=typeof e.beforeShowMonth=="function"?e.beforeShowMonth:void 0)}updateFocus(){const e=new Date(this.picker.viewDate);this.year=e.getFullYear(),this.focused=e.getMonth()}updateSelection(){const{dates:e,rangepicker:r}=this.picker.datepicker;this.selected=e.reduce((n,i)=>{const a=new Date(i),l=a.getFullYear(),o=a.getMonth();return n[l]===void 0?n[l]=[o]:_e(n[l],o),n},{}),r&&r.dates&&(this.range=r.dates.map(n=>{const i=new Date(n);return isNaN(i)?void 0:[i.getFullYear(),i.getMonth()]}))}render(){this.disabled=[],this.picker.setViewSwitchLabel(this.year),this.picker.setPrevBtnDisabled(this.year<=this.minYear),this.picker.setNextBtnDisabled(this.year>=this.maxYear);const e=this.selected[this.year]||[],r=this.year<this.minYear||this.year>this.maxYear,n=this.year===this.minYear,i=this.year===this.maxYear,a=wi(this.range,this.year);Array.from(this.grid.children).forEach((l,o)=>{const c=l.classList,d=we(this.year,o,1);if(l.className=`datepicker-cell hover:bg-gray-100 dark:hover:bg-gray-600 block flex-1 leading-9 border-0 rounded-lg cursor-pointer text-center text-gray-900 dark:text-white font-semibold text-sm ${this.cellClass}`,this.isMinView&&(l.dataset.date=d),l.textContent=this.monthNames[o],(r||n&&o<this.minMonth||i&&o>this.maxMonth)&&c.add("disabled"),a){const[f,h]=a;o>f&&o<h&&c.add("range"),o===f&&c.add("range-start"),o===h&&c.add("range-end")}e.includes(o)&&(c.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),c.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),o===this.focused&&c.add("focused"),this.beforeShow&&this.performBeforeHook(l,o,d)})}refresh(){const e=this.selected[this.year]||[],[r,n]=wi(this.range,this.year)||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach(i=>{i.classList.remove("range","range-start","range-end","selected","bg-blue-700","dark:bg-blue-600","dark:text-white","text-white","focused"),i.classList.add("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")}),Array.from(this.grid.children).forEach((i,a)=>{const l=i.classList;a>r&&a<n&&l.add("range"),a===r&&l.add("range-start"),a===n&&l.add("range-end"),e.includes(a)&&(l.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),l.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),a===this.focused&&l.add("focused")})}refreshFocus(){this.grid.querySelectorAll(".focused").forEach(e=>{e.classList.remove("focused")}),this.grid.children[this.focused].classList.add("focused")}}function hc(t){return[...t].reduce((e,r,n)=>e+=n?r:r.toUpperCase(),"")}class xi extends En{constructor(e,r){super(e,r)}init(e,r=!0){r&&(this.navStep=this.step*10,this.beforeShowOption=`beforeShow${hc(this.cellClass)}`,this.grid=this.element,this.element.classList.add(this.name,"datepicker-grid","w-64","grid","grid-cols-4"),this.grid.appendChild(me(Ye("span",12)))),super.init(e)}setOptions(e){if(he(e,"minDate")&&(e.minDate===void 0?this.minYear=this.minDate=void 0:(this.minYear=Ce(e.minDate,this.step),this.minDate=we(this.minYear,0,1))),he(e,"maxDate")&&(e.maxDate===void 0?this.maxYear=this.maxDate=void 0:(this.maxYear=Ce(e.maxDate,this.step),this.maxDate=we(this.maxYear,11,31))),e[this.beforeShowOption]!==void 0){const r=e[this.beforeShowOption];this.beforeShow=typeof r=="function"?r:void 0}}updateFocus(){const e=new Date(this.picker.viewDate),r=Ce(e,this.navStep),n=r+9*this.step;this.first=r,this.last=n,this.start=r-this.step,this.focused=Ce(e,this.step)}updateSelection(){const{dates:e,rangepicker:r}=this.picker.datepicker;this.selected=e.reduce((n,i)=>_e(n,Ce(i,this.step)),[]),r&&r.dates&&(this.range=r.dates.map(n=>{if(n!==void 0)return Ce(n,this.step)}))}render(){this.disabled=[],this.picker.setViewSwitchLabel(`${this.first}-${this.last}`),this.picker.setPrevBtnDisabled(this.first<=this.minYear),this.picker.setNextBtnDisabled(this.last>=this.maxYear),Array.from(this.grid.children).forEach((e,r)=>{const n=e.classList,i=this.start+r*this.step,a=we(i,0,1);if(e.className=`datepicker-cell hover:bg-gray-100 dark:hover:bg-gray-600 block flex-1 leading-9 border-0 rounded-lg cursor-pointer text-center text-gray-900 dark:text-white font-semibold text-sm ${this.cellClass}`,this.isMinView&&(e.dataset.date=a),e.textContent=e.dataset.year=i,r===0?n.add("prev"):r===11&&n.add("next"),(i<this.minYear||i>this.maxYear)&&n.add("disabled"),this.range){const[l,o]=this.range;i>l&&i<o&&n.add("range"),i===l&&n.add("range-start"),i===o&&n.add("range-end")}this.selected.includes(i)&&(n.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),n.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),i===this.focused&&n.add("focused"),this.beforeShow&&this.performBeforeHook(e,i,a)})}refresh(){const[e,r]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach(n=>{n.classList.remove("range","range-start","range-end","selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white","focused")}),Array.from(this.grid.children).forEach(n=>{const i=Number(n.textContent),a=n.classList;i>e&&i<r&&a.add("range"),i===e&&a.add("range-start"),i===r&&a.add("range-end"),this.selected.includes(i)&&(a.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),a.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),i===this.focused&&a.add("focused")})}refreshFocus(){const e=Math.round((this.focused-this.start)/this.step);this.grid.querySelectorAll(".focused").forEach(r=>{r.classList.remove("focused")}),this.grid.children[e].classList.add("focused")}}function We(t,e){const r={date:t.getDate(),viewDate:new Date(t.picker.viewDate),viewId:t.picker.currentView.id,datepicker:t};t.element.dispatchEvent(new CustomEvent(e,{detail:r}))}function Ut(t,e){const{minDate:r,maxDate:n}=t.config,{currentView:i,viewDate:a}=t.picker;let l;switch(i.id){case 0:l=Lt(a,e);break;case 1:l=ze(a,e);break;default:l=ze(a,e*i.navStep)}l=Sa(l,r,n),t.picker.changeFocus(l).render()}function _a(t){const e=t.picker.currentView.id;e!==t.config.maxView&&t.picker.changeView(e+1).render()}function Pa(t){t.config.updateOnBlur?t.update({autohide:!0}):(t.refresh("input"),t.hide())}function ki(t,e){const r=t.picker,n=new Date(r.viewDate),i=r.currentView.id,a=i===1?Lt(n,e-n.getMonth()):ze(n,e-n.getFullYear());r.changeFocus(a).changeView(i-1).render()}function mc(t){const e=t.picker,r=Ie();if(t.config.todayBtnMode===1){if(t.config.autohide){t.setDate(r);return}t.setDate(r,{render:!1}),e.update()}e.viewDate!==r&&e.changeFocus(r),e.changeView(0).render()}function gc(t){t.setDate({clear:!0})}function pc(t){_a(t)}function yc(t){Ut(t,-1)}function vc(t){Ut(t,1)}function bc(t,e){const r=Oa(e,".datepicker-cell");if(!r||r.classList.contains("disabled"))return;const{id:n,isMinView:i}=t.picker.currentView;i?t.setDate(Number(r.dataset.date)):n===1?ki(t,Number(r.dataset.month)):ki(t,Number(r.dataset.year))}function wc(t){!t.inline&&!t.config.disableTouchKeyboard&&t.inputField.focus()}function Ei(t,e){if(e.title!==void 0&&(e.title?(t.controls.title.textContent=e.title,dt(t.controls.title)):(t.controls.title.textContent="",ct(t.controls.title))),e.prevArrow){const r=t.controls.prevBtn;jt(r),e.prevArrow.forEach(n=>{r.appendChild(n.cloneNode(!0))})}if(e.nextArrow){const r=t.controls.nextBtn;jt(r),e.nextArrow.forEach(n=>{r.appendChild(n.cloneNode(!0))})}if(e.locale&&(t.controls.todayBtn.textContent=e.locale.today,t.controls.clearBtn.textContent=e.locale.clear),e.todayBtn!==void 0&&(e.todayBtn?dt(t.controls.todayBtn):ct(t.controls.todayBtn)),he(e,"minDate")||he(e,"maxDate")){const{minDate:r,maxDate:n}=t.datepicker.config;t.controls.todayBtn.disabled=!bn(Ie(),r,n)}e.clearBtn!==void 0&&(e.clearBtn?dt(t.controls.clearBtn):ct(t.controls.clearBtn))}function Di(t){const{dates:e,config:r}=t,n=e.length>0?vn(e):r.defaultViewDate;return Sa(n,r.minDate,r.maxDate)}function Fi(t,e){const r=new Date(t.viewDate),n=new Date(e),{id:i,year:a,first:l,last:o}=t.currentView,c=n.getFullYear();switch(t.viewDate=e,c!==r.getFullYear()&&We(t.datepicker,"changeYear"),n.getMonth()!==r.getMonth()&&We(t.datepicker,"changeMonth"),i){case 0:return e<l||e>o;case 1:return c!==a;default:return c<l||c>o}}function Er(t){return window.getComputedStyle(t).direction}class xc{constructor(e){this.datepicker=e;const r=oc.replace(/%buttonClass%/g,e.config.buttonClass),n=this.element=me(r).firstChild,[i,a,l]=n.firstChild.children,o=i.firstElementChild,[c,d,f]=i.lastElementChild.children,[h,u]=l.firstChild.children,y={title:o,prevBtn:c,viewSwitch:d,nextBtn:f,todayBtn:h,clearBtn:u};this.main=a,this.controls=y;const g=e.inline?"inline":"dropdown";n.classList.add(`datepicker-${g}`),g==="dropdown"&&n.classList.add("dropdown","absolute","top-0","left-0","z-50","pt-2"),Ei(this,e.config),this.viewDate=Di(e),xn(e,[[n,"click",wc.bind(null,e),{capture:!0}],[a,"click",bc.bind(null,e)],[y.viewSwitch,"click",pc.bind(null,e)],[y.prevBtn,"click",yc.bind(null,e)],[y.nextBtn,"click",vc.bind(null,e)],[y.todayBtn,"click",mc.bind(null,e)],[y.clearBtn,"click",gc.bind(null,e)]]),this.views=[new uc(this),new fc(this),new xi(this,{id:2,name:"years",cellClass:"year",step:1}),new xi(this,{id:3,name:"decades",cellClass:"decade",step:10})],this.currentView=this.views[e.config.startView],this.currentView.render(),this.main.appendChild(this.currentView.element),e.config.container.appendChild(this.element)}setOptions(e){Ei(this,e),this.views.forEach(r=>{r.init(e,!1)}),this.currentView.render()}detach(){this.datepicker.config.container.removeChild(this.element)}show(){if(this.active)return;this.element.classList.add("active","block"),this.element.classList.remove("hidden"),this.active=!0;const e=this.datepicker;if(!e.inline){const r=Er(e.inputField);r!==Er(e.config.container)?this.element.dir=r:this.element.dir&&this.element.removeAttribute("dir"),this.place(),e.config.disableTouchKeyboard&&e.inputField.blur()}We(e,"show")}hide(){this.active&&(this.datepicker.exitEditMode(),this.element.classList.remove("active","block"),this.element.classList.add("active","block","hidden"),this.active=!1,We(this.datepicker,"hide"))}place(){const{classList:e,style:r}=this.element,{config:n,inputField:i}=this.datepicker,a=n.container,{width:l,height:o}=this.element.getBoundingClientRect(),{left:c,top:d,width:f}=a.getBoundingClientRect(),{left:h,top:u,width:y,height:g}=i.getBoundingClientRect();let{x:p,y:D}=n.orientation,E,F,b;a===document.body?(E=window.scrollY,F=h+window.scrollX,b=u+E):(E=a.scrollTop,F=h-c,b=u-d+E),p==="auto"&&(F<0?(p="left",F=10):F+l>f?p="right":p=Er(i)==="rtl"?"right":"left"),p==="right"&&(F-=l-y),D==="auto"&&(D=b-o<E?"bottom":"top"),D==="top"?b-=o:b+=g,e.remove("datepicker-orient-top","datepicker-orient-bottom","datepicker-orient-right","datepicker-orient-left"),e.add(`datepicker-orient-${D}`,`datepicker-orient-${p}`),r.top=b&&`${b}px`,r.left=F&&`${F}px`}setViewSwitchLabel(e){this.controls.viewSwitch.textContent=e}setPrevBtnDisabled(e){this.controls.prevBtn.disabled=e}setNextBtnDisabled(e){this.controls.nextBtn.disabled=e}changeView(e){const r=this.currentView,n=this.views[e];return n.id!==r.id&&(this.currentView=n,this._renderMethod="render",We(this.datepicker,"changeView"),this.main.replaceChild(n.element,r.element)),this}changeFocus(e){return this._renderMethod=Fi(this,e)?"render":"refreshFocus",this.views.forEach(r=>{r.updateFocus()}),this}update(){const e=Di(this.datepicker);return this._renderMethod=Fi(this,e)?"render":"refresh",this.views.forEach(r=>{r.updateFocus(),r.updateSelection()}),this}render(e=!0){const r=e&&this._renderMethod||"render";delete this._renderMethod,this.currentView[r]()}}function Ia(t,e,r,n,i,a){if(bn(t,i,a)){if(n(t)){const l=e(t,r);return Ia(l,e,r,n,i,a)}return t}}function Ct(t,e,r,n){const i=t.picker,a=i.currentView,l=a.step||1;let o=i.viewDate,c,d;switch(a.id){case 0:n?o=Be(o,r*7):e.ctrlKey||e.metaKey?o=ze(o,r):o=Be(o,r),c=Be,d=f=>a.disabled.includes(f);break;case 1:o=Lt(o,n?r*4:r),c=Lt,d=f=>{const h=new Date(f),{year:u,disabled:y}=a;return h.getFullYear()===u&&y.includes(h.getMonth())};break;default:o=ze(o,r*(n?4:1)*l),c=ze,d=f=>a.disabled.includes(Ce(f,l))}o=Ia(o,c,r<0?-l:l,d,a.minDate,a.maxDate),o!==void 0&&i.changeFocus(o).render()}function kc(t,e){if(e.key==="Tab"){Pa(t);return}const r=t.picker,{id:n,isMinView:i}=r.currentView;if(r.active)if(t.editMode)switch(e.key){case"Escape":r.hide();break;case"Enter":t.exitEditMode({update:!0,autohide:t.config.autohide});break;default:return}else switch(e.key){case"Escape":r.hide();break;case"ArrowLeft":if(e.ctrlKey||e.metaKey)Ut(t,-1);else if(e.shiftKey){t.enterEditMode();return}else Ct(t,e,-1,!1);break;case"ArrowRight":if(e.ctrlKey||e.metaKey)Ut(t,1);else if(e.shiftKey){t.enterEditMode();return}else Ct(t,e,1,!1);break;case"ArrowUp":if(e.ctrlKey||e.metaKey)_a(t);else if(e.shiftKey){t.enterEditMode();return}else Ct(t,e,-1,!0);break;case"ArrowDown":if(e.shiftKey&&!e.ctrlKey&&!e.metaKey){t.enterEditMode();return}Ct(t,e,1,!0);break;case"Enter":i?t.setDate(r.viewDate):r.changeView(n-1).render();break;case"Backspace":case"Delete":t.enterEditMode();return;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&t.enterEditMode();return}else switch(e.key){case"ArrowDown":case"Escape":r.show();break;case"Enter":t.update();break;default:return}e.preventDefault(),e.stopPropagation()}function Ec(t){t.config.showOnFocus&&!t._showing&&t.show()}function Dc(t,e){const r=e.target;(t.picker.active||t.config.showOnClick)&&(r._active=r===document.activeElement,r._clicking=setTimeout(()=>{delete r._active,delete r._clicking},2e3))}function Fc(t,e){const r=e.target;r._clicking&&(clearTimeout(r._clicking),delete r._clicking,r._active&&t.enterEditMode(),delete r._active,t.config.showOnClick&&t.show())}function Nc(t,e){e.clipboardData.types.includes("text/plain")&&t.enterEditMode()}function Sc(t,e){const r=t.element;if(r!==document.activeElement)return;const n=t.picker.element;Oa(e,i=>i===r||i===n)||Pa(t)}function $a(t,e){return t.map(r=>gt(r,e.format,e.locale)).join(e.dateDelimiter)}function La(t,e,r=!1){const{config:n,dates:i,rangepicker:a}=t;if(e.length===0)return r?[]:void 0;const l=a&&t===a.datepickers[1];let o=e.reduce((c,d)=>{let f=mt(d,n.format,n.locale);if(f===void 0)return c;if(n.pickLevel>0){const h=new Date(f);n.pickLevel===1?f=l?h.setMonth(h.getMonth()+1,0):h.setDate(1):f=l?h.setFullYear(h.getFullYear()+1,0,0):h.setMonth(0,1)}return bn(f,n.minDate,n.maxDate)&&!c.includes(f)&&!n.datesDisabled.includes(f)&&!n.daysOfWeekDisabled.includes(new Date(f).getDay())&&c.push(f),c},[]);if(o.length!==0)return n.multidate&&!r&&(o=o.reduce((c,d)=>(i.includes(d)||c.push(d),c),i.filter(c=>!o.includes(c)))),n.maxNumberOfDates&&o.length>n.maxNumberOfDates?o.slice(n.maxNumberOfDates*-1):o}function Bt(t,e=3,r=!0){const{config:n,picker:i,inputField:a}=t;if(e&2){const l=i.active?n.pickLevel:n.startView;i.update().changeView(l).render(r)}e&1&&a&&(a.value=$a(t.dates,n))}function Ni(t,e,r){let{clear:n,render:i,autohide:a}=r;i===void 0&&(i=!0),i?a===void 0&&(a=t.config.autohide):a=!1;const l=La(t,e,n);l&&(l.toString()!==t.dates.toString()?(t.dates=l,Bt(t,i?3:1),We(t,"changeDate")):Bt(t,1),a&&t.hide())}class Cc{constructor(e,r={},n=void 0){e.datepicker=this,this.element=e;const i=this.config=Object.assign({buttonClass:r.buttonClass&&String(r.buttonClass)||"button",container:document.body,defaultViewDate:Ie(),maxDate:void 0,minDate:void 0},kr(kn,this));this._options=r,Object.assign(i,kr(r,this));const a=this.inline=e.tagName!=="INPUT";let l,o;if(a)i.container=e,o=vr(e.dataset.date,i.dateDelimiter),delete e.dataset.date;else{const f=r.container?document.querySelector(r.container):null;f&&(i.container=f),l=this.inputField=e,l.classList.add("datepicker-input"),o=vr(l.value,i.dateDelimiter)}if(n){const f=n.inputs.indexOf(l),h=n.datepickers;if(f<0||f>1||!Array.isArray(h))throw Error("Invalid rangepicker object.");h[f]=this,Object.defineProperty(this,"rangepicker",{get(){return n}})}this.dates=[];const c=La(this,o);c&&c.length>0&&(this.dates=c),l&&(l.value=$a(this.dates,i));const d=this.picker=new xc(this);if(a)this.show();else{const f=Sc.bind(null,this),h=[[l,"keydown",kc.bind(null,this)],[l,"focus",Ec.bind(null,this)],[l,"mousedown",Dc.bind(null,this)],[l,"click",Fc.bind(null,this)],[l,"paste",Nc.bind(null,this)],[document,"mousedown",f],[document,"touchstart",f],[window,"resize",d.place.bind(d)]];xn(this,h)}}static formatDate(e,r,n){return gt(e,r,n&&Ze[n]||Ze.en)}static parseDate(e,r,n){return mt(e,r,n&&Ze[n]||Ze.en)}static get locales(){return Ze}get active(){return!!(this.picker&&this.picker.active)}get pickerElement(){return this.picker?this.picker.element:void 0}setOptions(e){const r=this.picker,n=kr(e,this);Object.assign(this._options,e),Object.assign(this.config,n),r.setOptions(n),Bt(this,3)}show(){if(this.inputField){if(this.inputField.disabled)return;this.inputField!==document.activeElement&&(this._showing=!0,this.inputField.focus(),delete this._showing)}this.picker.show()}hide(){this.inline||(this.picker.hide(),this.picker.update().changeView(this.config.startView).render())}destroy(){return this.hide(),Ta(this),this.picker.detach(),this.inline||this.inputField.classList.remove("datepicker-input"),delete this.element.datepicker,this}getDate(e=void 0){const r=e?n=>gt(n,e,this.config.locale):n=>new Date(n);if(this.config.multidate)return this.dates.map(r);if(this.dates.length>0)return r(this.dates[0])}setDate(...e){const r=[...e],n={},i=vn(e);typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&i&&Object.assign(n,r.pop());const a=Array.isArray(r[0])?r[0]:r;Ni(this,a,n)}update(e=void 0){if(this.inline)return;const r={clear:!0,autohide:!!(e&&e.autohide)},n=vr(this.inputField.value,this.config.dateDelimiter);Ni(this,n,r)}refresh(e=void 0,r=!1){e&&typeof e!="string"&&(r=e,e=void 0);let n;e==="picker"?n=2:e==="input"?n=1:n=3,Bt(this,n,!r)}enterEditMode(){this.inline||!this.picker.active||this.editMode||(this.editMode=!0,this.inputField.classList.add("in-edit","border-blue-700"))}exitEditMode(e=void 0){if(this.inline||!this.editMode)return;const r=Object.assign({update:!1},e);delete this.editMode,this.inputField.classList.remove("in-edit","border-blue-700"),r.update&&this.update(r)}}function Si(t){const e=Object.assign({},t);return delete e.inputs,delete e.allowOneSidedRange,delete e.maxNumberOfDates,e}function Ci(t,e,r,n){xn(t,[[r,"changeDate",e]]),new Cc(r,n,t)}function et(t,e){if(t._updating)return;t._updating=!0;const r=e.target;if(r.datepicker===void 0)return;const n=t.datepickers,i={render:!1},a=t.inputs.indexOf(r),l=a===0?1:0,o=n[a].dates[0],c=n[l].dates[0];o!==void 0&&c!==void 0?a===0&&o>c?(n[0].setDate(c,i),n[1].setDate(o,i)):a===1&&o<c&&(n[0].setDate(o,i),n[1].setDate(c,i)):t.allowOneSidedRange||(o!==void 0||c!==void 0)&&(i.clear=!0,n[l].setDate(n[a].dates,i)),n[0].picker.update().render(),n[1].picker.update().render(),delete t._updating}class Ac{constructor(e,r={}){const n=Array.isArray(r.inputs)?r.inputs:Array.from(e.querySelectorAll("input"));if(n.length<2)return;e.rangepicker=this,this.element=e,this.inputs=n.slice(0,2),this.allowOneSidedRange=!!r.allowOneSidedRange;const i=et.bind(null,this),a=Si(r),l=[];Object.defineProperty(this,"datepickers",{get(){return l}}),Ci(this,i,this.inputs[0],a),Ci(this,i,this.inputs[1],a),Object.freeze(l),l[0].dates.length>0?et(this,{target:this.inputs[0]}):l[1].dates.length>0&&et(this,{target:this.inputs[1]})}get dates(){return this.datepickers.length===2?[this.datepickers[0].dates[0],this.datepickers[1].dates[0]]:void 0}setOptions(e){this.allowOneSidedRange=!!e.allowOneSidedRange;const r=Si(e);this.datepickers[0].setOptions(r),this.datepickers[1].setOptions(r)}destroy(){this.datepickers[0].destroy(),this.datepickers[1].destroy(),Ta(this),delete this.element.rangepicker}getDates(e=void 0){const r=e?n=>gt(n,e,this.datepickers[0].config.locale):n=>new Date(n);return this.dates.map(n=>n===void 0?n:r(n))}setDates(e,r){const[n,i]=this.datepickers,a=this.dates;this._updating=!0,n.setDate(e),i.setDate(r),delete this._updating,i.dates[0]!==a[1]?et(this,{target:this.inputs[1]}):n.dates[0]!==a[0]&&et(this,{target:this.inputs[0]})}}const Ai="dd/mm/yyyy";Array.from({length:24},(t,e)=>e).map(t=>{const e=t%12===0?12:t%12,r=String(e).padStart(2,"0"),n=t>11?"PM":"AM";return s(U,{children:[s("option",{value:`${r}:00 ${n}`,children:[r,":00 ",n]},`${t}:00`),s("option",{value:`${r}:00 ${n}`,children:[r,":30 ",n]},`${t}:30`)]})});const Tc=()=>{const[t,e]=A(),r=X(null),n=X(null),i=X(null),{values:a,errors:l,touched:o,setFieldValue:c}=bt(),d=!1,f=h=>{const u=h.detail.datepicker.rangepicker.getDates(Ai);(u[0]!==a.startDate||u[1]!==a.endDate)&&(c("startDate",u[0],!0),c("endDate",u[1],!0))};return M(()=>{if(r!=null&&r.current){const h=new Ac(r.current,{format:Ai,container:".modal"});e(h)}},[r==null?void 0:r.current]),M(()=>{n!=null&&n.current&&(i!=null&&i.current)&&(n.current.base.addEventListener("changeDate",f),i.current.base.addEventListener("changeDate",f))},[n==null?void 0:n.current,i==null?void 0:i.current]),s(U,{children:[s("div",{ref:r,"date-rangepicker":!0,className:"flex",children:[s("div",{className:"flex-col flex-1 mr-3",children:[s("label",{htmlFor:"startDate",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",l.startDate&&(o.startDate||o.endDate)?"text-red-600 space-x-5":"text-gray-700"),children:[l.startDate&&(o.startDate||o.endDate)&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Start Date*"})]}),s("div",{className:"relative",children:[s("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:s(Fr,{className:"mr-1.5 h-5 w-5","aria-hidden":"true"})}),s(oe,{ref:n,name:"startDate",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md border text-gray-900 pl-10 pr-0",placeholder:"DD/MM/YYYY",type:"text","aria-describedby":"startDate",validateOnBlur:!1})]}),l.startDate&&(o.startDate||o.endDate)&&s("span",{className:"flex-grow text-xs text-red-600",children:l.startDate})]}),s("div",{className:"flex-col flex-1 mr-3",children:[s("label",{htmlFor:"endDate",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",l.endDate&&(o.startDate||o.endDate)?"text-red-600 space-x-5":"text-gray-700"),children:[l.endDate&&(o.startDate||o.endDate)&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"End Date*"})]}),s("div",{className:"relative",children:[s("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:s(Fr,{className:"mr-1.5 h-5 w-5","aria-hidden":"true"})}),s(oe,{ref:i,name:"endDate",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md border text-gray-900 pl-10 pr-0",placeholder:"DD/MM/YYYY",type:"text","aria-describedby":"endDate"})]}),l.endDate&&(o.startDate||o.endDate)&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:l.endDate})]}),d]}),s("div",{children:[s("label",{htmlFor:"location",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",l.location&&o.location?"text-red-600 space-x-5":"text-gray-700"),children:[l.location&&o.location&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Location"}),l.location&&o.location&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:l.location})]}),s("div",{className:"mt-1 relative",children:s(oe,{name:"location",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md",placeholder:"Add event location",type:"text","aria-describedby":"location"})})]})]})},Mc=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],Oc=t=>{const e=X(null),[r,n]=A("pristine"),[i,a,l]=on(t.name);M(()=>{xe(i.value)?n("uploaded"):n("pristine")},[i]);const o=async c=>{c.preventDefault();const d=c.target.files;if(!d)return;const f=d.item(0);if(f){n("uploading");try{const h=await t.upload(f);l.setValue(Te(h)),n("uploaded")}catch(h){l.setError(`Error: ${h==null?void 0:h.message}`),n("error")}}};return s("div",{className:"flex justify-center cursor-pointer h-full w-full",children:s("div",{className:"flex-1 rounded-md shadow-sm border border-gray-300 focus-within:ring-1 focus-within:ring-primary focus-within:border-primary text-primary hover:text-primary hover:bg-gray-50",children:s("label",{htmlFor:t.name,className:"relative cursor-pointer flex items-stretch flex-grow focus-within:z-10",children:[s("div",{className:"relative flex items-stretch mr-6 focus-within:z-10",children:[s("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:[r==="uploading"&&s(yt,{}),r==="error"&&s(ae,{className:"text-red-600 h-5 w-5 border-0","aria-hidden":"true"}),(r==="pristine"||r==="uploaded")&&s(ys,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})]}),s("input",{type:"file",ref:e,name:t.name,id:t.name,className:"sr-only",accept:Mc.join(", "),disabled:r!=="pristine",onChange:o})]}),s("span",{className:"-ml-px flex-grow inline-flex items-center space-x-2 px-4 py-2 text-sm text-gray-500",children:[r==="uploading"&&"Uploading",r==="pristine"&&"Add supporting document (PDF, DOC up to 10MB)",r==="uploaded"&&vt(i.value).title,r==="error"&&s("span",{className:"text-red-600",children:`Failed to upload. ${a.error??"Unknow error."}`})]}),r==="pristine"&&s("span",{className:"-ml-px inline-flex items-center space-x-2 px-4 py-2 text-sm font-medium",children:"Upload"}),r==="uploaded"&&s("span",{className:"-ml-px inline-flex items-center space-x-2 px-4 py-2 text-sm font-medium text-red-600",onClick:c=>{c.preventDefault(),l.setValue(j),e.current&&(e.current.value=""),n("pristine")},children:"Remove"}),r==="error"&&s("span",{className:"-ml-px inline-flex items-center space-x-2 px-4 py-2 text-sm font-medium text-red-600",onClick:c=>{c.preventDefault(),l.setValue(j),e.current&&(e.current.value=""),n("pristine")},children:"Try again"})]})})})},_c=["image/png","image/jpeg","image/gif"],Ti=t=>{const e=X(null),[r,n]=A("pristine"),[i,a,l]=on(t.name);M(()=>{xe(i.value)?n("uploaded"):n("pristine")},[]);const o=async c=>{c.preventDefault();const d=c.target.files;if(!d)return;const f=d.item(0);if(f){n("uploading");try{const h=await t.upload(f);l.setValue(Te(h)),n("uploaded")}catch(h){l.setError(`Error: ${h==null?void 0:h.message}`),n("error")}}};return s("div",{className:"flex justify-center cursor-pointer h-full w-full",children:[r==="uploaded"&&s("div",{className:"flex flex-1 relative",children:[s("div",{className:"flex flex-1 border border-gray-300 rounded-md bg-white items-center justify-center",children:s("img",{className:"h-full object-contain",src:vt(a.value).downloadUrl,alt:""})}),s("div",{className:"transition absolute w-full h-full flex opacity-0 hover:opacity-100 border-gray-300 rounded-md items-center justify-center text-white backdrop-filter backdrop-brightness-50",children:s("button",{className:"inline-flex justify-center items-center p-2 border border-gray-300 hover:border-gray-100 hover:bg-gray-50 hover:bg-opacity-25 text-sm font-medium rounded",onClick:()=>{l.setValue(j),e.current&&(e.current.value=""),n("pristine")},children:[s(vs,{className:"h-5 w-5 border-0","aria-hidden":"true"}),t.mode==="full"&&s("span",{className:"pl-2",children:"Remove image"})]})})]}),r==="uploading"&&s("div",{className:"flex flex-col flex-grow rounded-md hover:bg-gray-50 border-2 border-dashed space-y-1 items-center justify-center px-6 pt-5 pb-6",children:[s(yt,{}),t.mode==="full"&&s("span",{className:"text-sm",children:"Uploading"})]}),r==="error"&&s("div",{className:"flex flex-col flex-grow rounded-md hover:bg-gray-50 border-2 border-dashed text-red-600 space-y-1 items-center justify-center text-center",onClick:()=>{l.setValue(j),e.current&&(e.current.value=""),n("pristine")},alt:a.error,children:[s(ae,{className:"h-6 w-6 border-0 mb-2","aria-hidden":"true"}),t.mode==="full"&&s(U,{children:[s("span",{className:"text-sm",children:a.error}),s("span",{className:"text-sm",children:"Click to try again."})]}),t.mode==="compact"&&s("span",{className:"text-sm",children:"Try again."})]}),r==="pristine"&&s("div",{className:"flex flex-1 rounded-md border-2 border-dashed space-y-1 text-center focus-within:outline-none focus-within:border-primary",children:s("label",{htmlFor:t.name,className:"flex flex-1 flex-col items-center justify-center relative cursor-pointer bg-white hover:bg-gray-50 rounded-md font-medium",children:[s("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48","aria-hidden":"true",children:s("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),s("div",{className:"text-sm text-gray-600",children:[t.title&&s("span",{children:t.title}),s("input",{ref:e,id:t.name,name:t.name,type:"file",className:"sr-only",accept:_c.join(", "),onChange:o})]}),t.subtitle&&s("p",{className:"text-xs text-gray-500",children:t.subtitle})]})})]})},Pc=t=>{const[e,r,n]=on(t.name);return s(nt.Group,{as:"div",className:"flex items-center flex-grow",children:[s(nt,{checked:e.value,onChange:i=>n.setValue(i),className:$(e.value?"bg-primary":"bg-gray-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"),children:s("span",{"aria-hidden":"true",className:$(e.value?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200")})}),t.label&&s(nt.Label,{as:"span",className:"ml-3",children:s("span",{className:"text-sm font-medium text-gray-900",children:t.label})})]})},Ic=t=>{const{values:e,isSubmitting:r}=bt();return M(()=>()=>{t.onUnmount&&!r&&t.onUnmount(e)},[r,e]),s(U,{})},$c=t=>{const e=Bi(()=>Bo)(t.initialValues);return s("div",{className:"mt-5 md:mt-0 md:col-span-2 w-160",children:s(aa,{initialValues:{...e,type:t.editableItemType},validationSchema:yn,onSubmit:async r=>{await t.onSaveAsync(r)},children:({values:r,errors:n,touched:i,isSubmitting:a})=>s(cn,{children:[s(Ic,{onUnmount:t.onUnmount}),s("div",{className:"shadow sm:rounded-md sm:overflow-hidden",children:[s("div",{className:"px-4 py-5 bg-white space-y-6 sm:p-6",children:[s("div",{className:"flex flex-1 justify-between",children:[s("h3",{className:"text-3xl font-semibold text-gray-900 tracking-tight sm:text-3xl",children:t.mode==="edit"?"Edit item":"Add new item"}),s("button",{type:"button",onClick:()=>t.onPreview(r),className:"inline-flex justify-center items-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md bg-gray-100 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400",children:[s(bs,{className:"mr-1.5 h-5 w-5","aria-hidden":"true"}),"Preview"]})]}),s("div",{children:[s("label",{className:"block text-sm font-medium text-gray-700",children:"Cover photo"}),s("div",{className:"mt-1 h-36",children:s(Ti,{name:"coverPhoto",mode:"full",title:"Add an image",subtitle:"PNG, JPG, GIF up to 10MB",upload:t.uploadImage})})]}),s("div",{className:"mt-6 flex",children:[r.type!=="customEvent"&&s("div",{class:"mr-4",children:[s("label",{className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.icon&&i.icon?"text-red-600 space-x-5":"text-gray-700"),children:[n.icon&&i.icon&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Thumbnail"})]}),s("div",{className:"mt-1 h-28 w-28",children:s(Ti,{name:"icon",mode:"compact",title:"Add an image",upload:t.uploadImage})})]}),s("div",{className:"flex-grow grid grid-cols-1 gap-2",children:[s("div",{children:[s("label",{htmlFor:"title",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.title&&i.title?"text-red-600 space-x-5":"text-gray-700"),children:[n.title&&i.title&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Title*"}),n.title&&i.title&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.title})]}),s("div",{className:"mt-1 relative",children:s(oe,{name:"title",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md",placeholder:"e.g. Free flu shots",type:"text","aria-describedby":"title"})})]}),s("div",{children:[s("label",{htmlFor:"subtitle",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.subtitle&&i.subtitle?"text-red-600 space-x-5":"text-gray-700"),children:[n.subtitle&&i.subtitle&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Subtitle*"}),n.subtitle&&i.subtitle&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.subtitle})]}),s("div",{className:"mt-1 relative",children:s(oe,{name:"subtitle",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md",placeholder:"e.g. Flu protection for you and your immediate family",type:"text","aria-describedby":"subtitle"})})]})]})]}),r.type==="customEvent"&&s(Tc,{}),s("div",{children:[s("label",{htmlFor:"description",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.description&&i.description?"text-red-600 space-x-5":"text-gray-700"),children:[n.description&&i.description&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Description*"}),n.description&&i.description&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.description})]}),s("div",{className:"mt-1",children:s(oe,{as:"textarea",name:"description",className:"shadow-sm focus:ring-primary focus:border-primary mt-1 block w-full sm:text-sm border border-gray-300 rounded-md whitespace-pre",placeholder:"Add detailed description",rows:3,type:"text","aria-describedby":"description"})})]}),s("div",{className:"grid grid-cols-4 gap-3",children:s("div",{className:"col-span-4 sm:col-span-2",children:[s("label",{htmlFor:"category",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.category&&i.category?"text-red-600 space-x-5":"text-gray-700"),children:[n.category&&i.category&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Category*"}),n.category&&i.category&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.category})]}),s(oe,{as:"select",name:"category",className:"mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary sm:text-sm",children:qi.map(l=>s("option",{value:l,children:Ki(l)}))})]})}),s("fieldset",{children:[s("legend",{className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.link&&i.link||n.linkLabel&&i.linkLabel?"text-red-600 space-x-5":"text-gray-700"),children:[(n.link&&i.link||n.linkLabel&&i.linkLabel)&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Link details"}),(n.link&&i.link||n.linkLabel&&i.linkLabel)&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:[n.linkLabel,n.link].filter(l=>!!l).join(". ")})]}),s("div",{className:"mt-1 bg-white rounded-md shadow-sm -space-y-px",children:s("div",{className:"flex -space-x-px",children:[s("div",{className:"w-1/12 flex-auto min-w-0",children:[s("label",{htmlFor:"item-link-label",className:"sr-only",children:"Link label"}),s(oe,{type:"text",name:"linkLabel",className:$("focus:ring-primary focus:border-primary relative block w-full rounded-none rounded-l-md bg-transparent focus:z-10 sm:text-sm",n.linkLabel&&i.linkLabel?"border-red-600":"border-gray-300"),placeholder:"e.g. Learn More"})]}),s("div",{className:"flex-auto min-w-0 relative",children:[s("label",{htmlFor:"item-link",className:"sr-only",children:"Link URL"}),s("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:s("span",{className:"text-gray-500 sm:text-sm",children:"https://"})}),s(oe,{type:"text",name:"link",className:$("focus:ring-primary focus:border-primary relative block w-full pl-16 rounded-none rounded-r-md bg-transparent focus:z-10 sm:text-sm",n.link&&i.link?"border-red-600":"border-gray-300"),placeholder:"www.example.com"})]})]})})]}),s("div",{className:"space-y-1",children:[s("label",{htmlFor:"attachment",className:"block text-sm font-medium text-gray-700 pointer-events-none",children:"Attachment"}),s(Oc,{name:"attachment",upload:t.uploadAttachement})]})]}),s("div",{className:"px-4 py-3 bg-gray-50 text-right sm:px-6 flex items-center justify-end gap-5",children:[t.onDelete&&t.mode==="edit"&&s("div",{className:"inline-flex flex-1",children:s("button",{type:"button",className:"inline-flex justify-center py-2 px-4 border border-gray-300 shadow-sm text-sm font-medium rounded text-red-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",onClick:t.onDelete,disabled:a,children:"Delete"})}),t.mode==="add"&&s(Pc,{name:"enableAfterSave",label:"Enabled when added"}),s("button",{type:"button",className:"inline-flex justify-center py-2 px-4 border border-gray-300 shadow-sm text-sm font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",onClick:()=>t.onCancel(),disabled:a,children:"Cancel"}),s("button",{type:"submit",disabled:a,className:"inline-flex justify-center py-2 px-4 border border-transparent disabled:opacity-50 shadow-sm text-sm font-medium rounded-md text-white bg-primary hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",children:[a&&s("span",{className:"text-white mr-2",children:s(yt,{})}),t.mode==="add"?"Add":"Save"]})]})]})]})})})},Va=t=>{const{uiState:e,store:r,selectedItem:n}=t,[i,a]=A(!1),l=()=>Wo(r),o=u=>Go(r,n,hi(u),t.save,t.reload,u.enableAfterSave),c=()=>Ho(r),d=u=>{t.onCancelEditing&&r.getValue().editDialog.screen==="hidden"&&t.onCancelEditing(u)},f=u=>{Yo(r,u),t.onPreview&&t.onPreview(u)},h=()=>t.delete?qo(r,n,t.delete):Promise.reject("Delete not implemented");return s(Gr,{isOpen:e.screen!=="hidden",onClose:l,children:[ue.match(e).with({screen:"form"},u=>s($c,{mode:u.editMode,initialValues:u.initialValues,editableItemType:r.getValue().editableItemType,onSaveAsync:o,onCancel:c,onUnmount:d,onDelete:t.delete?()=>a(!0):void 0,onPreview:f,uploadAttachement:t.uploadAttachement,uploadImage:t.uploadImage})).with({screen:"preview"},u=>s(dr,{item:hi(u.formData),onClose:l})).with({screen:"readonly-preview"},u=>s(dr,{item:u.itemData,onClose:l})).with({screen:"template-preview"},u=>s(dr,{actionButton:s("button",{className:"inline-flex justify-center items-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md bg-gray-100 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400",onClick:()=>{zo(r,u.templateData),t.onUseTemplate&&t.onUseTemplate(u.templateData)},children:"Use Template"}),item:u.templateData.data,onClose:l})).with(ue.__,()=>s(U,{})).exhaustive(),s(Jo,{isOpen:i,onConfirm:async()=>{await h(),a(!1)},onCancel:()=>a(!1)})]})};class Ra{constructor(){O(this,"id");O(this,"eventData");O(this,"templateData");O(this,"type");O(this,"isEnabled");O(this,"isFeatured");O(this,"metadata")}static toEditableItem(e){var i,a;const r=e.eventData??e.templateData,n=(i=r==null?void 0:r.links)!=null&&i.length?r.links[0]:null;return{type:e.type,id:e.id,data:{...r,linkLabel:n==null?void 0:n.label,url:n==null?void 0:n.href},lastModifiedDate:e.metadata.updatedAt,visibility:{isEnabled:e.isEnabled||!!((a=e.eventData)!=null&&a.isEnabled),isFeatured:e.isFeatured}}}static toEventItem(e){const r=e.linkLabel&&e.url?[{label:e.linkLabel,href:e.url}]:void 0;return{...e,links:r}}}class Lc{async save(e,r,n){const a={...Ra.toEventItem(e),isEnabled:!!n};return st.instance.url(`manage/events/${r??""}`).post(a).badRequest(()=>{throw new Error("Failed to execute event save")}).json()}async deleteItem(e){return Promise.resolve()}enableEvent(e,r){return this.save(e,r,!0)}async disableEvent(e,r){return this.save(e,r,!1)}async addToFeatured(e){return Promise.resolve()}async removeFromFeatured(e){return Promise.resolve()}async getPageStateAsync(){const e=await st.instance.url("manage/events").get().json(),r=await st.instance.url("manage/eventtemplates").get().json();return{availableEvents:[...e.availableEvents,...r.eventTemplates]}}}const Re=new Lc;class Vc extends zi{constructor(r){super(r);O(this,"eventsStats$",it([this.selectCount(r=>ur(r,"Upcoming",new Date)),this.selectCount(r=>ur(r,"Past",new Date)),this.selectCount(r=>ur(r,"Library",new Date))]).pipe(Ae(([r,n,i])=>({upcomingCount:r,pastCount:n,libraryCount:i}))));O(this,"editDialogState$",this.select(r=>r.editDialog));O(this,"eventsFilter$",this.select(r=>r.filter));O(this,"allFeaturedEvents$",this.selectAll({sortBy:Un,filterBy:[({visibility:r})=>r.isFeatured]}));O(this,"filteredEvents$",it([this.selectAll({sortBy:Un,filterBy:[({visibility:r})=>!r.isFeatured]}),this.select(r=>r.filter)]).pipe(Ae(([r,n])=>_s(r,n))));O(this,"isLoading$",this.selectLoading());O(this,"selectedEvent$",this.select(r=>r.selectedItem).pipe(Wi(r=>xe(r)?this.selectEntity(r.value).pipe(Ae(Te)):Hi(j))));this.store=r}get getSelectedEvent(){return this.getValue().selectedItem}}const Me=new Vc(ne),ja=3;class Rc{loadPageState(){return Me.selectCached(()=>Ee(Re.getPageStateAsync(),500),e=>{const r=e.availableEvents.map(Ra.toEditableItem);ne.set(r)})}reloadPageState(){ne.setHasCache(!1)}applyFilter(e){ne.update(r=>{r.filter=e})}async tryAddToFeaturedAsync(e){Me.getValue().featuredItems.length!==ja&&(await Re.addToFeatured(e),ne.update(e,r=>{r.visibility.isFeatured=!0}),ne.update(r=>{r.featuredItems.push(e)}))}async removeFromFeaturedAsync(e){await Re.removeFromFeatured(e),ne.removeFromFeatured(e)}async toggleEvent(e,r,n){e.visibility.isEnabled?(await Re.disableEvent(e.data,e.id),n(e.data)):(await Re.enableEvent(e.data,e.id),r(e.data)),Yi(()=>{e.visibility.isEnabled&&ne.removeFromFeatured(e.id),ne.update(e.id,i=>{i.visibility.isEnabled=!i.visibility.isEnabled})})}}const He=new Rc,jc=t=>{const[e,r]=A({screen:"hidden"}),[n,i,a]=dn();M(()=>{const h=[Me.editDialogState$.subscribe(r)];return()=>{h.map(u=>u.unsubscribe())}},[]);const l=()=>{He.reloadPageState(),lt.reloadViewPageState()},o=h=>{const u=h;let y=[];for(const g in u)u[g]||(y=[...y,g]);t.onCancel(y)},c=h=>Ot.postImageAsync({file:h}),d=h=>Ot.postDocumentAsync({file:h}),f=async(h,u,y)=>{try{await Re.save(h,u,y),He.applyFilter("Upcoming"),i({message:`Event successfully ${u?"edited":"added"}.`,level:ve.Success}),t.onSave(h,u)}catch{He.applyFilter("Upcoming"),i({message:`Event ${u?"editing":"creation"} failed. Please try again in a few minutes.`,level:ve.Error})}};return s(Va,{uiState:e,store:ot,selectedItem:e.screen=="form"&&e.editMode==="edit"?Me.getSelectedEvent:j,save:f,reload:l,uploadAttachement:d,uploadImage:c,onCancelEditing:o,onPreview:t.onPreview,onUseTemplate:t.onUseTemplate})},Uc=()=>{const[t,e]=A({upcomingCount:0,pastCount:0,libraryCount:0}),[r,n]=A(),[i,a]=A("Upcoming"),[l,o]=A(!0),[c,d]=A([]);M(()=>{const g=[Me.eventsStats$.subscribe(e),Me.filteredEvents$.subscribe(n),Me.eventsFilter$.subscribe(a),He.loadPageState().subscribe()];return()=>{g.map(p=>p.unsubscribe())}},[]),M(()=>{r&&o(!1)},[r]),M(()=>{d([{message:"Events are only available to customers who have been invited to use the new Flare app.",level:ve.Information}])},[]),M(()=>{if(!l)switch(i){case"Upcoming":{T.trackEvent({...ni,eventAction:"Viewed",calendarEventTab:"current",numberOfEvents:t.upcomingCount});break}case"Past":{T.trackEvent({...ni,eventAction:"Viewed",calendarEventTab:"past",numberOfEvents:t.pastCount});break}case"Library":T.trackEvent({...Ql,eventAction:"Viewed"})}},[l,i]);const f=[{name:"Upcoming Events",filterKey:"Upcoming",showDivider:!0,emptyMessage:"Add a new event or choose a template from our library",getCount:()=>(t==null?void 0:t.upcomingCount)??0},{name:"Past Events",filterKey:"Past",emptyMessage:"No events have occured",getCount:()=>{}},{name:"Library",filterKey:"Library",emptyMessage:"More event templates coming soon!",getCount:()=>{}}],h=i==="Library",u=g=>{var p;return T.trackEvent({...Ne,eventAction:"Published",title:g.title,startDate:((p=g.dateRange)==null?void 0:p.start)??"",hasLocation:!!g.location})},y=g=>{var p;return T.trackEvent({...Ne,eventAction:"Unpublished",title:g.title,startDate:((p=g.dateRange)==null?void 0:p.start)??"",hasLocation:!!g.location})};return s(rr.Provider,{value:{actionMessages:c,setActionMessages:d},children:[s(Wt,{title:"Events Manager",subTitle:"Build, maintain and manage your employee event offering.",buttonTitle:"Add new",isLoading:l,handleButtonClick:()=>{Da(ot),T.trackEvent({...ri,eventAction:"Opened",action:"add"})}}),s("div",{className:"pt-4",children:s(fn,{tabs:f,filterKey:i,onFilterChanged:g=>He.applyFilter(g)})}),s(un,{className:"mt-4"}),s("div",{className:"flex-auto pb-4 h-0 overflow-y-auto hide-scrollbar",children:s(en,{children:[l&&s(hn,{}),!l&&s(U,{children:s(Na,{filteredItems:r??[],maxFeaturedItems:ja,emptyMessage:f.filter(g=>g.filterKey===i)[0].emptyMessage,showYear:i==="Past",filteredDescription:i==="Upcoming"?"Upcoming Events":void 0,showLargeListItem:h,onToggleClicked:g=>i==="Upcoming"?He.toggleEvent(g,u,y):void 0,onEditClicked:g=>{Ea(ot,g),T.trackEvent({...ri,eventAction:"Opened",action:"edit"})},onPreviewClicked:g=>{var p;Fa(ot,g.data),T.trackEvent({...Ne,eventAction:"Viewed",title:g.data.title,startDate:((p=g.data.dateRange)==null?void 0:p.start)??"",hasLocation:!!g.data.location})}})})]})}),s(jc,{onSave:(g,p)=>{var D,E;T.trackEvent({...Ne,eventAction:p?"Updated":"Created",title:g.title,startDate:((D=g.dateRange)==null?void 0:D.start)??"",hasLocation:!!g.location}),p&&g.isEnabled&&T.trackEvent({...Ne,eventAction:"Published",title:g.title,startDate:((E=g.dateRange)==null?void 0:E.start)??"",hasLocation:!!g.location})},onPreview:g=>T.trackEvent({...Ne,eventAction:"Previewed",title:g.title,startDate:g.startDate??"",hasLocation:!!g.location}),onCancel:g=>T.trackEvent({...Ne,eventAction:"Abandoned",emptyFields:g.filter(p=>p!=="startTime"&&p!=="enableAfterSave")}),onUseTemplate:g=>T.trackEvent({...la,eventAction:"Cloned",templateTitle:g.data.title})})]})},Bc={eventName:"Section"},zc=()=>{const t=Wr(Qr),e=ut(()=>Jr(t),[t]),r=R(i=>{if(!e)return!1;const{featureFlags:a}=e;return a[i]},[e]),n=R(()=>e?e.featureFlags:{},[e]);return{getTreatment:r,getAllTreatments:n}},At=t=>()=>({...Bc,eventAction:"Opened",section:t}),Mi=[{name:"Perks",href:"#/admin",icon:ks,current:!0,access:(t,e)=>["accountAdmin","accountEditor"].includes(t),trackingEvent:At("perks")},{name:"Events",href:"#/admin/events",icon:Fr,current:!0,access:(t,e)=>["accountAdmin","accountEditor"].includes(t)&&e.flareMobileApp,trackingEvent:At("events")},{name:"Collections",href:"#/admin/collections",icon:Es,current:!0,access:(t,e)=>["accountAdmin","accountEditor"].includes(t)&&e.flareMobileApp,trackingEvent:At("collections")},{name:"Access",href:"#/admin/access",icon:Ds,current:!1,access:(t,e)=>["accountAdmin"].includes(t),trackingEvent:At("access")}],Wc=t=>{var c;const e=qr.useContext(Qr),r=((c=Jr(e))==null?void 0:c.benefitsProfile.role)??"user",{getAllTreatments:n}=zc(),i=ut(()=>n(),[n]),[a,l]=A(!1),o=d=>window.location.hash.replace(/\/+$/,"")===d.replace(/\/+$/,"");return s(U,{children:[s(Ps,{user:e}),s("div",{className:"min-w-5xl mx-auto h-screen flex overflow-hidden bg-white",children:[s(xt.Root,{show:a,as:U,children:s(Mt,{as:"div",static:!0,className:"fixed inset-0 flex z-40 md:hidden",open:a,onClose:l,children:[s(xt.Child,{as:U,enter:"transition-opacity ease-linear duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition-opacity ease-linear duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:s(Mt.Overlay,{className:"fixed inset-0 bg-gray-600 bg-opacity-75"})}),s(xt.Child,{as:U,enter:"transition ease-in-out duration-300 transform",enterFrom:"-translate-x-full",enterTo:"translate-x-0",leave:"transition ease-in-out duration-300 transform",leaveFrom:"translate-x-0",leaveTo:"-translate-x-full",children:s("div",{className:"relative flex-1 flex flex-col max-w-xs w-full pt-5 pb-4 bg-white",children:[s(xt.Child,{as:U,enter:"ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:s("div",{className:"absolute top-0 right-0 -mr-12 pt-2",children:s("button",{className:"ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white",onClick:()=>l(!1),children:[s("span",{className:"sr-only",children:"Close sidebar"}),s(ws,{className:"h-6 w-6 text-white","aria-hidden":"true"})]})})}),s("div",{className:"flex-shrink-0 flex items-center px-4",children:s("img",{className:"block h-8 w-auto",src:Is,alt:"Flare Benefits"})}),s("div",{className:"mt-5 flex-1 h-0 overflow-y-auto",children:s("nav",{className:"px-2 space-y-1",children:Mi.filter(d=>d.access(r,i)).map(d=>s("a",{href:d.href,onClick:T.handleTrackingOnClick(d.trackingEvent),className:$(o(d.href)?"bg-secondary text-primary":"text-gray-600 hover:bg-secondary hover:text-primary","group flex items-center px-2 py-2 text-base font-medium rounded-md"),children:[s(d.icon,{className:$(o(d.href)?"text-primary":"text-gray-400 group-hover:text-primary","mr-4 flex-shrink-0 h-6 w-6"),"aria-hidden":"true"}),d.name]},d.name))})})]})}),s("div",{className:"flex-shrink-0 w-14","aria-hidden":"true"})]})}),s("div",{className:"hidden md:flex md:flex-shrink-0",children:s("div",{className:"flex flex-col w-64",children:s("div",{className:"flex flex-col flex-grow border-r border-gray-200 pt-5 pb-4 bg-white overflow-y-auto",children:s("div",{className:"mt-5 flex-grow flex flex-col",children:s("nav",{className:"flex-1 px-2 bg-white space-y-1",children:Mi.filter(d=>d.access(r,i)).map(d=>s("a",{href:d.href,onClick:T.handleTrackingOnClick(d.trackingEvent),className:$(o(d.href)?"bg-secondary text-primary":"text-gray-600 hover:bg-secondary hover:text-primary","group flex items-center px-2 py-2 text-sm font-medium rounded-md"),children:[s(d.icon,{className:$(o(d.href)?"text-primary":"text-gray-400 group-hover:text-primary","mr-3 flex-shrink-0 h-6 w-6"),"aria-hidden":"true"}),d.name]},d.name))})})})})}),s("div",{className:"flex flex-col w-0 flex-1 overflow-hidden",children:[s("div",{className:"relative z-10 flex-shrink-0 flex h-16 bg-white",children:s("button",{className:"px-4 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary md:hidden",onClick:()=>l(!0),children:[s("span",{className:"sr-only",children:"Open sidebar"}),s(xs,{className:"h-6 w-6","aria-hidden":"true"})]})}),s("main",{className:"flex flex-col flex-1 overflow-auto focus:outline-none px-4 sm:px-6 lg:px-8 pt-1",children:t.children})]})]})]})},Oi={eventName:"PerkModal"},Dr={eventName:"Perks"},le={eventName:"Perk"};class Hc{async getPageStateAsync(){return at.instance.url("benefits/ui/manage-page").get().json()}async postCustomPerkCommandAsync(e,r){const n={command:r};return at.instance.url(`benefits/edit/${Bi(()=>"")(e)}`).post(n).badRequest(()=>{throw new Error("Failed to execute custom perk command")}).json()}async postPerkSetupCommandAsync(e){const r={command:e};return at.instance.url("benefits/perks-setup").post(r).badRequest(()=>{throw new Error("Failed to execute perks setup command")}).text()}}const pe=new Hc;class Yc{constructor(){O(this,"id");O(this,"perkData");O(this,"type");O(this,"isEnabled");O(this,"isFeatured");O(this,"metadata")}static toEditableItem(e){return{type:e.type,id:e.id,data:e.perkData,lastModifiedDate:e.metadata.updatedAt,visibility:{isEnabled:e.isEnabled,isFeatured:e.isFeatured}}}}var _i,Pi,Ii,tt;function Kc(t,e,r,n,i){var a={};return Object.keys(n).forEach(function(l){a[l]=n[l]}),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce(function(l,o){return o(t,e,l)||l},a),i&&a.initializer!==void 0&&(a.value=a.initializer?a.initializer.call(i):void 0,a.initializer=void 0),a.initializer===void 0?(Object.defineProperty(t,e,a),null):a}function qc(){return{featuredItems:[],editableItemType:"customPerk",filter:"All",selectedItem:j,editDialog:{screen:"hidden"}}}let Gc=(_i=Hr({name:"perks-manager",cache:{ttl:"3600000"},resettable:!0,producerFn:Yr}),Pi=Ri(),_i(Ii=(tt=class extends ji{constructor(){super(qc())}removeFromFeatured(e){this.update(e,r=>{r.visibility.isFeatured=!1}),this.update(r=>{r.featuredItems.splice(r.featuredItems.indexOf(e),1)})}},Kc(tt.prototype,"removeFromFeatured",[Pi],Object.getOwnPropertyDescriptor(tt.prototype,"removeFromFeatured"),tt.prototype),tt))||Ii);const ie=new Gc,Tt=ie;class pt extends zi{constructor(r){super(r);O(this,"perksStats$",it([this.selectCount(r=>r.type==="customPerk"),this.selectCount(r=>r.type==="marketplacePerk")]).pipe(Ae(([r,n])=>({customPerksCount:r,marketplacePerksCount:n}))));O(this,"editDialogState$",this.select(r=>r.editDialog));O(this,"perksFilter$",this.select(r=>r.filter));O(this,"allFeaturedPerks$",this.selectAll({sortBy:this.orderPerks,filterBy:[({visibility:r})=>r.isFeatured]}));O(this,"filteredFeaturedPerks$",it([this.allFeaturedPerks$,this.select(r=>r.filter)]).pipe(Ae(([r,n])=>pt.filterPerks(r,n))));O(this,"filteredPerks$",it([this.selectAll({sortBy:this.orderPerks,filterBy:[({visibility:r})=>!r.isFeatured]}),this.select(r=>r.filter)]).pipe(Ae(([r,n])=>pt.filterPerks(r,n))));O(this,"isLoading$",this.selectLoading());O(this,"selectedPerk$",this.select(r=>r.selectedItem).pipe(Wi(r=>xe(r)?this.selectEntity(r.value).pipe(Ae(Te)):Hi(j))));this.store=r}get getSelectedPerk(){return this.getValue().selectedItem}static filterPerks(r,n){switch(n){case"All":return r;case"Custom":return r.filter(i=>i.type==="customPerk");case"Marketplace":return r.filter(i=>i.type==="marketplacePerk")}}orderPerks(r,n,i){const a=r.visibility.isEnabled===n.visibility.isEnabled?0:r.visibility.isEnabled?-1:1,l=r.data.title.localeCompare(n.data.title);return 2*a+l}}const fe=new pt(ie),Ua=3;class Xc{loadPageState(){return fe.selectCached(()=>Ee(pe.getPageStateAsync(),500),e=>{ie.set(e.allPerks.map(Yc.toEditableItem))})}reloadPageState(){ie.setHasCache(!1)}applyFilter(e){ie.update(r=>{r.filter=e})}async tryAddToFeaturedAsync(e){fe.getValue().featuredItems.length!==Ua&&(await pe.postPerkSetupCommandAsync({addPerkToFeatured:e}),ie.update(e,r=>{r.visibility.isFeatured=!0}),ie.update(r=>{r.featuredItems.push(e)}),lt.reloadViewPageState())}async removeFromFeaturedAsync(e){await pe.postPerkSetupCommandAsync({removePerkFromFeatured:e}),ie.removeFromFeatured(e),lt.reloadViewPageState()}async toggleBenefit(e,r,n){e.visibility.isEnabled?(await pe.postPerkSetupCommandAsync({disablePerk:e.id}),n(e.data)):(await pe.postPerkSetupCommandAsync({enablePerk:e.id}),r(e.data)),Yi(()=>{e.visibility.isEnabled&&ie.removeFromFeatured(e.id),ie.update(e.id,i=>{i.visibility.isEnabled=!i.visibility.isEnabled})}),lt.reloadViewPageState()}}const je=new Xc,Jc=t=>{const[e,r]=A({screen:"hidden"}),[n,i,a]=dn();M(()=>{const u=[fe.editDialogState$.subscribe(r)];return()=>{u.map(y=>y.unsubscribe())}},[]);const l=u=>{const y=u;let g=[];for(const p in y)y[p]||(g=[...g,p]);t.onCancel(g)},o=async(u,y,g)=>{const p=y?{updateCustomPerk:u}:{createCustomPerk:u},D=y?ke(y):j;let E="";try{E=(await pe.postCustomPerkCommandAsync(D,p)).id,i({message:`Perk successfully ${xe(D)?"edited":"added"}.`,level:ve.Success}),t.onSave(u,y)}catch{i({message:`Perk ${xe(D)?"editing":"creation"} failed. Please try again in a few minutes.`,level:ve.Error})}!g&&!y?await pe.postPerkSetupCommandAsync({disablePerk:E}):t.onPublish(u)},c=()=>{je.reloadPageState(),lt.reloadViewPageState()},d=async u=>{await pe.postCustomPerkCommandAsync(ke(u),"deleteCustomPerk"),i({message:"Perk successfully deleted.",level:ve.Success}),t.onDelete(u)},f=u=>Ot.postImageAsync({file:u}),h=u=>Ot.postDocumentAsync({file:u});return s(Va,{uiState:e,store:Tt,selectedItem:e.screen=="form"&&e.editMode==="edit"?fe.getSelectedPerk:j,save:o,reload:c,delete:d,uploadAttachement:h,uploadImage:f,onCancelEditing:l,onPreview:t.onPreview})},Qc=()=>{const[t,e]=A({customPerksCount:0,marketplacePerksCount:0}),[r,n]=A([]),[i,a]=A([]),[l,o]=A([]),[c,d]=A("All"),[f,h]=A(!0),[u,y]=A([]);M(()=>{o(pt.filterPerks(i,c))},[c,i]),M(()=>{const C=[fe.perksStats$.subscribe(e),fe.filteredPerks$.subscribe(n),fe.perksFilter$.subscribe(d),fe.allFeaturedPerks$.subscribe(a),fe.isLoading$.subscribe(h),je.loadPageState().subscribe()];return()=>{C.map(H=>H.unsubscribe())}},[]),M(()=>{if(!f)switch(c){case"All":{T.trackEvent({...Dr,eventAction:"Viewed",perkTab:"all",numberOfPerks:t.customPerksCount+t.marketplacePerksCount});break}case"Marketplace":{T.trackEvent({...Dr,eventAction:"Viewed",perkTab:"marketplace",numberOfPerks:t.marketplacePerksCount});break}case"Custom":T.trackEvent({...Dr,eventAction:"Viewed",perkTab:"custom",numberOfPerks:t.customPerksCount})}},[f,c]);const g=[{name:"All Perks",filterKey:"All",emptyMessage:"No perks to show",getCount:()=>t.customPerksCount+t.marketplacePerksCount},{name:"Marketplace Perks",filterKey:"Marketplace",emptyMessage:"No marketplace perks to show",getCount:()=>t.marketplacePerksCount},{name:"Custom Perks",filterKey:"Custom",emptyMessage:"No custom perks have been added",getCount:()=>t.customPerksCount}],p=()=>{Da(Tt),T.trackEvent({...Oi,eventAction:"Opened",action:"add"})},D=C=>je.applyFilter(C),E=C=>{C.visibility.isFeatured?(je.removeFromFeaturedAsync(C.id),T.trackEvent({...le,eventAction:"Unfeatured",title:C.data.title})):(je.tryAddToFeaturedAsync(C.id),T.trackEvent({...le,eventAction:"Featured",title:C.data.title}))},F=C=>{const H=Y=>T.trackEvent({...le,eventAction:"Published",title:Y.title}),Ge=Y=>T.trackEvent({...le,eventAction:"Unpublished",title:Y.title});je.toggleBenefit(C,H,Ge)},b=C=>{T.trackEvent({...le,eventAction:"Published",title:C.title})},L=C=>{Ea(Tt,C),T.trackEvent({...Oi,eventAction:"Opened",action:"edit"})},q=C=>{Fa(Tt,C.data),T.trackEvent({...le,eventAction:"Viewed",title:C.data.title})},k=(C,H)=>{T.trackEvent({...le,eventAction:H?"Updated":"Created",title:C.title})},S=C=>T.trackEvent({...le,eventAction:"Previewed",title:C.title}),De=C=>T.trackEvent({...le,eventAction:"Abandoned",emptyFields:C.filter(H=>H!=="startTime"&&H!=="endDate"&&H!=="enableAfterSave"&&H!=="location")}),qe=C=>{const H=r.filter(Ge=>Ge.id===C);T.trackEvent({...le,eventAction:"Deleted",title:H.length>0?H[0].data.title:C})};return s(rr.Provider,{value:{actionMessages:u,setActionMessages:y},children:[s(Wt,{title:"Perks Manager",subTitle:"Build, maintain and manage your employee perks offering.",buttonTitle:"Add new",isLoading:f,handleButtonClick:p}),s("div",{className:"pt-4",children:s(fn,{tabs:g,filterKey:c,onFilterChanged:D})}),s(un,{className:"pt-4"}),s("div",{className:"flex-auto my-4 h-0 overflow-y-auto hide-scrollbar",children:s(en,{children:[f&&s(hn,{}),!f&&s(U,{children:s(Na,{filteredItems:r,featuredItems:{totalCount:i.length,filtered:l},maxFeaturedItems:Ua,emptyMessage:g.filter(C=>C.filterKey===c)[0].emptyMessage,onFeatureClicked:E,onToggleClicked:F,onEditClicked:L,onPreviewClicked:q})})]})}),s(Jc,{onSave:k,onPublish:b,onPreview:S,onCancel:De,onDelete:qe})]})},fd=()=>{const{service:t}=Xr();return M(()=>{ne.setHasCache(!1),ie.setHasCache(!1),t.trackAdminOpenedAsync()},[]),s(Wc,{children:s(Fs,{history:$s(Ns()),children:[s(kt,{path:"/admin",component:Qc}),s(kt,{path:"/admin/events",component:Uc}),s(kt,{path:"/admin/access",component:zl}),s(kt,{path:"/admin/collections",component:Jl})]})})};export{fd as default};
|
|
34
|
+
<div class="weeks">${He("span",6,{class:"week block flex-1 leading-9 border-0 rounded-lg cursor-default text-center text-gray-900 font-semibold text-sm"})}</div>
|
|
35
|
+
</div>`);class wn{constructor(e,r){Object.assign(this,r,{picker:e,element:me('<div class="datepicker-view flex"></div>').firstChild,selected:[]}),this.init(this.picker.datepicker.config)}init(e){e.pickLevel!==void 0&&(this.isMinView=this.id===e.pickLevel),this.setOptions(e),this.updateFocus(),this.updateSelection()}performBeforeHook(e,r,n){let i=this.beforeShow(new Date(n));switch(typeof i){case"boolean":i={enabled:i};break;case"string":i={classes:i}}if(i){if(i.enabled===!1&&(e.classList.add("disabled"),_e(this.disabled,r)),i.classes){const a=i.classes.split(/\s+/);e.classList.add(...a),a.includes("disabled")&&_e(this.disabled,r)}i.content&&sc(e,i.content)}}}class fc extends wn{constructor(e){super(e,{id:0,name:"days",cellClass:"day"})}init(e,r=!0){if(r){const n=me(dc).firstChild;this.dow=n.firstChild,this.grid=n.lastChild,this.element.appendChild(n)}super.init(e)}setOptions(e){let r;if(he(e,"minDate")&&(this.minDate=e.minDate),he(e,"maxDate")&&(this.maxDate=e.maxDate),e.datesDisabled&&(this.datesDisabled=e.datesDisabled),e.daysOfWeekDisabled&&(this.daysOfWeekDisabled=e.daysOfWeekDisabled,r=!0),e.daysOfWeekHighlighted&&(this.daysOfWeekHighlighted=e.daysOfWeekHighlighted),e.todayHighlight!==void 0&&(this.todayHighlight=e.todayHighlight),e.weekStart!==void 0&&(this.weekStart=e.weekStart,this.weekEnd=e.weekEnd,r=!0),e.locale){const n=this.locale=e.locale;this.dayNames=n.daysMin,this.switchLabelFormat=n.titleFormat,r=!0}if(e.beforeShowDay!==void 0&&(this.beforeShow=typeof e.beforeShowDay=="function"?e.beforeShowDay:void 0),e.calendarWeeks!==void 0)if(e.calendarWeeks&&!this.calendarWeeks){const n=me(uc).firstChild;this.calendarWeeks={element:n,dow:n.firstChild,weeks:n.lastChild},this.element.insertBefore(n,this.element.firstChild)}else this.calendarWeeks&&!e.calendarWeeks&&(this.element.removeChild(this.calendarWeeks.element),this.calendarWeeks=null);e.showDaysOfWeek!==void 0&&(e.showDaysOfWeek?(dt(this.dow),this.calendarWeeks&&dt(this.calendarWeeks.dow)):(ct(this.dow),this.calendarWeeks&&ct(this.calendarWeeks.dow))),r&&Array.from(this.dow.children).forEach((n,i)=>{const a=(this.weekStart+i)%7;n.textContent=this.dayNames[a],n.className=this.daysOfWeekDisabled.includes(a)?"dow disabled text-center h-6 leading-6 text-sm font-medium text-gray-500 dark:text-gray-400 cursor-not-allowed":"dow text-center h-6 leading-6 text-sm font-medium text-gray-500 dark:text-gray-400"})}updateFocus(){const e=new Date(this.picker.viewDate),r=e.getFullYear(),n=e.getMonth(),i=we(r,n,1),a=Vt(i,this.weekStart,this.weekStart);this.first=i,this.last=we(r,n+1,0),this.start=a,this.focused=this.picker.viewDate}updateSelection(){const{dates:e,rangepicker:r}=this.picker.datepicker;this.selected=e,r&&(this.range=r.dates)}render(){this.today=this.todayHighlight?Ie():void 0,this.disabled=[...this.datesDisabled];const e=mt(this.focused,this.switchLabelFormat,this.locale);if(this.picker.setViewSwitchLabel(e),this.picker.setPrevBtnDisabled(this.first<=this.minDate),this.picker.setNextBtnDisabled(this.last>=this.maxDate),this.calendarWeeks){const r=Vt(this.first,1,1);Array.from(this.calendarWeeks.weeks.children).forEach((n,i)=>{n.textContent=ec(Zo(r,i))})}Array.from(this.grid.children).forEach((r,n)=>{const i=r.classList,a=Ue(this.start,n),l=new Date(a),o=l.getDay();if(r.className=`datepicker-cell hover:bg-gray-100 dark:hover:bg-gray-600 block flex-1 leading-9 border-0 rounded-lg cursor-pointer text-center text-gray-900 dark:text-white font-semibold text-sm ${this.cellClass}`,r.dataset.date=a,r.textContent=l.getDate(),a<this.first?i.add("prev","text-gray-500","dark:text-white"):a>this.last&&i.add("next","text-gray-500","dark:text-white"),this.today===a&&i.add("today","bg-gray-100","dark:bg-gray-600"),(a<this.minDate||a>this.maxDate||this.disabled.includes(a))&&i.add("disabled","cursor-not-allowed"),this.daysOfWeekDisabled.includes(o)&&(i.add("disabled","cursor-not-allowed"),_e(this.disabled,a)),this.daysOfWeekHighlighted.includes(o)&&i.add("highlighted"),this.range){const[c,d]=this.range;a>c&&a<d&&(i.add("range","bg-gray-200","dark:bg-gray-600"),i.remove("rounded-lg","rounded-l-lg","rounded-r-lg")),a===c&&(i.add("range-start","bg-gray-100","dark:bg-gray-600","rounded-l-lg"),i.remove("rounded-lg","rounded-r-lg")),a===d&&(i.add("range-end","bg-gray-100","dark:bg-gray-600","rounded-r-lg"),i.remove("rounded-lg","rounded-l-lg"))}this.selected.includes(a)&&(i.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),i.remove("text-gray-900","text-gray-500","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600","dark:bg-gray-600","bg-gray-100","bg-gray-200")),a===this.focused&&i.add("focused"),this.beforeShow&&this.performBeforeHook(r,a,a)})}refresh(){const[e,r]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach(n=>{n.classList.remove("range","range-start","range-end","selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white","focused"),n.classList.add("text-gray-900","rounded-lg","dark:text-white")}),Array.from(this.grid.children).forEach(n=>{const i=Number(n.dataset.date),a=n.classList;a.remove("bg-gray-200","dark:bg-gray-600","rounded-l-lg","rounded-r-lg"),i>e&&i<r&&(a.add("range","bg-gray-200","dark:bg-gray-600"),a.remove("rounded-lg")),i===e&&(a.add("range-start","bg-gray-200","dark:bg-gray-600","rounded-l-lg"),a.remove("rounded-lg","rounded-r-lg")),i===r&&(a.add("range-end","bg-gray-200","dark:bg-gray-600","rounded-r-lg"),a.remove("rounded-lg","rounded-l-lg")),this.selected.includes(i)&&(a.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),a.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600","bg-gray-100","bg-gray-200","dark:bg-gray-600")),i===this.focused&&a.add("focused")})}refreshFocus(){const e=Math.round((this.focused-this.start)/864e5);this.grid.querySelectorAll(".focused").forEach(r=>{r.classList.remove("focused")}),this.grid.children[e].classList.add("focused")}}function yi(t,e){if(!t||!t[0]||!t[1])return;const[[r,n],[i,a]]=t;if(!(r>e||i<e))return[r===e?n:-1,i===e?a:12]}class hc extends wn{constructor(e){super(e,{id:1,name:"months",cellClass:"month"})}init(e,r=!0){r&&(this.grid=this.element,this.element.classList.add("months","datepicker-grid","w-64","grid","grid-cols-4"),this.grid.appendChild(me(He("span",12,{"data-month":n=>n})))),super.init(e)}setOptions(e){if(e.locale&&(this.monthNames=e.locale.monthsShort),he(e,"minDate"))if(e.minDate===void 0)this.minYear=this.minMonth=this.minDate=void 0;else{const r=new Date(e.minDate);this.minYear=r.getFullYear(),this.minMonth=r.getMonth(),this.minDate=r.setDate(1)}if(he(e,"maxDate"))if(e.maxDate===void 0)this.maxYear=this.maxMonth=this.maxDate=void 0;else{const r=new Date(e.maxDate);this.maxYear=r.getFullYear(),this.maxMonth=r.getMonth(),this.maxDate=we(this.maxYear,this.maxMonth+1,0)}e.beforeShowMonth!==void 0&&(this.beforeShow=typeof e.beforeShowMonth=="function"?e.beforeShowMonth:void 0)}updateFocus(){const e=new Date(this.picker.viewDate);this.year=e.getFullYear(),this.focused=e.getMonth()}updateSelection(){const{dates:e,rangepicker:r}=this.picker.datepicker;this.selected=e.reduce((n,i)=>{const a=new Date(i),l=a.getFullYear(),o=a.getMonth();return n[l]===void 0?n[l]=[o]:_e(n[l],o),n},{}),r&&r.dates&&(this.range=r.dates.map(n=>{const i=new Date(n);return isNaN(i)?void 0:[i.getFullYear(),i.getMonth()]}))}render(){this.disabled=[],this.picker.setViewSwitchLabel(this.year),this.picker.setPrevBtnDisabled(this.year<=this.minYear),this.picker.setNextBtnDisabled(this.year>=this.maxYear);const e=this.selected[this.year]||[],r=this.year<this.minYear||this.year>this.maxYear,n=this.year===this.minYear,i=this.year===this.maxYear,a=yi(this.range,this.year);Array.from(this.grid.children).forEach((l,o)=>{const c=l.classList,d=we(this.year,o,1);if(l.className=`datepicker-cell hover:bg-gray-100 dark:hover:bg-gray-600 block flex-1 leading-9 border-0 rounded-lg cursor-pointer text-center text-gray-900 dark:text-white font-semibold text-sm ${this.cellClass}`,this.isMinView&&(l.dataset.date=d),l.textContent=this.monthNames[o],(r||n&&o<this.minMonth||i&&o>this.maxMonth)&&c.add("disabled"),a){const[f,h]=a;o>f&&o<h&&c.add("range"),o===f&&c.add("range-start"),o===h&&c.add("range-end")}e.includes(o)&&(c.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),c.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),o===this.focused&&c.add("focused"),this.beforeShow&&this.performBeforeHook(l,o,d)})}refresh(){const e=this.selected[this.year]||[],[r,n]=yi(this.range,this.year)||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach(i=>{i.classList.remove("range","range-start","range-end","selected","bg-blue-700","dark:bg-blue-600","dark:text-white","text-white","focused"),i.classList.add("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")}),Array.from(this.grid.children).forEach((i,a)=>{const l=i.classList;a>r&&a<n&&l.add("range"),a===r&&l.add("range-start"),a===n&&l.add("range-end"),e.includes(a)&&(l.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),l.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),a===this.focused&&l.add("focused")})}refreshFocus(){this.grid.querySelectorAll(".focused").forEach(e=>{e.classList.remove("focused")}),this.grid.children[this.focused].classList.add("focused")}}function mc(t){return[...t].reduce((e,r,n)=>e+=n?r:r.toUpperCase(),"")}class vi extends wn{constructor(e,r){super(e,r)}init(e,r=!0){r&&(this.navStep=this.step*10,this.beforeShowOption=`beforeShow${mc(this.cellClass)}`,this.grid=this.element,this.element.classList.add(this.name,"datepicker-grid","w-64","grid","grid-cols-4"),this.grid.appendChild(me(He("span",12)))),super.init(e)}setOptions(e){if(he(e,"minDate")&&(e.minDate===void 0?this.minYear=this.minDate=void 0:(this.minYear=Ce(e.minDate,this.step),this.minDate=we(this.minYear,0,1))),he(e,"maxDate")&&(e.maxDate===void 0?this.maxYear=this.maxDate=void 0:(this.maxYear=Ce(e.maxDate,this.step),this.maxDate=we(this.maxYear,11,31))),e[this.beforeShowOption]!==void 0){const r=e[this.beforeShowOption];this.beforeShow=typeof r=="function"?r:void 0}}updateFocus(){const e=new Date(this.picker.viewDate),r=Ce(e,this.navStep),n=r+9*this.step;this.first=r,this.last=n,this.start=r-this.step,this.focused=Ce(e,this.step)}updateSelection(){const{dates:e,rangepicker:r}=this.picker.datepicker;this.selected=e.reduce((n,i)=>_e(n,Ce(i,this.step)),[]),r&&r.dates&&(this.range=r.dates.map(n=>{if(n!==void 0)return Ce(n,this.step)}))}render(){this.disabled=[],this.picker.setViewSwitchLabel(`${this.first}-${this.last}`),this.picker.setPrevBtnDisabled(this.first<=this.minYear),this.picker.setNextBtnDisabled(this.last>=this.maxYear),Array.from(this.grid.children).forEach((e,r)=>{const n=e.classList,i=this.start+r*this.step,a=we(i,0,1);if(e.className=`datepicker-cell hover:bg-gray-100 dark:hover:bg-gray-600 block flex-1 leading-9 border-0 rounded-lg cursor-pointer text-center text-gray-900 dark:text-white font-semibold text-sm ${this.cellClass}`,this.isMinView&&(e.dataset.date=a),e.textContent=e.dataset.year=i,r===0?n.add("prev"):r===11&&n.add("next"),(i<this.minYear||i>this.maxYear)&&n.add("disabled"),this.range){const[l,o]=this.range;i>l&&i<o&&n.add("range"),i===l&&n.add("range-start"),i===o&&n.add("range-end")}this.selected.includes(i)&&(n.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),n.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),i===this.focused&&n.add("focused"),this.beforeShow&&this.performBeforeHook(e,i,a)})}refresh(){const[e,r]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach(n=>{n.classList.remove("range","range-start","range-end","selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white","focused")}),Array.from(this.grid.children).forEach(n=>{const i=Number(n.textContent),a=n.classList;i>e&&i<r&&a.add("range"),i===e&&a.add("range-start"),i===r&&a.add("range-end"),this.selected.includes(i)&&(a.add("selected","bg-blue-700","text-white","dark:bg-blue-600","dark:text-white"),a.remove("text-gray-900","hover:bg-gray-100","dark:text-white","dark:hover:bg-gray-600")),i===this.focused&&a.add("focused")})}refreshFocus(){const e=Math.round((this.focused-this.start)/this.step);this.grid.querySelectorAll(".focused").forEach(r=>{r.classList.remove("focused")}),this.grid.children[e].classList.add("focused")}}function We(t,e){const r={date:t.getDate(),viewDate:new Date(t.picker.viewDate),viewId:t.picker.currentView.id,datepicker:t};t.element.dispatchEvent(new CustomEvent(e,{detail:r}))}function Bt(t,e){const{minDate:r,maxDate:n}=t.config,{currentView:i,viewDate:a}=t.picker;let l;switch(i.id){case 0:l=Lt(a,e);break;case 1:l=ze(a,e);break;default:l=ze(a,e*i.navStep)}l=Sa(l,r,n),t.picker.changeFocus(l).render()}function _a(t){const e=t.picker.currentView.id;e!==t.config.maxView&&t.picker.changeView(e+1).render()}function Pa(t){t.config.updateOnBlur?t.update({autohide:!0}):(t.refresh("input"),t.hide())}function bi(t,e){const r=t.picker,n=new Date(r.viewDate),i=r.currentView.id,a=i===1?Lt(n,e-n.getMonth()):ze(n,e-n.getFullYear());r.changeFocus(a).changeView(i-1).render()}function gc(t){const e=t.picker,r=Ie();if(t.config.todayBtnMode===1){if(t.config.autohide){t.setDate(r);return}t.setDate(r,{render:!1}),e.update()}e.viewDate!==r&&e.changeFocus(r),e.changeView(0).render()}function pc(t){t.setDate({clear:!0})}function yc(t){_a(t)}function vc(t){Bt(t,-1)}function bc(t){Bt(t,1)}function wc(t,e){const r=Oa(e,".datepicker-cell");if(!r||r.classList.contains("disabled"))return;const{id:n,isMinView:i}=t.picker.currentView;i?t.setDate(Number(r.dataset.date)):n===1?bi(t,Number(r.dataset.month)):bi(t,Number(r.dataset.year))}function xc(t){!t.inline&&!t.config.disableTouchKeyboard&&t.inputField.focus()}function wi(t,e){if(e.title!==void 0&&(e.title?(t.controls.title.textContent=e.title,dt(t.controls.title)):(t.controls.title.textContent="",ct(t.controls.title))),e.prevArrow){const r=t.controls.prevBtn;jt(r),e.prevArrow.forEach(n=>{r.appendChild(n.cloneNode(!0))})}if(e.nextArrow){const r=t.controls.nextBtn;jt(r),e.nextArrow.forEach(n=>{r.appendChild(n.cloneNode(!0))})}if(e.locale&&(t.controls.todayBtn.textContent=e.locale.today,t.controls.clearBtn.textContent=e.locale.clear),e.todayBtn!==void 0&&(e.todayBtn?dt(t.controls.todayBtn):ct(t.controls.todayBtn)),he(e,"minDate")||he(e,"maxDate")){const{minDate:r,maxDate:n}=t.datepicker.config;t.controls.todayBtn.disabled=!pn(Ie(),r,n)}e.clearBtn!==void 0&&(e.clearBtn?dt(t.controls.clearBtn):ct(t.controls.clearBtn))}function xi(t){const{dates:e,config:r}=t,n=e.length>0?gn(e):r.defaultViewDate;return Sa(n,r.minDate,r.maxDate)}function ki(t,e){const r=new Date(t.viewDate),n=new Date(e),{id:i,year:a,first:l,last:o}=t.currentView,c=n.getFullYear();switch(t.viewDate=e,c!==r.getFullYear()&&We(t.datepicker,"changeYear"),n.getMonth()!==r.getMonth()&&We(t.datepicker,"changeMonth"),i){case 0:return e<l||e>o;case 1:return c!==a;default:return c<l||c>o}}function Er(t){return window.getComputedStyle(t).direction}class kc{constructor(e){this.datepicker=e;const r=cc.replace(/%buttonClass%/g,e.config.buttonClass),n=this.element=me(r).firstChild,[i,a,l]=n.firstChild.children,o=i.firstElementChild,[c,d,f]=i.lastElementChild.children,[h,u]=l.firstChild.children,y={title:o,prevBtn:c,viewSwitch:d,nextBtn:f,todayBtn:h,clearBtn:u};this.main=a,this.controls=y;const g=e.inline?"inline":"dropdown";n.classList.add(`datepicker-${g}`),g==="dropdown"&&n.classList.add("dropdown","absolute","top-0","left-0","z-50","pt-2"),wi(this,e.config),this.viewDate=xi(e),vn(e,[[n,"click",xc.bind(null,e),{capture:!0}],[a,"click",wc.bind(null,e)],[y.viewSwitch,"click",yc.bind(null,e)],[y.prevBtn,"click",vc.bind(null,e)],[y.nextBtn,"click",bc.bind(null,e)],[y.todayBtn,"click",gc.bind(null,e)],[y.clearBtn,"click",pc.bind(null,e)]]),this.views=[new fc(this),new hc(this),new vi(this,{id:2,name:"years",cellClass:"year",step:1}),new vi(this,{id:3,name:"decades",cellClass:"decade",step:10})],this.currentView=this.views[e.config.startView],this.currentView.render(),this.main.appendChild(this.currentView.element),e.config.container.appendChild(this.element)}setOptions(e){wi(this,e),this.views.forEach(r=>{r.init(e,!1)}),this.currentView.render()}detach(){this.datepicker.config.container.removeChild(this.element)}show(){if(this.active)return;this.element.classList.add("active","block"),this.element.classList.remove("hidden"),this.active=!0;const e=this.datepicker;if(!e.inline){const r=Er(e.inputField);r!==Er(e.config.container)?this.element.dir=r:this.element.dir&&this.element.removeAttribute("dir"),this.place(),e.config.disableTouchKeyboard&&e.inputField.blur()}We(e,"show")}hide(){this.active&&(this.datepicker.exitEditMode(),this.element.classList.remove("active","block"),this.element.classList.add("active","block","hidden"),this.active=!1,We(this.datepicker,"hide"))}place(){const{classList:e,style:r}=this.element,{config:n,inputField:i}=this.datepicker,a=n.container,{width:l,height:o}=this.element.getBoundingClientRect(),{left:c,top:d,width:f}=a.getBoundingClientRect(),{left:h,top:u,width:y,height:g}=i.getBoundingClientRect();let{x:p,y:D}=n.orientation,E,F,b;a===document.body?(E=window.scrollY,F=h+window.scrollX,b=u+E):(E=a.scrollTop,F=h-c,b=u-d+E),p==="auto"&&(F<0?(p="left",F=10):F+l>f?p="right":p=Er(i)==="rtl"?"right":"left"),p==="right"&&(F-=l-y),D==="auto"&&(D=b-o<E?"bottom":"top"),D==="top"?b-=o:b+=g,e.remove("datepicker-orient-top","datepicker-orient-bottom","datepicker-orient-right","datepicker-orient-left"),e.add(`datepicker-orient-${D}`,`datepicker-orient-${p}`),r.top=b&&`${b}px`,r.left=F&&`${F}px`}setViewSwitchLabel(e){this.controls.viewSwitch.textContent=e}setPrevBtnDisabled(e){this.controls.prevBtn.disabled=e}setNextBtnDisabled(e){this.controls.nextBtn.disabled=e}changeView(e){const r=this.currentView,n=this.views[e];return n.id!==r.id&&(this.currentView=n,this._renderMethod="render",We(this.datepicker,"changeView"),this.main.replaceChild(n.element,r.element)),this}changeFocus(e){return this._renderMethod=ki(this,e)?"render":"refreshFocus",this.views.forEach(r=>{r.updateFocus()}),this}update(){const e=xi(this.datepicker);return this._renderMethod=ki(this,e)?"render":"refresh",this.views.forEach(r=>{r.updateFocus(),r.updateSelection()}),this}render(e=!0){const r=e&&this._renderMethod||"render";delete this._renderMethod,this.currentView[r]()}}function Ia(t,e,r,n,i,a){if(pn(t,i,a)){if(n(t)){const l=e(t,r);return Ia(l,e,r,n,i,a)}return t}}function St(t,e,r,n){const i=t.picker,a=i.currentView,l=a.step||1;let o=i.viewDate,c,d;switch(a.id){case 0:n?o=Ue(o,r*7):e.ctrlKey||e.metaKey?o=ze(o,r):o=Ue(o,r),c=Ue,d=f=>a.disabled.includes(f);break;case 1:o=Lt(o,n?r*4:r),c=Lt,d=f=>{const h=new Date(f),{year:u,disabled:y}=a;return h.getFullYear()===u&&y.includes(h.getMonth())};break;default:o=ze(o,r*(n?4:1)*l),c=ze,d=f=>a.disabled.includes(Ce(f,l))}o=Ia(o,c,r<0?-l:l,d,a.minDate,a.maxDate),o!==void 0&&i.changeFocus(o).render()}function Ec(t,e){if(e.key==="Tab"){Pa(t);return}const r=t.picker,{id:n,isMinView:i}=r.currentView;if(r.active)if(t.editMode)switch(e.key){case"Escape":r.hide();break;case"Enter":t.exitEditMode({update:!0,autohide:t.config.autohide});break;default:return}else switch(e.key){case"Escape":r.hide();break;case"ArrowLeft":if(e.ctrlKey||e.metaKey)Bt(t,-1);else if(e.shiftKey){t.enterEditMode();return}else St(t,e,-1,!1);break;case"ArrowRight":if(e.ctrlKey||e.metaKey)Bt(t,1);else if(e.shiftKey){t.enterEditMode();return}else St(t,e,1,!1);break;case"ArrowUp":if(e.ctrlKey||e.metaKey)_a(t);else if(e.shiftKey){t.enterEditMode();return}else St(t,e,-1,!0);break;case"ArrowDown":if(e.shiftKey&&!e.ctrlKey&&!e.metaKey){t.enterEditMode();return}St(t,e,1,!0);break;case"Enter":i?t.setDate(r.viewDate):r.changeView(n-1).render();break;case"Backspace":case"Delete":t.enterEditMode();return;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&t.enterEditMode();return}else switch(e.key){case"ArrowDown":case"Escape":r.show();break;case"Enter":t.update();break;default:return}e.preventDefault(),e.stopPropagation()}function Dc(t){t.config.showOnFocus&&!t._showing&&t.show()}function Fc(t,e){const r=e.target;(t.picker.active||t.config.showOnClick)&&(r._active=r===document.activeElement,r._clicking=setTimeout(()=>{delete r._active,delete r._clicking},2e3))}function Nc(t,e){const r=e.target;r._clicking&&(clearTimeout(r._clicking),delete r._clicking,r._active&&t.enterEditMode(),delete r._active,t.config.showOnClick&&t.show())}function Sc(t,e){e.clipboardData.types.includes("text/plain")&&t.enterEditMode()}function Cc(t,e){const r=t.element;if(r!==document.activeElement)return;const n=t.picker.element;Oa(e,i=>i===r||i===n)||Pa(t)}function $a(t,e){return t.map(r=>mt(r,e.format,e.locale)).join(e.dateDelimiter)}function La(t,e,r=!1){const{config:n,dates:i,rangepicker:a}=t;if(e.length===0)return r?[]:void 0;const l=a&&t===a.datepickers[1];let o=e.reduce((c,d)=>{let f=ht(d,n.format,n.locale);if(f===void 0)return c;if(n.pickLevel>0){const h=new Date(f);n.pickLevel===1?f=l?h.setMonth(h.getMonth()+1,0):h.setDate(1):f=l?h.setFullYear(h.getFullYear()+1,0,0):h.setMonth(0,1)}return pn(f,n.minDate,n.maxDate)&&!c.includes(f)&&!n.datesDisabled.includes(f)&&!n.daysOfWeekDisabled.includes(new Date(f).getDay())&&c.push(f),c},[]);if(o.length!==0)return n.multidate&&!r&&(o=o.reduce((c,d)=>(i.includes(d)||c.push(d),c),i.filter(c=>!o.includes(c)))),n.maxNumberOfDates&&o.length>n.maxNumberOfDates?o.slice(n.maxNumberOfDates*-1):o}function Ut(t,e=3,r=!0){const{config:n,picker:i,inputField:a}=t;if(e&2){const l=i.active?n.pickLevel:n.startView;i.update().changeView(l).render(r)}e&1&&a&&(a.value=$a(t.dates,n))}function Ei(t,e,r){let{clear:n,render:i,autohide:a}=r;i===void 0&&(i=!0),i?a===void 0&&(a=t.config.autohide):a=!1;const l=La(t,e,n);l&&(l.toString()!==t.dates.toString()?(t.dates=l,Ut(t,i?3:1),We(t,"changeDate")):Ut(t,1),a&&t.hide())}class Ac{constructor(e,r={},n=void 0){e.datepicker=this,this.element=e;const i=this.config=Object.assign({buttonClass:r.buttonClass&&String(r.buttonClass)||"button",container:document.body,defaultViewDate:Ie(),maxDate:void 0,minDate:void 0},kr(bn,this));this._options=r,Object.assign(i,kr(r,this));const a=this.inline=e.tagName!=="INPUT";let l,o;if(a)i.container=e,o=vr(e.dataset.date,i.dateDelimiter),delete e.dataset.date;else{const f=r.container?document.querySelector(r.container):null;f&&(i.container=f),l=this.inputField=e,l.classList.add("datepicker-input"),o=vr(l.value,i.dateDelimiter)}if(n){const f=n.inputs.indexOf(l),h=n.datepickers;if(f<0||f>1||!Array.isArray(h))throw Error("Invalid rangepicker object.");h[f]=this,Object.defineProperty(this,"rangepicker",{get(){return n}})}this.dates=[];const c=La(this,o);c&&c.length>0&&(this.dates=c),l&&(l.value=$a(this.dates,i));const d=this.picker=new kc(this);if(a)this.show();else{const f=Cc.bind(null,this),h=[[l,"keydown",Ec.bind(null,this)],[l,"focus",Dc.bind(null,this)],[l,"mousedown",Fc.bind(null,this)],[l,"click",Nc.bind(null,this)],[l,"paste",Sc.bind(null,this)],[document,"mousedown",f],[document,"touchstart",f],[window,"resize",d.place.bind(d)]];vn(this,h)}}static formatDate(e,r,n){return mt(e,r,n&&Ze[n]||Ze.en)}static parseDate(e,r,n){return ht(e,r,n&&Ze[n]||Ze.en)}static get locales(){return Ze}get active(){return!!(this.picker&&this.picker.active)}get pickerElement(){return this.picker?this.picker.element:void 0}setOptions(e){const r=this.picker,n=kr(e,this);Object.assign(this._options,e),Object.assign(this.config,n),r.setOptions(n),Ut(this,3)}show(){if(this.inputField){if(this.inputField.disabled)return;this.inputField!==document.activeElement&&(this._showing=!0,this.inputField.focus(),delete this._showing)}this.picker.show()}hide(){this.inline||(this.picker.hide(),this.picker.update().changeView(this.config.startView).render())}destroy(){return this.hide(),Ta(this),this.picker.detach(),this.inline||this.inputField.classList.remove("datepicker-input"),delete this.element.datepicker,this}getDate(e=void 0){const r=e?n=>mt(n,e,this.config.locale):n=>new Date(n);if(this.config.multidate)return this.dates.map(r);if(this.dates.length>0)return r(this.dates[0])}setDate(...e){const r=[...e],n={},i=gn(e);typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&i&&Object.assign(n,r.pop());const a=Array.isArray(r[0])?r[0]:r;Ei(this,a,n)}update(e=void 0){if(this.inline)return;const r={clear:!0,autohide:!!(e&&e.autohide)},n=vr(this.inputField.value,this.config.dateDelimiter);Ei(this,n,r)}refresh(e=void 0,r=!1){e&&typeof e!="string"&&(r=e,e=void 0);let n;e==="picker"?n=2:e==="input"?n=1:n=3,Ut(this,n,!r)}enterEditMode(){this.inline||!this.picker.active||this.editMode||(this.editMode=!0,this.inputField.classList.add("in-edit","border-blue-700"))}exitEditMode(e=void 0){if(this.inline||!this.editMode)return;const r=Object.assign({update:!1},e);delete this.editMode,this.inputField.classList.remove("in-edit","border-blue-700"),r.update&&this.update(r)}}function Di(t){const e=Object.assign({},t);return delete e.inputs,delete e.allowOneSidedRange,delete e.maxNumberOfDates,e}function Fi(t,e,r,n){vn(t,[[r,"changeDate",e]]),new Ac(r,n,t)}function et(t,e){if(t._updating)return;t._updating=!0;const r=e.target;if(r.datepicker===void 0)return;const n=t.datepickers,i={render:!1},a=t.inputs.indexOf(r),l=a===0?1:0,o=n[a].dates[0],c=n[l].dates[0];o!==void 0&&c!==void 0?a===0&&o>c?(n[0].setDate(c,i),n[1].setDate(o,i)):a===1&&o<c&&(n[0].setDate(o,i),n[1].setDate(c,i)):t.allowOneSidedRange||(o!==void 0||c!==void 0)&&(i.clear=!0,n[l].setDate(n[a].dates,i)),n[0].picker.update().render(),n[1].picker.update().render(),delete t._updating}class Tc{constructor(e,r={}){const n=Array.isArray(r.inputs)?r.inputs:Array.from(e.querySelectorAll("input"));if(n.length<2)return;e.rangepicker=this,this.element=e,this.inputs=n.slice(0,2),this.allowOneSidedRange=!!r.allowOneSidedRange;const i=et.bind(null,this),a=Di(r),l=[];Object.defineProperty(this,"datepickers",{get(){return l}}),Fi(this,i,this.inputs[0],a),Fi(this,i,this.inputs[1],a),Object.freeze(l),l[0].dates.length>0?et(this,{target:this.inputs[0]}):l[1].dates.length>0&&et(this,{target:this.inputs[1]})}get dates(){return this.datepickers.length===2?[this.datepickers[0].dates[0],this.datepickers[1].dates[0]]:void 0}setOptions(e){this.allowOneSidedRange=!!e.allowOneSidedRange;const r=Di(e);this.datepickers[0].setOptions(r),this.datepickers[1].setOptions(r)}destroy(){this.datepickers[0].destroy(),this.datepickers[1].destroy(),Ta(this),delete this.element.rangepicker}getDates(e=void 0){const r=e?n=>mt(n,e,this.datepickers[0].config.locale):n=>new Date(n);return this.dates.map(n=>n===void 0?n:r(n))}setDates(e,r){const[n,i]=this.datepickers,a=this.dates;this._updating=!0,n.setDate(e),i.setDate(r),delete this._updating,i.dates[0]!==a[1]?et(this,{target:this.inputs[1]}):n.dates[0]!==a[0]&&et(this,{target:this.inputs[0]})}}const Ni="dd/mm/yyyy";Array.from({length:24},(t,e)=>e).map(t=>{const e=t%12===0?12:t%12,r=String(e).padStart(2,"0"),n=t>11?"PM":"AM";return s(B,{children:[s("option",{value:`${r}:00 ${n}`,children:[r,":00 ",n]},`${t}:00`),s("option",{value:`${r}:00 ${n}`,children:[r,":30 ",n]},`${t}:30`)]})});const Mc=()=>{const[t,e]=A(),r=X(null),n=X(null),i=X(null),{values:a,errors:l,touched:o,setFieldValue:c}=vt(),d=!1,f=h=>{const u=h.detail.datepicker.rangepicker.getDates(Ni);(u[0]!==a.startDate||u[1]!==a.endDate)&&(c("startDate",u[0],!0),c("endDate",u[1],!0))};return M(()=>{if(r!=null&&r.current){const h=new Tc(r.current,{format:Ni,container:".modal"});e(h)}},[r==null?void 0:r.current]),M(()=>{n!=null&&n.current&&(i!=null&&i.current)&&(n.current.base.addEventListener("changeDate",f),i.current.base.addEventListener("changeDate",f))},[n==null?void 0:n.current,i==null?void 0:i.current]),s(B,{children:[s("div",{ref:r,"date-rangepicker":!0,className:"flex",children:[s("div",{className:"flex-col flex-1 mr-3",children:[s("label",{htmlFor:"startDate",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",l.startDate&&(o.startDate||o.endDate)?"text-red-600 space-x-5":"text-gray-700"),children:[l.startDate&&(o.startDate||o.endDate)&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Start Date*"})]}),s("div",{className:"relative",children:[s("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:s(Fr,{className:"mr-1.5 h-5 w-5","aria-hidden":"true"})}),s(oe,{ref:n,name:"startDate",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md border text-gray-900 pl-10 pr-0",placeholder:"DD/MM/YYYY",type:"text","aria-describedby":"startDate",validateOnBlur:!1})]}),l.startDate&&(o.startDate||o.endDate)&&s("span",{className:"flex-grow text-xs text-red-600",children:l.startDate})]}),s("div",{className:"flex-col flex-1 mr-3",children:[s("label",{htmlFor:"endDate",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",l.endDate&&(o.startDate||o.endDate)?"text-red-600 space-x-5":"text-gray-700"),children:[l.endDate&&(o.startDate||o.endDate)&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"End Date*"})]}),s("div",{className:"relative",children:[s("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:s(Fr,{className:"mr-1.5 h-5 w-5","aria-hidden":"true"})}),s(oe,{ref:i,name:"endDate",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md border text-gray-900 pl-10 pr-0",placeholder:"DD/MM/YYYY",type:"text","aria-describedby":"endDate"})]}),l.endDate&&(o.startDate||o.endDate)&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:l.endDate})]}),d]}),s("div",{children:[s("label",{htmlFor:"location",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",l.location&&o.location?"text-red-600 space-x-5":"text-gray-700"),children:[l.location&&o.location&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Location"}),l.location&&o.location&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:l.location})]}),s("div",{className:"mt-1 relative",children:s(oe,{name:"location",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md",placeholder:"Add event location",type:"text","aria-describedby":"location"})})]})]})},Oc=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],_c=t=>{const e=X(null),[r,n]=A("pristine"),[i,a,l]=an(t.name);M(()=>{xe(i.value)?n("uploaded"):n("pristine")},[i]);const o=async c=>{c.preventDefault();const d=c.target.files;if(!d)return;const f=d.item(0);if(f){n("uploading");try{const h=await t.upload(f);l.setValue(Te(h)),n("uploaded")}catch(h){l.setError(`Error: ${h==null?void 0:h.message}`),n("error")}}};return s("div",{className:"flex justify-center cursor-pointer h-full w-full",children:s("div",{className:"flex-1 rounded-md shadow-sm border border-gray-300 focus-within:ring-1 focus-within:ring-primary focus-within:border-primary text-primary hover:text-primary hover:bg-gray-50",children:s("label",{htmlFor:t.name,className:"relative cursor-pointer flex items-stretch flex-grow focus-within:z-10",children:[s("div",{className:"relative flex items-stretch mr-6 focus-within:z-10",children:[s("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:[r==="uploading"&&s(pt,{}),r==="error"&&s(ae,{className:"text-red-600 h-5 w-5 border-0","aria-hidden":"true"}),(r==="pristine"||r==="uploaded")&&s(ys,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})]}),s("input",{type:"file",ref:e,name:t.name,id:t.name,className:"sr-only",accept:Oc.join(", "),disabled:r!=="pristine",onChange:o})]}),s("span",{className:"-ml-px flex-grow inline-flex items-center space-x-2 px-4 py-2 text-sm text-gray-500",children:[r==="uploading"&&"Uploading",r==="pristine"&&"Add supporting document (PDF, DOC up to 10MB)",r==="uploaded"&&yt(i.value).title,r==="error"&&s("span",{className:"text-red-600",children:`Failed to upload. ${a.error??"Unknow error."}`})]}),r==="pristine"&&s("span",{className:"-ml-px inline-flex items-center space-x-2 px-4 py-2 text-sm font-medium",children:"Upload"}),r==="uploaded"&&s("span",{className:"-ml-px inline-flex items-center space-x-2 px-4 py-2 text-sm font-medium text-red-600",onClick:c=>{c.preventDefault(),l.setValue(j),e.current&&(e.current.value=""),n("pristine")},children:"Remove"}),r==="error"&&s("span",{className:"-ml-px inline-flex items-center space-x-2 px-4 py-2 text-sm font-medium text-red-600",onClick:c=>{c.preventDefault(),l.setValue(j),e.current&&(e.current.value=""),n("pristine")},children:"Try again"})]})})})},Pc=["image/png","image/jpeg","image/gif"],Si=t=>{const e=X(null),[r,n]=A("pristine"),[i,a,l]=an(t.name);M(()=>{xe(i.value)?n("uploaded"):n("pristine")},[]);const o=async c=>{c.preventDefault();const d=c.target.files;if(!d)return;const f=d.item(0);if(f){n("uploading");try{const h=await t.upload(f);l.setValue(Te(h)),n("uploaded")}catch(h){l.setError(`Error: ${h==null?void 0:h.message}`),n("error")}}};return s("div",{className:"flex justify-center cursor-pointer h-full w-full",children:[r==="uploaded"&&s("div",{className:"flex flex-1 relative",children:[s("div",{className:"flex flex-1 border border-gray-300 rounded-md bg-white items-center justify-center",children:s("img",{className:"h-full object-contain",src:yt(a.value).downloadUrl,alt:""})}),s("div",{className:"transition absolute w-full h-full flex opacity-0 hover:opacity-100 border-gray-300 rounded-md items-center justify-center text-white backdrop-filter backdrop-brightness-50",children:s("button",{className:"inline-flex justify-center items-center p-2 border border-gray-300 hover:border-gray-100 hover:bg-gray-50 hover:bg-opacity-25 text-sm font-medium rounded",onClick:()=>{l.setValue(j),e.current&&(e.current.value=""),n("pristine")},children:[s(vs,{className:"h-5 w-5 border-0","aria-hidden":"true"}),t.mode==="full"&&s("span",{className:"pl-2",children:"Remove image"})]})})]}),r==="uploading"&&s("div",{className:"flex flex-col flex-grow rounded-md hover:bg-gray-50 border-2 border-dashed space-y-1 items-center justify-center px-6 pt-5 pb-6",children:[s(pt,{}),t.mode==="full"&&s("span",{className:"text-sm",children:"Uploading"})]}),r==="error"&&s("div",{className:"flex flex-col flex-grow rounded-md hover:bg-gray-50 border-2 border-dashed text-red-600 space-y-1 items-center justify-center text-center",onClick:()=>{l.setValue(j),e.current&&(e.current.value=""),n("pristine")},alt:a.error,children:[s(ae,{className:"h-6 w-6 border-0 mb-2","aria-hidden":"true"}),t.mode==="full"&&s(B,{children:[s("span",{className:"text-sm",children:a.error}),s("span",{className:"text-sm",children:"Click to try again."})]}),t.mode==="compact"&&s("span",{className:"text-sm",children:"Try again."})]}),r==="pristine"&&s("div",{className:"flex flex-1 rounded-md border-2 border-dashed space-y-1 text-center focus-within:outline-none focus-within:border-primary",children:s("label",{htmlFor:t.name,className:"flex flex-1 flex-col items-center justify-center relative cursor-pointer bg-white hover:bg-gray-50 rounded-md font-medium",children:[s("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48","aria-hidden":"true",children:s("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),s("div",{className:"text-sm text-gray-600",children:[t.title&&s("span",{children:t.title}),s("input",{ref:e,id:t.name,name:t.name,type:"file",className:"sr-only",accept:Pc.join(", "),onChange:o})]}),t.subtitle&&s("p",{className:"text-xs text-gray-500",children:t.subtitle})]})})]})},Ic=t=>{const[e,r,n]=an(t.name);return s(nt.Group,{as:"div",className:"flex items-center flex-grow",children:[s(nt,{checked:e.value,onChange:i=>n.setValue(i),className:$(e.value?"bg-primary":"bg-gray-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"),children:s("span",{"aria-hidden":"true",className:$(e.value?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200")})}),t.label&&s(nt.Label,{as:"span",className:"ml-3",children:s("span",{className:"text-sm font-medium text-gray-900",children:t.label})})]})},$c=t=>{const{values:e,isSubmitting:r}=vt();return M(()=>()=>{t.onUnmount&&!r&&t.onUnmount(e)},[r,e]),s(B,{})},Lc=t=>{const e=ji(()=>zo)(t.initialValues);return s("div",{className:"mt-5 md:mt-0 md:col-span-2 w-160",children:s(aa,{initialValues:{...e,type:t.editableItemType},validationSchema:mn,onSubmit:async r=>{await t.onSaveAsync(r)},children:({values:r,errors:n,touched:i,isSubmitting:a})=>s(sn,{children:[s($c,{onUnmount:t.onUnmount}),s("div",{className:"shadow sm:rounded-md sm:overflow-hidden",children:[s("div",{className:"px-4 py-5 bg-white space-y-6 sm:p-6",children:[s("div",{className:"flex flex-1 justify-between",children:[s("h3",{className:"text-3xl font-semibold text-gray-900 tracking-tight sm:text-3xl",children:t.mode==="edit"?"Edit item":"Add new item"}),s("button",{type:"button",onClick:()=>t.onPreview(r),className:"inline-flex justify-center items-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md bg-gray-100 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400",children:[s(bs,{className:"mr-1.5 h-5 w-5","aria-hidden":"true"}),"Preview"]})]}),s("div",{children:[s("label",{className:"block text-sm font-medium text-gray-700",children:"Cover photo"}),s("div",{className:"mt-1 h-36",children:s(Si,{name:"coverPhoto",mode:"full",title:"Add an image",subtitle:"PNG, JPG, GIF up to 10MB",upload:t.uploadImage})})]}),s("div",{className:"mt-6 flex",children:[r.type!=="customEvent"&&s("div",{class:"mr-4",children:[s("label",{className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.icon&&i.icon?"text-red-600 space-x-5":"text-gray-700"),children:[n.icon&&i.icon&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Thumbnail"})]}),s("div",{className:"mt-1 h-28 w-28",children:s(Si,{name:"icon",mode:"compact",title:"Add an image",upload:t.uploadImage})})]}),s("div",{className:"flex-grow grid grid-cols-1 gap-2",children:[s("div",{children:[s("label",{htmlFor:"title",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.title&&i.title?"text-red-600 space-x-5":"text-gray-700"),children:[n.title&&i.title&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Title*"}),n.title&&i.title&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.title})]}),s("div",{className:"mt-1 relative",children:s(oe,{name:"title",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md",placeholder:"e.g. Free flu shots",type:"text","aria-describedby":"title"})})]}),s("div",{children:[s("label",{htmlFor:"subtitle",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.subtitle&&i.subtitle?"text-red-600 space-x-5":"text-gray-700"),children:[n.subtitle&&i.subtitle&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Subtitle*"}),n.subtitle&&i.subtitle&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.subtitle})]}),s("div",{className:"mt-1 relative",children:s(oe,{name:"subtitle",className:"shadow-sm focus:ring-primary focus:border-primary block w-full sm:text-sm border-gray-300 rounded-md",placeholder:"e.g. Flu protection for you and your immediate family",type:"text","aria-describedby":"subtitle"})})]})]})]}),r.type==="customEvent"&&s(Mc,{}),s("div",{children:[s("label",{htmlFor:"description",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.description&&i.description?"text-red-600 space-x-5":"text-gray-700"),children:[n.description&&i.description&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Description*"}),n.description&&i.description&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.description})]}),s("div",{className:"mt-1",children:s(oe,{as:"textarea",name:"description",className:"shadow-sm focus:ring-primary focus:border-primary mt-1 block w-full sm:text-sm border border-gray-300 rounded-md whitespace-pre",placeholder:"Add detailed description",rows:3,type:"text","aria-describedby":"description"})})]}),s("div",{className:"grid grid-cols-4 gap-3",children:s("div",{className:"col-span-4 sm:col-span-2",children:[s("label",{htmlFor:"category",className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.category&&i.category?"text-red-600 space-x-5":"text-gray-700"),children:[n.category&&i.category&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Category*"}),n.category&&i.category&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:n.category})]}),s(oe,{as:"select",name:"category",className:"mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary sm:text-sm",children:qi.map(l=>s("option",{value:l,children:Ki(l)}))})]})}),s("fieldset",{children:[s("legend",{className:$("inline-flex relative w-full justify-start items-center text-sm font-medium",n.link&&i.link||n.linkLabel&&i.linkLabel?"text-red-600 space-x-5":"text-gray-700"),children:[(n.link&&i.link||n.linkLabel&&i.linkLabel)&&s(ae,{className:"absolute left-0 h-4 w-4 border-0 mr-1","aria-hidden":"true"}),s("span",{children:"Link details"}),(n.link&&i.link||n.linkLabel&&i.linkLabel)&&s("span",{className:"flex-grow text-right text-xs text-red-600",children:[n.linkLabel,n.link].filter(l=>!!l).join(". ")})]}),s("div",{className:"mt-1 bg-white rounded-md shadow-sm -space-y-px",children:s("div",{className:"flex -space-x-px",children:[s("div",{className:"w-1/12 flex-auto min-w-0",children:[s("label",{htmlFor:"item-link-label",className:"sr-only",children:"Link label"}),s(oe,{type:"text",name:"linkLabel",className:$("focus:ring-primary focus:border-primary relative block w-full rounded-none rounded-l-md bg-transparent focus:z-10 sm:text-sm",n.linkLabel&&i.linkLabel?"border-red-600":"border-gray-300"),placeholder:"e.g. Learn More"})]}),s("div",{className:"flex-auto min-w-0 relative",children:[s("label",{htmlFor:"item-link",className:"sr-only",children:"Link URL"}),s("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:s("span",{className:"text-gray-500 sm:text-sm",children:"https://"})}),s(oe,{type:"text",name:"link",className:$("focus:ring-primary focus:border-primary relative block w-full pl-16 rounded-none rounded-r-md bg-transparent focus:z-10 sm:text-sm",n.link&&i.link?"border-red-600":"border-gray-300"),placeholder:"www.example.com"})]})]})})]}),s("div",{className:"space-y-1",children:[s("label",{htmlFor:"attachment",className:"block text-sm font-medium text-gray-700 pointer-events-none",children:"Attachment"}),s(_c,{name:"attachment",upload:t.uploadAttachement})]})]}),s("div",{className:"px-4 py-3 bg-gray-50 text-right sm:px-6 flex items-center justify-end gap-5",children:[t.onDelete&&t.mode==="edit"&&s("div",{className:"inline-flex flex-1",children:s("button",{type:"button",className:"inline-flex justify-center py-2 px-4 border border-gray-300 shadow-sm text-sm font-medium rounded text-red-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",onClick:t.onDelete,disabled:a,children:"Delete"})}),t.mode==="add"&&s(Ic,{name:"enableAfterSave",label:"Enabled when added"}),s("button",{type:"button",className:"inline-flex justify-center py-2 px-4 border border-gray-300 shadow-sm text-sm font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",onClick:()=>t.onCancel(),disabled:a,children:"Cancel"}),s("button",{type:"submit",disabled:a,className:"inline-flex justify-center py-2 px-4 border border-transparent disabled:opacity-50 shadow-sm text-sm font-medium rounded-md text-white bg-primary hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",children:[a&&s("span",{className:"text-white mr-2",children:s(pt,{})}),t.mode==="add"?"Add":"Save"]})]})]})]})})})},Va=t=>{const{uiState:e,store:r,selectedItem:n}=t,[i,a]=A(!1),l=()=>Yo(r),o=u=>Xo(r,n,di(u),t.save,t.reload,u.enableAfterSave),c=()=>Ho(r),d=u=>{t.onCancelEditing&&r.getValue().editDialog.screen==="hidden"&&t.onCancelEditing(u)},f=u=>{Ko(r,u),t.onPreview&&t.onPreview(u)},h=()=>t.delete?Go(r,n,t.delete):Promise.reject("Delete not implemented");return s(qr,{isOpen:e.screen!=="hidden",onClose:l,children:[ue.match(e).with({screen:"form"},u=>s(Lc,{mode:u.editMode,initialValues:u.initialValues,editableItemType:r.getValue().editableItemType,onSaveAsync:o,onCancel:c,onUnmount:d,onDelete:t.delete?()=>a(!0):void 0,onPreview:f,uploadAttachement:t.uploadAttachement,uploadImage:t.uploadImage})).with({screen:"preview"},u=>s(dr,{item:di(u.formData),onClose:l})).with({screen:"readonly-preview"},u=>s(dr,{item:u.itemData,onClose:l})).with({screen:"template-preview"},u=>s(dr,{actionButton:s("button",{className:"inline-flex justify-center items-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md bg-gray-100 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400",onClick:()=>{Wo(r,u.templateData),t.onUseTemplate&&t.onUseTemplate(u.templateData)},children:"Use Template"}),item:u.templateData.data,onClose:l})).with(ue.__,()=>s(B,{})).exhaustive(),s(Qo,{isOpen:i,onConfirm:async()=>{await h(),a(!1)},onCancel:()=>a(!1)})]})};class Ra{constructor(){O(this,"id");O(this,"eventData");O(this,"templateData");O(this,"type");O(this,"isEnabled");O(this,"isFeatured");O(this,"metadata")}static toEditableItem(e){var i,a;const r=e.eventData??e.templateData,n=(i=r==null?void 0:r.links)!=null&&i.length?r.links[0]:null;return{type:e.type,id:e.id,data:{...r,linkLabel:n==null?void 0:n.label,url:n==null?void 0:n.href},lastModifiedDate:e.metadata.updatedAt,visibility:{isEnabled:e.isEnabled||!!((a=e.eventData)!=null&&a.isEnabled),isFeatured:e.isFeatured}}}static toEventItem(e){const r=e.linkLabel&&e.url?[{label:e.linkLabel,href:e.url}]:void 0;return{...e,links:r}}}class Vc{async save(e,r,n){const a={...Ra.toEventItem(e),isEnabled:!!n};return st.instance.url(`manage/events/${r??""}`).post(a).badRequest(()=>{throw new Error("Failed to execute event save")}).json()}async deleteItem(e){return Promise.resolve()}enableEvent(e,r){return this.save(e,r,!0)}async disableEvent(e,r){return this.save(e,r,!1)}async addToFeatured(e){return Promise.resolve()}async removeFromFeatured(e){return Promise.resolve()}async getPageStateAsync(){const e=await st.instance.url("manage/events").get().json(),r=await st.instance.url("manage/eventtemplates").get().json();return{availableEvents:[...e.availableEvents,...r.eventTemplates]}}}const Re=new Vc;class Rc extends Bi{constructor(r){super(r);O(this,"eventsStats$",it([this.selectCount(r=>ur(r,"Upcoming",new Date)),this.selectCount(r=>ur(r,"Past",new Date)),this.selectCount(r=>ur(r,"Library",new Date))]).pipe(Ae(([r,n,i])=>({upcomingCount:r,pastCount:n,libraryCount:i}))));O(this,"editDialogState$",this.select(r=>r.editDialog));O(this,"eventsFilter$",this.select(r=>r.filter));O(this,"allFeaturedEvents$",this.selectAll({sortBy:Vn,filterBy:[({visibility:r})=>r.isFeatured]}));O(this,"filteredEvents$",it([this.selectAll({sortBy:Vn,filterBy:[({visibility:r})=>!r.isFeatured]}),this.select(r=>r.filter)]).pipe(Ae(([r,n])=>_s(r,n))));O(this,"isLoading$",this.selectLoading());O(this,"selectedEvent$",this.select(r=>r.selectedItem).pipe(Ui(r=>xe(r)?this.selectEntity(r.value).pipe(Ae(Te)):zi(j))));this.store=r}get getSelectedEvent(){return this.getValue().selectedItem}}const Me=new Rc(ne),ja=3;class jc{loadPageState(){return Me.selectCached(()=>Ee(Re.getPageStateAsync(),500),e=>{const r=e.availableEvents.map(Ra.toEditableItem);ne.set(r)})}reloadPageState(){ne.setHasCache(!1)}applyFilter(e){ne.update(r=>{r.filter=e})}async tryAddToFeaturedAsync(e){Me.getValue().featuredItems.length!==ja&&(await Re.addToFeatured(e),ne.update(e,r=>{r.visibility.isFeatured=!0}),ne.update(r=>{r.featuredItems.push(e)}))}async removeFromFeaturedAsync(e){await Re.removeFromFeatured(e),ne.removeFromFeatured(e)}async toggleEvent(e,r,n){e.visibility.isEnabled?(await Re.disableEvent(e.data,e.id),n(e.data)):(await Re.enableEvent(e.data,e.id),r(e.data)),Wi(()=>{e.visibility.isEnabled&&ne.removeFromFeatured(e.id),ne.update(e.id,i=>{i.visibility.isEnabled=!i.visibility.isEnabled})})}}const Ye=new jc,Bc=t=>{const[e,r]=A({screen:"hidden"}),[n,i,a]=ln();M(()=>{const h=[Me.editDialogState$.subscribe(r)];return()=>{h.map(u=>u.unsubscribe())}},[]);const l=()=>{Ye.reloadPageState(),lt.reloadViewPageState()},o=h=>{const u=h;let y=[];for(const g in u)u[g]||(y=[...y,g]);t.onCancel(y)},c=h=>Ot.postImageAsync({file:h}),d=h=>Ot.postDocumentAsync({file:h}),f=async(h,u,y)=>{try{await Re.save(h,u,y),Ye.applyFilter("Upcoming"),i({message:`Event successfully ${u?"edited":"added"}.`,level:ve.Success}),t.onSave(h,u)}catch{Ye.applyFilter("Upcoming"),i({message:`Event ${u?"editing":"creation"} failed. Please try again in a few minutes.`,level:ve.Error})}};return s(Va,{uiState:e,store:ot,selectedItem:e.screen=="form"&&e.editMode==="edit"?Me.getSelectedEvent:j,save:f,reload:l,uploadAttachement:d,uploadImage:c,onCancelEditing:o,onPreview:t.onPreview,onUseTemplate:t.onUseTemplate})},Uc=()=>{const[t,e]=A({upcomingCount:0,pastCount:0,libraryCount:0}),[r,n]=A(),[i,a]=A("Upcoming"),[l,o]=A(!0),[c,d]=A([]);M(()=>{const g=[Me.eventsStats$.subscribe(e),Me.filteredEvents$.subscribe(n),Me.eventsFilter$.subscribe(a),Ye.loadPageState().subscribe()];return()=>{g.map(p=>p.unsubscribe())}},[]),M(()=>{r&&o(!1)},[r]),M(()=>{d([{message:"Events are only available to customers who have been invited to use the new Flare app.",level:ve.Information}])},[]),M(()=>{if(!l)switch(i){case"Upcoming":{T.trackEvent({...ei,eventAction:"Viewed",calendarEventTab:"current",numberOfEvents:t.upcomingCount});break}case"Past":{T.trackEvent({...ei,eventAction:"Viewed",calendarEventTab:"past",numberOfEvents:t.pastCount});break}case"Library":T.trackEvent({...Zl,eventAction:"Viewed"})}},[l,i]);const f=[{name:"Upcoming Events",filterKey:"Upcoming",showDivider:!0,emptyMessage:"Add a new event or choose a template from our library",getCount:()=>(t==null?void 0:t.upcomingCount)??0},{name:"Past Events",filterKey:"Past",emptyMessage:"No events have occured",getCount:()=>{}},{name:"Library",filterKey:"Library",emptyMessage:"More event templates coming soon!",getCount:()=>{}}],h=i==="Library",u=g=>{var p;return T.trackEvent({...Ne,eventAction:"Published",title:g.title,startDate:((p=g.dateRange)==null?void 0:p.start)??"",hasLocation:!!g.location})},y=g=>{var p;return T.trackEvent({...Ne,eventAction:"Unpublished",title:g.title,startDate:((p=g.dateRange)==null?void 0:p.start)??"",hasLocation:!!g.location})};return s(rr.Provider,{value:{actionMessages:c,setActionMessages:d},children:[s(Wt,{title:"Events Manager",subTitle:"Build, maintain and manage your employee event offering.",buttonTitle:"Add new",isLoading:l,handleButtonClick:()=>{Da(ot),T.trackEvent({...Zn,eventAction:"Opened",action:"add"})}}),s("div",{className:"pt-4",children:s(cn,{tabs:f,filterKey:i,onFilterChanged:g=>Ye.applyFilter(g)})}),s(on,{className:"mt-4"}),s("div",{className:"flex-auto pb-4 h-0 overflow-y-auto hide-scrollbar",children:s(Jr,{children:[l&&s(dn,{}),!l&&s(B,{children:s(Na,{filteredItems:r??[],maxFeaturedItems:ja,emptyMessage:f.filter(g=>g.filterKey===i)[0].emptyMessage,showYear:i==="Past",filteredDescription:i==="Upcoming"?"Upcoming Events":void 0,showLargeListItem:h,onToggleClicked:g=>i==="Upcoming"?Ye.toggleEvent(g,u,y):void 0,onEditClicked:g=>{Ea(ot,g),T.trackEvent({...Zn,eventAction:"Opened",action:"edit"})},onPreviewClicked:g=>{var p;Fa(ot,g.data),T.trackEvent({...Ne,eventAction:"Viewed",title:g.data.title,startDate:((p=g.data.dateRange)==null?void 0:p.start)??"",hasLocation:!!g.data.location})}})})]})}),s(Bc,{onSave:(g,p)=>{var D,E;T.trackEvent({...Ne,eventAction:p?"Updated":"Created",title:g.title,startDate:((D=g.dateRange)==null?void 0:D.start)??"",hasLocation:!!g.location}),p&&g.isEnabled&&T.trackEvent({...Ne,eventAction:"Published",title:g.title,startDate:((E=g.dateRange)==null?void 0:E.start)??"",hasLocation:!!g.location})},onPreview:g=>T.trackEvent({...Ne,eventAction:"Previewed",title:g.title,startDate:g.startDate??"",hasLocation:!!g.location}),onCancel:g=>T.trackEvent({...Ne,eventAction:"Abandoned",emptyFields:g.filter(p=>p!=="startTime"&&p!=="enableAfterSave")}),onUseTemplate:g=>T.trackEvent({...la,eventAction:"Cloned",templateTitle:g.data.title})})]})},zc={eventName:"Section"},Ct=t=>()=>({...zc,eventAction:"Opened",section:t}),Ci=[{name:"Perks",href:"#/admin",icon:ks,current:!0,access:(t,e)=>["accountAdmin","accountEditor"].includes(t),trackingEvent:Ct("perks")},{name:"Events",href:"#/admin/events",icon:Fr,current:!0,access:(t,e)=>["accountAdmin","accountEditor"].includes(t)&&e.flareMobileApp,trackingEvent:Ct("events")},{name:"Collections",href:"#/admin/collections",icon:Es,current:!0,access:(t,e)=>["accountAdmin","accountEditor"].includes(t)&&e.flareMobileApp,trackingEvent:Ct("collections")},{name:"Access",href:"#/admin/access",icon:Ds,current:!1,access:(t,e)=>["accountAdmin"].includes(t),trackingEvent:Ct("access")}],Wc=t=>{var c;const e=Kr.useContext(Hi),r=((c=Yi(e))==null?void 0:c.benefitsProfile.role)??"user",{getAllTreatments:n}=Ps(),i=Tt(()=>n(),[n]),[a,l]=A(!1),o=d=>window.location.hash.replace(/\/+$/,"")===d.replace(/\/+$/,"");return s(B,{children:[s(Is,{user:e}),s("div",{className:"min-w-5xl mx-auto h-screen flex overflow-hidden bg-white",children:[s(wt.Root,{show:a,as:B,children:s(Mt,{as:"div",static:!0,className:"fixed inset-0 flex z-40 md:hidden",open:a,onClose:l,children:[s(wt.Child,{as:B,enter:"transition-opacity ease-linear duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition-opacity ease-linear duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:s(Mt.Overlay,{className:"fixed inset-0 bg-gray-600 bg-opacity-75"})}),s(wt.Child,{as:B,enter:"transition ease-in-out duration-300 transform",enterFrom:"-translate-x-full",enterTo:"translate-x-0",leave:"transition ease-in-out duration-300 transform",leaveFrom:"translate-x-0",leaveTo:"-translate-x-full",children:s("div",{className:"relative flex-1 flex flex-col max-w-xs w-full pt-5 pb-4 bg-white",children:[s(wt.Child,{as:B,enter:"ease-in-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in-out duration-300",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:s("div",{className:"absolute top-0 right-0 -mr-12 pt-2",children:s("button",{className:"ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white",onClick:()=>l(!1),children:[s("span",{className:"sr-only",children:"Close sidebar"}),s(ws,{className:"h-6 w-6 text-white","aria-hidden":"true"})]})})}),s("div",{className:"flex-shrink-0 flex items-center px-4",children:s("img",{className:"block h-8 w-auto",src:$s,alt:"Flare Benefits"})}),s("div",{className:"mt-5 flex-1 h-0 overflow-y-auto",children:s("nav",{className:"px-2 space-y-1",children:Ci.filter(d=>d.access(r,i)).map(d=>s("a",{href:d.href,onClick:T.handleTrackingOnClick(d.trackingEvent),className:$(o(d.href)?"bg-secondary text-primary":"text-gray-600 hover:bg-secondary hover:text-primary","group flex items-center px-2 py-2 text-base font-medium rounded-md"),children:[s(d.icon,{className:$(o(d.href)?"text-primary":"text-gray-400 group-hover:text-primary","mr-4 flex-shrink-0 h-6 w-6"),"aria-hidden":"true"}),d.name]},d.name))})})]})}),s("div",{className:"flex-shrink-0 w-14","aria-hidden":"true"})]})}),s("div",{className:"hidden md:flex md:flex-shrink-0",children:s("div",{className:"flex flex-col w-64",children:s("div",{className:"flex flex-col flex-grow border-r border-gray-200 pt-5 pb-4 bg-white overflow-y-auto",children:s("div",{className:"mt-5 flex-grow flex flex-col",children:s("nav",{className:"flex-1 px-2 bg-white space-y-1",children:Ci.filter(d=>d.access(r,i)).map(d=>s("a",{href:d.href,onClick:T.handleTrackingOnClick(d.trackingEvent),className:$(o(d.href)?"bg-secondary text-primary":"text-gray-600 hover:bg-secondary hover:text-primary","group flex items-center px-2 py-2 text-sm font-medium rounded-md"),children:[s(d.icon,{className:$(o(d.href)?"text-primary":"text-gray-400 group-hover:text-primary","mr-3 flex-shrink-0 h-6 w-6"),"aria-hidden":"true"}),d.name]},d.name))})})})})}),s("div",{className:"flex flex-col w-0 flex-1 overflow-hidden",children:[s("div",{className:"relative z-10 flex-shrink-0 flex h-16 bg-white",children:s("button",{className:"px-4 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary md:hidden",onClick:()=>l(!0),children:[s("span",{className:"sr-only",children:"Open sidebar"}),s(xs,{className:"h-6 w-6","aria-hidden":"true"})]})}),s("main",{className:"flex flex-col flex-1 overflow-auto focus:outline-none px-4 sm:px-6 lg:px-8 pt-1",children:t.children})]})]})]})},Ai={eventName:"PerkModal"},Dr={eventName:"Perks"},le={eventName:"Perk"};class Yc{async getPageStateAsync(){return at.instance.url("benefits/ui/manage-page").get().json()}async postCustomPerkCommandAsync(e,r){const n={command:r};return at.instance.url(`benefits/edit/${ji(()=>"")(e)}`).post(n).badRequest(()=>{throw new Error("Failed to execute custom perk command")}).json()}async postPerkSetupCommandAsync(e){const r={command:e};return at.instance.url("benefits/perks-setup").post(r).badRequest(()=>{throw new Error("Failed to execute perks setup command")}).text()}}const pe=new Yc;class Hc{constructor(){O(this,"id");O(this,"perkData");O(this,"type");O(this,"isEnabled");O(this,"isFeatured");O(this,"metadata")}static toEditableItem(e){return{type:e.type,id:e.id,data:e.perkData,lastModifiedDate:e.metadata.updatedAt,visibility:{isEnabled:e.isEnabled,isFeatured:e.isFeatured}}}}var Ti,Mi,Oi,tt;function Kc(t,e,r,n,i){var a={};return Object.keys(n).forEach(function(l){a[l]=n[l]}),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce(function(l,o){return o(t,e,l)||l},a),i&&a.initializer!==void 0&&(a.value=a.initializer?a.initializer.call(i):void 0,a.initializer=void 0),a.initializer===void 0?(Object.defineProperty(t,e,a),null):a}function qc(){return{featuredItems:[],editableItemType:"customPerk",filter:"All",selectedItem:j,editDialog:{screen:"hidden"}}}let Gc=(Ti=Wr({name:"perks-manager",cache:{ttl:"3600000"},resettable:!0,producerFn:Yr}),Mi=Li(),Ti(Oi=(tt=class extends Vi{constructor(){super(qc())}removeFromFeatured(e){this.update(e,r=>{r.visibility.isFeatured=!1}),this.update(r=>{r.featuredItems.splice(r.featuredItems.indexOf(e),1)})}},Kc(tt.prototype,"removeFromFeatured",[Mi],Object.getOwnPropertyDescriptor(tt.prototype,"removeFromFeatured"),tt.prototype),tt))||Oi);const ie=new Gc,At=ie;class gt extends Bi{constructor(r){super(r);O(this,"perksStats$",it([this.selectCount(r=>r.type==="customPerk"),this.selectCount(r=>r.type==="marketplacePerk")]).pipe(Ae(([r,n])=>({customPerksCount:r,marketplacePerksCount:n}))));O(this,"editDialogState$",this.select(r=>r.editDialog));O(this,"perksFilter$",this.select(r=>r.filter));O(this,"allFeaturedPerks$",this.selectAll({sortBy:this.orderPerks,filterBy:[({visibility:r})=>r.isFeatured]}));O(this,"filteredFeaturedPerks$",it([this.allFeaturedPerks$,this.select(r=>r.filter)]).pipe(Ae(([r,n])=>gt.filterPerks(r,n))));O(this,"filteredPerks$",it([this.selectAll({sortBy:this.orderPerks,filterBy:[({visibility:r})=>!r.isFeatured]}),this.select(r=>r.filter)]).pipe(Ae(([r,n])=>gt.filterPerks(r,n))));O(this,"isLoading$",this.selectLoading());O(this,"selectedPerk$",this.select(r=>r.selectedItem).pipe(Ui(r=>xe(r)?this.selectEntity(r.value).pipe(Ae(Te)):zi(j))));this.store=r}get getSelectedPerk(){return this.getValue().selectedItem}static filterPerks(r,n){switch(n){case"All":return r;case"Custom":return r.filter(i=>i.type==="customPerk");case"Marketplace":return r.filter(i=>i.type==="marketplacePerk")}}orderPerks(r,n,i){const a=r.visibility.isEnabled===n.visibility.isEnabled?0:r.visibility.isEnabled?-1:1,l=r.data.title.localeCompare(n.data.title);return 2*a+l}}const fe=new gt(ie),Ba=3;class Xc{loadPageState(){return fe.selectCached(()=>Ee(pe.getPageStateAsync(),500),e=>{ie.set(e.allPerks.map(Hc.toEditableItem))})}reloadPageState(){ie.setHasCache(!1)}applyFilter(e){ie.update(r=>{r.filter=e})}async tryAddToFeaturedAsync(e){fe.getValue().featuredItems.length!==Ba&&(await pe.postPerkSetupCommandAsync({addPerkToFeatured:e}),ie.update(e,r=>{r.visibility.isFeatured=!0}),ie.update(r=>{r.featuredItems.push(e)}),lt.reloadViewPageState())}async removeFromFeaturedAsync(e){await pe.postPerkSetupCommandAsync({removePerkFromFeatured:e}),ie.removeFromFeatured(e),lt.reloadViewPageState()}async toggleBenefit(e,r,n){e.visibility.isEnabled?(await pe.postPerkSetupCommandAsync({disablePerk:e.id}),n(e.data)):(await pe.postPerkSetupCommandAsync({enablePerk:e.id}),r(e.data)),Wi(()=>{e.visibility.isEnabled&&ie.removeFromFeatured(e.id),ie.update(e.id,i=>{i.visibility.isEnabled=!i.visibility.isEnabled})}),lt.reloadViewPageState()}}const je=new Xc,Jc=t=>{const[e,r]=A({screen:"hidden"}),[n,i,a]=ln();M(()=>{const u=[fe.editDialogState$.subscribe(r)];return()=>{u.map(y=>y.unsubscribe())}},[]);const l=u=>{const y=u;let g=[];for(const p in y)y[p]||(g=[...g,p]);t.onCancel(g)},o=async(u,y,g)=>{const p=y?{updateCustomPerk:u}:{createCustomPerk:u},D=y?ke(y):j;let E="";try{E=(await pe.postCustomPerkCommandAsync(D,p)).id,i({message:`Perk successfully ${xe(D)?"edited":"added"}.`,level:ve.Success}),t.onSave(u,y)}catch{i({message:`Perk ${xe(D)?"editing":"creation"} failed. Please try again in a few minutes.`,level:ve.Error})}!g&&!y?await pe.postPerkSetupCommandAsync({disablePerk:E}):t.onPublish(u)},c=()=>{je.reloadPageState(),lt.reloadViewPageState()},d=async u=>{await pe.postCustomPerkCommandAsync(ke(u),"deleteCustomPerk"),i({message:"Perk successfully deleted.",level:ve.Success}),t.onDelete(u)},f=u=>Ot.postImageAsync({file:u}),h=u=>Ot.postDocumentAsync({file:u});return s(Va,{uiState:e,store:At,selectedItem:e.screen=="form"&&e.editMode==="edit"?fe.getSelectedPerk:j,save:o,reload:c,delete:d,uploadAttachement:h,uploadImage:f,onCancelEditing:l,onPreview:t.onPreview})},Qc=()=>{const[t,e]=A({customPerksCount:0,marketplacePerksCount:0}),[r,n]=A([]),[i,a]=A([]),[l,o]=A([]),[c,d]=A("All"),[f,h]=A(!0),[u,y]=A([]);M(()=>{o(gt.filterPerks(i,c))},[c,i]),M(()=>{const C=[fe.perksStats$.subscribe(e),fe.filteredPerks$.subscribe(n),fe.perksFilter$.subscribe(d),fe.allFeaturedPerks$.subscribe(a),fe.isLoading$.subscribe(h),je.loadPageState().subscribe()];return()=>{C.map(Y=>Y.unsubscribe())}},[]),M(()=>{if(!f)switch(c){case"All":{T.trackEvent({...Dr,eventAction:"Viewed",perkTab:"all",numberOfPerks:t.customPerksCount+t.marketplacePerksCount});break}case"Marketplace":{T.trackEvent({...Dr,eventAction:"Viewed",perkTab:"marketplace",numberOfPerks:t.marketplacePerksCount});break}case"Custom":T.trackEvent({...Dr,eventAction:"Viewed",perkTab:"custom",numberOfPerks:t.customPerksCount})}},[f,c]);const g=[{name:"All Perks",filterKey:"All",emptyMessage:"No perks to show",getCount:()=>t.customPerksCount+t.marketplacePerksCount},{name:"Marketplace Perks",filterKey:"Marketplace",emptyMessage:"No marketplace perks to show",getCount:()=>t.marketplacePerksCount},{name:"Custom Perks",filterKey:"Custom",emptyMessage:"No custom perks have been added",getCount:()=>t.customPerksCount}],p=()=>{Da(At),T.trackEvent({...Ai,eventAction:"Opened",action:"add"})},D=C=>je.applyFilter(C),E=C=>{C.visibility.isFeatured?(je.removeFromFeaturedAsync(C.id),T.trackEvent({...le,eventAction:"Unfeatured",title:C.data.title})):(je.tryAddToFeaturedAsync(C.id),T.trackEvent({...le,eventAction:"Featured",title:C.data.title}))},F=C=>{const Y=H=>T.trackEvent({...le,eventAction:"Published",title:H.title}),Ge=H=>T.trackEvent({...le,eventAction:"Unpublished",title:H.title});je.toggleBenefit(C,Y,Ge)},b=C=>{T.trackEvent({...le,eventAction:"Published",title:C.title})},L=C=>{Ea(At,C),T.trackEvent({...Ai,eventAction:"Opened",action:"edit"})},q=C=>{Fa(At,C.data),T.trackEvent({...le,eventAction:"Viewed",title:C.data.title})},k=(C,Y)=>{T.trackEvent({...le,eventAction:Y?"Updated":"Created",title:C.title})},S=C=>T.trackEvent({...le,eventAction:"Previewed",title:C.title}),De=C=>T.trackEvent({...le,eventAction:"Abandoned",emptyFields:C.filter(Y=>Y!=="startTime"&&Y!=="endDate"&&Y!=="enableAfterSave"&&Y!=="location")}),qe=C=>{const Y=r.filter(Ge=>Ge.id===C);T.trackEvent({...le,eventAction:"Deleted",title:Y.length>0?Y[0].data.title:C})};return s(rr.Provider,{value:{actionMessages:u,setActionMessages:y},children:[s(Wt,{title:"Perks Manager",subTitle:"Build, maintain and manage your employee perks offering.",buttonTitle:"Add new",isLoading:f,handleButtonClick:p}),s("div",{className:"pt-4",children:s(cn,{tabs:g,filterKey:c,onFilterChanged:D})}),s(on,{className:"pt-4"}),s("div",{className:"flex-auto my-4 h-0 overflow-y-auto hide-scrollbar",children:s(Jr,{children:[f&&s(dn,{}),!f&&s(B,{children:s(Na,{filteredItems:r,featuredItems:{totalCount:i.length,filtered:l},maxFeaturedItems:Ba,emptyMessage:g.filter(C=>C.filterKey===c)[0].emptyMessage,onFeatureClicked:E,onToggleClicked:F,onEditClicked:L,onPreviewClicked:q})})]})}),s(Jc,{onSave:k,onPublish:b,onPreview:S,onCancel:De,onDelete:qe})]})},ud=()=>{const{service:t}=Gr();return M(()=>{ne.setHasCache(!1),ie.setHasCache(!1),t.trackAdminOpenedAsync()},[]),s(Wc,{children:s(Fs,{history:Ls(Ns()),children:[s(xt,{path:"/admin",component:Qc}),s(xt,{path:"/admin/events",component:Uc}),s(xt,{path:"/admin/access",component:Wl}),s(xt,{path:"/admin/collections",component:Ql})]})})};export{ud as default};
|