import S from"./Icon.fe8c0e68.js";import U from"./Avatar.b92bd51d.js";import H from"./Kbd.56cf2239.js";import{_ as O}from"./_plugin-vue_export-helper.c27b6911.js";import{g as B,j,v as w,o,c as t,y as s,t as u,l,a as m,F as I,x as q,k as f,w as A,H as h,K as z,V as N,d as V}from"./entry.9e31e8a4.js";import{Y as K}from"./combobox.6c039cbe.js";import"./tw-merge.27ca352e.js";import"./ui.config.7ae255de.js";import"./dom.737f30ce.js";import"./use-tracked-pointer.81956309.js";import"./focus-management.fbd5ae77.js";import"./open-closed.4ff1261a.js";import"./use-resolve-button-type.13bd624b.js";import"./use-outside-click.047f3b08.js";import"./hidden.1f99b477.js";import"./use-controllable.c4815e67.js";import"./disposables.57da4964.js";import"./micro-task.89dcd6af.js";const L=B({components:{HComboboxOption:K,UIcon:S,UAvatar:U,UKbd:H},props:{group:{type:Object,required:!0},query:{type:String,default:""},groupAttribute:{type:String,required:!0},commandAttribute:{type:String,required:!0},selectedIcon:{type:String,required:!0},ui:{type:Object,required:!0}},setup(e){const k=j(()=>{const n=e.group[e.groupAttribute];return typeof n=="function"?n(e.query):n});function v(n,{indices:$,value:g}){if(n===g)return"";let i="",d=0;$.forEach(p=>{const r=p[1]+1,y=r-p[0]>=e.query.length;i+=[g.substring(d,p[0]),y&&"<mark>",g.substring(p[0],r),y&&"</mark>"].filter(Boolean).join(""),d=r}),i+=g.substring(d);const b=i.indexOf("<mark>");return b>60&&(i=`...${i.substring(b-60)}`),i}return{label:k,highlight:v}}}),M=["aria-label"],P=["innerHTML"];function T(e,k,v,n,$,g){const i=S,d=U,b=H,p=w("HComboboxOption");return o(),t("div",{class:s(e.ui.group.wrapper),role:"option"},[e.label?(o(),t("h2",{key:0,class:s(e.ui.group.label)},u(e.label),3)):l("",!0),m("div",{class:s(e.ui.group.container),role:"listbox","aria-label":e.group[e.groupAttribute]},[(o(!0),t(I,null,q(e.group.commands,(r,y)=>(o(),f(p,{key:`${e.group.key}-${y}`,value:r,disabled:r.disabled,as:"template"},{default:A(({active:a,selected:c})=>[m("div",{class:s([e.ui.group.command.base,a?e.ui.group.command.active:e.ui.group.command.inactive,r.disabled?"cursor-not-allowed":"cursor-pointer"])},[m("div",{class:s(e.ui.group.command.container)},[h(e.$slots,`${e.group.key}-icon`,{group:e.group,command:r,active:a,selected:c},()=>[r.icon?(o(),f(i,{key:0,name:r.icon,class:s([e.ui.group.command.icon.base,a?e.ui.group.command.icon.active:e.ui.group.command.icon.inactive,r.iconClass]),"aria-hidden":"true"},null,8,["name","class"])):r.avatar?(o(),f(d,z({key:1},{size:e.ui.group.command.avatar.size,...r.avatar},{class:e.ui.group.command.avatar.base,"aria-hidden":"true"}),null,16,["class"])):r.chip?(o(),t("span",{key:2,class:s(e.ui.group.command.chip.base),style:N({background:`#${r.chip}`})},null,6)):l("",!0)]),m("div",{class:s([e.ui.group.command.label,r.disabled&&e.ui.group.command.disabled])},[h(e.$slots,`${e.group.key}-command`,{group:e.group,command:r,active:a,selected:c},()=>[r.prefix?(o(),t("span",{key:0,class:s(["flex-shrink-0",r.prefixClass||e.ui.group.command.prefix])},u(r.prefix),3)):l("",!0),m("span",{class:s(["truncate",{"flex-none":r.suffix||r.matches?.length}])},u(r[e.commandAttribute]),3),r.matches?.length?(o(),t("span",{key:1,class:s(["truncate",r.suffixClass||e.ui.group.command.suffix]),innerHTML:e.highlight(r[e.commandAttribute],r.matches[0])},null,10,P)):r.suffix?(o(),t("span",{key:2,class:s(["truncate",r.suffixClass||e.ui.group.command.suffix])},u(r.suffix),3)):l("",!0)])],2)],2),c?(o(),f(i,{key:0,name:e.selectedIcon,class:s(e.ui.group.command.selectedIcon.base),"aria-hidden":"true"},null,8,["name","class"])):a&&(e.group.active||e.$slots[`${e.group.key}-active`])?h(e.$slots,`${e.group.key}-active`,{key:1,group:e.group,command:r,active:a,selected:c},()=>[e.group.active?(o(),t("span",{key:0,class:s(e.ui.group.active)},u(e.group.active),3)):l("",!0)]):h(e.$slots,`${e.group.key}-inactive`,{key:2,group:e.group,command:r,active:a,selected:c},()=>[r.shortcuts?.length?(o(),t("span",{key:0,class:s(e.ui.group.command.shortcuts)},[(o(!0),t(I,null,q(r.shortcuts,C=>(o(),f(b,{key:C},{default:A(()=>[V(u(C),1)]),_:2},1024))),128))],2)):!r.disabled&&e.group.inactive?(o(),t("span",{key:1,class:s(e.ui.group.inactive)},u(e.group.inactive),3)):l("",!0)])],2)]),_:2},1032,["value","disabled"]))),128))],10,M)],2)}const ie=O(L,[["render",T]]);export{ie as default};
