origami-zen
Version:
Collection of reusable web components. Built for Origami CMS.
4 lines (3 loc) • 32.1 kB
JavaScript
function __decorate(e,t,n,a){var o,s=arguments.length,_=3>s?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)_=Reflect.decorate(e,t,n,a);else for(var p=e.length-1;0<=p;p--)(o=e[p])&&(_=(3>s?o(_):3<s?o(t,n,_):o(t,n))||_);return 3<s&&_&&Object.defineProperty(t,n,_),_}function __metadata(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}window.JSCompiler_renameProperty=function(e){return e};let dedupeId=0;const dedupingMixin=function(e){function t(t){let a=t.__mixinSet;if(a&&a[r])return t;let o=n,i=o.get(t);i||(i=e(t),o.set(t,i));let d=Object.create(i.__mixinSet||a||null);return d[r]=!0,i.__mixinSet=d,i}let n=e.__mixinApplications;n||(n=new WeakMap,e.__mixinApplications=n);let r=dedupeId++;return t};let microtaskCurrHandle=0,microtaskLastHandle=0,microtaskCallbacks=[],microtaskNodeContent=0,microtaskNode=document.createTextNode("");new window.MutationObserver(microtaskFlush).observe(microtaskNode,{characterData:!0});function microtaskFlush(){const e=microtaskCallbacks.length;for(let t,n=0;n<e;n++)if(t=microtaskCallbacks[n],t)try{t()}catch(t){setTimeout(()=>{throw t})}microtaskCallbacks.splice(0,e),microtaskLastHandle+=e}const microTask={run(e){return microtaskNode.textContent=microtaskNodeContent++,microtaskCallbacks.push(e),microtaskCurrHandle++},cancel(e){const t=e-microtaskLastHandle;if(0<=t){if(!microtaskCallbacks[t])throw new Error("invalid async handle: "+e);microtaskCallbacks[t]=null}}},microtask=microTask,PropertiesChanged=dedupingMixin(e=>{return class extends e{static createProperties(e){const t=this.prototype;for(let n in e)n in t||t._createPropertyAccessor(n)}static attributeNameForProperty(e){return e.toLowerCase()}static typeForProperty(){}_createPropertyAccessor(e,t){this._addPropertyToAttributeMap(e),this.hasOwnProperty("__dataHasAccessor")||(this.__dataHasAccessor=Object.assign({},this.__dataHasAccessor)),this.__dataHasAccessor[e]||(this.__dataHasAccessor[e]=!0,this._definePropertyAccessor(e,t))}_addPropertyToAttributeMap(e){if(this.hasOwnProperty("__dataAttributes")||(this.__dataAttributes=Object.assign({},this.__dataAttributes)),!this.__dataAttributes[e]){const t=this.constructor.attributeNameForProperty(e);this.__dataAttributes[t]=e}}_definePropertyAccessor(e,t){Object.defineProperty(this,e,{get(){return this._getProperty(e)},set:t?function(){}:function(t){this._setProperty(e,t)}})}constructor(){super(),this.__dataEnabled=!1,this.__dataReady=!1,this.__dataInvalid=!1,this.__data={},this.__dataPending=null,this.__dataOld=null,this.__dataInstanceProps=null,this.__serializing=!1,this._initializeProperties()}ready(){this.__dataReady=!0,this._flushProperties()}_initializeProperties(){for(let e in this.__dataHasAccessor)this.hasOwnProperty(e)&&(this.__dataInstanceProps=this.__dataInstanceProps||{},this.__dataInstanceProps[e]=this[e],delete this[e])}_initializeInstanceProperties(e){Object.assign(this,e)}_setProperty(e,t){this._setPendingProperty(e,t)&&this._invalidateProperties()}_getProperty(e){return this.__data[e]}_setPendingProperty(e,t){let n=this.__data[e],r=this._shouldPropertyChange(e,t,n);return r&&(!this.__dataPending&&(this.__dataPending={},this.__dataOld={}),this.__dataOld&&!(e in this.__dataOld)&&(this.__dataOld[e]=n),this.__data[e]=t,this.__dataPending[e]=t),r}_invalidateProperties(){!this.__dataInvalid&&this.__dataReady&&(this.__dataInvalid=!0,microtask.run(()=>{this.__dataInvalid&&(this.__dataInvalid=!1,this._flushProperties())}))}_enableProperties(){this.__dataEnabled||(this.__dataEnabled=!0,this.__dataInstanceProps&&(this._initializeInstanceProperties(this.__dataInstanceProps),this.__dataInstanceProps=null),this.ready())}_flushProperties(){const e=this.__data,t=this.__dataPending,n=this.__dataOld;this._shouldPropertiesChange(e,t,n)&&(this.__dataPending=null,this.__dataOld=null,this._propertiesChanged(e,t,n))}_shouldPropertiesChange(e,t){return!!t}_propertiesChanged(){}_shouldPropertyChange(e,t,n){return n!==t&&(n===n||t===t)}attributeChangedCallback(e,t,n,r){t!==n&&this._attributeToProperty(e,n),super.attributeChangedCallback&&super.attributeChangedCallback(e,t,n,r)}_attributeToProperty(e,t,n){if(!this.__serializing){const r=this.__dataAttributes,a=r&&r[e]||e;this[a]=this._deserializeValue(t,n||this.constructor.typeForProperty(a))}}_propertyToAttribute(e,t,n){this.__serializing=!0,n=3>arguments.length?this[e]:n,this._valueToNodeAttribute(this,n,t||this.constructor.attributeNameForProperty(e)),this.__serializing=!1}_valueToNodeAttribute(e,t,n){const r=this._serializeValue(t);r===void 0?e.removeAttribute(n):e.setAttribute(n,r)}_serializeValue(e){switch(typeof e){case"boolean":return e?"":void 0;default:return null==e?void 0:e.toString();}}_deserializeValue(e,t){return t===Boolean?null!==e:t===Number?+e:e}}});function normalizeProperties(e){const t={};for(let n in e){const r=e[n];t[n]="function"==typeof r?{type:r}:r}return t}const PropertiesMixin=dedupingMixin(e=>{function t(e){const t=Object.getPrototypeOf(e);return t.prototype instanceof a?t:null}function n(e){if(!e.hasOwnProperty(JSCompiler_renameProperty("__ownProperties",e))){let t=null;e.hasOwnProperty(JSCompiler_renameProperty("properties",e))&&e.properties&&(t=normalizeProperties(e.properties)),e.__ownProperties=t}return e.__ownProperties}const r=PropertiesChanged(e);class a extends r{static get observedAttributes(){const e=this._properties;return e?Object.keys(e).map(e=>this.attributeNameForProperty(e)):[]}static finalize(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__finalized",this))){const e=t(this);e&&e.finalize(),this.__finalized=!0,this._finalizeClass()}}static _finalizeClass(){const e=n(this);e&&this.createProperties(e)}static get _properties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__properties",this))){const e=t(this);this.__properties=Object.assign({},e&&e._properties,n(this))}return this.__properties}static typeForProperty(e){const t=this._properties[e];return t&&t.type}_initializeProperties(){this.constructor.finalize(),super._initializeProperties()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._enableProperties()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback()}}return a}),templateCaches=new Map,html=(e,...t)=>new TemplateResult(e,t,"html");class TemplateResult{constructor(e,t,n,r=defaultPartCallback){this.strings=e,this.values=t,this.type=n,this.partCallback=r}getHTML(){const e=this.strings.length-1;let t="",n=!0;for(let r=0;r<e;r++){const e=this.strings[r];t+=e;const a=findTagClose(e);n=-1<a?a<e.length:n,t+=n?nodeMarker:marker}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");return e.innerHTML=this.getHTML(),e}}function defaultTemplateFactory(e){let t=templateCaches.get(e.type);void 0===t&&(t=new Map,templateCaches.set(e.type,t));let n=t.get(e.strings);return void 0===n&&(n=new Template(e,e.getTemplateElement()),t.set(e.strings,n)),n}function render(e,t,n=defaultTemplateFactory){const r=n(e);let a=t.__templateInstance;if(void 0!==a&&a.template===r&&a._partCallback===e.partCallback)return void a.update(e.values);a=new TemplateInstance(r,e.partCallback,n),t.__templateInstance=a;const o=a._clone();a.update(e.values),removeNodes(t,t.firstChild),t.appendChild(o)}const marker=`{{lit-${(Math.random()+"").slice(2)}}}`,nodeMarker=`<!--${marker}-->`,markerRegex=new RegExp(`${marker}|${nodeMarker}`),lastAttributeNameRegex=/[ \x09\x0a\x0c\x0d]([^\0-\x1F\x7F-\x9F \x09\x0a\x0c\x0d"'>=/]+)[ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*)$/;function findTagClose(e){const t=e.lastIndexOf(">"),n=e.indexOf("<",t+1);return-1<n?e.length:t}class TemplatePart{constructor(e,t,n,r,a){this.type=e,this.index=t,this.name=n,this.rawName=r,this.strings=a}}class Template{constructor(e,t){this.parts=[],this.element=t;const n=this.element.content,r=document.createTreeWalker(n,133,null,!1);let a=-1,o=0;const i=[];for(let n,d;r.nextNode();){a++,n=d;const t=d=r.currentNode;if(1===t.nodeType){if(!t.hasAttributes())continue;const n=t.attributes;let r=0;for(let e=0;e<n.length;e++)0<=n[e].value.indexOf(marker)&&r++;for(;0<r--;){const r=e.strings[o],i=lastAttributeNameRegex.exec(r)[1],d=n.getNamedItem(i),s=d.value.split(markerRegex);this.parts.push(new TemplatePart("attribute",a,d.name,i,s)),t.removeAttribute(d.name),o+=s.length-1}}else if(3===t.nodeType){const e=t.nodeValue;if(0>e.indexOf(marker))continue;const n=t.parentNode,r=e.split(markerRegex),d=r.length-1;o+=d;for(let e=0;e<d;e++)n.insertBefore(""===r[e]?document.createComment(""):document.createTextNode(r[e]),t),this.parts.push(new TemplatePart("node",a++));n.insertBefore(""===r[d]?document.createComment(""):document.createTextNode(r[d]),t),i.push(t)}else if(8===t.nodeType&&t.nodeValue===marker){const e=t.parentNode,r=t.previousSibling;null===r||r!==n||r.nodeType!==Node.TEXT_NODE?e.insertBefore(document.createComment(""),t):a--,this.parts.push(new TemplatePart("node",a++)),i.push(t),null===t.nextSibling?e.insertBefore(document.createComment(""),t):a--,d=n,o++}}for(const r of i)r.parentNode.removeChild(r)}}const getValue=(e,t)=>isDirective(t)?(t=t(e),directiveValue):null===t?void 0:t,isDirective=e=>"function"==typeof e&&!0===e.__litDirective,directiveValue={},isPrimitiveValue=e=>null===e||"object"!=typeof e&&"function"!=typeof e;class AttributePart{constructor(e,t,n,r){this.instance=e,this.element=t,this.name=n,this.strings=r,this.size=r.length-1,this._previousValues=[]}_interpolate(e,t){const n=this.strings,r=n.length-1;let a="";for(let o=0;o<r;o++){a+=n[o];const r=getValue(this,e[t+o]);if(r&&r!==directiveValue&&(Array.isArray(r)||"string"!=typeof r&&r[Symbol.iterator]))for(const e of r)a+=e;else a+=r}return a+n[r]}_equalToPreviousValues(e,t){for(let n=t;n<t+this.size;n++)if(this._previousValues[n]!==e[n]||!isPrimitiveValue(e[n]))return!1;return!0}setValue(e,t){if(this._equalToPreviousValues(e,t))return;const n=this.strings;let r;2===n.length&&""===n[0]&&""===n[1]?(r=getValue(this,e[t]),Array.isArray(r)&&(r=r.join(""))):r=this._interpolate(e,t),r!==directiveValue&&this.element.setAttribute(this.name,r),this._previousValues=e}}class NodePart{constructor(e,t,n){this.instance=e,this.startNode=t,this.endNode=n,this._previousValue=void 0}setValue(e){if(e=getValue(this,e),e!==directiveValue)if(isPrimitiveValue(e)){if(e===this._previousValue)return;this._setText(e)}else e instanceof TemplateResult?this._setTemplateResult(e):Array.isArray(e)||e[Symbol.iterator]?this._setIterable(e):e instanceof Node?this._setNode(e):void 0===e.then?this._setText(e):this._setPromise(e)}_insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}_setNode(e){this._previousValue===e||(this.clear(),this._insert(e),this._previousValue=e)}_setText(e){const t=this.startNode.nextSibling;e=e===void 0?"":e,t===this.endNode.previousSibling&&t.nodeType===Node.TEXT_NODE?t.textContent=e:this._setNode(document.createTextNode(e)),this._previousValue=e}_setTemplateResult(e){const t=this.instance._getTemplate(e);let n;this._previousValue&&this._previousValue.template===t?n=this._previousValue:(n=new TemplateInstance(t,this.instance._partCallback,this.instance._getTemplate),this._setNode(n._clone()),this._previousValue=n),n.update(e.values)}_setIterable(e){Array.isArray(this._previousValue)||(this.clear(),this._previousValue=[]);const t=this._previousValue;let n=0;for(const r of e){let e=t[n];if(e===void 0){let r=this.startNode;if(0<n){const e=t[n-1];r=e.endNode=document.createTextNode(""),this._insert(r)}e=new NodePart(this.instance,r,this.endNode),t.push(e)}e.setValue(r),n++}if(0==n)this.clear(),this._previousValue=void 0;else if(n<t.length){const e=t[n-1];t.length=n,this.clear(e.endNode.previousSibling),e.endNode=this.endNode}}_setPromise(e){this._previousValue=e,e.then(t=>{this._previousValue===e&&this.setValue(t)})}clear(e=this.startNode){removeNodes(this.startNode.parentNode,e.nextSibling,this.endNode)}}const defaultPartCallback=(e,t,n)=>{if("attribute"===t.type)return new AttributePart(e,n,t.name,t.strings);if("node"===t.type)return new NodePart(e,n,n.nextSibling);throw new Error(`Unknown part type ${t.type}`)};class TemplateInstance{constructor(e,t,n){this._parts=[],this.template=e,this._partCallback=t,this._getTemplate=n}update(e){let t=0;for(const n of this._parts)void 0===n.size?(n.setValue(e[t]),t++):(n.setValue(e,t),t+=n.size)}_clone(){const e=document.importNode(this.template.element.content,!0),t=this.template.parts;if(0<t.length){const n=document.createTreeWalker(e,133,null,!1);let r=-1;for(let e=0;e<t.length;e++){const a=t[e];for(;r<a.index;)r++,n.nextNode();this._parts.push(this._partCallback(this,a,n.currentNode))}}return e}}const removeNodes=(e,t,n=null)=>{for(let r=t;r!==n;){const t=r.nextSibling;e.removeChild(r),r=t}},shadyTemplateFactory=e=>t=>{const n=`${t.type}--${e}`;let r=templateCaches.get(n);r===void 0&&(r=new Map,templateCaches.set(n,r));let a=r.get(t.strings);if(a===void 0){const n=t.getTemplateElement();"object"==typeof window.ShadyCSS&&window.ShadyCSS.prepareTemplate(n,e),a=new Template(t,n),r.set(t.strings,a)}return a};function render$1(e,t,n){return render(e,t,shadyTemplateFactory(n))}const html$1=(e,...t)=>new TemplateResult(e,t,"html",extendedPartCallback),extendedPartCallback=(e,t,n)=>{if("attribute"===t.type){if("on-"===t.rawName.substr(0,3)){const r=t.rawName.slice(3);return new EventPart(e,n,r)}const r=t.name.substr(t.name.length-1);if("$"===r){const r=t.name.slice(0,-1);return new AttributePart(e,n,r,t.strings)}if("?"===r){const r=t.name.slice(0,-1);return new BooleanAttributePart(e,n,r,t.strings)}return new PropertyPart(e,n,t.rawName,t.strings)}return defaultPartCallback(e,t,n)};class BooleanAttributePart extends AttributePart{setValue(e,t){const n=this.strings;if(2===n.length&&""===n[0]&&""===n[1]){const n=getValue(this,e[t]);if(n===directiveValue)return;n?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name)}else throw new Error("boolean attributes can only contain a single expression")}}class PropertyPart extends AttributePart{setValue(e,t){const n=this.strings;let r;this._equalToPreviousValues(e,t)||(r=2===n.length&&""===n[0]&&""===n[1]?getValue(this,e[t]):this._interpolate(e,t),r!==directiveValue&&(this.element[this.name]=r),this._previousValues=e)}}class EventPart{constructor(e,t,n){this.instance=e,this.element=t,this.eventName=n}setValue(e){const t=getValue(this,e);t===this._listener||(null==t?this.element.removeEventListener(this.eventName,this):null==this._listener&&this.element.addEventListener(this.eventName,this),this._listener=t)}handleEvent(e){"function"==typeof this._listener?this._listener.call(this.element,e):"function"==typeof this._listener.handleEvent&&this._listener.handleEvent(e)}}class LitElement extends PropertiesMixin(HTMLElement){constructor(){super(...arguments),this.__renderComplete=null,this.__resolveRenderComplete=null,this.__isInvalid=!1,this.__isChanging=!1}ready(){this._root=this._createRoot(),super.ready(),this._firstRendered()}_firstRendered(){}_createRoot(){return this.attachShadow({mode:"open"})}_shouldPropertiesChange(e,t,n){const r=this._shouldRender(e,t,n);return!r&&this.__resolveRenderComplete&&this.__resolveRenderComplete(!1),r}_shouldRender(){return!0}_propertiesChanged(e,t,n){super._propertiesChanged(e,t,n);const r=this._render(e);r&&this._root!==void 0&&this._applyRender(r,this._root),this._didRender(e,t,n),this.__resolveRenderComplete&&this.__resolveRenderComplete(!0)}_flushProperties(){this.__isChanging=!0,this.__isInvalid=!1,super._flushProperties(),this.__isChanging=!1}_shouldPropertyChange(e,t,n){const r=super._shouldPropertyChange(e,t,n);return r&&this.__isChanging&&console.trace(`Setting properties in response to other properties changing `+`considered harmful. Setting '${e}' from `+`'${this._getProperty(e)}' to '${t}'.`),r}_render(){throw new Error("_render() not implemented")}_applyRender(e,t){render$1(e,t,this.localName)}_didRender(){}_requestRender(){this._invalidateProperties()}_invalidateProperties(){this.__isInvalid=!0,super._invalidateProperties()}get renderComplete(){return this.__renderComplete||(this.__renderComplete=new Promise(e=>{this.__resolveRenderComplete=t=>{this.__resolveRenderComplete=this.__renderComplete=null,e(t)}}),!this.__isInvalid&&this.__resolveRenderComplete&&Promise.resolve().then(()=>this.__resolveRenderComplete(!1))),this.__renderComplete}}var Reflect$1,commonjsGlobal="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?{}:self:global:window;(function(e){(function(t){function n(e,t){return function(n,r){"function"!=typeof e[n]&&Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}var r="object"==typeof commonjsGlobal?commonjsGlobal:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),a=n(e);"undefined"==typeof r.Reflect?r.Reflect=e:a=n(r.Reflect,a),t(a)})(function(e){function t(e,t){for(var n=e.length-1;0<=n;--n){var r=e[n],a=r(t);if(!u(a)&&!c(a)){if(!x(a))throw new TypeError;t=a}}return t}function n(e,t,n,r){for(var a=e.length-1;0<=a;--a){var o=e[a],d=o(t,n,r);if(!u(d)&&!c(d)){if(!g(d))throw new TypeError;r=d}}return r}function r(e,t,n){var r=W.get(e);if(u(r)){if(!n)return;r=new B,W.set(e,r)}var a=r.get(t);if(u(a)){if(!n)return;a=new B,r.set(t,a)}return a}function a(e,t,n){var r=o(e,t,n);if(r)return!0;var i=T(t);return!c(i)&&a(e,i,n)}function o(e,t,n){var a=r(t,n,!1);return!u(a)&&h(a.has(e))}function i(e,t,n){var r=o(e,t,n);if(r)return d(e,t,n);var a=T(t);return c(a)?void 0:i(e,a,n)}function d(e,t,n){var a=r(t,n,!1);return u(a)?void 0:a.get(e)}function s(e,t,n,a){var o=r(n,a,!0);o.set(e,t)}function _(e,t){var n=p(e,t),r=T(e);if(null===r)return n;var a=_(r,t);if(0>=a.length)return n;if(0>=n.length)return a;for(var o=new F,i=[],d=0,s=n;d<s.length;d++){var l=s[d],u=o.has(l);u||(o.add(l),i.push(l))}for(var c=0,y=a;c<y.length;c++){var l=y[c],u=o.has(l);u||(o.add(l),i.push(l))}return i}function p(e,t){var n=[],a=r(e,t,!1);if(u(a))return n;for(var o=a.keys(),i=A(o),d=0;;){var s=w(i);if(!s)return n.length=d,n;var _=I(s);try{n[d]=_}catch(t){try{S(i)}finally{throw t}}d++}}function l(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6;}}function u(e){return e===void 0}function c(e){return null===e}function y(e){return"symbol"==typeof e}function g(e){return"object"==typeof e?null!==e:"function"==typeof e}function m(e,t){switch(l(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e;}var n=3===t?"string":5===t?"number":"default",r=N(e,z);if(r!==void 0){var a=r.call(e,n);if(g(a))throw new TypeError;return a}return f(e,"default"==n?"number":n)}function f(e,t){if("string"===t){var n=e.toString;if(k(n)){var r=n.call(e);if(!g(r))return r}var a=e.valueOf;if(k(a)){var r=a.call(e);if(!g(r))return r}}else{var a=e.valueOf;if(k(a)){var r=a.call(e);if(!g(r))return r}var o=e.toString;if(k(o)){var r=o.call(e);if(!g(r))return r}}throw new TypeError}function h(e){return!!e}function v(e){return""+e}function b(e){var t=m(e,3);return y(t)?t:v(t)}function P(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function k(e){return"function"==typeof e}function x(e){return"function"==typeof e}function C(e){switch(l(e)){case 3:return!0;case 4:return!0;default:return!1;}}function N(e,t){var n=e[t];if(void 0!==n&&null!==n){if(!k(n))throw new TypeError;return n}}function A(e){var t=N(e,R);if(!k(t))throw new TypeError;var n=t.call(e);if(!g(n))throw new TypeError;return n}function I(e){return e.value}function w(e){var t=e.next();return!t.done&&t}function S(e){var t=e["return"];t&&t.call(e)}function T(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===K)return t;if(t!==K)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(null==r||r===Object.prototype)return t;var a=r.constructor;return"function"==typeof a?a===e?t:a:t}function O(e){return e.__=void 0,delete e.__,e}var E=Object.prototype.hasOwnProperty,V="function"==typeof Symbol,z=V&&"undefined"!=typeof Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",R=V&&"undefined"!=typeof Symbol.iterator?Symbol.iterator:"@@iterator",L="function"==typeof Object.create,M={__proto__:[]}instanceof Array,j=!L&&!M,H={create:L?function(){return O(Object.create(null))}:M?function(){return O({__proto__:null})}:function(){return O({})},has:j?function(e,t){return E.call(e,t)}:function(e,t){return t in e},get:j?function(e,t){return E.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},K=Object.getPrototypeOf(Function),D="object"==typeof process&&process.env&&"true"===process.env.REFLECT_METADATA_USE_MAP_POLYFILL,B=D||"function"!=typeof Map||"function"!=typeof Map.prototype.entries?function(){function e(e){return e}function t(e,t){return t}function n(e,t){return[e,t]}var r={},a=[],o=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype["@@iterator"]=function(){return this},e.prototype[R]=function(){return this},e.prototype.next=function(){var e=this._index;if(0<=e&&e<this._keys.length){var t=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=a,this._values=a):this._index++,{value:t,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw 0<=this._index&&(this._index=-1,this._keys=a,this._values=a),e},e.prototype.return=function(e){return 0<=this._index&&(this._index=-1,this._keys=a,this._values=a),{value:e,done:!0}},e}();return function(){function a(){this._keys=[],this._values=[],this._cacheKey=r,this._cacheIndex=-2}return Object.defineProperty(a.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),a.prototype.has=function(e){return 0<=this._find(e,!1)},a.prototype.get=function(e){var t=this._find(e,!1);return 0<=t?this._values[t]:void 0},a.prototype.set=function(e,t){var n=this._find(e,!0);return this._values[n]=t,this},a.prototype.delete=function(e){var t=this._find(e,!1);if(0<=t){for(var n=this._keys.length,a=t+1;a<n;a++)this._keys[a-1]=this._keys[a],this._values[a-1]=this._values[a];return this._keys.length--,this._values.length--,e===this._cacheKey&&(this._cacheKey=r,this._cacheIndex=-2),!0}return!1},a.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=r,this._cacheIndex=-2},a.prototype.keys=function(){return new o(this._keys,this._values,e)},a.prototype.values=function(){return new o(this._keys,this._values,t)},a.prototype.entries=function(){return new o(this._keys,this._values,n)},a.prototype["@@iterator"]=function(){return this.entries()},a.prototype[R]=function(){return this.entries()},a.prototype._find=function(e,t){return this._cacheKey!==e&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=e)),0>this._cacheIndex&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},a}()}():Map,F=D||"function"!=typeof Set||"function"!=typeof Set.prototype.entries?function(){return function(){function e(){this._map=new B}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.values()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[R]=function(){return this.keys()},e}()}():Set,q=D||"function"!=typeof WeakMap?function(){function e(){var e;do e="@@WeakMap@@"+a();while(H.has(o,e));return o[e]=!0,e}function t(e,t){if(!E.call(e,i)){if(!t)return;Object.defineProperty(e,i,{value:H.create()})}return e[i]}function n(e,t){for(var n=0;n<t;++n)e[n]=0|255*Math.random();return e}function r(e){return"function"==typeof Uint8Array?"undefined"==typeof crypto?"undefined"==typeof msCrypto?n(new Uint8Array(e),e):msCrypto.getRandomValues(new Uint8Array(e)):crypto.getRandomValues(new Uint8Array(e)):n(Array(e),e)}function a(){var e=r(16);e[6]=64|79&e[6],e[8]=128|191&e[8];for(var t,n="",a=0;a<16;++a)t=e[a],(4===a||6===a||8===a)&&(n+="-"),16>t&&(n+="0"),n+=t.toString(16).toLowerCase();return n}var o=H.create(),i=e();return function(){function n(){this._key=e()}return n.prototype.has=function(e){var n=t(e,!1);return void 0!==n&&H.has(n,this._key)},n.prototype.get=function(e){var n=t(e,!1);return void 0===n?void 0:H.get(n,this._key)},n.prototype.set=function(e,n){var r=t(e,!0);return r[this._key]=n,this},n.prototype.delete=function(e){var n=t(e,!1);return void 0!==n&&delete n[this._key]},n.prototype.clear=function(){this._key=e()},n}()}():WeakMap,W=new q;e("decorate",function(e,r,a,o){if(!u(a)){if(!P(e))throw new TypeError;if(!g(r))throw new TypeError;if(!g(o)&&!u(o)&&!c(o))throw new TypeError;return c(o)&&(o=void 0),a=b(a),n(e,r,a,o)}if(!P(e))throw new TypeError;if(!x(r))throw new TypeError;return t(e,r)}),e("metadata",function(e,t){return function(n,r){if(!g(n))throw new TypeError;if(!u(r)&&!C(r))throw new TypeError;s(e,t,n,r)}}),e("defineMetadata",function(e,t,n,r){if(!g(n))throw new TypeError;return u(r)||(r=b(r)),s(e,t,n,r)}),e("hasMetadata",function(e,t,n){if(!g(t))throw new TypeError;return u(n)||(n=b(n)),a(e,t,n)}),e("hasOwnMetadata",function(e,t,n){if(!g(t))throw new TypeError;return u(n)||(n=b(n)),o(e,t,n)}),e("getMetadata",function(e,t,n){if(!g(t))throw new TypeError;return u(n)||(n=b(n)),i(e,t,n)}),e("getOwnMetadata",function(e,t,n){if(!g(t))throw new TypeError;return u(n)||(n=b(n)),d(e,t,n)}),e("getMetadataKeys",function(e,t){if(!g(e))throw new TypeError;return u(t)||(t=b(t)),_(e,t)}),e("getOwnMetadataKeys",function(e,t){if(!g(e))throw new TypeError;return u(t)||(t=b(t)),p(e,t)}),e("deleteMetadata",function(e,t,n){if(!g(t))throw new TypeError;u(n)||(n=b(n));var a=r(t,n,!1);if(u(a))return!1;if(!a.delete(e))return!1;if(0<a.size)return!0;var o=W.get(t);return!(o.delete(n),!(0<o.size))||(W.delete(t),!0)})})})(Reflect$1||(Reflect$1={}));const bindAttributes=function(e){return class extends e{_propertiesChanged(e,t,n){super._propertiesChanged(e,t,n);const r=this.constructor._boundAttributes;r&&t&&Object.keys(t).forEach(t=>{if(r.includes(t)){const n=e[t];n||0===n?this.setAttribute(t,e[t]):this.removeAttribute(t)}})}}},component=e=>function(t){window.customElements.define(e,t)};function property(e,t){function n(e,t){Reflect.hasMetadata("design:type",e,t)&&(r.type=Reflect.getMetadata("design:type",e,t)),e.constructor.properties=e.constructor.properties||{},e.constructor.properties[t]=Object.assign(r,e.constructor.properties[t]||{})}let r,a=!1;return void 0===t?(r=e||{},a=!0):r={},a?n:n(e,t)}var CSS=html$1`<style>:host{--arrow-size: 1rem;position:fixed;border-radius:var(--tooltip-border-radius, var(--border-radius, .4rem));background-color:var(--tooltip-bg, var(--color-white, #fff));box-shadow:var(--tooltip-shadow, var(--shadow-main-soft, 0 var(--size-tiny, 1rem) var(--size-main, 4rem) var(--color-main-soft, rgba(105,58,145,0.1))));padding:var(--tooltip-padding, var(--size-tiny, 1rem));visibility:hidden;opacity:0;z-index:999}:host:before{content:'';position:absolute;width:0;height:0;border-left:var(--arrow-size) solid transparent;border-right:var(--arrow-size) solid transparent;border-top:var(--arrow-size) solid white;box-shadow:var(--tooltip-shadow, var(--shadow-main-soft, 0 var(--size-tiny, 1rem) var(--size-main, 4rem) var(--color-main-soft, rgba(105,58,145,0.1))))}:host-context([position^=top]),:host-context([position^=bottom]){transform:translateX(-50%)}:host-context([position^=left]),:host-context([position^=right]){transform:translateY(-50%)}:host-context([position^=top]):before{top:100%}:host-context([position^=bottom]):before{bottom:100%;transform:rotate(180deg)}:host-context([position$=-top]):before{bottom:var(--tooltip-border-radius, var(--border-radius, .4rem))}:host-context([position$=-bottom]):before{top:var(--tooltip-border-radius, var(--border-radius, .4rem))}:host-context([position^=right]):before{right:calc(100% - var(--arrow-size) / 2);transform:rotate(90deg)}:host-context([position^=left]):before{left:calc(100% - var(--arrow-size) / 2);transform:rotate(270deg)}:host-context([position$=-right]):before{left:var(--tooltip-border-radius, var(--border-radius, .4rem))}:host-context([position$=-left]):before{right:var(--tooltip-border-radius, var(--border-radius, .4rem))}:host-context([position=bottom]):before,:host-context([position=top]):before{left:50%;margin-left:-1rem}:host-context([position=right]):before,:host-context([position=left]):before{top:50%;margin-top:-0.5rem}:host-context([show]){animation:tooltip-fade var(--transition-time, .35s) forwards}@keyframes tooltip-fade{from{visibility:visible;opacity:0}to{visibility:visible;opacity:1}}@keyframes tooltip-up{from{visibility:visible;opacity:0;margin-top:2px}to{visibility:visible;opacity:1;margin-top:0}}
</style>`;let Tooltip=class extends LitElement{constructor(){super(),this.position="bottom",this.__show=!1,this._update=this._update.bind(this),this._remove=this._remove.bind(this),this._show=this._show.bind(this),this._hide=this._hide.bind(this)}ready(){super.ready(),this.show=!1}connectedCallback(){super.connectedCallback(),this._update(),this.removable&&(window.addEventListener("mouseup",this._remove),window.addEventListener("keydown",this._remove)),window.addEventListener("scroll",this._update),window.addEventListener("resize",this._update)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("scroll",this._update),window.removeEventListener("resize",this._update)}get show(){return this.__show}set show(e){e?this.setAttribute("show","true"):this.removeAttribute("show"),this.__show=e}get for(){return"string"==typeof this._for?document.querySelector(`#${this._for}`):this._for||null}set for(e){e&&this._for!==e&&(this._updateHandlers("remove"),this._for=e,this._updateHandlers("add"),this._update())}get on(){return this._on}set on(e){this._updateHandlers("remove"),this._on=e,this._updateHandlers("add")}_render(){return html`${CSS}<slot></slot>`}_didRender(){this._update()}_show(){this.show=!0}_hide(){this.show=!1}_update(){if(!this.for||!this.position)return void(this.show=!1);const{x:e,y:t,width:n,height:r}=this.for.getBoundingClientRect();this.style.left=/^left$/.test(this.position)?`${parseInt(e.toString(),10)}px`:/^right$/.test(this.position)?`${parseInt((e+n).toString(),10)}px`:`${parseInt((e+n/2).toString(),10)}px`,this.style.top=/^top$/.test(this.position)?`${parseInt(t.toString(),10)}px`:/^bottom$/.test(this.position)?`${parseInt((t+r).toString(),10)}px`:`${parseInt((t+r/2).toString(),10)}px`}_remove(t){t instanceof KeyboardEvent&&"Escape"!==t.key||(window.removeEventListener("keydown",this._remove),window.removeEventListener("click",this._remove),this.remove())}_updateHandlers(e){const t=this.for;if(t&&"boolean"!=typeof this.on){const n="add"===e?t.addEventListener.bind(t):t.removeEventListener.bind(t);switch(this.on){case"hover":n("mouseenter",this._show),n("mouseleave",this._hide);}}}};Tooltip._boundAttributes=["position","on"],__decorate([property,__metadata("design:type",String)],Tooltip.prototype,"position",void 0),__decorate([property,__metadata("design:type",Object),__metadata("design:paramtypes",[Object])],Tooltip.prototype,"show",null),__decorate([property,__metadata("design:type",Object),__metadata("design:paramtypes",[Object])],Tooltip.prototype,"for",null),__decorate([property,__metadata("design:type",Object),__metadata("design:paramtypes",[Object])],Tooltip.prototype,"on",null),Tooltip=__decorate([component("zen-tooltip"),bindAttributes,__metadata("design:paramtypes",[])],Tooltip);
//# sourceMappingURL=Tooltip.js.map