{
  "version": 3,
  "sources": ["/cdn/shop/t/6/assets/kloth-hero-video.js?hero-video-support=e4f47d8"],
  "sourcesContent": ["if (!customElements.get('kloth-hero-video')) {\n  customElements.define('kloth-hero-video', class extends HTMLElement {\n    connectedCallback() {\n      if (this.events) return;\n      this.events = new AbortController();\n      if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', () => this.initialize(), { once: true, signal: this.events.signal });\n      } else {\n        this.initialize();\n      }\n    }\n\n    initialize() {\n      this.video = this.querySelector('video');\n      this.hero = this.closest('.kloth-hero');\n      this.button = this.hero?.querySelector('.kloth-hero__video-toggle');\n      if (!this.video || !this.button) return;\n      let config;\n      try {\n        config = JSON.parse(this.querySelector('[data-hero-video-config]').textContent);\n      } catch {\n        return;\n      }\n      this.sources = {};\n      for (const key of ['desktop', 'mobile']) {\n        this.sources[key] = (config[key] || []).filter(source =>\n          source.url && (source.format === 'mp4' || source.mime_type === 'video/mp4') &&\n          this.video.canPlayType(source.mime_type || 'video/mp4')\n        ).sort((a, b) => (a.width || 0) - (b.width || 0));\n      }\n      this.breakpoint = matchMedia('(max-width: 749px)');\n      this.reducedMotion = matchMedia('(prefers-reduced-motion: reduce)');\n      this.connection = navigator.connection;\n      this.userPaused ??= false;\n      this.userStarted ??= false;\n      this.loaded = false;\n      this.pending = false;\n      this.attempt = (this.attempt || 0) + 1;\n      this.source = null;\n      this.pageActive = true;\n      this.classList.remove('is-ready');\n      const rect = this.hero.getBoundingClientRect();\n      this.visible = rect.bottom > 0 && rect.top < innerHeight;\n      this.video.muted = true;\n      this.video.defaultMuted = true;\n      const options = { signal: this.events.signal };\n      this.button.addEventListener('click', () => {\n        if (!this.video.paused) {\n          this.userPaused = true;\n        } else {\n          this.userPaused = false;\n          this.userStarted = true;\n          if (this.failed) this.loaded = false;\n          this.failed = false;\n        }\n        this.sync();\n      }, options);\n      this.video.addEventListener('playing', () => {\n        if (!this.shouldPlay()) {\n          this.video.pause();\n          return;\n        }\n        this.classList.add('is-ready');\n        this.updateButton();\n      }, options);\n      this.video.addEventListener('pause', () => this.updateButton(), options);\n      this.video.addEventListener('play', () => this.updateButton(), options);\n      this.video.addEventListener('error', () => {\n        if (!this.loaded) return;\n        this.failed = true;\n        this.video.pause();\n        this.classList.remove('is-ready');\n        this.updateButton();\n      }, options);\n      this.breakpoint.addEventListener('change', () => this.selectSource(), options);\n      this.reducedMotion.addEventListener('change', () => {\n        if (this.reducedMotion.matches) this.userStarted = false;\n        this.sync();\n      }, options);\n      this.connection?.addEventListener('change', () => this.sync(), options);\n      document.addEventListener('visibilitychange', () => this.sync(), options);\n      window.addEventListener('pagehide', () => { this.pageActive = false; this.sync(); }, options);\n      window.addEventListener('pageshow', () => { this.pageActive = true; this.sync(); }, options);\n      if ('IntersectionObserver' in window) {\n        this.observer = new IntersectionObserver(entries => {\n          this.visible = entries[0].isIntersecting;\n          this.sync();\n        });\n        this.observer.observe(this.hero);\n      }\n      this.selectSource();\n    }\n\n    selectSource() {\n      const sources = this.breakpoint.matches && this.sources.mobile.length\n        ? this.sources.mobile : this.sources.desktop;\n      const width = Math.min(this.getBoundingClientRect().width * Math.min(devicePixelRatio || 1, 1.5), 1920);\n      const source = sources.find(item => item.width >= width) || sources.at(-1);\n      const url = source?.url || '';\n      if (this.source === url) return;\n      this.attempt += 1;\n      this.pending = false;\n      this.loaded = false;\n      this.failed = false;\n      this.source = url;\n      this.video.pause();\n      this.video.removeAttribute('src');\n      this.video.load();\n      this.classList.remove('is-ready');\n      this.button.hidden = !url;\n      this.sync();\n    }\n\n    shouldPlay() {\n      const autoplay = this.dataset.autoplay === 'true' && !this.reducedMotion.matches && !this.connection?.saveData;\n      return Boolean(this.isConnected && this.pageActive && this.source && !this.failed && !this.userPaused &&\n        (this.userStarted || autoplay) && this.visible && !document.hidden);\n    }\n\n    sync() {\n      if (!this.shouldPlay()) {\n        if (this.pending) { this.attempt += 1; this.pending = false; }\n        this.video.pause();\n        this.updateButton();\n        return;\n      }\n      if (!this.loaded) {\n        this.video.src = this.source;\n        this.video.load();\n        this.loaded = true;\n      }\n      if (!this.video.paused || this.pending) return;\n      const attempt = ++this.attempt;\n      this.pending = true;\n      Promise.resolve(this.video.play()).catch(() => {\n        if (attempt !== this.attempt || !this.shouldPlay()) return;\n        this.userPaused = true;\n        this.video.pause();\n        this.updateButton();\n      }).finally(() => {\n        if (attempt === this.attempt) this.pending = false;\n      });\n    }\n\n    updateButton() {\n      const playing = !this.video.paused;\n      const label = playing ? this.button.dataset.pauseLabel : this.button.dataset.playLabel;\n      this.button.dataset.playing = String(playing);\n      this.button.setAttribute('aria-label', label);\n      this.button.querySelector('[data-hero-video-label]').textContent = label;\n    }\n\n    disconnectedCallback() {\n      this.attempt += 1;\n      this.events?.abort();\n      this.events = null;\n      this.observer?.disconnect();\n      if (this.video) {\n        this.video.pause();\n        this.video.removeAttribute('src');\n        this.video.load();\n      }\n    }\n  });\n}\n"],
  "mappings": "AAAK,eAAe,IAAI,kBAAkB,GACxC,eAAe,OAAO,mBAAoB,cAAc,WAAY,CAClE,mBAAoB,CACd,KAAK,SACT,KAAK,OAAS,IAAI,gBACd,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoB,IAAM,KAAK,WAAW,EAAG,CAAE,KAAM,GAAM,OAAQ,KAAK,OAAO,MAAO,CAAC,EAEjH,KAAK,WAAW,EAEpB,CAEA,YAAa,CAIX,GAHA,KAAK,MAAQ,KAAK,cAAc,OAAO,EACvC,KAAK,KAAO,KAAK,QAAQ,aAAa,EACtC,KAAK,OAAS,KAAK,MAAM,cAAc,2BAA2B,EAC9D,CAAC,KAAK,OAAS,CAAC,KAAK,OAAQ,OACjC,IAAI,OACJ,GAAI,CACF,OAAS,KAAK,MAAM,KAAK,cAAc,0BAA0B,EAAE,WAAW,CAChF,MAAQ,CACN,MACF,CACA,KAAK,QAAU,CAAC,EAChB,UAAW,MAAO,CAAC,UAAW,QAAQ,EACpC,KAAK,QAAQ,GAAG,GAAK,OAAO,GAAG,GAAK,CAAC,G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