const e=require("../../vc-select/hooks/useBaseProps.js"),t=require("../context.js"),n=require("../utils/commonUtil.js"),r=require("../utils/treeUtil.js"),i=require("./Column.js"),a=require("./useActive.js"),o=require("./useKeyboard.js");let s=require("vue");var c=(0,s.defineComponent)({compatConfig:{MODE:3},name:`OptionList`,inheritAttrs:!1,setup(c,l){let{attrs:u,slots:d}=l,f=e.default(),p=(0,s.ref)(),m=(0,s.computed)(()=>f.direction===`rtl`),{options:h,values:g,halfValues:_,fieldNames:v,changeOnSelect:y,onSelect:b,searchOptions:x,dropdownPrefixCls:S,loadData:C,expandTrigger:w,customSlots:T}=t.useInjectCascader(),E=(0,s.computed)(()=>S.value||f.prefixCls),D=(0,s.shallowRef)([]),O=e=>{if(!C.value||f.searchValue)return;let t=r.toPathOptions(e,h.value,v.value).map(({option:e})=>e),i=t[t.length-1];if(i&&!n.isLeaf(i,v.value)){let r=n.toPathKey(e);D.value=[...D.value,r],C.value(t)}};(0,s.watchEffect)(()=>{D.value.length&&D.value.forEach(e=>{let t=r.toPathOptions(n.toPathValueStr(e),h.value,v.value,!0).map(({option:e})=>e),i=t[t.length-1];(!i||i[v.value.children]||n.isLeaf(i,v.value))&&(D.value=D.value.filter(t=>t!==e))})});let k=(0,s.computed)(()=>new Set(n.toPathKeys(g.value))),A=(0,s.computed)(()=>new Set(n.toPathKeys(_.value))),[j,M]=a.default(),N=e=>{M(e),O(e)},P=e=>{let{disabled:t}=e,r=n.isLeaf(e,v.value);return!t&&(r||y.value||f.multiple)},F=(e,t,n=!1)=>{b(e),!f.multiple&&(t||y.value&&(w.value===`hover`||n))&&f.toggleOpen(!1)},I=(0,s.computed)(()=>f.searchValue?x.value:h.value),L=(0,s.computed)(()=>{let e=[{options:I.value}],t=I.value;for(let n=0;n<j.value.length;n+=1){let r=j.value[n],i=t.find(e=>e[v.value.value]===r)?.[v.value.children];if(!i?.length)break;t=i,e.push({options:i})}return e});o.default(l,I,v,j,N,(e,t)=>{P(t)&&F(e,n.isLeaf(t,v.value),!0)});let R=e=>{e.preventDefault()};return(0,s.onMounted)(()=>{(0,s.watch)(j,e=>{for(let t=0;t<e.length;t+=1){let r=n.toPathKey(e.slice(0,t+1)),i=p.value?.querySelector(`li[data-path-key="${r.replace(/\\{0,2}"/g,`\\"`)}"]`);i&&n.scrollIntoParentView(i)}},{flush:`post`,immediate:!0})}),()=>{let{notFoundContent:e=d.notFoundContent?.()||T.value.notFoundContent?.(),multiple:t,toggleOpen:n}=f,r=!L.value[0]?.options?.length,a=[{[v.value.value]:`__EMPTY__`,[i.FIX_LABEL]:e,disabled:!0}],o={...u,multiple:!r&&t,onSelect:F,onActive:N,onToggleOpen:n,checkedSet:k.value,halfCheckedSet:A.value,loadingKeys:D.value,isSelectable:P},c=(r?[{options:a}]:L.value).map((e,t)=>{let n=j.value.slice(0,t),r=j.value[t];return(0,s.createVNode)(i.default,{key:t,...o,prefixCls:E.value,options:e.options,prevValuePath:n,activeValue:r},null)});return(0,s.createVNode)(`div`,{class:[`${E.value}-menus`,{[`${E.value}-menu-empty`]:r,[`${E.value}-rtl`]:m.value}],onMousedown:R,ref:p},[c])}}});exports.default=c;