{"version":3,"file":"product-top-badge-section-xxxxxxxxxxxxxxxxxxxx.min.js","mappings":"yBAQA,MAAMA,wBAAwBC,YAC5B,6BAAkBC,GAChB,MAAO,CACL,aAEJ,CAeO,iBAAAC,GACLC,KAAKC,uBACLD,KAAKE,QACP,CAEQ,oBAAAD,GACDD,KAAKG,aACRH,KAAKI,aAAa,CAAEC,KAAM,SAC1BL,KAAKG,WAAWG,UAAY,geAEhC,CAEO,wBAAAC,CAAyBC,EAAeC,EAAkBC,GAC/DV,KAAKC,uBAEDD,KAAKW,aAAeF,IAAaC,GACnCV,KAAKE,QAET,CAEQ,MAAAA,GACQF,KAAKG,WAAWS,cAAc,UACtCC,YAAcb,KAAKc,QAAQC,OAAS,EAC5C,EASGC,eAAeC,IAAI,sBACtBD,eAAeE,OAAO,oBAAqBtB","sources":["webpack://lange/./scripts/sections/product-top-badge/product-top-badge/index.ts"],"sourcesContent":["import { CustomElement } from '@integrabeauty/custom-elements';\nimport html from './index.html';\nimport styles from './index.scss';\n\n/**\n * A custom element that displays a badge on the top of the product image on PDP or in product card\n * on PLP.\n */\nclass ProductTopBadge extends HTMLElement implements CustomElement {\n  public static get observedAttributes() {\n    return [\n      'data-value'\n    ];\n  }\n\n  declare readonly dataset: {\n    /**\n     * Defines the style variant for the component, 'highlighted' is supported, any other value is\n     * treated as 'default'.\n     */\n    style: string;\n\n    /**\n     * The text value to be displayed inside the badge\n     */\n    value: string;\n  };\n\n  public connectedCallback() {\n    this.initializeShadowRoot();\n    this.render();\n  }\n\n  private initializeShadowRoot() {\n    if (!this.shadowRoot) {\n      this.attachShadow({ mode: 'open' });\n      this.shadowRoot.innerHTML = `<style>${styles}</style>${html}`;\n    }\n  }\n\n  public attributeChangedCallback(_name: string, oldValue: string, newValue: string) {\n    this.initializeShadowRoot();\n\n    if (this.isConnected && oldValue !== newValue) {\n      this.render();\n    }\n  }\n\n  private render() {\n    const badge = this.shadowRoot.querySelector('.badge');\n    badge.textContent = this.dataset.value || '';\n  }\n}\n\ndeclare global {\n  interface HTMLElementTagNameMap {\n    'product-top-badge': ProductTopBadge;\n  }\n}\n\nif (!customElements.get('product-top-badge')) {\n  customElements.define('product-top-badge', ProductTopBadge);\n}\n"],"names":["ProductTopBadge","HTMLElement","observedAttributes","connectedCallback","this","initializeShadowRoot","render","shadowRoot","attachShadow","mode","innerHTML","attributeChangedCallback","_name","oldValue","newValue","isConnected","querySelector","textContent","dataset","value","customElements","get","define"],"sourceRoot":""}