"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var a=require("../../_virtual/jsx-runtime.js"),l=require("react"),m=require("../../utils/index.js"),r=require("./styles.js");function b(e){return e&&e.__esModule?e:{default:e}}var o=b(l);function x(e){const i=m.getId(e["data-testid"]);if(e.breadcrumbs.length===0)throw new Error("Breadcrumbs need at least one item to render.");function u(n){return e.currentPage?!0:n+1<e.breadcrumbs.length}function s(){const{length:n}=e.breadcrumbs;return e.breadcrumbs[n-1]}switch(e.variant){case"back":let n=function(t){t.stopPropagation(),d&&d.onClick&&d.onClick(t)};const d=s();return a.jsxRuntimeExports.jsxs(r.BreadcrumbWrapper,{onClick:n,scrim:e.scrim,variant:"back","data-testid":e["data-testid"],"data-trackid":e["data-trackid"],"aria-label":"breadcrumbs",children:[a.jsxRuntimeExports.jsx(r.BreadcrumbBackChevron,{role:"img","data-testid":i("back-chevron")}),a.jsxRuntimeExports.jsx(r.BreadcrumbItem,{onClick:n,"data-testid":i("back-button"),children:d.label})]});case"default":default:return a.jsxRuntimeExports.jsxs(r.BreadcrumbWrapper,{scrim:e.scrim,variant:"default","data-testid":e["data-testid"],"data-trackid":e["data-trackid"],"aria-label":"breadcrumbs",children:[e.breadcrumbs.map((t,c)=>a.jsxRuntimeExports.jsxs(o.default.Fragment,{children:[a.jsxRuntimeExports.jsx(r.BreadcrumbItem,{target:t.href&&e.target?e.target:void 0,as:t.href?"a":"button",href:t.href,onClick:t.href?void 0:t.onClick,"data-testid":i(`item-${c}`),children:t.label}),u(c)&&a.jsxRuntimeExports.jsx(r.BreadcrumbChevron,{role:"img","data-testid":i(`chevron-${c}`)})]},`bc-${c}-${t.label}`)),e.currentPage&&a.jsxRuntimeExports.jsx(r.BreadcrumbCurrentPage,{target:e.currentPageLink&&e.target?e.target:void 0,"aria-current":"page","data-testid":i("current-page"),as:e.currentPageLink?"a":void 0,href:e.currentPageLink,children:e.currentPage})]})}}exports.Breadcrumb=x;
