1import{j as e,u as ks,d as ot,e as rt}from"./vendor-query-DBp4gPgf.js";import{r as n,a as it,u as Is}from"./vendor-react-g8dEulS4.js";import{d as Y,a as C,X as lt,c as Rs,e as Es,b as xe,s as he,u as Ps,f as As,g as Ms,h as Ds,i as Ls}from"./index-DC5xQW3Q.js";import{B as E,L as fe,C as ct,a as dt,b as ut,d as pt,e as D,I as G}from"./card-DctDIF7q.js";import{O as mt,C as ht,l as Os,T as ft,m as xt,n as Hs,o as Bs,p as Fs,a as Ke,b as U,P as A,e as P,u as K,q as Vs,r as Us,s as zs,F as Ws,D as $s,k as qe,d as gt,j as Ks,g as De,h as qs,t as Je}from"./vendor-ui-CsxsGL2z.js";import{a as vt,A as Gs,b as Ys,d as Qs,e as Xs,R as Zs,c as Js,u as ea}from"./vendor-radix-C-VOrnof.js";import{C as ta}from"./clock-C16uHjE4.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const sa=Y("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const aa=Y("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const yt=Y("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const na=Y("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 22 * @license lucide-react v0.462.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const oa=Y("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** 27 * @license lucide-react v0.462.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const ra=Y("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** 32 * @license lucide-react v0.462.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const ia=Y("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** 37 * @license lucide-react v0.462.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const wt=Y("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** 42 * @license lucide-react v0.462.0 - ISC 43 * 44 * This source code is licensed under the ISC license. 45 * See the LICENSE file in the root directory of this source tree. 46 */const et=Y("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** 47 * @license lucide-react v0.462.0 - ISC 48 * 49 * This source code is licensed under the ISC license. 50 * See the LICENSE file in the root directory of this source tree. 51 */const la=Y("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),St=n.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:C("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
51ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...a}));St.displayName="Textarea";const Le=Hs,Oe=Bs,ca=Fs,jt=n.forwardRef(({className:t,...a},s)=>e.jsx(mt,{ref:s,className:C("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));jt.displayName=mt.displayName;const ye=n.forwardRef(({className:t,children:a,...s},o)=>e.jsxs(ca,{children:[e.jsx(jt,{}),e.jsxs(ht,{ref:o,className:C("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[a,e.jsxs(Os,{className:"absolute right-4 top-4 roun
51ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(lt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ye.displayName=ht.displayName;const we=({className:t,...a})=>e.jsx("div",{className:C("flex flex-col space-y-1.5 text-center sm:text-left",t),...a});we.displayName="DialogHeader";const Se=n.forwardRef(({className:t,...a},s)=>e.jsx(ft,{ref:s,className:C("text-lg font-semibold leading-none tracking-tight",t),...a}));Se.displayName=ft.displayName;const da=n.forwardRef(({className:t,...a},s)=>e.jsx(xt,{ref:s,className:C("text-sm text-muted-foreground",t),...a}));da.displayName=xt.displayName;function bt(t){const a=n.useRef({value:t,previous:t});return n.useMemo(()=>(a.current.value!==t&&(a.current.previous=a.current.value,a.current.value=t),a.current.previous),[t])}var ua=[" ","Enter","ArrowUp","ArrowDown"],pa=[" ","Enter"],re="Select",[be,Ne,ma]=Rs(re),[ue,En]=Ke(re,[ma,vt]),_e=vt(),[ha,te]=ue(re),[fa,xa]=ue(re),Nt=t=>{const{__scopeSelect:a,children:s,open:o,defaultOpen:r,onOpenChange:c,value:u,defaultValue:i,onValueChange:d,dir:p,name:x,autoComplete:w,disabled:b,required:N,form:S}=t,h=_e(a),[g,v]=n.useState(null),[f,m]=n.useState(null),[_,L]=n.useState(!1),ae=Ks(p),[M,F]=De({prop:o,defaultProp:r??!1,onChange:c,caller:re}),[l,j]=De({prop:u,defaultProp:i,onChange:d,caller:re}),O=n.useRef(null),z=g?S||!!g.closest("form"):!0,[J,Q]=n.useState(new Set),X=Array.from(J).map(H=>H.props.value).join(";");return e.jsx(Zs,{...h,children:e.jsxs(ha,{required:N,scope:a,trigger:g,onTriggerChange:v,valueNode:f,onValueNodeChange:m,valueNodeHasChildren:_,onValueNodeHasChildrenChange:L,contentId:qe(),value:l,onValueChange:j,open:M,onOpenChange:F,dir:ae,triggerPointerDownPosRef:O,disabled:b,children:[e.jsx(be.Provider,{scope:a,children:e.jsx(fa,{scope:t.__scopeSelect,onNativeOptionAdd:n.useCallback(H=>{Q(q=>new Set(q).add(H))},[]),onNativeOptionRemove:n.useCallback(H=>{Q(q=>{const Z=new Set(q);return Z.delete(H),Z})},[]),children:s})}),z?e.jsxs(Gt,{"aria-hidden":!0,required:N,tabIndex:-1,name:x,autoComplete:w,value:l,onChange:H=>j(H.target.value),disabled:b,form:S,children:[l===void 0?e.jsx("option",{value:""}):null,Array.from(J)]},X):null]})})};Nt.displayName=re;var _t="SelectTrigger",Ct=n.forwardRef((t,a)=>{const{__scopeSelect:s,disabled:o=!1,...r}=t,c=_e(s),u=te(_t,s),i=u.disabled||o,d=U(a,u.onTriggerChange),p=Ne(s),x=n.useRef("touch"),[w,b,N]=Qt(h=>{const g=p().filter(m=>!m.disabled),v=g.find(m=>m.value===u.value),f=Xt(g,h,v);f!==void 0&&u.onValueChange(f.value)}),S=h=>{i||(u.onOpenChange(!0),N()),h&&(u.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return e.jsx(Gs,{asChild:!0,...c,children:e.jsx(A.button,{type:"button",role:"combobox","aria-controls":u.contentId,"aria-expanded":u.open,"aria-required":u.required,"aria-autocomplete":"none",dir:u.dir,"data-state":u.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":Yt(u.value)?"":void 0,...r,ref:d,onClick:P(r.onClick,h=>{h.currentTarget.focus(),x.current!=="mouse"&&S(h)}),onPointerDown:P(r.onPointerDown,h=>{x.current=h.pointerType;const g=h.target;g.hasPointerCapture(h.pointerId)&&g.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(S(h),h.preventDefault())}),onKeyDown:P(r.onKeyDown,h=>{const g=w.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&b(h.key),!(g&&h.key===" ")&&ua.includes(h.key)&&(S(),h.preventDefault())})})})});Ct.displayName=_t;var Tt="SelectValue",kt=n.forwardRef((t,a)=>{const{__scopeSelect:s,className:o,style:r,children:c,placeholder:u="",...i}=t,d=te(Tt,s),{onValueNodeHasChildrenChange:p}=d,x=c!==void 0,w=U(a,d.onValueNodeChange);return K(()=>{p(x)},[p,x]),e.jsx(A.span,{...i,ref:w,style:{pointerEvents:"none"},children:Yt(d.value)?e.jsx(e.Fragment,{children:u}):c})});kt.displayName=Tt;var ga="SelectIcon",It=n.forwardRef((t,a)=>{const{__scopeSelect:s,children:o,...r}=t;return e.jsx(A.span,{"aria-hidden":!0,...r,ref:a,children:o||"â¼"})});It.displayName=ga;var va="SelectPortal",Rt=t=>e.jsx(qs,{asChild:!0,...t});Rt.displayName=va;var ie="SelectContent",Et=n.forwardRef((t,a)=>{const s=te(ie,t.__scopeSelect),[o,r]=n.useState();if(K(()=>{r(new DocumentFragment)},[]),!s.open){const c=o;return c?it.createPortal(e.jsx(Pt,{scope:t.__scopeSelect,children:e.jsx(be.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),c):null}
vendor: 14,528 bytes, line 51
51return e.jsx(At,{...t,ref:a})});Et.displayName=ie;var W=10,[Pt,se]=ue(ie),ya="SelectContentImpl",wa=Js("SelectContent.RemoveScroll"),At=n.forwardRef((t,a)=>{const{__scopeSelect:s,position:o="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:c,onPointerDownOutside:u,side:i,sideOffset:d,align:p,alignOffset:x,arrowPadding:w,collisionBoundary:b,collisionPadding:N,sticky:S,hideWhenDetached:h,avoidCollisions:g,...v}=t,f=te(ie,s),[m,_]=n.useState(null),[L,ae]=n.useState(null),M=U(a,y=>_(y)),[F,l]=n.useState(null),[j,O]=n.useState(null),z=Ne(s),[J,Q]=n.useState(!1),X=n.useRef(!1);n.useEffect(()=>{if(m)return Vs(m)},[m]),Us();const H=n.useCallback(y=>{const[R,...B]=z().map(k=>k.ref.current),[I]=B.slice(-1),T=document.activeElement;for(const k of y)if(k===T||(k==null||k.scrollIntoView({block:"nearest"}),k===R&&L&&(L.scrollTop=0),k===I&&L&&(L.scrollTop=L.scrollHeight),k==null||k.focus(),document.activeElement!==T))return},[z,L]),q=n.useCallback(()=>H([F,m]),[H,F,m]);n.useEffect(()=>{J&&q()},[J,q]);const{onOpenChange:Z,triggerPointerDownPosRef:ee}=f;n.useEffect(()=>{if(m){let y={x:0,y:0};const R=I=>{var T,k;y={x:Math.abs(Math.round(I.pageX)-(((T=ee.current)==null?void 0:T.x)??0)),y:Math.abs(Math.round(I.pageY)-(((k=ee.current)==null?void 0:k.y)??0))}},B=I=>{y.x<=10&&y.y<=10?I.preventDefault():m.contains(I.target)||Z(!1),document.removeEventListener("pointermove",R),ee.current=null};return ee.current!==null&&(document.addEventListener("pointermove",R),document.addEventListener("pointerup",B,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",B,{capture:!0})}}},[m,Z,ee]),n.useEffect(()=>{const y=()=>Z(!1);return window.addEventListener("blur",y),window.addEventListener("resize",y),()=>{window.removeEventListener("blur",y),window.removeEventListener("resize",y)}},[Z]);const[Te,ge]=Qt(y=>{const R=z().filter(T=>!T.disabled),B=R.find(T=>T.ref.current===document.activeElement),I=Xt(R,y,B);I&&setTimeout(()=>I.ref.current.focus())}),ke=n.useCallback((y,R,B)=>{const I=!X.current&&!B;(f.value!==void 0&&f.value===R||I)&&(l(y),I&&(X.current=!0))},[f.value]),Ie=n.useCallback(()=>m==null?void 0:m.focus(),[m]),le=n.useCallback((y,R,B)=>{const I=!X.current&&!B;(f.value!==void 0&&f.value===R||I)&&O(y)},[f.value]),ve=o==="popper"?He:Mt,pe=ve===He?{side:i,sideOffset:d,align:p,alignOffset:x,arrowPadding:w,collisionBoundary:b,collisionPadding:N,sticky:S,hideWhenDetached:h,avoidCollisions:g}:{};return e.jsx(Pt,{scope:s,content:m,viewport:L,onViewportChange:ae,itemRefCallback:ke,selectedItem:F,onItemLeave:Ie,itemTextRefCallback:le,focusSelectedItem:q,selectedItemText:j,position:o,isPositioned:J,searchRef:Te,children:e.jsx(zs,{as:wa,allowPinchZoom:!0,children:e.jsx(Ws,{asChild:!0,trapped:f.open,onMountAutoFocus:y=>{y.preventDefault()},onUnmountAutoFocus:P(r,y=>{var R;(R=f.trigger)==null||R.focus({preventScroll:!0}),y.preventDefault()}),children:e.jsx($s,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:y=>y.preventDefault(),onDismiss:()=>f.onOpenChange(!1),children:e.jsx(ve,{role:"listbox",id:f.contentId,"data-state":f.open?"open":"closed",dir:f.dir,onContextMenu:y=>y.preventDefault(),...v,...pe,onPlaced:()=>Q(!0),ref:M,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:P(v.onKeyDown,y=>{const R=y.ctrlKey||y.altKey||y.metaKey;if(y.key==="Tab"&&y.preventDefault(),!R&&y.key.length===1&&ge(y.key),["ArrowUp","ArrowDown","Home","End"].includes(y.key)){let I=z().filter(T=>!T.disabled).map(T=>T.ref.current);if(["ArrowUp","End"].includes(y.key)&&(I=I.slice().reverse()),["ArrowUp","ArrowDown"].includes(y.key)){const T=y.target,k=I.indexOf(T);I=I.slice(k+1)}setTimeout(()=>H(I)),y.preventDefault()}})})})})})})});At.displayName=ya;var Sa="SelectItemAlignedPosition",Mt=n.forwardRef((t,a)=>{const{__scopeSelect:s,onPlaced:o,...r}=t,c=te(ie,s),u=se(ie,s),[i,d]=n.useState(null),[p,x]=n.useState(null),w=U(a,M=>x(M)),b=Ne(s),N=n.useRef(!1),S=n.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:v,focusSelectedItem:f}=u,m=n.useCallback(()=>{if(c.trigger&&c.valueNode&&i&&p&&h&&g&&v){const M=c.trigger.getBoundingClientRect(),F=p.getBoundingClientRect(),l=c.valueNode.getBoundingClientRect(),j=v.getBoundingClientRect();if(c.dir!=="rtl"){const T=j.left-F.left,k=l.left-T,ne=M.left-k,oe=M.width+ne,Re=Math.max(oe,F.width),Ee=window.innerWidth-W,Pe=Je(k,[W,Math.max(W,Ee-Re)]);i.style.minWidth=oe+"px",i.style.left=Pe+"px"}else{const T=F.right-j.right,k=window.innerWidth-l.right-T,ne=window.innerWidth-M.right-k,oe=M.width+ne,Re=Math.max(oe,F.width),Ee=window.innerWidth-W,Pe=Je(k,[W,Math.max(W,Ee-Re)]);i.style.minWidth=oe+"px",i.style.right=Pe+"px"}const O=b(),z=window.innerHeight-W*2,J=h.scrollHeight,Q=window.getComputedStyle(p),X=parseInt(Q.borderTopWidth,10),H=parseInt(Q.paddingTop,10),q=parseInt(Q.borderBottomWidth,10),Z=parseInt(Q.paddingBottom,10),ee=X+H+J+Z+q,Te=Math.min(g.offsetHeight*5,ee),ge=window.getComputedStyle(h),ke=parseInt(ge.paddingTop,10),Ie=parseInt(ge.paddingBottom,10),le=M.top+M.height/2-W,ve=z-le,pe=g.offsetHeight/2,y=g.offsetTop+pe,R=X+H+y,B=ee-R;if(R<=le){const T=O.length>0&&g===O[O.length-1].ref.current;i.style.bottom="0px";const k=p.clientHeight-h.offsetTop-h.offsetHeight,ne=Math.max(ve,pe+(T?Ie:0)+k+q),oe=R+ne;i.style.height=oe+"px"}else{const T=O.length>0&&g===O[0].ref.current;i.style.top="0px";const ne=Math.max(le,X+h.offsetTop+(T?ke:0)+pe)+B;i.style.height=ne+"px",h.scrollTop=R-le+h.offsetTop}i.style.margin=`${W}px 0`,i.style.minHeight=Te+"px",i.style.maxHeight=z+"px",o==null||o(),requestAnimationFrame(()=>N.current=!0)}},[b,c.trigger,c.valueNode,i,p,h,g,v,c.dir,o]);K(()=>m(),[m]);const[_,L]=n.useState();K(()=>{p&&L(window.getComputedStyle(p).zIndex)},[p]);const ae=n.useCallback(M=>{M&&S.current===!0&&(m(),f==null||f(),S.current=!1)},[m,f]);return e.jsx(ba,{scope:s,contentWrapper:i,shouldExpandOnScrollRef:N,onScrollButtonChange:ae,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:e.jsx(A.div,{...r,ref:w,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});Mt.displayName=Sa;var ja="SelectPopperPosition",He=n.forwardRef((t,a)=>{const{__scopeSelect:s,align:o="start",collisionPadding:r=W,...c}=t,u=_e(s);return e.jsx(Ys,{...u,...c,ref:a,align:o,collisionPadding:r,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});He.displayName=ja;var[ba,Ge]=ue(ie,{}),Be="SelectViewport",Dt=n.forwardRef((t,a)=>{const{__scopeSelect:s,nonce:o,...r}=t,c=se(Be,s),u=Ge(Be,s),i=U(a,c.onViewportChange),d=n.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),e.jsx(be.Slot,{scope:s,children:e.jsx(A.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:P(r.onScroll,p=>{const x=p.currentTarget,{contentWrapper:w,shouldExpandOnScrollRef:b}=u;if(b!=null&&b.current&&w){const N=Math.abs(d.current-x.scrollTop);if(N>0){const S=window.innerHeight-W*2,h=parseFloat(w.style.minHeight),g=parseFloat(w.style.height),v=Math.max(h,g);if(v<S){const f=v+N,m=Math.min(S,f),_=f-m;w.style.height=m+"px",w.style.bottom==="0px"&&(x.scrollTop=_>0?_:0,w.style.justifyContent="flex-end")}}}d.current=x.scrollTop})})})]})});Dt.displayName=Be;var Lt="SelectGroup",[Na,_a]=ue(Lt),Ca=n.forwardRef((t,a)=>{const{__scopeSelect:s,...o}=t,r=qe();return e.jsx(Na,{scope:s,id:r,children:e.jsx(A.div,{role:"group","aria-labelledby":r,...o,ref:a})})});Ca.displayName=Lt;var Ot="SelectLabel",Ht=n.forwardRef((t,a)=>{const{__scopeSelect:s,...o}=t,r=_a(Ot,s);return e.jsx(A.div,{id:r.id,...o,ref:a})});Ht.displayName=Ot;var je="SelectItem",[Ta,Bt]=ue(je),Ft=n.forwardRef((t,a)=>{const{__scopeSelect:s,value:o,disabled:r=!1,textValue:c,...u}=t,i=te(je,s),d=se(je,s),p=i.value===o,[x,w]=n.useState(c??""),[b,N]=n.useState(!1),S=U(a,f=>{var m;return(m=d.itemRefCallback)==null?void 0:m.call(d,f,o,r)}),h=qe(),g=n.useRef("touch"),v=()=>{r||(i.onValueChange(o),i.onOpenChange(!1))};if(o==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(Ta,{scope:s,value:o,disabled:r,textId:h,isSelected:p,onItemTextChange:n.useCallback(f=>{w(m=>m||((f==null?void 0:f.textContent)??"").trim())},[]),children:e.jsx(be.ItemSlot,{scope:s,value:o,disabled:r,textValue:x,children:e.jsx(A.div,{role:"option","aria-labelledby":h,"data-highlighted":b?"":void 0,"aria-selected":p&&b,"data-state":p?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...u,ref:S,onFocus:P(u.onFocus,()=>N(!0)),onBlur:P(u.onBlur,()=>N(!1)),onClick:P(u.onClick,()=>{g.current!=="mouse"&&v()}),onPointerUp:P(u.onPointerUp,()=>{g.current==="mouse"&&v()}),onPointerDown:P(u.onPointerDown,f=>{g.current=f.pointerType}),onPointerMove:P(u.onPointerMove,f=>{var m;g.current=f.pointerType,r?(m=d.onItemLeave)==null||m.call(d):g.current==="mouse"&&f.currentTarget.focus({preventScroll:!0})}),onPointerLeave:P(u.onPointerLeave,f=>{var m;f.currentTarget===document.activeElement&&((m=d.onItemLeave)==null||m.call(d))}),onKeyDown:P(u.onKeyDown,f=>{var _;((_=d.searchRef)==null?void 0:_.current)!==""&&f.key===" "||(pa.includes(f.key)&&v(),f.key===" "&&f.preventDefault())})})})})});Ft.displayName=je;var me="SelectItemText",Vt=n.forwardRef((t,a)=>{const{__scopeSelect:s,className:o,style:r,...c}=t,u=te(me,s),i=se(me,s),d=Bt(me,s),p=xa(me,s),[x,w]=n.useState(null),b=U(a,v=>w(v),d.onItemTextChange,v=>{var f;return(f=i.itemTextRefCallback)==null?void 0:f.call(i,v,d.value,d.disabled)}),N=x==null?void 0:x.textContent,S=n.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:N},d.value),[d.disabled,d.value,N]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=p;return K(()=>(h(S),()=>g(S)),[h,g,S]),e.jsxs(e.Fragment,{children:[e.jsx(A.span,{id:d.textId,...c,ref:b}),d.isSelected&&u.valueNode&&!u.valueNodeHasChildren?it.createPortal(c.children,u.valueNode):null]})});Vt.displayName=me;var Ut="SelectItemIndicator",zt=n.forwardRef((t,a)=>{const{__scopeSelect:s,...o}=t;return Bt(Ut,s).isSelected?e.jsx(A.span,{"aria-hidden":!0,...o,ref:a}):null});zt.displayName=Ut;var Fe="SelectScrollUpButton",Wt=n.forwardRef((t,a)=>{const s=se(Fe,t.__scopeSelect),o=Ge(Fe,t.__scopeSelect),[r,c]=n.useState(!1),u=U(a,o.onScrollButtonChange);return K(()=>{if(s.viewport&&s.isPositioned){let i=function(){const p=d.scrollTop>0;c(p)};const d=s.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[s.viewport,s.isPositioned]),r?e.jsx(Kt,{...t,ref:u,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=s;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});Wt.displayName=Fe;var Ve="SelectScrollDownButton",$t=n.forwardRef((t,a)=>{const s=se(Ve,t.__scopeSelect),o=Ge(Ve,t.__scopeSelect),[r,c]=n.useState(!1),u=U(a,o.onScrollButtonChange);return K(()=>{if(s.viewport&&s.isPositioned){let i=function(){const p=d.scrollHeight-d.clientHeight,x=Math.ceil(d.scrollTop)<p;c(x)};const d=s.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[s.viewport,s.isPositioned]),r?e.jsx(Kt,{...t,ref:u,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=s;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});$t.displayName=Ve;var Kt=n.forwardRef((t,a)=>{const{__scopeSelect:s,onAutoScroll:o,...r}=t,c=se("SelectScrollButton",s),u=n.useRef(null),i=Ne(s),d=n.useCallback(()=>{u.current!==null&&(window.clearInterval(u.current),u.current=null)},[]);return n.useEffect(()=>()=>d(),[d]),K(()=>{var x;const p=i().find(w=>w.ref.current===document.activeElement);(x=p==null?void 0:p.ref.current)==null||x.scrollIntoView({block:"nearest"})},[i]),e.jsx(A.div,{"aria-hidden":!0,...r,ref:a,style:{flexShrink:0,...r.style},onPointerDown:P(r.onPointerDown,()=>{u.current===null&&(u.current=window.setInterval(o,50))}),onPointerMove:P(r.onPointerMove,()=>{var p;(p=c.onItemLeave)==null||p.call(c),u.current===null&&(u.current=window.setInterval(o,50))}),onPointerLeave:P(r.onPointerLeave,()=>{d()})})}),ka="SelectSeparator",qt=n.forwardRef((t,a)=>{const{__scopeSelect:s,...o}=t;return e.jsx(A.div,{"aria-hidden":!0,...o,ref:a})});qt.displayName=ka;var Ue="SelectArrow",Ia=n.forwardRef((t,a)=>{const{__scopeSelect:s,...o}=t,r=_e(s),c=te(Ue,s),u=se(Ue,s);return c.open&&u.position==="popper"?e.jsx(Qs,{...r,...o,ref:a}):null});Ia.displayName=Ue;var Ra="SelectBubbleInput",Gt=n.forwardRef(({__scopeSelect:t,value:a,...s},o)=>{const r=n.useRef(null),c=U(o,r),u=bt(a);return n.useEffect(()=>{const i=r.current;if(!i)return;const d=window.HTMLSelectElement.prototype,x=Object.getOwnPropertyDescriptor(d,"value").set;if(u!==a&&x){const w=new Event("change",{bubbles:!0});x.call(i,a),i.dispatchEvent(w)}},[u,a]),e.jsx(A.select,{...s,style:{...Xs,...s.style},ref:c,defaultValue:a})});Gt.displayName=Ra;function Yt(t){return t===""||t===void 0}function Qt(t){const a=gt(t),s=n.useRef(""),o=n.useRef(0),r=n.useCallback(u=>{const i=s.current+u;a(i),function d(p){s.current=p,window.clearTimeout(o.current),p!==""&&(o.current=window.setTimeout(()=>d(""),1e3))}(i)},[a]),c=n.useCallback(()=>{s.current="",window.clearTimeout(o.current)},[]);return n.useEffect(()=>()=>window.clearTimeout(o.current),[]),[s,r,c]}function Xt(t,a,s){const r=a.length>1&&Array.from(a).every(p=>p===a[0])?a[0]:a,c=s?t.indexOf(s):-1;let u=Ea(t,Math.max(c,0));r.length===1&&(u=u.filter(p=>p!==s));const d=u.find(p=>p.textValue.toLowerCase().startsWith(r.toLowerCase()));return d!==s?d:void 0}function Ea(t,a){return t.map((s,o)=>t[(a+o)%t.length])}var Pa=Nt,Zt=Ct,Aa=kt,Ma=It,Da=Rt,Jt=Et,La=Dt,es=Ht,ts=Ft,Oa=Vt,Ha=zt,ss=Wt,as=$t,ns=qt;const tt=Pa,st=Aa,ze=n.forwardRef(({className:t,children:a,...s},o)=>e.jsxs(Zt,{ref:o,className:C("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
51ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(Ma,{asChild:!0,children:e.jsx(yt,{className:"h-4 w-4 opacity-50"})})]}));ze.displayName=Zt.displayName;const os=n.forwardRef(({className:t,...a},s)=>e.jsx(ss,{ref:s,className:C("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(na,{className:"h-4 w-4"})}));os.displayName=ss.displayName;const rs=n.forwardRef(({className:t,...a},s)=>e.jsx(as,{ref:s,className:C("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(yt,{className:"h-4 w-4"})}));rs.displayName=as.displayName;const We=n.forwardRef(({className:t,children:a,position:s="popper",...o},r)=>e.jsx(Da,{children:e.jsxs(Jt,{ref:r,className:C("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...o,children:[e.jsx(os,{}),e.jsx(La,{className:C("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(rs,{})]})}));We.displayName=Jt.displayName;const Ba=n.forwardRef(({className:t,...a},s)=>e.jsx(es,{ref:s,className:C("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a}));Ba.displayName=es.displayName;const $e=n.forwardRef(({className:t,children:a,...s},o)=>e.jsxs(ts,{ref:o,className:C("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ha,{children:e.jsx(aa,{className:"h-4 w-4"})})}),e.jsx(Oa,{children:a})]}));$e.displayName=ts.displayName;const Fa=n.forwardRef(({className:t,...a},s)=>e.jsx(ns,{ref:s,className:C("-mx-1 my-1 h-px bg-muted",t),...a}));Fa.displayName=ns.displayName;var Ce="Switch",[Va,Pn]=Ke(Ce),[Ua,za]=Va(Ce),is=n.forwardRef((t,a)=>{const{__scopeSwitch:s,name:o,checked:r,defaultChecked:c,required:u,disabled:i,value:d="on",onCheckedChange:p,form:x,...w}=t,[b,N]=n.useState(null),S=U(a,m=>N(m)),h=n.useRef(!1),g=b?x||!!b.closest("form"):!0,[v,f]=De({prop:r,defaultProp:c??!1,onChange:p,caller:Ce});return e.jsxs(Ua,{scope:s,checked:v,disabled:i,children:[e.jsx(A.button,{type:"button",role:"switch","aria-checked":v,"aria-required":u,"data-state":us(v),"data-disabled":i?"":void 0,disabled:i,value:d,...w,ref:S,onClick:P(t.onClick,m=>{f(_=>!_),g&&(h.current=m.isPropagationStopped(),h.current||m.stopPropagation())})}),g&&e.jsx(ds,{control:b,bubbles:!h.current,name:o,value:d,checked:v,required:u,disabled:i,form:x,style:{transform:"translateX(-100%)"}})]})});is.displayName=Ce;var ls="SwitchThumb",cs=n.forwardRef((t,a)=>{const{__scopeSwitch:s,...o}=t,r=za(ls,s);return e.jsx(A.span,{"data-state":us(r.checked),"data-disabled":r.disabled?"":void 0,...o,ref:a})});cs.displayName=ls;var Wa="SwitchBubbleInput",ds=n.forwardRef(({__scopeSwitch:t,control:a,checked:s,bubbles:o=!0,...r},c)=>{const u=n.useRef(null),i=U(u,c),d=bt(s),p=ea(a);return n.useEffect(()=>{const x=u.current;if(!x)return;const w=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(w,"checked").set;if(d!==s&&N){const S=new Event("click",{bubbles:o});N.call(x,s),x.dispatchEvent(S)}},[d,s,o]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...r,tabIndex:-1,ref:i,style:{...r.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ds.displayName=Wa;function us(t){return t?"checked":"unchecked"}var ps=is,$a=cs;const ms=n.forwardRef(({className:t,...a},s)=>e.jsx(ps,{className:C("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input 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",t),...a,ref:s,children:e.jsx($a,{className:C("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}
51));ms.displayName=ps.displayName;const Ye=n.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:s,className:C("w-full caption-bottom text-sm",t),...a})}));Ye.displayName="Table";const Qe=n.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:C("[&_tr]:border-b",t),...a}));Qe.displayName="TableHeader";const Xe=n.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:C("[&_tr:last-child]:border-0",t),...a}));Xe.displayName="TableBody";const Ka=n.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:C("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...a}));Ka.displayName="TableFooter";const ce=n.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:C("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...a}));ce.displayName="TableRow";const $=n.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:C("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...a}));$.displayName="TableHead";const V=n.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:C("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...a}));V.displayName="TableCell";const qa=n.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:C("mt-4 text-sm text-muted-foreground",t),...a}));qa.displayName="TableCaption";const Ga=Es("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function at({className:t,variant:a,...s}){return e.jsx("div",{className:C(Ga({variant:a}),t),...s})}const Ya=t=>ks({queryKey:["team-member-hours",t],queryFn:async()=>{const{data:a,error:s}=await he.from("team_member_hours").select("*").eq("team_member_id",t).order("day_of_week",{ascending:!0});if(s)throw s;return a},enabled:!!t,staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnWindowFocus:!1}),Qa=()=>{const t=ot(),{toast:a}=xe();return rt({mutationFn:async s=>{const{data:o,error:r}=await he.from("team_member_hours").upsert(s,{onConflict:"team_member_id,day_of_week"}).select().single();if(r)throw r;return o},onSuccess:(s,o)=>{t.invalidateQueries({queryKey:["team-member-hours"]}),t.invalidateQueries({queryKey:["team-member-hours",o.team_member_id]})},onError:s=>{a({title:"Error saving hours",description:s.message,variant:"destructive"})}})},Xa=()=>{const t=ot(),{toast:a}=xe();return rt({mutationFn:async({teamMemberId:s,dayOfWeek:o})=>{const{error:r}=await he.from("team_member_hours").delete().eq("team_member_id",s).eq("day_of_week",o);if(r)throw r},onSuccess:(s,o)=>{t.invalidateQueries({queryKey:["team-member-hours"]}),t.invalidateQueries({queryKey:["team-member-hours",o.teamMemberId]})},onError:s=>{a({title:"Error deleting hours",description:s.message,variant:"destructive"})}})},Za=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Ja=({teamMemberId:t,teamMemberName:a})=>{const{data:s,isLoading:o}=Ya(t),r=Qa(),c=Xa(),{toast:u}=xe(),[i,d]=n.useState(!1),[p,x]=n.useState(null),[w,b]=n.useState("09:00"),[N,S]=n.useState("17:00"),h=m=>s==null?void 0:s.find(_=>_.day_of_week===m),g=m=>{const _=h(m);_?(b(_.start_time),S(_.end_time)):(b("09:00"),S("17:00")),x(m)},v=async()=>{p&&(await r.mutateAsync({team_member_id:t,day_of_week:p,start_time:w,end_time:N}),u({title:`Hours saved for ${p}`}),x(null))},f=async m=>{await c.mutateAsync({teamMemberId:t,dayOfWeek:m}),u({title:`Hours removed for ${m}`})};return e.jsxs(Le,{open:i,onOpenChange:d,children:[e.jsx(Oe,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",children:[e.jsx(ta,{className:"w-4 h-4 mr-1"}),"Hours"]})}),e.jsxs(ye,{className:"max-w-lg",children:[e.jsx(we,{children:e.jsxs(Se,{children:["Working Hours - ",a
51]})}),o?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(fe,{className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[p&&e.jsxs(ct,{className:"bg-muted/50",children:[e.jsx(dt,{className:"pb-2",children:e.jsxs(ut,{className:"text-sm",children:["Set hours for ",p]})}),e.jsxs(pt,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{className:"text-xs",children:"Start"}),e.jsx(G,{type:"time",value:w,onChange:m=>b(m.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{className:"text-xs",children:"End"}),e.jsx(G,{type:"time",value:N,onChange:m=>S(m.target.value)})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(E,{size:"sm",onClick:v,disabled:r.isPending,children:[r.isPending&&e.jsx(fe,{className:"w-3 h-3 animate-spin mr-1"}),"Save"]}),e.jsx(E,{size:"sm",variant:"outline",onClick:()=>x(null),children:"Cancel"})]})]})]}),e.jsxs(Ye,{children:[e.jsx(Qe,{children:e.jsxs(ce,{children:[e.jsx($,{children:"Day"}),e.jsx($,{children:"Start"}),e.jsx($,{children:"End"}),e.jsx($,{className:"text-right",children:"Actions"})]})}),e.jsx(Xe,{children:Za.map(m=>{const _=h(m);return e.jsxs(ce,{children:[e.jsx(V,{className:"font-medium",children:m}),e.jsx(V,{children:(_==null?void 0:_.start_time)||"â"}),e.jsx(V,{children:(_==null?void 0:_.end_time)||"â"}),e.jsxs(V,{className:"text-right",children:[e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>g(m),children:_?"Edit":"Add"}),_&&e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>f(m),disabled:c.isPending,children:e.jsx(wt,{className:"w-3 h-3 text-destructive"})})]})]},m)})})]})]})]})]})};var hs={exports:{}},fs={};/** 52 * @license React 53 * use-sync-external-store-shim.production.js 54 * 55 * Copyright (c) Meta Platforms, Inc. and affiliates. 56 * 57 * This source code is licensed under the MIT license found in the 58 * LICENSE file in the root directory of this source tree. 59 */var de=n;function en(t,a){return t===a&&(t!==0||1/t===1/a)||t!==t&&a!==a}var tn=typeof Object.is=="function"?Object.is:en,sn=de.useState,an=de.useEffect,nn=de.useLayoutEffect,on=de.useDebugValue;function rn(t,a){var s=a(),o=sn({inst:{value:s,getSnapshot:a}}),r=o[0].inst,c=o[1];return nn(function(){r.value=s,r.getSnapshot=a,Ae(r)&&c({inst:r})},[t,s,a]),an(function(){return Ae(r)&&c({inst:r}),t(function(){Ae(r)&&c({inst:r})})},[t]),on(s),s}function Ae(t){var a=t.getSnapshot;t=t.value;try{var s=a();return!tn(t,s)}catch{return!0}}function ln(t,a){return a()}var cn=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?ln:rn;fs.useSyncExternalStore=de.useSyncExternalStore!==void 0?de.useSyncExternalStore:cn;hs.exports=fs;var dn=hs.exports;function un(){return dn.useSyncExternalStore(pn,()=>!0,()=>!1)}function pn(){return()=>{}}var Ze="Avatar",[mn,An]=Ke(Ze),[hn,xs]=mn(Ze),gs=n.forwardRef((t,a)=>{const{__scopeAvatar:s,...o}=t,[r,c]=n.useState("idle");return e.jsx(hn,{scope:s,imageLoadingStatus:r,onImageLoadingStatusChange:c,children:e.jsx(A.span,{...o,ref:a})})});gs.displayName=Ze;var vs="AvatarImage",ys=n.forwardRef((t,a)=>{const{__scopeAvatar:s,src:o,onLoadingStatusChange:r=()=>{},...c}=t,u=xs(vs,s),i=fn(o,c),d=gt(p=>{r(p),u.onImageLoadingStatusChange(p)});return K(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(A.img,{...c,ref:a,src:o}):null});ys.displayName=vs;var ws="AvatarFallback",Ss=n.forwardRef((t,a)=>{const{__scopeAvatar:s,delayMs:o,...r}=t,c=xs(ws,s),[u,i]=n.useState(o===void 0);return n.useEffect(()=>{if(o!==void 0){const d=window.setTimeout(()=>i(!0),o);return()=>window.clearTimeout(d)}},[o]),u&&c.imageLoadingStatus!=="loaded"?e.jsx(A.span,{...r,ref:a}):null});Ss.displayName=ws;function nt(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function fn(t,{referrerPolicy:a,crossOrigin:s}){const o=un(),r=n.useRef(null),c=o?(r.current||(r.current=new window.Image),r.current):null,[u,i]=n.useState(()=>nt(c,t));return K(()=>{i(nt(c,t))},[c,t]),K(()=>{const d=w=>()=>{i(w)};if(!c)return;const p=d("loaded"),x=d("error");return c.addEventListener("load",p),c.addEventListener("error",x),a&&(c.referrerPolicy=a),typeof s=="string"&&(c.crossOrigin=s),()=>{c.removeEventListener("load",p),c.removeEventListener("error",x)}},[c,s,a]),u}var js=gs,bs=ys,Ns=Ss;const _s=n.forwardRef(({className:t,...a},s)=>e.jsx(js,{ref:s,className:C("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));_s.displayName=js.displayName;const Cs=n.forwardRef(({className:t,...a},s)=>e.jsx(bs,{ref:s,className:C("aspect-square h-full w-full",t),...a}));Cs.displayName=bs.displayName;const Ts=n.forwardRef(({className:t,...a},s)=>e.jsx(Ns,{ref:s,className:C("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));Ts.displayName=Ns.displayName;const xn={"pastel-aqua":"bg-[hsl(187_71%_82%)]","pastel-yellow":"bg-[hsl(54_100%_88%)]","pastel-blue":"bg-[hsl(207_71%_86%)]","pastel-green":"bg-[hsl(123_38%_85%)]","pastel-pink":"bg-[hsl(340_82%_86%)]"},gn=t=>t.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2),vn=t=>new Promise((a,s)=>{const o=new Image,r=document.createElement("canvas"),c=r.getContext("2d");o.onload=()=>
59{if(r.width=800,r.height=800,!c){s(new Error("Could not get canvas context"));return}const i=Math.min(o.width,o.height),d=(o.width-i)/2,p=(o.height-i)/2;c.drawImage(o,d,p,i,i,0,0,800,800),r.toBlob(x=>{x?a(x):s(new Error("Could not create blob"))},"image/jpeg",.8)},o.onerror=()=>s(new Error("Could not load image")),o.src=URL.createObjectURL(t)}),yn=({currentUrl:t,name:a,avatarColor:s,onUpload:o})=>{const[r,c]=n.useState(!1),u=n.useRef(null),{toast:i}=xe(),d=xn[s]||"bg-[hsl(187_71%_82%)]",p=async w=>{var N;const b=(N=w.target.files)==null?void 0:N[0];if(b){if(!b.type.startsWith("image/")){i({title:"Invalid file",description:"Please select an image file",variant:"destructive"});return}c(!0);try{const S=await vn(b),h=Date.now(),v=`${a.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}-${h}.jpg`,{data:f,error:m}=await he.storage.from("team-avatars").upload(v,S,{contentType:"image/jpeg",upsert:!1});if(m)throw m;const{data:_}=he.storage.from("team-avatars").getPublicUrl(f.path);o(_.publicUrl),i({title:"Photo uploaded successfully"})}catch(S){console.error("Upload error:",S),i({title:"Upload failed",description:S.message||"Could not upload photo",variant:"destructive"})}finally{c(!1),u.current&&(u.current.value="")}}},x=()=>{o(null)};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(_s,{className:`w-16 h-16 ${t?"":d}`,children:[t?e.jsx(Cs,{src:t,alt:a}):null,e.jsx(Ts,{className:d,children:gn(a||"TM")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:p,className:"hidden"}),e.jsx(E,{type:"button",variant:"outline",size:"sm",onClick:()=>{var w;return(w=u.current)==null?void 0:w.click()},disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Optimizing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(la,{className:"w-4 h-4 mr-2"}),"Upload Photo"]})}),t&&e.jsxs(E,{type:"button",variant:"ghost",size:"sm",onClick:x,className:"text-destructive hover:text-destructive",children:[e.jsx(lt,{className:"w-4 h-4 mr-2"}),"Remove"]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auto-optimized to 800Ã800 JPEG (recommended for fast loading)"})]})},wn=["pastel-aqua","pastel-yellow","pastel-blue","pastel-green","pastel-pink"],Sn=["Physiotherapy","Pilates","Exercise Physiology","Podiatry"],jn=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Me={name:"",role:"",department:"Physiotherapy",one_liner:"",bio:"",special_interests:[],working_days:[],working_hours_start:null,working_hours_end:null,avatar_color:"pastel-aqua",avatar_url:null,display_order:0,is_active:!0,on_leave:!1,leave_until:null},bn=({onSubmit:t})=>{const[a,s]=n.useState("");return e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"leave_until",children:"Return date"}),e.jsx(G,{id:"leave_until",type:"date",value:a,onChange:o=>s(o.target.value),min:new Date().toISOString().split("T")[0]})]}),e.jsx(E,{className:"w-full",disabled:!a,onClick:()=>t(a),children:"Confirm Leave"})]})},Mn=()=>{const{user:t,isAdmin:a,loading:s,adminLoading:o,signOut:r}=Ps(),c=Is(),{toast:u}=xe(),{data:i,isLoading:d}=As(),p=Ms(),x=Ds(),w=Ls(),[b,N]=n.useState(!1),[S,h]=n.useState(null),[g,v]=n.useState(Me),[f,m]=n.useState("");n.useEffect(()=>{!s&&!t&&c("/auth")},[t,s,c]),n.useEffect(()=>{!s&&!o&&t&&!a&&(u({title:"Access denied",description:"You need admin privileges to access this page.",variant:"destructive"}),c("/"))},[a,o,s,t,c,u]);const _=l=>{l?(h(l),v({name:l.name,role:l.role,department:l.department,one_liner:l.one_liner||"",bio:l.bio||"",special_interests:l.special_interests||[],working_days:l.working_days||[],working_hours_start:l.working_hours_start,working_hours_end:l.working_hours_end,avatar_color:l.avatar_color,avatar_url:l.avatar_url,display_order:l.display_order,is_active:l.is_active,on_leave:l.on_leave,leave_until:l.leave_until}),m((l.special_interests||[]).join(", "))):(h(null),v(Me),m("")),N(!0)},L=()=>{N(!1),h(null),v(Me),m("")},ae=async l=>{l.preventDefault();const j=f.split(",").map(z=>
59z.trim()).filter(Boolean),O={...g,special_interests:j};S?await x.mutateAsync({id:S.id,...O}):await p.mutateAsync(O),L()},M=async l=>{confirm("Are you sure you want to delete this team member?")&&await w.mutateAsync(l)},F=l=>{v(j=>({...j,working_days:j.working_days.includes(l)?j.working_days.filter(O=>O!==l):[...j.working_days,l]}))};return s||o||d?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(fe,{className:"w-8 h-8 animate-spin text-primary"})}):a?e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>c("/"),children:e.jsx(sa,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Admin Panel"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage team members"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t==null?void 0:t.email}),e.jsxs(E,{variant:"outline",size:"sm",onClick:r,children:[e.jsx(oa,{className:"w-4 h-4 mr-2"}),"Sign Out"]})]})]}),e.jsxs(ct,{children:[e.jsxs(dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(ut,{children:["Team Members (",(i==null?void 0:i.length)||0,")"]}),e.jsxs(Le,{open:b,onOpenChange:N,children:[e.jsx(Oe,{asChild:!0,children:e.jsxs(E,{onClick:()=>_(),children:[e.jsx(ia,{className:"w-4 h-4 mr-2"}),"Add Member"]})}),e.jsxs(ye,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(we,{children:e.jsxs(Se,{children:[S?"Edit":"Add"," Team Member"]})}),e.jsxs("form",{onSubmit:ae,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Profile Photo"}),e.jsx(yn,{currentUrl:g.avatar_url,name:g.name,avatarColor:g.avatar_color,onUpload:l=>v(j=>({...j,avatar_url:l}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"name",children:"Name *"}),e.jsx(G,{id:"name",value:g.name,onChange:l=>v(j=>({...j,name:l.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"role",children:"Role *"}),e.jsx(G,{id:"role",value:g.role,onChange:l=>v(j=>({...j,role:l.target.value})),required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Department *"}),e.jsxs(tt,{value:g.department,onValueChange:l=>v(j=>({...j,department:l})),children:[e.jsx(ze,{children:e.jsx(st,{})}),e.jsx(We,{children:Sn.map(l=>e.jsx($e,{value:l,children:l},l))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Avatar Color (fallback)"}),e.jsxs(tt,{value:g.avatar_color,onValueChange:l=>v(j=>({...j,avatar_color:l})),children:[e.jsx(ze,{children:e.jsx(st,{})}),e.jsx(We,{children:wn.map(l=>e.jsx($e,{value:l,children:l},l))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"one_liner",children:"One-liner"}),e.jsx(G,{id:"one_liner",value:g.one_liner||"",onChange:l=>v(j=>({...j,one_liner:l.target.value})),placeholder:"A short tagline..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"bio",children:"Bio"}),e.jsx(St,{id:"bio",value:g.bio||"",onChange:l=>v(j=>({...j,bio:l.target.value})),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"interests",children:"Special Interests (comma-separated)"}),e.jsx(G,{id:"interests",value:f,onChange:l=>m(l.target.value),placeholder:"Sports rehab, Manual therapy, Pilates..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{children:"Working Days"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:jn.map(l=>e.jsx(E,{type:"button",variant:g.working_days.includes(l)?"default":"outline",size:"sm",onClick:()=>F(l),children:l},l))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"working_hours_start",children:"Working Hours Start"}),e.jsx(G,{id:"working_hours_start",type:"time",value:g.working_hours_start||"",onChange:l=>v(j=>({...j,working_hours_start:l.target.value||null}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"working_hours_end",children:"Working Hours End"}),e.jsx(G,{id:"working_hours_end",type:"time",value:g.working_hours_end||"",onChange:l=>v(j=>({...j,working_hours_end:l.target.value||null}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"display_order",children:"Display Order"}),e.jsx(G,{id:"display_order",type:"number",value:g.display_order,onChange:l=>v(j=>({...j,display_order:parseInt(l.target.value)||0}))})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(ms,{id:"is_active",checked:g.is_active,onCheckedChange:l=>v(j=>({...j,is_active:l}))}),e.jsx(D,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(E,{type:"button",variant:"outline",onClick:L,children:"Cancel"}),e.jsxs(E,{type:"submit",disabled:p.isPending||x.isPending,children:[(p.isPending||x.isPending)&&e.jsx(fe,{className:"w-4 h-4 animate-spin mr-2"}),S?"Update":"Create"]})]})]})]})]})]}),e.jsx(pt,{children:e.jsxs(Ye,{children:[e.jsx(Qe,{children:e.jsxs(ce,{children:[e.jsx($,{children:"Name"}),e.jsx($,{children:"Department"}),e.jsx($,{children:"Status"}),e.jsx($,{children:"Leave"}),e.jsx($,{children:"Order"}),e.jsx($,{className:"text-right",children:"Actions"})]})}),e.jsxs(Xe,{children:[i==null?void 0:i.map(l=>e.jsxs(ce,{children:[e.jsx(V,{className:"font-medium",children:l.name}),e.jsx(V,{children:l.department}),e.jsx(V,{children:e.jsx(at,{variant:l.is_active?"default":"secondary",children:l.is_active?"Active":"Inactive"})}),e.jsx(V,{children:l.on_leave?e.jsxs("div",{className:"space-y-1",children:[e.jsxs(at,{variant:"outline",className:"bg-amber-500/10 text-amber-600 border-amber-500/30",children:[e.jsx(et,{className:"w-3 h-3 mr-1"}),"On Leave"]}),l.leave_until&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Until ",l.leave_until]}),e.jsx(E,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:()=>x.mutate({id:l.id,on_leave:!1,leave_until:null}),children:"End leave"})]}):e.jsxs(Le,{children:[e.jsx(Oe,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1",children:[e.jsx(et,{className:"w-3 h-3"}),"Set leave"]})}),e.jsxs(ye,{className:"max-w-sm",children:[e.jsx(we,{children:e.jsxs(Se,{children:["Set ",l.name," on leave"]})}),e.jsx(bn,{memberId:l.id,onSubmit:j=>{x.mutate({id:l.id,on_leave:!0,leave_until:j})}})]})]})}),e.jsx(V,{children:l.display_order}),e.jsxs(V,{className:"text-right space-x-1",children:[e.jsx(Ja,{teamMemberId:l.id,teamMemberName:l.name}),e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>_(l),children:e.jsx(ra,{className:"w-4 h-4"})}),e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>M(l.id),children:e.jsx(wt,{className:"w-4 h-4 text-destructive"})})]})]},l.id)),(!i||i.length===0)&&e.jsx(ce,{children:e.jsx(V,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No team members yet. Add your first one!"})})]})]})})]})]})}):null};export{Mn as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.