!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).littlefoot={})}(this,function(e){"use strict";var P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}var r=n(function(o){var i,a,c,u,s,l,f,d,p,v,h,m,y,g,b,w,_,x,E,S,O,L;!function(){var e,r,t="object"==typeof P?P:"object"==typeof self?self:"object"==typeof this?this:{};function n(n,r){return n!==t&&("function"==typeof Object.create?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(e,t){return n[e]=r?r(e,t):t}}e=n(t,n(o.exports)),r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},i=function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},a=Object.assign||function(e){for(var t,n=1,r=arguments.length;na[0]&&t[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},h=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||0
<% content %>
',buttonTemplate:''};function f(e,t){e.isReady()&&(e.dismiss(),setTimeout(function(){e.remove()},t))}var a=n(function(e,t){t.__esModule=!0;var p=96,v=25.4,h=72,m=6;function y(e){return e?o.getStyle(e,"fontSize")||y(e.parentElement):o.getStyle(window.document.documentElement,"fontSize")}t.pixels=function e(t,n){var r,o,i,a,c,u,s=null!=(o=null===(r=null==n?void 0:n.ownerDocument)||void 0===r?void 0:r.defaultView)?o:window,l=s.document.documentElement||s.document.body,f=(a=t||"0",c=parseFloat(a),u=a.match(/[\d-.]+(\w+)$/),[c,(null!=(i=null==u?void 0:u[1])?i:"").toLowerCase()]),d=f[0];switch(f[1]){case"rem":return d*e(y(window.document.documentElement));case"em":return d*e(y(n),null==n?void 0:n.parentElement);case"in":return d*p;case"q":return d*p/v/4;case"mm":return d*p/v;case"cm":return d*p*10/v;case"pt":return d*p/h;case"pc":return d*p/m;case"vh":return(d*s.innerHeight||l.clientWidth)/100;case"vw":return(d*s.innerWidth||l.clientHeight)/100;case"vmin":return d*Math.min(s.innerWidth||l.clientWidth,s.innerHeight||l.clientHeight)/100;case"vmax":return d*Math.max(s.innerWidth||l.clientWidth,s.innerHeight||l.clientHeight)/100;default:return d}}});t(a);var E=a.pixels,S="is-active",O="is-changing",L="is-scrollable";function j(e){var t=e.id,f=e.button,d=e.content,n=e.host,p=e.popover,c=e.wrapper,r=!1,v=0;return{id:t,activate:function(e){f.classList.add(O),f.setAttribute("aria-expanded","true"),f.classList.add(S),f.insertAdjacentElement("afterend",p),p.style.maxWidth=document.body.clientWidth+"px";var t=h(d,"maxHeight");v=Math.round(E(t,d)),"function"==typeof e&&e(p,f)},dismiss:function(){f.classList.add(O),f.blur(),f.setAttribute("aria-expanded","false"),f.classList.remove(S)},isActive:function(){return f.classList.contains(S)},isReady:function(){return!f.classList.contains(O)},isHovered:function(){return r},ready:function(){p.classList.add(S),f.classList.remove(O)},remove:function(){i(p),f.classList.remove(O)},reposition:function(){if(p.parentElement){var e=_(f),t=Math.min(v,(s=x(c=p,u=e),l=parseInt(h(c,"marginTop"),10),u[s?g:y]-l-15));d.style.maxHeight=t+"px",o=x(n=p,r=e),(i=n.dataset.footnotePosition)!==(a=o?g:y)&&(n.dataset.footnotePosition=a,n.classList.remove(""+m+i),n.classList.add(""+m+a),n.style.transformOrigin=100*r.leftRelative+"% "+(o?"100%":"0")),p.offsetHeight<=d.scrollHeight&&p.classList.add(L)}var n,r,o,i,a,c,u,s,l},resize:function(){if(p.parentElement){var e=_(f),t=d.offsetWidth,n=parseInt(h(f,"marginLeft"),10),r=-e.leftRelative*t+n+f.offsetWidth/2;p.style.left=r+"px",c.style.maxWidth=t+"px",o=p,i=e.leftRelative,(a=o.querySelector("."+u))&&(a.style.left=100*i+"%")}var o,i,a},startHovering:function(){r=!0},stopHovering:function(){r=!1},destroy:function(){i(n)}}}var c=n(function(e,t){t.__esModule=!0,t.throttle=function(r,o){void 0===o&&(o=0);var i,a=0;return Object.assign(function(){for(var e=[],t=0;t+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g;function h(e,t){e=e.slice(0).concat(e["default"]);var n=e.length,r,o,i,a,c=t,u,s,l=[];do{f.exec("");if(i=f.exec(c)){c=i[3];if(i[2]||!c){for(r=0;r3&&arguments[3]!==undefined?arguments[3]:{};var o=r.capture?true:false;var i=o?l:s;var a=i[e];if(!a){a=new c;i[e]=a;document.addEventListener(e,u,o)}a.add(t,n)}function r(e,t,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var o=r.capture?true:false;var i=o?l:s;var a=i[e];if(!a)return;a.remove(t,n);if(a.size)return;delete i[e];document.removeEventListener(e,u,o)}function o(e,t,n){return e.dispatchEvent(new CustomEvent(t,{bubbles:true,cancelable:true,detail:n}))}e.fire=o,e.off=r,e.on=t,Object.defineProperty(e,"__esModule",{value:true})}(t,d)});t(p);var T=p.off,k=p.on,H=16,A="[data-footnote-button]",D="[data-footnote-id]",I="[data-footnote-popover]",v="is-fully-scrolled";function F(e){return e.target}function R(e){return null==e?void 0:e.dataset.footnoteId}function W(r,o){return function(e){e.preventDefault();var t=R(F(e).closest(D)),n=t&&r(t);n&&o(n)}}function z(e,t){var r;e.addEventListener("wheel",M((r=t,function(e){var t=e.currentTarget,n=-e.deltaY;0"+n.innerHTML+"

"}}}var Q=function(o){var i=0,a=null;return function(e){var t=e.original,n=e.data,r=t.reference.closest(o);return i=a===r?i+1:1,a=r,{original:t,data:s(s({},n),{number:i})}}};function X(e){var t=/<%=?\s*(\w+?)\s*%>/g;return function(r){return e.replace(t,function(e,t){var n;return String(null!==(n=r[t])&&void 0!==n?n:"")})}}function Z(e){var s,l,i,a,c,u,f,t,n,r=e.allowDuplicates,o=e.anchorParentSelector,d=e.anchorPattern,p=e.buttonTemplate,v=e.contentTemplate,h=e.footnoteSelector,m=e.numberResetSelector,y=e.scope,g=(t=document,n=d,V(t,y+' a[href*="#"]').filter(function(e){return(e.href+e.rel).match(n)}).map((i=document,a=r,c=o,u=h,f=[],function(e){var t="#"+e.href.split("#")[1].replace(/[:.+~*[\]]/g,"\\$&"),n=V(i,t).find(function(e){return a||!f.includes(e)}),r=null==n?void 0:n.closest(u);if(r){f.push(r);var o=e.closest(c)||e;return{reference:o,referenceId:o.id||e.id,body:r}}})).filter(B).map(K).map(m?Q(m):function(e){return e}).map((s=X(p),l=X(v),function(e){var t=e.original,n=e.data,r=n.id,o=$(''+s(n)+""),i=o.firstElementChild;i.dataset.footnoteButton="",i.dataset.footnoteId=r,i.dataset.footnoteNumber=""+n.number;var a=$(l(n));a.dataset.footnotePopover="",a.dataset.footnoteId=r;var c=G(a,w),u=G(a,b);return z(u,a),{original:t,data:n,id:r,button:i,host:o,popover:a,content:u,wrapper:c}})));return g.forEach(function(e){var t,n,r=e.original,o=e.host;U(r.reference),U(r.body),Y(r.body.parentElement),t=r.reference,n=o,t.insertAdjacentElement("beforebegin",n)}),g.map(j)}function ee(e){e.forEach(function(e){return e.destroy()}),V(document,"."+q).forEach(function(e){return e.classList.remove(q)})}function te(e){void 0===e&&(e={});var t,n,r,o,i,a=s(s({},l),e),c=(r=(t={setup:Z,addListeners:C,cleanup:ee}).setup(n=a),o={activate:u,dismiss:f,lookup:function(t){return r.find(function(e){return e.id===t})},dismissAll:function(){r.forEach(function(e){return f(e,n.dismissDelay)})},repositionAll:function(){r.forEach(function(e){return e.reposition()})},resizeAll:function(){r.forEach(function(e){return e.resize()})},toggle:function(e){e.isActive()?f(e,n.dismissDelay):u(e,n.activateDelay)},hover:function(e){e.startHovering(),n.activateOnHover&&!e.isActive()&&u(e,n.hoverDelay)},unhover:function(e){e.stopHovering(),n.dismissOnUnhover&&setTimeout(function(){r.filter(function(e){return!e.isHovered()}).forEach(function(e){return f(e,n.dismissDelay)})},n.hoverDelay)}},i=t.addListeners(o),s(s({},o),{unmount:function(){i(),t.cleanup(r)}}));function u(t,e){n.allowMultiple||r.filter(function(e){return e.id!==t.id}).forEach(function(e){return f(e,n.dismissDelay)}),t.isReady()&&(t.activate(n.activateCallback),t.reposition(),t.resize(),setTimeout(function(){t.ready()},e))}return{activate:function(e,t){void 0===t&&(t=a.activateDelay);var n=c.lookup(e);n&&c.activate(n,t)},dismiss:function(e,t){void 0===t&&(t=a.dismissDelay);var n=e&&c.lookup(e);n?c.dismiss(n,t):c.dismissAll()},unmount:c.unmount,getSetting:function(e){return a[e]},updateSetting:function(e,t){a[e]=t}}}e.default=te,e.littlefoot=te,Object.defineProperty(e,"__esModule",{value:!0})});