"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var theme_1 = require("../middleware/theme");
var vdom_1 = require("@dojo/framework/core/vdom");
var css = require("../theme/default/breadcrumb-group.m.css");
var fixedCss = require("./styles/breadcrumb-group.m.css");
var separatorFactory = vdom_1.create({ theme: theme_1.default });
exports.Separator = separatorFactory(function Separator(_a) {
    var children = _a.children, theme = _a.middleware.theme;
    var themeCss = theme.classes(css);
    return (vdom_1.tsx("li", { "aria-hidden": "true", classes: themeCss.listItem },
        vdom_1.tsx("span", { classes: [fixedCss.separatorFixed, themeCss.separator] }, children())));
});
exports.BreadcrumbSeparator = exports.Separator;
var breadcrumbFactory = vdom_1.create({ theme: theme_1.default }).properties();
exports.Breadcrumb = breadcrumbFactory(function Breadcrumb(_a) {
    var children = _a.children, theme = _a.middleware.theme, properties = _a.properties;
    var _b = properties(), current = _b.current, href = _b.href, title = _b.title;
    var themeCss = theme.classes(css);
    return (vdom_1.tsx("li", { classes: [themeCss.listItem, current ? themeCss.current : undefined] }, href ? (vdom_1.tsx("a", { "aria-current": current || undefined, classes: [fixedCss.breadcrumbFixed, themeCss.breadcrumb], href: href, title: title }, children())) : (vdom_1.tsx("span", { "aria-current": current || undefined, classes: [fixedCss.breadcrumbFixed, themeCss.breadcrumb] }, children()))));
});
var factory = vdom_1.create({ theme: theme_1.default })
    .properties()
    .children();
exports.BreadcrumbGroup = factory(function BreadcrumbGroup(_a) {
    var children = _a.children, properties = _a.properties, theme = _a.middleware.theme;
    var _b = properties(), items = _b.items, label = _b.label, classes = _b.classes, themeProp = _b.theme, variant = _b.variant;
    var themeCss = theme.classes(css);
    var defaultRenderer = function (items) {
        var lastIndex = items.length - 1;
        return items.map(function (item, index) { return (vdom_1.tsx("virtual", null,
            index !== 0 && vdom_1.tsx(exports.Separator, { key: "breadcrumb-" + index + "-separator" }, "/"),
            vdom_1.tsx(exports.Breadcrumb, { key: "breadcrumb-" + index, current: index === lastIndex ? 'page' : undefined, href: item.href, title: item.title, classes: classes, theme: themeProp, variant: variant }, item.label))); });
    };
    var _c = tslib_1.__read(children(), 1), _d = _c[0], renderer = _d === void 0 ? defaultRenderer : _d;
    return (vdom_1.tsx("nav", { classes: [theme.variant(), themeCss.root], "aria-label": label },
        vdom_1.tsx("ol", { classes: [fixedCss.listFixed, themeCss.list] }, renderer(items))));
});
exports.default = exports.BreadcrumbGroup;

/*# sourceMappingURL=index.js.map*/