import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t,t as n}from"./jsx-runtime-CiQ1k8xo.js";import{c as r,d as i,i as a,n as o,o as s,t as c,u as l}from"./dist-B8SKCozm.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./Combination-9DfZp13g.js";import{a as _,i as v,n as y,r as b,t as x}from"./dist-DXUvl421.js";var S=e(t(),1),C=n(),w=`Popover`,[T,ee]=r(w,[_]),E=_(),[D,O]=T(w),k=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=E(t),l=S.useRef(null),[u,f]=S.useState(!1),[p,m]=c({prop:r,defaultProp:i??!1,onChange:a,caller:w});return(0,C.jsx)(v,{...s,children:(0,C.jsx)(D,{scope:t,contentId:d(),triggerRef:l,open:p,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>f(!0),[]),onCustomAnchorRemove:S.useCallback(()=>f(!1),[]),modal:o,children:n})})};k.displayName=w;var A=`PopoverAnchor`,j=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(A,n),a=E(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return S.useEffect(()=>(o(),()=>s()),[o,s]),(0,C.jsx)(x,{...a,...r,ref:t})});j.displayName=A;var M=`PopoverTrigger`,N=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,o=O(M,n),s=E(n),c=l(t,o.triggerRef),u=(0,C.jsx)(a.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":o.open,"aria-controls":o.contentId,"data-state":J(o.open),...r,ref:c,onClick:i(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?u:(0,C.jsx)(x,{asChild:!0,...s,children:u})});N.displayName=M;var P=`PopoverPortal`,[F,I]=T(P,{forceMount:void 0}),L=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=O(P,t);return(0,C.jsx)(F,{scope:t,forceMount:n,children:(0,C.jsx)(o,{present:n||a.open,children:(0,C.jsx)(m,{asChild:!0,container:i,children:r})})})};L.displayName=P;var R=`PopoverContent`,z=S.forwardRef((e,t)=>{let n=I(R,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=O(R,e.__scopePopover);return(0,C.jsx)(o,{present:r||a.open,children:a.modal?(0,C.jsx)(V,{...i,ref:t}):(0,C.jsx)(H,{...i,ref:t})})});z.displayName=R;var B=s(`PopoverContent.RemoveScroll`),V=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(null),a=l(t,r),o=S.useRef(!1);return S.useEffect(()=>{let e=r.current;if(e)return f(e)},[]),(0,C.jsx)(g,{as:B,allowPinchZoom:!0,children:(0,C.jsx)(U,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:i(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:i(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;o.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:i(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),H=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(!1),i=S.useRef(!1);return(0,C.jsx)(U,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),U=S.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:d,...f}=e,m=O(R,n),g=E(n);return p(),(0,C.jsx)(u,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,C.jsx)(h,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>m.onOpenChange(!1),children:(0,C.jsx)(b,{"data-state":J(m.open),role:`dialog`,id:m.contentId,...g,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),W=`PopoverClose`,G=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,o=O(W,n);return(0,C.jsx)(a.button,{type:`button`,...r,ref:t,onClick:i(e.onClick,()=>o.onOpenChange(!1))})});G.displayName=W;var K=`PopoverArrow`,q=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=E(n);return(0,C.jsx)(y,{...i,...r,ref:t})});q.displayName=K;function J(e){return e?`open`:`closed`}var Y=k,X=N,Z=L,Q=z,$=G;export{X as a,Y as i,Q as n,Z as r,$ as t};
//# sourceMappingURL=dist-DBoRrpWS.js.map