/**
 * Copyright 2019 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as t,html as e,css as l}from"../../../lit/index.js";import{SimpleModalCssVars as o}from"../simple-modal.js";class SimpleModalTemplate extends t{static get styles(){return[l`
        :host {
          display: none;
        }
      `]}static get tag(){return"simple-modal-template"}constructor(){super(),this.title="",this.modal=globalThis.SimpleModal.requestAvailability()}static get properties(){return{modal:{type:Object},title:{type:String},mode:{type:String}}}render(){return e`
      <slot name="header"></slot>
      <slot name="content"></slot>
      <slot name="buttons"></slot>
    `}associateEvents(t,e="click",l=!0,o=!0){return t.addEventListener(e,(e=>{this.openModal(t,l,o)})),this.modal}openModal(t,e=!0,l=!0){let s=getComputedStyle(this),i={};o.forEach((t=>{i[t]=s.getPropertyValue(t),"--simple-modal-z-index"==t&&(i[t]=Number(i[t]))}));const a=new CustomEvent("simple-modal-show",{bubbles:e,cancelable:l,composed:!0,detail:{id:this.getAttribute("modal-id"),elements:{header:this._getSlot("header"),content:this._getSlot("content"),buttons:this._getSlot("buttons"),custom:this._getCustom()},resize:this.resize,invokedBy:t,modalClass:this.getAttribute("class"),styles:i,clone:!1,mode:null!==this.mode&&this.mode,title:null!==this.title&&this.title}});globalThis.dispatchEvent(a)}_getCustom(){let t=this.querySelectorAll('[slot="custom"]');return 1==t.length?t[0].cloneNode(!0):this._getSlot("custom")}_getSlot(t){let e=this.querySelectorAll('[slot="'+t+'"]');e&&e[0]&&"SLOT"==e[0].tagName&&(e=e[0].assignedNodes({flatten:!0}));let l=globalThis.document.createElement("div");return e.forEach((t=>{l.appendChild(t.cloneNode(!0))})),null!==e&&l.cloneNode(!0)}}customElements.define(SimpleModalTemplate.tag,SimpleModalTemplate);export{SimpleModalTemplate};