-
Notifications
You must be signed in to change notification settings - Fork 9
/
splitsbrowser.min.js
25 lines (25 loc) · 147 KB
/
splitsbrowser.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*!
* SplitsBrowser - Orienteering results analysis.
*
* Copyright (C) 2000-2022 Dave Ryder, Reinhard Balling, Andris Strazdins,
* Ed Nash, Luke Woodward
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
var SplitsBrowser={Version:"3.5.4",Model:{},Input:{},Controls:{},Messages:{}};!function(){"use strict";function e(t){this.name="InvalidData",this.message=t}function s(t){this.name="WrongFileFormat",this.message=t}SplitsBrowser.isTrue=function(t){return t},SplitsBrowser.isNotNull=function(t){return null!==t},SplitsBrowser.isNaNStrict=function(t){return t!=t},SplitsBrowser.isNotNullNorNaN=function(t){return null!==t&&t==t},e.prototype.toString=function(){return this.name+": "+this.message},SplitsBrowser.throwInvalidData=function(t){throw new e(t)},s.prototype.toString=function(){return this.name+": "+this.message},SplitsBrowser.throwWrongFileFormat=function(t){throw new s(t)},SplitsBrowser.hasProperty=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},SplitsBrowser.addIfNotNull=function(t,e){return null===t||null===e?null:t+e},SplitsBrowser.subtractIfNotNull=function(t,e){return null===t||null===e?null:t-e},SplitsBrowser.parseCourseLength=function(t){t=parseFloat(t.replace(",","."));return isFinite(t)?(500<=t&&(t/=1e3),t):null},SplitsBrowser.parseCourseClimb=function(t){t=parseInt(t,10);return SplitsBrowser.isNaNStrict(t)?null:t},SplitsBrowser.normaliseLineEndings=function(t){return t.replace(/\r\n/g,"\n").replace(/\r/g,"\n")}}(),function(){"use strict";var r=SplitsBrowser.hasProperty,e=!1,s=function(t){window.alert(t)},n=null,i=null,o=SplitsBrowser.Messages;function l(t){e||(s(t),e=!0)}SplitsBrowser.setMessageAlerter=function(t){s=t},SplitsBrowser.tryGetMessage=function(t,e){return null!==n&&r(o[n],t)?SplitsBrowser.getMessage(t):e},SplitsBrowser.getMessage=function(t){return null===i&&SplitsBrowser.initialiseMessages(),null!==n?r(o[n],t)?o[n][t]:(l("Message not found for key '"+t+"' in language '"+n+"'"),"?????"):(l("No messages found. Has a language file been loaded?"),"?????")},SplitsBrowser.getMessageWithFormatting=function(t,e){var s,n,i=SplitsBrowser.getMessage(t);for(s in e)r(e,s)&&(n=s.replace(/([.+*?|{}()^$[\]\\])/g,"\\$1"),i=i.replace(new RegExp(n,"g"),e[s]));return i},SplitsBrowser.getAllLanguages=function(){return i.slice(0)},SplitsBrowser.getLanguage=function(){return n},SplitsBrowser.getLanguageName=function(t){return r(o,t)&&r(o[t],"Language")?o[t].Language:"?????"},SplitsBrowser.setLanguage=function(t){r(o,t)&&(n=t)},SplitsBrowser.initialiseMessages=function(t){for(var e in i=[],o!==SplitsBrowser.Messages&&l("You appear to have loaded a messages file in the old format. This file, and all others loaded after it, will not work.\n\nPlease check the messages files."),o)r(o,e)&&i.push(e);0===i.length?l("No messages files were found."):n=t&&r(o,t)?t:i[0]}}(),function(){"use strict";SplitsBrowser.NULL_TIME_PLACEHOLDER="-----";var r=SplitsBrowser.isNaNStrict;function o(t){return t<10?"0"+t:t.toString()}SplitsBrowser.formatTime=function(t,e){if(null===t)return SplitsBrowser.NULL_TIME_PLACEHOLDER;if(r(t))return"???";var s="",n=(t<0&&(s="-",t=-t),Math.floor(t/3600)),i=Math.floor(t/60)%60,t=t%60;return 0<n&&(s+=n.toString()+":"),s+=o(i)+":",t<10&&(s+="0"),s+="number"==typeof e?t.toFixed(e):Math.round(100*t)/100},SplitsBrowser.formatTimeOfDay=function(t){var e=Math.floor(t/3600%24),s=Math.floor(t/60)%60,t=Math.floor(t%60);return o(e)+":"+o(s)+":"+o(t)},SplitsBrowser.parseTime=function(t){var e;return t=t.trim(),/^(-?\d+:)?-?\d+:-?\d\d([,.]\d{1,10})?$/.test(t)?(t=t.replace(",",".").split(":"),e=0,t.forEach(function(t){e=60*e+parseFloat(t)}),e):null}}(),function(){"use strict";var t=SplitsBrowser.isNotNull,i=SplitsBrowser.isNaNStrict,e=SplitsBrowser.hasProperty,l=SplitsBrowser.addIfNotNull,n=SplitsBrowser.subtractIfNotNull,u=SplitsBrowser.throwInvalidData;function h(t){if(!$.isArray(t))throw new TypeError("Cumulative times must be an array - got "+typeof t+" instead");0===t.length?u("Array of cumulative times must not be empty"):0!==t[0]?u("Array of cumulative times must have zero as its first item"):1===t.length&&u("Array of cumulative times must contain more than just a single zero");for(var e=[],s=0;s+1<t.length;s+=1)e.push(n(t[s+1],t[s]));return e}function a(t,e,s,n,i){"number"!=typeof t&&u("Result order must be a number, got "+typeof t+" '"+t+"' instead"),"number"!=typeof e&&null!==e&&u("Start time must be a number, got "+typeof e+" '"+e+"' instead"),this.order=t,this.startTime=e,this.owner=i,this.isOKDespiteMissingTimes=!1,this.isNonCompetitive=!1,this.isNonStarter=!1,this.isNonFinisher=!1,this.isDisqualified=!1,this.isOverMaxTime=!1,this.originalSplitTimes=s,this.originalCumTimes=n,this.splitTimes=null,this.cumTimes=null,this.splitRanks=null,this.cumRanks=null,this.timeLosses=null,this.className=null,this.offsets=null,this.totalTime=null===n||-1<n.indexOf(null)?null:n[n.length-1]}function c(t,e,s){for(var n=[0],i=0;i<t.length;i+=1)for(var r=s(t[i]),o=1;o<r.length;o+=1)n.push(l(e[i],r[o]));return n}SplitsBrowser.Model.compareResults=function(t,e){return t.isDisqualified!==e.isDisqualified?t.isDisqualified?1:-1:t.totalTime===e.totalTime?t.order-e.order:null===t.totalTime?null===e.totalTime?0:1:null===e.totalTime?-1:t.totalTime-e.totalTime},a.prototype.setOKDespiteMissingTimes=function(){this.isOKDespiteMissingTimes=!0,null!==this.originalCumTimes&&(this.totalTime=this.originalCumTimes[this.originalCumTimes.length-1])},a.prototype.setNonCompetitive=function(){this.isNonCompetitive=!0},a.prototype.setNonStarter=function(){this.isNonStarter=!0},a.prototype.setNonFinisher=function(){this.isNonFinisher=!0},a.prototype.disqualify=function(){this.isDisqualified=!0},a.prototype.setOverMaxTime=function(){this.isOverMaxTime=!0},a.prototype.setClassName=function(t){this.className=t},a.prototype.setOffsets=function(t){this.offsets=t},a.fromOriginalCumTimes=function(t,e,s,n){return new a(t,e,h(s),s,n)},a.fromCumTimes=function(t,e,s,n){t=a.fromOriginalCumTimes(t,e,s,n);return t.splitTimes=t.originalSplitTimes,t.cumTimes=t.originalCumTimes,t},a.prototype.setRepairedCumulativeTimes=function(t){this.cumTimes=t,this.splitTimes=h(t)},a.prototype.completed=function(){return null!==this.totalTime&&!this.isDisqualified&&!this.isOverMaxTime},a.prototype.hasAnyTimes=function(){return this.originalCumTimes.slice(1).some(t)},a.prototype.getSplitTimeTo=function(t){return 0===t?0:this.splitTimes[t-1]},a.prototype.getOriginalSplitTimeTo=function(t){return this.isNonStarter?null:0===t?0:this.originalSplitTimes[t-1]},a.prototype.isSplitTimeDubious=function(t){return 0<t&&this.originalSplitTimes[t-1]!==this.splitTimes[t-1]},a.prototype.getCumulativeTimeTo=function(t){return this.cumTimes[t]},a.prototype.getOriginalCumulativeTimeTo=function(t){return this.isNonStarter?null:this.originalCumTimes[t]},a.prototype.isCumulativeTimeDubious=function(t){return this.originalCumTimes[t]!==this.cumTimes[t]},a.prototype.getSplitRankTo=function(t){return null===this.splitRanks?null:this.splitRanks[t]},a.prototype.getCumulativeRankTo=function(t){return null===this.cumRanks?null:this.cumRanks[t]},a.prototype.getTimeLossAt=function(t){return 0===t||null===this.timeLosses?null:this.timeLosses[t-1]},a.prototype.getAllCumulativeTimes=function(){return this.cumTimes},a.prototype.getAllOriginalCumulativeTimes=function(){return this.originalCumTimes},a.prototype.getAllSplitTimes=function(){return this.splitTimes},a.prototype.lacksStartTime=function(){return null===this.startTime&&this.splitTimes.some(t)},a.prototype.setSplitAndCumulativeRanks=function(t,e){null===t[0]&&null===e[0]||u("Split and cumulative ranks arrays must both start with null"),this.splitRanks=t,this.cumRanks=e},a.prototype.getCumTimesAdjustedToReference=function(s){return s.length!==this.cumTimes.length?u("Cannot adjust cumulative times because the numbers of times are different ("+this.cumTimes.length+" and "+s.length+")"):-1<s.indexOf(null)&&u("Cannot adjust cumulative times because a null value is in the reference data"),this.cumTimes.map(function(t,e){return n(t,s[e])})},a.prototype.getCumTimesAdjustedToReferenceWithStartAdded=function(t,e){var s,t=this.getCumTimesAdjustedToReference(t);return s=null===e||0===e?this.startTime:(e=this.offsets[e],this.startTime+this.cumTimes[e]-t[e]),t.map(function(t){return l(t,s)})},a.prototype.getSplitPercentsBehindReferenceCumTimes=function(s){s.length!==this.cumTimes.length?u("Cannot determine percentages-behind because the numbers of times are different ("+this.cumTimes.length+" and "+s.length+")"):-1<s.indexOf(null)&&u("Cannot determine percentages-behind because a null value is in the reference data");var n=[0];return this.splitTimes.forEach(function(t,e){null===t?n.push(null):0<(e=s[e+1]-s[e])?n.push(100*(t-e)/e):0==e?n.push(0===n.length?0:n[n.length-1]):n.push(null)}),n},a.prototype.determineTimeLosses=function(s){var t,e,n;this.completed()&&(s.length!==this.splitTimes.length?u("Cannot determine time loss with "+this.splitTimes.length+" split times using "+s.length+" fastest splits"):s.some(i)&&u("Cannot determine time loss when there is a NaN value in the fastest splits"),this.isOKDespiteMissingTimes||this.splitTimes.some(i)?this.timeLosses=this.splitTimes.map(function(){return NaN}):((t=this.splitTimes.filter(function(t,e){return 0!==s[e]}).map(function(t,e){return t/s[e]})).sort(d3.ascending),n=0===t.length?NaN:t.length%2==1?t[(t.length-1)/2]:(t[(e=t.length/2)-1]+t[e])/2,this.timeLosses=this.splitTimes.map(function(t,e){return Math.round(t-s[e]*n)})))},a.prototype.crosses=function(t,e){t.cumTimes.length!==this.cumTimes.length&&u("Two results with different numbers of controls cannot cross");for(var s,n,i,r=!1,o=!1,l=null===e||null===this.offsets?(s=0,this.cumTimes.length):(s=this.offsets[e],e+1===this.offsets.length?this.cumTimes.length:this.offsets[e+1]+1),a=s;a<l;a+=1)null!==this.cumTimes[a]&&null!==t.cumTimes[a]&&((n=this.startTime+this.cumTimes[a])<(i=t.startTime+t.cumTimes[a])?r=!0:i<n&&(o=!0));return r&&o},a.prototype.isTimeOmitted=function(t){return i(t)||this.isOKDespiteMissingTimes&&null===t},a.prototype.getIndexesAroundOmittedTimes=function(t){for(var e=[],s=1;s+1<t.length;)if(this.isTimeOmitted(t[s])){for(var n=s;n+1<t.length&&this.isTimeOmitted(t[n+1]);)n+=1;n+1<t.length&&null!==t[s-1]&&null!==t[n+1]&&e.push({start:s-1,end:n+1}),s=n+1}else s+=1;return e},a.prototype.getControlIndexesAroundOmittedCumulativeTimes=function(){return this.getIndexesAroundOmittedTimes(this.cumTimes)},a.prototype.getControlIndexesAroundOmittedSplitTimes=function(){return this.getIndexesAroundOmittedTimes([0].concat(this.splitTimes))},a.prototype.getOwnerNameForLeg=function(t){return(e(this.owner,"members")&&null!==t?this.owner.members[t]:this.owner).name},a.prototype.determineAggregateStatus=function(t){if(t.some(function(t){return t.isDisqualified}))this.isDisqualified=!0;else if(t.every(function(t){return t.isNonStarter}))this.isNonStarter=!0;else{for(var e=-1;e+1<t.length;e+=1){var s=t[e+1];if(s.isNonStarter||s.isNonFinisher||!s.completed())break}for(var n=t.length;0<n;--n)if(!t[n-1].isNonStarter)break;if(e<t.length-1){if(e+1===n)return void(this.isNonFinisher=!0);if(e+2===n&&t[e+1].isNonFinisher)return void(this.isNonFinisher=!0)}t.some(function(t){return t.isOverMaxTime})?this.isOverMaxTime=!0:(t.some(function(t){return t.isNonCompetitive})&&(this.isNonCompetitive=!0),t.some(function(t){return t.isOKDespiteMissingTimes})&&this.setOKDespiteMissingTimes())}},a.prototype.restrictToCommonControls=function(t,e){t.length!==e.length&&u("Should have two equal-length arrays of common controls");for(var s=[0],n=1,i=0;i<t.length;i+=1){for(var r=t[i],o=e[i],l=0,a=0;a<r.length;a+=1)l<o.length&&r[a]===o[l]&&(n>=this.originalCumTimes.length&&u("Attempt to read too many original controls: likely that the wrong list of controls has been passed"),s.push(this.originalCumTimes[n]),l+=1),n+=1;l<o.length&&u("Did not reach end of common controls: likely that they are not a subset of the controls"),n>=this.originalCumTimes.length&&u("Attempt to read too many original controls: likely that the wrong list of controls has been passed"),s.push(this.originalCumTimes[n]),n+=1}n<this.originalCumTimes.length&&u("Did not reach end of original controls: likely that a wrong list of controls has been passed"),this.originalCumTimes=s,this.originalSplitTimes=h(s)},a.createTeamResult=function(t,e,s){e.length<2&&u("Team results can only be created from at least two other results");i=[0],(n=e).forEach(function(t,e){var s=i[i.length-1],e=e+1<n.length?n[e+1]:null,s=null!==s&&null!==t.totalTime?s+t.totalTime:null!==e&&null!==e.startTime&&null!==n[0].startTime?e.startTime-n[0].startTime:null;i.push(s)});var n,i,r=i.slice(0,i.length-1),o=(s.setMembers(e.map(function(t){return t.owner})),c(e,r,function(t){return t.originalCumTimes})),t=a.fromOriginalCumTimes(t,e[0].startTime,o,s);return e.every(function(t){return null!==t.cumTimes})&&(t.cumTimes=c(e,r,function(t){return t.cumTimes}),t.splitTimes=h(t.cumTimes)),t.determineAggregateStatus(e),t},SplitsBrowser.Model.Result=a}(),function(){"use strict";function t(t,e){this.name=t,this.club=e,this.yearOfBirth=null,this.gender=null}t.prototype.setYearOfBirth=function(t){this.yearOfBirth=t},t.prototype.setGender=function(t){this.gender=t},SplitsBrowser.Model.Competitor=t}(),function(){"use strict";function t(t,e){this.name=t,this.club=e}t.prototype.setMembers=function(t){this.members=t},SplitsBrowser.Model.Team=t}(),function(){var u=SplitsBrowser.throwInvalidData;SplitsBrowser.COMMON_CONTROLS_MODE="commonControls",SplitsBrowser.determineCommonControls=function(t,e){for(var s=d3.map(),n=(0===t.length&&u("Cannot determine the list of common controls of an empty array"),t.forEach(function(t){var e=d3.set();t.forEach(function(t){e.has(t)||(e.add(t),s.has(t)?s.set(t,s.get(t)+1):s.set(t,1))})}),t.length),i=t[0].filter(function(t){return s.get(t)===n}),r=1;r<n;r+=1){var o=t[r].filter(function(t){return s.get(t)===n}),l=d3.set();o.forEach(function(t){l.has(t)?u("Cannot determine common controls because "+e+" contains duplicated control "+t):l.add(t)}),o.length!==i.length&&u("Unexpectedly didn't get the same number of common controls for all competitors");for(var a=0;a<i.length;a+=1)i[a]!==o[a]&&u("Inconsistent ordering for control "+i[a]+" in "+e)}return i}}(),function(){"use strict";var r=SplitsBrowser.isNotNullNorNaN,t=SplitsBrowser.throwInvalidData;function e(e,t,s){this.name=e,this.numControls=t,this.numbersOfControls=null,this.offsets=null,this.results=s,this.course=null,this.hasDubiousData=!1,this.isTeamClass=!1,this.results.forEach(function(t){t.setClassName(e)})}e.prototype.recordHasDubiousData=function(){this.hasDubiousData=!0},e.prototype.setIsTeamClass=function(t){this.isTeamClass=!0,this.numbersOfControls=t,this.offsets=[0];for(var e=1;e<t.length;e+=1)this.offsets.push(this.offsets[e-1]+t[e-1]+1);this.results.forEach(function(t){t.setOffsets(this.offsets)},this)},e.prototype.determineTimeLosses=function(){var e=d3.range(1,this.numControls+2).map(function(t){t=this.getFastestSplitTo(t);return null===t?null:t.split},this);this.results.forEach(function(t){t.determineTimeLosses(e)})},e.prototype.isEmpty=function(){return 0===this.results.length},e.prototype.setCourse=function(t){this.course=t},e.prototype.getFastestSplitTo=function(s){("number"!=typeof s||s<1||s>this.numControls+1)&&t("Cannot return splits to leg '"+s+"' in a course with "+this.numControls+" control(s)");var n=null,i=null;return this.results.forEach(function(t){var e=t.getSplitTimeTo(s);r(e)&&(null===n||e<n)&&(n=e,i=t)}),null===n?null:{split:n,name:i.owner.name}},e.prototype.getResultsAtControlInTimeRange=function(s,n,i){("number"!=typeof s||isNaN(s)||s<0||s>this.numControls+1)&&t("Control number must be a number between 0 and "+this.numControls+" inclusive");var r=[];return this.results.forEach(function(t){var e=t.getCumulativeTimeTo(s);null!==e&&null!==t.startTime&&(e=e+t.startTime,n<=e&&e<=i&&r.push({name:t.owner.name,time:e}))}),r},SplitsBrowser.Model.CourseClass=e}(),function(){"use strict";var h=SplitsBrowser.isNotNull,u=SplitsBrowser.isNaNStrict,c=SplitsBrowser.isNotNullNorNaN,o=SplitsBrowser.throwInvalidData,n=SplitsBrowser.Model.compareResults;function t(t){var e=t.filter(c),s=(e.sort(d3.ascending),new d3.map);return e.forEach(function(t,e){s.has(t)||s.set(t,e+1)}),t.map(function(t){return c(t)?s.get(t):t})}function e(t){this.allResults=function(t){if(0===t.length)return[];var e=[],s=t[0].numControls;return t.forEach(function(t){t.numControls!==s&&o("Cannot merge classes with "+s+" and "+t.numControls+" controls"),t.results.forEach(function(t){t.isNonStarter||e.push(t)})}),e.sort(n),e}(t),this.classes=t,this.numControls=0<t.length?t[0].numControls:null,this.computeRanks()}function p(t,e){for(var s=[],n=1;n+1<t.length;)if(c(t[n]))n+=1;else{for(var i=n;i+1<t.length&&!c(t[i+1]);)i+=1;(i+1<t.length||e)&&s.push({start:n-1,end:i+1}),n=i+1}return s}function s(t){for(var e=p(t=t.slice(0),!1),s=0;s<e.length;s+=1)for(var n=e[s],i=t[n.start],r=(t[n.end]-i)/(n.end-n.start),o=n.start+1;o<n.end;o+=1)t[o]=i+(o-n.start)*r;for(var l=t.length;0<=l&&u(t[l-1]);)--l;if(0<l)for(var a=l;a<t.length;a+=1)t[a]=t[a-1]+(a===t.length-1?60:180);return t}e.prototype.isEmpty=function(){return 0===this.allResults.length},e.prototype.getCourse=function(){return 0<this.classes.length?this.classes[0].course:null},e.prototype.getPrimaryClassName=function(){return 0<this.classes.length?this.classes[0].name:null},e.prototype.getNumClasses=function(){return this.classes.length},e.prototype.hasDubiousData=function(){return this.classes.some(function(t){return t.hasDubiousData})},e.prototype.hasTeamData=function(){return 0<this.classes.length&&this.classes.every(function(t){return t.isTeamClass})},e.prototype.getLegCount=function(){for(var t=null,e=0;e<this.classes.length;e+=1){if(!this.classes[e].isTeamClass)return null;var s=this.classes[e].numbersOfControls.length;if(null===t)t=s;else if(t!==s)return null}return t},e.prototype.getWinnerCumTimes=function(){if(0===this.allResults.length)return null;var t=this.allResults[0];return t.completed()?s(t.cumTimes):null},e.prototype.getFastestCumTimes=function(){return this.getFastestCumTimesPlusPercentage(0)},e.prototype.getFastestCumTimesPlusPercentage=function(t){if(null===this.numControls)return null;var s=1+t/100,r=new Array(this.numControls+1);r[0]=0;for(var o,e=1;e<=this.numControls+1;e+=1){for(var n=null,i=0;i<this.allResults.length;i+=1){var l=this.allResults[i].getSplitTimeTo(e);c(l)&&(null===n||l<n)&&(n=l)}r[e]=n}if(r.every(h)||(t=p(r,!0),o=[],this.allResults.forEach(function(e){p(e.getAllCumulativeTimes(),!1).forEach(function(t){o.push({start:t.start,end:t.end,size:t.end-t.start,overallSplit:e.getCumulativeTimeTo(t.end)-e.getCumulativeTimeTo(t.start)})})}),t.forEach(function(e){var t=o.filter(function(t){return t.start<=e.start&&e.end<=t.end+1}),s=null,n=null;if(t.forEach(function(t){(null===s||t.size<s)&&(s=t.size,n=null),(null===n||t.overallSplit<n)&&(n=t.overallSplit)}),null!==s&&null!==n)for(var i=e.start+1;i<e.end;i+=1)r[i]=n/s})),!r.every(h))for(var a=0;a<r.length;a+=1)null===r[a]&&(r[a]=a===r.length-1?60:180);var u=new Array(this.numControls+1);return r.forEach(function(t,e){u[e]=0===e?0:u[e-1]+t*s}),u},e.prototype.getCumulativeTimesForResult=function(t){return s(this.allResults[t].getAllCumulativeTimes())},e.prototype.computeRanks=function(){var n,i;0!==this.allResults.length&&(n=[],i=[],this.allResults.forEach(function(){n.push([null]),i.push([null])}),d3.range(1,this.numControls+2).forEach(function(e){var s=t(this.allResults.map(function(t){return t.getSplitTimeTo(e)}));this.allResults.forEach(function(t,e){n[e].push(s[e])})},this),d3.range(1,this.numControls+2).forEach(function(s){var n=t(this.allResults.map(function(t,e){return 1<s&&null===i[e][s-1]&&!t.isOKDespiteMissingTimes?null:t.getCumulativeTimeTo(s)}));this.allResults.forEach(function(t,e){i[e].push(n[e])})},this),this.allResults.forEach(function(t,e){t.setSplitAndCumulativeRanks(n[e],i[e])}))},e.prototype.getFastestSplitsTo=function(t,i,e){if("number"!=typeof t||t<=0)o("The number of splits must be a positive integer");else{if(!("number"!=typeof i||i<=0||i>this.numControls+1)){for(var s=this.allResults.filter(function(t){return t.completed()&&!u(t.getSplitTimeTo(i))}),n=(s.sort(function(t,e){var s=t.getSplitTimeTo(i),n=e.getSplitTimeTo(i);return s===n?d3.ascending(t.totalTime,e.totalTime):d3.ascending(s,n)}),[]),r=0;r<s.length&&r<t;r+=1)n.push({name:s[r].getOwnerNameForLeg(e),split:s[r].getSplitTimeTo(i)});return n}o("Control "+i+" out of range")}},e.prototype.sliceForLegIndex=function(t,e){var s;return this.hasTeamData()&&null!==e?(s=this.classes[0].numbersOfControls[e]+2,e=this.classes[0].offsets[e],t.slice(e,e+s)):t.slice(0)},e.prototype.getChartData=function(e,t,s,n){if(void 0===e)throw new TypeError("referenceCumTimes undefined or missing");if(void 0===t)throw new TypeError("currentIndexes undefined or missing");if(void 0===s)throw new TypeError("chartType undefined or missing");if(void 0===n)throw new TypeError("legIndex undefined or missing");var i,r,o,l=this.allResults.map(function(t){return s.dataSelector(t,e,n)}),a=t.map(function(t){return l[t]}),u=(this.hasTeamData()&&null!==n?(a=a.map(function(t){return this.sliceForLegIndex(t,n)},this),i=this.classes[0].numbersOfControls[n],e=this.sliceForLegIndex(e,n)):i=this.numControls,d3.min(e)),h=d3.max(e),c=(o=0===t.length?this.isEmpty()?(r=0,60):(o=l[0],r=d3.min(o),d3.max(o)):(r=d3.min(a.map(function(t){return d3.min(t)})),d3.max(a.map(function(t){return d3.max(t)}))),Math.abs(o-r)<1e-8&&(o=r+1),this.hasTeamData()&&null!==n?this.classes[0].offsets[n]:0),p=t.map(function(t){return s.indexesAroundOmittedTimesFunc(this.allResults[t]).filter(function(t){return t.start>=c&&t.end<c+i+2}).map(function(t){return{start:t.start-c,end:t.end-c}})},this),a=d3.transpose(a),d=e,d=d3.zip(d,a),a=t.map(function(t){return this.allResults[t].getOwnerNameForLeg(n)},this);return{dataColumns:d.map(function(t){return{x:t[0],ys:t[1]}}),resultNames:a,numControls:i,xExtent:[u,h],yExtent:[r,o],dubiousTimesInfo:p}},SplitsBrowser.Model.CourseClassSet=e}(),function(){"use strict";var r=SplitsBrowser.throwInvalidData;function t(t,e,s,n,i){this.name=t,this.classes=e,this.length=s,this.climb=n,this.controls=i}var l=t.START="__START__",a=t.FINISH="__FINISH__",o=t.INTERMEDIATE="__INTERMEDIATE__";t.prototype.getOtherClasses=function(e){var t=this.classes.filter(function(t){return t!==e});if(t.length!==this.classes.length)return t;r("Course.getOtherClasses: given class is not in this course")},t.prototype.getNumClasses=function(){return this.classes.length},t.prototype.hasControls=function(){return null!==this.controls},t.prototype.getControlCode=function(t){return 0===t?l:1<=t&&t<=this.controls.length?this.controls[t-1]:t===this.controls.length+1?a:void r("Cannot get control code of control "+t+" because it is out of range")},t.prototype.usesLeg=function(t,e){return 0<=this.getLegNumber(t,e)},t.prototype.getLegNumber=function(t,e){if(null===this.controls)return-1;if(t===l&&e===a)return 0===this.controls.length?1:-1;if(t===l)return 0<this.controls.length&&this.controls[0]===e?1:-1;if(e===a)return 0<this.controls.length&&this.controls[this.controls.length-1]===t?this.controls.length+1:-1;for(var s=1;s<this.controls.length;s+=1)if(this.controls[s-1]===t&&this.controls[s]===e)return s+1;return-1},t.prototype.getFastestSplitsForLeg=function(t,e){null===this.legs&&r("Cannot determine fastest splits for a leg because leg information is not available");var s=this.getLegNumber(t,e),n=(s<0&&r("Leg from "+((t===l||t===o?"start":t)+" to "+(e===a||e===o?"end":e))+" not found in course "+this.name),s),i=[];return this.classes.forEach(function(t){var e=t.getFastestSplitTo(n);null!==e&&i.push({name:e.name,className:t.name,split:e.split})}),i},t.prototype.getResultsAtControlInTimeRange=function(t,e,s){if(null===this.controls)return[];if(t===l)return this.getResultsAtControlNumInTimeRange(0,e,s);if(t===a)return this.getResultsAtControlNumInTimeRange(this.controls.length+1,e,s);for(var n=-1,i=[],r=function(t){i.push(t)};;){var o=this.controls.indexOf(t,n+1);if(o<0)return i;this.getResultsAtControlNumInTimeRange(o+1,e,s).forEach(r),n=o}},t.prototype.getResultsAtControlNumInTimeRange=function(t,s,n){var i=[];return this.classes.forEach(function(e){e.getResultsAtControlInTimeRange(t,s,n).forEach(function(t){i.push({name:t.name,time:t.time,className:e.name})})}),i},t.prototype.hasControl=function(t){return null!==this.controls&&-1<this.controls.indexOf(t)},t.prototype.getNextControls=function(t){if(null===this.controls)r("Course has no controls");else if(t===a)r("Cannot fetch next control after the finish");else{if(t===l)return[0===this.controls.length?a:this.controls[0]];for(var e=-1,s=[];;){var n=this.controls.indexOf(t,e+1);if(-1===n)break;n===this.controls.length-1?s.push(a):s.push(this.controls[n+1]),e=n}if(0!==s.length)return s;r("Control '"+t+"' not found on course "+this.name)}},SplitsBrowser.Model.Course=t}(),function(){"use strict";var s=SplitsBrowser.Model.Course;function t(t,e,s){this.classes=t,this.courses=e,this.warnings=s}t.prototype.determineTimeLosses=function(){this.classes.forEach(function(t){t.determineTimeLosses()})},t.prototype.needsRepair=function(){return this.classes.some(function(t){return t.results.some(function(t){return null===t.getAllCumulativeTimes()})})},t.prototype.getFastestSplitsForLeg=function(e,s){var n=[];return this.courses.forEach(function(t){t.usesLeg(e,s)&&(n=n.concat(t.getFastestSplitsForLeg(e,s)))}),n.sort(function(t,e){return d3.ascending(t.split,e.split)}),n},t.prototype.getResultsAtControlInTimeRange=function(e,s,n){var i=[];return this.courses.forEach(function(t){t.getResultsAtControlInTimeRange(e,s,n).forEach(function(t){i.push(t)})}),i.sort(function(t,e){return d3.ascending(t.time,e.time)}),i},t.prototype.getNextControlsAfter=function(e){var t=this.courses;return(t=e!==s.START?t.filter(function(t){return t.hasControl(e)}):t).map(function(t){return{course:t,nextControls:t.getNextControls(e)}})},SplitsBrowser.Model.Event=t}(),function(){function n(t){return null===t?null:t/60}function t(t){return t.getControlIndexesAroundOmittedCumulativeTimes()}function e(e){return function(t){return e(t).filter(function(t){return 0<t.start})}}function s(t){return t.getControlIndexesAroundOmittedSplitTimes()}SplitsBrowser.Model.ChartTypes={SplitsGraph:{nameKey:"SplitsGraphChartType",dataSelector:function(t,e){return t.getCumTimesAdjustedToReference(e).map(n)},yAxisLabelKey:"SplitsGraphYAxisLabel",isRaceGraph:!1,isResultsTable:!1,minViewableControl:1,indexesAroundOmittedTimesFunc:t},RaceGraph:{nameKey:"RaceGraphChartType",dataSelector:function(t,e,s){return t.getCumTimesAdjustedToReferenceWithStartAdded(e,s).map(n)},yAxisLabelKey:"RaceGraphYAxisLabel",isRaceGraph:!0,isResultsTable:!1,minViewableControl:0,indexesAroundOmittedTimesFunc:t},PositionAfterLeg:{nameKey:"PositionAfterLegChartType",dataSelector:function(t){return t.cumRanks},yAxisLabelKey:"PositionYAxisLabel",isRaceGraph:!1,isResultsTable:!1,minViewableControl:1,indexesAroundOmittedTimesFunc:e(t)},SplitPosition:{nameKey:"SplitPositionChartType",dataSelector:function(t){return t.splitRanks},yAxisLabelKey:"PositionYAxisLabel",isRaceGraph:!1,isResultsTable:!1,minViewableControl:1,indexesAroundOmittedTimesFunc:e(s)},PercentBehind:{nameKey:"PercentBehindChartType",dataSelector:function(t,e){return t.getSplitPercentsBehindReferenceCumTimes(e)},yAxisLabelKey:"PercentBehindYAxisLabel",isRaceGraph:!1,isResultsTable:!1,minViewableControl:1,indexesAroundOmittedTimesFunc:s},ResultsTable:{nameKey:"ResultsTableChartType",dataSelector:null,yAxisLabelKey:null,isRaceGraph:!1,isResultsTable:!0,minViewableControl:1,indexesAroundOmittedTimesFunc:null}}}(),function(){"use strict";var i="number",r=SplitsBrowser.throwInvalidData;function t(t){typeof t!=i?r("Result count must be a number"):t<0&&r("Result count must be a non-negative number"),this.count=t,this.currentIndexes=[],this.changeHandlers=[]}t.prototype.isSelected=function(t){return-1<this.currentIndexes.indexOf(t)},t.prototype.isSingleRunnerSelected=function(){return 1===this.currentIndexes.length},t.prototype.getSingleRunnerIndex=function(){return this.isSingleRunnerSelected()?this.currentIndexes[0]:null},t.prototype.selectCrossingRunners=function(t,s){var n;this.isSingleRunnerSelected()&&(n=t[this.currentIndexes[0]].result,t.forEach(function(t,e){t.visible&&t.result.crosses(n,s)&&this.currentIndexes.push(e)},this),this.currentIndexes.sort(d3.ascending),this.fireChangeHandlers())},t.prototype.fireChangeHandlers=function(){this.changeHandlers.forEach(function(t){t(this.currentIndexes.slice(0))},this)},t.prototype.selectAll=function(){this.currentIndexes=d3.range(this.count),this.fireChangeHandlers()},t.prototype.selectNone=function(){this.currentIndexes=[],this.fireChangeHandlers()},t.prototype.getSelectedIndexes=function(){return this.currentIndexes.slice(0)},t.prototype.setSelectedIndexes=function(t){t.every(function(t){return 0<=t&&t<this.count},this)&&(this.currentIndexes=t,this.fireChangeHandlers())},t.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},t.prototype.deregisterChangeHandler=function(t){t=this.changeHandlers.indexOf(t);-1<t&&this.changeHandlers.splice(t,1)},t.prototype.toggle=function(t){var e;typeof t==i?0<=t&&t<this.count?(-1===(e=this.currentIndexes.indexOf(t))?(this.currentIndexes.push(t),this.currentIndexes.sort(d3.ascending)):this.currentIndexes.splice(e,1),this.fireChangeHandlers()):r("Index '"+t+"' is out of range"):r("Index is not a number")},t.prototype.bulkSelect=function(t){t.some(function(t){return typeof t!=i||t<0||t>=this.count},this)&&r("Indexes not all numeric and in range");var e=d3.set(this.currentIndexes);0<(t=t.filter(function(t){return!e.has(t)})).length&&(this.currentIndexes=this.currentIndexes.concat(t),this.currentIndexes.sort(d3.ascending),this.fireChangeHandlers())},t.prototype.bulkDeselect=function(t){t.some(function(t){return typeof t!=i||t<0||t>=this.count},this)&&r("Indexes not all numeric and in range");for(var e=d3.set(this.currentIndexes),s=!1,n=0;n<t.length;n+=1)e.has(t[n])&&(e.remove(t[n]),s=!0);s&&(this.currentIndexes=e.values().map(function(t){return parseInt(t,10)}),this.currentIndexes.sort(d3.ascending),this.fireChangeHandlers())},t.prototype.migrate=function(e,t){$.isArray(e)?$.isArray(t)?e.length!==this.count?r("ResultSelection.migrate: oldResults list must have the same length as the current count"):0===t.length&&0<this.currentIndexes.length&&r("ResultSelection.migrate: newResults list must not be empty if current list has results selected"):r("ResultSelection.migrate: newResults not an array"):r("ResultSelection.migrate: oldResults not an array");var s=this.currentIndexes.map(function(t){return e[t]});this.count=t.length,this.currentIndexes=[],t.forEach(function(t,e){0<=s.indexOf(t)&&this.currentIndexes.push(e)},this)},SplitsBrowser.Model.ResultSelection=t}(),function(){"use strict";function s(t){this.madeAnyChanges=!1,this.permitZeroSplits=t}var a=SplitsBrowser.isNotNullNorNaN,i=SplitsBrowser.throwInvalidData;s.prototype.getFirstNonAscendingIndexes=function(t){0!==t.length&&0===t[0]||i("cumulative times array does not start with a zero cumulative time");for(var e=0,s=1;s<t.length;s+=1){var n=t[s];if(a(n)){if(n<t[e]||n===t[e]&&(!this.permitZeroSplits||e<s-1))return{first:e,second:s};e=s}}return null},s.prototype.removeCumulativeTimesCausingNegativeSplits=function(t){for(var e=this.getFirstNonAscendingIndexes(t);null!==e&&e.second+1<t.length;){for(var s=e.first,n=e.second,i=!1,r=1;r<=3;r+=1){var o=t.slice();if(3!==r||1!==s&&a(t[s-1])){1===r?o[n]=NaN:2===r&&0<s?o[s]=NaN:3===r&&1<s&&(o[s]=NaN,o[s-1]=NaN);var l=this.getFirstNonAscendingIndexes(o);if(null===l||l.first>n){t=o,this.madeAnyChanges=i=!0,e=l;break}}}if(!i)break}return t},s.prototype.removeFinishTimeIfAbsurd=function(t){var e=t[t.length-1],s=t[t.length-2];a(e)&&a(s)&&e<=s-300&&(t[t.length-1]=NaN,this.madeAnyChanges=!0)},s.prototype.repairResult=function(t){var e=t.originalCumTimes.slice(0),e=this.removeCumulativeTimesCausingNegativeSplits(e);t.completed()||this.removeFinishTimeIfAbsurd(e),t.setRepairedCumulativeTimes(e)},s.prototype.repairCourseClass=function(t){this.madeAnyChanges=!1,t.results.forEach(function(t){this.repairResult(t)},this),this.madeAnyChanges&&t.recordHasDubiousData()},s.prototype.repairEventData=function(t){t.classes.forEach(function(t){this.repairCourseClass(t)},this)},SplitsBrowser.DataRepair={repairEventData:function(t,e){new s(e).repairEventData(t)},transferResultData:function(t){t.classes.forEach(function(t){t.results.forEach(function(t){t.setRepairedCumulativeTimes(t.getAllOriginalCumulativeTimes())})})}}}(),function(){"use strict";var r=SplitsBrowser.isTrue,n=SplitsBrowser.isNotNull,o=SplitsBrowser.throwInvalidData,l=SplitsBrowser.throwWrongFileFormat,
a=SplitsBrowser.normaliseLineEndings,f=SplitsBrowser.parseTime,g=SplitsBrowser.Model.Result.fromCumTimes,C=SplitsBrowser.Model.Competitor,i=SplitsBrowser.Model.compareResults,u=SplitsBrowser.Model.CourseClass,h=SplitsBrowser.Model.Course,c=SplitsBrowser.Model.Event;function p(t,p){var t=t.split(/\r?\n/).filter(r),e=(0===t.length&&o("parseCourseClass got an empty list of lines"),t.shift().split(","));if(2===e.length){var d=e.shift(),s=e.shift(),m=parseInt(s,10);if(isNaN(m))o("Could not read control count: '"+s+"'");else{if(!(m<0&&0<t.length))return(s=t.map(function(t,e){for(var s=m,n=d,i=p,r=(t=t).split(",");r.length>s+5&&r[3].match(/[^0-9.,:-]/);)r[2]+=","+r[3],r.splice(3,1);var o,l,a,u,h,t=r.length,c=((r.shift()||"")+" "+(r.shift()||"")).trim()||"<name unknown>";return t===s+5?(o=r.shift(),u=r.shift(),0===(h=f(u))?h=null:u.match(/^\d{1,10}:\d\d:\d\d$/)||(h*=60),l=[0],a=0,r.map(function(t){t=f(t);null!==t&&0<t?(a+=t,l.push(a)):l.push(null)}),u=g(e+1,h,l,new C(c,o)),0===a&&u.setNonStarter(),u):(i.push("Competitor '"+c+"' appears to have the wrong number of split times - "+((h=t-(s+5))<0?-h+" too few":h+" too many")+" (row "+(e+1)+" of class '"+n+"')"),null)}).filter(n)).sort(i),new u(d,m,s);o("Expected a non-negative control count, got "+m+" instead")}}else l("Expected first line to have two parts (class name and number of controls), got "+e.length+" part(s) instead")}SplitsBrowser.Input.CSV={parseEventData:function(t){/<html/i.test(t)&&l("Cannot parse this file as CSV as it appears to be HTML");var t=(t=(t=a(t)).replace(/,{1,100}\n/g,"\n").replace(/,{1,100}$/,"")).split(/\n\n/).map(function(t){return t.trim()}).filter(r),e=[],s=t.map(function(t){return p(t,e)});0===(s=s.filter(function(t){return!t.isEmpty()})).length&&o("No competitor data was found");for(var n=s.map(function(t){return new h(t.name,[t],null,null,null)}),i=0;i<s.length;i+=1)s[i].setCourse(n[i]);return new c(s,n,e)}}}(),function(){"use strict";var n=SplitsBrowser.throwInvalidData,i=SplitsBrowser.throwWrongFileFormat,a=SplitsBrowser.isNaNStrict,u=SplitsBrowser.hasProperty,r=SplitsBrowser.parseCourseLength,o=SplitsBrowser.parseCourseClimb,e=SplitsBrowser.normaliseLineEndings,h=SplitsBrowser.parseTime,c=SplitsBrowser.Model.Result.fromOriginalCumTimes,p=SplitsBrowser.Model.Competitor,s=SplitsBrowser.Model.CourseClass,C=SplitsBrowser.Model.Course,l=SplitsBrowser.Model.Event,d=[";",",","\t","\\"],m={};[44,46,60].forEach(function(t){m[t]={course:t-7,distance:t-6,climb:t-5,controlCount:t-4,placing:t-3,startPunch:t-2,finish:t-1,control1:t}}),[44,46].forEach(function(t){m[t].nonCompetitive=t-38,m[t].startTime=t-37,m[t].time=t-35,m[t].classifier=t-34,m[t].club=t-31,m[t].className=t-28}),m[44].combinedName=3,m[44].yearOfBirth=4,m[46].forename=4,m[46].surname=3,m[46].yearOfBirth=5,m[46].gender=6,m[60].forename=6,m[60].surname=5,m[60].yearOfBirth=7,m[60].gender=8,m[60].combinedName=3,m[60].nonCompetitive=10,m[60].startTime=11,m[60].time=13,m[60].classifier=14,m[60].club=20,m[60].className=26,m[60].classNameFallback=m[60].course,m[60].clubFallback=18;function f(t){return t='"'===t[0]&&'"'===t[t.length-1]?t.substring(1,t.length-1).replace(/""/g,'"').trim():t}function g(t){this.data=e(t),this.classes=d3.map(),this.courseDetails=d3.map(),this.classCoursePairs=[],this.columnIndexes=null,this.warnings=[]}g.prototype.identifyDelimiter=function(){this.lines.length<=1&&i("No data found to read");for(var t=this.lines[1],e=0;e<d.length;e+=1){var s=d[e];if(37<t.split(s).length)return s}i("Data appears not to be in the OE CSV format")},g.prototype.identifyFormatVariation=function(t){var e=this.lines[1].split(t),s=/^[A-Za-z0-9]{1,10}$/;for(n in m)if(u(m,n)){var n=parseInt(n,10);if(n<e.length&&s.test(e[n])&&(""===e[n-2].trim()||null!==h(e[n-2]))&&(""===e[n-1].trim()||null!==h(e[n-1])))if(""!==e[m[n].controlCount].trim())return void(this.columnIndexes=m[n])}i("Did not find control 1 at any of the supported indexes")},g.prototype.getClassName=function(t){var e=t[this.columnIndexes.className];return e=""===e&&u(this.columnIndexes,"classNameFallback")?t[this.columnIndexes.classNameFallback]:e},g.prototype.getStartTime=function(t){var e=t[this.columnIndexes.startPunch];return""===e&&(e=t[this.columnIndexes.startTime]),h(e)},g.prototype.getNumControls=function(t,e){var s,n=this.getClassName(t);return""===n.trim()?(s=this.getName(t)||"<name unknown>",this.warnings.push("Could not find a class for competitor '"+s+"' (line "+e+")"),null):this.classes.has(n)?this.classes.get(n).numControls:(n=parseInt(t[this.columnIndexes.controlCount],10),isFinite(n)?n:(s=this.getName(t)||"<name unknown>",this.warnings.push("Could not read the control count '"+t[this.columnIndexes.controlCount]+"' for competitor '"+s+"' from line "+e),null))},g.prototype.readCumulativeTimes=function(t,e,s){for(var n=[0],i=0;i<s;i+=1){var r=this.columnIndexes.control1+1+2*i,r=r<t.length?t[r]:null,r=null===r?null:h(r);n.push(r)}var o,l,a=h(t[this.columnIndexes.time]);return null===a&&(o=this.getStartTime(t),l=h(t[this.columnIndexes.finish]),null!==o&&null!==l&&(a=l-o)),n.push(a),n},g.prototype.createClassIfNecessary=function(t,e){t=this.getClassName(t);this.classes.has(t)||this.classes.set(t,{numControls:e,results:[]})},g.prototype.createCourseIfNecessary=function(e,t){var s=e[this.columnIndexes.course];this.courseDetails.has(s)||(t=d3.range(0,t).map(function(t){return e[this.columnIndexes.control1+2*t]},this),this.courseDetails.set(s,{length:r(e[this.columnIndexes.distance]),climb:o(e[this.columnIndexes.climb]),controls:t}))},g.prototype.createClassCoursePairIfNecessary=function(t){var e=this.getClassName(t),s=t[this.columnIndexes.course];this.classCoursePairs.some(function(t){return t[0]===e&&t[1]===s})||this.classCoursePairs.push([e,s])},g.prototype.getName=function(t){var e="";return e=""===(e=u(this.columnIndexes,"forename")&&u(this.columnIndexes,"surname")?(t[this.columnIndexes.forename]+" "+t[this.columnIndexes.surname]).trim():e)&&u(this.columnIndexes,"combinedName")?t[this.columnIndexes.combinedName]:e},g.prototype.addCompetitor=function(t,e){var s=this.getClassName(t),n=t[this.columnIndexes.placing],i=t[this.columnIndexes.club],r=(""===i&&u(this.columnIndexes,"clubFallback")&&(i=t[this.columnIndexes.clubFallback]),this.getStartTime(t)),o=this.getName(t),l=""!==n&&a(parseInt(n,10)),n=(l&&o.substring(o.length-n.length)===n&&(o=o.substring(0,o.length-n.length).trim()),this.classes.get(s).results.length+1),o=new p(o,i),i=t[this.columnIndexes.yearOfBirth],i=(""!==i&&(i=parseInt(i,10),a(i)||o.setYearOfBirth(i)),!u(this.columnIndexes,"gender")||"M"!==(i=t[this.columnIndexes.gender])&&"F"!==i||o.setGender(i),c(n,r,e,o)),n=(("1"===t[this.columnIndexes.nonCompetitive]||l)&&i.completed()&&i.setNonCompetitive(),t[this.columnIndexes.classifier]);""!==n?"0"===n&&0<=e.indexOf(null)&&null!==e[e.length-1]?i.setOKDespiteMissingTimes():"1"===n?i.setNonStarter():"2"===n?i.setNonFinisher():"4"===n?i.disqualify():"5"===n&&i.setOverMaxTime():i.hasAnyTimes()||i.setNonStarter(),this.classes.get(s).results.push(i)},g.prototype.readLine=function(t,e,s){""!==t.trim()&&((t=t.split(s).map(function(t){return t.trim()}).map(f)).length<37&&n("Too few items on line "+e+" of the input file: expected at least 37, got "+t.length),null!==(s=this.getNumControls(t,e))&&(e=this.readCumulativeTimes(t,e,s),this.createClassIfNecessary(t,s),this.createCourseIfNecessary(t,s),this.createClassCoursePairIfNecessary(t),this.addCompetitor(t,e)))},g.prototype.getMapsBetweenClassesAndCourses=function(){var s=d3.map(),n=d3.map();return this.classCoursePairs.forEach(function(t){var e=t[0],t=t[1];s.has(e)?s.get(e).push(t):s.set(e,[t]),n.has(t)?n.get(t).push(e):n.set(t,[e])}),{classesToCourses:s,coursesToClasses:n}},g.prototype.createClasses=function(){var t=this.classes.keys();return t.sort(),t.map(function(t){var e=this.classes.get(t);return new s(t,e.numControls,e.results)},this)},g.prototype.createCourseFromLinkedClassesAndCourses=function(t,e,s,n){for(var i=[t],r=[],o=[],l=[];0<i.length||0<r.length;){for(;0<i.length;){for(var a=i.shift(),u=e.coursesToClasses.get(a),h=0;h<u.length;h+=1)c=u[h],r.indexOf(c)<0&&l.indexOf(c)<0&&r.push(c);o.push(a)}for(;0<r.length;){for(var c=r.shift(),p=e.classesToCourses.get(c),d=0;d<p.length;d+=1)a=p[d],i.indexOf(a)<0&&o.indexOf(a)<0&&i.push(a);l.push(c)}}o.forEach(function(t){s.add(t)});var m=l.map(function(t){return n.get(t)}),f=this.courseDetails.get(t),g=new C(t,m,f.length,f.climb,f.controls);return m.forEach(function(t){t.setCourse(g)}),g},g.prototype.determineCourses=function(t){var e=this.getMapsBetweenClassesAndCourses(),s=d3.set(),n=d3.map(),i=(t.forEach(function(t){n.set(t.name,t)}),[]);return e.coursesToClasses.keys().forEach(function(t){s.has(t)||(t=this.createCourseFromLinkedClassesAndCourses(t,e,s,n),i.push(t))},this),i},g.prototype.parseEventData=function(){this.warnings=[],this.lines=this.data.split(/\n/);var s=this.identifyDelimiter(),t=(this.identifyFormatVariation(s),this.lines.shift(),this.lines.forEach(function(t,e){this.readLine(t,e+1,s)},this),this.createClasses()),e=(0===t.length&&0<this.warnings.length&&i("This file may have looked vaguely like an OE CSV file but no data could be read out of it"),this.determineCourses(t));return new l(t,e,this.warnings)},SplitsBrowser.Input.OE={},SplitsBrowser.Input.OE.parseEventData=function(t){return new g(t).parseEventData()}}(),function(){"use strict";var a=SplitsBrowser.isNotNull,h=SplitsBrowser.throwInvalidData,n=SplitsBrowser.throwWrongFileFormat,e=SplitsBrowser.parseCourseLength,i=SplitsBrowser.normaliseLineEndings,c=SplitsBrowser.parseTime,s=SplitsBrowser.Model.Result.fromOriginalCumTimes,r=SplitsBrowser.Model.Competitor,u=SplitsBrowser.Model.CourseClass,p=SplitsBrowser.Model.Course,d=SplitsBrowser.Model.Event,o=/<[^>]{1,200}>/g,l=/([0-9.,]{1,10})\s{0,10}(?:Km|km)/,m=/(\d{1,10})\s{0,10}(?:Cm|Hm|hm|m)/;function f(t){return null!==t&&""!==t}function g(t){return""!==(t=t.trim())&&isFinite(t)}function C(t){return t.split(/\s+/g).filter(f)}function S(t){return t.replace(o,"")}function v(t,e){for(var s,n=[];null!==(s=t.exec(e));)n.push(S(s[1]));return n}function y(t){return v(/<font[^>]{0,100}>(.{0,100}?)<\/font>/g,t)}function T(t){return v(/<td[^>]{0,100}>(.{0,100}?)<\/td>/g,t).map(function(t){return t.trim()})}function x(t){return T(t).filter(function(t){return""!==t})}function w(t){t=l.exec(t);return null===t?null:e(t[1])}function b(t){t=m.exec(t);return null===t?null:parseInt(t[1],10)}function L(t){for(var e=[],s=0;s<t.length;s+=1){var n=t[s],i=n.indexOf("(");-1<i&&")"===n[n.length-1]?(i=n.substring(i+1,n.length-1),e.push(i)):s+1===t.length?e.push(null):h("Unrecognised control header label: '"+n+"'")}return e}function D(t,e){for(;0<e.length&&"*"===e[e.length-1][0];)e.splice(e.length-1,1),t.splice(t.length-1,1)}function R(t,e,s,n,i,r){this.name=t,this.club=e,this.className=s,this.totalTime=n,this.cumTimes=i,this.competitive=r}R.prototype.isContinuation=function(){return""===this.name&&""===this.club&&null===this.className&&""===this.totalTime&&!this.competitive},R.prototype.append=function(t){if(!t.isContinuation())throw new Error("Can only append a continuation CompetitorParseRecord");this.cumTimes=this.cumTimes.concat(t.cumTimes)},R.prototype.toResult=function(t){var e=[0].concat(this.cumTimes),t=s(t,null,e,new r(this.name,this.club));return t.completed()&&!this.competitive&&t.setNonCompetitive(),t.hasAnyTimes()||t.setNonStarter(),t};function t(){this.precedingColumnCount=null}function I(){this.timesOffset=null}function N(){this.usesClasses=!1}t.prototype.isTextOfThisFormat=function(t){return 0<=t.indexOf("<pre>")&&0<=t.indexOf("<font")},t.prototype.preprocess=function(t){var e=t.indexOf("<pre>");if(-1===e)throw new Error("Cannot find opening pre tag");var e=t.indexOf("\n",e),s=(t=(t=t.substring(e+1)).replace(/\n{2,}/g,"\n")).lastIndexOf("</pre>");return-1===s&&h("Found opening <pre> but no closing </pre>"),e=t.lastIndexOf("\n",s),(t=t.substring(0,e)).trim()},t.prototype.canIgnoreThisLine=function(t){return""===t},t.prototype.isCourseHeaderLine=function(t){return 2===y(t).length},t.prototype.parseCourseHeaderLine=function(t){t=y(t);if(2!==t.length)throw new Error("Course header line should have two parts");var e=t[0],t=t[1],s=e.indexOf("("),s=-1<s?e.substring(0,s):e,e=w(t),t=b(t);return{name:s.trim(),distance:e,climb:t}},t.prototype.parseControlsLine=function(t){var e=t.lastIndexOf("</font>");return L(C((-1===e?t:t.substring(e+"</font>".length)).trim()))},t.prototype.readCompetitorSplitDataLine=function(t){for(var e=0;e<this.precedingColumnCount;e+=1){var s=t.indexOf("</font>");t=t.substring(s+"</font>".length)}return C(S(t))},t.prototype.parseCompetitor=function(t,e){var s=y(t),n=y(e),i=(null===this.precedingColumnCount&&(i=s[1].trim(),this.precedingColumnCount=i.match(/^\d{0,10}$/)?4:3),g(s[0])),r=s[this.precedingColumnCount-2].trim(),s=s[this.precedingColumnCount-1].trim(),n=n[this.precedingColumnCount-2].trim(),o=this.readCompetitorSplitDataLine(t),e=this.readCompetitorSplitDataLine(e),e=(D(o=o.map(c),e),null);if(null!==r&&""!==r){for(var l=-1,a=0;a<this.precedingColumnCount;a+=1)l=t.indexOf("</font>",l+1);var u=C(t.substring(0,l+"</font>".length).replace(/<font[^>]{0,100}>(.{0,100}?)<\/font>/g,""));0<u.length&&(e=u[0])}return new R(r,n,e,s,o,i)},I.prototype.isTextOfThisFormat=function(t){for(var e=-1,s=0;s<5;s+=1)if(-1===(e=t.indexOf("<table",e+1)))return!1;return!0},I.prototype.preprocess=function(t){var e=t.indexOf("</table>"),e=(-1===e&&h("Could not find any closing </table> tags"),(t=t.substring(e+"</table>".length)).indexOf("</div>")),s=t.indexOf("<table"),s=(t=(t=(t=(t=(t=-1<e&&e<s?t.substring(e+"</div>".length):t).replace(/>\n{1,100}</g,"><").replace(/><tr>/g,">\n<tr>").replace(/<\/tr></g,"</tr>\n<").replace(/><table/g,">\n<table").replace(/<\/table></g,"</table>\n<")).replace(/<\/col[^>]{0,100}>/g,"")).replace(/<tr[^>]{0,100}><td[^>]{0,100}>(?:<nobr>)? ?(?:<\/nobr>)?<\/td><\/tr>/g,"")).replace(/<a id="[^"]{0,100}"><\/a>/g,"")).indexOf('<div id="navigation">');return 0<=s&&(0<=(e=t.indexOf("</div>",s))&&(t=t.substring(0,s)+t.substring(e+6))),(t=t.replace("</body></html>","")).trim()},I.prototype.canIgnoreThisLine=function(t){var e;return-1<t.indexOf("<th>")?(e=v(/<th[^>]{0,100}>(.{0,100}?)<\/th>/g,t).filter(function(t){return""!==t}),this.timesOffset=e.length,!0):""===t||-1<t.indexOf("<table")||-1<t.indexOf("</table>")},I.prototype.isCourseHeaderLine=function(t){return-1<t.indexOf('<td id="header"')},I.prototype.parseCourseHeaderLine=function(t){for(var e=x(t),t=(0===e.length&&h("No parts found in course header line"),e[0]),s=t.indexOf("("),n=(t=(t=-1<s?t.substring(0,s):t).trim(),null),i=null,r=1;r<e.length;r+=1)null===n&&(n=w(e[r])),null===i&&(i=b(e[r]));return{name:t,distance:n,climb:i}},I.prototype.parseControlsLine=function(t){return L(x(t))},I.prototype.readCompetitorSplitDataLine=function(t){for(var e=T(t),t=this.timesOffset,s=e.length;0<s&&""===e[s-1];)--s;return e.slice(t,s).filter(f)},I.prototype.parseCompetitor=function(t,e){var s=T(t),n=T(e),i=g(s[0]),r=3===this.timesOffset?1:2,o=s[r],l=s[this.timesOffset-1],n=n[r],r=5===this.timesOffset&&""!==o?s[3]:null,s=this.readCompetitorSplitDataLine(t),t=this.readCompetitorSplitDataLine(e),e=(D(s=s.map(c),t),s.filter(a).length);return e!==t.length&&h("Cumulative and split times do not have the same length: "+e+" cumulative times, "+t.length+" split times"),new R(o,n,r,l,s,i)};function O(t,e,s){this.name=t,this.distance=e,this.climb=s,this.controls=[],this.competitors=[]}function M(t){this.recognizer=t,this.courses=[],this.currentCourse=null,this.lines=null,this.linePos=-1,this.currentCompetitor=null}N.prototype.isTextOfThisFormat=function(t){var e=t.indexOf("<table");if(0<=e){e=t.indexOf("<table",e+1);if(0<=e)if(t.indexOf("<table",e+1)<0)return!0}return!1},N.prototype.preprocess=function(t){var e=t.indexOf("</table>");return-1===e&&h("Could not find any closing </table> tags"),0<=t.indexOf('<td colspan="25">')&&(this.usesClasses=!0),(t=(t=(t=(t=t.substring(e+"</table>".length)).replace(/<tr[^>]{0,100}><td colspan=[^>]{0,100}> <\/td><\/tr>/g,"")).replace(/\n{2,}/g,"\n")).replace("</body>","").replace("</html>","")).trim()},N.prototype.canIgnoreThisLine=function(t){return""===t||-1<t.indexOf("<table")||-1<t.indexOf("</table>")||-1<t.indexOf("<hr>")},N.prototype.isCourseHeaderLine=function(t){return-1<t.indexOf('<tr class="clubName"')},N.prototype.parseCourseHeaderLine=function(t){var e,s,t=x(t),t=(0===t.length&&h("No parts found in course header line"),t[0]),n=/^(.{0,100}?)\s{1,10}\((\d{1,10})m,\s{0,10}(\d{1,10})m\)$/.exec(t),t=null===n?(e=t,s=null):(e=n[1],s=parseInt(n[2],10)/1e3,parseInt(n[3],10));return{name:e.trim(),distance:s,climb:t}},N.prototype.parseControlsLine=function(t){return x(t).map(function(t){var e=t.indexOf("-");return-1===e?null:t.substring(e+1)})},N.prototype.readCompetitorSplitDataLine=function(t){for(var e=this.usesClasses?5:4,s=t.length;0<s&&""===t[s-1];)--s;for(var n=[],i=e;i<s;i+=2){var r=t[i];f(r)&&n.push(r)}return n},N.prototype.parseCompetitor=function(t,e){for(var s=T(t),n=T(e),t=g(s[0]),e=s[2],i=s[this.usesClasses?4:3],r=this.usesClasses&&""!==e?s[3]:null,o=n[2],l=this.usesClasses?5:4;l<s.length&&l<n.length;l+=2)""!==s[l]&&""===n[l]&&(n[l]="----");var a=this.readCompetitorSplitDataLine(s),u=this.readCompetitorSplitDataLine(n);return D(a=a.map(c),u),a.length!==u.length&&h("Cumulative and split times do not have the same length: "+a.length+" cumulative times, "+u.length+" split times"),new R(e,o,r,i,a,t)},O.prototype.addControls=function(t){this.controls=this.controls.concat(t)},O.prototype.hasAllControls=function(){return 0<this.controls.length&&null===this.controls[this.controls.length-1]},O.prototype.addCompetitor=function(t){if(t.competitive||t.cumTimes.length!==this.controls.length-1||t.cumTimes.push(null),null===c(t.totalTime)&&0===t.cumTimes.length)for(;t.cumTimes.length<this.controls.length;)t.cumTimes.push(null);t.cumTimes.length===this.controls.length?this.competitors.push(t):h("Competitor '"+t.name+"' should have "+this.controls.length+" cumulative times, but has "+t.cumTimes.length+" times")},M.prototype.tryGetLine=function(){return this.linePos+1<this.lines.length?(this.linePos+=1,this.lines[this.linePos]):null},M.prototype.addCurrentCompetitorIfNecessary=function(){null!==this.currentCompetitor&&(this.currentCourse.addCompetitor(this.currentCompetitor),this.currentCompetitor=null)},M.prototype.addCurrentCompetitorAndCourseIfNecessary=function(){this.addCurrentCompetitorIfNecessary(),null!==this.currentCourse&&this.courses.push(this.currentCourse)},M.prototype.readCompetitorLines=function(t){var e=this.tryGetLine(),t=(null===e&&h("Hit end of input data unexpectedly while parsing competitor: first line was '"+t+"'"),this.recognizer.parseCompetitor(t,e));t.isContinuation()?null===this.currentCompetitor?h("First row of competitor data has no name nor time"):this.currentCompetitor.append(t):(this.addCurrentCompetitorIfNecessary(),this.currentCompetitor=t)},M.prototype.areClassesUniqueWithinCourses=function(){for(var t=d3.map(),e=0;e<this.courses.length;e+=1)for(var s=this.courses[e],n=0;n<s.competitors.length;n+=1){var i=s.competitors[n];if(t.has(i.className)){if(t.get(i.className)!==s.name)return!1}else t.set(i.className,s.name)}return!0},M.prototype.createOverallEventObject=function(){var s=this.areClassesUniqueWithinCourses(),t=[],o=[],l=this.courses.every(function(t){return t.competitors.every(function(t){return a(t.className)})});return this.courses.forEach(function(n){var i=d3.map(),r=(n.competitors.forEach(function(t){var e=l&&s?t.className:n.name;i.has(e)?i.get(e).push(t):i.set(e,[t])}),[]),e=(i.keys().forEach(function(t){var e=n.controls.length-1,s=i.get(t).map(function(t,e){return t.toResult(e+1)}),t=new u(t,e,s);r.push(t),o.push(t)},this),new p(n.name,r,n.distance,n.climb,n.controls.slice(0,n.controls.length-1)));t.push(e),r.forEach(function(t){t.setCourse(e)})},this),new d(o,t,[])},M.prototype.parse=function(t){for(this.lines=t.split("\n");;){var e,s=this.tryGetLine();if(null===s)break;this.recognizer.canIgnoreThisLine(s)||(this.recognizer.isCourseHeaderLine(s)?(this.addCurrentCompetitorAndCourseIfNecessary(),e=this.recognizer.parseCourseHeaderLine(s),this.currentCourse=new O(e.name,e.distance,e.climb)):null!==this.currentCourse&&(this.currentCourse.hasAllControls()?this.readCompetitorLines(s):(e=this.recognizer.parseControlsLine(s),this.currentCourse.addControls(e))))}return this.addCurrentCompetitorAndCourseIfNecessary(),0===this.courses.length&&h("No competitor data was found"),this.createOverallEventObject()};var B=[t,I,N];SplitsBrowser.Input.Html={},SplitsBrowser.Input.Html.parseEventData=function(t){t=i(t);for(var e=0;e<B.length;e+=1){var s=new B[e];if(s.isTextOfThisFormat(t))return t=s.preprocess(t),new M(s).parse(t)}n("No HTML recognizers recognised this as HTML they could parse")}}(),function(){"use strict";var n=SplitsBrowser.throwWrongFileFormat,i=SplitsBrowser.normaliseLineEndings,a=SplitsBrowser.parseTime,l=SplitsBrowser.parseCourseLength,u=SplitsBrowser.parseCourseClimb,h=SplitsBrowser.Model.Result.fromOriginalCumTimes,c=SplitsBrowser.Model.Competitor,o=SplitsBrowser.Model.CourseClass,p=SplitsBrowser.Model.Course,r=SplitsBrowser.Model.Event,e={controlsOffset:38,step:3,name:3,club:5,courseName:7,startTime:8,length:null,climb:null,placing:null,finishTime:null,allowMultipleCompetitorNames:!0},d=[",",";"],m=/^[A-Za-z0-9]{1,10}$/;function f(t){for(var e=t.length-1;0<=e&&""===t[e];)--e;t.splice(e+1,t.length-e-1)}function s(t){this.format=t,this.classes=d3.map(),this.delimiter=null,this.hasAnyStarters=!1,this.warnings=[],this.controlsTerminationOffset=null===t.finishTime?t.step:0}s.prototype.determineDelimiter=function(t){for(var e=0;e<d.length;e+=1){var s=d[e],n=t.split(s);if(f(n),n.length>this.format.controlsOffset)return s}return null},s.prototype.adjustLinePartsForMultipleCompetitors=function(t){if(this.format.allowMultipleCompetitorNames)for(;t.length>this.format.name+1&&t[this.format.name+1].match(/^\s\S/);)t[this.format.name]+=","+t[this.format.name+1],t.splice(this.format.name+1,1)},s.prototype.checkControlCodesAlphaNumeric=function(t){var e=t.split(this.delimiter);f(e),this.adjustLinePartsForMultipleCompetitors(e,this.format);for(var s=this.format.controlsOffset;s+this.controlsTerminationOffset<e.length;s+=this.format.step)m.test(e[s])||n("Data appears not to be in an alternative CSV format - data in cell "+s+" of the first row ('"+e[s]+"') is not an number")},s.prototype.addResultToCourse=function(t,e,s){if(this.classes.has(e)){var n=this.classes.get(e),i=t.getAllOriginalCumulativeTimes();i.length-1!==n.controls.length+1?this.warnings.push("Competitor '"+t.owner.name+"' has the wrong number of splits for course '"+e+"': expected "+(n.controls.length+1)+", actual "+(i.length-1)):n.results.push(t)}else{for(var r=[],o=this.format.controlsOffset;o+this.controlsTerminationOffset<s.length;o+=this.format.step)r.push(s[o]);i=null===this.format.length?null:l(s[this.format.length]),n=null===this.format.climb?null:u(s[this.format.climb]);this.classes.set(e,{length:i,climb:n,controls:r,results:[t]})}},s.prototype.readDataRow=function(t){var e=t.split(this.delimiter);if(f(e),this.adjustLinePartsForMultipleCompetitors(e),!(e.length<this.format.controlsOffset)){for(;(e.length-this.format.controlsOffset)%this.format.step!=0;)e.push("");for(var s,t=e[this.format.name],n=e[this.format.club],i=e[this.format.courseName],r=a(e[this.format.startTime]),o=[0],l=this.format.controlsOffset+1;l<e.length;l+=this.format.step)o.push(a(e[l]));null!==this.format.finishTime&&(s=a(e[this.format.finishTime]),o.push(null===r||null===s?null:s-r)),1===o.length?""!==t&&this.warnings.push("Competitor '"+t+"' on course '"+(""===i?"(unnamed)":i)+"' has no times recorded"):(s=this.classes.has(i)?this.classes.get(i).results.length+1:1,s=h(s,r,o,new c(t,n)),null!==this.format.placing&&s.completed()&&!e[this.format.placing].match(/^\d{1,10}$/)&&s.setNonCompetitive(),s.hasAnyTimes()?this.hasAnyStarters=!0:s.setNonStarter(),this.addResultToCourse(s,i,e))}},s.prototype.createClassesAndCourses=function(){var i=[],r=d3.map(),s=(this.classes.entries().forEach(function(t){var e=t.key,t=t.value,s=new o(e,t.controls.length,t.results),n=(i.push(s),t.controls.join(","));r.has(n)?r.get(n).classes.push(s):r.set(n,{name:e,classes:[s],length:t.length,climb:t.climb,controls:t.controls})}),[]);return r.values().forEach(function(t){var e=new p(t.name,t.classes,t.length,t.climb,t.controls);t.classes.forEach(function(t){t.setCourse(e)}),s.push(e)}),{classes:i,courses:s}},s.prototype.parseEventData=function(t){this.warnings=[];var e=(t=i(t)).split(/\n/),t=(e.length<2&&n("Data appears not to be in an alternative CSV format - too few lines"),e[1]);this.delimiter=this.determineDelimiter(t),null===this.delimiter&&n("Data appears not to be in an alternative CSV format - first data line has fewer than "+this.format.controlsOffset+" parts when separated by any recognised delimiter"),this.checkControlCodesAlphaNumeric(t);for(var s=1;s<e.length;s+=1)this.readDataRow(e[s]);t=this.createClassesAndCourses();return this.hasAnyStarters||n("Data appears not to be in an alternative CSV format - data apparently could be read but everyone was a non-starter"),new r(t.classes,t.courses,this.warnings)},SplitsBrowser.Input.AlternativeCSV={parseTripleColumnEventData:function(t){return new s(e).parseEventData(t)}}}(),function(){"use strict";var I=SplitsBrowser.throwInvalidData,i=SplitsBrowser.throwWrongFileFormat,N=SplitsBrowser.COMMON_CONTROLS_MODE,O=SplitsBrowser.determineCommonControls,o=SplitsBrowser.isNaNStrict,s=SplitsBrowser.parseTime,c=SplitsBrowser.Model.Result.fromOriginalCumTimes,M=SplitsBrowser.Model.Result.createTeamResult,p=SplitsBrowser.Model.Competitor,B=SplitsBrowser.Model.Team,d=SplitsBrowser.Model.CourseClass,A=SplitsBrowser.Model.Course,m=SplitsBrowser.Model.Event;function r(t){return void 0===t}var f=/^\d{4}/,t={isOfThisVersion:function(t){return 0<=t.indexOf("IOFdata.dtd")},checkVersion:function(t){var e=$("> IOFVersion",t),e=(0===e.length?i("Could not find IOFVersion element"):r(e=e.attr("version"))?i("Version attribute missing from IOFVersion element"):"2.0.3"!==e&&i("Found unrecognised IOF XML data format '"+e+"'"),t.attr("status"));r(e)||"complete"===e.toLowerCase()||I("Only complete IOF data supported; snapshot and delta are not supported")},readClassName:function(t){return $("> ClassShortName",t).text()},readTeamName:function(t){return $("> TeamName",t).text()},readTeamMemberResults:function(t){return $("> PersonResult",t)},readCourseFromClass:function(t,e){var s,n=$("> ClassShortName",t).text(),t=$("> PersonResult > Result",t).first(),i=null;return 0<t.length&&(0<(s=(t=$("> CourseLength",t)).text()).length&&(i=parseFloat(s),isFinite(i)?r(t=t.attr("unit"))||"m"===t?i/=1e3:"km"!==t&&("ft"===t?i/=3280:(e.push("Course '"+n+"' gives its length in a unit '"+t+"', but this unit was not recognised"),i=null)):(e.push("Course '"+n+"' specifies a course length that was not understood: '"+s+"'"),i=null))),{id:null,name:n,length:i,climb:null,numberOfControls:null}},getCompetitorNameElement:function(t){return $("> Person > PersonName",t)},readClubName:function(t){var e=$("> Club > ShortName",t).text();return""===e?$("> Club > Name",t).text():e},readDateOfBirth:function(t){return $("> Person > BirthDate > Date",t).text()},readStartTime:function(t){t=$("> StartTime > Clock",t).text();return""===t?null:s(t)},readTotalTime:function(t){t=$("> Time",t).text();return""===t?null:s(t)},getStatus:function(t){t=$("> CompetitorStatus",t);return 1===t.length?t.attr("value"):""},StatusNonCompetitive:"NotCompeting",StatusNonStarter:"DidNotStart",StatusNonFinisher:"DidNotFinish",StatusDisqualified:"Disqualified",StatusOverMaxTime:"OverTime",isAdditional:function(){return!1},readSplitTime:function(t){var e=$("> ControlCode",t).text(),t=(""===(e=""===e?$("> Control > ControlCode",t).text():e)&&I("Control code missing for control"),$("> Time",t).text());return{code:e,time:""===t?null:s(t)}}},e=/^\d\d\d\d-?\d\d-?\d\dT?(\d\d):?(\d\d)(?::?(\d\d))?/,n={isOfThisVersion:function(t){return 0<=t.indexOf("http://www.orienteering.org/datastandard/3.0")},checkVersion:function(t){var e=t.attr("iofVersion"),e=(r(e)?i("Could not find IOF version number"):"3.0"!==e&&i("Found unrecognised IOF XML data format '"+e+"'"),t.attr("status"));r(e)||"complete"===e.toLowerCase()||I("Only complete IOF data supported; snapshot and delta are not supported")},readClassName:function(t){return $("> Class > Name",t).text()},readTeamName:function(t){return $("> Name",t).text()},readTeamMemberResults:function(t){return $("> TeamMemberResult",t)},readCourseFromClass:function(t,e){var s,t=$("> Course",t),n=$("> Id",t).text()||null,i=$("> Name",t).text(),r=$("> Length",t).text(),e=(""===r?s=null:(s=parseInt(r,10),o(s)?(e.push("Course '"+i+"' specifies a course length that was not understood: '"+r+"'"),s=null):s/=1e3),$("> NumberOfControls",t).text()),r=parseInt(e,10),e=(o(r)&&(r=null),$("> Climb",t).text()),t=parseInt(e,10);return{id:n,name:i,length:s,climb:t=o(t)?null:t,numberOfControls:r}},getCompetitorNameElement:function(t){return $("> Person > Name",t)},readClubName:function(t){var e=$("> Organisation > ShortName",t).text();return""===e?$("> Organisation > Name",t).text():e},readDateOfBirth:function(t){t=$("> Person > BirthDate",t).text(),t=f.exec(t);return null===t?null:parseInt(t[0],10)},readStartTime:function(t){t=$("> StartTime",t).text(),t=e.exec(t);return null===t?null:60*parseInt(t[1],10)*60+60*parseInt(t[2],10)+(r(t[3])?0:parseInt(t[3],10))},readTime:function(t){t=parseFloat(t);return isFinite(t)?t:null},readTotalTime:function(t){t=$("> Time",t).text();return n.readTime(t)},getStatus:function(t){return $("> Status",t).text()},StatusNonCompetitive:"NotCompeting",StatusNonStarter:"DidNotStart",StatusNonFinisher:"DidNotFinish",StatusDisqualified:"Disqualified",StatusOverMaxTime:"OverTime",isAdditional:function(t){return"Additional"===t.attr("status")},readSplitTime:function(t){var e=$("> ControlCode",t).text();return""===e&&I("Control code missing for control"),{code:e,time:"Missing"===t.attr("status")||""===(e=$("> Time",t).text())?null:n.readTime(e)}}},g=[t,n];function F(t,e,s,n){var t=$(t),i=s.getCompetitorNameElement(t),r=(i=i,r=$("> Given",i).text(),i=$("> Family",i).text(),""===r?i:""===i?r:r+" "+i);if(""===r)return n.push("Could not find a name for a competitor"),null;var i=s.readClubName(t),o=s.readDateOfBirth(t),o=f.exec(o),o=null===o?null:parseInt(o[0],10),l=$("> Person",t).attr("sex"),t=$("Result",t);if(0===t.length)return n.push("Could not find any result information for competitor '"+r+"'"),null;var n=s.readStartTime(t),a=s.readTotalTime(t),u=s.getStatus(t),t=$("> SplitTime",t).toArray().filter(function(t){return!s.isAdditional($(t))}).map(function(t){return s.readSplitTime($(t))}),h=t.map(function(t){return t.code}),t=t.map(function(t){return t.time}),r=(t.unshift(0),t.push(u===s.StatusNonStarter?null:a),new p(r,i)),i=(null!==o&&r.setYearOfBirth(o),"M"!==l&&"F"!==l||r.setGender(l),c(e,n,t,r));return"OK"===u&&null!==a&&0<=t.indexOf(null)?i.setOKDespiteMissingTimes():u===s.StatusNonCompetitive?i.setNonCompetitive():u===s.StatusNonStarter?i.setNonStarter():u===s.StatusNonFinisher?i.setNonFinisher():u===s.StatusDisqualified?i.disqualify():u===s.StatusOverMaxTime&&i.setOverMaxTime(),{result:i,controls:h}}function C(t,e,s,n){var t=$(t),i={name:null,results:[],teamSize:null,controls:[],course:null},r=(i.course=e.readCourseFromClass(t,n),e.readClassName(t)),o=(i.name=r=""===r?"<unnamed class>":r,i.course.numbersOfControls=null,$("> PersonResult",t)),l=$("> TeamResult",t);if(0<o.length&&0<l.length)return n.push("Class '"+r+"' has a combination of relay teams and individual results"),null;if(0<o.length)for(var a=0;a<o.length;a+=1){S=C=g=f=m=u=d=p=c=h=u=void 0;var u=o[a],h=a+1,c=i,p=e,d=n;if(null!==(u=F(u,h,p,d))){var m=u.result,f=u.controls,g=(0!==c.results.length||m.isNonStarter&&0===f.length||(c.controls=f,null===c.course.numberOfControls&&(c.course.numberOfControls=c.controls.length)),m.getAllOriginalCumulativeTimes().length-2),C=null;if(!m.isNonStarter||0!=g)if(g!==c.course.numberOfControls)C="Competitor '"+m.owner.name+"' in class '"+c.name+"' has an unexpected number of controls: expected "+c.course.numberOfControls+", actual "+g;else for(var S=0;S<g;S+=1)if(c.controls[S]!==f[S]){C="Competitor '"+m.owner.name+"' has an unexpected control code at control "+(S+1)+": expected '"+c.controls[S]+"', actual '"+f[S]+"'";break}null===C?c.results.push(m):d.push(C)}}else{if(!(0<l.length))return n.push("Class '"+r+"' has no competitors"),null;for(var v=[],y=0;y<l.length;y+=1)!function(t,e,s,n,i,r,o){var l=n.readTeamName(t),a=n.readClubName(t),u=n.readTeamMemberResults(
t);if(0===u.length)r.push("Ignoring team "+(""===l?"(unnamed team)":l)+" with no members");else if(0===s.results.length&&1===u.length)r.push("Ignoring team "+(""===l?"(unnamed team)":l)+" with only a single member");else{for(var h=[],c=[],p=0;p<u.length;p+=1){var d=F(u[p],e,n,r);if(null===d)return;h.push(d.result),c.push(d.controls)}for(p=1;p<u.length;p+=1){var m=$("> Result > FinishTime",u[p-1]).text(),f=$("> Result > StartTime",u[p]).text();if(!h[p].isNonStarter&&m!==f)return r.push("In team "+(""===l?"(unnamed team)":l)+" in class '"+s.name+"', "+h[p-1].owner.name+" does not finish at the same time as "+h[p].owner.name+" starts")}t=c.map(function(t){return t.length});if(0===s.results.length&&(s.teamSize=h.length,null===s.course.numbersOfControls&&(s.course.numbersOfControls=t)),h.length!==s.teamSize)r.push("Team "+(""===l?"(unnamed team)":"'"+l+"'")+" in class '"+s.name+"' has an unexpected number of members: expected "+s.teamSize+" but was actually "+h.length);else{var g=null,t=M(e,h,new B(l,a));if(i!==N)for(var C=0;C<h.length;C+=1){var S=s.course.numbersOfControls[C],v=h[C],y=v.getAllOriginalCumulativeTimes().length-2;if(y!==S){g="Competitor '"+v.owner.name+"' in team '"+l+"' in class '"+s.name+"' has an unexpected number of controls: expected "+S+", actual "+y;break}}null===g?(s.results.push(t),i===N&&o.push(c)):r.push(g)}}}(l[y],y+1,i,e,s,n,v);if(s===N){var T=i,x=v;T.results.length!==x.length&&I("Different number of results and all-controls lists"),0===x.length&&I("Unexpected empty list of results for processing common controls");for(var w=x[0].length,b=[],L=0;L<w;L+=1)b.push(O(x.map(function(t){return t[L]}),"leg "+L+" of class "+T.name));for(var D=0;D<T.results.length;D+=1)T.results[D].restrictToCommonControls(x[D],b);for(var R=[],L=0;L<b.length;L+=1)R=R.concat(b[L]),L<b.length-1&&R.push(A.INTERMEDIATE);T.controls=R,T.course.numbersOfControls=b.map(function(t){return t.length})}}return null===i.course.id&&0<i.controls.length&&(i.course.id=i.controls.join(",")),i}SplitsBrowser.Input.IOFXml={parseEventData:function(t,r){var e,o=function(t){for(var e=0;e<g.length;e+=1){var s=g[e];if(s.isOfThisVersion(t))return s}i("Data apparently not of any recognised IOF XML format")}(t),t=function(t){try{return $.parseXML(t)}catch(t){I("XML data not well-formed")}}(t),s=(e=t,n=o,"ResultList"!==(s=(e=$("> *",t)).prop("tagName"))&&i("Root element of XML document does not have expected name 'ResultList', got '"+s+"'"),n.checkVersion(e),$("> ResultList > ClassResult",$(t)).toArray()),l=(0===s.length&&I("No class result elements found"),[]),a=[],u=d3.map(),h=[],n=(s.forEach(function(t){var e,s,n,i,t=C(t,o,r,h);null!==t&&(e=t.course,n=null!==t.teams&&null!==t.course.numbersOfControls&&0<t.course.numbersOfControls.length?(i=t.course.numbersOfControls.reduce(function(t,e){return t+e},0)+t.teamSize-1,r!==N&&(t.controls=null),!(s=null)):(i=t.controls.length,s=e.id+","+t.controls.join(","),!1),i=new d(t.name,i,t.results),n&&i.setIsTeamClass(t.course.numbersOfControls),l.push(i),null!==e.id&&null!==s&&u.has(s)?u.get(s).classes.push(i):(e.classes=[i],e.controls=t.controls,a.push(e),null!==e.id&&u.set(s,e)))}),a.map(function(t){var e=new A(t.name,t.classes,t.length,t.climb,t.controls);return t.classes.forEach(function(t){t.setCourse(e)}),e}));return new m(l,n,h)}}}(),function(){"use strict";var i=[SplitsBrowser.Input.CSV.parseEventData,SplitsBrowser.Input.OE.parseEventData,SplitsBrowser.Input.Html.parseEventData,SplitsBrowser.Input.AlternativeCSV.parseTripleColumnEventData,SplitsBrowser.Input.IOFXml.parseEventData];SplitsBrowser.Input.parseEventData=function(t,e){for(var s=0;s<i.length;s+=1){var n=i[s];try{return n(t,e)}catch(t){if("WrongFileFormat"!==t.name)throw t}}return null}}(),function(){"use strict";function t(t,e){this.parent=t,this.alerter=e,this.handler=null,this.resultSelection=null,this.lastFilterString="",this.allResults=[],this.allResultDetails=[],this.dragging=!1,this.dragStartResultIndex=null,this.currentDragResultIndex=null,this.allResultDivs=[],this.inverted=!1,this.hasTeamData=!1,this.selectedLegIndex=null,this.placeholderDiv=null,this.changeHandlers=[],this.containerDiv=d3.select(t).append("div").attr("id","resultListContainer"),this.buttonsPanel=this.containerDiv.append("div");var s=this;this.allButton=this.buttonsPanel.append("button").attr("id","selectAllResults").style("width","50%").on("click",function(){s.selectAllFiltered()}),this.noneButton=this.buttonsPanel.append("button").attr("id","selectNoResults").style("width","50%").on("click",function(){s.selectNoneFiltered()}),$(this.noneButton.node()).dblclick(function(){s.selectNone()}),this.buttonsPanel.append("br"),this.crossingRunnersButton=this.buttonsPanel.append("button").attr("id","selectCrossingRunners").style("width","100%").on("click",function(){s.selectCrossingRunners()}).style("display","none"),this.filter=this.buttonsPanel.append("input").attr("type","text"),this.filter.on("input",function(){s.updateFilterIfChanged()}).on("keyup",function(){s.updateFilterIfChangedDelayed()}).on("mouseup",function(){s.updateFilterIfChangedDelayed()}),this.listDiv=this.containerDiv.append("div").attr("id","resultList"),this.listDiv.on("mousedown",function(){s.startDrag(-1)}).on("mousemove",function(){s.mouseMove(-1)}).on("mouseup",function(){s.stopDrag()}),d3.select(document.body).on("mouseup",function(){s.stopDrag()}),this.setMessages()}var e=SplitsBrowser.getMessage,s=SplitsBrowser.getMessageWithFormatting;function o(t){return t.toLowerCase().replace(/\W/g,"")}t.prototype.setMessages=function(){this.allButton.text(e("SelectAllCompetitors")),this.noneButton.text(e("SelectNoCompetitors")),this.crossingRunnersButton.text(e("SelectCrossingRunners")),this.filter.attr("placeholder",e("CompetitorListFilter"))},t.prototype.retranslate=function(){this.setMessages(),null!==this.placeholderDiv&&(this.setPlaceholderDivText(),this.fireChangeHandlers())},t.prototype.setPlaceholderDivText=function(){this.placeholderDiv.text(e(this.hasTeamData?"NoTeamsStarted":"NoCompetitorsStarted"))},t.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},t.prototype.deregisterChangeHandler=function(t){t=this.changeHandlers.indexOf(t);-1<t&&this.changeHandlers.splice(t,1)},t.prototype.fireChangeHandlers=function(){this.changeHandlers.forEach(function(t){t()},this)},t.prototype.isMouseOffBottomOfResultList=function(){return null===this.lastVisibleDiv||d3.mouse(this.lastVisibleDiv)[1]>=$(this.lastVisibleDiv).height()},t.prototype.getDragClassName=function(){return this.inverted?"dragDeselected":"dragSelected"},t.prototype.startDrag=function(t){if(1===d3.event.which){this.dragStartResultIndex=t,this.currentDragResultIndex=t,this.allResultDivs=$("div.result");var e=this.allResultDivs.filter(":visible");if(this.lastVisibleDiv=0===e.length?null:e[e.length-1],this.inverted=d3.event.shiftKey,-1===t){if(!this.isMouseOffBottomOfResultList())return}else d3.select(this.allResultDivs[t]).classed(this.getDragClassName(),!0);d3.event.stopPropagation(),this.dragging=!0}},t.prototype.mouseMove=function(t){if(this.dragging&&(d3.event.stopPropagation(),t!==this.currentDragResultIndex)){var e=this.getDragClassName();if(d3.selectAll("div.result."+e).classed(e,!1),(-1!==this.dragStartResultIndex||-1!==t)&&(-1!==t||this.isMouseOffBottomOfResultList())){for(var s,n=-1===this.dragStartResultIndex||-1===t?(s=this.dragStartResultIndex+t- -1,this.allResultDivs.length-1):(s=Math.min(this.dragStartResultIndex,t),Math.max(this.dragStartResultIndex,t)),i=[],r=s;r<=n;r+=1)this.allResultDetails[r].visible&&i.push(this.allResultDivs[r]);d3.selectAll(i).classed(e,!0),this.currentDragResultIndex=t}}},t.prototype.stopDrag=function(){if(this.dragging){this.dragging=!1;for(var t=[],e=this.getDragClassName(),s=0;s<this.allResultDivs.length;s+=1)$(this.allResultDivs[s]).hasClass(e)&&t.push(s);d3.selectAll("div.result."+e).classed(e,!1),d3.event.currentTarget===document||-1===this.currentDragResultIndex&&!this.isMouseOffBottomOfResultList()||(1===t.length?this.toggleResult(t[0]):this.inverted?this.resultSelection.bulkDeselect(t):this.resultSelection.bulkSelect(t)),this.dragStartResultIndex=null,this.currentDragResultIndex=null,d3.event.stopPropagation()}},t.prototype.width=function(){return $(this.containerDiv.node()).width()},t.prototype.setHeight=function(t){$(this.listDiv.node()).height(t-$(this.buttonsPanel.node()).height())},t.prototype.getAllVisibleIndexes=function(){return d3.range(this.allResultDetails.length).filter(function(t){return this.allResultDetails[t].visible},this)},t.prototype.selectAllFiltered=function(){this.resultSelection.bulkSelect(this.getAllVisibleIndexes())},t.prototype.selectNoneFiltered=function(){this.resultSelection.bulkDeselect(this.getAllVisibleIndexes())},t.prototype.selectNone=function(){this.resultSelection.selectNone()},t.prototype.isSelected=function(t){return null!==this.resultSelection&&this.resultSelection.isSelected(t)},t.prototype.selectCrossingRunners=function(){var t,e;this.resultSelection.selectCrossingRunners(this.allResultDetails,this.selectedLegIndex),this.resultSelection.isSingleRunnerSelected()&&(t=this.allResults[this.resultSelection.getSingleRunnerIndex()].getOwnerNameForLeg(this.selectedLegIndex),e=0<this.lastFilterString.length,this.alerter(s(e?"RaceGraphNoCrossingRunnersFiltered":"RaceGraphNoCrossingRunners",{$$NAME$$:t})))},t.prototype.enableOrDisableCrossingRunnersButton=function(){this.crossingRunnersButton.node().disabled=!this.resultSelection.isSingleRunnerSelected()},t.prototype.setChartType=function(t){this.crossingRunnersButton.style("display",t.isRaceGraph?"block":"none")},t.prototype.selectionChanged=function(){var s=this;this.listDiv.selectAll("div.result").data(d3.range(this.resultSelection.count)).classed("selected",function(t,e){return s.isSelected(e)})},t.prototype.toggleResult=function(t){this.resultSelection.toggle(t)},t.prototype.formatTooltip=function(t){var e=[t.owner.name],t=(t.owner.members.forEach(function(t){e.push(t.name)}),null===this.selectedLegIndex?0:this.selectedLegIndex+1);return e[t]="> "+e[t],e.join("\n")},t.prototype.setResultList=function(t,e,s,n){this.allResults=t,this.hasTeamData=s,this.selectedLegIndex=n,this.allResultDetails=this.allResults.map(function(t){return{result:t,normedName:o(t.owner.name),visible:!0}}),t=s?this.formatTooltip.bind(this):function(){return null},null!==this.placeholderDiv&&(this.placeholderDiv.remove(),this.placeholderDiv=null);var i=this.listDiv.selectAll("div.result").data(this.allResults),r=this;i.enter().append("div").classed("result",!0).classed("selected",function(t,e){return r.isSelected(e)}),i.selectAll("span").remove(),i=this.listDiv.selectAll("div.result").data(this.allResults).attr("title",t),e&&i.append("span").classed("resultClassLabel",!0).text(function(t){return t.className}),i.append("span").classed("nonfinisher",function(t){return!t.completed()}).text(function(t){var e=(s&&null!==n?t.owner.members[n]:t.owner).name;return t.completed()?""===e?" ":e:"* "+e}),i.exit().remove(),0===this.allResults.length&&(this.placeholderDiv=this.listDiv.append("div").classed("resultListPlaceholder",!0),this.setPlaceholderDivText()),this.allButton.property("disabled",0===this.allResults.length),this.noneButton.property("disabled",0===this.allResults.length),this.filter.property("disabled",0===this.allResults.length),i.on("mousedown",function(t,e){r.startDrag(e)}).on("mousemove",function(t,e){r.mouseMove(e)}).on("mouseup",function(){r.stopDrag()}),this.updateFilter()},t.prototype.setSelection=function(t){null!==this.resultSelection&&this.resultSelection.deregisterChangeHandler(this.handler);var e=this;this.resultSelection=t,this.handler=function(){e.selectionChanged()},this.resultSelection.registerChangeHandler(this.handler),this.selectionChanged()},t.prototype.getFilterText=function(){return this.filter.node().value},t.prototype.setFilterText=function(t){this.filter.node().value=t,this.updateFilterIfChanged()},t.prototype.updateFilter=function(){var e=o(this.filter.node().value),s=(this.allResultDetails.forEach(function(t){t.visible=0<=t.normedName.indexOf(e)}),this);this.listDiv.selectAll("div.result").style("display",function(t,e){return s.allResultDetails[e].visible?null:"none"})},t.prototype.updateFilterIfChanged=function(){var t=this.getFilterText();t!==this.lastFilterString&&(this.updateFilter(),this.lastFilterString=t,this.fireChangeHandlers())},t.prototype.updateFilterIfChangedDelayed=function(){var t=this;setTimeout(function(){t.updateFilterIfChanged()},1)},SplitsBrowser.Controls.ResultList=t}(),function(){"use strict";var t=SplitsBrowser.getMessage,s=SplitsBrowser.getAllLanguages,n=SplitsBrowser.getLanguage,i=SplitsBrowser.getLanguageName,e=SplitsBrowser.setLanguage;function r(t){var e;this.changeHandlers=[],this.label=null,this.dropDown=null,this.allLanguages=s(),this.allLanguages.length<2||(d3.select(t).append("div").classed("topRowStartSpacer",!0),t=d3.select(t).append("div").classed("topRowStart",!0),this.label=t.append("span"),(e=this).dropDown=t.append("select").node(),$(this.dropDown).bind("change",function(){e.onLanguageChanged()}),(t=d3.select(this.dropDown).selectAll("option").data(this.allLanguages)).enter().append("option"),(t=d3.select(this.dropDown).selectAll("option").data(this.allLanguages)).attr("value",function(t){return t}).text(function(t){return i(t)}),t.exit().remove(),this.setLanguage(n()),this.setMessages())}r.prototype.setMessages=function(){this.label.text(t("LanguageSelectorLabel"))},r.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},r.prototype.setLanguage=function(t){t=this.allLanguages.indexOf(t);0<=t&&(this.dropDown.selectedIndex=t,this.onLanguageChanged())},r.prototype.onLanguageChanged=function(){e(this.dropDown.options[this.dropDown.selectedIndex].value),this.changeHandlers.forEach(function(t){t()})},SplitsBrowser.Controls.LanguageSelector=r}(),function(){"use strict";var s=SplitsBrowser.throwInvalidData,n=SplitsBrowser.getMessage;function t(t){this.changeHandlers=[],this.otherClassesEnabled=!0;var e=d3.select(t).append("div").classed("topRowStart",!0),n=(this.labelSpan=e.append("span"),this);this.dropDown=e.append("select").node(),$(this.dropDown).bind("change",function(){n.updateOtherClasses(d3.set()),n.onSelectionChanged()}),this.otherClassesContainer=d3.select(t).append("div").attr("id","otherClassesContainer").classed("topRowStart",!0).style("display","none"),this.otherClassesCombiningLabel=this.otherClassesContainer.append("span").classed("otherClassCombining",!0),this.otherClassesSelector=this.otherClassesContainer.append("div").classed("otherClassSelector",!0).style("display","inline-block"),this.otherClassesSpan=this.otherClassesSelector.append("span"),this.otherClassesList=d3.select(t).append("div").classed("otherClassList",!0).classed("transient",!0).style("position","absolute").style("display","none"),this.otherClassesSelector.on("click",function(){n.showHideClassSelector()}),this.setClasses([]),this.selectedOtherClassIndexes=d3.set(),$(document).click(function(t){var e,s=n.otherClassesList.node();"none"===s.style.display||(e=$("div.otherClassList,div.otherClassSelector")).is(t.target)||0!==e.has(t.target).length||(s.style.display="none")}),this.setMessages()}t.prototype.setMessages=function(){this.labelSpan.text(n("ClassSelectorLabel")),this.otherClassesCombiningLabel.text(n("AdditionalClassSelectorLabel"))},t.prototype.setOtherClassesEnabled=function(t){this.otherClassesCombiningLabel.classed("disabled",!t),this.otherClassesSelector.classed("disabled",!t),this.otherClassesEnabled=t},t.prototype.setClasses=function(t){var e;$.isArray(t)?(t=0===(this.classes=t).length?(this.dropDown.disabled=!0,[n("NoClassesLoadedPlaceholder")]):(this.dropDown.disabled=!1,t.map(function(t){return t.name})),(e=d3.select(this.dropDown).selectAll("option").data(t)).enter().append("option"),(e=d3.select(this.dropDown).selectAll("option").data(t)).attr("value",function(t,e){return e.toString()}).text(function(t){return t}),e.exit().remove(),this.updateOtherClasses(d3.set())):s("ClassSelector.setClasses: classes is not an array")},t.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},t.prototype.selectClasses=function(t){0<t.length&&t.every(function(t){return 0<=t&&t<this.dropDown.options.length},this)&&(this.dropDown.selectedIndex=t[0],this.updateOtherClasses(d3.set(t.slice(1))),this.onSelectionChanged())},t.prototype.getSelectedClasses=function(){var e;return this.dropDown.disabled?[]:(e=[this.dropDown.selectedIndex],this.selectedOtherClassIndexes.each(function(t){e.push(parseInt(t,10))}),e)},t.prototype.onSelectionChanged=function(){var e=this.getSelectedClasses();this.changeHandlers.forEach(function(t){t(e)})},t.prototype.updateOtherClassText=function(){var t=this.selectedOtherClassIndexes.values();t.sort(d3.ascending),t=0===t.length?n("NoAdditionalClassesSelectedPlaceholder"):t.map(function(t){return this.classes[t].name},this).join(", "),this.otherClassesSpan.text(t)},t.prototype.updateOtherClasses=function(e){this.otherClassesList.style("display","none"),this.selectedOtherClassIndexes=e,this.updateOtherClassText(),$("div.otherClassItem").off("click");var s=this,n=(0<this.classes.length?(t=this.classes[this.dropDown.selectedIndex]).course.getOtherClasses(t):[]).map(function(t){return this.classes.indexOf(t)},this),t=this.otherClassesList.selectAll("div").data(n),t=(t.enter().append("div").classed("otherClassItem",!0),(t=this.otherClassesList.selectAll("div").data(n)).attr("id",function(t){return"courseClassIdx_"+t}).classed("selected",function(t){return e.has(t)}).text(function(t){return s.classes[t].name}),t.exit().remove(),0<n.length?this.otherClassesContainer.style("display",null):this.otherClassesContainer.style("display","none"),$(this.otherClassesSelector.node()).offset()),i=$(this.otherClassesSelector.node()).outerHeight();this.otherClassesList.style("left",t.left+"px").style("top",t.top+i+"px"),$("div.otherClassItem").each(function(t,e){$(e).on("click",function(){s.toggleOtherClass(n[t])})})},t.prototype.showHideClassSelector=function(){this.otherClassesEnabled&&this.otherClassesList.style("display","none"===this.otherClassesList.style("display")?null:"none")},t.prototype.toggleOtherClass=function(t){this.selectedOtherClassIndexes.has(t)?this.selectedOtherClassIndexes.remove(t):this.selectedOtherClassIndexes.add(t),d3.select("div#courseClassIdx_"+t).classed("selected",this.selectedOtherClassIndexes.has(t)),this.updateOtherClassText(),this.onSelectionChanged()},t.prototype.retranslate=function(){this.setMessages(),0===this.classes.length&&d3.select(this.dropDown.options[0]).text(n("NoClassesLoadedPlaceholder")),0===this.selectedOtherClassIndexes.values().length&&this.otherClassesSpan.text(n("NoAdditionalClassesSelectedPlaceholder"))},SplitsBrowser.Controls.ClassSelector=t}(),function(){"use strict";var s=SplitsBrowser.getMessage,n=SplitsBrowser.getMessageWithFormatting,t=[{nameKey:"CompareWithWinner",selector:function(t){return t.getWinnerCumTimes()},requiresWinner:!0,percentage:""},{nameKey:"CompareWithFastestTime",selector:function(t){return t.getFastestCumTimes()},requiresWinner:!1,percentage:""}],i=([5,25,50,100].forEach(function(e){t.push({nameKey:"CompareWithFastestTimePlusPercentage",selector:function(t){return t.getFastestCumTimesPlusPercentage(e)},requiresWinner:!1,percentage:e})}),t.slice(0)),e=(i.push({nameKey:"CompareWithAnyRunner",selector:null,requiresWinner:!0,percentage:""}),t.slice(0));e.push({nameKey:"CompareWithAnyTeam",selector:null,requiresWinner:!0,percentage:""});function r(t,e){this.changeHandlers=[],this.classes=null,this.currentResultIndex=null,this.previousResultList=null,this.parent=t,this.alerter=e,this.hasWinner=!1,this.previousSelectedIndex=-1,this.courseClassSet=null,this.selectedLegIndex=null,this.comparisonOptions=i;var e=d3.select(t).append("div").classed("topRowStart",!0),s=(this.comparisonSelectorLabel=e.append("span").classed("comparisonSelectorLabel",!0),this);this.dropDown=e.append("select").attr("id","comparisonSelector").node(),$(this.dropDown).bind("change",function(){s.onSelectionChanged()}),this.optionsList=d3.select(this.dropDown).selectAll("option").data(this.comparisonOptions),this.optionsList.enter().append("option"),this.optionsList=d3.select(this.dropDown).selectAll("option").data(this.comparisonOptions),this.optionsList.attr("value",function(t,e){return e.toString()}),this.optionsList.exit().remove(),this.resultDiv=d3.select(t).append("div").classed("topRowStart",!0).style("display","none").style("padding-left","20px"),this.resultSpan=this.resultDiv.append("span").attr("id","resultSpan").classed("comparisonSelectorLabel",!0),this.resultDropDown=this.resultDiv.append("select").attr("id","resultSelector").node(),$(this.resultDropDown).bind("change",function(){s.onSelectionChanged()}),this.dropDown.selectedIndex=1,this.previousSelectedIndex=1,this.setMessages()}r.prototype.setMessages=function(){this.comparisonSelectorLabel.text(s("ComparisonSelectorLabel")),this.setCompareWithAnyLabel(),this.optionsList.text(function(t){return n(t.nameKey,{$$PERCENT$$:t.percentage})})},r.prototype.setCompareWithAnyLabel=function(){null!==this.courseClassSet&&this.courseClassSet.hasTeamData()&&null===this.selectedLegIndex?this.resultSpan.text(s("CompareWithAnyTeamLabel")):this.resultSpan.text(s("CompareWithAnyRunnerLabel"))},r.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},r.prototype.isAnyResultSelected=function(){return this.dropDown.selectedIndex===this.comparisonOptions.length-1},r.prototype.setCourseClassSet=function(t){this.courseClassSet=t,this.selectedLegIndex=null,this.comparisonOptions=t.hasTeamData()?e:i,this.optionsList=d3.select(this.dropDown).selectAll("option").data(this.comparisonOptions),this.optionsList.text(function(t){return n(t.nameKey,{$$PERCENT$$:t.percentage})}),this.setResults(),this.setCompareWithAnyLabel()},r.prototype.setSelectedLeg=function(t){this.selectedLegIndex=t,this.setResults(),this.setCompareWithAnyLabel(),this.optionsList.data(null===t?e:i),this.optionsList.text(function(t){return n(t.nameKey,{$$PERCENT$$:t.percentage})})},r.prototype.setResults=function(){var e=this.courseClassSet.allResults,s=d3.range(e.length).filter(function(t){return e[t].completed()}),t=e.filter(function(t){return t.completed()}),n=(this.hasWinner=0<t.length,this.selectedLegIndex),i=d3.select(this.resultDropDown).selectAll("option").data(t);i.enter().append("option"),(i=d3.select(this.resultDropDown).selectAll("option").data(t)).attr("value",function(t,e){return s[e].toString()}).text(function(t){return t.getOwnerNameForLeg(n)}),i.exit().remove(),null===this.previousResultList?this.currentResultIndex=0:this.hasWinner?(t=this.previousResultList[this.currentResultIndex],i=e.indexOf(t),this.currentResultIndex=Math.max(i,0)):this.comparisonOptions[this.dropDown.selectedIndex].requiresWinner&&this.setComparisonType(1,null),this.resultDropDown.selectedIndex=this.currentResultIndex,this.previousResultList=e},r.prototype.setEnabled=function(t){d3.select(this.parent).selectAll("span.comparisonSelectorLabel").classed("disabled",!t),this.dropDown.disabled=!t,this.resultDropDown.disabled=!t},r.prototype.getComparisonFunction=function(){var e;return this.isAnyResultSelected()?(e=this,function(t){return t.getCumulativeTimesForResult(e.currentResultIndex)}):this.comparisonOptions[this.dropDown.selectedIndex].selector},r.prototype.getComparisonType=function(){var t=this.isAnyResultSelected()?(this.resultDropDown.selectedIndex<0&&(this.resultDropDown.selectedIndex=0),this.courseClassSet.allResults[this.resultDropDown.selectedIndex]):null;return{index:this.dropDown.selectedIndex,result:t}},r.prototype.setComparisonType=function(t,e){0<=t&&t<this.comparisonOptions.length&&(t===this.comparisonOptions.length-1?0<=(e=this.courseClassSet.allResults.indexOf(e))&&(this.dropDown.selectedIndex=t,this.resultDropDown.selectedIndex=e,this.onSelectionChanged()):(this.dropDown.selectedIndex=t,this.onSelectionChanged()))},r.prototype.onSelectionChanged=function(){var t=Math.max(this.resultDropDown.selectedIndex,0),e=this.comparisonOptions[this.dropDown.selectedIndex];!this.hasWinner&&e.requiresWinner?(this.alerter(n(null!==this.courseClassSet&&this.courseClassSet.hasTeamData()?"CannotCompareAsNoWinnerTeam":"CannotCompareAsNoWinner",{$$OPTION$$:s(e.nameKey)})),this.dropDown.selectedIndex=this.previousSelectedIndex):(this.resultDiv.style("display",this.isAnyResultSelected()?null:"none"),this.currentResultIndex=0===this.resultDropDown.options.length?0:parseInt(this.resultDropDown.options[t].value,10),this.previousSelectedIndex=this.dropDown.selectedIndex,this.changeHandlers.forEach(function(t){t(this.getComparisonFunction())},this))},SplitsBrowser.Controls.ComparisonSelector=r}(),function(){"use strict";var s=SplitsBrowser.getMessage,n="statisticCheckbox",i=["TotalTime","SplitTime","BehindFastest","TimeLoss"],r=["StatisticsTotalTime","StatisticsSplitTime","StatisticsBehindFastest","StatisticsTimeLoss"],o=["SplitTime","TimeLoss"];function t(t){this.div=d3.select(t).append("div").classed("topRowEnd",!0).attr("id","statisticSelector");var t=this.div.selectAll("div").data(i).enter().append("div").style("display","inline-block"),e=(t.append("input").attr("id",function(t){return n+t}).attr("type","checkbox").attr("checked",function(t){return 0<=o.indexOf(t)?"checked":null}),this.statisticLabels=t.append("label").attr("for",function(t){return n+t}).classed("statisticsSelectorLabel",!0),this);$("input",this.div.node()).bind("change",function(){return e.onCheckboxChanged()}),this.handlers=[],this.setMessages()}t.prototype.setMessages=function(){this.statisticLabels.text(function(t,e){return s(r[e])})},t.prototype.clearAll=function(){this.div.selectAll("input").attr("checked",null)},t.prototype.setEnabled=function(t){this.div.selectAll("label.statisticsSelectorLabel").classed("disabled",!t),this.div.selectAll("input").attr("disabled",t?null:"disabled")},t.prototype.registerChangeHandler=function(t){-1===this.handlers.indexOf(t)&&this.handlers.push(t)},t.prototype.deregisterChangeHandler=function(t){t=this.handlers.indexOf(t);-1!==t&&this.handlers.splice(t,1)},t.prototype.getVisibleStatistics=function(){var s={};return this.div.selectAll("input").nodes().forEach(function(t,e){s[i[e]]=t.checked}),s},t.prototype.setVisibleStatistics=function(s){this.div.selectAll("input").nodes().forEach(function(t,e){t.checked=s[i[e]]||!1}),this.onCheckboxChanged()},t.prototype.onCheckboxChanged=function(){var e=this.getVisibleStatistics();this.handlers.forEach(function(t){t(e)})},SplitsBrowser.Controls.StatisticsSelector=t}(),function(){"use strict";var e=SplitsBrowser.getMessage;function t(t,e){this.changeHandlers=[],this.chartTypes=e,this.raceGraphDisabledNotifier=null,this.lastSelectedIndex=0;var t=d3.select(t).append("div").classed("topRowStart",!0),s=(this.labelSpan=t.append("span"),this);this.dropDown=t.append("select").node(),$(this.dropDown).bind("change",function(){s.onSelectionChanged()}),this.optionsList=d3.select(this.dropDown).selectAll("option").data(e),this.optionsList.enter().append("option"),this.optionsList=d3.select(this.dropDown).selectAll("option").data(e),this.optionsList.attr("value",function(t,e){return e.toString()}),this.optionsList.exit().remove(),this.setMessages()}t.prototype.setMessages=function(){this.labelSpan.text(e("ChartTypeSelectorLabel")),this.optionsList.text(function(t){return e(t.nameKey)})},t.prototype.setRaceGraphDisabledNotifier=function(t){this.raceGraphDisabledNotifier=t,null!==this.raceGraphDisabledNotifier&&this.chartTypes[this.dropDown.selectedIndex].isRaceGraph&&(this.raceGraphDisabledNotifier(),this.dropDown.selectedIndex=0,this.onSelectionChanged())},t.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},t.prototype.getChartType=function(){return this.chartTypes[Math.max(this.dropDown.selectedIndex,0)]},t.prototype.setChartType=function(t){t=this.chartTypes.indexOf(t);0<=t&&(this.dropDown.selectedIndex=t,this.onSelectionChanged())},t.prototype.onSelectionChanged=function(){null!==this.raceGraphDisabledNotifier&&this.chartTypes[this.dropDown.selectedIndex].isRaceGraph&&(this.raceGraphDisabledNotifier(),this.dropDown.selectedIndex=Math.max(this.lastSelectedIndex,0)),this.changeHandlers.forEach(function(t){t(this.chartTypes[this.dropDown.selectedIndex])},this),this.lastSelectedIndex=this.dropDown.selectedIndex},SplitsBrowser.Controls.ChartTypeSelector=t}(),function(){"use strict";var t=SplitsBrowser.getMessage;function e(t){this.parent=t;var e="originalDataCheckbox",t=(this.containerDiv=t.append("div").classed("topRowStart",!0).attr("id","originalDataSelectorContainer"),this.containerDiv.append("div").classed("topRowStartSpacer",!0),this.containerDiv.append("span")),s=this;this.checkbox=t.append("input").attr("type","checkbox").attr("id",e).on("click",function(){s.fireChangeHandlers()}).node(),this.label=t.append("label").attr("for",e).classed("originalDataSelectorLabel",!0),this.handlers=[],this.setMessages()}e.prototype.setMessages=function(){this.label.text(t("ShowOriginalData")),this.containerDiv.attr("title",t("ShowOriginalDataTooltip"))},e.prototype.registerChangeHandler=function(t){-1===this.handlers.indexOf(t)&&this.handlers.push(t)},e.prototype.deregisterChangeHandler=function(t){t=this.handlers.indexOf(t);-1!==t&&this.handlers.splice(t,1)},e.prototype.fireChangeHandlers=function(){this.handlers.forEach(function(t){t(this.checkbox.checked)},this)},e.prototype.isOriginalDataSelected=function(){return this.checkbox.checked},e.prototype.selectOriginalData=function(){this.checkbox.checked=!0,this.fireChangeHandlers()},e.prototype.setVisible=function(t){this.containerDiv.style("display",t?null:"none")},e.prototype.setEnabled=function(t){this.parent.selectAll("label.originalDataSelectorLabel").classed("disabled",!t),this.checkbox.disabled=!t},SplitsBrowser.Controls.OriginalDataSelector=e}(),function(){"use strict";var s=SplitsBrowser.getMessage,n=SplitsBrowser.getMessageWithFormatting;function t(t){this.changeHandlers=[],this.parent=t,this.courseClassSet=null,this.legCount=null,this.containerDiv=t.append("div").attr("id","legSelectorContainer").classed("topRowStart",!0).style("display","none"),this.containerDiv.append("div").classed("topRowStartSpacer",!0),this.legSelectorLabel=this.containerDiv.append("span").classed("legSelectorLabel",!0);var e=this;this.dropDown=this.containerDiv.append("select").attr("id","legSelector").node(),$(this.dropDown).bind("change",function(){e.onSelectionChanged()}),this.options=null,this.dropDown.selectedIndex=0,this.setMessages()}t.prototype.setMessages=function(){this.legSelectorLabel.text(s("LegSelectorLabel")),this.setLegNames()},t.prototype.registerChangeHandler=function(t){-1===this.changeHandlers.indexOf(t)&&this.changeHandlers.push(t)},t.prototype.setLegNames=function(){for(var t=[s("ShowAllLegs")],e=0;e<this.legCount;e+=1)t.push(n("ShowLeg",{$$LEG_NUMBER$$:e+1}));this.options=d3.select(this.dropDown).selectAll("option").data(t),this.options.enter().append("option"),this.options=d3.select(this.dropDown).selectAll("option").data(t),this.options.attr("value",function(t,e){return 0===e?"":e-1}).text(function(t){return t}),this.options.exit().remove()},t.prototype.setCourseClassSet=function(t){this.courseClassSet=t,this.legCount=this.courseClassSet.getLegCount(),null===this.legCount?(this.options=null,d3.select(this.dropDown).selectAll("option").remove(),this.containerDiv.style("display","none")):(this.setLegNames(),this.containerDiv.style("display",null),this.dropDown.selectedIndex=0)},t.prototype.getSelectedLeg=function(){if(null===this.options)return null;var t=Math.max(this.dropDown.selectedIndex,0);return 0===t?null:t-1},t.prototype.setSelectedLeg=function(t){null!==this.options&&(((t=null===t?0:t+1)<0||t>=this.options.size())&&(t=0),this.dropDown.selectedIndex=t,this.onSelectionChanged())},t.prototype.onSelectionChanged=function(){var e=this.getSelectedLeg();this.changeHandlers.forEach(function(t){t(e)})},SplitsBrowser.Controls.LegSelector=t}(),function(){"use strict";var o=SplitsBrowser.formatTime,l=SplitsBrowser.getMessage,a=SplitsBrowser.getMessageWithFormatting,u=SplitsBrowser.Model.Course,t={};t.getFastestSplitsPopupData=function(t,e,s){e=(e=t.getFastestSplitsTo(10,e,s)).map(function(t){return{time:t.split,name:t.name,highlight:!1}}),t=t.hasTeamData()&&null===s?"SelectedClassesPopupPlaceholderTeams":"SelectedClassesPopupPlaceholder";return{title:l("SelectedClassesPopupHeader"),data:e,placeholder:l(t)}},
t.getFastestSplitsForLegPopupData=function(t,e,s){var n=t.getCourse(),i=n.getControlCode(s-1),n=n.getControlCode(s),s=i===u.START||i===u.INTERMEDIATE?l("StartName"):i,r=n===u.INTERMEDIATE||n===u.FINISH?l("FinishName"):n,s=a("FastestLegTimePopupHeader",{$$START$$:s,$$END$$:r}),o=t.getPrimaryClassName();return{title:s,data:e.getFastestSplitsForLeg(i,n).map(function(t){return{name:t.name,className:t.className,time:t.split,highlight:t.className===o}}),placeholder:null}},t.getResultsVisitingCurrentControlPopupData=function(t,e,s,n){var s=t.getCourse().getControlCode(s),i=Math.round(n)-120,n=Math.round(n)+120,e=e.getResultsAtControlInTimeRange(s,i,n),r=t.getPrimaryClassName(),t=e.map(function(t){return{name:t.name,className:t.className,time:t.time,highlight:t.className===r}}),e=s===u.START?l("StartName"):s===u.INTERMEDIATE||s===u.FINISH?l("FinishName"):a("ControlName",{$$CODE$$:s});return{title:a("NearbyCompetitorsPopupHeader",{$$START$$:o(i),$$END$$:o(n),$$CONTROL$$:e}),data:t,placeholder:l("NoNearbyCompetitors")}},t.getNextControlData=function(t,e,s){s=Math.min(s,t.controls.length),t=t.getControlCode(s),s=e.getNextControlsAfter(t);return s.sort(function(t,e){t=t.course.name,e=e.course.name;if(t===e)return 0;if(""===t||""===e||t[0]!==e[0])return t<e?-1:1;if(null!==(n=/^[^0-9]+/.exec(t))&&0<n.length){n=n[0];if(0<n.length&&n.length<t.length&&e.substring(0,n.length)===n){var s=parseInt(t.substring(n.length),10),n=parseInt(e.substring(n.length),10);if(!isNaN(s)&&!isNaN(n))return s-n}}return t<e?-1:1}),{thisControl:t===u.START||t===u.INTERMEDIATE?l("StartName"):a("ControlName",{$$CODE$$:t}),nextControls:s.map(function(t){for(var e=t.nextControls.slice(0),s=0;s<e.length;s+=1)e[s]!==u.INTERMEDIATE&&e[s]!==u.FINISH||(e[s]=l("FinishName"));return{course:t.course,nextControls:e.join(", ")}})}},SplitsBrowser.Model.ChartPopupData=t}(),function(){"use strict";var n=SplitsBrowser.formatTime,i=SplitsBrowser.hasProperty;function t(t,e){this.shown=!1,this.mouseIn=!1,this.popupDiv=d3.select(t).append("div"),this.popupDiv.classed("chartPopup",!0).style("display","none").style("position","absolute"),this.dataHeader=this.popupDiv.append("div").classed("chartPopupHeader",!0).append("span");var s,t=this.popupDiv.append("div").classed("chartPopupTableContainer",!0);for(s in this.dataTable=t.append("table"),this.popupDiv.selectAll(".nextControls").style("display","none"),e)i(e,s)&&$(this.popupDiv.node()).on(s,e[s]);var n=this;$(this.popupDiv.node()).mouseenter(function(){n.mouseIn=!0}),$(this.popupDiv.node()).mouseleave(function(){n.mouseIn=!1})}t.prototype.isShown=function(){return this.shown},t.prototype.isMouseIn=function(){return this.mouseIn},t.prototype.setData=function(t,e){this.dataHeader.text(t.title);var s=this.dataTable.selectAll("tr").data(t.data);s.enter().append("tr"),(s=this.dataTable.selectAll("tr").data(t.data)).classed("highlighted",function(t){return t.highlight}),s.selectAll("td").remove(),s.append("td").text(function(t){return n(t.time)}),e&&s.append("td").text(function(t){return t.className}),s.append("td").text(function(t){return t.name}),s.exit().remove(),0===t.data.length&&null!==t.placeholder&&this.dataTable.append("tr").append("td").text(t.placeholder)},t.prototype.setNextControlData=function(t){this.dataHeader.text(t.thisControl);t=this.dataTable.selectAll("tr").data(t.nextControls);t.enter().append("tr"),t.selectAll("td").remove(),t.classed("highlighted",!1),t.append("td").text(function(t){return t.course.name}),t.append("td").text("--\x3e"),t.append("td").text(function(t){return t.nextControls}),t.exit().remove()},t.prototype.setLocation=function(t){this.popupDiv.style("left",t.x+"px").style("top",t.y+"px")},t.prototype.show=function(t){this.popupDiv.style("display",null),this.shown=!0,this.setLocation(t)},t.prototype.hide=function(){this.popupDiv.style("display","none"),this.shown=!1},t.prototype.height=function(){return $(this.popupDiv.node()).height()},SplitsBrowser.Controls.ChartPopup=t}(),function(){"use strict";var e=18,i=0,r=18,o=53,l=" ",a=["#FF0000","#4444FF","#00FF00","#000000","#CC0066","#000099","#FFCC00","#884400","#9900FF","#CCCC00","#888800","#CC6699","#00DD00","#3399FF","#BB00BB","#00DDDD","#FF00FF","#0088BB","#888888","#FF99FF","#55BB33"],u=SplitsBrowser.formatTime,h=SplitsBrowser.formatTimeOfDay,c=SplitsBrowser.getMessage,p=SplitsBrowser.isNotNullNorNaN,n=SplitsBrowser.isNaNStrict,t=SplitsBrowser.Model.ChartPopupData,d=SplitsBrowser.Controls.ChartPopup;function m(t,e,s){s=null===(e=s&&null===t?t=NaN:e)?"-":n(e)?"?":e.toString();return l+u(t)+" ("+s+")"}function f(t,e){return""===e?t:t+" ("+e+")"}function g(t){return t.completed()&&t.isNonCompetitive?c("NonCompetitiveShort"):t.isNonFinisher?c("DidNotFinishShort"):t.isDisqualified?c("DisqualifiedShort"):t.isOverMaxTime?c("OverMaxTimeShort"):t.completed()?"":c("MispunchedShort")}function s(t){this.parent=t,this.xScale=null,this.yScale=null,this.hasData=!1,this.overallWidth=-1,this.overallHeight=-1,this.contentWidth=-1,this.contentHeight=-1,this.numControls=-1,this.selectedIndexes=[],this.currentResultData=null,this.isPopupOpen=!1,this.popupUpdateFunc=null,this.maxStartTimeLabelWidth=0,this.mouseOutTimeout=null,this.selectedIndexesOrderedByLastYValue=[],this.referenceCumTimes=[],this.referenceCumTimesSorted=[],this.referenceCumTimeIndexes=[],this.fastestCumTimes=[],this.selectedLegIndex=null,this.isMouseIn=!1,this.currentControlIndex=null,this.actualControlIndex=null,this.controlLine=null,this.svg=d3.select(this.parent).append("svg").attr("id","chart"),this.svgGroup=this.svg.append("g"),this.setLeftMargin(o);function e(t){i.onMouseMove(t)}function s(t){i.onMouseUp(t)}function n(t){i.onMouseDown(t)}var i=this,r=($(this.svg.node()).mouseenter(function(t){i.onMouseEnter(t)}).mousemove(e).mouseleave(function(t){i.onMouseLeave(t)}).mousedown(n).mouseup(s),$(this.svg.node()).contextmenu(function(t){t.preventDefault()}),this.textSizeElement=this.svg.append("text").attr("fill","transparent").attr("id","sb-text-size-element"),{mousemove:e,mousedown:n,mouseup:s});this.popup=new d(t,r),$(document).mouseup(function(){i.popup.hide()})}function C(t){t=t.filter(p);return 0<t.length?d3.max(t):0}s.prototype.setLeftMargin=function(t){this.currentLeftMargin=t,this.svgGroup.attr("transform","translate("+this.currentLeftMargin+","+e+")")},s.prototype.getPopupLocation=function(t){return{x:t.pageX+10,y:Math.max(t.pageY-this.popup.height()/2,0)}},s.prototype.getFastestSplitsPopupData=function(){return t.getFastestSplitsPopupData(this.courseClassSet,this.currentControlIndex,this.selectedLegIndex)},s.prototype.getFastestSplitsForCurrentLegPopupData=function(){return t.getFastestSplitsForLegPopupData(this.courseClassSet,this.eventData,this.currentControlIndex)},s.prototype.setCurrentChartTime=function(t){t=t.pageY-$(this.svg.node()).offset().top-e;this.currentChartTime=Math.round(60*this.yScale.invert(t))+this.referenceCumTimes[this.currentControlIndex]},s.prototype.getResultsVisitingCurrentControlPopupData=function(){return t.getResultsVisitingCurrentControlPopupData(this.courseClassSet,this.eventData,this.currentControlIndex,this.currentChartTime)},s.prototype.getNextControlData=function(){return t.getNextControlData(this.courseClassSet.getCourse(),this.eventData,this.actualControlIndex)},s.prototype.onMouseEnter=function(t){null!==this.mouseOutTimeout&&(clearTimeout(this.mouseOutTimeout),this.mouseOutTimeout=null),this.isMouseIn=!0,this.hasData&&this.updateControlLineLocation(t)},s.prototype.onMouseMove=function(t){this.hasData&&this.isMouseIn&&null!==this.xScale&&this.updateControlLineLocation(t)},s.prototype.onMouseLeave=function(){var t=this;this.mouseOutTimeout=setTimeout(function(){t.popup.isMouseIn()||(t.isMouseIn=!1,t.removeControlLine())},1)},s.prototype.onMouseDown=function(t){var e=this;setTimeout(function(){e.showPopupDialog(t)},1)},s.prototype.onMouseUp=function(t){this.popup.hide(),t.preventDefault()},s.prototype.showPopupDialog=function(t){var e,s;this.isMouseIn&&null!==this.currentControlIndex&&(e=!1,!(s=this).isRaceGraph||1!==t.which&&3!==t.which?1===t.which?(this.popupUpdateFunc=function(){s.popup.setData(s.getFastestSplitsPopupData(),!1)},e=!0):3===t.which&&this.hasControls&&(this.popupUpdateFunc=function(){s.popup.setData(s.getFastestSplitsForCurrentLegPopupData(),!0)},e=!0):this.hasControls&&(this.setCurrentChartTime(t),this.popupUpdateFunc=function(){s.popup.setData(s.getResultsVisitingCurrentControlPopupData(),!0)},e=!0),e&&(this.updatePopupContents(t),this.popup.show(this.getPopupLocation(t))))},s.prototype.updatePopupContents=function(t){t=t.pageY-$(this.svg.node()).offset().top;this.hasControls&&t<e?this.updateNextControlInformation():this.popupUpdateFunc()},s.prototype.updateNextControlInformation=function(){this.hasControls&&this.popup.setNextControlData(this.getNextControlData())},s.prototype.drawControlLine=function(t){this.currentControlIndex=t,this.updateResultStatistics();t=this.xScale(this.referenceCumTimes[t]);this.controlLine=this.svgGroup.append("line").attr("x1",t).attr("y1",0).attr("x2",t).attr("y2",this.contentHeight).attr("class","controlLine").node()},s.prototype.updateControlLineLocation=function(t){var e=$(this.svg.node()),s=e.offset(),n=t.pageX-s.left,s=t.pageY-s.top;this.currentLeftMargin<=n&&n<e.width()-i&&s<e.height()-r?(s=this.xScale.invert(n-this.currentLeftMargin),s=(e=d3.bisect(this.referenceCumTimesSorted,s))>=this.referenceCumTimesSorted.length?this.referenceCumTimesSorted.length-1:(n=Math.abs(this.referenceCumTimesSorted[e]-s),Math.abs(s-this.referenceCumTimesSorted[e-1])<n?e-1:e),n=this.referenceCumTimeIndexes[s],null!==this.actualControlIndex&&this.actualControlIndex===n||(this.removeControlLine(),this.actualControlIndex=n,this.drawControlLine(Math.max(this.minViewableControl,n))),this.popup.isShown()&&null!==this.currentControlIndex&&(this.isRaceGraph&&this.setCurrentChartTime(t),this.updatePopupContents(t),this.popup.setLocation(this.getPopupLocation(t)))):(this.removeControlLine(),this.popup.hide())},s.prototype.removeControlLine=function(){this.currentControlIndex=null,this.actualControlIndex=null,this.updateResultStatistics(),null!==this.controlLine&&(d3.select(this.controlLine).remove(),this.controlLine=null)},s.prototype.getTimesBehindFastest=function(e,t){var t=t.map(function(t){return this.courseClassSet.allResults[t]},this),s=this.fastestCumTimes[e]-this.fastestCumTimes[e-1];return t.map(function(t){t=t.getSplitTimeTo(e);return null===t?null:t-s})},s.prototype.getTimeLosses=function(e,t){return t.map(function(t){return this.courseClassSet.allResults[t]},this).map(function(t){return t.getTimeLossAt(e)})},s.prototype.updateResultStatistics=function(){var t,e,s,n=this.selectedIndexesOrderedByLastYValue.map(function(t){return this.courseClassSet.allResults[t]},this),i=n.map(function(t){return f(t.getOwnerNameForLeg(this.selectedLegIndex),g(t))},this);null!==this.currentControlIndex&&0<this.currentControlIndex&&(t=n.map(function(t){return t.isOKDespiteMissingTimes}),this.visibleStatistics.TotalTime&&(s=n.map(function(t){return t.getCumulativeTimeTo(this.currentControlIndex)},this),e=n.map(function(t){return t.getCumulativeRankTo(this.currentControlIndex)},this),i=d3.zip(i,s,e,t).map(function(t){return t[0]+m(t[1],t[2],t[3])})),this.visibleStatistics.SplitTime&&(s=n.map(function(t){return t.getSplitTimeTo(this.currentControlIndex)},this),e=n.map(function(t){return t.getSplitRankTo(this.currentControlIndex)},this),i=d3.zip(i,s,e,t).map(function(t){return t[0]+m(t[1],t[2],t[3])})),this.visibleStatistics.BehindFastest&&(n=this.getTimesBehindFastest(this.currentControlIndex,this.selectedIndexesOrderedByLastYValue),i=d3.zip(i,n,t).map(function(t){return t[0]+l+u(t[2]&&null===t[1]?NaN:t[1])})),this.visibleStatistics.TimeLoss&&(s=this.getTimeLosses(this.currentControlIndex,this.selectedIndexesOrderedByLastYValue),i=d3.zip(i,s).map(function(t){return t[0]+l+u(t[1])}))),this.hasData&&this.currentResultData.forEach(function(t,e){t.label=i[e]}),d3.selectAll("text.resultLabel").text(function(t){return t.label})},s.prototype.getTickFormatter=function(){var s=this;if(this.courseClassSet.hasTeamData()){var n=[c("StartNameShort")],t=this.courseClassSet.classes[0].numbersOfControls;null!==this.selectedLegIndex&&(t=[t[this.selectedLegIndex]]);for(var e=0;e<t.length;e+=1){for(var i=1;i<=t[e];i+=1)n.push(i.toString());n.push(c("FinishNameShort"))}return function(t,e){return n[e]}}return function(t,e){return 0===e?c("StartNameShort"):e===s.numControls+1?c("FinishNameShort"):e.toString()}},s.prototype.getTextWidth=function(t){return this.textSizeElement.text(t).node().getBBox().width},s.prototype.getTextHeight=function(t){return this.textSizeElement.text(t).node().getBBox().height},s.prototype.getMaxGraphEndTextWidth=function(){var t;return 0===this.selectedIndexes.length?0:(t=this.selectedIndexes.map(function(t){t=this.courseClassSet.allResults[t];return this.getTextWidth(f(t.getOwnerNameForLeg(this.selectedLegIndex),g(t)))},this),d3.max(t)+this.determineMaxStatisticTextWidth())},s.prototype.getMaxTimeAndRankTextWidth=function(s,n){var i=0,r=0,o=this.selectedIndexes.map(function(t){return this.courseClassSet.allResults[t]},this),t=(d3.range(1,this.numControls+2).forEach(function(e){var t=o.map(function(t){return t[s](e)}),t=(i=Math.max(i,C(t)),o.map(function(t){return t[n](e)}));r=Math.max(r,C(t))}),m(i,r));return this.getTextWidth(t)},s.prototype.getMaxSplitTimeAndRankTextWidth=function(){return this.getMaxTimeAndRankTextWidth("getSplitTimeTo","getSplitRankTo")},s.prototype.getMaxCumulativeTimeAndRankTextWidth=function(){return this.getMaxTimeAndRankTextWidth("getCumulativeTimeTo","getCumulativeRankTo")},s.prototype.getMaxTimeBehindFastestWidth=function(){for(var t=0,e=1;e<=this.numControls+1;e+=1)var s=this.getTimesBehindFastest(e,this.selectedIndexes),t=Math.max(t,C(s));return this.getTextWidth(l+u(t))},s.prototype.getMaxTimeLossWidth=function(){for(var t=0,e=0,s=1;s<=this.numControls+1;s+=1){var n=this.getTimeLosses(s,this.selectedIndexes).filter(p);0<n.length&&(t=Math.max(t,d3.max(n)),e=Math.min(e,d3.min(n)))}return Math.max(this.getTextWidth(l+u(t)),this.getTextWidth(l+u(e)))},s.prototype.determineMaxStatisticTextWidth=function(){var t=0;return this.visibleStatistics.TotalTime&&(t+=this.getMaxCumulativeTimeAndRankTextWidth()),this.visibleStatistics.SplitTime&&(t+=this.getMaxSplitTimeAndRankTextWidth()),this.visibleStatistics.BehindFastest&&(t+=this.getMaxTimeBehindFastestWidth()),this.visibleStatistics.TimeLoss&&(t+=this.getMaxTimeLossWidth()),t},s.prototype.determineMaxStartTimeLabelWidth=function(t){t=0<t.resultNames.length?d3.max(t.resultNames.map(function(t){return this.getTextWidth("00:00:00 "+t)},this)):0;return t},s.prototype.createScales=function(t){this.xScale=d3.scaleLinear().domain(t.xExtent).range([0,this.contentWidth]),this.yScale=d3.scaleLinear().domain(t.yExtent).range([0,this.contentHeight]),this.xScaleMinutes=d3.scaleLinear().domain([t.xExtent[0]/60,t.xExtent[1]/60]).range([0,this.contentWidth])},s.prototype.drawBackgroundRectangles=function(){for(var e=this.courseClassSet.sliceForLegIndex(this.referenceCumTimes,this.selectedLegIndex),t=(e.sort(d3.ascending),1);t<e.length;)e[t]===e[t-1]?e.splice(t,1):t+=1;var s=this,n=this.svgGroup.selectAll("rect").data(d3.range(e.length-1)),i=(n.enter().append("rect"),[]),r=this.courseClassSet.hasTeamData()?this.courseClassSet.classes[0].numbersOfControls:[this.courseClassSet.numControls];this.courseClassSet.hasTeamData()&&null!==this.selectedLegIndex&&(r=[r[this.selectedLegIndex]]);for(var o=0;o<r.length;o+=1)for(var l=0;l<=r[o];l+=1)i.push(1+l%2+(o+(this.selectedLegIndex||0))%2*2);(n=this.svgGroup.selectAll("rect").data(d3.range(e.length-1))).attr("x",function(t){return s.xScale(e[t])}).attr("y",0).attr("width",function(t){return s.xScale(e[t+1])-s.xScale(e[t])}).attr("height",this.contentHeight).attr("class",function(t){return"background"+i[t]}),n.exit().remove()},s.prototype.determineYAxisTickFormatter=function(t){var s,n;return this.isRaceGraph?0===(s=0===t.dataColumns.length?[]:t.dataColumns[0].ys).length?function(t){return h(60*t)}:(n=this.yScale,function(e){return 10<=d3.min(s.map(function(t){return Math.abs(n(t)-n(e))}))?h(Math.round(60*e)):""}):null},s.prototype.drawAxes=function(t,e){var e=this.determineYAxisTickFormatter(e),s=d3.axisTop().scale(this.xScale).tickFormat(this.getTickFormatter()).tickValues(this.courseClassSet.sliceForLegIndex(this.referenceCumTimes,this.selectedLegIndex)),e=d3.axisLeft().scale(this.yScale).tickFormat(e),n=d3.axisBottom().scale(this.xScaleMinutes);this.svgGroup.selectAll("g.axis").remove(),this.svgGroup.append("g").attr("class","x axis").call(s),this.svgGroup.append("g").attr("class","y axis").call(e).append("text").attr("transform","rotate(-90)").attr("x",-(this.contentHeight-6)).attr("y",6).attr("dy",".71em").style("text-anchor","start").style("fill","black").text(t),this.svgGroup.append("g").attr("class","x axis").attr("transform","translate(0,"+this.contentHeight+")").call(n).append("text").attr("x",60).attr("y",-5).style("text-anchor","start").style("fill","black").text(c("LowerXAxisChartLabel"))},s.prototype.drawChartLines=function(o){var l=this;this.svgGroup.selectAll("path.graphLine").remove(),this.svgGroup.selectAll("line.aroundOmittedTimes").remove(),d3.range(this.numLines).forEach(function(e){function s(){l.highlight(l.selectedIndexes[e])}function n(){l.unhighlight()}var i,r=a[this.selectedIndexes[e]%a.length];this.svgGroup.append("path").attr("d",(i=e,(o.dataColumns.some(function(t){return p(t.ys[i])})?d3.line().x(function(t){return l.xScale(t.x)}).y(function(t){return l.yScale(t.ys[i])}).defined(function(t){return p(t.ys[i])}):d3.line().x(0).y(0).defined(function(t,e){return 0===e}))(o.dataColumns))).attr("stroke",r).attr("class","graphLine result"+this.selectedIndexes[e]).on("mouseenter",s).on("mouseleave",n).append("title").text(o.resultNames[e]),o.dubiousTimesInfo[e].forEach(function(t){this.svgGroup.append("line").attr("x1",this.xScale(o.dataColumns[t.start].x)).attr("y1",this.yScale(o.dataColumns[t.start].ys[e])).attr("x2",this.xScale(o.dataColumns[t.end].x)).attr("y2",this.yScale(o.dataColumns[t.end].ys[e])).attr("stroke",r).attr("class","aroundOmittedTimes result"+this.selectedIndexes[e]).on("mouseenter",s).on("mouseleave",n).append("title").text(o.resultNames[e])},this)},this)},s.prototype.highlight=function(t){this.svg.selectAll("path.graphLine.result"+t).classed("selected",!0),this.svg.selectAll("line.resultLegendLine.result"+t).classed("selected",!0),this.svg.selectAll("text.resultLabel.result"+t).classed("selected",!0),this.svg.selectAll("text.startLabel.result"+t).classed("selected",!0),this.svg.selectAll("line.aroundOmittedTimes.result"+t).classed("selected",!0)},s.prototype.unhighlight=function(){this.svg.selectAll("path.graphLine.selected").classed("selected",!1),this.svg.selectAll("line.resultLegendLine.selected").classed("selected",!1),this.svg.selectAll("text.resultLabel.selected").classed("selected",!1),this.svg.selectAll("text.startLabel.selected").classed("selected",!1),this.svg.selectAll("line.aroundOmittedTimes.selected").classed("selected",!1)},s.prototype.drawResultStartTimeLabels=function(s){var n=s.dataColumns[0],i=this,t=this.svgGroup.selectAll("text.startLabel").data(this.selectedIndexes);t.enter().append("text").classed("startLabel",!0),(t=this.svgGroup.selectAll("text.startLabel").data(this.selectedIndexes)).attr("x",-7).attr("y",function(t,e){return i.yScale(n.ys[e])+i.getTextHeight(s.resultNames[e])/4}).attr("class",function(t){return"startLabel result"+t}).on("mouseenter",function(t){i.highlight(t)}).on("mouseleave",function(){i.unhighlight()}).text(function(t,e){return h(Math.round(60*n.ys[e]))+" "+s.resultNames[e]}),t.exit().remove()},s.prototype.removeResultStartTimeLabels=function(){this.svgGroup.selectAll("text.startLabel").remove()},s.prototype.adjustResultLegendLabelsDownwardsIfNecessary=function(){for(var t=1;t<this.numLines;t+=1){var e=this.currentResultData[t-1],s=this.currentResultData[t];s.y<e.y+e.textHeight&&(s.y=e.y+e.textHeight)}},s.prototype.adjustResultLegendLabelsUpwardsIfNecessary=function(t){if(0<this.numLines&&this.currentResultData[this.numLines-1].y>this.contentHeight){this.currentResultData[this.numLines-1].y=Math.max(t,this.contentHeight);for(var e=this.numLines-2;0<=e;--e){var s=this.currentResultData[e+1],n=this.currentResultData[e];if(!(n.y+n.textHeight>s.y))break;n.y=s.y-n.textHeight}}},s.prototype.drawResultLegendLabels=function(t){var i=0;if(0===t.dataColumns.length)this.currentResultData=[];else for(var r=t.dataColumns[t.dataColumns.length-1],e=(this.currentResultData=d3.range(this.numLines).map(function(t){var e=this.selectedIndexes[t],s=this.courseClassSet.allResults[e].getOwnerNameForLeg(this.selectedLegIndex),n=this.getTextHeight(s);return i+=n,{label:f(s,g(this.courseClassSet.allResults[e])),textHeight:n,y:p(r.ys[t])?this.yScale(r.ys[t]):null,colour:a[e%a.length],index:e}},this),i-=this.currentResultData[this.numLines-1].textHeight,null),s=this.numLines-1;0<=s;--s)null===this.currentResultData[s].y&&(this.currentResultData[s].y=null===e?this.contentHeight:e-this.currentResultData[s].textHeight,e=this.currentResultData[s].y);this.currentResultData.sort(function(t,e){return t.y-e.y}),this.selectedIndexesOrderedByLastYValue=this.currentResultData.map(function(t){return t.index}),this.adjustResultLegendLabelsDownwardsIfNecessary(),this.adjustResultLegendLabelsUpwardsIfNecessary(i);var t=this.svgGroup.selectAll("line.resultLegendLine").data(this.currentResultData),n=(t.enter().append("line").classed("resultLegendLine",!0),this),t=((t=this.svgGroup.selectAll("line.resultLegendLine").data(this.currentResultData)).attr("x1",this.contentWidth+1).attr("y1",function(t){return t.y}).attr("x2",this.contentWidth+10+1).attr("y2",function(t){return t.y}).attr("stroke",function(t){return t.colour}).attr("class",function(t){return"resultLegendLine result"+t.index}).on("mouseenter",function(t){n.highlight(t.index)}).on("mouseleave",function(){n.unhighlight()}),t.exit().remove(),this.svgGroup.selectAll("text.resultLabel").data(this.currentResultData));t.enter().append("text").classed("resultLabel",!0),(t=this.svgGroup.selectAll("text.resultLabel").data(this.currentResultData)).attr("x",this.contentWidth+10+2).attr("y",function(t){return t.y+t.textHeight/4}).attr("class",function(t){return"resultLabel result"+t.index}).on("mouseenter",function(t){n.highlight(t.index)}).on("mouseleave",function(){n.unhighlight()}).text(function(t){return t.label}),t.exit().remove()},s.prototype.adjustContentSize=function(){var t=this.getMaxGraphEndTextWidth();this.setLeftMargin(Math.max(this.maxStartTimeLabelWidth+8,o)),this.contentWidth=Math.max(this.overallWidth-this.currentLeftMargin-i-t-12,100),this.contentHeight=Math.max(this.overallHeight-e-r,100)},s.prototype.setSize=function(t,e){this.overallWidth=t,this.overallHeight=e,$(this.svg.node()).width(t).height(e),this.adjustContentSize()},s.prototype.clearGraph=function(){this.svgGroup.selectAll("*").remove()},s.prototype.sortReferenceCumTimes=function(){var s=d3.map();this.referenceCumTimes.forEach(function(t,e){s.has(t)||s.set(t,e)}),this.referenceCumTimesSorted=this.referenceCumTimes.slice(0),this.referenceCumTimesSorted.sort(d3.ascending);for(var t=this.referenceCumTimesSorted.length-1;0<t;--t)this.referenceCumTimesSorted[t]===this.referenceCumTimesSorted[t-1]&&this.referenceCumTimesSorted.splice(t,1);this.referenceCumTimeIndexes=this.referenceCumTimesSorted.map(function(t){return s.get(t)})},s.prototype.drawChart=function(t,e,s,n,i){var r=t.chartData;this.numControls=r.numControls,this.numLines=r.resultNames.length,this.selectedIndexes=e,this.referenceCumTimes=t.referenceCumTimes,this.fastestCumTimes=t.fastestCumTimes,this.eventData=t.eventData,this.courseClassSet=t.courseClassSet,this.hasControls=t.courseClassSet.getCourse().hasControls(),this.isRaceGraph=n.isRaceGraph,this.minViewableControl=n.minViewableControl,this.visibleStatistics=s,this.selectedLegIndex=i,this.hasData=!0,this.maxStatisticTextWidth=this.determineMaxStatisticTextWidth(),this.maxStartTimeLabelWidth=this.isRaceGraph?this.determineMaxStartTimeLabelWidth(r):0,this.sortReferenceCumTimes(),this.adjustContentSize(),this.createScales(r),this.drawBackgroundRectangles(),this.drawAxes(c(n.yAxisLabelKey),r),this.drawChartLines(r),this.drawResultLegendLabels(r),this.removeControlLine(),this.isRaceGraph?this.drawResultStartTimeLabels(r):this.removeResultStartTimeLabels()},SplitsBrowser.Controls.Chart=s}(),function(){"use strict";var v=SplitsBrowser.formatTime,y=SplitsBrowser.Model.compareResults,T=SplitsBrowser.getMessage,x=SplitsBrowser.getMessageWithFormatting,w=SplitsBrowser.subtractIfNotNull,b=SplitsBrowser.isNotNullNorNaN;function t(t){this.parent=t,this.courseClass=null,this.div=null,this.headerSpan=null,this.table=null,this.selectedLegIndex=null,this.buildTable()}function L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t,e,s){return null===t&&s?"??:??":v(t,e)}t.prototype.buildTable=function(){this.div=d3.select(this.parent).append("div").attr("id","resultsTableContainer"),this.headerSpan=this.div.append("div").append("span").classed("resultsTableHeader",!0),this.table=this.div.append("table").classed("resultsTable",!0),this.table.append("thead").append("tr"),this.table.append("tbody")},t.prototype.populateTable=function(){var n,t,e,s=this.courseClass.name+", ",i=this.courseClass.isTeamClass&&null!==this.selectedLegIndex?(n=this.courseClass.numbersOfControls[this.selectedLegIndex],this.courseClass.offsets[this.selectedLegIndex]):(n=this.courseClass.numControls,0),r=(this.courseClass.isTeamClass&&null!==this.selectedLegIndex&&(s+=x("ShowLeg",{$$LEG_NUMBER$$:this.selectedLegIndex+1})+", "),this.courseClass.isTeamClass&&null===this.selectedLegIndex?(r=this.courseClass.numbersOfControls.join(" + "),s+=x("ResultsTableHeaderMultipleControls",{$$NUM$$:r})):s+=1===n?T("ResultsTableHeaderSingleControl"):x("ResultsTableHeaderMultipleControls",{$$NUM$$:n}),this.courseClass.course),o=(null!==r.length&&(s+=", "+x("ResultsTableHeaderCourseLength",{$$DISTANCE$$:r.length.toFixed(1)})),null!==r.climb&&(s+=", "+x("ResultsTableHeaderClimb",{$$CLIMB$$:r.climb})),this.headerSpan.text(s),[T("ResultsTableHeaderControlNumber"),T("ResultsTableHeaderName"),T("ResultsTableHeaderTime")]),l=this.courseClass.course.controls;if(this.courseClass.isTeamClass)if(null===this.selectedLegIndex)for(var a=0;a<this.courseClass.numbersOfControls.length;a+=1){var u="-"+(a+1);if(null===l)for(t=1;t<=this.courseClass.numbersOfControls[a];t+=1)o.push(t+u);else for(t=1;t<=this.courseClass.numbersOfControls[a];t+=1)e=l[this.courseClass.offsets[a]+t-1],o.push(t+u+" ("+e+")");o.push(T("FinishName")+u)}else{if(null===l)for(t=1;t<=this.courseClass.numbersOfControls[this.selectedLegIndex];t+=1)o.push(t);else for(t=1;t<=this.courseClass.numbersOfControls[this.selectedLegIndex];t+=1)e=l[this.courseClass.offsets[this.selectedLegIndex]+t-1],o.push(t+" ("+e+")");o.push(T("FinishName"))}else(o=null===l?o.concat(d3.range(1,n+1)):o.concat(l.map(function(t,e){return e+1+" ("+t+")"}))).push(T("FinishName"));var r=this.table.select("thead tr").selectAll("th").data(o),h=(r.enter().append("th"),r.exit().remove(),(r=this.table.select("thead tr").selectAll("th").data(o)).text(function(t){return t}),[]);function c(t,e,s){var n=[];return t&&n.push("fastest"),e&&n.push("dubious"),s&&n.push("missing"),n.join(" ")}function p(t,e,s,n,i,r){h.push("<td"),s&&h.push(' class="'+s+'"'),r&&h.push(' title="'+L(r)+'"'),h.push("><span"),""!==n&&h.push(' class="'+n+'"'),h.push(">"),h.push(L(t)),h.push("</span><br><span"),""!==i&&h.push(' class="'+i+'"'),h.push(">"),h.push(L(e)),h.push("</span></td>\n")}var d,m,f=this.courseClass.results.slice(0),g=(f.sort(y),0),C=0,S=(d=0,m=1,f.forEach(function(t){t.getAllOriginalCumulativeTimes().forEach(function(t){if(b(t))for(;d<2&&Math.abs(t-Math.round(t*m)/m)>1e-7*Math.abs(t);)d+=1,m*=10})}),d);f.forEach(function(a,t){h.push("<tr><td>"),a.isNonCompetitive?(h.push(L(T("NonCompetitiveShort"))),g+=1):a.completed()&&(0!==t&&f[t-1].totalTime===a.totalTime||(C=t+1-g),h.push(""+C)),h.push("</td>"),t=this.courseClass.isTeamClass&&null===this.selectedLegIndex?a.owner.members.map(function(t){return t.name}).join("\n"):"";var e,s,u=a.getOriginalCumulativeTimeTo(i),t=(p(a.getOwnerNameForLeg(this.selectedLegIndex),a.owner.club,null,"","",t),this.courseClass.isTeamClass&&null!==this.selectedLegIndex?w(a.getOriginalCumulativeTimeTo(i+n+1),u):a.totalTime);p((t=t,s=S,(e=a).isNonStarter?T("DidNotStartShort"):e.isNonFinisher?T("DidNotFinishShort"):e.isDisqualified?T("DisqualifiedShort"):e.isOverMaxTime?T("OverMaxTimeShort"):e.completed()?v(t,s):T("MispunchedShort"))," ","time","","",""),d3.range(i+1,i+n+2).forEach(function(t){var e=w(a.getOriginalCumulativeTimeTo(t),u),s=a.getOriginalSplitTimeTo(t),n=D(e,S,a.isOKDespiteMissingTimes),i=D(s,S,a.isOKDespiteMissingTimes),r=1===a.getCumulativeRankTo(t),o=1===a.getSplitRankTo(t),l=a.isCumulativeTimeDubious(t),t=a.isSplitTimeDubious(t),e=a.isOKDespiteMissingTimes&&null===e,s=a.isOKDespiteMissingTimes&&null===s;p(n,i,"time",c(r,l,e),c(o,t,s),"")}),h.push("</tr>\n")},this),this.table.select("tbody").node().innerHTML=h.join("")},t.prototype.setClass=function(t){this.courseClass=t,(this.selectedLegIndex=null)!==this.courseClass&&this.populateTable()},t.prototype.setSelectedLegIndex=function(t){this.selectedLegIndex=t,null!==this.courseClass&&this.populateTable()},t.prototype.show=function(){this.div.style("display",null)},t.prototype.hide=function(){this.div.style("display","none")},t.prototype.retranslate=function(){this.populateTable()},SplitsBrowser.Controls.ResultsTable=t}(),function(){"use strict";var i=SplitsBrowser.isNaNStrict,h=SplitsBrowser.hasProperty,c=SplitsBrowser.Model.ChartTypes,r=SplitsBrowser.Model.CourseClassSet;function p(t,e){return t.replace(new RegExp(e.source,"g"),"")}var d=/(?:^|&|\?)class=([^&]+)/;var m=/(?:^|&|\?)chartType=([^&]+)/;var f=/(?:^|&|\?)compareWith=([^&]+)/,g=["Winner","FastestTime","FastestTimePlus5","FastestTimePlus25","FastestTimePlus50","FastestTimePlus100"];var C=/(?:^|&|\?)selected=([^&]+)/;var S=/(?:^|&|\?)stats=([^&]*)/,v=["TotalTime","SplitTime","BehindFastest","TimeLoss"];var y=/(?:^|&|\?)showOriginal=([^&]*)/;var T=/(?:^|&|\?)selectedLeg=([^&]*)/;var x=/(?:^|&|\?)filterText=([^&]*)/;SplitsBrowser.parseQueryString=function(t,e){var s,n=function(t,e){if(null===(t=d.exec(t)))return null;for(var s=d3.map(),n=0;n<e.classes.length;n+=1)s.set(e.classes[n].name,e.classes[n]);var i,t=decodeURIComponent(t[1]).split(";");return 0===(t=(t=d3.set(t).values()).filter(function(t){return s.has(t)}).map(function(t){return s.get(t)})).length?null:(i=t[0].course,t=t.filter(function(t){return t.course===i}),new r(t))}(t,e);return{classes:null===n?null:n.classes.map(function(t){return e.classes.indexOf(t)}),chartType:(s=t,null===(s=m.exec(s))?null:(s=s[1],h(c,s)?c[s]:null)),compareWith:function(t,e){if(null===(t=f.exec(t)))return null;var s=decodeURIComponent(t[1]);if(1<=(t=g.indexOf(s)))return{index:t,result:null};if(0===t&&null!==e)return e.allResults.some(function(t){return t.completed()})?{index:0,result:null}:null;if(null===e)return null;for(var n=0;n<e.allResults.length;n+=1){var i=e.allResults[n];if(i.owner.name===s&&i.completed())return{index:g.length,result:i}}return null}(t,n),selected:function(t,e){if(null===e)return null;if(null===(t=C.exec(t)))return null;if(0<=(t=decodeURIComponent(t[1]).split(";")).indexOf("*"))return d3.range(0,e.allResults.length);var t=d3.set(t).values(),s=e.allResults.map(function(t){return t.owner.name}),n=[];return t.forEach(function(t){t=s.indexOf(t);0<=t&&n.push(t)}),n.sort(d3.ascending),0===n.length?null:n}(t,n),stats:function(t){if(null===(t=S.exec(t)))return null;var e=decodeURIComponent(t[1]).split(";"),s={};v.forEach(function(t){s[t]=!1});for(var n=0;n<e.length;n+=1){var i=e[n];if(h(s,i))s[i]=!0;else if(""!==i)return null}return s}(t),showOriginal:(s=t,null!==(s=y.exec(s))&&"1"===s[1]),selectedLeg:(n=t,null===(n=T.exec(n))?null:(n=parseInt(n[1],10),i(n)?null:n)),filterText:(s=t,null===(s=x.exec(s))?"":decodeURIComponent(s[1]))}},SplitsBrowser.formatQueryString=function(t,e,s,n){var i,r,o,l,a,u;return a=t,i=e,e=n.classes,a=p(a,d),e=e.map(function(t){return i.classes[t].name}),t=function(t,e){for(var s in t=p(t,m),c)if(h(c,s)&&c[s]===e)return t+"&chartType="+encodeURIComponent(s);return t}(t=a+"&class="+encodeURIComponent(e.join(";")),n.chartType),a=t,e=n.compareWith.index,l=n.compareWith.result,a=p(a,f),u=null,"number"==typeof e&&0<=e&&e<g.length?u=g[e]:null!==l&&(u=l.owner.name),t=null===u?a:a+"&compareWith="+encodeURIComponent(u),e=t,r=s,l=n.selected,
e=p(e,C),t=0===(l=l.map(function(t){return r.allResults[t]})).length?e:l.length===r.allResults.length?e+"&selected=*":(l=l.map(function(t){return t.owner.name}).join(";"),e+"&selected="+encodeURIComponent(l)),a=t,o=n.stats,a=p(a,S),u=v.filter(function(t){return h(o,t)&&o[t]}),t=a+"&stats="+encodeURIComponent(u.join(";")),s=t,e=n.showOriginal,s=p(s,y),l=t=e?s+"&showOriginal=1":s,a=n.selectedLeg,l=p(l,T),t=null===a?l:l+"&selectedLeg="+encodeURIComponent(a),u=t,e=n.filterText,u=p(u,x),t=(t=""===e?u:u+"&filterText="+encodeURIComponent(e)).replace(/^\??&/,"")}}(),function(){"use strict";var t=SplitsBrowser.getMessage;function e(t){this.parent=t,this.warnings=[],this.containerDiv=t.append("div").classed("topRowStart",!0).attr("id","warningViewerContainer").style("display","none"),this.containerDiv.append("div").classed("topRowStartSpacer",!0),this.warningTriangle=this.createWarningTriangle(this.containerDiv),this.warningList=t.append("div").classed("warningList",!0).classed("transient",!0).style("position","absolute").style("display","none");var s=this;$(document).click(function(t){var e;"none"===s.warningList.style("display")||(e=$("div#warningTriangleContainer,div.warningList")).is(t.target)||0!==e.has(t.target).length||s.warningList.style("display","none")}),this.setMessages()}e.prototype.setMessages=function(){this.containerDiv.attr("title",t("WarningsTooltip"))},e.prototype.createWarningTriangle=function(){var t=this.containerDiv.append("div").attr("id","warningTriangleContainer"),e=t.append("svg"),s=(e.style("width","21px").style("height","19px").style("margin-bottom","-3px"),e.append("polygon").attr("points","1,18 10,0 19,18").style("stroke","black").style("stroke-width","1.5px").style("fill","#ffd426"),e.append("text").attr("x",10).attr("y",16).attr("text-anchor","middle").style("font-size","14px").text("!"),this);return t.on("click",function(){s.showHideErrorList()}),e},e.prototype.setWarnings=function(t){var e=this.warningList.selectAll("div").data(t);e.enter().append("div").classed("warning",!0),(e=this.warningList.selectAll("div").data(t)).text(function(t){return t}),e.exit().remove(),this.containerDiv.style("display",t&&0<t.length?"block":"none")},e.prototype.showHideErrorList=function(){var t,e,s;"none"===this.warningList.style("display")?(t=$(this.warningTriangle.node()).offset(),e=$(this.warningTriangle.node()).outerHeight(),s=$(this.warningList.node()).outerWidth(),this.warningList.style("left",Math.max(t.left-s/2,0)+"px").style("top",t.top+e+5+"px").style("display","block")):this.warningList.style("display","none")},SplitsBrowser.Controls.WarningViewer=e}(),function(){"use strict";var t=SplitsBrowser.Version,n=SplitsBrowser.getMessage,e=SplitsBrowser.tryGetMessage,i=SplitsBrowser.getMessageWithFormatting,r=SplitsBrowser.initialiseMessages,s=SplitsBrowser.Model,o=s.ResultSelection,l=s.CourseClassSet,a=s.ChartTypes,u=SplitsBrowser.Input.parseEventData,h=SplitsBrowser.DataRepair.repairEventData,c=SplitsBrowser.DataRepair.transferResultData,p=SplitsBrowser.parseQueryString,d=SplitsBrowser.formatQueryString,s=SplitsBrowser.Controls,m=s.LanguageSelector,f=s.ClassSelector,g=s.ChartTypeSelector,C=s.ComparisonSelector,S=s.OriginalDataSelector,v=s.LegSelector,y=s.StatisticsSelector,T=s.WarningViewer,x=s.ResultList,w=s.Chart,b=s.ResultsTable;function L(){if(window.d3){if(!(parseFloat(d3.version)<4))return 1;alert("D3 version "+d3.version+" was found. SplitsBrowser requires D3 version 4 or later.")}else alert("D3 was not found. SplitsBrowser requires D3 version 4 or later.")}function D(t){this.options=t,this.eventData=null,this.classes=null,this.currentClasses=[],this.chartData=null,this.referenceCumTimes=null,this.fastestCumTimes=null,this.previousResultList=[],this.topBarHeight=t&&t.topBar&&0<$(t.topBar).length?$(t.topBar).outerHeight(!0):0,this.selection=null,this.courseClassSet=null,this.languageSelector=null,this.classSelector=null,this.comparisonSelector=null,this.originalDataSelector=null,this.legSelector=null,this.statisticsSelector=null,this.resultList=null,this.warningViewer=null,this.chart=null,this.topPanel=null,this.mainPanel=null,this.buttonsPanel=null,this.resultListContainer=null,this.container=null,this.currentResizeTimeout=null}function R(t){alert(t)}function I(){alert(n("RaceGraphDisabledAsStartTimesMissing"))}function N(t,e){var s=d3.select("body").append("div").classed("sbErrors",!0);s.append("h1").text(n("LoadFailedHeader")),s.append("p").text(i(t,e))}function O(t,e,s){N("LoadFailedReadError",{$$ERROR$$:s})}D.prototype.enableOrDisableRaceGraph=function(){var t=this.courseClassSet.allResults.some(function(t){return t.lacksStartTime()});this.chartTypeSelector.setRaceGraphDisabledNotifier(t?I:null)},D.prototype.setEvent=function(t){this.eventData=t,this.classes=t.classes,null!==this.classSelector&&this.classSelector.setClasses(this.classes),this.warningViewer.setWarnings(t.warnings)},D.prototype.drawLogo=function(){this.logoSvg=this.topPanel.append("svg").classed("topRowStart",!0),this.logoSvg.style("width","19px").style("height","19px").style("margin-bottom","-3px"),this.logoSvg.append("rect").attr("x","0").attr("y","0").attr("width","19").attr("height","19").attr("fill","white"),this.logoSvg.append("polygon").attr("points","0,19 19,0 19,19").attr("fill","red"),this.logoSvg.append("polyline").attr("points","0.5,0.5 0.5,18.5 18.5,18.5 18.5,0.5 0.5,0.5 0.5,18.5").attr("stroke","black").attr("fill","none"),this.logoSvg.append("polyline").attr("points","1,12 5,8 8,14 17,11").attr("fill","none").attr("stroke","blue").attr("stroke-width","2"),this.logoSvg.selectAll("*").append("title"),this.setLogoMessages()},D.prototype.setLogoMessages=function(){this.logoSvg.selectAll("title").text(i("ApplicationVersion",{$$VERSION$$:t}))},D.prototype.addSpacer=function(){this.topPanel.append("div").classed("topRowStartSpacer",!0)},D.prototype.addLanguageSelector=function(){this.languageSelector=new m(this.topPanel.node())},D.prototype.addClassSelector=function(){this.classSelector=new f(this.topPanel.node()),null!==this.classes&&this.classSelector.setClasses(this.classes)},D.prototype.addChartTypeSelector=function(){var t=[a.SplitsGraph,a.RaceGraph,a.PositionAfterLeg,a.SplitPosition,a.PercentBehind,a.ResultsTable];this.chartTypeSelector=new g(this.topPanel.node(),t)},D.prototype.addComparisonSelector=function(){this.comparisonSelector=new C(this.topPanel.node(),R),null!==this.classes&&this.comparisonSelector.setClasses(this.classes)},D.prototype.addOriginalDataSelector=function(){this.originalDataSelector=new S(this.topPanel)},D.prototype.addLegSelector=function(){this.legSelector=new v(this.topPanel)},D.prototype.addDirectLink=function(){this.directLink=this.topPanel.append("a").classed("topRowStart",!0).attr("id","directLinkAnchor").attr("href",document.location.href),this.setDirectLinkMessages()},D.prototype.addWarningViewer=function(){this.warningViewer=new T(this.topPanel)},D.prototype.setDirectLinkMessages=function(){this.directLink.attr("title",e("DirectLinkToolTip","")).text(n("DirectLink"))},D.prototype.updateDirectLink=function(){var t={classes:this.classSelector.getSelectedClasses(),chartType:this.chartTypeSelector.getChartType(),compareWith:this.comparisonSelector.getComparisonType(),selected:this.selection.getSelectedIndexes(),stats:this.statisticsSelector.getVisibleStatistics(),showOriginal:this.courseClassSet.hasDubiousData()&&this.originalDataSelector.isOriginalDataSelected(),selectedLeg:this.legSelector.getSelectedLeg(),filterText:this.resultList.getFilterText()},e=document.location.search,t=d(e,this.eventData,this.courseClassSet,t),s=document.location.href;this.directLink.attr("href",s.substring(0,s.length-e.length)+"?"+t.replace(/^\?+/,""))},D.prototype.addResultList=function(){this.resultList=new x(this.mainPanel.node(),R)},D.prototype.buildUi=function(){var t=d3.select("body"),e=(t.style("overflow","hidden"),this.container=t.append("div").attr("id","sbContainer"),this.topPanel=this.container.append("div"),this.drawLogo(),this.addLanguageSelector(),this.addSpacer(),this.addClassSelector(),this.addLegSelector(),this.addSpacer(),this.addChartTypeSelector(),this.addSpacer(),this.addComparisonSelector(),this.addOriginalDataSelector(),this.addSpacer(),this.addDirectLink(),this.addWarningViewer(),this.statisticsSelector=new y(this.topPanel.node()),this.topPanel.append("div").style("clear","both"),this.mainPanel=this.container.append("div"),this.addResultList(),this.chart=new w(this.mainPanel.node()),this.resultsTable=new b(this.container.node()),this.resultsTable.hide(),this);$(window).resize(function(){e.handleWindowResize()}),$("input:text").bind("selectstart",function(t){t.stopPropagation()}),$(this.container.node()).bind("selectstart",function(){return!1}),$(document).keydown(function(t){27===t.which&&e.hideTransientElements()})},D.prototype.registerChangeHandlers=function(){var e=this;this.languageSelector.registerChangeHandler(function(){e.retranslate()}),this.classSelector.registerChangeHandler(function(t){e.selectClasses(t)}),this.chartTypeSelector.registerChangeHandler(function(t){e.selectChartTypeAndRedraw(t)}),this.comparisonSelector.registerChangeHandler(function(t){e.selectComparison(t)}),this.originalDataSelector.registerChangeHandler(function(t){e.showOriginalOrRepairedData(t)}),this.legSelector.registerChangeHandler(function(){e.handleLegSelectionChanged()}),this.resultList.registerChangeHandler(function(){e.handleFilterTextChanged()})},D.prototype.handleWindowResize=function(){null!==this.currentResizeTimeout&&clearTimeout(this.currentResizeTimeout);var t=this;this.currentResizeTimeout=setTimeout(function(){t.postResizeHook()},100)},D.prototype.postResizeHook=function(){this.currentResizeTimeout=null,this.setResultListHeight(),this.setChartSize(),this.hideTransientElements(),this.redraw()},D.prototype.hideTransientElements=function(){d3.selectAll(".transient").style("display","none")},D.prototype.getHorizontalMargin=function(){var t=$("body"),e=$(this.container.node());return t.outerWidth(!0)-t.width()+(e.outerWidth()-e.width())},D.prototype.getVerticalMargin=function(){var t=$("body"),e=$(this.container.node());return t.outerHeight(!0)-t.height()+(e.outerHeight()-e.height())},D.prototype.getUsableHeight=function(){return $(window).outerHeight()-this.getVerticalMargin()-this.topBarHeight-$(this.topPanel.node()).height()},D.prototype.setResultListHeight=function(){this.resultList.setHeight(this.getUsableHeight())},D.prototype.setChartSize=function(){var t=this.getHorizontalMargin(),e=this.getVerticalMargin(),t=$(window).width()-t,e=$(window).height()-e-this.topBarHeight,e=($(this.container.node()).width(t).height(e),t-this.resultList.width()-2),t=this.getUsableHeight();this.chart.setSize(e,t)},D.prototype.drawChart=function(){var e,t,s;this.chartTypeSelector.getChartType().isResultsTable||(this.currentVisibleStatistics=this.statisticsSelector.getVisibleStatistics(),null!==this.selectionChangeHandler&&this.selection.deregisterChangeHandler(this.selectionChangeHandler),null!==this.statisticsChangeHandler&&this.statisticsSelector.deregisterChangeHandler(this.statisticsChangeHandler),(e=this).selectionChangeHandler=function(){e.resultList.enableOrDisableCrossingRunnersButton(),e.redraw(),e.updateDirectLink()},this.selection.registerChangeHandler(this.selectionChangeHandler),this.statisticsChangeHandler=function(t){e.currentVisibleStatistics=t,e.redraw(),e.updateDirectLink()},this.statisticsSelector.registerChangeHandler(this.statisticsChangeHandler),this.updateControlEnabledness(),0<this.classes.length&&(t=this.legSelector.getSelectedLeg(),s=this.comparisonSelector.getComparisonFunction(),this.referenceCumTimes=s(this.courseClassSet),this.fastestCumTimes=this.courseClassSet.getFastestCumTimes(t),this.chartData=this.courseClassSet.getChartData(this.referenceCumTimes,this.selection.getSelectedIndexes(),this.chartTypeSelector.getChartType(),t),this.redrawChart()))},D.prototype.redrawChart=function(){var t={chartData:this.chartData,eventData:this.eventData,courseClassSet:this.courseClassSet,referenceCumTimes:this.referenceCumTimes,fastestCumTimes:this.fastestCumTimes};this.chart.drawChart(t,this.selection.getSelectedIndexes(),this.currentVisibleStatistics,this.chartTypeSelector.getChartType(),this.legSelector.getSelectedLeg())},D.prototype.redraw=function(){var t=this.chartTypeSelector.getChartType();t.isResultsTable||(this.chartData=this.courseClassSet.getChartData(this.referenceCumTimes,this.selection.getSelectedIndexes(),t,this.legSelector.getSelectedLeg()),this.redrawChart())},D.prototype.retranslate=function(){this.setLogoMessages(),this.languageSelector.setMessages(),this.classSelector.retranslate(),this.chartTypeSelector.setMessages(),this.comparisonSelector.setMessages(),this.originalDataSelector.setMessages(),this.legSelector.setMessages(),this.setDirectLinkMessages(),this.statisticsSelector.setMessages(),this.warningViewer.setMessages(),this.resultList.retranslate(),this.resultsTable.retranslate(),this.chartTypeSelector.getChartType().isResultsTable||this.redrawChart()},D.prototype.setClasses=function(t){this.currentClasses=t.map(function(t){return this.classes[t]},this),this.courseClassSet=new l(this.currentClasses),this.comparisonSelector.setCourseClassSet(this.courseClassSet),this.resultsTable.setClass(0<this.currentClasses.length?this.currentClasses[0]:null),this.enableOrDisableRaceGraph(),this.originalDataSelector.setVisible(this.courseClassSet.hasDubiousData()),this.legSelector.setCourseClassSet(this.courseClassSet)},D.prototype.initClasses=function(t){this.classSelector.selectClasses(t),this.setClasses(t),this.resultList.setResultList(this.courseClassSet.allResults,1<this.currentClasses.length,this.courseClassSet.hasTeamData(),null),this.selection=new o(this.courseClassSet.allResults.length),this.resultList.setSelection(this.selection),this.previousResultList=this.courseClassSet.allResults},D.prototype.selectClasses=function(t){0<t.length&&0<this.currentClasses.length&&this.classes[t[0]]===this.currentClasses[0]||this.selection.selectNone(),this.setClasses(t),this.resultList.setResultList(this.courseClassSet.allResults,1<this.currentClasses.length,this.courseClassSet.hasTeamData(),null),this.selection.migrate(this.previousResultList,this.courseClassSet.allResults),this.resultList.selectionChanged(),this.chartTypeSelector.getChartType().isResultsTable||(this.setChartSize(),this.drawChart()),this.previousResultList=this.courseClassSet.allResults,this.updateDirectLink()},D.prototype.selectComparison=function(){this.drawChart(),this.updateDirectLink()},D.prototype.selectChartType=function(t){t.isResultsTable?(this.mainPanel.style("display","none"),this.container.style("width",null).style("height",null),d3.select("body").style("overflow",null),this.resultsTable.show()):(this.resultsTable.hide(),d3.select("body").style("overflow","hidden"),this.mainPanel.style("display",null),this.setChartSize()),this.updateControlEnabledness(),this.resultList.setChartType(t)},D.prototype.selectChartTypeAndRedraw=function(t){this.selectChartType(t),t.isResultsTable||(this.setResultListHeight(),this.drawChart()),this.updateDirectLink()},D.prototype.selectOriginalOrRepairedData=function(t){t?c(this.eventData):h(this.eventData,this.options&&this.options.permitZeroSplits),this.eventData.determineTimeLosses()},D.prototype.showOriginalOrRepairedData=function(t){this.selectOriginalOrRepairedData(t),this.drawChart(),this.updateDirectLink()},D.prototype.setSelectedLegIndex=function(){this.comparisonSelector.setSelectedLeg(this.legSelector.getSelectedLeg()),this.resultList.setResultList(this.courseClassSet.allResults,1<this.currentClasses.length,this.courseClassSet.hasTeamData(),this.legSelector.getSelectedLeg()),this.resultsTable.setSelectedLegIndex(this.legSelector.getSelectedLeg())},D.prototype.handleLegSelectionChanged=function(){this.setSelectedLegIndex(),this.setChartSize(),this.drawChart(),this.updateDirectLink()},D.prototype.handleFilterTextChanged=function(){this.setChartSize(),this.redraw(),this.updateDirectLink()},D.prototype.updateControlEnabledness=function(){var t=this.chartTypeSelector.getChartType();this.classSelector.setOtherClassesEnabled(!t.isResultsTable),this.comparisonSelector.setEnabled(!t.isResultsTable),this.statisticsSelector.setEnabled(!t.isResultsTable),this.originalDataSelector.setEnabled(!t.isResultsTable),this.resultList.enableOrDisableCrossingRunnersButton()},D.prototype.updateFromQueryString=function(t){null===t.classes?this.setDefaultSelectedClass():this.initClasses(t.classes),null!==t.chartType&&(this.chartTypeSelector.setChartType(t.chartType),this.selectChartType(t.chartType)),null!==t.compareWith&&this.comparisonSelector.setComparisonType(t.compareWith.index,t.compareWith.runner),null!==t.selected&&this.selection.setSelectedIndexes(t.selected),null!==t.stats&&this.statisticsSelector.setVisibleStatistics(t.stats),t.showOriginal&&this.courseClassSet.hasDubiousData()&&(this.originalDataSelector.selectOriginalData(),this.selectOriginalOrRepairedData(!0)),null!==t.selectedLeg&&(this.legSelector.setSelectedLeg(t.selectedLeg),this.setSelectedLegIndex()),""!==t.filterText&&this.resultList.setFilterText(t.filterText)},D.prototype.setDefaultSelectedClass=function(){this.initClasses(0<this.classes.length?[0]:[])},SplitsBrowser.Viewer=D,SplitsBrowser.readEvent=function(t,e){if(L()){var s;try{s=u(t,e&&e.relayMode||"allControls")}catch(t){if("InvalidData"===t.name)return void N("LoadFailedInvalidData",{$$MESSAGE$$:t.message});throw t}null===s?N("LoadFailedUnrecognisedData",{}):(s.needsRepair()&&h(s,e&&e.permitZeroSplits),"string"==typeof e&&(e={topBar:e}),s.determineTimeLosses(),e&&e.defaultLanguage&&r(e.defaultLanguage),(t=new D(e)).buildUi(),t.setEvent(s),null!==(e=document.location.search)&&0<e.length?(e=p(e,s),t.updateFromQueryString(e)):t.setDefaultSelectedClass(),t.setResultListHeight(),t.setChartSize(),t.drawChart(),t.registerChangeHandlers())}},SplitsBrowser.loadEvent=function(t,n){L()&&$.ajax({url:t,data:"",success:function(t,e){var s;t=t,s=n,"success"===(e=e)?SplitsBrowser.readEvent(t,s):N("LoadFailedStatusNotSuccess",{$$STATUS$$:e})},dataType:"text",error:O})}}();