(function(){var t;(t=jQuery).bigfoot=function(o){var e,n,i,a,r,s,l,f,c,d,u,p,h,g,v,b,m,O,C,_,T,y,w,F,x,N,k;return i=void 0,c={actionOriginalFN:"hide",activateCallback:function(){},activateOnHover:!1,allowMultipleFN:!1,anchorPattern:/(fn|footnote|note)[:\-_\d]/gi,anchorParentTagname:"sup",breakpoints:{},deleteOnUnhover:!1,footnoteParentClass:"footnote",footnoteTagname:"li",hoverDelay:250,numberResetSelector:void 0,popoverDeleteDelay:300,popoverCreateDelay:100,positionContent:!0,preventPageScroll:!0,scope:!1,useFootnoteOnlyOnce:!0,contentMarkup:'<aside class="bigfoot-footnote is-positioned-bottom" data-footnote-number="{{FOOTNOTENUM}}" data-footnote-identifier="{{FOOTNOTEID}}" alt="Footnote {{FOOTNOTENUM}}"> <div class="bigfoot-footnote__wrapper"> <div class="bigfoot-footnote__content"> {{FOOTNOTECONTENT}} </div></div> <div class="bigfoot-footnote__tooltip"></div> </aside>',buttonMarkup:'<div class=\'bigfoot-footnote__container\'> <button class="bigfoot-footnote__button" id="{{SUP:data-footnote-backlink-ref}}" data-footnote-number="{{FOOTNOTENUM}}" data-footnote-identifier="{{FOOTNOTEID}}" alt="See Footnote {{FOOTNOTENUM}}" rel="footnote" data-bigfoot-footnote="{{FOOTNOTECONTENT}}"> <svg class="bigfoot-footnote__button__circle" viewbox="0 0 6 6" preserveAspectRatio="xMinYMin"><circle r="3" cx="3" cy="3" fill="white"></circle></svg> <svg class="bigfoot-footnote__button__circle" viewbox="0 0 6 6" preserveAspectRatio="xMinYMin"><circle r="3" cx="3" cy="3" fill="white"></circle></svg> <svg class="bigfoot-footnote__button__circle" viewbox="0 0 6 6" preserveAspectRatio="xMinYMin"><circle r="3" cx="3" cy="3" fill="white"></circle></svg> </button></div>'},w=t.extend(c,o),v={},p=function(){var o,e,n,i,a,r,l,f,c,u,p,h,g,v,b,O,C,T,y;for(u=w.scope?w.scope+' a[href*="#"]':'a[href*="#"]',n=t(u).filter((function(){var o,e;return"null"!==(e=(o=t(this)).attr("rel"))&&null!=e||(e=""),(""+o.attr("href")+e).match(w.anchorPattern)&&o.closest("[class*="+w.footnoteParentClass+"]:not(a):not("+w.anchorParentTagname+")").length<1})),b=[],f=[],s(n,g=[]),t(g).each((function(){var o,e;if(e=t(this).data("footnote-ref").replace(/[:.+~*\]\[]/g,"\\$&"),w.useFootnoteOnlyOnce&&(e+=":not(.footnote-processed)"),(o=t(e).closest(w.footnoteTagname)).length>0)return b.push(o.first().addClass("footnote-processed")),f.push(this)})),h=(e=t("[data-footnote-identifier]:last")).length<1?0:+e.data("footnote-identifier"),y=[],O=C=0,T=b.length;0<=T?C<T:C>T;O=0<=T?++C:--C)switch(p=(p=m(t(b[O]).html().trim(),t(f[O]).data("footnote-backlink-ref"))).replace(/"/g,"&quot;").replace(/&lt;/g,"&ltsym;").replace(/&gt;/g,"&gtsym;"),h+=1,c="",r=t(f[O]),l=t(b[O]),null!=w.numberResetSelector?((o=r.closest(w.numberResetSelector)).is(i)?v+=1:v=1,i=o):v=h,0!==p.indexOf("<")&&(p="<p>"+p+"</p>"),c=w.buttonMarkup.replace(/\{\{FOOTNOTENUM\}\}/g,v).replace(/\{\{FOOTNOTEID\}\}/g,h).replace(/\{\{FOOTNOTECONTENT\}\}/g,p),c=_(c,"SUP",r),c=_(c,"FN",l),t(c).insertBefore(r),a=l.parent(),w.actionOriginalFN.toLowerCase()){case"hide":r.addClass("footnote-print-only"),l.addClass("footnote-print-only"),y.push(d(a));break;case"delete":r.remove(),l.remove(),y.push(d(a));break;default:y.push(r.addClass("footnote-print-only"))}switch($footnotesParent=t("[class="+w.footnoteParentClass+"]"),w.actionOriginalFN.toLowerCase()){case"hide":case"delete":y.push(d($footnotesParent));break;default:y.push($footnotesParent.addClass("footnote-print-only"))}return y},s=function(o,e){var n,i,a;null==e&&(e=[]),n=void 0,i=void 0,a=void 0,o.each((function(){var o,r;return r=t(this),i="#"+r.attr("href").split("#")[1],n=r.closest(w.anchorParentTagname),o=r.find(w.anchorParentTagname),n.length>0?(a=(n.attr("id")||"")+(r.attr("id")||""),e.push(n.attr({"data-footnote-backlink-ref":a,"data-footnote-ref":i}))):o.length>0?(a=(o.attr("id")||"")+(r.attr("id")||""),e.push(r.attr({"data-footnote-backlink-ref":a,"data-footnote-ref":i}))):(a=r.attr("id")||"",e.push(r.attr({"data-footnote-backlink-ref":a,"data-footnote-ref":i})))}))},d=function(t){var o;if(o=void 0,t&&0!==t.length)return t.is(":empty")||0===t.children(":not(.footnote-print-only)").length?(o=t.parent(),"delete"===w.actionOriginalFN.toLowerCase()?t.remove():t.addClass("footnote-print-only"),d(o)):t.children(":not(.footnote-print-only)").length===t.children("hr:not(.footnote-print-only), h4:not(.footnote-print-only), header:not(.footnote-print-only)").length?(o=t.parent(),"delete"===w.actionOriginalFN.toLowerCase()?t.remove():(t.children("hr").addClass("footnote-print-only"),t.children("h4").addClass("footnote-print-only"),t.children("header").addClass("footnote-print-only"),t.addClass("footnote-print-only")),d(o)):void 0},m=function(t,o){var e;return o.indexOf(" ")>=0&&(o=o.trim().replace(/\s+/g,"|").replace(/(.*)/g,"($1)")),e=new RegExp("(\\s|&nbsp;)*<\\s*a[^#<]*#"+o+"[^>]*>(.*?)<\\s*/\\s*a>","g"),t.replace(e,"").replace("[]","")},_=function(t,o,e){var n,i,a;for(n=void 0,a=void 0,n=(i=new RegExp("\\{\\{"+o+":([^\\}]*)\\}\\}","g")).exec(t);n;)n[1]&&(a=e.attr(n[1])||"",t=t.replace("{{"+o+":"+n[1]+"}}",a)),n=i.exec(t);return t},a=function(o){var e,n;if(w.activateOnHover){if(n='[data-footnote-identifier="'+(e=t(o.target).closest(".bigfoot-footnote__button")).attr("data-footnote-identifier")+'"]',e.hasClass("is-active"))return;e.addClass("is-hover-instantiated"),w.allowMultipleFN||C(".bigfoot-footnote:not("+n+")"),f(".bigfoot-footnote__button"+n).addClass("is-hover-instantiated")}},F=function(o){var e,n,i;e=(i=t(o.target)).closest(".bigfoot-footnote__button"),n=i.closest(".bigfoot-footnote"),e.length>0?(o.preventDefault(),l(e)):n.length<1&&t(".bigfoot-footnote").length>0&&C()},l=function(t){var o;t.blur(),o='data-footnote-identifier="'+t.attr("data-footnote-identifier")+'"',t.hasClass("changing")||(t.hasClass("is-active")?w.allowMultipleFN?C(".bigfoot-footnote["+o+"]"):C():(t.addClass("changing"),setTimeout((function(){return t.removeClass("changing")}),w.popoverCreateDelay),f(".bigfoot-footnote__button["+o+"]"),t.addClass("is-click-instantiated"),w.allowMultipleFN||C(".bigfoot-footnote:not(["+o+"])")))},f=function(o){var e,n;return e=void 0,e="string"!=typeof o&&w.allowMultipleFN?o:"string"!=typeof o?o.first():w.allowMultipleFN?t(o).closest(".bigfoot-footnote__button"):t(o+":first").closest(".bigfoot-footnote__button"),n=t(),e.each((function(){var o,i,a,s;a=t(this),s=void 0;try{return s=w.contentMarkup.replace(/\{\{FOOTNOTENUM\}\}/g,a.attr("data-footnote-number")).replace(/\{\{FOOTNOTEID\}\}/g,a.attr("data-footnote-identifier")).replace(/\{\{FOOTNOTECONTENT\}\}/g,a.attr("data-bigfoot-footnote")).replace(/\&gtsym\;/g,"&gt;").replace(/\&ltsym\;/g,"&lt;"),s=_(s,"BUTTON",a)}finally{o=t(s);try{w.activateCallback(o,a)}catch(t){}o.insertAfter(e),v[a.attr("data-footnote-identifier")]="init",o.attr("bigfoot-max-width",r(o.css("max-width"),o)),o.css("max-width",1e4),i=o.find(".bigfoot-footnote__content"),o.attr("data-bigfoot-max-height",r(i.css("max-height"),i)),T(),a.addClass("is-active"),o.find(".bigfoot-footnote__content").bindScrollHandler(),n=n.add(o)}})),setTimeout((function(){return n.addClass("is-active")}),w.popoverCreateDelay),n},n=function(){var t,o;return(t=document.createElement("div")).style.cssText="display:inline-block;padding:0;line-height:1;position:absolute;visibility:hidden;font-size:1em;",t.appendChild(document.createElement("M")),document.body.appendChild(t),o=t.offsetHeight,document.body.removeChild(t),o},r=function(t,o){return"none"===t?t=1e4:t.indexOf("rem")>=0?t=parseFloat(t)*n():t.indexOf("em")>=0?t=parseFloat(t)*parseFloat(o.css("font-size")):t.indexOf("px")>=0?(t=parseFloat(t))<=60&&(t/=parseFloat(o.parent().css("width"))):t.indexOf("%")>=0&&(t=parseFloat(t)/100),t},t.fn.bindScrollHandler=function(){return w.preventPageScroll?(t(this).on("DOMMouseScroll mousewheel",(function(o){var e,n,i,a,r,s,l,f;if(l=(n=t(this)).scrollTop(),s=n[0].scrollHeight,a=parseInt(n.css("height")),e=n.closest(".bigfoot-footnote"),n.scrollTop()>0&&n.scrollTop()<10&&e.addClass("is-scrollable"),e.hasClass("is-scrollable"))return r=function(){return o.stopPropagation(),o.preventDefault(),o.returnValue=!1,!1},!(f=(i="DOMMouseScroll"===o.type?-40*o.originalEvent.detail:o.originalEvent.wheelDelta)>0)&&-i>s-a-l?(n.scrollTop(s),e.addClass("is-fully-scrolled"),r()):f&&i>l?(n.scrollTop(0),e.removeClass("is-fully-scrolled"),r()):e.removeClass("is-fully-scrolled")})),t(this)):t(this)},x=function(o){if(w.deleteOnUnhover&&w.activateOnHover)return setTimeout((function(){if(t(o.target).closest(".bigfoot-footnote, .bigfoot-footnote__button"),t(".bigfoot-footnote__button:hover, .bigfoot-footnote:hover").length<1)return C()}),w.hoverDelay)},u=function(t){if(27===t.keyCode)return C()},C=function(o,e){var n,i,a,r;return null==o&&(o=".bigfoot-footnote"),null==e&&(e=w.popoverDeleteDelay),n=t(),r=void 0,i=void 0,a=void 0,t(o).each((function(){if(a=t(this),r=a.attr("data-footnote-identifier"),!(i=t('.bigfoot-footnote__button[data-footnote-identifier="'+r+'"]')).hasClass("changing"))return n=n.add(i),i.removeClass("is-active is-hover-instantiated is-click-instantiated").addClass("changing"),a.removeClass("is-active").addClass("disapearing"),setTimeout((function(){return a.remove(),delete v[r],i.removeClass("changing")}),e)})),n},T=function(o){var e;w.positionContent&&(e=o?o.type:"resize",t(".bigfoot-footnote").each((function(){var o,n,i,a,r,s,l,f,c,d,u,p,h,g,m;if(a=(i=t(this)).attr("data-footnote-identifier"),i.find(".bigfoot-footnote__content"),o=i.siblings(".bigfoot-footnote__button"),p=y(o),s=parseFloat(i.css("margin-top")),l=+i.attr("data-bigfoot-max-height"),h=2*s+i.outerHeight(),f=1e4,u=p.bottomRoom<h&&p.topRoom>p.bottomRoom,r=v[a],u?("top"!==r&&(v[a]="top",i.addClass("is-positioned-top").removeClass("is-positioned-bottom"),i.css("transform-origin",100*p.leftRelative+"% 100%")),f=p.topRoom-s-15):("bottom"===r&&"init"!==r||(v[a]="bottom",i.removeClass("is-positioned-top").addClass("is-positioned-bottom"),i.css("transform-origin",100*p.leftRelative+"% 0%")),f=p.bottomRoom-s-15),i.find(".bigfoot-footnote__content").css({"max-height":Math.min(f,l)+"px"}),"resize"===e&&(d=parseFloat(i.attr("bigfoot-max-width")),n=i.find(".bigfoot-footnote__wrapper"),c=d,d<=1&&(m=1e4,w.maxWidthRelativeTo&&(g=t(w.maxWidthRelativeTo)).length>0&&(m=g.outerWidth()),c=Math.min(window.innerWidth,m)*d),c=Math.min(c,i.find(".bigfoot-footnote__content").outerWidth()+1),n.css("max-width",c+"px"),i.css({left:-p.leftRelative*c+parseFloat(o.css("margin-left"))+o.outerWidth()/2+"px"}),b(i,p.leftRelative)),parseInt(i.outerHeight())<i.find(".bigfoot-footnote__content")[0].scrollHeight)return i.addClass("is-scrollable")})))},b=function(t,o){var e;null==o&&(o=.5),(e=t.find(".bigfoot-footnote__tooltip")).length>0&&e.css("left",100*o+"%")},y=function(t){var o,e,n,i,a,r;return e=parseFloat(t.css("margin-left")),n=parseFloat(t.outerWidth())-e,o=parseFloat(t.outerHeight()),r=k(),a=t.offset().top-r.scrollY+o/2,i=t.offset().left-r.scrollX+n/2,{topRoom:a,bottomRoom:r.height-a,leftRoom:i,rightRoom:r.width-i,leftRelative:i/r.width,topRelative:a/r.height}},k=function(){var o;return o=t(window),{width:window.innerWidth,height:window.innerHeight,scrollX:o.scrollLeft(),scrollY:o.scrollTop()}},e=function(t,o,e,n,a){var r,s,l,f,c,d;return null==n&&(n=w.popoverDeleteDelay),null==a&&(a=!0),f=void 0,s=void 0,d=void 0,"string"==typeof t?(c=(s=">"===(d="iphone"===t.toLowerCase()?"<320px":"ipad"===t.toLowerCase()?"<768px":t).charAt(0)?"min":"<"===d.charAt(0)?"max":null)?"("+s+"-width: "+d.substring(1)+")":d,f=window.matchMedia(c)):f=t,f.media&&"invalid"===f.media?{added:!1,mq:f,listener:null}:(r="max"===s,o=o||g(a,n,"min"===s,(function(t){return t.addClass("is-bottom-fixed")})),e=e||g(a,n,r,(function(){})),l=function(t){t.matches?o(a,i):e(a,i)},f.addListener(l),l(f),w.breakpoints[t]={added:!0,mq:f,listener:l},w.breakpoints[t])},g=function(t,o,e,n){return function(t,i){var a;return a=void 0,t&&(a=i.close(),i.updateSetting("activateCallback",n)),setTimeout((function(){if(i.updateSetting("positionContent",e),t)return i.activate(a)}),o)}},O=function(t,o){var e,n,i;if(e=void 0,i=!1,"string"==typeof t)i=void 0!==w.breakpoints[t];else for(e in w.breakpoints)w.breakpoints.hasOwnProperty(e)&&w.breakpoints[e].mq===t&&(i=!0);return i&&(n=w.breakpoints[e||t],o?o({matches:!1}):n.listener({matches:!1}),n.mq.removeListener(n.listener),delete w.breakpoints[e||t]),i},N=function(t,o){var e,n;if(e=void 0,"string"==typeof t)e=w[t],w[t]=o;else for(n in e={},t)t.hasOwnProperty(n)&&(e[n]=w[n],w[n]=t[n]);return e},h=function(t){return w[t]},t(document).ready((function(){return p(),t(document).on("mouseenter",".bigfoot-footnote__button",a),t(document).on("touchend click",F),t(document).on("mouseout",".is-hover-instantiated",x),t(document).on("keyup",u),t(window).on("scroll resize",T),t(document).on("gestureend",(function(){return T()}))})),i={removePopovers:C,close:C,createPopover:f,activate:f,repositionFeet:T,reposition:T,addBreakpoint:e,removeBreakpoint:O,getSetting:h,updateSetting:N}}}).call(this);
