@embedreach/components 0.3.5 → 0.3.7
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/chunks/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -89,7 +89,7 @@ function s9(e,a){return e?function(e){return"function"==typeof e&&(()=>{const a=
|
|
|
89
89
|
*
|
|
90
90
|
* This source code is licensed under the MIT license found in the
|
|
91
91
|
* LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/fTe.exports="production"===process.env.NODE_ENV?function(){if(gTe)return vTe;gTe=1;var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},t=a.useState,n=a.useEffect,i=a.useLayoutEffect,r=a.useDebugValue;function o(a){var t=a.getSnapshot;a=a.value;try{var n=t();return!e(a,n)}catch(i){return!0}}var s="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(e,a){var s=a(),l=t({inst:{value:s,getSnapshot:a}}),u=l[0].inst,c=l[1];return i((function(){u.value=s,u.getSnapshot=a,o(u)&&c({inst:u})}),[e,s,a]),n((function(){return o(u)&&c({inst:u}),e((function(){o(u)&&c({inst:u})}))}),[e]),r(s),s};return vTe.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:s,vTe}():(yTe||(yTe=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var a=e.getSnapshot;e=e.value;try{var t=a();return!n(e,t)}catch(i){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=a,n="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},i=t.useState,r=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue,l=!1,u=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(a,c){l||void 0===t.startTransition||(l=!0);var d=c();if(!u){var m=c();n(d,m)||(u=!0)}var h=(m=i({inst:{value:d,getSnapshot:c}}))[0].inst,p=m[1];return o((function(){h.value=d,h.getSnapshot=c,e(h)&&p({inst:h})}),[a,d,c]),r((function(){return e(h)&&p({inst:h}),a((function(){e(h)&&p({inst:h})}))}),[a]),s(d),d};bTe.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),bTe);var kTe=fTe.exports,STe='[cmdk-group=""]',wTe='[cmdk-group-items=""]',ATe='[cmdk-item=""]',CTe=`${ATe}:not([aria-disabled="true"])`,MTe="cmdk-item-select",TTe="data-value",xTe=(e,a,t)=>pTe(e,a,t),ETe=r.createContext(void 0),NTe=()=>r.useContext(ETe),_Te=r.createContext(void 0),PTe=()=>r.useContext(_Te),jTe=r.createContext(void 0),LTe=r.forwardRef(((e,a)=>{let t=WTe((()=>{var a,t;return{search:"",value:null!=(t=null!=(a=e.value)?a:e.defaultValue)?t:"",filtered:{count:0,items:new Map,groups:new Set}}})),n=WTe((()=>new Set)),i=WTe((()=>new Map)),o=WTe((()=>new Map)),s=WTe((()=>new Set)),l=JTe(e),{label:u,children:c,value:d,onValueChange:m,filter:h,shouldFilter:p,loop:g,disablePointerSelection:f=!1,vimBindings:v=!0,...y}=e,b=q9(),k=q9(),S=q9(),w=r.useRef(null),A=YTe();UTe((()=>{if(void 0!==d){let e=d.trim();t.current.value=e,C.emit()}}),[d]),UTe((()=>{A(6,_)}),[]);let C=r.useMemo((()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>t.current,setState:(e,a,n)=>{var i,r,o;if(!Object.is(t.current[e],a)){if(t.current[e]=a,"search"===e)N(),x(),A(1,E);else if("value"===e&&(n||A(5,_),void 0!==(null==(i=l.current)?void 0:i.value))){return void(null==(o=(r=l.current).onValueChange)||o.call(r,null!=a?a:""))}C.emit()}},emit:()=>{s.current.forEach((e=>e()))}})),[]),M=r.useMemo((()=>({value:(e,a,n)=>{var i;a!==(null==(i=o.current.get(e))?void 0:i.value)&&(o.current.set(e,{value:a,keywords:n}),t.current.filtered.items.set(e,T(a,n)),A(2,(()=>{x(),C.emit()})))},item:(e,a)=>(n.current.add(e),a&&(i.current.has(a)?i.current.get(a).add(e):i.current.set(a,new Set([e]))),A(3,(()=>{N(),x(),t.current.value||E(),C.emit()})),()=>{o.current.delete(e),n.current.delete(e),t.current.filtered.items.delete(e);let a=P();A(4,(()=>{N(),(null==a?void 0:a.getAttribute("id"))===e&&E(),C.emit()}))}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{o.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:S,labelId:k,listInnerRef:w})),[]);function T(e,a){var n,i;let r=null!=(i=null==(n=l.current)?void 0:n.filter)?i:xTe;return e?r(e,t.current.search,a):0}function x(){if(!t.current.search||!1===l.current.shouldFilter)return;let e=t.current.filtered.items,a=[];t.current.filtered.groups.forEach((t=>{let n=i.current.get(t),r=0;n.forEach((a=>{let t=e.get(a);r=Math.max(t,r)})),a.push([t,r])}));let n=w.current;j().sort(((a,t)=>{var n,i;let r=a.getAttribute("id"),o=t.getAttribute("id");return(null!=(n=e.get(o))?n:0)-(null!=(i=e.get(r))?i:0)})).forEach((e=>{let a=e.closest(wTe);a?a.appendChild(e.parentElement===a?e:e.closest(`${wTe} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${wTe} > *`))})),a.sort(((e,a)=>a[1]-e[1])).forEach((e=>{var a;let t=null==(a=w.current)?void 0:a.querySelector(`${STe}[${TTe}="${encodeURIComponent(e[0])}"]`);null==t||t.parentElement.appendChild(t)}))}function E(){let e=j().find((e=>"true"!==e.getAttribute("aria-disabled"))),a=null==e?void 0:e.getAttribute(TTe);C.setState("value",a||void 0)}function N(){var e,a,r,s;if(!t.current.search||!1===l.current.shouldFilter)return void(t.current.filtered.count=n.current.size);t.current.filtered.groups=new Set;let u=0;for(let i of n.current){let n=T(null!=(a=null==(e=o.current.get(i))?void 0:e.value)?a:"",null!=(s=null==(r=o.current.get(i))?void 0:r.keywords)?s:[]);t.current.filtered.items.set(i,n),n>0&&u++}for(let[n,o]of i.current)for(let e of o)if(t.current.filtered.items.get(e)>0){t.current.filtered.groups.add(n);break}t.current.filtered.count=u}function _(){var e,a,t;let n=P();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(t=null==(a=n.closest(STe))?void 0:a.querySelector('[cmdk-group-heading=""]'))||t.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=w.current)?void 0:e.querySelector(`${ATe}[aria-selected="true"]`)}function j(){var e;return Array.from((null==(e=w.current)?void 0:e.querySelectorAll(CTe))||[])}function L(e){let a=j()[e];a&&C.setState("value",a.getAttribute(TTe))}function B(e){var a;let t=P(),n=j(),i=n.findIndex((e=>e===t)),r=n[i+e];null!=(a=l.current)&&a.loop&&(r=i+e<0?n[n.length-1]:i+e===n.length?n[0]:n[i+e]),r&&C.setState("value",r.getAttribute(TTe))}function R(e){let a,t=P(),n=null==t?void 0:t.closest(STe);for(;n&&!a;)n=e>0?GTe(n,STe):VTe(n,STe),a=null==n?void 0:n.querySelector(CTe);a?C.setState("value",a.getAttribute(TTe)):B(e)}let D=()=>L(j().length-1),z=e=>{e.preventDefault(),e.metaKey?D():e.altKey?R(1):B(1)},O=e=>{e.preventDefault(),e.metaKey?L(0):e.altKey?R(-1):B(-1)};return r.createElement(y9.div,{ref:a,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:e=>{var a;if(null==(a=y.onKeyDown)||a.call(y,e),!e.defaultPrevented)switch(e.key){case"n":case"j":v&&e.ctrlKey&&z(e);break;case"ArrowDown":z(e);break;case"p":case"k":v&&e.ctrlKey&&O(e);break;case"ArrowUp":O(e);break;case"Home":e.preventDefault(),L(0);break;case"End":e.preventDefault(),D();break;case"Enter":if(!e.nativeEvent.isComposing&&229!==e.keyCode){e.preventDefault();let a=P();if(a){let e=new Event(MTe);a.dispatchEvent(e)}}}}},r.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:XTe},u),QTe(e,(e=>r.createElement(_Te.Provider,{value:C},r.createElement(ETe.Provider,{value:M},e)))))})),BTe=r.forwardRef(((e,a)=>{var t,n;let i=q9(),o=r.useRef(null),s=r.useContext(jTe),l=NTe(),u=JTe(e),c=null!=(n=null==(t=u.current)?void 0:t.forceMount)?n:null==s?void 0:s.forceMount;UTe((()=>{if(!c)return l.item(i,null==s?void 0:s.id)}),[c]);let d=ZTe(i,o,[e.value,e.children,o],e.keywords),m=PTe(),h=$Te((e=>e.value&&e.value===d.current)),p=$Te((e=>!(!c&&!1!==l.filter())||(!e.search||e.filtered.items.get(i)>0)));function g(){var e,a;f(),null==(a=(e=u.current).onSelect)||a.call(e,d.current)}function f(){m.setState("value",d.current,!0)}if(r.useEffect((()=>{let a=o.current;if(a&&!e.disabled)return a.addEventListener(MTe,g),()=>a.removeEventListener(MTe,g)}),[p,e.onSelect,e.disabled]),!p)return null;let{disabled:v,value:y,onSelect:b,forceMount:k,keywords:S,...w}=e;return r.createElement(y9.div,{ref:qTe([o,a]),...w,id:i,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!h,"data-disabled":!!v,"data-selected":!!h,onPointerMove:v||l.getDisablePointerSelection()?void 0:f,onClick:v?void 0:g},e.children)})),RTe=r.forwardRef(((e,a)=>{let{heading:t,children:n,forceMount:i,...o}=e,s=q9(),l=r.useRef(null),u=r.useRef(null),c=q9(),d=NTe(),m=$Te((e=>!(!i&&!1!==d.filter())||(!e.search||e.filtered.groups.has(s))));UTe((()=>d.group(s)),[]),ZTe(s,l,[e.value,e.heading,u]);let h=r.useMemo((()=>({id:s,forceMount:i})),[i]);return r.createElement(y9.div,{ref:qTe([l,a]),...o,"cmdk-group":"",role:"presentation",hidden:!m||void 0},t&&r.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),QTe(e,(e=>r.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},r.createElement(jTe.Provider,{value:h},e)))))})),DTe=r.forwardRef(((e,a)=>{let{alwaysRender:t,...n}=e,i=r.useRef(null),o=$Te((e=>!e.search));return t||o?r.createElement(y9.div,{ref:qTe([i,a]),...n,"cmdk-separator":"",role:"separator"}):null})),zTe=r.forwardRef(((e,a)=>{let{onValueChange:t,...n}=e,i=null!=e.value,o=PTe(),s=$Te((e=>e.search)),l=$Te((e=>e.value)),u=NTe(),c=r.useMemo((()=>{var e;let a=null==(e=u.listInnerRef.current)?void 0:e.querySelector(`${ATe}[${TTe}="${encodeURIComponent(l)}"]`);return null==a?void 0:a.getAttribute("id")}),[]);return r.useEffect((()=>{null!=e.value&&o.setState("search",e.value)}),[e.value]),r.createElement(y9.input,{ref:a,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":c,id:u.inputId,type:"text",value:i?e.value:s,onChange:e=>{i||o.setState("search",e.target.value),null==t||t(e.target.value)}})})),OTe=r.forwardRef(((e,a)=>{let{children:t,label:n="Suggestions",...i}=e,o=r.useRef(null),s=r.useRef(null),l=NTe();return r.useEffect((()=>{if(s.current&&o.current){let e,a=s.current,t=o.current,n=new ResizeObserver((()=>{e=requestAnimationFrame((()=>{t.style.setProperty("--cmdk-list-height",a.offsetHeight.toFixed(1)+"px")}))}));return n.observe(a),()=>{cancelAnimationFrame(e),n.unobserve(a)}}}),[]),r.createElement(y9.div,{ref:qTe([o,a]),...i,"cmdk-list":"",role:"listbox","aria-label":n,id:l.listId},QTe(e,(e=>r.createElement("div",{ref:qTe([s,l.listInnerRef]),"cmdk-list-sizer":""},e))))})),KTe=r.forwardRef(((e,a)=>{let{open:t,onOpenChange:n,overlayClassName:i,contentClassName:o,container:s,...l}=e;return r.createElement(jZ,{open:t,onOpenChange:n},r.createElement(BZ,{container:s},r.createElement(RZ,{"cmdk-overlay":"",className:i}),r.createElement(DZ,{"aria-label":e.label,"cmdk-dialog":"",className:o},r.createElement(LTe,{ref:a,...l}))))})),HTe=r.forwardRef(((e,a)=>$Te((e=>0===e.filtered.count))?r.createElement(y9.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null)),ITe=r.forwardRef(((e,a)=>{let{progress:t,children:n,label:i="Loading...",...o}=e;return r.createElement(y9.div,{ref:a,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},QTe(e,(e=>r.createElement("div",{"aria-hidden":!0},e))))})),FTe=Object.assign(LTe,{List:OTe,Item:BTe,Input:zTe,Group:RTe,Separator:DTe,Dialog:KTe,Empty:HTe,Loading:ITe});function GTe(e,a){let t=e.nextElementSibling;for(;t;){if(t.matches(a))return t;t=t.nextElementSibling}}function VTe(e,a){let t=e.previousElementSibling;for(;t;){if(t.matches(a))return t;t=t.previousElementSibling}}function JTe(e){let a=r.useRef(e);return UTe((()=>{a.current=e})),a}var UTe="undefined"==typeof window?r.useEffect:r.useLayoutEffect;function WTe(e){let a=r.useRef();return void 0===a.current&&(a.current=e()),a}function qTe(e){return a=>{e.forEach((e=>{"function"==typeof e?e(a):null!=e&&(e.current=a)}))}}function $Te(e){let a=PTe(),t=()=>e(a.snapshot());return kTe.useSyncExternalStore(a.subscribe,t,t)}function ZTe(e,a,t,n=[]){let i=r.useRef(),o=NTe();return UTe((()=>{var r;let s=(()=>{var e;for(let a of t){if("string"==typeof a)return a.trim();if("object"==typeof a&&"current"in a)return a.current?null==(e=a.current.textContent)?void 0:e.trim():i.current}})(),l=n.map((e=>e.trim()));o.value(e,s,l),null==(r=a.current)||r.setAttribute(TTe,s),i.current=s})),i}var YTe=()=>{let[e,a]=r.useState(),t=WTe((()=>new Map));return UTe((()=>{t.current.forEach((e=>e())),t.current=new Map}),[e]),(e,n)=>{t.current.set(e,n),a({})}};function QTe({asChild:e,children:a},t){return e&&r.isValidElement(a)?r.cloneElement(function(e){let a=e.type;return"function"==typeof a?a(e.props):"render"in a?a.render(e.props):e}(a),{ref:a.ref},t(a.props.children)):t(a)}var XTe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const exe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe,{ref:n,className:XO("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a})));exe.displayName=FTe.displayName;const axe=r.forwardRef((({className:e,searchIcon:a,...n},i)=>t.jsxs("div",{className:"flex items-center border-b px-3",children:[a||t.jsx(Iz,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 "}),t.jsx(FTe.Input,{ref:i,className:XO("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]})));axe.displayName=FTe.Input.displayName;const txe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.List,{ref:n,className:XO("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a})));txe.displayName=FTe.List.displayName;const nxe=r.forwardRef(((e,a)=>t.jsx(FTe.Empty,{ref:a,className:"py-6 text-center text-sm",...e})));nxe.displayName=FTe.Empty.displayName;const ixe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.Group,{ref:n,className:XO("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...a})));ixe.displayName=FTe.Group.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.Separator,{ref:n,className:XO("-mx-1 h-px bg-border",e),...a}))).displayName=FTe.Separator.displayName;const rxe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.Item,{ref:n,className:XO("relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...a})));function oxe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function sxe(...e){return a=>{let t=!1;const n=e.map((e=>{const n=oxe(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():oxe(e[a],null)}}}}function lxe(...e){return r.useCallback(sxe(...e),e)}function uxe(e){const a=cxe(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(mxe);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function cxe(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{const a=r(...e);return i(...e),a}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?sxe(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}rxe.displayName=FTe.Item.displayName;var dxe=Symbol("radix.slottable");function mxe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===dxe}var hxe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=uxe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),pxe=globalThis?.document?r.useLayoutEffect:()=>{};var gxe=e=>{const{present:a,children:t}=e,n=function(e){const[a,t]=r.useState(),n=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,t)=>a[e][t]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=fxe(n.current);o.current="mounted"===l?e:"none"}),[l]),pxe((()=>{const a=n.current,t=i.current;if(t!==e){const n=o.current,r=fxe(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(t&&n!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),pxe((()=>{if(a){let e;const t=a.ownerDocument.defaultView??window,r=r=>{const o=fxe(n.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const n=a.style.animationFillMode;a.style.animationFillMode="forwards",e=t.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=n)}))}},s=e=>{e.target===a&&(o.current=fxe(n.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{t.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{n.current=e?getComputedStyle(e):null,t(e)}),[])}}(a),i="function"==typeof t?t({present:n.isPresent}):r.Children.only(t),o=lxe(n.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof t||n.isPresent?r.cloneElement(i,{ref:o}):null};function fxe(e){return e?.animationName||"none"}function vxe(...e){const a=e[0];if(1===e.length)return a;const t=()=>{const t=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const n=t.reduce(((a,{useScope:t,scopeName:n})=>({...a,...t(e)[`__scope${n}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:n})),[n])}};return t.scopeName=a.scopeName,t}function yxe(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}gxe.displayName="Presence";var bxe=r.createContext(void 0);function kxe(e,a,{checkForDefaultPrevented:t=!0}={}){return function(n){if(e?.(n),!1===t||!n.defaultPrevented)return a?.(n)}}var Sxe="ScrollArea",[wxe,Axe]=function(e,a=[]){let n=[];const i=()=>{const a=n.map((e=>r.createContext(e)));return function(t){const n=t?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...t,[e]:n}})),[t,n])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=n.length;n=[...n,i];const l=a=>{const{scope:n,children:i,...l}=a,u=n?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return t.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(t,n){const l=r.useContext(n?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${a}\``)}]},vxe(i,...a)]}(Sxe),[Cxe,Mxe]=wxe(Sxe),Txe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,type:i="hover",dir:o,scrollHideDelay:s=600,...l}=e,[u,c]=r.useState(null),[d,m]=r.useState(null),[h,p]=r.useState(null),[g,f]=r.useState(null),[v,y]=r.useState(null),[b,k]=r.useState(0),[S,w]=r.useState(0),[A,C]=r.useState(!1),[M,T]=r.useState(!1),x=lxe(a,(e=>c(e))),E=function(e){const a=r.useContext(bxe);return e||a||"ltr"}(o);return t.jsx(Cxe,{scope:n,type:i,dir:E,scrollHideDelay:s,scrollArea:u,viewport:d,onViewportChange:m,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:f,scrollbarXEnabled:A,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:M,onScrollbarYEnabledChange:T,onCornerWidthChange:k,onCornerHeightChange:w,children:t.jsx(hxe.div,{dir:E,...l,ref:x,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})}));Txe.displayName=Sxe;var xxe="ScrollAreaViewport",Exe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,children:i,nonce:o,...s}=e,l=Mxe(xxe,n),u=lxe(a,r.useRef(null),l.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),t.jsx(hxe.div,{"data-radix-scroll-area-viewport":"",...s,ref:u,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})}));Exe.displayName=xxe;var Nxe="ScrollAreaScrollbar",_xe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:l}=o,u="horizontal"===e.orientation;return r.useEffect((()=>(u?s(!0):l(!0),()=>{u?s(!1):l(!1)})),[u,s,l]),"hover"===o.type?t.jsx(Pxe,{...i,ref:a,forceMount:n}):"scroll"===o.type?t.jsx(jxe,{...i,ref:a,forceMount:n}):"auto"===o.type?t.jsx(Lxe,{...i,ref:a,forceMount:n}):"always"===o.type?t.jsx(Bxe,{...i,ref:a}):null}));_xe.displayName=Nxe;var Pxe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),[s,l]=r.useState(!1);return r.useEffect((()=>{const e=o.scrollArea;let a=0;if(e){const t=()=>{window.clearTimeout(a),l(!0)},n=()=>{a=window.setTimeout((()=>l(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",t),e.addEventListener("pointerleave",n),()=>{window.clearTimeout(a),e.removeEventListener("pointerenter",t),e.removeEventListener("pointerleave",n)}}}),[o.scrollArea,o.scrollHideDelay]),t.jsx(gxe,{present:n||s,children:t.jsx(Lxe,{"data-state":s?"visible":"hidden",...i,ref:a})})})),jxe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),s="horizontal"===e.orientation,l=Xxe((()=>c("SCROLL_END")),100),[u,c]=(d={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer(((e,a)=>d[e][a]??e),"hidden"));var d;return r.useEffect((()=>{if("idle"===u){const e=window.setTimeout((()=>c("HIDE")),o.scrollHideDelay);return()=>window.clearTimeout(e)}}),[u,o.scrollHideDelay,c]),r.useEffect((()=>{const e=o.viewport,a=s?"scrollLeft":"scrollTop";if(e){let t=e[a];const n=()=>{const n=e[a];t!==n&&(c("SCROLL"),l()),t=n};return e.addEventListener("scroll",n),()=>e.removeEventListener("scroll",n)}}),[o.viewport,s,c,l]),t.jsx(gxe,{present:n||"hidden"!==u,children:t.jsx(Bxe,{"data-state":"hidden"===u?"hidden":"visible",...i,ref:a,onPointerEnter:kxe(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:kxe(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),Lxe=r.forwardRef(((e,a)=>{const n=Mxe(Nxe,e.__scopeScrollArea),{forceMount:i,...o}=e,[s,l]=r.useState(!1),u="horizontal"===e.orientation,c=Xxe((()=>{if(n.viewport){l(u?n.viewport.offsetWidth<n.viewport.scrollWidth:n.viewport.offsetHeight<n.viewport.scrollHeight)}}),10);return eEe(n.viewport,c),eEe(n.content,c),t.jsx(gxe,{present:i||s,children:t.jsx(Bxe,{"data-state":s?"visible":"hidden",...o,ref:a})})})),Bxe=r.forwardRef(((e,a)=>{const{orientation:n="vertical",...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),s=r.useRef(null),l=r.useRef(0),[u,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Wxe(u.viewport,u.content),m={...i,sizes:u,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:e=>l.current=e};function h(e,a){return function(e,a,t,n="ltr"){const i=qxe(t),r=i/2,o=a||r,s=t.scrollbar.paddingStart+o,l=t.scrollbar.size-t.scrollbar.paddingEnd-(i-o),u=t.content-t.viewport,c="ltr"===n?[0,u]:[-1*u,0];return Zxe([s,l],c)(e)}(e,l.current,u,a)}return"horizontal"===n?t.jsx(Rxe,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=$xe(o.viewport.scrollLeft,u,o.dir);s.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=h(e,o.dir))}}):"vertical"===n?t.jsx(Dxe,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=$xe(o.viewport.scrollTop,u);s.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=h(e))}}):null})),Rxe=r.forwardRef(((e,a)=>{const{sizes:n,onSizesChange:i,...o}=e,s=Mxe(Nxe,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=lxe(a,c,s.onScrollbarXChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),t.jsx(Kxe,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":qxe(n)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.x),onDragScroll:a=>e.onDragScroll(a.x),onWheelScroll:(a,t)=>{if(s.viewport){const n=s.viewport.scrollLeft+a.deltaX;e.onWheelScroll(n),Yxe(n,t)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Uxe(l.paddingLeft),paddingEnd:Uxe(l.paddingRight)}})}})})),Dxe=r.forwardRef(((e,a)=>{const{sizes:n,onSizesChange:i,...o}=e,s=Mxe(Nxe,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=lxe(a,c,s.onScrollbarYChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),t.jsx(Kxe,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":qxe(n)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.y),onDragScroll:a=>e.onDragScroll(a.y),onWheelScroll:(a,t)=>{if(s.viewport){const n=s.viewport.scrollTop+a.deltaY;e.onWheelScroll(n),Yxe(n,t)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Uxe(l.paddingTop),paddingEnd:Uxe(l.paddingBottom)}})}})})),[zxe,Oxe]=wxe(Nxe),Kxe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,sizes:i,hasThumb:o,onThumbChange:s,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...p}=e,g=Mxe(Nxe,n),[f,v]=r.useState(null),y=lxe(a,(e=>v(e))),b=r.useRef(null),k=r.useRef(""),S=g.viewport,w=i.content-i.viewport,A=yxe(m),C=yxe(c),M=Xxe(h,10);function T(e){if(b.current){d({x:e.clientX-b.current.left,y:e.clientY-b.current.top})}}return r.useEffect((()=>{const e=e=>{const a=e.target,t=f?.contains(a);t&&A(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[S,f,w,A]),r.useEffect(C,[i,C]),eEe(f,M),eEe(g.content,M),t.jsx(zxe,{scope:n,scrollbar:f,hasThumb:o,onThumbChange:yxe(s),onThumbPointerUp:yxe(l),onThumbPositionChange:C,onThumbPointerDown:yxe(u),children:t.jsx(hxe.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:kxe(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),b.current=f.getBoundingClientRect(),k.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(e)}})),onPointerMove:kxe(e.onPointerMove,T),onPointerUp:kxe(e.onPointerUp,(e=>{const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=k.current,g.viewport&&(g.viewport.style.scrollBehavior=""),b.current=null}))})})})),Hxe="ScrollAreaThumb",Ixe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,r=Oxe(Hxe,e.__scopeScrollArea);return t.jsx(gxe,{present:n||r.hasThumb,children:t.jsx(Fxe,{ref:a,...i})})})),Fxe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,style:i,...o}=e,s=Mxe(Hxe,n),l=Oxe(Hxe,n),{onThumbPositionChange:u}=l,c=lxe(a,(e=>l.onThumbChange(e))),d=r.useRef(void 0),m=Xxe((()=>{d.current&&(d.current(),d.current=void 0)}),100);return r.useEffect((()=>{const e=s.viewport;if(e){const a=()=>{if(m(),!d.current){const a=Qxe(e,u);d.current=a,u()}};return u(),e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}}),[s.viewport,m,u]),t.jsx(hxe.div,{"data-state":l.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:kxe(e.onPointerDownCapture,(e=>{const a=e.target.getBoundingClientRect();l.onThumbPointerDown({x:e.clientX-a.left,y:e.clientY-a.top})})),onPointerUp:kxe(e.onPointerUp,l.onThumbPointerUp)})}));Ixe.displayName=Hxe;var Gxe="ScrollAreaCorner",Vxe=r.forwardRef(((e,a)=>{const n=Mxe(Gxe,e.__scopeScrollArea),i=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&i?t.jsx(Jxe,{...e,ref:a}):null}));Vxe.displayName=Gxe;var Jxe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,...i}=e,o=Mxe(Gxe,n),[s,l]=r.useState(0),[u,c]=r.useState(0),d=Boolean(s&&u);return eEe(o.scrollbarX,(()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)})),eEe(o.scrollbarY,(()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),l(e)})),d?t.jsx(hxe.div,{...i,ref:a,style:{width:s,height:u,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null}));function Uxe(e){return e?parseInt(e,10):0}function Wxe(e,a){const t=e/a;return isNaN(t)?0:t}function qxe(e){const a=Wxe(e.viewport,e.content);return Math.max((e.scrollbar.size-(e.scrollbar.paddingStart+e.scrollbar.paddingEnd))*a,18)}function $xe(e,a,t="ltr"){const n=qxe(a),i=a.content-a.viewport,r=a.scrollbar.size-(a.scrollbar.paddingStart+a.scrollbar.paddingEnd)-n,o=function(e,[a,t]){return Math.min(t,Math.max(a,e))}(e,"ltr"===t?[0,i]:[-1*i,0]);return Zxe([0,i],[0,r])(o)}function Zxe(e,a){return t=>{if(e[0]===e[1]||a[0]===a[1])return a[0];return a[0]+(a[1]-a[0])/(e[1]-e[0])*(t-e[0])}}function Yxe(e,a){return e>0&&e<a}var Qxe=(e,a=()=>{})=>{let t={left:e.scrollLeft,top:e.scrollTop},n=0;return function i(){const r={left:e.scrollLeft,top:e.scrollTop};(t.left!==r.left||t.top!==r.top)&&a(),t=r,n=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(n)};function Xxe(e,a){const t=yxe(e),n=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(n.current)),[]),r.useCallback((()=>{window.clearTimeout(n.current),n.current=window.setTimeout(t,a)}),[t,a])}function eEe(e,a){const t=yxe(a);pxe((()=>{let a=0;if(e){const n=new ResizeObserver((()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(t)}));return n.observe(e),()=>{window.cancelAnimationFrame(a),n.unobserve(e)}}}),[e,t])}var aEe=Txe,tEe=Exe,nEe=Vxe;const iEe=r.forwardRef((({className:e,children:a,...n},i)=>t.jsxs(aEe,{ref:i,className:$Z("relative overflow-hidden",e),...n,children:[t.jsx(tEe,{className:"h-full w-full rounded-[inherit]",children:a}),t.jsx(rEe,{}),t.jsx(nEe,{})]})));iEe.displayName=aEe.displayName;const rEe=r.forwardRef((({className:e,orientation:a="vertical",...n},i)=>t.jsx(_xe,{ref:i,orientation:a,className:$Z("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:t.jsx(Ixe,{className:"relative flex-1 rounded-full bg-border"})})));rEe.displayName=_xe.displayName;var oEe=r.forwardRef(((e,a)=>{const{children:n,...i}=e,o=r.Children.toArray(n),s=o.find(uEe);if(s){const e=s.props.children,n=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(sEe,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,n):null})}return t.jsx(sEe,{...i,ref:a,children:n})}));oEe.displayName="Slot";var sEe=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?IZ(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));sEe.displayName="SlotClone";var lEe=({children:e})=>t.jsx(t.Fragment,{children:e});function uEe(e){return r.isValidElement(e)&&e.type===lEe}var cEe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const n=r.forwardRef(((e,n)=>{const{asChild:i,...r}=e,o=i?oEe:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(o,{...r,ref:n})}));return n.displayName=`Primitive.${a}`,{...e,[a]:n}}),{}),dEe="horizontal",mEe=["horizontal","vertical"],hEe=r.forwardRef(((e,a)=>{const{decorative:n,orientation:i=dEe,...r}=e,o=function(e){return mEe.includes(e)}(i)?i:dEe;return t.jsx(cEe.div,{"data-orientation":o,...n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...r,ref:a})}));hEe.displayName="Separator";var pEe=hEe;const gEe=r.forwardRef((({className:e,orientation:a="horizontal",decorative:n=!0,...i},r)=>t.jsx(pEe,{ref:r,decorative:n,orientation:a,className:XO("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...i})));function fEe({options:e,onValueChange:a,selectedValues:n,setSelectedValues:i,maxCount:o,placeholder:s="Select options",title:l="Select Items",searchPlaceholder:u="Search items...",emptyMessage:c="No items found",extraCommandItems:d=[],canOpen:m=!0,singleSelect:h=!1}){const[p,g]=r.useState(!1),[f,v]=r.useState(""),[y,b]=r.useState(n),k=r.useMemo((()=>Array.from(new Map([...e].filter((e=>e&&"string"==typeof e.value&&"string"==typeof e.label&&""!==e.value.trim()&&""!==e.label.trim())).map((e=>[e.value,e]))).values())),[e]),S=r.useMemo((()=>{if(!f)return k;return[...k.filter((e=>y.includes(e.value))),...k.filter((e=>!y.includes(e.value))).filter((e=>e.label.toLowerCase().includes(f.toLowerCase())))]}),[k,f,y]),w=r.useCallback((()=>n.map((a=>{const t=e.find((e=>e.value===a));return{value:a,label:t?.label||a}}))),[n,e]),A=e=>{if(h)return b([e]),a([e]),i([e]),void g(!1);b((a=>a.includes(e)?a.filter((a=>a!==e)):o&&a.length>=o?a:[...a,e]))};r.useEffect((()=>{p&&(b(n),v(""))}),[p,n]);const C=y.length,M=S.filter((e=>y.includes(e.value))).length,T=w(),x=!o||y.length<o,E=r.useMemo((()=>S.filter((e=>y.includes(e.value)))),[S,y]),N=r.useMemo((()=>S.filter((e=>!y.includes(e.value)))),[S,y]);return t.jsxs(ZZ,{open:p&&m,onOpenChange:m?g:void 0,children:[t.jsx(YZ,{asChild:!0,children:t.jsxs(H5,{variant:"outline",disabled:!m,className:XO("w-full justify-between text-left font-normal h-9 p-3",!m&&"opacity-50 cursor-not-allowed"),children:[t.jsx("div",{className:"flex flex-nowrap items-center gap-1 max-w-[70%]",children:0===T.length?t.jsx("span",{className:"text-muted-foreground",children:s}):h?t.jsx(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label}):T.length<=2?T.map((e=>t.jsx(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:e.label},e.value))):t.jsxs(t.Fragment,{children:[t.jsx(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label},T[0].value),t.jsxs(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:["+",T.length-1," more"]})]})}),t.jsx(V5.DropdownMenuTrigger,{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0"})]})}),t.jsxs(eY,{className:"max-w-md w-full max-h-[80vh] p-0",children:[t.jsx(aY,{className:"p-6 pb-4",children:t.jsxs(nY,{className:"flex items-center gap-2 text-xl",children:[t.jsx(V5.UsersIcon,{className:"h-5 w-5 text-primary"}),l]})}),t.jsx("div",{className:"px-6 pb-4",children:t.jsxs("div",{className:"relative",children:[t.jsx(V5.SearchIcon,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(gte,{placeholder:u,value:f,onChange:e=>v(e.target.value),className:"pl-10 h-11"})]})}),!h&&t.jsx("div",{className:"px-6 pb-4",children:t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsxs("span",{className:"text-muted-foreground",children:[C," of ",k.length," selected",o&&` (max ${o})`]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H5,{variant:"ghost",size:"sm",onClick:()=>{const e=S.filter((e=>!y.includes(e.value))),a=o?e.slice(0,o-y.length):e;b((e=>[...e,...a.map((e=>e.value))]))},disabled:!x||M===S.length,className:"h-8 text-xs",children:"Select All"}),t.jsx(H5,{variant:"ghost",size:"sm",onClick:()=>{const e=new Set(S.map((e=>e.value)));b((a=>a.filter((a=>!e.has(a)))))},disabled:0===M,className:"h-8 text-xs",children:"Clear All"})]})]})}),t.jsx(gEe,{}),t.jsx(iEe,{className:"flex-1 max-h-[300px]",children:t.jsx(exe,{className:"rounded-none border-none",children:t.jsxs(ixe,{children:[d.length>0&&t.jsxs(t.Fragment,{children:[d.map(((e,a)=>t.jsx("div",{className:"px-3 py-2",children:e(g)},`extra-command-${a}`))),t.jsx(gEe,{className:"my-2"})]}),0===S.length?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(V5.SearchIcon,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:c})]}):t.jsxs(t.Fragment,{children:[!h&&E.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:["Selected (",E.length,")"]}),E.map((e=>t.jsxs(rxe,{onSelect:()=>A(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors hover:bg-muted/50 cursor-pointer",children:[t.jsx(oTe,{checked:!0,disabled:!1,onChange:()=>A(e.value),className:"flex-shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),t.jsx(V5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value))),t.jsx(gEe,{className:"my-2"})]}),t.jsx("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:h?"Options":`Available (${N.length})`}),N.map((e=>{const a=y.includes(e.value),n=!h&&!x;return t.jsxs(rxe,{onSelect:()=>!n&&A(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors "+(n?"opacity-50 cursor-not-allowed":"hover:bg-muted/50 cursor-pointer"),children:[!h&&t.jsx(oTe,{checked:a,disabled:n,onChange:()=>!n&&A(e.value),className:"flex-shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),a&&t.jsx(V5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value)}))]})]})})}),!h&&t.jsxs(t.Fragment,{children:[t.jsx(gEe,{}),t.jsx("div",{className:"p-6 pt-4",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(H5,{variant:"outline",onClick:()=>{b(n),v(""),g(!1)},className:"flex-1",children:"Cancel"}),t.jsxs(H5,{onClick:()=>{a(y),i(y),g(!1)},className:"flex-1 bg-primary hover:bg-primary/90",children:["Apply (",C,")"]})]})})]})]})]})}gEe.displayName=pEe.displayName;const vEe=e=>t.jsx(lye,{as:"span",className:"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200",children:e.node.attrs.displayName}),yEe=Pve.create({name:"mergeField",group:"inline",inline:!0,atom:!0,addAttributes:()=>({templateName:{default:null,parseHTML:e=>e.getAttribute("data-template-name")},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name")}}),parseHTML:()=>[{tag:"span[data-merge-field]"}],renderHTML:({HTMLAttributes:e})=>["span",vfe(e,{"data-merge-field":"true"})],renderText:({node:e})=>e.attrs.templateName,addNodeView:()=>hye(vEe)}),bEe=({value:e,onChange:n,maxLength:i,mergeFieldsResponse:r,editorRef:o})=>{const[s,l]=a.useState(0),u=a.useMemo((()=>r?.mergeFields?.flatMap((e=>e.entries))??[]),[r]),c=a.useCallback((e=>{if(!e)return"";return e.replace(/\{\{.*?\}\}/g,(e=>{const a=u.find((a=>a.value===e));return a?`<span class="inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200" data-merge-field="true" data-template-name="${a.value}" data-display-name="${a.label}">${a.label}</span>`:e}))}),[u]),d=oye({extensions:[Mbe,yEe],content:"",editorProps:{attributes:{class:"min-h-[300px] p-3 border border-gray-200 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none prose prose-sm max-w-none"}},onUpdate:({editor:e})=>{const a=e.getText();l(a.length),n(a)}});a.useEffect((()=>{if(d&&e){if(d.getText()!==e){const a=c(e);d.commands.setContent(a,!1),l(e.length)}}}),[d,e,c]);const m=a.useCallback((e=>{if(e.length>0&&d){const a=u.find((a=>a.value===e[0]));a&&d.chain().focus().insertContent({type:"mergeField",attrs:{templateName:a.value,displayName:a.label}}).run()}}),[d,u]),h=a.useMemo((()=>u.map((e=>({label:e.label,value:e.value})))),[u]),p=((e,a)=>({colorClass:e>=a?"text-red-500":e>320?"text-amber-500":"text-gray-500",text:`${e}/${a} characters`}))(s,i);return d?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{ref:o,children:t.jsx(Jve,{editor:d})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(fEe,{options:h,selectedValues:[],setSelectedValues:()=>{},onValueChange:m,placeholder:"Add merge field",title:"Merge Fields",searchPlaceholder:"Search merge fields...",emptyMessage:"No merge fields found",singleSelect:!0}),t.jsx(Fue,{title:"Merge Fields"})]}),t.jsxs("div",{className:`flex items-center gap-2 text-sm transition-colors duration-300 ${p.colorClass}`,children:[p.text,s>jwe&&t.jsx(Fue,{title:"The maximum number of characters for an SMS is 1500. This includes the company name, if you have one, and the merge fields. The recommended limit is 320 characters for best delivery rates. Click to learn more",onClick:()=>{window.open("https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging","_blank")},link:{url:"https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging",text:"The maximum number of characters for an SMS is 1500. This includes the company name, if you have one, and the merge fields. The recommended limit is 320 characters for best delivery rates. Click to learn more"}})]})]})]}):t.jsx("div",{children:"Loading editor..."})},kEe=({mergeFieldsResponse:e})=>{const n=B5(),i=R5(),{data:r}=$re(),o=a.useCallback((()=>{const e=n?.actionData?.find((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId===i?.id));return e?.actionMetadata.communicationGroupId}),[n?.actionData,i?.id]),{channelSenders:s}=Jre(),{data:l,isLoading:u}=Twe(),{channelAccounts:c}=Fre(),{toast:d}=Ve(),{updateCommunicationGroup:m,isUpdating:h}=Ye(),[p,g]=a.useState(null),[f,v]=a.useState(!1),[y,b]=a.useState(null),[k,S]=a.useState(null),[w,A]=a.useState([]),[C,M]=a.useState(null),[T,x]=a.useState(!1),[E,N]=a.useState(!1),_=a.useRef(null),[P,j]=a.useState(null),[L,B]=a.useState(null),[R,D]=a.useState(!1),z=a.useMemo((()=>Nle({channelSenders:s?.results??[],channelAccounts:c?.results??[],smsApplication:r})),[s,c,r]);a.useEffect((()=>{T||(j(w.length>0?w[0]:null),B(null),D(!1))}),[T,w]),a.useEffect((()=>{i?.textMessageMediaUrls&&A(i.textMessageMediaUrls)}),[i?.textMessageMediaUrls]);a.useEffect((()=>{i&&!1===E&&(i.smsChannelSenderId&&null===p&&g(i.smsChannelSenderId),i.smsMessageBody&&null===k&&(S(i.smsMessageBody),M(i.smsMessageBody)),i.textMessageCompanyName&&null===y&&b(i.textMessageCompanyName),i.textMessageMediaUrls&&0===w.length&&A(i.textMessageMediaUrls),T&&(null===C&&M(k),w.length>0&&!P&&!R&&j(w[0])),void 0!==s&&E&&(p?p&&i?.id&&m({groupId:i.id,params:{smsChannelSenderId:p}}):z?.[0]&&(g(z[0].channelSender.id),i?.id&&m({groupId:i.id,params:{smsChannelSenderId:z[0].channelSender.id}}))),N(!0))}),[i,p,k,y,w,E,T,C,P,R,s,z,m]);a.useEffect((()=>{y||!l?.name||f||(v(!0),b(l.branding?.brandName?l.branding?.brandName:l.name))}),[y,l?.name,f,l?.branding?.brandName]);return c&&s&&!u&&void 0!==z&&void 0!==r?0===z?.length&&r?.status!==Ele.PENDING?t.jsx(zMe,{}):t.jsxs("div",{children:[t.jsx(ZZ,{open:T,onOpenChange:x,children:t.jsxs(eY,{hideCloseButton:!0,className:"max-w-[50vw]",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"SMS Editor"}),t.jsx(iY,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),t.jsxs("div",{className:"",children:[P&&t.jsx("div",{className:"flex justify-center mb-6",children:t.jsx("div",{className:"relative group w-fit",children:t.jsx("img",{src:P,alt:"SMS attachment preview",className:"max-h-48 max-w-xs rounded-xl shadow-lg border border-gray-200 object-contain bg-white transition-transform duration-200",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}})})}),t.jsx(bEe,{value:C,onChange:M,maxLength:1500-(y?.length||0),mergeFieldsResponse:e}),t.jsx("div",{className:"mt-4 flex items-center justify-end",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"file",ref:_,onChange:async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await HMe(e.result),t=IMe(a);B(t),j(a),D(!1),i?.id&&m({groupId:i.id,params:{textMessageMedia:[t]}},{onError:()=>{d({title:"Error updating image",description:"Please contact your administrator"})}})}catch(a){d({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),t.jsx(H5,P?{variant:"outline",onClick:()=>{_.current&&(_.current.value=""),i?.id&&m({groupId:i.id,params:{textMessageMedia:[]}},{onSuccess:()=>{j(null),B(null),D(!1),A([]),_.current&&(_.current.value="")},onError:()=>{d({title:"Error removing image",description:"Please contact your administrator"})}})},className:"px-4",disabled:R||h,children:"Remove Image"}:{variant:"outline",onClick:()=>{_.current?.click()},className:"px-4",disabled:w.length>=1||R||null!==L||h,children:"Add Image"}),t.jsx(H5,{variant:"outline",onClick:()=>{M(k),x(!1),j(w.length>0?w[0]:null),B(null),D(!1)},className:"px-4",children:"Cancel"}),t.jsx(H5,{onClick:()=>{if(C&&C.length>1500)return void d({title:"SMS is too long",description:"Please shorten your message"});if(null===C||0===C.length)return void d({title:"Oops",description:"Please enter a message"});S(C);const e=o();e&&m({groupId:e,params:{smsChannelSenderId:p,smsMessageBody:C,textMessageCompanyName:y,textMessageMedia:L?[L]:R?[]:void 0}},{onSuccess:()=>{x(!1),j(null),B(null),D(!1)},onError:()=>{d({title:"Error updating SMS",description:"Please contact your administrator"})}})},className:"px-4",disabled:h,children:"Save Changes"})]})})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Kbe,{className:"text-foreground",children:"From Number"}),t.jsxs(pwe,{onValueChange:e=>{g(e),i?.id&&m({groupId:i.id,params:{smsChannelSenderId:e}})},value:p??void 0,children:[t.jsx(vwe,{children:t.jsx(fwe,{placeholder:"Select number",children:p?FMe({channelSenderId:p,smsChannelSenders:z}):"Select number"})}),t.jsx(kwe,{children:z?.map((e=>t.jsx(Swe,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName??e.channelSender.channelSenderMetadata.from??"Select number"},e.channelSender.id)))})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx(Kbe,{className:"text-foreground",children:"Company Name"}),t.jsx(Fue,{title:"Adding your company name can help customers identify who they are talking to"})]}),t.jsx(gte,{placeholder:"Enter company name",value:y??"",onChange:e=>{const a=e.target.value;a.length>100?d({title:"Oops",description:"Company name cannot exceed 100 characters",variant:"destructive"}):b(a??null)},disabled:!p&&!r})]})]}),t.jsxs("div",{className:"border rounded-lg p-4",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h3",{className:"font-medium",children:"Preview"}),t.jsx("div",{children:t.jsx(H5,{onClick:()=>x(!0),className:"text-sm px-3 py-1 rounded ",disabled:0===(z?.length??0)&&void 0===r||n?.status!==ha.DRAFT,children:"Edit"})})]}),t.jsx("div",{children:r?p||r?t.jsx(t.Fragment,{children:k?t.jsx(JMe,{body:OMe({companyName:y??void 0,smsBody:k}),imageUrls:w}):t.jsx(Ewe,{type:"sms"})}):t.jsx(Dwe,{type:"sms"}):t.jsx("div",{children:"Submit an application"})})]})]})]}):t.jsx("div",{children:t.jsx(lY,{text:["Loading..."]})})},SEe=()=>{const e=R5(),{getMergeFields:a,isGetting:n}=Qe(e?.id??void 0);return n||!a?t.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(lY,{text:["Fetching Content..."]})}):t.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[t.jsx(Jwe,{title:lH("engage:automation"),type:_we.SMS}),t.jsx(kEe,{mergeFieldsResponse:a})]})},wEe=e=>e.friendlyName||e.from||e.messageServiceSid||"Unknown Sender";function AEe(e,a,{checkForDefaultPrevented:t=!0}={}){return function(n){if(e?.(n),!1===t||!n.defaultPrevented)return a?.(n)}}function CEe(e,a=[]){let n=[];const i=()=>{const a=n.map((e=>r.createContext(e)));return function(t){const n=t?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...t,[e]:n}})),[t,n])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=n.length;n=[...n,i];const l=a=>{const{scope:n,children:i,...l}=a,u=n?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return t.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(t,n){const l=r.useContext(n?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${a}\``)}]},MEe(i,...a)]}function MEe(...e){const a=e[0];if(1===e.length)return a;const t=()=>{const t=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const n=t.reduce(((a,{useScope:t,scopeName:n})=>({...a,...t(e)[`__scope${n}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:n})),[n])}};return t.scopeName=a.scopeName,t}function TEe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function xEe(...e){return a=>{let t=!1;const n=e.map((e=>{const n=TEe(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():TEe(e[a],null)}}}}function EEe(...e){return r.useCallback(xEe(...e),e)}function NEe(e){const a=_Ee(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(jEe);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function _Ee(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?xEe(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var PEe=Symbol("radix.slottable");function jEe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===PEe}var LEe=globalThis?.document?r.useLayoutEffect:()=>{},BEe=r[" useId ".trim().toString()]||(()=>{}),REe=0;function DEe(e){const[a,t]=r.useState(BEe());return LEe((()=>{t((e=>e??String(REe++)))}),[e]),e||(a?`radix-${a}`:"")}var zEe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=NEe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});var OEe=r[" useInsertionEffect ".trim().toString()]||LEe;function KEe({prop:e,defaultProp:a,onChange:t=()=>{},caller:n}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[t,n]=r.useState(e),i=r.useRef(t),o=r.useRef(a);return OEe((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==t&&(o.current?.(t),i.current=t)}),[t,i]),[t,n,o]}({defaultProp:a,onChange:t}),l=void 0!==e,u=l?e:i;{const a=r.useRef(void 0!==e);r.useEffect((()=>{const e=a.current;if(e!==l){}a.current=l}),[l,n])}const c=r.useCallback((a=>{if(l){const t=function(e){return"function"==typeof e}(a)?a(e):a;t!==e&&s.current?.(t)}else o(a)}),[l,e,o,s]);return[u,c]}var HEe=r.createContext(void 0);function IEe(e){const a=r.useContext(HEe);return e||a||"ltr"}var FEe="rovingFocusGroup.onEntryFocus",GEe={bubbles:!1,cancelable:!0},VEe="RovingFocusGroup",[JEe,UEe,WEe]=function(e){const n=e+"CollectionProvider",[i,r]=CEe(n),[o,s]=i(n,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:n,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return t.jsx(o,{scope:n,itemMap:s,collectionRef:r,children:i})};l.displayName=n;const u=e+"CollectionSlot",c=NEe(u),d=a.forwardRef(((e,a)=>{const{scope:n,children:i}=e,r=EEe(a,s(u,n).collectionRef);return t.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=NEe(m),g=a.forwardRef(((e,n)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=EEe(n,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),t.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(t){const n=s(e+"CollectionConsumer",t);return a.useCallback((()=>{const e=n.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(n.itemMap.values()).sort(((e,t)=>a.indexOf(e.ref.current)-a.indexOf(t.ref.current)))}),[n.collectionRef,n.itemMap])},r]}(VEe),[qEe,$Ee]=CEe(VEe,[WEe]),[ZEe,YEe]=qEe(VEe),QEe=r.forwardRef(((e,a)=>t.jsx(JEe.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(JEe.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(XEe,{...e,ref:a})})})));QEe.displayName=VEe;var XEe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:m=!1,...h}=e,p=r.useRef(null),g=EEe(a,p),f=IEe(s),[v,y]=KEe({prop:l,defaultProp:u??null,onChange:c,caller:VEe}),[b,k]=r.useState(!1),S=function(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}(d),w=UEe(n),A=r.useRef(!1),[C,M]=r.useState(0);return r.useEffect((()=>{const e=p.current;if(e)return e.addEventListener(FEe,S),()=>e.removeEventListener(FEe,S)}),[S]),t.jsx(ZEe,{scope:n,orientation:i,dir:f,loop:o,currentTabStopId:v,onItemFocus:r.useCallback((e=>y(e)),[y]),onItemShiftTab:r.useCallback((()=>k(!0)),[]),onFocusableItemAdd:r.useCallback((()=>M((e=>e+1))),[]),onFocusableItemRemove:r.useCallback((()=>M((e=>e-1))),[]),children:t.jsx(zEe.div,{tabIndex:b||0===C?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:AEe(e.onMouseDown,(()=>{A.current=!0})),onFocus:AEe(e.onFocus,(e=>{if(e.target===e.currentTarget&&!A.current&&!b){const a=new CustomEvent(FEe,GEe);if(e.currentTarget.dispatchEvent(a),!a.defaultPrevented){const e=w().filter((e=>e.focusable));nNe([e.find((e=>e.active)),e.find((e=>e.id===v)),...e].filter(Boolean).map((e=>e.ref.current)),m)}}A.current=!1})),onBlur:AEe(e.onBlur,(()=>k(!1)))})})})),eNe="RovingFocusGroupItem",aNe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:o=!1,tabStopId:s,children:l,...u}=e,c=DEe(),d=s||c,m=YEe(eNe,n),h=m.currentTabStopId===d,p=UEe(n),{onFocusableItemAdd:g,onFocusableItemRemove:f,currentTabStopId:v}=m;return r.useEffect((()=>{if(i)return g(),()=>f()}),[i,g,f]),t.jsx(JEe.ItemSlot,{scope:n,id:d,focusable:i,active:o,children:t.jsx(zEe.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...u,ref:a,onMouseDown:AEe(e.onMouseDown,(e=>{i?m.onItemFocus(d):e.preventDefault()})),onFocus:AEe(e.onFocus,(()=>m.onItemFocus(d))),onKeyDown:AEe(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void m.onItemShiftTab();if(e.target!==e.currentTarget)return;const a=function(e,a,t){const n=function(e,a){return"rtl"!==a?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,t);return"vertical"===a&&["ArrowLeft","ArrowRight"].includes(n)||"horizontal"===a&&["ArrowUp","ArrowDown"].includes(n)?void 0:tNe[n]}(e,m.orientation,m.dir);if(void 0!==a){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter((e=>e.focusable)).map((e=>e.ref.current));if("last"===a)i.reverse();else if("prev"===a||"next"===a){"prev"===a&&i.reverse();const r=i.indexOf(e.currentTarget);i=m.loop?(n=r+1,(t=i).map(((e,a)=>t[(n+a)%t.length]))):i.slice(r+1)}setTimeout((()=>nNe(i)))}var t,n})),children:"function"==typeof l?l({isCurrentTabStop:h,hasTabStop:null!=v}):l})})}));aNe.displayName=eNe;var tNe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function nNe(e,a=!1){const t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus({preventScroll:a}),document.activeElement!==t)return}}var iNe=QEe,rNe=aNe;var oNe=e=>{const{present:a,children:t}=e,n=function(e){const[a,t]=r.useState(),n=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,t)=>a[e][t]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=sNe(n.current);o.current="mounted"===l?e:"none"}),[l]),LEe((()=>{const a=n.current,t=i.current;if(t!==e){const n=o.current,r=sNe(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(t&&n!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),LEe((()=>{if(a){let e;const t=a.ownerDocument.defaultView??window,r=r=>{const o=sNe(n.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const n=a.style.animationFillMode;a.style.animationFillMode="forwards",e=t.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=n)}))}},s=e=>{e.target===a&&(o.current=sNe(n.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{t.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{n.current=e?getComputedStyle(e):null,t(e)}),[])}}(a),i="function"==typeof t?t({present:n.isPresent}):r.Children.only(t),o=EEe(n.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof t||n.isPresent?r.cloneElement(i,{ref:o}):null};function sNe(e){return e?.animationName||"none"}oNe.displayName="Presence";var lNe="Tabs",[uNe,cNe]=CEe(lNe,[$Ee]),dNe=$Ee(),[mNe,hNe]=uNe(lNe),pNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,value:i,onValueChange:r,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:u="automatic",...c}=e,d=IEe(l),[m,h]=KEe({prop:i,onChange:r,defaultProp:o??"",caller:lNe});return t.jsx(mNe,{scope:n,baseId:DEe(),value:m,onValueChange:h,orientation:s,dir:d,activationMode:u,children:t.jsx(zEe.div,{dir:d,"data-orientation":s,...c,ref:a})})}));pNe.displayName=lNe;var gNe="TabsList",fNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,loop:i=!0,...r}=e,o=hNe(gNe,n),s=dNe(n);return t.jsx(iNe,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:i,children:t.jsx(zEe.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:a})})}));fNe.displayName=gNe;var vNe="TabsTrigger",yNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,value:i,disabled:r=!1,...o}=e,s=hNe(vNe,n),l=dNe(n),u=SNe(s.baseId,i),c=wNe(s.baseId,i),d=i===s.value;return t.jsx(rNe,{asChild:!0,...l,focusable:!r,active:d,children:t.jsx(zEe.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...o,ref:a,onMouseDown:AEe(e.onMouseDown,(e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():s.onValueChange(i)})),onKeyDown:AEe(e.onKeyDown,(e=>{[" ","Enter"].includes(e.key)&&s.onValueChange(i)})),onFocus:AEe(e.onFocus,(()=>{d||r||!("manual"!==s.activationMode)||s.onValueChange(i)}))})})}));yNe.displayName=vNe;var bNe="TabsContent",kNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,value:i,forceMount:o,children:s,...l}=e,u=hNe(bNe,n),c=SNe(u.baseId,i),d=wNe(u.baseId,i),m=i===u.value,h=r.useRef(m);return r.useEffect((()=>{const e=requestAnimationFrame((()=>h.current=!1));return()=>cancelAnimationFrame(e)}),[]),t.jsx(oNe,{present:o||m,children:({present:n})=>t.jsx(zEe.div,{"data-state":m?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!n,id:d,tabIndex:0,...l,ref:a,style:{...e.style,animationDuration:h.current?"0s":void 0},children:n&&s})})}));function SNe(e,a){return`${e}-trigger-${a}`}function wNe(e,a){return`${e}-content-${a}`}kNe.displayName=bNe;var ANe=fNe,CNe=yNe,MNe=kNe;const TNe=pNe,xNe=r.forwardRef((({className:e,...a},n)=>t.jsx(ANe,{ref:n,className:XO("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a})));xNe.displayName=ANe.displayName;const ENe=r.forwardRef((({className:e,...a},n)=>t.jsx(CNe,{ref:n,className:XO("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...a})));ENe.displayName=CNe.displayName;const NNe=r.forwardRef((({className:e,...a},n)=>t.jsx(MNe,{ref:n,className:XO("ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a})));NNe.displayName=MNe.displayName;const _Ne=({type:e})=>{const n=R5(),i=B5(),{toast:r}=Ve(),[o,s]=a.useState(!1),{resetCommunicationGroupToDefault:l,isPending:u}=ea(),c=e===_we.EMAIL?"Email":"SMS";return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("div",{className:"flex items-center gap-2",children:!!n&&(n.type===Fwe.MANAGED&&(e===_we.SMS?n.updatedFromDefault?.text_message_body:n.updatedFromDefault?.email_text_body||n.updatedFromDefault?.email_html_body))&&t.jsx(t.Fragment,{children:u?t.jsx(lY,{}):t.jsx(H5,{variant:"outline",size:"sm",disabled:u,onClick:()=>s(!0),children:"Reset To Default"})})})}),t.jsx(ZZ,{open:o,onOpenChange:s,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsxs(aY,{children:[t.jsx(nY,{className:"text-xl font-semibold",children:"Reset To Default"}),t.jsxs(iY,{className:"text-base text-muted-foreground",children:["Are you sure you want to reset this ",c.toLowerCase()," ","template to its default state? This action cannot be undone."]})]}),t.jsxs(tY,{className:"flex flex-row justify-end gap-3 mt-6",children:[t.jsx(H5,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:async()=>{n&&i?l({communicationGroupId:n.id,automationId:i.id,type:e===_we.EMAIL?"email":"sms"},{onSuccess:()=>{r({title:lH("engage:success.communication_reset","Communication reset to default!")}),s(!1)},onSettled:()=>{s(!1)},onError:()=>{r({title:"Error updating",description:"No sender found",variant:"destructive"})}}):r({title:"Error updating",description:"No sender found",variant:"destructive"})},disabled:u,children:"Reset To Default"})]})]})})]})},PNe="reach-styles-module__base___r-a1U",jNe=GD([PNe],{variants:{variant:{default:"reach-styles-module__default___vu2Rt",primary:"reach-styles-module__primary___mGKjo",success:"reach-styles-module__success___xn1Y1",warning:"reach-styles-module__warning___jdyU9",error:"reach-styles-module__error___Z-3IS"},size:{default:"reach-styles-module__sizeDefault___oS6W2",sm:"reach-styles-module__sizeSm___GI826",lg:"reach-styles-module__sizeLg___J--WF"},position:{default:"reach-styles-module__positionDefault___visr6",top:"reach-styles-module__positionTop___y6h-n",bottom:"reach-styles-module__positionBottom___vYLkd",inline:"reach-styles-module__positionInline___NjZsw"}},defaultVariants:{variant:"default",size:"default",position:"default"}}),LNe=({children:e})=>t.jsx("div",{className:"rounded-lg p-6 bg-background flex-1 min-h-0 flex items-center justify-center overflow-y-auto",children:e}),BNe=({emailBody:e})=>t.jsx(LNe,{children:t.jsx(Lwe,{html:e})}),RNe=({onOpenChange:e})=>t.jsx("div",{role:"button",tabIndex:0,"aria-label":"Close dialog",onClick:()=>e(!1),onKeyDown:a=>{"Enter"!==a.key&&" "!==a.key||e(!1)},className:"absolute top-3 right-3 z-20 rounded-full p-2 bg-white/80 shadow-lg border border-gray-200 hover:bg-primary/90 hover:text-white active:bg-primary/95 transition-all duration-200 focus:outline-none focus:ring-4 focus:ring-primary/30 focus:ring-offset-2 group cursor-pointer",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)"},children:t.jsx(V5.CloseButton,{className:"w-5 h-5 text-primary group-hover:text-primary-foreground group-active:text-primary-foreground transition-colors duration-200"})}),DNe=({expandDialogContent:e})=>{const[n,i]=a.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(ZZ,{open:n,onOpenChange:i,children:t.jsxs(eY,{hideCloseButton:!0,className:"w-[80vw] h-[80vh] max-h-none bg-transparent border-none max-w-screen-lg ",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Expanded Preview"}),t.jsx(iY,{children:"Expanded view of communication content"})]}),t.jsxs("div",{className:"h-full flex flex-col overflow-hidden rounded-xl",children:[t.jsx(RNe,{onOpenChange:i}),e]})]})}),t.jsx(H5,{size:"sm",variant:"outline",onClick:()=>i(!0),children:t.jsx(V5.ExpandIcon,{className:"w-3 h-3"})})]})},zNe=({label:e,value:a,className:n})=>t.jsxs("div",{className:"flex items-center gap-1 min-w-0 max-w-full flex-shrink",children:[t.jsxs("span",{className:"sr-only",children:[e,":"]}),t.jsx("span",{className:XO("truncate",n),children:a})]}),ONe=({mergeFieldsResponse:e})=>{const n=B5(),i=R5(),r=(()=>{const{channelSenders:e}=Jre(),{channelAccounts:t}=Fre();return a.useMemo((()=>e?.results&&t?.results?e.results.filter((e=>e.channelSenderMetadata.userPart)).flatMap((e=>{const a=t.results.find((a=>a.id===e.channelAccountId));return!a?.channelAccountMetadata||a.channelAccountMetadata.type!==Gre.REACH_MANAGED&&a.channelAccountMetadata.type!==Gre.REACH_MANAGED_SES?[]:[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,channelSenderMetadata:e.channelSenderMetadata}]})):[]),[e?.results,t?.results])})(),{channelSenders:o}=Jre(),{updateCommunicationGroup:s}=Ye(),[l,u]=a.useState(!1),{state:{replyToSettingsText:c,replyToSettingsLink:d,fromNameSettingsText:m,fromNameSettingsLink:h}}=a.useContext(rY),[p,g]=a.useState(!1),[f,v]=a.useState(i?.emailChannelSenderId||null),[y,b]=a.useState(i?.emailSubject||null),[k,S]=a.useState(i?.emailPreviewText||null),[w,A]=a.useState(""),[C,M]=a.useState(""),[T,x]=a.useState(!0),[E,N]=a.useState(!1),[_,P]=a.useState(null),[j,L]=a.useState(i?.emailSubject||null),B=wwe(y,500),R=wwe(k,500);if(a.useEffect((()=>{if(o?.results&&f){const e=o.results.find((e=>e.id===f));e&&(E&&!T||M(e.channelSenderMetadata.emailReplyTo),T&&A(e.channelSenderMetadata.emailFromName),x(!1))}}),[o?.results,f,E,T]),a.useEffect((()=>{i?.emailChannelSenderId&&!f&&v(i.emailChannelSenderId),i&&null!==i.emailSubject&&null===y&&(b(i.emailSubject),L(i.emailSubject)),i&&null!==i.emailPreviewText&&null===k&&S(i.emailPreviewText)}),[i,f,y,k]),a.useEffect((()=>{if(f&&B&&i?.id&&!T){g(!0);(async()=>{try{await s({groupId:i.id,params:{emailChannelSenderId:f,emailSubject:B,...R&&{emailPreviewText:R}}})}catch(e){}finally{g(!1)}})()}}),[f,B,R,i?.id,s,T]),!n||!i||!i.emailChannelSenderId)return null;const D=r.find((e=>e.channelSenderId===i.emailChannelSenderId)),z=w||D?.fullDomain,O=y,K=k;return t.jsx("div",{className:"w-full bg-background rounded-lg p-3",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 overflow-hidden flex-1",children:[z&&t.jsx(zNe,{label:"From",value:z,className:"font-bold"}),O&&t.jsx(zNe,{label:"Subject",value:t.jsx(VMe,{content:O,mergeFieldsResponse:e,variant:"minimal",className:"font-normal"}),className:"font-normal"}),K&&t.jsx(zNe,{label:"Preview",value:t.jsx(VMe,{content:K,mergeFieldsResponse:e,variant:"minimal",className:"text-muted-foreground/50 italic"}),className:"text-muted-foreground/50 italic"})]}),t.jsxs(Nre,{open:l,onOpenChange:e=>{u(e),""===y?.trim()&&j&&!1===e&&(b(j),P(null))},children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{size:"sm",variant:"outline",disabled:n.status!==ha.DRAFT,children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]})}),t.jsx(Pre,{className:"w-96",align:"end",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"From Email"}),t.jsxs(pwe,{onValueChange:e=>{v(e),x(!0),N(!1)},value:f??void 0,disabled:p,children:[t.jsx(vwe,{className:"bg-background hover:bg-accent/50 focus:bg-accent/50 data-[state=open]:bg-accent/50 transition-colors",children:t.jsx(fwe,{placeholder:"Select email",className:"text-muted-foreground",children:f?r?.find((e=>e.channelSenderId===f))?.fullDomain:""})}),t.jsx(kwe,{children:r?.map((e=>t.jsx(Swe,{value:e.channelSenderId,children:e.fullDomain},e.channelSenderId)))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"From Name"}),t.jsx(Fue,{title:m||"From name can be configured under settings in the home screen",link:h?{url:h}:void 0})]}),t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground bg-muted/50 rounded-md",children:w||t.jsx("span",{className:"italic text-muted-foreground/70",children:"Not set"})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Reply-To"}),t.jsx(Fue,{title:c||"Reply to email can be configured under settings in the home screen",link:d?{url:d}:void 0})]}),t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground bg-muted/50 rounded-md",children:C||(f?r?.find((e=>e.channelSenderId===f))?.fullDomain:"")||t.jsx("span",{className:"italic text-muted-foreground/70",children:"Not set"})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Subject"}),t.jsx("span",{className:"text-xs text-red-500 ml-0.5",children:"*"})]}),t.jsx(Ebe,{value:y,onChange:b,mergeFieldsResponse:e,placeholder:"Enter email subject",className:"bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50 "+(_?"border-red-300 focus:border-red-500":""),ariaLabel:"Insert merge field into subject"}),_&&t.jsx("p",{className:"text-xs text-red-500 animate-pulse",children:_})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Preview Text"}),t.jsx(Fue,{title:"This text will be used for the preview text of the email in the inbox"})]}),t.jsx(Ebe,{value:k,onChange:S,mergeFieldsResponse:e})]})]})})]})]})})},KNe=({type:e,disablePreviewSubtext:a=!1})=>{const n="sms"===e?"SMS":"Email";return t.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center justify-center bg-zinc-50/80 border border-zinc-100 rounded-2xl shadow-md px-6 py-12 max-w-[90vw] w-full sm:max-w-md mx-auto text-center",style:{containerType:"inline-size"},children:[t.jsx("sms"===e?V5.SmsIcon:V5.EmailIcon,{className:"w-12 h-12 text-zinc-500 mb-4"}),t.jsxs("h2",{className:"text-xl font-semibold text-zinc-800 mb-2",children:["No ",n," Content Yet"]}),!a&&t.jsxs("p",{className:"text-zinc-500 text-base mb-1",children:["Click"," ",t.jsx("span",{className:"font-medium text-zinc-700",children:"Edit content"})," to start crafting your ",n," message."]})]})})},HNe=a.forwardRef((({onClick:e},a)=>t.jsxs(H5,{ref:a,variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 flex items-center gap-2 shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:e,children:[t.jsx(V5.PreviewButton,{className:"w-4 h-4"}),t.jsx("span",{className:"font-medium text-sm",children:"Test"})]})));HNe.displayName="PreviewButton";const INe=e=>/^[^\s@.]+(?:\.[^\s@.]+)*@[^\s@.]+(?:\.[^\s@.]+)+$/.test(e),FNe=e=>{if(!/^[0-9\s()+.-]+$/.test(e))return!1;const a=e.replace(/\D/g,"");return e.startsWith("+")?a.length>=10&&a.length<=15:10===a.length||!(11!==a.length||!a.startsWith("1"))},GNe=e=>{const a=e.replace(/\D/g,"");if(10===a.length)return`(${a.slice(0,3)}) ${a.slice(3,6)}-${a.slice(6)}`;if(11===a.length&&a.startsWith("1"))return`+1 (${a.slice(1,4)}) ${a.slice(4,7)}-${a.slice(7)}`;if(a.length>0){const t=e.startsWith("+")?"+":"",n=a.slice((e.startsWith("+"),0));return`${t}${n.match(/.{1,4}/g)?.join("-")||n}`}return e},VNe=({automation:e,type:n,setOpenSendPreviewPopup:i,open:r})=>{const[o,s]=a.useState(""),[l,u]=a.useState(""),[c,d]=a.useState(null),[m,h]=a.useState(!1),[p,g]=a.useState(""),[f,v]=a.useState(!1),{sendTestCommunication:y,sendError:b,isSendSuccess:k}=Xe(),{toast:S}=Ve(),w=e.actionData?.find((e=>"send_communication"===e.actionType)),A=w?.actionMetadata.communicationGroupId,{communicationGroup:C,isGetting:M}=Ze(A??void 0),{data:T}=x5({includeSegments:e.includeSegmentIds,excludeSegments:e.excludeSegmentIds,automationId:e.id}),x=a.useRef(null),E=a.useMemo((()=>[...T?.recipients??[]].filter((e=>!(!e.firstName||!e.lastName)&&(!("email"===n&&!e.email)&&!("sms"===n&&!e.phone))))),[T?.recipients,n]),N=a.useCallback((()=>{if(!A)return Promise.resolve(null);if(!C)return Promise.reject(new Error("Communication group not loaded"));switch(n){case"email":return Promise.resolve(C.emailChannelSenderId);case"sms":return Promise.resolve(C.smsChannelSenderId);default:return Promise.reject(new Error(`Unsupported type: ${n}`))}}),[C,n,A]);a.useEffect((()=>{(async()=>{try{const e=await N();d(e)}catch(e){d(null)}finally{h(!0)}})()}),[N]),a.useEffect((()=>{k&&(S({title:"Success",description:`Preview ${"email"===n?"email":"SMS"} sent successfully!`}),i(!1))}),[k,n,i,S]),a.useEffect((()=>{b&&(S({title:"Error",description:`Failed to send preview: ${b.message}`,variant:"destructive"}),i(!1))}),[b,S,i]),a.useEffect((()=>{r&&(s(""),u(""),g(""),v(!1))}),[r]),a.useEffect((()=>{!r&&f&&setTimeout((()=>{document.body.style.pointerEvents=""}),0)}),[r,f]);const _="email"===n?"email address":"phone number",P="email"===n?"email":"text";if(!m||M||!T)return t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsx(lY,{text:["Fetching sender data","Fetching recipients"]})});if(!c)return t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsxs("div",{className:"text-center flex flex-col justify-center items-center gap-2",children:[t.jsx(V5.AlertCircleIcon,{className:"h-12 w-12 text-gray-400 mb-4"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"No sender found"}),t.jsx("p",{className:"text-gray-500",children:"Please update the automation to include a sender for this type"})]})});const j="email"===n&&(null===C?.emailSubject||null===C?.emailChannelSenderId);return t.jsxs("div",{className:"",ref:x,children:[t.jsxs("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:["Send Test ",P]}),t.jsx(gte,{type:"email"===n?"email":"tel",placeholder:`Enter ${_}`,value:o,onChange:e=>{s(e.target.value),u("")},className:"w-full px-3 py-3 border border-gray-300 rounded-lg text-base \n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\n placeholder-gray-400"}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Enter a ",_," to preview this ",P,"."]}),t.jsx("div",{className:"my-4 border-t border-gray-200"}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(pwe,{value:p,onValueChange:e=>{g(e)},onOpenChange:e=>{v(e),!e&&x.current&&x.current.focus()},children:[t.jsx(vwe,{className:"w-full bg-white border border-gray-300 rounded-lg text-base\n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:t.jsx(fwe,{children:p?T?.recipients.find((e=>e.id===p))?.firstName+" "+T?.recipients.find((e=>e.id===p))?.lastName:"Preview as"})}),t.jsx(kwe,{position:"popper",className:"z-[100]",children:t.jsx(gwe,{children:E.map((e=>t.jsx(Swe,{value:e.id,className:"cursor-pointer hover:bg-gray-50",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{className:"font-medium",children:[e.firstName," ",e.lastName]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.email&&`Email: ${e.email}`,e.email&&e.phone&&" • ",e.phone&&`Phone: ${e.phone}`]})]})},`${e.firstName}-${e.lastName}`)))})})]}),p&&t.jsxs(t.Fragment,{children:[t.jsx(H5,{variant:"ghost",size:"icon",onClick:()=>g(""),disabled:j,className:`h-10 w-10 rounded-lg hover:bg-gray-100 ${j&&"cursor-not-allowed"}`,title:"Clear selection",children:t.jsx(V5.CloseButton,{className:"h-4 w-4 text-gray-500"})}),j&&t.jsx("p",{className:"text-xs text-amber-600 mt-1",children:"Please select a sender and subject first"})]})]}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Test using real customer data to preview how merge tags (like name) will appear. If left blank, you'll see raw placeholders (e.g."," ","{{First Name}}",")."]})]}),l&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-4 border-t border-gray-200"}),t.jsx("p",{className:"text-red-500 text-sm mb-4 -mt-2",children:l})]}),t.jsx(H5,{onClick:()=>{if(!("email"===n?INe(o):FNe(o)))return void u(`Please enter a ${_}`);if(!c)return void u("No sender found, please update the automation first!");const a=e.actionData?.find((e=>"send_communication"===e.actionType)),t=a?.actionMetadata.communicationGroupId;if(!t)return Promise.resolve(null);y({id:t,params:"email"===n?{emailAddress:o,previewAsRecipientId:p}:{phoneNumber:o,previewAsRecipientId:p}})},disabled:!o,className:"w-full disabled:cursor-not-allowed",children:"Send Test"})]})},JNe=({open:e,onOpenChange:a,automation:n})=>t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Send Preview Email"}),t.jsx(iY,{children:"Send a preview email to the automation."})]}),t.jsx(VNe,{automation:n,type:"email",setOpenSendPreviewPopup:a,open:e})]})}),UNe=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1})=>{const r=B5(),o=R5(),{channelSenders:s}=Jre(),{channelAccounts:l}=Fre(),{data:u,isLoading:c}=xwe(),{state:{selectedActionId:d}}=a.useContext(S5),[m,h]=a.useState(!1),[p,g]=a.useState(!1),[f,v]=a.useState(null),[y,b]=a.useState(!1),[k,S]=a.useState(!1),[w,A]=a.useState({width:0,height:0}),{getMergeFields:C}=Qe(o?.id??void 0);a.useEffect((()=>{null===f&&u&&p&&(u?.uiDefaults||v(!0),u?.uiDefaults?.emailHelpDialogShow&&!f&&v(!0))}),[u,f,p]),a.useEffect((()=>{const e=()=>{A({width:window.innerWidth,height:window.innerHeight})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]);if(!r||!o||void 0===s||void 0===l||!d||c)return null;const M=o.emailHtmlBody||"",T=M.length>0,x=Uwe({channelSenders:s?.results??[],channelAccounts:l?.results??[]}),E=o.emailChannelSenderId?o.emailSubject?o.emailHtmlBody?null:"Please first ensure you have an email content":"Please first ensure you have an email subject":"Please first select an email sender",N=r.status===ha.DRAFT&&!n,_=!e&&T,P=!o.emailChannelSenderId||0===x.length,j=()=>{const e=t.jsxs(H5,{size:"sm",variant:"outline",disabled:!N,className:XO(!N&&"cursor-not-allowed"),onClick:()=>g(!0),children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]});return N?e:t.jsx(Fue,{alertText:"You can only edit the content if we are in the draft state.",asChild:!0,className:"cursor-not-allowed",children:t.jsx("div",{className:"inline-block cursor-not-allowed",children:e})})},L=()=>{const e=t.jsx(HNe,{onClick:()=>h(!0)});return E?t.jsx(Fue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:e}):e};return t.jsxs("div",{className:"flex-1 flex flex-col items-center pt-4",children:[t.jsx(ZZ,{open:null!==f&&f,onOpenChange:v,children:t.jsxs(eY,{className:"max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Preview Help"}),t.jsx(iY,{children:"Learn more about the email preview and how to use it to create your email."})]}),t.jsx(Rwe,{})]})}),t.jsx(ZZ,{open:p,onOpenChange:g,children:t.jsxs(eY,{className:"min-w-[100vw] min-h-[100vh]",hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault()},children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Editor"}),t.jsx(iY,{children:"Edit your email content using the visual editor. Use the details section above to modify sender and subject settings."})]}),t.jsxs("div",{className:"w-full h-full",children:[t.jsxs("div",{className:"flex justify-between items-center p-1 border-b",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(H5,{size:"sm",onClick:()=>v(!0),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:"Help"}),t.jsx(V5.InfoIcon,{className:"w-4 h-4"})]})})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Nbe,{})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(H5,{variant:"destructive",onClick:()=>{S(!0)},className:"text-sm px-3 py-1 rounded",children:"Cancel"}),t.jsx(H5,{onClick:()=>b(!0),className:"text-sm px-3 py-1 rounded",children:"Save"})]})]}),r&&C&&t.jsx(Hwe,{cancelClicked:k,setCancelClicked:S,showStripoEditor:p,automation:r,setShowStripoEditor:g,saveClicked:y,setSaveClicked:b,stripoDialogDimensions:w,mergeFieldsResponse:C,actionId:d})]})]})}),x.length>0&&t.jsx(JNe,{open:m,onOpenChange:h,automation:r}),P&&t.jsx("div",{className:"px-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"Email Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The email channel is currently disabled. To send email messages, please enable the channel by selecting a valid email sender."})]})]})})})}),T?t.jsx("div",{className:"relative flex-1 w-full flex flex-col overflow-hidden",children:t.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col",children:t.jsxs("div",{className:"flex flex-col space-y-4 px-4 pb-20",children:[t.jsx("div",{className:"w-full flex-shrink-0 max-w-2xl mx-auto rounded-md",children:t.jsx(ONe,{mergeFieldsResponse:C})}),t.jsxs("div",{className:"rounded-lg bg-background flex-1 min-h-0 flex flex-col items-center max-w-2xl mx-auto w-full",children:[t.jsxs("div",{className:"flex items-center space-x-2 w-full justify-end p-3",children:[t.jsx(_Ne,{type:_we.EMAIL}),t.jsx(j,{}),_&&t.jsx(L,{}),T&&t.jsx(DNe,{expandDialogContent:t.jsx(BNe,{emailBody:M})})]}),t.jsx(Lwe,{html:M})]}),t.jsx("p",{className:"text-center text-sm text-muted-foreground flex-shrink-0 pt-4",children:"These previews show exactly how your messages will appear to your customers"})]})})}):t.jsxs(t.Fragment,{children:[P&&t.jsx("div",{className:"px-4 pt-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"Email Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The email channel is currently disabled. To send email messages, please enable the channel by selecting a valid email sender."})]})]})})})}),t.jsx(KNe,{type:"email",disablePreviewSubtext:i})]})]})},WNe=({smsBody:e,imageUrls:a})=>t.jsx(LNe,{children:t.jsx(JMe,{body:e,imageUrls:a})}),qNe=({open:e,onOpenChange:a,automation:n})=>t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Send Preview SMS"}),t.jsx(iY,{children:"Send a preview SMS to the automation."})]}),t.jsx(VNe,{automation:n,type:"sms",setOpenSendPreviewPopup:a,open:e})]})}),$Ne=({label:e,value:a,className:n})=>t.jsxs("div",{className:"flex items-center gap-1 min-w-0 max-w-full flex-shrink",children:[t.jsxs("span",{className:"sr-only",children:[e,":"]}),t.jsx("span",{className:XO("truncate",n),children:a})]}),ZNe=()=>{const e=B5(),n=R5(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre(),{data:o}=$re(),{updateCommunicationGroup:s}=Ye(),[l,u]=a.useState(!1),[c,d]=a.useState(!1),[m,h]=a.useState(!0),[p,g]=a.useState(n?.smsChannelSenderId||null),[f,v]=a.useState(n?.textMessageCompanyName||null),y=n?.smsMessageBody||null,b=wwe(f,500),k=a.useMemo((()=>Nle({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o})),[i?.results,r?.results,o]),S=k?.find((e=>e.channelSender.id===n?.smsChannelSenderId)),w=S?.channelSender.channelSenderMetadata.from&&null!==S.channelSender.channelSenderMetadata.from?S.channelSender.channelSenderMetadata.from:null,A=S?.channelSender.channelSenderMetadata.friendlyName??(w&&null!==w?GNe(w??""):S?.channelSender.channelSenderMetadata.messageServiceSid);if(a.useEffect((()=>{i?.results&&p&&h(!1)}),[i?.results,p]),a.useEffect((()=>{if(p&&n?.id&&!m){d(!0);(async()=>{try{await s({groupId:n.id,params:{smsChannelSenderId:p,...b?{textMessageCompanyName:b}:{textMessageCompanyName:null}}})}catch(e){}finally{d(!1)}})()}}),[p,b,n?.id,s,m]),!(e&&n&&i&&r&&k&&(void 0!==o||S)))return null;const C=y?y.length>50?y.substring(0,50)+"...":y:null;return t.jsx("div",{className:"w-full bg-background rounded-lg p-3",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 overflow-hidden flex-1",children:[A&&t.jsx($Ne,{label:"From",value:A,className:"font-bold"}),f&&t.jsx($Ne,{label:"Company",value:f,className:"font-normal"}),C&&t.jsx($Ne,{label:"Message",value:C,className:"text-muted-foreground/50 italic"})]}),t.jsxs(Nre,{open:l,onOpenChange:u,children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{size:"sm",variant:"outline",children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]})}),t.jsx(Pre,{className:"w-96",align:"end",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"From"}),t.jsxs(pwe,{onValueChange:e=>{g(e),h(!0)},value:p??void 0,disabled:c,children:[t.jsx(vwe,{className:"bg-background hover:bg-accent/50 focus:bg-accent/50 data-[state=open]:bg-accent/50 transition-colors",children:t.jsx(fwe,{placeholder:"Select sender",className:"text-muted-foreground",children:p?k?.find((e=>e.channelSender.id===p))?.channelSender.channelSenderMetadata.friendlyName||k?.find((e=>e.channelSender.id===p))?.channelSender.channelSenderMetadata.from:""})}),t.jsx(kwe,{children:k?.map((e=>t.jsx(Swe,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName||e.channelSender.channelSenderMetadata.from},e.channelSender.id)))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Company"}),t.jsx(Fue,{title:"Company name will be included in the SMS message"})]}),t.jsx(gte,{placeholder:"Enter company name",className:"bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50",value:f??"",onChange:e=>{v(""===e.target.value?null:e.target.value)},disabled:c||m})]})]})})]})]})})},YNe=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1,setupRequired:r=!1})=>{const[o,s]=a.useState(!1),{channelSenders:l}=Jre(),{channelAccounts:u}=Fre(),c=B5(),d=R5(),[m,h]=a.useState(!1),{data:p}=$re(),[g,f]=a.useState(r),[v,y]=a.useState(null),[b,k]=a.useState(null),[S,w]=a.useState(null),[A,C]=a.useState(!1),M=a.useRef(null),{toast:T}=Ve(),{updateCommunicationGroup:x,isUpdating:E}=Ye(),{getMergeFields:N}=Qe(d?.id??void 0),_=Nle({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:p}),P=_.find((e=>e.channelSender.id===d?.smsChannelSenderId)),j=a.useMemo((()=>d?.textMessageMediaUrls??[]),[d?.textMessageMediaUrls]),L=d?.smsMessageBody||"",B=a.useCallback((()=>{v&&v.length>1500?T({title:"SMS is too long",description:"Please shorten your message"}):null!==v&&0!==v.length?d?.id&&x({groupId:d.id,params:{smsMessageBody:v,textMessageMedia:S?[S]:A?[]:void 0}},{onSuccess:()=>{h(!1),k(null),w(null),C(!1)},onError:()=>{T({title:"Error updating SMS",description:"Please contact your administrator"})}}):T({title:"Oops",description:"Please enter a message"})}),[v,d?.id,S,A,x,T]),R=a.useCallback((()=>{y(L),h(!1),k(j.length>0?j[0]:null),w(null),C(!1)}),[L,j]),D=a.useCallback((()=>{k(null),w(null),C(!0),M.current&&(M.current.value="")}),[]),z=a.useCallback((async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await HMe(e.result),t=IMe(a);w(t),k(a),C(!1)}catch(a){T({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}}),[T]),O=a.useCallback((()=>{M.current?.click()}),[]);if(a.useEffect((()=>{m&&L&&(y(L),j.length>0&&!b&&!A&&k(j[0]))}),[m,L,j,b,A]),a.useEffect((()=>{m||(k(j.length>0?j[0]:null),w(null),C(!1))}),[m,j]),a.useEffect((()=>{P&&P.smsApplication&&P.smsApplication.status===Ele.PENDING&&f(!1)}),[d?.smsChannelSenderId,p,_,P]),!c||void 0===l)return null;const K=!P?.smsApplication||P.smsApplication.status===Ele.APPROVED,H=L.length>0,I=OMe({companyName:d?.textMessageCompanyName??void 0,smsBody:L});let F=null;d?.smsChannelSenderId||(F="Please first select a sms sender"),d?.smsMessageBody||(F="Please first ensure you have a sms content");const G=c.status===ha.DRAFT&&!n,V=!e&&K,J=!g&&(!d?.smsChannelSenderId||P?.smsApplication&&P.smsApplication.status!==Ele.APPROVED&&P.smsApplication.status!==Ele.PENDING),U=()=>{const e=t.jsxs(H5,{size:"sm",variant:"outline",disabled:!G,className:XO(!G&&"cursor-not-allowed"),onClick:()=>{h(!0)},children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]});return G?e:t.jsx(Fue,{alertText:"You can only edit the content if we are in the draft state.",asChild:!0,className:"cursor-not-allowed",children:t.jsx("div",{className:"inline-block cursor-not-allowed",children:e})})},W=()=>{const e=t.jsx(HNe,{onClick:()=>s(!0)});return F?t.jsx(Fue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:e}):e};return t.jsx(wY,{children:g?t.jsx("div",{className:"w-full pt-8 mx-auto",children:t.jsx(zMe,{})}):t.jsxs(o5.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3,ease:[.16,1,.3,1]},className:"flex-1 flex flex-col items-center",children:[t.jsx(qNe,{open:o,onOpenChange:s,automation:c}),t.jsx(ZZ,{open:m,onOpenChange:h,children:t.jsxs(eY,{hideCloseButton:!0,className:"max-w-[50vw]",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"SMS Editor"}),t.jsx(iY,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),t.jsxs("div",{className:"",children:[b&&t.jsx("div",{className:"flex justify-center mb-6",children:t.jsx("div",{className:"relative group w-fit",children:t.jsx("img",{src:b,alt:"SMS attachment preview",className:"max-h-48 max-w-xs rounded-xl shadow-lg border border-gray-200 object-contain bg-white transition-transform duration-200",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}})})}),N&&t.jsx(bEe,{value:v,onChange:y,maxLength:1500-(d?.textMessageCompanyName?.length||0),mergeFieldsResponse:N}),t.jsx("div",{className:"mt-4 flex items-center justify-end",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"file",ref:M,onChange:z,accept:"image/*",className:"hidden"}),t.jsx(H5,b?{variant:"outline",onClick:D,className:"px-4",disabled:A||E,children:"Remove Image"}:{variant:"outline",onClick:O,className:"px-4",disabled:j.length>=1||A||null!==S||E,children:"Add Image"}),t.jsx(H5,{variant:"outline",onClick:R,className:"px-4",children:"Cancel"}),t.jsx(H5,{onClick:B,className:"px-4",disabled:E,children:"Save Changes"})]})})]})]})}),J&&t.jsx("div",{className:"px-4 pt-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"SMS Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The SMS channel is currently disabled. To send SMS messages, please enable the channel by selecting a valid SMS sender and ensuring your SMS application is approved."})]})]})})})}),H?t.jsx("div",{className:"relative flex-1 w-full flex flex-col overflow-hidden",children:t.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col",children:t.jsxs("div",{className:"flex flex-col space-y-4 px-4 pt-4 pb-20",children:[t.jsx("div",{className:"w-full flex-shrink-0 max-w-2xl mx-auto rounded-md",children:t.jsx(ZNe,{})}),t.jsxs("div",{className:"rounded-lg bg-background flex-1 min-h-0 flex flex-col items-center max-w-2xl mx-auto w-full",children:[t.jsxs("div",{className:"flex items-center space-x-2 w-full justify-end p-3",children:[t.jsx(_Ne,{type:_we.SMS}),t.jsx(U,{}),V&&t.jsx(W,{}),H&&t.jsx(DNe,{expandDialogContent:t.jsx(WNe,{smsBody:I,imageUrls:j})})]}),t.jsx(JMe,{body:I,imageUrls:j})]}),t.jsx("p",{className:"text-center text-sm text-muted-foreground flex-shrink-0 pt-4",children:"These previews show exactly how your messages will appear to your customers"})]})})}):t.jsxs(t.Fragment,{children:[J&&t.jsx("div",{className:"px-4 pt-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"SMS Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The SMS channel is currently disabled. To send SMS messages, please enable the channel by selecting a valid SMS sender and ensuring your SMS application is approved."})]})]})})})}),t.jsx(KNe,{type:"sms",disablePreviewSubtext:i})]})]})})},QNe=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1})=>{const[r,o]=a.useState(null),s=R5(),{channelAccounts:l}=Fre(),{state:{hideSms:u}}=a.useContext(rY),{channelSenders:c}=Jre(),{data:d}=$re(),m=a.useMemo((()=>Nle({channelSenders:c?.results??[],channelAccounts:l?.results??[],smsApplication:d})),[c?.results,l?.results,d]);if(a.useEffect((()=>{r||o(s?.emailChannelSenderId?"email":"sms")}),[s?.emailChannelSenderId,r]),!s||!c||!r)return t.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:t.jsx(lY,{text:["Loading..."]})});const h=!s?.smsChannelSenderId||u,p=!s?.emailChannelSenderId,g=0===m.length&&!d;return t.jsxs(TNe,{defaultValue:"email",value:r,onValueChange:e=>o("email"===e?"email":"sms"),className:"flex flex-col gap-4 flex-1 bg-muted rounded-md",children:[t.jsx("div",{className:"max-w-[640px] mx-auto w-full",children:t.jsxs(xNe,{className:"grid w-full "+(h||p?"grid-cols-1":"grid-cols-2"),children:[!p&&t.jsx(ENe,{value:"email",className:"group data-[state=active]:bg-white",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(V5.EmailIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),t.jsx(V5.EmailIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),t.jsx("span",{children:"Email"})]})}),!h&&t.jsx(ENe,{value:"sms",className:"group data-[state=active]:bg-white",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(V5.SmsIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),t.jsx(V5.SmsIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),t.jsx("span",{children:"SMS"}),g&&t.jsx(Fue,{title:"To enable SMS, please complete your business information and request approval from Twilio"})]})})]})}),t.jsx(NNe,{value:"email",children:t.jsx(UNe,{disablePreview:e,disableEditContent:n,disablePreviewSubtext:i})}),t.jsx(NNe,{value:"sms",children:t.jsx(YNe,{disablePreview:e,disableEditContent:n,disablePreviewSubtext:i,setupRequired:g})})]})},XNe="reach-styles-module__h2___J-48W",e_e="reach-styles-module__h3___QiFj-",a_e="reach-styles-module__minorText___1TEN6",t_e=({children:e,className:a})=>t.jsx("h2",{className:XO(XNe,a),children:e}),n_e=({children:e,className:a})=>t.jsx("h3",{className:XO(e_e,a),children:e}),i_e=({children:e,className:a})=>t.jsx("p",{className:XO(a_e,a),children:e}),r_e=({title:e,children:a,headerActions:n})=>t.jsxs("div",{className:"max-w-[1000px] mx-auto w-full flex-1 flex flex-col gap-4 pt-4",children:[t.jsxs("div",{className:"px-4 flex",children:[t.jsx(t_e,{className:"text-primary",children:e}),n&&t.jsx("div",{className:"ml-auto",children:n})]}),a]}),o_e=()=>t.jsx(r_e,{title:"Preview & Schedule",children:t.jsx(QNe,{disablePreview:!0,disableEditContent:!0,disablePreviewSubtext:!0})}),s_e=()=>{const e=B5(),n=R5(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre(),{data:o}=$re(),[s,l]=a.useState(null),[u,c]=a.useState(null),[d,m]=a.useState(null),[h,p]=a.useState(null);return a.useEffect((()=>{i&&m(i),r&&p(r)}),[i,r]),a.useEffect((()=>{if(n&&d&&h){const e=n.emailChannelSenderId,a=n.smsChannelSenderId,t=d.results.find((a=>a.id===e)),i=d.results.find((e=>e.id===a));if(t&&n.emailSubject&&n.emailHtmlBody){const e=t.channelSenderMetadata?.userPart,a=h.results.find((e=>e.id===t.channelAccountId));if(a)switch(a.channelAccountMetadata.type){case Gre.REACH_MANAGED:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:t.channelSenderMetadata?.emailFromName,subject:n.emailSubject,previewText:n.emailPreviewText,body:n.emailHtmlBody});break;case Gre.REACH_MANAGED_SES:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:t.channelSenderMetadata?.emailFromName,subject:n.emailSubject,previewText:n.emailPreviewText,body:n.emailHtmlBody});break;case Gre.TWILLIO:break;default:throw jre(a.channelAccountMetadata.type,Gre)}}(o||i)&&n.smsMessageBody&&c({fromPhone:i?wEe(i.channelSenderMetadata):"",body:n.smsMessageBody,companyName:n.textMessageCompanyName})}}),[n,d,h,o]),e?t.jsx("div",s||u?{className:"w-full",children:t.jsx("div",{className:"flex flex-col gap-4 w-full",children:t.jsx(o_e,{})})}:{className:"flex justify-center items-center h-full",children:t.jsx("div",{children:"No preview data Please complete previous steps"})}):t.jsx(lY,{text:["Loading..."]})};function l_e(e){return(l_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u_e(e){if(null===e||!0===e||!1===e)return NaN;var a=Number(e);return isNaN(a)?a:a<0?Math.ceil(a):Math.floor(a)}function c_e(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function d_e(e){c_e(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||"object"===l_e(e)&&"[object Date]"===a?new Date(e.getTime()):"number"==typeof e||"[object Number]"===a?new Date(e):new Date(NaN)}function m_e(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a);return isNaN(n)?new Date(NaN):n?(t.setDate(t.getDate()+n),t):t}function h_e(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a);if(isNaN(n))return new Date(NaN);if(!n)return t;var i=t.getDate(),r=new Date(t.getTime());return r.setMonth(t.getMonth()+n+1,0),i>=r.getDate()?r:(t.setFullYear(r.getFullYear(),r.getMonth(),i),t)}var p_e={};function g_e(){return p_e}function f_e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==t?t:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=d_e(e),h=m.getDay(),p=(h<d?7:0)+h-d;return m.setDate(m.getDate()-p),m.setHours(0,0,0,0),m}function v_e(e){return c_e(1,arguments),f_e(e,{weekStartsOn:1})}function y_e(e){c_e(1,arguments);var a=function(e){c_e(1,arguments);var a=d_e(e),t=a.getFullYear(),n=new Date(0);n.setFullYear(t+1,0,4),n.setHours(0,0,0,0);var i=v_e(n),r=new Date(0);r.setFullYear(t,0,4),r.setHours(0,0,0,0);var o=v_e(r);return a.getTime()>=i.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}(e),t=new Date(0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),v_e(t)}function b_e(e){var a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),e.getTime()-a.getTime()}function k_e(e){c_e(1,arguments);var a=d_e(e);return a.setHours(0,0,0,0),a}function S_e(e,a){c_e(2,arguments);var t=k_e(e),n=k_e(a),i=t.getTime()-b_e(t),r=n.getTime()-b_e(n);return Math.round((i-r)/864e5)}function w_e(e,a){return c_e(2,arguments),m_e(e,7*u_e(a))}function A_e(e,a){return c_e(2,arguments),h_e(e,12*u_e(a))}function C_e(e,a){c_e(2,arguments);var t=k_e(e),n=k_e(a);return t.getTime()===n.getTime()}function M_e(e){return c_e(1,arguments),e instanceof Date||"object"===l_e(e)&&"[object Date]"===Object.prototype.toString.call(e)}function T_e(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return 12*(t.getFullYear()-n.getFullYear())+(t.getMonth()-n.getMonth())}function x_e(e){c_e(1,arguments);var a=d_e(e),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(23,59,59,999),a}function E_e(e){c_e(1,arguments);var a=d_e(e);return a.setDate(1),a.setHours(0,0,0,0),a}function N_e(e){c_e(1,arguments);var a=d_e(e),t=new Date(0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}function __e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==t?t:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=d_e(e),h=m.getDay(),p=6+(h<d?-7:0)-(h-d);return m.setDate(m.getDate()+p),m.setHours(23,59,59,999),m}function P_e(e){return c_e(1,arguments),__e(e,{weekStartsOn:1})}function j_e(e,a){return c_e(2,arguments),function(e,a){c_e(2,arguments);var t=d_e(e).getTime(),n=u_e(a);return new Date(t+n)}(e,-u_e(a))}function L_e(e){c_e(1,arguments);var a=d_e(e),t=a.getUTCDay(),n=(t<1?7:0)+t-1;return a.setUTCDate(a.getUTCDate()-n),a.setUTCHours(0,0,0,0),a}function B_e(e){c_e(1,arguments);var a=d_e(e),t=a.getUTCFullYear(),n=new Date(0);n.setUTCFullYear(t+1,0,4),n.setUTCHours(0,0,0,0);var i=L_e(n),r=new Date(0);r.setUTCFullYear(t,0,4),r.setUTCHours(0,0,0,0);var o=L_e(r);return a.getTime()>=i.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function R_e(e){c_e(1,arguments);var a=d_e(e),t=L_e(a).getTime()-function(e){c_e(1,arguments);var a=B_e(e),t=new Date(0);return t.setUTCFullYear(a,0,4),t.setUTCHours(0,0,0,0),L_e(t)}(a).getTime();return Math.round(t/6048e5)+1}function D_e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==t?t:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=d_e(e),h=m.getUTCDay(),p=(h<d?7:0)+h-d;return m.setUTCDate(m.getUTCDate()-p),m.setUTCHours(0,0,0,0),m}function z_e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=d_e(e),d=c.getUTCFullYear(),m=g_e(),h=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==n?n:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setUTCFullYear(d+1,0,h),p.setUTCHours(0,0,0,0);var g=D_e(p,a),f=new Date(0);f.setUTCFullYear(d,0,h),f.setUTCHours(0,0,0,0);var v=D_e(f,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=v.getTime()?d:d-1}function O_e(e,a){c_e(1,arguments);var t=d_e(e),n=D_e(t,a).getTime()-function(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1),m=z_e(e,a),h=new Date(0);return h.setUTCFullYear(m,0,d),h.setUTCHours(0,0,0,0),D_e(h,a)}(t,a).getTime();return Math.round(n/6048e5)+1}function K_e(e,a){for(var t=e<0?"-":"",n=Math.abs(e).toString();n.length<a;)n="0"+n;return t+n}var H_e=function(e,a){var t=e.getUTCFullYear(),n=t>0?t:1-t;return K_e("yy"===a?n%100:n,a.length)},I_e=function(e,a){var t=e.getUTCMonth();return"M"===a?String(t+1):K_e(t+1,2)},F_e=function(e,a){return K_e(e.getUTCDate(),a.length)},G_e=function(e,a){return K_e(e.getUTCHours()%12||12,a.length)},V_e=function(e,a){return K_e(e.getUTCHours(),a.length)},J_e=function(e,a){return K_e(e.getUTCMinutes(),a.length)},U_e=function(e,a){return K_e(e.getUTCSeconds(),a.length)},W_e=function(e,a){var t=a.length,n=e.getUTCMilliseconds();return K_e(Math.floor(n*Math.pow(10,t-3)),a.length)},q_e="midnight",$_e="noon",Z_e="morning",Y_e="afternoon",Q_e="evening",X_e="night",ePe={G:function(e,a,t){var n=e.getUTCFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});default:return t.era(n,{width:"wide"})}},y:function(e,a,t){if("yo"===a){var n=e.getUTCFullYear();return t.ordinalNumber(n>0?n:1-n,{unit:"year"})}return H_e(e,a)},Y:function(e,a,t,n){var i=z_e(e,n),r=i>0?i:1-i;return"YY"===a?K_e(r%100,2):"Yo"===a?t.ordinalNumber(r,{unit:"year"}):K_e(r,a.length)},R:function(e,a){return K_e(B_e(e),a.length)},u:function(e,a){return K_e(e.getUTCFullYear(),a.length)},Q:function(e,a,t){var n=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"Q":return String(n);case"QQ":return K_e(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,a,t){var n=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"q":return String(n);case"qq":return K_e(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,a,t){var n=e.getUTCMonth();switch(a){case"M":case"MM":return I_e(e,a);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(e,a,t){var n=e.getUTCMonth();switch(a){case"L":return String(n+1);case"LL":return K_e(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(e,a,t,n){var i=O_e(e,n);return"wo"===a?t.ordinalNumber(i,{unit:"week"}):K_e(i,a.length)},I:function(e,a,t){var n=R_e(e);return"Io"===a?t.ordinalNumber(n,{unit:"week"}):K_e(n,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getUTCDate(),{unit:"date"}):F_e(e,a)},D:function(e,a,t){var n=function(e){c_e(1,arguments);var a=d_e(e),t=a.getTime();a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0);var n=a.getTime();return Math.floor((t-n)/864e5)+1}(e);return"Do"===a?t.ordinalNumber(n,{unit:"dayOfYear"}):K_e(n,a.length)},E:function(e,a,t){var n=e.getUTCDay();switch(a){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(e,a,t,n){var i=e.getUTCDay(),r=(i-n.weekStartsOn+8)%7||7;switch(a){case"e":return String(r);case"ee":return K_e(r,2);case"eo":return t.ordinalNumber(r,{unit:"day"});case"eee":return t.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(i,{width:"short",context:"formatting"});default:return t.day(i,{width:"wide",context:"formatting"})}},c:function(e,a,t,n){var i=e.getUTCDay(),r=(i-n.weekStartsOn+8)%7||7;switch(a){case"c":return String(r);case"cc":return K_e(r,a.length);case"co":return t.ordinalNumber(r,{unit:"day"});case"ccc":return t.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(i,{width:"narrow",context:"standalone"});case"cccccc":return t.day(i,{width:"short",context:"standalone"});default:return t.day(i,{width:"wide",context:"standalone"})}},i:function(e,a,t){var n=e.getUTCDay(),i=0===n?7:n;switch(a){case"i":return String(i);case"ii":return K_e(i,a.length);case"io":return t.ordinalNumber(i,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(e,a,t){var n=e.getUTCHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(n,{width:"narrow",context:"formatting"});default:return t.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(e,a,t){var n,i=e.getUTCHours();switch(n=12===i?$_e:0===i?q_e:i/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(n,{width:"narrow",context:"formatting"});default:return t.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(e,a,t){var n,i=e.getUTCHours();switch(n=i>=17?Q_e:i>=12?Y_e:i>=4?Z_e:X_e,a){case"B":case"BB":case"BBB":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(n,{width:"narrow",context:"formatting"});default:return t.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(e,a,t){if("ho"===a){var n=e.getUTCHours()%12;return 0===n&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return G_e(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getUTCHours(),{unit:"hour"}):V_e(e,a)},K:function(e,a,t){var n=e.getUTCHours()%12;return"Ko"===a?t.ordinalNumber(n,{unit:"hour"}):K_e(n,a.length)},k:function(e,a,t){var n=e.getUTCHours();return 0===n&&(n=24),"ko"===a?t.ordinalNumber(n,{unit:"hour"}):K_e(n,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):J_e(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):U_e(e,a)},S:function(e,a){return W_e(e,a)},X:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(a){case"X":return tPe(i);case"XXXX":case"XX":return nPe(i);default:return nPe(i,":")}},x:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();switch(a){case"x":return tPe(i);case"xxxx":case"xx":return nPe(i);default:return nPe(i,":")}},O:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+aPe(i,":");default:return"GMT"+nPe(i,":")}},z:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+aPe(i,":");default:return"GMT"+nPe(i,":")}},t:function(e,a,t,n){return K_e(Math.floor((n._originalDate||e).getTime()/1e3),a.length)},T:function(e,a,t,n){return K_e((n._originalDate||e).getTime(),a.length)}};function aPe(e,a){var t=e>0?"-":"+",n=Math.abs(e),i=Math.floor(n/60),r=n%60;if(0===r)return t+String(i);var o=a;return t+String(i)+o+K_e(r,2)}function tPe(e,a){return e%60==0?(e>0?"-":"+")+K_e(Math.abs(e)/60,2):nPe(e,a)}function nPe(e,a){var t=a||"",n=e>0?"-":"+",i=Math.abs(e);return n+K_e(Math.floor(i/60),2)+t+K_e(i%60,2)}var iPe=function(e,a){switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},rPe=function(e,a){switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},oPe={p:rPe,P:function(e,a){var t,n=e.match(/(P+)(p+)?/)||[],i=n[1],r=n[2];if(!r)return iPe(e,a);switch(i){case"P":t=a.dateTime({width:"short"});break;case"PP":t=a.dateTime({width:"medium"});break;case"PPP":t=a.dateTime({width:"long"});break;default:t=a.dateTime({width:"full"})}return t.replace("{{date}}",iPe(i,a)).replace("{{time}}",rPe(r,a))}},sPe=["D","DD"],lPe=["YY","YYYY"];function uPe(e,a,t){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(a,"`) for formatting years to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("YY"===e)throw new RangeError("Use `yy` instead of `YY` (in `".concat(a,"`) for formatting years to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("D"===e)throw new RangeError("Use `d` instead of `D` (in `".concat(a,"`) for formatting days of the month to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("DD"===e)throw new RangeError("Use `dd` instead of `DD` (in `".concat(a,"`) for formatting days of the month to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var cPe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function dPe(e){return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}var mPe={date:dPe({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:dPe({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:dPe({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},hPe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function pPe(e){return function(a,t){var n;if("formatting"===(null!=t&&t.context?String(t.context):"standalone")&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,r=null!=t&&t.width?String(t.width):i;n=e.formattingValues[r]||e.formattingValues[i]}else{var o=e.defaultWidth,s=null!=t&&t.width?String(t.width):e.defaultWidth;n=e.values[s]||e.values[o]}return n[e.argumentCallback?e.argumentCallback(a):a]}}var gPe={ordinalNumber:function(e,a){var t=Number(e),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:pPe({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:pPe({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:pPe({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:pPe({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:pPe({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function fPe(e){return function(a){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.width,i=a.match(n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth]);if(!i)return null;var r,o=i[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,a){for(var t=0;t<e.length;t++)if(a(e[t]))return t;return}(s,(function(e){return e.test(o)})):function(e,a){for(var t in e)if(e.hasOwnProperty(t)&&a(e[t]))return t;return}(s,(function(e){return e.test(o)}));return r=e.valueCallback?e.valueCallback(l):l,{value:r=t.valueCallback?t.valueCallback(r):r,rest:a.slice(o.length)}}}var vPe={ordinalNumber:function(e){return function(a){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=a.match(e.matchPattern);if(!n)return null;var i=n[0],r=a.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];return{value:o=t.valueCallback?t.valueCallback(o):o,rest:a.slice(i.length)}}}({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:fPe({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:fPe({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:fPe({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:fPe({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:fPe({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},yPe={code:"en-US",formatDistance:function(e,a,t){var n,i=cPe[e];return n="string"==typeof i?i:1===a?i.one:i.other.replace("{{count}}",a.toString()),null!=t&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n},formatLong:mPe,formatRelative:function(e,a,t,n){return hPe[e]},localize:gPe,match:vPe,options:{weekStartsOn:0,firstWeekContainsDate:1}},bPe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,kPe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,SPe=/^'([^]*?)'?$/,wPe=/''/g,APe=/[a-zA-Z]/;function CPe(e,a,t){var n,i,r,o,s,l,u,c,d,m,h,p,g,f,v,y,b,k;c_e(2,arguments);var S=String(a),w=g_e(),A=null!==(n=null!==(i=null==t?void 0:t.locale)&&void 0!==i?i:w.locale)&&void 0!==n?n:yPe,C=u_e(null!==(r=null!==(o=null!==(s=null!==(l=null==t?void 0:t.firstWeekContainsDate)&&void 0!==l?l:null==t||null===(u=t.locale)||void 0===u||null===(c=u.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==s?s:w.firstWeekContainsDate)&&void 0!==o?o:null===(d=w.locale)||void 0===d||null===(m=d.options)||void 0===m?void 0:m.firstWeekContainsDate)&&void 0!==r?r:1);if(!(C>=1&&C<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var M=u_e(null!==(h=null!==(p=null!==(g=null!==(f=null==t?void 0:t.weekStartsOn)&&void 0!==f?f:null==t||null===(v=t.locale)||void 0===v||null===(y=v.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==g?g:w.weekStartsOn)&&void 0!==p?p:null===(b=w.locale)||void 0===b||null===(k=b.options)||void 0===k?void 0:k.weekStartsOn)&&void 0!==h?h:0);if(!(M>=0&&M<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!A.localize)throw new RangeError("locale must contain localize property");if(!A.formatLong)throw new RangeError("locale must contain formatLong property");var T=d_e(e);if(!function(e){if(c_e(1,arguments),!M_e(e)&&"number"!=typeof e)return!1;var a=d_e(e);return!isNaN(Number(a))}(T))throw new RangeError("Invalid time value");var x=j_e(T,b_e(T)),E={firstWeekContainsDate:C,weekStartsOn:M,locale:A,_originalDate:T};return S.match(kPe).map((function(e){var a=e[0];return"p"===a||"P"===a?(0,oPe[a])(e,A.formatLong):e})).join("").match(bPe).map((function(n){if("''"===n)return"'";var i=n[0];if("'"===i)return function(e){var a=e.match(SPe);if(!a)return e;return a[1].replace(wPe,"'")}(n);var r=ePe[i];if(r)return null!=t&&t.useAdditionalWeekYearTokens||-1===lPe.indexOf(n)||uPe(n,a,String(e)),null!=t&&t.useAdditionalDayOfYearTokens||!function(e){return-1!==sPe.indexOf(e)}(n)||uPe(n,a,String(e)),r(x,n,A.localize,E);if(i.match(APe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return n})).join("")}function MPe(e){return c_e(1,arguments),Math.floor(function(e){return c_e(1,arguments),d_e(e).getTime()}(e)/1e3)}function TPe(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1),m=function(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=d_e(e),d=c.getFullYear(),m=g_e(),h=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==n?n:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(d+1,0,h),p.setHours(0,0,0,0);var g=f_e(p,a),f=new Date(0);f.setFullYear(d,0,h),f.setHours(0,0,0,0);var v=f_e(f,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=v.getTime()?d:d-1}(e,a),h=new Date(0);return h.setFullYear(m,0,d),h.setHours(0,0,0,0),f_e(h,a)}function xPe(e,a){return c_e(1,arguments),function(e,a,t){c_e(2,arguments);var n=f_e(e,t),i=f_e(a,t),r=n.getTime()-b_e(n),o=i.getTime()-b_e(i);return Math.round((r-o)/6048e5)}(function(e){c_e(1,arguments);var a=d_e(e),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(0,0,0,0),a}(e),E_e(e),a)+1}function EPe(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getTime()>n.getTime()}function NPe(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getTime()<n.getTime()}function _Pe(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()}function PPe(e,a){return c_e(2,arguments),m_e(e,-u_e(a))}function jPe(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a),i=t.getFullYear(),r=t.getDate(),o=new Date(0);o.setFullYear(i,n,15),o.setHours(0,0,0,0);var s=function(e){c_e(1,arguments);var a=d_e(e),t=a.getFullYear(),n=a.getMonth(),i=new Date(0);return i.setFullYear(t,n+1,0),i.setHours(0,0,0,0),i.getDate()}(o);return t.setMonth(n,Math.min(r,s)),t}function LPe(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a);return isNaN(t.getTime())?new Date(NaN):(t.setFullYear(n),t)}var BPe=function(){return BPe=Object.assign||function(e){for(var a,t=1,n=arguments.length;t<n;t++)for(var i in a=arguments[t])Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i]);return e},BPe.apply(this,arguments)};function RPe(e,a,t){for(var n,i=0,r=a.length;i<r;i++)!n&&i in a||(n||(n=Array.prototype.slice.call(a,0,i)),n[i]=a[i]);return e.concat(n||Array.prototype.slice.call(a))}function DPe(e){return"multiple"===e.mode}function zPe(e){return"range"===e.mode}function OPe(e){return"single"===e.mode}"function"==typeof SuppressedError&&SuppressedError;var KPe={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};var HPe=Object.freeze({__proto__:null,formatCaption:function(e,a){return CPe(e,"LLLL y",a)},formatDay:function(e,a){return CPe(e,"d",a)},formatMonthCaption:function(e,a){return CPe(e,"LLLL",a)},formatWeekNumber:function(e){return"".concat(e)},formatWeekdayName:function(e,a){return CPe(e,"cccccc",a)},formatYearCaption:function(e,a){return CPe(e,"yyyy",a)}}),IPe=Object.freeze({__proto__:null,labelDay:function(e,a,t){return CPe(e,"do MMMM (EEEE)",t)},labelMonthDropdown:function(){return"Month: "},labelNext:function(){return"Go to next month"},labelPrevious:function(){return"Go to previous month"},labelWeekNumber:function(e){return"Week n. ".concat(e)},labelWeekday:function(e,a){return CPe(e,"cccc",a)},labelYearDropdown:function(){return"Year: "}});var FPe=a.createContext(void 0);function GPe(e){var a,n,i=e.initialProps,r={captionLayout:"buttons",classNames:KPe,formatters:HPe,labels:IPe,locale:yPe,modifiersClassNames:{},modifiers:{},numberOfMonths:1,styles:{},today:new Date,mode:"default"},o=function(e){var a=e.fromYear,t=e.toYear,n=e.fromMonth,i=e.toMonth,r=e.fromDate,o=e.toDate;return n?r=E_e(n):a&&(r=new Date(a,0,1)),i?o=x_e(i):t&&(o=new Date(t,11,31)),{fromDate:r?k_e(r):void 0,toDate:o?k_e(o):void 0}}(i),s=o.fromDate,l=o.toDate,u=null!==(a=i.captionLayout)&&void 0!==a?a:r.captionLayout;"buttons"===u||s&&l||(u="buttons"),(OPe(i)||DPe(i)||zPe(i))&&(n=i.onSelect);var c=BPe(BPe(BPe({},r),i),{captionLayout:u,classNames:BPe(BPe({},r.classNames),i.classNames),components:BPe({},i.components),formatters:BPe(BPe({},r.formatters),i.formatters),fromDate:s,labels:BPe(BPe({},r.labels),i.labels),mode:i.mode||r.mode,modifiers:BPe(BPe({},r.modifiers),i.modifiers),modifiersClassNames:BPe(BPe({},r.modifiersClassNames),i.modifiersClassNames),onSelect:n,styles:BPe(BPe({},r.styles),i.styles),toDate:l});return t.jsx(FPe.Provider,{value:c,children:e.children})}function VPe(){var e=a.useContext(FPe);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function JPe(e){var a=VPe();return t.jsx("div",{className:a.classNames.caption_label,style:a.styles.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:(0,a.formatters.formatCaption)(e.displayMonth,{locale:a.locale})})}function UPe(e){return t.jsx("svg",BPe({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:t.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function WPe(e){var a,n,i=e.onChange,r=e.value,o=e.children,s=e.caption,l=e.className,u=e.style,c=VPe(),d=null!==(n=null===(a=c.components)||void 0===a?void 0:a.IconDropdown)&&void 0!==n?n:UPe;return t.jsxs("div",{className:l,style:u,children:[t.jsx("span",{className:c.classNames.vhidden,children:e["aria-label"]}),t.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:r,onChange:i,children:o}),t.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[s,t.jsx(d,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function qPe(e){var a,n=VPe(),i=n.fromDate,r=n.toDate,o=n.styles,s=n.locale,l=n.formatters.formatMonthCaption,u=n.classNames,c=n.components,d=n.labels.labelMonthDropdown;if(!i)return t.jsx(t.Fragment,{});if(!r)return t.jsx(t.Fragment,{});var m=[];if(function(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getFullYear()===n.getFullYear()}(i,r))for(var h=E_e(i),p=i.getMonth();p<=r.getMonth();p++)m.push(jPe(h,p));else for(h=E_e(new Date),p=0;p<=11;p++)m.push(jPe(h,p));var g=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:WPe;return t.jsx(g,{name:"months","aria-label":d(),className:u.dropdown_month,style:o.dropdown_month,onChange:function(a){var t=Number(a.target.value),n=jPe(E_e(e.displayMonth),t);e.onChange(n)},value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:s}),children:m.map((function(e){return t.jsx("option",{value:e.getMonth(),children:l(e,{locale:s})},e.getMonth())}))})}function $Pe(e){var a,n=e.displayMonth,i=VPe(),r=i.fromDate,o=i.toDate,s=i.locale,l=i.styles,u=i.classNames,c=i.components,d=i.formatters.formatYearCaption,m=i.labels.labelYearDropdown,h=[];if(!r)return t.jsx(t.Fragment,{});if(!o)return t.jsx(t.Fragment,{});for(var p=r.getFullYear(),g=o.getFullYear(),f=p;f<=g;f++)h.push(LPe(N_e(new Date),f));var v=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:WPe;return t.jsx(v,{name:"years","aria-label":m(),className:u.dropdown_year,style:l.dropdown_year,onChange:function(a){var t=LPe(E_e(n),Number(a.target.value));e.onChange(t)},value:n.getFullYear(),caption:d(n,{locale:s}),children:h.map((function(e){return t.jsx("option",{value:e.getFullYear(),children:d(e,{locale:s})},e.getFullYear())}))})}function ZPe(){var e=VPe(),t=function(e){var a=e.month||e.defaultMonth||e.today||new Date,t=e.toDate,n=e.fromDate,i=e.numberOfMonths,r=void 0===i?1:i;return t&&T_e(t,a)<0&&(a=h_e(t,-1*(r-1))),n&&T_e(a,n)<0&&(a=n),E_e(a)}(e),n=function(e,t){var n=a.useState(e);return[void 0===t?n[0]:t,n[1]]}(t,e.month),i=n[1];return[n[0],function(a){var t;if(!e.disableNavigation){var n=E_e(a);i(n),null===(t=e.onMonthChange)||void 0===t||t.call(e,n)}}]}var YPe=a.createContext(void 0);function QPe(e){var a=VPe(),n=ZPe(),i=n[0],r=n[1],o=function(e,a){for(var t=a.reverseMonths,n=a.numberOfMonths,i=E_e(e),r=T_e(E_e(h_e(i,n)),i),o=[],s=0;s<r;s++){var l=h_e(i,s);o.push(l)}return t&&(o=o.reverse()),o}(i,a),s=function(e,a){if(!a.disableNavigation){var t=a.toDate,n=a.numberOfMonths,i=void 0===n?1:n,r=a.pagedNavigation?i:1,o=E_e(e);if(!t)return h_e(o,r);if(!(T_e(t,e)<i))return h_e(o,r)}}(i,a),l=function(e,a){if(!a.disableNavigation){var t=a.fromDate,n=a.numberOfMonths,i=a.pagedNavigation?void 0===n?1:n:1,r=E_e(e);if(!t)return h_e(r,-i);if(!(T_e(r,t)<=0))return h_e(r,-i)}}(i,a),u=function(e){return o.some((function(a){return _Pe(e,a)}))};return t.jsx(YPe.Provider,{value:{currentMonth:i,displayMonths:o,goToMonth:r,goToDate:function(e,t){u(e)||(t&&NPe(e,t)?r(h_e(e,1+-1*a.numberOfMonths)):r(e))},previousMonth:l,nextMonth:s,isDateDisplayed:u},children:e.children})}function XPe(){var e=a.useContext(YPe);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function eje(e){var a,n=VPe(),i=n.classNames,r=n.styles,o=n.components,s=XPe().goToMonth,l=function(a){s(h_e(a,e.displayIndex?-e.displayIndex:0))},u=null!==(a=null==o?void 0:o.CaptionLabel)&&void 0!==a?a:JPe,c=t.jsx(u,{id:e.id,displayMonth:e.displayMonth});return t.jsxs("div",{className:i.caption_dropdowns,style:r.caption_dropdowns,children:[t.jsx("div",{className:i.vhidden,children:c}),t.jsx(qPe,{onChange:l,displayMonth:e.displayMonth}),t.jsx($Pe,{onChange:l,displayMonth:e.displayMonth})]})}function aje(e){return t.jsx("svg",BPe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function tje(e){return t.jsx("svg",BPe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var nje=a.forwardRef((function(e,a){var n=VPe(),i=n.classNames,r=n.styles,o=[i.button_reset,i.button];e.className&&o.push(e.className);var s=o.join(" "),l=BPe(BPe({},r.button_reset),r.button);return e.style&&Object.assign(l,e.style),t.jsx("button",BPe({},e,{ref:a,type:"button",className:s,style:l}))}));function ije(e){var a,n,i=VPe(),r=i.dir,o=i.locale,s=i.classNames,l=i.styles,u=i.labels,c=u.labelPrevious,d=u.labelNext,m=i.components;if(!e.nextMonth&&!e.previousMonth)return t.jsx(t.Fragment,{});var h=c(e.previousMonth,{locale:o}),p=[s.nav_button,s.nav_button_previous].join(" "),g=d(e.nextMonth,{locale:o}),f=[s.nav_button,s.nav_button_next].join(" "),v=null!==(a=null==m?void 0:m.IconRight)&&void 0!==a?a:tje,y=null!==(n=null==m?void 0:m.IconLeft)&&void 0!==n?n:aje;return t.jsxs("div",{className:s.nav,style:l.nav,children:[!e.hidePrevious&&t.jsx(nje,{name:"previous-month","aria-label":h,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:t.jsx("rtl"===r?v:y,{className:s.nav_icon,style:l.nav_icon})}),!e.hideNext&&t.jsx(nje,{name:"next-month","aria-label":g,className:f,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:t.jsx("rtl"===r?y:v,{className:s.nav_icon,style:l.nav_icon})})]})}function rje(e){var a=VPe().numberOfMonths,n=XPe(),i=n.previousMonth,r=n.nextMonth,o=n.goToMonth,s=n.displayMonths,l=s.findIndex((function(a){return _Pe(e.displayMonth,a)})),u=0===l,c=l===s.length-1;return t.jsx(ije,{displayMonth:e.displayMonth,hideNext:a>1&&(u||!c),hidePrevious:a>1&&(c||!u),nextMonth:r,previousMonth:i,onPreviousClick:function(){i&&o(i)},onNextClick:function(){r&&o(r)}})}function oje(e){var a,n,i=VPe(),r=i.classNames,o=i.styles,s=i.captionLayout,l=i.components,u=null!==(a=null==l?void 0:l.CaptionLabel)&&void 0!==a?a:JPe;return n=i.disableNavigation?t.jsx(u,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===s?t.jsx(eje,{displayMonth:e.displayMonth,id:e.id}):t.jsxs(t.Fragment,"dropdown-buttons"===s?{children:[t.jsx(eje,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),t.jsx(rje,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}:{children:[t.jsx(u,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx(rje,{displayMonth:e.displayMonth,id:e.id})]}),t.jsx("div",{className:r.caption,style:o.caption,children:n})}function sje(e){var a=VPe(),n=a.footer;return n?t.jsx("tfoot",{className:a.classNames.tfoot,style:a.styles.tfoot,children:t.jsx("tr",{children:t.jsx("td",{colSpan:8,children:n})})}):t.jsx(t.Fragment,{})}function lje(){var e=VPe(),a=e.classNames,n=e.styles,i=e.showWeekNumber,r=e.locale,o=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,l=function(e,a,t){for(var n=t?v_e(new Date):f_e(new Date,{locale:e,weekStartsOn:a}),i=[],r=0;r<7;r++){var o=m_e(n,r);i.push(o)}return i}(r,e.weekStartsOn,e.ISOWeek);return t.jsxs("tr",{style:n.head_row,className:a.head_row,children:[i&&t.jsx("td",{style:n.head_cell,className:a.head_cell}),l.map((function(e,i){return t.jsx("th",{scope:"col",className:a.head_cell,style:n.head_cell,"aria-label":s(e,{locale:r}),children:o(e,{locale:r})},i)}))]})}function uje(){var e,a=VPe(),n=a.components,i=null!==(e=null==n?void 0:n.HeadRow)&&void 0!==e?e:lje;return t.jsx("thead",{style:a.styles.head,className:a.classNames.head,children:t.jsx(i,{})})}function cje(e){var a=VPe();return t.jsx(t.Fragment,{children:(0,a.formatters.formatDay)(e.date,{locale:a.locale})})}var dje=a.createContext(void 0);function mje(e){if(!DPe(e.initialProps)){return t.jsx(dje.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}return t.jsx(hje,{initialProps:e.initialProps,children:e.children})}function hje(e){var a=e.initialProps,n=e.children,i=a.selected,r=a.min,o=a.max,s={disabled:[]};return i&&s.disabled.push((function(e){var a=o&&i.length>o-1,t=i.some((function(a){return C_e(a,e)}));return Boolean(a&&!t)})),t.jsx(dje.Provider,{value:{selected:i,onDayClick:function(e,t,n){var s,l;if((null===(s=a.onDayClick)||void 0===s||s.call(a,e,t,n),!Boolean(t.selected&&r&&(null==i?void 0:i.length)===r))&&!Boolean(!t.selected&&o&&(null==i?void 0:i.length)===o)){var u=i?RPe([],i):[];if(t.selected){var c=u.findIndex((function(a){return C_e(e,a)}));u.splice(c,1)}else u.push(e);null===(l=a.onSelect)||void 0===l||l.call(a,u,e,t,n)}},modifiers:s},children:n})}function pje(){var e=a.useContext(dje);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var gje,fje,vje=a.createContext(void 0);function yje(e){if(!zPe(e.initialProps)){return t.jsx(vje.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}return t.jsx(bje,{initialProps:e.initialProps,children:e.children})}function bje(e){var a=e.initialProps,n=e.children,i=a.selected,r=i||{},o=r.from,s=r.to,l=a.min,u=a.max,c={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(c.range_start=[o],s?(c.range_end=[s],C_e(o,s)||(c.range_middle=[{after:o,before:s}])):c.range_end=[o]):s&&(c.range_start=[s],c.range_end=[s]),l&&(o&&!s&&c.disabled.push({after:PPe(o,l-1),before:m_e(o,l-1)}),o&&s&&c.disabled.push({after:o,before:m_e(o,l-1)}),!o&&s&&c.disabled.push({after:PPe(s,l-1),before:m_e(s,l-1)})),u){if(o&&!s&&(c.disabled.push({before:m_e(o,1-u)}),c.disabled.push({after:m_e(o,u-1)})),o&&s){var d=u-(S_e(s,o)+1);c.disabled.push({before:PPe(o,d)}),c.disabled.push({after:m_e(s,d)})}!o&&s&&(c.disabled.push({before:m_e(s,1-u)}),c.disabled.push({after:m_e(s,u-1)}))}return t.jsx(vje.Provider,{value:{selected:i,onDayClick:function(e,t,n){var r,o;null===(r=a.onDayClick)||void 0===r||r.call(a,e,t,n);var s=function(e,a){var t=a||{},n=t.from,i=t.to;if(n&&i){if(C_e(i,e)&&C_e(n,e))return;if(C_e(i,e))return{from:i,to:void 0};if(C_e(n,e))return;return EPe(n,e)?{from:e,to:i}:{from:n,to:e}}return i?EPe(e,i)?{from:i,to:e}:{from:e,to:i}:n?NPe(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}(e,i);null===(o=a.onSelect)||void 0===o||o.call(a,s,e,t,n)},modifiers:c},children:n})}function kje(){var e=a.useContext(vje);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Sje(e){return Array.isArray(e)?RPe([],e):void 0!==e?[e]:[]}(fje=gje||(gje={})).Outside="outside",fje.Disabled="disabled",fje.Selected="selected",fje.Hidden="hidden",fje.Today="today",fje.RangeStart="range_start",fje.RangeEnd="range_end",fje.RangeMiddle="range_middle";var wje=gje.Selected,Aje=gje.Disabled,Cje=gje.Hidden,Mje=gje.Today,Tje=gje.RangeEnd,xje=gje.RangeMiddle,Eje=gje.RangeStart,Nje=gje.Outside;var _je=a.createContext(void 0);function Pje(e){var a=VPe(),n=function(e,a,t){var n,i=((n={})[wje]=Sje(e.selected),n[Aje]=Sje(e.disabled),n[Cje]=Sje(e.hidden),n[Mje]=[e.today],n[Tje]=[],n[xje]=[],n[Eje]=[],n[Nje]=[],n);return e.fromDate&&i[Aje].push({before:e.fromDate}),e.toDate&&i[Aje].push({after:e.toDate}),DPe(e)?i[Aje]=i[Aje].concat(a.modifiers[Aje]):zPe(e)&&(i[Aje]=i[Aje].concat(t.modifiers[Aje]),i[Eje]=t.modifiers[Eje],i[xje]=t.modifiers[xje],i[Tje]=t.modifiers[Tje]),i}(a,pje(),kje()),i=function(e){var a={};return Object.entries(e).forEach((function(e){a[e[0]]=Sje(e[1])})),a}(a.modifiers),r=BPe(BPe({},n),i);return t.jsx(_je.Provider,{value:r,children:e.children})}function jje(){var e=a.useContext(_je);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function Lje(e,a){return a.some((function(a){if("boolean"==typeof a)return a;if(M_e(a))return C_e(e,a);var t,n,i,r,o;if(function(e){return Array.isArray(e)&&e.every(M_e)}(a))return a.includes(e);if(function(e){return Boolean(e&&"object"==typeof e&&"from"in e)}(a))return t=e,o=(n=a).to,(r=n.from)&&o?(S_e(o,r)<0&&(r=(i=[o,r])[0],o=i[1]),S_e(t,r)>=0&&S_e(o,t)>=0):o?C_e(o,t):!!r&&C_e(r,t);if(function(e){return Boolean(e&&"object"==typeof e&&"dayOfWeek"in e)}(a))return a.dayOfWeek.includes(e.getDay());if(function(e){return Boolean(e&&"object"==typeof e&&"before"in e&&"after"in e)}(a)){var s=S_e(a.before,e)>0,l=S_e(a.after,e)<0;return EPe(a.before,a.after)?l&&s:s||l}return function(e){return Boolean(e&&"object"==typeof e&&"after"in e)}(a)?S_e(e,a.after)>0:function(e){return Boolean(e&&"object"==typeof e&&"before"in e)}(a)?S_e(a.before,e)>0:"function"==typeof a&&a(e)}))}function Bje(e,a,t){var n=Object.keys(a).reduce((function(t,n){return Lje(e,a[n])&&t.push(n),t}),[]),i={};return n.forEach((function(e){return i[e]=!0})),t&&!_Pe(e,t)&&(i.outside=!0),i}function Rje(e,a){var t=a.moveBy,n=a.direction,i=a.context,r=a.modifiers,o=a.retry,s=void 0===o?{count:0,lastFocused:e}:o,l=i.weekStartsOn,u=i.fromDate,c=i.toDate,d=i.locale,m={day:m_e,week:w_e,month:h_e,year:A_e,startOfWeek:function(e){return i.ISOWeek?v_e(e):f_e(e,{locale:d,weekStartsOn:l})},endOfWeek:function(e){return i.ISOWeek?P_e(e):__e(e,{locale:d,weekStartsOn:l})}}[t](e,"after"===n?1:-1);"before"===n&&u?m=function(e){var a,t;if(c_e(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==l_e(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=d_e(e);(void 0===t||t<a||isNaN(Number(a)))&&(t=a)})),t||new Date(NaN)}([u,m]):"after"===n&&c&&(m=function(e){var a,t;if(c_e(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==l_e(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=d_e(e);(void 0===t||t>a||isNaN(a.getDate()))&&(t=a)})),t||new Date(NaN)}([c,m]));var h=!0;if(r){var p=Bje(m,r);h=!p.disabled&&!p.hidden}return h?m:s.count>365?s.lastFocused:Rje(m,{moveBy:t,direction:n,context:i,modifiers:r,retry:BPe(BPe({},s),{count:s.count+1})})}var Dje=a.createContext(void 0);function zje(e){var n=XPe(),i=jje(),r=a.useState(),o=r[0],s=r[1],l=a.useState(),u=l[0],c=l[1],d=function(e,a){for(var t,n,i=E_e(e[0]),r=x_e(e[e.length-1]),o=i;o<=r;){var s=Bje(o,a);if(s.disabled||s.hidden)o=m_e(o,1);else{if(s.selected)return o;s.today&&!n&&(n=o),t||(t=o),o=m_e(o,1)}}return n||t}(n.displayMonths,i),m=(null!=o?o:u&&n.isDateDisplayed(u))?u:d,h=function(e){s(e)},p=VPe(),g=function(e,a){if(o){var t=Rje(o,{moveBy:e,direction:a,context:p,modifiers:i});C_e(o,t)||(n.goToDate(t,o),h(t))}};return t.jsx(Dje.Provider,{value:{focusedDay:o,focusTarget:m,blur:function(){c(o),s(void 0)},focus:h,focusDayAfter:function(){return g("day","after")},focusDayBefore:function(){return g("day","before")},focusWeekAfter:function(){return g("week","after")},focusWeekBefore:function(){return g("week","before")},focusMonthBefore:function(){return g("month","before")},focusMonthAfter:function(){return g("month","after")},focusYearBefore:function(){return g("year","before")},focusYearAfter:function(){return g("year","after")},focusStartOfWeek:function(){return g("startOfWeek","before")},focusEndOfWeek:function(){return g("endOfWeek","after")}},children:e.children})}function Oje(){var e=a.useContext(Dje);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}var Kje=a.createContext(void 0);function Hje(e){if(!OPe(e.initialProps)){return t.jsx(Kje.Provider,{value:{selected:void 0},children:e.children})}return t.jsx(Ije,{initialProps:e.initialProps,children:e.children})}function Ije(e){var a=e.initialProps;return t.jsx(Kje.Provider,{value:{selected:a.selected,onDayClick:function(e,t,n){var i,r,o;null===(i=a.onDayClick)||void 0===i||i.call(a,e,t,n),!t.selected||a.required?null===(o=a.onSelect)||void 0===o||o.call(a,e,e,t,n):null===(r=a.onSelect)||void 0===r||r.call(a,void 0,e,t,n)}},children:e.children})}function Fje(){var e=a.useContext(Kje);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function Gje(e,a){var t=[e.classNames.day];return Object.keys(a).forEach((function(a){var n=e.modifiersClassNames[a];if(n)t.push(n);else if(function(e){return Object.values(gje).includes(e)}(a)){var i=e.classNames["day_".concat(a)];i&&t.push(i)}})),t}function Vje(e,n,i){var r,o,s,l=VPe(),u=Oje(),c=function(e,a){return Bje(e,jje(),a)}(e,n),d=function(e,a){var t=VPe(),n=Fje(),i=pje(),r=kje(),o=Oje(),s=o.focusDayAfter,l=o.focusDayBefore,u=o.focusWeekAfter,c=o.focusWeekBefore,d=o.blur,m=o.focus,h=o.focusMonthBefore,p=o.focusMonthAfter,g=o.focusYearBefore,f=o.focusYearAfter,v=o.focusStartOfWeek,y=o.focusEndOfWeek;return{onClick:function(o){var s,l,u,c;OPe(t)?null===(s=n.onDayClick)||void 0===s||s.call(n,e,a,o):DPe(t)?null===(l=i.onDayClick)||void 0===l||l.call(i,e,a,o):zPe(t)?null===(u=r.onDayClick)||void 0===u||u.call(r,e,a,o):null===(c=t.onDayClick)||void 0===c||c.call(t,e,a,o)},onFocus:function(n){var i;m(e),null===(i=t.onDayFocus)||void 0===i||i.call(t,e,a,n)},onBlur:function(n){var i;d(),null===(i=t.onDayBlur)||void 0===i||i.call(t,e,a,n)},onKeyDown:function(n){var i;switch(n.key){case"ArrowLeft":n.preventDefault(),n.stopPropagation(),"rtl"===t.dir?s():l();break;case"ArrowRight":n.preventDefault(),n.stopPropagation(),"rtl"===t.dir?l():s();break;case"ArrowDown":n.preventDefault(),n.stopPropagation(),u();break;case"ArrowUp":n.preventDefault(),n.stopPropagation(),c();break;case"PageUp":n.preventDefault(),n.stopPropagation(),n.shiftKey?g():h();break;case"PageDown":n.preventDefault(),n.stopPropagation(),n.shiftKey?f():p();break;case"Home":n.preventDefault(),n.stopPropagation(),v();break;case"End":n.preventDefault(),n.stopPropagation(),y()}null===(i=t.onDayKeyDown)||void 0===i||i.call(t,e,a,n)},onKeyUp:function(n){var i;null===(i=t.onDayKeyUp)||void 0===i||i.call(t,e,a,n)},onMouseEnter:function(n){var i;null===(i=t.onDayMouseEnter)||void 0===i||i.call(t,e,a,n)},onMouseLeave:function(n){var i;null===(i=t.onDayMouseLeave)||void 0===i||i.call(t,e,a,n)},onPointerEnter:function(n){var i;null===(i=t.onDayPointerEnter)||void 0===i||i.call(t,e,a,n)},onPointerLeave:function(n){var i;null===(i=t.onDayPointerLeave)||void 0===i||i.call(t,e,a,n)},onTouchCancel:function(n){var i;null===(i=t.onDayTouchCancel)||void 0===i||i.call(t,e,a,n)},onTouchEnd:function(n){var i;null===(i=t.onDayTouchEnd)||void 0===i||i.call(t,e,a,n)},onTouchMove:function(n){var i;null===(i=t.onDayTouchMove)||void 0===i||i.call(t,e,a,n)},onTouchStart:function(n){var i;null===(i=t.onDayTouchStart)||void 0===i||i.call(t,e,a,n)}}}(e,c),m=function(){var e=VPe(),a=Fje(),t=pje(),n=kje();return OPe(e)?a.selected:DPe(e)?t.selected:zPe(e)?n.selected:void 0}(),h=Boolean(l.onDayClick||"default"!==l.mode);a.useEffect((function(){var a;c.outside||u.focusedDay&&h&&C_e(u.focusedDay,e)&&(null===(a=i.current)||void 0===a||a.focus())}),[u.focusedDay,e,i,h,c.outside]);var p=Gje(l,c).join(" "),g=function(e,a){var t=BPe({},e.styles.day);return Object.keys(a).forEach((function(a){var n;t=BPe(BPe({},t),null===(n=e.modifiersStyles)||void 0===n?void 0:n[a])})),t}(l,c),f=Boolean(c.outside&&!l.showOutsideDays||c.hidden),v=null!==(s=null===(o=l.components)||void 0===o?void 0:o.DayContent)&&void 0!==s?s:cje,y={style:g,className:p,children:t.jsx(v,{date:e,displayMonth:n,activeModifiers:c}),role:"gridcell"},b=u.focusTarget&&C_e(u.focusTarget,e)&&!c.outside,k=u.focusedDay&&C_e(u.focusedDay,e),S=BPe(BPe(BPe({},y),((r={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,r.tabIndex=k||b?0:-1,r)),d);return{isButton:h,isHidden:f,activeModifiers:c,selectedDays:m,buttonProps:S,divProps:y}}function Jje(e){var n=a.useRef(null),i=Vje(e.date,e.displayMonth,n);return i.isHidden?t.jsx("div",{role:"gridcell"}):i.isButton?t.jsx(nje,BPe({name:"day",ref:n},i.buttonProps)):t.jsx("div",BPe({},i.divProps))}function Uje(e){var a=e.number,n=e.dates,i=VPe(),r=i.onWeekNumberClick,o=i.styles,s=i.classNames,l=i.locale,u=i.labels.labelWeekNumber,c=(0,i.formatters.formatWeekNumber)(Number(a),{locale:l});if(!r)return t.jsx("span",{className:s.weeknumber,style:o.weeknumber,children:c});var d=u(Number(a),{locale:l});return t.jsx(nje,{name:"week-number","aria-label":d,className:s.weeknumber,style:o.weeknumber,onClick:function(e){r(a,n,e)},children:c})}function Wje(e){var a,n,i,r=VPe(),o=r.styles,s=r.classNames,l=r.components,u=null!==(a=null==l?void 0:l.Day)&&void 0!==a?a:Jje,c=null!==(n=null==l?void 0:l.WeekNumber)&&void 0!==n?n:Uje;return r.showWeekNumber&&(i=t.jsx("td",{className:s.cell,style:o.cell,children:t.jsx(c,{number:e.weekNumber,dates:e.dates})})),t.jsxs("tr",{className:s.row,style:o.row,children:[i,e.dates.map((function(a){return t.jsx("td",{className:s.cell,style:o.cell,role:"presentation",children:t.jsx(u,{displayMonth:e.displayMonth,date:a})},MPe(a))}))]})}function qje(e,a,t){for(var n=(null==t?void 0:t.ISOWeek)?P_e(a):__e(a,t),i=(null==t?void 0:t.ISOWeek)?v_e(e):f_e(e,t),r=S_e(n,i),o=[],s=0;s<=r;s++)o.push(m_e(i,s));var l=o.reduce((function(e,a){var n=(null==t?void 0:t.ISOWeek)?function(e){c_e(1,arguments);var a=d_e(e),t=v_e(a).getTime()-y_e(a).getTime();return Math.round(t/6048e5)+1}(a):function(e,a){c_e(1,arguments);var t=d_e(e),n=f_e(t,a).getTime()-TPe(t,a).getTime();return Math.round(n/6048e5)+1}(a,t),i=e.find((function(e){return e.weekNumber===n}));return i?(i.dates.push(a),e):(e.push({weekNumber:n,dates:[a]}),e)}),[]);return l}function $je(e){var a,n,i,r=VPe(),o=r.locale,s=r.classNames,l=r.styles,u=r.hideHead,c=r.components,d=r.weekStartsOn,m=r.firstWeekContainsDate,h=r.ISOWeek,p=function(e,a){var t=qje(E_e(e),x_e(e),a);if(null==a?void 0:a.useFixedWeeks){var n=xPe(e,a);if(n<6){var i=t[t.length-1],r=i.dates[i.dates.length-1],o=w_e(r,6-n),s=qje(w_e(r,1),o,a);t.push.apply(t,s)}}return t}(e.displayMonth,{useFixedWeeks:Boolean(r.fixedWeeks),ISOWeek:h,locale:o,weekStartsOn:d,firstWeekContainsDate:m}),g=null!==(a=null==c?void 0:c.Head)&&void 0!==a?a:uje,f=null!==(n=null==c?void 0:c.Row)&&void 0!==n?n:Wje,v=null!==(i=null==c?void 0:c.Footer)&&void 0!==i?i:sje;return t.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&t.jsx(g,{}),t.jsx("tbody",{className:s.tbody,style:l.tbody,children:p.map((function(a){return t.jsx(f,{displayMonth:e.displayMonth,dates:a.dates,weekNumber:a.weekNumber},a.weekNumber)}))}),t.jsx(v,{displayMonth:e.displayMonth})]})}var Zje="undefined"!=typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,Yje=!1,Qje=0;function Xje(){return"react-day-picker-".concat(++Qje)}function eLe(e){var n,i,r=VPe(),o=r.dir,s=r.classNames,l=r.styles,u=r.components,c=XPe().displayMonths,d=function(e){var t,n=null!=e?e:Yje?Xje():null,i=a.useState(n),r=i[0],o=i[1];return Zje((function(){null===r&&o(Xje())}),[]),a.useEffect((function(){!1===Yje&&(Yje=!0)}),[]),null!==(t=null!=e?e:r)&&void 0!==t?t:void 0}(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),m=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,h=[s.month],p=l.month,g=0===e.displayIndex,f=e.displayIndex===c.length-1,v=!g&&!f;"rtl"===o&&(f=(n=[g,f])[0],g=n[1]),g&&(h.push(s.caption_start),p=BPe(BPe({},p),l.caption_start)),f&&(h.push(s.caption_end),p=BPe(BPe({},p),l.caption_end)),v&&(h.push(s.caption_between),p=BPe(BPe({},p),l.caption_between));var y=null!==(i=null==u?void 0:u.Caption)&&void 0!==i?i:oje;return t.jsxs("div",{className:h.join(" "),style:p,children:[t.jsx(y,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx($je,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function aLe(e){var a=VPe();return t.jsx("div",{className:a.classNames.months,style:a.styles.months,children:e.children})}function tLe(e){var n,i,r=e.initialProps,o=VPe(),s=Oje(),l=XPe(),u=a.useState(!1),c=u[0],d=u[1];a.useEffect((function(){o.initialFocus&&s.focusTarget&&(c||(s.focus(s.focusTarget),d(!0)))}),[o.initialFocus,c,s.focus,s.focusTarget,s]);var m=[o.classNames.root,o.className];o.numberOfMonths>1&&m.push(o.classNames.multiple_months),o.showWeekNumber&&m.push(o.classNames.with_weeknumber);var h=BPe(BPe({},o.styles.root),o.style),p=Object.keys(r).filter((function(e){return e.startsWith("data-")})).reduce((function(e,a){var t;return BPe(BPe({},e),((t={})[a]=r[a],t))}),{}),g=null!==(i=null===(n=r.components)||void 0===n?void 0:n.Months)&&void 0!==i?i:aLe;return t.jsx("div",BPe({className:m.join(" "),style:h,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:t.jsx(g,{children:l.displayMonths.map((function(e,a){return t.jsx(eLe,{displayIndex:a,displayMonth:e},a)}))})}))}function nLe(e){var a=e.children,n=function(e,a){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)a.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]])}return t}(e,["children"]);return t.jsx(GPe,{initialProps:n,children:t.jsx(QPe,{children:t.jsx(Hje,{initialProps:n,children:t.jsx(mje,{initialProps:n,children:t.jsx(yje,{initialProps:n,children:t.jsx(Pje,{children:t.jsx(zje,{children:a})})})})})})})}function iLe(e){return t.jsx(nLe,BPe({},e,{children:t.jsx(tLe,{initialProps:e})}))}function rLe({className:e,classNames:a,showOutsideDays:n=!0,...i}){const r={months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:XO(K5({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-[#6b7280] rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-[#f1f5f9] [&:has([aria-selected].day-outside)]:bg-[#f1f5f9]/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",day:XO(K5({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"!bg-black !text-gray-200 hover:!bg-black hover:!text-gray-200 focus:!bg-black focus:!text-white",day_today:"bg-gray-200 text-black",day_outside:"day-outside text-[#94a3b8] aria-selected:bg-[#f1f5f9]/50 aria-selected:text-[#94a3b8]",day_disabled:"text-[#94a3b8] opacity-50",day_range_middle:"aria-selected:bg-[#f1f5f9] aria-selected:text-black",day_hidden:"invisible",...a};return t.jsx(iLe,{showOutsideDays:n,className:XO("p-3",e),classNames:r,components:{IconLeft:()=>t.jsx(iz,{className:"h-4 w-4"}),IconRight:()=>t.jsx(rz,{className:"h-4 w-4"})},...i})}rLe.displayName="Calendar";const oLe=({setScheduleTime:e,setTimezone:a,timezone:n,scheduleTime:i,setIsDirty:o,canEditScheduleTime:s})=>{const[l,u]=r.useState(s&&i&&i<(new Date).toISOString()?"Please select a time in the future":null),[c,d]=r.useState(i&&"now"!==i?Eue(new Date(i),"HH:mm"):"00:00"),m=Intl.supportedValuesOf("timeZone").map((e=>({label:e,value:e}))),h=e=>{if(!s)return;const t=new Date(i||(new Date).toISOString()),n=Ile(new Date,15);t<new Date(n.toLocaleString("en-US",{timeZone:e}))?u("Please select a time at least 15 minutes in the future"):(u(null),a(e),o(!0))},p=a=>{if(!s)return;const t=Ile(new Date,15);new Date(a.toLocaleString("en-US",{timeZone:n}))<new Date(t.toLocaleString("en-US",{timeZone:n}))?u("Please select a time at least 15 minutes in the future"):(u(null),e(a.toISOString()),o(!0))};return t.jsx("div",{className:"w-full @container/schedule-time",children:t.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[t.jsxs("div",{className:"flex gap-2 w-full @xl/schedule-time:flex-row flex-col items-center justify-center",children:[t.jsxs(Nre,{children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{variant:"outline",disabled:!s,className:XO("bg-background w-full sm:w-[280px] justify-start text-left font-normal",!i&&"text-muted-foreground",!s&&"opacity-50 cursor-not-allowed"),children:[t.jsx(ez,{className:"mr-2 h-4 w-4"}),i?"now"===i?"Send immediately":Eue(new Date(i),"PPP"):t.jsx("span",{children:"Pick a date"})]})}),t.jsx(Pre,{className:"w-auto p-0 z-[60] pointer-events-auto",children:t.jsx(rLe,{mode:"single",selected:i?new Date(i):void 0,onSelect:e=>{if(!e||!s)return;const[a,t]=c.split(":").map(Number);e.setHours(a,t),p(e)},disabled:e=>{const a=new Date;return a.setHours(0,0,0,0),e<a||!s},initialFocus:!0})})]}),t.jsx("input",{type:"time",value:c,onChange:e=>{if(s&&(d(e.target.value),i&&e.target.value)){const[a,t]=e.target.value.split(":").map(Number),n=new Date(i);n.setHours(a,t),p(n)}},disabled:!s,className:XO("flex h-9 w-full sm:w-[150px] rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",l&&"border-red-500",!s&&"opacity-50 cursor-not-allowed")}),t.jsx("div",{className:"w-full sm:w-[200px]",children:t.jsx(fEe,{options:m,selectedValues:[n],setSelectedValues:e=>h(e[0]),onValueChange:e=>h(e[0]),placeholder:"Select timezone...",searchPlaceholder:"Search timezone...",emptyMessage:"No timezone found",title:"Select Timezone",singleSelect:!0,canOpen:s})})]}),l&&t.jsxs("p",{className:"text-destructive text-sm mt-2 flex items-center",children:[t.jsx("span",{className:"mr-2",children:"⚠️"}),l]})]})})},sLe=({title:e="Edit Schedule Time"})=>{const n=B5(),i=ce(),{updateAutomation:r}=ra(n?.id||""),{toast:o}=Ve(),[s,l]=a.useState(null),[u,c]=a.useState(n?.triggerMetadata?.triggerType===ua.ONE_TIME?n?.triggerMetadata?.scheduledAt:null),[d,m]=a.useState(n?.triggerMetadata?.triggerType===ua.ONE_TIME&&n?.triggerMetadata?.timezone||"America/New_York"),[h,p]=a.useState(!1),[g,f]=a.useState(null);let v=a.useRef(null);const y=a.useCallback((()=>{n&&("sendNow"===s||"now"===u?r({trigger:{triggerType:ua.ONE_TIME,scheduledAt:"now"}},{onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Be.all})}}):u&&d&&r({trigger:{triggerType:ua.ONE_TIME,scheduledAt:u,timezone:d}},{onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Be.all})}}))}),[n,s,u,d,r,o,i]);if(a.useEffect((()=>(g&&(v.current&&clearTimeout(v.current),v.current=setTimeout((()=>{o(g),f(null)}),800)),()=>{v.current&&clearTimeout(v.current)})),[g,o]),a.useEffect((()=>{n&&h&&s&&("sendNow"===s||u)&&(y(),p(!1))}),[s,u,d,y,n,h]),a.useEffect((()=>{null===s&&n?.triggerMetadata&&"object"==typeof n.triggerMetadata&&null!==n.triggerMetadata&&"scheduledAt"in n.triggerMetadata&&("now"===n?.triggerMetadata?.scheduledAt&&n?.triggerType===ua.ONE_TIME?l("sendNow"):(n?.triggerMetadata?.scheduledAt&&c(n.triggerMetadata.scheduledAt),n?.triggerMetadata?.timezone&&m(n.triggerMetadata.timezone),l("schedule")))}),[n,s]),!n)return null;const b=n.status===ha.DRAFT,k=lH(n?.triggerType===ua.ONE_TIME?"engage:automation":"engage:broadcast");return t.jsx(r_e,{title:e,headerActions:!b&&t.jsx(Fue,{title:"You can only edit the schedule time if the automation is in draft mode"}),children:t.jsx("div",{className:"@container flex-1 mx-4",children:t.jsxs("div",{className:"flex @[1000px]:flex-row flex-col gap-8 items-center",children:[t.jsxs("div",{className:"flex-1 w-full",children:[t.jsxs("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-4",children:[t.jsx(G5,{selected:"sendNow"===s,title:"Immediately",subtitle:`Messages will be sent within ~5 minutes of starting the ${k.toLowerCase()}. Check the Recipients tab to see who has received a message.`,icon:t.jsx(V5.SendButton,{className:"text-primary"}),onClick:()=>{b&&(l("sendNow"),c("now"),m("America/New_York"),p(!0))},disabled:!b}),t.jsx(G5,{selected:"schedule"===s,title:"Schedule",subtitle:`Choose date and time. Any ${k.toLowerCase()} scheduled more than 2 hours from now can be unscheduled and updated.`,icon:t.jsx(V5.ScheduleButton,{className:"text-primary"}),onClick:()=>{b&&l("schedule")},disabled:!b})]}),t.jsx(wY,{children:"schedule"===s&&t.jsx(s5,{className:"overflow-hidden mt-8",children:t.jsx("div",{className:"bg-gray-50 rounded-xl p-5 border border-gray-100 flex items-center justify-center",children:t.jsx(oLe,{setScheduleTime:e=>{c(e),p(!0)},setTimezone:e=>{m(e),p(!0)},timezone:d,scheduleTime:u,setIsDirty:p,canEditScheduleTime:b})})})})]}),u&&"now"!==u&&t.jsx(o5.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.6,ease:[.23,1,.32,1],delay:.1},className:"@[1000px]:w-80 max-w-md w-full shrink-0 h-fit p-4 bg-blue-50 rounded-xl border border-blue-100 backdrop-blur-sm",children:t.jsxs(t.Fragment,{children:[t.jsx(o5.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Currently scheduled for:"}),t.jsx(o5.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short",timeZone:d||void 0})})]})})]})})})},lLe=()=>t.jsx("div",{children:t.jsx(sLe,{title:"Set Schedule Time"})});var uLe=(e=>(e.DAYS="days",e))(uLe||{});const cLe=(e,a)=>{switch(e){case j5.EQUALS:return"Equals";case j5.NOT_EQUALS:return"Not Equals";case j5.GREATER_THAN:return a===_5.Date?"Date on or after":"Greater than";case j5.LESS_THAN:return a===_5.Date?"Date on or before":"Less than";case j5.EXISTS:return"Exists";case j5.EQUALS_MONTH_DAY:return"Month and Day Matches";case j5.EQUALS_MONTH_DAY_YEAR:return"Month, Day, and Year Matches";case j5.BETWEEN_MONTH_DAY:return"Between Month Day";case j5.BETWEEN_MONTH_DAY_YEAR:return"Between Month Day Year";case j5.ARRAY_CONTAINS:return"Is One Of";default:return e}},dLe={email:"Email Address",phone:"Phone Number",firstName:"First Name",lastName:"Last Name"},mLe=({options:e,value:a,onChange:n,placeholder:i,className:o="",disableInput:s=!1})=>{const[l,u]=r.useState(!1);return t.jsxs(Nre,{modal:!0,open:l,onOpenChange:u,children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{"aria-expanded":l,className:XO("w-full overflow-hidden justify-between",o),variant:"outline",children:[a?e.find((e=>e.value===a))?.label:i,t.jsx(sz,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(Pre,{className:XO("w-full min-w-[120px] max-w-[600px] p-0",o),children:t.jsxs(exe,{children:[!s&&t.jsx(axe,{placeholder:`${i}...`}),t.jsxs(txe,{children:[t.jsxs(nxe,{children:["No ",i.toLowerCase()," found."]}),t.jsx(ixe,{children:e.map((e=>t.jsxs(rxe,{value:e.value,onSelect:e=>{n(e===a?"":e),u(!1)},children:[t.jsx(tz,{className:XO("mr-2 h-4 w-4",a===e.value?"opacity-100":"opacity-0")}),e.label]},e.id||e.value)))})]})]})})]})};var hLe="Switch",[pLe,gLe]=u9(hLe),[fLe,vLe]=pLe(hLe),yLe=r.forwardRef(((e,a)=>{const{__scopeSwitch:n,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),f=FZ(a,(e=>g(e))),v=r.useRef(!1),y=!p||(m||!!p.closest("form")),[b=!1,k]=m9({prop:o,defaultProp:s,onChange:d});return t.jsxs(fLe,{scope:n,checked:b,disabled:u,children:[t.jsx(y9.button,{type:"button",role:"switch","aria-checked":b,"aria-required":l,"data-state":wLe(b),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:f,onClick:l9(e.onClick,(e=>{k((e=>!e)),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())}))}),y&&t.jsx(SLe,{control:p,bubbles:!v.current,name:i,value:c,checked:b,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"}})]})}));yLe.displayName=hLe;var bLe="SwitchThumb",kLe=r.forwardRef(((e,a)=>{const{__scopeSwitch:n,...i}=e,r=vLe(bLe,n);return t.jsx(y9.span,{"data-state":wLe(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:a})}));kLe.displayName=bLe;var SLe=e=>{const{control:a,checked:n,bubbles:i=!0,...o}=e,s=r.useRef(null),l=UMe(n),u=M7(a);return r.useEffect((()=>{const e=s.current,a=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(a,"checked").set;if(l!==n&&t){const a=new Event("click",{bubbles:i});t.call(e,n),e.dispatchEvent(a)}}),[l,n,i]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function wLe(e){return e?"checked":"unchecked"}var ALe=yLe,CLe=kLe;const MLe=r.forwardRef((({className:e,...a},n)=>t.jsx(ALe,{className:XO("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input/50",e),...a,ref:n,children:t.jsx(CLe,{className:XO("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})));MLe.displayName=ALe.displayName;const TLe=({onSelect:e,date:a,placeholder:n="Pick a date",monthDayOnly:i=!1})=>t.jsxs(Nre,{modal:!0,children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{variant:"outline",className:XO("w-[200px] justify-start text-left font-normal h-9",!a&&"text-muted-foreground"),children:[t.jsx(ez,{className:"mr-2 h-4 w-4"}),a?Eue(a,i?"MMMM d":"PPP"):t.jsx("span",{children:n})]})}),t.jsx(Pre,{className:"w-auto p-0",align:"start",children:t.jsx(rLe,{mode:"single",selected:a,onSelect:e,initialFocus:!0})})]}),xLe=Ale.union([Ale.date(),Ale.string().transform((e=>{if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[a,t,n]=e.split("-").map(Number);return new Date(a,t-1,n)}return new Date(e)}))]).refine((e=>!isNaN(e.getTime())),{message:"Invalid date"}),ELe=e=>void 0===e.value||!("number"!=typeof e.value||e.value<0)&&(e.unit===uLe.DAYS&&(("before"===e.direction||"after"===e.direction)&&"relative"===e.type)),NLe=e=>{const{date:a,fieldType:t}=e;return t===_5.Date?new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),0,0,0,0)):a},_Le=({fieldType:e,operator:a,value:n,onChange:i,options:o,toast:s})=>{const l=n.length>0&&"object"==typeof n[0]&&"type"in n[0]&&"relative"===n[0].type,u=n.length>0&&"object"==typeof n[0]&&"startDate"in n[0]&&"endDate"in n[0],[c,d]=r.useState((()=>{if((e===_5.Date||e===_5.DateTime)&&n.length>0){const e=xLe.safeParse(n[0]);return e.success?e.data:void 0}})),[m,h]=r.useState(l),[p,g]=r.useState(l?n[0]:{type:"relative",value:0,unit:uLe.DAYS,direction:"before"}),[f,v]=r.useState(u?n[0]:void 0),[y,b]=r.useState(!1);if(r.useEffect((()=>{a!==j5.EQUALS_MONTH_DAY&&a!==j5.EQUALS_MONTH_DAY_YEAR&&m&&(h(!1),i(c?[c]:[]))}),[a,m,c,i]),r.useEffect((()=>{if(u&&f?.startDate){b("object"==typeof f.startDate&&"type"in f.startDate)}}),[u,f]),e===_5.String||e===_5.ReachResource||e===_5.Array)return a===j5.EXISTS?null:t.jsx(fEe,{options:(o||[]).map((e=>({label:e.displayName,value:e.id}))),onValueChange:e=>{i(e)},selectedValues:n.map((e=>{const a=(o||[]).find((a=>a.id===String(e)||a.displayName===String(e)||a.id===a.displayName&&a.id===String(e)));return a?.id||String(e)})),setSelectedValues:e=>{i(e)}});if(e===_5.Date||e===_5.DateTime){const n=a===j5.EQUALS_MONTH_DAY||a===j5.EQUALS_MONTH_DAY_YEAR,r=a===j5.BETWEEN_MONTH_DAY||a===j5.BETWEEN_MONTH_DAY_YEAR,o=e=>{ELe(e)?(g(e),m&&i([e])):s({title:"Invalid relative date",description:"Please enter a valid non-negative number of days.",variant:"destructive"})},l=e=>{const a=e.startDate??f?.startDate,t=e.endDate??f?.endDate,n=a&&"object"==typeof a&&"type"in a,r=t&&"object"==typeof t&&"type"in t;if(a&&t){if(n!==r)return void s({title:"Invalid date range",description:"Both start and end dates must be of the same type (either both absolute or both relative).",variant:"destructive"});if(!n&&!r&&!(e=>!e.finalStartDate||!e.finalEndDate||e.finalStartDate<e.finalEndDate)({finalStartDate:a,finalEndDate:t}))return void s({title:"Invalid date range",description:"Start date must be before end date.",variant:"destructive"});if(n&&(!ELe(a)||!ELe(t)))return void s({title:"Invalid relative date",description:"Please enter valid relative dates.",variant:"destructive"})}v(e),a&&t&&i([{startDate:a,endDate:t}])},u=a=>{a&&(e=>e instanceof Date?!isNaN(e.getTime()):"object"==typeof e&&"type"in e&&"relative"===e.type&&ELe(e))(a)?(d(NLe({date:a,fieldType:e})),i([NLe({date:a,fieldType:e})]),h(!1)):a||(d(void 0),i([]),h(!1))},k=a=>{h(a),i(a?[p]:c?[NLe({date:c,fieldType:e})]:[])};return t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("div",{className:"min-h-[36px] flex items-center",children:[(!m||!n)&&!r&&t.jsx(TLe,{date:c,onSelect:u,monthDayOnly:a===j5.EQUALS_MONTH_DAY}),n&&m&&t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(gte,{type:"number",value:void 0===p.value?"":p.value,onChange:e=>{const a=""===e.target.value?void 0:parseInt(e.target.value,10);o({...p,value:a})},className:"w-20 h-9",min:"0","aria-label":"Relative days value"}),t.jsxs(pwe,{value:p.direction,onValueChange:e=>{o({...p,direction:e})},children:[t.jsx(vwe,{className:"w-[180px] h-9","aria-label":"Relative direction",children:t.jsx(fwe,{placeholder:"Select direction..."})}),t.jsxs(kwe,{children:[t.jsx(Swe,{value:"before",children:"days before today"}),t.jsx(Swe,{value:"after",children:"days after today"})]})]})]}),r&&t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("div",{className:"flex flex-col space-y-2",children:[t.jsx("div",{className:"flex items-center space-x-2",children:y?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(gte,{type:"number",value:f?.startDate&&"object"==typeof f.startDate&&"type"in f.startDate?f.startDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:uLe.DAYS,direction:f?.startDate?.direction||"before"};ELe(a)&&(v({...f,startDate:a}),l({...f,startDate:a}))},className:"w-20 h-9",min:"0","aria-label":"Start date relative days"}),t.jsxs(pwe,{value:f?.startDate&&"object"==typeof f.startDate&&"type"in f.startDate?f.startDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:f?.startDate?.value,unit:uLe.DAYS,direction:e};ELe(a)&&(v({...f,startDate:a}),l({...f,startDate:a}))},children:[t.jsx(vwe,{className:"w-[180px] h-9",children:t.jsx(fwe,{placeholder:"Select direction..."})}),t.jsxs(kwe,{children:[t.jsx(Swe,{value:"before",children:"days before today"}),t.jsx(Swe,{value:"after",children:"days after today"})]})]}),t.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"Start"})]}):t.jsx(TLe,{placeholder:"Start date",date:f?.startDate instanceof Date||"string"==typeof f?.startDate?f.startDate instanceof Date?f.startDate:new Date(f.startDate):void 0,monthDayOnly:a===j5.BETWEEN_MONTH_DAY,onSelect:a=>{const t=a;t&&(v({...f,startDate:NLe({date:t,fieldType:e})}),l({...f,startDate:NLe({date:t,fieldType:e})}))}})}),t.jsx("div",{className:"flex items-center space-x-2",children:y?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(gte,{type:"number",value:f?.endDate&&"object"==typeof f.endDate&&"type"in f.endDate?f.endDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:uLe.DAYS,direction:f?.endDate?.direction||"before"};ELe(a)&&(v({...f,endDate:a}),l({...f,endDate:a}))},className:"w-20 h-9",min:"0","aria-label":"End date relative days"}),t.jsxs(pwe,{value:f?.endDate&&"object"==typeof f.endDate&&"type"in f.endDate?f.endDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:f?.endDate?.value,unit:uLe.DAYS,direction:e};ELe(a)&&(v({...f,endDate:a}),l({...f,endDate:a}))},children:[t.jsx(vwe,{className:"w-[180px] h-9",children:t.jsx(fwe,{placeholder:"Select direction..."})}),t.jsxs(kwe,{children:[t.jsx(Swe,{value:"before",children:"days before today"}),t.jsx(Swe,{value:"after",children:"days after today"})]})]}),t.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"End"})]}):t.jsx(TLe,{placeholder:"End date",date:f?.endDate instanceof Date||"string"==typeof f?.endDate?f.endDate instanceof Date?f.endDate:new Date(f.endDate):void 0,monthDayOnly:a===j5.BETWEEN_MONTH_DAY,onSelect:a=>{const t=a;t&&(v({...f,endDate:NLe({date:t,fieldType:e})}),l({...f,endDate:NLe({date:t,fieldType:e})}))}})})]}),t.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[t.jsx(MLe,{id:"between-relative-date-switch",checked:y,onCheckedChange:e=>{if(b(e),e){const e={type:"relative",value:0,unit:uLe.DAYS,direction:"before"},a={type:"relative",value:0,unit:uLe.DAYS,direction:"before"};v({startDate:e,endDate:a}),l({startDate:e,endDate:a})}else{const e=new Date,a=new Date(e);a.setDate(a.getDate()+1),v({startDate:e,endDate:a}),l({startDate:e,endDate:a})}},"aria-label":"Toggle relative date input for between dates"}),t.jsx(Kbe,{htmlFor:"between-relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})]}),n&&t.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[t.jsx(MLe,{id:"relative-date-switch",checked:m,onCheckedChange:k,"aria-label":"Toggle relative date input"}),t.jsx(Kbe,{htmlFor:"relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})}if(e===_5.Number||e===_5.Integer)return a===j5.EXISTS?null:t.jsx(gte,{type:"number",value:n.length>0?String(n[0]):"",onChange:e=>i([Number(e.target.value)]),className:"w-[200px]"});if(e===_5.Boolean){if(a===j5.EXISTS)return null;const e=n.length>0&&Boolean(n[0]);return t.jsx(MLe,{checked:e,onCheckedChange:e=>i([e])})}return t.jsx(gte,{value:n.length>0?String(n[0]):"",onChange:e=>i([e.target.value]),className:"w-[200px]",disabled:!0})},PLe=({condition:e,onUpdate:n,onDuplicate:i,onDelete:r,segmentsConditions:o})=>{const{toast:s}=Ve(),l=(e=>{const a=o.conditions.find((a=>a.field===e));return a||null})(e.field)||{operators:[],type:_5.String,options:void 0},u=l.operators,c=l.type,d=o.conditions.map((e=>e.field)).map((e=>({value:e,label:dLe[e]||e})));return a.useEffect((()=>{setTimeout((()=>document.body.style.pointerEvents=""),0)}),[]),t.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch gap-2 min-w-0 w-full",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 items-stretch gap-2 min-w-0 w-full",children:[t.jsx("div",{className:"flex-1 min-w-0 items-center flex",children:t.jsx(mLe,{options:d,value:e.field,onChange:a=>{const t=a,i=o.conditions.find((e=>e.field===t));if(!i)return;const r=i.operators.map((e=>({value:e,label:cLe(e,i.type),fieldType:i.type}))),s=r[0]?.value;let l=[];switch(i.type){case _5.Boolean:l=[!1];break;case _5.Number:l=[0];break;case _5.Date:case _5.DateTime:l=[new Date];break;case _5.String:l=i.options?.length?i.options.map((e=>e.displayName)):[];break;default:l=[]}n({...e,field:t,operator:s,value:l})},placeholder:"Select field",className:"w-full",disableInput:!0})}),t.jsxs("div",{className:"flex-1 min-w-0 max-w-xs flex gap-2 items-center",children:[(e.operator===j5.EQUALS_MONTH_DAY||e.operator===j5.EQUALS_MONTH_DAY_YEAR||e.operator===j5.BETWEEN_MONTH_DAY||e.operator===j5.BETWEEN_MONTH_DAY_YEAR)&&t.jsx("div",{className:"flex items-center",children:(e=>{let a;switch(e){case j5.EQUALS_MONTH_DAY:a="This operator will check if only the month and day are equal. This is useful for things like birthday, where year does not matter";break;case j5.EQUALS_MONTH_DAY_YEAR:a="This operator will check if only the month and day are equal. This is useful for things like appointment dates, where specific day and month is important but year does not matter";break;case j5.BETWEEN_MONTH_DAY:a="This operator will check if the date is between the two dates, but only checking the month and the day, not the year. This is helpful for things like birthday, where year does not matter";break;case j5.BETWEEN_MONTH_DAY_YEAR:a="This operator will check if the date is between the two dates, checking the month, day and year. This is helpful for things like appointment dates, where specific day, month and year is important";break;default:return null}return t.jsx(Fue,{title:a})})(e.operator)}),t.jsx(mLe,{options:u.map((e=>({value:e,label:e?cLe(e,c):e}))),value:e.operator,onChange:a=>n({...e,operator:a}),placeholder:"Select operator",className:"w-full",disableInput:!0})]}),t.jsx("div",{className:"flex-1 min-w-0 max-w-full overflow-x-auto",children:t.jsx(_Le,{fieldType:c,operator:e.operator,options:"string"==typeof e.value[0]&&e.value[0]&&Array.isArray(l.options)?[...(l.options||[]).map((e=>({displayName:e.displayName,id:e.id}))),...e.value.filter((e=>!l.options?.some((a=>a.id===e||a.displayName===e)))).map((e=>({displayName:e,id:e})))]:l.options?.map((e=>({displayName:e.displayName,id:e.id}))),value:e.value,onChange:a=>n({...e,value:a}),toast:s})})]}),t.jsxs("div",{className:"flex items-center flex-shrink-0 pl-2",children:[t.jsx(H5,{size:"icon",variant:"ghost",onClick:i,children:t.jsx(vz,{className:"h-4 w-4"})}),t.jsx(H5,{size:"icon",variant:"ghost",onClick:r,children:t.jsx(Yz,{className:"h-4 w-4"})})]})]})},jLe=({onSelectStyle:e})=>{const[n,i]=a.useState(null);return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 max-w-4xl mx-auto",children:[t.jsx(G5,{onClick:()=>{i("ai"),e("ai")},title:"Build with AI",subtitle:"Describe your audience in plain language and let AI create the conditions",icon:t.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:t.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:t.jsx($z,{className:"w-full h-full"})})}),selected:"ai"===n}),t.jsx(G5,{onClick:()=>{i("manual"),e("manual")},title:"Build Manually",subtitle:`Create your ${lH("engage:segment")} by configuring conditions directly`,icon:t.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:t.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:t.jsx(Gz,{className:"w-full h-full"})})}),selected:"manual"===n})]})},LLe=({segmentId:e,setOpen:a,setTextToSegment:n,promptBuilderStyle:i,textToSegment:r})=>t.jsx("div",{children:t.jsx(aY,{className:"",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(nY,{className:"text-3xl font-normal",children:e?`Edit ${lH("engage:segment")}`:`Create ${lH("engage:segment")}`}),t.jsxs("div",{className:"flex items-center gap-2",children:[!1===i&&!1===r&&t.jsx(Hie,{children:t.jsxs(Iie,{children:[t.jsx(Fie,{asChild:!0,children:t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>n(!0),children:t.jsx($z,{className:"h-4 w-3"})})}),t.jsx(Gie,{children:t.jsxs("p",{children:["Use AI to create ",lH("engage:segment")," by describing them in natural language"]})})]})}),t.jsx(H5,{variant:"ghost",size:"icon",onClick:()=>{a(!1)},className:"h-8 w-8",children:t.jsx(rO,{className:"h-4 w-4"})})]})]})})}),BLe=r.forwardRef((({className:e,...a},n)=>t.jsx("textarea",{className:XO("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...a})));BLe.displayName="Textarea";const RLe=({setTextToSegment:e,setSegment:n})=>{const[i,r]=a.useState(""),[o,s]=a.useState(!1),{toast:u}=Ve();return t.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Describe your audience"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Describe the audience you want to target in plain language, and our AI will create the conditions for you."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(wY,{children:[o&&t.jsx(s5,{children:t.jsx(lY,{})}),!o&&t.jsx(s5,{children:t.jsx(BLe,{placeholder:"Describe your target audience...",className:"min-h-[120px] resize-none",value:i,onChange:e=>r(e.target.value)})})]}),t.jsx("div",{className:"flex justify-end gap-2",children:t.jsxs(H5,{onClick:async()=>{if(!i)return void u({title:"Please enter a description",description:"Please enter a description of your target audience",variant:"destructive"});s(!0);const a=await(async e=>{const{userInput:a,userCustomVerb:t}=e;return(await Le(`${l}/text-to-segment`,{method:"POST",body:JSON.stringify({text:a,userCustomVerb:t||"user"})})).data})({userInput:i,userCustomVerb:lH("engage:user")});a.success&&a.conditions?(u({title:`${lH("engage:segment")} conditions built successfully 🚀`,description:`Your ${lH("engage:segment")} conditions have been built successfully`}),n(a.conditions)):u({title:`${lH("engage:segment")} build failed`,description:"Please try again",variant:"destructive"}),e(!1),s(!1)},children:[t.jsx($z,{className:"h-4 w-4"}),"Generate ",lH("engage:segment")]})})]})]})};function DLe({segmentId:e,setOpen:a,onSegmentUpdated:n}){const{toast:i}=Ve(),o=void 0===e,[s,l]=r.useState(!1),[u,c]=r.useState({version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[]}),{segment:d,isLoading:m}=E5(e||""),{updateSegment:h}=N5(e),{createSegment:p,isCreating:g,segmentsConditions:f}=M5(),[v,y]=r.useState(!1),[b,k]=r.useState(!!o);r.useEffect((()=>{f&&c(d?{version:"1.0",id:d.id,name:d.name,description:d.description,logic:"AND",conditions:d.conditions}:{version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[{field:f.conditions[0].field,operator:f.conditions[0].operators[0],value:[]}]})}),[d,f]);const S=e=>e.value.some((e=>"object"==typeof e&&"type"in e&&"relative"===e.type)),w=e=>e.value.some((e=>"object"==typeof e&&"startDate"in e&&"endDate"in e));if(!f||m)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lY,{})});return t.jsxs(t.Fragment,{children:[t.jsx(LLe,{segmentId:e,setOpen:a,setTextToSegment:y,promptBuilderStyle:b,textToSegment:v},"segment-builder-header"),b?t.jsx(s5,{children:t.jsx(jLe,{onSelectStyle:e=>{"ai"===e&&y(!0),k(!1)}})},"prompt-builder-style"):t.jsx(s5,{children:t.jsxs("div",{className:"flex flex-1 flex-col",children:[t.jsx("div",{className:"flex flex-1 flex-col px-8 py-2",children:t.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-visible",children:t.jsx(wY,{children:v?t.jsx(s5,{children:t.jsx(RLe,{setTextToSegment:y,setSegment:e=>c({...u,conditions:e})})}):t.jsxs(s5,{children:[t.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex items-center gap-0",children:[t.jsx(Kbe,{className:"text-muted-foreground text-xs",children:"Name"}),t.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),t.jsx(gte,{placeholder:`${lH("engage:segment")} name`,value:u.name,onChange:e=>c({...u,name:e.target.value})})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(Kbe,{className:"text-muted-foreground text-xs",children:"Description"}),t.jsx(gte,{placeholder:`${lH("engage:segment")} description`,value:u.description,onChange:e=>c({...u,description:e.target.value})})]})]}),u.conditions.length>0&&t.jsx("div",{className:"flex-1 overflow-y-auto pb-8",children:t.jsx("div",{className:"grid",children:t.jsx(wY,{mode:"popLayout",children:u.conditions.map(((e,a)=>t.jsxs(o5.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{type:"spring",stiffness:300,damping:30,mass:.5},children:[a>0&&t.jsxs(o5.div,{className:"relative flex items-center gap-3 py-1",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:[t.jsx(o5.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}}),t.jsx(o5.span,{className:"text-muted-foreground text-xs",initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},children:"AND"}),t.jsx(o5.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}})]}),t.jsx(PLe,{condition:e,onUpdate:e=>((e,a)=>{const t=[...u.conditions];t[e]=a,c({...u,conditions:t})})(a,e),segmentsConditions:f,onDuplicate:()=>(e=>{const a=[...u.conditions];a.splice(e+1,0,{...u.conditions[e]}),c({...u,conditions:a})})(a),onDelete:()=>(e=>{const a=u.conditions.filter(((a,t)=>t!==e));c({...u,conditions:a})})(a)})]},`${e.field}-${e.operator}-${a}`)))})})})]})})})}),t.jsx("div",{className:"border-t px-8 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(H5,v?{variant:"secondary",onClick:()=>y(!1),children:[t.jsx(Gz,{className:"h-4 w-4"}),"Manual Builder"]}:{variant:"secondary",onClick:()=>{c({...u,conditions:[...u.conditions,{field:f.conditions[0].field,operator:f.conditions[0].operators[0],value:[]}]})},children:[t.jsx(Kz,{className:"h-4 w-4"}),"Add Condition"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H5,{variant:"destructive",onClick:()=>a(!1),children:"Cancel"}),t.jsx(H5,{variant:"default",onClick:async()=>{if(!u.name)return void i({title:"Name is required",description:"Please ensure all fields are filled out",variant:"destructive"});const{valid:t,error:r}=(e=>{for(const a of e){if(!a.field||!a.operator)return{valid:!1,error:"Please ensure all fields are filled out for condition"};if(a.operator!==j5.EXISTS&&0===a.value.length)return{valid:!1,error:`Please ensure a value is selected for ${a.field}`};if(a.operator===j5.EXISTS&&a.value.length>0)return{valid:!1,error:`EXISTS operator can only be used with an empty array for ${a.field}`};if(S(a)&&a.operator!==j5.EQUALS_MONTH_DAY&&a.operator!==j5.EQUALS_MONTH_DAY_YEAR)return{valid:!1,error:`Relative dates can only be used with the month and day or month, day, and year operator for ${a.field}`};if(S(a)&&void 0===a.value[0].value)return{valid:!1,error:`Please select a value for the relative date for ${a.field}`};if(w(a)&&a.operator!==j5.BETWEEN_MONTH_DAY&&a.operator!==j5.BETWEEN_MONTH_DAY_YEAR)return{valid:!1,error:`Between dates can only be used with the between month day or between month day year operator for ${a.field}`};if(w(a)&&a.value.length>1)return{valid:!1,error:`Between dates can only have a single value for ${a.field}`};if(w(a)){const e=a.value[0];if(!e.startDate||!e.endDate)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate instanceof Date&&e.endDate instanceof Date&&e.startDate>e.endDate)return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("object"==typeof e.startDate&&"type"in e.startDate&&"relative"===e.startDate.type&&"object"==typeof e.endDate&&"type"in e.endDate&&"relative"===e.endDate.type){if(!e.startDate.value||!e.endDate.value)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate.direction!==e.endDate.direction)return{valid:!1,error:`Start and end date must be of the same direction for ${a.field}`};const t=e=>{if(e.unit===uLe.DAYS)return e.value??0;throw g5(e.unit,uLe)};if("before"===e.startDate.direction&&t(e.startDate)>t(e.endDate))return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("after"===e.startDate.direction&&t(e.startDate)<t(e.endDate))return{valid:!1,error:`Start date must be after end date for ${a.field}`}}}}return{valid:!0,error:void 0}})(u.conditions);if(!t)return void i({title:"Conditions are invalid",description:r??"Please ensure all fields are filled out",variant:"destructive"});const o=u.conditions.map((e=>{const a=f?.conditions.find((a=>a.field===e.field));return a?.type===_5.Date&&(e.value=e.value.map((e=>e instanceof Date?e.toISOString().split("T")[0]:e))),e}));l(!0);try{e&&d?h({name:u.name,description:u.description,conditions:o},{onSuccess:()=>{i({title:`${lH("engage:segment")} updated successfully`}),a(!1),n?.(e)},onError:()=>{i({title:`Error updating ${lH("engage:segment")}`,description:"Please try again",variant:"destructive"}),n?.("error")}}):p({name:u.name,description:u.description,conditions:u.conditions},{onSuccess:e=>{i({title:`${lH("engage:segment")} created successfully`}),n?.(e?.id??!1),a(!1)},onError:()=>{i({title:`Error creating ${lH("engage:segment")}`,description:"Please try again",variant:"destructive"}),n?.("error")}})}catch(s){i({title:`Error saving ${lH("engage:segment")}`,description:"Please try again",variant:"destructive"}),n?.("error")}finally{l(!1)}},disabled:s||g,children:s||g?t.jsxs(t.Fragment,{children:[t.jsx(Cz,{className:"mr-2 h-4 w-4 animate-spin"}),e?"Updating...":"Creating..."]}):e?"Update":"Create"})]})]})})]})},"manual-builder-style")]})}function zLe({open:e,setOpen:a,segmentId:n,onSegmentUpdated:i}){return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"flex max-h-[86vh] flex-col gap-0 overflow-visible max-w-6xl w-full",hideCloseButton:!0,children:[t.jsxs(qZ,{children:[t.jsxs(nY,{children:[lH("engage:segment")," Builder"]}),t.jsxs(iY,{children:["Build a ",lH("engage:segment")," to target your audience"]})]}),t.jsx(DLe,{segmentId:n,setOpen:a,onSegmentUpdated:e=>{i?.(e),a(!1)}})]})})}const OLe=()=>t.jsx(Fue,{title:`These are estimated numbers of ${lH("engage:user",{count:2}).toLocaleLowerCase()} that are matched. The actual count may change at the time of sending. You can see the breakdown of who have opted into email or sms.`}),KLe=({value:e,label:a,percentage:n,variant:i,isLoading:r,selected:o,onClick:s})=>t.jsxs("div",{className:`rounded-md border-2 border-muted-foreground/20 px-2 pt-2 pb-3 duration-300 ease-in-out overflow-x-auto max-w-full min-w-0 ${o?"scale-[1.02] [border-color:hsl(var(--reach-primary))] shadow-lg":""} ${s?"cursor-pointer hover:bg-gray-50/50 transition-colors":""}`,style:{containerType:"inline-size"},"data-card-container":!0,onClick:s,children:[t.jsxs("div",{className:"flex flex-col gap-1 items-start w-full min-w-0",children:[t.jsx("div",{className:"flex items-baseline gap-2 w-full min-w-0 @container/num",children:r?t.jsx("span",{className:"animate-pulse",children:"..."}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold pl-2 break-words max-w-full min-w-0 truncate\n text-xl @[250px]/card:text-2xl @[350px]/card:text-3xl @[500px]/card:text-4xl text-primary",children:e.toLocaleString()}),void 0!==n&&e.toLocaleString().replace(/,/g,"").length<5&&t.jsxs("span",{className:"text-muted-foreground/50 text-sm hidden @[120px]/num:inline",children:["(",n,"%)"]})]})}),t.jsx("span",{className:`px-2 sm:px-2.5 py-1 text-xs font-medium rounded-lg ${{default:"bg-gray-100/50 text-gray-700",blue:"bg-blue-100/50 text-blue-700",green:"bg-green-100/50 text-green-700"}[i]}`,children:a})]}),t.jsx("p",{className:"text-sm text-muted-fore hidden @[250px]/card:inline mt-1",children:1===e?"contact":"contacts"})]}),HLe=({countResponse:e,selectedFilter:n="all",onFilterChange:i})=>{const r=a.useMemo((()=>e?.recipients?e.recipients.reduce(((a,t)=>({total:e.count,emails:a.emails+(t.email?1:0),phones:a.phones+(t.phone?1:0)})),{total:0,emails:0,phones:0}):{total:0,emails:0,phones:0}),[e]),o=e=>Math.round(e/(r.total||1)*100);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(i_e,{children:"Estimated Matches"}),t.jsx(OLe,{})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 md:mb-6 w-full gap-4 mt-3 px-1",children:[t.jsx(KLe,{value:r.total,label:"Total",variant:"default",isLoading:void 0===e,selected:"all"===n,onClick:i?()=>i("all"):void 0}),t.jsx(KLe,{value:r.emails,label:"Subscribed to Email",percentage:o(r.emails),variant:"blue",isLoading:void 0===e,selected:"email"===n,onClick:i?()=>i("email"):void 0}),t.jsx(KLe,{value:r.phones,label:"Subscribed to SMS",percentage:o(r.phones),variant:"green",isLoading:void 0===e,selected:"phone"===n,onClick:i?()=>i("phone"):void 0})]})]})},ILe=e=>{const a=`${e.firstName||""} ${e.lastName||""}`.trim();return a||(e.firstName?e.firstName:e.lastName?e.lastName:e.email?e.email:e.phone?e.phone:`Unnamed ${lH("engage:user")}`)},FLe=({recipients:e,filter:a="all"})=>{const n=e?.filter((e=>{const t=!!e.email,n=!!e.phone;if(!t&&!n)return!1;switch(a){case"email":return t;case"phone":return n;default:return!0}}));return n?.length?t.jsx("div",{className:"bg-foreground/5 rounded-lg h-full relative overflow-hidden",children:t.jsx("div",{className:"absolute inset-0 w-full h-full overflow-y-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"sticky top-0 bg-foreground/5 backdrop-blur-sm",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Name"}),t.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Contact"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200/50",children:n.map(((e,a)=>t.jsxs("tr",{className:"hover:bg-white/50 transition-colors",children:[t.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-gray-900",children:ILe(e)}),t.jsx("td",{className:"px-3 sm:px-4 py-3",children:t.jsxs("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:[e.email&&t.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-blue-100/50 text-blue-700 rounded-lg",children:"Email"}),e.phone&&t.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-green-100/50 text-green-700 rounded-lg",children:"Phone"})]})})]},a)))})]})})}):null},GLe=({onSelectionChange:e,defaultValue:n="all",canEditAudience:i=!0})=>{const[r,o]=a.useState(n),s=a=>{i&&(o(a),e?.(a))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(i_e,{children:"Filter"}),!i&&t.jsx(Fue,{title:"You cannot edit the audience unless you are in draft mode"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4 p-1",children:[t.jsx(G5,{onClick:()=>s("all"),title:`All ${lH("engage:user",{count:2})}`,subtitle:"Send to everyone",icon:t.jsx(V5.UsersIcon,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"all"===r,disabled:!i}),t.jsx(G5,{onClick:()=>s("segments"),title:`Select ${lH("engage:user",{count:2})}`,subtitle:`Choose from ${lH("engage:segment",{count:2})}`,icon:t.jsx(V5.UserEdit,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"segments"===r,disabled:!i})]})]})},VLe=({segments:e,allSegments:n,onAddSegment:i,onRemoveSegment:r,setOpenCreateSegmentDialog:o,canEditAudience:s=!0})=>{const[l,u]=a.useState([]),c=n.map((e=>({label:e.name,value:e.id})));return a.useEffect((()=>{u(e)}),[e]),t.jsx("div",{children:t.jsx(fEe,{canOpen:s,selectedValues:l,setSelectedValues:u,options:c,onValueChange:a=>{const t=a.filter((a=>!e.includes(a))),n=e.filter((e=>!a.includes(e)));t.forEach(i),n.forEach(r)},placeholder:"Select segments",maxCount:5,extraCommandItems:[e=>t.jsxs(rxe,{onSelect:()=>{e(!0),o(!0)},className:"cursor-pointer",children:[t.jsx(V5.PlusIcon,{className:"w-4 h-4"}),"New"]},"new-segment")]})})},JLe=({includedSegments:e,excludedSegments:n,handleAddSegment:i,handleRemoveSegment:r,setOpenCreateSegmentDialog:o,segments:s,defaultIsExcludeOpen:l=!1,canEditAudience:u=!0})=>{const[c,d]=a.useState(l);return t.jsxs("div",{children:[t.jsx(VLe,{segments:e,allSegments:s||[],onAddSegment:e=>i(e,"include"),onRemoveSegment:e=>r(e,"include"),setOpenCreateSegmentDialog:o}),t.jsx("div",{className:"border-t border-gray-200 my-8"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(H5,{onClick:()=>{u&&d(!c)},className:"flex items-center gap-1 transition-colors",size:"sm",children:[t.jsx(o5.div,{animate:{rotate:c?180:0},transition:{duration:.2},children:t.jsx(V5.DropdownMenuTrigger,{className:"w-5 h-5"})}),t.jsx("span",{children:"Don't send to"})]}),t.jsx(wY,{children:c&&t.jsx(o5.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeInOut"},children:t.jsx(VLe,{canEditAudience:u,segments:n,allSegments:s||[],onAddSegment:e=>i(e,"exclude"),onRemoveSegment:e=>r(e,"exclude"),setOpenCreateSegmentDialog:o})})})]})]})},ULe=({title:e="Preview Audience"})=>{const n=B5(),[i,r]=a.useState("all"),[o,s]=a.useState(n?.includeSegmentIds||[]),[l,u]=a.useState(n?.excludeSegmentIds||[]),[c,d]=a.useState(!1),[m,h]=a.useState(!1),[p,g]=a.useState("all"),{segments:f,isLoading:v}=T5(),{updateAutomation:y}=ra(n?.id??""),[b,k]=a.useState(void 0),S=1===o.length&&0===l.length&&void 0!==f?.find((e=>e.type===P5.ALL_USERS&&e.id===o[0]));a.useEffect((()=>{n&&!m&&!1===v&&(1===o.length&&void 0!==f.find((e=>e.type===P5.ALL_USERS&&e.id===o[0]))?r("all"):r("segments"),A5({includeSegments:o,excludeSegments:l}).then((e=>{k(e)})),h(!0))}),[n,S,m,o,l,f,v]);a.useEffect((()=>{n&&m&&(JSON.stringify(o)===JSON.stringify(n.includeSegmentIds)&&JSON.stringify(l)===JSON.stringify(n.excludeSegmentIds)||(y({includeSegments:o,excludeSegments:l}),A5({includeSegments:o,excludeSegments:l}).then((e=>{k(e)}))))}),[o,l,n,m,y]);const w=n?.status===ha.DRAFT;return t.jsxs(r_e,{title:e,children:[!v&&f&&m?t.jsxs("div",{className:"flex gap-8 w-full pb-4 px-4",children:[t.jsxs("div",{className:"flex flex-col flex-1 relative overflow-y-auto pb-4 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:[t.jsx(HLe,{countResponse:b,selectedFilter:p,onFilterChange:g}),t.jsx(GLe,{onSelectionChange:e=>{if(r(e),"all"===e){const e=f?.find((e=>e.type===P5.ALL_USERS));if(!e)return;s([e.id]),u([])}},defaultValue:i,canEditAudience:w}),t.jsx(wY,{children:"segments"===i&&t.jsx(o5.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3,ease:"easeInOut"},className:"w-full pt-4",children:t.jsx(JLe,{canEditAudience:w,includedSegments:o,excludedSegments:l,handleAddSegment:(e,a)=>{"include"===a?s((a=>[...a,e])):u((a=>[...a,e]))},handleRemoveSegment:(e,a)=>{"include"===a?s((a=>a.filter((a=>a!==e)))):u((a=>a.filter((a=>a!==e))))},setOpenCreateSegmentDialog:d,segments:f,defaultIsExcludeOpen:l.length>0})})})]}),t.jsx("div",{className:"flex flex-col flex-1 relative overflow-hidden",children:b?.recipients&&t.jsx(FLe,{recipients:b.recipients,filter:p})})]}):t.jsx("div",{children:t.jsx(lY,{text:["Fetching segments","Finishing up"]})}),t.jsx(zLe,{open:c,setOpen:d,onSegmentUpdated:e=>{e&&s((a=>[...a,e]))}})]})},WLe=()=>t.jsx(ULe,{title:"Select Audience"}),qLe=({selectedChannels:e,setSelectedChannels:a,hasEmailChannelSenders:n,hasSmsChannelSenders:i,automationType:r})=>{const{toast:o}=Ve(),s=[...n?[{label:"Email",value:"email",icon:V5.EmailIcon,checked:e.includes("email")}]:[],...i?[{label:"SMS",value:"sms",icon:V5.SmsIcon,checked:e.includes("sms")}]:[]];return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-xl font-medium text-foreground",children:"Message Types"}),t.jsxs("p",{className:"text-muted-foreground mb-2 text-sm",children:["Select the channels you want to use in this"," ",r===ua.ONE_TIME?lH("engage:broadcast").toLowerCase():lH("engage:automation").toLowerCase()]})]}),t.jsx("div",{className:"w-full grid grid-cols-2 gap-3",children:s.map((n=>t.jsxs(iTe,{checked:n.checked,onCheckedChange:()=>{"email"===n.value?e.includes("email")?e.includes("sms")?a(["sms"]):o({title:"Cant Remove Email",description:`At least one channel is required for an ${r===ua.ONE_TIME?lH("engage:broadcast").toLowerCase():lH("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"email"]):e.includes("sms")?e.includes("email")?a(["email"]):o({title:"Cant Remove SMS",description:`At least one channel is required for an ${r===ua.ONE_TIME?lH("engage:broadcast").toLowerCase():lH("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"sms"])},className:"relative ring-[1px] ring-border rounded-lg px-4 py-3 text-start text-muted-foreground data-[state=checked]:ring-2 data-[state=checked]:ring-primary data-[state=checked]:font-medium",children:[t.jsx(n.icon,{className:"mb-3",size:20}),t.jsx("span",{className:"font-medium tracking-tight",children:n.label}),t.jsx(rTe,{className:"absolute top-2 right-2",children:t.jsx(cz,{className:"fill-primary text-primary-foreground"})})]},n.value)))})]})},$Le=()=>{const{channelSenders:e}=Jre(),{channelAccounts:n}=Fre(),i=R5(),{updateCommunicationGroup:r}=Ye(),{state:{selectedChannels:o},setSelectedChannels:s}=a.useContext(Kre),l=B5(),{data:u}=$re(),c=a.useCallback((async e=>{s(e),e.includes("email")||i?.id&&r({groupId:i?.id,params:{emailChannelSenderId:null}}),e.includes("sms")||i?.id&&r({groupId:i?.id,params:{smsChannelSenderId:null}})}),[s,r,i?.id]),d=a.useMemo((()=>Uwe({channelSenders:e?.results??[],channelAccounts:n?.results??[]})),[e?.results,n?.results]),m=a.useMemo((()=>Nle({channelSenders:e?.results??[],channelAccounts:n?.results??[],smsApplication:u})),[e?.results,n?.results,u]);if(!o||!d||!m)return t.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(lY,{text:["Fetching Content..."]})});const h=d.length>0,p=m.length>0;return t.jsx("div",{className:"flex flex-col gap-4 flex-shrink-0",children:t.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(qLe,{automationType:l?.triggerMetadata?.triggerType,selectedChannels:o,setSelectedChannels:c,hasEmailChannelSenders:h,hasSmsChannelSenders:p})})})};var ZLe=(e=>(e[e.SelectAudience=1]="SelectAudience",e[e.SelectSenders=2]="SelectSenders",e[e.EditEmailContent=3]="EditEmailContent",e[e.EditSmsContent=4]="EditSmsContent",e[e.Schedule=5]="Schedule",e[e.PreviewAndSend=6]="PreviewAndSend",e))(ZLe||{});const YLe="https://assets.embedreach.com/defaults/logo-placeholder-128.png",QLe="You have not uploaded a custom logo. Please make sure to double check your email before sending!",XLe=()=>{const e=B5(),t=R5(),{state:{selectedChannels:n}}=a.useContext(Kre),{data:i}=$re(),{channelSenders:r}=Jre(),{channelAccounts:o}=Fre(),s=Nle({channelSenders:r?.results??[],channelAccounts:o?.results??[],smsApplication:i}),l=a.useCallback((async a=>e?await(async e=>{const{currentStep:a,automation:t,communicationGroup:n,selectedChannels:i,smsChannelSenders:r}=e;switch(a){case ZLe.SelectAudience:return{canMove:t.includeSegmentIds.length>0,errorMessage:"Please ensure you have selected at least one segment"};case ZLe.SelectSenders:return{canMove:i.length>0,errorMessage:"Please ensure you have selected at least one channel"};case ZLe.EditSmsContent:{const e=t.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!n)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};const a=r.find((e=>e.channelSender.id===n.smsChannelSenderId));return a?n.smsMessageBody?a.smsApplication&&a.smsApplication.status!==Ele.APPROVED?{canMove:!0,errorMessage:null,warningMessage:"You will only be able to send this message once your SMS application is approved"}:{canMove:!0,errorMessage:null}:{canMove:!1,errorMessage:"Please ensure you have a text body"}:{canMove:!1,errorMessage:"Please ensure you have selected a text sender"}}case ZLe.EditEmailContent:{const e=t.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!n)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};if(!n.emailChannelSenderId)return{canMove:!1,errorMessage:"Please ensure you have selected a email sender"};if(!n.emailHtmlBody||!n.emailSubject)return{canMove:!1,errorMessage:"Please ensure you have a email body and subject"};let a=null;return n.emailChannelSenderId&&n.emailHtmlBody&&n.emailHtmlBody.includes(YLe)&&(a=QLe),{canMove:!0,errorMessage:null,warningMessage:a}}case ZLe.Schedule:{if(!t.triggerMetadata)return{canMove:!1,errorMessage:"Please make sure to select a time to send before starting!"};if(t.triggerMetadata.triggerType!==ua.ONE_TIME)return{canMove:Boolean(t.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:null};if(!t.triggerMetadata?.scheduledAt)return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${lH("engage:broadcast")}`};if(!Boolean(t.triggerMetadata?.scheduledAt&&("now"===t.triggerMetadata.scheduledAt||"now"!==t.triggerMetadata.scheduledAt&&new Date(t.triggerMetadata.scheduledAt)>new Date)))return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${lH("engage:broadcast")}`};if(!Boolean(t.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))))return{canMove:!1,errorMessage:"Please ensure you have set a valid email or sms communication"};const e=t.triggerMetadata;return{canMove:Boolean(e.scheduledAt&&("now"===e.scheduledAt||new Date(e.scheduledAt)>new Date)&&t.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:`Please ensure you have set a valid future date for your ${lH("engage:broadcast")}`}}case ZLe.PreviewAndSend:return{canMove:!0,errorMessage:null};default:jre(a,ZLe)}})({currentStep:a,automation:e,communicationGroup:t,selectedChannels:n,smsChannelSenders:s}):{canMove:!1,errorMessage:`${lH("engage:broadcast")} not loaded`}),[e,t,n,s]);return{validateStep:l}},eBe=({onFinish:e,getExtraMergeFields:n,onBeforeSchedule:i})=>{const r=B5(),o=R5(),{updateAutomation:s}=ra(r?.id||""),{estimatedMatchesStats:l}=(e=>{const{data:t}=x5({automationId:e?.id??"",includeSegments:e?.includeSegmentIds??[],excludeSegments:e?.excludeSegmentIds??[]}),n=a.useMemo((()=>t?.recipients?t.recipients.reduce(((e,a)=>({emails:e.emails+(a.email?1:0),phones:e.phones+(a.phone?1:0)})),{emails:0,phones:0}):{emails:0,phones:0}),[t?.recipients]);return{estimatedMatches:t,estimatedMatchesStats:n}})(r??void 0),{state:{selectedChannels:u}}=a.useContext(Kre),{validateStep:c}=XLe(),[d,m]=a.useState([]),{data:h}=$re(),[p,g]=a.useState(!1),{channelSenders:f}=Jre(),{channelAccounts:v}=Fre(),{updateCommunicationGroup:y}=Ye(),b=a.useRef(!1),[k,S]=a.useState(ZLe.SelectAudience);if(a.useEffect((()=>{if(null!==r&&null!==o){const e=Nle({channelSenders:f?.results??[],channelAccounts:v?.results??[],smsApplication:h});m((({automation:e,communicationGroup:a,selectedChannels:n,smsChannelSenders:i})=>e?[{id:"audience",title:"Audience",step:1,isValid:()=>e.includeSegmentIds.length>0,content:t.jsx(Vue,{content:t.jsx(WLe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===ua.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},{id:"senders",title:"Channels",step:2,isValid:()=>0!==n.length,content:t.jsx(Vue,{content:t.jsx($Le,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===ua.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},...n.includes("email")?[{id:"edit-email-content",title:"Edit Email Content",step:3,isValid:()=>{const t=e.actionData?.find((e=>"send_communication"===e.actionType));return!!t&&!!a.emailChannelSenderId&&!(!a.emailHtmlBody||!a.emailSubject)},content:t.jsx(Vue,{content:t.jsx(Wwe,{})},"audience"),footerConfig:{backText:"",nextText:"",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],...n.includes("sms")?[{id:"edit-sms-content",title:"Edit SMS Content",step:4,isValid:()=>{const t=e.actionData?.find((e=>"send_communication"===e.actionType));return!!(t&&t.actionMetadata.communicationGroupId&&a.smsChannelSenderId&&a.smsMessageBody)},content:t.jsx(Vue,{content:t.jsx(SEe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],{id:"schedule",title:"Schedule",step:5,isValid:()=>Boolean(e.triggerMetadata?.triggerType===ua.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date)&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:t.jsx(Vue,{className:"flex-1",content:t.jsx(lLe,{})},"schedule"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}},{id:"send",title:"Send",step:6,isValid:()=>Boolean(e.triggerMetadata?.triggerType===ua.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date(Date.now()+18e4))&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:t.jsx(Vue,{className:"flex-1",content:t.jsx(s_e,{})},"send"),footerConfig:{backText:"Back",nextText:e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&"now"===e.triggerMetadata.scheduledAt?"Send Now":"Schedule",hideBack:!1,backDisabled:!1,getInfoTooltipTitle:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));if(e&&null!==e.smsApplication&&e.smsApplication?.status!==Ele.APPROVED)return"You cannot send this yet if you have selected a text channel and don't have an approved SMS application. Please save as draft and try again later."},nextDisabled:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));return!(!a.smsChannelSenderId||e&&(null===e.smsApplication||e.smsApplication?.status===Ele.APPROVED))||null===a.smsChannelSenderId&&null===a.emailChannelSenderId}}}]:[])({automation:r,communicationGroup:o,selectedChannels:u,smsChannelSenders:e}))}}),[r,o,n,u,f?.results,v?.results,h]),a.useEffect((()=>{n&&!b.current&&n().then((e=>{o?.id&&(b.current=!0,y({groupId:o?.id,params:{extraMergeFields:e}}))}))}),[n,o,y]),!(r&&k&&o&&d.length))return t.jsx("div",{className:"flex-1 flex flex-col @container justify-center items-center h-[500px]",children:t.jsx(lY,{text:[`Fetching ${lH("engage:broadcast")} data`,"Finishing up"]})});const w=async()=>{const{canMove:a,errorMessage:t,warningMessage:n}=await c(k);a?(n&&Ge({title:n,variant:"warning"}),k===ZLe.PreviewAndSend?await(async()=>{if(null===o.emailChannelSenderId&&null===o.smsChannelSenderId)return void Ge({title:"Oops!",description:"Please select an email sender or sms sender",variant:"destructive"});const a=Nle({channelSenders:f?.results??[],channelAccounts:v?.results??[],smsApplication:h});if(o.smsChannelSenderId){const e=a.find((e=>e.channelSender.id===o.smsChannelSenderId));if(e?.smsApplication?.application&&e?.smsApplication.status!==Ele.APPROVED)return void Ge({title:"Oops!",description:"You cant schedule a communication with a pending sms application. Please save as a draft and re-try once the application is approved."})}if(i)try{const a=await i({estimatedEmailRecipients:l?.emails||0,estimatedSmsRecipients:l?.phones||0});!0===a?s({status:ha.ACTIVE},{onSuccess:()=>{Ge({title:`${lH("engage:broadcast")} scheduled!`}),e()},onError:()=>{Ge({title:"Oops!",description:"Please contact your administrator",variant:"destructive"})}}):Ge({title:"Oops!",description:a,variant:"destructive"})}catch(t){Ge({title:"Oops!",description:"An error occurred while checking scheduling conditions",variant:"destructive"})}else s({status:ha.ACTIVE}),Ge({title:`${lH("engage:broadcast")} scheduled!`}),e()})():S(k===ZLe.SelectSenders&&1===u.length&&"sms"===u[0]||k===ZLe.EditEmailContent&&1===u.length&&"email"===u[0]?k+2:k+1)):Ge({title:"Oops!",description:t,variant:"destructive"})},A=()=>{k>ZLe.SelectAudience&&S(k===ZLe.EditSmsContent&&1===u.length&&"sms"===u[0]?k-2:k-1)},C=()=>{e()};return t.jsxs("div",{className:"flex-1 flex flex-col @container h-full min-h-0",children:[t.jsxs("header",{className:"w-full flex items-center gap-4 h-16 px-6",children:[t.jsx("h1",{className:"text-xl font-bold leading-none",children:r.name}),t.jsx("div",{className:"flex items-center gap-4",children:t.jsx(a6,{variant:Lue(r.status),children:Lre({status:r.status,automationType:r.triggerType})})})]}),t.jsxs("main",{className:"flex gap-4 flex-1 min-h-0",children:[t.jsx("div",{className:"hidden @[1000px]:block",children:t.jsx("nav",{className:"space-y-0 w-50 self-start pr-6 pl-8 pt-4 ",children:d.map((e=>t.jsx("div",{className:`\n rounded-md transition-colors\n ${e.step===k?"bg-[var(--reach-secondary)] text-[var(--reach-primary-foreground)] font-medium":e.step<k?"text-muted-foreground hover:bg-muted":"text-muted-foreground/60"}\n `,children:t.jsx(d6,{label:e.title,isActive:e.step===k,isCompleted:e.isValid(),onClick:async()=>{if(!p)if(e.step>k){const{canMove:a,errorMessage:t,warningMessages:n}=await(async e=>{if(e<=k)return{canMove:!0,errorMessage:null};g(!0);try{const a=[];for(let t=k;t<e;t++){const{canMove:e,errorMessage:n,warningMessage:i}=await c(t);if(!e)return{canMove:e,errorMessage:n};i&&a.push(i)}return{canMove:!0,errorMessage:null,warningMessages:a}}finally{g(!1)}})(e.step);if(a){if(n&&n.length>0)for(const e of n)Ge({title:e,variant:"warning"});S(e.step)}else t&&Ge({title:"Cannot navigate to this step",description:t,variant:"destructive"})}else S(e.step)}})},e.step)))})}),t.jsx("section",{className:"flex-1 mr-6 w-full relative rounded-xl bg-gray-100 ml-6 @[1000px]:ml-0",children:t.jsx("div",{className:" overflow-y-auto top-0 left-0 right-0 bottom-0 flex-1 h-full flex-col flex",children:t.jsx(wY,{children:t.jsx(s5,{className:"pt-0 h-full",children:d.find((e=>e.step===k))?.content},k)})})})]}),t.jsx("footer",{className:"w-full flex justify-end shadow-md z-10 items-center h-16 px-6",children:t.jsx(Gue,{handleSkipAndSaveAsDraft:C,handleBack:A,handleNext:w,hideBack:d.find((e=>e.step===k))?.footerConfig.hideBack??!1,backText:d.find((e=>e.step===k))?.footerConfig.backText??"Back",nextText:d.find((e=>e.step===k))?.footerConfig.nextText??"Next",backDisabled:d.find((e=>e.step===k))?.footerConfig.backDisabled??!1,nextDisabled:d.find((e=>e.step===k))?.footerConfig.nextDisabled()??!1,getInfoTooltipTitle:d.find((e=>e.step===k))?.footerConfig.getInfoTooltipTitle??void 0})})]})},aBe=({children:e,actionId:n})=>{const{setActionId:i}=a.useContext(S5);return a.useEffect((()=>{i(n)}),[n,i]),t.jsx("div",{children:t.jsx(Hre,{children:e})})},tBe=()=>t.jsxs("div",{children:[t.jsx("div",{className:q5,children:t.jsx(V5.OneTimeBroadcast,{})}),t.jsx("h3",{className:$5,children:lH("engage:broadcast")}),t.jsx("p",{className:Z5,children:"Send a single message to your current list, like announcing a sale or newsletter."})]}),nBe=()=>t.jsxs("div",{children:[t.jsx("div",{className:Y5,children:"Coming Soon"}),t.jsx("div",{className:q5,children:t.jsx(V5.RealtimeActivity,{})}),t.jsx("h3",{className:$5,children:"Realtime Activity"}),t.jsx("p",{className:Z5,children:"Responds to immediate actions your contacts take, like abandoned carts, form submissions, or appointment bookings."})]}),iBe=({selectedType:e,setAutomationName:a,automationName:n,setAutomationDescription:i,automationDescription:r})=>t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 max-w-lg mx-auto",children:[t.jsxs("h2",{className:"text-2xl font-semibold mb-8 text-center",children:["Name Your"," ",lH(e===ua.ONE_TIME?"engage:broadcast":"engage:automation")]}),t.jsxs("div",{className:"w-full space-y-6",children:[t.jsx("div",{className:"bg-gray-50 p-6 rounded-xl items-center justify-center text-center",children:(()=>{switch(e){case ua.ONE_TIME:return t.jsx(tBe,{});case ua.TRIGGER_BASED:return t.jsx(nBe,{});default:throw jre(e,ua)}})()}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[t.jsx("label",{htmlFor:"automationName",className:"block text-sm font-medium text-gray-900",children:"Name"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Only visible to your team"})]}),t.jsx(gte,{id:"automationName",type:"text",value:n,onChange:e=>a(e.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500 shadow-sm",placeholder:"e.g. April Newsletter Campaign",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[t.jsx("label",{htmlFor:"automationDescription",className:"block text-sm font-medium text-gray-900",children:"Description"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Optional"})]}),t.jsx(BLe,{id:"automationDescription",value:r,onChange:e=>i(e.target.value),className:"w-full min-h-[80px] resize-none",placeholder:`Add any helpful context for your team. If left blank, we'll generate one for you when you start the ${lH("engage:broadcast").toLowerCase()}`})]})]})]})]}),rBe=({onClose:e,automationType:n,currentStep:i,setCurrentStep:r,getExtraMergeFields:o,onBeforeSchedule:s})=>{const{createAutomation:l,isCreating:u}=ia(),[c,m]=a.useState(!1),[h,p]=a.useState(void 0),[g,f]=a.useState(void 0),[v,y]=a.useState(!1),[b,k]=a.useState(n?{name:void 0,description:void 0,type:n}:{name:void 0,description:void 0,type:void 0}),S=void 0!==b.name&&void 0!==b.type&&""!==b.name;a.useEffect((()=>{if(b.type&&!b.name&&!v){const e=new Date,a=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t=e.toLocaleDateString([],{month:"long",day:"numeric"}),n=`${lH("engage:broadcast")} ${t} ${a}`,i="";k((e=>({...e,name:n,description:i}))),y(!0)}}),[b,v]);if(u||c)return t.jsx("div",{className:W5,children:t.jsx(lY,{text:[`Creating ${lH("engage:broadcast")}`,"Finishing up"]})});return t.jsxs("div",{className:$Z("relative overflow-y-auto h-full p-8",i===I5.OneTimeWizard?"max-h-[90vh]":"h-full"),children:[t.jsx(wY,{mode:"wait",children:t.jsx(s5,{className:"h-full",children:(()=>{switch(i){case I5.ChooseAutomationType:return t.jsx(Q5,{onNext:e=>{k({...b,type:e}),r(I5.SetAutomationName)}});case I5.SetAutomationName:return b.type?t.jsx(iBe,{selectedType:b.type,setAutomationName:e=>{k({...b,name:e})},automationName:b.name??"",setAutomationDescription:e=>{k({...b,description:e})},automationDescription:b.description??""}):null;case I5.OneTimeWizard:return h&&g?t.jsx(z5,{automationId:h,children:t.jsx(aBe,{actionId:g,children:t.jsx(eBe,{onFinish:()=>{e?.(h)},getExtraMergeFields:o,onBeforeSchedule:s})})}):null;default:throw g5(i,I5)}})()},i)}),i!==I5.OneTimeWizard&&t.jsx("div",{className:"pt-2",children:t.jsx(F5,{onClose:e,currentStep:i,setCurrentStep:r,isDisabled:!S,createAutomation:async()=>{if(!S||!b.name||!b.type)return;m(!0);l({name:b.name,type:b.type,description:b.description},{onSuccess:async a=>{if(a.id){const t=await(async e=>(await Le(`${d}`,{method:"POST",body:JSON.stringify(e)})).data)({}),i=p5().toString();await Re(a.id,{action:[{actionType:"send_communication",actionMetadata:{actionType:"send_communication",communicationGroupId:t.id,currentActionId:i}}]}),p(a.id),await qe({automationId:a.id,actionId:i}),n===ua.ONE_TIME?(r(I5.OneTimeWizard),f(i),m(!1)):e?.(a.id)}else e?.("error")},onError:()=>{e?.("error")},onSettled:()=>{k({name:void 0,description:void 0,type:void 0})}})},disableBackButton:void 0!==n})})]})};function oBe({open:e,setOpen:n,onClose:i,automationType:r,getExtraMergeFields:o,replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c}){const[d,m]=a.useState(r?I5.SetAutomationName:I5.ChooseAutomationType);return a.useEffect((()=>{e&&m(r?I5.SetAutomationName:I5.ChooseAutomationType)}),[e,r]),t.jsx(oY,{children:t.jsx(sY,{replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c,children:t.jsx(ZZ,{open:e,onOpenChange:n,children:t.jsxs(eY,{hideCloseButton:d===I5.OneTimeWizard,className:`flex max-h-[86vh] ${d===I5.OneTimeWizard?"max-w-[90vw]":"max-w-4xl"} flex-col gap-0 overflow-visible p-0`,children:[t.jsx(aY,{children:t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs(qZ,{children:[t.jsx(nY,{className:"text-3xl font-normal",children:"Create Automation"}),t.jsx(iY,{children:"Create a new automation to send messages to your customers."})]})})}),t.jsx(rBe,{onClose:e=>{i?.(e),n(!1)},automationType:r,currentStep:d,setCurrentStep:m,getExtraMergeFields:o})]})})})})}const sBe=({tabs:e,activeTab:n,onTabChange:i,tabsLocation:r="left",secondaryTabs:o=!1})=>{const s=a.useRef([]),[l,u]=a.useState({width:0,left:0});a.useEffect((()=>{const a=s.current[e.findIndex((e=>e.id===n))];a&&u({width:a.offsetWidth,left:a.offsetLeft})}),[n,e]);const c=e.find((e=>e.id===n));return t.jsxs("div",{className:"flex flex-col gap-4 w-full overflow-x-hidden h-full",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"relative flex items-center gap-8 "+("left"===r?"w-full justify-start":"w-full justify-center"),children:[t.jsx("div",{className:"absolute bottom-0 h-[1px] rounded-full transition-all duration-300 ease-out\n bg-gradient-to-r from-primary to-primary/90\n shadow-[0_0_8px_rgba(var(--primary-rgb),0.3)]",style:{width:`${l.width}px`,left:`${l.left}px`}}),e.map(((e,a)=>t.jsx("button",{ref:e=>s.current[a]=e,onClick:()=>i(e.id),className:$Z("relative px-7 py-3 transition-all duration-200 text-lg",n!==e.id&&"text-muted-foreground",o&&"text-sm"),children:e.label},e.id)))]})}),t.jsx("div",{className:"relative overflow-hidden flex-grow min-h-0",children:t.jsx("div",{className:"relative h-full",children:c?c.content:null})})]})},lBe=({primaryColor:e="var(--primary)"})=>{const a=e;return t.jsxs("div",{className:"space-y-4",children:[t.jsx(MCe,{children:"This is how your brand colors will look on email"}),t.jsx("div",{className:"bg-muted/50 p-6 rounded-lg w-full mx-auto border border-muted",children:t.jsxs("div",{className:"flex flex-col bg-background items-center space-y-4 max-w-md border rounded-lg mx-auto pb-8 overflow-hidden",children:[t.jsx("div",{className:"h-20 w-full -mb-10 bg-secondary"}),t.jsx("div",{className:"w-12 h-12 rounded-lg"}),t.jsxs("div",{className:"w-full space-y-3 flex flex-col items-center px-8 pb-4 max-w-sm",children:[t.jsx("div",{className:"h-2 rounded w-3/4 mx-auto bg-muted-foreground"}),t.jsx("div",{className:"h-2 bg-muted rounded w-full"}),t.jsx("div",{className:"h-2 bg-muted rounded w-2/3"}),t.jsx("div",{className:"h-2 bg-muted rounded w-2/3"})]}),t.jsx(H5,{className:"w-full max-w-[20ch]",style:{backgroundColor:a,borderColor:a},children:"Button"})]})})]})},uBe={all:["website"],content:()=>[...uBe.all,"content"],analyze:()=>[...uBe.all,"analyze"],brandSettings:()=>[...uBe.all,"brand-settings"]},cBe=async()=>(await Le("/web-presence/brand-settings",{method:"POST"})).data,dBe=({isLoading:e,brandSettings:n,onComplete:i})=>{const[r,o]=a.useState(0),s=[{text:"Analyzing your brand palette",icon:Rz},{text:"Extracting your visual identity",icon:bz},{text:"Discovering your brand personality",icon:Sz},{text:"Crafting your email style",icon:Tz},{text:"Finalizing your brand profile",icon:uz}];a.useEffect((()=>{if(!e)return;const a=setInterval((()=>{o((e=>{const t=e+1;return t>=s.length?(clearInterval(a),setTimeout((()=>{i()}),1500),e):t}))}),2500);return()=>clearInterval(a)}),[e,i,s.length]);return t.jsx(o5.div,{className:"flex flex-col items-center justify-center h-full w-full bg-background p-6",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},children:t.jsxs("div",{className:"flex flex-col items-center gap-8 max-w-2xl w-full",children:[t.jsx(o5.div,n?.logoUrl?{className:"w-24 h-24 sm:w-32 sm:h-32 flex items-center justify-center rounded-xl overflow-hidden bg-card shadow-md border",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:t.jsx("img",{src:n.logoUrl,alt:"Brand Logo",className:"max-w-full max-h-full object-contain"})}:{className:"w-24 h-24 sm:w-32 sm:h-32 rounded-xl flex items-center justify-center shadow-md border bg-primary",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:n?.brandName?t.jsx("span",{className:"text-4xl sm:text-5xl font-bold text-white",children:n.brandName.charAt(0)}):t.jsx($z,{className:"w-12 h-12 sm:w-16 sm:h-16 text-white"})}),t.jsx(o5.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-xl font-medium text-center text-foreground",children:s[r].text},`loading-${r}`),t.jsx("div",{className:"flex items-center justify-center space-x-8 sm:space-x-12",children:s.map(((e,a)=>{const n=a<=r,i=a===r;return t.jsxs(o5.div,{className:"relative flex items-center justify-center w-12 h-12 rounded-full border-2 "+(n?"bg-card shadow-md border-primary":"bg-muted border-muted-foreground/30"),initial:{scale:.8,opacity:.5},animate:{scale:i?1.1:1,opacity:n?1:.5},transition:{duration:.3},children:[t.jsx(e.icon,{className:"w-5 h-5 "+(n?"text-primary":"text-muted-foreground")}),i&&t.jsx(o5.div,{className:"absolute inset-0 rounded-full border-2 border-primary",initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]},`step-${a}`)}))}),t.jsx(o5.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8,duration:.6},className:"w-full",children:t.jsx("div",{className:"h-[140px] w-full max-w-lg mx-auto p-5 bg-gradient-to-br from-card/70 to-card/40 backdrop-blur-md rounded-2xl border border-border/60 shadow-lg",children:t.jsxs("div",{className:"h-full flex flex-col justify-center",children:[0===r&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80 text-center",children:"Extracted Color Palette"}),t.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[n?.primaryColor,...n?.secondaryColors||[]]?.slice(0,4).map(((e,a)=>t.jsx("div",{className:"flex flex-col items-center gap-1",children:t.jsx("div",{className:"w-10 h-10 rounded-xl border-2 border-white/50 shadow-md",style:{backgroundColor:e}})},a)))}),t.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"Brand colors identified"})]}),1===r&&t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Identity"}),n?.brandName?t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-xl font-bold",children:n.brandName}),n.brandTagline&&t.jsxs("div",{className:"text-sm text-muted-foreground italic px-4",children:['"',n.brandTagline,'"']}),t.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Visual identity extracted"})]}):t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Extracting brand elements..."})]}),2===r&&t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Personality"}),n?.brandPersonality?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-center gap-4",children:[n.brandPersonality.tone&&t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Tone"}),t.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:n.brandPersonality.tone})]}),n.brandPersonality.voice&&t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Voice"}),t.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:n.brandPersonality.voice})]})]}),n.brandPersonality.values&&n.brandPersonality.values.length>0&&t.jsx("div",{className:"flex justify-center gap-1 flex-wrap",children:n.brandPersonality.values.slice(0,3).map(((e,a)=>t.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full",children:e},a)))})]}):t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand tone and voice..."})]}),3===r&&t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Email Template Preview"}),t.jsxs("div",{className:"bg-background/60 rounded-lg p-3 border border-border/30",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-4 h-4 rounded"}),t.jsx("div",{className:"text-xs font-medium text-foreground",children:n?.brandName||"Your Brand"})]}),t.jsxs("div",{className:"text-xs text-muted-foreground text-left",children:["Email styling applied with your brand colors",n?.brandPersonality?.tone&&`, ${n.brandPersonality.tone} tone`,", and visual identity"]})]})]}),4===r&&t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Kit Complete"}),t.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[t.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Identity"}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:n?.brandName?"✓":"—"})]}),t.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Colors"}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:n?.primaryColor?"✓":"—"})]}),t.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Personality"}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:n?.brandPersonality?.tone?"✓":"—"})]})]})]}),(0===r&&!n?.primaryColor&&!n?.colorPalette||1===r&&!n?.brandName||2===r&&!n?.brandPersonality)&&t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand data..."}),t.jsx("div",{className:"flex justify-center gap-1 mt-2",children:[...Array(3)].map(((e,a)=>t.jsx(o5.div,{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/50",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:1,repeat:1/0,delay:.2*a}},a)))})]})]})})},`content-${r}`)]})})},mBe=({setAutoParse:e,onBrandSettingsGenerated:n})=>{const{data:i,updateWebsite:r,isUpdatingWebsite:o}=xwe(),s=be({mutationFn:cBe,mutationKey:uBe.brandSettings(),onSuccess:()=>{Ge({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})},onError:()=>{Ge({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}}),[l,u]=a.useState(i?.website||""),[c,d]=a.useState(!1),[m,h]=a.useState(null),[p,g]=a.useState(!1);return t.jsxs("div",{className:"flex flex-col pt-4 pb-12",children:[t.jsx("div",{className:"flex-1 flex flex-col",children:t.jsx("div",{className:"flex-1 p-4 space-y-4",children:t.jsxs(wY,{mode:"wait",children:[!p&&t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"h-full flex flex-col",children:t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 space-y-8",children:[t.jsxs("div",{className:"space-y-2 w-full max-w-md",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Your Website URL"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center",children:[t.jsx(gte,{type:"url",value:l,onChange:e=>u(e.target.value),placeholder:"https://example.com",className:"flex-1",disabled:!c}),t.jsx(wY,{mode:"wait",children:c?t.jsxs(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2",children:[t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>{d(!1),u(i?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),t.jsx(H5,{size:"sm",onClick:async()=>{try{r(l),d(!1)}catch(e){}},disabled:o||!l,className:"w-full sm:w-auto",children:o?t.jsx(lY,{}):"Save Changes"})]},"save"):t.jsx(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>d(!0),className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl",children:[t.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[t.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"What we'll analyze"}),t.jsxs("ul",{className:"text-sm text-gray-600 space-y-1",children:[t.jsx("li",{children:"• Your brand colors and color palette"}),t.jsx("li",{children:"• Your logo (if detectable)"}),t.jsx("li",{children:"• Your brand name and tagline"}),t.jsx("li",{children:"• Your brand's tone and personality"})]})]}),t.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[t.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"How it helps you"}),t.jsx("p",{className:"text-sm text-gray-600",children:"Our AI will automatically extract your brand assets to create consistently styled emails that match your website. This helps maintain brand recognition and professionalism in all your communications."})]})]}),t.jsx(o5.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground max-w-md text-center",children:"We'll use AI to analyze your website and extract your brand elements to create perfectly matched email templates."})]})},"url-confirmation"),p&&m&&t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"h-full",children:t.jsx(dBe,{isLoading:p,brandSettings:m,onComplete:()=>{g(!1),Ge({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})}})},"analyzing"),p&&!m&&t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"my-12 h-full flex flex-col items-center justify-center",children:t.jsxs(o5.div,{className:"flex flex-col items-center gap-8",initial:{backgroundPosition:"0% 0%"},animate:{backgroundPosition:"100% 100%"},transition:{duration:5,repeat:1/0,repeatType:"reverse"},children:[t.jsxs(o5.div,{className:"relative w-24 h-24 flex items-center justify-center",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:[t.jsx(Iz,{className:"w-12 h-12 text-primary drop-shadow-md"}),t.jsx(o5.div,{className:"absolute inset-0 rounded-full border-2",style:{borderColor:"var(--primary)"},initial:{scale:.8,opacity:0},animate:{scale:2.5,opacity:[0,.8,0]},transition:{duration:3,repeat:1/0,ease:"easeOut",repeatType:"loop"}})]}),t.jsxs("div",{className:"space-y-2 pt-16 text-center",children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Analyzing your website"}),t.jsx(wY,{mode:"wait",children:t.jsx(o5.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-muted-foreground/50 max-w-md",children:"Generating your brand's unique visual identity and personality"},"loading-message")})]})]})},"pre-analyzing")]})})}),!p&&t.jsxs(tY,{className:"text-center sm:justify-center",children:[t.jsx(H5,{variant:"outline",onClick:()=>{e(!1)},className:"gap-1",children:"Go Back"}),t.jsxs(H5,{onClick:async()=>{try{g(!0);const e=await s.mutateAsync();h(e),n&&n(e)}catch(e){g(!1),h(null),Ge({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}},disabled:!l||s.isPending,className:"gap-1",children:[t.jsx($z,{className:"h-4 w-4 text-amber-500"}),s.isPending?t.jsx(lY,{}):"Analyze Website"]})]})]})},hBe=()=>{const{data:e,updateWebsite:n,isUpdatingWebsite:i}=xwe(),[r,o]=a.useState(e?.website||""),[s,l]=a.useState(!1),{toast:u}=Ve();return t.jsx("div",{className:"w-full h-full flex flex-col bg-background rounded-lg",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t.jsx(wY,{mode:"wait",children:t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col h-full",children:t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center space-y-8",children:t.jsx("div",{className:"space-y-2 w-full max-w-lg",children:t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center h-full",children:[t.jsx(gte,{type:"url",value:r,onChange:e=>o(e.target.value),placeholder:"https://example.com",className:"flex-1 m-1",disabled:!s}),t.jsx(wY,{mode:"wait",children:s?t.jsxs(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2 items-center",children:[t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>{l(!1),o(e?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),t.jsx(H5,{size:"sm",onClick:async()=>{if(Ale.string().url().safeParse(r).success)try{n(r,{onSuccess:()=>{l(!1)}})}catch(e){}else u({title:"Invalid website URL",description:"Please enter a valid website URL (e.g. including http://)",variant:"destructive"})},disabled:i||!r,className:"w-full sm:w-auto",children:i?t.jsx(lY,{}):"Save Changes"})]},"save"):t.jsx(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>{l(!0)},className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})})})},"url-confirmation")})})})},pBe=({setAutoParse:e})=>{const{isLoading:a}=xwe();return t.jsxs("div",{className:"p-6 rounded-xl border-[5px] bg-background flex flex-col gap-3",style:{border:"5px solid transparent",background:"linear-gradient(white, white) padding-box, linear-gradient(164.56deg, rgba(152,194,255,0.6) 1%, rgba(194,177,231,0.6) 99%) border-box"},children:[t.jsxs("div",{className:"px-1 flex flex-col gap-3",children:[t.jsx("h3",{className:"font-medium text-sm leading-none",children:"Automatically add your brand to your emails"}),t.jsx("p",{className:"text-sm text-muted-foreground font-normal leading-none",children:"How your brand expresses itself in communication"})]}),t.jsxs("div",{className:"flex gap-4 items-center",children:[t.jsx(hBe,{}),t.jsxs(H5,{type:"button",onClick:async()=>{e(!0)},disabled:a,className:"flex gap-1 items-center",children:[t.jsx($z,{className:"h-4 w-4 text-amber-500"}),`${NMe}`]})]})]})},gBe=Ale.object({brandName:Ale.string().min(1,"Brand name is required"),logoUrl:Ale.string().optional(),logoBase64:Ale.string().optional(),primaryColor:Ale.string().regex(/^#[0-9A-F]{6}$/i,"Invalid color format")}),fBe=["#000000","#2563eb","#059669","#dc2626","#9333ea","#ea580c","#0891b2","#be123c","#4338f5","#16a34a"],vBe=a.forwardRef((({onSubmit:e,defaultValues:n},i)=>{const r=a.useRef(null),[o,s]=a.useState(n?.logoUrl||null),[l,u]=a.useState(null),[c,d]=a.useState(null),[m,h]=a.useState(!1),p=yCe({resolver:iMe(gBe),defaultValues:{brandName:n?.brandName||"",logoUrl:n?.logoUrl||"",primaryColor:n?.primaryColor||fBe[0]},mode:"onBlur"});a.useEffect((()=>{if(n&&null===c){const e={brandName:n.brandName||"",logoUrl:n.logoUrl||"",primaryColor:n.primaryColor||fBe[0]};p.reset(e),d(e),s(n.logoUrl||null)}}),[n,p,c]);const g=e=>{u(null);const a=e.target.files?.[0];if(a){if(!["image/png","image/jpeg"].includes(a.type))return void u("Only PNG and JPEG files are supported. Please upload a valid image.");const e=new FileReader;e.onloadend=()=>{const a=e.result;s(a),p.setValue("logoBase64",IMe(a))},e.readAsDataURL(a)}},f=async a=>{await e(a)};return a.useImperativeHandle(i,(()=>({submit:()=>{p.handleSubmit(f)()},isDirty:()=>{if(!c)return!1;const e=p.getValues();return e.brandName!==c.brandName||e.logoUrl!==c.logoUrl||e.primaryColor!==c.primaryColor}}))),t.jsxs(t.Fragment,{children:[!1===m&&t.jsx("div",{className:"px-8 pt-8",children:t.jsx(pBe,{setAutoParse:h})}),m?t.jsx("div",{className:"px-8",children:t.jsx(mBe,{setAutoParse:h,onBrandSettingsGenerated:e=>{h(!1),p.setValue("brandName",e.brandName||""),p.setValue("logoBase64",e.logoUrl?IMe(e.logoUrl):""),p.setValue("primaryColor",e.primaryColor||fBe[0]),s(e.logoUrl||null)}})}):t.jsx(bCe,{...p,children:t.jsxs("form",{onSubmit:p.handleSubmit(f),className:"space-y-6 p-8",children:[t.jsx(SCe,{control:p.control,name:"brandName",render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Brand Name"}),t.jsx(TCe,{children:t.jsx(gte,{placeholder:"Enter your brand name",...e})}),t.jsx(xCe,{})]})}),t.jsx(SCe,{control:p.control,name:"logoUrl",render:()=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Brand Logo"}),t.jsx(TCe,{children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-dashed border-border flex items-center justify-center bg-muted overflow-hidden",children:o?t.jsx("img",{src:o,alt:"Brand logo preview",className:"w-full h-full object-contain"}):t.jsx(eO,{className:"h-8 w-8 text-muted-foreground"})}),t.jsxs("div",{className:"flex flex-col gap-2 max-w-xs w-full",children:[t.jsx("input",{type:"file",ref:r,onChange:g,accept:"image/png, image/jpeg",className:"hidden"}),t.jsxs(H5,{type:"button",variant:"outline",onClick:()=>r.current?.click(),disabled:p.formState.isSubmitting,children:[t.jsx(eO,{className:"w-4 h-4 mr-2"}),"Upload Logo"]}),t.jsx("span",{className:"text-xs text-muted-foreground mt-1 break-words whitespace-normal",children:"Upload a square PNG or JPEG (min. 100×100px) with white or transparent background for best results"}),l&&t.jsx("span",{className:"text-xs text-destructive mt-1",children:l})]})]})}),t.jsx(xCe,{})]})}),t.jsx(SCe,{control:p.control,name:"primaryColor",render:({field:e})=>{const a=e.value||p.getValues("primaryColor");return t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Primary Color"}),t.jsx(TCe,{children:t.jsxs("div",{className:"flex-1 max-w-xs space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Rz,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),t.jsx(gte,{type:"text",value:a,onChange:a=>e.onChange(a.target.value),className:"font-mono text-sm pl-10 pr-12",placeholder:fBe[3],disabled:p.formState.isSubmitting}),t.jsx("input",{type:"color",value:a,onChange:a=>e.onChange(a.target.value),className:"sr-only",disabled:p.formState.isSubmitting,id:"colorPicker"}),t.jsx(H5,{variant:"ghost",size:"sm",onClick:()=>document.getElementById("colorPicker")?.click(),className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-6 h-6 rounded-sm border border-border cursor-pointer hover:border-border/80 transition-colors",style:{backgroundColor:a},disabled:p.formState.isSubmitting})]}),t.jsx("div",{className:"flex gap-3 flex-wrap",children:fBe.map((n=>t.jsx(H5,{type:"button",variant:"ghost",size:"sm",className:"w-4 h-4 p-0 rounded-full border "+(a===n?"ring-2 ring-gray-400":""),style:{backgroundColor:n},onClick:()=>e.onChange(n),disabled:p.formState.isSubmitting},n)))})]})}),t.jsx(xCe,{})]})}}),t.jsx(lBe,{primaryColor:p.watch("primaryColor")})]})})]})}));vBe.displayName="BrandSettingsForm";const yBe=()=>{const{data:e}=xwe();return{brandDefaults:{brandName:e?.branding?.brandName||e?.name,brandTagline:e?.branding?.brandTagline,logoUrl:e?.branding?.logoUrl,primaryColor:e?.branding?.primaryColor,secondaryColors:e?.branding?.secondaryColors,brandPersonality:e?.branding?.brandPersonality},businessDefaults:{company:{name:e?.name||"",website:e?.website||"",address1:"",address2:"",city:"",stateProvince:"",zipCode:"",country:"US"},contact:{firstName:"",lastName:"",email:"",phoneNumber:""}},meResponse:e}},bBe=()=>{const{toast:e}=Ve(),{updateBrandSettings:a,updateBusinessSettings:t}=xwe(),{updateChannelSender:n}=Ure(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre();return{handleBrandSubmit:async(t,n)=>{try{a({brandName:t.brandName,primaryColor:t.primaryColor,logoUrl:t.logoUrl,logoBase64:t.logoBase64},{onSuccess:()=>{n?.()}})}catch(i){e({title:"Failed to save brand settings",description:"Please try again",variant:"destructive"})}},handleBusinessSubmit:async(a,n)=>{try{t(a,{onSuccess:()=>{n?.()}})}catch(i){e({title:"Failed to save business settings",description:"Please try again",variant:"destructive"})}},handleEmailSubmit:async(a,t)=>{try{const o=Uwe({channelSenders:i?.results??[],channelAccounts:r?.results??[]}).find((e=>e.channelSenderId===a.channelSenderId));if(!o)return;n({toUpdate:{channelSenderMetadata:{...o.channelSender.channelSenderMetadata,emailReplyTo:a.replyToEmail,emailFromName:a.displayName}},id:o.channelSender.id},{onSuccess:()=>{e({title:"Email channel settings saved 🚀"}),t?.()},onError:()=>{e({title:"Failed to save email channel settings",description:"Please try again",variant:"destructive"})}})}catch(o){e({title:"Failed to save email channel settings",description:"Please try again",variant:"destructive"})}},handleSMSSubmit:async a=>{try{await new Promise((e=>setTimeout(e,500))),e({title:"SMS channel settings saved 🚀"}),a?.()}catch(t){e({title:"Failed to save SMS channel settings",description:"Please try again",variant:"destructive"})}}}},kBe=a.createContext(null),SBe=()=>{const e=a.useContext(kBe);if(!e)throw new Error("useEngageSettingsContext must be used within EngageSettingsProvider");return e},wBe=({isOnboarding:e=!1,onNext:n,onBack:i,title:r,description:o})=>{const{navigation:s}=SBe(),{isUpdatingBrandSettings:l,isLoading:u}=xwe(),{brandDefaults:c}=yBe(),{handleBrandSubmit:d}=bBe(),m=a.useContext(BCe),h=a.useRef(null),p=n||m?.goToNextStep||s?.goToNextStep||(()=>{});return t.jsx(QCe,{title:r||(e?gMe:dMe),description:o||(e?"Add your logo, colors, and brand voice to match your identity across all communication.":"Configure your brand identity and visual elements."),onBack:i||m?.goToPreviousStep||s?.goToPreviousStep||(()=>{}),onNext:()=>h.current?.submit(),isSubmitting:l,submitLabel:e?void 0:"Save",mode:e?"onboarding":"settings",children:u?t.jsx("div",{className:"flex justify-center items-center h-full py-10",children:t.jsx(lY,{})}):t.jsx(vBe,{ref:h,onSubmit:a=>d(a,e?p:void 0),defaultValues:c})})},ABe=({schema:e,defaultValues:a,onSubmit:t})=>{const{toast:n}=Ve(),i=yCe({resolver:iMe(e),defaultValues:a,mode:"onSubmit",reValidateMode:"onSubmit"});return{form:i,handleSubmit:i.handleSubmit((async e=>{try{await t(e)}catch(a){throw n({title:"Validation Error",description:a instanceof Error?a.message:"Please check your inputs",variant:"destructive"}),a}})),isSubmitting:i.formState.isSubmitting,errors:i.formState.errors}};var CBe=(e=>(e.STANDARD="standard",e))(CBe||{});const MBe=Ale.object({type:Ale.literal("standard"),company:Ale.object({name:Ale.string().describe("The legal name of the company"),address1:Ale.string().optional(),address2:Ale.string().optional(),city:Ale.string().optional(),stateProvince:Ale.string().optional(),zipCode:Ale.string().optional(),country:Ale.string().length(2).optional()})}),TBe=Ale.discriminatedUnion("type",[MBe]),xBe=({isOnboarding:e=!1,onNext:n,onBack:i,onSkip:r,title:o,description:s,showPrefilled:l=!1,prefilledData:u})=>{const{navigation:c}=SBe(),{isUpdatingBusinessSettings:d}=xwe(),{businessDefaults:m}=yBe(),{handleBusinessSubmit:h}=bBe(),p=a.useContext(BCe),g=n||p?.goToNextStep||c?.goToNextStep||(()=>{});return t.jsx(QCe,{title:o||(e?fMe:mMe),description:s||(e?"Configure your business information for SMS toll-free number registration.":"Provide your business details and authorized representative information."),onBack:i||p?.goToPreviousStep||c?.goToPreviousStep||(()=>{}),onNext:()=>{const e=document.querySelector("form");e?.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))},onSkip:r,isSubmitting:d,submitLabel:e?void 0:"Save",mode:e?"onboarding":"settings",children:t.jsxs("div",{className:"space-y-4",children:[l&&u&&t.jsx(NBe,{}),t.jsx(EBe,{onSubmit:a=>h(a,e?g:void 0),defaultValues:u||m})]})})},EBe=({onSubmit:e,defaultValues:a,context:n="email"})=>{const{form:i,handleSubmit:r}=ABe({schema:TBe,defaultValues:{type:CBe.STANDARD,company:{name:a?.company?.name||"",address1:a?.company?.address1||"",address2:a?.company?.address2||"",city:a?.company?.city||"",stateProvince:a?.company?.stateProvince||"",zipCode:a?.company?.zipCode||"",country:a?.company?.country||""}},onSubmit:e});return t.jsx(bCe,{...i,children:t.jsxs("form",{onSubmit:r,className:"space-y-6 p-8",children:[t.jsx(ZCe,{title:"",children:t.jsx(LMe,{control:i.control,context:n})}),t.jsx(H5,{type:"submit",className:"sr-only",children:"Submit"})]})})},NBe=()=>t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4 mx-auto",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(tz,{className:"w-5 h-5 text-primary flex-shrink-0 mt-0.5"}),t.jsx("p",{className:"text-primary text-sm text-left",children:"Your business information has been automatically filled from your account settings. You can review and edit these details if needed."})]})}),_Be=Ale.object({displayName:Ale.string().min(1,"Display name is required"),channelSenderId:Ale.string().min(1,"Channel sender is required"),replyToEmail:Ale.string().email("Please enter a valid email address")}),PBe=({onSubmit:e})=>{const{channelSenders:n,isLoading:i}=Jre(),{channelAccounts:r,isLoading:o}=Fre(),s=a.useRef(!1),{form:l,handleSubmit:u}=ABe({schema:_Be,defaultValues:{channelSenderId:"",displayName:"",replyToEmail:""},onSubmit:e}),c=a.useMemo((()=>Uwe({channelSenders:n?.results??[],channelAccounts:r?.results??[]})),[n?.results,r?.results]),d=a.useMemo((()=>c.map((e=>({value:e.channelSenderId,label:e.fullDomain,description:e.channelSender.channelSenderMetadata.emailReplyTo||"No reply-to set"})))),[c]);return a.useEffect((()=>{if(c.length>0&&!s.current){s.current=!0;const e=c[0],{emailFromName:a,emailReplyTo:t}=e.channelSender.channelSenderMetadata;l.reset({channelSenderId:e.channelSenderId,displayName:a||"",replyToEmail:t||""})}}),[c,l]),a.useEffect((()=>{const e=l.watch(((e,{name:a})=>{if("channelSenderId"===a&&e.channelSenderId&&s.current){const a=c.find((a=>a.channelSenderId===e.channelSenderId));if(a){const{emailFromName:e,emailReplyTo:t}=a.channelSender.channelSenderMetadata;e&&l.setValue("displayName",e),t&&l.setValue("replyToEmail",t)}}}));return()=>e.unsubscribe()}),[c,l]),i||void 0===n||o||void 0===r?t.jsx("div",{className:"flex justify-center items-center h-full py-10",children:t.jsx(lY,{})}):t.jsx(bCe,{...l,children:t.jsxs("form",{onSubmit:u,className:"space-y-6 p-8",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{children:"Account Email"}),t.jsx(Fue,{title:"This is the address your recipients will see as the sender of the email.",size:"small"})]}),t.jsx($Ce,{control:l.control,name:"channelSenderId",label:"",placeholder:"Select a sender",options:d})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{children:"Display Name"}),t.jsx(Fue,{title:"This is the name that appears in the 'From' field alongside your sender email.",size:"small"})]}),t.jsx(qCe,{control:l.control,name:"displayName",label:"",placeholder:"Name that appears in the From field"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{children:"Reply-to Email"}),t.jsx(Fue,{title:"Replies from recipients will go to this email address. It can be different from the default sender address.",size:"small"})]}),t.jsx(qCe,{control:l.control,name:"replyToEmail",label:"",placeholder:"Replies from recipients will go to this email",type:"email"})]}),t.jsx(H5,{type:"submit",className:"sr-only",children:"Submit"})]})})},jBe=({isOnboarding:e=!1,onNext:n,onBack:i,title:r,description:o})=>{const{navigation:s}=SBe(),{handleEmailSubmit:l}=bBe(),{isUpdating:u}=Ure(),c=a.useContext(BCe),d=n||c?.goToNextStep||s?.goToNextStep||(()=>{});return t.jsx(QCe,{title:r||(e?vMe:hMe),description:o||(e?"Configure your email settings to ensure proper delivery and branding of your email communications.":"Configure your email sending settings and preferences."),onBack:i||c?.goToPreviousStep||s?.goToPreviousStep||(()=>{}),onNext:()=>{const e=document.querySelector("form");e?.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))},isSubmitting:u,submitLabel:e?void 0:"Save",mode:e?"onboarding":"settings",children:t.jsx(PBe,{onSubmit:a=>l(a,e?d:void 0)})})},LBe=({hideSubmitButton:e=!1,formRef:n,onNeedsApplicationChange:i,onApplicationSubmit:r,onFormVisibilityChange:o})=>{const[s,l]=a.useState(null),{channelSenders:u}=Jre(),{channelAccounts:c}=Fre(),{data:d}=$re(),m=Nle({channelSenders:u?.results??[],channelAccounts:c?.results??[],smsApplication:d});a.useEffect((()=>{if(null!==s||void 0===c||void 0===u)return;m.some((e=>e.smsApplication?.status===Ele.APPROVED||null===e.smsApplication))?(l({sender:m}),i?.(!1)):(l(!1),i?.(!0))}),[m,s,c,u,i]);const h={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}};if(null===s)return t.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:t.jsx(lY,{})});const p=m.some((e=>e.smsApplication?.status===Ele.APPROVED));return t.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:s?t.jsxs(o5.div,{initial:"hidden",animate:"visible",exit:"exit",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1],staggerChildren:.1}},exit:{opacity:0,y:-20,transition:{duration:.3,ease:[.4,0,1,1]}}},className:XO("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl gap-3 mx-auto bg-background"),children:[t.jsx(o5.div,{variants:h,className:"w-16 h-16 rounded-xl flex items-center justify-center bg-primary/10",children:t.jsx(V5.SmsIcon,{className:"text-primary"})}),t.jsx(o5.h2,{variants:h,className:"text-lg font-medium text-foreground",children:"SMS Sending Number Active"}),t.jsx(o5.div,{variants:h,className:"max-w-xl mx-auto",children:t.jsx("p",p?{className:"text-sm font-normal text-muted-foreground mb-2",children:"Your SMS sending number has been verified and is ready to use. You can now create and send SMS campaigns!"}:{className:"text-sm font-normal text-muted-foreground mb-2",children:"You already have a valid SMS sending number and it is ready to use. You can create and send SMS campaigns!"})}),t.jsxs(o5.div,{variants:h,className:"flex flex-col items-center w-full gap-4",children:[t.jsxs("span",{className:"inline-flex items-center px-4 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-800 font-medium text-base mb-2",children:[t.jsx("span",{className:"w-2 h-2 bg-blue-500 rounded-full mr-2"}),"Ready to send"]}),t.jsx("div",{className:"w-full flex flex-col gap-3 max-w-md mx-auto",children:m.map((e=>{const a=!!e.channelSender.channelSenderMetadata.friendlyName?.toLowerCase().includes("pending approval"),n=e.channelSender.channelSenderMetadata.friendlyName||e.channelSender.channelSenderMetadata.from||"Unknown Number";return t.jsxs("div",{className:XO("flex items-center justify-between rounded-xl px-4 py-3 border shadow-sm",a?"bg-gray-50 border-gray-200 text-gray-500":"bg-blue-50 border-blue-200 text-blue-900 font-semibold"),children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a?t.jsx(V5.AlertCircleIcon,{className:"w-5 h-5 text-yellow-500 shrink-0"}):t.jsx(V5.CheckIcon,{className:"w-5 h-5 text-blue-500 shrink-0"}),t.jsx("span",{className:"truncate",title:n,children:n})]}),!a&&e.channelSender.channelSenderMetadata.from&&e.channelSender.channelSenderMetadata.friendlyName!==e.channelSender.channelSenderMetadata.from&&t.jsx("span",{className:"font-mono text-xs text-blue-700 ml-2",children:e.channelSender.channelSenderMetadata.from})]},e.channelSender.id)}))})]})]}):t.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:t.jsx(zMe,{hideSubmitButton:e,formRef:n,onApplicationSubmit:r,onFormVisibilityChange:o})})})},BBe=({isOnboarding:e=!1,onNext:n,onBack:i,title:r,description:o})=>{const{navigation:s}=SBe(),{handleSMSSubmit:l}=bBe(),{createSmsRegistrationApplication:u,isCreating:c}=Zre(),{toast:d}=Ve(),m=a.useRef(null),[h,p]=a.useState(!1),[g,f]=a.useState(!1),[v,y]=a.useState(!1),b=a.useContext(BCe),k=n||b?.goToNextStep||s?.goToNextStep||(()=>{});return t.jsx(QCe,{title:r||(e?yMe:pMe),description:o||(e?"Set up your SMS provider to start sending personalized messages to your customers.":"Configure your SMS sending settings and preferences."),onBack:i||b?.goToPreviousStep||s?.goToPreviousStep||(()=>{}),onNext:async()=>{if(h&&g&&m.current)m.current.submit();else{y(!0);try{await l(e?k:void 0)}finally{y(!1)}}},submitLabel:h&&g?e?void 0:"Submit for approval":e?void 0:"Save",isSubmitting:h&&g?c:v,mode:e?"onboarding":"settings",children:t.jsx(LBe,{hideSubmitButton:!0,formRef:m,onNeedsApplicationChange:p,onApplicationSubmit:async a=>{try{await u({application:a,onSuccess:()=>{d({title:"SMS application submitted 🚀",description:"Your application has been submitted for approval."}),e&&k()}})}catch(t){d({title:"Failed to submit SMS application",description:"Please try again",variant:"destructive"})}},onFormVisibilityChange:f})})},RBe=()=>{const{open:e,setOpen:a,currentStep:n,navigation:i}=SBe();return t.jsx(UCe,{open:e,onOpenChange:e=>{e||a(!1)},title:sMe,description:lMe,sidebarItems:PMe,currentStep:n,onStepChange:i.goToStep,completedSteps:[],mode:"settings",showSidebar:!0,className:"max-w-4xl h-[80vh]",children:{[oMe.BRAND]:t.jsx(wBe,{}),[oMe.BUSINESS]:t.jsx(xBe,{}),[oMe.EMAIL]:t.jsx(jBe,{}),[oMe.SMS]:t.jsx(BBe,{})}[n]||null})},DBe=({children:e,open:a,setOpen:n})=>{const{navigation:i}=RCe({config:{steps:PMe,initialStep:oMe.BRAND},onClose:()=>n(!1)});return t.jsx(kBe.Provider,{value:{open:a,setOpen:n,currentStep:i.currentStep,navigation:i},children:e})},zBe=a.createContext(void 0),OBe=()=>{const e=a.useContext(zBe);if(!e)throw new Error("useEngageOnboardingContext must be used within EngageOnboardingProvider");return e},KBe=[oMe.SPLASH,oMe.BRAND,oMe.EMAIL,oMe.BUSINESS,oMe.BUSINESS_SKIP_INTERSTITIAL,oMe.SMS_INTERSTITIAL,oMe.SMS,oMe.COMPLETION],HBe=()=>{const{onClose:e}=OBe(),[t,n]=a.useState(!1),[i,r]=a.useState(!1),o=a.useMemo((()=>KBe.filter((e=>!(e===oMe.SMS&&t||e===oMe.SMS_INTERSTITIAL&&t||e===oMe.BUSINESS_SKIP_INTERSTITIAL&&i)))),[t,i]),s=a.useMemo((()=>({steps:o.map((e=>({key:e,label:e}))),initialStep:oMe.SPLASH,mode:ECe})),[o]),{navigation:l}=RCe({config:s,onClose:e}),u=a.useCallback((e=>{e===oMe.BUSINESS&&i&&r(!1),l.goToStep(e)}),[i,l]),c=a.useCallback((e=>{n(!e),l.goToStep(e?oMe.SMS:oMe.COMPLETION)}),[l]),d=a.useCallback((()=>{r(!0),l.goToStep(oMe.BUSINESS_SKIP_INTERSTITIAL)}),[l]),m=a.useCallback((()=>{e(),l.goToStep(oMe.SPLASH),n(!1),r(!1)}),[e,l]);return{currentStep:l.currentStep,currentStepIndex:l.currentStepIndex,steps:l.steps,goToNextStep:l.goToNextStep,goToPreviousStep:l.goToPreviousStep,goToStep:u,canGoNext:l.canGoNext,canGoPrevious:l.canGoPrevious,isLastStep:l.isLastStep,isFirstStep:l.isFirstStep,handleSMSChoice:c,handleBusinessSkip:d,handleClose:m}},IBe=()=>{const{goToStep:e,goToNextStep:a}=HBe();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:t.jsxs("div",{className:"max-w-2xl space-y-6 w-full mx-auto",children:[t.jsx("div",{className:"w-16 h-16 bg-amber-100 rounded-2xl flex items-center justify-center",children:t.jsx(fz,{className:"w-8 h-8 text-amber-600"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"text-xl font-medium text-primary",children:"Business information can be added later"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"You can always return to add your business details when you're ready to get approved for sending."})]}),t.jsx("div",{className:"bg-muted/50 border border-muted rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(QD,{className:"w-5 h-5 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"What you'll miss:"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Business approval for higher sending limits and better deliverability"})]})]})})]})}),t.jsx("div",{className:"border-t border-border py-6 px-8 bg-background",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(H5,{variant:"ghost",onClick:()=>e(oMe.BUSINESS),className:"flex items-center gap-2",children:[t.jsx($D,{className:"w-4 h-4"}),"Go back to business info"]}),t.jsx(H5,{onClick:a,children:"Continue without business info"})]})})]})},FBe=()=>{const{handleClose:e}=HBe();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8 pt-10 @lg/onboarding-sidebar:pt-16 flex items-center justify-center",children:t.jsxs("div",{className:"max-w-2xl space-y-8",children:[t.jsx("div",{className:"w-24 h-24 mx-auto bg-muted rounded-2xl flex items-center justify-center",children:t.jsx(uz,{className:"w-16 h-16 text-primary"})}),t.jsxs("div",{className:"space-y-10 text-center",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"font-medium text-foreground flex items-center justify-center gap-3 text-2xl",children:"You're Ready to Go 🚀"}),t.jsx("div",{className:"space-y-4 text-muted-foreground",children:t.jsxs("p",{className:"text-sm whitespace-pre-line",children:["Everything's configured — now start sending campaigns and"," ",lH("engage:automation",{count:2})," to engage your audience."]})})]}),t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4 max-w-md mx-auto",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Fue,{title:"You can set up SMS later from the settings menu.",size:"small"}),t.jsx("p",{className:"text-primary text-sm text-left",children:"You can set up SMS later from the settings menu."})]})})]})]})}),t.jsx("div",{className:"border-t border-border py-6 px-8 flex items-center justify-end bg-background gap-4",children:t.jsxs(H5,{onClick:e,className:"flex items-center gap-2 text-sm",children:["Go to dashboard",t.jsx(ZD,{className:"w-4 h-4"})]})})]})},GBe=()=>{const{handleSMSChoice:e,goToPreviousStep:a}=HBe();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8 pt-10 @lg/onboarding-sidebar:pt-16",children:t.jsxs("div",{className:"max-w-2xl text-center space-y-8",children:[t.jsx("div",{className:"w-24 h-24 mx-auto bg-muted rounded-2xl flex items-center justify-center",children:t.jsx(_z,{className:"w-12 h-12 text-muted-foreground"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"text-xl font-bold text-foreground",children:"Want to reach your audience via SMS?"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"Share time-sensitive updates and drive more engagement with verified SMS."})]}),t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"space-y-6 border-2 border-muted rounded-lg mx-auto overflow-hidden",children:[t.jsx("h2",{className:"text-primary font-medium text-base text-center bg-muted p-2",children:"Why set up SMS?"}),t.jsxs("div",{className:"space-y-4 px-6 pb-6",children:[t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(az,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"SMS messages get 5x more opens than emails"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(oO,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Send urgent updates instantly"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(Uz,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Gain trust with verified sender ID"})]})]})]})}),t.jsx("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-4 max-w-sm mx-auto",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(wz,{className:"w-5 h-5 text-primary flex-shrink-0 mt-0.5"}),t.jsx("p",{className:"text-primary text-sm text-left whitespace-pre-line",children:"SMS requires company verification via Twilio. You can skip this step and set it up later."})]})})]})}),t.jsxs("div",{className:"border-t border-border py-6 px-8 flex items-center justify-between bg-background gap-4",children:[t.jsxs(H5,{variant:"outline",onClick:a,className:"flex items-center gap-2 text-sm",children:[t.jsx(iz,{className:"w-4 h-4"}),"Previous Step"]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(H5,{onClick:()=>e(!1),variant:"outline",className:"flex items-center gap-2 text-sm",children:"Not now"}),t.jsxs(H5,{onClick:()=>e(!0),className:"flex items-center gap-2 text-sm",children:["Yes, let's setup SMS",t.jsx(ZD,{className:"w-4 h-4"})]})]})]})]})},VBe=()=>{const{goToNextStep:e}=HBe(),{isPrefilled:n}=(()=>{const{channelSenders:e}=Jre(),{channelAccounts:t}=Fre(),{data:n}=$re();return a.useMemo((()=>{if(!e?.results||!t?.results)return{isPrefilled:!1,prefilledData:null};const a=Nle({channelSenders:e.results,channelAccounts:t.results,smsApplication:n}).find((e=>e.smsApplication?.status===Ele.APPROVED));if(!a?.smsApplication?.application)return{isPrefilled:!1,prefilledData:null};const i=a.smsApplication.application;return{isPrefilled:!0,prefilledData:"aws_toll_free_number"===i.type?{type:CBe.STANDARD,company:{name:i.company.name,website:i.company.website,address1:i.company.address1,address2:i.company.address2,city:i.company.city,stateProvince:i.company.stateProvince,zipCode:i.company.zipCode,country:i.company.country},contact:{firstName:i.contact.firstName,lastName:i.contact.lastName,email:i.contact.email,phoneNumber:i.contact.phoneNumber}}:null}}),[e,t,n])})();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:t.jsxs("div",{className:"max-w-2xl space-y-6 w-full mx-auto",children:[t.jsx("div",{className:"w-16 h-16 bg-muted rounded-2xl flex items-center justify-center",children:t.jsx(Fz,{className:"w-8 h-8 text-primary"})}),t.jsxs("div",{className:"space-y-2 max-w-lg",children:[t.jsx("h1",{className:"text-xl font-medium text-primary leading-tight",children:"Start sending beautiful, branded emails & SMS"}),t.jsxs("p",{className:"text-sm",children:["Set up branded ",lH("engage:automation",{count:2})," that boost engagement and save you time."]})]}),t.jsxs("div",{className:"space-y-6 border-2 border-muted rounded-lg mx-auto overflow-hidden",children:[t.jsx("h2",{className:"text-primary font-medium text-base text-center bg-muted p-2",children:"Why set this up?"}),t.jsxs("div",{className:"space-y-4 px-6 pb-6",children:[t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(Fz,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Look professional from day one with branded emails and SMS"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(iO,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Reach more customers in less time with automated messages"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(oO,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Start sending in minutes - no tech skills required"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(fz,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Measure results - see what's working and improve"})]})]})]})]})}),t.jsxs("div",{className:"border-t border-border py-6 px-8 bg-background space-y-4",children:[n&&t.jsx("div",{className:"w-full flex-shrink-0",children:t.jsx(NBe,{})}),t.jsxs("div",{className:"flex items-center justify-between bg-background gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Fue,{title:`In just 5 minutes, you'll be ready to send branded ${lH("engage:automation",{count:2})}`,size:"small"}),t.jsxs("span",{children:["In just 5 minutes, you'll be ready to send branded"," ",lH("engage:automation",{count:2})]})]}),t.jsxs(H5,{onClick:e,className:"flex items-center gap-2 text-sm",children:["Let's start",t.jsx(ZD,{className:"w-4 h-4"})]})]})]})]})},JBe=()=>{const{open:e,onClose:a}=OBe(),{currentStep:n,goToStep:i,handleClose:r}=HBe(),o=n!==oMe.SPLASH&&n!==oMe.COMPLETION&&n!==oMe.BUSINESS_SKIP_INTERSTITIAL;return t.jsx(UCe,{open:e,onOpenChange:e=>{e||(r?r():a())},title:uMe,description:cMe,sidebarItems:jMe,currentStep:n,onStepChange:i,completedSteps:[],mode:"onboarding",showSidebar:o,showMobileNav:o,className:"max-w-5xl h-[90vh]",children:{[oMe.SPLASH]:t.jsx(VBe,{}),[oMe.BRAND]:t.jsx(wBe,{}),[oMe.EMAIL]:t.jsx(jBe,{}),[oMe.BUSINESS]:t.jsx(xBe,{}),[oMe.BUSINESS_SKIP_INTERSTITIAL]:t.jsx(IBe,{}),[oMe.SMS_INTERSTITIAL]:t.jsx(GBe,{}),[oMe.SMS]:t.jsx(BBe,{}),[oMe.COMPLETION]:t.jsx(FBe,{})}[n]||null})},UBe=({children:e,open:a,onClose:n})=>t.jsx(zBe.Provider,{value:{open:a,onClose:n},children:e}),WBe=({automationId:e,isOpen:a,onClose:n})=>{const{linkClickStats:i,isGetting:r,getError:o}=aa(e);return t.jsx(ZZ,{open:a,onOpenChange:n,children:t.jsxs(eY,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[t.jsx(aY,{children:t.jsxs(nY,{className:"flex items-center gap-2",children:[t.jsx(Bz,{className:"h-5 w-5"}),"Link Click Statistics"]})}),t.jsxs("div",{className:"space-y-4",children:[r&&t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"Loading link click statistics..."}),o&&t.jsx("div",{className:"text-sm text-destructive text-center py-8",children:"Error loading link click statistics. Please try again."}),!r&&!o&&(!i||0===Object.keys(i).length)&&t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No link clicks found."}),!r&&!o&&i&&Object.keys(i).length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Summary"}),t.jsxs("div",{className:"flex gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold",children:Object.keys(i).length})," ","unique links"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold",children:Object.values(i).reduce(((e,a)=>e+a),0)})," ","total clicks"]})]})]}),t.jsx("div",{className:"space-y-2",children:Object.entries(i).sort((([,e],[,a])=>a-e)).map((([e,a])=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:text-blue-800 hover:underline flex items-center gap-1 truncate",children:[t.jsx("span",{className:"truncate",children:e}),t.jsx(yz,{className:"h-3 w-3 flex-shrink-0"})]})}),t.jsxs("div",{className:"text-right ml-4",children:[t.jsx("span",{className:"font-semibold text-lg",children:a}),t.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:1===a?"click":"clicks"})]})]},e)))})]})]})]})})},qBe=e=>{if(!e)return"$0.00";const a="string"==typeof e?e.replace(/,/g,""):e,t=Number(a);return Number.isNaN(t)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t)},$Be=({Icon:e,title:a,value:n,tooltipText:i,change:r,onClick:o,isClickable:s=!1})=>t.jsxs(Zie,{className:"relative flex flex-col justify-between min-h-[130px] transition-all duration-300 p-4 "+(s?"hover:shadow-md cursor-pointer hover:bg-muted/50":"hover:shadow-md"),onClick:o,children:[t.jsxs("div",{className:"flex justify-between items-start",children:[t.jsx("div",{className:"rounded-lg p-2 bg-primary/10 flex items-center justify-center",children:t.jsx(e,{className:"w-5 h-5 text-primary"})}),t.jsx("div",{className:"absolute top-3 right-3",children:t.jsx(Fue,{title:i})})]}),t.jsxs("div",{className:"mt-4",children:[t.jsx("div",{className:"text-2xl font-bold leading-tight text-primary",children:n}),t.jsx(i_e,{children:a})]}),r&&t.jsx("div",{className:"absolute bottom-3 right-3",children:t.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full bg-green-100 text-green-600 text-xs font-semibold",children:r})})]}),ZBe=({activeTab:e,automation:a})=>{if(!a)return null;const n={sales:[{Icon:V5.SalesAmount,title:"Order Amount",value:qBe(a.derivedRevenue),tooltipText:"Total derived revenue from this campaign"},{Icon:V5.Orders,title:"Orders",value:a.derivedOrders,tooltipText:"Total individual orders from this campaign"}]};return t.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:n[e].map(((e,a)=>t.jsx($Be,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},YBe=({activeTab:e,statistics:a,automationId:n,onLinkClickStatsOpen:i})=>{const r={email:[{Icon:V5.MessagesSent,title:"Emails Sent",value:a.email.numberSent,tooltipText:"Total number of emails that were successfully sent in this campaign",onClick:void 0,isClickable:!1},{Icon:V5.OpenRate,title:"Open Rate",value:`${(100*a.email.openPercentage).toFixed(2)}%`,tooltipText:"Percentage of recipients who opened the email out of total emails delivered",onClick:void 0,isClickable:!1},{Icon:V5.TotalBounceRate,title:"Total Bounce Rate",value:`${(100*(a.email.softBounceRate+a.email.hardBounceRate)).toFixed(2)}%`,tooltipText:"Percentage of emails that were not delivered due to permanent (hard) or temporary (soft) delivery failures. Hard bounces will be automatically unsubscribed.",onClick:void 0,isClickable:!1},{Icon:V5.LinksClicked,title:"Links Clicked",value:a.email.linksClicked,tooltipText:"Total number of times recipients clicked on links within the email. Click to view detailed link statistics.",onClick:i,isClickable:!!n&&!!i},{Icon:V5.SpamComplies,title:"Spam Complaints",value:`${(100*a.email.spamComplaintRate).toFixed(2)}%`,tooltipText:"Percentage of emails that were marked as spam by recipients or their spam filters. Manual spam complaints will be automatically unsubscribed.",onClick:void 0,isClickable:!1},{Icon:V5.UnsubscribeRate,title:"Unsubscribe Rate",value:`${(100*a.email.unsubscribedRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who unsubscribed after receiving this email",onClick:void 0,isClickable:!1}],sms:[{Icon:V5.MessagesSent,title:"SMS Sent",value:a.sms.numberSent,tooltipText:"Total number of SMS messages that were successfully sent in this campaign",onClick:void 0,isClickable:!1}]};return t.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:r[e].map(((e,a)=>t.jsx($Be,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText,onClick:e.onClick,isClickable:e.isClickable},a)))})},QBe=({automationId:e,includeSales:n=!1,includeSms:i=!1,automation:r})=>{const[o,s]=a.useState(!1),{statistics:l,isLoading:u}=oa(e);return u||!l?t.jsx("div",{className:"bg-white rounded-2xl w-full p-6 space-y-4 relative h-[14.05rem]",children:t.jsx(lY,{text:[`Fetching ${lH("engage:insight",{count:2})}`,"Finishing up"]})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bg-white rounded-2xl w-full p-6 flex flex-col gap-6",children:[t.jsxs("section",{children:[t.jsx(t_e,{className:"mb-4",children:lH("engage:emailInsights","Email Insights")}),t.jsx(YBe,{activeTab:"email",statistics:l,automationId:e,onLinkClickStatsOpen:()=>s(!0)})]}),(i||n)&&t.jsx(gEe,{className:"my-2"}),i&&t.jsxs("section",{children:[t.jsx(t_e,{className:"mb-4",children:lH("engage:smsInsights","SMS Insights")}),t.jsx(YBe,{activeTab:"sms",statistics:l})]}),n&&i&&t.jsx(gEe,{className:"my-2"}),n&&t.jsxs("section",{children:[t.jsx(t_e,{className:"mb-4",children:lH("engage:salesInsights","Sales Insights")}),t.jsx(ZBe,{activeTab:"sales",automation:r})]})]}),e&&t.jsx(WBe,{automationId:e,isOpen:o,onClose:()=>s(!1)})]})},XBe=e=>{const{updateAutomation:t,updateError:n,isUpdateSuccess:i}=ra(e),{toast:r}=Ve();return a.useEffect((()=>{i?r({title:"Status updated",description:"The status has been updated successfully"}):n&&r({title:"Error updating status",description:"Please try again",variant:"destructive"})}),[i,n,r]),{toggleStatus:async e=>{try{return await t({status:e?ha.ACTIVE:ha.DRAFT}),!0}catch(a){return r({title:"Error updating status",description:"Please try again",variant:"destructive"}),!1}}}};function eRe(){const{toast:e}=Ve(),[n,i]=a.useState(null),{toggleStatus:r}=XBe(n||""),o=gne(),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{automations:h,nextCursor:p,isLoading:g,error:f,isFetching:v,isPlaceholderData:y}=sa({cursor:u,limit:s,triggerTypes:[ua.TRIGGER_BASED,ua.DATE_BASED],search:d||void 0});a.useEffect((()=>{f&&e({title:`Error Fetching ${lH("engage:automation")}`,description:f?.message||"Please try again.",variant:"destructive"})}),[f,e]);const b=a.useMemo((()=>(h||[]).map((e=>({...e,emailsSent:0,smsSent:0,updated_at:e.updatedAt||e.createdAt})))),[h]),k=a.useCallback((async(e,a)=>{try{i(e);const t=a===ha.ACTIVE;await r(t)}finally{i(null)}}),[r,i]),S=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]),w=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),A=a.useMemo((()=>Iue({automationName:lH("engage:automation"),setUrl:w,onToggle:k,vsaasManaged:!0})),[k,w]);return t.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:t.jsx("div",{className:"flex-grow min-h-0 p-2",children:t.jsx(vte,{data:b,columns:A,paginationMode:"cursor",initialPageSize:s,isLoading:g&&!y,onRowClick:e=>{o(`/automations/view-modal/${e.id}?showBackButton=true`)},cursorPaginationQueryResult:{nextCursor:p,isLoading:g,isFetching:v,isPlaceholderData:y},onQueryParametersChange:S,searchValue:d,onSearchChange:m})})})}function aRe(){const{toast:e}=Ve(),[n,i]=a.useState(!1),[r,o]=a.useState(null),{toggleStatus:s}=XBe(r||""),l=gne(),[u,c]=a.useState(10),[d,m]=a.useState(void 0),[h,p]=a.useState(""),{automations:g,nextCursor:f,isLoading:v,error:y,isFetching:b,isPlaceholderData:k}=sa({cursor:d,limit:u,triggerTypes:[ua.ONE_TIME],search:h||void 0});a.useEffect((()=>{y&&e({title:`Error Fetching ${lH("engage:broadcast")}`,description:y?.message||"Please try again.",variant:"destructive"})}),[y,e]);const S=a.useMemo((()=>(g||[]).map((e=>({...e,updated_at:e.updatedAt})))),[g]),w=a.useCallback((async(e,a)=>{try{o(e);const t=a===ha.ACTIVE;await s(t)}finally{o(null)}}),[s,o]),A=a.useCallback((e=>{m(e.cursor),c(e.pageSize)}),[]),C=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),M=a.useMemo((()=>Iue({automationName:lH("engage:broadcast"),setUrl:C,onToggle:w,pillForStatus:!0})),[w,C]);return t.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[t.jsx("div",{className:"flex-grow min-h-0 p-2",children:t.jsx(vte,{data:S,columns:M,paginationMode:"cursor",initialPageSize:u,headerActions:t.jsxs(H5,{className:"bg-primary",onClick:()=>i(!0),children:[t.jsx(Kz,{className:"h-4 w-4 mr-1"}),"New"]}),isLoading:v&&!k,cursorPaginationQueryResult:{nextCursor:f,isLoading:v,isFetching:b,isPlaceholderData:k},onRowClick:e=>{l(`/automations/view-modal/${e.id}?showBackButton=true`)},onQueryParametersChange:A,searchValue:h,onSearchChange:p})}),t.jsx(oBe,{open:n,setOpen:i,onClose:a=>{jue(i,e,a,`Error creating ${lH("engage:broadcast")}`,"Please try again"),m(void 0),c(10),p(""),!1!==a&&l(`/automations/view-modal/${a}?showBackButton=true`)},automationType:ua.ONE_TIME})]})}function tRe(){const{toast:e}=Ve(),[n,i]=a.useState(!1),[r,o]=a.useState(null),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{segments:h,isLoading:p,nextCursor:g,isFetching:f,isPlaceholderData:v}=T5({search:d||void 0,cursor:u,limit:s}),y=a.useCallback((e=>{o(e),i(!0)}),[o]),b=a.useMemo((()=>function(e){return[Rue("name",`${lH("engage:segment")} Name`,!0),Due(),Pue({accessorKey:"user_count",header:lH("engage:user_other"),meta:{align:"right",displayName:lH("engage:user_other")},cellClassName:"text-muted-foreground pr-4",cellFormatter:e=>{const a=e.getValue()??0;return`${a.toLocaleString()} ${lH("engage:user",{count:a}).toLowerCase()}`}}),zue("updated_at"),Hue(e||(()=>{}))]}(y)),[y]),k=a.useMemo((()=>h?h.map((e=>({...e,updated_at:e.createdAt.toString(),user_count:e.userCount,user_count_updated_at:e.userCountUpdatedAt}))):[]),[h]),S=a.useMemo((()=>t.jsxs(H5,{onClick:()=>{o(null),i(!0)},children:[t.jsx(Kz,{className:"h-4 w-4"}),"New List"]})),[]),w=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]);return t.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[t.jsx("div",{className:"flex-grow min-h-0 p-2",children:t.jsx(vte,{data:k,columns:b,paginationMode:"cursor",initialPageSize:s,headerActions:S,isLoading:p&&!v,cursorPaginationQueryResult:{nextCursor:g,isLoading:p,isFetching:f,isPlaceholderData:v},onQueryParametersChange:w,onRowClick:a=>{if(a.type===P5.CUSTOM)o(a.id),i(!0);else{let t;switch(a.type){case P5.ALL_USERS:t="All users";break;case P5.MANAGED:t="Managed";break;default:throw jre(a.type,P5)}e({title:`${t} ${lH("engage:segment").toLowerCase()} cannot be edited`})}},searchValue:d,onSearchChange:m})}),t.jsx(zLe,{open:n,setOpen:i,segmentId:r??void 0,onSegmentUpdated:a=>{jue(i,e,a,`Error creating ${lH("engage:segment")}`,"Please try again"),c(void 0),l(10),m("")}})]})}const nRe=()=>{const e=ce(),[n,i]=a.useState(!1),r=oR()["show-engage-onboarding"]??!1,[o,s]=a.useState(r),[l,u]=a.useState(null),{automations:c,isLoading:d}=sa({triggerTypes:[ua.TRIGGER_BASED,ua.DATE_BASED]}),[m,h]=a.useState();return a.useEffect((()=>{e.prefetchQuery({queryKey:Be.list()}),e.prefetchQuery({queryKey:C5.lists()})}),[e]),a.useEffect((()=>{if(d||void 0===c)return;const e=[{id:"broadcasts",label:lH("engage:broadcast",{count:2}),content:t.jsx(aRe,{})},{id:"segments",label:lH("engage:segment",{count:2}),content:t.jsx(tRe,{})},{id:"statistics",label:lH("engage:insight",{count:2}),content:t.jsx(QBe,{includeSales:!1,includeSms:!0})}];c.length>0?(u("automations"),h([{id:"automations",label:lH("engage:automation",{count:2}),content:t.jsx(eRe,{})},...e])):(u("broadcasts"),h(e))}),[c,d]),null===l||null==m?t.jsx("div",{className:"w-full h-full flex justify-center items-center",children:t.jsx(lY,{})}):t.jsxs("div",{className:"w-full h-full flex flex-col gap-4",children:[r&&t.jsx(UBe,{open:o,onClose:()=>s(!1),children:t.jsx(JBe,{})}),t.jsx(DBe,{open:n,setOpen:i,children:t.jsx(RBe,{})}),t.jsx("div",{className:"flex justify-end",children:t.jsx(H5,{variant:"outline",onClick:()=>i(!0),children:t.jsx(Vz,{className:"w-4 h-4"})})}),t.jsx("div",{className:"flex-1 w-full h-full flex flex-col gap-4",children:t.jsx(sBe,{activeTab:l,tabs:m,onTabChange:u})})]})};function iRe({open:e,onOpenChange:a}){const n=B5(),{toast:i}=Ve(),{updateAutomation:r,isUpdating:o}=ra(n?.id||""),s=lH(n?.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation");return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:"Archive Automation"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to archive"," ",t.jsxs("span",{className:"font-semibold text-gray-900",children:['"',n?.name,'"']}),"?"]}),t.jsxs("div",{className:"text-sm text-gray-500 bg-amber-50 border border-amber-200 rounded-lg p-3",children:[t.jsx("p",{className:"font-medium text-amber-800 mb-1",children:"What happens when you archive:"}),t.jsxs("ul",{className:"text-amber-700 space-y-1",children:[t.jsx("li",{children:"• The automation will be hidden from your main list"}),t.jsx("li",{children:"• Historical data and settings are preserved"})]})]}),t.jsxs(tY,{className:"gap-2",children:[t.jsx(H5,{variant:"outline",onClick:()=>a(!1),disabled:o,children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:async function(){n?r({status:ha.ARCHIVED},{onSuccess:()=>{i({title:`${s} archived`,description:`"${n.name}" has been successfully archived.`}),a(!1)},onError:()=>{i({title:"Error archiving!",description:"Please contact your administrator.",variant:"destructive"})}}):i({title:"Error archiving automation",description:"Please try again.",variant:"destructive"})},disabled:o,children:o?"Archiving...":"Archive Automation"})]})]})]})})}function rRe({value:e,schema:n,onSubmit:i,fieldName:r,className:o,successMessage:s="Updated successfully",errorMessage:l="Failed to update",placeholderText:u}){const[c,d]=a.useState(!1),[m,h]=a.useState(!1),[p,g]=a.useState(0),[f,v]=a.useState(0),[y,b]=a.useState(e),[k,S]=a.useState(e),w=a.useRef(null),A=a.useRef(null),C=a.useRef(null),M=a.useRef(null),{toast:T}=Ve(),x=yCe({resolver:iMe(n),defaultValues:{[r]:e}});a.useEffect((()=>{x.reset({[r]:e}),b(e),S(e)}),[e,r,x]),a.useEffect((()=>{A.current&&g(A.current.offsetWidth),M.current&&!c&&v(M.current.offsetWidth)}),[c]),a.useEffect((()=>{C.current&&y&&g(C.current.offsetWidth)}),[y]),a.useEffect((()=>{c&&w.current&&(w.current.focus(),w.current.select())}),[c]);const E=async e=>{h(!0);const a=e[r];try{await i(e),S(a),T({variant:"success",title:s}),d(!1)}catch(t){T({variant:"destructive",title:l})}finally{h(!1)}},N=()=>{x.reset(),d(!1),b(k)},_=e=>{"Escape"===e.key&&N()};return c?t.jsx(bCe,{...x,children:t.jsxs("form",{onSubmit:x.handleSubmit(E),className:$Z("inline-flex items-center gap-2 min-h-[20px]",o),style:{minWidth:f?`${f}px`:"auto"},children:[t.jsx("span",{ref:C,className:"absolute invisible whitespace-pre leading-none select-none pointer-events-none",style:{font:"inherit"},children:y||k}),t.jsx(SCe,{control:x.control,name:r,render:({field:e})=>t.jsx(CCe,{className:"flex-1 min-w-0",children:t.jsx(TCe,{children:t.jsx("input",{...e,ref:w,style:{width:`${Math.max(p+40,120)}px`,minWidth:`${Math.max(p,100)}px`,font:"inherit"},className:"bg-transparent outline-none leading-none h-[20px] border-none p-0 m-0",onChange:a=>{e.onChange(a),b(a.target.value)},onKeyDown:_,disabled:m,onBlur:a=>{e.onBlur(),setTimeout((()=>{const e=a.currentTarget.form;e&&!e.contains(document.activeElement)&&N()}),0)}})})})}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.jsx(H5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",onClick:N,disabled:m,children:t.jsx(rO,{className:"h-3 w-3"})}),t.jsx(H5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",disabled:m,onClick:()=>{x.handleSubmit(E)()},children:m?t.jsx(Cz,{className:"h-3 w-3 animate-spin"}):t.jsx(tz,{className:"h-3 w-3"})})]})]})}):t.jsxs("button",{ref:M,type:"button",className:$Z("group relative inline-flex items-center gap-2 cursor-pointer min-h-[20px] bg-transparent border-none p-0 text-left",o),onClick:()=>d(!0),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),d(!0))},"aria-label":"Edit field",children:[t.jsx("span",{ref:A,className:$Z("leading-none select-none",o,{italic:!k}),children:k||u}),t.jsx(Dz,{className:"h-3 w-3 transition-opacity duration-200 flex-shrink-0 opacity-0 group-hover:opacity-100"})]})}function oRe({open:e,onOpenChange:a}){const n=B5(),{toast:i}=Ve(),{updateAutomation:r}=ra(n?.id||""),o=ce();return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:n?.status===ha.SENDING?`Cancel ${lH("engage:automation")}`:`Cancel ${lH("engage:automation")} Before Sending`})}),t.jsx("div",{className:"space-y-4",children:n?t.jsxs(t.Fragment,n.status===ha.SENDING?{children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",t.jsx("span",{className:"font-bold px-1 text-primary",children:n.name}),lH("engage:automation")," as soon as possible."]}),t.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[t.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[t.jsxs("li",{children:["We'll attempt to cancel the"," ",lH("engage:broadcast").toLowerCase()]}),t.jsx("li",{children:"Any messages already in the process of being sent will be delivered"}),t.jsxs("li",{children:["Future ",lH("engage:broadcast").toLowerCase()," messages will be cancelled"]}),t.jsxs("li",{children:["You can create a new ",lH("engage:broadcast").toLowerCase()," if needed"]})]})]})]}:{children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",t.jsx("span",{className:"font-bold px-1 text-primary",children:n.name}),lH("engage:automation")," before it starts sending."]}),t.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[t.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[t.jsx("li",{children:"The automation will be cancelled"}),t.jsx("li",{children:"You can create a new automation if needed"})]})]})]}):null}),t.jsxs(tY,{className:"gap-2 sm:gap-0",children:[t.jsx(H5,{variant:"outline",onClick:()=>a(!1),children:"Continue Running"}),t.jsxs(H5,{variant:"destructive",onClick:()=>{if(!n)return;const e=n.status===ha.SENDING?ha.PARTIALLY_CANCELLED:ha.CANCELLED,t=n.status===ha.SENDING?`Attempting to cancel ${lH("engage:broadcast").toLowerCase()}`:`Successfully cancelled ${lH("engage:broadcast").toLowerCase()}`,s=`Failed to cancel ${lH("engage:broadcast").toLowerCase()}`;r({status:e},{onError:()=>{i({title:s,description:"Please contact your administrator.",variant:"destructive"}),o.invalidateQueries({queryKey:Be.all})},onSuccess:()=>{a(!1),i({title:t,description:n.status===ha.SENDING?`We'll attempt to cancel your ${lH("engage:broadcast").toLowerCase()}. Any messages already in progress will be delivered.`:`Your ${lH("engage:broadcast").toLowerCase()} has been cancelled.`})}})},children:["Cancel ",lH("engage:automation")]})]})]})})}function sRe({open:e,onOpenChange:a,setIsActive:n}){const i=B5(),{updateAutomation:r}=ra(i?.id||""),{toast:o}=Ve(),s=ce(),l=lH(i?.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation"),u=i?.triggerType===ua.ONE_TIME?"Unschedule":`Pause ${l}`;return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:u})}),t.jsxs("div",{children:[i?.triggerType===ua.ONE_TIME?"Are you sure you want to unschedule the":"Are you sure you want to pause the",t.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name})," ",l,"?"]}),t.jsxs(tY,{className:"gap-2 sm:gap-0",children:[t.jsx(H5,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:()=>{r({status:ha.DRAFT},{onSuccess:()=>{o({title:`Updated ${l}`,description:`${l} status updated`}),a(!1),n(!1)},onError:()=>{o({title:`Failed to update ${l}`,description:"Please try again"}),s.invalidateQueries({queryKey:Be.all})}})},children:u})]})]})})}const lRe=ale({name:Ise().min(2,"Title must be at least 2 characters"),description:Ise()});function uRe({open:e,onOpenChange:a,onDuplicationCreated:n}){const i=B5(),{toast:r}=Ve(),o=yCe({resolver:iMe(lRe),defaultValues:{name:`${i?.name} (copy)`,description:i?.description??""}}),{duplicateAutomation:s}=la();return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:"Duplicate Automation"})}),t.jsx(bCe,{...o,children:t.jsxs("form",{onSubmit:o.handleSubmit((async function(e){i&&e.name?s({automationId:i.id,name:e.name,description:e.description},{onSuccess:e=>{e.id&&(n?.(e.id),a(!1))}}):r({title:"Error duplicating automation",description:"Please try again. Please make sure to fill in the name of the automation."})})),className:"space-y-4",children:[t.jsxs("div",{children:["Create a copy of the",t.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name}),"automation with a new title and description."]}),t.jsx(SCe,{control:o.control,name:"name",render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Title"}),t.jsx(TCe,{children:t.jsx(gte,{...e})}),t.jsx(xCe,{})]})}),t.jsx(SCe,{control:o.control,name:"description",render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Description"}),t.jsx(TCe,{children:t.jsx(BLe,{...e})}),t.jsx(xCe,{})]})}),t.jsx(tY,{children:t.jsx(H5,{type:"submit",children:"Duplicate"})})]})})]})})}const cRe=ale({name:Ise().min(2,"Title must be at least 2 characters")}),dRe=ale({description:Ise().max(300,"Description must be less than 300 characters")}),mRe=({showBackButton:e,onDuplicationCreated:n,onBeforeSchedule:i})=>{const r=B5(),o=gne(),{updateAutomation:s}=ra(r?.id||""),{toast:l}=Ve(),u=(()=>{const{state:e}=L5();return e.recipientStats})(),c=R5(),{data:d}=$re(),{channelSenders:m}=Jre(),{channelAccounts:h}=Fre(),p=ce(),[g,f]=a.useState(void 0),[v,y]=a.useState(!1),[b,k]=a.useState(!1),[S,w]=a.useState(!1),[A,C]=a.useState(!1),[M,T]=a.useState(0),[x,E]=a.useState(!1),N=Nle({channelSenders:m?.results??[],channelAccounts:h?.results??[],smsApplication:d});a.useEffect((()=>{if(r)switch(r.status){case ha.DRAFT:f(!1);break;case ha.ACTIVE:case ha.RUNNING:case ha.COMPLETED:f(!0);break;case ha.FAILED:case ha.DEACTIVATED:f(!1);break;case ha.SENDING:case ha.SCHEDULED:f(!0);break;case ha.PARTIALLY_CANCELLED:case ha.CANCELLED:case ha.ARCHIVED:f(!1);break;default:throw jre(r.status,ha)}}),[r]);const _=lH(r?.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation"),P=a.useCallback((()=>{if(!r)return l({title:`${_} not found`,description:"Please contact your administrator",variant:"destructive"}),null;const e=async e=>{if(g&&!e)w(!0);else{if(C(!0),i&&!0===e){let e=0;for(;!u&&e<20;)await new Promise((e=>setTimeout(e,100))),e++;if(!u)return l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),void C(!1);const a=await i({estimatedEmailRecipients:u?.emails??0,estimatedSmsRecipients:u?.phones??0});if(!0!==a)return l({title:"Error while updating the status",description:a,variant:"destructive"}),void C(!1)}if(c?.emailChannelSenderId&&c?.emailHtmlBody&&c?.emailHtmlBody?.includes(YLe)){if(0===M)return l({title:`${QLe}. You can click send again to send anyway.`,variant:"warning"}),T(M+1),void C(!1);T(M+1)}switch(r.triggerType){case ua.ONE_TIME:if(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt)return l({title:"Ensure you have selected a scheduled time",variant:"destructive"}),void C(!1);if(!c||!c.emailChannelSenderId&&!c.smsChannelSenderId)return l({title:"Ensure you have selected at least one kind of communication",variant:"destructive"}),void C(!1);break;case ua.TRIGGER_BASED:case ua.DATE_BASED:break;default:throw jre(r.triggerType,ua)}s({status:e?ha.ACTIVE:ha.DEACTIVATED},{onSuccess:()=>{f(e),l(r.triggerType===ua.ONE_TIME?e?{title:`${_} started!`}:{title:`${_} has been unscheduled`}:{title:`${_} status updated to ${e?"active":"inactive"}`}),C(!1)},onError:()=>{l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),C(!1),p.invalidateQueries({queryKey:Be.all})}})}};if(!r||!c)return null;const a=N.find((e=>e.channelSender.id===c?.smsChannelSenderId)),n=!r.triggerMetadata||null===r.triggerMetadata,o=r.triggerMetadata?.triggerType===ua.ONE_TIME&&!r.triggerMetadata?.scheduledAt,d=!c?.emailChannelSenderId&&!c?.smsChannelSenderId,m=r.triggerType===ua.ONE_TIME,h=m&&a&&a?.smsApplication?.application&&a?.smsApplication?.status!==Ele.APPROVED,v=c?.emailChannelSenderId&&(!c?.emailSubject||!c?.emailHtmlBody),y=c?.smsChannelSenderId&&!c?.smsMessageBody,b=m&&(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt);let k,S=!1,A=!0;switch(r.status){case ha.ACTIVE:S=!1;break;case ha.DRAFT:(d||v||y)&&(S=!0,v&&(k="Missing subject in email communication"),y&&(k="Missing SMS message in SMS communication")),b&&(S=!0),h&&(S=!0);break;case ha.DEACTIVATED:case ha.PARTIALLY_CANCELLED:case ha.CANCELLED:switch(S=!0,A=!1,r.status){case ha.DEACTIVATED:k="Automation is deactivated";break;case ha.PARTIALLY_CANCELLED:k="Automation is partially cancelled";break;case ha.CANCELLED:k="Automation is cancelled";break;default:throw jre(r.status,ha)}break;case ha.RUNNING:S=!0,r.triggerType===ua.TRIGGER_BASED?(k=`Cannot change status of running ${_}`,A=!0):A=r.triggerType===ua.ONE_TIME&&r.status===ha.RUNNING;break;case ha.COMPLETED:S=!0,k=`Cannot change status of completed ${_}`,A=!1;break;case ha.FAILED:S=!0,k=`Cannot change status of failed ${_}`,A=!1;break;case ha.SENDING:case ha.SCHEDULED:S=!1,A=!0;break;case ha.ARCHIVED:S=!0,k=`Cannot change status of archived ${_}`,A=!1;break;default:throw jre(r.status,ha)}const x=(()=>{switch(r.triggerType){case ua.DATE_BASED:case ua.TRIGGER_BASED:return t.jsxs("div",{className:"flex items-center gap-2 w-[12ch] cursor-pointer",children:[t.jsx(g?tz:pz,{className:"w-4 h-4"}),t.jsx("div",{className:"text-[13px] font-medium",children:g?"Active":"Inactive"}),t.jsx(MLe,{checked:g,onCheckedChange:e,disabled:S})]});case ua.ONE_TIME:if((r.status===ha.RUNNING||r.status===ha.SCHEDULED||r.status===ha.SENDING)&&r.triggerType===ua.ONE_TIME)return t.jsx(H5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>E(!0),disabled:!1,children:"Cancel"});if(n||o||d||h||v||y){return t.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:(()=>{const a=r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"===r.triggerMetadata?.scheduledAt?`Start ${_}`:"Schedule Send";if(r.status!==ha.DRAFT&&r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"!==r.triggerMetadata?.scheduledAt&&r.status===ha.ACTIVE)return t.jsx(H5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:S,children:r.triggerType===ua.ONE_TIME?"Unschedule":"Convert to Draft"});const n=[];h&&n.push("The SMS number selected is still not approved"),b&&n.push("Please select a schedule time on the left sidebar"),d&&n.push("Please add at least one sender"),v&&n.push("Please add a subject to your email communication"),y&&n.push("Please add a message to your SMS communication");const i=n.map((e=>{return(a=e)?a.charAt(0).toUpperCase()+a.slice(1):a;var a})),o=`You cannot start this ${lH("engage:broadcast").toLowerCase()} yet. ${i.join(" · ")}`;return t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Fue,{alertText:o,asChild:!1,className:"!cursor-not-allowed",children:t.jsx("div",{className:"px-4 py-2 rounded border border-input bg-background text-muted-foreground cursor-not-allowed text-sm font-medium",children:t.jsx("span",{children:a})})})})})()})}if(!g){let a="Schedule Send";return r.triggerMetadata&&r.triggerMetadata.triggerType===ua.ONE_TIME&&r.triggerMetadata.scheduledAt&&"now"===r.triggerMetadata.scheduledAt&&(a=`Start ${_}`),t.jsx(H5,{variant:"default",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:S,children:a})}return t.jsx(H5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:S,children:r.triggerType===ua.ONE_TIME?"Unschedule":"Convert to Draft"});default:throw jre(r.triggerType,ua)}})();return S&&k&&r.triggerType===ua.TRIGGER_BASED?t.jsx(Fue,{alertText:k,asChild:!0,children:t.jsx("div",{className:"flex items-center gap-2",children:A&&x})}):t.jsx("div",{className:"flex items-center gap-2",children:A&&x})}),[r,c,N,l,g,_,i,s,u,M,p]),j=a.useMemo((()=>r?t.jsx(a6,{variant:Lue(r.status),children:Lre({status:r.status,automationType:r.triggerType})}):null),[r]);return r&&void 0!==g?t.jsxs("header",{className:"flex px-1 pt-1",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e&&t.jsx(H5,{variant:"ghost",size:"icon",onClick:()=>o(-1),children:t.jsx($D,{})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs("div",{className:"flex flex-col gap-0 items-start",children:[t.jsx(rRe,{value:r.name,schema:cRe,onSubmit:e=>{s({name:e.name},{onError:()=>{l({title:`Failed to update ${_} name`,description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Be.all})}})},fieldName:"name",className:"text-lg",successMessage:`${_} name updated`,errorMessage:`Failed to update ${_.toLowerCase()} name`}),r.automationType!==da.MANAGED?t.jsx(rRe,{value:r.description||"",schema:dRe,onSubmit:e=>{s({description:e.description},{onError:()=>{l({title:`Failed to update ${_.toLowerCase()} description`,description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Be.all})}})},fieldName:"description",className:"text-sm "+(r.description?"text-current":"text-muted-foreground"),successMessage:"Description updated",errorMessage:"Failed to update description",placeholderText:`Describe the goal of the ${_.toLowerCase()}`}):r.description&&t.jsx("div",{className:"text-sm text-current",children:r.description})]})})]}),t.jsxs("div",{className:"ml-auto flex gap-4 items-center",children:[t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[j,r.triggerType===ua.ONE_TIME&&t.jsxs(t.Fragment,{children:[t.jsx("div",{role:"button",tabIndex:0,className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 cursor-pointer",onClick:()=>y(!0),children:t.jsx(Fue,{title:"Duplicate",Icon:V5.DuplicateIcon,asChild:!1,onClick:()=>y(!0)})}),r.status===ha.COMPLETED||r.status===ha.DRAFT&&t.jsx("div",{role:"button",tabIndex:0,className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 cursor-pointer",onClick:()=>k(!0),children:t.jsx(Fue,{title:"Archive",Icon:V5.ArchiveIcon,asChild:!1,onClick:()=>k(!0)})})]})]}),t.jsx("div",A?{className:"flex items-center text-muted-foreground pr-2",children:t.jsx(lY,{size:"sm"})}:{className:"flex items-center",children:P()})]}),t.jsx(uRe,{open:v,onOpenChange:y,onDuplicationCreated:n}),t.jsx(sRe,{open:S,onOpenChange:w,setIsActive:f}),t.jsx(oRe,{open:x,onOpenChange:E}),t.jsx(iRe,{open:b,onOpenChange:k})]}):null},hRe=()=>{const e=B5(),{isLoading:n}=oa(e?.id),{state:{hideSales:i,hideSms:r}}=a.useContext(rY);return!e||n?t.jsx(lY,{text:[`Fetching ${lH("engage:insight",{count:2})}`,"Finishing up"]}):t.jsx("div",{className:"h-full p-4",children:t.jsx(QBe,{automationId:e.id,automation:e,includeSales:!i,includeSms:!r})})},pRe=()=>{const e=B5(),[n,i]=a.useState(10),[r,o]=a.useState(void 0),[s,l]=a.useState(""),{sentCommunications:u,isLoading:c,isFetching:d,isPlaceholderData:m,fetchError:h}=na({automationId:e?.id??"",cursor:r,limit:n,search:s||void 0}),p=a.useCallback((e=>{o(e.cursor),i(e.pageSize)}),[]),g=[{accessorKey:"communicationsSent",id:"lastCommunication",header:"Sent At",cell:({row:e})=>e.original.communicationJobCreatedAt?t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"text-sm text-gray-600",children:Eue(new Date(e.original.communicationJobCreatedAt),"MMM d, yyyy h:mm a")})}):t.jsx("span",{className:"text-gray-400",children:"Not available"})},{accessorFn:e=>`${e.firstName||""} ${e.lastName||""}`.trim(),id:"name",header:"Name",cell:({row:e})=>{const a=`${e.original.firstName||""} ${e.original.lastName||""}`.trim();return a||t.jsx("span",{className:"text-gray-400",children:"Not provided"})}},{accessorKey:"email",header:"Email",cell:({row:e})=>e.original.email||t.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"phone",header:"Phone",cell:({row:e})=>e.original.phone?GNe(e.original.phone):t.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"communicationsSent",id:"communicationsSent",header:"Communications Sent",cell:({row:e})=>{const a=e.original.communicationsSent||[],n=a.filter((e=>e.type===pa.EMAIL)),i=a.filter((e=>e.type===pa.SMS)),r=n.length>0,o=i.length>0,s=n.some((e=>e.delivered)),l=i.some((e=>e.delivered)),u=n.find((e=>e.error))?.error,c=i.find((e=>e.error))?.error,d=n.some((e=>e.skipped)),m=i.some((e=>e.skipped)),h=(e,a,n,i)=>t.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsxs("div",{className:"relative",children:[t.jsx("email"===e?V5.EmailIcon:V5.SmsIcon,{className:"h-4 w-4 "+(n?"text-red-500":i?"text-gray-400":a?"text-green-500":"text-gray-400")}),a&&!n&&!i&&t.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white"}),n&&t.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white"}),i&&t.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-gray-400 ring-1 ring-white"})]}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm font-medium",children:"email"===e?"Email":"SMS"}),t.jsx("span",n?{className:"text-xs text-red-500",children:"Failed"}:i?{className:"text-xs text-gray-500",children:"Skipped"}:{className:"text-xs "+(a?"text-green-600":"text-gray-500"),children:a?"Delivered":"Pending"})]})]});return t.jsxs("div",{className:"flex items-center gap-3",children:[r&&(u?t.jsx(Fue,{title:u,children:h("email",s,u,d)}):h("email",s,u,d)),r&&o&&t.jsx("div",{className:"h-8 w-px bg-gray-200"}),o&&(c?t.jsx(Fue,{title:c,children:h("sms",l,c,m)}):h("sms",l,c,m)),!r&&!o&&t.jsx("span",{className:"text-sm text-gray-400",children:"None"})]})}}];return e&&!c&&u?h?t.jsxs("div",{children:["Error: ",h.message]}):!u||!s&&0===u.results.length?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx("div",{className:"mb-4",children:t.jsx(V5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),t.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Communications Sent Yet"}),t.jsxs("p",{className:"text-gray-500",children:["This"," ",lH(e.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation")," ","hasn't sent any communications yet. Please check back later to see recipient details once communications have been sent."]})]}):t.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:t.jsx("div",{className:"flex-grow min-h-0 p-4",children:t.jsx(vte,{data:u?.results||[],columns:g,paginationMode:"cursor",initialPageSize:n,isLoading:c&&!m,cursorPaginationQueryResult:{nextCursor:u?.pagination.cursor||null,isLoading:c,isFetching:d,isPlaceholderData:m},onQueryParametersChange:p,searchValue:s,onSearchChange:l})})}):t.jsx(lY,{text:["Fetching Recipients","Finishing up"]})},gRe=()=>{const e=B5();return e?e?.triggerType===ua.ONE_TIME&&e?.status===ha.DRAFT?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx("div",{className:"mb-4",children:t.jsx(V5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),t.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Recipients Available Yet"}),t.jsxs("p",{className:"text-gray-500",children:["Recipients will be available once this"," ",lH(e.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation")," ","has completed running. Please check back after the automation has finished."]})]}):t.jsx(pRe,{}):t.jsx(lY,{text:["Fetching Recipients","Finishing up"]})},fRe=a.createContext(null);fRe.displayName="PanelGroupContext";const vRe="data-panel-group",yRe="data-panel-group-direction",bRe="data-panel-group-id",kRe="data-panel",SRe="data-panel-collapsible",wRe="data-panel-id",ARe="data-panel-size",CRe="data-resize-handle",MRe="data-resize-handle-active",TRe="data-panel-resize-handle-enabled",xRe="data-panel-resize-handle-id",ERe="data-resize-handle-state",NRe=a.useLayoutEffect,_Re=r["useId".toString()],PRe="function"==typeof _Re?_Re:()=>null;let jRe=0;function LRe(e=null){const t=PRe(),n=a.useRef(e||t||null);return null===n.current&&(n.current=""+jRe++),null!=e?e:n.current}function BRe({children:e,className:t="",collapsedSize:n,collapsible:i,defaultSize:r,forwardedRef:o,id:s,maxSize:l,minSize:u,onCollapse:c,onExpand:d,onResize:m,order:h,style:p,tagName:g="div",...f}){const v=a.useContext(fRe);if(null===v)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:b,getPanelSize:k,getPanelStyle:S,groupId:w,isPanelCollapsed:A,reevaluatePanelConstraints:C,registerPanel:M,resizePanel:T,unregisterPanel:x}=v,E=LRe(s),N=a.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:m},constraints:{collapsedSize:n,collapsible:i,defaultSize:r,maxSize:l,minSize:u},id:E,idIsFromProps:void 0!==s,order:h});a.useRef({didLogMissingDefaultSizeWarning:!1}),NRe((()=>{const{callbacks:e,constraints:a}=N.current,t={...a};N.current.id=E,N.current.idIsFromProps=void 0!==s,N.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=m,a.collapsedSize=n,a.collapsible=i,a.defaultSize=r,a.maxSize=l,a.minSize=u,t.collapsedSize===a.collapsedSize&&t.collapsible===a.collapsible&&t.maxSize===a.maxSize&&t.minSize===a.minSize||C(N.current,t)})),NRe((()=>{const e=N.current;return M(e),()=>{x(e)}}),[h,E,M,x]),a.useImperativeHandle(o,(()=>({collapse:()=>{y(N.current)},expand:e=>{b(N.current,e)},getId:()=>E,getSize:()=>k(N.current),isCollapsed:()=>A(N.current),isExpanded:()=>!A(N.current),resize:e=>{T(N.current,e)}})),[y,b,k,A,E,T]);const _=S(N.current,r);return a.createElement(g,{...f,children:e,className:t,id:E,style:{..._,...p},[bRe]:w,[kRe]:"",[SRe]:i||void 0,[wRe]:E,[ARe]:parseFloat(""+_.flexGrow).toFixed(1)})}const RRe=a.forwardRef(((e,t)=>a.createElement(BRe,{...e,forwardedRef:t})));BRe.displayName="Panel",RRe.displayName="forwardRef(Panel)";let DRe=null,zRe=-1,ORe=null;function KRe(e,a){var t,n;const i=function(e,a){if(a){const e=!!(a&QRe),t=!!(a&XRe);if(a&ZRe)return e?"se-resize":t?"ne-resize":"e-resize";if(a&YRe)return e?"sw-resize":t?"nw-resize":"w-resize";if(e)return"s-resize";if(t)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,a);if(DRe!==i){var r;if(DRe=i,null===ORe&&(ORe=document.createElement("style"),document.head.appendChild(ORe)),zRe>=0)null===(r=ORe.sheet)||void 0===r||r.removeRule(zRe);zRe=null!==(t=null===(n=ORe.sheet)||void 0===n?void 0:n.insertRule(`*{cursor: ${i} !important;}`))&&void 0!==t?t:-1}}function HRe(e){return"keydown"===e.type}function IRe(e){return e.type.startsWith("pointer")}function FRe(e){return e.type.startsWith("mouse")}function GRe(e){if(IRe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(FRe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const VRe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function JRe(e){const a=getComputedStyle(e);return"fixed"===a.position||(!("auto"===a.zIndex||"static"===a.position&&!function(e){var a;const t=getComputedStyle(null!==(a=$Re(e))&&void 0!==a?a:e).display;return"flex"===t||"inline-flex"===t}(e))||(+a.opacity<1||("transform"in a&&"none"!==a.transform||("webkitTransform"in a&&"none"!==a.webkitTransform||("mixBlendMode"in a&&"normal"!==a.mixBlendMode||("filter"in a&&"none"!==a.filter||("webkitFilter"in a&&"none"!==a.webkitFilter||("isolation"in a&&"isolate"===a.isolation||(!!VRe.test(a.willChange)||"touch"===a.webkitOverflowScrolling)))))))))}function URe(e){let a=e.length;for(;a--;){const t=e[a];if(fDe(t,"Missing node"),JRe(t))return t}return null}function WRe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function qRe(e){const a=[];for(;e;)a.push(e),e=$Re(e);return a}function $Re(e){const{parentNode:a}=e;return a&&a instanceof ShadowRoot?a.host:a}const ZRe=1,YRe=2,QRe=4,XRe=8,eDe="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let aDe=[],tDe=!1,nDe=new Map,iDe=new Map;const rDe=new Set;function oDe(e){const{target:a}=e,{x:t,y:n}=GRe(e);tDe=!0,cDe({target:a,x:t,y:n}),pDe(),aDe.length>0&&(gDe("down",e),e.preventDefault(),uDe(a)||e.stopImmediatePropagation())}function sDe(e){const{x:a,y:t}=GRe(e);if(tDe&&0===e.buttons&&(tDe=!1,gDe("up",e)),!tDe){const{target:n}=e;cDe({target:n,x:a,y:t})}gDe("move",e),mDe(),aDe.length>0&&e.preventDefault()}function lDe(e){const{target:a}=e,{x:t,y:n}=GRe(e);iDe.clear(),tDe=!1,aDe.length>0&&(e.preventDefault(),uDe(a)||e.stopImmediatePropagation()),gDe("up",e),cDe({target:a,x:t,y:n}),mDe(),pDe()}function uDe(e){let a=e;for(;a;){if(a.hasAttribute(CRe))return!0;a=a.parentElement}return!1}function cDe({target:e,x:a,y:t}){aDe.splice(0);let n=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(n=e),rDe.forEach((e=>{const{element:i,hitAreaMargins:r}=e,o=i.getBoundingClientRect(),{bottom:s,left:l,right:u,top:c}=o,d=eDe?r.coarse:r.fine;if(a>=l-d&&a<=u+d&&t>=c-d&&t<=s+d){if(null!==n&&document.contains(n)&&i!==n&&!i.contains(n)&&!n.contains(i)&&function(e,a){if(e===a)throw new Error("Cannot compare node with itself");const t={a:qRe(e),b:qRe(a)};let n;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),a=t.b.pop(),n=e;fDe(n,"Stacking order can only be calculated for elements with a common ancestor");const i=WRe(URe(t.a)),r=WRe(URe(t.b));if(i===r){const e=n.childNodes,a={a:t.a.at(-1),b:t.b.at(-1)};let i=e.length;for(;i--;){const t=e[i];if(t===a.a)return 1;if(t===a.b)return-1}}return Math.sign(i-r)}(n,i)>0){let e=n,a=!1;for(;e&&!e.contains(i);){if((m=e.getBoundingClientRect()).x<(h=o).x+h.width&&m.x+m.width>h.x&&m.y<h.y+h.height&&m.y+m.height>h.y){a=!0;break}e=e.parentElement}if(a)return}aDe.push(e)}var m,h}))}function dDe(e,a){iDe.set(e,a)}function mDe(){let e=!1,a=!1;aDe.forEach((t=>{const{direction:n}=t;"horizontal"===n?e=!0:a=!0}));let t=0;iDe.forEach((e=>{t|=e})),e&&a?KRe("intersection",t):e?KRe("horizontal",t):a?KRe("vertical",t):null!==ORe&&(document.head.removeChild(ORe),DRe=null,ORe=null,zRe=-1)}let hDe=new AbortController;function pDe(){hDe.abort(),hDe=new AbortController;const e={capture:!0,signal:hDe.signal};rDe.size&&(tDe?(aDe.length>0&&nDe.forEach(((a,t)=>{const{body:n}=t;a>0&&(n.addEventListener("contextmenu",lDe,e),n.addEventListener("pointerleave",sDe,e),n.addEventListener("pointermove",sDe,e))})),nDe.forEach(((a,t)=>{const{body:n}=t;n.addEventListener("pointerup",lDe,e),n.addEventListener("pointercancel",lDe,e)}))):nDe.forEach(((a,t)=>{const{body:n}=t;a>0&&(n.addEventListener("pointerdown",oDe,e),n.addEventListener("pointermove",sDe,e))})))}function gDe(e,a){rDe.forEach((t=>{const{setResizeHandlerState:n}=t,i=aDe.includes(t);n(e,i,a)}))}function fDe(e,a){if(!e)throw Error(a)}function vDe(e,a,t=10){return e.toFixed(t)===a.toFixed(t)?0:e>a?1:-1}function yDe(e,a,t=10){return 0===vDe(e,a,t)}function bDe(e,a,t){return 0===vDe(e,a,t)}function kDe({panelConstraints:e,panelIndex:a,size:t}){const n=e[a];fDe(null!=n,`Panel constraints not found for index ${a}`);let{collapsedSize:i=0,collapsible:r,maxSize:o=100,minSize:s=0}=n;if(vDe(t,s)<0)if(r){t=vDe(t,(i+s)/2)<0?i:s}else t=s;return t=Math.min(o,t),t=parseFloat(t.toFixed(10))}function SDe({delta:e,initialLayout:a,panelConstraints:t,pivotIndices:n,prevLayout:i,trigger:r}){if(bDe(e,0))return a;const o=[...a],[s,l]=n;fDe(null!=s,"Invalid first pivot index"),fDe(null!=l,"Invalid second pivot index");let u=0;if("keyboard"===r){{const n=e<0?l:s,i=t[n];fDe(i,`Panel constraints not found for index ${n}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const t=a[n];if(fDe(null!=t,`Previous layout not found for panel index ${n}`),bDe(t,r)){const a=u-t;vDe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}{const n=e<0?s:l,i=t[n];fDe(i,`No panel constraints found for index ${n}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const t=a[n];if(fDe(null!=t,`Previous layout not found for panel index ${n}`),bDe(t,u)){const a=t-r;vDe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}}{const n=e<0?1:-1;let i=e<0?l:s,r=0;for(;;){const e=a[i];fDe(null!=e,`Previous layout not found for panel index ${i}`);if(r+=kDe({panelConstraints:t,panelIndex:i,size:100})-e,i+=n,i<0||i>=t.length)break}const o=Math.min(Math.abs(e),Math.abs(r));e=e<0?0-o:o}{let n=e<0?s:l;for(;n>=0&&n<t.length;){const i=Math.abs(e)-Math.abs(u),r=a[n];fDe(null!=r,`Previous layout not found for panel index ${n}`);const s=kDe({panelConstraints:t,panelIndex:n,size:r-i});if(!bDe(r,s)&&(u+=r-s,o[n]=s,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?n--:n++}}if(function(e,a,t){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(!bDe(e[n],a[n],t))return!1;return!0}(i,o))return i;{const n=e<0?l:s,i=a[n];fDe(null!=i,`Previous layout not found for panel index ${n}`);const r=i+u,c=kDe({panelConstraints:t,panelIndex:n,size:r});if(o[n]=c,!bDe(c,r)){let a=r-c;let n=e<0?l:s;for(;n>=0&&n<t.length;){const i=o[n];fDe(null!=i,`Previous layout not found for panel index ${n}`);const r=kDe({panelConstraints:t,panelIndex:n,size:i+a});if(bDe(i,r)||(a-=r-i,o[n]=r),bDe(a,0))break;e>0?n--:n++}}}return bDe(o.reduce(((e,a)=>a+e),0),100)?o:i}function wDe({layout:e,panelsArray:a,pivotIndices:t}){let n=0,i=100,r=0,o=0;const s=t[0];fDe(null!=s,"No pivot index found"),a.forEach(((e,a)=>{const{constraints:t}=e,{maxSize:l=100,minSize:u=0}=t;a===s?(n=u,i=l):(r+=u,o+=l)}));return{valueMax:Math.min(i,100-r),valueMin:Math.max(n,100-o),valueNow:e[s]}}function ADe(e,a=document){return Array.from(a.querySelectorAll(`[${xRe}][data-panel-group-id="${e}"]`))}function CDe(e,a,t=document){const n=ADe(e,t).findIndex((e=>e.getAttribute(xRe)===a));return null!=n?n:null}function MDe(e,a,t){const n=CDe(e,a,t);return null!=n?[n,n+1]:[-1,-1]}function TDe(e,a=document){var t;if(a instanceof HTMLElement&&(null==a||null===(t=a.dataset)||void 0===t?void 0:t.panelGroupId)==e)return a;const n=a.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function xDe(e,a=document){const t=a.querySelector(`[${xRe}="${e}"]`);return t||null}function EDe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:i,panelDataArray:r,panelGroupElement:o,setLayout:s}){a.useRef({didWarnAboutMissingResizeHandle:!1}),NRe((()=>{if(!o)return;const e=ADe(n,o);for(let a=0;a<r.length-1;a++){const{valueMax:t,valueMin:n,valueNow:o}=wDe({layout:i,panelsArray:r,pivotIndices:[a,a+1]}),s=e[a];if(null==s);else{const e=r[a];fDe(e,`No panel data found for index "${a}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(t)),s.setAttribute("aria-valuemin",""+Math.round(n)),s.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach(((e,a)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,i,r,o]),a.useEffect((()=>{if(!o)return;const e=t.current;fDe(e,"Eager values not found");const{panelDataArray:a}=e;fDe(null!=TDe(n,o),`No group found for id "${n}"`);const r=ADe(n,o);fDe(r,`No resize handles found for group id "${n}"`);const l=r.map((e=>{const t=e.getAttribute(xRe);fDe(t,"Resize handle element has no handle id attribute");const[r,l]=function(e,a,t,n=document){var i,r,o,s;const l=xDe(a,n),u=ADe(e,n),c=l?u.indexOf(l):-1;return[null!==(i=null===(r=t[c])||void 0===r?void 0:r.id)&&void 0!==i?i:null,null!==(o=null===(s=t[c+1])||void 0===s?void 0:s.id)&&void 0!==o?o:null]}(n,t,a,o);if(null==r||null==l)return()=>{};const u=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=a.findIndex((e=>e.id===r));if(l>=0){const e=a[l];fDe(e,`No panel data found for index ${l}`);const r=i[l],{collapsedSize:u=0,collapsible:c,minSize:d=0}=e.constraints;if(null!=r&&c){const e=SDe({delta:bDe(r,u)?d-u:u-r,initialLayout:i,panelConstraints:a.map((e=>e.constraints)),pivotIndices:MDe(n,t,o),prevLayout:i,trigger:"keyboard"});i!==e&&s(e)}}break}}};return e.addEventListener("keydown",u),()=>{e.removeEventListener("keydown",u)}}));return()=>{l.forEach((e=>e()))}}),[o,e,t,n,i,r,s])}function NDe(e,a){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==a[t])return!1;return!0}function _De(e,a){const t="horizontal"===e,{x:n,y:i}=GRe(a);return t?n:i}function PDe(e,a,t,n,i,r){if(HRe(e)){const a="horizontal"===t;let n=0;n=e.shiftKey?100:null!=i?i:10;let r=0;switch(e.key){case"ArrowDown":r=a?0:n;break;case"ArrowLeft":r=a?-n:0;break;case"ArrowRight":r=a?n:0;break;case"ArrowUp":r=a?0:-n;break;case"End":r=100;break;case"Home":r=-100}return r}return null==n?0:function(e,a,t,n,i){const r="horizontal"===t,o=xDe(a,i);fDe(o,`No resize handle element found for id "${a}"`);const s=o.getAttribute(bRe);fDe(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=n;const u=_De(t,e),c=TDe(s,i);fDe(c,`No group element found for id "${s}"`);const d=c.getBoundingClientRect();return(u-l)/(r?d.width:d.height)*100}(e,a,t,n,r)}function jDe(e,a,t){a.forEach(((a,n)=>{const i=e[n];fDe(i,`Panel data not found for index ${n}`);const{callbacks:r,constraints:o,id:s}=i,{collapsedSize:l=0,collapsible:u}=o,c=t[s];if(null==c||a!==c){t[s]=a;const{onCollapse:e,onExpand:n,onResize:i}=r;i&&i(a,c),u&&(e||n)&&(!n||null!=c&&!yDe(c,l)||yDe(a,l)||n(),!e||null!=c&&yDe(c,l)||!yDe(a,l)||e())}}))}function LDe(e,a){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=a[t])return!1;return!0}function BDe(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,a)=>{localStorage.setItem(e,a)}}catch(a){e.getItem=()=>null,e.setItem=()=>{}}}function RDe(e){return`react-resizable-panels:${e}`}function DDe(e){return e.map((e=>{const{constraints:a,id:t,idIsFromProps:n,order:i}=e;return n?t:i?`${i}:${JSON.stringify(a)}`:JSON.stringify(a)})).sort(((e,a)=>e.localeCompare(a))).join(",")}function zDe(e,a){try{const t=RDe(e),n=a.getItem(t);if(n){const e=JSON.parse(n);if("object"==typeof e&&null!=e)return e}}catch(t){}return null}function ODe(e,a,t,n,i){var r;const o=RDe(e),s=DDe(a),l=null!==(r=zDe(e,i))&&void 0!==r?r:{};l[s]={expandToSizes:Object.fromEntries(t.entries()),layout:n};try{i.setItem(o,JSON.stringify(l))}catch(u){}}function KDe({layout:e,panelConstraints:a}){const t=[...e],n=t.reduce(((e,a)=>e+a),0);if(t.length!==a.length)throw Error(`Invalid ${a.length} panel layout: ${t.map((e=>`${e}%`)).join(", ")}`);if(!bDe(n,100)&&t.length>0)for(let r=0;r<a.length;r++){const e=t[r];fDe(null!=e,`No layout data found for index ${r}`);t[r]=100/n*e}let i=0;for(let r=0;r<a.length;r++){const e=t[r];fDe(null!=e,`No layout data found for index ${r}`);const n=kDe({panelConstraints:a,panelIndex:r,size:e});e!=n&&(i+=e-n,t[r]=n)}if(!bDe(i,0))for(let r=0;r<a.length;r++){const e=t[r];fDe(null!=e,`No layout data found for index ${r}`);const n=kDe({panelConstraints:a,panelIndex:r,size:e+i});if(e!==n&&(i-=n-e,t[r]=n,bDe(i,0)))break}return t}const HDe={getItem:e=>(BDe(HDe),HDe.getItem(e)),setItem:(e,a)=>{BDe(HDe),HDe.setItem(e,a)}},IDe={};function FDe({autoSaveId:e=null,children:t,className:n="",direction:i,forwardedRef:r,id:o=null,onLayout:s=null,keyboardResizeBy:l=null,storage:u=HDe,style:c,tagName:d="div",...m}){const h=LRe(o),p=a.useRef(null),[g,f]=a.useState(null),[v,y]=a.useState([]),b=function(){const[e,t]=a.useState(0);return a.useCallback((()=>t((e=>e+1))),[])}(),k=a.useRef({}),S=a.useRef(new Map),w=a.useRef(0),A=a.useRef({autoSaveId:e,direction:i,dragState:g,id:h,keyboardResizeBy:l,onLayout:s,storage:u}),C=a.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});a.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),a.useImperativeHandle(r,(()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:a}=A.current,{layout:t,panelDataArray:n}=C.current,i=KDe({layout:e,panelConstraints:n.map((e=>e.constraints))});NDe(t,i)||(y(i),C.current.layout=i,a&&a(i),jDe(n,i,k.current))}})),[]),NRe((()=>{A.current.autoSaveId=e,A.current.direction=i,A.current.dragState=g,A.current.id=h,A.current.onLayout=s,A.current.storage=u})),EDe({committedValuesRef:A,eagerValuesRef:C,groupId:h,layout:v,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),a.useEffect((()=>{const{panelDataArray:a}=C.current;if(e){if(0===v.length||v.length!==a.length)return;let t=IDe[e];null==t&&(t=function(e,a=10){let t=null;return(...n)=>{null!==t&&clearTimeout(t),t=setTimeout((()=>{e(...n)}),a)}}(ODe,100),IDe[e]=t);const n=[...a],i=new Map(S.current);t(e,n,i,v,u)}}),[e,v,u]),a.useEffect((()=>{}));const M=a.useCallback((e=>{const{onLayout:a}=A.current,{layout:t,panelDataArray:n}=C.current;if(e.constraints.collapsible){const i=n.map((e=>e.constraints)),{collapsedSize:r=0,panelSize:o,pivotIndices:s}=JDe(n,e,t);if(fDe(null!=o,`Panel size not found for panel "${e.id}"`),!yDe(o,r)){S.current.set(e.id,o);const l=SDe({delta:VDe(n,e)===n.length-1?o-r:r-o,initialLayout:t,panelConstraints:i,pivotIndices:s,prevLayout:t,trigger:"imperative-api"});LDe(t,l)||(y(l),C.current.layout=l,a&&a(l),jDe(n,l,k.current))}}}),[]),T=a.useCallback(((e,a)=>{const{onLayout:t}=A.current,{layout:n,panelDataArray:i}=C.current;if(e.constraints.collapsible){const r=i.map((e=>e.constraints)),{collapsedSize:o=0,panelSize:s=0,minSize:l=0,pivotIndices:u}=JDe(i,e,n),c=null!=a?a:l;if(yDe(s,o)){const a=S.current.get(e.id),o=null!=a&&a>=c?a:c,l=SDe({delta:VDe(i,e)===i.length-1?s-o:o-s,initialLayout:n,panelConstraints:r,pivotIndices:u,prevLayout:n,trigger:"imperative-api"});LDe(n,l)||(y(l),C.current.layout=l,t&&t(l),jDe(i,l,k.current))}}}),[]),x=a.useCallback((e=>{const{layout:a,panelDataArray:t}=C.current,{panelSize:n}=JDe(t,e,a);return fDe(null!=n,`Panel size not found for panel "${e.id}"`),n}),[]),E=a.useCallback(((e,a)=>{const{panelDataArray:t}=C.current,n=VDe(t,e);return function({defaultSize:e,dragState:a,layout:t,panelData:n,panelIndex:i,precision:r=3}){const o=t[i];let s;return s=null==o?null!=e?e.toPrecision(r):"1":1===n.length?"1":o.toPrecision(r),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==a?"none":void 0}}({defaultSize:a,dragState:g,layout:v,panelData:t,panelIndex:n})}),[g,v]),N=a.useCallback((e=>{const{layout:a,panelDataArray:t}=C.current,{collapsedSize:n=0,collapsible:i,panelSize:r}=JDe(t,e,a);return fDe(null!=r,`Panel size not found for panel "${e.id}"`),!0===i&&yDe(r,n)}),[]),_=a.useCallback((e=>{const{layout:a,panelDataArray:t}=C.current,{collapsedSize:n=0,collapsible:i,panelSize:r}=JDe(t,e,a);return fDe(null!=r,`Panel size not found for panel "${e.id}"`),!i||vDe(r,n)>0}),[]),P=a.useCallback((e=>{const{panelDataArray:a}=C.current;a.push(e),a.sort(((e,a)=>{const t=e.order,n=a.order;return null==t&&null==n?0:null==t?-1:null==n?1:t-n})),C.current.panelDataArrayChanged=!0,b()}),[b]);NRe((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:a,storage:t}=A.current,{layout:n,panelDataArray:i}=C.current;let r=null;if(e){const a=function(e,a,t){var n,i;return null!==(i=(null!==(n=zDe(e,t))&&void 0!==n?n:{})[DDe(a)])&&void 0!==i?i:null}(e,i,t);a&&(S.current=new Map(Object.entries(a.expandToSizes)),r=a.layout)}null==r&&(r=function({panelDataArray:e}){const a=Array(e.length),t=e.map((e=>e.constraints));let n=0,i=100;for(let r=0;r<e.length;r++){const e=t[r];fDe(e,`Panel constraints not found for index ${r}`);const{defaultSize:o}=e;null!=o&&(n++,a[r]=o,i-=o)}for(let r=0;r<e.length;r++){const o=t[r];fDe(o,`Panel constraints not found for index ${r}`);const{defaultSize:s}=o;if(null!=s)continue;const l=i/(e.length-n);n++,a[r]=l,i-=l}return a}({panelDataArray:i}));const o=KDe({layout:r,panelConstraints:i.map((e=>e.constraints))});NDe(n,o)||(y(o),C.current.layout=o,a&&a(o),jDe(i,o,k.current))}})),NRe((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const j=a.useCallback((e=>{let a=!1;const t=p.current;if(t){"rtl"===window.getComputedStyle(t,null).getPropertyValue("direction")&&(a=!0)}return function(t){t.preventDefault();const n=p.current;if(!n)return()=>null;const{direction:i,dragState:r,id:o,keyboardResizeBy:s,onLayout:l}=A.current,{layout:u,panelDataArray:c}=C.current,{initialLayout:d}=null!=r?r:{},m=MDe(o,e,n);let h=PDe(t,e,i,r,s,n);const g="horizontal"===i;g&&a&&(h=-h);const f=SDe({delta:h,initialLayout:null!=d?d:u,panelConstraints:c.map((e=>e.constraints)),pivotIndices:m,prevLayout:u,trigger:HRe(t)?"keyboard":"mouse-or-touch"}),v=!LDe(u,f);(IRe(t)||FRe(t))&&w.current!=h&&(w.current=h,dDe(e,v||0===h?0:g?h<0?ZRe:YRe:h<0?QRe:XRe)),v&&(y(f),C.current.layout=f,l&&l(f),jDe(c,f,k.current))}}),[]),L=a.useCallback(((e,a)=>{const{onLayout:t}=A.current,{layout:n,panelDataArray:i}=C.current,r=i.map((e=>e.constraints)),{panelSize:o,pivotIndices:s}=JDe(i,e,n);fDe(null!=o,`Panel size not found for panel "${e.id}"`);const l=SDe({delta:VDe(i,e)===i.length-1?o-a:a-o,initialLayout:n,panelConstraints:r,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});LDe(n,l)||(y(l),C.current.layout=l,t&&t(l),jDe(i,l,k.current))}),[]),B=a.useCallback(((e,a)=>{const{layout:t,panelDataArray:n}=C.current,{collapsedSize:i=0,collapsible:r}=a,{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:u=0}=e.constraints,{panelSize:c}=JDe(n,e,t);null!=c&&(r&&s&&yDe(c,i)?yDe(i,o)||L(e,o):c<u?L(e,u):c>l&&L(e,l))}),[L]),R=a.useCallback(((e,a)=>{const{direction:t}=A.current,{layout:n}=C.current;if(!p.current)return;const i=xDe(e,p.current);fDe(i,`Drag handle element not found for id "${e}"`);const r=_De(t,a);f({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:r,initialLayout:n})}),[]),D=a.useCallback((()=>{f(null)}),[]),z=a.useCallback((e=>{const{panelDataArray:a}=C.current,t=VDe(a,e);t>=0&&(a.splice(t,1),delete k.current[e.id],C.current.panelDataArrayChanged=!0,b())}),[b]),O=a.useMemo((()=>({collapsePanel:M,direction:i,dragState:g,expandPanel:T,getPanelSize:x,getPanelStyle:E,groupId:h,isPanelCollapsed:N,isPanelExpanded:_,reevaluatePanelConstraints:B,registerPanel:P,registerResizeHandle:j,resizePanel:L,startDragging:R,stopDragging:D,unregisterPanel:z,panelGroupElement:p.current})),[M,g,i,T,x,E,h,N,_,B,P,j,L,R,D,z]);return a.createElement(fRe.Provider,{value:O},a.createElement(d,{...m,children:t,className:n,id:o,ref:p,style:{...{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%"},...c},[vRe]:"",[yRe]:i,[bRe]:h}))}const GDe=a.forwardRef(((e,t)=>a.createElement(FDe,{...e,forwardedRef:t})));function VDe(e,a){return e.findIndex((e=>e===a||e.id===a.id))}function JDe(e,a,t){const n=VDe(e,a);return{...a.constraints,panelSize:t[n],pivotIndices:n===e.length-1?[n-1,n]:[n,n+1]}}function UDe({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:i,id:r,onBlur:o,onClick:s,onDragging:l,onFocus:u,onPointerDown:c,onPointerUp:d,style:m={},tabIndex:h=0,tagName:p="div",...g}){var f,v;const y=a.useRef(null),b=a.useRef({onClick:s,onDragging:l,onPointerDown:c,onPointerUp:d});a.useEffect((()=>{b.current.onClick=s,b.current.onDragging=l,b.current.onPointerDown=c,b.current.onPointerUp=d}));const k=a.useContext(fRe);if(null===k)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:w,registerResizeHandle:A,startDragging:C,stopDragging:M,panelGroupElement:T}=k,x=LRe(r),[E,N]=a.useState("inactive"),[_,P]=a.useState(!1),[j,L]=a.useState(null),B=a.useRef({state:E});NRe((()=>{B.current.state=E})),a.useEffect((()=>{if(n)L(null);else{const e=A(x);L((()=>e))}}),[n,x,A]);const R=null!==(f=null==i?void 0:i.coarse)&&void 0!==f?f:15,D=null!==(v=null==i?void 0:i.fine)&&void 0!==v?v:5;a.useEffect((()=>{if(n||null==j)return;const e=y.current;fDe(e,"Element ref not attached");let a=!1;return function(e,a,t,n,i){var r;const{ownerDocument:o}=a,s={direction:t,element:a,hitAreaMargins:n,setResizeHandlerState:i},l=null!==(r=nDe.get(o))&&void 0!==r?r:0;return nDe.set(o,l+1),rDe.add(s),pDe(),function(){var a;iDe.delete(e),rDe.delete(s);const t=null!==(a=nDe.get(o))&&void 0!==a?a:1;if(nDe.set(o,t-1),pDe(),1===t&&nDe.delete(o),aDe.includes(s)){const e=aDe.indexOf(s);e>=0&&aDe.splice(e,1),mDe(),i("up",!0,null)}}}(x,e,S,{coarse:R,fine:D},((e,t,n)=>{if(t)switch(e){case"down":{N("drag"),a=!1,fDe(n,'Expected event to be defined for "down" action'),C(x,n);const{onDragging:e,onPointerDown:t}=b.current;null==e||e(!0),null==t||t();break}case"move":{const{state:e}=B.current;a=!0,"drag"!==e&&N("hover"),fDe(n,'Expected event to be defined for "move" action'),j(n);break}case"up":{N("hover"),M();const{onClick:e,onDragging:t,onPointerUp:n}=b.current;null==t||t(!1),null==n||n(),a||null==e||e();break}}else N("inactive")}))}),[R,S,n,D,A,x,j,C,M]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:i}){a.useEffect((()=>{if(e||null==n||null==i)return;const a=xDe(t,i);if(null==a)return;const r=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=a.getAttribute(bRe);fDe(n,`No group element found for id "${n}"`);const r=ADe(n,i),o=CDe(n,t,i);fDe(null!==o,`No resize element found for id "${t}"`),r[e.shiftKey?o>0?o-1:r.length-1:o+1<r.length?o+1:0].focus();break}}};return a.addEventListener("keydown",r),()=>{a.removeEventListener("keydown",r)}}),[i,e,t,n])}({disabled:n,handleId:x,resizeHandler:j,panelGroupElement:T});return a.createElement(p,{...g,children:e,className:t,id:r,onBlur:()=>{P(!1),null==o||o()},onFocus:()=>{P(!0),null==u||u()},ref:y,role:"separator",style:{touchAction:"none",userSelect:"none",...m},tabIndex:h,[yRe]:S,[bRe]:w,[CRe]:"",[MRe]:"drag"===E?"pointer":_?"keyboard":void 0,[TRe]:!n,[xRe]:x,[ERe]:E})}FDe.displayName="PanelGroup",GDe.displayName="forwardRef(PanelGroup)",UDe.displayName="PanelResizeHandle";const WDe=({className:e,...a})=>t.jsx(GDe,{className:$Z("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),qDe=RRe,$De=({withHandle:e,className:a,...n})=>t.jsx(UDe,{className:$Z("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...n,children:e&&t.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsx(kz,{className:"h-2.5 w-2.5"})})}),ZDe=({copyText:e})=>t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),YDe="rgba(245, 246, 247, 1)",QDe={[ma.SEND_COMMUNICATION]:{color:{bg:YDe},clickable:!0},[ma.WAIT_UNTIL_NEXT_FIXED_TIME]:{color:{bg:YDe},clickable:!1}},XDe={[ma.SEND_COMMUNICATION]:"Send Email & SMS",[ma.WAIT_UNTIL_NEXT_FIXED_TIME]:"Wait"},eze=({children:e,onClick:a,iconBgColor:n,iconStrokeColor:i,Icon:r,disabled:o=!1,selected:s=!1})=>{const l=r;return t.jsxs(o5.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},style:{backgroundColor:s?n:YDe},onClick:a,className:XO("flex gap-2 items-center rounded-md transition-colors group","p-2 border-2 border-transparent overflow-hidden",!o&&"hover:border-primary cursor-pointer",s&&"border-primary"),children:[t.jsx("div",{className:XO("bg-purple-50 rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 transition-colors",!o&&"group-hover/trigger-audience:bg-background",n),children:t.jsx(l,{className:XO("w-4 h-4 stroke-purple-500 group-hover/trigger-audience:fill-purple-50 transition-colors",i)})}),e]})},aze=({segmentName:e})=>t.jsx("span",{className:"inline-flex items-center bg-white border border-gray-200 rounded-md px-2 py-0.5 text-sm font-medium shadow-sm",children:e}),tze=()=>{const e=B5(),{setActionId:n,state:{selectedActionId:i}}=a.useContext(S5),[r,o]=a.useState(e?.includeSegmentIds||null),[s,l]=a.useState(e?.excludeSegmentIds||null),{segments:u}=T5(),c=a.useCallback((()=>u?.find((e=>e.type===P5.ALL_USERS))),[u]);return a.useEffect((()=>{e&&u&&(null===r&&null===s?(o(e?.includeSegmentIds||null),l(e?.excludeSegmentIds||null),0===e.includeSegmentIds.length&&0===e.excludeSegmentIds.length&&(o([c()?.id||""]),l([]))):(JSON.stringify(e.includeSegmentIds)!==JSON.stringify(r)&&o(e.includeSegmentIds),JSON.stringify(e.excludeSegmentIds)!==JSON.stringify(s)&&l(e.excludeSegmentIds)))}),[e,s,r,u,c]),e&&r&&s?t.jsx(t.Fragment,{children:t.jsx(eze,{selected:i===Gwe.EditAudience,iconBgColor:"bg-purple-50",iconStrokeColor:"stroke-purple-500",onClick:()=>{n(Gwe.EditAudience)},Icon:V5.AudienceIcon,children:t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:"Audience"}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ZDe,{copyText:`Send to all ${lH("engage:user",{count:2})} in ${1===r.length?"this":"these"} ${lH("engage:segment",{count:r.length}).toLowerCase()}`}),t.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map((e=>{const a=u?.find((a=>a.id===e));return a?t.jsx(aze,{segmentName:a.name},e):null}))})]})]})})}):null},nze=()=>{const e=B5(),{setActionId:n,state:{selectedActionId:i}}=a.useContext(S5),{segments:r}=T5(),o=lH(e?.triggerType===ua.TRIGGER_BASED?"engage:automation":"engage:broadcast"),s=`Start this ${o?.toLowerCase()}`,l=`Start this ${lH("engage:automation").toLowerCase()}`;if(!e||!r)return null;return t.jsx(t.Fragment,{children:(()=>{switch(e.triggerType){case ua.DATE_BASED:{if(!e.triggerMetadata||!("monthToTrigger"in e.triggerMetadata)||!("dayToTrigger"in e.triggerMetadata))return null;const a=e.triggerMetadata?.monthToTrigger,n=e.triggerMetadata?.dayToTrigger;let i="Date not set";if(a&&n){i=`${new Date(2024,a-1,n).toLocaleDateString("en-US",{month:"long"})} ${n}`}return t.jsx(eze,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:V5.TriggerIcon,children:t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:l}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.jsx(ZDe,{copyText:e.triggerMetadata.customTriggerCopy??`Every year on ${i}`})})]})})}case ua.TRIGGER_BASED:{if(e.triggerMetadata&&e.triggerMetadata.triggerType!==ua.TRIGGER_BASED||!e.triggerMetadata||e.triggerMetadata.eventName!==ca.USER_ENTERS_SEGMENT||!e.triggerMetadata.eventFilter.segment_id)return null;const a=e.triggerMetadata.eventFilter.segment_id,n=r.find((e=>e.id===a))?.name;return n?t.jsx(eze,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:V5.TriggerIcon,children:t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:s}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.triggerMetadata.customTriggerCopy?t.jsx(ZDe,{copyText:e.triggerMetadata.customTriggerCopy}):t.jsxs(t.Fragment,{children:[t.jsx(ZDe,{copyText:`When ${lH("engage:user").toLowerCase()} joins the`}),t.jsx(aze,{segmentName:n})]})})]})}):null}case ua.ONE_TIME:{const a=!e.triggerMetadata||!("scheduledAt"in e.triggerMetadata);return t.jsxs(eze,{iconBgColor:"bg-amber-100",iconStrokeColor:"stroke-amber-500",onClick:()=>{n(Gwe.EditTime)},selected:i===Gwe.EditTime,Icon:V5.TriggerIcon,children:[t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:s}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ZDe,a?{copyText:`Click to set the date and time for this ${lH("engage:broadcast")}`}:{copyText:"Bulk send at"}),!1===a&&e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&e.triggerMetadata.scheduledAt&&t.jsx("div",{className:"text-xs font-medium",children:t.jsx(aze,{segmentName:"now"===e.triggerMetadata.scheduledAt?"immediately":Eue(new Date(e.triggerMetadata.scheduledAt),"h:mma MM/dd/yy")})})]})]}),t.jsx("div",{className:"",children:a&&t.jsx(Fue,{title:`Please select a time before sending this ${lH("engage:broadcast")}.`,alertText:`A scheduled time is needed before sending this ${lH("engage:broadcast")}.`,Icon:V5.AlertTriangleIcon,iconColor:"text-red-500",size:"large"})})]})}default:throw jre(e.triggerType,ua)}})()})};var ize=r.forwardRef(((e,a)=>{const{children:n,...i}=e,o=r.Children.toArray(n),s=o.find(sze);if(s){const e=s.props.children,n=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(rze,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,n):null})}return t.jsx(rze,{...i,ref:a,children:n})}));ize.displayName="Slot";var rze=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?IZ(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));rze.displayName="SlotClone";var oze=({children:e})=>t.jsx(t.Fragment,{children:e});function sze(e){return r.isValidElement(e)&&e.type===oze}var lze=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const n=r.forwardRef(((e,n)=>{const{asChild:i,...r}=e,o=i?ize:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(o,{...r,ref:n})}));return n.displayName=`Primitive.${a}`,{...e,[a]:n}}),{}),uze=r.forwardRef(((e,a)=>{const{pressed:n,defaultPressed:i=!1,onPressedChange:r,...o}=e,[s=!1,l]=m9({prop:n,onChange:r,defaultProp:i});return t.jsx(lze.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...o,ref:a,onClick:l9(e.onClick,(()=>{e.disabled||l(!s)}))})}));uze.displayName="Toggle";var cze=uze;const dze=GD("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),mze=r.forwardRef((({className:e,variant:a,size:n,...i},r)=>t.jsx(cze,{ref:r,className:$Z(dze({variant:a,size:n,className:e})),...i})));mze.displayName=cze.displayName;const hze=({type:e,disabled:n=!1,actionId:i})=>{const{state:{selectedSubStepType:r},setSelectedSubStepType:o,setActionId:s}=a.useContext(S5),l=R5(),{updateCommunicationGroup:u,isUpdating:c}=Ye(),{channelSenders:d}=Jre(),{channelAccounts:m}=Fre(),{data:h}=$re(),{toast:p}=Ve(),{getMergeFields:g,isGetting:f}=Qe(l?.id??void 0),v=r===e,y=a.useMemo((()=>d?.results?.filter((e=>e.channelSenderMetadata.userPart))||[]),[d?.results]),b=a.useMemo((()=>Nle({channelSenders:d?.results??[],channelAccounts:m?.results??[],smsApplication:h})),[d?.results,m?.results,h]),k=a.useCallback((()=>{if(!l)return!1;switch(e){case Vwe.EMAIL:return!!l.emailChannelSenderId;case Vwe.SMS:return!!l.smsChannelSenderId}}),[l,e])(),S=a.useMemo((()=>{if(!l)return!1;return 1===[!!l.emailChannelSenderId,!!l.smsChannelSenderId].filter(Boolean).length&&k}),[l,k]),w=a.useCallback((async()=>{if(l?.id&&!c)if(k&&S)p({title:"Cannot disable channel",description:"At least one channel must remain enabled",variant:"destructive"});else try{const a={};switch(e){case Vwe.EMAIL:if(k&&l.emailChannelSenderId)a.emailChannelSenderId=null;else{const e=y[0];e&&(a.emailChannelSenderId=e.id)}break;case Vwe.SMS:if(k&&l.smsChannelSenderId)a.smsChannelSenderId=null;else{const e=b[0];e&&(a.smsChannelSenderId=e.channelSender.id)}}await u({groupId:l.id,params:a})}catch(a){}}),[l,k,e,u,c,y,b,p,S]),A=a.useCallback((()=>{if(!l)return"Need to select a channel";switch(e){case Vwe.EMAIL:return l.emailChannelSenderId?l.emailHtmlBody?!!l.emailSubject||"Please add a subject to the email":"Please add content to the email":"Please select a email sender";case Vwe.SMS:return l.smsChannelSenderId?!!l.smsMessageBody||"Please add content to the sms":"Please select a sms sender"}}),[l,e])();return t.jsxs(o5.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15,ease:"easeInOut"},className:XO("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group","border-2 border-transparent",v&&"border-primary",!n&&"hover:border-muted-foreground/30",n&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:v?"#f5f6f7":YDe},onClick:a=>{a.target.closest("button")||n||(s(i),o(e))},children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("div",{className:"rounded-md p-1.5 flex items-center justify-center w-6 h-6 flex-shrink-0 bg-white border",children:((e,a)=>{switch(e){case Vwe.EMAIL:return t.jsx(V5.EmailIcon,{className:XO("w-6 h-6",a?"text-primary":"text-gray-400")});case Vwe.SMS:return t.jsx(V5.SmsIcon,{className:XO("w-6 h-6",a?"text-primary":"text-gray-400")})}})(e,v)}),t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("div",{style:{color:v?"#3b82f6":"#64748b"},children:t.jsx(i_e,{className:"text-xs",children:(()=>{switch(e){case Vwe.EMAIL:return"Email";case Vwe.SMS:return"SMS"}})()})}),k&&t.jsx("div",{className:"text-[10px] font-medium text-muted-foreground",children:e===Vwe.EMAIL?f?t.jsx("span",{className:"text-[10px] font-medium text-muted-foreground",children:"..."}):t.jsx(VMe,{content:l?.emailSubject||"No subject set",mergeFieldsResponse:g,variant:"minimal",className:"text-[10px] font-medium text-muted-foreground"}):f?t.jsx("span",{className:"text-[10px] font-medium text-muted-foreground",children:"..."}):t.jsx(VMe,{content:l?.smsMessageBody?`${l.smsMessageBody.substring(0,40)}${l.smsMessageBody.length>40?"...":""}`:"No message set",mergeFieldsResponse:g,variant:"minimal",className:"text-[10px] font-medium text-muted-foreground"})}),!0!==A&&k&&t.jsx("div",{className:"text-[10px] text-amber-600 font-medium",children:A}),!k&&t.jsx("div",{className:"text-[10px] text-muted-foreground/70 font-medium italic",children:"Channel disabled"})]})]}),t.jsx("div",{className:"ml-auto",onClick:e=>{e.stopPropagation()},children:t.jsx(mze,{pressed:k,onPressedChange:()=>{c||k&&S||w()},disabled:c||k&&S||n,size:"sm",children:t.jsx(wY,{mode:"wait",initial:!1,children:k?t.jsx(o5.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.18,ease:"easeInOut"},className:"flex",children:t.jsx(tz,{className:"h-4 w-4 text-muted-foreground"})},"check"):t.jsx(o5.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.18,ease:"easeInOut"},className:"flex",children:t.jsx(rO,{className:"h-4 w-4 text-muted-foreground"})},"x")})})})]})},pze=e=>{switch(e){case ma.SEND_COMMUNICATION:return"Send Communication";case ma.WAIT_UNTIL_NEXT_FIXED_TIME:return"Wait";default:throw g5(e,ma)}},gze=e=>{switch(e){case ma.SEND_COMMUNICATION:return t.jsx(V5.CommunicationIcon,{className:"w-4 h-4"});case ma.WAIT_UNTIL_NEXT_FIXED_TIME:return t.jsx(V5.WaitUntilNextFixedTimeIcon,{className:"w-4 h-4"});default:throw jre(e,ma)}},fze=e=>{if(!(e&&e.actionType===ma.WAIT_UNTIL_NEXT_FIXED_TIME&&"hour"in e&&"minute"in e&&"timezone"in e))return null;const{hour:a,minute:t,timezone:n}=e;return`Wait until next ${`${a?.toString().padStart(2,"0")}:${t?.toString().padStart(2,"0")}`} ${n}`},vze=({actionDataWithMetadata:e})=>{const{actionData:n}=e,{state:{selectedActionId:i},setActionId:r,setSelectedCommunicationGroupId:o}=a.useContext(S5),s=a.useMemo((()=>i===n.actionMetadata.currentActionId),[i,n.actionMetadata.currentActionId]),l=QDe[n.actionType],u=l.color,c=l.clickable;return t.jsxs(o5.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},className:XO("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group"," border-2 border-transparent",s&&"border-primary",n.actionType!==ma.WAIT_UNTIL_NEXT_FIXED_TIME&&"hover:border-primary"),style:{backgroundColor:s?u.bg:u.bgUnselected??YDe},onClick:()=>{c&&(r(n.actionMetadata.currentActionId),n.actionType===ma.SEND_COMMUNICATION&&o(n.actionMetadata.communicationGroupId))},children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("div",{className:"rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 bg-white",children:gze(n.actionType)}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{style:{color:s?u.text:u.textUnselected},children:t.jsx(i_e,{children:XDe[n.actionType]})}),t.jsx("div",n.actionType===ma.WAIT_UNTIL_NEXT_FIXED_TIME?{className:"text-[11px] text-muted-foreground font-normal rounded bg-muted/40 w-fit max-w-full truncate",children:fze(n.actionMetadata)}:{className:"text-xs font-medium text-muted-foreground",children:pze(n.actionType)})]})]}),n.actionType===ma.SEND_COMMUNICATION&&t.jsx("div",{className:"flex items-center pr-2",children:t.jsx(V5.NextButton,s?{className:"w-4 h-4 text-muted-foreground rotate-90 transition-transform duration-200"}:{className:"w-4 h-4 text-muted-foreground transition-transform duration-200"})})]})},yze=()=>{const e=R5(),[n,i]=a.useState(!1),[r,o]=a.useState(void 0),{segments:s}=T5(),l=B5(),{setActionId:u,setSelectedSubStepType:c,state:{selectedActionId:d,selectedSubStepType:m}}=a.useContext(S5);ra(l?.id||""),a.useEffect((()=>{if(!l)return;if(d)return;const e=l.actionData?.find((e=>e.actionType===ma.SEND_COMMUNICATION));e&&u(e.actionMetadata.currentActionId)}),[l,u,d]),a.useEffect((()=>{if(!l)return;(async()=>{const e=[];for(const a of l.actionData??[])switch(a.actionType){case ma.SEND_COMMUNICATION:{const t=await Je(a.actionMetadata.communicationGroupId);e.push({actionData:a,communicationGroup:t});break}case ma.WAIT_UNTIL_NEXT_FIXED_TIME:e.push({actionData:a});break;default:throw g5(a.actionType,ma)}o(e)})()}),[l]),a.useEffect((()=>{if(d&&r&&e&&null===m){const a=r.find((e=>e.actionData.actionMetadata.currentActionId===d));a?.actionData.actionType===ma.SEND_COMMUNICATION&&c(e?.emailChannelSenderId?Vwe.EMAIL:Vwe.SMS)}}),[d,r,c,e,m]);if(!l||!r||l?.triggerType===ua.TRIGGER_BASED&&void 0===s)return null;const h=(e=>{const{steps:a,rootActionId:t}=e;if(!a||!t)return a??[];const n=new Map(a.map((e=>[e.actionData.actionMetadata.currentActionId,e]))),i=n.get(t);if(!i)return a;const r=[];let o=i;for(;o;){r.push(o);const e=o.actionData.actionMetadata.nextActionId;if(!e)break;o=n.get(e)}return r})({steps:r,rootActionId:l.triggerMetadata?.triggerType===ua.TRIGGER_BASED?l.triggerMetadata.rootActionId:void 0}).filter((e=>!!n||e.actionData.actionType===ma.SEND_COMMUNICATION));let p=()=>t.jsx("div",{},"empty-trigger-audience");return(n||l.triggerType===ua.ONE_TIME)&&(p=()=>t.jsxs("div",{className:"flex flex-col gap-3",children:[l.triggerType===ua.ONE_TIME&&t.jsx(tze,{}),l.triggerType!==ua.ONE_TIME&&t.jsx(nze,{})]})),t.jsxs("div",{className:"flex-1 flex flex-col gap-2 w-full overflow-visible",children:[(l.triggerType===ua.TRIGGER_BASED||l.triggerType===ua.DATE_BASED)&&t.jsxs("div",{className:"flex gap-2 items-center justify-between",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Messages sent in listed order"}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("div",{className:"text-sm font-medium",children:"Show all details"}),t.jsx(MLe,{defaultChecked:n,onCheckedChange:()=>{i(!n)}})]})]}),t.jsx("div",{className:"flex-1 flex flex-col gap-3",children:t.jsxs(wY,{mode:"popLayout",children:[p(),h.map(((e,a)=>t.jsx(o5.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*a,ease:"easeInOut"},children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(vze,{actionDataWithMetadata:e}),e.actionData.actionType===ma.SEND_COMMUNICATION&&d===e.actionData.actionMetadata.currentActionId&&e.actionData.actionMetadata.currentActionId&&t.jsxs("div",{className:"flex gap-3",children:[t.jsx(o5.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,delay:.25*h.length,ease:"easeInOut"},className:"w-12 flex justify-end items-center",children:t.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full rounded-full"})}),t.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[t.jsx(hze,{type:Vwe.EMAIL,actionId:e.actionData.actionMetadata.currentActionId,disabled:l.status!==ha.DRAFT}),t.jsx(hze,{type:Vwe.SMS,actionId:e.actionData.actionMetadata.currentActionId,disabled:l.status!==ha.DRAFT})]})]})]})},e.actionData.actionMetadata?.currentActionId??a))),l.triggerType===ua.ONE_TIME&&t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx(nze,{})},"one-time-trigger")]})})]})},bze=()=>{const e=B5(),{segments:a}=T5();return t.jsx("div",e&&a?{className:"h-full pt-4 relative",children:t.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col gap-3",children:t.jsx(yze,{})})}:{className:"flex h-full items-center justify-center",children:t.jsx(lY,{text:[`Getting details on your ${lH("engage:automation",{count:1}).toLowerCase()}`,"Finishing up"]})})},kze=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1,hideSms:r=!1})=>{const{state:{selectedSubStepType:o}}=a.useContext(S5);if(!R5())return t.jsx("div",{className:"flex flex-col gap-4 flex-1 bg-muted rounded-md",children:t.jsx(lY,{text:["Loading..."]})});if(!o)return t.jsx("div",{className:"flex flex-col gap-4 flex-1 bg-muted rounded-md",children:t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-medium text-muted-foreground mb-2",children:"Select Communication Type"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose Email or SMS from the steps on the left to preview and edit content"})]})})});const s={disablePreview:e,disableEditContent:n,disablePreviewSubtext:i};return t.jsxs("div",{className:"flex flex-col flex-1 bg-muted rounded-md",children:[o===Vwe.EMAIL&&t.jsx(UNe,{...s}),o===Vwe.SMS&&!r&&t.jsx(YNe,{...s})]})},Sze=()=>{const{state:{selectedActionId:e}}=a.useContext(S5),{state:{hideSms:n}}=a.useContext(rY);return t.jsx("div",{className:"flex flex-col gap-4 h-full w-full",children:t.jsx(wY,{mode:"wait",children:e===Gwe.EditTime?t.jsx(sLe,{}):e===Gwe.EditAudience?t.jsx(ULe,{}):t.jsx(kze,{hideSms:n})})})},wze=()=>t.jsxs(WDe,{direction:"horizontal",className:"flex-1",children:[t.jsx(qDe,{defaultSize:30,minSize:16,maxSize:48,children:t.jsx("aside",{className:"h-full",children:t.jsx(bze,{})})}),t.jsx($De,{className:"px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1"}),t.jsx(qDe,{defaultSize:70,children:t.jsx("main",{className:"h-full",children:t.jsx(Sze,{})})})]}),Aze=()=>{const[e,n]=a.useState(Nwe.WORKFLOW),i=[{id:Nwe.WORKFLOW,label:"Workflow",content:t.jsx(wze,{})},{id:Nwe.RECIPIENTS,label:"Recipients",content:t.jsx(gRe,{})},{id:Nwe.INSIGHTS,label:lH("engage:insight",{count:2}),content:t.jsx(hRe,{})}];return t.jsx(sBe,{tabs:i,activeTab:e,onTabChange:e=>n(e),tabsLocation:"left"})},Cze=({showBackButton:e=!1,onDuplicationCreated:n,onBeforeSchedule:i,getExtraMergeFields:r,hideSms:o,hideSales:s,replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d})=>{const m=B5(),h=R5(),{updateCommunicationGroup:p}=Ye(),{toast:g}=Ve(),{channelSenders:f}=Jre(),v=a.useRef("");return a.useEffect((()=>{if(h&&r){(async()=>{const e=await r(),a=JSON.stringify(e);a!==v.current&&(v.current=a,p({groupId:h?.id,params:{extraMergeFields:e}},{onError:()=>{g({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})()}}),[h,r,p,g]),a.useEffect((()=>{if(m&&h&&f&&m.automationType===da.MANAGED&&null===h.emailChannelSenderId&&null===h.smsChannelSenderId){if(!h.emailChannelSenderId){const e=f.results.filter((e=>e.channelSenderMetadata.userPart));e.length>0&&p({groupId:h.id,params:{emailChannelSenderId:e[0].id}})}if(!h.smsChannelSenderId){const e=f.results.filter((e=>e.channelSenderMetadata.from||e.channelSenderMetadata.messageServiceSid));e.length>0&&p({groupId:h.id,params:{smsChannelSenderId:e[0].id}})}}}),[m,h,f,p]),m&&h?t.jsx(oY,{children:t.jsx(sY,{replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d,hideSms:o,hideSales:s,children:t.jsxs("div",{className:"h-full flex flex-col gap-4",children:[t.jsx(mRe,{showBackButton:e,onDuplicationCreated:n,onBeforeSchedule:i}),t.jsx("div",{className:"flex-1 border-t",children:t.jsx(Aze,{})})]})})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lY,{text:[`Fetching ${lH("engage:automation").toLowerCase()} data`,"Finishing up"]})})},Mze=({...e})=>{const a=function(){let{matches:e}=r.useContext(une),a=e[e.length-1];return a?a.params:{}}(),[n]=Xne(),i=e.automationId||a?.automationId||n.get("automationId")||"",o="true"===n.get("showBackButton")||e.showBackButton;return t.jsx(z5,{automationId:i,children:t.jsx("div",{className:"bg-background h-full",children:t.jsx(Cze,{...e,showBackButton:o})})})};Object.values(Object.assign({}));var Tze=e=>null!=e;var xze=e=>"function"!=typeof e||e.length?e:e(),Eze=e=>Array.isArray(e)?e:e?[e]:[];var Nze=Fa;var _ze,Pze=function(e){const[a,t]=La(),n=e?.throw?(e,a)=>{throw t(e instanceof Error?e:new Error(a)),e}:(e,a)=>{t(e instanceof Error?e:new Error(a))},i=e?.api?Array.isArray(e.api)?e.api:[e.api]:[globalThis.localStorage].filter(Boolean),r=e?.prefix?`${e.prefix}.`:"",o=new Map,s=new Proxy({},{get(a,t){let s=o.get(t);s||(s=La(void 0,{equals:!1}),o.set(t,s)),s[0]();const l=i.reduce(((e,a)=>{if(null!==e||!a)return e;try{return a.getItem(`${r}${t}`)}catch(oXe){return n(oXe,`Error reading ${r}${t} from ${a.name}`),null}}),null);return null!==l&&e?.deserializer?e.deserializer(l,t,e.options):l}});return!1!==e?.sync&&Ia((()=>{const e=e=>{let a=!1;i.forEach((t=>{try{t!==e.storageArea&&e.key&&e.newValue!==t.getItem(e.key)&&(e.newValue?t.setItem(e.key,e.newValue):t.removeItem(e.key),a=!0)}catch(oXe){n(oXe,`Error synching api ${t.name} from storage event (${e.key}=${e.newValue})`)}})),a&&e.key&&o.get(e.key)?.[1]()};"addEventListener"in globalThis?(globalThis.addEventListener("storage",e),Fa((()=>globalThis.removeEventListener("storage",e)))):(i.forEach((a=>a.addEventListener?.("storage",e))),Fa((()=>i.forEach((a=>a.removeEventListener?.("storage",e))))))})),[s,(a,t,s)=>{const l=e?.serializer?e.serializer(t,a,s??e.options):t,u=`${r}${a}`;i.forEach((e=>{try{e.getItem(u)!==l&&e.setItem(u,l)}catch(oXe){n(oXe,`Error setting ${r}${a} to ${l} in ${e.name}`)}}));const c=o.get(a);c&&c[1]()},{clear:()=>i.forEach((e=>{try{e.clear()}catch(oXe){n(oXe,`Error clearing ${e.name}`)}})),error:a,remove:e=>i.forEach((a=>{try{a.removeItem(`${r}${e}`)}catch(oXe){n(oXe,`Error removing ${r}${e} from ${a.name}`)}})),toJSON:()=>{const a={},t=(t,n)=>{if(!a.hasOwnProperty(t)){const i=n&&e?.deserializer?e.deserializer(n,t,e.options):n;i&&(a[t]=i)}};return i.forEach((e=>{if("function"==typeof e.getAll){let a;try{a=e.getAll()}catch(oXe){n(oXe,`Error getting all values from in ${e.name}`)}for(const e of a)t(e,a[e])}else{let i,r=0;try{for(;i=e.key(r++);)a.hasOwnProperty(i)||t(i,e.getItem(i))}catch(oXe){n(oXe,`Error getting all values from ${e.name}`)}}})),a}}]},jze=e=>{if(!e)return"";let a="";for(const t in e){if(!e.hasOwnProperty(t))continue;const n=e[t];a+=n instanceof Date?`; ${t}=${n.toUTCString()}`:"boolean"==typeof n?`; ${t}`:`; ${t}=${n}`}return a},Lze=("function"==typeof(_ze={_cookies:[globalThis.document,"cookie"],getItem:e=>Lze._cookies[0][Lze._cookies[1]].match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)")?.pop()??null,setItem:(e,a,t)=>{const n=Lze.getItem(e);Lze._cookies[0][Lze._cookies[1]]=`${e}=${a}${jze(t)}`;const i=Object.assign(new Event("storage"),{key:e,oldValue:n,newValue:a,url:globalThis.document.URL,storageArea:Lze});window.dispatchEvent(i)},removeItem:e=>{Lze._cookies[0][Lze._cookies[1]]=`${e}=deleted${jze({expires:new Date(0)})}`},key:e=>{let a=null,t=0;return Lze._cookies[0][Lze._cookies[1]].replace(/(?:^|;)\s*(.+?)\s*=\s*[^;]+/g,((n,i)=>(!a&&i&&t++===e&&(a=i),""))),a},get length(){let e=0;return Lze._cookies[0][Lze._cookies[1]].replace(/(?:^|;)\s*.+?\s*=\s*[^;]+/g,(a=>(e+=a?1:0,""))),e}}).clear||(_ze.clear=()=>{let e;for(;e=_ze.key(0);)_ze.removeItem(e)}),_ze),Bze=796,Rze="bottom",Dze="system",zze=Object.keys(ai)[0],Oze=Object.keys(ii)[0],Kze=Wa({client:void 0,onlineManager:void 0,queryFlavor:"",version:"",shadowDOMTarget:void 0});function Hze(){return qa(Kze)}var Ize=Wa(void 0),Fze=e=>{const[a,t]=La(null),n=()=>{const e=a();null!=e&&(e.close(),t(null))},i=(n,i)=>{if(null!=a())return;const r=window.open("","TSQD-Devtools-Panel",`width=${n},height=${i},popup`);if(!r)throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");r.document.head.innerHTML="",r.document.body.innerHTML="",function(e=window.document){if(e[Dt]){for(let a of e[Dt].keys())e.removeEventListener(a,Zt);delete e[Dt]}}(r.document),r.document.title="TanStack Query Devtools",r.document.body.style.margin="0",r.addEventListener("pagehide",(()=>{e.setLocalStore("pip_open","false"),t(null)})),[...(Hze().shadowDOMTarget||document).styleSheets].forEach((e=>{try{const a=[...e.cssRules].map((e=>e.cssText)).join(""),t=document.createElement("style"),n=e.ownerNode;let i="";n&&"id"in n&&(i=n.id),i&&t.setAttribute("id",i),t.textContent=a,r.document.head.appendChild(t)}catch(rXe){const t=document.createElement("link");if(null==e.href)return;t.rel="stylesheet",t.type=e.type,t.media=e.media.toString(),t.href=e.href,r.document.head.appendChild(t)}})),Kt(["focusin","focusout","pointermove","keydown","pointerdown","pointerup","click","mousedown","input"],r.document),e.setLocalStore("pip_open","true"),t(r)};Da((()=>{"true"!==(e.localStore.pip_open??"false")||e.disabled||i(Number(window.innerWidth),Number(e.localStore.height||500))})),Da((()=>{const e=(Hze().shadowDOMTarget||document).querySelector("#_goober"),t=a();if(e&&t){const a=new MutationObserver((()=>{const a=(Hze().shadowDOMTarget||t.document).querySelector("#_goober");a&&(a.textContent=e.textContent)}));a.observe(e,{childList:!0,subtree:!0,characterDataOldValue:!0}),Fa((()=>{a.disconnect()}))}}));const r=za((()=>({pipWindow:a(),requestPipWindow:i,closePipWindow:n,disabled:e.disabled??!1})));return ht(Ize.Provider,{value:r,get children(){return e.children}})},Gze=()=>za((()=>{const e=qa(Ize);if(!e)throw new Error("usePiPWindow must be used within a PiPProvider");return e()})),Vze=Wa((()=>"dark"));function Jze(){return qa(Vze)}var Uze={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ấ":"A","Ắ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Æ":"AE","Ầ":"A","Ằ":"A","Ȃ":"A","Ç":"C","Ḉ":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ế":"E","Ḗ":"E","Ề":"E","Ḕ":"E","Ḝ":"E","Ȇ":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ḯ":"I","Ȋ":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ố":"O","Ṍ":"O","Ṓ":"O","Ȏ":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ấ":"a","ắ":"a","ẳ":"a","ẵ":"a","ặ":"a","æ":"ae","ầ":"a","ằ":"a","ȃ":"a","ç":"c","ḉ":"c","è":"e","é":"e","ê":"e","ë":"e","ế":"e","ḗ":"e","ề":"e","ḕ":"e","ḝ":"e","ȇ":"e","ì":"i","í":"i","î":"i","ï":"i","ḯ":"i","ȋ":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ố":"o","ṍ":"o","ṓ":"o","ȏ":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","C̆":"C","c̆":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","Ǵ":"G","ĝ":"g","ǵ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ḫ":"H","ḫ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ḱ":"K","ḱ":"k","K̆":"K","k̆":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ḿ":"M","ḿ":"m","M̆":"M","m̆":"m","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","N̆":"N","n̆":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","P̆":"P","p̆":"p","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","R̆":"R","r̆":"r","Ȓ":"R","ȓ":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","Ș":"S","ș":"s","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","ț":"t","Ț":"T","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","T̆":"T","t̆":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ȗ":"U","ȗ":"u","V̆":"V","v̆":"v","Ŵ":"W","ŵ":"w","Ẃ":"W","ẃ":"w","X̆":"X","x̆":"x","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Y̆":"Y","y̆":"y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ứ":"U","ứ":"u","Ṹ":"U","ṹ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o","Þ":"TH","þ":"th","Ṕ":"P","ṕ":"p","Ṥ":"S","ṥ":"s","X́":"X","x́":"x","Ѓ":"Г","ѓ":"г","Ќ":"К","ќ":"к","A̋":"A","a̋":"a","E̋":"E","e̋":"e","I̋":"I","i̋":"i","Ǹ":"N","ǹ":"n","Ồ":"O","ồ":"o","Ṑ":"O","ṑ":"o","Ừ":"U","ừ":"u","Ẁ":"W","ẁ":"w","Ỳ":"Y","ỳ":"y","Ȁ":"A","ȁ":"a","Ȅ":"E","ȅ":"e","Ȉ":"I","ȉ":"i","Ȍ":"O","ȍ":"o","Ȑ":"R","ȑ":"r","Ȕ":"U","ȕ":"u","B̌":"B","b̌":"b","Č̣":"C","č̣":"c","Ê̌":"E","ê̌":"e","F̌":"F","f̌":"f","Ǧ":"G","ǧ":"g","Ȟ":"H","ȟ":"h","J̌":"J","ǰ":"j","Ǩ":"K","ǩ":"k","M̌":"M","m̌":"m","P̌":"P","p̌":"p","Q̌":"Q","q̌":"q","Ř̩":"R","ř̩":"r","Ṧ":"S","ṧ":"s","V̌":"V","v̌":"v","W̌":"W","w̌":"w","X̌":"X","x̌":"x","Y̌":"Y","y̌":"y","A̧":"A","a̧":"a","B̧":"B","b̧":"b","Ḑ":"D","ḑ":"d","Ȩ":"E","ȩ":"e","Ɛ̧":"E","ɛ̧":"e","Ḩ":"H","ḩ":"h","I̧":"I","i̧":"i","Ɨ̧":"I","ɨ̧":"i","M̧":"M","m̧":"m","O̧":"O","o̧":"o","Q̧":"Q","q̧":"q","U̧":"U","u̧":"u","X̧":"X","x̧":"x","Z̧":"Z","z̧":"z"},Wze=Object.keys(Uze).join("|"),qze=new RegExp(Wze,"g");var $ze=7,Zze=6,Yze=5,Qze=4,Xze=3,eOe=2,aOe=1,tOe=0;function nOe(e,a,t){var n;if((t=t||{}).threshold=null!=(n=t.threshold)?n:aOe,!t.accessors){const n=iOe(e,a,t);return{rankedValue:e,rank:n,accessorIndex:-1,accessorThreshold:t.threshold,passed:n>=t.threshold}}const i=function(e,a){const t=[];for(let n=0,i=a.length;n<i;n++){const i=a[n],r=lOe(i),o=oOe(e,i);for(let e=0,a=o.length;e<a;e++)t.push({itemValue:o[e],attributes:r})}return t}(e,t.accessors),r={rankedValue:e,rank:tOe,accessorIndex:-1,accessorThreshold:t.threshold,passed:!1};for(let o=0;o<i.length;o++){const e=i[o];let n=iOe(e.itemValue,a,t);const{minRanking:s,maxRanking:l,threshold:u=t.threshold}=e.attributes;n<s&&n>=aOe?n=s:n>l&&(n=l),n=Math.min(n,l),n>=u&&n>r.rank&&(r.rank=n,r.passed=!0,r.accessorIndex=o,r.accessorThreshold=u,r.rankedValue=e.itemValue)}return r}function iOe(e,a,t){return e=rOe(e,t),(a=rOe(a,t)).length>e.length?tOe:e===a?$ze:(e=e.toLowerCase())===(a=a.toLowerCase())?Zze:e.startsWith(a)?Yze:e.includes(` ${a}`)?Qze:e.includes(a)?Xze:1===a.length?tOe:function(e){let a="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{a+=e.substr(0,1)}))})),a}(e).includes(a)?eOe:function(e,a){let t=0,n=0;function i(e,a,n){for(let i=n,r=a.length;i<r;i++){if(a[i]===e)return t+=1,i+1}return-1}function r(e){return aOe+t/a.length*(1/e)}const o=i(a[0],e,0);if(o<0)return tOe;n=o;for(let s=1,l=a.length;s<l;s++){n=i(a[s],e,n);if(!(n>-1))return tOe}return r(n-o)}(e,a)}function rOe(e,a){let{keepDiacritics:t}=a;return e=`${e}`,t||(e=e.replace(qze,(e=>Uze[e]))),e}function oOe(e,a){let t=a;"object"==typeof a&&(t=a.accessor);const n=t(e);return null==n?[]:Array.isArray(n)?n:[String(n)]}var sOe={maxRanking:1/0,minRanking:-1/0};function lOe(e){return"function"==typeof e?sOe:{...sOe,...e}}var uOe={data:""},cOe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,dOe=/\/\*[^]*?\*\/| +/g,mOe=/\n+/g,hOe=(e,a)=>{let t="",n="",i="";for(let r in e){let o=e[r];"@"==r[0]?"i"==r[1]?t=r+" "+o+";":n+="f"==r[1]?hOe(o,r):r+"{"+hOe(o,"k"==r[1]?"":a)+"}":"object"==typeof o?n+=hOe(o,a?a.replace(/([^,])+/g,(e=>r.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,(a=>/&/.test(a)?a.replace(/&/g,e):e?e+" "+a:a)))):r):null!=o&&(r=/^--/.test(r)?r:r.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=hOe.p?hOe.p(r,o):r+":"+o+";")}return t+(a&&i?a+"{"+i+"}":i)+n},pOe={},gOe=e=>{if("object"==typeof e){let a="";for(let t in e)a+=t+gOe(e[t]);return a}return e};function fOe(e){let a=this||{},t=e.call?e(a.p):e;return((e,a,t,n,i)=>{let r=gOe(e),o=pOe[r]||(pOe[r]=(e=>{let a=0,t=11;for(;a<e.length;)t=101*t+e.charCodeAt(a++)>>>0;return"go"+t})(r));if(!pOe[o]){let a=r!==e?e:(e=>{let a,t,n=[{}];for(;a=cOe.exec(e.replace(dOe,""));)a[4]?n.shift():a[3]?(t=a[3].replace(mOe," ").trim(),n.unshift(n[0][t]=n[0][t]||{})):n[0][a[1]]=a[2].replace(mOe," ").trim();return n[0]})(e);pOe[o]=hOe(i?{["@keyframes "+o]:a}:a,t?"":"."+o)}let s=t&&pOe.g?pOe.g:null;return t&&(pOe.g=pOe[o]),l=pOe[o],u=a,c=n,(d=s)?u.data=u.data.replace(d,l):-1===u.data.indexOf(l)&&(u.data=c?l+u.data:u.data+l),o;var l,u,c,d})(t.unshift?t.raw?((e,a,t)=>e.reduce(((e,n,i)=>{let r=a[i];if(r&&r.call){let e=r(t),a=e&&e.props&&e.props.className||/^go/.test(e)&&e;r=a?"."+a:e&&"object"==typeof e?e.props?"":hOe(e,""):!1===e?"":e}return e+n+(null==r?"":r)}),""))(t,[].slice.call(arguments,1),a.p):t.reduce(((e,t)=>Object.assign(e,t&&t.call?t(a.p):t)),{}):t,(e=>"object"==typeof window?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||uOe)(a.target),a.g,a.o,a.k)}function vOe(e){var a,t,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(a=0;a<i;a++)e[a]&&(t=vOe(e[a]))&&(n&&(n+=" "),n+=t)}else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function yOe(){for(var e,a,t=0,n="",i=arguments.length;t<i;t++)(e=arguments[t])&&(a=vOe(e))&&(n&&(n+=" "),n+=a);return n}function bOe(e,a){const t=Ka(e),{onChange:n}=a;let i=new Set(a.appear?void 0:t);const r=new WeakSet,[o,s]=La([],{equals:!1}),[l]=[Ja,Va],u=e=>{s((a=>(a.push.apply(a,e),a)));for(const a of e)r.delete(a)},c=(e,a,t)=>e.splice(t,0,a);return za((a=>{const t=o(),s=e();if(Ka(l))return l(),a;if(t.length){const e=a.filter((e=>!t.includes(e)));return t.length=0,n({list:e,added:[],removed:[],unchanged:e,finishRemoved:u}),e}return Ka((()=>{const e=new Set(s),t=s.slice(),o=[],l=[],d=[];for(const a of s)(i.has(a)?d:o).push(a);let m=!o.length;for(let n=0;n<a.length;n++){const i=a[n];e.has(i)||(r.has(i)||(l.push(i),r.add(i)),c(t,i,n)),m&&i!==t[n]&&(m=!1)}return!l.length&&m?a:(n({list:t,added:o,removed:l,unchanged:d,finishRemoved:u}),i=e,t)}))}),a.appear?[]:t.slice())}function kOe(...e){return a=e,(...e)=>{for(const t of a)t&&t(...e)};var a}fOe.bind({g:1}),fOe.bind({k:1});var SOe=e=>e instanceof Element;function wOe(e,a){if(a(e))return e;if("function"==typeof e&&!e.length)return wOe(e(),a);if(Array.isArray(e)){const t=[];for(const n of e){const e=wOe(n,a);e&&(Array.isArray(e)?t.push.apply(t,e):t.push(e))}return t.length?t:null}return null}function AOe(e,a=SOe,t=SOe){const n=za(e),i=za((()=>wOe(n(),a)));return i.toArray=()=>{const e=i();return Array.isArray(e)?e:e?[e]:[]},i}function COe(e){requestAnimationFrame((()=>requestAnimationFrame(e)))}function MOe(e,a,t,n){const{onBeforeEnter:i,onEnter:r,onAfterEnter:o}=a;function s(a){a&&a.target!==t||(t.removeEventListener("transitionend",s),t.removeEventListener("animationend",s),t.classList.remove(...e.enterActive),t.classList.remove(...e.enterTo),o?.(t))}i?.(t),t.classList.add(...e.enter),t.classList.add(...e.enterActive),queueMicrotask((()=>{if(!t.parentNode)return n?.();r?.(t,(()=>s()))})),COe((()=>{t.classList.remove(...e.enter),t.classList.add(...e.enterTo),(!r||r.length<2)&&(t.addEventListener("transitionend",s),t.addEventListener("animationend",s))}))}function TOe(e,a,t,n){const{onBeforeExit:i,onExit:r,onAfterExit:o}=a;if(!t.parentNode)return n?.();function s(a){a&&a.target!==t||(n?.(),t.removeEventListener("transitionend",s),t.removeEventListener("animationend",s),t.classList.remove(...e.exitActive),t.classList.remove(...e.exitTo),o?.(t))}i?.(t),t.classList.add(...e.exit),t.classList.add(...e.exitActive),r?.(t,(()=>s())),COe((()=>{t.classList.remove(...e.exit),t.classList.add(...e.exitTo),(!r||r.length<2)&&(t.addEventListener("transitionend",s),t.addEventListener("animationend",s))}))}var xOe=e=>{const a=function(e){return za((()=>{const a=e.name||"s";return{enterActive:(e.enterActiveClass||a+"-enter-active").split(" "),enter:(e.enterClass||a+"-enter").split(" "),enterTo:(e.enterToClass||a+"-enter-to").split(" "),exitActive:(e.exitActiveClass||a+"-exit-active").split(" "),exit:(e.exitClass||a+"-exit").split(" "),exitTo:(e.exitToClass||a+"-exit-to").split(" "),move:(e.moveClass||a+"-move").split(" ")}}))}(e);return bOe(AOe((()=>e.children)).toArray,{appear:e.appear,onChange({added:t,removed:n,finishRemoved:i,list:r}){const o=a();for(const a of t)MOe(o,e,a);const s=[];for(const e of r)e.isConnected&&(e instanceof HTMLElement||e instanceof SVGElement)&&s.push({el:e,rect:e.getBoundingClientRect()});queueMicrotask((()=>{const e=[];for(const{el:a,rect:t}of s)if(a.isConnected){const n=a.getBoundingClientRect(),i=t.left-n.left,r=t.top-n.top;(i||r)&&(a.style.transform=`translate(${i}px, ${r}px)`,a.style.transitionDuration="0s",e.push(a))}document;for(const a of e){let e=function(t){(t.target===a||/transform$/.test(t.propertyName))&&(a.removeEventListener("transitionend",e),a.classList.remove(...o.move))};a.classList.add(...o.move),a.style.transform=a.style.transitionDuration="",a.addEventListener("transitionend",e)}}));for(const a of n)TOe(o,e,a,(()=>i([a])))}})},EOe=Symbol("fallback");function NOe(e){for(const a of e)a.dispose()}function _Oe(e){const{by:a}=e;return za(function(e,a,t,n={}){const i=new Map;return Fa((()=>NOe(i.values()))),()=>{const t=e()||[];return Ka((()=>{if(!t.length)return NOe(i.values()),i.clear(),n.fallback?[ja((e=>(i.set(EOe,{dispose:e}),n.fallback())))]:[];const e=new Array(t.length),o=i.get(EOe);if(!i.size||o){o?.dispose(),i.delete(EOe);for(let n=0;n<t.length;n++){const i=t[n];r(e,i,n,a(i,n))}return e}const s=new Set(i.keys());for(let n=0;n<t.length;n++){const o=t[n],l=a(o,n);s.delete(l);const u=i.get(l);u?(e[n]=u.mapped,u.setIndex?.(n),u.setItem((()=>o))):r(e,o,n,l)}for(const a of s)i.get(a)?.dispose(),i.delete(a);return e}))};function r(e,a,n,r){ja((o=>{const[s,l]=La(a),u={setItem:l,dispose:o};if(t.length>1){const[e,a]=La(n);u.setIndex=a,u.mapped=t(s,e)}else u.mapped=t(s);i.set(r,u),e[n]=u.mapped}))}}((()=>e.each),"function"==typeof a?a:e=>e[a],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function POe(e,a,t,n){const i=()=>{Eze(xze(e)).forEach((e=>{e&&Eze(xze(a)).forEach((a=>function(e,a,t,n){return e.addEventListener(a,t,n),Nze(e.removeEventListener.bind(e,a,t,n))}(e,a,t,n)))}))};"function"==typeof e?Da(i):Ra(i)}function jOe(e,a,t){const n=new WeakMap,{observe:i,unobserve:r}=function(e,a){const t=new ResizeObserver(e);return Fa(t.disconnect.bind(t)),{observe:e=>t.observe(e,a),unobserve:t.unobserve.bind(t)}}((e=>{for(const t of e){const{contentRect:e,target:i}=t,r=Math.round(e.width),o=Math.round(e.height),s=n.get(i);s&&s.width===r&&s.height===o||(a(e,i,t),n.set(i,{width:r,height:o}))}}),t);Da((a=>{const t=Eze(xze(e)).filter(Tze);return function(e,a,t,n){const i=e.length,r=a.length;let o,s,l=0;if(r)if(i){for(;l<r&&a[l]===e[l];l++);for(o of(a=a.slice(l),e=e.slice(l),a))e.includes(o)||n(o);for(s of e)a.includes(s)||t(s)}else for(;l<r;l++)n(a[l]);else for(;l<i;l++)t(e[l])}(t,a,i,r),t}),[])}var LOe=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function BOe(e){const a={};let t;for(;t=LOe.exec(e);)a[t[1]]=t[2];return a}function ROe(e,a){if("string"==typeof e){if("string"==typeof a)return`${e};${a}`;e=BOe(e)}else"string"==typeof a&&(a=BOe(a));return{...e,...a}}function DOe(e,a){const t=[...e],n=t.indexOf(a);return-1!==n&&t.splice(n,1),t}function zOe(e){return"[object String]"===Object.prototype.toString.call(e)}function OOe(e){return a=>`${e()}-${a}`}function KOe(e,a){return!!e&&(e===a||e.contains(a))}function HOe(e,a=!1){const{activeElement:t}=IOe(e);if(!t?.nodeName)return null;if(FOe(t)&&t.contentDocument)return HOe(t.contentDocument.body,a);if(a){const e=t.getAttribute("aria-activedescendant");if(e){const a=IOe(t).getElementById(e);if(a)return a}}return t}function IOe(e){return e?e.ownerDocument||e:document}function FOe(e){return"IFRAME"===e.tagName}var GOe=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(GOe||{});function VOe(e){return"undefined"!=typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function JOe(){return VOe(/^Mac/i)}function UOe(){return VOe(/^iPhone/i)||VOe(/^iPad/i)||JOe()&&navigator.maxTouchPoints>1}function WOe(e,a){return a&&("function"==typeof a?a(e):a[0](a[1],e)),e?.defaultPrevented}function qOe(e){return a=>{for(const t of e)WOe(a,t)}}function $Oe(e){return JOe()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function ZOe(e){if(e)if(function(){if(null==YOe){YOe=!1;try{document.createElement("div").focus({get preventScroll(){return YOe=!0,!0}})}catch(rXe){}}return YOe}())e.focus({preventScroll:!0});else{const a=function(e){let a=e.parentNode;const t=[],n=document.scrollingElement||document.documentElement;for(;a instanceof HTMLElement&&a!==n;)(a.offsetHeight<a.scrollHeight||a.offsetWidth<a.scrollWidth)&&t.push({element:a,scrollTop:a.scrollTop,scrollLeft:a.scrollLeft}),a=a.parentNode;n instanceof HTMLElement&&t.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft});return t}(e);e.focus(),function(e){for(const{element:a,scrollTop:t,scrollLeft:n}of e)a.scrollTop=t,a.scrollLeft=n}(a)}}var YOe=null;var QOe=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],XOe=[...QOe,'[tabindex]:not([tabindex="-1"]):not([disabled])'],eKe=QOe.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",aKe=XOe.join(':not([hidden]):not([tabindex="-1"]),');function tKe(e,a){const t=Array.from(e.querySelectorAll(eKe)).filter(nKe);return a&&nKe(e)&&t.unshift(e),t.forEach(((e,a)=>{if(FOe(e)&&e.contentDocument){const n=tKe(e.contentDocument.body,!1);t.splice(a,1,...n)}})),t}function nKe(e){return iKe(e)&&!function(e){const a=parseInt(e.getAttribute("tabindex")||"0",10);return a<0}(e)}function iKe(e){return e.matches(eKe)&&rKe(e)}function rKe(e,a){return"#comment"!==e.nodeName&&function(e){if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const{display:a,visibility:t}=e.style;let n="none"!==a&&"hidden"!==t&&"collapse"!==t;if(n){if(!e.ownerDocument.defaultView)return n;const{getComputedStyle:a}=e.ownerDocument.defaultView,{display:t,visibility:i}=a(e);n="none"!==t&&"hidden"!==i&&"collapse"!==i}return n}(e)&&function(e,a){return!e.hasAttribute("hidden")&&("DETAILS"!==e.nodeName||!a||"SUMMARY"===a.nodeName||e.hasAttribute("open"))}(e,a)&&(!e.parentElement||rKe(e.parentElement,e))}function oKe(e){for(;e&&!sKe(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}function sKe(e){const a=window.getComputedStyle(e);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function lKe(){}function uKe(e,a){return yt(e,a)}var cKe=new Map,dKe=new Set;function mKe(){if("undefined"==typeof window)return;const e=a=>{if(!a.target)return;const t=cKe.get(a.target);if(t&&(t.delete(a.propertyName),0===t.size&&(a.target.removeEventListener("transitioncancel",e),cKe.delete(a.target)),0===cKe.size)){for(const e of dKe)e();dKe.clear()}};document.body.addEventListener("transitionrun",(a=>{if(!a.target)return;let t=cKe.get(a.target);t||(t=new Set,cKe.set(a.target,t),a.target.addEventListener("transitioncancel",e)),t.add(a.propertyName)})),document.body.addEventListener("transitionend",e)}function hKe(e,a){const t=pKe(e,a,"left"),n=pKe(e,a,"top"),i=a.offsetWidth,r=a.offsetHeight;let o=e.scrollLeft,s=e.scrollTop;const l=o+e.offsetWidth,u=s+e.offsetHeight;t<=o?o=t:t+i>l&&(o+=t+i-l),n<=s?s=n:n+r>u&&(s+=n+r-u),e.scrollLeft=o,e.scrollTop=s}function pKe(e,a,t){const n="left"===t?"offsetLeft":"offsetTop";let i=0;for(;a.offsetParent&&(i+=a[n],a.offsetParent!==e);){if(a.offsetParent.contains(e)){i-=e[n];break}a=a.offsetParent}return i}"undefined"!=typeof document&&("loading"!==document.readyState?mKe():document.addEventListener("DOMContentLoaded",mKe));var gKe={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};function fKe(e){return a=>(e(a),()=>e(void 0))}function vKe(e,a){const[t,n]=La(yKe(a?.()));return Da((()=>{n(e()?.tagName.toLowerCase()||yKe(a?.()))})),t}function yKe(e){return zOe(e)?e:void 0}function bKe(e){const[a,t]=bt(e,["as"]);if(!a.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return ht(nn,yt(t,{get component(){return a.as}}))}var kKe=["id","name","validationState","required","disabled","readOnly"];var SKe=Wa();function wKe(){const e=qa(SKe);if(void 0===e)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function AKe(e){const a=wKe(),t=uKe({id:a.generateId("description")},e);return Da((()=>Fa(a.registerDescription(t.id)))),ht(bKe,yt({as:"div"},(()=>a.dataset()),t))}function CKe(e){const a=wKe(),t=uKe({id:a.generateId("error-message")},e),[n,i]=bt(t,["forceMount"]),r=()=>"invalid"===a.validationState();return Da((()=>{r()&&Fa(a.registerErrorMessage(i.id))})),ht(Tt,{get when(){return n.forceMount||r()},get children(){return ht(bKe,yt({as:"div"},(()=>a.dataset()),i))}})}function MKe(e){let a;const t=wKe(),n=uKe({id:t.generateId("label")},e),[i,r]=bt(n,["ref"]),o=vKe((()=>a),(()=>"label"));return Da((()=>Fa(t.registerLabel(r.id)))),ht(bKe,yt({as:"label",ref(e){const t=kOe((e=>a=e),i.ref);"function"==typeof t&&t(e)},get for(){return za((()=>"label"===o()))()?t.fieldId():void 0}},(()=>t.dataset()),r))}function TKe(e,a){Da(Ha(e,(e=>{if(null==e)return;const t=function(e){return function(e){return e.matches("textarea, input, select, button")}(e)?e.form:e.closest("form")}(e);null!=t&&(t.addEventListener("reset",a,{passive:!0}),Fa((()=>{t.removeEventListener("reset",a)})))})))}function xKe(e){const[a,t]=La(e.defaultValue?.()),n=za((()=>void 0!==e.value?.())),i=za((()=>n()?e.value?.():a()));return[i,a=>{Ka((()=>{const r=function(e,...a){return"function"==typeof e?e(...a):e}(a,i());return Object.is(r,i())||(n()||t(r),e.onChange?.(r)),r}))}]}function EKe(e){const[a,t]=xKe(e);return[()=>a()??!1,t]}var NKe=Object.defineProperty,_Ke=(e,a)=>{for(var t in a)NKe(e,t,{get:a[t],enumerable:!0})},PKe=Wa();function jKe(){return qa(PKe)}function LKe(e,a){return Boolean(a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function BKe(e,a){const t=function(e){const a=e.map(((e,a)=>[a,e]));let t=!1;return a.sort((([e,a],[n,i])=>{const r=a.ref(),o=i.ref();return r===o?0:r&&o?LKe(r,o)?(e>n&&(t=!0),-1):(e<n&&(t=!0),1):0})),t?a.map((([e,a])=>a)):e}(e);e!==t&&a(t)}function RKe(e,a){if("function"!=typeof IntersectionObserver)return void function(e,a){Da((()=>{const t=setTimeout((()=>{BKe(e(),a)}));Fa((()=>clearTimeout(t)))}))}(e,a);let t=[];Da((()=>{const n=function(e){const a=e[0],t=e[e.length-1]?.ref();let n=a?.ref()?.parentElement;for(;n;){if(t&&n.contains(t))return n;n=n.parentElement}return IOe(n).body}(e()),i=new IntersectionObserver((()=>{const n=!!t.length;t=e(),n&&BKe(e(),a)}),{root:n});for(const a of e()){const e=a.ref();e&&i.observe(e)}Fa((()=>i.disconnect()))}))}function DKe(e={}){const[a,t]=function(e){const[a,t]=xKe(e);return[()=>a()??[],t]}({value:()=>xze(e.items),onChange:a=>e.onItemsChange?.(a)});RKe(a,t);const n=e=>(t((a=>{const t=function(e,a){const t=a.ref();if(!t)return-1;let n=e.length;if(!n)return-1;for(;n--;){const a=e[n]?.ref();if(a&&LKe(a,t))return n+1}return 0}(a,e);return function(e,a,t=-1){return t in e?[...e.slice(0,t),a,...e.slice(t)]:[...e,a]}(a,e,t)})),()=>{t((a=>{const t=a.filter((a=>a.ref()!==e.ref()));return a.length===t.length?a:t}))});return{DomCollectionProvider:e=>ht(PKe.Provider,{value:{registerItem:n},get children(){return e.children}})}}function zKe(e){const a=function(){const e=jKe();if(void 0===e)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}(),t=uKe({shouldRegisterItem:!0},e);Da((()=>{if(!t.shouldRegisterItem)return;Fa(a.registerItem(t.getItem()))}))}function OKe(e){let a=e.startIndex??0;const t=e.startLevel??0,n=[],i=a=>{if(null==a)return"";const t=e.getKey??"key",n=zOe(t)?a[t]:t(a);return null!=n?String(n):""},r=a=>{if(null==a)return"";const t=e.getTextValue??"textValue",n=zOe(t)?a[t]:t(a);return null!=n?String(n):""},o=a=>{if(null==a)return!1;const t=e.getDisabled??"disabled";return(zOe(t)?a[t]:t(a))??!1},s=a=>{if(null!=a)return zOe(e.getSectionChildren)?a[e.getSectionChildren]:e.getSectionChildren?.(a)};for(const l of e.dataSource)if(zOe(l)||"number"==typeof l)n.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:o(l),level:t,index:a}),a++;else if(null!=s(l)){n.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:t,index:a}),a++;const i=s(l)??[];if(i.length>0){const r=OKe({dataSource:i,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:a,startLevel:t+1});n.push(...r),a+=r.length}}else n.push({type:"item",rawValue:l,key:i(l),textValue:r(l),disabled:o(l),level:t,index:a}),a++;return n}function KKe(e,a=[]){return za((()=>{const t=OKe({dataSource:xze(e.dataSource),getKey:xze(e.getKey),getTextValue:xze(e.getTextValue),getDisabled:xze(e.getDisabled),getSectionChildren:xze(e.getSectionChildren)});for(let e=0;e<a.length;e++)a[e]();return e.factory(t)}))}var HKe=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),IKe=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function FKe(e){return function(e){if(Intl.Locale){const a=new Intl.Locale(e).maximize().script??"";return HKe.has(a)}const a=e.split("-")[0];return IKe.has(a)}(e)?"rtl":"ltr"}function GKe(){let e="undefined"!=typeof navigator&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:FKe(e)}}var VKe=GKe(),JKe=new Set;function UKe(){VKe=GKe();for(const e of JKe)e(VKe)}var WKe=Wa();function qKe(){const e=function(){const[e,a]=La(VKe),t=za((()=>e()));return Ia((()=>{0===JKe.size&&window.addEventListener("languagechange",UKe),JKe.add(a),Fa((()=>{JKe.delete(a),0===JKe.size&&window.removeEventListener("languagechange",UKe)}))})),{locale:()=>t().locale,direction:()=>t().direction}}();return qa(WKe)||e}var $Ke=new Map;var ZKe=class e extends Set{anchorKey;currentKey;constructor(a,t,n){super(a),a instanceof e?(this.anchorKey=t||a.anchorKey,this.currentKey=n||a.currentKey):(this.anchorKey=t,this.currentKey=n)}};function YKe(e){return JOe()||UOe()?e.altKey:e.ctrlKey}function QKe(e){return JOe()?e.metaKey:e.ctrlKey}function XKe(e){return new ZKe(e)}function eHe(e){const a=uKe({selectionMode:"none",selectionBehavior:"toggle"},e),[t,n]=La(!1),[i,r]=La(),o=za((()=>{const e=xze(a.selectedKeys);return null!=e?XKe(e):e})),s=za((()=>{const e=xze(a.defaultSelectedKeys);return null!=e?XKe(e):new ZKe})),[l,u]=function(e){const[a,t]=xKe(e);return[()=>a()??new ZKe,t]}({value:o,defaultValue:s,onChange:e=>a.onSelectionChange?.(e)}),[c,d]=La(xze(a.selectionBehavior));return Da((()=>{const e=l();"replace"===xze(a.selectionBehavior)&&"toggle"===c()&&"object"==typeof e&&0===e.size&&d("replace")})),Da((()=>{d(xze(a.selectionBehavior)??"toggle")})),{selectionMode:()=>xze(a.selectionMode),disallowEmptySelection:()=>xze(a.disallowEmptySelection)??!1,selectionBehavior:c,setSelectionBehavior:d,isFocused:t,setFocused:n,focusedKey:i,setFocusedKey:r,selectedKeys:l,setSelectedKeys:e=>{!xze(a.allowDuplicateSelectionEvents)&&function(e,a){if(e.size!==a.size)return!1;for(const t of e)if(!a.has(t))return!1;return!0}(e,l())||u(e)}}}function aHe(e,a,t){const n=yt({selectOnFocus:()=>"replace"===xze(e.selectionManager).selectionBehavior()},e),i=()=>a(),{direction:r}=qKe();let o={top:0,left:0};POe((()=>xze(n.isVirtualized)?void 0:i()),"scroll",(()=>{const e=i();e&&(o={top:e.scrollTop,left:e.scrollLeft})}));const{typeSelectHandlers:s}=function(e){const[a,t]=La(""),[n,i]=La(-1);return{typeSelectHandlers:{onKeyDown:r=>{if(xze(e.isDisabled))return;const o=xze(e.keyboardDelegate),s=xze(e.selectionManager);if(!o.getKeyForSearch)return;const l=function(e){return 1!==e.length&&/^[A-Z]/i.test(e)?"":e}(r.key);if(!l||r.ctrlKey||r.metaKey)return;" "===l&&a().trim().length>0&&(r.preventDefault(),r.stopPropagation());let u=t((e=>e+l)),c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u);null==c&&function(e){return e.split("").every((a=>a===e[0]))}(u)&&(u=u[0],c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u)),null!=c&&(s.setFocusedKey(c),e.onTypeSelect?.(c)),clearTimeout(n()),i(window.setTimeout((()=>t("")),500))}}}}({isDisabled:()=>xze(n.disallowTypeAhead),keyboardDelegate:()=>xze(n.keyboardDelegate),selectionManager:()=>xze(n.selectionManager)}),l=()=>xze(n.orientation)??"vertical",u=()=>{const e=xze(n.autoFocus);if(!e)return;const t=xze(n.selectionManager),i=xze(n.keyboardDelegate);let r;"first"===e&&(r=i.getFirstKey?.()),"last"===e&&(r=i.getLastKey?.());const o=t.selectedKeys();o.size&&(r=o.values().next().value),t.setFocused(!0),t.setFocusedKey(r);const s=a();s&&null==r&&!xze(n.shouldUseVirtualFocus)&&ZOe(s)};Ia((()=>{n.deferAutoFocus?setTimeout(u,0):u()})),Da(Ha([i,()=>xze(n.isVirtualized),()=>xze(n.selectionManager).focusedKey()],(e=>{const[a,t,i]=e;if(t)i&&n.scrollToKey?.(i);else if(i&&a){const e=a.querySelector(`[data-key="${i}"]`);e&&hKe(a,e)}})));return{tabIndex:za((()=>{if(!xze(n.shouldUseVirtualFocus))return null==xze(n.selectionManager).focusedKey()?0:-1})),onKeyDown:e=>{WOe(e,s.onKeyDown),e.altKey&&"Tab"===e.key&&e.preventDefault();const t=a();if(!t?.contains(e.target))return;const i=xze(n.selectionManager),o=xze(n.selectOnFocus),u=a=>{null!=a&&(i.setFocusedKey(a),e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&!YKe(e)&&i.replaceSelection(a))},c=xze(n.keyboardDelegate),d=xze(n.shouldFocusWrap),m=i.focusedKey();switch(e.key){case"vertical"===l()?"ArrowDown":"ArrowRight":if(c.getKeyBelow){let a;e.preventDefault(),a=null!=m?c.getKeyBelow(m):c.getFirstKey?.(),null==a&&d&&(a=c.getFirstKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowUp":"ArrowLeft":if(c.getKeyAbove){let a;e.preventDefault(),a=null!=m?c.getKeyAbove(m):c.getLastKey?.(),null==a&&d&&(a=c.getLastKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowLeft":"ArrowUp":if(c.getKeyLeftOf){e.preventDefault();const a="rtl"===r();let t;t=null!=m?c.getKeyLeftOf(m):a?c.getFirstKey?.():c.getLastKey?.(),u(t)}break;case"vertical"===l()?"ArrowRight":"ArrowDown":if(c.getKeyRightOf){e.preventDefault();const a="rtl"===r();let t;t=null!=m?c.getKeyRightOf(m):a?c.getLastKey?.():c.getFirstKey?.(),u(t)}break;case"Home":if(c.getFirstKey){e.preventDefault();const a=c.getFirstKey(m,QKe(e));null!=a&&(i.setFocusedKey(a),QKe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"End":if(c.getLastKey){e.preventDefault();const a=c.getLastKey(m,QKe(e));null!=a&&(i.setFocusedKey(a),QKe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"PageDown":if(c.getKeyPageBelow&&null!=m){e.preventDefault();u(c.getKeyPageBelow(m))}break;case"PageUp":if(c.getKeyPageAbove&&null!=m){e.preventDefault();u(c.getKeyPageAbove(m))}break;case"a":QKe(e)&&"multiple"===i.selectionMode()&&!0!==xze(n.disallowSelectAll)&&(e.preventDefault(),i.selectAll());break;case"Escape":e.defaultPrevented||(e.preventDefault(),xze(n.disallowEmptySelection)||i.clearSelection());break;case"Tab":if(!xze(n.allowsTabNavigation)){if(e.shiftKey)t.focus();else{const e=function(e,a){const t=a?.tabbable?aKe:eKe,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>a?.from?.contains(e)?NodeFilter.FILTER_REJECT:e.matches(t)&&rKe(e)&&(!a?.accept||a.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});return a?.from&&(n.currentNode=a.from),n}(t,{tabbable:!0});let a,n;do{n=e.lastChild(),n&&(a=n)}while(n);a&&!a.contains(document.activeElement)&&ZOe(a)}break}}},onMouseDown:e=>{i()===e.target&&e.preventDefault()},onFocusIn:e=>{const a=xze(n.selectionManager),t=xze(n.keyboardDelegate),r=xze(n.selectOnFocus);if(a.isFocused())e.currentTarget.contains(e.target)||a.setFocused(!1);else if(e.currentTarget.contains(e.target))if(a.setFocused(!0),null==a.focusedKey()){const n=e=>{null!=e&&(a.setFocusedKey(e),r&&a.replaceSelection(e))},i=e.relatedTarget;i&&e.currentTarget.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?n(a.lastSelectedKey()??t.getLastKey?.()):n(a.firstSelectedKey()??t.getFirstKey?.())}else if(!xze(n.isVirtualized)){const e=i();if(e){e.scrollTop=o.top,e.scrollLeft=o.left;const t=e.querySelector(`[data-key="${a.focusedKey()}"]`);t&&(ZOe(t),hKe(e,t))}}},onFocusOut:e=>{const a=xze(n.selectionManager);e.currentTarget.contains(e.relatedTarget)||a.setFocused(!1)}}}function tHe(e,a){const t=()=>xze(e.selectionManager),n=()=>xze(e.key),i=()=>xze(e.shouldUseVirtualFocus),r=e=>{"none"!==t().selectionMode()&&("single"===t().selectionMode()?t().isSelected(n())&&!t().disallowEmptySelection()?t().toggleSelection(n()):t().replaceSelection(n()):e?.shiftKey?t().extendSelection(n()):"toggle"===t().selectionBehavior()||QKe(e)||"pointerType"in e&&"touch"===e.pointerType?t().toggleSelection(n()):t().replaceSelection(n()))},o=()=>xze(e.disabled)||t().isDisabled(n()),s=()=>!o()&&t().canSelectItem(n());let l=null;const u=za((()=>{if(!i()&&!o())return n()===t().focusedKey()?0:-1})),c=za((()=>xze(e.virtualized)?void 0:n()));return Da(Ha([a,n,i,()=>t().focusedKey(),()=>t().isFocused()],(([a,t,n,i,r])=>{a&&t===i&&r&&!n&&document.activeElement!==a&&(e.focus?e.focus():ZOe(a))}))),{isSelected:()=>t().isSelected(n()),isDisabled:o,allowsSelection:s,tabIndex:u,dataKey:c,onPointerDown:a=>{s()&&(l=a.pointerType,"mouse"!==a.pointerType||0!==a.button||xze(e.shouldSelectOnPressUp)||r(a))},onPointerUp:a=>{s()&&"mouse"===a.pointerType&&0===a.button&&xze(e.shouldSelectOnPressUp)&&xze(e.allowsDifferentPressOrigin)&&r(a)},onClick:a=>{s()&&(xze(e.shouldSelectOnPressUp)&&!xze(e.allowsDifferentPressOrigin)||"mouse"!==l)&&r(a)},onKeyDown:e=>{s()&&["Enter"," "].includes(e.key)&&(YKe(e)?t().toggleSelection(n()):r(e))},onMouseDown:e=>{o()&&e.preventDefault()},onFocus:e=>{const r=a();i()||o()||!r||e.target===r&&t().setFocusedKey(n())}}}var nHe=class{collection;state;constructor(e,a){this.collection=e,this.state=a}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(null==e||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if("none"===this.state.selectionMode())return!1;const a=this.getKey(e);return null!=a&&this.state.selectedKeys().has(a)}isEmpty(){return 0===this.state.selectedKeys().size}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every((a=>e.has(a)))}firstSelectedKey(){let e;for(const a of this.state.selectedKeys()){const t=this.collection().getItem(a);e&&!(null!=t?.index&&null!=e?.index&&t.index<e.index)||(e=t)}return e?.key}lastSelectedKey(){let e;for(const a of this.state.selectedKeys()){const t=this.collection().getItem(a);e&&!(null!=t?.index&&null!=e?.index&&t.index>e.index)||(e=t)}return e?.key}extendSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode())return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const t=this.state.selectedKeys(),n=t.anchorKey||a,i=new ZKe(t,n,a);for(const r of this.getKeyRange(n,t.currentKey||a))i.delete(r);for(const r of this.getKeyRange(a,n))this.canSelectItem(r)&&i.add(r);this.state.setSelectedKeys(i)}getKeyRange(e,a){const t=this.collection().getItem(e),n=this.collection().getItem(a);return t&&n?null!=t.index&&null!=n.index&&t.index<=n.index?this.getKeyRangeInternal(e,a):this.getKeyRangeInternal(a,e):[]}getKeyRangeInternal(e,a){const t=[];let n=e;for(;null!=n;){const e=this.collection().getItem(n);if(e&&"item"===e.type&&t.push(n),n===a)return t;n=this.collection().getKeyAfter(n)}return[]}getKey(e){const a=this.collection().getItem(e);return a?a&&"item"===a.type?a.key:null:e}toggleSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode()&&!this.isSelected(e))return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const t=new ZKe(this.state.selectedKeys());t.has(a)?t.delete(a):this.canSelectItem(a)&&(t.add(a),t.anchorKey=a,t.currentKey=a),this.disallowEmptySelection()&&0===t.size||this.state.setSelectedKeys(t)}replaceSelection(e){if("none"===this.selectionMode())return;const a=this.getKey(e);if(null==a)return;const t=this.canSelectItem(a)?new ZKe([a],a,a):new ZKe;this.state.setSelectedKeys(t)}setSelectedKeys(e){if("none"===this.selectionMode())return;const a=new ZKe;for(const t of e){const e=this.getKey(t);if(null!=e&&(a.add(e),"single"===this.selectionMode()))break}this.state.setSelectedKeys(a)}selectAll(){"multiple"===this.selectionMode()&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new ZKe)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,a){"none"!==this.selectionMode()&&("single"===this.selectionMode()?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):"toggle"===this.selectionBehavior()||a&&"touch"===a.pointerType?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const a=this.selectedKeys();if(e.size!==a.size)return!1;for(const t of e)if(!a.has(t))return!1;for(const t of a)if(!e.has(t))return!1;return!0}canSelectItem(e){if("none"===this.state.selectionMode())return!1;const a=this.collection().getItem(e);return null!=a&&!a.disabled}isDisabled(e){const a=this.collection().getItem(e);return!a||a.disabled}getAllSelectableKeys(){const e=[];return(a=>{for(;null!=a;){if(this.canSelectItem(a)){const t=this.collection().getItem(a);if(!t)continue;"item"===t.type&&e.push(a)}a=this.collection().getKeyAfter(a)}})(this.collection().getFirstKey()),e}},iHe=class{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const n of e)this.keyMap.set(n.key,n);if(0===this.keyMap.size)return;let a,t=0;for(const[n,i]of this.keyMap)a?(a.nextKey=n,i.prevKey=a.key):(this.firstKey=n,i.prevKey=void 0),"item"===i.type&&(i.index=t++),a=i,a.nextKey=void 0;this.lastKey=a.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){return this.keyMap.get(e)?.prevKey}getKeyAfter(e){return this.keyMap.get(e)?.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const a=[...this.getKeys()];return this.getItem(a[e])}};var rHe,oHe=e=>"function"==typeof e?e():e,sHe=e=>{const a=za((()=>{const a=oHe(e.element);if(a)return getComputedStyle(a)})),t=()=>a()?.animationName??"none",[n,i]=La(oHe(e.show)?"present":"hidden");let r="none";return Da((n=>{const o=oHe(e.show);return Ka((()=>{if(n===o)return o;const e=r,s=t();if(o)i("present");else if("none"===s||"none"===a()?.display)i("hidden");else{i(!0===n&&e!==s?"hiding":"hidden")}})),o})),Da((()=>{const a=oHe(e.element);if(!a)return;const o=e=>{e.target===a&&(r=t())},s=e=>{const r=t().includes(e.animationName);e.target===a&&r&&"hiding"===n()&&i("hidden")};a.addEventListener("animationstart",o),a.addEventListener("animationcancel",s),a.addEventListener("animationend",s),Fa((()=>{a.removeEventListener("animationstart",o),a.removeEventListener("animationcancel",s),a.removeEventListener("animationend",s)}))})),{present:()=>"present"===n()||"hiding"===n(),state:n}},lHe="data-kb-top-layer",uHe=!1,cHe=[];function dHe(e){return cHe.findIndex((a=>a.node===e))}function mHe(){return cHe.filter((e=>e.isPointerBlocking))}function hHe(){return mHe().length>0}function pHe(e){const a=dHe([...mHe()].slice(-1)[0]?.node);return dHe(e)<a}var gHe={layers:cHe,isTopMostLayer:function(e){return cHe[cHe.length-1].node===e},hasPointerBlockingLayer:hHe,isBelowPointerBlockingLayer:pHe,addLayer:function(e){cHe.push(e)},removeLayer:function(e){const a=dHe(e);a<0||cHe.splice(a,1)},indexOf:dHe,find:function(e){return cHe[dHe(e)]},assignPointerEventToLayers:function(){for(const{node:e}of cHe)e.style.pointerEvents=pHe(e)?"none":"auto"},disableBodyPointerEvents:function(e){if(hHe()&&!uHe){const a=IOe(e);rHe=document.body.style.pointerEvents,a.body.style.pointerEvents="none",uHe=!0}},restoreBodyPointerEvents:function(e){if(hHe())return;const a=IOe(e);a.body.style.pointerEvents=rHe,0===a.body.style.length&&a.body.removeAttribute("style"),uHe=!1}};_Ke({},{Button:()=>yHe,Root:()=>vHe});var fHe=["button","color","file","image","reset","submit"];function vHe(e){let a;const t=uKe({type:"button"},e),[n,i]=bt(t,["ref","type","disabled"]),r=vKe((()=>a),(()=>"button")),o=za((()=>{const e=r();return null!=e&&function(e){const a=e.tagName.toLowerCase();return"button"===a||!("input"!==a||!e.type)&&-1!==fHe.indexOf(e.type)}({tagName:e,type:n.type})})),s=za((()=>"input"===r())),l=za((()=>"a"===r()&&null!=a?.getAttribute("href")));return ht(bKe,yt({as:"button",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)},get type(){return o()||s()?n.type:void 0},get role(){return o()||l()?void 0:"button"},get tabIndex(){return o()||l()||n.disabled?void 0:0},get disabled(){return o()||s()?n.disabled:void 0},get"aria-disabled"(){return!(o()||s()||!n.disabled)||void 0},get"data-disabled"(){return n.disabled?"":void 0}},i))}var yHe=vHe,bHe=["top","right","bottom","left"],kHe=Math.min,SHe=Math.max,wHe=Math.round,AHe=Math.floor,CHe=e=>({x:e,y:e}),MHe={left:"right",right:"left",bottom:"top",top:"bottom"},THe={start:"end",end:"start"};function xHe(e,a,t){return SHe(e,kHe(a,t))}function EHe(e,a){return"function"==typeof e?e(a):e}function NHe(e){return e.split("-")[0]}function _He(e){return e.split("-")[1]}function PHe(e){return"x"===e?"y":"x"}function jHe(e){return"y"===e?"height":"width"}function LHe(e){return["top","bottom"].includes(NHe(e))?"y":"x"}function BHe(e){return PHe(LHe(e))}function RHe(e){return e.replace(/start|end/g,(e=>THe[e]))}function DHe(e){return e.replace(/left|right|bottom|top/g,(e=>MHe[e]))}function zHe(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function OHe(e){const{x:a,y:t,width:n,height:i}=e;return{width:n,height:i,top:t,left:a,right:a+n,bottom:t+i,x:a,y:t}}function KHe(e,a,t){let{reference:n,floating:i}=e;const r=LHe(a),o=BHe(a),s=jHe(o),l=NHe(a),u="y"===r,c=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,m=n[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:n.y-i.height};break;case"bottom":h={x:c,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-i.width,y:d};break;default:h={x:n.x,y:n.y}}switch(_He(a)){case"start":h[o]-=m*(t&&u?-1:1);break;case"end":h[o]+=m*(t&&u?-1:1)}return h}async function HHe(e,a){var t;void 0===a&&(a={});const{x:n,y:i,platform:r,rects:o,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=EHe(a,e),p=zHe(h),g=s[m?"floating"===d?"reference":"floating":d],f=OHe(await r.getClippingRect({element:null==(t=await(null==r.isElement?void 0:r.isElement(g)))||t?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),v="floating"===d?{x:n,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),b=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},k=OHe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:y,strategy:l}):v);return{top:(f.top-k.top+p.top)/b.y,bottom:(k.bottom-f.bottom+p.bottom)/b.y,left:(f.left-k.left+p.left)/b.x,right:(k.right-f.right+p.right)/b.x}}function IHe(e,a){return{top:e.top-a.height,right:e.right-a.width,bottom:e.bottom-a.height,left:e.left-a.width}}function FHe(e){return bHe.some((a=>e[a]>=0))}function GHe(e){return UHe(e)?(e.nodeName||"").toLowerCase():"#document"}function VHe(e){var a;return(null==e||null==(a=e.ownerDocument)?void 0:a.defaultView)||window}function JHe(e){var a;return null==(a=(UHe(e)?e.ownerDocument:e.document)||window.document)?void 0:a.documentElement}function UHe(e){return e instanceof Node||e instanceof VHe(e).Node}function WHe(e){return e instanceof Element||e instanceof VHe(e).Element}function qHe(e){return e instanceof HTMLElement||e instanceof VHe(e).HTMLElement}function $He(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof VHe(e).ShadowRoot)}function ZHe(e){const{overflow:a,overflowX:t,overflowY:n,display:i}=tIe(e);return/auto|scroll|overlay|hidden|clip/.test(a+n+t)&&!["inline","contents"].includes(i)}function YHe(e){return["table","td","th"].includes(GHe(e))}function QHe(e){return[":popover-open",":modal"].some((a=>{try{return e.matches(a)}catch(rXe){return!1}}))}function XHe(e){const a=eIe(),t=WHe(e)?tIe(e):e;return"none"!==t.transform||"none"!==t.perspective||!!t.containerType&&"normal"!==t.containerType||!a&&!!t.backdropFilter&&"none"!==t.backdropFilter||!a&&!!t.filter&&"none"!==t.filter||["transform","perspective","filter"].some((e=>(t.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(t.contain||"").includes(e)))}function eIe(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function aIe(e){return["html","body","#document"].includes(GHe(e))}function tIe(e){return VHe(e).getComputedStyle(e)}function nIe(e){return WHe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function iIe(e){if("html"===GHe(e))return e;const a=e.assignedSlot||e.parentNode||$He(e)&&e.host||JHe(e);return $He(a)?a.host:a}function rIe(e){const a=iIe(e);return aIe(a)?e.ownerDocument?e.ownerDocument.body:e.body:qHe(a)&&ZHe(a)?a:rIe(a)}function oIe(e,a,t){var n;void 0===a&&(a=[]),void 0===t&&(t=!0);const i=rIe(e),r=i===(null==(n=e.ownerDocument)?void 0:n.body),o=VHe(i);return r?a.concat(o,o.visualViewport||[],ZHe(i)?i:[],o.frameElement&&t?oIe(o.frameElement):[]):a.concat(i,oIe(i,[],t))}function sIe(e){const a=tIe(e);let t=parseFloat(a.width)||0,n=parseFloat(a.height)||0;const i=qHe(e),r=i?e.offsetWidth:t,o=i?e.offsetHeight:n,s=wHe(t)!==r||wHe(n)!==o;return s&&(t=r,n=o),{width:t,height:n,$:s}}function lIe(e){return WHe(e)?e:e.contextElement}function uIe(e){const a=lIe(e);if(!qHe(a))return CHe(1);const t=a.getBoundingClientRect(),{width:n,height:i,$:r}=sIe(a);let o=(r?wHe(t.width):t.width)/n,s=(r?wHe(t.height):t.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var cIe=CHe(0);function dIe(e){const a=VHe(e);return eIe()&&a.visualViewport?{x:a.visualViewport.offsetLeft,y:a.visualViewport.offsetTop}:cIe}function mIe(e,a,t,n){void 0===a&&(a=!1),void 0===t&&(t=!1);const i=e.getBoundingClientRect(),r=lIe(e);let o=CHe(1);a&&(n?WHe(n)&&(o=uIe(n)):o=uIe(e));const s=function(e,a,t){return void 0===a&&(a=!1),!(!t||a&&t!==VHe(e))&&a}(r,t,n)?dIe(r):CHe(0);let l=(i.left+s.x)/o.x,u=(i.top+s.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(r){const e=VHe(r),a=n&&WHe(n)?VHe(n):n;let t=e,i=t.frameElement;for(;i&&n&&a!==t;){const e=uIe(i),a=i.getBoundingClientRect(),n=tIe(i),r=a.left+(i.clientLeft+parseFloat(n.paddingLeft))*e.x,o=a.top+(i.clientTop+parseFloat(n.paddingTop))*e.y;l*=e.x,u*=e.y,c*=e.x,d*=e.y,l+=r,u+=o,t=VHe(i),i=t.frameElement}}return OHe({width:c,height:d,x:l,y:u})}function hIe(e){return mIe(JHe(e)).left+nIe(e).scrollLeft}function pIe(e,a,t){let n;if("viewport"===a)n=function(e,a){const t=VHe(e),n=JHe(e),i=t.visualViewport;let r=n.clientWidth,o=n.clientHeight,s=0,l=0;if(i){r=i.width,o=i.height;const e=eIe();(!e||e&&"fixed"===a)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:o,x:s,y:l}}(e,t);else if("document"===a)n=function(e){const a=JHe(e),t=nIe(e),n=e.ownerDocument.body,i=SHe(a.scrollWidth,a.clientWidth,n.scrollWidth,n.clientWidth),r=SHe(a.scrollHeight,a.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+hIe(e);const s=-t.scrollTop;return"rtl"===tIe(n).direction&&(o+=SHe(a.clientWidth,n.clientWidth)-i),{width:i,height:r,x:o,y:s}}(JHe(e));else if(WHe(a))n=function(e,a){const t=mIe(e,!0,"fixed"===a),n=t.top+e.clientTop,i=t.left+e.clientLeft,r=qHe(e)?uIe(e):CHe(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:n*r.y}}(a,t);else{const t=dIe(e);n={...a,x:a.x-t.x,y:a.y-t.y}}return OHe(n)}function gIe(e,a){const t=iIe(e);return!(t===a||!WHe(t)||aIe(t))&&("fixed"===tIe(t).position||gIe(t,a))}function fIe(e,a,t){const n=qHe(a),i=JHe(a),r="fixed"===t,o=mIe(e,!0,r,a);let s={scrollLeft:0,scrollTop:0};const l=CHe(0);if(n||!n&&!r)if(("body"!==GHe(a)||ZHe(i))&&(s=nIe(a)),n){const e=mIe(a,!0,r,a);l.x=e.x+a.clientLeft,l.y=e.y+a.clientTop}else i&&(l.x=hIe(i));return{x:o.left+s.scrollLeft-l.x,y:o.top+s.scrollTop-l.y,width:o.width,height:o.height}}function vIe(e){return"static"===tIe(e).position}function yIe(e,a){return qHe(e)&&"fixed"!==tIe(e).position?a?a(e):e.offsetParent:null}function bIe(e,a){const t=VHe(e);if(QHe(e))return t;if(!qHe(e)){let a=iIe(e);for(;a&&!aIe(a);){if(WHe(a)&&!vIe(a))return a;a=iIe(a)}return t}let n=yIe(e,a);for(;n&&YHe(n)&&vIe(n);)n=yIe(n,a);return n&&aIe(n)&&vIe(n)&&!XHe(n)?t:n||function(e){let a=iIe(e);for(;qHe(a)&&!aIe(a);){if(XHe(a))return a;if(QHe(a))return null;a=iIe(a)}return null}(e)||t}var kIe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:a,rect:t,offsetParent:n,strategy:i}=e;const r="fixed"===i,o=JHe(n),s=!!a&&QHe(a.floating);if(n===o||s&&r)return t;let l={scrollLeft:0,scrollTop:0},u=CHe(1);const c=CHe(0),d=qHe(n);if((d||!d&&!r)&&(("body"!==GHe(n)||ZHe(o))&&(l=nIe(n)),qHe(n))){const e=mIe(n);u=uIe(n),c.x=e.x+n.clientLeft,c.y=e.y+n.clientTop}return{width:t.width*u.x,height:t.height*u.y,x:t.x*u.x-l.scrollLeft*u.x+c.x,y:t.y*u.y-l.scrollTop*u.y+c.y}},getDocumentElement:JHe,getClippingRect:function(e){let{element:a,boundary:t,rootBoundary:n,strategy:i}=e;const r=[..."clippingAncestors"===t?QHe(a)?[]:function(e,a){const t=a.get(e);if(t)return t;let n=oIe(e,[],!1).filter((e=>WHe(e)&&"body"!==GHe(e))),i=null;const r="fixed"===tIe(e).position;let o=r?iIe(e):e;for(;WHe(o)&&!aIe(o);){const a=tIe(o),t=XHe(o);t||"fixed"!==a.position||(i=null),(r?!t&&!i:!t&&"static"===a.position&&i&&["absolute","fixed"].includes(i.position)||ZHe(o)&&!t&&gIe(e,o))?n=n.filter((e=>e!==o)):i=a,o=iIe(o)}return a.set(e,n),n}(a,this._c):[].concat(t),n],o=r.reduce(((e,t)=>{const n=pIe(a,t,i);return e.top=SHe(n.top,e.top),e.right=kHe(n.right,e.right),e.bottom=kHe(n.bottom,e.bottom),e.left=SHe(n.left,e.left),e}),pIe(a,r[0],i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:bIe,getElementRects:async function(e){const a=this.getOffsetParent||bIe,t=this.getDimensions,n=await t(e.floating);return{reference:fIe(e.reference,await a(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:a,height:t}=sIe(e);return{width:a,height:t}},getScale:uIe,isElement:WHe,isRTL:function(e){return"rtl"===tIe(e).direction}};function SIe(e,a,t,n){void 0===n&&(n={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=n,u=lIe(e),c=i||r?[...u?oIe(u):[],...oIe(a)]:[];c.forEach((e=>{i&&e.addEventListener("scroll",t,{passive:!0}),r&&e.addEventListener("resize",t)}));const d=u&&s?function(e,a){let t,n=null;const i=JHe(e);function r(){var e;clearTimeout(t),null==(e=n)||e.disconnect(),n=null}return function o(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),r();const{left:u,top:c,width:d,height:m}=e.getBoundingClientRect();if(s||a(),!d||!m)return;const h={rootMargin:-AHe(c)+"px "+-AHe(i.clientWidth-(u+d))+"px "+-AHe(i.clientHeight-(c+m))+"px "+-AHe(u)+"px",threshold:SHe(0,kHe(1,l))||1};let p=!0;function g(e){const a=e[0].intersectionRatio;if(a!==l){if(!p)return o();a?o(!1,a):t=setTimeout((()=>{o(!1,1e-7)}),1e3)}p=!1}try{n=new IntersectionObserver(g,{...h,root:i.ownerDocument})}catch(rXe){n=new IntersectionObserver(g,h)}n.observe(e)}(!0),r}(u,t):null;let m,h=-1,p=null;o&&(p=new ResizeObserver((e=>{let[n]=e;n&&n.target===u&&p&&(p.unobserve(a),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(a)}))),t()})),u&&!l&&p.observe(u),p.observe(a));let g=l?mIe(e):null;return l&&function a(){const n=mIe(e);!g||n.x===g.x&&n.y===g.y&&n.width===g.width&&n.height===g.height||t();g=n,m=requestAnimationFrame(a)}(),t(),()=>{var e;c.forEach((e=>{i&&e.removeEventListener("scroll",t),r&&e.removeEventListener("resize",t)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var wIe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(a){var t,n;const{x:i,y:r,placement:o,middlewareData:s}=a,l=await async function(e,a){const{placement:t,platform:n,elements:i}=e,r=await(null==n.isRTL?void 0:n.isRTL(i.floating)),o=NHe(t),s=_He(t),l="y"===LHe(t),u=["left","top"].includes(o)?-1:1,c=r&&l?-1:1,d=EHe(a,e);let{mainAxis:m,crossAxis:h,alignmentAxis:p}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return s&&"number"==typeof p&&(h="end"===s?-1*p:p),l?{x:h*c,y:m*u}:{x:m*u,y:h*c}}(a,e);return o===(null==(t=s.offset)?void 0:t.placement)&&null!=(n=s.arrow)&&n.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:o}}}}},AIe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(a){const{x:t,y:n,placement:i}=a,{mainAxis:r=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:a,y:t}=e;return{x:a,y:t}}},...l}=EHe(e,a),u={x:t,y:n},c=await HHe(a,l),d=LHe(NHe(i)),m=PHe(d);let h=u[m],p=u[d];if(r){h=xHe(h+c["y"===m?"top":"left"],h,h-c["y"===m?"bottom":"right"])}if(o){p=xHe(p+c["y"===d?"top":"left"],p,p-c["y"===d?"bottom":"right"])}const g=s.fn({...a,[m]:h,[d]:p});return{...g,data:{x:g.x-t,y:g.y-n}}}}},CIe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(a){var t,n;const{placement:i,middlewareData:r,rects:o,initialPlacement:s,platform:l,elements:u}=a,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...f}=EHe(e,a);if(null!=(t=r.arrow)&&t.alignmentOffset)return{};const v=NHe(i),y=LHe(s),b=NHe(s)===s,k=await(null==l.isRTL?void 0:l.isRTL(u.floating)),S=m||(b||!g?[DHe(s)]:function(e){const a=DHe(e);return[RHe(e),a,RHe(a)]}(s)),w="none"!==p;!m&&w&&S.push(...function(e,a,t,n){const i=_He(e);let r=function(e,a,t){const n=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return t?a?i:n:a?n:i;case"left":case"right":return a?r:o;default:return[]}}(NHe(e),"start"===t,n);return i&&(r=r.map((e=>e+"-"+i)),a&&(r=r.concat(r.map(RHe)))),r}(s,g,p,k));const A=[s,...S],C=await HHe(a,f),M=[];let T=(null==(n=r.flip)?void 0:n.overflows)||[];if(c&&M.push(C[v]),d){const e=function(e,a,t){void 0===t&&(t=!1);const n=_He(e),i=BHe(e),r=jHe(i);let o="x"===i?n===(t?"end":"start")?"right":"left":"start"===n?"bottom":"top";return a.reference[r]>a.floating[r]&&(o=DHe(o)),[o,DHe(o)]}(i,o,k);M.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:i,overflows:M}],!M.every((e=>e<=0))){var x,E;const e=((null==(x=r.flip)?void 0:x.index)||0)+1,a=A[e];if(a)return{data:{index:e,overflows:T},reset:{placement:a}};let t=null==(E=T.filter((e=>e.overflows[0]<=0)).sort(((e,a)=>e.overflows[1]-a.overflows[1]))[0])?void 0:E.placement;if(!t)switch(h){case"bestFit":{var N;const e=null==(N=T.filter((e=>{if(w){const a=LHe(e.placement);return a===y||"y"===a}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,a)=>e+a),0)])).sort(((e,a)=>e[1]-a[1]))[0])?void 0:N[0];e&&(t=e);break}case"initialPlacement":t=s}if(i!==t)return{reset:{placement:t}}}return{}}}},MIe=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(a){const{placement:t,rects:n,platform:i,elements:r}=a,{apply:o=()=>{},...s}=EHe(e,a),l=await HHe(a,s),u=NHe(t),c=_He(t),d="y"===LHe(t),{width:m,height:h}=n.floating;let p,g;"top"===u||"bottom"===u?(p=u,g=c===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(g=u,p="end"===c?"top":"bottom");const f=h-l.top-l.bottom,v=m-l.left-l.right,y=kHe(h-l[p],f),b=kHe(m-l[g],v),k=!a.middlewareData.shift;let S=y,w=b;if(d?w=c||k?kHe(b,v):v:S=c||k?kHe(y,f):f,k&&!c){const e=SHe(l.left,0),a=SHe(l.right,0),t=SHe(l.top,0),n=SHe(l.bottom,0);d?w=m-2*(0!==e||0!==a?e+a:SHe(l.left,l.right)):S=h-2*(0!==t||0!==n?t+n:SHe(l.top,l.bottom))}await o({...a,availableWidth:w,availableHeight:S});const A=await i.getDimensions(r.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}},TIe=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(a){const{rects:t}=a,{strategy:n="referenceHidden",...i}=EHe(e,a);switch(n){case"referenceHidden":{const e=IHe(await HHe(a,{...i,elementContext:"reference"}),t.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:FHe(e)}}}case"escaped":{const e=IHe(await HHe(a,{...i,altBoundary:!0}),t.floating);return{data:{escapedOffsets:e,escaped:FHe(e)}}}default:return{}}}}},xIe=e=>({name:"arrow",options:e,async fn(a){const{x:t,y:n,placement:i,rects:r,platform:o,elements:s,middlewareData:l}=a,{element:u,padding:c=0}=EHe(e,a)||{};if(null==u)return{};const d=zHe(c),m={x:t,y:n},h=BHe(i),p=jHe(h),g=await o.getDimensions(u),f="y"===h,v=f?"top":"left",y=f?"bottom":"right",b=f?"clientHeight":"clientWidth",k=r.reference[p]+r.reference[h]-m[h]-r.floating[p],S=m[h]-r.reference[h],w=await(null==o.getOffsetParent?void 0:o.getOffsetParent(u));let A=w?w[b]:0;A&&await(null==o.isElement?void 0:o.isElement(w))||(A=s.floating[b]||r.floating[p]);const C=k/2-S/2,M=A/2-g[p]/2-1,T=kHe(d[v],M),x=kHe(d[y],M),E=T,N=A-g[p]-x,_=A/2-g[p]/2+C,P=xHe(E,_,N),j=!l.arrow&&null!=_He(i)&&_!==P&&r.reference[p]/2-(_<E?T:x)-g[p]/2<0,L=j?_<E?_-E:_-N:0;return{[h]:m[h]+L,data:{[h]:P,centerOffset:_-P-L,...j&&{alignmentOffset:L}},reset:j}}}),EIe=(e,a,t)=>{const n={platform:kIe,...t},i={...n.platform,_c:new Map};return(async(e,a,t)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:o}=t,s=r.filter(Boolean),l=await(null==o.isRTL?void 0:o.isRTL(a));let u=await o.getElementRects({reference:e,floating:a,strategy:i}),{x:c,y:d}=KHe(u,n,l),m=n,h={},p=0;for(let g=0;g<s.length;g++){const{name:t,fn:r}=s[g],{x:f,y:v,data:y,reset:b}=await r({x:c,y:d,initialPlacement:n,placement:m,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:a}});c=null!=f?f:c,d=null!=v?v:d,h={...h,[t]:{...h[t],...y}},b&&p<=50&&(p++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(u=!0===b.rects?await o.getElementRects({reference:e,floating:a,strategy:i}):b.rects),({x:c,y:d}=KHe(u,m,l))),g=-1)}return{x:c,y:d,placement:m,strategy:i,middlewareData:h}})(e,a,{...n,platform:i})},NIe=Wa();function _Ie(){const e=qa(NIe);if(void 0===e)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var PIe=Ot('<svg display="block" viewBox="0 0 30 30" style="transform:scale(1.02)"><g><path fill="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"></path><path stroke="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z">'),jIe={top:180,right:-90,bottom:0,left:90};function LIe(e){const a=_Ie(),t=uKe({size:30},e),[n,i]=bt(t,["ref","style","size"]),r=()=>a.currentPlacement().split("-")[0],o=function(e){const[a,t]=La();return Da((()=>{const a=e();var n;a&&t((n=a,IOe(n).defaultView||window).getComputedStyle(a))})),a}(a.contentRef),s=()=>2*Number.parseInt(o()?.getPropertyValue(`border-${r()}-width`)||"0px")*(30/n.size);return ht(bKe,yt({as:"div",ref(e){const t=kOe(a.setArrowRef,n.ref);"function"==typeof t&&t(e)},"aria-hidden":"true",get style(){return ROe({position:"absolute","font-size":`${n.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:o()?.getPropertyValue("background-color")||"none",stroke:o()?.getPropertyValue(`border-${r()}-color`)||"none","stroke-width":s()},n.style)}},i,{get children(){const e=PIe(),a=e.firstChild;return Ra((()=>Ht(a,"transform",`rotate(${jIe[r()]} 15 15) translate(0 2)`))),e}}))}function BIe(e){const{x:a=0,y:t=0,width:n=0,height:i=0}=e??{};if("function"==typeof DOMRect)return new DOMRect(a,t,n,i);const r={x:a,y:t,width:n,height:i,top:t,right:a+n,bottom:t+i,left:a};return{...r,toJSON:()=>r}}function RIe(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var DIe={top:"bottom",right:"left",bottom:"top",left:"right"};var zIe=Object.assign((function(e){const a=uKe({getAnchorRect:e=>e?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[t,n]=La(),[i,r]=La(),[o,s]=La(a.placement),l=()=>{return e=a.anchorRef?.(),t=a.getAnchorRect,{contextElement:e,getBoundingClientRect:()=>{const a=t(e);return a?BIe(a):e?e.getBoundingClientRect():BIe()}};var e,t},{direction:u}=qKe();async function c(){const e=l(),n=t(),r=i();if(!e||!n)return;const o=(r?.clientHeight||0)/2,c="number"==typeof a.gutter?a.gutter+o:a.gutter??o;n.style.setProperty("--kb-popper-content-overflow-padding",`${a.overflowPadding}px`),e.getBoundingClientRect();const d=[wIe((({placement:e})=>{const t=!!e.split("-")[1];return{mainAxis:c,crossAxis:t?void 0:a.shift,alignmentAxis:a.shift}}))];if(!1!==a.flip){const e="string"==typeof a.flip?a.flip.split(" "):void 0;if(void 0!==e&&!e.every(RIe))throw new Error("`flip` expects a spaced-delimited list of placements");d.push(CIe({padding:a.overflowPadding,fallbackPlacements:e}))}(a.slide||a.overlap)&&d.push(AIe({mainAxis:a.slide,crossAxis:a.overlap,padding:a.overflowPadding})),d.push(MIe({padding:a.overflowPadding,apply({availableWidth:e,availableHeight:t,rects:i}){const r=Math.round(i.reference.width);e=Math.floor(e),t=Math.floor(t),n.style.setProperty("--kb-popper-anchor-width",`${r}px`),n.style.setProperty("--kb-popper-content-available-width",`${e}px`),n.style.setProperty("--kb-popper-content-available-height",`${t}px`),a.sameWidth&&(n.style.width=`${r}px`),a.fitViewport&&(n.style.maxWidth=`${e}px`,n.style.maxHeight=`${t}px`)}})),a.hideWhenDetached&&d.push(TIe({padding:a.detachedPadding})),r&&d.push(xIe({element:r,padding:a.arrowPadding}));const m=await EIe(e,n,{placement:a.placement,strategy:"absolute",middleware:d,platform:{...kIe,isRTL:()=>"rtl"===u()}});if(s(m.placement),a.onCurrentPlacementChange?.(m.placement),!n)return;n.style.setProperty("--kb-popper-content-transform-origin",function(e,a){const[t,n]=e.split("-"),i=DIe[t];return n?"left"===t||"right"===t?`${i} ${"start"===n?"top":"bottom"}`:"start"===n?`${i} ${"rtl"===a?"right":"left"}`:`${i} ${"rtl"===a?"left":"right"}`:`${i} center`}(m.placement,u()));const h=Math.round(m.x),p=Math.round(m.y);let g;if(a.hideWhenDetached&&(g=m.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(n.style,{top:"0",left:"0",transform:`translate3d(${h}px, ${p}px, 0)`,visibility:g}),r&&m.middlewareData.arrow){const{x:e,y:a}=m.middlewareData.arrow,t=m.placement.split("-")[0];Object.assign(r.style,{left:null!=e?`${e}px`:"",top:null!=a?`${a}px`:"",[t]:"100%"})}}return Da((()=>{const e=l(),a=t();if(!e||!a)return;Fa(SIe(e,a,c,{elementResize:"function"==typeof ResizeObserver}))})),Da((()=>{const e=t(),n=a.contentRef?.();e&&n&&queueMicrotask((()=>{e.style.zIndex=getComputedStyle(n).zIndex}))})),ht(NIe.Provider,{value:{currentPlacement:o,contentRef:()=>a.contentRef?.(),setPositionerRef:n,setArrowRef:r},get children(){return a.children}})}),{Arrow:LIe,Context:NIe,usePopperContext:_Ie,Positioner:function(e){const a=_Ie(),[t,n]=bt(e,["ref","style"]);return ht(bKe,yt({as:"div",ref(e){const n=kOe(a.setPositionerRef,t.ref);"function"==typeof n&&n(e)},"data-popper-positioner":"",get style(){return ROe({position:"absolute",top:0,left:0,"min-width":"max-content"},t.style)}},n))}});var OIe="interactOutside.pointerDownOutside",KIe="interactOutside.focusOutside";var HIe=Wa();function IIe(e){let a;const t=qa(HIe),[n,i]=bt(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]);!function(e,a){let t,n=lKe;const i=()=>IOe(a()),r=a=>e.onPointerDownOutside?.(a),o=a=>e.onFocusOutside?.(a),s=a=>e.onInteractOutside?.(a),l=t=>{const n=t.target;return n instanceof HTMLElement&&!n.closest(`[${lHe}]`)&&!!KOe(i(),n)&&!KOe(a(),n)&&!e.shouldExcludeElement?.(n)},u=e=>{function t(){const t=a(),n=e.target;if(!t||!n||!l(e))return;const i=qOe([r,s]);n.addEventListener(OIe,i,{once:!0});const o=new CustomEvent(OIe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:2===e.button||$Oe(e)&&0===e.button}});n.dispatchEvent(o)}"touch"===e.pointerType?(i().removeEventListener("click",t),n=t,i().addEventListener("click",t,{once:!0})):t()},c=e=>{const t=a(),n=e.target;if(!t||!n||!l(e))return;const i=qOe([o,s]);n.addEventListener(KIe,i,{once:!0});const r=new CustomEvent(KIe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:!1}});n.dispatchEvent(r)};Da((()=>{xze(e.isDisabled)||(t=window.setTimeout((()=>{i().addEventListener("pointerdown",u,!0)}),0),i().addEventListener("focusin",c,!0),Fa((()=>{window.clearTimeout(t),i().removeEventListener("click",n),i().removeEventListener("pointerdown",u,!0),i().removeEventListener("focusin",c,!0)})))}))}({shouldExcludeElement:e=>!!a&&(n.excludedElements?.some((a=>KOe(a(),e)))||[...r].some((a=>KOe(a,e)))),onPointerDownOutside:e=>{a&&!gHe.isBelowPointerBlockingLayer(a)&&(n.bypassTopMostLayerCheck||gHe.isTopMostLayer(a))&&(n.onPointerDownOutside?.(e),n.onInteractOutside?.(e),e.defaultPrevented||n.onDismiss?.())},onFocusOutside:e=>{n.onFocusOutside?.(e),n.onInteractOutside?.(e),e.defaultPrevented||n.onDismiss?.()}},(()=>a)),function(e){const a=a=>{a.key===GOe.Escape&&e.onEscapeKeyDown?.(a)};Da((()=>{if(xze(e.isDisabled))return;const t=e.ownerDocument?.()??IOe();t.addEventListener("keydown",a),Fa((()=>{t.removeEventListener("keydown",a)}))}))}({ownerDocument:()=>IOe(a),onEscapeKeyDown:e=>{a&&gHe.isTopMostLayer(a)&&(n.onEscapeKeyDown?.(e),!e.defaultPrevented&&n.onDismiss&&(e.preventDefault(),n.onDismiss()))}}),Ia((()=>{if(!a)return;gHe.addLayer({node:a,isPointerBlocking:n.disableOutsidePointerEvents,dismiss:n.onDismiss});const e=t?.registerNestedLayer(a);gHe.assignPointerEventToLayers(),gHe.disableBodyPointerEvents(a),Fa((()=>{a&&(gHe.removeLayer(a),e?.(),gHe.assignPointerEventToLayers(),gHe.restoreBodyPointerEvents(a))}))})),Da(Ha([()=>a,()=>n.disableOutsidePointerEvents],(([e,a])=>{if(!e)return;const t=gHe.find(e);t&&t.isPointerBlocking!==a&&(t.isPointerBlocking=a,gHe.assignPointerEventToLayers()),a&&gHe.disableBodyPointerEvents(e),Fa((()=>{gHe.restoreBodyPointerEvents(e)}))}),{defer:!0}));return ht(HIe.Provider,{value:{registerNestedLayer:e=>{r.add(e);const a=t?.registerNestedLayer(e);return()=>{r.delete(e),a?.()}}},get children(){return ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)}},i))}})}function FIe(e={}){const[a,t]=EKe({value:()=>xze(e.open),defaultValue:()=>!!xze(e.defaultOpen),onChange:a=>e.onOpenChange?.(a)}),n=()=>{t(!0)},i=()=>{t(!1)};return{isOpen:a,setIsOpen:t,open:n,close:i,toggle:()=>{a()?i():n()}}}var GIe={};_Ke(GIe,{Description:()=>AKe,ErrorMessage:()=>CKe,Item:()=>qIe,ItemControl:()=>$Ie,ItemDescription:()=>ZIe,ItemIndicator:()=>YIe,ItemInput:()=>QIe,ItemLabel:()=>XIe,Label:()=>eFe,RadioGroup:()=>tFe,Root:()=>aFe});var VIe=Wa();function JIe(){const e=qa(VIe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var UIe=Wa();function WIe(){const e=qa(UIe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function qIe(e){const a=wKe(),t=JIe(),n=uKe({id:`${a.generateId("item")}-${wt()}`},e),[i,r]=bt(n,["value","disabled","onPointerDown"]),[o,s]=La(),[l,u]=La(),[c,d]=La(),[m,h]=La(),[p,g]=La(!1),f=za((()=>t.isSelectedValue(i.value))),v=za((()=>i.disabled||a.isDisabled()||!1)),y=e=>{WOe(e,i.onPointerDown),p()&&e.preventDefault()},b=za((()=>({...a.dataset(),"data-disabled":v()?"":void 0,"data-checked":f()?"":void 0}))),k={value:()=>i.value,dataset:b,isSelected:f,isDisabled:v,inputId:o,labelId:l,descriptionId:c,inputRef:m,select:()=>t.setSelectedValue(i.value),generateId:OOe((()=>r.id)),registerInput:fKe(s),registerLabel:fKe(u),registerDescription:fKe(d),setIsFocused:g,setInputRef:h};return ht(UIe.Provider,{value:k,get children(){return ht(bKe,yt({as:"div",role:"group",onPointerDown:y},b,r))}})}function $Ie(e){const a=WIe(),t=uKe({id:a.generateId("control")},e),[n,i]=bt(t,["onClick","onKeyDown"]);return ht(bKe,yt({as:"div",onClick:e=>{WOe(e,n.onClick),a.select(),a.inputRef()?.focus()},onKeyDown:e=>{WOe(e,n.onKeyDown),e.key===GOe.Space&&(a.select(),a.inputRef()?.focus())}},(()=>a.dataset()),i))}function ZIe(e){const a=WIe(),t=uKe({id:a.generateId("description")},e);return Da((()=>Fa(a.registerDescription(t.id)))),ht(bKe,yt({as:"div"},(()=>a.dataset()),t))}function YIe(e){const a=WIe(),t=uKe({id:a.generateId("indicator")},e),[n,i]=bt(t,["ref","forceMount"]),[r,o]=La(),{present:s}=sHe({show:()=>n.forceMount||a.isSelected(),element:()=>r()??null});return ht(Tt,{get when(){return s()},get children(){return ht(bKe,yt({as:"div",ref(e){const a=kOe(o,n.ref);"function"==typeof a&&a(e)}},(()=>a.dataset()),i))}})}function QIe(e){const a=wKe(),t=JIe(),n=WIe(),i=uKe({id:n.generateId("input")},e),[r,o]=bt(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),[s,l]=La(!1);return Da(Ha([()=>n.isSelected(),()=>n.value()],(e=>{if(!e[0]&&e[1]===n.value())return;l(!0);const a=n.inputRef();a?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))}),{defer:!0})),Da((()=>Fa(n.registerInput(o.id)))),ht(bKe,yt({as:"input",ref(e){const a=kOe(n.setInputRef,r.ref);"function"==typeof a&&a(e)},type:"radio",get name(){return a.name()},get value(){return n.value()},get checked(){return n.isSelected()},get required(){return a.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return a.isReadOnly()},get style(){return ROe({...gKe},r.style)},get"aria-labelledby"(){return[r["aria-labelledby"],n.labelId(),null!=r["aria-labelledby"]&&null!=o["aria-label"]?o.id:void 0].filter(Boolean).join(" ")||void 0},get"aria-describedby"(){return[r["aria-describedby"],n.descriptionId(),t.ariaDescribedBy()].filter(Boolean).join(" ")||void 0},onChange:e=>{if(WOe(e,r.onChange),e.stopPropagation(),!s()){t.setSelectedValue(n.value());e.target.checked=n.isSelected()}l(!1)},onFocus:e=>{WOe(e,r.onFocus),n.setIsFocused(!0)},onBlur:e=>{WOe(e,r.onBlur),n.setIsFocused(!1)}},(()=>n.dataset()),o))}function XIe(e){const a=WIe(),t=uKe({id:a.generateId("label")},e);return Da((()=>Fa(a.registerLabel(t.id)))),ht(bKe,yt({as:"label",get for(){return a.inputId()}},(()=>a.dataset()),t))}function eFe(e){return ht(MKe,yt({as:"span"},e))}function aFe(e){let a;const t=uKe({id:`radiogroup-${wt()}`,orientation:"vertical"},e),[n,i,r]=bt(t,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],kKe),[o,s]=xKe({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:e=>n.onChange?.(e)}),{formControlContext:l}=function(e){const a=uKe({id:`form-control-${wt()}`},e),[t,n]=La(),[i,r]=La(),[o,s]=La(),[l,u]=La();return{formControlContext:{name:()=>xze(a.name)??xze(a.id),dataset:za((()=>({"data-valid":"valid"===xze(a.validationState)?"":void 0,"data-invalid":"invalid"===xze(a.validationState)?"":void 0,"data-required":xze(a.required)?"":void 0,"data-disabled":xze(a.disabled)?"":void 0,"data-readonly":xze(a.readOnly)?"":void 0}))),validationState:()=>xze(a.validationState),isRequired:()=>xze(a.required),isDisabled:()=>xze(a.disabled),isReadOnly:()=>xze(a.readOnly),labelId:t,fieldId:i,descriptionId:o,errorMessageId:l,getAriaLabelledBy:(e,a,n)=>{const i=null!=n||null!=t();return[n,t(),i&&null!=a?e:void 0].filter(Boolean).join(" ")||void 0},getAriaDescribedBy:e=>[o(),l(),e].filter(Boolean).join(" ")||void 0,generateId:OOe((()=>xze(a.id))),registerLabel:fKe(n),registerField:fKe(r),registerDescription:fKe(s),registerErrorMessage:fKe(u)}}}(i);TKe((()=>a),(()=>s(n.defaultValue??"")));const u=()=>l.getAriaDescribedBy(n["aria-describedby"]),c=e=>e===o(),d={ariaDescribedBy:u,isSelectedValue:c,setSelectedValue:e=>{if(!l.isReadOnly()&&!l.isDisabled()&&(s(e),a))for(const t of a.querySelectorAll("[type='radio']")){t.checked=c(t.value)}}};return ht(SKe.Provider,{value:l,get children(){return ht(VIe.Provider,{value:d,get children(){return ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)},role:"radiogroup",get id(){return xze(i.id)},get"aria-invalid"(){return"invalid"===l.validationState()||void 0},get"aria-required"(){return l.isRequired()||void 0},get"aria-disabled"(){return l.isDisabled()||void 0},get"aria-readonly"(){return l.isReadOnly()||void 0},get"aria-orientation"(){return n.orientation},get"aria-labelledby"(){return l.getAriaLabelledBy(xze(i.id),r["aria-label"],n["aria-labelledby"])},get"aria-describedby"(){return u()}},(()=>l.dataset()),r))}})}})}var tFe=Object.assign(aFe,{Description:AKe,ErrorMessage:CKe,Item:qIe,ItemControl:$Ie,ItemDescription:ZIe,ItemIndicator:YIe,ItemInput:QIe,ItemLabel:XIe,Label:eFe}),nFe=class{collection;ref;collator;constructor(e,a,t){this.collection=e,this.ref=a,this.collator=t}getKeyBelow(e){let a=this.collection().getKeyAfter(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyAfter(a)}}getKeyAbove(e){let a=this.collection().getKeyBefore(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyBefore(a)}}getFirstKey(){let e=this.collection().getFirstKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){return this.ref?.()?.querySelector(`[data-key="${e}"]`)??null}getKeyPageAbove(e){const a=this.ref?.();let t=this.getItem(e);if(!a||!t)return;const n=Math.max(0,t.offsetTop+t.offsetHeight-a.offsetHeight);let i=e;for(;i&&t&&t.offsetTop>n;)i=this.getKeyAbove(i),t=null!=i?this.getItem(i):null;return i}getKeyPageBelow(e){const a=this.ref?.();let t=this.getItem(e);if(!a||!t)return;const n=Math.min(a.scrollHeight,t.offsetTop-t.offsetHeight+a.offsetHeight);let i=e;for(;i&&t&&t.offsetTop<n;)i=this.getKeyBelow(i),t=null!=i?this.getItem(i):null;return i}getKeyForSearch(e,a){const t=this.collator?.();if(!t)return;let n=null!=a?this.getKeyBelow(a):this.getFirstKey();for(;null!=n;){const a=this.collection().getItem(n);if(a){const i=a.textValue.slice(0,e.length);if(a.textValue&&0===t.compare(i,e))return n}n=this.getKeyBelow(n)}}};function iFe(e,a,t){const n=function(e){const{locale:a}=qKe(),t=za((()=>a()+(e?Object.entries(e).sort(((e,a)=>e[0]<a[0]?-1:1)).join():"")));return za((()=>{const n=t();let i;return $Ke.has(n)&&(i=$Ke.get(n)),i||(i=new Intl.Collator(a(),e),$Ke.set(n,i)),i}))}({usage:"search",sensitivity:"base"});return aHe({selectionManager:()=>xze(e.selectionManager),keyboardDelegate:za((()=>{const t=xze(e.keyboardDelegate);return t||new nFe(e.collection,a,n)})),autoFocus:()=>xze(e.autoFocus),deferAutoFocus:()=>xze(e.deferAutoFocus),shouldFocusWrap:()=>xze(e.shouldFocusWrap),disallowEmptySelection:()=>xze(e.disallowEmptySelection),selectOnFocus:()=>xze(e.selectOnFocus),disallowTypeAhead:()=>xze(e.disallowTypeAhead),shouldUseVirtualFocus:()=>xze(e.shouldUseVirtualFocus),allowsTabNavigation:()=>xze(e.allowsTabNavigation),isVirtualized:()=>xze(e.isVirtualized),scrollToKey:a=>xze(e.scrollToKey)?.(a),orientation:()=>xze(e.orientation)},a)}var rFe="focusScope.autoFocusOnMount",oFe="focusScope.autoFocusOnUnmount",sFe={bubbles:!1,cancelable:!0},lFe={stack:[],active(){return this.stack[0]},add(e){e!==this.active()&&this.active()?.pause(),this.stack=DOe(this.stack,e),this.stack.unshift(e)},remove(e){this.stack=DOe(this.stack,e),this.active()?.resume()}};function uFe(e,a){const[t,n]=La(!1),i={pause(){n(!0)},resume(){n(!1)}};let r=null;const o=a=>e.onMountAutoFocus?.(a),s=a=>e.onUnmountAutoFocus?.(a),l=()=>IOe(a()),u=()=>{const e=l().createElement("span");return e.setAttribute("data-focus-trap",""),e.tabIndex=0,Object.assign(e.style,gKe),e},c=()=>{const e=a();return e?tKe(e,!0).filter((e=>!e.hasAttribute("data-focus-trap"))):[]},d=()=>{const e=c();return e.length>0?e[0]:null};Da((()=>{const e=a();if(!e)return;lFe.add(i);const t=HOe(e);if(!KOe(e,t)){const a=new CustomEvent(rFe,sFe);e.addEventListener(rFe,o),e.dispatchEvent(a),a.defaultPrevented||setTimeout((()=>{ZOe(d()),HOe(e)===t&&ZOe(e)}),0)}Fa((()=>{e.removeEventListener(rFe,o),setTimeout((()=>{const n=new CustomEvent(oFe,sFe);(()=>{const e=a();if(!e)return!1;const t=HOe(e);return!!t&&!KOe(e,t)&&iKe(t)})()&&n.preventDefault(),e.addEventListener(oFe,s),e.dispatchEvent(n),n.defaultPrevented||ZOe(t??l().body),e.removeEventListener(oFe,s),lFe.remove(i)}),0)}))})),Da((()=>{const n=a();if(!n||!xze(e.trapFocus)||t())return;const i=e=>{const a=e.target;a?.closest(`[${lHe}]`)||(KOe(n,a)?r=a:ZOe(r))},o=e=>{const a=e.relatedTarget??HOe(n);a?.closest(`[${lHe}]`)||KOe(n,a)||ZOe(r)};l().addEventListener("focusin",i),l().addEventListener("focusout",o),Fa((()=>{l().removeEventListener("focusin",i),l().removeEventListener("focusout",o)}))})),Da((()=>{const n=a();if(!n||!xze(e.trapFocus)||t())return;const i=u();n.insertAdjacentElement("afterbegin",i);const r=u();function o(e){const a=d(),t=(()=>{const e=c();return e.length>0?e[e.length-1]:null})();ZOe(e.relatedTarget===a?t:a)}n.insertAdjacentElement("beforeend",r),i.addEventListener("focusin",o),r.addEventListener("focusin",o);const s=new MutationObserver((e=>{for(const a of e)a.previousSibling===r&&(r.remove(),n.insertAdjacentElement("beforeend",r)),a.nextSibling===i&&(i.remove(),n.insertAdjacentElement("afterbegin",i))}));s.observe(n,{childList:!0,subtree:!1}),Fa((()=>{i.removeEventListener("focusin",o),r.removeEventListener("focusin",o),i.remove(),r.remove(),s.disconnect()}))}))}var cFe="data-live-announcer";function dFe(e){Da((()=>{xze(e.isDisabled)||Fa(function(e,a=document.body){const t=new Set(e),n=new Set,i=e=>{for(const n of e.querySelectorAll(`[${cFe}], [${lHe}]`))t.add(n);const a=e=>{if(t.has(e)||e.parentElement&&n.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(const a of t)if(e.contains(a))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a}),o=a(e);if(o===NodeFilter.FILTER_ACCEPT&&r(e),o!==NodeFilter.FILTER_REJECT){let e=i.nextNode();for(;null!=e;)r(e),e=i.nextNode()}},r=e=>{const a=mFe.get(e)??0;"true"===e.getAttribute("aria-hidden")&&0===a||(0===a&&e.setAttribute("aria-hidden","true"),n.add(e),mFe.set(e,a+1))};hFe.length&&hFe[hFe.length-1].disconnect();i(a);const o=new MutationObserver((e=>{for(const a of e)if("childList"===a.type&&0!==a.addedNodes.length&&![...t,...n].some((e=>e.contains(a.target)))){for(const e of a.removedNodes)e instanceof Element&&(t.delete(e),n.delete(e));for(const e of a.addedNodes)!(e instanceof HTMLElement||e instanceof SVGElement)||"true"!==e.dataset.liveAnnouncer&&"true"!==e.dataset.reactAriaTopLayer?e instanceof Element&&i(e):t.add(e)}}));o.observe(a,{childList:!0,subtree:!0});const s={observe(){o.observe(a,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return hFe.push(s),()=>{o.disconnect();for(const e of n){const a=mFe.get(e);if(null==a)return;1===a?(e.removeAttribute("aria-hidden"),mFe.delete(e)):mFe.set(e,a-1)}s===hFe[hFe.length-1]?(hFe.pop(),hFe.length&&hFe[hFe.length-1].observe()):hFe.splice(hFe.indexOf(s),1)}}(xze(e.targets),xze(e.root)))}))}var mFe=new WeakMap,hFe=[];var pFe=new Map,gFe=e=>{Da((()=>{const a=oHe(e.style)??{},t=oHe(e.properties)??[],n={};for(const r in a)n[r]=e.element.style[r];const i=pFe.get(e.key);i?i.activeCount++:pFe.set(e.key,{activeCount:1,originalStyles:n,properties:t.map((e=>e.key))}),Object.assign(e.element.style,e.style);for(const r of t)e.element.style.setProperty(r.key,r.value);Fa((()=>{const a=pFe.get(e.key);if(a)if(1===a.activeCount){pFe.delete(e.key);for(const[t,n]of Object.entries(a.originalStyles))e.element.style[t]=n;for(const t of a.properties)e.element.style.removeProperty(t);0===e.element.style.length&&e.element.removeAttribute("style"),e.cleanup?.()}else a.activeCount--}))}))},fFe=(e,a)=>{switch(a){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},vFe=(e,a)=>{const t=getComputedStyle(e),n="x"===a?t.overflowX:t.overflowY;return"auto"===n||"scroll"===n||"HTML"===e.tagName&&"visible"===n},[yFe,bFe]=La([]),kFe=e=>[e.deltaX,e.deltaY],SFe=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],wFe=(e,a,t,n)=>{const i=null!==n&&AFe(n,e),[r,o]=((e,a,t)=>{const n="x"===a&&"rtl"===window.getComputedStyle(e).direction?-1:1;let i=e,r=0,o=0,s=!1;do{const[e,l,u]=fFe(i,a),c=u-e-n*l;0===l&&0===c||!vFe(i,a)||(r+=c,o+=l),i===(t??document.documentElement)?s=!0:i=i._$host??i.parentElement}while(i&&!s);return[r,o]})(e,a,i?n:void 0);return!(t>0&&Math.abs(r)<=1)&&!(t<0&&Math.abs(o)<1)},AFe=(e,a)=>{if(e.contains(a))return!0;let t=a;for(;t;){if(t===e)return!0;t=t._$host??t.parentElement}return!1},CFe=e=>{const a=yt({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),t=wt();let n=[0,0],i=null,r=null;Da((()=>{oHe(a.enabled)&&(bFe((e=>[...e,t])),Fa((()=>{bFe((e=>e.filter((e=>e!==t))))})))})),Da((()=>{if(!oHe(a.enabled)||!oHe(a.hideScrollbar))return;const{body:e}=document,t=window.innerWidth-e.offsetWidth;if(oHe(a.preventScrollbarShift)){const n={overflow:"hidden"},i=[];t>0&&("padding"===oHe(a.preventScrollbarShiftMode)?n.paddingRight=`calc(${window.getComputedStyle(e).paddingRight} + ${t}px)`:n.marginRight=`calc(${window.getComputedStyle(e).marginRight} + ${t}px)`,i.push({key:"--scrollbar-width",value:`${t}px`}));const r=window.scrollY,o=window.scrollX;gFe({key:"prevent-scroll",element:e,style:n,properties:i,cleanup:()=>{oHe(a.restoreScrollPosition)&&t>0&&window.scrollTo(o,r)}})}else gFe({key:"prevent-scroll",element:e,style:{overflow:"hidden"}})})),Da((()=>{var e;(e=t,yFe().indexOf(e)===yFe().length-1&&oHe(a.enabled))&&(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Fa((()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)})))}));const o=e=>{n=SFe(e),i=null,r=null},s=e=>{const t=e.target,n=oHe(a.element),i=kFe(e),r=Math.abs(i[0])>Math.abs(i[1])?"x":"y",o=wFe(t,r,"x"===r?i[0]:i[1],n);let s;s=!n||!AFe(n,t)||!o,s&&e.cancelable&&e.preventDefault()},l=e=>{const t=oHe(a.element),o=e.target;let s;if(2===e.touches.length)s=!oHe(a.allowPinchZoom);else{if(null==i||null===r){const a=SFe(e).map(((e,a)=>n[a]-e)),t=Math.abs(a[0])>Math.abs(a[1])?"x":"y";i=t,r="x"===t?a[0]:a[1]}if("range"===o.type)s=!1;else{const e=wFe(o,i,r,t);s=!t||!AFe(t,o)||!e}}s&&e.cancelable&&e.preventDefault()}},MFe=CFe,TFe=Wa();function xFe(){return qa(TFe)}function EFe(){const e=xFe();if(void 0===e)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var NFe=Wa();function _Fe(){const e=qa(NFe);if(void 0===e)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var PFe=Wa();function jFe(){const e=qa(PFe);if(void 0===e)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function LFe(e){let a;const t=jFe(),n=EFe(),i=uKe({id:t.generateId(`item-${wt()}`)},e),[r,o]=bt(i,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[s,l]=La(),[u,c]=La(),[d,m]=La(),h=()=>n.listState().selectionManager(),p=()=>o.id,g=()=>{r.onSelect?.(),r.closeOnSelect&&setTimeout((()=>{n.close(!0)}))};zKe({getItem:()=>({ref:()=>a,type:"item",key:p(),textValue:r.textValue??d()?.textContent??a?.textContent??"",disabled:r.disabled??!1})});const f=tHe({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),v=e=>{WOe(e,r.onPointerMove),"mouse"===e.pointerType&&(r.disabled?n.onItemLeave(e):(n.onItemEnter(e),e.defaultPrevented||(ZOe(e.currentTarget),n.listState().selectionManager().setFocused(!0),n.listState().selectionManager().setFocusedKey(p()))))},y=e=>{WOe(e,r.onPointerLeave),"mouse"===e.pointerType&&n.onItemLeave(e)},b=e=>{WOe(e,r.onPointerUp),r.disabled||0!==e.button||g()},k=e=>{if(WOe(e,r.onKeyDown),!e.repeat&&!r.disabled)switch(e.key){case"Enter":case" ":g()}},S=za((()=>r.indeterminate?"mixed":null!=r.checked?r.checked:void 0)),w=za((()=>({"data-indeterminate":r.indeterminate?"":void 0,"data-checked":r.checked&&!r.indeterminate?"":void 0,"data-disabled":r.disabled?"":void 0,"data-highlighted":h().focusedKey()===p()?"":void 0}))),A={isChecked:()=>r.checked,dataset:w,setLabelRef:m,generateId:OOe((()=>o.id)),registerLabel:fKe(l),registerDescription:fKe(c)};return ht(NFe.Provider,{value:A,get children(){return ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>a=e),r.ref);"function"==typeof t&&t(e)},get tabIndex(){return f.tabIndex()},get"aria-checked"(){return S()},get"aria-disabled"(){return r.disabled},get"aria-labelledby"(){return s()},get"aria-describedby"(){return u()},get"data-key"(){return f.dataKey()},get onPointerDown(){return qOe([r.onPointerDown,f.onPointerDown])},get onPointerUp(){return qOe([b,f.onPointerUp])},get onClick(){return qOe([r.onClick,f.onClick])},get onKeyDown(){return qOe([k,f.onKeyDown])},get onMouseDown(){return qOe([r.onMouseDown,f.onMouseDown])},get onFocus(){return qOe([r.onFocus,f.onFocus])},onPointerMove:v,onPointerLeave:y},w,o))}})}function BFe(e){const a=uKe({closeOnSelect:!1},e),[t,n]=bt(a,["checked","defaultChecked","onChange","onSelect"]),i=function(e={}){const[a,t]=EKe({value:()=>xze(e.isSelected),defaultValue:()=>!!xze(e.defaultIsSelected),onChange:a=>e.onSelectedChange?.(a)});return{isSelected:a,setIsSelected:a=>{xze(e.isReadOnly)||xze(e.isDisabled)||t(a)},toggle:()=>{xze(e.isReadOnly)||xze(e.isDisabled)||t(!a())}}}({isSelected:()=>t.checked,defaultIsSelected:()=>t.defaultChecked,onSelectedChange:e=>t.onChange?.(e),isDisabled:()=>n.disabled});return ht(LFe,yt({role:"menuitemcheckbox",get checked(){return i.isSelected()},onSelect:()=>{t.onSelect?.(),i.toggle()}},n))}var RFe=Wa();function DFe(){return qa(RFe)}var zFe={next:(e,a)=>"ltr"===e?"horizontal"===a?"ArrowRight":"ArrowDown":"horizontal"===a?"ArrowLeft":"ArrowUp",previous:(e,a)=>zFe.next("ltr"===e?"rtl":"ltr",a)},OFe=e=>"horizontal"===e?"ArrowDown":"ArrowRight",KFe=e=>"horizontal"===e?"ArrowUp":"ArrowLeft";function HFe(e){const a=jFe(),t=EFe(),n=DFe(),{direction:i}=qKe(),r=uKe({id:a.generateId("trigger")},e),[o,s]=bt(r,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>a.value();void 0!==n&&(l=()=>a.value()??o.id,void 0===n.lastValue()&&n.setLastValue(l));const u=vKe((()=>t.triggerRef()),(()=>"button")),c=za((()=>"a"===u()&&null!=t.triggerRef()?.getAttribute("href")));Da(Ha((()=>n?.value()),(e=>{c()&&e===l()&&t.triggerRef()?.focus()})));const d=()=>{void 0!==n?t.isOpen()?n.value()===l()&&n.closeMenu():(n.autoFocusMenu()||n.setAutoFocusMenu(!0),t.open(!1)):t.toggle(!0)};return Da((()=>Fa(t.registerTriggerId(o.id)))),ht(vHe,yt({ref(e){const a=kOe(t.setTriggerRef,o.ref);"function"==typeof a&&a(e)},get"data-kb-menu-value-trigger"(){return a.value()},get id(){return o.id},get disabled(){return o.disabled},"aria-haspopup":"true",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return za((()=>!!t.isOpen()))()?t.contentId():void 0},get"data-highlighted"(){return void 0!==l()&&n?.value()===l()||void 0},get tabIndex(){return void 0!==n?n.value()===l()||n.lastValue()===l()?0:-1:void 0},onPointerDown:e=>{WOe(e,o.onPointerDown),e.currentTarget.dataset.pointerType=e.pointerType,o.disabled||"touch"===e.pointerType||0!==e.button||d()},onMouseOver:e=>{WOe(e,o.onMouseOver),"touch"!==t.triggerRef()?.dataset.pointerType&&(o.disabled||void 0===n||void 0===n.value()||n.setValue(l))},onClick:e=>{WOe(e,o.onClick),o.disabled||"touch"===e.currentTarget.dataset.pointerType&&d()},onKeyDown:e=>{if(WOe(e,o.onKeyDown),!o.disabled){if(c())switch(e.key){case"Enter":case" ":return}switch(e.key){case"Enter":case" ":case OFe(a.orientation()):e.stopPropagation(),e.preventDefault(),function(e){if(document.contains(e)){const a=document.scrollingElement||document.documentElement;if("hidden"===window.getComputedStyle(a).overflow){let t=oKe(e);for(;e&&t&&e!==a&&t!==a;)hKe(t,e),t=oKe(e=t)}else{const{left:a,top:t}=e.getBoundingClientRect();e?.scrollIntoView?.({block:"nearest"});const{left:n,top:i}=e.getBoundingClientRect();(Math.abs(a-n)>1||Math.abs(t-i)>1)&&e.scrollIntoView?.({block:"nearest"})}}}(e.currentTarget),t.open("first"),n?.setAutoFocusMenu(!0),n?.setValue(l);break;case KFe(a.orientation()):e.stopPropagation(),e.preventDefault(),t.open("last");break;case zFe.next(i(),a.orientation()):if(void 0===n)break;e.stopPropagation(),e.preventDefault(),n.nextMenu();break;case zFe.previous(i(),a.orientation()):if(void 0===n)break;e.stopPropagation(),e.preventDefault(),n.previousMenu()}}},onFocus:e=>{WOe(e,o.onFocus),void 0!==n&&"touch"!==e.currentTarget.dataset.pointerType&&n.setValue(l)},role:void 0!==n?"menuitem":void 0},(()=>t.dataset()),s))}var IFe=Wa();function FFe(){return qa(IFe)}function GFe(e){let a;const t=jFe(),n=EFe(),i=DFe(),r=FFe(),{direction:o}=qKe(),s=uKe({id:t.generateId(`content-${wt()}`)},e),[l,u]=bt(s,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let c=0;const d=()=>null==n.parentMenuContext()&&void 0===i&&t.isModal(),m=iFe({selectionManager:n.listState().selectionManager,collection:n.listState().collection,autoFocus:n.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!n.listState().selectionManager().isFocused(),orientation:()=>"horizontal"===t.orientation()?"vertical":"horizontal"},(()=>a));uFe({trapFocus:()=>d()&&n.isOpen(),onMountAutoFocus:e=>{void 0===i&&l.onOpenAutoFocus?.(e)},onUnmountAutoFocus:l.onCloseAutoFocus},(()=>a));const h=e=>{l.onEscapeKeyDown?.(e),i?.setAutoFocusMenu(!1),n.close(!0)},p=e=>{l.onFocusOutside?.(e),t.isModal()&&e.preventDefault()};Da((()=>Fa(n.registerContentId(l.id))));const g={ref:kOe((e=>{n.setContentRef(e),a=e}),l.ref),role:"menu",get id(){return l.id},get tabIndex(){return m.tabIndex()},get"aria-labelledby"(){return n.triggerId()},onKeyDown:qOe([l.onKeyDown,m.onKeyDown,e=>{if(KOe(e.currentTarget,e.target)&&("Tab"===e.key&&n.isOpen()&&e.preventDefault(),void 0!==i&&"true"!==e.currentTarget.getAttribute("aria-haspopup")))switch(e.key){case zFe.next(o(),t.orientation()):e.stopPropagation(),e.preventDefault(),n.close(!0),i.setAutoFocusMenu(!0),i.nextMenu();break;case zFe.previous(o(),t.orientation()):if(e.currentTarget.hasAttribute("data-closed"))break;e.stopPropagation(),e.preventDefault(),n.close(!0),i.setAutoFocusMenu(!0),i.previousMenu()}}]),onMouseDown:qOe([l.onMouseDown,m.onMouseDown]),onFocusIn:qOe([l.onFocusIn,m.onFocusIn]),onFocusOut:qOe([l.onFocusOut,m.onFocusOut]),onPointerEnter:e=>{WOe(e,l.onPointerEnter),n.isOpen()&&(n.parentMenuContext()?.listState().selectionManager().setFocused(!1),n.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},onPointerMove:e=>{if(WOe(e,l.onPointerMove),"mouse"!==e.pointerType)return;const a=c!==e.clientX;KOe(e.currentTarget,e.target)&&a&&(n.setPointerDir(e.clientX>c?"right":"left"),c=e.clientX)},get"data-orientation"(){return t.orientation()}};return ht(Tt,{get when(){return n.contentPresent()},get children(){return ht(Tt,{get when(){return void 0===r||null!=n.parentMenuContext()},get fallback(){return ht(bKe,yt({as:"div"},(()=>n.dataset()),g,u))},get children(){return ht(zIe.Positioner,{get children(){return ht(IIe,yt({get disableOutsidePointerEvents(){return za((()=>!!d()))()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return ROe({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:h,onFocusOutside:p,get onDismiss(){return n.close}},(()=>n.dataset()),g,u))}})}})}})}function VFe(e){let a;const t=jFe(),n=EFe(),[i,r]=bt(e,["ref"]);return MFe({element:()=>a??null,enabled:()=>n.contentPresent()&&t.preventScroll()}),ht(GFe,yt({ref(e){const t=kOe((e=>{a=e}),i.ref);"function"==typeof t&&t(e)}},r))}var JFe=Wa();function UFe(e){const a=uKe({id:jFe().generateId(`group-${wt()}`)},e),[t,n]=La(),i={generateId:OOe((()=>a.id)),registerLabelId:fKe(n)};return ht(JFe.Provider,{value:i,get children(){return ht(bKe,yt({as:"div",role:"group",get"aria-labelledby"(){return t()}},a))}})}function WFe(e){const a=function(){const e=qa(JFe);if(void 0===e)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}(),t=uKe({id:a.generateId("label")},e),[n,i]=bt(t,["id"]);return Da((()=>Fa(a.registerLabelId(n.id)))),ht(bKe,yt({as:"span",get id(){return n.id},"aria-hidden":"true"},i))}function qFe(e){const a=EFe();return ht(bKe,yt({as:"span","aria-hidden":"true"},(()=>a.dataset()),uKe({children:"▼"},e)))}function $Fe(e){return ht(LFe,yt({role:"menuitem",closeOnSelect:!0},e))}function ZFe(e){const a=_Fe(),t=uKe({id:a.generateId("description")},e),[n,i]=bt(t,["id"]);return Da((()=>Fa(a.registerDescription(n.id)))),ht(bKe,yt({as:"div",get id(){return n.id}},(()=>a.dataset()),i))}function YFe(e){const a=_Fe(),t=uKe({id:a.generateId("indicator")},e),[n,i]=bt(t,["forceMount"]);return ht(Tt,{get when(){return n.forceMount||a.isChecked()},get children(){return ht(bKe,yt({as:"div"},(()=>a.dataset()),i))}})}function QFe(e){const a=_Fe(),t=uKe({id:a.generateId("label")},e),[n,i]=bt(t,["ref","id"]);return Da((()=>Fa(a.registerLabel(n.id)))),ht(bKe,yt({as:"div",ref(e){const t=kOe(a.setLabelRef,n.ref);"function"==typeof t&&t(e)},get id(){return n.id}},(()=>a.dataset()),i))}function XFe(e){const a=EFe();return ht(Tt,{get when(){return a.contentPresent()},get children(){return ht(tn,e)}})}var eGe=Wa();function aGe(e){const a=uKe({id:jFe().generateId(`radiogroup-${wt()}`)},e),[t,n]=bt(a,["value","defaultValue","onChange","disabled"]),[i,r]=xKe({value:()=>t.value,defaultValue:()=>t.defaultValue,onChange:e=>t.onChange?.(e)});return ht(eGe.Provider,{value:{isDisabled:()=>t.disabled,isSelectedValue:e=>e===i(),setSelectedValue:r},get children(){return ht(UFe,n)}})}function tGe(e){const a=function(){const e=qa(eGe);if(void 0===e)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}(),t=uKe({closeOnSelect:!1},e),[n,i]=bt(t,["value","onSelect"]);return ht(LFe,yt({role:"menuitemradio",get checked(){return a.isSelectedValue(n.value)},onSelect:()=>{n.onSelect?.(),a.setSelectedValue(n.value)}},i))}function nGe(e,a,t){const n=e.split("-")[0],i=t.getBoundingClientRect(),r=[],o=a.clientX,s=a.clientY;switch(n){case"top":r.push([o,s+5]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]);break;case"right":r.push([o-5,s]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]);break;case"bottom":r.push([o,s-5]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]);break;case"left":r.push([o+5,s]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top])}return r}function iGe(e){const a=jFe(),t=jKe(),n=xFe(),i=DFe(),r=FFe(),o=uKe({placement:"horizontal"===a.orientation()?"bottom-start":"right-start"},e),[s,l]=bt(o,["open","defaultOpen","onOpenChange"]);let u=0,c=null,d="right";const[m,h]=La(),[p,g]=La(),[f,v]=La(),[y,b]=La(),[k,S]=La(!0),[w,A]=La(l.placement),[C,M]=La([]),[T,x]=La([]),{DomCollectionProvider:E}=DKe({items:T,onItemsChange:x}),N=FIe({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:e=>s.onOpenChange?.(e)}),{present:_}=sHe({show:()=>a.forceMount()||N.isOpen(),element:()=>y()??null}),P=function(e){const a=eHe(e),t=KKe({dataSource:()=>xze(e.dataSource),getKey:()=>xze(e.getKey),getTextValue:()=>xze(e.getTextValue),getDisabled:()=>xze(e.getDisabled),getSectionChildren:()=>xze(e.getSectionChildren),factory:a=>new iHe(e.filter?e.filter(a):a)},[()=>e.filter]),n=new nHe(t,a);return Ba((()=>{const e=a.focusedKey();null==e||t().getItem(e)||a.setFocusedKey(void 0)})),{collection:t,selectionManager:()=>n}}({selectionMode:"none",dataSource:T}),j=e=>{S(e),N.open()},L=(e=!1)=>{N.close(),e&&n&&n.close(!0)},B=()=>{const e=y();e&&(ZOe(e),P.selectionManager().setFocused(!0),P.selectionManager().setFocusedKey(void 0))},R=()=>{null!=r?setTimeout((()=>B())):B()},D=e=>{return d===c?.side&&(a=e,t=c?.area,!!t&&function(e,a){const[t,n]=e;let i=!1;for(let r=a.length,o=0,s=r-1;o<r;s=o++){const[e,l]=a[o],[u,c]=a[s],[,d]=a[0===s?r-1:s-1]||[0,0],m=(l-c)*(t-e)-(e-u)*(n-l);if(c<l){if(n>=c&&n<l){if(0===m)return!0;m>0&&(n===c?n>d&&(i=!i):i=!i)}}else if(l<c){if(n>l&&n<=c){if(0===m)return!0;m<0&&(n===c?n<d&&(i=!i):i=!i)}}else if(n==l&&(t>=u&&t<=e||t>=e&&t<=u))return!0}return i}([a.clientX,a.clientY],t));var a,t};dFe({isDisabled:()=>!(null==n&&N.isOpen()&&a.isModal()),targets:()=>[y(),...C()].filter(Boolean)}),Da((()=>{const e=y();if(!e||!n)return;const a=n.registerNestedMenu(e);Fa((()=>{a()}))})),Da((()=>{void 0===n&&i?.registerMenu(a.value(),[y(),...C()])})),Da((()=>{void 0===n&&void 0!==i&&(i.value()===a.value()?(f()?.focus(),i.autoFocusMenu()&&j(!0)):L())})),Da((()=>{void 0===n&&void 0!==i&&N.isOpen()&&i.setValue(a.value())})),Fa((()=>{void 0===n&&i?.unregisterMenu(a.value())}));const z={dataset:za((()=>({"data-expanded":N.isOpen()?"":void 0,"data-closed":N.isOpen()?void 0:""}))),isOpen:N.isOpen,contentPresent:_,nestedMenus:C,currentPlacement:w,pointerGraceTimeoutId:()=>u,autoFocus:k,listState:()=>P,parentMenuContext:()=>n,triggerRef:f,contentRef:y,triggerId:m,contentId:p,setTriggerRef:v,setContentRef:b,open:j,close:L,toggle:e=>{S(e),N.toggle()},focusContent:R,onItemEnter:e=>{D(e)&&e.preventDefault()},onItemLeave:e=>{D(e)||R()},onTriggerLeave:e=>{D(e)&&e.preventDefault()},setPointerDir:e=>d=e,setPointerGraceTimeoutId:e=>u=e,setPointerGraceIntent:e=>c=e,registerNestedMenu:e=>{M((a=>[...a,e]));const a=n?.registerNestedMenu(e);return()=>{M((a=>DOe(a,e))),a?.()}},registerItemToParentDomCollection:t?.registerItem,registerTriggerId:fKe(h),registerContentId:fKe(g)};return ht(E,{get children(){return ht(TFe.Provider,{value:z,get children(){return ht(Tt,{when:void 0===r,get fallback(){return l.children},get children(){return ht(zIe,yt({anchorRef:f,contentRef:y,onCurrentPlacementChange:A},l))}})}})}})}function rGe(e){const{direction:a}=qKe();return ht(iGe,yt({get placement(){return"rtl"===a()?"left-start":"right-start"},flip:!0},e))}var oGe=(e,a)=>"ltr"===e?["horizontal"===a?"ArrowLeft":"ArrowUp"]:["horizontal"===a?"ArrowRight":"ArrowDown"];function sGe(e){const a=EFe(),t=jFe(),[n,i]=bt(e,["onFocusOutside","onKeyDown"]),{direction:r}=qKe();return ht(GFe,yt({onOpenAutoFocus:e=>{e.preventDefault()},onCloseAutoFocus:e=>{e.preventDefault()},onFocusOutside:e=>{n.onFocusOutside?.(e);const t=e.target;KOe(a.triggerRef(),t)||a.close()},onKeyDown:e=>{WOe(e,n.onKeyDown);const i=KOe(e.currentTarget,e.target),o=oGe(r(),t.orientation()).includes(e.key),s=null!=a.parentMenuContext();i&&o&&s&&(a.close(),ZOe(a.triggerRef()))}},i))}var lGe=["Enter"," "],uGe=(e,a)=>"ltr"===e?[...lGe,"horizontal"===a?"ArrowRight":"ArrowDown"]:[...lGe,"horizontal"===a?"ArrowLeft":"ArrowUp"];function cGe(e){let a;const t=jFe(),n=EFe(),i=uKe({id:t.generateId(`sub-trigger-${wt()}`)},e),[r,o]=bt(i,["ref","id","textValue","disabled","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);let s=null;const l=()=>{s&&window.clearTimeout(s),s=null},{direction:u}=qKe(),c=()=>r.id,d=()=>{const e=n.parentMenuContext();if(null==e)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return e.listState().selectionManager()},m=tHe({key:c,selectionManager:d,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),h=e=>{WOe(e,r.onClick),n.isOpen()||r.disabled||n.open(!0)},p=e=>{WOe(e,r.onKeyDown),e.repeat||r.disabled||uGe(u(),t.orientation()).includes(e.key)&&(e.stopPropagation(),e.preventDefault(),d().setFocused(!1),d().setFocusedKey(void 0),n.isOpen()||n.open("first"),n.focusContent(),n.listState().selectionManager().setFocused(!0),n.listState().selectionManager().setFocusedKey(n.listState().collection().getFirstKey()))};return Da((()=>{if(null==n.registerItemToParentDomCollection)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");Fa(n.registerItemToParentDomCollection({ref:()=>a,type:"item",key:c(),textValue:r.textValue??a?.textContent??"",disabled:r.disabled??!1}))})),Da(Ha((()=>n.parentMenuContext()?.pointerGraceTimeoutId()),(e=>{Fa((()=>{window.clearTimeout(e),n.parentMenuContext()?.setPointerGraceIntent(null)}))}))),Da((()=>Fa(n.registerTriggerId(r.id)))),Fa((()=>{l()})),ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>{n.setTriggerRef(e),a=e}),r.ref);"function"==typeof t&&t(e)},get id(){return r.id},role:"menuitem",get tabIndex(){return m.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return za((()=>!!n.isOpen()))()?n.contentId():void 0},get"aria-disabled"(){return r.disabled},get"data-key"(){return m.dataKey()},get"data-highlighted"(){return d().focusedKey()===c()?"":void 0},get"data-disabled"(){return r.disabled?"":void 0},get onPointerDown(){return qOe([r.onPointerDown,m.onPointerDown])},get onPointerUp(){return qOe([r.onPointerUp,m.onPointerUp])},get onClick(){return qOe([h,m.onClick])},get onKeyDown(){return qOe([p,m.onKeyDown])},get onMouseDown(){return qOe([r.onMouseDown,m.onMouseDown])},get onFocus(){return qOe([r.onFocus,m.onFocus])},onPointerMove:e=>{if(WOe(e,r.onPointerMove),"mouse"!==e.pointerType)return;const a=n.parentMenuContext();a?.onItemEnter(e),e.defaultPrevented||(r.disabled?a?.onItemLeave(e):(n.isOpen()||s||(n.parentMenuContext()?.setPointerGraceIntent(null),s=window.setTimeout((()=>{n.open(!1),l()}),100)),a?.onItemEnter(e),e.defaultPrevented||(n.listState().selectionManager().isFocused()&&(n.listState().selectionManager().setFocused(!1),n.listState().selectionManager().setFocusedKey(void 0)),ZOe(e.currentTarget),a?.listState().selectionManager().setFocused(!0),a?.listState().selectionManager().setFocusedKey(c()))))},onPointerLeave:e=>{if(WOe(e,r.onPointerLeave),"mouse"!==e.pointerType)return;l();const a=n.parentMenuContext(),t=n.contentRef();if(t){a?.setPointerGraceIntent({area:nGe(n.currentPlacement(),e,t),side:n.currentPlacement().split("-")[0]}),window.clearTimeout(a?.pointerGraceTimeoutId());const i=window.setTimeout((()=>{a?.setPointerGraceIntent(null)}),300);a?.setPointerGraceTimeoutId(i)}else{if(a?.onTriggerLeave(e),e.defaultPrevented)return;a?.setPointerGraceIntent(null)}a?.onItemLeave(e)}},(()=>n.dataset()),o))}function dGe(e){const a=DFe(),t=uKe({id:`menu-${wt()}`,modal:!0},e),[n,i]=bt(t,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),r=FIe({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:e=>n.onOpenChange?.(e)}),o={isModal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??o.isModal(),forceMount:()=>n.forceMount??!1,generateId:OOe((()=>n.id)),value:()=>n.value,orientation:()=>n.orientation??a?.orientation()??"horizontal"};return ht(PFe.Provider,{value:o,get children(){return ht(iGe,yt({get open(){return r.isOpen()},get onOpenChange(){return r.setIsOpen}},i))}})}function mGe(e){let a;const t=uKe({orientation:"horizontal"},e),[n,i]=bt(t,["ref","orientation"]),r=vKe((()=>a),(()=>"hr"));return ht(bKe,yt({as:"hr",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)},get role(){return"hr"!==r()?"separator":void 0},get"aria-orientation"(){return"vertical"===n.orientation?"vertical":void 0},get"data-orientation"(){return n.orientation}},i))}_Ke({},{Root:()=>mGe,Separator:()=>hGe});var hGe=mGe,pGe={};function gGe(e){const a=jFe(),t=EFe(),[n,i]=bt(e,["onCloseAutoFocus","onInteractOutside"]);let r=!1;return ht(VFe,yt({onCloseAutoFocus:e=>{n.onCloseAutoFocus?.(e),r||ZOe(t.triggerRef()),r=!1,e.preventDefault()},onInteractOutside:e=>{n.onInteractOutside?.(e),a.isModal()&&!e.detail.isContextMenu||(r=!0)}},i))}function fGe(e){return ht(dGe,uKe({id:`dropdownmenu-${wt()}`},e))}_Ke(pGe,{Arrow:()=>LIe,CheckboxItem:()=>BFe,Content:()=>gGe,DropdownMenu:()=>vGe,Group:()=>UFe,GroupLabel:()=>WFe,Icon:()=>qFe,Item:()=>$Fe,ItemDescription:()=>ZFe,ItemIndicator:()=>YFe,ItemLabel:()=>QFe,Portal:()=>XFe,RadioGroup:()=>aGe,RadioItem:()=>tGe,Root:()=>fGe,Separator:()=>mGe,Sub:()=>rGe,SubContent:()=>sGe,SubTrigger:()=>cGe,Trigger:()=>HFe});var vGe=Object.assign(fGe,{Arrow:LIe,CheckboxItem:BFe,Content:gGe,Group:UFe,GroupLabel:WFe,Icon:qFe,Item:$Fe,ItemDescription:ZFe,ItemIndicator:YFe,ItemLabel:QFe,Portal:XFe,RadioGroup:aGe,RadioItem:tGe,Separator:mGe,Sub:rGe,SubContent:sGe,SubTrigger:cGe,Trigger:HFe}),yGe={colors:{inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000000",white:"#ffffff",neutral:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},darkGray:{50:"#525c7a",100:"#49536e",200:"#414962",300:"#394056",400:"#313749",500:"#292e3d",600:"#212530",700:"#191c24",800:"#111318",900:"#0b0d10"},gray:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},blue:{25:"#F5FAFF",50:"#EFF8FF",100:"#D1E9FF",200:"#B2DDFF",300:"#84CAFF",400:"#53B1FD",500:"#2E90FA",600:"#1570EF",700:"#175CD3",800:"#1849A9",900:"#194185"},green:{25:"#F6FEF9",50:"#ECFDF3",100:"#D1FADF",200:"#A6F4C5",300:"#6CE9A6",400:"#32D583",500:"#12B76A",600:"#039855",700:"#027A48",800:"#05603A",900:"#054F31"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},yellow:{25:"#FFFCF5",50:"#FFFAEB",100:"#FEF0C7",200:"#FEDF89",300:"#FEC84B",400:"#FDB022",500:"#F79009",600:"#DC6803",700:"#B54708",800:"#93370D",900:"#7A2E0E"},purple:{25:"#FAFAFF",50:"#F4F3FF",100:"#EBE9FE",200:"#D9D6FE",300:"#BDB4FE",400:"#9B8AFB",500:"#7A5AF8",600:"#6938EF",700:"#5925DC",800:"#4A1FB8",900:"#3E1C96"},teal:{25:"#F6FEFC",50:"#F0FDF9",100:"#CCFBEF",200:"#99F6E0",300:"#5FE9D0",400:"#2ED3B7",500:"#15B79E",600:"#0E9384",700:"#107569",800:"#125D56",900:"#134E48"},pink:{25:"#fdf2f8",50:"#fce7f3",100:"#fbcfe8",200:"#f9a8d4",300:"#f472b6",400:"#ec4899",500:"#db2777",600:"#be185d",700:"#9d174d",800:"#831843",900:"#500724"},cyan:{25:"#ecfeff",50:"#cffafe",100:"#a5f3fc",200:"#67e8f9",300:"#22d3ee",400:"#06b6d4",500:"#0891b2",600:"#0e7490",700:"#155e75",800:"#164e63",900:"#083344"}},alpha:{90:"e5",80:"cc"},font:{size:{xs:"calc(var(--tsqd-font-size) * 0.75)",sm:"calc(var(--tsqd-font-size) * 0.875)",md:"var(--tsqd-font-size)"},lineHeight:{xs:"calc(var(--tsqd-font-size) * 1)",sm:"calc(var(--tsqd-font-size) * 1.25)",md:"calc(var(--tsqd-font-size) * 1.5)"},weight:{medium:"500",semibold:"600",bold:"700"}},border:{radius:{xs:"calc(var(--tsqd-font-size) * 0.125)",sm:"calc(var(--tsqd-font-size) * 0.25)",full:"9999px"}},size:{.25:"calc(var(--tsqd-font-size) * 0.0625)",.5:"calc(var(--tsqd-font-size) * 0.125)",1:"calc(var(--tsqd-font-size) * 0.25)",1.5:"calc(var(--tsqd-font-size) * 0.375)",2:"calc(var(--tsqd-font-size) * 0.5)",2.5:"calc(var(--tsqd-font-size) * 0.625)",3:"calc(var(--tsqd-font-size) * 0.75)",3.5:"calc(var(--tsqd-font-size) * 0.875)",4:"calc(var(--tsqd-font-size) * 1)",4.5:"calc(var(--tsqd-font-size) * 1.125)",5:"calc(var(--tsqd-font-size) * 1.25)",6:"calc(var(--tsqd-font-size) * 1.5)",6.5:"calc(var(--tsqd-font-size) * 1.625)",14:"calc(var(--tsqd-font-size) * 3.5)"},shadow:{xs:(e="rgb(0 0 0 / 0.1)")=>"0 1px 2px 0 rgb(0 0 0 / 0.05)",sm:(e="rgb(0 0 0 / 0.1)")=>`0 1px 3px 0 ${e}, 0 1px 2px -1px ${e}`,md:(e="rgb(0 0 0 / 0.1)")=>`0 4px 6px -1px ${e}, 0 2px 4px -2px ${e}`,lg:(e="rgb(0 0 0 / 0.1)")=>`0 10px 15px -3px ${e}, 0 4px 6px -4px ${e}`,xl:(e="rgb(0 0 0 / 0.1)")=>`0 20px 25px -5px ${e}, 0 8px 10px -6px ${e}`,"2xl":(e="rgb(0 0 0 / 0.25)")=>`0 25px 50px -12px ${e}`,inner:(e="rgb(0 0 0 / 0.05)")=>`inset 0 2px 4px 0 ${e}`,none:()=>"none"}},bGe=Ot('<svg width=14 height=14 viewBox="0 0 14 14"fill=none xmlns=http://www.w3.org/2000/svg><path d="M13 13L9.00007 9M10.3333 5.66667C10.3333 8.244 8.244 10.3333 5.66667 10.3333C3.08934 10.3333 1 8.244 1 5.66667C1 3.08934 3.08934 1 5.66667 1C8.244 1 10.3333 3.08934 10.3333 5.66667Z"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),kGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 3H15M3 6H21M19 6L18.2987 16.5193C18.1935 18.0975 18.1409 18.8867 17.8 19.485C17.4999 20.0118 17.0472 20.4353 16.5017 20.6997C15.882 21 15.0911 21 13.5093 21H10.4907C8.90891 21 8.11803 21 7.49834 20.6997C6.95276 20.4353 6.50009 20.0118 6.19998 19.485C5.85911 18.8867 5.8065 18.0975 5.70129 16.5193L5 6M10 10.5V15.5M14 10.5V15.5"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),SGe=Ot('<svg width=10 height=6 viewBox="0 0 10 6"fill=none xmlns=http://www.w3.org/2000/svg><path d="M1 1L5 5L9 1"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),wGe=Ot('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 13.3333V2.66667M8 2.66667L4 6.66667M8 2.66667L12 6.66667"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),AGe=Ot('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),CGe=Ot('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2v2m0 16v2M4 12H2m4.314-5.686L4.9 4.9m12.786 1.414L19.1 4.9M6.314 17.69 4.9 19.104m12.786-1.414 1.414 1.414M22 12h-2m-3 0a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),MGe=Ot('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M22 15.844a10.424 10.424 0 0 1-4.306.925c-5.779 0-10.463-4.684-10.463-10.462 0-1.536.33-2.994.925-4.307A10.464 10.464 0 0 0 2 11.538C2 17.316 6.684 22 12.462 22c4.243 0 7.896-2.526 9.538-6.156Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),TGe=Ot('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 21h8m-4-4v4m-5.2-4h10.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C22 14.72 22 13.88 22 12.2V7.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C19.72 3 18.88 3 17.2 3H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 5.28 2 6.12 2 7.8v4.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 17 5.12 17 6.8 17Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),xGe=Ot('<svg stroke=currentColor fill=currentColor stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M0 0h24v24H0z"></path><path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3a4.237 4.237 0 00-6 0zm-4-4l2 2a7.074 7.074 0 0110 0l2-2C15.14 9.14 8.87 9.14 5 13z">'),EGe=Ot('<svg stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M24 .01c0-.01 0-.01 0 0L0 0v24h24V.01zM0 0h24v24H0V0zm0 0h24v24H0V0z"></path><path d="M22.99 9C19.15 5.16 13.8 3.76 8.84 4.78l2.52 2.52c3.47-.17 6.99 1.05 9.63 3.7l2-2zm-4 4a9.793 9.793 0 00-4.49-2.56l3.53 3.53.96-.97zM2 3.05L5.07 6.1C3.6 6.82 2.22 7.78 1 9l1.99 2c1.24-1.24 2.67-2.16 4.2-2.77l2.24 2.24A9.684 9.684 0 005 13v.01L6.99 15a7.042 7.042 0 014.92-2.06L18.98 20l1.27-1.26L3.29 1.79 2 3.05zM9 17l3 3 3-3a4.237 4.237 0 00-6 0z">'),NGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.3951 19.3711L9.97955 20.6856C10.1533 21.0768 10.4368 21.4093 10.7958 21.6426C11.1547 21.8759 11.5737 22.0001 12.0018 22C12.4299 22.0001 12.8488 21.8759 13.2078 21.6426C13.5667 21.4093 13.8503 21.0768 14.024 20.6856L14.6084 19.3711C14.8165 18.9047 15.1664 18.5159 15.6084 18.26C16.0532 18.0034 16.5678 17.8941 17.0784 17.9478L18.5084 18.1C18.9341 18.145 19.3637 18.0656 19.7451 17.8713C20.1265 17.6771 20.4434 17.3763 20.6573 17.0056C20.8715 16.635 20.9735 16.2103 20.9511 15.7829C20.9286 15.3555 20.7825 14.9438 20.5307 14.5978L19.684 13.4344C19.3825 13.0171 19.2214 12.5148 19.224 12C19.2239 11.4866 19.3865 10.9864 19.6884 10.5711L20.5351 9.40778C20.787 9.06175 20.933 8.65007 20.9555 8.22267C20.978 7.79528 20.8759 7.37054 20.6618 7C20.4479 6.62923 20.131 6.32849 19.7496 6.13423C19.3681 5.93997 18.9386 5.86053 18.5129 5.90556L17.0829 6.05778C16.5722 6.11141 16.0577 6.00212 15.6129 5.74556C15.17 5.48825 14.82 5.09736 14.6129 4.62889L14.024 3.31444C13.8503 2.92317 13.5667 2.59072 13.2078 2.3574C12.8488 2.12408 12.4299 1.99993 12.0018 2C11.5737 1.99993 11.1547 2.12408 10.7958 2.3574C10.4368 2.59072 10.1533 2.92317 9.97955 3.31444L9.3951 4.62889C9.18803 5.09736 8.83798 5.48825 8.3951 5.74556C7.95032 6.00212 7.43577 6.11141 6.9251 6.05778L5.49066 5.90556C5.06499 5.86053 4.6354 5.93997 4.25397 6.13423C3.87255 6.32849 3.55567 6.62923 3.34177 7C3.12759 7.37054 3.02555 7.79528 3.04804 8.22267C3.07052 8.65007 3.21656 9.06175 3.46844 9.40778L4.3151 10.5711C4.61704 10.9864 4.77964 11.4866 4.77955 12C4.77964 12.5134 4.61704 13.0137 4.3151 13.4289L3.46844 14.5922C3.21656 14.9382 3.07052 15.3499 3.04804 15.7773C3.02555 16.2047 3.12759 16.6295 3.34177 17C3.55589 17.3706 3.8728 17.6712 4.25417 17.8654C4.63554 18.0596 5.06502 18.1392 5.49066 18.0944L6.92066 17.9422C7.43133 17.8886 7.94587 17.9979 8.39066 18.2544C8.83519 18.511 9.18687 18.902 9.3951 19.3711Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><path d="M12 15C13.6568 15 15 13.6569 15 12C15 10.3431 13.6568 9 12 9C10.3431 9 8.99998 10.3431 8.99998 12C8.99998 13.6569 10.3431 15 12 15Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),_Ge=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M16 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V8M11.5 12.5L17 7M17 7H12M17 7V12M6.2 21H8.8C9.9201 21 10.4802 21 10.908 20.782C11.2843 20.5903 11.5903 20.2843 11.782 19.908C12 19.4802 12 18.9201 12 17.8V15.2C12 14.0799 12 13.5198 11.782 13.092C11.5903 12.7157 11.2843 12.4097 10.908 12.218C10.4802 12 9.92011 12 8.8 12H6.2C5.0799 12 4.51984 12 4.09202 12.218C3.71569 12.4097 3.40973 12.7157 3.21799 13.092C3 13.5198 3 14.0799 3 15.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),PGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path class=copier d="M8 8V5.2C8 4.0799 8 3.51984 8.21799 3.09202C8.40973 2.71569 8.71569 2.40973 9.09202 2.21799C9.51984 2 10.0799 2 11.2 2H18.8C19.9201 2 20.4802 2 20.908 2.21799C21.2843 2.40973 21.5903 2.71569 21.782 3.09202C22 3.51984 22 4.0799 22 5.2V12.8C22 13.9201 22 14.4802 21.782 14.908C21.5903 15.2843 21.2843 15.5903 20.908 15.782C20.4802 16 19.9201 16 18.8 16H16M5.2 22H12.8C13.9201 22 14.4802 22 14.908 21.782C15.2843 21.5903 15.5903 21.2843 15.782 20.908C16 20.4802 16 19.9201 16 18.8V11.2C16 10.0799 16 9.51984 15.782 9.09202C15.5903 8.71569 15.2843 8.40973 14.908 8.21799C14.4802 8 13.9201 8 12.8 8H5.2C4.0799 8 3.51984 8 3.09202 8.21799C2.71569 8.40973 2.40973 8.71569 2.21799 9.09202C2 9.51984 2 10.0799 2 11.2V18.8C2 19.9201 2 20.4802 2.21799 20.908C2.40973 21.2843 2.71569 21.5903 3.09202 21.782C3.51984 22 4.07989 22 5.2 22Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round stroke=currentColor>'),jGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M2.5 21.4998L8.04927 19.3655C8.40421 19.229 8.58168 19.1607 8.74772 19.0716C8.8952 18.9924 9.0358 18.901 9.16804 18.7984C9.31692 18.6829 9.45137 18.5484 9.72028 18.2795L21 6.99982C22.1046 5.89525 22.1046 4.10438 21 2.99981C19.8955 1.89525 18.1046 1.89524 17 2.99981L5.72028 14.2795C5.45138 14.5484 5.31692 14.6829 5.20139 14.8318C5.09877 14.964 5.0074 15.1046 4.92823 15.2521C4.83911 15.4181 4.77085 15.5956 4.63433 15.9506L2.5 21.4998ZM2.5 21.4998L4.55812 16.1488C4.7054 15.7659 4.77903 15.5744 4.90534 15.4867C5.01572 15.4101 5.1523 15.3811 5.2843 15.4063C5.43533 15.4351 5.58038 15.5802 5.87048 15.8703L8.12957 18.1294C8.41967 18.4195 8.56472 18.5645 8.59356 18.7155C8.61877 18.8475 8.58979 18.9841 8.51314 19.0945C8.42545 19.2208 8.23399 19.2944 7.85107 19.4417L2.5 21.4998Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),LGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),BGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 9L15 15M15 9L9 15M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke=#F04438 stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),RGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 xmlns=http://www.w3.org/2000/svg><rect class=list width=20 height=20 y=2 x=2 rx=2></rect><line class=list-item y1=7 y2=7 x1=6 x2=18></line><line class=list-item y2=12 y1=12 x1=6 x2=18></line><line class=list-item y1=17 y2=17 x1=6 x2=18>'),DGe=Ot('<svg viewBox="0 0 24 24"height=20 width=20 fill=none xmlns=http://www.w3.org/2000/svg><path d="M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),zGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),OGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2V6M12 18V22M6 12H2M22 12H18M19.0784 19.0784L16.25 16.25M19.0784 4.99994L16.25 7.82837M4.92157 19.0784L7.75 16.25M4.92157 4.99994L7.75 7.82837"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><animateTransform attributeName=transform attributeType=XML type=rotate from=0 to=360 dur=2s repeatCount=indefinite>'),KGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M15 9L9 15M9 9L15 15M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),HGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.5 15V9M14.5 15V9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),IGe=Ot('<svg version=1.0 viewBox="0 0 633 633"><linearGradient x1=-666.45 x2=-666.45 y1=163.28 y2=163.99 gradientTransform="matrix(633 0 0 633 422177 -103358)"gradientUnits=userSpaceOnUse><stop stop-color=#6BDAFF offset=0></stop><stop stop-color=#F9FFB5 offset=.32></stop><stop stop-color=#FFA770 offset=.71></stop><stop stop-color=#FF7373 offset=1></stop></linearGradient><circle cx=316.5 cy=316.5 r=316.5></circle><defs><filter x=-137.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=316.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=316.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=316.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=272.2 y=308 width=176.9 height=129.3 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=272.2 y=308 width=176.9 height=129.3 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><line x1=436 x2=431 y1=403.2 y2=431.8 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=291 x2=280 y1=341.5 y2=403.5 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=332.9 x2=328.6 y1=384.1 y2=411.2 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><linearGradient x1=-670.75 x2=-671.59 y1=164.4 y2=164.49 gradientTransform="matrix(-184.16 -32.472 -11.461 64.997 -121359 -32126)"gradientUnits=userSpaceOnUse><stop stop-color=#EE2700 offset=0></stop><stop stop-color=#FF008E offset=1></stop></linearGradient><path d="m344.1 363 97.7 17.2c5.8 2.1 8.2 6.1 7.1 12.1s-4.7 9.2-11 9.9l-106-18.7-57.5-59.2c-3.2-4.8-2.9-9.1 0.8-12.8s8.3-4.4 13.7-2.1l55.2 53.6z"clip-rule=evenodd fill-rule=evenodd></path><line x1=428.2 x2=429.1 y1=384.5 y2=378 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=395.2 x2=396.1 y1=379.5 y2=373 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=362.2 x2=363.1 y1=373.5 y2=367.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=324.2 x2=328.4 y1=351.3 y2=347.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=303.2 x2=307.4 y1=331.3 y2=327.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line></g><defs><filter x=73.2 y=113.8 width=280.6 height=317.4 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=73.2 y=113.8 width=280.6 height=317.4 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-672.16 x2=-672.16 y1=165.03 y2=166.03 gradientTransform="matrix(-100.18 48.861 97.976 200.88 -83342 -93.059)"gradientUnits=userSpaceOnUse><stop stop-color=#A17500 offset=0></stop><stop stop-color=#5D2100 offset=1></stop></linearGradient><path d="m192.3 203c8.1 37.3 14 73.6 17.8 109.1 3.8 35.4 2.8 75.1-3 119.2l61.2-16.7c-15.6-59-25.2-97.9-28.6-116.6s-10.8-51.9-22.1-99.6l-25.3 4.6"clip-rule=evenodd fill-rule=evenodd></path><g stroke=#2F8A00><linearGradient x1=-660.23 x2=-660.23 y1=166.72 y2=167.72 gradientTransform="matrix(92.683 4.8573 -2.0259 38.657 61680 -3088.6)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9s-12.6-22.1-36.5-29.9c-15.9-5.2-34.4-1.5-55.5 11.1 15.9 14.3 29.5 22.6 40.7 24.9 16.8 3.6 51.3-6.1 51.3-6.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-661.36 x2=-661.36 y1=164.18 y2=165.18 gradientTransform="matrix(110 5.7648 -6.3599 121.35 73933 -15933)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5s-47.5-8.5-83.2 15.7c-23.8 16.2-34.3 49.3-31.6 99.4 30.3-27.8 52.1-48.5 65.2-61.9 19.8-20.2 49.6-53.2 49.6-53.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.79 x2=-656.79 y1=165.15 y2=166.15 gradientTransform="matrix(62.954 3.2993 -3.5023 66.828 42156 -8754.1)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9c-0.8-21.9 6-38 20.6-48.2s29.8-15.4 45.5-15.3c-6.1 21.4-14.5 35.8-25.2 43.4s-24.4 14.2-40.9 20.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-663.07 x2=-663.07 y1=165.44 y2=166.44 gradientTransform="matrix(152.47 7.9907 -3.0936 59.029 101884 -4318.7)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c31.9-30 64.1-39.7 96.7-29s50.8 30.4 54.6 59.1c-35.2-5.5-60.4-9.6-75.8-12.1-15.3-2.6-40.5-8.6-75.5-18z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-662.57 x2=-662.57 y1=164.44 y2=165.44 gradientTransform="matrix(136.46 7.1517 -5.2163 99.533 91536 -11442)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c35.8-7.6 65.6-0.2 89.2 22s37.7 49 42.3 80.3c-39.8-9.7-68.3-23.8-85.5-42.4s-32.5-38.5-46-59.9z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.43 x2=-656.43 y1=163.86 y2=164.86 gradientTransform="matrix(60.866 3.1899 -8.7773 167.48 41560 -25168)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c-33.6 13.8-53.6 35.7-60.1 65.6s-3.6 63.1 8.7 99.6c27.4-40.3 43.2-69.6 47.4-88s5.6-44.1 4-77.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><path d="m196.5 182.3c-14.8 21.6-25.1 41.4-30.8 59.4s-9.5 33-11.1 45.1"fill=none stroke-linecap=round stroke-width=8></path><path d="m194.9 185.7c-24.4 1.7-43.8 9-58.1 21.8s-24.7 25.4-31.3 37.8"fill=none stroke-linecap=round stroke-width=8></path><path d="m204.5 176.4c29.7-6.7 52-8.4 67-5.1s26.9 8.6 35.8 15.9"fill=none stroke-linecap=round stroke-width=8></path><path d="m196.5 181.4c20.3 9.9 38.2 20.5 53.9 31.9s27.4 22.1 35.1 32"fill=none stroke-linecap=round stroke-width=8></path></g></g><defs><filter x=50.5 y=399 width=532 height=633 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=50.5 y=399 width=532 height=633 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-666.06 x2=-666.23 y1=163.36 y2=163.75 gradientTransform="matrix(532 0 0 633 354760 -102959)"gradientUnits=userSpaceOnUse><stop stop-color=#FFF400 offset=0></stop><stop stop-color=#3C8700 offset=1></stop></linearGradient><ellipse cx=316.5 cy=715.5 rx=266 ry=316.5></ellipse></g><defs><filter x=391 y=-24 width=288 height=283 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=391 y=-24 width=288 height=283 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-664.56 x2=-664.56 y1=163.79 y2=164.79 gradientTransform="matrix(227 0 0 227 151421 -37204)"gradientUnits=userSpaceOnUse><stop stop-color=#FFDF00 offset=0></stop><stop stop-color=#FF9D00 offset=1></stop></linearGradient><circle cx=565.5 cy=89.5 r=113.5></circle><linearGradient x1=-644.5 x2=-645.77 y1=342 y2=342 gradientTransform="matrix(30 0 0 1 19770 -253)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=427 x2=397 y1=89 y2=89 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-641.56 x2=-642.83 y1=196.02 y2=196.07 gradientTransform="matrix(26.5 0 0 5.5 17439 -1025.5)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=430.5 x2=404 y1=55.5 y2=50 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-643.73 x2=-645 y1=185.83 y2=185.9 gradientTransform="matrix(29 0 0 8 19107 -1361)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=431 x2=402 y1=122 y2=130 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-638.94 x2=-640.22 y1=177.09 y2=177.39 gradientTransform="matrix(24 0 0 13 15783 -2145)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=442 x2=418 y1=153 y2=166 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-633.42 x2=-634.7 y1=172.41 y2=173.31 gradientTransform="matrix(20 0 0 19 13137 -3096)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=464 x2=444 y1=180 y2=199 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-619.05 x2=-619.52 y1=170.82 y2=171.82 gradientTransform="matrix(13.83 0 0 22.85 9050 -3703.4)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=491.4 x2=477.5 y1=203 y2=225.9 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-578.5 x2=-578.63 y1=170.31 y2=171.31 gradientTransform="matrix(7.5 0 0 24.5 4860 -3953)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=524.5 x2=517 y1=219.5 y2=244 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=666.5 x2=666.5 y1=170.31 y2=171.31 gradientTransform="matrix(.5 0 0 24.5 231.5 -3944)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=564.5 x2=565 y1=228.5 y2=253 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12>');function FGe(){return bGe()}function GGe(){return kGe()}function VGe(){return SGe()}function JGe(){return wGe()}function UGe(){return AGe()}function WGe(){return(e=AGe()).style.setProperty("transform","rotate(90deg)"),e;var e}function qGe(){return(e=AGe()).style.setProperty("transform","rotate(-90deg)"),e;var e}function $Ge(){return CGe()}function ZGe(){return MGe()}function YGe(){return TGe()}function QGe(){return xGe()}function XGe(){return EGe()}function eVe(){return NGe()}function aVe(){return _Ge()}function tVe(){return PGe()}function nVe(){return jGe()}function iVe(e){return a=LGe(),t=a.firstChild,Ra((()=>Ht(t,"stroke","dark"===e.theme?"#12B76A":"#027A48"))),a;var a,t}function rVe(){return BGe()}function oVe(){return RGe()}function sVe(e){return[ht(Tt,{get when(){return e.checked},get children(){var a=LGe(),t=a.firstChild;return Ra((()=>Ht(t,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}}),ht(Tt,{get when(){return!e.checked},get children(){var a=DGe(),t=a.firstChild;return Ra((()=>Ht(t,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}})]}function lVe(){return zGe()}function uVe(){return OGe()}function cVe(){return KGe()}function dVe(){return HGe()}function mVe(){const e=wt();return a=IGe(),r=(i=(n=(t=a.firstChild).nextSibling).nextSibling).firstChild,s=(o=i.nextSibling).firstChild,c=(u=(l=o.nextSibling).nextSibling).firstChild,m=(d=u.nextSibling).firstChild,g=(p=(h=d.nextSibling).nextSibling).firstChild,v=(f=p.nextSibling).firstChild,k=(b=(y=f.nextSibling).nextSibling).firstChild,w=(S=b.nextSibling).firstChild,M=(C=(A=S.nextSibling).nextSibling).firstChild,x=(T=C.nextSibling).firstChild,_=(N=(E=T.nextSibling).nextSibling).firstChild,j=(P=N.nextSibling).firstChild,R=(B=(L=P.nextSibling).nextSibling).firstChild,z=(D=B.nextSibling).firstChild,H=(K=(O=D.nextSibling).firstChild.nextSibling.nextSibling.nextSibling).nextSibling,F=(I=O.nextSibling).firstChild,V=(G=I.nextSibling).firstChild,re=(ie=(ne=(te=(ae=(ee=(X=(Q=(Y=(Z=($=(q=(W=(U=(J=G.nextSibling).firstChild).nextSibling).nextSibling.firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,se=(oe=J.nextSibling).firstChild,ue=(le=oe.nextSibling).firstChild,me=(de=(ce=le.nextSibling).firstChild).nextSibling,pe=(he=ce.nextSibling).firstChild,fe=(ge=he.nextSibling).firstChild,Re=(Be=(Le=(je=(Pe=(_e=(Ne=(Ee=(xe=(Te=(Me=(Ce=(Ae=(we=(Se=(ke=(be=(ye=(ve=ge.nextSibling).firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,Ht(t,"id",`a-${e}`),Ht(n,"fill",`url(#a-${e})`),Ht(r,"id",`am-${e}`),Ht(o,"id",`b-${e}`),Ht(s,"filter",`url(#am-${e})`),Ht(l,"mask",`url(#b-${e})`),Ht(c,"id",`ah-${e}`),Ht(d,"id",`k-${e}`),Ht(m,"filter",`url(#ah-${e})`),Ht(h,"mask",`url(#k-${e})`),Ht(g,"id",`ae-${e}`),Ht(f,"id",`j-${e}`),Ht(v,"filter",`url(#ae-${e})`),Ht(y,"mask",`url(#j-${e})`),Ht(k,"id",`ai-${e}`),Ht(S,"id",`i-${e}`),Ht(w,"filter",`url(#ai-${e})`),Ht(A,"mask",`url(#i-${e})`),Ht(M,"id",`aj-${e}`),Ht(T,"id",`h-${e}`),Ht(x,"filter",`url(#aj-${e})`),Ht(E,"mask",`url(#h-${e})`),Ht(_,"id",`ag-${e}`),Ht(P,"id",`g-${e}`),Ht(j,"filter",`url(#ag-${e})`),Ht(L,"mask",`url(#g-${e})`),Ht(R,"id",`af-${e}`),Ht(D,"id",`f-${e}`),Ht(z,"filter",`url(#af-${e})`),Ht(O,"mask",`url(#f-${e})`),Ht(K,"id",`m-${e}`),Ht(H,"fill",`url(#m-${e})`),Ht(F,"id",`ak-${e}`),Ht(G,"id",`e-${e}`),Ht(V,"filter",`url(#ak-${e})`),Ht(J,"mask",`url(#e-${e})`),Ht(U,"id",`n-${e}`),Ht(W,"fill",`url(#n-${e})`),Ht(q,"id",`r-${e}`),Ht($,"fill",`url(#r-${e})`),Ht(Z,"id",`s-${e}`),Ht(Y,"fill",`url(#s-${e})`),Ht(Q,"id",`q-${e}`),Ht(X,"fill",`url(#q-${e})`),Ht(ee,"id",`p-${e}`),Ht(ae,"fill",`url(#p-${e})`),Ht(te,"id",`o-${e}`),Ht(ne,"fill",`url(#o-${e})`),Ht(ie,"id",`l-${e}`),Ht(re,"fill",`url(#l-${e})`),Ht(se,"id",`al-${e}`),Ht(le,"id",`d-${e}`),Ht(ue,"filter",`url(#al-${e})`),Ht(ce,"mask",`url(#d-${e})`),Ht(de,"id",`u-${e}`),Ht(me,"fill",`url(#u-${e})`),Ht(pe,"id",`ad-${e}`),Ht(ge,"id",`c-${e}`),Ht(fe,"filter",`url(#ad-${e})`),Ht(ve,"mask",`url(#c-${e})`),Ht(ye,"id",`t-${e}`),Ht(be,"fill",`url(#t-${e})`),Ht(ke,"id",`v-${e}`),Ht(Se,"stroke",`url(#v-${e})`),Ht(we,"id",`aa-${e}`),Ht(Ae,"stroke",`url(#aa-${e})`),Ht(Ce,"id",`w-${e}`),Ht(Me,"stroke",`url(#w-${e})`),Ht(Te,"id",`ac-${e}`),Ht(xe,"stroke",`url(#ac-${e})`),Ht(Ee,"id",`ab-${e}`),Ht(Ne,"stroke",`url(#ab-${e})`),Ht(_e,"id",`y-${e}`),Ht(Pe,"stroke",`url(#y-${e})`),Ht(je,"id",`x-${e}`),Ht(Le,"stroke",`url(#x-${e})`),Ht(Be,"id",`z-${e}`),Ht(Re,"stroke",`url(#z-${e})`),a;var a,t,n,i,r,o,s,l,u,c,d,m,h,p,g,f,v,y,b,k,S,w,A,C,M,T,x,E,N,_,P,j,L,B,R,D,z,O,K,H,I,F,G,V,J,U,W,q,$,Z,Y,Q,X,ee,ae,te,ne,ie,re,oe,se,le,ue,ce,de,me,he,pe,ge,fe,ve,ye,be,ke,Se,we,Ae,Ce,Me,Te,xe,Ee,Ne,_e,Pe,je,Le,Be,Re}var hVe=Ot('<span><svg width=16 height=16 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M6 12L10 8L6 4"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),pVe=Ot('<button title="Copy object to clipboard">'),gVe=Ot('<button title="Remove all items"aria-label="Remove all items">'),fVe=Ot('<button title="Delete item"aria-label="Delete item">'),vVe=Ot('<button title="Toggle value"aria-label="Toggle value">'),yVe=Ot('<button title="Bulk Edit Data"aria-label="Bulk Edit Data">'),bVe=Ot("<div>"),kVe=Ot("<div><button> <span></span> <span> "),SVe=Ot("<input>"),wVe=Ot("<span>"),AVe=Ot("<div><span>:"),CVe=Ot("<div><div><button> [<!>...<!>]");var MVe=e=>{const a=Jze(),t=Hze().shadowDOMTarget?fOe.bind({target:Hze().shadowDOMTarget}):fOe,n=za((()=>"dark"===a()?BVe(t):LVe(t)));return i=hVe(),Ra((()=>It(i,yOe(n().expander,t`
|
|
92
|
+
*/fTe.exports="production"===process.env.NODE_ENV?function(){if(gTe)return vTe;gTe=1;var e="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},t=a.useState,n=a.useEffect,i=a.useLayoutEffect,r=a.useDebugValue;function o(a){var t=a.getSnapshot;a=a.value;try{var n=t();return!e(a,n)}catch(i){return!0}}var s="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(e,a){var s=a(),l=t({inst:{value:s,getSnapshot:a}}),u=l[0].inst,c=l[1];return i((function(){u.value=s,u.getSnapshot=a,o(u)&&c({inst:u})}),[e,s,a]),n((function(){return o(u)&&c({inst:u}),e((function(){o(u)&&c({inst:u})}))}),[e]),r(s),s};return vTe.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:s,vTe}():(yTe||(yTe=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var a=e.getSnapshot;e=e.value;try{var t=a();return!n(e,t)}catch(i){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=a,n="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},i=t.useState,r=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue,l=!1,u=!1,c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,a){return a()}:function(a,c){l||void 0===t.startTransition||(l=!0);var d=c();if(!u){var m=c();n(d,m)||(u=!0)}var h=(m=i({inst:{value:d,getSnapshot:c}}))[0].inst,p=m[1];return o((function(){h.value=d,h.getSnapshot=c,e(h)&&p({inst:h})}),[a,d,c]),r((function(){return e(h)&&p({inst:h}),a((function(){e(h)&&p({inst:h})}))}),[a]),s(d),d};bTe.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),bTe);var kTe=fTe.exports,STe='[cmdk-group=""]',wTe='[cmdk-group-items=""]',ATe='[cmdk-item=""]',CTe=`${ATe}:not([aria-disabled="true"])`,MTe="cmdk-item-select",TTe="data-value",xTe=(e,a,t)=>pTe(e,a,t),ETe=r.createContext(void 0),NTe=()=>r.useContext(ETe),_Te=r.createContext(void 0),PTe=()=>r.useContext(_Te),jTe=r.createContext(void 0),LTe=r.forwardRef(((e,a)=>{let t=WTe((()=>{var a,t;return{search:"",value:null!=(t=null!=(a=e.value)?a:e.defaultValue)?t:"",filtered:{count:0,items:new Map,groups:new Set}}})),n=WTe((()=>new Set)),i=WTe((()=>new Map)),o=WTe((()=>new Map)),s=WTe((()=>new Set)),l=JTe(e),{label:u,children:c,value:d,onValueChange:m,filter:h,shouldFilter:p,loop:g,disablePointerSelection:f=!1,vimBindings:v=!0,...y}=e,b=q9(),k=q9(),S=q9(),w=r.useRef(null),A=YTe();UTe((()=>{if(void 0!==d){let e=d.trim();t.current.value=e,C.emit()}}),[d]),UTe((()=>{A(6,_)}),[]);let C=r.useMemo((()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>t.current,setState:(e,a,n)=>{var i,r,o;if(!Object.is(t.current[e],a)){if(t.current[e]=a,"search"===e)N(),x(),A(1,E);else if("value"===e&&(n||A(5,_),void 0!==(null==(i=l.current)?void 0:i.value))){return void(null==(o=(r=l.current).onValueChange)||o.call(r,null!=a?a:""))}C.emit()}},emit:()=>{s.current.forEach((e=>e()))}})),[]),M=r.useMemo((()=>({value:(e,a,n)=>{var i;a!==(null==(i=o.current.get(e))?void 0:i.value)&&(o.current.set(e,{value:a,keywords:n}),t.current.filtered.items.set(e,T(a,n)),A(2,(()=>{x(),C.emit()})))},item:(e,a)=>(n.current.add(e),a&&(i.current.has(a)?i.current.get(a).add(e):i.current.set(a,new Set([e]))),A(3,(()=>{N(),x(),t.current.value||E(),C.emit()})),()=>{o.current.delete(e),n.current.delete(e),t.current.filtered.items.delete(e);let a=P();A(4,(()=>{N(),(null==a?void 0:a.getAttribute("id"))===e&&E(),C.emit()}))}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{o.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:S,labelId:k,listInnerRef:w})),[]);function T(e,a){var n,i;let r=null!=(i=null==(n=l.current)?void 0:n.filter)?i:xTe;return e?r(e,t.current.search,a):0}function x(){if(!t.current.search||!1===l.current.shouldFilter)return;let e=t.current.filtered.items,a=[];t.current.filtered.groups.forEach((t=>{let n=i.current.get(t),r=0;n.forEach((a=>{let t=e.get(a);r=Math.max(t,r)})),a.push([t,r])}));let n=w.current;j().sort(((a,t)=>{var n,i;let r=a.getAttribute("id"),o=t.getAttribute("id");return(null!=(n=e.get(o))?n:0)-(null!=(i=e.get(r))?i:0)})).forEach((e=>{let a=e.closest(wTe);a?a.appendChild(e.parentElement===a?e:e.closest(`${wTe} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${wTe} > *`))})),a.sort(((e,a)=>a[1]-e[1])).forEach((e=>{var a;let t=null==(a=w.current)?void 0:a.querySelector(`${STe}[${TTe}="${encodeURIComponent(e[0])}"]`);null==t||t.parentElement.appendChild(t)}))}function E(){let e=j().find((e=>"true"!==e.getAttribute("aria-disabled"))),a=null==e?void 0:e.getAttribute(TTe);C.setState("value",a||void 0)}function N(){var e,a,r,s;if(!t.current.search||!1===l.current.shouldFilter)return void(t.current.filtered.count=n.current.size);t.current.filtered.groups=new Set;let u=0;for(let i of n.current){let n=T(null!=(a=null==(e=o.current.get(i))?void 0:e.value)?a:"",null!=(s=null==(r=o.current.get(i))?void 0:r.keywords)?s:[]);t.current.filtered.items.set(i,n),n>0&&u++}for(let[n,o]of i.current)for(let e of o)if(t.current.filtered.items.get(e)>0){t.current.filtered.groups.add(n);break}t.current.filtered.count=u}function _(){var e,a,t;let n=P();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(t=null==(a=n.closest(STe))?void 0:a.querySelector('[cmdk-group-heading=""]'))||t.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=w.current)?void 0:e.querySelector(`${ATe}[aria-selected="true"]`)}function j(){var e;return Array.from((null==(e=w.current)?void 0:e.querySelectorAll(CTe))||[])}function L(e){let a=j()[e];a&&C.setState("value",a.getAttribute(TTe))}function B(e){var a;let t=P(),n=j(),i=n.findIndex((e=>e===t)),r=n[i+e];null!=(a=l.current)&&a.loop&&(r=i+e<0?n[n.length-1]:i+e===n.length?n[0]:n[i+e]),r&&C.setState("value",r.getAttribute(TTe))}function R(e){let a,t=P(),n=null==t?void 0:t.closest(STe);for(;n&&!a;)n=e>0?GTe(n,STe):VTe(n,STe),a=null==n?void 0:n.querySelector(CTe);a?C.setState("value",a.getAttribute(TTe)):B(e)}let D=()=>L(j().length-1),z=e=>{e.preventDefault(),e.metaKey?D():e.altKey?R(1):B(1)},O=e=>{e.preventDefault(),e.metaKey?L(0):e.altKey?R(-1):B(-1)};return r.createElement(y9.div,{ref:a,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:e=>{var a;if(null==(a=y.onKeyDown)||a.call(y,e),!e.defaultPrevented)switch(e.key){case"n":case"j":v&&e.ctrlKey&&z(e);break;case"ArrowDown":z(e);break;case"p":case"k":v&&e.ctrlKey&&O(e);break;case"ArrowUp":O(e);break;case"Home":e.preventDefault(),L(0);break;case"End":e.preventDefault(),D();break;case"Enter":if(!e.nativeEvent.isComposing&&229!==e.keyCode){e.preventDefault();let a=P();if(a){let e=new Event(MTe);a.dispatchEvent(e)}}}}},r.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:XTe},u),QTe(e,(e=>r.createElement(_Te.Provider,{value:C},r.createElement(ETe.Provider,{value:M},e)))))})),BTe=r.forwardRef(((e,a)=>{var t,n;let i=q9(),o=r.useRef(null),s=r.useContext(jTe),l=NTe(),u=JTe(e),c=null!=(n=null==(t=u.current)?void 0:t.forceMount)?n:null==s?void 0:s.forceMount;UTe((()=>{if(!c)return l.item(i,null==s?void 0:s.id)}),[c]);let d=ZTe(i,o,[e.value,e.children,o],e.keywords),m=PTe(),h=$Te((e=>e.value&&e.value===d.current)),p=$Te((e=>!(!c&&!1!==l.filter())||(!e.search||e.filtered.items.get(i)>0)));function g(){var e,a;f(),null==(a=(e=u.current).onSelect)||a.call(e,d.current)}function f(){m.setState("value",d.current,!0)}if(r.useEffect((()=>{let a=o.current;if(a&&!e.disabled)return a.addEventListener(MTe,g),()=>a.removeEventListener(MTe,g)}),[p,e.onSelect,e.disabled]),!p)return null;let{disabled:v,value:y,onSelect:b,forceMount:k,keywords:S,...w}=e;return r.createElement(y9.div,{ref:qTe([o,a]),...w,id:i,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!h,"data-disabled":!!v,"data-selected":!!h,onPointerMove:v||l.getDisablePointerSelection()?void 0:f,onClick:v?void 0:g},e.children)})),RTe=r.forwardRef(((e,a)=>{let{heading:t,children:n,forceMount:i,...o}=e,s=q9(),l=r.useRef(null),u=r.useRef(null),c=q9(),d=NTe(),m=$Te((e=>!(!i&&!1!==d.filter())||(!e.search||e.filtered.groups.has(s))));UTe((()=>d.group(s)),[]),ZTe(s,l,[e.value,e.heading,u]);let h=r.useMemo((()=>({id:s,forceMount:i})),[i]);return r.createElement(y9.div,{ref:qTe([l,a]),...o,"cmdk-group":"",role:"presentation",hidden:!m||void 0},t&&r.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),QTe(e,(e=>r.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},r.createElement(jTe.Provider,{value:h},e)))))})),DTe=r.forwardRef(((e,a)=>{let{alwaysRender:t,...n}=e,i=r.useRef(null),o=$Te((e=>!e.search));return t||o?r.createElement(y9.div,{ref:qTe([i,a]),...n,"cmdk-separator":"",role:"separator"}):null})),zTe=r.forwardRef(((e,a)=>{let{onValueChange:t,...n}=e,i=null!=e.value,o=PTe(),s=$Te((e=>e.search)),l=$Te((e=>e.value)),u=NTe(),c=r.useMemo((()=>{var e;let a=null==(e=u.listInnerRef.current)?void 0:e.querySelector(`${ATe}[${TTe}="${encodeURIComponent(l)}"]`);return null==a?void 0:a.getAttribute("id")}),[]);return r.useEffect((()=>{null!=e.value&&o.setState("search",e.value)}),[e.value]),r.createElement(y9.input,{ref:a,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":c,id:u.inputId,type:"text",value:i?e.value:s,onChange:e=>{i||o.setState("search",e.target.value),null==t||t(e.target.value)}})})),OTe=r.forwardRef(((e,a)=>{let{children:t,label:n="Suggestions",...i}=e,o=r.useRef(null),s=r.useRef(null),l=NTe();return r.useEffect((()=>{if(s.current&&o.current){let e,a=s.current,t=o.current,n=new ResizeObserver((()=>{e=requestAnimationFrame((()=>{t.style.setProperty("--cmdk-list-height",a.offsetHeight.toFixed(1)+"px")}))}));return n.observe(a),()=>{cancelAnimationFrame(e),n.unobserve(a)}}}),[]),r.createElement(y9.div,{ref:qTe([o,a]),...i,"cmdk-list":"",role:"listbox","aria-label":n,id:l.listId},QTe(e,(e=>r.createElement("div",{ref:qTe([s,l.listInnerRef]),"cmdk-list-sizer":""},e))))})),KTe=r.forwardRef(((e,a)=>{let{open:t,onOpenChange:n,overlayClassName:i,contentClassName:o,container:s,...l}=e;return r.createElement(jZ,{open:t,onOpenChange:n},r.createElement(BZ,{container:s},r.createElement(RZ,{"cmdk-overlay":"",className:i}),r.createElement(DZ,{"aria-label":e.label,"cmdk-dialog":"",className:o},r.createElement(LTe,{ref:a,...l}))))})),HTe=r.forwardRef(((e,a)=>$Te((e=>0===e.filtered.count))?r.createElement(y9.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null)),ITe=r.forwardRef(((e,a)=>{let{progress:t,children:n,label:i="Loading...",...o}=e;return r.createElement(y9.div,{ref:a,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},QTe(e,(e=>r.createElement("div",{"aria-hidden":!0},e))))})),FTe=Object.assign(LTe,{List:OTe,Item:BTe,Input:zTe,Group:RTe,Separator:DTe,Dialog:KTe,Empty:HTe,Loading:ITe});function GTe(e,a){let t=e.nextElementSibling;for(;t;){if(t.matches(a))return t;t=t.nextElementSibling}}function VTe(e,a){let t=e.previousElementSibling;for(;t;){if(t.matches(a))return t;t=t.previousElementSibling}}function JTe(e){let a=r.useRef(e);return UTe((()=>{a.current=e})),a}var UTe="undefined"==typeof window?r.useEffect:r.useLayoutEffect;function WTe(e){let a=r.useRef();return void 0===a.current&&(a.current=e()),a}function qTe(e){return a=>{e.forEach((e=>{"function"==typeof e?e(a):null!=e&&(e.current=a)}))}}function $Te(e){let a=PTe(),t=()=>e(a.snapshot());return kTe.useSyncExternalStore(a.subscribe,t,t)}function ZTe(e,a,t,n=[]){let i=r.useRef(),o=NTe();return UTe((()=>{var r;let s=(()=>{var e;for(let a of t){if("string"==typeof a)return a.trim();if("object"==typeof a&&"current"in a)return a.current?null==(e=a.current.textContent)?void 0:e.trim():i.current}})(),l=n.map((e=>e.trim()));o.value(e,s,l),null==(r=a.current)||r.setAttribute(TTe,s),i.current=s})),i}var YTe=()=>{let[e,a]=r.useState(),t=WTe((()=>new Map));return UTe((()=>{t.current.forEach((e=>e())),t.current=new Map}),[e]),(e,n)=>{t.current.set(e,n),a({})}};function QTe({asChild:e,children:a},t){return e&&r.isValidElement(a)?r.cloneElement(function(e){let a=e.type;return"function"==typeof a?a(e.props):"render"in a?a.render(e.props):e}(a),{ref:a.ref},t(a.props.children)):t(a)}var XTe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const exe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe,{ref:n,className:XO("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a})));exe.displayName=FTe.displayName;const axe=r.forwardRef((({className:e,searchIcon:a,...n},i)=>t.jsxs("div",{className:"flex items-center border-b px-3",children:[a||t.jsx(Iz,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 "}),t.jsx(FTe.Input,{ref:i,className:XO("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]})));axe.displayName=FTe.Input.displayName;const txe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.List,{ref:n,className:XO("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a})));txe.displayName=FTe.List.displayName;const nxe=r.forwardRef(((e,a)=>t.jsx(FTe.Empty,{ref:a,className:"py-6 text-center text-sm",...e})));nxe.displayName=FTe.Empty.displayName;const ixe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.Group,{ref:n,className:XO("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...a})));ixe.displayName=FTe.Group.displayName;r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.Separator,{ref:n,className:XO("-mx-1 h-px bg-border",e),...a}))).displayName=FTe.Separator.displayName;const rxe=r.forwardRef((({className:e,...a},n)=>t.jsx(FTe.Item,{ref:n,className:XO("relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...a})));function oxe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function sxe(...e){return a=>{let t=!1;const n=e.map((e=>{const n=oxe(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():oxe(e[a],null)}}}}function lxe(...e){return r.useCallback(sxe(...e),e)}function uxe(e){const a=cxe(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(mxe);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function cxe(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{const a=r(...e);return i(...e),a}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?sxe(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}rxe.displayName=FTe.Item.displayName;var dxe=Symbol("radix.slottable");function mxe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===dxe}var hxe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=uxe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),pxe=globalThis?.document?r.useLayoutEffect:()=>{};var gxe=e=>{const{present:a,children:t}=e,n=function(e){const[a,t]=r.useState(),n=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,t)=>a[e][t]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=fxe(n.current);o.current="mounted"===l?e:"none"}),[l]),pxe((()=>{const a=n.current,t=i.current;if(t!==e){const n=o.current,r=fxe(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(t&&n!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),pxe((()=>{if(a){let e;const t=a.ownerDocument.defaultView??window,r=r=>{const o=fxe(n.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const n=a.style.animationFillMode;a.style.animationFillMode="forwards",e=t.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=n)}))}},s=e=>{e.target===a&&(o.current=fxe(n.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{t.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{n.current=e?getComputedStyle(e):null,t(e)}),[])}}(a),i="function"==typeof t?t({present:n.isPresent}):r.Children.only(t),o=lxe(n.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof t||n.isPresent?r.cloneElement(i,{ref:o}):null};function fxe(e){return e?.animationName||"none"}function vxe(...e){const a=e[0];if(1===e.length)return a;const t=()=>{const t=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const n=t.reduce(((a,{useScope:t,scopeName:n})=>({...a,...t(e)[`__scope${n}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:n})),[n])}};return t.scopeName=a.scopeName,t}function yxe(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}gxe.displayName="Presence";var bxe=r.createContext(void 0);function kxe(e,a,{checkForDefaultPrevented:t=!0}={}){return function(n){if(e?.(n),!1===t||!n.defaultPrevented)return a?.(n)}}var Sxe="ScrollArea",[wxe,Axe]=function(e,a=[]){let n=[];const i=()=>{const a=n.map((e=>r.createContext(e)));return function(t){const n=t?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...t,[e]:n}})),[t,n])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=n.length;n=[...n,i];const l=a=>{const{scope:n,children:i,...l}=a,u=n?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return t.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(t,n){const l=r.useContext(n?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${a}\``)}]},vxe(i,...a)]}(Sxe),[Cxe,Mxe]=wxe(Sxe),Txe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,type:i="hover",dir:o,scrollHideDelay:s=600,...l}=e,[u,c]=r.useState(null),[d,m]=r.useState(null),[h,p]=r.useState(null),[g,f]=r.useState(null),[v,y]=r.useState(null),[b,k]=r.useState(0),[S,w]=r.useState(0),[A,C]=r.useState(!1),[M,T]=r.useState(!1),x=lxe(a,(e=>c(e))),E=function(e){const a=r.useContext(bxe);return e||a||"ltr"}(o);return t.jsx(Cxe,{scope:n,type:i,dir:E,scrollHideDelay:s,scrollArea:u,viewport:d,onViewportChange:m,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:f,scrollbarXEnabled:A,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:M,onScrollbarYEnabledChange:T,onCornerWidthChange:k,onCornerHeightChange:w,children:t.jsx(hxe.div,{dir:E,...l,ref:x,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})}));Txe.displayName=Sxe;var xxe="ScrollAreaViewport",Exe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,children:i,nonce:o,...s}=e,l=Mxe(xxe,n),u=lxe(a,r.useRef(null),l.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),t.jsx(hxe.div,{"data-radix-scroll-area-viewport":"",...s,ref:u,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})}));Exe.displayName=xxe;var Nxe="ScrollAreaScrollbar",_xe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:l}=o,u="horizontal"===e.orientation;return r.useEffect((()=>(u?s(!0):l(!0),()=>{u?s(!1):l(!1)})),[u,s,l]),"hover"===o.type?t.jsx(Pxe,{...i,ref:a,forceMount:n}):"scroll"===o.type?t.jsx(jxe,{...i,ref:a,forceMount:n}):"auto"===o.type?t.jsx(Lxe,{...i,ref:a,forceMount:n}):"always"===o.type?t.jsx(Bxe,{...i,ref:a}):null}));_xe.displayName=Nxe;var Pxe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),[s,l]=r.useState(!1);return r.useEffect((()=>{const e=o.scrollArea;let a=0;if(e){const t=()=>{window.clearTimeout(a),l(!0)},n=()=>{a=window.setTimeout((()=>l(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",t),e.addEventListener("pointerleave",n),()=>{window.clearTimeout(a),e.removeEventListener("pointerenter",t),e.removeEventListener("pointerleave",n)}}}),[o.scrollArea,o.scrollHideDelay]),t.jsx(gxe,{present:n||s,children:t.jsx(Lxe,{"data-state":s?"visible":"hidden",...i,ref:a})})})),jxe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),s="horizontal"===e.orientation,l=Xxe((()=>c("SCROLL_END")),100),[u,c]=(d={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer(((e,a)=>d[e][a]??e),"hidden"));var d;return r.useEffect((()=>{if("idle"===u){const e=window.setTimeout((()=>c("HIDE")),o.scrollHideDelay);return()=>window.clearTimeout(e)}}),[u,o.scrollHideDelay,c]),r.useEffect((()=>{const e=o.viewport,a=s?"scrollLeft":"scrollTop";if(e){let t=e[a];const n=()=>{const n=e[a];t!==n&&(c("SCROLL"),l()),t=n};return e.addEventListener("scroll",n),()=>e.removeEventListener("scroll",n)}}),[o.viewport,s,c,l]),t.jsx(gxe,{present:n||"hidden"!==u,children:t.jsx(Bxe,{"data-state":"hidden"===u?"hidden":"visible",...i,ref:a,onPointerEnter:kxe(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:kxe(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),Lxe=r.forwardRef(((e,a)=>{const n=Mxe(Nxe,e.__scopeScrollArea),{forceMount:i,...o}=e,[s,l]=r.useState(!1),u="horizontal"===e.orientation,c=Xxe((()=>{if(n.viewport){l(u?n.viewport.offsetWidth<n.viewport.scrollWidth:n.viewport.offsetHeight<n.viewport.scrollHeight)}}),10);return eEe(n.viewport,c),eEe(n.content,c),t.jsx(gxe,{present:i||s,children:t.jsx(Bxe,{"data-state":s?"visible":"hidden",...o,ref:a})})})),Bxe=r.forwardRef(((e,a)=>{const{orientation:n="vertical",...i}=e,o=Mxe(Nxe,e.__scopeScrollArea),s=r.useRef(null),l=r.useRef(0),[u,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Wxe(u.viewport,u.content),m={...i,sizes:u,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:e=>l.current=e};function h(e,a){return function(e,a,t,n="ltr"){const i=qxe(t),r=i/2,o=a||r,s=t.scrollbar.paddingStart+o,l=t.scrollbar.size-t.scrollbar.paddingEnd-(i-o),u=t.content-t.viewport,c="ltr"===n?[0,u]:[-1*u,0];return Zxe([s,l],c)(e)}(e,l.current,u,a)}return"horizontal"===n?t.jsx(Rxe,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=$xe(o.viewport.scrollLeft,u,o.dir);s.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=h(e,o.dir))}}):"vertical"===n?t.jsx(Dxe,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=$xe(o.viewport.scrollTop,u);s.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=h(e))}}):null})),Rxe=r.forwardRef(((e,a)=>{const{sizes:n,onSizesChange:i,...o}=e,s=Mxe(Nxe,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=lxe(a,c,s.onScrollbarXChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),t.jsx(Kxe,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":qxe(n)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.x),onDragScroll:a=>e.onDragScroll(a.x),onWheelScroll:(a,t)=>{if(s.viewport){const n=s.viewport.scrollLeft+a.deltaX;e.onWheelScroll(n),Yxe(n,t)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Uxe(l.paddingLeft),paddingEnd:Uxe(l.paddingRight)}})}})})),Dxe=r.forwardRef(((e,a)=>{const{sizes:n,onSizesChange:i,...o}=e,s=Mxe(Nxe,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=lxe(a,c,s.onScrollbarYChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),t.jsx(Kxe,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":qxe(n)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.y),onDragScroll:a=>e.onDragScroll(a.y),onWheelScroll:(a,t)=>{if(s.viewport){const n=s.viewport.scrollTop+a.deltaY;e.onWheelScroll(n),Yxe(n,t)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Uxe(l.paddingTop),paddingEnd:Uxe(l.paddingBottom)}})}})})),[zxe,Oxe]=wxe(Nxe),Kxe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,sizes:i,hasThumb:o,onThumbChange:s,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...p}=e,g=Mxe(Nxe,n),[f,v]=r.useState(null),y=lxe(a,(e=>v(e))),b=r.useRef(null),k=r.useRef(""),S=g.viewport,w=i.content-i.viewport,A=yxe(m),C=yxe(c),M=Xxe(h,10);function T(e){if(b.current){d({x:e.clientX-b.current.left,y:e.clientY-b.current.top})}}return r.useEffect((()=>{const e=e=>{const a=e.target,t=f?.contains(a);t&&A(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[S,f,w,A]),r.useEffect(C,[i,C]),eEe(f,M),eEe(g.content,M),t.jsx(zxe,{scope:n,scrollbar:f,hasThumb:o,onThumbChange:yxe(s),onThumbPointerUp:yxe(l),onThumbPositionChange:C,onThumbPointerDown:yxe(u),children:t.jsx(hxe.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:kxe(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),b.current=f.getBoundingClientRect(),k.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(e)}})),onPointerMove:kxe(e.onPointerMove,T),onPointerUp:kxe(e.onPointerUp,(e=>{const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=k.current,g.viewport&&(g.viewport.style.scrollBehavior=""),b.current=null}))})})})),Hxe="ScrollAreaThumb",Ixe=r.forwardRef(((e,a)=>{const{forceMount:n,...i}=e,r=Oxe(Hxe,e.__scopeScrollArea);return t.jsx(gxe,{present:n||r.hasThumb,children:t.jsx(Fxe,{ref:a,...i})})})),Fxe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,style:i,...o}=e,s=Mxe(Hxe,n),l=Oxe(Hxe,n),{onThumbPositionChange:u}=l,c=lxe(a,(e=>l.onThumbChange(e))),d=r.useRef(void 0),m=Xxe((()=>{d.current&&(d.current(),d.current=void 0)}),100);return r.useEffect((()=>{const e=s.viewport;if(e){const a=()=>{if(m(),!d.current){const a=Qxe(e,u);d.current=a,u()}};return u(),e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}}),[s.viewport,m,u]),t.jsx(hxe.div,{"data-state":l.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:kxe(e.onPointerDownCapture,(e=>{const a=e.target.getBoundingClientRect();l.onThumbPointerDown({x:e.clientX-a.left,y:e.clientY-a.top})})),onPointerUp:kxe(e.onPointerUp,l.onThumbPointerUp)})}));Ixe.displayName=Hxe;var Gxe="ScrollAreaCorner",Vxe=r.forwardRef(((e,a)=>{const n=Mxe(Gxe,e.__scopeScrollArea),i=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&i?t.jsx(Jxe,{...e,ref:a}):null}));Vxe.displayName=Gxe;var Jxe=r.forwardRef(((e,a)=>{const{__scopeScrollArea:n,...i}=e,o=Mxe(Gxe,n),[s,l]=r.useState(0),[u,c]=r.useState(0),d=Boolean(s&&u);return eEe(o.scrollbarX,(()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)})),eEe(o.scrollbarY,(()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),l(e)})),d?t.jsx(hxe.div,{...i,ref:a,style:{width:s,height:u,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null}));function Uxe(e){return e?parseInt(e,10):0}function Wxe(e,a){const t=e/a;return isNaN(t)?0:t}function qxe(e){const a=Wxe(e.viewport,e.content);return Math.max((e.scrollbar.size-(e.scrollbar.paddingStart+e.scrollbar.paddingEnd))*a,18)}function $xe(e,a,t="ltr"){const n=qxe(a),i=a.content-a.viewport,r=a.scrollbar.size-(a.scrollbar.paddingStart+a.scrollbar.paddingEnd)-n,o=function(e,[a,t]){return Math.min(t,Math.max(a,e))}(e,"ltr"===t?[0,i]:[-1*i,0]);return Zxe([0,i],[0,r])(o)}function Zxe(e,a){return t=>{if(e[0]===e[1]||a[0]===a[1])return a[0];return a[0]+(a[1]-a[0])/(e[1]-e[0])*(t-e[0])}}function Yxe(e,a){return e>0&&e<a}var Qxe=(e,a=()=>{})=>{let t={left:e.scrollLeft,top:e.scrollTop},n=0;return function i(){const r={left:e.scrollLeft,top:e.scrollTop};(t.left!==r.left||t.top!==r.top)&&a(),t=r,n=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(n)};function Xxe(e,a){const t=yxe(e),n=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(n.current)),[]),r.useCallback((()=>{window.clearTimeout(n.current),n.current=window.setTimeout(t,a)}),[t,a])}function eEe(e,a){const t=yxe(a);pxe((()=>{let a=0;if(e){const n=new ResizeObserver((()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(t)}));return n.observe(e),()=>{window.cancelAnimationFrame(a),n.unobserve(e)}}}),[e,t])}var aEe=Txe,tEe=Exe,nEe=Vxe;const iEe=r.forwardRef((({className:e,children:a,...n},i)=>t.jsxs(aEe,{ref:i,className:$Z("relative overflow-hidden",e),...n,children:[t.jsx(tEe,{className:"h-full w-full rounded-[inherit]",children:a}),t.jsx(rEe,{}),t.jsx(nEe,{})]})));iEe.displayName=aEe.displayName;const rEe=r.forwardRef((({className:e,orientation:a="vertical",...n},i)=>t.jsx(_xe,{ref:i,orientation:a,className:$Z("flex touch-none select-none transition-colors","vertical"===a&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:t.jsx(Ixe,{className:"relative flex-1 rounded-full bg-border"})})));rEe.displayName=_xe.displayName;var oEe=r.forwardRef(((e,a)=>{const{children:n,...i}=e,o=r.Children.toArray(n),s=o.find(uEe);if(s){const e=s.props.children,n=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(sEe,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,n):null})}return t.jsx(sEe,{...i,ref:a,children:n})}));oEe.displayName="Slot";var sEe=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?IZ(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));sEe.displayName="SlotClone";var lEe=({children:e})=>t.jsx(t.Fragment,{children:e});function uEe(e){return r.isValidElement(e)&&e.type===lEe}var cEe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const n=r.forwardRef(((e,n)=>{const{asChild:i,...r}=e,o=i?oEe:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(o,{...r,ref:n})}));return n.displayName=`Primitive.${a}`,{...e,[a]:n}}),{}),dEe="horizontal",mEe=["horizontal","vertical"],hEe=r.forwardRef(((e,a)=>{const{decorative:n,orientation:i=dEe,...r}=e,o=function(e){return mEe.includes(e)}(i)?i:dEe;return t.jsx(cEe.div,{"data-orientation":o,...n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...r,ref:a})}));hEe.displayName="Separator";var pEe=hEe;const gEe=r.forwardRef((({className:e,orientation:a="horizontal",decorative:n=!0,...i},r)=>t.jsx(pEe,{ref:r,decorative:n,orientation:a,className:XO("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...i})));function fEe({options:e,onValueChange:a,selectedValues:n,setSelectedValues:i,maxCount:o,placeholder:s="Select options",title:l="Select Items",searchPlaceholder:u="Search items...",emptyMessage:c="No items found",extraCommandItems:d=[],canOpen:m=!0,singleSelect:h=!1}){const[p,g]=r.useState(!1),[f,v]=r.useState(""),[y,b]=r.useState(n),k=r.useMemo((()=>Array.from(new Map([...e].filter((e=>e&&"string"==typeof e.value&&"string"==typeof e.label&&""!==e.value.trim()&&""!==e.label.trim())).map((e=>[e.value,e]))).values())),[e]),S=r.useMemo((()=>{if(!f)return k;return[...k.filter((e=>y.includes(e.value))),...k.filter((e=>!y.includes(e.value))).filter((e=>e.label.toLowerCase().includes(f.toLowerCase())))]}),[k,f,y]),w=r.useCallback((()=>n.map((a=>{const t=e.find((e=>e.value===a));return{value:a,label:t?.label||a}}))),[n,e]),A=e=>{if(h)return b([e]),a([e]),i([e]),void g(!1);b((a=>a.includes(e)?a.filter((a=>a!==e)):o&&a.length>=o?a:[...a,e]))};r.useEffect((()=>{p&&(b(n),v(""))}),[p,n]);const C=y.length,M=S.filter((e=>y.includes(e.value))).length,T=w(),x=!o||y.length<o,E=r.useMemo((()=>S.filter((e=>y.includes(e.value)))),[S,y]),N=r.useMemo((()=>S.filter((e=>!y.includes(e.value)))),[S,y]);return t.jsxs(ZZ,{open:p&&m,onOpenChange:m?g:void 0,children:[t.jsx(YZ,{asChild:!0,children:t.jsxs(H5,{variant:"outline",disabled:!m,className:XO("w-full justify-between text-left font-normal h-9 p-3",!m&&"opacity-50 cursor-not-allowed"),children:[t.jsx("div",{className:"flex flex-nowrap items-center gap-1 max-w-[70%]",children:0===T.length?t.jsx("span",{className:"text-muted-foreground",children:s}):h?t.jsx(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label}):T.length<=2?T.map((e=>t.jsx(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:e.label},e.value))):t.jsxs(t.Fragment,{children:[t.jsx(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label},T[0].value),t.jsxs(a6,{variant:"secondary",className:"text-xs whitespace-nowrap",children:["+",T.length-1," more"]})]})}),t.jsx(V5.DropdownMenuTrigger,{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0"})]})}),t.jsxs(eY,{className:"max-w-md w-full max-h-[80vh] p-0",children:[t.jsx(aY,{className:"p-6 pb-4",children:t.jsxs(nY,{className:"flex items-center gap-2 text-xl",children:[t.jsx(V5.UsersIcon,{className:"h-5 w-5 text-primary"}),l]})}),t.jsx("div",{className:"px-6 pb-4",children:t.jsxs("div",{className:"relative",children:[t.jsx(V5.SearchIcon,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(gte,{placeholder:u,value:f,onChange:e=>v(e.target.value),className:"pl-10 h-11"})]})}),!h&&t.jsx("div",{className:"px-6 pb-4",children:t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsxs("span",{className:"text-muted-foreground",children:[C," of ",k.length," selected",o&&` (max ${o})`]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H5,{variant:"ghost",size:"sm",onClick:()=>{const e=S.filter((e=>!y.includes(e.value))),a=o?e.slice(0,o-y.length):e;b((e=>[...e,...a.map((e=>e.value))]))},disabled:!x||M===S.length,className:"h-8 text-xs",children:"Select All"}),t.jsx(H5,{variant:"ghost",size:"sm",onClick:()=>{const e=new Set(S.map((e=>e.value)));b((a=>a.filter((a=>!e.has(a)))))},disabled:0===M,className:"h-8 text-xs",children:"Clear All"})]})]})}),t.jsx(gEe,{}),t.jsx(iEe,{className:"flex-1 max-h-[300px]",children:t.jsx(exe,{className:"rounded-none border-none",children:t.jsxs(ixe,{children:[d.length>0&&t.jsxs(t.Fragment,{children:[d.map(((e,a)=>t.jsx("div",{className:"px-3 py-2",children:e(g)},`extra-command-${a}`))),t.jsx(gEe,{className:"my-2"})]}),0===S.length?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(V5.SearchIcon,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:c})]}):t.jsxs(t.Fragment,{children:[!h&&E.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:["Selected (",E.length,")"]}),E.map((e=>t.jsxs(rxe,{onSelect:()=>A(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors hover:bg-muted/50 cursor-pointer",children:[t.jsx(oTe,{checked:!0,disabled:!1,onChange:()=>A(e.value),className:"flex-shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),t.jsx(V5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value))),t.jsx(gEe,{className:"my-2"})]}),t.jsx("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:h?"Options":`Available (${N.length})`}),N.map((e=>{const a=y.includes(e.value),n=!h&&!x;return t.jsxs(rxe,{onSelect:()=>!n&&A(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors "+(n?"opacity-50 cursor-not-allowed":"hover:bg-muted/50 cursor-pointer"),children:[!h&&t.jsx(oTe,{checked:a,disabled:n,onChange:()=>!n&&A(e.value),className:"flex-shrink-0"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),a&&t.jsx(V5.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value)}))]})]})})}),!h&&t.jsxs(t.Fragment,{children:[t.jsx(gEe,{}),t.jsx("div",{className:"p-6 pt-4",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(H5,{variant:"outline",onClick:()=>{b(n),v(""),g(!1)},className:"flex-1",children:"Cancel"}),t.jsxs(H5,{onClick:()=>{a(y),i(y),g(!1)},className:"flex-1 bg-primary hover:bg-primary/90",children:["Apply (",C,")"]})]})})]})]})]})}gEe.displayName=pEe.displayName;const vEe=e=>t.jsx(lye,{as:"span",className:"inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200",children:e.node.attrs.displayName}),yEe=Pve.create({name:"mergeField",group:"inline",inline:!0,atom:!0,addAttributes:()=>({templateName:{default:null,parseHTML:e=>e.getAttribute("data-template-name")},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name")}}),parseHTML:()=>[{tag:"span[data-merge-field]"}],renderHTML:({HTMLAttributes:e})=>["span",vfe(e,{"data-merge-field":"true"})],renderText:({node:e})=>e.attrs.templateName,addNodeView:()=>hye(vEe)}),bEe=({value:e,onChange:n,maxLength:i,mergeFieldsResponse:r,editorRef:o})=>{const[s,l]=a.useState(0),u=a.useMemo((()=>r?.mergeFields?.flatMap((e=>e.entries))??[]),[r]),c=a.useCallback((e=>{if(!e)return"";return e.replace(/\{\{.*?\}\}/g,(e=>{const a=u.find((a=>a.value===e));return a?`<span class="inline-flex items-center px-1 py-0.5 rounded text-xs bg-blue-100 text-blue-800 font-medium border border-blue-200" data-merge-field="true" data-template-name="${a.value}" data-display-name="${a.label}">${a.label}</span>`:e}))}),[u]),d=oye({extensions:[Mbe,yEe],content:"",editorProps:{attributes:{class:"min-h-[300px] p-3 border border-gray-200 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none prose prose-sm max-w-none"}},onUpdate:({editor:e})=>{const a=e.getText();l(a.length),n(a)}});a.useEffect((()=>{if(d&&e){if(d.getText()!==e){const a=c(e);d.commands.setContent(a,!1),l(e.length)}}}),[d,e,c]);const m=a.useCallback((e=>{if(e.length>0&&d){const a=u.find((a=>a.value===e[0]));a&&d.chain().focus().insertContent({type:"mergeField",attrs:{templateName:a.value,displayName:a.label}}).run()}}),[d,u]),h=a.useMemo((()=>u.map((e=>({label:e.label,value:e.value})))),[u]),p=((e,a)=>({colorClass:e>=a?"text-red-500":e>320?"text-amber-500":"text-gray-500",text:`${e}/${a} characters`}))(s,i);return d?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{ref:o,children:t.jsx(Jve,{editor:d})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(fEe,{options:h,selectedValues:[],setSelectedValues:()=>{},onValueChange:m,placeholder:"Add merge field",title:"Merge Fields",searchPlaceholder:"Search merge fields...",emptyMessage:"No merge fields found",singleSelect:!0}),t.jsx(Fue,{title:"Merge Fields"})]}),t.jsxs("div",{className:`flex items-center gap-2 text-sm transition-colors duration-300 ${p.colorClass}`,children:[p.text,s>jwe&&t.jsx(Fue,{title:"The maximum number of characters for an SMS is 1500. This includes the company name, if you have one, and the merge fields. The recommended limit is 320 characters for best delivery rates. Click to learn more",onClick:()=>{window.open("https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging","_blank")},link:{url:"https://help.twilio.com/articles/360033806753-Maximum-Message-Length-with-Twilio-Programmable-Messaging",text:"The maximum number of characters for an SMS is 1500. This includes the company name, if you have one, and the merge fields. The recommended limit is 320 characters for best delivery rates. Click to learn more"}})]})]})]}):t.jsx("div",{children:"Loading editor..."})},kEe=({mergeFieldsResponse:e})=>{const n=B5(),i=R5(),{data:r}=$re(),o=a.useCallback((()=>{const e=n?.actionData?.find((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId===i?.id));return e?.actionMetadata.communicationGroupId}),[n?.actionData,i?.id]),{channelSenders:s}=Jre(),{data:l,isLoading:u}=Twe(),{channelAccounts:c}=Fre(),{toast:d}=Ve(),{updateCommunicationGroup:m,isUpdating:h}=Ye(),[p,g]=a.useState(null),[f,v]=a.useState(!1),[y,b]=a.useState(null),[k,S]=a.useState(null),[w,A]=a.useState([]),[C,M]=a.useState(null),[T,x]=a.useState(!1),[E,N]=a.useState(!1),_=a.useRef(null),[P,j]=a.useState(null),[L,B]=a.useState(null),[R,D]=a.useState(!1),z=a.useMemo((()=>Nle({channelSenders:s?.results??[],channelAccounts:c?.results??[],smsApplication:r})),[s,c,r]);a.useEffect((()=>{T||(j(w.length>0?w[0]:null),B(null),D(!1))}),[T,w]),a.useEffect((()=>{i?.textMessageMediaUrls&&A(i.textMessageMediaUrls)}),[i?.textMessageMediaUrls]);a.useEffect((()=>{i&&!1===E&&(i.smsChannelSenderId&&null===p&&g(i.smsChannelSenderId),i.smsMessageBody&&null===k&&(S(i.smsMessageBody),M(i.smsMessageBody)),i.textMessageCompanyName&&null===y&&b(i.textMessageCompanyName),i.textMessageMediaUrls&&0===w.length&&A(i.textMessageMediaUrls),T&&(null===C&&M(k),w.length>0&&!P&&!R&&j(w[0])),void 0!==s&&E&&(p?p&&i?.id&&m({groupId:i.id,params:{smsChannelSenderId:p}}):z?.[0]&&(g(z[0].channelSender.id),i?.id&&m({groupId:i.id,params:{smsChannelSenderId:z[0].channelSender.id}}))),N(!0))}),[i,p,k,y,w,E,T,C,P,R,s,z,m]);a.useEffect((()=>{y||!l?.name||f||(v(!0),b(l.branding?.brandName?l.branding?.brandName:l.name))}),[y,l?.name,f,l?.branding?.brandName]);return c&&s&&!u&&void 0!==z&&void 0!==r?0===z?.length&&r?.status!==Ele.PENDING?t.jsx(zMe,{}):t.jsxs("div",{children:[t.jsx(ZZ,{open:T,onOpenChange:x,children:t.jsxs(eY,{hideCloseButton:!0,className:"max-w-[50vw]",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"SMS Editor"}),t.jsx(iY,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),t.jsxs("div",{className:"",children:[P&&t.jsx("div",{className:"flex justify-center mb-6",children:t.jsx("div",{className:"relative group w-fit",children:t.jsx("img",{src:P,alt:"SMS attachment preview",className:"max-h-48 max-w-xs rounded-xl shadow-lg border border-gray-200 object-contain bg-white transition-transform duration-200",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}})})}),t.jsx(bEe,{value:C,onChange:M,maxLength:1500-(y?.length||0),mergeFieldsResponse:e}),t.jsx("div",{className:"mt-4 flex items-center justify-end",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"file",ref:_,onChange:async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await HMe(e.result),t=IMe(a);B(t),j(a),D(!1),i?.id&&m({groupId:i.id,params:{textMessageMedia:[t]}},{onError:()=>{d({title:"Error updating image",description:"Please contact your administrator"})}})}catch(a){d({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),t.jsx(H5,P?{variant:"outline",onClick:()=>{_.current&&(_.current.value=""),i?.id&&m({groupId:i.id,params:{textMessageMedia:[]}},{onSuccess:()=>{j(null),B(null),D(!1),A([]),_.current&&(_.current.value="")},onError:()=>{d({title:"Error removing image",description:"Please contact your administrator"})}})},className:"px-4",disabled:R||h,children:"Remove Image"}:{variant:"outline",onClick:()=>{_.current?.click()},className:"px-4",disabled:w.length>=1||R||null!==L||h,children:"Add Image"}),t.jsx(H5,{variant:"outline",onClick:()=>{M(k),x(!1),j(w.length>0?w[0]:null),B(null),D(!1)},className:"px-4",children:"Cancel"}),t.jsx(H5,{onClick:()=>{if(C&&C.length>1500)return void d({title:"SMS is too long",description:"Please shorten your message"});if(null===C||0===C.length)return void d({title:"Oops",description:"Please enter a message"});S(C);const e=o();e&&m({groupId:e,params:{smsChannelSenderId:p,smsMessageBody:C,textMessageCompanyName:y,textMessageMedia:L?[L]:R?[]:void 0}},{onSuccess:()=>{x(!1),j(null),B(null),D(!1)},onError:()=>{d({title:"Error updating SMS",description:"Please contact your administrator"})}})},className:"px-4",disabled:h,children:"Save Changes"})]})})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(Kbe,{className:"text-foreground",children:"From Number"}),t.jsxs(pwe,{onValueChange:e=>{g(e),i?.id&&m({groupId:i.id,params:{smsChannelSenderId:e}})},value:p??void 0,children:[t.jsx(vwe,{children:t.jsx(fwe,{placeholder:"Select number",children:p?FMe({channelSenderId:p,smsChannelSenders:z}):"Select number"})}),t.jsx(kwe,{children:z?.map((e=>t.jsx(Swe,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName??e.channelSender.channelSenderMetadata.from??"Select number"},e.channelSender.id)))})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx(Kbe,{className:"text-foreground",children:"Company Name"}),t.jsx(Fue,{title:"Adding your company name can help customers identify who they are talking to"})]}),t.jsx(gte,{placeholder:"Enter company name",value:y??"",onChange:e=>{const a=e.target.value;a.length>100?d({title:"Oops",description:"Company name cannot exceed 100 characters",variant:"destructive"}):b(a??null)},disabled:!p&&!r})]})]}),t.jsxs("div",{className:"border rounded-lg p-4",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx("h3",{className:"font-medium",children:"Preview"}),t.jsx("div",{children:t.jsx(H5,{onClick:()=>x(!0),className:"text-sm px-3 py-1 rounded ",disabled:0===(z?.length??0)&&void 0===r||n?.status!==ha.DRAFT,children:"Edit"})})]}),t.jsx("div",{children:r?p||r?t.jsx(t.Fragment,{children:k?t.jsx(JMe,{body:OMe({companyName:y??void 0,smsBody:k}),imageUrls:w}):t.jsx(Ewe,{type:"sms"})}):t.jsx(Dwe,{type:"sms"}):t.jsx("div",{children:"Submit an application"})})]})]})]}):t.jsx("div",{children:t.jsx(lY,{text:["Loading..."]})})},SEe=()=>{const e=R5(),{getMergeFields:a,isGetting:n}=Qe(e?.id??void 0);return n||!a?t.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(lY,{text:["Fetching Content..."]})}):t.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[t.jsx(Jwe,{title:lH("engage:automation"),type:_we.SMS}),t.jsx(kEe,{mergeFieldsResponse:a})]})},wEe=e=>e.friendlyName||e.from||e.messageServiceSid||"Unknown Sender";function AEe(e,a,{checkForDefaultPrevented:t=!0}={}){return function(n){if(e?.(n),!1===t||!n.defaultPrevented)return a?.(n)}}function CEe(e,a=[]){let n=[];const i=()=>{const a=n.map((e=>r.createContext(e)));return function(t){const n=t?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...t,[e]:n}})),[t,n])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=n.length;n=[...n,i];const l=a=>{const{scope:n,children:i,...l}=a,u=n?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return t.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(t,n){const l=r.useContext(n?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${a}\``)}]},MEe(i,...a)]}function MEe(...e){const a=e[0];if(1===e.length)return a;const t=()=>{const t=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const n=t.reduce(((a,{useScope:t,scopeName:n})=>({...a,...t(e)[`__scope${n}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:n})),[n])}};return t.scopeName=a.scopeName,t}function TEe(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function xEe(...e){return a=>{let t=!1;const n=e.map((e=>{const n=TEe(e,a);return t||"function"!=typeof n||(t=!0),n}));if(t)return()=>{for(let a=0;a<n.length;a++){const t=n[a];"function"==typeof t?t():TEe(e[a],null)}}}}function EEe(...e){return r.useCallback(xEe(...e),e)}function NEe(e){const a=_Ee(e),n=r.forwardRef(((e,n)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(jEe);if(l){const e=l.props.children,i=s.map((a=>a===l?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(a,{...o,ref:n,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return t.jsx(a,{...o,ref:n,children:i})}));return n.displayName=`${e}.Slot`,n}function _Ee(e){const a=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?xEe(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var PEe=Symbol("radix.slottable");function jEe(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===PEe}var LEe=globalThis?.document?r.useLayoutEffect:()=>{},BEe=r[" useId ".trim().toString()]||(()=>{}),REe=0;function DEe(e){const[a,t]=r.useState(BEe());return LEe((()=>{t((e=>e??String(REe++)))}),[e]),e||(a?`radix-${a}`:"")}var zEe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const n=NEe(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?n:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});var OEe=r[" useInsertionEffect ".trim().toString()]||LEe;function KEe({prop:e,defaultProp:a,onChange:t=()=>{},caller:n}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[t,n]=r.useState(e),i=r.useRef(t),o=r.useRef(a);return OEe((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==t&&(o.current?.(t),i.current=t)}),[t,i]),[t,n,o]}({defaultProp:a,onChange:t}),l=void 0!==e,u=l?e:i;{const a=r.useRef(void 0!==e);r.useEffect((()=>{const e=a.current;if(e!==l){}a.current=l}),[l,n])}const c=r.useCallback((a=>{if(l){const t=function(e){return"function"==typeof e}(a)?a(e):a;t!==e&&s.current?.(t)}else o(a)}),[l,e,o,s]);return[u,c]}var HEe=r.createContext(void 0);function IEe(e){const a=r.useContext(HEe);return e||a||"ltr"}var FEe="rovingFocusGroup.onEntryFocus",GEe={bubbles:!1,cancelable:!0},VEe="RovingFocusGroup",[JEe,UEe,WEe]=function(e){const n=e+"CollectionProvider",[i,r]=CEe(n),[o,s]=i(n,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:n,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return t.jsx(o,{scope:n,itemMap:s,collectionRef:r,children:i})};l.displayName=n;const u=e+"CollectionSlot",c=NEe(u),d=a.forwardRef(((e,a)=>{const{scope:n,children:i}=e,r=EEe(a,s(u,n).collectionRef);return t.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=NEe(m),g=a.forwardRef(((e,n)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=EEe(n,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),t.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(t){const n=s(e+"CollectionConsumer",t);return a.useCallback((()=>{const e=n.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(n.itemMap.values()).sort(((e,t)=>a.indexOf(e.ref.current)-a.indexOf(t.ref.current)))}),[n.collectionRef,n.itemMap])},r]}(VEe),[qEe,$Ee]=CEe(VEe,[WEe]),[ZEe,YEe]=qEe(VEe),QEe=r.forwardRef(((e,a)=>t.jsx(JEe.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(JEe.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(XEe,{...e,ref:a})})})));QEe.displayName=VEe;var XEe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:m=!1,...h}=e,p=r.useRef(null),g=EEe(a,p),f=IEe(s),[v,y]=KEe({prop:l,defaultProp:u??null,onChange:c,caller:VEe}),[b,k]=r.useState(!1),S=function(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}(d),w=UEe(n),A=r.useRef(!1),[C,M]=r.useState(0);return r.useEffect((()=>{const e=p.current;if(e)return e.addEventListener(FEe,S),()=>e.removeEventListener(FEe,S)}),[S]),t.jsx(ZEe,{scope:n,orientation:i,dir:f,loop:o,currentTabStopId:v,onItemFocus:r.useCallback((e=>y(e)),[y]),onItemShiftTab:r.useCallback((()=>k(!0)),[]),onFocusableItemAdd:r.useCallback((()=>M((e=>e+1))),[]),onFocusableItemRemove:r.useCallback((()=>M((e=>e-1))),[]),children:t.jsx(zEe.div,{tabIndex:b||0===C?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:AEe(e.onMouseDown,(()=>{A.current=!0})),onFocus:AEe(e.onFocus,(e=>{if(e.target===e.currentTarget&&!A.current&&!b){const a=new CustomEvent(FEe,GEe);if(e.currentTarget.dispatchEvent(a),!a.defaultPrevented){const e=w().filter((e=>e.focusable));nNe([e.find((e=>e.active)),e.find((e=>e.id===v)),...e].filter(Boolean).map((e=>e.ref.current)),m)}}A.current=!1})),onBlur:AEe(e.onBlur,(()=>k(!1)))})})})),eNe="RovingFocusGroupItem",aNe=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:o=!1,tabStopId:s,children:l,...u}=e,c=DEe(),d=s||c,m=YEe(eNe,n),h=m.currentTabStopId===d,p=UEe(n),{onFocusableItemAdd:g,onFocusableItemRemove:f,currentTabStopId:v}=m;return r.useEffect((()=>{if(i)return g(),()=>f()}),[i,g,f]),t.jsx(JEe.ItemSlot,{scope:n,id:d,focusable:i,active:o,children:t.jsx(zEe.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...u,ref:a,onMouseDown:AEe(e.onMouseDown,(e=>{i?m.onItemFocus(d):e.preventDefault()})),onFocus:AEe(e.onFocus,(()=>m.onItemFocus(d))),onKeyDown:AEe(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void m.onItemShiftTab();if(e.target!==e.currentTarget)return;const a=function(e,a,t){const n=function(e,a){return"rtl"!==a?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,t);return"vertical"===a&&["ArrowLeft","ArrowRight"].includes(n)||"horizontal"===a&&["ArrowUp","ArrowDown"].includes(n)?void 0:tNe[n]}(e,m.orientation,m.dir);if(void 0!==a){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter((e=>e.focusable)).map((e=>e.ref.current));if("last"===a)i.reverse();else if("prev"===a||"next"===a){"prev"===a&&i.reverse();const r=i.indexOf(e.currentTarget);i=m.loop?(n=r+1,(t=i).map(((e,a)=>t[(n+a)%t.length]))):i.slice(r+1)}setTimeout((()=>nNe(i)))}var t,n})),children:"function"==typeof l?l({isCurrentTabStop:h,hasTabStop:null!=v}):l})})}));aNe.displayName=eNe;var tNe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function nNe(e,a=!1){const t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus({preventScroll:a}),document.activeElement!==t)return}}var iNe=QEe,rNe=aNe;var oNe=e=>{const{present:a,children:t}=e,n=function(e){const[a,t]=r.useState(),n=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,t)=>a[e][t]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=sNe(n.current);o.current="mounted"===l?e:"none"}),[l]),LEe((()=>{const a=n.current,t=i.current;if(t!==e){const n=o.current,r=sNe(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(t&&n!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),LEe((()=>{if(a){let e;const t=a.ownerDocument.defaultView??window,r=r=>{const o=sNe(n.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const n=a.style.animationFillMode;a.style.animationFillMode="forwards",e=t.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=n)}))}},s=e=>{e.target===a&&(o.current=sNe(n.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{t.clearTimeout(e),a.removeEventListener("animationstart",s),a.removeEventListener("animationcancel",r),a.removeEventListener("animationend",r)}}u("ANIMATION_END")}),[a,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{n.current=e?getComputedStyle(e):null,t(e)}),[])}}(a),i="function"==typeof t?t({present:n.isPresent}):r.Children.only(t),o=EEe(n.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof t||n.isPresent?r.cloneElement(i,{ref:o}):null};function sNe(e){return e?.animationName||"none"}oNe.displayName="Presence";var lNe="Tabs",[uNe,cNe]=CEe(lNe,[$Ee]),dNe=$Ee(),[mNe,hNe]=uNe(lNe),pNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,value:i,onValueChange:r,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:u="automatic",...c}=e,d=IEe(l),[m,h]=KEe({prop:i,onChange:r,defaultProp:o??"",caller:lNe});return t.jsx(mNe,{scope:n,baseId:DEe(),value:m,onValueChange:h,orientation:s,dir:d,activationMode:u,children:t.jsx(zEe.div,{dir:d,"data-orientation":s,...c,ref:a})})}));pNe.displayName=lNe;var gNe="TabsList",fNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,loop:i=!0,...r}=e,o=hNe(gNe,n),s=dNe(n);return t.jsx(iNe,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:i,children:t.jsx(zEe.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:a})})}));fNe.displayName=gNe;var vNe="TabsTrigger",yNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,value:i,disabled:r=!1,...o}=e,s=hNe(vNe,n),l=dNe(n),u=SNe(s.baseId,i),c=wNe(s.baseId,i),d=i===s.value;return t.jsx(rNe,{asChild:!0,...l,focusable:!r,active:d,children:t.jsx(zEe.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...o,ref:a,onMouseDown:AEe(e.onMouseDown,(e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():s.onValueChange(i)})),onKeyDown:AEe(e.onKeyDown,(e=>{[" ","Enter"].includes(e.key)&&s.onValueChange(i)})),onFocus:AEe(e.onFocus,(()=>{d||r||!("manual"!==s.activationMode)||s.onValueChange(i)}))})})}));yNe.displayName=vNe;var bNe="TabsContent",kNe=r.forwardRef(((e,a)=>{const{__scopeTabs:n,value:i,forceMount:o,children:s,...l}=e,u=hNe(bNe,n),c=SNe(u.baseId,i),d=wNe(u.baseId,i),m=i===u.value,h=r.useRef(m);return r.useEffect((()=>{const e=requestAnimationFrame((()=>h.current=!1));return()=>cancelAnimationFrame(e)}),[]),t.jsx(oNe,{present:o||m,children:({present:n})=>t.jsx(zEe.div,{"data-state":m?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!n,id:d,tabIndex:0,...l,ref:a,style:{...e.style,animationDuration:h.current?"0s":void 0},children:n&&s})})}));function SNe(e,a){return`${e}-trigger-${a}`}function wNe(e,a){return`${e}-content-${a}`}kNe.displayName=bNe;var ANe=fNe,CNe=yNe,MNe=kNe;const TNe=pNe,xNe=r.forwardRef((({className:e,...a},n)=>t.jsx(ANe,{ref:n,className:XO("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a})));xNe.displayName=ANe.displayName;const ENe=r.forwardRef((({className:e,...a},n)=>t.jsx(CNe,{ref:n,className:XO("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...a})));ENe.displayName=CNe.displayName;const NNe=r.forwardRef((({className:e,...a},n)=>t.jsx(MNe,{ref:n,className:XO("ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a})));NNe.displayName=MNe.displayName;const _Ne=({type:e})=>{const n=R5(),i=B5(),{toast:r}=Ve(),[o,s]=a.useState(!1),{resetCommunicationGroupToDefault:l,isPending:u}=ea(),c=e===_we.EMAIL?"Email":"SMS";return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("div",{className:"flex items-center gap-2",children:!!n&&(n.type===Fwe.MANAGED&&(e===_we.SMS?n.updatedFromDefault?.text_message_body:n.updatedFromDefault?.email_text_body||n.updatedFromDefault?.email_html_body))&&t.jsx(t.Fragment,{children:u?t.jsx(lY,{}):t.jsx(H5,{variant:"outline",size:"sm",disabled:u,onClick:()=>s(!0),children:"Reset To Default"})})})}),t.jsx(ZZ,{open:o,onOpenChange:s,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsxs(aY,{children:[t.jsx(nY,{className:"text-xl font-semibold",children:"Reset To Default"}),t.jsxs(iY,{className:"text-base text-muted-foreground",children:["Are you sure you want to reset this ",c.toLowerCase()," ","template to its default state? This action cannot be undone."]})]}),t.jsxs(tY,{className:"flex flex-row justify-end gap-3 mt-6",children:[t.jsx(H5,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:async()=>{n&&i?l({communicationGroupId:n.id,automationId:i.id,type:e===_we.EMAIL?"email":"sms"},{onSuccess:()=>{r({title:lH("engage:success.communication_reset","Communication reset to default!")}),s(!1)},onSettled:()=>{s(!1)},onError:()=>{r({title:"Error updating",description:"No sender found",variant:"destructive"})}}):r({title:"Error updating",description:"No sender found",variant:"destructive"})},disabled:u,children:"Reset To Default"})]})]})})]})},PNe="reach-styles-module__base___r-a1U",jNe=GD([PNe],{variants:{variant:{default:"reach-styles-module__default___vu2Rt",primary:"reach-styles-module__primary___mGKjo",success:"reach-styles-module__success___xn1Y1",warning:"reach-styles-module__warning___jdyU9",error:"reach-styles-module__error___Z-3IS"},size:{default:"reach-styles-module__sizeDefault___oS6W2",sm:"reach-styles-module__sizeSm___GI826",lg:"reach-styles-module__sizeLg___J--WF"},position:{default:"reach-styles-module__positionDefault___visr6",top:"reach-styles-module__positionTop___y6h-n",bottom:"reach-styles-module__positionBottom___vYLkd",inline:"reach-styles-module__positionInline___NjZsw"}},defaultVariants:{variant:"default",size:"default",position:"default"}}),LNe=({children:e})=>t.jsx("div",{className:"rounded-lg p-6 bg-background flex-1 min-h-0 flex items-center justify-center overflow-y-auto",children:e}),BNe=({emailBody:e})=>t.jsx(LNe,{children:t.jsx(Lwe,{html:e})}),RNe=({onOpenChange:e})=>t.jsx("div",{role:"button",tabIndex:0,"aria-label":"Close dialog",onClick:()=>e(!1),onKeyDown:a=>{"Enter"!==a.key&&" "!==a.key||e(!1)},className:"absolute top-3 right-3 z-20 rounded-full p-2 bg-white/80 shadow-lg border border-gray-200 hover:bg-primary/90 hover:text-white active:bg-primary/95 transition-all duration-200 focus:outline-none focus:ring-4 focus:ring-primary/30 focus:ring-offset-2 group cursor-pointer",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)"},children:t.jsx(V5.CloseButton,{className:"w-5 h-5 text-primary group-hover:text-primary-foreground group-active:text-primary-foreground transition-colors duration-200"})}),DNe=({expandDialogContent:e})=>{const[n,i]=a.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(ZZ,{open:n,onOpenChange:i,children:t.jsxs(eY,{hideCloseButton:!0,className:"w-[80vw] h-[80vh] max-h-none bg-transparent border-none max-w-screen-lg ",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Expanded Preview"}),t.jsx(iY,{children:"Expanded view of communication content"})]}),t.jsxs("div",{className:"h-full flex flex-col overflow-hidden rounded-xl",children:[t.jsx(RNe,{onOpenChange:i}),e]})]})}),t.jsx(H5,{size:"sm",variant:"outline",onClick:()=>i(!0),children:t.jsx(V5.ExpandIcon,{className:"w-3 h-3"})})]})},zNe=({label:e,value:a,className:n})=>t.jsxs("div",{className:"flex items-center gap-1 min-w-0 max-w-full flex-shrink",children:[t.jsxs("span",{className:"sr-only",children:[e,":"]}),t.jsx("span",{className:XO("truncate",n),children:a})]}),ONe=({mergeFieldsResponse:e})=>{const n=B5(),i=R5(),r=(()=>{const{channelSenders:e}=Jre(),{channelAccounts:t}=Fre();return a.useMemo((()=>e?.results&&t?.results?e.results.filter((e=>e.channelSenderMetadata.userPart)).flatMap((e=>{const a=t.results.find((a=>a.id===e.channelAccountId));return!a?.channelAccountMetadata||a.channelAccountMetadata.type!==Gre.REACH_MANAGED&&a.channelAccountMetadata.type!==Gre.REACH_MANAGED_SES?[]:[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,channelSenderMetadata:e.channelSenderMetadata}]})):[]),[e?.results,t?.results])})(),{channelSenders:o}=Jre(),{updateCommunicationGroup:s}=Ye(),[l,u]=a.useState(!1),{state:{replyToSettingsText:c,replyToSettingsLink:d,fromNameSettingsText:m,fromNameSettingsLink:h}}=a.useContext(rY),[p,g]=a.useState(!1),[f,v]=a.useState(i?.emailChannelSenderId||null),[y,b]=a.useState(i?.emailSubject||null),[k,S]=a.useState(i?.emailPreviewText||null),[w,A]=a.useState(""),[C,M]=a.useState(""),[T,x]=a.useState(!0),[E,N]=a.useState(!1),[_,P]=a.useState(null),[j,L]=a.useState(i?.emailSubject||null),B=wwe(y,500),R=wwe(k,500);if(a.useEffect((()=>{if(o?.results&&f){const e=o.results.find((e=>e.id===f));e&&(E&&!T||M(e.channelSenderMetadata.emailReplyTo),T&&A(e.channelSenderMetadata.emailFromName),x(!1))}}),[o?.results,f,E,T]),a.useEffect((()=>{i?.emailChannelSenderId&&!f&&v(i.emailChannelSenderId),i&&null!==i.emailSubject&&null===y&&(b(i.emailSubject),L(i.emailSubject)),i&&null!==i.emailPreviewText&&null===k&&S(i.emailPreviewText)}),[i,f,y,k]),a.useEffect((()=>{if(f&&B&&i?.id&&!T){g(!0);(async()=>{try{await s({groupId:i.id,params:{emailChannelSenderId:f,emailSubject:B,...R&&{emailPreviewText:R}}})}catch(e){}finally{g(!1)}})()}}),[f,B,R,i?.id,s,T]),!n||!i||!i.emailChannelSenderId)return null;const D=r.find((e=>e.channelSenderId===i.emailChannelSenderId)),z=w||D?.fullDomain,O=y,K=k;return t.jsx("div",{className:"w-full bg-background rounded-lg p-3",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 overflow-hidden flex-1",children:[z&&t.jsx(zNe,{label:"From",value:z,className:"font-bold"}),O&&t.jsx(zNe,{label:"Subject",value:t.jsx(VMe,{content:O,mergeFieldsResponse:e,variant:"minimal",className:"font-normal"}),className:"font-normal"}),K&&t.jsx(zNe,{label:"Preview",value:t.jsx(VMe,{content:K,mergeFieldsResponse:e,variant:"minimal",className:"text-muted-foreground/50 italic"}),className:"text-muted-foreground/50 italic"})]}),t.jsxs(Nre,{open:l,onOpenChange:e=>{u(e),""===y?.trim()&&j&&!1===e&&(b(j),P(null))},children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{size:"sm",variant:"outline",disabled:n.status!==ha.DRAFT,children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]})}),t.jsx(Pre,{className:"w-96",align:"end",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"From Email"}),t.jsxs(pwe,{onValueChange:e=>{v(e),x(!0),N(!1)},value:f??void 0,disabled:p,children:[t.jsx(vwe,{className:"bg-background hover:bg-accent/50 focus:bg-accent/50 data-[state=open]:bg-accent/50 transition-colors",children:t.jsx(fwe,{placeholder:"Select email",className:"text-muted-foreground",children:f?r?.find((e=>e.channelSenderId===f))?.fullDomain:""})}),t.jsx(kwe,{children:r?.map((e=>t.jsx(Swe,{value:e.channelSenderId,children:e.fullDomain},e.channelSenderId)))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"From Name"}),t.jsx(Fue,{title:m||"From name can be configured under settings in the home screen",link:h?{url:h}:void 0})]}),t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground bg-muted/50 rounded-md",children:w||t.jsx("span",{className:"italic text-muted-foreground/70",children:"Not set"})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Reply-To"}),t.jsx(Fue,{title:c||"Reply to email can be configured under settings in the home screen",link:d?{url:d}:void 0})]}),t.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground bg-muted/50 rounded-md",children:C||(f?r?.find((e=>e.channelSenderId===f))?.fullDomain:"")||t.jsx("span",{className:"italic text-muted-foreground/70",children:"Not set"})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Subject"}),t.jsx("span",{className:"text-xs text-red-500 ml-0.5",children:"*"})]}),t.jsx(Ebe,{value:y,onChange:b,mergeFieldsResponse:e,placeholder:"Enter email subject",className:"bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50 "+(_?"border-red-300 focus:border-red-500":""),ariaLabel:"Insert merge field into subject"}),_&&t.jsx("p",{className:"text-xs text-red-500 animate-pulse",children:_})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Preview Text"}),t.jsx(Fue,{title:"This text will be used for the preview text of the email in the inbox"})]}),t.jsx(Ebe,{value:k,onChange:S,mergeFieldsResponse:e})]})]})})]})]})})},KNe=({type:e,disablePreviewSubtext:a=!1})=>{const n="sms"===e?"SMS":"Email";return t.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center justify-center bg-zinc-50/80 border border-zinc-100 rounded-2xl shadow-md px-6 py-12 max-w-[90vw] w-full sm:max-w-md mx-auto text-center",style:{containerType:"inline-size"},children:[t.jsx("sms"===e?V5.SmsIcon:V5.EmailIcon,{className:"w-12 h-12 text-zinc-500 mb-4"}),t.jsxs("h2",{className:"text-xl font-semibold text-zinc-800 mb-2",children:["No ",n," Content Yet"]}),!a&&t.jsxs("p",{className:"text-zinc-500 text-base mb-1",children:["Click"," ",t.jsx("span",{className:"font-medium text-zinc-700",children:"Edit content"})," to start crafting your ",n," message."]})]})})},HNe=a.forwardRef((({onClick:e},a)=>t.jsxs(H5,{ref:a,variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 flex items-center gap-2 shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:e,children:[t.jsx(V5.PreviewButton,{className:"w-4 h-4"}),t.jsx("span",{className:"font-medium text-sm",children:"Test"})]})));HNe.displayName="PreviewButton";const INe=e=>/^[^\s@.]+(?:\.[^\s@.]+)*@[^\s@.]+(?:\.[^\s@.]+)+$/.test(e),FNe=e=>{if(!/^[0-9\s()+.-]+$/.test(e))return!1;const a=e.replace(/\D/g,"");return e.startsWith("+")?a.length>=10&&a.length<=15:10===a.length||!(11!==a.length||!a.startsWith("1"))},GNe=e=>{const a=e.replace(/\D/g,"");if(10===a.length)return`(${a.slice(0,3)}) ${a.slice(3,6)}-${a.slice(6)}`;if(11===a.length&&a.startsWith("1"))return`+1 (${a.slice(1,4)}) ${a.slice(4,7)}-${a.slice(7)}`;if(a.length>0){const t=e.startsWith("+")?"+":"",n=a.slice((e.startsWith("+"),0));return`${t}${n.match(/.{1,4}/g)?.join("-")||n}`}return e},VNe=({automation:e,type:n,setOpenSendPreviewPopup:i,open:r})=>{const[o,s]=a.useState(""),[l,u]=a.useState(""),[c,d]=a.useState(null),[m,h]=a.useState(!1),[p,g]=a.useState(""),[f,v]=a.useState(!1),{sendTestCommunication:y,sendError:b,isSendSuccess:k}=Xe(),{toast:S}=Ve(),w=e.actionData?.find((e=>"send_communication"===e.actionType)),A=w?.actionMetadata.communicationGroupId,{communicationGroup:C,isGetting:M}=Ze(A??void 0),{data:T}=x5({includeSegments:e.includeSegmentIds,excludeSegments:e.excludeSegmentIds,automationId:e.id}),x=a.useRef(null),E=a.useMemo((()=>[...T?.recipients??[]].filter((e=>!(!e.firstName||!e.lastName)&&(!("email"===n&&!e.email)&&!("sms"===n&&!e.phone))))),[T?.recipients,n]),N=a.useCallback((()=>{if(!A)return Promise.resolve(null);if(!C)return Promise.reject(new Error("Communication group not loaded"));switch(n){case"email":return Promise.resolve(C.emailChannelSenderId);case"sms":return Promise.resolve(C.smsChannelSenderId);default:return Promise.reject(new Error(`Unsupported type: ${n}`))}}),[C,n,A]);a.useEffect((()=>{(async()=>{try{const e=await N();d(e)}catch(e){d(null)}finally{h(!0)}})()}),[N]),a.useEffect((()=>{k&&(S({title:"Success",description:`Preview ${"email"===n?"email":"SMS"} sent successfully!`}),i(!1))}),[k,n,i,S]),a.useEffect((()=>{b&&(S({title:"Error",description:`Failed to send preview: ${b.message}`,variant:"destructive"}),i(!1))}),[b,S,i]),a.useEffect((()=>{r&&(s(""),u(""),g(""),v(!1))}),[r]),a.useEffect((()=>{!r&&f&&setTimeout((()=>{document.body.style.pointerEvents=""}),0)}),[r,f]);const _="email"===n?"email address":"phone number",P="email"===n?"email":"text";if(!m||M||!T)return t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsx(lY,{text:["Fetching sender data","Fetching recipients"]})});if(!c)return t.jsx("div",{className:"flex justify-center items-center h-full",children:t.jsxs("div",{className:"text-center flex flex-col justify-center items-center gap-2",children:[t.jsx(V5.AlertCircleIcon,{className:"h-12 w-12 text-gray-400 mb-4"}),t.jsx("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"No sender found"}),t.jsx("p",{className:"text-gray-500",children:"Please update the automation to include a sender for this type"})]})});const j="email"===n&&(null===C?.emailSubject||null===C?.emailChannelSenderId);return t.jsxs("div",{className:"",ref:x,children:[t.jsxs("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:["Send Test ",P]}),t.jsx(gte,{type:"email"===n?"email":"tel",placeholder:`Enter ${_}`,value:o,onChange:e=>{s(e.target.value),u("")},className:"w-full px-3 py-3 border border-gray-300 rounded-lg text-base \n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent\n placeholder-gray-400"}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Enter a ",_," to preview this ",P,"."]}),t.jsx("div",{className:"my-4 border-t border-gray-200"}),t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(pwe,{value:p,onValueChange:e=>{g(e)},onOpenChange:e=>{v(e),!e&&x.current&&x.current.focus()},children:[t.jsx(vwe,{className:"w-full bg-white border border-gray-300 rounded-lg text-base\n focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:t.jsx(fwe,{children:p?T?.recipients.find((e=>e.id===p))?.firstName+" "+T?.recipients.find((e=>e.id===p))?.lastName:"Preview as"})}),t.jsx(kwe,{position:"popper",className:"z-[100]",children:t.jsx(gwe,{children:E.map((e=>t.jsx(Swe,{value:e.id,className:"cursor-pointer hover:bg-gray-50",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{className:"font-medium",children:[e.firstName," ",e.lastName]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[e.email&&`Email: ${e.email}`,e.email&&e.phone&&" • ",e.phone&&`Phone: ${e.phone}`]})]})},`${e.firstName}-${e.lastName}`)))})})]}),p&&t.jsxs(t.Fragment,{children:[t.jsx(H5,{variant:"ghost",size:"icon",onClick:()=>g(""),disabled:j,className:`h-10 w-10 rounded-lg hover:bg-gray-100 ${j&&"cursor-not-allowed"}`,title:"Clear selection",children:t.jsx(V5.CloseButton,{className:"h-4 w-4 text-gray-500"})}),j&&t.jsx("p",{className:"text-xs text-amber-600 mt-1",children:"Please select a sender and subject first"})]})]}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Test using real customer data to preview how merge tags (like name) will appear. If left blank, you'll see raw placeholders (e.g."," ","{{First Name}}",")."]})]}),l&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-4 border-t border-gray-200"}),t.jsx("p",{className:"text-red-500 text-sm mb-4 -mt-2",children:l})]}),t.jsx(H5,{onClick:()=>{if(!("email"===n?INe(o):FNe(o)))return void u(`Please enter a ${_}`);if(!c)return void u("No sender found, please update the automation first!");const a=e.actionData?.find((e=>"send_communication"===e.actionType)),t=a?.actionMetadata.communicationGroupId;if(!t)return Promise.resolve(null);y({id:t,params:"email"===n?{emailAddress:o,previewAsRecipientId:p}:{phoneNumber:o,previewAsRecipientId:p}})},disabled:!o,className:"w-full disabled:cursor-not-allowed",children:"Send Test"})]})},JNe=({open:e,onOpenChange:a,automation:n})=>t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Send Preview Email"}),t.jsx(iY,{children:"Send a preview email to the automation."})]}),t.jsx(VNe,{automation:n,type:"email",setOpenSendPreviewPopup:a,open:e})]})}),UNe=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1})=>{const r=B5(),o=R5(),{channelSenders:s}=Jre(),{channelAccounts:l}=Fre(),{data:u,isLoading:c}=xwe(),{state:{selectedActionId:d}}=a.useContext(S5),[m,h]=a.useState(!1),[p,g]=a.useState(!1),[f,v]=a.useState(null),[y,b]=a.useState(!1),[k,S]=a.useState(!1),[w,A]=a.useState({width:0,height:0}),{getMergeFields:C}=Qe(o?.id??void 0);a.useEffect((()=>{null===f&&u&&p&&(u?.uiDefaults||v(!0),u?.uiDefaults?.emailHelpDialogShow&&!f&&v(!0))}),[u,f,p]),a.useEffect((()=>{const e=()=>{A({width:window.innerWidth,height:window.innerHeight})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]);if(!r||!o||void 0===s||void 0===l||!d||c)return null;const M=o.emailHtmlBody||"",T=M.length>0,x=Uwe({channelSenders:s?.results??[],channelAccounts:l?.results??[]}),E=o.emailChannelSenderId?o.emailSubject?o.emailHtmlBody?null:"Please first ensure you have an email content":"Please first ensure you have an email subject":"Please first select an email sender",N=r.status===ha.DRAFT&&!n,_=!e&&T,P=!o.emailChannelSenderId||0===x.length,j=()=>{const e=t.jsxs(H5,{size:"sm",variant:"outline",disabled:!N,className:XO(!N&&"cursor-not-allowed"),onClick:()=>g(!0),children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]});return N?e:t.jsx(Fue,{alertText:"You can only edit the content if we are in the draft state.",asChild:!0,className:"cursor-not-allowed",children:t.jsx("div",{className:"inline-block cursor-not-allowed",children:e})})},L=()=>{const e=t.jsx(HNe,{onClick:()=>h(!0)});return E?t.jsx(Fue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:e}):e};return t.jsxs("div",{className:"flex-1 flex flex-col items-center pt-4",children:[t.jsx(ZZ,{open:null!==f&&f,onOpenChange:v,children:t.jsxs(eY,{className:"max-h-[86vh] gap-0 overflow-visible max-w-3xl w-full h-full",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Preview Help"}),t.jsx(iY,{children:"Learn more about the email preview and how to use it to create your email."})]}),t.jsx(Rwe,{})]})}),t.jsx(ZZ,{open:p,onOpenChange:g,children:t.jsxs(eY,{className:"min-w-[100vw] min-h-[100vh]",hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault()},children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Email Editor"}),t.jsx(iY,{children:"Edit your email content using the visual editor. Use the details section above to modify sender and subject settings."})]}),t.jsxs("div",{className:"w-full h-full",children:[t.jsxs("div",{className:"flex justify-between items-center p-1 border-b",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(H5,{size:"sm",onClick:()=>v(!0),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:"Help"}),t.jsx(V5.InfoIcon,{className:"w-4 h-4"})]})})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Nbe,{})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(H5,{variant:"destructive",onClick:()=>{S(!0)},className:"text-sm px-3 py-1 rounded",children:"Cancel"}),t.jsx(H5,{onClick:()=>b(!0),className:"text-sm px-3 py-1 rounded",children:"Save"})]})]}),r&&C&&t.jsx(Hwe,{cancelClicked:k,setCancelClicked:S,showStripoEditor:p,automation:r,setShowStripoEditor:g,saveClicked:y,setSaveClicked:b,stripoDialogDimensions:w,mergeFieldsResponse:C,actionId:d})]})]})}),x.length>0&&t.jsx(JNe,{open:m,onOpenChange:h,automation:r}),P&&t.jsx("div",{className:"px-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"Email Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The email channel is currently disabled. To send email messages, please enable the channel by selecting a valid email sender."})]})]})})})}),T?t.jsx("div",{className:"relative flex-1 w-full flex flex-col overflow-hidden",children:t.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col",children:t.jsxs("div",{className:"flex flex-col space-y-4 px-4 pb-20",children:[t.jsx("div",{className:"w-full flex-shrink-0 max-w-2xl mx-auto rounded-md",children:t.jsx(ONe,{mergeFieldsResponse:C})}),t.jsxs("div",{className:"rounded-lg bg-background flex-1 min-h-0 flex flex-col items-center max-w-2xl mx-auto w-full",children:[t.jsxs("div",{className:"flex items-center space-x-2 w-full justify-end p-3",children:[t.jsx(_Ne,{type:_we.EMAIL}),t.jsx(j,{}),_&&t.jsx(L,{}),T&&t.jsx(DNe,{expandDialogContent:t.jsx(BNe,{emailBody:M})})]}),t.jsx(Lwe,{html:M})]}),t.jsx("p",{className:"text-center text-sm text-muted-foreground flex-shrink-0 pt-4",children:"These previews show exactly how your messages will appear to your customers"})]})})}):t.jsxs(t.Fragment,{children:[P&&t.jsx("div",{className:"px-4 pt-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"Email Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The email channel is currently disabled. To send email messages, please enable the channel by selecting a valid email sender."})]})]})})})}),t.jsx(KNe,{type:"email",disablePreviewSubtext:i})]})]})},WNe=({smsBody:e,imageUrls:a})=>t.jsx(LNe,{children:t.jsx(JMe,{body:e,imageUrls:a})}),qNe=({open:e,onOpenChange:a,automation:n})=>t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"Send Preview SMS"}),t.jsx(iY,{children:"Send a preview SMS to the automation."})]}),t.jsx(VNe,{automation:n,type:"sms",setOpenSendPreviewPopup:a,open:e})]})}),$Ne=({label:e,value:a,className:n})=>t.jsxs("div",{className:"flex items-center gap-1 min-w-0 max-w-full flex-shrink",children:[t.jsxs("span",{className:"sr-only",children:[e,":"]}),t.jsx("span",{className:XO("truncate",n),children:a})]}),ZNe=()=>{const e=B5(),n=R5(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre(),{data:o}=$re(),{updateCommunicationGroup:s}=Ye(),[l,u]=a.useState(!1),[c,d]=a.useState(!1),[m,h]=a.useState(!0),[p,g]=a.useState(n?.smsChannelSenderId||null),[f,v]=a.useState(n?.textMessageCompanyName||null),y=n?.smsMessageBody||null,b=wwe(f,500),k=a.useMemo((()=>Nle({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o})),[i?.results,r?.results,o]),S=k?.find((e=>e.channelSender.id===n?.smsChannelSenderId)),w=S?.channelSender.channelSenderMetadata.from&&null!==S.channelSender.channelSenderMetadata.from?S.channelSender.channelSenderMetadata.from:null,A=S?.channelSender.channelSenderMetadata.friendlyName??(w&&null!==w?GNe(w??""):S?.channelSender.channelSenderMetadata.messageServiceSid);if(a.useEffect((()=>{i?.results&&p&&h(!1)}),[i?.results,p]),a.useEffect((()=>{if(p&&n?.id&&!m){d(!0);(async()=>{try{await s({groupId:n.id,params:{smsChannelSenderId:p,...b?{textMessageCompanyName:b}:{textMessageCompanyName:null}}})}catch(e){}finally{d(!1)}})()}}),[p,b,n?.id,s,m]),!(e&&n&&i&&r&&k&&(void 0!==o||S)))return null;const C=y?y.length>50?y.substring(0,50)+"...":y:null;return t.jsx("div",{className:"w-full bg-background rounded-lg p-3",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 overflow-hidden flex-1",children:[A&&t.jsx($Ne,{label:"From",value:A,className:"font-bold"}),f&&t.jsx($Ne,{label:"Company",value:f,className:"font-normal"}),C&&t.jsx($Ne,{label:"Message",value:C,className:"text-muted-foreground/50 italic"})]}),t.jsxs(Nre,{open:l,onOpenChange:u,children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{size:"sm",variant:"outline",children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]})}),t.jsx(Pre,{className:"w-96",align:"end",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"From"}),t.jsxs(pwe,{onValueChange:e=>{g(e),h(!0)},value:p??void 0,disabled:c,children:[t.jsx(vwe,{className:"bg-background hover:bg-accent/50 focus:bg-accent/50 data-[state=open]:bg-accent/50 transition-colors",children:t.jsx(fwe,{placeholder:"Select sender",className:"text-muted-foreground",children:p?k?.find((e=>e.channelSender.id===p))?.channelSender.channelSenderMetadata.friendlyName||k?.find((e=>e.channelSender.id===p))?.channelSender.channelSenderMetadata.from:""})}),t.jsx(kwe,{children:k?.map((e=>t.jsx(Swe,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName||e.channelSender.channelSenderMetadata.from},e.channelSender.id)))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{className:"text-sm font-medium text-foreground",children:"Company"}),t.jsx(Fue,{title:"Company name will be included in the SMS message"})]}),t.jsx(gte,{placeholder:"Enter company name",className:"bg-background hover:bg-accent/50 focus:bg-accent transition-colors placeholder:text-muted-foreground/50",value:f??"",onChange:e=>{v(""===e.target.value?null:e.target.value)},disabled:c||m})]})]})})]})]})})},YNe=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1,setupRequired:r=!1})=>{const[o,s]=a.useState(!1),{channelSenders:l}=Jre(),{channelAccounts:u}=Fre(),c=B5(),d=R5(),[m,h]=a.useState(!1),{data:p}=$re(),[g,f]=a.useState(r),[v,y]=a.useState(null),[b,k]=a.useState(null),[S,w]=a.useState(null),[A,C]=a.useState(!1),M=a.useRef(null),{toast:T}=Ve(),{updateCommunicationGroup:x,isUpdating:E}=Ye(),{getMergeFields:N}=Qe(d?.id??void 0),_=Nle({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:p}),P=_.find((e=>e.channelSender.id===d?.smsChannelSenderId)),j=a.useMemo((()=>d?.textMessageMediaUrls??[]),[d?.textMessageMediaUrls]),L=d?.smsMessageBody||"",B=a.useCallback((()=>{v&&v.length>1500?T({title:"SMS is too long",description:"Please shorten your message"}):null!==v&&0!==v.length?d?.id&&x({groupId:d.id,params:{smsMessageBody:v,textMessageMedia:S?[S]:A?[]:void 0}},{onSuccess:()=>{h(!1),k(null),w(null),C(!1)},onError:()=>{T({title:"Error updating SMS",description:"Please contact your administrator"})}}):T({title:"Oops",description:"Please enter a message"})}),[v,d?.id,S,A,x,T]),R=a.useCallback((()=>{y(L),h(!1),k(j.length>0?j[0]:null),w(null),C(!1)}),[L,j]),D=a.useCallback((()=>{k(null),w(null),C(!0),M.current&&(M.current.value="")}),[]),z=a.useCallback((async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await HMe(e.result),t=IMe(a);w(t),k(a),C(!1)}catch(a){T({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}}),[T]),O=a.useCallback((()=>{M.current?.click()}),[]);if(a.useEffect((()=>{m&&L&&(y(L),j.length>0&&!b&&!A&&k(j[0]))}),[m,L,j,b,A]),a.useEffect((()=>{m||(k(j.length>0?j[0]:null),w(null),C(!1))}),[m,j]),a.useEffect((()=>{P&&P.smsApplication&&P.smsApplication.status===Ele.PENDING&&f(!1)}),[d?.smsChannelSenderId,p,_,P]),!c||void 0===l)return null;const K=!P?.smsApplication||P.smsApplication.status===Ele.APPROVED,H=L.length>0,I=OMe({companyName:d?.textMessageCompanyName??void 0,smsBody:L});let F=null;d?.smsChannelSenderId||(F="Please first select a sms sender"),d?.smsMessageBody||(F="Please first ensure you have a sms content");const G=c.status===ha.DRAFT&&!n,V=!e&&K,J=!g&&(!d?.smsChannelSenderId||P?.smsApplication&&P.smsApplication.status!==Ele.APPROVED&&P.smsApplication.status!==Ele.PENDING),U=()=>{const e=t.jsxs(H5,{size:"sm",variant:"outline",disabled:!G,className:XO(!G&&"cursor-not-allowed"),onClick:()=>{h(!0)},children:[t.jsx(V5.EditIcon,{className:"w-3 h-3"}),"Edit"]});return G?e:t.jsx(Fue,{alertText:"You can only edit the content if we are in the draft state.",asChild:!0,className:"cursor-not-allowed",children:t.jsx("div",{className:"inline-block cursor-not-allowed",children:e})})},W=()=>{const e=t.jsx(HNe,{onClick:()=>s(!0)});return F?t.jsx(Fue,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:e}):e};return t.jsx(wY,{children:g?t.jsx("div",{className:"w-full pt-8 mx-auto",children:t.jsx(zMe,{})}):t.jsxs(o5.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3,ease:[.16,1,.3,1]},className:"flex-1 flex flex-col items-center",children:[t.jsx(qNe,{open:o,onOpenChange:s,automation:c}),t.jsx(ZZ,{open:m,onOpenChange:h,children:t.jsxs(eY,{hideCloseButton:!0,className:"max-w-[50vw]",children:[t.jsxs(qZ,{children:[t.jsx(nY,{children:"SMS Editor"}),t.jsx(iY,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),t.jsxs("div",{className:"",children:[b&&t.jsx("div",{className:"flex justify-center mb-6",children:t.jsx("div",{className:"relative group w-fit",children:t.jsx("img",{src:b,alt:"SMS attachment preview",className:"max-h-48 max-w-xs rounded-xl shadow-lg border border-gray-200 object-contain bg-white transition-transform duration-200",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}})})}),N&&t.jsx(bEe,{value:v,onChange:y,maxLength:1500-(d?.textMessageCompanyName?.length||0),mergeFieldsResponse:N}),t.jsx("div",{className:"mt-4 flex items-center justify-end",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"file",ref:M,onChange:z,accept:"image/*",className:"hidden"}),t.jsx(H5,b?{variant:"outline",onClick:D,className:"px-4",disabled:A||E,children:"Remove Image"}:{variant:"outline",onClick:O,className:"px-4",disabled:j.length>=1||A||null!==S||E,children:"Add Image"}),t.jsx(H5,{variant:"outline",onClick:R,className:"px-4",children:"Cancel"}),t.jsx(H5,{onClick:B,className:"px-4",disabled:E,children:"Save Changes"})]})})]})]})}),J&&t.jsx("div",{className:"px-4 pt-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"SMS Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The SMS channel is currently disabled. To send SMS messages, please enable the channel by selecting a valid SMS sender and ensuring your SMS application is approved."})]})]})})})}),H?t.jsx("div",{className:"relative flex-1 w-full flex flex-col overflow-hidden",children:t.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col",children:t.jsxs("div",{className:"flex flex-col space-y-4 px-4 pt-4 pb-20",children:[t.jsx("div",{className:"w-full flex-shrink-0 max-w-2xl mx-auto rounded-md",children:t.jsx(ZNe,{})}),t.jsxs("div",{className:"rounded-lg bg-background flex-1 min-h-0 flex flex-col items-center max-w-2xl mx-auto w-full",children:[t.jsxs("div",{className:"flex items-center space-x-2 w-full justify-end p-3",children:[t.jsx(_Ne,{type:_we.SMS}),t.jsx(U,{}),V&&t.jsx(W,{}),H&&t.jsx(DNe,{expandDialogContent:t.jsx(WNe,{smsBody:I,imageUrls:j})})]}),t.jsx(JMe,{body:I,imageUrls:j})]}),t.jsx("p",{className:"text-center text-sm text-muted-foreground flex-shrink-0 pt-4",children:"These previews show exactly how your messages will appear to your customers"})]})})}):t.jsxs(t.Fragment,{children:[J&&t.jsx("div",{className:"px-4 pt-4 w-full",children:t.jsx("div",{className:"max-w-2xl mx-auto",children:t.jsx("div",{className:XO(jNe({variant:"warning",size:"default",position:"inline"}),PNe,"p-4 relative"),role:"alert",children:t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"mr-3 shrink-0 pt-0.5",children:t.jsx(Xz,{className:"h-5 w-5"})}),t.jsxs("div",{className:"flex-grow",children:[t.jsx("h5",{className:"text-sm font-medium mb-1",children:"SMS Channel Disabled"}),t.jsx("div",{className:"text-sm",children:"The SMS channel is currently disabled. To send SMS messages, please enable the channel by selecting a valid SMS sender and ensuring your SMS application is approved."})]})]})})})}),t.jsx(KNe,{type:"sms",disablePreviewSubtext:i})]})]})})},QNe=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1})=>{const[r,o]=a.useState(null),s=R5(),{channelAccounts:l}=Fre(),{state:{hideSms:u}}=a.useContext(rY),{channelSenders:c}=Jre(),{data:d}=$re(),m=a.useMemo((()=>Nle({channelSenders:c?.results??[],channelAccounts:l?.results??[],smsApplication:d})),[c?.results,l?.results,d]);if(a.useEffect((()=>{r||o(s?.emailChannelSenderId?"email":"sms")}),[s?.emailChannelSenderId,r]),!s||!c||!r)return t.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:t.jsx(lY,{text:["Loading..."]})});const h=!s?.smsChannelSenderId||u,p=!s?.emailChannelSenderId,g=0===m.length&&!d;return t.jsxs(TNe,{defaultValue:"email",value:r,onValueChange:e=>o("email"===e?"email":"sms"),className:"flex flex-col gap-4 flex-1 bg-muted rounded-md",children:[t.jsx("div",{className:"max-w-[640px] mx-auto w-full",children:t.jsxs(xNe,{className:"grid w-full "+(h||p?"grid-cols-1":"grid-cols-2"),children:[!p&&t.jsx(ENe,{value:"email",className:"group data-[state=active]:bg-white",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(V5.EmailIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),t.jsx(V5.EmailIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),t.jsx("span",{children:"Email"})]})}),!h&&t.jsx(ENe,{value:"sms",className:"group data-[state=active]:bg-white",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(V5.SmsIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),t.jsx(V5.SmsIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),t.jsx("span",{children:"SMS"}),g&&t.jsx(Fue,{title:"To enable SMS, please complete your business information and request approval from Twilio"})]})})]})}),t.jsx(NNe,{value:"email",children:t.jsx(UNe,{disablePreview:e,disableEditContent:n,disablePreviewSubtext:i})}),t.jsx(NNe,{value:"sms",children:t.jsx(YNe,{disablePreview:e,disableEditContent:n,disablePreviewSubtext:i,setupRequired:g})})]})},XNe="reach-styles-module__h2___J-48W",e_e="reach-styles-module__h3___QiFj-",a_e="reach-styles-module__minorText___1TEN6",t_e=({children:e,className:a})=>t.jsx("h2",{className:XO(XNe,a),children:e}),n_e=({children:e,className:a})=>t.jsx("h3",{className:XO(e_e,a),children:e}),i_e=({children:e,className:a})=>t.jsx("p",{className:XO(a_e,a),children:e}),r_e=({title:e,children:a,headerActions:n})=>t.jsxs("div",{className:"max-w-[1000px] mx-auto w-full flex-1 flex flex-col gap-4 pt-4",children:[t.jsxs("div",{className:"px-4 flex",children:[t.jsx(t_e,{className:"text-primary",children:e}),n&&t.jsx("div",{className:"ml-auto",children:n})]}),a]}),o_e=()=>t.jsx(r_e,{title:"Preview & Schedule",children:t.jsx(QNe,{disablePreview:!0,disableEditContent:!0,disablePreviewSubtext:!0})}),s_e=()=>{const e=B5(),n=R5(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre(),{data:o}=$re(),[s,l]=a.useState(null),[u,c]=a.useState(null),[d,m]=a.useState(null),[h,p]=a.useState(null);return a.useEffect((()=>{i&&m(i),r&&p(r)}),[i,r]),a.useEffect((()=>{if(n&&d&&h){const e=n.emailChannelSenderId,a=n.smsChannelSenderId,t=d.results.find((a=>a.id===e)),i=d.results.find((e=>e.id===a));if(t&&n.emailSubject&&n.emailHtmlBody){const e=t.channelSenderMetadata?.userPart,a=h.results.find((e=>e.id===t.channelAccountId));if(a)switch(a.channelAccountMetadata.type){case Gre.REACH_MANAGED:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:t.channelSenderMetadata?.emailFromName,subject:n.emailSubject,previewText:n.emailPreviewText,body:n.emailHtmlBody});break;case Gre.REACH_MANAGED_SES:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:t.channelSenderMetadata?.emailFromName,subject:n.emailSubject,previewText:n.emailPreviewText,body:n.emailHtmlBody});break;case Gre.TWILLIO:break;default:throw jre(a.channelAccountMetadata.type,Gre)}}(o||i)&&n.smsMessageBody&&c({fromPhone:i?wEe(i.channelSenderMetadata):"",body:n.smsMessageBody,companyName:n.textMessageCompanyName})}}),[n,d,h,o]),e?t.jsx("div",s||u?{className:"w-full",children:t.jsx("div",{className:"flex flex-col gap-4 w-full",children:t.jsx(o_e,{})})}:{className:"flex justify-center items-center h-full",children:t.jsx("div",{children:"No preview data Please complete previous steps"})}):t.jsx(lY,{text:["Loading..."]})};function l_e(e){return(l_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u_e(e){if(null===e||!0===e||!1===e)return NaN;var a=Number(e);return isNaN(a)?a:a<0?Math.ceil(a):Math.floor(a)}function c_e(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function d_e(e){c_e(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||"object"===l_e(e)&&"[object Date]"===a?new Date(e.getTime()):"number"==typeof e||"[object Number]"===a?new Date(e):new Date(NaN)}function m_e(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a);return isNaN(n)?new Date(NaN):n?(t.setDate(t.getDate()+n),t):t}function h_e(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a);if(isNaN(n))return new Date(NaN);if(!n)return t;var i=t.getDate(),r=new Date(t.getTime());return r.setMonth(t.getMonth()+n+1,0),i>=r.getDate()?r:(t.setFullYear(r.getFullYear(),r.getMonth(),i),t)}var p_e={};function g_e(){return p_e}function f_e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==t?t:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=d_e(e),h=m.getDay(),p=(h<d?7:0)+h-d;return m.setDate(m.getDate()-p),m.setHours(0,0,0,0),m}function v_e(e){return c_e(1,arguments),f_e(e,{weekStartsOn:1})}function y_e(e){c_e(1,arguments);var a=function(e){c_e(1,arguments);var a=d_e(e),t=a.getFullYear(),n=new Date(0);n.setFullYear(t+1,0,4),n.setHours(0,0,0,0);var i=v_e(n),r=new Date(0);r.setFullYear(t,0,4),r.setHours(0,0,0,0);var o=v_e(r);return a.getTime()>=i.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}(e),t=new Date(0);return t.setFullYear(a,0,4),t.setHours(0,0,0,0),v_e(t)}function b_e(e){var a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),e.getTime()-a.getTime()}function k_e(e){c_e(1,arguments);var a=d_e(e);return a.setHours(0,0,0,0),a}function S_e(e,a){c_e(2,arguments);var t=k_e(e),n=k_e(a),i=t.getTime()-b_e(t),r=n.getTime()-b_e(n);return Math.round((i-r)/864e5)}function w_e(e,a){return c_e(2,arguments),m_e(e,7*u_e(a))}function A_e(e,a){return c_e(2,arguments),h_e(e,12*u_e(a))}function C_e(e,a){c_e(2,arguments);var t=k_e(e),n=k_e(a);return t.getTime()===n.getTime()}function M_e(e){return c_e(1,arguments),e instanceof Date||"object"===l_e(e)&&"[object Date]"===Object.prototype.toString.call(e)}function T_e(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return 12*(t.getFullYear()-n.getFullYear())+(t.getMonth()-n.getMonth())}function x_e(e){c_e(1,arguments);var a=d_e(e),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(23,59,59,999),a}function E_e(e){c_e(1,arguments);var a=d_e(e);return a.setDate(1),a.setHours(0,0,0,0),a}function N_e(e){c_e(1,arguments);var a=d_e(e),t=new Date(0);return t.setFullYear(a.getFullYear(),0,1),t.setHours(0,0,0,0),t}function __e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==t?t:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=d_e(e),h=m.getDay(),p=6+(h<d?-7:0)-(h-d);return m.setDate(m.getDate()+p),m.setHours(23,59,59,999),m}function P_e(e){return c_e(1,arguments),__e(e,{weekStartsOn:1})}function j_e(e,a){return c_e(2,arguments),function(e,a){c_e(2,arguments);var t=d_e(e).getTime(),n=u_e(a);return new Date(t+n)}(e,-u_e(a))}function L_e(e){c_e(1,arguments);var a=d_e(e),t=a.getUTCDay(),n=(t<1?7:0)+t-1;return a.setUTCDate(a.getUTCDate()-n),a.setUTCHours(0,0,0,0),a}function B_e(e){c_e(1,arguments);var a=d_e(e),t=a.getUTCFullYear(),n=new Date(0);n.setUTCFullYear(t+1,0,4),n.setUTCHours(0,0,0,0);var i=L_e(n),r=new Date(0);r.setUTCFullYear(t,0,4),r.setUTCHours(0,0,0,0);var o=L_e(r);return a.getTime()>=i.getTime()?t+1:a.getTime()>=o.getTime()?t:t-1}function R_e(e){c_e(1,arguments);var a=d_e(e),t=L_e(a).getTime()-function(e){c_e(1,arguments);var a=B_e(e),t=new Date(0);return t.setUTCFullYear(a,0,4),t.setUTCHours(0,0,0,0),L_e(t)}(a).getTime();return Math.round(t/6048e5)+1}function D_e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.weekStartsOn)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==i?i:c.weekStartsOn)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==t?t:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=d_e(e),h=m.getUTCDay(),p=(h<d?7:0)+h-d;return m.setUTCDate(m.getUTCDate()-p),m.setUTCHours(0,0,0,0),m}function z_e(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=d_e(e),d=c.getUTCFullYear(),m=g_e(),h=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==n?n:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setUTCFullYear(d+1,0,h),p.setUTCHours(0,0,0,0);var g=D_e(p,a),f=new Date(0);f.setUTCFullYear(d,0,h),f.setUTCHours(0,0,0,0);var v=D_e(f,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=v.getTime()?d:d-1}function O_e(e,a){c_e(1,arguments);var t=d_e(e),n=D_e(t,a).getTime()-function(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1),m=z_e(e,a),h=new Date(0);return h.setUTCFullYear(m,0,d),h.setUTCHours(0,0,0,0),D_e(h,a)}(t,a).getTime();return Math.round(n/6048e5)+1}function K_e(e,a){for(var t=e<0?"-":"",n=Math.abs(e).toString();n.length<a;)n="0"+n;return t+n}var H_e=function(e,a){var t=e.getUTCFullYear(),n=t>0?t:1-t;return K_e("yy"===a?n%100:n,a.length)},I_e=function(e,a){var t=e.getUTCMonth();return"M"===a?String(t+1):K_e(t+1,2)},F_e=function(e,a){return K_e(e.getUTCDate(),a.length)},G_e=function(e,a){return K_e(e.getUTCHours()%12||12,a.length)},V_e=function(e,a){return K_e(e.getUTCHours(),a.length)},J_e=function(e,a){return K_e(e.getUTCMinutes(),a.length)},U_e=function(e,a){return K_e(e.getUTCSeconds(),a.length)},W_e=function(e,a){var t=a.length,n=e.getUTCMilliseconds();return K_e(Math.floor(n*Math.pow(10,t-3)),a.length)},q_e="midnight",$_e="noon",Z_e="morning",Y_e="afternoon",Q_e="evening",X_e="night",ePe={G:function(e,a,t){var n=e.getUTCFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(n,{width:"abbreviated"});case"GGGGG":return t.era(n,{width:"narrow"});default:return t.era(n,{width:"wide"})}},y:function(e,a,t){if("yo"===a){var n=e.getUTCFullYear();return t.ordinalNumber(n>0?n:1-n,{unit:"year"})}return H_e(e,a)},Y:function(e,a,t,n){var i=z_e(e,n),r=i>0?i:1-i;return"YY"===a?K_e(r%100,2):"Yo"===a?t.ordinalNumber(r,{unit:"year"}):K_e(r,a.length)},R:function(e,a){return K_e(B_e(e),a.length)},u:function(e,a){return K_e(e.getUTCFullYear(),a.length)},Q:function(e,a,t){var n=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"Q":return String(n);case"QQ":return K_e(n,2);case"Qo":return t.ordinalNumber(n,{unit:"quarter"});case"QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,a,t){var n=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"q":return String(n);case"qq":return K_e(n,2);case"qo":return t.ordinalNumber(n,{unit:"quarter"});case"qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,a,t){var n=e.getUTCMonth();switch(a){case"M":case"MM":return I_e(e,a);case"Mo":return t.ordinalNumber(n+1,{unit:"month"});case"MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(n,{width:"narrow",context:"formatting"});default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(e,a,t){var n=e.getUTCMonth();switch(a){case"L":return String(n+1);case"LL":return K_e(n+1,2);case"Lo":return t.ordinalNumber(n+1,{unit:"month"});case"LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(n,{width:"narrow",context:"standalone"});default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(e,a,t,n){var i=O_e(e,n);return"wo"===a?t.ordinalNumber(i,{unit:"week"}):K_e(i,a.length)},I:function(e,a,t){var n=R_e(e);return"Io"===a?t.ordinalNumber(n,{unit:"week"}):K_e(n,a.length)},d:function(e,a,t){return"do"===a?t.ordinalNumber(e.getUTCDate(),{unit:"date"}):F_e(e,a)},D:function(e,a,t){var n=function(e){c_e(1,arguments);var a=d_e(e),t=a.getTime();a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0);var n=a.getTime();return Math.floor((t-n)/864e5)+1}(e);return"Do"===a?t.ordinalNumber(n,{unit:"dayOfYear"}):K_e(n,a.length)},E:function(e,a,t){var n=e.getUTCDay();switch(a){case"E":case"EE":case"EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(e,a,t,n){var i=e.getUTCDay(),r=(i-n.weekStartsOn+8)%7||7;switch(a){case"e":return String(r);case"ee":return K_e(r,2);case"eo":return t.ordinalNumber(r,{unit:"day"});case"eee":return t.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(i,{width:"short",context:"formatting"});default:return t.day(i,{width:"wide",context:"formatting"})}},c:function(e,a,t,n){var i=e.getUTCDay(),r=(i-n.weekStartsOn+8)%7||7;switch(a){case"c":return String(r);case"cc":return K_e(r,a.length);case"co":return t.ordinalNumber(r,{unit:"day"});case"ccc":return t.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(i,{width:"narrow",context:"standalone"});case"cccccc":return t.day(i,{width:"short",context:"standalone"});default:return t.day(i,{width:"wide",context:"standalone"})}},i:function(e,a,t){var n=e.getUTCDay(),i=0===n?7:n;switch(a){case"i":return String(i);case"ii":return K_e(i,a.length);case"io":return t.ordinalNumber(i,{unit:"day"});case"iii":return t.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(e,a,t){var n=e.getUTCHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(n,{width:"narrow",context:"formatting"});default:return t.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(e,a,t){var n,i=e.getUTCHours();switch(n=12===i?$_e:0===i?q_e:i/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(n,{width:"narrow",context:"formatting"});default:return t.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(e,a,t){var n,i=e.getUTCHours();switch(n=i>=17?Q_e:i>=12?Y_e:i>=4?Z_e:X_e,a){case"B":case"BB":case"BBB":return t.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(n,{width:"narrow",context:"formatting"});default:return t.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(e,a,t){if("ho"===a){var n=e.getUTCHours()%12;return 0===n&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return G_e(e,a)},H:function(e,a,t){return"Ho"===a?t.ordinalNumber(e.getUTCHours(),{unit:"hour"}):V_e(e,a)},K:function(e,a,t){var n=e.getUTCHours()%12;return"Ko"===a?t.ordinalNumber(n,{unit:"hour"}):K_e(n,a.length)},k:function(e,a,t){var n=e.getUTCHours();return 0===n&&(n=24),"ko"===a?t.ordinalNumber(n,{unit:"hour"}):K_e(n,a.length)},m:function(e,a,t){return"mo"===a?t.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):J_e(e,a)},s:function(e,a,t){return"so"===a?t.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):U_e(e,a)},S:function(e,a){return W_e(e,a)},X:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(a){case"X":return tPe(i);case"XXXX":case"XX":return nPe(i);default:return nPe(i,":")}},x:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();switch(a){case"x":return tPe(i);case"xxxx":case"xx":return nPe(i);default:return nPe(i,":")}},O:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+aPe(i,":");default:return"GMT"+nPe(i,":")}},z:function(e,a,t,n){var i=(n._originalDate||e).getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+aPe(i,":");default:return"GMT"+nPe(i,":")}},t:function(e,a,t,n){return K_e(Math.floor((n._originalDate||e).getTime()/1e3),a.length)},T:function(e,a,t,n){return K_e((n._originalDate||e).getTime(),a.length)}};function aPe(e,a){var t=e>0?"-":"+",n=Math.abs(e),i=Math.floor(n/60),r=n%60;if(0===r)return t+String(i);var o=a;return t+String(i)+o+K_e(r,2)}function tPe(e,a){return e%60==0?(e>0?"-":"+")+K_e(Math.abs(e)/60,2):nPe(e,a)}function nPe(e,a){var t=a||"",n=e>0?"-":"+",i=Math.abs(e);return n+K_e(Math.floor(i/60),2)+t+K_e(i%60,2)}var iPe=function(e,a){switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});default:return a.date({width:"full"})}},rPe=function(e,a){switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});default:return a.time({width:"full"})}},oPe={p:rPe,P:function(e,a){var t,n=e.match(/(P+)(p+)?/)||[],i=n[1],r=n[2];if(!r)return iPe(e,a);switch(i){case"P":t=a.dateTime({width:"short"});break;case"PP":t=a.dateTime({width:"medium"});break;case"PPP":t=a.dateTime({width:"long"});break;default:t=a.dateTime({width:"full"})}return t.replace("{{date}}",iPe(i,a)).replace("{{time}}",rPe(r,a))}},sPe=["D","DD"],lPe=["YY","YYYY"];function uPe(e,a,t){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(a,"`) for formatting years to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("YY"===e)throw new RangeError("Use `yy` instead of `YY` (in `".concat(a,"`) for formatting years to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("D"===e)throw new RangeError("Use `d` instead of `D` (in `".concat(a,"`) for formatting days of the month to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("DD"===e)throw new RangeError("Use `dd` instead of `DD` (in `".concat(a,"`) for formatting days of the month to the input `").concat(t,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var cPe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function dPe(e){return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}var mPe={date:dPe({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:dPe({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:dPe({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},hPe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function pPe(e){return function(a,t){var n;if("formatting"===(null!=t&&t.context?String(t.context):"standalone")&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,r=null!=t&&t.width?String(t.width):i;n=e.formattingValues[r]||e.formattingValues[i]}else{var o=e.defaultWidth,s=null!=t&&t.width?String(t.width):e.defaultWidth;n=e.values[s]||e.values[o]}return n[e.argumentCallback?e.argumentCallback(a):a]}}var gPe={ordinalNumber:function(e,a){var t=Number(e),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:pPe({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:pPe({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:pPe({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:pPe({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:pPe({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})};function fPe(e){return function(a){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.width,i=a.match(n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth]);if(!i)return null;var r,o=i[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,a){for(var t=0;t<e.length;t++)if(a(e[t]))return t;return}(s,(function(e){return e.test(o)})):function(e,a){for(var t in e)if(e.hasOwnProperty(t)&&a(e[t]))return t;return}(s,(function(e){return e.test(o)}));return r=e.valueCallback?e.valueCallback(l):l,{value:r=t.valueCallback?t.valueCallback(r):r,rest:a.slice(o.length)}}}var vPe={ordinalNumber:function(e){return function(a){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=a.match(e.matchPattern);if(!n)return null;var i=n[0],r=a.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];return{value:o=t.valueCallback?t.valueCallback(o):o,rest:a.slice(i.length)}}}({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}}),era:fPe({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:fPe({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:fPe({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:fPe({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:fPe({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},yPe={code:"en-US",formatDistance:function(e,a,t){var n,i=cPe[e];return n="string"==typeof i?i:1===a?i.one:i.other.replace("{{count}}",a.toString()),null!=t&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n},formatLong:mPe,formatRelative:function(e,a,t,n){return hPe[e]},localize:gPe,match:vPe,options:{weekStartsOn:0,firstWeekContainsDate:1}},bPe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,kPe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,SPe=/^'([^]*?)'?$/,wPe=/''/g,APe=/[a-zA-Z]/;function CPe(e,a,t){var n,i,r,o,s,l,u,c,d,m,h,p,g,f,v,y,b,k;c_e(2,arguments);var S=String(a),w=g_e(),A=null!==(n=null!==(i=null==t?void 0:t.locale)&&void 0!==i?i:w.locale)&&void 0!==n?n:yPe,C=u_e(null!==(r=null!==(o=null!==(s=null!==(l=null==t?void 0:t.firstWeekContainsDate)&&void 0!==l?l:null==t||null===(u=t.locale)||void 0===u||null===(c=u.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==s?s:w.firstWeekContainsDate)&&void 0!==o?o:null===(d=w.locale)||void 0===d||null===(m=d.options)||void 0===m?void 0:m.firstWeekContainsDate)&&void 0!==r?r:1);if(!(C>=1&&C<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var M=u_e(null!==(h=null!==(p=null!==(g=null!==(f=null==t?void 0:t.weekStartsOn)&&void 0!==f?f:null==t||null===(v=t.locale)||void 0===v||null===(y=v.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==g?g:w.weekStartsOn)&&void 0!==p?p:null===(b=w.locale)||void 0===b||null===(k=b.options)||void 0===k?void 0:k.weekStartsOn)&&void 0!==h?h:0);if(!(M>=0&&M<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!A.localize)throw new RangeError("locale must contain localize property");if(!A.formatLong)throw new RangeError("locale must contain formatLong property");var T=d_e(e);if(!function(e){if(c_e(1,arguments),!M_e(e)&&"number"!=typeof e)return!1;var a=d_e(e);return!isNaN(Number(a))}(T))throw new RangeError("Invalid time value");var x=j_e(T,b_e(T)),E={firstWeekContainsDate:C,weekStartsOn:M,locale:A,_originalDate:T};return S.match(kPe).map((function(e){var a=e[0];return"p"===a||"P"===a?(0,oPe[a])(e,A.formatLong):e})).join("").match(bPe).map((function(n){if("''"===n)return"'";var i=n[0];if("'"===i)return function(e){var a=e.match(SPe);if(!a)return e;return a[1].replace(wPe,"'")}(n);var r=ePe[i];if(r)return null!=t&&t.useAdditionalWeekYearTokens||-1===lPe.indexOf(n)||uPe(n,a,String(e)),null!=t&&t.useAdditionalDayOfYearTokens||!function(e){return-1!==sPe.indexOf(e)}(n)||uPe(n,a,String(e)),r(x,n,A.localize,E);if(i.match(APe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return n})).join("")}function MPe(e){return c_e(1,arguments),Math.floor(function(e){return c_e(1,arguments),d_e(e).getTime()}(e)/1e3)}function TPe(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=g_e(),d=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:c.firstWeekContainsDate)&&void 0!==n?n:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1),m=function(e,a){var t,n,i,r,o,s,l,u;c_e(1,arguments);var c=d_e(e),d=c.getFullYear(),m=g_e(),h=u_e(null!==(t=null!==(n=null!==(i=null!==(r=null==a?void 0:a.firstWeekContainsDate)&&void 0!==r?r:null==a||null===(o=a.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==i?i:m.firstWeekContainsDate)&&void 0!==n?n:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==t?t:1);if(!(h>=1&&h<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(d+1,0,h),p.setHours(0,0,0,0);var g=f_e(p,a),f=new Date(0);f.setFullYear(d,0,h),f.setHours(0,0,0,0);var v=f_e(f,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=v.getTime()?d:d-1}(e,a),h=new Date(0);return h.setFullYear(m,0,d),h.setHours(0,0,0,0),f_e(h,a)}function xPe(e,a){return c_e(1,arguments),function(e,a,t){c_e(2,arguments);var n=f_e(e,t),i=f_e(a,t),r=n.getTime()-b_e(n),o=i.getTime()-b_e(i);return Math.round((r-o)/6048e5)}(function(e){c_e(1,arguments);var a=d_e(e),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(0,0,0,0),a}(e),E_e(e),a)+1}function EPe(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getTime()>n.getTime()}function NPe(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getTime()<n.getTime()}function _Pe(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()}function PPe(e,a){return c_e(2,arguments),m_e(e,-u_e(a))}function jPe(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a),i=t.getFullYear(),r=t.getDate(),o=new Date(0);o.setFullYear(i,n,15),o.setHours(0,0,0,0);var s=function(e){c_e(1,arguments);var a=d_e(e),t=a.getFullYear(),n=a.getMonth(),i=new Date(0);return i.setFullYear(t,n+1,0),i.setHours(0,0,0,0),i.getDate()}(o);return t.setMonth(n,Math.min(r,s)),t}function LPe(e,a){c_e(2,arguments);var t=d_e(e),n=u_e(a);return isNaN(t.getTime())?new Date(NaN):(t.setFullYear(n),t)}var BPe=function(){return BPe=Object.assign||function(e){for(var a,t=1,n=arguments.length;t<n;t++)for(var i in a=arguments[t])Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i]);return e},BPe.apply(this,arguments)};function RPe(e,a,t){for(var n,i=0,r=a.length;i<r;i++)!n&&i in a||(n||(n=Array.prototype.slice.call(a,0,i)),n[i]=a[i]);return e.concat(n||Array.prototype.slice.call(a))}function DPe(e){return"multiple"===e.mode}function zPe(e){return"range"===e.mode}function OPe(e){return"single"===e.mode}"function"==typeof SuppressedError&&SuppressedError;var KPe={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};var HPe=Object.freeze({__proto__:null,formatCaption:function(e,a){return CPe(e,"LLLL y",a)},formatDay:function(e,a){return CPe(e,"d",a)},formatMonthCaption:function(e,a){return CPe(e,"LLLL",a)},formatWeekNumber:function(e){return"".concat(e)},formatWeekdayName:function(e,a){return CPe(e,"cccccc",a)},formatYearCaption:function(e,a){return CPe(e,"yyyy",a)}}),IPe=Object.freeze({__proto__:null,labelDay:function(e,a,t){return CPe(e,"do MMMM (EEEE)",t)},labelMonthDropdown:function(){return"Month: "},labelNext:function(){return"Go to next month"},labelPrevious:function(){return"Go to previous month"},labelWeekNumber:function(e){return"Week n. ".concat(e)},labelWeekday:function(e,a){return CPe(e,"cccc",a)},labelYearDropdown:function(){return"Year: "}});var FPe=a.createContext(void 0);function GPe(e){var a,n,i=e.initialProps,r={captionLayout:"buttons",classNames:KPe,formatters:HPe,labels:IPe,locale:yPe,modifiersClassNames:{},modifiers:{},numberOfMonths:1,styles:{},today:new Date,mode:"default"},o=function(e){var a=e.fromYear,t=e.toYear,n=e.fromMonth,i=e.toMonth,r=e.fromDate,o=e.toDate;return n?r=E_e(n):a&&(r=new Date(a,0,1)),i?o=x_e(i):t&&(o=new Date(t,11,31)),{fromDate:r?k_e(r):void 0,toDate:o?k_e(o):void 0}}(i),s=o.fromDate,l=o.toDate,u=null!==(a=i.captionLayout)&&void 0!==a?a:r.captionLayout;"buttons"===u||s&&l||(u="buttons"),(OPe(i)||DPe(i)||zPe(i))&&(n=i.onSelect);var c=BPe(BPe(BPe({},r),i),{captionLayout:u,classNames:BPe(BPe({},r.classNames),i.classNames),components:BPe({},i.components),formatters:BPe(BPe({},r.formatters),i.formatters),fromDate:s,labels:BPe(BPe({},r.labels),i.labels),mode:i.mode||r.mode,modifiers:BPe(BPe({},r.modifiers),i.modifiers),modifiersClassNames:BPe(BPe({},r.modifiersClassNames),i.modifiersClassNames),onSelect:n,styles:BPe(BPe({},r.styles),i.styles),toDate:l});return t.jsx(FPe.Provider,{value:c,children:e.children})}function VPe(){var e=a.useContext(FPe);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function JPe(e){var a=VPe();return t.jsx("div",{className:a.classNames.caption_label,style:a.styles.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:(0,a.formatters.formatCaption)(e.displayMonth,{locale:a.locale})})}function UPe(e){return t.jsx("svg",BPe({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:t.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function WPe(e){var a,n,i=e.onChange,r=e.value,o=e.children,s=e.caption,l=e.className,u=e.style,c=VPe(),d=null!==(n=null===(a=c.components)||void 0===a?void 0:a.IconDropdown)&&void 0!==n?n:UPe;return t.jsxs("div",{className:l,style:u,children:[t.jsx("span",{className:c.classNames.vhidden,children:e["aria-label"]}),t.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:r,onChange:i,children:o}),t.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[s,t.jsx(d,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function qPe(e){var a,n=VPe(),i=n.fromDate,r=n.toDate,o=n.styles,s=n.locale,l=n.formatters.formatMonthCaption,u=n.classNames,c=n.components,d=n.labels.labelMonthDropdown;if(!i)return t.jsx(t.Fragment,{});if(!r)return t.jsx(t.Fragment,{});var m=[];if(function(e,a){c_e(2,arguments);var t=d_e(e),n=d_e(a);return t.getFullYear()===n.getFullYear()}(i,r))for(var h=E_e(i),p=i.getMonth();p<=r.getMonth();p++)m.push(jPe(h,p));else for(h=E_e(new Date),p=0;p<=11;p++)m.push(jPe(h,p));var g=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:WPe;return t.jsx(g,{name:"months","aria-label":d(),className:u.dropdown_month,style:o.dropdown_month,onChange:function(a){var t=Number(a.target.value),n=jPe(E_e(e.displayMonth),t);e.onChange(n)},value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:s}),children:m.map((function(e){return t.jsx("option",{value:e.getMonth(),children:l(e,{locale:s})},e.getMonth())}))})}function $Pe(e){var a,n=e.displayMonth,i=VPe(),r=i.fromDate,o=i.toDate,s=i.locale,l=i.styles,u=i.classNames,c=i.components,d=i.formatters.formatYearCaption,m=i.labels.labelYearDropdown,h=[];if(!r)return t.jsx(t.Fragment,{});if(!o)return t.jsx(t.Fragment,{});for(var p=r.getFullYear(),g=o.getFullYear(),f=p;f<=g;f++)h.push(LPe(N_e(new Date),f));var v=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:WPe;return t.jsx(v,{name:"years","aria-label":m(),className:u.dropdown_year,style:l.dropdown_year,onChange:function(a){var t=LPe(E_e(n),Number(a.target.value));e.onChange(t)},value:n.getFullYear(),caption:d(n,{locale:s}),children:h.map((function(e){return t.jsx("option",{value:e.getFullYear(),children:d(e,{locale:s})},e.getFullYear())}))})}function ZPe(){var e=VPe(),t=function(e){var a=e.month||e.defaultMonth||e.today||new Date,t=e.toDate,n=e.fromDate,i=e.numberOfMonths,r=void 0===i?1:i;return t&&T_e(t,a)<0&&(a=h_e(t,-1*(r-1))),n&&T_e(a,n)<0&&(a=n),E_e(a)}(e),n=function(e,t){var n=a.useState(e);return[void 0===t?n[0]:t,n[1]]}(t,e.month),i=n[1];return[n[0],function(a){var t;if(!e.disableNavigation){var n=E_e(a);i(n),null===(t=e.onMonthChange)||void 0===t||t.call(e,n)}}]}var YPe=a.createContext(void 0);function QPe(e){var a=VPe(),n=ZPe(),i=n[0],r=n[1],o=function(e,a){for(var t=a.reverseMonths,n=a.numberOfMonths,i=E_e(e),r=T_e(E_e(h_e(i,n)),i),o=[],s=0;s<r;s++){var l=h_e(i,s);o.push(l)}return t&&(o=o.reverse()),o}(i,a),s=function(e,a){if(!a.disableNavigation){var t=a.toDate,n=a.numberOfMonths,i=void 0===n?1:n,r=a.pagedNavigation?i:1,o=E_e(e);if(!t)return h_e(o,r);if(!(T_e(t,e)<i))return h_e(o,r)}}(i,a),l=function(e,a){if(!a.disableNavigation){var t=a.fromDate,n=a.numberOfMonths,i=a.pagedNavigation?void 0===n?1:n:1,r=E_e(e);if(!t)return h_e(r,-i);if(!(T_e(r,t)<=0))return h_e(r,-i)}}(i,a),u=function(e){return o.some((function(a){return _Pe(e,a)}))};return t.jsx(YPe.Provider,{value:{currentMonth:i,displayMonths:o,goToMonth:r,goToDate:function(e,t){u(e)||(t&&NPe(e,t)?r(h_e(e,1+-1*a.numberOfMonths)):r(e))},previousMonth:l,nextMonth:s,isDateDisplayed:u},children:e.children})}function XPe(){var e=a.useContext(YPe);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function eje(e){var a,n=VPe(),i=n.classNames,r=n.styles,o=n.components,s=XPe().goToMonth,l=function(a){s(h_e(a,e.displayIndex?-e.displayIndex:0))},u=null!==(a=null==o?void 0:o.CaptionLabel)&&void 0!==a?a:JPe,c=t.jsx(u,{id:e.id,displayMonth:e.displayMonth});return t.jsxs("div",{className:i.caption_dropdowns,style:r.caption_dropdowns,children:[t.jsx("div",{className:i.vhidden,children:c}),t.jsx(qPe,{onChange:l,displayMonth:e.displayMonth}),t.jsx($Pe,{onChange:l,displayMonth:e.displayMonth})]})}function aje(e){return t.jsx("svg",BPe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function tje(e){return t.jsx("svg",BPe({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var nje=a.forwardRef((function(e,a){var n=VPe(),i=n.classNames,r=n.styles,o=[i.button_reset,i.button];e.className&&o.push(e.className);var s=o.join(" "),l=BPe(BPe({},r.button_reset),r.button);return e.style&&Object.assign(l,e.style),t.jsx("button",BPe({},e,{ref:a,type:"button",className:s,style:l}))}));function ije(e){var a,n,i=VPe(),r=i.dir,o=i.locale,s=i.classNames,l=i.styles,u=i.labels,c=u.labelPrevious,d=u.labelNext,m=i.components;if(!e.nextMonth&&!e.previousMonth)return t.jsx(t.Fragment,{});var h=c(e.previousMonth,{locale:o}),p=[s.nav_button,s.nav_button_previous].join(" "),g=d(e.nextMonth,{locale:o}),f=[s.nav_button,s.nav_button_next].join(" "),v=null!==(a=null==m?void 0:m.IconRight)&&void 0!==a?a:tje,y=null!==(n=null==m?void 0:m.IconLeft)&&void 0!==n?n:aje;return t.jsxs("div",{className:s.nav,style:l.nav,children:[!e.hidePrevious&&t.jsx(nje,{name:"previous-month","aria-label":h,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:t.jsx("rtl"===r?v:y,{className:s.nav_icon,style:l.nav_icon})}),!e.hideNext&&t.jsx(nje,{name:"next-month","aria-label":g,className:f,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:t.jsx("rtl"===r?y:v,{className:s.nav_icon,style:l.nav_icon})})]})}function rje(e){var a=VPe().numberOfMonths,n=XPe(),i=n.previousMonth,r=n.nextMonth,o=n.goToMonth,s=n.displayMonths,l=s.findIndex((function(a){return _Pe(e.displayMonth,a)})),u=0===l,c=l===s.length-1;return t.jsx(ije,{displayMonth:e.displayMonth,hideNext:a>1&&(u||!c),hidePrevious:a>1&&(c||!u),nextMonth:r,previousMonth:i,onPreviousClick:function(){i&&o(i)},onNextClick:function(){r&&o(r)}})}function oje(e){var a,n,i=VPe(),r=i.classNames,o=i.styles,s=i.captionLayout,l=i.components,u=null!==(a=null==l?void 0:l.CaptionLabel)&&void 0!==a?a:JPe;return n=i.disableNavigation?t.jsx(u,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===s?t.jsx(eje,{displayMonth:e.displayMonth,id:e.id}):t.jsxs(t.Fragment,"dropdown-buttons"===s?{children:[t.jsx(eje,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),t.jsx(rje,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}:{children:[t.jsx(u,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx(rje,{displayMonth:e.displayMonth,id:e.id})]}),t.jsx("div",{className:r.caption,style:o.caption,children:n})}function sje(e){var a=VPe(),n=a.footer;return n?t.jsx("tfoot",{className:a.classNames.tfoot,style:a.styles.tfoot,children:t.jsx("tr",{children:t.jsx("td",{colSpan:8,children:n})})}):t.jsx(t.Fragment,{})}function lje(){var e=VPe(),a=e.classNames,n=e.styles,i=e.showWeekNumber,r=e.locale,o=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,l=function(e,a,t){for(var n=t?v_e(new Date):f_e(new Date,{locale:e,weekStartsOn:a}),i=[],r=0;r<7;r++){var o=m_e(n,r);i.push(o)}return i}(r,e.weekStartsOn,e.ISOWeek);return t.jsxs("tr",{style:n.head_row,className:a.head_row,children:[i&&t.jsx("td",{style:n.head_cell,className:a.head_cell}),l.map((function(e,i){return t.jsx("th",{scope:"col",className:a.head_cell,style:n.head_cell,"aria-label":s(e,{locale:r}),children:o(e,{locale:r})},i)}))]})}function uje(){var e,a=VPe(),n=a.components,i=null!==(e=null==n?void 0:n.HeadRow)&&void 0!==e?e:lje;return t.jsx("thead",{style:a.styles.head,className:a.classNames.head,children:t.jsx(i,{})})}function cje(e){var a=VPe();return t.jsx(t.Fragment,{children:(0,a.formatters.formatDay)(e.date,{locale:a.locale})})}var dje=a.createContext(void 0);function mje(e){if(!DPe(e.initialProps)){return t.jsx(dje.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}return t.jsx(hje,{initialProps:e.initialProps,children:e.children})}function hje(e){var a=e.initialProps,n=e.children,i=a.selected,r=a.min,o=a.max,s={disabled:[]};return i&&s.disabled.push((function(e){var a=o&&i.length>o-1,t=i.some((function(a){return C_e(a,e)}));return Boolean(a&&!t)})),t.jsx(dje.Provider,{value:{selected:i,onDayClick:function(e,t,n){var s,l;if((null===(s=a.onDayClick)||void 0===s||s.call(a,e,t,n),!Boolean(t.selected&&r&&(null==i?void 0:i.length)===r))&&!Boolean(!t.selected&&o&&(null==i?void 0:i.length)===o)){var u=i?RPe([],i):[];if(t.selected){var c=u.findIndex((function(a){return C_e(e,a)}));u.splice(c,1)}else u.push(e);null===(l=a.onSelect)||void 0===l||l.call(a,u,e,t,n)}},modifiers:s},children:n})}function pje(){var e=a.useContext(dje);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var gje,fje,vje=a.createContext(void 0);function yje(e){if(!zPe(e.initialProps)){return t.jsx(vje.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}return t.jsx(bje,{initialProps:e.initialProps,children:e.children})}function bje(e){var a=e.initialProps,n=e.children,i=a.selected,r=i||{},o=r.from,s=r.to,l=a.min,u=a.max,c={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(c.range_start=[o],s?(c.range_end=[s],C_e(o,s)||(c.range_middle=[{after:o,before:s}])):c.range_end=[o]):s&&(c.range_start=[s],c.range_end=[s]),l&&(o&&!s&&c.disabled.push({after:PPe(o,l-1),before:m_e(o,l-1)}),o&&s&&c.disabled.push({after:o,before:m_e(o,l-1)}),!o&&s&&c.disabled.push({after:PPe(s,l-1),before:m_e(s,l-1)})),u){if(o&&!s&&(c.disabled.push({before:m_e(o,1-u)}),c.disabled.push({after:m_e(o,u-1)})),o&&s){var d=u-(S_e(s,o)+1);c.disabled.push({before:PPe(o,d)}),c.disabled.push({after:m_e(s,d)})}!o&&s&&(c.disabled.push({before:m_e(s,1-u)}),c.disabled.push({after:m_e(s,u-1)}))}return t.jsx(vje.Provider,{value:{selected:i,onDayClick:function(e,t,n){var r,o;null===(r=a.onDayClick)||void 0===r||r.call(a,e,t,n);var s=function(e,a){var t=a||{},n=t.from,i=t.to;if(n&&i){if(C_e(i,e)&&C_e(n,e))return;if(C_e(i,e))return{from:i,to:void 0};if(C_e(n,e))return;return EPe(n,e)?{from:e,to:i}:{from:n,to:e}}return i?EPe(e,i)?{from:i,to:e}:{from:e,to:i}:n?NPe(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}(e,i);null===(o=a.onSelect)||void 0===o||o.call(a,s,e,t,n)},modifiers:c},children:n})}function kje(){var e=a.useContext(vje);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Sje(e){return Array.isArray(e)?RPe([],e):void 0!==e?[e]:[]}(fje=gje||(gje={})).Outside="outside",fje.Disabled="disabled",fje.Selected="selected",fje.Hidden="hidden",fje.Today="today",fje.RangeStart="range_start",fje.RangeEnd="range_end",fje.RangeMiddle="range_middle";var wje=gje.Selected,Aje=gje.Disabled,Cje=gje.Hidden,Mje=gje.Today,Tje=gje.RangeEnd,xje=gje.RangeMiddle,Eje=gje.RangeStart,Nje=gje.Outside;var _je=a.createContext(void 0);function Pje(e){var a=VPe(),n=function(e,a,t){var n,i=((n={})[wje]=Sje(e.selected),n[Aje]=Sje(e.disabled),n[Cje]=Sje(e.hidden),n[Mje]=[e.today],n[Tje]=[],n[xje]=[],n[Eje]=[],n[Nje]=[],n);return e.fromDate&&i[Aje].push({before:e.fromDate}),e.toDate&&i[Aje].push({after:e.toDate}),DPe(e)?i[Aje]=i[Aje].concat(a.modifiers[Aje]):zPe(e)&&(i[Aje]=i[Aje].concat(t.modifiers[Aje]),i[Eje]=t.modifiers[Eje],i[xje]=t.modifiers[xje],i[Tje]=t.modifiers[Tje]),i}(a,pje(),kje()),i=function(e){var a={};return Object.entries(e).forEach((function(e){a[e[0]]=Sje(e[1])})),a}(a.modifiers),r=BPe(BPe({},n),i);return t.jsx(_je.Provider,{value:r,children:e.children})}function jje(){var e=a.useContext(_je);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function Lje(e,a){return a.some((function(a){if("boolean"==typeof a)return a;if(M_e(a))return C_e(e,a);var t,n,i,r,o;if(function(e){return Array.isArray(e)&&e.every(M_e)}(a))return a.includes(e);if(function(e){return Boolean(e&&"object"==typeof e&&"from"in e)}(a))return t=e,o=(n=a).to,(r=n.from)&&o?(S_e(o,r)<0&&(r=(i=[o,r])[0],o=i[1]),S_e(t,r)>=0&&S_e(o,t)>=0):o?C_e(o,t):!!r&&C_e(r,t);if(function(e){return Boolean(e&&"object"==typeof e&&"dayOfWeek"in e)}(a))return a.dayOfWeek.includes(e.getDay());if(function(e){return Boolean(e&&"object"==typeof e&&"before"in e&&"after"in e)}(a)){var s=S_e(a.before,e)>0,l=S_e(a.after,e)<0;return EPe(a.before,a.after)?l&&s:s||l}return function(e){return Boolean(e&&"object"==typeof e&&"after"in e)}(a)?S_e(e,a.after)>0:function(e){return Boolean(e&&"object"==typeof e&&"before"in e)}(a)?S_e(a.before,e)>0:"function"==typeof a&&a(e)}))}function Bje(e,a,t){var n=Object.keys(a).reduce((function(t,n){return Lje(e,a[n])&&t.push(n),t}),[]),i={};return n.forEach((function(e){return i[e]=!0})),t&&!_Pe(e,t)&&(i.outside=!0),i}function Rje(e,a){var t=a.moveBy,n=a.direction,i=a.context,r=a.modifiers,o=a.retry,s=void 0===o?{count:0,lastFocused:e}:o,l=i.weekStartsOn,u=i.fromDate,c=i.toDate,d=i.locale,m={day:m_e,week:w_e,month:h_e,year:A_e,startOfWeek:function(e){return i.ISOWeek?v_e(e):f_e(e,{locale:d,weekStartsOn:l})},endOfWeek:function(e){return i.ISOWeek?P_e(e):__e(e,{locale:d,weekStartsOn:l})}}[t](e,"after"===n?1:-1);"before"===n&&u?m=function(e){var a,t;if(c_e(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==l_e(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=d_e(e);(void 0===t||t<a||isNaN(Number(a)))&&(t=a)})),t||new Date(NaN)}([u,m]):"after"===n&&c&&(m=function(e){var a,t;if(c_e(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==l_e(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=d_e(e);(void 0===t||t>a||isNaN(a.getDate()))&&(t=a)})),t||new Date(NaN)}([c,m]));var h=!0;if(r){var p=Bje(m,r);h=!p.disabled&&!p.hidden}return h?m:s.count>365?s.lastFocused:Rje(m,{moveBy:t,direction:n,context:i,modifiers:r,retry:BPe(BPe({},s),{count:s.count+1})})}var Dje=a.createContext(void 0);function zje(e){var n=XPe(),i=jje(),r=a.useState(),o=r[0],s=r[1],l=a.useState(),u=l[0],c=l[1],d=function(e,a){for(var t,n,i=E_e(e[0]),r=x_e(e[e.length-1]),o=i;o<=r;){var s=Bje(o,a);if(s.disabled||s.hidden)o=m_e(o,1);else{if(s.selected)return o;s.today&&!n&&(n=o),t||(t=o),o=m_e(o,1)}}return n||t}(n.displayMonths,i),m=(null!=o?o:u&&n.isDateDisplayed(u))?u:d,h=function(e){s(e)},p=VPe(),g=function(e,a){if(o){var t=Rje(o,{moveBy:e,direction:a,context:p,modifiers:i});C_e(o,t)||(n.goToDate(t,o),h(t))}};return t.jsx(Dje.Provider,{value:{focusedDay:o,focusTarget:m,blur:function(){c(o),s(void 0)},focus:h,focusDayAfter:function(){return g("day","after")},focusDayBefore:function(){return g("day","before")},focusWeekAfter:function(){return g("week","after")},focusWeekBefore:function(){return g("week","before")},focusMonthBefore:function(){return g("month","before")},focusMonthAfter:function(){return g("month","after")},focusYearBefore:function(){return g("year","before")},focusYearAfter:function(){return g("year","after")},focusStartOfWeek:function(){return g("startOfWeek","before")},focusEndOfWeek:function(){return g("endOfWeek","after")}},children:e.children})}function Oje(){var e=a.useContext(Dje);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}var Kje=a.createContext(void 0);function Hje(e){if(!OPe(e.initialProps)){return t.jsx(Kje.Provider,{value:{selected:void 0},children:e.children})}return t.jsx(Ije,{initialProps:e.initialProps,children:e.children})}function Ije(e){var a=e.initialProps;return t.jsx(Kje.Provider,{value:{selected:a.selected,onDayClick:function(e,t,n){var i,r,o;null===(i=a.onDayClick)||void 0===i||i.call(a,e,t,n),!t.selected||a.required?null===(o=a.onSelect)||void 0===o||o.call(a,e,e,t,n):null===(r=a.onSelect)||void 0===r||r.call(a,void 0,e,t,n)}},children:e.children})}function Fje(){var e=a.useContext(Kje);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function Gje(e,a){var t=[e.classNames.day];return Object.keys(a).forEach((function(a){var n=e.modifiersClassNames[a];if(n)t.push(n);else if(function(e){return Object.values(gje).includes(e)}(a)){var i=e.classNames["day_".concat(a)];i&&t.push(i)}})),t}function Vje(e,n,i){var r,o,s,l=VPe(),u=Oje(),c=function(e,a){return Bje(e,jje(),a)}(e,n),d=function(e,a){var t=VPe(),n=Fje(),i=pje(),r=kje(),o=Oje(),s=o.focusDayAfter,l=o.focusDayBefore,u=o.focusWeekAfter,c=o.focusWeekBefore,d=o.blur,m=o.focus,h=o.focusMonthBefore,p=o.focusMonthAfter,g=o.focusYearBefore,f=o.focusYearAfter,v=o.focusStartOfWeek,y=o.focusEndOfWeek;return{onClick:function(o){var s,l,u,c;OPe(t)?null===(s=n.onDayClick)||void 0===s||s.call(n,e,a,o):DPe(t)?null===(l=i.onDayClick)||void 0===l||l.call(i,e,a,o):zPe(t)?null===(u=r.onDayClick)||void 0===u||u.call(r,e,a,o):null===(c=t.onDayClick)||void 0===c||c.call(t,e,a,o)},onFocus:function(n){var i;m(e),null===(i=t.onDayFocus)||void 0===i||i.call(t,e,a,n)},onBlur:function(n){var i;d(),null===(i=t.onDayBlur)||void 0===i||i.call(t,e,a,n)},onKeyDown:function(n){var i;switch(n.key){case"ArrowLeft":n.preventDefault(),n.stopPropagation(),"rtl"===t.dir?s():l();break;case"ArrowRight":n.preventDefault(),n.stopPropagation(),"rtl"===t.dir?l():s();break;case"ArrowDown":n.preventDefault(),n.stopPropagation(),u();break;case"ArrowUp":n.preventDefault(),n.stopPropagation(),c();break;case"PageUp":n.preventDefault(),n.stopPropagation(),n.shiftKey?g():h();break;case"PageDown":n.preventDefault(),n.stopPropagation(),n.shiftKey?f():p();break;case"Home":n.preventDefault(),n.stopPropagation(),v();break;case"End":n.preventDefault(),n.stopPropagation(),y()}null===(i=t.onDayKeyDown)||void 0===i||i.call(t,e,a,n)},onKeyUp:function(n){var i;null===(i=t.onDayKeyUp)||void 0===i||i.call(t,e,a,n)},onMouseEnter:function(n){var i;null===(i=t.onDayMouseEnter)||void 0===i||i.call(t,e,a,n)},onMouseLeave:function(n){var i;null===(i=t.onDayMouseLeave)||void 0===i||i.call(t,e,a,n)},onPointerEnter:function(n){var i;null===(i=t.onDayPointerEnter)||void 0===i||i.call(t,e,a,n)},onPointerLeave:function(n){var i;null===(i=t.onDayPointerLeave)||void 0===i||i.call(t,e,a,n)},onTouchCancel:function(n){var i;null===(i=t.onDayTouchCancel)||void 0===i||i.call(t,e,a,n)},onTouchEnd:function(n){var i;null===(i=t.onDayTouchEnd)||void 0===i||i.call(t,e,a,n)},onTouchMove:function(n){var i;null===(i=t.onDayTouchMove)||void 0===i||i.call(t,e,a,n)},onTouchStart:function(n){var i;null===(i=t.onDayTouchStart)||void 0===i||i.call(t,e,a,n)}}}(e,c),m=function(){var e=VPe(),a=Fje(),t=pje(),n=kje();return OPe(e)?a.selected:DPe(e)?t.selected:zPe(e)?n.selected:void 0}(),h=Boolean(l.onDayClick||"default"!==l.mode);a.useEffect((function(){var a;c.outside||u.focusedDay&&h&&C_e(u.focusedDay,e)&&(null===(a=i.current)||void 0===a||a.focus())}),[u.focusedDay,e,i,h,c.outside]);var p=Gje(l,c).join(" "),g=function(e,a){var t=BPe({},e.styles.day);return Object.keys(a).forEach((function(a){var n;t=BPe(BPe({},t),null===(n=e.modifiersStyles)||void 0===n?void 0:n[a])})),t}(l,c),f=Boolean(c.outside&&!l.showOutsideDays||c.hidden),v=null!==(s=null===(o=l.components)||void 0===o?void 0:o.DayContent)&&void 0!==s?s:cje,y={style:g,className:p,children:t.jsx(v,{date:e,displayMonth:n,activeModifiers:c}),role:"gridcell"},b=u.focusTarget&&C_e(u.focusTarget,e)&&!c.outside,k=u.focusedDay&&C_e(u.focusedDay,e),S=BPe(BPe(BPe({},y),((r={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,r.tabIndex=k||b?0:-1,r)),d);return{isButton:h,isHidden:f,activeModifiers:c,selectedDays:m,buttonProps:S,divProps:y}}function Jje(e){var n=a.useRef(null),i=Vje(e.date,e.displayMonth,n);return i.isHidden?t.jsx("div",{role:"gridcell"}):i.isButton?t.jsx(nje,BPe({name:"day",ref:n},i.buttonProps)):t.jsx("div",BPe({},i.divProps))}function Uje(e){var a=e.number,n=e.dates,i=VPe(),r=i.onWeekNumberClick,o=i.styles,s=i.classNames,l=i.locale,u=i.labels.labelWeekNumber,c=(0,i.formatters.formatWeekNumber)(Number(a),{locale:l});if(!r)return t.jsx("span",{className:s.weeknumber,style:o.weeknumber,children:c});var d=u(Number(a),{locale:l});return t.jsx(nje,{name:"week-number","aria-label":d,className:s.weeknumber,style:o.weeknumber,onClick:function(e){r(a,n,e)},children:c})}function Wje(e){var a,n,i,r=VPe(),o=r.styles,s=r.classNames,l=r.components,u=null!==(a=null==l?void 0:l.Day)&&void 0!==a?a:Jje,c=null!==(n=null==l?void 0:l.WeekNumber)&&void 0!==n?n:Uje;return r.showWeekNumber&&(i=t.jsx("td",{className:s.cell,style:o.cell,children:t.jsx(c,{number:e.weekNumber,dates:e.dates})})),t.jsxs("tr",{className:s.row,style:o.row,children:[i,e.dates.map((function(a){return t.jsx("td",{className:s.cell,style:o.cell,role:"presentation",children:t.jsx(u,{displayMonth:e.displayMonth,date:a})},MPe(a))}))]})}function qje(e,a,t){for(var n=(null==t?void 0:t.ISOWeek)?P_e(a):__e(a,t),i=(null==t?void 0:t.ISOWeek)?v_e(e):f_e(e,t),r=S_e(n,i),o=[],s=0;s<=r;s++)o.push(m_e(i,s));var l=o.reduce((function(e,a){var n=(null==t?void 0:t.ISOWeek)?function(e){c_e(1,arguments);var a=d_e(e),t=v_e(a).getTime()-y_e(a).getTime();return Math.round(t/6048e5)+1}(a):function(e,a){c_e(1,arguments);var t=d_e(e),n=f_e(t,a).getTime()-TPe(t,a).getTime();return Math.round(n/6048e5)+1}(a,t),i=e.find((function(e){return e.weekNumber===n}));return i?(i.dates.push(a),e):(e.push({weekNumber:n,dates:[a]}),e)}),[]);return l}function $je(e){var a,n,i,r=VPe(),o=r.locale,s=r.classNames,l=r.styles,u=r.hideHead,c=r.components,d=r.weekStartsOn,m=r.firstWeekContainsDate,h=r.ISOWeek,p=function(e,a){var t=qje(E_e(e),x_e(e),a);if(null==a?void 0:a.useFixedWeeks){var n=xPe(e,a);if(n<6){var i=t[t.length-1],r=i.dates[i.dates.length-1],o=w_e(r,6-n),s=qje(w_e(r,1),o,a);t.push.apply(t,s)}}return t}(e.displayMonth,{useFixedWeeks:Boolean(r.fixedWeeks),ISOWeek:h,locale:o,weekStartsOn:d,firstWeekContainsDate:m}),g=null!==(a=null==c?void 0:c.Head)&&void 0!==a?a:uje,f=null!==(n=null==c?void 0:c.Row)&&void 0!==n?n:Wje,v=null!==(i=null==c?void 0:c.Footer)&&void 0!==i?i:sje;return t.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&t.jsx(g,{}),t.jsx("tbody",{className:s.tbody,style:l.tbody,children:p.map((function(a){return t.jsx(f,{displayMonth:e.displayMonth,dates:a.dates,weekNumber:a.weekNumber},a.weekNumber)}))}),t.jsx(v,{displayMonth:e.displayMonth})]})}var Zje="undefined"!=typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,Yje=!1,Qje=0;function Xje(){return"react-day-picker-".concat(++Qje)}function eLe(e){var n,i,r=VPe(),o=r.dir,s=r.classNames,l=r.styles,u=r.components,c=XPe().displayMonths,d=function(e){var t,n=null!=e?e:Yje?Xje():null,i=a.useState(n),r=i[0],o=i[1];return Zje((function(){null===r&&o(Xje())}),[]),a.useEffect((function(){!1===Yje&&(Yje=!0)}),[]),null!==(t=null!=e?e:r)&&void 0!==t?t:void 0}(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),m=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,h=[s.month],p=l.month,g=0===e.displayIndex,f=e.displayIndex===c.length-1,v=!g&&!f;"rtl"===o&&(f=(n=[g,f])[0],g=n[1]),g&&(h.push(s.caption_start),p=BPe(BPe({},p),l.caption_start)),f&&(h.push(s.caption_end),p=BPe(BPe({},p),l.caption_end)),v&&(h.push(s.caption_between),p=BPe(BPe({},p),l.caption_between));var y=null!==(i=null==u?void 0:u.Caption)&&void 0!==i?i:oje;return t.jsxs("div",{className:h.join(" "),style:p,children:[t.jsx(y,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx($je,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function aLe(e){var a=VPe();return t.jsx("div",{className:a.classNames.months,style:a.styles.months,children:e.children})}function tLe(e){var n,i,r=e.initialProps,o=VPe(),s=Oje(),l=XPe(),u=a.useState(!1),c=u[0],d=u[1];a.useEffect((function(){o.initialFocus&&s.focusTarget&&(c||(s.focus(s.focusTarget),d(!0)))}),[o.initialFocus,c,s.focus,s.focusTarget,s]);var m=[o.classNames.root,o.className];o.numberOfMonths>1&&m.push(o.classNames.multiple_months),o.showWeekNumber&&m.push(o.classNames.with_weeknumber);var h=BPe(BPe({},o.styles.root),o.style),p=Object.keys(r).filter((function(e){return e.startsWith("data-")})).reduce((function(e,a){var t;return BPe(BPe({},e),((t={})[a]=r[a],t))}),{}),g=null!==(i=null===(n=r.components)||void 0===n?void 0:n.Months)&&void 0!==i?i:aLe;return t.jsx("div",BPe({className:m.join(" "),style:h,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:t.jsx(g,{children:l.displayMonths.map((function(e,a){return t.jsx(eLe,{displayIndex:a,displayMonth:e},a)}))})}))}function nLe(e){var a=e.children,n=function(e,a){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&a.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)a.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]])}return t}(e,["children"]);return t.jsx(GPe,{initialProps:n,children:t.jsx(QPe,{children:t.jsx(Hje,{initialProps:n,children:t.jsx(mje,{initialProps:n,children:t.jsx(yje,{initialProps:n,children:t.jsx(Pje,{children:t.jsx(zje,{children:a})})})})})})})}function iLe(e){return t.jsx(nLe,BPe({},e,{children:t.jsx(tLe,{initialProps:e})}))}function rLe({className:e,classNames:a,showOutsideDays:n=!0,...i}){const r={months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:XO(K5({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-[#6b7280] rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-[#f1f5f9] [&:has([aria-selected].day-outside)]:bg-[#f1f5f9]/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",day:XO(K5({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"!bg-black !text-gray-200 hover:!bg-black hover:!text-gray-200 focus:!bg-black focus:!text-white",day_today:"bg-gray-200 text-black",day_outside:"day-outside text-[#94a3b8] aria-selected:bg-[#f1f5f9]/50 aria-selected:text-[#94a3b8]",day_disabled:"text-[#94a3b8] opacity-50",day_range_middle:"aria-selected:bg-[#f1f5f9] aria-selected:text-black",day_hidden:"invisible",...a};return t.jsx(iLe,{showOutsideDays:n,className:XO("p-3",e),classNames:r,components:{IconLeft:()=>t.jsx(iz,{className:"h-4 w-4"}),IconRight:()=>t.jsx(rz,{className:"h-4 w-4"})},...i})}rLe.displayName="Calendar";const oLe=({setScheduleTime:e,setTimezone:a,timezone:n,scheduleTime:i,setIsDirty:o,canEditScheduleTime:s})=>{const[l,u]=r.useState(s&&i&&i<(new Date).toISOString()?"Please select a time in the future":null),[c,d]=r.useState(i&&"now"!==i?Eue(new Date(i),"HH:mm"):"00:00"),m=Intl.supportedValuesOf("timeZone").map((e=>({label:e,value:e}))),h=e=>{if(!s)return;const t=new Date(i||(new Date).toISOString()),n=Ile(new Date,15);t<new Date(n.toLocaleString("en-US",{timeZone:e}))?u("Please select a time at least 15 minutes in the future"):(u(null),a(e),o(!0))},p=a=>{if(!s)return;const t=Ile(new Date,15);new Date(a.toLocaleString("en-US",{timeZone:n}))<new Date(t.toLocaleString("en-US",{timeZone:n}))?u("Please select a time at least 15 minutes in the future"):(u(null),e(a.toISOString()),o(!0))};return t.jsx("div",{className:"w-full @container/schedule-time",children:t.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[t.jsxs("div",{className:"flex gap-2 w-full @xl/schedule-time:flex-row flex-col items-center justify-center",children:[t.jsxs(Nre,{children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{variant:"outline",disabled:!s,className:XO("bg-background w-full sm:w-[280px] justify-start text-left font-normal",!i&&"text-muted-foreground",!s&&"opacity-50 cursor-not-allowed"),children:[t.jsx(ez,{className:"mr-2 h-4 w-4"}),i?"now"===i?"Send immediately":Eue(new Date(i),"PPP"):t.jsx("span",{children:"Pick a date"})]})}),t.jsx(Pre,{className:"w-auto p-0 z-[60] pointer-events-auto",children:t.jsx(rLe,{mode:"single",selected:i?new Date(i):void 0,onSelect:e=>{if(!e||!s)return;const[a,t]=c.split(":").map(Number);e.setHours(a,t),p(e)},disabled:e=>{const a=new Date;return a.setHours(0,0,0,0),e<a||!s},initialFocus:!0})})]}),t.jsx("input",{type:"time",value:c,onChange:e=>{if(s&&(d(e.target.value),i&&e.target.value)){const[a,t]=e.target.value.split(":").map(Number),n=new Date(i);n.setHours(a,t),p(n)}},disabled:!s,className:XO("flex h-9 w-full sm:w-[150px] rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",l&&"border-red-500",!s&&"opacity-50 cursor-not-allowed")}),t.jsx("div",{className:"w-full sm:w-[200px]",children:t.jsx(fEe,{options:m,selectedValues:[n],setSelectedValues:e=>h(e[0]),onValueChange:e=>h(e[0]),placeholder:"Select timezone...",searchPlaceholder:"Search timezone...",emptyMessage:"No timezone found",title:"Select Timezone",singleSelect:!0,canOpen:s})})]}),l&&t.jsxs("p",{className:"text-destructive text-sm mt-2 flex items-center",children:[t.jsx("span",{className:"mr-2",children:"⚠️"}),l]})]})})},sLe=({title:e="Edit Schedule Time"})=>{const n=B5(),i=ce(),{updateAutomation:r}=ra(n?.id||""),{toast:o}=Ve(),[s,l]=a.useState(null),[u,c]=a.useState(n?.triggerMetadata?.triggerType===ua.ONE_TIME?n?.triggerMetadata?.scheduledAt:null),[d,m]=a.useState(n?.triggerMetadata?.triggerType===ua.ONE_TIME&&n?.triggerMetadata?.timezone||"America/New_York"),[h,p]=a.useState(!1),[g,f]=a.useState(null);let v=a.useRef(null);const y=a.useCallback((()=>{n&&("sendNow"===s||"now"===u?r({trigger:{triggerType:ua.ONE_TIME,scheduledAt:"now"}},{onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Be.all})}}):u&&d&&r({trigger:{triggerType:ua.ONE_TIME,scheduledAt:u,timezone:d}},{onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:Be.all})}}))}),[n,s,u,d,r,o,i]);if(a.useEffect((()=>(g&&(v.current&&clearTimeout(v.current),v.current=setTimeout((()=>{o(g),f(null)}),800)),()=>{v.current&&clearTimeout(v.current)})),[g,o]),a.useEffect((()=>{n&&h&&s&&("sendNow"===s||u)&&(y(),p(!1))}),[s,u,d,y,n,h]),a.useEffect((()=>{null===s&&n?.triggerMetadata&&"object"==typeof n.triggerMetadata&&null!==n.triggerMetadata&&"scheduledAt"in n.triggerMetadata&&("now"===n?.triggerMetadata?.scheduledAt&&n?.triggerType===ua.ONE_TIME?l("sendNow"):(n?.triggerMetadata?.scheduledAt&&c(n.triggerMetadata.scheduledAt),n?.triggerMetadata?.timezone&&m(n.triggerMetadata.timezone),l("schedule")))}),[n,s]),!n)return null;const b=n.status===ha.DRAFT,k=lH(n?.triggerType===ua.ONE_TIME?"engage:automation":"engage:broadcast");return t.jsx(r_e,{title:e,headerActions:!b&&t.jsx(Fue,{title:"You can only edit the schedule time if the automation is in draft mode"}),children:t.jsx("div",{className:"@container flex-1 mx-4",children:t.jsxs("div",{className:"flex @[1000px]:flex-row flex-col gap-8 items-center",children:[t.jsxs("div",{className:"flex-1 w-full",children:[t.jsxs("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-4",children:[t.jsx(G5,{selected:"sendNow"===s,title:"Immediately",subtitle:`Messages will be sent within ~5 minutes of starting the ${k.toLowerCase()}. Check the Recipients tab to see who has received a message.`,icon:t.jsx(V5.SendButton,{className:"text-primary"}),onClick:()=>{b&&(l("sendNow"),c("now"),m("America/New_York"),p(!0))},disabled:!b}),t.jsx(G5,{selected:"schedule"===s,title:"Schedule",subtitle:`Choose date and time. Any ${k.toLowerCase()} scheduled more than 2 hours from now can be unscheduled and updated.`,icon:t.jsx(V5.ScheduleButton,{className:"text-primary"}),onClick:()=>{b&&l("schedule")},disabled:!b})]}),t.jsx(wY,{children:"schedule"===s&&t.jsx(s5,{className:"overflow-hidden mt-8",children:t.jsx("div",{className:"bg-gray-50 rounded-xl p-5 border border-gray-100 flex items-center justify-center",children:t.jsx(oLe,{setScheduleTime:e=>{c(e),p(!0)},setTimezone:e=>{m(e),p(!0)},timezone:d,scheduleTime:u,setIsDirty:p,canEditScheduleTime:b})})})})]}),u&&"now"!==u&&t.jsx(o5.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.6,ease:[.23,1,.32,1],delay:.1},className:"@[1000px]:w-80 max-w-md w-full shrink-0 h-fit p-4 bg-blue-50 rounded-xl border border-blue-100 backdrop-blur-sm",children:t.jsxs(t.Fragment,{children:[t.jsx(o5.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Currently scheduled for:"}),t.jsx(o5.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short",timeZone:d||void 0})})]})})]})})})},lLe=()=>t.jsx("div",{children:t.jsx(sLe,{title:"Set Schedule Time"})});var uLe=(e=>(e.DAYS="days",e))(uLe||{});const cLe=(e,a)=>{switch(e){case j5.EQUALS:return"Equals";case j5.NOT_EQUALS:return"Not Equals";case j5.GREATER_THAN:return a===_5.Date?"Date on or after":"Greater than";case j5.LESS_THAN:return a===_5.Date?"Date on or before":"Less than";case j5.EXISTS:return"Exists";case j5.EQUALS_MONTH_DAY:return"Month and Day Matches";case j5.EQUALS_MONTH_DAY_YEAR:return"Month, Day, and Year Matches";case j5.BETWEEN_MONTH_DAY:return"Between Month Day";case j5.BETWEEN_MONTH_DAY_YEAR:return"Between Month Day Year";case j5.ARRAY_CONTAINS:return"Is One Of";default:return e}},dLe={email:"Email Address",phone:"Phone Number",firstName:"First Name",lastName:"Last Name"},mLe=({options:e,value:a,onChange:n,placeholder:i,className:o="",disableInput:s=!1})=>{const[l,u]=r.useState(!1);return t.jsxs(Nre,{modal:!0,open:l,onOpenChange:u,children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{"aria-expanded":l,className:XO("w-full overflow-hidden justify-between",o),variant:"outline",children:[a?e.find((e=>e.value===a))?.label:i,t.jsx(sz,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(Pre,{className:XO("w-full min-w-[120px] max-w-[600px] p-0",o),children:t.jsxs(exe,{children:[!s&&t.jsx(axe,{placeholder:`${i}...`}),t.jsxs(txe,{children:[t.jsxs(nxe,{children:["No ",i.toLowerCase()," found."]}),t.jsx(ixe,{children:e.map((e=>t.jsxs(rxe,{value:e.value,onSelect:e=>{n(e===a?"":e),u(!1)},children:[t.jsx(tz,{className:XO("mr-2 h-4 w-4",a===e.value?"opacity-100":"opacity-0")}),e.label]},e.id||e.value)))})]})]})})]})};var hLe="Switch",[pLe,gLe]=u9(hLe),[fLe,vLe]=pLe(hLe),yLe=r.forwardRef(((e,a)=>{const{__scopeSwitch:n,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),f=FZ(a,(e=>g(e))),v=r.useRef(!1),y=!p||(m||!!p.closest("form")),[b=!1,k]=m9({prop:o,defaultProp:s,onChange:d});return t.jsxs(fLe,{scope:n,checked:b,disabled:u,children:[t.jsx(y9.button,{type:"button",role:"switch","aria-checked":b,"aria-required":l,"data-state":wLe(b),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:f,onClick:l9(e.onClick,(e=>{k((e=>!e)),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())}))}),y&&t.jsx(SLe,{control:p,bubbles:!v.current,name:i,value:c,checked:b,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"}})]})}));yLe.displayName=hLe;var bLe="SwitchThumb",kLe=r.forwardRef(((e,a)=>{const{__scopeSwitch:n,...i}=e,r=vLe(bLe,n);return t.jsx(y9.span,{"data-state":wLe(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:a})}));kLe.displayName=bLe;var SLe=e=>{const{control:a,checked:n,bubbles:i=!0,...o}=e,s=r.useRef(null),l=UMe(n),u=M7(a);return r.useEffect((()=>{const e=s.current,a=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(a,"checked").set;if(l!==n&&t){const a=new Event("click",{bubbles:i});t.call(e,n),e.dispatchEvent(a)}}),[l,n,i]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function wLe(e){return e?"checked":"unchecked"}var ALe=yLe,CLe=kLe;const MLe=r.forwardRef((({className:e,...a},n)=>t.jsx(ALe,{className:XO("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input/50",e),...a,ref:n,children:t.jsx(CLe,{className:XO("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})));MLe.displayName=ALe.displayName;const TLe=({onSelect:e,date:a,placeholder:n="Pick a date",monthDayOnly:i=!1})=>t.jsxs(Nre,{modal:!0,children:[t.jsx(_re,{asChild:!0,children:t.jsxs(H5,{variant:"outline",className:XO("w-[200px] justify-start text-left font-normal h-9",!a&&"text-muted-foreground"),children:[t.jsx(ez,{className:"mr-2 h-4 w-4"}),a?Eue(a,i?"MMMM d":"PPP"):t.jsx("span",{children:n})]})}),t.jsx(Pre,{className:"w-auto p-0",align:"start",children:t.jsx(rLe,{mode:"single",selected:a,onSelect:e,initialFocus:!0})})]}),xLe=Ale.union([Ale.date(),Ale.string().transform((e=>{if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[a,t,n]=e.split("-").map(Number);return new Date(a,t-1,n)}return new Date(e)}))]).refine((e=>!isNaN(e.getTime())),{message:"Invalid date"}),ELe=e=>void 0===e.value||!("number"!=typeof e.value||e.value<0)&&(e.unit===uLe.DAYS&&(("before"===e.direction||"after"===e.direction)&&"relative"===e.type)),NLe=e=>{const{date:a,fieldType:t}=e;return t===_5.Date?new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),0,0,0,0)):a},_Le=({fieldType:e,operator:a,value:n,onChange:i,options:o,toast:s})=>{const l=n.length>0&&"object"==typeof n[0]&&"type"in n[0]&&"relative"===n[0].type,u=n.length>0&&"object"==typeof n[0]&&"startDate"in n[0]&&"endDate"in n[0],[c,d]=r.useState((()=>{if((e===_5.Date||e===_5.DateTime)&&n.length>0){const e=xLe.safeParse(n[0]);return e.success?e.data:void 0}})),[m,h]=r.useState(l),[p,g]=r.useState(l?n[0]:{type:"relative",value:0,unit:uLe.DAYS,direction:"before"}),[f,v]=r.useState(u?n[0]:void 0),[y,b]=r.useState(!1);if(r.useEffect((()=>{a!==j5.EQUALS_MONTH_DAY&&a!==j5.EQUALS_MONTH_DAY_YEAR&&m&&(h(!1),i(c?[c]:[]))}),[a,m,c,i]),r.useEffect((()=>{if(u&&f?.startDate){b("object"==typeof f.startDate&&"type"in f.startDate)}}),[u,f]),e===_5.String||e===_5.ReachResource||e===_5.Array)return a===j5.EXISTS?null:t.jsx(fEe,{options:(o||[]).map((e=>({label:e.displayName,value:e.id}))),onValueChange:e=>{i(e)},selectedValues:n.map((e=>{const a=(o||[]).find((a=>a.id===String(e)||a.displayName===String(e)||a.id===a.displayName&&a.id===String(e)));return a?.id||String(e)})),setSelectedValues:e=>{i(e)}});if(e===_5.Date||e===_5.DateTime){const n=a===j5.EQUALS_MONTH_DAY||a===j5.EQUALS_MONTH_DAY_YEAR,r=a===j5.BETWEEN_MONTH_DAY||a===j5.BETWEEN_MONTH_DAY_YEAR,o=e=>{ELe(e)?(g(e),m&&i([e])):s({title:"Invalid relative date",description:"Please enter a valid non-negative number of days.",variant:"destructive"})},l=e=>{const a=e.startDate??f?.startDate,t=e.endDate??f?.endDate,n=a&&"object"==typeof a&&"type"in a,r=t&&"object"==typeof t&&"type"in t;if(a&&t){if(n!==r)return void s({title:"Invalid date range",description:"Both start and end dates must be of the same type (either both absolute or both relative).",variant:"destructive"});if(!n&&!r&&!(e=>!e.finalStartDate||!e.finalEndDate||e.finalStartDate<e.finalEndDate)({finalStartDate:a,finalEndDate:t}))return void s({title:"Invalid date range",description:"Start date must be before end date.",variant:"destructive"});if(n&&(!ELe(a)||!ELe(t)))return void s({title:"Invalid relative date",description:"Please enter valid relative dates.",variant:"destructive"})}v(e),a&&t&&i([{startDate:a,endDate:t}])},u=a=>{a&&(e=>e instanceof Date?!isNaN(e.getTime()):"object"==typeof e&&"type"in e&&"relative"===e.type&&ELe(e))(a)?(d(NLe({date:a,fieldType:e})),i([NLe({date:a,fieldType:e})]),h(!1)):a||(d(void 0),i([]),h(!1))},k=a=>{h(a),i(a?[p]:c?[NLe({date:c,fieldType:e})]:[])};return t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("div",{className:"min-h-[36px] flex items-center",children:[(!m||!n)&&!r&&t.jsx(TLe,{date:c,onSelect:u,monthDayOnly:a===j5.EQUALS_MONTH_DAY}),n&&m&&t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(gte,{type:"number",value:void 0===p.value?"":p.value,onChange:e=>{const a=""===e.target.value?void 0:parseInt(e.target.value,10);o({...p,value:a})},className:"w-20 h-9",min:"0","aria-label":"Relative days value"}),t.jsxs(pwe,{value:p.direction,onValueChange:e=>{o({...p,direction:e})},children:[t.jsx(vwe,{className:"w-[180px] h-9","aria-label":"Relative direction",children:t.jsx(fwe,{placeholder:"Select direction..."})}),t.jsxs(kwe,{children:[t.jsx(Swe,{value:"before",children:"days before today"}),t.jsx(Swe,{value:"after",children:"days after today"})]})]})]}),r&&t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsxs("div",{className:"flex flex-col space-y-2",children:[t.jsx("div",{className:"flex items-center space-x-2",children:y?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(gte,{type:"number",value:f?.startDate&&"object"==typeof f.startDate&&"type"in f.startDate?f.startDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:uLe.DAYS,direction:f?.startDate?.direction||"before"};ELe(a)&&(v({...f,startDate:a}),l({...f,startDate:a}))},className:"w-20 h-9",min:"0","aria-label":"Start date relative days"}),t.jsxs(pwe,{value:f?.startDate&&"object"==typeof f.startDate&&"type"in f.startDate?f.startDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:f?.startDate?.value,unit:uLe.DAYS,direction:e};ELe(a)&&(v({...f,startDate:a}),l({...f,startDate:a}))},children:[t.jsx(vwe,{className:"w-[180px] h-9",children:t.jsx(fwe,{placeholder:"Select direction..."})}),t.jsxs(kwe,{children:[t.jsx(Swe,{value:"before",children:"days before today"}),t.jsx(Swe,{value:"after",children:"days after today"})]})]}),t.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"Start"})]}):t.jsx(TLe,{placeholder:"Start date",date:f?.startDate instanceof Date||"string"==typeof f?.startDate?f.startDate instanceof Date?f.startDate:new Date(f.startDate):void 0,monthDayOnly:a===j5.BETWEEN_MONTH_DAY,onSelect:a=>{const t=a;t&&(v({...f,startDate:NLe({date:t,fieldType:e})}),l({...f,startDate:NLe({date:t,fieldType:e})}))}})}),t.jsx("div",{className:"flex items-center space-x-2",children:y?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(gte,{type:"number",value:f?.endDate&&"object"==typeof f.endDate&&"type"in f.endDate?f.endDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:uLe.DAYS,direction:f?.endDate?.direction||"before"};ELe(a)&&(v({...f,endDate:a}),l({...f,endDate:a}))},className:"w-20 h-9",min:"0","aria-label":"End date relative days"}),t.jsxs(pwe,{value:f?.endDate&&"object"==typeof f.endDate&&"type"in f.endDate?f.endDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:f?.endDate?.value,unit:uLe.DAYS,direction:e};ELe(a)&&(v({...f,endDate:a}),l({...f,endDate:a}))},children:[t.jsx(vwe,{className:"w-[180px] h-9",children:t.jsx(fwe,{placeholder:"Select direction..."})}),t.jsxs(kwe,{children:[t.jsx(Swe,{value:"before",children:"days before today"}),t.jsx(Swe,{value:"after",children:"days after today"})]})]}),t.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"End"})]}):t.jsx(TLe,{placeholder:"End date",date:f?.endDate instanceof Date||"string"==typeof f?.endDate?f.endDate instanceof Date?f.endDate:new Date(f.endDate):void 0,monthDayOnly:a===j5.BETWEEN_MONTH_DAY,onSelect:a=>{const t=a;t&&(v({...f,endDate:NLe({date:t,fieldType:e})}),l({...f,endDate:NLe({date:t,fieldType:e})}))}})})]}),t.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[t.jsx(MLe,{id:"between-relative-date-switch",checked:y,onCheckedChange:e=>{if(b(e),e){const e={type:"relative",value:0,unit:uLe.DAYS,direction:"before"},a={type:"relative",value:0,unit:uLe.DAYS,direction:"before"};v({startDate:e,endDate:a}),l({startDate:e,endDate:a})}else{const e=new Date,a=new Date(e);a.setDate(a.getDate()+1),v({startDate:e,endDate:a}),l({startDate:e,endDate:a})}},"aria-label":"Toggle relative date input for between dates"}),t.jsx(Kbe,{htmlFor:"between-relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})]}),n&&t.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[t.jsx(MLe,{id:"relative-date-switch",checked:m,onCheckedChange:k,"aria-label":"Toggle relative date input"}),t.jsx(Kbe,{htmlFor:"relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})}if(e===_5.Number||e===_5.Integer)return a===j5.EXISTS?null:t.jsx(gte,{type:"number",value:n.length>0?String(n[0]):"",onChange:e=>i([Number(e.target.value)]),className:"w-[200px]"});if(e===_5.Boolean){if(a===j5.EXISTS)return null;const e=n.length>0&&Boolean(n[0]);return t.jsx(MLe,{checked:e,onCheckedChange:e=>i([e])})}return t.jsx(gte,{value:n.length>0?String(n[0]):"",onChange:e=>i([e.target.value]),className:"w-[200px]",disabled:!0})},PLe=({condition:e,onUpdate:n,onDuplicate:i,onDelete:r,segmentsConditions:o})=>{const{toast:s}=Ve(),l=(e=>{const a=o.conditions.find((a=>a.field===e));return a||null})(e.field)||{operators:[],type:_5.String,options:void 0},u=l.operators,c=l.type,d=o.conditions.map((e=>e.field)).map((e=>({value:e,label:dLe[e]||e})));return a.useEffect((()=>{setTimeout((()=>document.body.style.pointerEvents=""),0)}),[]),t.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch gap-2 min-w-0 w-full",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 items-stretch gap-2 min-w-0 w-full",children:[t.jsx("div",{className:"flex-1 min-w-0 items-center flex",children:t.jsx(mLe,{options:d,value:e.field,onChange:a=>{const t=a,i=o.conditions.find((e=>e.field===t));if(!i)return;const r=i.operators.map((e=>({value:e,label:cLe(e,i.type),fieldType:i.type}))),s=r[0]?.value;let l=[];switch(i.type){case _5.Boolean:l=[!1];break;case _5.Number:l=[0];break;case _5.Date:case _5.DateTime:l=[new Date];break;case _5.String:l=i.options?.length?i.options.map((e=>e.displayName)):[];break;default:l=[]}n({...e,field:t,operator:s,value:l})},placeholder:"Select field",className:"w-full",disableInput:!0})}),t.jsxs("div",{className:"flex-1 min-w-0 max-w-xs flex gap-2 items-center",children:[(e.operator===j5.EQUALS_MONTH_DAY||e.operator===j5.EQUALS_MONTH_DAY_YEAR||e.operator===j5.BETWEEN_MONTH_DAY||e.operator===j5.BETWEEN_MONTH_DAY_YEAR)&&t.jsx("div",{className:"flex items-center",children:(e=>{let a;switch(e){case j5.EQUALS_MONTH_DAY:a="This operator will check if only the month and day are equal. This is useful for things like birthday, where year does not matter";break;case j5.EQUALS_MONTH_DAY_YEAR:a="This operator will check if only the month and day are equal. This is useful for things like appointment dates, where specific day and month is important but year does not matter";break;case j5.BETWEEN_MONTH_DAY:a="This operator will check if the date is between the two dates, but only checking the month and the day, not the year. This is helpful for things like birthday, where year does not matter";break;case j5.BETWEEN_MONTH_DAY_YEAR:a="This operator will check if the date is between the two dates, checking the month, day and year. This is helpful for things like appointment dates, where specific day, month and year is important";break;default:return null}return t.jsx(Fue,{title:a})})(e.operator)}),t.jsx(mLe,{options:u.map((e=>({value:e,label:e?cLe(e,c):e}))),value:e.operator,onChange:a=>n({...e,operator:a}),placeholder:"Select operator",className:"w-full",disableInput:!0})]}),t.jsx("div",{className:"flex-1 min-w-0 max-w-full overflow-x-auto",children:t.jsx(_Le,{fieldType:c,operator:e.operator,options:"string"==typeof e.value[0]&&e.value[0]&&Array.isArray(l.options)?[...(l.options||[]).map((e=>({displayName:e.displayName,id:e.id}))),...e.value.filter((e=>!l.options?.some((a=>a.id===e||a.displayName===e)))).map((e=>({displayName:e,id:e})))]:l.options?.map((e=>({displayName:e.displayName,id:e.id}))),value:e.value,onChange:a=>n({...e,value:a}),toast:s})})]}),t.jsxs("div",{className:"flex items-center flex-shrink-0 pl-2",children:[t.jsx(H5,{size:"icon",variant:"ghost",onClick:i,children:t.jsx(vz,{className:"h-4 w-4"})}),t.jsx(H5,{size:"icon",variant:"ghost",onClick:r,children:t.jsx(Yz,{className:"h-4 w-4"})})]})]})},jLe=({onSelectStyle:e})=>{const[n,i]=a.useState(null);return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 max-w-4xl mx-auto",children:[t.jsx(G5,{onClick:()=>{i("ai"),e("ai")},title:"Build with AI",subtitle:"Describe your audience in plain language and let AI create the conditions",icon:t.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:t.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:t.jsx($z,{className:"w-full h-full"})})}),selected:"ai"===n}),t.jsx(G5,{onClick:()=>{i("manual"),e("manual")},title:"Build Manually",subtitle:`Create your ${lH("engage:segment")} by configuring conditions directly`,icon:t.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:t.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:t.jsx(Gz,{className:"w-full h-full"})})}),selected:"manual"===n})]})},LLe=({segmentId:e,setOpen:a,setTextToSegment:n,promptBuilderStyle:i,textToSegment:r})=>t.jsx("div",{children:t.jsx(aY,{className:"",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(nY,{className:"text-3xl font-normal",children:e?`Edit ${lH("engage:segment")}`:`Create ${lH("engage:segment")}`}),t.jsxs("div",{className:"flex items-center gap-2",children:[!1===i&&!1===r&&t.jsx(Hie,{children:t.jsxs(Iie,{children:[t.jsx(Fie,{asChild:!0,children:t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>n(!0),children:t.jsx($z,{className:"h-4 w-3"})})}),t.jsx(Gie,{children:t.jsxs("p",{children:["Use AI to create ",lH("engage:segment")," by describing them in natural language"]})})]})}),t.jsx(H5,{variant:"ghost",size:"icon",onClick:()=>{a(!1)},className:"h-8 w-8",children:t.jsx(rO,{className:"h-4 w-4"})})]})]})})}),BLe=r.forwardRef((({className:e,...a},n)=>t.jsx("textarea",{className:XO("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...a})));BLe.displayName="Textarea";const RLe=({setTextToSegment:e,setSegment:n})=>{const[i,r]=a.useState(""),[o,s]=a.useState(!1),{toast:u}=Ve();return t.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Describe your audience"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Describe the audience you want to target in plain language, and our AI will create the conditions for you."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(wY,{children:[o&&t.jsx(s5,{children:t.jsx(lY,{})}),!o&&t.jsx(s5,{children:t.jsx(BLe,{placeholder:"Describe your target audience...",className:"min-h-[120px] resize-none",value:i,onChange:e=>r(e.target.value)})})]}),t.jsx("div",{className:"flex justify-end gap-2",children:t.jsxs(H5,{onClick:async()=>{if(!i)return void u({title:"Please enter a description",description:"Please enter a description of your target audience",variant:"destructive"});s(!0);const a=await(async e=>{const{userInput:a,userCustomVerb:t}=e;return(await Le(`${l}/text-to-segment`,{method:"POST",body:JSON.stringify({text:a,userCustomVerb:t||"user"})})).data})({userInput:i,userCustomVerb:lH("engage:user")});a.success&&a.conditions?(u({title:`${lH("engage:segment")} conditions built successfully 🚀`,description:`Your ${lH("engage:segment")} conditions have been built successfully`}),n(a.conditions)):u({title:`${lH("engage:segment")} build failed`,description:"Please try again",variant:"destructive"}),e(!1),s(!1)},children:[t.jsx($z,{className:"h-4 w-4"}),"Generate ",lH("engage:segment")]})})]})]})};function DLe({segmentId:e,setOpen:a,onSegmentUpdated:n}){const{toast:i}=Ve(),o=void 0===e,[s,l]=r.useState(!1),[u,c]=r.useState({version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[]}),{segment:d,isLoading:m}=E5(e||""),{updateSegment:h}=N5(e),{createSegment:p,isCreating:g,segmentsConditions:f}=M5(),[v,y]=r.useState(!1),[b,k]=r.useState(!!o);r.useEffect((()=>{f&&c(d?{version:"1.0",id:d.id,name:d.name,description:d.description,logic:"AND",conditions:d.conditions}:{version:"1.0",id:"",name:"",description:"",logic:"AND",conditions:[{field:f.conditions[0].field,operator:f.conditions[0].operators[0],value:[]}]})}),[d,f]);const S=e=>e.value.some((e=>"object"==typeof e&&"type"in e&&"relative"===e.type)),w=e=>e.value.some((e=>"object"==typeof e&&"startDate"in e&&"endDate"in e));if(!f||m)return t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lY,{})});return t.jsxs(t.Fragment,{children:[t.jsx(LLe,{segmentId:e,setOpen:a,setTextToSegment:y,promptBuilderStyle:b,textToSegment:v},"segment-builder-header"),b?t.jsx(s5,{children:t.jsx(jLe,{onSelectStyle:e=>{"ai"===e&&y(!0),k(!1)}})},"prompt-builder-style"):t.jsx(s5,{children:t.jsxs("div",{className:"flex flex-1 flex-col",children:[t.jsx("div",{className:"flex flex-1 flex-col px-8 py-2",children:t.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-visible",children:t.jsx(wY,{children:v?t.jsx(s5,{children:t.jsx(RLe,{setTextToSegment:y,setSegment:e=>c({...u,conditions:e})})}):t.jsxs(s5,{children:[t.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex items-center gap-0",children:[t.jsx(Kbe,{className:"text-muted-foreground text-xs",children:"Name"}),t.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),t.jsx(gte,{placeholder:`${lH("engage:segment")} name`,value:u.name,onChange:e=>c({...u,name:e.target.value})})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(Kbe,{className:"text-muted-foreground text-xs",children:"Description"}),t.jsx(gte,{placeholder:`${lH("engage:segment")} description`,value:u.description,onChange:e=>c({...u,description:e.target.value})})]})]}),u.conditions.length>0&&t.jsx("div",{className:"flex-1 overflow-y-auto pb-8",children:t.jsx("div",{className:"grid",children:t.jsx(wY,{mode:"popLayout",children:u.conditions.map(((e,a)=>t.jsxs(o5.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{type:"spring",stiffness:300,damping:30,mass:.5},children:[a>0&&t.jsxs(o5.div,{className:"relative flex items-center gap-3 py-1",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:[t.jsx(o5.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}}),t.jsx(o5.span,{className:"text-muted-foreground text-xs",initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},children:"AND"}),t.jsx(o5.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}})]}),t.jsx(PLe,{condition:e,onUpdate:e=>((e,a)=>{const t=[...u.conditions];t[e]=a,c({...u,conditions:t})})(a,e),segmentsConditions:f,onDuplicate:()=>(e=>{const a=[...u.conditions];a.splice(e+1,0,{...u.conditions[e]}),c({...u,conditions:a})})(a),onDelete:()=>(e=>{const a=u.conditions.filter(((a,t)=>t!==e));c({...u,conditions:a})})(a)})]},`${e.field}-${e.operator}-${a}`)))})})})]})})})}),t.jsx("div",{className:"border-t px-8 py-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(H5,v?{variant:"secondary",onClick:()=>y(!1),children:[t.jsx(Gz,{className:"h-4 w-4"}),"Manual Builder"]}:{variant:"secondary",onClick:()=>{c({...u,conditions:[...u.conditions,{field:f.conditions[0].field,operator:f.conditions[0].operators[0],value:[]}]})},children:[t.jsx(Kz,{className:"h-4 w-4"}),"Add Condition"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(H5,{variant:"destructive",onClick:()=>a(!1),children:"Cancel"}),t.jsx(H5,{variant:"default",onClick:async()=>{if(!u.name)return void i({title:"Name is required",description:"Please ensure all fields are filled out",variant:"destructive"});const{valid:t,error:r}=(e=>{for(const a of e){if(!a.field||!a.operator)return{valid:!1,error:"Please ensure all fields are filled out for condition"};if(a.operator!==j5.EXISTS&&0===a.value.length)return{valid:!1,error:`Please ensure a value is selected for ${a.field}`};if(a.operator===j5.EXISTS&&a.value.length>0)return{valid:!1,error:`EXISTS operator can only be used with an empty array for ${a.field}`};if(S(a)&&a.operator!==j5.EQUALS_MONTH_DAY&&a.operator!==j5.EQUALS_MONTH_DAY_YEAR)return{valid:!1,error:`Relative dates can only be used with the month and day or month, day, and year operator for ${a.field}`};if(S(a)&&void 0===a.value[0].value)return{valid:!1,error:`Please select a value for the relative date for ${a.field}`};if(w(a)&&a.operator!==j5.BETWEEN_MONTH_DAY&&a.operator!==j5.BETWEEN_MONTH_DAY_YEAR)return{valid:!1,error:`Between dates can only be used with the between month day or between month day year operator for ${a.field}`};if(w(a)&&a.value.length>1)return{valid:!1,error:`Between dates can only have a single value for ${a.field}`};if(w(a)){const e=a.value[0];if(!e.startDate||!e.endDate)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate instanceof Date&&e.endDate instanceof Date&&e.startDate>e.endDate)return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("object"==typeof e.startDate&&"type"in e.startDate&&"relative"===e.startDate.type&&"object"==typeof e.endDate&&"type"in e.endDate&&"relative"===e.endDate.type){if(!e.startDate.value||!e.endDate.value)return{valid:!1,error:`Please ensure both a start and end date are selected for ${a.field}`};if(e.startDate.direction!==e.endDate.direction)return{valid:!1,error:`Start and end date must be of the same direction for ${a.field}`};const t=e=>{if(e.unit===uLe.DAYS)return e.value??0;throw g5(e.unit,uLe)};if("before"===e.startDate.direction&&t(e.startDate)>t(e.endDate))return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("after"===e.startDate.direction&&t(e.startDate)<t(e.endDate))return{valid:!1,error:`Start date must be after end date for ${a.field}`}}}}return{valid:!0,error:void 0}})(u.conditions);if(!t)return void i({title:"Conditions are invalid",description:r??"Please ensure all fields are filled out",variant:"destructive"});const o=u.conditions.map((e=>{const a=f?.conditions.find((a=>a.field===e.field));return a?.type===_5.Date&&(e.value=e.value.map((e=>e instanceof Date?e.toISOString().split("T")[0]:e))),e}));l(!0);try{e&&d?h({name:u.name,description:u.description,conditions:o},{onSuccess:()=>{i({title:`${lH("engage:segment")} updated successfully`}),a(!1),n?.(e)},onError:()=>{i({title:`Error updating ${lH("engage:segment")}`,description:"Please try again",variant:"destructive"}),n?.("error")}}):p({name:u.name,description:u.description,conditions:u.conditions},{onSuccess:e=>{i({title:`${lH("engage:segment")} created successfully`}),n?.(e?.id??!1),a(!1)},onError:()=>{i({title:`Error creating ${lH("engage:segment")}`,description:"Please try again",variant:"destructive"}),n?.("error")}})}catch(s){i({title:`Error saving ${lH("engage:segment")}`,description:"Please try again",variant:"destructive"}),n?.("error")}finally{l(!1)}},disabled:s||g,children:s||g?t.jsxs(t.Fragment,{children:[t.jsx(Cz,{className:"mr-2 h-4 w-4 animate-spin"}),e?"Updating...":"Creating..."]}):e?"Update":"Create"})]})]})})]})},"manual-builder-style")]})}function zLe({open:e,setOpen:a,segmentId:n,onSegmentUpdated:i}){return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"flex max-h-[86vh] flex-col gap-0 overflow-visible max-w-6xl w-full",hideCloseButton:!0,children:[t.jsxs(qZ,{children:[t.jsxs(nY,{children:[lH("engage:segment")," Builder"]}),t.jsxs(iY,{children:["Build a ",lH("engage:segment")," to target your audience"]})]}),t.jsx(DLe,{segmentId:n,setOpen:a,onSegmentUpdated:e=>{i?.(e),a(!1)}})]})})}const OLe=()=>t.jsx(Fue,{title:`These are estimated numbers of ${lH("engage:user",{count:2}).toLocaleLowerCase()} that are matched. The actual count may change at the time of sending. You can see the breakdown of who have opted into email or sms.`}),KLe=({value:e,label:a,percentage:n,variant:i,isLoading:r,selected:o,onClick:s})=>t.jsxs("div",{className:`rounded-md border-2 border-muted-foreground/20 px-2 pt-2 pb-3 duration-300 ease-in-out overflow-x-auto max-w-full min-w-0 ${o?"scale-[1.02] [border-color:hsl(var(--reach-primary))] shadow-lg":""} ${s?"cursor-pointer hover:bg-gray-50/50 transition-colors":""}`,style:{containerType:"inline-size"},"data-card-container":!0,onClick:s,children:[t.jsxs("div",{className:"flex flex-col gap-1 items-start w-full min-w-0",children:[t.jsx("div",{className:"flex items-baseline gap-2 w-full min-w-0 @container/num",children:r?t.jsx("span",{className:"animate-pulse",children:"..."}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold pl-2 break-words max-w-full min-w-0 truncate\n text-xl @[250px]/card:text-2xl @[350px]/card:text-3xl @[500px]/card:text-4xl text-primary",children:e.toLocaleString()}),void 0!==n&&e.toLocaleString().replace(/,/g,"").length<5&&t.jsxs("span",{className:"text-muted-foreground/50 text-sm hidden @[120px]/num:inline",children:["(",n,"%)"]})]})}),t.jsx("span",{className:`px-2 sm:px-2.5 py-1 text-xs font-medium rounded-lg ${{default:"bg-gray-100/50 text-gray-700",blue:"bg-blue-100/50 text-blue-700",green:"bg-green-100/50 text-green-700"}[i]}`,children:a})]}),t.jsx("p",{className:"text-sm text-muted-fore hidden @[250px]/card:inline mt-1",children:1===e?"contact":"contacts"})]}),HLe=({countResponse:e,selectedFilter:n="all",onFilterChange:i})=>{const r=a.useMemo((()=>e?.recipients?e.recipients.reduce(((a,t)=>({total:e.count,emails:a.emails+(t.email?1:0),phones:a.phones+(t.phone?1:0)})),{total:0,emails:0,phones:0}):{total:0,emails:0,phones:0}),[e]),o=e=>Math.round(e/(r.total||1)*100);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(i_e,{children:"Estimated Matches"}),t.jsx(OLe,{})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 md:mb-6 w-full gap-4 mt-3 px-1",children:[t.jsx(KLe,{value:r.total,label:"Total",variant:"default",isLoading:void 0===e,selected:"all"===n,onClick:i?()=>i("all"):void 0}),t.jsx(KLe,{value:r.emails,label:"Subscribed to Email",percentage:o(r.emails),variant:"blue",isLoading:void 0===e,selected:"email"===n,onClick:i?()=>i("email"):void 0}),t.jsx(KLe,{value:r.phones,label:"Subscribed to SMS",percentage:o(r.phones),variant:"green",isLoading:void 0===e,selected:"phone"===n,onClick:i?()=>i("phone"):void 0})]})]})},ILe=e=>{const a=`${e.firstName||""} ${e.lastName||""}`.trim();return a||(e.firstName?e.firstName:e.lastName?e.lastName:e.email?e.email:e.phone?e.phone:`Unnamed ${lH("engage:user")}`)},FLe=({recipients:e,filter:a="all"})=>{const n=e?.filter((e=>{const t=!!e.email,n=!!e.phone;if(!t&&!n)return!1;switch(a){case"email":return t;case"phone":return n;default:return!0}}));return n?.length?t.jsx("div",{className:"bg-foreground/5 rounded-lg h-full relative overflow-hidden",children:t.jsx("div",{className:"absolute inset-0 w-full h-full overflow-y-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"sticky top-0 bg-foreground/5 backdrop-blur-sm",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Name"}),t.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Contact"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-200/50",children:n.map(((e,a)=>t.jsxs("tr",{className:"hover:bg-white/50 transition-colors",children:[t.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-gray-900",children:ILe(e)}),t.jsx("td",{className:"px-3 sm:px-4 py-3",children:t.jsxs("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:[e.email&&t.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-blue-100/50 text-blue-700 rounded-lg",children:"Email"}),e.phone&&t.jsx("span",{className:"px-2 sm:px-2.5 py-1 text-xs font-medium bg-green-100/50 text-green-700 rounded-lg",children:"Phone"})]})})]},a)))})]})})}):null},GLe=({onSelectionChange:e,defaultValue:n="all",canEditAudience:i=!0})=>{const[r,o]=a.useState(n),s=a=>{i&&(o(a),e?.(a))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(i_e,{children:"Filter"}),!i&&t.jsx(Fue,{title:"You cannot edit the audience unless you are in draft mode"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4 p-1",children:[t.jsx(G5,{onClick:()=>s("all"),title:`All ${lH("engage:user",{count:2})}`,subtitle:"Send to everyone",icon:t.jsx(V5.UsersIcon,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"all"===r,disabled:!i}),t.jsx(G5,{onClick:()=>s("segments"),title:`Select ${lH("engage:user",{count:2})}`,subtitle:`Choose from ${lH("engage:segment",{count:2})}`,icon:t.jsx(V5.UserEdit,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"segments"===r,disabled:!i})]})]})},VLe=({segments:e,allSegments:n,onAddSegment:i,onRemoveSegment:r,setOpenCreateSegmentDialog:o,canEditAudience:s=!0})=>{const[l,u]=a.useState([]),c=n.map((e=>({label:e.name,value:e.id})));return a.useEffect((()=>{u(e)}),[e]),t.jsx("div",{children:t.jsx(fEe,{canOpen:s,selectedValues:l,setSelectedValues:u,options:c,onValueChange:a=>{const t=a.filter((a=>!e.includes(a))),n=e.filter((e=>!a.includes(e)));t.forEach(i),n.forEach(r)},placeholder:"Select segments",maxCount:5,extraCommandItems:[e=>t.jsxs(rxe,{onSelect:()=>{e(!0),o(!0)},className:"cursor-pointer",children:[t.jsx(V5.PlusIcon,{className:"w-4 h-4"}),"New"]},"new-segment")]})})},JLe=({includedSegments:e,excludedSegments:n,handleAddSegment:i,handleRemoveSegment:r,setOpenCreateSegmentDialog:o,segments:s,defaultIsExcludeOpen:l=!1,canEditAudience:u=!0})=>{const[c,d]=a.useState(l);return t.jsxs("div",{children:[t.jsx(VLe,{segments:e,allSegments:s||[],onAddSegment:e=>i(e,"include"),onRemoveSegment:e=>r(e,"include"),setOpenCreateSegmentDialog:o}),t.jsx("div",{className:"border-t border-gray-200 my-8"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(H5,{onClick:()=>{u&&d(!c)},className:"flex items-center gap-1 transition-colors",size:"sm",children:[t.jsx(o5.div,{animate:{rotate:c?180:0},transition:{duration:.2},children:t.jsx(V5.DropdownMenuTrigger,{className:"w-5 h-5"})}),t.jsx("span",{children:"Don't send to"})]}),t.jsx(wY,{children:c&&t.jsx(o5.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeInOut"},children:t.jsx(VLe,{canEditAudience:u,segments:n,allSegments:s||[],onAddSegment:e=>i(e,"exclude"),onRemoveSegment:e=>r(e,"exclude"),setOpenCreateSegmentDialog:o})})})]})]})},ULe=({title:e="Preview Audience"})=>{const n=B5(),[i,r]=a.useState("all"),[o,s]=a.useState(n?.includeSegmentIds||[]),[l,u]=a.useState(n?.excludeSegmentIds||[]),[c,d]=a.useState(!1),[m,h]=a.useState(!1),[p,g]=a.useState("all"),{segments:f,isLoading:v}=T5(),{updateAutomation:y}=ra(n?.id??""),[b,k]=a.useState(void 0),S=1===o.length&&0===l.length&&void 0!==f?.find((e=>e.type===P5.ALL_USERS&&e.id===o[0]));a.useEffect((()=>{n&&!m&&!1===v&&(1===o.length&&void 0!==f.find((e=>e.type===P5.ALL_USERS&&e.id===o[0]))?r("all"):r("segments"),A5({includeSegments:o,excludeSegments:l}).then((e=>{k(e)})),h(!0))}),[n,S,m,o,l,f,v]);a.useEffect((()=>{n&&m&&(JSON.stringify(o)===JSON.stringify(n.includeSegmentIds)&&JSON.stringify(l)===JSON.stringify(n.excludeSegmentIds)||(y({includeSegments:o,excludeSegments:l}),A5({includeSegments:o,excludeSegments:l}).then((e=>{k(e)}))))}),[o,l,n,m,y]);const w=n?.status===ha.DRAFT;return t.jsxs(r_e,{title:e,children:[!v&&f&&m?t.jsxs("div",{className:"flex gap-8 w-full pb-4 px-4",children:[t.jsxs("div",{className:"flex flex-col flex-1 relative overflow-y-auto pb-4 [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:[t.jsx(HLe,{countResponse:b,selectedFilter:p,onFilterChange:g}),t.jsx(GLe,{onSelectionChange:e=>{if(r(e),"all"===e){const e=f?.find((e=>e.type===P5.ALL_USERS));if(!e)return;s([e.id]),u([])}},defaultValue:i,canEditAudience:w}),t.jsx(wY,{children:"segments"===i&&t.jsx(o5.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3,ease:"easeInOut"},className:"w-full pt-4",children:t.jsx(JLe,{canEditAudience:w,includedSegments:o,excludedSegments:l,handleAddSegment:(e,a)=>{"include"===a?s((a=>[...a,e])):u((a=>[...a,e]))},handleRemoveSegment:(e,a)=>{"include"===a?s((a=>a.filter((a=>a!==e)))):u((a=>a.filter((a=>a!==e))))},setOpenCreateSegmentDialog:d,segments:f,defaultIsExcludeOpen:l.length>0})})})]}),t.jsx("div",{className:"flex flex-col flex-1 relative overflow-hidden",children:b?.recipients&&t.jsx(FLe,{recipients:b.recipients,filter:p})})]}):t.jsx("div",{children:t.jsx(lY,{text:["Fetching segments","Finishing up"]})}),t.jsx(zLe,{open:c,setOpen:d,onSegmentUpdated:e=>{e&&s((a=>[...a,e]))}})]})},WLe=()=>t.jsx(ULe,{title:"Select Audience"}),qLe=({selectedChannels:e,setSelectedChannels:a,hasEmailChannelSenders:n,hasSmsChannelSenders:i,automationType:r})=>{const{toast:o}=Ve(),s=[...n?[{label:"Email",value:"email",icon:V5.EmailIcon,checked:e.includes("email")}]:[],...i?[{label:"SMS",value:"sms",icon:V5.SmsIcon,checked:e.includes("sms")}]:[]];return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-xl font-medium text-foreground",children:"Message Types"}),t.jsxs("p",{className:"text-muted-foreground mb-2 text-sm",children:["Select the channels you want to use in this"," ",r===ua.ONE_TIME?lH("engage:broadcast").toLowerCase():lH("engage:automation").toLowerCase()]})]}),t.jsx("div",{className:"w-full grid grid-cols-2 gap-3",children:s.map((n=>t.jsxs(iTe,{checked:n.checked,onCheckedChange:()=>{"email"===n.value?e.includes("email")?e.includes("sms")?a(["sms"]):o({title:"Cant Remove Email",description:`At least one channel is required for an ${r===ua.ONE_TIME?lH("engage:broadcast").toLowerCase():lH("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"email"]):e.includes("sms")?e.includes("email")?a(["email"]):o({title:"Cant Remove SMS",description:`At least one channel is required for an ${r===ua.ONE_TIME?lH("engage:broadcast").toLowerCase():lH("engage:automation").toLowerCase()}`,variant:"destructive"}):a([...e,"sms"])},className:"relative ring-[1px] ring-border rounded-lg px-4 py-3 text-start text-muted-foreground data-[state=checked]:ring-2 data-[state=checked]:ring-primary data-[state=checked]:font-medium",children:[t.jsx(n.icon,{className:"mb-3",size:20}),t.jsx("span",{className:"font-medium tracking-tight",children:n.label}),t.jsx(rTe,{className:"absolute top-2 right-2",children:t.jsx(cz,{className:"fill-primary text-primary-foreground"})})]},n.value)))})]})},$Le=()=>{const{channelSenders:e}=Jre(),{channelAccounts:n}=Fre(),i=R5(),{updateCommunicationGroup:r}=Ye(),{state:{selectedChannels:o},setSelectedChannels:s}=a.useContext(Kre),l=B5(),{data:u}=$re(),c=a.useCallback((async e=>{s(e),e.includes("email")||i?.id&&r({groupId:i?.id,params:{emailChannelSenderId:null}}),e.includes("sms")||i?.id&&r({groupId:i?.id,params:{smsChannelSenderId:null}})}),[s,r,i?.id]),d=a.useMemo((()=>Uwe({channelSenders:e?.results??[],channelAccounts:n?.results??[]})),[e?.results,n?.results]),m=a.useMemo((()=>Nle({channelSenders:e?.results??[],channelAccounts:n?.results??[],smsApplication:u})),[e?.results,n?.results,u]);if(!o||!d||!m)return t.jsx("div",{className:"flex justify-center items-center flex-1 h-full bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(lY,{text:["Fetching Content..."]})});const h=d.length>0,p=m.length>0;return t.jsx("div",{className:"flex flex-col gap-4 flex-shrink-0",children:t.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:t.jsx(qLe,{automationType:l?.triggerMetadata?.triggerType,selectedChannels:o,setSelectedChannels:c,hasEmailChannelSenders:h,hasSmsChannelSenders:p})})})};var ZLe=(e=>(e[e.SelectAudience=1]="SelectAudience",e[e.SelectSenders=2]="SelectSenders",e[e.EditEmailContent=3]="EditEmailContent",e[e.EditSmsContent=4]="EditSmsContent",e[e.Schedule=5]="Schedule",e[e.PreviewAndSend=6]="PreviewAndSend",e))(ZLe||{});const YLe="https://assets.embedreach.com/defaults/logo-placeholder-128.png",QLe="You have not uploaded a custom logo. Please make sure to double check your email before sending!",XLe=()=>{const e=B5(),t=R5(),{state:{selectedChannels:n}}=a.useContext(Kre),{data:i}=$re(),{channelSenders:r}=Jre(),{channelAccounts:o}=Fre(),s=Nle({channelSenders:r?.results??[],channelAccounts:o?.results??[],smsApplication:i}),l=a.useCallback((async a=>e?await(async e=>{const{currentStep:a,automation:t,communicationGroup:n,selectedChannels:i,smsChannelSenders:r}=e;switch(a){case ZLe.SelectAudience:return{canMove:t.includeSegmentIds.length>0,errorMessage:"Please ensure you have selected at least one segment"};case ZLe.SelectSenders:return{canMove:i.length>0,errorMessage:"Please ensure you have selected at least one channel"};case ZLe.EditSmsContent:{const e=t.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!n)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};const a=r.find((e=>e.channelSender.id===n.smsChannelSenderId));return a?n.smsMessageBody?a.smsApplication&&a.smsApplication.status!==Ele.APPROVED?{canMove:!0,errorMessage:null,warningMessage:"You will only be able to send this message once your SMS application is approved"}:{canMove:!0,errorMessage:null}:{canMove:!1,errorMessage:"Please ensure you have a text body"}:{canMove:!1,errorMessage:"Please ensure you have selected a text sender"}}case ZLe.EditEmailContent:{const e=t.actionData?.find((e=>"send_communication"===e.actionType));if(!e)return{canMove:!1,errorMessage:"Please ensure you have selected either a email communication or text communication"};if(!n)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};if(!n.emailChannelSenderId)return{canMove:!1,errorMessage:"Please ensure you have selected a email sender"};if(!n.emailHtmlBody||!n.emailSubject)return{canMove:!1,errorMessage:"Please ensure you have a email body and subject"};let a=null;return n.emailChannelSenderId&&n.emailHtmlBody&&n.emailHtmlBody.includes(YLe)&&(a=QLe),{canMove:!0,errorMessage:null,warningMessage:a}}case ZLe.Schedule:{if(!t.triggerMetadata)return{canMove:!1,errorMessage:"Please make sure to select a time to send before starting!"};if(t.triggerMetadata.triggerType!==ua.ONE_TIME)return{canMove:Boolean(t.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:null};if(!t.triggerMetadata?.scheduledAt)return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${lH("engage:broadcast")}`};if(!Boolean(t.triggerMetadata?.scheduledAt&&("now"===t.triggerMetadata.scheduledAt||"now"!==t.triggerMetadata.scheduledAt&&new Date(t.triggerMetadata.scheduledAt)>new Date)))return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${lH("engage:broadcast")}`};if(!Boolean(t.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))))return{canMove:!1,errorMessage:"Please ensure you have set a valid email or sms communication"};const e=t.triggerMetadata;return{canMove:Boolean(e.scheduledAt&&("now"===e.scheduledAt||new Date(e.scheduledAt)>new Date)&&t.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:`Please ensure you have set a valid future date for your ${lH("engage:broadcast")}`}}case ZLe.PreviewAndSend:return{canMove:!0,errorMessage:null};default:jre(a,ZLe)}})({currentStep:a,automation:e,communicationGroup:t,selectedChannels:n,smsChannelSenders:s}):{canMove:!1,errorMessage:`${lH("engage:broadcast")} not loaded`}),[e,t,n,s]);return{validateStep:l}},eBe=({onFinish:e,getExtraMergeFields:n,onBeforeSchedule:i})=>{const r=B5(),o=R5(),{updateAutomation:s}=ra(r?.id||""),{estimatedMatchesStats:l}=(e=>{const{data:t}=x5({automationId:e?.id??"",includeSegments:e?.includeSegmentIds??[],excludeSegments:e?.excludeSegmentIds??[]}),n=a.useMemo((()=>t?.recipients?t.recipients.reduce(((e,a)=>({emails:e.emails+(a.email?1:0),phones:e.phones+(a.phone?1:0)})),{emails:0,phones:0}):{emails:0,phones:0}),[t?.recipients]);return{estimatedMatches:t,estimatedMatchesStats:n}})(r??void 0),{state:{selectedChannels:u}}=a.useContext(Kre),{validateStep:c}=XLe(),[d,m]=a.useState([]),{data:h}=$re(),[p,g]=a.useState(!1),{channelSenders:f}=Jre(),{channelAccounts:v}=Fre(),{updateCommunicationGroup:y}=Ye(),b=a.useRef(!1),[k,S]=a.useState(ZLe.SelectAudience);if(a.useEffect((()=>{if(null!==r&&null!==o){const e=Nle({channelSenders:f?.results??[],channelAccounts:v?.results??[],smsApplication:h});m((({automation:e,communicationGroup:a,selectedChannels:n,smsChannelSenders:i})=>e?[{id:"audience",title:"Audience",step:1,isValid:()=>e.includeSegmentIds.length>0,content:t.jsx(Vue,{content:t.jsx(WLe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===ua.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},{id:"senders",title:"Channels",step:2,isValid:()=>0!==n.length,content:t.jsx(Vue,{content:t.jsx($Le,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===ua.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},...n.includes("email")?[{id:"edit-email-content",title:"Edit Email Content",step:3,isValid:()=>{const t=e.actionData?.find((e=>"send_communication"===e.actionType));return!!t&&!!a.emailChannelSenderId&&!(!a.emailHtmlBody||!a.emailSubject)},content:t.jsx(Vue,{content:t.jsx(Wwe,{})},"audience"),footerConfig:{backText:"",nextText:"",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],...n.includes("sms")?[{id:"edit-sms-content",title:"Edit SMS Content",step:4,isValid:()=>{const t=e.actionData?.find((e=>"send_communication"===e.actionType));return!!(t&&t.actionMetadata.communicationGroupId&&a.smsChannelSenderId&&a.smsMessageBody)},content:t.jsx(Vue,{content:t.jsx(SEe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],{id:"schedule",title:"Schedule",step:5,isValid:()=>Boolean(e.triggerMetadata?.triggerType===ua.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date)&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:t.jsx(Vue,{className:"flex-1",content:t.jsx(lLe,{})},"schedule"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}},{id:"send",title:"Send",step:6,isValid:()=>Boolean(e.triggerMetadata?.triggerType===ua.ONE_TIME&&e.triggerMetadata?.scheduledAt&&("now"===e.triggerMetadata.scheduledAt||"now"!==e.triggerMetadata.scheduledAt&&new Date(e.triggerMetadata.scheduledAt)>new Date(Date.now()+18e4))&&e.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),content:t.jsx(Vue,{className:"flex-1",content:t.jsx(s_e,{})},"send"),footerConfig:{backText:"Back",nextText:e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&"now"===e.triggerMetadata.scheduledAt?"Send Now":"Schedule",hideBack:!1,backDisabled:!1,getInfoTooltipTitle:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));if(e&&null!==e.smsApplication&&e.smsApplication?.status!==Ele.APPROVED)return"You cannot send this yet if you have selected a text channel and don't have an approved SMS application. Please save as draft and try again later."},nextDisabled:()=>{const e=i.find((e=>e.channelSender.id===a.smsChannelSenderId));return!(!a.smsChannelSenderId||e&&(null===e.smsApplication||e.smsApplication?.status===Ele.APPROVED))||null===a.smsChannelSenderId&&null===a.emailChannelSenderId}}}]:[])({automation:r,communicationGroup:o,selectedChannels:u,smsChannelSenders:e}))}}),[r,o,n,u,f?.results,v?.results,h]),a.useEffect((()=>{n&&!b.current&&n().then((e=>{o?.id&&(b.current=!0,y({groupId:o?.id,params:{extraMergeFields:e}}))}))}),[n,o,y]),!(r&&k&&o&&d.length))return t.jsx("div",{className:"flex-1 flex flex-col @container justify-center items-center h-[500px]",children:t.jsx(lY,{text:[`Fetching ${lH("engage:broadcast")} data`,"Finishing up"]})});const w=async()=>{const{canMove:a,errorMessage:t,warningMessage:n}=await c(k);a?(n&&Ge({title:n,variant:"warning"}),k===ZLe.PreviewAndSend?await(async()=>{if(null===o.emailChannelSenderId&&null===o.smsChannelSenderId)return void Ge({title:"Oops!",description:"Please select an email sender or sms sender",variant:"destructive"});const a=Nle({channelSenders:f?.results??[],channelAccounts:v?.results??[],smsApplication:h});if(o.smsChannelSenderId){const e=a.find((e=>e.channelSender.id===o.smsChannelSenderId));if(e?.smsApplication?.application&&e?.smsApplication.status!==Ele.APPROVED)return void Ge({title:"Oops!",description:"You cant schedule a communication with a pending sms application. Please save as a draft and re-try once the application is approved."})}if(i)try{const a=await i({estimatedEmailRecipients:l?.emails||0,estimatedSmsRecipients:l?.phones||0});!0===a?s({status:ha.ACTIVE},{onSuccess:()=>{Ge({title:`${lH("engage:broadcast")} scheduled!`}),e()},onError:()=>{Ge({title:"Oops!",description:"Please contact your administrator",variant:"destructive"})}}):Ge({title:"Oops!",description:a,variant:"destructive"})}catch(t){Ge({title:"Oops!",description:"An error occurred while checking scheduling conditions",variant:"destructive"})}else s({status:ha.ACTIVE}),Ge({title:`${lH("engage:broadcast")} scheduled!`}),e()})():S(k===ZLe.SelectSenders&&1===u.length&&"sms"===u[0]||k===ZLe.EditEmailContent&&1===u.length&&"email"===u[0]?k+2:k+1)):Ge({title:"Oops!",description:t,variant:"destructive"})},A=()=>{k>ZLe.SelectAudience&&S(k===ZLe.EditSmsContent&&1===u.length&&"sms"===u[0]?k-2:k-1)},C=()=>{e()};return t.jsxs("div",{className:"flex-1 flex flex-col @container h-full min-h-0",children:[t.jsxs("header",{className:"w-full flex items-center gap-4 h-16 px-6",children:[t.jsx("h1",{className:"text-xl font-bold leading-none",children:r.name}),t.jsx("div",{className:"flex items-center gap-4",children:t.jsx(a6,{variant:Lue(r.status),children:Lre({status:r.status,automationType:r.triggerType})})})]}),t.jsxs("main",{className:"flex gap-4 flex-1 min-h-0",children:[t.jsx("div",{className:"hidden @[1000px]:block",children:t.jsx("nav",{className:"space-y-0 w-50 self-start pr-6 pl-8 pt-4 ",children:d.map((e=>t.jsx("div",{className:`\n rounded-md transition-colors\n ${e.step===k?"bg-[var(--reach-secondary)] text-[var(--reach-primary-foreground)] font-medium":e.step<k?"text-muted-foreground hover:bg-muted":"text-muted-foreground/60"}\n `,children:t.jsx(d6,{label:e.title,isActive:e.step===k,isCompleted:e.isValid(),onClick:async()=>{if(!p)if(e.step>k){const{canMove:a,errorMessage:t,warningMessages:n}=await(async e=>{if(e<=k)return{canMove:!0,errorMessage:null};g(!0);try{const a=[];for(let t=k;t<e;t++){const{canMove:e,errorMessage:n,warningMessage:i}=await c(t);if(!e)return{canMove:e,errorMessage:n};i&&a.push(i)}return{canMove:!0,errorMessage:null,warningMessages:a}}finally{g(!1)}})(e.step);if(a){if(n&&n.length>0)for(const e of n)Ge({title:e,variant:"warning"});S(e.step)}else t&&Ge({title:"Cannot navigate to this step",description:t,variant:"destructive"})}else S(e.step)}})},e.step)))})}),t.jsx("section",{className:"flex-1 mr-6 w-full relative rounded-xl bg-gray-100 ml-6 @[1000px]:ml-0",children:t.jsx("div",{className:" overflow-y-auto top-0 left-0 right-0 bottom-0 flex-1 h-full flex-col flex",children:t.jsx(wY,{children:t.jsx(s5,{className:"pt-0 h-full",children:d.find((e=>e.step===k))?.content},k)})})})]}),t.jsx("footer",{className:"w-full flex justify-end shadow-md z-10 items-center h-16 px-6",children:t.jsx(Gue,{handleSkipAndSaveAsDraft:C,handleBack:A,handleNext:w,hideBack:d.find((e=>e.step===k))?.footerConfig.hideBack??!1,backText:d.find((e=>e.step===k))?.footerConfig.backText??"Back",nextText:d.find((e=>e.step===k))?.footerConfig.nextText??"Next",backDisabled:d.find((e=>e.step===k))?.footerConfig.backDisabled??!1,nextDisabled:d.find((e=>e.step===k))?.footerConfig.nextDisabled()??!1,getInfoTooltipTitle:d.find((e=>e.step===k))?.footerConfig.getInfoTooltipTitle??void 0})})]})},aBe=({children:e,actionId:n})=>{const{setActionId:i}=a.useContext(S5);return a.useEffect((()=>{i(n)}),[n,i]),t.jsx("div",{children:t.jsx(Hre,{children:e})})},tBe=()=>t.jsxs("div",{children:[t.jsx("div",{className:q5,children:t.jsx(V5.OneTimeBroadcast,{})}),t.jsx("h3",{className:$5,children:lH("engage:broadcast")}),t.jsx("p",{className:Z5,children:"Send a single message to your current list, like announcing a sale or newsletter."})]}),nBe=()=>t.jsxs("div",{children:[t.jsx("div",{className:Y5,children:"Coming Soon"}),t.jsx("div",{className:q5,children:t.jsx(V5.RealtimeActivity,{})}),t.jsx("h3",{className:$5,children:"Realtime Activity"}),t.jsx("p",{className:Z5,children:"Responds to immediate actions your contacts take, like abandoned carts, form submissions, or appointment bookings."})]}),iBe=({selectedType:e,setAutomationName:a,automationName:n,setAutomationDescription:i,automationDescription:r})=>t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 max-w-lg mx-auto",children:[t.jsxs("h2",{className:"text-2xl font-semibold mb-8 text-center",children:["Name Your"," ",lH(e===ua.ONE_TIME?"engage:broadcast":"engage:automation")]}),t.jsxs("div",{className:"w-full space-y-6",children:[t.jsx("div",{className:"bg-gray-50 p-6 rounded-xl items-center justify-center text-center",children:(()=>{switch(e){case ua.ONE_TIME:return t.jsx(tBe,{});case ua.TRIGGER_BASED:return t.jsx(nBe,{});default:throw jre(e,ua)}})()}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[t.jsx("label",{htmlFor:"automationName",className:"block text-sm font-medium text-gray-900",children:"Name"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Only visible to your team"})]}),t.jsx(gte,{id:"automationName",type:"text",value:n,onChange:e=>a(e.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500 shadow-sm",placeholder:"e.g. April Newsletter Campaign",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[t.jsx("label",{htmlFor:"automationDescription",className:"block text-sm font-medium text-gray-900",children:"Description"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Optional"})]}),t.jsx(BLe,{id:"automationDescription",value:r,onChange:e=>i(e.target.value),className:"w-full min-h-[80px] resize-none",placeholder:`Add any helpful context for your team. If left blank, we'll generate one for you when you start the ${lH("engage:broadcast").toLowerCase()}`})]})]})]})]}),rBe=({onClose:e,automationType:n,currentStep:i,setCurrentStep:r,getExtraMergeFields:o,onBeforeSchedule:s})=>{const{createAutomation:l,isCreating:u}=ia(),[c,m]=a.useState(!1),[h,p]=a.useState(void 0),[g,f]=a.useState(void 0),[v,y]=a.useState(!1),[b,k]=a.useState(n?{name:void 0,description:void 0,type:n}:{name:void 0,description:void 0,type:void 0}),S=void 0!==b.name&&void 0!==b.type&&""!==b.name;a.useEffect((()=>{if(b.type&&!b.name&&!v){const e=new Date,a=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t=e.toLocaleDateString([],{month:"long",day:"numeric"}),n=`${lH("engage:broadcast")} ${t} ${a}`,i="";k((e=>({...e,name:n,description:i}))),y(!0)}}),[b,v]);if(u||c)return t.jsx("div",{className:W5,children:t.jsx(lY,{text:[`Creating ${lH("engage:broadcast")}`,"Finishing up"]})});return t.jsxs("div",{className:$Z("relative overflow-y-auto h-full p-8",i===I5.OneTimeWizard?"max-h-[90vh]":"h-full"),children:[t.jsx(wY,{mode:"wait",children:t.jsx(s5,{className:"h-full",children:(()=>{switch(i){case I5.ChooseAutomationType:return t.jsx(Q5,{onNext:e=>{k({...b,type:e}),r(I5.SetAutomationName)}});case I5.SetAutomationName:return b.type?t.jsx(iBe,{selectedType:b.type,setAutomationName:e=>{k({...b,name:e})},automationName:b.name??"",setAutomationDescription:e=>{k({...b,description:e})},automationDescription:b.description??""}):null;case I5.OneTimeWizard:return h&&g?t.jsx(z5,{automationId:h,children:t.jsx(aBe,{actionId:g,children:t.jsx(eBe,{onFinish:()=>{e?.(h)},getExtraMergeFields:o,onBeforeSchedule:s})})}):null;default:throw g5(i,I5)}})()},i)}),i!==I5.OneTimeWizard&&t.jsx("div",{className:"pt-2",children:t.jsx(F5,{onClose:e,currentStep:i,setCurrentStep:r,isDisabled:!S,createAutomation:async()=>{if(!S||!b.name||!b.type)return;m(!0);l({name:b.name,type:b.type,description:b.description},{onSuccess:async a=>{if(a.id){const t=await(async e=>(await Le(`${d}`,{method:"POST",body:JSON.stringify(e)})).data)({}),i=p5().toString();await Re(a.id,{action:[{actionType:"send_communication",actionMetadata:{actionType:"send_communication",communicationGroupId:t.id,currentActionId:i}}]}),p(a.id),await qe({automationId:a.id,actionId:i}),n===ua.ONE_TIME?(r(I5.OneTimeWizard),f(i),m(!1)):e?.(a.id)}else e?.("error")},onError:()=>{e?.("error")},onSettled:()=>{k({name:void 0,description:void 0,type:void 0})}})},disableBackButton:void 0!==n})})]})};function oBe({open:e,setOpen:n,onClose:i,automationType:r,getExtraMergeFields:o,replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c}){const[d,m]=a.useState(r?I5.SetAutomationName:I5.ChooseAutomationType);return a.useEffect((()=>{e&&m(r?I5.SetAutomationName:I5.ChooseAutomationType)}),[e,r]),t.jsx(oY,{children:t.jsx(sY,{replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c,children:t.jsx(ZZ,{open:e,onOpenChange:n,children:t.jsxs(eY,{hideCloseButton:d===I5.OneTimeWizard,className:`flex max-h-[86vh] ${d===I5.OneTimeWizard?"max-w-[90vw]":"max-w-4xl"} flex-col gap-0 overflow-visible p-0`,children:[t.jsx(aY,{children:t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs(qZ,{children:[t.jsx(nY,{className:"text-3xl font-normal",children:"Create Automation"}),t.jsx(iY,{children:"Create a new automation to send messages to your customers."})]})})}),t.jsx(rBe,{onClose:e=>{i?.(e),n(!1)},automationType:r,currentStep:d,setCurrentStep:m,getExtraMergeFields:o})]})})})})}const sBe=({tabs:e,activeTab:n,onTabChange:i,tabsLocation:r="left",secondaryTabs:o=!1})=>{const s=a.useRef([]),[l,u]=a.useState({width:0,left:0});a.useEffect((()=>{const a=s.current[e.findIndex((e=>e.id===n))];a&&u({width:a.offsetWidth,left:a.offsetLeft})}),[n,e]);const c=e.find((e=>e.id===n));return t.jsxs("div",{className:"flex flex-col gap-4 w-full overflow-x-hidden h-full",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"relative flex items-center gap-8 "+("left"===r?"w-full justify-start":"w-full justify-center"),children:[t.jsx("div",{className:"absolute bottom-0 h-[1px] rounded-full transition-all duration-300 ease-out\n bg-gradient-to-r from-primary to-primary/90\n shadow-[0_0_8px_rgba(var(--primary-rgb),0.3)]",style:{width:`${l.width}px`,left:`${l.left}px`}}),e.map(((e,a)=>t.jsx("button",{ref:e=>s.current[a]=e,onClick:()=>i(e.id),className:$Z("relative px-7 py-3 transition-all duration-200 text-lg",n!==e.id&&"text-muted-foreground",o&&"text-sm"),children:e.label},e.id)))]})}),t.jsx("div",{className:"relative overflow-hidden flex-grow min-h-0",children:t.jsx("div",{className:"relative h-full",children:c?c.content:null})})]})},lBe=({primaryColor:e="var(--primary)"})=>{const a=e;return t.jsxs("div",{className:"space-y-4",children:[t.jsx(MCe,{children:"This is how your brand colors will look on email"}),t.jsx("div",{className:"bg-muted/50 p-6 rounded-lg w-full mx-auto border border-muted",children:t.jsxs("div",{className:"flex flex-col bg-background items-center space-y-4 max-w-md border rounded-lg mx-auto pb-8 overflow-hidden",children:[t.jsx("div",{className:"h-20 w-full -mb-10 bg-secondary"}),t.jsx("div",{className:"w-12 h-12 rounded-lg"}),t.jsxs("div",{className:"w-full space-y-3 flex flex-col items-center px-8 pb-4 max-w-sm",children:[t.jsx("div",{className:"h-2 rounded w-3/4 mx-auto bg-muted-foreground"}),t.jsx("div",{className:"h-2 bg-muted rounded w-full"}),t.jsx("div",{className:"h-2 bg-muted rounded w-2/3"}),t.jsx("div",{className:"h-2 bg-muted rounded w-2/3"})]}),t.jsx(H5,{className:"w-full max-w-[20ch]",style:{backgroundColor:a,borderColor:a},children:"Button"})]})})]})},uBe={all:["website"],content:()=>[...uBe.all,"content"],analyze:()=>[...uBe.all,"analyze"],brandSettings:()=>[...uBe.all,"brand-settings"]},cBe=async()=>(await Le("/web-presence/brand-settings",{method:"POST"})).data,dBe=({isLoading:e,brandSettings:n,onComplete:i})=>{const[r,o]=a.useState(0),s=[{text:"Analyzing your brand palette",icon:Rz},{text:"Extracting your visual identity",icon:bz},{text:"Discovering your brand personality",icon:Sz},{text:"Crafting your email style",icon:Tz},{text:"Finalizing your brand profile",icon:uz}];a.useEffect((()=>{if(!e)return;const a=setInterval((()=>{o((e=>{const t=e+1;return t>=s.length?(clearInterval(a),setTimeout((()=>{i()}),1500),e):t}))}),2500);return()=>clearInterval(a)}),[e,i,s.length]);return t.jsx(o5.div,{className:"flex flex-col items-center justify-center h-full w-full bg-background p-6",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},children:t.jsxs("div",{className:"flex flex-col items-center gap-8 max-w-2xl w-full",children:[t.jsx(o5.div,n?.logoUrl?{className:"w-24 h-24 sm:w-32 sm:h-32 flex items-center justify-center rounded-xl overflow-hidden bg-card shadow-md border",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:t.jsx("img",{src:n.logoUrl,alt:"Brand Logo",className:"max-w-full max-h-full object-contain"})}:{className:"w-24 h-24 sm:w-32 sm:h-32 rounded-xl flex items-center justify-center shadow-md border bg-primary",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:n?.brandName?t.jsx("span",{className:"text-4xl sm:text-5xl font-bold text-white",children:n.brandName.charAt(0)}):t.jsx($z,{className:"w-12 h-12 sm:w-16 sm:h-16 text-white"})}),t.jsx(o5.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-xl font-medium text-center text-foreground",children:s[r].text},`loading-${r}`),t.jsx("div",{className:"flex items-center justify-center space-x-8 sm:space-x-12",children:s.map(((e,a)=>{const n=a<=r,i=a===r;return t.jsxs(o5.div,{className:"relative flex items-center justify-center w-12 h-12 rounded-full border-2 "+(n?"bg-card shadow-md border-primary":"bg-muted border-muted-foreground/30"),initial:{scale:.8,opacity:.5},animate:{scale:i?1.1:1,opacity:n?1:.5},transition:{duration:.3},children:[t.jsx(e.icon,{className:"w-5 h-5 "+(n?"text-primary":"text-muted-foreground")}),i&&t.jsx(o5.div,{className:"absolute inset-0 rounded-full border-2 border-primary",initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]},`step-${a}`)}))}),t.jsx(o5.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8,duration:.6},className:"w-full",children:t.jsx("div",{className:"h-[140px] w-full max-w-lg mx-auto p-5 bg-gradient-to-br from-card/70 to-card/40 backdrop-blur-md rounded-2xl border border-border/60 shadow-lg",children:t.jsxs("div",{className:"h-full flex flex-col justify-center",children:[0===r&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80 text-center",children:"Extracted Color Palette"}),t.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[n?.primaryColor,...n?.secondaryColors||[]]?.slice(0,4).map(((e,a)=>t.jsx("div",{className:"flex flex-col items-center gap-1",children:t.jsx("div",{className:"w-10 h-10 rounded-xl border-2 border-white/50 shadow-md",style:{backgroundColor:e}})},a)))}),t.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"Brand colors identified"})]}),1===r&&t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Identity"}),n?.brandName?t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-xl font-bold",children:n.brandName}),n.brandTagline&&t.jsxs("div",{className:"text-sm text-muted-foreground italic px-4",children:['"',n.brandTagline,'"']}),t.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Visual identity extracted"})]}):t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Extracting brand elements..."})]}),2===r&&t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Personality"}),n?.brandPersonality?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-center gap-4",children:[n.brandPersonality.tone&&t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Tone"}),t.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:n.brandPersonality.tone})]}),n.brandPersonality.voice&&t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Voice"}),t.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:n.brandPersonality.voice})]})]}),n.brandPersonality.values&&n.brandPersonality.values.length>0&&t.jsx("div",{className:"flex justify-center gap-1 flex-wrap",children:n.brandPersonality.values.slice(0,3).map(((e,a)=>t.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full",children:e},a)))})]}):t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand tone and voice..."})]}),3===r&&t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Email Template Preview"}),t.jsxs("div",{className:"bg-background/60 rounded-lg p-3 border border-border/30",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-4 h-4 rounded"}),t.jsx("div",{className:"text-xs font-medium text-foreground",children:n?.brandName||"Your Brand"})]}),t.jsxs("div",{className:"text-xs text-muted-foreground text-left",children:["Email styling applied with your brand colors",n?.brandPersonality?.tone&&`, ${n.brandPersonality.tone} tone`,", and visual identity"]})]})]}),4===r&&t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Kit Complete"}),t.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[t.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Identity"}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:n?.brandName?"✓":"—"})]}),t.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Colors"}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:n?.primaryColor?"✓":"—"})]}),t.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Personality"}),t.jsx("div",{className:"text-sm font-medium text-foreground",children:n?.brandPersonality?.tone?"✓":"—"})]})]})]}),(0===r&&!n?.primaryColor&&!n?.colorPalette||1===r&&!n?.brandName||2===r&&!n?.brandPersonality)&&t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand data..."}),t.jsx("div",{className:"flex justify-center gap-1 mt-2",children:[...Array(3)].map(((e,a)=>t.jsx(o5.div,{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/50",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:1,repeat:1/0,delay:.2*a}},a)))})]})]})})},`content-${r}`)]})})},mBe=({setAutoParse:e,onBrandSettingsGenerated:n})=>{const{data:i,updateWebsite:r,isUpdatingWebsite:o}=xwe(),s=be({mutationFn:cBe,mutationKey:uBe.brandSettings(),onSuccess:()=>{Ge({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})},onError:()=>{Ge({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}}),[l,u]=a.useState(i?.website||""),[c,d]=a.useState(!1),[m,h]=a.useState(null),[p,g]=a.useState(!1);return t.jsxs("div",{className:"flex flex-col pt-4 pb-12",children:[t.jsx("div",{className:"flex-1 flex flex-col",children:t.jsx("div",{className:"flex-1 p-4 space-y-4",children:t.jsxs(wY,{mode:"wait",children:[!p&&t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"h-full flex flex-col",children:t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 space-y-8",children:[t.jsxs("div",{className:"space-y-2 w-full max-w-md",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Your Website URL"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center",children:[t.jsx(gte,{type:"url",value:l,onChange:e=>u(e.target.value),placeholder:"https://example.com",className:"flex-1",disabled:!c}),t.jsx(wY,{mode:"wait",children:c?t.jsxs(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2",children:[t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>{d(!1),u(i?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),t.jsx(H5,{size:"sm",onClick:async()=>{try{r(l),d(!1)}catch(e){}},disabled:o||!l,className:"w-full sm:w-auto",children:o?t.jsx(lY,{}):"Save Changes"})]},"save"):t.jsx(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>d(!0),className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl",children:[t.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[t.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"What we'll analyze"}),t.jsxs("ul",{className:"text-sm text-gray-600 space-y-1",children:[t.jsx("li",{children:"• Your brand colors and color palette"}),t.jsx("li",{children:"• Your logo (if detectable)"}),t.jsx("li",{children:"• Your brand name and tagline"}),t.jsx("li",{children:"• Your brand's tone and personality"})]})]}),t.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[t.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"How it helps you"}),t.jsx("p",{className:"text-sm text-gray-600",children:"Our AI will automatically extract your brand assets to create consistently styled emails that match your website. This helps maintain brand recognition and professionalism in all your communications."})]})]}),t.jsx(o5.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground max-w-md text-center",children:"We'll use AI to analyze your website and extract your brand elements to create perfectly matched email templates."})]})},"url-confirmation"),p&&m&&t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"h-full",children:t.jsx(dBe,{isLoading:p,brandSettings:m,onComplete:()=>{g(!1),Ge({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})}})},"analyzing"),p&&!m&&t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"my-12 h-full flex flex-col items-center justify-center",children:t.jsxs(o5.div,{className:"flex flex-col items-center gap-8",initial:{backgroundPosition:"0% 0%"},animate:{backgroundPosition:"100% 100%"},transition:{duration:5,repeat:1/0,repeatType:"reverse"},children:[t.jsxs(o5.div,{className:"relative w-24 h-24 flex items-center justify-center",initial:{scale:.9},animate:{scale:1},transition:{scale:{duration:2,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}},children:[t.jsx(Iz,{className:"w-12 h-12 text-primary drop-shadow-md"}),t.jsx(o5.div,{className:"absolute inset-0 rounded-full border-2",style:{borderColor:"var(--primary)"},initial:{scale:.8,opacity:0},animate:{scale:2.5,opacity:[0,.8,0]},transition:{duration:3,repeat:1/0,ease:"easeOut",repeatType:"loop"}})]}),t.jsxs("div",{className:"space-y-2 pt-16 text-center",children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Analyzing your website"}),t.jsx(wY,{mode:"wait",children:t.jsx(o5.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-muted-foreground/50 max-w-md",children:"Generating your brand's unique visual identity and personality"},"loading-message")})]})]})},"pre-analyzing")]})})}),!p&&t.jsxs(tY,{className:"text-center sm:justify-center",children:[t.jsx(H5,{variant:"outline",onClick:()=>{e(!1)},className:"gap-1",children:"Go Back"}),t.jsxs(H5,{onClick:async()=>{try{g(!0);const e=await s.mutateAsync();h(e),n&&n(e)}catch(e){g(!1),h(null),Ge({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}},disabled:!l||s.isPending,className:"gap-1",children:[t.jsx($z,{className:"h-4 w-4 text-amber-500"}),s.isPending?t.jsx(lY,{}):"Analyze Website"]})]})]})},hBe=()=>{const{data:e,updateWebsite:n,isUpdatingWebsite:i}=xwe(),[r,o]=a.useState(e?.website||""),[s,l]=a.useState(!1),{toast:u}=Ve();return t.jsx("div",{className:"w-full h-full flex flex-col bg-background rounded-lg",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t.jsx(wY,{mode:"wait",children:t.jsx(o5.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col h-full",children:t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center space-y-8",children:t.jsx("div",{className:"space-y-2 w-full max-w-lg",children:t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center h-full",children:[t.jsx(gte,{type:"url",value:r,onChange:e=>o(e.target.value),placeholder:"https://example.com",className:"flex-1 m-1",disabled:!s}),t.jsx(wY,{mode:"wait",children:s?t.jsxs(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2 items-center",children:[t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>{l(!1),o(e?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),t.jsx(H5,{size:"sm",onClick:async()=>{if(Ale.string().url().safeParse(r).success)try{n(r,{onSuccess:()=>{l(!1)}})}catch(e){}else u({title:"Invalid website URL",description:"Please enter a valid website URL (e.g. including http://)",variant:"destructive"})},disabled:i||!r,className:"w-full sm:w-auto",children:i?t.jsx(lY,{}):"Save Changes"})]},"save"):t.jsx(o5.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:t.jsx(H5,{variant:"outline",size:"sm",onClick:()=>{l(!0)},className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})})})},"url-confirmation")})})})},pBe=({setAutoParse:e})=>{const{isLoading:a}=xwe();return t.jsxs("div",{className:"p-6 rounded-xl border-[5px] bg-background flex flex-col gap-3",style:{border:"5px solid transparent",background:"linear-gradient(white, white) padding-box, linear-gradient(164.56deg, rgba(152,194,255,0.6) 1%, rgba(194,177,231,0.6) 99%) border-box"},children:[t.jsxs("div",{className:"px-1 flex flex-col gap-3",children:[t.jsx("h3",{className:"font-medium text-sm leading-none",children:"Automatically add your brand to your emails"}),t.jsx("p",{className:"text-sm text-muted-foreground font-normal leading-none",children:"How your brand expresses itself in communication"})]}),t.jsxs("div",{className:"flex gap-4 items-center",children:[t.jsx(hBe,{}),t.jsxs(H5,{type:"button",onClick:async()=>{e(!0)},disabled:a,className:"flex gap-1 items-center",children:[t.jsx($z,{className:"h-4 w-4 text-amber-500"}),`${NMe}`]})]})]})},gBe=Ale.object({brandName:Ale.string().min(1,"Brand name is required"),logoUrl:Ale.string().optional(),logoBase64:Ale.string().optional(),primaryColor:Ale.string().regex(/^#[0-9A-F]{6}$/i,"Invalid color format")}),fBe=["#000000","#2563eb","#059669","#dc2626","#9333ea","#ea580c","#0891b2","#be123c","#4338f5","#16a34a"],vBe=a.forwardRef((({onSubmit:e,defaultValues:n},i)=>{const r=a.useRef(null),[o,s]=a.useState(n?.logoUrl||null),[l,u]=a.useState(null),[c,d]=a.useState(null),[m,h]=a.useState(!1),p=yCe({resolver:iMe(gBe),defaultValues:{brandName:n?.brandName||"",logoUrl:n?.logoUrl||"",primaryColor:n?.primaryColor||fBe[0]},mode:"onBlur"});a.useEffect((()=>{if(n&&null===c){const e={brandName:n.brandName||"",logoUrl:n.logoUrl||"",primaryColor:n.primaryColor||fBe[0]};p.reset(e),d(e),s(n.logoUrl||null)}}),[n,p,c]);const g=e=>{u(null);const a=e.target.files?.[0];if(a){if(!["image/png","image/jpeg"].includes(a.type))return void u("Only PNG and JPEG files are supported. Please upload a valid image.");const e=new FileReader;e.onloadend=()=>{const a=e.result;s(a),p.setValue("logoBase64",IMe(a))},e.readAsDataURL(a)}},f=async a=>{await e(a)};return a.useImperativeHandle(i,(()=>({submit:()=>{p.handleSubmit(f)()},isDirty:()=>{if(!c)return!1;const e=p.getValues();return e.brandName!==c.brandName||e.logoUrl!==c.logoUrl||e.primaryColor!==c.primaryColor}}))),t.jsxs(t.Fragment,{children:[!1===m&&t.jsx("div",{className:"px-8 pt-8",children:t.jsx(pBe,{setAutoParse:h})}),m?t.jsx("div",{className:"px-8",children:t.jsx(mBe,{setAutoParse:h,onBrandSettingsGenerated:e=>{h(!1),p.setValue("brandName",e.brandName||""),p.setValue("logoBase64",e.logoUrl?IMe(e.logoUrl):""),p.setValue("primaryColor",e.primaryColor||fBe[0]),s(e.logoUrl||null)}})}):t.jsx(bCe,{...p,children:t.jsxs("form",{onSubmit:p.handleSubmit(f),className:"space-y-6 p-8",children:[t.jsx(SCe,{control:p.control,name:"brandName",render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Brand Name"}),t.jsx(TCe,{children:t.jsx(gte,{placeholder:"Enter your brand name",...e})}),t.jsx(xCe,{})]})}),t.jsx(SCe,{control:p.control,name:"logoUrl",render:()=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Brand Logo"}),t.jsx(TCe,{children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-dashed border-border flex items-center justify-center bg-muted overflow-hidden",children:o?t.jsx("img",{src:o,alt:"Brand logo preview",className:"w-full h-full object-contain"}):t.jsx(eO,{className:"h-8 w-8 text-muted-foreground"})}),t.jsxs("div",{className:"flex flex-col gap-2 max-w-xs w-full",children:[t.jsx("input",{type:"file",ref:r,onChange:g,accept:"image/png, image/jpeg",className:"hidden"}),t.jsxs(H5,{type:"button",variant:"outline",onClick:()=>r.current?.click(),disabled:p.formState.isSubmitting,children:[t.jsx(eO,{className:"w-4 h-4 mr-2"}),"Upload Logo"]}),t.jsx("span",{className:"text-xs text-muted-foreground mt-1 break-words whitespace-normal",children:"Upload a square PNG or JPEG (min. 100×100px) with white or transparent background for best results"}),l&&t.jsx("span",{className:"text-xs text-destructive mt-1",children:l})]})]})}),t.jsx(xCe,{})]})}),t.jsx(SCe,{control:p.control,name:"primaryColor",render:({field:e})=>{const a=e.value||p.getValues("primaryColor");return t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Primary Color"}),t.jsx(TCe,{children:t.jsxs("div",{className:"flex-1 max-w-xs space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Rz,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),t.jsx(gte,{type:"text",value:a,onChange:a=>e.onChange(a.target.value),className:"font-mono text-sm pl-10 pr-12",placeholder:fBe[3],disabled:p.formState.isSubmitting}),t.jsx("input",{type:"color",value:a,onChange:a=>e.onChange(a.target.value),className:"sr-only",disabled:p.formState.isSubmitting,id:"colorPicker"}),t.jsx(H5,{variant:"ghost",size:"sm",onClick:()=>document.getElementById("colorPicker")?.click(),className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-6 h-6 rounded-sm border border-border cursor-pointer hover:border-border/80 transition-colors",style:{backgroundColor:a},disabled:p.formState.isSubmitting})]}),t.jsx("div",{className:"flex gap-3 flex-wrap",children:fBe.map((n=>t.jsx(H5,{type:"button",variant:"ghost",size:"sm",className:"w-4 h-4 p-0 rounded-full border "+(a===n?"ring-2 ring-gray-400":""),style:{backgroundColor:n},onClick:()=>e.onChange(n),disabled:p.formState.isSubmitting},n)))})]})}),t.jsx(xCe,{})]})}}),t.jsx(lBe,{primaryColor:p.watch("primaryColor")})]})})]})}));vBe.displayName="BrandSettingsForm";const yBe=()=>{const{data:e}=xwe();return{brandDefaults:{brandName:e?.branding?.brandName||e?.name,brandTagline:e?.branding?.brandTagline,logoUrl:e?.branding?.logoUrl,primaryColor:e?.branding?.primaryColor,secondaryColors:e?.branding?.secondaryColors,brandPersonality:e?.branding?.brandPersonality},businessDefaults:{company:{name:e?.name||"",website:e?.website||"",address1:"",address2:"",city:"",stateProvince:"",zipCode:"",country:"US"},contact:{firstName:"",lastName:"",email:"",phoneNumber:""}},meResponse:e}},bBe=()=>{const{toast:e}=Ve(),{updateBrandSettings:a,updateBusinessSettings:t}=xwe(),{updateChannelSender:n}=Ure(),{channelSenders:i}=Jre(),{channelAccounts:r}=Fre();return{handleBrandSubmit:async(t,n)=>{try{a({brandName:t.brandName,primaryColor:t.primaryColor,logoUrl:t.logoUrl,logoBase64:t.logoBase64},{onSuccess:()=>{n?.()}})}catch(i){e({title:"Failed to save brand settings",description:"Please try again",variant:"destructive"})}},handleBusinessSubmit:async(a,n)=>{try{t(a,{onSuccess:()=>{n?.()}})}catch(i){e({title:"Failed to save business settings",description:"Please try again",variant:"destructive"})}},handleEmailSubmit:async(a,t)=>{try{const o=Uwe({channelSenders:i?.results??[],channelAccounts:r?.results??[]}).find((e=>e.channelSenderId===a.channelSenderId));if(!o)return;n({toUpdate:{channelSenderMetadata:{...o.channelSender.channelSenderMetadata,emailReplyTo:a.replyToEmail,emailFromName:a.displayName}},id:o.channelSender.id},{onSuccess:()=>{e({title:"Email channel settings saved 🚀"}),t?.()},onError:()=>{e({title:"Failed to save email channel settings",description:"Please try again",variant:"destructive"})}})}catch(o){e({title:"Failed to save email channel settings",description:"Please try again",variant:"destructive"})}},handleSMSSubmit:async a=>{try{await new Promise((e=>setTimeout(e,500))),e({title:"SMS channel settings saved 🚀"}),a?.()}catch(t){e({title:"Failed to save SMS channel settings",description:"Please try again",variant:"destructive"})}}}},kBe=a.createContext(null),SBe=()=>{const e=a.useContext(kBe);if(!e)throw new Error("useEngageSettingsContext must be used within EngageSettingsProvider");return e},wBe=({isOnboarding:e=!1,onNext:n,onBack:i,title:r,description:o})=>{const{navigation:s}=SBe(),{isUpdatingBrandSettings:l,isLoading:u}=xwe(),{brandDefaults:c}=yBe(),{handleBrandSubmit:d}=bBe(),m=a.useContext(BCe),h=a.useRef(null),p=n||m?.goToNextStep||s?.goToNextStep||(()=>{});return t.jsx(QCe,{title:r||(e?gMe:dMe),description:o||(e?"Add your logo, colors, and brand voice to match your identity across all communication.":"Configure your brand identity and visual elements."),onBack:i||m?.goToPreviousStep||s?.goToPreviousStep||(()=>{}),onNext:()=>h.current?.submit(),isSubmitting:l,submitLabel:e?void 0:"Save",mode:e?"onboarding":"settings",children:u?t.jsx("div",{className:"flex justify-center items-center h-full py-10",children:t.jsx(lY,{})}):t.jsx(vBe,{ref:h,onSubmit:a=>d(a,e?p:void 0),defaultValues:c})})},ABe=({schema:e,defaultValues:a,onSubmit:t})=>{const{toast:n}=Ve(),i=yCe({resolver:iMe(e),defaultValues:a,mode:"onSubmit",reValidateMode:"onSubmit"});return{form:i,handleSubmit:i.handleSubmit((async e=>{try{await t(e)}catch(a){throw n({title:"Validation Error",description:a instanceof Error?a.message:"Please check your inputs",variant:"destructive"}),a}})),isSubmitting:i.formState.isSubmitting,errors:i.formState.errors}};var CBe=(e=>(e.STANDARD="standard",e))(CBe||{});const MBe=Ale.object({type:Ale.literal("standard"),company:Ale.object({name:Ale.string().describe("The legal name of the company"),address1:Ale.string().optional(),address2:Ale.string().optional(),city:Ale.string().optional(),stateProvince:Ale.string().optional(),zipCode:Ale.string().optional(),country:Ale.string().length(2).optional()})}),TBe=Ale.discriminatedUnion("type",[MBe]),xBe=({isOnboarding:e=!1,onNext:n,onBack:i,onSkip:r,title:o,description:s,showPrefilled:l=!1,prefilledData:u})=>{const{navigation:c}=SBe(),{isUpdatingBusinessSettings:d}=xwe(),{businessDefaults:m}=yBe(),{handleBusinessSubmit:h}=bBe(),p=a.useContext(BCe),g=n||p?.goToNextStep||c?.goToNextStep||(()=>{});return t.jsx(QCe,{title:o||(e?fMe:mMe),description:s||(e?"Configure your business information for SMS toll-free number registration.":"Provide your business details and authorized representative information."),onBack:i||p?.goToPreviousStep||c?.goToPreviousStep||(()=>{}),onNext:()=>{const e=document.querySelector("form");e?.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))},onSkip:r,isSubmitting:d,submitLabel:e?void 0:"Save",mode:e?"onboarding":"settings",children:t.jsxs("div",{className:"space-y-4",children:[l&&u&&t.jsx(NBe,{}),t.jsx(EBe,{onSubmit:a=>h(a,e?g:void 0),defaultValues:u||m})]})})},EBe=({onSubmit:e,defaultValues:a,context:n="email"})=>{const{form:i,handleSubmit:r}=ABe({schema:TBe,defaultValues:{type:CBe.STANDARD,company:{name:a?.company?.name||"",address1:a?.company?.address1||"",address2:a?.company?.address2||"",city:a?.company?.city||"",stateProvince:a?.company?.stateProvince||"",zipCode:a?.company?.zipCode||"",country:a?.company?.country||""}},onSubmit:e});return t.jsx(bCe,{...i,children:t.jsxs("form",{onSubmit:r,className:"space-y-6 p-8",children:[t.jsx(ZCe,{title:"",children:t.jsx(LMe,{control:i.control,context:n})}),t.jsx(H5,{type:"submit",className:"sr-only",children:"Submit"})]})})},NBe=()=>t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4 mx-auto",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(tz,{className:"w-5 h-5 text-primary flex-shrink-0 mt-0.5"}),t.jsx("p",{className:"text-primary text-sm text-left",children:"Your business information has been automatically filled from your account settings. You can review and edit these details if needed."})]})}),_Be=Ale.object({displayName:Ale.string().min(1,"Display name is required"),channelSenderId:Ale.string().min(1,"Channel sender is required"),replyToEmail:Ale.string().email("Please enter a valid email address")}),PBe=({onSubmit:e})=>{const{channelSenders:n,isLoading:i}=Jre(),{channelAccounts:r,isLoading:o}=Fre(),s=a.useRef(!1),{form:l,handleSubmit:u}=ABe({schema:_Be,defaultValues:{channelSenderId:"",displayName:"",replyToEmail:""},onSubmit:e}),c=a.useMemo((()=>Uwe({channelSenders:n?.results??[],channelAccounts:r?.results??[]})),[n?.results,r?.results]),d=a.useMemo((()=>c.map((e=>({value:e.channelSenderId,label:e.fullDomain,description:e.channelSender.channelSenderMetadata.emailReplyTo||"No reply-to set"})))),[c]);return a.useEffect((()=>{if(c.length>0&&!s.current){s.current=!0;const e=c[0],{emailFromName:a,emailReplyTo:t}=e.channelSender.channelSenderMetadata;l.reset({channelSenderId:e.channelSenderId,displayName:a||"",replyToEmail:t||""})}}),[c,l]),a.useEffect((()=>{const e=l.watch(((e,{name:a})=>{if("channelSenderId"===a&&e.channelSenderId&&s.current){const a=c.find((a=>a.channelSenderId===e.channelSenderId));if(a){const{emailFromName:e,emailReplyTo:t}=a.channelSender.channelSenderMetadata;e&&l.setValue("displayName",e),t&&l.setValue("replyToEmail",t)}}}));return()=>e.unsubscribe()}),[c,l]),i||void 0===n||o||void 0===r?t.jsx("div",{className:"flex justify-center items-center h-full py-10",children:t.jsx(lY,{})}):t.jsx(bCe,{...l,children:t.jsxs("form",{onSubmit:u,className:"space-y-6 p-8",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{children:"Account Email"}),t.jsx(Fue,{title:"This is the address your recipients will see as the sender of the email.",size:"small"})]}),t.jsx($Ce,{control:l.control,name:"channelSenderId",label:"",placeholder:"Select a sender",options:d})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{children:"Display Name"}),t.jsx(Fue,{title:"This is the name that appears in the 'From' field alongside your sender email.",size:"small"})]}),t.jsx(qCe,{control:l.control,name:"displayName",label:"",placeholder:"Name that appears in the From field"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Kbe,{children:"Reply-to Email"}),t.jsx(Fue,{title:"Replies from recipients will go to this email address. It can be different from the default sender address.",size:"small"})]}),t.jsx(qCe,{control:l.control,name:"replyToEmail",label:"",placeholder:"Replies from recipients will go to this email",type:"email"})]}),t.jsx(H5,{type:"submit",className:"sr-only",children:"Submit"})]})})},jBe=({isOnboarding:e=!1,onNext:n,onBack:i,title:r,description:o})=>{const{navigation:s}=SBe(),{handleEmailSubmit:l}=bBe(),{isUpdating:u}=Ure(),c=a.useContext(BCe),d=n||c?.goToNextStep||s?.goToNextStep||(()=>{});return t.jsx(QCe,{title:r||(e?vMe:hMe),description:o||(e?"Configure your email settings to ensure proper delivery and branding of your email communications.":"Configure your email sending settings and preferences."),onBack:i||c?.goToPreviousStep||s?.goToPreviousStep||(()=>{}),onNext:()=>{const e=document.querySelector("form");e?.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))},isSubmitting:u,submitLabel:e?void 0:"Save",mode:e?"onboarding":"settings",children:t.jsx(PBe,{onSubmit:a=>l(a,e?d:void 0)})})},LBe=({hideSubmitButton:e=!1,formRef:n,onNeedsApplicationChange:i,onApplicationSubmit:r,onFormVisibilityChange:o})=>{const[s,l]=a.useState(null),{channelSenders:u}=Jre(),{channelAccounts:c}=Fre(),{data:d}=$re(),m=Nle({channelSenders:u?.results??[],channelAccounts:c?.results??[],smsApplication:d});a.useEffect((()=>{if(null!==s||void 0===c||void 0===u)return;m.some((e=>e.smsApplication?.status===Ele.APPROVED||null===e.smsApplication))?(l({sender:m}),i?.(!1)):(l(!1),i?.(!0))}),[m,s,c,u,i]);const h={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}};if(null===s)return t.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:t.jsx(lY,{})});const p=m.some((e=>e.smsApplication?.status===Ele.APPROVED));return t.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:s?t.jsxs(o5.div,{initial:"hidden",animate:"visible",exit:"exit",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1],staggerChildren:.1}},exit:{opacity:0,y:-20,transition:{duration:.3,ease:[.4,0,1,1]}}},className:XO("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl gap-3 mx-auto bg-background"),children:[t.jsx(o5.div,{variants:h,className:"w-16 h-16 rounded-xl flex items-center justify-center bg-primary/10",children:t.jsx(V5.SmsIcon,{className:"text-primary"})}),t.jsx(o5.h2,{variants:h,className:"text-lg font-medium text-foreground",children:"SMS Sending Number Active"}),t.jsx(o5.div,{variants:h,className:"max-w-xl mx-auto",children:t.jsx("p",p?{className:"text-sm font-normal text-muted-foreground mb-2",children:"Your SMS sending number has been verified and is ready to use. You can now create and send SMS campaigns!"}:{className:"text-sm font-normal text-muted-foreground mb-2",children:"You already have a valid SMS sending number and it is ready to use. You can create and send SMS campaigns!"})}),t.jsxs(o5.div,{variants:h,className:"flex flex-col items-center w-full gap-4",children:[t.jsxs("span",{className:"inline-flex items-center px-4 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-800 font-medium text-base mb-2",children:[t.jsx("span",{className:"w-2 h-2 bg-blue-500 rounded-full mr-2"}),"Ready to send"]}),t.jsx("div",{className:"w-full flex flex-col gap-3 max-w-md mx-auto",children:m.map((e=>{const a=!!e.channelSender.channelSenderMetadata.friendlyName?.toLowerCase().includes("pending approval"),n=e.channelSender.channelSenderMetadata.friendlyName||e.channelSender.channelSenderMetadata.from||"Unknown Number";return t.jsxs("div",{className:XO("flex items-center justify-between rounded-xl px-4 py-3 border shadow-sm",a?"bg-gray-50 border-gray-200 text-gray-500":"bg-blue-50 border-blue-200 text-blue-900 font-semibold"),children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a?t.jsx(V5.AlertCircleIcon,{className:"w-5 h-5 text-yellow-500 shrink-0"}):t.jsx(V5.CheckIcon,{className:"w-5 h-5 text-blue-500 shrink-0"}),t.jsx("span",{className:"truncate",title:n,children:n})]}),!a&&e.channelSender.channelSenderMetadata.from&&e.channelSender.channelSenderMetadata.friendlyName!==e.channelSender.channelSenderMetadata.from&&t.jsx("span",{className:"font-mono text-xs text-blue-700 ml-2",children:e.channelSender.channelSenderMetadata.from})]},e.channelSender.id)}))})]})]}):t.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:t.jsx(zMe,{hideSubmitButton:e,formRef:n,onApplicationSubmit:r,onFormVisibilityChange:o})})})},BBe=({isOnboarding:e=!1,onNext:n,onBack:i,title:r,description:o})=>{const{navigation:s}=SBe(),{handleSMSSubmit:l}=bBe(),{createSmsRegistrationApplication:u,isCreating:c}=Zre(),{toast:d}=Ve(),m=a.useRef(null),[h,p]=a.useState(!1),[g,f]=a.useState(!1),[v,y]=a.useState(!1),b=a.useContext(BCe),k=n||b?.goToNextStep||s?.goToNextStep||(()=>{});return t.jsx(QCe,{title:r||(e?yMe:pMe),description:o||(e?"Set up your SMS provider to start sending personalized messages to your customers.":"Configure your SMS sending settings and preferences."),onBack:i||b?.goToPreviousStep||s?.goToPreviousStep||(()=>{}),onNext:async()=>{if(h&&g&&m.current)m.current.submit();else{y(!0);try{await l(e?k:void 0)}finally{y(!1)}}},submitLabel:h&&g?e?void 0:"Submit for approval":e?void 0:"Save",isSubmitting:h&&g?c:v,mode:e?"onboarding":"settings",children:t.jsx(LBe,{hideSubmitButton:!0,formRef:m,onNeedsApplicationChange:p,onApplicationSubmit:async a=>{try{await u({application:a,onSuccess:()=>{d({title:"SMS application submitted 🚀",description:"Your application has been submitted for approval."}),e&&k()}})}catch(t){d({title:"Failed to submit SMS application",description:"Please try again",variant:"destructive"})}},onFormVisibilityChange:f})})},RBe=()=>{const{open:e,setOpen:a,currentStep:n,navigation:i}=SBe();return t.jsx(UCe,{open:e,onOpenChange:e=>{e||a(!1)},title:sMe,description:lMe,sidebarItems:PMe,currentStep:n,onStepChange:i.goToStep,completedSteps:[],mode:"settings",showSidebar:!0,className:"max-w-4xl h-[80vh]",children:{[oMe.BRAND]:t.jsx(wBe,{}),[oMe.BUSINESS]:t.jsx(xBe,{}),[oMe.EMAIL]:t.jsx(jBe,{}),[oMe.SMS]:t.jsx(BBe,{})}[n]||null})},DBe=({children:e,open:a,setOpen:n})=>{const{navigation:i}=RCe({config:{steps:PMe,initialStep:oMe.BRAND},onClose:()=>n(!1)});return t.jsx(kBe.Provider,{value:{open:a,setOpen:n,currentStep:i.currentStep,navigation:i},children:e})},zBe=a.createContext(void 0),OBe=()=>{const e=a.useContext(zBe);if(!e)throw new Error("useEngageOnboardingContext must be used within EngageOnboardingProvider");return e},KBe=[oMe.SPLASH,oMe.BRAND,oMe.EMAIL,oMe.BUSINESS,oMe.BUSINESS_SKIP_INTERSTITIAL,oMe.SMS_INTERSTITIAL,oMe.SMS,oMe.COMPLETION],HBe=()=>{const{onClose:e}=OBe(),[t,n]=a.useState(!1),[i,r]=a.useState(!1),o=a.useMemo((()=>KBe.filter((e=>!(e===oMe.SMS&&t||e===oMe.SMS_INTERSTITIAL&&t||e===oMe.BUSINESS_SKIP_INTERSTITIAL&&i)))),[t,i]),s=a.useMemo((()=>({steps:o.map((e=>({key:e,label:e}))),initialStep:oMe.SPLASH,mode:ECe})),[o]),{navigation:l}=RCe({config:s,onClose:e}),u=a.useCallback((e=>{e===oMe.BUSINESS&&i&&r(!1),l.goToStep(e)}),[i,l]),c=a.useCallback((e=>{n(!e),l.goToStep(e?oMe.SMS:oMe.COMPLETION)}),[l]),d=a.useCallback((()=>{r(!0),l.goToStep(oMe.BUSINESS_SKIP_INTERSTITIAL)}),[l]),m=a.useCallback((()=>{e(),l.goToStep(oMe.SPLASH),n(!1),r(!1)}),[e,l]);return{currentStep:l.currentStep,currentStepIndex:l.currentStepIndex,steps:l.steps,goToNextStep:l.goToNextStep,goToPreviousStep:l.goToPreviousStep,goToStep:u,canGoNext:l.canGoNext,canGoPrevious:l.canGoPrevious,isLastStep:l.isLastStep,isFirstStep:l.isFirstStep,handleSMSChoice:c,handleBusinessSkip:d,handleClose:m}},IBe=()=>{const{goToStep:e,goToNextStep:a}=HBe();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:t.jsxs("div",{className:"max-w-2xl space-y-6 w-full mx-auto",children:[t.jsx("div",{className:"w-16 h-16 bg-amber-100 rounded-2xl flex items-center justify-center",children:t.jsx(fz,{className:"w-8 h-8 text-amber-600"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"text-xl font-medium text-primary",children:"Business information can be added later"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"You can always return to add your business details when you're ready to get approved for sending."})]}),t.jsx("div",{className:"bg-muted/50 border border-muted rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(QD,{className:"w-5 h-5 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"What you'll miss:"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Business approval for higher sending limits and better deliverability"})]})]})})]})}),t.jsx("div",{className:"border-t border-border py-6 px-8 bg-background",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(H5,{variant:"ghost",onClick:()=>e(oMe.BUSINESS),className:"flex items-center gap-2",children:[t.jsx($D,{className:"w-4 h-4"}),"Go back to business info"]}),t.jsx(H5,{onClick:a,children:"Continue without business info"})]})})]})},FBe=()=>{const{handleClose:e}=HBe();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8 pt-10 @lg/onboarding-sidebar:pt-16 flex items-center justify-center",children:t.jsxs("div",{className:"max-w-2xl space-y-8",children:[t.jsx("div",{className:"w-24 h-24 mx-auto bg-muted rounded-2xl flex items-center justify-center",children:t.jsx(uz,{className:"w-16 h-16 text-primary"})}),t.jsxs("div",{className:"space-y-10 text-center",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"font-medium text-foreground flex items-center justify-center gap-3 text-2xl",children:"You're Ready to Go 🚀"}),t.jsx("div",{className:"space-y-4 text-muted-foreground",children:t.jsxs("p",{className:"text-sm whitespace-pre-line",children:["Everything's configured — now start sending campaigns and"," ",lH("engage:automation",{count:2})," to engage your audience."]})})]}),t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4 max-w-md mx-auto",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Fue,{title:"You can set up SMS later from the settings menu.",size:"small"}),t.jsx("p",{className:"text-primary text-sm text-left",children:"You can set up SMS later from the settings menu."})]})})]})]})}),t.jsx("div",{className:"border-t border-border py-6 px-8 flex items-center justify-end bg-background gap-4",children:t.jsxs(H5,{onClick:e,className:"flex items-center gap-2 text-sm",children:["Go to dashboard",t.jsx(ZD,{className:"w-4 h-4"})]})})]})},GBe=()=>{const{handleSMSChoice:e,goToPreviousStep:a}=HBe();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8 pt-10 @lg/onboarding-sidebar:pt-16",children:t.jsxs("div",{className:"max-w-2xl text-center space-y-8",children:[t.jsx("div",{className:"w-24 h-24 mx-auto bg-muted rounded-2xl flex items-center justify-center",children:t.jsx(_z,{className:"w-12 h-12 text-muted-foreground"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"text-xl font-bold text-foreground",children:"Want to reach your audience via SMS?"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"Share time-sensitive updates and drive more engagement with verified SMS."})]}),t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"space-y-6 border-2 border-muted rounded-lg mx-auto overflow-hidden",children:[t.jsx("h2",{className:"text-primary font-medium text-base text-center bg-muted p-2",children:"Why set up SMS?"}),t.jsxs("div",{className:"space-y-4 px-6 pb-6",children:[t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(az,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"SMS messages get 5x more opens than emails"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(oO,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Send urgent updates instantly"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(Uz,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Gain trust with verified sender ID"})]})]})]})}),t.jsx("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-4 max-w-sm mx-auto",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(wz,{className:"w-5 h-5 text-primary flex-shrink-0 mt-0.5"}),t.jsx("p",{className:"text-primary text-sm text-left whitespace-pre-line",children:"SMS requires company verification via Twilio. You can skip this step and set it up later."})]})})]})}),t.jsxs("div",{className:"border-t border-border py-6 px-8 flex items-center justify-between bg-background gap-4",children:[t.jsxs(H5,{variant:"outline",onClick:a,className:"flex items-center gap-2 text-sm",children:[t.jsx(iz,{className:"w-4 h-4"}),"Previous Step"]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(H5,{onClick:()=>e(!1),variant:"outline",className:"flex items-center gap-2 text-sm",children:"Not now"}),t.jsxs(H5,{onClick:()=>e(!0),className:"flex items-center gap-2 text-sm",children:["Yes, let's setup SMS",t.jsx(ZD,{className:"w-4 h-4"})]})]})]})]})},VBe=()=>{const{goToNextStep:e}=HBe(),{isPrefilled:n}=(()=>{const{channelSenders:e}=Jre(),{channelAccounts:t}=Fre(),{data:n}=$re();return a.useMemo((()=>{if(!e?.results||!t?.results)return{isPrefilled:!1,prefilledData:null};const a=Nle({channelSenders:e.results,channelAccounts:t.results,smsApplication:n}).find((e=>e.smsApplication?.status===Ele.APPROVED));if(!a?.smsApplication?.application)return{isPrefilled:!1,prefilledData:null};const i=a.smsApplication.application;return{isPrefilled:!0,prefilledData:"aws_toll_free_number"===i.type?{type:CBe.STANDARD,company:{name:i.company.name,website:i.company.website,address1:i.company.address1,address2:i.company.address2,city:i.company.city,stateProvince:i.company.stateProvince,zipCode:i.company.zipCode,country:i.company.country},contact:{firstName:i.contact.firstName,lastName:i.contact.lastName,email:i.contact.email,phoneNumber:i.contact.phoneNumber}}:null}}),[e,t,n])})();return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:t.jsxs("div",{className:"max-w-2xl space-y-6 w-full mx-auto",children:[t.jsx("div",{className:"w-16 h-16 bg-muted rounded-2xl flex items-center justify-center",children:t.jsx(Fz,{className:"w-8 h-8 text-primary"})}),t.jsxs("div",{className:"space-y-2 max-w-lg",children:[t.jsx("h1",{className:"text-xl font-medium text-primary leading-tight",children:"Start sending beautiful, branded emails & SMS"}),t.jsxs("p",{className:"text-sm",children:["Set up branded ",lH("engage:automation",{count:2})," that boost engagement and save you time."]})]}),t.jsxs("div",{className:"space-y-6 border-2 border-muted rounded-lg mx-auto overflow-hidden",children:[t.jsx("h2",{className:"text-primary font-medium text-base text-center bg-muted p-2",children:"Why set this up?"}),t.jsxs("div",{className:"space-y-4 px-6 pb-6",children:[t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(Fz,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Look professional from day one with branded emails and SMS"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(iO,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Reach more customers in less time with automated messages"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(oO,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Start sending in minutes - no tech skills required"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:t.jsx(fz,{className:"w-4 h-4"})}),t.jsx("p",{className:"text-sm",children:"Measure results - see what's working and improve"})]})]})]})]})}),t.jsxs("div",{className:"border-t border-border py-6 px-8 bg-background space-y-4",children:[n&&t.jsx("div",{className:"w-full flex-shrink-0",children:t.jsx(NBe,{})}),t.jsxs("div",{className:"flex items-center justify-between bg-background gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Fue,{title:`In just 5 minutes, you'll be ready to send branded ${lH("engage:automation",{count:2})}`,size:"small"}),t.jsxs("span",{children:["In just 5 minutes, you'll be ready to send branded"," ",lH("engage:automation",{count:2})]})]}),t.jsxs(H5,{onClick:e,className:"flex items-center gap-2 text-sm",children:["Let's start",t.jsx(ZD,{className:"w-4 h-4"})]})]})]})]})},JBe=()=>{const{open:e,onClose:a}=OBe(),{currentStep:n,goToStep:i,handleClose:r}=HBe(),o=n!==oMe.SPLASH&&n!==oMe.COMPLETION&&n!==oMe.BUSINESS_SKIP_INTERSTITIAL;return t.jsx(UCe,{open:e,onOpenChange:e=>{e||(r?r():a())},title:uMe,description:cMe,sidebarItems:jMe,currentStep:n,onStepChange:i,completedSteps:[],mode:"onboarding",showSidebar:o,showMobileNav:o,className:"max-w-5xl h-[90vh]",children:{[oMe.SPLASH]:t.jsx(VBe,{}),[oMe.BRAND]:t.jsx(wBe,{}),[oMe.EMAIL]:t.jsx(jBe,{}),[oMe.BUSINESS]:t.jsx(xBe,{}),[oMe.BUSINESS_SKIP_INTERSTITIAL]:t.jsx(IBe,{}),[oMe.SMS_INTERSTITIAL]:t.jsx(GBe,{}),[oMe.SMS]:t.jsx(BBe,{}),[oMe.COMPLETION]:t.jsx(FBe,{})}[n]||null})},UBe=({children:e,open:a,onClose:n})=>t.jsx(zBe.Provider,{value:{open:a,onClose:n},children:e}),WBe=({automationId:e,isOpen:a,onClose:n})=>{const{linkClickStats:i,isGetting:r,getError:o}=aa(e);return t.jsx(ZZ,{open:a,onOpenChange:n,children:t.jsxs(eY,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[t.jsx(aY,{children:t.jsxs(nY,{className:"flex items-center gap-2",children:[t.jsx(Bz,{className:"h-5 w-5"}),"Link Click Statistics"]})}),t.jsxs("div",{className:"space-y-4",children:[r&&t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"Loading link click statistics..."}),o&&t.jsx("div",{className:"text-sm text-destructive text-center py-8",children:"Error loading link click statistics. Please try again."}),!r&&!o&&(!i||0===Object.keys(i).length)&&t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No link clicks found."}),!r&&!o&&i&&Object.keys(i).length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[t.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Summary"}),t.jsxs("div",{className:"flex gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold",children:Object.keys(i).length})," ","unique links"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold",children:Object.values(i).reduce(((e,a)=>e+a),0)})," ","total clicks"]})]})]}),t.jsx("div",{className:"space-y-2",children:Object.entries(i).sort((([,e],[,a])=>a-e)).map((([e,a])=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:text-blue-800 hover:underline flex items-center gap-1 truncate",children:[t.jsx("span",{className:"truncate",children:e}),t.jsx(yz,{className:"h-3 w-3 flex-shrink-0"})]})}),t.jsxs("div",{className:"text-right ml-4",children:[t.jsx("span",{className:"font-semibold text-lg",children:a}),t.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:1===a?"click":"clicks"})]})]},e)))})]})]})]})})},qBe=e=>{if(!e)return"$0.00";const a="string"==typeof e?e.replace(/,/g,""):e,t=Number(a);return Number.isNaN(t)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t)},$Be=({Icon:e,title:a,value:n,tooltipText:i,change:r,onClick:o,isClickable:s=!1})=>t.jsxs(Zie,{className:"relative flex flex-col justify-between min-h-[130px] transition-all duration-300 p-4 "+(s?"hover:shadow-md cursor-pointer hover:bg-muted/50":"hover:shadow-md"),onClick:o,children:[t.jsxs("div",{className:"flex justify-between items-start",children:[t.jsx("div",{className:"rounded-lg p-2 bg-primary/10 flex items-center justify-center",children:t.jsx(e,{className:"w-5 h-5 text-primary"})}),t.jsx("div",{className:"absolute top-3 right-3",children:t.jsx(Fue,{title:i})})]}),t.jsxs("div",{className:"mt-4",children:[t.jsx("div",{className:"text-2xl font-bold leading-tight text-primary",children:n}),t.jsx(i_e,{children:a})]}),r&&t.jsx("div",{className:"absolute bottom-3 right-3",children:t.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full bg-green-100 text-green-600 text-xs font-semibold",children:r})})]}),ZBe=({activeTab:e,automation:a})=>{if(!a)return null;const n={sales:[{Icon:V5.SalesAmount,title:"Order Amount",value:qBe(a.derivedRevenue),tooltipText:"Total derived revenue from this campaign"},{Icon:V5.Orders,title:"Orders",value:a.derivedOrders,tooltipText:"Total individual orders from this campaign"}]};return t.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:n[e].map(((e,a)=>t.jsx($Be,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},YBe=({activeTab:e,statistics:a,automationId:n,onLinkClickStatsOpen:i})=>{const r={email:[{Icon:V5.MessagesSent,title:"Emails Sent",value:a.email.numberSent,tooltipText:"Total number of emails that were successfully sent in this campaign",onClick:void 0,isClickable:!1},{Icon:V5.OpenRate,title:"Open Rate",value:`${(100*a.email.openPercentage).toFixed(2)}%`,tooltipText:"Percentage of recipients who opened the email out of total emails delivered",onClick:void 0,isClickable:!1},{Icon:V5.TotalBounceRate,title:"Total Bounce Rate",value:`${(100*(a.email.softBounceRate+a.email.hardBounceRate)).toFixed(2)}%`,tooltipText:"Percentage of emails that were not delivered due to permanent (hard) or temporary (soft) delivery failures. Hard bounces will be automatically unsubscribed.",onClick:void 0,isClickable:!1},{Icon:V5.LinksClicked,title:"Links Clicked",value:a.email.linksClicked,tooltipText:"Total number of times recipients clicked on links within the email. Click to view detailed link statistics.",onClick:i,isClickable:!!n&&!!i},{Icon:V5.SpamComplies,title:"Spam Complaints",value:`${(100*a.email.spamComplaintRate).toFixed(2)}%`,tooltipText:"Percentage of emails that were marked as spam by recipients or their spam filters. Manual spam complaints will be automatically unsubscribed.",onClick:void 0,isClickable:!1},{Icon:V5.UnsubscribeRate,title:"Unsubscribe Rate",value:`${(100*a.email.unsubscribedRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who unsubscribed after receiving this email",onClick:void 0,isClickable:!1}],sms:[{Icon:V5.MessagesSent,title:"SMS Sent",value:a.sms.numberSent,tooltipText:"Total number of SMS messages that were successfully sent in this campaign",onClick:void 0,isClickable:!1}]};return t.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:r[e].map(((e,a)=>t.jsx($Be,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText,onClick:e.onClick,isClickable:e.isClickable},a)))})},QBe=({automationId:e,includeSales:n=!1,includeSms:i=!1,automation:r})=>{const[o,s]=a.useState(!1),{statistics:l,isLoading:u}=oa(e);return u||!l?t.jsx("div",{className:"bg-white rounded-2xl w-full p-6 space-y-4 relative h-[14.05rem]",children:t.jsx(lY,{text:[`Fetching ${lH("engage:insight",{count:2})}`,"Finishing up"]})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bg-white rounded-2xl w-full p-6 flex flex-col gap-6",children:[t.jsxs("section",{children:[t.jsx(t_e,{className:"mb-4",children:lH("engage:emailInsights","Email Insights")}),t.jsx(YBe,{activeTab:"email",statistics:l,automationId:e,onLinkClickStatsOpen:()=>s(!0)})]}),(i||n)&&t.jsx(gEe,{className:"my-2"}),i&&t.jsxs("section",{children:[t.jsx(t_e,{className:"mb-4",children:lH("engage:smsInsights","SMS Insights")}),t.jsx(YBe,{activeTab:"sms",statistics:l})]}),n&&i&&t.jsx(gEe,{className:"my-2"}),n&&t.jsxs("section",{children:[t.jsx(t_e,{className:"mb-4",children:lH("engage:salesInsights","Sales Insights")}),t.jsx(ZBe,{activeTab:"sales",automation:r})]})]}),e&&t.jsx(WBe,{automationId:e,isOpen:o,onClose:()=>s(!1)})]})},XBe=e=>{const{updateAutomation:t,updateError:n,isUpdateSuccess:i}=ra(e),{toast:r}=Ve();return a.useEffect((()=>{i?r({title:"Status updated",description:"The status has been updated successfully"}):n&&r({title:"Error updating status",description:"Please try again",variant:"destructive"})}),[i,n,r]),{toggleStatus:async e=>{try{return await t({status:e?ha.ACTIVE:ha.DRAFT}),!0}catch(a){return r({title:"Error updating status",description:"Please try again",variant:"destructive"}),!1}}}};function eRe(){const{toast:e}=Ve(),[n,i]=a.useState(null),{toggleStatus:r}=XBe(n||""),o=gne(),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{automations:h,nextCursor:p,isLoading:g,error:f,isFetching:v,isPlaceholderData:y}=sa({cursor:u,limit:s,triggerTypes:[ua.TRIGGER_BASED,ua.DATE_BASED],search:d||void 0});a.useEffect((()=>{f&&e({title:`Error Fetching ${lH("engage:automation")}`,description:f?.message||"Please try again.",variant:"destructive"})}),[f,e]);const b=a.useMemo((()=>(h||[]).map((e=>({...e,emailsSent:0,smsSent:0,updated_at:e.updatedAt||e.createdAt})))),[h]),k=a.useCallback((async(e,a)=>{try{i(e);const t=a===ha.ACTIVE;await r(t)}finally{i(null)}}),[r,i]),S=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]),w=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),A=a.useMemo((()=>Iue({automationName:lH("engage:automation"),setUrl:w,onToggle:k,vsaasManaged:!0})),[k,w]);return t.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:t.jsx("div",{className:"flex-grow min-h-0 p-2",children:t.jsx(vte,{data:b,columns:A,paginationMode:"cursor",initialPageSize:s,isLoading:g&&!y,onRowClick:e=>{o(`/automations/view-modal/${e.id}?showBackButton=true`)},cursorPaginationQueryResult:{nextCursor:p,isLoading:g,isFetching:v,isPlaceholderData:y},onQueryParametersChange:S,searchValue:d,onSearchChange:m})})})}function aRe(){const{toast:e}=Ve(),[n,i]=a.useState(!1),[r,o]=a.useState(null),{toggleStatus:s}=XBe(r||""),l=gne(),[u,c]=a.useState(10),[d,m]=a.useState(void 0),[h,p]=a.useState(""),{automations:g,nextCursor:f,isLoading:v,error:y,isFetching:b,isPlaceholderData:k}=sa({cursor:d,limit:u,triggerTypes:[ua.ONE_TIME],search:h||void 0});a.useEffect((()=>{y&&e({title:`Error Fetching ${lH("engage:broadcast")}`,description:y?.message||"Please try again.",variant:"destructive"})}),[y,e]);const S=a.useMemo((()=>(g||[]).map((e=>({...e,updated_at:e.updatedAt})))),[g]),w=a.useCallback((async(e,a)=>{try{o(e);const t=a===ha.ACTIVE;await s(t)}finally{o(null)}}),[s,o]),A=a.useCallback((e=>{m(e.cursor),c(e.pageSize)}),[]),C=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),M=a.useMemo((()=>Iue({automationName:lH("engage:broadcast"),setUrl:C,onToggle:w,pillForStatus:!0})),[w,C]);return t.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[t.jsx("div",{className:"flex-grow min-h-0 p-2",children:t.jsx(vte,{data:S,columns:M,paginationMode:"cursor",initialPageSize:u,headerActions:t.jsxs(H5,{className:"bg-primary",onClick:()=>i(!0),children:[t.jsx(Kz,{className:"h-4 w-4 mr-1"}),"New"]}),isLoading:v&&!k,cursorPaginationQueryResult:{nextCursor:f,isLoading:v,isFetching:b,isPlaceholderData:k},onRowClick:e=>{l(`/automations/view-modal/${e.id}?showBackButton=true`)},onQueryParametersChange:A,searchValue:h,onSearchChange:p})}),t.jsx(oBe,{open:n,setOpen:i,onClose:a=>{jue(i,e,a,`Error creating ${lH("engage:broadcast")}`,"Please try again"),m(void 0),c(10),p(""),!1!==a&&l(`/automations/view-modal/${a}?showBackButton=true`)},automationType:ua.ONE_TIME})]})}function tRe(){const{toast:e}=Ve(),[n,i]=a.useState(!1),[r,o]=a.useState(null),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{segments:h,isLoading:p,nextCursor:g,isFetching:f,isPlaceholderData:v}=T5({search:d||void 0,cursor:u,limit:s}),y=a.useCallback((e=>{o(e),i(!0)}),[o]),b=a.useMemo((()=>function(e){return[Rue("name",`${lH("engage:segment")} Name`,!0),Due(),Pue({accessorKey:"user_count",header:lH("engage:user_other"),meta:{align:"right",displayName:lH("engage:user_other")},cellClassName:"text-muted-foreground pr-4",cellFormatter:e=>{const a=e.getValue()??0;return`${a.toLocaleString()} ${lH("engage:user",{count:a}).toLowerCase()}`}}),zue("updated_at"),Hue(e||(()=>{}))]}(y)),[y]),k=a.useMemo((()=>h?h.map((e=>({...e,updated_at:e.createdAt.toString(),user_count:e.userCount,user_count_updated_at:e.userCountUpdatedAt}))):[]),[h]),S=a.useMemo((()=>t.jsxs(H5,{onClick:()=>{o(null),i(!0)},children:[t.jsx(Kz,{className:"h-4 w-4"}),"New List"]})),[]),w=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]);return t.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[t.jsx("div",{className:"flex-grow min-h-0 p-2",children:t.jsx(vte,{data:k,columns:b,paginationMode:"cursor",initialPageSize:s,headerActions:S,isLoading:p&&!v,cursorPaginationQueryResult:{nextCursor:g,isLoading:p,isFetching:f,isPlaceholderData:v},onQueryParametersChange:w,onRowClick:a=>{if(a.type===P5.CUSTOM)o(a.id),i(!0);else{let t;switch(a.type){case P5.ALL_USERS:t="All users";break;case P5.MANAGED:t="Managed";break;default:throw jre(a.type,P5)}e({title:`${t} ${lH("engage:segment").toLowerCase()} cannot be edited`})}},searchValue:d,onSearchChange:m})}),t.jsx(zLe,{open:n,setOpen:i,segmentId:r??void 0,onSegmentUpdated:a=>{jue(i,e,a,`Error creating ${lH("engage:segment")}`,"Please try again"),c(void 0),l(10),m("")}})]})}const nRe=()=>{const e=ce(),[n,i]=a.useState(!1),r=oR()["show-engage-onboarding"]??!1,[o,s]=a.useState(r),[l,u]=a.useState(null),{automations:c,isLoading:d}=sa({triggerTypes:[ua.TRIGGER_BASED,ua.DATE_BASED]}),[m,h]=a.useState();return a.useEffect((()=>{e.prefetchQuery({queryKey:Be.list()}),e.prefetchQuery({queryKey:C5.lists()})}),[e]),a.useEffect((()=>{if(d||void 0===c)return;const e=[{id:"broadcasts",label:lH("engage:broadcast",{count:2}),content:t.jsx(aRe,{})},{id:"segments",label:lH("engage:segment",{count:2}),content:t.jsx(tRe,{})},{id:"statistics",label:lH("engage:insight",{count:2}),content:t.jsx(QBe,{includeSales:!1,includeSms:!0})}];c.length>0?(u("automations"),h([{id:"automations",label:lH("engage:automation",{count:2}),content:t.jsx(eRe,{})},...e])):(u("broadcasts"),h(e))}),[c,d]),null===l||null==m?t.jsx("div",{className:"w-full h-full flex justify-center items-center",children:t.jsx(lY,{})}):t.jsxs("div",{className:"w-full h-full flex flex-col gap-4",children:[r&&t.jsx(UBe,{open:o,onClose:()=>s(!1),children:t.jsx(JBe,{})}),t.jsx(DBe,{open:n,setOpen:i,children:t.jsx(RBe,{})}),t.jsx("div",{className:"flex justify-end",children:t.jsx(H5,{variant:"outline",onClick:()=>i(!0),children:t.jsx(Vz,{className:"w-4 h-4"})})}),t.jsx("div",{className:"flex-1 w-full h-full flex flex-col gap-4",children:t.jsx(sBe,{activeTab:l,tabs:m,onTabChange:u})})]})};function iRe({open:e,onOpenChange:a}){const n=B5(),{toast:i}=Ve(),{updateAutomation:r,isUpdating:o}=ra(n?.id||""),s=lH(n?.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation");return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:"Archive Automation"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to archive"," ",t.jsxs("span",{className:"font-semibold text-gray-900",children:['"',n?.name,'"']}),"?"]}),t.jsxs("div",{className:"text-sm text-gray-500 bg-amber-50 border border-amber-200 rounded-lg p-3",children:[t.jsx("p",{className:"font-medium text-amber-800 mb-1",children:"What happens when you archive:"}),t.jsxs("ul",{className:"text-amber-700 space-y-1",children:[t.jsx("li",{children:"• The automation will be hidden from your main list"}),t.jsx("li",{children:"• Historical data and settings are preserved"})]})]}),t.jsxs(tY,{className:"gap-2",children:[t.jsx(H5,{variant:"outline",onClick:()=>a(!1),disabled:o,children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:async function(){n?r({status:ha.ARCHIVED},{onSuccess:()=>{i({title:`${s} archived`,description:`"${n.name}" has been successfully archived.`}),a(!1)},onError:()=>{i({title:"Error archiving!",description:"Please contact your administrator.",variant:"destructive"})}}):i({title:"Error archiving automation",description:"Please try again.",variant:"destructive"})},disabled:o,children:o?"Archiving...":"Archive Automation"})]})]})]})})}function rRe({value:e,schema:n,onSubmit:i,fieldName:r,className:o,successMessage:s="Updated successfully",errorMessage:l="Failed to update",placeholderText:u}){const[c,d]=a.useState(!1),[m,h]=a.useState(!1),[p,g]=a.useState(0),[f,v]=a.useState(0),[y,b]=a.useState(e),[k,S]=a.useState(e),w=a.useRef(null),A=a.useRef(null),C=a.useRef(null),M=a.useRef(null),{toast:T}=Ve(),x=yCe({resolver:iMe(n),defaultValues:{[r]:e}});a.useEffect((()=>{x.reset({[r]:e}),b(e),S(e)}),[e,r,x]),a.useEffect((()=>{A.current&&g(A.current.offsetWidth),M.current&&!c&&v(M.current.offsetWidth)}),[c]),a.useEffect((()=>{C.current&&y&&g(C.current.offsetWidth)}),[y]),a.useEffect((()=>{c&&w.current&&(w.current.focus(),w.current.select())}),[c]);const E=async e=>{h(!0);const a=e[r];try{await i(e),S(a),T({variant:"success",title:s}),d(!1)}catch(t){T({variant:"destructive",title:l})}finally{h(!1)}},N=()=>{x.reset(),d(!1),b(k)},_=e=>{"Escape"===e.key&&N()};return c?t.jsx(bCe,{...x,children:t.jsxs("form",{onSubmit:x.handleSubmit(E),className:$Z("inline-flex items-center gap-2 min-h-[20px]",o),style:{minWidth:f?`${f}px`:"auto"},children:[t.jsx("span",{ref:C,className:"absolute invisible whitespace-pre leading-none select-none pointer-events-none",style:{font:"inherit"},children:y||k}),t.jsx(SCe,{control:x.control,name:r,render:({field:e})=>t.jsx(CCe,{className:"flex-1 min-w-0",children:t.jsx(TCe,{children:t.jsx("input",{...e,ref:w,style:{width:`${Math.max(p+40,120)}px`,minWidth:`${Math.max(p,100)}px`,font:"inherit"},className:"bg-transparent outline-none leading-none h-[20px] border-none p-0 m-0",onChange:a=>{e.onChange(a),b(a.target.value)},onKeyDown:_,disabled:m,onBlur:a=>{e.onBlur(),setTimeout((()=>{const e=a.currentTarget.form;e&&!e.contains(document.activeElement)&&N()}),0)}})})})}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.jsx(H5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",onClick:N,disabled:m,children:t.jsx(rO,{className:"h-3 w-3"})}),t.jsx(H5,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",disabled:m,onClick:()=>{x.handleSubmit(E)()},children:m?t.jsx(Cz,{className:"h-3 w-3 animate-spin"}):t.jsx(tz,{className:"h-3 w-3"})})]})]})}):t.jsxs("button",{ref:M,type:"button",className:$Z("group relative inline-flex items-center gap-2 cursor-pointer min-h-[20px] bg-transparent border-none p-0 text-left",o),onClick:()=>d(!0),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),d(!0))},"aria-label":"Edit field",children:[t.jsx("span",{ref:A,className:$Z("leading-none select-none",o,{italic:!k}),children:k||u}),t.jsx(Dz,{className:"h-3 w-3 transition-opacity duration-200 flex-shrink-0 opacity-0 group-hover:opacity-100"})]})}function oRe({open:e,onOpenChange:a}){const n=B5(),{toast:i}=Ve(),{updateAutomation:r}=ra(n?.id||""),o=ce();return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:n?.status===ha.SENDING?`Cancel ${lH("engage:automation")}`:`Cancel ${lH("engage:automation")} Before Sending`})}),t.jsx("div",{className:"space-y-4",children:n?t.jsxs(t.Fragment,n.status===ha.SENDING?{children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",t.jsx("span",{className:"font-bold px-1 text-primary",children:n.name}),lH("engage:automation")," as soon as possible."]}),t.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[t.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[t.jsxs("li",{children:["We'll attempt to cancel the"," ",lH("engage:broadcast").toLowerCase()]}),t.jsx("li",{children:"Any messages already in the process of being sent will be delivered"}),t.jsxs("li",{children:["Future ",lH("engage:broadcast").toLowerCase()," messages will be cancelled"]}),t.jsxs("li",{children:["You can create a new ",lH("engage:broadcast").toLowerCase()," if needed"]})]})]})]}:{children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",t.jsx("span",{className:"font-bold px-1 text-primary",children:n.name}),lH("engage:automation")," before it starts sending."]}),t.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[t.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[t.jsx("li",{children:"The automation will be cancelled"}),t.jsx("li",{children:"You can create a new automation if needed"})]})]})]}):null}),t.jsxs(tY,{className:"gap-2 sm:gap-0",children:[t.jsx(H5,{variant:"outline",onClick:()=>a(!1),children:"Continue Running"}),t.jsxs(H5,{variant:"destructive",onClick:()=>{if(!n)return;const e=n.status===ha.SENDING?ha.PARTIALLY_CANCELLED:ha.CANCELLED,t=n.status===ha.SENDING?`Attempting to cancel ${lH("engage:broadcast").toLowerCase()}`:`Successfully cancelled ${lH("engage:broadcast").toLowerCase()}`,s=`Failed to cancel ${lH("engage:broadcast").toLowerCase()}`;r({status:e},{onError:()=>{i({title:s,description:"Please contact your administrator.",variant:"destructive"}),o.invalidateQueries({queryKey:Be.all})},onSuccess:()=>{a(!1),i({title:t,description:n.status===ha.SENDING?`We'll attempt to cancel your ${lH("engage:broadcast").toLowerCase()}. Any messages already in progress will be delivered.`:`Your ${lH("engage:broadcast").toLowerCase()} has been cancelled.`})}})},children:["Cancel ",lH("engage:automation")]})]})]})})}function sRe({open:e,onOpenChange:a,setIsActive:n}){const i=B5(),{updateAutomation:r}=ra(i?.id||""),{toast:o}=Ve(),s=ce(),l=lH(i?.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation"),u=i?.triggerType===ua.ONE_TIME?"Unschedule":`Pause ${l}`;return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:u})}),t.jsxs("div",{children:[i?.triggerType===ua.ONE_TIME?"Are you sure you want to unschedule the":"Are you sure you want to pause the",t.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name})," ",l,"?"]}),t.jsxs(tY,{className:"gap-2 sm:gap-0",children:[t.jsx(H5,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),t.jsx(H5,{variant:"destructive",onClick:()=>{r({status:ha.DRAFT},{onSuccess:()=>{o({title:`Updated ${l}`,description:`${l} status updated`}),a(!1),n(!1)},onError:()=>{o({title:`Failed to update ${l}`,description:"Please try again"}),s.invalidateQueries({queryKey:Be.all})}})},children:u})]})]})})}const lRe=ale({name:Ise().min(2,"Title must be at least 2 characters"),description:Ise()});function uRe({open:e,onOpenChange:a,onDuplicationCreated:n}){const i=B5(),{toast:r}=Ve(),o=yCe({resolver:iMe(lRe),defaultValues:{name:`${i?.name} (copy)`,description:i?.description??""}}),{duplicateAutomation:s}=la();return t.jsx(ZZ,{open:e,onOpenChange:a,children:t.jsxs(eY,{className:"sm:max-w-[425px]",children:[t.jsx(aY,{children:t.jsx(nY,{children:"Duplicate Automation"})}),t.jsx(bCe,{...o,children:t.jsxs("form",{onSubmit:o.handleSubmit((async function(e){i&&e.name?s({automationId:i.id,name:e.name,description:e.description},{onSuccess:e=>{e.id&&(n?.(e.id),a(!1))}}):r({title:"Error duplicating automation",description:"Please try again. Please make sure to fill in the name of the automation."})})),className:"space-y-4",children:[t.jsxs("div",{children:["Create a copy of the",t.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name}),"automation with a new title and description."]}),t.jsx(SCe,{control:o.control,name:"name",render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Title"}),t.jsx(TCe,{children:t.jsx(gte,{...e})}),t.jsx(xCe,{})]})}),t.jsx(SCe,{control:o.control,name:"description",render:({field:e})=>t.jsxs(CCe,{children:[t.jsx(MCe,{children:"Description"}),t.jsx(TCe,{children:t.jsx(BLe,{...e})}),t.jsx(xCe,{})]})}),t.jsx(tY,{children:t.jsx(H5,{type:"submit",children:"Duplicate"})})]})})]})})}const cRe=ale({name:Ise().min(2,"Title must be at least 2 characters")}),dRe=ale({description:Ise().max(300,"Description must be less than 300 characters")}),mRe=({showBackButton:e,onDuplicationCreated:n,onBeforeSchedule:i})=>{const r=B5(),o=gne(),{updateAutomation:s}=ra(r?.id||""),{toast:l}=Ve(),u=(()=>{const{state:e}=L5();return e.recipientStats})(),c=R5(),{data:d}=$re(),{channelSenders:m}=Jre(),{channelAccounts:h}=Fre(),p=ce(),[g,f]=a.useState(void 0),[v,y]=a.useState(!1),[b,k]=a.useState(!1),[S,w]=a.useState(!1),[A,C]=a.useState(!1),[M,T]=a.useState(0),[x,E]=a.useState(!1),N=Nle({channelSenders:m?.results??[],channelAccounts:h?.results??[],smsApplication:d});a.useEffect((()=>{if(r)switch(r.status){case ha.DRAFT:f(!1);break;case ha.ACTIVE:case ha.RUNNING:case ha.COMPLETED:f(!0);break;case ha.FAILED:case ha.DEACTIVATED:f(!1);break;case ha.SENDING:case ha.SCHEDULED:f(!0);break;case ha.PARTIALLY_CANCELLED:case ha.CANCELLED:case ha.ARCHIVED:f(!1);break;default:throw jre(r.status,ha)}}),[r]);const _=lH(r?.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation"),P=a.useCallback((()=>{if(!r)return l({title:`${_} not found`,description:"Please contact your administrator",variant:"destructive"}),null;const e=async e=>{if(g&&!e)w(!0);else{if(C(!0),i&&!0===e){let e=0;for(;!u&&e<20;)await new Promise((e=>setTimeout(e,100))),e++;if(!u)return l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),void C(!1);const a=await i({estimatedEmailRecipients:u?.emails??0,estimatedSmsRecipients:u?.phones??0});if(!0!==a)return l({title:"Error while updating the status",description:a,variant:"destructive"}),void C(!1)}if(c?.emailChannelSenderId&&c?.emailHtmlBody&&c?.emailHtmlBody?.includes(YLe)){if(0===M)return l({title:`${QLe}. You can click send again to send anyway.`,variant:"warning"}),T(M+1),void C(!1);T(M+1)}switch(r.triggerType){case ua.ONE_TIME:if(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt)return l({title:"Ensure you have selected a scheduled time",variant:"destructive"}),void C(!1);if(!c||!c.emailChannelSenderId&&!c.smsChannelSenderId)return l({title:"Ensure you have selected at least one kind of communication",variant:"destructive"}),void C(!1);break;case ua.TRIGGER_BASED:case ua.DATE_BASED:break;default:throw jre(r.triggerType,ua)}s({status:e?ha.ACTIVE:ha.DEACTIVATED},{onSuccess:()=>{f(e),l(r.triggerType===ua.ONE_TIME?e?{title:`${_} started!`}:{title:`${_} has been unscheduled`}:{title:`${_} status updated to ${e?"active":"inactive"}`}),C(!1)},onError:()=>{l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),C(!1),p.invalidateQueries({queryKey:Be.all})}})}};if(!r||!c)return null;const a=N.find((e=>e.channelSender.id===c?.smsChannelSenderId)),n=!r.triggerMetadata||null===r.triggerMetadata,o=r.triggerMetadata?.triggerType===ua.ONE_TIME&&!r.triggerMetadata?.scheduledAt,d=!c?.emailChannelSenderId&&!c?.smsChannelSenderId,m=r.triggerType===ua.ONE_TIME,h=m&&a&&a?.smsApplication?.application&&a?.smsApplication?.status!==Ele.APPROVED,v=c?.emailChannelSenderId&&(!c?.emailSubject||!c?.emailHtmlBody),y=c?.smsChannelSenderId&&!c?.smsMessageBody,b=m&&(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt);let k,S=!1,A=!0;switch(r.status){case ha.ACTIVE:S=!1;break;case ha.DRAFT:(d||v||y)&&(S=!0,v&&(k="Missing subject in email communication"),y&&(k="Missing SMS message in SMS communication")),b&&(S=!0),h&&(S=!0);break;case ha.DEACTIVATED:case ha.PARTIALLY_CANCELLED:case ha.CANCELLED:switch(S=!0,A=!1,r.status){case ha.DEACTIVATED:k="Automation is deactivated";break;case ha.PARTIALLY_CANCELLED:k="Automation is partially cancelled";break;case ha.CANCELLED:k="Automation is cancelled";break;default:throw jre(r.status,ha)}break;case ha.RUNNING:S=!0,r.triggerType===ua.TRIGGER_BASED?(k=`Cannot change status of running ${_}`,A=!0):A=r.triggerType===ua.ONE_TIME&&r.status===ha.RUNNING;break;case ha.COMPLETED:S=!0,k=`Cannot change status of completed ${_}`,A=!1;break;case ha.FAILED:S=!0,k=`Cannot change status of failed ${_}`,A=!1;break;case ha.SENDING:case ha.SCHEDULED:S=!1,A=!0;break;case ha.ARCHIVED:S=!0,k=`Cannot change status of archived ${_}`,A=!1;break;default:throw jre(r.status,ha)}const x=(()=>{switch(r.triggerType){case ua.DATE_BASED:case ua.TRIGGER_BASED:return t.jsxs("div",{className:"flex items-center gap-2 w-[12ch] cursor-pointer",children:[t.jsx(g?tz:pz,{className:"w-4 h-4"}),t.jsx("div",{className:"text-[13px] font-medium",children:g?"Active":"Inactive"}),t.jsx(MLe,{checked:g,onCheckedChange:e,disabled:S})]});case ua.ONE_TIME:if((r.status===ha.RUNNING||r.status===ha.SCHEDULED||r.status===ha.SENDING)&&r.triggerType===ua.ONE_TIME)return t.jsx(H5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>E(!0),disabled:!1,children:"Cancel"});if(n||o||d||h||v||y){return t.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:(()=>{const a=r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"===r.triggerMetadata?.scheduledAt?`Start ${_}`:"Schedule Send";if(r.status!==ha.DRAFT&&r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"!==r.triggerMetadata?.scheduledAt&&r.status===ha.ACTIVE)return t.jsx(H5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:S,children:r.triggerType===ua.ONE_TIME?"Unschedule":"Convert to Draft"});const n=[];h&&n.push("The SMS number selected is still not approved"),b&&n.push("Please select a schedule time on the left sidebar"),d&&n.push("Please add at least one sender"),v&&n.push("Please add a subject to your email communication"),y&&n.push("Please add a message to your SMS communication");const i=n.map((e=>{return(a=e)?a.charAt(0).toUpperCase()+a.slice(1):a;var a})),o=`You cannot start this ${lH("engage:broadcast").toLowerCase()} yet. ${i.join(" · ")}`;return t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Fue,{alertText:o,asChild:!1,className:"!cursor-not-allowed",children:t.jsx("div",{className:"px-4 py-2 rounded border border-input bg-background text-muted-foreground cursor-not-allowed text-sm font-medium",children:t.jsx("span",{children:a})})})})})()})}if(!g){let a="Schedule Send";return r.triggerMetadata&&r.triggerMetadata.triggerType===ua.ONE_TIME&&r.triggerMetadata.scheduledAt&&"now"===r.triggerMetadata.scheduledAt&&(a=`Start ${_}`),t.jsx(H5,{variant:"default",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:S,children:a})}return t.jsx(H5,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:S,children:r.triggerType===ua.ONE_TIME?"Unschedule":"Convert to Draft"});default:throw jre(r.triggerType,ua)}})();return S&&k&&r.triggerType===ua.TRIGGER_BASED?t.jsx(Fue,{alertText:k,asChild:!0,children:t.jsx("div",{className:"flex items-center gap-2",children:A&&x})}):t.jsx("div",{className:"flex items-center gap-2",children:A&&x})}),[r,c,N,l,g,_,i,s,u,M,p]),j=a.useMemo((()=>r?t.jsx(a6,{variant:Lue(r.status),children:Lre({status:r.status,automationType:r.triggerType})}):null),[r]);return r&&void 0!==g?t.jsxs("header",{className:"flex px-1 pt-1",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e&&t.jsx(H5,{variant:"ghost",size:"icon",onClick:()=>o(-1),children:t.jsx($D,{})}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs("div",{className:"flex flex-col gap-0 items-start",children:[t.jsx(rRe,{value:r.name,schema:cRe,onSubmit:e=>{s({name:e.name},{onError:()=>{l({title:`Failed to update ${_} name`,description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Be.all})}})},fieldName:"name",className:"text-lg",successMessage:`${_} name updated`,errorMessage:`Failed to update ${_.toLowerCase()} name`}),r.automationType!==da.MANAGED?t.jsx(rRe,{value:r.description||"",schema:dRe,onSubmit:e=>{s({description:e.description},{onError:()=>{l({title:`Failed to update ${_.toLowerCase()} description`,description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:Be.all})}})},fieldName:"description",className:"text-sm "+(r.description?"text-current":"text-muted-foreground"),successMessage:"Description updated",errorMessage:"Failed to update description",placeholderText:`Describe the goal of the ${_.toLowerCase()}`}):r.description&&t.jsx("div",{className:"text-sm text-current",children:r.description})]})})]}),t.jsxs("div",{className:"ml-auto flex gap-4 items-center",children:[t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[j,r.triggerType===ua.ONE_TIME&&t.jsxs(t.Fragment,{children:[t.jsx("div",{role:"button",tabIndex:0,className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 cursor-pointer",onClick:()=>y(!0),children:t.jsx(Fue,{title:"Duplicate",Icon:V5.DuplicateIcon,asChild:!1,onClick:()=>y(!0)})}),r.status===ha.COMPLETED||r.status===ha.DRAFT&&t.jsx("div",{role:"button",tabIndex:0,className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 cursor-pointer",onClick:()=>k(!0),children:t.jsx(Fue,{title:"Archive",Icon:V5.ArchiveIcon,asChild:!1,onClick:()=>k(!0)})})]})]}),t.jsx("div",A?{className:"flex items-center text-muted-foreground pr-2",children:t.jsx(lY,{size:"sm"})}:{className:"flex items-center",children:P()})]}),t.jsx(uRe,{open:v,onOpenChange:y,onDuplicationCreated:n}),t.jsx(sRe,{open:S,onOpenChange:w,setIsActive:f}),t.jsx(oRe,{open:x,onOpenChange:E}),t.jsx(iRe,{open:b,onOpenChange:k})]}):null},hRe=()=>{const e=B5(),{isLoading:n}=oa(e?.id),{state:{hideSales:i,hideSms:r}}=a.useContext(rY);return!e||n?t.jsx(lY,{text:[`Fetching ${lH("engage:insight",{count:2})}`,"Finishing up"]}):t.jsx("div",{className:"h-full p-4",children:t.jsx(QBe,{automationId:e.id,automation:e,includeSales:!i,includeSms:!r})})},pRe=()=>{const e=B5(),[n,i]=a.useState(10),[r,o]=a.useState(void 0),[s,l]=a.useState(""),{sentCommunications:u,isLoading:c,isFetching:d,isPlaceholderData:m,fetchError:h}=na({automationId:e?.id??"",cursor:r,limit:n,search:s||void 0}),p=a.useCallback((e=>{o(e.cursor),i(e.pageSize)}),[]),g=[{accessorKey:"communicationsSent",id:"lastCommunication",header:"Sent At",cell:({row:e})=>e.original.communicationJobCreatedAt?t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"text-sm text-gray-600",children:Eue(new Date(e.original.communicationJobCreatedAt),"MMM d, yyyy h:mm a")})}):t.jsx("span",{className:"text-gray-400",children:"Not available"})},{accessorFn:e=>`${e.firstName||""} ${e.lastName||""}`.trim(),id:"name",header:"Name",cell:({row:e})=>{const a=`${e.original.firstName||""} ${e.original.lastName||""}`.trim();return a||t.jsx("span",{className:"text-gray-400",children:"Not provided"})}},{accessorKey:"email",header:"Email",cell:({row:e})=>e.original.email||t.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"phone",header:"Phone",cell:({row:e})=>e.original.phone?GNe(e.original.phone):t.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"communicationsSent",id:"communicationsSent",header:"Communications Sent",cell:({row:e})=>{const a=e.original.communicationsSent||[],n=a.filter((e=>e.type===pa.EMAIL)),i=a.filter((e=>e.type===pa.SMS)),r=n.length>0,o=i.length>0,s=n.some((e=>e.delivered)),l=i.some((e=>e.delivered)),u=n.find((e=>e.error))?.error,c=i.find((e=>e.error))?.error,d=n.some((e=>e.skipped)),m=i.some((e=>e.skipped)),h=(e,a,n,i)=>t.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsxs("div",{className:"relative",children:[t.jsx("email"===e?V5.EmailIcon:V5.SmsIcon,{className:"h-4 w-4 "+(n?"text-red-500":i?"text-gray-400":a?"text-green-500":"text-gray-400")}),a&&!n&&!i&&t.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white"}),n&&t.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white"}),i&&t.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-gray-400 ring-1 ring-white"})]}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm font-medium",children:"email"===e?"Email":"SMS"}),t.jsx("span",n?{className:"text-xs text-red-500",children:"Failed"}:i?{className:"text-xs text-gray-500",children:"Skipped"}:{className:"text-xs "+(a?"text-green-600":"text-gray-500"),children:a?"Delivered":"Pending"})]})]});return t.jsxs("div",{className:"flex items-center gap-3",children:[r&&(u?t.jsx(Fue,{title:u,children:h("email",s,u,d)}):h("email",s,u,d)),r&&o&&t.jsx("div",{className:"h-8 w-px bg-gray-200"}),o&&(c?t.jsx(Fue,{title:c,children:h("sms",l,c,m)}):h("sms",l,c,m)),!r&&!o&&t.jsx("span",{className:"text-sm text-gray-400",children:"None"})]})}}];return e&&!c&&u?h?t.jsxs("div",{children:["Error: ",h.message]}):!u||!s&&0===u.results.length?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx("div",{className:"mb-4",children:t.jsx(V5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),t.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Communications Sent Yet"}),t.jsxs("p",{className:"text-gray-500",children:["This"," ",lH(e.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation")," ","hasn't sent any communications yet. Please check back later to see recipient details once communications have been sent."]})]}):t.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:t.jsx("div",{className:"flex-grow min-h-0 p-4",children:t.jsx(vte,{data:u?.results||[],columns:g,paginationMode:"cursor",initialPageSize:n,isLoading:c&&!m,cursorPaginationQueryResult:{nextCursor:u?.pagination.cursor||null,isLoading:c,isFetching:d,isPlaceholderData:m},onQueryParametersChange:p,searchValue:s,onSearchChange:l})})}):t.jsx(lY,{text:["Fetching Recipients","Finishing up"]})},gRe=()=>{const e=B5();return e?e?.triggerType===ua.ONE_TIME&&e?.status===ha.DRAFT?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx("div",{className:"mb-4",children:t.jsx(V5.UserIcon,{className:"h-12 w-12 text-gray-400"})}),t.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Recipients Available Yet"}),t.jsxs("p",{className:"text-gray-500",children:["Recipients will be available once this"," ",lH(e.triggerType===ua.ONE_TIME?"engage:broadcast":"engage:automation")," ","has completed running. Please check back after the automation has finished."]})]}):t.jsx(pRe,{}):t.jsx(lY,{text:["Fetching Recipients","Finishing up"]})},fRe=a.createContext(null);fRe.displayName="PanelGroupContext";const vRe="data-panel-group",yRe="data-panel-group-direction",bRe="data-panel-group-id",kRe="data-panel",SRe="data-panel-collapsible",wRe="data-panel-id",ARe="data-panel-size",CRe="data-resize-handle",MRe="data-resize-handle-active",TRe="data-panel-resize-handle-enabled",xRe="data-panel-resize-handle-id",ERe="data-resize-handle-state",NRe=a.useLayoutEffect,_Re=r["useId".toString()],PRe="function"==typeof _Re?_Re:()=>null;let jRe=0;function LRe(e=null){const t=PRe(),n=a.useRef(e||t||null);return null===n.current&&(n.current=""+jRe++),null!=e?e:n.current}function BRe({children:e,className:t="",collapsedSize:n,collapsible:i,defaultSize:r,forwardedRef:o,id:s,maxSize:l,minSize:u,onCollapse:c,onExpand:d,onResize:m,order:h,style:p,tagName:g="div",...f}){const v=a.useContext(fRe);if(null===v)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:b,getPanelSize:k,getPanelStyle:S,groupId:w,isPanelCollapsed:A,reevaluatePanelConstraints:C,registerPanel:M,resizePanel:T,unregisterPanel:x}=v,E=LRe(s),N=a.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:m},constraints:{collapsedSize:n,collapsible:i,defaultSize:r,maxSize:l,minSize:u},id:E,idIsFromProps:void 0!==s,order:h});a.useRef({didLogMissingDefaultSizeWarning:!1}),NRe((()=>{const{callbacks:e,constraints:a}=N.current,t={...a};N.current.id=E,N.current.idIsFromProps=void 0!==s,N.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=m,a.collapsedSize=n,a.collapsible=i,a.defaultSize=r,a.maxSize=l,a.minSize=u,t.collapsedSize===a.collapsedSize&&t.collapsible===a.collapsible&&t.maxSize===a.maxSize&&t.minSize===a.minSize||C(N.current,t)})),NRe((()=>{const e=N.current;return M(e),()=>{x(e)}}),[h,E,M,x]),a.useImperativeHandle(o,(()=>({collapse:()=>{y(N.current)},expand:e=>{b(N.current,e)},getId:()=>E,getSize:()=>k(N.current),isCollapsed:()=>A(N.current),isExpanded:()=>!A(N.current),resize:e=>{T(N.current,e)}})),[y,b,k,A,E,T]);const _=S(N.current,r);return a.createElement(g,{...f,children:e,className:t,id:E,style:{..._,...p},[bRe]:w,[kRe]:"",[SRe]:i||void 0,[wRe]:E,[ARe]:parseFloat(""+_.flexGrow).toFixed(1)})}const RRe=a.forwardRef(((e,t)=>a.createElement(BRe,{...e,forwardedRef:t})));BRe.displayName="Panel",RRe.displayName="forwardRef(Panel)";let DRe=null,zRe=-1,ORe=null;function KRe(e,a){var t,n;const i=function(e,a){if(a){const e=!!(a&QRe),t=!!(a&XRe);if(a&ZRe)return e?"se-resize":t?"ne-resize":"e-resize";if(a&YRe)return e?"sw-resize":t?"nw-resize":"w-resize";if(e)return"s-resize";if(t)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,a);if(DRe!==i){var r;if(DRe=i,null===ORe&&(ORe=document.createElement("style"),document.head.appendChild(ORe)),zRe>=0)null===(r=ORe.sheet)||void 0===r||r.removeRule(zRe);zRe=null!==(t=null===(n=ORe.sheet)||void 0===n?void 0:n.insertRule(`*{cursor: ${i} !important;}`))&&void 0!==t?t:-1}}function HRe(e){return"keydown"===e.type}function IRe(e){return e.type.startsWith("pointer")}function FRe(e){return e.type.startsWith("mouse")}function GRe(e){if(IRe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(FRe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const VRe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function JRe(e){const a=getComputedStyle(e);return"fixed"===a.position||(!("auto"===a.zIndex||"static"===a.position&&!function(e){var a;const t=getComputedStyle(null!==(a=$Re(e))&&void 0!==a?a:e).display;return"flex"===t||"inline-flex"===t}(e))||(+a.opacity<1||("transform"in a&&"none"!==a.transform||("webkitTransform"in a&&"none"!==a.webkitTransform||("mixBlendMode"in a&&"normal"!==a.mixBlendMode||("filter"in a&&"none"!==a.filter||("webkitFilter"in a&&"none"!==a.webkitFilter||("isolation"in a&&"isolate"===a.isolation||(!!VRe.test(a.willChange)||"touch"===a.webkitOverflowScrolling)))))))))}function URe(e){let a=e.length;for(;a--;){const t=e[a];if(fDe(t,"Missing node"),JRe(t))return t}return null}function WRe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function qRe(e){const a=[];for(;e;)a.push(e),e=$Re(e);return a}function $Re(e){const{parentNode:a}=e;return a&&a instanceof ShadowRoot?a.host:a}const ZRe=1,YRe=2,QRe=4,XRe=8,eDe="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let aDe=[],tDe=!1,nDe=new Map,iDe=new Map;const rDe=new Set;function oDe(e){const{target:a}=e,{x:t,y:n}=GRe(e);tDe=!0,cDe({target:a,x:t,y:n}),pDe(),aDe.length>0&&(gDe("down",e),e.preventDefault(),uDe(a)||e.stopImmediatePropagation())}function sDe(e){const{x:a,y:t}=GRe(e);if(tDe&&0===e.buttons&&(tDe=!1,gDe("up",e)),!tDe){const{target:n}=e;cDe({target:n,x:a,y:t})}gDe("move",e),mDe(),aDe.length>0&&e.preventDefault()}function lDe(e){const{target:a}=e,{x:t,y:n}=GRe(e);iDe.clear(),tDe=!1,aDe.length>0&&(e.preventDefault(),uDe(a)||e.stopImmediatePropagation()),gDe("up",e),cDe({target:a,x:t,y:n}),mDe(),pDe()}function uDe(e){let a=e;for(;a;){if(a.hasAttribute(CRe))return!0;a=a.parentElement}return!1}function cDe({target:e,x:a,y:t}){aDe.splice(0);let n=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(n=e),rDe.forEach((e=>{const{element:i,hitAreaMargins:r}=e,o=i.getBoundingClientRect(),{bottom:s,left:l,right:u,top:c}=o,d=eDe?r.coarse:r.fine;if(a>=l-d&&a<=u+d&&t>=c-d&&t<=s+d){if(null!==n&&document.contains(n)&&i!==n&&!i.contains(n)&&!n.contains(i)&&function(e,a){if(e===a)throw new Error("Cannot compare node with itself");const t={a:qRe(e),b:qRe(a)};let n;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),a=t.b.pop(),n=e;fDe(n,"Stacking order can only be calculated for elements with a common ancestor");const i=WRe(URe(t.a)),r=WRe(URe(t.b));if(i===r){const e=n.childNodes,a={a:t.a.at(-1),b:t.b.at(-1)};let i=e.length;for(;i--;){const t=e[i];if(t===a.a)return 1;if(t===a.b)return-1}}return Math.sign(i-r)}(n,i)>0){let e=n,a=!1;for(;e&&!e.contains(i);){if((m=e.getBoundingClientRect()).x<(h=o).x+h.width&&m.x+m.width>h.x&&m.y<h.y+h.height&&m.y+m.height>h.y){a=!0;break}e=e.parentElement}if(a)return}aDe.push(e)}var m,h}))}function dDe(e,a){iDe.set(e,a)}function mDe(){let e=!1,a=!1;aDe.forEach((t=>{const{direction:n}=t;"horizontal"===n?e=!0:a=!0}));let t=0;iDe.forEach((e=>{t|=e})),e&&a?KRe("intersection",t):e?KRe("horizontal",t):a?KRe("vertical",t):null!==ORe&&(document.head.removeChild(ORe),DRe=null,ORe=null,zRe=-1)}let hDe=new AbortController;function pDe(){hDe.abort(),hDe=new AbortController;const e={capture:!0,signal:hDe.signal};rDe.size&&(tDe?(aDe.length>0&&nDe.forEach(((a,t)=>{const{body:n}=t;a>0&&(n.addEventListener("contextmenu",lDe,e),n.addEventListener("pointerleave",sDe,e),n.addEventListener("pointermove",sDe,e))})),nDe.forEach(((a,t)=>{const{body:n}=t;n.addEventListener("pointerup",lDe,e),n.addEventListener("pointercancel",lDe,e)}))):nDe.forEach(((a,t)=>{const{body:n}=t;a>0&&(n.addEventListener("pointerdown",oDe,e),n.addEventListener("pointermove",sDe,e))})))}function gDe(e,a){rDe.forEach((t=>{const{setResizeHandlerState:n}=t,i=aDe.includes(t);n(e,i,a)}))}function fDe(e,a){if(!e)throw Error(a)}function vDe(e,a,t=10){return e.toFixed(t)===a.toFixed(t)?0:e>a?1:-1}function yDe(e,a,t=10){return 0===vDe(e,a,t)}function bDe(e,a,t){return 0===vDe(e,a,t)}function kDe({panelConstraints:e,panelIndex:a,size:t}){const n=e[a];fDe(null!=n,`Panel constraints not found for index ${a}`);let{collapsedSize:i=0,collapsible:r,maxSize:o=100,minSize:s=0}=n;if(vDe(t,s)<0)if(r){t=vDe(t,(i+s)/2)<0?i:s}else t=s;return t=Math.min(o,t),t=parseFloat(t.toFixed(10))}function SDe({delta:e,initialLayout:a,panelConstraints:t,pivotIndices:n,prevLayout:i,trigger:r}){if(bDe(e,0))return a;const o=[...a],[s,l]=n;fDe(null!=s,"Invalid first pivot index"),fDe(null!=l,"Invalid second pivot index");let u=0;if("keyboard"===r){{const n=e<0?l:s,i=t[n];fDe(i,`Panel constraints not found for index ${n}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const t=a[n];if(fDe(null!=t,`Previous layout not found for panel index ${n}`),bDe(t,r)){const a=u-t;vDe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}{const n=e<0?s:l,i=t[n];fDe(i,`No panel constraints found for index ${n}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const t=a[n];if(fDe(null!=t,`Previous layout not found for panel index ${n}`),bDe(t,u)){const a=t-r;vDe(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}}{const n=e<0?1:-1;let i=e<0?l:s,r=0;for(;;){const e=a[i];fDe(null!=e,`Previous layout not found for panel index ${i}`);if(r+=kDe({panelConstraints:t,panelIndex:i,size:100})-e,i+=n,i<0||i>=t.length)break}const o=Math.min(Math.abs(e),Math.abs(r));e=e<0?0-o:o}{let n=e<0?s:l;for(;n>=0&&n<t.length;){const i=Math.abs(e)-Math.abs(u),r=a[n];fDe(null!=r,`Previous layout not found for panel index ${n}`);const s=kDe({panelConstraints:t,panelIndex:n,size:r-i});if(!bDe(r,s)&&(u+=r-s,o[n]=s,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?n--:n++}}if(function(e,a,t){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(!bDe(e[n],a[n],t))return!1;return!0}(i,o))return i;{const n=e<0?l:s,i=a[n];fDe(null!=i,`Previous layout not found for panel index ${n}`);const r=i+u,c=kDe({panelConstraints:t,panelIndex:n,size:r});if(o[n]=c,!bDe(c,r)){let a=r-c;let n=e<0?l:s;for(;n>=0&&n<t.length;){const i=o[n];fDe(null!=i,`Previous layout not found for panel index ${n}`);const r=kDe({panelConstraints:t,panelIndex:n,size:i+a});if(bDe(i,r)||(a-=r-i,o[n]=r),bDe(a,0))break;e>0?n--:n++}}}return bDe(o.reduce(((e,a)=>a+e),0),100)?o:i}function wDe({layout:e,panelsArray:a,pivotIndices:t}){let n=0,i=100,r=0,o=0;const s=t[0];fDe(null!=s,"No pivot index found"),a.forEach(((e,a)=>{const{constraints:t}=e,{maxSize:l=100,minSize:u=0}=t;a===s?(n=u,i=l):(r+=u,o+=l)}));return{valueMax:Math.min(i,100-r),valueMin:Math.max(n,100-o),valueNow:e[s]}}function ADe(e,a=document){return Array.from(a.querySelectorAll(`[${xRe}][data-panel-group-id="${e}"]`))}function CDe(e,a,t=document){const n=ADe(e,t).findIndex((e=>e.getAttribute(xRe)===a));return null!=n?n:null}function MDe(e,a,t){const n=CDe(e,a,t);return null!=n?[n,n+1]:[-1,-1]}function TDe(e,a=document){var t;if(a instanceof HTMLElement&&(null==a||null===(t=a.dataset)||void 0===t?void 0:t.panelGroupId)==e)return a;const n=a.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function xDe(e,a=document){const t=a.querySelector(`[${xRe}="${e}"]`);return t||null}function EDe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:i,panelDataArray:r,panelGroupElement:o,setLayout:s}){a.useRef({didWarnAboutMissingResizeHandle:!1}),NRe((()=>{if(!o)return;const e=ADe(n,o);for(let a=0;a<r.length-1;a++){const{valueMax:t,valueMin:n,valueNow:o}=wDe({layout:i,panelsArray:r,pivotIndices:[a,a+1]}),s=e[a];if(null==s);else{const e=r[a];fDe(e,`No panel data found for index "${a}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(t)),s.setAttribute("aria-valuemin",""+Math.round(n)),s.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach(((e,a)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,i,r,o]),a.useEffect((()=>{if(!o)return;const e=t.current;fDe(e,"Eager values not found");const{panelDataArray:a}=e;fDe(null!=TDe(n,o),`No group found for id "${n}"`);const r=ADe(n,o);fDe(r,`No resize handles found for group id "${n}"`);const l=r.map((e=>{const t=e.getAttribute(xRe);fDe(t,"Resize handle element has no handle id attribute");const[r,l]=function(e,a,t,n=document){var i,r,o,s;const l=xDe(a,n),u=ADe(e,n),c=l?u.indexOf(l):-1;return[null!==(i=null===(r=t[c])||void 0===r?void 0:r.id)&&void 0!==i?i:null,null!==(o=null===(s=t[c+1])||void 0===s?void 0:s.id)&&void 0!==o?o:null]}(n,t,a,o);if(null==r||null==l)return()=>{};const u=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=a.findIndex((e=>e.id===r));if(l>=0){const e=a[l];fDe(e,`No panel data found for index ${l}`);const r=i[l],{collapsedSize:u=0,collapsible:c,minSize:d=0}=e.constraints;if(null!=r&&c){const e=SDe({delta:bDe(r,u)?d-u:u-r,initialLayout:i,panelConstraints:a.map((e=>e.constraints)),pivotIndices:MDe(n,t,o),prevLayout:i,trigger:"keyboard"});i!==e&&s(e)}}break}}};return e.addEventListener("keydown",u),()=>{e.removeEventListener("keydown",u)}}));return()=>{l.forEach((e=>e()))}}),[o,e,t,n,i,r,s])}function NDe(e,a){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==a[t])return!1;return!0}function _De(e,a){const t="horizontal"===e,{x:n,y:i}=GRe(a);return t?n:i}function PDe(e,a,t,n,i,r){if(HRe(e)){const a="horizontal"===t;let n=0;n=e.shiftKey?100:null!=i?i:10;let r=0;switch(e.key){case"ArrowDown":r=a?0:n;break;case"ArrowLeft":r=a?-n:0;break;case"ArrowRight":r=a?n:0;break;case"ArrowUp":r=a?0:-n;break;case"End":r=100;break;case"Home":r=-100}return r}return null==n?0:function(e,a,t,n,i){const r="horizontal"===t,o=xDe(a,i);fDe(o,`No resize handle element found for id "${a}"`);const s=o.getAttribute(bRe);fDe(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=n;const u=_De(t,e),c=TDe(s,i);fDe(c,`No group element found for id "${s}"`);const d=c.getBoundingClientRect();return(u-l)/(r?d.width:d.height)*100}(e,a,t,n,r)}function jDe(e,a,t){a.forEach(((a,n)=>{const i=e[n];fDe(i,`Panel data not found for index ${n}`);const{callbacks:r,constraints:o,id:s}=i,{collapsedSize:l=0,collapsible:u}=o,c=t[s];if(null==c||a!==c){t[s]=a;const{onCollapse:e,onExpand:n,onResize:i}=r;i&&i(a,c),u&&(e||n)&&(!n||null!=c&&!yDe(c,l)||yDe(a,l)||n(),!e||null!=c&&yDe(c,l)||!yDe(a,l)||e())}}))}function LDe(e,a){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=a[t])return!1;return!0}function BDe(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,a)=>{localStorage.setItem(e,a)}}catch(a){e.getItem=()=>null,e.setItem=()=>{}}}function RDe(e){return`react-resizable-panels:${e}`}function DDe(e){return e.map((e=>{const{constraints:a,id:t,idIsFromProps:n,order:i}=e;return n?t:i?`${i}:${JSON.stringify(a)}`:JSON.stringify(a)})).sort(((e,a)=>e.localeCompare(a))).join(",")}function zDe(e,a){try{const t=RDe(e),n=a.getItem(t);if(n){const e=JSON.parse(n);if("object"==typeof e&&null!=e)return e}}catch(t){}return null}function ODe(e,a,t,n,i){var r;const o=RDe(e),s=DDe(a),l=null!==(r=zDe(e,i))&&void 0!==r?r:{};l[s]={expandToSizes:Object.fromEntries(t.entries()),layout:n};try{i.setItem(o,JSON.stringify(l))}catch(u){}}function KDe({layout:e,panelConstraints:a}){const t=[...e],n=t.reduce(((e,a)=>e+a),0);if(t.length!==a.length)throw Error(`Invalid ${a.length} panel layout: ${t.map((e=>`${e}%`)).join(", ")}`);if(!bDe(n,100)&&t.length>0)for(let r=0;r<a.length;r++){const e=t[r];fDe(null!=e,`No layout data found for index ${r}`);t[r]=100/n*e}let i=0;for(let r=0;r<a.length;r++){const e=t[r];fDe(null!=e,`No layout data found for index ${r}`);const n=kDe({panelConstraints:a,panelIndex:r,size:e});e!=n&&(i+=e-n,t[r]=n)}if(!bDe(i,0))for(let r=0;r<a.length;r++){const e=t[r];fDe(null!=e,`No layout data found for index ${r}`);const n=kDe({panelConstraints:a,panelIndex:r,size:e+i});if(e!==n&&(i-=n-e,t[r]=n,bDe(i,0)))break}return t}const HDe={getItem:e=>(BDe(HDe),HDe.getItem(e)),setItem:(e,a)=>{BDe(HDe),HDe.setItem(e,a)}},IDe={};function FDe({autoSaveId:e=null,children:t,className:n="",direction:i,forwardedRef:r,id:o=null,onLayout:s=null,keyboardResizeBy:l=null,storage:u=HDe,style:c,tagName:d="div",...m}){const h=LRe(o),p=a.useRef(null),[g,f]=a.useState(null),[v,y]=a.useState([]),b=function(){const[e,t]=a.useState(0);return a.useCallback((()=>t((e=>e+1))),[])}(),k=a.useRef({}),S=a.useRef(new Map),w=a.useRef(0),A=a.useRef({autoSaveId:e,direction:i,dragState:g,id:h,keyboardResizeBy:l,onLayout:s,storage:u}),C=a.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});a.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),a.useImperativeHandle(r,(()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:a}=A.current,{layout:t,panelDataArray:n}=C.current,i=KDe({layout:e,panelConstraints:n.map((e=>e.constraints))});NDe(t,i)||(y(i),C.current.layout=i,a&&a(i),jDe(n,i,k.current))}})),[]),NRe((()=>{A.current.autoSaveId=e,A.current.direction=i,A.current.dragState=g,A.current.id=h,A.current.onLayout=s,A.current.storage=u})),EDe({committedValuesRef:A,eagerValuesRef:C,groupId:h,layout:v,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),a.useEffect((()=>{const{panelDataArray:a}=C.current;if(e){if(0===v.length||v.length!==a.length)return;let t=IDe[e];null==t&&(t=function(e,a=10){let t=null;return(...n)=>{null!==t&&clearTimeout(t),t=setTimeout((()=>{e(...n)}),a)}}(ODe,100),IDe[e]=t);const n=[...a],i=new Map(S.current);t(e,n,i,v,u)}}),[e,v,u]),a.useEffect((()=>{}));const M=a.useCallback((e=>{const{onLayout:a}=A.current,{layout:t,panelDataArray:n}=C.current;if(e.constraints.collapsible){const i=n.map((e=>e.constraints)),{collapsedSize:r=0,panelSize:o,pivotIndices:s}=JDe(n,e,t);if(fDe(null!=o,`Panel size not found for panel "${e.id}"`),!yDe(o,r)){S.current.set(e.id,o);const l=SDe({delta:VDe(n,e)===n.length-1?o-r:r-o,initialLayout:t,panelConstraints:i,pivotIndices:s,prevLayout:t,trigger:"imperative-api"});LDe(t,l)||(y(l),C.current.layout=l,a&&a(l),jDe(n,l,k.current))}}}),[]),T=a.useCallback(((e,a)=>{const{onLayout:t}=A.current,{layout:n,panelDataArray:i}=C.current;if(e.constraints.collapsible){const r=i.map((e=>e.constraints)),{collapsedSize:o=0,panelSize:s=0,minSize:l=0,pivotIndices:u}=JDe(i,e,n),c=null!=a?a:l;if(yDe(s,o)){const a=S.current.get(e.id),o=null!=a&&a>=c?a:c,l=SDe({delta:VDe(i,e)===i.length-1?s-o:o-s,initialLayout:n,panelConstraints:r,pivotIndices:u,prevLayout:n,trigger:"imperative-api"});LDe(n,l)||(y(l),C.current.layout=l,t&&t(l),jDe(i,l,k.current))}}}),[]),x=a.useCallback((e=>{const{layout:a,panelDataArray:t}=C.current,{panelSize:n}=JDe(t,e,a);return fDe(null!=n,`Panel size not found for panel "${e.id}"`),n}),[]),E=a.useCallback(((e,a)=>{const{panelDataArray:t}=C.current,n=VDe(t,e);return function({defaultSize:e,dragState:a,layout:t,panelData:n,panelIndex:i,precision:r=3}){const o=t[i];let s;return s=null==o?null!=e?e.toPrecision(r):"1":1===n.length?"1":o.toPrecision(r),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==a?"none":void 0}}({defaultSize:a,dragState:g,layout:v,panelData:t,panelIndex:n})}),[g,v]),N=a.useCallback((e=>{const{layout:a,panelDataArray:t}=C.current,{collapsedSize:n=0,collapsible:i,panelSize:r}=JDe(t,e,a);return fDe(null!=r,`Panel size not found for panel "${e.id}"`),!0===i&&yDe(r,n)}),[]),_=a.useCallback((e=>{const{layout:a,panelDataArray:t}=C.current,{collapsedSize:n=0,collapsible:i,panelSize:r}=JDe(t,e,a);return fDe(null!=r,`Panel size not found for panel "${e.id}"`),!i||vDe(r,n)>0}),[]),P=a.useCallback((e=>{const{panelDataArray:a}=C.current;a.push(e),a.sort(((e,a)=>{const t=e.order,n=a.order;return null==t&&null==n?0:null==t?-1:null==n?1:t-n})),C.current.panelDataArrayChanged=!0,b()}),[b]);NRe((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:a,storage:t}=A.current,{layout:n,panelDataArray:i}=C.current;let r=null;if(e){const a=function(e,a,t){var n,i;return null!==(i=(null!==(n=zDe(e,t))&&void 0!==n?n:{})[DDe(a)])&&void 0!==i?i:null}(e,i,t);a&&(S.current=new Map(Object.entries(a.expandToSizes)),r=a.layout)}null==r&&(r=function({panelDataArray:e}){const a=Array(e.length),t=e.map((e=>e.constraints));let n=0,i=100;for(let r=0;r<e.length;r++){const e=t[r];fDe(e,`Panel constraints not found for index ${r}`);const{defaultSize:o}=e;null!=o&&(n++,a[r]=o,i-=o)}for(let r=0;r<e.length;r++){const o=t[r];fDe(o,`Panel constraints not found for index ${r}`);const{defaultSize:s}=o;if(null!=s)continue;const l=i/(e.length-n);n++,a[r]=l,i-=l}return a}({panelDataArray:i}));const o=KDe({layout:r,panelConstraints:i.map((e=>e.constraints))});NDe(n,o)||(y(o),C.current.layout=o,a&&a(o),jDe(i,o,k.current))}})),NRe((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const j=a.useCallback((e=>{let a=!1;const t=p.current;if(t){"rtl"===window.getComputedStyle(t,null).getPropertyValue("direction")&&(a=!0)}return function(t){t.preventDefault();const n=p.current;if(!n)return()=>null;const{direction:i,dragState:r,id:o,keyboardResizeBy:s,onLayout:l}=A.current,{layout:u,panelDataArray:c}=C.current,{initialLayout:d}=null!=r?r:{},m=MDe(o,e,n);let h=PDe(t,e,i,r,s,n);const g="horizontal"===i;g&&a&&(h=-h);const f=SDe({delta:h,initialLayout:null!=d?d:u,panelConstraints:c.map((e=>e.constraints)),pivotIndices:m,prevLayout:u,trigger:HRe(t)?"keyboard":"mouse-or-touch"}),v=!LDe(u,f);(IRe(t)||FRe(t))&&w.current!=h&&(w.current=h,dDe(e,v||0===h?0:g?h<0?ZRe:YRe:h<0?QRe:XRe)),v&&(y(f),C.current.layout=f,l&&l(f),jDe(c,f,k.current))}}),[]),L=a.useCallback(((e,a)=>{const{onLayout:t}=A.current,{layout:n,panelDataArray:i}=C.current,r=i.map((e=>e.constraints)),{panelSize:o,pivotIndices:s}=JDe(i,e,n);fDe(null!=o,`Panel size not found for panel "${e.id}"`);const l=SDe({delta:VDe(i,e)===i.length-1?o-a:a-o,initialLayout:n,panelConstraints:r,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});LDe(n,l)||(y(l),C.current.layout=l,t&&t(l),jDe(i,l,k.current))}),[]),B=a.useCallback(((e,a)=>{const{layout:t,panelDataArray:n}=C.current,{collapsedSize:i=0,collapsible:r}=a,{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:u=0}=e.constraints,{panelSize:c}=JDe(n,e,t);null!=c&&(r&&s&&yDe(c,i)?yDe(i,o)||L(e,o):c<u?L(e,u):c>l&&L(e,l))}),[L]),R=a.useCallback(((e,a)=>{const{direction:t}=A.current,{layout:n}=C.current;if(!p.current)return;const i=xDe(e,p.current);fDe(i,`Drag handle element not found for id "${e}"`);const r=_De(t,a);f({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:r,initialLayout:n})}),[]),D=a.useCallback((()=>{f(null)}),[]),z=a.useCallback((e=>{const{panelDataArray:a}=C.current,t=VDe(a,e);t>=0&&(a.splice(t,1),delete k.current[e.id],C.current.panelDataArrayChanged=!0,b())}),[b]),O=a.useMemo((()=>({collapsePanel:M,direction:i,dragState:g,expandPanel:T,getPanelSize:x,getPanelStyle:E,groupId:h,isPanelCollapsed:N,isPanelExpanded:_,reevaluatePanelConstraints:B,registerPanel:P,registerResizeHandle:j,resizePanel:L,startDragging:R,stopDragging:D,unregisterPanel:z,panelGroupElement:p.current})),[M,g,i,T,x,E,h,N,_,B,P,j,L,R,D,z]);return a.createElement(fRe.Provider,{value:O},a.createElement(d,{...m,children:t,className:n,id:o,ref:p,style:{...{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%"},...c},[vRe]:"",[yRe]:i,[bRe]:h}))}const GDe=a.forwardRef(((e,t)=>a.createElement(FDe,{...e,forwardedRef:t})));function VDe(e,a){return e.findIndex((e=>e===a||e.id===a.id))}function JDe(e,a,t){const n=VDe(e,a);return{...a.constraints,panelSize:t[n],pivotIndices:n===e.length-1?[n-1,n]:[n,n+1]}}function UDe({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:i,id:r,onBlur:o,onClick:s,onDragging:l,onFocus:u,onPointerDown:c,onPointerUp:d,style:m={},tabIndex:h=0,tagName:p="div",...g}){var f,v;const y=a.useRef(null),b=a.useRef({onClick:s,onDragging:l,onPointerDown:c,onPointerUp:d});a.useEffect((()=>{b.current.onClick=s,b.current.onDragging=l,b.current.onPointerDown=c,b.current.onPointerUp=d}));const k=a.useContext(fRe);if(null===k)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:w,registerResizeHandle:A,startDragging:C,stopDragging:M,panelGroupElement:T}=k,x=LRe(r),[E,N]=a.useState("inactive"),[_,P]=a.useState(!1),[j,L]=a.useState(null),B=a.useRef({state:E});NRe((()=>{B.current.state=E})),a.useEffect((()=>{if(n)L(null);else{const e=A(x);L((()=>e))}}),[n,x,A]);const R=null!==(f=null==i?void 0:i.coarse)&&void 0!==f?f:15,D=null!==(v=null==i?void 0:i.fine)&&void 0!==v?v:5;a.useEffect((()=>{if(n||null==j)return;const e=y.current;fDe(e,"Element ref not attached");let a=!1;return function(e,a,t,n,i){var r;const{ownerDocument:o}=a,s={direction:t,element:a,hitAreaMargins:n,setResizeHandlerState:i},l=null!==(r=nDe.get(o))&&void 0!==r?r:0;return nDe.set(o,l+1),rDe.add(s),pDe(),function(){var a;iDe.delete(e),rDe.delete(s);const t=null!==(a=nDe.get(o))&&void 0!==a?a:1;if(nDe.set(o,t-1),pDe(),1===t&&nDe.delete(o),aDe.includes(s)){const e=aDe.indexOf(s);e>=0&&aDe.splice(e,1),mDe(),i("up",!0,null)}}}(x,e,S,{coarse:R,fine:D},((e,t,n)=>{if(t)switch(e){case"down":{N("drag"),a=!1,fDe(n,'Expected event to be defined for "down" action'),C(x,n);const{onDragging:e,onPointerDown:t}=b.current;null==e||e(!0),null==t||t();break}case"move":{const{state:e}=B.current;a=!0,"drag"!==e&&N("hover"),fDe(n,'Expected event to be defined for "move" action'),j(n);break}case"up":{N("hover"),M();const{onClick:e,onDragging:t,onPointerUp:n}=b.current;null==t||t(!1),null==n||n(),a||null==e||e();break}}else N("inactive")}))}),[R,S,n,D,A,x,j,C,M]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:i}){a.useEffect((()=>{if(e||null==n||null==i)return;const a=xDe(t,i);if(null==a)return;const r=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=a.getAttribute(bRe);fDe(n,`No group element found for id "${n}"`);const r=ADe(n,i),o=CDe(n,t,i);fDe(null!==o,`No resize element found for id "${t}"`),r[e.shiftKey?o>0?o-1:r.length-1:o+1<r.length?o+1:0].focus();break}}};return a.addEventListener("keydown",r),()=>{a.removeEventListener("keydown",r)}}),[i,e,t,n])}({disabled:n,handleId:x,resizeHandler:j,panelGroupElement:T});return a.createElement(p,{...g,children:e,className:t,id:r,onBlur:()=>{P(!1),null==o||o()},onFocus:()=>{P(!0),null==u||u()},ref:y,role:"separator",style:{touchAction:"none",userSelect:"none",...m},tabIndex:h,[yRe]:S,[bRe]:w,[CRe]:"",[MRe]:"drag"===E?"pointer":_?"keyboard":void 0,[TRe]:!n,[xRe]:x,[ERe]:E})}FDe.displayName="PanelGroup",GDe.displayName="forwardRef(PanelGroup)",UDe.displayName="PanelResizeHandle";const WDe=({className:e,...a})=>t.jsx(GDe,{className:$Z("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),qDe=RRe,$De=({withHandle:e,className:a,...n})=>t.jsx(UDe,{className:$Z("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",a),...n,children:e&&t.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:t.jsx(kz,{className:"h-2.5 w-2.5"})})}),ZDe=({copyText:e})=>t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),YDe="rgba(245, 246, 247, 1)",QDe={[ma.SEND_COMMUNICATION]:{color:{bg:YDe},clickable:!0},[ma.WAIT_UNTIL_NEXT_FIXED_TIME]:{color:{bg:YDe},clickable:!1}},XDe={[ma.SEND_COMMUNICATION]:"Send Email & SMS",[ma.WAIT_UNTIL_NEXT_FIXED_TIME]:"Wait"},eze=({children:e,onClick:a,iconBgColor:n,iconStrokeColor:i,Icon:r,disabled:o=!1,selected:s=!1})=>{const l=r;return t.jsxs(o5.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},style:{backgroundColor:s?n:YDe},onClick:a,className:XO("flex gap-2 items-center rounded-md transition-colors group","p-2 border-2 border-transparent overflow-hidden",!o&&"hover:border-primary cursor-pointer",s&&"border-primary"),children:[t.jsx("div",{className:XO("bg-purple-50 rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 transition-colors",!o&&"group-hover/trigger-audience:bg-background",n),children:t.jsx(l,{className:XO("w-4 h-4 stroke-purple-500 group-hover/trigger-audience:fill-purple-50 transition-colors",i)})}),e]})},aze=({segmentName:e})=>t.jsx("span",{className:"inline-flex items-center bg-white border border-gray-200 rounded-md px-2 py-0.5 text-sm font-medium shadow-sm",children:e}),tze=()=>{const e=B5(),{setActionId:n,state:{selectedActionId:i}}=a.useContext(S5),[r,o]=a.useState(e?.includeSegmentIds||null),[s,l]=a.useState(e?.excludeSegmentIds||null),{segments:u}=T5(),c=a.useCallback((()=>u?.find((e=>e.type===P5.ALL_USERS))),[u]);return a.useEffect((()=>{e&&u&&(null===r&&null===s?(o(e?.includeSegmentIds||null),l(e?.excludeSegmentIds||null),0===e.includeSegmentIds.length&&0===e.excludeSegmentIds.length&&(o([c()?.id||""]),l([]))):(JSON.stringify(e.includeSegmentIds)!==JSON.stringify(r)&&o(e.includeSegmentIds),JSON.stringify(e.excludeSegmentIds)!==JSON.stringify(s)&&l(e.excludeSegmentIds)))}),[e,s,r,u,c]),e&&r&&s?t.jsx(t.Fragment,{children:t.jsx(eze,{selected:i===Gwe.EditAudience,iconBgColor:"bg-purple-50",iconStrokeColor:"stroke-purple-500",onClick:()=>{n(Gwe.EditAudience)},Icon:V5.AudienceIcon,children:t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:"Audience"}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ZDe,{copyText:`Send to all ${lH("engage:user",{count:2})} in ${1===r.length?"this":"these"} ${lH("engage:segment",{count:r.length}).toLowerCase()}`}),t.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map((e=>{const a=u?.find((a=>a.id===e));return a?t.jsx(aze,{segmentName:a.name},e):null}))})]})]})})}):null},nze=()=>{const e=B5(),{setActionId:n,state:{selectedActionId:i}}=a.useContext(S5),{segments:r}=T5(),o=lH(e?.triggerType===ua.TRIGGER_BASED?"engage:automation":"engage:broadcast"),s=`Start this ${o?.toLowerCase()}`,l=`Start this ${lH("engage:automation").toLowerCase()}`;if(!e||!r)return null;return t.jsx(t.Fragment,{children:(()=>{switch(e.triggerType){case ua.DATE_BASED:{if(!e.triggerMetadata||!("monthToTrigger"in e.triggerMetadata)||!("dayToTrigger"in e.triggerMetadata))return null;const a=e.triggerMetadata?.monthToTrigger,n=e.triggerMetadata?.dayToTrigger;let i="Date not set";if(a&&n){i=`${new Date(2024,a-1,n).toLocaleDateString("en-US",{month:"long"})} ${n}`}return t.jsx(eze,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:V5.TriggerIcon,children:t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:l}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.jsx(ZDe,{copyText:e.triggerMetadata.customTriggerCopy??`Every year on ${i}`})})]})})}case ua.TRIGGER_BASED:{if(e.triggerMetadata&&e.triggerMetadata.triggerType!==ua.TRIGGER_BASED||!e.triggerMetadata||e.triggerMetadata.eventName!==ca.USER_ENTERS_SEGMENT||!e.triggerMetadata.eventFilter.segment_id)return null;const a=e.triggerMetadata.eventFilter.segment_id,n=r.find((e=>e.id===a))?.name;return n?t.jsx(eze,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:V5.TriggerIcon,children:t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:s}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.triggerMetadata.customTriggerCopy?t.jsx(ZDe,{copyText:e.triggerMetadata.customTriggerCopy}):t.jsxs(t.Fragment,{children:[t.jsx(ZDe,{copyText:`When ${lH("engage:user").toLowerCase()} joins the`}),t.jsx(aze,{segmentName:n})]})})]})}):null}case ua.ONE_TIME:{const a=!e.triggerMetadata||!("scheduledAt"in e.triggerMetadata);return t.jsxs(eze,{iconBgColor:"bg-amber-100",iconStrokeColor:"stroke-amber-500",onClick:()=>{n(Gwe.EditTime)},selected:i===Gwe.EditTime,Icon:V5.TriggerIcon,children:[t.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[t.jsx(i_e,{children:s}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ZDe,a?{copyText:`Click to set the date and time for this ${lH("engage:broadcast")}`}:{copyText:"Bulk send at"}),!1===a&&e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&e.triggerMetadata.scheduledAt&&t.jsx("div",{className:"text-xs font-medium",children:t.jsx(aze,{segmentName:"now"===e.triggerMetadata.scheduledAt?"immediately":Eue(new Date(e.triggerMetadata.scheduledAt),"h:mma MM/dd/yy")})})]})]}),t.jsx("div",{className:"",children:a&&t.jsx(Fue,{title:`Please select a time before sending this ${lH("engage:broadcast")}.`,alertText:`A scheduled time is needed before sending this ${lH("engage:broadcast")}.`,Icon:V5.AlertTriangleIcon,iconColor:"text-red-500",size:"large"})})]})}default:throw jre(e.triggerType,ua)}})()})};var ize=r.forwardRef(((e,a)=>{const{children:n,...i}=e,o=r.Children.toArray(n),s=o.find(sze);if(s){const e=s.props.children,n=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return t.jsx(rze,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,n):null})}return t.jsx(rze,{...i,ref:a,children:n})}));ize.displayName="Slot";var rze=r.forwardRef(((e,a)=>{const{children:t,...n}=e;if(r.isValidElement(t)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning;if(t)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=a&&"isReactWarning"in a&&a.isReactWarning,t)return e.props.ref;return e.props.ref||e.ref}(t),i=function(e,a){const t={...a};for(const n in a){const i=e[n],r=a[n];/^on[A-Z]/.test(n)?i&&r?t[n]=(...e)=>{r(...e),i(...e)}:i&&(t[n]=i):"style"===n?t[n]={...i,...r}:"className"===n&&(t[n]=[i,r].filter(Boolean).join(" "))}return{...e,...t}}(n,t.props);return t.type!==r.Fragment&&(i.ref=a?IZ(a,e):e),r.cloneElement(t,i)}return r.Children.count(t)>1?r.Children.only(null):null}));rze.displayName="SlotClone";var oze=({children:e})=>t.jsx(t.Fragment,{children:e});function sze(e){return r.isValidElement(e)&&e.type===oze}var lze=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const n=r.forwardRef(((e,n)=>{const{asChild:i,...r}=e,o=i?ize:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(o,{...r,ref:n})}));return n.displayName=`Primitive.${a}`,{...e,[a]:n}}),{}),uze=r.forwardRef(((e,a)=>{const{pressed:n,defaultPressed:i=!1,onPressedChange:r,...o}=e,[s=!1,l]=m9({prop:n,onChange:r,defaultProp:i});return t.jsx(lze.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...o,ref:a,onClick:l9(e.onClick,(()=>{e.disabled||l(!s)}))})}));uze.displayName="Toggle";var cze=uze;const dze=GD("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),mze=r.forwardRef((({className:e,variant:a,size:n,...i},r)=>t.jsx(cze,{ref:r,className:$Z(dze({variant:a,size:n,className:e})),...i})));mze.displayName=cze.displayName;const hze=({type:e,disabled:n=!1,actionId:i})=>{const{state:{selectedSubStepType:r},setSelectedSubStepType:o,setActionId:s}=a.useContext(S5),l=R5(),{updateCommunicationGroup:u,isUpdating:c}=Ye(),{channelSenders:d}=Jre(),{channelAccounts:m}=Fre(),{data:h}=$re(),{toast:p}=Ve(),{getMergeFields:g,isGetting:f}=Qe(l?.id??void 0),v=r===e,y=a.useMemo((()=>d?.results?.filter((e=>e.channelSenderMetadata.userPart))||[]),[d?.results]),b=a.useMemo((()=>Nle({channelSenders:d?.results??[],channelAccounts:m?.results??[],smsApplication:h})),[d?.results,m?.results,h]),k=a.useCallback((()=>{if(!l)return!1;switch(e){case Vwe.EMAIL:return!!l.emailChannelSenderId;case Vwe.SMS:return!!l.smsChannelSenderId}}),[l,e])(),S=a.useMemo((()=>{if(!l)return!1;return 1===[!!l.emailChannelSenderId,!!l.smsChannelSenderId].filter(Boolean).length&&k}),[l,k]),w=a.useCallback((async()=>{if(l?.id&&!c)if(k&&S)p({title:"Cannot disable channel",description:"At least one channel must remain enabled",variant:"destructive"});else try{const a={};switch(e){case Vwe.EMAIL:if(k&&l.emailChannelSenderId)a.emailChannelSenderId=null;else{const e=y[0];e&&(a.emailChannelSenderId=e.id)}break;case Vwe.SMS:if(k&&l.smsChannelSenderId)a.smsChannelSenderId=null;else{const e=b[0];e&&(a.smsChannelSenderId=e.channelSender.id)}}await u({groupId:l.id,params:a})}catch(a){}}),[l,k,e,u,c,y,b,p,S]),A=a.useCallback((()=>{if(!l)return"Need to select a channel";switch(e){case Vwe.EMAIL:return l.emailChannelSenderId?l.emailHtmlBody?!!l.emailSubject||"Please add a subject to the email":"Please add content to the email":"Please select a email sender";case Vwe.SMS:return l.smsChannelSenderId?!!l.smsMessageBody||"Please add content to the sms":"Please select a sms sender"}}),[l,e])();return t.jsxs(o5.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15,ease:"easeInOut"},className:XO("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group","border-2 border-transparent",v&&"border-primary",!n&&"hover:border-muted-foreground/30",n&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:v?"#f5f6f7":YDe},onClick:a=>{a.target.closest("button")||n||(s(i),o(e))},children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("div",{className:"rounded-md p-1.5 flex items-center justify-center w-6 h-6 flex-shrink-0 bg-white border",children:((e,a)=>{switch(e){case Vwe.EMAIL:return t.jsx(V5.EmailIcon,{className:XO("w-6 h-6",a?"text-primary":"text-gray-400")});case Vwe.SMS:return t.jsx(V5.SmsIcon,{className:XO("w-6 h-6",a?"text-primary":"text-gray-400")})}})(e,v)}),t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("div",{style:{color:v?"#3b82f6":"#64748b"},children:t.jsx(i_e,{className:"text-xs",children:(()=>{switch(e){case Vwe.EMAIL:return"Email";case Vwe.SMS:return"SMS"}})()})}),k&&t.jsx("div",{className:"text-[10px] font-medium text-muted-foreground",children:e===Vwe.EMAIL?f?t.jsx("span",{className:"text-[10px] font-medium text-muted-foreground",children:"..."}):t.jsx(VMe,{content:l?.emailSubject||"No subject set",mergeFieldsResponse:g,variant:"minimal",className:"text-[10px] font-medium text-muted-foreground"}):f?t.jsx("span",{className:"text-[10px] font-medium text-muted-foreground",children:"..."}):t.jsx(VMe,{content:l?.smsMessageBody?`${l.smsMessageBody.substring(0,40)}${l.smsMessageBody.length>40?"...":""}`:"No message set",mergeFieldsResponse:g,variant:"minimal",className:"text-[10px] font-medium text-muted-foreground"})}),!0!==A&&k&&t.jsx("div",{className:"text-[10px] text-amber-600 font-medium",children:A}),!k&&t.jsx("div",{className:"text-[10px] text-muted-foreground/70 font-medium italic",children:"Channel disabled"})]})]}),t.jsx("div",{className:"ml-auto",onClick:e=>{e.stopPropagation()},children:t.jsx(mze,{pressed:k,onPressedChange:()=>{c||k&&S||w()},disabled:c||k&&S||n,size:"sm",children:t.jsx(wY,{mode:"wait",initial:!1,children:k?t.jsx(o5.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.18,ease:"easeInOut"},className:"flex",children:t.jsx(tz,{className:"h-4 w-4 text-muted-foreground"})},"check"):t.jsx(o5.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.18,ease:"easeInOut"},className:"flex",children:t.jsx(rO,{className:"h-4 w-4 text-muted-foreground"})},"x")})})})]})},pze=e=>{switch(e){case ma.SEND_COMMUNICATION:return"Send Communication";case ma.WAIT_UNTIL_NEXT_FIXED_TIME:return"Wait";default:throw g5(e,ma)}},gze=e=>{switch(e){case ma.SEND_COMMUNICATION:return t.jsx(V5.CommunicationIcon,{className:"w-4 h-4"});case ma.WAIT_UNTIL_NEXT_FIXED_TIME:return t.jsx(V5.WaitUntilNextFixedTimeIcon,{className:"w-4 h-4"});default:throw jre(e,ma)}},fze=e=>{if(!(e&&e.actionType===ma.WAIT_UNTIL_NEXT_FIXED_TIME&&"hour"in e&&"minute"in e&&"timezone"in e))return null;const{hour:a,minute:t,timezone:n}=e;return`Wait until next ${`${a?.toString().padStart(2,"0")}:${t?.toString().padStart(2,"0")}`} ${n}`},vze=({actionDataWithMetadata:e})=>{const{actionData:n}=e,{state:{selectedActionId:i},setActionId:r,setSelectedCommunicationGroupId:o}=a.useContext(S5),s=a.useMemo((()=>i===n.actionMetadata.currentActionId),[i,n.actionMetadata.currentActionId]),l=QDe[n.actionType],u=l.color,c=l.clickable;return t.jsxs(o5.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},className:XO("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group"," border-2 border-transparent",s&&"border-primary",n.actionType!==ma.WAIT_UNTIL_NEXT_FIXED_TIME&&"hover:border-primary"),style:{backgroundColor:s?u.bg:u.bgUnselected??YDe},onClick:()=>{c&&(r(n.actionMetadata.currentActionId),n.actionType===ma.SEND_COMMUNICATION&&o(n.actionMetadata.communicationGroupId))},children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx("div",{className:"rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 bg-white",children:gze(n.actionType)}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{style:{color:s?u.text:u.textUnselected},children:t.jsx(i_e,{children:XDe[n.actionType]})}),t.jsx("div",n.actionType===ma.WAIT_UNTIL_NEXT_FIXED_TIME?{className:"text-[11px] text-muted-foreground font-normal rounded bg-muted/40 w-fit max-w-full truncate",children:fze(n.actionMetadata)}:{className:"text-xs font-medium text-muted-foreground",children:pze(n.actionType)})]})]}),n.actionType===ma.SEND_COMMUNICATION&&t.jsx("div",{className:"flex items-center pr-2",children:t.jsx(V5.NextButton,s?{className:"w-4 h-4 text-muted-foreground rotate-90 transition-transform duration-200"}:{className:"w-4 h-4 text-muted-foreground transition-transform duration-200"})})]})},yze=()=>{const e=R5(),[n,i]=a.useState(!1),[r,o]=a.useState(void 0),{segments:s}=T5(),l=B5(),{setActionId:u,setSelectedSubStepType:c,state:{selectedActionId:d,selectedSubStepType:m}}=a.useContext(S5);ra(l?.id||""),a.useEffect((()=>{if(!l)return;if(d)return;const e=l.actionData?.find((e=>e.actionType===ma.SEND_COMMUNICATION));e&&u(e.actionMetadata.currentActionId)}),[l,u,d]),a.useEffect((()=>{if(!l)return;(async()=>{const e=[];for(const a of l.actionData??[])switch(a.actionType){case ma.SEND_COMMUNICATION:{const t=await Je(a.actionMetadata.communicationGroupId);e.push({actionData:a,communicationGroup:t});break}case ma.WAIT_UNTIL_NEXT_FIXED_TIME:e.push({actionData:a});break;default:throw g5(a.actionType,ma)}o(e)})()}),[l]),a.useEffect((()=>{if(d&&r&&e&&null===m){const a=r.find((e=>e.actionData.actionMetadata.currentActionId===d));a?.actionData.actionType===ma.SEND_COMMUNICATION&&c(e?.emailChannelSenderId?Vwe.EMAIL:Vwe.SMS)}}),[d,r,c,e,m]);if(!l||!r||l?.triggerType===ua.TRIGGER_BASED&&void 0===s)return null;const h=(e=>{const{steps:a,rootActionId:t}=e;if(!a||!t)return a??[];const n=new Map(a.map((e=>[e.actionData.actionMetadata.currentActionId,e]))),i=n.get(t);if(!i)return a;const r=[];let o=i;for(;o;){r.push(o);const e=o.actionData.actionMetadata.nextActionId;if(!e)break;o=n.get(e)}return r})({steps:r,rootActionId:l.triggerMetadata?.triggerType===ua.TRIGGER_BASED?l.triggerMetadata.rootActionId:void 0}).filter((e=>!!n||e.actionData.actionType===ma.SEND_COMMUNICATION));let p=()=>t.jsx("div",{},"empty-trigger-audience");return(n||l.triggerType===ua.ONE_TIME)&&(p=()=>t.jsxs("div",{className:"flex flex-col gap-3",children:[l.triggerType===ua.ONE_TIME&&t.jsx(tze,{}),l.triggerType!==ua.ONE_TIME&&t.jsx(nze,{})]})),t.jsxs("div",{className:"flex-1 flex flex-col gap-2 w-full overflow-visible",children:[(l.triggerType===ua.TRIGGER_BASED||l.triggerType===ua.DATE_BASED)&&t.jsxs("div",{className:"flex gap-2 items-center justify-between",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:"Messages sent in listed order"}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("div",{className:"text-sm font-medium",children:"Show all details"}),t.jsx(MLe,{defaultChecked:n,onCheckedChange:()=>{i(!n)}})]})]}),t.jsx("div",{className:"flex-1 flex flex-col gap-3",children:t.jsxs(wY,{mode:"popLayout",children:[p(),h.map(((e,a)=>t.jsx(o5.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*a,ease:"easeInOut"},children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(vze,{actionDataWithMetadata:e}),e.actionData.actionType===ma.SEND_COMMUNICATION&&d===e.actionData.actionMetadata.currentActionId&&e.actionData.actionMetadata.currentActionId&&t.jsxs("div",{className:"flex gap-3",children:[t.jsx(o5.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,delay:.25*h.length,ease:"easeInOut"},className:"w-12 flex justify-end items-center",children:t.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full rounded-full"})}),t.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[t.jsx(hze,{type:Vwe.EMAIL,actionId:e.actionData.actionMetadata.currentActionId,disabled:l.status!==ha.DRAFT}),t.jsx(hze,{type:Vwe.SMS,actionId:e.actionData.actionMetadata.currentActionId,disabled:l.status!==ha.DRAFT})]})]})]})},e.actionData.actionMetadata?.currentActionId??a))),l.triggerType===ua.ONE_TIME&&t.jsx("div",{className:"flex flex-col gap-3",children:t.jsx(nze,{})},"one-time-trigger")]})})]})},bze=()=>{const e=B5(),{segments:a}=T5();return t.jsx("div",e&&a?{className:"h-full pt-4 relative",children:t.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col gap-3",children:t.jsx(yze,{})})}:{className:"flex h-full items-center justify-center",children:t.jsx(lY,{text:[`Getting details on your ${lH("engage:automation",{count:1}).toLowerCase()}`,"Finishing up"]})})},kze=({disablePreview:e=!1,disableEditContent:n=!1,disablePreviewSubtext:i=!1,hideSms:r=!1})=>{const{state:{selectedSubStepType:o}}=a.useContext(S5);if(!R5())return t.jsx("div",{className:"flex flex-col gap-4 flex-1 bg-muted rounded-md",children:t.jsx(lY,{text:["Loading..."]})});if(!o)return t.jsx("div",{className:"flex flex-col gap-4 flex-1 bg-muted rounded-md",children:t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-medium text-muted-foreground mb-2",children:"Select Communication Type"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose Email or SMS from the steps on the left to preview and edit content"})]})})});const s={disablePreview:e,disableEditContent:n,disablePreviewSubtext:i};return t.jsxs("div",{className:"flex flex-col flex-1 bg-muted rounded-md",children:[o===Vwe.EMAIL&&t.jsx(UNe,{...s}),o===Vwe.SMS&&!r&&t.jsx(YNe,{...s})]})},Sze=()=>{const{state:{selectedActionId:e}}=a.useContext(S5),{state:{hideSms:n}}=a.useContext(rY);return t.jsx("div",{className:"flex flex-col gap-4 h-full w-full",children:t.jsx(wY,{mode:"wait",children:e===Gwe.EditTime?t.jsx(sLe,{}):e===Gwe.EditAudience?t.jsx(ULe,{}):t.jsx(kze,{hideSms:n})})})},wze=()=>t.jsxs(WDe,{direction:"horizontal",className:"flex-1",children:[t.jsx(qDe,{defaultSize:30,minSize:16,maxSize:48,children:t.jsx("aside",{className:"h-full",children:t.jsx(bze,{})})}),t.jsx($De,{className:"px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1"}),t.jsx(qDe,{defaultSize:70,children:t.jsx("main",{className:"h-full",children:t.jsx(Sze,{})})})]}),Aze=()=>{const[e,n]=a.useState(Nwe.WORKFLOW),i=[{id:Nwe.WORKFLOW,label:"Workflow",content:t.jsx(wze,{})},{id:Nwe.RECIPIENTS,label:"Recipients",content:t.jsx(gRe,{})},{id:Nwe.INSIGHTS,label:lH("engage:insight",{count:2}),content:t.jsx(hRe,{})}];return t.jsx(sBe,{tabs:i,activeTab:e,onTabChange:e=>n(e),tabsLocation:"left"})},Cze=({showBackButton:e=!1,onDuplicationCreated:n,onBeforeSchedule:i,getExtraMergeFields:r,hideSms:o,hideSales:s,replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d})=>{const m=B5(),h=R5(),{updateCommunicationGroup:p}=Ye(),{toast:g}=Ve(),{channelSenders:f}=Jre(),v=a.useRef("");return a.useEffect((()=>{if(h&&r){(async()=>{const e=await r(),a=JSON.stringify(e);a!==v.current&&(v.current=a,p({groupId:h?.id,params:{extraMergeFields:e}},{onError:()=>{g({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})()}}),[h,r,p,g]),a.useEffect((()=>{if(m&&h&&f&&m.automationType===da.MANAGED&&null===h.emailChannelSenderId&&null===h.smsChannelSenderId){if(!h.emailChannelSenderId){const e=f.results.filter((e=>e.channelSenderMetadata.userPart));e.length>0&&p({groupId:h.id,params:{emailChannelSenderId:e[0].id}})}if(!h.smsChannelSenderId){const e=f.results.filter((e=>e.channelSenderMetadata.from||e.channelSenderMetadata.messageServiceSid));e.length>0&&p({groupId:h.id,params:{smsChannelSenderId:e[0].id}})}}}),[m,h,f,p]),m&&h?t.jsx(oY,{children:t.jsx(sY,{replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d,hideSms:o,hideSales:s,children:t.jsxs("div",{className:"h-full flex flex-col gap-4",children:[t.jsx(mRe,{showBackButton:e,onDuplicationCreated:n,onBeforeSchedule:i}),t.jsx("div",{className:"flex-1 border-t",children:t.jsx(Aze,{})})]})})}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(lY,{text:[`Fetching ${lH("engage:automation").toLowerCase()} data`,"Finishing up"]})})},Mze=({...e})=>{const a=function(){let{matches:e}=r.useContext(une),a=e[e.length-1];return a?a.params:{}}(),[n]=Xne(),i=e.automationId||a?.automationId||n.get("automationId")||"",o="true"===n.get("showBackButton")||e.showBackButton;return t.jsx(z5,{automationId:i,children:t.jsx("div",{className:"bg-background h-full min-h-[750px]",children:t.jsx(Cze,{...e,showBackButton:o})})})};Object.values(Object.assign({}));var Tze=e=>null!=e;var xze=e=>"function"!=typeof e||e.length?e:e(),Eze=e=>Array.isArray(e)?e:e?[e]:[];var Nze=Fa;var _ze,Pze=function(e){const[a,t]=La(),n=e?.throw?(e,a)=>{throw t(e instanceof Error?e:new Error(a)),e}:(e,a)=>{t(e instanceof Error?e:new Error(a))},i=e?.api?Array.isArray(e.api)?e.api:[e.api]:[globalThis.localStorage].filter(Boolean),r=e?.prefix?`${e.prefix}.`:"",o=new Map,s=new Proxy({},{get(a,t){let s=o.get(t);s||(s=La(void 0,{equals:!1}),o.set(t,s)),s[0]();const l=i.reduce(((e,a)=>{if(null!==e||!a)return e;try{return a.getItem(`${r}${t}`)}catch(oXe){return n(oXe,`Error reading ${r}${t} from ${a.name}`),null}}),null);return null!==l&&e?.deserializer?e.deserializer(l,t,e.options):l}});return!1!==e?.sync&&Ia((()=>{const e=e=>{let a=!1;i.forEach((t=>{try{t!==e.storageArea&&e.key&&e.newValue!==t.getItem(e.key)&&(e.newValue?t.setItem(e.key,e.newValue):t.removeItem(e.key),a=!0)}catch(oXe){n(oXe,`Error synching api ${t.name} from storage event (${e.key}=${e.newValue})`)}})),a&&e.key&&o.get(e.key)?.[1]()};"addEventListener"in globalThis?(globalThis.addEventListener("storage",e),Fa((()=>globalThis.removeEventListener("storage",e)))):(i.forEach((a=>a.addEventListener?.("storage",e))),Fa((()=>i.forEach((a=>a.removeEventListener?.("storage",e))))))})),[s,(a,t,s)=>{const l=e?.serializer?e.serializer(t,a,s??e.options):t,u=`${r}${a}`;i.forEach((e=>{try{e.getItem(u)!==l&&e.setItem(u,l)}catch(oXe){n(oXe,`Error setting ${r}${a} to ${l} in ${e.name}`)}}));const c=o.get(a);c&&c[1]()},{clear:()=>i.forEach((e=>{try{e.clear()}catch(oXe){n(oXe,`Error clearing ${e.name}`)}})),error:a,remove:e=>i.forEach((a=>{try{a.removeItem(`${r}${e}`)}catch(oXe){n(oXe,`Error removing ${r}${e} from ${a.name}`)}})),toJSON:()=>{const a={},t=(t,n)=>{if(!a.hasOwnProperty(t)){const i=n&&e?.deserializer?e.deserializer(n,t,e.options):n;i&&(a[t]=i)}};return i.forEach((e=>{if("function"==typeof e.getAll){let a;try{a=e.getAll()}catch(oXe){n(oXe,`Error getting all values from in ${e.name}`)}for(const e of a)t(e,a[e])}else{let i,r=0;try{for(;i=e.key(r++);)a.hasOwnProperty(i)||t(i,e.getItem(i))}catch(oXe){n(oXe,`Error getting all values from ${e.name}`)}}})),a}}]},jze=e=>{if(!e)return"";let a="";for(const t in e){if(!e.hasOwnProperty(t))continue;const n=e[t];a+=n instanceof Date?`; ${t}=${n.toUTCString()}`:"boolean"==typeof n?`; ${t}`:`; ${t}=${n}`}return a},Lze=("function"==typeof(_ze={_cookies:[globalThis.document,"cookie"],getItem:e=>Lze._cookies[0][Lze._cookies[1]].match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)")?.pop()??null,setItem:(e,a,t)=>{const n=Lze.getItem(e);Lze._cookies[0][Lze._cookies[1]]=`${e}=${a}${jze(t)}`;const i=Object.assign(new Event("storage"),{key:e,oldValue:n,newValue:a,url:globalThis.document.URL,storageArea:Lze});window.dispatchEvent(i)},removeItem:e=>{Lze._cookies[0][Lze._cookies[1]]=`${e}=deleted${jze({expires:new Date(0)})}`},key:e=>{let a=null,t=0;return Lze._cookies[0][Lze._cookies[1]].replace(/(?:^|;)\s*(.+?)\s*=\s*[^;]+/g,((n,i)=>(!a&&i&&t++===e&&(a=i),""))),a},get length(){let e=0;return Lze._cookies[0][Lze._cookies[1]].replace(/(?:^|;)\s*.+?\s*=\s*[^;]+/g,(a=>(e+=a?1:0,""))),e}}).clear||(_ze.clear=()=>{let e;for(;e=_ze.key(0);)_ze.removeItem(e)}),_ze),Bze=796,Rze="bottom",Dze="system",zze=Object.keys(ai)[0],Oze=Object.keys(ii)[0],Kze=Wa({client:void 0,onlineManager:void 0,queryFlavor:"",version:"",shadowDOMTarget:void 0});function Hze(){return qa(Kze)}var Ize=Wa(void 0),Fze=e=>{const[a,t]=La(null),n=()=>{const e=a();null!=e&&(e.close(),t(null))},i=(n,i)=>{if(null!=a())return;const r=window.open("","TSQD-Devtools-Panel",`width=${n},height=${i},popup`);if(!r)throw new Error("Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.");r.document.head.innerHTML="",r.document.body.innerHTML="",function(e=window.document){if(e[Dt]){for(let a of e[Dt].keys())e.removeEventListener(a,Zt);delete e[Dt]}}(r.document),r.document.title="TanStack Query Devtools",r.document.body.style.margin="0",r.addEventListener("pagehide",(()=>{e.setLocalStore("pip_open","false"),t(null)})),[...(Hze().shadowDOMTarget||document).styleSheets].forEach((e=>{try{const a=[...e.cssRules].map((e=>e.cssText)).join(""),t=document.createElement("style"),n=e.ownerNode;let i="";n&&"id"in n&&(i=n.id),i&&t.setAttribute("id",i),t.textContent=a,r.document.head.appendChild(t)}catch(rXe){const t=document.createElement("link");if(null==e.href)return;t.rel="stylesheet",t.type=e.type,t.media=e.media.toString(),t.href=e.href,r.document.head.appendChild(t)}})),Kt(["focusin","focusout","pointermove","keydown","pointerdown","pointerup","click","mousedown","input"],r.document),e.setLocalStore("pip_open","true"),t(r)};Da((()=>{"true"!==(e.localStore.pip_open??"false")||e.disabled||i(Number(window.innerWidth),Number(e.localStore.height||500))})),Da((()=>{const e=(Hze().shadowDOMTarget||document).querySelector("#_goober"),t=a();if(e&&t){const a=new MutationObserver((()=>{const a=(Hze().shadowDOMTarget||t.document).querySelector("#_goober");a&&(a.textContent=e.textContent)}));a.observe(e,{childList:!0,subtree:!0,characterDataOldValue:!0}),Fa((()=>{a.disconnect()}))}}));const r=za((()=>({pipWindow:a(),requestPipWindow:i,closePipWindow:n,disabled:e.disabled??!1})));return ht(Ize.Provider,{value:r,get children(){return e.children}})},Gze=()=>za((()=>{const e=qa(Ize);if(!e)throw new Error("usePiPWindow must be used within a PiPProvider");return e()})),Vze=Wa((()=>"dark"));function Jze(){return qa(Vze)}var Uze={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ấ":"A","Ắ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Æ":"AE","Ầ":"A","Ằ":"A","Ȃ":"A","Ç":"C","Ḉ":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ế":"E","Ḗ":"E","Ề":"E","Ḕ":"E","Ḝ":"E","Ȇ":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ḯ":"I","Ȋ":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ố":"O","Ṍ":"O","Ṓ":"O","Ȏ":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ấ":"a","ắ":"a","ẳ":"a","ẵ":"a","ặ":"a","æ":"ae","ầ":"a","ằ":"a","ȃ":"a","ç":"c","ḉ":"c","è":"e","é":"e","ê":"e","ë":"e","ế":"e","ḗ":"e","ề":"e","ḕ":"e","ḝ":"e","ȇ":"e","ì":"i","í":"i","î":"i","ï":"i","ḯ":"i","ȋ":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ố":"o","ṍ":"o","ṓ":"o","ȏ":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","C̆":"C","c̆":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","Ǵ":"G","ĝ":"g","ǵ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ḫ":"H","ḫ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ḱ":"K","ḱ":"k","K̆":"K","k̆":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ḿ":"M","ḿ":"m","M̆":"M","m̆":"m","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","N̆":"N","n̆":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","P̆":"P","p̆":"p","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","R̆":"R","r̆":"r","Ȓ":"R","ȓ":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","Ș":"S","ș":"s","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","ț":"t","Ț":"T","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","T̆":"T","t̆":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ȗ":"U","ȗ":"u","V̆":"V","v̆":"v","Ŵ":"W","ŵ":"w","Ẃ":"W","ẃ":"w","X̆":"X","x̆":"x","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Y̆":"Y","y̆":"y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ứ":"U","ứ":"u","Ṹ":"U","ṹ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o","Þ":"TH","þ":"th","Ṕ":"P","ṕ":"p","Ṥ":"S","ṥ":"s","X́":"X","x́":"x","Ѓ":"Г","ѓ":"г","Ќ":"К","ќ":"к","A̋":"A","a̋":"a","E̋":"E","e̋":"e","I̋":"I","i̋":"i","Ǹ":"N","ǹ":"n","Ồ":"O","ồ":"o","Ṑ":"O","ṑ":"o","Ừ":"U","ừ":"u","Ẁ":"W","ẁ":"w","Ỳ":"Y","ỳ":"y","Ȁ":"A","ȁ":"a","Ȅ":"E","ȅ":"e","Ȉ":"I","ȉ":"i","Ȍ":"O","ȍ":"o","Ȑ":"R","ȑ":"r","Ȕ":"U","ȕ":"u","B̌":"B","b̌":"b","Č̣":"C","č̣":"c","Ê̌":"E","ê̌":"e","F̌":"F","f̌":"f","Ǧ":"G","ǧ":"g","Ȟ":"H","ȟ":"h","J̌":"J","ǰ":"j","Ǩ":"K","ǩ":"k","M̌":"M","m̌":"m","P̌":"P","p̌":"p","Q̌":"Q","q̌":"q","Ř̩":"R","ř̩":"r","Ṧ":"S","ṧ":"s","V̌":"V","v̌":"v","W̌":"W","w̌":"w","X̌":"X","x̌":"x","Y̌":"Y","y̌":"y","A̧":"A","a̧":"a","B̧":"B","b̧":"b","Ḑ":"D","ḑ":"d","Ȩ":"E","ȩ":"e","Ɛ̧":"E","ɛ̧":"e","Ḩ":"H","ḩ":"h","I̧":"I","i̧":"i","Ɨ̧":"I","ɨ̧":"i","M̧":"M","m̧":"m","O̧":"O","o̧":"o","Q̧":"Q","q̧":"q","U̧":"U","u̧":"u","X̧":"X","x̧":"x","Z̧":"Z","z̧":"z"},Wze=Object.keys(Uze).join("|"),qze=new RegExp(Wze,"g");var $ze=7,Zze=6,Yze=5,Qze=4,Xze=3,eOe=2,aOe=1,tOe=0;function nOe(e,a,t){var n;if((t=t||{}).threshold=null!=(n=t.threshold)?n:aOe,!t.accessors){const n=iOe(e,a,t);return{rankedValue:e,rank:n,accessorIndex:-1,accessorThreshold:t.threshold,passed:n>=t.threshold}}const i=function(e,a){const t=[];for(let n=0,i=a.length;n<i;n++){const i=a[n],r=lOe(i),o=oOe(e,i);for(let e=0,a=o.length;e<a;e++)t.push({itemValue:o[e],attributes:r})}return t}(e,t.accessors),r={rankedValue:e,rank:tOe,accessorIndex:-1,accessorThreshold:t.threshold,passed:!1};for(let o=0;o<i.length;o++){const e=i[o];let n=iOe(e.itemValue,a,t);const{minRanking:s,maxRanking:l,threshold:u=t.threshold}=e.attributes;n<s&&n>=aOe?n=s:n>l&&(n=l),n=Math.min(n,l),n>=u&&n>r.rank&&(r.rank=n,r.passed=!0,r.accessorIndex=o,r.accessorThreshold=u,r.rankedValue=e.itemValue)}return r}function iOe(e,a,t){return e=rOe(e,t),(a=rOe(a,t)).length>e.length?tOe:e===a?$ze:(e=e.toLowerCase())===(a=a.toLowerCase())?Zze:e.startsWith(a)?Yze:e.includes(` ${a}`)?Qze:e.includes(a)?Xze:1===a.length?tOe:function(e){let a="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{a+=e.substr(0,1)}))})),a}(e).includes(a)?eOe:function(e,a){let t=0,n=0;function i(e,a,n){for(let i=n,r=a.length;i<r;i++){if(a[i]===e)return t+=1,i+1}return-1}function r(e){return aOe+t/a.length*(1/e)}const o=i(a[0],e,0);if(o<0)return tOe;n=o;for(let s=1,l=a.length;s<l;s++){n=i(a[s],e,n);if(!(n>-1))return tOe}return r(n-o)}(e,a)}function rOe(e,a){let{keepDiacritics:t}=a;return e=`${e}`,t||(e=e.replace(qze,(e=>Uze[e]))),e}function oOe(e,a){let t=a;"object"==typeof a&&(t=a.accessor);const n=t(e);return null==n?[]:Array.isArray(n)?n:[String(n)]}var sOe={maxRanking:1/0,minRanking:-1/0};function lOe(e){return"function"==typeof e?sOe:{...sOe,...e}}var uOe={data:""},cOe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,dOe=/\/\*[^]*?\*\/| +/g,mOe=/\n+/g,hOe=(e,a)=>{let t="",n="",i="";for(let r in e){let o=e[r];"@"==r[0]?"i"==r[1]?t=r+" "+o+";":n+="f"==r[1]?hOe(o,r):r+"{"+hOe(o,"k"==r[1]?"":a)+"}":"object"==typeof o?n+=hOe(o,a?a.replace(/([^,])+/g,(e=>r.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,(a=>/&/.test(a)?a.replace(/&/g,e):e?e+" "+a:a)))):r):null!=o&&(r=/^--/.test(r)?r:r.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=hOe.p?hOe.p(r,o):r+":"+o+";")}return t+(a&&i?a+"{"+i+"}":i)+n},pOe={},gOe=e=>{if("object"==typeof e){let a="";for(let t in e)a+=t+gOe(e[t]);return a}return e};function fOe(e){let a=this||{},t=e.call?e(a.p):e;return((e,a,t,n,i)=>{let r=gOe(e),o=pOe[r]||(pOe[r]=(e=>{let a=0,t=11;for(;a<e.length;)t=101*t+e.charCodeAt(a++)>>>0;return"go"+t})(r));if(!pOe[o]){let a=r!==e?e:(e=>{let a,t,n=[{}];for(;a=cOe.exec(e.replace(dOe,""));)a[4]?n.shift():a[3]?(t=a[3].replace(mOe," ").trim(),n.unshift(n[0][t]=n[0][t]||{})):n[0][a[1]]=a[2].replace(mOe," ").trim();return n[0]})(e);pOe[o]=hOe(i?{["@keyframes "+o]:a}:a,t?"":"."+o)}let s=t&&pOe.g?pOe.g:null;return t&&(pOe.g=pOe[o]),l=pOe[o],u=a,c=n,(d=s)?u.data=u.data.replace(d,l):-1===u.data.indexOf(l)&&(u.data=c?l+u.data:u.data+l),o;var l,u,c,d})(t.unshift?t.raw?((e,a,t)=>e.reduce(((e,n,i)=>{let r=a[i];if(r&&r.call){let e=r(t),a=e&&e.props&&e.props.className||/^go/.test(e)&&e;r=a?"."+a:e&&"object"==typeof e?e.props?"":hOe(e,""):!1===e?"":e}return e+n+(null==r?"":r)}),""))(t,[].slice.call(arguments,1),a.p):t.reduce(((e,t)=>Object.assign(e,t&&t.call?t(a.p):t)),{}):t,(e=>"object"==typeof window?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||uOe)(a.target),a.g,a.o,a.k)}function vOe(e){var a,t,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(a=0;a<i;a++)e[a]&&(t=vOe(e[a]))&&(n&&(n+=" "),n+=t)}else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function yOe(){for(var e,a,t=0,n="",i=arguments.length;t<i;t++)(e=arguments[t])&&(a=vOe(e))&&(n&&(n+=" "),n+=a);return n}function bOe(e,a){const t=Ka(e),{onChange:n}=a;let i=new Set(a.appear?void 0:t);const r=new WeakSet,[o,s]=La([],{equals:!1}),[l]=[Ja,Va],u=e=>{s((a=>(a.push.apply(a,e),a)));for(const a of e)r.delete(a)},c=(e,a,t)=>e.splice(t,0,a);return za((a=>{const t=o(),s=e();if(Ka(l))return l(),a;if(t.length){const e=a.filter((e=>!t.includes(e)));return t.length=0,n({list:e,added:[],removed:[],unchanged:e,finishRemoved:u}),e}return Ka((()=>{const e=new Set(s),t=s.slice(),o=[],l=[],d=[];for(const a of s)(i.has(a)?d:o).push(a);let m=!o.length;for(let n=0;n<a.length;n++){const i=a[n];e.has(i)||(r.has(i)||(l.push(i),r.add(i)),c(t,i,n)),m&&i!==t[n]&&(m=!1)}return!l.length&&m?a:(n({list:t,added:o,removed:l,unchanged:d,finishRemoved:u}),i=e,t)}))}),a.appear?[]:t.slice())}function kOe(...e){return a=e,(...e)=>{for(const t of a)t&&t(...e)};var a}fOe.bind({g:1}),fOe.bind({k:1});var SOe=e=>e instanceof Element;function wOe(e,a){if(a(e))return e;if("function"==typeof e&&!e.length)return wOe(e(),a);if(Array.isArray(e)){const t=[];for(const n of e){const e=wOe(n,a);e&&(Array.isArray(e)?t.push.apply(t,e):t.push(e))}return t.length?t:null}return null}function AOe(e,a=SOe,t=SOe){const n=za(e),i=za((()=>wOe(n(),a)));return i.toArray=()=>{const e=i();return Array.isArray(e)?e:e?[e]:[]},i}function COe(e){requestAnimationFrame((()=>requestAnimationFrame(e)))}function MOe(e,a,t,n){const{onBeforeEnter:i,onEnter:r,onAfterEnter:o}=a;function s(a){a&&a.target!==t||(t.removeEventListener("transitionend",s),t.removeEventListener("animationend",s),t.classList.remove(...e.enterActive),t.classList.remove(...e.enterTo),o?.(t))}i?.(t),t.classList.add(...e.enter),t.classList.add(...e.enterActive),queueMicrotask((()=>{if(!t.parentNode)return n?.();r?.(t,(()=>s()))})),COe((()=>{t.classList.remove(...e.enter),t.classList.add(...e.enterTo),(!r||r.length<2)&&(t.addEventListener("transitionend",s),t.addEventListener("animationend",s))}))}function TOe(e,a,t,n){const{onBeforeExit:i,onExit:r,onAfterExit:o}=a;if(!t.parentNode)return n?.();function s(a){a&&a.target!==t||(n?.(),t.removeEventListener("transitionend",s),t.removeEventListener("animationend",s),t.classList.remove(...e.exitActive),t.classList.remove(...e.exitTo),o?.(t))}i?.(t),t.classList.add(...e.exit),t.classList.add(...e.exitActive),r?.(t,(()=>s())),COe((()=>{t.classList.remove(...e.exit),t.classList.add(...e.exitTo),(!r||r.length<2)&&(t.addEventListener("transitionend",s),t.addEventListener("animationend",s))}))}var xOe=e=>{const a=function(e){return za((()=>{const a=e.name||"s";return{enterActive:(e.enterActiveClass||a+"-enter-active").split(" "),enter:(e.enterClass||a+"-enter").split(" "),enterTo:(e.enterToClass||a+"-enter-to").split(" "),exitActive:(e.exitActiveClass||a+"-exit-active").split(" "),exit:(e.exitClass||a+"-exit").split(" "),exitTo:(e.exitToClass||a+"-exit-to").split(" "),move:(e.moveClass||a+"-move").split(" ")}}))}(e);return bOe(AOe((()=>e.children)).toArray,{appear:e.appear,onChange({added:t,removed:n,finishRemoved:i,list:r}){const o=a();for(const a of t)MOe(o,e,a);const s=[];for(const e of r)e.isConnected&&(e instanceof HTMLElement||e instanceof SVGElement)&&s.push({el:e,rect:e.getBoundingClientRect()});queueMicrotask((()=>{const e=[];for(const{el:a,rect:t}of s)if(a.isConnected){const n=a.getBoundingClientRect(),i=t.left-n.left,r=t.top-n.top;(i||r)&&(a.style.transform=`translate(${i}px, ${r}px)`,a.style.transitionDuration="0s",e.push(a))}document;for(const a of e){let e=function(t){(t.target===a||/transform$/.test(t.propertyName))&&(a.removeEventListener("transitionend",e),a.classList.remove(...o.move))};a.classList.add(...o.move),a.style.transform=a.style.transitionDuration="",a.addEventListener("transitionend",e)}}));for(const a of n)TOe(o,e,a,(()=>i([a])))}})},EOe=Symbol("fallback");function NOe(e){for(const a of e)a.dispose()}function _Oe(e){const{by:a}=e;return za(function(e,a,t,n={}){const i=new Map;return Fa((()=>NOe(i.values()))),()=>{const t=e()||[];return Ka((()=>{if(!t.length)return NOe(i.values()),i.clear(),n.fallback?[ja((e=>(i.set(EOe,{dispose:e}),n.fallback())))]:[];const e=new Array(t.length),o=i.get(EOe);if(!i.size||o){o?.dispose(),i.delete(EOe);for(let n=0;n<t.length;n++){const i=t[n];r(e,i,n,a(i,n))}return e}const s=new Set(i.keys());for(let n=0;n<t.length;n++){const o=t[n],l=a(o,n);s.delete(l);const u=i.get(l);u?(e[n]=u.mapped,u.setIndex?.(n),u.setItem((()=>o))):r(e,o,n,l)}for(const a of s)i.get(a)?.dispose(),i.delete(a);return e}))};function r(e,a,n,r){ja((o=>{const[s,l]=La(a),u={setItem:l,dispose:o};if(t.length>1){const[e,a]=La(n);u.setIndex=a,u.mapped=t(s,e)}else u.mapped=t(s);i.set(r,u),e[n]=u.mapped}))}}((()=>e.each),"function"==typeof a?a:e=>e[a],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function POe(e,a,t,n){const i=()=>{Eze(xze(e)).forEach((e=>{e&&Eze(xze(a)).forEach((a=>function(e,a,t,n){return e.addEventListener(a,t,n),Nze(e.removeEventListener.bind(e,a,t,n))}(e,a,t,n)))}))};"function"==typeof e?Da(i):Ra(i)}function jOe(e,a,t){const n=new WeakMap,{observe:i,unobserve:r}=function(e,a){const t=new ResizeObserver(e);return Fa(t.disconnect.bind(t)),{observe:e=>t.observe(e,a),unobserve:t.unobserve.bind(t)}}((e=>{for(const t of e){const{contentRect:e,target:i}=t,r=Math.round(e.width),o=Math.round(e.height),s=n.get(i);s&&s.width===r&&s.height===o||(a(e,i,t),n.set(i,{width:r,height:o}))}}),t);Da((a=>{const t=Eze(xze(e)).filter(Tze);return function(e,a,t,n){const i=e.length,r=a.length;let o,s,l=0;if(r)if(i){for(;l<r&&a[l]===e[l];l++);for(o of(a=a.slice(l),e=e.slice(l),a))e.includes(o)||n(o);for(s of e)a.includes(s)||t(s)}else for(;l<r;l++)n(a[l]);else for(;l<i;l++)t(e[l])}(t,a,i,r),t}),[])}var LOe=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function BOe(e){const a={};let t;for(;t=LOe.exec(e);)a[t[1]]=t[2];return a}function ROe(e,a){if("string"==typeof e){if("string"==typeof a)return`${e};${a}`;e=BOe(e)}else"string"==typeof a&&(a=BOe(a));return{...e,...a}}function DOe(e,a){const t=[...e],n=t.indexOf(a);return-1!==n&&t.splice(n,1),t}function zOe(e){return"[object String]"===Object.prototype.toString.call(e)}function OOe(e){return a=>`${e()}-${a}`}function KOe(e,a){return!!e&&(e===a||e.contains(a))}function HOe(e,a=!1){const{activeElement:t}=IOe(e);if(!t?.nodeName)return null;if(FOe(t)&&t.contentDocument)return HOe(t.contentDocument.body,a);if(a){const e=t.getAttribute("aria-activedescendant");if(e){const a=IOe(t).getElementById(e);if(a)return a}}return t}function IOe(e){return e?e.ownerDocument||e:document}function FOe(e){return"IFRAME"===e.tagName}var GOe=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(GOe||{});function VOe(e){return"undefined"!=typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function JOe(){return VOe(/^Mac/i)}function UOe(){return VOe(/^iPhone/i)||VOe(/^iPad/i)||JOe()&&navigator.maxTouchPoints>1}function WOe(e,a){return a&&("function"==typeof a?a(e):a[0](a[1],e)),e?.defaultPrevented}function qOe(e){return a=>{for(const t of e)WOe(a,t)}}function $Oe(e){return JOe()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function ZOe(e){if(e)if(function(){if(null==YOe){YOe=!1;try{document.createElement("div").focus({get preventScroll(){return YOe=!0,!0}})}catch(rXe){}}return YOe}())e.focus({preventScroll:!0});else{const a=function(e){let a=e.parentNode;const t=[],n=document.scrollingElement||document.documentElement;for(;a instanceof HTMLElement&&a!==n;)(a.offsetHeight<a.scrollHeight||a.offsetWidth<a.scrollWidth)&&t.push({element:a,scrollTop:a.scrollTop,scrollLeft:a.scrollLeft}),a=a.parentNode;n instanceof HTMLElement&&t.push({element:n,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft});return t}(e);e.focus(),function(e){for(const{element:a,scrollTop:t,scrollLeft:n}of e)a.scrollTop=t,a.scrollLeft=n}(a)}}var YOe=null;var QOe=["input:not([type='hidden']):not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","a[href]","area[href]","[tabindex]","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]:not([contenteditable='false'])"],XOe=[...QOe,'[tabindex]:not([tabindex="-1"]):not([disabled])'],eKe=QOe.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",aKe=XOe.join(':not([hidden]):not([tabindex="-1"]),');function tKe(e,a){const t=Array.from(e.querySelectorAll(eKe)).filter(nKe);return a&&nKe(e)&&t.unshift(e),t.forEach(((e,a)=>{if(FOe(e)&&e.contentDocument){const n=tKe(e.contentDocument.body,!1);t.splice(a,1,...n)}})),t}function nKe(e){return iKe(e)&&!function(e){const a=parseInt(e.getAttribute("tabindex")||"0",10);return a<0}(e)}function iKe(e){return e.matches(eKe)&&rKe(e)}function rKe(e,a){return"#comment"!==e.nodeName&&function(e){if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const{display:a,visibility:t}=e.style;let n="none"!==a&&"hidden"!==t&&"collapse"!==t;if(n){if(!e.ownerDocument.defaultView)return n;const{getComputedStyle:a}=e.ownerDocument.defaultView,{display:t,visibility:i}=a(e);n="none"!==t&&"hidden"!==i&&"collapse"!==i}return n}(e)&&function(e,a){return!e.hasAttribute("hidden")&&("DETAILS"!==e.nodeName||!a||"SUMMARY"===a.nodeName||e.hasAttribute("open"))}(e,a)&&(!e.parentElement||rKe(e.parentElement,e))}function oKe(e){for(;e&&!sKe(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}function sKe(e){const a=window.getComputedStyle(e);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function lKe(){}function uKe(e,a){return yt(e,a)}var cKe=new Map,dKe=new Set;function mKe(){if("undefined"==typeof window)return;const e=a=>{if(!a.target)return;const t=cKe.get(a.target);if(t&&(t.delete(a.propertyName),0===t.size&&(a.target.removeEventListener("transitioncancel",e),cKe.delete(a.target)),0===cKe.size)){for(const e of dKe)e();dKe.clear()}};document.body.addEventListener("transitionrun",(a=>{if(!a.target)return;let t=cKe.get(a.target);t||(t=new Set,cKe.set(a.target,t),a.target.addEventListener("transitioncancel",e)),t.add(a.propertyName)})),document.body.addEventListener("transitionend",e)}function hKe(e,a){const t=pKe(e,a,"left"),n=pKe(e,a,"top"),i=a.offsetWidth,r=a.offsetHeight;let o=e.scrollLeft,s=e.scrollTop;const l=o+e.offsetWidth,u=s+e.offsetHeight;t<=o?o=t:t+i>l&&(o+=t+i-l),n<=s?s=n:n+r>u&&(s+=n+r-u),e.scrollLeft=o,e.scrollTop=s}function pKe(e,a,t){const n="left"===t?"offsetLeft":"offsetTop";let i=0;for(;a.offsetParent&&(i+=a[n],a.offsetParent!==e);){if(a.offsetParent.contains(e)){i-=e[n];break}a=a.offsetParent}return i}"undefined"!=typeof document&&("loading"!==document.readyState?mKe():document.addEventListener("DOMContentLoaded",mKe));var gKe={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};function fKe(e){return a=>(e(a),()=>e(void 0))}function vKe(e,a){const[t,n]=La(yKe(a?.()));return Da((()=>{n(e()?.tagName.toLowerCase()||yKe(a?.()))})),t}function yKe(e){return zOe(e)?e:void 0}function bKe(e){const[a,t]=bt(e,["as"]);if(!a.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return ht(nn,yt(t,{get component(){return a.as}}))}var kKe=["id","name","validationState","required","disabled","readOnly"];var SKe=Wa();function wKe(){const e=qa(SKe);if(void 0===e)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function AKe(e){const a=wKe(),t=uKe({id:a.generateId("description")},e);return Da((()=>Fa(a.registerDescription(t.id)))),ht(bKe,yt({as:"div"},(()=>a.dataset()),t))}function CKe(e){const a=wKe(),t=uKe({id:a.generateId("error-message")},e),[n,i]=bt(t,["forceMount"]),r=()=>"invalid"===a.validationState();return Da((()=>{r()&&Fa(a.registerErrorMessage(i.id))})),ht(Tt,{get when(){return n.forceMount||r()},get children(){return ht(bKe,yt({as:"div"},(()=>a.dataset()),i))}})}function MKe(e){let a;const t=wKe(),n=uKe({id:t.generateId("label")},e),[i,r]=bt(n,["ref"]),o=vKe((()=>a),(()=>"label"));return Da((()=>Fa(t.registerLabel(r.id)))),ht(bKe,yt({as:"label",ref(e){const t=kOe((e=>a=e),i.ref);"function"==typeof t&&t(e)},get for(){return za((()=>"label"===o()))()?t.fieldId():void 0}},(()=>t.dataset()),r))}function TKe(e,a){Da(Ha(e,(e=>{if(null==e)return;const t=function(e){return function(e){return e.matches("textarea, input, select, button")}(e)?e.form:e.closest("form")}(e);null!=t&&(t.addEventListener("reset",a,{passive:!0}),Fa((()=>{t.removeEventListener("reset",a)})))})))}function xKe(e){const[a,t]=La(e.defaultValue?.()),n=za((()=>void 0!==e.value?.())),i=za((()=>n()?e.value?.():a()));return[i,a=>{Ka((()=>{const r=function(e,...a){return"function"==typeof e?e(...a):e}(a,i());return Object.is(r,i())||(n()||t(r),e.onChange?.(r)),r}))}]}function EKe(e){const[a,t]=xKe(e);return[()=>a()??!1,t]}var NKe=Object.defineProperty,_Ke=(e,a)=>{for(var t in a)NKe(e,t,{get:a[t],enumerable:!0})},PKe=Wa();function jKe(){return qa(PKe)}function LKe(e,a){return Boolean(a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function BKe(e,a){const t=function(e){const a=e.map(((e,a)=>[a,e]));let t=!1;return a.sort((([e,a],[n,i])=>{const r=a.ref(),o=i.ref();return r===o?0:r&&o?LKe(r,o)?(e>n&&(t=!0),-1):(e<n&&(t=!0),1):0})),t?a.map((([e,a])=>a)):e}(e);e!==t&&a(t)}function RKe(e,a){if("function"!=typeof IntersectionObserver)return void function(e,a){Da((()=>{const t=setTimeout((()=>{BKe(e(),a)}));Fa((()=>clearTimeout(t)))}))}(e,a);let t=[];Da((()=>{const n=function(e){const a=e[0],t=e[e.length-1]?.ref();let n=a?.ref()?.parentElement;for(;n;){if(t&&n.contains(t))return n;n=n.parentElement}return IOe(n).body}(e()),i=new IntersectionObserver((()=>{const n=!!t.length;t=e(),n&&BKe(e(),a)}),{root:n});for(const a of e()){const e=a.ref();e&&i.observe(e)}Fa((()=>i.disconnect()))}))}function DKe(e={}){const[a,t]=function(e){const[a,t]=xKe(e);return[()=>a()??[],t]}({value:()=>xze(e.items),onChange:a=>e.onItemsChange?.(a)});RKe(a,t);const n=e=>(t((a=>{const t=function(e,a){const t=a.ref();if(!t)return-1;let n=e.length;if(!n)return-1;for(;n--;){const a=e[n]?.ref();if(a&&LKe(a,t))return n+1}return 0}(a,e);return function(e,a,t=-1){return t in e?[...e.slice(0,t),a,...e.slice(t)]:[...e,a]}(a,e,t)})),()=>{t((a=>{const t=a.filter((a=>a.ref()!==e.ref()));return a.length===t.length?a:t}))});return{DomCollectionProvider:e=>ht(PKe.Provider,{value:{registerItem:n},get children(){return e.children}})}}function zKe(e){const a=function(){const e=jKe();if(void 0===e)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}(),t=uKe({shouldRegisterItem:!0},e);Da((()=>{if(!t.shouldRegisterItem)return;Fa(a.registerItem(t.getItem()))}))}function OKe(e){let a=e.startIndex??0;const t=e.startLevel??0,n=[],i=a=>{if(null==a)return"";const t=e.getKey??"key",n=zOe(t)?a[t]:t(a);return null!=n?String(n):""},r=a=>{if(null==a)return"";const t=e.getTextValue??"textValue",n=zOe(t)?a[t]:t(a);return null!=n?String(n):""},o=a=>{if(null==a)return!1;const t=e.getDisabled??"disabled";return(zOe(t)?a[t]:t(a))??!1},s=a=>{if(null!=a)return zOe(e.getSectionChildren)?a[e.getSectionChildren]:e.getSectionChildren?.(a)};for(const l of e.dataSource)if(zOe(l)||"number"==typeof l)n.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:o(l),level:t,index:a}),a++;else if(null!=s(l)){n.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:t,index:a}),a++;const i=s(l)??[];if(i.length>0){const r=OKe({dataSource:i,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:a,startLevel:t+1});n.push(...r),a+=r.length}}else n.push({type:"item",rawValue:l,key:i(l),textValue:r(l),disabled:o(l),level:t,index:a}),a++;return n}function KKe(e,a=[]){return za((()=>{const t=OKe({dataSource:xze(e.dataSource),getKey:xze(e.getKey),getTextValue:xze(e.getTextValue),getDisabled:xze(e.getDisabled),getSectionChildren:xze(e.getSectionChildren)});for(let e=0;e<a.length;e++)a[e]();return e.factory(t)}))}var HKe=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),IKe=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function FKe(e){return function(e){if(Intl.Locale){const a=new Intl.Locale(e).maximize().script??"";return HKe.has(a)}const a=e.split("-")[0];return IKe.has(a)}(e)?"rtl":"ltr"}function GKe(){let e="undefined"!=typeof navigator&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:FKe(e)}}var VKe=GKe(),JKe=new Set;function UKe(){VKe=GKe();for(const e of JKe)e(VKe)}var WKe=Wa();function qKe(){const e=function(){const[e,a]=La(VKe),t=za((()=>e()));return Ia((()=>{0===JKe.size&&window.addEventListener("languagechange",UKe),JKe.add(a),Fa((()=>{JKe.delete(a),0===JKe.size&&window.removeEventListener("languagechange",UKe)}))})),{locale:()=>t().locale,direction:()=>t().direction}}();return qa(WKe)||e}var $Ke=new Map;var ZKe=class e extends Set{anchorKey;currentKey;constructor(a,t,n){super(a),a instanceof e?(this.anchorKey=t||a.anchorKey,this.currentKey=n||a.currentKey):(this.anchorKey=t,this.currentKey=n)}};function YKe(e){return JOe()||UOe()?e.altKey:e.ctrlKey}function QKe(e){return JOe()?e.metaKey:e.ctrlKey}function XKe(e){return new ZKe(e)}function eHe(e){const a=uKe({selectionMode:"none",selectionBehavior:"toggle"},e),[t,n]=La(!1),[i,r]=La(),o=za((()=>{const e=xze(a.selectedKeys);return null!=e?XKe(e):e})),s=za((()=>{const e=xze(a.defaultSelectedKeys);return null!=e?XKe(e):new ZKe})),[l,u]=function(e){const[a,t]=xKe(e);return[()=>a()??new ZKe,t]}({value:o,defaultValue:s,onChange:e=>a.onSelectionChange?.(e)}),[c,d]=La(xze(a.selectionBehavior));return Da((()=>{const e=l();"replace"===xze(a.selectionBehavior)&&"toggle"===c()&&"object"==typeof e&&0===e.size&&d("replace")})),Da((()=>{d(xze(a.selectionBehavior)??"toggle")})),{selectionMode:()=>xze(a.selectionMode),disallowEmptySelection:()=>xze(a.disallowEmptySelection)??!1,selectionBehavior:c,setSelectionBehavior:d,isFocused:t,setFocused:n,focusedKey:i,setFocusedKey:r,selectedKeys:l,setSelectedKeys:e=>{!xze(a.allowDuplicateSelectionEvents)&&function(e,a){if(e.size!==a.size)return!1;for(const t of e)if(!a.has(t))return!1;return!0}(e,l())||u(e)}}}function aHe(e,a,t){const n=yt({selectOnFocus:()=>"replace"===xze(e.selectionManager).selectionBehavior()},e),i=()=>a(),{direction:r}=qKe();let o={top:0,left:0};POe((()=>xze(n.isVirtualized)?void 0:i()),"scroll",(()=>{const e=i();e&&(o={top:e.scrollTop,left:e.scrollLeft})}));const{typeSelectHandlers:s}=function(e){const[a,t]=La(""),[n,i]=La(-1);return{typeSelectHandlers:{onKeyDown:r=>{if(xze(e.isDisabled))return;const o=xze(e.keyboardDelegate),s=xze(e.selectionManager);if(!o.getKeyForSearch)return;const l=function(e){return 1!==e.length&&/^[A-Z]/i.test(e)?"":e}(r.key);if(!l||r.ctrlKey||r.metaKey)return;" "===l&&a().trim().length>0&&(r.preventDefault(),r.stopPropagation());let u=t((e=>e+l)),c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u);null==c&&function(e){return e.split("").every((a=>a===e[0]))}(u)&&(u=u[0],c=o.getKeyForSearch(u,s.focusedKey())??o.getKeyForSearch(u)),null!=c&&(s.setFocusedKey(c),e.onTypeSelect?.(c)),clearTimeout(n()),i(window.setTimeout((()=>t("")),500))}}}}({isDisabled:()=>xze(n.disallowTypeAhead),keyboardDelegate:()=>xze(n.keyboardDelegate),selectionManager:()=>xze(n.selectionManager)}),l=()=>xze(n.orientation)??"vertical",u=()=>{const e=xze(n.autoFocus);if(!e)return;const t=xze(n.selectionManager),i=xze(n.keyboardDelegate);let r;"first"===e&&(r=i.getFirstKey?.()),"last"===e&&(r=i.getLastKey?.());const o=t.selectedKeys();o.size&&(r=o.values().next().value),t.setFocused(!0),t.setFocusedKey(r);const s=a();s&&null==r&&!xze(n.shouldUseVirtualFocus)&&ZOe(s)};Ia((()=>{n.deferAutoFocus?setTimeout(u,0):u()})),Da(Ha([i,()=>xze(n.isVirtualized),()=>xze(n.selectionManager).focusedKey()],(e=>{const[a,t,i]=e;if(t)i&&n.scrollToKey?.(i);else if(i&&a){const e=a.querySelector(`[data-key="${i}"]`);e&&hKe(a,e)}})));return{tabIndex:za((()=>{if(!xze(n.shouldUseVirtualFocus))return null==xze(n.selectionManager).focusedKey()?0:-1})),onKeyDown:e=>{WOe(e,s.onKeyDown),e.altKey&&"Tab"===e.key&&e.preventDefault();const t=a();if(!t?.contains(e.target))return;const i=xze(n.selectionManager),o=xze(n.selectOnFocus),u=a=>{null!=a&&(i.setFocusedKey(a),e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&!YKe(e)&&i.replaceSelection(a))},c=xze(n.keyboardDelegate),d=xze(n.shouldFocusWrap),m=i.focusedKey();switch(e.key){case"vertical"===l()?"ArrowDown":"ArrowRight":if(c.getKeyBelow){let a;e.preventDefault(),a=null!=m?c.getKeyBelow(m):c.getFirstKey?.(),null==a&&d&&(a=c.getFirstKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowUp":"ArrowLeft":if(c.getKeyAbove){let a;e.preventDefault(),a=null!=m?c.getKeyAbove(m):c.getLastKey?.(),null==a&&d&&(a=c.getLastKey?.(m)),u(a)}break;case"vertical"===l()?"ArrowLeft":"ArrowUp":if(c.getKeyLeftOf){e.preventDefault();const a="rtl"===r();let t;t=null!=m?c.getKeyLeftOf(m):a?c.getFirstKey?.():c.getLastKey?.(),u(t)}break;case"vertical"===l()?"ArrowRight":"ArrowDown":if(c.getKeyRightOf){e.preventDefault();const a="rtl"===r();let t;t=null!=m?c.getKeyRightOf(m):a?c.getLastKey?.():c.getFirstKey?.(),u(t)}break;case"Home":if(c.getFirstKey){e.preventDefault();const a=c.getFirstKey(m,QKe(e));null!=a&&(i.setFocusedKey(a),QKe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"End":if(c.getLastKey){e.preventDefault();const a=c.getLastKey(m,QKe(e));null!=a&&(i.setFocusedKey(a),QKe(e)&&e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&i.replaceSelection(a))}break;case"PageDown":if(c.getKeyPageBelow&&null!=m){e.preventDefault();u(c.getKeyPageBelow(m))}break;case"PageUp":if(c.getKeyPageAbove&&null!=m){e.preventDefault();u(c.getKeyPageAbove(m))}break;case"a":QKe(e)&&"multiple"===i.selectionMode()&&!0!==xze(n.disallowSelectAll)&&(e.preventDefault(),i.selectAll());break;case"Escape":e.defaultPrevented||(e.preventDefault(),xze(n.disallowEmptySelection)||i.clearSelection());break;case"Tab":if(!xze(n.allowsTabNavigation)){if(e.shiftKey)t.focus();else{const e=function(e,a){const t=a?.tabbable?aKe:eKe,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>a?.from?.contains(e)?NodeFilter.FILTER_REJECT:e.matches(t)&&rKe(e)&&(!a?.accept||a.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});return a?.from&&(n.currentNode=a.from),n}(t,{tabbable:!0});let a,n;do{n=e.lastChild(),n&&(a=n)}while(n);a&&!a.contains(document.activeElement)&&ZOe(a)}break}}},onMouseDown:e=>{i()===e.target&&e.preventDefault()},onFocusIn:e=>{const a=xze(n.selectionManager),t=xze(n.keyboardDelegate),r=xze(n.selectOnFocus);if(a.isFocused())e.currentTarget.contains(e.target)||a.setFocused(!1);else if(e.currentTarget.contains(e.target))if(a.setFocused(!0),null==a.focusedKey()){const n=e=>{null!=e&&(a.setFocusedKey(e),r&&a.replaceSelection(e))},i=e.relatedTarget;i&&e.currentTarget.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?n(a.lastSelectedKey()??t.getLastKey?.()):n(a.firstSelectedKey()??t.getFirstKey?.())}else if(!xze(n.isVirtualized)){const e=i();if(e){e.scrollTop=o.top,e.scrollLeft=o.left;const t=e.querySelector(`[data-key="${a.focusedKey()}"]`);t&&(ZOe(t),hKe(e,t))}}},onFocusOut:e=>{const a=xze(n.selectionManager);e.currentTarget.contains(e.relatedTarget)||a.setFocused(!1)}}}function tHe(e,a){const t=()=>xze(e.selectionManager),n=()=>xze(e.key),i=()=>xze(e.shouldUseVirtualFocus),r=e=>{"none"!==t().selectionMode()&&("single"===t().selectionMode()?t().isSelected(n())&&!t().disallowEmptySelection()?t().toggleSelection(n()):t().replaceSelection(n()):e?.shiftKey?t().extendSelection(n()):"toggle"===t().selectionBehavior()||QKe(e)||"pointerType"in e&&"touch"===e.pointerType?t().toggleSelection(n()):t().replaceSelection(n()))},o=()=>xze(e.disabled)||t().isDisabled(n()),s=()=>!o()&&t().canSelectItem(n());let l=null;const u=za((()=>{if(!i()&&!o())return n()===t().focusedKey()?0:-1})),c=za((()=>xze(e.virtualized)?void 0:n()));return Da(Ha([a,n,i,()=>t().focusedKey(),()=>t().isFocused()],(([a,t,n,i,r])=>{a&&t===i&&r&&!n&&document.activeElement!==a&&(e.focus?e.focus():ZOe(a))}))),{isSelected:()=>t().isSelected(n()),isDisabled:o,allowsSelection:s,tabIndex:u,dataKey:c,onPointerDown:a=>{s()&&(l=a.pointerType,"mouse"!==a.pointerType||0!==a.button||xze(e.shouldSelectOnPressUp)||r(a))},onPointerUp:a=>{s()&&"mouse"===a.pointerType&&0===a.button&&xze(e.shouldSelectOnPressUp)&&xze(e.allowsDifferentPressOrigin)&&r(a)},onClick:a=>{s()&&(xze(e.shouldSelectOnPressUp)&&!xze(e.allowsDifferentPressOrigin)||"mouse"!==l)&&r(a)},onKeyDown:e=>{s()&&["Enter"," "].includes(e.key)&&(YKe(e)?t().toggleSelection(n()):r(e))},onMouseDown:e=>{o()&&e.preventDefault()},onFocus:e=>{const r=a();i()||o()||!r||e.target===r&&t().setFocusedKey(n())}}}var nHe=class{collection;state;constructor(e,a){this.collection=e,this.state=a}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(null==e||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if("none"===this.state.selectionMode())return!1;const a=this.getKey(e);return null!=a&&this.state.selectedKeys().has(a)}isEmpty(){return 0===this.state.selectedKeys().size}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every((a=>e.has(a)))}firstSelectedKey(){let e;for(const a of this.state.selectedKeys()){const t=this.collection().getItem(a);e&&!(null!=t?.index&&null!=e?.index&&t.index<e.index)||(e=t)}return e?.key}lastSelectedKey(){let e;for(const a of this.state.selectedKeys()){const t=this.collection().getItem(a);e&&!(null!=t?.index&&null!=e?.index&&t.index>e.index)||(e=t)}return e?.key}extendSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode())return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const t=this.state.selectedKeys(),n=t.anchorKey||a,i=new ZKe(t,n,a);for(const r of this.getKeyRange(n,t.currentKey||a))i.delete(r);for(const r of this.getKeyRange(a,n))this.canSelectItem(r)&&i.add(r);this.state.setSelectedKeys(i)}getKeyRange(e,a){const t=this.collection().getItem(e),n=this.collection().getItem(a);return t&&n?null!=t.index&&null!=n.index&&t.index<=n.index?this.getKeyRangeInternal(e,a):this.getKeyRangeInternal(a,e):[]}getKeyRangeInternal(e,a){const t=[];let n=e;for(;null!=n;){const e=this.collection().getItem(n);if(e&&"item"===e.type&&t.push(n),n===a)return t;n=this.collection().getKeyAfter(n)}return[]}getKey(e){const a=this.collection().getItem(e);return a?a&&"item"===a.type?a.key:null:e}toggleSelection(e){if("none"===this.selectionMode())return;if("single"===this.selectionMode()&&!this.isSelected(e))return void this.replaceSelection(e);const a=this.getKey(e);if(null==a)return;const t=new ZKe(this.state.selectedKeys());t.has(a)?t.delete(a):this.canSelectItem(a)&&(t.add(a),t.anchorKey=a,t.currentKey=a),this.disallowEmptySelection()&&0===t.size||this.state.setSelectedKeys(t)}replaceSelection(e){if("none"===this.selectionMode())return;const a=this.getKey(e);if(null==a)return;const t=this.canSelectItem(a)?new ZKe([a],a,a):new ZKe;this.state.setSelectedKeys(t)}setSelectedKeys(e){if("none"===this.selectionMode())return;const a=new ZKe;for(const t of e){const e=this.getKey(t);if(null!=e&&(a.add(e),"single"===this.selectionMode()))break}this.state.setSelectedKeys(a)}selectAll(){"multiple"===this.selectionMode()&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new ZKe)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,a){"none"!==this.selectionMode()&&("single"===this.selectionMode()?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):"toggle"===this.selectionBehavior()||a&&"touch"===a.pointerType?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const a=this.selectedKeys();if(e.size!==a.size)return!1;for(const t of e)if(!a.has(t))return!1;for(const t of a)if(!e.has(t))return!1;return!0}canSelectItem(e){if("none"===this.state.selectionMode())return!1;const a=this.collection().getItem(e);return null!=a&&!a.disabled}isDisabled(e){const a=this.collection().getItem(e);return!a||a.disabled}getAllSelectableKeys(){const e=[];return(a=>{for(;null!=a;){if(this.canSelectItem(a)){const t=this.collection().getItem(a);if(!t)continue;"item"===t.type&&e.push(a)}a=this.collection().getKeyAfter(a)}})(this.collection().getFirstKey()),e}},iHe=class{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const n of e)this.keyMap.set(n.key,n);if(0===this.keyMap.size)return;let a,t=0;for(const[n,i]of this.keyMap)a?(a.nextKey=n,i.prevKey=a.key):(this.firstKey=n,i.prevKey=void 0),"item"===i.type&&(i.index=t++),a=i,a.nextKey=void 0;this.lastKey=a.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){return this.keyMap.get(e)?.prevKey}getKeyAfter(e){return this.keyMap.get(e)?.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const a=[...this.getKeys()];return this.getItem(a[e])}};var rHe,oHe=e=>"function"==typeof e?e():e,sHe=e=>{const a=za((()=>{const a=oHe(e.element);if(a)return getComputedStyle(a)})),t=()=>a()?.animationName??"none",[n,i]=La(oHe(e.show)?"present":"hidden");let r="none";return Da((n=>{const o=oHe(e.show);return Ka((()=>{if(n===o)return o;const e=r,s=t();if(o)i("present");else if("none"===s||"none"===a()?.display)i("hidden");else{i(!0===n&&e!==s?"hiding":"hidden")}})),o})),Da((()=>{const a=oHe(e.element);if(!a)return;const o=e=>{e.target===a&&(r=t())},s=e=>{const r=t().includes(e.animationName);e.target===a&&r&&"hiding"===n()&&i("hidden")};a.addEventListener("animationstart",o),a.addEventListener("animationcancel",s),a.addEventListener("animationend",s),Fa((()=>{a.removeEventListener("animationstart",o),a.removeEventListener("animationcancel",s),a.removeEventListener("animationend",s)}))})),{present:()=>"present"===n()||"hiding"===n(),state:n}},lHe="data-kb-top-layer",uHe=!1,cHe=[];function dHe(e){return cHe.findIndex((a=>a.node===e))}function mHe(){return cHe.filter((e=>e.isPointerBlocking))}function hHe(){return mHe().length>0}function pHe(e){const a=dHe([...mHe()].slice(-1)[0]?.node);return dHe(e)<a}var gHe={layers:cHe,isTopMostLayer:function(e){return cHe[cHe.length-1].node===e},hasPointerBlockingLayer:hHe,isBelowPointerBlockingLayer:pHe,addLayer:function(e){cHe.push(e)},removeLayer:function(e){const a=dHe(e);a<0||cHe.splice(a,1)},indexOf:dHe,find:function(e){return cHe[dHe(e)]},assignPointerEventToLayers:function(){for(const{node:e}of cHe)e.style.pointerEvents=pHe(e)?"none":"auto"},disableBodyPointerEvents:function(e){if(hHe()&&!uHe){const a=IOe(e);rHe=document.body.style.pointerEvents,a.body.style.pointerEvents="none",uHe=!0}},restoreBodyPointerEvents:function(e){if(hHe())return;const a=IOe(e);a.body.style.pointerEvents=rHe,0===a.body.style.length&&a.body.removeAttribute("style"),uHe=!1}};_Ke({},{Button:()=>yHe,Root:()=>vHe});var fHe=["button","color","file","image","reset","submit"];function vHe(e){let a;const t=uKe({type:"button"},e),[n,i]=bt(t,["ref","type","disabled"]),r=vKe((()=>a),(()=>"button")),o=za((()=>{const e=r();return null!=e&&function(e){const a=e.tagName.toLowerCase();return"button"===a||!("input"!==a||!e.type)&&-1!==fHe.indexOf(e.type)}({tagName:e,type:n.type})})),s=za((()=>"input"===r())),l=za((()=>"a"===r()&&null!=a?.getAttribute("href")));return ht(bKe,yt({as:"button",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)},get type(){return o()||s()?n.type:void 0},get role(){return o()||l()?void 0:"button"},get tabIndex(){return o()||l()||n.disabled?void 0:0},get disabled(){return o()||s()?n.disabled:void 0},get"aria-disabled"(){return!(o()||s()||!n.disabled)||void 0},get"data-disabled"(){return n.disabled?"":void 0}},i))}var yHe=vHe,bHe=["top","right","bottom","left"],kHe=Math.min,SHe=Math.max,wHe=Math.round,AHe=Math.floor,CHe=e=>({x:e,y:e}),MHe={left:"right",right:"left",bottom:"top",top:"bottom"},THe={start:"end",end:"start"};function xHe(e,a,t){return SHe(e,kHe(a,t))}function EHe(e,a){return"function"==typeof e?e(a):e}function NHe(e){return e.split("-")[0]}function _He(e){return e.split("-")[1]}function PHe(e){return"x"===e?"y":"x"}function jHe(e){return"y"===e?"height":"width"}function LHe(e){return["top","bottom"].includes(NHe(e))?"y":"x"}function BHe(e){return PHe(LHe(e))}function RHe(e){return e.replace(/start|end/g,(e=>THe[e]))}function DHe(e){return e.replace(/left|right|bottom|top/g,(e=>MHe[e]))}function zHe(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function OHe(e){const{x:a,y:t,width:n,height:i}=e;return{width:n,height:i,top:t,left:a,right:a+n,bottom:t+i,x:a,y:t}}function KHe(e,a,t){let{reference:n,floating:i}=e;const r=LHe(a),o=BHe(a),s=jHe(o),l=NHe(a),u="y"===r,c=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,m=n[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:n.y-i.height};break;case"bottom":h={x:c,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-i.width,y:d};break;default:h={x:n.x,y:n.y}}switch(_He(a)){case"start":h[o]-=m*(t&&u?-1:1);break;case"end":h[o]+=m*(t&&u?-1:1)}return h}async function HHe(e,a){var t;void 0===a&&(a={});const{x:n,y:i,platform:r,rects:o,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:m=!1,padding:h=0}=EHe(a,e),p=zHe(h),g=s[m?"floating"===d?"reference":"floating":d],f=OHe(await r.getClippingRect({element:null==(t=await(null==r.isElement?void 0:r.isElement(g)))||t?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),v="floating"===d?{x:n,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),b=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},k=OHe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:y,strategy:l}):v);return{top:(f.top-k.top+p.top)/b.y,bottom:(k.bottom-f.bottom+p.bottom)/b.y,left:(f.left-k.left+p.left)/b.x,right:(k.right-f.right+p.right)/b.x}}function IHe(e,a){return{top:e.top-a.height,right:e.right-a.width,bottom:e.bottom-a.height,left:e.left-a.width}}function FHe(e){return bHe.some((a=>e[a]>=0))}function GHe(e){return UHe(e)?(e.nodeName||"").toLowerCase():"#document"}function VHe(e){var a;return(null==e||null==(a=e.ownerDocument)?void 0:a.defaultView)||window}function JHe(e){var a;return null==(a=(UHe(e)?e.ownerDocument:e.document)||window.document)?void 0:a.documentElement}function UHe(e){return e instanceof Node||e instanceof VHe(e).Node}function WHe(e){return e instanceof Element||e instanceof VHe(e).Element}function qHe(e){return e instanceof HTMLElement||e instanceof VHe(e).HTMLElement}function $He(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof VHe(e).ShadowRoot)}function ZHe(e){const{overflow:a,overflowX:t,overflowY:n,display:i}=tIe(e);return/auto|scroll|overlay|hidden|clip/.test(a+n+t)&&!["inline","contents"].includes(i)}function YHe(e){return["table","td","th"].includes(GHe(e))}function QHe(e){return[":popover-open",":modal"].some((a=>{try{return e.matches(a)}catch(rXe){return!1}}))}function XHe(e){const a=eIe(),t=WHe(e)?tIe(e):e;return"none"!==t.transform||"none"!==t.perspective||!!t.containerType&&"normal"!==t.containerType||!a&&!!t.backdropFilter&&"none"!==t.backdropFilter||!a&&!!t.filter&&"none"!==t.filter||["transform","perspective","filter"].some((e=>(t.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(t.contain||"").includes(e)))}function eIe(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function aIe(e){return["html","body","#document"].includes(GHe(e))}function tIe(e){return VHe(e).getComputedStyle(e)}function nIe(e){return WHe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function iIe(e){if("html"===GHe(e))return e;const a=e.assignedSlot||e.parentNode||$He(e)&&e.host||JHe(e);return $He(a)?a.host:a}function rIe(e){const a=iIe(e);return aIe(a)?e.ownerDocument?e.ownerDocument.body:e.body:qHe(a)&&ZHe(a)?a:rIe(a)}function oIe(e,a,t){var n;void 0===a&&(a=[]),void 0===t&&(t=!0);const i=rIe(e),r=i===(null==(n=e.ownerDocument)?void 0:n.body),o=VHe(i);return r?a.concat(o,o.visualViewport||[],ZHe(i)?i:[],o.frameElement&&t?oIe(o.frameElement):[]):a.concat(i,oIe(i,[],t))}function sIe(e){const a=tIe(e);let t=parseFloat(a.width)||0,n=parseFloat(a.height)||0;const i=qHe(e),r=i?e.offsetWidth:t,o=i?e.offsetHeight:n,s=wHe(t)!==r||wHe(n)!==o;return s&&(t=r,n=o),{width:t,height:n,$:s}}function lIe(e){return WHe(e)?e:e.contextElement}function uIe(e){const a=lIe(e);if(!qHe(a))return CHe(1);const t=a.getBoundingClientRect(),{width:n,height:i,$:r}=sIe(a);let o=(r?wHe(t.width):t.width)/n,s=(r?wHe(t.height):t.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var cIe=CHe(0);function dIe(e){const a=VHe(e);return eIe()&&a.visualViewport?{x:a.visualViewport.offsetLeft,y:a.visualViewport.offsetTop}:cIe}function mIe(e,a,t,n){void 0===a&&(a=!1),void 0===t&&(t=!1);const i=e.getBoundingClientRect(),r=lIe(e);let o=CHe(1);a&&(n?WHe(n)&&(o=uIe(n)):o=uIe(e));const s=function(e,a,t){return void 0===a&&(a=!1),!(!t||a&&t!==VHe(e))&&a}(r,t,n)?dIe(r):CHe(0);let l=(i.left+s.x)/o.x,u=(i.top+s.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(r){const e=VHe(r),a=n&&WHe(n)?VHe(n):n;let t=e,i=t.frameElement;for(;i&&n&&a!==t;){const e=uIe(i),a=i.getBoundingClientRect(),n=tIe(i),r=a.left+(i.clientLeft+parseFloat(n.paddingLeft))*e.x,o=a.top+(i.clientTop+parseFloat(n.paddingTop))*e.y;l*=e.x,u*=e.y,c*=e.x,d*=e.y,l+=r,u+=o,t=VHe(i),i=t.frameElement}}return OHe({width:c,height:d,x:l,y:u})}function hIe(e){return mIe(JHe(e)).left+nIe(e).scrollLeft}function pIe(e,a,t){let n;if("viewport"===a)n=function(e,a){const t=VHe(e),n=JHe(e),i=t.visualViewport;let r=n.clientWidth,o=n.clientHeight,s=0,l=0;if(i){r=i.width,o=i.height;const e=eIe();(!e||e&&"fixed"===a)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:o,x:s,y:l}}(e,t);else if("document"===a)n=function(e){const a=JHe(e),t=nIe(e),n=e.ownerDocument.body,i=SHe(a.scrollWidth,a.clientWidth,n.scrollWidth,n.clientWidth),r=SHe(a.scrollHeight,a.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+hIe(e);const s=-t.scrollTop;return"rtl"===tIe(n).direction&&(o+=SHe(a.clientWidth,n.clientWidth)-i),{width:i,height:r,x:o,y:s}}(JHe(e));else if(WHe(a))n=function(e,a){const t=mIe(e,!0,"fixed"===a),n=t.top+e.clientTop,i=t.left+e.clientLeft,r=qHe(e)?uIe(e):CHe(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:n*r.y}}(a,t);else{const t=dIe(e);n={...a,x:a.x-t.x,y:a.y-t.y}}return OHe(n)}function gIe(e,a){const t=iIe(e);return!(t===a||!WHe(t)||aIe(t))&&("fixed"===tIe(t).position||gIe(t,a))}function fIe(e,a,t){const n=qHe(a),i=JHe(a),r="fixed"===t,o=mIe(e,!0,r,a);let s={scrollLeft:0,scrollTop:0};const l=CHe(0);if(n||!n&&!r)if(("body"!==GHe(a)||ZHe(i))&&(s=nIe(a)),n){const e=mIe(a,!0,r,a);l.x=e.x+a.clientLeft,l.y=e.y+a.clientTop}else i&&(l.x=hIe(i));return{x:o.left+s.scrollLeft-l.x,y:o.top+s.scrollTop-l.y,width:o.width,height:o.height}}function vIe(e){return"static"===tIe(e).position}function yIe(e,a){return qHe(e)&&"fixed"!==tIe(e).position?a?a(e):e.offsetParent:null}function bIe(e,a){const t=VHe(e);if(QHe(e))return t;if(!qHe(e)){let a=iIe(e);for(;a&&!aIe(a);){if(WHe(a)&&!vIe(a))return a;a=iIe(a)}return t}let n=yIe(e,a);for(;n&&YHe(n)&&vIe(n);)n=yIe(n,a);return n&&aIe(n)&&vIe(n)&&!XHe(n)?t:n||function(e){let a=iIe(e);for(;qHe(a)&&!aIe(a);){if(XHe(a))return a;if(QHe(a))return null;a=iIe(a)}return null}(e)||t}var kIe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:a,rect:t,offsetParent:n,strategy:i}=e;const r="fixed"===i,o=JHe(n),s=!!a&&QHe(a.floating);if(n===o||s&&r)return t;let l={scrollLeft:0,scrollTop:0},u=CHe(1);const c=CHe(0),d=qHe(n);if((d||!d&&!r)&&(("body"!==GHe(n)||ZHe(o))&&(l=nIe(n)),qHe(n))){const e=mIe(n);u=uIe(n),c.x=e.x+n.clientLeft,c.y=e.y+n.clientTop}return{width:t.width*u.x,height:t.height*u.y,x:t.x*u.x-l.scrollLeft*u.x+c.x,y:t.y*u.y-l.scrollTop*u.y+c.y}},getDocumentElement:JHe,getClippingRect:function(e){let{element:a,boundary:t,rootBoundary:n,strategy:i}=e;const r=[..."clippingAncestors"===t?QHe(a)?[]:function(e,a){const t=a.get(e);if(t)return t;let n=oIe(e,[],!1).filter((e=>WHe(e)&&"body"!==GHe(e))),i=null;const r="fixed"===tIe(e).position;let o=r?iIe(e):e;for(;WHe(o)&&!aIe(o);){const a=tIe(o),t=XHe(o);t||"fixed"!==a.position||(i=null),(r?!t&&!i:!t&&"static"===a.position&&i&&["absolute","fixed"].includes(i.position)||ZHe(o)&&!t&&gIe(e,o))?n=n.filter((e=>e!==o)):i=a,o=iIe(o)}return a.set(e,n),n}(a,this._c):[].concat(t),n],o=r.reduce(((e,t)=>{const n=pIe(a,t,i);return e.top=SHe(n.top,e.top),e.right=kHe(n.right,e.right),e.bottom=kHe(n.bottom,e.bottom),e.left=SHe(n.left,e.left),e}),pIe(a,r[0],i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:bIe,getElementRects:async function(e){const a=this.getOffsetParent||bIe,t=this.getDimensions,n=await t(e.floating);return{reference:fIe(e.reference,await a(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:a,height:t}=sIe(e);return{width:a,height:t}},getScale:uIe,isElement:WHe,isRTL:function(e){return"rtl"===tIe(e).direction}};function SIe(e,a,t,n){void 0===n&&(n={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=n,u=lIe(e),c=i||r?[...u?oIe(u):[],...oIe(a)]:[];c.forEach((e=>{i&&e.addEventListener("scroll",t,{passive:!0}),r&&e.addEventListener("resize",t)}));const d=u&&s?function(e,a){let t,n=null;const i=JHe(e);function r(){var e;clearTimeout(t),null==(e=n)||e.disconnect(),n=null}return function o(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),r();const{left:u,top:c,width:d,height:m}=e.getBoundingClientRect();if(s||a(),!d||!m)return;const h={rootMargin:-AHe(c)+"px "+-AHe(i.clientWidth-(u+d))+"px "+-AHe(i.clientHeight-(c+m))+"px "+-AHe(u)+"px",threshold:SHe(0,kHe(1,l))||1};let p=!0;function g(e){const a=e[0].intersectionRatio;if(a!==l){if(!p)return o();a?o(!1,a):t=setTimeout((()=>{o(!1,1e-7)}),1e3)}p=!1}try{n=new IntersectionObserver(g,{...h,root:i.ownerDocument})}catch(rXe){n=new IntersectionObserver(g,h)}n.observe(e)}(!0),r}(u,t):null;let m,h=-1,p=null;o&&(p=new ResizeObserver((e=>{let[n]=e;n&&n.target===u&&p&&(p.unobserve(a),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(a)}))),t()})),u&&!l&&p.observe(u),p.observe(a));let g=l?mIe(e):null;return l&&function a(){const n=mIe(e);!g||n.x===g.x&&n.y===g.y&&n.width===g.width&&n.height===g.height||t();g=n,m=requestAnimationFrame(a)}(),t(),()=>{var e;c.forEach((e=>{i&&e.removeEventListener("scroll",t),r&&e.removeEventListener("resize",t)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var wIe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(a){var t,n;const{x:i,y:r,placement:o,middlewareData:s}=a,l=await async function(e,a){const{placement:t,platform:n,elements:i}=e,r=await(null==n.isRTL?void 0:n.isRTL(i.floating)),o=NHe(t),s=_He(t),l="y"===LHe(t),u=["left","top"].includes(o)?-1:1,c=r&&l?-1:1,d=EHe(a,e);let{mainAxis:m,crossAxis:h,alignmentAxis:p}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return s&&"number"==typeof p&&(h="end"===s?-1*p:p),l?{x:h*c,y:m*u}:{x:m*u,y:h*c}}(a,e);return o===(null==(t=s.offset)?void 0:t.placement)&&null!=(n=s.arrow)&&n.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:o}}}}},AIe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(a){const{x:t,y:n,placement:i}=a,{mainAxis:r=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:a,y:t}=e;return{x:a,y:t}}},...l}=EHe(e,a),u={x:t,y:n},c=await HHe(a,l),d=LHe(NHe(i)),m=PHe(d);let h=u[m],p=u[d];if(r){h=xHe(h+c["y"===m?"top":"left"],h,h-c["y"===m?"bottom":"right"])}if(o){p=xHe(p+c["y"===d?"top":"left"],p,p-c["y"===d?"bottom":"right"])}const g=s.fn({...a,[m]:h,[d]:p});return{...g,data:{x:g.x-t,y:g.y-n}}}}},CIe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(a){var t,n;const{placement:i,middlewareData:r,rects:o,initialPlacement:s,platform:l,elements:u}=a,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...f}=EHe(e,a);if(null!=(t=r.arrow)&&t.alignmentOffset)return{};const v=NHe(i),y=LHe(s),b=NHe(s)===s,k=await(null==l.isRTL?void 0:l.isRTL(u.floating)),S=m||(b||!g?[DHe(s)]:function(e){const a=DHe(e);return[RHe(e),a,RHe(a)]}(s)),w="none"!==p;!m&&w&&S.push(...function(e,a,t,n){const i=_He(e);let r=function(e,a,t){const n=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return t?a?i:n:a?n:i;case"left":case"right":return a?r:o;default:return[]}}(NHe(e),"start"===t,n);return i&&(r=r.map((e=>e+"-"+i)),a&&(r=r.concat(r.map(RHe)))),r}(s,g,p,k));const A=[s,...S],C=await HHe(a,f),M=[];let T=(null==(n=r.flip)?void 0:n.overflows)||[];if(c&&M.push(C[v]),d){const e=function(e,a,t){void 0===t&&(t=!1);const n=_He(e),i=BHe(e),r=jHe(i);let o="x"===i?n===(t?"end":"start")?"right":"left":"start"===n?"bottom":"top";return a.reference[r]>a.floating[r]&&(o=DHe(o)),[o,DHe(o)]}(i,o,k);M.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:i,overflows:M}],!M.every((e=>e<=0))){var x,E;const e=((null==(x=r.flip)?void 0:x.index)||0)+1,a=A[e];if(a)return{data:{index:e,overflows:T},reset:{placement:a}};let t=null==(E=T.filter((e=>e.overflows[0]<=0)).sort(((e,a)=>e.overflows[1]-a.overflows[1]))[0])?void 0:E.placement;if(!t)switch(h){case"bestFit":{var N;const e=null==(N=T.filter((e=>{if(w){const a=LHe(e.placement);return a===y||"y"===a}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,a)=>e+a),0)])).sort(((e,a)=>e[1]-a[1]))[0])?void 0:N[0];e&&(t=e);break}case"initialPlacement":t=s}if(i!==t)return{reset:{placement:t}}}return{}}}},MIe=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(a){const{placement:t,rects:n,platform:i,elements:r}=a,{apply:o=()=>{},...s}=EHe(e,a),l=await HHe(a,s),u=NHe(t),c=_He(t),d="y"===LHe(t),{width:m,height:h}=n.floating;let p,g;"top"===u||"bottom"===u?(p=u,g=c===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(g=u,p="end"===c?"top":"bottom");const f=h-l.top-l.bottom,v=m-l.left-l.right,y=kHe(h-l[p],f),b=kHe(m-l[g],v),k=!a.middlewareData.shift;let S=y,w=b;if(d?w=c||k?kHe(b,v):v:S=c||k?kHe(y,f):f,k&&!c){const e=SHe(l.left,0),a=SHe(l.right,0),t=SHe(l.top,0),n=SHe(l.bottom,0);d?w=m-2*(0!==e||0!==a?e+a:SHe(l.left,l.right)):S=h-2*(0!==t||0!==n?t+n:SHe(l.top,l.bottom))}await o({...a,availableWidth:w,availableHeight:S});const A=await i.getDimensions(r.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}},TIe=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(a){const{rects:t}=a,{strategy:n="referenceHidden",...i}=EHe(e,a);switch(n){case"referenceHidden":{const e=IHe(await HHe(a,{...i,elementContext:"reference"}),t.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:FHe(e)}}}case"escaped":{const e=IHe(await HHe(a,{...i,altBoundary:!0}),t.floating);return{data:{escapedOffsets:e,escaped:FHe(e)}}}default:return{}}}}},xIe=e=>({name:"arrow",options:e,async fn(a){const{x:t,y:n,placement:i,rects:r,platform:o,elements:s,middlewareData:l}=a,{element:u,padding:c=0}=EHe(e,a)||{};if(null==u)return{};const d=zHe(c),m={x:t,y:n},h=BHe(i),p=jHe(h),g=await o.getDimensions(u),f="y"===h,v=f?"top":"left",y=f?"bottom":"right",b=f?"clientHeight":"clientWidth",k=r.reference[p]+r.reference[h]-m[h]-r.floating[p],S=m[h]-r.reference[h],w=await(null==o.getOffsetParent?void 0:o.getOffsetParent(u));let A=w?w[b]:0;A&&await(null==o.isElement?void 0:o.isElement(w))||(A=s.floating[b]||r.floating[p]);const C=k/2-S/2,M=A/2-g[p]/2-1,T=kHe(d[v],M),x=kHe(d[y],M),E=T,N=A-g[p]-x,_=A/2-g[p]/2+C,P=xHe(E,_,N),j=!l.arrow&&null!=_He(i)&&_!==P&&r.reference[p]/2-(_<E?T:x)-g[p]/2<0,L=j?_<E?_-E:_-N:0;return{[h]:m[h]+L,data:{[h]:P,centerOffset:_-P-L,...j&&{alignmentOffset:L}},reset:j}}}),EIe=(e,a,t)=>{const n={platform:kIe,...t},i={...n.platform,_c:new Map};return(async(e,a,t)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:o}=t,s=r.filter(Boolean),l=await(null==o.isRTL?void 0:o.isRTL(a));let u=await o.getElementRects({reference:e,floating:a,strategy:i}),{x:c,y:d}=KHe(u,n,l),m=n,h={},p=0;for(let g=0;g<s.length;g++){const{name:t,fn:r}=s[g],{x:f,y:v,data:y,reset:b}=await r({x:c,y:d,initialPlacement:n,placement:m,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:a}});c=null!=f?f:c,d=null!=v?v:d,h={...h,[t]:{...h[t],...y}},b&&p<=50&&(p++,"object"==typeof b&&(b.placement&&(m=b.placement),b.rects&&(u=!0===b.rects?await o.getElementRects({reference:e,floating:a,strategy:i}):b.rects),({x:c,y:d}=KHe(u,m,l))),g=-1)}return{x:c,y:d,placement:m,strategy:i,middlewareData:h}})(e,a,{...n,platform:i})},NIe=Wa();function _Ie(){const e=qa(NIe);if(void 0===e)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var PIe=Ot('<svg display="block" viewBox="0 0 30 30" style="transform:scale(1.02)"><g><path fill="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"></path><path stroke="none" d="M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z">'),jIe={top:180,right:-90,bottom:0,left:90};function LIe(e){const a=_Ie(),t=uKe({size:30},e),[n,i]=bt(t,["ref","style","size"]),r=()=>a.currentPlacement().split("-")[0],o=function(e){const[a,t]=La();return Da((()=>{const a=e();var n;a&&t((n=a,IOe(n).defaultView||window).getComputedStyle(a))})),a}(a.contentRef),s=()=>2*Number.parseInt(o()?.getPropertyValue(`border-${r()}-width`)||"0px")*(30/n.size);return ht(bKe,yt({as:"div",ref(e){const t=kOe(a.setArrowRef,n.ref);"function"==typeof t&&t(e)},"aria-hidden":"true",get style(){return ROe({position:"absolute","font-size":`${n.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:o()?.getPropertyValue("background-color")||"none",stroke:o()?.getPropertyValue(`border-${r()}-color`)||"none","stroke-width":s()},n.style)}},i,{get children(){const e=PIe(),a=e.firstChild;return Ra((()=>Ht(a,"transform",`rotate(${jIe[r()]} 15 15) translate(0 2)`))),e}}))}function BIe(e){const{x:a=0,y:t=0,width:n=0,height:i=0}=e??{};if("function"==typeof DOMRect)return new DOMRect(a,t,n,i);const r={x:a,y:t,width:n,height:i,top:t,right:a+n,bottom:t+i,left:a};return{...r,toJSON:()=>r}}function RIe(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var DIe={top:"bottom",right:"left",bottom:"top",left:"right"};var zIe=Object.assign((function(e){const a=uKe({getAnchorRect:e=>e?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[t,n]=La(),[i,r]=La(),[o,s]=La(a.placement),l=()=>{return e=a.anchorRef?.(),t=a.getAnchorRect,{contextElement:e,getBoundingClientRect:()=>{const a=t(e);return a?BIe(a):e?e.getBoundingClientRect():BIe()}};var e,t},{direction:u}=qKe();async function c(){const e=l(),n=t(),r=i();if(!e||!n)return;const o=(r?.clientHeight||0)/2,c="number"==typeof a.gutter?a.gutter+o:a.gutter??o;n.style.setProperty("--kb-popper-content-overflow-padding",`${a.overflowPadding}px`),e.getBoundingClientRect();const d=[wIe((({placement:e})=>{const t=!!e.split("-")[1];return{mainAxis:c,crossAxis:t?void 0:a.shift,alignmentAxis:a.shift}}))];if(!1!==a.flip){const e="string"==typeof a.flip?a.flip.split(" "):void 0;if(void 0!==e&&!e.every(RIe))throw new Error("`flip` expects a spaced-delimited list of placements");d.push(CIe({padding:a.overflowPadding,fallbackPlacements:e}))}(a.slide||a.overlap)&&d.push(AIe({mainAxis:a.slide,crossAxis:a.overlap,padding:a.overflowPadding})),d.push(MIe({padding:a.overflowPadding,apply({availableWidth:e,availableHeight:t,rects:i}){const r=Math.round(i.reference.width);e=Math.floor(e),t=Math.floor(t),n.style.setProperty("--kb-popper-anchor-width",`${r}px`),n.style.setProperty("--kb-popper-content-available-width",`${e}px`),n.style.setProperty("--kb-popper-content-available-height",`${t}px`),a.sameWidth&&(n.style.width=`${r}px`),a.fitViewport&&(n.style.maxWidth=`${e}px`,n.style.maxHeight=`${t}px`)}})),a.hideWhenDetached&&d.push(TIe({padding:a.detachedPadding})),r&&d.push(xIe({element:r,padding:a.arrowPadding}));const m=await EIe(e,n,{placement:a.placement,strategy:"absolute",middleware:d,platform:{...kIe,isRTL:()=>"rtl"===u()}});if(s(m.placement),a.onCurrentPlacementChange?.(m.placement),!n)return;n.style.setProperty("--kb-popper-content-transform-origin",function(e,a){const[t,n]=e.split("-"),i=DIe[t];return n?"left"===t||"right"===t?`${i} ${"start"===n?"top":"bottom"}`:"start"===n?`${i} ${"rtl"===a?"right":"left"}`:`${i} ${"rtl"===a?"left":"right"}`:`${i} center`}(m.placement,u()));const h=Math.round(m.x),p=Math.round(m.y);let g;if(a.hideWhenDetached&&(g=m.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(n.style,{top:"0",left:"0",transform:`translate3d(${h}px, ${p}px, 0)`,visibility:g}),r&&m.middlewareData.arrow){const{x:e,y:a}=m.middlewareData.arrow,t=m.placement.split("-")[0];Object.assign(r.style,{left:null!=e?`${e}px`:"",top:null!=a?`${a}px`:"",[t]:"100%"})}}return Da((()=>{const e=l(),a=t();if(!e||!a)return;Fa(SIe(e,a,c,{elementResize:"function"==typeof ResizeObserver}))})),Da((()=>{const e=t(),n=a.contentRef?.();e&&n&&queueMicrotask((()=>{e.style.zIndex=getComputedStyle(n).zIndex}))})),ht(NIe.Provider,{value:{currentPlacement:o,contentRef:()=>a.contentRef?.(),setPositionerRef:n,setArrowRef:r},get children(){return a.children}})}),{Arrow:LIe,Context:NIe,usePopperContext:_Ie,Positioner:function(e){const a=_Ie(),[t,n]=bt(e,["ref","style"]);return ht(bKe,yt({as:"div",ref(e){const n=kOe(a.setPositionerRef,t.ref);"function"==typeof n&&n(e)},"data-popper-positioner":"",get style(){return ROe({position:"absolute",top:0,left:0,"min-width":"max-content"},t.style)}},n))}});var OIe="interactOutside.pointerDownOutside",KIe="interactOutside.focusOutside";var HIe=Wa();function IIe(e){let a;const t=qa(HIe),[n,i]=bt(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]);!function(e,a){let t,n=lKe;const i=()=>IOe(a()),r=a=>e.onPointerDownOutside?.(a),o=a=>e.onFocusOutside?.(a),s=a=>e.onInteractOutside?.(a),l=t=>{const n=t.target;return n instanceof HTMLElement&&!n.closest(`[${lHe}]`)&&!!KOe(i(),n)&&!KOe(a(),n)&&!e.shouldExcludeElement?.(n)},u=e=>{function t(){const t=a(),n=e.target;if(!t||!n||!l(e))return;const i=qOe([r,s]);n.addEventListener(OIe,i,{once:!0});const o=new CustomEvent(OIe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:2===e.button||$Oe(e)&&0===e.button}});n.dispatchEvent(o)}"touch"===e.pointerType?(i().removeEventListener("click",t),n=t,i().addEventListener("click",t,{once:!0})):t()},c=e=>{const t=a(),n=e.target;if(!t||!n||!l(e))return;const i=qOe([o,s]);n.addEventListener(KIe,i,{once:!0});const r=new CustomEvent(KIe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:!1}});n.dispatchEvent(r)};Da((()=>{xze(e.isDisabled)||(t=window.setTimeout((()=>{i().addEventListener("pointerdown",u,!0)}),0),i().addEventListener("focusin",c,!0),Fa((()=>{window.clearTimeout(t),i().removeEventListener("click",n),i().removeEventListener("pointerdown",u,!0),i().removeEventListener("focusin",c,!0)})))}))}({shouldExcludeElement:e=>!!a&&(n.excludedElements?.some((a=>KOe(a(),e)))||[...r].some((a=>KOe(a,e)))),onPointerDownOutside:e=>{a&&!gHe.isBelowPointerBlockingLayer(a)&&(n.bypassTopMostLayerCheck||gHe.isTopMostLayer(a))&&(n.onPointerDownOutside?.(e),n.onInteractOutside?.(e),e.defaultPrevented||n.onDismiss?.())},onFocusOutside:e=>{n.onFocusOutside?.(e),n.onInteractOutside?.(e),e.defaultPrevented||n.onDismiss?.()}},(()=>a)),function(e){const a=a=>{a.key===GOe.Escape&&e.onEscapeKeyDown?.(a)};Da((()=>{if(xze(e.isDisabled))return;const t=e.ownerDocument?.()??IOe();t.addEventListener("keydown",a),Fa((()=>{t.removeEventListener("keydown",a)}))}))}({ownerDocument:()=>IOe(a),onEscapeKeyDown:e=>{a&&gHe.isTopMostLayer(a)&&(n.onEscapeKeyDown?.(e),!e.defaultPrevented&&n.onDismiss&&(e.preventDefault(),n.onDismiss()))}}),Ia((()=>{if(!a)return;gHe.addLayer({node:a,isPointerBlocking:n.disableOutsidePointerEvents,dismiss:n.onDismiss});const e=t?.registerNestedLayer(a);gHe.assignPointerEventToLayers(),gHe.disableBodyPointerEvents(a),Fa((()=>{a&&(gHe.removeLayer(a),e?.(),gHe.assignPointerEventToLayers(),gHe.restoreBodyPointerEvents(a))}))})),Da(Ha([()=>a,()=>n.disableOutsidePointerEvents],(([e,a])=>{if(!e)return;const t=gHe.find(e);t&&t.isPointerBlocking!==a&&(t.isPointerBlocking=a,gHe.assignPointerEventToLayers()),a&&gHe.disableBodyPointerEvents(e),Fa((()=>{gHe.restoreBodyPointerEvents(e)}))}),{defer:!0}));return ht(HIe.Provider,{value:{registerNestedLayer:e=>{r.add(e);const a=t?.registerNestedLayer(e);return()=>{r.delete(e),a?.()}}},get children(){return ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)}},i))}})}function FIe(e={}){const[a,t]=EKe({value:()=>xze(e.open),defaultValue:()=>!!xze(e.defaultOpen),onChange:a=>e.onOpenChange?.(a)}),n=()=>{t(!0)},i=()=>{t(!1)};return{isOpen:a,setIsOpen:t,open:n,close:i,toggle:()=>{a()?i():n()}}}var GIe={};_Ke(GIe,{Description:()=>AKe,ErrorMessage:()=>CKe,Item:()=>qIe,ItemControl:()=>$Ie,ItemDescription:()=>ZIe,ItemIndicator:()=>YIe,ItemInput:()=>QIe,ItemLabel:()=>XIe,Label:()=>eFe,RadioGroup:()=>tFe,Root:()=>aFe});var VIe=Wa();function JIe(){const e=qa(VIe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var UIe=Wa();function WIe(){const e=qa(UIe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function qIe(e){const a=wKe(),t=JIe(),n=uKe({id:`${a.generateId("item")}-${wt()}`},e),[i,r]=bt(n,["value","disabled","onPointerDown"]),[o,s]=La(),[l,u]=La(),[c,d]=La(),[m,h]=La(),[p,g]=La(!1),f=za((()=>t.isSelectedValue(i.value))),v=za((()=>i.disabled||a.isDisabled()||!1)),y=e=>{WOe(e,i.onPointerDown),p()&&e.preventDefault()},b=za((()=>({...a.dataset(),"data-disabled":v()?"":void 0,"data-checked":f()?"":void 0}))),k={value:()=>i.value,dataset:b,isSelected:f,isDisabled:v,inputId:o,labelId:l,descriptionId:c,inputRef:m,select:()=>t.setSelectedValue(i.value),generateId:OOe((()=>r.id)),registerInput:fKe(s),registerLabel:fKe(u),registerDescription:fKe(d),setIsFocused:g,setInputRef:h};return ht(UIe.Provider,{value:k,get children(){return ht(bKe,yt({as:"div",role:"group",onPointerDown:y},b,r))}})}function $Ie(e){const a=WIe(),t=uKe({id:a.generateId("control")},e),[n,i]=bt(t,["onClick","onKeyDown"]);return ht(bKe,yt({as:"div",onClick:e=>{WOe(e,n.onClick),a.select(),a.inputRef()?.focus()},onKeyDown:e=>{WOe(e,n.onKeyDown),e.key===GOe.Space&&(a.select(),a.inputRef()?.focus())}},(()=>a.dataset()),i))}function ZIe(e){const a=WIe(),t=uKe({id:a.generateId("description")},e);return Da((()=>Fa(a.registerDescription(t.id)))),ht(bKe,yt({as:"div"},(()=>a.dataset()),t))}function YIe(e){const a=WIe(),t=uKe({id:a.generateId("indicator")},e),[n,i]=bt(t,["ref","forceMount"]),[r,o]=La(),{present:s}=sHe({show:()=>n.forceMount||a.isSelected(),element:()=>r()??null});return ht(Tt,{get when(){return s()},get children(){return ht(bKe,yt({as:"div",ref(e){const a=kOe(o,n.ref);"function"==typeof a&&a(e)}},(()=>a.dataset()),i))}})}function QIe(e){const a=wKe(),t=JIe(),n=WIe(),i=uKe({id:n.generateId("input")},e),[r,o]=bt(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),[s,l]=La(!1);return Da(Ha([()=>n.isSelected(),()=>n.value()],(e=>{if(!e[0]&&e[1]===n.value())return;l(!0);const a=n.inputRef();a?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))}),{defer:!0})),Da((()=>Fa(n.registerInput(o.id)))),ht(bKe,yt({as:"input",ref(e){const a=kOe(n.setInputRef,r.ref);"function"==typeof a&&a(e)},type:"radio",get name(){return a.name()},get value(){return n.value()},get checked(){return n.isSelected()},get required(){return a.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return a.isReadOnly()},get style(){return ROe({...gKe},r.style)},get"aria-labelledby"(){return[r["aria-labelledby"],n.labelId(),null!=r["aria-labelledby"]&&null!=o["aria-label"]?o.id:void 0].filter(Boolean).join(" ")||void 0},get"aria-describedby"(){return[r["aria-describedby"],n.descriptionId(),t.ariaDescribedBy()].filter(Boolean).join(" ")||void 0},onChange:e=>{if(WOe(e,r.onChange),e.stopPropagation(),!s()){t.setSelectedValue(n.value());e.target.checked=n.isSelected()}l(!1)},onFocus:e=>{WOe(e,r.onFocus),n.setIsFocused(!0)},onBlur:e=>{WOe(e,r.onBlur),n.setIsFocused(!1)}},(()=>n.dataset()),o))}function XIe(e){const a=WIe(),t=uKe({id:a.generateId("label")},e);return Da((()=>Fa(a.registerLabel(t.id)))),ht(bKe,yt({as:"label",get for(){return a.inputId()}},(()=>a.dataset()),t))}function eFe(e){return ht(MKe,yt({as:"span"},e))}function aFe(e){let a;const t=uKe({id:`radiogroup-${wt()}`,orientation:"vertical"},e),[n,i,r]=bt(t,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],kKe),[o,s]=xKe({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:e=>n.onChange?.(e)}),{formControlContext:l}=function(e){const a=uKe({id:`form-control-${wt()}`},e),[t,n]=La(),[i,r]=La(),[o,s]=La(),[l,u]=La();return{formControlContext:{name:()=>xze(a.name)??xze(a.id),dataset:za((()=>({"data-valid":"valid"===xze(a.validationState)?"":void 0,"data-invalid":"invalid"===xze(a.validationState)?"":void 0,"data-required":xze(a.required)?"":void 0,"data-disabled":xze(a.disabled)?"":void 0,"data-readonly":xze(a.readOnly)?"":void 0}))),validationState:()=>xze(a.validationState),isRequired:()=>xze(a.required),isDisabled:()=>xze(a.disabled),isReadOnly:()=>xze(a.readOnly),labelId:t,fieldId:i,descriptionId:o,errorMessageId:l,getAriaLabelledBy:(e,a,n)=>{const i=null!=n||null!=t();return[n,t(),i&&null!=a?e:void 0].filter(Boolean).join(" ")||void 0},getAriaDescribedBy:e=>[o(),l(),e].filter(Boolean).join(" ")||void 0,generateId:OOe((()=>xze(a.id))),registerLabel:fKe(n),registerField:fKe(r),registerDescription:fKe(s),registerErrorMessage:fKe(u)}}}(i);TKe((()=>a),(()=>s(n.defaultValue??"")));const u=()=>l.getAriaDescribedBy(n["aria-describedby"]),c=e=>e===o(),d={ariaDescribedBy:u,isSelectedValue:c,setSelectedValue:e=>{if(!l.isReadOnly()&&!l.isDisabled()&&(s(e),a))for(const t of a.querySelectorAll("[type='radio']")){t.checked=c(t.value)}}};return ht(SKe.Provider,{value:l,get children(){return ht(VIe.Provider,{value:d,get children(){return ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)},role:"radiogroup",get id(){return xze(i.id)},get"aria-invalid"(){return"invalid"===l.validationState()||void 0},get"aria-required"(){return l.isRequired()||void 0},get"aria-disabled"(){return l.isDisabled()||void 0},get"aria-readonly"(){return l.isReadOnly()||void 0},get"aria-orientation"(){return n.orientation},get"aria-labelledby"(){return l.getAriaLabelledBy(xze(i.id),r["aria-label"],n["aria-labelledby"])},get"aria-describedby"(){return u()}},(()=>l.dataset()),r))}})}})}var tFe=Object.assign(aFe,{Description:AKe,ErrorMessage:CKe,Item:qIe,ItemControl:$Ie,ItemDescription:ZIe,ItemIndicator:YIe,ItemInput:QIe,ItemLabel:XIe,Label:eFe}),nFe=class{collection;ref;collator;constructor(e,a,t){this.collection=e,this.ref=a,this.collator=t}getKeyBelow(e){let a=this.collection().getKeyAfter(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyAfter(a)}}getKeyAbove(e){let a=this.collection().getKeyBefore(e);for(;null!=a;){const e=this.collection().getItem(a);if(e&&"item"===e.type&&!e.disabled)return a;a=this.collection().getKeyBefore(a)}}getFirstKey(){let e=this.collection().getFirstKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;null!=e;){const a=this.collection().getItem(e);if(a&&"item"===a.type&&!a.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){return this.ref?.()?.querySelector(`[data-key="${e}"]`)??null}getKeyPageAbove(e){const a=this.ref?.();let t=this.getItem(e);if(!a||!t)return;const n=Math.max(0,t.offsetTop+t.offsetHeight-a.offsetHeight);let i=e;for(;i&&t&&t.offsetTop>n;)i=this.getKeyAbove(i),t=null!=i?this.getItem(i):null;return i}getKeyPageBelow(e){const a=this.ref?.();let t=this.getItem(e);if(!a||!t)return;const n=Math.min(a.scrollHeight,t.offsetTop-t.offsetHeight+a.offsetHeight);let i=e;for(;i&&t&&t.offsetTop<n;)i=this.getKeyBelow(i),t=null!=i?this.getItem(i):null;return i}getKeyForSearch(e,a){const t=this.collator?.();if(!t)return;let n=null!=a?this.getKeyBelow(a):this.getFirstKey();for(;null!=n;){const a=this.collection().getItem(n);if(a){const i=a.textValue.slice(0,e.length);if(a.textValue&&0===t.compare(i,e))return n}n=this.getKeyBelow(n)}}};function iFe(e,a,t){const n=function(e){const{locale:a}=qKe(),t=za((()=>a()+(e?Object.entries(e).sort(((e,a)=>e[0]<a[0]?-1:1)).join():"")));return za((()=>{const n=t();let i;return $Ke.has(n)&&(i=$Ke.get(n)),i||(i=new Intl.Collator(a(),e),$Ke.set(n,i)),i}))}({usage:"search",sensitivity:"base"});return aHe({selectionManager:()=>xze(e.selectionManager),keyboardDelegate:za((()=>{const t=xze(e.keyboardDelegate);return t||new nFe(e.collection,a,n)})),autoFocus:()=>xze(e.autoFocus),deferAutoFocus:()=>xze(e.deferAutoFocus),shouldFocusWrap:()=>xze(e.shouldFocusWrap),disallowEmptySelection:()=>xze(e.disallowEmptySelection),selectOnFocus:()=>xze(e.selectOnFocus),disallowTypeAhead:()=>xze(e.disallowTypeAhead),shouldUseVirtualFocus:()=>xze(e.shouldUseVirtualFocus),allowsTabNavigation:()=>xze(e.allowsTabNavigation),isVirtualized:()=>xze(e.isVirtualized),scrollToKey:a=>xze(e.scrollToKey)?.(a),orientation:()=>xze(e.orientation)},a)}var rFe="focusScope.autoFocusOnMount",oFe="focusScope.autoFocusOnUnmount",sFe={bubbles:!1,cancelable:!0},lFe={stack:[],active(){return this.stack[0]},add(e){e!==this.active()&&this.active()?.pause(),this.stack=DOe(this.stack,e),this.stack.unshift(e)},remove(e){this.stack=DOe(this.stack,e),this.active()?.resume()}};function uFe(e,a){const[t,n]=La(!1),i={pause(){n(!0)},resume(){n(!1)}};let r=null;const o=a=>e.onMountAutoFocus?.(a),s=a=>e.onUnmountAutoFocus?.(a),l=()=>IOe(a()),u=()=>{const e=l().createElement("span");return e.setAttribute("data-focus-trap",""),e.tabIndex=0,Object.assign(e.style,gKe),e},c=()=>{const e=a();return e?tKe(e,!0).filter((e=>!e.hasAttribute("data-focus-trap"))):[]},d=()=>{const e=c();return e.length>0?e[0]:null};Da((()=>{const e=a();if(!e)return;lFe.add(i);const t=HOe(e);if(!KOe(e,t)){const a=new CustomEvent(rFe,sFe);e.addEventListener(rFe,o),e.dispatchEvent(a),a.defaultPrevented||setTimeout((()=>{ZOe(d()),HOe(e)===t&&ZOe(e)}),0)}Fa((()=>{e.removeEventListener(rFe,o),setTimeout((()=>{const n=new CustomEvent(oFe,sFe);(()=>{const e=a();if(!e)return!1;const t=HOe(e);return!!t&&!KOe(e,t)&&iKe(t)})()&&n.preventDefault(),e.addEventListener(oFe,s),e.dispatchEvent(n),n.defaultPrevented||ZOe(t??l().body),e.removeEventListener(oFe,s),lFe.remove(i)}),0)}))})),Da((()=>{const n=a();if(!n||!xze(e.trapFocus)||t())return;const i=e=>{const a=e.target;a?.closest(`[${lHe}]`)||(KOe(n,a)?r=a:ZOe(r))},o=e=>{const a=e.relatedTarget??HOe(n);a?.closest(`[${lHe}]`)||KOe(n,a)||ZOe(r)};l().addEventListener("focusin",i),l().addEventListener("focusout",o),Fa((()=>{l().removeEventListener("focusin",i),l().removeEventListener("focusout",o)}))})),Da((()=>{const n=a();if(!n||!xze(e.trapFocus)||t())return;const i=u();n.insertAdjacentElement("afterbegin",i);const r=u();function o(e){const a=d(),t=(()=>{const e=c();return e.length>0?e[e.length-1]:null})();ZOe(e.relatedTarget===a?t:a)}n.insertAdjacentElement("beforeend",r),i.addEventListener("focusin",o),r.addEventListener("focusin",o);const s=new MutationObserver((e=>{for(const a of e)a.previousSibling===r&&(r.remove(),n.insertAdjacentElement("beforeend",r)),a.nextSibling===i&&(i.remove(),n.insertAdjacentElement("afterbegin",i))}));s.observe(n,{childList:!0,subtree:!1}),Fa((()=>{i.removeEventListener("focusin",o),r.removeEventListener("focusin",o),i.remove(),r.remove(),s.disconnect()}))}))}var cFe="data-live-announcer";function dFe(e){Da((()=>{xze(e.isDisabled)||Fa(function(e,a=document.body){const t=new Set(e),n=new Set,i=e=>{for(const n of e.querySelectorAll(`[${cFe}], [${lHe}]`))t.add(n);const a=e=>{if(t.has(e)||e.parentElement&&n.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(const a of t)if(e.contains(a))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a}),o=a(e);if(o===NodeFilter.FILTER_ACCEPT&&r(e),o!==NodeFilter.FILTER_REJECT){let e=i.nextNode();for(;null!=e;)r(e),e=i.nextNode()}},r=e=>{const a=mFe.get(e)??0;"true"===e.getAttribute("aria-hidden")&&0===a||(0===a&&e.setAttribute("aria-hidden","true"),n.add(e),mFe.set(e,a+1))};hFe.length&&hFe[hFe.length-1].disconnect();i(a);const o=new MutationObserver((e=>{for(const a of e)if("childList"===a.type&&0!==a.addedNodes.length&&![...t,...n].some((e=>e.contains(a.target)))){for(const e of a.removedNodes)e instanceof Element&&(t.delete(e),n.delete(e));for(const e of a.addedNodes)!(e instanceof HTMLElement||e instanceof SVGElement)||"true"!==e.dataset.liveAnnouncer&&"true"!==e.dataset.reactAriaTopLayer?e instanceof Element&&i(e):t.add(e)}}));o.observe(a,{childList:!0,subtree:!0});const s={observe(){o.observe(a,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return hFe.push(s),()=>{o.disconnect();for(const e of n){const a=mFe.get(e);if(null==a)return;1===a?(e.removeAttribute("aria-hidden"),mFe.delete(e)):mFe.set(e,a-1)}s===hFe[hFe.length-1]?(hFe.pop(),hFe.length&&hFe[hFe.length-1].observe()):hFe.splice(hFe.indexOf(s),1)}}(xze(e.targets),xze(e.root)))}))}var mFe=new WeakMap,hFe=[];var pFe=new Map,gFe=e=>{Da((()=>{const a=oHe(e.style)??{},t=oHe(e.properties)??[],n={};for(const r in a)n[r]=e.element.style[r];const i=pFe.get(e.key);i?i.activeCount++:pFe.set(e.key,{activeCount:1,originalStyles:n,properties:t.map((e=>e.key))}),Object.assign(e.element.style,e.style);for(const r of t)e.element.style.setProperty(r.key,r.value);Fa((()=>{const a=pFe.get(e.key);if(a)if(1===a.activeCount){pFe.delete(e.key);for(const[t,n]of Object.entries(a.originalStyles))e.element.style[t]=n;for(const t of a.properties)e.element.style.removeProperty(t);0===e.element.style.length&&e.element.removeAttribute("style"),e.cleanup?.()}else a.activeCount--}))}))},fFe=(e,a)=>{switch(a){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},vFe=(e,a)=>{const t=getComputedStyle(e),n="x"===a?t.overflowX:t.overflowY;return"auto"===n||"scroll"===n||"HTML"===e.tagName&&"visible"===n},[yFe,bFe]=La([]),kFe=e=>[e.deltaX,e.deltaY],SFe=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],wFe=(e,a,t,n)=>{const i=null!==n&&AFe(n,e),[r,o]=((e,a,t)=>{const n="x"===a&&"rtl"===window.getComputedStyle(e).direction?-1:1;let i=e,r=0,o=0,s=!1;do{const[e,l,u]=fFe(i,a),c=u-e-n*l;0===l&&0===c||!vFe(i,a)||(r+=c,o+=l),i===(t??document.documentElement)?s=!0:i=i._$host??i.parentElement}while(i&&!s);return[r,o]})(e,a,i?n:void 0);return!(t>0&&Math.abs(r)<=1)&&!(t<0&&Math.abs(o)<1)},AFe=(e,a)=>{if(e.contains(a))return!0;let t=a;for(;t;){if(t===e)return!0;t=t._$host??t.parentElement}return!1},CFe=e=>{const a=yt({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),t=wt();let n=[0,0],i=null,r=null;Da((()=>{oHe(a.enabled)&&(bFe((e=>[...e,t])),Fa((()=>{bFe((e=>e.filter((e=>e!==t))))})))})),Da((()=>{if(!oHe(a.enabled)||!oHe(a.hideScrollbar))return;const{body:e}=document,t=window.innerWidth-e.offsetWidth;if(oHe(a.preventScrollbarShift)){const n={overflow:"hidden"},i=[];t>0&&("padding"===oHe(a.preventScrollbarShiftMode)?n.paddingRight=`calc(${window.getComputedStyle(e).paddingRight} + ${t}px)`:n.marginRight=`calc(${window.getComputedStyle(e).marginRight} + ${t}px)`,i.push({key:"--scrollbar-width",value:`${t}px`}));const r=window.scrollY,o=window.scrollX;gFe({key:"prevent-scroll",element:e,style:n,properties:i,cleanup:()=>{oHe(a.restoreScrollPosition)&&t>0&&window.scrollTo(o,r)}})}else gFe({key:"prevent-scroll",element:e,style:{overflow:"hidden"}})})),Da((()=>{var e;(e=t,yFe().indexOf(e)===yFe().length-1&&oHe(a.enabled))&&(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Fa((()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)})))}));const o=e=>{n=SFe(e),i=null,r=null},s=e=>{const t=e.target,n=oHe(a.element),i=kFe(e),r=Math.abs(i[0])>Math.abs(i[1])?"x":"y",o=wFe(t,r,"x"===r?i[0]:i[1],n);let s;s=!n||!AFe(n,t)||!o,s&&e.cancelable&&e.preventDefault()},l=e=>{const t=oHe(a.element),o=e.target;let s;if(2===e.touches.length)s=!oHe(a.allowPinchZoom);else{if(null==i||null===r){const a=SFe(e).map(((e,a)=>n[a]-e)),t=Math.abs(a[0])>Math.abs(a[1])?"x":"y";i=t,r="x"===t?a[0]:a[1]}if("range"===o.type)s=!1;else{const e=wFe(o,i,r,t);s=!t||!AFe(t,o)||!e}}s&&e.cancelable&&e.preventDefault()}},MFe=CFe,TFe=Wa();function xFe(){return qa(TFe)}function EFe(){const e=xFe();if(void 0===e)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var NFe=Wa();function _Fe(){const e=qa(NFe);if(void 0===e)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var PFe=Wa();function jFe(){const e=qa(PFe);if(void 0===e)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function LFe(e){let a;const t=jFe(),n=EFe(),i=uKe({id:t.generateId(`item-${wt()}`)},e),[r,o]=bt(i,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[s,l]=La(),[u,c]=La(),[d,m]=La(),h=()=>n.listState().selectionManager(),p=()=>o.id,g=()=>{r.onSelect?.(),r.closeOnSelect&&setTimeout((()=>{n.close(!0)}))};zKe({getItem:()=>({ref:()=>a,type:"item",key:p(),textValue:r.textValue??d()?.textContent??a?.textContent??"",disabled:r.disabled??!1})});const f=tHe({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),v=e=>{WOe(e,r.onPointerMove),"mouse"===e.pointerType&&(r.disabled?n.onItemLeave(e):(n.onItemEnter(e),e.defaultPrevented||(ZOe(e.currentTarget),n.listState().selectionManager().setFocused(!0),n.listState().selectionManager().setFocusedKey(p()))))},y=e=>{WOe(e,r.onPointerLeave),"mouse"===e.pointerType&&n.onItemLeave(e)},b=e=>{WOe(e,r.onPointerUp),r.disabled||0!==e.button||g()},k=e=>{if(WOe(e,r.onKeyDown),!e.repeat&&!r.disabled)switch(e.key){case"Enter":case" ":g()}},S=za((()=>r.indeterminate?"mixed":null!=r.checked?r.checked:void 0)),w=za((()=>({"data-indeterminate":r.indeterminate?"":void 0,"data-checked":r.checked&&!r.indeterminate?"":void 0,"data-disabled":r.disabled?"":void 0,"data-highlighted":h().focusedKey()===p()?"":void 0}))),A={isChecked:()=>r.checked,dataset:w,setLabelRef:m,generateId:OOe((()=>o.id)),registerLabel:fKe(l),registerDescription:fKe(c)};return ht(NFe.Provider,{value:A,get children(){return ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>a=e),r.ref);"function"==typeof t&&t(e)},get tabIndex(){return f.tabIndex()},get"aria-checked"(){return S()},get"aria-disabled"(){return r.disabled},get"aria-labelledby"(){return s()},get"aria-describedby"(){return u()},get"data-key"(){return f.dataKey()},get onPointerDown(){return qOe([r.onPointerDown,f.onPointerDown])},get onPointerUp(){return qOe([b,f.onPointerUp])},get onClick(){return qOe([r.onClick,f.onClick])},get onKeyDown(){return qOe([k,f.onKeyDown])},get onMouseDown(){return qOe([r.onMouseDown,f.onMouseDown])},get onFocus(){return qOe([r.onFocus,f.onFocus])},onPointerMove:v,onPointerLeave:y},w,o))}})}function BFe(e){const a=uKe({closeOnSelect:!1},e),[t,n]=bt(a,["checked","defaultChecked","onChange","onSelect"]),i=function(e={}){const[a,t]=EKe({value:()=>xze(e.isSelected),defaultValue:()=>!!xze(e.defaultIsSelected),onChange:a=>e.onSelectedChange?.(a)});return{isSelected:a,setIsSelected:a=>{xze(e.isReadOnly)||xze(e.isDisabled)||t(a)},toggle:()=>{xze(e.isReadOnly)||xze(e.isDisabled)||t(!a())}}}({isSelected:()=>t.checked,defaultIsSelected:()=>t.defaultChecked,onSelectedChange:e=>t.onChange?.(e),isDisabled:()=>n.disabled});return ht(LFe,yt({role:"menuitemcheckbox",get checked(){return i.isSelected()},onSelect:()=>{t.onSelect?.(),i.toggle()}},n))}var RFe=Wa();function DFe(){return qa(RFe)}var zFe={next:(e,a)=>"ltr"===e?"horizontal"===a?"ArrowRight":"ArrowDown":"horizontal"===a?"ArrowLeft":"ArrowUp",previous:(e,a)=>zFe.next("ltr"===e?"rtl":"ltr",a)},OFe=e=>"horizontal"===e?"ArrowDown":"ArrowRight",KFe=e=>"horizontal"===e?"ArrowUp":"ArrowLeft";function HFe(e){const a=jFe(),t=EFe(),n=DFe(),{direction:i}=qKe(),r=uKe({id:a.generateId("trigger")},e),[o,s]=bt(r,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>a.value();void 0!==n&&(l=()=>a.value()??o.id,void 0===n.lastValue()&&n.setLastValue(l));const u=vKe((()=>t.triggerRef()),(()=>"button")),c=za((()=>"a"===u()&&null!=t.triggerRef()?.getAttribute("href")));Da(Ha((()=>n?.value()),(e=>{c()&&e===l()&&t.triggerRef()?.focus()})));const d=()=>{void 0!==n?t.isOpen()?n.value()===l()&&n.closeMenu():(n.autoFocusMenu()||n.setAutoFocusMenu(!0),t.open(!1)):t.toggle(!0)};return Da((()=>Fa(t.registerTriggerId(o.id)))),ht(vHe,yt({ref(e){const a=kOe(t.setTriggerRef,o.ref);"function"==typeof a&&a(e)},get"data-kb-menu-value-trigger"(){return a.value()},get id(){return o.id},get disabled(){return o.disabled},"aria-haspopup":"true",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return za((()=>!!t.isOpen()))()?t.contentId():void 0},get"data-highlighted"(){return void 0!==l()&&n?.value()===l()||void 0},get tabIndex(){return void 0!==n?n.value()===l()||n.lastValue()===l()?0:-1:void 0},onPointerDown:e=>{WOe(e,o.onPointerDown),e.currentTarget.dataset.pointerType=e.pointerType,o.disabled||"touch"===e.pointerType||0!==e.button||d()},onMouseOver:e=>{WOe(e,o.onMouseOver),"touch"!==t.triggerRef()?.dataset.pointerType&&(o.disabled||void 0===n||void 0===n.value()||n.setValue(l))},onClick:e=>{WOe(e,o.onClick),o.disabled||"touch"===e.currentTarget.dataset.pointerType&&d()},onKeyDown:e=>{if(WOe(e,o.onKeyDown),!o.disabled){if(c())switch(e.key){case"Enter":case" ":return}switch(e.key){case"Enter":case" ":case OFe(a.orientation()):e.stopPropagation(),e.preventDefault(),function(e){if(document.contains(e)){const a=document.scrollingElement||document.documentElement;if("hidden"===window.getComputedStyle(a).overflow){let t=oKe(e);for(;e&&t&&e!==a&&t!==a;)hKe(t,e),t=oKe(e=t)}else{const{left:a,top:t}=e.getBoundingClientRect();e?.scrollIntoView?.({block:"nearest"});const{left:n,top:i}=e.getBoundingClientRect();(Math.abs(a-n)>1||Math.abs(t-i)>1)&&e.scrollIntoView?.({block:"nearest"})}}}(e.currentTarget),t.open("first"),n?.setAutoFocusMenu(!0),n?.setValue(l);break;case KFe(a.orientation()):e.stopPropagation(),e.preventDefault(),t.open("last");break;case zFe.next(i(),a.orientation()):if(void 0===n)break;e.stopPropagation(),e.preventDefault(),n.nextMenu();break;case zFe.previous(i(),a.orientation()):if(void 0===n)break;e.stopPropagation(),e.preventDefault(),n.previousMenu()}}},onFocus:e=>{WOe(e,o.onFocus),void 0!==n&&"touch"!==e.currentTarget.dataset.pointerType&&n.setValue(l)},role:void 0!==n?"menuitem":void 0},(()=>t.dataset()),s))}var IFe=Wa();function FFe(){return qa(IFe)}function GFe(e){let a;const t=jFe(),n=EFe(),i=DFe(),r=FFe(),{direction:o}=qKe(),s=uKe({id:t.generateId(`content-${wt()}`)},e),[l,u]=bt(s,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let c=0;const d=()=>null==n.parentMenuContext()&&void 0===i&&t.isModal(),m=iFe({selectionManager:n.listState().selectionManager,collection:n.listState().collection,autoFocus:n.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!n.listState().selectionManager().isFocused(),orientation:()=>"horizontal"===t.orientation()?"vertical":"horizontal"},(()=>a));uFe({trapFocus:()=>d()&&n.isOpen(),onMountAutoFocus:e=>{void 0===i&&l.onOpenAutoFocus?.(e)},onUnmountAutoFocus:l.onCloseAutoFocus},(()=>a));const h=e=>{l.onEscapeKeyDown?.(e),i?.setAutoFocusMenu(!1),n.close(!0)},p=e=>{l.onFocusOutside?.(e),t.isModal()&&e.preventDefault()};Da((()=>Fa(n.registerContentId(l.id))));const g={ref:kOe((e=>{n.setContentRef(e),a=e}),l.ref),role:"menu",get id(){return l.id},get tabIndex(){return m.tabIndex()},get"aria-labelledby"(){return n.triggerId()},onKeyDown:qOe([l.onKeyDown,m.onKeyDown,e=>{if(KOe(e.currentTarget,e.target)&&("Tab"===e.key&&n.isOpen()&&e.preventDefault(),void 0!==i&&"true"!==e.currentTarget.getAttribute("aria-haspopup")))switch(e.key){case zFe.next(o(),t.orientation()):e.stopPropagation(),e.preventDefault(),n.close(!0),i.setAutoFocusMenu(!0),i.nextMenu();break;case zFe.previous(o(),t.orientation()):if(e.currentTarget.hasAttribute("data-closed"))break;e.stopPropagation(),e.preventDefault(),n.close(!0),i.setAutoFocusMenu(!0),i.previousMenu()}}]),onMouseDown:qOe([l.onMouseDown,m.onMouseDown]),onFocusIn:qOe([l.onFocusIn,m.onFocusIn]),onFocusOut:qOe([l.onFocusOut,m.onFocusOut]),onPointerEnter:e=>{WOe(e,l.onPointerEnter),n.isOpen()&&(n.parentMenuContext()?.listState().selectionManager().setFocused(!1),n.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},onPointerMove:e=>{if(WOe(e,l.onPointerMove),"mouse"!==e.pointerType)return;const a=c!==e.clientX;KOe(e.currentTarget,e.target)&&a&&(n.setPointerDir(e.clientX>c?"right":"left"),c=e.clientX)},get"data-orientation"(){return t.orientation()}};return ht(Tt,{get when(){return n.contentPresent()},get children(){return ht(Tt,{get when(){return void 0===r||null!=n.parentMenuContext()},get fallback(){return ht(bKe,yt({as:"div"},(()=>n.dataset()),g,u))},get children(){return ht(zIe.Positioner,{get children(){return ht(IIe,yt({get disableOutsidePointerEvents(){return za((()=>!!d()))()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return ROe({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:h,onFocusOutside:p,get onDismiss(){return n.close}},(()=>n.dataset()),g,u))}})}})}})}function VFe(e){let a;const t=jFe(),n=EFe(),[i,r]=bt(e,["ref"]);return MFe({element:()=>a??null,enabled:()=>n.contentPresent()&&t.preventScroll()}),ht(GFe,yt({ref(e){const t=kOe((e=>{a=e}),i.ref);"function"==typeof t&&t(e)}},r))}var JFe=Wa();function UFe(e){const a=uKe({id:jFe().generateId(`group-${wt()}`)},e),[t,n]=La(),i={generateId:OOe((()=>a.id)),registerLabelId:fKe(n)};return ht(JFe.Provider,{value:i,get children(){return ht(bKe,yt({as:"div",role:"group",get"aria-labelledby"(){return t()}},a))}})}function WFe(e){const a=function(){const e=qa(JFe);if(void 0===e)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}(),t=uKe({id:a.generateId("label")},e),[n,i]=bt(t,["id"]);return Da((()=>Fa(a.registerLabelId(n.id)))),ht(bKe,yt({as:"span",get id(){return n.id},"aria-hidden":"true"},i))}function qFe(e){const a=EFe();return ht(bKe,yt({as:"span","aria-hidden":"true"},(()=>a.dataset()),uKe({children:"▼"},e)))}function $Fe(e){return ht(LFe,yt({role:"menuitem",closeOnSelect:!0},e))}function ZFe(e){const a=_Fe(),t=uKe({id:a.generateId("description")},e),[n,i]=bt(t,["id"]);return Da((()=>Fa(a.registerDescription(n.id)))),ht(bKe,yt({as:"div",get id(){return n.id}},(()=>a.dataset()),i))}function YFe(e){const a=_Fe(),t=uKe({id:a.generateId("indicator")},e),[n,i]=bt(t,["forceMount"]);return ht(Tt,{get when(){return n.forceMount||a.isChecked()},get children(){return ht(bKe,yt({as:"div"},(()=>a.dataset()),i))}})}function QFe(e){const a=_Fe(),t=uKe({id:a.generateId("label")},e),[n,i]=bt(t,["ref","id"]);return Da((()=>Fa(a.registerLabel(n.id)))),ht(bKe,yt({as:"div",ref(e){const t=kOe(a.setLabelRef,n.ref);"function"==typeof t&&t(e)},get id(){return n.id}},(()=>a.dataset()),i))}function XFe(e){const a=EFe();return ht(Tt,{get when(){return a.contentPresent()},get children(){return ht(tn,e)}})}var eGe=Wa();function aGe(e){const a=uKe({id:jFe().generateId(`radiogroup-${wt()}`)},e),[t,n]=bt(a,["value","defaultValue","onChange","disabled"]),[i,r]=xKe({value:()=>t.value,defaultValue:()=>t.defaultValue,onChange:e=>t.onChange?.(e)});return ht(eGe.Provider,{value:{isDisabled:()=>t.disabled,isSelectedValue:e=>e===i(),setSelectedValue:r},get children(){return ht(UFe,n)}})}function tGe(e){const a=function(){const e=qa(eGe);if(void 0===e)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}(),t=uKe({closeOnSelect:!1},e),[n,i]=bt(t,["value","onSelect"]);return ht(LFe,yt({role:"menuitemradio",get checked(){return a.isSelectedValue(n.value)},onSelect:()=>{n.onSelect?.(),a.setSelectedValue(n.value)}},i))}function nGe(e,a,t){const n=e.split("-")[0],i=t.getBoundingClientRect(),r=[],o=a.clientX,s=a.clientY;switch(n){case"top":r.push([o,s+5]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]);break;case"right":r.push([o-5,s]),r.push([i.left,i.top]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]);break;case"bottom":r.push([o,s-5]),r.push([i.right,i.top]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]);break;case"left":r.push([o+5,s]),r.push([i.right,i.bottom]),r.push([i.left,i.bottom]),r.push([i.left,i.top]),r.push([i.right,i.top])}return r}function iGe(e){const a=jFe(),t=jKe(),n=xFe(),i=DFe(),r=FFe(),o=uKe({placement:"horizontal"===a.orientation()?"bottom-start":"right-start"},e),[s,l]=bt(o,["open","defaultOpen","onOpenChange"]);let u=0,c=null,d="right";const[m,h]=La(),[p,g]=La(),[f,v]=La(),[y,b]=La(),[k,S]=La(!0),[w,A]=La(l.placement),[C,M]=La([]),[T,x]=La([]),{DomCollectionProvider:E}=DKe({items:T,onItemsChange:x}),N=FIe({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:e=>s.onOpenChange?.(e)}),{present:_}=sHe({show:()=>a.forceMount()||N.isOpen(),element:()=>y()??null}),P=function(e){const a=eHe(e),t=KKe({dataSource:()=>xze(e.dataSource),getKey:()=>xze(e.getKey),getTextValue:()=>xze(e.getTextValue),getDisabled:()=>xze(e.getDisabled),getSectionChildren:()=>xze(e.getSectionChildren),factory:a=>new iHe(e.filter?e.filter(a):a)},[()=>e.filter]),n=new nHe(t,a);return Ba((()=>{const e=a.focusedKey();null==e||t().getItem(e)||a.setFocusedKey(void 0)})),{collection:t,selectionManager:()=>n}}({selectionMode:"none",dataSource:T}),j=e=>{S(e),N.open()},L=(e=!1)=>{N.close(),e&&n&&n.close(!0)},B=()=>{const e=y();e&&(ZOe(e),P.selectionManager().setFocused(!0),P.selectionManager().setFocusedKey(void 0))},R=()=>{null!=r?setTimeout((()=>B())):B()},D=e=>{return d===c?.side&&(a=e,t=c?.area,!!t&&function(e,a){const[t,n]=e;let i=!1;for(let r=a.length,o=0,s=r-1;o<r;s=o++){const[e,l]=a[o],[u,c]=a[s],[,d]=a[0===s?r-1:s-1]||[0,0],m=(l-c)*(t-e)-(e-u)*(n-l);if(c<l){if(n>=c&&n<l){if(0===m)return!0;m>0&&(n===c?n>d&&(i=!i):i=!i)}}else if(l<c){if(n>l&&n<=c){if(0===m)return!0;m<0&&(n===c?n<d&&(i=!i):i=!i)}}else if(n==l&&(t>=u&&t<=e||t>=e&&t<=u))return!0}return i}([a.clientX,a.clientY],t));var a,t};dFe({isDisabled:()=>!(null==n&&N.isOpen()&&a.isModal()),targets:()=>[y(),...C()].filter(Boolean)}),Da((()=>{const e=y();if(!e||!n)return;const a=n.registerNestedMenu(e);Fa((()=>{a()}))})),Da((()=>{void 0===n&&i?.registerMenu(a.value(),[y(),...C()])})),Da((()=>{void 0===n&&void 0!==i&&(i.value()===a.value()?(f()?.focus(),i.autoFocusMenu()&&j(!0)):L())})),Da((()=>{void 0===n&&void 0!==i&&N.isOpen()&&i.setValue(a.value())})),Fa((()=>{void 0===n&&i?.unregisterMenu(a.value())}));const z={dataset:za((()=>({"data-expanded":N.isOpen()?"":void 0,"data-closed":N.isOpen()?void 0:""}))),isOpen:N.isOpen,contentPresent:_,nestedMenus:C,currentPlacement:w,pointerGraceTimeoutId:()=>u,autoFocus:k,listState:()=>P,parentMenuContext:()=>n,triggerRef:f,contentRef:y,triggerId:m,contentId:p,setTriggerRef:v,setContentRef:b,open:j,close:L,toggle:e=>{S(e),N.toggle()},focusContent:R,onItemEnter:e=>{D(e)&&e.preventDefault()},onItemLeave:e=>{D(e)||R()},onTriggerLeave:e=>{D(e)&&e.preventDefault()},setPointerDir:e=>d=e,setPointerGraceTimeoutId:e=>u=e,setPointerGraceIntent:e=>c=e,registerNestedMenu:e=>{M((a=>[...a,e]));const a=n?.registerNestedMenu(e);return()=>{M((a=>DOe(a,e))),a?.()}},registerItemToParentDomCollection:t?.registerItem,registerTriggerId:fKe(h),registerContentId:fKe(g)};return ht(E,{get children(){return ht(TFe.Provider,{value:z,get children(){return ht(Tt,{when:void 0===r,get fallback(){return l.children},get children(){return ht(zIe,yt({anchorRef:f,contentRef:y,onCurrentPlacementChange:A},l))}})}})}})}function rGe(e){const{direction:a}=qKe();return ht(iGe,yt({get placement(){return"rtl"===a()?"left-start":"right-start"},flip:!0},e))}var oGe=(e,a)=>"ltr"===e?["horizontal"===a?"ArrowLeft":"ArrowUp"]:["horizontal"===a?"ArrowRight":"ArrowDown"];function sGe(e){const a=EFe(),t=jFe(),[n,i]=bt(e,["onFocusOutside","onKeyDown"]),{direction:r}=qKe();return ht(GFe,yt({onOpenAutoFocus:e=>{e.preventDefault()},onCloseAutoFocus:e=>{e.preventDefault()},onFocusOutside:e=>{n.onFocusOutside?.(e);const t=e.target;KOe(a.triggerRef(),t)||a.close()},onKeyDown:e=>{WOe(e,n.onKeyDown);const i=KOe(e.currentTarget,e.target),o=oGe(r(),t.orientation()).includes(e.key),s=null!=a.parentMenuContext();i&&o&&s&&(a.close(),ZOe(a.triggerRef()))}},i))}var lGe=["Enter"," "],uGe=(e,a)=>"ltr"===e?[...lGe,"horizontal"===a?"ArrowRight":"ArrowDown"]:[...lGe,"horizontal"===a?"ArrowLeft":"ArrowUp"];function cGe(e){let a;const t=jFe(),n=EFe(),i=uKe({id:t.generateId(`sub-trigger-${wt()}`)},e),[r,o]=bt(i,["ref","id","textValue","disabled","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);let s=null;const l=()=>{s&&window.clearTimeout(s),s=null},{direction:u}=qKe(),c=()=>r.id,d=()=>{const e=n.parentMenuContext();if(null==e)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return e.listState().selectionManager()},m=tHe({key:c,selectionManager:d,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),h=e=>{WOe(e,r.onClick),n.isOpen()||r.disabled||n.open(!0)},p=e=>{WOe(e,r.onKeyDown),e.repeat||r.disabled||uGe(u(),t.orientation()).includes(e.key)&&(e.stopPropagation(),e.preventDefault(),d().setFocused(!1),d().setFocusedKey(void 0),n.isOpen()||n.open("first"),n.focusContent(),n.listState().selectionManager().setFocused(!0),n.listState().selectionManager().setFocusedKey(n.listState().collection().getFirstKey()))};return Da((()=>{if(null==n.registerItemToParentDomCollection)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");Fa(n.registerItemToParentDomCollection({ref:()=>a,type:"item",key:c(),textValue:r.textValue??a?.textContent??"",disabled:r.disabled??!1}))})),Da(Ha((()=>n.parentMenuContext()?.pointerGraceTimeoutId()),(e=>{Fa((()=>{window.clearTimeout(e),n.parentMenuContext()?.setPointerGraceIntent(null)}))}))),Da((()=>Fa(n.registerTriggerId(r.id)))),Fa((()=>{l()})),ht(bKe,yt({as:"div",ref(e){const t=kOe((e=>{n.setTriggerRef(e),a=e}),r.ref);"function"==typeof t&&t(e)},get id(){return r.id},role:"menuitem",get tabIndex(){return m.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return za((()=>!!n.isOpen()))()?n.contentId():void 0},get"aria-disabled"(){return r.disabled},get"data-key"(){return m.dataKey()},get"data-highlighted"(){return d().focusedKey()===c()?"":void 0},get"data-disabled"(){return r.disabled?"":void 0},get onPointerDown(){return qOe([r.onPointerDown,m.onPointerDown])},get onPointerUp(){return qOe([r.onPointerUp,m.onPointerUp])},get onClick(){return qOe([h,m.onClick])},get onKeyDown(){return qOe([p,m.onKeyDown])},get onMouseDown(){return qOe([r.onMouseDown,m.onMouseDown])},get onFocus(){return qOe([r.onFocus,m.onFocus])},onPointerMove:e=>{if(WOe(e,r.onPointerMove),"mouse"!==e.pointerType)return;const a=n.parentMenuContext();a?.onItemEnter(e),e.defaultPrevented||(r.disabled?a?.onItemLeave(e):(n.isOpen()||s||(n.parentMenuContext()?.setPointerGraceIntent(null),s=window.setTimeout((()=>{n.open(!1),l()}),100)),a?.onItemEnter(e),e.defaultPrevented||(n.listState().selectionManager().isFocused()&&(n.listState().selectionManager().setFocused(!1),n.listState().selectionManager().setFocusedKey(void 0)),ZOe(e.currentTarget),a?.listState().selectionManager().setFocused(!0),a?.listState().selectionManager().setFocusedKey(c()))))},onPointerLeave:e=>{if(WOe(e,r.onPointerLeave),"mouse"!==e.pointerType)return;l();const a=n.parentMenuContext(),t=n.contentRef();if(t){a?.setPointerGraceIntent({area:nGe(n.currentPlacement(),e,t),side:n.currentPlacement().split("-")[0]}),window.clearTimeout(a?.pointerGraceTimeoutId());const i=window.setTimeout((()=>{a?.setPointerGraceIntent(null)}),300);a?.setPointerGraceTimeoutId(i)}else{if(a?.onTriggerLeave(e),e.defaultPrevented)return;a?.setPointerGraceIntent(null)}a?.onItemLeave(e)}},(()=>n.dataset()),o))}function dGe(e){const a=DFe(),t=uKe({id:`menu-${wt()}`,modal:!0},e),[n,i]=bt(t,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),r=FIe({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:e=>n.onOpenChange?.(e)}),o={isModal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??o.isModal(),forceMount:()=>n.forceMount??!1,generateId:OOe((()=>n.id)),value:()=>n.value,orientation:()=>n.orientation??a?.orientation()??"horizontal"};return ht(PFe.Provider,{value:o,get children(){return ht(iGe,yt({get open(){return r.isOpen()},get onOpenChange(){return r.setIsOpen}},i))}})}function mGe(e){let a;const t=uKe({orientation:"horizontal"},e),[n,i]=bt(t,["ref","orientation"]),r=vKe((()=>a),(()=>"hr"));return ht(bKe,yt({as:"hr",ref(e){const t=kOe((e=>a=e),n.ref);"function"==typeof t&&t(e)},get role(){return"hr"!==r()?"separator":void 0},get"aria-orientation"(){return"vertical"===n.orientation?"vertical":void 0},get"data-orientation"(){return n.orientation}},i))}_Ke({},{Root:()=>mGe,Separator:()=>hGe});var hGe=mGe,pGe={};function gGe(e){const a=jFe(),t=EFe(),[n,i]=bt(e,["onCloseAutoFocus","onInteractOutside"]);let r=!1;return ht(VFe,yt({onCloseAutoFocus:e=>{n.onCloseAutoFocus?.(e),r||ZOe(t.triggerRef()),r=!1,e.preventDefault()},onInteractOutside:e=>{n.onInteractOutside?.(e),a.isModal()&&!e.detail.isContextMenu||(r=!0)}},i))}function fGe(e){return ht(dGe,uKe({id:`dropdownmenu-${wt()}`},e))}_Ke(pGe,{Arrow:()=>LIe,CheckboxItem:()=>BFe,Content:()=>gGe,DropdownMenu:()=>vGe,Group:()=>UFe,GroupLabel:()=>WFe,Icon:()=>qFe,Item:()=>$Fe,ItemDescription:()=>ZFe,ItemIndicator:()=>YFe,ItemLabel:()=>QFe,Portal:()=>XFe,RadioGroup:()=>aGe,RadioItem:()=>tGe,Root:()=>fGe,Separator:()=>mGe,Sub:()=>rGe,SubContent:()=>sGe,SubTrigger:()=>cGe,Trigger:()=>HFe});var vGe=Object.assign(fGe,{Arrow:LIe,CheckboxItem:BFe,Content:gGe,Group:UFe,GroupLabel:WFe,Icon:qFe,Item:$Fe,ItemDescription:ZFe,ItemIndicator:YFe,ItemLabel:QFe,Portal:XFe,RadioGroup:aGe,RadioItem:tGe,Separator:mGe,Sub:rGe,SubContent:sGe,SubTrigger:cGe,Trigger:HFe}),yGe={colors:{inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000000",white:"#ffffff",neutral:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},darkGray:{50:"#525c7a",100:"#49536e",200:"#414962",300:"#394056",400:"#313749",500:"#292e3d",600:"#212530",700:"#191c24",800:"#111318",900:"#0b0d10"},gray:{50:"#f9fafb",100:"#f2f4f7",200:"#eaecf0",300:"#d0d5dd",400:"#98a2b3",500:"#667085",600:"#475467",700:"#344054",800:"#1d2939",900:"#101828"},blue:{25:"#F5FAFF",50:"#EFF8FF",100:"#D1E9FF",200:"#B2DDFF",300:"#84CAFF",400:"#53B1FD",500:"#2E90FA",600:"#1570EF",700:"#175CD3",800:"#1849A9",900:"#194185"},green:{25:"#F6FEF9",50:"#ECFDF3",100:"#D1FADF",200:"#A6F4C5",300:"#6CE9A6",400:"#32D583",500:"#12B76A",600:"#039855",700:"#027A48",800:"#05603A",900:"#054F31"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},yellow:{25:"#FFFCF5",50:"#FFFAEB",100:"#FEF0C7",200:"#FEDF89",300:"#FEC84B",400:"#FDB022",500:"#F79009",600:"#DC6803",700:"#B54708",800:"#93370D",900:"#7A2E0E"},purple:{25:"#FAFAFF",50:"#F4F3FF",100:"#EBE9FE",200:"#D9D6FE",300:"#BDB4FE",400:"#9B8AFB",500:"#7A5AF8",600:"#6938EF",700:"#5925DC",800:"#4A1FB8",900:"#3E1C96"},teal:{25:"#F6FEFC",50:"#F0FDF9",100:"#CCFBEF",200:"#99F6E0",300:"#5FE9D0",400:"#2ED3B7",500:"#15B79E",600:"#0E9384",700:"#107569",800:"#125D56",900:"#134E48"},pink:{25:"#fdf2f8",50:"#fce7f3",100:"#fbcfe8",200:"#f9a8d4",300:"#f472b6",400:"#ec4899",500:"#db2777",600:"#be185d",700:"#9d174d",800:"#831843",900:"#500724"},cyan:{25:"#ecfeff",50:"#cffafe",100:"#a5f3fc",200:"#67e8f9",300:"#22d3ee",400:"#06b6d4",500:"#0891b2",600:"#0e7490",700:"#155e75",800:"#164e63",900:"#083344"}},alpha:{90:"e5",80:"cc"},font:{size:{xs:"calc(var(--tsqd-font-size) * 0.75)",sm:"calc(var(--tsqd-font-size) * 0.875)",md:"var(--tsqd-font-size)"},lineHeight:{xs:"calc(var(--tsqd-font-size) * 1)",sm:"calc(var(--tsqd-font-size) * 1.25)",md:"calc(var(--tsqd-font-size) * 1.5)"},weight:{medium:"500",semibold:"600",bold:"700"}},border:{radius:{xs:"calc(var(--tsqd-font-size) * 0.125)",sm:"calc(var(--tsqd-font-size) * 0.25)",full:"9999px"}},size:{.25:"calc(var(--tsqd-font-size) * 0.0625)",.5:"calc(var(--tsqd-font-size) * 0.125)",1:"calc(var(--tsqd-font-size) * 0.25)",1.5:"calc(var(--tsqd-font-size) * 0.375)",2:"calc(var(--tsqd-font-size) * 0.5)",2.5:"calc(var(--tsqd-font-size) * 0.625)",3:"calc(var(--tsqd-font-size) * 0.75)",3.5:"calc(var(--tsqd-font-size) * 0.875)",4:"calc(var(--tsqd-font-size) * 1)",4.5:"calc(var(--tsqd-font-size) * 1.125)",5:"calc(var(--tsqd-font-size) * 1.25)",6:"calc(var(--tsqd-font-size) * 1.5)",6.5:"calc(var(--tsqd-font-size) * 1.625)",14:"calc(var(--tsqd-font-size) * 3.5)"},shadow:{xs:(e="rgb(0 0 0 / 0.1)")=>"0 1px 2px 0 rgb(0 0 0 / 0.05)",sm:(e="rgb(0 0 0 / 0.1)")=>`0 1px 3px 0 ${e}, 0 1px 2px -1px ${e}`,md:(e="rgb(0 0 0 / 0.1)")=>`0 4px 6px -1px ${e}, 0 2px 4px -2px ${e}`,lg:(e="rgb(0 0 0 / 0.1)")=>`0 10px 15px -3px ${e}, 0 4px 6px -4px ${e}`,xl:(e="rgb(0 0 0 / 0.1)")=>`0 20px 25px -5px ${e}, 0 8px 10px -6px ${e}`,"2xl":(e="rgb(0 0 0 / 0.25)")=>`0 25px 50px -12px ${e}`,inner:(e="rgb(0 0 0 / 0.05)")=>`inset 0 2px 4px 0 ${e}`,none:()=>"none"}},bGe=Ot('<svg width=14 height=14 viewBox="0 0 14 14"fill=none xmlns=http://www.w3.org/2000/svg><path d="M13 13L9.00007 9M10.3333 5.66667C10.3333 8.244 8.244 10.3333 5.66667 10.3333C3.08934 10.3333 1 8.244 1 5.66667C1 3.08934 3.08934 1 5.66667 1C8.244 1 10.3333 3.08934 10.3333 5.66667Z"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),kGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 3H15M3 6H21M19 6L18.2987 16.5193C18.1935 18.0975 18.1409 18.8867 17.8 19.485C17.4999 20.0118 17.0472 20.4353 16.5017 20.6997C15.882 21 15.0911 21 13.5093 21H10.4907C8.90891 21 8.11803 21 7.49834 20.6997C6.95276 20.4353 6.50009 20.0118 6.19998 19.485C5.85911 18.8867 5.8065 18.0975 5.70129 16.5193L5 6M10 10.5V15.5M14 10.5V15.5"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),SGe=Ot('<svg width=10 height=6 viewBox="0 0 10 6"fill=none xmlns=http://www.w3.org/2000/svg><path d="M1 1L5 5L9 1"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),wGe=Ot('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 13.3333V2.66667M8 2.66667L4 6.66667M8 2.66667L12 6.66667"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),AGe=Ot('<svg width=12 height=12 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"stroke=currentColor stroke-width=1.66667 stroke-linecap=round stroke-linejoin=round>'),CGe=Ot('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2v2m0 16v2M4 12H2m4.314-5.686L4.9 4.9m12.786 1.414L19.1 4.9M6.314 17.69 4.9 19.104m12.786-1.414 1.414 1.414M22 12h-2m-3 0a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),MGe=Ot('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M22 15.844a10.424 10.424 0 0 1-4.306.925c-5.779 0-10.463-4.684-10.463-10.462 0-1.536.33-2.994.925-4.307A10.464 10.464 0 0 0 2 11.538C2 17.316 6.684 22 12.462 22c4.243 0 7.896-2.526 9.538-6.156Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),TGe=Ot('<svg viewBox="0 0 24 24"height=12 width=12 fill=none xmlns=http://www.w3.org/2000/svg><path d="M8 21h8m-4-4v4m-5.2-4h10.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C22 14.72 22 13.88 22 12.2V7.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C19.72 3 18.88 3 17.2 3H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 5.28 2 6.12 2 7.8v4.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 17 5.12 17 6.8 17Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),xGe=Ot('<svg stroke=currentColor fill=currentColor stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M0 0h24v24H0z"></path><path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3a4.237 4.237 0 00-6 0zm-4-4l2 2a7.074 7.074 0 0110 0l2-2C15.14 9.14 8.87 9.14 5 13z">'),EGe=Ot('<svg stroke-width=0 viewBox="0 0 24 24"height=1em width=1em xmlns=http://www.w3.org/2000/svg><path fill=none d="M24 .01c0-.01 0-.01 0 0L0 0v24h24V.01zM0 0h24v24H0V0zm0 0h24v24H0V0z"></path><path d="M22.99 9C19.15 5.16 13.8 3.76 8.84 4.78l2.52 2.52c3.47-.17 6.99 1.05 9.63 3.7l2-2zm-4 4a9.793 9.793 0 00-4.49-2.56l3.53 3.53.96-.97zM2 3.05L5.07 6.1C3.6 6.82 2.22 7.78 1 9l1.99 2c1.24-1.24 2.67-2.16 4.2-2.77l2.24 2.24A9.684 9.684 0 005 13v.01L6.99 15a7.042 7.042 0 014.92-2.06L18.98 20l1.27-1.26L3.29 1.79 2 3.05zM9 17l3 3 3-3a4.237 4.237 0 00-6 0z">'),NGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.3951 19.3711L9.97955 20.6856C10.1533 21.0768 10.4368 21.4093 10.7958 21.6426C11.1547 21.8759 11.5737 22.0001 12.0018 22C12.4299 22.0001 12.8488 21.8759 13.2078 21.6426C13.5667 21.4093 13.8503 21.0768 14.024 20.6856L14.6084 19.3711C14.8165 18.9047 15.1664 18.5159 15.6084 18.26C16.0532 18.0034 16.5678 17.8941 17.0784 17.9478L18.5084 18.1C18.9341 18.145 19.3637 18.0656 19.7451 17.8713C20.1265 17.6771 20.4434 17.3763 20.6573 17.0056C20.8715 16.635 20.9735 16.2103 20.9511 15.7829C20.9286 15.3555 20.7825 14.9438 20.5307 14.5978L19.684 13.4344C19.3825 13.0171 19.2214 12.5148 19.224 12C19.2239 11.4866 19.3865 10.9864 19.6884 10.5711L20.5351 9.40778C20.787 9.06175 20.933 8.65007 20.9555 8.22267C20.978 7.79528 20.8759 7.37054 20.6618 7C20.4479 6.62923 20.131 6.32849 19.7496 6.13423C19.3681 5.93997 18.9386 5.86053 18.5129 5.90556L17.0829 6.05778C16.5722 6.11141 16.0577 6.00212 15.6129 5.74556C15.17 5.48825 14.82 5.09736 14.6129 4.62889L14.024 3.31444C13.8503 2.92317 13.5667 2.59072 13.2078 2.3574C12.8488 2.12408 12.4299 1.99993 12.0018 2C11.5737 1.99993 11.1547 2.12408 10.7958 2.3574C10.4368 2.59072 10.1533 2.92317 9.97955 3.31444L9.3951 4.62889C9.18803 5.09736 8.83798 5.48825 8.3951 5.74556C7.95032 6.00212 7.43577 6.11141 6.9251 6.05778L5.49066 5.90556C5.06499 5.86053 4.6354 5.93997 4.25397 6.13423C3.87255 6.32849 3.55567 6.62923 3.34177 7C3.12759 7.37054 3.02555 7.79528 3.04804 8.22267C3.07052 8.65007 3.21656 9.06175 3.46844 9.40778L4.3151 10.5711C4.61704 10.9864 4.77964 11.4866 4.77955 12C4.77964 12.5134 4.61704 13.0137 4.3151 13.4289L3.46844 14.5922C3.21656 14.9382 3.07052 15.3499 3.04804 15.7773C3.02555 16.2047 3.12759 16.6295 3.34177 17C3.55589 17.3706 3.8728 17.6712 4.25417 17.8654C4.63554 18.0596 5.06502 18.1392 5.49066 18.0944L6.92066 17.9422C7.43133 17.8886 7.94587 17.9979 8.39066 18.2544C8.83519 18.511 9.18687 18.902 9.3951 19.3711Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><path d="M12 15C13.6568 15 15 13.6569 15 12C15 10.3431 13.6568 9 12 9C10.3431 9 8.99998 10.3431 8.99998 12C8.99998 13.6569 10.3431 15 12 15Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),_Ge=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M16 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V8M11.5 12.5L17 7M17 7H12M17 7V12M6.2 21H8.8C9.9201 21 10.4802 21 10.908 20.782C11.2843 20.5903 11.5903 20.2843 11.782 19.908C12 19.4802 12 18.9201 12 17.8V15.2C12 14.0799 12 13.5198 11.782 13.092C11.5903 12.7157 11.2843 12.4097 10.908 12.218C10.4802 12 9.92011 12 8.8 12H6.2C5.0799 12 4.51984 12 4.09202 12.218C3.71569 12.4097 3.40973 12.7157 3.21799 13.092C3 13.5198 3 14.0799 3 15.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),PGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path class=copier d="M8 8V5.2C8 4.0799 8 3.51984 8.21799 3.09202C8.40973 2.71569 8.71569 2.40973 9.09202 2.21799C9.51984 2 10.0799 2 11.2 2H18.8C19.9201 2 20.4802 2 20.908 2.21799C21.2843 2.40973 21.5903 2.71569 21.782 3.09202C22 3.51984 22 4.0799 22 5.2V12.8C22 13.9201 22 14.4802 21.782 14.908C21.5903 15.2843 21.2843 15.5903 20.908 15.782C20.4802 16 19.9201 16 18.8 16H16M5.2 22H12.8C13.9201 22 14.4802 22 14.908 21.782C15.2843 21.5903 15.5903 21.2843 15.782 20.908C16 20.4802 16 19.9201 16 18.8V11.2C16 10.0799 16 9.51984 15.782 9.09202C15.5903 8.71569 15.2843 8.40973 14.908 8.21799C14.4802 8 13.9201 8 12.8 8H5.2C4.0799 8 3.51984 8 3.09202 8.21799C2.71569 8.40973 2.40973 8.71569 2.21799 9.09202C2 9.51984 2 10.0799 2 11.2V18.8C2 19.9201 2 20.4802 2.21799 20.908C2.40973 21.2843 2.71569 21.5903 3.09202 21.782C3.51984 22 4.07989 22 5.2 22Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round stroke=currentColor>'),jGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M2.5 21.4998L8.04927 19.3655C8.40421 19.229 8.58168 19.1607 8.74772 19.0716C8.8952 18.9924 9.0358 18.901 9.16804 18.7984C9.31692 18.6829 9.45137 18.5484 9.72028 18.2795L21 6.99982C22.1046 5.89525 22.1046 4.10438 21 2.99981C19.8955 1.89525 18.1046 1.89524 17 2.99981L5.72028 14.2795C5.45138 14.5484 5.31692 14.6829 5.20139 14.8318C5.09877 14.964 5.0074 15.1046 4.92823 15.2521C4.83911 15.4181 4.77085 15.5956 4.63433 15.9506L2.5 21.4998ZM2.5 21.4998L4.55812 16.1488C4.7054 15.7659 4.77903 15.5744 4.90534 15.4867C5.01572 15.4101 5.1523 15.3811 5.2843 15.4063C5.43533 15.4351 5.58038 15.5802 5.87048 15.8703L8.12957 18.1294C8.41967 18.4195 8.56472 18.5645 8.59356 18.7155C8.61877 18.8475 8.58979 18.9841 8.51314 19.0945C8.42545 19.2208 8.23399 19.2944 7.85107 19.4417L2.5 21.4998Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),LGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),BGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9 9L15 15M15 9L9 15M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"stroke=#F04438 stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),RGe=Ot('<svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 xmlns=http://www.w3.org/2000/svg><rect class=list width=20 height=20 y=2 x=2 rx=2></rect><line class=list-item y1=7 y2=7 x1=6 x2=18></line><line class=list-item y2=12 y1=12 x1=6 x2=18></line><line class=list-item y1=17 y2=17 x1=6 x2=18>'),DGe=Ot('<svg viewBox="0 0 24 24"height=20 width=20 fill=none xmlns=http://www.w3.org/2000/svg><path d="M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),zGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M7.5 12L10.5 15L16.5 9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),OGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M12 2V6M12 18V22M6 12H2M22 12H18M19.0784 19.0784L16.25 16.25M19.0784 4.99994L16.25 7.82837M4.92157 19.0784L7.75 16.25M4.92157 4.99994L7.75 7.82837"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path><animateTransform attributeName=transform attributeType=XML type=rotate from=0 to=360 dur=2s repeatCount=indefinite>'),KGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M15 9L9 15M9 9L15 15M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),HGe=Ot('<svg width=14 height=14 viewBox="0 0 24 24"fill=none xmlns=http://www.w3.org/2000/svg><path d="M9.5 15V9M14.5 15V9M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),IGe=Ot('<svg version=1.0 viewBox="0 0 633 633"><linearGradient x1=-666.45 x2=-666.45 y1=163.28 y2=163.99 gradientTransform="matrix(633 0 0 633 422177 -103358)"gradientUnits=userSpaceOnUse><stop stop-color=#6BDAFF offset=0></stop><stop stop-color=#F9FFB5 offset=.32></stop><stop stop-color=#FFA770 offset=.71></stop><stop stop-color=#FF7373 offset=1></stop></linearGradient><circle cx=316.5 cy=316.5 r=316.5></circle><defs><filter x=-137.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=316.5 y=412 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=412 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=610.5 rx=214.5 ry=186 fill=#015064 stroke=#00CFE2 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=316.5 y=450 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=450 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=648.5 rx=214.5 ry=186 fill=#015064 stroke=#00A8B8 stroke-width=25></ellipse></g><defs><filter x=-137.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=-137.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=89.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=316.5 y=486 width=454 height=396.9 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=316.5 y=486 width=454 height=396.9 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><ellipse cx=543.5 cy=684.5 rx=214.5 ry=186 fill=#015064 stroke=#007782 stroke-width=25></ellipse></g><defs><filter x=272.2 y=308 width=176.9 height=129.3 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=272.2 y=308 width=176.9 height=129.3 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><line x1=436 x2=431 y1=403.2 y2=431.8 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=291 x2=280 y1=341.5 y2=403.5 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><line x1=332.9 x2=328.6 y1=384.1 y2=411.2 fill=none stroke=#000 stroke-linecap=round stroke-linejoin=bevel stroke-width=11></line><linearGradient x1=-670.75 x2=-671.59 y1=164.4 y2=164.49 gradientTransform="matrix(-184.16 -32.472 -11.461 64.997 -121359 -32126)"gradientUnits=userSpaceOnUse><stop stop-color=#EE2700 offset=0></stop><stop stop-color=#FF008E offset=1></stop></linearGradient><path d="m344.1 363 97.7 17.2c5.8 2.1 8.2 6.1 7.1 12.1s-4.7 9.2-11 9.9l-106-18.7-57.5-59.2c-3.2-4.8-2.9-9.1 0.8-12.8s8.3-4.4 13.7-2.1l55.2 53.6z"clip-rule=evenodd fill-rule=evenodd></path><line x1=428.2 x2=429.1 y1=384.5 y2=378 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=395.2 x2=396.1 y1=379.5 y2=373 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=362.2 x2=363.1 y1=373.5 y2=367.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=324.2 x2=328.4 y1=351.3 y2=347.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line><line x1=303.2 x2=307.4 y1=331.3 y2=327.4 fill=none stroke=#fff stroke-linecap=round stroke-linejoin=bevel stroke-width=7></line></g><defs><filter x=73.2 y=113.8 width=280.6 height=317.4 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=73.2 y=113.8 width=280.6 height=317.4 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-672.16 x2=-672.16 y1=165.03 y2=166.03 gradientTransform="matrix(-100.18 48.861 97.976 200.88 -83342 -93.059)"gradientUnits=userSpaceOnUse><stop stop-color=#A17500 offset=0></stop><stop stop-color=#5D2100 offset=1></stop></linearGradient><path d="m192.3 203c8.1 37.3 14 73.6 17.8 109.1 3.8 35.4 2.8 75.1-3 119.2l61.2-16.7c-15.6-59-25.2-97.9-28.6-116.6s-10.8-51.9-22.1-99.6l-25.3 4.6"clip-rule=evenodd fill-rule=evenodd></path><g stroke=#2F8A00><linearGradient x1=-660.23 x2=-660.23 y1=166.72 y2=167.72 gradientTransform="matrix(92.683 4.8573 -2.0259 38.657 61680 -3088.6)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9s-12.6-22.1-36.5-29.9c-15.9-5.2-34.4-1.5-55.5 11.1 15.9 14.3 29.5 22.6 40.7 24.9 16.8 3.6 51.3-6.1 51.3-6.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-661.36 x2=-661.36 y1=164.18 y2=165.18 gradientTransform="matrix(110 5.7648 -6.3599 121.35 73933 -15933)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5s-47.5-8.5-83.2 15.7c-23.8 16.2-34.3 49.3-31.6 99.4 30.3-27.8 52.1-48.5 65.2-61.9 19.8-20.2 49.6-53.2 49.6-53.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.79 x2=-656.79 y1=165.15 y2=166.15 gradientTransform="matrix(62.954 3.2993 -3.5023 66.828 42156 -8754.1)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m195 183.9c-0.8-21.9 6-38 20.6-48.2s29.8-15.4 45.5-15.3c-6.1 21.4-14.5 35.8-25.2 43.4s-24.4 14.2-40.9 20.1z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-663.07 x2=-663.07 y1=165.44 y2=166.44 gradientTransform="matrix(152.47 7.9907 -3.0936 59.029 101884 -4318.7)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c31.9-30 64.1-39.7 96.7-29s50.8 30.4 54.6 59.1c-35.2-5.5-60.4-9.6-75.8-12.1-15.3-2.6-40.5-8.6-75.5-18z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-662.57 x2=-662.57 y1=164.44 y2=165.44 gradientTransform="matrix(136.46 7.1517 -5.2163 99.533 91536 -11442)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c35.8-7.6 65.6-0.2 89.2 22s37.7 49 42.3 80.3c-39.8-9.7-68.3-23.8-85.5-42.4s-32.5-38.5-46-59.9z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><linearGradient x1=-656.43 x2=-656.43 y1=163.86 y2=164.86 gradientTransform="matrix(60.866 3.1899 -8.7773 167.48 41560 -25168)"gradientUnits=userSpaceOnUse><stop stop-color=#2F8A00 offset=0></stop><stop stop-color=#90FF57 offset=1></stop></linearGradient><path d="m194.9 184.5c-33.6 13.8-53.6 35.7-60.1 65.6s-3.6 63.1 8.7 99.6c27.4-40.3 43.2-69.6 47.4-88s5.6-44.1 4-77.2z"clip-rule=evenodd fill-rule=evenodd stroke-width=13></path><path d="m196.5 182.3c-14.8 21.6-25.1 41.4-30.8 59.4s-9.5 33-11.1 45.1"fill=none stroke-linecap=round stroke-width=8></path><path d="m194.9 185.7c-24.4 1.7-43.8 9-58.1 21.8s-24.7 25.4-31.3 37.8"fill=none stroke-linecap=round stroke-width=8></path><path d="m204.5 176.4c29.7-6.7 52-8.4 67-5.1s26.9 8.6 35.8 15.9"fill=none stroke-linecap=round stroke-width=8></path><path d="m196.5 181.4c20.3 9.9 38.2 20.5 53.9 31.9s27.4 22.1 35.1 32"fill=none stroke-linecap=round stroke-width=8></path></g></g><defs><filter x=50.5 y=399 width=532 height=633 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=50.5 y=399 width=532 height=633 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-666.06 x2=-666.23 y1=163.36 y2=163.75 gradientTransform="matrix(532 0 0 633 354760 -102959)"gradientUnits=userSpaceOnUse><stop stop-color=#FFF400 offset=0></stop><stop stop-color=#3C8700 offset=1></stop></linearGradient><ellipse cx=316.5 cy=715.5 rx=266 ry=316.5></ellipse></g><defs><filter x=391 y=-24 width=288 height=283 filterUnits=userSpaceOnUse><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix></filter></defs><mask x=391 y=-24 width=288 height=283 maskUnits=userSpaceOnUse><g><circle cx=316.5 cy=316.5 r=316.5 fill=#fff></circle></g></mask><g><linearGradient x1=-664.56 x2=-664.56 y1=163.79 y2=164.79 gradientTransform="matrix(227 0 0 227 151421 -37204)"gradientUnits=userSpaceOnUse><stop stop-color=#FFDF00 offset=0></stop><stop stop-color=#FF9D00 offset=1></stop></linearGradient><circle cx=565.5 cy=89.5 r=113.5></circle><linearGradient x1=-644.5 x2=-645.77 y1=342 y2=342 gradientTransform="matrix(30 0 0 1 19770 -253)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=427 x2=397 y1=89 y2=89 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-641.56 x2=-642.83 y1=196.02 y2=196.07 gradientTransform="matrix(26.5 0 0 5.5 17439 -1025.5)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=430.5 x2=404 y1=55.5 y2=50 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-643.73 x2=-645 y1=185.83 y2=185.9 gradientTransform="matrix(29 0 0 8 19107 -1361)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=431 x2=402 y1=122 y2=130 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-638.94 x2=-640.22 y1=177.09 y2=177.39 gradientTransform="matrix(24 0 0 13 15783 -2145)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=442 x2=418 y1=153 y2=166 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-633.42 x2=-634.7 y1=172.41 y2=173.31 gradientTransform="matrix(20 0 0 19 13137 -3096)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=464 x2=444 y1=180 y2=199 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-619.05 x2=-619.52 y1=170.82 y2=171.82 gradientTransform="matrix(13.83 0 0 22.85 9050 -3703.4)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=491.4 x2=477.5 y1=203 y2=225.9 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=-578.5 x2=-578.63 y1=170.31 y2=171.31 gradientTransform="matrix(7.5 0 0 24.5 4860 -3953)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=524.5 x2=517 y1=219.5 y2=244 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12></line><linearGradient x1=666.5 x2=666.5 y1=170.31 y2=171.31 gradientTransform="matrix(.5 0 0 24.5 231.5 -3944)"gradientUnits=userSpaceOnUse><stop stop-color=#FFA400 offset=0></stop><stop stop-color=#FF5E00 offset=1></stop></linearGradient><line x1=564.5 x2=565 y1=228.5 y2=253 fill=none stroke-linecap=round stroke-linejoin=bevel stroke-width=12>');function FGe(){return bGe()}function GGe(){return kGe()}function VGe(){return SGe()}function JGe(){return wGe()}function UGe(){return AGe()}function WGe(){return(e=AGe()).style.setProperty("transform","rotate(90deg)"),e;var e}function qGe(){return(e=AGe()).style.setProperty("transform","rotate(-90deg)"),e;var e}function $Ge(){return CGe()}function ZGe(){return MGe()}function YGe(){return TGe()}function QGe(){return xGe()}function XGe(){return EGe()}function eVe(){return NGe()}function aVe(){return _Ge()}function tVe(){return PGe()}function nVe(){return jGe()}function iVe(e){return a=LGe(),t=a.firstChild,Ra((()=>Ht(t,"stroke","dark"===e.theme?"#12B76A":"#027A48"))),a;var a,t}function rVe(){return BGe()}function oVe(){return RGe()}function sVe(e){return[ht(Tt,{get when(){return e.checked},get children(){var a=LGe(),t=a.firstChild;return Ra((()=>Ht(t,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}}),ht(Tt,{get when(){return!e.checked},get children(){var a=DGe(),t=a.firstChild;return Ra((()=>Ht(t,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}})]}function lVe(){return zGe()}function uVe(){return OGe()}function cVe(){return KGe()}function dVe(){return HGe()}function mVe(){const e=wt();return a=IGe(),r=(i=(n=(t=a.firstChild).nextSibling).nextSibling).firstChild,s=(o=i.nextSibling).firstChild,c=(u=(l=o.nextSibling).nextSibling).firstChild,m=(d=u.nextSibling).firstChild,g=(p=(h=d.nextSibling).nextSibling).firstChild,v=(f=p.nextSibling).firstChild,k=(b=(y=f.nextSibling).nextSibling).firstChild,w=(S=b.nextSibling).firstChild,M=(C=(A=S.nextSibling).nextSibling).firstChild,x=(T=C.nextSibling).firstChild,_=(N=(E=T.nextSibling).nextSibling).firstChild,j=(P=N.nextSibling).firstChild,R=(B=(L=P.nextSibling).nextSibling).firstChild,z=(D=B.nextSibling).firstChild,H=(K=(O=D.nextSibling).firstChild.nextSibling.nextSibling.nextSibling).nextSibling,F=(I=O.nextSibling).firstChild,V=(G=I.nextSibling).firstChild,re=(ie=(ne=(te=(ae=(ee=(X=(Q=(Y=(Z=($=(q=(W=(U=(J=G.nextSibling).firstChild).nextSibling).nextSibling.firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,se=(oe=J.nextSibling).firstChild,ue=(le=oe.nextSibling).firstChild,me=(de=(ce=le.nextSibling).firstChild).nextSibling,pe=(he=ce.nextSibling).firstChild,fe=(ge=he.nextSibling).firstChild,Re=(Be=(Le=(je=(Pe=(_e=(Ne=(Ee=(xe=(Te=(Me=(Ce=(Ae=(we=(Se=(ke=(be=(ye=(ve=ge.nextSibling).firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,Ht(t,"id",`a-${e}`),Ht(n,"fill",`url(#a-${e})`),Ht(r,"id",`am-${e}`),Ht(o,"id",`b-${e}`),Ht(s,"filter",`url(#am-${e})`),Ht(l,"mask",`url(#b-${e})`),Ht(c,"id",`ah-${e}`),Ht(d,"id",`k-${e}`),Ht(m,"filter",`url(#ah-${e})`),Ht(h,"mask",`url(#k-${e})`),Ht(g,"id",`ae-${e}`),Ht(f,"id",`j-${e}`),Ht(v,"filter",`url(#ae-${e})`),Ht(y,"mask",`url(#j-${e})`),Ht(k,"id",`ai-${e}`),Ht(S,"id",`i-${e}`),Ht(w,"filter",`url(#ai-${e})`),Ht(A,"mask",`url(#i-${e})`),Ht(M,"id",`aj-${e}`),Ht(T,"id",`h-${e}`),Ht(x,"filter",`url(#aj-${e})`),Ht(E,"mask",`url(#h-${e})`),Ht(_,"id",`ag-${e}`),Ht(P,"id",`g-${e}`),Ht(j,"filter",`url(#ag-${e})`),Ht(L,"mask",`url(#g-${e})`),Ht(R,"id",`af-${e}`),Ht(D,"id",`f-${e}`),Ht(z,"filter",`url(#af-${e})`),Ht(O,"mask",`url(#f-${e})`),Ht(K,"id",`m-${e}`),Ht(H,"fill",`url(#m-${e})`),Ht(F,"id",`ak-${e}`),Ht(G,"id",`e-${e}`),Ht(V,"filter",`url(#ak-${e})`),Ht(J,"mask",`url(#e-${e})`),Ht(U,"id",`n-${e}`),Ht(W,"fill",`url(#n-${e})`),Ht(q,"id",`r-${e}`),Ht($,"fill",`url(#r-${e})`),Ht(Z,"id",`s-${e}`),Ht(Y,"fill",`url(#s-${e})`),Ht(Q,"id",`q-${e}`),Ht(X,"fill",`url(#q-${e})`),Ht(ee,"id",`p-${e}`),Ht(ae,"fill",`url(#p-${e})`),Ht(te,"id",`o-${e}`),Ht(ne,"fill",`url(#o-${e})`),Ht(ie,"id",`l-${e}`),Ht(re,"fill",`url(#l-${e})`),Ht(se,"id",`al-${e}`),Ht(le,"id",`d-${e}`),Ht(ue,"filter",`url(#al-${e})`),Ht(ce,"mask",`url(#d-${e})`),Ht(de,"id",`u-${e}`),Ht(me,"fill",`url(#u-${e})`),Ht(pe,"id",`ad-${e}`),Ht(ge,"id",`c-${e}`),Ht(fe,"filter",`url(#ad-${e})`),Ht(ve,"mask",`url(#c-${e})`),Ht(ye,"id",`t-${e}`),Ht(be,"fill",`url(#t-${e})`),Ht(ke,"id",`v-${e}`),Ht(Se,"stroke",`url(#v-${e})`),Ht(we,"id",`aa-${e}`),Ht(Ae,"stroke",`url(#aa-${e})`),Ht(Ce,"id",`w-${e}`),Ht(Me,"stroke",`url(#w-${e})`),Ht(Te,"id",`ac-${e}`),Ht(xe,"stroke",`url(#ac-${e})`),Ht(Ee,"id",`ab-${e}`),Ht(Ne,"stroke",`url(#ab-${e})`),Ht(_e,"id",`y-${e}`),Ht(Pe,"stroke",`url(#y-${e})`),Ht(je,"id",`x-${e}`),Ht(Le,"stroke",`url(#x-${e})`),Ht(Be,"id",`z-${e}`),Ht(Re,"stroke",`url(#z-${e})`),a;var a,t,n,i,r,o,s,l,u,c,d,m,h,p,g,f,v,y,b,k,S,w,A,C,M,T,x,E,N,_,P,j,L,B,R,D,z,O,K,H,I,F,G,V,J,U,W,q,$,Z,Y,Q,X,ee,ae,te,ne,ie,re,oe,se,le,ue,ce,de,me,he,pe,ge,fe,ve,ye,be,ke,Se,we,Ae,Ce,Me,Te,xe,Ee,Ne,_e,Pe,je,Le,Be,Re}var hVe=Ot('<span><svg width=16 height=16 viewBox="0 0 16 16"fill=none xmlns=http://www.w3.org/2000/svg><path d="M6 12L10 8L6 4"stroke-width=2 stroke-linecap=round stroke-linejoin=round>'),pVe=Ot('<button title="Copy object to clipboard">'),gVe=Ot('<button title="Remove all items"aria-label="Remove all items">'),fVe=Ot('<button title="Delete item"aria-label="Delete item">'),vVe=Ot('<button title="Toggle value"aria-label="Toggle value">'),yVe=Ot('<button title="Bulk Edit Data"aria-label="Bulk Edit Data">'),bVe=Ot("<div>"),kVe=Ot("<div><button> <span></span> <span> "),SVe=Ot("<input>"),wVe=Ot("<span>"),AVe=Ot("<div><span>:"),CVe=Ot("<div><div><button> [<!>...<!>]");var MVe=e=>{const a=Jze(),t=Hze().shadowDOMTarget?fOe.bind({target:Hze().shadowDOMTarget}):fOe,n=za((()=>"dark"===a()?BVe(t):LVe(t)));return i=hVe(),Ra((()=>It(i,yOe(n().expander,t`
|
|
93
93
|
transform: rotate(${e.expanded?90:0}deg);
|
|
94
94
|
`,e.expanded&&t`
|
|
95
95
|
& svg {
|