@keditor/components
Version:
A library of generic web components that are accessible, framework agnostic, possible to style, and easy to use with data provided by Contentful
270 lines (268 loc) • 50.7 kB
JavaScript
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const t="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,e=(t,e,n=null)=>{for(;e!==n;){const n=e.nextSibling;t.removeChild(e),e=n}},n=`{{lit-${String(Math.random()).slice(2)}}}`,r=`\x3c!--${n}--\x3e`,s=new RegExp(`${n}|${r}`),i="$lit$";class o{constructor(t,e){this.parts=[],this.element=e;const r=[],o=[],l=document.createTreeWalker(e.content,133,null,!1);let h=0,p=-1,d=0;const{strings:f,values:{length:m}}=t;for(;d<m;){const t=l.nextNode();if(null!==t){if(p++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:n}=e;let r=0;for(let t=0;t<n;t++)a(e[t].name,i)&&r++;for(;r-- >0;){const e=f[d],n=u.exec(e)[2],r=n.toLowerCase()+i,o=t.getAttribute(r);t.removeAttribute(r);const a=o.split(s);this.parts.push({type:"attribute",index:p,name:n,strings:a}),d+=a.length-1}}"TEMPLATE"===t.tagName&&(o.push(t),l.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,o=e.split(s),l=o.length-1;for(let e=0;e<l;e++){let r,s=o[e];if(""===s)r=c();else{const t=u.exec(s);null!==t&&a(t[2],i)&&(s=s.slice(0,t.index)+t[1]+t[2].slice(0,-i.length)+t[3]),r=document.createTextNode(s)}n.insertBefore(r,t),this.parts.push({type:"node",index:++p})}""===o[l]?(n.insertBefore(c(),t),r.push(t)):t.data=o[l],d+=l}}else if(8===t.nodeType)if(t.data===n){const e=t.parentNode;null!==t.previousSibling&&p!==h||(p++,e.insertBefore(c(),t)),h=p,this.parts.push({type:"node",index:p}),null===t.nextSibling?t.data="":(r.push(t),p--),d++}else{let e=-1;for(;-1!==(e=t.data.indexOf(n,e+1));)this.parts.push({type:"node",index:-1}),d++}}else l.currentNode=o.pop()}for(const n of r)n.parentNode.removeChild(n)}}const a=(t,e)=>{const n=t.length-e.length;return n>=0&&t.slice(n)===e},l=t=>-1!==t.index,c=()=>document.createComment(""),u=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function h(t,e){const{element:{content:n},parts:r}=t,s=document.createTreeWalker(n,133,null,!1);let i=d(r),o=r[i],a=-1,l=0;const c=[];let u=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===u&&(u=null),e.has(t)&&(c.push(t),null===u&&(u=t)),null!==u&&l++;void 0!==o&&o.index===a;)o.index=null!==u?-1:o.index-l,i=d(r,i),o=r[i]}c.forEach((t=>t.parentNode.removeChild(t)))}const p=t=>{let e=11===t.nodeType?0:1;const n=document.createTreeWalker(t,133,null,!1);for(;n.nextNode();)e++;return e},d=(t,e=-1)=>{for(let n=e+1;n<t.length;n++){const e=t[n];if(l(e))return n}return-1};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const f=new WeakMap,m=t=>"function"==typeof t&&f.has(t),y={},v={};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
class g{constructor(t,e,n){this.__parts=[],this.template=t,this.processor=e,this.options=n}update(t){let e=0;for(const n of this.__parts)void 0!==n&&n.setValue(t[e]),e++;for(const n of this.__parts)void 0!==n&&n.commit()}_clone(){const e=t?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),n=[],r=this.template.parts,s=document.createTreeWalker(e,133,null,!1);let i,o=0,a=0,c=s.nextNode();for(;o<r.length;)if(i=r[o],l(i)){for(;a<i.index;)a++,"TEMPLATE"===c.nodeName&&(n.push(c),s.currentNode=c.content),null===(c=s.nextNode())&&(s.currentNode=n.pop(),c=s.nextNode());if("node"===i.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(c.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(c,i.name,i.strings,this.options));o++}else this.__parts.push(void 0),o++;return t&&(document.adoptNode(e),customElements.upgrade(e)),e}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const _=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),b=` ${n} `;class w{constructor(t,e,n,r){this.strings=t,this.values=e,this.type=n,this.processor=r}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let o=0;o<t;o++){const t=this.strings[o],a=t.lastIndexOf("\x3c!--");s=(a>-1||s)&&-1===t.indexOf("--\x3e",a+1);const l=u.exec(t);e+=null===l?t+(s?b:r):t.substr(0,l.index)+l[1]+l[2]+i+l[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==_&&(e=_.createHTML(e)),t.innerHTML=e,t}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const S=t=>null===t||!("object"==typeof t||"function"==typeof t),x=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class P{constructor(t,e,n){this.dirty=!0,this.element=t,this.name=e,this.strings=n,this.parts=[];for(let r=0;r<n.length-1;r++)this.parts[r]=this._createPart()}_createPart(){return new T(this)}_getValue(){const t=this.strings,e=t.length-1,n=this.parts;if(1===e&&""===t[0]&&""===t[1]){const t=n[0].value;if("symbol"==typeof t)return String(t);if("string"==typeof t||!x(t))return t}let r="";for(let s=0;s<e;s++){r+=t[s];const e=n[s];if(void 0!==e){const t=e.value;if(S(t)||!x(t))r+="string"==typeof t?t:String(t);else for(const e of t)r+="string"==typeof e?e:String(e)}}return r+=t[e],r}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class T{constructor(t){this.value=void 0,this.committer=t}setValue(t){t===y||S(t)&&t===this.value||(this.value=t,m(t)||(this.committer.dirty=!0))}commit(){for(;m(this.value);){const t=this.value;this.value=y,t(this)}this.value!==y&&this.committer.commit()}}class k{constructor(t){this.value=void 0,this.__pendingValue=void 0,this.options=t}appendInto(t){this.startNode=t.appendChild(c()),this.endNode=t.appendChild(c())}insertAfterNode(t){this.startNode=t,this.endNode=t.nextSibling}appendIntoPart(t){t.__insert(this.startNode=c()),t.__insert(this.endNode=c())}insertAfterPart(t){t.__insert(this.startNode=c()),this.endNode=t.endNode,t.endNode=this.startNode}setValue(t){this.__pendingValue=t}commit(){if(null===this.startNode.parentNode)return;for(;m(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=y,t(this)}const t=this.__pendingValue;t!==y&&(S(t)?t!==this.value&&this.__commitText(t):t instanceof w?this.__commitTemplateResult(t):t instanceof Node?this.__commitNode(t):x(t)?this.__commitIterable(t):t===v?(this.value=v,this.clear()):this.__commitText(t))}__insert(t){this.endNode.parentNode.insertBefore(t,this.endNode)}__commitNode(t){this.value!==t&&(this.clear(),this.__insert(t),this.value=t)}__commitText(t){const e=this.startNode.nextSibling,n="string"==typeof(t=null==t?"":t)?t:String(t);e===this.endNode.previousSibling&&3===e.nodeType?e.data=n:this.__commitNode(document.createTextNode(n)),this.value=t}__commitTemplateResult(t){const e=this.options.templateFactory(t);if(this.value instanceof g&&this.value.template===e)this.value.update(t.values);else{const n=new g(e,t.processor,this.options),r=n._clone();n.update(t.values),this.__commitNode(r),this.value=n}}__commitIterable(t){Array.isArray(this.value)||(this.value=[],this.clear());const e=this.value;let n,r=0;for(const s of t)n=e[r],void 0===n&&(n=new k(this.options),e.push(n),0===r?n.appendIntoPart(this):n.insertAfterPart(e[r-1])),n.setValue(s),n.commit(),r++;r<e.length&&(e.length=r,this.clear(n&&n.endNode))}clear(t=this.startNode){e(this.startNode.parentNode,t.nextSibling,this.endNode)}}class O{constructor(t,e,n){if(this.value=void 0,this.__pendingValue=void 0,2!==n.length||""!==n[0]||""!==n[1])throw new Error("Boolean attributes can only contain a single expression");this.element=t,this.name=e,this.strings=n}setValue(t){this.__pendingValue=t}commit(){for(;m(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=y,t(this)}if(this.__pendingValue===y)return;const t=!!this.__pendingValue;this.value!==t&&(t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=t),this.__pendingValue=y}}class C extends P{constructor(t,e,n){super(t,e,n),this.single=2===n.length&&""===n[0]&&""===n[1]}_createPart(){return new A(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class A extends T{}let E=!1;(()=>{try{const t={get capture(){return E=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class j{constructor(t,e,n){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=n,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;m(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=y,t(this)}if(this.__pendingValue===y)return;const t=this.__pendingValue,e=this.value,n=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),r=null!=t&&(null==e||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),r&&(this.__options=N(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=y}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const N=t=>t&&(E?{capture:t.capture,passive:t.passive,once:t.once}:t.capture)
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/;function $(t){let e=M.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},M.set(t.type,e));let r=e.stringsArray.get(t.strings);if(void 0!==r)return r;const s=t.strings.join(n);return r=e.keyString.get(s),void 0===r&&(r=new o(t,t.getTemplateElement()),e.keyString.set(s,r)),e.stringsArray.set(t.strings,r),r}const M=new Map,U=new WeakMap;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/const V=new
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
class{handleAttributeExpressions(t,e,n,r){const s=e[0];if("."===s){return new C(t,e.slice(1),n).parts}if("@"===s)return[new j(t,e.slice(1),r.eventContext)];if("?"===s)return[new O(t,e.slice(1),n)];return new P(t,e,n).parts}handleTextExpression(t){return new k(t)}};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const L=(t,...e)=>new w(t,e,"html",V)
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/,R=(t,e)=>`${t}--${e}`;let z=!0;void 0===window.ShadyCSS?z=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),z=!1);const I=t=>e=>{const r=R(e.type,t);let s=M.get(r);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},M.set(r,s));let i=s.stringsArray.get(e.strings);if(void 0!==i)return i;const a=e.strings.join(n);if(i=s.keyString.get(a),void 0===i){const n=e.getTemplateElement();z&&window.ShadyCSS.prepareTemplateDom(n,t),i=new o(e,n),s.keyString.set(a,i)}return s.stringsArray.set(e.strings,i),i},F=["html","svg"],W=new Set,q=(t,e,n)=>{W.add(t);const r=n?n.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:i}=s;if(0===i)return void window.ShadyCSS.prepareTemplateStyles(r,t);const o=document.createElement("style");for(let c=0;c<i;c++){const t=s[c];t.parentNode.removeChild(t),o.textContent+=t.textContent}(t=>{F.forEach((e=>{const n=M.get(R(e,t));void 0!==n&&n.keyString.forEach((t=>{const{element:{content:e}}=t,n=new Set;Array.from(e.querySelectorAll("style")).forEach((t=>{n.add(t)})),h(t,n)}))}))})(t);const a=r.content;n?function(t,e,n=null){const{element:{content:r},parts:s}=t;if(null==n)return void r.appendChild(e);const i=document.createTreeWalker(r,133,null,!1);let o=d(s),a=0,l=-1;for(;i.nextNode();)for(l++,i.currentNode===n&&(a=p(e),n.parentNode.insertBefore(e,n));-1!==o&&s[o].index===l;){if(a>0){for(;-1!==o;)s[o].index+=a,o=d(s,o);return}o=d(s,o)}}(n,o,a.firstChild):a.insertBefore(o,a.firstChild),window.ShadyCSS.prepareTemplateStyles(r,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(n){a.insertBefore(o,a.firstChild);const t=new Set;t.add(o),h(n,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const D={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},B=(t,e)=>e!==t&&(e==e||t==t),H={attribute:!0,type:String,converter:D,reflect:!1,hasChanged:B},J="finalized";class Q extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach(((e,n)=>{const r=this._attributeNameForProperty(n,e);void 0!==r&&(this._attributeToPropertyMap.set(r,n),t.push(r))})),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach(((t,e)=>this._classProperties.set(e,t)))}}static createProperty(t,e=H){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const n="symbol"==typeof t?Symbol():`__${t}`,r=this.getPropertyDescriptor(t,n,e);void 0!==r&&Object.defineProperty(this.prototype,t,r)}static getPropertyDescriptor(t,e,n){return{get(){return this[e]},set(r){const s=this[t];this[e]=r,this.requestUpdateInternal(t,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||H}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty(J)||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const n of e)this.createProperty(n,t[n])}}static _attributeNameForProperty(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,n=B){return n(t,e)}static _propertyValueFromAttribute(t,e){const n=e.type,r=e.converter||D,s="function"==typeof r?r:r.fromAttribute;return s?s(t,n):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const n=e.type,r=e.converter;return(r&&r.toAttribute||D.toAttribute)(t,n)}initialize(){this._updateState=0,this._updatePromise=new Promise((t=>this._enableUpdatingResolver=t)),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach(((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}}))}_applyInstanceProperties(){this._instanceProperties.forEach(((t,e)=>this[e]=t)),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,n){e!==n&&this._attributeToProperty(t,n)}_propertyToAttribute(t,e,n=H){const r=this.constructor,s=r._attributeNameForProperty(t,n);if(void 0!==s){const t=r._propertyValueToAttribute(e,n);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(s):this.setAttribute(s,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const n=this.constructor,r=n._attributeToPropertyMap.get(t);if(void 0!==r){const t=n.getPropertyOptions(r);this._updateState=16|this._updateState,this[r]=n._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,n){let r=!0;if(void 0!==t){const s=this.constructor;n=n||s.getPropertyOptions(t),s._valueHasChanged(this[t],e,n.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,n))):r=!1}!this._hasRequestedUpdate&&r&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(n){throw t=!1,this._markUpdated(),n}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach(((t,e)=>this._propertyToAttribute(e,this[e],t))),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}Q.finalized=!0;
/**
@license
Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
const G=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,K=Symbol();class X{constructor(t,e){if(e!==K)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(G?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Y=(t,...e)=>{const n=e.reduce(((e,n,r)=>e+(t=>{if(t instanceof X)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(n)+t[r+1]),t[0]);return new X(n,K)};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const Z={};class tt extends Q{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,n)=>t.reduceRight(((t,n)=>Array.isArray(n)?e(n,t):(t.add(n),t)),n),n=e(t,new Set),r=[];n.forEach((t=>r.unshift(t))),this._styles=r}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map((t=>{if(t instanceof CSSStyleSheet&&!G){const e=Array.prototype.slice.call(t.cssRules).reduce(((t,e)=>t+e.cssText),"");return new X(String(e),K)}return t}))}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?G?this.renderRoot.adoptedStyleSheets=t.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map((t=>t.cssText)),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==Z&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach((t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)})))}render(){return Z}}tt.finalized=!0,tt.render=(t,n,r)=>{if(!r||"object"!=typeof r||!r.scopeName)throw new Error("The `scopeName` option is required.");const s=r.scopeName,i=U.has(n),o=z&&11===n.nodeType&&!!n.host,a=o&&!W.has(s),l=a?document.createDocumentFragment():n;if(((t,n,r)=>{let s=U.get(n);void 0===s&&(e(n,n.firstChild),U.set(n,s=new k(Object.assign({templateFactory:$},r))),s.appendInto(n)),s.setValue(t),s.commit()})(t,l,Object.assign({templateFactory:I(s)},r)),a){const t=U.get(l);U.delete(l);const r=t.value instanceof g?t.value.template:void 0;q(s,l,r),e(n,n.firstChild),n.appendChild(l),U.set(n,t)}!i&&o&&window.ShadyCSS.styleElement(n.host)},tt.shadowRootOptions={mode:"open"};var et="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},nt={},rt={},st={},it=et&&et.__assign||function(){return(it=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},ot=et&&et.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n},at=et&&et.__spreadArray||function(t,e){for(var n=0,r=e.length,s=t.length;n<r;n++,s++)t[s]=e[n];return t};Object.defineProperty(st,"__esModule",{value:!0}),st.Linkset=void 0;var lt=function(){function t(t){this.elements=t,this.size=t.length}return t.prototype.hasLinkTo=function(t){return this.elements.some((function(e){return e.rel===t}))},t.prototype.linkTo=function(t){return this.elements.find((function(e){return e.rel===t}))},t.prototype.linksTo=function(e){return new t(this.elements.filter((function(t){return t.rel===e})))},t.prototype.linksFrom=function(e){return new t(this.elements.filter((function(t){return t.anchor===e})))},t.prototype.linksWithAttribute=function(e){return new t(this.elements.filter((function(t){return Object.prototype.hasOwnProperty.call(t.attributes,e)})))},t.prototype.linksWithAttributeValue=function(e,n){return new t(this.linksWithAttribute(e).elements.filter((function(t){return(Array.isArray(t.attributes[e])?t.attributes[e]:[t.attributes[e]]).some((function(t){return function(t,e){if(typeof t!=typeof e)return!1;if("string"==typeof t&&"string"==typeof e)return t===e;return t.value==t.value&&t.language==t.language}(t,n)}))})))},t.prototype[Symbol.iterator]=function(){var t=this.elements,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}},t.prototype.normalize=function(){var t={};return this.elements.forEach((function(e){var n=e.anchor,r=e.rel,s=ot(e,["anchor","rel"]);Object.hasOwnProperty.call(t,n)||(t[n]={}),Object.hasOwnProperty.call(t[n],r)||(t[n][r]=[]);var i=s.href,o=s.attributes,a=it({href:i},o);t[n][r].push(a)})),{linkset:Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return at(at([],t),[it({anchor:n},r)])}),[])}},t}();st.Linkset=lt;var ct={},ut=et&&et.__spreadArray||function(t,e){for(var n=0,r=e.length,s=t.length;n<r;n++,s++)t[s]=e[n];return t};Object.defineProperty(ct,"__esModule",{value:!0}),ct.buildTree=ct.MenuElement=void 0;var ht=function(){function t(t,e){void 0===e&&(e=[]),this.link=t,this.children=pt(ut([],e))}return Object.defineProperty(t.prototype,"title",{get:function(){return this.link.attributes.title},enumerable:!1,configurable:!0}),t}();function pt(t){if(t.length<2)return t.length?[new ht(t.shift())]:[];t.sort((function(t,e){return t.attributes["drupal-menu-hierarchy"][0].localeCompare(e.attributes["drupal-menu-hierarchy"][0])}));var e,n=[],r=[];do{var s=t.shift();e?s.attributes["drupal-menu-hierarchy"][0].length>e.attributes["drupal-menu-hierarchy"][0].length?r.push(s):(n.push(new ht(e,r)),e=s,r=[]):e=s}while(t.length);return n.push(new ht(e,r)),n}ct.MenuElement=ht,ct.buildTree=pt;var dt,ft=et&&et.__extends||(dt=function(t,e){return(dt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}dt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),mt=et&&et.__spreadArray||function(t,e){for(var n=0,r=e.length,s=t.length;n<r;n++,s++)t[s]=e[n];return t};Object.defineProperty(rt,"__esModule",{value:!0}),rt.Menu=void 0;var yt=ct,vt=function(t){function e(e,n){var r=t.call(this,n.elements)||this;return r.id=e,r.tree=yt.buildTree(mt([],r.elements)),r}return ft(e,t),e.prototype.linksTo=function(n){return new e(this.id,t.prototype.linksTo.call(this,n))},e.prototype.linksFrom=function(n){return new e(this.id,t.prototype.linksTo.call(this,n))},e.prototype.linksWithAttribute=function(n){return new e(this.id,t.prototype.linksWithAttribute.call(this,n))},e.prototype.linksWithAttributeValue=function(n,r){return new e(this.id,t.prototype.linksWithAttributeValue.call(this,n,r))},e}(st.Linkset);rt.Menu=vt;var gt={},_t={},bt=et&&et.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n};Object.defineProperty(_t,"__esModule",{value:!0}),_t.Link=void 0;var wt=function(t){var e=t.anchor,n=t.rel,r=t.href,s=bt(t,["anchor","rel","href"]);this.anchor=e,this.rel=n,this.href=r,this.attributes=s};_t.Link=wt;var St=et&&et.__assign||function(){return(St=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},xt=et&&et.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n};Object.defineProperty(gt,"__esModule",{value:!0}),gt.denormalize=gt.parse=void 0;var Pt=st,Tt=_t;function kt(t){var e=[];return t.linkset.forEach((function(t){var n=t.anchor,r=xt(t,["anchor"]);Object.keys(r).forEach((function(r){t[r].forEach((function(t){e.push(new Tt.Link(St({anchor:n,rel:r},t)))}))}))})),new Pt.Linkset(e)}gt.denormalize=kt,gt.parse=function(t){return kt(JSON.parse(t))},Object.defineProperty(nt,"__esModule",{value:!0});var Ot=nt.denormalize=nt.parse=void 0,Ct=rt,At=gt;function Et(t,e){var n=At.denormalize(t),r=[];e?r.push(e):n.linksWithAttribute("drupal-menu-machine-name").elements.forEach((function(t){r.includes(t.attributes["drupal-menu-machine-name"][0])||r.push(t.attributes["drupal-menu-machine-name"][0])}));var s=r.map((function(t){return new Ct.Menu(t,n.linksWithAttributeValue("drupal-menu-machine-name",t))}));return e?s.shift():s}Ot=nt.denormalize=Et,nt.parse=function(t,e){return Et(JSON.parse(t),e)};class jt extends tt{static get styles(){return Y`
:host {
display: block;
}
:host(.dark) {
background-color: black;
color: white;
}
:host(.light) {
background-color: lightgrey;
}
.gdwc-menu li > ul {
display: none;
}
.gdwc-menu ul.show {
display: block;
}
`}static get properties(){return{baseUrl:{type:String},menuId:{type:String},branding:{type:String},tree:{type:Array},isLoading:{type:Boolean,attribute:!1},loadingMessage:{type:String}}}constructor(){super(),this.tree=[],this.isLoading=!1,this.loadingMessage="Loading..."}connectedCallback(){super.connectedCallback(),this.baseUrl&&this.menuId&&this.fetchData(this.baseUrl,this.menuId)}static menuLevelTemplate(t){return L`<ul part="menu-level">
${t}
</ul>`}menuParentTemplate(t,e){return L`<li part="menu-item">
<a
@click="${jt.openMenu}"
role="button"
aria-expanded="false"
aria-haspopup="true"
href="#"
>
${t}
</a>
${this.renderMenuLevel(e)}
</li>`}static menuLinkTemplate(t,e){return L`<li part="menu-item"><a href=${e}>${t}</a></li>`}static menuItemTemplate(t){return L`<li part="menu-item">${t}</li>`}renderMenuLevel(t){const e=t.map((t=>this.renderMenuItem(t)));return jt.menuLevelTemplate(e)}renderMenuItem(t){var e,n,r;const s=null==(n=null==(e=null==t?void 0:t.link)?void 0:e.attributes)?void 0:n.title,i=null==(r=null==t?void 0:t.link)?void 0:r.href,o=null==t?void 0:t.children;return o&&o.length?this.menuParentTemplate(s,o):i?jt.menuLinkTemplate(s,i):jt.menuItemTemplate(s)}fetchData(t,e){this.isLoading=!0;const n=`${t}/system/menu/${e}/linkset`;fetch(n,{}).then((t=>{if(t.ok)return t.json();throw this.isLoading=!1,new Error(`Unable to fetch ${n}. ${t.status} ${t.statusText}`)})).then((t=>{try{const n=Ot(t,e);this.tree=n.tree}catch(n){throw new Error("Unable to denormalize menu.")}this.isLoading=!1}))}render(){return L`
<div class="gdwc-menu">
<slot name="brand"><h2>${this.branding}</h2></slot>
${this.isLoading?L`<slot name="loading">${this.loadingMessage}</slot>`:this.renderMenuLevel(this.tree)}
</div>
`}static openMenu(t){t.preventDefault();const{target:e}=t;"true"===e.getAttribute("aria-expanded")?(e.setAttribute("aria-expanded","false"),e.nextElementSibling.classList.remove("show")):(e.setAttribute("aria-expanded","true"),e.nextElementSibling.classList.add("show"))}}customElements.get("gdwc-menu")||customElements.define("gdwc-menu",jt);var Nt=Array.isArray,$t="object"==typeof et&&et&&et.Object===Object&&et,Mt="object"==typeof self&&self&&self.Object===Object&&self,Ut=$t||Mt||Function("return this")(),Vt=Ut.Symbol,Lt=Vt,Rt=Object.prototype,zt=Rt.hasOwnProperty,It=Rt.toString,Ft=Lt?Lt.toStringTag:void 0;var Wt=function(t){var e=zt.call(t,Ft),n=t[Ft];try{t[Ft]=void 0;var r=!0}catch(i){}var s=It.call(t);return r&&(e?t[Ft]=n:delete t[Ft]),s},qt=Object.prototype.toString;var Dt=Wt,Bt=function(t){return qt.call(t)},Ht=Vt?Vt.toStringTag:void 0;var Jt=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Ht&&Ht in Object(t)?Dt(t):Bt(t)};var Qt=Jt,Gt=function(t){return null!=t&&"object"==typeof t};var Kt=function(t){return"symbol"==typeof t||Gt(t)&&"[object Symbol]"==Qt(t)},Xt=Nt,Yt=Kt,Zt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,te=/^\w*$/;var ee=function(t,e){if(Xt(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!Yt(t))||(te.test(t)||!Zt.test(t)||null!=e&&t in Object(e))};var ne=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},re=Jt,se=ne;var ie,oe=function(t){if(!se(t))return!1;var e=re(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},ae=Ut["__core-js_shared__"],le=(ie=/[^.]+$/.exec(ae&&ae.keys&&ae.keys.IE_PROTO||""))?"Symbol(src)_1."+ie:"";var ce=function(t){return!!le&&le in t},ue=Function.prototype.toString;var he=oe,pe=ce,de=ne,fe=function(t){if(null!=t){try{return ue.call(t)}catch(e){}try{return t+""}catch(e){}}return""},me=/^\[object .+?Constructor\]$/,ye=Function.prototype,ve=Object.prototype,ge=ye.toString,_e=ve.hasOwnProperty,be=RegExp("^"+ge.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var we=function(t){return!(!de(t)||pe(t))&&(he(t)?be:me).test(fe(t))},Se=function(t,e){return null==t?void 0:t[e]};var xe=function(t,e){var n=Se(t,e);return we(n)?n:void 0},Pe=xe(Object,"create"),Te=Pe;var ke=function(){this.__data__=Te?Te(null):{},this.size=0};var Oe=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ce=Pe,Ae=Object.prototype.hasOwnProperty;var Ee=function(t){var e=this.__data__;if(Ce){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return Ae.call(e,t)?e[t]:void 0},je=Pe,Ne=Object.prototype.hasOwnProperty;var $e=Pe;var Me=ke,Ue=Oe,Ve=Ee,Le=function(t){var e=this.__data__;return je?void 0!==e[t]:Ne.call(e,t)},Re=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=$e&&void 0===e?"__lodash_hash_undefined__":e,this};function ze(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}ze.prototype.clear=Me,ze.prototype.delete=Ue,ze.prototype.get=Ve,ze.prototype.has=Le,ze.prototype.set=Re;var Ie=ze;var Fe=function(){this.__data__=[],this.size=0};var We=function(t,e){return t===e||t!=t&&e!=e};var qe=function(t,e){for(var n=t.length;n--;)if(We(t[n][0],e))return n;return-1},De=qe,Be=Array.prototype.splice;var He=qe;var Je=qe;var Qe=qe;var Ge=Fe,Ke=function(t){var e=this.__data__,n=De(e,t);return!(n<0)&&(n==e.length-1?e.pop():Be.call(e,n,1),--this.size,!0)},Xe=function(t){var e=this.__data__,n=He(e,t);return n<0?void 0:e[n][1]},Ye=function(t){return Je(this.__data__,t)>-1},Ze=function(t,e){var n=this.__data__,r=Qe(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};function tn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}tn.prototype.clear=Ge,tn.prototype.delete=Ke,tn.prototype.get=Xe,tn.prototype.has=Ye,tn.prototype.set=Ze;var en=tn,nn=xe(Ut,"Map"),rn=Ie,sn=en,on=nn;var an=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var ln=function(t,e){var n=t.__data__;return an(e)?n["string"==typeof e?"string":"hash"]:n.map},cn=ln;var un=ln;var hn=ln;var pn=ln;var dn=function(){this.size=0,this.__data__={hash:new rn,map:new(on||sn),string:new rn}},fn=function(t){var e=cn(this,t).delete(t);return this.size-=e?1:0,e},mn=function(t){return un(this,t).get(t)},yn=function(t){return hn(this,t).has(t)},vn=function(t,e){var n=pn(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function gn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}gn.prototype.clear=dn,gn.prototype.delete=fn,gn.prototype.get=mn,gn.prototype.has=yn,gn.prototype.set=vn;var _n=gn;function bn(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,s=e?e.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=t.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(bn.Cache||_n),n}bn.Cache=_n;var wn=bn;var Sn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xn=/\\(\\)?/g,Pn=function(t){var e=wn(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Sn,(function(t,n,r,s){e.push(r?s.replace(xn,"$1"):n||t)})),e}));var Tn=function(t,e){for(var n=-1,r=null==t?0:t.length,s=Array(r);++n<r;)s[n]=e(t[n],n,t);return s},kn=Nt,On=Kt,Cn=Vt?Vt.prototype:void 0,An=Cn?Cn.toString:void 0;var En=function t(e){if("string"==typeof e)return e;if(kn(e))return Tn(e,t)+"";if(On(e))return An?An.call(e):"";var n=e+"";return"0"==n&&1/e==-Infinity?"-0":n};var jn=Nt,Nn=ee,$n=Pn,Mn=function(t){return null==t?"":En(t)};var Un=Kt;var Vn=function(t,e){return jn(t)?t:Nn(t,e)?[t]:$n(Mn(t))},Ln=function(t){if("string"==typeof t||Un(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var Rn=function(t,e){for(var n=0,r=(e=Vn(e,t)).length;null!=t&&n<r;)t=t[Ln(e[n++])];return n&&n==r?t:void 0};var zn=function(t,e,n){var r=null==t?void 0:Rn(t,e);return void 0===r?n:r};async function In(t,e,n,r){await new Promise((t=>setTimeout(t,3e3)));const s=await fetch(`https://cdn.contentful.com/spaces/${n}/environments/${r}/entries/${t}?access_token=${e}`),i=await s.json();return i.fields.ContentType=zn(i,"sys.contentType.sys.id")?zn(i,"sys.contentType.sys.id"):"empty",i.fields}async function Fn(t,e,n,r){await new Promise((t=>setTimeout(t,3e3)));const s=await fetch(`https://cdn.contentful.com/spaces/${n}/environments/${r}/assets/${t}?access_token=${e}`),i=await s.json();return zn(i,"fields.file.url")}class Wn extends tt{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.content="",this.socialMediaCheckTwitter=!0}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},entryData:{type:Array},socialMediaCheckTwitter:{type:Boolean},blockQuote:{type:String}}}async firstUpdated(){this.entryData=await In(this.id,this.accessToken,this.space,this.environment)}script(){const t=document.createElement("script");return t.onload=this.onLoad.bind(this),!0===this.socialMediaCheckTwitter?t.src="https://platform.twitter.com/widgets.js":t.src="https://www.instagram.com/static/bundles/es6/EmbedSDK.js/58b07fec4121.js",t}onLoad(){!1===this.socialMediaCheckTwitter&&window.instgrm.Embeds.process()}updated(){}render(){"twitter"===zn(this.entryData,"ContentType")?(this.socialMediaCheckTwitter=!0,this.blockQuote=zn(this.entryData,"twitterBlockquote")):(this.socialMediaCheckTwitter=!1,this.blockQuote=zn(this.entryData,"instagramBlockquote"));const t=document.createElement("div");return t.innerHTML=this.blockQuote,L`
${t}
${this.script()}
`}createRenderRoot(){return this}}customElements.get("social-media")||customElements.define("social-media",Wn);class qn extends tt{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.content=""}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},description:{type:String},heading:{type:String},image:{type:Array}}}async firstUpdated(){const t=await In(this.id,this.accessToken,this.space,this.environment);this.description=zn(t,"description.content[0].content[0].value"),this.heading=zn(t,"heading"),this.imgId=zn(t,"image.sys.id"),this.image=await Fn(this.imgId,this.accessToken,this.space,this.environment)}updated(){}render(){return L`
<section class="card-component">
<div class="card-image">
<img src="${this.image}" alt="img"/>
</div>
<h2 class="section-title" >${this.heading}</h2>
<p class="card-desc">${this.description}</p>
</section>
`}}customElements.get("card-component")||customElements.define("card-component",qn);class Dn extends tt{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.image=[]}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},entryData:{type:Array},image:{type:Array}}}async firstUpdated(){const t=await In(this.id,this.accessToken,this.space,this.environment);this.image=await async function(t,e,n,r){return await Promise.all(t&&t.map((async t=>{const s=zn(t,"sys.id"),i=await Fn(s,e,n,r);return await new Promise((t=>setTimeout(t,3e3))),i})))}(zn(t,"image"),this.accessToken,this.space,this.environment)}script(){}onLoad(){}updated(){}render(){return L`
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
${this.image.map(((t,e)=>L`<li data-target="#myCarousel" data-slide-to=${e} class=${0===e?"active":""}></li>`))}
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
${this.image.map(((t,e)=>L`
<div class=${0===e?"item active":"item"}>
<img src=${t} alt="img">
</div>
`))}
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
`}createRenderRoot(){return this}}customElements.get("slider-component")||customElements.define("slider-component",Dn);class Bn extends tt{constructor(){super(),this.id="Somebody",this.accessToken="accessToken",this.space="space",this.environment="environment",this.image=[]}static get properties(){return{id:{type:String},accessToken:{type:String},space:{type:String},environment:{type:String},entryData:{type:Array},image:{type:Array}}}async firstUpdated(){let t=[];const e=await In(this.id,this.accessToken,this.space,this.environment),n=zn(e,"heromediaSlides"),r=await async function(t,e,n,r){return await Promise.all(t&&t.map((async t=>{const s=zn(t,"sys.id"),i={};i[s]=await In(s,e,n,r);const o=await Fn(zn(i[s],"image.sys.id"),e,n,r);return i[s].imageUrl=null!==o?o:"default.jpg",await new Promise((t=>setTimeout(t,3e3))),i})))}(n,this.accessToken,this.space,this.environment);r&&(t=r.map((t=>{const e=Object.values(t);return{image:e[0].imageUrl,title:e[0].title,short_title:e[0].shortTitle,subhead:e[0].subhead,summary:e[0].description.content[0]&&e[0].description.content[0].content[0].value,link_url:e[0].linkurl,link_text:e[0].linkText,text_position:e[0].textPosition,background_color:e[0].textBackgroundColor}}))),this.image=t}render(){return L`
<div id="heromedia" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" >
${this.image.map(((t,e)=>L`
<div class=${0===e?"item active":"item"}>
<div >
<div class="photo-panel">
<img src=${t.image} width="100%" height="" alt=""/>
</div>
<div class="photo-overlay ${t.text_position}" style="background-color:${t.background_color};">
<div class="photo_title">
<h1>${t.title}</h1>
</div>
<div class="photo_short_title">
<h4>${t.short_title}</h4>
</div>
<div class="photo_subhead">${t.subhead}</div>
<div class="photo_desc">
${t.summary}
</div>
${t.link_url?L`<div class="photo_btn_wrapper">
<a href=${t.link_url} class="rounded-0" tabindex="0">${t.link_text}</a>
</div>`:L``}
</div>
</div>
</div>
`))}
</div>
${this.image.length>1?L`<!-- Left and right controls -->
<a class="left carousel-control" href="#heromedia" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#heromedia" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
`:L``}
</div>
<style>
#heromedia .carousel-control {