"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("./query-assigned-elements-8EurZY45.js"),c=require("./chip-CiCrVTPi.js"),d=require("./tslib.es6-CHeFCc6E.js"),S=require("./foundation-pgmPu2iJ.js"),C=require("./keyboard-CZlaSOb1.js"),E=require("./property-DYTC_2-m.js"),N=require("./query-Dv2F3m_t.js");/**
 * @license
 * Copyright 2016 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */var y;(function(a){a.ARIA_MULTISELECTABLE="aria-multiselectable"})(y||(y={}));var F;(function(a){a.CHIP="mdc-evolution-chip"})(F||(F={}));var f;(function(a){a.INTERACTION="MDCChipSet:interaction",a.REMOVAL="MDCChipSet:removal",a.SELECTION="MDCChipSet:selection"})(f||(f={}));/**
 * @license
 * Copyright 2020 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */var v;(function(a){a[a.INCREMENT=0]="INCREMENT",a[a.DECREMENT=1]="DECREMENT"})(v||(v={}));var R=function(a){d.__extends(i,a);function i(e){return a.call(this,d.__assign(d.__assign({},i.defaultAdapter),e))||this}return Object.defineProperty(i,"defaultAdapter",{get:function(){return{announceMessage:function(){},emitEvent:function(){},getAttribute:function(){return null},getChipActionsAtIndex:function(){return[]},getChipCount:function(){return 0},getChipIdAtIndex:function(){return""},getChipIndexById:function(){return 0},isChipFocusableAtIndex:function(){return!1},isChipSelectableAtIndex:function(){return!1},isChipSelectedAtIndex:function(){return!1},removeChipAtIndex:function(){},setChipFocusAtIndex:function(){},setChipSelectedAtIndex:function(){},startChipAnimationAtIndex:function(){}}},enumerable:!1,configurable:!0}),i.prototype.handleChipAnimation=function(e){var t=e.detail,r=t.chipID,n=t.animation,o=t.isComplete,h=t.addedAnnouncement,s=t.removedAnnouncement,p=this.adapter.getChipIndexById(r);if(n===c.MDCChipAnimation.EXIT&&o){s&&this.adapter.announceMessage(s),this.removeAfterAnimation(p,r);return}if(n===c.MDCChipAnimation.ENTER&&o&&h){this.adapter.announceMessage(h);return}},i.prototype.handleChipInteraction=function(e){var t=e.detail,r=t.source,n=t.chipID,o=t.isSelectable,h=t.isSelected,s=t.shouldRemove,p=this.adapter.getChipIndexById(n);if(s){this.removeChip(p);return}this.focusChip(p,r,c.MDCChipActionFocusBehavior.FOCUSABLE),this.adapter.emitEvent(f.INTERACTION,{chipIndex:p,chipID:n}),o&&this.setSelection(p,r,!h)},i.prototype.handleChipNavigation=function(e){var t=e.detail,r=t.chipID,n=t.key,o=t.isRTL,h=t.source,s=this.adapter.getChipIndexById(r),p=n===C.KEY.ARROW_RIGHT&&!o||n===C.KEY.ARROW_LEFT&&o;if(p){this.focusNextChipFrom(s+1);return}var u=n===C.KEY.ARROW_LEFT&&!o||n===C.KEY.ARROW_RIGHT&&o;if(u){this.focusPrevChipFrom(s-1);return}if(n===C.KEY.ARROW_DOWN){this.focusNextChipFrom(s+1,h);return}if(n===C.KEY.ARROW_UP){this.focusPrevChipFrom(s-1,h);return}if(n===C.KEY.HOME){this.focusNextChipFrom(0,h);return}if(n===C.KEY.END){this.focusPrevChipFrom(this.adapter.getChipCount()-1,h);return}},i.prototype.getSelectedChipIndexes=function(){for(var e,t,r=new Set,n=this.adapter.getChipCount(),o=0;o<n;o++){var h=this.adapter.getChipActionsAtIndex(o);try{for(var s=(e=void 0,d.__values(h)),p=s.next();!p.done;p=s.next()){var u=p.value;this.adapter.isChipSelectedAtIndex(o,u)&&r.add(o)}}catch(l){e={error:l}}finally{try{p&&!p.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}}return r},i.prototype.setChipSelected=function(e,t,r){this.adapter.isChipSelectableAtIndex(e,t)&&this.setSelection(e,t,r)},i.prototype.isChipSelected=function(e,t){return this.adapter.isChipSelectedAtIndex(e,t)},i.prototype.removeChip=function(e){e>=this.adapter.getChipCount()||e<0||(this.adapter.startChipAnimationAtIndex(e,c.MDCChipAnimation.EXIT),this.adapter.emitEvent(f.REMOVAL,{chipID:this.adapter.getChipIdAtIndex(e),chipIndex:e,isComplete:!1}))},i.prototype.addChip=function(e){e>=this.adapter.getChipCount()||e<0||this.adapter.startChipAnimationAtIndex(e,c.MDCChipAnimation.ENTER)},i.prototype.focusNextChipFrom=function(e,t){for(var r=this.adapter.getChipCount(),n=e;n<r;n++){var o=this.getFocusableAction(n,v.INCREMENT,t);if(o){this.focusChip(n,o,c.MDCChipActionFocusBehavior.FOCUSABLE_AND_FOCUSED);return}}},i.prototype.focusPrevChipFrom=function(e,t){for(var r=e;r>-1;r--){var n=this.getFocusableAction(r,v.DECREMENT,t);if(n){this.focusChip(r,n,c.MDCChipActionFocusBehavior.FOCUSABLE_AND_FOCUSED);return}}},i.prototype.getFocusableAction=function(e,t,r){var n=this.adapter.getChipActionsAtIndex(e);return t===v.DECREMENT&&n.reverse(),r?this.getMatchingFocusableAction(e,n,r):this.getFirstFocusableAction(e,n)},i.prototype.getFirstFocusableAction=function(e,t){var r,n;try{for(var o=d.__values(t),h=o.next();!h.done;h=o.next()){var s=h.value;if(this.adapter.isChipFocusableAtIndex(e,s))return s}}catch(p){r={error:p}}finally{try{h&&!h.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return null},i.prototype.getMatchingFocusableAction=function(e,t,r){var n,o,h=null;try{for(var s=d.__values(t),p=s.next();!p.done;p=s.next()){var u=p.value;if(this.adapter.isChipFocusableAtIndex(e,u)&&(h=u),h===r)return h}}catch(l){n={error:l}}finally{try{p&&!p.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return h},i.prototype.focusChip=function(e,t,r){var n,o;this.adapter.setChipFocusAtIndex(e,t,r);for(var h=this.adapter.getChipCount(),s=0;s<h;s++){var p=this.adapter.getChipActionsAtIndex(s);try{for(var u=(n=void 0,d.__values(p)),l=u.next();!l.done;l=u.next()){var m=l.value;m===t&&s===e||this.adapter.setChipFocusAtIndex(s,m,c.MDCChipActionFocusBehavior.NOT_FOCUSABLE)}}catch(x){n={error:x}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}},i.prototype.supportsMultiSelect=function(){return this.adapter.getAttribute(y.ARIA_MULTISELECTABLE)==="true"},i.prototype.setSelection=function(e,t,r){var n,o;if(this.adapter.setChipSelectedAtIndex(e,t,r),this.adapter.emitEvent(f.SELECTION,{chipID:this.adapter.getChipIdAtIndex(e),chipIndex:e,isSelected:r}),!this.supportsMultiSelect())for(var h=this.adapter.getChipCount(),s=0;s<h;s++){var p=this.adapter.getChipActionsAtIndex(s);try{for(var u=(n=void 0,d.__values(p)),l=u.next();!l.done;l=u.next()){var m=l.value;m===t&&s===e||this.adapter.setChipSelectedAtIndex(s,m,!1)}}catch(x){n={error:x}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}},i.prototype.removeAfterAnimation=function(e,t){this.adapter.removeChipAtIndex(e),this.adapter.emitEvent(f.REMOVAL,{chipIndex:e,isComplete:!0,chipID:t});var r=this.adapter.getChipCount();r<=0||this.focusNearestFocusableAction(e)},i.prototype.focusNearestFocusableAction=function(e){for(var t=this.adapter.getChipCount(),r=e,n=e;r>-1||n<t;){var o=this.getNearestFocusableAction(r,n,c.MDCChipActionType.TRAILING);if(o){this.focusChip(o.index,o.action,c.MDCChipActionFocusBehavior.FOCUSABLE_AND_FOCUSED);return}r--,n++}},i.prototype.getNearestFocusableAction=function(e,t,r){var n=this.getFocusableAction(e,v.DECREMENT,r);if(n)return{index:e,action:n};if(t===e)return null;var o=this.getFocusableAction(t,v.INCREMENT,r);return o?{index:t,action:o}:null},i}(S.MDCFoundation);/**
 * @license
 * Copyright 2020 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */var b;(function(a){a.POLITE="polite",a.ASSERTIVE="assertive"})(b||(b={}));var M="data-mdc-dom-announce";function D(a,i){T.getInstance().say(a,i)}var T=function(){function a(){this.liveRegions=new Map}return a.getInstance=function(){return a.instance||(a.instance=new a),a.instance},a.prototype.say=function(i,e){var t,r,n=(t=e==null?void 0:e.priority)!==null&&t!==void 0?t:b.POLITE,o=(r=e==null?void 0:e.ownerDocument)!==null&&r!==void 0?r:document,h=this.getLiveRegion(n,o);h.textContent="",setTimeout(function(){h.textContent=i,o.addEventListener("click",s)},1);function s(){h.textContent="",o.removeEventListener("click",s)}},a.prototype.getLiveRegion=function(i,e){var t=this.liveRegions.get(e);t||(t=new Map,this.liveRegions.set(e,t));var r=t.get(i);if(r&&e.body.contains(r))return r;var n=this.createLiveRegion(i,e);return t.set(i,n),n},a.prototype.createLiveRegion=function(i,e){var t=e.createElement("div");return t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.height="1px",t.style.overflow="hidden",t.setAttribute("aria-atomic","true"),t.setAttribute("aria-live",i),t.setAttribute(M,"true"),e.body.appendChild(t),t},a}(),L=Object.defineProperty,g=(a,i,e,t)=>{for(var r=void 0,n=a.length-1,o;n>=0;n--)(o=a[n])&&(r=o(i,e,r)||r);return r&&L(i,e,r),r};class A extends I.s{constructor(){super(...arguments),this.selectable=!1,this.multi=!1,this.label="",this.activeIndex=0,this._previousActiveIndex=-1,this.chips=[]}render(){return I.x`<span
      class="mdc-evolution-chip-set"
      role="${this.selectable||this.multi?"listbox":"grid"}"
      aria-label="${this.label}"
      aria-multiselectable="${this.multi}"
    >
      <span class="mdc-evolution-chip-set__chips" role="presentation">
        <slot></slot>
      </span>
    </span>`}async updated(i){super.updated(i),await this.updateComplete,this.activeIndex!=this._previousActiveIndex&&this.mdcFoundation.setChipSelected(this.activeIndex,c.MDCChipActionType.PRIMARY,!0)}firstUpdated(i){var r;super.firstUpdated(i);const e=(r=this.shadowRoot)==null?void 0:r.querySelector("slot"),t=(e==null?void 0:e.assignedElements().filter(n=>n instanceof c.CovalentChip))??[];for(let n=0;n<t.length;n++){const o=t[n];this.chips.push(o)}this.mdcFoundation!==void 0&&this.mdcFoundation.destroy(),this.mdcFoundation=new R(this.createAdapter()),this.mdcFoundation.init()}connectedCallback(){super.connectedCallback(),this.addEventListener(c.MDCChipEvents.ANIMATION,this._handleChipAnimation),this.addEventListener(c.MDCChipEvents.INTERACTION,this._handleChipInteraction),this.addEventListener(c.MDCChipEvents.NAVIGATION,this._handleChipNavigation)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(c.MDCChipEvents.ANIMATION,this._handleChipAnimation),this.removeEventListener(c.MDCChipEvents.INTERACTION,this._handleChipInteraction),this.removeEventListener(c.MDCChipEvents.NAVIGATION,this._handleChipNavigation)}createAdapter(){return{announceMessage:D,emitEvent:(i,e)=>this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:e})),getAttribute:i=>this.mdcRoot.getAttribute(i),getChipActionsAtIndex:i=>this.chips[i].getActions(),getChipCount:()=>this.chips.length,getChipIdAtIndex:i=>this.chips[i].getElementID(),getChipIndexById:i=>this.chips.findIndex(e=>e.getElementID()===i),isChipFocusableAtIndex:(i,e)=>this.chips[i].isActionFocusable(e),isChipSelectableAtIndex:(i,e)=>this.chips[i].isActionSelectable(e),isChipSelectedAtIndex:(i,e)=>this.chips[i].isActionSelected(e),removeChipAtIndex:i=>this.chips[i].remove(),setChipFocusAtIndex:(i,e,t)=>this.chips[i].setActionFocus(e,t),setChipSelectedAtIndex:(i,e,t)=>this.chips[i].setActionSelected(e,t),startChipAnimationAtIndex:(i,e)=>this.chips[i].startAnimation(e)}}_handleChipAnimation(i){this.mdcFoundation.handleChipAnimation(i)}_handleChipInteraction(i){this.mdcFoundation.handleChipInteraction(i)}_handleChipNavigation(i){this.mdcFoundation.handleChipNavigation(i)}}g([N.i(".mdc-evolution-chip-set")],A.prototype,"mdcRoot");g([E.n({type:Boolean,reflect:!0})],A.prototype,"selectable");g([E.n({type:Boolean,reflect:!0})],A.prototype,"multi");g([E.n()],A.prototype,"label");g([E.n({type:Number})],A.prototype,"activeIndex");const O=".mdc-evolution-chip-set{display:flex}.mdc-evolution-chip-set:focus{outline:none}.mdc-evolution-chip-set__chips{display:flex;flex-flow:wrap;min-width:0}.mdc-evolution-chip-set--overflow .mdc-evolution-chip-set__chips{flex-flow:nowrap}.mdc-evolution-chip-set .mdc-evolution-chip-set__chips{margin-left:-8px;margin-right:0}[dir=rtl] .mdc-evolution-chip-set .mdc-evolution-chip-set__chips,.mdc-evolution-chip-set .mdc-evolution-chip-set__chips[dir=rtl]{margin-left:0;margin-right:-8px}.mdc-evolution-chip-set .mdc-evolution-chip{margin-left:8px;margin-right:0}[dir=rtl] .mdc-evolution-chip-set .mdc-evolution-chip,.mdc-evolution-chip-set .mdc-evolution-chip[dir=rtl]{margin-left:0;margin-right:8px}.mdc-evolution-chip-set .mdc-evolution-chip{margin-top:4px;margin-bottom:4px}::slotted(cv-chip){margin-left:8px;margin-right:0}[dir=rtl] ::slotted(cv-chip),::slotted(cv-chip[dir=rtl]){margin-left:0;margin-right:8px}::slotted(cv-chip){margin-top:4px;margin-bottom:4px}";var _=Object.getOwnPropertyDescriptor,w=(a,i,e,t)=>{for(var r=t>1?void 0:t?_(i,e):i,n=a.length-1,o;n>=0;n--)(o=a[n])&&(r=o(r)||r);return r};exports.CovalentChipSet=class extends A{};exports.CovalentChipSet.styles=[I.i`
      ${I.r(O)}
    `];exports.CovalentChipSet=w([I.e("cv-chip-set")],exports.CovalentChipSet);const B=exports.CovalentChipSet;exports.default=B;
