/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import{a as f}from"./chunk.UWYANU5D.js";import{a as p}from"./chunk.KTGSZEAG.js";import{a as k,b as v}from"./chunk.DL7NX432.js";import{a as b,e as l,g as A,l as h}from"./chunk.LJLEPTLU.js";import{f as i}from"./chunk.MCIQXNKY.js";var _=`${v}backdrop`,y={CONTAINER:".forge-backdrop"},E={OPACITY:.54,DELAY:0,TRANSITION_DURATION:150},O={DELAY:"delay",MAX_OPACITY:"max-opacity",APPEARANCE:"appearance",FIXED:"fixed"},g={BACKDROP_CLICK:`${_}-click`},e={elementName:_,selectors:y,numbers:E,attributes:O,events:g};var n=class extends f{constructor(a){super(a);this._backdropElement=A(a,e.selectors.CONTAINER)}setBackdropOpacity(a){this._backdropElement.style.opacity=a.toString()}addBackdropEventListener(a,o){this._backdropElement.addEventListener("click",o)}removeBackdropEventListener(a,o){this._backdropElement.removeEventListener("click",o)}};var s=class{constructor(t){this._adapter=t;this._delay=e.numbers.DELAY;this._maxOpacity=e.numbers.OPACITY;this._adapter.addBackdropEventListener("click",this._onClick.bind(this))}initialize(){this._adapter.setBackdropOpacity(0),this._applyAppearance(),this._adapter.setHostAttribute(e.attributes.DELAY,this._delay.toString()),this.fadeIn()}fadeOut(){return new Promise(t=>{this._adapter.setBackdropOpacity(0),setTimeout(()=>t(),e.numbers.TRANSITION_DURATION)})}fadeIn(){return new Promise(t=>{setTimeout(()=>{this._adapter.setBackdropOpacity(this._maxOpacity),setTimeout(()=>t(),e.numbers.TRANSITION_DURATION)},this.delay)})}_onClick(t){t.stopPropagation(),this._adapter.emitHostEvent(e.events.BACKDROP_CLICK,void 0,!0,!0)}disconnect(){this._adapter.removeBackdropEventListener("click",this._onClick)}_applyAppearance(){this._appearance?this._adapter.setHostAttribute(e.attributes.APPEARANCE,String(this._appearance)):this._adapter.removeHostAttribute(e.attributes.APPEARANCE)}set delay(t){this._delay!==t&&(this._delay=t,this._adapter.setHostAttribute(e.attributes.DELAY,this._delay.toString()))}get delay(){return this._delay}set maxOpacity(t){this._maxOpacity!==t&&(this._maxOpacity=t,this._adapter.setHostAttribute(e.attributes.MAX_OPACITY,this._maxOpacity.toString()))}get maxOpacity(){return this._maxOpacity}get appearance(){return this._appearance}set appearance(t){this._appearance!==t&&(this._appearance=t,this._applyAppearance())}};var I='<template><div class="forge-backdrop" part="root"></div></template>',C=".forge-backdrop{z-index:7;z-index:var(--forge-z-index-backdrop,7);background-color:rgba(0,0,0,.54);background-color:var(--forge-backdrop-theme-background,rgba(0,0,0,.54));position:absolute;top:0;bottom:0;left:0;right:0;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;-webkit-transition:opacity 150ms 0s cubic-bezier(0, 0, .2, 1);transition:opacity 150ms 0s cubic-bezier(0, 0, .2, 1);opacity:0}:host{display:block}:host([hidden]){display:none}:host([fixed]) .forge-backdrop{position:fixed}:host([appearance=light]){--forge-backdrop-theme-background:rgba(255, 255, 255, 0.54)}:host([appearance=dark]){--forge-backdrop-theme-background:rgba(0, 0, 0, 0.54)}",r=class extends h{constructor(){super();l(this,I,C),this._foundation=new s(new n(this))}static get observedAttributes(){return[e.attributes.DELAY,e.attributes.MAX_OPACITY]}connectedCallback(){if(this.hasAttribute(e.attributes.DELAY)&&this.getAttribute(e.attributes.DELAY)){let a=Number(this.getAttribute(e.attributes.DELAY));this.delay=a>=0?a:e.numbers.DELAY}if(this.hasAttribute(e.attributes.MAX_OPACITY)){let a=Number(this.getAttribute(e.attributes.MAX_OPACITY));this.maxOpacity=a>=0&&a<=1?a:e.numbers.OPACITY}this._foundation.initialize()}disconnectedCallback(){this._foundation.disconnect()}attributeChangedCallback(a,o,c){switch(a){case e.attributes.DELAY:let u=Number(c);this.delay=u>=0?u:e.numbers.DELAY;break;case e.attributes.MAX_OPACITY:let d=Number(c);this.maxOpacity=d>=0&&d<=1?d:e.numbers.OPACITY;break;case e.attributes.APPEARANCE:this.appearance=c;break}}fadeOut(){return this._foundation.fadeOut()}fadeIn(){return this._foundation.fadeIn()}};i([p()],r.prototype,"delay",2),i([p()],r.prototype,"appearance",2),i([p()],r.prototype,"maxOpacity",2),r=i([k({name:e.elementName})],r);function V(){b(r)}export{e as a,n as b,s as c,r as d,V as e};
//# sourceMappingURL=chunk.7C7XCT32.js.map
