import U from"./Icon.RQAIFpgh.js";import{_ as B}from"./Avatar.sEieiGia.js";import O from"./Kbd.jbtAGVVz.js";import{_ as z}from"./_plugin-vue_export-helper.x3n3nnut.js";import{h as H,v as w,E as M,o,c as i,B as s,t as u,z as l,a as b,F as I,A as q,y,w as S,M as v,P as N,$ as j,d as E}from"./entry.RGd0w9hd.js";import{Y as L}from"./combobox.7fhLu1gU.js";import"./Icon.IbV_ZJvz.js";import"./index.aIcZnwHK.js";import"./selectMenu.C9lwG85K.js";import"./dom.vx4sd08t.js";import"./use-tracked-pointer.jcmvkDWj.js";import"./focus-management.3ip_EPSh.js";import"./open-closed.L86q9WWN.js";import"./use-resolve-button-type.q1QsTaKC.js";import"./use-outside-click.4nsAJllP.js";import"./hidden.q9bj9KME.js";import"./use-controllable.IRSiZAwX.js";import"./disposables.MoseSqH0.js";import"./micro-task.ZxAilEVg.js";const P=H({components:{HComboboxOption:L,UIcon:U,UAvatar:B,UKbd:O},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 $=w(()=>{const n=e.group[e.groupAttribute];return typeof n=="function"?n(e.query):n});function C(n,{indices:A,value:g}){if(n===g)return"";let t="",d=0;A.forEach(p=>{const r=p[1]+1,k=r-p[0]>=e.query.length;t+=[g.substring(d,p[0]),k&&"<mark>",g.substring(p[0],r),k&&"</mark>"].filter(Boolean).join(""),d=r}),t+=g.substring(d);const h=t.indexOf("<mark>");return h>60&&(t=`...${t.substring(h-60)}`),t}return{label:$,highlight:C}}}),T=["aria-label"],V=["innerHTML"];function F(e,$,C,n,A,g){const t=U,d=B,h=O,p=M("HComboboxOption");return o(),i("div",{class:s(e.ui.group.wrapper),role:"option"},[e.label?(o(),i("h2",{key:0,class:s(e.ui.group.label)},u(e.label),3)):l("",!0),b("div",{class:s(e.ui.group.container),role:"listbox","aria-label":e.group[e.groupAttribute]},[(o(!0),i(I,null,q(e.group.commands,(r,k)=>(o(),y(p,{key:`${e.group.key}-${k}`,value:r,disabled:r.disabled,as:"template"},{default:S(({active:a,selected:c})=>[b("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"])},[b("div",{class:s(e.ui.group.command.container)},[v(e.$slots,`${e.group.key}-icon`,{group:e.group,command:r,active:a,selected:c},()=>[r.icon?(o(),y(t,{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(),y(d,N({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(),i("span",{key:2,class:s(e.ui.group.command.chip.base),style:j({background:`#${r.chip}`})},null,6)):l("",!0)]),b("div",{class:s([e.ui.group.command.label,r.disabled&&e.ui.group.command.disabled])},[v(e.$slots,`${e.group.key}-command`,{group:e.group,command:r,active:a,selected:c},()=>{var m,f;return[r.prefix?(o(),i("span",{key:0,class:s(["flex-shrink-0",r.prefixClass||e.ui.group.command.prefix])},u(r.prefix),3)):l("",!0),b("span",{class:s(["truncate",{"flex-none":r.suffix||((m=r.matches)==null?void 0:m.length)}])},u(r[e.commandAttribute]),3),(f=r.matches)!=null&&f.length?(o(),i("span",{key:1,class:s(["truncate",r.suffixClass||e.ui.group.command.suffix]),innerHTML:e.highlight(r[e.commandAttribute],r.matches[0])},null,10,V)):r.suffix?(o(),i("span",{key:2,class:s(["truncate",r.suffixClass||e.ui.group.command.suffix])},u(r.suffix),3)):l("",!0)]})],2)],2),c?(o(),y(t,{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`])?v(e.$slots,`${e.group.key}-active`,{key:1,group:e.group,command:r,active:a,selected:c},()=>[e.group.active?(o(),i("span",{key:0,class:s(e.ui.group.active)},u(e.group.active),3)):l("",!0)]):v(e.$slots,`${e.group.key}-inactive`,{key:2,group:e.group,command:r,active:a,selected:c},()=>{var m;return[(m=r.shortcuts)!=null&&m.length?(o(),i("span",{key:0,class:s(e.ui.group.command.shortcuts)},[(o(!0),i(I,null,q(r.shortcuts,f=>(o(),y(h,{key:f},{default:S(()=>[E(u(f),1)]),_:2},1024))),128))],2)):!r.disabled&&e.group.inactive?(o(),i("span",{key:1,class:s(e.ui.group.inactive)},u(e.group.inactive),3)):l("",!0)]})],2)]),_:2},1032,["value","disabled"]))),128))],10,T)],2)}const ue=z(P,[["render",F]]);export{ue as default};
