{"version":3,"file":"main-legacy.626e7de4.js","sources":["../../node_modules/picturefill/dist/picturefill.js","../../node_modules/object-fit-images/dist/ofi.common-js.js","../../src/_js/app/config.js","../../src/_js/app/masthead.js","../../src/_js/app/megamenu.js","../../src/_js/app/cookie.js","../../src/_js/app/accordeon.js","../../src/_js/app/maps.js","../../src/_js/app/alert.js","../../src/_js/app/forms.js","../../node_modules/ev-emitter/ev-emitter.js","../../node_modules/get-size/get-size.js","../../node_modules/desandro-matches-selector/matches-selector.js","../../node_modules/fizzy-ui-utils/utils.js","../../node_modules/flickity/js/cell.js","../../node_modules/flickity/js/slide.js","../../node_modules/flickity/js/animate.js","../../node_modules/flickity/js/flickity.js","../../node_modules/unipointer/unipointer.js","../../node_modules/unidragger/unidragger.js","../../node_modules/flickity/js/drag.js","../../node_modules/flickity/js/prev-next-button.js","../../node_modules/flickity/js/page-dots.js","../../node_modules/flickity/js/player.js","../../node_modules/flickity/js/add-remove-cell.js","../../node_modules/flickity/js/lazyload.js","../../node_modules/flickity/js/index.js","../../src/_js/app/carousel.js","../../src/_js/lib/debounce.js","../../node_modules/waypoints/lib/noframework.waypoints.js","../../src/_js/app/scroll.js","../../src/_js/app/video.js","../../src/_js/app/nav.filter.js","../../src/_js/app/shadow.overlay.js","../../src/_js/app/foldout.js","../../src/_js/utilties/index.js","../../src/_js/app/autocomplete.js"],"sourcesContent":["/*! picturefill - v3.0.2 - 2016-02-12\n * https://scottjehl.github.io/picturefill/\n * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT\n */\n/*! Gecko-Picture - v1.0\n * https://github.com/scottjehl/picturefill/tree/3.0/src/plugins/gecko-picture\n * Firefox's early picture implementation (prior to FF41) is static and does\n * not react to viewport changes. This tiny module fixes this.\n */\n(function(window) {\n\t/*jshint eqnull:true */\n\tvar ua = navigator.userAgent;\n\n\tif ( window.HTMLPictureElement && ((/ecko/).test(ua) && ua.match(/rv\\:(\\d+)/) && RegExp.$1 < 45) ) {\n\t\taddEventListener(\"resize\", (function() {\n\t\t\tvar timer;\n\n\t\t\tvar dummySrc = document.createElement(\"source\");\n\n\t\t\tvar fixRespimg = function(img) {\n\t\t\t\tvar source, sizes;\n\t\t\t\tvar picture = img.parentNode;\n\n\t\t\t\tif (picture.nodeName.toUpperCase() === \"PICTURE\") {\n\t\t\t\t\tsource = dummySrc.cloneNode();\n\n\t\t\t\t\tpicture.insertBefore(source, picture.firstElementChild);\n\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\tpicture.removeChild(source);\n\t\t\t\t\t});\n\t\t\t\t} else if (!img._pfLastSize || img.offsetWidth > img._pfLastSize) {\n\t\t\t\t\timg._pfLastSize = img.offsetWidth;\n\t\t\t\t\tsizes = img.sizes;\n\t\t\t\t\timg.sizes += \",100vw\";\n\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\timg.sizes = sizes;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tvar findPictureImgs = function() {\n\t\t\t\tvar i;\n\t\t\t\tvar imgs = document.querySelectorAll(\"picture > img, img[srcset][sizes]\");\n\t\t\t\tfor (i = 0; i < imgs.length; i++) {\n\t\t\t\t\tfixRespimg(imgs[i]);\n\t\t\t\t}\n\t\t\t};\n\t\t\tvar onResize = function() {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\ttimer = setTimeout(findPictureImgs, 99);\n\t\t\t};\n\t\t\tvar mq = window.matchMedia && matchMedia(\"(orientation: landscape)\");\n\t\t\tvar init = function() {\n\t\t\t\tonResize();\n\n\t\t\t\tif (mq && mq.addListener) {\n\t\t\t\t\tmq.addListener(onResize);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdummySrc.srcset = \"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\";\n\n\t\t\tif (/^[c|i]|d$/.test(document.readyState || \"\")) {\n\t\t\t\tinit();\n\t\t\t} else {\n\t\t\t\tdocument.addEventListener(\"DOMContentLoaded\", init);\n\t\t\t}\n\n\t\t\treturn onResize;\n\t\t})());\n\t}\n})(window);\n\n/*! Picturefill - v3.0.2\n * http://scottjehl.github.io/picturefill\n * Copyright (c) 2015 https://github.com/scottjehl/picturefill/blob/master/Authors.txt;\n * License: MIT\n */\n\n(function( window, document, undefined ) {\n\t// Enable strict mode\n\t\"use strict\";\n\n\t// HTML shim|v it for old IE (IE9 will still need the HTML video tag workaround)\n\tdocument.createElement( \"picture\" );\n\n\tvar warn, eminpx, alwaysCheckWDescriptor, evalId;\n\t// local object for method references and testing exposure\n\tvar pf = {};\n\tvar isSupportTestReady = false;\n\tvar noop = function() {};\n\tvar image = document.createElement( \"img\" );\n\tvar getImgAttr = image.getAttribute;\n\tvar setImgAttr = image.setAttribute;\n\tvar removeImgAttr = image.removeAttribute;\n\tvar docElem = document.documentElement;\n\tvar types = {};\n\tvar cfg = {\n\t\t//resource selection:\n\t\talgorithm: \"\"\n\t};\n\tvar srcAttr = \"data-pfsrc\";\n\tvar srcsetAttr = srcAttr + \"set\";\n\t// ua sniffing is done for undetectable img loading features,\n\t// to do some non crucial perf optimizations\n\tvar ua = navigator.userAgent;\n\tvar supportAbort = (/rident/).test(ua) || ((/ecko/).test(ua) && ua.match(/rv\\:(\\d+)/) && RegExp.$1 > 35 );\n\tvar curSrcProp = \"currentSrc\";\n\tvar regWDesc = /\\s+\\+?\\d+(e\\d+)?w/;\n\tvar regSize = /(\\([^)]+\\))?\\s*(.+)/;\n\tvar setOptions = window.picturefillCFG;\n\t/**\n\t * Shortcut property for https://w3c.github.io/webappsec/specs/mixedcontent/#restricts-mixed-content ( for easy overriding in tests )\n\t */\n\t// baseStyle also used by getEmValue (i.e.: width: 1em is important)\n\tvar baseStyle = \"position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)\";\n\tvar fsCss = \"font-size:100%!important;\";\n\tvar isVwDirty = true;\n\n\tvar cssCache = {};\n\tvar sizeLengthCache = {};\n\tvar DPR = window.devicePixelRatio;\n\tvar units = {\n\t\tpx: 1,\n\t\t\"in\": 96\n\t};\n\tvar anchor = document.createElement( \"a\" );\n\t/**\n\t * alreadyRun flag used for setOptions. is it true setOptions will reevaluate\n\t * @type {boolean}\n\t */\n\tvar alreadyRun = false;\n\n\t// Reusable, non-\"g\" Regexes\n\n\t// (Don't use \\s, to avoid matching non-breaking space.)\n\tvar regexLeadingSpaces = /^[ \\t\\n\\r\\u000c]+/,\n\t regexLeadingCommasOrSpaces = /^[, \\t\\n\\r\\u000c]+/,\n\t regexLeadingNotSpaces = /^[^ \\t\\n\\r\\u000c]+/,\n\t regexTrailingCommas = /[,]+$/,\n\t regexNonNegativeInteger = /^\\d+$/,\n\n\t // ( Positive or negative or unsigned integers or decimals, without or without exponents.\n\t // Must include at least one digit.\n\t // According to spec tests any decimal point must be followed by a digit.\n\t // No leading plus sign is allowed.)\n\t // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number\n\t regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;\n\n\tvar on = function(obj, evt, fn, capture) {\n\t\tif ( obj.addEventListener ) {\n\t\t\tobj.addEventListener(evt, fn, capture || false);\n\t\t} else if ( obj.attachEvent ) {\n\t\t\tobj.attachEvent( \"on\" + evt, fn);\n\t\t}\n\t};\n\n\t/**\n\t * simple memoize function:\n\t */\n\n\tvar memoize = function(fn) {\n\t\tvar cache = {};\n\t\treturn function(input) {\n\t\t\tif ( !(input in cache) ) {\n\t\t\t\tcache[ input ] = fn(input);\n\t\t\t}\n\t\t\treturn cache[ input ];\n\t\t};\n\t};\n\n\t// UTILITY FUNCTIONS\n\n\t// Manual is faster than RegEx\n\t// http://jsperf.com/whitespace-character/5\n\tfunction isSpace(c) {\n\t\treturn (c === \"\\u0020\" || // space\n\t\t c === \"\\u0009\" || // horizontal tab\n\t\t c === \"\\u000A\" || // new line\n\t\t c === \"\\u000C\" || // form feed\n\t\t c === \"\\u000D\"); // carriage return\n\t}\n\n\t/**\n\t * gets a mediaquery and returns a boolean or gets a css length and returns a number\n\t * @param css mediaqueries or css length\n\t * @returns {boolean|number}\n\t *\n\t * based on: https://gist.github.com/jonathantneal/db4f77009b155f083738\n\t */\n\tvar evalCSS = (function() {\n\n\t\tvar regLength = /^([\\d\\.]+)(em|vw|px)$/;\n\t\tvar replace = function() {\n\t\t\tvar args = arguments, index = 0, string = args[0];\n\t\t\twhile (++index in args) {\n\t\t\t\tstring = string.replace(args[index], args[++index]);\n\t\t\t}\n\t\t\treturn string;\n\t\t};\n\n\t\tvar buildStr = memoize(function(css) {\n\n\t\t\treturn \"return \" + replace((css || \"\").toLowerCase(),\n\t\t\t\t// interpret `and`\n\t\t\t\t/\\band\\b/g, \"&&\",\n\n\t\t\t\t// interpret `,`\n\t\t\t\t/,/g, \"||\",\n\n\t\t\t\t// interpret `min-` as >=\n\t\t\t\t/min-([a-z-\\s]+):/g, \"e.$1>=\",\n\n\t\t\t\t// interpret `max-` as <=\n\t\t\t\t/max-([a-z-\\s]+):/g, \"e.$1<=\",\n\n\t\t\t\t//calc value\n\t\t\t\t/calc([^)]+)/g, \"($1)\",\n\n\t\t\t\t// interpret css values\n\t\t\t\t/(\\d+[\\.]*[\\d]*)([a-z]+)/g, \"($1 * e.$2)\",\n\t\t\t\t//make eval less evil\n\t\t\t\t/^(?!(e.[a-z]|[0-9\\.&=|><\\+\\-\\*\\(\\)\\/])).*/ig, \"\"\n\t\t\t) + \";\";\n\t\t});\n\n\t\treturn function(css, length) {\n\t\t\tvar parsedLength;\n\t\t\tif (!(css in cssCache)) {\n\t\t\t\tcssCache[css] = false;\n\t\t\t\tif (length && (parsedLength = css.match( regLength ))) {\n\t\t\t\t\tcssCache[css] = parsedLength[ 1 ] * units[parsedLength[ 2 ]];\n\t\t\t\t} else {\n\t\t\t\t\t/*jshint evil:true */\n\t\t\t\t\ttry{\n\t\t\t\t\t\tcssCache[css] = new Function(\"e\", buildStr(css))(units);\n\t\t\t\t\t} catch(e) {}\n\t\t\t\t\t/*jshint evil:false */\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn cssCache[css];\n\t\t};\n\t})();\n\n\tvar setResolution = function( candidate, sizesattr ) {\n\t\tif ( candidate.w ) { // h = means height: || descriptor.type === 'h' do not handle yet...\n\t\t\tcandidate.cWidth = pf.calcListLength( sizesattr || \"100vw\" );\n\t\t\tcandidate.res = candidate.w / candidate.cWidth ;\n\t\t} else {\n\t\t\tcandidate.res = candidate.d;\n\t\t}\n\t\treturn candidate;\n\t};\n\n\t/**\n\t *\n\t * @param opt\n\t */\n\tvar picturefill = function( opt ) {\n\n\t\tif (!isSupportTestReady) {return;}\n\n\t\tvar elements, i, plen;\n\n\t\tvar options = opt || {};\n\n\t\tif ( options.elements && options.elements.nodeType === 1 ) {\n\t\t\tif ( options.elements.nodeName.toUpperCase() === \"IMG\" ) {\n\t\t\t\toptions.elements = [ options.elements ];\n\t\t\t} else {\n\t\t\t\toptions.context = options.elements;\n\t\t\t\toptions.elements = null;\n\t\t\t}\n\t\t}\n\n\t\telements = options.elements || pf.qsa( (options.context || document), ( options.reevaluate || options.reselect ) ? pf.sel : pf.selShort );\n\n\t\tif ( (plen = elements.length) ) {\n\n\t\t\tpf.setupRun( options );\n\t\t\talreadyRun = true;\n\n\t\t\t// Loop through all elements\n\t\t\tfor ( i = 0; i < plen; i++ ) {\n\t\t\t\tpf.fillImg(elements[ i ], options);\n\t\t\t}\n\n\t\t\tpf.teardownRun( options );\n\t\t}\n\t};\n\n\t/**\n\t * outputs a warning for the developer\n\t * @param {message}\n\t * @type {Function}\n\t */\n\twarn = ( window.console && console.warn ) ?\n\t\tfunction( message ) {\n\t\t\tconsole.warn( message );\n\t\t} :\n\t\tnoop\n\t;\n\n\tif ( !(curSrcProp in image) ) {\n\t\tcurSrcProp = \"src\";\n\t}\n\n\t// Add support for standard mime types.\n\ttypes[ \"image/jpeg\" ] = true;\n\ttypes[ \"image/gif\" ] = true;\n\ttypes[ \"image/png\" ] = true;\n\n\tfunction detectTypeSupport( type, typeUri ) {\n\t\t// based on Modernizr's lossless img-webp test\n\t\t// note: asynchronous\n\t\tvar image = new window.Image();\n\t\timage.onerror = function() {\n\t\t\ttypes[ type ] = false;\n\t\t\tpicturefill();\n\t\t};\n\t\timage.onload = function() {\n\t\t\ttypes[ type ] = image.width === 1;\n\t\t\tpicturefill();\n\t\t};\n\t\timage.src = typeUri;\n\t\treturn \"pending\";\n\t}\n\n\t// test svg support\n\ttypes[ \"image/svg+xml\" ] = document.implementation.hasFeature( \"http://www.w3.org/TR/SVG11/feature#Image\", \"1.1\" );\n\n\t/**\n\t * updates the internal vW property with the current viewport width in px\n\t */\n\tfunction updateMetrics() {\n\n\t\tisVwDirty = false;\n\t\tDPR = window.devicePixelRatio;\n\t\tcssCache = {};\n\t\tsizeLengthCache = {};\n\n\t\tpf.DPR = DPR || 1;\n\n\t\tunits.width = Math.max(window.innerWidth || 0, docElem.clientWidth);\n\t\tunits.height = Math.max(window.innerHeight || 0, docElem.clientHeight);\n\n\t\tunits.vw = units.width / 100;\n\t\tunits.vh = units.height / 100;\n\n\t\tevalId = [ units.height, units.width, DPR ].join(\"-\");\n\n\t\tunits.em = pf.getEmValue();\n\t\tunits.rem = units.em;\n\t}\n\n\tfunction chooseLowRes( lowerValue, higherValue, dprValue, isCached ) {\n\t\tvar bonusFactor, tooMuch, bonus, meanDensity;\n\n\t\t//experimental\n\t\tif (cfg.algorithm === \"saveData\" ){\n\t\t\tif ( lowerValue > 2.7 ) {\n\t\t\t\tmeanDensity = dprValue + 1;\n\t\t\t} else {\n\t\t\t\ttooMuch = higherValue - dprValue;\n\t\t\t\tbonusFactor = Math.pow(lowerValue - 0.6, 1.5);\n\n\t\t\t\tbonus = tooMuch * bonusFactor;\n\n\t\t\t\tif (isCached) {\n\t\t\t\t\tbonus += 0.1 * bonusFactor;\n\t\t\t\t}\n\n\t\t\t\tmeanDensity = lowerValue + bonus;\n\t\t\t}\n\t\t} else {\n\t\t\tmeanDensity = (dprValue > 1) ?\n\t\t\t\tMath.sqrt(lowerValue * higherValue) :\n\t\t\t\tlowerValue;\n\t\t}\n\n\t\treturn meanDensity > dprValue;\n\t}\n\n\tfunction applyBestCandidate( img ) {\n\t\tvar srcSetCandidates;\n\t\tvar matchingSet = pf.getSet( img );\n\t\tvar evaluated = false;\n\t\tif ( matchingSet !== \"pending\" ) {\n\t\t\tevaluated = evalId;\n\t\t\tif ( matchingSet ) {\n\t\t\t\tsrcSetCandidates = pf.setRes( matchingSet );\n\t\t\t\tpf.applySetCandidate( srcSetCandidates, img );\n\t\t\t}\n\t\t}\n\t\timg[ pf.ns ].evaled = evaluated;\n\t}\n\n\tfunction ascendingSort( a, b ) {\n\t\treturn a.res - b.res;\n\t}\n\n\tfunction setSrcToCur( img, src, set ) {\n\t\tvar candidate;\n\t\tif ( !set && src ) {\n\t\t\tset = img[ pf.ns ].sets;\n\t\t\tset = set && set[set.length - 1];\n\t\t}\n\n\t\tcandidate = getCandidateForSrc(src, set);\n\n\t\tif ( candidate ) {\n\t\t\tsrc = pf.makeUrl(src);\n\t\t\timg[ pf.ns ].curSrc = src;\n\t\t\timg[ pf.ns ].curCan = candidate;\n\n\t\t\tif ( !candidate.res ) {\n\t\t\t\tsetResolution( candidate, candidate.set.sizes );\n\t\t\t}\n\t\t}\n\t\treturn candidate;\n\t}\n\n\tfunction getCandidateForSrc( src, set ) {\n\t\tvar i, candidate, candidates;\n\t\tif ( src && set ) {\n\t\t\tcandidates = pf.parseSet( set );\n\t\t\tsrc = pf.makeUrl(src);\n\t\t\tfor ( i = 0; i < candidates.length; i++ ) {\n\t\t\t\tif ( src === pf.makeUrl(candidates[ i ].url) ) {\n\t\t\t\t\tcandidate = candidates[ i ];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn candidate;\n\t}\n\n\tfunction getAllSourceElements( picture, candidates ) {\n\t\tvar i, len, source, srcset;\n\n\t\t// SPEC mismatch intended for size and perf:\n\t\t// actually only source elements preceding the img should be used\n\t\t// also note: don't use qsa here, because IE8 sometimes doesn't like source as the key part in a selector\n\t\tvar sources = picture.getElementsByTagName( \"source\" );\n\n\t\tfor ( i = 0, len = sources.length; i < len; i++ ) {\n\t\t\tsource = sources[ i ];\n\t\t\tsource[ pf.ns ] = true;\n\t\t\tsrcset = source.getAttribute( \"srcset\" );\n\n\t\t\t// if source does not have a srcset attribute, skip\n\t\t\tif ( srcset ) {\n\t\t\t\tcandidates.push( {\n\t\t\t\t\tsrcset: srcset,\n\t\t\t\t\tmedia: source.getAttribute( \"media\" ),\n\t\t\t\t\ttype: source.getAttribute( \"type\" ),\n\t\t\t\t\tsizes: source.getAttribute( \"sizes\" )\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Srcset Parser\n\t * By Alex Bell | MIT License\n\t *\n\t * @returns Array [{url: _, d: _, w: _, h:_, set:_(????)}, ...]\n\t *\n\t * Based super duper closely on the reference algorithm at:\n\t * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute\n\t */\n\n\t// 1. Let input be the value passed to this algorithm.\n\t// (TO-DO : Explain what \"set\" argument is here. Maybe choose a more\n\t// descriptive & more searchable name. Since passing the \"set\" in really has\n\t// nothing to do with parsing proper, I would prefer this assignment eventually\n\t// go in an external fn.)\n\tfunction parseSrcset(input, set) {\n\n\t\tfunction collectCharacters(regEx) {\n\t\t\tvar chars,\n\t\t\t match = regEx.exec(input.substring(pos));\n\t\t\tif (match) {\n\t\t\t\tchars = match[ 0 ];\n\t\t\t\tpos += chars.length;\n\t\t\t\treturn chars;\n\t\t\t}\n\t\t}\n\n\t\tvar inputLength = input.length,\n\t\t url,\n\t\t descriptors,\n\t\t currentDescriptor,\n\t\t state,\n\t\t c,\n\n\t\t // 2. Let position be a pointer into input, initially pointing at the start\n\t\t // of the string.\n\t\t pos = 0,\n\n\t\t // 3. Let candidates be an initially empty source set.\n\t\t candidates = [];\n\n\t\t/**\n\t\t* Adds descriptor properties to a candidate, pushes to the candidates array\n\t\t* @return undefined\n\t\t*/\n\t\t// (Declared outside of the while loop so that it's only created once.\n\t\t// (This fn is defined before it is used, in order to pass JSHINT.\n\t\t// Unfortunately this breaks the sequencing of the spec comments. :/ )\n\t\tfunction parseDescriptors() {\n\n\t\t\t// 9. Descriptor parser: Let error be no.\n\t\t\tvar pError = false,\n\n\t\t\t// 10. Let width be absent.\n\t\t\t// 11. Let density be absent.\n\t\t\t// 12. Let future-compat-h be absent. (We're implementing it now as h)\n\t\t\t w, d, h, i,\n\t\t\t candidate = {},\n\t\t\t desc, lastChar, value, intVal, floatVal;\n\n\t\t\t// 13. For each descriptor in descriptors, run the appropriate set of steps\n\t\t\t// from the following list:\n\t\t\tfor (i = 0 ; i < descriptors.length; i++) {\n\t\t\t\tdesc = descriptors[ i ];\n\n\t\t\t\tlastChar = desc[ desc.length - 1 ];\n\t\t\t\tvalue = desc.substring(0, desc.length - 1);\n\t\t\t\tintVal = parseInt(value, 10);\n\t\t\t\tfloatVal = parseFloat(value);\n\n\t\t\t\t// If the descriptor consists of a valid non-negative integer followed by\n\t\t\t\t// a U+0077 LATIN SMALL LETTER W character\n\t\t\t\tif (regexNonNegativeInteger.test(value) && (lastChar === \"w\")) {\n\n\t\t\t\t\t// If width and density are not both absent, then let error be yes.\n\t\t\t\t\tif (w || d) {pError = true;}\n\n\t\t\t\t\t// Apply the rules for parsing non-negative integers to the descriptor.\n\t\t\t\t\t// If the result is zero, let error be yes.\n\t\t\t\t\t// Otherwise, let width be the result.\n\t\t\t\t\tif (intVal === 0) {pError = true;} else {w = intVal;}\n\n\t\t\t\t// If the descriptor consists of a valid floating-point number followed by\n\t\t\t\t// a U+0078 LATIN SMALL LETTER X character\n\t\t\t\t} else if (regexFloatingPoint.test(value) && (lastChar === \"x\")) {\n\n\t\t\t\t\t// If width, density and future-compat-h are not all absent, then let error\n\t\t\t\t\t// be yes.\n\t\t\t\t\tif (w || d || h) {pError = true;}\n\n\t\t\t\t\t// Apply the rules for parsing floating-point number values to the descriptor.\n\t\t\t\t\t// If the result is less than zero, let error be yes. Otherwise, let density\n\t\t\t\t\t// be the result.\n\t\t\t\t\tif (floatVal < 0) {pError = true;} else {d = floatVal;}\n\n\t\t\t\t// If the descriptor consists of a valid non-negative integer followed by\n\t\t\t\t// a U+0068 LATIN SMALL LETTER H character\n\t\t\t\t} else if (regexNonNegativeInteger.test(value) && (lastChar === \"h\")) {\n\n\t\t\t\t\t// If height and density are not both absent, then let error be yes.\n\t\t\t\t\tif (h || d) {pError = true;}\n\n\t\t\t\t\t// Apply the rules for parsing non-negative integers to the descriptor.\n\t\t\t\t\t// If the result is zero, let error be yes. Otherwise, let future-compat-h\n\t\t\t\t\t// be the result.\n\t\t\t\t\tif (intVal === 0) {pError = true;} else {h = intVal;}\n\n\t\t\t\t// Anything else, Let error be yes.\n\t\t\t\t} else {pError = true;}\n\t\t\t} // (close step 13 for loop)\n\n\t\t\t// 15. If error is still no, then append a new image source to candidates whose\n\t\t\t// URL is url, associated with a width width if not absent and a pixel\n\t\t\t// density density if not absent. Otherwise, there is a parse error.\n\t\t\tif (!pError) {\n\t\t\t\tcandidate.url = url;\n\n\t\t\t\tif (w) { candidate.w = w;}\n\t\t\t\tif (d) { candidate.d = d;}\n\t\t\t\tif (h) { candidate.h = h;}\n\t\t\t\tif (!h && !d && !w) {candidate.d = 1;}\n\t\t\t\tif (candidate.d === 1) {set.has1x = true;}\n\t\t\t\tcandidate.set = set;\n\n\t\t\t\tcandidates.push(candidate);\n\t\t\t}\n\t\t} // (close parseDescriptors fn)\n\n\t\t/**\n\t\t* Tokenizes descriptor properties prior to parsing\n\t\t* Returns undefined.\n\t\t* (Again, this fn is defined before it is used, in order to pass JSHINT.\n\t\t* Unfortunately this breaks the logical sequencing of the spec comments. :/ )\n\t\t*/\n\t\tfunction tokenize() {\n\n\t\t\t// 8.1. Descriptor tokeniser: Skip whitespace\n\t\t\tcollectCharacters(regexLeadingSpaces);\n\n\t\t\t// 8.2. Let current descriptor be the empty string.\n\t\t\tcurrentDescriptor = \"\";\n\n\t\t\t// 8.3. Let state be in descriptor.\n\t\t\tstate = \"in descriptor\";\n\n\t\t\twhile (true) {\n\n\t\t\t\t// 8.4. Let c be the character at position.\n\t\t\t\tc = input.charAt(pos);\n\n\t\t\t\t// Do the following depending on the value of state.\n\t\t\t\t// For the purpose of this step, \"EOF\" is a special character representing\n\t\t\t\t// that position is past the end of input.\n\n\t\t\t\t// In descriptor\n\t\t\t\tif (state === \"in descriptor\") {\n\t\t\t\t\t// Do the following, depending on the value of c:\n\n\t\t\t\t // Space character\n\t\t\t\t // If current descriptor is not empty, append current descriptor to\n\t\t\t\t // descriptors and let current descriptor be the empty string.\n\t\t\t\t // Set state to after descriptor.\n\t\t\t\t\tif (isSpace(c)) {\n\t\t\t\t\t\tif (currentDescriptor) {\n\t\t\t\t\t\t\tdescriptors.push(currentDescriptor);\n\t\t\t\t\t\t\tcurrentDescriptor = \"\";\n\t\t\t\t\t\t\tstate = \"after descriptor\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t// U+002C COMMA (,)\n\t\t\t\t\t// Advance position to the next character in input. If current descriptor\n\t\t\t\t\t// is not empty, append current descriptor to descriptors. Jump to the step\n\t\t\t\t\t// labeled descriptor parser.\n\t\t\t\t\t} else if (c === \",\") {\n\t\t\t\t\t\tpos += 1;\n\t\t\t\t\t\tif (currentDescriptor) {\n\t\t\t\t\t\t\tdescriptors.push(currentDescriptor);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparseDescriptors();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t// U+0028 LEFT PARENTHESIS (()\n\t\t\t\t\t// Append c to current descriptor. Set state to in parens.\n\t\t\t\t\t} else if (c === \"\\u0028\") {\n\t\t\t\t\t\tcurrentDescriptor = currentDescriptor + c;\n\t\t\t\t\t\tstate = \"in parens\";\n\n\t\t\t\t\t// EOF\n\t\t\t\t\t// If current descriptor is not empty, append current descriptor to\n\t\t\t\t\t// descriptors. Jump to the step labeled descriptor parser.\n\t\t\t\t\t} else if (c === \"\") {\n\t\t\t\t\t\tif (currentDescriptor) {\n\t\t\t\t\t\t\tdescriptors.push(currentDescriptor);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparseDescriptors();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t// Anything else\n\t\t\t\t\t// Append c to current descriptor.\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcurrentDescriptor = currentDescriptor + c;\n\t\t\t\t\t}\n\t\t\t\t// (end \"in descriptor\"\n\n\t\t\t\t// In parens\n\t\t\t\t} else if (state === \"in parens\") {\n\n\t\t\t\t\t// U+0029 RIGHT PARENTHESIS ())\n\t\t\t\t\t// Append c to current descriptor. Set state to in descriptor.\n\t\t\t\t\tif (c === \")\") {\n\t\t\t\t\t\tcurrentDescriptor = currentDescriptor + c;\n\t\t\t\t\t\tstate = \"in descriptor\";\n\n\t\t\t\t\t// EOF\n\t\t\t\t\t// Append current descriptor to descriptors. Jump to the step labeled\n\t\t\t\t\t// descriptor parser.\n\t\t\t\t\t} else if (c === \"\") {\n\t\t\t\t\t\tdescriptors.push(currentDescriptor);\n\t\t\t\t\t\tparseDescriptors();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t// Anything else\n\t\t\t\t\t// Append c to current descriptor.\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcurrentDescriptor = currentDescriptor + c;\n\t\t\t\t\t}\n\n\t\t\t\t// After descriptor\n\t\t\t\t} else if (state === \"after descriptor\") {\n\n\t\t\t\t\t// Do the following, depending on the value of c:\n\t\t\t\t\t// Space character: Stay in this state.\n\t\t\t\t\tif (isSpace(c)) {\n\n\t\t\t\t\t// EOF: Jump to the step labeled descriptor parser.\n\t\t\t\t\t} else if (c === \"\") {\n\t\t\t\t\t\tparseDescriptors();\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t// Anything else\n\t\t\t\t\t// Set state to in descriptor. Set position to the previous character in input.\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate = \"in descriptor\";\n\t\t\t\t\t\tpos -= 1;\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Advance position to the next character in input.\n\t\t\t\tpos += 1;\n\n\t\t\t// Repeat this step.\n\t\t\t} // (close while true loop)\n\t\t}\n\n\t\t// 4. Splitting loop: Collect a sequence of characters that are space\n\t\t// characters or U+002C COMMA characters. If any U+002C COMMA characters\n\t\t// were collected, that is a parse error.\n\t\twhile (true) {\n\t\t\tcollectCharacters(regexLeadingCommasOrSpaces);\n\n\t\t\t// 5. If position is past the end of input, return candidates and abort these steps.\n\t\t\tif (pos >= inputLength) {\n\t\t\t\treturn candidates; // (we're done, this is the sole return path)\n\t\t\t}\n\n\t\t\t// 6. Collect a sequence of characters that are not space characters,\n\t\t\t// and let that be url.\n\t\t\turl = collectCharacters(regexLeadingNotSpaces);\n\n\t\t\t// 7. Let descriptors be a new empty list.\n\t\t\tdescriptors = [];\n\n\t\t\t// 8. If url ends with a U+002C COMMA character (,), follow these substeps:\n\t\t\t//\t\t(1). Remove all trailing U+002C COMMA characters from url. If this removed\n\t\t\t// more than one character, that is a parse error.\n\t\t\tif (url.slice(-1) === \",\") {\n\t\t\t\turl = url.replace(regexTrailingCommas, \"\");\n\t\t\t\t// (Jump ahead to step 9 to skip tokenization and just push the candidate).\n\t\t\t\tparseDescriptors();\n\n\t\t\t//\tOtherwise, follow these substeps:\n\t\t\t} else {\n\t\t\t\ttokenize();\n\t\t\t} // (close else of step 8)\n\n\t\t// 16. Return to the step labeled splitting loop.\n\t\t} // (Close of big while loop.)\n\t}\n\n\t/*\n\t * Sizes Parser\n\t *\n\t * By Alex Bell | MIT License\n\t *\n\t * Non-strict but accurate and lightweight JS Parser for the string value \n\t *\n\t * Reference algorithm at:\n\t * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-sizes-attribute\n\t *\n\t * Most comments are copied in directly from the spec\n\t * (except for comments in parens).\n\t *\n\t * Grammar is:\n\t * = # [ , ]? | \n\t * = \n\t * = \n\t * http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-sizes\n\t *\n\t * E.g. \"(max-width: 30em) 100vw, (max-width: 50em) 70vw, 100vw\"\n\t * or \"(min-width: 30em), calc(30vw - 15px)\" or just \"30vw\"\n\t *\n\t * Returns the first valid with a media condition that evaluates to true,\n\t * or \"100vw\" if all valid media conditions evaluate to false.\n\t *\n\t */\n\n\tfunction parseSizes(strValue) {\n\n\t\t// (Percentage CSS lengths are not allowed in this case, to avoid confusion:\n\t\t// https://html.spec.whatwg.org/multipage/embedded-content.html#valid-source-size-list\n\t\t// CSS allows a single optional plus or minus sign:\n\t\t// http://www.w3.org/TR/CSS2/syndata.html#numbers\n\t\t// CSS is ASCII case-insensitive:\n\t\t// http://www.w3.org/TR/CSS2/syndata.html#characters )\n\t\t// Spec allows exponential notation for type:\n\t\t// http://dev.w3.org/csswg/css-values/#numbers\n\t\tvar regexCssLengthWithUnits = /^(?:[+-]?[0-9]+|[0-9]*\\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i;\n\n\t\t// (This is a quick and lenient test. Because of optional unlimited-depth internal\n\t\t// grouping parens and strict spacing rules, this could get very complicated.)\n\t\tvar regexCssCalc = /^calc\\((?:[0-9a-z \\.\\+\\-\\*\\/\\(\\)]+)\\)$/i;\n\n\t\tvar i;\n\t\tvar unparsedSizesList;\n\t\tvar unparsedSizesListLength;\n\t\tvar unparsedSize;\n\t\tvar lastComponentValue;\n\t\tvar size;\n\n\t\t// UTILITY FUNCTIONS\n\n\t\t// (Toy CSS parser. The goals here are:\n\t\t// 1) expansive test coverage without the weight of a full CSS parser.\n\t\t// 2) Avoiding regex wherever convenient.\n\t\t// Quick tests: http://jsfiddle.net/gtntL4gr/3/\n\t\t// Returns an array of arrays.)\n\t\tfunction parseComponentValues(str) {\n\t\t\tvar chrctr;\n\t\t\tvar component = \"\";\n\t\t\tvar componentArray = [];\n\t\t\tvar listArray = [];\n\t\t\tvar parenDepth = 0;\n\t\t\tvar pos = 0;\n\t\t\tvar inComment = false;\n\n\t\t\tfunction pushComponent() {\n\t\t\t\tif (component) {\n\t\t\t\t\tcomponentArray.push(component);\n\t\t\t\t\tcomponent = \"\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction pushComponentArray() {\n\t\t\t\tif (componentArray[0]) {\n\t\t\t\t\tlistArray.push(componentArray);\n\t\t\t\t\tcomponentArray = [];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// (Loop forwards from the beginning of the string.)\n\t\t\twhile (true) {\n\t\t\t\tchrctr = str.charAt(pos);\n\n\t\t\t\tif (chrctr === \"\") { // ( End of string reached.)\n\t\t\t\t\tpushComponent();\n\t\t\t\t\tpushComponentArray();\n\t\t\t\t\treturn listArray;\n\t\t\t\t} else if (inComment) {\n\t\t\t\t\tif ((chrctr === \"*\") && (str[pos + 1] === \"/\")) { // (At end of a comment.)\n\t\t\t\t\t\tinComment = false;\n\t\t\t\t\t\tpos += 2;\n\t\t\t\t\t\tpushComponent();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpos += 1; // (Skip all characters inside comments.)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t} else if (isSpace(chrctr)) {\n\t\t\t\t\t// (If previous character in loop was also a space, or if\n\t\t\t\t\t// at the beginning of the string, do not add space char to\n\t\t\t\t\t// component.)\n\t\t\t\t\tif ( (str.charAt(pos - 1) && isSpace( str.charAt(pos - 1) ) ) || !component ) {\n\t\t\t\t\t\tpos += 1;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (parenDepth === 0) {\n\t\t\t\t\t\tpushComponent();\n\t\t\t\t\t\tpos +=1;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// (Replace any space character with a plain space for legibility.)\n\t\t\t\t\t\tchrctr = \" \";\n\t\t\t\t\t}\n\t\t\t\t} else if (chrctr === \"(\") {\n\t\t\t\t\tparenDepth += 1;\n\t\t\t\t} else if (chrctr === \")\") {\n\t\t\t\t\tparenDepth -= 1;\n\t\t\t\t} else if (chrctr === \",\") {\n\t\t\t\t\tpushComponent();\n\t\t\t\t\tpushComponentArray();\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t} else if ( (chrctr === \"/\") && (str.charAt(pos + 1) === \"*\") ) {\n\t\t\t\t\tinComment = true;\n\t\t\t\t\tpos += 2;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcomponent = component + chrctr;\n\t\t\t\tpos += 1;\n\t\t\t}\n\t\t}\n\n\t\tfunction isValidNonNegativeSourceSizeValue(s) {\n\t\t\tif (regexCssLengthWithUnits.test(s) && (parseFloat(s) >= 0)) {return true;}\n\t\t\tif (regexCssCalc.test(s)) {return true;}\n\t\t\t// ( http://www.w3.org/TR/CSS2/syndata.html#numbers says:\n\t\t\t// \"-0 is equivalent to 0 and is not a negative number.\" which means that\n\t\t\t// unitless zero and unitless negative zero must be accepted as special cases.)\n\t\t\tif ((s === \"0\") || (s === \"-0\") || (s === \"+0\")) {return true;}\n\t\t\treturn false;\n\t\t}\n\n\t\t// When asked to parse a sizes attribute from an element, parse a\n\t\t// comma-separated list of component values from the value of the element's\n\t\t// sizes attribute (or the empty string, if the attribute is absent), and let\n\t\t// unparsed sizes list be the result.\n\t\t// http://dev.w3.org/csswg/css-syntax/#parse-comma-separated-list-of-component-values\n\n\t\tunparsedSizesList = parseComponentValues(strValue);\n\t\tunparsedSizesListLength = unparsedSizesList.length;\n\n\t\t// For each unparsed size in unparsed sizes list:\n\t\tfor (i = 0; i < unparsedSizesListLength; i++) {\n\t\t\tunparsedSize = unparsedSizesList[i];\n\n\t\t\t// 1. Remove all consecutive s from the end of unparsed size.\n\t\t\t// ( parseComponentValues() already omits spaces outside of parens. )\n\n\t\t\t// If unparsed size is now empty, that is a parse error; continue to the next\n\t\t\t// iteration of this algorithm.\n\t\t\t// ( parseComponentValues() won't push an empty array. )\n\n\t\t\t// 2. If the last component value in unparsed size is a valid non-negative\n\t\t\t// , let size be its value and remove the component value\n\t\t\t// from unparsed size. Any CSS function other than the calc() function is\n\t\t\t// invalid. Otherwise, there is a parse error; continue to the next iteration\n\t\t\t// of this algorithm.\n\t\t\t// http://dev.w3.org/csswg/css-syntax/#parse-component-value\n\t\t\tlastComponentValue = unparsedSize[unparsedSize.length - 1];\n\n\t\t\tif (isValidNonNegativeSourceSizeValue(lastComponentValue)) {\n\t\t\t\tsize = lastComponentValue;\n\t\t\t\tunparsedSize.pop();\n\t\t\t} else {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// 3. Remove all consecutive s from the end of unparsed\n\t\t\t// size. If unparsed size is now empty, return size and exit this algorithm.\n\t\t\t// If this was not the last item in unparsed sizes list, that is a parse error.\n\t\t\tif (unparsedSize.length === 0) {\n\t\t\t\treturn size;\n\t\t\t}\n\n\t\t\t// 4. Parse the remaining component values in unparsed size as a\n\t\t\t// . If it does not parse correctly, or it does parse\n\t\t\t// correctly but the evaluates to false, continue to the\n\t\t\t// next iteration of this algorithm.\n\t\t\t// (Parsing all possible compound media conditions in JS is heavy, complicated,\n\t\t\t// and the payoff is unclear. Is there ever an situation where the\n\t\t\t// media condition parses incorrectly but still somehow evaluates to true?\n\t\t\t// Can we just rely on the browser/polyfill to do it?)\n\t\t\tunparsedSize = unparsedSize.join(\" \");\n\t\t\tif (!(pf.matchesMedia( unparsedSize ) ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// 5. Return size and exit this algorithm.\n\t\t\treturn size;\n\t\t}\n\n\t\t// If the above algorithm exhausts unparsed sizes list without returning a\n\t\t// size value, return 100vw.\n\t\treturn \"100vw\";\n\t}\n\n\t// namespace\n\tpf.ns = (\"pf\" + new Date().getTime()).substr(0, 9);\n\n\t// srcset support test\n\tpf.supSrcset = \"srcset\" in image;\n\tpf.supSizes = \"sizes\" in image;\n\tpf.supPicture = !!window.HTMLPictureElement;\n\n\t// UC browser does claim to support srcset and picture, but not sizes,\n\t// this extended test reveals the browser does support nothing\n\tif (pf.supSrcset && pf.supPicture && !pf.supSizes) {\n\t\t(function(image2) {\n\t\t\timage.srcset = \"data:,a\";\n\t\t\timage2.src = \"data:,a\";\n\t\t\tpf.supSrcset = image.complete === image2.complete;\n\t\t\tpf.supPicture = pf.supSrcset && pf.supPicture;\n\t\t})(document.createElement(\"img\"));\n\t}\n\n\t// Safari9 has basic support for sizes, but does't expose the `sizes` idl attribute\n\tif (pf.supSrcset && !pf.supSizes) {\n\n\t\t(function() {\n\t\t\tvar width2 = \"data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==\";\n\t\t\tvar width1 = \"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\";\n\t\t\tvar img = document.createElement(\"img\");\n\t\t\tvar test = function() {\n\t\t\t\tvar width = img.width;\n\n\t\t\t\tif (width === 2) {\n\t\t\t\t\tpf.supSizes = true;\n\t\t\t\t}\n\n\t\t\t\talwaysCheckWDescriptor = pf.supSrcset && !pf.supSizes;\n\n\t\t\t\tisSupportTestReady = true;\n\t\t\t\t// force async\n\t\t\t\tsetTimeout(picturefill);\n\t\t\t};\n\n\t\t\timg.onload = test;\n\t\t\timg.onerror = test;\n\t\t\timg.setAttribute(\"sizes\", \"9px\");\n\n\t\t\timg.srcset = width1 + \" 1w,\" + width2 + \" 9w\";\n\t\t\timg.src = width1;\n\t\t})();\n\n\t} else {\n\t\tisSupportTestReady = true;\n\t}\n\n\t// using pf.qsa instead of dom traversing does scale much better,\n\t// especially on sites mixing responsive and non-responsive images\n\tpf.selShort = \"picture>img,img[srcset]\";\n\tpf.sel = pf.selShort;\n\tpf.cfg = cfg;\n\n\t/**\n\t * Shortcut property for `devicePixelRatio` ( for easy overriding in tests )\n\t */\n\tpf.DPR = (DPR || 1 );\n\tpf.u = units;\n\n\t// container of supported mime types that one might need to qualify before using\n\tpf.types = types;\n\n\tpf.setSize = noop;\n\n\t/**\n\t * Gets a string and returns the absolute URL\n\t * @param src\n\t * @returns {String} absolute URL\n\t */\n\n\tpf.makeUrl = memoize(function(src) {\n\t\tanchor.href = src;\n\t\treturn anchor.href;\n\t});\n\n\t/**\n\t * Gets a DOM element or document and a selctor and returns the found matches\n\t * Can be extended with jQuery/Sizzle for IE7 support\n\t * @param context\n\t * @param sel\n\t * @returns {NodeList|Array}\n\t */\n\tpf.qsa = function(context, sel) {\n\t\treturn ( \"querySelector\" in context ) ? context.querySelectorAll(sel) : [];\n\t};\n\n\t/**\n\t * Shortcut method for matchMedia ( for easy overriding in tests )\n\t * wether native or pf.mMQ is used will be decided lazy on first call\n\t * @returns {boolean}\n\t */\n\tpf.matchesMedia = function() {\n\t\tif ( window.matchMedia && (matchMedia( \"(min-width: 0.1em)\" ) || {}).matches ) {\n\t\t\tpf.matchesMedia = function( media ) {\n\t\t\t\treturn !media || ( matchMedia( media ).matches );\n\t\t\t};\n\t\t} else {\n\t\t\tpf.matchesMedia = pf.mMQ;\n\t\t}\n\n\t\treturn pf.matchesMedia.apply( this, arguments );\n\t};\n\n\t/**\n\t * A simplified matchMedia implementation for IE8 and IE9\n\t * handles only min-width/max-width with px or em values\n\t * @param media\n\t * @returns {boolean}\n\t */\n\tpf.mMQ = function( media ) {\n\t\treturn media ? evalCSS(media) : true;\n\t};\n\n\t/**\n\t * Returns the calculated length in css pixel from the given sourceSizeValue\n\t * http://dev.w3.org/csswg/css-values-3/#length-value\n\t * intended Spec mismatches:\n\t * * Does not check for invalid use of CSS functions\n\t * * Does handle a computed length of 0 the same as a negative and therefore invalid value\n\t * @param sourceSizeValue\n\t * @returns {Number}\n\t */\n\tpf.calcLength = function( sourceSizeValue ) {\n\n\t\tvar value = evalCSS(sourceSizeValue, true) || false;\n\t\tif (value < 0) {\n\t\t\tvalue = false;\n\t\t}\n\n\t\treturn value;\n\t};\n\n\t/**\n\t * Takes a type string and checks if its supported\n\t */\n\n\tpf.supportsType = function( type ) {\n\t\treturn ( type ) ? types[ type ] : true;\n\t};\n\n\t/**\n\t * Parses a sourceSize into mediaCondition (media) and sourceSizeValue (length)\n\t * @param sourceSizeStr\n\t * @returns {*}\n\t */\n\tpf.parseSize = memoize(function( sourceSizeStr ) {\n\t\tvar match = ( sourceSizeStr || \"\" ).match(regSize);\n\t\treturn {\n\t\t\tmedia: match && match[1],\n\t\t\tlength: match && match[2]\n\t\t};\n\t});\n\n\tpf.parseSet = function( set ) {\n\t\tif ( !set.cands ) {\n\t\t\tset.cands = parseSrcset(set.srcset, set);\n\t\t}\n\t\treturn set.cands;\n\t};\n\n\t/**\n\t * returns 1em in css px for html/body default size\n\t * function taken from respondjs\n\t * @returns {*|number}\n\t */\n\tpf.getEmValue = function() {\n\t\tvar body;\n\t\tif ( !eminpx && (body = document.body) ) {\n\t\t\tvar div = document.createElement( \"div\" ),\n\t\t\t\toriginalHTMLCSS = docElem.style.cssText,\n\t\t\t\toriginalBodyCSS = body.style.cssText;\n\n\t\t\tdiv.style.cssText = baseStyle;\n\n\t\t\t// 1em in a media query is the value of the default font size of the browser\n\t\t\t// reset docElem and body to ensure the correct value is returned\n\t\t\tdocElem.style.cssText = fsCss;\n\t\t\tbody.style.cssText = fsCss;\n\n\t\t\tbody.appendChild( div );\n\t\t\teminpx = div.offsetWidth;\n\t\t\tbody.removeChild( div );\n\n\t\t\t//also update eminpx before returning\n\t\t\teminpx = parseFloat( eminpx, 10 );\n\n\t\t\t// restore the original values\n\t\t\tdocElem.style.cssText = originalHTMLCSS;\n\t\t\tbody.style.cssText = originalBodyCSS;\n\n\t\t}\n\t\treturn eminpx || 16;\n\t};\n\n\t/**\n\t * Takes a string of sizes and returns the width in pixels as a number\n\t */\n\tpf.calcListLength = function( sourceSizeListStr ) {\n\t\t// Split up source size list, ie ( max-width: 30em ) 100%, ( max-width: 50em ) 50%, 33%\n\t\t//\n\t\t// or (min-width:30em) calc(30% - 15px)\n\t\tif ( !(sourceSizeListStr in sizeLengthCache) || cfg.uT ) {\n\t\t\tvar winningLength = pf.calcLength( parseSizes( sourceSizeListStr ) );\n\n\t\t\tsizeLengthCache[ sourceSizeListStr ] = !winningLength ? units.width : winningLength;\n\t\t}\n\n\t\treturn sizeLengthCache[ sourceSizeListStr ];\n\t};\n\n\t/**\n\t * Takes a candidate object with a srcset property in the form of url/\n\t * ex. \"images/pic-medium.png 1x, images/pic-medium-2x.png 2x\" or\n\t * \"images/pic-medium.png 400w, images/pic-medium-2x.png 800w\" or\n\t * \"images/pic-small.png\"\n\t * Get an array of image candidates in the form of\n\t * {url: \"/foo/bar.png\", resolution: 1}\n\t * where resolution is http://dev.w3.org/csswg/css-values-3/#resolution-value\n\t * If sizes is specified, res is calculated\n\t */\n\tpf.setRes = function( set ) {\n\t\tvar candidates;\n\t\tif ( set ) {\n\n\t\t\tcandidates = pf.parseSet( set );\n\n\t\t\tfor ( var i = 0, len = candidates.length; i < len; i++ ) {\n\t\t\t\tsetResolution( candidates[ i ], set.sizes );\n\t\t\t}\n\t\t}\n\t\treturn candidates;\n\t};\n\n\tpf.setRes.res = setResolution;\n\n\tpf.applySetCandidate = function( candidates, img ) {\n\t\tif ( !candidates.length ) {return;}\n\t\tvar candidate,\n\t\t\ti,\n\t\t\tj,\n\t\t\tlength,\n\t\t\tbestCandidate,\n\t\t\tcurSrc,\n\t\t\tcurCan,\n\t\t\tcandidateSrc,\n\t\t\tabortCurSrc;\n\n\t\tvar imageData = img[ pf.ns ];\n\t\tvar dpr = pf.DPR;\n\n\t\tcurSrc = imageData.curSrc || img[curSrcProp];\n\n\t\tcurCan = imageData.curCan || setSrcToCur(img, curSrc, candidates[0].set);\n\n\t\t// if we have a current source, we might either become lazy or give this source some advantage\n\t\tif ( curCan && curCan.set === candidates[ 0 ].set ) {\n\n\t\t\t// if browser can abort image request and the image has a higher pixel density than needed\n\t\t\t// and this image isn't downloaded yet, we skip next part and try to save bandwidth\n\t\t\tabortCurSrc = (supportAbort && !img.complete && curCan.res - 0.1 > dpr);\n\n\t\t\tif ( !abortCurSrc ) {\n\t\t\t\tcurCan.cached = true;\n\n\t\t\t\t// if current candidate is \"best\", \"better\" or \"okay\",\n\t\t\t\t// set it to bestCandidate\n\t\t\t\tif ( curCan.res >= dpr ) {\n\t\t\t\t\tbestCandidate = curCan;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( !bestCandidate ) {\n\n\t\t\tcandidates.sort( ascendingSort );\n\n\t\t\tlength = candidates.length;\n\t\t\tbestCandidate = candidates[ length - 1 ];\n\n\t\t\tfor ( i = 0; i < length; i++ ) {\n\t\t\t\tcandidate = candidates[ i ];\n\t\t\t\tif ( candidate.res >= dpr ) {\n\t\t\t\t\tj = i - 1;\n\n\t\t\t\t\t// we have found the perfect candidate,\n\t\t\t\t\t// but let's improve this a little bit with some assumptions ;-)\n\t\t\t\t\tif (candidates[ j ] &&\n\t\t\t\t\t\t(abortCurSrc || curSrc !== pf.makeUrl( candidate.url )) &&\n\t\t\t\t\t\tchooseLowRes(candidates[ j ].res, candidate.res, dpr, candidates[ j ].cached)) {\n\n\t\t\t\t\t\tbestCandidate = candidates[ j ];\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbestCandidate = candidate;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( bestCandidate ) {\n\n\t\t\tcandidateSrc = pf.makeUrl( bestCandidate.url );\n\n\t\t\timageData.curSrc = candidateSrc;\n\t\t\timageData.curCan = bestCandidate;\n\n\t\t\tif ( candidateSrc !== curSrc ) {\n\t\t\t\tpf.setSrc( img, bestCandidate );\n\t\t\t}\n\t\t\tpf.setSize( img );\n\t\t}\n\t};\n\n\tpf.setSrc = function( img, bestCandidate ) {\n\t\tvar origWidth;\n\t\timg.src = bestCandidate.url;\n\n\t\t// although this is a specific Safari issue, we don't want to take too much different code paths\n\t\tif ( bestCandidate.set.type === \"image/svg+xml\" ) {\n\t\t\torigWidth = img.style.width;\n\t\t\timg.style.width = (img.offsetWidth + 1) + \"px\";\n\n\t\t\t// next line only should trigger a repaint\n\t\t\t// if... is only done to trick dead code removal\n\t\t\tif ( img.offsetWidth + 1 ) {\n\t\t\t\timg.style.width = origWidth;\n\t\t\t}\n\t\t}\n\t};\n\n\tpf.getSet = function( img ) {\n\t\tvar i, set, supportsType;\n\t\tvar match = false;\n\t\tvar sets = img [ pf.ns ].sets;\n\n\t\tfor ( i = 0; i < sets.length && !match; i++ ) {\n\t\t\tset = sets[i];\n\n\t\t\tif ( !set.srcset || !pf.matchesMedia( set.media ) || !(supportsType = pf.supportsType( set.type )) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( supportsType === \"pending\" ) {\n\t\t\t\tset = supportsType;\n\t\t\t}\n\n\t\t\tmatch = set;\n\t\t\tbreak;\n\t\t}\n\n\t\treturn match;\n\t};\n\n\tpf.parseSets = function( element, parent, options ) {\n\t\tvar srcsetAttribute, imageSet, isWDescripor, srcsetParsed;\n\n\t\tvar hasPicture = parent && parent.nodeName.toUpperCase() === \"PICTURE\";\n\t\tvar imageData = element[ pf.ns ];\n\n\t\tif ( imageData.src === undefined || options.src ) {\n\t\t\timageData.src = getImgAttr.call( element, \"src\" );\n\t\t\tif ( imageData.src ) {\n\t\t\t\tsetImgAttr.call( element, srcAttr, imageData.src );\n\t\t\t} else {\n\t\t\t\tremoveImgAttr.call( element, srcAttr );\n\t\t\t}\n\t\t}\n\n\t\tif ( imageData.srcset === undefined || options.srcset || !pf.supSrcset || element.srcset ) {\n\t\t\tsrcsetAttribute = getImgAttr.call( element, \"srcset\" );\n\t\t\timageData.srcset = srcsetAttribute;\n\t\t\tsrcsetParsed = true;\n\t\t}\n\n\t\timageData.sets = [];\n\n\t\tif ( hasPicture ) {\n\t\t\timageData.pic = true;\n\t\t\tgetAllSourceElements( parent, imageData.sets );\n\t\t}\n\n\t\tif ( imageData.srcset ) {\n\t\t\timageSet = {\n\t\t\t\tsrcset: imageData.srcset,\n\t\t\t\tsizes: getImgAttr.call( element, \"sizes\" )\n\t\t\t};\n\n\t\t\timageData.sets.push( imageSet );\n\n\t\t\tisWDescripor = (alwaysCheckWDescriptor || imageData.src) && regWDesc.test(imageData.srcset || \"\");\n\n\t\t\t// add normal src as candidate, if source has no w descriptor\n\t\t\tif ( !isWDescripor && imageData.src && !getCandidateForSrc(imageData.src, imageSet) && !imageSet.has1x ) {\n\t\t\t\timageSet.srcset += \", \" + imageData.src;\n\t\t\t\timageSet.cands.push({\n\t\t\t\t\turl: imageData.src,\n\t\t\t\t\td: 1,\n\t\t\t\t\tset: imageSet\n\t\t\t\t});\n\t\t\t}\n\n\t\t} else if ( imageData.src ) {\n\t\t\timageData.sets.push( {\n\t\t\t\tsrcset: imageData.src,\n\t\t\t\tsizes: null\n\t\t\t} );\n\t\t}\n\n\t\timageData.curCan = null;\n\t\timageData.curSrc = undefined;\n\n\t\t// if img has picture or the srcset was removed or has a srcset and does not support srcset at all\n\t\t// or has a w descriptor (and does not support sizes) set support to false to evaluate\n\t\timageData.supported = !( hasPicture || ( imageSet && !pf.supSrcset ) || (isWDescripor && !pf.supSizes) );\n\n\t\tif ( srcsetParsed && pf.supSrcset && !imageData.supported ) {\n\t\t\tif ( srcsetAttribute ) {\n\t\t\t\tsetImgAttr.call( element, srcsetAttr, srcsetAttribute );\n\t\t\t\telement.srcset = \"\";\n\t\t\t} else {\n\t\t\t\tremoveImgAttr.call( element, srcsetAttr );\n\t\t\t}\n\t\t}\n\n\t\tif (imageData.supported && !imageData.srcset && ((!imageData.src && element.src) || element.src !== pf.makeUrl(imageData.src))) {\n\t\t\tif (imageData.src === null) {\n\t\t\t\telement.removeAttribute(\"src\");\n\t\t\t} else {\n\t\t\t\telement.src = imageData.src;\n\t\t\t}\n\t\t}\n\n\t\timageData.parsed = true;\n\t};\n\n\tpf.fillImg = function(element, options) {\n\t\tvar imageData;\n\t\tvar extreme = options.reselect || options.reevaluate;\n\n\t\t// expando for caching data on the img\n\t\tif ( !element[ pf.ns ] ) {\n\t\t\telement[ pf.ns ] = {};\n\t\t}\n\n\t\timageData = element[ pf.ns ];\n\n\t\t// if the element has already been evaluated, skip it\n\t\t// unless `options.reevaluate` is set to true ( this, for example,\n\t\t// is set to true when running `picturefill` on `resize` ).\n\t\tif ( !extreme && imageData.evaled === evalId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( !imageData.parsed || options.reevaluate ) {\n\t\t\tpf.parseSets( element, element.parentNode, options );\n\t\t}\n\n\t\tif ( !imageData.supported ) {\n\t\t\tapplyBestCandidate( element );\n\t\t} else {\n\t\t\timageData.evaled = evalId;\n\t\t}\n\t};\n\n\tpf.setupRun = function() {\n\t\tif ( !alreadyRun || isVwDirty || (DPR !== window.devicePixelRatio) ) {\n\t\t\tupdateMetrics();\n\t\t}\n\t};\n\n\t// If picture is supported, well, that's awesome.\n\tif ( pf.supPicture ) {\n\t\tpicturefill = noop;\n\t\tpf.fillImg = noop;\n\t} else {\n\n\t\t // Set up picture polyfill by polling the document\n\t\t(function() {\n\t\t\tvar isDomReady;\n\t\t\tvar regReady = window.attachEvent ? /d$|^c/ : /d$|^c|^i/;\n\n\t\t\tvar run = function() {\n\t\t\t\tvar readyState = document.readyState || \"\";\n\n\t\t\t\ttimerId = setTimeout(run, readyState === \"loading\" ? 200 : 999);\n\t\t\t\tif ( document.body ) {\n\t\t\t\t\tpf.fillImgs();\n\t\t\t\t\tisDomReady = isDomReady || regReady.test(readyState);\n\t\t\t\t\tif ( isDomReady ) {\n\t\t\t\t\t\tclearTimeout( timerId );\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tvar timerId = setTimeout(run, document.body ? 9 : 99);\n\n\t\t\t// Also attach picturefill on resize and readystatechange\n\t\t\t// http://modernjavascript.blogspot.com/2013/08/building-better-debounce.html\n\t\t\tvar debounce = function(func, wait) {\n\t\t\t\tvar timeout, timestamp;\n\t\t\t\tvar later = function() {\n\t\t\t\t\tvar last = (new Date()) - timestamp;\n\n\t\t\t\t\tif (last < wait) {\n\t\t\t\t\t\ttimeout = setTimeout(later, wait - last);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttimeout = null;\n\t\t\t\t\t\tfunc();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\treturn function() {\n\t\t\t\t\ttimestamp = new Date();\n\n\t\t\t\t\tif (!timeout) {\n\t\t\t\t\t\ttimeout = setTimeout(later, wait);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t};\n\t\t\tvar lastClientWidth = docElem.clientHeight;\n\t\t\tvar onResize = function() {\n\t\t\t\tisVwDirty = Math.max(window.innerWidth || 0, docElem.clientWidth) !== units.width || docElem.clientHeight !== lastClientWidth;\n\t\t\t\tlastClientWidth = docElem.clientHeight;\n\t\t\t\tif ( isVwDirty ) {\n\t\t\t\t\tpf.fillImgs();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ton( window, \"resize\", debounce(onResize, 99 ) );\n\t\t\ton( document, \"readystatechange\", run );\n\t\t})();\n\t}\n\n\tpf.picturefill = picturefill;\n\t//use this internally for easy monkey patching/performance testing\n\tpf.fillImgs = picturefill;\n\tpf.teardownRun = noop;\n\n\t/* expose methods for testing */\n\tpicturefill._ = pf;\n\n\twindow.picturefillCFG = {\n\t\tpf: pf,\n\t\tpush: function(args) {\n\t\t\tvar name = args.shift();\n\t\t\tif (typeof pf[name] === \"function\") {\n\t\t\t\tpf[name].apply(pf, args);\n\t\t\t} else {\n\t\t\t\tcfg[name] = args[0];\n\t\t\t\tif (alreadyRun) {\n\t\t\t\t\tpf.fillImgs( { reselect: true } );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\twhile (setOptions && setOptions.length) {\n\t\twindow.picturefillCFG.push(setOptions.shift());\n\t}\n\n\t/* expose picturefill */\n\twindow.picturefill = picturefill;\n\n\t/* expose picturefill */\n\tif ( typeof module === \"object\" && typeof module.exports === \"object\" ) {\n\t\t// CommonJS, just export\n\t\tmodule.exports = picturefill;\n\t} else if ( typeof define === \"function\" && define.amd ) {\n\t\t// AMD support\n\t\tdefine( \"picturefill\", function() { return picturefill; } );\n\t}\n\n\t// IE8 evals this sync, so it must be the last thing we do\n\tif ( !pf.supPicture ) {\n\t\ttypes[ \"image/webp\" ] = detectTypeSupport(\"image/webp\", \"data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA==\" );\n\t}\n\n} )( window, document );\n","/*! npm.im/object-fit-images 3.2.4 */\n'use strict';\n\nvar OFI = 'bfred-it:object-fit-images';\nvar propRegex = /(object-fit|object-position)\\s*:\\s*([-.\\w\\s%]+)/g;\nvar testImg = typeof Image === 'undefined' ? {style: {'object-position': 1}} : new Image();\nvar supportsObjectFit = 'object-fit' in testImg.style;\nvar supportsObjectPosition = 'object-position' in testImg.style;\nvar supportsOFI = 'background-size' in testImg.style;\nvar supportsCurrentSrc = typeof testImg.currentSrc === 'string';\nvar nativeGetAttribute = testImg.getAttribute;\nvar nativeSetAttribute = testImg.setAttribute;\nvar autoModeEnabled = false;\n\nfunction createPlaceholder(w, h) {\n\treturn (\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='\" + w + \"' height='\" + h + \"'%3E%3C/svg%3E\");\n}\n\nfunction polyfillCurrentSrc(el) {\n\tif (el.srcset && !supportsCurrentSrc && window.picturefill) {\n\t\tvar pf = window.picturefill._;\n\t\t// parse srcset with picturefill where currentSrc isn't available\n\t\tif (!el[pf.ns] || !el[pf.ns].evaled) {\n\t\t\t// force synchronous srcset parsing\n\t\t\tpf.fillImg(el, {reselect: true});\n\t\t}\n\n\t\tif (!el[pf.ns].curSrc) {\n\t\t\t// force picturefill to parse srcset\n\t\t\tel[pf.ns].supported = false;\n\t\t\tpf.fillImg(el, {reselect: true});\n\t\t}\n\n\t\t// retrieve parsed currentSrc, if any\n\t\tel.currentSrc = el[pf.ns].curSrc || el.src;\n\t}\n}\n\nfunction getStyle(el) {\n\tvar style = getComputedStyle(el).fontFamily;\n\tvar parsed;\n\tvar props = {};\n\twhile ((parsed = propRegex.exec(style)) !== null) {\n\t\tprops[parsed[1]] = parsed[2];\n\t}\n\treturn props;\n}\n\nfunction setPlaceholder(img, width, height) {\n\t// Default: fill width, no height\n\tvar placeholder = createPlaceholder(width || 1, height || 0);\n\n\t// Only set placeholder if it's different\n\tif (nativeGetAttribute.call(img, 'src') !== placeholder) {\n\t\tnativeSetAttribute.call(img, 'src', placeholder);\n\t}\n}\n\nfunction onImageReady(img, callback) {\n\t// naturalWidth is only available when the image headers are loaded,\n\t// this loop will poll it every 100ms.\n\tif (img.naturalWidth) {\n\t\tcallback(img);\n\t} else {\n\t\tsetTimeout(onImageReady, 100, img, callback);\n\t}\n}\n\nfunction fixOne(el) {\n\tvar style = getStyle(el);\n\tvar ofi = el[OFI];\n\tstyle['object-fit'] = style['object-fit'] || 'fill'; // default value\n\n\t// Avoid running where unnecessary, unless OFI had already done its deed\n\tif (!ofi.img) {\n\t\t// fill is the default behavior so no action is necessary\n\t\tif (style['object-fit'] === 'fill') {\n\t\t\treturn;\n\t\t}\n\n\t\t// Where object-fit is supported and object-position isn't (Safari < 10)\n\t\tif (\n\t\t\t!ofi.skipTest && // unless user wants to apply regardless of browser support\n\t\t\tsupportsObjectFit && // if browser already supports object-fit\n\t\t\t!style['object-position'] // unless object-position is used\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// keep a clone in memory while resetting the original to a blank\n\tif (!ofi.img) {\n\t\tofi.img = new Image(el.width, el.height);\n\t\tofi.img.srcset = nativeGetAttribute.call(el, \"data-ofi-srcset\") || el.srcset;\n\t\tofi.img.src = nativeGetAttribute.call(el, \"data-ofi-src\") || el.src;\n\n\t\t// preserve for any future cloneNode calls\n\t\t// https://github.com/bfred-it/object-fit-images/issues/53\n\t\tnativeSetAttribute.call(el, \"data-ofi-src\", el.src);\n\t\tif (el.srcset) {\n\t\t\tnativeSetAttribute.call(el, \"data-ofi-srcset\", el.srcset);\n\t\t}\n\n\t\tsetPlaceholder(el, el.naturalWidth || el.width, el.naturalHeight || el.height);\n\n\t\t// remove srcset because it overrides src\n\t\tif (el.srcset) {\n\t\t\tel.srcset = '';\n\t\t}\n\t\ttry {\n\t\t\tkeepSrcUsable(el);\n\t\t} catch (err) {\n\t\t\tif (window.console) {\n\t\t\t\tconsole.warn('https://bit.ly/ofi-old-browser');\n\t\t\t}\n\t\t}\n\t}\n\n\tpolyfillCurrentSrc(ofi.img);\n\n\tel.style.backgroundImage = \"url(\\\"\" + ((ofi.img.currentSrc || ofi.img.src).replace(/\"/g, '\\\\\"')) + \"\\\")\";\n\tel.style.backgroundPosition = style['object-position'] || 'center';\n\tel.style.backgroundRepeat = 'no-repeat';\n\tel.style.backgroundOrigin = 'content-box';\n\n\tif (/scale-down/.test(style['object-fit'])) {\n\t\tonImageReady(ofi.img, function () {\n\t\t\tif (ofi.img.naturalWidth > el.width || ofi.img.naturalHeight > el.height) {\n\t\t\t\tel.style.backgroundSize = 'contain';\n\t\t\t} else {\n\t\t\t\tel.style.backgroundSize = 'auto';\n\t\t\t}\n\t\t});\n\t} else {\n\t\tel.style.backgroundSize = style['object-fit'].replace('none', 'auto').replace('fill', '100% 100%');\n\t}\n\n\tonImageReady(ofi.img, function (img) {\n\t\tsetPlaceholder(el, img.naturalWidth, img.naturalHeight);\n\t});\n}\n\nfunction keepSrcUsable(el) {\n\tvar descriptors = {\n\t\tget: function get(prop) {\n\t\t\treturn el[OFI].img[prop ? prop : 'src'];\n\t\t},\n\t\tset: function set(value, prop) {\n\t\t\tel[OFI].img[prop ? prop : 'src'] = value;\n\t\t\tnativeSetAttribute.call(el, (\"data-ofi-\" + prop), value); // preserve for any future cloneNode\n\t\t\tfixOne(el);\n\t\t\treturn value;\n\t\t}\n\t};\n\tObject.defineProperty(el, 'src', descriptors);\n\tObject.defineProperty(el, 'currentSrc', {\n\t\tget: function () { return descriptors.get('currentSrc'); }\n\t});\n\tObject.defineProperty(el, 'srcset', {\n\t\tget: function () { return descriptors.get('srcset'); },\n\t\tset: function (ss) { return descriptors.set(ss, 'srcset'); }\n\t});\n}\n\nfunction hijackAttributes() {\n\tfunction getOfiImageMaybe(el, name) {\n\t\treturn el[OFI] && el[OFI].img && (name === 'src' || name === 'srcset') ? el[OFI].img : el;\n\t}\n\tif (!supportsObjectPosition) {\n\t\tHTMLImageElement.prototype.getAttribute = function (name) {\n\t\t\treturn nativeGetAttribute.call(getOfiImageMaybe(this, name), name);\n\t\t};\n\n\t\tHTMLImageElement.prototype.setAttribute = function (name, value) {\n\t\t\treturn nativeSetAttribute.call(getOfiImageMaybe(this, name), name, String(value));\n\t\t};\n\t}\n}\n\nfunction fix(imgs, opts) {\n\tvar startAutoMode = !autoModeEnabled && !imgs;\n\topts = opts || {};\n\timgs = imgs || 'img';\n\n\tif ((supportsObjectPosition && !opts.skipTest) || !supportsOFI) {\n\t\treturn false;\n\t}\n\n\t// use imgs as a selector or just select all images\n\tif (imgs === 'img') {\n\t\timgs = document.getElementsByTagName('img');\n\t} else if (typeof imgs === 'string') {\n\t\timgs = document.querySelectorAll(imgs);\n\t} else if (!('length' in imgs)) {\n\t\timgs = [imgs];\n\t}\n\n\t// apply fix to all\n\tfor (var i = 0; i < imgs.length; i++) {\n\t\timgs[i][OFI] = imgs[i][OFI] || {\n\t\t\tskipTest: opts.skipTest\n\t\t};\n\t\tfixOne(imgs[i]);\n\t}\n\n\tif (startAutoMode) {\n\t\tdocument.body.addEventListener('load', function (e) {\n\t\t\tif (e.target.tagName === 'IMG') {\n\t\t\t\tfix(e.target, {\n\t\t\t\t\tskipTest: opts.skipTest\n\t\t\t\t});\n\t\t\t}\n\t\t}, true);\n\t\tautoModeEnabled = true;\n\t\timgs = 'img'; // reset to a generic selector for watchMQ\n\t}\n\n\t// if requested, watch media queries for object-fit change\n\tif (opts.watchMQ) {\n\t\twindow.addEventListener('resize', fix.bind(null, imgs, {\n\t\t\tskipTest: opts.skipTest\n\t\t}));\n\t}\n}\n\nfix.supportsObjectFit = supportsObjectFit;\nfix.supportsObjectPosition = supportsObjectPosition;\n\nhijackAttributes();\n\nmodule.exports = fix;\n","/*----------------------------------------------------------------------------*\\\r\n Config\r\n All global settings for JS.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd = {};\r\n\r\nwindow.ggd.config = {\r\n mq: {\r\n 'palm': '(min-width: 0)',\r\n 'palm-large': '(min-width: 639px)',\r\n 'lap': '(min-width: 640px)',\r\n 'desk': '(min-width: 1024px)'\r\n }\r\n};\r\n","/*----------------------------------------------------------------------------*\\\r\n Masthead\r\n Functions for masthead.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.masthead = {\r\n init: function(){\r\n var self = this;\r\n var $mastheads = document.querySelectorAll('.js--masthead');\r\n self.$content = document.querySelector('.js--masthead__content');\r\n self.$footer = document.querySelector('.js--masthead__footer');\r\n\r\n for (var i = 0; i < $mastheads.length; ++i) {\r\n var $masthead = $mastheads[i];\r\n self.initMasthead($masthead);\r\n }\r\n },\r\n\r\n initMasthead: function ($masthead) {\r\n var self = this;\r\n\r\n var $triggers = $masthead.querySelector('.js--masthead__trigger');\r\n $triggers.setAttribute('aria-expanded', 'false');\r\n\r\n $triggers.addEventListener('click', function () {\r\n var $trigger = this;\r\n var $fold = self.getFold($masthead);\r\n self.toggleFold($masthead, $trigger, $fold);\r\n });\r\n },\r\n\r\n getFold: function ($masthead) {\r\n var $fold = $masthead.querySelector('.js--masthead__fold');\r\n return $fold;\r\n },\r\n\r\n toggleFold: function ($masthead, $trigger, $fold) {\r\n var self = this;\r\n var $menuLabel = $trigger.querySelector('.js--hamburger__flag');\r\n var menuLabelOpen = $menuLabel.getAttribute('data-hamburger-open');\r\n var menuLabelClose = $menuLabel.getAttribute('data-hamburger-close');\r\n\r\n if ($trigger.classList.contains('is-open')) {\r\n self.$content.inert = false;\r\n self.$footer.inert = false;\r\n $fold.classList.remove('is-animated-in');\r\n $trigger.classList.remove('is-open');\r\n $trigger.setAttribute('aria-expanded', 'false');\r\n $menuLabel.innerHTML = menuLabelOpen;\r\n\r\n document.removeEventListener('keydown', self.closeFoldOnEscape);\r\n document.removeEventListener('focusin', self.closeFoldOnTab);\r\n document.removeEventListener('click', self.closeFoldOnTab);\r\n\r\n setTimeout(function () {\r\n $fold.classList.remove('is-open');\r\n }, 1000);\r\n } else {\r\n self.$content.inert = true;\r\n self.$footer.inert = true;\r\n $fold.classList.add('is-open');\r\n\r\n setTimeout(function () {\r\n $fold.classList.add('is-animated-in');\r\n }, 1);\r\n\r\n $trigger.classList.add('is-open');\r\n $trigger.setAttribute('aria-expanded', 'true');\r\n $menuLabel.innerHTML = menuLabelClose;\r\n\r\n // add eventlistener to close the fold when pressing escape or tabbing outside the fold, remove listeners when fold is closed\r\n document.addEventListener('keydown', self.closeFoldOnEscape);\r\n document.addEventListener('focusin', self.closeFoldOnTab);\r\n document.addEventListener('click', self.closeFoldOnTab);\r\n }\r\n },\r\n\r\n closeFoldOnEscape: function (event) {\r\n if (event.key === 'Escape') {\r\n var $masthead = document.querySelector('.js--masthead');\r\n var $trigger = $masthead.querySelector('.js--masthead__trigger');\r\n var $fold = $masthead.querySelector('.js--masthead__fold');\r\n \r\n window.ggd.masthead.toggleFold($masthead, $trigger, $fold);\r\n }\r\n },\r\n closeFoldOnTab: function (event) {\r\n var $masthead = document.querySelector('.js--masthead');\r\n var $trigger = $masthead.querySelector('.js--masthead__trigger');\r\n var $fold = $masthead.querySelector('.js--masthead__fold');\r\n\r\n if (!$fold.contains(event.target) && !$trigger.contains(event.target)) {\r\n window.ggd.masthead.toggleFold($masthead, $trigger, $fold);\r\n }\r\n },\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.masthead.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Navigation\r\n Functions for nav elements.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.megamenu = {\r\n activeMenuItem: null,\r\n\r\n init: function(){\r\n this.initMegaMenu();\r\n },\r\n\r\n initMegaMenu: function () {\r\n var self = this;\r\n var $navTriggers = document.querySelectorAll('.js--nav-primary__trigger');\r\n\r\n for (var i = 0; i < $navTriggers.length; ++i) {\r\n var $navTrigger = $navTriggers[i];\r\n self.setupMegaMenu($navTrigger);\r\n }\r\n },\r\n\r\n setupMegaMenu: function ($navTrigger) {\r\n var self = this;\r\n\r\n $navTrigger.addEventListener('click', function(e) {\r\n // If screen larger then desk make link not clickable\r\n if (window.matchMedia(window.ggd.config.mq.desk).matches) {\r\n e.preventDefault();\r\n }\r\n\r\n var $navMegaMenuWrap = this.nextElementSibling;\r\n\r\n if ($navTrigger === self.activeMenuItem) {\r\n self.closeMegaMenu(self.activeMenuItem);\r\n window.ggd.shadow.closeShadow();\r\n } else {\r\n if (self.activeMenuItem) {\r\n self.closeMegaMenu(self.activeMenuItem);\r\n }\r\n\r\n self.openMegaMenu(this, $navMegaMenuWrap);\r\n }\r\n\r\n });\r\n },\r\n\r\n openMegaMenu: function ($navTrigger, $navMegaMenuWrap) {\r\n var self = this;\r\n\r\n // store active menu item\r\n self.activeMenuItem = $navTrigger;\r\n // Set active class on navtrigger.\r\n $navTrigger.classList.add('is-open');\r\n\r\n // Set active class on navtrigger.\r\n $navMegaMenuWrap.classList.add('is-open');\r\n $navMegaMenuWrap.classList.add('to-open');\r\n\r\n setTimeout(() => {\r\n $navMegaMenuWrap.classList.remove('to-open');\r\n }, 600);\r\n\r\n // Open shadow overlay\r\n window.ggd.shadow.openShadow();\r\n\r\n // Close searchbar if opened.\r\n if (window.ggd.search) {\r\n window.ggd.search.close();\r\n }\r\n\r\n // Set correct Aria rules.\r\n $navTrigger.setAttribute('aria-expanded', 'true');\r\n //add eventlististener to close menu on tab\r\n\r\n document.addEventListener('keydown', window.ggd.megamenu.handleTabOutsideMegaMenu, false);\r\n },\r\n\r\n handleTabOutsideMegaMenu: function (e) {\r\n const trigger = document.querySelector('.js--nav-primary__trigger.is-open');\r\n if (!e.target.closest('.js--nav-primary__trigger') && !e.target.closest('.js--nav-primary')) {\r\n window.ggd.megamenu.closeMegaMenu(trigger);\r\n window.ggd.shadow.closeShadow();\r\n document.removeEventListener('keydown', window.ggd.megamenu.handleTabOutsideMegaMenu, false);\r\n }\r\n },\r\n\r\n // Close Megamenu and close current active item.\r\n closeMegaMenu: function ($navTrigger) {\r\n var self = this;\r\n self.activeMenuItem = null;\r\n $navTrigger.classList.remove('is-open');\r\n $navTrigger.setAttribute('aria-expanded', 'false');\r\n // window.ggd.shadow.closeShadow();\r\n\r\n // Remove active class frome megamenu container.\r\n $navTrigger.nextElementSibling.classList.add('from-open');\r\n setTimeout(() => {\r\n $navTrigger.nextElementSibling.classList.remove('is-open');\r\n $navTrigger.nextElementSibling.classList.remove('from-open');\r\n }, 600);\r\n\r\n // window.ggd.shadow.removeActiveTrigger();\r\n },\r\n\r\n // Function to close all active menu items. Mainly used for calling from other functions.\r\n closeAllMenus: function () {\r\n var $navTriggers = [].slice.call(document.querySelectorAll('.js--nav-primary__trigger')) || [];\r\n\r\n $navTriggers.forEach(function($navTrigger) {\r\n if ($navTrigger.classList.contains('is-open')) {\r\n // Remove active class frome megamenu container.\r\n $navTrigger.nextElementSibling.classList.add('from-open');\r\n setTimeout(() => {\r\n $navTrigger.nextElementSibling.classList.remove('is-open');\r\n $navTrigger.nextElementSibling.classList.remove('from-open');\r\n }, 600);\r\n }\r\n\r\n // Remove is-open from all navTriggers.\r\n $navTrigger.classList.remove('is-open');\r\n\r\n // Set correct Aria rules.\r\n $navTrigger.setAttribute('aria-expanded', 'false');\r\n });\r\n }\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.megamenu.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Load more\r\n Loads new articles through a AJAX call.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.cookie = {\r\n createCookie: function (name, value, days) {\r\n // Create cookie\r\n var expires;\r\n\r\n if (days) {\r\n var date = new Date();\r\n date.setTime(date.getTime()+(days*24*60*60*1000));\r\n expires = '; expires='+date.toGMTString();\r\n }\r\n else {\r\n expires = '';\r\n }\r\n\r\n document.cookie = name+'='+value+expires+'; path=/';\r\n },\r\n\r\n readCookie: function (name) {\r\n var nameEQ = name + '=';\r\n var ca = document.cookie.split(';');\r\n\r\n for(var i=0;i < ca.length;i++) {\r\n var c = ca[i];\r\n\r\n while (c.charAt(0) === ' ') {\r\n c = c.substring(1,c.length);\r\n }\r\n\r\n if (c.indexOf(nameEQ) === 0) {\r\n return c.substring(nameEQ.length,c.length);\r\n }\r\n }\r\n return null;\r\n }\r\n};\r\n","/*----------------------------------------------------------------------------*\\\r\n Accordeon\r\n Simple, accessible accordeon\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.accordeon = {\r\n init: function(){\r\n this.initAccordeons();\r\n },\r\n\r\n initAccordeons: function () {\r\n var self = this;\r\n var $elements = document.querySelectorAll('.js--accordeon:not(.is-initialised)');\r\n\r\n for (var i = 0; i < $elements.length; ++i) {\r\n var $element = $elements[i];\r\n self.setupAccordeon($element);\r\n }\r\n },\r\n\r\n setupAccordeon: function ($accordeon) {\r\n var self = this;\r\n if(!$accordeon.classList.contains('is-initialised')) {\r\n self.setupToggles($accordeon);\r\n $accordeon.classList.add('is-initialised');\r\n }\r\n },\r\n\r\n setupToggles: function ($accordeon) {\r\n var self = this;\r\n var $toggles = $accordeon.querySelectorAll('.js--accordeon__toggle');\r\n\r\n for (var i = 0; i < $toggles.length; ++i) {\r\n var $toggle = $toggles[i];\r\n self.initToggle($accordeon, $toggle);\r\n }\r\n },\r\n\r\n initToggle: function ($accordeon, $toggle) {\r\n var $item = $toggle.closest('.js--accordeon__item');\r\n\r\n if ($item.classList.contains('is-open')) {\r\n $toggle.setAttribute('aria-expanded', 'true');\r\n } else {\r\n $toggle.setAttribute('aria-expanded', 'false');\r\n }\r\n\r\n\r\n\r\n $toggle.addEventListener('click', function () {\r\n if ($item.classList.contains('is-open')) {\r\n $item.classList.remove('is-open');\r\n $toggle.setAttribute('aria-expanded', 'false');\r\n } else {\r\n $item.classList.add('is-open');\r\n $toggle.setAttribute('aria-expanded', 'true');\r\n }\r\n });\r\n }\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.accordeon.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Maps\r\n Google Maps functions\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.maps = {\r\n init: function(){\r\n var self = this;\r\n var $mapContainers = document.querySelectorAll('.js--map');\r\n\r\n for (var i = 0; i < $mapContainers.length; ++i) {\r\n var $mapContainer = $mapContainers[i];\r\n self.initMaps($mapContainer);\r\n }\r\n },\r\n\r\n initMaps: function ($mapContainer) {\r\n var self = this,\r\n $map,\r\n $infoWindow = new window.google.maps.InfoWindow(),\r\n mapZoom = parseFloat($mapContainer.getAttribute('data-map-zoom')),\r\n mapLat = parseFloat($mapContainer.getAttribute('data-map-lat')),\r\n mapLong = parseFloat($mapContainer.getAttribute('data-map-long')),\r\n scrollToZoom = $mapContainer.getAttribute('data-map-scroll-to-zoom');\r\n\r\n if(typeof scrollToZoom === 'undefined' || scrollToZoom === null || scrollToZoom === '' ){\r\n scrollToZoom = 'true';\r\n }\r\n\r\n // Create Google Maps instance.\r\n $map = new window.google.maps.Map($mapContainer, {\r\n center: {\r\n lat: mapLat,\r\n lng: mapLong\r\n },\r\n zoom: mapZoom,\r\n scrollwheel: 'true' === scrollToZoom\r\n });\r\n\r\n // Get JSON file with Maps info.\r\n self.getJson($map, $infoWindow, $mapContainer);\r\n },\r\n\r\n // Add markers to Google maps.\r\n addMarkers: function ($map, $infoWindow, dataValues) {\r\n var self = this;\r\n var marker;\r\n\r\n var icon = {\r\n url: '/static/public/images/locationpin.png'\r\n };\r\n\r\n // Set longitude and latitude from JSON array.\r\n var longitude = parseFloat(dataValues.Longitude);\r\n var latitude = parseFloat(dataValues.Latitude);\r\n\r\n var location = {\r\n lat: latitude,\r\n lng: longitude\r\n };\r\n\r\n marker = new window.google.maps.Marker({\r\n position: location,\r\n map: $map,\r\n icon: icon\r\n });\r\n\r\n self.createInfoWindow($map, $infoWindow, marker, dataValues);\r\n\r\n // CURRENTLY NOT USING THIS FUNCTION, MAYBE IN A LATER STADIUM TO CLUSTER MARKERS.\r\n //self.setZoom($map, longitude, latitude, $boundBox);\r\n },\r\n\r\n // CURRENTLY NOT USING THIS FUNCTION, MAYBE IN A LATER STADIUM TO CLUSTER MARKERS.\r\n // Set the zoom to fit comfortably all the markers in the map\r\n /*setZoom: function (map, longitude, latitude, $boundBox) {\r\n $boundBox.extend(new google.maps.LatLng(latitude, longitude));\r\n\r\n // Don't zoom in too far on only one marker\r\n if ($boundBox.getNorthEast().equals($boundBox.getSouthWest())) {\r\n var extendPoint1 = new google.maps.LatLng($boundBox.getNorthEast().lat() + 0.01, $boundBox.getNorthEast().lng() + 0.01);\r\n var extendPoint2 = new google.maps.LatLng($boundBox.getNorthEast().lat() - 0.01, $boundBox.getNorthEast().lng() - 0.01);\r\n $boundBox.extend(extendPoint1);\r\n $boundBox.extend(extendPoint2);\r\n }\r\n\r\n map.setCenter($boundBox.getCenter());\r\n map.fitBounds($boundBox);\r\n },*/\r\n\r\n\r\n // Create info window when clicking on marker.\r\n createInfoWindow: function ($map, $infoWindow, marker, dataValues) {\r\n var contentString = '
'+\r\n '

'+ dataValues.City +'

' +\r\n '' +\r\n '' +\r\n '' +\r\n '' +\r\n 'Routebeschrijving' +\r\n '' +\r\n '' +\r\n 'Bekijk regio' +\r\n '' +\r\n '' +\r\n '' +\r\n '
';\r\n\r\n marker.addListener('click', function() {\r\n $infoWindow.setContent(contentString);\r\n $infoWindow.open($map, marker);\r\n });\r\n },\r\n\r\n // Get JSON with Maps info\r\n getJson: function ($map, $infoWindow, $mapContainer) {\r\n var self = this;\r\n var request = new XMLHttpRequest();\r\n var dataURL = $mapContainer.getAttribute('data-map-url');\r\n var singleJson = $mapContainer.getAttribute('data-single-clinic');\r\n\r\n if(typeof dataURL !== 'undefined' && dataURL !== null && dataURL !== '') {\r\n request.open('GET', dataURL, true);\r\n\r\n request.onload = function() {\r\n if (request.status >= 200 && request.status < 400) {\r\n // XML load succesfull\r\n var data = JSON.parse(request.responseText);\r\n\r\n // Loop trough all JSON data\r\n if (typeof data !== 'undefined' && data !== null) {\r\n for (var i = 0; i < data.length; i++) {\r\n var dataValues = data[i];\r\n\r\n self.addMarkers($map, $infoWindow, dataValues);\r\n }\r\n }\r\n }\r\n };\r\n\r\n request.onerror = function() {\r\n // There was a connection error of some sort\r\n };\r\n\r\n request.send();\r\n\r\n } else if(typeof singleJson !== 'undefined' && singleJson !== null && singleJson !== '') {\r\n var jsonValues = JSON.parse(singleJson);\r\n if(typeof jsonValues !== 'undefined' && jsonValues !== null){\r\n var dataValues = jsonValues[0];\r\n // check to make sure the map has a center\r\n if(isNaN($map.center.lat()) && isNaN($map.center.lng())){\r\n $map.setCenter({lat: parseFloat(dataValues.Latitude), lng: parseFloat(dataValues.Longitude)});\r\n }\r\n self.addMarkers($map, $infoWindow, dataValues);\r\n }\r\n }\r\n }\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.maps.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n ALERT\r\n JS for alert messages\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.alert = {\r\n init: function(){\r\n var self = this;\r\n var $elements = document.querySelectorAll('.js--alert');\r\n\r\n for (var i = 0; i < $elements.length; ++i) {\r\n var $element = $elements[i];\r\n self.initAlert($element);\r\n }\r\n },\r\n\r\n initAlert: function ($element) {\r\n var self = this;\r\n var $alertType = $element.getAttribute('data-alert');\r\n\r\n var cookielaw = window.ggd.cookie.readCookie($alertType);\r\n\r\n // Check if alert is already closed is in a cookie\r\n if (cookielaw !== $alertType) {\r\n $element.classList.add('is-visible');\r\n\r\n self.calcHeight($element, $alertType);\r\n document.querySelector('footer').style.marginBottom = $element.offsetHeight;\r\n }\r\n },\r\n\r\n calcHeight: function ($element, $alertType) {\r\n var self = this;\r\n\r\n $element.style.height = 'auto';\r\n var $alertHeight = $element.offsetHeight;\r\n\r\n $element.style.height = $alertHeight + 'px';\r\n\r\n self.closeAlert($element, $alertType);\r\n },\r\n\r\n closeAlert: function ($element, $alertType) {\r\n var $closeTriggers = $element.querySelectorAll('.js--alert-close');\r\n\r\n for (var i = 0; i < $closeTriggers.length; ++i) {\r\n var $closeTrigger = $closeTriggers[i];\r\n\r\n // Click on close button, close alert.\r\n $closeTrigger.addEventListener('click', function() {\r\n $element.hidden = true;\r\n // Check if alert is cookiebar, then set cookie for 1 year. If alert is not cookiebar then create session cookie.\r\n if (!this.classList.contains('js--alert-cookielaw')) {\r\n // Set 1 year cookie\r\n window.ggd.cookie.createCookie($alertType, $alertType, '');\r\n } else {\r\n // Set Session cookie\r\n window.ggd.cookie.createCookie($alertType, $alertType, 365);\r\n }\r\n });\r\n }\r\n }\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.alert.init();\r\n}, false);\r\n\r\nwindow.addEventListener('resize', function () {\r\n window.ggd.alert.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Forms\r\n All JS form form elements\r\n\\*----------------------------------------------------------------------------*/\r\n\r\n// import Pikaday from 'pikaday';\r\n\r\nwindow.ggd.forms = {\r\n init: function(){\r\n this.inputFile();\r\n },\r\n\r\n inputFile: function () {\r\n var $elements = document.querySelector('.js--input-file');\r\n\r\n if (!$elements) {\r\n return;\r\n }\r\n\r\n // Get input-file name\r\n $elements.querySelector('.js--input-file-mask').onchange = function () {\r\n $elements.querySelector('.js--input-file-text').value = this.files[0].name;\r\n };\r\n },\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.forms.init();\r\n}, false);\r\n","/**\n * EvEmitter v1.1.0\n * Lil' event emitter\n * MIT License\n */\n\n/* jshint unused: true, undef: true, strict: true */\n\n( function( global, factory ) {\n // universal module definition\n /* jshint strict: false */ /* globals define, module, window */\n if ( typeof define == 'function' && define.amd ) {\n // AMD - RequireJS\n define( factory );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS - Browserify, Webpack\n module.exports = factory();\n } else {\n // Browser globals\n global.EvEmitter = factory();\n }\n\n}( typeof window != 'undefined' ? window : this, function() {\n\n\"use strict\";\n\nfunction EvEmitter() {}\n\nvar proto = EvEmitter.prototype;\n\nproto.on = function( eventName, listener ) {\n if ( !eventName || !listener ) {\n return;\n }\n // set events hash\n var events = this._events = this._events || {};\n // set listeners array\n var listeners = events[ eventName ] = events[ eventName ] || [];\n // only add once\n if ( listeners.indexOf( listener ) == -1 ) {\n listeners.push( listener );\n }\n\n return this;\n};\n\nproto.once = function( eventName, listener ) {\n if ( !eventName || !listener ) {\n return;\n }\n // add event\n this.on( eventName, listener );\n // set once flag\n // set onceEvents hash\n var onceEvents = this._onceEvents = this._onceEvents || {};\n // set onceListeners object\n var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};\n // set flag\n onceListeners[ listener ] = true;\n\n return this;\n};\n\nproto.off = function( eventName, listener ) {\n var listeners = this._events && this._events[ eventName ];\n if ( !listeners || !listeners.length ) {\n return;\n }\n var index = listeners.indexOf( listener );\n if ( index != -1 ) {\n listeners.splice( index, 1 );\n }\n\n return this;\n};\n\nproto.emitEvent = function( eventName, args ) {\n var listeners = this._events && this._events[ eventName ];\n if ( !listeners || !listeners.length ) {\n return;\n }\n // copy over to avoid interference if .off() in listener\n listeners = listeners.slice(0);\n args = args || [];\n // once stuff\n var onceListeners = this._onceEvents && this._onceEvents[ eventName ];\n\n for ( var i=0; i < listeners.length; i++ ) {\n var listener = listeners[i]\n var isOnce = onceListeners && onceListeners[ listener ];\n if ( isOnce ) {\n // remove listener\n // remove before trigger to prevent recursion\n this.off( eventName, listener );\n // unset once flag\n delete onceListeners[ listener ];\n }\n // trigger listener\n listener.apply( this, args );\n }\n\n return this;\n};\n\nproto.allOff = function() {\n delete this._events;\n delete this._onceEvents;\n};\n\nreturn EvEmitter;\n\n}));\n","/*!\n * getSize v2.0.3\n * measure size of elements\n * MIT license\n */\n\n/* jshint browser: true, strict: true, undef: true, unused: true */\n/* globals console: false */\n\n( function( window, factory ) {\n /* jshint strict: false */ /* globals define, module */\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( factory );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory();\n } else {\n // browser global\n window.getSize = factory();\n }\n\n})( window, function factory() {\n'use strict';\n\n// -------------------------- helpers -------------------------- //\n\n// get a number from a string, not a percentage\nfunction getStyleSize( value ) {\n var num = parseFloat( value );\n // not a percent like '100%', and a number\n var isValid = value.indexOf('%') == -1 && !isNaN( num );\n return isValid && num;\n}\n\nfunction noop() {}\n\nvar logError = typeof console == 'undefined' ? noop :\n function( message ) {\n console.error( message );\n };\n\n// -------------------------- measurements -------------------------- //\n\nvar measurements = [\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'paddingBottom',\n 'marginLeft',\n 'marginRight',\n 'marginTop',\n 'marginBottom',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'borderTopWidth',\n 'borderBottomWidth'\n];\n\nvar measurementsLength = measurements.length;\n\nfunction getZeroSize() {\n var size = {\n width: 0,\n height: 0,\n innerWidth: 0,\n innerHeight: 0,\n outerWidth: 0,\n outerHeight: 0\n };\n for ( var i=0; i < measurementsLength; i++ ) {\n var measurement = measurements[i];\n size[ measurement ] = 0;\n }\n return size;\n}\n\n// -------------------------- getStyle -------------------------- //\n\n/**\n * getStyle, get style of element, check for Firefox bug\n * https://bugzilla.mozilla.org/show_bug.cgi?id=548397\n */\nfunction getStyle( elem ) {\n var style = getComputedStyle( elem );\n if ( !style ) {\n logError( 'Style returned ' + style +\n '. Are you running this code in a hidden iframe on Firefox? ' +\n 'See https://bit.ly/getsizebug1' );\n }\n return style;\n}\n\n// -------------------------- setup -------------------------- //\n\nvar isSetup = false;\n\nvar isBoxSizeOuter;\n\n/**\n * setup\n * check isBoxSizerOuter\n * do on first getSize() rather than on page load for Firefox bug\n */\nfunction setup() {\n // setup once\n if ( isSetup ) {\n return;\n }\n isSetup = true;\n\n // -------------------------- box sizing -------------------------- //\n\n /**\n * Chrome & Safari measure the outer-width on style.width on border-box elems\n * IE11 & Firefox<29 measures the inner-width\n */\n var div = document.createElement('div');\n div.style.width = '200px';\n div.style.padding = '1px 2px 3px 4px';\n div.style.borderStyle = 'solid';\n div.style.borderWidth = '1px 2px 3px 4px';\n div.style.boxSizing = 'border-box';\n\n var body = document.body || document.documentElement;\n body.appendChild( div );\n var style = getStyle( div );\n // round value for browser zoom. desandro/masonry#928\n isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;\n getSize.isBoxSizeOuter = isBoxSizeOuter;\n\n body.removeChild( div );\n}\n\n// -------------------------- getSize -------------------------- //\n\nfunction getSize( elem ) {\n setup();\n\n // use querySeletor if elem is string\n if ( typeof elem == 'string' ) {\n elem = document.querySelector( elem );\n }\n\n // do not proceed on non-objects\n if ( !elem || typeof elem != 'object' || !elem.nodeType ) {\n return;\n }\n\n var style = getStyle( elem );\n\n // if hidden, everything is 0\n if ( style.display == 'none' ) {\n return getZeroSize();\n }\n\n var size = {};\n size.width = elem.offsetWidth;\n size.height = elem.offsetHeight;\n\n var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';\n\n // get all measurements\n for ( var i=0; i < measurementsLength; i++ ) {\n var measurement = measurements[i];\n var value = style[ measurement ];\n var num = parseFloat( value );\n // any 'auto', 'medium' value will be 0\n size[ measurement ] = !isNaN( num ) ? num : 0;\n }\n\n var paddingWidth = size.paddingLeft + size.paddingRight;\n var paddingHeight = size.paddingTop + size.paddingBottom;\n var marginWidth = size.marginLeft + size.marginRight;\n var marginHeight = size.marginTop + size.marginBottom;\n var borderWidth = size.borderLeftWidth + size.borderRightWidth;\n var borderHeight = size.borderTopWidth + size.borderBottomWidth;\n\n var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;\n\n // overwrite width and height if we can get it from style\n var styleWidth = getStyleSize( style.width );\n if ( styleWidth !== false ) {\n size.width = styleWidth +\n // add padding and border unless it's already including it\n ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );\n }\n\n var styleHeight = getStyleSize( style.height );\n if ( styleHeight !== false ) {\n size.height = styleHeight +\n // add padding and border unless it's already including it\n ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );\n }\n\n size.innerWidth = size.width - ( paddingWidth + borderWidth );\n size.innerHeight = size.height - ( paddingHeight + borderHeight );\n\n size.outerWidth = size.width + marginWidth;\n size.outerHeight = size.height + marginHeight;\n\n return size;\n}\n\nreturn getSize;\n\n});\n","/**\n * matchesSelector v2.0.2\n * matchesSelector( element, '.selector' )\n * MIT license\n */\n\n/*jshint browser: true, strict: true, undef: true, unused: true */\n\n( function( window, factory ) {\n /*global define: false, module: false */\n 'use strict';\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( factory );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory();\n } else {\n // browser global\n window.matchesSelector = factory();\n }\n\n}( window, function factory() {\n 'use strict';\n\n var matchesMethod = ( function() {\n var ElemProto = window.Element.prototype;\n // check for the standard method name first\n if ( ElemProto.matches ) {\n return 'matches';\n }\n // check un-prefixed\n if ( ElemProto.matchesSelector ) {\n return 'matchesSelector';\n }\n // check vendor prefixes\n var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];\n\n for ( var i=0; i < prefixes.length; i++ ) {\n var prefix = prefixes[i];\n var method = prefix + 'MatchesSelector';\n if ( ElemProto[ method ] ) {\n return method;\n }\n }\n })();\n\n return function matchesSelector( elem, selector ) {\n return elem[ matchesMethod ]( selector );\n };\n\n}));\n","/**\n * Fizzy UI utils v2.0.7\n * MIT license\n */\n\n/*jshint browser: true, undef: true, unused: true, strict: true */\n\n( function( window, factory ) {\n // universal module definition\n /*jshint strict: false */ /*globals define, module, require */\n\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'desandro-matches-selector/matches-selector'\n ], function( matchesSelector ) {\n return factory( window, matchesSelector );\n });\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('desandro-matches-selector')\n );\n } else {\n // browser global\n window.fizzyUIUtils = factory(\n window,\n window.matchesSelector\n );\n }\n\n}( window, function factory( window, matchesSelector ) {\n\n'use strict';\n\nvar utils = {};\n\n// ----- extend ----- //\n\n// extends objects\nutils.extend = function( a, b ) {\n for ( var prop in b ) {\n a[ prop ] = b[ prop ];\n }\n return a;\n};\n\n// ----- modulo ----- //\n\nutils.modulo = function( num, div ) {\n return ( ( num % div ) + div ) % div;\n};\n\n// ----- makeArray ----- //\n\nvar arraySlice = Array.prototype.slice;\n\n// turn element or nodeList into an array\nutils.makeArray = function( obj ) {\n if ( Array.isArray( obj ) ) {\n // use object if already an array\n return obj;\n }\n // return empty array if undefined or null. #6\n if ( obj === null || obj === undefined ) {\n return [];\n }\n\n var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';\n if ( isArrayLike ) {\n // convert nodeList to array\n return arraySlice.call( obj );\n }\n\n // array of single index\n return [ obj ];\n};\n\n// ----- removeFrom ----- //\n\nutils.removeFrom = function( ary, obj ) {\n var index = ary.indexOf( obj );\n if ( index != -1 ) {\n ary.splice( index, 1 );\n }\n};\n\n// ----- getParent ----- //\n\nutils.getParent = function( elem, selector ) {\n while ( elem.parentNode && elem != document.body ) {\n elem = elem.parentNode;\n if ( matchesSelector( elem, selector ) ) {\n return elem;\n }\n }\n};\n\n// ----- getQueryElement ----- //\n\n// use element as selector string\nutils.getQueryElement = function( elem ) {\n if ( typeof elem == 'string' ) {\n return document.querySelector( elem );\n }\n return elem;\n};\n\n// ----- handleEvent ----- //\n\n// enable .ontype to trigger from .addEventListener( elem, 'type' )\nutils.handleEvent = function( event ) {\n var method = 'on' + event.type;\n if ( this[ method ] ) {\n this[ method ]( event );\n }\n};\n\n// ----- filterFindElements ----- //\n\nutils.filterFindElements = function( elems, selector ) {\n // make array of elems\n elems = utils.makeArray( elems );\n var ffElems = [];\n\n elems.forEach( function( elem ) {\n // check that elem is an actual element\n if ( !( elem instanceof HTMLElement ) ) {\n return;\n }\n // add elem if no selector\n if ( !selector ) {\n ffElems.push( elem );\n return;\n }\n // filter & find items if we have a selector\n // filter\n if ( matchesSelector( elem, selector ) ) {\n ffElems.push( elem );\n }\n // find children\n var childElems = elem.querySelectorAll( selector );\n // concat childElems to filterFound array\n for ( var i=0; i < childElems.length; i++ ) {\n ffElems.push( childElems[i] );\n }\n });\n\n return ffElems;\n};\n\n// ----- debounceMethod ----- //\n\nutils.debounceMethod = function( _class, methodName, threshold ) {\n threshold = threshold || 100;\n // original method\n var method = _class.prototype[ methodName ];\n var timeoutName = methodName + 'Timeout';\n\n _class.prototype[ methodName ] = function() {\n var timeout = this[ timeoutName ];\n clearTimeout( timeout );\n\n var args = arguments;\n var _this = this;\n this[ timeoutName ] = setTimeout( function() {\n method.apply( _this, args );\n delete _this[ timeoutName ];\n }, threshold );\n };\n};\n\n// ----- docReady ----- //\n\nutils.docReady = function( callback ) {\n var readyState = document.readyState;\n if ( readyState == 'complete' || readyState == 'interactive' ) {\n // do async to allow for other scripts to run. metafizzy/flickity#441\n setTimeout( callback );\n } else {\n document.addEventListener( 'DOMContentLoaded', callback );\n }\n};\n\n// ----- htmlInit ----- //\n\n// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/\nutils.toDashed = function( str ) {\n return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {\n return $1 + '-' + $2;\n }).toLowerCase();\n};\n\nvar console = window.console;\n/**\n * allow user to initialize classes via [data-namespace] or .js-namespace class\n * htmlInit( Widget, 'widgetName' )\n * options are parsed from data-namespace-options\n */\nutils.htmlInit = function( WidgetClass, namespace ) {\n utils.docReady( function() {\n var dashedNamespace = utils.toDashed( namespace );\n var dataAttr = 'data-' + dashedNamespace;\n var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );\n var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );\n var elems = utils.makeArray( dataAttrElems )\n .concat( utils.makeArray( jsDashElems ) );\n var dataOptionsAttr = dataAttr + '-options';\n var jQuery = window.jQuery;\n\n elems.forEach( function( elem ) {\n var attr = elem.getAttribute( dataAttr ) ||\n elem.getAttribute( dataOptionsAttr );\n var options;\n try {\n options = attr && JSON.parse( attr );\n } catch ( error ) {\n // log error, do not initialize\n if ( console ) {\n console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +\n ': ' + error );\n }\n return;\n }\n // initialize\n var instance = new WidgetClass( elem, options );\n // make available via $().data('namespace')\n if ( jQuery ) {\n jQuery.data( elem, namespace, instance );\n }\n });\n\n });\n};\n\n// ----- ----- //\n\nreturn utils;\n\n}));\n","// Flickity.Cell\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'get-size/get-size',\n ], function( getSize ) {\n return factory( window, getSize );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('get-size')\n );\n } else {\n // browser global\n window.Flickity = window.Flickity || {};\n window.Flickity.Cell = factory(\n window,\n window.getSize\n );\n }\n\n}( window, function factory( window, getSize ) {\n\n'use strict';\n\nfunction Cell( elem, parent ) {\n this.element = elem;\n this.parent = parent;\n\n this.create();\n}\n\nvar proto = Cell.prototype;\n\nproto.create = function() {\n this.element.style.position = 'absolute';\n this.element.setAttribute( 'aria-hidden', 'true' );\n this.x = 0;\n this.shift = 0;\n this.element.style[ this.parent.originSide ] = 0;\n};\n\nproto.destroy = function() {\n // reset style\n this.unselect();\n this.element.style.position = '';\n var side = this.parent.originSide;\n this.element.style[ side ] = '';\n this.element.style.transform = '';\n this.element.removeAttribute('aria-hidden');\n};\n\nproto.getSize = function() {\n this.size = getSize( this.element );\n};\n\nproto.setPosition = function( x ) {\n this.x = x;\n this.updateTarget();\n this.renderPosition( x );\n};\n\n// setDefaultTarget v1 method, backwards compatibility, remove in v3\nproto.updateTarget = proto.setDefaultTarget = function() {\n var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';\n this.target = this.x + this.size[ marginProperty ] +\n this.size.width * this.parent.cellAlign;\n};\n\nproto.renderPosition = function( x ) {\n // render position of cell with in slider\n var sideOffset = this.parent.originSide === 'left' ? 1 : -1;\n\n var adjustedX = this.parent.options.percentPosition ?\n x * sideOffset * ( this.parent.size.innerWidth / this.size.width ) :\n x * sideOffset;\n\n this.element.style.transform = 'translateX(' +\n this.parent.getPositionValue( adjustedX ) + ')';\n};\n\nproto.select = function() {\n this.element.classList.add('is-selected');\n this.element.removeAttribute('aria-hidden');\n};\n\nproto.unselect = function() {\n this.element.classList.remove('is-selected');\n this.element.setAttribute( 'aria-hidden', 'true' );\n};\n\n/**\n * @param {Integer} shift - 0, 1, or -1\n */\nproto.wrapShift = function( shift ) {\n this.shift = shift;\n this.renderPosition( this.x + this.parent.slideableWidth * shift );\n};\n\nproto.remove = function() {\n this.element.parentNode.removeChild( this.element );\n};\n\nreturn Cell;\n\n} ) );\n","// slide\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( factory );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory();\n } else {\n // browser global\n window.Flickity = window.Flickity || {};\n window.Flickity.Slide = factory();\n }\n\n}( window, function factory() {\n'use strict';\n\nfunction Slide( parent ) {\n this.parent = parent;\n this.isOriginLeft = parent.originSide == 'left';\n this.cells = [];\n this.outerWidth = 0;\n this.height = 0;\n}\n\nvar proto = Slide.prototype;\n\nproto.addCell = function( cell ) {\n this.cells.push( cell );\n this.outerWidth += cell.size.outerWidth;\n this.height = Math.max( cell.size.outerHeight, this.height );\n // first cell stuff\n if ( this.cells.length == 1 ) {\n this.x = cell.x; // x comes from first cell\n var beginMargin = this.isOriginLeft ? 'marginLeft' : 'marginRight';\n this.firstMargin = cell.size[ beginMargin ];\n }\n};\n\nproto.updateTarget = function() {\n var endMargin = this.isOriginLeft ? 'marginRight' : 'marginLeft';\n var lastCell = this.getLastCell();\n var lastMargin = lastCell ? lastCell.size[ endMargin ] : 0;\n var slideWidth = this.outerWidth - ( this.firstMargin + lastMargin );\n this.target = this.x + this.firstMargin + slideWidth * this.parent.cellAlign;\n};\n\nproto.getLastCell = function() {\n return this.cells[ this.cells.length - 1 ];\n};\n\nproto.select = function() {\n this.cells.forEach( function( cell ) {\n cell.select();\n } );\n};\n\nproto.unselect = function() {\n this.cells.forEach( function( cell ) {\n cell.unselect();\n } );\n};\n\nproto.getCellElements = function() {\n return this.cells.map( function( cell ) {\n return cell.element;\n } );\n};\n\nreturn Slide;\n\n} ) );\n","// animate\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'fizzy-ui-utils/utils',\n ], function( utils ) {\n return factory( window, utils );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n window.Flickity = window.Flickity || {};\n window.Flickity.animatePrototype = factory(\n window,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, utils ) {\n\n'use strict';\n\n// -------------------------- animate -------------------------- //\n\nvar proto = {};\n\nproto.startAnimation = function() {\n if ( this.isAnimating ) {\n return;\n }\n\n this.isAnimating = true;\n this.restingFrames = 0;\n this.animate();\n};\n\nproto.animate = function() {\n this.applyDragForce();\n this.applySelectedAttraction();\n\n var previousX = this.x;\n\n this.integratePhysics();\n this.positionSlider();\n this.settle( previousX );\n // animate next frame\n if ( this.isAnimating ) {\n var _this = this;\n requestAnimationFrame( function animateFrame() {\n _this.animate();\n } );\n }\n};\n\nproto.positionSlider = function() {\n var x = this.x;\n // wrap position around\n if ( this.options.wrapAround && this.cells.length > 1 ) {\n x = utils.modulo( x, this.slideableWidth );\n x -= this.slideableWidth;\n this.shiftWrapCells( x );\n }\n\n this.setTranslateX( x, this.isAnimating );\n this.dispatchScrollEvent();\n};\n\nproto.setTranslateX = function( x, is3d ) {\n x += this.cursorPosition;\n // reverse if right-to-left and using transform\n x = this.options.rightToLeft ? -x : x;\n var translateX = this.getPositionValue( x );\n // use 3D transforms for hardware acceleration on iOS\n // but use 2D when settled, for better font-rendering\n this.slider.style.transform = is3d ?\n 'translate3d(' + translateX + ',0,0)' : 'translateX(' + translateX + ')';\n};\n\nproto.dispatchScrollEvent = function() {\n var firstSlide = this.slides[0];\n if ( !firstSlide ) {\n return;\n }\n var positionX = -this.x - firstSlide.target;\n var progress = positionX / this.slidesWidth;\n this.dispatchEvent( 'scroll', null, [ progress, positionX ] );\n};\n\nproto.positionSliderAtSelected = function() {\n if ( !this.cells.length ) {\n return;\n }\n this.x = -this.selectedSlide.target;\n this.velocity = 0; // stop wobble\n this.positionSlider();\n};\n\nproto.getPositionValue = function( position ) {\n if ( this.options.percentPosition ) {\n // percent position, round to 2 digits, like 12.34%\n return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 ) + '%';\n } else {\n // pixel positioning\n return Math.round( position ) + 'px';\n }\n};\n\nproto.settle = function( previousX ) {\n // keep track of frames where x hasn't moved\n var isResting = !this.isPointerDown &&\n Math.round( this.x * 100 ) == Math.round( previousX * 100 );\n if ( isResting ) {\n this.restingFrames++;\n }\n // stop animating if resting for 3 or more frames\n if ( this.restingFrames > 2 ) {\n this.isAnimating = false;\n delete this.isFreeScrolling;\n // render position with translateX when settled\n this.positionSlider();\n this.dispatchEvent( 'settle', null, [ this.selectedIndex ] );\n }\n};\n\nproto.shiftWrapCells = function( x ) {\n // shift before cells\n var beforeGap = this.cursorPosition + x;\n this._shiftCells( this.beforeShiftCells, beforeGap, -1 );\n // shift after cells\n var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition );\n this._shiftCells( this.afterShiftCells, afterGap, 1 );\n};\n\nproto._shiftCells = function( cells, gap, shift ) {\n for ( var i = 0; i < cells.length; i++ ) {\n var cell = cells[i];\n var cellShift = gap > 0 ? shift : 0;\n cell.wrapShift( cellShift );\n gap -= cell.size.outerWidth;\n }\n};\n\nproto._unshiftCells = function( cells ) {\n if ( !cells || !cells.length ) {\n return;\n }\n for ( var i = 0; i < cells.length; i++ ) {\n cells[i].wrapShift( 0 );\n }\n};\n\n// -------------------------- physics -------------------------- //\n\nproto.integratePhysics = function() {\n this.x += this.velocity;\n this.velocity *= this.getFrictionFactor();\n};\n\nproto.applyForce = function( force ) {\n this.velocity += force;\n};\n\nproto.getFrictionFactor = function() {\n return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ];\n};\n\nproto.getRestingPosition = function() {\n // my thanks to Steven Wittens, who simplified this math greatly\n return this.x + this.velocity / ( 1 - this.getFrictionFactor() );\n};\n\nproto.applyDragForce = function() {\n if ( !this.isDraggable || !this.isPointerDown ) {\n return;\n }\n // change the position to drag position by applying force\n var dragVelocity = this.dragX - this.x;\n var dragForce = dragVelocity - this.velocity;\n this.applyForce( dragForce );\n};\n\nproto.applySelectedAttraction = function() {\n // do not attract if pointer down or no slides\n var dragDown = this.isDraggable && this.isPointerDown;\n if ( dragDown || this.isFreeScrolling || !this.slides.length ) {\n return;\n }\n var distance = this.selectedSlide.target * -1 - this.x;\n var force = distance * this.options.selectedAttraction;\n this.applyForce( force );\n};\n\nreturn proto;\n\n} ) );\n","// Flickity main\n/* eslint-disable max-params */\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'ev-emitter/ev-emitter',\n 'get-size/get-size',\n 'fizzy-ui-utils/utils',\n './cell',\n './slide',\n './animate',\n ], function( EvEmitter, getSize, utils, Cell, Slide, animatePrototype ) {\n return factory( window, EvEmitter, getSize, utils, Cell, Slide, animatePrototype );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('ev-emitter'),\n require('get-size'),\n require('fizzy-ui-utils'),\n require('./cell'),\n require('./slide'),\n require('./animate')\n );\n } else {\n // browser global\n var _Flickity = window.Flickity;\n\n window.Flickity = factory(\n window,\n window.EvEmitter,\n window.getSize,\n window.fizzyUIUtils,\n _Flickity.Cell,\n _Flickity.Slide,\n _Flickity.animatePrototype\n );\n }\n\n}( window, function factory( window, EvEmitter, getSize,\n utils, Cell, Slide, animatePrototype ) {\n\n/* eslint-enable max-params */\n'use strict';\n\n// vars\nvar jQuery = window.jQuery;\nvar getComputedStyle = window.getComputedStyle;\nvar console = window.console;\n\nfunction moveElements( elems, toElem ) {\n elems = utils.makeArray( elems );\n while ( elems.length ) {\n toElem.appendChild( elems.shift() );\n }\n}\n\n// -------------------------- Flickity -------------------------- //\n\n// globally unique identifiers\nvar GUID = 0;\n// internal store of all Flickity intances\nvar instances = {};\n\nfunction Flickity( element, options ) {\n var queryElement = utils.getQueryElement( element );\n if ( !queryElement ) {\n if ( console ) {\n console.error( 'Bad element for Flickity: ' + ( queryElement || element ) );\n }\n return;\n }\n this.element = queryElement;\n // do not initialize twice on same element\n if ( this.element.flickityGUID ) {\n var instance = instances[ this.element.flickityGUID ];\n if ( instance ) instance.option( options );\n return instance;\n }\n\n // add jQuery\n if ( jQuery ) {\n this.$element = jQuery( this.element );\n }\n // options\n this.options = utils.extend( {}, this.constructor.defaults );\n this.option( options );\n\n // kick things off\n this._create();\n}\n\nFlickity.defaults = {\n accessibility: true,\n // adaptiveHeight: false,\n cellAlign: 'center',\n // cellSelector: undefined,\n // contain: false,\n freeScrollFriction: 0.075, // friction when free-scrolling\n friction: 0.28, // friction when selecting\n namespaceJQueryEvents: true,\n // initialIndex: 0,\n percentPosition: true,\n resize: true,\n selectedAttraction: 0.025,\n setGallerySize: true,\n // watchCSS: false,\n // wrapAround: false\n};\n\n// hash of methods triggered on _create()\nFlickity.createMethods = [];\n\nvar proto = Flickity.prototype;\n// inherit EventEmitter\nutils.extend( proto, EvEmitter.prototype );\n\nproto._create = function() {\n // add id for Flickity.data\n var id = this.guid = ++GUID;\n this.element.flickityGUID = id; // expando\n instances[ id ] = this; // associate via id\n // initial properties\n this.selectedIndex = 0;\n // how many frames slider has been in same position\n this.restingFrames = 0;\n // initial physics properties\n this.x = 0;\n this.velocity = 0;\n this.originSide = this.options.rightToLeft ? 'right' : 'left';\n // create viewport & slider\n this.viewport = document.createElement('div');\n this.viewport.className = 'flickity-viewport';\n this._createSlider();\n\n if ( this.options.resize || this.options.watchCSS ) {\n window.addEventListener( 'resize', this );\n }\n\n // add listeners from on option\n for ( var eventName in this.options.on ) {\n var listener = this.options.on[ eventName ];\n this.on( eventName, listener );\n }\n\n Flickity.createMethods.forEach( function( method ) {\n this[ method ]();\n }, this );\n\n if ( this.options.watchCSS ) {\n this.watchCSS();\n } else {\n this.activate();\n }\n\n};\n\n/**\n * set options\n * @param {Object} opts - options to extend\n */\nproto.option = function( opts ) {\n utils.extend( this.options, opts );\n};\n\nproto.activate = function() {\n if ( this.isActive ) {\n return;\n }\n this.isActive = true;\n this.element.classList.add('flickity-enabled');\n if ( this.options.rightToLeft ) {\n this.element.classList.add('flickity-rtl');\n }\n\n this.getSize();\n // move initial cell elements so they can be loaded as cells\n var cellElems = this._filterFindCellElements( this.element.children );\n moveElements( cellElems, this.slider );\n this.viewport.appendChild( this.slider );\n this.element.appendChild( this.viewport );\n // get cells from children\n this.reloadCells();\n\n if ( this.options.accessibility ) {\n // allow element to focusable\n this.element.tabIndex = 0;\n // listen for key presses\n this.element.addEventListener( 'keydown', this );\n }\n\n this.emitEvent('activate');\n this.selectInitialIndex();\n // flag for initial activation, for using initialIndex\n this.isInitActivated = true;\n // ready event. #493\n this.dispatchEvent('ready');\n};\n\n// slider positions the cells\nproto._createSlider = function() {\n // slider element does all the positioning\n var slider = document.createElement('div');\n slider.className = 'flickity-slider';\n slider.style[ this.originSide ] = 0;\n this.slider = slider;\n};\n\nproto._filterFindCellElements = function( elems ) {\n return utils.filterFindElements( elems, this.options.cellSelector );\n};\n\n// goes through all children\nproto.reloadCells = function() {\n // collection of item elements\n this.cells = this._makeCells( this.slider.children );\n this.positionCells();\n this._getWrapShiftCells();\n this.setGallerySize();\n};\n\n/**\n * turn elements into Flickity.Cells\n * @param {[Array, NodeList, HTMLElement]} elems - elements to make into cells\n * @returns {Array} items - collection of new Flickity Cells\n */\nproto._makeCells = function( elems ) {\n var cellElems = this._filterFindCellElements( elems );\n\n // create new Flickity for collection\n var cells = cellElems.map( function( cellElem ) {\n return new Cell( cellElem, this );\n }, this );\n\n return cells;\n};\n\nproto.getLastCell = function() {\n return this.cells[ this.cells.length - 1 ];\n};\n\nproto.getLastSlide = function() {\n return this.slides[ this.slides.length - 1 ];\n};\n\n// positions all cells\nproto.positionCells = function() {\n // size all cells\n this._sizeCells( this.cells );\n // position all cells\n this._positionCells( 0 );\n};\n\n/**\n * position certain cells\n * @param {Integer} index - which cell to start with\n */\nproto._positionCells = function( index ) {\n index = index || 0;\n // also measure maxCellHeight\n // start 0 if positioning all cells\n this.maxCellHeight = index ? this.maxCellHeight || 0 : 0;\n var cellX = 0;\n // get cellX\n if ( index > 0 ) {\n var startCell = this.cells[ index - 1 ];\n cellX = startCell.x + startCell.size.outerWidth;\n }\n var len = this.cells.length;\n for ( var i = index; i < len; i++ ) {\n var cell = this.cells[i];\n cell.setPosition( cellX );\n cellX += cell.size.outerWidth;\n this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight );\n }\n // keep track of cellX for wrap-around\n this.slideableWidth = cellX;\n // slides\n this.updateSlides();\n // contain slides target\n this._containSlides();\n // update slidesWidth\n this.slidesWidth = len ? this.getLastSlide().target - this.slides[0].target : 0;\n};\n\n/**\n * cell.getSize() on multiple cells\n * @param {Array} cells - cells to size\n */\nproto._sizeCells = function( cells ) {\n cells.forEach( function( cell ) {\n cell.getSize();\n } );\n};\n\n// -------------------------- -------------------------- //\n\nproto.updateSlides = function() {\n this.slides = [];\n if ( !this.cells.length ) {\n return;\n }\n\n var slide = new Slide( this );\n this.slides.push( slide );\n var isOriginLeft = this.originSide == 'left';\n var nextMargin = isOriginLeft ? 'marginRight' : 'marginLeft';\n\n var canCellFit = this._getCanCellFit();\n\n this.cells.forEach( function( cell, i ) {\n // just add cell if first cell in slide\n if ( !slide.cells.length ) {\n slide.addCell( cell );\n return;\n }\n\n var slideWidth = ( slide.outerWidth - slide.firstMargin ) +\n ( cell.size.outerWidth - cell.size[ nextMargin ] );\n\n if ( canCellFit.call( this, i, slideWidth ) ) {\n slide.addCell( cell );\n } else {\n // doesn't fit, new slide\n slide.updateTarget();\n\n slide = new Slide( this );\n this.slides.push( slide );\n slide.addCell( cell );\n }\n }, this );\n // last slide\n slide.updateTarget();\n // update .selectedSlide\n this.updateSelectedSlide();\n};\n\nproto._getCanCellFit = function() {\n var groupCells = this.options.groupCells;\n if ( !groupCells ) {\n return function() {\n return false;\n };\n } else if ( typeof groupCells == 'number' ) {\n // group by number. 3 -> [0,1,2], [3,4,5], ...\n var number = parseInt( groupCells, 10 );\n return function( i ) {\n return ( i % number ) !== 0;\n };\n }\n // default, group by width of slide\n // parse '75%\n var percentMatch = typeof groupCells == 'string' &&\n groupCells.match( /^(\\d+)%$/ );\n var percent = percentMatch ? parseInt( percentMatch[1], 10 ) / 100 : 1;\n return function( i, slideWidth ) {\n /* eslint-disable-next-line no-invalid-this */\n return slideWidth <= ( this.size.innerWidth + 1 ) * percent;\n };\n};\n\n// alias _init for jQuery plugin .flickity()\nproto._init =\nproto.reposition = function() {\n this.positionCells();\n this.positionSliderAtSelected();\n};\n\nproto.getSize = function() {\n this.size = getSize( this.element );\n this.setCellAlign();\n this.cursorPosition = this.size.innerWidth * this.cellAlign;\n};\n\nvar cellAlignShorthands = {\n // cell align, then based on origin side\n center: {\n left: 0.5,\n right: 0.5,\n },\n left: {\n left: 0,\n right: 1,\n },\n right: {\n right: 0,\n left: 1,\n },\n};\n\nproto.setCellAlign = function() {\n var shorthand = cellAlignShorthands[ this.options.cellAlign ];\n this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign;\n};\n\nproto.setGallerySize = function() {\n if ( this.options.setGallerySize ) {\n var height = this.options.adaptiveHeight && this.selectedSlide ?\n this.selectedSlide.height : this.maxCellHeight;\n this.viewport.style.height = height + 'px';\n }\n};\n\nproto._getWrapShiftCells = function() {\n // only for wrap-around\n if ( !this.options.wrapAround ) {\n return;\n }\n // unshift previous cells\n this._unshiftCells( this.beforeShiftCells );\n this._unshiftCells( this.afterShiftCells );\n // get before cells\n // initial gap\n var gapX = this.cursorPosition;\n var cellIndex = this.cells.length - 1;\n this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 );\n // get after cells\n // ending gap between last cell and end of gallery viewport\n gapX = this.size.innerWidth - this.cursorPosition;\n // start cloning at first cell, working forwards\n this.afterShiftCells = this._getGapCells( gapX, 0, 1 );\n};\n\nproto._getGapCells = function( gapX, cellIndex, increment ) {\n // keep adding cells until the cover the initial gap\n var cells = [];\n while ( gapX > 0 ) {\n var cell = this.cells[ cellIndex ];\n if ( !cell ) {\n break;\n }\n cells.push( cell );\n cellIndex += increment;\n gapX -= cell.size.outerWidth;\n }\n return cells;\n};\n\n// ----- contain ----- //\n\n// contain cell targets so no excess sliding\nproto._containSlides = function() {\n if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) {\n return;\n }\n var isRightToLeft = this.options.rightToLeft;\n var beginMargin = isRightToLeft ? 'marginRight' : 'marginLeft';\n var endMargin = isRightToLeft ? 'marginLeft' : 'marginRight';\n var contentWidth = this.slideableWidth - this.getLastCell().size[ endMargin ];\n // content is less than gallery size\n var isContentSmaller = contentWidth < this.size.innerWidth;\n // bounds\n var beginBound = this.cursorPosition + this.cells[0].size[ beginMargin ];\n var endBound = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign );\n // contain each cell target\n this.slides.forEach( function( slide ) {\n if ( isContentSmaller ) {\n // all cells fit inside gallery\n slide.target = contentWidth * this.cellAlign;\n } else {\n // contain to bounds\n slide.target = Math.max( slide.target, beginBound );\n slide.target = Math.min( slide.target, endBound );\n }\n }, this );\n};\n\n// ----- ----- //\n\n/**\n * emits events via eventEmitter and jQuery events\n * @param {String} type - name of event\n * @param {Event} event - original event\n * @param {Array} args - extra arguments\n */\nproto.dispatchEvent = function( type, event, args ) {\n var emitArgs = event ? [ event ].concat( args ) : args;\n this.emitEvent( type, emitArgs );\n\n if ( jQuery && this.$element ) {\n // default trigger with type if no event\n type += this.options.namespaceJQueryEvents ? '.flickity' : '';\n var $event = type;\n if ( event ) {\n // create jQuery event\n var jQEvent = new jQuery.Event( event );\n jQEvent.type = type;\n $event = jQEvent;\n }\n this.$element.trigger( $event, args );\n }\n};\n\n// -------------------------- select -------------------------- //\n\n/**\n * @param {Integer} index - index of the slide\n * @param {Boolean} isWrap - will wrap-around to last/first if at the end\n * @param {Boolean} isInstant - will immediately set position at selected cell\n */\nproto.select = function( index, isWrap, isInstant ) {\n if ( !this.isActive ) {\n return;\n }\n index = parseInt( index, 10 );\n this._wrapSelect( index );\n\n if ( this.options.wrapAround || isWrap ) {\n index = utils.modulo( index, this.slides.length );\n }\n // bail if invalid index\n if ( !this.slides[ index ] ) {\n return;\n }\n var prevIndex = this.selectedIndex;\n this.selectedIndex = index;\n this.updateSelectedSlide();\n if ( isInstant ) {\n this.positionSliderAtSelected();\n } else {\n this.startAnimation();\n }\n if ( this.options.adaptiveHeight ) {\n this.setGallerySize();\n }\n // events\n this.dispatchEvent( 'select', null, [ index ] );\n // change event if new index\n if ( index != prevIndex ) {\n this.dispatchEvent( 'change', null, [ index ] );\n }\n // old v1 event name, remove in v3\n this.dispatchEvent('cellSelect');\n};\n\n// wraps position for wrapAround, to move to closest slide. #113\nproto._wrapSelect = function( index ) {\n var len = this.slides.length;\n var isWrapping = this.options.wrapAround && len > 1;\n if ( !isWrapping ) {\n return index;\n }\n var wrapIndex = utils.modulo( index, len );\n // go to shortest\n var delta = Math.abs( wrapIndex - this.selectedIndex );\n var backWrapDelta = Math.abs( ( wrapIndex + len ) - this.selectedIndex );\n var forewardWrapDelta = Math.abs( ( wrapIndex - len ) - this.selectedIndex );\n if ( !this.isDragSelect && backWrapDelta < delta ) {\n index += len;\n } else if ( !this.isDragSelect && forewardWrapDelta < delta ) {\n index -= len;\n }\n // wrap position so slider is within normal area\n if ( index < 0 ) {\n this.x -= this.slideableWidth;\n } else if ( index >= len ) {\n this.x += this.slideableWidth;\n }\n};\n\nproto.previous = function( isWrap, isInstant ) {\n this.select( this.selectedIndex - 1, isWrap, isInstant );\n};\n\nproto.next = function( isWrap, isInstant ) {\n this.select( this.selectedIndex + 1, isWrap, isInstant );\n};\n\nproto.updateSelectedSlide = function() {\n var slide = this.slides[ this.selectedIndex ];\n // selectedIndex could be outside of slides, if triggered before resize()\n if ( !slide ) {\n return;\n }\n // unselect previous selected slide\n this.unselectSelectedSlide();\n // update new selected slide\n this.selectedSlide = slide;\n slide.select();\n this.selectedCells = slide.cells;\n this.selectedElements = slide.getCellElements();\n // HACK: selectedCell & selectedElement is first cell in slide, backwards compatibility\n // Remove in v3?\n this.selectedCell = slide.cells[0];\n this.selectedElement = this.selectedElements[0];\n};\n\nproto.unselectSelectedSlide = function() {\n if ( this.selectedSlide ) {\n this.selectedSlide.unselect();\n }\n};\n\nproto.selectInitialIndex = function() {\n var initialIndex = this.options.initialIndex;\n // already activated, select previous selectedIndex\n if ( this.isInitActivated ) {\n this.select( this.selectedIndex, false, true );\n return;\n }\n // select with selector string\n if ( initialIndex && typeof initialIndex == 'string' ) {\n var cell = this.queryCell( initialIndex );\n if ( cell ) {\n this.selectCell( initialIndex, false, true );\n return;\n }\n }\n\n var index = 0;\n // select with number\n if ( initialIndex && this.slides[ initialIndex ] ) {\n index = initialIndex;\n }\n // select instantly\n this.select( index, false, true );\n};\n\n/**\n * select slide from number or cell element\n * @param {[Element, Number]} value - zero-based index or element to select\n * @param {Boolean} isWrap - enables wrapping around for extra index\n * @param {Boolean} isInstant - disables slide animation\n */\nproto.selectCell = function( value, isWrap, isInstant ) {\n // get cell\n var cell = this.queryCell( value );\n if ( !cell ) {\n return;\n }\n\n var index = this.getCellSlideIndex( cell );\n this.select( index, isWrap, isInstant );\n};\n\nproto.getCellSlideIndex = function( cell ) {\n // get index of slides that has cell\n for ( var i = 0; i < this.slides.length; i++ ) {\n var slide = this.slides[i];\n var index = slide.cells.indexOf( cell );\n if ( index != -1 ) {\n return i;\n }\n }\n};\n\n// -------------------------- get cells -------------------------- //\n\n/**\n * get Flickity.Cell, given an Element\n * @param {Element} elem - matching cell element\n * @returns {Flickity.Cell} cell - matching cell\n */\nproto.getCell = function( elem ) {\n // loop through cells to get the one that matches\n for ( var i = 0; i < this.cells.length; i++ ) {\n var cell = this.cells[i];\n if ( cell.element == elem ) {\n return cell;\n }\n }\n};\n\n/**\n * get collection of Flickity.Cells, given Elements\n * @param {[Element, Array, NodeList]} elems - multiple elements\n * @returns {Array} cells - Flickity.Cells\n */\nproto.getCells = function( elems ) {\n elems = utils.makeArray( elems );\n var cells = [];\n elems.forEach( function( elem ) {\n var cell = this.getCell( elem );\n if ( cell ) {\n cells.push( cell );\n }\n }, this );\n return cells;\n};\n\n/**\n * get cell elements\n * @returns {Array} cellElems\n */\nproto.getCellElements = function() {\n return this.cells.map( function( cell ) {\n return cell.element;\n } );\n};\n\n/**\n * get parent cell from an element\n * @param {Element} elem - child element\n * @returns {Flickit.Cell} cell - parent cell\n */\nproto.getParentCell = function( elem ) {\n // first check if elem is cell\n var cell = this.getCell( elem );\n if ( cell ) {\n return cell;\n }\n // try to get parent cell elem\n elem = utils.getParent( elem, '.flickity-slider > *' );\n return this.getCell( elem );\n};\n\n/**\n * get cells adjacent to a slide\n * @param {Integer} adjCount - number of adjacent slides\n * @param {Integer} index - index of slide to start\n * @returns {Array} cells - array of Flickity.Cells\n */\nproto.getAdjacentCellElements = function( adjCount, index ) {\n if ( !adjCount ) {\n return this.selectedSlide.getCellElements();\n }\n index = index === undefined ? this.selectedIndex : index;\n\n var len = this.slides.length;\n if ( 1 + ( adjCount * 2 ) >= len ) {\n return this.getCellElements();\n }\n\n var cellElems = [];\n for ( var i = index - adjCount; i <= index + adjCount; i++ ) {\n var slideIndex = this.options.wrapAround ? utils.modulo( i, len ) : i;\n var slide = this.slides[ slideIndex ];\n if ( slide ) {\n cellElems = cellElems.concat( slide.getCellElements() );\n }\n }\n return cellElems;\n};\n\n/**\n * select slide from number or cell element\n * @param {[Element, String, Number]} selector - element, selector string, or index\n * @returns {Flickity.Cell} - matching cell\n */\nproto.queryCell = function( selector ) {\n if ( typeof selector == 'number' ) {\n // use number as index\n return this.cells[ selector ];\n }\n if ( typeof selector == 'string' ) {\n // do not select invalid selectors from hash: #123, #/. #791\n if ( selector.match( /^[#.]?[\\d/]/ ) ) {\n return;\n }\n // use string as selector, get element\n selector = this.element.querySelector( selector );\n }\n // get cell from element\n return this.getCell( selector );\n};\n\n// -------------------------- events -------------------------- //\n\nproto.uiChange = function() {\n this.emitEvent('uiChange');\n};\n\n// keep focus on element when child UI elements are clicked\nproto.childUIPointerDown = function( event ) {\n // HACK iOS does not allow touch events to bubble up?!\n if ( event.type != 'touchstart' ) {\n event.preventDefault();\n }\n this.focus();\n};\n\n// ----- resize ----- //\n\nproto.onresize = function() {\n this.watchCSS();\n this.resize();\n};\n\nutils.debounceMethod( Flickity, 'onresize', 150 );\n\nproto.resize = function() {\n // #1177 disable resize behavior when animating or dragging for iOS 15\n if ( !this.isActive || this.isAnimating || this.isDragging ) {\n return;\n }\n this.getSize();\n // wrap values\n if ( this.options.wrapAround ) {\n this.x = utils.modulo( this.x, this.slideableWidth );\n }\n this.positionCells();\n this._getWrapShiftCells();\n this.setGallerySize();\n this.emitEvent('resize');\n // update selected index for group slides, instant\n // TODO: position can be lost between groups of various numbers\n var selectedElement = this.selectedElements && this.selectedElements[0];\n this.selectCell( selectedElement, false, true );\n};\n\n// watches the :after property, activates/deactivates\nproto.watchCSS = function() {\n var watchOption = this.options.watchCSS;\n if ( !watchOption ) {\n return;\n }\n\n var afterContent = getComputedStyle( this.element, ':after' ).content;\n // activate if :after { content: 'flickity' }\n if ( afterContent.indexOf('flickity') != -1 ) {\n this.activate();\n } else {\n this.deactivate();\n }\n};\n\n// ----- keydown ----- //\n\n// go previous/next if left/right keys pressed\nproto.onkeydown = function( event ) {\n // only work if element is in focus\n var isNotFocused = document.activeElement && document.activeElement != this.element;\n if ( !this.options.accessibility || isNotFocused ) {\n return;\n }\n\n var handler = Flickity.keyboardHandlers[ event.keyCode ];\n if ( handler ) {\n handler.call( this );\n }\n};\n\nFlickity.keyboardHandlers = {\n // left arrow\n 37: function() {\n var leftMethod = this.options.rightToLeft ? 'next' : 'previous';\n this.uiChange();\n this[ leftMethod ]();\n },\n // right arrow\n 39: function() {\n var rightMethod = this.options.rightToLeft ? 'previous' : 'next';\n this.uiChange();\n this[ rightMethod ]();\n },\n};\n\n// ----- focus ----- //\n\nproto.focus = function() {\n // TODO remove scrollTo once focus options gets more support\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus ...\n // #Browser_compatibility\n var prevScrollY = window.pageYOffset;\n this.element.focus({ preventScroll: true });\n // hack to fix scroll jump after focus, #76\n if ( window.pageYOffset != prevScrollY ) {\n window.scrollTo( window.pageXOffset, prevScrollY );\n }\n};\n\n// -------------------------- destroy -------------------------- //\n\n// deactivate all Flickity functionality, but keep stuff available\nproto.deactivate = function() {\n if ( !this.isActive ) {\n return;\n }\n this.element.classList.remove('flickity-enabled');\n this.element.classList.remove('flickity-rtl');\n this.unselectSelectedSlide();\n // destroy cells\n this.cells.forEach( function( cell ) {\n cell.destroy();\n } );\n this.element.removeChild( this.viewport );\n // move child elements back into element\n moveElements( this.slider.children, this.element );\n if ( this.options.accessibility ) {\n this.element.removeAttribute('tabIndex');\n this.element.removeEventListener( 'keydown', this );\n }\n // set flags\n this.isActive = false;\n this.emitEvent('deactivate');\n};\n\nproto.destroy = function() {\n this.deactivate();\n window.removeEventListener( 'resize', this );\n this.allOff();\n this.emitEvent('destroy');\n if ( jQuery && this.$element ) {\n jQuery.removeData( this.element, 'flickity' );\n }\n delete this.element.flickityGUID;\n delete instances[ this.guid ];\n};\n\n// -------------------------- prototype -------------------------- //\n\nutils.extend( proto, animatePrototype );\n\n// -------------------------- extras -------------------------- //\n\n/**\n * get Flickity instance from element\n * @param {[Element, String]} elem - element or selector string\n * @returns {Flickity} - Flickity instance\n */\nFlickity.data = function( elem ) {\n elem = utils.getQueryElement( elem );\n var id = elem && elem.flickityGUID;\n return id && instances[ id ];\n};\n\nutils.htmlInit( Flickity, 'flickity' );\n\nif ( jQuery && jQuery.bridget ) {\n jQuery.bridget( 'flickity', Flickity );\n}\n\n// set internal jQuery, for Webpack + jQuery v3, #478\nFlickity.setJQuery = function( jq ) {\n jQuery = jq;\n};\n\nFlickity.Cell = Cell;\nFlickity.Slide = Slide;\n\nreturn Flickity;\n\n} ) );\n","/*!\n * Unipointer v2.4.0\n * base class for doing one thing with pointer event\n * MIT license\n */\n\n/*jshint browser: true, undef: true, unused: true, strict: true */\n\n( function( window, factory ) {\n // universal module definition\n /* jshint strict: false */ /*global define, module, require */\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'ev-emitter/ev-emitter'\n ], function( EvEmitter ) {\n return factory( window, EvEmitter );\n });\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('ev-emitter')\n );\n } else {\n // browser global\n window.Unipointer = factory(\n window,\n window.EvEmitter\n );\n }\n\n}( window, function factory( window, EvEmitter ) {\n\n'use strict';\n\nfunction noop() {}\n\nfunction Unipointer() {}\n\n// inherit EvEmitter\nvar proto = Unipointer.prototype = Object.create( EvEmitter.prototype );\n\nproto.bindStartEvent = function( elem ) {\n this._bindStartEvent( elem, true );\n};\n\nproto.unbindStartEvent = function( elem ) {\n this._bindStartEvent( elem, false );\n};\n\n/**\n * Add or remove start event\n * @param {Boolean} isAdd - remove if falsey\n */\nproto._bindStartEvent = function( elem, isAdd ) {\n // munge isAdd, default to true\n isAdd = isAdd === undefined ? true : isAdd;\n var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener';\n\n // default to mouse events\n var startEvent = 'mousedown';\n if ( 'ontouchstart' in window ) {\n // HACK prefer Touch Events as you can preventDefault on touchstart to\n // disable scroll in iOS & mobile Chrome metafizzy/flickity#1177\n startEvent = 'touchstart';\n } else if ( window.PointerEvent ) {\n // Pointer Events\n startEvent = 'pointerdown';\n }\n elem[ bindMethod ]( startEvent, this );\n};\n\n// trigger handler methods for events\nproto.handleEvent = function( event ) {\n var method = 'on' + event.type;\n if ( this[ method ] ) {\n this[ method ]( event );\n }\n};\n\n// returns the touch that we're keeping track of\nproto.getTouch = function( touches ) {\n for ( var i=0; i < touches.length; i++ ) {\n var touch = touches[i];\n if ( touch.identifier == this.pointerIdentifier ) {\n return touch;\n }\n }\n};\n\n// ----- start event ----- //\n\nproto.onmousedown = function( event ) {\n // dismiss clicks from right or middle buttons\n var button = event.button;\n if ( button && ( button !== 0 && button !== 1 ) ) {\n return;\n }\n this._pointerDown( event, event );\n};\n\nproto.ontouchstart = function( event ) {\n this._pointerDown( event, event.changedTouches[0] );\n};\n\nproto.onpointerdown = function( event ) {\n this._pointerDown( event, event );\n};\n\n/**\n * pointer start\n * @param {Event} event\n * @param {Event or Touch} pointer\n */\nproto._pointerDown = function( event, pointer ) {\n // dismiss right click and other pointers\n // button = 0 is okay, 1-4 not\n if ( event.button || this.isPointerDown ) {\n return;\n }\n\n this.isPointerDown = true;\n // save pointer identifier to match up touch events\n this.pointerIdentifier = pointer.pointerId !== undefined ?\n // pointerId for pointer events, touch.indentifier for touch events\n pointer.pointerId : pointer.identifier;\n\n this.pointerDown( event, pointer );\n};\n\nproto.pointerDown = function( event, pointer ) {\n this._bindPostStartEvents( event );\n this.emitEvent( 'pointerDown', [ event, pointer ] );\n};\n\n// hash of events to be bound after start event\nvar postStartEvents = {\n mousedown: [ 'mousemove', 'mouseup' ],\n touchstart: [ 'touchmove', 'touchend', 'touchcancel' ],\n pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ],\n};\n\nproto._bindPostStartEvents = function( event ) {\n if ( !event ) {\n return;\n }\n // get proper events to match start event\n var events = postStartEvents[ event.type ];\n // bind events to node\n events.forEach( function( eventName ) {\n window.addEventListener( eventName, this );\n }, this );\n // save these arguments\n this._boundPointerEvents = events;\n};\n\nproto._unbindPostStartEvents = function() {\n // check for _boundEvents, in case dragEnd triggered twice (old IE8 bug)\n if ( !this._boundPointerEvents ) {\n return;\n }\n this._boundPointerEvents.forEach( function( eventName ) {\n window.removeEventListener( eventName, this );\n }, this );\n\n delete this._boundPointerEvents;\n};\n\n// ----- move event ----- //\n\nproto.onmousemove = function( event ) {\n this._pointerMove( event, event );\n};\n\nproto.onpointermove = function( event ) {\n if ( event.pointerId == this.pointerIdentifier ) {\n this._pointerMove( event, event );\n }\n};\n\nproto.ontouchmove = function( event ) {\n var touch = this.getTouch( event.changedTouches );\n if ( touch ) {\n this._pointerMove( event, touch );\n }\n};\n\n/**\n * pointer move\n * @param {Event} event\n * @param {Event or Touch} pointer\n * @private\n */\nproto._pointerMove = function( event, pointer ) {\n this.pointerMove( event, pointer );\n};\n\n// public\nproto.pointerMove = function( event, pointer ) {\n this.emitEvent( 'pointerMove', [ event, pointer ] );\n};\n\n// ----- end event ----- //\n\n\nproto.onmouseup = function( event ) {\n this._pointerUp( event, event );\n};\n\nproto.onpointerup = function( event ) {\n if ( event.pointerId == this.pointerIdentifier ) {\n this._pointerUp( event, event );\n }\n};\n\nproto.ontouchend = function( event ) {\n var touch = this.getTouch( event.changedTouches );\n if ( touch ) {\n this._pointerUp( event, touch );\n }\n};\n\n/**\n * pointer up\n * @param {Event} event\n * @param {Event or Touch} pointer\n * @private\n */\nproto._pointerUp = function( event, pointer ) {\n this._pointerDone();\n this.pointerUp( event, pointer );\n};\n\n// public\nproto.pointerUp = function( event, pointer ) {\n this.emitEvent( 'pointerUp', [ event, pointer ] );\n};\n\n// ----- pointer done ----- //\n\n// triggered on pointer up & pointer cancel\nproto._pointerDone = function() {\n this._pointerReset();\n this._unbindPostStartEvents();\n this.pointerDone();\n};\n\nproto._pointerReset = function() {\n // reset properties\n this.isPointerDown = false;\n delete this.pointerIdentifier;\n};\n\nproto.pointerDone = noop;\n\n// ----- pointer cancel ----- //\n\nproto.onpointercancel = function( event ) {\n if ( event.pointerId == this.pointerIdentifier ) {\n this._pointerCancel( event, event );\n }\n};\n\nproto.ontouchcancel = function( event ) {\n var touch = this.getTouch( event.changedTouches );\n if ( touch ) {\n this._pointerCancel( event, touch );\n }\n};\n\n/**\n * pointer cancel\n * @param {Event} event\n * @param {Event or Touch} pointer\n * @private\n */\nproto._pointerCancel = function( event, pointer ) {\n this._pointerDone();\n this.pointerCancel( event, pointer );\n};\n\n// public\nproto.pointerCancel = function( event, pointer ) {\n this.emitEvent( 'pointerCancel', [ event, pointer ] );\n};\n\n// ----- ----- //\n\n// utility function for getting x/y coords from event\nUnipointer.getPointerPoint = function( pointer ) {\n return {\n x: pointer.pageX,\n y: pointer.pageY\n };\n};\n\n// ----- ----- //\n\nreturn Unipointer;\n\n}));\n","/*!\n * Unidragger v2.4.0\n * Draggable base class\n * MIT license\n */\n\n/*jshint browser: true, unused: true, undef: true, strict: true */\n\n( function( window, factory ) {\n // universal module definition\n /*jshint strict: false */ /*globals define, module, require */\n\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'unipointer/unipointer'\n ], function( Unipointer ) {\n return factory( window, Unipointer );\n });\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('unipointer')\n );\n } else {\n // browser global\n window.Unidragger = factory(\n window,\n window.Unipointer\n );\n }\n\n}( window, function factory( window, Unipointer ) {\n\n'use strict';\n\n// -------------------------- Unidragger -------------------------- //\n\nfunction Unidragger() {}\n\n// inherit Unipointer & EvEmitter\nvar proto = Unidragger.prototype = Object.create( Unipointer.prototype );\n\n// ----- bind start ----- //\n\nproto.bindHandles = function() {\n this._bindHandles( true );\n};\n\nproto.unbindHandles = function() {\n this._bindHandles( false );\n};\n\n/**\n * Add or remove start event\n * @param {Boolean} isAdd\n */\nproto._bindHandles = function( isAdd ) {\n // munge isAdd, default to true\n isAdd = isAdd === undefined ? true : isAdd;\n // bind each handle\n var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener';\n var touchAction = isAdd ? this._touchActionValue : '';\n for ( var i=0; i < this.handles.length; i++ ) {\n var handle = this.handles[i];\n this._bindStartEvent( handle, isAdd );\n handle[ bindMethod ]( 'click', this );\n // touch-action: none to override browser touch gestures. metafizzy/flickity#540\n if ( window.PointerEvent ) {\n handle.style.touchAction = touchAction;\n }\n }\n};\n\n// prototype so it can be overwriteable by Flickity\nproto._touchActionValue = 'none';\n\n// ----- start event ----- //\n\n/**\n * pointer start\n * @param {Event} event\n * @param {Event or Touch} pointer\n */\nproto.pointerDown = function( event, pointer ) {\n var isOkay = this.okayPointerDown( event );\n if ( !isOkay ) {\n return;\n }\n // track start event position\n // Safari 9 overrides pageX and pageY. These values needs to be copied. flickity#842\n this.pointerDownPointer = {\n pageX: pointer.pageX,\n pageY: pointer.pageY,\n };\n\n event.preventDefault();\n this.pointerDownBlur();\n // bind move and end events\n this._bindPostStartEvents( event );\n this.emitEvent( 'pointerDown', [ event, pointer ] );\n};\n\n// nodes that have text fields\nvar cursorNodes = {\n TEXTAREA: true,\n INPUT: true,\n SELECT: true,\n OPTION: true,\n};\n\n// input types that do not have text fields\nvar clickTypes = {\n radio: true,\n checkbox: true,\n button: true,\n submit: true,\n image: true,\n file: true,\n};\n\n// dismiss inputs with text fields. flickity#403, flickity#404\nproto.okayPointerDown = function( event ) {\n var isCursorNode = cursorNodes[ event.target.nodeName ];\n var isClickType = clickTypes[ event.target.type ];\n var isOkay = !isCursorNode || isClickType;\n if ( !isOkay ) {\n this._pointerReset();\n }\n return isOkay;\n};\n\n// kludge to blur previously focused input\nproto.pointerDownBlur = function() {\n var focused = document.activeElement;\n // do not blur body for IE10, metafizzy/flickity#117\n var canBlur = focused && focused.blur && focused != document.body;\n if ( canBlur ) {\n focused.blur();\n }\n};\n\n// ----- move event ----- //\n\n/**\n * drag move\n * @param {Event} event\n * @param {Event or Touch} pointer\n */\nproto.pointerMove = function( event, pointer ) {\n var moveVector = this._dragPointerMove( event, pointer );\n this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] );\n this._dragMove( event, pointer, moveVector );\n};\n\n// base pointer move logic\nproto._dragPointerMove = function( event, pointer ) {\n var moveVector = {\n x: pointer.pageX - this.pointerDownPointer.pageX,\n y: pointer.pageY - this.pointerDownPointer.pageY\n };\n // start drag if pointer has moved far enough to start drag\n if ( !this.isDragging && this.hasDragStarted( moveVector ) ) {\n this._dragStart( event, pointer );\n }\n return moveVector;\n};\n\n// condition if pointer has moved far enough to start drag\nproto.hasDragStarted = function( moveVector ) {\n return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3;\n};\n\n// ----- end event ----- //\n\n/**\n * pointer up\n * @param {Event} event\n * @param {Event or Touch} pointer\n */\nproto.pointerUp = function( event, pointer ) {\n this.emitEvent( 'pointerUp', [ event, pointer ] );\n this._dragPointerUp( event, pointer );\n};\n\nproto._dragPointerUp = function( event, pointer ) {\n if ( this.isDragging ) {\n this._dragEnd( event, pointer );\n } else {\n // pointer didn't move enough for drag to start\n this._staticClick( event, pointer );\n }\n};\n\n// -------------------------- drag -------------------------- //\n\n// dragStart\nproto._dragStart = function( event, pointer ) {\n this.isDragging = true;\n // prevent clicks\n this.isPreventingClicks = true;\n this.dragStart( event, pointer );\n};\n\nproto.dragStart = function( event, pointer ) {\n this.emitEvent( 'dragStart', [ event, pointer ] );\n};\n\n// dragMove\nproto._dragMove = function( event, pointer, moveVector ) {\n // do not drag if not dragging yet\n if ( !this.isDragging ) {\n return;\n }\n\n this.dragMove( event, pointer, moveVector );\n};\n\nproto.dragMove = function( event, pointer, moveVector ) {\n event.preventDefault();\n this.emitEvent( 'dragMove', [ event, pointer, moveVector ] );\n};\n\n// dragEnd\nproto._dragEnd = function( event, pointer ) {\n // set flags\n this.isDragging = false;\n // re-enable clicking async\n setTimeout( function() {\n delete this.isPreventingClicks;\n }.bind( this ) );\n\n this.dragEnd( event, pointer );\n};\n\nproto.dragEnd = function( event, pointer ) {\n this.emitEvent( 'dragEnd', [ event, pointer ] );\n};\n\n// ----- onclick ----- //\n\n// handle all clicks and prevent clicks when dragging\nproto.onclick = function( event ) {\n if ( this.isPreventingClicks ) {\n event.preventDefault();\n }\n};\n\n// ----- staticClick ----- //\n\n// triggered after pointer down & up with no/tiny movement\nproto._staticClick = function( event, pointer ) {\n // ignore emulated mouse up clicks\n if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) {\n return;\n }\n\n this.staticClick( event, pointer );\n\n // set flag for emulated clicks 300ms after touchend\n if ( event.type != 'mouseup' ) {\n this.isIgnoringMouseUp = true;\n // reset flag after 300ms\n setTimeout( function() {\n delete this.isIgnoringMouseUp;\n }.bind( this ), 400 );\n }\n};\n\nproto.staticClick = function( event, pointer ) {\n this.emitEvent( 'staticClick', [ event, pointer ] );\n};\n\n// ----- utils ----- //\n\nUnidragger.getPointerPoint = Unipointer.getPointerPoint;\n\n// ----- ----- //\n\nreturn Unidragger;\n\n}));\n","// drag\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './flickity',\n 'unidragger/unidragger',\n 'fizzy-ui-utils/utils',\n ], function( Flickity, Unidragger, utils ) {\n return factory( window, Flickity, Unidragger, utils );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('./flickity'),\n require('unidragger'),\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n window.Flickity = factory(\n window,\n window.Flickity,\n window.Unidragger,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, Flickity, Unidragger, utils ) {\n\n'use strict';\n\n// ----- defaults ----- //\n\nutils.extend( Flickity.defaults, {\n draggable: '>1',\n dragThreshold: 3,\n} );\n\n// ----- create ----- //\n\nFlickity.createMethods.push('_createDrag');\n\n// -------------------------- drag prototype -------------------------- //\n\nvar proto = Flickity.prototype;\nutils.extend( proto, Unidragger.prototype );\nproto._touchActionValue = 'pan-y';\n\n// -------------------------- -------------------------- //\n\nproto._createDrag = function() {\n this.on( 'activate', this.onActivateDrag );\n this.on( 'uiChange', this._uiChangeDrag );\n this.on( 'deactivate', this.onDeactivateDrag );\n this.on( 'cellChange', this.updateDraggable );\n // TODO updateDraggable on resize? if groupCells & slides change\n};\n\nproto.onActivateDrag = function() {\n this.handles = [ this.viewport ];\n this.bindHandles();\n this.updateDraggable();\n};\n\nproto.onDeactivateDrag = function() {\n this.unbindHandles();\n this.element.classList.remove('is-draggable');\n};\n\nproto.updateDraggable = function() {\n // disable dragging if less than 2 slides. #278\n if ( this.options.draggable == '>1' ) {\n this.isDraggable = this.slides.length > 1;\n } else {\n this.isDraggable = this.options.draggable;\n }\n if ( this.isDraggable ) {\n this.element.classList.add('is-draggable');\n } else {\n this.element.classList.remove('is-draggable');\n }\n};\n\n// backwards compatibility\nproto.bindDrag = function() {\n this.options.draggable = true;\n this.updateDraggable();\n};\n\nproto.unbindDrag = function() {\n this.options.draggable = false;\n this.updateDraggable();\n};\n\nproto._uiChangeDrag = function() {\n delete this.isFreeScrolling;\n};\n\n// -------------------------- pointer events -------------------------- //\n\nproto.pointerDown = function( event, pointer ) {\n if ( !this.isDraggable ) {\n this._pointerDownDefault( event, pointer );\n return;\n }\n var isOkay = this.okayPointerDown( event );\n if ( !isOkay ) {\n return;\n }\n\n this._pointerDownPreventDefault( event );\n this.pointerDownFocus( event );\n // blur\n if ( document.activeElement != this.element ) {\n // do not blur if already focused\n this.pointerDownBlur();\n }\n\n // stop if it was moving\n this.dragX = this.x;\n this.viewport.classList.add('is-pointer-down');\n // track scrolling\n this.pointerDownScroll = getScrollPosition();\n window.addEventListener( 'scroll', this );\n\n this._pointerDownDefault( event, pointer );\n};\n\n// default pointerDown logic, used for staticClick\nproto._pointerDownDefault = function( event, pointer ) {\n // track start event position\n // Safari 9 overrides pageX and pageY. These values needs to be copied. #779\n this.pointerDownPointer = {\n pageX: pointer.pageX,\n pageY: pointer.pageY,\n };\n // bind move and end events\n this._bindPostStartEvents( event );\n this.dispatchEvent( 'pointerDown', event, [ pointer ] );\n};\n\nvar focusNodes = {\n INPUT: true,\n TEXTAREA: true,\n SELECT: true,\n};\n\nproto.pointerDownFocus = function( event ) {\n var isFocusNode = focusNodes[ event.target.nodeName ];\n if ( !isFocusNode ) {\n this.focus();\n }\n};\n\nproto._pointerDownPreventDefault = function( event ) {\n var isTouchStart = event.type == 'touchstart';\n var isTouchPointer = event.pointerType == 'touch';\n var isFocusNode = focusNodes[ event.target.nodeName ];\n if ( !isTouchStart && !isTouchPointer && !isFocusNode ) {\n event.preventDefault();\n }\n};\n\n// ----- move ----- //\n\nproto.hasDragStarted = function( moveVector ) {\n return Math.abs( moveVector.x ) > this.options.dragThreshold;\n};\n\n// ----- up ----- //\n\nproto.pointerUp = function( event, pointer ) {\n delete this.isTouchScrolling;\n this.viewport.classList.remove('is-pointer-down');\n this.dispatchEvent( 'pointerUp', event, [ pointer ] );\n this._dragPointerUp( event, pointer );\n};\n\nproto.pointerDone = function() {\n window.removeEventListener( 'scroll', this );\n delete this.pointerDownScroll;\n};\n\n// -------------------------- dragging -------------------------- //\n\nproto.dragStart = function( event, pointer ) {\n if ( !this.isDraggable ) {\n return;\n }\n this.dragStartPosition = this.x;\n this.startAnimation();\n window.removeEventListener( 'scroll', this );\n this.dispatchEvent( 'dragStart', event, [ pointer ] );\n};\n\nproto.pointerMove = function( event, pointer ) {\n var moveVector = this._dragPointerMove( event, pointer );\n this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] );\n this._dragMove( event, pointer, moveVector );\n};\n\nproto.dragMove = function( event, pointer, moveVector ) {\n if ( !this.isDraggable ) {\n return;\n }\n event.preventDefault();\n\n this.previousDragX = this.dragX;\n // reverse if right-to-left\n var direction = this.options.rightToLeft ? -1 : 1;\n if ( this.options.wrapAround ) {\n // wrap around move. #589\n moveVector.x %= this.slideableWidth;\n }\n var dragX = this.dragStartPosition + moveVector.x * direction;\n\n if ( !this.options.wrapAround && this.slides.length ) {\n // slow drag\n var originBound = Math.max( -this.slides[0].target, this.dragStartPosition );\n dragX = dragX > originBound ? ( dragX + originBound ) * 0.5 : dragX;\n var endBound = Math.min( -this.getLastSlide().target, this.dragStartPosition );\n dragX = dragX < endBound ? ( dragX + endBound ) * 0.5 : dragX;\n }\n\n this.dragX = dragX;\n\n this.dragMoveTime = new Date();\n this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] );\n};\n\nproto.dragEnd = function( event, pointer ) {\n if ( !this.isDraggable ) {\n return;\n }\n if ( this.options.freeScroll ) {\n this.isFreeScrolling = true;\n }\n // set selectedIndex based on where flick will end up\n var index = this.dragEndRestingSelect();\n\n if ( this.options.freeScroll && !this.options.wrapAround ) {\n // if free-scroll & not wrap around\n // do not free-scroll if going outside of bounding slides\n // so bounding slides can attract slider, and keep it in bounds\n var restingX = this.getRestingPosition();\n this.isFreeScrolling = -restingX > this.slides[0].target &&\n -restingX < this.getLastSlide().target;\n } else if ( !this.options.freeScroll && index == this.selectedIndex ) {\n // boost selection if selected index has not changed\n index += this.dragEndBoostSelect();\n }\n delete this.previousDragX;\n // apply selection\n // TODO refactor this, selecting here feels weird\n // HACK, set flag so dragging stays in correct direction\n this.isDragSelect = this.options.wrapAround;\n this.select( index );\n delete this.isDragSelect;\n this.dispatchEvent( 'dragEnd', event, [ pointer ] );\n};\n\nproto.dragEndRestingSelect = function() {\n var restingX = this.getRestingPosition();\n // how far away from selected slide\n var distance = Math.abs( this.getSlideDistance( -restingX, this.selectedIndex ) );\n // get closet resting going up and going down\n var positiveResting = this._getClosestResting( restingX, distance, 1 );\n var negativeResting = this._getClosestResting( restingX, distance, -1 );\n // use closer resting for wrap-around\n var index = positiveResting.distance < negativeResting.distance ?\n positiveResting.index : negativeResting.index;\n return index;\n};\n\n/**\n * given resting X and distance to selected cell\n * get the distance and index of the closest cell\n * @param {Number} restingX - estimated post-flick resting position\n * @param {Number} distance - distance to selected cell\n * @param {Integer} increment - +1 or -1, going up or down\n * @returns {Object} - { distance: {Number}, index: {Integer} }\n */\nproto._getClosestResting = function( restingX, distance, increment ) {\n var index = this.selectedIndex;\n var minDistance = Infinity;\n var condition = this.options.contain && !this.options.wrapAround ?\n // if contain, keep going if distance is equal to minDistance\n function( dist, minDist ) {\n return dist <= minDist;\n } : function( dist, minDist ) {\n return dist < minDist;\n };\n while ( condition( distance, minDistance ) ) {\n // measure distance to next cell\n index += increment;\n minDistance = distance;\n distance = this.getSlideDistance( -restingX, index );\n if ( distance === null ) {\n break;\n }\n distance = Math.abs( distance );\n }\n return {\n distance: minDistance,\n // selected was previous index\n index: index - increment,\n };\n};\n\n/**\n * measure distance between x and a slide target\n * @param {Number} x - horizontal position\n * @param {Integer} index - slide index\n * @returns {Number} - slide distance\n */\nproto.getSlideDistance = function( x, index ) {\n var len = this.slides.length;\n // wrap around if at least 2 slides\n var isWrapAround = this.options.wrapAround && len > 1;\n var slideIndex = isWrapAround ? utils.modulo( index, len ) : index;\n var slide = this.slides[ slideIndex ];\n if ( !slide ) {\n return null;\n }\n // add distance for wrap-around slides\n var wrap = isWrapAround ? this.slideableWidth * Math.floor( index/len ) : 0;\n return x - ( slide.target + wrap );\n};\n\nproto.dragEndBoostSelect = function() {\n // do not boost if no previousDragX or dragMoveTime\n if ( this.previousDragX === undefined || !this.dragMoveTime ||\n // or if drag was held for 100 ms\n new Date() - this.dragMoveTime > 100 ) {\n return 0;\n }\n\n var distance = this.getSlideDistance( -this.dragX, this.selectedIndex );\n var delta = this.previousDragX - this.dragX;\n if ( distance > 0 && delta > 0 ) {\n // boost to next if moving towards the right, and positive velocity\n return 1;\n } else if ( distance < 0 && delta < 0 ) {\n // boost to previous if moving towards the left, and negative velocity\n return -1;\n }\n return 0;\n};\n\n// ----- staticClick ----- //\n\nproto.staticClick = function( event, pointer ) {\n // get clickedCell, if cell was clicked\n var clickedCell = this.getParentCell( event.target );\n var cellElem = clickedCell && clickedCell.element;\n var cellIndex = clickedCell && this.cells.indexOf( clickedCell );\n this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] );\n};\n\n// ----- scroll ----- //\n\nproto.onscroll = function() {\n var scroll = getScrollPosition();\n var scrollMoveX = this.pointerDownScroll.x - scroll.x;\n var scrollMoveY = this.pointerDownScroll.y - scroll.y;\n // cancel click/tap if scroll is too much\n if ( Math.abs( scrollMoveX ) > 3 || Math.abs( scrollMoveY ) > 3 ) {\n this._pointerDone();\n }\n};\n\n// ----- utils ----- //\n\nfunction getScrollPosition() {\n return {\n x: window.pageXOffset,\n y: window.pageYOffset,\n };\n}\n\n// ----- ----- //\n\nreturn Flickity;\n\n} ) );\n","// prev/next buttons\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './flickity',\n 'unipointer/unipointer',\n 'fizzy-ui-utils/utils',\n ], function( Flickity, Unipointer, utils ) {\n return factory( window, Flickity, Unipointer, utils );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('./flickity'),\n require('unipointer'),\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n factory(\n window,\n window.Flickity,\n window.Unipointer,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, Flickity, Unipointer, utils ) {\n'use strict';\n\nvar svgURI = 'http://www.w3.org/2000/svg';\n\n// -------------------------- PrevNextButton -------------------------- //\n\nfunction PrevNextButton( direction, parent ) {\n this.direction = direction;\n this.parent = parent;\n this._create();\n}\n\nPrevNextButton.prototype = Object.create( Unipointer.prototype );\n\nPrevNextButton.prototype._create = function() {\n // properties\n this.isEnabled = true;\n this.isPrevious = this.direction == -1;\n var leftDirection = this.parent.options.rightToLeft ? 1 : -1;\n this.isLeft = this.direction == leftDirection;\n\n var element = this.element = document.createElement('button');\n element.className = 'flickity-button flickity-prev-next-button';\n element.className += this.isPrevious ? ' previous' : ' next';\n // prevent button from submitting form http://stackoverflow.com/a/10836076/182183\n element.setAttribute( 'type', 'button' );\n // init as disabled\n this.disable();\n\n element.setAttribute( 'aria-label', this.isPrevious ? 'Previous' : 'Next' );\n\n // create arrow\n var svg = this.createSVG();\n element.appendChild( svg );\n // events\n this.parent.on( 'select', this.update.bind( this ) );\n this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) );\n};\n\nPrevNextButton.prototype.activate = function() {\n this.bindStartEvent( this.element );\n this.element.addEventListener( 'click', this );\n // add to DOM\n this.parent.element.appendChild( this.element );\n};\n\nPrevNextButton.prototype.deactivate = function() {\n // remove from DOM\n this.parent.element.removeChild( this.element );\n // click events\n this.unbindStartEvent( this.element );\n this.element.removeEventListener( 'click', this );\n};\n\nPrevNextButton.prototype.createSVG = function() {\n var svg = document.createElementNS( svgURI, 'svg' );\n svg.setAttribute( 'class', 'flickity-button-icon' );\n svg.setAttribute( 'viewBox', '0 0 100 100' );\n var path = document.createElementNS( svgURI, 'path' );\n var pathMovements = getArrowMovements( this.parent.options.arrowShape );\n path.setAttribute( 'd', pathMovements );\n path.setAttribute( 'class', 'arrow' );\n // rotate arrow\n if ( !this.isLeft ) {\n path.setAttribute( 'transform', 'translate(100, 100) rotate(180) ' );\n }\n svg.appendChild( path );\n return svg;\n};\n\n// get SVG path movmement\nfunction getArrowMovements( shape ) {\n // use shape as movement if string\n if ( typeof shape == 'string' ) {\n return shape;\n }\n // create movement string\n return 'M ' + shape.x0 + ',50' +\n ' L ' + shape.x1 + ',' + ( shape.y1 + 50 ) +\n ' L ' + shape.x2 + ',' + ( shape.y2 + 50 ) +\n ' L ' + shape.x3 + ',50 ' +\n ' L ' + shape.x2 + ',' + ( 50 - shape.y2 ) +\n ' L ' + shape.x1 + ',' + ( 50 - shape.y1 ) +\n ' Z';\n}\n\nPrevNextButton.prototype.handleEvent = utils.handleEvent;\n\nPrevNextButton.prototype.onclick = function() {\n if ( !this.isEnabled ) {\n return;\n }\n this.parent.uiChange();\n var method = this.isPrevious ? 'previous' : 'next';\n this.parent[ method ]();\n};\n\n// ----- ----- //\n\nPrevNextButton.prototype.enable = function() {\n if ( this.isEnabled ) {\n return;\n }\n this.element.disabled = false;\n this.isEnabled = true;\n};\n\nPrevNextButton.prototype.disable = function() {\n if ( !this.isEnabled ) {\n return;\n }\n this.element.disabled = true;\n this.isEnabled = false;\n};\n\nPrevNextButton.prototype.update = function() {\n // index of first or last slide, if previous or next\n var slides = this.parent.slides;\n // enable is wrapAround and at least 2 slides\n if ( this.parent.options.wrapAround && slides.length > 1 ) {\n this.enable();\n return;\n }\n var lastIndex = slides.length ? slides.length - 1 : 0;\n var boundIndex = this.isPrevious ? 0 : lastIndex;\n var method = this.parent.selectedIndex == boundIndex ? 'disable' : 'enable';\n this[ method ]();\n};\n\nPrevNextButton.prototype.destroy = function() {\n this.deactivate();\n this.allOff();\n};\n\n// -------------------------- Flickity prototype -------------------------- //\n\nutils.extend( Flickity.defaults, {\n prevNextButtons: true,\n arrowShape: {\n x0: 10,\n x1: 60, y1: 50,\n x2: 70, y2: 40,\n x3: 30,\n },\n} );\n\nFlickity.createMethods.push('_createPrevNextButtons');\nvar proto = Flickity.prototype;\n\nproto._createPrevNextButtons = function() {\n if ( !this.options.prevNextButtons ) {\n return;\n }\n\n this.prevButton = new PrevNextButton( -1, this );\n this.nextButton = new PrevNextButton( 1, this );\n\n this.on( 'activate', this.activatePrevNextButtons );\n};\n\nproto.activatePrevNextButtons = function() {\n this.prevButton.activate();\n this.nextButton.activate();\n this.on( 'deactivate', this.deactivatePrevNextButtons );\n};\n\nproto.deactivatePrevNextButtons = function() {\n this.prevButton.deactivate();\n this.nextButton.deactivate();\n this.off( 'deactivate', this.deactivatePrevNextButtons );\n};\n\n// -------------------------- -------------------------- //\n\nFlickity.PrevNextButton = PrevNextButton;\n\nreturn Flickity;\n\n} ) );\n","// page dots\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './flickity',\n 'unipointer/unipointer',\n 'fizzy-ui-utils/utils',\n ], function( Flickity, Unipointer, utils ) {\n return factory( window, Flickity, Unipointer, utils );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('./flickity'),\n require('unipointer'),\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n factory(\n window,\n window.Flickity,\n window.Unipointer,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, Flickity, Unipointer, utils ) {\n\n// -------------------------- PageDots -------------------------- //\n\n'use strict';\n\nfunction PageDots( parent ) {\n this.parent = parent;\n this._create();\n}\n\nPageDots.prototype = Object.create( Unipointer.prototype );\n\nPageDots.prototype._create = function() {\n // create holder element\n this.holder = document.createElement('ol');\n this.holder.className = 'flickity-page-dots';\n // create dots, array of elements\n this.dots = [];\n // events\n this.handleClick = this.onClick.bind( this );\n this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) );\n};\n\nPageDots.prototype.activate = function() {\n this.setDots();\n this.holder.addEventListener( 'click', this.handleClick );\n this.bindStartEvent( this.holder );\n // add to DOM\n this.parent.element.appendChild( this.holder );\n};\n\nPageDots.prototype.deactivate = function() {\n this.holder.removeEventListener( 'click', this.handleClick );\n this.unbindStartEvent( this.holder );\n // remove from DOM\n this.parent.element.removeChild( this.holder );\n};\n\nPageDots.prototype.setDots = function() {\n // get difference between number of slides and number of dots\n var delta = this.parent.slides.length - this.dots.length;\n if ( delta > 0 ) {\n this.addDots( delta );\n } else if ( delta < 0 ) {\n this.removeDots( -delta );\n }\n};\n\nPageDots.prototype.addDots = function( count ) {\n var fragment = document.createDocumentFragment();\n var newDots = [];\n var length = this.dots.length;\n var max = length + count;\n\n for ( var i = length; i < max; i++ ) {\n var dot = document.createElement('li');\n dot.className = 'dot';\n dot.setAttribute( 'aria-label', 'Page dot ' + ( i + 1 ) );\n fragment.appendChild( dot );\n newDots.push( dot );\n }\n\n this.holder.appendChild( fragment );\n this.dots = this.dots.concat( newDots );\n};\n\nPageDots.prototype.removeDots = function( count ) {\n // remove from this.dots collection\n var removeDots = this.dots.splice( this.dots.length - count, count );\n // remove from DOM\n removeDots.forEach( function( dot ) {\n this.holder.removeChild( dot );\n }, this );\n};\n\nPageDots.prototype.updateSelected = function() {\n // remove selected class on previous\n if ( this.selectedDot ) {\n this.selectedDot.className = 'dot';\n this.selectedDot.removeAttribute('aria-current');\n }\n // don't proceed if no dots\n if ( !this.dots.length ) {\n return;\n }\n this.selectedDot = this.dots[ this.parent.selectedIndex ];\n this.selectedDot.className = 'dot is-selected';\n this.selectedDot.setAttribute( 'aria-current', 'step' );\n};\n\nPageDots.prototype.onTap = // old method name, backwards-compatible\nPageDots.prototype.onClick = function( event ) {\n var target = event.target;\n // only care about dot clicks\n if ( target.nodeName != 'LI' ) {\n return;\n }\n\n this.parent.uiChange();\n var index = this.dots.indexOf( target );\n this.parent.select( index );\n};\n\nPageDots.prototype.destroy = function() {\n this.deactivate();\n this.allOff();\n};\n\nFlickity.PageDots = PageDots;\n\n// -------------------------- Flickity -------------------------- //\n\nutils.extend( Flickity.defaults, {\n pageDots: true,\n} );\n\nFlickity.createMethods.push('_createPageDots');\n\nvar proto = Flickity.prototype;\n\nproto._createPageDots = function() {\n if ( !this.options.pageDots ) {\n return;\n }\n this.pageDots = new PageDots( this );\n // events\n this.on( 'activate', this.activatePageDots );\n this.on( 'select', this.updateSelectedPageDots );\n this.on( 'cellChange', this.updatePageDots );\n this.on( 'resize', this.updatePageDots );\n this.on( 'deactivate', this.deactivatePageDots );\n};\n\nproto.activatePageDots = function() {\n this.pageDots.activate();\n};\n\nproto.updateSelectedPageDots = function() {\n this.pageDots.updateSelected();\n};\n\nproto.updatePageDots = function() {\n this.pageDots.setDots();\n};\n\nproto.deactivatePageDots = function() {\n this.pageDots.deactivate();\n};\n\n// ----- ----- //\n\nFlickity.PageDots = PageDots;\n\nreturn Flickity;\n\n} ) );\n","// player & autoPlay\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'ev-emitter/ev-emitter',\n 'fizzy-ui-utils/utils',\n './flickity',\n ], function( EvEmitter, utils, Flickity ) {\n return factory( EvEmitter, utils, Flickity );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n require('ev-emitter'),\n require('fizzy-ui-utils'),\n require('./flickity')\n );\n } else {\n // browser global\n factory(\n window.EvEmitter,\n window.fizzyUIUtils,\n window.Flickity\n );\n }\n\n}( window, function factory( EvEmitter, utils, Flickity ) {\n\n'use strict';\n\n// -------------------------- Player -------------------------- //\n\nfunction Player( parent ) {\n this.parent = parent;\n this.state = 'stopped';\n // visibility change event handler\n this.onVisibilityChange = this.visibilityChange.bind( this );\n this.onVisibilityPlay = this.visibilityPlay.bind( this );\n}\n\nPlayer.prototype = Object.create( EvEmitter.prototype );\n\n// start play\nPlayer.prototype.play = function() {\n if ( this.state == 'playing' ) {\n return;\n }\n // do not play if page is hidden, start playing when page is visible\n var isPageHidden = document.hidden;\n if ( isPageHidden ) {\n document.addEventListener( 'visibilitychange', this.onVisibilityPlay );\n return;\n }\n\n this.state = 'playing';\n // listen to visibility change\n document.addEventListener( 'visibilitychange', this.onVisibilityChange );\n // start ticking\n this.tick();\n};\n\nPlayer.prototype.tick = function() {\n // do not tick if not playing\n if ( this.state != 'playing' ) {\n return;\n }\n\n var time = this.parent.options.autoPlay;\n // default to 3 seconds\n time = typeof time == 'number' ? time : 3000;\n var _this = this;\n // HACK: reset ticks if stopped and started within interval\n this.clear();\n this.timeout = setTimeout( function() {\n _this.parent.next( true );\n _this.tick();\n }, time );\n};\n\nPlayer.prototype.stop = function() {\n this.state = 'stopped';\n this.clear();\n // remove visibility change event\n document.removeEventListener( 'visibilitychange', this.onVisibilityChange );\n};\n\nPlayer.prototype.clear = function() {\n clearTimeout( this.timeout );\n};\n\nPlayer.prototype.pause = function() {\n if ( this.state == 'playing' ) {\n this.state = 'paused';\n this.clear();\n }\n};\n\nPlayer.prototype.unpause = function() {\n // re-start play if paused\n if ( this.state == 'paused' ) {\n this.play();\n }\n};\n\n// pause if page visibility is hidden, unpause if visible\nPlayer.prototype.visibilityChange = function() {\n var isPageHidden = document.hidden;\n this[ isPageHidden ? 'pause' : 'unpause' ]();\n};\n\nPlayer.prototype.visibilityPlay = function() {\n this.play();\n document.removeEventListener( 'visibilitychange', this.onVisibilityPlay );\n};\n\n// -------------------------- Flickity -------------------------- //\n\nutils.extend( Flickity.defaults, {\n pauseAutoPlayOnHover: true,\n} );\n\nFlickity.createMethods.push('_createPlayer');\nvar proto = Flickity.prototype;\n\nproto._createPlayer = function() {\n this.player = new Player( this );\n\n this.on( 'activate', this.activatePlayer );\n this.on( 'uiChange', this.stopPlayer );\n this.on( 'pointerDown', this.stopPlayer );\n this.on( 'deactivate', this.deactivatePlayer );\n};\n\nproto.activatePlayer = function() {\n if ( !this.options.autoPlay ) {\n return;\n }\n this.player.play();\n this.element.addEventListener( 'mouseenter', this );\n};\n\n// Player API, don't hate the ... thanks I know where the door is\n\nproto.playPlayer = function() {\n this.player.play();\n};\n\nproto.stopPlayer = function() {\n this.player.stop();\n};\n\nproto.pausePlayer = function() {\n this.player.pause();\n};\n\nproto.unpausePlayer = function() {\n this.player.unpause();\n};\n\nproto.deactivatePlayer = function() {\n this.player.stop();\n this.element.removeEventListener( 'mouseenter', this );\n};\n\n// ----- mouseenter/leave ----- //\n\n// pause auto-play on hover\nproto.onmouseenter = function() {\n if ( !this.options.pauseAutoPlayOnHover ) {\n return;\n }\n this.player.pause();\n this.element.addEventListener( 'mouseleave', this );\n};\n\n// resume auto-play on hover off\nproto.onmouseleave = function() {\n this.player.unpause();\n this.element.removeEventListener( 'mouseleave', this );\n};\n\n// ----- ----- //\n\nFlickity.Player = Player;\n\nreturn Flickity;\n\n} ) );\n","// add, remove cell\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './flickity',\n 'fizzy-ui-utils/utils',\n ], function( Flickity, utils ) {\n return factory( window, Flickity, utils );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('./flickity'),\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n factory(\n window,\n window.Flickity,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, Flickity, utils ) {\n\n'use strict';\n\n// append cells to a document fragment\nfunction getCellsFragment( cells ) {\n var fragment = document.createDocumentFragment();\n cells.forEach( function( cell ) {\n fragment.appendChild( cell.element );\n } );\n return fragment;\n}\n\n// -------------------------- add/remove cell prototype -------------------------- //\n\nvar proto = Flickity.prototype;\n\n/**\n * Insert, prepend, or append cells\n * @param {[Element, Array, NodeList]} elems - Elements to insert\n * @param {Integer} index - Zero-based number to insert\n */\nproto.insert = function( elems, index ) {\n var cells = this._makeCells( elems );\n if ( !cells || !cells.length ) {\n return;\n }\n var len = this.cells.length;\n // default to append\n index = index === undefined ? len : index;\n // add cells with document fragment\n var fragment = getCellsFragment( cells );\n // append to slider\n var isAppend = index == len;\n if ( isAppend ) {\n this.slider.appendChild( fragment );\n } else {\n var insertCellElement = this.cells[ index ].element;\n this.slider.insertBefore( fragment, insertCellElement );\n }\n // add to this.cells\n if ( index === 0 ) {\n // prepend, add to start\n this.cells = cells.concat( this.cells );\n } else if ( isAppend ) {\n // append, add to end\n this.cells = this.cells.concat( cells );\n } else {\n // insert in this.cells\n var endCells = this.cells.splice( index, len - index );\n this.cells = this.cells.concat( cells ).concat( endCells );\n }\n\n this._sizeCells( cells );\n this.cellChange( index, true );\n};\n\nproto.append = function( elems ) {\n this.insert( elems, this.cells.length );\n};\n\nproto.prepend = function( elems ) {\n this.insert( elems, 0 );\n};\n\n/**\n * Remove cells\n * @param {[Element, Array, NodeList]} elems - ELements to remove\n */\nproto.remove = function( elems ) {\n var cells = this.getCells( elems );\n if ( !cells || !cells.length ) {\n return;\n }\n\n var minCellIndex = this.cells.length - 1;\n // remove cells from collection & DOM\n cells.forEach( function( cell ) {\n cell.remove();\n var index = this.cells.indexOf( cell );\n minCellIndex = Math.min( index, minCellIndex );\n utils.removeFrom( this.cells, cell );\n }, this );\n\n this.cellChange( minCellIndex, true );\n};\n\n/**\n * logic to be run after a cell's size changes\n * @param {Element} elem - cell's element\n */\nproto.cellSizeChange = function( elem ) {\n var cell = this.getCell( elem );\n if ( !cell ) {\n return;\n }\n cell.getSize();\n\n var index = this.cells.indexOf( cell );\n this.cellChange( index );\n};\n\n/**\n * logic any time a cell is changed: added, removed, or size changed\n * @param {Integer} changedCellIndex - index of the changed cell, optional\n * @param {Boolean} isPositioningSlider - Positions slider after selection\n */\nproto.cellChange = function( changedCellIndex, isPositioningSlider ) {\n var prevSelectedElem = this.selectedElement;\n this._positionCells( changedCellIndex );\n this._getWrapShiftCells();\n this.setGallerySize();\n // update selectedIndex\n // try to maintain position & select previous selected element\n var cell = this.getCell( prevSelectedElem );\n if ( cell ) {\n this.selectedIndex = this.getCellSlideIndex( cell );\n }\n this.selectedIndex = Math.min( this.slides.length - 1, this.selectedIndex );\n\n this.emitEvent( 'cellChange', [ changedCellIndex ] );\n // position slider\n this.select( this.selectedIndex );\n // do not position slider after lazy load\n if ( isPositioningSlider ) {\n this.positionSliderAtSelected();\n }\n};\n\n// ----- ----- //\n\nreturn Flickity;\n\n} ) );\n","// lazyload\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './flickity',\n 'fizzy-ui-utils/utils',\n ], function( Flickity, utils ) {\n return factory( window, Flickity, utils );\n } );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('./flickity'),\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n factory(\n window,\n window.Flickity,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, Flickity, utils ) {\n'use strict';\n\nFlickity.createMethods.push('_createLazyload');\nvar proto = Flickity.prototype;\n\nproto._createLazyload = function() {\n this.on( 'select', this.lazyLoad );\n};\n\nproto.lazyLoad = function() {\n var lazyLoad = this.options.lazyLoad;\n if ( !lazyLoad ) {\n return;\n }\n // get adjacent cells, use lazyLoad option for adjacent count\n var adjCount = typeof lazyLoad == 'number' ? lazyLoad : 0;\n var cellElems = this.getAdjacentCellElements( adjCount );\n // get lazy images in those cells\n var lazyImages = [];\n cellElems.forEach( function( cellElem ) {\n var lazyCellImages = getCellLazyImages( cellElem );\n lazyImages = lazyImages.concat( lazyCellImages );\n } );\n // load lazy images\n lazyImages.forEach( function( img ) {\n new LazyLoader( img, this );\n }, this );\n};\n\nfunction getCellLazyImages( cellElem ) {\n // check if cell element is lazy image\n if ( cellElem.nodeName == 'IMG' ) {\n var lazyloadAttr = cellElem.getAttribute('data-flickity-lazyload');\n var srcAttr = cellElem.getAttribute('data-flickity-lazyload-src');\n var srcsetAttr = cellElem.getAttribute('data-flickity-lazyload-srcset');\n if ( lazyloadAttr || srcAttr || srcsetAttr ) {\n return [ cellElem ];\n }\n }\n // select lazy images in cell\n var lazySelector = 'img[data-flickity-lazyload], ' +\n 'img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]';\n var imgs = cellElem.querySelectorAll( lazySelector );\n return utils.makeArray( imgs );\n}\n\n// -------------------------- LazyLoader -------------------------- //\n\n/**\n * class to handle loading images\n * @param {Image} img - Image element\n * @param {Flickity} flickity - Flickity instance\n */\nfunction LazyLoader( img, flickity ) {\n this.img = img;\n this.flickity = flickity;\n this.load();\n}\n\nLazyLoader.prototype.handleEvent = utils.handleEvent;\n\nLazyLoader.prototype.load = function() {\n this.img.addEventListener( 'load', this );\n this.img.addEventListener( 'error', this );\n // get src & srcset\n var src = this.img.getAttribute('data-flickity-lazyload') ||\n this.img.getAttribute('data-flickity-lazyload-src');\n var srcset = this.img.getAttribute('data-flickity-lazyload-srcset');\n // set src & serset\n this.img.src = src;\n if ( srcset ) {\n this.img.setAttribute( 'srcset', srcset );\n }\n // remove attr\n this.img.removeAttribute('data-flickity-lazyload');\n this.img.removeAttribute('data-flickity-lazyload-src');\n this.img.removeAttribute('data-flickity-lazyload-srcset');\n};\n\nLazyLoader.prototype.onload = function( event ) {\n this.complete( event, 'flickity-lazyloaded' );\n};\n\nLazyLoader.prototype.onerror = function( event ) {\n this.complete( event, 'flickity-lazyerror' );\n};\n\nLazyLoader.prototype.complete = function( event, className ) {\n // unbind events\n this.img.removeEventListener( 'load', this );\n this.img.removeEventListener( 'error', this );\n\n var cell = this.flickity.getParentCell( this.img );\n var cellElem = cell && cell.element;\n this.flickity.cellSizeChange( cellElem );\n\n this.img.classList.add( className );\n this.flickity.dispatchEvent( 'lazyLoad', event, cellElem );\n};\n\n// ----- ----- //\n\nFlickity.LazyLoader = LazyLoader;\n\nreturn Flickity;\n\n} ) );\n","/*!\n * Flickity v2.3.0\n * Touch, responsive, flickable carousels\n *\n * Licensed GPLv3 for open source use\n * or Flickity Commercial License for commercial use\n *\n * https://flickity.metafizzy.co\n * Copyright 2015-2021 Metafizzy\n */\n\n( function( window, factory ) {\n // universal module definition\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './flickity',\n './drag',\n './prev-next-button',\n './page-dots',\n './player',\n './add-remove-cell',\n './lazyload',\n ], factory );\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n require('./flickity'),\n require('./drag'),\n require('./prev-next-button'),\n require('./page-dots'),\n require('./player'),\n require('./add-remove-cell'),\n require('./lazyload')\n );\n }\n\n} )( window, function factory( Flickity ) {\n return Flickity;\n} );\n","/*----------------------------------------------------------------------------*\\\r\n Carousel\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nimport Flickity from 'flickity';\r\nimport debounce from '../lib/debounce';\r\n\r\n/* Enhance Flickity with custom slideStart function as it's not in Flickity's API. */\r\nvar startAnimation = Flickity.prototype.startAnimation;\r\nFlickity.prototype.startAnimation = function() {\r\n if ( this.isAnimating ) {\r\n return;\r\n }\r\n // do previous logic\r\n startAnimation.apply( this, arguments );\r\n // trigger event\r\n this.dispatchEvent('slideStart');\r\n};\r\n\r\nwindow.ggd.carousel = {\r\n init: function(){\r\n var self = this;\r\n var $carousel = [].slice.call(document.querySelectorAll('.js--carousel')) || [];\r\n\r\n if (!$carousel) {\r\n return false;\r\n }\r\n\r\n // Loop through all carousel instances.\r\n $carousel.forEach(function($carousel) {\r\n self.initCarousel($carousel);\r\n });\r\n },\r\n\r\n initCarousel: function ($carousel) {\r\n var self = this;\r\n var carouselOptions = JSON.parse($carousel.getAttribute('data-carousel-option'));\r\n\r\n // Init Flickity and get carousel-options from data-attribute\r\n var flkty = new Flickity($carousel,\r\n carouselOptions\r\n );\r\n\r\n // Init Flickity and get carousel-options from data-attribute\r\n self.customNav($carousel, flkty);\r\n },\r\n\r\n customNav: function ($carousel, flkty) {\r\n var self = this;\r\n var $nav = document.querySelector('.js--carousel__nav');\r\n\r\n // Check if there is a nav, otherwise return false.\r\n if (!$nav) {\r\n return false;\r\n }\r\n\r\n var $navCells = [].slice.call($nav.querySelectorAll('.js--carousel__nav-cell')) || [];\r\n\r\n // Set first nav item to active on pageload.\r\n self.setActiveNav(flkty, 0, $navCells);\r\n\r\n // When flickity starts scrolling set active nav item.\r\n flkty.on('slideStart', function() {\r\n var selectedCell = flkty.selectedIndex;\r\n self.setActiveNav(flkty, selectedCell, $navCells);\r\n });\r\n\r\n // Loop through all navigation triggers and get the slide numbers through data-attribute.\r\n $navCells.forEach(function($navCell) {\r\n $navCell.addEventListener('click', function() {\r\n\r\n var navCellNumber = $navCell.getAttribute('data-carousel-cell');\r\n\r\n if (navCellNumber) {\r\n self.goToSlide(flkty, navCellNumber, $navCells);\r\n }\r\n });\r\n });\r\n },\r\n\r\n // Set active carousel nav item\r\n setActiveNav: function(flkty, navCellNumber, $navCells) {\r\n var self = this;\r\n var $selectedCell = document.querySelector('.js--carousel__nav-cell[data-carousel-cell=\"' + navCellNumber + '\"]');\r\n var $navContent = $selectedCell.querySelector('.js--carousel__nav-content');\r\n var $innerCell = $selectedCell.querySelector('.js--carousel__nav-content__inner');\r\n var $innerHeight = self.getNavItemHeight($innerCell);\r\n\r\n $navCells.forEach(function($navCellAll) {\r\n // Remove is-active class from non-active carousel navs\r\n $navCellAll.classList.remove('is-active');\r\n\r\n // Reset height for all non-active carousel navs.\r\n var $navContentAll = $navCellAll.querySelector('.js--carousel__nav-content');\r\n\r\n if (window.innerWidth > 767) {\r\n $navContentAll.style.height = 0 +'px';\r\n } else {\r\n $navContentAll.style.height = 'auto';\r\n }\r\n });\r\n\r\n $navContent.style.height = $innerHeight+'px';\r\n $selectedCell.classList.add('is-active');\r\n },\r\n\r\n // Go to slide when clicking carousel nav item\r\n goToSlide: function(flkty, navCellNumber, $navCells) {\r\n var self = this;\r\n flkty.select(navCellNumber);\r\n flkty.stopPlayer();\r\n\r\n self.setActiveNav(flkty, navCellNumber, $navCells);\r\n },\r\n\r\n // Get innerHeight of navigation trigger.\r\n getNavItemHeight: function($inner){\r\n var height = 0;\r\n height = height + $inner.offsetHeight;\r\n\r\n return height;\r\n }\r\n};\r\n\r\n\r\nvar debounceCarousel = debounce(function() {\r\n window.ggd.carousel.init();\r\n}, 250);\r\n\r\nwindow.addEventListener('resize', debounceCarousel);\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.carousel.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Debounce function\r\n https://davidwalsh.name/javascript-debounce-function\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nexport default function (func, wait, immediate) {\r\n var timeout;\r\n return function() {\r\n var context = this;\r\n var args = arguments;\r\n\r\n var later = function() {\r\n timeout = null;\r\n\r\n if (!immediate) {\r\n func.apply(context, args);\r\n }\r\n };\r\n\r\n var callNow = immediate && !timeout;\r\n clearTimeout(timeout);\r\n timeout = setTimeout(later, wait);\r\n if (callNow) {\r\n func.apply(context, args);\r\n }\r\n };\r\n}\r\n","/*!\nWaypoints - 4.0.1\nCopyright © 2011-2016 Caleb Troughton\nLicensed under the MIT license.\nhttps://github.com/imakewebthings/waypoints/blob/master/licenses.txt\n*/\n(function() {\n 'use strict'\n\n var keyCounter = 0\n var allWaypoints = {}\n\n /* http://imakewebthings.com/waypoints/api/waypoint */\n function Waypoint(options) {\n if (!options) {\n throw new Error('No options passed to Waypoint constructor')\n }\n if (!options.element) {\n throw new Error('No element option passed to Waypoint constructor')\n }\n if (!options.handler) {\n throw new Error('No handler option passed to Waypoint constructor')\n }\n\n this.key = 'waypoint-' + keyCounter\n this.options = Waypoint.Adapter.extend({}, Waypoint.defaults, options)\n this.element = this.options.element\n this.adapter = new Waypoint.Adapter(this.element)\n this.callback = options.handler\n this.axis = this.options.horizontal ? 'horizontal' : 'vertical'\n this.enabled = this.options.enabled\n this.triggerPoint = null\n this.group = Waypoint.Group.findOrCreate({\n name: this.options.group,\n axis: this.axis\n })\n this.context = Waypoint.Context.findOrCreateByElement(this.options.context)\n\n if (Waypoint.offsetAliases[this.options.offset]) {\n this.options.offset = Waypoint.offsetAliases[this.options.offset]\n }\n this.group.add(this)\n this.context.add(this)\n allWaypoints[this.key] = this\n keyCounter += 1\n }\n\n /* Private */\n Waypoint.prototype.queueTrigger = function(direction) {\n this.group.queueTrigger(this, direction)\n }\n\n /* Private */\n Waypoint.prototype.trigger = function(args) {\n if (!this.enabled) {\n return\n }\n if (this.callback) {\n this.callback.apply(this, args)\n }\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/destroy */\n Waypoint.prototype.destroy = function() {\n this.context.remove(this)\n this.group.remove(this)\n delete allWaypoints[this.key]\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/disable */\n Waypoint.prototype.disable = function() {\n this.enabled = false\n return this\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/enable */\n Waypoint.prototype.enable = function() {\n this.context.refresh()\n this.enabled = true\n return this\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/next */\n Waypoint.prototype.next = function() {\n return this.group.next(this)\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/previous */\n Waypoint.prototype.previous = function() {\n return this.group.previous(this)\n }\n\n /* Private */\n Waypoint.invokeAll = function(method) {\n var allWaypointsArray = []\n for (var waypointKey in allWaypoints) {\n allWaypointsArray.push(allWaypoints[waypointKey])\n }\n for (var i = 0, end = allWaypointsArray.length; i < end; i++) {\n allWaypointsArray[i][method]()\n }\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/destroy-all */\n Waypoint.destroyAll = function() {\n Waypoint.invokeAll('destroy')\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/disable-all */\n Waypoint.disableAll = function() {\n Waypoint.invokeAll('disable')\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/enable-all */\n Waypoint.enableAll = function() {\n Waypoint.Context.refreshAll()\n for (var waypointKey in allWaypoints) {\n allWaypoints[waypointKey].enabled = true\n }\n return this\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/refresh-all */\n Waypoint.refreshAll = function() {\n Waypoint.Context.refreshAll()\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/viewport-height */\n Waypoint.viewportHeight = function() {\n return window.innerHeight || document.documentElement.clientHeight\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/viewport-width */\n Waypoint.viewportWidth = function() {\n return document.documentElement.clientWidth\n }\n\n Waypoint.adapters = []\n\n Waypoint.defaults = {\n context: window,\n continuous: true,\n enabled: true,\n group: 'default',\n horizontal: false,\n offset: 0\n }\n\n Waypoint.offsetAliases = {\n 'bottom-in-view': function() {\n return this.context.innerHeight() - this.adapter.outerHeight()\n },\n 'right-in-view': function() {\n return this.context.innerWidth() - this.adapter.outerWidth()\n }\n }\n\n window.Waypoint = Waypoint\n}())\n;(function() {\n 'use strict'\n\n function requestAnimationFrameShim(callback) {\n window.setTimeout(callback, 1000 / 60)\n }\n\n var keyCounter = 0\n var contexts = {}\n var Waypoint = window.Waypoint\n var oldWindowLoad = window.onload\n\n /* http://imakewebthings.com/waypoints/api/context */\n function Context(element) {\n this.element = element\n this.Adapter = Waypoint.Adapter\n this.adapter = new this.Adapter(element)\n this.key = 'waypoint-context-' + keyCounter\n this.didScroll = false\n this.didResize = false\n this.oldScroll = {\n x: this.adapter.scrollLeft(),\n y: this.adapter.scrollTop()\n }\n this.waypoints = {\n vertical: {},\n horizontal: {}\n }\n\n element.waypointContextKey = this.key\n contexts[element.waypointContextKey] = this\n keyCounter += 1\n if (!Waypoint.windowContext) {\n Waypoint.windowContext = true\n Waypoint.windowContext = new Context(window)\n }\n\n this.createThrottledScrollHandler()\n this.createThrottledResizeHandler()\n }\n\n /* Private */\n Context.prototype.add = function(waypoint) {\n var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical'\n this.waypoints[axis][waypoint.key] = waypoint\n this.refresh()\n }\n\n /* Private */\n Context.prototype.checkEmpty = function() {\n var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal)\n var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical)\n var isWindow = this.element == this.element.window\n if (horizontalEmpty && verticalEmpty && !isWindow) {\n this.adapter.off('.waypoints')\n delete contexts[this.key]\n }\n }\n\n /* Private */\n Context.prototype.createThrottledResizeHandler = function() {\n var self = this\n\n function resizeHandler() {\n self.handleResize()\n self.didResize = false\n }\n\n this.adapter.on('resize.waypoints', function() {\n if (!self.didResize) {\n self.didResize = true\n Waypoint.requestAnimationFrame(resizeHandler)\n }\n })\n }\n\n /* Private */\n Context.prototype.createThrottledScrollHandler = function() {\n var self = this\n function scrollHandler() {\n self.handleScroll()\n self.didScroll = false\n }\n\n this.adapter.on('scroll.waypoints', function() {\n if (!self.didScroll || Waypoint.isTouch) {\n self.didScroll = true\n Waypoint.requestAnimationFrame(scrollHandler)\n }\n })\n }\n\n /* Private */\n Context.prototype.handleResize = function() {\n Waypoint.Context.refreshAll()\n }\n\n /* Private */\n Context.prototype.handleScroll = function() {\n var triggeredGroups = {}\n var axes = {\n horizontal: {\n newScroll: this.adapter.scrollLeft(),\n oldScroll: this.oldScroll.x,\n forward: 'right',\n backward: 'left'\n },\n vertical: {\n newScroll: this.adapter.scrollTop(),\n oldScroll: this.oldScroll.y,\n forward: 'down',\n backward: 'up'\n }\n }\n\n for (var axisKey in axes) {\n var axis = axes[axisKey]\n var isForward = axis.newScroll > axis.oldScroll\n var direction = isForward ? axis.forward : axis.backward\n\n for (var waypointKey in this.waypoints[axisKey]) {\n var waypoint = this.waypoints[axisKey][waypointKey]\n if (waypoint.triggerPoint === null) {\n continue\n }\n var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint\n var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint\n var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint\n var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint\n if (crossedForward || crossedBackward) {\n waypoint.queueTrigger(direction)\n triggeredGroups[waypoint.group.id] = waypoint.group\n }\n }\n }\n\n for (var groupKey in triggeredGroups) {\n triggeredGroups[groupKey].flushTriggers()\n }\n\n this.oldScroll = {\n x: axes.horizontal.newScroll,\n y: axes.vertical.newScroll\n }\n }\n\n /* Private */\n Context.prototype.innerHeight = function() {\n /*eslint-disable eqeqeq */\n if (this.element == this.element.window) {\n return Waypoint.viewportHeight()\n }\n /*eslint-enable eqeqeq */\n return this.adapter.innerHeight()\n }\n\n /* Private */\n Context.prototype.remove = function(waypoint) {\n delete this.waypoints[waypoint.axis][waypoint.key]\n this.checkEmpty()\n }\n\n /* Private */\n Context.prototype.innerWidth = function() {\n /*eslint-disable eqeqeq */\n if (this.element == this.element.window) {\n return Waypoint.viewportWidth()\n }\n /*eslint-enable eqeqeq */\n return this.adapter.innerWidth()\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/context-destroy */\n Context.prototype.destroy = function() {\n var allWaypoints = []\n for (var axis in this.waypoints) {\n for (var waypointKey in this.waypoints[axis]) {\n allWaypoints.push(this.waypoints[axis][waypointKey])\n }\n }\n for (var i = 0, end = allWaypoints.length; i < end; i++) {\n allWaypoints[i].destroy()\n }\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/context-refresh */\n Context.prototype.refresh = function() {\n /*eslint-disable eqeqeq */\n var isWindow = this.element == this.element.window\n /*eslint-enable eqeqeq */\n var contextOffset = isWindow ? undefined : this.adapter.offset()\n var triggeredGroups = {}\n var axes\n\n this.handleScroll()\n axes = {\n horizontal: {\n contextOffset: isWindow ? 0 : contextOffset.left,\n contextScroll: isWindow ? 0 : this.oldScroll.x,\n contextDimension: this.innerWidth(),\n oldScroll: this.oldScroll.x,\n forward: 'right',\n backward: 'left',\n offsetProp: 'left'\n },\n vertical: {\n contextOffset: isWindow ? 0 : contextOffset.top,\n contextScroll: isWindow ? 0 : this.oldScroll.y,\n contextDimension: this.innerHeight(),\n oldScroll: this.oldScroll.y,\n forward: 'down',\n backward: 'up',\n offsetProp: 'top'\n }\n }\n\n for (var axisKey in axes) {\n var axis = axes[axisKey]\n for (var waypointKey in this.waypoints[axisKey]) {\n var waypoint = this.waypoints[axisKey][waypointKey]\n var adjustment = waypoint.options.offset\n var oldTriggerPoint = waypoint.triggerPoint\n var elementOffset = 0\n var freshWaypoint = oldTriggerPoint == null\n var contextModifier, wasBeforeScroll, nowAfterScroll\n var triggeredBackward, triggeredForward\n\n if (waypoint.element !== waypoint.element.window) {\n elementOffset = waypoint.adapter.offset()[axis.offsetProp]\n }\n\n if (typeof adjustment === 'function') {\n adjustment = adjustment.apply(waypoint)\n }\n else if (typeof adjustment === 'string') {\n adjustment = parseFloat(adjustment)\n if (waypoint.options.offset.indexOf('%') > - 1) {\n adjustment = Math.ceil(axis.contextDimension * adjustment / 100)\n }\n }\n\n contextModifier = axis.contextScroll - axis.contextOffset\n waypoint.triggerPoint = Math.floor(elementOffset + contextModifier - adjustment)\n wasBeforeScroll = oldTriggerPoint < axis.oldScroll\n nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll\n triggeredBackward = wasBeforeScroll && nowAfterScroll\n triggeredForward = !wasBeforeScroll && !nowAfterScroll\n\n if (!freshWaypoint && triggeredBackward) {\n waypoint.queueTrigger(axis.backward)\n triggeredGroups[waypoint.group.id] = waypoint.group\n }\n else if (!freshWaypoint && triggeredForward) {\n waypoint.queueTrigger(axis.forward)\n triggeredGroups[waypoint.group.id] = waypoint.group\n }\n else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) {\n waypoint.queueTrigger(axis.forward)\n triggeredGroups[waypoint.group.id] = waypoint.group\n }\n }\n }\n\n Waypoint.requestAnimationFrame(function() {\n for (var groupKey in triggeredGroups) {\n triggeredGroups[groupKey].flushTriggers()\n }\n })\n\n return this\n }\n\n /* Private */\n Context.findOrCreateByElement = function(element) {\n return Context.findByElement(element) || new Context(element)\n }\n\n /* Private */\n Context.refreshAll = function() {\n for (var contextId in contexts) {\n contexts[contextId].refresh()\n }\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/context-find-by-element */\n Context.findByElement = function(element) {\n return contexts[element.waypointContextKey]\n }\n\n window.onload = function() {\n if (oldWindowLoad) {\n oldWindowLoad()\n }\n Context.refreshAll()\n }\n\n\n Waypoint.requestAnimationFrame = function(callback) {\n var requestFn = window.requestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n requestAnimationFrameShim\n requestFn.call(window, callback)\n }\n Waypoint.Context = Context\n}())\n;(function() {\n 'use strict'\n\n function byTriggerPoint(a, b) {\n return a.triggerPoint - b.triggerPoint\n }\n\n function byReverseTriggerPoint(a, b) {\n return b.triggerPoint - a.triggerPoint\n }\n\n var groups = {\n vertical: {},\n horizontal: {}\n }\n var Waypoint = window.Waypoint\n\n /* http://imakewebthings.com/waypoints/api/group */\n function Group(options) {\n this.name = options.name\n this.axis = options.axis\n this.id = this.name + '-' + this.axis\n this.waypoints = []\n this.clearTriggerQueues()\n groups[this.axis][this.name] = this\n }\n\n /* Private */\n Group.prototype.add = function(waypoint) {\n this.waypoints.push(waypoint)\n }\n\n /* Private */\n Group.prototype.clearTriggerQueues = function() {\n this.triggerQueues = {\n up: [],\n down: [],\n left: [],\n right: []\n }\n }\n\n /* Private */\n Group.prototype.flushTriggers = function() {\n for (var direction in this.triggerQueues) {\n var waypoints = this.triggerQueues[direction]\n var reverse = direction === 'up' || direction === 'left'\n waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint)\n for (var i = 0, end = waypoints.length; i < end; i += 1) {\n var waypoint = waypoints[i]\n if (waypoint.options.continuous || i === waypoints.length - 1) {\n waypoint.trigger([direction])\n }\n }\n }\n this.clearTriggerQueues()\n }\n\n /* Private */\n Group.prototype.next = function(waypoint) {\n this.waypoints.sort(byTriggerPoint)\n var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)\n var isLast = index === this.waypoints.length - 1\n return isLast ? null : this.waypoints[index + 1]\n }\n\n /* Private */\n Group.prototype.previous = function(waypoint) {\n this.waypoints.sort(byTriggerPoint)\n var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)\n return index ? this.waypoints[index - 1] : null\n }\n\n /* Private */\n Group.prototype.queueTrigger = function(waypoint, direction) {\n this.triggerQueues[direction].push(waypoint)\n }\n\n /* Private */\n Group.prototype.remove = function(waypoint) {\n var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)\n if (index > -1) {\n this.waypoints.splice(index, 1)\n }\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/first */\n Group.prototype.first = function() {\n return this.waypoints[0]\n }\n\n /* Public */\n /* http://imakewebthings.com/waypoints/api/last */\n Group.prototype.last = function() {\n return this.waypoints[this.waypoints.length - 1]\n }\n\n /* Private */\n Group.findOrCreate = function(options) {\n return groups[options.axis][options.name] || new Group(options)\n }\n\n Waypoint.Group = Group\n}())\n;(function() {\n 'use strict'\n\n var Waypoint = window.Waypoint\n\n function isWindow(element) {\n return element === element.window\n }\n\n function getWindow(element) {\n if (isWindow(element)) {\n return element\n }\n return element.defaultView\n }\n\n function NoFrameworkAdapter(element) {\n this.element = element\n this.handlers = {}\n }\n\n NoFrameworkAdapter.prototype.innerHeight = function() {\n var isWin = isWindow(this.element)\n return isWin ? this.element.innerHeight : this.element.clientHeight\n }\n\n NoFrameworkAdapter.prototype.innerWidth = function() {\n var isWin = isWindow(this.element)\n return isWin ? this.element.innerWidth : this.element.clientWidth\n }\n\n NoFrameworkAdapter.prototype.off = function(event, handler) {\n function removeListeners(element, listeners, handler) {\n for (var i = 0, end = listeners.length - 1; i < end; i++) {\n var listener = listeners[i]\n if (!handler || handler === listener) {\n element.removeEventListener(listener)\n }\n }\n }\n\n var eventParts = event.split('.')\n var eventType = eventParts[0]\n var namespace = eventParts[1]\n var element = this.element\n\n if (namespace && this.handlers[namespace] && eventType) {\n removeListeners(element, this.handlers[namespace][eventType], handler)\n this.handlers[namespace][eventType] = []\n }\n else if (eventType) {\n for (var ns in this.handlers) {\n removeListeners(element, this.handlers[ns][eventType] || [], handler)\n this.handlers[ns][eventType] = []\n }\n }\n else if (namespace && this.handlers[namespace]) {\n for (var type in this.handlers[namespace]) {\n removeListeners(element, this.handlers[namespace][type], handler)\n }\n this.handlers[namespace] = {}\n }\n }\n\n /* Adapted from jQuery 1.x offset() */\n NoFrameworkAdapter.prototype.offset = function() {\n if (!this.element.ownerDocument) {\n return null\n }\n\n var documentElement = this.element.ownerDocument.documentElement\n var win = getWindow(this.element.ownerDocument)\n var rect = {\n top: 0,\n left: 0\n }\n\n if (this.element.getBoundingClientRect) {\n rect = this.element.getBoundingClientRect()\n }\n\n return {\n top: rect.top + win.pageYOffset - documentElement.clientTop,\n left: rect.left + win.pageXOffset - documentElement.clientLeft\n }\n }\n\n NoFrameworkAdapter.prototype.on = function(event, handler) {\n var eventParts = event.split('.')\n var eventType = eventParts[0]\n var namespace = eventParts[1] || '__default'\n var nsHandlers = this.handlers[namespace] = this.handlers[namespace] || {}\n var nsTypeList = nsHandlers[eventType] = nsHandlers[eventType] || []\n\n nsTypeList.push(handler)\n this.element.addEventListener(eventType, handler)\n }\n\n NoFrameworkAdapter.prototype.outerHeight = function(includeMargin) {\n var height = this.innerHeight()\n var computedStyle\n\n if (includeMargin && !isWindow(this.element)) {\n computedStyle = window.getComputedStyle(this.element)\n height += parseInt(computedStyle.marginTop, 10)\n height += parseInt(computedStyle.marginBottom, 10)\n }\n\n return height\n }\n\n NoFrameworkAdapter.prototype.outerWidth = function(includeMargin) {\n var width = this.innerWidth()\n var computedStyle\n\n if (includeMargin && !isWindow(this.element)) {\n computedStyle = window.getComputedStyle(this.element)\n width += parseInt(computedStyle.marginLeft, 10)\n width += parseInt(computedStyle.marginRight, 10)\n }\n\n return width\n }\n\n NoFrameworkAdapter.prototype.scrollLeft = function() {\n var win = getWindow(this.element)\n return win ? win.pageXOffset : this.element.scrollLeft\n }\n\n NoFrameworkAdapter.prototype.scrollTop = function() {\n var win = getWindow(this.element)\n return win ? win.pageYOffset : this.element.scrollTop\n }\n\n NoFrameworkAdapter.extend = function() {\n var args = Array.prototype.slice.call(arguments)\n\n function merge(target, obj) {\n if (typeof target === 'object' && typeof obj === 'object') {\n for (var key in obj) {\n if (obj.hasOwnProperty(key)) {\n target[key] = obj[key]\n }\n }\n }\n\n return target\n }\n\n for (var i = 1, end = args.length; i < end; i++) {\n merge(args[0], args[i])\n }\n return args[0]\n }\n\n NoFrameworkAdapter.inArray = function(element, array, i) {\n return array == null ? -1 : array.indexOf(element, i)\n }\n\n NoFrameworkAdapter.isEmptyObject = function(obj) {\n /* eslint no-unused-vars: 0 */\n for (var name in obj) {\n return false\n }\n return true\n }\n\n Waypoint.adapters.push({\n name: 'noframework',\n Adapter: NoFrameworkAdapter\n })\n Waypoint.Adapter = NoFrameworkAdapter\n}())\n;","/*----------------------------------------------------------------------------*\\\r\n Scroll\r\n Functions that trigger on scroll events.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nimport 'waypoints/lib/noframework.waypoints';\r\n\r\nwindow.ggd.scroll = {\r\n init: function(){\r\n var self = this;\r\n\r\n self.initSmoothScroll();\r\n self.initSections();\r\n self.stickyScroll();\r\n },\r\n\r\n initSmoothScroll: function() {\r\n this.selectBoxScroll();\r\n },\r\n\r\n // Scroll function for selectbox element.\r\n selectBoxScroll: function() {\r\n var $selectBox = document.querySelector('.js--smooth-scroll-select');\r\n\r\n if ($selectBox === null) {\r\n return false;\r\n }\r\n\r\n $selectBox.addEventListener('change', function(){\r\n var selectValue = this.options[$selectBox.selectedIndex].value;\r\n var anchor = document.querySelector(selectValue);\r\n\r\n anchor.scrollIntoView({\r\n behavior: 'smooth',\r\n });\r\n });\r\n },\r\n\r\n initSections: function() {\r\n var self = this;\r\n\r\n // Get all sections with a ID.\r\n var $anchorNav = document.querySelector('.js--anchor-nav');\r\n var $sections = document.querySelectorAll('section[id]');\r\n\r\n if ($anchorNav === null) {\r\n return;\r\n }\r\n\r\n // Loop through all sections on a page.\r\n for (var i = 0; i < $sections.length; ++i) {\r\n var $section = $sections[i].id;\r\n\r\n // Create waypoints for all sections\r\n var element = document.getElementById($section);\r\n element.setAttribute('number', i);\r\n new window.Waypoint({\r\n element: element,\r\n handler: function handler(direction) {\r\n var $item = this.element.id;\r\n var number = this.element.getAttribute('number');\r\n if (direction === 'up') {\r\n if (number > 0) {\r\n self.activeNavItem($sections[number - 1].id);\r\n }\r\n } else {\r\n self.activeNavItem($item);\r\n }\r\n },\r\n offset: '65'\r\n });\r\n }\r\n },\r\n\r\n // Set active class in anchor nav for active section\r\n activeNavItem: function($item) {\r\n var $navItems = document.querySelectorAll('.js--anchor-nav__item');\r\n\r\n for (var i = 0; i < $navItems.length; ++i) {\r\n var $navItem = $navItems[i];\r\n var navItemHref = $navItem.getAttribute('href');\r\n var navItemId = navItemHref.split('#');\r\n navItemId = navItemId[1];\r\n\r\n $navItem.classList.remove('is-active');\r\n\r\n if (navItemId === $item) {\r\n $navItem.classList.add('is-active');\r\n }\r\n }\r\n },\r\n\r\n // Sticky nav.\r\n stickyScroll: function() {\r\n var $el = document.querySelector('.js--sticky-scroll');\r\n\r\n if ($el === null) {\r\n return false;\r\n }\r\n\r\n var $elHeight = $el.offsetHeight;\r\n\r\n window.addEventListener('scroll', function() {\r\n var stickyOffset = $el.getBoundingClientRect().top;\r\n\r\n if(stickyOffset <= 0) {\r\n $el.classList.add('is-sticky');\r\n $el.style.paddingTop = $elHeight + 'px';\r\n } else {\r\n $el.classList.remove('is-sticky');\r\n $el.style.paddingTop = '0px';\r\n }\r\n });\r\n },\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.scroll.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Video\r\n Function for YT video's.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.video = {\r\n init: function () {\r\n var self = this;\r\n //self.heroVideo();\r\n self.getVideos();\r\n\r\n var tag = document.createElement('script');\r\n tag.src = 'https://www.youtube.com/iframe_api';\r\n var firstScriptTag = document.getElementsByTagName('script')[0];\r\n firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\r\n },\r\n\r\n initVideo: function (videoId, hasAutoplay, hasControls, $videoPlaceholder) {\r\n if ($videoPlaceholder !== null) {\r\n var playerWrap = document.createElement('div');\r\n $videoPlaceholder.appendChild(playerWrap);\r\n }\r\n\r\n if (videoId) {\r\n new window.YT.Player(playerWrap, {\r\n width: '100%',\r\n height: 570,\r\n videoId: videoId,\r\n playerVars: {\r\n 'disablekb': 1,\r\n 'autoplay': hasAutoplay,\r\n 'controls': hasControls,\r\n 'loop': 1,\r\n 'modestbranding': 1,\r\n 'rel': 0,\r\n 'showinfo': 0,\r\n 'playlist': videoId\r\n }\r\n });\r\n }\r\n },\r\n\r\n /* Init Homepage hero video */\r\n /*heroVideo: function () {\r\n var self = this;\r\n var $videoPlaceholder = document.querySelector('.js--hero__video-insert');\r\n var $videoHero = document.querySelector('.js--hero-video');*/\r\n\r\n /* Check if video is in hero and if screenwidth is bigger then desk. */\r\n /*if ($videoHero && Modernizr.mq(enex.config.mq.desk)) {\r\n var videoId = $videoPlaceholder.getAttribute('data-video-id');\r\n var hasAutoplay = $videoPlaceholder.getAttribute('data-video-autoplay');\r\n var hasControls = $videoPlaceholder.getAttribute('data-video-controls');\r\n\r\n self.initVideo(videoId, hasAutoplay, hasControls, $videoPlaceholder);\r\n }\r\n },*/\r\n\r\n /*muteVideo: function(player) {\r\n // Check if video is in hero, then mute it.\r\n if (player.a.parentNode.className === 'js--hero__video-insert'){\r\n player.mute();\r\n }\r\n },*/\r\n\r\n getVideos: function() {\r\n var self = this;\r\n var $videoElements = document.querySelectorAll('.js--video');\r\n\r\n for (var i = 0; i < $videoElements.length; ++i) {\r\n var $videoElement = $videoElements[i];\r\n self.loadVideoTrigger($videoElement);\r\n }\r\n },\r\n\r\n /* Open video lightbox from button click */\r\n loadVideoTrigger: function($videoElement) {\r\n var self = this;\r\n var $videoTrigger = $videoElement.querySelector('.js--video__trigger');\r\n\r\n var videoId = $videoTrigger.getAttribute('data-video-id');\r\n var hasAutoplay = $videoTrigger.getAttribute('data-video-autoplay');\r\n var hasControls = $videoTrigger.getAttribute('data-video-controls');\r\n\r\n $videoTrigger.addEventListener('click', function(){\r\n $videoElement.classList.add('is-active');\r\n self.appendVideoBlock(videoId, hasAutoplay, hasControls, this, $videoElement);\r\n });\r\n },\r\n\r\n /* Append video to inline video block */\r\n appendVideoBlock: function (videoId, hasAutoplay, hasControls, $videoTrigger, $videoElement) {\r\n var self = this;\r\n\r\n var $videoBlock = $videoTrigger.parentNode;\r\n $videoBlock.classList.add('is-active');\r\n\r\n // Get video wrap of current Video Block.\r\n var $videoWraps = $videoElement.querySelector('.js--video__wrap');\r\n\r\n // Embed flexembed div and js video insert div.\r\n $videoWraps.innerHTML = '
';\r\n var $videoContainer = $videoWraps.querySelector('.js--video-insert--block');\r\n\r\n // Load video in current video block.\r\n self.initVideo(videoId, hasAutoplay, hasControls, $videoContainer);\r\n self.closeVideo($videoElement, $videoWraps, $videoBlock);\r\n },\r\n\r\n closeVideo: function ($videoElement, $videoWraps, $videoBlock) {\r\n var $closeVideoTrigger = $videoElement.querySelector('.video-block__close');\r\n\r\n if (!$closeVideoTrigger) {\r\n return false;\r\n }\r\n\r\n $closeVideoTrigger.addEventListener('click', function(){\r\n $videoElement.classList.remove('is-active');\r\n $videoBlock.classList.remove('is-active');\r\n\r\n // Clear video\r\n $videoWraps.innerHTML = '';\r\n });\r\n }\r\n};\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.video.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Nav filter\r\n Filter nav functions, for opening and closing nav.\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.filter = {\r\n init: function() {\r\n var self = this;\r\n var $filter = document.querySelector('.js--nav-filter');\r\n\r\n if (!$filter) {\r\n return;\r\n }\r\n\r\n var $modal = $filter.querySelector('.js--nav-filter__modal'),\r\n $open = document.querySelector('.js--nav-filter__open'),\r\n $close = $filter.querySelector('.js--nav-filter__close');\r\n\r\n self.openFilter($filter, $modal, $open, $close);\r\n },\r\n\r\n openFilter: function ($filter, $modal, $open, $close) {\r\n $open.addEventListener('click', function(event){\r\n event.preventDefault();\r\n $modal.classList.add('is-open');\r\n });\r\n\r\n $close.addEventListener('click', function(event){\r\n event.preventDefault();\r\n $modal.classList.remove('is-open');\r\n });\r\n }\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.filter.init();\r\n}, false);\r\n","/*----------------------------------------------------------------------------*\\\r\n Shadow.overlay\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nwindow.ggd.shadow = {\r\n init: function(){\r\n var self = this;\r\n var $shadowOverlay = document.querySelector('.js--shadow-overlay');\r\n var $shadowOverlayTriggers = document.querySelectorAll('.js--shadow-overlay__trigger');\r\n var $shadowOverlayFocuses = document.querySelectorAll('.js--shadow-overlay__focus');\r\n\r\n // Check if shadowOverlay is available.\r\n if (!$shadowOverlay) {\r\n return false;\r\n }\r\n\r\n for (var i = 0; i < $shadowOverlayTriggers.length; ++i) {\r\n var $shadowOverlayTrigger = $shadowOverlayTriggers[i];\r\n self.triggerShadow($shadowOverlay, $shadowOverlayTrigger);\r\n self.clickShadow($shadowOverlay);\r\n }\r\n\r\n for (var j = 0; j < $shadowOverlayFocuses.length; ++j) {\r\n var $shadowOverlayFocus = $shadowOverlayFocuses[j];\r\n self.focusShadow($shadowOverlay, $shadowOverlayFocus);\r\n }\r\n },\r\n\r\n openShadow: function () {\r\n var $shadowOverlay = document.querySelector('.js--shadow-overlay');\r\n\r\n $shadowOverlay.classList.add('is-active');\r\n $shadowOverlay.classList.add('is-animating-in');\r\n\r\n setTimeout(function() {\r\n $shadowOverlay.classList.remove('is-animating-in');\r\n }, 500);\r\n },\r\n\r\n closeShadow: function () {\r\n var $shadowOverlay = document.querySelector('.js--shadow-overlay');\r\n\r\n $shadowOverlay.classList.add('is-animating-out');\r\n\r\n setTimeout(function(){\r\n $shadowOverlay.classList.remove('is-animating-out');\r\n $shadowOverlay.classList.remove('is-active');\r\n }, 500);\r\n },\r\n\r\n // Opens shadow with trigger button click.\r\n triggerShadow: function ($shadowOverlay, $shadowOverlayTrigger) {\r\n var self = this;\r\n\r\n $shadowOverlayTrigger.addEventListener('click', function() {\r\n // Set class is-triggered when clicking trigger.\r\n $shadowOverlayTrigger.classList.toggle('is-triggered');\r\n\r\n if ($shadowOverlayTrigger.classList.contains('is-triggered')) {\r\n self.openShadow();\r\n } else {\r\n self.closeShadow();\r\n }\r\n });\r\n },\r\n\r\n removeActiveTrigger: function () {\r\n var $shadowOverlayTriggers = [].slice.call(document.querySelectorAll('.js--shadow-overlay__trigger')) || [];\r\n\r\n $shadowOverlayTriggers.forEach(function($shadowOverlayTrigger) {\r\n $shadowOverlayTrigger.classList.remove('is-triggered');\r\n });\r\n },\r\n\r\n // Opens shadow with focus in inputfield.\r\n focusShadow: function ($shadowOverlay, $shadowOverlayFocus) {\r\n var self = this;\r\n\r\n $shadowOverlayFocus.addEventListener('focus', function() {\r\n self.openShadow();\r\n });\r\n\r\n $shadowOverlayFocus.addEventListener('blur', function() {\r\n self.closeShadow();\r\n });\r\n },\r\n\r\n // Close shadow when clicking on shadow-overlay. Also close depending menus and triggers.\r\n clickShadow: function ($shadowOverlay) {\r\n var self = this;\r\n\r\n $shadowOverlay.addEventListener('click', function(e) {\r\n e.preventDefault();\r\n\r\n self.closeShadow();\r\n\r\n // Close all megamenus.\r\n window.ggd.megamenu.closeAllMenus();\r\n\r\n // Close search bar.\r\n if (window.ggd.search) {\r\n window.ggd.search.close();\r\n }\r\n });\r\n }\r\n};\r\n\r\n\r\nwindow.addEventListener('load', function () {\r\n window.ggd.shadow.init();\r\n}, false);\r\n","class Foldout {\r\n constructor($el) {\r\n this.$toggle = $el.querySelector('.js--foldout__toggle');\r\n this.$content = $el.querySelector(`#${this.$toggle.getAttribute('aria-controls')}`);\r\n this.$focusEl = $el.querySelector('.js--foldout__focus');\r\n this.init();\r\n\r\n if ($el.classList.contains('js--foldout--search')) {\r\n window.ggd.search = this;\r\n }\r\n }\r\n\r\n init() {\r\n this.$toggle.addEventListener('click', () => {\r\n if (this.$toggle.getAttribute('aria-expanded') === 'false') {\r\n this.open();\r\n } else {\r\n this.close();\r\n }\r\n });\r\n }\r\n\r\n open() {\r\n this.$toggle.setAttribute('aria-expanded', 'true');\r\n this.$content.classList.add('is-active');\r\n\r\n if (this.$focusEl) {\r\n this.$focusEl.focus();\r\n }\r\n }\r\n\r\n close() {\r\n this.$toggle.setAttribute('aria-expanded', 'false');\r\n this.$content.classList.remove('is-active');\r\n // this.$content.hidden = true;\r\n }\r\n}\r\n\r\n[...document.querySelectorAll('.js--foldout')].forEach(($el) => {\r\n new Foldout($el);\r\n});\r\n","// const toTwoDigit = (number) =>\r\n// number.toLocaleString(undefined, {\r\n// minimumIntegerDigits: 2,\r\n// });\r\n//\r\n// exports.toTwoDigit = toTwoDigit;\r\n//\r\nexport const getKeyCode = (e) => {\r\n let code = '';\r\n\r\n if (e.key !== undefined) {\r\n code = e.key;\r\n } else if (e.keyIdentifier !== undefined) {\r\n code = e.keyIdentifier;\r\n } else if (e.keyCode !== undefined) {\r\n code = e.keyCode;\r\n }\r\n\r\n return code.toLowerCase();\r\n};\r\n\r\nexport const simplifyString = (string) => string.replace(/[^a-zA-Z]/g, '').toLowerCase();\r\n\r\n/**\r\n * @param {string} string\r\n * @param {array} array\r\n */\r\nexport const fuzzyMatchStringInArray = (string, array) => {\r\n const simpleString = simplifyString(string);\r\n return array.filter(({value}) => simplifyString(value).search(simpleString) > -1);\r\n};\r\n\r\n// export const fuzzyMatchStringInArray = fuzzyMatchStringInArray;\r\n\r\nexport const $ = ($scope, selector) => {\r\n return $scope.querySelector(selector);\r\n};\r\nexport const $$ = ($scope, selector) => {\r\n return $scope.querySelectorAll(selector);\r\n};\r\n","import { getKeyCode, fuzzyMatchStringInArray } from '../utilties/index';\r\n\r\nclass Autocomplete {\r\n constructor($el) {\r\n this.$el = $el;\r\n\r\n this.state = {\r\n activeOption: null,\r\n };\r\n\r\n this.apiUrl = $el.dataset.suggestionUrl;\r\n this.queryMinLength = $el.dataset.queryMinLength;\r\n\r\n if (!this.apiUrl) {\r\n this.$wrapSelect = $el.querySelector('[data-module-bind=autocomplete-wrap-select]');\r\n this.$select = this.$wrapSelect.querySelector('[data-module-bind*=autocomplete-select]');\r\n }\r\n\r\n this.$input = $el.querySelector('[data-module-bind=autocomplete-input]');\r\n this.$list = $el.querySelector('[data-module-bind=autocomplete-list]');\r\n this.$amount = $el.querySelector('[data-module-bind=autocomplete-amount]');\r\n // I need this later in the click handler\r\n this.listItemSelector = '[data-module-bind=autocomplete-list-option]';\r\n this.$optionTemplate = $el.querySelector(this.listItemSelector);\r\n }\r\n\r\n init() {\r\n this.handleInputEvents();\r\n this.handleListEvents();\r\n this.hideFoldoutOnBlur();\r\n\r\n if (this.$input.value.length < this.queryMinLength) {\r\n return;\r\n }\r\n\r\n this.getMatches('').then((options) => {\r\n this.buildMenu(options);\r\n });\r\n }\r\n\r\n handleListEvents() {\r\n // event delegation for list item click\r\n this.$list.addEventListener('click', (e) => {\r\n if (e.target && e.target.matches(this.listItemSelector)) {\r\n this.selectOption(e.target.dataset.optionValue);\r\n }\r\n });\r\n\r\n // keyboard navigation in the list\r\n this.$list.addEventListener('keydown', (e) => {\r\n const keyCode = getKeyCode(e);\r\n switch (keyCode) {\r\n case 'enter':\r\n this.selectOption(e.target.dataset.optionValue);\r\n break;\r\n case 'tab':\r\n this.hideMenu();\r\n break;\r\n case 'arrowup':\r\n case 'up':\r\n e.preventDefault();\r\n if (this.state.activeOption !== 0) {\r\n this.highlightOption(this.state.activeOption - 1);\r\n } else {\r\n this.$input.focus();\r\n }\r\n break;\r\n case 'arrowdown':\r\n case 'down':\r\n e.preventDefault();\r\n this.highlightOption(this.state.activeOption + 1);\r\n break;\r\n case 'escape':\r\n case 'esc':\r\n this.hideMenu();\r\n break;\r\n // space, tab ?\r\n default:\r\n // focus ?\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * @param {number} index\r\n */\r\n highlightOption(index) {\r\n const $options = this.$list.querySelectorAll(this.listItemSelector);\r\n\r\n if (index >= $options.length) {\r\n return;\r\n }\r\n\r\n if (this.state.activeOption) {\r\n $options[this.state.activeOption].setAttribute('aria-selected', 'false');\r\n }\r\n\r\n this.state.activeOption = index;\r\n $options[this.state.activeOption].focus();\r\n $options[this.state.activeOption].setAttribute('aria-selected', 'true');\r\n }\r\n\r\n hideFoldoutOnBlur() {\r\n // hide foldout when clicking outside the component\r\n document.documentElement.addEventListener('click', (e) => {\r\n if (!this.$el.contains(e.target)) {\r\n this.hideMenu();\r\n }\r\n });\r\n }\r\n\r\n handleInputEvents() {\r\n // if tab out, hide the menu\r\n this.$input.addEventListener('keydown', (e) => {\r\n const keyCode = getKeyCode(e);\r\n if (keyCode === 'tab') {\r\n this.hideMenu();\r\n }\r\n });\r\n\r\n this.$input.addEventListener('keyup', (e) => {\r\n const keyCode = getKeyCode(e);\r\n switch (keyCode) {\r\n // ignore these keys, old & new spec names\r\n case 'esc':\r\n case 'escape':\r\n case 'up':\r\n case 'arrowup':\r\n case 'left':\r\n case 'arrowleft':\r\n case 'right':\r\n case 'arrowright':\r\n case 'space':\r\n case ' ':\r\n case 'enter':\r\n case 'shift':\r\n case 'tab':\r\n break;\r\n // on arrow down, jump to the list\r\n case 'arrowdown':\r\n case 'down':\r\n this.handleInputKeyPressDown();\r\n break;\r\n // otherwise, handle typing\r\n default:\r\n this.handleTyping();\r\n }\r\n });\r\n\r\n this.$input.addEventListener('focus', () => {\r\n let query = '';\r\n\r\n if (this.apiUrl) {\r\n query = this.$input.value;\r\n }\r\n\r\n if (query.length < this.queryMinLength) {\r\n return;\r\n }\r\n\r\n this.getMatches(query).then((options) => {\r\n this.buildMenu(options);\r\n this.showMenu();\r\n });\r\n });\r\n }\r\n\r\n handleTyping() {\r\n if (this.$input.value.length < this.queryMinLength) {\r\n return;\r\n }\r\n\r\n this.getMatches(this.$input.value).then((options) => this.handleResult(options));\r\n }\r\n\r\n /**\r\n * @param {array} options\r\n */\r\n handleResult(options) {\r\n if (!options.length) {\r\n this.hideMenu();\r\n this.setSelectValue('');\r\n } else {\r\n this.buildMenu(options);\r\n this.showMenu();\r\n }\r\n }\r\n\r\n /**\r\n * @param {string} message\r\n * @param {number} amount\r\n */\r\n showMessage(message, amount) {\r\n this.$list.innerHTML = '';\r\n const $loaderOption = this.$optionTemplate.cloneNode(true);\r\n // make it unselectable\r\n $loaderOption.removeAttribute('data-module-bind');\r\n $loaderOption.innerHTML = message;\r\n $loaderOption.hidden = false;\r\n this.$list.appendChild($loaderOption);\r\n this.showMenu();\r\n // set live region text (screen reader announcement)\r\n this.$amount.innerHTML = amount;\r\n }\r\n\r\n /**\r\n * @param {string} query\r\n */\r\n getMatches(query) {\r\n if (this.apiUrl) {\r\n return this.getRemoteMatches(query);\r\n }\r\n\r\n return this.getSelectMatches(query);\r\n }\r\n\r\n /**\r\n * @param {string} query\r\n */\r\n getSelectMatches(query) {\r\n if (query === '') {\r\n const options = [...this.$select.options];\r\n options.shift();\r\n return options;\r\n }\r\n\r\n return fuzzyMatchStringInArray(query, [...this.$select.options]);\r\n }\r\n\r\n /**\r\n * @param {string} query\r\n */\r\n async getRemoteMatches(query) {\r\n const controller = new AbortController();\r\n const { signal } = controller;\r\n\r\n let result;\r\n try {\r\n const request = await fetch(`${this.apiUrl}&suggestion=${query}`, { signal });\r\n result = await request.json();\r\n } catch (error) {\r\n result = {\r\n HasError: true,\r\n };\r\n }\r\n\r\n return result;\r\n }\r\n\r\n handleInputKeyPressDown() {\r\n const $options = this.$list.querySelectorAll(this.listItemSelector);\r\n\r\n if (!$options.length) {\r\n return;\r\n }\r\n\r\n // show menu, focus first item\r\n this.showMenu();\r\n this.highlightOption(0);\r\n }\r\n\r\n /**\r\n * @param {array} options\r\n */\r\n buildMenu(options) {\r\n this.$list.innerHTML = '';\r\n options.forEach((option) => {\r\n // build autocomplete list item\r\n const $option = this.$optionTemplate.cloneNode(true);\r\n $option.hidden = false;\r\n if (this.apiUrl) {\r\n // depending on data structure from api\r\n $option.dataset.optionValue = option.value;\r\n $option.innerHTML = option.value;\r\n } else {\r\n // value and innerText from `