import{LitElement as t,html as e,css as a}from"../../lit/index.js";class TwitterEmbed extends t{static get tag(){return"twitter-embed"}constructor(){super(),this.lang=globalThis.document.body.getAttribute("xml:lang")||globalThis.document.body.getAttribute("lang")||globalThis.document.documentElement.getAttribute("xml:lang")||globalThis.document.documentElement.getAttribute("lang")||globalThis.navigator.language||"en",this.dataWidth="550px",this.dataTheme="light",this.tweet=null,this.tweetId=null,this.allowPopups="allow-popups"}static get properties(){return{tweet:{type:String},_haxstate:{type:Boolean},lang:{type:String},dataWidth:{type:String,attribute:"data-width"},dataTheme:{type:String,attribute:"data-theme"},tweetId:{type:String,attribute:"tweet-id"},noPopups:{type:Boolean,attribute:"no-popups"},allowPopups:{type:String}}}static get haxProperties(){return new URL(`./lib/${this.tag}.haxProperties.json`,import.meta.url).href}haxHooks(){return{gizmoRegistration:"haxgizmoRegistration",editModeChanged:"haxeditModeChanged",activeElementChanged:"haxactiveElementChanged"}}haxgizmoRegistration(t){globalThis.dispatchEvent(new CustomEvent("i18n-manager-register-element",{detail:{namespace:"twitter-embed.haxProperties",localesPath:new URL("./locales/twitter-embed.haxProperties.es.json",import.meta.url).href+"/../",locales:["es"]}}))}haxactiveElementChanged(t,e){e&&(this._haxstate=e)}haxeditModeChanged(t){this._haxstate=t}_clickPrevent(t){this._haxstate&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())}updated(t){t.forEach(((t,e)=>{"noPopups"===e&&(this[e]?this.allowPopups="":this.allowPopups="allow-popups"),"tweet"===e&&this[e]&&(this[e].includes("twitter.com")||this[e].includes("x.com"))&&(this.tweetId=this[e].split("/").pop())}))}render(){return e`
      <div
        @click="${this._clickPrevent}"
        class="twitter-tweet twitter-tweet-rendered"
        style="display: flex; max-width: ${this.dataWidth}; width: 100%; margin-top: 10px; margin-bottom: 10px; pointer-events:${this._haxstate?"none":"inherit"}"
      >
        <iframe
          .sandbox="allow-same-origin allow-scripts ${this.allowPopups}"
          scrolling="no"
          frameborder="0"
          loading="lazy"
          allowtransparency="true"
          allow="autoplay; encrypted-media; fullscreen"
          style="position: static; visibility: visible; width: ${this.dataWidth}; height: 498px; display: block; flex-grow: 1;"
          title="Twitter Tweet"
          src="https://platform.x.com/embed/index.html?dnt=true&amp;frame=false&amp;hideCard=false&amp;hideThread=false&amp;id=${this.tweetId}&amp;lang=${this.lang}&amp;theme=${this.dataTheme}&amp;widgetsVersion=223fc1c4%3A1596143124634&amp;width=${this.dataWidth}"
          data-tweet-id="${this.tweetId}"
        >
        </iframe>
      </div>
    `}}customElements.define(TwitterEmbed.tag,TwitterEmbed);export{TwitterEmbed};