@adia-ai/web-components 0.8.21 → 0.8.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,7 +137,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
137
137
  <icon-ui name="caret-down" slot="caret"></icon-ui>
138
138
  </span>
139
139
  ${o}
140
- `,this.hint&&this.setAttribute("aria-describedby",r);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#y),a.addEventListener("click",this.#y)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#R),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#A(),this.multiple&&this.#M();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#f().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n)),this.#$()),this.#n){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#n.querySelectorAll('[role="option"]')){let n=i.getAttribute("data-value");(e?e.has(n):n===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#n?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#n.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#n.style.width="max-content",this.#r=lt(e,this.#n,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#Q,{once:!0})})}else this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q)}#v(){let t=[],e=i=>{for(let n of i.children)if(!n.hasAttribute("slot")){if(n.tagName==="OPTION"||n.tagName==="OPTGROUP"){t.push(n);continue}if(n.matches('[role="presentation"]')||n.style?.display==="contents"){e(n);continue}t.push(n)}};return e(this),t}#w(){this.#i=[];let t=new Set,e=[];for(let i of this.#v())if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled,icon:r.getAttribute("icon")||"",avatar:r.getAttribute("avatar")||"",mark:r.hasAttribute("mark")}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled,icon:i.getAttribute("icon")||"",avatar:i.getAttribute("avatar")||"",mark:i.hasAttribute("mark")}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){Rt(()=>{this.#i=t,this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n))),this.#$();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C()),this.#A()})}get options(){return this.#i}static#k(t){return t?t.mark?'<adia-mark-ui data-select-mark size="sm"></adia-mark-ui>':t.avatar?`<img data-option-avatar src="${Pt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Pt(t.icon)}"></icon-ui>`:"":""}#A(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(u=>u.options||[u]).find(u=>!u.header&&!u.separator&&u.value===this.value),n=i&&i.mark||this.mark||!1,r=i&&i.avatar||this.avatar||"",o=i&&i.icon||this.icon||"",a=t.querySelector(":scope > [data-select-leading]"),l="";if(n?l='<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':r?l=`<img slot="leading" data-select-leading src="${Pt(r)}" alt="" />`:o&&(l=`<icon-ui slot="leading" data-select-leading name="${Pt(o)}"></icon-ui>`),!l){a?.remove();return}let h=document.createElement("template");h.innerHTML=l;let c=h.content.firstElementChild;a?a.tagName===c.tagName?c.tagName==="IMG"?a.getAttribute("src")!==c.getAttribute("src")&&a.setAttribute("src",c.getAttribute("src")):a.getAttribute("name")!==c.getAttribute("name")&&a.setAttribute("name",c.getAttribute("name")):a.replaceWith(c):t.insertBefore(c,t.firstChild)}#$(){if(!this.#n)return;if(this.#n.innerHTML="",this.multiple?this.#n.setAttribute("aria-multiselectable","true"):this.#n.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("size","xs"),i.dataset.selectAllBtn="",i.setAttribute("text",this.#P()?"Clear":"Select all"),i.addEventListener("click",this.#O),e.appendChild(i),this.#n.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,r=n?n.has(e.value):e.value===this.value,o=s.#k(e);if(e.action){i.setAttribute("data-action-option","");let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Pt(e.label)}`:a.textContent=e.label,i.appendChild(a)}else if(this.multiple){i.setAttribute("data-multi-option","");let a=document.createElement("span");a.setAttribute("data-checkbox",""),a.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Pt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else{i.setAttribute("data-single-option","");let a=document.createElement("span");a.setAttribute("data-radio",""),a.setAttribute("aria-hidden","true"),i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Pt(e.label)}`:l.textContent=e.label,i.appendChild(l)}return r&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#d),i};for(let e of this.#i)if(e.separator)this.#n.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Pt(e.label)}</strong><span>${Pt(e.description||"")}</span></div>`:`<div><strong>${Pt(e.label)}</strong><span>${Pt(e.description||"")}</span></div>`,this.#n.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Pt(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#n.appendChild(i)}else this.#n.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#n.appendChild(e)}this.#a&&this.#E()}#P(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#f());return t.every(i=>e.has(String(i.value)))}#M(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;if(this.summaryLabel){for(;t.firstChild;)t.removeChild(t.firstChild);return}let e=this.#f(),i=Number(this.maxChips)||0,n=i>0&&e.length>i?e.slice(0,i):e,r=i>0&&e.length>i?e.length-i:0,o=a=>this.#L(a);for(;t.firstChild;)t.removeChild(t.firstChild);for(let a of n){let l=document.createElement("tag-ui");l.setAttribute("size","sm"),!this.disabled&&!this.readonly&&l.setAttribute("removable",""),l.dataset.chipValue=String(a),l.setAttribute("text",o(a)),t.appendChild(l)}if(r>0){let a=document.createElement("button-ui");a.setAttribute("variant","ghost"),a.setAttribute("size","xs"),a.dataset.more="",a.setAttribute("text",`+${r} more`),a.addEventListener("click",this.#b),t.appendChild(a)}}#L(t){let i=this.#i.flatMap(n=>n.options||[n]).filter(n=>!n.separator&&!n.header&&n.value!=null).find(n=>String(n.value)===String(t));return i?i.label:String(t)}#C(){if(this.multiple){if(this.summaryLabel){let i=this.#f();return i.length===0?this.placeholder:i.length===1?this.#L(i[0]):`${this.summaryLabel} (${i.length})`}return this.value?"":this.placeholder}return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#I=t=>{this.disabled||this.#n&&t.composedPath().includes(this.#n)||(this.open=!this.open)};#Q=t=>{!this.contains(t.target)&&!(this.#n&&t.composedPath().includes(this.#n))&&(this.open=!1)};#T=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",n=!this.#a||this.#a.length===0;if((!i||n)&&this.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#E();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#a){let i=this.#a;this.value=i,this.#a="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#q(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#q(-1))};#R=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#E()};#E(){if(!this.#n)return;let t=this.#a.toLowerCase(),e=this.#n.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#n.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#n.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#q(t){if(!this.#n)return;let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#n.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#I),this.removeEventListener("keydown",this.#T),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q),this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#n=null}};x("select-ui",dn);P();var fn=class extends w{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};x("segment-ui",fn);var pn=class s extends Z{static properties={...Z.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#a)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#a)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#a;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)}this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#c(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#c(i[r])}};x("segmented-ui",pn);var mn=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
140
+ `,this.hint&&this.setAttribute("aria-describedby",r);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#y),a.addEventListener("click",this.#y)),this.searchable&&(this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u)),this.#o=this.querySelector('input[slot="display"]'),this.#o&&(this.#o.addEventListener("input",this.#R),this.#o.addEventListener("focus",this.#h),this.#o.addEventListener("click",this.#u))),e&&this.appendChild(e)}this.#A(),this.multiple&&this.#M();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#f().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n)),this.#$()),this.#n){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#n.querySelectorAll('[role="option"]')){let n=i.getAttribute("data-value");n!==null&&(e?e.has(n):n===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#n?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#n.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#n.style.width="max-content",this.#r=lt(e,this.#n,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#l=requestAnimationFrame(()=>{this.#l=null,document.addEventListener("pointerdown",this.#Q,{once:!0})})}else this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q)}#v(){let t=[],e=i=>{for(let n of i.children)if(!n.hasAttribute("slot")){if(n.tagName==="OPTION"||n.tagName==="OPTGROUP"){t.push(n);continue}if(n.matches('[role="presentation"]')||n.style?.display==="contents"){e(n);continue}t.push(n)}};return e(this),t}#w(){this.#i=[];let t=new Set,e=[];for(let i of this.#v())if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled,icon:r.getAttribute("icon")||"",avatar:r.getAttribute("avatar")||"",mark:r.hasAttribute("mark")}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled,icon:i.getAttribute("icon")||"",avatar:i.getAttribute("avatar")||"",mark:i.hasAttribute("mark")}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){Rt(()=>{this.#i=t,this.#n||(this.#n=this.querySelector('[slot="listbox"]'),this.#n||(this.#n=document.createElement("div"),this.#n.setAttribute("slot","listbox"),this.#n.setAttribute("role","listbox"),this.#n.setAttribute("popover","manual"),this.appendChild(this.#n))),this.#$();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#C()),this.#A()})}get options(){return this.#i}static#k(t){return t?t.mark?'<adia-mark-ui data-select-mark size="sm"></adia-mark-ui>':t.avatar?`<img data-option-avatar src="${Pt(t.avatar)}" alt="" />`:t.icon?`<icon-ui name="${Pt(t.icon)}"></icon-ui>`:"":""}#A(){if(this.multiple||!this.#s)return;let t=this.querySelector('[slot="trigger"]');if(!t)return;let i=this.#i.flatMap(u=>u.options||[u]).find(u=>!u.header&&!u.separator&&u.value===this.value),n=i&&i.mark||this.mark||!1,r=i&&i.avatar||this.avatar||"",o=i&&i.icon||this.icon||"",a=t.querySelector(":scope > [data-select-leading]"),l="";if(n?l='<adia-mark-ui slot="leading" data-select-leading size="sm"></adia-mark-ui>':r?l=`<img slot="leading" data-select-leading src="${Pt(r)}" alt="" />`:o&&(l=`<icon-ui slot="leading" data-select-leading name="${Pt(o)}"></icon-ui>`),!l){a?.remove();return}let h=document.createElement("template");h.innerHTML=l;let c=h.content.firstElementChild;a?a.tagName===c.tagName?c.tagName==="IMG"?a.getAttribute("src")!==c.getAttribute("src")&&a.setAttribute("src",c.getAttribute("src")):a.getAttribute("name")!==c.getAttribute("name")&&a.setAttribute("name",c.getAttribute("name")):a.replaceWith(c):t.insertBefore(c,t.firstChild)}#$(){if(!this.#n)return;if(this.#n.innerHTML="",this.multiple?this.#n.setAttribute("aria-multiselectable","true"):this.#n.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button-ui");i.setAttribute("variant","ghost"),i.setAttribute("size","xs"),i.dataset.selectAllBtn="",i.setAttribute("text",this.#P()?"Clear":"Select all"),i.addEventListener("click",this.#O),e.appendChild(i),this.#n.appendChild(e)}let t=e=>{if(e.separator){let a=document.createElement("hr");return a.setAttribute("data-separator",""),a}let i=document.createElement("div");i.setAttribute("role","option"),e.action||i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(a=>a.trim()).filter(Boolean)):null,r=!e.action&&(n?n.has(e.value):e.value===this.value),o=s.#k(e);if(e.action){i.setAttribute("data-action-option","");let a=document.createElement("span");a.setAttribute("data-option-label",""),o?a.innerHTML=`${o}${Pt(e.label)}`:a.textContent=e.label,i.appendChild(a)}else if(this.multiple){i.setAttribute("data-multi-option","");let a=document.createElement("span");a.setAttribute("data-checkbox",""),a.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Pt(e.label)}`:l.textContent=e.label,i.appendChild(l)}else{i.setAttribute("data-single-option","");let a=document.createElement("span");a.setAttribute("data-radio",""),a.setAttribute("aria-hidden","true"),i.appendChild(a);let l=document.createElement("span");l.setAttribute("data-option-label",""),o?l.innerHTML=`${o}${Pt(e.label)}`:l.textContent=e.label,i.appendChild(l)}return r&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#d),i};for(let e of this.#i)if(e.separator)this.#n.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${Pt(e.label)}</strong><span>${Pt(e.description||"")}</span></div>`:`<div><strong>${Pt(e.label)}</strong><span>${Pt(e.description||"")}</span></div>`,this.#n.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${Pt(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#n.appendChild(i)}else this.#n.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#n.appendChild(e)}this.#a&&this.#E()}#P(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#f());return t.every(i=>e.has(String(i.value)))}#M(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;if(this.summaryLabel){for(;t.firstChild;)t.removeChild(t.firstChild);return}let e=this.#f(),i=Number(this.maxChips)||0,n=i>0&&e.length>i?e.slice(0,i):e,r=i>0&&e.length>i?e.length-i:0,o=a=>this.#L(a);for(;t.firstChild;)t.removeChild(t.firstChild);for(let a of n){let l=document.createElement("tag-ui");l.setAttribute("size","sm"),!this.disabled&&!this.readonly&&l.setAttribute("removable",""),l.dataset.chipValue=String(a),l.setAttribute("text",o(a)),t.appendChild(l)}if(r>0){let a=document.createElement("button-ui");a.setAttribute("variant","ghost"),a.setAttribute("size","xs"),a.dataset.more="",a.setAttribute("text",`+${r} more`),a.addEventListener("click",this.#b),t.appendChild(a)}}#L(t){let i=this.#i.flatMap(n=>n.options||[n]).filter(n=>!n.separator&&!n.header&&n.value!=null).find(n=>String(n.value)===String(t));return i?i.label:String(t)}#C(){if(this.multiple){if(this.summaryLabel){let i=this.#f();return i.length===0?this.placeholder:i.length===1?this.#L(i[0]):`${this.summaryLabel} (${i.length})`}return this.value?"":this.placeholder}return this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#I=t=>{this.disabled||this.#n&&t.composedPath().includes(this.#n)||(this.open=!this.open)};#Q=t=>{!this.contains(t.target)&&!(this.#n&&t.composedPath().includes(this.#n))&&(this.open=!1)};#T=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",n=!this.#a||this.#a.length===0;if((!i||n)&&this.#f().length>0){t.preventDefault(),this.#m();return}}if(t.key==="Escape"){if(this.searchable&&this.#a){this.#a="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#E();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#a){let i=this.#a;this.value=i,this.#a="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#n?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#q(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#q(-1))};#R=t=>{this.#a=t.target.value||"",this.open||(this.open=!0),this.#E()};#E(){if(!this.#n)return;let t=this.#a.toLowerCase(),e=this.#n.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#n.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#n.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#q(t){if(!this.#n)return;let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#n.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#I),this.removeEventListener("keydown",this.#T),this.removeEventListener("remove",this.#g),this.#c?.disconnect(),this.#l!=null&&(cancelAnimationFrame(this.#l),this.#l=null),document.removeEventListener("pointerdown",this.#Q),this.#o&&(this.#o.removeEventListener("input",this.#R),this.#o.removeEventListener("focus",this.#h),this.#o.removeEventListener("click",this.#u),this.#o=null),this.#r?.(),this.#r=null,this.#n?.hidePopover?.(),this.#n=null}};x("select-ui",dn);P();var fn=class extends w{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};x("segment-ui",fn);var pn=class s extends Z{static properties={...Z.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#a)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#a)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#a;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)}this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#c(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#c(i[r])}};x("segmented-ui",pn);var mn=class extends Z{static labelDeprecated=!1;static properties={...Z.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
141
141
  <span slot="label">${this.label}</span>
142
142
  <span slot="value">${this.#r(this.value)}</span>
143
143
  ${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
@@ -284,7 +284,7 @@ Correct shape for <chart-ui x="label" y="value">:
284
284
  <div data-empty>No matches</div>
285
285
  <div data-footer></div>
286
286
  </div>
287
- `,this.#$(),n.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...n),r.length&&this.#d.replaceChildren(...r),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#P()}#$(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#P(){this.#r&&(this.#r.addEventListener("input",this.#g),this.#r.addEventListener("keydown",this.#b),this.#r.addEventListener("focus",this.#y),this.#r.addEventListener("blur",this.#O)),this.#u&&this.#u.addEventListener("click",this.#v),this.#d&&this.#d.addEventListener("click",this.#w)}#M(){this.#r&&(this.#r.removeEventListener("input",this.#g),this.#r.removeEventListener("keydown",this.#b),this.#r.removeEventListener("focus",this.#y),this.#r.removeEventListener("blur",this.#O)),this.#u&&this.#u.removeEventListener("click",this.#v),this.#d&&this.#d.removeEventListener("click",this.#w)}#L(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&!e&&(e=r.value);t.push(n)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){Rt(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#Q(),this.#Y()})}get options(){return this.#t}#C(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#I(t){return this.#C().find(e=>e.value===t)||null}#Q(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#C(),i=this.#q(e).slice(0,Number(this.maxOptions)||100),n=0,r=a=>{n+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${n}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.innerHTML=`<span data-option-label>${this.#R(a.label??a.value)}</span>`,l.addEventListener("click",this.#S),l.addEventListener("mouseenter",this.#x),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#q(a.options);if(!l.length)continue;let h=document.createElement("div");h.setAttribute("role","group");let c=document.createElement("div");c.setAttribute("data-group-label",""),c.textContent=a.label||"",h.appendChild(c);for(let u of l)h.appendChild(r(u));t.appendChild(h)}else a&&this.#E(a)&&t.appendChild(r(a));else for(let a of i)t.appendChild(r(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.open&&this.#T(),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#T(){if(!this.#o)return;let t=Number(this.maxVisibleItems),e=this.#o.querySelectorAll('[role="option"]');if(!Number.isFinite(t)||t<=0||e.length<=t){this.#o.style.removeProperty("--combobox-list-max-block");return}let i=e[0].getBoundingClientRect().height;if(!i)return;let n=getComputedStyle(this.#o),r=(parseFloat(n.paddingBlockStart)||0)+(parseFloat(n.paddingBlockEnd)||0)+(parseFloat(n.borderBlockStartWidth)||0)+(parseFloat(n.borderBlockEndWidth)||0);this.#o.style.setProperty("--combobox-list-max-block",`${Math.ceil(i*t+r)}px`)}#R(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Ws(e);let i=this.#i,n=new RegExp(XR(i),"i"),r=e.match(n);if(!r)return Ws(e);let o=r.index??0,a=o+r[0].length;return Ws(e.slice(0,o))+"<mark>"+Ws(e.slice(o,a))+"</mark>"+Ws(e.slice(a))}#E(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let n=0;for(let r of e){if(n=i.indexOf(r,n),n===-1)return!1;n+=1}return!0}default:return i.includes(e)}}#q(t){return this.#i?t.filter(e=>this.#E(e)):t.slice()}#B(){if(this.#n)return;let t=this.#r.textContent||"";this.#i=t.trim(),this.#r.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#Q();let e=this.#X();this.#i&&e.length&&this.#V(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#Z(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#W(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#W(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#V(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#X();this.#V(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#D();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#st("escape"));return}if(e==="Tab"){this.#U();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#_(){}#N(t){!this.freeText&&this.#i&&!this.value&&(this.#Y(),this.#i="")}#X(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#W(t){let e=this.#X();if(!e.length)return;if(this.#s<0){this.#V(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#V(i)}#V(t){let e=this.#X();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let o of e)o.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];if(!n)return;n.setAttribute("data-active","");let r=this.#o;if(r){let o=n.offsetTop,a=o+n.offsetHeight;o<r.scrollTop?r.scrollTop=o:a>r.scrollTop+r.clientHeight&&(r.scrollTop=a-r.clientHeight)}this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id)}#F(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#G(i,"click")}#z(t){let e=t.currentTarget,n=this.#X().indexOf(e);n>=0&&this.#V(n)}#D(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#X(),e=this.#s>=0?t[this.#s]:null;if(e){this.#G(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#H("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}if(this.freeText){this.#K(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#Y(),this.#i="",this.#Q()}#U(){if(!this.open)return;let t=this.#X(),e=this.#s>=0?t[this.#s]:null;if(e){this.#G(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#I(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}this.#Y(),this.#i="",this.#H("blur")}#G(t,e){if(this.readonly){this.#H("select");return}let i=this.#I(t);Rt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#K(t,e){if(this.readonly){this.#H("select");return}Rt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#tt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#r?.focus()}#J(t){Rt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#Y(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#et(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#r?.focus()))}#it(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#Y(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#st(t){this.#Y(),this.#i="",this.#Q(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#nt(){if(!this.#o)return;this.#o.showPopover?.(),this.#T();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=lt(t,this.#o,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{this.#p=null,document.addEventListener("pointerdown",this.#k)});let e=this.#X();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#V(i>=0?i:0)}#H(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#Y(){if(!this.#r)return;let t=this.#I(this.value),e=t?t.label??t.value??"":this.value||"";(this.#r.textContent||"")!==e&&(this.#n=!0,this.#r.textContent=e,this.#n=!1),this.#r.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#r?.focus()}selectOption(t){return this.#I(t)?(this.#G(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};x("combobox-ui",Mo);_e();var qR=0;function NR(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ro=class extends Z{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=Z.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
287
+ `,this.#$(),n.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...n),r.length&&this.#d.replaceChildren(...r),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#P()}#$(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#P(){this.#r&&(this.#r.addEventListener("input",this.#g),this.#r.addEventListener("keydown",this.#b),this.#r.addEventListener("focus",this.#y),this.#r.addEventListener("blur",this.#O)),this.#u&&this.#u.addEventListener("click",this.#v),this.#d&&this.#d.addEventListener("click",this.#w)}#M(){this.#r&&(this.#r.removeEventListener("input",this.#g),this.#r.removeEventListener("keydown",this.#b),this.#r.removeEventListener("focus",this.#y),this.#r.removeEventListener("blur",this.#O)),this.#u&&this.#u.removeEventListener("click",this.#v),this.#d&&this.#d.removeEventListener("click",this.#w)}#L(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&!e&&(e=r.value);t.push(n)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){Rt(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#Q(),this.#Y()})}get options(){return this.#t}#C(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#I(t){return this.#C().find(e=>e.value===t)||null}#Q(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#C(),i=this.#q(e).slice(0,Number(this.maxOptions)||100),n=0,r=a=>{n+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${n}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.setAttribute("data-single-option",""),l.innerHTML=`<span data-radio aria-hidden="true"></span><span data-option-label>${this.#R(a.label??a.value)}</span>`,l.addEventListener("click",this.#S),l.addEventListener("mouseenter",this.#x),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#q(a.options);if(!l.length)continue;let h=document.createElement("div");h.setAttribute("role","group");let c=document.createElement("div");c.setAttribute("data-group-label",""),c.textContent=a.label||"",h.appendChild(c);for(let u of l)h.appendChild(r(u));t.appendChild(h)}else a&&this.#E(a)&&t.appendChild(r(a));else for(let a of i)t.appendChild(r(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.open&&this.#T(),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#T(){if(!this.#o)return;let t=Number(this.maxVisibleItems),e=this.#o.querySelectorAll('[role="option"]');if(!Number.isFinite(t)||t<=0||e.length<=t){this.#o.style.removeProperty("--combobox-list-max-block");return}let i=e[0].getBoundingClientRect().height;if(!i)return;let n=getComputedStyle(this.#o),r=(parseFloat(n.paddingBlockStart)||0)+(parseFloat(n.paddingBlockEnd)||0)+(parseFloat(n.borderBlockStartWidth)||0)+(parseFloat(n.borderBlockEndWidth)||0);this.#o.style.setProperty("--combobox-list-max-block",`${Math.ceil(i*t+r)}px`)}#R(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Ws(e);let i=this.#i,n=new RegExp(XR(i),"i"),r=e.match(n);if(!r)return Ws(e);let o=r.index??0,a=o+r[0].length;return Ws(e.slice(0,o))+"<mark>"+Ws(e.slice(o,a))+"</mark>"+Ws(e.slice(a))}#E(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let n=0;for(let r of e){if(n=i.indexOf(r,n),n===-1)return!1;n+=1}return!0}default:return i.includes(e)}}#q(t){return this.#i?t.filter(e=>this.#E(e)):t.slice()}#B(){if(this.#n)return;let t=this.#r.textContent||"";this.#i=t.trim(),this.#r.toggleAttribute("data-empty",!t),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#Q();let e=this.#X();this.#i&&e.length&&this.#V(0),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#Z(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#W(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#W(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#V(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#X();this.#V(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#D();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#st("escape"));return}if(e==="Tab"){this.#U();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#J("keyboard"));return}}#_(){}#N(t){!this.freeText&&this.#i&&!this.value&&(this.#Y(),this.#i="")}#X(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#W(t){let e=this.#X();if(!e.length)return;if(this.#s<0){this.#V(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#V(i)}#V(t){let e=this.#X();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let o of e)o.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];if(!n)return;n.setAttribute("data-active","");let r=this.#o;if(r){let o=n.offsetTop,a=o+n.offsetHeight;o<r.scrollTop?r.scrollTop=o:a>r.scrollTop+r.clientHeight&&(r.scrollTop=a-r.clientHeight)}this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id)}#F(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#G(i,"click")}#z(t){let e=t.currentTarget,n=this.#X().indexOf(e);n>=0&&this.#V(n)}#D(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#X(),e=this.#s>=0?t[this.#s]:null;if(e){this.#G(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#H("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}if(this.freeText){this.#K(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#Y(),this.#i="",this.#Q()}#U(){if(!this.open)return;let t=this.#X(),e=this.#s>=0?t[this.#s]:null;if(e){this.#G(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#I(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#K(i,"keyboard");return}this.#Y(),this.#i="",this.#H("blur")}#G(t,e){if(this.readonly){this.#H("select");return}let i=this.#I(t);Rt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#K(t,e){if(this.readonly){this.#H("select");return}Rt(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#Y(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#tt(t){t.preventDefault(),t.stopPropagation(),this.#J("click"),this.#r?.focus()}#J(t){Rt(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#Y(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#J("programmatic")}#et(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#r?.focus()))}#it(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#Y(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#st(t){this.#Y(),this.#i="",this.#Q(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#nt(){if(!this.#o)return;this.#o.showPopover?.(),this.#T();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#f?.(),this.#f=lt(t,this.#o,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{this.#p=null,document.addEventListener("pointerdown",this.#k)});let e=this.#X();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#V(i>=0?i:0)}#H(t){this.#o&&(this.#f?.(),this.#f=null,this.#o.hidePopover?.(),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null),document.removeEventListener("pointerdown",this.#k),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#Y(){if(!this.#r)return;let t=this.#I(this.value),e=t?t.label??t.value??"":this.value||"";(this.#r.textContent||"")!==e&&(this.#n=!0,this.#r.textContent=e,this.#n=!1),this.#r.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#r?.focus()}selectOption(t){return this.#I(t)?(this.#G(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};x("combobox-ui",Mo);_e();var qR=0;function NR(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ro=class extends Z{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=Z.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
288
288
  `,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},transform:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let n=this.#z(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++qR}`;#u=()=>this.#M();#d=t=>this.#L(t);#f=t=>this.#C(t);#p=t=>this.#I(t);#m=t=>this.#Q(t);#g=t=>this.#T(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#z(this.getAttribute("value"));t&&(this.#t=t)}this.#b(),this.#x(),this.#$(),this.#P()}disconnected(){super.disconnected(),this.#S(),this.#a=null,this.#o=null,this.#l=null,this.#c=null}render(){this.#o&&(this.disabled||this.readonly?this.#o.contentEditable="false":this.#o.contentEditable="plaintext-only",this.#o.setAttribute("data-placeholder",this.placeholder||""),this.#e.length?(this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","listbox"),this.setAttribute("aria-expanded",String(!!this.hasAttribute("suggesting")))):(this.setAttribute("role","group"),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded")),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.placeholder||"Tags"))}set value(t){Rt(()=>{let e=Array.isArray(t)?t.map(n=>String(n??"")):typeof t=="string"?this.#z(t)||[]:[],i=this.#t.slice();this.#t=e,this.#x(),this.#$(),this.#P(),this.#_(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){Rt(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#A(),this.render()})}get suggestions(){return this.#e.slice()}set validateFn(t){this.#i=typeof t=="function"?t:null}get validateFn(){return this.#i}addToken(t){return this.#E(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#Z(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#x(),this.#$(),this.#P(),this.#_(t,[],"programmatic")}focus(){this.#o?.focus()}#b(){if(this.querySelector(":scope > [data-chip-list]")){this.#y(),this.#O();return}let t=this.querySelector(':scope > template[slot="chip"]'),e=`${this.#h}-suggestions`,i=`${this.#h}-input`;this.innerHTML=`
289
289
  <div data-chip-list role="list" aria-label="Tags"></div>
290
290
  <span data-inline-input