mercury_editor-2.0.x-dev/build/js/dialog.element.min.js
build/js/dialog.element.min.js
!function(){"use strict";
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const t=window,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),o=new WeakMap;class s{constructor(t,e,o){if(this._$cssResult$=!0,o!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const n=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,i))(e)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/;var r;const a=window,l=a.trustedTypes,d=l?l.emptyScript:"",h=a.reactiveElementPolyfillSupport,c={toAttribute(t,e){switch(e){case Boolean:t=t?d:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},p=(t,e)=>e!==t&&(e==e||t==t),u={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:p},m="finalized";class g extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Ep(i,e);void 0!==o&&(this._$Ev.set(o,i),t.push(o))})),t}static createProperty(t,e=u){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const s=this[t];this[e]=o,this.requestUpdate(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||u}static finalize(){if(this.hasOwnProperty(m))return!1;this[m]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(n(t))}else void 0!==t&&e.push(n(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var i;const o=null!==(i=this.shadowRoot)&&void 0!==i?i:this.attachShadow(this.constructor.shadowRootOptions);return((i,o)=>{e?i.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):o.forEach((e=>{const o=document.createElement("style"),s=t.litNonce;void 0!==s&&o.setAttribute("nonce",s),o.textContent=e.cssText,i.appendChild(o)}))})(o,this.constructor.elementStyles),o}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=u){var o;const s=this.constructor._$Ep(t,i);if(void 0!==s&&!0===i.reflect){const n=(void 0!==(null===(o=i.converter)||void 0===o?void 0:o.toAttribute)?i.converter:c).toAttribute(e,i.type);this._$El=t,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$El=null}}_$AK(t,e){var i;const o=this.constructor,s=o._$Ev.get(t);if(void 0!==s&&this._$El!==s){const t=o.getPropertyOptions(s),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:c;this._$El=s,this[s]=n.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||p)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var v;g[m]=!0,g.elementProperties=new Map,g.elementStyles=[],g.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:g}),(null!==(r=a.reactiveElementVersions)&&void 0!==r?r:a.reactiveElementVersions=[]).push("1.6.3");const f=window,_=f.trustedTypes,y=_?_.createPolicy("lit-html",{createHTML:t=>t}):void 0,b="$lit$",$=`lit$${(Math.random()+"").slice(9)}$`,w="?"+$,x=`<${w}>`,k=document,A=()=>k.createComment(""),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,S=Array.isArray,C="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,P=/>/g,H=RegExp(`>|${C}(?:([^\\s"'>=/]+)(${C}*=${C}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,D=/"/g,R=/^(?:script|style|textarea|title)$/i,U=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),N=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),L=new WeakMap,T=k.createTreeWalker(k,129,null,!1);function j(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==y?y.createHTML(e):e}const I=(t,e)=>{const i=t.length-1,o=[];let s,n=2===e?"<svg>":"",r=z;for(let e=0;e<i;e++){const i=t[e];let a,l,d=-1,h=0;for(;h<i.length&&(r.lastIndex=h,l=r.exec(i),null!==l);)h=r.lastIndex,r===z?"!--"===l[1]?r=M:void 0!==l[1]?r=P:void 0!==l[2]?(R.test(l[2])&&(s=RegExp("</"+l[2],"g")),r=H):void 0!==l[3]&&(r=H):r===H?">"===l[0]?(r=null!=s?s:z,d=-1):void 0===l[1]?d=-2:(d=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?H:'"'===l[3]?D:B):r===D||r===B?r=H:r===M||r===P?r=z:(r=H,s=void 0);const c=r===H&&t[e+1].startsWith("/>")?" ":"";n+=r===z?i+x:d>=0?(o.push(a),i.slice(0,d)+b+i.slice(d)+$+c):i+$+(-2===d?(o.push(void 0),e):c)}return[j(t,n+(t[i]||"<?>")+(2===e?"</svg>":"")),o]};class V{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let s=0,n=0;const r=t.length-1,a=this.parts,[l,d]=I(t,e);if(this.el=V.createElement(l,i),T.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=T.nextNode())&&a.length<r;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith(b)||e.startsWith($)){const i=d[n++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+b).split($),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:s,name:e[2],strings:t,ctor:"."===e[1]?Y:"?"===e[1]?J:"@"===e[1]?Z:X})}else a.push({type:6,index:s})}for(const e of t)o.removeAttribute(e)}if(R.test(o.tagName)){const t=o.textContent.split($),e=t.length-1;if(e>0){o.textContent=_?_.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],A()),T.nextNode(),a.push({type:2,index:++s});o.append(t[e],A())}}}else if(8===o.nodeType)if(o.data===w)a.push({type:2,index:s});else{let t=-1;for(;-1!==(t=o.data.indexOf($,t+1));)a.push({type:7,index:s}),t+=$.length-1}s++}}static createElement(t,e){const i=k.createElement("template");return i.innerHTML=t,i}}function W(t,e,i=t,o){var s,n,r,a;if(e===N)return e;let l=void 0!==o?null===(s=i._$Co)||void 0===s?void 0:s[o]:i._$Cl;const d=E(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==d&&(null===(n=null==l?void 0:l._$AO)||void 0===n||n.call(l,!1),void 0===d?l=void 0:(l=new d(t),l._$AT(t,i,o)),void 0!==o?(null!==(r=(a=i)._$Co)&&void 0!==r?r:a._$Co=[])[o]=l:i._$Cl=l),void 0!==l&&(e=W(t,l._$AS(t,e.values),l,o)),e}class F{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:o}=this._$AD,s=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:k).importNode(i,!0);T.currentNode=s;let n=T.nextNode(),r=0,a=0,l=o[0];for(;void 0!==l;){if(r===l.index){let e;2===l.type?e=new q(n,n.nextSibling,this,t):1===l.type?e=new l.ctor(n,l.name,l.strings,this,t):6===l.type&&(e=new G(n,this,t)),this._$AV.push(e),l=o[++a]}r!==(null==l?void 0:l.index)&&(n=T.nextNode(),r++)}return T.currentNode=k,s}v(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class q{constructor(t,e,i,o){var s;this.type=2,this._$AH=O,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cp=null===(s=null==o?void 0:o.isConnected)||void 0===s||s}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=W(this,t,e),E(t)?t===O||null==t||""===t?(this._$AH!==O&&this._$AR(),this._$AH=O):t!==this._$AH&&t!==N&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>S(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==O&&E(this._$AH)?this._$AA.nextSibling.data=t:this.$(k.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:o}=t,s="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=V.createElement(j(o.h,o.h[0]),this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===s)this._$AH.v(i);else{const t=new F(s,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=L.get(t.strings);return void 0===e&&L.set(t.strings,e=new V(t)),e}T(t){S(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const s of t)o===e.length?e.push(i=new q(this.k(A()),this.k(A()),this,this.options)):i=e[o],i._$AI(s),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class X{constructor(t,e,i,o,s){this.type=1,this._$AH=O,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=s,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=O}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const s=this.strings;let n=!1;if(void 0===s)t=W(this,t,e,0),n=!E(t)||t!==this._$AH&&t!==N,n&&(this._$AH=t);else{const o=t;let r,a;for(t=s[0],r=0;r<s.length-1;r++)a=W(this,o[i+r],e,r),a===N&&(a=this._$AH[r]),n||(n=!E(a)||a!==this._$AH[r]),a===O?t=O:t!==O&&(t+=(null!=a?a:"")+s[r+1]),this._$AH[r]=a}n&&!o&&this.j(t)}j(t){t===O?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Y extends X{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===O?void 0:t}}const K=_?_.emptyScript:"";class J extends X{constructor(){super(...arguments),this.type=4}j(t){t&&t!==O?this.element.setAttribute(this.name,K):this.element.removeAttribute(this.name)}}class Z extends X{constructor(t,e,i,o,s){super(t,e,i,o,s),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=W(this,t,e,0))&&void 0!==i?i:O)===N)return;const o=this._$AH,s=t===O&&o!==O||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,n=t!==O&&(o===O||s);s&&this.element.removeEventListener(this.name,this,o),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class G{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){W(this,t)}}const Q=f.litHtmlPolyfillSupport;null==Q||Q(V,q),(null!==(v=f.litHtmlVersions)&&void 0!==v?v:f.litHtmlVersions=[]).push("2.8.0");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var tt,et;class it extends g{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{var o,s;const n=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let r=n._$litPart$;if(void 0===r){const t=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:null;n._$litPart$=r=new q(e.insertBefore(A(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return N}}it.finalized=!0,it._$litElement$=!0,null===(tt=globalThis.litElementHydrateSupport)||void 0===tt||tt.call(globalThis,{LitElement:it});const ot=globalThis.litElementPolyfillSupport;null==ot||ot({LitElement:it}),(null!==(et=globalThis.litElementVersions)&&void 0!==et?et:globalThis.litElementVersions=[]).push("3.3.3");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const st=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function nt(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):st(t,e)
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/}function rt(t){return nt({...t,state:!0})}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var at;null===(at=window.HTMLSlotElement)||void 0===at||at.prototype.assignedElements;
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var lt,dt,ht,ct=window&&window.__decorate||function(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};!function(t){t.Idle="idle",t.Move="move",t.Resize="resize"}(lt||(lt={})),function(t){t.None="none",t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"}(dt||(dt={})),function(t){t.None="none",t.N="n",t.NE="ne",t.E="e",t.SE="se",t.S="s",t.SW="sw",t.W="w",t.NW="nw"}(ht||(ht={}));let pt=class extends it{constructor(){super(...arguments),this.open=!1,this.modal=!1,this.moveable=!1,this.moveBtn=!1,this.dock="none",this.push=!1,this.dockable=!1,this.hideCloseButton=!1,this.backdropOpacity=1,this.returnValue="",this.minWidth=200,this.resizable=!1,this._height=null,this._width=null,this._dialogInteraction=lt.Idle,this.title="",this._dragStartX=0,this._dragStartY=0,this._dragStartHeight=0,this._dragStartWidth=0,this._offsetTop=0,this._offsetLeft=0,this._resizeDirection=ht.None,this._resizeObserver=null,this.styles=document.createElement("style"),this._onDock=(t="right")=>async()=>{const e=await this._dialog;e.style.removeProperty("inset"),e.style.removeProperty("height"),e.style.removeProperty("width"),this.dock=t,e.offsetHeight>0&&document.documentElement.style.setProperty(`--me-dialog-dock-${t}-height`,`${this._height}px`),e.offsetWidth>0&&document.documentElement.style.setProperty(`--me-dialog-dock-${t}-height`,`${this._width}px`),this._pushBody()},this._onUnDock=async()=>{this.dock="none"},this._onDragMouseUp=()=>{this._dialogInteraction=lt.Idle,document.removeEventListener("mouseup",this._onDragMouseUp),document.removeEventListener("mousemove",this._onDragMouseMove)},this._onDragMouseMove=async t=>{const e=await this._dialog,i=t.clientX-this._dragStartX,o=t.clientY-this._dragStartY;switch(this._dialogInteraction){case lt.Move:e.style.left=`${Math.min(Math.max(0,this._offsetLeft+i),window.innerWidth-e.offsetWidth)}px`,e.style.top=`${this._offsetTop+o}px`,e.style.right="auto",e.style.bottom="auto";break;case lt.Resize:switch(this._resizeDirection){case ht.N:this._height=Math.min(this._dragStartHeight-o,window.innerHeight),document.documentElement.style.setProperty(`--me-dialog-dock-${this.dock}-height`,`${this._height}px`);break;case ht.E:this._width=Math.max(this.minWidth,Math.min(this._dragStartWidth+i,window.innerWidth)),document.documentElement.style.setProperty(`--me-dialog-dock-${this.dock}-width`,`${this._width}px`);break;case ht.S:this._height=Math.min(this._dragStartHeight+o,window.innerHeight),document.documentElement.style.setProperty(`--me-dialog-dock-${this.dock}-height`,`${this._height}px`);break;case ht.W:this._width=Math.max(this.minWidth,Math.max(0,Math.min(this._dragStartWidth-i,window.innerWidth))),document.documentElement.style.setProperty(`--me-dialog-dock-${this.dock}-width`,`${this._width}px`)}}},this._pushBody=async()=>{const t={top:"",right:"",bottom:"",left:""};if(this.open&&this.push)switch(this.dock){case"top":t.top=`padding-top: var(--me-dialog-offset-top, var(--me-dialog-dock-${this.dock}-height)) !important;`;break;case"right":t.right=`padding-right: var(--me-dialog-offset-right, var(--me-dialog-dock-${this.dock}-width)) !important;`;break;case"bottom":t.bottom=`padding-bottom: var(--me-dialog-offset-bottom, var(--me-dialog-dock-${this.dock}-height)) !important;`;break;case"left":t.left=`padding-left: var(--me-dialog-offset-left, var(--me-dialog-dock-${this.dock}-width)) !important;`}this.styles.innerHTML=`body {\n transition: padding var(--me-dialog-duration, 200) var(--me-dialog-timing, ease-out);\n ${Object.values(t).filter((t=>t)).join("\n")}\n }`}}connectedCallback(){super.connectedCallback(),this.styles.setAttribute("class","mercury-dialog-styles"),document.head.appendChild(this.styles)}disconnectedCallback(){super.disconnectedCallback(),this.styles.remove()}_getResizeDirection(){switch(this.dock){case"top":return ht.S;case"right":return ht.W;case"bottom":return ht.N;case"left":return ht.E;default:return ht.None}}async _handleClose(){const t=await this._dialog;this.returnValue=t.returnValue,this.open=!1,this._pushBody(),this.dispatchEvent(new Event("close"))}async _handleCancel(){const t=await this._dialog;this.returnValue=t.returnValue,this.dispatchEvent(new Event("cancel"))}async _keydownHandler(t){if("Escape"===t.code){const t=this.getRootNode(),e=t.querySelector(`#${this.id}`);e&&!this.hideCloseButton&&e.contains(t.activeElement)&&this._handleClose()}}render(){return U`
<dialog
id="dialog"
part="dialog"
data-dock=${this.dock}
@close=${this._handleClose}
@cancel=${this._handleCancel}
class=${[this.moveable&&"is-moveable",!this.resizable||"none"!==this.dock&&this.dock?"not-resizable":"is-resizable",`is-${this._dialogInteraction}`].join(" ")}
>
${this.title||!this.hideCloseButton?U`<header @mousedown=${this._onMoveMouseDown}>
${this.title?U`<h2>${this.title}</h2>`:U``}
<div class="buttons">
${this.moveable&&this.moveBtn?U`<button
@mousedown=${this._onMoveMouseDown}
part="drag-button"
id="dragButton"
>
<i></i>
<span>Drag</span>
</button>`:U``}
${this.dockable?"none"===this.dock?U`<button
@click=${this._onDock()}
part="dock-button"
id="dockButton"
>
<i></i>
<span>Dock</span>
</button>`:U`<button
@click=${this._onUnDock}
part="undock-button"
id="undockButton"
>
<i></i>
<span>Undock</span>
</button>`:""}
<form method="dialog">
${this.hideCloseButton?U``:U`<button
@click=${this._onCloseClick}
part="close-button"
id="closeButton"
>
<i></i>
<span>Close</span>
</button>`}
</form>
</div>
</header>`:U``}
${this.resizable&&"none"!==this.dock?U`<button
@mousedown=${this._onResizeMouseDown}
id="resizeButton"
data-resize-dir=${this._getResizeDirection()}
>
<span>Resize</span>
</button>`:U``}
<main>
<slot></slot>
</main>
<footer @mousedown=${this._onMoveMouseDown}>
<slot name="footer"></slot>
</footer>
</dialog>
`}async updated(t){if((t.has("dock")||t.has("push")||t.has("modal"))&&this._pushBody(),this.open?this.getRootNode().addEventListener("keydown",(t=>this._keydownHandler(t))):this.getRootNode().removeEventListener("keydown",(t=>this._keydownHandler(t))),"none"!==this.dock)if(this.open){const t=await this._dialog;this._resizeObserver||(this._resizeObserver=new ResizeObserver((t=>{for(const e of t)this._height&&this._width||(this._height=e.contentRect.height,this._width=e.contentRect.width,document.documentElement.style.setProperty(`--me-dialog-dock-${this.dock}-height`,`${this._height}px`),document.documentElement.style.setProperty(`--me-dialog-dock-${this.dock}-width`,`${this._width}px`))}))),this._resizeObserver.observe(t)}else this._resizeObserver&&this._resizeObserver.disconnect()}async showModal(){this.modal=!0,this.open=!0,this.isDocked()&&this._onDock(),(await this._dialog).showModal(),this.dispatchEvent(new Event("open"))}async show(){this.modal=!1,this.open=!0,this.isDocked()&&await this._onDock(this.dock)(),(await this._dialog).show(),this.dispatchEvent(new Event("open"))}async close(){this.isDocked()&&await this._onDock(this.dock)(),(await this._dialog).close()}isDocked(){return this.dock&&"none"!==this.dock}_onCloseClick(){this.open=!1}async _onResizeMouseDown(t){if(this._dialogInteraction=lt.Resize,t.target instanceof HTMLButtonElement){const e=t.target.getAttribute("data-resize-dir");this._resizeDirection=e}this._onDragMouseDown(t)}async _onMoveMouseDown(t){this.moveable&&(this._dialogInteraction=lt.Move,this.dock="none",this._onDragMouseDown(t))}async _onDragMouseDown(t){const e=await this._dialog;this._dragStartX=t.clientX,this._dragStartY=t.clientY,this._dragStartHeight=e.offsetHeight,this._dragStartWidth=e.offsetWidth,this._offsetLeft=e.offsetLeft,this._offsetTop=e.offsetTop,document.addEventListener("mouseup",this._onDragMouseUp),document.addEventListener("mousemove",this._onDragMouseMove)}};pt.styles=((t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,i,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1]),t[0]);return new s(o,t,i)})`
:host {
--me-resize-button-size: 8px;
display: block;
font-family: var(--me-font-family, sans-serif);
z-index: var(--me-dialog-z-index, 1255);
position: relative;
}
dialog {
border-style: var(--me-border-style, solid);
border-width: var(--me-border-width, 1px);
border-color: var(--me-border-color, #e5e5e5);
box-shadow: 0 1px 2px rgb(20 45 82 / 2%), 0 3px 4px rgb(20 45 82 / 3%), 0 5px 8px rgb(20 45 82 / 4%);
padding: 0;
position: fixed;
margin: auto;
inset: var(--me-dialog-position-top, 0px) var(--me-dialog-position-right, 0px) var(--me-dialog-position-bottom, 0px) var(--me-dialog-position-left, 0px);
overflow: auto;
width: var(--me-dialog-width, var(--me-dialog-width-default, fit-content));
height: var(--me-dialog-height, var(--me-dialog-height-default, fit-content));
min-width: var(--me-dialog-min-width, min-content);
max-width: calc(100vw - var(--me-dialog-viewport-offset, 80px));
max-height: calc(100vh - var(--me-dialog-viewport-offset, 80px));
z-index: 1000;
}
dialog.is-resizable {
resize: both;
}
dialog.is-resize ::slotted(*) {
pointer-events: none;
}
dialog[open] {
display: flex;
flex-direction: column;
justify-content: stretch;
}
dialog[data-dock='left'] {
height: auto;
inset: var(--me-dialog-position-top, 0px) var(--me-dialog-position-right, auto) var(--me-dialog-position-bottom, 0px) var(--me-dialog-position-left, 0px);
margin: 0 auto 0 0;
max-height: 100dvh;
max-width: 100dvw;
width: var(--me-dialog-dock-left-width, var(--me-dialog-width-default, 400px));
}
dialog[data-dock='right'] {
height: auto;
inset: var(--me-dialog-position-top, 0px) var(--me-dialog-position-right, 0px) var(--me-dialog-position-bottom, 0px) var(--me-dialog-position-left, auto);
margin: 0 0 0 auto;
max-height: 100dvh;
max-width: 100dvw;
width: var(--me-dialog-dock-right-width, var(--me-dialog-width-default, 400px));
}
dialog[data-dock='bottom'] {
inset: var(--me-dialog-position-top, auto) var(--me-dialog-position-right, 0px) var(--me-dialog-position-bottom, 0px) var(--me-dialog-position-left, 0px);
margin: auto 0 0 0;
width: auto;
max-width: 100dvw;
height: var(--me-dialog-dock-bottom-height, var(--me-dialog-height-default, 400px));
}
dialog[data-dock='top'] {
inset: var(--me-dialog-position-top, 0px) var(--me-dialog-position-right, 0px) var(--me-dialog-position-bottom, auto) var(--me-dialog-position-left, 0px);
margin: 0 0 auto 0;
width: auto;
max-width: 100dvw;
height: var(--me-dialog-dock-top-height, var(--me-dialog-height-default, 400px));
}
dialog::backdrop {
background-color: black;
opacity: 0.4;
}
#dragButton {
cursor: move;
}
header {
background-color: var(--me-dialog-header-background-color, #fff);
display: flex;
justify-content: space-between;
padding: var(--me-dialog-header-space-inset-y, var(--me-space-inset-y, 5px)) var(--me-dialog-header-space-inset-x, var(--me-space-inset-x, 20px));
border-bottom-style: var(--me-border-style, solid);
border-bottom-width: var(--me-border-width, 1px);
border-bottom-color: var(--me-border-color, #e5e5e5);
position: sticky;
top: 0;
}
dialog.is-moveable header {
cursor: grab;
}
h2 {
font-size: var(--me-label-font-size, 16px);
line-height: var(--me-label-line-height, 1.1);
margin-inline-end: var(--me-space-inset, .5em);
}
main {
position: relative;
background-color: var(--me-dialog-main-background-color, #fff);
padding: var(--me-dialog-main-space-inset-y, var(--me-space-inset-y, 20px)) var(--me-dialog-main-space-inset-y, var(--me-space-inset-y, 20px));
overflow-y: auto;
flex-grow: 1;
flex-shrink: 1;
flex-basis: fit-content;
}
.buttons {
display: flex;
justify-content: flex-end;
margin-inline-end: -10px;
}
form[method='dialog'] {
align-items: stretch;
display: flex;
}
button {
height: var(--me-dialog-icon-button-height, 40px);
width: var(--me-dialog-icon-button-width, 40px);
border: none;
display: flex;
align-items: center;
justify-content: center;
position: relative;
border-radius: var(--me-dialog-icon-button-radius, 3px);
background-color: var(--me-dialog-icon-button-background-color, #fff);
transition: all .2s ease-out;
}
button:hover {
background-color: var(--me-dialog-icon-button-background-color-hover, #efefef);
}
button[data-resize-dir] {
position: absolute;
opacity: .5;
border-radius: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
z-index: 10;
}
button[data-resize-dir]:after {
content: "";
display: block;
border: 0 #888 solid;
}
button[data-resize-dir="e"],
button[data-resize-dir="w"] {
cursor: ew-resize;
height: auto;
width: var(--me-resize-button-size);
}
button[data-resize-dir="e"]:after,
button[data-resize-dir="w"]:after {
height: 2em;
width: 3px;
border-left-width: 1px;
border-right-width: 1px;
}
button[data-resize-dir="e"] {
inset: 0 0 0 auto;
justify-content: flex-start;
}
button[data-resize-dir="w"] {
inset: 0 auto 0 0;
justify-content: flex-end;
}
button[data-resize-dir="n"],
button[data-resize-dir="s"] {
cursor: ns-resize;
height: var(--me-resize-button-size);
width: auto;
}
button[data-resize-dir="n"]:after,
button[data-resize-dir="s"]:after {
width: 2em;
height: 3px;
border-top-width: 1px;
border-bottom-width: 1px;
}
button[data-resize-dir="n"] {
inset: 0 0 auto 0;
align-items: flex-end;
}
button[data-resize-dir="s"] {
inset: auto 0 0 0;
align-items: flex-start;
}
::slotted([slot="footer"]) {
background-color: var(--me-dialog-footer-background-color, #fff);
padding: var(--me-dialog-footer-space-inset-y, var(--me-space-inset-y, 5px)) var(--me-dialog-footer-space-inset-x, var(--me-space-inset-x, 20px));
border-top-style: var(--me-border-style, solid);
border-top-width: var(--me-border-width, 1px);
border-top-color: var(--me-border-color, #e5e5e5);
position: sticky;
bottom: 0;
}
dialog.is-moveable footer {
cursor: grab;
}
button i {
background-position: center;
background-repeat: no-repeat;
display: block;
height: 50%;
width: 50%;
}
button span {
position: absolute !important;
overflow: hidden;
clip: rect(1px,1px,1px,1px);
width: 1px;
height: 1px;
word-wrap: normal;
}
#closeButton i {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.--><path d="M310.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L160 210.7 54.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L114.7 256 9.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 301.3l105.4 105.3c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L205.3 256l105.3-105.4z"/></svg>');
}
#dragButton i {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.--><path d="M278.6 9.4c-12.5-12.5-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l9.4-9.4V224H109.3l9.4-9.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-64 64c-12.5 12.5-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-9.4-9.4H224v114.8l-9.4-9.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-9.4 9.4V288h114.8l-9.4 9.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3l-64-64c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l9.4 9.4H288V109.3l9.4 9.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-64-64z"/></svg>');
}
#dockButton i {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.--><path d="M7.724 65.49A64.308 64.308 0 0 1 32 40.56a63.55 63.55 0 0 1 25.46-8.23c2.15-.22 4.33-.33 6.54-.33h384c35.3 0 64 28.65 64 64v320c0 35.3-28.7 64-64 64H64c-35.35 0-64-28.7-64-64V96c0-2.21.112-4.39.33-6.54a63.634 63.634 0 0 1 7.394-23.97zM48 416c0 8.8 7.16 16 16 16h384c8.8 0 16-7.2 16-16V224H48v192z"/></svg>');
}
#undockButton i {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.--><path d="M432 48H208c-17.7 0-32 14.33-32 32v16h-48V80c0-44.18 35.8-80 80-80h224c44.2 0 80 35.82 80 80v224c0 44.2-35.8 80-80 80h-16v-48h16c17.7 0 32-14.3 32-32V80c0-17.67-14.3-32-32-32zm-112 80c35.3 0 64 28.7 64 64v256c0 35.3-28.7 64-64 64H64c-35.35 0-64-28.7-64-64V192c0-35.3 28.65-64 64-64h256zM64 464h256c8.8 0 16-7.2 16-16V256H48v192c0 8.8 7.16 16 16 16z"/></svg>');
}
`,ct([nt({type:Boolean,reflect:!0})],pt.prototype,"open",void 0),ct([nt({type:Boolean,reflect:!0})],pt.prototype,"modal",void 0),ct([nt({type:Boolean,reflect:!0})],pt.prototype,"moveable",void 0),ct([nt({type:Boolean,reflect:!0})],pt.prototype,"moveBtn",void 0),ct([nt({type:dt,reflect:!0})],pt.prototype,"dock",void 0),ct([nt({type:Boolean,reflect:!0})],pt.prototype,"push",void 0),ct([nt({type:Boolean,reflect:!0})],pt.prototype,"dockable",void 0),ct([nt({type:Boolean,reflect:!0,attribute:"hide-close-button"})],pt.prototype,"hideCloseButton",void 0),ct([nt({type:Number,reflect:!0})],pt.prototype,"backdropOpacity",void 0),ct([nt({type:String,attribute:!1})],pt.prototype,"returnValue",void 0),ct([nt({type:Number,reflect:!0})],pt.prototype,"minWidth",void 0),ct([nt({type:Boolean,reflect:!0})],pt.prototype,"resizable",void 0),ct([rt()],pt.prototype,"_height",void 0),ct([rt()],pt.prototype,"_width",void 0),ct([rt()],pt.prototype,"_dialogInteraction",void 0),ct([nt({type:String,reflect:!0})],pt.prototype,"title",void 0),ct([
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function(t){return(({finisher:t,descriptor:e})=>(i,o)=>{var s;if(void 0===o){const o=null!==(s=i.originalKey)&&void 0!==s?s:i.key,n=null!=e?{kind:"method",placement:"prototype",key:o,descriptor:e(i.key)}:{...i,key:o};return null!=t&&(n.finisher=function(e){t(e,o)}),n}{const s=i.constructor;void 0!==e&&Object.defineProperty(i,o,e(o)),null==t||t(s,o)}})({descriptor:e=>({async get(){var e;return await this.updateComplete,null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t)},enumerable:!0,configurable:!0})})}("#dialog")],pt.prototype,"_dialog",void 0),pt=ct([(t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){customElements.define(t,e)}}})(t,e))("mercury-dialog")],pt)}();
