import{r as t,c as i,h as s,H as e,g as o}from"./p-ClISz4NF.js";import{g as r,a as n}from"./p-CoD1xawt.js";import{c as a}from"./p-vN03FcXN.js";import{b as c}from"./p-Bo1ROm5Q.js";import"./p-BcQO4NH2.js";import"./p-U40vKHrs.js";import"./p-CQvUntGY.js";const h={triggerEvents:"click",exclude:""};function l(t,i,s,e=h){const o=f(e);p(e).forEach((e=>{window.addEventListener(e,(e=>{d(e,t,i,s,o)}),false)}))}function d(t,i,s,e,o){const r=t.target;if(!s.contains(r)&&!u(r,o)){e.call(i)}}function p(t){if(t.triggerEvents){return t.triggerEvents.split(",").map((t=>t.trim()))}return["click"]}function f(t){if(t.exclude){try{return Array.from(document.querySelectorAll(t.exclude))}catch(i){console.warn(`@ClickOutside: Exclude: '${t.exclude}' will not be evaluated. Check your exclude selector syntax.`,i)}}return}function u(t,i){if(t&&i){for(let s of i){if(s.contains(t)){return true}}}return false}var g;(function(t){t["LEFT"]="left";t["RIGHT"]="right"})(g||(g={}));const v={root:"gov-dropdown",list:"gov-dropdown__list"};const m=class{constructor(s){t(this,s);this.govChange=i(this,"gov-change");this.open=false;this.position=g.LEFT;this.h=r(this.host);this.listId=a("GovDropdownList");this.controlId=a("GovDropdownControl")}watchOpen(){var t;(t=this.trigger)===null||t===void 0?void 0:t.setAttribute("aria-expanded",n(this.open))}get trigger(){return this.host.querySelector(`* > ${c.root}`)}get list(){return this.h.getSlot("list")}componentWillLoad(){var t;if(!this.trigger)return;this.trigger.setAttribute("aria-controls",this.listId);this.trigger.setAttribute("aria-haspopup",n(!!this.list));this.trigger.setAttribute("aria-expanded",n(this.open));this.trigger.setAttribute("identifier",(t=this.identifier)!==null&&t!==void 0?t:this.controlId);this.trigger.addEventListener("gov-click",(t=>{t.preventDefault();t.stopPropagation();this.open=!this.open;this.govChange.emit({component:v.root,originalEvent:t,open:this.open})}))}render(){return s(e,{key:"24e596043840ec3b4e2ae0c59cecd1ec5425f5b5",class:this.h.classes([v.root]),open:this.open,position:this.position},s("slot",{key:"5c9c344162c6842585b134b327e9d45e4c1df19e"}),s("div",{key:"b424408e77eaebc2eedfe5ac1c7a916808af21f7",ref:t=>l(this,t,(()=>this.open=false)),class:v.list,id:this.listId,"aria-labelledby":this.controlId,"aria-hidden":n(!this.open),hidden:!this.open},s("slot",{key:"b39d21fd27642fd5e7ece4b9d68de2e8468b93ae",name:"list"})))}async getState(){return this.open}async toggle(){this.open=!this.open}get host(){return o(this)}static get watchers(){return{open:["watchOpen"]}}};export{m as gov_dropdown};
//# sourceMappingURL=p-017d6340.entry.js.map