{"version":3,"file":"compareImages-3f98fa07.js","sources":["../../../src/js/modules/compare-images.js"],"sourcesContent":["const template = document.createElement(\"template\");\n\n// Styling range input thumbs requires you to separately define the CSS rules\n// for different browsers. We store them once here for ease of maintenance.\nconst thumbStyles = `\n background-color: var(--thumb-background-color);\n background-image: var(--thumb-background-image);\n background-size: 90%;\n background-position: center center;\n background-repeat: no-repeat;\n border-radius: var(--thumb-radius);\n border: var(--thumb-border-size) var(--thumb-border-color) solid;\n color: var(--thumb-border-color);\n width: var(--thumb-size);\n height: var(--thumb-size);\n`;\n\nconst thumbFocusStyles = `\n box-shadow: 0px 0px 0px var(--focus-width) var(--focus-color);\n`;\n\nconst thumbSvgWidth = 4;\n\n// Since the code below is a template string literal, it will not be minified or\n// transpiled\ntemplate.innerHTML = /*html*/`\n \n\n \n \n\n \n`;\n\n/**\n * Our ImageCompare web component class\n *\n * @attr {string} label-text - Provide additional context to screen reader users.\n *\n * @slot image-1 - Your first image. Will appear on the \"left\"\n * @slot image-2 - Your second image. Will appear on the \"right\"\n *\n * @cssprop --thumb-background-color - The background color of the range slider handle.\n * @cssprop --thumb-background-image - The background image of the range slider handle.\n * @cssprop --thumb-size - The size of the range slider handle.\n * @cssprop --thumb-radius - The border-radius of the range slider handle.\n * @cssprop --thumb-border-color - The color of the range slider handle border.\n * @cssprop --thumb-border-size - The width of the range slider handle border.\n *\n * @ccprop --focus-width - The width of the range slider handle's focus outline.\n * @ccprop --focus-color - The color of the range slider handle's focus outline.\n *\n * @ccprop --divider-width - The width of the divider shown between the two images.\n * @ccprop --divider-color - The color of the divider shown between the two images.\n */\nclass ImageCompare extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: \"open\" });\n }\n\n connectedCallback() {\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n\n ['input', 'change'].forEach((eventName) => {\n this.shadowRoot.querySelector(\"input\").addEventListener(\n eventName,\n ({ target }) => {\n if (this.animationFrame) cancelAnimationFrame(this.animationFrame);\n\n this.animationFrame = requestAnimationFrame(() => {\n this.shadowRoot.host.style.setProperty('--exposure', `${target.value}%`)\n });\n },\n );\n });\n\n const customLabel = this.shadowRoot.host.getAttribute('label-text');\n if(customLabel) {\n this.shadowRoot.querySelector(\".js-label-text\").textContent = customLabel;\n }\n }\n}\n\ncustomElements.define(\"image-compare\", ImageCompare);\n"],"names":["template","thumbStyles","thumbFocusStyles","thumbSvgWidth","ImageCompare","eventName","target","customLabel"],"mappings":"AAAA,MAAMA,EAAW,SAAS,cAAc,UAAU,EAI5CC,EAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAadC,EAAmB;AAAA;AAAA,EAInBC,EAAgB,EAItBH,EAAS,UAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wPAM2NG,CAAa,oIAAoIA,CAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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