/**
 * Copyright 2020 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
class MoarSarcasm extends HTMLElement{static get tag(){return"moar-sarcasm"}static get haxProperties(){return new URL(`./lib/${this.tag}.haxProperties.json`,import.meta.url).href}constructor(){super(),this.template=globalThis.document.createElement("template"),this.attachShadow({mode:"open"}),this.render(),this.observer=new MutationObserver((t=>{t.forEach((t=>{this.say=this.innerText}))})),this.observer.observe(this,{characterData:!0,attributes:!1,childList:!0,subtree:!0})}get html(){return`\n      <style>\n        :host {\n          display: inline-block;\n          word-break: break-all;\n        }\n        span {\n          font-style: italic;\n        }\n        .letter:nth-child(odd) {\n          text-transform: uppercase;\n        }\n        .letter:nth-child(even) {\n          text-transform: lowercase;\n        }\n        .slot {\n          position: absolute!important;\n          width: 1px!important;\n          height: 1px!important;\n          padding: 0!important;\n          margin: -1px!important;\n          overflow: hidden!important;\n          clip: rect(0,0,0,0)!important;\n          white-space: nowrap!important;\n          border: 0!important;\n        }\n      </style>\n      <span class="sarcastic" aria-hidden="true"></span>\n      <span class="slot">${this.a11y}<slot></slot></span>\n    `}connectedCallback(){globalThis.ShadyCSS&&globalThis.ShadyCSS.styleElement(this),this.a11y="the following is sarcastic:",this.say=this.innerText}render(){this.shadowRoot&&(this.shadowRoot.innerHTML=null),this.template&&(this.template.innerHTML=this.html),globalThis.ShadyCSS&&this.template&&globalThis.ShadyCSS.prepareTemplate(this.template,this.tag),this.shadowRoot&&this.template&&this.shadowRoot.appendChild(this.template.content.cloneNode(!0))}processText(t){this.shadowRoot.querySelector(".sarcastic").innerHTML="";for(var e=0;e<t.length;e++){let a=globalThis.document.createElement("span");t.charAt(e).match(/[a-z]/i)?(a.classList.add("letter"),a.innerText=t.charAt(e)):a=globalThis.document.createTextNode(t.charAt(e)),this.shadowRoot.querySelector(".sarcastic").appendChild(a)}}static get observedAttributes(){return["say","a11y"]}set say(t){t!==this.innerText?this.innerText=t:this.setAttribute("say",t)}set a11y(t){this.setAttribute("a11y",t)}get say(){return this.getAttribute("say")}get a11y(){return this.getAttribute("a11y")}attributeChangedCallback(t,e,a){if(a)switch(t){case"say":this.processText(a);break;case"a11y":this.render()}}}customElements.define(MoarSarcasm.tag,MoarSarcasm);export{MoarSarcasm};