@embedreach/components 0.2.64 → 0.2.66

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/index.umd.js CHANGED
@@ -111,7 +111,7 @@ function YQ(e,a){return e?function(e){return"function"==typeof e&&(()=>{const a=
111
111
  *
112
112
  * This source code is licensed under the MIT license found in the
113
113
  * LICENSE file in the root directory of this source tree.
114
- */tse.exports="production"===process.env.NODE_ENV?function(){if(nse)return ise;nse=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},n=a.useState,t=a.useEffect,i=a.useLayoutEffect,r=a.useDebugValue;function o(a){var n=a.getSnapshot;a=a.value;try{var t=n();return!e(a,t)}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=n({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]),t((function(){return o(u)&&c({inst:u}),e((function(){o(u)&&c({inst:u})}))}),[e]),r(s),s};return ise.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:s,ise}():(rse||(rse=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var a=e.getSnapshot;e=e.value;try{var n=a();return!t(e,n)}catch(i){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=a,t="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},i=n.useState,r=n.useEffect,o=n.useLayoutEffect,s=n.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===n.startTransition||(l=!0);var d=c();if(!u){var m=c();t(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};ose.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),ose);var sse=tse.exports,lse='[cmdk-group=""]',use='[cmdk-group-items=""]',cse='[cmdk-item=""]',dse=`${cse}:not([aria-disabled="true"])`,mse="cmdk-item-select",hse="data-value",pse=(e,a,n)=>ase(e,a,n),gse=r.createContext(void 0),vse=()=>r.useContext(gse),fse=r.createContext(void 0),yse=()=>r.useContext(fse),kse=r.createContext(void 0),bse=r.forwardRef(((e,a)=>{let n=zse((()=>{var a,n;return{search:"",value:null!=(n=null!=(a=e.value)?a:e.defaultValue)?n:"",filtered:{count:0,items:new Map,groups:new Set}}})),t=zse((()=>new Set)),i=zse((()=>new Map)),o=zse((()=>new Map)),s=zse((()=>new Set)),l=Lse(e),{label:u,children:c,value:d,onValueChange:m,filter:h,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:f=!0,...y}=e,k=KX(),b=KX(),S=KX(),A=r.useRef(null),w=Kse();Bse((()=>{if(void 0!==d){let e=d.trim();n.current.value=e,C.emit()}}),[d]),Bse((()=>{w(6,P)}),[]);let C=r.useMemo((()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>n.current,setState:(e,a,t)=>{var i,r,o;if(!Object.is(n.current[e],a)){if(n.current[e]=a,"search"===e)x(),N(),w(1,E);else if("value"===e&&(t||w(5,P),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,t)=>{var i;a!==(null==(i=o.current.get(e))?void 0:i.value)&&(o.current.set(e,{value:a,keywords:t}),n.current.filtered.items.set(e,T(a,t)),w(2,(()=>{N(),C.emit()})))},item:(e,a)=>(t.current.add(e),a&&(i.current.has(a)?i.current.get(a).add(e):i.current.set(a,new Set([e]))),w(3,(()=>{x(),N(),n.current.value||E(),C.emit()})),()=>{o.current.delete(e),t.current.delete(e),n.current.filtered.items.delete(e);let a=j();w(4,(()=>{x(),(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:k,inputId:S,labelId:b,listInnerRef:A})),[]);function T(e,a){var t,i;let r=null!=(i=null==(t=l.current)?void 0:t.filter)?i:pse;return e?r(e,n.current.search,a):0}function N(){if(!n.current.search||!1===l.current.shouldFilter)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach((n=>{let t=i.current.get(n),r=0;t.forEach((a=>{let n=e.get(a);r=Math.max(n,r)})),a.push([n,r])}));let t=A.current;L().sort(((a,n)=>{var t,i;let r=a.getAttribute("id"),o=n.getAttribute("id");return(null!=(t=e.get(o))?t:0)-(null!=(i=e.get(r))?i:0)})).forEach((e=>{let a=e.closest(use);a?a.appendChild(e.parentElement===a?e:e.closest(`${use} > *`)):t.appendChild(e.parentElement===t?e:e.closest(`${use} > *`))})),a.sort(((e,a)=>a[1]-e[1])).forEach((e=>{var a;let n=null==(a=A.current)?void 0:a.querySelector(`${lse}[${hse}="${encodeURIComponent(e[0])}"]`);null==n||n.parentElement.appendChild(n)}))}function E(){let e=L().find((e=>"true"!==e.getAttribute("aria-disabled"))),a=null==e?void 0:e.getAttribute(hse);C.setState("value",a||void 0)}function x(){var e,a,r,s;if(!n.current.search||!1===l.current.shouldFilter)return void(n.current.filtered.count=t.current.size);n.current.filtered.groups=new Set;let u=0;for(let i of t.current){let t=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:[]);n.current.filtered.items.set(i,t),t>0&&u++}for(let[t,o]of i.current)for(let e of o)if(n.current.filtered.items.get(e)>0){n.current.filtered.groups.add(t);break}n.current.filtered.count=u}function P(){var e,a,n;let t=j();t&&((null==(e=t.parentElement)?void 0:e.firstChild)===t&&(null==(n=null==(a=t.closest(lse))?void 0:a.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),t.scrollIntoView({block:"nearest"}))}function j(){var e;return null==(e=A.current)?void 0:e.querySelector(`${cse}[aria-selected="true"]`)}function L(){var e;return Array.from((null==(e=A.current)?void 0:e.querySelectorAll(dse))||[])}function B(e){let a=L()[e];a&&C.setState("value",a.getAttribute(hse))}function z(e){var a;let n=j(),t=L(),i=t.findIndex((e=>e===n)),r=t[i+e];null!=(a=l.current)&&a.loop&&(r=i+e<0?t[t.length-1]:i+e===t.length?t[0]:t[i+e]),r&&C.setState("value",r.getAttribute(hse))}function R(e){let a,n=j(),t=null==n?void 0:n.closest(lse);for(;t&&!a;)t=e>0?Pse(t,lse):jse(t,lse),a=null==t?void 0:t.querySelector(dse);a?C.setState("value",a.getAttribute(hse)):z(e)}let _=()=>B(L().length-1),D=e=>{e.preventDefault(),e.metaKey?_():e.altKey?R(1):z(1)},K=e=>{e.preventDefault(),e.metaKey?B(0):e.altKey?R(-1):z(-1)};return r.createElement(lX.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":f&&e.ctrlKey&&D(e);break;case"ArrowDown":D(e);break;case"p":case"k":f&&e.ctrlKey&&K(e);break;case"ArrowUp":K(e);break;case"Home":e.preventDefault(),B(0);break;case"End":e.preventDefault(),_();break;case"Enter":if(!e.nativeEvent.isComposing&&229!==e.keyCode){e.preventDefault();let a=j();if(a){let e=new Event(mse);a.dispatchEvent(e)}}}}},r.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:Ose},u),Hse(e,(e=>r.createElement(fse.Provider,{value:C},r.createElement(gse.Provider,{value:M},e)))))})),Sse=r.forwardRef(((e,a)=>{var n,t;let i=KX(),o=r.useRef(null),s=r.useContext(kse),l=vse(),u=Lse(e),c=null!=(t=null==(n=u.current)?void 0:n.forceMount)?t:null==s?void 0:s.forceMount;Bse((()=>{if(!c)return l.item(i,null==s?void 0:s.id)}),[c]);let d=Dse(i,o,[e.value,e.children,o],e.keywords),m=yse(),h=_se((e=>e.value&&e.value===d.current)),p=_se((e=>!(!c&&!1!==l.filter())||(!e.search||e.filtered.items.get(i)>0)));function g(){var e,a;v(),null==(a=(e=u.current).onSelect)||a.call(e,d.current)}function v(){m.setState("value",d.current,!0)}if(r.useEffect((()=>{let a=o.current;if(a&&!e.disabled)return a.addEventListener(mse,g),()=>a.removeEventListener(mse,g)}),[p,e.onSelect,e.disabled]),!p)return null;let{disabled:f,value:y,onSelect:k,forceMount:b,keywords:S,...A}=e;return r.createElement(lX.div,{ref:Rse([o,a]),...A,id:i,"cmdk-item":"",role:"option","aria-disabled":!!f,"aria-selected":!!h,"data-disabled":!!f,"data-selected":!!h,onPointerMove:f||l.getDisablePointerSelection()?void 0:v,onClick:f?void 0:g},e.children)})),Ase=r.forwardRef(((e,a)=>{let{heading:n,children:t,forceMount:i,...o}=e,s=KX(),l=r.useRef(null),u=r.useRef(null),c=KX(),d=vse(),m=_se((e=>!(!i&&!1!==d.filter())||(!e.search||e.filtered.groups.has(s))));Bse((()=>d.group(s)),[]),Dse(s,l,[e.value,e.heading,u]);let h=r.useMemo((()=>({id:s,forceMount:i})),[i]);return r.createElement(lX.div,{ref:Rse([l,a]),...o,"cmdk-group":"",role:"presentation",hidden:!m||void 0},n&&r.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Hse(e,(e=>r.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},r.createElement(kse.Provider,{value:h},e)))))})),wse=r.forwardRef(((e,a)=>{let{alwaysRender:n,...t}=e,i=r.useRef(null),o=_se((e=>!e.search));return n||o?r.createElement(lX.div,{ref:Rse([i,a]),...t,"cmdk-separator":"",role:"separator"}):null})),Cse=r.forwardRef(((e,a)=>{let{onValueChange:n,...t}=e,i=null!=e.value,o=yse(),s=_se((e=>e.search)),l=_se((e=>e.value)),u=vse(),c=r.useMemo((()=>{var e;let a=null==(e=u.listInnerRef.current)?void 0:e.querySelector(`${cse}[${hse}="${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(lX.input,{ref:a,...t,"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==n||n(e.target.value)}})})),Mse=r.forwardRef(((e,a)=>{let{children:n,label:t="Suggestions",...i}=e,o=r.useRef(null),s=r.useRef(null),l=vse();return r.useEffect((()=>{if(s.current&&o.current){let e,a=s.current,n=o.current,t=new ResizeObserver((()=>{e=requestAnimationFrame((()=>{n.style.setProperty("--cmdk-list-height",a.offsetHeight.toFixed(1)+"px")}))}));return t.observe(a),()=>{cancelAnimationFrame(e),t.unobserve(a)}}}),[]),r.createElement(lX.div,{ref:Rse([o,a]),...i,"cmdk-list":"",role:"listbox","aria-label":t,id:l.listId},Hse(e,(e=>r.createElement("div",{ref:Rse([s,l.listInnerRef]),"cmdk-list-sizer":""},e))))})),Tse=r.forwardRef(((e,a)=>{let{open:n,onOpenChange:t,overlayClassName:i,contentClassName:o,container:s,...l}=e;return r.createElement(RG,{open:n,onOpenChange:t},r.createElement(_G,{container:s},r.createElement(DG,{"cmdk-overlay":"",className:i}),r.createElement(KG,{"aria-label":e.label,"cmdk-dialog":"",className:o},r.createElement(bse,{ref:a,...l}))))})),Nse=r.forwardRef(((e,a)=>_se((e=>0===e.filtered.count))?r.createElement(lX.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null)),Ese=r.forwardRef(((e,a)=>{let{progress:n,children:t,label:i="Loading...",...o}=e;return r.createElement(lX.div,{ref:a,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Hse(e,(e=>r.createElement("div",{"aria-hidden":!0},e))))})),xse=Object.assign(bse,{List:Mse,Item:Sse,Input:Cse,Group:Ase,Separator:wse,Dialog:Tse,Empty:Nse,Loading:Ese});function Pse(e,a){let n=e.nextElementSibling;for(;n;){if(n.matches(a))return n;n=n.nextElementSibling}}function jse(e,a){let n=e.previousElementSibling;for(;n;){if(n.matches(a))return n;n=n.previousElementSibling}}function Lse(e){let a=r.useRef(e);return Bse((()=>{a.current=e})),a}var Bse="undefined"==typeof window?r.useEffect:r.useLayoutEffect;function zse(e){let a=r.useRef();return void 0===a.current&&(a.current=e()),a}function Rse(e){return a=>{e.forEach((e=>{"function"==typeof e?e(a):null!=e&&(e.current=a)}))}}function _se(e){let a=yse(),n=()=>e(a.snapshot());return sse.useSyncExternalStore(a.subscribe,n,n)}function Dse(e,a,n,t=[]){let i=r.useRef(),o=vse();return Bse((()=>{var r;let s=(()=>{var e;for(let a of n){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=t.map((e=>e.trim()));o.value(e,s,l),null==(r=a.current)||r.setAttribute(hse,s),i.current=s})),i}var Kse=()=>{let[e,a]=r.useState(),n=zse((()=>new Map));return Bse((()=>{n.current.forEach((e=>e())),n.current=new Map}),[e]),(e,t)=>{n.current.set(e,t),a({})}};function Hse({asChild:e,children:a},n){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},n(a.props.children)):n(a)}var Ose={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Ise=r.forwardRef((({className:e,...a},t)=>n.jsx(xse,{ref:t,className:pm("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a})));Ise.displayName=xse.displayName;const Gse=r.forwardRef((({className:e,searchIcon:a,...t},i)=>n.jsxs("div",{className:"flex items-center border-b px-3",children:[a||n.jsx(sd,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 "}),n.jsx(xse.Input,{ref:i,className:pm("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),...t})]})));Gse.displayName=xse.Input.displayName;const Vse=r.forwardRef((({className:e,...a},t)=>n.jsx(xse.List,{ref:t,className:pm("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a})));Vse.displayName=xse.List.displayName;const Fse=r.forwardRef(((e,a)=>n.jsx(xse.Empty,{ref:a,className:"py-6 text-center text-sm",...e})));Fse.displayName=xse.Empty.displayName;const Jse=r.forwardRef((({className:e,...a},t)=>n.jsx(xse.Group,{ref:t,className:pm("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})));Jse.displayName=xse.Group.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(xse.Separator,{ref:t,className:pm("-mx-1 h-px bg-border",e),...a}))).displayName=xse.Separator.displayName;const Use=r.forwardRef((({className:e,...a},t)=>n.jsx(xse.Item,{ref:t,className:pm("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 Wse(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function qse(...e){return a=>{let n=!1;const t=e.map((e=>{const t=Wse(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():Wse(e[a],null)}}}}function Zse(...e){return r.useCallback(qse(...e),e)}function $se(e){const a=Yse(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Xse);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 n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function Yse(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{const a=r(...e);return i(...e),a}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?qse(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}Use.displayName=xse.Item.displayName;var Qse=Symbol("radix.slottable");function Xse(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Qse}var ele=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=$se(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),ale=globalThis?.document?r.useLayoutEffect:()=>{};var nle=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=tle(t.current);o.current="mounted"===l?e:"none"}),[l]),ale((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=tle(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),ale((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=tle(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=tle(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.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=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=Zse(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function tle(e){return e?.animationName||"none"}function ile(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function rle(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}nle.displayName="Presence";var ole=r.createContext(void 0);function sle(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}var lle="ScrollArea",[ule,cle]=function(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},ile(i,...a)]}(lle),[dle,mle]=ule(lle),hle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,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,v]=r.useState(null),[f,y]=r.useState(null),[k,b]=r.useState(0),[S,A]=r.useState(0),[w,C]=r.useState(!1),[M,T]=r.useState(!1),N=Zse(a,(e=>c(e))),E=function(e){const a=r.useContext(ole);return e||a||"ltr"}(o);return n.jsx(dle,{scope:t,type:i,dir:E,scrollHideDelay:s,scrollArea:u,viewport:d,onViewportChange:m,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:w,onScrollbarXEnabledChange:C,scrollbarY:f,onScrollbarYChange:y,scrollbarYEnabled:M,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:A,children:n.jsx(ele.div,{dir:E,...l,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})}));hle.displayName=lle;var ple="ScrollAreaViewport",gle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,children:i,nonce:o,...s}=e,l=mle(ple,t),u=Zse(a,r.useRef(null),l.onViewportChange);return n.jsxs(n.Fragment,{children:[n.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}),n.jsx(ele.div,{"data-radix-scroll-area-viewport":"",...s,ref:u,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})}));gle.displayName=ple;var vle="ScrollAreaScrollbar",fle=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=mle(vle,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?n.jsx(yle,{...i,ref:a,forceMount:t}):"scroll"===o.type?n.jsx(kle,{...i,ref:a,forceMount:t}):"auto"===o.type?n.jsx(ble,{...i,ref:a,forceMount:t}):"always"===o.type?n.jsx(Sle,{...i,ref:a}):null}));fle.displayName=vle;var yle=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=mle(vle,e.__scopeScrollArea),[s,l]=r.useState(!1);return r.useEffect((()=>{const e=o.scrollArea;let a=0;if(e){const n=()=>{window.clearTimeout(a),l(!0)},t=()=>{a=window.setTimeout((()=>l(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",t),()=>{window.clearTimeout(a),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",t)}}}),[o.scrollArea,o.scrollHideDelay]),n.jsx(nle,{present:t||s,children:n.jsx(ble,{"data-state":s?"visible":"hidden",...i,ref:a})})})),kle=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=mle(vle,e.__scopeScrollArea),s="horizontal"===e.orientation,l=Ole((()=>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 n=e[a];const t=()=>{const t=e[a];n!==t&&(c("SCROLL"),l()),n=t};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[o.viewport,s,c,l]),n.jsx(nle,{present:t||"hidden"!==u,children:n.jsx(Sle,{"data-state":"hidden"===u?"hidden":"visible",...i,ref:a,onPointerEnter:sle(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:sle(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),ble=r.forwardRef(((e,a)=>{const t=mle(vle,e.__scopeScrollArea),{forceMount:i,...o}=e,[s,l]=r.useState(!1),u="horizontal"===e.orientation,c=Ole((()=>{if(t.viewport){l(u?t.viewport.offsetWidth<t.viewport.scrollWidth:t.viewport.offsetHeight<t.viewport.scrollHeight)}}),10);return Ile(t.viewport,c),Ile(t.content,c),n.jsx(nle,{present:i||s,children:n.jsx(Sle,{"data-state":s?"visible":"hidden",...o,ref:a})})})),Sle=r.forwardRef(((e,a)=>{const{orientation:t="vertical",...i}=e,o=mle(vle,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=zle(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,n,t="ltr"){const i=Rle(n),r=i/2,o=a||r,s=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-(i-o),u=n.content-n.viewport,c="ltr"===t?[0,u]:[-1*u,0];return Dle([s,l],c)(e)}(e,l.current,u,a)}return"horizontal"===t?n.jsx(Ale,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=_le(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"===t?n.jsx(wle,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=_le(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})),Ale=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=mle(vle,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Zse(a,c,s.onScrollbarXChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(Tle,{"data-orientation":"horizontal",...o,ref:d,sizes:t,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":Rle(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.x),onDragScroll:a=>e.onDragScroll(a.x),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollLeft+a.deltaX;e.onWheelScroll(t),Kle(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ble(l.paddingLeft),paddingEnd:Ble(l.paddingRight)}})}})})),wle=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=mle(vle,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Zse(a,c,s.onScrollbarYChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(Tle,{"data-orientation":"vertical",...o,ref:d,sizes:t,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":Rle(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.y),onDragScroll:a=>e.onDragScroll(a.y),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollTop+a.deltaY;e.onWheelScroll(t),Kle(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ble(l.paddingTop),paddingEnd:Ble(l.paddingBottom)}})}})})),[Cle,Mle]=ule(vle),Tle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,sizes:i,hasThumb:o,onThumbChange:s,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...p}=e,g=mle(vle,t),[v,f]=r.useState(null),y=Zse(a,(e=>f(e))),k=r.useRef(null),b=r.useRef(""),S=g.viewport,A=i.content-i.viewport,w=rle(m),C=rle(c),M=Ole(h,10);function T(e){if(k.current){d({x:e.clientX-k.current.left,y:e.clientY-k.current.top})}}return r.useEffect((()=>{const e=e=>{const a=e.target,n=v?.contains(a);n&&w(e,A)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[S,v,A,w]),r.useEffect(C,[i,C]),Ile(v,M),Ile(g.content,M),n.jsx(Cle,{scope:t,scrollbar:v,hasThumb:o,onThumbChange:rle(s),onThumbPointerUp:rle(l),onThumbPositionChange:C,onThumbPointerDown:rle(u),children:n.jsx(ele.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:sle(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),k.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(e)}})),onPointerMove:sle(e.onPointerMove,T),onPointerUp:sle(e.onPointerUp,(e=>{const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,g.viewport&&(g.viewport.style.scrollBehavior=""),k.current=null}))})})})),Nle="ScrollAreaThumb",Ele=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,r=Mle(Nle,e.__scopeScrollArea);return n.jsx(nle,{present:t||r.hasThumb,children:n.jsx(xle,{ref:a,...i})})})),xle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,style:i,...o}=e,s=mle(Nle,t),l=Mle(Nle,t),{onThumbPositionChange:u}=l,c=Zse(a,(e=>l.onThumbChange(e))),d=r.useRef(void 0),m=Ole((()=>{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=Hle(e,u);d.current=a,u()}};return u(),e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}}),[s.viewport,m,u]),n.jsx(ele.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:sle(e.onPointerDownCapture,(e=>{const a=e.target.getBoundingClientRect();l.onThumbPointerDown({x:e.clientX-a.left,y:e.clientY-a.top})})),onPointerUp:sle(e.onPointerUp,l.onThumbPointerUp)})}));Ele.displayName=Nle;var Ple="ScrollAreaCorner",jle=r.forwardRef(((e,a)=>{const t=mle(Ple,e.__scopeScrollArea),i=Boolean(t.scrollbarX&&t.scrollbarY);return"scroll"!==t.type&&i?n.jsx(Lle,{...e,ref:a}):null}));jle.displayName=Ple;var Lle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,...i}=e,o=mle(Ple,t),[s,l]=r.useState(0),[u,c]=r.useState(0),d=Boolean(s&&u);return Ile(o.scrollbarX,(()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)})),Ile(o.scrollbarY,(()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),l(e)})),d?n.jsx(ele.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 Ble(e){return e?parseInt(e,10):0}function zle(e,a){const n=e/a;return isNaN(n)?0:n}function Rle(e){const a=zle(e.viewport,e.content);return Math.max((e.scrollbar.size-(e.scrollbar.paddingStart+e.scrollbar.paddingEnd))*a,18)}function _le(e,a,n="ltr"){const t=Rle(a),i=a.content-a.viewport,r=a.scrollbar.size-(a.scrollbar.paddingStart+a.scrollbar.paddingEnd)-t,o=function(e,[a,n]){return Math.min(n,Math.max(a,e))}(e,"ltr"===n?[0,i]:[-1*i,0]);return Dle([0,i],[0,r])(o)}function Dle(e,a){return n=>{if(e[0]===e[1]||a[0]===a[1])return a[0];return a[0]+(a[1]-a[0])/(e[1]-e[0])*(n-e[0])}}function Kle(e,a){return e>0&&e<a}var Hle=(e,a=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},t=0;return function i(){const r={left:e.scrollLeft,top:e.scrollTop};(n.left!==r.left||n.top!==r.top)&&a(),n=r,t=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(t)};function Ole(e,a){const n=rle(e),t=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),r.useCallback((()=>{window.clearTimeout(t.current),t.current=window.setTimeout(n,a)}),[n,a])}function Ile(e,a){const n=rle(a);ale((()=>{let a=0;if(e){const t=new ResizeObserver((()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(n)}));return t.observe(e),()=>{window.cancelAnimationFrame(a),t.unobserve(e)}}}),[e,n])}var Gle=hle,Vle=gle,Fle=jle;const Jle=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(Gle,{ref:i,className:GG("relative overflow-hidden",e),...t,children:[n.jsx(Vle,{className:"h-full w-full rounded-[inherit]",children:a}),n.jsx(Ule,{}),n.jsx(Fle,{})]})));Jle.displayName=Gle.displayName;const Ule=r.forwardRef((({className:e,orientation:a="vertical",...t},i)=>n.jsx(fle,{ref:i,orientation:a,className:GG("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),...t,children:n.jsx(Ele,{className:"relative flex-1 rounded-full bg-border"})})));Ule.displayName=fle.displayName;var Wle=r.forwardRef(((e,a)=>{const{children:t,...i}=e,o=r.Children.toArray(t),s=o.find($le);if(s){const e=s.props.children,t=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(qle,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,t):null})}return n.jsx(qle,{...i,ref:a,children:t})}));Wle.displayName="Slot";var qle=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?mO(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));qle.displayName="SlotClone";var Zle=({children:e})=>n.jsx(n.Fragment,{children:e});function $le(e){return r.isValidElement(e)&&e.type===Zle}var Yle=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const t=r.forwardRef(((e,t)=>{const{asChild:i,...r}=e,o=i?Wle:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(o,{...r,ref:t})}));return t.displayName=`Primitive.${a}`,{...e,[a]:t}}),{}),Qle="horizontal",Xle=["horizontal","vertical"],eue=r.forwardRef(((e,a)=>{const{decorative:t,orientation:i=Qle,...r}=e,o=function(e){return Xle.includes(e)}(i)?i:Qle;return n.jsx(Yle.div,{"data-orientation":o,...t?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...r,ref:a})}));eue.displayName="Separator";var aue=eue;const nue=r.forwardRef((({className:e,orientation:a="horizontal",decorative:t=!0,...i},r)=>n.jsx(aue,{ref:r,decorative:t,orientation:a,className:pm("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...i})));function tue({options:e,onValueChange:a,selectedValues:t,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),[v,f]=r.useState(""),[y,k]=r.useState(t),b=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(!v)return b;return[...b.filter((e=>y.includes(e.value))),...b.filter((e=>!y.includes(e.value))).filter((e=>e.label.toLowerCase().includes(v.toLowerCase())))]}),[b,v,y]),A=r.useCallback((()=>t.map((a=>{const n=e.find((e=>e.value===a));return{value:a,label:n?.label||a}}))),[t,e]),w=e=>{if(h)return k([e]),a([e]),i([e]),void g(!1);k((a=>a.includes(e)?a.filter((a=>a!==e)):o&&a.length>=o?a:[...a,e]))};r.useEffect((()=>{p&&(k(t),f(""))}),[p,t]);const C=y.length,M=S.filter((e=>y.includes(e.value))).length,T=A(),N=!o||y.length<o,E=r.useMemo((()=>S.filter((e=>y.includes(e.value)))),[S,y]),x=r.useMemo((()=>S.filter((e=>!y.includes(e.value)))),[S,y]);return n.jsxs(VG,{open:p&&m,onOpenChange:g,children:[n.jsx(FG,{asChild:!0,children:n.jsxs(PY,{variant:"outline",className:"w-full justify-between text-left font-normal h-9 p-3",children:[n.jsx("div",{className:"flex flex-nowrap items-center gap-1 max-w-[70%]",children:0===T.length?n.jsx("span",{className:"text-muted-foreground",children:s}):h?n.jsx(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label}):T.length<=2?T.map((e=>n.jsx(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:e.label},e.value))):n.jsxs(n.Fragment,{children:[n.jsx(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label},T[0].value),n.jsxs(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:["+",T.length-1," more"]})]})}),n.jsx(zY.DropdownMenuTrigger,{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0"})]})}),n.jsxs(WG,{className:"max-w-md w-full max-h-[80vh] p-0",children:[n.jsx(qG,{className:"p-6 pb-4",children:n.jsxs($G,{className:"flex items-center gap-2 text-xl",children:[n.jsx(zY.UsersIcon,{className:"h-5 w-5 text-primary"}),l]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"relative",children:[n.jsx(zY.SearchIcon,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(r4,{placeholder:u,value:v,onChange:e=>f(e.target.value),className:"pl-10 h-11"})]})}),!h&&n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:[C," of ",b.length," selected",o&&` (max ${o})`]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(PY,{variant:"ghost",size:"sm",onClick:()=>{const e=S.filter((e=>!y.includes(e.value))),a=o?e.slice(0,o-y.length):e;k((e=>[...e,...a.map((e=>e.value))]))},disabled:!N||M===S.length,className:"h-8 text-xs",children:"Select All"}),n.jsx(PY,{variant:"ghost",size:"sm",onClick:()=>{const e=new Set(S.map((e=>e.value)));k((a=>a.filter((a=>!e.has(a)))))},disabled:0===M,className:"h-8 text-xs",children:"Clear All"})]})]})}),n.jsx(nue,{}),n.jsx(Jle,{className:"flex-1 max-h-[300px]",children:n.jsx(Ise,{className:"rounded-none border-none",children:n.jsxs(Jse,{children:[d.length>0&&n.jsxs(n.Fragment,{children:[d.map(((e,a)=>n.jsx("div",{className:"px-3 py-2",children:e(g)},`extra-command-${a}`))),n.jsx(nue,{className:"my-2"})]}),0===S.length?n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(zY.SearchIcon,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:c})]}):n.jsxs(n.Fragment,{children:[!h&&E.length>0&&n.jsxs(n.Fragment,{children:[n.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=>n.jsxs(Use,{onSelect:()=>w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors hover:bg-muted/50 cursor-pointer",children:[n.jsx(Woe,{checked:!0,disabled:!1,onChange:()=>w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),n.jsx(zY.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value))),n.jsx(nue,{className:"my-2"})]}),n.jsx("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:h?"Options":`Available (${x.length})`}),x.map((e=>{const a=y.includes(e.value),t=!h&&!N;return n.jsxs(Use,{onSelect:()=>!t&&w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors "+(t?"opacity-50 cursor-not-allowed":"hover:bg-muted/50 cursor-pointer"),children:[!h&&n.jsx(Woe,{checked:a,disabled:t,onChange:()=>!t&&w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),a&&n.jsx(zY.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value)}))]})]})})}),!h&&n.jsxs(n.Fragment,{children:[n.jsx(nue,{}),n.jsx("div",{className:"p-6 pt-4",children:n.jsxs("div",{className:"flex gap-3",children:[n.jsx(PY,{variant:"outline",onClick:()=>{k(t),f(""),g(!1)},className:"flex-1",children:"Cancel"}),n.jsxs(PY,{onClick:()=>{a(y),i(y),g(!1)},className:"flex-1 bg-primary hover:bg-primary/90",children:["Apply (",C,")"]})]})})]})]})]})}nue.displayName=aue.displayName;const iue=r.forwardRef((({className:e,...a},t)=>n.jsx("textarea",{className:pm("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:t,...a})));iue.displayName="Textarea";const rue=e=>{const{companyName:a,smsBody:n}=e;return a&&n?`${a}:\n${n}`:n??""},oue=({body:e,imageUrls:a})=>n.jsx("div",{className:"sms-preview-outer @container",children:n.jsxs("div",{className:"sms-phone-mockup",children:[n.jsx("div",{className:"sms-phone-notch"}),n.jsxs("div",{className:"sms-phone-inner",children:[a&&a.length>0&&a.map(((e,a)=>n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:n.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:e})})]}),n.jsx("div",{className:"sms-phone-home-indicator"})]})}),sue=({mergeFieldsResponse:e})=>{const t=1500,i=AY(),r=wY(),{data:o}=L9(),s=a.useCallback((()=>{const e=i?.actionData?.find((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId===r?.id));return e?.actionMetadata.communicationGroupId}),[i?.actionData,r?.id]),{channelSenders:l}=E9(),{data:u,isLoading:c}=Poe(),{channelAccounts:d}=M9(),{toast:m}=Ie(),{updateCommunicationGroup:h,isUpdating:p}=Ze(),[g,v]=a.useState(null),[f,y]=a.useState(!1),[k,b]=a.useState(null),[S,A]=a.useState(null),[w,C]=a.useState([]),[M,T]=a.useState(null),[N,E]=a.useState(!1),[x,P]=a.useState(!1),j=a.useRef(null),L=a.useRef(null),[B,z]=a.useState(null),[R,_]=a.useState(null),[D,K]=a.useState(!1),H=a.useMemo((()=>mee({channelSenders:l?.results??[],channelAccounts:d?.results??[],smsApplication:o})),[l,d,o]);a.useEffect((()=>{N&&(T(S),w.length>0&&!B&&!D&&z(w[0]))}),[N,S,w,B,D]),a.useEffect((()=>{N||(z(w.length>0?w[0]:null),_(null),K(!1))}),[N,w]);a.useEffect((()=>{r&&(v(r.smsChannelSenderId),A(r.smsMessageBody),r.textMessageCompanyName&&b(r.textMessageCompanyName),r.textMessageMediaUrls&&C(r.textMessageMediaUrls),P(!0))}),[r]);a.useEffect((()=>{void 0!==l&&x&&(g?g&&r?.id&&h({groupId:r.id,params:{smsChannelSenderId:g}}):H?.[0]&&(v(H[0].channelSender.id),r?.id&&h({groupId:r.id,params:{smsChannelSenderId:H[0].channelSender.id}})))}),[l,g,r?.id,h,o,d?.results,r?.emailChannelSenderId,H,x]),a.useEffect((()=>{k||!u?.name||f||(y(!0),b(u.name))}),[k,u?.name,f]);return d&&l&&!c&&void 0!==H&&void 0!==o?0===H?.length&&o?.status!==dee.PENDING?n.jsx(Noe,{}):n.jsxs("div",{children:[n.jsx(VG,{open:N,onOpenChange:E,children:n.jsxs(WG,{hideCloseButton:!0,className:"max-w-[50vw]",children:[n.jsxs(kO,{children:[n.jsx($G,{children:"SMS Editor"}),n.jsx(YG,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),n.jsxs("div",{className:"",children:[B&&n.jsx("div",{className:"flex justify-center mb-6",children:n.jsxs("div",{className:"relative group w-fit",children:[n.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 group-hover:scale-105",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}}),n.jsx(PY,{variant:"ghost",size:"icon",className:"absolute -top-3 -right-3 bg-white/80 hover:bg-red-100 text-gray-500 hover:text-red-500 shadow-md border border-gray-200 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{z(null),_(null),K(!0)},style:{boxShadow:"0 2px 8px 0 rgba(0,0,0,0.10)"},children:n.jsx(bd,{className:"h-4 w-4"})})]})}),n.jsx(iue,{ref:j,className:"min-h-[300px]",placeholder:"Text message content...",value:M??"",onChange:e=>{T(e.target.value)},maxLength:t-(k?.length||0)}),n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(tue,{options:e?.mergeFields?.flatMap((e=>e.entries.map((e=>({label:e.label,value:e.value})))))??[],selectedValues:[],setSelectedValues:()=>{},onValueChange:e=>{if(e.length>0){const a=j.current,n=M||"",t=a?.selectionStart??n.length,i=a?.selectionEnd??n.length,r=n.slice(0,t)+e[0]+n.slice(i);T(r),setTimeout((()=>{const n=t+e[0].length;a?.focus(),a?.setSelectionRange(n,n)}),0)}},placeholder:"Add merge field",title:"Merge Fields",searchPlaceholder:"Search merge fields...",emptyMessage:"No merge fields found",singleSelect:!0}),n.jsx(Mae,{title:"Dynamic content is a way to insert dynamic content into your messages such as the customer's name, email, or other details."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{type:"file",ref:L,onChange:async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await async function(e){if(!Loe)throw new Error("Image conversion is only supported in browser environments");return new Promise(((a,n)=>{try{const t=new window.Image;t.crossOrigin="anonymous",t.onload=()=>{try{const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const i=e.getContext("2d");if(!i)return void n(new Error("Failed to get canvas context"));i.drawImage(t,0,0);const r=e.toDataURL("image/png",1);a(r)}catch(e){n(e)}},t.onerror=()=>{n(new Error("Failed to load image"))},t.src=e}catch(t){n(t)}}))}(e.result),n=function(e){if(!e.startsWith("data:"))throw new Error('Invalid data URL: must start with "data:"');const a=e.split(",");if(2!==a.length)throw new Error("Invalid data URL format: missing base64 data");if(!a[0].includes(";base64"))throw new Error("Invalid data URL format: missing base64 encoding");return a[1]}(a);_(n),z(a),K(!1)}catch(a){m({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsx(PY,{variant:"outline",onClick:()=>{L.current?.click()},className:"px-4",disabled:w.length>=1||D||null!==R,children:"Add Image"}),n.jsx(PY,{variant:"outline",onClick:()=>{T(S),E(!1),z(w.length>0?w[0]:null),_(null),K(!1)},className:"px-4",children:"Cancel"}),n.jsx(PY,{onClick:()=>{if(M&&M.length>t)return void m({title:"SMS is too long",description:"Please shorten your message"});A(M);const e=s();e&&h({groupId:e,params:{smsChannelSenderId:g,smsMessageBody:M,textMessageCompanyName:k,textMessageMedia:R?[R]:D?[]:void 0}},{onSuccess:()=>{E(!1),z(null),_(null),K(!1)},onError:()=>{m({title:"Error updating SMS",description:"Please contact your administrator"})}})},className:"px-4",disabled:p,children:"Save Changes"})]})]}),n.jsxs("div",{className:"flex justify-end mt-2 text-sm transition-colors duration-300 items-center gap-2 "+(M&&M.length>320?M.length>=t?"text-red-500":"text-amber-500":"text-gray-500"),children:[M?M.length:0,"/",t-(k?.length||0)," characters",M&&M.length>320&&n.jsx(Mae,{title:"The best delivery rates are achieved when the message is 320 characters or less.",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"}})]})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Kae,{className:"text-foreground",children:"From Number"}),n.jsxs(hie,{onValueChange:e=>{v(e)},value:g??void 0,children:[n.jsx(vie,{children:n.jsx(gie,{placeholder:"Select number",children:g?(O=g,H?.find((e=>e.channelSender.id===O))?.channelSender.channelSenderMetadata.friendlyName??H?.find((e=>e.channelSender.id===O))?.channelSender.channelSenderMetadata.from??O):"Select number"})}),n.jsx(kie,{children:H?.map((e=>n.jsx(bie,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName??e.channelSender.channelSenderMetadata.from??"Select number"},e.channelSender.id)))})]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx(Kae,{className:"text-foreground",children:"Company Name"}),n.jsx(Mae,{title:"Adding your company name can help customers identify who they are talking to"})]}),n.jsx(r4,{placeholder:"Enter company name",value:k??"",className:"text-muted-foreground",onChange:e=>{b(e.target.value??null)},disabled:!g&&!o})]})]}),n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex justify-between items-center mb-4",children:[n.jsx("h3",{className:"font-medium",children:"Preview"}),n.jsx("div",{children:n.jsx(PY,{onClick:()=>E(!0),className:"text-sm px-3 py-1 rounded ",disabled:0===(H?.length??0)&&void 0===o,children:"Edit"})})]}),n.jsx("div",{children:o?g||o?n.jsx(n.Fragment,{children:S?n.jsx(oue,{body:rue({companyName:k??void 0,smsBody:S}),imageUrls:w}):n.jsx(Sie,{type:"sms"})}):n.jsx(Cie,{type:"sms"}):n.jsx("div",{children:"Submit an application"})})]})]})]}):n.jsx("div",{children:n.jsx(NY,{text:["Loading..."]})});var O},lue=()=>{const e=wY(),{getMergeFields:a,isGetting:t}=$e(e?.id??void 0);return t||!a?n.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:n.jsx(NY,{text:["Fetching Content..."]})}):n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Bie,{title:"SMS Campaign",type:"sms"}),n.jsx(sue,{mergeFieldsResponse:a})]})},uue=e=>e.friendlyName||e.from||e.messageServiceSid||"Unknown Sender";function cue(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}function due(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},mue(i,...a)]}function mue(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function hue(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function pue(...e){return a=>{let n=!1;const t=e.map((e=>{const t=hue(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():hue(e[a],null)}}}}function gue(...e){return r.useCallback(pue(...e),e)}function vue(e){const a=fue(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(kue);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 n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function fue(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?pue(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var yue=Symbol("radix.slottable");function kue(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===yue}var bue=globalThis?.document?r.useLayoutEffect:()=>{},Sue=r[" useId ".trim().toString()]||(()=>{}),Aue=0;function wue(e){const[a,n]=r.useState(Sue());return bue((()=>{n((e=>e??String(Aue++)))}),[e]),e||(a?`radix-${a}`:"")}var Cue=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=vue(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});var Mue=r[" useInsertionEffect ".trim().toString()]||bue;function Tue({prop:e,defaultProp:a,onChange:n=()=>{},caller:t}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[n,t]=r.useState(e),i=r.useRef(n),o=r.useRef(a);return Mue((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==n&&(o.current?.(n),i.current=n)}),[n,i]),[n,t,o]}({defaultProp:a,onChange:n}),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,t])}const c=r.useCallback((a=>{if(l){const n=function(e){return"function"==typeof e}(a)?a(e):a;n!==e&&s.current?.(n)}else o(a)}),[l,e,o,s]);return[u,c]}var Nue=r.createContext(void 0);function Eue(e){const a=r.useContext(Nue);return e||a||"ltr"}var xue="rovingFocusGroup.onEntryFocus",Pue={bubbles:!1,cancelable:!0},jue="RovingFocusGroup",[Lue,Bue,zue]=function(e){const t=e+"CollectionProvider",[i,r]=due(t),[o,s]=i(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return n.jsx(o,{scope:t,itemMap:s,collectionRef:r,children:i})};l.displayName=t;const u=e+"CollectionSlot",c=vue(u),d=a.forwardRef(((e,a)=>{const{scope:t,children:i}=e,r=gue(a,s(u,t).collectionRef);return n.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=vue(m),g=a.forwardRef(((e,t)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=gue(t,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),n.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(n){const t=s(e+"CollectionConsumer",n);return a.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(t.itemMap.values()).sort(((e,n)=>a.indexOf(e.ref.current)-a.indexOf(n.ref.current)))}),[t.collectionRef,t.itemMap])},r]}(jue),[Rue,_ue]=due(jue,[zue]),[Due,Kue]=Rue(jue),Hue=r.forwardRef(((e,a)=>n.jsx(Lue.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Lue.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Oue,{...e,ref:a})})})));Hue.displayName=jue;var Oue=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,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=gue(a,p),v=Eue(s),[f,y]=Tue({prop:l,defaultProp:u??null,onChange:c,caller:jue}),[k,b]=r.useState(!1),S=function(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}(d),A=Bue(t),w=r.useRef(!1),[C,M]=r.useState(0);return r.useEffect((()=>{const e=p.current;if(e)return e.addEventListener(xue,S),()=>e.removeEventListener(xue,S)}),[S]),n.jsx(Due,{scope:t,orientation:i,dir:v,loop:o,currentTabStopId:f,onItemFocus:r.useCallback((e=>y(e)),[y]),onItemShiftTab:r.useCallback((()=>b(!0)),[]),onFocusableItemAdd:r.useCallback((()=>M((e=>e+1))),[]),onFocusableItemRemove:r.useCallback((()=>M((e=>e-1))),[]),children:n.jsx(Cue.div,{tabIndex:k||0===C?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:cue(e.onMouseDown,(()=>{w.current=!0})),onFocus:cue(e.onFocus,(e=>{if(e.target===e.currentTarget&&!w.current&&!k){const a=new CustomEvent(xue,Pue);if(e.currentTarget.dispatchEvent(a),!a.defaultPrevented){const e=A().filter((e=>e.focusable));Fue([e.find((e=>e.active)),e.find((e=>e.id===f)),...e].filter(Boolean).map((e=>e.ref.current)),m)}}w.current=!1})),onBlur:cue(e.onBlur,(()=>b(!1)))})})})),Iue="RovingFocusGroupItem",Gue=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:o=!1,tabStopId:s,children:l,...u}=e,c=wue(),d=s||c,m=Kue(Iue,t),h=m.currentTabStopId===d,p=Bue(t),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:f}=m;return r.useEffect((()=>{if(i)return g(),()=>v()}),[i,g,v]),n.jsx(Lue.ItemSlot,{scope:t,id:d,focusable:i,active:o,children:n.jsx(Cue.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...u,ref:a,onMouseDown:cue(e.onMouseDown,(e=>{i?m.onItemFocus(d):e.preventDefault()})),onFocus:cue(e.onFocus,(()=>m.onItemFocus(d))),onKeyDown:cue(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void m.onItemShiftTab();if(e.target!==e.currentTarget)return;const a=function(e,a,n){const t=function(e,a){return"rtl"!==a?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===a&&["ArrowLeft","ArrowRight"].includes(t)||"horizontal"===a&&["ArrowUp","ArrowDown"].includes(t)?void 0:Vue[t]}(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?(t=r+1,(n=i).map(((e,a)=>n[(t+a)%n.length]))):i.slice(r+1)}setTimeout((()=>Fue(i)))}var n,t})),children:"function"==typeof l?l({isCurrentTabStop:h,hasTabStop:null!=f}):l})})}));Gue.displayName=Iue;var Vue={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fue(e,a=!1){const n=document.activeElement;for(const t of e){if(t===n)return;if(t.focus({preventScroll:a}),document.activeElement!==n)return}}var Jue=Hue,Uue=Gue;var Wue=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=que(t.current);o.current="mounted"===l?e:"none"}),[l]),bue((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=que(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),bue((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=que(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=que(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.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=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=gue(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function que(e){return e?.animationName||"none"}Wue.displayName="Presence";var Zue="Tabs",[$ue,Yue]=due(Zue,[_ue]),Que=_ue(),[Xue,ece]=$ue(Zue),ace=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,onValueChange:r,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:u="automatic",...c}=e,d=Eue(l),[m,h]=Tue({prop:i,onChange:r,defaultProp:o??"",caller:Zue});return n.jsx(Xue,{scope:t,baseId:wue(),value:m,onValueChange:h,orientation:s,dir:d,activationMode:u,children:n.jsx(Cue.div,{dir:d,"data-orientation":s,...c,ref:a})})}));ace.displayName=Zue;var nce="TabsList",tce=r.forwardRef(((e,a)=>{const{__scopeTabs:t,loop:i=!0,...r}=e,o=ece(nce,t),s=Que(t);return n.jsx(Jue,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:i,children:n.jsx(Cue.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:a})})}));tce.displayName=nce;var ice="TabsTrigger",rce=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,disabled:r=!1,...o}=e,s=ece(ice,t),l=Que(t),u=lce(s.baseId,i),c=uce(s.baseId,i),d=i===s.value;return n.jsx(Uue,{asChild:!0,...l,focusable:!r,active:d,children:n.jsx(Cue.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:cue(e.onMouseDown,(e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():s.onValueChange(i)})),onKeyDown:cue(e.onKeyDown,(e=>{[" ","Enter"].includes(e.key)&&s.onValueChange(i)})),onFocus:cue(e.onFocus,(()=>{d||r||!("manual"!==s.activationMode)||s.onValueChange(i)}))})})}));rce.displayName=ice;var oce="TabsContent",sce=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,forceMount:o,children:s,...l}=e,u=ece(oce,t),c=lce(u.baseId,i),d=uce(u.baseId,i),m=i===u.value,h=r.useRef(m);return r.useEffect((()=>{const e=requestAnimationFrame((()=>h.current=!1));return()=>cancelAnimationFrame(e)}),[]),n.jsx(Wue,{present:o||m,children:({present:t})=>n.jsx(Cue.div,{"data-state":m?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!t,id:d,tabIndex:0,...l,ref:a,style:{...e.style,animationDuration:h.current?"0s":void 0},children:t&&s})})}));function lce(e,a){return`${e}-trigger-${a}`}function uce(e,a){return`${e}-content-${a}`}sce.displayName=oce;var cce=tce,dce=rce,mce=sce;const hce=ace,pce=r.forwardRef((({className:e,...a},t)=>n.jsx(cce,{ref:t,className:pm("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a})));pce.displayName=cce.displayName;const gce=r.forwardRef((({className:e,...a},t)=>n.jsx(dce,{ref:t,className:pm("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})));gce.displayName=dce.displayName;const vce=r.forwardRef((({className:e,...a},t)=>n.jsx(mce,{ref:t,className:pm("ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a})));vce.displayName=mce.displayName;const fce=({onOpenChange:e})=>n.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:n.jsx(zY.CloseButton,{className:"w-5 h-5 text-primary group-hover:text-primary-foreground group-active:text-primary-foreground transition-colors duration-200"})}),yce=({selectedChannels:e,setSelectedChannels:a,hasEmailChannelSenders:t,hasSmsChannelSenders:i,automationType:r})=>{const{toast:o}=Ie(),s=[...t?[{label:"Email",value:"email",icon:zY.EmailIcon,checked:e.includes("email")}]:[],...i?[{label:"SMS",value:"sms",icon:zY.SmsIcon,checked:e.includes("sms")}]:[]];return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-xl font-medium text-foreground",children:"Message Types"}),n.jsxs("p",{className:"text-muted-foreground mb-2 text-sm",children:["Select the channels you want to use in this"," ",r===oa.ONE_TIME?Eh("engage:broadcast").toLowerCase():Eh("engage:automation").toLowerCase()]})]}),n.jsx("div",{className:"w-full grid grid-cols-2 gap-3",children:s.map((t=>n.jsxs(Joe,{checked:t.checked,onCheckedChange:()=>{"email"===t.value?e.includes("email")?e.includes("sms")?a(["sms"]):o({title:"Cant Remove Email",description:`At least one channel is required for an ${r===oa.ONE_TIME?Eh("engage:broadcast").toLowerCase():Eh("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===oa.ONE_TIME?Eh("engage:broadcast").toLowerCase():Eh("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:[n.jsx(t.icon,{className:"mb-3",size:20}),n.jsx("span",{className:"font-medium tracking-tight",children:t.label}),n.jsx(Uoe,{className:"absolute top-2 right-2",children:n.jsx(_c,{className:"fill-primary text-primary-foreground"})})]},t.value)))})]})},kce=({getExtraMergeFields:e})=>{const[t,i]=a.useState(null),r=a.useRef(null),{toast:o}=Ie(),s=wY(),{channelSenders:l}=E9(),{channelAccounts:u}=M9(),{updateCommunicationGroup:c}=Ze(),d=AY(),{data:m}=L9(),{setSelectedSubStepType:h}=a.useContext(uY),{getMergeFields:p,isGetting:g}=$e(s?.id??void 0),[v,f]=a.useState(void 0);a.useEffect((()=>{const e=s?.id;e&&t&&(t.includes("email")||null===s?.emailChannelSenderId||c({groupId:e,params:{emailChannelSenderId:null}}),t.includes("sms")||null===s?.smsChannelSenderId||c({groupId:e,params:{smsChannelSenderId:null}}),1===t.length&&("email"===t[0]&&h(Lie.EMAIL),"sms"===t[0]&&h(Lie.SMS)))}),[t,c,s,m,h]),a.useEffect((()=>{const e=s?.id;e||0!==t?.length||i(["email"])}),[d,s,t]);const y=a.useCallback((e=>{const a=[];e.emailChannelSenderId&&a.push("email"),e.smsChannelSenderId&&a.push("sms"),0===a.length&&a.push("email"),i(a)}),[]);a.useEffect((()=>{s&&!t&&y(s)}),[s,y,t]),a.useEffect((()=>{g||void 0===v&&(e?e().then((e=>{s?.id&&(y(s),c({groupId:s?.id,params:{extraMergeFields:e}},{onSuccess:async()=>{try{const e=await Ve(s?.id);f(e)}catch{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}},onError:e=>{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})):f(p))}),[e,c,s,o,g,p,v,y]);const k=a.useMemo((()=>zie({channelSenders:l?.results??[],channelAccounts:u?.results??[]})),[l?.results,u?.results]),b=a.useMemo((()=>mee({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:m})),[l?.results,u?.results,m]);if(!t||g||!v||!k||!b)return n.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:n.jsx(NY,{text:["Fetching Content..."]})});const S=k.length>0,A=b.length>0;return n.jsxs("div",{className:"flex flex-col gap-4 flex-shrink-0",children:[n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(yce,{automationType:d?.triggerMetadata?.triggerType,selectedChannels:t,setSelectedChannels:i,hasEmailChannelSenders:S,hasSmsChannelSenders:A})}),t.includes("email")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:r,children:[n.jsx(Bie,{title:"Email Campaign",type:"email"}),n.jsx(xie,{mergeFieldsResponse:v,emailChannelSendersWithChannelAccounts:k})]}),t.includes("sms")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Bie,{title:"SMS Campaign",type:"sms"}),n.jsx(sue,{mergeFieldsResponse:v})]})]})},bce=({open:e,onOpenChange:a})=>n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"max-w-[75vw] min-h-[75vh] overflow-y-auto max-h-[90vh] po",hideCloseButton:!0,children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Edit Campaign Content"}),n.jsx(YG,{children:"Edit the content of the campaign"})]}),n.jsx(fce,{onOpenChange:a}),n.jsx(kce,{})]})}),Sce=()=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"})]}),Ace=({children:e,actionButtons:a})=>n.jsxs("div",{className:"flex-1 w-full relative overflow-hidden max-w-screen-lg mx-auto",children:[n.jsxs("div",{className:"h-full relative w-full rounded-2xl bg-white border border-zinc-200 overflow-hidden min-h-[500px] flex flex-col",style:{containerType:"inline-size"},children:[n.jsxs("div",{className:"flex items-center space-x-3 pt-3 px-4 z-10 w-full justify-between",children:[n.jsx(Sce,{}),a&&n.jsx("div",{className:"flex items-center space-x-2",children:a})]}),e]}),n.jsx("div",{className:"text-center text-sm text-muted-foreground mt-4",children:n.jsx("p",{children:"These previews show exactly how your messages will appear to your customers"})})]}),wce=()=>{const e=AY(),t=wY(),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),o=a.useMemo((()=>i?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=r?.results?.find((a=>a.id===e.channelAccountId));return a&&a.channelAccountMetadata.type===T9.REACH_MANAGED?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,channelSenderMetadata:e.channelSenderMetadata}]:[]}))||[]),[i?.results,r?.results]),s=t?.emailChannelSenderId;if(!(e&&t&&o&&s))return null;const l=o.find((e=>e.channelSenderId===s)),u=l?.fullDomain,c=l?.channelSenderMetadata.emailReplyTo,d=t.emailSubject,m=t.emailPreviewText,h=l?.channelSenderMetadata.emailFromName;return n.jsxs("div",{className:"space-y-1 overflow-hidden",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsxs("div",{className:"text-base font-medium",children:[u,h&&n.jsxs("span",{className:"text-muted-foreground",children:["<",h,">"]})]})]}),c&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Reply-To"}),n.jsx("div",{className:"text-base font-medium",children:c})]}),d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Subject"}),n.jsx("div",{className:"text-base font-medium",children:d})]}),m&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Preview Text"}),n.jsx("div",{className:"text-sm font-medium line-clamp-2",children:m})]})]})},Cce=({emailBody:e})=>{const[t,i]=a.useState({width:0,height:0}),r=a.useRef(null);return a.useEffect((()=>{const e=()=>{r.current&&requestAnimationFrame((()=>{i({width:r.current?r.current.offsetWidth-75:0,height:r.current?r.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[r]),n.jsxs(Ace,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(wce,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",ref:r,children:n.jsx(Aie,{html:e,height:t.height,width:t.width})})]})},Mce=({expandDialogContent:e})=>{const[t,i]=a.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(VG,{open:t,onOpenChange:i,children:n.jsxs(WG,{hideCloseButton:!0,className:"w-[80vw] h-[80vh] max-h-none bg-transparent border-none max-w-screen-lg ",children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Expanded Preview"}),n.jsx(YG,{children:"Expanded view of communication content"})]}),n.jsxs("div",{className:"h-full flex flex-col overflow-hidden rounded-xl",children:[n.jsx(fce,{onOpenChange:i}),e]})]})}),n.jsx(PY,{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:()=>i(!0),children:n.jsx(zY.ExpandIcon,{className:"w-4 h-4 text-muted-foreground"})})]})},Tce=({type:e,disablePreviewSubtext:a=!1})=>{const t="sms"===e?"SMS":"Email";return n.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center",children:n.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:[n.jsx("sms"===e?zY.SmsIcon:zY.EmailIcon,{className:"w-12 h-12 text-zinc-500 mb-4"}),n.jsxs("h2",{className:"text-xl font-semibold text-zinc-800 mb-2",children:["No ",t," Content Yet"]}),!a&&n.jsxs("p",{className:"text-zinc-500 text-base mb-1",children:["Click"," ",n.jsx("span",{className:"font-medium text-zinc-700",children:"Edit content"})," to start crafting your ",t," message."]})]})})},Nce=a.forwardRef((({onClick:e},a)=>n.jsxs(PY,{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:[n.jsx(zY.PreviewButton,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium text-sm",children:"Test"})]})));Nce.displayName="PreviewButton";const Ece=e=>/^[^\s@.]+(?:\.[^\s@.]+)*@[^\s@.]+(?:\.[^\s@.]+)+$/.test(e),xce=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"))},Pce=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 n=e.startsWith("+")?"+":"",t=a.slice((e.startsWith("+"),0));return`${n}${t.match(/.{1,4}/g)?.join("-")||t}`}return e},jce=({automation:e,type:t,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(""),[v,f]=a.useState(!1),{sendTestCommunication:y,sendError:k,isSendSuccess:b}=Ye(),{toast:S}=Ie(),A=e.actionData?.find((e=>"send_communication"===e.actionType)),w=A?.actionMetadata.communicationGroupId,{communicationGroup:C,isGetting:M}=qe(w??void 0),{data:T}=gY({includeSegments:e.includeSegmentIds,excludeSegments:e.excludeSegmentIds,automationId:e.id}),N=a.useRef(null),E=a.useMemo((()=>[...T?.recipients??[]].filter((e=>!(!e.firstName||!e.lastName)&&(!("email"===t&&!e.email)&&!("sms"===t&&!e.phone))))),[T?.recipients,t]),x=a.useCallback((()=>{if(!w)return Promise.resolve(null);if(!C)return Promise.reject(new Error("Communication group not loaded"));switch(t){case"email":return Promise.resolve(C.emailChannelSenderId);case"sms":return Promise.resolve(C.smsChannelSenderId);default:return Promise.reject(new Error(`Unsupported type: ${t}`))}}),[C,t,w]);a.useEffect((()=>{(async()=>{try{const e=await x();d(e)}catch(e){d(null)}finally{h(!0)}})()}),[x]),a.useEffect((()=>{b&&(S({title:"Success",description:`Preview ${"email"===t?"email":"SMS"} sent successfully!`}),i(!1))}),[b,t,i,S]),a.useEffect((()=>{k&&(S({title:"Error",description:`Failed to send preview: ${k.message}`,variant:"destructive"}),i(!1))}),[k,S,i]),a.useEffect((()=>{r&&(s(""),u(""),g(""),f(!1))}),[r]),a.useEffect((()=>{!r&&v&&setTimeout((()=>{document.body.style.pointerEvents=""}),0)}),[r,v]);return m&&!M&&T?c?n.jsxs("div",{className:"",ref:N,children:[n.jsxs("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:["Send Test ","email"===t?"Email":"Text"]}),n.jsx(r4,{type:"email"===t?"email":"tel",placeholder:"email"===t?"Enter email address":"Enter phone number",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"}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Enter a valid ","email"===t?"email address":"phone number"," to send a test to that recipient."]}),n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(hie,{value:p,onValueChange:e=>{g(e)},onOpenChange:e=>{f(e),!e&&N.current&&N.current.focus()},children:[n.jsx(vie,{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:n.jsx(gie,{children:p?T?.recipients.find((e=>e.id===p))?.firstName+" "+T?.recipients.find((e=>e.id===p))?.lastName:"Preview as"})}),n.jsx(kie,{position:"popper",className:"z-[100]",children:n.jsx(pie,{children:E.map((e=>n.jsx(bie,{value:e.id,className:"cursor-pointer hover:bg-gray-50",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("span",{className:"font-medium",children:[e.firstName," ",e.lastName]}),n.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&&n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>g(""),className:"h-10 w-10 rounded-lg hover:bg-gray-100",title:"Clear selection",children:n.jsx(zY.CloseButton,{className:"h-4 w-4 text-gray-500"})})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1.5",children:"Optional: Test as a specific recipient to see how the message will appear with their data. If not selected, raw merge tags will be used."})]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsx("p",{className:"text-red-500 text-sm mb-4 -mt-2",children:l})]}),n.jsx(PY,{onClick:()=>{if(!("email"===t?Ece(o):xce(o)))return void u("Please enter a valid "+("email"===t?"email address":"phone number"));if(!c)return void u("No sender found, please update the automation first!");const a=e.actionData?.find((e=>"send_communication"===e.actionType)),n=a?.actionMetadata.communicationGroupId;if(!n)return Promise.resolve(null);y({id:n,params:"email"===t?{emailAddress:o,previewAsRecipientId:p}:{phoneNumber:o,previewAsRecipientId:p}})},disabled:!o,className:"w-full disabled:cursor-not-allowed",children:"Send Test"})]}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsxs("div",{className:"text-center flex flex-col justify-center items-center gap-2",children:[n.jsx(zY.AlertCircleIcon,{className:"h-12 w-12 text-gray-400 mb-4"}),n.jsx("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"No sender found"}),n.jsx("p",{className:"text-gray-500",children:"Please update the automation to include a sender for this type"})]})}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsx(NY,{text:["Fetching sender data","Fetching recipients"]})})},Lce=({open:e,onOpenChange:a,automation:t})=>n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Send Preview Email"}),n.jsx(YG,{children:"Send a preview email to the automation."})]}),n.jsx(jce,{automation:t,type:"email",setOpenSendPreviewPopup:a,open:e})]})}),Bce=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const r=AY(),o=wY(),{channelSenders:s}=E9(),{channelAccounts:l}=M9(),[u,c]=a.useState({width:0,height:0}),[d,m]=a.useState(!1),[h,p]=a.useState(!1),g=a.useRef(null);if(a.useEffect((()=>{const e=()=>{g.current&&requestAnimationFrame((()=>{c({width:g.current?g.current.offsetWidth-75:0,height:g.current?g.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[g]),!r||!o||void 0===s||void 0===l)return null;const v=o?.emailHtmlBody||"",f=o?.emailChannelSenderId&&v.length>0,y=zie({channelSenders:s?.results??[],channelAccounts:l?.results??[]});let k=null;return o?.emailChannelSenderId||(k="Please first select an email sender"),o?.emailSubject||(k="Please first ensure you have an email subject"),o?.emailHtmlBody||(k="Please first ensure you have an email content"),n.jsxs("div",{className:"flex-1 flex flex-col items-center w-full",children:[n.jsx(bce,{open:h,onOpenChange:p}),y.length>0&&n.jsx(Lce,{open:d,onOpenChange:m,automation:r}),n.jsx(Ace,{actionButtons:n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex items-center space-x-2",children:[!e&&f&&(k?n.jsx(Mae,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:n.jsx(Nce,{onClick:()=>m(!0)})}):n.jsx(Nce,{onClick:()=>m(!0)})),!t&&r.status===ca.DRAFT&&n.jsx(PY,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>p(!0),children:"Edit content"}),f&&n.jsx(Mce,{expandDialogContent:n.jsx(Cce,{emailBody:v})})]})}),children:f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(wce,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full min-h-[500px]",ref:g,children:n.jsx(Aie,{html:v,height:u.height,width:u.width})})]}):n.jsx(Tce,{type:"email",disablePreviewSubtext:i})})]})},zce=()=>{const e=AY(),t=wY(),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),{data:o}=L9(),s=a.useMemo((()=>mee({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o})),[i?.results,r?.results,o]),l=s?.find((e=>e.channelSender.id===t?.smsChannelSenderId));if(!l&&!o)return null;if(!(e&&t&&i&&r&&s&&(void 0!==o||l)))return null;const u=l?.channelSender.channelSenderMetadata.from&&null!==l.channelSender.channelSenderMetadata.from?l.channelSender.channelSenderMetadata.from:null,c=l?.channelSender.channelSenderMetadata.friendlyName??(u&&null!==u?Pce(u??""):l?.channelSender.channelSenderMetadata.messageServiceSid);return n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsx("div",{className:"text-base font-medium font-mono text-zinc-800",children:c})]})})},Rce=({smsBody:e,imageUrls:a})=>n.jsxs(Ace,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(zce,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",children:n.jsx(oue,{body:e,imageUrls:a})})]}),_ce=({open:e,onOpenChange:a,automation:t})=>n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Send Preview SMS"}),n.jsx(YG,{children:"Send a preview SMS to the automation."})]}),n.jsx(jce,{automation:t,type:"sms",setOpenSendPreviewPopup:a,open:e})]})}),Dce=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,setupRequired:r=!1})=>{const[o,s]=a.useState(!1),{channelSenders:l}=E9(),{channelAccounts:u}=M9(),c=AY(),d=wY(),[m,h]=a.useState(!1),{data:p}=L9(),[g,v]=a.useState(r),f=mee({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:p}),y=f.find((e=>e.channelSender.id===d?.smsChannelSenderId));if(a.useEffect((()=>{y&&y.smsApplication&&y.smsApplication.status===dee.PENDING&&v(!1)}),[d?.smsChannelSenderId,p,f,y]),!c||void 0===l)return null;const k=d?.smsMessageBody||"",b=!y?.smsApplication||y.smsApplication.status===dee.APPROVED,S=(p||d?.smsChannelSenderId)&&k.length>0,A=rue({companyName:d?.textMessageCompanyName??void 0,smsBody:k}),w=d?.textMessageMediaUrls??[];let C=null;return d?.smsChannelSenderId||(C="Please first select a sms sender"),d?.smsMessageBody||(C="Please first ensure you have a sms content"),n.jsx(dV,{children:g?n.jsx("div",{className:"w-full pt-8 mx-auto",children:n.jsx(Noe,{})}):n.jsxs(Z$.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 flex-col items-center w-full h-full",children:[n.jsx(bce,{open:m,onOpenChange:h}),n.jsx(_ce,{open:o,onOpenChange:s,automation:c}),n.jsx(Ace,{actionButtons:n.jsxs(n.Fragment,{children:[!e&&b&&(C?n.jsx(Mae,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!1,children:n.jsx("div",{className:"inline-block",children:n.jsx(Nce,{onClick:()=>s(!0)})})}):n.jsx(Nce,{onClick:()=>s(!0)})),c.status===ca.DRAFT&&!t&&n.jsx(PY,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>h(!0),children:"Edit content"}),S&&n.jsx(Mce,{expandDialogContent:n.jsx(Rce,{smsBody:A,imageUrls:w})})]}),children:S?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(zce,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full flex items-center justify-center",children:n.jsx(oue,{body:A,imageUrls:w})})]}):n.jsx(Tce,{type:"sms",disablePreviewSubtext:i})})]})})},Kce=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const[r,o]=a.useState(null),s=wY(),{channelAccounts:l}=M9(),{state:{hideSms:u}}=a.useContext(bO),{channelSenders:c}=E9(),{data:d}=L9(),m=a.useMemo((()=>mee({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 n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(NY,{text:["Loading..."]})});const h=!s?.smsChannelSenderId||u,p=!s?.emailChannelSenderId,g=0===m.length&&!d;return n.jsxs(hce,{defaultValue:"email",value:r,onValueChange:e=>o("email"===e?"email":"sms"),className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md pb-4",children:[n.jsx("div",{className:"max-w-[640px] mx-auto w-full",children:n.jsxs(pce,{className:"grid w-full "+(h||p?"grid-cols-1":"grid-cols-2"),children:[!p&&n.jsx(gce,{value:"email",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx(zY.EmailIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(zY.EmailIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"Email"})]})}),!h&&n.jsx(gce,{value:"sms",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(zY.SmsIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(zY.SmsIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"SMS"}),g&&n.jsx(Mae,{title:"To enable SMS, please complete your business information and request approval from Twilio"})]})})]})}),n.jsx(vce,{value:"email",children:n.jsx(Bce,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i})}),n.jsx(vce,{value:"sms",children:n.jsx(Dce,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i,setupRequired:g})})]})},Hce="reach-styles-module__h2___J-48W",Oce="reach-styles-module__h3___QiFj-",Ice="reach-styles-module__minorText___1TEN6",Gce=({children:e,className:a})=>n.jsx("h2",{className:pm(Hce,a),children:e}),Vce=({children:e,className:a})=>n.jsx("h3",{className:pm(Oce,a),children:e}),Fce=({children:e,className:a})=>n.jsx("p",{className:pm(Ice,a),children:e}),Jce=({title:e,children:a,headerActions:t})=>n.jsxs("div",{className:"max-w-[1000px] mx-auto w-full flex-1 flex flex-col gap-4 pt-4",children:[n.jsxs("div",{className:"px-4 flex",children:[n.jsx(Gce,{className:"text-primary",children:e}),t&&n.jsx("div",{className:"ml-auto",children:t})]}),a]}),Uce=()=>n.jsx(Jce,{title:"Preview & Schedule",children:n.jsx(Kce,{disablePreview:!0,disableEditContent:!0,disablePreviewSubtext:!0})}),Wce=()=>{const e=AY(),t=wY(),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),{data:o}=L9(),[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(t&&d&&h){const e=t.emailChannelSenderId,a=t.smsChannelSenderId,n=d.results.find((a=>a.id===e)),i=d.results.find((e=>e.id===a));if(n&&t.emailSubject&&t.emailHtmlBody){const e=n.channelSenderMetadata?.userPart,a=h.results.find((e=>e.id===n.channelAccountId));if(a)switch(a.channelAccountMetadata.type){case T9.REACH_MANAGED:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:n.channelSenderMetadata?.emailFromName,subject:t.emailSubject,previewText:t.emailPreviewText,body:t.emailHtmlBody});break;case T9.TWILLIO:break;default:throw g9(a.channelAccountMetadata.type,T9)}}(o||i)&&t.smsMessageBody&&c({fromPhone:i?uue(i.channelSenderMetadata):"",body:t.smsMessageBody,companyName:t.textMessageCompanyName})}}),[t,d,h,o]),e?n.jsx("div",s||u?{className:"w-full",children:n.jsx("div",{className:"flex flex-col gap-4 w-full",children:n.jsx(Uce,{})})}:{className:"flex justify-center items-center h-full",children:n.jsx("div",{children:"No preview data Please complete previous steps"})}):n.jsx(NY,{text:["Loading..."]})};function qce(e){return(qce="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 Zce(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 $ce(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function Yce(e){$ce(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||"object"===qce(e)&&"[object Date]"===a?new Date(e.getTime()):"number"==typeof e||"[object Number]"===a?new Date(e):new Date(NaN)}function Qce(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a);return isNaN(t)?new Date(NaN):t?(n.setDate(n.getDate()+t),n):n}function Xce(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a);if(isNaN(t))return new Date(NaN);if(!t)return n;var i=n.getDate(),r=new Date(n.getTime());return r.setMonth(n.getMonth()+t+1,0),i>=r.getDate()?r:(n.setFullYear(r.getFullYear(),r.getMonth(),i),n)}var ede={};function ade(){return ede}function nde(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Yce(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 tde(e){return $ce(1,arguments),nde(e,{weekStartsOn:1})}function ide(e){$ce(1,arguments);var a=function(e){$ce(1,arguments);var a=Yce(e),n=a.getFullYear(),t=new Date(0);t.setFullYear(n+1,0,4),t.setHours(0,0,0,0);var i=tde(t),r=new Date(0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);var o=tde(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}(e),n=new Date(0);return n.setFullYear(a,0,4),n.setHours(0,0,0,0),tde(n)}function rde(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 ode(e){$ce(1,arguments);var a=Yce(e);return a.setHours(0,0,0,0),a}function sde(e,a){$ce(2,arguments);var n=ode(e),t=ode(a),i=n.getTime()-rde(n),r=t.getTime()-rde(t);return Math.round((i-r)/864e5)}function lde(e,a){return $ce(2,arguments),Qce(e,7*Zce(a))}function ude(e,a){return $ce(2,arguments),Xce(e,12*Zce(a))}function cde(e,a){$ce(2,arguments);var n=ode(e),t=ode(a);return n.getTime()===t.getTime()}function dde(e){return $ce(1,arguments),e instanceof Date||"object"===qce(e)&&"[object Date]"===Object.prototype.toString.call(e)}function mde(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return 12*(n.getFullYear()-t.getFullYear())+(n.getMonth()-t.getMonth())}function hde(e){$ce(1,arguments);var a=Yce(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(23,59,59,999),a}function pde(e){$ce(1,arguments);var a=Yce(e);return a.setDate(1),a.setHours(0,0,0,0),a}function gde(e){$ce(1,arguments);var a=Yce(e),n=new Date(0);return n.setFullYear(a.getFullYear(),0,1),n.setHours(0,0,0,0),n}function vde(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Yce(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 fde(e){return $ce(1,arguments),vde(e,{weekStartsOn:1})}function yde(e,a){return $ce(2,arguments),function(e,a){$ce(2,arguments);var n=Yce(e).getTime(),t=Zce(a);return new Date(n+t)}(e,-Zce(a))}function kde(e){$ce(1,arguments);var a=Yce(e),n=a.getUTCDay(),t=(n<1?7:0)+n-1;return a.setUTCDate(a.getUTCDate()-t),a.setUTCHours(0,0,0,0),a}function bde(e){$ce(1,arguments);var a=Yce(e),n=a.getUTCFullYear(),t=new Date(0);t.setUTCFullYear(n+1,0,4),t.setUTCHours(0,0,0,0);var i=kde(t),r=new Date(0);r.setUTCFullYear(n,0,4),r.setUTCHours(0,0,0,0);var o=kde(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}function Sde(e){$ce(1,arguments);var a=Yce(e),n=kde(a).getTime()-function(e){$ce(1,arguments);var a=bde(e),n=new Date(0);return n.setUTCFullYear(a,0,4),n.setUTCHours(0,0,0,0),kde(n)}(a).getTime();return Math.round(n/6048e5)+1}function Ade(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Yce(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 wde(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=Yce(e),d=c.getUTCFullYear(),m=ade(),h=Zce(null!==(n=null!==(t=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!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n: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=Ade(p,a),v=new Date(0);v.setUTCFullYear(d,0,h),v.setUTCHours(0,0,0,0);var f=Ade(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}function Cde(e,a){$ce(1,arguments);var n=Yce(e),t=Ade(n,a).getTime()-function(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=wde(e,a),h=new Date(0);return h.setUTCFullYear(m,0,d),h.setUTCHours(0,0,0,0),Ade(h,a)}(n,a).getTime();return Math.round(t/6048e5)+1}function Mde(e,a){for(var n=e<0?"-":"",t=Math.abs(e).toString();t.length<a;)t="0"+t;return n+t}var Tde=function(e,a){var n=e.getUTCFullYear(),t=n>0?n:1-n;return Mde("yy"===a?t%100:t,a.length)},Nde=function(e,a){var n=e.getUTCMonth();return"M"===a?String(n+1):Mde(n+1,2)},Ede=function(e,a){return Mde(e.getUTCDate(),a.length)},xde=function(e,a){return Mde(e.getUTCHours()%12||12,a.length)},Pde=function(e,a){return Mde(e.getUTCHours(),a.length)},jde=function(e,a){return Mde(e.getUTCMinutes(),a.length)},Lde=function(e,a){return Mde(e.getUTCSeconds(),a.length)},Bde=function(e,a){var n=a.length,t=e.getUTCMilliseconds();return Mde(Math.floor(t*Math.pow(10,n-3)),a.length)},zde="midnight",Rde="noon",_de="morning",Dde="afternoon",Kde="evening",Hde="night",Ode={G:function(e,a,n){var t=e.getUTCFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return n.era(t,{width:"abbreviated"});case"GGGGG":return n.era(t,{width:"narrow"});default:return n.era(t,{width:"wide"})}},y:function(e,a,n){if("yo"===a){var t=e.getUTCFullYear();return n.ordinalNumber(t>0?t:1-t,{unit:"year"})}return Tde(e,a)},Y:function(e,a,n,t){var i=wde(e,t),r=i>0?i:1-i;return"YY"===a?Mde(r%100,2):"Yo"===a?n.ordinalNumber(r,{unit:"year"}):Mde(r,a.length)},R:function(e,a){return Mde(bde(e),a.length)},u:function(e,a){return Mde(e.getUTCFullYear(),a.length)},Q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"Q":return String(t);case"QQ":return Mde(t,2);case"Qo":return n.ordinalNumber(t,{unit:"quarter"});case"QQQ":return n.quarter(t,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(t,{width:"narrow",context:"formatting"});default:return n.quarter(t,{width:"wide",context:"formatting"})}},q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"q":return String(t);case"qq":return Mde(t,2);case"qo":return n.ordinalNumber(t,{unit:"quarter"});case"qqq":return n.quarter(t,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(t,{width:"narrow",context:"standalone"});default:return n.quarter(t,{width:"wide",context:"standalone"})}},M:function(e,a,n){var t=e.getUTCMonth();switch(a){case"M":case"MM":return Nde(e,a);case"Mo":return n.ordinalNumber(t+1,{unit:"month"});case"MMM":return n.month(t,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(t,{width:"narrow",context:"formatting"});default:return n.month(t,{width:"wide",context:"formatting"})}},L:function(e,a,n){var t=e.getUTCMonth();switch(a){case"L":return String(t+1);case"LL":return Mde(t+1,2);case"Lo":return n.ordinalNumber(t+1,{unit:"month"});case"LLL":return n.month(t,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(t,{width:"narrow",context:"standalone"});default:return n.month(t,{width:"wide",context:"standalone"})}},w:function(e,a,n,t){var i=Cde(e,t);return"wo"===a?n.ordinalNumber(i,{unit:"week"}):Mde(i,a.length)},I:function(e,a,n){var t=Sde(e);return"Io"===a?n.ordinalNumber(t,{unit:"week"}):Mde(t,a.length)},d:function(e,a,n){return"do"===a?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):Ede(e,a)},D:function(e,a,n){var t=function(e){$ce(1,arguments);var a=Yce(e),n=a.getTime();a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0);var t=a.getTime();return Math.floor((n-t)/864e5)+1}(e);return"Do"===a?n.ordinalNumber(t,{unit:"dayOfYear"}):Mde(t,a.length)},E:function(e,a,n){var t=e.getUTCDay();switch(a){case"E":case"EE":case"EEE":return n.day(t,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(t,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},e:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"e":return String(r);case"ee":return Mde(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"c":return String(r);case"cc":return Mde(r,a.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,a,n){var t=e.getUTCDay(),i=0===t?7:t;switch(a){case"i":return String(i);case"ii":return Mde(i,a.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(t,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(t,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},a:function(e,a,n){var t=e.getUTCHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},b:function(e,a,n){var t,i=e.getUTCHours();switch(t=12===i?Rde:0===i?zde:i/12>=1?"pm":"am",a){case"b":case"bb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},B:function(e,a,n){var t,i=e.getUTCHours();switch(t=i>=17?Kde:i>=12?Dde:i>=4?_de:Hde,a){case"B":case"BB":case"BBB":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},h:function(e,a,n){if("ho"===a){var t=e.getUTCHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return xde(e,a)},H:function(e,a,n){return"Ho"===a?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):Pde(e,a)},K:function(e,a,n){var t=e.getUTCHours()%12;return"Ko"===a?n.ordinalNumber(t,{unit:"hour"}):Mde(t,a.length)},k:function(e,a,n){var t=e.getUTCHours();return 0===t&&(t=24),"ko"===a?n.ordinalNumber(t,{unit:"hour"}):Mde(t,a.length)},m:function(e,a,n){return"mo"===a?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):jde(e,a)},s:function(e,a,n){return"so"===a?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):Lde(e,a)},S:function(e,a){return Bde(e,a)},X:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(a){case"X":return Gde(i);case"XXXX":case"XX":return Vde(i);default:return Vde(i,":")}},x:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"x":return Gde(i);case"xxxx":case"xx":return Vde(i);default:return Vde(i,":")}},O:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ide(i,":");default:return"GMT"+Vde(i,":")}},z:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ide(i,":");default:return"GMT"+Vde(i,":")}},t:function(e,a,n,t){return Mde(Math.floor((t._originalDate||e).getTime()/1e3),a.length)},T:function(e,a,n,t){return Mde((t._originalDate||e).getTime(),a.length)}};function Ide(e,a){var n=e>0?"-":"+",t=Math.abs(e),i=Math.floor(t/60),r=t%60;if(0===r)return n+String(i);var o=a;return n+String(i)+o+Mde(r,2)}function Gde(e,a){return e%60==0?(e>0?"-":"+")+Mde(Math.abs(e)/60,2):Vde(e,a)}function Vde(e,a){var n=a||"",t=e>0?"-":"+",i=Math.abs(e);return t+Mde(Math.floor(i/60),2)+n+Mde(i%60,2)}var Fde=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"})}},Jde=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"})}},Ude={p:Jde,P:function(e,a){var n,t=e.match(/(P+)(p+)?/)||[],i=t[1],r=t[2];if(!r)return Fde(e,a);switch(i){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",Fde(i,a)).replace("{{time}}",Jde(r,a))}},Wde=["D","DD"],qde=["YY","YYYY"];function Zde(e,a,n){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(a,"`) for formatting years to the input `").concat(n,"`; 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(n,"`; 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(n,"`; 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(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var $de={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 Yde(e){return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=a.width?String(a.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var Qde={date:Yde({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Yde({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:Yde({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Xde={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function eme(e){return function(a,n){var t;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,r=null!=n&&n.width?String(n.width):i;t=e.formattingValues[r]||e.formattingValues[i]}else{var o=e.defaultWidth,s=null!=n&&n.width?String(n.width):e.defaultWidth;t=e.values[s]||e.values[o]}return t[e.argumentCallback?e.argumentCallback(a):a]}}var ame={ordinalNumber:function(e,a){var n=Number(e),t=n%100;if(t>20||t<10)switch(t%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:eme({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:eme({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:eme({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:eme({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:eme({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 nme(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.width,i=a.match(t&&e.matchPatterns[t]||e.matchPatterns[e.defaultMatchWidth]);if(!i)return null;var r,o=i[0],s=t&&e.parsePatterns[t]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,a){for(var n=0;n<e.length;n++)if(a(e[n]))return n;return}(s,(function(e){return e.test(o)})):function(e,a){for(var n in e)if(e.hasOwnProperty(n)&&a(e[n]))return n;return}(s,(function(e){return e.test(o)}));return r=e.valueCallback?e.valueCallback(l):l,{value:r=n.valueCallback?n.valueCallback(r):r,rest:a.slice(o.length)}}}var tme={ordinalNumber:function(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=a.match(e.matchPattern);if(!t)return null;var i=t[0],r=a.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];return{value:o=n.valueCallback?n.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:nme({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:nme({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:nme({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:nme({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:nme({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"})},ime={code:"en-US",formatDistance:function(e,a,n){var t,i=$de[e];return t="string"==typeof i?i:1===a?i.one:i.other.replace("{{count}}",a.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+t:t+" ago":t},formatLong:Qde,formatRelative:function(e,a,n,t){return Xde[e]},localize:ame,match:tme,options:{weekStartsOn:0,firstWeekContainsDate:1}},rme=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ome=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,sme=/^'([^]*?)'?$/,lme=/''/g,ume=/[a-zA-Z]/;function cme(e,a,n){var t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b;$ce(2,arguments);var S=String(a),A=ade(),w=null!==(t=null!==(i=null==n?void 0:n.locale)&&void 0!==i?i:A.locale)&&void 0!==t?t:ime,C=Zce(null!==(r=null!==(o=null!==(s=null!==(l=null==n?void 0:n.firstWeekContainsDate)&&void 0!==l?l:null==n||null===(u=n.locale)||void 0===u||null===(c=u.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==s?s:A.firstWeekContainsDate)&&void 0!==o?o:null===(d=A.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=Zce(null!==(h=null!==(p=null!==(g=null!==(v=null==n?void 0:n.weekStartsOn)&&void 0!==v?v:null==n||null===(f=n.locale)||void 0===f||null===(y=f.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==g?g:A.weekStartsOn)&&void 0!==p?p:null===(k=A.locale)||void 0===k||null===(b=k.options)||void 0===b?void 0:b.weekStartsOn)&&void 0!==h?h:0);if(!(M>=0&&M<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!w.localize)throw new RangeError("locale must contain localize property");if(!w.formatLong)throw new RangeError("locale must contain formatLong property");var T=Yce(e);if(!function(e){if($ce(1,arguments),!dde(e)&&"number"!=typeof e)return!1;var a=Yce(e);return!isNaN(Number(a))}(T))throw new RangeError("Invalid time value");var N=yde(T,rde(T)),E={firstWeekContainsDate:C,weekStartsOn:M,locale:w,_originalDate:T};return S.match(ome).map((function(e){var a=e[0];return"p"===a||"P"===a?(0,Ude[a])(e,w.formatLong):e})).join("").match(rme).map((function(t){if("''"===t)return"'";var i=t[0];if("'"===i)return function(e){var a=e.match(sme);if(!a)return e;return a[1].replace(lme,"'")}(t);var r=Ode[i];if(r)return null!=n&&n.useAdditionalWeekYearTokens||-1===qde.indexOf(t)||Zde(t,a,String(e)),null!=n&&n.useAdditionalDayOfYearTokens||!function(e){return-1!==Wde.indexOf(e)}(t)||Zde(t,a,String(e)),r(N,t,w.localize,E);if(i.match(ume))throw new RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return t})).join("")}function dme(e){return $ce(1,arguments),Math.floor(function(e){return $ce(1,arguments),Yce(e).getTime()}(e)/1e3)}function mme(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=function(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=Yce(e),d=c.getFullYear(),m=ade(),h=Zce(null!==(n=null!==(t=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!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n: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=nde(p,a),v=new Date(0);v.setFullYear(d,0,h),v.setHours(0,0,0,0);var f=nde(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}(e,a),h=new Date(0);return h.setFullYear(m,0,d),h.setHours(0,0,0,0),nde(h,a)}function hme(e,a){return $ce(1,arguments),function(e,a,n){$ce(2,arguments);var t=nde(e,n),i=nde(a,n),r=t.getTime()-rde(t),o=i.getTime()-rde(i);return Math.round((r-o)/6048e5)}(function(e){$ce(1,arguments);var a=Yce(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(0,0,0,0),a}(e),pde(e),a)+1}function pme(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getTime()>t.getTime()}function gme(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getTime()<t.getTime()}function vme(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function fme(e,a){return $ce(2,arguments),Qce(e,-Zce(a))}function yme(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a),i=n.getFullYear(),r=n.getDate(),o=new Date(0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);var s=function(e){$ce(1,arguments);var a=Yce(e),n=a.getFullYear(),t=a.getMonth(),i=new Date(0);return i.setFullYear(n,t+1,0),i.setHours(0,0,0,0),i.getDate()}(o);return n.setMonth(t,Math.min(r,s)),n}function kme(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a);return isNaN(n.getTime())?new Date(NaN):(n.setFullYear(t),n)}var bme=function(){return bme=Object.assign||function(e){for(var a,n=1,t=arguments.length;n<t;n++)for(var i in a=arguments[n])Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i]);return e},bme.apply(this,arguments)};function Sme(e,a,n){for(var t,i=0,r=a.length;i<r;i++)!t&&i in a||(t||(t=Array.prototype.slice.call(a,0,i)),t[i]=a[i]);return e.concat(t||Array.prototype.slice.call(a))}function Ame(e){return"multiple"===e.mode}function wme(e){return"range"===e.mode}function Cme(e){return"single"===e.mode}"function"==typeof SuppressedError&&SuppressedError;var Mme={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 Tme=Object.freeze({__proto__:null,formatCaption:function(e,a){return cme(e,"LLLL y",a)},formatDay:function(e,a){return cme(e,"d",a)},formatMonthCaption:function(e,a){return cme(e,"LLLL",a)},formatWeekNumber:function(e){return"".concat(e)},formatWeekdayName:function(e,a){return cme(e,"cccccc",a)},formatYearCaption:function(e,a){return cme(e,"yyyy",a)}}),Nme=Object.freeze({__proto__:null,labelDay:function(e,a,n){return cme(e,"do MMMM (EEEE)",n)},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 cme(e,"cccc",a)},labelYearDropdown:function(){return"Year: "}});var Eme=a.createContext(void 0);function xme(e){var a,t,i=e.initialProps,r={captionLayout:"buttons",classNames:Mme,formatters:Tme,labels:Nme,locale:ime,modifiersClassNames:{},modifiers:{},numberOfMonths:1,styles:{},today:new Date,mode:"default"},o=function(e){var a=e.fromYear,n=e.toYear,t=e.fromMonth,i=e.toMonth,r=e.fromDate,o=e.toDate;return t?r=pde(t):a&&(r=new Date(a,0,1)),i?o=hde(i):n&&(o=new Date(n,11,31)),{fromDate:r?ode(r):void 0,toDate:o?ode(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"),(Cme(i)||Ame(i)||wme(i))&&(t=i.onSelect);var c=bme(bme(bme({},r),i),{captionLayout:u,classNames:bme(bme({},r.classNames),i.classNames),components:bme({},i.components),formatters:bme(bme({},r.formatters),i.formatters),fromDate:s,labels:bme(bme({},r.labels),i.labels),mode:i.mode||r.mode,modifiers:bme(bme({},r.modifiers),i.modifiers),modifiersClassNames:bme(bme({},r.modifiersClassNames),i.modifiersClassNames),onSelect:t,styles:bme(bme({},r.styles),i.styles),toDate:l});return n.jsx(Eme.Provider,{value:c,children:e.children})}function Pme(){var e=a.useContext(Eme);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function jme(e){var a=Pme();return n.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 Lme(e){return n.jsx("svg",bme({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:n.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 Bme(e){var a,t,i=e.onChange,r=e.value,o=e.children,s=e.caption,l=e.className,u=e.style,c=Pme(),d=null!==(t=null===(a=c.components)||void 0===a?void 0:a.IconDropdown)&&void 0!==t?t:Lme;return n.jsxs("div",{className:l,style:u,children:[n.jsx("span",{className:c.classNames.vhidden,children:e["aria-label"]}),n.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:r,onChange:i,children:o}),n.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[s,n.jsx(d,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function zme(e){var a,t=Pme(),i=t.fromDate,r=t.toDate,o=t.styles,s=t.locale,l=t.formatters.formatMonthCaption,u=t.classNames,c=t.components,d=t.labels.labelMonthDropdown;if(!i)return n.jsx(n.Fragment,{});if(!r)return n.jsx(n.Fragment,{});var m=[];if(function(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getFullYear()===t.getFullYear()}(i,r))for(var h=pde(i),p=i.getMonth();p<=r.getMonth();p++)m.push(yme(h,p));else for(h=pde(new Date),p=0;p<=11;p++)m.push(yme(h,p));var g=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Bme;return n.jsx(g,{name:"months","aria-label":d(),className:u.dropdown_month,style:o.dropdown_month,onChange:function(a){var n=Number(a.target.value),t=yme(pde(e.displayMonth),n);e.onChange(t)},value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:s}),children:m.map((function(e){return n.jsx("option",{value:e.getMonth(),children:l(e,{locale:s})},e.getMonth())}))})}function Rme(e){var a,t=e.displayMonth,i=Pme(),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 n.jsx(n.Fragment,{});if(!o)return n.jsx(n.Fragment,{});for(var p=r.getFullYear(),g=o.getFullYear(),v=p;v<=g;v++)h.push(kme(gde(new Date),v));var f=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Bme;return n.jsx(f,{name:"years","aria-label":m(),className:u.dropdown_year,style:l.dropdown_year,onChange:function(a){var n=kme(pde(t),Number(a.target.value));e.onChange(n)},value:t.getFullYear(),caption:d(t,{locale:s}),children:h.map((function(e){return n.jsx("option",{value:e.getFullYear(),children:d(e,{locale:s})},e.getFullYear())}))})}function _me(){var e=Pme(),n=function(e){var a=e.month||e.defaultMonth||e.today||new Date,n=e.toDate,t=e.fromDate,i=e.numberOfMonths,r=void 0===i?1:i;return n&&mde(n,a)<0&&(a=Xce(n,-1*(r-1))),t&&mde(a,t)<0&&(a=t),pde(a)}(e),t=function(e,n){var t=a.useState(e);return[void 0===n?t[0]:n,t[1]]}(n,e.month),i=t[1];return[t[0],function(a){var n;if(!e.disableNavigation){var t=pde(a);i(t),null===(n=e.onMonthChange)||void 0===n||n.call(e,t)}}]}var Dme=a.createContext(void 0);function Kme(e){var a=Pme(),t=_me(),i=t[0],r=t[1],o=function(e,a){for(var n=a.reverseMonths,t=a.numberOfMonths,i=pde(e),r=mde(pde(Xce(i,t)),i),o=[],s=0;s<r;s++){var l=Xce(i,s);o.push(l)}return n&&(o=o.reverse()),o}(i,a),s=function(e,a){if(!a.disableNavigation){var n=a.toDate,t=a.numberOfMonths,i=void 0===t?1:t,r=a.pagedNavigation?i:1,o=pde(e);if(!n)return Xce(o,r);if(!(mde(n,e)<i))return Xce(o,r)}}(i,a),l=function(e,a){if(!a.disableNavigation){var n=a.fromDate,t=a.numberOfMonths,i=a.pagedNavigation?void 0===t?1:t:1,r=pde(e);if(!n)return Xce(r,-i);if(!(mde(r,n)<=0))return Xce(r,-i)}}(i,a),u=function(e){return o.some((function(a){return vme(e,a)}))};return n.jsx(Dme.Provider,{value:{currentMonth:i,displayMonths:o,goToMonth:r,goToDate:function(e,n){u(e)||(n&&gme(e,n)?r(Xce(e,1+-1*a.numberOfMonths)):r(e))},previousMonth:l,nextMonth:s,isDateDisplayed:u},children:e.children})}function Hme(){var e=a.useContext(Dme);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function Ome(e){var a,t=Pme(),i=t.classNames,r=t.styles,o=t.components,s=Hme().goToMonth,l=function(a){s(Xce(a,e.displayIndex?-e.displayIndex:0))},u=null!==(a=null==o?void 0:o.CaptionLabel)&&void 0!==a?a:jme,c=n.jsx(u,{id:e.id,displayMonth:e.displayMonth});return n.jsxs("div",{className:i.caption_dropdowns,style:r.caption_dropdowns,children:[n.jsx("div",{className:i.vhidden,children:c}),n.jsx(zme,{onChange:l,displayMonth:e.displayMonth}),n.jsx(Rme,{onChange:l,displayMonth:e.displayMonth})]})}function Ime(e){return n.jsx("svg",bme({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.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 Gme(e){return n.jsx("svg",bme({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.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 Vme=a.forwardRef((function(e,a){var t=Pme(),i=t.classNames,r=t.styles,o=[i.button_reset,i.button];e.className&&o.push(e.className);var s=o.join(" "),l=bme(bme({},r.button_reset),r.button);return e.style&&Object.assign(l,e.style),n.jsx("button",bme({},e,{ref:a,type:"button",className:s,style:l}))}));function Fme(e){var a,t,i=Pme(),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 n.jsx(n.Fragment,{});var h=c(e.previousMonth,{locale:o}),p=[s.nav_button,s.nav_button_previous].join(" "),g=d(e.nextMonth,{locale:o}),v=[s.nav_button,s.nav_button_next].join(" "),f=null!==(a=null==m?void 0:m.IconRight)&&void 0!==a?a:Gme,y=null!==(t=null==m?void 0:m.IconLeft)&&void 0!==t?t:Ime;return n.jsxs("div",{className:s.nav,style:l.nav,children:[!e.hidePrevious&&n.jsx(Vme,{name:"previous-month","aria-label":h,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:n.jsx("rtl"===r?f:y,{className:s.nav_icon,style:l.nav_icon})}),!e.hideNext&&n.jsx(Vme,{name:"next-month","aria-label":g,className:v,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:n.jsx("rtl"===r?y:f,{className:s.nav_icon,style:l.nav_icon})})]})}function Jme(e){var a=Pme().numberOfMonths,t=Hme(),i=t.previousMonth,r=t.nextMonth,o=t.goToMonth,s=t.displayMonths,l=s.findIndex((function(a){return vme(e.displayMonth,a)})),u=0===l,c=l===s.length-1;return n.jsx(Fme,{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 Ume(e){var a,t,i=Pme(),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:jme;return t=i.disableNavigation?n.jsx(u,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===s?n.jsx(Ome,{displayMonth:e.displayMonth,id:e.id}):n.jsxs(n.Fragment,"dropdown-buttons"===s?{children:[n.jsx(Ome,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),n.jsx(Jme,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}:{children:[n.jsx(u,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(Jme,{displayMonth:e.displayMonth,id:e.id})]}),n.jsx("div",{className:r.caption,style:o.caption,children:t})}function Wme(e){var a=Pme(),t=a.footer;return t?n.jsx("tfoot",{className:a.classNames.tfoot,style:a.styles.tfoot,children:n.jsx("tr",{children:n.jsx("td",{colSpan:8,children:t})})}):n.jsx(n.Fragment,{})}function qme(){var e=Pme(),a=e.classNames,t=e.styles,i=e.showWeekNumber,r=e.locale,o=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,l=function(e,a,n){for(var t=n?tde(new Date):nde(new Date,{locale:e,weekStartsOn:a}),i=[],r=0;r<7;r++){var o=Qce(t,r);i.push(o)}return i}(r,e.weekStartsOn,e.ISOWeek);return n.jsxs("tr",{style:t.head_row,className:a.head_row,children:[i&&n.jsx("td",{style:t.head_cell,className:a.head_cell}),l.map((function(e,i){return n.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":s(e,{locale:r}),children:o(e,{locale:r})},i)}))]})}function Zme(){var e,a=Pme(),t=a.components,i=null!==(e=null==t?void 0:t.HeadRow)&&void 0!==e?e:qme;return n.jsx("thead",{style:a.styles.head,className:a.classNames.head,children:n.jsx(i,{})})}function $me(e){var a=Pme();return n.jsx(n.Fragment,{children:(0,a.formatters.formatDay)(e.date,{locale:a.locale})})}var Yme=a.createContext(void 0);function Qme(e){if(!Ame(e.initialProps)){return n.jsx(Yme.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}return n.jsx(Xme,{initialProps:e.initialProps,children:e.children})}function Xme(e){var a=e.initialProps,t=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,n=i.some((function(a){return cde(a,e)}));return Boolean(a&&!n)})),n.jsx(Yme.Provider,{value:{selected:i,onDayClick:function(e,n,t){var s,l;if((null===(s=a.onDayClick)||void 0===s||s.call(a,e,n,t),!Boolean(n.selected&&r&&(null==i?void 0:i.length)===r))&&!Boolean(!n.selected&&o&&(null==i?void 0:i.length)===o)){var u=i?Sme([],i):[];if(n.selected){var c=u.findIndex((function(a){return cde(e,a)}));u.splice(c,1)}else u.push(e);null===(l=a.onSelect)||void 0===l||l.call(a,u,e,n,t)}},modifiers:s},children:t})}function ehe(){var e=a.useContext(Yme);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var ahe,nhe,the=a.createContext(void 0);function ihe(e){if(!wme(e.initialProps)){return n.jsx(the.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}return n.jsx(rhe,{initialProps:e.initialProps,children:e.children})}function rhe(e){var a=e.initialProps,t=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],cde(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:fme(o,l-1),before:Qce(o,l-1)}),o&&s&&c.disabled.push({after:o,before:Qce(o,l-1)}),!o&&s&&c.disabled.push({after:fme(s,l-1),before:Qce(s,l-1)})),u){if(o&&!s&&(c.disabled.push({before:Qce(o,1-u)}),c.disabled.push({after:Qce(o,u-1)})),o&&s){var d=u-(sde(s,o)+1);c.disabled.push({before:fme(o,d)}),c.disabled.push({after:Qce(s,d)})}!o&&s&&(c.disabled.push({before:Qce(s,1-u)}),c.disabled.push({after:Qce(s,u-1)}))}return n.jsx(the.Provider,{value:{selected:i,onDayClick:function(e,n,t){var r,o;null===(r=a.onDayClick)||void 0===r||r.call(a,e,n,t);var s=function(e,a){var n=a||{},t=n.from,i=n.to;if(t&&i){if(cde(i,e)&&cde(t,e))return;if(cde(i,e))return{from:i,to:void 0};if(cde(t,e))return;return pme(t,e)?{from:e,to:i}:{from:t,to:e}}return i?pme(e,i)?{from:i,to:e}:{from:e,to:i}:t?gme(e,t)?{from:e,to:t}:{from:t,to:e}:{from:e,to:void 0}}(e,i);null===(o=a.onSelect)||void 0===o||o.call(a,s,e,n,t)},modifiers:c},children:t})}function ohe(){var e=a.useContext(the);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function she(e){return Array.isArray(e)?Sme([],e):void 0!==e?[e]:[]}(nhe=ahe||(ahe={})).Outside="outside",nhe.Disabled="disabled",nhe.Selected="selected",nhe.Hidden="hidden",nhe.Today="today",nhe.RangeStart="range_start",nhe.RangeEnd="range_end",nhe.RangeMiddle="range_middle";var lhe=ahe.Selected,uhe=ahe.Disabled,che=ahe.Hidden,dhe=ahe.Today,mhe=ahe.RangeEnd,hhe=ahe.RangeMiddle,phe=ahe.RangeStart,ghe=ahe.Outside;var vhe=a.createContext(void 0);function fhe(e){var a=Pme(),t=function(e,a,n){var t,i=((t={})[lhe]=she(e.selected),t[uhe]=she(e.disabled),t[che]=she(e.hidden),t[dhe]=[e.today],t[mhe]=[],t[hhe]=[],t[phe]=[],t[ghe]=[],t);return e.fromDate&&i[uhe].push({before:e.fromDate}),e.toDate&&i[uhe].push({after:e.toDate}),Ame(e)?i[uhe]=i[uhe].concat(a.modifiers[uhe]):wme(e)&&(i[uhe]=i[uhe].concat(n.modifiers[uhe]),i[phe]=n.modifiers[phe],i[hhe]=n.modifiers[hhe],i[mhe]=n.modifiers[mhe]),i}(a,ehe(),ohe()),i=function(e){var a={};return Object.entries(e).forEach((function(e){a[e[0]]=she(e[1])})),a}(a.modifiers),r=bme(bme({},t),i);return n.jsx(vhe.Provider,{value:r,children:e.children})}function yhe(){var e=a.useContext(vhe);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function khe(e,a){return a.some((function(a){if("boolean"==typeof a)return a;if(dde(a))return cde(e,a);var n,t,i,r,o;if(function(e){return Array.isArray(e)&&e.every(dde)}(a))return a.includes(e);if(function(e){return Boolean(e&&"object"==typeof e&&"from"in e)}(a))return n=e,o=(t=a).to,(r=t.from)&&o?(sde(o,r)<0&&(r=(i=[o,r])[0],o=i[1]),sde(n,r)>=0&&sde(o,n)>=0):o?cde(o,n):!!r&&cde(r,n);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=sde(a.before,e)>0,l=sde(a.after,e)<0;return pme(a.before,a.after)?l&&s:s||l}return function(e){return Boolean(e&&"object"==typeof e&&"after"in e)}(a)?sde(e,a.after)>0:function(e){return Boolean(e&&"object"==typeof e&&"before"in e)}(a)?sde(a.before,e)>0:"function"==typeof a&&a(e)}))}function bhe(e,a,n){var t=Object.keys(a).reduce((function(n,t){return khe(e,a[t])&&n.push(t),n}),[]),i={};return t.forEach((function(e){return i[e]=!0})),n&&!vme(e,n)&&(i.outside=!0),i}function She(e,a){var n=a.moveBy,t=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:Qce,week:lde,month:Xce,year:ude,startOfWeek:function(e){return i.ISOWeek?tde(e):nde(e,{locale:d,weekStartsOn:l})},endOfWeek:function(e){return i.ISOWeek?fde(e):vde(e,{locale:d,weekStartsOn:l})}}[n](e,"after"===t?1:-1);"before"===t&&u?m=function(e){var a,n;if($ce(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==qce(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Yce(e);(void 0===n||n<a||isNaN(Number(a)))&&(n=a)})),n||new Date(NaN)}([u,m]):"after"===t&&c&&(m=function(e){var a,n;if($ce(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==qce(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Yce(e);(void 0===n||n>a||isNaN(a.getDate()))&&(n=a)})),n||new Date(NaN)}([c,m]));var h=!0;if(r){var p=bhe(m,r);h=!p.disabled&&!p.hidden}return h?m:s.count>365?s.lastFocused:She(m,{moveBy:n,direction:t,context:i,modifiers:r,retry:bme(bme({},s),{count:s.count+1})})}var Ahe=a.createContext(void 0);function whe(e){var t=Hme(),i=yhe(),r=a.useState(),o=r[0],s=r[1],l=a.useState(),u=l[0],c=l[1],d=function(e,a){for(var n,t,i=pde(e[0]),r=hde(e[e.length-1]),o=i;o<=r;){var s=bhe(o,a);if(s.disabled||s.hidden)o=Qce(o,1);else{if(s.selected)return o;s.today&&!t&&(t=o),n||(n=o),o=Qce(o,1)}}return t||n}(t.displayMonths,i),m=(null!=o?o:u&&t.isDateDisplayed(u))?u:d,h=function(e){s(e)},p=Pme(),g=function(e,a){if(o){var n=She(o,{moveBy:e,direction:a,context:p,modifiers:i});cde(o,n)||(t.goToDate(n,o),h(n))}};return n.jsx(Ahe.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 Che(){var e=a.useContext(Ahe);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}var Mhe=a.createContext(void 0);function The(e){if(!Cme(e.initialProps)){return n.jsx(Mhe.Provider,{value:{selected:void 0},children:e.children})}return n.jsx(Nhe,{initialProps:e.initialProps,children:e.children})}function Nhe(e){var a=e.initialProps;return n.jsx(Mhe.Provider,{value:{selected:a.selected,onDayClick:function(e,n,t){var i,r,o;null===(i=a.onDayClick)||void 0===i||i.call(a,e,n,t),!n.selected||a.required?null===(o=a.onSelect)||void 0===o||o.call(a,e,e,n,t):null===(r=a.onSelect)||void 0===r||r.call(a,void 0,e,n,t)}},children:e.children})}function Ehe(){var e=a.useContext(Mhe);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function xhe(e,a){var n=[e.classNames.day];return Object.keys(a).forEach((function(a){var t=e.modifiersClassNames[a];if(t)n.push(t);else if(function(e){return Object.values(ahe).includes(e)}(a)){var i=e.classNames["day_".concat(a)];i&&n.push(i)}})),n}function Phe(e,t,i){var r,o,s,l=Pme(),u=Che(),c=function(e,a){return bhe(e,yhe(),a)}(e,t),d=function(e,a){var n=Pme(),t=Ehe(),i=ehe(),r=ohe(),o=Che(),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,v=o.focusYearAfter,f=o.focusStartOfWeek,y=o.focusEndOfWeek;return{onClick:function(o){var s,l,u,c;Cme(n)?null===(s=t.onDayClick)||void 0===s||s.call(t,e,a,o):Ame(n)?null===(l=i.onDayClick)||void 0===l||l.call(i,e,a,o):wme(n)?null===(u=r.onDayClick)||void 0===u||u.call(r,e,a,o):null===(c=n.onDayClick)||void 0===c||c.call(n,e,a,o)},onFocus:function(t){var i;m(e),null===(i=n.onDayFocus)||void 0===i||i.call(n,e,a,t)},onBlur:function(t){var i;d(),null===(i=n.onDayBlur)||void 0===i||i.call(n,e,a,t)},onKeyDown:function(t){var i;switch(t.key){case"ArrowLeft":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?s():l();break;case"ArrowRight":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?l():s();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),u();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),c();break;case"PageUp":t.preventDefault(),t.stopPropagation(),t.shiftKey?g():h();break;case"PageDown":t.preventDefault(),t.stopPropagation(),t.shiftKey?v():p();break;case"Home":t.preventDefault(),t.stopPropagation(),f();break;case"End":t.preventDefault(),t.stopPropagation(),y()}null===(i=n.onDayKeyDown)||void 0===i||i.call(n,e,a,t)},onKeyUp:function(t){var i;null===(i=n.onDayKeyUp)||void 0===i||i.call(n,e,a,t)},onMouseEnter:function(t){var i;null===(i=n.onDayMouseEnter)||void 0===i||i.call(n,e,a,t)},onMouseLeave:function(t){var i;null===(i=n.onDayMouseLeave)||void 0===i||i.call(n,e,a,t)},onPointerEnter:function(t){var i;null===(i=n.onDayPointerEnter)||void 0===i||i.call(n,e,a,t)},onPointerLeave:function(t){var i;null===(i=n.onDayPointerLeave)||void 0===i||i.call(n,e,a,t)},onTouchCancel:function(t){var i;null===(i=n.onDayTouchCancel)||void 0===i||i.call(n,e,a,t)},onTouchEnd:function(t){var i;null===(i=n.onDayTouchEnd)||void 0===i||i.call(n,e,a,t)},onTouchMove:function(t){var i;null===(i=n.onDayTouchMove)||void 0===i||i.call(n,e,a,t)},onTouchStart:function(t){var i;null===(i=n.onDayTouchStart)||void 0===i||i.call(n,e,a,t)}}}(e,c),m=function(){var e=Pme(),a=Ehe(),n=ehe(),t=ohe();return Cme(e)?a.selected:Ame(e)?n.selected:wme(e)?t.selected:void 0}(),h=Boolean(l.onDayClick||"default"!==l.mode);a.useEffect((function(){var a;c.outside||u.focusedDay&&h&&cde(u.focusedDay,e)&&(null===(a=i.current)||void 0===a||a.focus())}),[u.focusedDay,e,i,h,c.outside]);var p=xhe(l,c).join(" "),g=function(e,a){var n=bme({},e.styles.day);return Object.keys(a).forEach((function(a){var t;n=bme(bme({},n),null===(t=e.modifiersStyles)||void 0===t?void 0:t[a])})),n}(l,c),v=Boolean(c.outside&&!l.showOutsideDays||c.hidden),f=null!==(s=null===(o=l.components)||void 0===o?void 0:o.DayContent)&&void 0!==s?s:$me,y={style:g,className:p,children:n.jsx(f,{date:e,displayMonth:t,activeModifiers:c}),role:"gridcell"},k=u.focusTarget&&cde(u.focusTarget,e)&&!c.outside,b=u.focusedDay&&cde(u.focusedDay,e),S=bme(bme(bme({},y),((r={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,r.tabIndex=b||k?0:-1,r)),d);return{isButton:h,isHidden:v,activeModifiers:c,selectedDays:m,buttonProps:S,divProps:y}}function jhe(e){var t=a.useRef(null),i=Phe(e.date,e.displayMonth,t);return i.isHidden?n.jsx("div",{role:"gridcell"}):i.isButton?n.jsx(Vme,bme({name:"day",ref:t},i.buttonProps)):n.jsx("div",bme({},i.divProps))}function Lhe(e){var a=e.number,t=e.dates,i=Pme(),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 n.jsx("span",{className:s.weeknumber,style:o.weeknumber,children:c});var d=u(Number(a),{locale:l});return n.jsx(Vme,{name:"week-number","aria-label":d,className:s.weeknumber,style:o.weeknumber,onClick:function(e){r(a,t,e)},children:c})}function Bhe(e){var a,t,i,r=Pme(),o=r.styles,s=r.classNames,l=r.components,u=null!==(a=null==l?void 0:l.Day)&&void 0!==a?a:jhe,c=null!==(t=null==l?void 0:l.WeekNumber)&&void 0!==t?t:Lhe;return r.showWeekNumber&&(i=n.jsx("td",{className:s.cell,style:o.cell,children:n.jsx(c,{number:e.weekNumber,dates:e.dates})})),n.jsxs("tr",{className:s.row,style:o.row,children:[i,e.dates.map((function(a){return n.jsx("td",{className:s.cell,style:o.cell,role:"presentation",children:n.jsx(u,{displayMonth:e.displayMonth,date:a})},dme(a))}))]})}function zhe(e,a,n){for(var t=(null==n?void 0:n.ISOWeek)?fde(a):vde(a,n),i=(null==n?void 0:n.ISOWeek)?tde(e):nde(e,n),r=sde(t,i),o=[],s=0;s<=r;s++)o.push(Qce(i,s));var l=o.reduce((function(e,a){var t=(null==n?void 0:n.ISOWeek)?function(e){$ce(1,arguments);var a=Yce(e),n=tde(a).getTime()-ide(a).getTime();return Math.round(n/6048e5)+1}(a):function(e,a){$ce(1,arguments);var n=Yce(e),t=nde(n,a).getTime()-mme(n,a).getTime();return Math.round(t/6048e5)+1}(a,n),i=e.find((function(e){return e.weekNumber===t}));return i?(i.dates.push(a),e):(e.push({weekNumber:t,dates:[a]}),e)}),[]);return l}function Rhe(e){var a,t,i,r=Pme(),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 n=zhe(pde(e),hde(e),a);if(null==a?void 0:a.useFixedWeeks){var t=hme(e,a);if(t<6){var i=n[n.length-1],r=i.dates[i.dates.length-1],o=lde(r,6-t),s=zhe(lde(r,1),o,a);n.push.apply(n,s)}}return n}(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:Zme,v=null!==(t=null==c?void 0:c.Row)&&void 0!==t?t:Bhe,f=null!==(i=null==c?void 0:c.Footer)&&void 0!==i?i:Wme;return n.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&n.jsx(g,{}),n.jsx("tbody",{className:s.tbody,style:l.tbody,children:p.map((function(a){return n.jsx(v,{displayMonth:e.displayMonth,dates:a.dates,weekNumber:a.weekNumber},a.weekNumber)}))}),n.jsx(f,{displayMonth:e.displayMonth})]})}var _he="undefined"!=typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,Dhe=!1,Khe=0;function Hhe(){return"react-day-picker-".concat(++Khe)}function Ohe(e){var t,i,r=Pme(),o=r.dir,s=r.classNames,l=r.styles,u=r.components,c=Hme().displayMonths,d=function(e){var n,t=null!=e?e:Dhe?Hhe():null,i=a.useState(t),r=i[0],o=i[1];return _he((function(){null===r&&o(Hhe())}),[]),a.useEffect((function(){!1===Dhe&&(Dhe=!0)}),[]),null!==(n=null!=e?e:r)&&void 0!==n?n: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,v=e.displayIndex===c.length-1,f=!g&&!v;"rtl"===o&&(v=(t=[g,v])[0],g=t[1]),g&&(h.push(s.caption_start),p=bme(bme({},p),l.caption_start)),v&&(h.push(s.caption_end),p=bme(bme({},p),l.caption_end)),f&&(h.push(s.caption_between),p=bme(bme({},p),l.caption_between));var y=null!==(i=null==u?void 0:u.Caption)&&void 0!==i?i:Ume;return n.jsxs("div",{className:h.join(" "),style:p,children:[n.jsx(y,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(Rhe,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function Ihe(e){var a=Pme();return n.jsx("div",{className:a.classNames.months,style:a.styles.months,children:e.children})}function Ghe(e){var t,i,r=e.initialProps,o=Pme(),s=Che(),l=Hme(),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=bme(bme({},o.styles.root),o.style),p=Object.keys(r).filter((function(e){return e.startsWith("data-")})).reduce((function(e,a){var n;return bme(bme({},e),((n={})[a]=r[a],n))}),{}),g=null!==(i=null===(t=r.components)||void 0===t?void 0:t.Months)&&void 0!==i?i:Ihe;return n.jsx("div",bme({className:m.join(" "),style:h,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:n.jsx(g,{children:l.displayMonths.map((function(e,a){return n.jsx(Ohe,{displayIndex:a,displayMonth:e},a)}))})}))}function Vhe(e){var a=e.children,t=function(e,a){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&a.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(e);i<t.length;i++)a.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(n[t[i]]=e[t[i]])}return n}(e,["children"]);return n.jsx(xme,{initialProps:t,children:n.jsx(Kme,{children:n.jsx(The,{initialProps:t,children:n.jsx(Qme,{initialProps:t,children:n.jsx(ihe,{initialProps:t,children:n.jsx(fhe,{children:n.jsx(whe,{children:a})})})})})})})}function Fhe(e){return n.jsx(Vhe,bme({},e,{children:n.jsx(Ghe,{initialProps:e})}))}function Jhe({className:e,classNames:a,showOutsideDays:t=!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:pm(xY({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:pm(xY({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 n.jsx(Fhe,{showOutsideDays:t,className:pm("p-3",e),classNames:r,components:{IconLeft:()=>n.jsx(Pc,{className:"h-4 w-4"}),IconRight:()=>n.jsx(jc,{className:"h-4 w-4"})},...i})}Jhe.displayName="Calendar";const Uhe=({setScheduleTime:e,setTimezone:a,timezone:t,scheduleTime:i,setIsDirty:o})=>{const[s,l]=r.useState(i&&i<(new Date).toISOString()?"Please select a time in the future":null),[u,c]=r.useState(i&&"now"!==i?dae(new Date(i),"HH:mm"):"00:00"),d=Intl.supportedValuesOf("timeZone").map((e=>({label:e,value:e}))),m=e=>{const n=new Date(i||(new Date).toISOString()),t=Cee(new Date,15);n<new Date(t.toLocaleString("en-US",{timeZone:e}))?l("Please select a time at least 15 minutes in the future"):(l(null),a(e),o(!0))},h=a=>{const n=Cee(new Date,15);new Date(a.toLocaleString("en-US",{timeZone:t}))<new Date(n.toLocaleString("en-US",{timeZone:t}))?l("Please select a time at least 15 minutes in the future"):(l(null),e(a.toISOString()),o(!0))};return n.jsx("div",{className:"w-full @container/schedule-time",children:n.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[n.jsxs("div",{className:"flex gap-2 w-full @xl/schedule-time:flex-row flex-col items-center justify-center",children:[n.jsxs(m9,{children:[n.jsx(h9,{asChild:!0,children:n.jsxs(PY,{variant:"outline",className:pm("bg-background w-full sm:w-[280px] justify-start text-left font-normal",!i&&"text-muted-foreground"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),i?"now"===i?"Send immediately":dae(new Date(i),"PPP"):n.jsx("span",{children:"Pick a date"})]})}),n.jsx(p9,{className:"w-auto p-0 z-[60] pointer-events-auto",children:n.jsx(Jhe,{mode:"single",selected:i?new Date(i):void 0,onSelect:e=>{if(!e)return;const[a,n]=u.split(":").map(Number);e.setHours(a,n),h(e)},disabled:e=>{const a=new Date;return a.setHours(0,0,0,0),e<a},initialFocus:!0})})]}),n.jsx("input",{type:"time",value:u,onChange:e=>{if(c(e.target.value),i&&e.target.value){const[a,n]=e.target.value.split(":").map(Number),t=new Date(i);t.setHours(a,n),h(t)}},className:pm("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",s&&"border-red-500")}),n.jsx("div",{className:"w-full sm:w-[200px]",children:n.jsx(tue,{options:d,selectedValues:[t],setSelectedValues:e=>m(e[0]),onValueChange:e=>m(e[0]),placeholder:"Select timezone...",searchPlaceholder:"Search timezone...",emptyMessage:"No timezone found",title:"Select Timezone",singleSelect:!0})})]}),s&&n.jsxs("p",{className:"text-destructive text-sm mt-2 flex items-center",children:[n.jsx("span",{className:"mr-2",children:"⚠️"}),s]})]})})},Whe=({title:e="Edit Schedule Time"})=>{const t=AY(),i=ce(),{updateAutomation:r}=na(t?.id||""),{toast:o}=Ie(),[s,l]=a.useState(null),[u,c]=a.useState(t?.triggerMetadata?.triggerType===oa.ONE_TIME?t?.triggerMetadata?.scheduledAt:null),[d,m]=a.useState(t?.triggerMetadata?.triggerType===oa.ONE_TIME&&t?.triggerMetadata?.timezone||"America/New_York"),[h,p]=a.useState(!1),[g,v]=a.useState(null);let f=a.useRef(null);const y=a.useCallback((()=>{t&&("sendNow"===s||"now"===u?r({trigger:{triggerType:oa.ONE_TIME,scheduledAt:"now"}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${Eh("engage:broadcast")} scheduled to begin sending in 5 minutes after you activate it`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:je.all})}}):u&&d&&r({trigger:{triggerType:oa.ONE_TIME,scheduledAt:u,timezone:d}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${Eh("engage:broadcast")} scheduled to start at ${new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric"})}`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:je.all})}}))}),[t,s,u,d,r,o,i]);if(a.useEffect((()=>(g&&(f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{o(g),v(null)}),800)),()=>{f.current&&clearTimeout(f.current)})),[g,o]),a.useEffect((()=>{t&&h&&s&&("sendNow"===s||u)&&(y(),p(!1))}),[s,u,d,y,t,h]),a.useEffect((()=>{null===s&&t?.triggerMetadata&&"object"==typeof t.triggerMetadata&&null!==t.triggerMetadata&&"scheduledAt"in t.triggerMetadata&&("now"===t?.triggerMetadata?.scheduledAt&&t?.triggerType===oa.ONE_TIME?l("sendNow"):(t?.triggerMetadata?.scheduledAt&&c(t.triggerMetadata.scheduledAt),t?.triggerMetadata?.timezone&&m(t.triggerMetadata.timezone),l("schedule")))}),[t,s]),!t)return null;const k=t.status===ca.DRAFT;return n.jsx(Jce,{title:e,headerActions:!k&&n.jsx(Mae,{title:"You can only edit the schedule time if the automation is in draft mode"}),children:n.jsx("div",{className:"@container flex-1 mx-4",children:n.jsxs("div",{className:"flex @[1000px]:flex-row flex-col gap-8 items-center",children:[n.jsxs("div",{className:"flex-1 w-full",children:[n.jsxs("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-4",children:[n.jsx(BY,{selected:"sendNow"===s,title:"Send Now",subtitle:"Campaign will begin sending in 5 minutes",icon:n.jsx(zY.SendButton,{className:"text-primary"}),onClick:()=>{k&&(l("sendNow"),c("now"),m("America/New_York"),p(!0))}}),n.jsx(BY,{selected:"schedule"===s,title:"Schedule",subtitle:"Choose date and time",icon:n.jsx(zY.ScheduleButton,{className:"text-primary"}),onClick:()=>{k&&l("schedule")}})]}),n.jsx(dV,{children:"schedule"===s&&n.jsx(EY,{className:"overflow-hidden mt-8",children:n.jsx("div",{className:"bg-gray-50 rounded-xl p-5 border border-gray-100 flex items-center justify-center",children:n.jsx(Uhe,{setScheduleTime:e=>{c(e),p(!0)},setTimezone:e=>{m(e),p(!0)},timezone:d,scheduleTime:u,setIsDirty:p})})})})]}),u&&n.jsx(Z$.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:n.jsxs(n.Fragment,"now"===u?{children:[n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Ready to send immediately"}),n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:"Once you mark this automation as active, we'll send it 5 minutes from that moment"})]}:{children:[n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Currently scheduled for:"}),n.jsx(Z$.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})})]})})]})})})},qhe=()=>n.jsx("div",{children:n.jsx(Whe,{title:"Set Schedule Time"})});var Zhe=(e=>(e.DAYS="days",e))(Zhe||{});const $he=(e,a)=>{switch(e){case bY.EQUALS:return"Equals";case bY.NOT_EQUALS:return"Not Equals";case bY.GREATER_THAN:return a===yY.Date?"Date on or after":"Greater than";case bY.LESS_THAN:return a===yY.Date?"Date on or before":"Less than";case bY.EXISTS:return"Exists";case bY.EQUALS_MONTH_DAY:return"Month and Day Matches";case bY.EQUALS_MONTH_DAY_YEAR:return"Month, Day, and Year Matches";case bY.BETWEEN_MONTH_DAY:return"Between Month Day";case bY.BETWEEN_MONTH_DAY_YEAR:return"Between Month Day Year";case bY.ARRAY_CONTAINS:return"Is One Of";default:return e}},Yhe={email:"Email Address",phone:"Phone Number",firstName:"First Name",lastName:"Last Name"},Qhe=({options:e,value:a,onChange:t,placeholder:i,className:o="",disableInput:s=!1})=>{const[l,u]=r.useState(!1);return n.jsxs(m9,{modal:!0,open:l,onOpenChange:u,children:[n.jsx(h9,{asChild:!0,children:n.jsxs(PY,{"aria-expanded":l,className:pm("w-full overflow-hidden justify-between",o),variant:"outline",children:[a?e.find((e=>e.value===a))?.label:i,n.jsx(Bc,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),n.jsx(p9,{className:pm("w-full min-w-[120px] max-w-[600px] p-0",o),children:n.jsxs(Ise,{children:[!s&&n.jsx(Gse,{placeholder:`${i}...`}),n.jsxs(Vse,{children:[n.jsxs(Fse,{children:["No ",i.toLowerCase()," found."]}),n.jsx(Jse,{children:e.map((e=>n.jsxs(Use,{value:e.value,onSelect:e=>{t(e===a?"":e),u(!1)},children:[n.jsx(Ec,{className:pm("mr-2 h-4 w-4",a===e.value?"opacity-100":"opacity-0")}),e.label]},e.id||e.value)))})]})]})})]})};var Xhe="Switch",[epe,ape]=XQ(Xhe),[npe,tpe]=epe(Xhe),ipe=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),v=hO(a,(e=>g(e))),f=r.useRef(!1),y=!p||(m||!!p.closest("form")),[k=!1,b]=nX({prop:o,defaultProp:s,onChange:d});return n.jsxs(npe,{scope:t,checked:k,disabled:u,children:[n.jsx(lX.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":lpe(k),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:v,onClick:QQ(e.onClick,(e=>{b((e=>!e)),y&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())}))}),y&&n.jsx(spe,{control:p,bubbles:!f.current,name:i,value:c,checked:k,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"}})]})}));ipe.displayName=Xhe;var rpe="SwitchThumb",ope=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,...i}=e,r=tpe(rpe,t);return n.jsx(lX.span,{"data-state":lpe(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:a})}));ope.displayName=rpe;var spe=e=>{const{control:a,checked:t,bubbles:i=!0,...o}=e,s=r.useRef(null),l=Boe(t),u=g1(a);return r.useEffect((()=>{const e=s.current,a=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(a,"checked").set;if(l!==t&&n){const a=new Event("click",{bubbles:i});n.call(e,t),e.dispatchEvent(a)}}),[l,t,i]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...o,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function lpe(e){return e?"checked":"unchecked"}var upe=ipe,cpe=ope;const dpe=r.forwardRef((({className:e,...a},t)=>n.jsx(upe,{className:pm("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:t,children:n.jsx(cpe,{className:pm("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")})})));dpe.displayName=upe.displayName;const mpe=({onSelect:e,date:a,placeholder:t="Pick a date",monthDayOnly:i=!1})=>n.jsxs(m9,{modal:!0,children:[n.jsx(h9,{asChild:!0,children:n.jsxs(PY,{variant:"outline",className:pm("w-[200px] justify-start text-left font-normal h-9",!a&&"text-muted-foreground"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),a?dae(a,i?"MMMM d":"PPP"):n.jsx("span",{children:t})]})}),n.jsx(p9,{className:"w-auto p-0",align:"start",children:n.jsx(Jhe,{mode:"single",selected:a,onSelect:e,initialFocus:!0})})]}),hpe=e=>void 0===e.value||!("number"!=typeof e.value||e.value<0)&&(e.unit===Zhe.DAYS&&(("before"===e.direction||"after"===e.direction)&&"relative"===e.type)),ppe=({fieldType:e,operator:a,value:t,onChange:i,options:o,toast:s})=>{const l=t.length>0&&"object"==typeof t[0]&&"type"in t[0]&&"relative"===t[0].type,u=t.length>0&&"object"==typeof t[0]&&"startDate"in t[0]&&"endDate"in t[0],[c,d]=r.useState((e===yY.Date||e===yY.DateTime)&&t.length>0&&t[0]instanceof Date?t[0]:void 0),[m,h]=r.useState(l),[p,g]=r.useState(l?t[0]:{type:"relative",value:0,unit:Zhe.DAYS,direction:"before"}),[v,f]=r.useState(u?t[0]:void 0),[y,k]=r.useState(!1);if(r.useEffect((()=>{a!==bY.EQUALS_MONTH_DAY&&a!==bY.EQUALS_MONTH_DAY_YEAR&&m&&(h(!1),i(c?[c]:[]))}),[a,m,c,i]),r.useEffect((()=>{if(u&&v?.startDate){k("object"==typeof v.startDate&&"type"in v.startDate)}}),[u,v]),e===yY.String||e===yY.ReachResource||e===yY.Array)return a===bY.EXISTS?null:n.jsx(tue,{options:(o||[]).map((e=>({label:e.displayName,value:e.id}))),onValueChange:e=>{i(e)},selectedValues:t.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===yY.Date||e===yY.DateTime){const e=a===bY.EQUALS_MONTH_DAY||a===bY.EQUALS_MONTH_DAY_YEAR,t=a===bY.BETWEEN_MONTH_DAY||a===bY.BETWEEN_MONTH_DAY_YEAR,r=e=>{hpe(e)?(g(e),m&&i([e])):s({title:"Invalid relative date",description:"Please enter a valid non-negative number of days.",variant:"destructive"})},o=e=>{const a=e.startDate??v?.startDate,n=e.endDate??v?.endDate,t=a&&"object"==typeof a&&"type"in a,r=n&&"object"==typeof n&&"type"in n;if(a&&n){if(t!==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(!t&&!r&&!(e=>!e.finalStartDate||!e.finalEndDate||e.finalStartDate<e.finalEndDate)({finalStartDate:a,finalEndDate:n}))return void s({title:"Invalid date range",description:"Start date must be before end date.",variant:"destructive"});if(t&&(!hpe(a)||!hpe(n)))return void s({title:"Invalid relative date",description:"Please enter valid relative dates.",variant:"destructive"})}f(e),a&&n&&i([{startDate:a,endDate:n}])},l=e=>{e&&(e=>e instanceof Date?!isNaN(e.getTime()):"object"==typeof e&&"type"in e&&"relative"===e.type&&hpe(e))(e)?(d(e),i([e]),h(!1)):e||(d(void 0),i([]),h(!1))},u=e=>{h(e),i(e?[p]:c?[c]:[])};return n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"min-h-[36px] flex items-center",children:[(!m||!e)&&!t&&n.jsx(mpe,{date:c,onSelect:l,monthDayOnly:a===bY.EQUALS_MONTH_DAY}),e&&m&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(r4,{type:"number",value:void 0===p.value?"":p.value,onChange:e=>{const a=""===e.target.value?void 0:parseInt(e.target.value,10);r({...p,value:a})},className:"w-20 h-9",min:"0","aria-label":"Relative days value"}),n.jsxs(hie,{value:p.direction,onValueChange:e=>{r({...p,direction:e})},children:[n.jsx(vie,{className:"w-[180px] h-9","aria-label":"Relative direction",children:n.jsx(gie,{placeholder:"Select direction..."})}),n.jsxs(kie,{children:[n.jsx(bie,{value:"before",children:"days before today"}),n.jsx(bie,{value:"after",children:"days after today"})]})]})]}),t&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(r4,{type:"number",value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:Zhe.DAYS,direction:v?.startDate?.direction||"before"};hpe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},className:"w-20 h-9",min:"0","aria-label":"Start date relative days"}),n.jsxs(hie,{value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.startDate?.value,unit:Zhe.DAYS,direction:e};hpe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},children:[n.jsx(vie,{className:"w-[180px] h-9",children:n.jsx(gie,{placeholder:"Select direction..."})}),n.jsxs(kie,{children:[n.jsx(bie,{value:"before",children:"days before today"}),n.jsx(bie,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"Start"})]}):n.jsx(mpe,{placeholder:"Start date",date:v?.startDate instanceof Date||"string"==typeof v?.startDate?v.startDate instanceof Date?v.startDate:new Date(v.startDate):void 0,monthDayOnly:a===bY.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,startDate:a}),o({...v,startDate:a}))}})}),n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(r4,{type:"number",value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:Zhe.DAYS,direction:v?.endDate?.direction||"before"};hpe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},className:"w-20 h-9",min:"0","aria-label":"End date relative days"}),n.jsxs(hie,{value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.endDate?.value,unit:Zhe.DAYS,direction:e};hpe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},children:[n.jsx(vie,{className:"w-[180px] h-9",children:n.jsx(gie,{placeholder:"Select direction..."})}),n.jsxs(kie,{children:[n.jsx(bie,{value:"before",children:"days before today"}),n.jsx(bie,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"End"})]}):n.jsx(mpe,{placeholder:"End date",date:v?.endDate instanceof Date||"string"==typeof v?.endDate?v.endDate instanceof Date?v.endDate:new Date(v.endDate):void 0,monthDayOnly:a===bY.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,endDate:a}),o({...v,endDate:a}))}})})]}),n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(dpe,{id:"between-relative-date-switch",checked:y,onCheckedChange:e=>{if(k(e),e){const e={type:"relative",value:0,unit:Zhe.DAYS,direction:"before"},a={type:"relative",value:0,unit:Zhe.DAYS,direction:"before"};f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}else{const e=new Date,a=new Date(e);a.setDate(a.getDate()+1),f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}},"aria-label":"Toggle relative date input for between dates"}),n.jsx(Kae,{htmlFor:"between-relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})]}),e&&n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(dpe,{id:"relative-date-switch",checked:m,onCheckedChange:u,"aria-label":"Toggle relative date input"}),n.jsx(Kae,{htmlFor:"relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})}if(e===yY.Number||e===yY.Integer)return a===bY.EXISTS?null:n.jsx(r4,{type:"number",value:t.length>0?String(t[0]):"",onChange:e=>i([Number(e.target.value)]),className:"w-[200px]"});if(e===yY.Boolean){if(a===bY.EXISTS)return null;const e=t.length>0&&Boolean(t[0]);return n.jsx(dpe,{checked:e,onCheckedChange:e=>i([e])})}return n.jsx(r4,{value:t.length>0?String(t[0]):"",onChange:e=>i([e.target.value]),className:"w-[200px]",disabled:!0})},gpe=({condition:e,onUpdate:t,onDuplicate:i,onDelete:r,segmentsConditions:o})=>{const{toast:s}=Ie(),l=(e=>{const a=o.conditions.find((a=>a.field===e));return a||null})(e.field)||{operators:[],type:yY.String,options:void 0},u=l.operators,c=l.type,d=o.conditions.map((e=>e.field)).map((e=>({value:e,label:Yhe[e]||e})));return a.useEffect((()=>{setTimeout((()=>document.body.style.pointerEvents=""),0)}),[]),n.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch gap-2 min-w-0 w-full",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 items-stretch gap-2 min-w-0 w-full",children:[n.jsx("div",{className:"flex-1 min-w-0 items-center flex",children:n.jsx(Qhe,{options:d,value:e.field,onChange:a=>{const n=a,i=o.conditions.find((e=>e.field===n));if(!i)return;const r=i.operators.map((e=>({value:e,label:$he(e,i.type),fieldType:i.type}))),s=r[0]?.value;let l=[];switch(i.type){case yY.Boolean:l=[!1];break;case yY.Number:l=[0];break;case yY.Date:case yY.DateTime:l=[new Date];break;case yY.String:l=i.options?.length?i.options.map((e=>e.displayName)):[];break;default:l=[]}t({...e,field:n,operator:s,value:l})},placeholder:"Select field",className:"w-full",disableInput:!0})}),n.jsxs("div",{className:"flex-1 min-w-0 max-w-xs flex gap-2 items-center",children:[(e.operator===bY.EQUALS_MONTH_DAY||e.operator===bY.EQUALS_MONTH_DAY_YEAR||e.operator===bY.BETWEEN_MONTH_DAY||e.operator===bY.BETWEEN_MONTH_DAY_YEAR)&&n.jsx("div",{className:"flex items-center",children:(e=>{let a;switch(e){case bY.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 bY.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 bY.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 bY.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 n.jsx(Mae,{title:a})})(e.operator)}),n.jsx(Qhe,{options:u.map((e=>({value:e,label:e?$he(e,c):e}))),value:e.operator,onChange:a=>t({...e,operator:a}),placeholder:"Select operator",className:"w-full",disableInput:!0})]}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(ppe,{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=>t({...e,value:a}),toast:s})})]}),n.jsxs("div",{className:"flex items-center flex-shrink-0 pl-2",children:[n.jsx(PY,{size:"icon",variant:"ghost",onClick:i,children:n.jsx(Hc,{className:"h-4 w-4"})}),n.jsx(PY,{size:"icon",variant:"ghost",onClick:r,children:n.jsx(pd,{className:"h-4 w-4"})})]})]})},vpe=({onSelectStyle:e})=>{const[t,i]=a.useState(null);return n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 max-w-4xl mx-auto",children:[n.jsx(BY,{onClick:()=>{i("ai"),e("ai")},title:"Build with AI",subtitle:"Describe your audience in plain language and let AI create the conditions",icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(md,{className:"w-full h-full"})})}),selected:"ai"===t}),n.jsx(BY,{onClick:()=>{i("manual"),e("manual")},title:"Build Manually",subtitle:`Create your ${Eh("engage:segment")} by configuring conditions directly`,icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(ud,{className:"w-full h-full"})})}),selected:"manual"===t})]})},fpe=({segmentId:e,setOpen:a,setTextToSegment:t,promptBuilderStyle:i,textToSegment:r})=>n.jsx("div",{children:n.jsx(qG,{className:"",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx($G,{className:"text-3xl font-normal",children:e?`Edit ${Eh("engage:segment")}`:`Create ${Eh("engage:segment")}`}),n.jsxs("div",{className:"flex items-center gap-2",children:[!1===i&&!1===r&&n.jsx(P6,{children:n.jsxs(j6,{children:[n.jsx(L6,{asChild:!0,children:n.jsx(PY,{variant:"outline",size:"sm",onClick:()=>t(!0),children:n.jsx(md,{className:"h-4 w-3"})})}),n.jsx(B6,{children:n.jsxs("p",{children:["Use AI to create ",Eh("engage:segment")," by describing them in natural language"]})})]})}),n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>{a(!1)},className:"h-8 w-8",children:n.jsx(bd,{className:"h-4 w-4"})})]})]})})}),ype=({setTextToSegment:e,setSegment:t})=>{const[i,r]=a.useState(""),[o,s]=a.useState(!1),{toast:u}=Ie();return n.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Describe your audience"}),n.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."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(dV,{children:[o&&n.jsx(EY,{children:n.jsx(NY,{})}),!o&&n.jsx(EY,{children:n.jsx(iue,{placeholder:"Describe your target audience...",className:"min-h-[120px] resize-none",value:i,onChange:e=>r(e.target.value)})})]}),n.jsx("div",{className:"flex justify-end gap-2",children:n.jsxs(PY,{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=>(await Pe(`${l}/text-to-segment`,{method:"POST",body:JSON.stringify({text:e})})).data)(i);a.success&&a.conditions?(u({title:`${Eh("engage:segment")} conditions built successfully 🚀`,description:`Your ${Eh("engage:segment")} conditions have been built successfully`}),t(a.conditions)):u({title:`${Eh("engage:segment")} build failed`,description:"Please try again",variant:"destructive"}),e(!1),s(!1)},children:[n.jsx(md,{className:"h-4 w-4"}),"Generate ",Eh("engage:segment")]})})]})]})};function kpe({segmentId:e,setOpen:a,onSegmentUpdated:t}){const{toast:i}=Ie(),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}=vY(e||""),{updateSegment:h}=fY(e),{createSegment:p,isCreating:g,segmentsConditions:v}=hY(),[f,y]=r.useState(!1),[k,b]=r.useState(!!o);r.useEffect((()=>{v&&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:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})}),[d,v]);const S=e=>e.value.some((e=>"object"==typeof e&&"type"in e&&"relative"===e.type)),A=e=>e.value.some((e=>"object"==typeof e&&"startDate"in e&&"endDate"in e));if(!v||m)return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(NY,{})});return n.jsxs(n.Fragment,{children:[n.jsx(fpe,{segmentId:e,setOpen:a,setTextToSegment:y,promptBuilderStyle:k,textToSegment:f},"segment-builder-header"),k?n.jsx(EY,{children:n.jsx(vpe,{onSelectStyle:e=>{"ai"===e&&y(!0),b(!1)}})},"prompt-builder-style"):n.jsx(EY,{children:n.jsxs("div",{className:"flex flex-1 flex-col",children:[n.jsx("div",{className:"flex flex-1 flex-col px-8 py-2",children:n.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-visible",children:n.jsx(dV,{children:f?n.jsx(EY,{children:n.jsx(ype,{setTextToSegment:y,setSegment:e=>c({...u,conditions:e})})}):n.jsxs(EY,{children:[n.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsx(Kae,{className:"text-muted-foreground text-xs",children:"Name"}),n.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),n.jsx(r4,{placeholder:`${Eh("engage:segment")} name`,value:u.name,onChange:e=>c({...u,name:e.target.value})})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Kae,{className:"text-muted-foreground text-xs",children:"Description"}),n.jsx(r4,{placeholder:`${Eh("engage:segment")} description`,value:u.description,onChange:e=>c({...u,description:e.target.value})})]})]}),u.conditions.length>0&&n.jsx("div",{className:"flex-1 overflow-y-auto pb-8",children:n.jsx("div",{className:"grid",children:n.jsx(dV,{mode:"popLayout",children:u.conditions.map(((e,a)=>n.jsxs(Z$.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&&n.jsxs(Z$.div,{className:"relative flex items-center gap-3 py-1",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:[n.jsx(Z$.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}}),n.jsx(Z$.span,{className:"text-muted-foreground text-xs",initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},children:"AND"}),n.jsx(Z$.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}})]}),n.jsx(gpe,{condition:e,onUpdate:e=>((e,a)=>{const n=[...u.conditions];n[e]=a,c({...u,conditions:n})})(a,e),segmentsConditions:v,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,n)=>n!==e));c({...u,conditions:a})})(a)})]},`${e.field}-${e.operator}-${a}`)))})})})]})})})}),n.jsx("div",{className:"border-t px-8 py-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(PY,f?{variant:"secondary",onClick:()=>y(!1),children:[n.jsx(ud,{className:"h-4 w-4"}),"Manual Builder"]}:{variant:"secondary",onClick:()=>{c({...u,conditions:[...u.conditions,{field:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})},children:[n.jsx(rd,{className:"h-4 w-4"}),"Add Condition"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(PY,{variant:"destructive",onClick:()=>a(!1),children:"Cancel"}),n.jsx(PY,{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:n,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!==bY.EXISTS&&0===a.value.length)return{valid:!1,error:`Please ensure a value is selected for ${a.field}`};if(a.operator===bY.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!==bY.EQUALS_MONTH_DAY&&a.operator!==bY.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(A(a)&&a.operator!==bY.BETWEEN_MONTH_DAY&&a.operator!==bY.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(A(a)&&a.value.length>1)return{valid:!1,error:`Between dates can only have a single value for ${a.field}`};if(A(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("type"in e.startDate&&"relative"===e.startDate.type&&"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 n=e=>{if(e.unit===Zhe.DAYS)return e.value??0;throw tY(e.unit,Zhe)};if("before"===e.startDate.direction&&n(e.startDate)>n(e.endDate))return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("after"===e.startDate.direction&&n(e.startDate)<n(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(!n)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=v?.conditions.find((a=>a.field===e.field));return a?.type===yY.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:`${Eh("engage:segment")} updated successfully`}),a(!1),t?.(e)},onError:()=>{i({title:`Error updating ${Eh("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}}):p({name:u.name,description:u.description,conditions:u.conditions},{onSuccess:e=>{i({title:`${Eh("engage:segment")} created successfully`}),t?.(e?.id??!1),a(!1)},onError:()=>{i({title:`Error creating ${Eh("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}})}catch(s){i({title:`Error saving ${Eh("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}finally{l(!1)}},disabled:s||g,children:s||g?n.jsxs(n.Fragment,{children:[n.jsx(Wc,{className:"mr-2 h-4 w-4 animate-spin"}),e?"Updating...":"Creating..."]}):e?"Update":"Create"})]})]})})]})},"manual-builder-style")]})}function bpe({open:e,setOpen:a,segmentId:t,onSegmentUpdated:i}){return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"flex max-h-[86vh] flex-col gap-0 overflow-visible max-w-6xl w-full",hideCloseButton:!0,children:[n.jsxs(kO,{children:[n.jsxs($G,{children:[Eh("engage:segment")," Builder"]}),n.jsxs(YG,{children:["Build a ",Eh("engage:segment")," to target your audience"]})]}),n.jsx(kpe,{segmentId:t,setOpen:a,onSegmentUpdated:e=>{i?.(e),a(!1)}})]})})}const Spe=()=>n.jsx(Mae,{title:`These are estimated numbers of ${Eh("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.`}),Ape=({value:e,label:a,percentage:t,variant:i,isLoading:r,selected:o})=>n.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":""),style:{containerType:"inline-size"},"data-card-container":!0,children:[n.jsxs("div",{className:"flex flex-col gap-1 items-start w-full min-w-0",children:[n.jsx("div",{className:"flex items-baseline gap-2 w-full min-w-0 @container/num",children:r?n.jsx("span",{className:"animate-pulse",children:"..."}):n.jsxs(n.Fragment,{children:[n.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!==t&&e.toLocaleString().replace(/,/g,"").length<5&&n.jsxs("span",{className:"text-muted-foreground/50 text-sm hidden @[120px]/num:inline",children:["(",t,"%)"]})]})}),n.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})]}),n.jsx("p",{className:"text-sm text-muted-fore hidden @[250px]/card:inline mt-1",children:1===e?"contact":"contacts"})]}),wpe=({countResponse:e})=>{const t=a.useMemo((()=>e?.recipients?e.recipients.reduce(((a,n)=>({total:e.count,emails:a.emails+(n.email?1:0),phones:a.phones+(n.phone?1:0)})),{total:0,emails:0,phones:0}):{total:0,emails:0,phones:0}),[e]),i=e=>Math.round(e/(t.total||1)*100);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fce,{children:"Estimated Matches"}),n.jsx(Spe,{})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 md:mb-6 w-full gap-4 mt-3 px-1",children:[n.jsx(Ape,{value:t.total,label:"Total",variant:"default",isLoading:void 0===e}),n.jsx(Ape,{value:t.emails,label:"Subscribed to Email",percentage:i(t.emails),variant:"blue",isLoading:void 0===e}),n.jsx(Ape,{value:t.phones,label:"Subscribed to SMS",percentage:i(t.phones),variant:"green",isLoading:void 0===e})]})]})},Cpe=({recipients:e})=>{if(!e?.length)return null;const a=e.filter((e=>e.firstName||e.lastName));return n.jsx("div",{className:"bg-foreground/5 rounded-lg h-full relative overflow-hidden",children:n.jsx("div",{className:"absolute inset-0 w-full h-full overflow-y-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{className:"sticky top-0 bg-foreground/5 backdrop-blur-sm",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Name"}),n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Contact"})]})}),n.jsx("tbody",{className:"divide-y divide-gray-200/50",children:a.map(((e,a)=>n.jsxs("tr",{className:"hover:bg-white/50 transition-colors",children:[n.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-gray-900",children:`${e.firstName||""} ${e.lastName||""}`.trim()}),n.jsx("td",{className:"px-3 sm:px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:[e.email&&n.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&&n.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)))})]})})})},Mpe=({onSelectionChange:e,defaultValue:t="all",canEditAudience:i=!0})=>{const[r,o]=a.useState(t),s=a=>{i&&(o(a),e?.(a))};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fce,{children:"Filter"}),!i&&n.jsx(Mae,{title:"You cannot edit the audience unless you are in draft mode"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 p-1",children:[n.jsx(BY,{onClick:()=>s("all"),title:`All ${Eh("engage:user",{count:2})}`,subtitle:"Send to everyone",icon:n.jsx(zY.UsersIcon,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"all"===r,disabled:!i}),n.jsx(BY,{onClick:()=>s("segments"),title:`Select ${Eh("engage:user",{count:2})}`,subtitle:`Choose from ${Eh("engage:segment",{count:2})}`,icon:n.jsx(zY.UserEdit,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"segments"===r,disabled:!i})]})]})},Tpe=({segments:e,allSegments:t,onAddSegment:i,onRemoveSegment:r,setOpenCreateSegmentDialog:o,canEditAudience:s=!0})=>{const[l,u]=a.useState([]),c=t.map((e=>({label:e.name,value:e.id})));return a.useEffect((()=>{u(e)}),[e]),n.jsx("div",{children:n.jsx(tue,{canOpen:s,selectedValues:l,setSelectedValues:u,options:c,onValueChange:a=>{const n=a.filter((a=>!e.includes(a))),t=e.filter((e=>!a.includes(e)));n.forEach(i),t.forEach(r)},placeholder:"Select segments",maxCount:5,extraCommandItems:[e=>n.jsxs(Use,{onSelect:()=>{e(!0),o(!0)},className:"cursor-pointer",children:[n.jsx(zY.PlusIcon,{className:"w-4 h-4"}),"New"]},"new-segment")]})})},Npe=({includedSegments:e,excludedSegments:t,handleAddSegment:i,handleRemoveSegment:r,setOpenCreateSegmentDialog:o,segments:s,defaultIsExcludeOpen:l=!1,canEditAudience:u=!0})=>{const[c,d]=a.useState(l);return n.jsxs("div",{children:[n.jsx(Tpe,{segments:e,allSegments:s||[],onAddSegment:e=>i(e,"include"),onRemoveSegment:e=>r(e,"include"),setOpenCreateSegmentDialog:o}),n.jsx("div",{className:"border-t border-gray-200 my-8"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(PY,{onClick:()=>{u&&d(!c)},className:"flex items-center gap-1 transition-colors",size:"sm",children:[n.jsx(Z$.div,{animate:{rotate:c?180:0},transition:{duration:.2},children:n.jsx(zY.DropdownMenuTrigger,{className:"w-5 h-5"})}),n.jsx("span",{children:"Don't send to"})]}),n.jsx(dV,{children:c&&n.jsx(Z$.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeInOut"},children:n.jsx(Tpe,{canEditAudience:u,segments:t,allSegments:s||[],onAddSegment:e=>i(e,"exclude"),onRemoveSegment:e=>r(e,"exclude"),setOpenCreateSegmentDialog:o})})})]})]})},Epe=({title:e="Preview Audience"})=>{const t=AY(),[i,r]=a.useState("all"),[o,s]=a.useState(t?.includeSegmentIds||[]),[l,u]=a.useState(t?.excludeSegmentIds||[]),[c,d]=a.useState(!1),[m,h]=a.useState(!1),{segments:p,isLoading:g}=pY(),{updateAutomation:v}=na(t?.id??""),[f,y]=a.useState(void 0),k=1===o.length&&0===l.length&&void 0!==p?.find((e=>e.type===kY.ALL_USERS&&e.id===o[0]));a.useEffect((()=>{t&&!m&&(1===o.length&&void 0!==p?.find((e=>e.type===kY.ALL_USERS&&e.id===o[0]))?r("all"):r("segments"),dY({includeSegments:o,excludeSegments:l}).then((e=>{y(e)})),h(!0))}),[t,k,m,o,l,p]);a.useEffect((()=>{t&&m&&(JSON.stringify(o)===JSON.stringify(t.includeSegmentIds)&&JSON.stringify(l)===JSON.stringify(t.excludeSegmentIds)||(v({includeSegments:o,excludeSegments:l}),dY({includeSegments:o,excludeSegments:l}).then((e=>{y(e)}))))}),[o,l,t,m,v]);const b=t?.status===ca.DRAFT;return n.jsxs(Jce,{title:e,children:[!g&&p&&m?n.jsxs("div",{className:"flex gap-8 w-full pb-4 px-4",children:[n.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:[n.jsx(wpe,{countResponse:f}),n.jsx(Mpe,{onSelectionChange:e=>{if(r(e),"all"===e){const e=p?.find((e=>e.type===kY.ALL_USERS));if(!e)return;s([e.id]),u([])}},defaultValue:i,canEditAudience:b}),n.jsx(dV,{children:"segments"===i&&n.jsx(Z$.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:n.jsx(Npe,{canEditAudience:b,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:p,defaultIsExcludeOpen:l.length>0})})})]}),n.jsx("div",{className:"flex flex-col flex-1 relative overflow-hidden",children:f?.recipients&&n.jsx(Cpe,{recipients:f.recipients})})]}):n.jsx("div",{children:n.jsx(NY,{text:["Fetching segments","Finishing up"]})}),n.jsx(bpe,{open:c,setOpen:d,onSegmentUpdated:e=>{e&&s((a=>[...a,e]))}})]})},xpe=()=>n.jsx(Epe,{title:"Select Audience"}),Ppe=()=>{const{channelSenders:e}=E9(),{channelAccounts:t}=M9(),i=wY(),{updateCommunicationGroup:r}=Ze(),{state:{selectedChannels:o},setSelectedChannels:s}=a.useContext(A9),l=AY(),{data:u}=L9(),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((()=>zie({channelSenders:e?.results??[],channelAccounts:t?.results??[]})),[e?.results,t?.results]),m=a.useMemo((()=>mee({channelSenders:e?.results??[],channelAccounts:t?.results??[],smsApplication:u})),[e?.results,t?.results,u]);if(!o||!d||!m)return n.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:n.jsx(NY,{text:["Fetching Content..."]})});const h=d.length>0,p=m.length>0;return n.jsx("div",{className:"flex flex-col gap-4 flex-shrink-0",children:n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(yce,{automationType:l?.triggerMetadata?.triggerType,selectedChannels:o,setSelectedChannels:c,hasEmailChannelSenders:h,hasSmsChannelSenders:p})})})};var jpe=(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))(jpe||{});const Lpe="https://assets.embedreach.com/defaults/logo-placeholder-128.png",Bpe="You have not uploaded a custom logo. Please make sure to double check your email before sending!",zpe=()=>{const e=AY(),n=wY(),{state:{selectedChannels:t}}=a.useContext(A9),{data:i}=L9(),{channelSenders:r}=E9(),{channelAccounts:o}=M9(),s=mee({channelSenders:r?.results??[],channelAccounts:o?.results??[],smsApplication:i}),l=a.useCallback((async a=>e?await(async e=>{const{currentStep:a,automation:n,communicationGroup:t,selectedChannels:i,smsChannelSenders:r}=e;switch(a){case jpe.SelectAudience:return{canMove:n.includeSegmentIds.length>0,errorMessage:"Please ensure you have selected at least one segment"};case jpe.SelectSenders:return{canMove:i.length>0,errorMessage:"Please ensure you have selected at least one channel"};case jpe.EditSmsContent:{const e=n.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(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};const a=r.find((e=>e.channelSender.id===t.smsChannelSenderId));return a?t.smsMessageBody?a.smsApplication&&a.smsApplication.status!==dee.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 jpe.EditEmailContent:{const e=n.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(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};if(!t.emailChannelSenderId)return{canMove:!1,errorMessage:"Please ensure you have selected a email sender"};if(!t.emailHtmlBody||!t.emailSubject)return{canMove:!1,errorMessage:"Please ensure you have a email body and subject"};let a=null;return t.emailHtmlBody?.includes(Lpe)&&(a=Bpe),{canMove:!0,errorMessage:null,warningMessage:a}}case jpe.Schedule:{if(!n.triggerMetadata)return{canMove:!1,errorMessage:"Please make sure to select a time to send before starting!"};if(n.triggerMetadata.triggerType!==oa.ONE_TIME)return{canMove:Boolean(n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:null};if(!n.triggerMetadata?.scheduledAt)return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${Eh("engage:broadcast")}`};if(!Boolean(n.triggerMetadata?.scheduledAt&&("now"===n.triggerMetadata.scheduledAt||"now"!==n.triggerMetadata.scheduledAt&&new Date(n.triggerMetadata.scheduledAt)>new Date)))return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${Eh("engage:broadcast")}`};if(!Boolean(n.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=n.triggerMetadata;return{canMove:Boolean(e.scheduledAt&&("now"===e.scheduledAt||new Date(e.scheduledAt)>new Date)&&n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:`Please ensure you have set a valid future date for your ${Eh("engage:broadcast")}`}}case jpe.PreviewAndSend:return{canMove:!0,errorMessage:null};default:g9(a,jpe)}})({currentStep:a,automation:e,communicationGroup:n,selectedChannels:t,smsChannelSenders:s}):{canMove:!1,errorMessage:`${Eh("engage:broadcast")} not loaded`}),[e,n,t,s]);return{validateStep:l}},Rpe=({onFinish:e,getExtraMergeFields:t,onBeforeSchedule:i})=>{const r=AY(),o=wY(),{updateAutomation:s}=na(r?.id||""),{estimatedMatchesStats:l}=(e=>{const{data:n}=gY({automationId:e?.id??"",includeSegments:e?.includeSegmentIds??[],excludeSegments:e?.excludeSegmentIds??[]}),t=a.useMemo((()=>n?.recipients?n.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}),[n?.recipients]);return{estimatedMatches:n,estimatedMatchesStats:t}})(r??void 0),{state:{selectedChannels:u}}=a.useContext(A9),{validateStep:c}=zpe(),[d,m]=a.useState([]),{data:h}=L9(),[p,g]=a.useState(!1),{channelSenders:v}=E9(),{channelAccounts:f}=M9(),[y,k]=a.useState(jpe.SelectAudience);if(a.useEffect((()=>{if(null!==r&&null!==o){const e=mee({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});m((({automation:e,communicationGroup:a,selectedChannels:t,smsChannelSenders:i})=>e?[{id:"audience",title:"Audience",step:1,isValid:()=>e.includeSegmentIds.length>0,content:n.jsx(Nae,{content:n.jsx(xpe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===oa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},{id:"senders",title:"Channel Senders",step:2,isValid:()=>0!==t.length,content:n.jsx(Nae,{content:n.jsx(Ppe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===oa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},...t.includes("email")?[{id:"edit-email-content",title:"Edit Email Content",step:3,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!n&&!!a.emailChannelSenderId&&!(!a.emailHtmlBody||!a.emailSubject)},content:n.jsx(Nae,{content:n.jsx(Rie,{})},"audience"),footerConfig:{backText:"",nextText:"",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],...t.includes("sms")?[{id:"edit-sms-content",title:"Edit SMS Content",step:4,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!(n&&n.actionMetadata.communicationGroupId&&a.smsChannelSenderId&&a.smsMessageBody)},content:n.jsx(Nae,{content:n.jsx(lue,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],{id:"schedule",title:"Schedule",step:5,isValid:()=>Boolean(e.triggerMetadata?.triggerType===oa.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:n.jsx(Nae,{className:"flex-1",content:n.jsx(qhe,{})},"schedule"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}},{id:"send",title:"Send",step:6,isValid:()=>Boolean(e.triggerMetadata?.triggerType===oa.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:n.jsx(Nae,{className:"flex-1",content:n.jsx(Wce,{})},"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!==dee.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===dee.APPROVED))||null===a.smsChannelSenderId&&null===a.emailChannelSenderId}}}]:[])({automation:r,communicationGroup:o,selectedChannels:u,smsChannelSenders:e}))}}),[r,o,t,u,v?.results,f?.results,h]),!(r&&y&&o&&d.length))return n.jsx("div",{className:"flex-1 flex flex-col @container justify-center items-center h-[500px]",children:n.jsx(NY,{text:[`Fetching ${Eh("engage:broadcast")} data`,"Finishing up"]})});const b=async()=>{const{canMove:a,errorMessage:n,warningMessage:t}=await c(y);a?(t&&Oe({title:t,variant:"warning"}),y===jpe.PreviewAndSend?await(async()=>{if(null===o.emailChannelSenderId&&null===o.smsChannelSenderId)return void Oe({title:"Oops!",description:"Please select an email sender or sms sender",variant:"destructive"});const a=mee({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});if(o.smsChannelSenderId){const e=a.find((e=>e.channelSender.id===o.smsChannelSenderId));if(e?.smsApplication?.application&&e?.smsApplication.status!==dee.APPROVED)return void Oe({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:ca.ACTIVE},{onSuccess:()=>{Oe({title:`${Eh("engage:broadcast")} scheduled!`}),e()},onError:()=>{Oe({title:"Oops!",description:"Please contact your administrator",variant:"destructive"})}}):Oe({title:"Oops!",description:a,variant:"destructive"})}catch(n){Oe({title:"Oops!",description:"An error occurred while checking scheduling conditions",variant:"destructive"})}else s({status:ca.ACTIVE}),Oe({title:`${Eh("engage:broadcast")} scheduled!`}),e()})():k(y===jpe.SelectSenders&&1===u.length&&"sms"===u[0]||y===jpe.EditEmailContent&&1===u.length&&"email"===u[0]?y+2:y+1)):Oe({title:"Oops!",description:n,variant:"destructive"})},S=()=>{y>jpe.SelectAudience&&k(y===jpe.EditSmsContent&&1===u.length&&"sms"===u[0]?y-2:y-1)},A=()=>{e()};return n.jsxs("div",{className:"flex-1 flex flex-col @container h-full min-h-0",children:[n.jsxs("header",{className:"w-full flex items-center gap-4 h-16 px-6",children:[n.jsx("h1",{className:"text-xl font-bold leading-none",children:r.name}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsx(JY,{variant:vae(r.status),children:v9({status:r.status,automationType:r.triggerType})})})]}),n.jsxs("main",{className:"flex gap-4 flex-1 min-h-0",children:[n.jsx("div",{className:"hidden @[1000px]:block",children:n.jsx("nav",{className:"space-y-0 w-50 self-start pr-6 pl-8 pt-4 ",children:d.map((e=>n.jsx("div",{className:`\n rounded-md transition-colors\n ${e.step===y?"bg-[var(--reach-secondary)] text-[var(--reach-primary-foreground)] font-medium":e.step<y?"text-muted-foreground hover:bg-muted":"text-muted-foreground/60"}\n `,children:n.jsx(aQ,{label:e.title,isActive:e.step===y,isCompleted:e.isValid(),onClick:async()=>{if(!p)if(e.step>y){const{canMove:a,errorMessage:n,warningMessages:t}=await(async e=>{if(e<=y)return{canMove:!0,errorMessage:null};g(!0);try{const a=[];for(let n=y;n<e;n++){const{canMove:e,errorMessage:t,warningMessage:i}=await c(n);if(!e)return{canMove:e,errorMessage:t};i&&a.push(i)}return{canMove:!0,errorMessage:null,warningMessages:a}}finally{g(!1)}})(e.step);if(a){if(t&&t.length>0)for(const e of t)Oe({title:e,variant:"warning"});k(e.step)}else n&&Oe({title:"Cannot navigate to this step",description:n,variant:"destructive"})}else k(e.step)}})},e.step)))})}),n.jsx("section",{className:"flex-1 mr-6 w-full relative rounded-xl bg-gray-100 ml-6 @[1000px]:ml-0",children:n.jsx("div",{className:" overflow-y-auto top-0 left-0 right-0 bottom-0 flex-1 h-full flex-col flex",children:n.jsx(dV,{children:n.jsx(EY,{className:"pt-0 h-full",children:d.find((e=>e.step===y))?.content},y)})})})]}),n.jsx("footer",{className:"w-full flex justify-end shadow-md z-10 items-center h-16 px-6",children:n.jsx(Tae,{handleSkipAndSaveAsDraft:A,handleBack:S,handleNext:b,hideBack:d.find((e=>e.step===y))?.footerConfig.hideBack??!1,backText:d.find((e=>e.step===y))?.footerConfig.backText??"Back",nextText:d.find((e=>e.step===y))?.footerConfig.nextText??"Next",backDisabled:d.find((e=>e.step===y))?.footerConfig.backDisabled??!1,nextDisabled:d.find((e=>e.step===y))?.footerConfig.nextDisabled()??!1,getInfoTooltipTitle:d.find((e=>e.step===y))?.footerConfig.getInfoTooltipTitle??void 0})})]})},_pe=({children:e,actionId:t})=>{const{setActionId:i}=a.useContext(uY);return a.useEffect((()=>{i(t)}),[t,i]),n.jsx("div",{children:n.jsx(w9,{children:e})})},Dpe=()=>n.jsxs("div",{children:[n.jsx("div",{className:KY,children:n.jsx(zY.OneTimeBroadcast,{})}),n.jsx("h3",{className:HY,children:Eh("engage:broadcast")}),n.jsx("p",{className:OY,children:"Send a single message to your current list, like announcing a sale or newsletter."})]}),Kpe=()=>n.jsxs("div",{children:[n.jsx("div",{className:IY,children:"Coming Soon"}),n.jsx("div",{className:KY,children:n.jsx(zY.RealtimeActivity,{})}),n.jsx("h3",{className:HY,children:"Realtime Activity"}),n.jsx("p",{className:OY,children:"Responds to immediate actions your contacts take, like abandoned carts, form submissions, or appointment bookings."})]}),Hpe=({selectedType:e,setAutomationName:a,automationName:t,setAutomationDescription:i,automationDescription:r})=>n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 max-w-lg mx-auto",children:[n.jsxs("h2",{className:"text-2xl font-semibold mb-8 text-center",children:["Name Your"," ",Eh(e===oa.ONE_TIME?"engage:broadcast":"engage:trigger_based")]}),n.jsxs("div",{className:"w-full space-y-6",children:[n.jsx("div",{className:"bg-gray-50 p-6 rounded-xl items-center justify-center text-center",children:(()=>{switch(e){case oa.ONE_TIME:return n.jsx(Dpe,{});case oa.TRIGGER_BASED:return n.jsx(Kpe,{});default:throw g9(e,oa)}})()}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationName",className:"block text-sm font-medium text-gray-900",children:"Name"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Only visible to your team"})]}),n.jsx(r4,{id:"automationName",type:"text",value:t,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})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationDescription",className:"block text-sm font-medium text-gray-900",children:"Description"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Optional"})]}),n.jsx(iue,{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 ${Eh("engage:broadcast").toLowerCase()}`})]})]})]})]}),Ope=({onClose:e,automationType:t,currentStep:i,setCurrentStep:r,getExtraMergeFields:o,onBeforeSchedule:s})=>{const{createAutomation:l,isCreating:u}=aa(),[c,m]=a.useState(!1),[h,p]=a.useState(void 0),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(t?{name:void 0,description:void 0,type:t}:{name:void 0,description:void 0,type:void 0}),S=void 0!==k.name&&void 0!==k.type&&""!==k.name;a.useEffect((()=>{if(k.type&&!k.name&&!f){const e=new Date,a=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),n=e.toLocaleDateString([],{month:"long",day:"numeric"}),t=`${Eh("engage:broadcast")} ${n} ${a}`,i="";b((e=>({...e,name:t,description:i}))),y(!0)}}),[k,f]);if(u||c)return n.jsx("div",{className:DY,children:n.jsx(NY,{text:[`Creating ${Eh("engage:broadcast")}`,"Finishing up"]})});return n.jsxs("div",{className:GG("relative overflow-y-auto h-full p-8",i===jY.OneTimeWizard?"max-h-[90vh]":"h-full"),children:[n.jsx(dV,{mode:"wait",children:n.jsx(EY,{className:"h-full",children:(()=>{switch(i){case jY.ChooseAutomationType:return n.jsx(GY,{onNext:e=>{b({...k,type:e}),r(jY.SetAutomationName)}});case jY.SetAutomationName:return k.type?n.jsx(Hpe,{selectedType:k.type,setAutomationName:e=>{b({...k,name:e})},automationName:k.name??"",setAutomationDescription:e=>{b({...k,description:e})},automationDescription:k.description??""}):null;case jY.OneTimeWizard:return h&&g?n.jsx(MY,{automationId:h,children:n.jsx(_pe,{actionId:g,children:n.jsx(Rpe,{onFinish:()=>{e?.(h)},getExtraMergeFields:o,onBeforeSchedule:s})})}):null;default:throw tY(i,jY)}})()},i)}),i!==jY.OneTimeWizard&&n.jsx("div",{className:"pt-2",children:n.jsx(LY,{onClose:e,currentStep:i,setCurrentStep:r,isDisabled:!S,createAutomation:async()=>{if(!S||!k.name||!k.type)return;m(!0);l({name:k.name,type:k.type,description:k.description},{onSuccess:async a=>{if(a.id){const n=await(async e=>(await Pe(`${d}`,{method:"POST",body:JSON.stringify(e)})).data)({}),i=nY().toString();await Le(a.id,{action:[{actionType:"send_communication",actionMetadata:{actionType:"send_communication",communicationGroupId:n.id,currentActionId:i}}]}),p(a.id),await Ue({automationId:a.id,actionId:i}),t===oa.ONE_TIME?(r(jY.OneTimeWizard),v(i),m(!1)):e?.(a.id)}else e?.("error")},onError:()=>{e?.("error")},onSettled:()=>{b({name:void 0,description:void 0,type:void 0})}})},disableBackButton:void 0!==t})})]})};function Ipe({open:e,setOpen:t,onClose:i,automationType:r,getExtraMergeFields:o,replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c}){const[d,m]=a.useState(r?jY.SetAutomationName:jY.ChooseAutomationType);return a.useEffect((()=>{e&&m(r?jY.SetAutomationName:jY.ChooseAutomationType)}),[e,r]),n.jsx(SO,{children:n.jsx(AO,{replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c,children:n.jsx(VG,{open:e,onOpenChange:t,children:n.jsxs(WG,{hideCloseButton:d===jY.OneTimeWizard,className:`flex max-h-[86vh] ${d===jY.OneTimeWizard?"max-w-[90vw]":"max-w-4xl"} flex-col gap-0 overflow-visible p-0`,children:[n.jsx(qG,{children:n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs(kO,{children:[n.jsx($G,{className:"text-3xl font-normal",children:"Create Automation"}),n.jsx(YG,{children:"Create a new automation to send messages to your customers."})]})})}),n.jsx(Ope,{onClose:e=>{i?.(e),t(!1)},automationType:r,currentStep:d,setCurrentStep:m,getExtraMergeFields:o})]})})})})}const Gpe=({tabs:e,activeTab:t,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===t))];a&&u({width:a.offsetWidth,left:a.offsetLeft})}),[t,e]);const c=e.find((e=>e.id===t));return n.jsxs("div",{className:"flex flex-col gap-4 w-full overflow-x-hidden h-full",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"relative flex items-center gap-8 "+("left"===r?"w-full justify-start":"w-full justify-center"),children:[n.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)=>n.jsx("button",{ref:e=>s.current[a]=e,onClick:()=>i(e.id),className:GG("relative px-7 py-3 transition-all duration-200 text-lg",t!==e.id&&"text-muted-foreground",o&&"text-sm"),children:e.label},e.id)))]})}),n.jsx("div",{className:"relative overflow-hidden flex-grow min-h-0",children:n.jsx("div",{className:"relative h-full",children:c?c.content:null})})]})},Vpe=e=>{if(!e)return"$0.00";const a="string"==typeof e?e.replace(/,/g,""):e,n=Number(a);return Number.isNaN(n)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},Fpe="reach-styles-module__header___-izE2",Jpe="reach-styles-module__title___n1hA9",Upe="reach-styles-module__description___EvXM-",Wpe="reach-styles-module__content___okv68",qpe="reach-styles-module__footer___YA4U4",Zpe=kc("reach-styles-module__base___zJcoE",{variants:{variant:{default:"reach-styles-module__default___88Q0d",destructive:"reach-styles-module__destructive___5EWhN",outline:"reach-styles-module__outline___gj9sC",secondary:"reach-styles-module__secondary___cN5Wj"}},defaultVariants:{variant:"default"}}),$pe=r.forwardRef((({className:e,variant:a,...t},i)=>n.jsx("div",{ref:i,className:pm(Zpe({variant:a}),e),...t})));$pe.displayName="Card";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Fpe,e),...a}))).displayName="CardHeader";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Jpe,e),...a}))).displayName="CardTitle";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Upe,e),...a}))).displayName="CardDescription";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Wpe,e),...a}))).displayName="CardContent";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(qpe,e),...a}))).displayName="CardFooter";const Ype=({Icon:e,title:a,value:t,tooltipText:i,change:r})=>n.jsxs($pe,{className:"relative flex flex-col justify-between min-h-[130px] transition-all duration-300 hover:shadow-md p-4",children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsx("div",{className:"rounded-lg p-2 bg-primary/10 flex items-center justify-center",children:n.jsx(e,{className:"w-5 h-5 text-primary"})}),n.jsx("div",{className:"absolute top-3 right-3",children:n.jsx(Mae,{title:i})})]}),n.jsxs("div",{className:"mt-4",children:[n.jsx("div",{className:"text-2xl font-bold leading-tight text-primary",children:t}),n.jsx(Fce,{children:a})]}),r&&n.jsx("div",{className:"absolute bottom-3 right-3",children:n.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})})]}),Qpe=({activeTab:e,automation:a})=>{if(!a)return null;const t={sales:[{Icon:zY.SalesAmount,title:"Order Amount",value:Vpe(a.derivedRevenue),tooltipText:"Total derived revenue from this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(Ype,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},Xpe=({activeTab:e,statistics:a})=>{const t={email:[{Icon:zY.MessagesSent,title:"Emails Sent",value:a.email.numberSent,tooltipText:"Total number of emails that were successfully sent in this campaign"},{Icon:zY.OpenRate,title:"Open Rate",value:`${(100*a.email.openPercentage).toFixed(2)}%`,tooltipText:"Percentage of recipients who opened the email out of total emails delivered"},{Icon:zY.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"},{Icon:zY.LinksClicked,title:"Links Clicked",value:a.email.linksClicked,tooltipText:"Total number of times recipients clicked on links within the email"},{Icon:zY.SpamComplies,title:"Spam Complaints",value:`${(100*a.email.spamComplaintRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who marked this email as spam"},{Icon:zY.UnsubscribeRate,title:"Unsubscribe Rate",value:`${(100*a.email.unsubscribedRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who unsubscribed after receiving this email"}],sms:[{Icon:zY.MessagesSent,title:"SMS Sent",value:a.sms.numberSent,tooltipText:"Total number of SMS messages that were successfully sent in this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(Ype,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},ege=({automationId:e,includeSales:t=!1,includeSms:i=!1,automation:r})=>{const[o,s]=a.useState("email"),{statistics:l,isLoading:u}=ta(e);if(u||!l)return n.jsx("div",{className:"bg-white rounded-2xl w-full p-6 space-y-4 relative h-[14.05rem]",children:n.jsx(NY,{text:[`Fetching ${Eh("engage:insight",{count:2})}`,"Finishing up"]})});const c=[{id:"email",label:`Email ${Eh("engage:insight",{count:2})}`,content:n.jsx(Xpe,{activeTab:"email",statistics:l})},...i?[{id:"sms",label:`SMS ${Eh("engage:insight",{count:2})}`,content:n.jsx(Xpe,{activeTab:"sms",statistics:l})}]:[],...t?[{id:"sales",label:`Sales ${Eh("engage:insight",{count:2})}`,content:n.jsx(Qpe,{activeTab:"sales",automation:r})}]:[]];return n.jsx(Gpe,{tabs:c,activeTab:o,onTabChange:e=>s(e),tabsLocation:"left"})},age={all:["website"],content:()=>[...age.all,"content"],analyze:()=>[...age.all,"analyze"],brandSettings:()=>[...age.all,"brand-settings"]},nge=async()=>(await Pe("/web-presence/brand-settings",{method:"POST"})).data,tge=({isLoading:e,brandSettings:t,onComplete:i})=>{const[r,o]=a.useState(0),s=[{text:"Analyzing your brand palette",icon:ed},{text:"Extracting your visual identity",icon:Ic},{text:"Discovering your brand personality",icon:Vc},{text:"Crafting your email style",icon:Zc},{text:"Finalizing your brand profile",icon:Rc}];a.useEffect((()=>{if(!e)return;const a=setInterval((()=>{o((e=>{const n=e+1;return n>=s.length?(clearInterval(a),setTimeout((()=>{i()}),1500),e):n}))}),2500);return()=>clearInterval(a)}),[e,i,s.length]);return n.jsx(Z$.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:n.jsxs("div",{className:"flex flex-col items-center gap-8 max-w-2xl w-full",children:[n.jsx(Z$.div,t?.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:n.jsx("img",{src:t.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:t?.brandName?n.jsx("span",{className:"text-4xl sm:text-5xl font-bold text-white",children:t.brandName.charAt(0)}):n.jsx(md,{className:"w-12 h-12 sm:w-16 sm:h-16 text-white"})}),n.jsx(Z$.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}`),n.jsx("div",{className:"flex items-center justify-center space-x-8 sm:space-x-12",children:s.map(((e,a)=>{const t=a<=r,i=a===r;return n.jsxs(Z$.div,{className:"relative flex items-center justify-center w-12 h-12 rounded-full border-2 "+(t?"bg-card shadow-md border-primary":"bg-muted border-muted-foreground/30"),initial:{scale:.8,opacity:.5},animate:{scale:i?1.1:1,opacity:t?1:.5},transition:{duration:.3},children:[n.jsx(e.icon,{className:"w-5 h-5 "+(t?"text-primary":"text-muted-foreground")}),i&&n.jsx(Z$.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}`)}))}),n.jsx(Z$.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8,duration:.6},className:"w-full",children:n.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:n.jsxs("div",{className:"h-full flex flex-col justify-center",children:[0===r&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80 text-center",children:"Extracted Color Palette"}),n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[t?.primaryColor,...t?.secondaryColors||[]]?.slice(0,4).map(((e,a)=>n.jsx("div",{className:"flex flex-col items-center gap-1",children:n.jsx("div",{className:"w-10 h-10 rounded-xl border-2 border-white/50 shadow-md",style:{backgroundColor:e}})},a)))}),n.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"Brand colors identified"})]}),1===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Identity"}),t?.brandName?n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xl font-bold",children:t.brandName}),t.brandTagline&&n.jsxs("div",{className:"text-sm text-muted-foreground italic px-4",children:['"',t.brandTagline,'"']}),n.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Visual identity extracted"})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Extracting brand elements..."})]}),2===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Personality"}),t?.brandPersonality?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-center gap-4",children:[t.brandPersonality.tone&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Tone"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.tone})]}),t.brandPersonality.voice&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Voice"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.voice})]})]}),t.brandPersonality.values&&t.brandPersonality.values.length>0&&n.jsx("div",{className:"flex justify-center gap-1 flex-wrap",children:t.brandPersonality.values.slice(0,3).map(((e,a)=>n.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full",children:e},a)))})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand tone and voice..."})]}),3===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Email Template Preview"}),n.jsxs("div",{className:"bg-background/60 rounded-lg p-3 border border-border/30",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("div",{className:"w-4 h-4 rounded"}),n.jsx("div",{className:"text-xs font-medium text-foreground",children:t?.brandName||"Your Brand"})]}),n.jsxs("div",{className:"text-xs text-muted-foreground text-left",children:["Email styling applied with your brand colors",t?.brandPersonality?.tone&&`, ${t.brandPersonality.tone} tone`,", and visual identity"]})]})]}),4===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Kit Complete"}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Identity"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandName?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Colors"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.primaryColor?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Personality"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandPersonality?.tone?"✓":"—"})]})]})]}),(0===r&&!t?.primaryColor&&!t?.colorPalette||1===r&&!t?.brandName||2===r&&!t?.brandPersonality)&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand data..."}),n.jsx("div",{className:"flex justify-center gap-1 mt-2",children:[...Array(3)].map(((e,a)=>n.jsx(Z$.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}`)]})})},ige=({setAutoParse:e,onBrandSettingsGenerated:t,onForceRefresh:i})=>{const{data:r,updateWebsite:o,isUpdatingWebsite:s,updateBrandSettings:l}=joe(),u=ke({mutationFn:nge,mutationKey:age.brandSettings()}),[c,d]=a.useState(r?.website||""),[m,h]=a.useState(!1),[p,g]=a.useState(null),[v,f]=a.useState(!1),[y,k]=a.useState(!1),b=()=>{e(!1)};return y&&p?n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(oge,{initialBrandSettings:p,onSave:()=>{p&&(l({logoBase64:p.logo_base64,primaryColor:p.primaryColor,secondaryColors:p.secondaryColors,brandTagline:p.brandTagline,brandName:p.brandName,brandPersonality:p.brandPersonality,colorPalette:p.colorPalette}),i&&i(),Oe({title:"Brand settings saved successfully 🚀",description:"Your brand identity has been updated."}),e(!1))},onBack:b,showAutoParseButton:!1})},"results"):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden",children:[n.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:n.jsxs(dV,{mode:"wait",children:[!v&&!y&&n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col h-full",children:n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 space-y-8",children:[n.jsxs("div",{className:"space-y-2 w-full max-w-md",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block text-center",children:"Your Website URL"}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center",children:[n.jsx(r4,{type:"url",value:c,onChange:e=>d(e.target.value),placeholder:"https://example.com",className:"flex-1",disabled:!m}),n.jsx(dV,{mode:"wait",children:m?n.jsxs(Z$.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2",children:[n.jsx(PY,{variant:"outline",size:"sm",onClick:()=>{h(!1),d(r?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),n.jsx(PY,{size:"sm",onClick:async()=>{try{o(c),h(!1),Oe({title:"Website URL updated successfully 🎉",description:"Your website URL has been saved."})}catch(e){Oe({title:"Error updating website URL",description:"Please try again.",variant:"destructive"})}},disabled:s||!c,className:"w-full sm:w-auto",children:s?n.jsx(NY,{}):"Save Changes"})]},"save"):n.jsx(Z$.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:n.jsx(PY,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl",children:[n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"What we'll analyze"}),n.jsxs("ul",{className:"text-sm text-gray-600 space-y-1",children:[n.jsx("li",{children:"• Your brand colors and color palette"}),n.jsx("li",{children:"• Your logo (if detectable)"}),n.jsx("li",{children:"• Your brand name and tagline"}),n.jsx("li",{children:"• Your brand's tone and personality"})]})]}),n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"How it helps you"}),n.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."})]})]}),n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground text-center max-w-md",children:"We'll use AI to analyze your website and extract your brand elements to create perfectly matched email templates."})]})},"url-confirmation"),v&&p&&n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(tge,{isLoading:v,brandSettings:p,onComplete:()=>{f(!1),k(!0),Oe({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})}})},"analyzing"),v&&!p&&n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col items-center justify-center h-full",children:n.jsxs(Z$.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:[n.jsxs(Z$.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:[n.jsx(sd,{className:"w-12 h-12 text-primary drop-shadow-md"}),n.jsx(Z$.div,{className:"absolute inset-0 rounded-full border-2",style:{borderColor:"var(--primary)"},initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]}),n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:"Analyzing your website"}),n.jsx(dV,{mode:"wait",children:n.jsx(Z$.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-gray-600 max-w-md text-center px-4",children:"Generating your brand's unique visual identity and personality"},"loading-message")})]})]})},"pre-analyzing")]})}),!v&&!y&&n.jsxs(ZG,{className:"p-4",children:[n.jsx(PY,{variant:"outline",onClick:b,className:"gap-1",children:"Go Back"}),n.jsxs(PY,{onClick:async()=>{try{f(!0);const e=await u.mutateAsync();g(e),t&&t(e)}catch(e){f(!1),g(null),Oe({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}},disabled:!c||u.isPending,className:"gap-1",children:[n.jsx(md,{className:"h-4 w-4 text-amber-500"}),u.isPending?n.jsx(NY,{}):"Analyze Website"]})]})]})},rge=["#a91919","#2563eb","#16a34a","#f59e0b","#6d28d9"],oge=({initialBrandSettings:e,onSave:t,onBack:i,showAutoParseButton:r=!0})=>{const{data:o,isLoading:s,updateBrandSettings:l,isUpdatingBrandSettings:u}=joe(),[c,d]=a.useState({}),[m,h]=a.useState(!1),[p,g]=a.useState({}),[v,f]=a.useState(""),[y,k]=a.useState(""),[b,S]=a.useState("#000000"),[A,w]=a.useState(Date.now()),[C,M]=a.useState(!1),[T,N]=a.useState(null),[E,x]=a.useState({identity:!0,colors:!0,personality:!0}),P=a.useRef(null),{toast:j}=Ie();a.useEffect((()=>{if(e)return d({brandName:e.brandName,brandTagline:e.brandTagline,logoUrl:e.logoUrl,primaryColor:e.primaryColor||"#000000",secondaryColors:e.secondaryColors||[],brandPersonality:{tone:e.brandPersonality?.tone,voice:e.brandPersonality?.voice,values:e.brandPersonality?.values||[]}}),void w(Date.now());o?.branding&&(d({brandName:o.branding.brandName||o.name,brandTagline:o.branding.brandTagline||"",logoUrl:o.branding.logoUrl||"",primaryColor:o.branding.primaryColor||"#000000",secondaryColors:o.branding.secondaryColors||[],brandPersonality:{tone:o.branding.brandPersonality?.tone,voice:o.branding.brandPersonality?.voice,values:o.branding.brandPersonality?.values||[]}}),w(Date.now()))}),[o,e]);const L=e=>{x((a=>({...a,[e]:!a[e]})))},B=e=>{g((a=>{const n={...a,[e]:!a[e]};return n[e]&&("brandName"===e?f(c.brandName||""):"brandTagline"===e?f(c.brandTagline||""):"primaryColor"===e?f(c.primaryColor||"#000000"):"tone"===e?f(c.brandPersonality?.tone||""):"voice"===e&&f(c.brandPersonality?.voice||"")),n}))},z=e=>{"brandName"===e?d((e=>({...e,brandName:v}))):"brandTagline"===e?d((e=>({...e,brandTagline:v}))):"primaryColor"===e?d((e=>({...e,primaryColor:v}))):"tone"===e?d((e=>({...e,brandPersonality:{...e.brandPersonality,tone:v||void 0}}))):"voice"===e&&d((e=>({...e,brandPersonality:{...e.brandPersonality,voice:v||void 0}}))),B(e)},R=e=>{B(e)},_=e=>{d((a=>({...a,primaryColor:e})))},D=()=>{y.trim()&&(d((e=>{const a=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:[...a,y.trim()]}}})),k(""))};return s?n.jsx("div",{className:"flex justify-center items-center h-full min-h-[500px] w-full bg-white rounded-lg shadow-sm",children:n.jsx(NY,{})}):m?n.jsx(ige,{setAutoParse:h,onForceRefresh:()=>w(Date.now())}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden gap-4 pt-16",children:[n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 px-6 pt-2",children:[n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("identity"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Identity"})]}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(E.identity?Lc:xc,{className:"h-4 w-4"})})]}),E.identity&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Name"}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("brandName"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandName?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandName"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>z("brandName"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm font-medium",children:c.brandName})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Tagline"}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("brandTagline"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandTagline?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0,placeholder:"Your brand's tagline"}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandTagline"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>z("brandTagline"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm italic",children:c.brandTagline||"No tagline set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-3",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Logo"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Square image, 128x128px, PNG recommended"})]})}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-dashed border-gray-200 flex items-center justify-center bg-gray-50 overflow-hidden",children:c.logoUrl?n.jsx("img",{src:c?.logoUrl,alt:c.brandName||"Brand logo",className:"w-full h-full object-contain"},A):n.jsx(Fc,{className:"h-10 w-10 text-gray-300"})}),n.jsxs("div",{className:"absolute inset-0 bg-black bg-opacity-40 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:[n.jsx("input",{type:"file",ref:P,onChange:e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{const n=e.result.split(",")[1];N(n);const t=URL.createObjectURL(a);d((e=>({...e,logoUrl:t}))),w(Date.now()),l({logoBase64:n})},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsxs(PY,{variant:"ghost",size:"sm",onClick:()=>{P.current?.click()},className:"text-white hover:text-white hover:bg-black hover:bg-opacity-20",children:[n.jsx(vd,{className:"h-4 w-4 mr-1"}),"Update"]})]})]}),c.logoUrl&&n.jsxs("div",{className:"flex-1 flex items-center gap-2 max-w-md bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx("div",{className:"flex-1 truncate text-sm text-gray-600 font-mono",children:c.logoUrl}),n.jsxs(PY,{variant:"ghost",size:"sm",onClick:async()=>{if(c.logoUrl)try{await navigator.clipboard.writeText(c.logoUrl),M(!0),setTimeout((()=>M(!1)),1500),j({title:"Logo URL copied to clipboard"})}catch(cBe){try{const e=document.createElement("textarea");e.value=c.logoUrl,e.style.position="fixed",e.style.left="-9999px",document.body.appendChild(e),e.focus(),e.select();const a=document.execCommand("copy");if(document.body.removeChild(e),!a)throw new Error("Fallback copy command failed");M(!0),setTimeout((()=>M(!1)),1500),j({title:"Logo URL copied to clipboard"})}catch(e){j({title:"Failed to copy URL",description:"Could not copy the URL to clipboard. Please try again or copy manually.",variant:"destructive"})}}},className:"h-7 px-2 text-xs shrink-0",children:[C?n.jsx(Ec,{className:"h-3.5 w-3.5 mr-1 text-green-500"}):n.jsx(Hc,{className:"h-3.5 w-3.5 mr-1"}),C?"Copied":"Copy"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("colors"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Colors"})]}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(E.colors?Lc:xc,{className:"h-4 w-4"})})]}),E.colors&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Primary Color"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Your main brand color used throughout the interface"})]}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("primaryColor"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("div",{className:"w-14 h-14 rounded-lg shadow-md",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsxs("div",p.primaryColor?{className:"flex flex-1 gap-2 max-w-sm",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(ed,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),n.jsx(r4,{type:"text",value:v,onChange:e=>f(e.target.value),className:"pl-10 h-10 font-mono text-sm flex-1",placeholder:"#000000",maxLength:7,autoFocus:!0})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("primaryColor"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>z("primaryColor"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}:{className:"flex-1 max-w-sm",children:[n.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx(ed,{className:"h-4 w-4 text-gray-400"}),n.jsx("div",{className:"text-sm font-mono",children:c.primaryColor||"#000000"})]}),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx(r4,{type:"color",value:c.primaryColor||"#000000",onChange:e=>_(e.target.value),className:"w-8 h-8 p-1 cursor-pointer rounded-md"}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:rge.map(((e,a)=>n.jsx(PY,{variant:"ghost",size:"icon",className:"w-6 h-6 rounded-full border border-gray-200 "+(c.primaryColor===e?"ring-2 ring-gray-400 ring-offset-1":""),style:{backgroundColor:e},onClick:()=>_(e)},a)))})]})]})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Secondary Colors"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Additional colors that complement your primary brand color"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"flex flex-wrap gap-3 mb-4",children:c.secondaryColors?.length?c.secondaryColors.map(((e,a)=>n.jsxs("div",{className:"group relative flex flex-col items-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-lg shadow-sm border border-gray-200 mb-1 group-hover:ring-2 ring-gray-200",style:{backgroundColor:e}}),n.jsx("div",{className:"text-xs font-mono text-gray-600",children:e}),n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.secondaryColors||[];return{...e,secondaryColors:n.filter((e=>e!==a))}}));var a},className:"absolute -top-1 -right-1 w-5 h-5 bg-white rounded-full shadow border border-gray-200 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(bd,{className:"w-3 h-3 text-gray-500"})})]},a))):n.jsx("div",{className:"text-sm text-gray-500 italic my-2",children:"No secondary colors set"})}),n.jsxs("div",{className:"flex items-end gap-3",children:[n.jsxs("div",{className:"flex-1 max-w-xs",children:[n.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Add color"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx(r4,{type:"color",value:b,onChange:e=>S(e.target.value),className:"w-10 h-10 p-1 cursor-pointer rounded-md"}),n.jsx(r4,{type:"text",value:b,onChange:e=>S(e.target.value),className:"h-10 font-mono text-sm",placeholder:"#000000",maxLength:7})]})]}),n.jsxs(PY,{variant:"outline",onClick:()=>{b&&(d((e=>{const a=e.secondaryColors||[];return{...e,secondaryColors:[...a,b]}})),S("#000000"))},className:"h-10",children:[n.jsx(rd,{className:"h-4 w-4 mr-1"}),"Add Color"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("personality"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Personality"})]}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(E.personality?Lc:xc,{className:"h-4 w-4"})})]}),E.personality&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Tone"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"The overall feeling and attitude your brand conveys"})]}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("tone"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.tone?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("tone"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>z("tone"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.tone||"No tone set"})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Voice"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"How your brand expresses itself in communication"})]}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("voice"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.voice?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("voice"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>z("voice"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.voice||"No voice set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Values"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Core principles and beliefs that drive your brand"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"mb-4",children:n.jsx("div",c.brandPersonality?.values&&c.brandPersonality.values.length>0?{className:"flex flex-wrap gap-2",children:c.brandPersonality.values.map(((e,a)=>n.jsxs(JY,{variant:"outline",className:"px-3 py-1.5 border-2 hover:border-red-100 group transition-colors text-primary",style:{borderColor:`${c.primaryColor}30`||"#f3f4f6",backgroundColor:`${c.primaryColor}08`||"#f9fafb"},children:[e,n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:n.filter((e=>e!==a))}}}));var a},className:"ml-1.5 w-4 h-4 flex items-center justify-center rounded-full bg-gray-200 hover:bg-red-100 hover:text-red-500 transition-colors",children:n.jsx(bd,{className:"w-2.5 h-2.5"})})]},a)))}:{className:"text-sm text-gray-500 italic py-2",children:"No brand values set"})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{placeholder:"Add a brand value",value:y,onChange:e=>k(e.target.value),className:"flex-1",onKeyDown:e=>"Enter"===e.key&&D()}),n.jsxs(PY,{variant:"outline",onClick:D,disabled:!y.trim(),children:[n.jsx(rd,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})]})]})]}),n.jsxs(ZG,{className:"pb-4 px-6",children:[i?n.jsx(PY,{variant:"outline",className:"gap-1.5",onClick:i,children:"Go Back"}):r&&n.jsxs(PY,{variant:"outline",className:"gap-1.5",onClick:()=>{h(!0)},children:[n.jsx(md,{className:"h-4 w-4 text-amber-500"}),"Auto Parse"]}),n.jsx(PY,{className:"px-4",onClick:async()=>{let e;T?e=T:c.logoUrl?.startsWith("data:image/png;base64,")?e=c.logoUrl.split(",")[1]:c.logoUrl?.startsWith("blob:")&&(e=void 0),l({brandName:c.brandName,brandTagline:c.brandTagline,logoBase64:e,primaryColor:c.primaryColor,secondaryColors:c.secondaryColors,brandPersonality:c.brandPersonality}),j({title:"Brand settings saved 🚀"}),t&&t(),N(null)},disabled:u,children:u?"Saving":"Save Changes"})]})]})},sge=oee.object({channelSenderId:oee.string().min(1,"Please select a channel sender"),replyTo:oee.string().trim().min(1).email("Please enter a valid email address").or(oee.literal("").transform((()=>null))).or(oee.null()).optional(),fromName:oee.string().trim().min(1).or(oee.literal("").transform((()=>null))).or(oee.null()).optional()}),lge=()=>{const{channelSenders:e,isLoading:t}=E9(),{channelAccounts:i,isLoading:r}=M9(),{updateChannelSender:o,isUpdating:s}=x9(),{toast:l}=Ie(),u=soe({resolver:hoe(sge),defaultValues:{channelSenderId:"",replyTo:"",fromName:""}}),c=a.useMemo((()=>zie({channelSenders:e?.results??[],channelAccounts:i?.results??[]})),[e?.results,i?.results]);if(a.useEffect((()=>{if(c&&c.length>0&&!u.getValues("channelSenderId")){const e=c[0];u.setValue("channelSenderId",e.channelSenderId),u.setValue("replyTo",e.channelSender.channelSenderMetadata.emailReplyTo??""),u.setValue("fromName",e.channelSender.channelSenderMetadata.emailFromName??"")}}),[c,u]),t||void 0===e||r||void 0===i)return n.jsx("div",{className:"flex justify-center items-center h-full py-10",children:n.jsx(NY,{})});return n.jsxs("div",{className:"w-full max-w-4xl mx-auto mt-8",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-gray-900 mb-1",children:"Set up Your Email Channel"}),n.jsx("p",{className:"text-muted-foreground text-base",children:"Define your default sender name, email address, and reply-to to start sending emails with confidence."})]}),n.jsx(poe,{...u,children:n.jsxs("form",{onSubmit:u.handleSubmit((async e=>{const a=c.find((a=>a.channelSenderId===e.channelSenderId));a&&o({toUpdate:{channelSenderMetadata:{...a.channelSender.channelSenderMetadata,emailReplyTo:e.replyTo?e.replyTo:`noreply@${a.baseDomain??""}`,emailFromName:e.fromName?e.fromName:null}},id:a.channelSender.id},{onSuccess:()=>{l({title:"Email channel sender updated successfully!"})},onError:()=>{l({title:"Failed to update email channel sender",description:"Please contact your administrator",variant:"destructive"})}})})),className:"bg-white border border-gray-200 rounded-2xl shadow-sm p-8 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[n.jsx(boe,{className:"flex items-center gap-1 text-base font-medium mb-2",children:"Email Channel Sender"}),n.jsxs(hie,{value:u.watch("channelSenderId"),onValueChange:e=>{u.setValue("channelSenderId",e);const a=c.find((a=>a.channelSenderId===e));a&&u.setValue("replyTo",a.channelSender.channelSenderMetadata.emailReplyTo??"")},children:[n.jsx(vie,{className:"w-full bg-gray-50 border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 rounded-lg min-h-[48px] text-base",children:n.jsx(gie,{placeholder:"Select a sender"})}),n.jsx(kie,{children:c.map((e=>n.jsx(bie,{value:e.channelSenderId,children:n.jsxs("div",{className:"flex flex-col text-left",children:[n.jsx("span",{className:"font-medium",children:e.fullDomain}),n.jsx("span",{className:"text-xs text-muted-foreground",children:e.channelSender.channelSenderMetadata.emailReplyTo||"No reply-to set"})]})},e.channelSenderId)))})]})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(boe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["Reply-to Email",n.jsx(Mae,{title:"Reply to email to use when the reply button is clicked"})]}),n.jsxs("span",{className:"text-xs text-muted-foreground font-normal mb-1",children:["Optional – will use"," ",n.jsx("span",{className:"font-mono",children:u.watch("channelSenderId")?`noreply@${c.find((e=>e.channelSenderId===u.watch("channelSenderId")))?.baseDomain}`:"sender domain"})," ","if empty"]}),n.jsx(Moe,{control:u.control,name:"replyTo",type:"email",placeholder:"Replies from recipients will go to this email (optional)"})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(boe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["From Name",n.jsx(Mae,{title:"From name to use when the email is sent"})]}),n.jsx(Moe,{control:u.control,name:"fromName",placeholder:"From name to use when the email is sent (optional)"})]}),n.jsx("div",{className:"flex gap-3 pt-4 justify-end border-t border-gray-100",children:n.jsx(PY,{type:"submit",disabled:s,className:"min-w-[120px]",children:s?"Saving...":"Save"})})]})})]})},uge=()=>{const[e,t]=a.useState(null),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),{data:o}=L9(),s=mee({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o});a.useEffect((()=>{s.length>0&&s.some((e=>e.smsApplication?.status===dee.APPROVED||!e.smsApplication))?t(!0):t(!1)}),[s,o]);const l={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}};if(null===e)return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(NY,{})});const u=s.some((e=>e.smsApplication?.status===dee.APPROVED));return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:e?n.jsxs(Z$.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:pm("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto mb-16","bg-background"),children:[n.jsx(Z$.div,{variants:l,className:"w-16 h-16 rounded-xl flex items-center justify-center bg-green-50",children:n.jsx(zY.SmsIcon,{className:"text-green-600"})}),n.jsx(Z$.h2,{variants:l,className:"text-lg font-medium text-foreground",children:"SMS Sending Number Active"}),n.jsx(Z$.div,{variants:l,className:"max-w-xl mx-auto",children:n.jsx("p",u?{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!"})}),n.jsxs(Z$.div,{variants:l,className:"flex items-center gap-2 px-4 py-2 bg-green-50 border border-green-200 rounded-full mt-2",children:[n.jsx(Z$.div,{animate:{scale:[1,1.2,1],opacity:[1,.8,1]},transition:{duration:2,repeat:Number.POSITIVE_INFINITY,ease:"easeInOut"},className:"w-2 h-2 bg-green-500 rounded-full"}),n.jsx("span",{className:"text-sm font-medium text-green-800",children:"Ready to send"})]})]}):n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(Noe,{})})})};function cge({tabs:e,activeTab:a,onTabChange:t,title:i}){return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{className:"w-48 py-2 pl-4",children:[i&&n.jsx("h2",{className:"px-4 pt-4 pb-5 text-lg font-medium",children:i}),e.map((e=>n.jsx(PY,{variant:"ghost",className:pm("w-full justify-start mb-1",a===e.id&&"bg-accent"),onClick:()=>t(e.id),children:e.label},e.id)))]}),n.jsx("div",{className:"flex-1 overflow-y-auto pl-6 pr-4 pb-4",children:e.find((e=>e.id===a))?.content})]})}function dge({open:e,setOpen:t}){const[i,r]=a.useState("brand");a.useEffect((()=>{e&&r("brand")}),[e]);const o=[{id:"brand",label:"Brand",content:n.jsx(oge,{})},{id:"email-channel",label:"Email Channel",content:n.jsx(lge,{})},{id:"sms-channel",label:"SMS Channel",content:n.jsx(uge,{})}];return n.jsx(VG,{open:e,onOpenChange:t,children:n.jsxs(WG,{className:"flex w-[90vw] h-[90vh] flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl xl:max-w-5xl p-0",children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Settings"}),n.jsx(YG,{children:"Edit your business and brand settings"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(cge,{tabs:o,activeTab:i,onTabChange:r,title:"Settings"})})]})})}const mge=e=>{const{updateAutomation:n,updateError:t,isUpdateSuccess:i}=na(e),{toast:r}=Ie();return a.useEffect((()=>{i?r({title:"Status updated",description:"The status has been updated successfully"}):t&&r({title:"Error updating status",description:"Please try again",variant:"destructive"})}),[i,t,r]),{toggleStatus:async e=>{try{return await n({status:e?ca.ACTIVE:ca.DRAFT}),!0}catch(a){return r({title:"Error updating status",description:"Please try again",variant:"destructive"}),!1}}}};function hge(){const{toast:e}=Ie(),[t,i]=a.useState(null),{toggleStatus:r}=mge(t||""),o=r5(),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{automations:h,nextCursor:p,isLoading:g,error:v,isFetching:f,isPlaceholderData:y}=ia({cursor:u,limit:s,triggerType:oa.TRIGGER_BASED,search:d||void 0});a.useEffect((()=>{v&&e({title:`Error Fetching ${Eh("engage:automation")}`,description:v?.message||"Please try again.",variant:"destructive"})}),[v,e]);const k=a.useMemo((()=>(h||[]).map((e=>({...e,emailsSent:0,smsSent:0,updated_at:e.updatedAt||e.createdAt})))),[h]),b=a.useCallback((async(e,a)=>{try{i(e);const n=a===ca.ACTIVE;await r(n)}finally{i(null)}}),[r,i]),S=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]),A=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),w=a.useMemo((()=>Cae({automationName:Eh("engage:automation"),setUrl:A,onToggle:b,vsaasManaged:!0})),[b,A]);return n.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx(s4,{data:k,columns:w,paginationMode:"cursor",initialPageSize:s,isLoading:g&&!y,onRowClick:e=>{o(`/automations/view-modal/${e.id}?showBackButton=true`)},cursorPaginationQueryResult:{nextCursor:p,isLoading:g,isFetching:f,isPlaceholderData:y},onQueryParametersChange:S,searchValue:d,onSearchChange:m})})})}function pge(){const{toast:e}=Ie(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{toggleStatus:s}=mge(r||""),l=r5(),[u,c]=a.useState(10),[d,m]=a.useState(void 0),[h,p]=a.useState(""),{automations:g,nextCursor:v,isLoading:f,error:y,isFetching:k,isPlaceholderData:b}=ia({cursor:d,limit:u,triggerType:oa.ONE_TIME,search:h||void 0});a.useEffect((()=>{y&&e({title:`Error Fetching ${Eh("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]),A=a.useCallback((async(e,a)=>{try{o(e);const n=a===ca.ACTIVE;await s(n)}finally{o(null)}}),[s,o]),w=a.useCallback((e=>{m(e.cursor),c(e.pageSize)}),[]),C=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),M=a.useMemo((()=>Cae({automationName:Eh("engage:broadcast"),setUrl:C,onToggle:A,pillForStatus:!0})),[A,C]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx(s4,{data:S,columns:M,paginationMode:"cursor",initialPageSize:u,headerActions:n.jsxs(PY,{className:"bg-primary",onClick:()=>i(!0),children:[n.jsx(rd,{className:"h-4 w-4 mr-1"}),"New"]}),isLoading:f&&!b,cursorPaginationQueryResult:{nextCursor:v,isLoading:f,isFetching:k,isPlaceholderData:b},onRowClick:e=>{l(`/automations/view-modal/${e.id}?showBackButton=true`)},onQueryParametersChange:w,searchValue:h,onSearchChange:p})}),n.jsx(Ipe,{open:t,setOpen:i,onClose:a=>{gae(i,e,a,`Error creating ${Eh("engage:broadcast")}`,"Please try again"),m(void 0),c(10),p(""),!1!==a&&l(`/automations/view-modal/${a}?showBackButton=true`)},automationType:oa.ONE_TIME})]})}function gge(){const{toast:e}=Ie(),[t,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:v,isPlaceholderData:f}=pY({search:d||void 0,cursor:u,limit:s}),y=a.useCallback((e=>{o(e),i(!0)}),[o]),k=a.useMemo((()=>function(e){return[yae("name",`${Eh("engage:segment")} Name`,!0),kae(),pae({accessorKey:"user_count",header:Eh("engage:user_other"),meta:{align:"right",displayName:Eh("engage:user_other")},cellClassName:"text-muted-foreground pr-4",cellFormatter:e=>{const a=e.getValue()??0;return`${a.toLocaleString()} ${1===a?Eh("engage:user").toLowerCase():Eh("engage:user_other").toLowerCase()}`}}),bae("user_count_updated_at"),wae(e||(()=>{}))]}(y)),[y]),b=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((()=>n.jsxs(PY,{onClick:()=>{o(null),i(!0)},children:[n.jsx(rd,{className:"h-4 w-4"}),"New List"]})),[]),A=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx(s4,{data:b,columns:k,paginationMode:"cursor",initialPageSize:s,headerActions:S,isLoading:p&&!f,cursorPaginationQueryResult:{nextCursor:g,isLoading:p,isFetching:v,isPlaceholderData:f},onQueryParametersChange:A,onRowClick:a=>{a.type!==kY.MANAGED?(o(a.id),i(!0)):e({title:`Managed ${Eh("engage:segment")} cannot be edited!`,variant:"destructive"})},searchValue:d,onSearchChange:m})}),n.jsx(bpe,{open:t,setOpen:i,segmentId:r??void 0,onSegmentUpdated:a=>{gae(i,e,a,`Error creating ${Eh("engage:segment")}`,"Please try again"),c(void 0),l(10),m("")}})]})}const vge=()=>{const e=ce(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{automations:s,isLoading:l}=ia({triggerType:oa.TRIGGER_BASED}),[u,c]=a.useState();return a.useEffect((()=>{e.prefetchQuery({queryKey:je.list()}),e.prefetchQuery({queryKey:mY.lists()})}),[e]),a.useEffect((()=>{if(l||void 0===s)return;const e=[{id:"broadcasts",label:Eh("engage:broadcast",{count:2}),content:n.jsx(pge,{})},{id:"segments",label:Eh("engage:segment",{count:2}),content:n.jsx(gge,{})},{id:"statistics",label:Eh("engage:insight",{count:2}),content:n.jsx(ege,{})}];s.length>0?(o("automations"),c([{id:"automations",label:Eh("engage:automation",{count:2}),content:n.jsx(hge,{})},...e])):(o("broadcasts"),c(e))}),[s,l]),null===r||null==u?n.jsx("div",{className:"w-full h-full flex justify-center items-center",children:n.jsx(NY,{})}):n.jsxs("div",{className:"w-full h-full flex flex-col gap-4",children:[n.jsx(dge,{open:t,setOpen:i}),n.jsx("div",{className:"flex justify-end",children:n.jsx(PY,{variant:"outline",onClick:()=>i(!0),children:n.jsx(cd,{className:"w-4 h-4"})})}),n.jsx("div",{className:"flex-1 w-full h-full flex flex-col gap-4",children:n.jsx(Gpe,{activeTab:r,tabs:u,onTabChange:o})})]})};function fge({value:e,schema:t,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),[v,f]=a.useState(0),[y,k]=a.useState(e),[b,S]=a.useState(e),A=a.useRef(null),w=a.useRef(null),C=a.useRef(null),M=a.useRef(null),{toast:T}=Ie(),N=soe({resolver:hoe(t),defaultValues:{[r]:e}});a.useEffect((()=>{N.reset({[r]:e}),k(e),S(e)}),[e,r,N]),a.useEffect((()=>{w.current&&g(w.current.offsetWidth),M.current&&!c&&f(M.current.offsetWidth)}),[c]),a.useEffect((()=>{C.current&&y&&g(C.current.offsetWidth)}),[y]),a.useEffect((()=>{c&&A.current&&(A.current.focus(),A.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(n){T({variant:"destructive",title:l})}finally{h(!1)}},x=()=>{N.reset(),d(!1),k(b)},P=e=>{"Escape"===e.key&&x()};return c?n.jsx(poe,{...N,children:n.jsxs("form",{onSubmit:N.handleSubmit(E),className:GG("inline-flex items-center gap-2 min-h-[20px]",o),style:{minWidth:v?`${v}px`:"auto"},children:[n.jsx("span",{ref:C,className:"absolute invisible whitespace-pre leading-none select-none pointer-events-none",style:{font:"inherit"},children:y||b}),n.jsx(voe,{control:N.control,name:r,render:({field:e})=>n.jsx(koe,{className:"flex-1 min-w-0",children:n.jsx(Soe,{children:n.jsx("input",{...e,ref:A,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),k(a.target.value)},onKeyDown:P,disabled:m,onBlur:a=>{e.onBlur(),setTimeout((()=>{a.currentTarget.form?.contains(document.activeElement)||x()}),0)}})})})}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsx(PY,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",onClick:x,disabled:m,children:n.jsx(bd,{className:"h-3 w-3"})}),n.jsx(PY,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",disabled:m,onClick:()=>{N.handleSubmit(E)()},children:m?n.jsx(Wc,{className:"h-3 w-3 animate-spin"}):n.jsx(Ec,{className:"h-3 w-3"})})]})]})}):n.jsxs("button",{ref:M,type:"button",className:GG("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:[n.jsx("span",{ref:w,className:GG("leading-none select-none",o,{italic:!b}),children:b||u}),n.jsx(nd,{className:"h-3 w-3 transition-opacity duration-200 flex-shrink-0 opacity-0 group-hover:opacity-100"})]})}function yge({open:e,onOpenChange:a}){const t=AY(),{toast:i}=Ie(),{updateAutomation:r}=na(t?.id||""),o=ce();return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"sm:max-w-[425px]",children:[n.jsx(qG,{children:n.jsx($G,{children:t?.status===ca.SENDING?`Cancel ${Eh("engage:automation")}`:`Cancel ${Eh("engage:automation")} Before Sending`})}),n.jsx("div",{className:"space-y-4",children:t?n.jsxs(n.Fragment,t.status===ca.SENDING?{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),Eh("engage:automation")," as soon as possible."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsxs("li",{children:["We'll attempt to cancel the"," ",Eh("engage:broadcast").toLowerCase()]}),n.jsx("li",{children:"Any messages already in the process of being sent will be delivered"}),n.jsxs("li",{children:["Future ",Eh("engage:broadcast").toLowerCase()," messages will be cancelled"]}),n.jsxs("li",{children:["You can create a new ",Eh("engage:broadcast").toLowerCase()," if needed"]})]})]})]}:{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),Eh("engage:automation")," before it starts sending."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsx("li",{children:"The automation will be cancelled"}),n.jsx("li",{children:"You can create a new automation if needed"})]})]})]}):null}),n.jsxs(ZG,{className:"gap-2 sm:gap-0",children:[n.jsx(PY,{variant:"outline",onClick:()=>a(!1),children:"Continue Running"}),n.jsxs(PY,{variant:"destructive",onClick:()=>{if(!t)return;const e=t.status===ca.SENDING?ca.PARTIALLY_CANCELLED:ca.CANCELLED,n=t.status===ca.SENDING?`Attempting to cancel ${Eh("engage:broadcast").toLowerCase()}`:`Successfully cancelled ${Eh("engage:broadcast").toLowerCase()}`,s=`Failed to cancel ${Eh("engage:broadcast").toLowerCase()}`;r({status:e},{onError:()=>{i({title:s,description:"Please contact your administrator.",variant:"destructive"}),o.invalidateQueries({queryKey:je.all})},onSuccess:()=>{a(!1),i({title:n,description:t.status===ca.SENDING?`We'll attempt to cancel your ${Eh("engage:broadcast").toLowerCase()}. Any messages already in progress will be delivered.`:`Your ${Eh("engage:broadcast").toLowerCase()} has been cancelled.`})}})},children:["Cancel ",Eh("engage:automation")]})]})]})})}function kge({open:e,onOpenChange:a,setIsActive:t}){const i=AY(),{updateAutomation:r}=na(i?.id||""),{toast:o}=Ie(),s=ce(),l=Eh(i?.triggerType===oa.ONE_TIME?"engage:broadcast":"engage:automation"),u=i?.triggerType===oa.ONE_TIME?"Unschedule":"Convert to draft";return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"sm:max-w-[425px]",children:[n.jsx(qG,{children:n.jsx($G,{children:u})}),n.jsxs("div",{children:["Are you sure you want to convert",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name})," ",l," to draft?"]}),n.jsxs(ZG,{className:"gap-2 sm:gap-0",children:[n.jsx(PY,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),n.jsx(PY,{variant:"destructive",onClick:()=>{r({status:ca.DRAFT},{onSuccess:()=>{o({title:`Updated ${l}`,description:`${l} status updated to draft`}),a(!1),t(!1)},onError:()=>{o({title:`Failed to update ${l}`,description:"Please try again"}),s.invalidateQueries({queryKey:je.all})}})},children:u})]})]})})}const bge=K7({name:C7().min(2,"Title must be at least 2 characters"),description:C7()});function Sge({open:e,onOpenChange:a,onDuplicationCreated:t}){const i=AY(),{toast:r}=Ie(),o=soe({resolver:hoe(bge),defaultValues:{name:`${i?.name} (copy)`,description:i?.description??""}}),{duplicateAutomation:s}=ra();return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"sm:max-w-[425px]",children:[n.jsx(qG,{children:n.jsx($G,{children:"Duplicate Automation"})}),n.jsx(poe,{...o,children:n.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&&(t?.(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:[n.jsxs("div",{children:["Create a copy of the",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name}),"automation with a new title and description."]}),n.jsx(voe,{control:o.control,name:"name",render:({field:e})=>n.jsxs(koe,{children:[n.jsx(boe,{children:"Title"}),n.jsx(Soe,{children:n.jsx(r4,{...e})}),n.jsx(Aoe,{})]})}),n.jsx(voe,{control:o.control,name:"description",render:({field:e})=>n.jsxs(koe,{children:[n.jsx(boe,{children:"Description"}),n.jsx(Soe,{children:n.jsx(iue,{...e})}),n.jsx(Aoe,{})]})}),n.jsx(ZG,{children:n.jsx(PY,{type:"submit",children:"Duplicate"})})]})})]})})}const Age=K7({name:C7().min(2,"Title must be at least 2 characters")}),wge=K7({description:C7().max(300,"Description must be less than 300 characters")}),Cge=({showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i})=>{const r=AY(),o=r5(),{updateAutomation:s}=na(r?.id||""),{toast:l}=Ie(),u=(()=>{const{state:e}=SY();return e.recipientStats})(),c=wY(),{data:d}=L9(),{channelSenders:m}=E9(),{channelAccounts:h}=M9(),p=ce(),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(!1),[S,A]=a.useState(!1),[w,C]=a.useState(0),[M,T]=a.useState(!1),N=mee({channelSenders:m?.results??[],channelAccounts:h?.results??[],smsApplication:d});a.useEffect((()=>{if(r)switch(r.status){case ca.DRAFT:v(!1);break;case ca.ACTIVE:case ca.RUNNING:case ca.COMPLETED:v(!0);break;case ca.FAILED:case ca.DEACTIVATED:v(!1);break;case ca.SENDING:case ca.SCHEDULED:v(!0);break;case ca.PARTIALLY_CANCELLED:case ca.CANCELLED:v(!1);break;default:throw g9(r.status,ca)}}),[r]);const E=a.useCallback((()=>{if(!r)return l({title:"Automation not found",description:"Please contact your administrator",variant:"destructive"}),null;const e=async e=>{if(g&&!e)b(!0);else{if(A(!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 A(!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 A(!1)}if(c?.emailHtmlBody?.includes(Lpe)){if(0===w)return l({title:`${Bpe}. You can click send again to send anyway.`,variant:"warning"}),C(w+1),void A(!1);C(w+1)}switch(r.triggerType){case oa.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 A(!1);if(!c||!c.emailChannelSenderId&&!c.smsChannelSenderId)return l({title:"Ensure you have selected at least one kind of communication",variant:"destructive"}),void A(!1);break;case oa.TRIGGER_BASED:break;default:throw g9(r.triggerType,oa)}const a=Eh(r.triggerType===oa.ONE_TIME?"engage:automation":"engage:broadcast");s({status:e?ca.ACTIVE:ca.DEACTIVATED},{onSuccess:()=>{v(e),l(r.triggerType===oa.ONE_TIME?e?{title:`${a} started!`}:{title:`${a} has been unscheduled`}:{title:`${a} status updated to ${e?"active":"inactive"}`}),A(!1)},onError:()=>{l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),A(!1),p.invalidateQueries({queryKey:je.all})}})}};if(!r||!c)return null;const a=N.find((e=>e.channelSender.id===c?.smsChannelSenderId)),t=!r.triggerMetadata||null===r.triggerMetadata,o=r.triggerMetadata?.triggerType===oa.ONE_TIME&&!r.triggerMetadata?.scheduledAt,d=!c?.emailChannelSenderId&&!c?.smsChannelSenderId,m=r.triggerType===oa.ONE_TIME,h=m&&a&&a?.smsApplication?.application&&a?.smsApplication?.status!==dee.APPROVED,f=c?.emailChannelSenderId&&(!c?.emailSubject||!c?.emailHtmlBody),y=c?.smsChannelSenderId&&!c?.smsMessageBody,k=m&&(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt);let S,M=!1,E=!0;switch(r.status){case ca.ACTIVE:M=!1;break;case ca.DRAFT:(d||f||y)&&(M=!0,f&&(S="Missing subject in email communication"),y&&(S="Missing SMS message in SMS communication")),k&&(M=!0),h&&(M=!0);break;case ca.DEACTIVATED:case ca.PARTIALLY_CANCELLED:case ca.CANCELLED:switch(M=!0,E=!1,r.status){case ca.DEACTIVATED:S="Automation is deactivated";break;case ca.PARTIALLY_CANCELLED:S="Automation is partially cancelled";break;case ca.CANCELLED:S="Automation is cancelled";break;default:throw g9(r.status,ca)}break;case ca.RUNNING:M=!0,r.triggerType===oa.TRIGGER_BASED?(S="Cannot change status of running automation",E=!0):E=r.triggerType===oa.ONE_TIME&&r.status===ca.RUNNING;break;case ca.COMPLETED:M=!0,S="Cannot change status of completed automation",E=!1;break;case ca.FAILED:M=!0,S="Cannot change status of failed automation",E=!1;break;case ca.SENDING:case ca.SCHEDULED:M=!1,E=!0;break;default:throw g9(r.status,ca)}const x=(()=>{switch(r.triggerType){case oa.TRIGGER_BASED:return n.jsxs("div",{className:"flex items-center gap-2 w-[12ch] cursor-pointer",children:[n.jsx(g?Ec:Dc,{className:"w-4 h-4"}),n.jsx("div",{className:"text-[13px] font-medium",children:g?"Active":"Inactive"}),n.jsx(dpe,{checked:g,onCheckedChange:e,disabled:M})]});case oa.ONE_TIME:if((r.status===ca.RUNNING||r.status===ca.SCHEDULED||r.status===ca.SENDING)&&r.triggerType===oa.ONE_TIME)return n.jsx(PY,{variant:"outline",className:"flex items-center gap-2",onClick:()=>T(!0),disabled:!1,children:"Cancel"});if(t||o||d||h||f||y){return n.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:(()=>{const a=r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"===r.triggerMetadata?.scheduledAt?"Send Now":"Schedule Send";if(r.status!==ca.DRAFT&&r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"!==r.triggerMetadata?.scheduledAt&&r.status===ca.ACTIVE)return n.jsx(PY,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===oa.ONE_TIME?"Unschedule":"Convert to Draft"});const t=[];h&&t.push("The SMS number selected is still not approved"),k&&t.push("Please select a schedule time on the left sidebar"),d&&t.push("Please add at least one sender"),f&&t.push("Please add a subject to your email communication"),y&&t.push("Please add a message to your SMS communication");const i=t.map((e=>{return(a=e).charAt(0).toUpperCase()+a.slice(1);var a})),o=`You cannot start this ${Eh("engage:broadcast")} yet. ${i.join(" · ")}`;return n.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:n.jsx(Mae,{alertText:o,asChild:!1,children:n.jsx(PY,{variant:"outline",className:"flex items-center gap-2 cursor-not-allowed",disabled:!0,asChild:!0,children:a})})})})()})}if(!g){let a="Schedule Send";return r.triggerMetadata&&r.triggerMetadata.triggerType===oa.ONE_TIME&&r.triggerMetadata.scheduledAt&&"now"===r.triggerMetadata.scheduledAt&&(a="Send Now"),n.jsx(PY,{variant:"default",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:a})}return n.jsx(PY,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===oa.ONE_TIME?"Unschedule":"Convert to Draft"});default:throw g9(r.triggerType,oa)}})();return M&&S&&r.triggerType===oa.TRIGGER_BASED?n.jsx(Mae,{alertText:S,asChild:!0,children:n.jsx("div",{className:"flex items-center gap-2",children:E&&x})}):n.jsx("div",{className:"flex items-center gap-2",children:E&&x})}),[r,c,N,l,g,i,s,u,w,p]),x=a.useMemo((()=>r?n.jsx(JY,{variant:vae(r.status),children:v9({status:r.status,automationType:r.triggerType})}):null),[r]);return r&&void 0!==g?n.jsxs("header",{className:"flex px-1 pt-1",children:[n.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e&&n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>o(-1),children:n.jsx(Cc,{})}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs("div",{className:"flex flex-col gap-0 items-start",children:[n.jsx(fge,{value:r.name,schema:Age,onSubmit:e=>{s({name:e.name},{onError:()=>{l({title:"Failed to update automation name",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:je.all})}})},fieldName:"name",className:"text-lg",successMessage:"Automation name updated",errorMessage:"Failed to update automation name"}),r.automationType!==la.MANAGED?n.jsx(fge,{value:r.description||"",schema:wge,onSubmit:e=>{s({description:e.description},{onError:()=>{l({title:"Failed to update automation description",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:je.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 automation"}):r.description&&n.jsx("div",{className:"text-sm text-current",children:r.description})]})})]}),n.jsxs("div",{className:"ml-auto flex gap-4 items-center",children:[n.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[x,r.triggerType===oa.ONE_TIME&&n.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:n.jsx(Mae,{title:"Duplicate",Icon:zY.DuplicateIcon,asChild:!1,onClick:()=>y(!0)})})]}),n.jsx("div",S?{className:"flex items-center text-muted-foreground pr-2",children:n.jsx(NY,{size:"sm"})}:{className:"flex items-center",children:E()})]}),n.jsx(Sge,{open:f,onOpenChange:y,onDuplicationCreated:t}),n.jsx(kge,{open:k,onOpenChange:b,setIsActive:v}),n.jsx(yge,{open:M,onOpenChange:T})]}):null},Mge=()=>{const e=AY(),{isLoading:t}=ta(e?.id),{state:{hideSales:i,hideSms:r}}=a.useContext(bO);return!e||t?n.jsx(NY,{text:[`Fetching ${Eh("engage:insight",{count:2})}`,"Finishing up"]}):n.jsx("div",{className:"h-full p-4",children:n.jsx(ege,{automationId:e.id,automation:e,includeSales:!i,includeSms:!r})})},Tge=()=>{const e=AY(),[t,i]=a.useState(10),[r,o]=a.useState(void 0),[s,l]=a.useState(""),{sentCommunications:u,isLoading:c,isFetching:d,isPlaceholderData:m,fetchError:h}=ea({automationId:e?.id??"",cursor:r,limit:t,search:s||void 0}),p=a.useCallback((e=>{o(e.cursor),i(e.pageSize)}),[]),g=[{accessorKey:"communicationsSent",id:"lastCommunication",header:"Updated At",cell:({row:e})=>{const a=e.original.communicationsSent||[];if(0===a.length)return n.jsx("span",{className:"text-gray-400",children:"None"});const t=a.reduce(((e,a)=>e&&e.updatedAt?a.updatedAt&&new Date(a.updatedAt)>new Date(e.updatedAt)?a:e:a));return t?.updatedAt?n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("span",{className:"text-sm text-gray-600",children:dae(new Date(t.updatedAt),"MMM d, yyyy h:mm a")})}):n.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||n.jsx("span",{className:"text-gray-400",children:"Not provided"})}},{accessorKey:"email",header:"Email",cell:({row:e})=>e.original.email||n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"phone",header:"Phone",cell:({row:e})=>e.original.phone?Pce(e.original.phone):n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"communicationsSent",id:"communicationsSent",header:"Communications Sent",cell:({row:e})=>{const a=e.original.communicationsSent||[],t=a.filter((e=>e.type===da.EMAIL)),i=a.filter((e=>e.type===da.SMS)),r=t.length>0,o=i.length>0,s=t.some((e=>e.delivered)),l=i.some((e=>e.delivered)),u=t.find((e=>e.error))?.error,c=i.find((e=>e.error))?.error,d=(e,a,t)=>n.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[n.jsxs("div",{className:"relative",children:[n.jsx("email"===e?zY.EmailIcon:zY.SmsIcon,{className:"h-4 w-4 "+(t?"text-red-500":a?"text-green-500":"text-gray-400")}),a&&!t&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white"}),t&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white"})]}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-medium",children:"email"===e?"Email":"SMS"}),n.jsx("span",t?{className:"text-xs text-red-500",children:"Failed"}:{className:"text-xs "+(a?"text-green-600":"text-gray-500"),children:a?"Delivered":"Pending"})]})]});return n.jsxs("div",{className:"flex items-center gap-3",children:[r&&(u?n.jsx(Mae,{title:u,children:d("email",s,u)}):d("email",s,u)),r&&o&&n.jsx("div",{className:"h-8 w-px bg-gray-200"}),o&&(c?n.jsx(Mae,{title:c,children:d("sms",l,c)}):d("sms",l,c)),!r&&!o&&n.jsx("span",{className:"text-sm text-gray-400",children:"None"})]})}}];return e&&!c&&u?h?n.jsxs("div",{children:["Error: ",h.message]}):!u||!s&&0===u.results.length?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(zY.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Communications Sent Yet"}),n.jsxs("p",{className:"text-gray-500",children:["This"," ",Eh(e.triggerType===oa.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."]})]}):n.jsx("div",{className:"h-full p-4",children:n.jsx(s4,{data:u.results,columns:g,paginationMode:"cursor",initialPageSize:t,isLoading:c&&!m,cursorPaginationQueryResult:{nextCursor:u.pagination.cursor,isLoading:c,isFetching:d,isPlaceholderData:m},onQueryParametersChange:p,searchValue:s,onSearchChange:l})}):n.jsx(NY,{text:["Fetching Recipients","Finishing up"]})},Nge=()=>{const e=AY();return e?e?.triggerType===oa.ONE_TIME&&e?.status===ca.DRAFT?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(zY.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Recipients Available Yet"}),n.jsxs("p",{className:"text-gray-500",children:["Recipients will be available once this"," ",Eh(e.triggerType===oa.ONE_TIME?"engage:broadcast":"engage:automation")," ","has completed running. Please check back after the automation has finished."]})]}):n.jsx(Tge,{}):n.jsx(NY,{text:["Fetching Recipients","Finishing up"]})},Ege=a.createContext(null);Ege.displayName="PanelGroupContext";const xge="data-panel-group",Pge="data-panel-group-direction",jge="data-panel-group-id",Lge="data-panel",Bge="data-panel-collapsible",zge="data-panel-id",Rge="data-panel-size",_ge="data-resize-handle",Dge="data-resize-handle-active",Kge="data-panel-resize-handle-enabled",Hge="data-panel-resize-handle-id",Oge="data-resize-handle-state",Ige=a.useLayoutEffect,Gge=r["useId".toString()],Vge="function"==typeof Gge?Gge:()=>null;let Fge=0;function Jge(e=null){const n=Vge(),t=a.useRef(e||n||null);return null===t.current&&(t.current=""+Fge++),null!=e?e:t.current}function Uge({children:e,className:n="",collapsedSize:t,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",...v}){const f=a.useContext(Ege);if(null===f)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:k,getPanelSize:b,getPanelStyle:S,groupId:A,isPanelCollapsed:w,reevaluatePanelConstraints:C,registerPanel:M,resizePanel:T,unregisterPanel:N}=f,E=Jge(s),x=a.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:m},constraints:{collapsedSize:t,collapsible:i,defaultSize:r,maxSize:l,minSize:u},id:E,idIsFromProps:void 0!==s,order:h});a.useRef({didLogMissingDefaultSizeWarning:!1}),Ige((()=>{const{callbacks:e,constraints:a}=x.current,n={...a};x.current.id=E,x.current.idIsFromProps=void 0!==s,x.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=m,a.collapsedSize=t,a.collapsible=i,a.defaultSize=r,a.maxSize=l,a.minSize=u,n.collapsedSize===a.collapsedSize&&n.collapsible===a.collapsible&&n.maxSize===a.maxSize&&n.minSize===a.minSize||C(x.current,n)})),Ige((()=>{const e=x.current;return M(e),()=>{N(e)}}),[h,E,M,N]),a.useImperativeHandle(o,(()=>({collapse:()=>{y(x.current)},expand:e=>{k(x.current,e)},getId:()=>E,getSize:()=>b(x.current),isCollapsed:()=>w(x.current),isExpanded:()=>!w(x.current),resize:e=>{T(x.current,e)}})),[y,k,b,w,E,T]);const P=S(x.current,r);return a.createElement(g,{...v,children:e,className:n,id:E,style:{...P,...p},[jge]:A,[Lge]:"",[Bge]:i||void 0,[zge]:E,[Rge]:parseFloat(""+P.flexGrow).toFixed(1)})}const Wge=a.forwardRef(((e,n)=>a.createElement(Uge,{...e,forwardedRef:n})));Uge.displayName="Panel",Wge.displayName="forwardRef(Panel)";let qge=null,Zge=-1,$ge=null;function Yge(e,a){var n,t;const i=function(e,a){if(a){const e=!!(a&cve),n=!!(a&dve);if(a&lve)return e?"se-resize":n?"ne-resize":"e-resize";if(a&uve)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,a);if(qge!==i){var r;if(qge=i,null===$ge&&($ge=document.createElement("style"),document.head.appendChild($ge)),Zge>=0)null===(r=$ge.sheet)||void 0===r||r.removeRule(Zge);Zge=null!==(n=null===(t=$ge.sheet)||void 0===t?void 0:t.insertRule(`*{cursor: ${i} !important;}`))&&void 0!==n?n:-1}}function Qge(e){return"keydown"===e.type}function Xge(e){return e.type.startsWith("pointer")}function eve(e){return e.type.startsWith("mouse")}function ave(e){if(Xge(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(eve(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const nve=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function tve(e){const a=getComputedStyle(e);return"fixed"===a.position||(!("auto"===a.zIndex||"static"===a.position&&!function(e){var a;const n=getComputedStyle(null!==(a=sve(e))&&void 0!==a?a:e).display;return"flex"===n||"inline-flex"===n}(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||(!!nve.test(a.willChange)||"touch"===a.webkitOverflowScrolling)))))))))}function ive(e){let a=e.length;for(;a--;){const n=e[a];if(Eve(n,"Missing node"),tve(n))return n}return null}function rve(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ove(e){const a=[];for(;e;)a.push(e),e=sve(e);return a}function sve(e){const{parentNode:a}=e;return a&&a instanceof ShadowRoot?a.host:a}const lve=1,uve=2,cve=4,dve=8,mve="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let hve=[],pve=!1,gve=new Map,vve=new Map;const fve=new Set;function yve(e){const{target:a}=e,{x:n,y:t}=ave(e);pve=!0,Ave({target:a,x:n,y:t}),Tve(),hve.length>0&&(Nve("down",e),e.preventDefault(),Sve(a)||e.stopImmediatePropagation())}function kve(e){const{x:a,y:n}=ave(e);if(pve&&0===e.buttons&&(pve=!1,Nve("up",e)),!pve){const{target:t}=e;Ave({target:t,x:a,y:n})}Nve("move",e),Cve(),hve.length>0&&e.preventDefault()}function bve(e){const{target:a}=e,{x:n,y:t}=ave(e);vve.clear(),pve=!1,hve.length>0&&(e.preventDefault(),Sve(a)||e.stopImmediatePropagation()),Nve("up",e),Ave({target:a,x:n,y:t}),Cve(),Tve()}function Sve(e){let a=e;for(;a;){if(a.hasAttribute(_ge))return!0;a=a.parentElement}return!1}function Ave({target:e,x:a,y:n}){hve.splice(0);let t=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(t=e),fve.forEach((e=>{const{element:i,hitAreaMargins:r}=e,o=i.getBoundingClientRect(),{bottom:s,left:l,right:u,top:c}=o,d=mve?r.coarse:r.fine;if(a>=l-d&&a<=u+d&&n>=c-d&&n<=s+d){if(null!==t&&document.contains(t)&&i!==t&&!i.contains(t)&&!t.contains(i)&&function(e,a){if(e===a)throw new Error("Cannot compare node with itself");const n={a:ove(e),b:ove(a)};let t;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),a=n.b.pop(),t=e;Eve(t,"Stacking order can only be calculated for elements with a common ancestor");const i=rve(ive(n.a)),r=rve(ive(n.b));if(i===r){const e=t.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let i=e.length;for(;i--;){const n=e[i];if(n===a.a)return 1;if(n===a.b)return-1}}return Math.sign(i-r)}(t,i)>0){let e=t,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}hve.push(e)}var m,h}))}function wve(e,a){vve.set(e,a)}function Cve(){let e=!1,a=!1;hve.forEach((n=>{const{direction:t}=n;"horizontal"===t?e=!0:a=!0}));let n=0;vve.forEach((e=>{n|=e})),e&&a?Yge("intersection",n):e?Yge("horizontal",n):a?Yge("vertical",n):null!==$ge&&(document.head.removeChild($ge),qge=null,$ge=null,Zge=-1)}let Mve=new AbortController;function Tve(){Mve.abort(),Mve=new AbortController;const e={capture:!0,signal:Mve.signal};fve.size&&(pve?(hve.length>0&&gve.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("contextmenu",bve,e),t.addEventListener("pointerleave",kve,e),t.addEventListener("pointermove",kve,e))})),gve.forEach(((a,n)=>{const{body:t}=n;t.addEventListener("pointerup",bve,e),t.addEventListener("pointercancel",bve,e)}))):gve.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("pointerdown",yve,e),t.addEventListener("pointermove",kve,e))})))}function Nve(e,a){fve.forEach((n=>{const{setResizeHandlerState:t}=n,i=hve.includes(n);t(e,i,a)}))}function Eve(e,a){if(!e)throw Error(a)}function xve(e,a,n=10){return e.toFixed(n)===a.toFixed(n)?0:e>a?1:-1}function Pve(e,a,n=10){return 0===xve(e,a,n)}function jve(e,a,n){return 0===xve(e,a,n)}function Lve({panelConstraints:e,panelIndex:a,size:n}){const t=e[a];Eve(null!=t,`Panel constraints not found for index ${a}`);let{collapsedSize:i=0,collapsible:r,maxSize:o=100,minSize:s=0}=t;if(xve(n,s)<0)if(r){n=xve(n,(i+s)/2)<0?i:s}else n=s;return n=Math.min(o,n),n=parseFloat(n.toFixed(10))}function Bve({delta:e,initialLayout:a,panelConstraints:n,pivotIndices:t,prevLayout:i,trigger:r}){if(jve(e,0))return a;const o=[...a],[s,l]=t;Eve(null!=s,"Invalid first pivot index"),Eve(null!=l,"Invalid second pivot index");let u=0;if("keyboard"===r){{const t=e<0?l:s,i=n[t];Eve(i,`Panel constraints not found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(Eve(null!=n,`Previous layout not found for panel index ${t}`),jve(n,r)){const a=u-n;xve(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}{const t=e<0?s:l,i=n[t];Eve(i,`No panel constraints found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(Eve(null!=n,`Previous layout not found for panel index ${t}`),jve(n,u)){const a=n-r;xve(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}}{const t=e<0?1:-1;let i=e<0?l:s,r=0;for(;;){const e=a[i];Eve(null!=e,`Previous layout not found for panel index ${i}`);if(r+=Lve({panelConstraints:n,panelIndex:i,size:100})-e,i+=t,i<0||i>=n.length)break}const o=Math.min(Math.abs(e),Math.abs(r));e=e<0?0-o:o}{let t=e<0?s:l;for(;t>=0&&t<n.length;){const i=Math.abs(e)-Math.abs(u),r=a[t];Eve(null!=r,`Previous layout not found for panel index ${t}`);const s=Lve({panelConstraints:n,panelIndex:t,size:r-i});if(!jve(r,s)&&(u+=r-s,o[t]=s,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,a,n){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(!jve(e[t],a[t],n))return!1;return!0}(i,o))return i;{const t=e<0?l:s,i=a[t];Eve(null!=i,`Previous layout not found for panel index ${t}`);const r=i+u,c=Lve({panelConstraints:n,panelIndex:t,size:r});if(o[t]=c,!jve(c,r)){let a=r-c;let t=e<0?l:s;for(;t>=0&&t<n.length;){const i=o[t];Eve(null!=i,`Previous layout not found for panel index ${t}`);const r=Lve({panelConstraints:n,panelIndex:t,size:i+a});if(jve(i,r)||(a-=r-i,o[t]=r),jve(a,0))break;e>0?t--:t++}}}return jve(o.reduce(((e,a)=>a+e),0),100)?o:i}function zve({layout:e,panelsArray:a,pivotIndices:n}){let t=0,i=100,r=0,o=0;const s=n[0];Eve(null!=s,"No pivot index found"),a.forEach(((e,a)=>{const{constraints:n}=e,{maxSize:l=100,minSize:u=0}=n;a===s?(t=u,i=l):(r+=u,o+=l)}));return{valueMax:Math.min(i,100-r),valueMin:Math.max(t,100-o),valueNow:e[s]}}function Rve(e,a=document){return Array.from(a.querySelectorAll(`[${Hge}][data-panel-group-id="${e}"]`))}function _ve(e,a,n=document){const t=Rve(e,n).findIndex((e=>e.getAttribute(Hge)===a));return null!=t?t:null}function Dve(e,a,n){const t=_ve(e,a,n);return null!=t?[t,t+1]:[-1,-1]}function Kve(e,a=document){var n;if(a instanceof HTMLElement&&(null==a||null===(n=a.dataset)||void 0===n?void 0:n.panelGroupId)==e)return a;const t=a.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function Hve(e,a=document){const n=a.querySelector(`[${Hge}="${e}"]`);return n||null}function Ove({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:i,panelDataArray:r,panelGroupElement:o,setLayout:s}){a.useRef({didWarnAboutMissingResizeHandle:!1}),Ige((()=>{if(!o)return;const e=Rve(t,o);for(let a=0;a<r.length-1;a++){const{valueMax:n,valueMin:t,valueNow:o}=zve({layout:i,panelsArray:r,pivotIndices:[a,a+1]}),s=e[a];if(null==s);else{const e=r[a];Eve(e,`No panel data found for index "${a}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(n)),s.setAttribute("aria-valuemin",""+Math.round(t)),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")}))}}),[t,i,r,o]),a.useEffect((()=>{if(!o)return;const e=n.current;Eve(e,"Eager values not found");const{panelDataArray:a}=e;Eve(null!=Kve(t,o),`No group found for id "${t}"`);const r=Rve(t,o);Eve(r,`No resize handles found for group id "${t}"`);const l=r.map((e=>{const n=e.getAttribute(Hge);Eve(n,"Resize handle element has no handle id attribute");const[r,l]=function(e,a,n,t=document){var i,r,o,s;const l=Hve(a,t),u=Rve(e,t),c=l?u.indexOf(l):-1;return[null!==(i=null===(r=n[c])||void 0===r?void 0:r.id)&&void 0!==i?i:null,null!==(o=null===(s=n[c+1])||void 0===s?void 0:s.id)&&void 0!==o?o:null]}(t,n,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];Eve(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=Bve({delta:jve(r,u)?d-u:u-r,initialLayout:i,panelConstraints:a.map((e=>e.constraints)),pivotIndices:Dve(t,n,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,n,t,i,r,s])}function Ive(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==a[n])return!1;return!0}function Gve(e,a){const n="horizontal"===e,{x:t,y:i}=ave(a);return n?t:i}function Vve(e,a,n,t,i,r){if(Qge(e)){const a="horizontal"===n;let t=0;t=e.shiftKey?100:null!=i?i:10;let r=0;switch(e.key){case"ArrowDown":r=a?0:t;break;case"ArrowLeft":r=a?-t:0;break;case"ArrowRight":r=a?t:0;break;case"ArrowUp":r=a?0:-t;break;case"End":r=100;break;case"Home":r=-100}return r}return null==t?0:function(e,a,n,t,i){const r="horizontal"===n,o=Hve(a,i);Eve(o,`No resize handle element found for id "${a}"`);const s=o.getAttribute(jge);Eve(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=t;const u=Gve(n,e),c=Kve(s,i);Eve(c,`No group element found for id "${s}"`);const d=c.getBoundingClientRect();return(u-l)/(r?d.width:d.height)*100}(e,a,n,t,r)}function Fve(e,a,n){a.forEach(((a,t)=>{const i=e[t];Eve(i,`Panel data not found for index ${t}`);const{callbacks:r,constraints:o,id:s}=i,{collapsedSize:l=0,collapsible:u}=o,c=n[s];if(null==c||a!==c){n[s]=a;const{onCollapse:e,onExpand:t,onResize:i}=r;i&&i(a,c),u&&(e||t)&&(!t||null!=c&&!Pve(c,l)||Pve(a,l)||t(),!e||null!=c&&Pve(c,l)||!Pve(a,l)||e())}}))}function Jve(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=a[n])return!1;return!0}function Uve(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 Wve(e){return`react-resizable-panels:${e}`}function qve(e){return e.map((e=>{const{constraints:a,id:n,idIsFromProps:t,order:i}=e;return t?n:i?`${i}:${JSON.stringify(a)}`:JSON.stringify(a)})).sort(((e,a)=>e.localeCompare(a))).join(",")}function Zve(e,a){try{const n=Wve(e),t=a.getItem(n);if(t){const e=JSON.parse(t);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function $ve(e,a,n,t,i){var r;const o=Wve(e),s=qve(a),l=null!==(r=Zve(e,i))&&void 0!==r?r:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:t};try{i.setItem(o,JSON.stringify(l))}catch(u){}}function Yve({layout:e,panelConstraints:a}){const n=[...e],t=n.reduce(((e,a)=>e+a),0);if(n.length!==a.length)throw Error(`Invalid ${a.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!jve(t,100)&&n.length>0)for(let r=0;r<a.length;r++){const e=n[r];Eve(null!=e,`No layout data found for index ${r}`);n[r]=100/t*e}let i=0;for(let r=0;r<a.length;r++){const e=n[r];Eve(null!=e,`No layout data found for index ${r}`);const t=Lve({panelConstraints:a,panelIndex:r,size:e});e!=t&&(i+=e-t,n[r]=t)}if(!jve(i,0))for(let r=0;r<a.length;r++){const e=n[r];Eve(null!=e,`No layout data found for index ${r}`);const t=Lve({panelConstraints:a,panelIndex:r,size:e+i});if(e!==t&&(i-=t-e,n[r]=t,jve(i,0)))break}return n}const Qve={getItem:e=>(Uve(Qve),Qve.getItem(e)),setItem:(e,a)=>{Uve(Qve),Qve.setItem(e,a)}},Xve={};function efe({autoSaveId:e=null,children:n,className:t="",direction:i,forwardedRef:r,id:o=null,onLayout:s=null,keyboardResizeBy:l=null,storage:u=Qve,style:c,tagName:d="div",...m}){const h=Jge(o),p=a.useRef(null),[g,v]=a.useState(null),[f,y]=a.useState([]),k=function(){const[e,n]=a.useState(0);return a.useCallback((()=>n((e=>e+1))),[])}(),b=a.useRef({}),S=a.useRef(new Map),A=a.useRef(0),w=a.useRef({autoSaveId:e,direction:i,dragState:g,id:h,keyboardResizeBy:l,onLayout:s,storage:u}),C=a.useRef({layout:f,panelDataArray:[],panelDataArrayChanged:!1});a.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),a.useImperativeHandle(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current,i=Yve({layout:e,panelConstraints:t.map((e=>e.constraints))});Ive(n,i)||(y(i),C.current.layout=i,a&&a(i),Fve(t,i,b.current))}})),[]),Ige((()=>{w.current.autoSaveId=e,w.current.direction=i,w.current.dragState=g,w.current.id=h,w.current.onLayout=s,w.current.storage=u})),Ove({committedValuesRef:w,eagerValuesRef:C,groupId:h,layout:f,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),a.useEffect((()=>{const{panelDataArray:a}=C.current;if(e){if(0===f.length||f.length!==a.length)return;let n=Xve[e];null==n&&(n=function(e,a=10){let n=null;return(...t)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...t)}),a)}}($ve,100),Xve[e]=n);const t=[...a],i=new Map(S.current);n(e,t,i,f,u)}}),[e,f,u]),a.useEffect((()=>{}));const M=a.useCallback((e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current;if(e.constraints.collapsible){const i=t.map((e=>e.constraints)),{collapsedSize:r=0,panelSize:o,pivotIndices:s}=tfe(t,e,n);if(Eve(null!=o,`Panel size not found for panel "${e.id}"`),!Pve(o,r)){S.current.set(e.id,o);const l=Bve({delta:nfe(t,e)===t.length-1?o-r:r-o,initialLayout:n,panelConstraints:i,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});Jve(n,l)||(y(l),C.current.layout=l,a&&a(l),Fve(t,l,b.current))}}}),[]),T=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,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}=tfe(i,e,t),c=null!=a?a:l;if(Pve(s,o)){const a=S.current.get(e.id),o=null!=a&&a>=c?a:c,l=Bve({delta:nfe(i,e)===i.length-1?s-o:o-s,initialLayout:t,panelConstraints:r,pivotIndices:u,prevLayout:t,trigger:"imperative-api"});Jve(t,l)||(y(l),C.current.layout=l,n&&n(l),Fve(i,l,b.current))}}}),[]),N=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{panelSize:t}=tfe(n,e,a);return Eve(null!=t,`Panel size not found for panel "${e.id}"`),t}),[]),E=a.useCallback(((e,a)=>{const{panelDataArray:n}=C.current,t=nfe(n,e);return function({defaultSize:e,dragState:a,layout:n,panelData:t,panelIndex:i,precision:r=3}){const o=n[i];let s;return s=null==o?null!=e?e.toPrecision(r):"1":1===t.length?"1":o.toPrecision(r),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==a?"none":void 0}}({defaultSize:a,dragState:g,layout:f,panelData:n,panelIndex:t})}),[g,f]),x=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=tfe(n,e,a);return Eve(null!=r,`Panel size not found for panel "${e.id}"`),!0===i&&Pve(r,t)}),[]),P=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=tfe(n,e,a);return Eve(null!=r,`Panel size not found for panel "${e.id}"`),!i||xve(r,t)>0}),[]),j=a.useCallback((e=>{const{panelDataArray:a}=C.current;a.push(e),a.sort(((e,a)=>{const n=e.order,t=a.order;return null==n&&null==t?0:null==n?-1:null==t?1:n-t})),C.current.panelDataArrayChanged=!0,k()}),[k]);Ige((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:a,storage:n}=w.current,{layout:t,panelDataArray:i}=C.current;let r=null;if(e){const a=function(e,a,n){var t,i;return null!==(i=(null!==(t=Zve(e,n))&&void 0!==t?t:{})[qve(a)])&&void 0!==i?i:null}(e,i,n);a&&(S.current=new Map(Object.entries(a.expandToSizes)),r=a.layout)}null==r&&(r=function({panelDataArray:e}){const a=Array(e.length),n=e.map((e=>e.constraints));let t=0,i=100;for(let r=0;r<e.length;r++){const e=n[r];Eve(e,`Panel constraints not found for index ${r}`);const{defaultSize:o}=e;null!=o&&(t++,a[r]=o,i-=o)}for(let r=0;r<e.length;r++){const o=n[r];Eve(o,`Panel constraints not found for index ${r}`);const{defaultSize:s}=o;if(null!=s)continue;const l=i/(e.length-t);t++,a[r]=l,i-=l}return a}({panelDataArray:i}));const o=Yve({layout:r,panelConstraints:i.map((e=>e.constraints))});Ive(t,o)||(y(o),C.current.layout=o,a&&a(o),Fve(i,o,b.current))}})),Ige((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const L=a.useCallback((e=>{let a=!1;const n=p.current;if(n){"rtl"===window.getComputedStyle(n,null).getPropertyValue("direction")&&(a=!0)}return function(n){n.preventDefault();const t=p.current;if(!t)return()=>null;const{direction:i,dragState:r,id:o,keyboardResizeBy:s,onLayout:l}=w.current,{layout:u,panelDataArray:c}=C.current,{initialLayout:d}=null!=r?r:{},m=Dve(o,e,t);let h=Vve(n,e,i,r,s,t);const g="horizontal"===i;g&&a&&(h=-h);const v=Bve({delta:h,initialLayout:null!=d?d:u,panelConstraints:c.map((e=>e.constraints)),pivotIndices:m,prevLayout:u,trigger:Qge(n)?"keyboard":"mouse-or-touch"}),f=!Jve(u,v);(Xge(n)||eve(n))&&A.current!=h&&(A.current=h,wve(e,f||0===h?0:g?h<0?lve:uve:h<0?cve:dve)),f&&(y(v),C.current.layout=v,l&&l(v),Fve(c,v,b.current))}}),[]),B=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,panelDataArray:i}=C.current,r=i.map((e=>e.constraints)),{panelSize:o,pivotIndices:s}=tfe(i,e,t);Eve(null!=o,`Panel size not found for panel "${e.id}"`);const l=Bve({delta:nfe(i,e)===i.length-1?o-a:a-o,initialLayout:t,panelConstraints:r,pivotIndices:s,prevLayout:t,trigger:"imperative-api"});Jve(t,l)||(y(l),C.current.layout=l,n&&n(l),Fve(i,l,b.current))}),[]),z=a.useCallback(((e,a)=>{const{layout:n,panelDataArray:t}=C.current,{collapsedSize:i=0,collapsible:r}=a,{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:u=0}=e.constraints,{panelSize:c}=tfe(t,e,n);null!=c&&(r&&s&&Pve(c,i)?Pve(i,o)||B(e,o):c<u?B(e,u):c>l&&B(e,l))}),[B]),R=a.useCallback(((e,a)=>{const{direction:n}=w.current,{layout:t}=C.current;if(!p.current)return;const i=Hve(e,p.current);Eve(i,`Drag handle element not found for id "${e}"`);const r=Gve(n,a);v({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:r,initialLayout:t})}),[]),_=a.useCallback((()=>{v(null)}),[]),D=a.useCallback((e=>{const{panelDataArray:a}=C.current,n=nfe(a,e);n>=0&&(a.splice(n,1),delete b.current[e.id],C.current.panelDataArrayChanged=!0,k())}),[k]),K=a.useMemo((()=>({collapsePanel:M,direction:i,dragState:g,expandPanel:T,getPanelSize:N,getPanelStyle:E,groupId:h,isPanelCollapsed:x,isPanelExpanded:P,reevaluatePanelConstraints:z,registerPanel:j,registerResizeHandle:L,resizePanel:B,startDragging:R,stopDragging:_,unregisterPanel:D,panelGroupElement:p.current})),[M,g,i,T,N,E,h,x,P,z,j,L,B,R,_,D]);return a.createElement(Ege.Provider,{value:K},a.createElement(d,{...m,children:n,className:t,id:o,ref:p,style:{...{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%"},...c},[xge]:"",[Pge]:i,[jge]:h}))}const afe=a.forwardRef(((e,n)=>a.createElement(efe,{...e,forwardedRef:n})));function nfe(e,a){return e.findIndex((e=>e===a||e.id===a.id))}function tfe(e,a,n){const t=nfe(e,a);return{...a.constraints,panelSize:n[t],pivotIndices:t===e.length-1?[t-1,t]:[t,t+1]}}function ife({children:e=null,className:n="",disabled:t=!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 v,f;const y=a.useRef(null),k=a.useRef({onClick:s,onDragging:l,onPointerDown:c,onPointerUp:d});a.useEffect((()=>{k.current.onClick=s,k.current.onDragging=l,k.current.onPointerDown=c,k.current.onPointerUp=d}));const b=a.useContext(Ege);if(null===b)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:A,registerResizeHandle:w,startDragging:C,stopDragging:M,panelGroupElement:T}=b,N=Jge(r),[E,x]=a.useState("inactive"),[P,j]=a.useState(!1),[L,B]=a.useState(null),z=a.useRef({state:E});Ige((()=>{z.current.state=E})),a.useEffect((()=>{if(t)B(null);else{const e=w(N);B((()=>e))}}),[t,N,w]);const R=null!==(v=null==i?void 0:i.coarse)&&void 0!==v?v:15,_=null!==(f=null==i?void 0:i.fine)&&void 0!==f?f:5;a.useEffect((()=>{if(t||null==L)return;const e=y.current;Eve(e,"Element ref not attached");let a=!1;return function(e,a,n,t,i){var r;const{ownerDocument:o}=a,s={direction:n,element:a,hitAreaMargins:t,setResizeHandlerState:i},l=null!==(r=gve.get(o))&&void 0!==r?r:0;return gve.set(o,l+1),fve.add(s),Tve(),function(){var a;vve.delete(e),fve.delete(s);const n=null!==(a=gve.get(o))&&void 0!==a?a:1;if(gve.set(o,n-1),Tve(),1===n&&gve.delete(o),hve.includes(s)){const e=hve.indexOf(s);e>=0&&hve.splice(e,1),Cve(),i("up",!0,null)}}}(N,e,S,{coarse:R,fine:_},((e,n,t)=>{if(n)switch(e){case"down":{x("drag"),a=!1,Eve(t,'Expected event to be defined for "down" action'),C(N,t);const{onDragging:e,onPointerDown:n}=k.current;null==e||e(!0),null==n||n();break}case"move":{const{state:e}=z.current;a=!0,"drag"!==e&&x("hover"),Eve(t,'Expected event to be defined for "move" action'),L(t);break}case"up":{x("hover"),M();const{onClick:e,onDragging:n,onPointerUp:t}=k.current;null==n||n(!1),null==t||t(),a||null==e||e();break}}else x("inactive")}))}),[R,S,t,_,w,N,L,C,M]),function({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:i}){a.useEffect((()=>{if(e||null==t||null==i)return;const a=Hve(n,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(),t(e);break;case"F6":{e.preventDefault();const t=a.getAttribute(jge);Eve(t,`No group element found for id "${t}"`);const r=Rve(t,i),o=_ve(t,n,i);Eve(null!==o,`No resize element found for id "${n}"`),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,n,t])}({disabled:t,handleId:N,resizeHandler:L,panelGroupElement:T});return a.createElement(p,{...g,children:e,className:n,id:r,onBlur:()=>{j(!1),null==o||o()},onFocus:()=>{j(!0),null==u||u()},ref:y,role:"separator",style:{touchAction:"none",userSelect:"none",...m},tabIndex:h,[Pge]:S,[jge]:A,[_ge]:"",[Dge]:"drag"===E?"pointer":P?"keyboard":void 0,[Kge]:!t,[Hge]:N,[Oge]:E})}efe.displayName="PanelGroup",afe.displayName="forwardRef(PanelGroup)",ife.displayName="PanelResizeHandle";const rfe=({className:e,...a})=>n.jsx(afe,{className:GG("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),ofe=Wge,sfe=({withHandle:e,className:a,...t})=>n.jsx(ife,{className:GG("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),...t,children:e&&n.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:n.jsx(Gc,{className:"h-2.5 w-2.5"})})}),lfe=({copyText:e})=>n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),ufe="rgba(245, 246, 247, 1)",cfe={[ua.SEND_COMMUNICATION]:{color:{bg:ufe},clickable:!0},[ua.WAIT_UNTIL_NEXT_FIXED_TIME]:{color:{bg:ufe},clickable:!1}},dfe={[ua.SEND_COMMUNICATION]:"Send Email & SMS",[ua.WAIT_UNTIL_NEXT_FIXED_TIME]:"Wait"},mfe=({children:e,onClick:a,iconBgColor:t,iconStrokeColor:i,Icon:r,disabled:o=!1,selected:s=!1})=>{const l=r;return n.jsxs(Z$.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?t:ufe},onClick:a,className:pm("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:[n.jsx("div",{className:pm("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",t),children:n.jsx(l,{className:pm("w-4 h-4 stroke-purple-500 group-hover/trigger-audience:fill-purple-50 transition-colors",i)})}),e]})},hfe=({segmentName:e})=>n.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}),pfe=()=>{const e=AY(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(uY),[r,o]=a.useState(e?.includeSegmentIds||null),[s,l]=a.useState(e?.excludeSegmentIds||null),{segments:u}=pY(),c=a.useCallback((()=>u?.find((e=>e.type===kY.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?n.jsx(n.Fragment,{children:n.jsx(mfe,{selected:i===jie.EditAudience,iconBgColor:"bg-purple-50",iconStrokeColor:"stroke-purple-500",onClick:()=>{t(jie.EditAudience)},Icon:zY.AudienceIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Fce,{children:"Audience"}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(lfe,{copyText:`Send to all ${Eh("engage:user",{count:2})} in ${1===r.length?"this":"these"} ${Eh("engage:segment",{count:r.length}).toLowerCase()}`}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map((e=>{const a=u?.find((a=>a.id===e));return a?n.jsx(hfe,{segmentName:a.name},e):null}))})]})]})})}):null},gfe=()=>{const e=AY(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(uY),{segments:r}=pY(),o=Eh(e?.triggerType===oa.TRIGGER_BASED?"engage:automation":"engage:broadcast"),s=`Start this ${o?.toLowerCase()}`;if(!e||!r)return null;return n.jsx(n.Fragment,{children:(()=>{switch(e.triggerType){case oa.TRIGGER_BASED:{if(e.triggerMetadata&&e.triggerMetadata.triggerType!==oa.TRIGGER_BASED||!e.triggerMetadata||e.triggerMetadata.eventName!==sa.USER_ENTERS_SEGMENT||!e.triggerMetadata.eventFilter.segment_id)return null;const a=e.triggerMetadata.eventFilter.segment_id,t=r.find((e=>e.id===a))?.name;return t?n.jsx(mfe,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:zY.TriggerIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Fce,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(lfe,{copyText:`When ${Eh("engage:user").toLowerCase()} joins the`}),n.jsx(hfe,{segmentName:t})]})]})}):null}case oa.ONE_TIME:{const a=!e.triggerMetadata||!("scheduledAt"in e.triggerMetadata);return n.jsxs(mfe,{iconBgColor:"bg-amber-100",iconStrokeColor:"stroke-amber-500",onClick:()=>{t(jie.EditTime)},selected:i===jie.EditTime,Icon:zY.TriggerIcon,children:[n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Fce,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(lfe,a?{copyText:`Click to set the date and time for this ${Eh("engage:broadcast")}`}:{copyText:"Bulk send at"}),!1===a&&e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&e.triggerMetadata.scheduledAt&&n.jsx("div",{className:"text-xs font-medium",children:n.jsx(hfe,{segmentName:"now"===e.triggerMetadata.scheduledAt?"5 minutes after send":dae(new Date(e.triggerMetadata.scheduledAt),"h:mma MM/dd/yy")})})]})]}),n.jsx("div",{className:"",children:a&&n.jsx(Mae,{title:"Please select a time before sending this ${t('engage:broadcast')}.",alertText:`A scheduled time is needed before sending this ${Eh("engage:broadcast")}.`,Icon:zY.AlertTriangleIcon,iconColor:"text-red-500",size:"large"})})]})}default:throw g9(e.triggerType,oa)}})()})},vfe=({type:e,disabled:t=!1,actionId:i})=>{const{state:{selectedSubStepType:r},setSelectedSubStepType:o,setActionId:s}=a.useContext(uY),l=wY(),u=r===e,c=a.useCallback((()=>{if(!l)return"Need to select a channel";switch(e){case Lie.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 Lie.SMS:return l.smsChannelSenderId?!!l.smsMessageBody||"Please add content to the sms":"Please select a sms sender"}}),[l,e]);if(t)return null;const d=c();return n.jsx(Z$.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15,ease:"easeInOut"},className:pm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group","border-2 border-transparent",u&&"border-primary",!t&&"hover:border-muted-foreground/30",t&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:u?"#f5f6f7":ufe},onClick:()=>{t||(s(i),o(e))},children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.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 Lie.EMAIL:return n.jsx(zY.EmailIcon,{className:pm("w-6 h-6",a?"text-primary":"text-gray-400")});case Lie.SMS:return n.jsx(zY.SmsIcon,{className:pm("w-6 h-6",a?"text-primary":"text-gray-400")})}})(e,u)}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("div",{style:{color:u?"#3b82f6":"#64748b"},children:n.jsx(Fce,{className:"text-xs",children:(()=>{switch(e){case Lie.EMAIL:return"Email";case Lie.SMS:return"SMS"}})()})}),n.jsx("div",{className:"text-[10px] font-medium text-muted-foreground",children:(()=>{if(!l)return"";switch(e){case Lie.EMAIL:return l.emailSubject||"No subject set";case Lie.SMS:return l.smsMessageBody?`${l.smsMessageBody.substring(0,40)}${l.smsMessageBody.length>40?"...":""}`:"No message set"}})()}),!0!==d&&n.jsx("div",{className:"text-[10px] text-amber-600 font-medium",children:d})]})]})})},ffe=e=>{switch(e){case ua.SEND_COMMUNICATION:return"Send Communication";case ua.WAIT_UNTIL_NEXT_FIXED_TIME:return"Wait";default:throw tY(e,ua)}},yfe=e=>{switch(e){case ua.SEND_COMMUNICATION:return n.jsx(zY.CommunicationIcon,{className:"w-4 h-4"});case ua.WAIT_UNTIL_NEXT_FIXED_TIME:return n.jsx(zY.WaitUntilNextFixedTimeIcon,{className:"w-4 h-4"});default:throw g9(e,ua)}},kfe=e=>{if(!(e&&e.actionType===ua.WAIT_UNTIL_NEXT_FIXED_TIME&&"hour"in e&&"minute"in e&&"timezone"in e))return null;const{hour:a,minute:n,timezone:t}=e;return`Wait until next ${`${a?.toString().padStart(2,"0")}:${n?.toString().padStart(2,"0")}`} ${t}`},bfe=({actionDataWithMetadata:e})=>{const{actionData:t,communicationGroup:i}=e,{state:{selectedActionId:r},setActionId:o,setSelectedCommunicationGroupId:s}=a.useContext(uY),l=a.useMemo((()=>r===t.actionMetadata.currentActionId),[r,t.actionMetadata.currentActionId]),u=cfe[t.actionType],c=u.color,d=u.clickable;return n.jsxs(Z$.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},className:pm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group"," border-2 border-transparent",l&&"border-primary",t.actionType!==ua.WAIT_UNTIL_NEXT_FIXED_TIME&&"hover:border-primary"),style:{backgroundColor:l?c.bg:c.bgUnselected??ufe},onClick:()=>{d&&(o(t.actionMetadata.currentActionId),t.actionType===ua.SEND_COMMUNICATION&&s(t.actionMetadata.communicationGroupId))},children:[n.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[n.jsx("div",{className:"rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 bg-white",children:yfe(t.actionType)}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{style:{color:l?c.text:c.textUnselected},children:n.jsx(Fce,{children:dfe[t.actionType]})}),n.jsx("div",t.actionType===ua.WAIT_UNTIL_NEXT_FIXED_TIME?{className:"text-[11px] text-muted-foreground font-normal rounded bg-muted/40 w-fit max-w-full truncate",children:kfe(t.actionMetadata)}:{className:"text-xs font-medium text-muted-foreground",children:t.actionType===ua.SEND_COMMUNICATION&&i?.emailSubject?i?.emailSubject:ffe(t.actionType)})]})]}),t.actionType===ua.SEND_COMMUNICATION&&n.jsx("div",{className:"flex items-center pr-2",children:n.jsx(zY.NextButton,l?{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"})})]})},Sfe=()=>{const e=wY(),[t,i]=a.useState(!1),[r,o]=a.useState(void 0),s=AY(),{setActionId:l,setSelectedSubStepType:u,state:{selectedActionId:c,selectedSubStepType:d}}=a.useContext(uY);if(na(s?.id||""),a.useEffect((()=>{if(!s)return;if(c)return;const e=s.actionData?.find((e=>"send_communication"===e.actionType));e&&l(e.actionMetadata.currentActionId)}),[s,l,c]),a.useEffect((()=>{if(!s)return;(async()=>{const e=[];for(const a of s.actionData??[])switch(a.actionType){case ua.SEND_COMMUNICATION:{const n=await Ge(a.actionMetadata.communicationGroupId);e.push({actionData:a,communicationGroup:n});break}case ua.WAIT_UNTIL_NEXT_FIXED_TIME:e.push({actionData:a});break;default:throw tY(a.actionType,ua)}o(e)})()}),[s]),a.useEffect((()=>{if(c&&r&&e&&null===d){const a=r.find((e=>e.actionData.actionMetadata.currentActionId===c));"send_communication"===a?.actionData.actionType&&u(e?.emailChannelSenderId?Lie.EMAIL:Lie.SMS)}}),[c,r,u,e,d]),!s||!r)return null;const m=(e=>{const{steps:a,rootActionId:n}=e;if(!a||!n)return a??[];const t=new Map(a.map((e=>[e.actionData.actionMetadata.currentActionId,e]))),i=t.get(n);if(!i)return a;const r=[];let o=i;for(;o;){r.push(o);const e=o.actionData.actionMetadata.nextActionId;if(!e)break;o=t.get(e)}return r})({steps:r,rootActionId:s.triggerMetadata?.triggerType===oa.TRIGGER_BASED?s.triggerMetadata.rootActionId:void 0}).filter((e=>!!t||"send_communication"===e.actionData.actionType));let h=()=>n.jsx("div",{},"empty-trigger-audience");return(t||s.triggerType===oa.ONE_TIME)&&(h=()=>n.jsxs("div",{className:"flex flex-col gap-3",children:[s.triggerType===oa.ONE_TIME&&n.jsx(pfe,{}),s.triggerType!==oa.ONE_TIME&&n.jsx(gfe,{})]})),n.jsxs("div",{className:"flex-1 flex flex-col gap-2 w-full overflow-visible",children:[s.triggerType===oa.TRIGGER_BASED&&n.jsxs("div",{className:"flex gap-2 items-center justify-between",children:[n.jsx("div",{className:"text-[13px] text-muted-foreground",children:"Messages sent in listed order"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("div",{className:"text-[13px] font-medium",children:"Show all details"}),n.jsx(dpe,{defaultChecked:t,onCheckedChange:()=>{i(!t)}})]})]}),n.jsx("div",{className:"flex-1 flex flex-col gap-3",children:n.jsxs(dV,{mode:"popLayout",children:[h(),m.map(((a,t)=>n.jsx(Z$.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*t,ease:"easeInOut"},children:n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(bfe,{actionDataWithMetadata:a}),"send_communication"===a.actionData.actionType&&c===a.actionData.actionMetadata.currentActionId&&a.actionData.actionMetadata.currentActionId&&n.jsxs("div",{className:"flex gap-3",children:[n.jsx(Z$.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,delay:.25*m.length,ease:"easeInOut"},className:"w-12 flex justify-end items-center",children:n.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full rounded-full"})}),n.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[e?.emailChannelSenderId&&n.jsx(vfe,{type:Lie.EMAIL,actionId:a.actionData.actionMetadata.currentActionId}),e?.smsChannelSenderId&&n.jsx(vfe,{type:Lie.SMS,actionId:a.actionData.actionMetadata.currentActionId})]})]})]})},a.actionData.actionMetadata?.currentActionId??t))),s.triggerType===oa.ONE_TIME&&n.jsx("div",{className:"flex flex-col gap-3",children:n.jsx(gfe,{})},"one-time-trigger")]})})]})},Afe=()=>{const e=AY(),{segments:a}=pY();return n.jsx("div",e&&a?{className:"h-full pt-4 relative",children:n.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col gap-3",children:n.jsx(Sfe,{})})}:{className:"flex h-full items-center justify-center",children:n.jsx(NY,{text:[`Getting details on your ${Eh("engage:automation",{count:1}).toLowerCase()}`,"Finishing up"]})})},wfe=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,hideSms:r=!1})=>{const{state:{selectedSubStepType:o}}=a.useContext(uY);if(!wY())return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(NY,{text:["Loading..."]})});if(!o)return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h3",{className:"text-lg font-medium text-muted-foreground mb-2",children:"Select Communication Type"}),n.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:t,disablePreviewSubtext:i};return n.jsxs("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:[o===Lie.EMAIL&&n.jsx(Bce,{...s}),o===Lie.SMS&&!r&&n.jsx(Dce,{...s})]})},Cfe=()=>{const{state:{selectedActionId:e}}=a.useContext(uY),{state:{hideSms:t}}=a.useContext(bO);return n.jsx("div",{className:"flex flex-col gap-4 h-full w-full",children:n.jsx(dV,{mode:"wait",children:e===jie.EditTime?n.jsx(Whe,{}):e===jie.EditAudience?n.jsx(Epe,{}):n.jsx(wfe,{hideSms:t})})})},Mfe=()=>n.jsxs(rfe,{direction:"horizontal",className:"flex-1",children:[n.jsx(ofe,{defaultSize:30,minSize:16,maxSize:48,children:n.jsx("aside",{className:"h-full",children:n.jsx(Afe,{})})}),n.jsx(sfe,{className:"px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1"}),n.jsx(ofe,{defaultSize:70,children:n.jsx("main",{className:"h-full",children:n.jsx(Cfe,{})})})]}),Tfe=()=>{const[e,t]=a.useState("workflow"),i=[{id:"workflow",label:"Workflow",content:n.jsx(Mfe,{})},{id:"recipients",label:"Recipients",content:n.jsx(Nge,{})},{id:"insights",label:Eh("engage:insight",{count:2}),content:n.jsx(Mge,{})}];return n.jsx(Gpe,{tabs:i,activeTab:e,onTabChange:t,tabsLocation:"left"})},Nfe=({showBackButton:e=!1,onDuplicationCreated:t,onBeforeSchedule:i,getExtraMergeFields:r,hideSms:o,hideSales:s,replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d})=>{const m=AY(),h=wY(),{updateCommunicationGroup:p}=Ze(),{toast:g}=Ie(),{channelSenders:v}=E9(),f=a.useRef("");return a.useEffect((()=>{if(h&&r){(async()=>{const e=await r(),a=JSON.stringify(e);a!==f.current&&(f.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&&v&&m.automationType===la.MANAGED&&null===h.emailChannelSenderId&&null===h.smsChannelSenderId){if(!h.emailChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.userPart));e.length>0&&p({groupId:h.id,params:{emailChannelSenderId:e[0].id}})}if(!h.smsChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.from||e.channelSenderMetadata.messageServiceSid));e.length>0&&p({groupId:h.id,params:{smsChannelSenderId:e[0].id}})}}}),[m,h,v,p]),m&&h?n.jsx(SO,{children:n.jsx(AO,{replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d,hideSms:o,hideSales:s,children:n.jsxs("div",{className:"h-full flex flex-col gap-4",children:[n.jsx(Cge,{showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i}),n.jsx("div",{className:"flex-1 border-t",children:n.jsx(Tfe,{})})]})})}):n.jsx("div",{className:"flex h-screen items-center justify-center",children:n.jsx(NY,{text:[`Fetching ${Eh("engage:automation").toLowerCase()} data`,"Finishing up"]})})},Efe=({...e})=>{const a=function(){let{matches:e}=r.useContext(X4),a=e[e.length-1];return a?a.params:{}}(),[t]=V5(),i=e.automationId||a?.automationId||t.get("automationId")||"",o="true"===t.get("showBackButton")||e.showBackButton;return n.jsx(MY,{automationId:i,children:n.jsx("div",{className:"bg-background h-full",children:n.jsx(Nfe,{...e,showBackButton:o})})})};Object.values(Object.assign({}));var xfe=e=>null!=e;var Pfe=e=>"function"!=typeof e||e.length?e:e(),jfe=e=>Array.isArray(e)?e:e?[e]:[];var Lfe=Ha;var Bfe,zfe=function(e){const[a,n]=Pa(),t=e?.throw?(e,a)=>{throw n(e instanceof Error?e:new Error(a)),e}:(e,a)=>{n(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,n){let s=o.get(n);s||(s=Pa(void 0,{equals:!1}),o.set(n,s)),s[0]();const l=i.reduce(((e,a)=>{if(null!==e||!a)return e;try{return a.getItem(`${r}${n}`)}catch(cBe){return t(cBe,`Error reading ${r}${n} from ${a.name}`),null}}),null);return null!==l&&e?.deserializer?e.deserializer(l,n,e.options):l}});return!1!==e?.sync&&Ka((()=>{const e=e=>{let a=!1;i.forEach((n=>{try{n!==e.storageArea&&e.key&&e.newValue!==n.getItem(e.key)&&(e.newValue?n.setItem(e.key,e.newValue):n.removeItem(e.key),a=!0)}catch(cBe){t(cBe,`Error synching api ${n.name} from storage event (${e.key}=${e.newValue})`)}})),a&&e.key&&o.get(e.key)?.[1]()};"addEventListener"in globalThis?(globalThis.addEventListener("storage",e),Ha((()=>globalThis.removeEventListener("storage",e)))):(i.forEach((a=>a.addEventListener?.("storage",e))),Ha((()=>i.forEach((a=>a.removeEventListener?.("storage",e))))))})),[s,(a,n,s)=>{const l=e?.serializer?e.serializer(n,a,s??e.options):n,u=`${r}${a}`;i.forEach((e=>{try{e.getItem(u)!==l&&e.setItem(u,l)}catch(cBe){t(cBe,`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(cBe){t(cBe,`Error clearing ${e.name}`)}})),error:a,remove:e=>i.forEach((a=>{try{a.removeItem(`${r}${e}`)}catch(cBe){t(cBe,`Error removing ${r}${e} from ${a.name}`)}})),toJSON:()=>{const a={},n=(n,t)=>{if(!a.hasOwnProperty(n)){const i=t&&e?.deserializer?e.deserializer(t,n,e.options):t;i&&(a[n]=i)}};return i.forEach((e=>{if("function"==typeof e.getAll){let a;try{a=e.getAll()}catch(cBe){t(cBe,`Error getting all values from in ${e.name}`)}for(const e of a)n(e,a[e])}else{let i,r=0;try{for(;i=e.key(r++);)a.hasOwnProperty(i)||n(i,e.getItem(i))}catch(cBe){t(cBe,`Error getting all values from ${e.name}`)}}})),a}}]},Rfe=e=>{if(!e)return"";let a="";for(const n in e){if(!e.hasOwnProperty(n))continue;const t=e[n];a+=t instanceof Date?`; ${n}=${t.toUTCString()}`:"boolean"==typeof t?`; ${n}`:`; ${n}=${t}`}return a},_fe=("function"==typeof(Bfe={_cookies:[globalThis.document,"cookie"],getItem:e=>_fe._cookies[0][_fe._cookies[1]].match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)")?.pop()??null,setItem:(e,a,n)=>{const t=_fe.getItem(e);_fe._cookies[0][_fe._cookies[1]]=`${e}=${a}${Rfe(n)}`;const i=Object.assign(new Event("storage"),{key:e,oldValue:t,newValue:a,url:globalThis.document.URL,storageArea:_fe});window.dispatchEvent(i)},removeItem:e=>{_fe._cookies[0][_fe._cookies[1]]=`${e}=deleted${Rfe({expires:new Date(0)})}`},key:e=>{let a=null,n=0;return _fe._cookies[0][_fe._cookies[1]].replace(/(?:^|;)\s*(.+?)\s*=\s*[^;]+/g,((t,i)=>(!a&&i&&n++===e&&(a=i),""))),a},get length(){let e=0;return _fe._cookies[0][_fe._cookies[1]].replace(/(?:^|;)\s*.+?\s*=\s*[^;]+/g,(a=>(e+=a?1:0,""))),e}}).clear||(Bfe.clear=()=>{let e;for(;e=Bfe.key(0);)Bfe.removeItem(e)}),Bfe),Dfe=796,Kfe="bottom",Hfe="system",Ofe=Object.keys(Qt)[0],Ife=Object.keys(ai)[0],Gfe=Fa({client:void 0,onlineManager:void 0,queryFlavor:"",version:"",shadowDOMTarget:void 0});function Vfe(){return Ja(Gfe)}var Ffe=Fa(void 0),Jfe=e=>{const[a,n]=Pa(null),t=()=>{const e=a();null!=e&&(e.close(),n(null))},i=(t,i)=>{if(null!=a())return;const r=window.open("","TSQD-Devtools-Panel",`width=${t},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[zn]){for(let a of e[zn].keys())e.removeEventListener(a,qn);delete e[zn]}}(r.document),r.document.title="TanStack Query Devtools",r.document.body.style.margin="0",r.addEventListener("pagehide",(()=>{e.setLocalStore("pip_open","false"),n(null)})),[...(Vfe().shadowDOMTarget||document).styleSheets].forEach((e=>{try{const a=[...e.cssRules].map((e=>e.cssText)).join(""),n=document.createElement("style"),t=e.ownerNode;let i="";t&&"id"in t&&(i=t.id),i&&n.setAttribute("id",i),n.textContent=a,r.document.head.appendChild(n)}catch(uBe){const n=document.createElement("link");if(null==e.href)return;n.rel="stylesheet",n.type=e.type,n.media=e.media.toString(),n.href=e.href,r.document.head.appendChild(n)}})),Dn(["focusin","focusout","pointermove","keydown","pointerdown","pointerup","click","mousedown","input"],r.document),e.setLocalStore("pip_open","true"),n(r)};Ba((()=>{"true"!==(e.localStore.pip_open??"false")||e.disabled||i(Number(window.innerWidth),Number(e.localStore.height||500))})),Ba((()=>{const e=(Vfe().shadowDOMTarget||document).querySelector("#_goober"),n=a();if(e&&n){const a=new MutationObserver((()=>{const a=(Vfe().shadowDOMTarget||n.document).querySelector("#_goober");a&&(a.textContent=e.textContent)}));a.observe(e,{childList:!0,subtree:!0,characterDataOldValue:!0}),Ha((()=>{a.disconnect()}))}}));const r=za((()=>({pipWindow:a(),requestPipWindow:i,closePipWindow:t,disabled:e.disabled??!1})));return dn(Ffe.Provider,{value:r,get children(){return e.children}})},Ufe=()=>za((()=>{const e=Ja(Ffe);if(!e)throw new Error("usePiPWindow must be used within a PiPProvider");return e()})),Wfe=Fa((()=>"dark"));function qfe(){return Ja(Wfe)}var Zfe={"À":"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"},$fe=Object.keys(Zfe).join("|"),Yfe=new RegExp($fe,"g");var Qfe=7,Xfe=6,eye=5,aye=4,nye=3,tye=2,iye=1,rye=0;function oye(e,a,n){var t;if((n=n||{}).threshold=null!=(t=n.threshold)?t:iye,!n.accessors){const t=sye(e,a,n);return{rankedValue:e,rank:t,accessorIndex:-1,accessorThreshold:n.threshold,passed:t>=n.threshold}}const i=function(e,a){const n=[];for(let t=0,i=a.length;t<i;t++){const i=a[t],r=dye(i),o=uye(e,i);for(let e=0,a=o.length;e<a;e++)n.push({itemValue:o[e],attributes:r})}return n}(e,n.accessors),r={rankedValue:e,rank:rye,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let o=0;o<i.length;o++){const e=i[o];let t=sye(e.itemValue,a,n);const{minRanking:s,maxRanking:l,threshold:u=n.threshold}=e.attributes;t<s&&t>=iye?t=s:t>l&&(t=l),t=Math.min(t,l),t>=u&&t>r.rank&&(r.rank=t,r.passed=!0,r.accessorIndex=o,r.accessorThreshold=u,r.rankedValue=e.itemValue)}return r}function sye(e,a,n){return e=lye(e,n),(a=lye(a,n)).length>e.length?rye:e===a?Qfe:(e=e.toLowerCase())===(a=a.toLowerCase())?Xfe:e.startsWith(a)?eye:e.includes(` ${a}`)?aye:e.includes(a)?nye:1===a.length?rye:function(e){let a="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{a+=e.substr(0,1)}))})),a}(e).includes(a)?tye:function(e,a){let n=0,t=0;function i(e,a,t){for(let i=t,r=a.length;i<r;i++){if(a[i]===e)return n+=1,i+1}return-1}function r(e){return iye+n/a.length*(1/e)}const o=i(a[0],e,0);if(o<0)return rye;t=o;for(let s=1,l=a.length;s<l;s++){t=i(a[s],e,t);if(!(t>-1))return rye}return r(t-o)}(e,a)}function lye(e,a){let{keepDiacritics:n}=a;return e=`${e}`,n||(e=e.replace(Yfe,(e=>Zfe[e]))),e}function uye(e,a){let n=a;"object"==typeof a&&(n=a.accessor);const t=n(e);return null==t?[]:Array.isArray(t)?t:[String(t)]}var cye={maxRanking:1/0,minRanking:-1/0};function dye(e){return"function"==typeof e?cye:{...cye,...e}}var mye={data:""},hye=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,pye=/\/\*[^]*?\*\/| +/g,gye=/\n+/g,vye=(e,a)=>{let n="",t="",i="";for(let r in e){let o=e[r];"@"==r[0]?"i"==r[1]?n=r+" "+o+";":t+="f"==r[1]?vye(o,r):r+"{"+vye(o,"k"==r[1]?"":a)+"}":"object"==typeof o?t+=vye(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+=vye.p?vye.p(r,o):r+":"+o+";")}return n+(a&&i?a+"{"+i+"}":i)+t},fye={},yye=e=>{if("object"==typeof e){let a="";for(let n in e)a+=n+yye(e[n]);return a}return e};function kye(e){let a=this||{},n=e.call?e(a.p):e;return((e,a,n,t,i)=>{let r=yye(e),o=fye[r]||(fye[r]=(e=>{let a=0,n=11;for(;a<e.length;)n=101*n+e.charCodeAt(a++)>>>0;return"go"+n})(r));if(!fye[o]){let a=r!==e?e:(e=>{let a,n,t=[{}];for(;a=hye.exec(e.replace(pye,""));)a[4]?t.shift():a[3]?(n=a[3].replace(gye," ").trim(),t.unshift(t[0][n]=t[0][n]||{})):t[0][a[1]]=a[2].replace(gye," ").trim();return t[0]})(e);fye[o]=vye(i?{["@keyframes "+o]:a}:a,n?"":"."+o)}let s=n&&fye.g?fye.g:null;return n&&(fye.g=fye[o]),l=fye[o],u=a,c=t,(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})(n.unshift?n.raw?((e,a,n)=>e.reduce(((e,t,i)=>{let r=a[i];if(r&&r.call){let e=r(n),a=e&&e.props&&e.props.className||/^go/.test(e)&&e;r=a?"."+a:e&&"object"==typeof e?e.props?"":vye(e,""):!1===e?"":e}return e+t+(null==r?"":r)}),""))(n,[].slice.call(arguments,1),a.p):n.reduce(((e,n)=>Object.assign(e,n&&n.call?n(a.p):n)),{}):n,(t=a.target,"object"==typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||mye),a.g,a.o,a.k);var t}function bye(e){var a,n,t="";if("string"==typeof e||"number"==typeof e)t+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(a=0;a<i;a++)e[a]&&(n=bye(e[a]))&&(t&&(t+=" "),t+=n)}else for(n in e)e[n]&&(t&&(t+=" "),t+=n);return t}function Sye(){for(var e,a,n=0,t="",i=arguments.length;n<i;n++)(e=arguments[n])&&(a=bye(e))&&(t&&(t+=" "),t+=a);return t}function Aye(e,a){const n=_a(e),{onChange:t}=a;let i=new Set(a.appear?void 0:n);const r=new WeakSet,[o,s]=Pa([],{equals:!1}),[l]=[Ga,Ia],u=e=>{s((a=>(a.push.apply(a,e),a)));for(const a of e)r.delete(a)},c=(e,a,n)=>e.splice(n,0,a);return za((a=>{const n=o(),s=e();if(_a(l))return l(),a;if(n.length){const e=a.filter((e=>!n.includes(e)));return n.length=0,t({list:e,added:[],removed:[],unchanged:e,finishRemoved:u}),e}return _a((()=>{const e=new Set(s),n=s.slice(),o=[],l=[],d=[];for(const a of s)(i.has(a)?d:o).push(a);let m=!o.length;for(let t=0;t<a.length;t++){const i=a[t];e.has(i)||(r.has(i)||(l.push(i),r.add(i)),c(n,i,t)),m&&i!==n[t]&&(m=!1)}return!l.length&&m?a:(t({list:n,added:o,removed:l,unchanged:d,finishRemoved:u}),i=e,n)}))}),a.appear?[]:n.slice())}function wye(...e){return a=e,(...e)=>{for(const n of a)n&&n(...e)};var a}kye.bind({g:1}),kye.bind({k:1});var Cye=e=>e instanceof Element;function Mye(e,a){if(a(e))return e;if("function"==typeof e&&!e.length)return Mye(e(),a);if(Array.isArray(e)){const n=[];for(const t of e){const e=Mye(t,a);e&&(Array.isArray(e)?n.push.apply(n,e):n.push(e))}return n.length?n:null}return null}function Tye(e,a=Cye,n=Cye){const t=za(e),i=za((()=>Mye(t(),a)));return i.toArray=()=>{const e=i();return Array.isArray(e)?e:e?[e]:[]},i}function Nye(e){requestAnimationFrame((()=>requestAnimationFrame(e)))}function Eye(e,a,n,t){const{onBeforeEnter:i,onEnter:r,onAfterEnter:o}=a;function s(a){a&&a.target!==n||(n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.enterActive),n.classList.remove(...e.enterTo),o?.(n))}i?.(n),n.classList.add(...e.enter),n.classList.add(...e.enterActive),queueMicrotask((()=>{if(!n.parentNode)return t?.();r?.(n,(()=>s()))})),Nye((()=>{n.classList.remove(...e.enter),n.classList.add(...e.enterTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}function xye(e,a,n,t){const{onBeforeExit:i,onExit:r,onAfterExit:o}=a;if(!n.parentNode)return t?.();function s(a){a&&a.target!==n||(t?.(),n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.exitActive),n.classList.remove(...e.exitTo),o?.(n))}i?.(n),n.classList.add(...e.exit),n.classList.add(...e.exitActive),r?.(n,(()=>s())),Nye((()=>{n.classList.remove(...e.exit),n.classList.add(...e.exitTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}var Pye=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 Aye(Tye((()=>e.children)).toArray,{appear:e.appear,onChange({added:n,removed:t,finishRemoved:i,list:r}){const o=a();for(const a of n)Eye(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:n}of s)if(a.isConnected){const t=a.getBoundingClientRect(),i=n.left-t.left,r=n.top-t.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(n){(n.target===a||/transform$/.test(n.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 t)xye(o,e,a,(()=>i([a])))}})},jye=Symbol("fallback");function Lye(e){for(const a of e)a.dispose()}function Bye(e){const{by:a}=e;return za(function(e,a,n,t={}){const i=new Map;return Ha((()=>Lye(i.values()))),()=>{const n=e()||[];return _a((()=>{if(!n.length)return Lye(i.values()),i.clear(),t.fallback?[xa((e=>(i.set(jye,{dispose:e}),t.fallback())))]:[];const e=new Array(n.length),o=i.get(jye);if(!i.size||o){o?.dispose(),i.delete(jye);for(let t=0;t<n.length;t++){const i=n[t];r(e,i,t,a(i,t))}return e}const s=new Set(i.keys());for(let t=0;t<n.length;t++){const o=n[t],l=a(o,t);s.delete(l);const u=i.get(l);u?(e[t]=u.mapped,u.setIndex?.(t),u.setItem((()=>o))):r(e,o,t,l)}for(const a of s)i.get(a)?.dispose(),i.delete(a);return e}))};function r(e,a,t,r){xa((o=>{const[s,l]=Pa(a),u={setItem:l,dispose:o};if(n.length>1){const[e,a]=Pa(t);u.setIndex=a,u.mapped=n(s,e)}else u.mapped=n(s);i.set(r,u),e[t]=u.mapped}))}}((()=>e.each),"function"==typeof a?a:e=>e[a],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function zye(e,a,n,t){const i=()=>{jfe(Pfe(e)).forEach((e=>{e&&jfe(Pfe(a)).forEach((a=>function(e,a,n,t){return e.addEventListener(a,n,t),Lfe(e.removeEventListener.bind(e,a,n,t))}(e,a,n,t)))}))};"function"==typeof e?Ba(i):La(i)}function Rye(e,a,n){const t=new WeakMap,{observe:i,unobserve:r}=function(e,a){const n=new ResizeObserver(e);return Ha(n.disconnect.bind(n)),{observe:e=>n.observe(e,a),unobserve:n.unobserve.bind(n)}}((e=>{for(const n of e){const{contentRect:e,target:i}=n,r=Math.round(e.width),o=Math.round(e.height),s=t.get(i);s&&s.width===r&&s.height===o||(a(e,i,n),t.set(i,{width:r,height:o}))}}),n);Ba((a=>{const n=jfe(Pfe(e)).filter(xfe);return function(e,a,n,t){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)||t(o);for(s of e)a.includes(s)||n(s)}else for(;l<r;l++)t(a[l]);else for(;l<i;l++)n(e[l])}(n,a,i,r),n}),[])}var _ye=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Dye(e){const a={};let n;for(;n=_ye.exec(e);)a[n[1]]=n[2];return a}function Kye(e,a){if("string"==typeof e){if("string"==typeof a)return`${e};${a}`;e=Dye(e)}else"string"==typeof a&&(a=Dye(a));return{...e,...a}}function Hye(e,a){const n=[...e],t=n.indexOf(a);return-1!==t&&n.splice(t,1),n}function Oye(e){return"[object String]"===Object.prototype.toString.call(e)}function Iye(e){return a=>`${e()}-${a}`}function Gye(e,a){return!!e&&(e===a||e.contains(a))}function Vye(e,a=!1){const{activeElement:n}=Fye(e);if(!n?.nodeName)return null;if(Jye(n)&&n.contentDocument)return Vye(n.contentDocument.body,a);if(a){const e=n.getAttribute("aria-activedescendant");if(e){const a=Fye(n).getElementById(e);if(a)return a}}return n}function Fye(e){return e?e.ownerDocument||e:document}function Jye(e){return"IFRAME"===e.tagName}var Uye=(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))(Uye||{});function Wye(e){return"undefined"!=typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function qye(){return Wye(/^Mac/i)}function Zye(){return Wye(/^iPhone/i)||Wye(/^iPad/i)||qye()&&navigator.maxTouchPoints>1}function $ye(e,a){return a&&("function"==typeof a?a(e):a[0](a[1],e)),e?.defaultPrevented}function Yye(e){return a=>{for(const n of e)$ye(a,n)}}function Qye(e){return qye()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Xye(e){if(e)if(function(){if(null==eke){eke=!1;try{document.createElement("div").focus({get preventScroll(){return eke=!0,!0}})}catch(uBe){}}return eke}())e.focus({preventScroll:!0});else{const a=function(e){let a=e.parentNode;const n=[],t=document.scrollingElement||document.documentElement;for(;a instanceof HTMLElement&&a!==t;)(a.offsetHeight<a.scrollHeight||a.offsetWidth<a.scrollWidth)&&n.push({element:a,scrollTop:a.scrollTop,scrollLeft:a.scrollLeft}),a=a.parentNode;t instanceof HTMLElement&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft});return n}(e);e.focus(),function(e){for(const{element:a,scrollTop:n,scrollLeft:t}of e)a.scrollTop=n,a.scrollLeft=t}(a)}}var eke=null;var ake=["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'])"],nke=[...ake,'[tabindex]:not([tabindex="-1"]):not([disabled])'],tke=ake.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",ike=nke.join(':not([hidden]):not([tabindex="-1"]),');function rke(e,a){const n=Array.from(e.querySelectorAll(tke)).filter(oke);return a&&oke(e)&&n.unshift(e),n.forEach(((e,a)=>{if(Jye(e)&&e.contentDocument){const t=rke(e.contentDocument.body,!1);n.splice(a,1,...t)}})),n}function oke(e){return ske(e)&&!function(e){const a=parseInt(e.getAttribute("tabindex")||"0",10);return a<0}(e)}function ske(e){return e.matches(tke)&&lke(e)}function lke(e,a){return"#comment"!==e.nodeName&&function(e){if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const{display:a,visibility:n}=e.style;let t="none"!==a&&"hidden"!==n&&"collapse"!==n;if(t){if(!e.ownerDocument.defaultView)return t;const{getComputedStyle:a}=e.ownerDocument.defaultView,{display:n,visibility:i}=a(e);t="none"!==n&&"hidden"!==i&&"collapse"!==i}return t}(e)&&function(e,a){return!e.hasAttribute("hidden")&&("DETAILS"!==e.nodeName||!a||"SUMMARY"===a.nodeName||e.hasAttribute("open"))}(e,a)&&(!e.parentElement||lke(e.parentElement,e))}function uke(e){for(;e&&!cke(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}function cke(e){const a=window.getComputedStyle(e);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function dke(){}function mke(e,a){return vn(e,a)}var hke=new Map,pke=new Set;function gke(){if("undefined"==typeof window)return;const e=a=>{if(!a.target)return;const n=hke.get(a.target);if(n&&(n.delete(a.propertyName),0===n.size&&(a.target.removeEventListener("transitioncancel",e),hke.delete(a.target)),0===hke.size)){for(const e of pke)e();pke.clear()}};document.body.addEventListener("transitionrun",(a=>{if(!a.target)return;let n=hke.get(a.target);n||(n=new Set,hke.set(a.target,n),a.target.addEventListener("transitioncancel",e)),n.add(a.propertyName)})),document.body.addEventListener("transitionend",e)}function vke(e,a){const n=fke(e,a,"left"),t=fke(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;n<=o?o=n:n+i>l&&(o+=n+i-l),t<=s?s=t:t+r>u&&(s+=t+r-u),e.scrollLeft=o,e.scrollTop=s}function fke(e,a,n){const t="left"===n?"offsetLeft":"offsetTop";let i=0;for(;a.offsetParent&&(i+=a[t],a.offsetParent!==e);){if(a.offsetParent.contains(e)){i-=e[t];break}a=a.offsetParent}return i}"undefined"!=typeof document&&("loading"!==document.readyState?gke():document.addEventListener("DOMContentLoaded",gke));var yke={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 kke(e){return a=>(e(a),()=>e(void 0))}function bke(e,a){const[n,t]=Pa(Ske(a?.()));return Ba((()=>{t(e()?.tagName.toLowerCase()||Ske(a?.()))})),n}function Ske(e){return Oye(e)?e:void 0}function Ake(e){const[a,n]=fn(e,["as"]);if(!a.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return dn(at,vn(n,{get component(){return a.as}}))}var wke=["id","name","validationState","required","disabled","readOnly"];var Cke=Fa();function Mke(){const e=Ja(Cke);if(void 0===e)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function Tke(e){const a=Mke(),n=mke({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),dn(Ake,vn({as:"div"},(()=>a.dataset()),n))}function Nke(e){const a=Mke(),n=mke({id:a.generateId("error-message")},e),[t,i]=fn(n,["forceMount"]),r=()=>"invalid"===a.validationState();return Ba((()=>{r()&&Ha(a.registerErrorMessage(i.id))})),dn(Cn,{get when(){return t.forceMount||r()},get children(){return dn(Ake,vn({as:"div"},(()=>a.dataset()),i))}})}function Eke(e){let a;const n=Mke(),t=mke({id:n.generateId("label")},e),[i,r]=fn(t,["ref"]),o=bke((()=>a),(()=>"label"));return Ba((()=>Ha(n.registerLabel(r.id)))),dn(Ake,vn({as:"label",ref(e){const n=wye((e=>a=e),i.ref);"function"==typeof n&&n(e)},get for(){return za((()=>"label"===o()))()?n.fieldId():void 0}},(()=>n.dataset()),r))}function xke(e,a){Ba(Da(e,(e=>{if(null==e)return;const n=function(e){return function(e){return e.matches("textarea, input, select, button")}(e)?e.form:e.closest("form")}(e);null!=n&&(n.addEventListener("reset",a,{passive:!0}),Ha((()=>{n.removeEventListener("reset",a)})))})))}function Pke(e){const[a,n]=Pa(e.defaultValue?.()),t=za((()=>void 0!==e.value?.())),i=za((()=>t()?e.value?.():a()));return[i,a=>{_a((()=>{const r=function(e,...a){return"function"==typeof e?e(...a):e}(a,i());return Object.is(r,i())||(t()||n(r),e.onChange?.(r)),r}))}]}function jke(e){const[a,n]=Pke(e);return[()=>a()??!1,n]}var Lke=Object.defineProperty,Bke=(e,a)=>{for(var n in a)Lke(e,n,{get:a[n],enumerable:!0})},zke=Fa();function Rke(){return Ja(zke)}function _ke(e,a){return Boolean(a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function Dke(e,a){const n=function(e){const a=e.map(((e,a)=>[a,e]));let n=!1;return a.sort((([e,a],[t,i])=>{const r=a.ref(),o=i.ref();return r===o?0:r&&o?_ke(r,o)?(e>t&&(n=!0),-1):(e<t&&(n=!0),1):0})),n?a.map((([e,a])=>a)):e}(e);e!==n&&a(n)}function Kke(e,a){if("function"!=typeof IntersectionObserver)return void function(e,a){Ba((()=>{const n=setTimeout((()=>{Dke(e(),a)}));Ha((()=>clearTimeout(n)))}))}(e,a);let n=[];Ba((()=>{const t=function(e){const a=e[0],n=e[e.length-1]?.ref();let t=a?.ref()?.parentElement;for(;t;){if(n&&t.contains(n))return t;t=t.parentElement}return Fye(t).body}(e()),i=new IntersectionObserver((()=>{const t=!!n.length;n=e(),t&&Dke(e(),a)}),{root:t});for(const a of e()){const e=a.ref();e&&i.observe(e)}Ha((()=>i.disconnect()))}))}function Hke(e={}){const[a,n]=function(e){const[a,n]=Pke(e);return[()=>a()??[],n]}({value:()=>Pfe(e.items),onChange:a=>e.onItemsChange?.(a)});Kke(a,n);const t=e=>(n((a=>{const n=function(e,a){const n=a.ref();if(!n)return-1;let t=e.length;if(!t)return-1;for(;t--;){const a=e[t]?.ref();if(a&&_ke(a,n))return t+1}return 0}(a,e);return function(e,a,n=-1){return n in e?[...e.slice(0,n),a,...e.slice(n)]:[...e,a]}(a,e,n)})),()=>{n((a=>{const n=a.filter((a=>a.ref()!==e.ref()));return a.length===n.length?a:n}))});return{DomCollectionProvider:e=>dn(zke.Provider,{value:{registerItem:t},get children(){return e.children}})}}function Oke(e){const a=function(){const e=Rke();if(void 0===e)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}(),n=mke({shouldRegisterItem:!0},e);Ba((()=>{if(!n.shouldRegisterItem)return;Ha(a.registerItem(n.getItem()))}))}function Ike(e){let a=e.startIndex??0;const n=e.startLevel??0,t=[],i=a=>{if(null==a)return"";const n=e.getKey??"key",t=Oye(n)?a[n]:n(a);return null!=t?String(t):""},r=a=>{if(null==a)return"";const n=e.getTextValue??"textValue",t=Oye(n)?a[n]:n(a);return null!=t?String(t):""},o=a=>{if(null==a)return!1;const n=e.getDisabled??"disabled";return(Oye(n)?a[n]:n(a))??!1},s=a=>{if(null!=a)return Oye(e.getSectionChildren)?a[e.getSectionChildren]:e.getSectionChildren?.(a)};for(const l of e.dataSource)if(Oye(l)||"number"==typeof l)t.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:o(l),level:n,index:a}),a++;else if(null!=s(l)){t.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:a}),a++;const i=s(l)??[];if(i.length>0){const r=Ike({dataSource:i,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:a,startLevel:n+1});t.push(...r),a+=r.length}}else t.push({type:"item",rawValue:l,key:i(l),textValue:r(l),disabled:o(l),level:n,index:a}),a++;return t}function Gke(e,a=[]){return za((()=>{const n=Ike({dataSource:Pfe(e.dataSource),getKey:Pfe(e.getKey),getTextValue:Pfe(e.getTextValue),getDisabled:Pfe(e.getDisabled),getSectionChildren:Pfe(e.getSectionChildren)});for(let e=0;e<a.length;e++)a[e]();return e.factory(n)}))}var Vke=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),Fke=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function Jke(e){return function(e){if(Intl.Locale){const a=new Intl.Locale(e).maximize().script??"";return Vke.has(a)}const a=e.split("-")[0];return Fke.has(a)}(e)?"rtl":"ltr"}function Uke(){let e="undefined"!=typeof navigator&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:Jke(e)}}var Wke=Uke(),qke=new Set;function Zke(){Wke=Uke();for(const e of qke)e(Wke)}var $ke=Fa();function Yke(){const e=function(){const[e,a]=Pa(Wke),n=za((()=>e()));return Ka((()=>{0===qke.size&&window.addEventListener("languagechange",Zke),qke.add(a),Ha((()=>{qke.delete(a),0===qke.size&&window.removeEventListener("languagechange",Zke)}))})),{locale:()=>n().locale,direction:()=>n().direction}}();return Ja($ke)||e}var Qke=new Map;var Xke=class e extends Set{anchorKey;currentKey;constructor(a,n,t){super(a),a instanceof e?(this.anchorKey=n||a.anchorKey,this.currentKey=t||a.currentKey):(this.anchorKey=n,this.currentKey=t)}};function ebe(e){return qye()||Zye()?e.altKey:e.ctrlKey}function abe(e){return qye()?e.metaKey:e.ctrlKey}function nbe(e){return new Xke(e)}function tbe(e){const a=mke({selectionMode:"none",selectionBehavior:"toggle"},e),[n,t]=Pa(!1),[i,r]=Pa(),o=za((()=>{const e=Pfe(a.selectedKeys);return null!=e?nbe(e):e})),s=za((()=>{const e=Pfe(a.defaultSelectedKeys);return null!=e?nbe(e):new Xke})),[l,u]=function(e){const[a,n]=Pke(e);return[()=>a()??new Xke,n]}({value:o,defaultValue:s,onChange:e=>a.onSelectionChange?.(e)}),[c,d]=Pa(Pfe(a.selectionBehavior));return Ba((()=>{const e=l();"replace"===Pfe(a.selectionBehavior)&&"toggle"===c()&&"object"==typeof e&&0===e.size&&d("replace")})),Ba((()=>{d(Pfe(a.selectionBehavior)??"toggle")})),{selectionMode:()=>Pfe(a.selectionMode),disallowEmptySelection:()=>Pfe(a.disallowEmptySelection)??!1,selectionBehavior:c,setSelectionBehavior:d,isFocused:n,setFocused:t,focusedKey:i,setFocusedKey:r,selectedKeys:l,setSelectedKeys:e=>{!Pfe(a.allowDuplicateSelectionEvents)&&function(e,a){if(e.size!==a.size)return!1;for(const n of e)if(!a.has(n))return!1;return!0}(e,l())||u(e)}}}function ibe(e,a,n){const t=vn({selectOnFocus:()=>"replace"===Pfe(e.selectionManager).selectionBehavior()},e),i=()=>a(),{direction:r}=Yke();let o={top:0,left:0};zye((()=>Pfe(t.isVirtualized)?void 0:i()),"scroll",(()=>{const e=i();e&&(o={top:e.scrollTop,left:e.scrollLeft})}));const{typeSelectHandlers:s}=function(e){const[a,n]=Pa(""),[t,i]=Pa(-1);return{typeSelectHandlers:{onKeyDown:r=>{if(Pfe(e.isDisabled))return;const o=Pfe(e.keyboardDelegate),s=Pfe(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=n((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(t()),i(window.setTimeout((()=>n("")),500))}}}}({isDisabled:()=>Pfe(t.disallowTypeAhead),keyboardDelegate:()=>Pfe(t.keyboardDelegate),selectionManager:()=>Pfe(t.selectionManager)}),l=()=>Pfe(t.orientation)??"vertical",u=()=>{const e=Pfe(t.autoFocus);if(!e)return;const n=Pfe(t.selectionManager),i=Pfe(t.keyboardDelegate);let r;"first"===e&&(r=i.getFirstKey?.()),"last"===e&&(r=i.getLastKey?.());const o=n.selectedKeys();o.size&&(r=o.values().next().value),n.setFocused(!0),n.setFocusedKey(r);const s=a();s&&null==r&&!Pfe(t.shouldUseVirtualFocus)&&Xye(s)};Ka((()=>{t.deferAutoFocus?setTimeout(u,0):u()})),Ba(Da([i,()=>Pfe(t.isVirtualized),()=>Pfe(t.selectionManager).focusedKey()],(e=>{const[a,n,i]=e;if(n)i&&t.scrollToKey?.(i);else if(i&&a){const e=a.querySelector(`[data-key="${i}"]`);e&&vke(a,e)}})));return{tabIndex:za((()=>{if(!Pfe(t.shouldUseVirtualFocus))return null==Pfe(t.selectionManager).focusedKey()?0:-1})),onKeyDown:e=>{$ye(e,s.onKeyDown),e.altKey&&"Tab"===e.key&&e.preventDefault();const n=a();if(!n?.contains(e.target))return;const i=Pfe(t.selectionManager),o=Pfe(t.selectOnFocus),u=a=>{null!=a&&(i.setFocusedKey(a),e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&!ebe(e)&&i.replaceSelection(a))},c=Pfe(t.keyboardDelegate),d=Pfe(t.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 n;n=null!=m?c.getKeyLeftOf(m):a?c.getFirstKey?.():c.getLastKey?.(),u(n)}break;case"vertical"===l()?"ArrowRight":"ArrowDown":if(c.getKeyRightOf){e.preventDefault();const a="rtl"===r();let n;n=null!=m?c.getKeyRightOf(m):a?c.getLastKey?.():c.getFirstKey?.(),u(n)}break;case"Home":if(c.getFirstKey){e.preventDefault();const a=c.getFirstKey(m,abe(e));null!=a&&(i.setFocusedKey(a),abe(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,abe(e));null!=a&&(i.setFocusedKey(a),abe(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":abe(e)&&"multiple"===i.selectionMode()&&!0!==Pfe(t.disallowSelectAll)&&(e.preventDefault(),i.selectAll());break;case"Escape":e.defaultPrevented||(e.preventDefault(),Pfe(t.disallowEmptySelection)||i.clearSelection());break;case"Tab":if(!Pfe(t.allowsTabNavigation)){if(e.shiftKey)n.focus();else{const e=function(e,a){const n=a?.tabbable?ike:tke,t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>a?.from?.contains(e)?NodeFilter.FILTER_REJECT:e.matches(n)&&lke(e)&&(!a?.accept||a.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});return a?.from&&(t.currentNode=a.from),t}(n,{tabbable:!0});let a,t;do{t=e.lastChild(),t&&(a=t)}while(t);a&&!a.contains(document.activeElement)&&Xye(a)}break}}},onMouseDown:e=>{i()===e.target&&e.preventDefault()},onFocusIn:e=>{const a=Pfe(t.selectionManager),n=Pfe(t.keyboardDelegate),r=Pfe(t.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 t=e=>{null!=e&&(a.setFocusedKey(e),r&&a.replaceSelection(e))},i=e.relatedTarget;i&&e.currentTarget.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?t(a.lastSelectedKey()??n.getLastKey?.()):t(a.firstSelectedKey()??n.getFirstKey?.())}else if(!Pfe(t.isVirtualized)){const e=i();if(e){e.scrollTop=o.top,e.scrollLeft=o.left;const n=e.querySelector(`[data-key="${a.focusedKey()}"]`);n&&(Xye(n),vke(e,n))}}},onFocusOut:e=>{const a=Pfe(t.selectionManager);e.currentTarget.contains(e.relatedTarget)||a.setFocused(!1)}}}function rbe(e,a){const n=()=>Pfe(e.selectionManager),t=()=>Pfe(e.key),i=()=>Pfe(e.shouldUseVirtualFocus),r=e=>{"none"!==n().selectionMode()&&("single"===n().selectionMode()?n().isSelected(t())&&!n().disallowEmptySelection()?n().toggleSelection(t()):n().replaceSelection(t()):e?.shiftKey?n().extendSelection(t()):"toggle"===n().selectionBehavior()||abe(e)||"pointerType"in e&&"touch"===e.pointerType?n().toggleSelection(t()):n().replaceSelection(t()))},o=()=>Pfe(e.disabled)||n().isDisabled(t()),s=()=>!o()&&n().canSelectItem(t());let l=null;const u=za((()=>{if(!i()&&!o())return t()===n().focusedKey()?0:-1})),c=za((()=>Pfe(e.virtualized)?void 0:t()));return Ba(Da([a,t,i,()=>n().focusedKey(),()=>n().isFocused()],(([a,n,t,i,r])=>{a&&n===i&&r&&!t&&document.activeElement!==a&&(e.focus?e.focus():Xye(a))}))),{isSelected:()=>n().isSelected(t()),isDisabled:o,allowsSelection:s,tabIndex:u,dataKey:c,onPointerDown:a=>{s()&&(l=a.pointerType,"mouse"!==a.pointerType||0!==a.button||Pfe(e.shouldSelectOnPressUp)||r(a))},onPointerUp:a=>{s()&&"mouse"===a.pointerType&&0===a.button&&Pfe(e.shouldSelectOnPressUp)&&Pfe(e.allowsDifferentPressOrigin)&&r(a)},onClick:a=>{s()&&(Pfe(e.shouldSelectOnPressUp)&&!Pfe(e.allowsDifferentPressOrigin)||"mouse"!==l)&&r(a)},onKeyDown:e=>{s()&&["Enter"," "].includes(e.key)&&(ebe(e)?n().toggleSelection(t()):r(e))},onMouseDown:e=>{o()&&e.preventDefault()},onFocus:e=>{const r=a();i()||o()||!r||e.target===r&&n().setFocusedKey(t())}}}var obe=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 n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index<e.index)||(e=n)}return e?.key}lastSelectedKey(){let e;for(const a of this.state.selectedKeys()){const n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index>e.index)||(e=n)}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 n=this.state.selectedKeys(),t=n.anchorKey||a,i=new Xke(n,t,a);for(const r of this.getKeyRange(t,n.currentKey||a))i.delete(r);for(const r of this.getKeyRange(a,t))this.canSelectItem(r)&&i.add(r);this.state.setSelectedKeys(i)}getKeyRange(e,a){const n=this.collection().getItem(e),t=this.collection().getItem(a);return n&&t?null!=n.index&&null!=t.index&&n.index<=t.index?this.getKeyRangeInternal(e,a):this.getKeyRangeInternal(a,e):[]}getKeyRangeInternal(e,a){const n=[];let t=e;for(;null!=t;){const e=this.collection().getItem(t);if(e&&"item"===e.type&&n.push(t),t===a)return n;t=this.collection().getKeyAfter(t)}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 n=new Xke(this.state.selectedKeys());n.has(a)?n.delete(a):this.canSelectItem(a)&&(n.add(a),n.anchorKey=a,n.currentKey=a),this.disallowEmptySelection()&&0===n.size||this.state.setSelectedKeys(n)}replaceSelection(e){if("none"===this.selectionMode())return;const a=this.getKey(e);if(null==a)return;const n=this.canSelectItem(a)?new Xke([a],a,a):new Xke;this.state.setSelectedKeys(n)}setSelectedKeys(e){if("none"===this.selectionMode())return;const a=new Xke;for(const n of e){const e=this.getKey(n);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 Xke)}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 n of e)if(!a.has(n))return!1;for(const n of a)if(!e.has(n))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 n=this.collection().getItem(a);if(!n)continue;"item"===n.type&&e.push(a)}a=this.collection().getKeyAfter(a)}})(this.collection().getFirstKey()),e}},sbe=class{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const t of e)this.keyMap.set(t.key,t);if(0===this.keyMap.size)return;let a,n=0;for(const[t,i]of this.keyMap)a?(a.nextKey=t,i.prevKey=a.key):(this.firstKey=t,i.prevKey=void 0),"item"===i.type&&(i.index=n++),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 lbe,ube=e=>"function"==typeof e?e():e,cbe=e=>{const a=za((()=>{const a=ube(e.element);if(a)return getComputedStyle(a)})),n=()=>a()?.animationName??"none",[t,i]=Pa(ube(e.show)?"present":"hidden");let r="none";return Ba((t=>{const o=ube(e.show);return _a((()=>{if(t===o)return o;const e=r,s=n();if(o)i("present");else if("none"===s||"none"===a()?.display)i("hidden");else{i(!0===t&&e!==s?"hiding":"hidden")}})),o})),Ba((()=>{const a=ube(e.element);if(!a)return;const o=e=>{e.target===a&&(r=n())},s=e=>{const r=n().includes(e.animationName);e.target===a&&r&&"hiding"===t()&&i("hidden")};a.addEventListener("animationstart",o),a.addEventListener("animationcancel",s),a.addEventListener("animationend",s),Ha((()=>{a.removeEventListener("animationstart",o),a.removeEventListener("animationcancel",s),a.removeEventListener("animationend",s)}))})),{present:()=>"present"===t()||"hiding"===t(),state:t}},dbe="data-kb-top-layer",mbe=!1,hbe=[];function pbe(e){return hbe.findIndex((a=>a.node===e))}function gbe(){return hbe.filter((e=>e.isPointerBlocking))}function vbe(){return gbe().length>0}function fbe(e){const a=pbe([...gbe()].slice(-1)[0]?.node);return pbe(e)<a}var ybe={layers:hbe,isTopMostLayer:function(e){return hbe[hbe.length-1].node===e},hasPointerBlockingLayer:vbe,isBelowPointerBlockingLayer:fbe,addLayer:function(e){hbe.push(e)},removeLayer:function(e){const a=pbe(e);a<0||hbe.splice(a,1)},indexOf:pbe,find:function(e){return hbe[pbe(e)]},assignPointerEventToLayers:function(){for(const{node:e}of hbe)e.style.pointerEvents=fbe(e)?"none":"auto"},disableBodyPointerEvents:function(e){if(vbe()&&!mbe){const a=Fye(e);lbe=document.body.style.pointerEvents,a.body.style.pointerEvents="none",mbe=!0}},restoreBodyPointerEvents:function(e){if(vbe())return;const a=Fye(e);a.body.style.pointerEvents=lbe,0===a.body.style.length&&a.body.removeAttribute("style"),mbe=!1}};Bke({},{Button:()=>Sbe,Root:()=>bbe});var kbe=["button","color","file","image","reset","submit"];function bbe(e){let a;const n=mke({type:"button"},e),[t,i]=fn(n,["ref","type","disabled"]),r=bke((()=>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!==kbe.indexOf(e.type)}({tagName:e,type:t.type})})),s=za((()=>"input"===r())),l=za((()=>"a"===r()&&null!=a?.getAttribute("href")));return dn(Ake,vn({as:"button",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)},get type(){return o()||s()?t.type:void 0},get role(){return o()||l()?void 0:"button"},get tabIndex(){return o()||l()||t.disabled?void 0:0},get disabled(){return o()||s()?t.disabled:void 0},get"aria-disabled"(){return!(o()||s()||!t.disabled)||void 0},get"data-disabled"(){return t.disabled?"":void 0}},i))}var Sbe=bbe,Abe=["top","right","bottom","left"],wbe=Math.min,Cbe=Math.max,Mbe=Math.round,Tbe=Math.floor,Nbe=e=>({x:e,y:e}),Ebe={left:"right",right:"left",bottom:"top",top:"bottom"},xbe={start:"end",end:"start"};function Pbe(e,a,n){return Cbe(e,wbe(a,n))}function jbe(e,a){return"function"==typeof e?e(a):e}function Lbe(e){return e.split("-")[0]}function Bbe(e){return e.split("-")[1]}function zbe(e){return"x"===e?"y":"x"}function Rbe(e){return"y"===e?"height":"width"}function _be(e){return["top","bottom"].includes(Lbe(e))?"y":"x"}function Dbe(e){return zbe(_be(e))}function Kbe(e){return e.replace(/start|end/g,(e=>xbe[e]))}function Hbe(e){return e.replace(/left|right|bottom|top/g,(e=>Ebe[e]))}function Obe(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 Ibe(e){const{x:a,y:n,width:t,height:i}=e;return{width:t,height:i,top:n,left:a,right:a+t,bottom:n+i,x:a,y:n}}function Gbe(e,a,n){let{reference:t,floating:i}=e;const r=_be(a),o=Dbe(a),s=Rbe(o),l=Lbe(a),u="y"===r,c=t.x+t.width/2-i.width/2,d=t.y+t.height/2-i.height/2,m=t[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:t.y-i.height};break;case"bottom":h={x:c,y:t.y+t.height};break;case"right":h={x:t.x+t.width,y:d};break;case"left":h={x:t.x-i.width,y:d};break;default:h={x:t.x,y:t.y}}switch(Bbe(a)){case"start":h[o]-=m*(n&&u?-1:1);break;case"end":h[o]+=m*(n&&u?-1:1)}return h}async function Vbe(e,a){var n;void 0===a&&(a={});const{x:t,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}=jbe(a,e),p=Obe(h),g=s[m?"floating"===d?"reference":"floating":d],v=Ibe(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),f="floating"===d?{x:t,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),k=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},b=Ibe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:f,offsetParent:y,strategy:l}):f);return{top:(v.top-b.top+p.top)/k.y,bottom:(b.bottom-v.bottom+p.bottom)/k.y,left:(v.left-b.left+p.left)/k.x,right:(b.right-v.right+p.right)/k.x}}function Fbe(e,a){return{top:e.top-a.height,right:e.right-a.width,bottom:e.bottom-a.height,left:e.left-a.width}}function Jbe(e){return Abe.some((a=>e[a]>=0))}function Ube(e){return Zbe(e)?(e.nodeName||"").toLowerCase():"#document"}function Wbe(e){var a;return(null==e||null==(a=e.ownerDocument)?void 0:a.defaultView)||window}function qbe(e){var a;return null==(a=(Zbe(e)?e.ownerDocument:e.document)||window.document)?void 0:a.documentElement}function Zbe(e){return e instanceof Node||e instanceof Wbe(e).Node}function $be(e){return e instanceof Element||e instanceof Wbe(e).Element}function Ybe(e){return e instanceof HTMLElement||e instanceof Wbe(e).HTMLElement}function Qbe(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof Wbe(e).ShadowRoot)}function Xbe(e){const{overflow:a,overflowX:n,overflowY:t,display:i}=rSe(e);return/auto|scroll|overlay|hidden|clip/.test(a+t+n)&&!["inline","contents"].includes(i)}function eSe(e){return["table","td","th"].includes(Ube(e))}function aSe(e){return[":popover-open",":modal"].some((a=>{try{return e.matches(a)}catch(uBe){return!1}}))}function nSe(e){const a=tSe(),n=$be(e)?rSe(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!a&&!!n.backdropFilter&&"none"!==n.backdropFilter||!a&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function tSe(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function iSe(e){return["html","body","#document"].includes(Ube(e))}function rSe(e){return Wbe(e).getComputedStyle(e)}function oSe(e){return $be(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sSe(e){if("html"===Ube(e))return e;const a=e.assignedSlot||e.parentNode||Qbe(e)&&e.host||qbe(e);return Qbe(a)?a.host:a}function lSe(e){const a=sSe(e);return iSe(a)?e.ownerDocument?e.ownerDocument.body:e.body:Ybe(a)&&Xbe(a)?a:lSe(a)}function uSe(e,a,n){var t;void 0===a&&(a=[]),void 0===n&&(n=!0);const i=lSe(e),r=i===(null==(t=e.ownerDocument)?void 0:t.body),o=Wbe(i);return r?a.concat(o,o.visualViewport||[],Xbe(i)?i:[],o.frameElement&&n?uSe(o.frameElement):[]):a.concat(i,uSe(i,[],n))}function cSe(e){const a=rSe(e);let n=parseFloat(a.width)||0,t=parseFloat(a.height)||0;const i=Ybe(e),r=i?e.offsetWidth:n,o=i?e.offsetHeight:t,s=Mbe(n)!==r||Mbe(t)!==o;return s&&(n=r,t=o),{width:n,height:t,$:s}}function dSe(e){return $be(e)?e:e.contextElement}function mSe(e){const a=dSe(e);if(!Ybe(a))return Nbe(1);const n=a.getBoundingClientRect(),{width:t,height:i,$:r}=cSe(a);let o=(r?Mbe(n.width):n.width)/t,s=(r?Mbe(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var hSe=Nbe(0);function pSe(e){const a=Wbe(e);return tSe()&&a.visualViewport?{x:a.visualViewport.offsetLeft,y:a.visualViewport.offsetTop}:hSe}function gSe(e,a,n,t){void 0===a&&(a=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),r=dSe(e);let o=Nbe(1);a&&(t?$be(t)&&(o=mSe(t)):o=mSe(e));const s=function(e,a,n){return void 0===a&&(a=!1),!(!n||a&&n!==Wbe(e))&&a}(r,n,t)?pSe(r):Nbe(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=Wbe(r),a=t&&$be(t)?Wbe(t):t;let n=e,i=n.frameElement;for(;i&&t&&a!==n;){const e=mSe(i),a=i.getBoundingClientRect(),t=rSe(i),r=a.left+(i.clientLeft+parseFloat(t.paddingLeft))*e.x,o=a.top+(i.clientTop+parseFloat(t.paddingTop))*e.y;l*=e.x,u*=e.y,c*=e.x,d*=e.y,l+=r,u+=o,n=Wbe(i),i=n.frameElement}}return Ibe({width:c,height:d,x:l,y:u})}function vSe(e){return gSe(qbe(e)).left+oSe(e).scrollLeft}function fSe(e,a,n){let t;if("viewport"===a)t=function(e,a){const n=Wbe(e),t=qbe(e),i=n.visualViewport;let r=t.clientWidth,o=t.clientHeight,s=0,l=0;if(i){r=i.width,o=i.height;const e=tSe();(!e||e&&"fixed"===a)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:o,x:s,y:l}}(e,n);else if("document"===a)t=function(e){const a=qbe(e),n=oSe(e),t=e.ownerDocument.body,i=Cbe(a.scrollWidth,a.clientWidth,t.scrollWidth,t.clientWidth),r=Cbe(a.scrollHeight,a.clientHeight,t.scrollHeight,t.clientHeight);let o=-n.scrollLeft+vSe(e);const s=-n.scrollTop;return"rtl"===rSe(t).direction&&(o+=Cbe(a.clientWidth,t.clientWidth)-i),{width:i,height:r,x:o,y:s}}(qbe(e));else if($be(a))t=function(e,a){const n=gSe(e,!0,"fixed"===a),t=n.top+e.clientTop,i=n.left+e.clientLeft,r=Ybe(e)?mSe(e):Nbe(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:t*r.y}}(a,n);else{const n=pSe(e);t={...a,x:a.x-n.x,y:a.y-n.y}}return Ibe(t)}function ySe(e,a){const n=sSe(e);return!(n===a||!$be(n)||iSe(n))&&("fixed"===rSe(n).position||ySe(n,a))}function kSe(e,a,n){const t=Ybe(a),i=qbe(a),r="fixed"===n,o=gSe(e,!0,r,a);let s={scrollLeft:0,scrollTop:0};const l=Nbe(0);if(t||!t&&!r)if(("body"!==Ube(a)||Xbe(i))&&(s=oSe(a)),t){const e=gSe(a,!0,r,a);l.x=e.x+a.clientLeft,l.y=e.y+a.clientTop}else i&&(l.x=vSe(i));return{x:o.left+s.scrollLeft-l.x,y:o.top+s.scrollTop-l.y,width:o.width,height:o.height}}function bSe(e){return"static"===rSe(e).position}function SSe(e,a){return Ybe(e)&&"fixed"!==rSe(e).position?a?a(e):e.offsetParent:null}function ASe(e,a){const n=Wbe(e);if(aSe(e))return n;if(!Ybe(e)){let a=sSe(e);for(;a&&!iSe(a);){if($be(a)&&!bSe(a))return a;a=sSe(a)}return n}let t=SSe(e,a);for(;t&&eSe(t)&&bSe(t);)t=SSe(t,a);return t&&iSe(t)&&bSe(t)&&!nSe(t)?n:t||function(e){let a=sSe(e);for(;Ybe(a)&&!iSe(a);){if(nSe(a))return a;if(aSe(a))return null;a=sSe(a)}return null}(e)||n}var wSe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:a,rect:n,offsetParent:t,strategy:i}=e;const r="fixed"===i,o=qbe(t),s=!!a&&aSe(a.floating);if(t===o||s&&r)return n;let l={scrollLeft:0,scrollTop:0},u=Nbe(1);const c=Nbe(0),d=Ybe(t);if((d||!d&&!r)&&(("body"!==Ube(t)||Xbe(o))&&(l=oSe(t)),Ybe(t))){const e=gSe(t);u=mSe(t),c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x,y:n.y*u.y-l.scrollTop*u.y+c.y}},getDocumentElement:qbe,getClippingRect:function(e){let{element:a,boundary:n,rootBoundary:t,strategy:i}=e;const r=[..."clippingAncestors"===n?aSe(a)?[]:function(e,a){const n=a.get(e);if(n)return n;let t=uSe(e,[],!1).filter((e=>$be(e)&&"body"!==Ube(e))),i=null;const r="fixed"===rSe(e).position;let o=r?sSe(e):e;for(;$be(o)&&!iSe(o);){const a=rSe(o),n=nSe(o);n||"fixed"!==a.position||(i=null),(r?!n&&!i:!n&&"static"===a.position&&i&&["absolute","fixed"].includes(i.position)||Xbe(o)&&!n&&ySe(e,o))?t=t.filter((e=>e!==o)):i=a,o=sSe(o)}return a.set(e,t),t}(a,this._c):[].concat(n),t],o=r.reduce(((e,n)=>{const t=fSe(a,n,i);return e.top=Cbe(t.top,e.top),e.right=wbe(t.right,e.right),e.bottom=wbe(t.bottom,e.bottom),e.left=Cbe(t.left,e.left),e}),fSe(a,r[0],i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:ASe,getElementRects:async function(e){const a=this.getOffsetParent||ASe,n=this.getDimensions,t=await n(e.floating);return{reference:kSe(e.reference,await a(e.floating),e.strategy),floating:{x:0,y:0,width:t.width,height:t.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:a,height:n}=cSe(e);return{width:a,height:n}},getScale:mSe,isElement:$be,isRTL:function(e){return"rtl"===rSe(e).direction}};function CSe(e,a,n,t){void 0===t&&(t={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=t,u=dSe(e),c=i||r?[...u?uSe(u):[],...uSe(a)]:[];c.forEach((e=>{i&&e.addEventListener("scroll",n,{passive:!0}),r&&e.addEventListener("resize",n)}));const d=u&&s?function(e,a){let n,t=null;const i=qbe(e);function r(){var e;clearTimeout(n),null==(e=t)||e.disconnect(),t=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:-Tbe(c)+"px "+-Tbe(i.clientWidth-(u+d))+"px "+-Tbe(i.clientHeight-(c+m))+"px "+-Tbe(u)+"px",threshold:Cbe(0,wbe(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):n=setTimeout((()=>{o(!1,1e-7)}),1e3)}p=!1}try{t=new IntersectionObserver(g,{...h,root:i.ownerDocument})}catch(uBe){t=new IntersectionObserver(g,h)}t.observe(e)}(!0),r}(u,n):null;let m,h=-1,p=null;o&&(p=new ResizeObserver((e=>{let[t]=e;t&&t.target===u&&p&&(p.unobserve(a),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(a)}))),n()})),u&&!l&&p.observe(u),p.observe(a));let g=l?gSe(e):null;return l&&function a(){const t=gSe(e);!g||t.x===g.x&&t.y===g.y&&t.width===g.width&&t.height===g.height||n();g=t,m=requestAnimationFrame(a)}(),n(),()=>{var e;c.forEach((e=>{i&&e.removeEventListener("scroll",n),r&&e.removeEventListener("resize",n)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var MSe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(a){var n,t;const{x:i,y:r,placement:o,middlewareData:s}=a,l=await async function(e,a){const{placement:n,platform:t,elements:i}=e,r=await(null==t.isRTL?void 0:t.isRTL(i.floating)),o=Lbe(n),s=Bbe(n),l="y"===_be(n),u=["left","top"].includes(o)?-1:1,c=r&&l?-1:1,d=jbe(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==(n=s.offset)?void 0:n.placement)&&null!=(t=s.arrow)&&t.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:o}}}}},TSe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(a){const{x:n,y:t,placement:i}=a,{mainAxis:r=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:a,y:n}=e;return{x:a,y:n}}},...l}=jbe(e,a),u={x:n,y:t},c=await Vbe(a,l),d=_be(Lbe(i)),m=zbe(d);let h=u[m],p=u[d];if(r){h=Pbe(h+c["y"===m?"top":"left"],h,h-c["y"===m?"bottom":"right"])}if(o){p=Pbe(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-n,y:g.y-t}}}}},NSe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(a){var n,t;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,...v}=jbe(e,a);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const f=Lbe(i),y=_be(s),k=Lbe(s)===s,b=await(null==l.isRTL?void 0:l.isRTL(u.floating)),S=m||(k||!g?[Hbe(s)]:function(e){const a=Hbe(e);return[Kbe(e),a,Kbe(a)]}(s)),A="none"!==p;!m&&A&&S.push(...function(e,a,n,t){const i=Bbe(e);let r=function(e,a,n){const t=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return n?a?i:t:a?t:i;case"left":case"right":return a?r:o;default:return[]}}(Lbe(e),"start"===n,t);return i&&(r=r.map((e=>e+"-"+i)),a&&(r=r.concat(r.map(Kbe)))),r}(s,g,p,b));const w=[s,...S],C=await Vbe(a,v),M=[];let T=(null==(t=r.flip)?void 0:t.overflows)||[];if(c&&M.push(C[f]),d){const e=function(e,a,n){void 0===n&&(n=!1);const t=Bbe(e),i=Dbe(e),r=Rbe(i);let o="x"===i?t===(n?"end":"start")?"right":"left":"start"===t?"bottom":"top";return a.reference[r]>a.floating[r]&&(o=Hbe(o)),[o,Hbe(o)]}(i,o,b);M.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:i,overflows:M}],!M.every((e=>e<=0))){var N,E;const e=((null==(N=r.flip)?void 0:N.index)||0)+1,a=w[e];if(a)return{data:{index:e,overflows:T},reset:{placement:a}};let n=null==(E=T.filter((e=>e.overflows[0]<=0)).sort(((e,a)=>e.overflows[1]-a.overflows[1]))[0])?void 0:E.placement;if(!n)switch(h){case"bestFit":{var x;const e=null==(x=T.filter((e=>{if(A){const a=_be(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:x[0];e&&(n=e);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}},ESe=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(a){const{placement:n,rects:t,platform:i,elements:r}=a,{apply:o=()=>{},...s}=jbe(e,a),l=await Vbe(a,s),u=Lbe(n),c=Bbe(n),d="y"===_be(n),{width:m,height:h}=t.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 v=h-l.top-l.bottom,f=m-l.left-l.right,y=wbe(h-l[p],v),k=wbe(m-l[g],f),b=!a.middlewareData.shift;let S=y,A=k;if(d?A=c||b?wbe(k,f):f:S=c||b?wbe(y,v):v,b&&!c){const e=Cbe(l.left,0),a=Cbe(l.right,0),n=Cbe(l.top,0),t=Cbe(l.bottom,0);d?A=m-2*(0!==e||0!==a?e+a:Cbe(l.left,l.right)):S=h-2*(0!==n||0!==t?n+t:Cbe(l.top,l.bottom))}await o({...a,availableWidth:A,availableHeight:S});const w=await i.getDimensions(r.floating);return m!==w.width||h!==w.height?{reset:{rects:!0}}:{}}}},xSe=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(a){const{rects:n}=a,{strategy:t="referenceHidden",...i}=jbe(e,a);switch(t){case"referenceHidden":{const e=Fbe(await Vbe(a,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Jbe(e)}}}case"escaped":{const e=Fbe(await Vbe(a,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Jbe(e)}}}default:return{}}}}},PSe=e=>({name:"arrow",options:e,async fn(a){const{x:n,y:t,placement:i,rects:r,platform:o,elements:s,middlewareData:l}=a,{element:u,padding:c=0}=jbe(e,a)||{};if(null==u)return{};const d=Obe(c),m={x:n,y:t},h=Dbe(i),p=Rbe(h),g=await o.getDimensions(u),v="y"===h,f=v?"top":"left",y=v?"bottom":"right",k=v?"clientHeight":"clientWidth",b=r.reference[p]+r.reference[h]-m[h]-r.floating[p],S=m[h]-r.reference[h],A=await(null==o.getOffsetParent?void 0:o.getOffsetParent(u));let w=A?A[k]:0;w&&await(null==o.isElement?void 0:o.isElement(A))||(w=s.floating[k]||r.floating[p]);const C=b/2-S/2,M=w/2-g[p]/2-1,T=wbe(d[f],M),N=wbe(d[y],M),E=T,x=w-g[p]-N,P=w/2-g[p]/2+C,j=Pbe(E,P,x),L=!l.arrow&&null!=Bbe(i)&&P!==j&&r.reference[p]/2-(P<E?T:N)-g[p]/2<0,B=L?P<E?P-E:P-x:0;return{[h]:m[h]+B,data:{[h]:j,centerOffset:P-j-B,...L&&{alignmentOffset:B}},reset:L}}}),jSe=(e,a,n)=>{const t={platform:wSe,...n},i={...t.platform,_c:new Map};return(async(e,a,n)=>{const{placement:t="bottom",strategy:i="absolute",middleware:r=[],platform:o}=n,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}=Gbe(u,t,l),m=t,h={},p=0;for(let g=0;g<s.length;g++){const{name:n,fn:r}=s[g],{x:v,y:f,data:y,reset:k}=await r({x:c,y:d,initialPlacement:t,placement:m,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:a}});c=null!=v?v:c,d=null!=f?f:d,h={...h,[n]:{...h[n],...y}},k&&p<=50&&(p++,"object"==typeof k&&(k.placement&&(m=k.placement),k.rects&&(u=!0===k.rects?await o.getElementRects({reference:e,floating:a,strategy:i}):k.rects),({x:c,y:d}=Gbe(u,m,l))),g=-1)}return{x:c,y:d,placement:m,strategy:i,middlewareData:h}})(e,a,{...t,platform:i})},LSe=Fa();function BSe(){const e=Ja(LSe);if(void 0===e)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var zSe=_n('<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">'),RSe={top:180,right:-90,bottom:0,left:90};function _Se(e){const a=BSe(),n=mke({size:30},e),[t,i]=fn(n,["ref","style","size"]),r=()=>a.currentPlacement().split("-")[0],o=function(e){const[a,n]=Pa();return Ba((()=>{const a=e();var t;a&&n((t=a,Fye(t).defaultView||window).getComputedStyle(a))})),a}(a.contentRef),s=()=>2*Number.parseInt(o()?.getPropertyValue(`border-${r()}-width`)||"0px")*(30/t.size);return dn(Ake,vn({as:"div",ref(e){const n=wye(a.setArrowRef,t.ref);"function"==typeof n&&n(e)},"aria-hidden":"true",get style(){return Kye({position:"absolute","font-size":`${t.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()},t.style)}},i,{get children(){const e=zSe(),a=e.firstChild;return La((()=>Kn(a,"transform",`rotate(${RSe[r()]} 15 15) translate(0 2)`))),e}}))}function DSe(e){const{x:a=0,y:n=0,width:t=0,height:i=0}=e??{};if("function"==typeof DOMRect)return new DOMRect(a,n,t,i);const r={x:a,y:n,width:t,height:i,top:n,right:a+t,bottom:n+i,left:a};return{...r,toJSON:()=>r}}function KSe(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var HSe={top:"bottom",right:"left",bottom:"top",left:"right"};var OSe=Object.assign((function(e){const a=mke({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),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(a.placement),l=()=>{return e=a.anchorRef?.(),n=a.getAnchorRect,{contextElement:e,getBoundingClientRect:()=>{const a=n(e);return a?DSe(a):e?e.getBoundingClientRect():DSe()}};var e,n},{direction:u}=Yke();async function c(){const e=l(),t=n(),r=i();if(!e||!t)return;const o=(r?.clientHeight||0)/2,c="number"==typeof a.gutter?a.gutter+o:a.gutter??o;t.style.setProperty("--kb-popper-content-overflow-padding",`${a.overflowPadding}px`),e.getBoundingClientRect();const d=[MSe((({placement:e})=>{const n=!!e.split("-")[1];return{mainAxis:c,crossAxis:n?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(KSe))throw new Error("`flip` expects a spaced-delimited list of placements");d.push(NSe({padding:a.overflowPadding,fallbackPlacements:e}))}(a.slide||a.overlap)&&d.push(TSe({mainAxis:a.slide,crossAxis:a.overlap,padding:a.overflowPadding})),d.push(ESe({padding:a.overflowPadding,apply({availableWidth:e,availableHeight:n,rects:i}){const r=Math.round(i.reference.width);e=Math.floor(e),n=Math.floor(n),t.style.setProperty("--kb-popper-anchor-width",`${r}px`),t.style.setProperty("--kb-popper-content-available-width",`${e}px`),t.style.setProperty("--kb-popper-content-available-height",`${n}px`),a.sameWidth&&(t.style.width=`${r}px`),a.fitViewport&&(t.style.maxWidth=`${e}px`,t.style.maxHeight=`${n}px`)}})),a.hideWhenDetached&&d.push(xSe({padding:a.detachedPadding})),r&&d.push(PSe({element:r,padding:a.arrowPadding}));const m=await jSe(e,t,{placement:a.placement,strategy:"absolute",middleware:d,platform:{...wSe,isRTL:()=>"rtl"===u()}});if(s(m.placement),a.onCurrentPlacementChange?.(m.placement),!t)return;t.style.setProperty("--kb-popper-content-transform-origin",function(e,a){const[n,t]=e.split("-"),i=HSe[n];return t?"left"===n||"right"===n?`${i} ${"start"===t?"top":"bottom"}`:"start"===t?`${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(t.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,n=m.placement.split("-")[0];Object.assign(r.style,{left:null!=e?`${e}px`:"",top:null!=a?`${a}px`:"",[n]:"100%"})}}return Ba((()=>{const e=l(),a=n();if(!e||!a)return;Ha(CSe(e,a,c,{elementResize:"function"==typeof ResizeObserver}))})),Ba((()=>{const e=n(),t=a.contentRef?.();e&&t&&queueMicrotask((()=>{e.style.zIndex=getComputedStyle(t).zIndex}))})),dn(LSe.Provider,{value:{currentPlacement:o,contentRef:()=>a.contentRef?.(),setPositionerRef:t,setArrowRef:r},get children(){return a.children}})}),{Arrow:_Se,Context:LSe,usePopperContext:BSe,Positioner:function(e){const a=BSe(),[n,t]=fn(e,["ref","style"]);return dn(Ake,vn({as:"div",ref(e){const t=wye(a.setPositionerRef,n.ref);"function"==typeof t&&t(e)},"data-popper-positioner":"",get style(){return Kye({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},t))}});var ISe="interactOutside.pointerDownOutside",GSe="interactOutside.focusOutside";var VSe=Fa();function FSe(e){let a;const n=Ja(VSe),[t,i]=fn(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]);!function(e,a){let n,t=dke;const i=()=>Fye(a()),r=a=>e.onPointerDownOutside?.(a),o=a=>e.onFocusOutside?.(a),s=a=>e.onInteractOutside?.(a),l=n=>{const t=n.target;return t instanceof HTMLElement&&!t.closest(`[${dbe}]`)&&!!Gye(i(),t)&&!Gye(a(),t)&&!e.shouldExcludeElement?.(t)},u=e=>{function n(){const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=Yye([r,s]);t.addEventListener(ISe,i,{once:!0});const o=new CustomEvent(ISe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:2===e.button||Qye(e)&&0===e.button}});t.dispatchEvent(o)}"touch"===e.pointerType?(i().removeEventListener("click",n),t=n,i().addEventListener("click",n,{once:!0})):n()},c=e=>{const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=Yye([o,s]);t.addEventListener(GSe,i,{once:!0});const r=new CustomEvent(GSe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:!1}});t.dispatchEvent(r)};Ba((()=>{Pfe(e.isDisabled)||(n=window.setTimeout((()=>{i().addEventListener("pointerdown",u,!0)}),0),i().addEventListener("focusin",c,!0),Ha((()=>{window.clearTimeout(n),i().removeEventListener("click",t),i().removeEventListener("pointerdown",u,!0),i().removeEventListener("focusin",c,!0)})))}))}({shouldExcludeElement:e=>!!a&&(t.excludedElements?.some((a=>Gye(a(),e)))||[...r].some((a=>Gye(a,e)))),onPointerDownOutside:e=>{a&&!ybe.isBelowPointerBlockingLayer(a)&&(t.bypassTopMostLayerCheck||ybe.isTopMostLayer(a))&&(t.onPointerDownOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.())},onFocusOutside:e=>{t.onFocusOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.()}},(()=>a)),function(e){const a=a=>{a.key===Uye.Escape&&e.onEscapeKeyDown?.(a)};Ba((()=>{if(Pfe(e.isDisabled))return;const n=e.ownerDocument?.()??Fye();n.addEventListener("keydown",a),Ha((()=>{n.removeEventListener("keydown",a)}))}))}({ownerDocument:()=>Fye(a),onEscapeKeyDown:e=>{a&&ybe.isTopMostLayer(a)&&(t.onEscapeKeyDown?.(e),!e.defaultPrevented&&t.onDismiss&&(e.preventDefault(),t.onDismiss()))}}),Ka((()=>{if(!a)return;ybe.addLayer({node:a,isPointerBlocking:t.disableOutsidePointerEvents,dismiss:t.onDismiss});const e=n?.registerNestedLayer(a);ybe.assignPointerEventToLayers(),ybe.disableBodyPointerEvents(a),Ha((()=>{a&&(ybe.removeLayer(a),e?.(),ybe.assignPointerEventToLayers(),ybe.restoreBodyPointerEvents(a))}))})),Ba(Da([()=>a,()=>t.disableOutsidePointerEvents],(([e,a])=>{if(!e)return;const n=ybe.find(e);n&&n.isPointerBlocking!==a&&(n.isPointerBlocking=a,ybe.assignPointerEventToLayers()),a&&ybe.disableBodyPointerEvents(e),Ha((()=>{ybe.restoreBodyPointerEvents(e)}))}),{defer:!0}));return dn(VSe.Provider,{value:{registerNestedLayer:e=>{r.add(e);const a=n?.registerNestedLayer(e);return()=>{r.delete(e),a?.()}}},get children(){return dn(Ake,vn({as:"div",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)}},i))}})}function JSe(e={}){const[a,n]=jke({value:()=>Pfe(e.open),defaultValue:()=>!!Pfe(e.defaultOpen),onChange:a=>e.onOpenChange?.(a)}),t=()=>{n(!0)},i=()=>{n(!1)};return{isOpen:a,setIsOpen:n,open:t,close:i,toggle:()=>{a()?i():t()}}}var USe={};Bke(USe,{Description:()=>Tke,ErrorMessage:()=>Nke,Item:()=>YSe,ItemControl:()=>QSe,ItemDescription:()=>XSe,ItemIndicator:()=>eAe,ItemInput:()=>aAe,ItemLabel:()=>nAe,Label:()=>tAe,RadioGroup:()=>rAe,Root:()=>iAe});var WSe=Fa();function qSe(){const e=Ja(WSe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var ZSe=Fa();function $Se(){const e=Ja(ZSe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function YSe(e){const a=Mke(),n=qSe(),t=mke({id:`${a.generateId("item")}-${bn()}`},e),[i,r]=fn(t,["value","disabled","onPointerDown"]),[o,s]=Pa(),[l,u]=Pa(),[c,d]=Pa(),[m,h]=Pa(),[p,g]=Pa(!1),v=za((()=>n.isSelectedValue(i.value))),f=za((()=>i.disabled||a.isDisabled()||!1)),y=e=>{$ye(e,i.onPointerDown),p()&&e.preventDefault()},k=za((()=>({...a.dataset(),"data-disabled":f()?"":void 0,"data-checked":v()?"":void 0}))),b={value:()=>i.value,dataset:k,isSelected:v,isDisabled:f,inputId:o,labelId:l,descriptionId:c,inputRef:m,select:()=>n.setSelectedValue(i.value),generateId:Iye((()=>r.id)),registerInput:kke(s),registerLabel:kke(u),registerDescription:kke(d),setIsFocused:g,setInputRef:h};return dn(ZSe.Provider,{value:b,get children(){return dn(Ake,vn({as:"div",role:"group",onPointerDown:y},k,r))}})}function QSe(e){const a=$Se(),n=mke({id:a.generateId("control")},e),[t,i]=fn(n,["onClick","onKeyDown"]);return dn(Ake,vn({as:"div",onClick:e=>{$ye(e,t.onClick),a.select(),a.inputRef()?.focus()},onKeyDown:e=>{$ye(e,t.onKeyDown),e.key===Uye.Space&&(a.select(),a.inputRef()?.focus())}},(()=>a.dataset()),i))}function XSe(e){const a=$Se(),n=mke({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),dn(Ake,vn({as:"div"},(()=>a.dataset()),n))}function eAe(e){const a=$Se(),n=mke({id:a.generateId("indicator")},e),[t,i]=fn(n,["ref","forceMount"]),[r,o]=Pa(),{present:s}=cbe({show:()=>t.forceMount||a.isSelected(),element:()=>r()??null});return dn(Cn,{get when(){return s()},get children(){return dn(Ake,vn({as:"div",ref(e){const a=wye(o,t.ref);"function"==typeof a&&a(e)}},(()=>a.dataset()),i))}})}function aAe(e){const a=Mke(),n=qSe(),t=$Se(),i=mke({id:t.generateId("input")},e),[r,o]=fn(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),[s,l]=Pa(!1);return Ba(Da([()=>t.isSelected(),()=>t.value()],(e=>{if(!e[0]&&e[1]===t.value())return;l(!0);const a=t.inputRef();a?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))}),{defer:!0})),Ba((()=>Ha(t.registerInput(o.id)))),dn(Ake,vn({as:"input",ref(e){const a=wye(t.setInputRef,r.ref);"function"==typeof a&&a(e)},type:"radio",get name(){return a.name()},get value(){return t.value()},get checked(){return t.isSelected()},get required(){return a.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return a.isReadOnly()},get style(){return Kye({...yke},r.style)},get"aria-labelledby"(){return[r["aria-labelledby"],t.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"],t.descriptionId(),n.ariaDescribedBy()].filter(Boolean).join(" ")||void 0},onChange:e=>{if($ye(e,r.onChange),e.stopPropagation(),!s()){n.setSelectedValue(t.value());e.target.checked=t.isSelected()}l(!1)},onFocus:e=>{$ye(e,r.onFocus),t.setIsFocused(!0)},onBlur:e=>{$ye(e,r.onBlur),t.setIsFocused(!1)}},(()=>t.dataset()),o))}function nAe(e){const a=$Se(),n=mke({id:a.generateId("label")},e);return Ba((()=>Ha(a.registerLabel(n.id)))),dn(Ake,vn({as:"label",get for(){return a.inputId()}},(()=>a.dataset()),n))}function tAe(e){return dn(Eke,vn({as:"span"},e))}function iAe(e){let a;const n=mke({id:`radiogroup-${bn()}`,orientation:"vertical"},e),[t,i,r]=fn(n,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],wke),[o,s]=Pke({value:()=>t.value,defaultValue:()=>t.defaultValue,onChange:e=>t.onChange?.(e)}),{formControlContext:l}=function(e){const a=mke({id:`form-control-${bn()}`},e),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(),[l,u]=Pa();return{formControlContext:{name:()=>Pfe(a.name)??Pfe(a.id),dataset:za((()=>({"data-valid":"valid"===Pfe(a.validationState)?"":void 0,"data-invalid":"invalid"===Pfe(a.validationState)?"":void 0,"data-required":Pfe(a.required)?"":void 0,"data-disabled":Pfe(a.disabled)?"":void 0,"data-readonly":Pfe(a.readOnly)?"":void 0}))),validationState:()=>Pfe(a.validationState),isRequired:()=>Pfe(a.required),isDisabled:()=>Pfe(a.disabled),isReadOnly:()=>Pfe(a.readOnly),labelId:n,fieldId:i,descriptionId:o,errorMessageId:l,getAriaLabelledBy:(e,a,t)=>{const i=null!=t||null!=n();return[t,n(),i&&null!=a?e:void 0].filter(Boolean).join(" ")||void 0},getAriaDescribedBy:e=>[o(),l(),e].filter(Boolean).join(" ")||void 0,generateId:Iye((()=>Pfe(a.id))),registerLabel:kke(t),registerField:kke(r),registerDescription:kke(s),registerErrorMessage:kke(u)}}}(i);xke((()=>a),(()=>s(t.defaultValue??"")));const u=()=>l.getAriaDescribedBy(t["aria-describedby"]),c=e=>e===o(),d={ariaDescribedBy:u,isSelectedValue:c,setSelectedValue:e=>{if(!l.isReadOnly()&&!l.isDisabled()&&(s(e),a))for(const n of a.querySelectorAll("[type='radio']")){n.checked=c(n.value)}}};return dn(Cke.Provider,{value:l,get children(){return dn(WSe.Provider,{value:d,get children(){return dn(Ake,vn({as:"div",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)},role:"radiogroup",get id(){return Pfe(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 t.orientation},get"aria-labelledby"(){return l.getAriaLabelledBy(Pfe(i.id),r["aria-label"],t["aria-labelledby"])},get"aria-describedby"(){return u()}},(()=>l.dataset()),r))}})}})}var rAe=Object.assign(iAe,{Description:Tke,ErrorMessage:Nke,Item:YSe,ItemControl:QSe,ItemDescription:XSe,ItemIndicator:eAe,ItemInput:aAe,ItemLabel:nAe,Label:tAe}),oAe=class{collection;ref;collator;constructor(e,a,n){this.collection=e,this.ref=a,this.collator=n}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 n=this.getItem(e);if(!a||!n)return;const t=Math.max(0,n.offsetTop+n.offsetHeight-a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop>t;)i=this.getKeyAbove(i),n=null!=i?this.getItem(i):null;return i}getKeyPageBelow(e){const a=this.ref?.();let n=this.getItem(e);if(!a||!n)return;const t=Math.min(a.scrollHeight,n.offsetTop-n.offsetHeight+a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop<t;)i=this.getKeyBelow(i),n=null!=i?this.getItem(i):null;return i}getKeyForSearch(e,a){const n=this.collator?.();if(!n)return;let t=null!=a?this.getKeyBelow(a):this.getFirstKey();for(;null!=t;){const a=this.collection().getItem(t);if(a){const i=a.textValue.slice(0,e.length);if(a.textValue&&0===n.compare(i,e))return t}t=this.getKeyBelow(t)}}};function sAe(e,a,n){const t=function(e){const{locale:a}=Yke(),n=za((()=>a()+(e?Object.entries(e).sort(((e,a)=>e[0]<a[0]?-1:1)).join():"")));return za((()=>{const t=n();let i;return Qke.has(t)&&(i=Qke.get(t)),i||(i=new Intl.Collator(a(),e),Qke.set(t,i)),i}))}({usage:"search",sensitivity:"base"});return ibe({selectionManager:()=>Pfe(e.selectionManager),keyboardDelegate:za((()=>{const n=Pfe(e.keyboardDelegate);return n||new oAe(e.collection,a,t)})),autoFocus:()=>Pfe(e.autoFocus),deferAutoFocus:()=>Pfe(e.deferAutoFocus),shouldFocusWrap:()=>Pfe(e.shouldFocusWrap),disallowEmptySelection:()=>Pfe(e.disallowEmptySelection),selectOnFocus:()=>Pfe(e.selectOnFocus),disallowTypeAhead:()=>Pfe(e.disallowTypeAhead),shouldUseVirtualFocus:()=>Pfe(e.shouldUseVirtualFocus),allowsTabNavigation:()=>Pfe(e.allowsTabNavigation),isVirtualized:()=>Pfe(e.isVirtualized),scrollToKey:a=>Pfe(e.scrollToKey)?.(a),orientation:()=>Pfe(e.orientation)},a)}var lAe="focusScope.autoFocusOnMount",uAe="focusScope.autoFocusOnUnmount",cAe={bubbles:!1,cancelable:!0},dAe={stack:[],active(){return this.stack[0]},add(e){e!==this.active()&&this.active()?.pause(),this.stack=Hye(this.stack,e),this.stack.unshift(e)},remove(e){this.stack=Hye(this.stack,e),this.active()?.resume()}};function mAe(e,a){const[n,t]=Pa(!1),i={pause(){t(!0)},resume(){t(!1)}};let r=null;const o=a=>e.onMountAutoFocus?.(a),s=a=>e.onUnmountAutoFocus?.(a),l=()=>Fye(a()),u=()=>{const e=l().createElement("span");return e.setAttribute("data-focus-trap",""),e.tabIndex=0,Object.assign(e.style,yke),e},c=()=>{const e=a();return e?rke(e,!0).filter((e=>!e.hasAttribute("data-focus-trap"))):[]},d=()=>{const e=c();return e.length>0?e[0]:null};Ba((()=>{const e=a();if(!e)return;dAe.add(i);const n=Vye(e);if(!Gye(e,n)){const a=new CustomEvent(lAe,cAe);e.addEventListener(lAe,o),e.dispatchEvent(a),a.defaultPrevented||setTimeout((()=>{Xye(d()),Vye(e)===n&&Xye(e)}),0)}Ha((()=>{e.removeEventListener(lAe,o),setTimeout((()=>{const t=new CustomEvent(uAe,cAe);(()=>{const e=a();if(!e)return!1;const n=Vye(e);return!!n&&!Gye(e,n)&&ske(n)})()&&t.preventDefault(),e.addEventListener(uAe,s),e.dispatchEvent(t),t.defaultPrevented||Xye(n??l().body),e.removeEventListener(uAe,s),dAe.remove(i)}),0)}))})),Ba((()=>{const t=a();if(!t||!Pfe(e.trapFocus)||n())return;const i=e=>{const a=e.target;a?.closest(`[${dbe}]`)||(Gye(t,a)?r=a:Xye(r))},o=e=>{const a=e.relatedTarget??Vye(t);a?.closest(`[${dbe}]`)||Gye(t,a)||Xye(r)};l().addEventListener("focusin",i),l().addEventListener("focusout",o),Ha((()=>{l().removeEventListener("focusin",i),l().removeEventListener("focusout",o)}))})),Ba((()=>{const t=a();if(!t||!Pfe(e.trapFocus)||n())return;const i=u();t.insertAdjacentElement("afterbegin",i);const r=u();function o(e){const a=d(),n=(()=>{const e=c();return e.length>0?e[e.length-1]:null})();Xye(e.relatedTarget===a?n:a)}t.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(),t.insertAdjacentElement("beforeend",r)),a.nextSibling===i&&(i.remove(),t.insertAdjacentElement("afterbegin",i))}));s.observe(t,{childList:!0,subtree:!1}),Ha((()=>{i.removeEventListener("focusin",o),r.removeEventListener("focusin",o),i.remove(),r.remove(),s.disconnect()}))}))}var hAe="data-live-announcer";function pAe(e){Ba((()=>{Pfe(e.isDisabled)||Ha(function(e,a=document.body){const n=new Set(e),t=new Set,i=e=>{for(const t of e.querySelectorAll(`[${hAe}], [${dbe}]`))n.add(t);const a=e=>{if(n.has(e)||e.parentElement&&t.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(const a of n)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=gAe.get(e)??0;"true"===e.getAttribute("aria-hidden")&&0===a||(0===a&&e.setAttribute("aria-hidden","true"),t.add(e),gAe.set(e,a+1))};vAe.length&&vAe[vAe.length-1].disconnect();i(a);const o=new MutationObserver((e=>{for(const a of e)if("childList"===a.type&&0!==a.addedNodes.length&&![...n,...t].some((e=>e.contains(a.target)))){for(const e of a.removedNodes)e instanceof Element&&(n.delete(e),t.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):n.add(e)}}));o.observe(a,{childList:!0,subtree:!0});const s={observe(){o.observe(a,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return vAe.push(s),()=>{o.disconnect();for(const e of t){const a=gAe.get(e);if(null==a)return;1===a?(e.removeAttribute("aria-hidden"),gAe.delete(e)):gAe.set(e,a-1)}s===vAe[vAe.length-1]?(vAe.pop(),vAe.length&&vAe[vAe.length-1].observe()):vAe.splice(vAe.indexOf(s),1)}}(Pfe(e.targets),Pfe(e.root)))}))}var gAe=new WeakMap,vAe=[];var fAe=new Map,yAe=e=>{Ba((()=>{const a=ube(e.style)??{},n=ube(e.properties)??[],t={};for(const r in a)t[r]=e.element.style[r];const i=fAe.get(e.key);i?i.activeCount++:fAe.set(e.key,{activeCount:1,originalStyles:t,properties:n.map((e=>e.key))}),Object.assign(e.element.style,e.style);for(const r of n)e.element.style.setProperty(r.key,r.value);Ha((()=>{const a=fAe.get(e.key);if(a)if(1===a.activeCount){fAe.delete(e.key);for(const[n,t]of Object.entries(a.originalStyles))e.element.style[n]=t;for(const n of a.properties)e.element.style.removeProperty(n);0===e.element.style.length&&e.element.removeAttribute("style"),e.cleanup?.()}else a.activeCount--}))}))},kAe=(e,a)=>{switch(a){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},bAe=(e,a)=>{const n=getComputedStyle(e),t="x"===a?n.overflowX:n.overflowY;return"auto"===t||"scroll"===t||"HTML"===e.tagName&&"visible"===t},[SAe,AAe]=Pa([]),wAe=e=>[e.deltaX,e.deltaY],CAe=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],MAe=(e,a,n,t)=>{const i=null!==t&&TAe(t,e),[r,o]=((e,a,n)=>{const t="x"===a&&"rtl"===window.getComputedStyle(e).direction?-1:1;let i=e,r=0,o=0,s=!1;do{const[e,l,u]=kAe(i,a),c=u-e-t*l;0===l&&0===c||!bAe(i,a)||(r+=c,o+=l),i===(n??document.documentElement)?s=!0:i=i._$host??i.parentElement}while(i&&!s);return[r,o]})(e,a,i?t:void 0);return!(n>0&&Math.abs(r)<=1)&&!(n<0&&Math.abs(o)<1)},TAe=(e,a)=>{if(e.contains(a))return!0;let n=a;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},NAe=e=>{const a=vn({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=bn();let t=[0,0],i=null,r=null;Ba((()=>{ube(a.enabled)&&(AAe((e=>[...e,n])),Ha((()=>{AAe((e=>e.filter((e=>e!==n))))})))})),Ba((()=>{if(!ube(a.enabled)||!ube(a.hideScrollbar))return;const{body:e}=document,n=window.innerWidth-e.offsetWidth;if(ube(a.preventScrollbarShift)){const t={overflow:"hidden"},i=[];n>0&&("padding"===ube(a.preventScrollbarShiftMode)?t.paddingRight=`calc(${window.getComputedStyle(e).paddingRight} + ${n}px)`:t.marginRight=`calc(${window.getComputedStyle(e).marginRight} + ${n}px)`,i.push({key:"--scrollbar-width",value:`${n}px`}));const r=window.scrollY,o=window.scrollX;yAe({key:"prevent-scroll",element:e,style:t,properties:i,cleanup:()=>{ube(a.restoreScrollPosition)&&n>0&&window.scrollTo(o,r)}})}else yAe({key:"prevent-scroll",element:e,style:{overflow:"hidden"}})})),Ba((()=>{var e;(e=n,SAe().indexOf(e)===SAe().length-1&&ube(a.enabled))&&(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Ha((()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)})))}));const o=e=>{t=CAe(e),i=null,r=null},s=e=>{const n=e.target,t=ube(a.element),i=wAe(e),r=Math.abs(i[0])>Math.abs(i[1])?"x":"y",o=MAe(n,r,"x"===r?i[0]:i[1],t);let s;s=!t||!TAe(t,n)||!o,s&&e.cancelable&&e.preventDefault()},l=e=>{const n=ube(a.element),o=e.target;let s;if(2===e.touches.length)s=!ube(a.allowPinchZoom);else{if(null==i||null===r){const a=CAe(e).map(((e,a)=>t[a]-e)),n=Math.abs(a[0])>Math.abs(a[1])?"x":"y";i=n,r="x"===n?a[0]:a[1]}if("range"===o.type)s=!1;else{const e=MAe(o,i,r,n);s=!n||!TAe(n,o)||!e}}s&&e.cancelable&&e.preventDefault()}},EAe=NAe,xAe=Fa();function PAe(){return Ja(xAe)}function jAe(){const e=PAe();if(void 0===e)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var LAe=Fa();function BAe(){const e=Ja(LAe);if(void 0===e)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var zAe=Fa();function RAe(){const e=Ja(zAe);if(void 0===e)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function _Ae(e){let a;const n=RAe(),t=jAe(),i=mke({id:n.generateId(`item-${bn()}`)},e),[r,o]=fn(i,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[s,l]=Pa(),[u,c]=Pa(),[d,m]=Pa(),h=()=>t.listState().selectionManager(),p=()=>o.id,g=()=>{r.onSelect?.(),r.closeOnSelect&&setTimeout((()=>{t.close(!0)}))};Oke({getItem:()=>({ref:()=>a,type:"item",key:p(),textValue:r.textValue??d()?.textContent??a?.textContent??"",disabled:r.disabled??!1})});const v=rbe({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),f=e=>{$ye(e,r.onPointerMove),"mouse"===e.pointerType&&(r.disabled?t.onItemLeave(e):(t.onItemEnter(e),e.defaultPrevented||(Xye(e.currentTarget),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(p()))))},y=e=>{$ye(e,r.onPointerLeave),"mouse"===e.pointerType&&t.onItemLeave(e)},k=e=>{$ye(e,r.onPointerUp),r.disabled||0!==e.button||g()},b=e=>{if($ye(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)),A=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}))),w={isChecked:()=>r.checked,dataset:A,setLabelRef:m,generateId:Iye((()=>o.id)),registerLabel:kke(l),registerDescription:kke(c)};return dn(LAe.Provider,{value:w,get children(){return dn(Ake,vn({as:"div",ref(e){const n=wye((e=>a=e),r.ref);"function"==typeof n&&n(e)},get tabIndex(){return v.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 v.dataKey()},get onPointerDown(){return Yye([r.onPointerDown,v.onPointerDown])},get onPointerUp(){return Yye([k,v.onPointerUp])},get onClick(){return Yye([r.onClick,v.onClick])},get onKeyDown(){return Yye([b,v.onKeyDown])},get onMouseDown(){return Yye([r.onMouseDown,v.onMouseDown])},get onFocus(){return Yye([r.onFocus,v.onFocus])},onPointerMove:f,onPointerLeave:y},A,o))}})}function DAe(e){const a=mke({closeOnSelect:!1},e),[n,t]=fn(a,["checked","defaultChecked","onChange","onSelect"]),i=function(e={}){const[a,n]=jke({value:()=>Pfe(e.isSelected),defaultValue:()=>!!Pfe(e.defaultIsSelected),onChange:a=>e.onSelectedChange?.(a)});return{isSelected:a,setIsSelected:a=>{Pfe(e.isReadOnly)||Pfe(e.isDisabled)||n(a)},toggle:()=>{Pfe(e.isReadOnly)||Pfe(e.isDisabled)||n(!a())}}}({isSelected:()=>n.checked,defaultIsSelected:()=>n.defaultChecked,onSelectedChange:e=>n.onChange?.(e),isDisabled:()=>t.disabled});return dn(_Ae,vn({role:"menuitemcheckbox",get checked(){return i.isSelected()},onSelect:()=>{n.onSelect?.(),i.toggle()}},t))}var KAe=Fa();function HAe(){return Ja(KAe)}var OAe={next:(e,a)=>"ltr"===e?"horizontal"===a?"ArrowRight":"ArrowDown":"horizontal"===a?"ArrowLeft":"ArrowUp",previous:(e,a)=>OAe.next("ltr"===e?"rtl":"ltr",a)},IAe=e=>"horizontal"===e?"ArrowDown":"ArrowRight",GAe=e=>"horizontal"===e?"ArrowUp":"ArrowLeft";function VAe(e){const a=RAe(),n=jAe(),t=HAe(),{direction:i}=Yke(),r=mke({id:a.generateId("trigger")},e),[o,s]=fn(r,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>a.value();void 0!==t&&(l=()=>a.value()??o.id,void 0===t.lastValue()&&t.setLastValue(l));const u=bke((()=>n.triggerRef()),(()=>"button")),c=za((()=>"a"===u()&&null!=n.triggerRef()?.getAttribute("href")));Ba(Da((()=>t?.value()),(e=>{c()&&e===l()&&n.triggerRef()?.focus()})));const d=()=>{void 0!==t?n.isOpen()?t.value()===l()&&t.closeMenu():(t.autoFocusMenu()||t.setAutoFocusMenu(!0),n.open(!1)):n.toggle(!0)};return Ba((()=>Ha(n.registerTriggerId(o.id)))),dn(bbe,vn({ref(e){const a=wye(n.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 n.isOpen()},get"aria-controls"(){return za((()=>!!n.isOpen()))()?n.contentId():void 0},get"data-highlighted"(){return void 0!==l()&&t?.value()===l()||void 0},get tabIndex(){return void 0!==t?t.value()===l()||t.lastValue()===l()?0:-1:void 0},onPointerDown:e=>{$ye(e,o.onPointerDown),e.currentTarget.dataset.pointerType=e.pointerType,o.disabled||"touch"===e.pointerType||0!==e.button||d()},onMouseOver:e=>{$ye(e,o.onMouseOver),"touch"!==n.triggerRef()?.dataset.pointerType&&(o.disabled||void 0===t||void 0===t.value()||t.setValue(l))},onClick:e=>{$ye(e,o.onClick),o.disabled||"touch"===e.currentTarget.dataset.pointerType&&d()},onKeyDown:e=>{if($ye(e,o.onKeyDown),!o.disabled){if(c())switch(e.key){case"Enter":case" ":return}switch(e.key){case"Enter":case" ":case IAe(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 n=uke(e);for(;e&&n&&e!==a&&n!==a;)vke(n,e),n=uke(e=n)}else{const{left:a,top:n}=e.getBoundingClientRect();e?.scrollIntoView?.({block:"nearest"});const{left:t,top:i}=e.getBoundingClientRect();(Math.abs(a-t)>1||Math.abs(n-i)>1)&&e.scrollIntoView?.({block:"nearest"})}}}(e.currentTarget),n.open("first"),t?.setAutoFocusMenu(!0),t?.setValue(l);break;case GAe(a.orientation()):e.stopPropagation(),e.preventDefault(),n.open("last");break;case OAe.next(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.nextMenu();break;case OAe.previous(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.previousMenu()}}},onFocus:e=>{$ye(e,o.onFocus),void 0!==t&&"touch"!==e.currentTarget.dataset.pointerType&&t.setValue(l)},role:void 0!==t?"menuitem":void 0},(()=>n.dataset()),s))}var FAe=Fa();function JAe(){return Ja(FAe)}function UAe(e){let a;const n=RAe(),t=jAe(),i=HAe(),r=JAe(),{direction:o}=Yke(),s=mke({id:n.generateId(`content-${bn()}`)},e),[l,u]=fn(s,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let c=0;const d=()=>null==t.parentMenuContext()&&void 0===i&&n.isModal(),m=sAe({selectionManager:t.listState().selectionManager,collection:t.listState().collection,autoFocus:t.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!t.listState().selectionManager().isFocused(),orientation:()=>"horizontal"===n.orientation()?"vertical":"horizontal"},(()=>a));mAe({trapFocus:()=>d()&&t.isOpen(),onMountAutoFocus:e=>{void 0===i&&l.onOpenAutoFocus?.(e)},onUnmountAutoFocus:l.onCloseAutoFocus},(()=>a));const h=e=>{l.onEscapeKeyDown?.(e),i?.setAutoFocusMenu(!1),t.close(!0)},p=e=>{l.onFocusOutside?.(e),n.isModal()&&e.preventDefault()};Ba((()=>Ha(t.registerContentId(l.id))));const g={ref:wye((e=>{t.setContentRef(e),a=e}),l.ref),role:"menu",get id(){return l.id},get tabIndex(){return m.tabIndex()},get"aria-labelledby"(){return t.triggerId()},onKeyDown:Yye([l.onKeyDown,m.onKeyDown,e=>{if(Gye(e.currentTarget,e.target)&&("Tab"===e.key&&t.isOpen()&&e.preventDefault(),void 0!==i&&"true"!==e.currentTarget.getAttribute("aria-haspopup")))switch(e.key){case OAe.next(o(),n.orientation()):e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.nextMenu();break;case OAe.previous(o(),n.orientation()):if(e.currentTarget.hasAttribute("data-closed"))break;e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.previousMenu()}}]),onMouseDown:Yye([l.onMouseDown,m.onMouseDown]),onFocusIn:Yye([l.onFocusIn,m.onFocusIn]),onFocusOut:Yye([l.onFocusOut,m.onFocusOut]),onPointerEnter:e=>{$ye(e,l.onPointerEnter),t.isOpen()&&(t.parentMenuContext()?.listState().selectionManager().setFocused(!1),t.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},onPointerMove:e=>{if($ye(e,l.onPointerMove),"mouse"!==e.pointerType)return;const a=c!==e.clientX;Gye(e.currentTarget,e.target)&&a&&(t.setPointerDir(e.clientX>c?"right":"left"),c=e.clientX)},get"data-orientation"(){return n.orientation()}};return dn(Cn,{get when(){return t.contentPresent()},get children(){return dn(Cn,{get when(){return void 0===r||null!=t.parentMenuContext()},get fallback(){return dn(Ake,vn({as:"div"},(()=>t.dataset()),g,u))},get children(){return dn(OSe.Positioner,{get children(){return dn(FSe,vn({get disableOutsidePointerEvents(){return za((()=>!!d()))()&&t.isOpen()},get excludedElements(){return[t.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return Kye({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:h,onFocusOutside:p,get onDismiss(){return t.close}},(()=>t.dataset()),g,u))}})}})}})}function WAe(e){let a;const n=RAe(),t=jAe(),[i,r]=fn(e,["ref"]);return EAe({element:()=>a??null,enabled:()=>t.contentPresent()&&n.preventScroll()}),dn(UAe,vn({ref(e){const n=wye((e=>{a=e}),i.ref);"function"==typeof n&&n(e)}},r))}var qAe=Fa();function ZAe(e){const a=mke({id:RAe().generateId(`group-${bn()}`)},e),[n,t]=Pa(),i={generateId:Iye((()=>a.id)),registerLabelId:kke(t)};return dn(qAe.Provider,{value:i,get children(){return dn(Ake,vn({as:"div",role:"group",get"aria-labelledby"(){return n()}},a))}})}function $Ae(e){const a=function(){const e=Ja(qAe);if(void 0===e)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}(),n=mke({id:a.generateId("label")},e),[t,i]=fn(n,["id"]);return Ba((()=>Ha(a.registerLabelId(t.id)))),dn(Ake,vn({as:"span",get id(){return t.id},"aria-hidden":"true"},i))}function YAe(e){const a=jAe();return dn(Ake,vn({as:"span","aria-hidden":"true"},(()=>a.dataset()),mke({children:"▼"},e)))}function QAe(e){return dn(_Ae,vn({role:"menuitem",closeOnSelect:!0},e))}function XAe(e){const a=BAe(),n=mke({id:a.generateId("description")},e),[t,i]=fn(n,["id"]);return Ba((()=>Ha(a.registerDescription(t.id)))),dn(Ake,vn({as:"div",get id(){return t.id}},(()=>a.dataset()),i))}function ewe(e){const a=BAe(),n=mke({id:a.generateId("indicator")},e),[t,i]=fn(n,["forceMount"]);return dn(Cn,{get when(){return t.forceMount||a.isChecked()},get children(){return dn(Ake,vn({as:"div"},(()=>a.dataset()),i))}})}function awe(e){const a=BAe(),n=mke({id:a.generateId("label")},e),[t,i]=fn(n,["ref","id"]);return Ba((()=>Ha(a.registerLabel(t.id)))),dn(Ake,vn({as:"div",ref(e){const n=wye(a.setLabelRef,t.ref);"function"==typeof n&&n(e)},get id(){return t.id}},(()=>a.dataset()),i))}function nwe(e){const a=jAe();return dn(Cn,{get when(){return a.contentPresent()},get children(){return dn(et,e)}})}var twe=Fa();function iwe(e){const a=mke({id:RAe().generateId(`radiogroup-${bn()}`)},e),[n,t]=fn(a,["value","defaultValue","onChange","disabled"]),[i,r]=Pke({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:e=>n.onChange?.(e)});return dn(twe.Provider,{value:{isDisabled:()=>n.disabled,isSelectedValue:e=>e===i(),setSelectedValue:r},get children(){return dn(ZAe,t)}})}function rwe(e){const a=function(){const e=Ja(twe);if(void 0===e)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}(),n=mke({closeOnSelect:!1},e),[t,i]=fn(n,["value","onSelect"]);return dn(_Ae,vn({role:"menuitemradio",get checked(){return a.isSelectedValue(t.value)},onSelect:()=>{t.onSelect?.(),a.setSelectedValue(t.value)}},i))}function owe(e,a,n){const t=e.split("-")[0],i=n.getBoundingClientRect(),r=[],o=a.clientX,s=a.clientY;switch(t){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 swe(e){const a=RAe(),n=Rke(),t=PAe(),i=HAe(),r=JAe(),o=mke({placement:"horizontal"===a.orientation()?"bottom-start":"right-start"},e),[s,l]=fn(o,["open","defaultOpen","onOpenChange"]);let u=0,c=null,d="right";const[m,h]=Pa(),[p,g]=Pa(),[v,f]=Pa(),[y,k]=Pa(),[b,S]=Pa(!0),[A,w]=Pa(l.placement),[C,M]=Pa([]),[T,N]=Pa([]),{DomCollectionProvider:E}=Hke({items:T,onItemsChange:N}),x=JSe({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:e=>s.onOpenChange?.(e)}),{present:P}=cbe({show:()=>a.forceMount()||x.isOpen(),element:()=>y()??null}),j=function(e){const a=tbe(e),n=Gke({dataSource:()=>Pfe(e.dataSource),getKey:()=>Pfe(e.getKey),getTextValue:()=>Pfe(e.getTextValue),getDisabled:()=>Pfe(e.getDisabled),getSectionChildren:()=>Pfe(e.getSectionChildren),factory:a=>new sbe(e.filter?e.filter(a):a)},[()=>e.filter]),t=new obe(n,a);return ja((()=>{const e=a.focusedKey();null==e||n().getItem(e)||a.setFocusedKey(void 0)})),{collection:n,selectionManager:()=>t}}({selectionMode:"none",dataSource:T}),L=e=>{S(e),x.open()},B=(e=!1)=>{x.close(),e&&t&&t.close(!0)},z=()=>{const e=y();e&&(Xye(e),j.selectionManager().setFocused(!0),j.selectionManager().setFocusedKey(void 0))},R=()=>{null!=r?setTimeout((()=>z())):z()},_=e=>{return d===c?.side&&(a=e,n=c?.area,!!n&&function(e,a){const[n,t]=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)*(n-e)-(e-u)*(t-l);if(c<l){if(t>=c&&t<l){if(0===m)return!0;m>0&&(t===c?t>d&&(i=!i):i=!i)}}else if(l<c){if(t>l&&t<=c){if(0===m)return!0;m<0&&(t===c?t<d&&(i=!i):i=!i)}}else if(t==l&&(n>=u&&n<=e||n>=e&&n<=u))return!0}return i}([a.clientX,a.clientY],n));var a,n};pAe({isDisabled:()=>!(null==t&&x.isOpen()&&a.isModal()),targets:()=>[y(),...C()].filter(Boolean)}),Ba((()=>{const e=y();if(!e||!t)return;const a=t.registerNestedMenu(e);Ha((()=>{a()}))})),Ba((()=>{void 0===t&&i?.registerMenu(a.value(),[y(),...C()])})),Ba((()=>{void 0===t&&void 0!==i&&(i.value()===a.value()?(v()?.focus(),i.autoFocusMenu()&&L(!0)):B())})),Ba((()=>{void 0===t&&void 0!==i&&x.isOpen()&&i.setValue(a.value())})),Ha((()=>{void 0===t&&i?.unregisterMenu(a.value())}));const D={dataset:za((()=>({"data-expanded":x.isOpen()?"":void 0,"data-closed":x.isOpen()?void 0:""}))),isOpen:x.isOpen,contentPresent:P,nestedMenus:C,currentPlacement:A,pointerGraceTimeoutId:()=>u,autoFocus:b,listState:()=>j,parentMenuContext:()=>t,triggerRef:v,contentRef:y,triggerId:m,contentId:p,setTriggerRef:f,setContentRef:k,open:L,close:B,toggle:e=>{S(e),x.toggle()},focusContent:R,onItemEnter:e=>{_(e)&&e.preventDefault()},onItemLeave:e=>{_(e)||R()},onTriggerLeave:e=>{_(e)&&e.preventDefault()},setPointerDir:e=>d=e,setPointerGraceTimeoutId:e=>u=e,setPointerGraceIntent:e=>c=e,registerNestedMenu:e=>{M((a=>[...a,e]));const a=t?.registerNestedMenu(e);return()=>{M((a=>Hye(a,e))),a?.()}},registerItemToParentDomCollection:n?.registerItem,registerTriggerId:kke(h),registerContentId:kke(g)};return dn(E,{get children(){return dn(xAe.Provider,{value:D,get children(){return dn(Cn,{when:void 0===r,get fallback(){return l.children},get children(){return dn(OSe,vn({anchorRef:v,contentRef:y,onCurrentPlacementChange:w},l))}})}})}})}function lwe(e){const{direction:a}=Yke();return dn(swe,vn({get placement(){return"rtl"===a()?"left-start":"right-start"},flip:!0},e))}var uwe=(e,a)=>"ltr"===e?["horizontal"===a?"ArrowLeft":"ArrowUp"]:["horizontal"===a?"ArrowRight":"ArrowDown"];function cwe(e){const a=jAe(),n=RAe(),[t,i]=fn(e,["onFocusOutside","onKeyDown"]),{direction:r}=Yke();return dn(UAe,vn({onOpenAutoFocus:e=>{e.preventDefault()},onCloseAutoFocus:e=>{e.preventDefault()},onFocusOutside:e=>{t.onFocusOutside?.(e);const n=e.target;Gye(a.triggerRef(),n)||a.close()},onKeyDown:e=>{$ye(e,t.onKeyDown);const i=Gye(e.currentTarget,e.target),o=uwe(r(),n.orientation()).includes(e.key),s=null!=a.parentMenuContext();i&&o&&s&&(a.close(),Xye(a.triggerRef()))}},i))}var dwe=["Enter"," "],mwe=(e,a)=>"ltr"===e?[...dwe,"horizontal"===a?"ArrowRight":"ArrowDown"]:[...dwe,"horizontal"===a?"ArrowLeft":"ArrowUp"];function hwe(e){let a;const n=RAe(),t=jAe(),i=mke({id:n.generateId(`sub-trigger-${bn()}`)},e),[r,o]=fn(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}=Yke(),c=()=>r.id,d=()=>{const e=t.parentMenuContext();if(null==e)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return e.listState().selectionManager()},m=rbe({key:c,selectionManager:d,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),h=e=>{$ye(e,r.onClick),t.isOpen()||r.disabled||t.open(!0)},p=e=>{$ye(e,r.onKeyDown),e.repeat||r.disabled||mwe(u(),n.orientation()).includes(e.key)&&(e.stopPropagation(),e.preventDefault(),d().setFocused(!1),d().setFocusedKey(void 0),t.isOpen()||t.open("first"),t.focusContent(),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(t.listState().collection().getFirstKey()))};return Ba((()=>{if(null==t.registerItemToParentDomCollection)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");Ha(t.registerItemToParentDomCollection({ref:()=>a,type:"item",key:c(),textValue:r.textValue??a?.textContent??"",disabled:r.disabled??!1}))})),Ba(Da((()=>t.parentMenuContext()?.pointerGraceTimeoutId()),(e=>{Ha((()=>{window.clearTimeout(e),t.parentMenuContext()?.setPointerGraceIntent(null)}))}))),Ba((()=>Ha(t.registerTriggerId(r.id)))),Ha((()=>{l()})),dn(Ake,vn({as:"div",ref(e){const n=wye((e=>{t.setTriggerRef(e),a=e}),r.ref);"function"==typeof n&&n(e)},get id(){return r.id},role:"menuitem",get tabIndex(){return m.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return za((()=>!!t.isOpen()))()?t.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 Yye([r.onPointerDown,m.onPointerDown])},get onPointerUp(){return Yye([r.onPointerUp,m.onPointerUp])},get onClick(){return Yye([h,m.onClick])},get onKeyDown(){return Yye([p,m.onKeyDown])},get onMouseDown(){return Yye([r.onMouseDown,m.onMouseDown])},get onFocus(){return Yye([r.onFocus,m.onFocus])},onPointerMove:e=>{if($ye(e,r.onPointerMove),"mouse"!==e.pointerType)return;const a=t.parentMenuContext();a?.onItemEnter(e),e.defaultPrevented||(r.disabled?a?.onItemLeave(e):(t.isOpen()||s||(t.parentMenuContext()?.setPointerGraceIntent(null),s=window.setTimeout((()=>{t.open(!1),l()}),100)),a?.onItemEnter(e),e.defaultPrevented||(t.listState().selectionManager().isFocused()&&(t.listState().selectionManager().setFocused(!1),t.listState().selectionManager().setFocusedKey(void 0)),Xye(e.currentTarget),a?.listState().selectionManager().setFocused(!0),a?.listState().selectionManager().setFocusedKey(c()))))},onPointerLeave:e=>{if($ye(e,r.onPointerLeave),"mouse"!==e.pointerType)return;l();const a=t.parentMenuContext(),n=t.contentRef();if(n){a?.setPointerGraceIntent({area:owe(t.currentPlacement(),e,n),side:t.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)}},(()=>t.dataset()),o))}function pwe(e){const a=HAe(),n=mke({id:`menu-${bn()}`,modal:!0},e),[t,i]=fn(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),r=JSe({open:()=>t.open,defaultOpen:()=>t.defaultOpen,onOpenChange:e=>t.onOpenChange?.(e)}),o={isModal:()=>t.modal??!0,preventScroll:()=>t.preventScroll??o.isModal(),forceMount:()=>t.forceMount??!1,generateId:Iye((()=>t.id)),value:()=>t.value,orientation:()=>t.orientation??a?.orientation()??"horizontal"};return dn(zAe.Provider,{value:o,get children(){return dn(swe,vn({get open(){return r.isOpen()},get onOpenChange(){return r.setIsOpen}},i))}})}function gwe(e){let a;const n=mke({orientation:"horizontal"},e),[t,i]=fn(n,["ref","orientation"]),r=bke((()=>a),(()=>"hr"));return dn(Ake,vn({as:"hr",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)},get role(){return"hr"!==r()?"separator":void 0},get"aria-orientation"(){return"vertical"===t.orientation?"vertical":void 0},get"data-orientation"(){return t.orientation}},i))}Bke({},{Root:()=>gwe,Separator:()=>vwe});var vwe=gwe,fwe={};function ywe(e){const a=RAe(),n=jAe(),[t,i]=fn(e,["onCloseAutoFocus","onInteractOutside"]);let r=!1;return dn(WAe,vn({onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),r||Xye(n.triggerRef()),r=!1,e.preventDefault()},onInteractOutside:e=>{t.onInteractOutside?.(e),a.isModal()&&!e.detail.isContextMenu||(r=!0)}},i))}function kwe(e){return dn(pwe,mke({id:`dropdownmenu-${bn()}`},e))}Bke(fwe,{Arrow:()=>_Se,CheckboxItem:()=>DAe,Content:()=>ywe,DropdownMenu:()=>bwe,Group:()=>ZAe,GroupLabel:()=>$Ae,Icon:()=>YAe,Item:()=>QAe,ItemDescription:()=>XAe,ItemIndicator:()=>ewe,ItemLabel:()=>awe,Portal:()=>nwe,RadioGroup:()=>iwe,RadioItem:()=>rwe,Root:()=>kwe,Separator:()=>gwe,Sub:()=>lwe,SubContent:()=>cwe,SubTrigger:()=>hwe,Trigger:()=>VAe});var bwe=Object.assign(kwe,{Arrow:_Se,CheckboxItem:DAe,Content:ywe,Group:ZAe,GroupLabel:$Ae,Icon:YAe,Item:QAe,ItemDescription:XAe,ItemIndicator:ewe,ItemLabel:awe,Portal:nwe,RadioGroup:iwe,RadioItem:rwe,Separator:gwe,Sub:lwe,SubContent:cwe,SubTrigger:hwe,Trigger:VAe}),Swe={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"}},Awe=_n('<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>'),wwe=_n('<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>'),Cwe=_n('<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>'),Mwe=_n('<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>'),Twe=_n('<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>'),Nwe=_n('<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>'),Ewe=_n('<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>'),xwe=_n('<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>'),Pwe=_n('<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">'),jwe=_n('<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">'),Lwe=_n('<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>'),Bwe=_n('<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>'),zwe=_n('<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>'),Rwe=_n('<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>'),_we=_n('<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>'),Dwe=_n('<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>'),Kwe=_n('<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>'),Hwe=_n('<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>'),Owe=_n('<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>'),Iwe=_n('<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>'),Gwe=_n('<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>'),Vwe=_n('<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>'),Fwe=_n('<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 Jwe(){return Awe()}function Uwe(){return wwe()}function Wwe(){return Cwe()}function qwe(){return Mwe()}function Zwe(){return Twe()}function $we(){return(e=Twe()).style.setProperty("transform","rotate(90deg)"),e;var e}function Ywe(){return(e=Twe()).style.setProperty("transform","rotate(-90deg)"),e;var e}function Qwe(){return Nwe()}function Xwe(){return Ewe()}function eCe(){return xwe()}function aCe(){return Pwe()}function nCe(){return jwe()}function tCe(){return Lwe()}function iCe(){return Bwe()}function rCe(){return zwe()}function oCe(){return Rwe()}function sCe(e){return a=_we(),n=a.firstChild,La((()=>Kn(n,"stroke","dark"===e.theme?"#12B76A":"#027A48"))),a;var a,n}function lCe(){return Dwe()}function uCe(){return Kwe()}function cCe(e){return[dn(Cn,{get when(){return e.checked},get children(){var a=_we(),n=a.firstChild;return La((()=>Kn(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}}),dn(Cn,{get when(){return!e.checked},get children(){var a=Hwe(),n=a.firstChild;return La((()=>Kn(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}})]}function dCe(){return Owe()}function mCe(){return Iwe()}function hCe(){return Gwe()}function pCe(){return Vwe()}function gCe(){const e=bn();return a=Fwe(),r=(i=(t=(n=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,f=(v=p.nextSibling).firstChild,b=(k=(y=v.nextSibling).nextSibling).firstChild,A=(S=k.nextSibling).firstChild,M=(C=(w=S.nextSibling).nextSibling).firstChild,N=(T=C.nextSibling).firstChild,P=(x=(E=T.nextSibling).nextSibling).firstChild,L=(j=x.nextSibling).firstChild,R=(z=(B=j.nextSibling).nextSibling).firstChild,D=(_=z.nextSibling).firstChild,O=(H=(K=_.nextSibling).firstChild.nextSibling.nextSibling.nextSibling).nextSibling,G=(I=K.nextSibling).firstChild,F=(V=I.nextSibling).firstChild,re=(ie=(te=(ne=(ae=(ee=(X=(Q=(Y=($=(Z=(q=(W=(U=(J=V.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,ve=(ge=he.nextSibling).firstChild,Re=(ze=(Be=(Le=(je=(Pe=(xe=(Ee=(Ne=(Te=(Me=(Ce=(we=(Ae=(Se=(be=(ke=(ye=(fe=ge.nextSibling).firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,Kn(n,"id",`a-${e}`),Kn(t,"fill",`url(#a-${e})`),Kn(r,"id",`am-${e}`),Kn(o,"id",`b-${e}`),Kn(s,"filter",`url(#am-${e})`),Kn(l,"mask",`url(#b-${e})`),Kn(c,"id",`ah-${e}`),Kn(d,"id",`k-${e}`),Kn(m,"filter",`url(#ah-${e})`),Kn(h,"mask",`url(#k-${e})`),Kn(g,"id",`ae-${e}`),Kn(v,"id",`j-${e}`),Kn(f,"filter",`url(#ae-${e})`),Kn(y,"mask",`url(#j-${e})`),Kn(b,"id",`ai-${e}`),Kn(S,"id",`i-${e}`),Kn(A,"filter",`url(#ai-${e})`),Kn(w,"mask",`url(#i-${e})`),Kn(M,"id",`aj-${e}`),Kn(T,"id",`h-${e}`),Kn(N,"filter",`url(#aj-${e})`),Kn(E,"mask",`url(#h-${e})`),Kn(P,"id",`ag-${e}`),Kn(j,"id",`g-${e}`),Kn(L,"filter",`url(#ag-${e})`),Kn(B,"mask",`url(#g-${e})`),Kn(R,"id",`af-${e}`),Kn(_,"id",`f-${e}`),Kn(D,"filter",`url(#af-${e})`),Kn(K,"mask",`url(#f-${e})`),Kn(H,"id",`m-${e}`),Kn(O,"fill",`url(#m-${e})`),Kn(G,"id",`ak-${e}`),Kn(V,"id",`e-${e}`),Kn(F,"filter",`url(#ak-${e})`),Kn(J,"mask",`url(#e-${e})`),Kn(U,"id",`n-${e}`),Kn(W,"fill",`url(#n-${e})`),Kn(q,"id",`r-${e}`),Kn(Z,"fill",`url(#r-${e})`),Kn($,"id",`s-${e}`),Kn(Y,"fill",`url(#s-${e})`),Kn(Q,"id",`q-${e}`),Kn(X,"fill",`url(#q-${e})`),Kn(ee,"id",`p-${e}`),Kn(ae,"fill",`url(#p-${e})`),Kn(ne,"id",`o-${e}`),Kn(te,"fill",`url(#o-${e})`),Kn(ie,"id",`l-${e}`),Kn(re,"fill",`url(#l-${e})`),Kn(se,"id",`al-${e}`),Kn(le,"id",`d-${e}`),Kn(ue,"filter",`url(#al-${e})`),Kn(ce,"mask",`url(#d-${e})`),Kn(de,"id",`u-${e}`),Kn(me,"fill",`url(#u-${e})`),Kn(pe,"id",`ad-${e}`),Kn(ge,"id",`c-${e}`),Kn(ve,"filter",`url(#ad-${e})`),Kn(fe,"mask",`url(#c-${e})`),Kn(ye,"id",`t-${e}`),Kn(ke,"fill",`url(#t-${e})`),Kn(be,"id",`v-${e}`),Kn(Se,"stroke",`url(#v-${e})`),Kn(Ae,"id",`aa-${e}`),Kn(we,"stroke",`url(#aa-${e})`),Kn(Ce,"id",`w-${e}`),Kn(Me,"stroke",`url(#w-${e})`),Kn(Te,"id",`ac-${e}`),Kn(Ne,"stroke",`url(#ac-${e})`),Kn(Ee,"id",`ab-${e}`),Kn(xe,"stroke",`url(#ab-${e})`),Kn(Pe,"id",`y-${e}`),Kn(je,"stroke",`url(#y-${e})`),Kn(Le,"id",`x-${e}`),Kn(Be,"stroke",`url(#x-${e})`),Kn(ze,"id",`z-${e}`),Kn(Re,"stroke",`url(#z-${e})`),a;var a,n,t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b,S,A,w,C,M,T,N,E,x,P,j,L,B,z,R,_,D,K,H,O,I,G,V,F,J,U,W,q,Z,$,Y,Q,X,ee,ae,ne,te,ie,re,oe,se,le,ue,ce,de,me,he,pe,ge,ve,fe,ye,ke,be,Se,Ae,we,Ce,Me,Te,Ne,Ee,xe,Pe,je,Le,Be,ze,Re}var vCe=_n('<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>'),fCe=_n('<button title="Copy object to clipboard">'),yCe=_n('<button title="Remove all items"aria-label="Remove all items">'),kCe=_n('<button title="Delete item"aria-label="Delete item">'),bCe=_n('<button title="Toggle value"aria-label="Toggle value">'),SCe=_n('<button title="Bulk Edit Data"aria-label="Bulk Edit Data">'),ACe=_n("<div>"),wCe=_n("<div><button> <span></span> <span> "),CCe=_n("<input>"),MCe=_n("<span>"),TCe=_n("<div><span>:"),NCe=_n("<div><div><button> [<!>...<!>]");var ECe=e=>{const a=qfe(),n=Vfe().shadowDOMTarget?kye.bind({target:Vfe().shadowDOMTarget}):kye,t=za((()=>"dark"===a()?DCe(n):_Ce(n)));return i=vCe(),La((()=>Hn(i,Sye(t().expander,n`
114
+ */tse.exports="production"===process.env.NODE_ENV?function(){if(nse)return ise;nse=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},n=a.useState,t=a.useEffect,i=a.useLayoutEffect,r=a.useDebugValue;function o(a){var n=a.getSnapshot;a=a.value;try{var t=n();return!e(a,t)}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=n({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]),t((function(){return o(u)&&c({inst:u}),e((function(){o(u)&&c({inst:u})}))}),[e]),r(s),s};return ise.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:s,ise}():(rse||(rse=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var a=e.getSnapshot;e=e.value;try{var n=a();return!t(e,n)}catch(i){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=a,t="function"==typeof Object.is?Object.is:function(e,a){return e===a&&(0!==e||1/e==1/a)||e!=e&&a!=a},i=n.useState,r=n.useEffect,o=n.useLayoutEffect,s=n.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===n.startTransition||(l=!0);var d=c();if(!u){var m=c();t(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};ose.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),ose);var sse=tse.exports,lse='[cmdk-group=""]',use='[cmdk-group-items=""]',cse='[cmdk-item=""]',dse=`${cse}:not([aria-disabled="true"])`,mse="cmdk-item-select",hse="data-value",pse=(e,a,n)=>ase(e,a,n),gse=r.createContext(void 0),vse=()=>r.useContext(gse),fse=r.createContext(void 0),yse=()=>r.useContext(fse),kse=r.createContext(void 0),bse=r.forwardRef(((e,a)=>{let n=zse((()=>{var a,n;return{search:"",value:null!=(n=null!=(a=e.value)?a:e.defaultValue)?n:"",filtered:{count:0,items:new Map,groups:new Set}}})),t=zse((()=>new Set)),i=zse((()=>new Map)),o=zse((()=>new Map)),s=zse((()=>new Set)),l=Lse(e),{label:u,children:c,value:d,onValueChange:m,filter:h,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:f=!0,...y}=e,k=KX(),b=KX(),S=KX(),A=r.useRef(null),w=Kse();Bse((()=>{if(void 0!==d){let e=d.trim();n.current.value=e,C.emit()}}),[d]),Bse((()=>{w(6,P)}),[]);let C=r.useMemo((()=>({subscribe:e=>(s.current.add(e),()=>s.current.delete(e)),snapshot:()=>n.current,setState:(e,a,t)=>{var i,r,o;if(!Object.is(n.current[e],a)){if(n.current[e]=a,"search"===e)x(),N(),w(1,E);else if("value"===e&&(t||w(5,P),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,t)=>{var i;a!==(null==(i=o.current.get(e))?void 0:i.value)&&(o.current.set(e,{value:a,keywords:t}),n.current.filtered.items.set(e,T(a,t)),w(2,(()=>{N(),C.emit()})))},item:(e,a)=>(t.current.add(e),a&&(i.current.has(a)?i.current.get(a).add(e):i.current.set(a,new Set([e]))),w(3,(()=>{x(),N(),n.current.value||E(),C.emit()})),()=>{o.current.delete(e),t.current.delete(e),n.current.filtered.items.delete(e);let a=j();w(4,(()=>{x(),(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:k,inputId:S,labelId:b,listInnerRef:A})),[]);function T(e,a){var t,i;let r=null!=(i=null==(t=l.current)?void 0:t.filter)?i:pse;return e?r(e,n.current.search,a):0}function N(){if(!n.current.search||!1===l.current.shouldFilter)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach((n=>{let t=i.current.get(n),r=0;t.forEach((a=>{let n=e.get(a);r=Math.max(n,r)})),a.push([n,r])}));let t=A.current;L().sort(((a,n)=>{var t,i;let r=a.getAttribute("id"),o=n.getAttribute("id");return(null!=(t=e.get(o))?t:0)-(null!=(i=e.get(r))?i:0)})).forEach((e=>{let a=e.closest(use);a?a.appendChild(e.parentElement===a?e:e.closest(`${use} > *`)):t.appendChild(e.parentElement===t?e:e.closest(`${use} > *`))})),a.sort(((e,a)=>a[1]-e[1])).forEach((e=>{var a;let n=null==(a=A.current)?void 0:a.querySelector(`${lse}[${hse}="${encodeURIComponent(e[0])}"]`);null==n||n.parentElement.appendChild(n)}))}function E(){let e=L().find((e=>"true"!==e.getAttribute("aria-disabled"))),a=null==e?void 0:e.getAttribute(hse);C.setState("value",a||void 0)}function x(){var e,a,r,s;if(!n.current.search||!1===l.current.shouldFilter)return void(n.current.filtered.count=t.current.size);n.current.filtered.groups=new Set;let u=0;for(let i of t.current){let t=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:[]);n.current.filtered.items.set(i,t),t>0&&u++}for(let[t,o]of i.current)for(let e of o)if(n.current.filtered.items.get(e)>0){n.current.filtered.groups.add(t);break}n.current.filtered.count=u}function P(){var e,a,n;let t=j();t&&((null==(e=t.parentElement)?void 0:e.firstChild)===t&&(null==(n=null==(a=t.closest(lse))?void 0:a.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),t.scrollIntoView({block:"nearest"}))}function j(){var e;return null==(e=A.current)?void 0:e.querySelector(`${cse}[aria-selected="true"]`)}function L(){var e;return Array.from((null==(e=A.current)?void 0:e.querySelectorAll(dse))||[])}function B(e){let a=L()[e];a&&C.setState("value",a.getAttribute(hse))}function z(e){var a;let n=j(),t=L(),i=t.findIndex((e=>e===n)),r=t[i+e];null!=(a=l.current)&&a.loop&&(r=i+e<0?t[t.length-1]:i+e===t.length?t[0]:t[i+e]),r&&C.setState("value",r.getAttribute(hse))}function R(e){let a,n=j(),t=null==n?void 0:n.closest(lse);for(;t&&!a;)t=e>0?Pse(t,lse):jse(t,lse),a=null==t?void 0:t.querySelector(dse);a?C.setState("value",a.getAttribute(hse)):z(e)}let _=()=>B(L().length-1),D=e=>{e.preventDefault(),e.metaKey?_():e.altKey?R(1):z(1)},K=e=>{e.preventDefault(),e.metaKey?B(0):e.altKey?R(-1):z(-1)};return r.createElement(lX.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":f&&e.ctrlKey&&D(e);break;case"ArrowDown":D(e);break;case"p":case"k":f&&e.ctrlKey&&K(e);break;case"ArrowUp":K(e);break;case"Home":e.preventDefault(),B(0);break;case"End":e.preventDefault(),_();break;case"Enter":if(!e.nativeEvent.isComposing&&229!==e.keyCode){e.preventDefault();let a=j();if(a){let e=new Event(mse);a.dispatchEvent(e)}}}}},r.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:Ose},u),Hse(e,(e=>r.createElement(fse.Provider,{value:C},r.createElement(gse.Provider,{value:M},e)))))})),Sse=r.forwardRef(((e,a)=>{var n,t;let i=KX(),o=r.useRef(null),s=r.useContext(kse),l=vse(),u=Lse(e),c=null!=(t=null==(n=u.current)?void 0:n.forceMount)?t:null==s?void 0:s.forceMount;Bse((()=>{if(!c)return l.item(i,null==s?void 0:s.id)}),[c]);let d=Dse(i,o,[e.value,e.children,o],e.keywords),m=yse(),h=_se((e=>e.value&&e.value===d.current)),p=_se((e=>!(!c&&!1!==l.filter())||(!e.search||e.filtered.items.get(i)>0)));function g(){var e,a;v(),null==(a=(e=u.current).onSelect)||a.call(e,d.current)}function v(){m.setState("value",d.current,!0)}if(r.useEffect((()=>{let a=o.current;if(a&&!e.disabled)return a.addEventListener(mse,g),()=>a.removeEventListener(mse,g)}),[p,e.onSelect,e.disabled]),!p)return null;let{disabled:f,value:y,onSelect:k,forceMount:b,keywords:S,...A}=e;return r.createElement(lX.div,{ref:Rse([o,a]),...A,id:i,"cmdk-item":"",role:"option","aria-disabled":!!f,"aria-selected":!!h,"data-disabled":!!f,"data-selected":!!h,onPointerMove:f||l.getDisablePointerSelection()?void 0:v,onClick:f?void 0:g},e.children)})),Ase=r.forwardRef(((e,a)=>{let{heading:n,children:t,forceMount:i,...o}=e,s=KX(),l=r.useRef(null),u=r.useRef(null),c=KX(),d=vse(),m=_se((e=>!(!i&&!1!==d.filter())||(!e.search||e.filtered.groups.has(s))));Bse((()=>d.group(s)),[]),Dse(s,l,[e.value,e.heading,u]);let h=r.useMemo((()=>({id:s,forceMount:i})),[i]);return r.createElement(lX.div,{ref:Rse([l,a]),...o,"cmdk-group":"",role:"presentation",hidden:!m||void 0},n&&r.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Hse(e,(e=>r.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},r.createElement(kse.Provider,{value:h},e)))))})),wse=r.forwardRef(((e,a)=>{let{alwaysRender:n,...t}=e,i=r.useRef(null),o=_se((e=>!e.search));return n||o?r.createElement(lX.div,{ref:Rse([i,a]),...t,"cmdk-separator":"",role:"separator"}):null})),Cse=r.forwardRef(((e,a)=>{let{onValueChange:n,...t}=e,i=null!=e.value,o=yse(),s=_se((e=>e.search)),l=_se((e=>e.value)),u=vse(),c=r.useMemo((()=>{var e;let a=null==(e=u.listInnerRef.current)?void 0:e.querySelector(`${cse}[${hse}="${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(lX.input,{ref:a,...t,"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==n||n(e.target.value)}})})),Mse=r.forwardRef(((e,a)=>{let{children:n,label:t="Suggestions",...i}=e,o=r.useRef(null),s=r.useRef(null),l=vse();return r.useEffect((()=>{if(s.current&&o.current){let e,a=s.current,n=o.current,t=new ResizeObserver((()=>{e=requestAnimationFrame((()=>{n.style.setProperty("--cmdk-list-height",a.offsetHeight.toFixed(1)+"px")}))}));return t.observe(a),()=>{cancelAnimationFrame(e),t.unobserve(a)}}}),[]),r.createElement(lX.div,{ref:Rse([o,a]),...i,"cmdk-list":"",role:"listbox","aria-label":t,id:l.listId},Hse(e,(e=>r.createElement("div",{ref:Rse([s,l.listInnerRef]),"cmdk-list-sizer":""},e))))})),Tse=r.forwardRef(((e,a)=>{let{open:n,onOpenChange:t,overlayClassName:i,contentClassName:o,container:s,...l}=e;return r.createElement(RG,{open:n,onOpenChange:t},r.createElement(_G,{container:s},r.createElement(DG,{"cmdk-overlay":"",className:i}),r.createElement(KG,{"aria-label":e.label,"cmdk-dialog":"",className:o},r.createElement(bse,{ref:a,...l}))))})),Nse=r.forwardRef(((e,a)=>_se((e=>0===e.filtered.count))?r.createElement(lX.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null)),Ese=r.forwardRef(((e,a)=>{let{progress:n,children:t,label:i="Loading...",...o}=e;return r.createElement(lX.div,{ref:a,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Hse(e,(e=>r.createElement("div",{"aria-hidden":!0},e))))})),xse=Object.assign(bse,{List:Mse,Item:Sse,Input:Cse,Group:Ase,Separator:wse,Dialog:Tse,Empty:Nse,Loading:Ese});function Pse(e,a){let n=e.nextElementSibling;for(;n;){if(n.matches(a))return n;n=n.nextElementSibling}}function jse(e,a){let n=e.previousElementSibling;for(;n;){if(n.matches(a))return n;n=n.previousElementSibling}}function Lse(e){let a=r.useRef(e);return Bse((()=>{a.current=e})),a}var Bse="undefined"==typeof window?r.useEffect:r.useLayoutEffect;function zse(e){let a=r.useRef();return void 0===a.current&&(a.current=e()),a}function Rse(e){return a=>{e.forEach((e=>{"function"==typeof e?e(a):null!=e&&(e.current=a)}))}}function _se(e){let a=yse(),n=()=>e(a.snapshot());return sse.useSyncExternalStore(a.subscribe,n,n)}function Dse(e,a,n,t=[]){let i=r.useRef(),o=vse();return Bse((()=>{var r;let s=(()=>{var e;for(let a of n){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=t.map((e=>e.trim()));o.value(e,s,l),null==(r=a.current)||r.setAttribute(hse,s),i.current=s})),i}var Kse=()=>{let[e,a]=r.useState(),n=zse((()=>new Map));return Bse((()=>{n.current.forEach((e=>e())),n.current=new Map}),[e]),(e,t)=>{n.current.set(e,t),a({})}};function Hse({asChild:e,children:a},n){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},n(a.props.children)):n(a)}var Ose={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Ise=r.forwardRef((({className:e,...a},t)=>n.jsx(xse,{ref:t,className:pm("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...a})));Ise.displayName=xse.displayName;const Gse=r.forwardRef((({className:e,searchIcon:a,...t},i)=>n.jsxs("div",{className:"flex items-center border-b px-3",children:[a||n.jsx(sd,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 "}),n.jsx(xse.Input,{ref:i,className:pm("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),...t})]})));Gse.displayName=xse.Input.displayName;const Vse=r.forwardRef((({className:e,...a},t)=>n.jsx(xse.List,{ref:t,className:pm("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a})));Vse.displayName=xse.List.displayName;const Fse=r.forwardRef(((e,a)=>n.jsx(xse.Empty,{ref:a,className:"py-6 text-center text-sm",...e})));Fse.displayName=xse.Empty.displayName;const Jse=r.forwardRef((({className:e,...a},t)=>n.jsx(xse.Group,{ref:t,className:pm("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})));Jse.displayName=xse.Group.displayName;r.forwardRef((({className:e,...a},t)=>n.jsx(xse.Separator,{ref:t,className:pm("-mx-1 h-px bg-border",e),...a}))).displayName=xse.Separator.displayName;const Use=r.forwardRef((({className:e,...a},t)=>n.jsx(xse.Item,{ref:t,className:pm("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 Wse(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function qse(...e){return a=>{let n=!1;const t=e.map((e=>{const t=Wse(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():Wse(e[a],null)}}}}function Zse(...e){return r.useCallback(qse(...e),e)}function $se(e){const a=Yse(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(Xse);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 n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function Yse(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{const a=r(...e);return i(...e),a}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?qse(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}Use.displayName=xse.Item.displayName;var Qse=Symbol("radix.slottable");function Xse(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Qse}var ele=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=$se(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{}),ale=globalThis?.document?r.useLayoutEffect:()=>{};var nle=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=tle(t.current);o.current="mounted"===l?e:"none"}),[l]),ale((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=tle(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),ale((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=tle(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=tle(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.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=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=Zse(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function tle(e){return e?.animationName||"none"}function ile(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function rle(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}nle.displayName="Presence";var ole=r.createContext(void 0);function sle(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}var lle="ScrollArea",[ule,cle]=function(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},ile(i,...a)]}(lle),[dle,mle]=ule(lle),hle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,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,v]=r.useState(null),[f,y]=r.useState(null),[k,b]=r.useState(0),[S,A]=r.useState(0),[w,C]=r.useState(!1),[M,T]=r.useState(!1),N=Zse(a,(e=>c(e))),E=function(e){const a=r.useContext(ole);return e||a||"ltr"}(o);return n.jsx(dle,{scope:t,type:i,dir:E,scrollHideDelay:s,scrollArea:u,viewport:d,onViewportChange:m,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:w,onScrollbarXEnabledChange:C,scrollbarY:f,onScrollbarYChange:y,scrollbarYEnabled:M,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:A,children:n.jsx(ele.div,{dir:E,...l,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})}));hle.displayName=lle;var ple="ScrollAreaViewport",gle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,children:i,nonce:o,...s}=e,l=mle(ple,t),u=Zse(a,r.useRef(null),l.onViewportChange);return n.jsxs(n.Fragment,{children:[n.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}),n.jsx(ele.div,{"data-radix-scroll-area-viewport":"",...s,ref:u,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})}));gle.displayName=ple;var vle="ScrollAreaScrollbar",fle=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=mle(vle,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?n.jsx(yle,{...i,ref:a,forceMount:t}):"scroll"===o.type?n.jsx(kle,{...i,ref:a,forceMount:t}):"auto"===o.type?n.jsx(ble,{...i,ref:a,forceMount:t}):"always"===o.type?n.jsx(Sle,{...i,ref:a}):null}));fle.displayName=vle;var yle=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=mle(vle,e.__scopeScrollArea),[s,l]=r.useState(!1);return r.useEffect((()=>{const e=o.scrollArea;let a=0;if(e){const n=()=>{window.clearTimeout(a),l(!0)},t=()=>{a=window.setTimeout((()=>l(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",t),()=>{window.clearTimeout(a),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",t)}}}),[o.scrollArea,o.scrollHideDelay]),n.jsx(nle,{present:t||s,children:n.jsx(ble,{"data-state":s?"visible":"hidden",...i,ref:a})})})),kle=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,o=mle(vle,e.__scopeScrollArea),s="horizontal"===e.orientation,l=Ole((()=>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 n=e[a];const t=()=>{const t=e[a];n!==t&&(c("SCROLL"),l()),n=t};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[o.viewport,s,c,l]),n.jsx(nle,{present:t||"hidden"!==u,children:n.jsx(Sle,{"data-state":"hidden"===u?"hidden":"visible",...i,ref:a,onPointerEnter:sle(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:sle(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),ble=r.forwardRef(((e,a)=>{const t=mle(vle,e.__scopeScrollArea),{forceMount:i,...o}=e,[s,l]=r.useState(!1),u="horizontal"===e.orientation,c=Ole((()=>{if(t.viewport){l(u?t.viewport.offsetWidth<t.viewport.scrollWidth:t.viewport.offsetHeight<t.viewport.scrollHeight)}}),10);return Ile(t.viewport,c),Ile(t.content,c),n.jsx(nle,{present:i||s,children:n.jsx(Sle,{"data-state":s?"visible":"hidden",...o,ref:a})})})),Sle=r.forwardRef(((e,a)=>{const{orientation:t="vertical",...i}=e,o=mle(vle,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=zle(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,n,t="ltr"){const i=Rle(n),r=i/2,o=a||r,s=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-(i-o),u=n.content-n.viewport,c="ltr"===t?[0,u]:[-1*u,0];return Dle([s,l],c)(e)}(e,l.current,u,a)}return"horizontal"===t?n.jsx(Ale,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=_le(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"===t?n.jsx(wle,{...m,ref:a,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=_le(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})),Ale=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=mle(vle,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Zse(a,c,s.onScrollbarXChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(Tle,{"data-orientation":"horizontal",...o,ref:d,sizes:t,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":Rle(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.x),onDragScroll:a=>e.onDragScroll(a.x),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollLeft+a.deltaX;e.onWheelScroll(t),Kle(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ble(l.paddingLeft),paddingEnd:Ble(l.paddingRight)}})}})})),wle=r.forwardRef(((e,a)=>{const{sizes:t,onSizesChange:i,...o}=e,s=mle(vle,e.__scopeScrollArea),[l,u]=r.useState(),c=r.useRef(null),d=Zse(a,c,s.onScrollbarYChange);return r.useEffect((()=>{c.current&&u(getComputedStyle(c.current))}),[c]),n.jsx(Tle,{"data-orientation":"vertical",...o,ref:d,sizes:t,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":Rle(t)+"px",...e.style},onThumbPointerDown:a=>e.onThumbPointerDown(a.y),onDragScroll:a=>e.onDragScroll(a.y),onWheelScroll:(a,n)=>{if(s.viewport){const t=s.viewport.scrollTop+a.deltaY;e.onWheelScroll(t),Kle(t,n)&&a.preventDefault()}},onResize:()=>{c.current&&s.viewport&&l&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ble(l.paddingTop),paddingEnd:Ble(l.paddingBottom)}})}})})),[Cle,Mle]=ule(vle),Tle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,sizes:i,hasThumb:o,onThumbChange:s,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...p}=e,g=mle(vle,t),[v,f]=r.useState(null),y=Zse(a,(e=>f(e))),k=r.useRef(null),b=r.useRef(""),S=g.viewport,A=i.content-i.viewport,w=rle(m),C=rle(c),M=Ole(h,10);function T(e){if(k.current){d({x:e.clientX-k.current.left,y:e.clientY-k.current.top})}}return r.useEffect((()=>{const e=e=>{const a=e.target,n=v?.contains(a);n&&w(e,A)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[S,v,A,w]),r.useEffect(C,[i,C]),Ile(v,M),Ile(g.content,M),n.jsx(Cle,{scope:t,scrollbar:v,hasThumb:o,onThumbChange:rle(s),onThumbPointerUp:rle(l),onThumbPositionChange:C,onThumbPointerDown:rle(u),children:n.jsx(ele.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:sle(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),k.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(e)}})),onPointerMove:sle(e.onPointerMove,T),onPointerUp:sle(e.onPointerUp,(e=>{const a=e.target;a.hasPointerCapture(e.pointerId)&&a.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,g.viewport&&(g.viewport.style.scrollBehavior=""),k.current=null}))})})})),Nle="ScrollAreaThumb",Ele=r.forwardRef(((e,a)=>{const{forceMount:t,...i}=e,r=Mle(Nle,e.__scopeScrollArea);return n.jsx(nle,{present:t||r.hasThumb,children:n.jsx(xle,{ref:a,...i})})})),xle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,style:i,...o}=e,s=mle(Nle,t),l=Mle(Nle,t),{onThumbPositionChange:u}=l,c=Zse(a,(e=>l.onThumbChange(e))),d=r.useRef(void 0),m=Ole((()=>{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=Hle(e,u);d.current=a,u()}};return u(),e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}}),[s.viewport,m,u]),n.jsx(ele.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:sle(e.onPointerDownCapture,(e=>{const a=e.target.getBoundingClientRect();l.onThumbPointerDown({x:e.clientX-a.left,y:e.clientY-a.top})})),onPointerUp:sle(e.onPointerUp,l.onThumbPointerUp)})}));Ele.displayName=Nle;var Ple="ScrollAreaCorner",jle=r.forwardRef(((e,a)=>{const t=mle(Ple,e.__scopeScrollArea),i=Boolean(t.scrollbarX&&t.scrollbarY);return"scroll"!==t.type&&i?n.jsx(Lle,{...e,ref:a}):null}));jle.displayName=Ple;var Lle=r.forwardRef(((e,a)=>{const{__scopeScrollArea:t,...i}=e,o=mle(Ple,t),[s,l]=r.useState(0),[u,c]=r.useState(0),d=Boolean(s&&u);return Ile(o.scrollbarX,(()=>{const e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)})),Ile(o.scrollbarY,(()=>{const e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),l(e)})),d?n.jsx(ele.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 Ble(e){return e?parseInt(e,10):0}function zle(e,a){const n=e/a;return isNaN(n)?0:n}function Rle(e){const a=zle(e.viewport,e.content);return Math.max((e.scrollbar.size-(e.scrollbar.paddingStart+e.scrollbar.paddingEnd))*a,18)}function _le(e,a,n="ltr"){const t=Rle(a),i=a.content-a.viewport,r=a.scrollbar.size-(a.scrollbar.paddingStart+a.scrollbar.paddingEnd)-t,o=function(e,[a,n]){return Math.min(n,Math.max(a,e))}(e,"ltr"===n?[0,i]:[-1*i,0]);return Dle([0,i],[0,r])(o)}function Dle(e,a){return n=>{if(e[0]===e[1]||a[0]===a[1])return a[0];return a[0]+(a[1]-a[0])/(e[1]-e[0])*(n-e[0])}}function Kle(e,a){return e>0&&e<a}var Hle=(e,a=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},t=0;return function i(){const r={left:e.scrollLeft,top:e.scrollTop};(n.left!==r.left||n.top!==r.top)&&a(),n=r,t=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(t)};function Ole(e,a){const n=rle(e),t=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),r.useCallback((()=>{window.clearTimeout(t.current),t.current=window.setTimeout(n,a)}),[n,a])}function Ile(e,a){const n=rle(a);ale((()=>{let a=0;if(e){const t=new ResizeObserver((()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(n)}));return t.observe(e),()=>{window.cancelAnimationFrame(a),t.unobserve(e)}}}),[e,n])}var Gle=hle,Vle=gle,Fle=jle;const Jle=r.forwardRef((({className:e,children:a,...t},i)=>n.jsxs(Gle,{ref:i,className:GG("relative overflow-hidden",e),...t,children:[n.jsx(Vle,{className:"h-full w-full rounded-[inherit]",children:a}),n.jsx(Ule,{}),n.jsx(Fle,{})]})));Jle.displayName=Gle.displayName;const Ule=r.forwardRef((({className:e,orientation:a="vertical",...t},i)=>n.jsx(fle,{ref:i,orientation:a,className:GG("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),...t,children:n.jsx(Ele,{className:"relative flex-1 rounded-full bg-border"})})));Ule.displayName=fle.displayName;var Wle=r.forwardRef(((e,a)=>{const{children:t,...i}=e,o=r.Children.toArray(t),s=o.find($le);if(s){const e=s.props.children,t=o.map((a=>a===s?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:a));return n.jsx(qle,{...i,ref:a,children:r.isValidElement(e)?r.cloneElement(e,void 0,t):null})}return n.jsx(qle,{...i,ref:a,children:t})}));Wle.displayName="Slot";var qle=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?mO(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));qle.displayName="SlotClone";var Zle=({children:e})=>n.jsx(n.Fragment,{children:e});function $le(e){return r.isValidElement(e)&&e.type===Zle}var Yle=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,a)=>{const t=r.forwardRef(((e,t)=>{const{asChild:i,...r}=e,o=i?Wle:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(o,{...r,ref:t})}));return t.displayName=`Primitive.${a}`,{...e,[a]:t}}),{}),Qle="horizontal",Xle=["horizontal","vertical"],eue=r.forwardRef(((e,a)=>{const{decorative:t,orientation:i=Qle,...r}=e,o=function(e){return Xle.includes(e)}(i)?i:Qle;return n.jsx(Yle.div,{"data-orientation":o,...t?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...r,ref:a})}));eue.displayName="Separator";var aue=eue;const nue=r.forwardRef((({className:e,orientation:a="horizontal",decorative:t=!0,...i},r)=>n.jsx(aue,{ref:r,decorative:t,orientation:a,className:pm("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",e),...i})));function tue({options:e,onValueChange:a,selectedValues:t,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),[v,f]=r.useState(""),[y,k]=r.useState(t),b=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(!v)return b;return[...b.filter((e=>y.includes(e.value))),...b.filter((e=>!y.includes(e.value))).filter((e=>e.label.toLowerCase().includes(v.toLowerCase())))]}),[b,v,y]),A=r.useCallback((()=>t.map((a=>{const n=e.find((e=>e.value===a));return{value:a,label:n?.label||a}}))),[t,e]),w=e=>{if(h)return k([e]),a([e]),i([e]),void g(!1);k((a=>a.includes(e)?a.filter((a=>a!==e)):o&&a.length>=o?a:[...a,e]))};r.useEffect((()=>{p&&(k(t),f(""))}),[p,t]);const C=y.length,M=S.filter((e=>y.includes(e.value))).length,T=A(),N=!o||y.length<o,E=r.useMemo((()=>S.filter((e=>y.includes(e.value)))),[S,y]),x=r.useMemo((()=>S.filter((e=>!y.includes(e.value)))),[S,y]);return n.jsxs(VG,{open:p&&m,onOpenChange:g,children:[n.jsx(FG,{asChild:!0,children:n.jsxs(PY,{variant:"outline",className:"w-full justify-between text-left font-normal h-9 p-3",children:[n.jsx("div",{className:"flex flex-nowrap items-center gap-1 max-w-[70%]",children:0===T.length?n.jsx("span",{className:"text-muted-foreground",children:s}):h?n.jsx(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label}):T.length<=2?T.map((e=>n.jsx(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:e.label},e.value))):n.jsxs(n.Fragment,{children:[n.jsx(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:T[0].label},T[0].value),n.jsxs(JY,{variant:"secondary",className:"text-xs whitespace-nowrap",children:["+",T.length-1," more"]})]})}),n.jsx(zY.DropdownMenuTrigger,{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0"})]})}),n.jsxs(WG,{className:"max-w-md w-full max-h-[80vh] p-0",children:[n.jsx(qG,{className:"p-6 pb-4",children:n.jsxs($G,{className:"flex items-center gap-2 text-xl",children:[n.jsx(zY.UsersIcon,{className:"h-5 w-5 text-primary"}),l]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"relative",children:[n.jsx(zY.SearchIcon,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(r4,{placeholder:u,value:v,onChange:e=>f(e.target.value),className:"pl-10 h-11"})]})}),!h&&n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsxs("span",{className:"text-muted-foreground",children:[C," of ",b.length," selected",o&&` (max ${o})`]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(PY,{variant:"ghost",size:"sm",onClick:()=>{const e=S.filter((e=>!y.includes(e.value))),a=o?e.slice(0,o-y.length):e;k((e=>[...e,...a.map((e=>e.value))]))},disabled:!N||M===S.length,className:"h-8 text-xs",children:"Select All"}),n.jsx(PY,{variant:"ghost",size:"sm",onClick:()=>{const e=new Set(S.map((e=>e.value)));k((a=>a.filter((a=>!e.has(a)))))},disabled:0===M,className:"h-8 text-xs",children:"Clear All"})]})]})}),n.jsx(nue,{}),n.jsx(Jle,{className:"flex-1 max-h-[300px]",children:n.jsx(Ise,{className:"rounded-none border-none",children:n.jsxs(Jse,{children:[d.length>0&&n.jsxs(n.Fragment,{children:[d.map(((e,a)=>n.jsx("div",{className:"px-3 py-2",children:e(g)},`extra-command-${a}`))),n.jsx(nue,{className:"my-2"})]}),0===S.length?n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(zY.SearchIcon,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:c})]}):n.jsxs(n.Fragment,{children:[!h&&E.length>0&&n.jsxs(n.Fragment,{children:[n.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=>n.jsxs(Use,{onSelect:()=>w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors hover:bg-muted/50 cursor-pointer",children:[n.jsx(Woe,{checked:!0,disabled:!1,onChange:()=>w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),n.jsx(zY.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value))),n.jsx(nue,{className:"my-2"})]}),n.jsx("div",{className:"px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground tracking-wide uppercase",children:h?"Options":`Available (${x.length})`}),x.map((e=>{const a=y.includes(e.value),t=!h&&!N;return n.jsxs(Use,{onSelect:()=>!t&&w(e.value),className:"flex items-center space-x-3 p-3 rounded-lg transition-colors "+(t?"opacity-50 cursor-not-allowed":"hover:bg-muted/50 cursor-pointer"),children:[!h&&n.jsx(Woe,{checked:a,disabled:t,onChange:()=>!t&&w(e.value),className:"flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx("div",{className:"font-medium text-sm truncate",children:e.label})}),a&&n.jsx(zY.CheckIcon,{className:"h-4 w-4 text-primary flex-shrink-0"})]},e.value)}))]})]})})}),!h&&n.jsxs(n.Fragment,{children:[n.jsx(nue,{}),n.jsx("div",{className:"p-6 pt-4",children:n.jsxs("div",{className:"flex gap-3",children:[n.jsx(PY,{variant:"outline",onClick:()=>{k(t),f(""),g(!1)},className:"flex-1",children:"Cancel"}),n.jsxs(PY,{onClick:()=>{a(y),i(y),g(!1)},className:"flex-1 bg-primary hover:bg-primary/90",children:["Apply (",C,")"]})]})})]})]})]})}nue.displayName=aue.displayName;const iue=r.forwardRef((({className:e,...a},t)=>n.jsx("textarea",{className:pm("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:t,...a})));iue.displayName="Textarea";const rue=e=>{const{companyName:a,smsBody:n}=e;return a&&n?`${a}:\n${n}`:n??""},oue=({body:e,imageUrls:a})=>n.jsx("div",{className:"sms-preview-outer @container",children:n.jsxs("div",{className:"sms-phone-mockup",children:[n.jsx("div",{className:"sms-phone-notch"}),n.jsxs("div",{className:"sms-phone-inner",children:[a&&a.length>0&&a.map(((e,a)=>n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:n.jsx("img",{src:e,alt:"MMS attachment",className:"sms-message-image",loading:"lazy"})})},e+a))),n.jsx("div",{className:"sms-message-row",children:n.jsx("div",{className:"sms-message-bubble",children:e})})]}),n.jsx("div",{className:"sms-phone-home-indicator"})]})}),sue=({mergeFieldsResponse:e})=>{const t=1500,i=AY(),r=wY(),{data:o}=L9(),s=a.useCallback((()=>{const e=i?.actionData?.find((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId===r?.id));return e?.actionMetadata.communicationGroupId}),[i?.actionData,r?.id]),{channelSenders:l}=E9(),{data:u,isLoading:c}=Poe(),{channelAccounts:d}=M9(),{toast:m}=Ie(),{updateCommunicationGroup:h,isUpdating:p}=Ze(),[g,v]=a.useState(null),[f,y]=a.useState(!1),[k,b]=a.useState(null),[S,A]=a.useState(null),[w,C]=a.useState([]),[M,T]=a.useState(null),[N,E]=a.useState(!1),[x,P]=a.useState(!1),j=a.useRef(null),L=a.useRef(null),[B,z]=a.useState(null),[R,_]=a.useState(null),[D,K]=a.useState(!1),H=a.useMemo((()=>mee({channelSenders:l?.results??[],channelAccounts:d?.results??[],smsApplication:o})),[l,d,o]);a.useEffect((()=>{N&&(T(S),w.length>0&&!B&&!D&&z(w[0]))}),[N,S,w,B,D]),a.useEffect((()=>{N||(z(w.length>0?w[0]:null),_(null),K(!1))}),[N,w]);a.useEffect((()=>{r&&(v(r.smsChannelSenderId),A(r.smsMessageBody),r.textMessageCompanyName&&b(r.textMessageCompanyName),r.textMessageMediaUrls&&C(r.textMessageMediaUrls),P(!0))}),[r]);a.useEffect((()=>{void 0!==l&&x&&(g?g&&r?.id&&h({groupId:r.id,params:{smsChannelSenderId:g}}):H?.[0]&&(v(H[0].channelSender.id),r?.id&&h({groupId:r.id,params:{smsChannelSenderId:H[0].channelSender.id}})))}),[l,g,r?.id,h,o,d?.results,r?.emailChannelSenderId,H,x]),a.useEffect((()=>{k||!u?.name||f||(y(!0),b(u.name))}),[k,u?.name,f]);return d&&l&&!c&&void 0!==H&&void 0!==o?0===H?.length&&o?.status!==dee.PENDING?n.jsx(Noe,{}):n.jsxs("div",{children:[n.jsx(VG,{open:N,onOpenChange:E,children:n.jsxs(WG,{hideCloseButton:!0,className:"max-w-[50vw]",children:[n.jsxs(kO,{children:[n.jsx($G,{children:"SMS Editor"}),n.jsx(YG,{children:"Learn more about the SMS editor and how to use it to create your SMS."})]}),n.jsxs("div",{className:"",children:[B&&n.jsx("div",{className:"flex justify-center mb-6",children:n.jsxs("div",{className:"relative group w-fit",children:[n.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 group-hover:scale-105",style:{boxShadow:"0 4px 24px 0 rgba(0,0,0,0.08)"}}),n.jsx(PY,{variant:"ghost",size:"icon",className:"absolute -top-3 -right-3 bg-white/80 hover:bg-red-100 text-gray-500 hover:text-red-500 shadow-md border border-gray-200 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{z(null),_(null),K(!0)},style:{boxShadow:"0 2px 8px 0 rgba(0,0,0,0.10)"},children:n.jsx(bd,{className:"h-4 w-4"})})]})}),n.jsx(iue,{ref:j,className:"min-h-[300px]",placeholder:"Text message content...",value:M??"",onChange:e=>{T(e.target.value)},maxLength:t-(k?.length||0)}),n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(tue,{options:e?.mergeFields?.flatMap((e=>e.entries.map((e=>({label:e.label,value:e.value})))))??[],selectedValues:[],setSelectedValues:()=>{},onValueChange:e=>{if(e.length>0){const a=j.current,n=M||"",t=a?.selectionStart??n.length,i=a?.selectionEnd??n.length,r=n.slice(0,t)+e[0]+n.slice(i);T(r),setTimeout((()=>{const n=t+e[0].length;a?.focus(),a?.setSelectionRange(n,n)}),0)}},placeholder:"Add merge field",title:"Merge Fields",searchPlaceholder:"Search merge fields...",emptyMessage:"No merge fields found",singleSelect:!0}),n.jsx(Mae,{title:"Dynamic content is a way to insert dynamic content into your messages such as the customer's name, email, or other details."})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{type:"file",ref:L,onChange:async e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{try{const a=await async function(e){if(!Loe)throw new Error("Image conversion is only supported in browser environments");return new Promise(((a,n)=>{try{const t=new window.Image;t.crossOrigin="anonymous",t.onload=()=>{try{const e=document.createElement("canvas");e.width=t.naturalWidth,e.height=t.naturalHeight;const i=e.getContext("2d");if(!i)return void n(new Error("Failed to get canvas context"));i.drawImage(t,0,0);const r=e.toDataURL("image/png",1);a(r)}catch(e){n(e)}},t.onerror=()=>{n(new Error("Failed to load image"))},t.src=e}catch(t){n(t)}}))}(e.result),n=function(e){if(!e.startsWith("data:"))throw new Error('Invalid data URL: must start with "data:"');const a=e.split(",");if(2!==a.length)throw new Error("Invalid data URL format: missing base64 data");if(!a[0].includes(";base64"))throw new Error("Invalid data URL format: missing base64 encoding");return a[1]}(a);_(n),z(a),K(!1)}catch(a){m({title:"Error converting image",description:"Failed to convert image to PNG format",variant:"destructive"})}},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsx(PY,{variant:"outline",onClick:()=>{L.current?.click()},className:"px-4",disabled:w.length>=1||D||null!==R,children:"Add Image"}),n.jsx(PY,{variant:"outline",onClick:()=>{T(S),E(!1),z(w.length>0?w[0]:null),_(null),K(!1)},className:"px-4",children:"Cancel"}),n.jsx(PY,{onClick:()=>{if(M&&M.length>t)return void m({title:"SMS is too long",description:"Please shorten your message"});A(M);const e=s();e&&h({groupId:e,params:{smsChannelSenderId:g,smsMessageBody:M,textMessageCompanyName:k,textMessageMedia:R?[R]:D?[]:void 0}},{onSuccess:()=>{E(!1),z(null),_(null),K(!1)},onError:()=>{m({title:"Error updating SMS",description:"Please contact your administrator"})}})},className:"px-4",disabled:p,children:"Save Changes"})]})]}),n.jsxs("div",{className:"flex justify-end mt-2 text-sm transition-colors duration-300 items-center gap-2 "+(M&&M.length>320?M.length>=t?"text-red-500":"text-amber-500":"text-gray-500"),children:[M?M.length:0,"/",t-(k?.length||0)," characters",M&&M.length>320&&n.jsx(Mae,{title:"The best delivery rates are achieved when the message is 320 characters or less.",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"}})]})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(Kae,{className:"text-foreground",children:"From Number"}),n.jsxs(hie,{onValueChange:e=>{v(e)},value:g??void 0,children:[n.jsx(vie,{children:n.jsx(gie,{placeholder:"Select number",children:g?(O=g,H?.find((e=>e.channelSender.id===O))?.channelSender.channelSenderMetadata.friendlyName??H?.find((e=>e.channelSender.id===O))?.channelSender.channelSenderMetadata.from??O):"Select number"})}),n.jsx(kie,{children:H?.map((e=>n.jsx(bie,{value:e.channelSender.id,children:e.channelSender.channelSenderMetadata.friendlyName??e.channelSender.channelSenderMetadata.from??"Select number"},e.channelSender.id)))})]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-1",children:[n.jsx(Kae,{className:"text-foreground",children:"Company Name"}),n.jsx(Mae,{title:"Adding your company name can help customers identify who they are talking to"})]}),n.jsx(r4,{placeholder:"Enter company name",value:k??"",className:"text-muted-foreground",onChange:e=>{b(e.target.value??null)},disabled:!g&&!o})]})]}),n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex justify-between items-center mb-4",children:[n.jsx("h3",{className:"font-medium",children:"Preview"}),n.jsx("div",{children:n.jsx(PY,{onClick:()=>E(!0),className:"text-sm px-3 py-1 rounded ",disabled:0===(H?.length??0)&&void 0===o,children:"Edit"})})]}),n.jsx("div",{children:o?g||o?n.jsx(n.Fragment,{children:S?n.jsx(oue,{body:rue({companyName:k??void 0,smsBody:S}),imageUrls:w}):n.jsx(Sie,{type:"sms"})}):n.jsx(Cie,{type:"sms"}):n.jsx("div",{children:"Submit an application"})})]})]})]}):n.jsx("div",{children:n.jsx(NY,{text:["Loading..."]})});var O},lue=()=>{const e=wY(),{getMergeFields:a,isGetting:t}=$e(e?.id??void 0);return t||!a?n.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:n.jsx(NY,{text:["Fetching Content..."]})}):n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Bie,{title:"SMS Campaign",type:"sms"}),n.jsx(sue,{mergeFieldsResponse:a})]})},uue=e=>e.friendlyName||e.from||e.messageServiceSid||"Unknown Sender";function cue(e,a,{checkForDefaultPrevented:n=!0}={}){return function(t){if(e?.(t),!1===n||!t.defaultPrevented)return a?.(t)}}function due(e,a=[]){let t=[];const i=()=>{const a=t.map((e=>r.createContext(e)));return function(n){const t=n?.[e]||a;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:t}})),[n,t])}};return i.scopeName=e,[function(a,i){const o=r.createContext(i),s=t.length;t=[...t,i];const l=a=>{const{scope:t,children:i,...l}=a,u=t?.[e]?.[s]||o,c=r.useMemo((()=>l),Object.values(l));return n.jsx(u.Provider,{value:c,children:i})};return l.displayName=a+"Provider",[l,function(n,t){const l=r.useContext(t?.[e]?.[s]||o);if(l)return l;if(void 0!==i)return i;throw new Error(`\`${n}\` must be used within \`${a}\``)}]},mue(i,...a)]}function mue(...e){const a=e[0];if(1===e.length)return a;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const t=n.reduce(((a,{useScope:n,scopeName:t})=>({...a,...n(e)[`__scope${t}`]})),{});return r.useMemo((()=>({[`__scope${a.scopeName}`]:t})),[t])}};return n.scopeName=a.scopeName,n}function hue(e,a){if("function"==typeof e)return e(a);null!=e&&(e.current=a)}function pue(...e){return a=>{let n=!1;const t=e.map((e=>{const t=hue(e,a);return n||"function"!=typeof t||(n=!0),t}));if(n)return()=>{for(let a=0;a<t.length;a++){const n=t[a];"function"==typeof n?n():hue(e[a],null)}}}}function gue(...e){return r.useCallback(pue(...e),e)}function vue(e){const a=fue(e),t=r.forwardRef(((e,t)=>{const{children:i,...o}=e,s=r.Children.toArray(i),l=s.find(kue);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 n.jsx(a,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,i):null})}return n.jsx(a,{...o,ref:t,children:i})}));return t.displayName=`${e}.Slot`,t}function fue(e){const a=r.forwardRef(((e,a)=>{const{children:n,...t}=e;if(r.isValidElement(n)){const e=function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,a){const n={...a};for(const t in a){const i=e[t],r=a[t];/^on[A-Z]/.test(t)?i&&r?n[t]=(...e)=>{r(...e),i(...e)}:i&&(n[t]=i):"style"===t?n[t]={...i,...r}:"className"===t&&(n[t]=[i,r].filter(Boolean).join(" "))}return{...e,...n}}(t,n.props);return n.type!==r.Fragment&&(i.ref=a?pue(a,e):e),r.cloneElement(n,i)}return r.Children.count(n)>1?r.Children.only(null):null}));return a.displayName=`${e}.SlotClone`,a}var yue=Symbol("radix.slottable");function kue(e){return r.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===yue}var bue=globalThis?.document?r.useLayoutEffect:()=>{},Sue=r[" useId ".trim().toString()]||(()=>{}),Aue=0;function wue(e){const[a,n]=r.useState(Sue());return bue((()=>{n((e=>e??String(Aue++)))}),[e]),e||(a?`radix-${a}`:"")}var Cue=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce(((e,a)=>{const t=vue(`Primitive.${a}`),i=r.forwardRef(((e,i)=>{const{asChild:r,...o}=e,s=r?t:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),n.jsx(s,{...o,ref:i})}));return i.displayName=`Primitive.${a}`,{...e,[a]:i}}),{});var Mue=r[" useInsertionEffect ".trim().toString()]||bue;function Tue({prop:e,defaultProp:a,onChange:n=()=>{},caller:t}){const[i,o,s]=function({defaultProp:e,onChange:a}){const[n,t]=r.useState(e),i=r.useRef(n),o=r.useRef(a);return Mue((()=>{o.current=a}),[a]),r.useEffect((()=>{i.current!==n&&(o.current?.(n),i.current=n)}),[n,i]),[n,t,o]}({defaultProp:a,onChange:n}),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,t])}const c=r.useCallback((a=>{if(l){const n=function(e){return"function"==typeof e}(a)?a(e):a;n!==e&&s.current?.(n)}else o(a)}),[l,e,o,s]);return[u,c]}var Nue=r.createContext(void 0);function Eue(e){const a=r.useContext(Nue);return e||a||"ltr"}var xue="rovingFocusGroup.onEntryFocus",Pue={bubbles:!1,cancelable:!0},jue="RovingFocusGroup",[Lue,Bue,zue]=function(e){const t=e+"CollectionProvider",[i,r]=due(t),[o,s]=i(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:i}=e,r=a.useRef(null),s=a.useRef(new Map).current;return n.jsx(o,{scope:t,itemMap:s,collectionRef:r,children:i})};l.displayName=t;const u=e+"CollectionSlot",c=vue(u),d=a.forwardRef(((e,a)=>{const{scope:t,children:i}=e,r=gue(a,s(u,t).collectionRef);return n.jsx(c,{ref:r,children:i})}));d.displayName=u;const m=e+"CollectionItemSlot",h="data-radix-collection-item",p=vue(m),g=a.forwardRef(((e,t)=>{const{scope:i,children:r,...o}=e,l=a.useRef(null),u=gue(t,l),c=s(m,i);return a.useEffect((()=>(c.itemMap.set(l,{ref:l,...o}),()=>{c.itemMap.delete(l)}))),n.jsx(p,{[h]:"",ref:u,children:r})}));return g.displayName=m,[{Provider:l,Slot:d,ItemSlot:g},function(n){const t=s(e+"CollectionConsumer",n);return a.useCallback((()=>{const e=t.collectionRef.current;if(!e)return[];const a=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(t.itemMap.values()).sort(((e,n)=>a.indexOf(e.ref.current)-a.indexOf(n.ref.current)))}),[t.collectionRef,t.itemMap])},r]}(jue),[Rue,_ue]=due(jue,[zue]),[Due,Kue]=Rue(jue),Hue=r.forwardRef(((e,a)=>n.jsx(Lue.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Lue.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Oue,{...e,ref:a})})})));Hue.displayName=jue;var Oue=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,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=gue(a,p),v=Eue(s),[f,y]=Tue({prop:l,defaultProp:u??null,onChange:c,caller:jue}),[k,b]=r.useState(!1),S=function(e){const a=r.useRef(e);return r.useEffect((()=>{a.current=e})),r.useMemo((()=>(...e)=>a.current?.(...e)),[])}(d),A=Bue(t),w=r.useRef(!1),[C,M]=r.useState(0);return r.useEffect((()=>{const e=p.current;if(e)return e.addEventListener(xue,S),()=>e.removeEventListener(xue,S)}),[S]),n.jsx(Due,{scope:t,orientation:i,dir:v,loop:o,currentTabStopId:f,onItemFocus:r.useCallback((e=>y(e)),[y]),onItemShiftTab:r.useCallback((()=>b(!0)),[]),onFocusableItemAdd:r.useCallback((()=>M((e=>e+1))),[]),onFocusableItemRemove:r.useCallback((()=>M((e=>e-1))),[]),children:n.jsx(Cue.div,{tabIndex:k||0===C?-1:0,"data-orientation":i,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:cue(e.onMouseDown,(()=>{w.current=!0})),onFocus:cue(e.onFocus,(e=>{if(e.target===e.currentTarget&&!w.current&&!k){const a=new CustomEvent(xue,Pue);if(e.currentTarget.dispatchEvent(a),!a.defaultPrevented){const e=A().filter((e=>e.focusable));Fue([e.find((e=>e.active)),e.find((e=>e.id===f)),...e].filter(Boolean).map((e=>e.ref.current)),m)}}w.current=!1})),onBlur:cue(e.onBlur,(()=>b(!1)))})})})),Iue="RovingFocusGroupItem",Gue=r.forwardRef(((e,a)=>{const{__scopeRovingFocusGroup:t,focusable:i=!0,active:o=!1,tabStopId:s,children:l,...u}=e,c=wue(),d=s||c,m=Kue(Iue,t),h=m.currentTabStopId===d,p=Bue(t),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:f}=m;return r.useEffect((()=>{if(i)return g(),()=>v()}),[i,g,v]),n.jsx(Lue.ItemSlot,{scope:t,id:d,focusable:i,active:o,children:n.jsx(Cue.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...u,ref:a,onMouseDown:cue(e.onMouseDown,(e=>{i?m.onItemFocus(d):e.preventDefault()})),onFocus:cue(e.onFocus,(()=>m.onItemFocus(d))),onKeyDown:cue(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void m.onItemShiftTab();if(e.target!==e.currentTarget)return;const a=function(e,a,n){const t=function(e,a){return"rtl"!==a?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===a&&["ArrowLeft","ArrowRight"].includes(t)||"horizontal"===a&&["ArrowUp","ArrowDown"].includes(t)?void 0:Vue[t]}(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?(t=r+1,(n=i).map(((e,a)=>n[(t+a)%n.length]))):i.slice(r+1)}setTimeout((()=>Fue(i)))}var n,t})),children:"function"==typeof l?l({isCurrentTabStop:h,hasTabStop:null!=f}):l})})}));Gue.displayName=Iue;var Vue={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fue(e,a=!1){const n=document.activeElement;for(const t of e){if(t===n)return;if(t.focus({preventScroll:a}),document.activeElement!==n)return}}var Jue=Hue,Uue=Gue;var Wue=e=>{const{present:a,children:n}=e,t=function(e){const[a,n]=r.useState(),t=r.useRef(null),i=r.useRef(e),o=r.useRef("none"),s=e?"mounted":"unmounted",[l,u]=function(e,a){return r.useReducer(((e,n)=>a[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=que(t.current);o.current="mounted"===l?e:"none"}),[l]),bue((()=>{const a=t.current,n=i.current;if(n!==e){const t=o.current,r=que(a);if(e)u("MOUNT");else if("none"===r||"none"===a?.display)u("UNMOUNT");else{u(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,u]),bue((()=>{if(a){let e;const n=a.ownerDocument.defaultView??window,r=r=>{const o=que(t.current).includes(r.animationName);if(r.target===a&&o&&(u("ANIMATION_END"),!i.current)){const t=a.style.animationFillMode;a.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===a.style.animationFillMode&&(a.style.animationFillMode=t)}))}},s=e=>{e.target===a&&(o.current=que(t.current))};return a.addEventListener("animationstart",s),a.addEventListener("animationcancel",r),a.addEventListener("animationend",r),()=>{n.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=>{t.current=e?getComputedStyle(e):null,n(e)}),[])}}(a),i="function"==typeof n?n({present:t.isPresent}):r.Children.only(n),o=gue(t.ref,function(e){let a=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning;if(n)return e.ref;if(a=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=a&&"isReactWarning"in a&&a.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||t.isPresent?r.cloneElement(i,{ref:o}):null};function que(e){return e?.animationName||"none"}Wue.displayName="Presence";var Zue="Tabs",[$ue,Yue]=due(Zue,[_ue]),Que=_ue(),[Xue,ece]=$ue(Zue),ace=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,onValueChange:r,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:u="automatic",...c}=e,d=Eue(l),[m,h]=Tue({prop:i,onChange:r,defaultProp:o??"",caller:Zue});return n.jsx(Xue,{scope:t,baseId:wue(),value:m,onValueChange:h,orientation:s,dir:d,activationMode:u,children:n.jsx(Cue.div,{dir:d,"data-orientation":s,...c,ref:a})})}));ace.displayName=Zue;var nce="TabsList",tce=r.forwardRef(((e,a)=>{const{__scopeTabs:t,loop:i=!0,...r}=e,o=ece(nce,t),s=Que(t);return n.jsx(Jue,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:i,children:n.jsx(Cue.div,{role:"tablist","aria-orientation":o.orientation,...r,ref:a})})}));tce.displayName=nce;var ice="TabsTrigger",rce=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,disabled:r=!1,...o}=e,s=ece(ice,t),l=Que(t),u=lce(s.baseId,i),c=uce(s.baseId,i),d=i===s.value;return n.jsx(Uue,{asChild:!0,...l,focusable:!r,active:d,children:n.jsx(Cue.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:cue(e.onMouseDown,(e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():s.onValueChange(i)})),onKeyDown:cue(e.onKeyDown,(e=>{[" ","Enter"].includes(e.key)&&s.onValueChange(i)})),onFocus:cue(e.onFocus,(()=>{d||r||!("manual"!==s.activationMode)||s.onValueChange(i)}))})})}));rce.displayName=ice;var oce="TabsContent",sce=r.forwardRef(((e,a)=>{const{__scopeTabs:t,value:i,forceMount:o,children:s,...l}=e,u=ece(oce,t),c=lce(u.baseId,i),d=uce(u.baseId,i),m=i===u.value,h=r.useRef(m);return r.useEffect((()=>{const e=requestAnimationFrame((()=>h.current=!1));return()=>cancelAnimationFrame(e)}),[]),n.jsx(Wue,{present:o||m,children:({present:t})=>n.jsx(Cue.div,{"data-state":m?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":c,hidden:!t,id:d,tabIndex:0,...l,ref:a,style:{...e.style,animationDuration:h.current?"0s":void 0},children:t&&s})})}));function lce(e,a){return`${e}-trigger-${a}`}function uce(e,a){return`${e}-content-${a}`}sce.displayName=oce;var cce=tce,dce=rce,mce=sce;const hce=ace,pce=r.forwardRef((({className:e,...a},t)=>n.jsx(cce,{ref:t,className:pm("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...a})));pce.displayName=cce.displayName;const gce=r.forwardRef((({className:e,...a},t)=>n.jsx(dce,{ref:t,className:pm("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})));gce.displayName=dce.displayName;const vce=r.forwardRef((({className:e,...a},t)=>n.jsx(mce,{ref:t,className:pm("ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a})));vce.displayName=mce.displayName;const fce=({onOpenChange:e})=>n.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:n.jsx(zY.CloseButton,{className:"w-5 h-5 text-primary group-hover:text-primary-foreground group-active:text-primary-foreground transition-colors duration-200"})}),yce=({selectedChannels:e,setSelectedChannels:a,hasEmailChannelSenders:t,hasSmsChannelSenders:i,automationType:r})=>{const{toast:o}=Ie(),s=[...t?[{label:"Email",value:"email",icon:zY.EmailIcon,checked:e.includes("email")}]:[],...i?[{label:"SMS",value:"sms",icon:zY.SmsIcon,checked:e.includes("sms")}]:[]];return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-xl font-medium text-foreground",children:"Message Types"}),n.jsxs("p",{className:"text-muted-foreground mb-2 text-sm",children:["Select the channels you want to use in this"," ",r===oa.ONE_TIME?Eh("engage:broadcast").toLowerCase():Eh("engage:automation").toLowerCase()]})]}),n.jsx("div",{className:"w-full grid grid-cols-2 gap-3",children:s.map((t=>n.jsxs(Joe,{checked:t.checked,onCheckedChange:()=>{"email"===t.value?e.includes("email")?e.includes("sms")?a(["sms"]):o({title:"Cant Remove Email",description:`At least one channel is required for an ${r===oa.ONE_TIME?Eh("engage:broadcast").toLowerCase():Eh("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===oa.ONE_TIME?Eh("engage:broadcast").toLowerCase():Eh("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:[n.jsx(t.icon,{className:"mb-3",size:20}),n.jsx("span",{className:"font-medium tracking-tight",children:t.label}),n.jsx(Uoe,{className:"absolute top-2 right-2",children:n.jsx(_c,{className:"fill-primary text-primary-foreground"})})]},t.value)))})]})},kce=({getExtraMergeFields:e})=>{const[t,i]=a.useState(null),r=a.useRef(null),{toast:o}=Ie(),s=wY(),{channelSenders:l}=E9(),{channelAccounts:u}=M9(),{updateCommunicationGroup:c}=Ze(),d=AY(),{data:m}=L9(),{setSelectedSubStepType:h}=a.useContext(uY),{getMergeFields:p,isGetting:g}=$e(s?.id??void 0),[v,f]=a.useState(void 0);a.useEffect((()=>{const e=s?.id;e&&t&&(t.includes("email")||null===s?.emailChannelSenderId||c({groupId:e,params:{emailChannelSenderId:null}}),t.includes("sms")||null===s?.smsChannelSenderId||c({groupId:e,params:{smsChannelSenderId:null}}),1===t.length&&("email"===t[0]&&h(Lie.EMAIL),"sms"===t[0]&&h(Lie.SMS)))}),[t,c,s,m,h]),a.useEffect((()=>{const e=s?.id;e||0!==t?.length||i(["email"])}),[d,s,t]);const y=a.useCallback((e=>{const a=[];e.emailChannelSenderId&&a.push("email"),e.smsChannelSenderId&&a.push("sms"),0===a.length&&a.push("email"),i(a)}),[]);a.useEffect((()=>{s&&!t&&y(s)}),[s,y,t]),a.useEffect((()=>{g||void 0===v&&(e?e().then((e=>{s?.id&&(y(s),c({groupId:s?.id,params:{extraMergeFields:e}},{onSuccess:async()=>{try{const e=await Ve(s?.id);f(e)}catch{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}},onError:e=>{o({title:"Error saving merge fields!",description:"Please contact your administrator if this issue persists.",variant:"destructive"})}}))})):f(p))}),[e,c,s,o,g,p,v,y]);const k=a.useMemo((()=>zie({channelSenders:l?.results??[],channelAccounts:u?.results??[]})),[l?.results,u?.results]),b=a.useMemo((()=>mee({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:m})),[l?.results,u?.results,m]);if(!t||g||!v||!k||!b)return n.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:n.jsx(NY,{text:["Fetching Content..."]})});const S=k.length>0,A=b.length>0;return n.jsxs("div",{className:"flex flex-col gap-4 flex-shrink-0",children:[n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(yce,{automationType:d?.triggerMetadata?.triggerType,selectedChannels:t,setSelectedChannels:i,hasEmailChannelSenders:S,hasSmsChannelSenders:A})}),t.includes("email")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",ref:r,children:[n.jsx(Bie,{title:"Email Campaign",type:"email"}),n.jsx(xie,{mergeFieldsResponse:v,emailChannelSendersWithChannelAccounts:k})]}),t.includes("sms")&&n.jsxs("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:[n.jsx(Bie,{title:"SMS Campaign",type:"sms"}),n.jsx(sue,{mergeFieldsResponse:v})]})]})},bce=({open:e,onOpenChange:a})=>n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"max-w-[75vw] min-h-[75vh] overflow-y-auto max-h-[90vh] po",hideCloseButton:!0,children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Edit Campaign Content"}),n.jsx(YG,{children:"Edit the content of the campaign"})]}),n.jsx(fce,{onOpenChange:a}),n.jsx(kce,{})]})}),Sce=()=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"}),n.jsx("span",{className:"w-3 h-3 rounded-full bg-zinc-300 border border-zinc-300 shadow-sm"})]}),Ace=({children:e,actionButtons:a})=>n.jsxs("div",{className:"flex-1 w-full relative overflow-hidden max-w-screen-lg mx-auto",children:[n.jsxs("div",{className:"h-full relative w-full rounded-2xl bg-white border border-zinc-200 overflow-hidden min-h-[500px] flex flex-col",style:{containerType:"inline-size"},children:[n.jsxs("div",{className:"flex items-center space-x-3 pt-3 px-4 z-10 w-full justify-between",children:[n.jsx(Sce,{}),a&&n.jsx("div",{className:"flex items-center space-x-2",children:a})]}),e]}),n.jsx("div",{className:"text-center text-sm text-muted-foreground mt-4",children:n.jsx("p",{children:"These previews show exactly how your messages will appear to your customers"})})]}),wce=()=>{const e=AY(),t=wY(),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),o=a.useMemo((()=>i?.results?.filter((e=>e.channelSenderMetadata.userPart))?.flatMap((e=>{const a=r?.results?.find((a=>a.id===e.channelAccountId));return a&&a.channelAccountMetadata.type===T9.REACH_MANAGED?[{channelSenderId:e.id,fullDomain:`${e.channelSenderMetadata.userPart}@${e.channelSenderMetadata.baseDomain}`,channelSenderMetadata:e.channelSenderMetadata}]:[]}))||[]),[i?.results,r?.results]),s=t?.emailChannelSenderId;if(!(e&&t&&o&&s))return null;const l=o.find((e=>e.channelSenderId===s)),u=l?.fullDomain,c=l?.channelSenderMetadata.emailReplyTo,d=t.emailSubject,m=t.emailPreviewText,h=l?.channelSenderMetadata.emailFromName;return n.jsxs("div",{className:"space-y-1 overflow-hidden",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsxs("div",{className:"text-base font-medium",children:[u,h&&n.jsxs("span",{className:"text-muted-foreground",children:["<",h,">"]})]})]}),c&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Reply-To"}),n.jsx("div",{className:"text-base font-medium",children:c})]}),d&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Subject"}),n.jsx("div",{className:"text-base font-medium",children:d})]}),m&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"Preview Text"}),n.jsx("div",{className:"text-sm font-medium line-clamp-2",children:m})]})]})},Cce=({emailBody:e})=>{const[t,i]=a.useState({width:0,height:0}),r=a.useRef(null);return a.useEffect((()=>{const e=()=>{r.current&&requestAnimationFrame((()=>{i({width:r.current?r.current.offsetWidth-75:0,height:r.current?r.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[r]),n.jsxs(Ace,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(wce,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",ref:r,children:n.jsx(Aie,{html:e,height:t.height,width:t.width})})]})},Mce=({expandDialogContent:e})=>{const[t,i]=a.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(VG,{open:t,onOpenChange:i,children:n.jsxs(WG,{hideCloseButton:!0,className:"w-[80vw] h-[80vh] max-h-none bg-transparent border-none max-w-screen-lg ",children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Expanded Preview"}),n.jsx(YG,{children:"Expanded view of communication content"})]}),n.jsxs("div",{className:"h-full flex flex-col overflow-hidden rounded-xl",children:[n.jsx(fce,{onOpenChange:i}),e]})]})}),n.jsx(PY,{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:()=>i(!0),children:n.jsx(zY.ExpandIcon,{className:"w-4 h-4 text-muted-foreground"})})]})},Tce=({type:e,disablePreviewSubtext:a=!1})=>{const t="sms"===e?"SMS":"Email";return n.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center",children:n.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:[n.jsx("sms"===e?zY.SmsIcon:zY.EmailIcon,{className:"w-12 h-12 text-zinc-500 mb-4"}),n.jsxs("h2",{className:"text-xl font-semibold text-zinc-800 mb-2",children:["No ",t," Content Yet"]}),!a&&n.jsxs("p",{className:"text-zinc-500 text-base mb-1",children:["Click"," ",n.jsx("span",{className:"font-medium text-zinc-700",children:"Edit content"})," to start crafting your ",t," message."]})]})})},Nce=a.forwardRef((({onClick:e},a)=>n.jsxs(PY,{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:[n.jsx(zY.PreviewButton,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium text-sm",children:"Test"})]})));Nce.displayName="PreviewButton";const Ece=e=>/^[^\s@.]+(?:\.[^\s@.]+)*@[^\s@.]+(?:\.[^\s@.]+)+$/.test(e),xce=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"))},Pce=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 n=e.startsWith("+")?"+":"",t=a.slice((e.startsWith("+"),0));return`${n}${t.match(/.{1,4}/g)?.join("-")||t}`}return e},jce=({automation:e,type:t,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(""),[v,f]=a.useState(!1),{sendTestCommunication:y,sendError:k,isSendSuccess:b}=Ye(),{toast:S}=Ie(),A=e.actionData?.find((e=>"send_communication"===e.actionType)),w=A?.actionMetadata.communicationGroupId,{communicationGroup:C,isGetting:M}=qe(w??void 0),{data:T}=gY({includeSegments:e.includeSegmentIds,excludeSegments:e.excludeSegmentIds,automationId:e.id}),N=a.useRef(null),E=a.useMemo((()=>[...T?.recipients??[]].filter((e=>!(!e.firstName||!e.lastName)&&(!("email"===t&&!e.email)&&!("sms"===t&&!e.phone))))),[T?.recipients,t]),x=a.useCallback((()=>{if(!w)return Promise.resolve(null);if(!C)return Promise.reject(new Error("Communication group not loaded"));switch(t){case"email":return Promise.resolve(C.emailChannelSenderId);case"sms":return Promise.resolve(C.smsChannelSenderId);default:return Promise.reject(new Error(`Unsupported type: ${t}`))}}),[C,t,w]);a.useEffect((()=>{(async()=>{try{const e=await x();d(e)}catch(e){d(null)}finally{h(!0)}})()}),[x]),a.useEffect((()=>{b&&(S({title:"Success",description:`Preview ${"email"===t?"email":"SMS"} sent successfully!`}),i(!1))}),[b,t,i,S]),a.useEffect((()=>{k&&(S({title:"Error",description:`Failed to send preview: ${k.message}`,variant:"destructive"}),i(!1))}),[k,S,i]),a.useEffect((()=>{r&&(s(""),u(""),g(""),f(!1))}),[r]),a.useEffect((()=>{!r&&v&&setTimeout((()=>{document.body.style.pointerEvents=""}),0)}),[r,v]);return m&&!M&&T?c?n.jsxs("div",{className:"",ref:N,children:[n.jsxs("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:["Send Test ","email"===t?"Email":"Text"]}),n.jsx(r4,{type:"email"===t?"email":"tel",placeholder:"email"===t?"Enter email address":"Enter phone number",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"}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1.5",children:["Enter a valid ","email"===t?"email address":"phone number"," to send a test to that recipient."]}),n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(hie,{value:p,onValueChange:e=>{g(e)},onOpenChange:e=>{f(e),!e&&N.current&&N.current.focus()},children:[n.jsx(vie,{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:n.jsx(gie,{children:p?T?.recipients.find((e=>e.id===p))?.firstName+" "+T?.recipients.find((e=>e.id===p))?.lastName:"Preview as"})}),n.jsx(kie,{position:"popper",className:"z-[100]",children:n.jsx(pie,{children:E.map((e=>n.jsx(bie,{value:e.id,className:"cursor-pointer hover:bg-gray-50",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("span",{className:"font-medium",children:[e.firstName," ",e.lastName]}),n.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&&n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>g(""),className:"h-10 w-10 rounded-lg hover:bg-gray-100",title:"Clear selection",children:n.jsx(zY.CloseButton,{className:"h-4 w-4 text-gray-500"})})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1.5",children:"Optional: Test as a specific recipient to see how the message will appear with their data. If not selected, raw merge tags will be used."})]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"my-4 border-t border-gray-200"}),n.jsx("p",{className:"text-red-500 text-sm mb-4 -mt-2",children:l})]}),n.jsx(PY,{onClick:()=>{if(!("email"===t?Ece(o):xce(o)))return void u("Please enter a valid "+("email"===t?"email address":"phone number"));if(!c)return void u("No sender found, please update the automation first!");const a=e.actionData?.find((e=>"send_communication"===e.actionType)),n=a?.actionMetadata.communicationGroupId;if(!n)return Promise.resolve(null);y({id:n,params:"email"===t?{emailAddress:o,previewAsRecipientId:p}:{phoneNumber:o,previewAsRecipientId:p}})},disabled:!o,className:"w-full disabled:cursor-not-allowed",children:"Send Test"})]}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsxs("div",{className:"text-center flex flex-col justify-center items-center gap-2",children:[n.jsx(zY.AlertCircleIcon,{className:"h-12 w-12 text-gray-400 mb-4"}),n.jsx("h3",{className:"text-lg font-semibold text-gray-700 mb-2",children:"No sender found"}),n.jsx("p",{className:"text-gray-500",children:"Please update the automation to include a sender for this type"})]})}):n.jsx("div",{className:"flex justify-center items-center h-full",children:n.jsx(NY,{text:["Fetching sender data","Fetching recipients"]})})},Lce=({open:e,onOpenChange:a,automation:t})=>n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Send Preview Email"}),n.jsx(YG,{children:"Send a preview email to the automation."})]}),n.jsx(jce,{automation:t,type:"email",setOpenSendPreviewPopup:a,open:e})]})}),Bce=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const r=AY(),o=wY(),{channelSenders:s}=E9(),{channelAccounts:l}=M9(),[u,c]=a.useState({width:0,height:0}),[d,m]=a.useState(!1),[h,p]=a.useState(!1),g=a.useRef(null);if(a.useEffect((()=>{const e=()=>{g.current&&requestAnimationFrame((()=>{c({width:g.current?g.current.offsetWidth-75:0,height:g.current?g.current.offsetHeight-75:0})}))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[g]),!r||!o||void 0===s||void 0===l)return null;const v=o?.emailHtmlBody||"",f=o?.emailChannelSenderId&&v.length>0,y=zie({channelSenders:s?.results??[],channelAccounts:l?.results??[]});let k=null;return o?.emailChannelSenderId||(k="Please first select an email sender"),o?.emailSubject||(k="Please first ensure you have an email subject"),o?.emailHtmlBody||(k="Please first ensure you have an email content"),n.jsxs("div",{className:"flex-1 flex flex-col items-center w-full",children:[n.jsx(bce,{open:h,onOpenChange:p}),y.length>0&&n.jsx(Lce,{open:d,onOpenChange:m,automation:r}),n.jsx(Ace,{actionButtons:n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex items-center space-x-2",children:[!e&&f&&(k?n.jsx(Mae,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!0,children:n.jsx(Nce,{onClick:()=>m(!0)})}):n.jsx(Nce,{onClick:()=>m(!0)})),!t&&r.status===ca.DRAFT&&n.jsx(PY,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>p(!0),children:"Edit content"}),f&&n.jsx(Mce,{expandDialogContent:n.jsx(Cce,{emailBody:v})})]})}),children:f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(wce,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full min-h-[500px]",ref:g,children:n.jsx(Aie,{html:v,height:u.height,width:u.width})})]}):n.jsx(Tce,{type:"email",disablePreviewSubtext:i})})]})},zce=()=>{const e=AY(),t=wY(),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),{data:o}=L9(),s=a.useMemo((()=>mee({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o})),[i?.results,r?.results,o]),l=s?.find((e=>e.channelSender.id===t?.smsChannelSenderId));if(!l&&!o)return null;if(!(e&&t&&i&&r&&s&&(void 0!==o||l)))return null;const u=l?.channelSender.channelSenderMetadata.from&&null!==l.channelSender.channelSenderMetadata.from?l.channelSender.channelSenderMetadata.from:null,c=l?.channelSender.channelSenderMetadata.friendlyName??(u&&null!==u?Pce(u??""):l?.channelSender.channelSenderMetadata.messageServiceSid);return n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground leading-none",children:"From"}),n.jsx("div",{className:"text-base font-medium font-mono text-zinc-800",children:c})]})})},Rce=({smsBody:e,imageUrls:a})=>n.jsxs(Ace,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(zce,{})})}),n.jsx("div",{className:"rounded-lg p-6 bg-white flex-1 min-h-0 flex items-center justify-center",children:n.jsx(oue,{body:e,imageUrls:a})})]}),_ce=({open:e,onOpenChange:a,automation:t})=>n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Send Preview SMS"}),n.jsx(YG,{children:"Send a preview SMS to the automation."})]}),n.jsx(jce,{automation:t,type:"sms",setOpenSendPreviewPopup:a,open:e})]})}),Dce=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,setupRequired:r=!1})=>{const[o,s]=a.useState(!1),{channelSenders:l}=E9(),{channelAccounts:u}=M9(),c=AY(),d=wY(),[m,h]=a.useState(!1),{data:p}=L9(),[g,v]=a.useState(r),f=mee({channelSenders:l?.results??[],channelAccounts:u?.results??[],smsApplication:p}),y=f.find((e=>e.channelSender.id===d?.smsChannelSenderId));if(a.useEffect((()=>{y&&y.smsApplication&&y.smsApplication.status===dee.PENDING&&v(!1)}),[d?.smsChannelSenderId,p,f,y]),!c||void 0===l)return null;const k=d?.smsMessageBody||"",b=!y?.smsApplication||y.smsApplication.status===dee.APPROVED,S=(p||d?.smsChannelSenderId)&&k.length>0,A=rue({companyName:d?.textMessageCompanyName??void 0,smsBody:k}),w=d?.textMessageMediaUrls??[];let C=null;return d?.smsChannelSenderId||(C="Please first select a sms sender"),d?.smsMessageBody||(C="Please first ensure you have a sms content"),n.jsx(dV,{children:g?n.jsx("div",{className:"w-full pt-8 mx-auto",children:n.jsx(Noe,{})}):n.jsxs(Z$.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 flex-col items-center w-full h-full",children:[n.jsx(bce,{open:m,onOpenChange:h}),n.jsx(_ce,{open:o,onOpenChange:s,automation:c}),n.jsx(Ace,{actionButtons:n.jsxs(n.Fragment,{children:[!e&&b&&(C?n.jsx(Mae,{alertText:"Unable to send preview",title:"There was an error preparing the preview. Please check your automation configuration.",className:"inline-block",asChild:!1,children:n.jsx("div",{className:"inline-block",children:n.jsx(Nce,{onClick:()=>s(!0)})})}):n.jsx(Nce,{onClick:()=>s(!0)})),c.status===ca.DRAFT&&!t&&n.jsx(PY,{variant:"outline",size:"sm",className:"rounded-lg px-3 py-2 font-medium text-sm shadow-sm bg-white/80 hover:bg-zinc-100 border border-zinc-200",onClick:()=>h(!0),children:"Edit content"}),S&&n.jsx(Mce,{expandDialogContent:n.jsx(Rce,{smsBody:A,imageUrls:w})})]}),children:S?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pt-4 pb-2 px-6 flex flex-col gap-1",children:n.jsx("div",{className:"rounded-xl bg-zinc-50/80 shadow-sm border border-zinc-100 p-4",children:n.jsx(zce,{})})}),n.jsx("div",{className:"w-full h-[1.5px] bg-zinc-200 my-2"}),n.jsx("div",{className:"flex-1 w-full overflow-auto h-full flex items-center justify-center",children:n.jsx(oue,{body:A,imageUrls:w})})]}):n.jsx(Tce,{type:"sms",disablePreviewSubtext:i})})]})})},Kce=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1})=>{const[r,o]=a.useState(null),s=wY(),{channelAccounts:l}=M9(),{state:{hideSms:u}}=a.useContext(bO),{channelSenders:c}=E9(),{data:d}=L9(),m=a.useMemo((()=>mee({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 n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(NY,{text:["Loading..."]})});const h=!s?.smsChannelSenderId||u,p=!s?.emailChannelSenderId,g=0===m.length&&!d;return n.jsxs(hce,{defaultValue:"email",value:r,onValueChange:e=>o("email"===e?"email":"sms"),className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md pb-4",children:[n.jsx("div",{className:"max-w-[640px] mx-auto w-full",children:n.jsxs(pce,{className:"grid w-full "+(h||p?"grid-cols-1":"grid-cols-2"),children:[!p&&n.jsx(gce,{value:"email",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx(zY.EmailIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(zY.EmailIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"Email"})]})}),!h&&n.jsx(gce,{value:"sms",className:"group data-[state=active]:bg-white",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(zY.SmsIcon,{className:"w-4 h-4 mr-2 hidden group-data-[state=active]:block text-primary"}),n.jsx(zY.SmsIcon,{className:"w-4 h-4 mr-2 block group-data-[state=active]:hidden text-gray-400"}),n.jsx("span",{children:"SMS"}),g&&n.jsx(Mae,{title:"To enable SMS, please complete your business information and request approval from Twilio"})]})})]})}),n.jsx(vce,{value:"email",children:n.jsx(Bce,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i})}),n.jsx(vce,{value:"sms",children:n.jsx(Dce,{disablePreview:e,disableEditContent:t,disablePreviewSubtext:i,setupRequired:g})})]})},Hce="reach-styles-module__h2___J-48W",Oce="reach-styles-module__h3___QiFj-",Ice="reach-styles-module__minorText___1TEN6",Gce=({children:e,className:a})=>n.jsx("h2",{className:pm(Hce,a),children:e}),Vce=({children:e,className:a})=>n.jsx("h3",{className:pm(Oce,a),children:e}),Fce=({children:e,className:a})=>n.jsx("p",{className:pm(Ice,a),children:e}),Jce=({title:e,children:a,headerActions:t})=>n.jsxs("div",{className:"max-w-[1000px] mx-auto w-full flex-1 flex flex-col gap-4 pt-4",children:[n.jsxs("div",{className:"px-4 flex",children:[n.jsx(Gce,{className:"text-primary",children:e}),t&&n.jsx("div",{className:"ml-auto",children:t})]}),a]}),Uce=()=>n.jsx(Jce,{title:"Preview & Schedule",children:n.jsx(Kce,{disablePreview:!0,disableEditContent:!0,disablePreviewSubtext:!0})}),Wce=()=>{const e=AY(),t=wY(),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),{data:o}=L9(),[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(t&&d&&h){const e=t.emailChannelSenderId,a=t.smsChannelSenderId,n=d.results.find((a=>a.id===e)),i=d.results.find((e=>e.id===a));if(n&&t.emailSubject&&t.emailHtmlBody){const e=n.channelSenderMetadata?.userPart,a=h.results.find((e=>e.id===n.channelAccountId));if(a)switch(a.channelAccountMetadata.type){case T9.REACH_MANAGED:l({fromEmail:`${e}@${a.channelAccountMetadata.baseDomain}.embedreach.com`,fromName:n.channelSenderMetadata?.emailFromName,subject:t.emailSubject,previewText:t.emailPreviewText,body:t.emailHtmlBody});break;case T9.TWILLIO:break;default:throw g9(a.channelAccountMetadata.type,T9)}}(o||i)&&t.smsMessageBody&&c({fromPhone:i?uue(i.channelSenderMetadata):"",body:t.smsMessageBody,companyName:t.textMessageCompanyName})}}),[t,d,h,o]),e?n.jsx("div",s||u?{className:"w-full",children:n.jsx("div",{className:"flex flex-col gap-4 w-full",children:n.jsx(Uce,{})})}:{className:"flex justify-center items-center h-full",children:n.jsx("div",{children:"No preview data Please complete previous steps"})}):n.jsx(NY,{text:["Loading..."]})};function qce(e){return(qce="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 Zce(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 $ce(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function Yce(e){$ce(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||"object"===qce(e)&&"[object Date]"===a?new Date(e.getTime()):"number"==typeof e||"[object Number]"===a?new Date(e):new Date(NaN)}function Qce(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a);return isNaN(t)?new Date(NaN):t?(n.setDate(n.getDate()+t),n):n}function Xce(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a);if(isNaN(t))return new Date(NaN);if(!t)return n;var i=n.getDate(),r=new Date(n.getTime());return r.setMonth(n.getMonth()+t+1,0),i>=r.getDate()?r:(n.setFullYear(r.getFullYear(),r.getMonth(),i),n)}var ede={};function ade(){return ede}function nde(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Yce(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 tde(e){return $ce(1,arguments),nde(e,{weekStartsOn:1})}function ide(e){$ce(1,arguments);var a=function(e){$ce(1,arguments);var a=Yce(e),n=a.getFullYear(),t=new Date(0);t.setFullYear(n+1,0,4),t.setHours(0,0,0,0);var i=tde(t),r=new Date(0);r.setFullYear(n,0,4),r.setHours(0,0,0,0);var o=tde(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}(e),n=new Date(0);return n.setFullYear(a,0,4),n.setHours(0,0,0,0),tde(n)}function rde(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 ode(e){$ce(1,arguments);var a=Yce(e);return a.setHours(0,0,0,0),a}function sde(e,a){$ce(2,arguments);var n=ode(e),t=ode(a),i=n.getTime()-rde(n),r=t.getTime()-rde(t);return Math.round((i-r)/864e5)}function lde(e,a){return $ce(2,arguments),Qce(e,7*Zce(a))}function ude(e,a){return $ce(2,arguments),Xce(e,12*Zce(a))}function cde(e,a){$ce(2,arguments);var n=ode(e),t=ode(a);return n.getTime()===t.getTime()}function dde(e){return $ce(1,arguments),e instanceof Date||"object"===qce(e)&&"[object Date]"===Object.prototype.toString.call(e)}function mde(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return 12*(n.getFullYear()-t.getFullYear())+(n.getMonth()-t.getMonth())}function hde(e){$ce(1,arguments);var a=Yce(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(23,59,59,999),a}function pde(e){$ce(1,arguments);var a=Yce(e);return a.setDate(1),a.setHours(0,0,0,0),a}function gde(e){$ce(1,arguments);var a=Yce(e),n=new Date(0);return n.setFullYear(a.getFullYear(),0,1),n.setHours(0,0,0,0),n}function vde(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Yce(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 fde(e){return $ce(1,arguments),vde(e,{weekStartsOn:1})}function yde(e,a){return $ce(2,arguments),function(e,a){$ce(2,arguments);var n=Yce(e).getTime(),t=Zce(a);return new Date(n+t)}(e,-Zce(a))}function kde(e){$ce(1,arguments);var a=Yce(e),n=a.getUTCDay(),t=(n<1?7:0)+n-1;return a.setUTCDate(a.getUTCDate()-t),a.setUTCHours(0,0,0,0),a}function bde(e){$ce(1,arguments);var a=Yce(e),n=a.getUTCFullYear(),t=new Date(0);t.setUTCFullYear(n+1,0,4),t.setUTCHours(0,0,0,0);var i=kde(t),r=new Date(0);r.setUTCFullYear(n,0,4),r.setUTCHours(0,0,0,0);var o=kde(r);return a.getTime()>=i.getTime()?n+1:a.getTime()>=o.getTime()?n:n-1}function Sde(e){$ce(1,arguments);var a=Yce(e),n=kde(a).getTime()-function(e){$ce(1,arguments);var a=bde(e),n=new Date(0);return n.setUTCFullYear(a,0,4),n.setUTCHours(0,0,0,0),kde(n)}(a).getTime();return Math.round(n/6048e5)+1}function Ade(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.weekStartsOn)&&void 0!==n?n:0);if(!(d>=0&&d<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var m=Yce(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 wde(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=Yce(e),d=c.getUTCFullYear(),m=ade(),h=Zce(null!==(n=null!==(t=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!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n: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=Ade(p,a),v=new Date(0);v.setUTCFullYear(d,0,h),v.setUTCHours(0,0,0,0);var f=Ade(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}function Cde(e,a){$ce(1,arguments);var n=Yce(e),t=Ade(n,a).getTime()-function(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=wde(e,a),h=new Date(0);return h.setUTCFullYear(m,0,d),h.setUTCHours(0,0,0,0),Ade(h,a)}(n,a).getTime();return Math.round(t/6048e5)+1}function Mde(e,a){for(var n=e<0?"-":"",t=Math.abs(e).toString();t.length<a;)t="0"+t;return n+t}var Tde=function(e,a){var n=e.getUTCFullYear(),t=n>0?n:1-n;return Mde("yy"===a?t%100:t,a.length)},Nde=function(e,a){var n=e.getUTCMonth();return"M"===a?String(n+1):Mde(n+1,2)},Ede=function(e,a){return Mde(e.getUTCDate(),a.length)},xde=function(e,a){return Mde(e.getUTCHours()%12||12,a.length)},Pde=function(e,a){return Mde(e.getUTCHours(),a.length)},jde=function(e,a){return Mde(e.getUTCMinutes(),a.length)},Lde=function(e,a){return Mde(e.getUTCSeconds(),a.length)},Bde=function(e,a){var n=a.length,t=e.getUTCMilliseconds();return Mde(Math.floor(t*Math.pow(10,n-3)),a.length)},zde="midnight",Rde="noon",_de="morning",Dde="afternoon",Kde="evening",Hde="night",Ode={G:function(e,a,n){var t=e.getUTCFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return n.era(t,{width:"abbreviated"});case"GGGGG":return n.era(t,{width:"narrow"});default:return n.era(t,{width:"wide"})}},y:function(e,a,n){if("yo"===a){var t=e.getUTCFullYear();return n.ordinalNumber(t>0?t:1-t,{unit:"year"})}return Tde(e,a)},Y:function(e,a,n,t){var i=wde(e,t),r=i>0?i:1-i;return"YY"===a?Mde(r%100,2):"Yo"===a?n.ordinalNumber(r,{unit:"year"}):Mde(r,a.length)},R:function(e,a){return Mde(bde(e),a.length)},u:function(e,a){return Mde(e.getUTCFullYear(),a.length)},Q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"Q":return String(t);case"QQ":return Mde(t,2);case"Qo":return n.ordinalNumber(t,{unit:"quarter"});case"QQQ":return n.quarter(t,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(t,{width:"narrow",context:"formatting"});default:return n.quarter(t,{width:"wide",context:"formatting"})}},q:function(e,a,n){var t=Math.ceil((e.getUTCMonth()+1)/3);switch(a){case"q":return String(t);case"qq":return Mde(t,2);case"qo":return n.ordinalNumber(t,{unit:"quarter"});case"qqq":return n.quarter(t,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(t,{width:"narrow",context:"standalone"});default:return n.quarter(t,{width:"wide",context:"standalone"})}},M:function(e,a,n){var t=e.getUTCMonth();switch(a){case"M":case"MM":return Nde(e,a);case"Mo":return n.ordinalNumber(t+1,{unit:"month"});case"MMM":return n.month(t,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(t,{width:"narrow",context:"formatting"});default:return n.month(t,{width:"wide",context:"formatting"})}},L:function(e,a,n){var t=e.getUTCMonth();switch(a){case"L":return String(t+1);case"LL":return Mde(t+1,2);case"Lo":return n.ordinalNumber(t+1,{unit:"month"});case"LLL":return n.month(t,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(t,{width:"narrow",context:"standalone"});default:return n.month(t,{width:"wide",context:"standalone"})}},w:function(e,a,n,t){var i=Cde(e,t);return"wo"===a?n.ordinalNumber(i,{unit:"week"}):Mde(i,a.length)},I:function(e,a,n){var t=Sde(e);return"Io"===a?n.ordinalNumber(t,{unit:"week"}):Mde(t,a.length)},d:function(e,a,n){return"do"===a?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):Ede(e,a)},D:function(e,a,n){var t=function(e){$ce(1,arguments);var a=Yce(e),n=a.getTime();a.setUTCMonth(0,1),a.setUTCHours(0,0,0,0);var t=a.getTime();return Math.floor((n-t)/864e5)+1}(e);return"Do"===a?n.ordinalNumber(t,{unit:"dayOfYear"}):Mde(t,a.length)},E:function(e,a,n){var t=e.getUTCDay();switch(a){case"E":case"EE":case"EEE":return n.day(t,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(t,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},e:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"e":return String(r);case"ee":return Mde(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,a,n,t){var i=e.getUTCDay(),r=(i-t.weekStartsOn+8)%7||7;switch(a){case"c":return String(r);case"cc":return Mde(r,a.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,a,n){var t=e.getUTCDay(),i=0===t?7:t;switch(a){case"i":return String(i);case"ii":return Mde(i,a.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(t,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(t,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(t,{width:"short",context:"formatting"});default:return n.day(t,{width:"wide",context:"formatting"})}},a:function(e,a,n){var t=e.getUTCHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},b:function(e,a,n){var t,i=e.getUTCHours();switch(t=12===i?Rde:0===i?zde:i/12>=1?"pm":"am",a){case"b":case"bb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},B:function(e,a,n){var t,i=e.getUTCHours();switch(t=i>=17?Kde:i>=12?Dde:i>=4?_de:Hde,a){case"B":case"BB":case"BBB":return n.dayPeriod(t,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(t,{width:"narrow",context:"formatting"});default:return n.dayPeriod(t,{width:"wide",context:"formatting"})}},h:function(e,a,n){if("ho"===a){var t=e.getUTCHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return xde(e,a)},H:function(e,a,n){return"Ho"===a?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):Pde(e,a)},K:function(e,a,n){var t=e.getUTCHours()%12;return"Ko"===a?n.ordinalNumber(t,{unit:"hour"}):Mde(t,a.length)},k:function(e,a,n){var t=e.getUTCHours();return 0===t&&(t=24),"ko"===a?n.ordinalNumber(t,{unit:"hour"}):Mde(t,a.length)},m:function(e,a,n){return"mo"===a?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):jde(e,a)},s:function(e,a,n){return"so"===a?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):Lde(e,a)},S:function(e,a){return Bde(e,a)},X:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();if(0===i)return"Z";switch(a){case"X":return Gde(i);case"XXXX":case"XX":return Vde(i);default:return Vde(i,":")}},x:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"x":return Gde(i);case"xxxx":case"xx":return Vde(i);default:return Vde(i,":")}},O:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ide(i,":");default:return"GMT"+Vde(i,":")}},z:function(e,a,n,t){var i=(t._originalDate||e).getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ide(i,":");default:return"GMT"+Vde(i,":")}},t:function(e,a,n,t){return Mde(Math.floor((t._originalDate||e).getTime()/1e3),a.length)},T:function(e,a,n,t){return Mde((t._originalDate||e).getTime(),a.length)}};function Ide(e,a){var n=e>0?"-":"+",t=Math.abs(e),i=Math.floor(t/60),r=t%60;if(0===r)return n+String(i);var o=a;return n+String(i)+o+Mde(r,2)}function Gde(e,a){return e%60==0?(e>0?"-":"+")+Mde(Math.abs(e)/60,2):Vde(e,a)}function Vde(e,a){var n=a||"",t=e>0?"-":"+",i=Math.abs(e);return t+Mde(Math.floor(i/60),2)+n+Mde(i%60,2)}var Fde=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"})}},Jde=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"})}},Ude={p:Jde,P:function(e,a){var n,t=e.match(/(P+)(p+)?/)||[],i=t[1],r=t[2];if(!r)return Fde(e,a);switch(i){case"P":n=a.dateTime({width:"short"});break;case"PP":n=a.dateTime({width:"medium"});break;case"PPP":n=a.dateTime({width:"long"});break;default:n=a.dateTime({width:"full"})}return n.replace("{{date}}",Fde(i,a)).replace("{{time}}",Jde(r,a))}},Wde=["D","DD"],qde=["YY","YYYY"];function Zde(e,a,n){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(a,"`) for formatting years to the input `").concat(n,"`; 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(n,"`; 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(n,"`; 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(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var $de={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 Yde(e){return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=a.width?String(a.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var Qde={date:Yde({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:Yde({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:Yde({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Xde={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function eme(e){return function(a,n){var t;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&e.formattingValues){var i=e.defaultFormattingWidth||e.defaultWidth,r=null!=n&&n.width?String(n.width):i;t=e.formattingValues[r]||e.formattingValues[i]}else{var o=e.defaultWidth,s=null!=n&&n.width?String(n.width):e.defaultWidth;t=e.values[s]||e.values[o]}return t[e.argumentCallback?e.argumentCallback(a):a]}}var ame={ordinalNumber:function(e,a){var n=Number(e),t=n%100;if(t>20||t<10)switch(t%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:eme({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:eme({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:eme({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:eme({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:eme({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 nme(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.width,i=a.match(t&&e.matchPatterns[t]||e.matchPatterns[e.defaultMatchWidth]);if(!i)return null;var r,o=i[0],s=t&&e.parsePatterns[t]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(s)?function(e,a){for(var n=0;n<e.length;n++)if(a(e[n]))return n;return}(s,(function(e){return e.test(o)})):function(e,a){for(var n in e)if(e.hasOwnProperty(n)&&a(e[n]))return n;return}(s,(function(e){return e.test(o)}));return r=e.valueCallback?e.valueCallback(l):l,{value:r=n.valueCallback?n.valueCallback(r):r,rest:a.slice(o.length)}}}var tme={ordinalNumber:function(e){return function(a){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=a.match(e.matchPattern);if(!t)return null;var i=t[0],r=a.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];return{value:o=n.valueCallback?n.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:nme({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:nme({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:nme({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:nme({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:nme({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"})},ime={code:"en-US",formatDistance:function(e,a,n){var t,i=$de[e];return t="string"==typeof i?i:1===a?i.one:i.other.replace("{{count}}",a.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+t:t+" ago":t},formatLong:Qde,formatRelative:function(e,a,n,t){return Xde[e]},localize:ame,match:tme,options:{weekStartsOn:0,firstWeekContainsDate:1}},rme=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ome=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,sme=/^'([^]*?)'?$/,lme=/''/g,ume=/[a-zA-Z]/;function cme(e,a,n){var t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b;$ce(2,arguments);var S=String(a),A=ade(),w=null!==(t=null!==(i=null==n?void 0:n.locale)&&void 0!==i?i:A.locale)&&void 0!==t?t:ime,C=Zce(null!==(r=null!==(o=null!==(s=null!==(l=null==n?void 0:n.firstWeekContainsDate)&&void 0!==l?l:null==n||null===(u=n.locale)||void 0===u||null===(c=u.options)||void 0===c?void 0:c.firstWeekContainsDate)&&void 0!==s?s:A.firstWeekContainsDate)&&void 0!==o?o:null===(d=A.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=Zce(null!==(h=null!==(p=null!==(g=null!==(v=null==n?void 0:n.weekStartsOn)&&void 0!==v?v:null==n||null===(f=n.locale)||void 0===f||null===(y=f.options)||void 0===y?void 0:y.weekStartsOn)&&void 0!==g?g:A.weekStartsOn)&&void 0!==p?p:null===(k=A.locale)||void 0===k||null===(b=k.options)||void 0===b?void 0:b.weekStartsOn)&&void 0!==h?h:0);if(!(M>=0&&M<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!w.localize)throw new RangeError("locale must contain localize property");if(!w.formatLong)throw new RangeError("locale must contain formatLong property");var T=Yce(e);if(!function(e){if($ce(1,arguments),!dde(e)&&"number"!=typeof e)return!1;var a=Yce(e);return!isNaN(Number(a))}(T))throw new RangeError("Invalid time value");var N=yde(T,rde(T)),E={firstWeekContainsDate:C,weekStartsOn:M,locale:w,_originalDate:T};return S.match(ome).map((function(e){var a=e[0];return"p"===a||"P"===a?(0,Ude[a])(e,w.formatLong):e})).join("").match(rme).map((function(t){if("''"===t)return"'";var i=t[0];if("'"===i)return function(e){var a=e.match(sme);if(!a)return e;return a[1].replace(lme,"'")}(t);var r=Ode[i];if(r)return null!=n&&n.useAdditionalWeekYearTokens||-1===qde.indexOf(t)||Zde(t,a,String(e)),null!=n&&n.useAdditionalDayOfYearTokens||!function(e){return-1!==Wde.indexOf(e)}(t)||Zde(t,a,String(e)),r(N,t,w.localize,E);if(i.match(ume))throw new RangeError("Format string contains an unescaped latin alphabet character `"+i+"`");return t})).join("")}function dme(e){return $ce(1,arguments),Math.floor(function(e){return $ce(1,arguments),Yce(e).getTime()}(e)/1e3)}function mme(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=ade(),d=Zce(null!==(n=null!==(t=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!==t?t:null===(l=c.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n:1),m=function(e,a){var n,t,i,r,o,s,l,u;$ce(1,arguments);var c=Yce(e),d=c.getFullYear(),m=ade(),h=Zce(null!==(n=null!==(t=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!==t?t:null===(l=m.locale)||void 0===l||null===(u=l.options)||void 0===u?void 0:u.firstWeekContainsDate)&&void 0!==n?n: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=nde(p,a),v=new Date(0);v.setFullYear(d,0,h),v.setHours(0,0,0,0);var f=nde(v,a);return c.getTime()>=g.getTime()?d+1:c.getTime()>=f.getTime()?d:d-1}(e,a),h=new Date(0);return h.setFullYear(m,0,d),h.setHours(0,0,0,0),nde(h,a)}function hme(e,a){return $ce(1,arguments),function(e,a,n){$ce(2,arguments);var t=nde(e,n),i=nde(a,n),r=t.getTime()-rde(t),o=i.getTime()-rde(i);return Math.round((r-o)/6048e5)}(function(e){$ce(1,arguments);var a=Yce(e),n=a.getMonth();return a.setFullYear(a.getFullYear(),n+1,0),a.setHours(0,0,0,0),a}(e),pde(e),a)+1}function pme(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getTime()>t.getTime()}function gme(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getTime()<t.getTime()}function vme(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()}function fme(e,a){return $ce(2,arguments),Qce(e,-Zce(a))}function yme(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a),i=n.getFullYear(),r=n.getDate(),o=new Date(0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);var s=function(e){$ce(1,arguments);var a=Yce(e),n=a.getFullYear(),t=a.getMonth(),i=new Date(0);return i.setFullYear(n,t+1,0),i.setHours(0,0,0,0),i.getDate()}(o);return n.setMonth(t,Math.min(r,s)),n}function kme(e,a){$ce(2,arguments);var n=Yce(e),t=Zce(a);return isNaN(n.getTime())?new Date(NaN):(n.setFullYear(t),n)}var bme=function(){return bme=Object.assign||function(e){for(var a,n=1,t=arguments.length;n<t;n++)for(var i in a=arguments[n])Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i]);return e},bme.apply(this,arguments)};function Sme(e,a,n){for(var t,i=0,r=a.length;i<r;i++)!t&&i in a||(t||(t=Array.prototype.slice.call(a,0,i)),t[i]=a[i]);return e.concat(t||Array.prototype.slice.call(a))}function Ame(e){return"multiple"===e.mode}function wme(e){return"range"===e.mode}function Cme(e){return"single"===e.mode}"function"==typeof SuppressedError&&SuppressedError;var Mme={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 Tme=Object.freeze({__proto__:null,formatCaption:function(e,a){return cme(e,"LLLL y",a)},formatDay:function(e,a){return cme(e,"d",a)},formatMonthCaption:function(e,a){return cme(e,"LLLL",a)},formatWeekNumber:function(e){return"".concat(e)},formatWeekdayName:function(e,a){return cme(e,"cccccc",a)},formatYearCaption:function(e,a){return cme(e,"yyyy",a)}}),Nme=Object.freeze({__proto__:null,labelDay:function(e,a,n){return cme(e,"do MMMM (EEEE)",n)},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 cme(e,"cccc",a)},labelYearDropdown:function(){return"Year: "}});var Eme=a.createContext(void 0);function xme(e){var a,t,i=e.initialProps,r={captionLayout:"buttons",classNames:Mme,formatters:Tme,labels:Nme,locale:ime,modifiersClassNames:{},modifiers:{},numberOfMonths:1,styles:{},today:new Date,mode:"default"},o=function(e){var a=e.fromYear,n=e.toYear,t=e.fromMonth,i=e.toMonth,r=e.fromDate,o=e.toDate;return t?r=pde(t):a&&(r=new Date(a,0,1)),i?o=hde(i):n&&(o=new Date(n,11,31)),{fromDate:r?ode(r):void 0,toDate:o?ode(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"),(Cme(i)||Ame(i)||wme(i))&&(t=i.onSelect);var c=bme(bme(bme({},r),i),{captionLayout:u,classNames:bme(bme({},r.classNames),i.classNames),components:bme({},i.components),formatters:bme(bme({},r.formatters),i.formatters),fromDate:s,labels:bme(bme({},r.labels),i.labels),mode:i.mode||r.mode,modifiers:bme(bme({},r.modifiers),i.modifiers),modifiersClassNames:bme(bme({},r.modifiersClassNames),i.modifiersClassNames),onSelect:t,styles:bme(bme({},r.styles),i.styles),toDate:l});return n.jsx(Eme.Provider,{value:c,children:e.children})}function Pme(){var e=a.useContext(Eme);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function jme(e){var a=Pme();return n.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 Lme(e){return n.jsx("svg",bme({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:n.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 Bme(e){var a,t,i=e.onChange,r=e.value,o=e.children,s=e.caption,l=e.className,u=e.style,c=Pme(),d=null!==(t=null===(a=c.components)||void 0===a?void 0:a.IconDropdown)&&void 0!==t?t:Lme;return n.jsxs("div",{className:l,style:u,children:[n.jsx("span",{className:c.classNames.vhidden,children:e["aria-label"]}),n.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:r,onChange:i,children:o}),n.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[s,n.jsx(d,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function zme(e){var a,t=Pme(),i=t.fromDate,r=t.toDate,o=t.styles,s=t.locale,l=t.formatters.formatMonthCaption,u=t.classNames,c=t.components,d=t.labels.labelMonthDropdown;if(!i)return n.jsx(n.Fragment,{});if(!r)return n.jsx(n.Fragment,{});var m=[];if(function(e,a){$ce(2,arguments);var n=Yce(e),t=Yce(a);return n.getFullYear()===t.getFullYear()}(i,r))for(var h=pde(i),p=i.getMonth();p<=r.getMonth();p++)m.push(yme(h,p));else for(h=pde(new Date),p=0;p<=11;p++)m.push(yme(h,p));var g=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Bme;return n.jsx(g,{name:"months","aria-label":d(),className:u.dropdown_month,style:o.dropdown_month,onChange:function(a){var n=Number(a.target.value),t=yme(pde(e.displayMonth),n);e.onChange(t)},value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:s}),children:m.map((function(e){return n.jsx("option",{value:e.getMonth(),children:l(e,{locale:s})},e.getMonth())}))})}function Rme(e){var a,t=e.displayMonth,i=Pme(),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 n.jsx(n.Fragment,{});if(!o)return n.jsx(n.Fragment,{});for(var p=r.getFullYear(),g=o.getFullYear(),v=p;v<=g;v++)h.push(kme(gde(new Date),v));var f=null!==(a=null==c?void 0:c.Dropdown)&&void 0!==a?a:Bme;return n.jsx(f,{name:"years","aria-label":m(),className:u.dropdown_year,style:l.dropdown_year,onChange:function(a){var n=kme(pde(t),Number(a.target.value));e.onChange(n)},value:t.getFullYear(),caption:d(t,{locale:s}),children:h.map((function(e){return n.jsx("option",{value:e.getFullYear(),children:d(e,{locale:s})},e.getFullYear())}))})}function _me(){var e=Pme(),n=function(e){var a=e.month||e.defaultMonth||e.today||new Date,n=e.toDate,t=e.fromDate,i=e.numberOfMonths,r=void 0===i?1:i;return n&&mde(n,a)<0&&(a=Xce(n,-1*(r-1))),t&&mde(a,t)<0&&(a=t),pde(a)}(e),t=function(e,n){var t=a.useState(e);return[void 0===n?t[0]:n,t[1]]}(n,e.month),i=t[1];return[t[0],function(a){var n;if(!e.disableNavigation){var t=pde(a);i(t),null===(n=e.onMonthChange)||void 0===n||n.call(e,t)}}]}var Dme=a.createContext(void 0);function Kme(e){var a=Pme(),t=_me(),i=t[0],r=t[1],o=function(e,a){for(var n=a.reverseMonths,t=a.numberOfMonths,i=pde(e),r=mde(pde(Xce(i,t)),i),o=[],s=0;s<r;s++){var l=Xce(i,s);o.push(l)}return n&&(o=o.reverse()),o}(i,a),s=function(e,a){if(!a.disableNavigation){var n=a.toDate,t=a.numberOfMonths,i=void 0===t?1:t,r=a.pagedNavigation?i:1,o=pde(e);if(!n)return Xce(o,r);if(!(mde(n,e)<i))return Xce(o,r)}}(i,a),l=function(e,a){if(!a.disableNavigation){var n=a.fromDate,t=a.numberOfMonths,i=a.pagedNavigation?void 0===t?1:t:1,r=pde(e);if(!n)return Xce(r,-i);if(!(mde(r,n)<=0))return Xce(r,-i)}}(i,a),u=function(e){return o.some((function(a){return vme(e,a)}))};return n.jsx(Dme.Provider,{value:{currentMonth:i,displayMonths:o,goToMonth:r,goToDate:function(e,n){u(e)||(n&&gme(e,n)?r(Xce(e,1+-1*a.numberOfMonths)):r(e))},previousMonth:l,nextMonth:s,isDateDisplayed:u},children:e.children})}function Hme(){var e=a.useContext(Dme);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function Ome(e){var a,t=Pme(),i=t.classNames,r=t.styles,o=t.components,s=Hme().goToMonth,l=function(a){s(Xce(a,e.displayIndex?-e.displayIndex:0))},u=null!==(a=null==o?void 0:o.CaptionLabel)&&void 0!==a?a:jme,c=n.jsx(u,{id:e.id,displayMonth:e.displayMonth});return n.jsxs("div",{className:i.caption_dropdowns,style:r.caption_dropdowns,children:[n.jsx("div",{className:i.vhidden,children:c}),n.jsx(zme,{onChange:l,displayMonth:e.displayMonth}),n.jsx(Rme,{onChange:l,displayMonth:e.displayMonth})]})}function Ime(e){return n.jsx("svg",bme({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.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 Gme(e){return n.jsx("svg",bme({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.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 Vme=a.forwardRef((function(e,a){var t=Pme(),i=t.classNames,r=t.styles,o=[i.button_reset,i.button];e.className&&o.push(e.className);var s=o.join(" "),l=bme(bme({},r.button_reset),r.button);return e.style&&Object.assign(l,e.style),n.jsx("button",bme({},e,{ref:a,type:"button",className:s,style:l}))}));function Fme(e){var a,t,i=Pme(),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 n.jsx(n.Fragment,{});var h=c(e.previousMonth,{locale:o}),p=[s.nav_button,s.nav_button_previous].join(" "),g=d(e.nextMonth,{locale:o}),v=[s.nav_button,s.nav_button_next].join(" "),f=null!==(a=null==m?void 0:m.IconRight)&&void 0!==a?a:Gme,y=null!==(t=null==m?void 0:m.IconLeft)&&void 0!==t?t:Ime;return n.jsxs("div",{className:s.nav,style:l.nav,children:[!e.hidePrevious&&n.jsx(Vme,{name:"previous-month","aria-label":h,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:n.jsx("rtl"===r?f:y,{className:s.nav_icon,style:l.nav_icon})}),!e.hideNext&&n.jsx(Vme,{name:"next-month","aria-label":g,className:v,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:n.jsx("rtl"===r?y:f,{className:s.nav_icon,style:l.nav_icon})})]})}function Jme(e){var a=Pme().numberOfMonths,t=Hme(),i=t.previousMonth,r=t.nextMonth,o=t.goToMonth,s=t.displayMonths,l=s.findIndex((function(a){return vme(e.displayMonth,a)})),u=0===l,c=l===s.length-1;return n.jsx(Fme,{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 Ume(e){var a,t,i=Pme(),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:jme;return t=i.disableNavigation?n.jsx(u,{id:e.id,displayMonth:e.displayMonth}):"dropdown"===s?n.jsx(Ome,{displayMonth:e.displayMonth,id:e.id}):n.jsxs(n.Fragment,"dropdown-buttons"===s?{children:[n.jsx(Ome,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),n.jsx(Jme,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}:{children:[n.jsx(u,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(Jme,{displayMonth:e.displayMonth,id:e.id})]}),n.jsx("div",{className:r.caption,style:o.caption,children:t})}function Wme(e){var a=Pme(),t=a.footer;return t?n.jsx("tfoot",{className:a.classNames.tfoot,style:a.styles.tfoot,children:n.jsx("tr",{children:n.jsx("td",{colSpan:8,children:t})})}):n.jsx(n.Fragment,{})}function qme(){var e=Pme(),a=e.classNames,t=e.styles,i=e.showWeekNumber,r=e.locale,o=e.formatters.formatWeekdayName,s=e.labels.labelWeekday,l=function(e,a,n){for(var t=n?tde(new Date):nde(new Date,{locale:e,weekStartsOn:a}),i=[],r=0;r<7;r++){var o=Qce(t,r);i.push(o)}return i}(r,e.weekStartsOn,e.ISOWeek);return n.jsxs("tr",{style:t.head_row,className:a.head_row,children:[i&&n.jsx("td",{style:t.head_cell,className:a.head_cell}),l.map((function(e,i){return n.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":s(e,{locale:r}),children:o(e,{locale:r})},i)}))]})}function Zme(){var e,a=Pme(),t=a.components,i=null!==(e=null==t?void 0:t.HeadRow)&&void 0!==e?e:qme;return n.jsx("thead",{style:a.styles.head,className:a.classNames.head,children:n.jsx(i,{})})}function $me(e){var a=Pme();return n.jsx(n.Fragment,{children:(0,a.formatters.formatDay)(e.date,{locale:a.locale})})}var Yme=a.createContext(void 0);function Qme(e){if(!Ame(e.initialProps)){return n.jsx(Yme.Provider,{value:{selected:void 0,modifiers:{disabled:[]}},children:e.children})}return n.jsx(Xme,{initialProps:e.initialProps,children:e.children})}function Xme(e){var a=e.initialProps,t=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,n=i.some((function(a){return cde(a,e)}));return Boolean(a&&!n)})),n.jsx(Yme.Provider,{value:{selected:i,onDayClick:function(e,n,t){var s,l;if((null===(s=a.onDayClick)||void 0===s||s.call(a,e,n,t),!Boolean(n.selected&&r&&(null==i?void 0:i.length)===r))&&!Boolean(!n.selected&&o&&(null==i?void 0:i.length)===o)){var u=i?Sme([],i):[];if(n.selected){var c=u.findIndex((function(a){return cde(e,a)}));u.splice(c,1)}else u.push(e);null===(l=a.onSelect)||void 0===l||l.call(a,u,e,n,t)}},modifiers:s},children:t})}function ehe(){var e=a.useContext(Yme);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}var ahe,nhe,the=a.createContext(void 0);function ihe(e){if(!wme(e.initialProps)){return n.jsx(the.Provider,{value:{selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}},children:e.children})}return n.jsx(rhe,{initialProps:e.initialProps,children:e.children})}function rhe(e){var a=e.initialProps,t=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],cde(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:fme(o,l-1),before:Qce(o,l-1)}),o&&s&&c.disabled.push({after:o,before:Qce(o,l-1)}),!o&&s&&c.disabled.push({after:fme(s,l-1),before:Qce(s,l-1)})),u){if(o&&!s&&(c.disabled.push({before:Qce(o,1-u)}),c.disabled.push({after:Qce(o,u-1)})),o&&s){var d=u-(sde(s,o)+1);c.disabled.push({before:fme(o,d)}),c.disabled.push({after:Qce(s,d)})}!o&&s&&(c.disabled.push({before:Qce(s,1-u)}),c.disabled.push({after:Qce(s,u-1)}))}return n.jsx(the.Provider,{value:{selected:i,onDayClick:function(e,n,t){var r,o;null===(r=a.onDayClick)||void 0===r||r.call(a,e,n,t);var s=function(e,a){var n=a||{},t=n.from,i=n.to;if(t&&i){if(cde(i,e)&&cde(t,e))return;if(cde(i,e))return{from:i,to:void 0};if(cde(t,e))return;return pme(t,e)?{from:e,to:i}:{from:t,to:e}}return i?pme(e,i)?{from:i,to:e}:{from:e,to:i}:t?gme(e,t)?{from:e,to:t}:{from:t,to:e}:{from:e,to:void 0}}(e,i);null===(o=a.onSelect)||void 0===o||o.call(a,s,e,n,t)},modifiers:c},children:t})}function ohe(){var e=a.useContext(the);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function she(e){return Array.isArray(e)?Sme([],e):void 0!==e?[e]:[]}(nhe=ahe||(ahe={})).Outside="outside",nhe.Disabled="disabled",nhe.Selected="selected",nhe.Hidden="hidden",nhe.Today="today",nhe.RangeStart="range_start",nhe.RangeEnd="range_end",nhe.RangeMiddle="range_middle";var lhe=ahe.Selected,uhe=ahe.Disabled,che=ahe.Hidden,dhe=ahe.Today,mhe=ahe.RangeEnd,hhe=ahe.RangeMiddle,phe=ahe.RangeStart,ghe=ahe.Outside;var vhe=a.createContext(void 0);function fhe(e){var a=Pme(),t=function(e,a,n){var t,i=((t={})[lhe]=she(e.selected),t[uhe]=she(e.disabled),t[che]=she(e.hidden),t[dhe]=[e.today],t[mhe]=[],t[hhe]=[],t[phe]=[],t[ghe]=[],t);return e.fromDate&&i[uhe].push({before:e.fromDate}),e.toDate&&i[uhe].push({after:e.toDate}),Ame(e)?i[uhe]=i[uhe].concat(a.modifiers[uhe]):wme(e)&&(i[uhe]=i[uhe].concat(n.modifiers[uhe]),i[phe]=n.modifiers[phe],i[hhe]=n.modifiers[hhe],i[mhe]=n.modifiers[mhe]),i}(a,ehe(),ohe()),i=function(e){var a={};return Object.entries(e).forEach((function(e){a[e[0]]=she(e[1])})),a}(a.modifiers),r=bme(bme({},t),i);return n.jsx(vhe.Provider,{value:r,children:e.children})}function yhe(){var e=a.useContext(vhe);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function khe(e,a){return a.some((function(a){if("boolean"==typeof a)return a;if(dde(a))return cde(e,a);var n,t,i,r,o;if(function(e){return Array.isArray(e)&&e.every(dde)}(a))return a.includes(e);if(function(e){return Boolean(e&&"object"==typeof e&&"from"in e)}(a))return n=e,o=(t=a).to,(r=t.from)&&o?(sde(o,r)<0&&(r=(i=[o,r])[0],o=i[1]),sde(n,r)>=0&&sde(o,n)>=0):o?cde(o,n):!!r&&cde(r,n);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=sde(a.before,e)>0,l=sde(a.after,e)<0;return pme(a.before,a.after)?l&&s:s||l}return function(e){return Boolean(e&&"object"==typeof e&&"after"in e)}(a)?sde(e,a.after)>0:function(e){return Boolean(e&&"object"==typeof e&&"before"in e)}(a)?sde(a.before,e)>0:"function"==typeof a&&a(e)}))}function bhe(e,a,n){var t=Object.keys(a).reduce((function(n,t){return khe(e,a[t])&&n.push(t),n}),[]),i={};return t.forEach((function(e){return i[e]=!0})),n&&!vme(e,n)&&(i.outside=!0),i}function She(e,a){var n=a.moveBy,t=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:Qce,week:lde,month:Xce,year:ude,startOfWeek:function(e){return i.ISOWeek?tde(e):nde(e,{locale:d,weekStartsOn:l})},endOfWeek:function(e){return i.ISOWeek?fde(e):vde(e,{locale:d,weekStartsOn:l})}}[n](e,"after"===t?1:-1);"before"===t&&u?m=function(e){var a,n;if($ce(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==qce(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Yce(e);(void 0===n||n<a||isNaN(Number(a)))&&(n=a)})),n||new Date(NaN)}([u,m]):"after"===t&&c&&(m=function(e){var a,n;if($ce(1,arguments),e&&"function"==typeof e.forEach)a=e;else{if("object"!==qce(e)||null===e)return new Date(NaN);a=Array.prototype.slice.call(e)}return a.forEach((function(e){var a=Yce(e);(void 0===n||n>a||isNaN(a.getDate()))&&(n=a)})),n||new Date(NaN)}([c,m]));var h=!0;if(r){var p=bhe(m,r);h=!p.disabled&&!p.hidden}return h?m:s.count>365?s.lastFocused:She(m,{moveBy:n,direction:t,context:i,modifiers:r,retry:bme(bme({},s),{count:s.count+1})})}var Ahe=a.createContext(void 0);function whe(e){var t=Hme(),i=yhe(),r=a.useState(),o=r[0],s=r[1],l=a.useState(),u=l[0],c=l[1],d=function(e,a){for(var n,t,i=pde(e[0]),r=hde(e[e.length-1]),o=i;o<=r;){var s=bhe(o,a);if(s.disabled||s.hidden)o=Qce(o,1);else{if(s.selected)return o;s.today&&!t&&(t=o),n||(n=o),o=Qce(o,1)}}return t||n}(t.displayMonths,i),m=(null!=o?o:u&&t.isDateDisplayed(u))?u:d,h=function(e){s(e)},p=Pme(),g=function(e,a){if(o){var n=She(o,{moveBy:e,direction:a,context:p,modifiers:i});cde(o,n)||(t.goToDate(n,o),h(n))}};return n.jsx(Ahe.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 Che(){var e=a.useContext(Ahe);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}var Mhe=a.createContext(void 0);function The(e){if(!Cme(e.initialProps)){return n.jsx(Mhe.Provider,{value:{selected:void 0},children:e.children})}return n.jsx(Nhe,{initialProps:e.initialProps,children:e.children})}function Nhe(e){var a=e.initialProps;return n.jsx(Mhe.Provider,{value:{selected:a.selected,onDayClick:function(e,n,t){var i,r,o;null===(i=a.onDayClick)||void 0===i||i.call(a,e,n,t),!n.selected||a.required?null===(o=a.onSelect)||void 0===o||o.call(a,e,e,n,t):null===(r=a.onSelect)||void 0===r||r.call(a,void 0,e,n,t)}},children:e.children})}function Ehe(){var e=a.useContext(Mhe);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function xhe(e,a){var n=[e.classNames.day];return Object.keys(a).forEach((function(a){var t=e.modifiersClassNames[a];if(t)n.push(t);else if(function(e){return Object.values(ahe).includes(e)}(a)){var i=e.classNames["day_".concat(a)];i&&n.push(i)}})),n}function Phe(e,t,i){var r,o,s,l=Pme(),u=Che(),c=function(e,a){return bhe(e,yhe(),a)}(e,t),d=function(e,a){var n=Pme(),t=Ehe(),i=ehe(),r=ohe(),o=Che(),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,v=o.focusYearAfter,f=o.focusStartOfWeek,y=o.focusEndOfWeek;return{onClick:function(o){var s,l,u,c;Cme(n)?null===(s=t.onDayClick)||void 0===s||s.call(t,e,a,o):Ame(n)?null===(l=i.onDayClick)||void 0===l||l.call(i,e,a,o):wme(n)?null===(u=r.onDayClick)||void 0===u||u.call(r,e,a,o):null===(c=n.onDayClick)||void 0===c||c.call(n,e,a,o)},onFocus:function(t){var i;m(e),null===(i=n.onDayFocus)||void 0===i||i.call(n,e,a,t)},onBlur:function(t){var i;d(),null===(i=n.onDayBlur)||void 0===i||i.call(n,e,a,t)},onKeyDown:function(t){var i;switch(t.key){case"ArrowLeft":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?s():l();break;case"ArrowRight":t.preventDefault(),t.stopPropagation(),"rtl"===n.dir?l():s();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),u();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),c();break;case"PageUp":t.preventDefault(),t.stopPropagation(),t.shiftKey?g():h();break;case"PageDown":t.preventDefault(),t.stopPropagation(),t.shiftKey?v():p();break;case"Home":t.preventDefault(),t.stopPropagation(),f();break;case"End":t.preventDefault(),t.stopPropagation(),y()}null===(i=n.onDayKeyDown)||void 0===i||i.call(n,e,a,t)},onKeyUp:function(t){var i;null===(i=n.onDayKeyUp)||void 0===i||i.call(n,e,a,t)},onMouseEnter:function(t){var i;null===(i=n.onDayMouseEnter)||void 0===i||i.call(n,e,a,t)},onMouseLeave:function(t){var i;null===(i=n.onDayMouseLeave)||void 0===i||i.call(n,e,a,t)},onPointerEnter:function(t){var i;null===(i=n.onDayPointerEnter)||void 0===i||i.call(n,e,a,t)},onPointerLeave:function(t){var i;null===(i=n.onDayPointerLeave)||void 0===i||i.call(n,e,a,t)},onTouchCancel:function(t){var i;null===(i=n.onDayTouchCancel)||void 0===i||i.call(n,e,a,t)},onTouchEnd:function(t){var i;null===(i=n.onDayTouchEnd)||void 0===i||i.call(n,e,a,t)},onTouchMove:function(t){var i;null===(i=n.onDayTouchMove)||void 0===i||i.call(n,e,a,t)},onTouchStart:function(t){var i;null===(i=n.onDayTouchStart)||void 0===i||i.call(n,e,a,t)}}}(e,c),m=function(){var e=Pme(),a=Ehe(),n=ehe(),t=ohe();return Cme(e)?a.selected:Ame(e)?n.selected:wme(e)?t.selected:void 0}(),h=Boolean(l.onDayClick||"default"!==l.mode);a.useEffect((function(){var a;c.outside||u.focusedDay&&h&&cde(u.focusedDay,e)&&(null===(a=i.current)||void 0===a||a.focus())}),[u.focusedDay,e,i,h,c.outside]);var p=xhe(l,c).join(" "),g=function(e,a){var n=bme({},e.styles.day);return Object.keys(a).forEach((function(a){var t;n=bme(bme({},n),null===(t=e.modifiersStyles)||void 0===t?void 0:t[a])})),n}(l,c),v=Boolean(c.outside&&!l.showOutsideDays||c.hidden),f=null!==(s=null===(o=l.components)||void 0===o?void 0:o.DayContent)&&void 0!==s?s:$me,y={style:g,className:p,children:n.jsx(f,{date:e,displayMonth:t,activeModifiers:c}),role:"gridcell"},k=u.focusTarget&&cde(u.focusTarget,e)&&!c.outside,b=u.focusedDay&&cde(u.focusedDay,e),S=bme(bme(bme({},y),((r={disabled:c.disabled,role:"gridcell"})["aria-selected"]=c.selected,r.tabIndex=b||k?0:-1,r)),d);return{isButton:h,isHidden:v,activeModifiers:c,selectedDays:m,buttonProps:S,divProps:y}}function jhe(e){var t=a.useRef(null),i=Phe(e.date,e.displayMonth,t);return i.isHidden?n.jsx("div",{role:"gridcell"}):i.isButton?n.jsx(Vme,bme({name:"day",ref:t},i.buttonProps)):n.jsx("div",bme({},i.divProps))}function Lhe(e){var a=e.number,t=e.dates,i=Pme(),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 n.jsx("span",{className:s.weeknumber,style:o.weeknumber,children:c});var d=u(Number(a),{locale:l});return n.jsx(Vme,{name:"week-number","aria-label":d,className:s.weeknumber,style:o.weeknumber,onClick:function(e){r(a,t,e)},children:c})}function Bhe(e){var a,t,i,r=Pme(),o=r.styles,s=r.classNames,l=r.components,u=null!==(a=null==l?void 0:l.Day)&&void 0!==a?a:jhe,c=null!==(t=null==l?void 0:l.WeekNumber)&&void 0!==t?t:Lhe;return r.showWeekNumber&&(i=n.jsx("td",{className:s.cell,style:o.cell,children:n.jsx(c,{number:e.weekNumber,dates:e.dates})})),n.jsxs("tr",{className:s.row,style:o.row,children:[i,e.dates.map((function(a){return n.jsx("td",{className:s.cell,style:o.cell,role:"presentation",children:n.jsx(u,{displayMonth:e.displayMonth,date:a})},dme(a))}))]})}function zhe(e,a,n){for(var t=(null==n?void 0:n.ISOWeek)?fde(a):vde(a,n),i=(null==n?void 0:n.ISOWeek)?tde(e):nde(e,n),r=sde(t,i),o=[],s=0;s<=r;s++)o.push(Qce(i,s));var l=o.reduce((function(e,a){var t=(null==n?void 0:n.ISOWeek)?function(e){$ce(1,arguments);var a=Yce(e),n=tde(a).getTime()-ide(a).getTime();return Math.round(n/6048e5)+1}(a):function(e,a){$ce(1,arguments);var n=Yce(e),t=nde(n,a).getTime()-mme(n,a).getTime();return Math.round(t/6048e5)+1}(a,n),i=e.find((function(e){return e.weekNumber===t}));return i?(i.dates.push(a),e):(e.push({weekNumber:t,dates:[a]}),e)}),[]);return l}function Rhe(e){var a,t,i,r=Pme(),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 n=zhe(pde(e),hde(e),a);if(null==a?void 0:a.useFixedWeeks){var t=hme(e,a);if(t<6){var i=n[n.length-1],r=i.dates[i.dates.length-1],o=lde(r,6-t),s=zhe(lde(r,1),o,a);n.push.apply(n,s)}}return n}(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:Zme,v=null!==(t=null==c?void 0:c.Row)&&void 0!==t?t:Bhe,f=null!==(i=null==c?void 0:c.Footer)&&void 0!==i?i:Wme;return n.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!u&&n.jsx(g,{}),n.jsx("tbody",{className:s.tbody,style:l.tbody,children:p.map((function(a){return n.jsx(v,{displayMonth:e.displayMonth,dates:a.dates,weekNumber:a.weekNumber},a.weekNumber)}))}),n.jsx(f,{displayMonth:e.displayMonth})]})}var _he="undefined"!=typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,Dhe=!1,Khe=0;function Hhe(){return"react-day-picker-".concat(++Khe)}function Ohe(e){var t,i,r=Pme(),o=r.dir,s=r.classNames,l=r.styles,u=r.components,c=Hme().displayMonths,d=function(e){var n,t=null!=e?e:Dhe?Hhe():null,i=a.useState(t),r=i[0],o=i[1];return _he((function(){null===r&&o(Hhe())}),[]),a.useEffect((function(){!1===Dhe&&(Dhe=!0)}),[]),null!==(n=null!=e?e:r)&&void 0!==n?n: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,v=e.displayIndex===c.length-1,f=!g&&!v;"rtl"===o&&(v=(t=[g,v])[0],g=t[1]),g&&(h.push(s.caption_start),p=bme(bme({},p),l.caption_start)),v&&(h.push(s.caption_end),p=bme(bme({},p),l.caption_end)),f&&(h.push(s.caption_between),p=bme(bme({},p),l.caption_between));var y=null!==(i=null==u?void 0:u.Caption)&&void 0!==i?i:Ume;return n.jsxs("div",{className:h.join(" "),style:p,children:[n.jsx(y,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(Rhe,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function Ihe(e){var a=Pme();return n.jsx("div",{className:a.classNames.months,style:a.styles.months,children:e.children})}function Ghe(e){var t,i,r=e.initialProps,o=Pme(),s=Che(),l=Hme(),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=bme(bme({},o.styles.root),o.style),p=Object.keys(r).filter((function(e){return e.startsWith("data-")})).reduce((function(e,a){var n;return bme(bme({},e),((n={})[a]=r[a],n))}),{}),g=null!==(i=null===(t=r.components)||void 0===t?void 0:t.Months)&&void 0!==i?i:Ihe;return n.jsx("div",bme({className:m.join(" "),style:h,dir:o.dir,id:o.id,nonce:r.nonce,title:r.title,lang:r.lang},p,{children:n.jsx(g,{children:l.displayMonths.map((function(e,a){return n.jsx(Ohe,{displayIndex:a,displayMonth:e},a)}))})}))}function Vhe(e){var a=e.children,t=function(e,a){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&a.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(e);i<t.length;i++)a.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(n[t[i]]=e[t[i]])}return n}(e,["children"]);return n.jsx(xme,{initialProps:t,children:n.jsx(Kme,{children:n.jsx(The,{initialProps:t,children:n.jsx(Qme,{initialProps:t,children:n.jsx(ihe,{initialProps:t,children:n.jsx(fhe,{children:n.jsx(whe,{children:a})})})})})})})}function Fhe(e){return n.jsx(Vhe,bme({},e,{children:n.jsx(Ghe,{initialProps:e})}))}function Jhe({className:e,classNames:a,showOutsideDays:t=!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:pm(xY({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:pm(xY({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 n.jsx(Fhe,{showOutsideDays:t,className:pm("p-3",e),classNames:r,components:{IconLeft:()=>n.jsx(Pc,{className:"h-4 w-4"}),IconRight:()=>n.jsx(jc,{className:"h-4 w-4"})},...i})}Jhe.displayName="Calendar";const Uhe=({setScheduleTime:e,setTimezone:a,timezone:t,scheduleTime:i,setIsDirty:o})=>{const[s,l]=r.useState(i&&i<(new Date).toISOString()?"Please select a time in the future":null),[u,c]=r.useState(i&&"now"!==i?dae(new Date(i),"HH:mm"):"00:00"),d=Intl.supportedValuesOf("timeZone").map((e=>({label:e,value:e}))),m=e=>{const n=new Date(i||(new Date).toISOString()),t=Cee(new Date,15);n<new Date(t.toLocaleString("en-US",{timeZone:e}))?l("Please select a time at least 15 minutes in the future"):(l(null),a(e),o(!0))},h=a=>{const n=Cee(new Date,15);new Date(a.toLocaleString("en-US",{timeZone:t}))<new Date(n.toLocaleString("en-US",{timeZone:t}))?l("Please select a time at least 15 minutes in the future"):(l(null),e(a.toISOString()),o(!0))};return n.jsx("div",{className:"w-full @container/schedule-time",children:n.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[n.jsxs("div",{className:"flex gap-2 w-full @xl/schedule-time:flex-row flex-col items-center justify-center",children:[n.jsxs(m9,{children:[n.jsx(h9,{asChild:!0,children:n.jsxs(PY,{variant:"outline",className:pm("bg-background w-full sm:w-[280px] justify-start text-left font-normal",!i&&"text-muted-foreground"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),i?"now"===i?"Send immediately":dae(new Date(i),"PPP"):n.jsx("span",{children:"Pick a date"})]})}),n.jsx(p9,{className:"w-auto p-0 z-[60] pointer-events-auto",children:n.jsx(Jhe,{mode:"single",selected:i?new Date(i):void 0,onSelect:e=>{if(!e)return;const[a,n]=u.split(":").map(Number);e.setHours(a,n),h(e)},disabled:e=>{const a=new Date;return a.setHours(0,0,0,0),e<a},initialFocus:!0})})]}),n.jsx("input",{type:"time",value:u,onChange:e=>{if(c(e.target.value),i&&e.target.value){const[a,n]=e.target.value.split(":").map(Number),t=new Date(i);t.setHours(a,n),h(t)}},className:pm("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",s&&"border-red-500")}),n.jsx("div",{className:"w-full sm:w-[200px]",children:n.jsx(tue,{options:d,selectedValues:[t],setSelectedValues:e=>m(e[0]),onValueChange:e=>m(e[0]),placeholder:"Select timezone...",searchPlaceholder:"Search timezone...",emptyMessage:"No timezone found",title:"Select Timezone",singleSelect:!0})})]}),s&&n.jsxs("p",{className:"text-destructive text-sm mt-2 flex items-center",children:[n.jsx("span",{className:"mr-2",children:"⚠️"}),s]})]})})},Whe=({title:e="Edit Schedule Time"})=>{const t=AY(),i=ce(),{updateAutomation:r}=na(t?.id||""),{toast:o}=Ie(),[s,l]=a.useState(null),[u,c]=a.useState(t?.triggerMetadata?.triggerType===oa.ONE_TIME?t?.triggerMetadata?.scheduledAt:null),[d,m]=a.useState(t?.triggerMetadata?.triggerType===oa.ONE_TIME&&t?.triggerMetadata?.timezone||"America/New_York"),[h,p]=a.useState(!1),[g,v]=a.useState(null);let f=a.useRef(null);const y=a.useCallback((()=>{t&&("sendNow"===s||"now"===u?r({trigger:{triggerType:oa.ONE_TIME,scheduledAt:"now"}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${Eh("engage:broadcast")} scheduled to begin sending in 5 minutes after you activate it`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:je.all})}}):u&&d&&r({trigger:{triggerType:oa.ONE_TIME,scheduledAt:u,timezone:d}},{onSuccess:()=>{v({title:"Schedule time updated successfully 🚀",description:`${Eh("engage:broadcast")} scheduled to start at ${new Date(u).toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric"})}`})},onError:()=>{o({title:"Failed to update schedule time",description:"Please try again",variant:"destructive"}),i.invalidateQueries({queryKey:je.all})}}))}),[t,s,u,d,r,o,i]);if(a.useEffect((()=>(g&&(f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{o(g),v(null)}),800)),()=>{f.current&&clearTimeout(f.current)})),[g,o]),a.useEffect((()=>{t&&h&&s&&("sendNow"===s||u)&&(y(),p(!1))}),[s,u,d,y,t,h]),a.useEffect((()=>{null===s&&t?.triggerMetadata&&"object"==typeof t.triggerMetadata&&null!==t.triggerMetadata&&"scheduledAt"in t.triggerMetadata&&("now"===t?.triggerMetadata?.scheduledAt&&t?.triggerType===oa.ONE_TIME?l("sendNow"):(t?.triggerMetadata?.scheduledAt&&c(t.triggerMetadata.scheduledAt),t?.triggerMetadata?.timezone&&m(t.triggerMetadata.timezone),l("schedule")))}),[t,s]),!t)return null;const k=t.status===ca.DRAFT;return n.jsx(Jce,{title:e,headerActions:!k&&n.jsx(Mae,{title:"You can only edit the schedule time if the automation is in draft mode"}),children:n.jsx("div",{className:"@container flex-1 mx-4",children:n.jsxs("div",{className:"flex @[1000px]:flex-row flex-col gap-8 items-center",children:[n.jsxs("div",{className:"flex-1 w-full",children:[n.jsxs("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-4",children:[n.jsx(BY,{selected:"sendNow"===s,title:"Send Now",subtitle:"Campaign will begin sending in 5 minutes",icon:n.jsx(zY.SendButton,{className:"text-primary"}),onClick:()=>{k&&(l("sendNow"),c("now"),m("America/New_York"),p(!0))}}),n.jsx(BY,{selected:"schedule"===s,title:"Schedule",subtitle:"Choose date and time",icon:n.jsx(zY.ScheduleButton,{className:"text-primary"}),onClick:()=>{k&&l("schedule")}})]}),n.jsx(dV,{children:"schedule"===s&&n.jsx(EY,{className:"overflow-hidden mt-8",children:n.jsx("div",{className:"bg-gray-50 rounded-xl p-5 border border-gray-100 flex items-center justify-center",children:n.jsx(Uhe,{setScheduleTime:e=>{c(e),p(!0)},setTimezone:e=>{m(e),p(!0)},timezone:d,scheduleTime:u,setIsDirty:p})})})})]}),u&&n.jsx(Z$.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:n.jsxs(n.Fragment,"now"===u?{children:[n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Ready to send immediately"}),n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.4},className:"text-md font-bold text-gray-800",children:"Once you mark this automation as active, we'll send it 5 minutes from that moment"})]}:{children:[n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:.8},transition:{delay:.3,duration:.4},className:"text-sm font-medium text-gray-700",children:"Currently scheduled for:"}),n.jsx(Z$.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})})]})})]})})})},qhe=()=>n.jsx("div",{children:n.jsx(Whe,{title:"Set Schedule Time"})});var Zhe=(e=>(e.DAYS="days",e))(Zhe||{});const $he=(e,a)=>{switch(e){case bY.EQUALS:return"Equals";case bY.NOT_EQUALS:return"Not Equals";case bY.GREATER_THAN:return a===yY.Date?"Date on or after":"Greater than";case bY.LESS_THAN:return a===yY.Date?"Date on or before":"Less than";case bY.EXISTS:return"Exists";case bY.EQUALS_MONTH_DAY:return"Month and Day Matches";case bY.EQUALS_MONTH_DAY_YEAR:return"Month, Day, and Year Matches";case bY.BETWEEN_MONTH_DAY:return"Between Month Day";case bY.BETWEEN_MONTH_DAY_YEAR:return"Between Month Day Year";case bY.ARRAY_CONTAINS:return"Is One Of";default:return e}},Yhe={email:"Email Address",phone:"Phone Number",firstName:"First Name",lastName:"Last Name"},Qhe=({options:e,value:a,onChange:t,placeholder:i,className:o="",disableInput:s=!1})=>{const[l,u]=r.useState(!1);return n.jsxs(m9,{modal:!0,open:l,onOpenChange:u,children:[n.jsx(h9,{asChild:!0,children:n.jsxs(PY,{"aria-expanded":l,className:pm("w-full overflow-hidden justify-between",o),variant:"outline",children:[a?e.find((e=>e.value===a))?.label:i,n.jsx(Bc,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),n.jsx(p9,{className:pm("w-full min-w-[120px] max-w-[600px] p-0",o),children:n.jsxs(Ise,{children:[!s&&n.jsx(Gse,{placeholder:`${i}...`}),n.jsxs(Vse,{children:[n.jsxs(Fse,{children:["No ",i.toLowerCase()," found."]}),n.jsx(Jse,{children:e.map((e=>n.jsxs(Use,{value:e.value,onSelect:e=>{t(e===a?"":e),u(!1)},children:[n.jsx(Ec,{className:pm("mr-2 h-4 w-4",a===e.value?"opacity-100":"opacity-0")}),e.label]},e.id||e.value)))})]})]})})]})};var Xhe="Switch",[epe,ape]=XQ(Xhe),[npe,tpe]=epe(Xhe),ipe=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,name:i,checked:o,defaultChecked:s,required:l,disabled:u,value:c="on",onCheckedChange:d,form:m,...h}=e,[p,g]=r.useState(null),v=hO(a,(e=>g(e))),f=r.useRef(!1),y=!p||(m||!!p.closest("form")),[k=!1,b]=nX({prop:o,defaultProp:s,onChange:d});return n.jsxs(npe,{scope:t,checked:k,disabled:u,children:[n.jsx(lX.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":lpe(k),"data-disabled":u?"":void 0,disabled:u,value:c,...h,ref:v,onClick:QQ(e.onClick,(e=>{b((e=>!e)),y&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())}))}),y&&n.jsx(spe,{control:p,bubbles:!f.current,name:i,value:c,checked:k,required:l,disabled:u,form:m,style:{transform:"translateX(-100%)"}})]})}));ipe.displayName=Xhe;var rpe="SwitchThumb",ope=r.forwardRef(((e,a)=>{const{__scopeSwitch:t,...i}=e,r=tpe(rpe,t);return n.jsx(lX.span,{"data-state":lpe(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:a})}));ope.displayName=rpe;var spe=e=>{const{control:a,checked:t,bubbles:i=!0,...o}=e,s=r.useRef(null),l=Boe(t),u=g1(a);return r.useEffect((()=>{const e=s.current,a=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(a,"checked").set;if(l!==t&&n){const a=new Event("click",{bubbles:i});n.call(e,t),e.dispatchEvent(a)}}),[l,t,i]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...o,tabIndex:-1,ref:s,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function lpe(e){return e?"checked":"unchecked"}var upe=ipe,cpe=ope;const dpe=r.forwardRef((({className:e,...a},t)=>n.jsx(upe,{className:pm("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:t,children:n.jsx(cpe,{className:pm("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")})})));dpe.displayName=upe.displayName;const mpe=({onSelect:e,date:a,placeholder:t="Pick a date",monthDayOnly:i=!1})=>n.jsxs(m9,{modal:!0,children:[n.jsx(h9,{asChild:!0,children:n.jsxs(PY,{variant:"outline",className:pm("w-[200px] justify-start text-left font-normal h-9",!a&&"text-muted-foreground"),children:[n.jsx(Nc,{className:"mr-2 h-4 w-4"}),a?dae(a,i?"MMMM d":"PPP"):n.jsx("span",{children:t})]})}),n.jsx(p9,{className:"w-auto p-0",align:"start",children:n.jsx(Jhe,{mode:"single",selected:a,onSelect:e,initialFocus:!0})})]}),hpe=e=>void 0===e.value||!("number"!=typeof e.value||e.value<0)&&(e.unit===Zhe.DAYS&&(("before"===e.direction||"after"===e.direction)&&"relative"===e.type)),ppe=({fieldType:e,operator:a,value:t,onChange:i,options:o,toast:s})=>{const l=t.length>0&&"object"==typeof t[0]&&"type"in t[0]&&"relative"===t[0].type,u=t.length>0&&"object"==typeof t[0]&&"startDate"in t[0]&&"endDate"in t[0],[c,d]=r.useState((e===yY.Date||e===yY.DateTime)&&t.length>0&&t[0]instanceof Date?t[0]:void 0),[m,h]=r.useState(l),[p,g]=r.useState(l?t[0]:{type:"relative",value:0,unit:Zhe.DAYS,direction:"before"}),[v,f]=r.useState(u?t[0]:void 0),[y,k]=r.useState(!1);if(r.useEffect((()=>{a!==bY.EQUALS_MONTH_DAY&&a!==bY.EQUALS_MONTH_DAY_YEAR&&m&&(h(!1),i(c?[c]:[]))}),[a,m,c,i]),r.useEffect((()=>{if(u&&v?.startDate){k("object"==typeof v.startDate&&"type"in v.startDate)}}),[u,v]),e===yY.String||e===yY.ReachResource||e===yY.Array)return a===bY.EXISTS?null:n.jsx(tue,{options:(o||[]).map((e=>({label:e.displayName,value:e.id}))),onValueChange:e=>{i(e)},selectedValues:t.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===yY.Date||e===yY.DateTime){const e=a===bY.EQUALS_MONTH_DAY||a===bY.EQUALS_MONTH_DAY_YEAR,t=a===bY.BETWEEN_MONTH_DAY||a===bY.BETWEEN_MONTH_DAY_YEAR,r=e=>{hpe(e)?(g(e),m&&i([e])):s({title:"Invalid relative date",description:"Please enter a valid non-negative number of days.",variant:"destructive"})},o=e=>{const a=e.startDate??v?.startDate,n=e.endDate??v?.endDate,t=a&&"object"==typeof a&&"type"in a,r=n&&"object"==typeof n&&"type"in n;if(a&&n){if(t!==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(!t&&!r&&!(e=>!e.finalStartDate||!e.finalEndDate||e.finalStartDate<e.finalEndDate)({finalStartDate:a,finalEndDate:n}))return void s({title:"Invalid date range",description:"Start date must be before end date.",variant:"destructive"});if(t&&(!hpe(a)||!hpe(n)))return void s({title:"Invalid relative date",description:"Please enter valid relative dates.",variant:"destructive"})}f(e),a&&n&&i([{startDate:a,endDate:n}])},l=e=>{e&&(e=>e instanceof Date?!isNaN(e.getTime()):"object"==typeof e&&"type"in e&&"relative"===e.type&&hpe(e))(e)?(d(e),i([e]),h(!1)):e||(d(void 0),i([]),h(!1))},u=e=>{h(e),i(e?[p]:c?[c]:[])};return n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"min-h-[36px] flex items-center",children:[(!m||!e)&&!t&&n.jsx(mpe,{date:c,onSelect:l,monthDayOnly:a===bY.EQUALS_MONTH_DAY}),e&&m&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(r4,{type:"number",value:void 0===p.value?"":p.value,onChange:e=>{const a=""===e.target.value?void 0:parseInt(e.target.value,10);r({...p,value:a})},className:"w-20 h-9",min:"0","aria-label":"Relative days value"}),n.jsxs(hie,{value:p.direction,onValueChange:e=>{r({...p,direction:e})},children:[n.jsx(vie,{className:"w-[180px] h-9","aria-label":"Relative direction",children:n.jsx(gie,{placeholder:"Select direction..."})}),n.jsxs(kie,{children:[n.jsx(bie,{value:"before",children:"days before today"}),n.jsx(bie,{value:"after",children:"days after today"})]})]})]}),t&&n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(r4,{type:"number",value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:Zhe.DAYS,direction:v?.startDate?.direction||"before"};hpe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},className:"w-20 h-9",min:"0","aria-label":"Start date relative days"}),n.jsxs(hie,{value:v?.startDate&&"object"==typeof v.startDate&&"type"in v.startDate?v.startDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.startDate?.value,unit:Zhe.DAYS,direction:e};hpe(a)&&(f({...v,startDate:a}),o({...v,startDate:a}))},children:[n.jsx(vie,{className:"w-[180px] h-9",children:n.jsx(gie,{placeholder:"Select direction..."})}),n.jsxs(kie,{children:[n.jsx(bie,{value:"before",children:"days before today"}),n.jsx(bie,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"Start"})]}):n.jsx(mpe,{placeholder:"Start date",date:v?.startDate instanceof Date||"string"==typeof v?.startDate?v.startDate instanceof Date?v.startDate:new Date(v.startDate):void 0,monthDayOnly:a===bY.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,startDate:a}),o({...v,startDate:a}))}})}),n.jsx("div",{className:"flex items-center space-x-2",children:y?n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(r4,{type:"number",value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.value:"",onChange:e=>{const a={type:"relative",value:""===e.target.value?void 0:parseInt(e.target.value,10),unit:Zhe.DAYS,direction:v?.endDate?.direction||"before"};hpe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},className:"w-20 h-9",min:"0","aria-label":"End date relative days"}),n.jsxs(hie,{value:v?.endDate&&"object"==typeof v.endDate&&"type"in v.endDate?v.endDate.direction:"before",onValueChange:e=>{const a={type:"relative",value:v?.endDate?.value,unit:Zhe.DAYS,direction:e};hpe(a)&&(f({...v,endDate:a}),o({...v,endDate:a}))},children:[n.jsx(vie,{className:"w-[180px] h-9",children:n.jsx(gie,{placeholder:"Select direction..."})}),n.jsxs(kie,{children:[n.jsx(bie,{value:"before",children:"days before today"}),n.jsx(bie,{value:"after",children:"days after today"})]})]}),n.jsx("span",{className:"w-12 text-xs font-medium text-muted-foreground flex-shrink-0",children:"End"})]}):n.jsx(mpe,{placeholder:"End date",date:v?.endDate instanceof Date||"string"==typeof v?.endDate?v.endDate instanceof Date?v.endDate:new Date(v.endDate):void 0,monthDayOnly:a===bY.BETWEEN_MONTH_DAY,onSelect:e=>{const a=e;a&&(f({...v,endDate:a}),o({...v,endDate:a}))}})})]}),n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(dpe,{id:"between-relative-date-switch",checked:y,onCheckedChange:e=>{if(k(e),e){const e={type:"relative",value:0,unit:Zhe.DAYS,direction:"before"},a={type:"relative",value:0,unit:Zhe.DAYS,direction:"before"};f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}else{const e=new Date,a=new Date(e);a.setDate(a.getDate()+1),f({startDate:e,endDate:a}),o({startDate:e,endDate:a})}},"aria-label":"Toggle relative date input for between dates"}),n.jsx(Kae,{htmlFor:"between-relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})]}),e&&n.jsxs("div",{className:"flex items-center space-x-1 pl-1",children:[n.jsx(dpe,{id:"relative-date-switch",checked:m,onCheckedChange:u,"aria-label":"Toggle relative date input"}),n.jsx(Kae,{htmlFor:"relative-date-switch",className:"text-xs font-normal text-muted-foreground cursor-pointer",children:"Relative"})]})]})}if(e===yY.Number||e===yY.Integer)return a===bY.EXISTS?null:n.jsx(r4,{type:"number",value:t.length>0?String(t[0]):"",onChange:e=>i([Number(e.target.value)]),className:"w-[200px]"});if(e===yY.Boolean){if(a===bY.EXISTS)return null;const e=t.length>0&&Boolean(t[0]);return n.jsx(dpe,{checked:e,onCheckedChange:e=>i([e])})}return n.jsx(r4,{value:t.length>0?String(t[0]):"",onChange:e=>i([e.target.value]),className:"w-[200px]",disabled:!0})},gpe=({condition:e,onUpdate:t,onDuplicate:i,onDelete:r,segmentsConditions:o})=>{const{toast:s}=Ie(),l=(e=>{const a=o.conditions.find((a=>a.field===e));return a||null})(e.field)||{operators:[],type:yY.String,options:void 0},u=l.operators,c=l.type,d=o.conditions.map((e=>e.field)).map((e=>({value:e,label:Yhe[e]||e})));return a.useEffect((()=>{setTimeout((()=>document.body.style.pointerEvents=""),0)}),[]),n.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch gap-2 min-w-0 w-full",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 items-stretch gap-2 min-w-0 w-full",children:[n.jsx("div",{className:"flex-1 min-w-0 items-center flex",children:n.jsx(Qhe,{options:d,value:e.field,onChange:a=>{const n=a,i=o.conditions.find((e=>e.field===n));if(!i)return;const r=i.operators.map((e=>({value:e,label:$he(e,i.type),fieldType:i.type}))),s=r[0]?.value;let l=[];switch(i.type){case yY.Boolean:l=[!1];break;case yY.Number:l=[0];break;case yY.Date:case yY.DateTime:l=[new Date];break;case yY.String:l=i.options?.length?i.options.map((e=>e.displayName)):[];break;default:l=[]}t({...e,field:n,operator:s,value:l})},placeholder:"Select field",className:"w-full",disableInput:!0})}),n.jsxs("div",{className:"flex-1 min-w-0 max-w-xs flex gap-2 items-center",children:[(e.operator===bY.EQUALS_MONTH_DAY||e.operator===bY.EQUALS_MONTH_DAY_YEAR||e.operator===bY.BETWEEN_MONTH_DAY||e.operator===bY.BETWEEN_MONTH_DAY_YEAR)&&n.jsx("div",{className:"flex items-center",children:(e=>{let a;switch(e){case bY.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 bY.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 bY.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 bY.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 n.jsx(Mae,{title:a})})(e.operator)}),n.jsx(Qhe,{options:u.map((e=>({value:e,label:e?$he(e,c):e}))),value:e.operator,onChange:a=>t({...e,operator:a}),placeholder:"Select operator",className:"w-full",disableInput:!0})]}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(ppe,{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=>t({...e,value:a}),toast:s})})]}),n.jsxs("div",{className:"flex items-center flex-shrink-0 pl-2",children:[n.jsx(PY,{size:"icon",variant:"ghost",onClick:i,children:n.jsx(Hc,{className:"h-4 w-4"})}),n.jsx(PY,{size:"icon",variant:"ghost",onClick:r,children:n.jsx(pd,{className:"h-4 w-4"})})]})]})},vpe=({onSelectStyle:e})=>{const[t,i]=a.useState(null);return n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-4 max-w-4xl mx-auto",children:[n.jsx(BY,{onClick:()=>{i("ai"),e("ai")},title:"Build with AI",subtitle:"Describe your audience in plain language and let AI create the conditions",icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(md,{className:"w-full h-full"})})}),selected:"ai"===t}),n.jsx(BY,{onClick:()=>{i("manual"),e("manual")},title:"Build Manually",subtitle:`Create your ${Eh("engage:segment")} by configuring conditions directly`,icon:n.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx("div",{className:"w-6 h-6 text-[hsl(var(--reach-primary))]",children:n.jsx(ud,{className:"w-full h-full"})})}),selected:"manual"===t})]})},fpe=({segmentId:e,setOpen:a,setTextToSegment:t,promptBuilderStyle:i,textToSegment:r})=>n.jsx("div",{children:n.jsx(qG,{className:"",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx($G,{className:"text-3xl font-normal",children:e?`Edit ${Eh("engage:segment")}`:`Create ${Eh("engage:segment")}`}),n.jsxs("div",{className:"flex items-center gap-2",children:[!1===i&&!1===r&&n.jsx(P6,{children:n.jsxs(j6,{children:[n.jsx(L6,{asChild:!0,children:n.jsx(PY,{variant:"outline",size:"sm",onClick:()=>t(!0),children:n.jsx(md,{className:"h-4 w-3"})})}),n.jsx(B6,{children:n.jsxs("p",{children:["Use AI to create ",Eh("engage:segment")," by describing them in natural language"]})})]})}),n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>{a(!1)},className:"h-8 w-8",children:n.jsx(bd,{className:"h-4 w-4"})})]})]})})}),ype=({setTextToSegment:e,setSegment:t})=>{const[i,r]=a.useState(""),[o,s]=a.useState(!1),{toast:u}=Ie();return n.jsxs("div",{className:"flex flex-col gap-6 p-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Describe your audience"}),n.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."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(dV,{children:[o&&n.jsx(EY,{children:n.jsx(NY,{})}),!o&&n.jsx(EY,{children:n.jsx(iue,{placeholder:"Describe your target audience...",className:"min-h-[120px] resize-none",value:i,onChange:e=>r(e.target.value)})})]}),n.jsx("div",{className:"flex justify-end gap-2",children:n.jsxs(PY,{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=>(await Pe(`${l}/text-to-segment`,{method:"POST",body:JSON.stringify({text:e})})).data)(i);a.success&&a.conditions?(u({title:`${Eh("engage:segment")} conditions built successfully 🚀`,description:`Your ${Eh("engage:segment")} conditions have been built successfully`}),t(a.conditions)):u({title:`${Eh("engage:segment")} build failed`,description:"Please try again",variant:"destructive"}),e(!1),s(!1)},children:[n.jsx(md,{className:"h-4 w-4"}),"Generate ",Eh("engage:segment")]})})]})]})};function kpe({segmentId:e,setOpen:a,onSegmentUpdated:t}){const{toast:i}=Ie(),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}=vY(e||""),{updateSegment:h}=fY(e),{createSegment:p,isCreating:g,segmentsConditions:v}=hY(),[f,y]=r.useState(!1),[k,b]=r.useState(!!o);r.useEffect((()=>{v&&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:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})}),[d,v]);const S=e=>e.value.some((e=>"object"==typeof e&&"type"in e&&"relative"===e.type)),A=e=>e.value.some((e=>"object"==typeof e&&"startDate"in e&&"endDate"in e));if(!v||m)return n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(NY,{})});return n.jsxs(n.Fragment,{children:[n.jsx(fpe,{segmentId:e,setOpen:a,setTextToSegment:y,promptBuilderStyle:k,textToSegment:f},"segment-builder-header"),k?n.jsx(EY,{children:n.jsx(vpe,{onSelectStyle:e=>{"ai"===e&&y(!0),b(!1)}})},"prompt-builder-style"):n.jsx(EY,{children:n.jsxs("div",{className:"flex flex-1 flex-col",children:[n.jsx("div",{className:"flex flex-1 flex-col px-8 py-2",children:n.jsx("div",{className:"flex flex-1 flex-col gap-4 overflow-visible",children:n.jsx(dV,{children:f?n.jsx(EY,{children:n.jsx(ype,{setTextToSegment:y,setSegment:e=>c({...u,conditions:e})})}):n.jsxs(EY,{children:[n.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center gap-0",children:[n.jsx(Kae,{className:"text-muted-foreground text-xs",children:"Name"}),n.jsx("span",{className:"text-xs text-red-500 ml-1 align-super",children:"*"})]}),n.jsx(r4,{placeholder:`${Eh("engage:segment")} name`,value:u.name,onChange:e=>c({...u,name:e.target.value})})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Kae,{className:"text-muted-foreground text-xs",children:"Description"}),n.jsx(r4,{placeholder:`${Eh("engage:segment")} description`,value:u.description,onChange:e=>c({...u,description:e.target.value})})]})]}),u.conditions.length>0&&n.jsx("div",{className:"flex-1 overflow-y-auto pb-8",children:n.jsx("div",{className:"grid",children:n.jsx(dV,{mode:"popLayout",children:u.conditions.map(((e,a)=>n.jsxs(Z$.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&&n.jsxs(Z$.div,{className:"relative flex items-center gap-3 py-1",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:[n.jsx(Z$.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}}),n.jsx(Z$.span,{className:"text-muted-foreground text-xs",initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},children:"AND"}),n.jsx(Z$.div,{className:"h-px flex-1 bg-border",initial:{scaleX:0},animate:{scaleX:1},transition:{type:"spring",stiffness:300,damping:30,mass:.5}})]}),n.jsx(gpe,{condition:e,onUpdate:e=>((e,a)=>{const n=[...u.conditions];n[e]=a,c({...u,conditions:n})})(a,e),segmentsConditions:v,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,n)=>n!==e));c({...u,conditions:a})})(a)})]},`${e.field}-${e.operator}-${a}`)))})})})]})})})}),n.jsx("div",{className:"border-t px-8 py-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(PY,f?{variant:"secondary",onClick:()=>y(!1),children:[n.jsx(ud,{className:"h-4 w-4"}),"Manual Builder"]}:{variant:"secondary",onClick:()=>{c({...u,conditions:[...u.conditions,{field:v.conditions[0].field,operator:v.conditions[0].operators[0],value:[]}]})},children:[n.jsx(rd,{className:"h-4 w-4"}),"Add Condition"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(PY,{variant:"destructive",onClick:()=>a(!1),children:"Cancel"}),n.jsx(PY,{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:n,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!==bY.EXISTS&&0===a.value.length)return{valid:!1,error:`Please ensure a value is selected for ${a.field}`};if(a.operator===bY.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!==bY.EQUALS_MONTH_DAY&&a.operator!==bY.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(A(a)&&a.operator!==bY.BETWEEN_MONTH_DAY&&a.operator!==bY.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(A(a)&&a.value.length>1)return{valid:!1,error:`Between dates can only have a single value for ${a.field}`};if(A(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("type"in e.startDate&&"relative"===e.startDate.type&&"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 n=e=>{if(e.unit===Zhe.DAYS)return e.value??0;throw tY(e.unit,Zhe)};if("before"===e.startDate.direction&&n(e.startDate)>n(e.endDate))return{valid:!1,error:`Start date must be before end date for ${a.field}`};if("after"===e.startDate.direction&&n(e.startDate)<n(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(!n)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=v?.conditions.find((a=>a.field===e.field));return a?.type===yY.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:`${Eh("engage:segment")} updated successfully`}),a(!1),t?.(e)},onError:()=>{i({title:`Error updating ${Eh("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}}):p({name:u.name,description:u.description,conditions:u.conditions},{onSuccess:e=>{i({title:`${Eh("engage:segment")} created successfully`}),t?.(e?.id??!1),a(!1)},onError:()=>{i({title:`Error creating ${Eh("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}})}catch(s){i({title:`Error saving ${Eh("engage:segment")}`,description:"Please try again",variant:"destructive"}),t?.("error")}finally{l(!1)}},disabled:s||g,children:s||g?n.jsxs(n.Fragment,{children:[n.jsx(Wc,{className:"mr-2 h-4 w-4 animate-spin"}),e?"Updating...":"Creating..."]}):e?"Update":"Create"})]})]})})]})},"manual-builder-style")]})}function bpe({open:e,setOpen:a,segmentId:t,onSegmentUpdated:i}){return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"flex max-h-[86vh] flex-col gap-0 overflow-visible max-w-6xl w-full",hideCloseButton:!0,children:[n.jsxs(kO,{children:[n.jsxs($G,{children:[Eh("engage:segment")," Builder"]}),n.jsxs(YG,{children:["Build a ",Eh("engage:segment")," to target your audience"]})]}),n.jsx(kpe,{segmentId:t,setOpen:a,onSegmentUpdated:e=>{i?.(e),a(!1)}})]})})}const Spe=()=>n.jsx(Mae,{title:`These are estimated numbers of ${Eh("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.`}),Ape=({value:e,label:a,percentage:t,variant:i,isLoading:r,selected:o})=>n.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":""),style:{containerType:"inline-size"},"data-card-container":!0,children:[n.jsxs("div",{className:"flex flex-col gap-1 items-start w-full min-w-0",children:[n.jsx("div",{className:"flex items-baseline gap-2 w-full min-w-0 @container/num",children:r?n.jsx("span",{className:"animate-pulse",children:"..."}):n.jsxs(n.Fragment,{children:[n.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!==t&&e.toLocaleString().replace(/,/g,"").length<5&&n.jsxs("span",{className:"text-muted-foreground/50 text-sm hidden @[120px]/num:inline",children:["(",t,"%)"]})]})}),n.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})]}),n.jsx("p",{className:"text-sm text-muted-fore hidden @[250px]/card:inline mt-1",children:1===e?"contact":"contacts"})]}),wpe=({countResponse:e})=>{const t=a.useMemo((()=>e?.recipients?e.recipients.reduce(((a,n)=>({total:e.count,emails:a.emails+(n.email?1:0),phones:a.phones+(n.phone?1:0)})),{total:0,emails:0,phones:0}):{total:0,emails:0,phones:0}),[e]),i=e=>Math.round(e/(t.total||1)*100);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fce,{children:"Estimated Matches"}),n.jsx(Spe,{})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 md:mb-6 w-full gap-4 mt-3 px-1",children:[n.jsx(Ape,{value:t.total,label:"Total",variant:"default",isLoading:void 0===e}),n.jsx(Ape,{value:t.emails,label:"Subscribed to Email",percentage:i(t.emails),variant:"blue",isLoading:void 0===e}),n.jsx(Ape,{value:t.phones,label:"Subscribed to SMS",percentage:i(t.phones),variant:"green",isLoading:void 0===e})]})]})},Cpe=({recipients:e})=>{if(!e?.length)return null;const a=e.filter((e=>e.firstName||e.lastName));return n.jsx("div",{className:"bg-foreground/5 rounded-lg h-full relative overflow-hidden",children:n.jsx("div",{className:"absolute inset-0 w-full h-full overflow-y-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{className:"sticky top-0 bg-foreground/5 backdrop-blur-sm",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Name"}),n.jsx("th",{className:"px-3 sm:px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Contact"})]})}),n.jsx("tbody",{className:"divide-y divide-gray-200/50",children:a.map(((e,a)=>n.jsxs("tr",{className:"hover:bg-white/50 transition-colors",children:[n.jsx("td",{className:"px-3 sm:px-4 py-3 text-sm text-gray-900",children:`${e.firstName||""} ${e.lastName||""}`.trim()}),n.jsx("td",{className:"px-3 sm:px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:[e.email&&n.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&&n.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)))})]})})})},Mpe=({onSelectionChange:e,defaultValue:t="all",canEditAudience:i=!0})=>{const[r,o]=a.useState(t),s=a=>{i&&(o(a),e?.(a))};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fce,{children:"Filter"}),!i&&n.jsx(Mae,{title:"You cannot edit the audience unless you are in draft mode"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 p-1",children:[n.jsx(BY,{onClick:()=>s("all"),title:`All ${Eh("engage:user",{count:2})}`,subtitle:"Send to everyone",icon:n.jsx(zY.UsersIcon,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"all"===r,disabled:!i}),n.jsx(BY,{onClick:()=>s("segments"),title:`Select ${Eh("engage:user",{count:2})}`,subtitle:`Choose from ${Eh("engage:segment",{count:2})}`,icon:n.jsx(zY.UserEdit,{className:"w-5 h-5 mb-2 text-gray-600"}),selected:"segments"===r,disabled:!i})]})]})},Tpe=({segments:e,allSegments:t,onAddSegment:i,onRemoveSegment:r,setOpenCreateSegmentDialog:o,canEditAudience:s=!0})=>{const[l,u]=a.useState([]),c=t.map((e=>({label:e.name,value:e.id})));return a.useEffect((()=>{u(e)}),[e]),n.jsx("div",{children:n.jsx(tue,{canOpen:s,selectedValues:l,setSelectedValues:u,options:c,onValueChange:a=>{const n=a.filter((a=>!e.includes(a))),t=e.filter((e=>!a.includes(e)));n.forEach(i),t.forEach(r)},placeholder:"Select segments",maxCount:5,extraCommandItems:[e=>n.jsxs(Use,{onSelect:()=>{e(!0),o(!0)},className:"cursor-pointer",children:[n.jsx(zY.PlusIcon,{className:"w-4 h-4"}),"New"]},"new-segment")]})})},Npe=({includedSegments:e,excludedSegments:t,handleAddSegment:i,handleRemoveSegment:r,setOpenCreateSegmentDialog:o,segments:s,defaultIsExcludeOpen:l=!1,canEditAudience:u=!0})=>{const[c,d]=a.useState(l);return n.jsxs("div",{children:[n.jsx(Tpe,{segments:e,allSegments:s||[],onAddSegment:e=>i(e,"include"),onRemoveSegment:e=>r(e,"include"),setOpenCreateSegmentDialog:o}),n.jsx("div",{className:"border-t border-gray-200 my-8"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(PY,{onClick:()=>{u&&d(!c)},className:"flex items-center gap-1 transition-colors",size:"sm",children:[n.jsx(Z$.div,{animate:{rotate:c?180:0},transition:{duration:.2},children:n.jsx(zY.DropdownMenuTrigger,{className:"w-5 h-5"})}),n.jsx("span",{children:"Don't send to"})]}),n.jsx(dV,{children:c&&n.jsx(Z$.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeInOut"},children:n.jsx(Tpe,{canEditAudience:u,segments:t,allSegments:s||[],onAddSegment:e=>i(e,"exclude"),onRemoveSegment:e=>r(e,"exclude"),setOpenCreateSegmentDialog:o})})})]})]})},Epe=({title:e="Preview Audience"})=>{const t=AY(),[i,r]=a.useState("all"),[o,s]=a.useState(t?.includeSegmentIds||[]),[l,u]=a.useState(t?.excludeSegmentIds||[]),[c,d]=a.useState(!1),[m,h]=a.useState(!1),{segments:p,isLoading:g}=pY(),{updateAutomation:v}=na(t?.id??""),[f,y]=a.useState(void 0),k=1===o.length&&0===l.length&&void 0!==p?.find((e=>e.type===kY.ALL_USERS&&e.id===o[0]));a.useEffect((()=>{t&&!m&&(1===o.length&&void 0!==p?.find((e=>e.type===kY.ALL_USERS&&e.id===o[0]))?r("all"):r("segments"),dY({includeSegments:o,excludeSegments:l}).then((e=>{y(e)})),h(!0))}),[t,k,m,o,l,p]);a.useEffect((()=>{t&&m&&(JSON.stringify(o)===JSON.stringify(t.includeSegmentIds)&&JSON.stringify(l)===JSON.stringify(t.excludeSegmentIds)||(v({includeSegments:o,excludeSegments:l}),dY({includeSegments:o,excludeSegments:l}).then((e=>{y(e)}))))}),[o,l,t,m,v]);const b=t?.status===ca.DRAFT;return n.jsxs(Jce,{title:e,children:[!g&&p&&m?n.jsxs("div",{className:"flex gap-8 w-full pb-4 px-4",children:[n.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:[n.jsx(wpe,{countResponse:f}),n.jsx(Mpe,{onSelectionChange:e=>{if(r(e),"all"===e){const e=p?.find((e=>e.type===kY.ALL_USERS));if(!e)return;s([e.id]),u([])}},defaultValue:i,canEditAudience:b}),n.jsx(dV,{children:"segments"===i&&n.jsx(Z$.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:n.jsx(Npe,{canEditAudience:b,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:p,defaultIsExcludeOpen:l.length>0})})})]}),n.jsx("div",{className:"flex flex-col flex-1 relative overflow-hidden",children:f?.recipients&&n.jsx(Cpe,{recipients:f.recipients})})]}):n.jsx("div",{children:n.jsx(NY,{text:["Fetching segments","Finishing up"]})}),n.jsx(bpe,{open:c,setOpen:d,onSegmentUpdated:e=>{e&&s((a=>[...a,e]))}})]})},xpe=()=>n.jsx(Epe,{title:"Select Audience"}),Ppe=()=>{const{channelSenders:e}=E9(),{channelAccounts:t}=M9(),i=wY(),{updateCommunicationGroup:r}=Ze(),{state:{selectedChannels:o},setSelectedChannels:s}=a.useContext(A9),l=AY(),{data:u}=L9(),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((()=>zie({channelSenders:e?.results??[],channelAccounts:t?.results??[]})),[e?.results,t?.results]),m=a.useMemo((()=>mee({channelSenders:e?.results??[],channelAccounts:t?.results??[],smsApplication:u})),[e?.results,t?.results,u]);if(!o||!d||!m)return n.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:n.jsx(NY,{text:["Fetching Content..."]})});const h=d.length>0,p=m.length>0;return n.jsx("div",{className:"flex flex-col gap-4 flex-shrink-0",children:n.jsx("div",{className:"bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",children:n.jsx(yce,{automationType:l?.triggerMetadata?.triggerType,selectedChannels:o,setSelectedChannels:c,hasEmailChannelSenders:h,hasSmsChannelSenders:p})})})};var jpe=(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))(jpe||{});const Lpe="https://assets.embedreach.com/defaults/logo-placeholder-128.png",Bpe="You have not uploaded a custom logo. Please make sure to double check your email before sending!",zpe=()=>{const e=AY(),n=wY(),{state:{selectedChannels:t}}=a.useContext(A9),{data:i}=L9(),{channelSenders:r}=E9(),{channelAccounts:o}=M9(),s=mee({channelSenders:r?.results??[],channelAccounts:o?.results??[],smsApplication:i}),l=a.useCallback((async a=>e?await(async e=>{const{currentStep:a,automation:n,communicationGroup:t,selectedChannels:i,smsChannelSenders:r}=e;switch(a){case jpe.SelectAudience:return{canMove:n.includeSegmentIds.length>0,errorMessage:"Please ensure you have selected at least one segment"};case jpe.SelectSenders:return{canMove:i.length>0,errorMessage:"Please ensure you have selected at least one channel"};case jpe.EditSmsContent:{const e=n.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(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};const a=r.find((e=>e.channelSender.id===t.smsChannelSenderId));return a?t.smsMessageBody?a.smsApplication&&a.smsApplication.status!==dee.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 jpe.EditEmailContent:{const e=n.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(!t)return{canMove:!1,errorMessage:"Please ensure you have selected a communication group"};if(!t.emailChannelSenderId)return{canMove:!1,errorMessage:"Please ensure you have selected a email sender"};if(!t.emailHtmlBody||!t.emailSubject)return{canMove:!1,errorMessage:"Please ensure you have a email body and subject"};let a=null;return t.emailHtmlBody?.includes(Lpe)&&(a=Bpe),{canMove:!0,errorMessage:null,warningMessage:a}}case jpe.Schedule:{if(!n.triggerMetadata)return{canMove:!1,errorMessage:"Please make sure to select a time to send before starting!"};if(n.triggerMetadata.triggerType!==oa.ONE_TIME)return{canMove:Boolean(n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:null};if(!n.triggerMetadata?.scheduledAt)return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${Eh("engage:broadcast")}`};if(!Boolean(n.triggerMetadata?.scheduledAt&&("now"===n.triggerMetadata.scheduledAt||"now"!==n.triggerMetadata.scheduledAt&&new Date(n.triggerMetadata.scheduledAt)>new Date)))return{canMove:!1,errorMessage:`Please ensure you have set a valid future date for your ${Eh("engage:broadcast")}`};if(!Boolean(n.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=n.triggerMetadata;return{canMove:Boolean(e.scheduledAt&&("now"===e.scheduledAt||new Date(e.scheduledAt)>new Date)&&n.actionData?.some((e=>"send_communication"===e.actionType&&e.actionMetadata.communicationGroupId))),errorMessage:`Please ensure you have set a valid future date for your ${Eh("engage:broadcast")}`}}case jpe.PreviewAndSend:return{canMove:!0,errorMessage:null};default:g9(a,jpe)}})({currentStep:a,automation:e,communicationGroup:n,selectedChannels:t,smsChannelSenders:s}):{canMove:!1,errorMessage:`${Eh("engage:broadcast")} not loaded`}),[e,n,t,s]);return{validateStep:l}},Rpe=({onFinish:e,getExtraMergeFields:t,onBeforeSchedule:i})=>{const r=AY(),o=wY(),{updateAutomation:s}=na(r?.id||""),{estimatedMatchesStats:l}=(e=>{const{data:n}=gY({automationId:e?.id??"",includeSegments:e?.includeSegmentIds??[],excludeSegments:e?.excludeSegmentIds??[]}),t=a.useMemo((()=>n?.recipients?n.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}),[n?.recipients]);return{estimatedMatches:n,estimatedMatchesStats:t}})(r??void 0),{state:{selectedChannels:u}}=a.useContext(A9),{validateStep:c}=zpe(),[d,m]=a.useState([]),{data:h}=L9(),[p,g]=a.useState(!1),{channelSenders:v}=E9(),{channelAccounts:f}=M9(),[y,k]=a.useState(jpe.SelectAudience);if(a.useEffect((()=>{if(null!==r&&null!==o){const e=mee({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});m((({automation:e,communicationGroup:a,selectedChannels:t,smsChannelSenders:i})=>e?[{id:"audience",title:"Audience",step:1,isValid:()=>e.includeSegmentIds.length>0,content:n.jsx(Nae,{content:n.jsx(xpe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===oa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},{id:"senders",title:"Channel Senders",step:2,isValid:()=>0!==t.length,content:n.jsx(Nae,{content:n.jsx(Ppe,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:e.triggerType===oa.ONE_TIME,backDisabled:!1,nextDisabled:()=>!1}},...t.includes("email")?[{id:"edit-email-content",title:"Edit Email Content",step:3,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!n&&!!a.emailChannelSenderId&&!(!a.emailHtmlBody||!a.emailSubject)},content:n.jsx(Nae,{content:n.jsx(Rie,{})},"audience"),footerConfig:{backText:"",nextText:"",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],...t.includes("sms")?[{id:"edit-sms-content",title:"Edit SMS Content",step:4,isValid:()=>{const n=e.actionData?.find((e=>"send_communication"===e.actionType));return!!(n&&n.actionMetadata.communicationGroupId&&a.smsChannelSenderId&&a.smsMessageBody)},content:n.jsx(Nae,{content:n.jsx(lue,{})},"audience"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}}]:[],{id:"schedule",title:"Schedule",step:5,isValid:()=>Boolean(e.triggerMetadata?.triggerType===oa.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:n.jsx(Nae,{className:"flex-1",content:n.jsx(qhe,{})},"schedule"),footerConfig:{backText:"Back",nextText:"Next",hideBack:!1,backDisabled:!1,nextDisabled:()=>!1}},{id:"send",title:"Send",step:6,isValid:()=>Boolean(e.triggerMetadata?.triggerType===oa.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:n.jsx(Nae,{className:"flex-1",content:n.jsx(Wce,{})},"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!==dee.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===dee.APPROVED))||null===a.smsChannelSenderId&&null===a.emailChannelSenderId}}}]:[])({automation:r,communicationGroup:o,selectedChannels:u,smsChannelSenders:e}))}}),[r,o,t,u,v?.results,f?.results,h]),!(r&&y&&o&&d.length))return n.jsx("div",{className:"flex-1 flex flex-col @container justify-center items-center h-[500px]",children:n.jsx(NY,{text:[`Fetching ${Eh("engage:broadcast")} data`,"Finishing up"]})});const b=async()=>{const{canMove:a,errorMessage:n,warningMessage:t}=await c(y);a?(t&&Oe({title:t,variant:"warning"}),y===jpe.PreviewAndSend?await(async()=>{if(null===o.emailChannelSenderId&&null===o.smsChannelSenderId)return void Oe({title:"Oops!",description:"Please select an email sender or sms sender",variant:"destructive"});const a=mee({channelSenders:v?.results??[],channelAccounts:f?.results??[],smsApplication:h});if(o.smsChannelSenderId){const e=a.find((e=>e.channelSender.id===o.smsChannelSenderId));if(e?.smsApplication?.application&&e?.smsApplication.status!==dee.APPROVED)return void Oe({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:ca.ACTIVE},{onSuccess:()=>{Oe({title:`${Eh("engage:broadcast")} scheduled!`}),e()},onError:()=>{Oe({title:"Oops!",description:"Please contact your administrator",variant:"destructive"})}}):Oe({title:"Oops!",description:a,variant:"destructive"})}catch(n){Oe({title:"Oops!",description:"An error occurred while checking scheduling conditions",variant:"destructive"})}else s({status:ca.ACTIVE}),Oe({title:`${Eh("engage:broadcast")} scheduled!`}),e()})():k(y===jpe.SelectSenders&&1===u.length&&"sms"===u[0]||y===jpe.EditEmailContent&&1===u.length&&"email"===u[0]?y+2:y+1)):Oe({title:"Oops!",description:n,variant:"destructive"})},S=()=>{y>jpe.SelectAudience&&k(y===jpe.EditSmsContent&&1===u.length&&"sms"===u[0]?y-2:y-1)},A=()=>{e()};return n.jsxs("div",{className:"flex-1 flex flex-col @container h-full min-h-0",children:[n.jsxs("header",{className:"w-full flex items-center gap-4 h-16 px-6",children:[n.jsx("h1",{className:"text-xl font-bold leading-none",children:r.name}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsx(JY,{variant:vae(r.status),children:v9({status:r.status,automationType:r.triggerType})})})]}),n.jsxs("main",{className:"flex gap-4 flex-1 min-h-0",children:[n.jsx("div",{className:"hidden @[1000px]:block",children:n.jsx("nav",{className:"space-y-0 w-50 self-start pr-6 pl-8 pt-4 ",children:d.map((e=>n.jsx("div",{className:`\n rounded-md transition-colors\n ${e.step===y?"bg-[var(--reach-secondary)] text-[var(--reach-primary-foreground)] font-medium":e.step<y?"text-muted-foreground hover:bg-muted":"text-muted-foreground/60"}\n `,children:n.jsx(aQ,{label:e.title,isActive:e.step===y,isCompleted:e.isValid(),onClick:async()=>{if(!p)if(e.step>y){const{canMove:a,errorMessage:n,warningMessages:t}=await(async e=>{if(e<=y)return{canMove:!0,errorMessage:null};g(!0);try{const a=[];for(let n=y;n<e;n++){const{canMove:e,errorMessage:t,warningMessage:i}=await c(n);if(!e)return{canMove:e,errorMessage:t};i&&a.push(i)}return{canMove:!0,errorMessage:null,warningMessages:a}}finally{g(!1)}})(e.step);if(a){if(t&&t.length>0)for(const e of t)Oe({title:e,variant:"warning"});k(e.step)}else n&&Oe({title:"Cannot navigate to this step",description:n,variant:"destructive"})}else k(e.step)}})},e.step)))})}),n.jsx("section",{className:"flex-1 mr-6 w-full relative rounded-xl bg-gray-100 ml-6 @[1000px]:ml-0",children:n.jsx("div",{className:" overflow-y-auto top-0 left-0 right-0 bottom-0 flex-1 h-full flex-col flex",children:n.jsx(dV,{children:n.jsx(EY,{className:"pt-0 h-full",children:d.find((e=>e.step===y))?.content},y)})})})]}),n.jsx("footer",{className:"w-full flex justify-end shadow-md z-10 items-center h-16 px-6",children:n.jsx(Tae,{handleSkipAndSaveAsDraft:A,handleBack:S,handleNext:b,hideBack:d.find((e=>e.step===y))?.footerConfig.hideBack??!1,backText:d.find((e=>e.step===y))?.footerConfig.backText??"Back",nextText:d.find((e=>e.step===y))?.footerConfig.nextText??"Next",backDisabled:d.find((e=>e.step===y))?.footerConfig.backDisabled??!1,nextDisabled:d.find((e=>e.step===y))?.footerConfig.nextDisabled()??!1,getInfoTooltipTitle:d.find((e=>e.step===y))?.footerConfig.getInfoTooltipTitle??void 0})})]})},_pe=({children:e,actionId:t})=>{const{setActionId:i}=a.useContext(uY);return a.useEffect((()=>{i(t)}),[t,i]),n.jsx("div",{children:n.jsx(w9,{children:e})})},Dpe=()=>n.jsxs("div",{children:[n.jsx("div",{className:KY,children:n.jsx(zY.OneTimeBroadcast,{})}),n.jsx("h3",{className:HY,children:Eh("engage:broadcast")}),n.jsx("p",{className:OY,children:"Send a single message to your current list, like announcing a sale or newsletter."})]}),Kpe=()=>n.jsxs("div",{children:[n.jsx("div",{className:IY,children:"Coming Soon"}),n.jsx("div",{className:KY,children:n.jsx(zY.RealtimeActivity,{})}),n.jsx("h3",{className:HY,children:"Realtime Activity"}),n.jsx("p",{className:OY,children:"Responds to immediate actions your contacts take, like abandoned carts, form submissions, or appointment bookings."})]}),Hpe=({selectedType:e,setAutomationName:a,automationName:t,setAutomationDescription:i,automationDescription:r})=>n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 max-w-lg mx-auto",children:[n.jsxs("h2",{className:"text-2xl font-semibold mb-8 text-center",children:["Name Your"," ",Eh(e===oa.ONE_TIME?"engage:broadcast":"engage:trigger_based")]}),n.jsxs("div",{className:"w-full space-y-6",children:[n.jsx("div",{className:"bg-gray-50 p-6 rounded-xl items-center justify-center text-center",children:(()=>{switch(e){case oa.ONE_TIME:return n.jsx(Dpe,{});case oa.TRIGGER_BASED:return n.jsx(Kpe,{});default:throw g9(e,oa)}})()}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationName",className:"block text-sm font-medium text-gray-900",children:"Name"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Only visible to your team"})]}),n.jsx(r4,{id:"automationName",type:"text",value:t,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})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-2",children:[n.jsx("label",{htmlFor:"automationDescription",className:"block text-sm font-medium text-gray-900",children:"Description"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"Optional"})]}),n.jsx(iue,{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 ${Eh("engage:broadcast").toLowerCase()}`})]})]})]})]}),Ope=({onClose:e,automationType:t,currentStep:i,setCurrentStep:r,getExtraMergeFields:o,onBeforeSchedule:s})=>{const{createAutomation:l,isCreating:u}=aa(),[c,m]=a.useState(!1),[h,p]=a.useState(void 0),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(t?{name:void 0,description:void 0,type:t}:{name:void 0,description:void 0,type:void 0}),S=void 0!==k.name&&void 0!==k.type&&""!==k.name;a.useEffect((()=>{if(k.type&&!k.name&&!f){const e=new Date,a=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),n=e.toLocaleDateString([],{month:"long",day:"numeric"}),t=`${Eh("engage:broadcast")} ${n} ${a}`,i="";b((e=>({...e,name:t,description:i}))),y(!0)}}),[k,f]);if(u||c)return n.jsx("div",{className:DY,children:n.jsx(NY,{text:[`Creating ${Eh("engage:broadcast")}`,"Finishing up"]})});return n.jsxs("div",{className:GG("relative overflow-y-auto h-full p-8",i===jY.OneTimeWizard?"max-h-[90vh]":"h-full"),children:[n.jsx(dV,{mode:"wait",children:n.jsx(EY,{className:"h-full",children:(()=>{switch(i){case jY.ChooseAutomationType:return n.jsx(GY,{onNext:e=>{b({...k,type:e}),r(jY.SetAutomationName)}});case jY.SetAutomationName:return k.type?n.jsx(Hpe,{selectedType:k.type,setAutomationName:e=>{b({...k,name:e})},automationName:k.name??"",setAutomationDescription:e=>{b({...k,description:e})},automationDescription:k.description??""}):null;case jY.OneTimeWizard:return h&&g?n.jsx(MY,{automationId:h,children:n.jsx(_pe,{actionId:g,children:n.jsx(Rpe,{onFinish:()=>{e?.(h)},getExtraMergeFields:o,onBeforeSchedule:s})})}):null;default:throw tY(i,jY)}})()},i)}),i!==jY.OneTimeWizard&&n.jsx("div",{className:"pt-2",children:n.jsx(LY,{onClose:e,currentStep:i,setCurrentStep:r,isDisabled:!S,createAutomation:async()=>{if(!S||!k.name||!k.type)return;m(!0);l({name:k.name,type:k.type,description:k.description},{onSuccess:async a=>{if(a.id){const n=await(async e=>(await Pe(`${d}`,{method:"POST",body:JSON.stringify(e)})).data)({}),i=nY().toString();await Le(a.id,{action:[{actionType:"send_communication",actionMetadata:{actionType:"send_communication",communicationGroupId:n.id,currentActionId:i}}]}),p(a.id),await Ue({automationId:a.id,actionId:i}),t===oa.ONE_TIME?(r(jY.OneTimeWizard),v(i),m(!1)):e?.(a.id)}else e?.("error")},onError:()=>{e?.("error")},onSettled:()=>{b({name:void 0,description:void 0,type:void 0})}})},disableBackButton:void 0!==t})})]})};function Ipe({open:e,setOpen:t,onClose:i,automationType:r,getExtraMergeFields:o,replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c}){const[d,m]=a.useState(r?jY.SetAutomationName:jY.ChooseAutomationType);return a.useEffect((()=>{e&&m(r?jY.SetAutomationName:jY.ChooseAutomationType)}),[e,r]),n.jsx(SO,{children:n.jsx(AO,{replyToSettingsText:s,replyToSettingsLink:l,fromNameSettingsText:u,fromNameSettingsLink:c,children:n.jsx(VG,{open:e,onOpenChange:t,children:n.jsxs(WG,{hideCloseButton:d===jY.OneTimeWizard,className:`flex max-h-[86vh] ${d===jY.OneTimeWizard?"max-w-[90vw]":"max-w-4xl"} flex-col gap-0 overflow-visible p-0`,children:[n.jsx(qG,{children:n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs(kO,{children:[n.jsx($G,{className:"text-3xl font-normal",children:"Create Automation"}),n.jsx(YG,{children:"Create a new automation to send messages to your customers."})]})})}),n.jsx(Ope,{onClose:e=>{i?.(e),t(!1)},automationType:r,currentStep:d,setCurrentStep:m,getExtraMergeFields:o})]})})})})}const Gpe=({tabs:e,activeTab:t,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===t))];a&&u({width:a.offsetWidth,left:a.offsetLeft})}),[t,e]);const c=e.find((e=>e.id===t));return n.jsxs("div",{className:"flex flex-col gap-4 w-full overflow-x-hidden h-full",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"relative flex items-center gap-8 "+("left"===r?"w-full justify-start":"w-full justify-center"),children:[n.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)=>n.jsx("button",{ref:e=>s.current[a]=e,onClick:()=>i(e.id),className:GG("relative px-7 py-3 transition-all duration-200 text-lg",t!==e.id&&"text-muted-foreground",o&&"text-sm"),children:e.label},e.id)))]})}),n.jsx("div",{className:"relative overflow-hidden flex-grow min-h-0",children:n.jsx("div",{className:"relative h-full",children:c?c.content:null})})]})},Vpe=e=>{if(!e)return"$0.00";const a="string"==typeof e?e.replace(/,/g,""):e,n=Number(a);return Number.isNaN(n)?"$0.00":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(n)},Fpe="reach-styles-module__header___-izE2",Jpe="reach-styles-module__title___n1hA9",Upe="reach-styles-module__description___EvXM-",Wpe="reach-styles-module__content___okv68",qpe="reach-styles-module__footer___YA4U4",Zpe=kc("reach-styles-module__base___zJcoE",{variants:{variant:{default:"reach-styles-module__default___88Q0d",destructive:"reach-styles-module__destructive___5EWhN",outline:"reach-styles-module__outline___gj9sC",secondary:"reach-styles-module__secondary___cN5Wj"}},defaultVariants:{variant:"default"}}),$pe=r.forwardRef((({className:e,variant:a,...t},i)=>n.jsx("div",{ref:i,className:pm(Zpe({variant:a}),e),...t})));$pe.displayName="Card";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Fpe,e),...a}))).displayName="CardHeader";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Jpe,e),...a}))).displayName="CardTitle";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Upe,e),...a}))).displayName="CardDescription";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(Wpe,e),...a}))).displayName="CardContent";r.forwardRef((({className:e,...a},t)=>n.jsx("div",{ref:t,className:pm(qpe,e),...a}))).displayName="CardFooter";const Ype=({Icon:e,title:a,value:t,tooltipText:i,change:r})=>n.jsxs($pe,{className:"relative flex flex-col justify-between min-h-[130px] transition-all duration-300 hover:shadow-md p-4",children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsx("div",{className:"rounded-lg p-2 bg-primary/10 flex items-center justify-center",children:n.jsx(e,{className:"w-5 h-5 text-primary"})}),n.jsx("div",{className:"absolute top-3 right-3",children:n.jsx(Mae,{title:i})})]}),n.jsxs("div",{className:"mt-4",children:[n.jsx("div",{className:"text-2xl font-bold leading-tight text-primary",children:t}),n.jsx(Fce,{children:a})]}),r&&n.jsx("div",{className:"absolute bottom-3 right-3",children:n.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})})]}),Qpe=({activeTab:e,automation:a})=>{if(!a)return null;const t={sales:[{Icon:zY.SalesAmount,title:"Order Amount",value:Vpe(a.derivedRevenue),tooltipText:"Total derived revenue from this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(Ype,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},Xpe=({activeTab:e,statistics:a})=>{const t={email:[{Icon:zY.MessagesSent,title:"Emails Sent",value:a.email.numberSent,tooltipText:"Total number of emails that were successfully sent in this campaign"},{Icon:zY.OpenRate,title:"Open Rate",value:`${(100*a.email.openPercentage).toFixed(2)}%`,tooltipText:"Percentage of recipients who opened the email out of total emails delivered"},{Icon:zY.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"},{Icon:zY.LinksClicked,title:"Links Clicked",value:a.email.linksClicked,tooltipText:"Total number of times recipients clicked on links within the email"},{Icon:zY.SpamComplies,title:"Spam Complaints",value:`${(100*a.email.spamComplaintRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who marked this email as spam"},{Icon:zY.UnsubscribeRate,title:"Unsubscribe Rate",value:`${(100*a.email.unsubscribedRate).toFixed(2)}%`,tooltipText:"Percentage of recipients who unsubscribed after receiving this email"}],sms:[{Icon:zY.MessagesSent,title:"SMS Sent",value:a.sms.numberSent,tooltipText:"Total number of SMS messages that were successfully sent in this campaign"}]};return n.jsx("div",{className:"grid gap-2 transition-all duration-300 grid-cols-3 pb-4",children:t[e].map(((e,a)=>n.jsx(Ype,{Icon:e.Icon,title:e.title,value:e.value,tooltipText:e.tooltipText},a)))})},ege=({automationId:e,includeSales:t=!1,includeSms:i=!1,automation:r})=>{const[o,s]=a.useState("email"),{statistics:l,isLoading:u}=ta(e);if(u||!l)return n.jsx("div",{className:"bg-white rounded-2xl w-full p-6 space-y-4 relative h-[14.05rem]",children:n.jsx(NY,{text:[`Fetching ${Eh("engage:insight",{count:2})}`,"Finishing up"]})});const c=[{id:"email",label:`Email ${Eh("engage:insight",{count:2})}`,content:n.jsx(Xpe,{activeTab:"email",statistics:l})},...i?[{id:"sms",label:`SMS ${Eh("engage:insight",{count:2})}`,content:n.jsx(Xpe,{activeTab:"sms",statistics:l})}]:[],...t?[{id:"sales",label:`Sales ${Eh("engage:insight",{count:2})}`,content:n.jsx(Qpe,{activeTab:"sales",automation:r})}]:[]];return n.jsx(Gpe,{tabs:c,activeTab:o,onTabChange:e=>s(e),tabsLocation:"left"})},age={all:["website"],content:()=>[...age.all,"content"],analyze:()=>[...age.all,"analyze"],brandSettings:()=>[...age.all,"brand-settings"]},nge=async()=>(await Pe("/web-presence/brand-settings",{method:"POST"})).data,tge=({isLoading:e,brandSettings:t,onComplete:i})=>{const[r,o]=a.useState(0),s=[{text:"Analyzing your brand palette",icon:ed},{text:"Extracting your visual identity",icon:Ic},{text:"Discovering your brand personality",icon:Vc},{text:"Crafting your email style",icon:Zc},{text:"Finalizing your brand profile",icon:Rc}];a.useEffect((()=>{if(!e)return;const a=setInterval((()=>{o((e=>{const n=e+1;return n>=s.length?(clearInterval(a),setTimeout((()=>{i()}),1500),e):n}))}),2500);return()=>clearInterval(a)}),[e,i,s.length]);return n.jsx(Z$.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:n.jsxs("div",{className:"flex flex-col items-center gap-8 max-w-2xl w-full",children:[n.jsx(Z$.div,t?.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:n.jsx("img",{src:t.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:t?.brandName?n.jsx("span",{className:"text-4xl sm:text-5xl font-bold text-white",children:t.brandName.charAt(0)}):n.jsx(md,{className:"w-12 h-12 sm:w-16 sm:h-16 text-white"})}),n.jsx(Z$.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}`),n.jsx("div",{className:"flex items-center justify-center space-x-8 sm:space-x-12",children:s.map(((e,a)=>{const t=a<=r,i=a===r;return n.jsxs(Z$.div,{className:"relative flex items-center justify-center w-12 h-12 rounded-full border-2 "+(t?"bg-card shadow-md border-primary":"bg-muted border-muted-foreground/30"),initial:{scale:.8,opacity:.5},animate:{scale:i?1.1:1,opacity:t?1:.5},transition:{duration:.3},children:[n.jsx(e.icon,{className:"w-5 h-5 "+(t?"text-primary":"text-muted-foreground")}),i&&n.jsx(Z$.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}`)}))}),n.jsx(Z$.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8,duration:.6},className:"w-full",children:n.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:n.jsxs("div",{className:"h-full flex flex-col justify-center",children:[0===r&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80 text-center",children:"Extracted Color Palette"}),n.jsx("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:[t?.primaryColor,...t?.secondaryColors||[]]?.slice(0,4).map(((e,a)=>n.jsx("div",{className:"flex flex-col items-center gap-1",children:n.jsx("div",{className:"w-10 h-10 rounded-xl border-2 border-white/50 shadow-md",style:{backgroundColor:e}})},a)))}),n.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"Brand colors identified"})]}),1===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Identity"}),t?.brandName?n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-xl font-bold",children:t.brandName}),t.brandTagline&&n.jsxs("div",{className:"text-sm text-muted-foreground italic px-4",children:['"',t.brandTagline,'"']}),n.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Visual identity extracted"})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Extracting brand elements..."})]}),2===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Personality"}),t?.brandPersonality?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-center gap-4",children:[t.brandPersonality.tone&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Tone"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.tone})]}),t.brandPersonality.voice&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Voice"}),n.jsx("div",{className:"text-sm font-medium text-foreground capitalize px-2 py-1 bg-background/50 rounded-md",children:t.brandPersonality.voice})]})]}),t.brandPersonality.values&&t.brandPersonality.values.length>0&&n.jsx("div",{className:"flex justify-center gap-1 flex-wrap",children:t.brandPersonality.values.slice(0,3).map(((e,a)=>n.jsx("span",{className:"px-2 py-1 text-xs font-medium rounded-full",children:e},a)))})]}):n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand tone and voice..."})]}),3===r&&n.jsxs("div",{className:"text-center space-y-3",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Email Template Preview"}),n.jsxs("div",{className:"bg-background/60 rounded-lg p-3 border border-border/30",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("div",{className:"w-4 h-4 rounded"}),n.jsx("div",{className:"text-xs font-medium text-foreground",children:t?.brandName||"Your Brand"})]}),n.jsxs("div",{className:"text-xs text-muted-foreground text-left",children:["Email styling applied with your brand colors",t?.brandPersonality?.tone&&`, ${t.brandPersonality.tone} tone`,", and visual identity"]})]})]}),4===r&&n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-foreground/80",children:"Brand Kit Complete"}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Identity"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandName?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Colors"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.primaryColor?"✓":"—"})]}),n.jsxs("div",{className:"bg-background/40 rounded-lg p-2",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Personality"}),n.jsx("div",{className:"text-sm font-medium text-foreground",children:t?.brandPersonality?.tone?"✓":"—"})]})]})]}),(0===r&&!t?.primaryColor&&!t?.colorPalette||1===r&&!t?.brandName||2===r&&!t?.brandPersonality)&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-sm text-muted-foreground italic",children:"Analyzing brand data..."}),n.jsx("div",{className:"flex justify-center gap-1 mt-2",children:[...Array(3)].map(((e,a)=>n.jsx(Z$.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}`)]})})},ige=({setAutoParse:e,onBrandSettingsGenerated:t,onForceRefresh:i})=>{const{data:r,updateWebsite:o,isUpdatingWebsite:s,updateBrandSettings:l}=joe(),u=ke({mutationFn:nge,mutationKey:age.brandSettings()}),[c,d]=a.useState(r?.website||""),[m,h]=a.useState(!1),[p,g]=a.useState(null),[v,f]=a.useState(!1),[y,k]=a.useState(!1),b=()=>{e(!1)};return y&&p?n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(oge,{initialBrandSettings:p,onSave:()=>{p&&(l({logoBase64:p.logo_base64,primaryColor:p.primaryColor,secondaryColors:p.secondaryColors,brandTagline:p.brandTagline,brandName:p.brandName,brandPersonality:p.brandPersonality,colorPalette:p.colorPalette}),i&&i(),Oe({title:"Brand settings saved successfully 🚀",description:"Your brand identity has been updated."}),e(!1))},onBack:b,showAutoParseButton:!1})},"results"):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden",children:[n.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:n.jsxs(dV,{mode:"wait",children:[!v&&!y&&n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col h-full",children:n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 space-y-8",children:[n.jsxs("div",{className:"space-y-2 w-full max-w-md",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block text-center",children:"Your Website URL"}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 items-center",children:[n.jsx(r4,{type:"url",value:c,onChange:e=>d(e.target.value),placeholder:"https://example.com",className:"flex-1",disabled:!m}),n.jsx(dV,{mode:"wait",children:m?n.jsxs(Z$.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex gap-2",children:[n.jsx(PY,{variant:"outline",size:"sm",onClick:()=>{h(!1),d(r?.website||"")},className:"w-full sm:w-auto",children:"Cancel"}),n.jsx(PY,{size:"sm",onClick:async()=>{try{o(c),h(!1),Oe({title:"Website URL updated successfully 🎉",description:"Your website URL has been saved."})}catch(e){Oe({title:"Error updating website URL",description:"Please try again.",variant:"destructive"})}},disabled:s||!c,className:"w-full sm:w-auto",children:s?n.jsx(NY,{}):"Save Changes"})]},"save"):n.jsx(Z$.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},children:n.jsx(PY,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"w-full sm:w-auto",children:"Edit URL"})},"edit")})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 w-full max-w-2xl",children:[n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"What we'll analyze"}),n.jsxs("ul",{className:"text-sm text-gray-600 space-y-1",children:[n.jsx("li",{children:"• Your brand colors and color palette"}),n.jsx("li",{children:"• Your logo (if detectable)"}),n.jsx("li",{children:"• Your brand name and tagline"}),n.jsx("li",{children:"• Your brand's tone and personality"})]})]}),n.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg border border-gray-100",children:[n.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:"How it helps you"}),n.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."})]})]}),n.jsx(Z$.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground text-center max-w-md",children:"We'll use AI to analyze your website and extract your brand elements to create perfectly matched email templates."})]})},"url-confirmation"),v&&p&&n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 h-full",children:n.jsx(tge,{isLoading:v,brandSettings:p,onComplete:()=>{f(!1),k(!0),Oe({title:"Brand settings generated successfully!",description:"Your brand identity has been analyzed."})}})},"analyzing"),v&&!p&&n.jsx(Z$.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col items-center justify-center h-full",children:n.jsxs(Z$.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:[n.jsxs(Z$.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:[n.jsx(sd,{className:"w-12 h-12 text-primary drop-shadow-md"}),n.jsx(Z$.div,{className:"absolute inset-0 rounded-full border-2",style:{borderColor:"var(--primary)"},initial:{scale:1,opacity:.8},animate:{scale:2.5,opacity:0},transition:{duration:3,repeat:1/0,ease:"easeOut"}})]}),n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:"Analyzing your website"}),n.jsx(dV,{mode:"wait",children:n.jsx(Z$.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.5},className:"text-gray-600 max-w-md text-center px-4",children:"Generating your brand's unique visual identity and personality"},"loading-message")})]})]})},"pre-analyzing")]})}),!v&&!y&&n.jsxs(ZG,{className:"p-4",children:[n.jsx(PY,{variant:"outline",onClick:b,className:"gap-1",children:"Go Back"}),n.jsxs(PY,{onClick:async()=>{try{f(!0);const e=await u.mutateAsync();g(e),t&&t(e)}catch(e){f(!1),g(null),Oe({title:"Error generating brand settings",description:"Please try again.",variant:"destructive"})}},disabled:!c||u.isPending,className:"gap-1",children:[n.jsx(md,{className:"h-4 w-4 text-amber-500"}),u.isPending?n.jsx(NY,{}):"Analyze Website"]})]})]})},rge=["#a91919","#2563eb","#16a34a","#f59e0b","#6d28d9"],oge=({initialBrandSettings:e,onSave:t,onBack:i,showAutoParseButton:r=!0})=>{const{data:o,isLoading:s,updateBrandSettings:l,isUpdatingBrandSettings:u}=joe(),[c,d]=a.useState({}),[m,h]=a.useState(!1),[p,g]=a.useState({}),[v,f]=a.useState(""),[y,k]=a.useState(""),[b,S]=a.useState("#000000"),[A,w]=a.useState(Date.now()),[C,M]=a.useState(!1),[T,N]=a.useState(null),[E,x]=a.useState({identity:!0,colors:!0,personality:!0}),P=a.useRef(null),{toast:j}=Ie();a.useEffect((()=>{if(e)return d({brandName:e.brandName,brandTagline:e.brandTagline,logoUrl:e.logoUrl,primaryColor:e.primaryColor||"#000000",secondaryColors:e.secondaryColors||[],brandPersonality:{tone:e.brandPersonality?.tone,voice:e.brandPersonality?.voice,values:e.brandPersonality?.values||[]}}),void w(Date.now());o?.branding&&(d({brandName:o.branding.brandName||o.name,brandTagline:o.branding.brandTagline||"",logoUrl:o.branding.logoUrl||"",primaryColor:o.branding.primaryColor||"#000000",secondaryColors:o.branding.secondaryColors||[],brandPersonality:{tone:o.branding.brandPersonality?.tone,voice:o.branding.brandPersonality?.voice,values:o.branding.brandPersonality?.values||[]}}),w(Date.now()))}),[o,e]);const L=e=>{x((a=>({...a,[e]:!a[e]})))},B=e=>{g((a=>{const n={...a,[e]:!a[e]};return n[e]&&("brandName"===e?f(c.brandName||""):"brandTagline"===e?f(c.brandTagline||""):"primaryColor"===e?f(c.primaryColor||"#000000"):"tone"===e?f(c.brandPersonality?.tone||""):"voice"===e&&f(c.brandPersonality?.voice||"")),n}))},z=e=>{"brandName"===e?d((e=>({...e,brandName:v}))):"brandTagline"===e?d((e=>({...e,brandTagline:v}))):"primaryColor"===e?d((e=>({...e,primaryColor:v}))):"tone"===e?d((e=>({...e,brandPersonality:{...e.brandPersonality,tone:v||void 0}}))):"voice"===e&&d((e=>({...e,brandPersonality:{...e.brandPersonality,voice:v||void 0}}))),B(e)},R=e=>{B(e)},_=e=>{d((a=>({...a,primaryColor:e})))},D=()=>{y.trim()&&(d((e=>{const a=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:[...a,y.trim()]}}})),k(""))};return s?n.jsx("div",{className:"flex justify-center items-center h-full min-h-[500px] w-full bg-white rounded-lg shadow-sm",children:n.jsx(NY,{})}):m?n.jsx(ige,{setAutoParse:h,onForceRefresh:()=>w(Date.now())}):n.jsxs("div",{className:"w-full h-full flex flex-col bg-white rounded-lg overflow-hidden gap-4 pt-16",children:[n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 px-6 pt-2",children:[n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("identity"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Identity"})]}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(E.identity?Lc:xc,{className:"h-4 w-4"})})]}),E.identity&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Name"}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("brandName"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandName?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandName"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>z("brandName"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm font-medium",children:c.brandName})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Brand Tagline"}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("brandTagline"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.brandTagline?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{value:v,onChange:e=>f(e.target.value),className:"flex-1",autoFocus:!0,placeholder:"Your brand's tagline"}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>R("brandTagline"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full hover:bg-gray-100",onClick:()=>z("brandTagline"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"p-3 bg-gray-50 rounded-lg border border-gray-200 text-sm italic",children:c.brandTagline||"No tagline set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-3",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Logo"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Square image, 128x128px, PNG recommended"})]})}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"w-24 h-24 rounded-lg border-2 border-dashed border-gray-200 flex items-center justify-center bg-gray-50 overflow-hidden",children:c.logoUrl?n.jsx("img",{src:c?.logoUrl,alt:c.brandName||"Brand logo",className:"w-full h-full object-contain"},A):n.jsx(Fc,{className:"h-10 w-10 text-gray-300"})}),n.jsxs("div",{className:"absolute inset-0 bg-black bg-opacity-40 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:[n.jsx("input",{type:"file",ref:P,onChange:e=>{const a=e.target.files?.[0];if(a){const e=new FileReader;e.onloadend=async()=>{const n=e.result.split(",")[1];N(n);const t=URL.createObjectURL(a);d((e=>({...e,logoUrl:t}))),w(Date.now()),l({logoBase64:n})},e.readAsDataURL(a)}},accept:"image/*",className:"hidden"}),n.jsxs(PY,{variant:"ghost",size:"sm",onClick:()=>{P.current?.click()},className:"text-white hover:text-white hover:bg-black hover:bg-opacity-20",children:[n.jsx(vd,{className:"h-4 w-4 mr-1"}),"Update"]})]})]}),c.logoUrl&&n.jsxs("div",{className:"flex-1 flex items-center gap-2 max-w-md bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx("div",{className:"flex-1 truncate text-sm text-gray-600 font-mono",children:c.logoUrl}),n.jsxs(PY,{variant:"ghost",size:"sm",onClick:async()=>{if(c.logoUrl)try{await navigator.clipboard.writeText(c.logoUrl),M(!0),setTimeout((()=>M(!1)),1500),j({title:"Logo URL copied to clipboard"})}catch(cBe){try{const e=document.createElement("textarea");e.value=c.logoUrl,e.style.position="fixed",e.style.left="-9999px",document.body.appendChild(e),e.focus(),e.select();const a=document.execCommand("copy");if(document.body.removeChild(e),!a)throw new Error("Fallback copy command failed");M(!0),setTimeout((()=>M(!1)),1500),j({title:"Logo URL copied to clipboard"})}catch(e){j({title:"Failed to copy URL",description:"Could not copy the URL to clipboard. Please try again or copy manually.",variant:"destructive"})}}},className:"h-7 px-2 text-xs shrink-0",children:[C?n.jsx(Ec,{className:"h-3.5 w-3.5 mr-1 text-green-500"}):n.jsx(Hc,{className:"h-3.5 w-3.5 mr-1"}),C?"Copied":"Copy"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("colors"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Colors"})]}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(E.colors?Lc:xc,{className:"h-4 w-4"})})]}),E.colors&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Primary Color"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Your main brand color used throughout the interface"})]}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("primaryColor"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("div",{className:"w-14 h-14 rounded-lg shadow-md",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsxs("div",p.primaryColor?{className:"flex flex-1 gap-2 max-w-sm",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(ed,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),n.jsx(r4,{type:"text",value:v,onChange:e=>f(e.target.value),className:"pl-10 h-10 font-mono text-sm flex-1",placeholder:"#000000",maxLength:7,autoFocus:!0})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("primaryColor"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>z("primaryColor"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}:{className:"flex-1 max-w-sm",children:[n.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[n.jsx(ed,{className:"h-4 w-4 text-gray-400"}),n.jsx("div",{className:"text-sm font-mono",children:c.primaryColor||"#000000"})]}),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx(r4,{type:"color",value:c.primaryColor||"#000000",onChange:e=>_(e.target.value),className:"w-8 h-8 p-1 cursor-pointer rounded-md"}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:rge.map(((e,a)=>n.jsx(PY,{variant:"ghost",size:"icon",className:"w-6 h-6 rounded-full border border-gray-200 "+(c.primaryColor===e?"ring-2 ring-gray-400 ring-offset-1":""),style:{backgroundColor:e},onClick:()=>_(e)},a)))})]})]})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Secondary Colors"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Additional colors that complement your primary brand color"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"flex flex-wrap gap-3 mb-4",children:c.secondaryColors?.length?c.secondaryColors.map(((e,a)=>n.jsxs("div",{className:"group relative flex flex-col items-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-lg shadow-sm border border-gray-200 mb-1 group-hover:ring-2 ring-gray-200",style:{backgroundColor:e}}),n.jsx("div",{className:"text-xs font-mono text-gray-600",children:e}),n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.secondaryColors||[];return{...e,secondaryColors:n.filter((e=>e!==a))}}));var a},className:"absolute -top-1 -right-1 w-5 h-5 bg-white rounded-full shadow border border-gray-200 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(bd,{className:"w-3 h-3 text-gray-500"})})]},a))):n.jsx("div",{className:"text-sm text-gray-500 italic my-2",children:"No secondary colors set"})}),n.jsxs("div",{className:"flex items-end gap-3",children:[n.jsxs("div",{className:"flex-1 max-w-xs",children:[n.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Add color"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx(r4,{type:"color",value:b,onChange:e=>S(e.target.value),className:"w-10 h-10 p-1 cursor-pointer rounded-md"}),n.jsx(r4,{type:"text",value:b,onChange:e=>S(e.target.value),className:"h-10 font-mono text-sm",placeholder:"#000000",maxLength:7})]})]}),n.jsxs(PY,{variant:"outline",onClick:()=>{b&&(d((e=>{const a=e.secondaryColors||[];return{...e,secondaryColors:[...a,b]}})),S("#000000"))},className:"h-10",children:[n.jsx(rd,{className:"h-4 w-4 mr-1"}),"Add Color"]})]})]})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow border border-gray-100 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>L("personality"),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-8 rounded-full",style:{backgroundColor:c.primaryColor||"#000000"}}),n.jsx("h3",{className:"text-base font-medium",children:"Brand Personality"})]}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",children:n.jsx(E.personality?Lc:xc,{className:"h-4 w-4"})})]}),E.personality&&n.jsxs("div",{className:"p-5 border-t border-gray-100 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Tone"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"The overall feeling and attitude your brand conveys"})]}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("tone"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.tone?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("tone"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>z("tone"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.tone||"No tone set"})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Voice"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"How your brand expresses itself in communication"})]}),n.jsx(PY,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full hover:bg-gray-100",onClick:()=>B("voice"),children:n.jsx(ad,{className:"h-3.5 w-3.5 text-gray-500"})})]}),p.voice?n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{type:"text",value:v,onChange:e=>f(e.target.value),className:"flex-1 h-10 rounded-md border border-gray-200 px-3 py-2",autoFocus:!0}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>R("voice"),children:n.jsx(bd,{className:"h-4 w-4 text-gray-500"})}),n.jsx(PY,{variant:"ghost",size:"icon",className:"h-10 w-10 rounded-full hover:bg-gray-100",onClick:()=>z("voice"),children:n.jsx(Ec,{className:"h-4 w-4 text-green-500"})})]})]}):n.jsx("div",{className:"flex h-10 items-center px-4 bg-gray-50 rounded-lg border border-gray-200 text-sm",children:c.brandPersonality?.voice||"No voice set"})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 block",children:"Brand Values"}),n.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Core principles and beliefs that drive your brand"})]})}),n.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[n.jsx("div",{className:"mb-4",children:n.jsx("div",c.brandPersonality?.values&&c.brandPersonality.values.length>0?{className:"flex flex-wrap gap-2",children:c.brandPersonality.values.map(((e,a)=>n.jsxs(JY,{variant:"outline",className:"px-3 py-1.5 border-2 hover:border-red-100 group transition-colors text-primary",style:{borderColor:`${c.primaryColor}30`||"#f3f4f6",backgroundColor:`${c.primaryColor}08`||"#f9fafb"},children:[e,n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>{return a=e,void d((e=>{const n=e.brandPersonality?.values||[];return{...e,brandPersonality:{...e.brandPersonality,values:n.filter((e=>e!==a))}}}));var a},className:"ml-1.5 w-4 h-4 flex items-center justify-center rounded-full bg-gray-200 hover:bg-red-100 hover:text-red-500 transition-colors",children:n.jsx(bd,{className:"w-2.5 h-2.5"})})]},a)))}:{className:"text-sm text-gray-500 italic py-2",children:"No brand values set"})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(r4,{placeholder:"Add a brand value",value:y,onChange:e=>k(e.target.value),className:"flex-1",onKeyDown:e=>"Enter"===e.key&&D()}),n.jsxs(PY,{variant:"outline",onClick:D,disabled:!y.trim(),children:[n.jsx(rd,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})]})]})]}),n.jsxs(ZG,{className:"pb-4 px-6",children:[i?n.jsx(PY,{variant:"outline",className:"gap-1.5",onClick:i,children:"Go Back"}):r&&n.jsxs(PY,{variant:"outline",className:"gap-1.5",onClick:()=>{h(!0)},children:[n.jsx(md,{className:"h-4 w-4 text-amber-500"}),"Auto Parse"]}),n.jsx(PY,{className:"px-4",onClick:async()=>{let e;T?e=T:c.logoUrl?.startsWith("data:image/png;base64,")?e=c.logoUrl.split(",")[1]:c.logoUrl?.startsWith("blob:")&&(e=void 0),l({brandName:c.brandName,brandTagline:c.brandTagline,logoBase64:e,primaryColor:c.primaryColor,secondaryColors:c.secondaryColors,brandPersonality:c.brandPersonality}),j({title:"Brand settings saved 🚀"}),t&&t(),N(null)},disabled:u,children:u?"Saving":"Save Changes"})]})]})},sge=oee.object({channelSenderId:oee.string().min(1,"Please select a channel sender"),replyTo:oee.string().trim().min(1).email("Please enter a valid email address").or(oee.literal("").transform((()=>null))).or(oee.null()).optional(),fromName:oee.string().trim().min(1).or(oee.literal("").transform((()=>null))).or(oee.null()).optional()}),lge=()=>{const{channelSenders:e,isLoading:t}=E9(),{channelAccounts:i,isLoading:r}=M9(),{updateChannelSender:o,isUpdating:s}=x9(),{toast:l}=Ie(),u=soe({resolver:hoe(sge),defaultValues:{channelSenderId:"",replyTo:"",fromName:""}}),c=a.useMemo((()=>zie({channelSenders:e?.results??[],channelAccounts:i?.results??[]})),[e?.results,i?.results]);if(a.useEffect((()=>{if(c&&c.length>0&&!u.getValues("channelSenderId")){const e=c[0];u.setValue("channelSenderId",e.channelSenderId),u.setValue("replyTo",e.channelSender.channelSenderMetadata.emailReplyTo??""),u.setValue("fromName",e.channelSender.channelSenderMetadata.emailFromName??"")}}),[c,u]),t||void 0===e||r||void 0===i)return n.jsx("div",{className:"flex justify-center items-center h-full py-10",children:n.jsx(NY,{})});return n.jsxs("div",{className:"w-full max-w-4xl mx-auto mt-8",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-gray-900 mb-1",children:"Set up Your Email Channel"}),n.jsx("p",{className:"text-muted-foreground text-base",children:"Define your default sender name, email address, and reply-to to start sending emails with confidence."})]}),n.jsx(poe,{...u,children:n.jsxs("form",{onSubmit:u.handleSubmit((async e=>{const a=c.find((a=>a.channelSenderId===e.channelSenderId));a&&o({toUpdate:{channelSenderMetadata:{...a.channelSender.channelSenderMetadata,emailReplyTo:e.replyTo?e.replyTo:`noreply@${a.baseDomain??""}`,emailFromName:e.fromName?e.fromName:null}},id:a.channelSender.id},{onSuccess:()=>{l({title:"Email channel sender updated successfully!"})},onError:()=>{l({title:"Failed to update email channel sender",description:"Please contact your administrator",variant:"destructive"})}})})),className:"bg-white border border-gray-200 rounded-2xl shadow-sm p-8 space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[n.jsx(boe,{className:"flex items-center gap-1 text-base font-medium mb-2",children:"Email Channel Sender"}),n.jsxs(hie,{value:u.watch("channelSenderId"),onValueChange:e=>{u.setValue("channelSenderId",e);const a=c.find((a=>a.channelSenderId===e));a&&u.setValue("replyTo",a.channelSender.channelSenderMetadata.emailReplyTo??"")},children:[n.jsx(vie,{className:"w-full bg-gray-50 border-gray-200 focus:ring-2 focus:ring-blue-500 focus:border-blue-500 rounded-lg min-h-[48px] text-base",children:n.jsx(gie,{placeholder:"Select a sender"})}),n.jsx(kie,{children:c.map((e=>n.jsx(bie,{value:e.channelSenderId,children:n.jsxs("div",{className:"flex flex-col text-left",children:[n.jsx("span",{className:"font-medium",children:e.fullDomain}),n.jsx("span",{className:"text-xs text-muted-foreground",children:e.channelSender.channelSenderMetadata.emailReplyTo||"No reply-to set"})]})},e.channelSenderId)))})]})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(boe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["Reply-to Email",n.jsx(Mae,{title:"Reply to email to use when the reply button is clicked"})]}),n.jsxs("span",{className:"text-xs text-muted-foreground font-normal mb-1",children:["Optional – will use"," ",n.jsx("span",{className:"font-mono",children:u.watch("channelSenderId")?`noreply@${c.find((e=>e.channelSenderId===u.watch("channelSenderId")))?.baseDomain}`:"sender domain"})," ","if empty"]}),n.jsx(Moe,{control:u.control,name:"replyTo",type:"email",placeholder:"Replies from recipients will go to this email (optional)"})]}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs(boe,{className:"flex items-center gap-1 text-base font-medium mb-0.5",children:["From Name",n.jsx(Mae,{title:"From name to use when the email is sent"})]}),n.jsx(Moe,{control:u.control,name:"fromName",placeholder:"From name to use when the email is sent (optional)"})]}),n.jsx("div",{className:"flex gap-3 pt-4 justify-end border-t border-gray-100",children:n.jsx(PY,{type:"submit",disabled:s,className:"min-w-[120px]",children:s?"Saving...":"Save"})})]})})]})},uge=()=>{const[e,t]=a.useState(null),{channelSenders:i}=E9(),{channelAccounts:r}=M9(),{data:o}=L9(),s=mee({channelSenders:i?.results??[],channelAccounts:r?.results??[],smsApplication:o});a.useEffect((()=>{s.length>0&&s.some((e=>e.smsApplication?.status===dee.APPROVED||!e.smsApplication))?t(!0):t(!1)}),[s,o]);const l={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:[.4,0,.2,1]}}};if(null===e)return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(NY,{})});const u=s.some((e=>e.smsApplication?.status===dee.APPROVED));return n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:e?n.jsxs(Z$.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:pm("flex flex-col items-center text-center w-full max-w-[72ch] rounded-xl p-6 gap-3 border border-border mx-auto mb-16","bg-background"),children:[n.jsx(Z$.div,{variants:l,className:"w-16 h-16 rounded-xl flex items-center justify-center bg-green-50",children:n.jsx(zY.SmsIcon,{className:"text-green-600"})}),n.jsx(Z$.h2,{variants:l,className:"text-lg font-medium text-foreground",children:"SMS Sending Number Active"}),n.jsx(Z$.div,{variants:l,className:"max-w-xl mx-auto",children:n.jsx("p",u?{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!"})}),n.jsxs(Z$.div,{variants:l,className:"flex items-center gap-2 px-4 py-2 bg-green-50 border border-green-200 rounded-full mt-2",children:[n.jsx(Z$.div,{animate:{scale:[1,1.2,1],opacity:[1,.8,1]},transition:{duration:2,repeat:Number.POSITIVE_INFINITY,ease:"easeInOut"},className:"w-2 h-2 bg-green-500 rounded-full"}),n.jsx("span",{className:"text-sm font-medium text-green-800",children:"Ready to send"})]})]}):n.jsx("div",{className:"w-full max-w-4xl mx-auto mt-8",children:n.jsx(Noe,{})})})};function cge({tabs:e,activeTab:a,onTabChange:t,title:i}){return n.jsxs("div",{className:"flex h-full",children:[n.jsxs("div",{className:"w-48 py-2 pl-4",children:[i&&n.jsx("h2",{className:"px-4 pt-4 pb-5 text-lg font-medium",children:i}),e.map((e=>n.jsx(PY,{variant:"ghost",className:pm("w-full justify-start mb-1",a===e.id&&"bg-accent"),onClick:()=>t(e.id),children:e.label},e.id)))]}),n.jsx("div",{className:"flex-1 overflow-y-auto pl-6 pr-4 pb-4",children:e.find((e=>e.id===a))?.content})]})}function dge({open:e,setOpen:t}){const[i,r]=a.useState("brand");a.useEffect((()=>{e&&r("brand")}),[e]);const o=[{id:"brand",label:"Brand",content:n.jsx(oge,{})},{id:"email-channel",label:"Email Channel",content:n.jsx(lge,{})},{id:"sms-channel",label:"SMS Channel",content:n.jsx(uge,{})}];return n.jsx(VG,{open:e,onOpenChange:t,children:n.jsxs(WG,{className:"flex w-[90vw] h-[90vh] flex-col gap-0 overflow-hidden sm:max-w-xl md:max-w-3xl lg:max-w-4xl xl:max-w-5xl p-0",children:[n.jsxs(kO,{children:[n.jsx($G,{children:"Settings"}),n.jsx(YG,{children:"Edit your business and brand settings"})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(cge,{tabs:o,activeTab:i,onTabChange:r,title:"Settings"})})]})})}const mge=e=>{const{updateAutomation:n,updateError:t,isUpdateSuccess:i}=na(e),{toast:r}=Ie();return a.useEffect((()=>{i?r({title:"Status updated",description:"The status has been updated successfully"}):t&&r({title:"Error updating status",description:"Please try again",variant:"destructive"})}),[i,t,r]),{toggleStatus:async e=>{try{return await n({status:e?ca.ACTIVE:ca.DRAFT}),!0}catch(a){return r({title:"Error updating status",description:"Please try again",variant:"destructive"}),!1}}}};function hge(){const{toast:e}=Ie(),[t,i]=a.useState(null),{toggleStatus:r}=mge(t||""),o=r5(),[s,l]=a.useState(10),[u,c]=a.useState(void 0),[d,m]=a.useState(""),{automations:h,nextCursor:p,isLoading:g,error:v,isFetching:f,isPlaceholderData:y}=ia({cursor:u,limit:s,triggerType:oa.TRIGGER_BASED,search:d||void 0});a.useEffect((()=>{v&&e({title:`Error Fetching ${Eh("engage:automation")}`,description:v?.message||"Please try again.",variant:"destructive"})}),[v,e]);const k=a.useMemo((()=>(h||[]).map((e=>({...e,emailsSent:0,smsSent:0,updated_at:e.updatedAt||e.createdAt})))),[h]),b=a.useCallback((async(e,a)=>{try{i(e);const n=a===ca.ACTIVE;await r(n)}finally{i(null)}}),[r,i]),S=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]),A=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),w=a.useMemo((()=>Cae({automationName:Eh("engage:automation"),setUrl:A,onToggle:b,vsaasManaged:!0})),[b,A]);return n.jsx("div",{className:"w-full h-[75vh] flex flex-col",children:n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx(s4,{data:k,columns:w,paginationMode:"cursor",initialPageSize:s,isLoading:g&&!y,onRowClick:e=>{o(`/automations/view-modal/${e.id}?showBackButton=true`)},cursorPaginationQueryResult:{nextCursor:p,isLoading:g,isFetching:f,isPlaceholderData:y},onQueryParametersChange:S,searchValue:d,onSearchChange:m})})})}function pge(){const{toast:e}=Ie(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{toggleStatus:s}=mge(r||""),l=r5(),[u,c]=a.useState(10),[d,m]=a.useState(void 0),[h,p]=a.useState(""),{automations:g,nextCursor:v,isLoading:f,error:y,isFetching:k,isPlaceholderData:b}=ia({cursor:d,limit:u,triggerType:oa.ONE_TIME,search:h||void 0});a.useEffect((()=>{y&&e({title:`Error Fetching ${Eh("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]),A=a.useCallback((async(e,a)=>{try{o(e);const n=a===ca.ACTIVE;await s(n)}finally{o(null)}}),[s,o]),w=a.useCallback((e=>{m(e.cursor),c(e.pageSize)}),[]),C=a.useCallback((e=>`/automations/view-modal/${e}?showBackButton=true`),[]),M=a.useMemo((()=>Cae({automationName:Eh("engage:broadcast"),setUrl:C,onToggle:A,pillForStatus:!0})),[A,C]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx(s4,{data:S,columns:M,paginationMode:"cursor",initialPageSize:u,headerActions:n.jsxs(PY,{className:"bg-primary",onClick:()=>i(!0),children:[n.jsx(rd,{className:"h-4 w-4 mr-1"}),"New"]}),isLoading:f&&!b,cursorPaginationQueryResult:{nextCursor:v,isLoading:f,isFetching:k,isPlaceholderData:b},onRowClick:e=>{l(`/automations/view-modal/${e.id}?showBackButton=true`)},onQueryParametersChange:w,searchValue:h,onSearchChange:p})}),n.jsx(Ipe,{open:t,setOpen:i,onClose:a=>{gae(i,e,a,`Error creating ${Eh("engage:broadcast")}`,"Please try again"),m(void 0),c(10),p(""),!1!==a&&l(`/automations/view-modal/${a}?showBackButton=true`)},automationType:oa.ONE_TIME})]})}function gge(){const{toast:e}=Ie(),[t,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:v,isPlaceholderData:f}=pY({search:d||void 0,cursor:u,limit:s}),y=a.useCallback((e=>{o(e),i(!0)}),[o]),k=a.useMemo((()=>function(e){return[yae("name",`${Eh("engage:segment")} Name`,!0),kae(),pae({accessorKey:"user_count",header:Eh("engage:user_other"),meta:{align:"right",displayName:Eh("engage:user_other")},cellClassName:"text-muted-foreground pr-4",cellFormatter:e=>{const a=e.getValue()??0;return`${a.toLocaleString()} ${1===a?Eh("engage:user").toLowerCase():Eh("engage:user_other").toLowerCase()}`}}),bae("user_count_updated_at"),wae(e||(()=>{}))]}(y)),[y]),b=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((()=>n.jsxs(PY,{onClick:()=>{o(null),i(!0)},children:[n.jsx(rd,{className:"h-4 w-4"}),"New List"]})),[]),A=a.useCallback((e=>{c(e.cursor),l(e.pageSize)}),[]);return n.jsxs("div",{className:"w-full h-[75vh] flex flex-col",children:[n.jsx("div",{className:"flex-grow min-h-0 p-2",children:n.jsx(s4,{data:b,columns:k,paginationMode:"cursor",initialPageSize:s,headerActions:S,isLoading:p&&!f,cursorPaginationQueryResult:{nextCursor:g,isLoading:p,isFetching:v,isPlaceholderData:f},onQueryParametersChange:A,onRowClick:a=>{a.type!==kY.MANAGED?(o(a.id),i(!0)):e({title:`Managed ${Eh("engage:segment")} cannot be edited!`,variant:"destructive"})},searchValue:d,onSearchChange:m})}),n.jsx(bpe,{open:t,setOpen:i,segmentId:r??void 0,onSegmentUpdated:a=>{gae(i,e,a,`Error creating ${Eh("engage:segment")}`,"Please try again"),c(void 0),l(10),m("")}})]})}const vge=()=>{const e=ce(),[t,i]=a.useState(!1),[r,o]=a.useState(null),{automations:s,isLoading:l}=ia({triggerType:oa.TRIGGER_BASED}),[u,c]=a.useState();return a.useEffect((()=>{e.prefetchQuery({queryKey:je.list()}),e.prefetchQuery({queryKey:mY.lists()})}),[e]),a.useEffect((()=>{if(l||void 0===s)return;const e=[{id:"broadcasts",label:Eh("engage:broadcast",{count:2}),content:n.jsx(pge,{})},{id:"segments",label:Eh("engage:segment",{count:2}),content:n.jsx(gge,{})},{id:"statistics",label:Eh("engage:insight",{count:2}),content:n.jsx(ege,{})}];s.length>0?(o("automations"),c([{id:"automations",label:Eh("engage:automation",{count:2}),content:n.jsx(hge,{})},...e])):(o("broadcasts"),c(e))}),[s,l]),null===r||null==u?n.jsx("div",{className:"w-full h-full flex justify-center items-center",children:n.jsx(NY,{})}):n.jsxs("div",{className:"w-full h-full flex flex-col gap-4",children:[n.jsx(dge,{open:t,setOpen:i}),n.jsx("div",{className:"flex justify-end",children:n.jsx(PY,{variant:"outline",onClick:()=>i(!0),children:n.jsx(cd,{className:"w-4 h-4"})})}),n.jsx("div",{className:"flex-1 w-full h-full flex flex-col gap-4",children:n.jsx(Gpe,{activeTab:r,tabs:u,onTabChange:o})})]})};function fge({value:e,schema:t,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),[v,f]=a.useState(0),[y,k]=a.useState(e),[b,S]=a.useState(e),A=a.useRef(null),w=a.useRef(null),C=a.useRef(null),M=a.useRef(null),{toast:T}=Ie(),N=soe({resolver:hoe(t),defaultValues:{[r]:e}});a.useEffect((()=>{N.reset({[r]:e}),k(e),S(e)}),[e,r,N]),a.useEffect((()=>{w.current&&g(w.current.offsetWidth),M.current&&!c&&f(M.current.offsetWidth)}),[c]),a.useEffect((()=>{C.current&&y&&g(C.current.offsetWidth)}),[y]),a.useEffect((()=>{c&&A.current&&(A.current.focus(),A.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(n){T({variant:"destructive",title:l})}finally{h(!1)}},x=()=>{N.reset(),d(!1),k(b)},P=e=>{"Escape"===e.key&&x()};return c?n.jsx(poe,{...N,children:n.jsxs("form",{onSubmit:N.handleSubmit(E),className:GG("inline-flex items-center gap-2 min-h-[20px]",o),style:{minWidth:v?`${v}px`:"auto"},children:[n.jsx("span",{ref:C,className:"absolute invisible whitespace-pre leading-none select-none pointer-events-none",style:{font:"inherit"},children:y||b}),n.jsx(voe,{control:N.control,name:r,render:({field:e})=>n.jsx(koe,{className:"flex-1 min-w-0",children:n.jsx(Soe,{children:n.jsx("input",{...e,ref:A,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),k(a.target.value)},onKeyDown:P,disabled:m,onBlur:a=>{e.onBlur(),setTimeout((()=>{a.currentTarget.form?.contains(document.activeElement)||x()}),0)}})})})}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsx(PY,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",onClick:x,disabled:m,children:n.jsx(bd,{className:"h-3 w-3"})}),n.jsx(PY,{type:"button",size:"icon",variant:"ghost",className:"h-5 w-5 p-0",disabled:m,onClick:()=>{N.handleSubmit(E)()},children:m?n.jsx(Wc,{className:"h-3 w-3 animate-spin"}):n.jsx(Ec,{className:"h-3 w-3"})})]})]})}):n.jsxs("button",{ref:M,type:"button",className:GG("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:[n.jsx("span",{ref:w,className:GG("leading-none select-none",o,{italic:!b}),children:b||u}),n.jsx(nd,{className:"h-3 w-3 transition-opacity duration-200 flex-shrink-0 opacity-0 group-hover:opacity-100"})]})}function yge({open:e,onOpenChange:a}){const t=AY(),{toast:i}=Ie(),{updateAutomation:r}=na(t?.id||""),o=ce();return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"sm:max-w-[425px]",children:[n.jsx(qG,{children:n.jsx($G,{children:t?.status===ca.SENDING?`Cancel ${Eh("engage:automation")}`:`Cancel ${Eh("engage:automation")} Before Sending`})}),n.jsx("div",{className:"space-y-4",children:t?n.jsxs(n.Fragment,t.status===ca.SENDING?{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),Eh("engage:automation")," as soon as possible."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsxs("li",{children:["We'll attempt to cancel the"," ",Eh("engage:broadcast").toLowerCase()]}),n.jsx("li",{children:"Any messages already in the process of being sent will be delivered"}),n.jsxs("li",{children:["Future ",Eh("engage:broadcast").toLowerCase()," messages will be cancelled"]}),n.jsxs("li",{children:["You can create a new ",Eh("engage:broadcast").toLowerCase()," if needed"]})]})]})]}:{children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll help you cancel your",n.jsx("span",{className:"font-bold px-1 text-primary",children:t.name}),Eh("engage:automation")," before it starts sending."]}),n.jsxs("div",{className:"rounded-lg bg-muted p-4 text-sm",children:[n.jsx("p",{className:"font-medium mb-2",children:"What happens next?"}),n.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[n.jsx("li",{children:"The automation will be cancelled"}),n.jsx("li",{children:"You can create a new automation if needed"})]})]})]}):null}),n.jsxs(ZG,{className:"gap-2 sm:gap-0",children:[n.jsx(PY,{variant:"outline",onClick:()=>a(!1),children:"Continue Running"}),n.jsxs(PY,{variant:"destructive",onClick:()=>{if(!t)return;const e=t.status===ca.SENDING?ca.PARTIALLY_CANCELLED:ca.CANCELLED,n=t.status===ca.SENDING?`Attempting to cancel ${Eh("engage:broadcast").toLowerCase()}`:`Successfully cancelled ${Eh("engage:broadcast").toLowerCase()}`,s=`Failed to cancel ${Eh("engage:broadcast").toLowerCase()}`;r({status:e},{onError:()=>{i({title:s,description:"Please contact your administrator.",variant:"destructive"}),o.invalidateQueries({queryKey:je.all})},onSuccess:()=>{a(!1),i({title:n,description:t.status===ca.SENDING?`We'll attempt to cancel your ${Eh("engage:broadcast").toLowerCase()}. Any messages already in progress will be delivered.`:`Your ${Eh("engage:broadcast").toLowerCase()} has been cancelled.`})}})},children:["Cancel ",Eh("engage:automation")]})]})]})})}function kge({open:e,onOpenChange:a,setIsActive:t}){const i=AY(),{updateAutomation:r}=na(i?.id||""),{toast:o}=Ie(),s=ce(),l=Eh(i?.triggerType===oa.ONE_TIME?"engage:broadcast":"engage:automation"),u=i?.triggerType===oa.ONE_TIME?"Unschedule":"Convert to draft";return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"sm:max-w-[425px]",children:[n.jsx(qG,{children:n.jsx($G,{children:u})}),n.jsxs("div",{children:["Are you sure you want to convert",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name})," ",l," to draft?"]}),n.jsxs(ZG,{className:"gap-2 sm:gap-0",children:[n.jsx(PY,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),n.jsx(PY,{variant:"destructive",onClick:()=>{r({status:ca.DRAFT},{onSuccess:()=>{o({title:`Updated ${l}`,description:`${l} status updated to draft`}),a(!1),t(!1)},onError:()=>{o({title:`Failed to update ${l}`,description:"Please try again"}),s.invalidateQueries({queryKey:je.all})}})},children:u})]})]})})}const bge=K7({name:C7().min(2,"Title must be at least 2 characters"),description:C7()});function Sge({open:e,onOpenChange:a,onDuplicationCreated:t}){const i=AY(),{toast:r}=Ie(),o=soe({resolver:hoe(bge),defaultValues:{name:`${i?.name} (copy)`,description:i?.description??""}}),{duplicateAutomation:s}=ra();return n.jsx(VG,{open:e,onOpenChange:a,children:n.jsxs(WG,{className:"sm:max-w-[425px]",children:[n.jsx(qG,{children:n.jsx($G,{children:"Duplicate Automation"})}),n.jsx(poe,{...o,children:n.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&&(t?.(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:[n.jsxs("div",{children:["Create a copy of the",n.jsx("span",{className:"font-bold px-1 text-primary",children:i?.name}),"automation with a new title and description."]}),n.jsx(voe,{control:o.control,name:"name",render:({field:e})=>n.jsxs(koe,{children:[n.jsx(boe,{children:"Title"}),n.jsx(Soe,{children:n.jsx(r4,{...e})}),n.jsx(Aoe,{})]})}),n.jsx(voe,{control:o.control,name:"description",render:({field:e})=>n.jsxs(koe,{children:[n.jsx(boe,{children:"Description"}),n.jsx(Soe,{children:n.jsx(iue,{...e})}),n.jsx(Aoe,{})]})}),n.jsx(ZG,{children:n.jsx(PY,{type:"submit",children:"Duplicate"})})]})})]})})}const Age=K7({name:C7().min(2,"Title must be at least 2 characters")}),wge=K7({description:C7().max(300,"Description must be less than 300 characters")}),Cge=({showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i})=>{const r=AY(),o=r5(),{updateAutomation:s}=na(r?.id||""),{toast:l}=Ie(),u=(()=>{const{state:e}=SY();return e.recipientStats})(),c=wY(),{data:d}=L9(),{channelSenders:m}=E9(),{channelAccounts:h}=M9(),p=ce(),[g,v]=a.useState(void 0),[f,y]=a.useState(!1),[k,b]=a.useState(!1),[S,A]=a.useState(!1),[w,C]=a.useState(0),[M,T]=a.useState(!1),N=mee({channelSenders:m?.results??[],channelAccounts:h?.results??[],smsApplication:d});a.useEffect((()=>{if(r)switch(r.status){case ca.DRAFT:v(!1);break;case ca.ACTIVE:case ca.RUNNING:case ca.COMPLETED:v(!0);break;case ca.FAILED:case ca.DEACTIVATED:v(!1);break;case ca.SENDING:case ca.SCHEDULED:v(!0);break;case ca.PARTIALLY_CANCELLED:case ca.CANCELLED:v(!1);break;default:throw g9(r.status,ca)}}),[r]);const E=a.useCallback((()=>{if(!r)return l({title:"Automation not found",description:"Please contact your administrator",variant:"destructive"}),null;const e=async e=>{if(g&&!e)b(!0);else{if(A(!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 A(!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 A(!1)}if(c?.emailHtmlBody?.includes(Lpe)){if(0===w)return l({title:`${Bpe}. You can click send again to send anyway.`,variant:"warning"}),C(w+1),void A(!1);C(w+1)}switch(r.triggerType){case oa.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 A(!1);if(!c||!c.emailChannelSenderId&&!c.smsChannelSenderId)return l({title:"Ensure you have selected at least one kind of communication",variant:"destructive"}),void A(!1);break;case oa.TRIGGER_BASED:break;default:throw g9(r.triggerType,oa)}const a=Eh(r.triggerType===oa.ONE_TIME?"engage:automation":"engage:broadcast");s({status:e?ca.ACTIVE:ca.DEACTIVATED},{onSuccess:()=>{v(e),l(r.triggerType===oa.ONE_TIME?e?{title:`${a} started!`}:{title:`${a} has been unscheduled`}:{title:`${a} status updated to ${e?"active":"inactive"}`}),A(!1)},onError:()=>{l({title:"Error while updating the status",description:"Please contact your administrator",variant:"destructive"}),A(!1),p.invalidateQueries({queryKey:je.all})}})}};if(!r||!c)return null;const a=N.find((e=>e.channelSender.id===c?.smsChannelSenderId)),t=!r.triggerMetadata||null===r.triggerMetadata,o=r.triggerMetadata?.triggerType===oa.ONE_TIME&&!r.triggerMetadata?.scheduledAt,d=!c?.emailChannelSenderId&&!c?.smsChannelSenderId,m=r.triggerType===oa.ONE_TIME,h=m&&a&&a?.smsApplication?.application&&a?.smsApplication?.status!==dee.APPROVED,f=c?.emailChannelSenderId&&(!c?.emailSubject||!c?.emailHtmlBody),y=c?.smsChannelSenderId&&!c?.smsMessageBody,k=m&&(!r.triggerMetadata||!("scheduledAt"in r.triggerMetadata)||!r.triggerMetadata?.scheduledAt);let S,M=!1,E=!0;switch(r.status){case ca.ACTIVE:M=!1;break;case ca.DRAFT:(d||f||y)&&(M=!0,f&&(S="Missing subject in email communication"),y&&(S="Missing SMS message in SMS communication")),k&&(M=!0),h&&(M=!0);break;case ca.DEACTIVATED:case ca.PARTIALLY_CANCELLED:case ca.CANCELLED:switch(M=!0,E=!1,r.status){case ca.DEACTIVATED:S="Automation is deactivated";break;case ca.PARTIALLY_CANCELLED:S="Automation is partially cancelled";break;case ca.CANCELLED:S="Automation is cancelled";break;default:throw g9(r.status,ca)}break;case ca.RUNNING:M=!0,r.triggerType===oa.TRIGGER_BASED?(S="Cannot change status of running automation",E=!0):E=r.triggerType===oa.ONE_TIME&&r.status===ca.RUNNING;break;case ca.COMPLETED:M=!0,S="Cannot change status of completed automation",E=!1;break;case ca.FAILED:M=!0,S="Cannot change status of failed automation",E=!1;break;case ca.SENDING:case ca.SCHEDULED:M=!1,E=!0;break;default:throw g9(r.status,ca)}const x=(()=>{switch(r.triggerType){case oa.TRIGGER_BASED:return n.jsxs("div",{className:"flex items-center gap-2 w-[12ch] cursor-pointer",children:[n.jsx(g?Ec:Dc,{className:"w-4 h-4"}),n.jsx("div",{className:"text-[13px] font-medium",children:g?"Active":"Inactive"}),n.jsx(dpe,{checked:g,onCheckedChange:e,disabled:M})]});case oa.ONE_TIME:if((r.status===ca.RUNNING||r.status===ca.SCHEDULED||r.status===ca.SENDING)&&r.triggerType===oa.ONE_TIME)return n.jsx(PY,{variant:"outline",className:"flex items-center gap-2",onClick:()=>T(!0),disabled:!1,children:"Cancel"});if(t||o||d||h||f||y){return n.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:(()=>{const a=r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"===r.triggerMetadata?.scheduledAt?"Send Now":"Schedule Send";if(r.status!==ca.DRAFT&&r.triggerMetadata&&"scheduledAt"in r.triggerMetadata&&"now"!==r.triggerMetadata?.scheduledAt&&r.status===ca.ACTIVE)return n.jsx(PY,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===oa.ONE_TIME?"Unschedule":"Convert to Draft"});const t=[];h&&t.push("The SMS number selected is still not approved"),k&&t.push("Please select a schedule time on the left sidebar"),d&&t.push("Please add at least one sender"),f&&t.push("Please add a subject to your email communication"),y&&t.push("Please add a message to your SMS communication");const i=t.map((e=>{return(a=e).charAt(0).toUpperCase()+a.slice(1);var a})),o=`You cannot start this ${Eh("engage:broadcast")} yet. ${i.join(" · ")}`;return n.jsx("div",{className:"flex items-center gap-2 cursor-not-allowed",children:n.jsx(Mae,{alertText:o,asChild:!1,children:n.jsx(PY,{variant:"outline",className:"flex items-center gap-2 cursor-not-allowed",disabled:!0,children:n.jsx("span",{children:a})})})})})()})}if(!g){let a="Schedule Send";return r.triggerMetadata&&r.triggerMetadata.triggerType===oa.ONE_TIME&&r.triggerMetadata.scheduledAt&&"now"===r.triggerMetadata.scheduledAt&&(a="Send Now"),n.jsx(PY,{variant:"default",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:a})}return n.jsx(PY,{variant:"outline",className:"flex items-center gap-2",onClick:()=>e(!g),disabled:M,children:r.triggerType===oa.ONE_TIME?"Unschedule":"Convert to Draft"});default:throw g9(r.triggerType,oa)}})();return M&&S&&r.triggerType===oa.TRIGGER_BASED?n.jsx(Mae,{alertText:S,asChild:!0,children:n.jsx("div",{className:"flex items-center gap-2",children:E&&x})}):n.jsx("div",{className:"flex items-center gap-2",children:E&&x})}),[r,c,N,l,g,i,s,u,w,p]),x=a.useMemo((()=>r?n.jsx(JY,{variant:vae(r.status),children:v9({status:r.status,automationType:r.triggerType})}):null),[r]);return r&&void 0!==g?n.jsxs("header",{className:"flex px-1 pt-1",children:[n.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e&&n.jsx(PY,{variant:"ghost",size:"icon",onClick:()=>o(-1),children:n.jsx(Cc,{})}),n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs("div",{className:"flex flex-col gap-0 items-start",children:[n.jsx(fge,{value:r.name,schema:Age,onSubmit:e=>{s({name:e.name},{onError:()=>{l({title:"Failed to update automation name",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:je.all})}})},fieldName:"name",className:"text-lg",successMessage:"Automation name updated",errorMessage:"Failed to update automation name"}),r.automationType!==la.MANAGED?n.jsx(fge,{value:r.description||"",schema:wge,onSubmit:e=>{s({description:e.description},{onError:()=>{l({title:"Failed to update automation description",description:"Please try again",variant:"destructive"}),p.invalidateQueries({queryKey:je.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 automation"}):r.description&&n.jsx("div",{className:"text-sm text-current",children:r.description})]})})]}),n.jsxs("div",{className:"ml-auto flex gap-4 items-center",children:[n.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[x,r.triggerType===oa.ONE_TIME&&n.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:n.jsx(Mae,{title:"Duplicate",Icon:zY.DuplicateIcon,asChild:!1,onClick:()=>y(!0)})})]}),n.jsx("div",S?{className:"flex items-center text-muted-foreground pr-2",children:n.jsx(NY,{size:"sm"})}:{className:"flex items-center",children:E()})]}),n.jsx(Sge,{open:f,onOpenChange:y,onDuplicationCreated:t}),n.jsx(kge,{open:k,onOpenChange:b,setIsActive:v}),n.jsx(yge,{open:M,onOpenChange:T})]}):null},Mge=()=>{const e=AY(),{isLoading:t}=ta(e?.id),{state:{hideSales:i,hideSms:r}}=a.useContext(bO);return!e||t?n.jsx(NY,{text:[`Fetching ${Eh("engage:insight",{count:2})}`,"Finishing up"]}):n.jsx("div",{className:"h-full p-4",children:n.jsx(ege,{automationId:e.id,automation:e,includeSales:!i,includeSms:!r})})},Tge=()=>{const e=AY(),[t,i]=a.useState(10),[r,o]=a.useState(void 0),[s,l]=a.useState(""),{sentCommunications:u,isLoading:c,isFetching:d,isPlaceholderData:m,fetchError:h}=ea({automationId:e?.id??"",cursor:r,limit:t,search:s||void 0}),p=a.useCallback((e=>{o(e.cursor),i(e.pageSize)}),[]),g=[{accessorKey:"communicationsSent",id:"lastCommunication",header:"Updated At",cell:({row:e})=>{const a=e.original.communicationsSent||[];if(0===a.length)return n.jsx("span",{className:"text-gray-400",children:"None"});const t=a.reduce(((e,a)=>e&&e.updatedAt?a.updatedAt&&new Date(a.updatedAt)>new Date(e.updatedAt)?a:e:a));return t?.updatedAt?n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("span",{className:"text-sm text-gray-600",children:dae(new Date(t.updatedAt),"MMM d, yyyy h:mm a")})}):n.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||n.jsx("span",{className:"text-gray-400",children:"Not provided"})}},{accessorKey:"email",header:"Email",cell:({row:e})=>e.original.email||n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"phone",header:"Phone",cell:({row:e})=>e.original.phone?Pce(e.original.phone):n.jsx("span",{className:"text-gray-400",children:"Not provided"})},{accessorKey:"communicationsSent",id:"communicationsSent",header:"Communications Sent",cell:({row:e})=>{const a=e.original.communicationsSent||[],t=a.filter((e=>e.type===da.EMAIL)),i=a.filter((e=>e.type===da.SMS)),r=t.length>0,o=i.length>0,s=t.some((e=>e.delivered)),l=i.some((e=>e.delivered)),u=t.find((e=>e.error))?.error,c=i.find((e=>e.error))?.error,d=(e,a,t)=>n.jsxs("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[n.jsxs("div",{className:"relative",children:[n.jsx("email"===e?zY.EmailIcon:zY.SmsIcon,{className:"h-4 w-4 "+(t?"text-red-500":a?"text-green-500":"text-gray-400")}),a&&!t&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white"}),t&&n.jsx("div",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white"})]}),n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{className:"text-sm font-medium",children:"email"===e?"Email":"SMS"}),n.jsx("span",t?{className:"text-xs text-red-500",children:"Failed"}:{className:"text-xs "+(a?"text-green-600":"text-gray-500"),children:a?"Delivered":"Pending"})]})]});return n.jsxs("div",{className:"flex items-center gap-3",children:[r&&(u?n.jsx(Mae,{title:u,children:d("email",s,u)}):d("email",s,u)),r&&o&&n.jsx("div",{className:"h-8 w-px bg-gray-200"}),o&&(c?n.jsx(Mae,{title:c,children:d("sms",l,c)}):d("sms",l,c)),!r&&!o&&n.jsx("span",{className:"text-sm text-gray-400",children:"None"})]})}}];return e&&!c&&u?h?n.jsxs("div",{children:["Error: ",h.message]}):!u||!s&&0===u.results.length?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(zY.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Communications Sent Yet"}),n.jsxs("p",{className:"text-gray-500",children:["This"," ",Eh(e.triggerType===oa.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."]})]}):n.jsx("div",{className:"h-full p-4",children:n.jsx(s4,{data:u.results,columns:g,paginationMode:"cursor",initialPageSize:t,isLoading:c&&!m,cursorPaginationQueryResult:{nextCursor:u.pagination.cursor,isLoading:c,isFetching:d,isPlaceholderData:m},onQueryParametersChange:p,searchValue:s,onSearchChange:l})}):n.jsx(NY,{text:["Fetching Recipients","Finishing up"]})},Nge=()=>{const e=AY();return e?e?.triggerType===oa.ONE_TIME&&e?.status===ca.DRAFT?n.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(zY.UserIcon,{className:"h-12 w-12 text-gray-400"})}),n.jsx("h3",{className:"mb-2 text-lg font-semibold text-gray-700",children:"No Recipients Available Yet"}),n.jsxs("p",{className:"text-gray-500",children:["Recipients will be available once this"," ",Eh(e.triggerType===oa.ONE_TIME?"engage:broadcast":"engage:automation")," ","has completed running. Please check back after the automation has finished."]})]}):n.jsx(Tge,{}):n.jsx(NY,{text:["Fetching Recipients","Finishing up"]})},Ege=a.createContext(null);Ege.displayName="PanelGroupContext";const xge="data-panel-group",Pge="data-panel-group-direction",jge="data-panel-group-id",Lge="data-panel",Bge="data-panel-collapsible",zge="data-panel-id",Rge="data-panel-size",_ge="data-resize-handle",Dge="data-resize-handle-active",Kge="data-panel-resize-handle-enabled",Hge="data-panel-resize-handle-id",Oge="data-resize-handle-state",Ige=a.useLayoutEffect,Gge=r["useId".toString()],Vge="function"==typeof Gge?Gge:()=>null;let Fge=0;function Jge(e=null){const n=Vge(),t=a.useRef(e||n||null);return null===t.current&&(t.current=""+Fge++),null!=e?e:t.current}function Uge({children:e,className:n="",collapsedSize:t,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",...v}){const f=a.useContext(Ege);if(null===f)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:k,getPanelSize:b,getPanelStyle:S,groupId:A,isPanelCollapsed:w,reevaluatePanelConstraints:C,registerPanel:M,resizePanel:T,unregisterPanel:N}=f,E=Jge(s),x=a.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:m},constraints:{collapsedSize:t,collapsible:i,defaultSize:r,maxSize:l,minSize:u},id:E,idIsFromProps:void 0!==s,order:h});a.useRef({didLogMissingDefaultSizeWarning:!1}),Ige((()=>{const{callbacks:e,constraints:a}=x.current,n={...a};x.current.id=E,x.current.idIsFromProps=void 0!==s,x.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=m,a.collapsedSize=t,a.collapsible=i,a.defaultSize=r,a.maxSize=l,a.minSize=u,n.collapsedSize===a.collapsedSize&&n.collapsible===a.collapsible&&n.maxSize===a.maxSize&&n.minSize===a.minSize||C(x.current,n)})),Ige((()=>{const e=x.current;return M(e),()=>{N(e)}}),[h,E,M,N]),a.useImperativeHandle(o,(()=>({collapse:()=>{y(x.current)},expand:e=>{k(x.current,e)},getId:()=>E,getSize:()=>b(x.current),isCollapsed:()=>w(x.current),isExpanded:()=>!w(x.current),resize:e=>{T(x.current,e)}})),[y,k,b,w,E,T]);const P=S(x.current,r);return a.createElement(g,{...v,children:e,className:n,id:E,style:{...P,...p},[jge]:A,[Lge]:"",[Bge]:i||void 0,[zge]:E,[Rge]:parseFloat(""+P.flexGrow).toFixed(1)})}const Wge=a.forwardRef(((e,n)=>a.createElement(Uge,{...e,forwardedRef:n})));Uge.displayName="Panel",Wge.displayName="forwardRef(Panel)";let qge=null,Zge=-1,$ge=null;function Yge(e,a){var n,t;const i=function(e,a){if(a){const e=!!(a&cve),n=!!(a&dve);if(a&lve)return e?"se-resize":n?"ne-resize":"e-resize";if(a&uve)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,a);if(qge!==i){var r;if(qge=i,null===$ge&&($ge=document.createElement("style"),document.head.appendChild($ge)),Zge>=0)null===(r=$ge.sheet)||void 0===r||r.removeRule(Zge);Zge=null!==(n=null===(t=$ge.sheet)||void 0===t?void 0:t.insertRule(`*{cursor: ${i} !important;}`))&&void 0!==n?n:-1}}function Qge(e){return"keydown"===e.type}function Xge(e){return e.type.startsWith("pointer")}function eve(e){return e.type.startsWith("mouse")}function ave(e){if(Xge(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(eve(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const nve=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function tve(e){const a=getComputedStyle(e);return"fixed"===a.position||(!("auto"===a.zIndex||"static"===a.position&&!function(e){var a;const n=getComputedStyle(null!==(a=sve(e))&&void 0!==a?a:e).display;return"flex"===n||"inline-flex"===n}(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||(!!nve.test(a.willChange)||"touch"===a.webkitOverflowScrolling)))))))))}function ive(e){let a=e.length;for(;a--;){const n=e[a];if(Eve(n,"Missing node"),tve(n))return n}return null}function rve(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ove(e){const a=[];for(;e;)a.push(e),e=sve(e);return a}function sve(e){const{parentNode:a}=e;return a&&a instanceof ShadowRoot?a.host:a}const lve=1,uve=2,cve=4,dve=8,mve="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let hve=[],pve=!1,gve=new Map,vve=new Map;const fve=new Set;function yve(e){const{target:a}=e,{x:n,y:t}=ave(e);pve=!0,Ave({target:a,x:n,y:t}),Tve(),hve.length>0&&(Nve("down",e),e.preventDefault(),Sve(a)||e.stopImmediatePropagation())}function kve(e){const{x:a,y:n}=ave(e);if(pve&&0===e.buttons&&(pve=!1,Nve("up",e)),!pve){const{target:t}=e;Ave({target:t,x:a,y:n})}Nve("move",e),Cve(),hve.length>0&&e.preventDefault()}function bve(e){const{target:a}=e,{x:n,y:t}=ave(e);vve.clear(),pve=!1,hve.length>0&&(e.preventDefault(),Sve(a)||e.stopImmediatePropagation()),Nve("up",e),Ave({target:a,x:n,y:t}),Cve(),Tve()}function Sve(e){let a=e;for(;a;){if(a.hasAttribute(_ge))return!0;a=a.parentElement}return!1}function Ave({target:e,x:a,y:n}){hve.splice(0);let t=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(t=e),fve.forEach((e=>{const{element:i,hitAreaMargins:r}=e,o=i.getBoundingClientRect(),{bottom:s,left:l,right:u,top:c}=o,d=mve?r.coarse:r.fine;if(a>=l-d&&a<=u+d&&n>=c-d&&n<=s+d){if(null!==t&&document.contains(t)&&i!==t&&!i.contains(t)&&!t.contains(i)&&function(e,a){if(e===a)throw new Error("Cannot compare node with itself");const n={a:ove(e),b:ove(a)};let t;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),a=n.b.pop(),t=e;Eve(t,"Stacking order can only be calculated for elements with a common ancestor");const i=rve(ive(n.a)),r=rve(ive(n.b));if(i===r){const e=t.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let i=e.length;for(;i--;){const n=e[i];if(n===a.a)return 1;if(n===a.b)return-1}}return Math.sign(i-r)}(t,i)>0){let e=t,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}hve.push(e)}var m,h}))}function wve(e,a){vve.set(e,a)}function Cve(){let e=!1,a=!1;hve.forEach((n=>{const{direction:t}=n;"horizontal"===t?e=!0:a=!0}));let n=0;vve.forEach((e=>{n|=e})),e&&a?Yge("intersection",n):e?Yge("horizontal",n):a?Yge("vertical",n):null!==$ge&&(document.head.removeChild($ge),qge=null,$ge=null,Zge=-1)}let Mve=new AbortController;function Tve(){Mve.abort(),Mve=new AbortController;const e={capture:!0,signal:Mve.signal};fve.size&&(pve?(hve.length>0&&gve.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("contextmenu",bve,e),t.addEventListener("pointerleave",kve,e),t.addEventListener("pointermove",kve,e))})),gve.forEach(((a,n)=>{const{body:t}=n;t.addEventListener("pointerup",bve,e),t.addEventListener("pointercancel",bve,e)}))):gve.forEach(((a,n)=>{const{body:t}=n;a>0&&(t.addEventListener("pointerdown",yve,e),t.addEventListener("pointermove",kve,e))})))}function Nve(e,a){fve.forEach((n=>{const{setResizeHandlerState:t}=n,i=hve.includes(n);t(e,i,a)}))}function Eve(e,a){if(!e)throw Error(a)}function xve(e,a,n=10){return e.toFixed(n)===a.toFixed(n)?0:e>a?1:-1}function Pve(e,a,n=10){return 0===xve(e,a,n)}function jve(e,a,n){return 0===xve(e,a,n)}function Lve({panelConstraints:e,panelIndex:a,size:n}){const t=e[a];Eve(null!=t,`Panel constraints not found for index ${a}`);let{collapsedSize:i=0,collapsible:r,maxSize:o=100,minSize:s=0}=t;if(xve(n,s)<0)if(r){n=xve(n,(i+s)/2)<0?i:s}else n=s;return n=Math.min(o,n),n=parseFloat(n.toFixed(10))}function Bve({delta:e,initialLayout:a,panelConstraints:n,pivotIndices:t,prevLayout:i,trigger:r}){if(jve(e,0))return a;const o=[...a],[s,l]=t;Eve(null!=s,"Invalid first pivot index"),Eve(null!=l,"Invalid second pivot index");let u=0;if("keyboard"===r){{const t=e<0?l:s,i=n[t];Eve(i,`Panel constraints not found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(Eve(null!=n,`Previous layout not found for panel index ${t}`),jve(n,r)){const a=u-n;xve(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}{const t=e<0?s:l,i=n[t];Eve(i,`No panel constraints found for index ${t}`);const{collapsedSize:r=0,collapsible:o,minSize:u=0}=i;if(o){const n=a[t];if(Eve(null!=n,`Previous layout not found for panel index ${t}`),jve(n,u)){const a=n-r;xve(a,Math.abs(e))>0&&(e=e<0?0-a:a)}}}}{const t=e<0?1:-1;let i=e<0?l:s,r=0;for(;;){const e=a[i];Eve(null!=e,`Previous layout not found for panel index ${i}`);if(r+=Lve({panelConstraints:n,panelIndex:i,size:100})-e,i+=t,i<0||i>=n.length)break}const o=Math.min(Math.abs(e),Math.abs(r));e=e<0?0-o:o}{let t=e<0?s:l;for(;t>=0&&t<n.length;){const i=Math.abs(e)-Math.abs(u),r=a[t];Eve(null!=r,`Previous layout not found for panel index ${t}`);const s=Lve({panelConstraints:n,panelIndex:t,size:r-i});if(!jve(r,s)&&(u+=r-s,o[t]=s,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,a,n){if(e.length!==a.length)return!1;for(let t=0;t<e.length;t++)if(!jve(e[t],a[t],n))return!1;return!0}(i,o))return i;{const t=e<0?l:s,i=a[t];Eve(null!=i,`Previous layout not found for panel index ${t}`);const r=i+u,c=Lve({panelConstraints:n,panelIndex:t,size:r});if(o[t]=c,!jve(c,r)){let a=r-c;let t=e<0?l:s;for(;t>=0&&t<n.length;){const i=o[t];Eve(null!=i,`Previous layout not found for panel index ${t}`);const r=Lve({panelConstraints:n,panelIndex:t,size:i+a});if(jve(i,r)||(a-=r-i,o[t]=r),jve(a,0))break;e>0?t--:t++}}}return jve(o.reduce(((e,a)=>a+e),0),100)?o:i}function zve({layout:e,panelsArray:a,pivotIndices:n}){let t=0,i=100,r=0,o=0;const s=n[0];Eve(null!=s,"No pivot index found"),a.forEach(((e,a)=>{const{constraints:n}=e,{maxSize:l=100,minSize:u=0}=n;a===s?(t=u,i=l):(r+=u,o+=l)}));return{valueMax:Math.min(i,100-r),valueMin:Math.max(t,100-o),valueNow:e[s]}}function Rve(e,a=document){return Array.from(a.querySelectorAll(`[${Hge}][data-panel-group-id="${e}"]`))}function _ve(e,a,n=document){const t=Rve(e,n).findIndex((e=>e.getAttribute(Hge)===a));return null!=t?t:null}function Dve(e,a,n){const t=_ve(e,a,n);return null!=t?[t,t+1]:[-1,-1]}function Kve(e,a=document){var n;if(a instanceof HTMLElement&&(null==a||null===(n=a.dataset)||void 0===n?void 0:n.panelGroupId)==e)return a;const t=a.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function Hve(e,a=document){const n=a.querySelector(`[${Hge}="${e}"]`);return n||null}function Ove({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:i,panelDataArray:r,panelGroupElement:o,setLayout:s}){a.useRef({didWarnAboutMissingResizeHandle:!1}),Ige((()=>{if(!o)return;const e=Rve(t,o);for(let a=0;a<r.length-1;a++){const{valueMax:n,valueMin:t,valueNow:o}=zve({layout:i,panelsArray:r,pivotIndices:[a,a+1]}),s=e[a];if(null==s);else{const e=r[a];Eve(e,`No panel data found for index "${a}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(n)),s.setAttribute("aria-valuemin",""+Math.round(t)),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")}))}}),[t,i,r,o]),a.useEffect((()=>{if(!o)return;const e=n.current;Eve(e,"Eager values not found");const{panelDataArray:a}=e;Eve(null!=Kve(t,o),`No group found for id "${t}"`);const r=Rve(t,o);Eve(r,`No resize handles found for group id "${t}"`);const l=r.map((e=>{const n=e.getAttribute(Hge);Eve(n,"Resize handle element has no handle id attribute");const[r,l]=function(e,a,n,t=document){var i,r,o,s;const l=Hve(a,t),u=Rve(e,t),c=l?u.indexOf(l):-1;return[null!==(i=null===(r=n[c])||void 0===r?void 0:r.id)&&void 0!==i?i:null,null!==(o=null===(s=n[c+1])||void 0===s?void 0:s.id)&&void 0!==o?o:null]}(t,n,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];Eve(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=Bve({delta:jve(r,u)?d-u:u-r,initialLayout:i,panelConstraints:a.map((e=>e.constraints)),pivotIndices:Dve(t,n,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,n,t,i,r,s])}function Ive(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==a[n])return!1;return!0}function Gve(e,a){const n="horizontal"===e,{x:t,y:i}=ave(a);return n?t:i}function Vve(e,a,n,t,i,r){if(Qge(e)){const a="horizontal"===n;let t=0;t=e.shiftKey?100:null!=i?i:10;let r=0;switch(e.key){case"ArrowDown":r=a?0:t;break;case"ArrowLeft":r=a?-t:0;break;case"ArrowRight":r=a?t:0;break;case"ArrowUp":r=a?0:-t;break;case"End":r=100;break;case"Home":r=-100}return r}return null==t?0:function(e,a,n,t,i){const r="horizontal"===n,o=Hve(a,i);Eve(o,`No resize handle element found for id "${a}"`);const s=o.getAttribute(jge);Eve(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=t;const u=Gve(n,e),c=Kve(s,i);Eve(c,`No group element found for id "${s}"`);const d=c.getBoundingClientRect();return(u-l)/(r?d.width:d.height)*100}(e,a,n,t,r)}function Fve(e,a,n){a.forEach(((a,t)=>{const i=e[t];Eve(i,`Panel data not found for index ${t}`);const{callbacks:r,constraints:o,id:s}=i,{collapsedSize:l=0,collapsible:u}=o,c=n[s];if(null==c||a!==c){n[s]=a;const{onCollapse:e,onExpand:t,onResize:i}=r;i&&i(a,c),u&&(e||t)&&(!t||null!=c&&!Pve(c,l)||Pve(a,l)||t(),!e||null!=c&&Pve(c,l)||!Pve(a,l)||e())}}))}function Jve(e,a){if(e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=a[n])return!1;return!0}function Uve(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 Wve(e){return`react-resizable-panels:${e}`}function qve(e){return e.map((e=>{const{constraints:a,id:n,idIsFromProps:t,order:i}=e;return t?n:i?`${i}:${JSON.stringify(a)}`:JSON.stringify(a)})).sort(((e,a)=>e.localeCompare(a))).join(",")}function Zve(e,a){try{const n=Wve(e),t=a.getItem(n);if(t){const e=JSON.parse(t);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function $ve(e,a,n,t,i){var r;const o=Wve(e),s=qve(a),l=null!==(r=Zve(e,i))&&void 0!==r?r:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:t};try{i.setItem(o,JSON.stringify(l))}catch(u){}}function Yve({layout:e,panelConstraints:a}){const n=[...e],t=n.reduce(((e,a)=>e+a),0);if(n.length!==a.length)throw Error(`Invalid ${a.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!jve(t,100)&&n.length>0)for(let r=0;r<a.length;r++){const e=n[r];Eve(null!=e,`No layout data found for index ${r}`);n[r]=100/t*e}let i=0;for(let r=0;r<a.length;r++){const e=n[r];Eve(null!=e,`No layout data found for index ${r}`);const t=Lve({panelConstraints:a,panelIndex:r,size:e});e!=t&&(i+=e-t,n[r]=t)}if(!jve(i,0))for(let r=0;r<a.length;r++){const e=n[r];Eve(null!=e,`No layout data found for index ${r}`);const t=Lve({panelConstraints:a,panelIndex:r,size:e+i});if(e!==t&&(i-=t-e,n[r]=t,jve(i,0)))break}return n}const Qve={getItem:e=>(Uve(Qve),Qve.getItem(e)),setItem:(e,a)=>{Uve(Qve),Qve.setItem(e,a)}},Xve={};function efe({autoSaveId:e=null,children:n,className:t="",direction:i,forwardedRef:r,id:o=null,onLayout:s=null,keyboardResizeBy:l=null,storage:u=Qve,style:c,tagName:d="div",...m}){const h=Jge(o),p=a.useRef(null),[g,v]=a.useState(null),[f,y]=a.useState([]),k=function(){const[e,n]=a.useState(0);return a.useCallback((()=>n((e=>e+1))),[])}(),b=a.useRef({}),S=a.useRef(new Map),A=a.useRef(0),w=a.useRef({autoSaveId:e,direction:i,dragState:g,id:h,keyboardResizeBy:l,onLayout:s,storage:u}),C=a.useRef({layout:f,panelDataArray:[],panelDataArrayChanged:!1});a.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),a.useImperativeHandle(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current,i=Yve({layout:e,panelConstraints:t.map((e=>e.constraints))});Ive(n,i)||(y(i),C.current.layout=i,a&&a(i),Fve(t,i,b.current))}})),[]),Ige((()=>{w.current.autoSaveId=e,w.current.direction=i,w.current.dragState=g,w.current.id=h,w.current.onLayout=s,w.current.storage=u})),Ove({committedValuesRef:w,eagerValuesRef:C,groupId:h,layout:f,panelDataArray:C.current.panelDataArray,setLayout:y,panelGroupElement:p.current}),a.useEffect((()=>{const{panelDataArray:a}=C.current;if(e){if(0===f.length||f.length!==a.length)return;let n=Xve[e];null==n&&(n=function(e,a=10){let n=null;return(...t)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...t)}),a)}}($ve,100),Xve[e]=n);const t=[...a],i=new Map(S.current);n(e,t,i,f,u)}}),[e,f,u]),a.useEffect((()=>{}));const M=a.useCallback((e=>{const{onLayout:a}=w.current,{layout:n,panelDataArray:t}=C.current;if(e.constraints.collapsible){const i=t.map((e=>e.constraints)),{collapsedSize:r=0,panelSize:o,pivotIndices:s}=tfe(t,e,n);if(Eve(null!=o,`Panel size not found for panel "${e.id}"`),!Pve(o,r)){S.current.set(e.id,o);const l=Bve({delta:nfe(t,e)===t.length-1?o-r:r-o,initialLayout:n,panelConstraints:i,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});Jve(n,l)||(y(l),C.current.layout=l,a&&a(l),Fve(t,l,b.current))}}}),[]),T=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,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}=tfe(i,e,t),c=null!=a?a:l;if(Pve(s,o)){const a=S.current.get(e.id),o=null!=a&&a>=c?a:c,l=Bve({delta:nfe(i,e)===i.length-1?s-o:o-s,initialLayout:t,panelConstraints:r,pivotIndices:u,prevLayout:t,trigger:"imperative-api"});Jve(t,l)||(y(l),C.current.layout=l,n&&n(l),Fve(i,l,b.current))}}}),[]),N=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{panelSize:t}=tfe(n,e,a);return Eve(null!=t,`Panel size not found for panel "${e.id}"`),t}),[]),E=a.useCallback(((e,a)=>{const{panelDataArray:n}=C.current,t=nfe(n,e);return function({defaultSize:e,dragState:a,layout:n,panelData:t,panelIndex:i,precision:r=3}){const o=n[i];let s;return s=null==o?null!=e?e.toPrecision(r):"1":1===t.length?"1":o.toPrecision(r),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==a?"none":void 0}}({defaultSize:a,dragState:g,layout:f,panelData:n,panelIndex:t})}),[g,f]),x=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=tfe(n,e,a);return Eve(null!=r,`Panel size not found for panel "${e.id}"`),!0===i&&Pve(r,t)}),[]),P=a.useCallback((e=>{const{layout:a,panelDataArray:n}=C.current,{collapsedSize:t=0,collapsible:i,panelSize:r}=tfe(n,e,a);return Eve(null!=r,`Panel size not found for panel "${e.id}"`),!i||xve(r,t)>0}),[]),j=a.useCallback((e=>{const{panelDataArray:a}=C.current;a.push(e),a.sort(((e,a)=>{const n=e.order,t=a.order;return null==n&&null==t?0:null==n?-1:null==t?1:n-t})),C.current.panelDataArrayChanged=!0,k()}),[k]);Ige((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:a,storage:n}=w.current,{layout:t,panelDataArray:i}=C.current;let r=null;if(e){const a=function(e,a,n){var t,i;return null!==(i=(null!==(t=Zve(e,n))&&void 0!==t?t:{})[qve(a)])&&void 0!==i?i:null}(e,i,n);a&&(S.current=new Map(Object.entries(a.expandToSizes)),r=a.layout)}null==r&&(r=function({panelDataArray:e}){const a=Array(e.length),n=e.map((e=>e.constraints));let t=0,i=100;for(let r=0;r<e.length;r++){const e=n[r];Eve(e,`Panel constraints not found for index ${r}`);const{defaultSize:o}=e;null!=o&&(t++,a[r]=o,i-=o)}for(let r=0;r<e.length;r++){const o=n[r];Eve(o,`Panel constraints not found for index ${r}`);const{defaultSize:s}=o;if(null!=s)continue;const l=i/(e.length-t);t++,a[r]=l,i-=l}return a}({panelDataArray:i}));const o=Yve({layout:r,panelConstraints:i.map((e=>e.constraints))});Ive(t,o)||(y(o),C.current.layout=o,a&&a(o),Fve(i,o,b.current))}})),Ige((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const L=a.useCallback((e=>{let a=!1;const n=p.current;if(n){"rtl"===window.getComputedStyle(n,null).getPropertyValue("direction")&&(a=!0)}return function(n){n.preventDefault();const t=p.current;if(!t)return()=>null;const{direction:i,dragState:r,id:o,keyboardResizeBy:s,onLayout:l}=w.current,{layout:u,panelDataArray:c}=C.current,{initialLayout:d}=null!=r?r:{},m=Dve(o,e,t);let h=Vve(n,e,i,r,s,t);const g="horizontal"===i;g&&a&&(h=-h);const v=Bve({delta:h,initialLayout:null!=d?d:u,panelConstraints:c.map((e=>e.constraints)),pivotIndices:m,prevLayout:u,trigger:Qge(n)?"keyboard":"mouse-or-touch"}),f=!Jve(u,v);(Xge(n)||eve(n))&&A.current!=h&&(A.current=h,wve(e,f||0===h?0:g?h<0?lve:uve:h<0?cve:dve)),f&&(y(v),C.current.layout=v,l&&l(v),Fve(c,v,b.current))}}),[]),B=a.useCallback(((e,a)=>{const{onLayout:n}=w.current,{layout:t,panelDataArray:i}=C.current,r=i.map((e=>e.constraints)),{panelSize:o,pivotIndices:s}=tfe(i,e,t);Eve(null!=o,`Panel size not found for panel "${e.id}"`);const l=Bve({delta:nfe(i,e)===i.length-1?o-a:a-o,initialLayout:t,panelConstraints:r,pivotIndices:s,prevLayout:t,trigger:"imperative-api"});Jve(t,l)||(y(l),C.current.layout=l,n&&n(l),Fve(i,l,b.current))}),[]),z=a.useCallback(((e,a)=>{const{layout:n,panelDataArray:t}=C.current,{collapsedSize:i=0,collapsible:r}=a,{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:u=0}=e.constraints,{panelSize:c}=tfe(t,e,n);null!=c&&(r&&s&&Pve(c,i)?Pve(i,o)||B(e,o):c<u?B(e,u):c>l&&B(e,l))}),[B]),R=a.useCallback(((e,a)=>{const{direction:n}=w.current,{layout:t}=C.current;if(!p.current)return;const i=Hve(e,p.current);Eve(i,`Drag handle element not found for id "${e}"`);const r=Gve(n,a);v({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:r,initialLayout:t})}),[]),_=a.useCallback((()=>{v(null)}),[]),D=a.useCallback((e=>{const{panelDataArray:a}=C.current,n=nfe(a,e);n>=0&&(a.splice(n,1),delete b.current[e.id],C.current.panelDataArrayChanged=!0,k())}),[k]),K=a.useMemo((()=>({collapsePanel:M,direction:i,dragState:g,expandPanel:T,getPanelSize:N,getPanelStyle:E,groupId:h,isPanelCollapsed:x,isPanelExpanded:P,reevaluatePanelConstraints:z,registerPanel:j,registerResizeHandle:L,resizePanel:B,startDragging:R,stopDragging:_,unregisterPanel:D,panelGroupElement:p.current})),[M,g,i,T,N,E,h,x,P,z,j,L,B,R,_,D]);return a.createElement(Ege.Provider,{value:K},a.createElement(d,{...m,children:n,className:t,id:o,ref:p,style:{...{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%"},...c},[xge]:"",[Pge]:i,[jge]:h}))}const afe=a.forwardRef(((e,n)=>a.createElement(efe,{...e,forwardedRef:n})));function nfe(e,a){return e.findIndex((e=>e===a||e.id===a.id))}function tfe(e,a,n){const t=nfe(e,a);return{...a.constraints,panelSize:n[t],pivotIndices:t===e.length-1?[t-1,t]:[t,t+1]}}function ife({children:e=null,className:n="",disabled:t=!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 v,f;const y=a.useRef(null),k=a.useRef({onClick:s,onDragging:l,onPointerDown:c,onPointerUp:d});a.useEffect((()=>{k.current.onClick=s,k.current.onDragging=l,k.current.onPointerDown=c,k.current.onPointerUp=d}));const b=a.useContext(Ege);if(null===b)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:S,groupId:A,registerResizeHandle:w,startDragging:C,stopDragging:M,panelGroupElement:T}=b,N=Jge(r),[E,x]=a.useState("inactive"),[P,j]=a.useState(!1),[L,B]=a.useState(null),z=a.useRef({state:E});Ige((()=>{z.current.state=E})),a.useEffect((()=>{if(t)B(null);else{const e=w(N);B((()=>e))}}),[t,N,w]);const R=null!==(v=null==i?void 0:i.coarse)&&void 0!==v?v:15,_=null!==(f=null==i?void 0:i.fine)&&void 0!==f?f:5;a.useEffect((()=>{if(t||null==L)return;const e=y.current;Eve(e,"Element ref not attached");let a=!1;return function(e,a,n,t,i){var r;const{ownerDocument:o}=a,s={direction:n,element:a,hitAreaMargins:t,setResizeHandlerState:i},l=null!==(r=gve.get(o))&&void 0!==r?r:0;return gve.set(o,l+1),fve.add(s),Tve(),function(){var a;vve.delete(e),fve.delete(s);const n=null!==(a=gve.get(o))&&void 0!==a?a:1;if(gve.set(o,n-1),Tve(),1===n&&gve.delete(o),hve.includes(s)){const e=hve.indexOf(s);e>=0&&hve.splice(e,1),Cve(),i("up",!0,null)}}}(N,e,S,{coarse:R,fine:_},((e,n,t)=>{if(n)switch(e){case"down":{x("drag"),a=!1,Eve(t,'Expected event to be defined for "down" action'),C(N,t);const{onDragging:e,onPointerDown:n}=k.current;null==e||e(!0),null==n||n();break}case"move":{const{state:e}=z.current;a=!0,"drag"!==e&&x("hover"),Eve(t,'Expected event to be defined for "move" action'),L(t);break}case"up":{x("hover"),M();const{onClick:e,onDragging:n,onPointerUp:t}=k.current;null==n||n(!1),null==t||t(),a||null==e||e();break}}else x("inactive")}))}),[R,S,t,_,w,N,L,C,M]),function({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:i}){a.useEffect((()=>{if(e||null==t||null==i)return;const a=Hve(n,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(),t(e);break;case"F6":{e.preventDefault();const t=a.getAttribute(jge);Eve(t,`No group element found for id "${t}"`);const r=Rve(t,i),o=_ve(t,n,i);Eve(null!==o,`No resize element found for id "${n}"`),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,n,t])}({disabled:t,handleId:N,resizeHandler:L,panelGroupElement:T});return a.createElement(p,{...g,children:e,className:n,id:r,onBlur:()=>{j(!1),null==o||o()},onFocus:()=>{j(!0),null==u||u()},ref:y,role:"separator",style:{touchAction:"none",userSelect:"none",...m},tabIndex:h,[Pge]:S,[jge]:A,[_ge]:"",[Dge]:"drag"===E?"pointer":P?"keyboard":void 0,[Kge]:!t,[Hge]:N,[Oge]:E})}efe.displayName="PanelGroup",afe.displayName="forwardRef(PanelGroup)",ife.displayName="PanelResizeHandle";const rfe=({className:e,...a})=>n.jsx(afe,{className:GG("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...a}),ofe=Wge,sfe=({withHandle:e,className:a,...t})=>n.jsx(ife,{className:GG("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),...t,children:e&&n.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:n.jsx(Gc,{className:"h-2.5 w-2.5"})})}),lfe=({copyText:e})=>n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),ufe="rgba(245, 246, 247, 1)",cfe={[ua.SEND_COMMUNICATION]:{color:{bg:ufe},clickable:!0},[ua.WAIT_UNTIL_NEXT_FIXED_TIME]:{color:{bg:ufe},clickable:!1}},dfe={[ua.SEND_COMMUNICATION]:"Send Email & SMS",[ua.WAIT_UNTIL_NEXT_FIXED_TIME]:"Wait"},mfe=({children:e,onClick:a,iconBgColor:t,iconStrokeColor:i,Icon:r,disabled:o=!1,selected:s=!1})=>{const l=r;return n.jsxs(Z$.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?t:ufe},onClick:a,className:pm("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:[n.jsx("div",{className:pm("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",t),children:n.jsx(l,{className:pm("w-4 h-4 stroke-purple-500 group-hover/trigger-audience:fill-purple-50 transition-colors",i)})}),e]})},hfe=({segmentName:e})=>n.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}),pfe=()=>{const e=AY(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(uY),[r,o]=a.useState(e?.includeSegmentIds||null),[s,l]=a.useState(e?.excludeSegmentIds||null),{segments:u}=pY(),c=a.useCallback((()=>u?.find((e=>e.type===kY.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?n.jsx(n.Fragment,{children:n.jsx(mfe,{selected:i===jie.EditAudience,iconBgColor:"bg-purple-50",iconStrokeColor:"stroke-purple-500",onClick:()=>{t(jie.EditAudience)},Icon:zY.AudienceIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Fce,{children:"Audience"}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(lfe,{copyText:`Send to all ${Eh("engage:user",{count:2})} in ${1===r.length?"this":"these"} ${Eh("engage:segment",{count:r.length}).toLowerCase()}`}),n.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map((e=>{const a=u?.find((a=>a.id===e));return a?n.jsx(hfe,{segmentName:a.name},e):null}))})]})]})})}):null},gfe=()=>{const e=AY(),{setActionId:t,state:{selectedActionId:i}}=a.useContext(uY),{segments:r}=pY(),o=Eh(e?.triggerType===oa.TRIGGER_BASED?"engage:automation":"engage:broadcast"),s=`Start this ${o?.toLowerCase()}`;if(!e||!r)return null;return n.jsx(n.Fragment,{children:(()=>{switch(e.triggerType){case oa.TRIGGER_BASED:{if(e.triggerMetadata&&e.triggerMetadata.triggerType!==oa.TRIGGER_BASED||!e.triggerMetadata||e.triggerMetadata.eventName!==sa.USER_ENTERS_SEGMENT||!e.triggerMetadata.eventFilter.segment_id)return null;const a=e.triggerMetadata.eventFilter.segment_id,t=r.find((e=>e.id===a))?.name;return t?n.jsx(mfe,{iconBgColor:"bg-amber-100",disabled:!0,iconStrokeColor:"stroke-amber-500",onClick:()=>{},Icon:zY.TriggerIcon,children:n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Fce,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(lfe,{copyText:`When ${Eh("engage:user").toLowerCase()} joins the`}),n.jsx(hfe,{segmentName:t})]})]})}):null}case oa.ONE_TIME:{const a=!e.triggerMetadata||!("scheduledAt"in e.triggerMetadata);return n.jsxs(mfe,{iconBgColor:"bg-amber-100",iconStrokeColor:"stroke-amber-500",onClick:()=>{t(jie.EditTime)},selected:i===jie.EditTime,Icon:zY.TriggerIcon,children:[n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx(Fce,{children:s}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(lfe,a?{copyText:`Click to set the date and time for this ${Eh("engage:broadcast")}`}:{copyText:"Bulk send at"}),!1===a&&e.triggerMetadata&&"scheduledAt"in e.triggerMetadata&&e.triggerMetadata.scheduledAt&&n.jsx("div",{className:"text-xs font-medium",children:n.jsx(hfe,{segmentName:"now"===e.triggerMetadata.scheduledAt?"5 minutes after send":dae(new Date(e.triggerMetadata.scheduledAt),"h:mma MM/dd/yy")})})]})]}),n.jsx("div",{className:"",children:a&&n.jsx(Mae,{title:"Please select a time before sending this ${t('engage:broadcast')}.",alertText:`A scheduled time is needed before sending this ${Eh("engage:broadcast")}.`,Icon:zY.AlertTriangleIcon,iconColor:"text-red-500",size:"large"})})]})}default:throw g9(e.triggerType,oa)}})()})},vfe=({type:e,disabled:t=!1,actionId:i})=>{const{state:{selectedSubStepType:r},setSelectedSubStepType:o,setActionId:s}=a.useContext(uY),l=wY(),u=r===e,c=a.useCallback((()=>{if(!l)return"Need to select a channel";switch(e){case Lie.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 Lie.SMS:return l.smsChannelSenderId?!!l.smsMessageBody||"Please add content to the sms":"Please select a sms sender"}}),[l,e]);if(t)return null;const d=c();return n.jsx(Z$.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15,ease:"easeInOut"},className:pm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group","border-2 border-transparent",u&&"border-primary",!t&&"hover:border-muted-foreground/30",t&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:u?"#f5f6f7":ufe},onClick:()=>{t||(s(i),o(e))},children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.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 Lie.EMAIL:return n.jsx(zY.EmailIcon,{className:pm("w-6 h-6",a?"text-primary":"text-gray-400")});case Lie.SMS:return n.jsx(zY.SmsIcon,{className:pm("w-6 h-6",a?"text-primary":"text-gray-400")})}})(e,u)}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("div",{style:{color:u?"#3b82f6":"#64748b"},children:n.jsx(Fce,{className:"text-xs",children:(()=>{switch(e){case Lie.EMAIL:return"Email";case Lie.SMS:return"SMS"}})()})}),n.jsx("div",{className:"text-[10px] font-medium text-muted-foreground",children:(()=>{if(!l)return"";switch(e){case Lie.EMAIL:return l.emailSubject||"No subject set";case Lie.SMS:return l.smsMessageBody?`${l.smsMessageBody.substring(0,40)}${l.smsMessageBody.length>40?"...":""}`:"No message set"}})()}),!0!==d&&n.jsx("div",{className:"text-[10px] text-amber-600 font-medium",children:d})]})]})})},ffe=e=>{switch(e){case ua.SEND_COMMUNICATION:return"Send Communication";case ua.WAIT_UNTIL_NEXT_FIXED_TIME:return"Wait";default:throw tY(e,ua)}},yfe=e=>{switch(e){case ua.SEND_COMMUNICATION:return n.jsx(zY.CommunicationIcon,{className:"w-4 h-4"});case ua.WAIT_UNTIL_NEXT_FIXED_TIME:return n.jsx(zY.WaitUntilNextFixedTimeIcon,{className:"w-4 h-4"});default:throw g9(e,ua)}},kfe=e=>{if(!(e&&e.actionType===ua.WAIT_UNTIL_NEXT_FIXED_TIME&&"hour"in e&&"minute"in e&&"timezone"in e))return null;const{hour:a,minute:n,timezone:t}=e;return`Wait until next ${`${a?.toString().padStart(2,"0")}:${n?.toString().padStart(2,"0")}`} ${t}`},bfe=({actionDataWithMetadata:e})=>{const{actionData:t,communicationGroup:i}=e,{state:{selectedActionId:r},setActionId:o,setSelectedCommunicationGroupId:s}=a.useContext(uY),l=a.useMemo((()=>r===t.actionMetadata.currentActionId),[r,t.actionMetadata.currentActionId]),u=cfe[t.actionType],c=u.color,d=u.clickable;return n.jsxs(Z$.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeInOut"},className:pm("p-2 pr-3 flex gap-2 items-center rounded-md transition-colors cursor-pointer group"," border-2 border-transparent",l&&"border-primary",t.actionType!==ua.WAIT_UNTIL_NEXT_FIXED_TIME&&"hover:border-primary"),style:{backgroundColor:l?c.bg:c.bgUnselected??ufe},onClick:()=>{d&&(o(t.actionMetadata.currentActionId),t.actionType===ua.SEND_COMMUNICATION&&s(t.actionMetadata.communicationGroupId))},children:[n.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[n.jsx("div",{className:"rounded-md p-2 flex items-center justify-center w-8 h-8 flex-shrink-0 bg-white",children:yfe(t.actionType)}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{style:{color:l?c.text:c.textUnselected},children:n.jsx(Fce,{children:dfe[t.actionType]})}),n.jsx("div",t.actionType===ua.WAIT_UNTIL_NEXT_FIXED_TIME?{className:"text-[11px] text-muted-foreground font-normal rounded bg-muted/40 w-fit max-w-full truncate",children:kfe(t.actionMetadata)}:{className:"text-xs font-medium text-muted-foreground",children:t.actionType===ua.SEND_COMMUNICATION&&i?.emailSubject?i?.emailSubject:ffe(t.actionType)})]})]}),t.actionType===ua.SEND_COMMUNICATION&&n.jsx("div",{className:"flex items-center pr-2",children:n.jsx(zY.NextButton,l?{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"})})]})},Sfe=()=>{const e=wY(),[t,i]=a.useState(!1),[r,o]=a.useState(void 0),s=AY(),{setActionId:l,setSelectedSubStepType:u,state:{selectedActionId:c,selectedSubStepType:d}}=a.useContext(uY);if(na(s?.id||""),a.useEffect((()=>{if(!s)return;if(c)return;const e=s.actionData?.find((e=>"send_communication"===e.actionType));e&&l(e.actionMetadata.currentActionId)}),[s,l,c]),a.useEffect((()=>{if(!s)return;(async()=>{const e=[];for(const a of s.actionData??[])switch(a.actionType){case ua.SEND_COMMUNICATION:{const n=await Ge(a.actionMetadata.communicationGroupId);e.push({actionData:a,communicationGroup:n});break}case ua.WAIT_UNTIL_NEXT_FIXED_TIME:e.push({actionData:a});break;default:throw tY(a.actionType,ua)}o(e)})()}),[s]),a.useEffect((()=>{if(c&&r&&e&&null===d){const a=r.find((e=>e.actionData.actionMetadata.currentActionId===c));"send_communication"===a?.actionData.actionType&&u(e?.emailChannelSenderId?Lie.EMAIL:Lie.SMS)}}),[c,r,u,e,d]),!s||!r)return null;const m=(e=>{const{steps:a,rootActionId:n}=e;if(!a||!n)return a??[];const t=new Map(a.map((e=>[e.actionData.actionMetadata.currentActionId,e]))),i=t.get(n);if(!i)return a;const r=[];let o=i;for(;o;){r.push(o);const e=o.actionData.actionMetadata.nextActionId;if(!e)break;o=t.get(e)}return r})({steps:r,rootActionId:s.triggerMetadata?.triggerType===oa.TRIGGER_BASED?s.triggerMetadata.rootActionId:void 0}).filter((e=>!!t||"send_communication"===e.actionData.actionType));let h=()=>n.jsx("div",{},"empty-trigger-audience");return(t||s.triggerType===oa.ONE_TIME)&&(h=()=>n.jsxs("div",{className:"flex flex-col gap-3",children:[s.triggerType===oa.ONE_TIME&&n.jsx(pfe,{}),s.triggerType!==oa.ONE_TIME&&n.jsx(gfe,{})]})),n.jsxs("div",{className:"flex-1 flex flex-col gap-2 w-full overflow-visible",children:[s.triggerType===oa.TRIGGER_BASED&&n.jsxs("div",{className:"flex gap-2 items-center justify-between",children:[n.jsx("div",{className:"text-[13px] text-muted-foreground",children:"Messages sent in listed order"}),n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("div",{className:"text-[13px] font-medium",children:"Show all details"}),n.jsx(dpe,{defaultChecked:t,onCheckedChange:()=>{i(!t)}})]})]}),n.jsx("div",{className:"flex-1 flex flex-col gap-3",children:n.jsxs(dV,{mode:"popLayout",children:[h(),m.map(((a,t)=>n.jsx(Z$.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,delay:.05*t,ease:"easeInOut"},children:n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(bfe,{actionDataWithMetadata:a}),"send_communication"===a.actionData.actionType&&c===a.actionData.actionMetadata.currentActionId&&a.actionData.actionMetadata.currentActionId&&n.jsxs("div",{className:"flex gap-3",children:[n.jsx(Z$.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2,delay:.25*m.length,ease:"easeInOut"},className:"w-12 flex justify-end items-center",children:n.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full rounded-full"})}),n.jsxs("div",{className:"flex flex-col gap-3 flex-1",children:[e?.emailChannelSenderId&&n.jsx(vfe,{type:Lie.EMAIL,actionId:a.actionData.actionMetadata.currentActionId}),e?.smsChannelSenderId&&n.jsx(vfe,{type:Lie.SMS,actionId:a.actionData.actionMetadata.currentActionId})]})]})]})},a.actionData.actionMetadata?.currentActionId??t))),s.triggerType===oa.ONE_TIME&&n.jsx("div",{className:"flex flex-col gap-3",children:n.jsx(gfe,{})},"one-time-trigger")]})})]})},Afe=()=>{const e=AY(),{segments:a}=pY();return n.jsx("div",e&&a?{className:"h-full pt-4 relative",children:n.jsx("div",{className:"absolute inset-0 overflow-y-auto flex flex-col gap-3",children:n.jsx(Sfe,{})})}:{className:"flex h-full items-center justify-center",children:n.jsx(NY,{text:[`Getting details on your ${Eh("engage:automation",{count:1}).toLowerCase()}`,"Finishing up"]})})},wfe=({disablePreview:e=!1,disableEditContent:t=!1,disablePreviewSubtext:i=!1,hideSms:r=!1})=>{const{state:{selectedSubStepType:o}}=a.useContext(uY);if(!wY())return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx(NY,{text:["Loading..."]})});if(!o)return n.jsx("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h3",{className:"text-lg font-medium text-muted-foreground mb-2",children:"Select Communication Type"}),n.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:t,disablePreviewSubtext:i};return n.jsxs("div",{className:"flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",children:[o===Lie.EMAIL&&n.jsx(Bce,{...s}),o===Lie.SMS&&!r&&n.jsx(Dce,{...s})]})},Cfe=()=>{const{state:{selectedActionId:e}}=a.useContext(uY),{state:{hideSms:t}}=a.useContext(bO);return n.jsx("div",{className:"flex flex-col gap-4 h-full w-full",children:n.jsx(dV,{mode:"wait",children:e===jie.EditTime?n.jsx(Whe,{}):e===jie.EditAudience?n.jsx(Epe,{}):n.jsx(wfe,{hideSms:t})})})},Mfe=()=>n.jsxs(rfe,{direction:"horizontal",className:"flex-1",children:[n.jsx(ofe,{defaultSize:30,minSize:16,maxSize:48,children:n.jsx("aside",{className:"h-full",children:n.jsx(Afe,{})})}),n.jsx(sfe,{className:"px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1"}),n.jsx(ofe,{defaultSize:70,children:n.jsx("main",{className:"h-full",children:n.jsx(Cfe,{})})})]}),Tfe=()=>{const[e,t]=a.useState("workflow"),i=[{id:"workflow",label:"Workflow",content:n.jsx(Mfe,{})},{id:"recipients",label:"Recipients",content:n.jsx(Nge,{})},{id:"insights",label:Eh("engage:insight",{count:2}),content:n.jsx(Mge,{})}];return n.jsx(Gpe,{tabs:i,activeTab:e,onTabChange:t,tabsLocation:"left"})},Nfe=({showBackButton:e=!1,onDuplicationCreated:t,onBeforeSchedule:i,getExtraMergeFields:r,hideSms:o,hideSales:s,replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d})=>{const m=AY(),h=wY(),{updateCommunicationGroup:p}=Ze(),{toast:g}=Ie(),{channelSenders:v}=E9(),f=a.useRef("");return a.useEffect((()=>{if(h&&r){(async()=>{const e=await r(),a=JSON.stringify(e);a!==f.current&&(f.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&&v&&m.automationType===la.MANAGED&&null===h.emailChannelSenderId&&null===h.smsChannelSenderId){if(!h.emailChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.userPart));e.length>0&&p({groupId:h.id,params:{emailChannelSenderId:e[0].id}})}if(!h.smsChannelSenderId){const e=v.results.filter((e=>e.channelSenderMetadata.from||e.channelSenderMetadata.messageServiceSid));e.length>0&&p({groupId:h.id,params:{smsChannelSenderId:e[0].id}})}}}),[m,h,v,p]),m&&h?n.jsx(SO,{children:n.jsx(AO,{replyToSettingsText:l,replyToSettingsLink:u,fromNameSettingsText:c,fromNameSettingsLink:d,hideSms:o,hideSales:s,children:n.jsxs("div",{className:"h-full flex flex-col gap-4",children:[n.jsx(Cge,{showBackButton:e,onDuplicationCreated:t,onBeforeSchedule:i}),n.jsx("div",{className:"flex-1 border-t",children:n.jsx(Tfe,{})})]})})}):n.jsx("div",{className:"flex h-screen items-center justify-center",children:n.jsx(NY,{text:[`Fetching ${Eh("engage:automation").toLowerCase()} data`,"Finishing up"]})})},Efe=({...e})=>{const a=function(){let{matches:e}=r.useContext(X4),a=e[e.length-1];return a?a.params:{}}(),[t]=V5(),i=e.automationId||a?.automationId||t.get("automationId")||"",o="true"===t.get("showBackButton")||e.showBackButton;return n.jsx(MY,{automationId:i,children:n.jsx("div",{className:"bg-background h-full",children:n.jsx(Nfe,{...e,showBackButton:o})})})};Object.values(Object.assign({}));var xfe=e=>null!=e;var Pfe=e=>"function"!=typeof e||e.length?e:e(),jfe=e=>Array.isArray(e)?e:e?[e]:[];var Lfe=Ha;var Bfe,zfe=function(e){const[a,n]=Pa(),t=e?.throw?(e,a)=>{throw n(e instanceof Error?e:new Error(a)),e}:(e,a)=>{n(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,n){let s=o.get(n);s||(s=Pa(void 0,{equals:!1}),o.set(n,s)),s[0]();const l=i.reduce(((e,a)=>{if(null!==e||!a)return e;try{return a.getItem(`${r}${n}`)}catch(cBe){return t(cBe,`Error reading ${r}${n} from ${a.name}`),null}}),null);return null!==l&&e?.deserializer?e.deserializer(l,n,e.options):l}});return!1!==e?.sync&&Ka((()=>{const e=e=>{let a=!1;i.forEach((n=>{try{n!==e.storageArea&&e.key&&e.newValue!==n.getItem(e.key)&&(e.newValue?n.setItem(e.key,e.newValue):n.removeItem(e.key),a=!0)}catch(cBe){t(cBe,`Error synching api ${n.name} from storage event (${e.key}=${e.newValue})`)}})),a&&e.key&&o.get(e.key)?.[1]()};"addEventListener"in globalThis?(globalThis.addEventListener("storage",e),Ha((()=>globalThis.removeEventListener("storage",e)))):(i.forEach((a=>a.addEventListener?.("storage",e))),Ha((()=>i.forEach((a=>a.removeEventListener?.("storage",e))))))})),[s,(a,n,s)=>{const l=e?.serializer?e.serializer(n,a,s??e.options):n,u=`${r}${a}`;i.forEach((e=>{try{e.getItem(u)!==l&&e.setItem(u,l)}catch(cBe){t(cBe,`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(cBe){t(cBe,`Error clearing ${e.name}`)}})),error:a,remove:e=>i.forEach((a=>{try{a.removeItem(`${r}${e}`)}catch(cBe){t(cBe,`Error removing ${r}${e} from ${a.name}`)}})),toJSON:()=>{const a={},n=(n,t)=>{if(!a.hasOwnProperty(n)){const i=t&&e?.deserializer?e.deserializer(t,n,e.options):t;i&&(a[n]=i)}};return i.forEach((e=>{if("function"==typeof e.getAll){let a;try{a=e.getAll()}catch(cBe){t(cBe,`Error getting all values from in ${e.name}`)}for(const e of a)n(e,a[e])}else{let i,r=0;try{for(;i=e.key(r++);)a.hasOwnProperty(i)||n(i,e.getItem(i))}catch(cBe){t(cBe,`Error getting all values from ${e.name}`)}}})),a}}]},Rfe=e=>{if(!e)return"";let a="";for(const n in e){if(!e.hasOwnProperty(n))continue;const t=e[n];a+=t instanceof Date?`; ${n}=${t.toUTCString()}`:"boolean"==typeof t?`; ${n}`:`; ${n}=${t}`}return a},_fe=("function"==typeof(Bfe={_cookies:[globalThis.document,"cookie"],getItem:e=>_fe._cookies[0][_fe._cookies[1]].match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)")?.pop()??null,setItem:(e,a,n)=>{const t=_fe.getItem(e);_fe._cookies[0][_fe._cookies[1]]=`${e}=${a}${Rfe(n)}`;const i=Object.assign(new Event("storage"),{key:e,oldValue:t,newValue:a,url:globalThis.document.URL,storageArea:_fe});window.dispatchEvent(i)},removeItem:e=>{_fe._cookies[0][_fe._cookies[1]]=`${e}=deleted${Rfe({expires:new Date(0)})}`},key:e=>{let a=null,n=0;return _fe._cookies[0][_fe._cookies[1]].replace(/(?:^|;)\s*(.+?)\s*=\s*[^;]+/g,((t,i)=>(!a&&i&&n++===e&&(a=i),""))),a},get length(){let e=0;return _fe._cookies[0][_fe._cookies[1]].replace(/(?:^|;)\s*.+?\s*=\s*[^;]+/g,(a=>(e+=a?1:0,""))),e}}).clear||(Bfe.clear=()=>{let e;for(;e=Bfe.key(0);)Bfe.removeItem(e)}),Bfe),Dfe=796,Kfe="bottom",Hfe="system",Ofe=Object.keys(Qt)[0],Ife=Object.keys(ai)[0],Gfe=Fa({client:void 0,onlineManager:void 0,queryFlavor:"",version:"",shadowDOMTarget:void 0});function Vfe(){return Ja(Gfe)}var Ffe=Fa(void 0),Jfe=e=>{const[a,n]=Pa(null),t=()=>{const e=a();null!=e&&(e.close(),n(null))},i=(t,i)=>{if(null!=a())return;const r=window.open("","TSQD-Devtools-Panel",`width=${t},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[zn]){for(let a of e[zn].keys())e.removeEventListener(a,qn);delete e[zn]}}(r.document),r.document.title="TanStack Query Devtools",r.document.body.style.margin="0",r.addEventListener("pagehide",(()=>{e.setLocalStore("pip_open","false"),n(null)})),[...(Vfe().shadowDOMTarget||document).styleSheets].forEach((e=>{try{const a=[...e.cssRules].map((e=>e.cssText)).join(""),n=document.createElement("style"),t=e.ownerNode;let i="";t&&"id"in t&&(i=t.id),i&&n.setAttribute("id",i),n.textContent=a,r.document.head.appendChild(n)}catch(uBe){const n=document.createElement("link");if(null==e.href)return;n.rel="stylesheet",n.type=e.type,n.media=e.media.toString(),n.href=e.href,r.document.head.appendChild(n)}})),Dn(["focusin","focusout","pointermove","keydown","pointerdown","pointerup","click","mousedown","input"],r.document),e.setLocalStore("pip_open","true"),n(r)};Ba((()=>{"true"!==(e.localStore.pip_open??"false")||e.disabled||i(Number(window.innerWidth),Number(e.localStore.height||500))})),Ba((()=>{const e=(Vfe().shadowDOMTarget||document).querySelector("#_goober"),n=a();if(e&&n){const a=new MutationObserver((()=>{const a=(Vfe().shadowDOMTarget||n.document).querySelector("#_goober");a&&(a.textContent=e.textContent)}));a.observe(e,{childList:!0,subtree:!0,characterDataOldValue:!0}),Ha((()=>{a.disconnect()}))}}));const r=za((()=>({pipWindow:a(),requestPipWindow:i,closePipWindow:t,disabled:e.disabled??!1})));return dn(Ffe.Provider,{value:r,get children(){return e.children}})},Ufe=()=>za((()=>{const e=Ja(Ffe);if(!e)throw new Error("usePiPWindow must be used within a PiPProvider");return e()})),Wfe=Fa((()=>"dark"));function qfe(){return Ja(Wfe)}var Zfe={"À":"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"},$fe=Object.keys(Zfe).join("|"),Yfe=new RegExp($fe,"g");var Qfe=7,Xfe=6,eye=5,aye=4,nye=3,tye=2,iye=1,rye=0;function oye(e,a,n){var t;if((n=n||{}).threshold=null!=(t=n.threshold)?t:iye,!n.accessors){const t=sye(e,a,n);return{rankedValue:e,rank:t,accessorIndex:-1,accessorThreshold:n.threshold,passed:t>=n.threshold}}const i=function(e,a){const n=[];for(let t=0,i=a.length;t<i;t++){const i=a[t],r=dye(i),o=uye(e,i);for(let e=0,a=o.length;e<a;e++)n.push({itemValue:o[e],attributes:r})}return n}(e,n.accessors),r={rankedValue:e,rank:rye,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let o=0;o<i.length;o++){const e=i[o];let t=sye(e.itemValue,a,n);const{minRanking:s,maxRanking:l,threshold:u=n.threshold}=e.attributes;t<s&&t>=iye?t=s:t>l&&(t=l),t=Math.min(t,l),t>=u&&t>r.rank&&(r.rank=t,r.passed=!0,r.accessorIndex=o,r.accessorThreshold=u,r.rankedValue=e.itemValue)}return r}function sye(e,a,n){return e=lye(e,n),(a=lye(a,n)).length>e.length?rye:e===a?Qfe:(e=e.toLowerCase())===(a=a.toLowerCase())?Xfe:e.startsWith(a)?eye:e.includes(` ${a}`)?aye:e.includes(a)?nye:1===a.length?rye:function(e){let a="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{a+=e.substr(0,1)}))})),a}(e).includes(a)?tye:function(e,a){let n=0,t=0;function i(e,a,t){for(let i=t,r=a.length;i<r;i++){if(a[i]===e)return n+=1,i+1}return-1}function r(e){return iye+n/a.length*(1/e)}const o=i(a[0],e,0);if(o<0)return rye;t=o;for(let s=1,l=a.length;s<l;s++){t=i(a[s],e,t);if(!(t>-1))return rye}return r(t-o)}(e,a)}function lye(e,a){let{keepDiacritics:n}=a;return e=`${e}`,n||(e=e.replace(Yfe,(e=>Zfe[e]))),e}function uye(e,a){let n=a;"object"==typeof a&&(n=a.accessor);const t=n(e);return null==t?[]:Array.isArray(t)?t:[String(t)]}var cye={maxRanking:1/0,minRanking:-1/0};function dye(e){return"function"==typeof e?cye:{...cye,...e}}var mye={data:""},hye=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,pye=/\/\*[^]*?\*\/| +/g,gye=/\n+/g,vye=(e,a)=>{let n="",t="",i="";for(let r in e){let o=e[r];"@"==r[0]?"i"==r[1]?n=r+" "+o+";":t+="f"==r[1]?vye(o,r):r+"{"+vye(o,"k"==r[1]?"":a)+"}":"object"==typeof o?t+=vye(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+=vye.p?vye.p(r,o):r+":"+o+";")}return n+(a&&i?a+"{"+i+"}":i)+t},fye={},yye=e=>{if("object"==typeof e){let a="";for(let n in e)a+=n+yye(e[n]);return a}return e};function kye(e){let a=this||{},n=e.call?e(a.p):e;return((e,a,n,t,i)=>{let r=yye(e),o=fye[r]||(fye[r]=(e=>{let a=0,n=11;for(;a<e.length;)n=101*n+e.charCodeAt(a++)>>>0;return"go"+n})(r));if(!fye[o]){let a=r!==e?e:(e=>{let a,n,t=[{}];for(;a=hye.exec(e.replace(pye,""));)a[4]?t.shift():a[3]?(n=a[3].replace(gye," ").trim(),t.unshift(t[0][n]=t[0][n]||{})):t[0][a[1]]=a[2].replace(gye," ").trim();return t[0]})(e);fye[o]=vye(i?{["@keyframes "+o]:a}:a,n?"":"."+o)}let s=n&&fye.g?fye.g:null;return n&&(fye.g=fye[o]),l=fye[o],u=a,c=t,(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})(n.unshift?n.raw?((e,a,n)=>e.reduce(((e,t,i)=>{let r=a[i];if(r&&r.call){let e=r(n),a=e&&e.props&&e.props.className||/^go/.test(e)&&e;r=a?"."+a:e&&"object"==typeof e?e.props?"":vye(e,""):!1===e?"":e}return e+t+(null==r?"":r)}),""))(n,[].slice.call(arguments,1),a.p):n.reduce(((e,n)=>Object.assign(e,n&&n.call?n(a.p):n)),{}):n,(t=a.target,"object"==typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||mye),a.g,a.o,a.k);var t}function bye(e){var a,n,t="";if("string"==typeof e||"number"==typeof e)t+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(a=0;a<i;a++)e[a]&&(n=bye(e[a]))&&(t&&(t+=" "),t+=n)}else for(n in e)e[n]&&(t&&(t+=" "),t+=n);return t}function Sye(){for(var e,a,n=0,t="",i=arguments.length;n<i;n++)(e=arguments[n])&&(a=bye(e))&&(t&&(t+=" "),t+=a);return t}function Aye(e,a){const n=_a(e),{onChange:t}=a;let i=new Set(a.appear?void 0:n);const r=new WeakSet,[o,s]=Pa([],{equals:!1}),[l]=[Ga,Ia],u=e=>{s((a=>(a.push.apply(a,e),a)));for(const a of e)r.delete(a)},c=(e,a,n)=>e.splice(n,0,a);return za((a=>{const n=o(),s=e();if(_a(l))return l(),a;if(n.length){const e=a.filter((e=>!n.includes(e)));return n.length=0,t({list:e,added:[],removed:[],unchanged:e,finishRemoved:u}),e}return _a((()=>{const e=new Set(s),n=s.slice(),o=[],l=[],d=[];for(const a of s)(i.has(a)?d:o).push(a);let m=!o.length;for(let t=0;t<a.length;t++){const i=a[t];e.has(i)||(r.has(i)||(l.push(i),r.add(i)),c(n,i,t)),m&&i!==n[t]&&(m=!1)}return!l.length&&m?a:(t({list:n,added:o,removed:l,unchanged:d,finishRemoved:u}),i=e,n)}))}),a.appear?[]:n.slice())}function wye(...e){return a=e,(...e)=>{for(const n of a)n&&n(...e)};var a}kye.bind({g:1}),kye.bind({k:1});var Cye=e=>e instanceof Element;function Mye(e,a){if(a(e))return e;if("function"==typeof e&&!e.length)return Mye(e(),a);if(Array.isArray(e)){const n=[];for(const t of e){const e=Mye(t,a);e&&(Array.isArray(e)?n.push.apply(n,e):n.push(e))}return n.length?n:null}return null}function Tye(e,a=Cye,n=Cye){const t=za(e),i=za((()=>Mye(t(),a)));return i.toArray=()=>{const e=i();return Array.isArray(e)?e:e?[e]:[]},i}function Nye(e){requestAnimationFrame((()=>requestAnimationFrame(e)))}function Eye(e,a,n,t){const{onBeforeEnter:i,onEnter:r,onAfterEnter:o}=a;function s(a){a&&a.target!==n||(n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.enterActive),n.classList.remove(...e.enterTo),o?.(n))}i?.(n),n.classList.add(...e.enter),n.classList.add(...e.enterActive),queueMicrotask((()=>{if(!n.parentNode)return t?.();r?.(n,(()=>s()))})),Nye((()=>{n.classList.remove(...e.enter),n.classList.add(...e.enterTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}function xye(e,a,n,t){const{onBeforeExit:i,onExit:r,onAfterExit:o}=a;if(!n.parentNode)return t?.();function s(a){a&&a.target!==n||(t?.(),n.removeEventListener("transitionend",s),n.removeEventListener("animationend",s),n.classList.remove(...e.exitActive),n.classList.remove(...e.exitTo),o?.(n))}i?.(n),n.classList.add(...e.exit),n.classList.add(...e.exitActive),r?.(n,(()=>s())),Nye((()=>{n.classList.remove(...e.exit),n.classList.add(...e.exitTo),(!r||r.length<2)&&(n.addEventListener("transitionend",s),n.addEventListener("animationend",s))}))}var Pye=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 Aye(Tye((()=>e.children)).toArray,{appear:e.appear,onChange({added:n,removed:t,finishRemoved:i,list:r}){const o=a();for(const a of n)Eye(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:n}of s)if(a.isConnected){const t=a.getBoundingClientRect(),i=n.left-t.left,r=n.top-t.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(n){(n.target===a||/transform$/.test(n.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 t)xye(o,e,a,(()=>i([a])))}})},jye=Symbol("fallback");function Lye(e){for(const a of e)a.dispose()}function Bye(e){const{by:a}=e;return za(function(e,a,n,t={}){const i=new Map;return Ha((()=>Lye(i.values()))),()=>{const n=e()||[];return _a((()=>{if(!n.length)return Lye(i.values()),i.clear(),t.fallback?[xa((e=>(i.set(jye,{dispose:e}),t.fallback())))]:[];const e=new Array(n.length),o=i.get(jye);if(!i.size||o){o?.dispose(),i.delete(jye);for(let t=0;t<n.length;t++){const i=n[t];r(e,i,t,a(i,t))}return e}const s=new Set(i.keys());for(let t=0;t<n.length;t++){const o=n[t],l=a(o,t);s.delete(l);const u=i.get(l);u?(e[t]=u.mapped,u.setIndex?.(t),u.setItem((()=>o))):r(e,o,t,l)}for(const a of s)i.get(a)?.dispose(),i.delete(a);return e}))};function r(e,a,t,r){xa((o=>{const[s,l]=Pa(a),u={setItem:l,dispose:o};if(n.length>1){const[e,a]=Pa(t);u.setIndex=a,u.mapped=n(s,e)}else u.mapped=n(s);i.set(r,u),e[t]=u.mapped}))}}((()=>e.each),"function"==typeof a?a:e=>e[a],e.children,"fallback"in e?{fallback:()=>e.fallback}:void 0))}function zye(e,a,n,t){const i=()=>{jfe(Pfe(e)).forEach((e=>{e&&jfe(Pfe(a)).forEach((a=>function(e,a,n,t){return e.addEventListener(a,n,t),Lfe(e.removeEventListener.bind(e,a,n,t))}(e,a,n,t)))}))};"function"==typeof e?Ba(i):La(i)}function Rye(e,a,n){const t=new WeakMap,{observe:i,unobserve:r}=function(e,a){const n=new ResizeObserver(e);return Ha(n.disconnect.bind(n)),{observe:e=>n.observe(e,a),unobserve:n.unobserve.bind(n)}}((e=>{for(const n of e){const{contentRect:e,target:i}=n,r=Math.round(e.width),o=Math.round(e.height),s=t.get(i);s&&s.width===r&&s.height===o||(a(e,i,n),t.set(i,{width:r,height:o}))}}),n);Ba((a=>{const n=jfe(Pfe(e)).filter(xfe);return function(e,a,n,t){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)||t(o);for(s of e)a.includes(s)||n(s)}else for(;l<r;l++)t(a[l]);else for(;l<i;l++)n(e[l])}(n,a,i,r),n}),[])}var _ye=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Dye(e){const a={};let n;for(;n=_ye.exec(e);)a[n[1]]=n[2];return a}function Kye(e,a){if("string"==typeof e){if("string"==typeof a)return`${e};${a}`;e=Dye(e)}else"string"==typeof a&&(a=Dye(a));return{...e,...a}}function Hye(e,a){const n=[...e],t=n.indexOf(a);return-1!==t&&n.splice(t,1),n}function Oye(e){return"[object String]"===Object.prototype.toString.call(e)}function Iye(e){return a=>`${e()}-${a}`}function Gye(e,a){return!!e&&(e===a||e.contains(a))}function Vye(e,a=!1){const{activeElement:n}=Fye(e);if(!n?.nodeName)return null;if(Jye(n)&&n.contentDocument)return Vye(n.contentDocument.body,a);if(a){const e=n.getAttribute("aria-activedescendant");if(e){const a=Fye(n).getElementById(e);if(a)return a}}return n}function Fye(e){return e?e.ownerDocument||e:document}function Jye(e){return"IFRAME"===e.tagName}var Uye=(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))(Uye||{});function Wye(e){return"undefined"!=typeof window&&null!=window.navigator&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function qye(){return Wye(/^Mac/i)}function Zye(){return Wye(/^iPhone/i)||Wye(/^iPad/i)||qye()&&navigator.maxTouchPoints>1}function $ye(e,a){return a&&("function"==typeof a?a(e):a[0](a[1],e)),e?.defaultPrevented}function Yye(e){return a=>{for(const n of e)$ye(a,n)}}function Qye(e){return qye()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Xye(e){if(e)if(function(){if(null==eke){eke=!1;try{document.createElement("div").focus({get preventScroll(){return eke=!0,!0}})}catch(uBe){}}return eke}())e.focus({preventScroll:!0});else{const a=function(e){let a=e.parentNode;const n=[],t=document.scrollingElement||document.documentElement;for(;a instanceof HTMLElement&&a!==t;)(a.offsetHeight<a.scrollHeight||a.offsetWidth<a.scrollWidth)&&n.push({element:a,scrollTop:a.scrollTop,scrollLeft:a.scrollLeft}),a=a.parentNode;t instanceof HTMLElement&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft});return n}(e);e.focus(),function(e){for(const{element:a,scrollTop:n,scrollLeft:t}of e)a.scrollTop=n,a.scrollLeft=t}(a)}}var eke=null;var ake=["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'])"],nke=[...ake,'[tabindex]:not([tabindex="-1"]):not([disabled])'],tke=ake.join(":not([hidden]),")+",[tabindex]:not([disabled]):not([hidden])",ike=nke.join(':not([hidden]):not([tabindex="-1"]),');function rke(e,a){const n=Array.from(e.querySelectorAll(tke)).filter(oke);return a&&oke(e)&&n.unshift(e),n.forEach(((e,a)=>{if(Jye(e)&&e.contentDocument){const t=rke(e.contentDocument.body,!1);n.splice(a,1,...t)}})),n}function oke(e){return ske(e)&&!function(e){const a=parseInt(e.getAttribute("tabindex")||"0",10);return a<0}(e)}function ske(e){return e.matches(tke)&&lke(e)}function lke(e,a){return"#comment"!==e.nodeName&&function(e){if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const{display:a,visibility:n}=e.style;let t="none"!==a&&"hidden"!==n&&"collapse"!==n;if(t){if(!e.ownerDocument.defaultView)return t;const{getComputedStyle:a}=e.ownerDocument.defaultView,{display:n,visibility:i}=a(e);t="none"!==n&&"hidden"!==i&&"collapse"!==i}return t}(e)&&function(e,a){return!e.hasAttribute("hidden")&&("DETAILS"!==e.nodeName||!a||"SUMMARY"===a.nodeName||e.hasAttribute("open"))}(e,a)&&(!e.parentElement||lke(e.parentElement,e))}function uke(e){for(;e&&!cke(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}function cke(e){const a=window.getComputedStyle(e);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function dke(){}function mke(e,a){return vn(e,a)}var hke=new Map,pke=new Set;function gke(){if("undefined"==typeof window)return;const e=a=>{if(!a.target)return;const n=hke.get(a.target);if(n&&(n.delete(a.propertyName),0===n.size&&(a.target.removeEventListener("transitioncancel",e),hke.delete(a.target)),0===hke.size)){for(const e of pke)e();pke.clear()}};document.body.addEventListener("transitionrun",(a=>{if(!a.target)return;let n=hke.get(a.target);n||(n=new Set,hke.set(a.target,n),a.target.addEventListener("transitioncancel",e)),n.add(a.propertyName)})),document.body.addEventListener("transitionend",e)}function vke(e,a){const n=fke(e,a,"left"),t=fke(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;n<=o?o=n:n+i>l&&(o+=n+i-l),t<=s?s=t:t+r>u&&(s+=t+r-u),e.scrollLeft=o,e.scrollTop=s}function fke(e,a,n){const t="left"===n?"offsetLeft":"offsetTop";let i=0;for(;a.offsetParent&&(i+=a[t],a.offsetParent!==e);){if(a.offsetParent.contains(e)){i-=e[t];break}a=a.offsetParent}return i}"undefined"!=typeof document&&("loading"!==document.readyState?gke():document.addEventListener("DOMContentLoaded",gke));var yke={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 kke(e){return a=>(e(a),()=>e(void 0))}function bke(e,a){const[n,t]=Pa(Ske(a?.()));return Ba((()=>{t(e()?.tagName.toLowerCase()||Ske(a?.()))})),n}function Ske(e){return Oye(e)?e:void 0}function Ake(e){const[a,n]=fn(e,["as"]);if(!a.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return dn(at,vn(n,{get component(){return a.as}}))}var wke=["id","name","validationState","required","disabled","readOnly"];var Cke=Fa();function Mke(){const e=Ja(Cke);if(void 0===e)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function Tke(e){const a=Mke(),n=mke({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),dn(Ake,vn({as:"div"},(()=>a.dataset()),n))}function Nke(e){const a=Mke(),n=mke({id:a.generateId("error-message")},e),[t,i]=fn(n,["forceMount"]),r=()=>"invalid"===a.validationState();return Ba((()=>{r()&&Ha(a.registerErrorMessage(i.id))})),dn(Cn,{get when(){return t.forceMount||r()},get children(){return dn(Ake,vn({as:"div"},(()=>a.dataset()),i))}})}function Eke(e){let a;const n=Mke(),t=mke({id:n.generateId("label")},e),[i,r]=fn(t,["ref"]),o=bke((()=>a),(()=>"label"));return Ba((()=>Ha(n.registerLabel(r.id)))),dn(Ake,vn({as:"label",ref(e){const n=wye((e=>a=e),i.ref);"function"==typeof n&&n(e)},get for(){return za((()=>"label"===o()))()?n.fieldId():void 0}},(()=>n.dataset()),r))}function xke(e,a){Ba(Da(e,(e=>{if(null==e)return;const n=function(e){return function(e){return e.matches("textarea, input, select, button")}(e)?e.form:e.closest("form")}(e);null!=n&&(n.addEventListener("reset",a,{passive:!0}),Ha((()=>{n.removeEventListener("reset",a)})))})))}function Pke(e){const[a,n]=Pa(e.defaultValue?.()),t=za((()=>void 0!==e.value?.())),i=za((()=>t()?e.value?.():a()));return[i,a=>{_a((()=>{const r=function(e,...a){return"function"==typeof e?e(...a):e}(a,i());return Object.is(r,i())||(t()||n(r),e.onChange?.(r)),r}))}]}function jke(e){const[a,n]=Pke(e);return[()=>a()??!1,n]}var Lke=Object.defineProperty,Bke=(e,a)=>{for(var n in a)Lke(e,n,{get:a[n],enumerable:!0})},zke=Fa();function Rke(){return Ja(zke)}function _ke(e,a){return Boolean(a.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function Dke(e,a){const n=function(e){const a=e.map(((e,a)=>[a,e]));let n=!1;return a.sort((([e,a],[t,i])=>{const r=a.ref(),o=i.ref();return r===o?0:r&&o?_ke(r,o)?(e>t&&(n=!0),-1):(e<t&&(n=!0),1):0})),n?a.map((([e,a])=>a)):e}(e);e!==n&&a(n)}function Kke(e,a){if("function"!=typeof IntersectionObserver)return void function(e,a){Ba((()=>{const n=setTimeout((()=>{Dke(e(),a)}));Ha((()=>clearTimeout(n)))}))}(e,a);let n=[];Ba((()=>{const t=function(e){const a=e[0],n=e[e.length-1]?.ref();let t=a?.ref()?.parentElement;for(;t;){if(n&&t.contains(n))return t;t=t.parentElement}return Fye(t).body}(e()),i=new IntersectionObserver((()=>{const t=!!n.length;n=e(),t&&Dke(e(),a)}),{root:t});for(const a of e()){const e=a.ref();e&&i.observe(e)}Ha((()=>i.disconnect()))}))}function Hke(e={}){const[a,n]=function(e){const[a,n]=Pke(e);return[()=>a()??[],n]}({value:()=>Pfe(e.items),onChange:a=>e.onItemsChange?.(a)});Kke(a,n);const t=e=>(n((a=>{const n=function(e,a){const n=a.ref();if(!n)return-1;let t=e.length;if(!t)return-1;for(;t--;){const a=e[t]?.ref();if(a&&_ke(a,n))return t+1}return 0}(a,e);return function(e,a,n=-1){return n in e?[...e.slice(0,n),a,...e.slice(n)]:[...e,a]}(a,e,n)})),()=>{n((a=>{const n=a.filter((a=>a.ref()!==e.ref()));return a.length===n.length?a:n}))});return{DomCollectionProvider:e=>dn(zke.Provider,{value:{registerItem:t},get children(){return e.children}})}}function Oke(e){const a=function(){const e=Rke();if(void 0===e)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}(),n=mke({shouldRegisterItem:!0},e);Ba((()=>{if(!n.shouldRegisterItem)return;Ha(a.registerItem(n.getItem()))}))}function Ike(e){let a=e.startIndex??0;const n=e.startLevel??0,t=[],i=a=>{if(null==a)return"";const n=e.getKey??"key",t=Oye(n)?a[n]:n(a);return null!=t?String(t):""},r=a=>{if(null==a)return"";const n=e.getTextValue??"textValue",t=Oye(n)?a[n]:n(a);return null!=t?String(t):""},o=a=>{if(null==a)return!1;const n=e.getDisabled??"disabled";return(Oye(n)?a[n]:n(a))??!1},s=a=>{if(null!=a)return Oye(e.getSectionChildren)?a[e.getSectionChildren]:e.getSectionChildren?.(a)};for(const l of e.dataSource)if(Oye(l)||"number"==typeof l)t.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:o(l),level:n,index:a}),a++;else if(null!=s(l)){t.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:a}),a++;const i=s(l)??[];if(i.length>0){const r=Ike({dataSource:i,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:a,startLevel:n+1});t.push(...r),a+=r.length}}else t.push({type:"item",rawValue:l,key:i(l),textValue:r(l),disabled:o(l),level:n,index:a}),a++;return t}function Gke(e,a=[]){return za((()=>{const n=Ike({dataSource:Pfe(e.dataSource),getKey:Pfe(e.getKey),getTextValue:Pfe(e.getTextValue),getDisabled:Pfe(e.getDisabled),getSectionChildren:Pfe(e.getSectionChildren)});for(let e=0;e<a.length;e++)a[e]();return e.factory(n)}))}var Vke=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),Fke=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function Jke(e){return function(e){if(Intl.Locale){const a=new Intl.Locale(e).maximize().script??"";return Vke.has(a)}const a=e.split("-")[0];return Fke.has(a)}(e)?"rtl":"ltr"}function Uke(){let e="undefined"!=typeof navigator&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:Jke(e)}}var Wke=Uke(),qke=new Set;function Zke(){Wke=Uke();for(const e of qke)e(Wke)}var $ke=Fa();function Yke(){const e=function(){const[e,a]=Pa(Wke),n=za((()=>e()));return Ka((()=>{0===qke.size&&window.addEventListener("languagechange",Zke),qke.add(a),Ha((()=>{qke.delete(a),0===qke.size&&window.removeEventListener("languagechange",Zke)}))})),{locale:()=>n().locale,direction:()=>n().direction}}();return Ja($ke)||e}var Qke=new Map;var Xke=class e extends Set{anchorKey;currentKey;constructor(a,n,t){super(a),a instanceof e?(this.anchorKey=n||a.anchorKey,this.currentKey=t||a.currentKey):(this.anchorKey=n,this.currentKey=t)}};function ebe(e){return qye()||Zye()?e.altKey:e.ctrlKey}function abe(e){return qye()?e.metaKey:e.ctrlKey}function nbe(e){return new Xke(e)}function tbe(e){const a=mke({selectionMode:"none",selectionBehavior:"toggle"},e),[n,t]=Pa(!1),[i,r]=Pa(),o=za((()=>{const e=Pfe(a.selectedKeys);return null!=e?nbe(e):e})),s=za((()=>{const e=Pfe(a.defaultSelectedKeys);return null!=e?nbe(e):new Xke})),[l,u]=function(e){const[a,n]=Pke(e);return[()=>a()??new Xke,n]}({value:o,defaultValue:s,onChange:e=>a.onSelectionChange?.(e)}),[c,d]=Pa(Pfe(a.selectionBehavior));return Ba((()=>{const e=l();"replace"===Pfe(a.selectionBehavior)&&"toggle"===c()&&"object"==typeof e&&0===e.size&&d("replace")})),Ba((()=>{d(Pfe(a.selectionBehavior)??"toggle")})),{selectionMode:()=>Pfe(a.selectionMode),disallowEmptySelection:()=>Pfe(a.disallowEmptySelection)??!1,selectionBehavior:c,setSelectionBehavior:d,isFocused:n,setFocused:t,focusedKey:i,setFocusedKey:r,selectedKeys:l,setSelectedKeys:e=>{!Pfe(a.allowDuplicateSelectionEvents)&&function(e,a){if(e.size!==a.size)return!1;for(const n of e)if(!a.has(n))return!1;return!0}(e,l())||u(e)}}}function ibe(e,a,n){const t=vn({selectOnFocus:()=>"replace"===Pfe(e.selectionManager).selectionBehavior()},e),i=()=>a(),{direction:r}=Yke();let o={top:0,left:0};zye((()=>Pfe(t.isVirtualized)?void 0:i()),"scroll",(()=>{const e=i();e&&(o={top:e.scrollTop,left:e.scrollLeft})}));const{typeSelectHandlers:s}=function(e){const[a,n]=Pa(""),[t,i]=Pa(-1);return{typeSelectHandlers:{onKeyDown:r=>{if(Pfe(e.isDisabled))return;const o=Pfe(e.keyboardDelegate),s=Pfe(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=n((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(t()),i(window.setTimeout((()=>n("")),500))}}}}({isDisabled:()=>Pfe(t.disallowTypeAhead),keyboardDelegate:()=>Pfe(t.keyboardDelegate),selectionManager:()=>Pfe(t.selectionManager)}),l=()=>Pfe(t.orientation)??"vertical",u=()=>{const e=Pfe(t.autoFocus);if(!e)return;const n=Pfe(t.selectionManager),i=Pfe(t.keyboardDelegate);let r;"first"===e&&(r=i.getFirstKey?.()),"last"===e&&(r=i.getLastKey?.());const o=n.selectedKeys();o.size&&(r=o.values().next().value),n.setFocused(!0),n.setFocusedKey(r);const s=a();s&&null==r&&!Pfe(t.shouldUseVirtualFocus)&&Xye(s)};Ka((()=>{t.deferAutoFocus?setTimeout(u,0):u()})),Ba(Da([i,()=>Pfe(t.isVirtualized),()=>Pfe(t.selectionManager).focusedKey()],(e=>{const[a,n,i]=e;if(n)i&&t.scrollToKey?.(i);else if(i&&a){const e=a.querySelector(`[data-key="${i}"]`);e&&vke(a,e)}})));return{tabIndex:za((()=>{if(!Pfe(t.shouldUseVirtualFocus))return null==Pfe(t.selectionManager).focusedKey()?0:-1})),onKeyDown:e=>{$ye(e,s.onKeyDown),e.altKey&&"Tab"===e.key&&e.preventDefault();const n=a();if(!n?.contains(e.target))return;const i=Pfe(t.selectionManager),o=Pfe(t.selectOnFocus),u=a=>{null!=a&&(i.setFocusedKey(a),e.shiftKey&&"multiple"===i.selectionMode()?i.extendSelection(a):o&&!ebe(e)&&i.replaceSelection(a))},c=Pfe(t.keyboardDelegate),d=Pfe(t.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 n;n=null!=m?c.getKeyLeftOf(m):a?c.getFirstKey?.():c.getLastKey?.(),u(n)}break;case"vertical"===l()?"ArrowRight":"ArrowDown":if(c.getKeyRightOf){e.preventDefault();const a="rtl"===r();let n;n=null!=m?c.getKeyRightOf(m):a?c.getLastKey?.():c.getFirstKey?.(),u(n)}break;case"Home":if(c.getFirstKey){e.preventDefault();const a=c.getFirstKey(m,abe(e));null!=a&&(i.setFocusedKey(a),abe(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,abe(e));null!=a&&(i.setFocusedKey(a),abe(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":abe(e)&&"multiple"===i.selectionMode()&&!0!==Pfe(t.disallowSelectAll)&&(e.preventDefault(),i.selectAll());break;case"Escape":e.defaultPrevented||(e.preventDefault(),Pfe(t.disallowEmptySelection)||i.clearSelection());break;case"Tab":if(!Pfe(t.allowsTabNavigation)){if(e.shiftKey)n.focus();else{const e=function(e,a){const n=a?.tabbable?ike:tke,t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>a?.from?.contains(e)?NodeFilter.FILTER_REJECT:e.matches(n)&&lke(e)&&(!a?.accept||a.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});return a?.from&&(t.currentNode=a.from),t}(n,{tabbable:!0});let a,t;do{t=e.lastChild(),t&&(a=t)}while(t);a&&!a.contains(document.activeElement)&&Xye(a)}break}}},onMouseDown:e=>{i()===e.target&&e.preventDefault()},onFocusIn:e=>{const a=Pfe(t.selectionManager),n=Pfe(t.keyboardDelegate),r=Pfe(t.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 t=e=>{null!=e&&(a.setFocusedKey(e),r&&a.replaceSelection(e))},i=e.relatedTarget;i&&e.currentTarget.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING?t(a.lastSelectedKey()??n.getLastKey?.()):t(a.firstSelectedKey()??n.getFirstKey?.())}else if(!Pfe(t.isVirtualized)){const e=i();if(e){e.scrollTop=o.top,e.scrollLeft=o.left;const n=e.querySelector(`[data-key="${a.focusedKey()}"]`);n&&(Xye(n),vke(e,n))}}},onFocusOut:e=>{const a=Pfe(t.selectionManager);e.currentTarget.contains(e.relatedTarget)||a.setFocused(!1)}}}function rbe(e,a){const n=()=>Pfe(e.selectionManager),t=()=>Pfe(e.key),i=()=>Pfe(e.shouldUseVirtualFocus),r=e=>{"none"!==n().selectionMode()&&("single"===n().selectionMode()?n().isSelected(t())&&!n().disallowEmptySelection()?n().toggleSelection(t()):n().replaceSelection(t()):e?.shiftKey?n().extendSelection(t()):"toggle"===n().selectionBehavior()||abe(e)||"pointerType"in e&&"touch"===e.pointerType?n().toggleSelection(t()):n().replaceSelection(t()))},o=()=>Pfe(e.disabled)||n().isDisabled(t()),s=()=>!o()&&n().canSelectItem(t());let l=null;const u=za((()=>{if(!i()&&!o())return t()===n().focusedKey()?0:-1})),c=za((()=>Pfe(e.virtualized)?void 0:t()));return Ba(Da([a,t,i,()=>n().focusedKey(),()=>n().isFocused()],(([a,n,t,i,r])=>{a&&n===i&&r&&!t&&document.activeElement!==a&&(e.focus?e.focus():Xye(a))}))),{isSelected:()=>n().isSelected(t()),isDisabled:o,allowsSelection:s,tabIndex:u,dataKey:c,onPointerDown:a=>{s()&&(l=a.pointerType,"mouse"!==a.pointerType||0!==a.button||Pfe(e.shouldSelectOnPressUp)||r(a))},onPointerUp:a=>{s()&&"mouse"===a.pointerType&&0===a.button&&Pfe(e.shouldSelectOnPressUp)&&Pfe(e.allowsDifferentPressOrigin)&&r(a)},onClick:a=>{s()&&(Pfe(e.shouldSelectOnPressUp)&&!Pfe(e.allowsDifferentPressOrigin)||"mouse"!==l)&&r(a)},onKeyDown:e=>{s()&&["Enter"," "].includes(e.key)&&(ebe(e)?n().toggleSelection(t()):r(e))},onMouseDown:e=>{o()&&e.preventDefault()},onFocus:e=>{const r=a();i()||o()||!r||e.target===r&&n().setFocusedKey(t())}}}var obe=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 n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index<e.index)||(e=n)}return e?.key}lastSelectedKey(){let e;for(const a of this.state.selectedKeys()){const n=this.collection().getItem(a);e&&!(null!=n?.index&&null!=e?.index&&n.index>e.index)||(e=n)}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 n=this.state.selectedKeys(),t=n.anchorKey||a,i=new Xke(n,t,a);for(const r of this.getKeyRange(t,n.currentKey||a))i.delete(r);for(const r of this.getKeyRange(a,t))this.canSelectItem(r)&&i.add(r);this.state.setSelectedKeys(i)}getKeyRange(e,a){const n=this.collection().getItem(e),t=this.collection().getItem(a);return n&&t?null!=n.index&&null!=t.index&&n.index<=t.index?this.getKeyRangeInternal(e,a):this.getKeyRangeInternal(a,e):[]}getKeyRangeInternal(e,a){const n=[];let t=e;for(;null!=t;){const e=this.collection().getItem(t);if(e&&"item"===e.type&&n.push(t),t===a)return n;t=this.collection().getKeyAfter(t)}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 n=new Xke(this.state.selectedKeys());n.has(a)?n.delete(a):this.canSelectItem(a)&&(n.add(a),n.anchorKey=a,n.currentKey=a),this.disallowEmptySelection()&&0===n.size||this.state.setSelectedKeys(n)}replaceSelection(e){if("none"===this.selectionMode())return;const a=this.getKey(e);if(null==a)return;const n=this.canSelectItem(a)?new Xke([a],a,a):new Xke;this.state.setSelectedKeys(n)}setSelectedKeys(e){if("none"===this.selectionMode())return;const a=new Xke;for(const n of e){const e=this.getKey(n);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 Xke)}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 n of e)if(!a.has(n))return!1;for(const n of a)if(!e.has(n))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 n=this.collection().getItem(a);if(!n)continue;"item"===n.type&&e.push(a)}a=this.collection().getKeyAfter(a)}})(this.collection().getFirstKey()),e}},sbe=class{keyMap=new Map;iterable;firstKey;lastKey;constructor(e){this.iterable=e;for(const t of e)this.keyMap.set(t.key,t);if(0===this.keyMap.size)return;let a,n=0;for(const[t,i]of this.keyMap)a?(a.nextKey=t,i.prevKey=a.key):(this.firstKey=t,i.prevKey=void 0),"item"===i.type&&(i.index=n++),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 lbe,ube=e=>"function"==typeof e?e():e,cbe=e=>{const a=za((()=>{const a=ube(e.element);if(a)return getComputedStyle(a)})),n=()=>a()?.animationName??"none",[t,i]=Pa(ube(e.show)?"present":"hidden");let r="none";return Ba((t=>{const o=ube(e.show);return _a((()=>{if(t===o)return o;const e=r,s=n();if(o)i("present");else if("none"===s||"none"===a()?.display)i("hidden");else{i(!0===t&&e!==s?"hiding":"hidden")}})),o})),Ba((()=>{const a=ube(e.element);if(!a)return;const o=e=>{e.target===a&&(r=n())},s=e=>{const r=n().includes(e.animationName);e.target===a&&r&&"hiding"===t()&&i("hidden")};a.addEventListener("animationstart",o),a.addEventListener("animationcancel",s),a.addEventListener("animationend",s),Ha((()=>{a.removeEventListener("animationstart",o),a.removeEventListener("animationcancel",s),a.removeEventListener("animationend",s)}))})),{present:()=>"present"===t()||"hiding"===t(),state:t}},dbe="data-kb-top-layer",mbe=!1,hbe=[];function pbe(e){return hbe.findIndex((a=>a.node===e))}function gbe(){return hbe.filter((e=>e.isPointerBlocking))}function vbe(){return gbe().length>0}function fbe(e){const a=pbe([...gbe()].slice(-1)[0]?.node);return pbe(e)<a}var ybe={layers:hbe,isTopMostLayer:function(e){return hbe[hbe.length-1].node===e},hasPointerBlockingLayer:vbe,isBelowPointerBlockingLayer:fbe,addLayer:function(e){hbe.push(e)},removeLayer:function(e){const a=pbe(e);a<0||hbe.splice(a,1)},indexOf:pbe,find:function(e){return hbe[pbe(e)]},assignPointerEventToLayers:function(){for(const{node:e}of hbe)e.style.pointerEvents=fbe(e)?"none":"auto"},disableBodyPointerEvents:function(e){if(vbe()&&!mbe){const a=Fye(e);lbe=document.body.style.pointerEvents,a.body.style.pointerEvents="none",mbe=!0}},restoreBodyPointerEvents:function(e){if(vbe())return;const a=Fye(e);a.body.style.pointerEvents=lbe,0===a.body.style.length&&a.body.removeAttribute("style"),mbe=!1}};Bke({},{Button:()=>Sbe,Root:()=>bbe});var kbe=["button","color","file","image","reset","submit"];function bbe(e){let a;const n=mke({type:"button"},e),[t,i]=fn(n,["ref","type","disabled"]),r=bke((()=>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!==kbe.indexOf(e.type)}({tagName:e,type:t.type})})),s=za((()=>"input"===r())),l=za((()=>"a"===r()&&null!=a?.getAttribute("href")));return dn(Ake,vn({as:"button",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)},get type(){return o()||s()?t.type:void 0},get role(){return o()||l()?void 0:"button"},get tabIndex(){return o()||l()||t.disabled?void 0:0},get disabled(){return o()||s()?t.disabled:void 0},get"aria-disabled"(){return!(o()||s()||!t.disabled)||void 0},get"data-disabled"(){return t.disabled?"":void 0}},i))}var Sbe=bbe,Abe=["top","right","bottom","left"],wbe=Math.min,Cbe=Math.max,Mbe=Math.round,Tbe=Math.floor,Nbe=e=>({x:e,y:e}),Ebe={left:"right",right:"left",bottom:"top",top:"bottom"},xbe={start:"end",end:"start"};function Pbe(e,a,n){return Cbe(e,wbe(a,n))}function jbe(e,a){return"function"==typeof e?e(a):e}function Lbe(e){return e.split("-")[0]}function Bbe(e){return e.split("-")[1]}function zbe(e){return"x"===e?"y":"x"}function Rbe(e){return"y"===e?"height":"width"}function _be(e){return["top","bottom"].includes(Lbe(e))?"y":"x"}function Dbe(e){return zbe(_be(e))}function Kbe(e){return e.replace(/start|end/g,(e=>xbe[e]))}function Hbe(e){return e.replace(/left|right|bottom|top/g,(e=>Ebe[e]))}function Obe(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 Ibe(e){const{x:a,y:n,width:t,height:i}=e;return{width:t,height:i,top:n,left:a,right:a+t,bottom:n+i,x:a,y:n}}function Gbe(e,a,n){let{reference:t,floating:i}=e;const r=_be(a),o=Dbe(a),s=Rbe(o),l=Lbe(a),u="y"===r,c=t.x+t.width/2-i.width/2,d=t.y+t.height/2-i.height/2,m=t[s]/2-i[s]/2;let h;switch(l){case"top":h={x:c,y:t.y-i.height};break;case"bottom":h={x:c,y:t.y+t.height};break;case"right":h={x:t.x+t.width,y:d};break;case"left":h={x:t.x-i.width,y:d};break;default:h={x:t.x,y:t.y}}switch(Bbe(a)){case"start":h[o]-=m*(n&&u?-1:1);break;case"end":h[o]+=m*(n&&u?-1:1)}return h}async function Vbe(e,a){var n;void 0===a&&(a={});const{x:t,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}=jbe(a,e),p=Obe(h),g=s[m?"floating"===d?"reference":"floating":d],v=Ibe(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(g)))||n?g:g.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),f="floating"===d?{x:t,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),k=await(null==r.isElement?void 0:r.isElement(y))&&await(null==r.getScale?void 0:r.getScale(y))||{x:1,y:1},b=Ibe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:f,offsetParent:y,strategy:l}):f);return{top:(v.top-b.top+p.top)/k.y,bottom:(b.bottom-v.bottom+p.bottom)/k.y,left:(v.left-b.left+p.left)/k.x,right:(b.right-v.right+p.right)/k.x}}function Fbe(e,a){return{top:e.top-a.height,right:e.right-a.width,bottom:e.bottom-a.height,left:e.left-a.width}}function Jbe(e){return Abe.some((a=>e[a]>=0))}function Ube(e){return Zbe(e)?(e.nodeName||"").toLowerCase():"#document"}function Wbe(e){var a;return(null==e||null==(a=e.ownerDocument)?void 0:a.defaultView)||window}function qbe(e){var a;return null==(a=(Zbe(e)?e.ownerDocument:e.document)||window.document)?void 0:a.documentElement}function Zbe(e){return e instanceof Node||e instanceof Wbe(e).Node}function $be(e){return e instanceof Element||e instanceof Wbe(e).Element}function Ybe(e){return e instanceof HTMLElement||e instanceof Wbe(e).HTMLElement}function Qbe(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof Wbe(e).ShadowRoot)}function Xbe(e){const{overflow:a,overflowX:n,overflowY:t,display:i}=rSe(e);return/auto|scroll|overlay|hidden|clip/.test(a+t+n)&&!["inline","contents"].includes(i)}function eSe(e){return["table","td","th"].includes(Ube(e))}function aSe(e){return[":popover-open",":modal"].some((a=>{try{return e.matches(a)}catch(uBe){return!1}}))}function nSe(e){const a=tSe(),n=$be(e)?rSe(e):e;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!a&&!!n.backdropFilter&&"none"!==n.backdropFilter||!a&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function tSe(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function iSe(e){return["html","body","#document"].includes(Ube(e))}function rSe(e){return Wbe(e).getComputedStyle(e)}function oSe(e){return $be(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sSe(e){if("html"===Ube(e))return e;const a=e.assignedSlot||e.parentNode||Qbe(e)&&e.host||qbe(e);return Qbe(a)?a.host:a}function lSe(e){const a=sSe(e);return iSe(a)?e.ownerDocument?e.ownerDocument.body:e.body:Ybe(a)&&Xbe(a)?a:lSe(a)}function uSe(e,a,n){var t;void 0===a&&(a=[]),void 0===n&&(n=!0);const i=lSe(e),r=i===(null==(t=e.ownerDocument)?void 0:t.body),o=Wbe(i);return r?a.concat(o,o.visualViewport||[],Xbe(i)?i:[],o.frameElement&&n?uSe(o.frameElement):[]):a.concat(i,uSe(i,[],n))}function cSe(e){const a=rSe(e);let n=parseFloat(a.width)||0,t=parseFloat(a.height)||0;const i=Ybe(e),r=i?e.offsetWidth:n,o=i?e.offsetHeight:t,s=Mbe(n)!==r||Mbe(t)!==o;return s&&(n=r,t=o),{width:n,height:t,$:s}}function dSe(e){return $be(e)?e:e.contextElement}function mSe(e){const a=dSe(e);if(!Ybe(a))return Nbe(1);const n=a.getBoundingClientRect(),{width:t,height:i,$:r}=cSe(a);let o=(r?Mbe(n.width):n.width)/t,s=(r?Mbe(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var hSe=Nbe(0);function pSe(e){const a=Wbe(e);return tSe()&&a.visualViewport?{x:a.visualViewport.offsetLeft,y:a.visualViewport.offsetTop}:hSe}function gSe(e,a,n,t){void 0===a&&(a=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),r=dSe(e);let o=Nbe(1);a&&(t?$be(t)&&(o=mSe(t)):o=mSe(e));const s=function(e,a,n){return void 0===a&&(a=!1),!(!n||a&&n!==Wbe(e))&&a}(r,n,t)?pSe(r):Nbe(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=Wbe(r),a=t&&$be(t)?Wbe(t):t;let n=e,i=n.frameElement;for(;i&&t&&a!==n;){const e=mSe(i),a=i.getBoundingClientRect(),t=rSe(i),r=a.left+(i.clientLeft+parseFloat(t.paddingLeft))*e.x,o=a.top+(i.clientTop+parseFloat(t.paddingTop))*e.y;l*=e.x,u*=e.y,c*=e.x,d*=e.y,l+=r,u+=o,n=Wbe(i),i=n.frameElement}}return Ibe({width:c,height:d,x:l,y:u})}function vSe(e){return gSe(qbe(e)).left+oSe(e).scrollLeft}function fSe(e,a,n){let t;if("viewport"===a)t=function(e,a){const n=Wbe(e),t=qbe(e),i=n.visualViewport;let r=t.clientWidth,o=t.clientHeight,s=0,l=0;if(i){r=i.width,o=i.height;const e=tSe();(!e||e&&"fixed"===a)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:o,x:s,y:l}}(e,n);else if("document"===a)t=function(e){const a=qbe(e),n=oSe(e),t=e.ownerDocument.body,i=Cbe(a.scrollWidth,a.clientWidth,t.scrollWidth,t.clientWidth),r=Cbe(a.scrollHeight,a.clientHeight,t.scrollHeight,t.clientHeight);let o=-n.scrollLeft+vSe(e);const s=-n.scrollTop;return"rtl"===rSe(t).direction&&(o+=Cbe(a.clientWidth,t.clientWidth)-i),{width:i,height:r,x:o,y:s}}(qbe(e));else if($be(a))t=function(e,a){const n=gSe(e,!0,"fixed"===a),t=n.top+e.clientTop,i=n.left+e.clientLeft,r=Ybe(e)?mSe(e):Nbe(1);return{width:e.clientWidth*r.x,height:e.clientHeight*r.y,x:i*r.x,y:t*r.y}}(a,n);else{const n=pSe(e);t={...a,x:a.x-n.x,y:a.y-n.y}}return Ibe(t)}function ySe(e,a){const n=sSe(e);return!(n===a||!$be(n)||iSe(n))&&("fixed"===rSe(n).position||ySe(n,a))}function kSe(e,a,n){const t=Ybe(a),i=qbe(a),r="fixed"===n,o=gSe(e,!0,r,a);let s={scrollLeft:0,scrollTop:0};const l=Nbe(0);if(t||!t&&!r)if(("body"!==Ube(a)||Xbe(i))&&(s=oSe(a)),t){const e=gSe(a,!0,r,a);l.x=e.x+a.clientLeft,l.y=e.y+a.clientTop}else i&&(l.x=vSe(i));return{x:o.left+s.scrollLeft-l.x,y:o.top+s.scrollTop-l.y,width:o.width,height:o.height}}function bSe(e){return"static"===rSe(e).position}function SSe(e,a){return Ybe(e)&&"fixed"!==rSe(e).position?a?a(e):e.offsetParent:null}function ASe(e,a){const n=Wbe(e);if(aSe(e))return n;if(!Ybe(e)){let a=sSe(e);for(;a&&!iSe(a);){if($be(a)&&!bSe(a))return a;a=sSe(a)}return n}let t=SSe(e,a);for(;t&&eSe(t)&&bSe(t);)t=SSe(t,a);return t&&iSe(t)&&bSe(t)&&!nSe(t)?n:t||function(e){let a=sSe(e);for(;Ybe(a)&&!iSe(a);){if(nSe(a))return a;if(aSe(a))return null;a=sSe(a)}return null}(e)||n}var wSe={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:a,rect:n,offsetParent:t,strategy:i}=e;const r="fixed"===i,o=qbe(t),s=!!a&&aSe(a.floating);if(t===o||s&&r)return n;let l={scrollLeft:0,scrollTop:0},u=Nbe(1);const c=Nbe(0),d=Ybe(t);if((d||!d&&!r)&&(("body"!==Ube(t)||Xbe(o))&&(l=oSe(t)),Ybe(t))){const e=gSe(t);u=mSe(t),c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x,y:n.y*u.y-l.scrollTop*u.y+c.y}},getDocumentElement:qbe,getClippingRect:function(e){let{element:a,boundary:n,rootBoundary:t,strategy:i}=e;const r=[..."clippingAncestors"===n?aSe(a)?[]:function(e,a){const n=a.get(e);if(n)return n;let t=uSe(e,[],!1).filter((e=>$be(e)&&"body"!==Ube(e))),i=null;const r="fixed"===rSe(e).position;let o=r?sSe(e):e;for(;$be(o)&&!iSe(o);){const a=rSe(o),n=nSe(o);n||"fixed"!==a.position||(i=null),(r?!n&&!i:!n&&"static"===a.position&&i&&["absolute","fixed"].includes(i.position)||Xbe(o)&&!n&&ySe(e,o))?t=t.filter((e=>e!==o)):i=a,o=sSe(o)}return a.set(e,t),t}(a,this._c):[].concat(n),t],o=r.reduce(((e,n)=>{const t=fSe(a,n,i);return e.top=Cbe(t.top,e.top),e.right=wbe(t.right,e.right),e.bottom=wbe(t.bottom,e.bottom),e.left=Cbe(t.left,e.left),e}),fSe(a,r[0],i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:ASe,getElementRects:async function(e){const a=this.getOffsetParent||ASe,n=this.getDimensions,t=await n(e.floating);return{reference:kSe(e.reference,await a(e.floating),e.strategy),floating:{x:0,y:0,width:t.width,height:t.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:a,height:n}=cSe(e);return{width:a,height:n}},getScale:mSe,isElement:$be,isRTL:function(e){return"rtl"===rSe(e).direction}};function CSe(e,a,n,t){void 0===t&&(t={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=t,u=dSe(e),c=i||r?[...u?uSe(u):[],...uSe(a)]:[];c.forEach((e=>{i&&e.addEventListener("scroll",n,{passive:!0}),r&&e.addEventListener("resize",n)}));const d=u&&s?function(e,a){let n,t=null;const i=qbe(e);function r(){var e;clearTimeout(n),null==(e=t)||e.disconnect(),t=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:-Tbe(c)+"px "+-Tbe(i.clientWidth-(u+d))+"px "+-Tbe(i.clientHeight-(c+m))+"px "+-Tbe(u)+"px",threshold:Cbe(0,wbe(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):n=setTimeout((()=>{o(!1,1e-7)}),1e3)}p=!1}try{t=new IntersectionObserver(g,{...h,root:i.ownerDocument})}catch(uBe){t=new IntersectionObserver(g,h)}t.observe(e)}(!0),r}(u,n):null;let m,h=-1,p=null;o&&(p=new ResizeObserver((e=>{let[t]=e;t&&t.target===u&&p&&(p.unobserve(a),cancelAnimationFrame(h),h=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(a)}))),n()})),u&&!l&&p.observe(u),p.observe(a));let g=l?gSe(e):null;return l&&function a(){const t=gSe(e);!g||t.x===g.x&&t.y===g.y&&t.width===g.width&&t.height===g.height||n();g=t,m=requestAnimationFrame(a)}(),n(),()=>{var e;c.forEach((e=>{i&&e.removeEventListener("scroll",n),r&&e.removeEventListener("resize",n)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(m)}}var MSe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(a){var n,t;const{x:i,y:r,placement:o,middlewareData:s}=a,l=await async function(e,a){const{placement:n,platform:t,elements:i}=e,r=await(null==t.isRTL?void 0:t.isRTL(i.floating)),o=Lbe(n),s=Bbe(n),l="y"===_be(n),u=["left","top"].includes(o)?-1:1,c=r&&l?-1:1,d=jbe(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==(n=s.offset)?void 0:n.placement)&&null!=(t=s.arrow)&&t.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:o}}}}},TSe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(a){const{x:n,y:t,placement:i}=a,{mainAxis:r=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:a,y:n}=e;return{x:a,y:n}}},...l}=jbe(e,a),u={x:n,y:t},c=await Vbe(a,l),d=_be(Lbe(i)),m=zbe(d);let h=u[m],p=u[d];if(r){h=Pbe(h+c["y"===m?"top":"left"],h,h-c["y"===m?"bottom":"right"])}if(o){p=Pbe(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-n,y:g.y-t}}}}},NSe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(a){var n,t;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,...v}=jbe(e,a);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const f=Lbe(i),y=_be(s),k=Lbe(s)===s,b=await(null==l.isRTL?void 0:l.isRTL(u.floating)),S=m||(k||!g?[Hbe(s)]:function(e){const a=Hbe(e);return[Kbe(e),a,Kbe(a)]}(s)),A="none"!==p;!m&&A&&S.push(...function(e,a,n,t){const i=Bbe(e);let r=function(e,a,n){const t=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return n?a?i:t:a?t:i;case"left":case"right":return a?r:o;default:return[]}}(Lbe(e),"start"===n,t);return i&&(r=r.map((e=>e+"-"+i)),a&&(r=r.concat(r.map(Kbe)))),r}(s,g,p,b));const w=[s,...S],C=await Vbe(a,v),M=[];let T=(null==(t=r.flip)?void 0:t.overflows)||[];if(c&&M.push(C[f]),d){const e=function(e,a,n){void 0===n&&(n=!1);const t=Bbe(e),i=Dbe(e),r=Rbe(i);let o="x"===i?t===(n?"end":"start")?"right":"left":"start"===t?"bottom":"top";return a.reference[r]>a.floating[r]&&(o=Hbe(o)),[o,Hbe(o)]}(i,o,b);M.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:i,overflows:M}],!M.every((e=>e<=0))){var N,E;const e=((null==(N=r.flip)?void 0:N.index)||0)+1,a=w[e];if(a)return{data:{index:e,overflows:T},reset:{placement:a}};let n=null==(E=T.filter((e=>e.overflows[0]<=0)).sort(((e,a)=>e.overflows[1]-a.overflows[1]))[0])?void 0:E.placement;if(!n)switch(h){case"bestFit":{var x;const e=null==(x=T.filter((e=>{if(A){const a=_be(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:x[0];e&&(n=e);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}},ESe=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(a){const{placement:n,rects:t,platform:i,elements:r}=a,{apply:o=()=>{},...s}=jbe(e,a),l=await Vbe(a,s),u=Lbe(n),c=Bbe(n),d="y"===_be(n),{width:m,height:h}=t.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 v=h-l.top-l.bottom,f=m-l.left-l.right,y=wbe(h-l[p],v),k=wbe(m-l[g],f),b=!a.middlewareData.shift;let S=y,A=k;if(d?A=c||b?wbe(k,f):f:S=c||b?wbe(y,v):v,b&&!c){const e=Cbe(l.left,0),a=Cbe(l.right,0),n=Cbe(l.top,0),t=Cbe(l.bottom,0);d?A=m-2*(0!==e||0!==a?e+a:Cbe(l.left,l.right)):S=h-2*(0!==n||0!==t?n+t:Cbe(l.top,l.bottom))}await o({...a,availableWidth:A,availableHeight:S});const w=await i.getDimensions(r.floating);return m!==w.width||h!==w.height?{reset:{rects:!0}}:{}}}},xSe=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(a){const{rects:n}=a,{strategy:t="referenceHidden",...i}=jbe(e,a);switch(t){case"referenceHidden":{const e=Fbe(await Vbe(a,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Jbe(e)}}}case"escaped":{const e=Fbe(await Vbe(a,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Jbe(e)}}}default:return{}}}}},PSe=e=>({name:"arrow",options:e,async fn(a){const{x:n,y:t,placement:i,rects:r,platform:o,elements:s,middlewareData:l}=a,{element:u,padding:c=0}=jbe(e,a)||{};if(null==u)return{};const d=Obe(c),m={x:n,y:t},h=Dbe(i),p=Rbe(h),g=await o.getDimensions(u),v="y"===h,f=v?"top":"left",y=v?"bottom":"right",k=v?"clientHeight":"clientWidth",b=r.reference[p]+r.reference[h]-m[h]-r.floating[p],S=m[h]-r.reference[h],A=await(null==o.getOffsetParent?void 0:o.getOffsetParent(u));let w=A?A[k]:0;w&&await(null==o.isElement?void 0:o.isElement(A))||(w=s.floating[k]||r.floating[p]);const C=b/2-S/2,M=w/2-g[p]/2-1,T=wbe(d[f],M),N=wbe(d[y],M),E=T,x=w-g[p]-N,P=w/2-g[p]/2+C,j=Pbe(E,P,x),L=!l.arrow&&null!=Bbe(i)&&P!==j&&r.reference[p]/2-(P<E?T:N)-g[p]/2<0,B=L?P<E?P-E:P-x:0;return{[h]:m[h]+B,data:{[h]:j,centerOffset:P-j-B,...L&&{alignmentOffset:B}},reset:L}}}),jSe=(e,a,n)=>{const t={platform:wSe,...n},i={...t.platform,_c:new Map};return(async(e,a,n)=>{const{placement:t="bottom",strategy:i="absolute",middleware:r=[],platform:o}=n,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}=Gbe(u,t,l),m=t,h={},p=0;for(let g=0;g<s.length;g++){const{name:n,fn:r}=s[g],{x:v,y:f,data:y,reset:k}=await r({x:c,y:d,initialPlacement:t,placement:m,strategy:i,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:a}});c=null!=v?v:c,d=null!=f?f:d,h={...h,[n]:{...h[n],...y}},k&&p<=50&&(p++,"object"==typeof k&&(k.placement&&(m=k.placement),k.rects&&(u=!0===k.rects?await o.getElementRects({reference:e,floating:a,strategy:i}):k.rects),({x:c,y:d}=Gbe(u,m,l))),g=-1)}return{x:c,y:d,placement:m,strategy:i,middlewareData:h}})(e,a,{...t,platform:i})},LSe=Fa();function BSe(){const e=Ja(LSe);if(void 0===e)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var zSe=_n('<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">'),RSe={top:180,right:-90,bottom:0,left:90};function _Se(e){const a=BSe(),n=mke({size:30},e),[t,i]=fn(n,["ref","style","size"]),r=()=>a.currentPlacement().split("-")[0],o=function(e){const[a,n]=Pa();return Ba((()=>{const a=e();var t;a&&n((t=a,Fye(t).defaultView||window).getComputedStyle(a))})),a}(a.contentRef),s=()=>2*Number.parseInt(o()?.getPropertyValue(`border-${r()}-width`)||"0px")*(30/t.size);return dn(Ake,vn({as:"div",ref(e){const n=wye(a.setArrowRef,t.ref);"function"==typeof n&&n(e)},"aria-hidden":"true",get style(){return Kye({position:"absolute","font-size":`${t.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()},t.style)}},i,{get children(){const e=zSe(),a=e.firstChild;return La((()=>Kn(a,"transform",`rotate(${RSe[r()]} 15 15) translate(0 2)`))),e}}))}function DSe(e){const{x:a=0,y:n=0,width:t=0,height:i=0}=e??{};if("function"==typeof DOMRect)return new DOMRect(a,n,t,i);const r={x:a,y:n,width:t,height:i,top:n,right:a+t,bottom:n+i,left:a};return{...r,toJSON:()=>r}}function KSe(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var HSe={top:"bottom",right:"left",bottom:"top",left:"right"};var OSe=Object.assign((function(e){const a=mke({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),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(a.placement),l=()=>{return e=a.anchorRef?.(),n=a.getAnchorRect,{contextElement:e,getBoundingClientRect:()=>{const a=n(e);return a?DSe(a):e?e.getBoundingClientRect():DSe()}};var e,n},{direction:u}=Yke();async function c(){const e=l(),t=n(),r=i();if(!e||!t)return;const o=(r?.clientHeight||0)/2,c="number"==typeof a.gutter?a.gutter+o:a.gutter??o;t.style.setProperty("--kb-popper-content-overflow-padding",`${a.overflowPadding}px`),e.getBoundingClientRect();const d=[MSe((({placement:e})=>{const n=!!e.split("-")[1];return{mainAxis:c,crossAxis:n?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(KSe))throw new Error("`flip` expects a spaced-delimited list of placements");d.push(NSe({padding:a.overflowPadding,fallbackPlacements:e}))}(a.slide||a.overlap)&&d.push(TSe({mainAxis:a.slide,crossAxis:a.overlap,padding:a.overflowPadding})),d.push(ESe({padding:a.overflowPadding,apply({availableWidth:e,availableHeight:n,rects:i}){const r=Math.round(i.reference.width);e=Math.floor(e),n=Math.floor(n),t.style.setProperty("--kb-popper-anchor-width",`${r}px`),t.style.setProperty("--kb-popper-content-available-width",`${e}px`),t.style.setProperty("--kb-popper-content-available-height",`${n}px`),a.sameWidth&&(t.style.width=`${r}px`),a.fitViewport&&(t.style.maxWidth=`${e}px`,t.style.maxHeight=`${n}px`)}})),a.hideWhenDetached&&d.push(xSe({padding:a.detachedPadding})),r&&d.push(PSe({element:r,padding:a.arrowPadding}));const m=await jSe(e,t,{placement:a.placement,strategy:"absolute",middleware:d,platform:{...wSe,isRTL:()=>"rtl"===u()}});if(s(m.placement),a.onCurrentPlacementChange?.(m.placement),!t)return;t.style.setProperty("--kb-popper-content-transform-origin",function(e,a){const[n,t]=e.split("-"),i=HSe[n];return t?"left"===n||"right"===n?`${i} ${"start"===t?"top":"bottom"}`:"start"===t?`${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(t.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,n=m.placement.split("-")[0];Object.assign(r.style,{left:null!=e?`${e}px`:"",top:null!=a?`${a}px`:"",[n]:"100%"})}}return Ba((()=>{const e=l(),a=n();if(!e||!a)return;Ha(CSe(e,a,c,{elementResize:"function"==typeof ResizeObserver}))})),Ba((()=>{const e=n(),t=a.contentRef?.();e&&t&&queueMicrotask((()=>{e.style.zIndex=getComputedStyle(t).zIndex}))})),dn(LSe.Provider,{value:{currentPlacement:o,contentRef:()=>a.contentRef?.(),setPositionerRef:t,setArrowRef:r},get children(){return a.children}})}),{Arrow:_Se,Context:LSe,usePopperContext:BSe,Positioner:function(e){const a=BSe(),[n,t]=fn(e,["ref","style"]);return dn(Ake,vn({as:"div",ref(e){const t=wye(a.setPositionerRef,n.ref);"function"==typeof t&&t(e)},"data-popper-positioner":"",get style(){return Kye({position:"absolute",top:0,left:0,"min-width":"max-content"},n.style)}},t))}});var ISe="interactOutside.pointerDownOutside",GSe="interactOutside.focusOutside";var VSe=Fa();function FSe(e){let a;const n=Ja(VSe),[t,i]=fn(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]);!function(e,a){let n,t=dke;const i=()=>Fye(a()),r=a=>e.onPointerDownOutside?.(a),o=a=>e.onFocusOutside?.(a),s=a=>e.onInteractOutside?.(a),l=n=>{const t=n.target;return t instanceof HTMLElement&&!t.closest(`[${dbe}]`)&&!!Gye(i(),t)&&!Gye(a(),t)&&!e.shouldExcludeElement?.(t)},u=e=>{function n(){const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=Yye([r,s]);t.addEventListener(ISe,i,{once:!0});const o=new CustomEvent(ISe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:2===e.button||Qye(e)&&0===e.button}});t.dispatchEvent(o)}"touch"===e.pointerType?(i().removeEventListener("click",n),t=n,i().addEventListener("click",n,{once:!0})):n()},c=e=>{const n=a(),t=e.target;if(!n||!t||!l(e))return;const i=Yye([o,s]);t.addEventListener(GSe,i,{once:!0});const r=new CustomEvent(GSe,{bubbles:!1,cancelable:!0,detail:{originalEvent:e,isContextMenu:!1}});t.dispatchEvent(r)};Ba((()=>{Pfe(e.isDisabled)||(n=window.setTimeout((()=>{i().addEventListener("pointerdown",u,!0)}),0),i().addEventListener("focusin",c,!0),Ha((()=>{window.clearTimeout(n),i().removeEventListener("click",t),i().removeEventListener("pointerdown",u,!0),i().removeEventListener("focusin",c,!0)})))}))}({shouldExcludeElement:e=>!!a&&(t.excludedElements?.some((a=>Gye(a(),e)))||[...r].some((a=>Gye(a,e)))),onPointerDownOutside:e=>{a&&!ybe.isBelowPointerBlockingLayer(a)&&(t.bypassTopMostLayerCheck||ybe.isTopMostLayer(a))&&(t.onPointerDownOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.())},onFocusOutside:e=>{t.onFocusOutside?.(e),t.onInteractOutside?.(e),e.defaultPrevented||t.onDismiss?.()}},(()=>a)),function(e){const a=a=>{a.key===Uye.Escape&&e.onEscapeKeyDown?.(a)};Ba((()=>{if(Pfe(e.isDisabled))return;const n=e.ownerDocument?.()??Fye();n.addEventListener("keydown",a),Ha((()=>{n.removeEventListener("keydown",a)}))}))}({ownerDocument:()=>Fye(a),onEscapeKeyDown:e=>{a&&ybe.isTopMostLayer(a)&&(t.onEscapeKeyDown?.(e),!e.defaultPrevented&&t.onDismiss&&(e.preventDefault(),t.onDismiss()))}}),Ka((()=>{if(!a)return;ybe.addLayer({node:a,isPointerBlocking:t.disableOutsidePointerEvents,dismiss:t.onDismiss});const e=n?.registerNestedLayer(a);ybe.assignPointerEventToLayers(),ybe.disableBodyPointerEvents(a),Ha((()=>{a&&(ybe.removeLayer(a),e?.(),ybe.assignPointerEventToLayers(),ybe.restoreBodyPointerEvents(a))}))})),Ba(Da([()=>a,()=>t.disableOutsidePointerEvents],(([e,a])=>{if(!e)return;const n=ybe.find(e);n&&n.isPointerBlocking!==a&&(n.isPointerBlocking=a,ybe.assignPointerEventToLayers()),a&&ybe.disableBodyPointerEvents(e),Ha((()=>{ybe.restoreBodyPointerEvents(e)}))}),{defer:!0}));return dn(VSe.Provider,{value:{registerNestedLayer:e=>{r.add(e);const a=n?.registerNestedLayer(e);return()=>{r.delete(e),a?.()}}},get children(){return dn(Ake,vn({as:"div",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)}},i))}})}function JSe(e={}){const[a,n]=jke({value:()=>Pfe(e.open),defaultValue:()=>!!Pfe(e.defaultOpen),onChange:a=>e.onOpenChange?.(a)}),t=()=>{n(!0)},i=()=>{n(!1)};return{isOpen:a,setIsOpen:n,open:t,close:i,toggle:()=>{a()?i():t()}}}var USe={};Bke(USe,{Description:()=>Tke,ErrorMessage:()=>Nke,Item:()=>YSe,ItemControl:()=>QSe,ItemDescription:()=>XSe,ItemIndicator:()=>eAe,ItemInput:()=>aAe,ItemLabel:()=>nAe,Label:()=>tAe,RadioGroup:()=>rAe,Root:()=>iAe});var WSe=Fa();function qSe(){const e=Ja(WSe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var ZSe=Fa();function $Se(){const e=Ja(ZSe);if(void 0===e)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function YSe(e){const a=Mke(),n=qSe(),t=mke({id:`${a.generateId("item")}-${bn()}`},e),[i,r]=fn(t,["value","disabled","onPointerDown"]),[o,s]=Pa(),[l,u]=Pa(),[c,d]=Pa(),[m,h]=Pa(),[p,g]=Pa(!1),v=za((()=>n.isSelectedValue(i.value))),f=za((()=>i.disabled||a.isDisabled()||!1)),y=e=>{$ye(e,i.onPointerDown),p()&&e.preventDefault()},k=za((()=>({...a.dataset(),"data-disabled":f()?"":void 0,"data-checked":v()?"":void 0}))),b={value:()=>i.value,dataset:k,isSelected:v,isDisabled:f,inputId:o,labelId:l,descriptionId:c,inputRef:m,select:()=>n.setSelectedValue(i.value),generateId:Iye((()=>r.id)),registerInput:kke(s),registerLabel:kke(u),registerDescription:kke(d),setIsFocused:g,setInputRef:h};return dn(ZSe.Provider,{value:b,get children(){return dn(Ake,vn({as:"div",role:"group",onPointerDown:y},k,r))}})}function QSe(e){const a=$Se(),n=mke({id:a.generateId("control")},e),[t,i]=fn(n,["onClick","onKeyDown"]);return dn(Ake,vn({as:"div",onClick:e=>{$ye(e,t.onClick),a.select(),a.inputRef()?.focus()},onKeyDown:e=>{$ye(e,t.onKeyDown),e.key===Uye.Space&&(a.select(),a.inputRef()?.focus())}},(()=>a.dataset()),i))}function XSe(e){const a=$Se(),n=mke({id:a.generateId("description")},e);return Ba((()=>Ha(a.registerDescription(n.id)))),dn(Ake,vn({as:"div"},(()=>a.dataset()),n))}function eAe(e){const a=$Se(),n=mke({id:a.generateId("indicator")},e),[t,i]=fn(n,["ref","forceMount"]),[r,o]=Pa(),{present:s}=cbe({show:()=>t.forceMount||a.isSelected(),element:()=>r()??null});return dn(Cn,{get when(){return s()},get children(){return dn(Ake,vn({as:"div",ref(e){const a=wye(o,t.ref);"function"==typeof a&&a(e)}},(()=>a.dataset()),i))}})}function aAe(e){const a=Mke(),n=qSe(),t=$Se(),i=mke({id:t.generateId("input")},e),[r,o]=fn(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),[s,l]=Pa(!1);return Ba(Da([()=>t.isSelected(),()=>t.value()],(e=>{if(!e[0]&&e[1]===t.value())return;l(!0);const a=t.inputRef();a?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))}),{defer:!0})),Ba((()=>Ha(t.registerInput(o.id)))),dn(Ake,vn({as:"input",ref(e){const a=wye(t.setInputRef,r.ref);"function"==typeof a&&a(e)},type:"radio",get name(){return a.name()},get value(){return t.value()},get checked(){return t.isSelected()},get required(){return a.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return a.isReadOnly()},get style(){return Kye({...yke},r.style)},get"aria-labelledby"(){return[r["aria-labelledby"],t.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"],t.descriptionId(),n.ariaDescribedBy()].filter(Boolean).join(" ")||void 0},onChange:e=>{if($ye(e,r.onChange),e.stopPropagation(),!s()){n.setSelectedValue(t.value());e.target.checked=t.isSelected()}l(!1)},onFocus:e=>{$ye(e,r.onFocus),t.setIsFocused(!0)},onBlur:e=>{$ye(e,r.onBlur),t.setIsFocused(!1)}},(()=>t.dataset()),o))}function nAe(e){const a=$Se(),n=mke({id:a.generateId("label")},e);return Ba((()=>Ha(a.registerLabel(n.id)))),dn(Ake,vn({as:"label",get for(){return a.inputId()}},(()=>a.dataset()),n))}function tAe(e){return dn(Eke,vn({as:"span"},e))}function iAe(e){let a;const n=mke({id:`radiogroup-${bn()}`,orientation:"vertical"},e),[t,i,r]=fn(n,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],wke),[o,s]=Pke({value:()=>t.value,defaultValue:()=>t.defaultValue,onChange:e=>t.onChange?.(e)}),{formControlContext:l}=function(e){const a=mke({id:`form-control-${bn()}`},e),[n,t]=Pa(),[i,r]=Pa(),[o,s]=Pa(),[l,u]=Pa();return{formControlContext:{name:()=>Pfe(a.name)??Pfe(a.id),dataset:za((()=>({"data-valid":"valid"===Pfe(a.validationState)?"":void 0,"data-invalid":"invalid"===Pfe(a.validationState)?"":void 0,"data-required":Pfe(a.required)?"":void 0,"data-disabled":Pfe(a.disabled)?"":void 0,"data-readonly":Pfe(a.readOnly)?"":void 0}))),validationState:()=>Pfe(a.validationState),isRequired:()=>Pfe(a.required),isDisabled:()=>Pfe(a.disabled),isReadOnly:()=>Pfe(a.readOnly),labelId:n,fieldId:i,descriptionId:o,errorMessageId:l,getAriaLabelledBy:(e,a,t)=>{const i=null!=t||null!=n();return[t,n(),i&&null!=a?e:void 0].filter(Boolean).join(" ")||void 0},getAriaDescribedBy:e=>[o(),l(),e].filter(Boolean).join(" ")||void 0,generateId:Iye((()=>Pfe(a.id))),registerLabel:kke(t),registerField:kke(r),registerDescription:kke(s),registerErrorMessage:kke(u)}}}(i);xke((()=>a),(()=>s(t.defaultValue??"")));const u=()=>l.getAriaDescribedBy(t["aria-describedby"]),c=e=>e===o(),d={ariaDescribedBy:u,isSelectedValue:c,setSelectedValue:e=>{if(!l.isReadOnly()&&!l.isDisabled()&&(s(e),a))for(const n of a.querySelectorAll("[type='radio']")){n.checked=c(n.value)}}};return dn(Cke.Provider,{value:l,get children(){return dn(WSe.Provider,{value:d,get children(){return dn(Ake,vn({as:"div",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)},role:"radiogroup",get id(){return Pfe(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 t.orientation},get"aria-labelledby"(){return l.getAriaLabelledBy(Pfe(i.id),r["aria-label"],t["aria-labelledby"])},get"aria-describedby"(){return u()}},(()=>l.dataset()),r))}})}})}var rAe=Object.assign(iAe,{Description:Tke,ErrorMessage:Nke,Item:YSe,ItemControl:QSe,ItemDescription:XSe,ItemIndicator:eAe,ItemInput:aAe,ItemLabel:nAe,Label:tAe}),oAe=class{collection;ref;collator;constructor(e,a,n){this.collection=e,this.ref=a,this.collator=n}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 n=this.getItem(e);if(!a||!n)return;const t=Math.max(0,n.offsetTop+n.offsetHeight-a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop>t;)i=this.getKeyAbove(i),n=null!=i?this.getItem(i):null;return i}getKeyPageBelow(e){const a=this.ref?.();let n=this.getItem(e);if(!a||!n)return;const t=Math.min(a.scrollHeight,n.offsetTop-n.offsetHeight+a.offsetHeight);let i=e;for(;i&&n&&n.offsetTop<t;)i=this.getKeyBelow(i),n=null!=i?this.getItem(i):null;return i}getKeyForSearch(e,a){const n=this.collator?.();if(!n)return;let t=null!=a?this.getKeyBelow(a):this.getFirstKey();for(;null!=t;){const a=this.collection().getItem(t);if(a){const i=a.textValue.slice(0,e.length);if(a.textValue&&0===n.compare(i,e))return t}t=this.getKeyBelow(t)}}};function sAe(e,a,n){const t=function(e){const{locale:a}=Yke(),n=za((()=>a()+(e?Object.entries(e).sort(((e,a)=>e[0]<a[0]?-1:1)).join():"")));return za((()=>{const t=n();let i;return Qke.has(t)&&(i=Qke.get(t)),i||(i=new Intl.Collator(a(),e),Qke.set(t,i)),i}))}({usage:"search",sensitivity:"base"});return ibe({selectionManager:()=>Pfe(e.selectionManager),keyboardDelegate:za((()=>{const n=Pfe(e.keyboardDelegate);return n||new oAe(e.collection,a,t)})),autoFocus:()=>Pfe(e.autoFocus),deferAutoFocus:()=>Pfe(e.deferAutoFocus),shouldFocusWrap:()=>Pfe(e.shouldFocusWrap),disallowEmptySelection:()=>Pfe(e.disallowEmptySelection),selectOnFocus:()=>Pfe(e.selectOnFocus),disallowTypeAhead:()=>Pfe(e.disallowTypeAhead),shouldUseVirtualFocus:()=>Pfe(e.shouldUseVirtualFocus),allowsTabNavigation:()=>Pfe(e.allowsTabNavigation),isVirtualized:()=>Pfe(e.isVirtualized),scrollToKey:a=>Pfe(e.scrollToKey)?.(a),orientation:()=>Pfe(e.orientation)},a)}var lAe="focusScope.autoFocusOnMount",uAe="focusScope.autoFocusOnUnmount",cAe={bubbles:!1,cancelable:!0},dAe={stack:[],active(){return this.stack[0]},add(e){e!==this.active()&&this.active()?.pause(),this.stack=Hye(this.stack,e),this.stack.unshift(e)},remove(e){this.stack=Hye(this.stack,e),this.active()?.resume()}};function mAe(e,a){const[n,t]=Pa(!1),i={pause(){t(!0)},resume(){t(!1)}};let r=null;const o=a=>e.onMountAutoFocus?.(a),s=a=>e.onUnmountAutoFocus?.(a),l=()=>Fye(a()),u=()=>{const e=l().createElement("span");return e.setAttribute("data-focus-trap",""),e.tabIndex=0,Object.assign(e.style,yke),e},c=()=>{const e=a();return e?rke(e,!0).filter((e=>!e.hasAttribute("data-focus-trap"))):[]},d=()=>{const e=c();return e.length>0?e[0]:null};Ba((()=>{const e=a();if(!e)return;dAe.add(i);const n=Vye(e);if(!Gye(e,n)){const a=new CustomEvent(lAe,cAe);e.addEventListener(lAe,o),e.dispatchEvent(a),a.defaultPrevented||setTimeout((()=>{Xye(d()),Vye(e)===n&&Xye(e)}),0)}Ha((()=>{e.removeEventListener(lAe,o),setTimeout((()=>{const t=new CustomEvent(uAe,cAe);(()=>{const e=a();if(!e)return!1;const n=Vye(e);return!!n&&!Gye(e,n)&&ske(n)})()&&t.preventDefault(),e.addEventListener(uAe,s),e.dispatchEvent(t),t.defaultPrevented||Xye(n??l().body),e.removeEventListener(uAe,s),dAe.remove(i)}),0)}))})),Ba((()=>{const t=a();if(!t||!Pfe(e.trapFocus)||n())return;const i=e=>{const a=e.target;a?.closest(`[${dbe}]`)||(Gye(t,a)?r=a:Xye(r))},o=e=>{const a=e.relatedTarget??Vye(t);a?.closest(`[${dbe}]`)||Gye(t,a)||Xye(r)};l().addEventListener("focusin",i),l().addEventListener("focusout",o),Ha((()=>{l().removeEventListener("focusin",i),l().removeEventListener("focusout",o)}))})),Ba((()=>{const t=a();if(!t||!Pfe(e.trapFocus)||n())return;const i=u();t.insertAdjacentElement("afterbegin",i);const r=u();function o(e){const a=d(),n=(()=>{const e=c();return e.length>0?e[e.length-1]:null})();Xye(e.relatedTarget===a?n:a)}t.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(),t.insertAdjacentElement("beforeend",r)),a.nextSibling===i&&(i.remove(),t.insertAdjacentElement("afterbegin",i))}));s.observe(t,{childList:!0,subtree:!1}),Ha((()=>{i.removeEventListener("focusin",o),r.removeEventListener("focusin",o),i.remove(),r.remove(),s.disconnect()}))}))}var hAe="data-live-announcer";function pAe(e){Ba((()=>{Pfe(e.isDisabled)||Ha(function(e,a=document.body){const n=new Set(e),t=new Set,i=e=>{for(const t of e.querySelectorAll(`[${hAe}], [${dbe}]`))n.add(t);const a=e=>{if(n.has(e)||e.parentElement&&t.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(const a of n)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=gAe.get(e)??0;"true"===e.getAttribute("aria-hidden")&&0===a||(0===a&&e.setAttribute("aria-hidden","true"),t.add(e),gAe.set(e,a+1))};vAe.length&&vAe[vAe.length-1].disconnect();i(a);const o=new MutationObserver((e=>{for(const a of e)if("childList"===a.type&&0!==a.addedNodes.length&&![...n,...t].some((e=>e.contains(a.target)))){for(const e of a.removedNodes)e instanceof Element&&(n.delete(e),t.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):n.add(e)}}));o.observe(a,{childList:!0,subtree:!0});const s={observe(){o.observe(a,{childList:!0,subtree:!0})},disconnect(){o.disconnect()}};return vAe.push(s),()=>{o.disconnect();for(const e of t){const a=gAe.get(e);if(null==a)return;1===a?(e.removeAttribute("aria-hidden"),gAe.delete(e)):gAe.set(e,a-1)}s===vAe[vAe.length-1]?(vAe.pop(),vAe.length&&vAe[vAe.length-1].observe()):vAe.splice(vAe.indexOf(s),1)}}(Pfe(e.targets),Pfe(e.root)))}))}var gAe=new WeakMap,vAe=[];var fAe=new Map,yAe=e=>{Ba((()=>{const a=ube(e.style)??{},n=ube(e.properties)??[],t={};for(const r in a)t[r]=e.element.style[r];const i=fAe.get(e.key);i?i.activeCount++:fAe.set(e.key,{activeCount:1,originalStyles:t,properties:n.map((e=>e.key))}),Object.assign(e.element.style,e.style);for(const r of n)e.element.style.setProperty(r.key,r.value);Ha((()=>{const a=fAe.get(e.key);if(a)if(1===a.activeCount){fAe.delete(e.key);for(const[n,t]of Object.entries(a.originalStyles))e.element.style[n]=t;for(const n of a.properties)e.element.style.removeProperty(n);0===e.element.style.length&&e.element.removeAttribute("style"),e.cleanup?.()}else a.activeCount--}))}))},kAe=(e,a)=>{switch(a){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},bAe=(e,a)=>{const n=getComputedStyle(e),t="x"===a?n.overflowX:n.overflowY;return"auto"===t||"scroll"===t||"HTML"===e.tagName&&"visible"===t},[SAe,AAe]=Pa([]),wAe=e=>[e.deltaX,e.deltaY],CAe=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],MAe=(e,a,n,t)=>{const i=null!==t&&TAe(t,e),[r,o]=((e,a,n)=>{const t="x"===a&&"rtl"===window.getComputedStyle(e).direction?-1:1;let i=e,r=0,o=0,s=!1;do{const[e,l,u]=kAe(i,a),c=u-e-t*l;0===l&&0===c||!bAe(i,a)||(r+=c,o+=l),i===(n??document.documentElement)?s=!0:i=i._$host??i.parentElement}while(i&&!s);return[r,o]})(e,a,i?t:void 0);return!(n>0&&Math.abs(r)<=1)&&!(n<0&&Math.abs(o)<1)},TAe=(e,a)=>{if(e.contains(a))return!0;let n=a;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},NAe=e=>{const a=vn({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",restoreScrollPosition:!0,allowPinchZoom:!1},e),n=bn();let t=[0,0],i=null,r=null;Ba((()=>{ube(a.enabled)&&(AAe((e=>[...e,n])),Ha((()=>{AAe((e=>e.filter((e=>e!==n))))})))})),Ba((()=>{if(!ube(a.enabled)||!ube(a.hideScrollbar))return;const{body:e}=document,n=window.innerWidth-e.offsetWidth;if(ube(a.preventScrollbarShift)){const t={overflow:"hidden"},i=[];n>0&&("padding"===ube(a.preventScrollbarShiftMode)?t.paddingRight=`calc(${window.getComputedStyle(e).paddingRight} + ${n}px)`:t.marginRight=`calc(${window.getComputedStyle(e).marginRight} + ${n}px)`,i.push({key:"--scrollbar-width",value:`${n}px`}));const r=window.scrollY,o=window.scrollX;yAe({key:"prevent-scroll",element:e,style:t,properties:i,cleanup:()=>{ube(a.restoreScrollPosition)&&n>0&&window.scrollTo(o,r)}})}else yAe({key:"prevent-scroll",element:e,style:{overflow:"hidden"}})})),Ba((()=>{var e;(e=n,SAe().indexOf(e)===SAe().length-1&&ube(a.enabled))&&(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",o,{passive:!1}),document.addEventListener("touchmove",l,{passive:!1}),Ha((()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",l)})))}));const o=e=>{t=CAe(e),i=null,r=null},s=e=>{const n=e.target,t=ube(a.element),i=wAe(e),r=Math.abs(i[0])>Math.abs(i[1])?"x":"y",o=MAe(n,r,"x"===r?i[0]:i[1],t);let s;s=!t||!TAe(t,n)||!o,s&&e.cancelable&&e.preventDefault()},l=e=>{const n=ube(a.element),o=e.target;let s;if(2===e.touches.length)s=!ube(a.allowPinchZoom);else{if(null==i||null===r){const a=CAe(e).map(((e,a)=>t[a]-e)),n=Math.abs(a[0])>Math.abs(a[1])?"x":"y";i=n,r="x"===n?a[0]:a[1]}if("range"===o.type)s=!1;else{const e=MAe(o,i,r,n);s=!n||!TAe(n,o)||!e}}s&&e.cancelable&&e.preventDefault()}},EAe=NAe,xAe=Fa();function PAe(){return Ja(xAe)}function jAe(){const e=PAe();if(void 0===e)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var LAe=Fa();function BAe(){const e=Ja(LAe);if(void 0===e)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var zAe=Fa();function RAe(){const e=Ja(zAe);if(void 0===e)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function _Ae(e){let a;const n=RAe(),t=jAe(),i=mke({id:n.generateId(`item-${bn()}`)},e),[r,o]=fn(i,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[s,l]=Pa(),[u,c]=Pa(),[d,m]=Pa(),h=()=>t.listState().selectionManager(),p=()=>o.id,g=()=>{r.onSelect?.(),r.closeOnSelect&&setTimeout((()=>{t.close(!0)}))};Oke({getItem:()=>({ref:()=>a,type:"item",key:p(),textValue:r.textValue??d()?.textContent??a?.textContent??"",disabled:r.disabled??!1})});const v=rbe({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),f=e=>{$ye(e,r.onPointerMove),"mouse"===e.pointerType&&(r.disabled?t.onItemLeave(e):(t.onItemEnter(e),e.defaultPrevented||(Xye(e.currentTarget),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(p()))))},y=e=>{$ye(e,r.onPointerLeave),"mouse"===e.pointerType&&t.onItemLeave(e)},k=e=>{$ye(e,r.onPointerUp),r.disabled||0!==e.button||g()},b=e=>{if($ye(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)),A=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}))),w={isChecked:()=>r.checked,dataset:A,setLabelRef:m,generateId:Iye((()=>o.id)),registerLabel:kke(l),registerDescription:kke(c)};return dn(LAe.Provider,{value:w,get children(){return dn(Ake,vn({as:"div",ref(e){const n=wye((e=>a=e),r.ref);"function"==typeof n&&n(e)},get tabIndex(){return v.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 v.dataKey()},get onPointerDown(){return Yye([r.onPointerDown,v.onPointerDown])},get onPointerUp(){return Yye([k,v.onPointerUp])},get onClick(){return Yye([r.onClick,v.onClick])},get onKeyDown(){return Yye([b,v.onKeyDown])},get onMouseDown(){return Yye([r.onMouseDown,v.onMouseDown])},get onFocus(){return Yye([r.onFocus,v.onFocus])},onPointerMove:f,onPointerLeave:y},A,o))}})}function DAe(e){const a=mke({closeOnSelect:!1},e),[n,t]=fn(a,["checked","defaultChecked","onChange","onSelect"]),i=function(e={}){const[a,n]=jke({value:()=>Pfe(e.isSelected),defaultValue:()=>!!Pfe(e.defaultIsSelected),onChange:a=>e.onSelectedChange?.(a)});return{isSelected:a,setIsSelected:a=>{Pfe(e.isReadOnly)||Pfe(e.isDisabled)||n(a)},toggle:()=>{Pfe(e.isReadOnly)||Pfe(e.isDisabled)||n(!a())}}}({isSelected:()=>n.checked,defaultIsSelected:()=>n.defaultChecked,onSelectedChange:e=>n.onChange?.(e),isDisabled:()=>t.disabled});return dn(_Ae,vn({role:"menuitemcheckbox",get checked(){return i.isSelected()},onSelect:()=>{n.onSelect?.(),i.toggle()}},t))}var KAe=Fa();function HAe(){return Ja(KAe)}var OAe={next:(e,a)=>"ltr"===e?"horizontal"===a?"ArrowRight":"ArrowDown":"horizontal"===a?"ArrowLeft":"ArrowUp",previous:(e,a)=>OAe.next("ltr"===e?"rtl":"ltr",a)},IAe=e=>"horizontal"===e?"ArrowDown":"ArrowRight",GAe=e=>"horizontal"===e?"ArrowUp":"ArrowLeft";function VAe(e){const a=RAe(),n=jAe(),t=HAe(),{direction:i}=Yke(),r=mke({id:a.generateId("trigger")},e),[o,s]=fn(r,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>a.value();void 0!==t&&(l=()=>a.value()??o.id,void 0===t.lastValue()&&t.setLastValue(l));const u=bke((()=>n.triggerRef()),(()=>"button")),c=za((()=>"a"===u()&&null!=n.triggerRef()?.getAttribute("href")));Ba(Da((()=>t?.value()),(e=>{c()&&e===l()&&n.triggerRef()?.focus()})));const d=()=>{void 0!==t?n.isOpen()?t.value()===l()&&t.closeMenu():(t.autoFocusMenu()||t.setAutoFocusMenu(!0),n.open(!1)):n.toggle(!0)};return Ba((()=>Ha(n.registerTriggerId(o.id)))),dn(bbe,vn({ref(e){const a=wye(n.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 n.isOpen()},get"aria-controls"(){return za((()=>!!n.isOpen()))()?n.contentId():void 0},get"data-highlighted"(){return void 0!==l()&&t?.value()===l()||void 0},get tabIndex(){return void 0!==t?t.value()===l()||t.lastValue()===l()?0:-1:void 0},onPointerDown:e=>{$ye(e,o.onPointerDown),e.currentTarget.dataset.pointerType=e.pointerType,o.disabled||"touch"===e.pointerType||0!==e.button||d()},onMouseOver:e=>{$ye(e,o.onMouseOver),"touch"!==n.triggerRef()?.dataset.pointerType&&(o.disabled||void 0===t||void 0===t.value()||t.setValue(l))},onClick:e=>{$ye(e,o.onClick),o.disabled||"touch"===e.currentTarget.dataset.pointerType&&d()},onKeyDown:e=>{if($ye(e,o.onKeyDown),!o.disabled){if(c())switch(e.key){case"Enter":case" ":return}switch(e.key){case"Enter":case" ":case IAe(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 n=uke(e);for(;e&&n&&e!==a&&n!==a;)vke(n,e),n=uke(e=n)}else{const{left:a,top:n}=e.getBoundingClientRect();e?.scrollIntoView?.({block:"nearest"});const{left:t,top:i}=e.getBoundingClientRect();(Math.abs(a-t)>1||Math.abs(n-i)>1)&&e.scrollIntoView?.({block:"nearest"})}}}(e.currentTarget),n.open("first"),t?.setAutoFocusMenu(!0),t?.setValue(l);break;case GAe(a.orientation()):e.stopPropagation(),e.preventDefault(),n.open("last");break;case OAe.next(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.nextMenu();break;case OAe.previous(i(),a.orientation()):if(void 0===t)break;e.stopPropagation(),e.preventDefault(),t.previousMenu()}}},onFocus:e=>{$ye(e,o.onFocus),void 0!==t&&"touch"!==e.currentTarget.dataset.pointerType&&t.setValue(l)},role:void 0!==t?"menuitem":void 0},(()=>n.dataset()),s))}var FAe=Fa();function JAe(){return Ja(FAe)}function UAe(e){let a;const n=RAe(),t=jAe(),i=HAe(),r=JAe(),{direction:o}=Yke(),s=mke({id:n.generateId(`content-${bn()}`)},e),[l,u]=fn(s,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let c=0;const d=()=>null==t.parentMenuContext()&&void 0===i&&n.isModal(),m=sAe({selectionManager:t.listState().selectionManager,collection:t.listState().collection,autoFocus:t.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!t.listState().selectionManager().isFocused(),orientation:()=>"horizontal"===n.orientation()?"vertical":"horizontal"},(()=>a));mAe({trapFocus:()=>d()&&t.isOpen(),onMountAutoFocus:e=>{void 0===i&&l.onOpenAutoFocus?.(e)},onUnmountAutoFocus:l.onCloseAutoFocus},(()=>a));const h=e=>{l.onEscapeKeyDown?.(e),i?.setAutoFocusMenu(!1),t.close(!0)},p=e=>{l.onFocusOutside?.(e),n.isModal()&&e.preventDefault()};Ba((()=>Ha(t.registerContentId(l.id))));const g={ref:wye((e=>{t.setContentRef(e),a=e}),l.ref),role:"menu",get id(){return l.id},get tabIndex(){return m.tabIndex()},get"aria-labelledby"(){return t.triggerId()},onKeyDown:Yye([l.onKeyDown,m.onKeyDown,e=>{if(Gye(e.currentTarget,e.target)&&("Tab"===e.key&&t.isOpen()&&e.preventDefault(),void 0!==i&&"true"!==e.currentTarget.getAttribute("aria-haspopup")))switch(e.key){case OAe.next(o(),n.orientation()):e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.nextMenu();break;case OAe.previous(o(),n.orientation()):if(e.currentTarget.hasAttribute("data-closed"))break;e.stopPropagation(),e.preventDefault(),t.close(!0),i.setAutoFocusMenu(!0),i.previousMenu()}}]),onMouseDown:Yye([l.onMouseDown,m.onMouseDown]),onFocusIn:Yye([l.onFocusIn,m.onFocusIn]),onFocusOut:Yye([l.onFocusOut,m.onFocusOut]),onPointerEnter:e=>{$ye(e,l.onPointerEnter),t.isOpen()&&(t.parentMenuContext()?.listState().selectionManager().setFocused(!1),t.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},onPointerMove:e=>{if($ye(e,l.onPointerMove),"mouse"!==e.pointerType)return;const a=c!==e.clientX;Gye(e.currentTarget,e.target)&&a&&(t.setPointerDir(e.clientX>c?"right":"left"),c=e.clientX)},get"data-orientation"(){return n.orientation()}};return dn(Cn,{get when(){return t.contentPresent()},get children(){return dn(Cn,{get when(){return void 0===r||null!=t.parentMenuContext()},get fallback(){return dn(Ake,vn({as:"div"},(()=>t.dataset()),g,u))},get children(){return dn(OSe.Positioner,{get children(){return dn(FSe,vn({get disableOutsidePointerEvents(){return za((()=>!!d()))()&&t.isOpen()},get excludedElements(){return[t.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return Kye({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:h,onFocusOutside:p,get onDismiss(){return t.close}},(()=>t.dataset()),g,u))}})}})}})}function WAe(e){let a;const n=RAe(),t=jAe(),[i,r]=fn(e,["ref"]);return EAe({element:()=>a??null,enabled:()=>t.contentPresent()&&n.preventScroll()}),dn(UAe,vn({ref(e){const n=wye((e=>{a=e}),i.ref);"function"==typeof n&&n(e)}},r))}var qAe=Fa();function ZAe(e){const a=mke({id:RAe().generateId(`group-${bn()}`)},e),[n,t]=Pa(),i={generateId:Iye((()=>a.id)),registerLabelId:kke(t)};return dn(qAe.Provider,{value:i,get children(){return dn(Ake,vn({as:"div",role:"group",get"aria-labelledby"(){return n()}},a))}})}function $Ae(e){const a=function(){const e=Ja(qAe);if(void 0===e)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}(),n=mke({id:a.generateId("label")},e),[t,i]=fn(n,["id"]);return Ba((()=>Ha(a.registerLabelId(t.id)))),dn(Ake,vn({as:"span",get id(){return t.id},"aria-hidden":"true"},i))}function YAe(e){const a=jAe();return dn(Ake,vn({as:"span","aria-hidden":"true"},(()=>a.dataset()),mke({children:"▼"},e)))}function QAe(e){return dn(_Ae,vn({role:"menuitem",closeOnSelect:!0},e))}function XAe(e){const a=BAe(),n=mke({id:a.generateId("description")},e),[t,i]=fn(n,["id"]);return Ba((()=>Ha(a.registerDescription(t.id)))),dn(Ake,vn({as:"div",get id(){return t.id}},(()=>a.dataset()),i))}function ewe(e){const a=BAe(),n=mke({id:a.generateId("indicator")},e),[t,i]=fn(n,["forceMount"]);return dn(Cn,{get when(){return t.forceMount||a.isChecked()},get children(){return dn(Ake,vn({as:"div"},(()=>a.dataset()),i))}})}function awe(e){const a=BAe(),n=mke({id:a.generateId("label")},e),[t,i]=fn(n,["ref","id"]);return Ba((()=>Ha(a.registerLabel(t.id)))),dn(Ake,vn({as:"div",ref(e){const n=wye(a.setLabelRef,t.ref);"function"==typeof n&&n(e)},get id(){return t.id}},(()=>a.dataset()),i))}function nwe(e){const a=jAe();return dn(Cn,{get when(){return a.contentPresent()},get children(){return dn(et,e)}})}var twe=Fa();function iwe(e){const a=mke({id:RAe().generateId(`radiogroup-${bn()}`)},e),[n,t]=fn(a,["value","defaultValue","onChange","disabled"]),[i,r]=Pke({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:e=>n.onChange?.(e)});return dn(twe.Provider,{value:{isDisabled:()=>n.disabled,isSelectedValue:e=>e===i(),setSelectedValue:r},get children(){return dn(ZAe,t)}})}function rwe(e){const a=function(){const e=Ja(twe);if(void 0===e)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}(),n=mke({closeOnSelect:!1},e),[t,i]=fn(n,["value","onSelect"]);return dn(_Ae,vn({role:"menuitemradio",get checked(){return a.isSelectedValue(t.value)},onSelect:()=>{t.onSelect?.(),a.setSelectedValue(t.value)}},i))}function owe(e,a,n){const t=e.split("-")[0],i=n.getBoundingClientRect(),r=[],o=a.clientX,s=a.clientY;switch(t){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 swe(e){const a=RAe(),n=Rke(),t=PAe(),i=HAe(),r=JAe(),o=mke({placement:"horizontal"===a.orientation()?"bottom-start":"right-start"},e),[s,l]=fn(o,["open","defaultOpen","onOpenChange"]);let u=0,c=null,d="right";const[m,h]=Pa(),[p,g]=Pa(),[v,f]=Pa(),[y,k]=Pa(),[b,S]=Pa(!0),[A,w]=Pa(l.placement),[C,M]=Pa([]),[T,N]=Pa([]),{DomCollectionProvider:E}=Hke({items:T,onItemsChange:N}),x=JSe({open:()=>s.open,defaultOpen:()=>s.defaultOpen,onOpenChange:e=>s.onOpenChange?.(e)}),{present:P}=cbe({show:()=>a.forceMount()||x.isOpen(),element:()=>y()??null}),j=function(e){const a=tbe(e),n=Gke({dataSource:()=>Pfe(e.dataSource),getKey:()=>Pfe(e.getKey),getTextValue:()=>Pfe(e.getTextValue),getDisabled:()=>Pfe(e.getDisabled),getSectionChildren:()=>Pfe(e.getSectionChildren),factory:a=>new sbe(e.filter?e.filter(a):a)},[()=>e.filter]),t=new obe(n,a);return ja((()=>{const e=a.focusedKey();null==e||n().getItem(e)||a.setFocusedKey(void 0)})),{collection:n,selectionManager:()=>t}}({selectionMode:"none",dataSource:T}),L=e=>{S(e),x.open()},B=(e=!1)=>{x.close(),e&&t&&t.close(!0)},z=()=>{const e=y();e&&(Xye(e),j.selectionManager().setFocused(!0),j.selectionManager().setFocusedKey(void 0))},R=()=>{null!=r?setTimeout((()=>z())):z()},_=e=>{return d===c?.side&&(a=e,n=c?.area,!!n&&function(e,a){const[n,t]=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)*(n-e)-(e-u)*(t-l);if(c<l){if(t>=c&&t<l){if(0===m)return!0;m>0&&(t===c?t>d&&(i=!i):i=!i)}}else if(l<c){if(t>l&&t<=c){if(0===m)return!0;m<0&&(t===c?t<d&&(i=!i):i=!i)}}else if(t==l&&(n>=u&&n<=e||n>=e&&n<=u))return!0}return i}([a.clientX,a.clientY],n));var a,n};pAe({isDisabled:()=>!(null==t&&x.isOpen()&&a.isModal()),targets:()=>[y(),...C()].filter(Boolean)}),Ba((()=>{const e=y();if(!e||!t)return;const a=t.registerNestedMenu(e);Ha((()=>{a()}))})),Ba((()=>{void 0===t&&i?.registerMenu(a.value(),[y(),...C()])})),Ba((()=>{void 0===t&&void 0!==i&&(i.value()===a.value()?(v()?.focus(),i.autoFocusMenu()&&L(!0)):B())})),Ba((()=>{void 0===t&&void 0!==i&&x.isOpen()&&i.setValue(a.value())})),Ha((()=>{void 0===t&&i?.unregisterMenu(a.value())}));const D={dataset:za((()=>({"data-expanded":x.isOpen()?"":void 0,"data-closed":x.isOpen()?void 0:""}))),isOpen:x.isOpen,contentPresent:P,nestedMenus:C,currentPlacement:A,pointerGraceTimeoutId:()=>u,autoFocus:b,listState:()=>j,parentMenuContext:()=>t,triggerRef:v,contentRef:y,triggerId:m,contentId:p,setTriggerRef:f,setContentRef:k,open:L,close:B,toggle:e=>{S(e),x.toggle()},focusContent:R,onItemEnter:e=>{_(e)&&e.preventDefault()},onItemLeave:e=>{_(e)||R()},onTriggerLeave:e=>{_(e)&&e.preventDefault()},setPointerDir:e=>d=e,setPointerGraceTimeoutId:e=>u=e,setPointerGraceIntent:e=>c=e,registerNestedMenu:e=>{M((a=>[...a,e]));const a=t?.registerNestedMenu(e);return()=>{M((a=>Hye(a,e))),a?.()}},registerItemToParentDomCollection:n?.registerItem,registerTriggerId:kke(h),registerContentId:kke(g)};return dn(E,{get children(){return dn(xAe.Provider,{value:D,get children(){return dn(Cn,{when:void 0===r,get fallback(){return l.children},get children(){return dn(OSe,vn({anchorRef:v,contentRef:y,onCurrentPlacementChange:w},l))}})}})}})}function lwe(e){const{direction:a}=Yke();return dn(swe,vn({get placement(){return"rtl"===a()?"left-start":"right-start"},flip:!0},e))}var uwe=(e,a)=>"ltr"===e?["horizontal"===a?"ArrowLeft":"ArrowUp"]:["horizontal"===a?"ArrowRight":"ArrowDown"];function cwe(e){const a=jAe(),n=RAe(),[t,i]=fn(e,["onFocusOutside","onKeyDown"]),{direction:r}=Yke();return dn(UAe,vn({onOpenAutoFocus:e=>{e.preventDefault()},onCloseAutoFocus:e=>{e.preventDefault()},onFocusOutside:e=>{t.onFocusOutside?.(e);const n=e.target;Gye(a.triggerRef(),n)||a.close()},onKeyDown:e=>{$ye(e,t.onKeyDown);const i=Gye(e.currentTarget,e.target),o=uwe(r(),n.orientation()).includes(e.key),s=null!=a.parentMenuContext();i&&o&&s&&(a.close(),Xye(a.triggerRef()))}},i))}var dwe=["Enter"," "],mwe=(e,a)=>"ltr"===e?[...dwe,"horizontal"===a?"ArrowRight":"ArrowDown"]:[...dwe,"horizontal"===a?"ArrowLeft":"ArrowUp"];function hwe(e){let a;const n=RAe(),t=jAe(),i=mke({id:n.generateId(`sub-trigger-${bn()}`)},e),[r,o]=fn(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}=Yke(),c=()=>r.id,d=()=>{const e=t.parentMenuContext();if(null==e)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return e.listState().selectionManager()},m=rbe({key:c,selectionManager:d,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>r.disabled},(()=>a)),h=e=>{$ye(e,r.onClick),t.isOpen()||r.disabled||t.open(!0)},p=e=>{$ye(e,r.onKeyDown),e.repeat||r.disabled||mwe(u(),n.orientation()).includes(e.key)&&(e.stopPropagation(),e.preventDefault(),d().setFocused(!1),d().setFocusedKey(void 0),t.isOpen()||t.open("first"),t.focusContent(),t.listState().selectionManager().setFocused(!0),t.listState().selectionManager().setFocusedKey(t.listState().collection().getFirstKey()))};return Ba((()=>{if(null==t.registerItemToParentDomCollection)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");Ha(t.registerItemToParentDomCollection({ref:()=>a,type:"item",key:c(),textValue:r.textValue??a?.textContent??"",disabled:r.disabled??!1}))})),Ba(Da((()=>t.parentMenuContext()?.pointerGraceTimeoutId()),(e=>{Ha((()=>{window.clearTimeout(e),t.parentMenuContext()?.setPointerGraceIntent(null)}))}))),Ba((()=>Ha(t.registerTriggerId(r.id)))),Ha((()=>{l()})),dn(Ake,vn({as:"div",ref(e){const n=wye((e=>{t.setTriggerRef(e),a=e}),r.ref);"function"==typeof n&&n(e)},get id(){return r.id},role:"menuitem",get tabIndex(){return m.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return za((()=>!!t.isOpen()))()?t.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 Yye([r.onPointerDown,m.onPointerDown])},get onPointerUp(){return Yye([r.onPointerUp,m.onPointerUp])},get onClick(){return Yye([h,m.onClick])},get onKeyDown(){return Yye([p,m.onKeyDown])},get onMouseDown(){return Yye([r.onMouseDown,m.onMouseDown])},get onFocus(){return Yye([r.onFocus,m.onFocus])},onPointerMove:e=>{if($ye(e,r.onPointerMove),"mouse"!==e.pointerType)return;const a=t.parentMenuContext();a?.onItemEnter(e),e.defaultPrevented||(r.disabled?a?.onItemLeave(e):(t.isOpen()||s||(t.parentMenuContext()?.setPointerGraceIntent(null),s=window.setTimeout((()=>{t.open(!1),l()}),100)),a?.onItemEnter(e),e.defaultPrevented||(t.listState().selectionManager().isFocused()&&(t.listState().selectionManager().setFocused(!1),t.listState().selectionManager().setFocusedKey(void 0)),Xye(e.currentTarget),a?.listState().selectionManager().setFocused(!0),a?.listState().selectionManager().setFocusedKey(c()))))},onPointerLeave:e=>{if($ye(e,r.onPointerLeave),"mouse"!==e.pointerType)return;l();const a=t.parentMenuContext(),n=t.contentRef();if(n){a?.setPointerGraceIntent({area:owe(t.currentPlacement(),e,n),side:t.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)}},(()=>t.dataset()),o))}function pwe(e){const a=HAe(),n=mke({id:`menu-${bn()}`,modal:!0},e),[t,i]=fn(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),r=JSe({open:()=>t.open,defaultOpen:()=>t.defaultOpen,onOpenChange:e=>t.onOpenChange?.(e)}),o={isModal:()=>t.modal??!0,preventScroll:()=>t.preventScroll??o.isModal(),forceMount:()=>t.forceMount??!1,generateId:Iye((()=>t.id)),value:()=>t.value,orientation:()=>t.orientation??a?.orientation()??"horizontal"};return dn(zAe.Provider,{value:o,get children(){return dn(swe,vn({get open(){return r.isOpen()},get onOpenChange(){return r.setIsOpen}},i))}})}function gwe(e){let a;const n=mke({orientation:"horizontal"},e),[t,i]=fn(n,["ref","orientation"]),r=bke((()=>a),(()=>"hr"));return dn(Ake,vn({as:"hr",ref(e){const n=wye((e=>a=e),t.ref);"function"==typeof n&&n(e)},get role(){return"hr"!==r()?"separator":void 0},get"aria-orientation"(){return"vertical"===t.orientation?"vertical":void 0},get"data-orientation"(){return t.orientation}},i))}Bke({},{Root:()=>gwe,Separator:()=>vwe});var vwe=gwe,fwe={};function ywe(e){const a=RAe(),n=jAe(),[t,i]=fn(e,["onCloseAutoFocus","onInteractOutside"]);let r=!1;return dn(WAe,vn({onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),r||Xye(n.triggerRef()),r=!1,e.preventDefault()},onInteractOutside:e=>{t.onInteractOutside?.(e),a.isModal()&&!e.detail.isContextMenu||(r=!0)}},i))}function kwe(e){return dn(pwe,mke({id:`dropdownmenu-${bn()}`},e))}Bke(fwe,{Arrow:()=>_Se,CheckboxItem:()=>DAe,Content:()=>ywe,DropdownMenu:()=>bwe,Group:()=>ZAe,GroupLabel:()=>$Ae,Icon:()=>YAe,Item:()=>QAe,ItemDescription:()=>XAe,ItemIndicator:()=>ewe,ItemLabel:()=>awe,Portal:()=>nwe,RadioGroup:()=>iwe,RadioItem:()=>rwe,Root:()=>kwe,Separator:()=>gwe,Sub:()=>lwe,SubContent:()=>cwe,SubTrigger:()=>hwe,Trigger:()=>VAe});var bwe=Object.assign(kwe,{Arrow:_Se,CheckboxItem:DAe,Content:ywe,Group:ZAe,GroupLabel:$Ae,Icon:YAe,Item:QAe,ItemDescription:XAe,ItemIndicator:ewe,ItemLabel:awe,Portal:nwe,RadioGroup:iwe,RadioItem:rwe,Separator:gwe,Sub:lwe,SubContent:cwe,SubTrigger:hwe,Trigger:VAe}),Swe={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"}},Awe=_n('<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>'),wwe=_n('<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>'),Cwe=_n('<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>'),Mwe=_n('<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>'),Twe=_n('<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>'),Nwe=_n('<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>'),Ewe=_n('<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>'),xwe=_n('<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>'),Pwe=_n('<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">'),jwe=_n('<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">'),Lwe=_n('<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>'),Bwe=_n('<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>'),zwe=_n('<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>'),Rwe=_n('<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>'),_we=_n('<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>'),Dwe=_n('<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>'),Kwe=_n('<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>'),Hwe=_n('<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>'),Owe=_n('<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>'),Iwe=_n('<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>'),Gwe=_n('<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>'),Vwe=_n('<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>'),Fwe=_n('<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 Jwe(){return Awe()}function Uwe(){return wwe()}function Wwe(){return Cwe()}function qwe(){return Mwe()}function Zwe(){return Twe()}function $we(){return(e=Twe()).style.setProperty("transform","rotate(90deg)"),e;var e}function Ywe(){return(e=Twe()).style.setProperty("transform","rotate(-90deg)"),e;var e}function Qwe(){return Nwe()}function Xwe(){return Ewe()}function eCe(){return xwe()}function aCe(){return Pwe()}function nCe(){return jwe()}function tCe(){return Lwe()}function iCe(){return Bwe()}function rCe(){return zwe()}function oCe(){return Rwe()}function sCe(e){return a=_we(),n=a.firstChild,La((()=>Kn(n,"stroke","dark"===e.theme?"#12B76A":"#027A48"))),a;var a,n}function lCe(){return Dwe()}function uCe(){return Kwe()}function cCe(e){return[dn(Cn,{get when(){return e.checked},get children(){var a=_we(),n=a.firstChild;return La((()=>Kn(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}}),dn(Cn,{get when(){return!e.checked},get children(){var a=Hwe(),n=a.firstChild;return La((()=>Kn(n,"stroke","dark"===e.theme?"#9B8AFB":"#6938EF"))),a}})]}function dCe(){return Owe()}function mCe(){return Iwe()}function hCe(){return Gwe()}function pCe(){return Vwe()}function gCe(){const e=bn();return a=Fwe(),r=(i=(t=(n=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,f=(v=p.nextSibling).firstChild,b=(k=(y=v.nextSibling).nextSibling).firstChild,A=(S=k.nextSibling).firstChild,M=(C=(w=S.nextSibling).nextSibling).firstChild,N=(T=C.nextSibling).firstChild,P=(x=(E=T.nextSibling).nextSibling).firstChild,L=(j=x.nextSibling).firstChild,R=(z=(B=j.nextSibling).nextSibling).firstChild,D=(_=z.nextSibling).firstChild,O=(H=(K=_.nextSibling).firstChild.nextSibling.nextSibling.nextSibling).nextSibling,G=(I=K.nextSibling).firstChild,F=(V=I.nextSibling).firstChild,re=(ie=(te=(ne=(ae=(ee=(X=(Q=(Y=($=(Z=(q=(W=(U=(J=V.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,ve=(ge=he.nextSibling).firstChild,Re=(ze=(Be=(Le=(je=(Pe=(xe=(Ee=(Ne=(Te=(Me=(Ce=(we=(Ae=(Se=(be=(ke=(ye=(fe=ge.nextSibling).firstChild).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling).nextSibling,Kn(n,"id",`a-${e}`),Kn(t,"fill",`url(#a-${e})`),Kn(r,"id",`am-${e}`),Kn(o,"id",`b-${e}`),Kn(s,"filter",`url(#am-${e})`),Kn(l,"mask",`url(#b-${e})`),Kn(c,"id",`ah-${e}`),Kn(d,"id",`k-${e}`),Kn(m,"filter",`url(#ah-${e})`),Kn(h,"mask",`url(#k-${e})`),Kn(g,"id",`ae-${e}`),Kn(v,"id",`j-${e}`),Kn(f,"filter",`url(#ae-${e})`),Kn(y,"mask",`url(#j-${e})`),Kn(b,"id",`ai-${e}`),Kn(S,"id",`i-${e}`),Kn(A,"filter",`url(#ai-${e})`),Kn(w,"mask",`url(#i-${e})`),Kn(M,"id",`aj-${e}`),Kn(T,"id",`h-${e}`),Kn(N,"filter",`url(#aj-${e})`),Kn(E,"mask",`url(#h-${e})`),Kn(P,"id",`ag-${e}`),Kn(j,"id",`g-${e}`),Kn(L,"filter",`url(#ag-${e})`),Kn(B,"mask",`url(#g-${e})`),Kn(R,"id",`af-${e}`),Kn(_,"id",`f-${e}`),Kn(D,"filter",`url(#af-${e})`),Kn(K,"mask",`url(#f-${e})`),Kn(H,"id",`m-${e}`),Kn(O,"fill",`url(#m-${e})`),Kn(G,"id",`ak-${e}`),Kn(V,"id",`e-${e}`),Kn(F,"filter",`url(#ak-${e})`),Kn(J,"mask",`url(#e-${e})`),Kn(U,"id",`n-${e}`),Kn(W,"fill",`url(#n-${e})`),Kn(q,"id",`r-${e}`),Kn(Z,"fill",`url(#r-${e})`),Kn($,"id",`s-${e}`),Kn(Y,"fill",`url(#s-${e})`),Kn(Q,"id",`q-${e}`),Kn(X,"fill",`url(#q-${e})`),Kn(ee,"id",`p-${e}`),Kn(ae,"fill",`url(#p-${e})`),Kn(ne,"id",`o-${e}`),Kn(te,"fill",`url(#o-${e})`),Kn(ie,"id",`l-${e}`),Kn(re,"fill",`url(#l-${e})`),Kn(se,"id",`al-${e}`),Kn(le,"id",`d-${e}`),Kn(ue,"filter",`url(#al-${e})`),Kn(ce,"mask",`url(#d-${e})`),Kn(de,"id",`u-${e}`),Kn(me,"fill",`url(#u-${e})`),Kn(pe,"id",`ad-${e}`),Kn(ge,"id",`c-${e}`),Kn(ve,"filter",`url(#ad-${e})`),Kn(fe,"mask",`url(#c-${e})`),Kn(ye,"id",`t-${e}`),Kn(ke,"fill",`url(#t-${e})`),Kn(be,"id",`v-${e}`),Kn(Se,"stroke",`url(#v-${e})`),Kn(Ae,"id",`aa-${e}`),Kn(we,"stroke",`url(#aa-${e})`),Kn(Ce,"id",`w-${e}`),Kn(Me,"stroke",`url(#w-${e})`),Kn(Te,"id",`ac-${e}`),Kn(Ne,"stroke",`url(#ac-${e})`),Kn(Ee,"id",`ab-${e}`),Kn(xe,"stroke",`url(#ab-${e})`),Kn(Pe,"id",`y-${e}`),Kn(je,"stroke",`url(#y-${e})`),Kn(Le,"id",`x-${e}`),Kn(Be,"stroke",`url(#x-${e})`),Kn(ze,"id",`z-${e}`),Kn(Re,"stroke",`url(#z-${e})`),a;var a,n,t,i,r,o,s,l,u,c,d,m,h,p,g,v,f,y,k,b,S,A,w,C,M,T,N,E,x,P,j,L,B,z,R,_,D,K,H,O,I,G,V,F,J,U,W,q,Z,$,Y,Q,X,ee,ae,ne,te,ie,re,oe,se,le,ue,ce,de,me,he,pe,ge,ve,fe,ye,ke,be,Se,Ae,we,Ce,Me,Te,Ne,Ee,xe,Pe,je,Le,Be,ze,Re}var vCe=_n('<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>'),fCe=_n('<button title="Copy object to clipboard">'),yCe=_n('<button title="Remove all items"aria-label="Remove all items">'),kCe=_n('<button title="Delete item"aria-label="Delete item">'),bCe=_n('<button title="Toggle value"aria-label="Toggle value">'),SCe=_n('<button title="Bulk Edit Data"aria-label="Bulk Edit Data">'),ACe=_n("<div>"),wCe=_n("<div><button> <span></span> <span> "),CCe=_n("<input>"),MCe=_n("<span>"),TCe=_n("<div><span>:"),NCe=_n("<div><div><button> [<!>...<!>]");var ECe=e=>{const a=qfe(),n=Vfe().shadowDOMTarget?kye.bind({target:Vfe().shadowDOMTarget}):kye,t=za((()=>"dark"===a()?DCe(n):_Ce(n)));return i=vCe(),La((()=>Hn(i,Sye(t().expander,n`
115
115
  transform: rotate(${e.expanded?90:0}deg);
116
116
  `,e.expanded&&n`
117
117
  & svg {