impulse_view_components 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,59 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@floating-ui/dom")):"function"==typeof define&&define.amd?define(["@floating-ui/dom"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM)}(this,function(g){"use strict";function t(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;0<=a;a--)(n=t[a])&&(o=(r<3?n(o):3<r?n(e,i,o):n(e,i))||o);return 3<r&&o&&Object.defineProperty(e,i,o),o}const e=Symbol.for("impulse");class o{constructor(t,e){this.proto=t,this.name=e,this.map=new Map,this.proto=t,this.name=e,this.initialize()}add(t){var e;null!=(e=this.value)&&e.add(t)}get value(){return this.map.get(this.name)}initialize(){Object.prototype.hasOwnProperty.call(this.proto,e)||(this.proto[e]=new Map),this.map=this.proto[e],this.map.has(this.name)||this.map.set(this.name,new Set)}}function i({type:i=String}={}){return(t,e)=>{new o(t,"property").add({key:e,type:i})}}function s(e){return t=>{try{window.customElements.define(e,t),window[t.name]=customElements.get(e)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}}}function n(){return(t,e)=>{new o(t,"target").add({key:e})}}const q=/^(?:(.+?)?(?:@(window|document))?->)?(.+)#(.+)?$/;function D(t){var[,t,e,i,s]=t.trim().match(q)||[];return{eventName:t,eventTarget:"window"===(t=e)?window:"document"===t?document:void 0,methodName:s,identifier:i}}class K{constructor(){this.map=new Map}add(t,e){r(this.map,t).add(e)}delete(t,e){r(this.map,t).delete(e),0===(null==(e=this.get(t))?void 0:e.size)&&this.map.delete(t)}clear(){this.map.clear()}get values(){return Array.from(this.map.values()).reduce((t,e)=>t.concat(Array.from(e)),[])}get(t){return this.map.get(t)}has(t,e){return!(null==(t=this.get(t))||!t.has(e))}}function r(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}class F{constructor(t,e,i,s){this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=s,this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=s}start(){this.eventTarget.addEventListener(this.eventName,this)}stop(){this.eventTarget.removeEventListener(this.eventName,this)}handleEvent(t){var e=this.instance[this.methodName];"function"==typeof e&&e.call(this.instance,t)}}function a(t,e){return(null==(t=t.getAttribute(e))?void 0:t.trim().split(/\s+/))||[]}class B{constructor(t,e,i){this.element=t,this.delegate=e,this.observerOptions=i,this.started=!1,this.element=t,this.delegate=e,this.observer=new MutationObserver(t=>this.processMutations(t)),this.observerOptions=i}start(){this.started||(this.started=!0,this.observer.observe(this.element,Object.assign({childList:!0,subtree:!0},this.observerOptions)))}stop(){this.started&&(this.observer.takeRecords(),this.observer.disconnect(),this.started=!1)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){"attributes"===t.type&&t.target instanceof Element?this.processAttributeChange(t.target,t.attributeName):"childList"===t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){e&&this.delegate.elementAttributeChanged(t,e)}processRemovedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.delegate.elementDisconnected(e)}}processAddedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.elementIsActive(e)&&this.delegate.elementConnected(e)}}elementFromNode(t){if(t.nodeType===Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected===this.element.isConnected&&this.element.contains(t)}}class l{constructor(t,e,i){this.instance=t,this.attributeName=e,this.delegate=i,this.instance=t,this.attributeName=e,this.elementObserver=new B(this.instance,this,{attributeFilter:[this.attributeName]}),this.delegate=i}start(){this.elementObserver.start()}stop(){this.elementObserver.stop()}elementConnected(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));t.hasAttribute(this.attributeName)&&e.push(t);for(const i of e)this.delegate.elementConnected(i)}elementDisconnected(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));t.hasAttribute(this.attributeName)&&e.push(t);for(const i of e)this.delegate.elementDisconnected(i)}elementAttributeChanged(t,e){var i,s;e===this.attributeName&&null!=(s=(i=this.delegate).elementAttributeChanged)&&s.call(i,t,e)}}const h="data-action";class j{constructor(t){this.instance=t,this.eventListenerMap=new K,this.instance=t,this.attributeObserver=new l(this.instance,h,this)}start(){this.attributeObserver.start();var t=Array.from(this.instance.querySelectorAll(`[${h}]`));this.instance.hasAttribute(h)&&t.push(this.instance),t.forEach(t=>this.bindActions(t))}stop(){this.eventListenerMap.values.forEach(t=>t.stop()),this.eventListenerMap.clear(),this.attributeObserver.stop()}elementConnected(t){this.bindActions(t)}elementDisconnected(t){this.unbindActions(t)}elementAttributeChanged(t){this.unbindActions(t),this.bindActions(t)}bindActions(n){a(n,h).forEach(t=>{var{eventName:t,eventTarget:e,methodName:i,identifier:s}=D(t);t&&s===this.identifier&&i&&(s=new F(this.instance,e||n,t,i),this.eventListenerMap.add(n,s),s.start())})}unbindActions(e){var t=this.eventListenerMap.get(e);t&&t.forEach(t=>{t.stop(),this.eventListenerMap.delete(e,t)})}get identifier(){return this.instance.identifier}}const U=/(-|_|\.|\s)+(.)?/g,$=/(^|\/)([A-Z])/g,z=/[ _]/g,_=/([a-z\d])([A-Z])/g;function c(t){return t.replace(_,"$1_$2").toLowerCase().replace(z,"-")}function d(t,e=""){if(!t)return e;try{return JSON.parse(t)}catch(t){return e}}class H{constructor(t){this.instance=t,this.instance=t,this.store=new o(Object.getPrototypeOf(this.instance),"property")}start(){for(var[{key:t,type:e}]of this.values.entries())this.initializeProperty(t,e)}stop(){}initializeProperty(t,e){var i=c(t),s=this.instance[t],e=Object.assign({configurable:!0},function(e,i,t){switch(t){case Number:return{get:()=>Number(e.getAttribute(i)||0),set:t=>e.setAttribute(i,(t||0).toString())};case Boolean:return{get:()=>e.hasAttribute(i)&&"false"!==e.getAttribute(i),set:t=>{t?e.setAttribute(i,""):e.removeAttribute(i)}};case Array:return{get:()=>JSON.parse(e.getAttribute(i)||"[]"),set:t=>e.setAttribute(i,JSON.stringify(t)||"[]")};case Object:return{get:()=>JSON.parse(e.getAttribute(i)||"{}"),set:t=>e.setAttribute(i,JSON.stringify(t)||"{}")};default:return{get:()=>e.getAttribute(i)||"",set:t=>e.setAttribute(i,t||"")}}}(this.instance,i,e));Object.defineProperty(this.instance,t,e),this.instance.hasAttribute(i)||null!=(t=e.set)&&t.call(e,s)}get values(){return this.store.value}}const u="data-target";class J{constructor(t){this.instance=t,this.instance=t,this.store=new o(Object.getPrototypeOf(this.instance),"target"),this.attributeObserver=new l(this.instance,u,this)}start(){this.attributeObserver.start(),this.targetKeys.forEach(t=>this.initializeKey(t))}stop(){this.targetKeys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(i){a(i,u).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.defineProperty(e,i),this.processAddedElement(e,i))})}elementDisconnected(i){a(i,u).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.processRemovedElement(e,i),this.defineProperty(e,null))})}initializeKey(t){var e;this.targetKeys.includes(t)&&(e=this.findTarget(t),this.defineProperty(t,e),e)&&this.processAddedElement(t,e)}terminateKey(t){var e;this.targetKeys.includes(t)&&(e=this.findTarget(t))&&this.processRemovedElement(t,e)}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}processAddedElement(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}processRemovedElement(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}findTarget(t){t=`[${u}~="${this.identifier}.${t}"]`;return this.instance.querySelector(t)}get targetKeys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}const p="data-target";class Q{constructor(t){this.instance=t,this.instance=t,this.store=new o(Object.getPrototypeOf(this.instance),"targets"),this.attributeObserver=new l(this.instance,p,this)}start(){this.attributeObserver.start(),this.targetKeys.forEach(t=>this.initializeKey(t))}stop(){this.targetKeys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(i){a(i,p).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.defineProperty(e,this.findTargets(e)),this.processAddedElement(e,i))})}elementDisconnected(i){a(i,p).forEach(t=>{var[t,e]=t.split(".");t&&e&&t===this.identifier&&this.targetKeys.includes(e)&&(this.processRemovedElement(e,i),this.defineProperty(e,this.findTargets(e)))})}initializeKey(e){var t;this.targetKeys.includes(e)&&(t=this.findTargets(e),this.defineProperty(e,t),t.forEach(t=>this.processAddedElement(e,t)))}terminateKey(e){this.targetKeys.includes(e)&&this.findTargets(e).forEach(t=>this.processRemovedElement(e,t))}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}processAddedElement(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}processRemovedElement(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}findTargets(t){t=`[${p}~="${this.identifier}.${t}"]`;return Array.from(this.instance.querySelectorAll(t))}get targetKeys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}class m extends HTMLElement{constructor(){super(...arguments),this.property=new H(this),this.targets=new Q(this),this.target=new J(this),this.action=new j(this),this._started=!1}async connectedCallback(){await new Promise(t=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t()}),customElements.upgrade(this),this.property.start(),await this._resolveUndefinedElements(),this.targets.start(),this.target.start(),this.action.start(),this._started=!0,this.setAttribute("data-impulse-element",""),this.connected()}static get observedAttributes(){var t=new o(this.prototype,"property");return Array.from(t.value).map(({key:t})=>c(t))}attributeChangedCallback(t,e,i){if(this._started&&e!==i){const r=t.replace(U,(t,e,i)=>i?i.toUpperCase():"").replace($,t=>t.toLowerCase());var s=this[r+"Changed"];if("function"==typeof s){var n=new o(Object.getPrototypeOf(this),"property"),n=Array.from(n.value).map(({key:t,type:e})=>({key:t,type:e})).find(({key:t})=>t===r);if(!n)throw new Error(`Unregistered attribute changed: ${t}. Register the attribute using the @property() decorator.`);var{newValue:t,oldValue:i}=function(t,e,i){switch(i){case Boolean:var s=t=>null!==t&&"false"!==t;return{newValue:s(t),oldValue:s(e)};case Number:return{newValue:Number(t),oldValue:Number(e)};case Array:return{newValue:d(t,[]),oldValue:d(e,[])};case Object:return{newValue:d(t,{}),oldValue:d(e,{})};default:return{newValue:t,oldValue:e}}}(i,e,n.type);s.call(this,t,i)}}}disconnectedCallback(){this.action.stop(),this.target.stop(),this.targets.stop(),this.property.stop(),this.disconnected(),this._started=!1}connected(){}disconnected(){}emit(t,e={}){var{target:i=this,prefix:s=this.identifier,detail:n={}}=e,e=function(t,e){var i={};for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(i[n[s]]=t[n[s]]);return i}(e,["target","prefix","detail"]),s=new CustomEvent(s?s+":"+t:t,Object.assign({bubbles:!0,composed:!0,detail:n},e));return i.dispatchEvent(s),s}get identifier(){return this.tagName.toLowerCase()}async _resolveUndefinedElements(){var t=Array.from(this.querySelectorAll(":not(:defined)")).map(t=>customElements.whenDefined(t.localName));await Promise.all(t)}}function f(t){return Number(t.replace(/[^-\d.]/g,""))}let v=class extends m{constructor(){super(...arguments),this.placement="bottom",this.active=!1,this.strategy="fixed",this.distance=0,this.skidding=0,this.flip=!0,this.flipPadding=0,this.fallbackPlacements=[],this.fallbackStrategy="bestFit",this.shift=!1,this.shiftPadding=0}connected(){this.start()}disconnected(){this.stop()}async anchorIdChanged(t){await this.stop(),t&&this.anchorElement&&this.start()}async activeChanged(t){t?this.start():await this.stop()}start(){this.anchorElement&&(this.style.position=this.strategy,this.style.top="0px",this.style.left="0px",this.cleanup=g.autoUpdate(this.anchorElement,this,this.reposition.bind(this)))}async stop(){return new Promise(t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,requestAnimationFrame(()=>t())):t()})}async reposition(){if(this.active&&this.anchorElement){var t=[g.offset({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(g.size({apply:({rects:t})=>{var e="width"===this.sync||"both"===this.sync,i="height"===this.sync||"both"===this.sync;this.style.width=e?t.reference.width+"px":"",this.style.height=i?t.reference.height+"px":""}})):(this.style.width="",this.style.height=""),this.flip&&t.push(g.flip({fallbackPlacements:this.fallbackPlacements.length?this.fallbackPlacements:void 0,fallbackStrategy:this.fallbackStrategy,padding:this.flipPadding})),this.shift&&t.push(g.shift({padding:this.shiftPadding})),this.arrowElement&&t.push(g.arrow({element:this.arrowElement,padding:this._arrowPadding}));const{x:e,y:i,placement:s,strategy:n,middlewareData:r}=await g.computePosition(this.anchorElement,this,{placement:this.placement,middleware:t,strategy:this.strategy});if(Object.assign(this.style,{left:e+"px",top:i+"px",position:n}),r.arrow&&this.arrowElement){const{x:e,y:i}=r.arrow;Object.assign(this.arrowElement.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}this.setAttribute("x-placement",s)}}get anchorElement(){return document.getElementById(this.anchorId)}get arrowElement(){return this.querySelector("[data-arrow]")}get _arrowPadding(){return"number"==typeof this.arrowPadding?this.arrowPadding:f(getComputedStyle(this).borderRadius)||2}};t([i()],v.prototype,"anchorId",void 0),t([i()],v.prototype,"placement",void 0),t([i({type:Boolean})],v.prototype,"active",void 0),t([i()],v.prototype,"strategy",void 0),t([i({type:Number})],v.prototype,"distance",void 0),t([i({type:Number})],v.prototype,"skidding",void 0),t([i()],v.prototype,"sync",void 0),t([i({type:Boolean})],v.prototype,"flip",void 0),t([i({type:Number})],v.prototype,"flipPadding",void 0),t([i({type:Array})],v.prototype,"fallbackPlacements",void 0),t([i()],v.prototype,"fallbackStrategy",void 0),t([i({type:Boolean})],v.prototype,"shift",void 0),t([i({type:Number})],v.prototype,"shiftPadding",void 0),t([i({type:Number})],v.prototype,"arrowPadding",void 0),v=t([s("awc-anchor")],v);var b=0;function y(){return b+=1,`ambiki-${Math.random().toString().slice(2,6)}-`+b}function w(t){return!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled")}var W=!!navigator.userAgent.match(/Macintosh/),X=class{input;list;multiple;isMouseMoving=!1;constructor(t,e,{multiple:i=!1}={}){this.input=t,this.list=e,this.multiple=i,this.list.id||(this.list.id=y()),this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.multiple&&this.input.setAttribute("aria-multiselectable","true"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-haspopup","listbox"),this.input.setAttribute("aria-autocomplete","list"),this.list.setAttribute("role","listbox"),this.onKeydown=this.onKeydown.bind(this),this.onClick=this.onClick.bind(this),this.onListMouseover=this.onListMouseover.bind(this),this.onListMousemove=this.onListMousemove.bind(this)}start(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","true"),this.input.setAttribute("aria-controls",this.list.id),this.input.addEventListener("keydown",this.onKeydown),this.list.addEventListener("click",this.onClick),this.list.addEventListener("mouseover",this.onListMouseover),this.list.addEventListener("mousemove",this.onListMousemove),this.initializeOptions()}stop(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","false"),this.input.removeAttribute("aria-controls"),this.input.removeEventListener("keydown",this.onKeydown),this.list.removeEventListener("click",this.onClick),this.list.removeEventListener("mouseover",this.onListMouseover),this.list.removeEventListener("mousemove",this.onListMousemove),this.deselectAll(),this.deactivate()}onKeydown(t){if(this.isMouseMoving=!1,!(t.shiftKey||t.metaKey||t.altKey||!W&&t.ctrlKey))switch(t.key){case"Enter":case"Tab":this.activeOption&&w(this.activeOption)&&(t.preventDefault(),t.stopPropagation(),this.activeOption.click());break;case"Escape":this.deactivate();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(1):this.activate(this.visibleOptions[0],{scroll:!0});break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(-1):this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;case"Home":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[0],{scroll:!0});break;case"End":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;default:t.ctrlKey||this.deactivate()}}onClick(t){t=A(t.target);t&&w(t)&&(this.multiple&&this.isSelected(t)?this.deselect(t):this.select(t),t.dispatchEvent(new CustomEvent("combobox:commit",{bubbles:!0})))}onListMouseover(t){var e;this.isMouseMoving?(e=A(t.target))&&this.activate(e):t.preventDefault()}onListMousemove(t){!this.isMouseMoving&&(this.isMouseMoving=!0,t=A(t.target))&&this.activate(t)}select(t){if(this.multiple)t.setAttribute("aria-selected","true");else for(var e of this.options)e.setAttribute("aria-selected",(e===t).toString())}deselect(t){t.setAttribute("aria-selected","false")}deselectAll(){for(var t of this.options)this.deselect(t)}activate(t,{scroll:e=!1}={}){for(var i of this.options)i.id===t.id?(i.setAttribute("data-active",""),this.input.setAttribute("aria-activedescendant",i.id),e&&i.scrollIntoView({block:"nearest"})):i.removeAttribute("data-active")}deactivate(){this.input.removeAttribute("aria-activedescendant");for(var t of Array.from(this.list.querySelectorAll('[role="option"][data-active]')))t.removeAttribute("data-active")}isSelected(t){return"true"===t.getAttribute("aria-selected")}get options(){return Array.from(this.list.querySelectorAll('[role="option"]'))}get visibleOptions(){return this.options.filter(Y)}get activeOption(){return this.list.querySelector("[data-active]")}move(t){this.activeOption&&(t=function(t,e,i){let s=t.indexOf(e),n=(s===t.length-1&&1===i&&(s=-1),1===i?0:t.length-1);return t[n=e&&0<=s&&0<=(e=s+i)&&e<t.length?e:n]}(this.visibleOptions,this.activeOption,t),this.activate(t,{scroll:!0}))}initializeOptions(){for(var t of this.options)t.setAttribute("tabindex","-1"),t.id||(t.id=y()),t.hasAttribute("aria-selected")||this.deselect(t)}};function A(t){return t&&t.closest('[role="option"]')||!1}function Y(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(0<t.offsetWidth||0<t.offsetHeight)}function E(o,{referenceElement:a,popupElement:l,arrowElement:h,arrowPadding:c=0,middleware:d=[],offsetOptions:u=0,placement:p="bottom-start",flipOptions:m,shiftOptions:f,strategy:v="fixed",sync:b}){let e;async function t(){if(o.open&&a){var t=[g.offset(u)];b?t.push(g.size({apply:({rects:t})=>{var e="height"===b||"both"===b;l.style.width="width"===b||"both"===b?t.reference.width+"px":"",l.style.height=e?t.reference.height+"px":""}})):(l.style.width="",l.style.height=""),t.push(g.flip(m)),t.push(g.shift(f)),h&&t.push(g.arrow({element:h,padding:c})),t.concat(d);const{x:e,y:i,placement:s,strategy:n,middlewareData:r}=await g.computePosition(a,l,{placement:p,middleware:t,strategy:v});if(Object.assign(l.style,{left:e+"px",top:i+"px",position:n}),r.arrow&&h){const{x:e,y:i}=r.arrow;Object.assign(h.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}l.setAttribute("x-placement",s)}}function i(){l.style.position=v,l.style.top="0px",l.style.left="0px",a&&(e=g.autoUpdate(a,l,t))}async function s(){return new Promise(t=>{e?(e(),e=void 0,requestAnimationFrame(()=>t())):t()})}i();const n=o.disconnected.bind(o);return Object.assign(o,{disconnected(){s(),n()}}),{start:i,update:async function(){await t()},stop:s}}function O(t,{boundaries:n,callback:r}){let o=null;function e(t){var e;o=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target}function i(t,e){if(o&&!t.defaultPrevented){var i=e(t);if(i&&i.getRootNode().contains(i)&&i.isConnected){for(const s of n)if(null!==s){if(s.contains(i))return;if(t.composed&&t.composedPath().includes(s))return}r(t,i),o=null}}}document.addEventListener("mousedown",e,!0),document.addEventListener("click",t=>i(t,()=>o),!0);const s=t.disconnected.bind(t);Object.assign(t,{disconnected(){o=null,document.removeEventListener("mousedown",e,!0),document.removeEventListener("click",t=>i(t,()=>o),!0),s()}})}function Z(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))}function G(t){var e,i;if(t)return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||""===(i=null==(e=t)||null==(i=e.getAttribute)?void 0:i.call(e,"contenteditable"))||"true"===i)&&!Z(t)?0:t.tabIndex;throw new Error("No node provided")}function tt(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex}function et(t){return"INPUT"===t.tagName}function it(t){if(!t.name)return 1;function e(t){return i.querySelectorAll('input[type="radio"][name="'+t+'"]')}var i=t.form||C(t);if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)s=e(window.CSS.escape(t.name));else try{s=e(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),0}var s=function(t,e){for(var i=0;i<t.length;i++)if(t[i].checked&&t[i].form===e)return t[i]}(s,t.form);return!s||s===t}function st(t){return et(e=t)&&"radio"===e.type&&!it(t);var e}function nt(t){var e=(t=t.getBoundingClientRect()).width,t=t.height;return 0===e&&0===t}function rt(t,e){return t=(e=e||{}).getShadowRoot?ht([t],e.includeContainer,{filter:mt.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:ft}):lt(t,e.includeContainer,mt.bind(null,e)),vt(t)}function x(t,e){if(e=e||{},t)return!1!==k.call(t,bt)&&P(e,t);throw new Error("No node provided")}var ot=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],S=ot.join(","),at="undefined"==typeof Element,k=at?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,C=!at&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},N=function t(e,i){void 0===i&&(i=!0);var s=null==e||null==(s=e.getAttribute)?void 0:s.call(e,"inert");return""===s||"true"===s||i&&e&&t(e.parentNode)},lt=function(t,e,i){var s;return N(t)?[]:(s=Array.prototype.slice.apply(t.querySelectorAll(S)),e&&k.call(t,S)&&s.unshift(t),s.filter(i))},ht=function t(e,i,s){for(var n=[],r=Array.from(e);r.length;){var o,a,l=r.shift();N(l,!1)||("SLOT"===l.tagName?(o=t((o=l.assignedElements()).length?o:l.children,!0,s),s.flatten?n.push.apply(n,o):n.push({scopeParent:l,candidates:o})):(k.call(l,S)&&s.filter(l)&&(i||!e.includes(l))&&n.push(l),o=l.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(l),a=!N(o,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(l)),o&&a?(a=t((!0===o?l:o).children,!0,s),s.flatten?n.push.apply(n,a):n.push({scopeParent:l,candidates:a})):r.unshift.apply(r,l.children)))}return n},ct=function(t){return et(t)&&"hidden"===t.type},dt=function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some(function(t){return"SUMMARY"===t.tagName})},ut=function(t,e){var i=e.displayCheck,s=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;e=k.call(t,"details>summary:first-of-type")?t.parentElement:t;if(k.call(e,"details:not([open]) *"))return!0;if(i&&"full"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return nt(t)}else{if("function"==typeof s){for(e=t;t;){var n=t.parentElement,r=C(t);if(n&&!n.shadowRoot&&!0===s(n))return nt(t);t=t.assignedSlot||(n||r===t.ownerDocument?n:r.host)}t=e}if(function(t){var e,i=t&&C(t),s=null==(e=i)?void 0:e.host,n=!1;if(i&&i!==t)for(n=!!(null!=(e=s)&&null!=(e=e.ownerDocument)&&e.contains(s)||null!=t&&null!=(e=t.ownerDocument)&&e.contains(t));!n&&s;)var r,n=!(null==(r=s=null==(r=i=C(s))?void 0:r.host)||null==(r=r.ownerDocument)||!r.contains(s));return n}(t))return!t.getClientRects().length;if("legacy-full"!==i)return!0}return!1},pt=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var s=e.children.item(i);if("LEGEND"===s.tagName)return!!k.call(e,"fieldset[disabled] *")||!s.contains(t)}return!0}e=e.parentElement}return!1},P=function(t,e){return!(e.disabled||N(e)||ct(e)||ut(e,t)||dt(e)||pt(e))},mt=function(t,e){return!(st(e)||G(e)<0||!P(t,e))},ft=function(t){t=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(t)||0<=t)},vt=function a(t){var l=[],h=[];return t.forEach(function(t,e){var i,s=!!t.scopeParent,n=s?t.scopeParent:t,r=(r=s,(i=G(o=n))<0&&r&&!Z(o)?0:i),o=s?a(t.candidates):n;0===r?s?l.push.apply(l,o):l.push(n):h.push({documentOrder:e,tabIndex:r,item:t,isScope:s,content:o})}),h.sort(tt).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(l)},bt=ot.concat("iframe").join(",");function V(t){return t.getAttribute("value")||""}function L(t){return t.getAttribute("data-text")||t.innerText.trim()}class gt{constructor(t){this.autocomplete=t,this.selectedValues=new Set,this.defaultSelectedValues=[],this.autocomplete=t}connected(){(function(t){try{return JSON.parse(t).map(t=>t.toString())}catch(t){return[]}})(this.autocomplete.value).forEach(t=>this.selectedValues.add(t)),this.defaultSelectedValues=this.persistedTags.map(t=>({value:V(t),text:L(t)}))}disconnected(){}start(){for(const t of this.autocomplete.options)this.selectedValues.has(V(t))?this.autocomplete.combobox.select(t):this.autocomplete.combobox.deselect(t)}stop(){this.clearInputField()}async commit(t){this.clearInputField();const e=V(t);t=L(t);if(this.selectedValues.has(e)?this.removeValue(e):this.setValue(e,t),this.autocomplete.src){await this.autocomplete.makeRequest(""),this.start();t=this.autocomplete.visibleOptions.find(t=>V(t)===e)||this.autocomplete.visibleOptions[0];t&&this.autocomplete.activate(t)}else for(const t of this.autocomplete.options)t.hidden=!1}clear(){this.selectedValues.forEach(t=>this.removeValue(t))}reset(){this.clear(),this.defaultSelectedValues.forEach(({value:t,text:e})=>this.setValue(t,e,{persisted:!0}))}setValue(e,t,{persisted:i=!1}={}){this.selectedValues.has(e)||(this.selectedValues.add(e),this.insertTag(e,t,{persisted:i}),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),this.autocomplete.open&&(t=this.autocomplete.options.find(t=>V(t)===e))&&this.autocomplete.combobox.select(t))}removeValue(e){var t;this.selectedValues.has(e)&&(this.selectedValues.delete(e),this.removeTag(e),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),t=this.autocomplete.options.find(t=>V(t)===e))&&this.autocomplete.combobox.deselect(t)}setRequiredAttribute(t){!t||0<this.selectedValues.size?this.autocomplete.input.required=!1:this.autocomplete.input.required=!0}insertTag(t,e,{persisted:i=!1}={}){var s=this.template.content.cloneNode(!0),n=s.querySelector('[data-behavior="tag"]'),r=s.querySelector('[data-behavior="text"]'),o=s.querySelector('[data-behavior="hidden-field"]');null!=n&&n.setAttribute("value",t),null!=n&&n.toggleAttribute("data-persisted",i),r&&(r.innerText=e),o&&(o.value=t),this.autocomplete.control.insertBefore(s,this.template)}removeTag(e){var t=this.tags.find(t=>V(t)===e);null!=t&&t.remove()}updateElementValue(){var t=Array.from(this.selectedValues.values());this.autocomplete.value=JSON.stringify(t)}clearInputField(){this.autocomplete.input.value&&(this.autocomplete.input.value="")}get firstActiveOption(){return this.autocomplete.visibleOptions.find(t=>this.selectedValues.has(V(t)))||this.autocomplete.visibleOptions[0]}get tags(){return Array.from(this.autocomplete.querySelectorAll('[data-behavior="tag"]'))}get persistedTags(){return this.tags.filter(t=>t.hasAttribute("data-persisted"))}get template(){return this.autocomplete.querySelector('[data-behavior="tag-template"]')}}class yt{constructor(t){this.autocomplete=t,this.defaultValue="",this.defaultText="",this.autocomplete=t}connected(){this.defaultValue=this.hiddenField.value,this.defaultText=this.hiddenField.getAttribute("data-text")||""}disconnected(){}start(){this.selectedOption&&this.autocomplete.combobox.select(this.selectedOption)}stop(){this.autocomplete.input.value=this.hiddenField.getAttribute("data-text")||""}commit(t){var e=V(t),t=L(t);this.setValue(e,t),this.autocomplete.open=!1}clear(){this.setValue(null,null)}reset(){this.setValue(this.defaultValue,this.defaultText)}setValue(t,e){this.autocomplete.value=t||"",this.autocomplete.input.value=e||"",this.hiddenField.value=t||"",this.hiddenField.setAttribute("data-text",e||""),null===t?this.autocomplete.combobox.deselectAll():this.autocomplete.open&&(e=this.autocomplete.options.find(t=>V(t)===this.defaultValue))&&this.autocomplete.combobox.select(e)}removeValue(){this.clear()}setRequiredAttribute(t){this.autocomplete.input.required=t}get firstActiveOption(){return this.selectedOption||this.autocomplete.visibleOptions[0]}get selectedOption(){return this.autocomplete.options.find(t=>this.isSelected(t))}isSelected(t){return V(t)===this.autocomplete.value}get hiddenField(){return this.autocomplete.querySelector('[data-behavior="hidden-field"]')}}let M=class extends m{constructor(){super(),this.open=!1,this.disabled=!1,this.required=!1,this.multiple=!1,this.param="q",this.singleSelect=new yt(this),this.multipleSelect=new gt(this),this.firstFocus=!0,this.inputPristine=!1,this.remoteSearch=function(e,i){let s;function t(...t){clearTimeout(s),s=setTimeout(()=>{e.apply(this,t)},i)}return t.clear=()=>{clearTimeout(s)},t}(this.remoteSearch.bind(this),300),this.handleFormReset=this.handleFormReset.bind(this)}connected(){var t;this.floatingUI=E(this,{referenceElement:this.control,popupElement:this.listbox,placement:"bottom",sync:"width",offsetOptions:4}),O(this,{boundaries:[this.control,this.listbox],callback:(t,e)=>{this.inputPristine&&!x(e)?t.preventDefault():this.open&&(this.open=!1),this.inputPristine=!1}}),this.combobox=new X(this.input,this.listbox,{multiple:this.multiple}),this.selectVariant=this.multiple?this.multipleSelect:this.singleSelect,this.selectVariant.connected(),null!=(t=this.form)&&t.addEventListener("reset",this.handleFormReset),this.selectVariant.setRequiredAttribute(this.required)}disconnected(){var t;this.open=!1,this.removeAttribute("data-focus"),this.firstFocus=!0,null!=(t=this.selectVariant)&&t.disconnected(),this.abortController=void 0,null!=(t=this.form)&&t.removeEventListener("reset",this.handleFormReset)}async openChanged(t){if(t)this.emit("show"),this.combobox.start(),this.listbox.hidden=!1,this.floatingUI.start(),this.src?await this.makeRequest(""):this.checkIfListIsEmpty(),null!=(t=this.selectVariant)&&t.start(),null!=(t=this.selectVariant)&&t.firstActiveOption&&this.activate(this.selectVariant.firstActiveOption),this.emit("shown");else{if(this.emit("hide"),this.listbox.hidden=!0,null!=(t=this.abortController)&&t.abort(),null!=(t=this.selectVariant)&&t.stop(),this.combobox.stop(),!this.src)for(const e of this.options)e.hidden=!1;this.removeAttribute("no-options"),this.removeAttribute("error"),this.inputPristine=!1,this.currentQuery=void 0,await this.floatingUI.stop(),this.emit("hidden")}}valueChanged(t){this.classList.toggle("awc-autocomplete--selected",""!==t&&"[]"!==t)}disabledChanged(t){if(this.input.disabled=t,this.clearBtn&&(this.clearBtn.disabled=t),this.multiple&&this.tagDismissBtns)for(const e of this.tagDismissBtns)e.disabled=t}requiredChanged(t){var e;null!=(e=this.selectVariant)&&e.setRequiredAttribute(t)}handleMousedown(t){t.target!==this.input&&t.preventDefault()}handleClick(t){this.disabled||(this.input.focus(),t=t.target["classList"],(t.contains("awc-autocomplete-control")||t.contains("awc-autocomplete-end-adornment"))&&(this.open=!0),this.firstFocus&&this.input.value&&this.input.select(),this.firstFocus=!1)}handleInputMousedown(){this.open=!0}handleInputFocus(){this.setAttribute("data-focus","")}handleInputBlur(){this.open&&(this.open=!1,this.inputPristine=!0),this.removeAttribute("data-focus"),this.firstFocus=!0}handleInputKeydown(t){switch(t.key){case"Enter":this.open&&t.preventDefault();break;case"Escape":this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1);break;case"ArrowDown":t.altKey&&!this.open&&(t.preventDefault(),this.open=!0);break;case"ArrowUp":t.altKey&&this.open&&(t.preventDefault(),this.open=!1);break;case"Backspace":var e;""===this.input.value&&this.multiple&&(e=this.multipleSelect["tags"],e=e[e.length-1])&&(t.preventDefault(),this.multipleSelect.removeValue(V(e)),this.emit("remove",{detail:{target:e}}))}}async handleInput(t){var t=t["target"];t instanceof HTMLInputElement&&(t=t.value.trim(),this.src?await this.remoteSearch(t):this.search(t))}async handleCommit(t){t.stopPropagation();var e,t=t.target;t instanceof HTMLElement&&(await(null==(e=this.selectVariant)?void 0:e.commit(t)),this.emit("commit",{detail:{target:t}}))}handleClear(){this.open=!1,this.clear(),this.emit("clear")}handleTagRemove(t){t=t.target.closest('[data-behavior="tag"]');t&&(this.multipleSelect.removeValue(V(t)),this.emit("remove",{detail:{target:t}}))}handleFormReset(){this.open=!1,this.reset(),this.emit("reset")}setValue(t,e){var i;null!=(i=this.selectVariant)&&i.setValue(t,e)}removeValue(t){this.multiple&&t?this.multipleSelect.removeValue(t):this.singleSelect.removeValue()}activate(t,{scroll:e=!0}={}){this.combobox.activate(t,{scroll:e})}deactivate(){this.combobox.deactivate()}clear(){var t;null!=(t=this.selectVariant)&&t.clear(),this.currentQuery=void 0}reset(){var t;null!=(t=this.selectVariant)&&t.reset(),this.currentQuery=void 0}focus(t){this.input.focus(t)}blur(){this.input.blur(),this.removeAttribute("data-focus")}show(){this.open||(this.open=!0)}hide(){this.open&&(this.open=!1)}search(t){var i;this.open=!0,this.options.forEach((i=t,t=>{var e;i?(e=null==(e=L(t))?void 0:e.toLowerCase().includes(i.toLowerCase()),t.hidden=!e):t.hidden=!1})),this.checkIfListIsEmpty(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async remoteSearch(t){this.open=!0,await this.makeRequest(t),null!=(t=this.selectVariant)&&t.start(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async makeRequest(t){if(this.currentQuery!==t){this.currentQuery=t,this.abortController?this.abortController.abort():(this.setAttribute("loading",""),this.emit("loadstart",{bubbles:!1,prefix:!1})),this.removeAttribute("error"),this.abortController=new AbortController;var e=new URL(this.src,window.location.href),i=new URLSearchParams(e.search.slice(1));i.append(this.param,t),e.search=i.toString();try{var s=await fetch(e.toString(),{signal:this.abortController.signal,credentials:"same-origin",headers:{accept:"text/fragment+html"}});if(!s.ok)throw new Error;this.optionsContainer.innerHTML=await s.text(),this.checkIfListIsEmpty(),this.combobox.initializeOptions(),this.abortController=void 0,await this.floatingUI.update(),this.emit("load",{bubbles:!1,prefix:!1})}catch(t){t instanceof Error&&"AbortError"!==t.name&&(this.abortController=void 0,this.setAttribute("error",""),this.emit("error",{bubbles:!1,prefix:!1}))}finally{this.removeAttribute("loading"),this.emit("loadend",{bubbles:!1,prefix:!1})}}}checkIfListIsEmpty(){this.toggleAttribute("no-options",0===this.visibleOptions.length)}get activeOption(){return this.combobox.activeOption}get visibleOptions(){return this.options.filter(t=>!t.hidden)}get options(){return this.combobox.options}get form(){return this.closest("form")}};t([i({type:Boolean})],M.prototype,"open",void 0),t([i()],M.prototype,"value",void 0),t([i({type:Boolean})],M.prototype,"disabled",void 0),t([i({type:Boolean})],M.prototype,"required",void 0),t([i({type:Boolean})],M.prototype,"multiple",void 0),t([i()],M.prototype,"src",void 0),t([i()],M.prototype,"param",void 0),t([n()],M.prototype,"input",void 0),t([n()],M.prototype,"listbox",void 0),t([n()],M.prototype,"control",void 0),t([n()],M.prototype,"optionsContainer",void 0),t([n()],M.prototype,"clearBtn",void 0),t([(t,e)=>{new o(t,"targets").add({key:e})}],M.prototype,"tagDismissBtns",void 0),M=t([s("awc-autocomplete")],M);let R=class extends m{constructor(){super(...arguments),this.hideOnOutsideClick=!0,this.controller=new AbortController}connected(){this.trigger&&this.trigger.addEventListener("click",this.handleTriggerClick.bind(this),{signal:this.controller.signal})}disconnected(){this.hide(),this.controller.abort()}handleTriggerClick(){var t;null!=(t=this.trigger)&&t.setAttribute("aria-expanded","true"),this.show()}handleClose(t){t.target!==this.dialog||(null!=(t=this.trigger)&&t.setAttribute("aria-expanded","false"),this.closest("dialog[open]"))||(document.body.style.removeProperty("padding-right"),document.body.style.removeProperty("overflow"))}show(){this.dialog.showModal(),document.body.style.paddingRight=window.innerWidth-document.body.clientWidth+"px",document.body.style.overflow="hidden"}hide(t){if(t&&(t.stopPropagation(),t.target.closest(this.identifier)!==this))return;this.dialog.close()}handleOutsideClick(t){var e;this.hideOnOutsideClick&&!t.defaultPrevented&&(e=t.target)instanceof HTMLElement&&e===this.dialog&&((e=e.getBoundingClientRect()).top<=t.clientY&&t.clientY<=e.top+e.height&&e.left<=t.clientX&&t.clientX<=e.left+e.width||this.hide())}get trigger(){return document.getElementById(this.triggerId)}get open(){return this.dialog.open}},wt=(t([i()],R.prototype,"triggerId",void 0),t([i({type:Boolean})],R.prototype,"hideOnOutsideClick",void 0),t([n()],R.prototype,"dialog",void 0),R=t([s("awc-dialog")],R),1e3);const I=new Set;function At(e,{abortSignal:t,boundaries:i=[]}={}){var s=new AbortController,t=t||s.signal;let n=document.activeElement,r;i.forEach(t=>{t&&I.add(t)});const o="awc-"+wt++;e.setAttribute("data-focus-trap-id",o),I.add(e);var a,l,i=Et(o),h=(i.onfocus=()=>{var t=rt(e).filter(t=>!t.hasAttribute("data-sentinel-for")),t=t[t.length-1];null!=t&&t.focus()},Et(o));function c(t){t?t!==document.activeElement&&(t.focus({preventScroll:!0}),r=t):c(e)}return h.onfocus=()=>{var t=rt(e).filter(t=>!t.hasAttribute("data-sentinel-for"))[0];null!=t&&t.focus()},i=i,null!=(a=(l=e).parentNode)&&a.insertBefore(i,l),a=h,null!=(l=(i=e).parentNode)&&l.insertBefore(a,i.nextSibling),c(function(t){if(t.hasAttribute("data-autofocus")&&x(t))return t;var e=t.querySelector("[data-autofocus]");if(e&&x(e))return e;e=function(t,e){return(e=e||{}).getShadowRoot?ht([t],e.includeContainer,{filter:P.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):lt(t,e.includeContainer,P.bind(null,e))}(t).filter(t=>!t.hasAttribute("data-sentinel-for"));if(e[0])return e[0];if(x(t))return t}(e)),document.addEventListener("focusin",function(t){var e,i=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target;for(const s of I)if(s.contains(i))return void(r=i);c(r)},{signal:t,capture:!0}),t.addEventListener("abort",()=>{var t=null==(t=e.parentNode)?void 0:t.querySelectorAll(`[data-sentinel-for="${o}"]`);null!=t&&t.forEach(t=>t.remove()),I.delete(e),c(n),n=null,r=null}),s}function Et(t){var e=document.createElement("span");return e.setAttribute("tabindex","0"),e.setAttribute("aria-hidden","true"),e.setAttribute("data-sentinel-for",t),e.style.position="fixed",e.style.top="1px",e.style.left="1px",e.style.width="1px",e.style.height="0px",e.style.padding="0px",e.style.margin="-1px",e.style.overflow="hidden",e.style.clip="rect(0px, 0px, 0px, 0px)",e.style.whiteSpace="nowrap",e.style.borderWidth="0px",e}let T=class extends m{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.strategy="fixed",this.clickBoundaries=[]}connected(){this.floatingUI=E(this,{referenceElement:this.button,popupElement:this.panel,arrowElement:this.arrow,arrowPadding:this.arrowPadding,placement:this.placement,strategy:this.strategy,offsetOptions:8,flipOptions:{fallbackAxisSideDirection:"end"}}),O(this,{boundaries:this.boundaries,callback:(t,e)=>{var i;!this.open||null!=(i=this.querySelector(this.identifier))&&i.open||(this.open=!1,x(e))||t.preventDefault()}}),this.open&&(this.button.setAttribute("aria-expanded","true"),this.floatingUI.start())}disconnected(){this.open=!1}async openChanged(t){t?(this.emit("show"),this.button.setAttribute("aria-expanded","true"),this.floatingUI.start(),this._focusTrap=At(this.panel,{boundaries:this.boundaries}),this.emit("shown")):(this.emit("hide"),this.button.setAttribute("aria-expanded","false"),await this.floatingUI.stop(),null!=(t=this._focusTrap)&&t.abort(),this.emit("hidden"))}handleButtonClick(t){t.target.closest(this.identifier)!==this||this.button.disabled||"true"===this.button.getAttribute("aria-disabled")||this.toggle()}toggle(){this.open=!this.open}show(){this.open||(this.open=!0)}hide(t){if(t&&t.target.closest(this.identifier)!==this)return;this.open&&(this.open=!1)}handleKeydown(t){var e;"Escape"!==t.key||(e=t.target.closest(this.identifier))!==this&&null!=e&&e.open||this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1)}async reposition(){await this.floatingUI.update()}get arrowPadding(){return f(getComputedStyle(this.panel).borderRadius)||2}get boundaries(){return this.clickBoundaries.map(t=>document.querySelector(t)).concat([this.button,this.panel])}get button(){return Array.from(this.querySelectorAll(`[data-target~="${this.identifier}.button"]`)).filter(t=>t.closest(this.identifier)===this)[0]}get panel(){return Array.from(this.querySelectorAll(`[data-target~="${this.identifier}.panel"]`)).filter(t=>t.closest(this.identifier)===this)[0]}get arrow(){return Array.from(this.querySelectorAll(`[data-target~="${this.identifier}.arrow"]`)).filter(t=>t.closest(this.identifier)===this)[0]}};t([i({type:Boolean})],T.prototype,"open",void 0),t([i()],T.prototype,"placement",void 0),t([i()],T.prototype,"strategy",void 0),t([i({type:Array})],T.prototype,"clickBoundaries",void 0),T=t([s("awc-popover")],T)});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@floating-ui/dom")):"function"==typeof define&&define.amd?define(["@floating-ui/dom"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM)}(this,function(g){"use strict";function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;0<=a;a--)(s=t[a])&&(r=(o<3?s(r):3<o?s(e,i,r):s(e,i))||r);return 3<o&&r&&Object.defineProperty(e,i,r),r}const R=Symbol.for("impulse");class r{constructor(t,e){this.ctor=t,this.name=e,this.map=new Map,this.ctor=t,this.name=e,this.initialize()}add(t){var e;null!=(e=this.value)&&e.add(t)}get value(){return this.map.get(this.name)}initialize(){Object.prototype.hasOwnProperty.call(this.ctor,R)||(this.ctor[R]=new Map),this.map=this.ctor[R],this.map.has(this.name)||this.map.set(this.name,new Set)}}function e({type:i=String}={}){return(t,e)=>{new r(t,"property").add({key:e,type:i})}}function i(e){return t=>{try{window.customElements.define(e,t),window[t.name]=customElements.get(e)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}}}function n(){return(t,e)=>{new r(t,"target").add({key:e})}}function q(){return(t,e)=>{new r(t,"targets").add({key:e})}}const B=/^(?:(.+?)?(?:@(window|document))?->)?(.+)#(.+)?$/;function F(t){var[,t,e,i,n]=t.trim().match(B)||[];return{eventName:t,eventTarget:"window"===(t=e)?window:"document"===t?document:void 0,methodName:n,identifier:i}}class j{constructor(){this.map=new Map}add(t,e){H(this.map,t).add(e)}delete(t,e){H(this.map,t).delete(e),0===(null==(e=this.get(t))?void 0:e.size)&&this.map.delete(t)}clear(){this.map.clear()}get values(){return Array.from(this.map.values()).reduce((t,e)=>t.concat(Array.from(e)),[])}get(t){return this.map.get(t)}has(t,e){return!(null==(t=this.get(t))||!t.has(e))}}function H(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}class U{constructor(t,e,i,n){this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=n,this.instance=t,this.eventTarget=e,this.eventName=i,this.methodName=n}start(){this.eventTarget.addEventListener(this.eventName,this)}stop(){this.eventTarget.removeEventListener(this.eventName,this)}handleEvent(t){var e=this.instance[this.methodName];"function"==typeof e&&e.call(this.instance,t)}}function o(t,e){return(null==(t=t.getAttribute(e))?void 0:t.trim().split(/\s+/))||[]}class z{constructor(t,e,i){this.element=t,this.delegate=e,this.observerOptions=i,this.started=!1,this.element=t,this.delegate=e,this.observer=new MutationObserver(t=>this.processMutations(t)),this.observerOptions=i}start(){this.started||(this.started=!0,this.observer.observe(this.element,Object.assign({childList:!0,subtree:!0},this.observerOptions)))}stop(){this.started&&(this.observer.takeRecords(),this.observer.disconnect(),this.started=!1)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){"attributes"===t.type&&t.target instanceof Element?this.processAttributeChange(t.target,t.attributeName):"childList"===t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){e&&this.delegate.elementAttributeChanged(t,e)}processRemovedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.delegate.elementDisconnected(e)}}processAddedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);e&&this.elementIsActive(e)&&this.delegate.elementConnected(e)}}elementFromNode(t){if(t.nodeType===Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected===this.element.isConnected&&this.element.contains(t)}}class K{constructor(t,e,i){this.instance=t,this.attributeName=e,this.delegate=i,this.instance=t,this.attributeName=e,this.elementObserver=new z(this.instance,this,{attributeFilter:[this.attributeName]}),this.delegate=i}start(){this.elementObserver.start()}stop(){this.elementObserver.stop()}elementConnected(t){for(const e of this.getMatchingElements(t))this.delegate.elementConnected(e)}elementDisconnected(t){for(const e of this.getMatchingElements(t))this.delegate.elementDisconnected(e)}elementAttributeChanged(t,e){var i,n;e===this.attributeName&&null!=(n=(i=this.delegate).elementAttributeChanged)&&n.call(i,t,e)}getMatchingElements(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));return t.hasAttribute(this.attributeName)&&e.unshift(t),e}}class ${constructor(t){this.instance=t,this.instance=t}findTarget(t){return this.instance.matches(t)?this.instance:this.getElements(t).find(this.scopedTarget.bind(this))||null}findTargets(t){return[...this.instance.matches(t)?[this.instance]:[],...this.getElements(t).filter(this.scopedTarget.bind(this))]}scopedTarget(t){return t.closest(this.identifier)===this.instance}getElements(t){return Array.from(this.instance.querySelectorAll(t))}get identifier(){return this.instance.identifier}}const W="data-action";class _{constructor(t){this.instance=t,this.eventListenerMap=new j,this.instance=t,this.scope=new $(this.instance),this.attributeObserver=new K(this.instance,W,this)}start(){this.attributeObserver.start(),this.actionableElements.forEach(t=>this.bindActions(t))}stop(){this.eventListenerMap.values.forEach(t=>t.stop()),this.eventListenerMap.clear(),this.attributeObserver.stop()}elementConnected(t){this.bindActions(t)}elementDisconnected(t){this.unbindActions(t)}elementAttributeChanged(t){this.unbindActions(t),this.bindActions(t)}bindActions(s){o(s,W).forEach(t=>{var{eventName:t,eventTarget:e,methodName:i,identifier:n}=F(t);t&&n===this.identifier&&i&&this.actionableElements.includes(s)&&(n=new U(this.instance,e||s,t,i),this.eventListenerMap.add(s,n),n.start())})}unbindActions(e){var t=this.eventListenerMap.get(e);t&&t.forEach(t=>{t.stop(),this.eventListenerMap.delete(e,t)})}get actionableElements(){return this.scope.findTargets(`[${W}]`)}get identifier(){return this.instance.identifier}}const J=/(-|_|\.|\s)+(.)?/g,Q=/(^|\/)([A-Z])/g,X=/[ _]/g,Y=/([a-z\d])([A-Z])/g;function G(t){return t.replace(Y,"$1_$2").toLowerCase().replace(X,"-")}function a(t,e=""){if(!t)return e;try{return JSON.parse(t)}catch(t){return e}}class Z{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"property")}start(){for(var[{key:t,type:e}]of this.properties.entries())this.initializeProperty(t,e)}stop(){}initializeProperty(t,e){var i=G(t),n=this.instance[t],e=Object.assign({configurable:!0},function(e,i,t){switch(t){case Number:return{get:()=>Number(e.getAttribute(i)||0),set:t=>e.setAttribute(i,(t||0).toString())};case Boolean:return{get:()=>e.hasAttribute(i)&&"false"!==e.getAttribute(i),set:t=>{t?e.setAttribute(i,""):e.removeAttribute(i)}};case Array:return{get:()=>JSON.parse(e.getAttribute(i)||"[]"),set:t=>e.setAttribute(i,JSON.stringify(t)||"[]")};case Object:return{get:()=>JSON.parse(e.getAttribute(i)||"{}"),set:t=>e.setAttribute(i,JSON.stringify(t)||"{}")};default:return{get:()=>e.getAttribute(i)||"",set:t=>e.setAttribute(i,t||"")}}}(this.instance,i,e));Object.defineProperty(this.instance,t,e),this.instance.hasAttribute(i)||null!=(t=e.set)&&t.call(e,n)}get properties(){return this.store.value}}class tt{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"target"),this.scope=new $(this.instance),this.targetsByName=new j,this.attributeObserver=new K(this.instance,"data-target",this)}start(){this.attributeObserver.start(),this.keys.forEach(t=>this.initializeKey(t))}stop(){this.keys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(t){for(const n of o(t,"data-target")){var[e,i]=n.split(".");i&&!this.targetsByName.has(i,t)&&e===this.identifier&&this.keys.includes(i)&&this.findTarget(i)===t&&(this.targetsByName.add(i,t),this.defineProperty(i,this.findTarget(i)),this.invokeConnectedCallback(i,t))}}elementDisconnected(t){for(const n of o(t,"data-target")){var[e,i]=n.split(".");i&&this.targetsByName.has(i,t)&&e===this.identifier&&this.keys.includes(i)&&(this.invokeDisconnectedCallback(i,t),this.defineProperty(i,null))}}initializeKey(t){var e=this.findTarget(t);e&&this.targetsByName.add(t,e),this.defineProperty(t,e),e&&this.invokeConnectedCallback(t,e)}terminateKey(t){var e=this.findTarget(t);e&&this.invokeDisconnectedCallback(t,e)}findTarget(t){return this.scope.findTarget(`[data-target~="${this.identifier}.${t}"]`)}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}invokeConnectedCallback(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}invokeDisconnectedCallback(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}get keys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}class et{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"targets"),this.scope=new $(this.instance),this.targetsByName=new j,this.attributeObserver=new K(this.instance,"data-target",this)}start(){this.attributeObserver.start(),this.keys.forEach(t=>this.initializeKey(t))}stop(){this.keys.forEach(t=>this.terminateKey(t)),this.attributeObserver.stop()}elementConnected(t){for(const n of o(t,"data-target")){var[e,i]=n.split(".");i&&!this.targetsByName.has(i,t)&&e===this.identifier&&this.keys.includes(i)&&this.findTargets(i).includes(t)&&(this.targetsByName.add(i,t),this.defineProperty(i,this.findTargets(i)),this.invokeConnectedCallback(i,t))}}elementDisconnected(t){for(const n of o(t,"data-target")){var[e,i]=n.split(".");i&&this.targetsByName.has(i,t)&&e===this.identifier&&this.keys.includes(i)&&(this.invokeDisconnectedCallback(i,t),this.defineProperty(i,this.findTargets(i)))}}initializeKey(e){var t=this.findTargets(e);t.forEach(t=>this.targetsByName.add(e,t)),this.defineProperty(e,t),t.forEach(t=>this.invokeConnectedCallback(e,t))}terminateKey(e){this.findTargets(e).forEach(t=>this.invokeDisconnectedCallback(e,t))}findTargets(t){return this.scope.findTargets(`[data-target~="${this.identifier}.${t}"]`)}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}invokeConnectedCallback(t,e){t=this.instance[t+"Connected"];"function"==typeof t&&t.call(this.instance,e)}invokeDisconnectedCallback(t,e){t=this.instance[t+"Disconnected"];"function"==typeof t&&t.call(this.instance,e)}get keys(){return Array.from(this.store.value).map(({key:t})=>t)}get identifier(){return this.instance.identifier}}class s extends HTMLElement{constructor(){super(...arguments),this.property=new Z(this),this.targets=new et(this),this.target=new tt(this),this.action=new _(this),this._started=!1}async connectedCallback(){await new Promise(t=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t()}),customElements.upgrade(this),this.property.start(),await this._resolveUndefinedElements(),this.targets.start(),this.target.start(),this.action.start(),this._started=!0,this.setAttribute("data-impulse-element",""),this.connected()}static get observedAttributes(){var t=new r(this.prototype,"property");return Array.from(t.value).map(({key:t})=>G(t))}attributeChangedCallback(t,e,i){if(this._started&&e!==i){const o=t.replace(J,(t,e,i)=>i?i.toUpperCase():"").replace(Q,t=>t.toLowerCase());var n=this[o+"Changed"];if("function"==typeof n){var s=new r(Object.getPrototypeOf(this),"property"),s=Array.from(s.value).map(({key:t,type:e})=>({key:t,type:e})).find(({key:t})=>t===o);if(!s)throw new Error(`Unregistered attribute changed: ${t}. Register the attribute using the @property() decorator.`);var{newValue:t,oldValue:i}=function(t,e,i){switch(i){case Boolean:var n=t=>null!==t&&"false"!==t;return{newValue:n(t),oldValue:n(e)};case Number:return{newValue:Number(t),oldValue:Number(e)};case Array:return{newValue:a(t,[]),oldValue:a(e,[])};case Object:return{newValue:a(t,{}),oldValue:a(e,{})};default:return{newValue:t,oldValue:e}}}(i,e,s.type);n.call(this,t,i)}}}disconnectedCallback(){this.action.stop(),this.target.stop(),this.targets.stop(),this.property.stop(),this.disconnected(),this._started=!1}connected(){}disconnected(){}emit(t,e={}){var{target:i=this,prefix:n=this.identifier,detail:s={}}=e,e=function(t,e){var i={};for(s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]]);return i}(e,["target","prefix","detail"]),n=new CustomEvent(n?n+":"+t:t,Object.assign({bubbles:!0,composed:!0,detail:s},e));return i.dispatchEvent(n),n}get identifier(){return this.tagName.toLowerCase()}async _resolveUndefinedElements(){var t=Array.from(this.querySelectorAll(":not(:defined)")).map(t=>customElements.whenDefined(t.localName));await Promise.all(t)}}function it(t){return Number(t.replace(/[^-\d.]/g,""))}let l=class extends s{constructor(){super(...arguments),this.placement="bottom",this.active=!1,this.strategy="fixed",this.distance=0,this.skidding=0,this.flip=!0,this.flipPadding=0,this.fallbackPlacements=[],this.fallbackStrategy="bestFit",this.shift=!1,this.shiftPadding=0}connected(){this.start()}disconnected(){this.stop()}async anchorIdChanged(t){await this.stop(),t&&this.anchorElement&&this.start()}async activeChanged(t){t?this.start():await this.stop()}start(){this.anchorElement&&(this.style.position=this.strategy,this.style.top="0px",this.style.left="0px",this.cleanup=g.autoUpdate(this.anchorElement,this,this.reposition.bind(this)))}async stop(){return new Promise(t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,requestAnimationFrame(()=>t())):t()})}async reposition(){if(this.active&&this.anchorElement){var t=[g.offset({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(g.size({apply:({rects:t})=>{var e="width"===this.sync||"both"===this.sync,i="height"===this.sync||"both"===this.sync;this.style.width=e?t.reference.width+"px":"",this.style.height=i?t.reference.height+"px":""}})):(this.style.width="",this.style.height=""),this.flip&&t.push(g.flip({fallbackPlacements:this.fallbackPlacements.length?this.fallbackPlacements:void 0,fallbackStrategy:this.fallbackStrategy,padding:this.flipPadding})),this.shift&&t.push(g.shift({padding:this.shiftPadding})),this.arrowElement&&t.push(g.arrow({element:this.arrowElement,padding:this._arrowPadding}));const{x:e,y:i,placement:n,strategy:s,middlewareData:o}=await g.computePosition(this.anchorElement,this,{placement:this.placement,middleware:t,strategy:this.strategy});if(Object.assign(this.style,{left:e+"px",top:i+"px",position:s}),o.arrow&&this.arrowElement){const{x:e,y:i}=o.arrow;Object.assign(this.arrowElement.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}this.setAttribute("x-placement",n)}}get anchorElement(){return document.getElementById(this.anchorId)}get arrowElement(){return this.querySelector("[data-arrow]")}get _arrowPadding(){return"number"==typeof this.arrowPadding?this.arrowPadding:it(getComputedStyle(this).borderRadius)||2}};t([e()],l.prototype,"anchorId",void 0),t([e()],l.prototype,"placement",void 0),t([e({type:Boolean})],l.prototype,"active",void 0),t([e()],l.prototype,"strategy",void 0),t([e({type:Number})],l.prototype,"distance",void 0),t([e({type:Number})],l.prototype,"skidding",void 0),t([e()],l.prototype,"sync",void 0),t([e({type:Boolean})],l.prototype,"flip",void 0),t([e({type:Number})],l.prototype,"flipPadding",void 0),t([e({type:Array})],l.prototype,"fallbackPlacements",void 0),t([e()],l.prototype,"fallbackStrategy",void 0),t([e({type:Boolean})],l.prototype,"shift",void 0),t([e({type:Number})],l.prototype,"shiftPadding",void 0),t([e({type:Number})],l.prototype,"arrowPadding",void 0),l=t([i("awc-anchor")],l);var nt=0;function st(){return nt+=1,`ambiki-${Math.random().toString().slice(2,6)}-`+nt}function ot(t){return!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled")}var rt=!!navigator.userAgent.match(/Macintosh/),at=class{input;list;multiple;isMouseMoving=!1;constructor(t,e,{multiple:i=!1}={}){this.input=t,this.list=e,this.multiple=i,this.list.id||(this.list.id=st()),this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.multiple&&this.input.setAttribute("aria-multiselectable","true"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-haspopup","listbox"),this.input.setAttribute("aria-autocomplete","list"),this.list.setAttribute("role","listbox"),this.onKeydown=this.onKeydown.bind(this),this.onClick=this.onClick.bind(this),this.onListMouseover=this.onListMouseover.bind(this),this.onListMousemove=this.onListMousemove.bind(this)}start(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","true"),this.input.setAttribute("aria-controls",this.list.id),this.input.addEventListener("keydown",this.onKeydown),this.list.addEventListener("click",this.onClick),this.list.addEventListener("mouseover",this.onListMouseover),this.list.addEventListener("mousemove",this.onListMousemove),this.initializeOptions()}stop(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","false"),this.input.removeAttribute("aria-controls"),this.input.removeEventListener("keydown",this.onKeydown),this.list.removeEventListener("click",this.onClick),this.list.removeEventListener("mouseover",this.onListMouseover),this.list.removeEventListener("mousemove",this.onListMousemove),this.deselectAll(),this.deactivate()}onKeydown(t){if(this.isMouseMoving=!1,!(t.shiftKey||t.metaKey||t.altKey||!rt&&t.ctrlKey))switch(t.key){case"Enter":case"Tab":this.activeOption&&ot(this.activeOption)&&(t.preventDefault(),t.stopPropagation(),this.activeOption.click());break;case"Escape":this.deactivate();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(1):this.activate(this.visibleOptions[0],{scroll:!0});break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(-1):this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;case"Home":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[0],{scroll:!0});break;case"End":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;default:t.ctrlKey||this.deactivate()}}onClick(t){t=lt(t.target);t&&ot(t)&&(this.multiple&&this.isSelected(t)?this.deselect(t):this.select(t),t.dispatchEvent(new CustomEvent("combobox:commit",{bubbles:!0})))}onListMouseover(t){var e;this.isMouseMoving?(e=lt(t.target))&&this.activate(e):t.preventDefault()}onListMousemove(t){!this.isMouseMoving&&(this.isMouseMoving=!0,t=lt(t.target))&&this.activate(t)}select(t){if(this.multiple)t.setAttribute("aria-selected","true");else for(var e of this.options)e.setAttribute("aria-selected",(e===t).toString())}deselect(t){t.setAttribute("aria-selected","false")}deselectAll(){for(var t of this.options)this.deselect(t)}activate(t,{scroll:e=!1}={}){for(var i of this.options)i.id===t.id?(i.setAttribute("data-active",""),this.input.setAttribute("aria-activedescendant",i.id),e&&i.scrollIntoView({block:"nearest"})):i.removeAttribute("data-active")}deactivate(){this.input.removeAttribute("aria-activedescendant");for(var t of Array.from(this.list.querySelectorAll('[role="option"][data-active]')))t.removeAttribute("data-active")}isSelected(t){return"true"===t.getAttribute("aria-selected")}get options(){return Array.from(this.list.querySelectorAll('[role="option"]'))}get visibleOptions(){return this.options.filter(ct)}get activeOption(){return this.list.querySelector("[data-active]")}move(t){this.activeOption&&(t=function(t,e,i){let n=t.indexOf(e),s=(n===t.length-1&&1===i&&(n=-1),1===i?0:t.length-1);return t[s=e&&0<=n&&0<=(e=n+i)&&e<t.length?e:s]}(this.visibleOptions,this.activeOption,t),this.activate(t,{scroll:!0}))}initializeOptions(){for(var t of this.options)t.setAttribute("tabindex","-1"),t.id||(t.id=st()),t.hasAttribute("aria-selected")||this.deselect(t)}};function lt(t){return t&&t.closest('[role="option"]')||!1}function ct(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(0<t.offsetWidth||0<t.offsetHeight)}function c(t,e){void 0===e&&(e=!0);var i=null==t||null==(i=t.getAttribute)?void 0:i.call(t,"inert");return""===i||"true"===i||e&&t&&c(t.parentNode)}function ht(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))}function ut(t){var e,i;if(t)return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||""===(i=null==(e=t)||null==(i=e.getAttribute)?void 0:i.call(e,"contenteditable"))||"true"===i)&&!ht(t)?0:t.tabIndex;throw new Error("No node provided")}function dt(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex}function pt(t){return"INPUT"===t.tagName}function ft(t){if(!t.name)return 1;function e(t){return i.querySelectorAll('input[type="radio"][name="'+t+'"]')}var i=t.form||p(t);if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)n=e(window.CSS.escape(t.name));else try{n=e(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),0}var n=function(t,e){for(var i=0;i<t.length;i++)if(t[i].checked&&t[i].form===e)return t[i]}(n,t.form);return!n||n===t}function mt(t){return pt(e=t)&&"radio"===e.type&&!ft(t);var e}function vt(t){var e=(t=t.getBoundingClientRect()).width,t=t.height;return 0===e&&0===t}function gt(t,e){var i=e.displayCheck,n=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return 1;if(e=d.call(t,"details>summary:first-of-type")?t.parentElement:t,d.call(e,"details:not([open]) *"))return 1;if(i&&"full"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return vt(t)}else{if("function"==typeof n){for(e=t;t;){var s=t.parentElement,o=p(t);if(s&&!s.shadowRoot&&!0===n(s))return vt(t);t=t.assignedSlot||(s||o===t.ownerDocument?s:o.host)}t=e}if(function(t){var e,i=t&&p(t),n=null==(e=i)?void 0:e.host,s=!1;if(i&&i!==t)for(s=!!(null!=(e=n)&&null!=(e=e.ownerDocument)&&e.contains(n)||null!=t&&null!=(e=t.ownerDocument)&&e.contains(t));!s&&n;)var o,s=!(null==(o=n=null==(o=i=p(n))?void 0:o.host)||null==(o=o.ownerDocument)||!o.contains(n));return s}(t))return!t.getClientRects().length;if("legacy-full"!==i)return 1}}function bt(t,e){return t=(e=e||{}).getShadowRoot?Et([t],e.includeContainer,{filter:St.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:Ot}):At(t,e.includeContainer,St.bind(null,e)),kt(t)}function u(t,e){if(e=e||{},t)return!1!==d.call(t,xt)&&f(e,t);throw new Error("No node provided")}var yt=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],wt=yt.join(","),h="undefined"==typeof Element,d=h?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,p=!h&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},At=function(t,e,i){var n;return c(t)?[]:(n=Array.prototype.slice.apply(t.querySelectorAll(wt)),e&&d.call(t,wt)&&n.unshift(t),n.filter(i))},Et=function t(e,i,n){for(var s=[],o=Array.from(e);o.length;){var r,a,l=o.shift();c(l,!1)||("SLOT"===l.tagName?(r=t((r=l.assignedElements()).length?r:l.children,!0,n),n.flatten?s.push.apply(s,r):s.push({scopeParent:l,candidates:r})):(d.call(l,wt)&&n.filter(l)&&(i||!e.includes(l))&&s.push(l),r=l.shadowRoot||"function"==typeof n.getShadowRoot&&n.getShadowRoot(l),a=!c(r,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(l)),r&&a?(a=t((!0===r?l:r).children,!0,n),n.flatten?s.push.apply(s,a):s.push({scopeParent:l,candidates:a})):o.unshift.apply(o,l.children)))}return s},f=function(t,e){var i;return!(e.disabled||c(e)||pt(i=e)&&"hidden"===i.type||gt(e,t)||"DETAILS"===(i=e).tagName&&Array.prototype.slice.apply(i.children).some(function(t){return"SUMMARY"===t.tagName})||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var n=e.children.item(i);if("LEGEND"===n.tagName)return!!d.call(e,"fieldset[disabled] *")||!n.contains(t)}return!0}e=e.parentElement}return!1}(e))},St=function(t,e){return!(mt(e)||ut(e)<0||!f(t,e))},Ot=function(t){t=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(t)||0<=t)},kt=function a(t){var l=[],c=[];return t.forEach(function(t,e){var i,n=!!t.scopeParent,s=n?t.scopeParent:t,o=(o=n,(i=ut(r=s))<0&&o&&!ht(r)?0:i),r=n?a(t.candidates):s;0===o?n?l.push.apply(l,r):l.push(s):c.push({documentOrder:e,tabIndex:o,item:t,isScope:n,content:r})}),c.sort(dt).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(l)},xt=yt.concat("iframe").join(",");function Ct(t){let e=t;for(;null!==e;){if(u(e)||e.hasAttribute("data-loosely-focusable"))return 1;e=e.parentElement}}function Tt(t,{referenceElement:r,popupElement:a,arrowElement:l,arrowPadding:c=0,middleware:h=[],offsetOptions:u=0,placement:d="bottom-start",flipOptions:p,shiftOptions:f,strategy:m="fixed",sync:v}){let e;async function i(t=!1){if(t&&r){t=[g.offset(u)];v?t.push(g.size({apply:({rects:t})=>{var e="height"===v||"both"===v;a.style.width="width"===v||"both"===v?t.reference.width+"px":"",a.style.height=e?t.reference.height+"px":""}})):(a.style.width="",a.style.height=""),t.push(g.flip(p)),t.push(g.shift(f)),l&&t.push(g.arrow({element:l,padding:c})),t.concat(h);const{x:e,y:i,placement:n,strategy:s,middlewareData:o}=await g.computePosition(r,a,{placement:d,middleware:t,strategy:m});if(Object.assign(a.style,{left:e+"px",top:i+"px",position:s}),o.arrow&&l){const{x:e,y:i}=o.arrow;Object.assign(l.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}a.setAttribute("x-placement",n)}}async function n(){return new Promise(t=>{e?(e(),e=void 0,requestAnimationFrame(()=>t())):t()})}a.style.position=m,a.style.top="0px",a.style.left="0px",r&&(e=g.autoUpdate(r,a,()=>i(!0)),n());const s=t.disconnected.bind(t);return Object.assign(t,{disconnected(){n(),s()}}),{start:function(){r&&(e=g.autoUpdate(r,a,()=>i(t.open)))},update:async function(){await i(t.open)},stop:n}}function Nt(t,{boundaries:s,callback:o}){let r=null;function e(t){var e;r=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target}function i(t,e){if(r&&!t.defaultPrevented){var i=e(t);if(i&&i.getRootNode().contains(i)&&i.isConnected){for(const n of s)if(null!==n){if(n.contains(i))return;if(t.composed&&t.composedPath().includes(n))return}o(t,i),r=null}}}document.addEventListener("mousedown",e,!0),document.addEventListener("click",t=>i(t,()=>r),!0);const n=t.disconnected.bind(t);Object.assign(t,{disconnected(){r=null,document.removeEventListener("mousedown",e,!0),document.removeEventListener("click",t=>i(t,()=>r),!0),n()}})}function m(t){return t.getAttribute("value")||""}function v(t){return t.getAttribute("data-text")||t.innerText.trim()}class Lt{constructor(t){this.autocomplete=t,this.selectedValues=new Set,this.defaultSelectedValues=[],this.autocomplete=t}connected(){(function(t){try{return JSON.parse(t).map(t=>t.toString())}catch(t){return[]}})(this.autocomplete.value).forEach(t=>this.selectedValues.add(t)),this.defaultSelectedValues=this.persistedTags.map(t=>({value:m(t),text:v(t)}))}disconnected(){}start(){for(const t of this.autocomplete.options)this.selectedValues.has(m(t))?this.autocomplete.combobox.select(t):this.autocomplete.combobox.deselect(t)}stop(){this.clearInputField()}async commit(t){this.clearInputField();const e=m(t);t=v(t);if(this.selectedValues.has(e)?this.removeValue(e):this.setValue(e,t),this.autocomplete.src){await this.autocomplete.makeRequest(""),this.start();t=this.autocomplete.visibleOptions.find(t=>m(t)===e)||this.autocomplete.visibleOptions[0];t&&this.autocomplete.activate(t)}else{for(const t of this.autocomplete.options)t.hidden=!1;for(const i of this.autocomplete.groups)i.hidden=!1}}clear(){this.selectedValues.forEach(t=>this.removeValue(t))}reset(){this.clear(),this.defaultSelectedValues.forEach(({value:t,text:e})=>this.setValue(t,e,{persisted:!0}))}setValue(e,t,{persisted:i=!1}={}){this.selectedValues.has(e)||(this.selectedValues.add(e),this.insertTag(e,t,{persisted:i}),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),this.autocomplete.open&&(t=this.autocomplete.options.find(t=>m(t)===e))&&this.autocomplete.combobox.select(t))}removeValue(e){var t;this.selectedValues.has(e)&&(this.selectedValues.delete(e),this.removeTag(e),this.updateElementValue(),this.setRequiredAttribute(this.autocomplete.required),t=this.autocomplete.options.find(t=>m(t)===e))&&this.autocomplete.combobox.deselect(t)}setRequiredAttribute(t){!t||0<this.selectedValues.size?this.autocomplete.input.required=!1:this.autocomplete.input.required=!0}insertTag(t,e,{persisted:i=!1}={}){var n=this.template.content.cloneNode(!0),s=n.querySelector('[data-behavior="tag"]'),o=n.querySelector('[data-behavior="text"]'),r=n.querySelector('[data-behavior="hidden-field"]');null!=s&&s.setAttribute("value",t),null!=s&&s.toggleAttribute("data-persisted",i),o&&(o.innerText=e),r&&(r.value=t),this.autocomplete.control.insertBefore(n,this.template)}removeTag(e){var t=this.tags.find(t=>m(t)===e);null!=t&&t.remove()}updateElementValue(){var t=Array.from(this.selectedValues.values());this.autocomplete.value=JSON.stringify(t)}clearInputField(){this.autocomplete.input.value&&(this.autocomplete.input.value="")}get firstActiveOption(){return this.autocomplete.visibleOptions.find(t=>this.selectedValues.has(m(t)))||this.autocomplete.visibleOptions[0]}get tags(){return Array.from(this.autocomplete.querySelectorAll('[data-behavior="tag"]'))}get persistedTags(){return this.tags.filter(t=>t.hasAttribute("data-persisted"))}get template(){return this.autocomplete.querySelector('[data-behavior="tag-template"]')}}class Pt{constructor(t){this.autocomplete=t,this.defaultValue="",this.defaultText="",this.autocomplete=t}connected(){this.defaultValue=this.hiddenField.value,this.defaultText=this.hiddenField.getAttribute("data-text")||""}disconnected(){}start(){this.selectedOption&&this.autocomplete.combobox.select(this.selectedOption)}stop(){this.autocomplete.input.value=this.hiddenField.getAttribute("data-text")||""}commit(t){var e=m(t),t=v(t);this.setValue(e,t),this.autocomplete.open=!1}clear(){this.setValue(null,null)}reset(){this.setValue(this.defaultValue,this.defaultText)}setValue(t,e){this.autocomplete.value=t||"",this.autocomplete.input.value=e||"",this.hiddenField.value=t||"",this.hiddenField.setAttribute("data-text",e||""),null===t?this.autocomplete.combobox.deselectAll():this.autocomplete.open&&(e=this.autocomplete.options.find(t=>m(t)===this.defaultValue))&&this.autocomplete.combobox.select(e)}removeValue(){this.clear()}setRequiredAttribute(t){this.autocomplete.input.required=t}get firstActiveOption(){return this.selectedOption||this.autocomplete.visibleOptions[0]}get selectedOption(){return this.autocomplete.options.find(t=>this.isSelected(t))}isSelected(t){return m(t)===this.autocomplete.value}get hiddenField(){return this.autocomplete.querySelector('[data-behavior="hidden-field"]')}}let b=class extends s{constructor(){super(),this.open=!1,this.disabled=!1,this.required=!1,this.multiple=!1,this.param="q",this.singleSelect=new Pt(this),this.multipleSelect=new Lt(this),this.firstFocus=!0,this.inputPristine=!1,this.remoteSearch=function(e,i){let n;function t(...t){clearTimeout(n),n=setTimeout(()=>{e.apply(this,t)},i)}return t.clear=()=>{clearTimeout(n)},t}(this.remoteSearch.bind(this),300),this.handleFormReset=this.handleFormReset.bind(this)}connected(){var t;this.floatingUI=Tt(this,{referenceElement:this.control,popupElement:this.listbox,placement:"bottom",sync:"width",offsetOptions:4}),Nt(this,{boundaries:[this.control,this.listbox],callback:(t,e)=>{this.inputPristine&&!Ct(e)?t.preventDefault():this.open&&(this.open=!1),this.inputPristine=!1}}),this.combobox=new at(this.input,this.listbox,{multiple:this.multiple}),this.selectVariant=this.multiple?this.multipleSelect:this.singleSelect,this.selectVariant.connected(),null!=(t=this.form)&&t.addEventListener("reset",this.handleFormReset),this.selectVariant.setRequiredAttribute(this.required)}disconnected(){var t;this.open=!1,this.removeAttribute("data-focus"),this.firstFocus=!0,null!=(t=this.selectVariant)&&t.disconnected(),this.abortController=void 0,null!=(t=this.form)&&t.removeEventListener("reset",this.handleFormReset)}async openChanged(t){if(t)this.emit("show"),this.combobox.start(),this.listbox.hidden=!1,this.floatingUI.start(),this.src?await this.makeRequest(""):this.checkIfListIsEmpty(),null!=(t=this.selectVariant)&&t.start(),null!=(t=this.selectVariant)&&t.firstActiveOption&&this.activate(this.selectVariant.firstActiveOption),this.emit("shown");else{if(this.emit("hide"),this.listbox.hidden=!0,null!=(t=this.abortController)&&t.abort(),null!=(t=this.selectVariant)&&t.stop(),this.combobox.stop(),!this.src){for(const e of this.options)e.hidden=!1;for(const i of this.groups)i.hidden=!1}this.removeAttribute("no-options"),this.removeAttribute("error"),this.inputPristine=!1,this.currentQuery=void 0,await this.floatingUI.stop(),this.emit("hidden")}}valueChanged(t){this.classList.toggle("awc-autocomplete--selected",""!==t&&"[]"!==t)}disabledChanged(t){if(this.input.disabled=t,this.clearBtn&&(this.clearBtn.disabled=t),this.multiple&&this.tagDismissBtns)for(const e of this.tagDismissBtns)e.disabled=t}requiredChanged(t){var e;null!=(e=this.selectVariant)&&e.setRequiredAttribute(t)}handleMousedown(t){t.target!==this.input&&t.preventDefault()}handleClick(t){this.disabled||(this.input.focus(),t=t.target["classList"],(t.contains("awc-autocomplete-control")||t.contains("awc-autocomplete-end-adornment"))&&(this.open=!0),this.firstFocus&&this.input.value&&this.input.select(),this.firstFocus=!1)}handleInputMousedown(t){t.preventDefault(),this.open=!0}handleInputFocus(){this.setAttribute("data-focus","")}handleInputBlur(){this.open&&(this.open=!1,this.inputPristine=!0),this.removeAttribute("data-focus"),this.firstFocus=!0}handleInputKeydown(t){switch(t.key){case"Enter":this.open&&t.preventDefault();break;case"Escape":this.open&&(t.preventDefault(),t.stopPropagation(),this.open=!1);break;case"ArrowDown":t.altKey&&!this.open&&(t.preventDefault(),this.open=!0);break;case"ArrowUp":t.altKey&&this.open&&(t.preventDefault(),this.open=!1);break;case"Backspace":var e;""===this.input.value&&this.multiple&&(e=this.multipleSelect["tags"],e=e[e.length-1])&&(t.preventDefault(),this.multipleSelect.removeValue(m(e)),this.emit("remove",{detail:{target:e}}))}}async handleInput(t){var t=t["target"];t instanceof HTMLInputElement&&(t=t.value.trim(),this.src?await this.remoteSearch(t):this.search(t))}async handleCommit(t){t.stopPropagation();var e,t=t.target;t instanceof HTMLElement&&(await(null==(e=this.selectVariant)?void 0:e.commit(t)),this.emit("commit",{detail:{target:t}}))}handleClear(){this.open=!1,this.clear(),this.emit("clear")}handleTagRemove(t){t=t.target.closest('[data-behavior="tag"]');t&&(this.multipleSelect.removeValue(m(t)),this.emit("remove",{detail:{target:t}}))}handleFormReset(){this.open=!1,this.reset(),this.emit("reset")}setValue(t,e){var i;null!=(i=this.selectVariant)&&i.setValue(t,e)}removeValue(t){this.multiple&&t?this.multipleSelect.removeValue(t):this.singleSelect.removeValue()}activate(t,{scroll:e=!0}={}){this.combobox.activate(t,{scroll:e})}deactivate(){this.combobox.deactivate()}clear(){var t;null!=(t=this.selectVariant)&&t.clear(),this.currentQuery=void 0}reset(){var t;null!=(t=this.selectVariant)&&t.reset(),this.currentQuery=void 0}focus(t){this.input.focus(t)}blur(){this.input.blur(),this.removeAttribute("data-focus")}show(){this.open||(this.open=!0)}hide(){this.open&&(this.open=!1)}search(t){var n;this.open=!0,this.options.forEach((n=t,t=>{var e,i=t.closest('[role="group"]');n?(e=null==(e=v(t))?void 0:e.toLowerCase().includes(n.toLowerCase()),t.hidden=!e,i&&(e=Array.from(i.querySelectorAll('[role="option"]')),i.hidden=e.every(t=>t.hidden))):(t.hidden=!1,i&&(i.hidden=!1))})),this.checkIfListIsEmpty(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async remoteSearch(t){this.open=!0,await this.makeRequest(t),null!=(t=this.selectVariant)&&t.start(),this.visibleOptions[0]&&this.activate(this.visibleOptions[0])}async makeRequest(t){if(this.currentQuery!==t){this.currentQuery=t,this.abortController?this.abortController.abort():(this.setAttribute("loading",""),this.emit("loadstart",{bubbles:!1,prefix:!1})),this.removeAttribute("error"),this.abortController=new AbortController;var e=new URL(this.src,window.location.href),i=new URLSearchParams(e.search.slice(1));i.append(this.param,t),e.search=i.toString();try{var n=await fetch(e.toString(),{signal:this.abortController.signal,credentials:"same-origin",headers:{accept:"text/fragment+html"}});if(!n.ok)throw new Error;this.optionsContainer.innerHTML=await n.text(),this.checkIfListIsEmpty(),this.combobox.initializeOptions(),this.abortController=void 0,await this.floatingUI.update(),this.emit("load",{bubbles:!1,prefix:!1})}catch(t){t instanceof Error&&"AbortError"!==t.name&&(this.abortController=void 0,this.setAttribute("error",""),this.emit("error",{bubbles:!1,prefix:!1}))}finally{this.removeAttribute("loading"),this.emit("loadend",{bubbles:!1,prefix:!1})}}}checkIfListIsEmpty(){this.toggleAttribute("no-options",0===this.visibleOptions.length)}get activeOption(){return this.combobox.activeOption}get visibleOptions(){return this.options.filter(t=>!t.hidden)}get options(){return this.combobox.options}get form(){return this.closest("form")}};t([e({type:Boolean})],b.prototype,"open",void 0),t([e()],b.prototype,"value",void 0),t([e({type:Boolean})],b.prototype,"disabled",void 0),t([e({type:Boolean})],b.prototype,"required",void 0),t([e({type:Boolean})],b.prototype,"multiple",void 0),t([e()],b.prototype,"src",void 0),t([e()],b.prototype,"param",void 0),t([n()],b.prototype,"input",void 0),t([n()],b.prototype,"listbox",void 0),t([n()],b.prototype,"control",void 0),t([n()],b.prototype,"optionsContainer",void 0),t([n()],b.prototype,"clearBtn",void 0),t([q()],b.prototype,"tagDismissBtns",void 0),t([q()],b.prototype,"groups",void 0),b=t([i("awc-autocomplete")],b);let y=class extends s{constructor(){super(...arguments),this.hideOnOutsideClick=!0,this.controller=new AbortController}connected(){this.trigger&&this.trigger.addEventListener("click",this.handleTriggerClick.bind(this),{signal:this.controller.signal})}disconnected(){this.hide(),this.controller.abort()}handleTriggerClick(){var t;null!=(t=this.trigger)&&t.setAttribute("aria-expanded","true"),this.show()}handleClose(){var t;null!=(t=this.trigger)&&t.setAttribute("aria-expanded","false"),this.closest("dialog[open]")||(document.body.style.removeProperty("padding-right"),document.body.style.removeProperty("overflow"))}show(){this.dialog.showModal(),document.body.style.paddingRight=window.innerWidth-document.body.clientWidth+"px",document.body.style.overflow="hidden"}hide(){this.dialog.close()}handleOutsideClick(t){var e;this.hideOnOutsideClick&&!t.defaultPrevented&&(e=t.target)instanceof HTMLElement&&e===this.dialog&&((e=e.getBoundingClientRect()).top<=t.clientY&&t.clientY<=e.top+e.height&&e.left<=t.clientX&&t.clientX<=e.left+e.width||this.hide())}get trigger(){return document.getElementById(this.triggerId)}get open(){return this.dialog.open}};t([e()],y.prototype,"triggerId",void 0),t([e({type:Boolean})],y.prototype,"hideOnOutsideClick",void 0),t([n()],y.prototype,"dialog",void 0),y=t([i("awc-dialog")],y);var w=class extends Event{oldState;newState;constructor(t,{oldState:e="",newState:i="",...n}={}){super(t,n),this.oldState=String(e||""),this.newState=String(i||"")}},Mt=new WeakMap;function Dt(t,e,i){Mt.set(t,setTimeout(()=>{Mt.has(t)&&t.dispatchEvent(new w("toggle",{cancelable:!1,oldState:e,newState:i}))},0))}var Vt=globalThis.ShadowRoot||function(){},It=globalThis.HTMLDialogElement||function(){},A=new WeakMap,E=new WeakMap,S=new WeakMap;function O(t){return S.get(t)||"hidden"}var k=new WeakMap;function x(t,e){return("auto"===t.popover||"manual"===t.popover)&&t.isConnected&&!(e&&"showing"!==O(t)||!e&&"hidden"!==O(t)||t instanceof It&&t.hasAttribute("open")||document.fullscreenElement===t)}function Rt(t){return t?Array.from(E.get(t.ownerDocument)||[]).indexOf(t)+1:0}function qt(t){var e=Bt(t),t=function(t){for(;t;){var e=t.popoverTargetElement;if(e instanceof HTMLElement)return e;if((t=(t=t.parentElement||T(t))instanceof Vt?t.host:t)instanceof Document)return}}(t);return Rt(e)>Rt(t)?e:t}function C(t){var e=E.get(t);for(const i of e||[]){if(i.isConnected)return i;e.delete(i)}return null}function T(t){return"function"==typeof t.getRootNode?t.getRootNode():t.parentNode?T(t.parentNode):t}function Bt(t){for(;t;){if(t instanceof HTMLElement&&"auto"===t.popover&&"showing"===S.get(t))return t;if((t=(t=t.parentElement||T(t))instanceof Vt?t.host:t)instanceof Document)return}}function Ft(t){if(t.shadowRoot&&!0!==t.shadowRoot.delegatesFocus)return null;let e=t,i=(e=e.shadowRoot?e.shadowRoot:e).querySelector("[autofocus]");if(i)return i;for(const r of e.querySelectorAll("slot"))for(const a of r.assignedElements({flatten:!0})){if(a.hasAttribute("autofocus"))return a;if(i=a.querySelector("[autofocus]"))return i}var n,s=t.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=s.currentNode;for(;o;){if(!((n=o).hidden||n instanceof Vt||(n instanceof HTMLButtonElement||n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement||n instanceof HTMLOptGroupElement||n instanceof HTMLOptionElement||n instanceof HTMLFieldSetElement)&&n.disabled||n instanceof HTMLInputElement&&"hidden"===n.type||n instanceof HTMLAnchorElement&&""===n.href||"number"!=typeof n.tabIndex||-1===n.tabIndex))return o;o=s.nextNode()}}var N=new WeakMap;function jt(e){if(x(e,!1)){var i=e.ownerDocument;if(e.dispatchEvent(new w("beforetoggle",{cancelable:!0,oldState:"closed",newState:"open"}))&&x(e,!1)){let t=!1;if("auto"===e.popover){var n=e.getAttribute("popover");if(P(function(t){const e=new Map;let i=0;var n=t.ownerDocument;for(const o of E.get(n)||[])e.set(o,i),i+=1;e.set(t,i),i+=1;let s=null;return n=t?.parentElement,s=null!==(n=Bt(n))&&(t=e.get(n),null===s||e.get(s)<t)?n:s}(e)||i,!1,!0),n!==e.getAttribute("popover")||!x(e,!1))return}C(i)||(t=!0),N.delete(e);n=i.activeElement;e.classList.add(":popover-open"),S.set(e,"showing"),A.has(i)||A.set(i,new Set),A.get(i).add(e),Ft(e)?.focus(),"auto"===e.popover&&(E.has(i)||E.set(i,new Set),E.get(i).add(e),$t(k.get(e),!0)),t&&n&&"auto"===e.popover&&N.set(e,n),Dt(e,"closed","open")}}}function L(t,e=!1,i=!1){var n;x(t,!0)&&(n=t.ownerDocument,"auto"===t.popover&&(P(t,e,i),!x(t,!0))||($t(k.get(t),!1),k.delete(t),i&&(t.dispatchEvent(new w("beforetoggle",{oldState:"open",newState:"closed"})),!x(t,!0)))||(A.get(n)?.delete(t),E.get(n)?.delete(t),t.classList.remove(":popover-open"),S.set(t,"hidden"),i&&Dt(t,"open","closed"),(n=N.get(t))&&(N.delete(t),e)&&n.focus()))}function Ht(t,e=!1,i=!1){let n=C(t);for(;n;)L(n,e,i),n=C(t)}function P(t,e,i){var n=t.ownerDocument||t;if(t instanceof Document)return Ht(n,e,i);let s=null,o=!1;for(const r of E.get(n)||[])if(r===t)o=!0;else if(o){s=r;break}if(!o)return Ht(n,e,i);for(;s&&"showing"===O(s)&&E.get(n)?.size;)L(s,e,i)}var Ut=new WeakMap;function zt(t){var e,i;t.isTrusted&&(i=t.composedPath()[0])&&C(e=i.ownerDocument)&&((i=qt(i))&&"pointerdown"===t.type?Ut.set(e,i):"pointerup"===t.type&&(t=Ut.get(e)===i,Ut.delete(e),t)&&P(i||e,!1,!0))}var Kt=new WeakMap;function $t(t,e=!1){var i;t&&(Kt.has(t)||Kt.set(t,t.getAttribute("aria-expanded")),(i=t.popoverTargetElement)instanceof HTMLElement&&"auto"===i.popover?t.setAttribute("aria-expanded",String(e)):(i=Kt.get(t))?t.setAttribute("aria-expanded",i):t.removeAttribute("aria-expanded"))}var Wt=globalThis.ShadowRoot||function(){};function M(t,e,i){const n=t[e];Object.defineProperty(t,e,{value(t){return n.call(this,i(t))}})}var _t=/(^|[^\\]):popover-open\b/g,h="function"==typeof window.CSSLayerBlockRule,Jt=`
2
+ ${h?"@layer popover-polyfill {":""}
3
+ :where([popover]) {
4
+ position: fixed;
5
+ z-index: 2147483647;
6
+ inset: 0;
7
+ padding: 0.25em;
8
+ width: fit-content;
9
+ height: fit-content;
10
+ border-width: initial;
11
+ border-color: initial;
12
+ border-image: initial;
13
+ border-style: solid;
14
+ background-color: canvas;
15
+ color: canvastext;
16
+ overflow: auto;
17
+ margin: auto;
18
+ }
19
+
20
+ :where(dialog[popover][open]) {
21
+ display: revert;
22
+ }
23
+
24
+ :where([anchor].\\:popover-open) {
25
+ inset: auto;
26
+ }
27
+
28
+ :where([anchor]:popover-open) {
29
+ inset: auto;
30
+ }
31
+
32
+ @supports not (background-color: canvas) {
33
+ :where([popover]) {
34
+ background-color: white;
35
+ color: black;
36
+ }
37
+ }
38
+
39
+ @supports (width: -moz-fit-content) {
40
+ :where([popover]) {
41
+ width: -moz-fit-content;
42
+ height: -moz-fit-content;
43
+ }
44
+ }
45
+
46
+ @supports not (inset: 0) {
47
+ :where([popover]) {
48
+ top: 0;
49
+ left: 0;
50
+ right: 0;
51
+ bottom: 0;
52
+ }
53
+ }
54
+
55
+ :where([popover]:not(.\\:popover-open)) {
56
+ display: none;
57
+ }
58
+ ${h?"}":""}
59
+ `,D=null;function Qt(t){if(null===D)try{(D=new CSSStyleSheet).replaceSync(Jt)}catch{D=!1}var e;!1===D?((e=document.createElement("style")).textContent=Jt,(t instanceof Document?t.head:t).prepend(e)):t.adoptedStyleSheets=[D,...t.adoptedStyleSheets]}function Xt(){function t(t){return t=t?.includes(":popover-open")?t.replace(_t,"$1.\\:popover-open"):t}window.ToggleEvent=window.ToggleEvent||w,M(Document.prototype,"querySelector",t),M(Document.prototype,"querySelectorAll",t),M(Element.prototype,"querySelector",t),M(Element.prototype,"querySelectorAll",t),M(Element.prototype,"matches",t),M(Element.prototype,"closest",t),M(DocumentFragment.prototype,"querySelectorAll",t),M(DocumentFragment.prototype,"querySelectorAll",t),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){var t;return this.hasAttribute("popover")?""===(t=(this.getAttribute("popover")||"").toLowerCase())||"auto"==t?"auto":"manual":null},set(t){this.setAttribute("popover",t)}},showPopover:{enumerable:!0,configurable:!0,value(){jt(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){L(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(t){"showing"===S.get(this)&&void 0===t||!1===t?L(this,!0,!0):void 0!==t&&!0!==t||jt(this)}}});const e=Element.prototype.attachShadow,i=(e&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(t){t=e.call(this,t);return Qt(t),t}}}),HTMLElement.prototype.attachInternals),n=(i&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){var t=i.call(this);return t.shadowRoot&&Qt(t.shadowRoot),t}}}),new WeakMap);function s(t){Object.defineProperties(t.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(t){if(null===t)this.removeAttribute("popovertarget"),n.delete(this);else{if(!(t instanceof Element))throw new TypeError("popoverTargetElement must be an element or null");this.setAttribute("popovertarget",""),n.set(this,t)}},get(){var t,e;return"button"!==this.localName&&"input"!==this.localName||"input"===this.localName&&"reset"!==this.type&&"image"!==this.type&&"button"!==this.type||this.disabled||this.form&&"submit"===this.type?null:(t=n.get(this))&&t.isConnected?t:t&&!t.isConnected?(n.delete(this),null):(t=T(this),e=this.getAttribute("popovertarget"),(t instanceof Document||t instanceof Wt)&&e&&t.getElementById(e)||null)}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){var t=(this.getAttribute("popovertargetaction")||"").toLowerCase();return"show"===t||"hide"===t?t:"toggle"},set(t){this.setAttribute("popovertargetaction",t)}}})}s(HTMLButtonElement),s(HTMLInputElement);const o=t=>{var e,i=t.composedPath(),n=i[0];n instanceof Element&&!n?.shadowRoot&&((n=T(n))instanceof Wt||n instanceof Document)&&(n=i.find(t=>t.matches?.("[popovertargetaction],[popovertarget]")))&&((n=(i=n).popoverTargetElement)instanceof HTMLElement&&(e=O(n),"show"===i.popoverTargetAction&&"showing"===e||"hide"===i.popoverTargetAction&&"hidden"===e||("showing"===e?L(n,!0,!0):x(n,!1)&&(k.set(n,i),jt(n)))),t.preventDefault())},r=t=>{var e=t.key,i=t.target;t.defaultPrevented||!i||"Escape"!==e&&"Esc"!==e||P(i.ownerDocument,!0,!0)};var a;(a=document).addEventListener("click",o),a.addEventListener("keydown",r),a.addEventListener("pointerdown",zt),a.addEventListener("pointerup",zt),Qt(document)}"undefined"!=typeof HTMLElement&&"object"==typeof HTMLElement.prototype&&"popover"in HTMLElement.prototype||Xt();let Yt=1e3;const V=new Set;function Gt(e,{abortSignal:t,surround:i=!0,boundaries:n=[]}={}){var s=new AbortController,t=t||s.signal;let o;n.forEach(t=>{t&&V.add(t)});const r="awc-"+Yt++;e.setAttribute("data-focus-trap-id",r),V.add(e);var a,l,n=Zt(r),c=(n.onfocus=()=>{var t=bt(e).filter(t=>!t.hasAttribute("data-sentinel-for"));(t[t.length-1]||e).focus()},Zt(r));function h(t){t?t!==document.activeElement&&(t.focus({preventScroll:!0}),o=t):h(e)}return c.onfocus=()=>{(bt(e).filter(t=>!t.hasAttribute("data-sentinel-for"))[0]||e).focus()},i?(i=n,null!=(l=(a=e).parentNode)&&l.insertBefore(i,a),l=c,null!=(a=(i=e).parentNode)&&a.insertBefore(l,i.nextSibling)):(e.prepend(n),e.append(c)),h(function(t){if(t.hasAttribute("data-autofocus")&&u(t))return t;var e=t.querySelector("[data-autofocus]");if(e&&u(e))return e;e=function(t,e){return(e=e||{}).getShadowRoot?Et([t],e.includeContainer,{filter:f.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):At(t,e.includeContainer,f.bind(null,e))}(t).filter(t=>!t.hasAttribute("data-sentinel-for"));if(e[0])return e[0];if(u(t))return t}(e)),document.addEventListener("focusin",function(t){var e,i=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target;for(const n of V)if(n.contains(i))return void(o=i);h(o)},{signal:t,capture:!0}),t.addEventListener("abort",()=>{var t=null==(t=e.parentNode)?void 0:t.querySelectorAll(`[data-sentinel-for="${r}"]`);null!=t&&t.forEach(t=>t.remove()),e.removeAttribute("data-focus-trap-id"),V.delete(e),o=null}),s}function Zt(t){var e=document.createElement("span");return e.setAttribute("tabindex","0"),e.setAttribute("aria-hidden","true"),e.setAttribute("data-sentinel-for",t),e.style.position="fixed",e.style.top="1px",e.style.left="1px",e.style.width="1px",e.style.height="0px",e.style.padding="0px",e.style.margin="-1px",e.style.overflow="hidden",e.style.clip="rect(0px, 0px, 0px, 0px)",e.style.whiteSpace="nowrap",e.style.borderWidth="0px",e}const te=new Set;let I=class extends s{constructor(){super(...arguments),this.placement="bottom",this.strategy="fixed",this.clickBoundaries=[]}connected(){this.floatingUI=Tt(this,{referenceElement:this.button,popupElement:this.panel,arrowElement:this.arrow,arrowPadding:this.arrowPadding,placement:this.placement,strategy:this.strategy,offsetOptions:8,flipOptions:{fallbackAxisSideDirection:"end"}}),Nt(this,{boundaries:this.boundaries,callback:(t,e)=>{this.open&&!this.hasNestedOpenPopovers&&(this.hide(),Ct(e)||(t.preventDefault(),this.button.focus()))}})}disconnected(){this.hide()}async handleToggle(){var t;this.open?(te.add(this),this.closeOtherPopovers(),this.emit("show"),this.button.setAttribute("aria-expanded","true"),this.floatingUI.start(),this._focusTrap=Gt(this.panel,{surround:!1,boundaries:this.boundaries}),this.emit("shown")):(this.emit("hide"),this.button.setAttribute("aria-expanded","false"),await this.floatingUI.stop(),null!=(t=this._focusTrap)&&t.abort(),te.delete(this),this.emit("hidden"))}toggle(){this.panel.togglePopover()}show(){this.open||this.panel.showPopover()}hide(t){this.open&&(this.panel.hidePopover(),t)&&this.button.focus()}handleKeydown(t){var e;"Escape"!==t.key||(e=t.target.closest(this.identifier))!==this&&null!=e&&e.open||this.open&&(t.preventDefault(),t.stopPropagation(),this.hide(),this.button.focus())}async reposition(){await this.floatingUI.update()}closeOtherPopovers(){for(const t of te)t===this||t.contains(this)||t.hide()}get hasNestedOpenPopovers(){return 0!==Array.from(this.querySelectorAll(this.identifier)).filter(t=>t.open).length}get arrowPadding(){return it(getComputedStyle(this.panel).borderRadius)||2}get boundaries(){return this.clickBoundaries.map(t=>document.querySelector(t)).concat([this.button,this.panel])}get open(){try{return this.panel.matches(":popover-open")}catch(t){return this.panel.matches(".\\:popover-open")}}};t([e()],I.prototype,"placement",void 0),t([e()],I.prototype,"strategy",void 0),t([e({type:Array})],I.prototype,"clickBoundaries",void 0),t([n()],I.prototype,"button",void 0),t([n()],I.prototype,"panel",void 0),t([n()],I.prototype,"arrow",void 0),I=t([i("awc-popover")],I)});
@@ -0,0 +1,6 @@
1
+ <%= render(Impulse::BaseRenderer.new(**@system_args)) do %>
2
+ <%= tag.div @title, id: @id, class: "awc-autocomplete-group-header" %>
3
+ <% options.each do |option| %>
4
+ <%= option %>
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1,26 @@
1
+ module Impulse
2
+ module Autocomplete
3
+ class GroupComponent < ApplicationComponent
4
+ renders_many :options, Impulse::Autocomplete::OptionComponent
5
+
6
+ def initialize(title:, **system_args)
7
+ @id = self.class.generate_id
8
+ @title = title
9
+ @system_args = system_args
10
+ @system_args[:tag] = :div
11
+ @system_args[:role] = :group
12
+ @system_args["aria-labelledby"] = @id
13
+ @system_args[:class] = class_names(system_args[:class], "awc-autocomplete-group")
14
+
15
+ @system_args[:data] = merge_attributes(
16
+ system_args[:data],
17
+ target: "awc-autocomplete.groups"
18
+ )
19
+ end
20
+
21
+ def render?
22
+ options.present?
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,10 @@
1
1
  <%= render(Impulse::BaseRenderer.new(**@system_args)) do %>
2
- <span id="<%= @text_id %>" class="awc-autocomplete-option-text"><%= @text %></span>
3
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="currentColor" class="awc-autocomplete-option-check" aria-hidden="true">
4
- <path fill="none" d="M0 0h24v24H0z"></path><path d="M10.0007 15.1709L19.1931 5.97852L20.6073 7.39273L10.0007 17.9993L3.63672 11.6354L5.05093 10.2212L10.0007 15.1709Z"></path>
5
- </svg>
2
+ <div class="awc-autocomplete-option-content">
3
+ <span id="<%= @text_id %>" class="awc-autocomplete-option-text"><%= @text %></span>
4
+ <% if @description %>
5
+ <span class="awc-autocomplete-option-description"><%= @description %></span>
6
+ <% end %>
7
+ </div>
8
+
9
+ <i class="bi bi-check2 awc-autocomplete-option-check" aria-hidden="true"></i>
6
10
  <% end %>
@@ -1,11 +1,12 @@
1
1
  module Impulse
2
2
  module Autocomplete
3
3
  class OptionComponent < ApplicationComponent
4
- attr_reader :value, :text, :system_args
4
+ attr_reader :value, :text, :description, :system_args
5
5
 
6
- def initialize(value:, text:, **system_args)
6
+ def initialize(value:, text:, description: nil, **system_args)
7
7
  @value = value
8
8
  @text = text
9
+ @description = description
9
10
  @text_id = self.class.generate_id
10
11
  @system_args = system_args
11
12
  @system_args[:id] = system_args.fetch(:id, self.class.generate_id)
@@ -7,9 +7,7 @@
7
7
  <span class="awc-autocomplete-tag-text" data-behavior="text"><%= selected.text %></span>
8
8
  <span class="awc-autocomplete-tag-end-adornment">
9
9
  <%= content_tag :button, type: :button, class: "awc-autocomplete-tag-dismiss-btn btn", tabindex: "-1", title: "Remove", disabled: @disabled, data: { action: "click->awc-autocomplete#handleTagRemove", target: "awc-autocomplete.tagDismissBtns" } do %>
10
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
11
- <path fill="none" d="M0 0h24v24H0z"></path><path d="M12.0007 10.5865L16.9504 5.63672L18.3646 7.05093L13.4149 12.0007L18.3646 16.9504L16.9504 18.3646L12.0007 13.4149L7.05093 18.3646L5.63672 16.9504L10.5865 12.0007L5.63672 7.05093L7.05093 5.63672L12.0007 10.5865Z"></path>
12
- </svg>
10
+ <i class="bi bi-x"></i>
13
11
  <% end %>
14
12
  </span>
15
13
  <%= hidden_field @object_name, @method_name, id: nil, value: selected.value, multiple: true, data: { behavior: "hidden-field" }, **hidden_field_args %>
@@ -21,9 +19,7 @@
21
19
  <span class="awc-autocomplete-tag-text" data-behavior="text"></span>
22
20
  <span class="awc-autocomplete-tag-end-adornment">
23
21
  <%= content_tag :button, type: :button, class: "awc-autocomplete-tag-dismiss-btn btn", tabindex: "-1", title: "Remove", data: { action: "click->awc-autocomplete#handleTagRemove", target: "awc-autocomplete.tagDismissBtns" } do %>
24
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
25
- <path fill="none" d="M0 0h24v24H0z"></path><path d="M12.0007 10.5865L16.9504 5.63672L18.3646 7.05093L13.4149 12.0007L18.3646 16.9504L16.9504 18.3646L12.0007 13.4149L7.05093 18.3646L5.63672 16.9504L10.5865 12.0007L5.63672 7.05093L7.05093 5.63672L12.0007 10.5865Z"></path>
26
- </svg>
22
+ <i class="bi bi-x"></i>
27
23
  <% end %>
28
24
  </span>
29
25
  <%= hidden_field @object_name, @method_name, id: nil, value: nil, multiple: true, data: { behavior: "hidden-field" }, **hidden_field_args %>
@@ -50,12 +46,12 @@
50
46
  <div class="awc-autocomplete-end-adornment">
51
47
  <% if @clearable %>
52
48
  <%= content_tag :button, type: :button, class: "awc-autocomplete-adornment-btn awc-autocomplete-clear-btn btn btn-light", title: "Clear", disabled: @disabled, data: { action: "click->awc-autocomplete#handleClear", target: "awc-autocomplete.clearBtn" } do %>
53
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12.0007 10.5865L16.9504 5.63672L18.3646 7.05093L13.4149 12.0007L18.3646 16.9504L16.9504 18.3646L12.0007 13.4149L7.05093 18.3646L5.63672 16.9504L10.5865 12.0007L5.63672 7.05093L7.05093 5.63672L12.0007 10.5865Z"></path></svg>
49
+ <i class="bi bi-x-lg"></i>
54
50
  <% end %>
55
51
  <% end %>
56
52
 
57
53
  <div aria-hidden="true" class="awc-autocomplete-adornment-decorator">
58
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 16L6 10H18L12 16Z"></path></svg>
54
+ <i class="bi bi-caret-down-fill"></i>
59
55
  </div>
60
56
  </div>
61
57
  <% end %>
@@ -2,7 +2,10 @@ module Impulse
2
2
  class AutocompleteComponent < ApplicationComponent
3
3
  renders_one :blankslate
4
4
  renders_one :error
5
- renders_many :options, Impulse::Autocomplete::OptionComponent
5
+ renders_many :options, types: {
6
+ option: {renders: Impulse::Autocomplete::OptionComponent, as: :option},
7
+ group: {renders: Impulse::Autocomplete::GroupComponent, as: :group}
8
+ }
6
9
 
7
10
  DEFAULT_SIZE = :md
8
11
  SIZE_MAPPINGS = {
@@ -35,6 +38,7 @@ module Impulse
35
38
  "awc-autocomplete--clearable": @clearable
36
39
  )
37
40
 
41
+ @system_args[:"data-loosely-focusable"] = "true"
38
42
  @system_args[:data] = merge_attributes(
39
43
  system_args[:data],
40
44
  action: "mousedown->awc-autocomplete#handleMousedown click->awc-autocomplete#handleClick combobox:commit->awc-autocomplete#handleCommit"
@@ -1,7 +1,7 @@
1
1
  <%= render(Impulse::BaseRenderer.new(**@system_args)) do %>
2
2
  <%= trigger %>
3
3
 
4
- <div id="<%= @panel_id %>" role="dialog" class="awc-popover-container popover bs-popover-auto" tabindex="-1" data-target="awc-popover.panel">
4
+ <div id="<%= @panel_id %>" popover="manual" role="dialog" class="awc-popover-container bs-popover-auto" tabindex="-1" data-target="awc-popover.panel" data-action="toggle->awc-popover#handleToggle">
5
5
  <div class="arrow" data-target="awc-popover.arrow"></div>
6
6
  <%= header %>
7
7
  <%= body %>
@@ -7,11 +7,11 @@ module Impulse
7
7
  system_args[:"aria-haspopup"] = :dialog
8
8
  system_args[:"aria-expanded"] = false
9
9
  system_args[:"aria-controls"] = @panel_id
10
+ system_args[:popovertarget] = @panel_id
10
11
  system_args[:"aria-disabled"] = (!!system_args[:disabled]).to_s
11
12
 
12
13
  system_args[:data] = merge_attributes(
13
14
  system_args[:data],
14
- action: "click->awc-popover#handleButtonClick",
15
15
  target: "awc-popover.button"
16
16
  )
17
17
 
@@ -29,7 +29,7 @@ module Impulse
29
29
  Impulse::BaseRenderer.new(**system_args)
30
30
  }
31
31
 
32
- def initialize(title:, click_boundaries: [], **system_args)
32
+ def initialize(title: nil, click_boundaries: [], **system_args)
33
33
  @title = title
34
34
  @system_args = system_args
35
35
  @system_args[:tag] = :"awc-popover"
@@ -1,11 +1,19 @@
1
1
  <%= render(Impulse::AutocompleteComponent.new(@object_name, @method_name, selected: value, **@system_args)) do |c| %>
2
2
  <% if options? %>
3
3
  <% options.each do |option| %>
4
- <%= c.with_option(value: option.value, text: option.text, **option.system_args) %>
4
+ <%= c.with_option(value: option.value, text: option.text, description: option.description, **option.system_args) %>
5
5
  <% end %>
6
6
  <% else %>
7
7
  <% options_from_choices.each do |option| %>
8
- <%= c.with_option(value: option.value, text: option.text, **option.html_attributes) %>
8
+ <% if option.is_a?(Array) %>
9
+ <% c.with_group(title: option.first) do |group| %>
10
+ <% option.second.each do |grouped_option| %>
11
+ <% group.with_option(value: grouped_option.value, text: grouped_option.text, **grouped_option.html_attributes) %>
12
+ <% end %>
13
+ <% end %>
14
+ <% else %>
15
+ <%= c.with_option(value: option.value, text: option.text, **option.html_attributes) %>
16
+ <% end %>
9
17
  <% end %>
10
18
  <% end %>
11
19
 
@@ -23,15 +23,31 @@ module Impulse
23
23
 
24
24
  def options_from_choices
25
25
  return [] if @choices.nil?
26
- @choices.map do |choice|
26
+ return grouped_options_for_select(@choices) if grouped_choices?
27
+ options_for_select(@choices)
28
+ end
29
+
30
+ def options_for_select(choices)
31
+ choices.map do |choice|
27
32
  html_attributes = option_html_attributes(choice)
28
33
  text, value = option_text_and_value(choice)
29
34
  OptionStruct.new(value, text, html_attributes)
30
35
  end
31
36
  end
32
37
 
38
+ def grouped_options_for_select(grouped_choices)
39
+ grouped_choices.map do |grouped_choice|
40
+ title, container = grouped_choice
41
+ [title, options_for_select(container)]
42
+ end
43
+ end
44
+
33
45
  def find_option(value)
34
- (options.presence || options_from_choices).find { |option| option.value.to_s == value.to_s }
46
+ (options.presence || options_from_choices).flatten.find { |option| option.try(:value)&.to_s == value.to_s }
47
+ end
48
+
49
+ def grouped_choices?
50
+ @choices.present? && @choices.first.respond_to?(:last) && Array === @choices.first.last
35
51
  end
36
52
 
37
53
  def multiple?
@@ -0,0 +1,20 @@
1
+ <%= render(Impulse::AutocompleteComponent.new(@object_name, @method_name, selected: value, **@system_args)) do |c| %>
2
+ <% if prioritized? %>
3
+ <% c.with_group(title: @priority_zones_title) do |group| %>
4
+ <% options[:priority_zones].each do |option| %>
5
+ <% group.with_option(value: option.name, text: option.to_s, data: {test_id: "priority-zones"}) %>
6
+ <% end %>
7
+ <% end %>
8
+ <% c.with_group(title: "Other") do |group| %>
9
+ <% options[:other].each do |option| %>
10
+ <% group.with_option(value: option.name, text: option.to_s, data: {test_id: "unprioritized-zones"}) %>
11
+ <% end %>
12
+ <% end %>
13
+ <% else %>
14
+ <% options[:other].each do |option| %>
15
+ <% c.with_option(value: option.name, text: option.to_s) %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <% c.with_blankslate_content(blankslate.presence || "We couldn't find that time zone!") %>
20
+ <% end %>
@@ -0,0 +1,66 @@
1
+ module Impulse
2
+ class TimeZoneSelectComponent < ApplicationComponent
3
+ renders_one :blankslate
4
+
5
+ OptionStruct = Struct.new(:value, :text)
6
+
7
+ def initialize(object_name, method_name, priority_zones = nil, selected: nil, default: nil, model: ::ActiveSupport::TimeZone, priority_zones_title: "Prioritized time zones", **system_args)
8
+ @object_name = object_name
9
+ @method_name = method_name
10
+ @priority_zones = priority_zones
11
+ @selected = selected
12
+ @default = default
13
+ @model = model
14
+ @priority_zones_title = priority_zones_title
15
+ @system_args = system_args
16
+ end
17
+
18
+ private
19
+
20
+ def options
21
+ priority_zones = @priority_zones
22
+
23
+ zones = Hash.new { |h, k| h[k] = [] }.tap do |hash|
24
+ model = @model.all
25
+
26
+ if priority_zones
27
+ if priority_zones.is_a?(Regexp)
28
+ priority_zones = model.select { |z| z.match?(priority_zones) }
29
+ end
30
+
31
+ hash[:priority_zones] = priority_zones
32
+ model -= priority_zones
33
+ end
34
+
35
+ hash[:other] = model
36
+ end
37
+
38
+ if zones[:other].blank?
39
+ zones[:other] = zones[:priority_zones]
40
+ zones[:priority_zones] = []
41
+ end
42
+
43
+ zones
44
+ end
45
+
46
+ def value
47
+ find_option(selected) if selected.present?
48
+ end
49
+
50
+ def options_from_choices
51
+ @model.all.map { |option| OptionStruct.new(option.name, option.to_s) }
52
+ end
53
+
54
+ def find_option(value)
55
+ options_from_choices.find { |option| option.value == value }
56
+ end
57
+
58
+ def selected
59
+ @selected || @default
60
+ end
61
+
62
+ def prioritized?
63
+ options[:priority_zones].present?
64
+ end
65
+ end
66
+ end
@@ -26,6 +26,17 @@ module Impulse
26
26
  **system_args
27
27
  ).render_tag(&block)
28
28
  end
29
+
30
+ def time_zone_select(method_name, priority_zones = nil, **system_args, &block)
31
+ Tags::TimeZoneSelect.new(
32
+ object:,
33
+ object_name:,
34
+ method_name:,
35
+ template:,
36
+ priority_zones:,
37
+ **system_args
38
+ ).render_tag(&block)
39
+ end
29
40
  end
30
41
  end
31
42
  end