import e from"../_util/warning.mjs";import{flattenChildren as t,getPropsSlot as n}from"../_util/props-util/index.mjs";import r from"../config-provider/hooks/useConfigInject.mjs";import i from"../_util/vue-types/index.mjs";import a from"../menu/index.mjs";import o from"./BreadcrumbItem.mjs";import s from"./style/index.mjs";import{cloneVNode as c,createVNode as l,defineComponent as u}from"vue";var d=()=>({prefixCls:String,routes:{type:Array},params:i.any,separator:i.any,itemRender:{type:Function}});function f(e,t){if(!e.breadcrumbName)return null;let n=Object.keys(t).join(`|`);return e.breadcrumbName.replace(RegExp(`:(${n})`,`g`),(e,n)=>t[n]||e)}function p(e){let{route:t,params:n,routes:r,paths:i}=e,a=r.indexOf(t)===r.length-1,o=f(t,n);return a?l(`span`,null,[o]):l(`a`,{href:`#/${i.join(`/`)}`},[o])}var m=u({compatConfig:{MODE:3},name:`ABreadcrumb`,inheritAttrs:!1,props:d(),slots:Object,setup(i,{slots:u,attrs:d}){let{prefixCls:f,direction:m}=r(`breadcrumb`,i),[h,g]=s(f),_=(e,t)=>(e=(e||``).replace(/^\//,``),Object.keys(t).forEach(n=>{e=e.replace(`:${n}`,t[n])}),e),v=(e,t,n)=>{let r=[...e],i=_(t||``,n);return i&&r.push(i),r},y=({routes:e=[],params:t={},separator:n,itemRender:r=p})=>{let i=[];return e.map(s=>{let c=_(s.path,t);c&&i.push(c);let u=[...i],d=null;s.children&&s.children.length&&(d=l(a,{items:s.children.map(n=>({key:n.path||n.breadcrumbName,label:r({route:n,params:t,routes:e,paths:v(u,n.path,t)})}))},null));let f={separator:n};return d&&(f.overlay=d),l(o,{...f,key:c||s.breadcrumbName},{default:()=>[r({route:s,params:t,routes:e,paths:u})]})})};return()=>{let r,{routes:a,params:o={}}=i,s=t(n(u,i)),_=n(u,i,`separator`)??`/`,v=i.itemRender||u.itemRender||p;a&&a.length>0?r=y({routes:a,params:o,separator:_,itemRender:v}):s.length&&(r=s.map((t,n)=>(e(typeof t.type==`object`&&(t.type.__ANT_BREADCRUMB_ITEM||t.type.__ANT_BREADCRUMB_SEPARATOR),`Breadcrumb`,`Only accepts Breadcrumb.Item and Breadcrumb.Separator as it's children`),c(t,{separator:_,key:n}))));let b={[f.value]:!0,[`${f.value}-rtl`]:m.value===`rtl`,[`${d.class}`]:!!d.class,[g.value]:!0};return h(l(`nav`,{...d,class:b},[l(`ol`,null,[r])]))}}});export{d as breadcrumbProps,m as default};