UNPKG

@creaditor/newsletter-starterkit

Version:

Creaditor Newsletter Editor - Starterkit for creating beautiful email newsletters

162 lines (161 loc) 28.4 kB
/*! For license information please see 6964.creaditor.bundle.js.LICENSE.txt */ "use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[6964],{6964:(t,e,s)=>{s.r(e),s.d(e,{default:()=>St});var i=Object.defineProperty,n=(t,e,s)=>((t,e,s)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);const o=globalThis,r=o.ShadowRoot&&(void 0===o.ShadyCSS||o.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),h=new WeakMap;let a=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==l)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(r&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=h.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&h.set(e,t))}return t}toString(){return this.cssText}};const d=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const n=1===t.length?t[0]:s.reduce(((e,s,i)=>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.")})(s)+t[i+1]),t[0]);return new a(n,t,l)},c=r?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,l))(e)})(t):t,{is:u,defineProperty:p,getOwnPropertyDescriptor:f,getOwnPropertyNames:$,getOwnPropertySymbols:v,getPrototypeOf:g}=Object,m=globalThis,_=m.trustedTypes,y=_?_.emptyScript:"",b=m.reactiveElementPolyfillSupport,A=(t,e)=>t,w={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},E=(t,e)=>!u(t,e),x={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:E};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),m.litPropertyMetadata??(m.litPropertyMetadata=new WeakMap);let C=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x;if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&p(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=f(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=null==i?void 0:i.call(this);null==n||n.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??x}static _$Ei(){if(this.hasOwnProperty(A("elementProperties")))return;const t=g(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(A("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(A("properties"))){const t=this.properties,e=[...$(t),...v(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),null==(t=this.constructor.l)||t.forEach((t=>t(this)))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),void 0!==this.renderRoot&&this.isConnected&&(null==(e=t.hostConnected)||e.call(t))}removeController(t){var e;null==(e=this._$EO)||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(r)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),i=o.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostConnected)?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostDisconnected)?void 0:e.call(t)}))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){var s;const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==(null==(s=i.converter)?void 0:s.toAttribute)?i.converter:w).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){var s,i;const n=this.constructor,o=n._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=n.getPropertyOptions(o),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null==(s=t.converter)?void 0:s.fromAttribute)?t.converter:w;this._$Em=o;const l=r.fromAttribute(e,t.type);this[o]=l??(null==(i=this._$Ej)?void 0:i.get(o))??l,this._$Em=null}}requestUpdate(t,e,s){var i;if(void 0!==t){const n=this.constructor,o=this[t];if(s??(s=n.getPropertyOptions(t)),!((s.hasChanged??E)(o,e)||s.useDefault&&s.reflect&&o===(null==(i=this._$Ej)?void 0:i.get(t))&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,s,i){let{useDefault:n,reflect:o,wrapped:r}=s;n&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,i??e??this[t]),!0!==r||void 0!==i)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===o&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}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;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostUpdate)?void 0:e.call(t)})),this.update(s)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(s)}willUpdate(t){}_$AE(t){var e;null==(e=this._$EO)||e.forEach((t=>{var e;return null==(e=t.hostUpdated)?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach((t=>this._$ET(t,this[t])))),this._$EM()}updated(t){}firstUpdated(t){}};C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[A("elementProperties")]=new Map,C[A("finalized")]=new Map,null==b||b({ReactiveElement:C}),(m.reactiveElementVersions??(m.reactiveElementVersions=[])).push("2.1.1");const S=globalThis,k=S.trustedTypes,P=k?k.createPolicy("lit-html",{createHTML:t=>t}):void 0,R="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,U="?"+T,N=`<${U}>`,O=document,H=()=>O.createComment(""),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,I=Array.isArray,z="[ \t\n\f\r]",B=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,L=/>/g,j=RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),W=/'/g,G=/"/g,V=/^(?:script|style|textarea|title)$/i,q=(Z=1,function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return{_$litType$:Z,strings:t,values:s}}),K=Symbol.for("lit-noChange"),F=Symbol.for("lit-nothing"),J=new WeakMap,Q=O.createTreeWalker(O,129);var Z;function X(t,e){if(!I(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==P?P.createHTML(e):e}class Y{constructor(t,e){let s,{strings:i,_$litType$:n}=t;this.parts=[];let o=0,r=0;const l=i.length-1,h=this.parts,[a,d]=((t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=B;for(let e=0;e<s;e++){const s=t[e];let l,h,a=-1,d=0;for(;d<s.length&&(r.lastIndex=d,h=r.exec(s),null!==h);)d=r.lastIndex,r===B?"!--"===h[1]?r=D:void 0!==h[1]?r=L:void 0!==h[2]?(V.test(h[2])&&(n=RegExp("</"+h[2],"g")),r=j):void 0!==h[3]&&(r=j):r===j?">"===h[0]?(r=n??B,a=-1):void 0===h[1]?a=-2:(a=r.lastIndex-h[2].length,l=h[1],r=void 0===h[3]?j:'"'===h[3]?G:W):r===G||r===W?r=j:r===D||r===L?r=B:(r=j,n=void 0);const c=r===j&&t[e+1].startsWith("/>")?" ":"";o+=r===B?s+N:a>=0?(i.push(l),s.slice(0,a)+R+s.slice(a)+T+c):s+T+(-2===a?e:c)}return[X(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]})(i,n);if(this.el=Y.createElement(a,e),Q.currentNode=this.el.content,2===n||3===n){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=Q.nextNode())&&h.length<l;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(R)){const e=d[r++],i=s.getAttribute(t).split(T),n=/([.?@])?(.*)/.exec(e);h.push({type:1,index:o,name:n[2],strings:i,ctor:"."===n[1]?nt:"?"===n[1]?ot:"@"===n[1]?rt:it}),s.removeAttribute(t)}else t.startsWith(T)&&(h.push({type:6,index:o}),s.removeAttribute(t));if(V.test(s.tagName)){const t=s.textContent.split(T),e=t.length-1;if(e>0){s.textContent=k?k.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],H()),Q.nextNode(),h.push({type:2,index:++o});s.append(t[e],H())}}}else if(8===s.nodeType)if(s.data===U)h.push({type:2,index:o});else{let t=-1;for(;-1!==(t=s.data.indexOf(T,t+1));)h.push({type:7,index:o}),t+=T.length-1}o++}}static createElement(t,e){const s=O.createElement("template");return s.innerHTML=t,s}}function tt(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3?arguments[3]:void 0;var n,o;if(e===K)return e;let r=void 0!==i?null==(n=s._$Co)?void 0:n[i]:s._$Cl;const l=M(e)?void 0:e._$litDirective$;return(null==r?void 0:r.constructor)!==l&&(null==(o=null==r?void 0:r._$AO)||o.call(r,!1),void 0===l?r=void 0:(r=new l(t),r._$AT(t,s,i)),void 0!==i?(s._$Co??(s._$Co=[]))[i]=r:s._$Cl=r),void 0!==r&&(e=tt(t,r._$AS(t,e.values),r,i)),e}class et{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){const{el:{content:e},parts:s}=this._$AD,i=((null==t?void 0:t.creationScope)??O).importNode(e,!0);Q.currentNode=i;let n=Q.nextNode(),o=0,r=0,l=s[0];for(;void 0!==l;){if(o===l.index){let e;2===l.type?e=new st(n,n.nextSibling,this,t):1===l.type?e=new l.ctor(n,l.name,l.strings,this,t):6===l.type&&(e=new lt(n,this,t)),this._$AV.push(e),l=s[++r]}o!==(null==l?void 0:l.index)&&(n=Q.nextNode(),o++)}return Q.currentNode=O,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class st{get _$AU(){var t;return(null==(t=this._$AM)?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=F,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(null==i?void 0:i.isConnected)??!0}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){t=tt(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),M(t)?t===F||null==t||""===t?(this._$AH!==F&&this._$AR(),this._$AH=F):t!==this._$AH&&t!==K&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>I(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==F&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){var e;const{values:s,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=Y.createElement(X(i.h,i.h[0]),this.options)),i);if((null==(e=this._$AH)?void 0:e._$AD)===n)this._$AH.p(s);else{const t=new et(n,this),e=t.u(this.options);t.p(s),this.T(e),this._$AH=t}}_$AC(t){let e=J.get(t.strings);return void 0===e&&J.set(t.strings,e=new Y(t)),e}k(t){I(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new st(this.O(H()),this.O(H()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,e=arguments.length>1?arguments[1]:void 0;var s;for(null==(s=this._$AP)||s.call(this,!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cv=t,null==(e=this._$AP)||e.call(this,t))}}class it{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=F,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=F}_$AI(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;const n=this.strings;let o=!1;if(void 0===n)t=tt(this,t,e,0),o=!M(t)||t!==this._$AH&&t!==K,o&&(this._$AH=t);else{const i=t;let r,l;for(t=n[0],r=0;r<n.length-1;r++)l=tt(this,i[s+r],e,r),l===K&&(l=this._$AH[r]),o||(o=!M(l)||l!==this._$AH[r]),l===F?t=F:t!==F&&(t+=(l??"")+n[r+1]),this._$AH[r]=l}o&&!i&&this.j(t)}j(t){t===F?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class nt extends it{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===F?void 0:t}}class ot extends it{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==F)}}class rt extends it{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t){if((t=tt(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,0)??F)===K)return;const e=this._$AH,s=t===F&&e!==F||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,i=t!==F&&(e===F||s);s&&this.element.removeEventListener(this.name,this,e),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;"function"==typeof this._$AH?this._$AH.call((null==(e=this.options)?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class lt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){tt(this,t)}}const ht=S.litHtmlPolyfillSupport;null==ht||ht(Y,st),(S.litHtmlVersions??(S.litHtmlVersions=[])).push("3.3.1");const at=globalThis;let dt=class extends C{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=(null==s?void 0:s.renderBefore)??e;let n=i._$litPart$;if(void 0===n){const t=(null==s?void 0:s.renderBefore)??null;i._$litPart$=n=new st(e.insertBefore(H(),t),t,void 0,s??{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null==(t=this._$Do)||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this._$Do)||t.setConnected(!1)}render(){return K}};var ct;dt._$litElement$=!0,dt.finalized=!0,null==(ct=at.litElementHydrateSupport)||ct.call(at,{LitElement:dt});const ut=at.litElementPolyfillSupport;null==ut||ut({LitElement:dt}),(at.litElementVersions??(at.litElementVersions=[])).push("4.2.1");const pt=2;class ft{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const $t=(t,e)=>{var s;const i=t._$AN;if(void 0===i)return!1;for(const t of i)null==(s=t._$AO)||s.call(t,e,!1),$t(t,e);return!0},vt=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===(null==s?void 0:s.size))},gt=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(void 0===s)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),yt(e)}};function mt(t){void 0!==this._$AN?(vt(this),this._$AM=t,gt(this)):this._$AM=t}function _t(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const i=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(e)if(Array.isArray(i))for(let t=s;t<i.length;t++)$t(i[t],!1),vt(i[t]);else null!=i&&($t(i,!1),vt(i));else $t(this,t)}const yt=t=>{t.type==pt&&(t._$AP??(t._$AP=_t),t._$AQ??(t._$AQ=mt))};class bt extends ft{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),gt(this),this.isConnected=t._$AU}_$AO(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var s,i;t!==this.isConnected&&(this.isConnected=t,t?null==(s=this.reconnected)||s.call(this):null==(i=this.disconnected)||i.call(this)),e&&($t(this,t),vt(this))}setValue(t){if((t=>void 0===t.strings)(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}class At{}const wt=new WeakMap,Et=(t=>function(){for(var e=arguments.length,s=new Array(e),i=0;i<e;i++)s[i]=arguments[i];return{_$litDirective$:t,values:s}})(class extends bt{render(t){return F}update(t,e){let[s]=e;var i;const n=s!==this.G;return n&&void 0!==this.G&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=s,this.ht=null==(i=t.options)?void 0:i.host,this.rt(this.ct=t.element)),F}rt(t){if(this.isConnected||(t=void 0),"function"==typeof this.G){const e=this.ht??globalThis;let s=wt.get(e);void 0===s&&(s=new WeakMap,wt.set(e,s)),void 0!==s.get(this.G)&&this.G.call(this.ht,void 0),s.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){var t,e;return"function"==typeof this.G?null==(t=wt.get(this.ht??globalThis))?void 0:t.get(this.G):null==(e=this.G)?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});let xt=1500;function Ct(){return xt++}class St extends dt{constructor(){super(),n(this,"contentRef",new At),this.toggle=this.toggle.bind(this),this.onEnter=this.onEnter.bind(this),this.onKeydown=this.onKeydown.bind(this),this.overflow=!0,this.maxHeight=300,this.left=0,this.top=0,this.custom=!1,this.opened=!1}close(){this.toggle()}onBouncing(t){this.searchText=t.target.value;const e=new UIEvent("search",{view:window,bubbles:!0,cancelable:!0});this.dispatchEvent(e)}render(){return q` <slot @click=${()=>this.toggle()} tabindex="0" name="trigger"></slot> ${this.opened?q` <div @mouseup=${this.onClickOutside} class="backdrop" style="z-index:${Ct()};" > <div ${Et(this.contentRef)} @mouseup=${this.preventClosing} style="z-index:${Ct()};left:${this.left}px;top:${this.top}px;" class="dropdown-content fade-in ${this.custom?"":"dropdown-background"}" > ${this.search?q`<cdtr-input @input=${this.onBouncing} type="search" value=${this.searchText} ></cdtr-input>`:null} <slot name="content"></slot> </div> </div>`:null} `}preventClosing(t){return t.stopPropagation(),setTimeout((()=>{this.calcRects()}),0),!1}onClickOutside(){this.toggle(!1)}updated(){var t;this.opened&&(setTimeout((()=>{this.calcRects()}),0),null==(t=this.contentRef.value)||t.classList.add("fade-in"),this.contentRef.value.style.maxHeight=`${this.maxHeight}px`)}calcRects(){var t,e;let s=0,i=0;const n=this.getBoundingClientRect(),o=null==(e=null==(t=this.contentRef)?void 0:t.value)?void 0:e.getBoundingClientRect();o&&(s=n.left,i=n.top,s<0&&(s=0),i<0&&(i=0),s+o.width>window.innerWidth&&(s=window.innerWidth-o.width),i+o.height>window.innerHeight&&(i=window.innerHeight-o.height),this.left=s,this.top=i,this.contentRef.value.style.left=`${n.left}px`,this.contentRef.value.style.top=`${i+n.height}px`,this.contentRef.value.style.overflow=this.overflow?"hidden auto":"hidden")}toggle(){var t;const e=arguments.length>0&&void 0!==arguments[0]&&arguments[0]||!this.opened;e?(window.removeEventListener("keydown",this.onKeydown),window.addEventListener("keydown",this.onKeydown),this.opened=e,setTimeout((()=>{const t=this.focusedItem=this.querySelector("cdtr-dropdown-item[focused]")||this.querySelector("cdtr-dropdown-item");t&&t.focus()}),20)):(window.removeEventListener("keydown",this.onKeydown),null==(t=this.contentRef.value)||t.classList.add("fade-out"),setTimeout((()=>{this.opened=e}),150)),this.setAttribute("aria-expanded",e)}onEnter(t){t.target===this&&13===t.keyCode&&this.toggle()}onKeydown(t){this.focusedItem&&40===t.keyCode&&this.focusedItem.nextElementSibling&&"CDTR-DROPDOWN-ITEM"===this.focusedItem.nextElementSibling.nodeName?(this.focusedItem=this.focusedItem.nextElementSibling,this.focusedItem&&this.focusedItem.focus()):this.focusedItem&&38===t.keyCode&&this.focusedItem.previousElementSibling&&"CDTR-DROPDOWN-ITEM"===this.focusedItem.previousElementSibling.nodeName?(this.focusedItem=this.focusedItem.previousElementSibling,this.focusedItem&&this.focusedItem.focus()):27===t.keyCode&&this.toggle();const e=new UIEvent("keypress",{view:window,bubbles:!0,cancelable:!0});this.dispatchEvent(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-disabled","false"),this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",this.opened),this.addEventListener("keydown",this.onEnter),setTimeout((()=>{this.opened&&this.toggle(!0)}),50)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKeydown)}patch(t){this.value=t,this.toggle(!1);const e=new UIEvent("change",{view:window,bubbles:!0,cancelable:!0});this.dispatchEvent(e),setTimeout((()=>{this.focus()}),0)}}n(St,"styles",d` :host { display: inline-block; overflow: hidden; box-sizing: border-box; } .backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: transparent; overflow: hidden; } .dropdown-background { background: #fff; } .dropdown-content { box-sizing: border-box; min-width: 50px; min-height: 50; position: fixed; border-radius: 0.25rem; /* padding: 3px; */ box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; } .fade-in { animation: fade-in 0.3s; } .fade-out { animation: fade-out 0.3s; opacity: 0; } @keyframes fade-in { from { opacity: 0; margin-top: 5px; } to { opacity: 1; } } @keyframes fade-out { from { opacity: 1; } to { margin-top: 5px; opacity: 0; } } `),n(St,"properties",{search:{type:Boolean},searchText:{type:String},left:{type:Number},top:{type:Number},opened:{type:Boolean},maxHeight:{type:Number},overflow:{type:Boolean},value:{type:String},custom:{type:String}});class kt extends dt{constructor(){super(),this.minWidth=50}render(){return q`<paper-button style="min-width:${this.minWidth}px" ><slot></slot> <cdtr-dd-arrow-icon></cdtr-dd-arrow-icon ></paper-button>`}}n(kt,"properties",{minWidth:{type:Number}}),n(kt,"styles",d` paper-button { display: flex; justify-content: space-between; text-transform: capitalize; width: 100%; font-size: 14px; font-weight: 400; line-height: 1.5; color: rgb(33, 37, 41); background: rgb(255, 255, 255); background-clip: padding-box; border-width: 1px; border-style: solid; border-image: initial; appearance: none; border-radius: 0.25rem; transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s; margin: 0px; font-family: var(--font-family); border-color: var(--input-border-color); box-sizing: border-box; padding: 5px; font-size: 12px; } paper-button:hover { border-color: black; } `);class Pt extends dt{constructor(){super(),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this)}focus(){this.shadowRoot.querySelector(".dropdown-item").focus()}onFocus(){this.focused=!0}onBlur(){this.focused=!1}onClick(t){if(this.notClickable)return;const e=this.closest("cdtr-dropdown");e&&e.patch(this.value,t,this)}onPress(t){if(13===t.keyCode){const e=new UIEvent("click",{view:window,bubbles:!0,cancelable:!0});this.dispatchEvent(e);const s=this.closest("cdtr-dropdown");s&&s.patch(this.value,t,this)}}connectedCallback(){super.connectedCallback(),this.selected&&this.scrollIntoView({behavior:"smooth",block:"start"})}render(){return q`<div role="button" @click=${this.onClick} @keydown=${this.onPress} @blur=${this.onBlur} @focus=${this.onFocus} class="dropdown-item" tabindex="0" > ${this.selected?q` <svg class="selected-svg" fill="var(--primary)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" > <path fill="none" d="M0 0h24v24H0z" /> <path d="M10 15.172l9.192-9.193 1.415 1.414L10 18l-6.364-6.364 1.414-1.414z" /> </svg>`:null} <slot></slot> </div>`}}n(Pt,"properties",{focused:{type:Boolean,reflect:!0},selected:{type:Boolean,reflect:!0},value:{type:String,reflect:!0},notClickable:{type:Boolean}}),n(Pt,"styles",d` .dropdown-item { position: relative; box-sizing: border-box; display: flex; font-family: Arial, Helvetica, sans-serif; font-size: 12px; cursor: pointer; margin-bottom: 2px; display: flex; align-items: center; user-select: none; width: 100%; justify-content: space-between; box-sizing: border-box; padding: 10px 20px; } .dropdown-item:hover { background: #f3f3f396; } .dropdown-item:focus { color: var(--primary-color); outline: none; background: #f3f3f3; } .selected-svg { width: 16px; position: absolute; left: 95%; transform: translate(-70%, -50%); top: 50%; } `),customElements.get("cdtr-dropdown-item")||customElements.define("cdtr-dropdown-item",Pt),customElements.get("cdtr-dropdown-button")||customElements.define("cdtr-dropdown-button",kt),customElements.get("cdtr-dropdown")||customElements.define("cdtr-dropdown",St)}}]);