import{n as Pe,r as he,s as Te,t as pe,j as o,P as T,v as w,w as U,x as Ae,y as Oe,z as xe,A as we,D as Ut,E as Bt,F as ke,G as oe,H as Vt,J as zt,K as Ht,M as Yt,Q as Wt,U as qt,V as Xt,W as Qt,X as Zt,c as A,C as Jt,a as en,b as tn,d as Fe,u as Le,e as nn,k as on,B as Ie,T as rn,I as ue,L as Ee,l as Se,m as an}from"./index-DXI13nSQ.js";import{r as s}from"./react-Cb2sDjhD.js";import{D as sn}from"./data-table-BVcXWtPw.js";import{E as cn}from"./empty-state-WHzNYVaT.js";import{C as ln}from"./confirm-dialog-_BtUs6oW.js";import{C as un}from"./chevron-right-uDVVnuGu.js";import{u as dn}from"./useQuery-CEwGD94N.js";import{T as pn}from"./trash-2-CTkSvnZX.js";import{R as fn}from"./refresh-ccw-BPKXoMZa.js";import{S as mn}from"./search-DzexDAbr.js";import{M as hn}from"./map-pin-CRS6YW4i.js";import"./table-oUi0mGOn.js";import"./arrow-up-DtrvOH7Z.js";import"./arrow-down-OdSfpgG4.js";import"./dialog-BVYFRXlI.js";import"./x-OHUicFfn.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xn=Pe("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const wn=Pe("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);var de="rovingFocusGroup.onEntryFocus",gn={bubbles:!1,cancelable:!0},X="RovingFocusGroup",[fe,Ge,vn]=Te(X),[Mn,Ke]=he(X,[vn]),[Cn,bn]=Mn(X),$e=s.forwardRef((e,t)=>o.jsx(fe.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(fe.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(yn,{...e,ref:t})})}));$e.displayName=X;var yn=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:c,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:f,onEntryFocus:m,preventScrollOnEntryFocus:d=!1,...i}=e,x=s.useRef(null),M=U(t,x),g=Ae(c),[N,v]=Oe({prop:l,defaultProp:u??null,onChange:f,caller:X}),[C,P]=s.useState(!1),b=xe(m),I=Ge(n),O=s.useRef(!1),[p,_]=s.useState(0);return s.useEffect(()=>{const y=x.current;if(y)return y.addEventListener(de,b),()=>y.removeEventListener(de,b)},[b]),o.jsx(Cn,{scope:n,orientation:r,dir:g,loop:a,currentTabStopId:N,onItemFocus:s.useCallback(y=>v(y),[v]),onItemShiftTab:s.useCallback(()=>P(!0),[]),onFocusableItemAdd:s.useCallback(()=>_(y=>y+1),[]),onFocusableItemRemove:s.useCallback(()=>_(y=>y-1),[]),children:o.jsx(T.div,{tabIndex:C||p===0?-1:0,"data-orientation":r,...i,ref:M,style:{outline:"none",...e.style},onMouseDown:w(e.onMouseDown,()=>{O.current=!0}),onFocus:w(e.onFocus,y=>{const j=!O.current;if(y.target===y.currentTarget&&j&&!C){const k=new CustomEvent(de,gn);if(y.currentTarget.dispatchEvent(k),!k.defaultPrevented){const B=I().filter(D=>D.focusable),V=B.find(D=>D.active),J=B.find(D=>D.id===N),ce=[V,J,...B].filter(Boolean).map(D=>D.ref.current);Ve(ce,d)}}O.current=!1}),onBlur:w(e.onBlur,()=>P(!1))})})}),Ue="RovingFocusGroupItem",Be=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:c,children:l,...u}=e,f=pe(),m=c||f,d=bn(Ue,n),i=d.currentTabStopId===m,x=Ge(n),{onFocusableItemAdd:M,onFocusableItemRemove:g,currentTabStopId:N}=d;return s.useEffect(()=>{if(r)return M(),()=>g()},[r,M,g]),o.jsx(fe.ItemSlot,{scope:n,id:m,focusable:r,active:a,children:o.jsx(T.span,{tabIndex:i?0:-1,"data-orientation":d.orientation,...u,ref:t,onMouseDown:w(e.onMouseDown,v=>{r?d.onItemFocus(m):v.preventDefault()}),onFocus:w(e.onFocus,()=>d.onItemFocus(m)),onKeyDown:w(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const C=Nn(v,d.orientation,d.dir);if(C!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let b=x().filter(I=>I.focusable).map(I=>I.ref.current);if(C==="last")b.reverse();else if(C==="prev"||C==="next"){C==="prev"&&b.reverse();const I=b.indexOf(v.currentTarget);b=d.loop?In(b,I+1):b.slice(I+1)}setTimeout(()=>Ve(b))}}),children:typeof l=="function"?l({isCurrentTabStop:i,hasTabStop:N!=null}):l})})});Be.displayName=Ue;var _n={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Rn(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Nn(e,t,n){const r=Rn(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return _n[r]}function Ve(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function In(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var En=$e,Sn=Be;function jn(e){const t=Dn(e),n=s.forwardRef((r,a)=>{const{children:c,...l}=r,u=s.Children.toArray(c),f=u.find(Tn);if(f){const m=f.props.children,d=u.map(i=>i===f?s.Children.count(m)>1?s.Children.only(null):s.isValidElement(m)?m.props.children:null:i);return o.jsx(t,{...l,ref:a,children:s.isValidElement(m)?s.cloneElement(m,void 0,d):null})}return o.jsx(t,{...l,ref:a,children:c})});return n.displayName=`${e}.Slot`,n}function Dn(e){const t=s.forwardRef((n,r)=>{const{children:a,...c}=n;if(s.isValidElement(a)){const l=On(a),u=An(c,a.props);return a.type!==s.Fragment&&(u.ref=r?we(r,l):l),s.cloneElement(a,u)}return s.Children.count(a)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Pn=Symbol("radix.slottable");function Tn(e){return s.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Pn}function An(e,t){const n={...t};for(const r in t){const a=e[r],c=t[r];/^on[A-Z]/.test(r)?a&&c?n[r]=(...u)=>{const f=c(...u);return a(...u),f}:a&&(n[r]=a):r==="style"?n[r]={...a,...c}:r==="className"&&(n[r]=[a,c].filter(Boolean).join(" "))}return{...e,...n}}function On(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var me=["Enter"," "],kn=["ArrowDown","PageUp","Home"],ze=["ArrowUp","PageDown","End"],Fn=[...kn,...ze],Ln={ltr:[...me,"ArrowRight"],rtl:[...me,"ArrowLeft"]},Gn={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Q="Menu",[W,Kn,$n]=Te(Q),[L,He]=he(Q,[$n,ke,Ke]),re=ke(),Ye=Ke(),[Un,G]=L(Q),[Bn,Z]=L(Q),We=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:c,modal:l=!0}=e,u=re(t),[f,m]=s.useState(null),d=s.useRef(!1),i=xe(c),x=Ae(a);return s.useEffect(()=>{const M=()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>d.current=!1;return document.addEventListener("keydown",M,{capture:!0}),()=>{document.removeEventListener("keydown",M,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),o.jsx(Ut,{...u,children:o.jsx(Un,{scope:t,open:n,onOpenChange:i,content:f,onContentChange:m,children:o.jsx(Bn,{scope:t,onClose:s.useCallback(()=>i(!1),[i]),isUsingKeyboardRef:d,dir:x,modal:l,children:r})})})};We.displayName=Q;var Vn="MenuAnchor",ge=s.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=re(n);return o.jsx(Bt,{...a,...r,ref:t})});ge.displayName=Vn;var ve="MenuPortal",[zn,qe]=L(ve,{forceMount:void 0}),Xe=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,c=G(ve,t);return o.jsx(zn,{scope:t,forceMount:n,children:o.jsx(oe,{present:n||c.open,children:o.jsx(Vt,{asChild:!0,container:a,children:r})})})};Xe.displayName=ve;var S="MenuContent",[Hn,Me]=L(S),Qe=s.forwardRef((e,t)=>{const n=qe(S,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,c=G(S,e.__scopeMenu),l=Z(S,e.__scopeMenu);return o.jsx(W.Provider,{scope:e.__scopeMenu,children:o.jsx(oe,{present:r||c.open,children:o.jsx(W.Slot,{scope:e.__scopeMenu,children:l.modal?o.jsx(Yn,{...a,ref:t}):o.jsx(Wn,{...a,ref:t})})})})}),Yn=s.forwardRef((e,t)=>{const n=G(S,e.__scopeMenu),r=s.useRef(null),a=U(t,r);return s.useEffect(()=>{const c=r.current;if(c)return zt(c)},[]),o.jsx(Ce,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:w(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Wn=s.forwardRef((e,t)=>{const n=G(S,e.__scopeMenu);return o.jsx(Ce,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),qn=jn("MenuContent.ScrollLock"),Ce=s.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:c,onCloseAutoFocus:l,disableOutsidePointerEvents:u,onEntryFocus:f,onEscapeKeyDown:m,onPointerDownOutside:d,onFocusOutside:i,onInteractOutside:x,onDismiss:M,disableOutsideScroll:g,...N}=e,v=G(S,n),C=Z(S,n),P=re(n),b=Ye(n),I=Kn(n),[O,p]=s.useState(null),_=s.useRef(null),y=U(t,_,v.onContentChange),j=s.useRef(0),k=s.useRef(""),B=s.useRef(0),V=s.useRef(null),J=s.useRef("right"),ee=s.useRef(0),ce=g?Wt:s.Fragment,D=g?{as:qn,allowPinchZoom:!0}:void 0,$t=h=>{const $=k.current+h,F=I().filter(E=>!E.disabled),z=document.activeElement,ie=F.find(E=>E.ref.current===z)?.textValue,le=F.map(E=>E.textValue),Re=co(le,$,ie),H=F.find(E=>E.textValue===Re)?.ref.current;(function E(Ne){k.current=Ne,window.clearTimeout(j.current),Ne!==""&&(j.current=window.setTimeout(()=>E(""),1e3))})($),H&&setTimeout(()=>H.focus())};s.useEffect(()=>()=>window.clearTimeout(j.current),[]),Yt();const K=s.useCallback(h=>J.current===V.current?.side&&lo(h,V.current?.area),[]);return o.jsx(Hn,{scope:n,searchRef:k,onItemEnter:s.useCallback(h=>{K(h)&&h.preventDefault()},[K]),onItemLeave:s.useCallback(h=>{K(h)||(_.current?.focus(),p(null))},[K]),onTriggerLeave:s.useCallback(h=>{K(h)&&h.preventDefault()},[K]),pointerGraceTimerRef:B,onPointerGraceIntentChange:s.useCallback(h=>{V.current=h},[]),children:o.jsx(ce,{...D,children:o.jsx(qt,{asChild:!0,trapped:a,onMountAutoFocus:w(c,h=>{h.preventDefault(),_.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:o.jsx(Xt,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:m,onPointerDownOutside:d,onFocusOutside:i,onInteractOutside:x,onDismiss:M,children:o.jsx(En,{asChild:!0,...b,dir:C.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:p,onEntryFocus:w(f,h=>{C.isUsingKeyboardRef.current||h.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(Qt,{role:"menu","aria-orientation":"vertical","data-state":ft(v.open),"data-radix-menu-content":"",dir:C.dir,...P,...N,ref:y,style:{outline:"none",...N.style},onKeyDown:w(N.onKeyDown,h=>{const F=h.target.closest("[data-radix-menu-content]")===h.currentTarget,z=h.ctrlKey||h.altKey||h.metaKey,ie=h.key.length===1;F&&(h.key==="Tab"&&h.preventDefault(),!z&&ie&&$t(h.key));const le=_.current;if(h.target!==le||!Fn.includes(h.key))return;h.preventDefault();const H=I().filter(E=>!E.disabled).map(E=>E.ref.current);ze.includes(h.key)&&H.reverse(),ao(H)}),onBlur:w(e.onBlur,h=>{h.currentTarget.contains(h.target)||(window.clearTimeout(j.current),k.current="")}),onPointerMove:w(e.onPointerMove,q(h=>{const $=h.target,F=ee.current!==h.clientX;if(h.currentTarget.contains($)&&F){const z=h.clientX>ee.current?"right":"left";J.current=z,ee.current=h.clientX}}))})})})})})})});Qe.displayName=S;var Xn="MenuGroup",be=s.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(T.div,{role:"group",...r,ref:t})});be.displayName=Xn;var Qn="MenuLabel",Ze=s.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(T.div,{...r,ref:t})});Ze.displayName=Qn;var te="MenuItem",je="menu.itemSelect",ae=s.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,c=s.useRef(null),l=Z(te,e.__scopeMenu),u=Me(te,e.__scopeMenu),f=U(t,c),m=s.useRef(!1),d=()=>{const i=c.current;if(!n&&i){const x=new CustomEvent(je,{bubbles:!0,cancelable:!0});i.addEventListener(je,M=>r?.(M),{once:!0}),Ht(i,x),x.defaultPrevented?m.current=!1:l.onClose()}};return o.jsx(Je,{...a,ref:f,disabled:n,onClick:w(e.onClick,d),onPointerDown:i=>{e.onPointerDown?.(i),m.current=!0},onPointerUp:w(e.onPointerUp,i=>{m.current||i.currentTarget?.click()}),onKeyDown:w(e.onKeyDown,i=>{const x=u.searchRef.current!=="";n||x&&i.key===" "||me.includes(i.key)&&(i.currentTarget.click(),i.preventDefault())})})});ae.displayName=te;var Je=s.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...c}=e,l=Me(te,n),u=Ye(n),f=s.useRef(null),m=U(t,f),[d,i]=s.useState(!1),[x,M]=s.useState("");return s.useEffect(()=>{const g=f.current;g&&M((g.textContent??"").trim())},[c.children]),o.jsx(W.ItemSlot,{scope:n,disabled:r,textValue:a??x,children:o.jsx(Sn,{asChild:!0,...u,focusable:!r,children:o.jsx(T.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...c,ref:m,onPointerMove:w(e.onPointerMove,q(g=>{r?l.onItemLeave(g):(l.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:w(e.onPointerLeave,q(g=>l.onItemLeave(g))),onFocus:w(e.onFocus,()=>i(!0)),onBlur:w(e.onBlur,()=>i(!1))})})})}),Zn="MenuCheckboxItem",et=s.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return o.jsx(at,{scope:e.__scopeMenu,checked:n,children:o.jsx(ae,{role:"menuitemcheckbox","aria-checked":ne(n)?"mixed":n,...a,ref:t,"data-state":_e(n),onSelect:w(a.onSelect,()=>r?.(ne(n)?!0:!n),{checkForDefaultPrevented:!1})})})});et.displayName=Zn;var tt="MenuRadioGroup",[Jn,eo]=L(tt,{value:void 0,onValueChange:()=>{}}),nt=s.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,c=xe(r);return o.jsx(Jn,{scope:e.__scopeMenu,value:n,onValueChange:c,children:o.jsx(be,{...a,ref:t})})});nt.displayName=tt;var ot="MenuRadioItem",rt=s.forwardRef((e,t)=>{const{value:n,...r}=e,a=eo(ot,e.__scopeMenu),c=n===a.value;return o.jsx(at,{scope:e.__scopeMenu,checked:c,children:o.jsx(ae,{role:"menuitemradio","aria-checked":c,...r,ref:t,"data-state":_e(c),onSelect:w(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});rt.displayName=ot;var ye="MenuItemIndicator",[at,to]=L(ye,{checked:!1}),st=s.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,c=to(ye,n);return o.jsx(oe,{present:r||ne(c.checked)||c.checked===!0,children:o.jsx(T.span,{...a,ref:t,"data-state":_e(c.checked)})})});st.displayName=ye;var no="MenuSeparator",ct=s.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(T.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ct.displayName=no;var oo="MenuArrow",it=s.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=re(n);return o.jsx(Zt,{...a,...r,ref:t})});it.displayName=oo;var ro="MenuSub",[Cr,lt]=L(ro),Y="MenuSubTrigger",ut=s.forwardRef((e,t)=>{const n=G(Y,e.__scopeMenu),r=Z(Y,e.__scopeMenu),a=lt(Y,e.__scopeMenu),c=Me(Y,e.__scopeMenu),l=s.useRef(null),{pointerGraceTimerRef:u,onPointerGraceIntentChange:f}=c,m={__scopeMenu:e.__scopeMenu},d=s.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return s.useEffect(()=>d,[d]),s.useEffect(()=>{const i=u.current;return()=>{window.clearTimeout(i),f(null)}},[u,f]),o.jsx(ge,{asChild:!0,...m,children:o.jsx(Je,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":ft(n.open),...e,ref:we(t,a.onTriggerChange),onClick:i=>{e.onClick?.(i),!(e.disabled||i.defaultPrevented)&&(i.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:w(e.onPointerMove,q(i=>{c.onItemEnter(i),!i.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(c.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:w(e.onPointerLeave,q(i=>{d();const x=n.content?.getBoundingClientRect();if(x){const M=n.content?.dataset.side,g=M==="right",N=g?-5:5,v=x[g?"left":"right"],C=x[g?"right":"left"];c.onPointerGraceIntentChange({area:[{x:i.clientX+N,y:i.clientY},{x:v,y:x.top},{x:C,y:x.top},{x:C,y:x.bottom},{x:v,y:x.bottom}],side:M}),window.clearTimeout(u.current),u.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(i),i.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:w(e.onKeyDown,i=>{const x=c.searchRef.current!=="";e.disabled||x&&i.key===" "||Ln[r.dir].includes(i.key)&&(n.onOpenChange(!0),n.content?.focus(),i.preventDefault())})})})});ut.displayName=Y;var dt="MenuSubContent",pt=s.forwardRef((e,t)=>{const n=qe(S,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,c=G(S,e.__scopeMenu),l=Z(S,e.__scopeMenu),u=lt(dt,e.__scopeMenu),f=s.useRef(null),m=U(t,f);return o.jsx(W.Provider,{scope:e.__scopeMenu,children:o.jsx(oe,{present:r||c.open,children:o.jsx(W.Slot,{scope:e.__scopeMenu,children:o.jsx(Ce,{id:u.contentId,"aria-labelledby":u.triggerId,...a,ref:m,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{l.isUsingKeyboardRef.current&&f.current?.focus(),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:w(e.onFocusOutside,d=>{d.target!==u.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:w(e.onEscapeKeyDown,d=>{l.onClose(),d.preventDefault()}),onKeyDown:w(e.onKeyDown,d=>{const i=d.currentTarget.contains(d.target),x=Gn[l.dir].includes(d.key);i&&x&&(c.onOpenChange(!1),u.trigger?.focus(),d.preventDefault())})})})})})});pt.displayName=dt;function ft(e){return e?"open":"closed"}function ne(e){return e==="indeterminate"}function _e(e){return ne(e)?"indeterminate":e?"checked":"unchecked"}function ao(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function so(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function co(e,t,n){const a=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,c=n?e.indexOf(n):-1;let l=so(e,Math.max(c,0));a.length===1&&(l=l.filter(m=>m!==n));const f=l.find(m=>m.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function io(e,t){const{x:n,y:r}=e;let a=!1;for(let c=0,l=t.length-1;c<t.length;l=c++){const u=t[c],f=t[l],m=u.x,d=u.y,i=f.x,x=f.y;d>r!=x>r&&n<(i-m)*(r-d)/(x-d)+m&&(a=!a)}return a}function lo(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return io(n,t)}function q(e){return t=>t.pointerType==="mouse"?e(t):void 0}var uo=We,po=ge,fo=Xe,mo=Qe,ho=be,xo=Ze,wo=ae,go=et,vo=nt,Mo=rt,Co=st,bo=ct,yo=it,_o=ut,Ro=pt,se="DropdownMenu",[No]=he(se,[He]),R=He(),[Io,mt]=No(se),ht=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:c,onOpenChange:l,modal:u=!0}=e,f=R(t),m=s.useRef(null),[d,i]=Oe({prop:a,defaultProp:c??!1,onChange:l,caller:se});return o.jsx(Io,{scope:t,triggerId:pe(),triggerRef:m,contentId:pe(),open:d,onOpenChange:i,onOpenToggle:s.useCallback(()=>i(x=>!x),[i]),modal:u,children:o.jsx(uo,{...f,open:d,onOpenChange:i,dir:r,modal:u,children:n})})};ht.displayName=se;var xt="DropdownMenuTrigger",wt=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,c=mt(xt,n),l=R(n);return o.jsx(po,{asChild:!0,...l,children:o.jsx(T.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:we(t,c.triggerRef),onPointerDown:w(e.onPointerDown,u=>{!r&&u.button===0&&u.ctrlKey===!1&&(c.onOpenToggle(),c.open||u.preventDefault())}),onKeyDown:w(e.onKeyDown,u=>{r||(["Enter"," "].includes(u.key)&&c.onOpenToggle(),u.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});wt.displayName=xt;var Eo="DropdownMenuPortal",gt=e=>{const{__scopeDropdownMenu:t,...n}=e,r=R(t);return o.jsx(fo,{...r,...n})};gt.displayName=Eo;var vt="DropdownMenuContent",Mt=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=mt(vt,n),c=R(n),l=s.useRef(!1);return o.jsx(mo,{id:a.contentId,"aria-labelledby":a.triggerId,...c,...r,ref:t,onCloseAutoFocus:w(e.onCloseAutoFocus,u=>{l.current||a.triggerRef.current?.focus(),l.current=!1,u.preventDefault()}),onInteractOutside:w(e.onInteractOutside,u=>{const f=u.detail.originalEvent,m=f.button===0&&f.ctrlKey===!0,d=f.button===2||m;(!a.modal||d)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Mt.displayName=vt;var So="DropdownMenuGroup",jo=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(ho,{...a,...r,ref:t})});jo.displayName=So;var Do="DropdownMenuLabel",Ct=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(xo,{...a,...r,ref:t})});Ct.displayName=Do;var Po="DropdownMenuItem",bt=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(wo,{...a,...r,ref:t})});bt.displayName=Po;var To="DropdownMenuCheckboxItem",yt=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(go,{...a,...r,ref:t})});yt.displayName=To;var Ao="DropdownMenuRadioGroup",Oo=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(vo,{...a,...r,ref:t})});Oo.displayName=Ao;var ko="DropdownMenuRadioItem",_t=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(Mo,{...a,...r,ref:t})});_t.displayName=ko;var Fo="DropdownMenuItemIndicator",Rt=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(Co,{...a,...r,ref:t})});Rt.displayName=Fo;var Lo="DropdownMenuSeparator",Nt=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(bo,{...a,...r,ref:t})});Nt.displayName=Lo;var Go="DropdownMenuArrow",Ko=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(yo,{...a,...r,ref:t})});Ko.displayName=Go;var $o="DropdownMenuSubTrigger",It=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(_o,{...a,...r,ref:t})});It.displayName=$o;var Uo="DropdownMenuSubContent",Et=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=R(n);return o.jsx(Ro,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Et.displayName=Uo;var Bo=ht,Vo=wt,zo=gt,St=Mt,jt=Ct,Dt=bt,Pt=yt,Tt=_t,At=Rt,Ot=Nt,kt=It,Ft=Et;const Ho=Bo,Yo=Vo,Wo=s.forwardRef(({className:e,inset:t,children:n,...r},a)=>o.jsxs(kt,{ref:a,className:A("flex cursor-default select-none items-center gap-2 rounded px-2 py-1.5 text-sm outline-none","focus:bg-surface-hover data-[state=open]:bg-surface-hover",t&&"pl-8",e),...r,children:[n,o.jsx(un,{className:"ml-auto h-4 w-4"})]}));Wo.displayName=kt.displayName;const qo=s.forwardRef(({className:e,...t},n)=>o.jsx(Ft,{ref:n,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-surface p-1 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",e),...t}));qo.displayName=Ft.displayName;const Lt=s.forwardRef(({className:e,sideOffset:t=4,...n},r)=>o.jsx(zo,{children:o.jsx(St,{ref:r,sideOffset:t,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-surface p-1 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",e),...n})}));Lt.displayName=St.displayName;const Gt=s.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Dt,{ref:r,className:A("relative flex cursor-default select-none items-center gap-2 rounded px-2 py-1.5 text-sm outline-none","focus:bg-surface-hover focus:text-text","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Gt.displayName=Dt.displayName;const Xo=s.forwardRef(({className:e,children:t,checked:n,...r},a)=>o.jsxs(Pt,{ref:a,className:A("relative flex cursor-default select-none items-center rounded py-1.5 pl-8 pr-2 text-sm outline-none","focus:bg-surface-hover","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(At,{children:o.jsx(Jt,{className:"h-4 w-4"})})}),t]}));Xo.displayName=Pt.displayName;const Qo=s.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Tt,{ref:r,className:A("relative flex cursor-default select-none items-center rounded py-1.5 pl-8 pr-2 text-sm outline-none","focus:bg-surface-hover","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(At,{children:o.jsx(xn,{className:"h-2 w-2 fill-current"})})}),t]}));Qo.displayName=Tt.displayName;const Zo=s.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(jt,{ref:r,className:A("px-2 py-1.5 text-xs font-semibold uppercase tracking-wide text-text-muted",t&&"pl-8",e),...n}));Zo.displayName=jt.displayName;const Jo=s.forwardRef(({className:e,...t},n)=>o.jsx(Ot,{ref:n,className:A("-mx-1 my-1 h-px bg-border",e),...t}));Jo.displayName=Ot.displayName;const Kt={all:["memos"],list:e=>["memos","list",e]};function er(e){return dn({queryKey:Kt.list(e),queryFn:()=>Fe.listMemos(e)})}function tr(){const e=en();return tn({mutationFn:t=>Fe.deleteMemo(t),onSuccess:()=>e.invalidateQueries({queryKey:Kt.all})})}const nr=300;function br(){const{t:e}=Le(["memos","common"]),[t,n]=nn(),r=t.get("q")??"",a=t.get("who")??"",c=t.get("what")??"",l=t.get("has_location")==="1",u=t.get("include_expired")==="1",[f,m]=s.useState(r);s.useEffect(()=>{if(f===r)return;const p=window.setTimeout(()=>{b({q:f||null})},nr);return()=>window.clearTimeout(p)},[f]);const d=s.useMemo(()=>({...r?{query:r}:{},...a?{who:a}:{},...c?{what:c}:{},...l?{has_location:!0}:{},...u?{include_expired:!0}:{},limit:200}),[r,a,c,l,u]),{data:i,isLoading:x,isFetching:M,refetch:g}=er(d),N=i?.memos??[],v=tr(),[C,P]=s.useState(null);function b(p){const _=new URLSearchParams(t);for(const[y,j]of Object.entries(p))j==null||j===""?_.delete(y):_.set(y,j);n(_,{replace:!0})}async function I(){if(C!=null)try{await v.mutateAsync(C),Se.success(e("toast.deleted"))}catch(p){const{message:_}=an(p,e);throw Se.error(_),p}}const O=s.useMemo(()=>[{id:"id",header:e("col.id"),cell:p=>o.jsxs("span",{className:"tabular-nums text-text-dim",children:["#",p.id]}),headClassName:"w-16"},{id:"what",header:e("col.what"),cell:p=>o.jsx("span",{className:"line-clamp-2",children:p.memo?o.jsx("span",{className:"text-text",children:p.memo}):o.jsx("span",{className:"font-medium text-text",children:p.what})}),asCardTitle:!0},{id:"who",header:e("col.who"),cell:p=>p.who?o.jsx(on,{variant:"secondary",children:p.who}):o.jsx("span",{className:"text-text-muted",children:"—"}),headClassName:"w-32"},{id:"when",header:e("col.when"),cell:p=>o.jsx("span",{className:"text-text-dim",children:p.whenText||(p.whenAt?De(p.whenAt):"—")}),headClassName:"w-36"},{id:"where",header:e("col.where"),cell:p=>p.where_label||p.where_lat!=null&&p.where_lng!=null?o.jsx(rr,{memo:p}):o.jsx("span",{className:"text-text-muted",children:"—"}),headClassName:"w-44"},{id:"platform",header:e("col.platform"),cell:p=>o.jsx("span",{className:"text-text-dim",children:p.platform}),headClassName:"w-24",hideOnMobile:!0},{id:"createdAt",header:e("col.createdAt"),cell:p=>o.jsx("span",{className:"text-text-dim",children:De(p.createdAt)}),headClassName:"w-36",hideOnMobile:!0},{id:"actions",header:"",cell:p=>o.jsx("div",{className:"flex justify-end",children:o.jsxs(Ie,{variant:"ghost",size:"sm",onClick:_=>{_.stopPropagation(),P(p.id)},disabled:v.isPending,"aria-label":e("action.delete"),children:[o.jsx(pn,{className:"h-3 w-3"}),o.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:e("action.delete")})]})}),headClassName:"w-24"}],[e,v.isPending]);return o.jsxs("div",{className:"flex min-h-dvh flex-col bg-bg",children:[o.jsx(rn,{}),o.jsxs("main",{className:"mx-auto flex w-full max-w-7xl flex-1 flex-col gap-4 px-3 py-4 sm:px-4 pb-safe",children:[o.jsxs("header",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx("h1",{className:"text-xl font-semibold",children:e("pageTitle")}),o.jsxs(Ie,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>g(),disabled:M,"aria-label":e("actions.refresh",{ns:"common"}),children:[o.jsx(fn,{className:`h-4 w-4 ${M?"animate-spin":""}`}),o.jsx("span",{className:"hidden sm:inline",children:e("actions.refresh",{ns:"common"})})]})]}),o.jsx("p",{className:"text-sm text-text-dim",children:e("subtitle")})]}),o.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[o.jsxs("div",{className:"relative flex-1 max-w-md",children:[o.jsx(mn,{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-text-muted"}),o.jsx(ue,{value:f,onChange:p=>m(p.target.value),placeholder:e("search.placeholder"),className:"pl-7"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:items-end",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ee,{htmlFor:"who-filter",className:"text-xs text-text-dim",children:e("search.who")}),o.jsx(ue,{id:"who-filter",value:a,onChange:p=>b({who:p.target.value||null}),className:"w-36"})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ee,{htmlFor:"what-filter",className:"text-xs text-text-dim",children:e("search.what")}),o.jsx(ue,{id:"what-filter",value:c,onChange:p=>b({what:p.target.value||null}),className:"w-36"})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("label",{className:"inline-flex items-center gap-1 text-sm text-text-dim",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:p=>b({has_location:p.target.checked?"1":null}),className:"h-4 w-4 accent-accent"}),e("search.hasLocation")]}),o.jsxs("label",{className:"inline-flex items-center gap-1 text-sm text-text-dim",children:[o.jsx("input",{type:"checkbox",checked:u,onChange:p=>b({include_expired:p.target.checked?"1":null}),className:"h-4 w-4 accent-accent"}),e("search.includeExpired")]})]})]}),o.jsx(sn,{columns:O,rows:N,getRowId:p=>String(p.id),loading:x,emptyState:o.jsx(cn,{icon:o.jsx(wn,{}),title:e("empty.title"),description:e("empty.description")})}),o.jsx(ln,{open:C!=null,onOpenChange:p=>{p||P(null)},title:e("action.confirmDelete"),description:e("action.confirmDeleteDesc"),intent:"danger",confirmLabel:e("action.delete"),onConfirm:I})]})]})}const or={baidu:"openMap.baidu",apple:"openMap.apple",google:"openMap.google",osm:"openMap.osm"};function rr({memo:e}){const{t}=Le("memos"),n=e.where_label||`${e.where_lat}, ${e.where_lng}`,r=Object.entries(e.mapUrls??{});return r.length===0?o.jsx("span",{className:"text-text-dim",children:n}):o.jsxs(Ho,{children:[o.jsx(Yo,{asChild:!0,children:o.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 text-sm text-text-dim hover:text-accent",onClick:a=>a.stopPropagation(),children:[o.jsx(hn,{className:"h-3 w-3"}),o.jsx("span",{className:"line-clamp-1 underline-offset-2 hover:underline",children:n})]})}),o.jsx(Lt,{children:r.map(([a,c])=>o.jsx(Gt,{asChild:!0,children:o.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:t(or[a]??"openMap.label",{defaultValue:a})})},a))})]})}function De(e){try{const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}export{br as default};
//# sourceMappingURL=memos-C6i1hbv9.js.map
