{"version":3,"file":"view-script.min.js","sources":["../../../../assets/js/base/_throttle.js","../../../../assets/js/modules/_fit-html-text.js","../../../../block-editor/blocks/statistic/view-script.js"],"sourcesContent":["export default function (fn, time = 50) {\n\tlet timer = null;\n\n\tfunction throttledFn(...args) {\n\t\tif (!timer) {\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\tfn(...args);\n\t\t\t\ttimer = null;\n\t\t\t}, time)\n\t\t}\n\t}\n\n\tthrottledFn.cancel = () => {\n\t\tclearTimeout(timer);\n\t\ttimer = null;\n\t}\n\n\treturn throttledFn;\n}\n","import throttle from '../base/_throttle.js';\n\nexport function calcFontSize( node, min, max ) {\n\n\tconst computedStyle = getComputedStyle( node );\n\tconst parentComputedStyle = getComputedStyle( node.parentNode );\n\tconst parentWidth = node.parentNode.clientWidth - parseFloat( parentComputedStyle.paddingLeft ) - parseFloat( parentComputedStyle.paddingRight );\n\tconst scrollWidth = node.scrollWidth;\n\tconst currentFontSize = parseFloat( computedStyle.fontSize );\n\tconst calcFontSize = Math.floor( ( parentWidth / scrollWidth ) * currentFontSize );\n\n\t// let fontSize = parentWidth == scrollWidth ? 100 : calcFontSize;\n\tlet fontSize = calcFontSize;\n\n\tif ( min && ! isNaN( Number( min ) ) ) {\n\t\tfontSize = Math.max( Number( min ), fontSize );\n\t}\n\tif ( max && ! isNaN( Number( max ) ) ) {\n\t\tfontSize = Math.min( Number( max ), fontSize );\n\t}\n\treturn fontSize;\n}\n\nexport class FitHtmlTextController {\n\tconstructor( opts = {} ) {\n\t\tthis.opts = {\n\t\t\tthrottle: 10,\n\t\t\tobserver: {\n\t\t\t\tcharacterData: true,\n\t\t\t\tsubtree: true,\n\t\t\t\tchildList: true,\n\t\t\t},\n\t\t\t...opts\n\t\t};\n\n\t\tthis.observed = [];\n\t\tthis.observer = new MutationObserver( this.resize.bind( this ) );\n\t\twindow.addEventListener( 'load', throttle( this.resize.bind(this), this.opts.throttle ) );\n\t\twindow.addEventListener( 'resize', throttle( this.resize.bind(this), this.opts.throttle ) );\n\t}\n\n\tresize() {\n\t\tthis.observed.forEach( observed => observed.resize() );\n\t}\n\n\tadd( nodes, opts = {} ) {\n\t\tif ( ! Array.isArray( nodes ) ) {\n\t\t\tif ( nodes instanceof HTMLElement ) {\n\t\t\t\tnodes = [ nodes ];\n\t\t\t} else if ( nodes instanceof NodeList ) {\n\t\t\t\tnodes = Array.from( nodes );\n\t\t\t} else if ( typeof nodes === 'string' ) {\n\t\t\t\tnodes = Array.from( document.querySelectorAll( nodes ) );\n\t\t\t} else {\n\t\t\t\tthrow new Error( 'Invalid FitHtmlText Nodes', nodes );\n\t\t\t}\n\t\t}\n\n\t\treturn nodes.filter( node => node instanceof HTMLElement && ! node.dataset.fitted ).map( n => {\n\t\t\tconst fitHtmlText = new FitHtmlText( n, opts );\n\n\t\t\tthis.observer.observe( fitHtmlText.node, this.opts.observer );\n\t\t\tthis.observed.push( fitHtmlText );\n\n\t\t\treturn fitHtmlText;\n\t\t} );\n\n\t}\n\n\tremove( node ) {\n\t\tconst unobserved = this.observed.filter( n => n.node === node );\n\n\t\tunobserved.forEach( n => n.reset() );\n\n\t\tthis.observed = this.observed.filter( n => ! unobserved.includes( n.node ) );\n\t}\n}\n\nexport class FitHtmlText {\n\tconstructor( node, opts = {} ) {\n\t\tthis.node = node;\n\t\tthis.opts = {\n\t\t\tmin: this.node.dataset.minFontSize || 16,\n\t\t\tmax: this.node.dataset.maxFontSize || 512,\n\t\t\tfittedClass: false,\n\t\t\t...opts\n\t\t};\n\n\t\tthis.node.style.display = 'inline-block';\n\t\tthis.node.style.maxWidth = 'none';\n\t\tthis.node.style.width = 'none';\n\t\tthis.node.dataset.fitted = true;\n\t\tthis.node.classList.add(this.opts.fittedClass);\n\n\n\t\tsetTimeout( this.resize.bind(this), 0 );\n\t}\n\n\tresize() {\n\n\n\t\trequestAnimationFrame( () => {\n\t\t\tconst fontSize = calcFontSize( this.node, this.opts.min, this.opts.max );\n\t\t\tthis.node.style.fontSize = `${ fontSize }px`;\n\t\t\tthis.node.style.whiteSpace = fontSize === this.opts.min ? 'normal' : 'nowrap';\n\n\t\t} );\n\t}\n\n\treset() {\n\t\tthis.node.style.display = '';\n\t\tthis.node.style.fontSize = '';\n\t\tthis.node.style.maxWidth = '';\n\t\tthis.node.style.width = '';\n\t\tthis.node.style.whiteSpace = '';\n\n\t\tdelete this.node.dataset.filled;\n\t}\n}\n\nexport function fitHtmlText( node, opts = {} ) {\n\tif ( ! FitHtmlTextController.instance ) {\n\t\tFitHtmlTextController.instance = new FitHtmlTextController();\n\t}\n\n\tFitHtmlTextController.instance.add( node, opts );\n\n\treturn FitHtmlTextController.instance;\n}\n","\nimport { fitHtmlText } from '../../../assets/js/modules/_fit-html-text';\n\nlet interval = false;\nconst offset = 10;\nlet prevScrollLeft = 0;\n\nfunction ready() {\n\tdocument.querySelectorAll('.stats-slide-activated').forEach( (node) => {\n\n\t\tconst controls = {\n\t\t\tprev: node.querySelector('.stats-nav > .prev-slide'),\n\t\t\tnext: node.querySelector('.stats-nav > .next-slide'),\n\t\t\tlist: node.querySelector('.statistics__items'),\n\t\t\tlistPadding: 75,\n\t\t\tparent: node,\n\t\t\tnavActive: 'stats-nav--active',\n\t\t\tnavs: node.querySelectorAll('.stats-nav button'),\n\t\t};\n\n\t\t// controls.prev.addEventListener('click', () => backskip(controls));\n\t\t// controls.next.addEventListener('click', () => skip(controls));\n\t\tcontrols.prev.addEventListener('touchstart', () => reverse( controls));\n\t\tcontrols.prev.addEventListener('touchend', () => stop(controls));\n\t\tcontrols.prev.addEventListener('touchcancel', () => stop(controls));\n\t\tcontrols.next.addEventListener('touchstart', () => forward(controls));\n\t\tcontrols.next.addEventListener('touchend', () => stop(controls));\n\t\tcontrols.next.addEventListener('touchcancel', () => stop(controls));\n\n\t\tcontrols.prev.addEventListener('mousedown', () => reverse(controls));\n \t\tcontrols.prev.addEventListener('mouseup', () => stop(controls));\n\t\tcontrols.next.addEventListener('mousedown', () => forward(controls));\n \t\tcontrols.next.addEventListener('mouseup', () => stop(controls));\n\n\t\tmaybeDisable(controls);\n\t\tmaybeHideNav(controls);\n\t\taddEventListener('resize', () => maybeHideNav(controls));\n \t});\n}\n\nconst reverse = ( controls ) => {\n\tstop(controls);\n\tconst { list } = controls;\n\n\tinterval = setInterval( () => {\n\t\tlist.scrollLeft -= 10;\n\t}, 8);\n\tmaybeDisable(controls);\n}\n\nconst forward = ( controls ) => {\n\tconst { list } = controls;\n\n\tinterval = setInterval( () => {\n\t\tlist.scrollLeft += 10;\n\t}, 8);\n\n\tmaybeDisable(controls);\n}\n\nconst stop = (controls) => {\n\tif (interval) {\n\t\tclearInterval( interval );\n\t}\n\tmaybeDisable(controls);\n}\n\nconst maybeHideNav = (controls) => {\n\tconst { listPadding, list, parent, navs } = controls;\n\tlet widthOfChildren = 0;\n\n\tlet wideWidthStr = getComputedStyle(document.documentElement).getPropertyValue('--wdg-wide-width');\n\tlet widePx;\n\n\tif (wideWidthStr) {\n\t\t// dissect clamp\n\t\tif (wideWidthStr.includes('clamp')) {\n\t\t\twideWidthStr = wideWidthStr.split(', ').map((str) => str.match(/[.0-9]/g).join(''));\n\t\t\twidePx = wideWidthStr[1] * 0.01 * window.innerWidth;\n\n\t\t\tif (widePx > wideWidthStr[2]) {\n\t\t\t\twidePx = wideWidthStr[2];\n\t\t\t}\n\t\t\tif (widePx > parent.offsetWidth) {\n\t\t\t\twidePx = parent.offsetWidth;\n\t\t\t}\n\t\t}\n\n\t} else {\n\t\twidePx = parent.offsetWidth;\n\t}\n\n\t[...list.children].forEach((li) => {\n\t\twidthOfChildren += li.offsetWidth;\n\t});\n\n\tif (widthOfChildren > widePx ) {\n\t\t[ ...navs].forEach((nav) => nav.classList.add(controls.navActive));\n\t} else {\n\t\t[ ...navs].forEach((nav) => nav.classList.remove(controls.navActive));\n\t}\n}\n\nconst maybeDisable = (controls) => {\n\tconst { list, next, prev } = controls;\n\tconst { scrollLeft } = list;\n\n\tconst maxScrollLeft = list.scrollWidth - list.clientWidth;\n\n\tif ((maxScrollLeft - scrollLeft ) < 150) {\n\t\tnext.disabled = true;\n\t}\n\n\t// reached beginning of list\n\tif ( list.scrollLeft <= 30 ) {\n\t\tprev.disabled = true;\n\t\tnext.disabled = false;\n\t} else {\n\t\tprev.disabled = false;\n\t}\n}\n\ndocument.addEventListener( 'DOMContentLoaded', () => {\n \tdocument.querySelectorAll( '.statistics__stat--auto-font-size' ).forEach( (el) => {\n\t\tfitHtmlText(el, { fittedClass: 'statistics__stat--auto-font-size--fitted' });\n\t});\n\n\tdocument.querySelectorAll( '.statistics' ).forEach( (stat) => {\n\t\tconst item = stat.getElementsByClassName('statistics__items');\n\t\tconst length = item[0].children.length\n\t\tif (length <= 4) {\n\t\t\treturn;\n\t\t}\n\t\tstat.classList.add('stats-slide-activated');\n\t\tstat.insertAdjacentHTML(\n\t\t\t'beforeend',\n\t\t\t`