import { Host, h } from "@stencil/core";
export class BbConnector {
    constructor() {
        this.base = '';
        this.path = '';
        this.root = '';
        this.mode = '';
    }
    get isPathValid() {
        return !!this.path;
    }
    get isRootValid() {
        return !this.root.endsWith('/');
    }
    get isBaseValid() {
        return ['listing', 'collection', 'profile'].includes(this.base);
    }
    historyHelper(history) {
        return {
            link: (path) => this.mode == 'hash' ? '#' + this.root + path : this.root + path,
            forward: (path) => history.push(this.root + path),
            back: (path) => history.pop(this.root + path)
        };
    }
    render() {
        return (h(Host, null,
            h("stencil-router", { historyType: this.mode == 'hash' ? 'hash' : 'browser' },
                this.isRootValid && this.isPathValid && this.base == 'listing' && h("stencil-route-switch", { scrollTopOffset: 0 },
                    h("stencil-route", { url: [this.root, this.root + '/'], exact: true, routeRender: () => (h("div", null,
                            "Listing ",
                            this.path)) }),
                    h("stencil-route", { url: this.root + '/updates/:updateId', exact: true, routeRender: (props) => (h("div", null,
                            "Listing Update ",
                            this.path,
                            " ",
                            props.match.params.updateId)) }),
                    h("stencil-route", { routeRender: () => (h("div", null, "404 - Listing")) })),
                this.isRootValid && this.isPathValid && this.base == 'profile' && h("stencil-route-switch", { scrollTopOffset: 0 },
                    h("stencil-route", { url: [this.root, this.root + '/'], exact: true, routeRender: (props) => h("bb-profile", { profilePath: this.path, history: this.historyHelper(props.history) }) }),
                    h("stencil-route", { url: this.root + '/listings/:listingId', exact: true, routeRender: (props) => (h("bb-listing", { listingPath: props.match.params.listingId, history: this.historyHelper(props.history) })) }),
                    h("stencil-route", { url: this.root + '/updates/:updateId', exact: true, routeRender: (props) => (h("div", null,
                            "Profile/Update ",
                            this.path,
                            " ",
                            props.match.params.updateId)) }),
                    h("stencil-route", { url: this.root + '/collections/:collectionId', exact: true, routeRender: (props) => (h("div", null,
                            "Profile/Collection ",
                            this.path,
                            " ",
                            props.match.params.collectionId)) }),
                    h("stencil-route", { url: this.root + '/collections/:collectionId/listings/:listingId', exact: true, routeRender: (props) => (h("div", null,
                            "Profile/Collection/Listing ",
                            this.path,
                            " ",
                            props.match.params.collectionId)) }),
                    h("stencil-route", { url: this.root + '/collections/:collectionId/listings/:listingId/updates/:updateId', exact: true, routeRender: (props) => (h("div", null,
                            "Profile/Collection/Listing/Update ",
                            this.path,
                            " ",
                            props.match.params.collectionId)) }),
                    h("stencil-route", { routeRender: () => (h("div", null, "404 - Profile")) })),
                this.isRootValid && this.isPathValid && this.base == 'collection' && h("stencil-route-switch", { scrollTopOffset: 0 },
                    h("stencil-route", { url: [this.root, this.root + '/'], exact: true, routeRender: () => (h("div", null,
                            "Collection ",
                            this.path)) }),
                    h("stencil-route", { url: this.root + '/listings/:listingId', exact: true, routeRender: (props) => (h("div", null,
                            "Collection/Listing ",
                            this.path,
                            " ",
                            props.match.params.collectionId)) }),
                    h("stencil-route", { url: this.root + '/listings/:listingId/updates/:updateId', exact: true, routeRender: (props) => (h("div", null,
                            "Collection/Listing/Update ",
                            this.path,
                            " ",
                            props.match.params.collectionId)) }),
                    h("stencil-route", { routeRender: () => (h("div", null, "404 - Collection")) })),
                !this.isRootValid || !this.isPathValid || !this.isBaseValid && h("stencil-route-switch", { scrollTopOffset: 0 },
                    h("stencil-route", { routeRender: () => (h("div", null, "400")) })))));
    }
    static get is() { return "bb-connector"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() { return {
        "$": ["bb-connector.css"]
    }; }
    static get styleUrls() { return {
        "$": ["bb-connector.css"]
    }; }
    static get properties() { return {
        "base": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "base",
            "reflect": false,
            "defaultValue": "''"
        },
        "path": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "path",
            "reflect": false,
            "defaultValue": "''"
        },
        "root": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "root",
            "reflect": false,
            "defaultValue": "''"
        },
        "mode": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "mode",
            "reflect": false,
            "defaultValue": "''"
        }
    }; }
}
