'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-58ea899e.js');
const component = require('./component-1e352960.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const ui = require('./ui-ae4ee13d.js');

var __decorate$2 = (undefined && undefined.__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;
};
/**
 * VegaBackdrop visible controller
 */
class VegaBackdropVisibleController extends globalSlimmerRegistry.VegaSlimmer {
  /**
   * During the loading process of the component, the background style is updated.
   */
  componentDidLoad() {
    this.updateBackdropStyle();
  }
  /**
   * Watching the visible prop.
   */
  watchVisible() {
    this.updateBackdropStyle();
  }
  /**
   * If visible is true, the backdrop will be visible.
   * If visible is false, the backdrop will be hidden and backdrop display will be none after the duration.
   */
  updateBackdropStyle() {
    if (this.visible) {
      this.host.style.display = 'block';
      setTimeout(() => {
        this.host.style.opacity = '1';
      });
    }
    else {
      this.host.style.opacity = '0';
      setTimeout(() => {
        if (!this.visible) {
          this.host.style.display = 'none';
        }
      }, this.duration);
    }
  }
}
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropVisibleController.prototype, "host", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropVisibleController.prototype, "visible", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropVisibleController.prototype, "duration", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
], VegaBackdropVisibleController.prototype, "componentDidLoad", null);
__decorate$2([
  globalSlimmerRegistry.MapToComponentMethod('watchVisible')
], VegaBackdropVisibleController.prototype, "watchVisible", null);

var __decorate$1 = (undefined && undefined.__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;
};
class VegaBackdropRenderer extends globalSlimmerRegistry.VegaSlimmer {
  render() {
    const { duration = 0, color } = this;
    return (index.h(index.Host, { style: {
        transitionDuration: duration ? `${duration}ms` : '',
      }, class: ui.arrayToClassString([color]), 
      /* eslint-disable-next-line react/jsx-no-bind */
      onClick: () => this.vegaClick.emit(), "aria-hidden": true }));
  }
}
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropRenderer.prototype, "visible", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropRenderer.prototype, "color", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropRenderer.prototype, "duration", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaBackdropRenderer.prototype, "vegaClick", void 0);

const vegaBackdropCss = ":host{position:fixed;top:0px;left:0px;right:0px;bottom:0px;opacity:0;display:none;transition-timing-function:cubic-bezier(0, 0, 0.2, 1);transition-property:opacity}:host(.bg-backdrop-modal){background-color:rgba(var(--v-bg-backdrop-modal, 18, 18, 39, 0.85))}:host(.bg-backdrop-popover){background-color:rgba(var(--v-bg-backdrop-popover, 32, 54, 69, 0.16))}:host(.bg-transparent){background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0))}";

var __decorate = (undefined && undefined.__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;
};
const VegaBackdrop = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.vegaClick = index.createEvent(this, "vegaClick", 7);
    this.globalSlimmers = {};
    this.vegaBackdropVisibleController = new VegaBackdropVisibleController();
    this.vegaBackdropRenderer = new VegaBackdropRenderer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Defines the color of the backdrop element.
     *
     * @vegaVersion 2.0.0
     */
    this.color = 'bg-backdrop-modal';
    /**
     * Whether to show or hide the backdrop
     *
     * @vegaVersion 2.0.0
     */
    this.visible = false;
  }
  watchVisible() {
  }
  render() {
    return component.sanitizeVegaComponent(this.vegaBackdropRenderer.render(), this.host);
  }
  get host() { return index.getElement(this); }
  static get watchers() { return {
    "visible": ["watchVisible"]
  }; }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaBackdrop.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaBackdrop.prototype, "vegaBackdropVisibleController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaBackdrop.prototype, "vegaBackdropRenderer", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaBackdrop.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaBackdrop.style = vegaBackdropCss;

exports.vega_backdrop = VegaBackdrop;
