β Back to parkrun Userscripts
Analyzes the impact of cancelled parkrun events on nearby alternatives
What is a userscript?
A userscript is a small piece of JavaScript that runs in your browser and enhances specific websites. These scripts work with parkrun event pages, parkrunner profile pages, and results pages, and can be used with any userscript manager including Userscripts, Tampermonkey, Violentmonkey, or any compatible browser extension.
Installation
-
Install a userscript manager for your browser:
- Desktop: Userscripts (Safari), Tampermonkey (Chrome, Firefox, Edge, Opera), or Violentmonkey (Orion)
- iOS: Userscripts (Safari) or Violentmonkey (Orion)
- Android: Install Kiwi Browser, then install Tampermonkey or Violentmonkey from the Chrome Web Store.
- Click the install link below for this script.
- Click βInstallβ when prompted by your userscript manager.
Install parkrun Cancellation Impact
Bookmarklet version
You can also use this script as a bookmarklet (a bookmark whose URL is JavaScript), which can be useful on browsers that support bookmarks but not userscript managers.
Desktop bookmarklet
Drag this link to your bookmarks bar:
parkrun Cancellation Impact bookmarklet
Mobile bookmarklet
On mobile browsers that let you edit bookmark URLs:
- Copy the JavaScript code below to your clipboard.
- Create a new bookmark for any page.
- Edit the bookmark and replace its URL with the code you copied.
- Navigate to the relevant parkrun page.
- Select the bookmark to run the script.
javascript:function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regenerator(){var h,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function r(e,t,n,r){var a,o,l,i,s,c,d,u,p,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,o=n,d=r||[],u=!1,p={p:c=0,n:0,v:h,a:g,f:g.bind(h,4),d:function(e,t){return l=e,i=0,s=h,p.n=t,y}},function(e,t,n){if(1<c)throw TypeError("Generator is already running");for(u&&1===t&&g(t,n),i=t,s=n;(f=i<2?h:s)||!u;){l||(i?i<3?(1<i&&(p.n=-1),g(i,s)):p.n=s:p.v=s);try{if(c=2,l){if(f=l[e=i?e:"next"]){if(!(f=f.call(l,s)))throw TypeError("iterator result is not an object");if(!f.done)return f;s=f.value,i<2&&(i=0)}else 1===i&&(f=l.return)&&f.call(l),i<2&&(s=TypeError("The iterator does not provide a '"+e+"' method"),i=1);l=h}else if((f=(u=p.n<0)?s:a.call(o,p))!==y)break}catch(e){l=h,i=1,s=e}finally{c=1}}return{value:f,done:u}}),!0),t;function g(e,t){for(i=e,s=t,f=0;!u&&c&&!n&&f<d.length;f++){var n,r=d[f],a=p.p,o=r[2];3<e?(n=o===t)&&(s=r[(i=r[4])?5:i=3],r[4]=r[5]=h):r[0]<=a&&((n=e<2&&a<r[1])?(i=0,p.v=t,p.n=r[1]):a<o&&(n=e<3||r[0]>t||o<t)&&(r[4]=e,r[5]=t,p.n=o,i=0))}if(n||1<e)return y;throw u=!0,t}}var y={};function m(){}function a(){}function o(){}var f=Object.getPrototypeOf,e=[][t]?f(f([][t]())):(_regeneratorDefine2(f={},t,function(){return this}),f),l=o.prototype=m.prototype=Object.create(e);function i(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,o):(e.__proto__=o,_regeneratorDefine2(e,n,"GeneratorFunction")),e.prototype=Object.create(l),e}return _regeneratorDefine2(l,"constructor",a.prototype=o),_regeneratorDefine2(o,"constructor",a),_regeneratorDefine2(o,n,a.displayName="GeneratorFunction"),_regeneratorDefine2(l),_regeneratorDefine2(l,n,"Generator"),_regeneratorDefine2(l,t,function(){return this}),_regeneratorDefine2(l,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:r,m:i}})()}function _regeneratorDefine2(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(_regeneratorDefine2=function(e,t,n,r){function a(t,n){_regeneratorDefine2(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))})(e,t,n,r)}function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}function asyncGeneratorStep(e,t,n,r,a,o,l){try{var i=e[o](l),s=i.value}catch(e){return void n(e)}i.done?t(s):Promise.resolve(s).then(r,a)}function _asyncToGenerator(i){return function(){var e=this,l=arguments;return new Promise(function(t,n){var r=i.apply(e,l);function a(e){asyncGeneratorStep(r,t,n,a,o,"next",e)}function o(e){asyncGeneratorStep(r,t,n,a,o,"throw",e)}a(void 0)})}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,l,i=[],s=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(i.push(r.value),i.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(l=n.return(),Object(l)!==l))return}finally{if(c)throw a}}return i}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var BASELINE_EVENTS=12,GAP_THRESHOLD_DAYS=7;function calculateBaseline(e){return 0===e.dates.length?{avgFinishers:0,avgVolunteers:0,totalEvents:0,minFinishers:0,maxFinishers:0,minVolunteers:0,maxVolunteers:0}:{avgFinishers:Math.round(e.finishers.reduce(function(e,t){return e+t},0)/e.dates.length),avgVolunteers:Math.round(e.volunteers.reduce(function(e,t){return e+t},0)/e.dates.length),totalEvents:e.dates.length,minFinishers:Math.min.apply(Math,_toConsumableArray(e.finishers)),maxFinishers:Math.max.apply(Math,_toConsumableArray(e.finishers)),minVolunteers:Math.min.apply(Math,_toConsumableArray(e.volunteers)),maxVolunteers:Math.max.apply(Math,_toConsumableArray(e.volunteers))}}function calculateDistance(e,t,n,r){var a=(n-e)*Math.PI/180,r=(r-t)*Math.PI/180,t=Math.sin(a/2)*Math.sin(a/2)+Math.cos(e*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 6371*(2*Math.atan2(Math.sqrt(t),Math.sqrt(1-t)))}function calculateBearing(e,t,n,r){r=(r-t)*Math.PI/180,t=e*Math.PI/180,e=n*Math.PI/180,n=Math.sin(r)*Math.cos(e),t=Math.cos(t)*Math.sin(e)-Math.sin(t)*Math.cos(e)*Math.cos(r),e=180*Math.atan2(n,t)/Math.PI;return e<0&&(e+=360),e}function detectAllEventGaps(e,t){e=e.rawDates.map(function(e){return parseDateString(e)});if(e.length<1)return[];for(var n,r,a,o=[],l=_toConsumableArray(e).sort(function(e,t){return e.getTime()-t.getTime()}),i=1;i<l.length;i++){var s=l[i-1],c=l[i],d=(c-s)/864e5;GAP_THRESHOLD_DAYS<d&&o.push({gapStartDate:s,gapEndDate:c,daysDiff:d,eventsBefore:i,eventsAfter:l.length-i})}return t&&1<=l.length&&(n=l[l.length-1],r=parseDateString(t=toLocalDateString(t)),GAP_THRESHOLD_DAYS<=(a=(r-n)/864e5))&&o.push({gapStartDate:n,gapEndDate:r,gapEndDateStr:t,daysDiff:a,eventsBefore:e.length,eventsAfter:0}),o}function detectEventGap(e,t){var n=e.rawDates.map(function(e){return parseDateString(e)});if(n.length<1)return null;e=new Date(Math.max.apply(Math,_toConsumableArray(n.map(function(e){return e.getTime()}))));if(t){var t=toLocalDateString(t),r=parseDateString(t),a=(r-e)/864e5;if(GAP_THRESHOLD_DAYS<=a)return{gapStartDate:e,gapEndDate:r,gapEndDateStr:t,daysDiff:a,eventsBefore:n.length,eventsAfter:0}}for(var o=[],l=1;l<n.length;l++){var i=n[l-1],s=n[l],c=(s-i)/864e5;GAP_THRESHOLD_DAYS<c&&o.push({gapStartDate:i,gapEndDate:s,daysDiff:c,eventsBefore:l,eventsAfter:n.length-l})}return 0<o.length?o[o.length-1]:null}function filterEventsByDateRange(n,r,a){var o={dates:[],finishers:[],volunteers:[]};return n.rawDates.forEach(function(e,t){e=new Date(e);r<=e&&e<=a&&(o.dates.push(n.dates[t]),o.finishers.push(n.finishers[t]),o.volunteers.push(n.volunteers[t]))}),o}function getBaselineEventsBefore(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:BASELINE_EVENTS,r=parseDateString(e.toISOString().split("T")[0]),a=[],o=t.rawDates.length-1;0<=o;o--){var l=parseDateString(t.rawDates[o]);if(l<r&&(a.push(o),n<=a.length))break}a.reverse();var e={dates:a.map(function(e){return t.dates[e]}),finishers:a.map(function(e){return t.finishers[e]}),volunteers:a.map(function(e){return t.volunteers[e]})},i=calculateBaseline(e);return{filtered:e,window:0<a.length?{start:parseDateString(t.rawDates[a[0]]),end:parseDateString(t.rawDates[a[a.length-1]])}:{start:new Date(r),end:new Date(r)},baseline:i}}function dayOfWeekForDateString(e){var e=_slicedToArray(e.split("-").map(Number),3),t=e[0],n=e[1],e=e[2],r=n<3?n+12:n,n=n<3?t-1:t,t=n%100,n=Math.floor(n/100);return(6+(e+Math.floor(13*(r+1)/5)+t+Math.floor(t/4)+Math.floor(n/4)-2*n)%7)%7}function addDaysToDateString(e,t){e=parseDateString(e);return new Date(e.getTime()+864e5*t).toISOString().split("T")[0]}function getCancellationSaturdays(e,t){for(var n=[],e=e.toISOString().split("T")[0],r=(6-dayOfWeekForDateString(e))%7,a=addDaysToDateString(e,r=0===r?7:r),o=parseDateString(a);o<t;)n.push(new Date(o)),o=parseDateString(a=addDaysToDateString(a,7));return n}function getMostRecentCancellationDate(e){var t,n,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return e?(r=r&&e.gapEndDateStr?toLocalDateString(r):e.gapEndDateStr)&&6===dayOfWeekForDateString(r)?(t=(n=_slicedToArray(r.split("-").map(Number),3))[0],new Date(t,n[1]-1,n[2])):(t=r?parseDateString(r):e.gapEndDate,0<(n=getCancellationSaturdays(e.gapStartDate,t)).length?n[n.length-1]:null):null}function parseDateString(e){return new Date("".concat(e,"T00:00:00Z"))}function toLocalDateString(e){var t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),e=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(n,"-").concat(e)}function getNotHeldLabel(e,t){var n;return null==e||null==(n=e.rawDates)||!n.length||parseDateString(e.rawDates[0])<=parseDateString(t.toISOString().split("T")[0])?null:"Launched ".concat(e.dates[0])}function isFinishersMaxUpToEvent(e,t,n){return!(!e||!e.eventNumbers||0===e.eventNumbers.length)&&-1!==(t=e.eventNumbers.indexOf(String(t)))&&(e=e.finishers.slice(0,t+1),n===Math.max.apply(Math,_toConsumableArray(e)))}var WAF_TITLE="JavaScript is disabled";function isInvalidHistoryData(e){return!e||e.title===WAF_TITLE}(()=>{var _={backgroundColor:"#1c1b2a",barColor:"#f59e0b",alertColor:"#ef4444",lineColor:"#22d3ee",textColor:"#f3f4f6",subtleTextColor:"#d1d5db",gridColor:"rgba(243, 244, 246, 0.18)",successColor:"#10b981"},m=864e5,N={currentEvent:null,allParkruns:null,gapInfo:null,nearbyParkruns:[],fetchController:null,analysisComplete:!1,impactData:null,currentCancellationIndex:-1,cancellationDates:[],sortColumn:"distance",sortDirection:"asc"};function c(e,t){e=document.querySelector(e);e&&e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t))}function r(){return(r=_asyncToGenerator(_regenerator().m(function e(){var t,n,r,a,o,l;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t="parkrun_events_cache",e.p=1,o=localStorage.getItem(t)){if(e.p=2,o=JSON.parse(o),r=o.data,o=o.timestamp,(o=Date.now()-o)<m)return console.log("Using cached parkrun events (".concat(Math.round(o/1e3/60)," minutes old)")),e.a(2,r);e.n=3}else e.n=5;break;case 3:e.n=5;break;case 4:e.p=4,o=e.v,console.log("Cache parse error, fetching fresh data",o);case 5:return console.log("Fetching parkrun events from https://images.parkrun.com/events.json"),e.n=6,fetch("https://images.parkrun.com/events.json");case 6:if((n=e.v).ok){e.n=7;break}return console.error("Fetch failed with status:",n.status),e.a(2,[]);case 7:return e.n=8,n.json();case 8:if(r=e.v,(a=(null==(a=r.events)?void 0:a.features)||r.features||[])&&0!==a.length){e.n=9;break}return console.error("No features found in response data"),e.a(2,[]);case 9:try{localStorage.setItem(t,JSON.stringify({data:a,timestamp:Date.now()}))}catch(e){console.warn("Failed to cache parkrun events:",e)}return console.log("Successfully loaded",a.length,"parkrun events"),e.a(2,a);case 10:return e.p=10,l=e.v,console.error("Failed to fetch parkruns:",l),e.a(2,[])}},e,null,[[2,4],[1,10]])}))).apply(this,arguments)}function M(){return{eventName:window.location.pathname.split("/")[1],domain:window.location.hostname,url:window.location.origin}}function S(){return(S=_asyncToGenerator(_regenerator().m(function e(t,n){var r,a,o,l,i,s,c,d,u,p,g,h,y;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:r="parkrun_history_".concat(t),e.p=1,(l=localStorage.getItem(r))?(e.p=2,l=JSON.parse(l),a=l.data,o=l.timestamp,isInvalidHistoryData(a)?(localStorage.removeItem(r),console.log("Discarding invalid cached history for ".concat(t,", re-fetching")),e.n=4):e.n=3):e.n=6;break;case 3:if((l=Date.now()-o)<m)return console.log("Using cached history for ".concat(t," (").concat(Math.round(l/1e3/60)," minutes old)")),e.a(2,a);e.n=4;break;case 4:e.n=6;break;case 5:e.p=5,h=e.v,console.log("Cache parse error for ".concat(t,", fetching fresh data"),h);case 6:return h="".concat(n,"/").concat(t,"/results/eventhistory/"),e.n=7,fetch(h);case 7:if((i=e.v).ok){e.n=8;break}throw new Error("HTTP ".concat(i.status));case 8:return e.n=9,i.text();case 9:if(y=e.v,g=new DOMParser,g=g.parseFromString(y,"text/html"),y=null!=(y=null==(y=g.querySelector("h1"))?void 0:y.textContent.trim())?y:t,s=[],c=[],d=[],u=[],p=[],g=g.querySelectorAll("tr.Results-table-row"),Array.from(g).reverse().forEach(function(e){var t=e.getAttribute("data-parkrun"),t=(t&&s.push(t),e.getAttribute("data-date")),t=(t&&(d.push(t),t=new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),c.push(t)),e.getAttribute("data-finishers")),t=(t&&u.push(parseInt(t,10)),e.getAttribute("data-volunteers"));t&&p.push(parseInt(t,10))}),isInvalidHistoryData(g={eventName:t,title:y,eventNumbers:s,dates:c,rawDates:d,finishers:u,volunteers:p}))return console.warn("Event history for ".concat(t," looks invalid (e.g. WAF block), not caching. Retry later.")),e.a(2,null);e.n=10;break;case 10:try{localStorage.setItem(r,JSON.stringify({data:g,timestamp:Date.now()}))}catch(e){console.warn("Failed to cache history for ".concat(t,":"),e)}return e.a(2,g);case 11:return e.p=11,y=e.v,console.error("Failed to fetch event history for ".concat(t,":"),y),e.a(2,null)}},e,null,[[2,5],[1,11]])}))).apply(this,arguments)}function a(){return(a=_asyncToGenerator(_regenerator().m(function e(){var t,n,r,a,o,l,i,s;return _regenerator().w(function(e){for(;;)switch(e.n){case 0:if((t=document.querySelector(".parkrun-cancellation-impact"))&&t.remove(),0===(t=(()=>{var e=null!=(e=null==(e=document.querySelector("h1"))?void 0:e.textContent.trim())?e:"Event History",n=[],r=[],a=[],o=[],l=[],t=document.querySelectorAll("tr.Results-table-row");return Array.from(t).reverse().forEach(function(e){var t=e.getAttribute("data-parkrun"),t=(t&&n.push(t),e.getAttribute("data-date")),t=(t&&(a.push(t),t=new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),r.push(t)),e.getAttribute("data-finishers")),t=(t&&o.push(parseInt(t,10)),e.getAttribute("data-volunteers"));t&&l.push(parseInt(t,10))}),{title:e,eventNumbers:n,dates:r,rawDates:a,finishers:o,volunteers:l}})()).eventNumbers.length)return console.log("No event history data found"),e.a(2);e.n=1;break;case 1:if(n=detectEventGap(t,new Date)){e.n=2;break}return console.log("No cancellation gap detected"),e.a(2);case 2:if(N.currentEvent=_objectSpread(_objectSpread({},t),{},{eventName:M().eventName}),N.gapInfo=n,r=M(),(a=document.createElement("div")).className="parkrun-cancellation-impact",a.style.width="100%",a.style.maxWidth="1200px",a.style.margin="20px auto",a.style.padding="15px",a.style.backgroundColor=_.backgroundColor,a.style.borderRadius="8px",a.style.boxShadow="0 2px 4px rgba(0,0,0,0.1)",N.allParkruns&&0!==N.allParkruns.length){e.n=3;break}return(o=document.createElement("div")).style.padding="10px",o.style.color=_.subtleTextColor,o.style.textAlign="center",o.textContent="Loading nearby parkruns...",a.appendChild(o),c("h1",a),e.a(2);case 3:if(N.nearbyParkruns=function(a,e,t){var n,o,l,i,s,c=2<arguments.length&&void 0!==t?t:50,t=e.find(function(e){return e.properties.eventname===a.eventName});return t?(n=_slicedToArray(t.geometry.coordinates,2),o=n[0],l=n[1],i=t.properties.countrycode,s=t.properties.seriesid,e.filter(function(e){var t,n,r;return e.properties.eventname!==a.eventName&&e.properties.countrycode===i&&e.properties.seriesid===s&&(t=(e=_slicedToArray(e.geometry.coordinates,2))[0],e=e[1],n=Math.abs(e-l),r=Math.abs(t-o),!(.5<n||.5<r))&&calculateDistance(l,o,e,t)<=c}).map(function(e){var t=_slicedToArray(e.geometry.coordinates,2),n=t[0],t=calculateDistance(l,o,t[1],n);return _objectSpread(_objectSpread({},e),{},{distance:t})}).sort(function(e,t){return e.distance-t.distance})):[]}(r,N.allParkruns),0===N.nearbyParkruns.length)return(o=document.createElement("div")).style.padding="10px",o.style.color=_.subtleTextColor,o.style.textAlign="center",o.textContent="No nearby parkruns found within 50km.",a.appendChild(o),c("h1",a),e.a(2);e.n=4;break;case 4:l=N.allParkruns.find(function(e){return e.properties.eventname===r.eventName}),l=(null==l||null==(l=l.properties)?void 0:l.EventShortName)||null,l=(e=>{var t=document.createElement("div"),n=(t.style.padding="20px",t.style.backgroundColor="#2b223d",t.style.borderRadius="8px",t.style.marginBottom="20px",t.style.border="1px solid ".concat(_.gridColor),document.createElement("h3")),r=(n.textContent="Cancellation Impact Analysis",n.style.color=_.barColor,n.style.margin="0 0 15px 0",n.style.fontSize="20px",t.appendChild(n),(n=document.createElement("div")).style.fontSize="16px",n.style.color=_.textColor,n.style.marginBottom="4px",n.innerHTML='<strong style="color: '.concat(_.lineColor,';">').concat(e,"</strong>"),t.appendChild(n),N.gapInfo&&(e=getMostRecentCancellationDate(N.gapInfo,new Date))&&((n=document.createElement("div")).style.fontSize="14px",n.style.color=_.subtleTextColor,n.style.marginBottom="15px",n.textContent="Most recent cancellation date: ".concat(e.toLocaleDateString("en-AU",{weekday:"long",year:"numeric",month:"long",day:"numeric"})),t.appendChild(n)),(e=document.createElement("div")).style.fontSize="14px",e.style.lineHeight="1.8",e.style.color=_.subtleTextColor,e.style.marginBottom="18px",e.innerHTML="π Analyzing impact on nearby parkruns within 50km",t.appendChild(e),document.createElement("button"));return r.textContent="βΆ Start Analysis",r.className="start-analysis-btn",r.style.padding="12px 24px",r.style.backgroundColor=_.lineColor,r.style.color="#1c1b2a",r.style.border="none",r.style.borderRadius="6px",r.style.cursor="pointer",r.style.fontWeight="bold",r.style.fontSize="14px",r.style.transition="all 0.2s",r.addEventListener("mouseenter",function(){r.style.backgroundColor="#0ea5e9",r.style.transform="translateY(-1px)"}),r.addEventListener("mouseleave",function(){r.style.backgroundColor=_.lineColor,r.style.transform="translateY(0)"}),t.appendChild(r),{section:t,startButton:r}})(l),i=l.section,s=l.startButton,a.appendChild(i),c("h1",a),s.addEventListener("click",function(){s.disabled=!0,s.textContent="Starting...",s.style.opacity="0.6",s.style.cursor="not-allowed";var e=(()=>{var e=document.createElement("div"),t=(e.className="parkrun-cancellation-progress",e.style.padding="15px",e.style.backgroundColor=_.backgroundColor,e.style.borderRadius="6px",e.style.marginBottom="15px",e.style.border="1px solid ".concat(_.gridColor),document.createElement("h4")),r=(t.textContent="Analyzing Nearby parkrun Impact",t.style.margin="0 0 12px 0",t.style.color=_.barColor,e.appendChild(t),(t=document.createElement("div")).style.width="100%",t.style.height="20px",t.style.backgroundColor="#3a3250",t.style.borderRadius="4px",t.style.marginBottom="10px",t.style.overflow="hidden",document.createElement("div")),a=(r.style.width="0%",r.style.height="100%",r.style.backgroundColor=_.lineColor,r.style.transition="width 0.3s ease",t.appendChild(r),e.appendChild(t),document.createElement("div")),n=(a.style.fontSize="13px",a.style.color=_.subtleTextColor,a.style.marginBottom="12px",e.appendChild(a),document.createElement("div"));return n.style.fontSize="12px",n.style.color=_.lineColor,n.style.fontWeight="bold",n.style.marginBottom="10px",e.appendChild(n),(t=document.createElement("button")).textContent="Stop Analysis",t.style.padding="6px 12px",t.style.backgroundColor=_.alertColor,t.style.color=_.textColor,t.style.border="none",t.style.borderRadius="4px",t.style.cursor="pointer",t.style.fontWeight="bold",t.style.fontSize="12px",e.appendChild(t),{progressSection:e,updateProgress:function(e,t){var n=Math.round(e/t*100);r.style.width=n+"%",a.textContent="".concat(e,"/").concat(t," parkruns analyzed")},updateStatus:function(e){n.textContent=e},stop:t,hide:function(){e.style.display="none"}}})();i.insertAdjacentElement("afterend",e.progressSection),N.fetchController=new AbortController,function(){d.apply(this,arguments)}(e,a,i)});case 5:return e.a(2)}},e)}))).apply(this,arguments)}function d(){return(d=_asyncToGenerator(_regenerator().m(function e(t,n,r){var a,o,l,i,s,c,d,u,p,g,h,y,m,f,b,v,C,x;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:a=M(),o=N.nearbyParkruns,i=detectAllEventGaps(N.currentEvent,new Date),l=[],i.forEach(function(e){var t=getCancellationSaturdays(e.gapStartDate,e.gapEndDate);l.push.apply(l,_toConsumableArray(t)),e.gapEndDateStr&&6===dayOfWeekForDateString(e.gapEndDateStr)&&l.push(parseDateString(e.gapEndDateStr))}),l.sort(function(e,t){return t-e}),N.cancellationDates=l,console.log("All Cancellation Saturdays:",l),i=[],s=[],c=0;case 1:if(c<o.length){if(N.fetchController.signal.aborted)return console.log("Analysis stopped by user"),e.a(3,8);e.n=2}else e.n=8;break;case 2:return d=o[c],u=d.properties.eventname,p=d.properties.EventShortName||u,g=d.distance.toFixed(1),t.updateStatus("Fetching: ".concat(p," (").concat(g,"km)")),t.updateProgress(c,o.length),e.p=3,e.n=4,function(){return S.apply(this,arguments)}(u,a.url);case 4:(x=e.v)?i.push({parkrun:d,historyData:x,shortName:p,distance:g}):s.push({parkrun:d,shortName:p,distance:g}),e.n=6;break;case 5:e.p=5,x=e.v,console.error("Failed to fetch ".concat(u,":"),x),s.push({parkrun:d,shortName:p,distance:g});case 6:return e.n=7,new Promise(function(e){return setTimeout(e,100)});case 7:c++,e.n=1;break;case 8:if(h=new Map,i.forEach(function(e){return h.set(e.parkrun.properties.eventname,e)}),y=new Map,s.forEach(function(e){return y.set(e.parkrun.properties.eventname,e)}),m={},f=[],l.forEach(function(s){var e=s.toISOString().split("T")[0],c=[];o.forEach(function(e){var t,n,r,a,o=e.properties.eventname,l=h.get(o),i=y.get(o);l?(t=l.historyData,n=l.shortName,l=l.distance,r=getBaselineEventsBefore(t,s),a=((e,t)=>{for(var n=t.toISOString().split("T")[0],r=0;r<e.rawDates.length;r++)if(e.rawDates[r]===n)return{date:e.dates[r],eventNumber:e.eventNumbers[r],finishers:e.finishers[r],volunteers:e.volunteers[r]};return null})(t,s),c.push({eventName:e.properties.eventname,title:t.title,displayName:n,distance:l,baseline:r.baseline,eventOnDate:a,historyData:t,seasonalTrend:r,change:a?{finishersChange:a.finishers-r.baseline.avgFinishers,volunteersChange:a.volunteers-r.baseline.avgVolunteers,finishersPct:0<r.baseline.avgFinishers?(a.finishers-r.baseline.avgFinishers)/r.baseline.avgFinishers*100:0,volunteersPct:0<r.baseline.avgVolunteers?(a.volunteers-r.baseline.avgVolunteers)/r.baseline.avgVolunteers*100:0}:null})):i&&c.push({eventName:o,title:o,displayName:i.shortName,distance:i.distance,baseline:{avgFinishers:0,avgVolunteers:0},eventOnDate:null,historyData:null,seasonalTrend:null,change:null,fetchFailed:!0})}),1<=c.filter(function(e){return e.eventOnDate}).length?(m[e]=c,f.push(s)):console.log("Skipping ".concat(e,": 0/").concat(c.length," parkruns ran (global cancellation)"))}),b=0<f.length?f:l,t.updateProgress(o.length,o.length),0===f.length)return t.updateStatus("No valid cancellation dates found - all detected dates had global cancellations"),t.stop.textContent="Close",t.stop.style.backgroundColor=_.alertColor,(v=document.createElement("div")).style.padding="15px",v.style.backgroundColor="#3a3250",v.style.borderRadius="6px",v.style.marginTop="15px",v.style.color=_.textColor,v.style.textAlign="center",v.innerHTML='\n <h3 style="color: '.concat(_.alertColor,'; margin: 0 0 10px 0;">β No Valid Analysis Dates</h3>\n <p style="margin: 0 0 8px 0;">All detected cancellation dates appear to be part of global cancellation periods (e.g., COVID-19).</p>\n <p style="margin: 0; color: ').concat(_.subtleTextColor,'; font-size: 13px;">\n No nearby parkruns held events on these dates, indicating system-wide cancellations rather than single-event cancellations.\n </p>\n '),n.appendChild(v),t.stop.addEventListener("click",function(){t.hide()}),e.a(2);e.n=9;break;case 9:t.updateStatus("Analysis complete! Found ".concat(f.length," valid cancellation date(s)")),(v=document.querySelector(".start-analysis-btn"))&&(v.style.display="none"),t.stop.textContent="Close",t.stop.style.backgroundColor=_.successColor,N.resultsByDate=m,N.cancellationDates=b,N.analysisComplete=!0,-1===N.currentCancellationIndex&&0<b.length&&(N.currentCancellationIndex=0),C=((r,a,o,l)=>{var e=document.createElement("div"),t=(e.className="parkrun-cancellation-nav",e.style.padding="15px",e.style.backgroundColor="#2b223d",e.style.borderRadius="8px",e.style.marginBottom="20px",e.style.border="1px solid ".concat(_.gridColor),document.createElement("div"));t.style.color=_.textColor,t.style.fontSize="14px",t.style.marginBottom="12px",t.innerHTML="\n <strong>".concat(o.length," Cancellation Date").concat(1!==o.length?"s":"",' Available</strong>\n <div style="color: ').concat(_.subtleTextColor,'; font-size: 12px; margin-top: 4px;">\n Use dropdown or buttons to navigate β’ Keyboard: <kbd style="background: #3a3250; padding: 2px 6px; border-radius: 3px; font-family: monospace; border: 1px solid ').concat(_.gridColor,';">β</kbd> <kbd style="background: #3a3250; padding: 2px 6px; border-radius: 3px; font-family: monospace; border: 1px solid ').concat(_.gridColor,';">β</kbd>\n </div>\n '),e.appendChild(t);(t=document.createElement("div")).style.display="flex",t.style.alignItems="center",t.style.gap="8px",t.style.flexWrap="wrap";var n=document.createElement("button"),i=(n.textContent="β",n.style.padding="6px 10px",l<o.length-1),s=(n.style.backgroundColor=i?_.lineColor:"#3a3250",n.style.color=i?"#2b223d":_.subtleTextColor,n.style.border="1px solid ".concat(_.gridColor),n.style.borderRadius="4px",n.style.cursor=i?"pointer":"not-allowed",n.style.fontWeight="bold",n.style.fontSize="14px",n.style.transition="all 0.2s ease",n.disabled=!i,i&&(n.addEventListener("mouseenter",function(){n.style.transform="translateY(-1px)",n.style.boxShadow="0 2px 4px rgba(34, 211, 238, 0.3)"}),n.addEventListener("mouseleave",function(){n.style.transform="translateY(0)",n.style.boxShadow="none"})),document.createElement("select")),c=(s.style.padding="6px 8px",s.style.backgroundColor="#3a3250",s.style.color=_.textColor,s.style.border="1px solid ".concat(_.gridColor),s.style.borderRadius="4px",s.style.cursor="pointer",s.style.fontWeight="bold",s.style.fontSize="12px",s.style.minWidth="220px",s.style.flex="1",o.forEach(function(e,t){var n=document.createElement("option"),e=e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",weekday:"short"});n.value=t,n.textContent=e,n.selected=t===l,s.appendChild(n)}),document.createElement("button")),i=(c.textContent="β",c.style.padding="6px 10px",0<l);function d(){var e,t,n=r.querySelector(".parkrun-cancellation-results");n&&n.remove(),k(r,a,o,N.currentCancellationIndex),(n=r.querySelector(".parkrun-cancellation-nav"))&&((e=n.querySelectorAll("select"))[0]&&(e[0].value=N.currentCancellationIndex),n=(e=n.querySelectorAll("button"))[0],e=e[1],n&&(t=N.currentCancellationIndex<o.length-1,n.disabled=!t,n.style.backgroundColor=t?_.lineColor:"#3a3250",n.style.color=t?"#2b223d":_.subtleTextColor,n.style.cursor=t?"pointer":"not-allowed"),e)&&(n=0<N.currentCancellationIndex,e.disabled=!n,e.style.backgroundColor=n?_.lineColor:"#3a3250",e.style.color=n?"#2b223d":_.subtleTextColor,e.style.cursor=n?"pointer":"not-allowed")}function u(){N.currentCancellationIndex<o.length-1&&(N.currentCancellationIndex+=1,d())}function p(){0<N.currentCancellationIndex&&(--N.currentCancellationIndex,d())}return c.style.backgroundColor=i?_.lineColor:"#3a3250",c.style.color=i?"#2b223d":_.subtleTextColor,c.style.border="1px solid ".concat(_.gridColor),c.style.borderRadius="4px",c.style.cursor=i?"pointer":"not-allowed",c.style.fontWeight="bold",c.style.fontSize="14px",c.style.transition="all 0.2s ease",c.disabled=!i,i&&(c.addEventListener("mouseenter",function(){c.style.transform="translateY(-1px)",c.style.boxShadow="0 2px 4px rgba(34, 211, 238, 0.3)"}),c.addEventListener("mouseleave",function(){c.style.transform="translateY(0)",c.style.boxShadow="none"})),t.appendChild(n),t.appendChild(s),t.appendChild(c),e.appendChild(t),n.addEventListener("click",u),c.addEventListener("click",p),s.addEventListener("change",function(e){N.currentCancellationIndex=parseInt(e.target.value,10),d()}),N.keyboardHandler&&document.removeEventListener("keydown",N.keyboardHandler),N.keyboardHandler=function(e){"ArrowLeft"===e.key&&u(),"ArrowRight"===e.key&&p()},document.addEventListener("keydown",N.keyboardHandler),e})(n,m,b,N.currentCancellationIndex),r.insertAdjacentElement("afterend",C),k(n,m,b,N.currentCancellationIndex),setTimeout(function(){t.hide()},500),t.stop.addEventListener("click",function(){t.hide()});case 10:return e.a(2)}},e,null,[[3,5]])}))).apply(this,arguments)}function O(e,t,n){function r(e){switch(t){case"name":return e.displayName||e.eventName;case"distance":return parseFloat(e.distance);case"eventNumber":return e.eventOnDate?parseInt(e.eventOnDate.eventNumber,10):-1;case"baselineFinishers":return e.baseline.avgFinishers;case"baselineVolunteers":return e.baseline.avgVolunteers;case"onDateFinishers":return e.eventOnDate?e.eventOnDate.finishers:-1;case"onDateVolunteers":return e.eventOnDate?e.eventOnDate.volunteers:-1;case"changeFinishers":return e.change?e.change.finishersChange:-999999;case"changeVolunteers":return e.change?e.change.volunteersChange:-999999;case"changePct":return e.change?e.change.finishersPct:-999999;default:return 0}}e=_toConsumableArray(e);return e.sort(function(e,t){e=r(e),t=r(t);return"asc"===n?e-t:t-e}),e}function o(){return(o=_asyncToGenerator(_regenerator().m(function e(t,n){var r,a,o,l,i,s;return _regenerator().w(function(e){for(;;)if(0===e.n)return r=t.cloneNode(!0),s=t.querySelectorAll("canvas"),a=r.querySelectorAll("canvas"),s.forEach(function(e,t){try{var n=e.toDataURL("image/png"),r=document.createElement("img");r.src=n,r.alt="Chart snapshot",r.style.maxWidth="100%",r.style.display="block",r.style.backgroundColor="#2b223d",a[t]&&a[t].replaceWith(r)}catch(e){console.error("Failed to serialize chart canvas:",e)}}),s=r.querySelector(".parkrun-cancellation-impact-map"),l=o="",s&&s.getAttribute("data-map-state")&&((s=s.querySelector('[id^="parkrun-impact-map-"]'))&&((i=document.createElement("div")).id="parkrun-standalone-map",i.style.height="400px",i.style.width="100%",i.style.borderRadius="4px",i.setAttribute("aria-label","Map of nearby parkruns: cancelled event at centre."),s.replaceWith(i)),o='<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.css" crossorigin="anonymous">',s=_.gridColor,l='<script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.js" crossorigin="anonymous"><\/script><script>(function(){var s=document.querySelector(".parkrun-cancellation-impact-map");if(!s)return;var j=s.getAttribute("data-map-state");if(!j)return;var d=JSON.parse(j);var m=L.map("parkrun-standalone-map",{preferCanvas:true}).setView([d.centreLat,d.centreLon],10);L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"© <a href=\\"https://www.openstreetmap.org/copyright\\">OpenStreetMap</a>"}).addTo(m);L.marker([d.centreLat,d.centreLon],{icon:L.divIcon({className:"impact-map-centre-marker",html:"<span style=\\"background:'+_.barColor+";width:24px;height:24px;border-radius:50%;border:2px solid "+s+';display:block;\\"></span>",iconSize:[24,24],iconAnchor:[12,12]})}).addTo(m).bindTooltip("Cancelled: "+d.centreTitle,{permanent:false,direction:"top",className:"impact-map-tooltip",opacity:1});d.points.forEach(function(p){L.circleMarker([p.lat,p.lon],{radius:p.radius,fillColor:p.fillColor,color:"'+s+'",weight:1,fillOpacity:1}).addTo(m).bindTooltip(p.tooltipHtml,{permanent:false,direction:"top",className:"impact-map-tooltip",offset:[0,-p.radius],opacity:1});});var b=L.latLngBounds([d.bounds[0][0],d.bounds[0][1]],[d.bounds[1][0],d.bounds[1][1]]);if(b.getNorthEast().equals(b.getSouthWest()))b=b.pad(0.02);m.fitBounds(b,{padding:[40,40],maxZoom:12});})();<\/script>'),i="\n :root { color-scheme: dark; }\n body { margin: 0; padding: 20px; background: ".concat(_.backgroundColor,"; color: ").concat(_.textColor,'; font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; line-height: 1.5; }\n a { color: ').concat(_.lineColor,"; }\n h1, h2, h3, h4 { color: ").concat(_.barColor,"; margin: 0 0 10px 0; }\n table { width: 100%; border-collapse: collapse; }\n th, td { border: 1px solid ").concat(_.gridColor,"; padding: 10px; text-align: left; }\n th { background: #2b223d; color: ").concat(_.barColor,"; }\n tr:nth-child(even) td { background: #241c35; }\n tr:nth-child(odd) td { background: #1f182e; }\n .parkrun-cancellation-results { background: ").concat(_.backgroundColor,"; padding: 16px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }\n .chart-img { max-width: 100%; display: block; }\n .meta { margin-bottom: 16px; color: ").concat(_.subtleTextColor,"; font-size: 13px; }\n .meta strong { color: ").concat(_.textColor,"; }\n .impact-map-centre-marker{background:transparent!important;border:none!important}\n .leaflet-tooltip.impact-map-tooltip{background:#2b223d;color:#f3f4f6;border:1px solid rgba(243,244,246,0.18);padding:8px 10px}\n .leaflet-tooltip.impact-map-tooltip::before{border-top-color:#2b223d}\n "),s='\n <header>\n <h1>parkrun Cancellation Impact</h1>\n <div class="meta">\n <div><strong>Event:</strong> '.concat(n.eventShortName,"</div>\n <div><strong>Cancelled date:</strong> ").concat(n.cancellationDateStr,"</div>\n <div><strong>Generated:</strong> ").concat(n.generatedAt,"</div>\n </div>\n </header>\n "),e.a(2,'<!DOCTYPE html><html><head><meta charset="UTF-8"><title>parkrun Cancellation Impact - '.concat(n.eventShortName," - ").concat(n.cancellationDateStr,"</title><style>").concat(i,"</style>").concat(o,"</head><body>").concat(s).concat(r.outerHTML).concat(l,"</body></html>"))},e)}))).apply(this,arguments)}function I(){return e.apply(this,arguments)}function e(){return(e=_asyncToGenerator(_regenerator().m(function e(t,n){var r,a;return _regenerator().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,function(){return o.apply(this,arguments)}(t,n);case 1:return r=e.v,a="parkrun-cancellation-impact-".concat(n.eventShortName,"-").concat(n.cancellationDateStr,".html"),e.a(2,{blob:new Blob([r],{type:"text/html"}),filename:a})}},e)}))).apply(this,arguments)}function k(e,t,n,r){function a(e){var t=y.querySelector("tbody"),s=(t&&t.remove(),document.createElement("tbody"));e.forEach(function(e){var t=document.createElement("tr"),n=(t.style.borderBottom="1px solid ".concat(_.gridColor),t.style.transition="background-color 0.15s ease",null!==e.eventOnDate),r=!0===e.fetchFailed,a=(n||r||(t.style.opacity="0.6"),t.addEventListener("mouseenter",function(){t.style.backgroundColor=n?"rgba(34, 211, 238, 0.08)":"rgba(243, 244, 246, 0.03)"}),t.addEventListener("mouseleave",function(){t.style.backgroundColor="transparent"}),document.createElement("td")),o=(a.style.padding="10px",a.style.textAlign="left",a.style.fontWeight="bold",document.createElement("a")),a=(o.href="".concat(M().url,"/").concat(e.eventName,"/results/eventhistory/"),o.textContent=e.displayName||e.eventName,o.style.color=_.lineColor,o.style.textDecoration="none",o.target="_blank",o.addEventListener("mouseenter",function(){o.style.textDecoration="underline"}),o.addEventListener("mouseleave",function(){o.style.textDecoration="none"}),a.appendChild(o),t.appendChild(a),document.createElement("td")),a=(a.style.padding="10px",a.style.textAlign="right",a.style.color=_.subtleTextColor,a.textContent="".concat(e.distance,"km"),t.appendChild(a),document.createElement("td")),a=(a.style.padding="10px",a.style.textAlign="right",e.eventOnDate&&e.eventOnDate.eventNumber?(a.textContent=e.eventOnDate.eventNumber,a.style.color=_.textColor):(a.textContent="β",a.style.color=_.subtleTextColor),t.appendChild(a),document.createElement("td")),a=(a.style.padding="10px",a.style.textAlign="right",r?(a.textContent="β",a.style.color=_.subtleTextColor):a.innerHTML="<strong>".concat(e.baseline.avgFinishers,"</strong>"),t.appendChild(a),document.createElement("td")),a=(a.style.padding="10px",a.style.textAlign="right",r?(a.textContent="β",a.style.color=_.subtleTextColor):a.textContent="".concat(e.baseline.avgVolunteers),t.appendChild(a),document.createElement("td")),l=(a.style.padding="10px",a.style.textAlign="right",e.eventOnDate?(l=isFinishersMaxUpToEvent(e.historyData,e.eventOnDate.eventNumber,e.eventOnDate.finishers)?" π":"",a.innerHTML="<strong>".concat(e.eventOnDate.finishers).concat(l,"</strong>")):(a.textContent="β",a.style.color=_.subtleTextColor),t.appendChild(a),document.createElement("td")),a=(l.style.padding="10px",l.style.textAlign="right",e.eventOnDate?l.textContent="".concat(e.eventOnDate.volunteers):(l.textContent="β",l.style.color=_.subtleTextColor),t.appendChild(l),document.createElement("td")),i=(a.style.padding="10px",a.style.textAlign="right",e.change?(l=0<e.change.finishersChange?"+":"",i=0<e.change.finishersChange?_.successColor:_.alertColor,a.innerHTML='<span style="color: '.concat(i,';">').concat(l).concat(e.change.finishersChange,"</span>")):(a.textContent="β",a.style.color=_.subtleTextColor),t.appendChild(a),document.createElement("td")),a=(i.style.padding="10px",i.style.textAlign="right",e.change?(l=0<e.change.volunteersChange?"+":"",a=0<e.change.volunteersChange?_.successColor:_.alertColor,i.innerHTML='<span style="color: '.concat(a,';">').concat(l).concat(e.change.volunteersChange,"</span>")):(i.textContent="β",i.style.color=_.subtleTextColor),t.appendChild(i),document.createElement("td")),l=(a.style.padding="10px",a.style.textAlign="right",e.change?(l=0<e.change.finishersPct?_.successColor:_.alertColor,i=0<e.change.finishersPct?"+":"",a.innerHTML='<span style="color: '.concat(l,';">').concat(i).concat(e.change.finishersPct.toFixed(1),"%</span>")):(a.textContent="β",a.style.color=_.subtleTextColor),t.appendChild(a),document.createElement("td"));l.style.padding="10px",l.style.textAlign="right",r?(l.textContent="Fetch failed",l.style.color=_.alertColor,l.title="Refresh page to retry"):e.eventOnDate?e.change.finishersChange<-5?(l.textContent="β Loss",l.style.color=_.alertColor):5<e.change.finishersChange?(l.textContent="β Gain",l.style.color=_.successColor):(l.textContent="β Stable",l.style.color=_.subtleTextColor):(i=getNotHeldLabel(e.historyData,u),l.textContent=null!=i?i:"No Event",l.style.color=_.subtleTextColor),t.appendChild(l),s.appendChild(t)}),y.appendChild(s)}var i,s,l,c,d,o,u=n[r],p=t[u.toISOString().split("T")[0]]||[],g=u.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),h=document.createElement("div"),n=(h.className="parkrun-cancellation-results",h.style.marginTop="20px",document.createElement("h3")),r=(n.textContent="Nearby parkrun Impact on ".concat(g),n.style.color=_.barColor,n.style.marginTop="20px",n.style.marginBottom="12px",h.appendChild(n),document.createElement("div")),y=(r.style.overflowX="auto",document.createElement("table")),t=(y.style.width="100%",y.style.borderCollapse="collapse",y.style.fontSize="13px",y.style.color=_.textColor,document.createElement("thead")),m=(t.style.position="sticky",t.style.top="0",t.style.backgroundColor="#2b223d",t.style.zIndex="10",document.createElement("tr")),f=(m.style.borderBottom="2px solid ".concat(_.gridColor),[{label:"parkrun",key:"name",align:"left",info:"Click column headers to sort. Default ordering is by distance."},{label:"Distance",key:"distance",align:"right",info:"Distance from cancelled event in kilometers."},{label:"Event #",key:"eventNumber",align:"right",info:"Event number on ".concat(g,". Lower numbers indicate newer parkruns.")},{label:"Baseline (Avg) Finishers",key:"baselineFinishers",align:"right",info:"12-event baseline average finishers for events before ".concat(g,".")},{label:"Baseline (Avg) Volunteers",key:"baselineVolunteers",align:"right",info:"12-event baseline average volunteers for events before ".concat(g,".")},{label:"On Date Finishers",key:"onDateFinishers",align:"right",info:"Actual finishers on ".concat(g,".")},{label:"On Date Volunteers",key:"onDateVolunteers",align:"right",info:"Actual volunteers on ".concat(g,".")},{label:"Change Finishers",key:"changeFinishers",align:"right",info:"Difference between actual and baseline finishers."},{label:"Change Volunteers",key:"changeVolunteers",align:"right",info:"Difference between actual and baseline volunteers."},{label:"Change % (Finishers)",key:"changePct",align:"right",info:"Percentage change in finishers compared to baseline."},{label:"Trend",key:"trend",align:"right",info:"Gain (+5 or more finishers), Loss (-5 or fewer), Stable (within Β±5), Launched (event had not started), No Event, or Fetch failed (refresh page to retry)."}]),n=(f.forEach(function(t){var e=document.createElement("th"),n=(e.style.padding="10px",e.style.textAlign=t.align,e.style.color=_.barColor,e.style.fontWeight="bold",e.style.cursor="pointer",e.style.userSelect="none",e.style.position="relative",e.style.transition="background-color 0.15s ease",e.addEventListener("mouseenter",function(){e.style.backgroundColor="rgba(34, 211, 238, 0.1)"}),e.addEventListener("mouseleave",function(){e.style.backgroundColor="transparent"}),document.createElement("span")),n=(n.textContent=t.label,n.style.marginRight="4px",e.appendChild(n),document.createElement("span")),r=(n.style.fontSize="10px",n.style.opacity=N.sortColumn===t.key?"1":"0.3",n.textContent=N.sortColumn!==t.key||"asc"===N.sortDirection?"β²":"βΌ",e.appendChild(n),document.createElement("span"));r.textContent=" βΉ",r.style.fontSize="12px",r.style.opacity="0.6",r.style.cursor="help",r.style.transition="opacity 0.2s ease",r.title=t.info,r.addEventListener("mouseenter",function(){r.style.opacity="1"}),r.addEventListener("mouseleave",function(){r.style.opacity="0.6"}),e.appendChild(r),e.addEventListener("click",function(){N.sortColumn===t.key?N.sortDirection="asc"===N.sortDirection?"desc":"asc":(N.sortColumn=t.key,N.sortDirection="asc");var e=O(p,N.sortColumn,N.sortDirection);a(e),f.forEach(function(e,t){t=m.children[t].children[1];e.key===N.sortColumn?(t.style.opacity="1",t.textContent="asc"===N.sortDirection?"β²":"βΌ"):(t.style.opacity="0.3",t.textContent="β²")})}),m.appendChild(e)}),t.appendChild(m),y.appendChild(t),O(p,N.sortColumn,N.sortDirection)),t=(a(n),r.appendChild(y),h.appendChild(r),p.filter(function(e){return null!=e.eventOnDate})),r=null==(n=N.allParkruns)?void 0:n.find(function(e){return e.properties.eventname===(null==(e=N.currentEvent)?void 0:e.eventName)});function b(e){n=e.displayName||e.eventName,(r=document.createElement("div")).textContent=n;var t,n=r.innerHTML,r=[],a=(r.push("Distance: "+e.distance+"km"),e.eventOnDate&&e.eventOnDate.eventNumber&&r.push("Event #: "+e.eventOnDate.eventNumber),r.push("Baseline (avg) finishers: "+(null!=(t=null==(t=e.baseline)?void 0:t.avgFinishers)?t:"β")),r.push("Baseline (avg) volunteers: "+(null!=(t=null==(t=e.baseline)?void 0:t.avgVolunteers)?t:"β")),e.eventOnDate&&(r.push("On date finishers: "+e.eventOnDate.finishers),r.push("On date volunteers: "+e.eventOnDate.volunteers)),e.change&&(t=0<e.change.finishersChange?"+":"",a=0<e.change.volunteersChange?"+":"",r.push("Change finishers: "+t+e.change.finishersChange),r.push("Change volunteers: "+a+e.change.volunteersChange),t=0<e.change.finishersPct?"+":"",r.push("Change % (finishers): "+t+e.change.finishersPct.toFixed(1)+"%")),e.change?5<e.change.finishersChange?"β Gain":e.change.finishersChange<-5?"β Loss":"β Stable":"β");return r.push("Trend: "+a),'<div class="impact-map-tooltip-content" style="min-width:200px;"><div class="impact-map-tooltip-name" style="font-size:14px;font-weight:bold;margin-bottom:6px;padding-bottom:6px;border-bottom:1px solid rgba(243,244,246,0.2);color:#f3f4f6;">'+n+'</div><div style="font-size:12px;line-height:1.5;color:#d1d5db;">'+r.join("<br>")+"</div></div>"}0<t.length&&r&&"undefined"!=typeof L&&(n=_slicedToArray(r.geometry.coordinates,2),i=n[0],s=n[1],r=t.map(function(t){var e,n,r,a,o,l=N.nearbyParkruns.find(function(e){return e.properties.eventname===t.eventName});return l?(e=(l=_slicedToArray(l.geometry.coordinates,2))[0],n=calculateBearing(s,i,l=l[1],e),r=parseFloat(t.distance,10),a=t.change?t.change.finishersPct:0,o=Math.abs(a),{result:t,lat:l,lon:e,bearing:n,distanceKm:r,pct:a,isStable:o<=5}):null}).filter(Boolean),document.querySelector('link[href*="leaflet.css"]')||((n=document.createElement("link")).rel="stylesheet",n.href="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.css",n.integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=",n.crossOrigin="anonymous",document.head.appendChild(n)),document.getElementById("parkrun-impact-map-styles")||((t=document.createElement("style")).id="parkrun-impact-map-styles",t.textContent=".impact-map-centre-marker{background:transparent!important;border:none!important}.leaflet-tooltip.impact-map-tooltip{background:#2b223d;color:#f3f4f6;border:1px solid rgba(243,244,246,0.18);padding:8px 10px}.leaflet-tooltip.impact-map-tooltip::before{border-top-color:#2b223d}",document.head.appendChild(t)),(n=document.createElement("div")).className="parkrun-cancellation-impact-map",n.style.marginTop="16px",n.style.padding="12px",n.style.backgroundColor="#3a3250",n.style.borderRadius="4px",(t=document.createElement("h3")).textContent="Impact map",t.style.color=_.barColor,t.style.margin="0 0 10px 0",n.appendChild(t),(t=document.createElement("div")).id="parkrun-impact-map-"+Date.now(),t.style.height="400px",t.style.width="100%",t.style.borderRadius="4px",t.setAttribute("aria-label","Map of nearby parkruns: cancelled event at centre."),n.appendChild(t),h.appendChild(n),l=L.map(t,{preferCanvas:!0}).setView([s,i],10),L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'}).addTo(l),t=null!=(t=null!=(t=null==(t=N.currentEvent)?void 0:t.title)?t:null==(t=N.currentEvent)?void 0:t.eventName)?t:"Cancelled event",L.marker([s,i],{icon:L.divIcon({className:"impact-map-centre-marker",html:'<span style="background:'+_.barColor+";width:24px;height:24px;border-radius:50%;border:2px solid "+_.gridColor+';display:block;"></span>',iconSize:[24,24],iconAnchor:[12,12]})}).addTo(l).bindTooltip("Cancelled: "+t,{permanent:!1,direction:"top",className:"impact-map-tooltip",opacity:1,openDelay:0,closeDelay:0}),c=[[s,i],[s,i]],d=[],r.forEach(function(e){var t=e.result,n=e.lat,r=e.lon,a=e.pct,e=e.isStable,o=e?8:10+18*Math.min(1,Math.abs(a)/50),e=e?_.subtleTextColor:0<a?_.successColor:_.alertColor;c[0][0]=Math.min(c[0][0],n),c[0][1]=Math.min(c[0][1],r),c[1][0]=Math.max(c[1][0],n),c[1][1]=Math.max(c[1][1],r),d.push({lat:n,lon:r,tooltipHtml:b(t),radius:o,fillColor:e}),L.circleMarker([n,r],{radius:o,fillColor:e,color:_.gridColor,weight:1,fillOpacity:1}).addTo(l).bindTooltip(b(t),{permanent:!1,direction:"top",className:"impact-map-tooltip",offset:[0,-o],opacity:1,openDelay:0,closeDelay:0})}),r=[c[0][0],c[0][1]],S=[c[1][0],c[1][1]],(o=L.latLngBounds(r,S)).getNorthEast().equals(o.getSouthWest())&&(o=o.pad(.02)),l.fitBounds(o,{padding:[40,40],maxZoom:12}),requestAnimationFrame(function(){requestAnimationFrame(function(){l.invalidateSize(),l.fitBounds(o,{padding:[40,40],maxZoom:12})})}),r={centreLat:s,centreLon:i,centreTitle:t,bounds:[[o.getSouthWest().lat,o.getSouthWest().lng],[o.getNorthEast().lat,o.getNorthEast().lng]],points:d},n.setAttribute("data-map-state",JSON.stringify(r)));function v(){var t=M(),e=N.allParkruns.find(function(e){return e.properties.eventname===t.eventName});return{eventShortName:(null==e||null==(e=e.properties)?void 0:e.EventShortName)||t.eventName,cancellationDateStr:u.toISOString().split("T")[0]}}var C,x=getBaselineEventsBefore(N.currentEvent,u),S=document.createElement("div"),t=(S.style.marginTop="16px",S.style.padding="12px",S.style.backgroundColor="#3a3250",S.style.borderRadius="4px",document.createElement("h3")),n=(t.textContent="Cancelled Event Seasonal Trend",t.style.color=_.barColor,t.style.margin="0 0 8px 0",S.appendChild(t),document.createElement("div")),r=x.window.start.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),t=x.window.end.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),r=(n.style.color=_.textColor,n.style.fontSize="13px",n.style.marginBottom="6px",n.innerHTML="Window: ".concat(r," β ").concat(t," (12-event baseline)"),S.appendChild(n),document.createElement("div")),r=(r.style.color=_.textColor,r.style.fontSize="13px",r.style.display="grid",r.style.gridTemplateColumns="repeat(auto-fit, minmax(200px, 1fr))",r.style.gap="8px",r.innerHTML="\n <div>Average finishers: <strong>".concat(x.baseline.avgFinishers,"</strong></div>\n <div>Min finishers: <strong>").concat(x.baseline.minFinishers,"</strong></div>\n <div>Max finishers: <strong>").concat(x.baseline.maxFinishers,"</strong></div>\n <div>Average volunteers: <strong>").concat(x.baseline.avgVolunteers,"</strong></div>\n <div>Min volunteers: <strong>").concat(x.baseline.minVolunteers,"</strong></div>\n <div>Max volunteers: <strong>").concat(x.baseline.maxVolunteers,"</strong></div>\n <div>Total events: <strong>").concat(x.baseline.totalEvents,"</strong></div>\n "),S.appendChild(r),"undefined"!=typeof Chart&&x.filtered.finishers&&0<x.filtered.finishers.length?((t=document.createElement("canvas")).style.marginTop="12px",S.appendChild(t),new Chart(t.getContext("2d"),{type:"line",data:{labels:x.filtered.dates,datasets:[{label:"Finishers",data:x.filtered.finishers,borderColor:_.lineColor,backgroundColor:"rgba(34, 211, 238, 0.25)",tension:.2,fill:!0},{label:"Volunteers",data:x.filtered.volunteers,borderColor:_.successColor,backgroundColor:"rgba(16, 185, 129, 0.18)",tension:.2,fill:!0},{label:"Finishers baseline avg",data:x.filtered.dates.map(function(){return x.baseline.avgFinishers}),borderColor:_.barColor,borderDash:[6,4],pointRadius:0},{label:"Volunteers baseline avg",data:x.filtered.dates.map(function(){return x.baseline.avgVolunteers}),borderColor:_.gridColor,borderDash:[6,4],pointRadius:0}]},options:{animation:!1,responsive:!0,maintainAspectRatio:!0,aspectRatio:1.6,plugins:{legend:{labels:{color:_.textColor}},title:{display:!0,text:"Finishers & volunteers over baseline window",color:_.textColor}},scales:{x:{ticks:{color:_.subtleTextColor},grid:{color:_.gridColor}},y:{beginAtZero:!0,ticks:{precision:0,color:_.subtleTextColor},grid:{color:_.gridColor},title:{display:!0,text:"Finishers",color:_.textColor}}}}})):((n=document.createElement("div")).style.color=_.subtleTextColor,n.style.fontSize="12px",n.style.marginTop="8px",n.textContent="No historical data available for the baseline window.",S.appendChild(n)),h.appendChild(S),p.filter(function(e){return e.change&&0<e.change.finishersChange&&void 0!==e.change.finishersPct})),t=_toConsumableArray(r).sort(function(e,t){return t.change.finishersChange-e.change.finishersChange}).slice(0,1),n=_toConsumableArray(r).filter(function(e){return 0<e.change.finishersPct}).sort(function(e,t){return t.change.finishersPct-e.change.finishersPct}).slice(0,1),k=document.createElement("div"),S=(k.style.marginTop="18px",k.style.padding="12px",k.style.backgroundColor="#2b223d",k.style.borderRadius="4px",document.createElement("h3")),r=(S.textContent="Most Impacted parkruns",S.style.color=_.barColor,S.style.margin="0 0 10px 0",k.appendChild(S),document.createElement("div")),S=(r.style.color=_.textColor,r.style.fontSize="13px",0===t.length?(r.textContent="No nearby parkruns saw an attendance increase on this date.",k.appendChild(r)):(S=[],t[0]&&(D=t[0],S.push("Largest absolute gain: <strong>".concat(D.displayName||D.eventName,"</strong> (+").concat(D.change.finishersChange," finishers, ").concat(D.change.finishersPct.toFixed(1),"%)"))),n[0]&&(D=n[0],S.push("Largest relative gain: <strong>".concat(D.displayName||D.eventName,"</strong> (+").concat(D.change.finishersPct.toFixed(1),"%, +").concat(D.change.finishersChange," finishers)"))),r.innerHTML=S.join("<br>"),k.appendChild(r),D=[t[0],n[0]].filter(Boolean),C=new Set,D.forEach(function(e){var t,n,r,a,o;e&&e.seasonalTrend&&e.seasonalTrend.filtered&&(C.has(e.eventName)||(C.add(e.eventName),(t=document.createElement("div")).style.marginTop="12px",t.style.padding="10px",t.style.backgroundColor="#3a3250",t.style.borderRadius="4px",(n=document.createElement("div")).style.color=_.textColor,n.style.fontWeight="bold",n.style.marginBottom="6px",n.textContent=e.displayName||e.eventName,t.appendChild(n),(n=document.createElement("div")).style.color=_.textColor,n.style.fontSize="12px",n.style.display="grid",n.style.gridTemplateColumns="repeat(auto-fit, minmax(160px, 1fr))",n.style.gap="6px",n.innerHTML="\n <div>Avg finishers: <strong>".concat(e.seasonalTrend.baseline.avgFinishers,"</strong></div>\n <div>Min finishers: <strong>").concat(e.seasonalTrend.baseline.minFinishers,"</strong></div>\n <div>Max finishers: <strong>").concat(e.seasonalTrend.baseline.maxFinishers,"</strong></div>\n <div>Avg volunteers: <strong>").concat(e.seasonalTrend.baseline.avgVolunteers,"</strong></div>\n <div>Min volunteers: <strong>").concat(e.seasonalTrend.baseline.minVolunteers,"</strong></div>\n <div>Max volunteers: <strong>").concat(e.seasonalTrend.baseline.maxVolunteers,"</strong></div>\n "),t.appendChild(n),"undefined"!=typeof Chart&&e.seasonalTrend.filtered.finishers&&0<e.seasonalTrend.filtered.finishers.length&&((n=document.createElement("canvas")).style.marginTop="10px",t.appendChild(n),r=_toConsumableArray(e.seasonalTrend.filtered.dates),a=_toConsumableArray(e.seasonalTrend.filtered.finishers),o=_toConsumableArray(e.seasonalTrend.filtered.volunteers),e.eventOnDate&&(r.push(g),a.push(e.eventOnDate.finishers),o.push(e.eventOnDate.volunteers)),new Chart(n.getContext("2d"),{type:"line",data:{labels:r,datasets:[{label:"Finishers",data:a,borderColor:_.lineColor,backgroundColor:"rgba(34, 211, 238, 0.25)",tension:.2,fill:!0},{label:"Volunteers",data:o,borderColor:_.successColor,backgroundColor:"rgba(16, 185, 129, 0.18)",tension:.2,fill:!0},{label:"Finishers baseline avg",data:r.map(function(){return e.seasonalTrend.baseline.avgFinishers}),borderColor:_.barColor,borderDash:[6,4],pointRadius:0},{label:"Volunteers baseline avg",data:r.map(function(){return e.seasonalTrend.baseline.avgVolunteers}),borderColor:_.gridColor,borderDash:[6,4],pointRadius:0}]},options:{animation:!1,responsive:!0,maintainAspectRatio:!0,aspectRatio:1.6,plugins:{legend:{labels:{color:_.textColor}},title:{display:!0,text:"Seasonal trend",color:_.textColor}},scales:{x:{ticks:{color:_.subtleTextColor},grid:{color:_.gridColor}},y:{beginAtZero:!0,ticks:{precision:0,color:_.subtleTextColor},grid:{color:_.gridColor},title:{display:!0,text:"Count",color:_.textColor}}}}})),k.appendChild(t)))})),h.appendChild(k),"undefined"!=typeof Chart&&((S=document.createElement("div")).style.marginTop="30px",(r=document.createElement("h3")).textContent="Visual Impact Analysis",r.style.color=_.barColor,r.style.marginBottom="15px",S.appendChild(r),(t=document.createElement("div")).style.display="grid",t.style.gridTemplateColumns="1fr 1fr",t.style.gap="20px",n=document.createElement("canvas"),(D=document.createElement("div")).style.minWidth="0",D.appendChild(n),t.appendChild(D),r=document.createElement("canvas"),(D=document.createElement("div")).style.minWidth="0",D.appendChild(r),t.appendChild(D),S.appendChild(t),h.appendChild(S),D=p.filter(function(e){return e.eventOnDate}).map(function(e){return e.title||e.eventName}),t=p.filter(function(e){return e.eventOnDate}).map(function(e){return e.baseline.avgFinishers}),S=p.filter(function(e){return e.eventOnDate}).map(function(e){return e.eventOnDate.finishers}),new Chart(n.getContext("2d"),{type:"bar",data:{labels:D,datasets:[{label:"Baseline (12-event avg)",data:t,backgroundColor:_.barColor,borderColor:_.barColor,borderWidth:1},{label:"Actual on ".concat(g),data:S,backgroundColor:_.lineColor,borderColor:_.lineColor,borderWidth:1}]},options:{animation:!1,responsive:!0,maintainAspectRatio:!0,aspectRatio:1.5,plugins:{legend:{labels:{color:_.textColor}},title:{display:!0,text:"Finishers: Baseline vs Actual",color:_.textColor}},scales:{x:{ticks:{color:_.subtleTextColor,display:!1},grid:{color:_.gridColor}},y:{beginAtZero:!0,title:{display:!0,text:"Finishers",color:_.textColor},ticks:{precision:0,color:_.subtleTextColor},grid:{color:_.gridColor}}}}}),n=p.filter(function(e){return e.eventOnDate}).map(function(e){return e.baseline.avgVolunteers}),t=p.filter(function(e){return e.eventOnDate}).map(function(e){return e.eventOnDate.volunteers}),new Chart(r.getContext("2d"),{type:"bar",data:{labels:D,datasets:[{label:"Baseline (12-event avg)",data:n,backgroundColor:_.barColor,borderColor:_.barColor,borderWidth:1},{label:"Actual on ".concat(g),data:t,backgroundColor:_.lineColor,borderColor:_.lineColor,borderWidth:1}]},options:{animation:!1,responsive:!0,maintainAspectRatio:!0,aspectRatio:1.5,plugins:{legend:{labels:{color:_.textColor}},title:{display:!0,text:"Volunteers: Baseline vs Actual",color:_.textColor}},scales:{x:{ticks:{color:_.subtleTextColor,display:!1},grid:{color:_.gridColor}},y:{beginAtZero:!0,title:{display:!0,text:"Volunteers",color:_.textColor},ticks:{precision:0,color:_.subtleTextColor},grid:{color:_.gridColor}}}}})),document.createElement("div")),r=(S.style.marginTop="20px",S.style.padding="12px",S.style.backgroundColor="#3a3250",S.style.borderRadius="4px",document.createElement("h4")),D=(r.textContent="Summary",r.style.margin="0 0 8px 0",r.style.color=_.lineColor,S.appendChild(r),p.filter(function(e){return e.eventOnDate&&e.change})),n=D.reduce(function(e,t){return e+t.change.finishersChange},0),t=D.reduce(function(e,t){return e+t.change.volunteersChange},0),r=0<D.length?Math.round(n/D.length):0,E=0<D.length?Math.round(D.reduce(function(e,t){return e+t.change.volunteersChange},0)/D.length):0,T=document.createElement("div"),D=(T.style.fontSize="13px",T.style.color=_.textColor,T.innerHTML='\n <p style="margin: 4px 0;">\n <strong>'.concat(p.length,'</strong> nearby parkruns analyzed\n <span style="color: ').concat(_.subtleTextColor,'; font-size: 11px; margin-left: 8px;" title="parkruns within 50km of the cancelled event in the same country and series">βΉ</span>\n </p>\n <p style="margin: 4px 0;">\n <strong>').concat(D.length,"</strong> held events on ").concat(g,'\n <span style="color: ').concat(_.subtleTextColor,'; font-size: 11px; margin-left: 8px;" title="Number of nearby parkruns that ran on this date">βΉ</span>\n </p>\n <p style="margin: 4px 0;">\n Average change in finishers: <span style="color: ').concat(r<0?_.alertColor:_.successColor,'; font-weight: bold;">').concat(0<r?"+":"").concat(r,'</span>\n <span style="color: ').concat(_.subtleTextColor,'; font-size: 11px; margin-left: 8px;" title="Mean difference between actual finishers and 12-event baseline average across events that ran">βΉ</span>\n </p>\n <p style="margin: 4px 0;">\n Average change in volunteers: <span style="color: ').concat(E<0?_.alertColor:_.successColor,'; font-weight: bold;">').concat(0<E?"+":"").concat(E,'</span>\n <span style="color: ').concat(_.subtleTextColor,'; font-size: 11px; margin-left: 8px;" title="Mean difference between actual volunteers and 12-event baseline average across events that ran">βΉ</span>\n </p>\n <p style="margin: 4px 0;">\n Estimated total additional finishers: <span style="color: ').concat(n<0?_.alertColor:_.successColor,'; font-weight: bold;">').concat(0<n?"+":"").concat(n,'</span>\n <span style="color: ').concat(_.subtleTextColor,'; font-size: 11px; margin-left: 8px;" title="Sum of all finisher changes across nearby parkruns - positive indicates runners redistributed from the cancelled event">βΉ</span>\n </p>\n <p style="margin: 4px 0;">\n Estimated total additional volunteers: <span style="color: ').concat(t<0?_.alertColor:_.successColor,'; font-weight: bold;">').concat(0<t?"+":"").concat(t,'</span>\n <span style="color: ').concat(_.subtleTextColor,'; font-size: 11px; margin-left: 8px;" title="Sum of all volunteer changes across nearby parkruns - indicates how many extra volunteers were needed on the day">βΉ</span>\n </p>\n '),S.appendChild(T),h.appendChild(S),document.createElement("div")),w=(D.style.display="flex",D.style.justifyContent="center",D.style.marginTop="20px",D.style.gap="10px",D.style.flexWrap="wrap",document.createElement("button")),A=(w.textContent="π Export HTML",w.style.padding="8px 16px",w.style.backgroundColor=_.barColor,w.style.color="#1c1b2a",w.style.border="none",w.style.borderRadius="4px",w.style.cursor="pointer",w.style.fontWeight="bold",w.style.fontSize="14px",w.addEventListener("click",_asyncToGenerator(_regenerator().m(function e(){var t,n,r,a,o,l,i;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:return t=w.textContent,n=w.style.display,w.textContent="Exporting...",w.disabled=!0,w.style.display="none",e.p=1,a=v(),r=a.eventShortName,a=a.cancellationDateStr,e.n=2,I(h,{eventShortName:r,cancellationDateStr:a,generatedAt:(new Date).toLocaleString()});case 2:r=e.v,a=r.blob,i=r.filename,o=URL.createObjectURL(a),(l=document.createElement("a")).href=o,l.download=i,l.click(),setTimeout(function(){return URL.revokeObjectURL(o)},1e3),console.log("HTML export complete"),e.n=4;break;case 3:e.p=3,i=e.v,console.error("HTML export failed:",i),alert("Error exporting HTML: "+i.message);case 4:return e.p=4,w.disabled=!1,w.textContent=t,w.style.display=n,e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}))),document.createElement("button"));A.textContent="π€ Share Report",A.style.padding="8px 16px",A.style.backgroundColor=_.lineColor,A.style.color="#2b223d",A.style.border="none",A.style.borderRadius="4px",A.style.cursor="pointer",A.style.fontWeight="bold",A.style.fontSize="14px",A.addEventListener("click",_asyncToGenerator(_regenerator().m(function e(){var t,n,r,a,o,l,i,s,c;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:return t=A.textContent,n=A.style.display,A.textContent="Sharing...",A.disabled=!0,A.style.display="none",e.p=1,a=v(),r=a.eventShortName,a=a.cancellationDateStr,e.n=2,I(h,{eventShortName:r,cancellationDateStr:a,generatedAt:(new Date).toLocaleString()});case 2:if(l=e.v,o=l.blob,l=l.filename,s=new File([o],l,{type:"text/html"}),navigator.canShare&&navigator.canShare({files:[s]}))return e.n=3,navigator.share({title:"parkrun Cancellation Impact - ".concat(r),text:"Cancellation date: ".concat(a),files:[s]});e.n=4;break;case 3:console.log("Report shared via Web Share API"),e.n=5;break;case 4:i=URL.createObjectURL(o),(s=document.createElement("a")).href=i,s.download=l,s.click(),setTimeout(function(){return URL.revokeObjectURL(i)},1e3),alert("Sharing is not supported in this browser, so the HTML report was downloaded instead.");case 5:e.n=7;break;case 6:e.p=6,c=e.v,console.error("Share failed:",c),alert("Error sharing report: "+c.message);case 7:return e.p=7,A.disabled=!1,A.textContent=t,A.style.display=n,e.f(7);case 8:return e.a(2)}},e,null,[[1,6,7,8]])}))),D.appendChild(w),D.appendChild(A),h.appendChild(D),e.appendChild(h)}function t(){return(t=_asyncToGenerator(_regenerator().m(function e(){var t,n;return _regenerator().w(function(e){for(;;)switch(e.n){case 0:if(t=document.querySelector(".Results-table"),n=window.location.href,n=n.includes("/eventhistory/"),t&&n){e.n=1;break}return e.a(2);case 1:return e.n=2,function(){return r.apply(this,arguments)}();case 2:N.allParkruns=e.v,!function(){a.apply(this,arguments)}();case 3:return e.a(2)}},e)}))).apply(this,arguments)}!function(){t.apply(this,arguments)}()})(),"undefined"!=typeof module&&module.exports&&(module.exports={calculateBaseline:calculateBaseline,calculateBearing:calculateBearing,calculateDistance:calculateDistance,detectAllEventGaps:detectAllEventGaps,detectEventGap:detectEventGap,filterEventsByDateRange:filterEventsByDateRange,getBaselineEventsBefore:getBaselineEventsBefore,getCancellationSaturdays:getCancellationSaturdays,getMostRecentCancellationDate:getMostRecentCancellationDate,getNotHeldLabel:getNotHeldLabel,isFinishersMaxUpToEvent:isFinishersMaxUpToEvent,isInvalidHistoryData:isInvalidHistoryData,parseDateString:parseDateString,toLocalDateString:toLocalDateString});