import{C as e,D as t,G as n,J as r,M as i,P as a,Q as o,V as s,W as c,Y as l,a as u,b as d,et as f,ft as p,it as m,j as ee,k as te,l as h,n as g,ot as _,q as v,r as y,st as b,t as x,w as S}from"../../client.js";import{t as C}from"../../custom-element-forward-events.js";import{w}from"../../components.js";import T from"../iconbutton/IconButton.js";var ne=a(`<h3 class="mc-listbox__title svelte-cf5eub"> </h3>`),E=a(`<div><!></div>`),D=a(`<div><div><div class="mc-listbox__header svelte-cf5eub"><!> <span class="mc-listbox__close svelte-cf5eub"><!></span></div> <div class="mc-listbox__body svelte-cf5eub"><ul class="mc-action-list svelte-cf5eub" role="menu"><!></ul></div></div></div> <!>`,1),O={hash:`svelte-cf5eub`,code:`/**
 * Do not edit directly, this file was auto-generated.
 */.mc-listbox.svelte-cf5eub:has(.mc-listbox__content:where(.svelte-cf5eub):not([popover])), .mc-listbox.svelte-cf5eub:has(.mc-listbox__content:where(.svelte-cf5eub):popover-open) {position:fixed;inset:0;display:flex;align-items:flex-end;justify-content:center;z-index:1;padding:0.5rem;background-color:var(--overlay-color-background, rgba(0, 0, 0, 0.5));inset:0;opacity:0;position:fixed;pointer-events:none;transition:opacity 0.4s ease, visibility 0ms 0.4s;z-index:var(--overlay-z-index, 4);}.mc-listbox:has(.mc-listbox__content:where(.svelte-cf5eub):not([popover])).is-visible.svelte-cf5eub, .mc-listbox:has(.mc-listbox__content:where(.svelte-cf5eub):popover-open).is-visible.svelte-cf5eub {opacity:1;pointer-events:all;transition:opacity 0.4s ease, visibility 0ms;visibility:visible;}.mc-listbox.svelte-cf5eub:has(.mc-listbox__content:where(.svelte-cf5eub):not([popover])), .mc-listbox.svelte-cf5eub:has(.mc-listbox__content:where(.svelte-cf5eub):popover-open) {opacity:1;}
@media (width >= 680px) {.mc-listbox.svelte-cf5eub:has(.mc-listbox__content:where(.svelte-cf5eub):not([popover])), .mc-listbox.svelte-cf5eub:has(.mc-listbox__content:where(.svelte-cf5eub):popover-open) {position:relative;display:block;padding:0;background-color:transparent;}
}.mc-listbox__content.svelte-cf5eub {border:var(--border-width-s, 0.0625rem) solid var(--color-border-primary, #cccccc);border-radius:var(--border-radius-m, 0.5rem);width:100%;z-index:10;background-color:var(--color-background-primary, #ffffff);pointer-events:all;}
@media (width >= 680px) {.mc-listbox__content.svelte-cf5eub {min-width:18.75rem;}
}.mc-listbox__header.svelte-cf5eub {display:flex;align-items:center;justify-content:center;position:relative;height:4rem;}
@media (width >= 680px) {.mc-listbox__header.svelte-cf5eub {display:none;}
}.mc-listbox__title.svelte-cf5eub {line-height:var(--line-height-s, 1.3);font-weight:var(--font-weight-semi-bold, 600);font-size:var(--font-size-100, 0.875rem);color:var(--color-text-tertiary, #666666);text-align:center;margin:0;}.mc-listbox__close.svelte-cf5eub {position:absolute;right:1.25rem;width:1.5rem;height:1.5rem;}.mc-listbox__body.svelte-cf5eub {overflow:hidden;}
@media (width >= 680px) {.mc-listbox--top.svelte-cf5eub .mc-listbox__content:where(.svelte-cf5eub) {margin:0 0 8px;inset:auto;position-area:span-right top;}.mc-listbox--bottom.svelte-cf5eub .mc-listbox__content:where(.svelte-cf5eub) {margin:8px 0 0;inset:auto;position-area:span-right bottom;}.mc-listbox--left.svelte-cf5eub .mc-listbox__content:where(.svelte-cf5eub) {margin:0 8px 0 0;inset:auto;position-area:span-bottom left;}.mc-listbox--right.svelte-cf5eub .mc-listbox__content:where(.svelte-cf5eub) {margin:0 0 0 8px;inset:auto;position-area:span-bottom right;}
}.mc-action-list.svelte-cf5eub {padding:0.5rem 0.5rem;margin:0;}.mc-action-list__element.svelte-cf5eub {height:2.5rem;cursor:pointer;border-radius:var(--border-radius-s, 0.25rem);flex-grow:1;}.mc-action-list__element.svelte-cf5eub:hover {background-color:var(--action-listbox-color-background-hover, rgba(0, 0, 0, 0.05));}.mc-action-list__element--danger.svelte-cf5eub .mc-action-list__text:where(.svelte-cf5eub) {color:var(--action-listbox-color-text-danger, #c61112);}.mc-action-list__element--danger.svelte-cf5eub .mc-action-list__icon:where(.svelte-cf5eub) {fill:var(--action-listbox-color-text-danger, #c61112);}.mc-action-list__element--danger.svelte-cf5eub:hover {background-color:var(--action-listbox-color-background-danger-hover, rgba(198, 17, 18, 0.1));}.mc-action-list__element--disabled.svelte-cf5eub .mc-action-list__text:where(.svelte-cf5eub) {color:var(--action-listbox-color-text-disabled, #b3b3b3);}.mc-action-list__element--disabled.svelte-cf5eub .mc-action-list__icon:where(.svelte-cf5eub) {fill:var(--action-listbox-color-text-disabled, #b3b3b3);}.mc-action-list__element--disabled.svelte-cf5eub:hover {background-color:transparent;}.mc-action-list__button.svelte-cf5eub {background-color:transparent;color:var(--action-listbox-color-text-default, #000000);border:none;display:flex;align-items:center;gap:0.25rem;padding:0;padding:0 0.25rem;cursor:pointer;width:100%;height:100%;}.mc-action-list__button.svelte-cf5eub:focus-visible {box-shadow:0 0 0 0.125rem var(--focus-color-mid, var(--focus-color-outline-mid, #ffffff)), 0 0 0 0.25rem var(--focus-color-outer, var(--focus-color-outline-outer, #000000));outline:0.125rem solid transparent;outline-offset:0.125rem;}.mc-action-list__text.svelte-cf5eub {font-size:var(--font-size-150, 1rem);font-weight:var(--font-weight-regular, 400);line-height:var(--line-height-s, 1.3);text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0;}.mc-action-list__icon.svelte-cf5eub {width:1.25rem;height:1.25rem;}.mc-action-list__divider.svelte-cf5eub {margin:0.5rem 0;}.mc-listbox__close.svelte-cf5eub {display:flex;align-items:center;justify-content:center;}`};function k(a,x){let C=e(x);b(x,!0),d(a,O);let k=g(x,`open`,15),A=g(x,`title`,7),j=g(x,`position`,7,`bottom`),M=g(x,`onclose`,7),N=g(x,`class`,7),P=y(x,[`$$slots`,`$$events`,`$$legacy`,`$$host`,`open`,`title`,`position`,`onclose`,`class`]),F=crypto.randomUUID(),I,L,R=f(null);function z(){M()?.();let e=new CustomEvent(`close`,{bubbles:!0,composed:!0});I.dispatchEvent(e),k(!1)}function B(){let e=L?.querySelector(`slot[name="item"]`);return e?e.assignedElements().filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`disabled`)!==`true`):[]}function V(e){let t=B();if(!t.length)return;let n=0;if(!e){let e=t.findIndex(e=>e===document.activeElement);n=e===-1?0:(e+1)%t.length}t[n]?.focus()}function H(){!L||!s(R)||(k()?(L.showPopover({source:s(R)}),V(!0)):L.hidePopover({source:s(R)}))}function U(e){if(!k())return;let t=e.composedPath?e.composedPath():[];!t.includes(I)&&!t.includes(s(R))&&k(!1)}function W(e){e.preventDefault(),e.key===`Tab`&&V(),e.key===`Escape`&&(k(!1),(s(R)?.querySelector(`slot[name="activator"]`)).assignedElements()[0].focus())}n(H),te(()=>(document.addEventListener(`mousedown`,U),()=>{document.removeEventListener(`mousedown`,U)}));var G={get open(){return k()},set open(e){k(e),m()},get title(){return A()},set title(e){A(e),m()},get position(){return j()},set position(e=`bottom`){j(e),m()},get onclose(){return M()},set onclose(e){M(e),m()},get class(){return N()},set class(e){N(e),m()}},K=D(),q=r(K);h(q,()=>({class:[`mc-listbox`,`mc-listbox--${j()}`,N()],...P}),void 0,void 0,void 0,`svelte-cf5eub`);var J=v(q);h(J,()=>({class:`mc-listbox__content`,...C.activator?{id:F,popover:`manual`,role:`dialog`,tabindex:0,onkeydown:W}:{}}),void 0,void 0,void 0,`svelte-cf5eub`);var Y=v(J),X=v(Y),re=e=>{var t=ne(),n=v(t,!0);p(t),c(()=>ee(n,A())),i(e,t)};t(X,e=>{A()&&e(re)});var Z=l(X,2);T(v(Z),{ghost:!0,"aria-label":`Close`,onclick:z,$$slots:{icon:(e,t)=>{w(e,{slot:`icon`})}}}),p(Z),p(Y);var Q=l(Y,2),$=v(Q);S(v($),x,`item`,{},null),p($),p(Q),p(J),u(J,e=>L=e,()=>L),p(q),u(q,e=>I=e,()=>I);var ie=l(q,2),ae=e=>{var t=E();S(v(t),x,`activator`,{},null),p(t),u(t,e=>o(R,e),()=>s(R)),i(e,t)};return t(ie,e=>{C.activator&&e(ae)}),i(a,K),_(G)}customElements.define(`m-action-listbox`,x(k,{open:{attribute:`open`,reflect:!0,type:`Boolean`},title:{},position:{},onclose:{},class:{}},[`item`,`activator`],[],{mode:`open`},C));
//# sourceMappingURL=ActionListbox.js.map