var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, Element, Prop, Method, State, Event, Watch, h, Host } from '@stencil/core';
import { sanitizeVegaComponent } from '../../../utils/component';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, slotPlaceholder, } from 'vega-slimmer/core';
import { VegaLeftNavOpenStateController } from './slimmers/controllers/vega-left-nav-open-state-controller';
import { VegaLeftNavHeaderRenderer } from './slimmers/renderers/vega-left-nav-header-renderer';
import { VegaLeftNavFooterRenderer } from './slimmers/renderers/vega-left-nav-footer-renderer';
import { VegaLeftNavZIndexController } from './slimmers/controllers/vega-left-nav-zindex-controller';
import { VegaLeftNavBackdropController } from './slimmers/controllers/vega-left-nav-backdrop-controller';
import { InjectKeyboardManager } from '../../../decorators/property-decorators/inject-keyboard-manager';
import { VegaNavListRenderer } from '../slimmers/renderers/vega-nav-list-renderer';
import { createEventEmitSlimmer, } from '../../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaStateUpdate } from '../../../helpers/event-manager/event-id/vega-event-id';
import { ComponentGlobalStyleSlimmer } from '../../../helpers/slimmers/component-global-style-slimmer';
import mainContentStyle from './vega-left-nav-content.css';
import { VegaLeftNavAutoCollapseController } from './slimmers/controllers/vega-left-nav-auto-collapse-controller';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../../helpers/slimmers/component-usage-runtime-metrics';
import { VegaLeftNavRuntimeMetricsPayloadDefinition } from '../../../constants/runtime-metrics-payload-definition/vega-left-nav/runtime-metrics-payload-definition';
import { createSubStateNotifySlimmer } from '../../../helpers/slimmers/sub-state/sub-state-notify-slimmer';
import { BrandSwitchControllerSlimmer } from '../../../helpers/slimmers/brand-switch-state-controller-slimmer';
import { VegaInternalThemeManager } from '../../../helpers/theme/internal-theme-manager';
/**
 * @vegaVersion 1.31.0
 */
export class VegaLeftNav {
  constructor() {
    this.globalSlimmers = {};
    this.headerRenderer = new VegaLeftNavHeaderRenderer();
    this.footerRenderer = new VegaLeftNavFooterRenderer();
    this.openStateController = new VegaLeftNavOpenStateController();
    this.backdropController = new VegaLeftNavBackdropController();
    this.zIndexController = new VegaLeftNavZIndexController();
    this.listRenderer = new VegaNavListRenderer();
    this.vegaLeftNavAutoCollapseController = new VegaLeftNavAutoCollapseController();
    this.stateUpdateEventEmitter = createEventEmitSlimmer(VegaLeftNav, VegaStateUpdate);
    this.componentGlobalStyleSlimmer = new ComponentGlobalStyleSlimmer(mainContentStyle);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaLeftNavRuntimeMetricsPayloadDefinition);
    this.autoCollapseGroupsNotifySlimmer = createSubStateNotifySlimmer(VegaLeftNav, 'autoCollapseGroups', 'watchAutoCollapseGroups');
    this.brandSwitchControllerSlimmer = new BrandSwitchControllerSlimmer();
    this.currentBranding = VegaInternalThemeManager.getBranding();
    this.openState = 'close';
    /**
     * Determines whether the left navigation is expanded or collapsed.
     *
     * @vegaVersion 1.39.2
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.open = false;
    /**
     * Specifies the configuration options for the header within the left-nav.
     *
     * You can use this property to define a custom title and subtitle.
     *
     * @vegaVersion 1.31.0
     */
    this.headerConfig = {};
    /**
     * Provides additional information or context in the form of
     *    a footnote in the left-nav footer.
     *
     * @vegaVersion 1.31.0
     */
    this.footnote = '';
    /**
     * Determines whether the left-nav should appear as an overlay,
     *    accompanied by a backdrop that darkens the content on the page.
     *
     * This property has no effect on breakpoints smaller than the desktop size.
     *
     * Note: To use the backdrop-free feature when the left navigation is open, ensure the `show-as-overlay`
     *    property is set to `false` within the `vega-left-nav` component. Additionally, enclose all content
     *    within an element possessing the class `vega-left-nav-content` immediately following the
     *    `vega-left-nav` component.
     *
     * @vegaVersion 1.33.0
     */
    this.showAsOverlay = true;
    /** Determines whether the left navigation automatically collapses when the left navigation link is clicked in overlay mode. *
     * @vegaVersion 2.7.0
     */
    this.autoCollapseOnOverlay = false;
    /**
     * Determines how the left navigation groups behave when clicked, controlling the automatic collapsing of open groups.
     *
     * Available options:
     * - `true`:
     *      Collapses the group when clicking either a group or a link.
     * - `false`:
     *     Collapses the group only when clicking a link; clicking a group does not collapse it.
     * - `always`:
     *     Always collapses the group when clicking a group or link (equivalent to true).
     * - `on-group-click`:
     *      Collapses the group only when clicking a group; clicking a link does not collapse it.
     * - `on-link-click`:
     *      Collapses the group only when clicking a link; clicking a group does not collapse it.
     * - `never`:
     *      Never collapses groups when clicking a group or link.
     * @vegaVersion 2.48.0
     * @VegaWarning - Boolean types are deprecated, please use "on-group-click" | "on-link-click" | "never" | "always" instead.
     */
    this.autoCollapseGroups = false;
  }
  watchOpenState() {
    methodPlaceholder();
  }
  watchOpen() {
    methodPlaceholder();
  }
  watchShowAsOverlay() {
    methodPlaceholder();
  }
  watchAutoCollapseGroups() {
    methodPlaceholder();
  }
  componentWillLoad() {
    if (typeof this.autoCollapseGroups === 'string') {
      if (this.autoCollapseGroups.includes('true')) {
        this.autoCollapseGroups = true;
      }
      else if (this.autoCollapseGroups.includes('false')) {
        this.autoCollapseGroups = false;
      }
    }
  }
  /**
   * Invoke this method to toggle the left-nav's open state.
   *
   * @vegaVersion 1.31.0
   */
  async toggle() {
    methodPlaceholder();
  }
  render() {
    slotPlaceholder(h("slot", null));
    return sanitizeVegaComponent(h(Host, null,
      this.headerRenderer.render(),
      this.listRenderer.render(),
      this.footerRenderer.render()), this.host);
  }
  static get is() { return "vega-left-nav"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-left-nav.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-left-nav.css"]
  }; }
  static get properties() { return {
    "open": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.39.2"
          }],
        "text": "Determines whether the left navigation is expanded or collapsed."
      },
      "attribute": "open",
      "reflect": false,
      "defaultValue": "false"
    },
    "headerConfig": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "LeftNavHeaderConfig",
        "resolved": "{ title?: string; subtitle?: string; }",
        "references": {
          "LeftNavHeaderConfig": {
            "location": "import",
            "path": "../interface"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.31.0"
          }],
        "text": "Specifies the configuration options for the header within the left-nav.\n\nYou can use this property to define a custom title and subtitle."
      },
      "defaultValue": "{}"
    },
    "source": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "LeftNavSourceItem[]",
        "resolved": "LeftNavSourceItem[]",
        "references": {
          "LeftNavSourceItem": {
            "location": "import",
            "path": "../interface"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.31.0"
          }],
        "text": "Specifies source data used to generate the links and\n   groups structure in the left-nav."
      }
    },
    "footnote": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.31.0"
          }],
        "text": "Provides additional information or context in the form of\n   a footnote in the left-nav footer."
      },
      "attribute": "footnote",
      "reflect": false,
      "defaultValue": "''"
    },
    "showAsOverlay": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.33.0"
          }],
        "text": "Determines whether the left-nav should appear as an overlay,\n   accompanied by a backdrop that darkens the content on the page.\n\nThis property has no effect on breakpoints smaller than the desktop size.\n\nNote: To use the backdrop-free feature when the left navigation is open, ensure the `show-as-overlay`\n   property is set to `false` within the `vega-left-nav` component. Additionally, enclose all content\n   within an element possessing the class `vega-left-nav-content` immediately following the\n   `vega-left-nav` component."
      },
      "attribute": "show-as-overlay",
      "reflect": false,
      "defaultValue": "true"
    },
    "autoCollapseOnOverlay": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Determines whether the left navigation automatically collapses when the left navigation link is clicked in overlay mode. *"
      },
      "attribute": "auto-collapse-on-overlay",
      "reflect": false,
      "defaultValue": "false"
    },
    "autoCollapseGroups": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "autoCollapseGroupsType",
        "resolved": "\"always\" | \"never\" | \"on-group-click\" | \"on-link-click\" | boolean",
        "references": {
          "autoCollapseGroupsType": {
            "location": "import",
            "path": "../interface"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.48.0"
          }, {
            "name": "VegaWarning",
            "text": "- Boolean types are deprecated, please use \"on-group-click\" | \"on-link-click\" | \"never\" | \"always\" instead."
          }],
        "text": "Determines how the left navigation groups behave when clicked, controlling the automatic collapsing of open groups.\n\nAvailable options:\n- `true`:\n     Collapses the group when clicking either a group or a link.\n- `false`:\n    Collapses the group only when clicking a link; clicking a group does not collapse it.\n- `always`:\n    Always collapses the group when clicking a group or link (equivalent to true).\n- `on-group-click`:\n     Collapses the group only when clicking a group; clicking a link does not collapse it.\n- `on-link-click`:\n     Collapses the group only when clicking a link; clicking a group does not collapse it.\n- `never`:\n     Never collapses groups when clicking a group or link."
      },
      "attribute": "auto-collapse-groups",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get states() { return {
    "currentBranding": {},
    "openState": {}
  }; }
  static get events() { return [{
      "method": "vegaStateUpdate",
      "name": "vegaStateUpdate",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.31.0"
          }],
        "text": "An event emitter notifying that the left-nav's open state has changed."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "stateUpdate",
      "name": "stateUpdate",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.0.0"
          }],
        "text": "An event emitter notifying that the left-nav's open state has changed."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }]; }
  static get methods() { return {
    "toggle": {
      "complexType": {
        "signature": "() => Promise<void>",
        "parameters": [],
        "references": {
          "Promise": {
            "location": "global"
          }
        },
        "return": "Promise<void>"
      },
      "docs": {
        "text": "Invoke this method to toggle the left-nav's open state.",
        "tags": [{
            "name": "vegaVersion",
            "text": "1.31.0"
          }]
      }
    }
  }; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "openState",
      "methodName": "watchOpenState"
    }, {
      "propName": "open",
      "methodName": "watchOpen"
    }, {
      "propName": "showAsOverlay",
      "methodName": "watchShowAsOverlay"
    }, {
      "propName": "autoCollapseGroups",
      "methodName": "watchAutoCollapseGroups"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaLeftNav.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "headerRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "footerRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "openStateController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "backdropController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "zIndexController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "listRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "vegaLeftNavAutoCollapseController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "stateUpdateEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "componentGlobalStyleSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "autoCollapseGroupsNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLeftNav.prototype, "brandSwitchControllerSlimmer", void 0);
__decorate([
  InjectKeyboardManager((target) => [
    {
      keyCode: 'Escape',
      // eslint-disable-next-line jsdoc/require-jsdoc
      activeElementInScope: /* istanbul ignore next */ () => {
        const backdrop = target.backdropController.getBackdrop();
        if (backdrop && backdrop.visible) {
          // eslint-disable-next-line no-restricted-globals
          return [document.body];
        }
        return [target.host];
      },
      callback: /* istanbul ignore next */ () => {
        const backdrop = target.backdropController.getBackdrop();
        if (backdrop && backdrop.visible) {
          target.openStateController.setOpenState('close');
        }
      },
    },
  ])
], VegaLeftNav.prototype, "host", void 0);
