!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
"}}}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})});