function showDialog(n){n.find(".modal-body").get(0).style.maxHeight=window.innerHeight-220+"px",n.modal("show")}function showStaticDialog(n){n.modal({backdrop:"static"})}function wrapTemplate(n,t){ko.bindingHandlers[n]={init:function(){return ko.bindingHandlers.template.init.apply(this,arguments)},update:function(n,i,r,u,f){var e=function(){return{name:t,data:i()}};ko.bindingHandlers.template.update(n,e,r,u,f)}},ko.virtualElements.allowedBindings[n]=!0}function slideIn(n,t){n.animate({left:"-="+t,width:235},500)}function slideOut(n,t){n.animate({left:"+="+t,width:255},500)}function slideHideAll(){slideHideBasedOnClass(".second-level-tile"),slideHideBasedOnClass(".third-level-tile"),slideHideBasedOnClass(".fourth-level-tile")}function performSlide(n,t){n.hasClass("open")?(n.removeClass("open"),slideIn(n,t)):(n.addClass("open"),slideOut(n,t))}function slideHideBasedOnClass(n){var t=$(n);t.each(function(n){var i=t.eq(n);i.hasClass("open")&&performSlide(i,i.css("left").replace("px",""))})}function renderName(n,t,i,r,u){var e=u.isOwner?u.category=="Coach"?"/2/images/coach.png":"/Members/user12.png":"/Members/user8.png",f='<img src="'+e+'" alt=""/> ';return i==null?f:f+(i+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function SelectEditor(n){var t,i,r=this;this.init=function(){t=$("<select tabIndex='0' class='editor-yesno' style='width:100%;'><option value=''><\/option><option value='Male'>Male<\/option><option value='Female'>Female<\/option><\/select>"),t.appendTo(n.container),t.focus()},this.destroy=function(){t.remove()},this.focus=function(){t.focus()},this.loadValue=function(r){t.val(i=r[n.column.field]),t.select()},this.serializeValue=function(){return t.val()},this.applyValue=function(t,i){t[n.column.field]=i},this.isValueChanged=function(){return t.val()!=i},this.validate=function(){return{valid:!0,msg:null}},this.init()}function SelectEditor2(n,t){return function(i){var r,u,f=this;this.init=function(){var u,f,e=ko.unwrap(t),o;_.any(e,function(n){return n.type=="TestingBattery"})?(u=_.map(_.filter(e,function(n){return n.type=="TestingBattery"}),function(t){var i=t[n.displaySource||"title"]||"";return t.type=="TestingBattery"&&(i="*"+i),"<option value='"+t[n.idSource||"id"]+"'>"+i.encodeHTML()+"<\/option>"}),f=u.join(""),u=_.map(_.filter(e,function(n){return n.type!="TestingBattery"}),function(t){var i=t[n.displaySource||"title"]||"";return t.type=="TestingBattery"&&(i="*"+i),"<option value='"+t[n.idSource||"id"]+"'>"+i.encodeHTML()+"<\/option>"}),o=u.join(""),r=$("<select tabIndex='0' class='editor-yesno' style='width:100%;'><option value=''><\/option><optgroup label=\"Batteries\"><\/optgroup>"+f+'<optgroup label="Tests"><\/optgroup>'+o+"<\/select>")):(u=_.map(e,function(t){var i=t[n.displaySource||"title"]||"";return"<option value='"+t[n.idSource||"id"]+"'>"+i.encodeHTML()+"<\/option>"}),f=u.join(""),r=$("<select tabIndex='0' class='editor-yesno' style='width:100%;'><option value=''><\/option>"+f+"<\/select>")),r.appendTo(i.container),r.focus()},this.destroy=function(){r.remove()},this.focus=function(){r.focus()},this.loadValue=function(n){r.val(u=n[i.column.field]),r.select()},this.serializeValue=function(){return r.val()},this.applyValue=function(n,t){n[i.column.field]=t},this.isValueChanged=function(){return r.val()!=u},this.validate=function(){return{valid:!0,msg:null}},this.init()}}function SelectEditorMulti(n,t){return function(i){var o,r,f,s=this,u,e;this.init=function(f){var c=_.filter(n(),function(n){return n.owner==0&&n.coachid}),h,s;u=ko.observable(f),e="select"+nextSelectId,nextSelectId++,h=t.createChildContext({value:u,options:c,location:[i.position.left,i.position.bottom],listId:e,isGrid:!0,isMulti:!0}),s=document.createElement("div"),ko.renderTemplate("controls_grid_select",h,{},s),o=$(s.firstChild),o.appendTo(i.container),r=o.find("input"),r.focus(),r.select()},this.hide=function(){$("#"+e).hide()},this.show=function(){$("#"+e).show()},this.position=function(n){var t=document.getElementById(e),i;t&&($(t).find("ul")[0].style.minWidth=n.width+"px",t.style.left=n.left+"px",i=$(t).height(),t.style.top=n.bottom+i>window.innerHeight?n.top-i+"px":n.bottom+"px")},this.destroy=function(){ko.removeNode(o.get(0))},this.focus=function(){r.focus()},this.getValue=function(){return u()},this.serializeValue=function(){return u()},this.setValue=function(n){u(n)},this.loadValue=function(n){f=n[i.column.field]||"",u?u(f):this.init(f),r[0].defaultValue=f,r.select()},this.applyValue=function(n,t){n[i.column.field]=t},this.isValueChanged=function(){return!(r.val()==""&&f==null)&&r.val()!=f},this.validate=function(){if(i.column.validator){var n=i.column.validator(r.val());if(!n.valid)return n}return{valid:!0,msg:null}}}}function ComboEditor(n){return function(t){var e,i,u,o=this,r,f;this.init=function(u){for(var c=t.grid.getData(),l={},s,a,v,h,o=0;o<c.getLength();o++)s=c.getItem(o)[t.column.field],s!==null&&s!==""&&(l[s]=!0);a=_.sortBy(_.keys(l),function(n){return n.substr?n.toLowerCase():n}),r=ko.observable(u),f="select"+nextSelectId,nextSelectId++,v=n.createChildContext({value:r,options:a,location:[t.position.left,t.position.bottom],listId:f,isGrid:!0}),h=document.createElement("div"),ko.renderTemplate("controls_grid_select",v,{},h),e=$(h.firstChild),e.appendTo(t.container),i=e.find("input"),i.focus(),i.select()},this.hide=function(){$("#"+f).hide()},this.show=function(){$("#"+f).show()},this.position=function(n){var t=document.getElementById(f),i;t&&($(t).find("ul")[0].style.minWidth=n.width+"px",t.style.left=n.left+"px",i=$(t).height(),t.style.top=n.bottom+i>window.innerHeight?n.top-i+"px":n.bottom+"px")},this.destroy=function(){ko.removeNode(e.get(0))},this.focus=function(){i.focus()},this.getValue=function(){return r()},this.serializeValue=function(){return r()},this.setValue=function(n){r(n)},this.loadValue=function(n){u=n[t.column.field]||"",r?r(u):this.init(u),i[0].defaultValue=u,i.select()},this.applyValue=function(n,i){n[t.column.field]=i},this.isValueChanged=function(){return!(i.val()==""&&u==null)&&i.val()!=u},this.validate=function(){if(t.column.validator){var n=t.column.validator(i.val());if(!n.valid)return n}return{valid:!0,msg:null}}}}function sortGridData(n,t,i){i===void 0&&(i=null),_.isString(n)&&(n=n?[{sortAsc:1,sortCol:{field:n}}]:[]);var r=n.concat([{sortAsc:1,sortCol:{field:"name"}},{sortAsc:1,sortCol:{field:"userName"}},{sortAsc:1,sortCol:{field:"__client"}},{sortAsc:1,sortCol:{field:"date"}},{sortAsc:1,sortCol:{field:"title"}}]);return i=i||ko.unwrap(t.data),i.sort(function(n,t){for(var e,s,h,f=0,c=r.length;f<c;f++){var l=r[f].sortCol.field,a=r[f].sortAsc?1:-1,i=n[l],u=t[l],o=r[f].sortCol.dataExtractor;if(o&&(i=o(i),u=o(u)),i===null||i===undefined||i===""){if(!(u===null||u===undefined||u===""))return 1}else i.substring&&(i=i.toLowerCase());if(u===null||u===undefined||u===""){if(!(i===null||i===undefined||i===""))return-1}else u.substring&&(u=u.toLowerCase());if(e=(i==u?0:i>u?1:-1)*a,typeof i=="object"&&i&&typeof u=="object"&&u&&(s=JSON.stringify(i),h=JSON.stringify(u),e=(s===h?0:s>h?1:-1)*a),e!=0)return e}return 0}),t.sortedData=i,i}function formatAreas(n){return _.map(n.areas,function(n){return'<area href="'+n.id+'" title="'+n.title+'" shape= "poly" coords="'+n.coords+'">'}).join("")}function datePickerDate(n){var t,i;return _.isFunction(n.date)?t=new Date(n.year(),n.month(),n.date(),1):_.isString(n)?(i=n.split("-"),t=new Date(parseInt(i[0],10),parseInt(i[1],10)-1,parseInt(i[2],10),1)):n}function eduration(n){var t=_.reduce(n,function(n,t){return n+ko.unwrap(t)},0);return t?ehour(t)+":"+emin(t)+":"+esec(t):""}function eload(n){return Math.floor(_.reduce(_.map(n,function(n,t){return ko.unwrap(n)*(t+1)}),function(n,t){return n+t},0)/60)}function ehour(n){return(n=ko.unwrap(n),!n)?"":Math.floor(n/3600)}function emin(n){if(n=ko.unwrap(n),!n)return"";var t=Math.floor(n/60)%60+"";return t.length>1?t:"0"+t}function esec(n){if(n=ko.unwrap(n),!n)return"";var t=n%60+"";return t.length>1?t:"0"+t}function rcolor(n,t,i){var r,f,u;return(i===void 0&&(i=null),r=n.split("_"),n=r[r.length-1],f={AppetiteLevel:!0,CompetitionPerformance:!0,EnergyLevels:!0,FatigueTiredness:!0,Fatigue:!0,Tiredness:!0,Motivation:!0,MoodState:!0,SleepQuality:!0,StressTension:!0,TrainingPerformance:!0,Soreness:!0,MuscleSoreness:!0,DiaryRecords:!0},!f[n]&&r[0]!=="GAUGE")?{}:(u=i!==null?i:n==="TrainingPerformance"||n==="CompetitionPerformance"||n==="Motivation"||n==="MoodState"||n==="EnergyLevels"||n==="SleepQuality"||n==="AppetiteLevel"||n==="DiaryRecords",{background:color(t,u,10),color:u&&t<4||!u&&t>6?"white":"black"})}function color(n,t,i){if(!n)return"";var r=["2b9c65","32c37c","97c93c","a5dc41","f3ec19","fecd08","f89a1d","ee3923","cd2027","a41e25"];return n>1&&n<i?(t&&(n=i+1-n),"#"+r[Math.floor(n/i*10)-1]):(n=n==i?t?1:10:t?10:1,"#"+r[n-1])}function rcolor2(n,t){var i=n.split("_"),r,u;return(n=i[i.length-1],r={DiaryRecords:!0},!r[n])?{}:(u=n=="DiaryRecords",{background:color2(t,u,8),color:"black"})}function color2(n,t,i){if(!n&&n!==0)return"";var r=["ff0000","ffef49","ffbb00","90ff00","00bfff","dddddd","a3a3a3","af59f9","ffffff"];return"#"+r[Math.floor(n/i*10)]}function addRoute(n,t){crossroads.addRoute(n,function(){for(var i=[],r,n=0;n<arguments.length;n++)i[n]=arguments[n];r=[currentContainer].concat(i),t.apply(t,r)})}function navigateTo(n){hasher.setHash(n)}function promptToSave(n,t){var r=function(){};bootbox.dialog({message:"There are unsaved changes. Do you want to save them?",title:"Save Changes",closeButton:!1,animate:!1,onEscape:r,buttons:{yes:{label:"Yes",className:"btn-primary dbtnsize",callback:function(){var i=n.saveData();i&&i.done(function(){n.skipNextSave=!0,hasher.setHash(t)})}},no:{label:"No",className:"btn-danger dbtnsize",callback:function(){n.skipNextSave=!0,hasher.setHash(t)}},cancel:{className:"btn btn-default dbtnsize",label:"Cancel",callback:r}}})}function requireModule(n,t){return require(["/Content/application/modules-built/"+n+".js","text!/Application/Home/Template/"+n],function(i,r){templatesLoaded[n]||($(document.head).append(r),templatesLoaded[n]=!0),t(i)})}function encodeHTMLSource(){var n={"&":"&#38;","<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","/":"&#47;"},t=/&(?!#?\w+;)|<|>|"|'|\//g;return function(){return this?this.replace(t,function(t){return n[t]||t}):this}}function getHourComponent(n){return n=n||0,Math.floor(n/3600)}function getMinuteComponent(n,t){return n=n||0,n=Math.floor(n/60),t&&(n=n%60),n}function getSecondComponent(n,t){return n=n||0,n=Math.floor(n),t&&(n=n%60),n}function getMillisecondComponent(n){return n=n||0,n-Math.floor(n)}function dtHour(n){var t=n;return n=ko.computed({read:function(){return t()*60},write:function(n){return t(n/60)}}),ko.computed({read:function(){return getHourComponent(n())||""},write:function(t){var i=n()-getHourComponent(n())*3600,r=(parseFloat(t)||0)*3600;n(r+i)}})}function dtMin(n,t){var i=n;return n=ko.computed({read:function(){return i()*60},write:function(n){return i(n/60)}}),ko.computed({read:function(){return getMinuteComponent(n(),ko.unwrap(t))||""},write:function(i){var r=getMillisecondComponent(n())+getSecondComponent(n(),!0),u;ko.unwrap(t)&&(r+=getHourComponent(n())*3600),u=(parseFloat(i)||0)*60,n(u+r)}})}function dtSec(n,t){var i=n;return n=ko.computed({read:function(){return i()*60},write:function(n){return i(n/60)}}),ko.computed({read:function(){return getSecondComponent(n(),ko.unwrap(t))||""},write:function(i){var r=getMillisecondComponent(n()),u;ko.unwrap(t)&&(r+=getMinuteComponent(n(),!1)*60),u=parseFloat(i)||0,n(r+u)}})}function dtSec2(n){var t=n;return n=ko.computed({read:function(){return t()*60},write:function(n){return t(n/60)}}),ko.computed({read:function(){var t=((n()-Math.floor(n()||0))*1e3).toFixed();if(!t||t==="0")return"";while(t.length<3)t="0"+t;while(t.length>1&&t.lastIndexOf("0")==t.length-1)t=t.substring(0,t.length-1);return t},write:function(t){var i,r;t=t||"",t.length>3&&(t=t.substring(0,3)),i=0,t.length===1?i=t/10:t.length===2?i=t/100:t.length===3&&(i=t/1e3),r=Math.floor(n()||0),n(r+i)}})}function loadAnalysisFields(){hasLoadedAF||(hasLoadedAF=!0,Fields.addAnalysis(Fields.labelTemplate()),Fields.addAnalysis(Fields.linkTemplate()),Fields.addAnalysis(Fields.htmlTemplate()),Fields.addAnalysis(Fields.lineBreakTemplate()),Fields.addAnalysis(Fields.gaugeTemplate()),Fields.addAnalysis(Fields.testGaugeTemplate(),!1),Fields.addAnalysis(Fields.chartTemplate()),Fields.addAnalysis(Fields.chartResistanceTemplate()),Fields.addAnalysis(Fields.testChartTemplate(),!1),Fields.addAnalysis(Fields.testChart2Template()),Fields.addAnalysis(Fields.injuryListTemplate()),Fields.addAnalysis(Fields.sorenessListTemplate()),Fields.addAnalysis(Fields.illnessListTemplate()),Fields.addAnalysis(Fields.testListTemplate()))}function setupController(){$.ajaxSetup({headers:{Accept:"application/jsonl"}}),bootbox.setDefaults({animate:!1});var n=navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Android")!=-1;if(!n)$(document.body).on("mouseover",".modal-dialog",function(){var n=$(this);n.data("init-drag")||(n.parent().css("overflow","hidden"),n.data("init-drag",!0).draggable({handle:".modal-header",cursor:"move"}))});AccountsController.registerRoutes(),ProgramsController.registerRoutes(),HomeController.registerRoutes(),FormsController.registerRoutes(),AnatomyController.registerRoutes(),GlossaryController.registerRoutes(),AnalysisController.registerRoutes(),TeamsController.registerRoutes(),RulesController.registerRoutes(),ExerciseController.registerRoutes(),ClientsController.registerRoutes(),PhoneController.registerRoutes(),SnapController.registerRoutes(),RmController.registerRoutes(),ToolboxController.registerRoutes(),CustomExerciseController.registerRoutes(),IndexPageController.registerRoutes(),crossroads.bypassed.add(function(){window.location.href.indexOf("dashboard.visualcoaching")!=-1?hasher.replaceHash("home/dashboard"):main.startup.startupPage==="Dashboard"?hasher.replaceHash("home/dashboard/"+main.startup.defaultDashboard+(main.startup.defaultDashboardView=="Table"?"/Table":main.startup.defaultClient?"/"+main.startup.defaultClient:"")):main.startup.startupPage==="phone"?hasher.replaceHash("phone"):hasher.replaceHash("home/programs2")}),hasher.initialized.add(parseHash),hasher.changed.add(parseHash),hasher.init()}function checkExpiry(){main.userId&&main.expiryDays<=30&&!hasShownExpiry&&(hasShownExpiry=!0,bootbox.alert("This is a friendly notice regarding your Visualcoaching Pro and Client licenses, as they are due for renewal in "+main.expiryDays+' days.<br/>Please contact Visualcoaching via email <a href="mailto:sales@visualcoaching.com">sales@visualcoaching.com<\/a> to discuss the options for renewing your licenses.'))}function MP4ForEx(n){if(n=ko.unwrap(n)+"",n.indexOf("-")==-1){while(n.length<5)n="0"+n;return"/VCP/Images/Exercises/"+n+".mp4"}return"user_videos/"+n+".mp4"}function MP4ForEx2(n){if(n=ko.unwrap(n)+"",n.indexOf("-")==-1){while(n.length<5)n="0"+n;return'<video src="/VCP/Images/Exercises/'+n+'.mp4" controls="controls" loop="loop" preload="auto" autoplay="autoplay" style="width: 320px; min-height: 250px;"><\/video>'}var t=mp4data[n];return t||(mp4data[n]=t=ko.observable(""),this.GetVideoUrlForEx2(n).done(function(i){i&&(i.indexOf("http")==0?t('<iframe height="240" src="'+i+'" allow="autoplay *; fullscreen *" loop="true" allowfullscreen="true"><\/iframe>'):t('<video src="/user_videos/'+n+'.mp4" controls="controls" loop="loop" preload="auto" autoplay="autoplay" style="width: 320px; min-height: 250px;"><\/video>'))})),t}function GetVideoUrlForEx2(n){return $.getJSON("/api/2/Exercise/GetExercise/"+n)}var _this=this,ENTER_KEY=13,requestAnimationFrameX=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(n){return window.setTimeout(n,20)},ResizeSensor=function(n,t){function o(){this.q=[],this.add=function(n){this.q.push(n)};var n,t;this.call=function(){for(n=0,t=this.q.length;n<t;n++)this.q[n].call()}}function s(n,t){return n.currentStyle?n.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(n,null).getPropertyValue(t):n.style[t]}function u(n,t){var i,f,u,h,y,p,w,b,c,l;if(n.resizedAttached){if(n.resizedAttached){n.resizedAttached.add(t);return}}else n.resizedAttached=new o,n.resizedAttached.add(t);n.resizeSensor=document.createElement("div"),n.resizeSensor.className="resize-sensor",i="position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;",f="position: absolute; left: 0; top: 0; transition: 0s;",n.resizeSensor.style.cssText=i,n.resizeSensor.innerHTML='<div class="resize-sensor-expand" style="'+i+'"><div style="'+f+'"><\/div><\/div><div class="resize-sensor-shrink" style="'+i+'"><div style="'+f+' width: 200%; height: 200%"><\/div><\/div>',n.appendChild(n.resizeSensor),s(n,"position")=="static"&&(n.style.position="relative");var r=n.resizeSensor.childNodes[0],a=r.childNodes[0],e=n.resizeSensor.childNodes[1],v=function(){a.style.width="100000px",a.style.height="100000px",r.scrollLeft=1e5,r.scrollTop=1e5,e.scrollLeft=1e5,e.scrollTop=1e5};v(),u=!1,h=function(){n.resizedAttached&&(u&&(n.resizedAttached.call(),u=!1),requestAnimationFrameX(h))},requestAnimationFrameX(h),c=function(){((w=n.offsetWidth)!=y||(b=n.offsetHeight)!=p)&&(u=!0,y=w,p=b),v()},l=function(n,t,i){n.attachEvent?n.attachEvent("on"+t,i):n.addEventListener(t,i)},l(r,"scroll",c),l(e,"scroll",c)}var r=Object.prototype.toString.call(n),f="[object Array]"===r||"[object NodeList]"===r||"[object HTMLCollection]"===r||"undefined"!=typeof jQuery&&n instanceof jQuery,i,e;if(f)for(i=0,e=n.length;i<e;i++)u(n[i],t);else u(n,t);this.detach=function(){if(f)for(var t=0,i=n.length;t<i;t++)ResizeSensor.detach(n[t]);else ResizeSensor.detach(n)}},deletePressHandlers,activeText,morphs,Chart,Gauge,TestGauge,SorenessControl,InjuryControl,DurationSelect,Tabs,fileChangeEventSubscribed,UploadFile,parseHash,templatesLoaded,Data,SelectClients,SelectClients2,GlossaryController,AnatomyController,ExerciseController,HomeController,FormsController,ClientsController,AccountsController,AnalysisController,TeamsController,RmController,RulesController,ProgramsController,ToolboxController,CustomExerciseController,IndexPageController,PhoneController,SnapController,yoyo1,yoyo2,Fields,hasLoadedAF,requirejs,require,define,safeLocalStorage,mp4data;ResizeSensor.detach=function(n){n.resizeSensor&&(n.removeChild(n.resizeSensor),delete n.resizeSensor,delete n.resizedAttached)},ko.bindingHandlers.color={init:function(n){new jscolor.color(n)}},ko.bindingHandlers.followScroller={init:function(n,t){setTimeout(function(){var i=$(n).parent().find(t());i.scroll(function(){n.style.marginLeft=-i.scrollLeft()+"px"})},0)}};var ITEMKEY="ko_sortItem",INDEXKEY="ko_sourceIndex",LISTKEY="ko_sortList",PARENTKEY="ko_parentList",DRAGKEY="ko_dragItem",dataGet=ko.utils.domData.get,dataSet=ko.utils.domData.set,addMetaDataAfterRender=function(n,t){ko.utils.arrayForEach(n,function(n){n.nodeType===1&&(dataSet(n,ITEMKEY,t),dataSet(n,PARENTKEY,dataGet(n.parentNode,LISTKEY)))})},prepareTemplateOptions=function(n,t){var i={},r=ko.unwrap(n())||{},u;return r.data?(i[t]=r.data,i.name=r.template):i[t]=n(),ko.utils.arrayForEach(["afterAdd","afterRender","as","beforeRemove","includeDestroyed","templateEngine","templateOptions"],function(n){i[n]=r[n]||ko.bindingHandlers.viewport3[n]}),t==="foreach"&&(i.afterRender?(u=i.afterRender,i.afterRender=function(n,t){addMetaDataAfterRender.call(t,n,t),u.call(t,n,t)}):i.afterRender=addMetaDataAfterRender),i},updateIndexFromDestroyedItems=function(n,t){var r=ko.unwrap(t),i;if(r)for(i=0;i<n;i++)r[i]&&ko.unwrap(r[i]._destroy)&&n++;return n},vpi=0;ko.bindingHandlers.viewport3={connectClass:"ko_container",allowDrop:!0,afterMove:null,beforeMove:null,options:{},createCleanNode:function(n){var t=n.cloneNode(!0);return $(n).remove(),t},createNode:function(n,t,i){var r=t.cloneNode(!0),u;return i?(r.style.height=i.h+"px",u=n.createChildContext(i.data),ko.applyBindings(u,r)):console.log("bad"),[r]},calculateHeightAndWrapper:function(n,t,i){for(var a=0,v=0,o=ko.unwrap(n),c={},l=[],e=0,h=!1,f,s,u,r=0;r<o.length;r++)f=t(o[r],r),f&&(s=i[r],s&&s.data===o[r]?(u=s,(u.y!==e||u.h!==f)&&(h=!0,u.y=e,u.h=f),a++):(h=!0,u={data:o[r],y:e,h:f,index:r},v++),l.push(u),c[r]=u,e+=f);return{height:e,wrapper:l,wrapperLookup:c,forceUpdate:h}},init:function(n,t,i,r,u){var s,e,lt,nt,w,ot,st,tt,l,vt,yt;if(n.children.length!==1)throw"Must have exactly one child for viewport";var o=$(n),b=ko.unwrap(t())||{},y=prepareTemplateOptions(t,"foreach"),f={},it,rt;for(o.contents().each(function(){this.nodeType!==1&&n.removeChild(this)}),s=o;s.length&&!s.hasClass("scroller")&&!s.hasClass("scroller-unpadded");s=s.parent());if(!s.length)throw"Scroller missing for viewport";for(e=o;e.length&&!e.hasClass("viewport-size");e=e.parent());var p=ko.bindingHandlers.viewport3,pt=p.createCleanNode(n.firstElementChild),k=i().rowHeight||25,v;v=o;var h=[],ht={},ct=p.createNode.bind(p,u,pt);$.extend(!0,f,p),b.options&&f.options&&(ko.utils.extend(f.options,b.options),delete b.options),ko.utils.extend(f,b),f.connectClass&&(ko.isObservable(f.allowDrop)||typeof f.allowDrop=="function")?ko.computed({read:function(){var t=ko.unwrap(f.allowDrop),i=typeof t=="function"?t.call(this,y.foreach):t;ko.utils.toggleDomNodeCssClass(n,f.connectClass,i)},disposeWhenNodeIsRemoved:n},_this):ko.utils.toggleDomNodeCssClass(n,f.connectClass,f.allowDrop),it=f.options.start,rt=f.options.update;var ut=25,a=-1,d=0;_.isFunction(k)||(lt=k,k=function(){return lt}),vpi++;var bt=vpi,at=function(){var l=new Date,i,f,r,n,u,e,t,c;if(h.length==0)return[0,-1];if(i=s.offset().top-o.offset().top,f=s.height(),f==0)return[0,-1];if(r=i+f,i=i,r=r,n=0,u=-1,r<0)return[0,-1];if(e=h[h.length-1],i>e.y+e.h)return[0,-1];for(t=0;t<h.length;t++)if(h[t].y<i&&(n=t),u=t,h[t].y>r)break;return n=Math.max(0,n),u=Math.min(h.length-1,u),n%2&&n--,c=new Date,[n,u]},c=null,wt=function(t){var r,i,u;for(window.isVPDragging&&(a!==-1&&t[0]>a&&(t[0]=a),a!==-1&&t[1]<a&&(t[1]=a),c&&t[0]>c[0]&&(t[0]=c[0]),c&&t[1]<c[1]&&(t[1]=c[1]),d=t[0],dataSet(n,"topDraggingIndex",d)),dataSet(n,"topDraggingIndex",t[0]),r=[],i=t[0];i<=t[1];i++)r.push(h[i]);u=h[t[0]],v[0].style.paddingTop=(u?Math.max(u.y,10):20)+"px",ko.utils.setDomNodeChildrenFromArrayMapping(v[0],r,ct,null,null),_.each(n.children,function(n){var t=ko.dataFor(n);t&&t.Type&&(dataSet(n,ITEMKEY,t),dataSet(n,PARENTKEY,dataGet(n.parentNode,LISTKEY)),t.height&&(n.style.height=ko.unwrap(t.height)+"px"))}),v[0].style.height=ut+"px",window.isVPDragging&&o.sortable("refresh")},ft=function(){var n=at();(c===null||c[0]!==n[0]||c[1]!==n[1])&&(wt(n),c=n)},et=!1,g=function(){et||(et=!0,et=!1,ft())};return s.scroll(g),$(window).resize(g),e&&(nt=dataGet(e[0],"resize-sensor"),nt?(w=dataGet(e[0],"resize-sensor-observer"),dataSet(e[0],"resize-sensor-count",dataGet(e[0],"resize-sensor-count")+1)):(w=ko.observable(!0),dataSet(e[0],"resize-sensor-observer",w),nt=new ResizeSensor(e[0],function(){w.valueHasMutated()}),dataSet(e[0],"resize-sensor",nt),dataSet(e[0],"resize-sensor-count",1)),ot=w.subscribe(g)),st=i().viewportSubscribeTo,tt=!0,ko.computed({read:function(){st&&st(),dataSet(n,LISTKEY,y.foreach),ko.unwrap(y.foreach),tt&&(tt=!1,setTimeout(function(){tt=!0;var n=p.calculateHeightAndWrapper(y.foreach,k,ht);ut=n.height+20,v[0].style.height=ut+"px",h=n.wrapper,ht=n.wrapperLookup,n.forceUpdate&&(c=null),ft()},0))},disposeWhenNodeIsRemoved:n}),vt=ko.utils.extend(f.options,{start:function(n,t){var r=t.item[0],i;a=ko.utils.arrayIndexOf(t.item.parent().children(),r),a+=at()[0],dataSet(r,INDEXKEY,a),t.item.find("input:focus").change(),it&&it.apply(this,arguments),i=ko.dataFor(r),i&&i.program&&i.program.selectExercise(i,null,null),window.isVPDragging=!0},stop:function(n,t){var i=t.item[0];window.isVPDragging=!1,a=-1,d=-1},receive:function(n,t){l=dataGet(t.item[0],DRAGKEY),l&&(l.clone&&(l=l.clone()),f.dragged&&(l=f.dragged.call(this,l,n,t)||l))},update:function(n,t){var r,o,h,e,s,u=t.item[0],p=t.item.parent()[0],i=dataGet(u,ITEMKEY)||l,c,v,k,g;if(l=null,c=$(this).parents(".program-container")[0],i&&(c===p||$.contains(c,p))){if(r=dataGet(u,PARENTKEY),h=dataGet(u,INDEXKEY),o=dataGet(u.parentNode,LISTKEY),e=ko.utils.arrayIndexOf(t.item.parent().children(),u),!_.isArray(i)&&_.isFunction(r)&&(i=_.filter(r(),function(n){return n===i||n.isSelected&&n.isSelected()})),y.includeDestroyed||(h=updateIndexFromDestroyedItems(h,r),e=updateIndexFromDestroyedItems(e,o)),s={item:i,sourceParent:r,sourceParentNode:r&&t.sender||u.parentNode,sourceIndex:h,targetParent:o,targetIndex:e,cancelDrop:!1},f.beforeMove&&(f.beforeMove.call(this,s,n,t),s.cancelDrop)){s.sourceParent?$(s.sourceParent===s.targetParent?this:t.sender).sortable("cancel"):$(u).remove();return}var a=ko.contextFor(u.parentNode).$program,w=ko.contextFor(u.parentNode).$week,b=ko.contextFor(u.parentNode).$session;a!==ko.contextFor(u).$program?(_.isArray(i)?o.splice.apply(o,[e,0].concat(_.map(i,function(n){return n.clone(a,w,b)}))):o.splice(e,0,i.clone(a,w,b)),$(t.sender).sortable("cancel")):e>=0?(v=dataGet(u.parentNode,"topDraggingIndex")||0,console.log("dropping",e,d,v),e+=v,r&&(_.isArray(i)?_.each(i,function(n){var t=r.indexOf(n),i;n.skipDispose=!0,i=r.splice(t,1),n.skipDispose=!1}):(k=r.indexOf(i),i.skipDispose=!0,g=r.splice(k,1),i.skipDispose=!1)),_.isArray(i)?o.splice.apply(o,[e,0].concat(i)):o.splice(e,0,i),r?r!==o&&(_.each(t.item,function(n){ko.cleanNode(n)}),t.item.remove()):t.item.remove()):t.item.remove(),dataSet(u,ITEMKEY,null),f.afterMove&&f.afterMove.call(this,s,n,t)}rt&&rt.apply(this,arguments),ft()},connectWith:f.connectClass?"."+f.connectClass:!1,helper:function(){return $("<div><\/div>")}}),yt=setTimeout(function(){o.sortable(vt),f.isEnabled!==undefined&&ko.computed({read:function(){o.sortable(ko.unwrap(f.isEnabled)?"enable":"disable")},disposeWhenNodeIsRemoved:n})},0),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){var t,i;ot&&ot.dispose(),t=dataGet(e[0],"resize-sensor-count"),t==1?(i=dataGet(e[0],"resize-sensor"),i.detach(),dataSet(e[0],"resize-sensor",null),dataSet(e[0],"resize-sensor-observer",null),dataSet(e[0],"resize-sensor-count",0)):dataSet(e[0],"resize-sensor-count",t-1),l=null,dataSet(n,LISTKEY,null),(o.data("ui-sortable")||o.data("sortable"))&&o.sortable("destroy"),clearTimeout(yt),s.off("scroll",g),_.each(h,function(n){return n.data=null}),ko.utils.setDomNodeChildrenFromArrayMapping(v[0],[],ct,null,null)}),{controlsDescendantBindings:!0}}},ko.bindingHandlers.viewport2={createCleanNode:function(n){var t=n.cloneNode(!0);return $(n).remove(),t},createNode:function(n,t,i){var r=t.cloneNode(!0),u;return r.style.height=i.h+"px",u=n.createChildContext(i.data),ko.applyBindings(u,r),[r]},calculateHeightAndWrapper:function(n,t){for(var u=ko.unwrap(n),e=[],f=0,r,i=0;i<u.length;i++)r=t(u[i],i),r&&(e.push({data:u[i],y:f,h:r,index:i}),f+=r);return{height:f,wrapper:e}},init:function(n,t,i,r,u){var f,y,a,c;if(n.children.length!==1)throw"Must have exactly one child for viewport";for(f=$(n);f.length&&!f.hasClass("scroller")&&!f.hasClass("scroller-unpadded");f=f.parent());if(!f.length)throw"Scroller missing for viewport";var s=ko.bindingHandlers.viewport2,w=s.createCleanNode(n.firstElementChild),h=i().rowHeight||25,o;o=n.nodeName==="UL"?$(n):$('<div class="unpadded"><\/div>').appendTo(n);var v=t(),e=[],b=s.createNode.bind(s,u,w);_.isFunction(h)||(y=h,h=function(){return y});var k=function(){for(var o=f.height(),u=f.scrollTop()+n.offsetTop,s=u+o,i=0,r=0,t=0;t<e.length;t++)if(e[t].y<u&&(i=t),r=t,e[t].y>s)break;return i=Math.max(0,i),r=Math.min(e.length-1,r),i%2&&i--,[i,r]},d=function(n){for(var r=[],i,t=n[0];t<=n[1];t++)r.push(e[t]);i=e[n[0]],o[0].style.paddingTop=(i?i.y:0)+"px",ko.utils.setDomNodeChildrenFromArrayMapping(o[0],r,b,null,null)},p=function(){d(k())},l=!1;return f.scroll(function(){l||(l=!0,setTimeout(function(){l=!1,p()},100))}),a=i().viewportSubscribeTo,c=!0,ko.computed({read:function(){a&&a(),ko.unwrap(v),c&&(c=!1,setTimeout(function(){c=!0;var n=s.calculateHeightAndWrapper(v,h);o.height(n.height),e=n.wrapper,p()},0))},disposeWhenNodeIsRemoved:n}),{controlsDescendantBindings:!0}}},ko.bindingHandlers.viewport={createCleanNode:function(n){var t=n.cloneNode(!0);return $(n).remove(),t},createNode:function(n,t,i){var r=t.cloneNode(!0),u;return r.style.height=i.h+"px",u=n.createChildContext(i.data),ko.applyBindings(u,r),[r]},calculateHeightAndWrapper:function(n,t){for(var u=ko.unwrap(n),e=[],f=0,r,i=0;i<u.length;i++)r=t(u[i],i),r&&(e.push({data:u[i],y:f,h:r,index:i}),f+=r);return{height:f,wrapper:e}},init:function(n,t,i,r,u){var f,p,a,c;if(n.children.length!=1)throw"Must have exactly one child for viewport";for(f=$(n);f.length&&!f.hasClass("scroller")&&!f.hasClass("scroller-unpadded");f=f.parent());if(!f.length)throw"Scroller missing for viewport";var s=ko.bindingHandlers.viewport,b=s.createCleanNode(n.firstElementChild),h=i().rowHeight||25,o;o=n.nodeName=="UL"?$(n):$('<div class="unpadded"><\/div>').appendTo(n);var v=t(),e=[],k=s.createNode.bind(s,u,b),y=25;_.isFunction(h)||(p=h,h=function(){return p});var d=function(){for(var o=f.height(),u=f.scrollTop()+n.offsetTop,s=u+o,i=0,r=0,t=0;t<e.length;t++)if(e[t].y<u&&(i=t),r=t,e[t].y>s)break;return i=Math.max(0,i-40),r=Math.min(e.length-1,r+40),i%2&&i--,[i,r]},g=function(n){for(var r=[],i,t=n[0];t<=n[1];t++)r.push(e[t]);i=e[n[0]],o[0].style.paddingTop=(i?i.y:0)+"px",o[0].style.height=y+"px",ko.utils.setDomNodeChildrenFromArrayMapping(o[0],r,k,null,null)},w=function(){g(d())},l=!1;return f.scroll(function(){l||(l=!0,setTimeout(function(){l=!1,w()},100))}),a=i().viewportSubscribeTo,c=!0,ko.computed({read:function(){a&&a(),ko.unwrap(v),c&&(c=!1,setTimeout(function(){c=!0;var n=s.calculateHeightAndWrapper(v,h);y=n.height,o.height(n.height),e=n.wrapper,w()},0))},disposeWhenNodeIsRemoved:n}),{controlsDescendantBindings:!0}}},ko.bindingHandlers.time={init:function(n,t){var i=ko.unwrap(t());n.innerHTML='<select id="'+i+'"><option>12:00 am<\/option><option>1:00 am<\/option><option>2:00 am<\/option><option>3:00 am<\/option><option>4:00 am<\/option><option>5:00 am<\/option><option>6:00 am<\/option><option>7:00 am<\/option><option>8:00 am<\/option><option>9:00 am<\/option><option>10:00 am<\/option><option>11:00 am<\/option><option>12:00 pm<\/option><option>1:00 pm<\/option><option>2:00 pm<\/option><option>3:00 pm<\/option><option>4:00 pm<\/option><option>5:00 pm<\/option><option>6:00 pm<\/option><option>7:00 pm<\/option><option>8:00 pm<\/option><option>9:00 pm<\/option><option>10:00 pm<\/option><option>11:00 pm<\/option><\/select>'}},ko.bindingHandlers.day={init:function(n,t){var i=ko.unwrap(t());n.innerHTML='<select id="'+i+'"><option>Sunday<\/option><option>Monday<\/option><option>Tuesday<\/option><option>Wednesday<\/option><option>Thursday<\/option><option>Friday<\/option><option>Saturday<\/option><\/select>'}},ko.bindingHandlers.topOnTrue={update:function(n,t){var f=ko.unwrap(t());f&&(t()(!1),n.scrollTop=0)}},ko.bindingHandlers.clickDelegate={init:function(n,t,i,r){function e(t){$(n).on(t.event||"click",t.selector,function(i){if(window.ignoreClick){i.preventDefault(),i.stopPropagation();return}var f=t.scope||r,u=ko.dataFor(this);u&&f[t.method](u,this,i,n),t.preventDefault!==!1&&i.preventDefault(),t.stopPropagation!==!1&&i.stopPropagation()})}var f=ko.unwrap(t());_.isArray(f)?f.forEach(function(n){return e(n)}):e(f)}},ko.bindingHandlers.checked2={init:function(n,t){var f=ko.unwrap(t());$(n).parent().parent().parent().on("mouseleave","div,label,span,input",function(){var i=t();i&&(i(n.checked),setTimeout(function(){i(n.checked)},10),setTimeout(function(){i(n.checked)},500))});$(n).parent().parent().parent().mouseup(function(){var i=t();i&&(i(n.checked),setTimeout(function(){i(n.checked)},10),setTimeout(function(){i(n.checked)},500))});$(n).on("change",function(){var i=t();i&&i(n.checked)})},update:function(n,t){n.checked=ko.unwrap(t())}},ko.bindingHandlers.quickClick={init:function(n,t,i,r,u){var f={deltaX:0,deltaY:0,clientX:0,clientY:0},e=function(n){if(f.deltaX=0,f.deltaY=0,n.touches&&n.touches[0]){var t=n.touches[0];f.clientX=t.clientX,f.clientY=t.clientY}},o=function(n){if(n.touches&&n.touches[0]){var t=n.touches[0];f.deltaX=f.clientX-t.clientX,f.deltaY=f.clientY-t.clientY}},s=function(t){if(t.preventDefault&&t.preventDefault(),event.cancelBubble=!0,t.stopPropagation&&t.stopPropagation(),Math.abs(f.deltaX)<30&&Math.abs(f.deltaY)<30&&!n.disabled){var i=document.createEvent("HTMLEvents");i.initEvent("click",!0,!0),n.dispatchEvent(i)}return!1};return n.addEventListener("touchstart",e,!1),n.addEventListener("touchmove",o,!0),n.addEventListener("touchend",s,!1),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.removeEventListener("touchstart",e,!1),n.removeEventListener("touchmove",o,!0),n.removeEventListener("touchend",s,!1)}),ko.bindingHandlers.event.init.call(this,n,function(){return{click:t()}},i,r,u)}},ko.bindingHandlers.quickClicker={init:function(n){var f={deltaX:0,deltaY:0,clientX:0,clientY:0},e=function(n){if(f.deltaX=0,f.deltaY=0,n.touches&&n.touches[0]){var t=n.touches[0];f.clientX=t.clientX,f.clientY=t.clientY}},o=function(n){if(n.touches&&n.touches[0]){var t=n.touches[0];f.deltaX=f.clientX-t.clientX,f.deltaY=f.clientY-t.clientY}},s=function(t){if(t.preventDefault&&t.preventDefault(),event.cancelBubble=!0,t.stopPropagation&&t.stopPropagation(),Math.abs(f.deltaX)<30&&Math.abs(f.deltaY)<30&&!n.disabled){var i=document.createEvent("HTMLEvents");i.initEvent("click",!0,!0),n.dispatchEvent(i)}return!1};n.addEventListener("touchstart",e,!1),n.addEventListener("touchmove",o,!0),n.addEventListener("touchend",s,!1)}},ko.bindingHandlers.withProperties={init:function(n,t,i,r,u){var f=t(),e=u.extend(f);return ko.applyBindingsToDescendants(e,n),{controlsDescendantBindings:!0}}},ko.virtualElements.allowedBindings.withProperties=!0,ko.bindingHandlers.enterKey={init:function(n,t,i,r,u){var f,e;f=function(n,i){i.keyCode===ENTER_KEY&&t().call(this,n,i)},e=function(){return{keyup:f}},ko.bindingHandlers.event.init(n,e,i,r,u)}},ko.bindingHandlers.selectVisible={update:function(n,t,i){var r=t(),u=i(),f=ko.unwrap(r),e=u.slideDuration||400;f==!0?$(n).show().focus().select():$(n).hide()}},ko.bindingHandlers.selectOnFocus={init:function(n){$(n).focus(function(){window.setTimeout(function(){n.value&&(n.setAttribute("type","text"),n.setSelectionRange(0,9999),n.setAttribute("type","number"))},10)})}},ko.bindingHandlers.selectAll={init:function(n){$(n).focus(function(){window.setTimeout(function(){n.value&&n.setSelectionRange(0,9999)},10)})}},deletePressHandlers=[],ko.bindingHandlers.deleteInProgram={init:function(n,t,i,r,u){var f=function(n){if(!$(n.target).hasClass("redactor-editor")&&!$(n.target).is("input")&&!$(n.target).hasClass("note-editable")){if(u.$program.weeks===null){console.log("off id: "+u.$deletePressHandlerId),$("body").off("keyup",deletePressHandlers[u.$deletePressHandlerId]);return}var t=n.which?n.which:n.keyCode;t===46&&u.$program.deleteSubscriber.valueHasMutated()}};$("body").on("keyup",f);u.$deletePressHandlerId=deletePressHandlers.length,deletePressHandlers.push(f)}},ko.bindingHandlers.googleTranslate={init:function(){google&&google.translate&&google.translate.TranslateElement&&new google.translate.TranslateElement({pageLanguage:"en",layout:google.translate.TranslateElement.InlineLayout.SIMPLE},"google_translate_element")}},activeText=null,ko.extenders.makeColumns=function(n,t){return n.split=ko.computed(function(){var r;t=Math.min(t,Math.floor((document.body.clientWidth-255)/320));var u=n(),o=u.length/t,f=[],e=0,i=[];for(r=0;r<u.length;r++)i.push(u[r]),e++,e>=o&&(f.push(i),i=[],e=0);return i.length&&f.push(i),f}),n},ko.extenders.makeColumns2=function(n,t){return n.split=ko.computed(function(){var i;t=Math.min(t,Math.floor((document.body.clientWidth-255)/320));var u=n(),f=u.length/t,r=[];for(i=0;i<f;i++)r.push([]);for(i=0;i<u.length;i++)r[i%f].push(i);return r}),n},ko.extenders.editableText=function(n,t){return n.editing=ko.observable(!1),n.placeholder=t,n.isPlaceholder=ko.pureComputed(function(){return!n()}),n.displayText=ko.pureComputed(function(){return n()||n.placeholder}),n.edit=function(){activeText&&activeText.close(),activeText=n,n.editing(!0)},n.close=function(){n.editing(!1),activeText=null},n},ko.bindingHandlers.editableHtml={init:function(n){$(n).redactor()}},ko.bindingHandlers.editableText={init:function(){return ko.bindingHandlers.template.init.apply(this,arguments)},update:function(n,t,i,r,u){var e=ko.observable({name:"tplEditableText",data:{d:t()}}),f=ko.unwrap(t());f.context&&(f.context.data=f.data,f.data=f.context,delete f.context),ko.bindingHandlers.template.update(n,e,i,r,u)}},wrapTemplate("menu","menu"),wrapTemplate("tabs","tplTabs"),ko.bindingHandlers.valueQ={after:["options","foreach"],init:function(n,t,i,r,u){var f={get:function(n){return n=="valueUpdate"?["afterkeydown","afterkeyup"]:i.get(n)},has:function(n){return n=="valueUpdate"?!0:i.has(n)}};return ko.bindingHandlers.value.init(n,t,f,r,u)},update:function(n,t,i,r,u){return ko.bindingHandlers.value.update(n,t,i,r,u)}},ko.bindingHandlers.clipchamp={init:function(n){var f=$(n);f.clipchamp&&f.clipchamp({onUploadComplete:function(n){var t=n.id,i=n.url,r=n.embedHtml;$("#clipchampVideo .modal-body").append("<h3>Upload completed.<\/h3>"),$("#clipchampVideo .modal-body").append("<p>Id: "+t+"<\/p>"),$("#clipchampVideo .modal-body").append("<p>Video Url: "+i+"<\/p>"),$("#clipchampVideo .modal-body").append('<p id="clipVideo">Video: '+r+"<\/p>"),$("#clipVideo > iframe").width(320),$("#clipVideo > iframe").height(180),$("#clipchampVideo").modal("show")}})}},ko.bindingHandlers.square={init:function(n,t){var i=$(n),r=ko.unwrap(t()),u,f;r||(r=1),u=i.width(),u?i.height(u*r):(f=i.height(),!f||i.width(f*r))}},ko.bindingHandlers.WithinFixedViewport={init:function(n){var f=$(n),e=f.siblings("a.dropdown-toggle");e.on("contextmenu mouseenter",function(){var r=document.body.clientWidth,i=$(document).height(),u=e.offset().top,t=f.height(),n=u-t/2;n+t+70>i&&(n=i-t-70),n<20&&(n=20),f.css("top",n+"px"),f.css("right",r-e.offset().left-15+"px")})}},ko.bindingHandlers.doubleClick={init:function(n){if(window.isPhone2){var t=0;$(n).on("click",function(i){t==0?t=+new Date:+new Date-t<800?($(n).dblclick(),i.stopPropagation(),i.preventDefault(),t=0):t=+new Date})}}},ko.bindingHandlers.slide={init:function(n,t){var f=$(n),e=ko.unwrap(t)(),o;if(e===1){if(f.siblings(".second-level-tile").length===0)return;o=f.siblings(".second-level-tile").eq(0),$(n).click(function(){var i=$(n).siblings(".slide-tile").eq(0);i.hasClass("open")||(slideHideBasedOnClass(".second-level-tile"),slideHideBasedOnClass(".third-level-tile"),slideHideBasedOnClass(".fourth-level-tile")),performSlide(i,240)})}else e===2?$(n).click(function(){var u=$(f.context),r,t,i;f=f.closest(".second-level-tile"),r=f.find("a.slide"),t=r.index(u),console.log(t),i=f.siblings(".third-level-tile").eq(t),i.hasClass("open")||(slideHideBasedOnClass(".third-level-tile"),slideHideBasedOnClass(".fourth-level-tile")),performSlide(i,495)}):e===3&&$(n).click(function(){var t=$(f.context);f=f.closest(".third-level-tile");var i=f.find("a.slide"),r=i.index(t),u=f.siblings(".fourth-level-tile").eq(r);performSlide(u,750)})}},$(document).click(function(n){var t=$(n.target);t.hasClass("slide")||(t=t.closest(".slide")),t.length===0&&slideHideAll()}),ko.bindingHandlers.dropdownMenu={init:function(n,t,i,r,u){function h(n){n.addClass("open");$(document).on("click.menuClickHandler",function(n){$(n.target).closest(".dropdown-menu").length||$(n.target).is(":button")||f.hasClass("open")&&(s()?($(document).off("click.menuClickHandler"),bootbox.dialog({message:"There are unsaved changes. Do you want to save them?",title:"Save Changes",closeButton:!1,animate:!1,buttons:{yes:{label:"Yes",className:"btn-primary dbtnsize",callback:function(){console.log(u),u.$data.saveChangeFunc(),e(f)}},no:{label:"No",className:"btn-warning dbtnsize",callback:function(){u.$data.notSaveFunc(),e(f)}},cancel:{label:"Cancel",className:"btn-danger dbtnsize",callback:function(n){n.stopPropagation(),e(f),h(f)}}}})):e(f))})}function e(n){n.removeClass("open"),$(document).off("click.menuClickHandler")}var l=function(){},o=$(n),f=o.parent(),c=o.siblings(".dropdown-menu"),s;c.length<=0||(s=i().hasChange||!1,o.click(function(n){n.stopPropagation(),console.log("click on ele"),f.hasClass("open")?e(f):h(f)}))}},ko.bindingHandlers.stopBubble={init:function(n){ko.utils.registerEventHandler(n,"click",function(n){n.cancelBubble=!0,n.stopPropagation&&n.stopPropagation()})}},ko.bindingHandlers.OnElementFocus={init:function(n,t,i,r){$(n).focus(function(){t()(r,n)})}},ko.bindingHandlers.OnElementBlur={init:function(n,t,i,r){$(n).blur(function(){t()(r,n)})}},ko.bindingHandlers.Collaspe={update:function(n,t){$(n).click(function(){$(n).hasClass("fa-plus")===!0?($(n).removeClass("fa-plus"),$(n).addClass("fa-minus")):($(n).addClass("fa-plus"),$(n).removeClass("fa-minus")),$("#"+t().Selector).toggleClass("in")})}},window.gridRefresh=ko.observable();var nextSelectId=1,GridObject=function(){function n(n){this.columns=n,this.checkboxText=ko.observable(""),this.data=ko.observableArray([]),this.selectedRows=ko.observableArray([]),this.sortBy=ko.observable("name")}return n}(),standardClientsColumns=[{id:"name",width:190,label:"Name",formatter:renderName},{id:"email",width:190,label:"Email"},{id:"category",width:85,label:"Category"},{id:"sport",width:190,label:"Sport"},{id:"discipline",width:145,label:"Discipline"},{id:"group",width:115,label:"Group"},{id:"keyword",width:115,label:"Keyword"}];ko.bindingHandlers.superselect={init:function(n,t,i,r,u){var l,e=t(),o=e.value,h=e.options,s=e.isMulti,p=o().split(","),c,f,a,v,y;s?(h=_.map(h,function(n){return{isSelected:ko.observable(!!_.find(p,function(t){return n.coachid==t})),data:n}}),l=h):(c=ko.observable(!1),l=ko.computed(function(){if(!c())return ko.unwrap(h);var n=(ko.unwrap(o)||"").toLowerCase();return _.filter(ko.unwrap(h),function(t){return(t||"").toLowerCase().indexOf(n)==0})})),a=u.createChildContext({placeholder:e.placeholder,value:o,options:l,select:function(n){s?(n.isSelected(!n.isSelected()),n.isSelected()?o(_.filter(o().split(","),function(n){return!!n}).concat(n.data.coachid).join(",")):o(_.filter(o().split(","),function(t){return!!t&&t!=n.data.coachid}).join(","))):(o(n),f.hide())},format:s?function(n){return n.name}:function(n){return n}}),ko.renderTemplate(e.isGrid?"controls_superselect":"controls_superselect2",a,{},n),v=document.createElement("div"),ko.renderTemplate(s?"controls_grid_selectlist_multi":"controls_grid_selectlist",a,{},v),f=$(v.firstChild),e.listId||(e.listId="select"+nextSelectId,nextSelectId++),f[0].id=e.listId,f.appendTo(document.body),f.hide();$(n).on("blur","input",function(t){s||t.currentTarget==f.get(0)||setTimeout(function(){document.activeElement==$(n).find("input").get(0)||$(document.activeElement).hasClass("select-list")||f.hide()},200)});$(n).on("focus","input",function(){c(!1),f.show()});$(n).on("keypress","input",function(){c(!0)});f.blur(function(){s||document.activeElement==$(n).find("input").get(0)||$(document.activeElement).hasClass("select-list")||f.hide()}),e.isGrid||(y=setInterval(function(){!$(n).is(":visible")&&f.is(":visible")?f.hide():(f.find("ul")[0].style.minWidth=$(n).width()-20+"px",f[0].style.left=$(n).offset().left+"px",f[0].style.top=$(n).offset().top+34+"px")},100)),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){ko.removeNode(f.get(0)),e.isGrid||clearInterval(y)});$(n).on("click",".toggle",function(){e.isGrid||(f.find("ul")[0].style.minWidth=$(n).width()-20+"px",f[0].style.left=$(n).offset().left+"px",f[0].style.top=$(n).offset().top+34+"px"),f.is(":visible")?f.hide():$(n).find("input").focus()});return{controlsDescendantBindings:!0}}},ko.bindingHandlers.grid={init:function(n,t,i,r,u){function nt(n,t,i){c.push(i),i.execute()}function tt(){var n=c.pop();n&&Slick.GlobalEditorLock.cancelCurrentEdit()&&(n.undo(),f.gotoCell(n.row,n.cell,!1)),e.checkForChanges&&e.checkForChanges()}var h,c,o,y,b,k,a,d;$(n).addClass("slick-grid");var f,e=ko.unwrap(t()),g=i().gridAutoHeight||!1,v=function(n,t){return n=="text"?Slick.Editors.Text:n=="number"?Slick.Editors.Integer:n=="combo"?SelectEditor2(t,t.options,u):n=="combomulti"?SelectEditorMulti(t.options,u):n=="autotext"?ComboEditor(u):n=="gender"?SelectEditor:null},s=_.map(ko.unwrap(e.columns),function(n){return{id:n.id,field:n.id,name:n.label,width:n.width,sortable:!0,formatter:n.formatter,editor:v(n.editor,n),dataExtractor:n.dataExtractor}});ko.isSubscribable(e.columns)&&e.columns.subscribe(function(n){var t=_.map(n,function(n){return{id:n.id,field:n.id,name:n.label,width:n.width,sortable:!0,formatter:n.formatter,editor:v(n.editor,n),dataExtractor:n.dataExtractor,headerCssClass:"text-center"}});e.hideCheckbox||(t=[o.getColumnDefinition()].concat(t)),f.setColumns(t)}),h={enableCellNavigation:!0,enableColumnReorder:!1,multiColumnSort:!0,syncColumnCellResize:!0,editable:!0,autoEdit:!0,editCommandHandler:nt,forceFitColumns:!1,autoHeight:e.autoHeight||g},c=[],e.hideCheckbox||(o=new Slick.CheckboxSelectColumn({cssClass:"slick-cell-checkboxsel",text:e.checkboxText}),s=[o.getColumnDefinition()].concat(s)),y=e.sortedData||ko.unwrap(e.data),f=new Slick.Grid(n,y,s,h);var l=function(){f.setOptions({autoHeight:!0}),f.resizeCanvas(),f.invalidate(),console.log("Functionality to run before printing.")},p=function(){h.autoHeight||f.setOptions({autoHeight:!1}),f.resizeCanvas(),f.invalidate(),console.log("Functionality to run after printing")},w=window.grids||[];return w.push(l),window.grids=w,window.matchMedia&&(b=window.matchMedia("print"),k=function(n){n.matches?l():p()},b.addListener(k)),window.onbeforeprint=l,window.onafterprint=p,$(n).data("grid",f),f.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow:!0})),o&&f.registerPlugin(o),e.undo=tt,e.getEditorLock=f.getEditorLock,e.grid=f,f.onClick.subscribe(function(n,t){var i;if(e.keepSelected&&!e.hideCheckbox){n.stopPropagation(),n.stopImmediatePropagation();return}f.getColumns()[t.cell].id==="count"&&(i=t.grid.getDataItem(t.row),i.checkState=i.checkState==0?1:i.checkState==1?i.count!=0&&i.maxCount!=i.count?2:0:0,f.invalidateRow(t.row),f.render(),n.stopPropagation(),n.stopImmediatePropagation()),f.getColumns()[t.cell].id==="countAdmin"&&(i=t.grid.getDataItem(t.row),i.checkStateAdmin=i.checkStateAdmin==0?1:i.checkStateAdmin==1?i.countAdmin!=0&&i.maxCount!=i.countAdmin?2:0:0,f.invalidateRow(t.row),f.render(),n.stopPropagation(),n.stopImmediatePropagation())}),f.onSelectedRowsChanged.subscribe(function(){var r=ko.unwrap(t()),e,u;r.ignoreUpdate||(e=r.sortedData||ko.unwrap(r.data),r.ignoreUpdate=!0,u=_.map(f.getSelectedRows(),function(n){return e[n]}),_.isEqual(u,r.selectedRows())||r.selectedRows(u),r.ignoreUpdate=!1)}),f.onCellChange.subscribe(function(){e.checkForChanges&&e.checkForChanges()}),e.selectedRows.subscribe(function(n){var t,i,r;if(n=_.filter(n,function(n){return!!n}),i=e.sortedData||ko.unwrap(e.data),!_.isEqual(_.map(f.getSelectedRows(),function(n){return i[n]}),n)){if(r=[],n.length==i.length)for(t=0;t<n.length;t++)r.push(t);else for(t=0;t<n.length;t++)r.push(_.indexOf(i,n[t]));f.setSelectedRows(r)}}),f.onBeforeEditCell.subscribe(function(n,t){var i=t.item,r=t.cell,u=t.column;return e.canEditCell&&!e.canEditCell(i,r,u)?!1:!0}),f.onSort.subscribe(function(n,i){var r=ko.unwrap(t());r.ignoreUpdate=!0,sortGridData(i.sortCols,r),r.selectedRows(r.selectedRows()),r.ignoreUpdate=!1,f.invalidate(),f.render()}),a=function(){f.resizeCanvas()},$(window).resize(a),d=window.gridRefresh.subscribe(function(){setTimeout(function(){f.resizeCanvas()},100)}),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){d.dispose(),$(window).unbind("resize",a)}),$(n).tooltip({selector:"[title]",container:"body",html:!0}),f.setSortColumn("name",!0),{controlsDescendantBindings:!0}},update:function(n,t){var i=ko.unwrap(t()),r,u,f;(ko.unwrap(i.data),i.ignoreUpdate)||(sortGridData(ko.unwrap(i.sortBy),i),r=$(n).data("grid"),u=_.filter(i.selectedRows.peek()||[],function(n){return!!n}),r.setSelectedRows([]),ko.computed(function(){i.selectedRows([])}).dispose(),f={getItem:function(n){var t=i.sortedData||ko.unwrap(i.data);return t[n]},getLength:function(){var n=i.sortedData||ko.unwrap(i.data);return n.length},getItemMetadata:function(n){var r=i.sortedData||ko.unwrap(i.data),t;return(i.getRowClass&&(t=i.getRowClass(r[n])),t)?{cssClasses:t}:null}},r.setData(f),r.resizeCanvas(),r.render(),i.keepSelected&&u.length&&ko.computed(function(){i.selectedRows(u)}).dispose())}},function(){function n(n,t,i){var u,r;if(ko.utils.domData.get(n,"tooltip-setup")!==!0){ko.utils.domData.set(n,"tooltip-setup",!0);var f=$(n),e=f.parents(".modal-content, #Main"),o="body";e.length&&(o=e.get(0)),u=ko.unwrap(t()),ko.utils.domData.set(n,"tooltip-value",u),r=$.extend({trigger:"hover",container:o},i),r=Object.prototype.toString.call(u)==="[object Object]"?$.extend(u,r):$.extend({title:function(){return ko.unwrap(t())}},r),f.tooltip(r),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){$(n).tooltip("destroy")})}}function t(t,i){var f=ko.utils.domData.get(t,"tooltip-value"),r,u;if(f==undefined){r=ko.unwrap(i()),r&&n(t,i,{dynamicPos:!!r&&typeof r=="object"?r.placement==null:!0});return}f!==ko.unwrap(i())&&(u=$(t).tooltip().data()["bs.tooltip"].$tip,u&&u.hasClass("in")&&$(t).tooltip(ko.unwrap(i())?"show":"hide"))}ko.bindingHandlers.tooltip={init:function(t,i){var u=ko.unwrap(i());u&&n(t,i,{dynamicPos:!!u&&typeof u=="object"?u.placement==null:!0})},update:t},ko.bindingHandlers.ltooltip={init:function(t,i){n(t,i,{placement:"left"})}},ko.bindingHandlers.rtooltip={init:function(t,i){n(t,i,{placement:"right",container:".navbar-nav",delay:{show:500,hide:1}})}},ko.bindingHandlers.dtooltip={init:function(t,i){var u=ko.unwrap(i());n(t,i,{dynamicPos:!!u&&typeof u=="object"?u.placement==null:!0,delay:{show:1e3,hide:100}})}},ko.bindingHandlers.dbtooltip={init:function(t,i){n(t,i,{placement:"bottom",html:!0,delay:{show:350,hide:100}})}},ko.bindingHandlers.tooltipDelegate={init:function(t,i,r,u){var f=ko.unwrap(i());$(t).on("mouseenter",f.selector,function(){var r=ko.contextFor(this),t,i;t=f.scope==="this"?u:ko.unwrap(r[f.scope||"$data"]),i=ko.unwrap(r[f.data||"$data"]),n(this,function(){return{delay:{show:0,hide:100},placement:f.placement||"right"}},{html:!0,title:function(){return f.method?t[f.method](i):i}}),$(this).tooltip("show")});$(t).on("mouseleave",f.selector,function(){$(this).tooltip("hide")})}},ko.bindingHandlers.tooltipToolbar={init:function(t){$(t).on("mouseenter","li",function(){var t=$(this).find("a")[0].title,i=$(this).find("a")[0].rel;i=="horizontalrule"&&(t="Insert Horizontal Rule"),i=="link"&&(t="URL Link"),i==="programLink"&&(t="Program Link"),i=="fontcolor"&&(t="Font Color"),i=="backcolor"&&(t="Back Color"),n(this,function(){return{delay:{show:0,hide:100},placement:"bottom"}},{title:t}),$(this).tooltip("show")})}},ko.bindingHandlers.popover={init:function(n,t){t()&&ko.utils.domData.get(n,"popover-setup")!==!0&&(ko.utils.domData.set(n,"popover-setup",!0),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){$(n).popover("destroy")}),$(n).popover({trigger:t().trigger||"hover",title:function(){var t=ko.utils.domData.get(n,"popover-title");return t?t():null},content:function(){var t=ko.utils.domData.get(n,"popover-content");return t?t():null},html:!0,container:"body"}))},update:function(n,t,i,r,u){var f=ko.unwrap(t());if(f){if(f.content)ko.utils.domData.set(n,"popover-title",function(){return f.title}),ko.utils.domData.set(n,"popover-content",function(){return f.content});else if(f.template){var e=ko.unwrap(f.data),o=ko.unwrap(f.title),s=ko.unwrap(f.template);ko.utils.domData.set(n,"popover-title",function(){return o}),ko.utils.domData.set(n,"popover-content-value",null),ko.utils.domData.set(n,"popover-content",function(){var t=ko.utils.domData.get(n,"popover-content-value"),r,i;return(!t||f.nocache)&&(r="data"in f?u.createChildContext(e,f.as):u,i=document.createElement("div"),ko.renderTemplate(s,r,{},i),t=i.innerHTML,ko.utils.domData.set(n,"popover-content-value",t)),t})}ko.unwrap(i().showOnUpdate)&&$(n).popover("show")}}}}(),morphs={regions:{section:"regions",areas:[{id:41,title:"Upper body-Anterior",coords:"83,57,83,117,46,117,45,130,41,142,37,166,28,189,21,204,18,216,20,233,16,232,16,232,15,234,17,237,18,241,14,237,14,237,13,239,16,242,18,245,15,245,13,243,9,242,14,248,5,246,5,222,11,208,14,194,17,176,26,141,26,134,27,116,27,97,32,86,36,81,40,77,47,76,53,75,66,69,72,64,73,60,72,56,83,57,83,57"},{id:40,title:"Torso-Anterior",coords:"83,118,83,219,68,201,55,188,52,183,51,176,54,156,51,138,47,124,47,118,83,118,83,118"},{id:39,title:"Lower body-Anterior",coords:"66,201,76,212,81,220,62,311,61,314,59,318,63,331,57,370,58,383,58,392,55,405,45,417,43,421,39,422,27,422,26,418,37,406,44,395,47,382,40,340,45,291,42,279,42,233,51,185,59,193,66,201,66,201"},{id:3058,title:"Upper body-Posterior",coords:"104,65,117,72,132,76,139,82,144,89,144,118,149,149,154,177,157,195,159,213,163,221,165,227,165,246,156,252,154,250,152,249,152,245,156,240,156,236,156,233,154,229,149,236,148,233,153,213,136,176,130,147,126,117,84,117,84,44,90,48,94,54,98,60,104,65,104,65"},{id:3057,title:"Torso-Posterior",coords:"123,118,123,123,119,137,116,149,116,168,115,173,110,177,101,182,92,189,87,199,86,209,85,219,85,118,123,118,123,118"},{id:3056,title:"Lower body-Posterior",coords:"118,187,126,223,128,258,125,296,126,319,130,341,124,392,126,399,129,402,134,404,140,409,135,412,129,414,124,419,119,421,115,419,112,403,114,388,108,351,108,332,110,324,87,218,88,211,88,203,90,196,94,189,100,185,106,182,113,177,118,170,118,179,118,187,118,187"}]},muscles:{section:"muscles",areas:[{mid:1,id:10,title:"Abdominals",coords:"84, 110, 84, 220, 68, 198, 51, 183, 51, 163, 52, 157, 52, 138, 68, 150, 69, 118"},{mid:2,id:11,title:"Arm anterior",coords:"45, 97, 46, 106, 48, 122, 46, 132, 41, 149, 31, 161, 27, 146, 27, 125, 30, 111"},{mid:3,id:12,title:"Arm posterior",coords:"127, 101, 146, 116, 148, 141, 145, 153, 141, 159, 132, 147, 126, 126, 125, 113"},{mid:4,id:13,title:"Lower back",coords:"121, 195, 115, 183, 107, 182, 99, 183, 87, 193, 86, 145, 94, 128, 99, 113, 101, 108, 102, 147, 106, 164, 112, 159, 116, 158, 119, 173, 120, 191"},{mid:43,id:2631,title:"Lattissimus dorsi",coords:"101, 108, 112, 113, 127, 104, 125, 121, 121, 139, 116, 156, 111, 161, 106, 165, 102, 154"},{mid:6,id:18,title:"Hand",coords:"160, 212, 165, 229, 167, 243, 166, 248, 160, 254, 152, 247, 157, 231, 150, 236, 150, 221, 152, 213"},{mid:6,id:18,title:"Hand",coords:"12, 206, 22, 213, 20, 222, 25, 232, 16, 249, 7, 246, 4, 222"},{mid:7,id:15,title:"Foream anterior",coords:"20, 210, 30, 182, 39, 166, 41, 150, 33, 160, 26, 146, 19, 167, 17, 185, 13, 206"},{mid:8,id:16,title:"Foream posterior",coords:"148, 145, 161, 211, 154, 212, 137, 179, 130, 146, 141, 158"},{mid:9,id:17,title:"Gluteals",coords:"86, 194, 86, 224, 109, 236, 122, 246, 130, 261, 127, 225, 121, 195, 113, 183, 102, 183"},{mid:10,id:19,title:"Lower leg anterior",coords:"46, 389, 58, 386, 59, 365, 61, 349, 65, 341, 61, 317, 55, 334, 50, 331, 45, 319, 41, 328, 39, 345, 43, 365"},{mid:11,id:20,title:"Lower leg posterior",coords:"122, 302, 131, 335, 131, 362, 124, 396, 112, 398, 113, 375, 110, 359, 105, 336, 108, 324, 111, 309"},{mid:12,id:21,title:"Medial thigh",coords:"82, 220, 69, 202, 62, 216, 63, 222, 68, 244, 71, 270"},{mid:13,id:22,title:"Neck anterior",coords:"56, 75, 71, 65, 73, 55, 84, 57, 84, 83, 76, 75"},{mid:14,id:23,title:"Chest &amp; Thoracic",coords:"83, 83, 84, 111, 69, 118, 69, 150, 53, 138, 49, 127, 46, 98, 48, 89, 58, 73, 75, 76"},{mid:15,id:24,title:"Shoulder anterior",coords:"56, 76, 47, 89, 46, 97, 28, 114, 28, 98, 31, 86, 38, 77, 50, 74"},{mid:16,id:25,title:"Shoulder posterior",coords:"102, 107, 113, 112, 128, 102, 147, 115, 146, 109, 132, 91, 123, 77, 138, 79, 107, 95"},{mid:42,id:2658,title:"Deltoid middle",coords:"145, 109, 144, 87, 137, 78, 132, 75, 133, 75, 124, 79"},{mid:17,id:26,title:"Thigh anterior",coords:"71, 270, 65, 300, 65, 310, 60, 320, 55, 333, 43, 318, 41, 304, 45, 293, 41, 269, 41, 231, 43, 217, 62, 217"},{mid:44,id:2686,title:"Hip flexors",coords:"43, 216, 52, 184, 68, 201, 61, 216"},{mid:18,id:27,title:"Thigh posterior",coords:"128, 316, 126, 296, 129, 260, 121, 245, 105, 234, 89, 225, 96, 269, 100, 285, 108, 321, 113, 310, 122, 303"},{mid:19,id:28,title:"Upper trapezius &amp; neck",coords:"124, 77, 112, 69, 100, 61, 94, 52, 89, 46, 86, 44, 86, 71, 104, 73"},{mid:41,id:2630,title:"Middle back",coords:"88, 143, 101, 111, 110, 89, 119, 82, 123, 77, 86, 71"}]},musclesRefined:{section:"musclesRefined",areas:[{mid:1,id:2633,title:"Abdominals",coords:"84, 110, 84, 220, 68, 198, 51, 183, 51, 163, 52, 157, 52, 138, 68, 150, 69, 118"},{mid:2,id:2634,title:"Arm anterior",coords:"45, 97, 46, 106, 48, 122, 46, 132, 41, 149, 31, 161, 27, 146, 27, 125, 30, 111"},{mid:3,id:2635,title:"Arm posterior",coords:"127, 101, 146, 116, 148, 141, 145, 153, 141, 159, 132, 147, 126, 126, 125, 113"},{mid:4,id:2636,title:"Lower back",coords:"121, 195, 115, 183, 107, 182, 99, 183, 87, 193, 86, 145, 94, 128, 99, 113, 101, 108, 102, 147, 106, 164, 112, 159, 116, 158, 119, 173, 120, 191"},{mid:43,id:2653,title:"Lattissimus dorsi",coords:"101, 108, 112, 113, 127, 104, 125, 121, 121, 139, 116, 156, 111, 161, 106, 165, 102, 154"},{mid:6,id:2641,title:"Hand",coords:"160, 212, 165, 229, 167, 243, 166, 248, 160, 254, 152, 247, 157, 231, 150, 236, 150, 221, 152, 213"},{mid:6,id:2641,title:"Hand",coords:"12, 206, 22, 213, 20, 222, 25, 232, 16, 249, 7, 246, 4, 222"},{mid:7,id:2639,title:"Foream anterior",coords:"20, 210, 30, 182, 39, 166, 41, 150, 33, 160, 26, 146, 19, 167, 17, 185, 13, 206"},{mid:8,id:2640,title:"Foream posterior",coords:"148, 145, 161, 211, 154, 212, 137, 179, 130, 146, 141, 158"},{mid:9,id:2637,title:"Gluteals",coords:"86, 194, 86, 224, 109, 236, 122, 246, 130, 261, 127, 225, 121, 195, 113, 183, 102, 183"},{mid:10,id:2642,title:"Lower leg anterior",coords:"46, 389, 58, 386, 59, 365, 61, 349, 65, 341, 61, 317, 55, 334, 50, 331, 45, 319, 41, 328, 39, 345, 43, 365"},{mid:11,id:2643,title:"Lower leg posterior",coords:"122, 302, 131, 335, 131, 362, 124, 396, 112, 398, 113, 375, 110, 359, 105, 336, 108, 324, 111, 309"},{mid:12,id:2644,title:"Medial thigh",coords:"82, 220, 69, 202, 62, 216, 63, 222, 68, 244, 71, 270"},{mid:13,id:2645,title:"Neck anterior",coords:"56, 75, 71, 65, 73, 55, 84, 57, 84, 83, 76, 75"},{mid:14,id:2646,title:"Chest &amp; Thoracic",coords:"83, 83, 84, 111, 69, 118, 69, 150, 53, 138, 49, 127, 46, 98, 48, 89, 58, 73, 75, 76"},{mid:15,id:2647,title:"Shoulder anterior",coords:"56, 76, 47, 89, 46, 97, 28, 114, 28, 98, 31, 86, 38, 77, 50, 74"},{mid:16,id:2648,title:"Shoulder posterior",coords:"102, 107, 113, 112, 128, 102, 147, 115, 146, 109, 132, 91, 123, 77, 138, 79, 107, 95"},{mid:42,id:2659,title:"Deltoid middle",coords:"145, 109, 144, 87, 137, 78, 132, 75, 133, 75, 124, 79"},{mid:17,id:2649,title:"Thigh anterior",coords:"71, 270, 65, 300, 65, 310, 60, 320, 55, 333, 43, 318, 41, 304, 45, 293, 41, 269, 41, 231, 43, 217, 62, 217"},{mid:44,id:2686,title:"Hip flexors",coords:"43, 216, 52, 184, 68, 201, 61, 216"},{mid:18,id:2650,title:"Thigh posterior",coords:"128, 316, 126, 296, 129, 260, 121, 245, 105, 234, 89, 225, 96, 269, 100, 285, 108, 321, 113, 310, 122, 303"},{mid:19,id:2651,title:"Upper trapezius &amp; neck",coords:"124, 77, 112, 69, 100, 61, 94, 52, 89, 46, 86, 44, 86, 71, 104, 73"},{mid:41,id:2652,title:"Middle back",coords:"88, 143, 101, 111, 110, 89, 119, 82, 123, 77, 86, 71"}]},joints:{section:"joints",areas:[{id:37,title:"Wrist",coords:"156,202,164,225,163,230,160,231,155,228,151,222,154,212,150,203,152,202,154,201,156,202,156,202"},{id:37,title:"Wrist",coords:"16,199,20,201,21,203,19,208,18,214,20,221,12,221,10,220,8,217,10,212,12,205,13,202,13,199,16,199,16,199"},{id:36,title:"Shoulder Girdle",coords:"144,100,142,110,137,115,130,118,122,118,114,117,108,113,104,107,103,98,104,91,106,83,112,78,121,75,133,77,140,82,144,90,144,100,144,100"},{id:36,title:"Shoulder Girdle",coords:"66,89,64,105,60,113,54,117,48,119,42,119,35,119,30,118,27,114,26,107,28,97,32,87,40,80,50,76,57,78,62,80,65,85,66,89,66,89"},{id:35,title:"Neck",coords:"97,41,97,73,73,73,73,41,97,41"},{id:34,title:"Knee",coords:"126,322,128,329,127,333,124,334,118,335,108,332,111,323,103,301,106,298,111,296,119,293,123,295,125,297,127,306,126,322,126,322"},{id:34,title:"Knee",coords:"65,297,62,309,59,318,62,327,61,330,57,332,51,333,45,330,41,325,44,314,42,306,44,293,45,290,47,287,52,284,59,286,63,289,65,297,65,297"},{id:33,title:"Hip &amp; Pelvis",coords:"119,174,118,179,126,221,126,230,112,226,108,222,105,218,102,208,101,196,102,190,104,184,109,178,116,174,119,174,119,174"},{id:33,title:"Hip &amp; Pelvis",coords:"68,195,65,217,63,223,59,228,53,232,47,233,43,232,43,224,51,174,58,177,63,182,67,189,68,195,68,195"},{id:32,title:"Elbow",coords:"146,141,151,162,150,166,147,168,141,168,134,166,133,155,130,143,137,141,146,141,146,141"},{id:32,title:"Elbow",coords:"41,143,37,170,31,170,28,170,26,167,23,163,21,158,24,147,26,136,33,135,39,138,41,143,41,143"},{id:31,title:"Back",coords:"98,75,98,216,70,216,73,75,98,75"},{id:30,title:"Ankle",coords:"124,394,127,399,130,404,129,409,126,413,118,418,115,417,114,412,112,405,112,393,124,390,124,394,124,394"},{id:30,title:"Ankle",coords:"58,393,58,401,56,406,52,407,46,405,42,400,44,392,46,380,56,379,58,393,58,393"}]}},window.morphs=morphs,window.formatMorphAreas=formatAreas,ko.bindingHandlers.morph={init:function(n,t){$(n).on("click","area",function(){var n=this.href.split("/"),i=parseInt(n[n.length-1]);return t()(i),!1})}},ko.bindingHandlers.morphMultiple={init:function(n,t){$(n).on("click","area",function(){var i=this.href.split("/"),r=parseInt(i[i.length-1]),n=t()(),u=n.indexOf(r);return u===-1?n.push(r):n.splice(u,1),t()(n),!1})}},window.tempRangeFilter="",Chart=function(){function n(){}return n.prototype.calculateMaxXData=function(n){if(!this.xFormattedSeries.length)return null;var t=d3.max(this.xFormattedSeries);return n==="Day"?d3.time.day.offset(t,1):n==="Week"?d3.time.week.offset(t,1):n==="Month"?d3.time.month.offset(t,1):n==="Year"?d3.time.year.offset(t,1):d3.time.day.offset(t,1)},n.prototype.calculateMinXData=function(n){if(!this.xFormattedSeries.length)return null;var t=d3.min(this.xFormattedSeries);return n==="Day"?d3.time.day.offset(t,-1):n==="Week"?d3.time.week.offset(t,-1):n==="Month"?d3.time.month.offset(t,-1):n==="Year"?d3.time.year.offset(t,-1):d3.time.day.offset(t,-1)},n.prototype.calculateMaxYData=function(n,t){var i,e=_.filter(n,function(n){return n.type=="stacked bar"}),r,u,f;return(e.length>0?(r=_.filter(n,function(n){return n.barIndex!==undefined}),i=d3.max(r.map(function(n){return d3.max(n.points.map(function(n){return d3.max(n)}))}))):(r=_.filter(n,function(n){return n.barIndex!==undefined}),i=d3.max(r.map(function(n){return d3.max(n.points.map(function(n){return d3.max(n)}))})),u=_.filter(n,function(n){return n.barIndex===undefined}),u.length>0&&(f=d3.max(u.map(function(n){return d3.max(n.points)})),i=d3.max([i,f]))),t!=undefined&&(t=parseFloat(t),t>i||i===undefined||i===null))?t:i==undefined?0:i},n.prototype.calculateMinYData=function(n,t){var f=_.filter(n,function(n){return n.barIndex!==undefined}),i=d3.min(f.map(function(n){return d3.min(n.points.map(function(n){return d3.min(n)}))})),r=_.filter(n,function(n){return n.barIndex===undefined}),u;return(r.length>0&&(u=d3.min(r.map(function(n){return d3.min(n.points)})),i=d3.min([i,u])),t!=undefined&&(t=parseFloat(t),t<i||i===undefined||i===null))?t:i===undefined||i===null?0:i},n.prototype.isOrdinal=function(){return this.xAxisType==="ordinal"},n.prototype.isSerial=function(){return this.xAxisType==="serial"},n.prototype.isSerialDate=function(){return this.xAxisType==="date"},n.prototype.addYAxis=function(n,t){var f=this,o=1,h=1,u,s,c,v;n.type==="Normal"||(n.type==="Distance (km)"&&(o=.001),n.type==="Distance (m)"&&(o=1),n.type==="Distance (cm)"&&(o=100),n.type==="Distance (mm)"&&(o=1e3),n.type==="Distance (mi)"&&(h=1609.34),n.type==="Distance (ft)"&&(h=.3048),n.type==="Distance (in)"&&(h=.0254)),o*=parseFloat(n.multiplier||"1");var e={y:d3.scale.linear().range([this.height,0])},l=(n.label||"").toLowerCase().indexOf("time")===0||(n.label||"").toLowerCase().indexOf("duration")===0||n.type.indexOf("Time")===0,a=l?10/60:10,i=this.calculateMaxYData(n.series,n.maxYValue),r=this.calculateMinYData(n.series,n.minYValue);(n.maxYValue===undefined||n.maxYValue===null)&&i<=a&&(r>0&&(r=0),i=a),r>0&&(n.minYValue===null||n.minYValue===undefined)&&(u=i-r,u==0&&(u=i),r=Math.max(0,r-u*.05)),i>0&&r>=0&&(n.maxYValue===undefined||n.maxYValue===null)&&(u=i-r,u==0&&(u=i),i=Math.max(0,i+u*.05)),e.y.domain([r,i]),s=d3.svg.axis().scale(e.y).orient(t).ticks(4),l&&s.tickFormat(function(t){var f,r,u,i;return n.type==="Time (hours)"?(t=t/60,f=Math.floor(t/60).toString(10),r=(Math.floor(t)%60).toString(10),f+":"+(r.length===1?"0":"")+r):n.type==="Time (seconds)"?(u=Math.floor(t).toString(10),i=(t-Math.floor(t)).toFixed(3).substr(1),u+(i!==".000"?i:"")):(r=Math.floor(t/60).toString(10),u=(Math.floor(t)%60).toString(10),i=(t-Math.floor(t)).toFixed(3).substr(1),r+":"+(u.length===1?"0":"")+u+(i!==".000"?i:""))}),c=i>=1e4?" vsmall":i>=1e3?" small":"",t==="left"&&(v=this.chart.append("g"),v.attr("class","y axis axisLeft"+c).call(s).append("text").attr("class","chart-label").attr("transform","rotate(-90)").attr("y",-40).attr("dy","0em").attr("x",-(this.height/2)).style("text-anchor","middle").text(n.label),this.chart.append("g").attr("class","tickLines").attr("style","stroke:#efebeb").call(s.tickSize(-this.width-20,0).tickFormat(""))),t==="right"&&this.chart.append("svg:g").attr("class","y axis axisRight"+c).attr("transform","translate("+(this.width+15)+",0)").call(s).append("text").attr("class","chart-label").attr("transform","rotate(-90)").attr("y",50).attr("x",-(this.height/2)).style("text-anchor","middle").text(n.label),n.shadingRanges&&ko.unwrap(n.shadingRanges).forEach(function(n){var t=parseFloat(n.minValue)||null,u=parseFloat(n.maxValue)||null,s,o;(t!=null||u!=null)&&((t>u&&(t=u),n.label&&f.rangesForLegend.push(n),t==null&&(t=r),t<r&&(t=r),t>i)||(u==null&&(u=i),u>i&&(u=i),u<r)||(s=e.y(t),o=e.y(u),f.chart.append("rect").attr("fill",n.color).attr("class","chartShading").attr("x",0).attr("width",f.width+15).attr("y",o).attr("height",s-o)))}),n.referenceLine&&n.referenceLine.forEach(function(n){var t=e.y(n.yValue);f.chart.append("line").attr("x1",0).attr("y1",t).attr("x2",f.width+15).attr("y2",t).attr("class","markerLine").attr("stroke",n.color),n.label&&f.chart.append("text").attr("fill",n.color).attr("class","referenceLineLabel").attr("x",-f.margin.left).attr("y",t).text(n.label)}),this.y.push(e)},n}(),ko.bindingHandlers.chart={init:function(){},update:function(n,t,i){var ft,u,v,c,tt,h,ut,gt,ti;if(n.innerHTML="",ft=ko.unwrap(t()),u=ko.unwrap(ft.data),u&&u.xAxis&&(u.yAxisLeft||u.yAxisRight)){var r=new Chart,f=new helper,ni=new dataHelper,l=new legend,nt=f.runTimeChartValue(u,u.runTimeOptions.chart),e={},p;r.axisType=u.xAxis===undefined?"Date":u.xAxis.flipaxis!==undefined?u.xAxis.flipaxis:u.xAxis.axisType,u.runTimeOptions.axis!=="default"&&(r.axisType=u.runTimeOptions.axis),v=!1,r.sortBy="Default",u.runTimeOptions.sort!=="default"&&(r.sortBy=u.runTimeOptions.sort),r.showLabels=u.runTimeOptions.showLabels,r.showGroupedData=!1,r.statistics=u.runTimeOptions.statistics,r.hasAvgLine=!1,c=0,tt=0,r.runtimeRedrawing=!1,r.showMean=!1,r.showRuntimeOptions=!1,r.xMouseTracker=ft.xMouseTracker,r.runTimeOptions=u.runTimeOptions;var w=f.getDateFormat(main.dateFormat),o=_.filter(u.yAxisLeft.series,function(n){return n.barIndex!==undefined}),y=[];u.yAxisRight&&(y=_.filter(u.yAxisRight.series,function(n){return n.barIndex!==undefined})),r.seriesList=[],r.rangesForLegend=[],ni.setupYAxisLeft(u),ni.setupYAxisRight(u),h=u.xAxis.series.length>8,h===!0&&(c=10),r.axisType==="Date"?(h=u.xAxis.series.length>8,h===!0&&(c=20)):o.length>0&&o[0].chartdata!==undefined&&(h=_.uniq(o[0].chartdata.GroupLegend).length>5,h===!0&&(c=d3.max(o[0].chartdata.GroupLegend.map(function(n){return n.length*3}))));var pt=f.getChartDimensions(n,i(),c,tt),ii=pt.margins,b=pt.width,k=pt.height;if(!(b<=0)&&!(k<=0)){r.drawChartSelectionDropdown=function(){var n,f,t,i,e;r.runtimeOptionsContainer.selectAll(".chartSelectionDropdown").remove(),n=["Bar","Line","Area","Table"],o.length>0&&(o[0].type==="pie"&&(n=["Pie","Table"]),f=_.filter(u.yAxisLeft.series,function(n){return n.type=="radar"||n.type=="grouped radar"}),f.length>0&&(n=["Radar","Table"])),t={Bar:"/Content/Images/ChartIcons/18/chart-bar_18.png",Pie:"/Content/Images/ChartIcons/18/chart-pie_18.png",Line:"/Content/Images/ChartIcons/18/chart-line_18.png",Area:"/Content/Images/ChartIcons/18/chart-area_18.png",Stack:"/Content/Images/ChartIcons/18/stack_bar_18.png",Table:"/Content/Images/ChartIcons/18/table_18.png",Radar:"/Content/Images/ChartIcons/18/radar_19.png"},i=r.runtimeOptionsContainer.append("div").attr("class","no-print").attr("class","chartSelectionDropdown dropdown").attr("style","display:inline-block;margin:2px;cursor:pointer;float:right"),i.append("button").attr("class","dropdown-toggle no-print").attr("data-toggle","dropdown").append("img").attr("style","vertical-align:middle").attr("src",t[nt]),e=i.append("div").attr("class","no-print dropdown-menu").attr("style","min-width: 10px;").append("ul"),e.selectAll(".options").data(n).enter().append("li").on("click",function(n){nt=n,u.runTimeOptions.chart=n,u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1),gt(u.runTimeOptions.chart)}).append("img").attr("src",function(n){return t[n]}).attr("style","margin:5px")},r.dateGroupSelectionDropdown=function(){if(u.isFitnessChart!==!0){r.runtimeOptionsContainer.selectAll(".dateGroupSelectionDropdown").remove();var t=["Day","Week","Month","Year"],n=r.runtimeOptionsContainer.append("div").attr("class","dateGroupSelectionDropdown").attr("style","display:inline-block;margin:2px;").append("select").attr("class","no-print").style("height","24px").on("change",function(){u.runTimeOptions.runtimeGroupBy=d3.select(this).property("value"),u.runtimeGroupBy(d3.select(this).property("value")),u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1),u.requeryCount(u.requeryCount()+1)});n.selectAll("option").remove(),n.selectAll("option").data(t).enter().append("option").attr("value",function(n){return n}).text(function(n){return n}),u.runtimeGroupBy&&n.property("value",u.runtimeGroupBy()),u.runTimeOptions.runtimeGroupBy!=="default"&&(n.property("value",u.runTimeOptions.runtimeGroupBy),u.runtimeGroupBy()!==u.runTimeOptions.runtimeGroupBy&&u.runtimeGroupBy(u.runTimeOptions.runtimeGroupBy))}},r.testCountSelectionDropdown=function(){if(u.isFitnessChart===!0){r.runtimeOptionsContainer.selectAll(".testCountSelectionDropdown").remove();var t=[{display:"Recent",val:1},{display:"2 Recent",val:2},{display:"3 Recent",val:3},{display:"4 Recent",val:4},{display:"5 Recent",val:5},{display:"6 Recent",val:6},{display:"10 Recent",val:10},{display:"All",val:100}],n=r.runtimeOptionsContainer.append("div").attr("class","testCountSelectionDropdown").attr("style","display:inline-block;margin:2px;").append("select").attr("class","no-print").style("height","24px").on("change",function(){u.runTimeOptions.runtimeGroupBy=d3.select(this).property("value"),u.runTimeOptions.testCount=u.runTimeOptions.runtimeGroupBy,u.testCount(d3.select(this).property("value")),u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1),u.requeryCount(u.requeryCount()+1)});n.selectAll("option").remove(),n.selectAll("option").data(t).enter().append("option").attr("value",function(n){return n.val}).text(function(n){return n.display}),u.testCount&&n.property("value",u.testCount()),u.runTimeOptions.testCount!=="default"&&(n.property("value",u.runTimeOptions.testCount),u.testCount()!==u.runTimeOptions.testCount&&(u.testCount(u.runTimeOptions.testCount),u.requeryCount(u.requeryCount()+1)))}},r.statisticsDropdown=function(){if(nt==="Bar"||nt==="Area"||nt==="Line"){r.runtimeOptionsContainer.selectAll(".statisticsDropdown").remove();var t=["No Stats","Mean","SD"],n=r.runtimeOptionsContainer.append("div").attr("class","statisticsDropdown").attr("style","display:inline-block;margin:2px;").append("select").attr("class","no-print").style("height","24px").on("change",function(){r.statistics=d3.select(this).property("value"),u.runTimeOptions.statistics=r.statistics,u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1),ut()});n.selectAll("option").remove(),n.selectAll("option").data(t).enter().append("option").attr("value",function(n){return n}).text(function(n){return n}),r.statistics&&n.property("value",r.statistics)}},e.Radar=function(){for(var i=new radarChart,e={w:b>k?k:b,h:b<k?b:k,levels:4,maxYValue:u.yAxisLeft.maxYValue||0,minYValue:u.yAxisLeft.minYValue||0},t=!0,n=0;n<g.length;n++)g[n].points.length>0&&(t=!1);t!==!0&&(f.setupXAxisRadar(r,u.xAxis,w),i.drawRadar(r,g,e),u.showLegend==!0&&l.setupLegendRadar(r),r.drawChartSelectionDropdown())},e.Pie=function(){var n=new pieChart;r.isPieChart=!0,u.xAxis.label=a[0].label,a[0].chartdata={},a[0].chartdata.Legend=[a[0].points.map(function(){return"Value"})],r.seriesList.push(a[0]),n.drawPieChart(r,a,u.xAxis),r.drawChartSelectionDropdown()},e.Area=function(n){var t=new areaChart;_.each(et,function(i){return t.createArea(r,i,0,r.axisType,n)}),u.yAxisRight&&_.each(ot,function(i){return t.createArea(r,i,1,r.axisType,n)})},e.Range=function(){var f=new rangeChart,i;et.length+st.length+s.length+rt.length+ot.length+it.length+d.length+ht.length>1||r.isPieChart||wt.length==2&&u.showRange&&u.showRange()&&!u.hasMultipleClient&&(r.runtimeOptionsContainer.selectAll(".chartRange").remove(),i=r.runtimeOptionsContainer.append("div").attr("class","chartRange no-print").attr("style","display:inline-block;margin:2px;float:right").append("select").attr("class","no-print").style("height","25px").on("change",function(){var t=d3.select(this).property("value");r.chart.selectAll(".chartRange").remove(),t==="Range"&&(f.createRange(r,wt,u.xAxis.series,0),u.yAxisRight&&bt.length==2&&f.createRange(r,bt,u.xAxis.series,1))}),i.selectAll("option").remove(),i.append("option").attr("value","No Range").text("No Range"),i.append("option").attr("value","Range").text("Range"))},e.AvgLine=function(n){var i=new avgLine;ct.length>0&&i.createAvgLine(r,ct[0].points,0,r.axisType,n,ct[0].label),lt.length>0&&i.createAvgLine(r,lt[0].points,1,r.axisType,n,lt[0].label)},e.Bar=function(t){var i=_.filter(s,function(n){return n.barIndex!==undefined}),o=new barChart,h,c,a,v;i.length>1?i[0].points.length>1?(r.runtimeOptionsContainer.selectAll(".multipleBarMeasure").remove(),h=r.runtimeOptionsContainer.append("div").attr("class","multipleBarMeasure no-print").attr("style","display:inline-block;margin:2px;float:right").append("select").attr("class","no-print").style("height","25px").on("change",function(){var h=d3.select(this).property("value"),a,c;r.svg.selectAll(".barGroup").remove(),r.svg.selectAll(".meanGroup").remove(),d3.select(n).selectAll(".legendDiv").remove(),a=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf","#37bd9d","#ffbb23","#FB8383","#3598DB","#BE90D4","#9CDAEE","#F64747","#6C7A89","#ACD15F","#D2527F","#36D7B7","#F39C12","#5C97BF","#FDE3A7","#1B9E77","#E08283","#BDC3C7","#CE0073","#86E2D5","#EF92D2","#66A3D2","#FF7300","#00AF64","#DBA13A","#FF2100","#9CDAEE","#34AF8C","#CB5073","#B3F581","#9685E3","#FFE576","#FF8876","#00B83B","#E97BC8","#69A8D4","#80105B","#7FEFA4","#DF004A","#65B8D2","#DDB0EF","#BCDF62","#DFBC62","#6590A2","#E8762C","#4D6F9F","#D53448","#684B98","#DF7E62","#DFD162","#459E6E","#D45D6E","#5B4F9A","#DFC662","#6DBD53","#FFCB87","#E788E7","#8EC0E7","#BAD052","#9884E3","#FD868C","#89EF7E","#FFFB87","#FFB787","#75DECC","#B67EE1","#FFD787","#ED7DBC","#D2F983","#829FE1"],r.color=d3.scale.ordinal().range(a),h==2&&i.length==2?(f.drawMultiMeasureBars(i,r,o,t),r.isMultiMeasure===!0&&l.setupLegend(r,n)):(s.map(function(n){n.isSelectedMeasure=!1}),r.isMultiMeasure=!1,c=0,i[h].YAxisScaleIndex!==undefined&&(c=i[h].YAxisScaleIndex),i[h].isSelectedMeasure=!0,o.createBarChart(r,i[h],c,r.axisType,t),e.Mean(!0),r.isMultiMeasure===!0&&l.setupLegend(r,n)),u.runTimeOptions.measure=h,u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1)}),h.selectAll("option").remove(),h.selectAll(".measureOption").data(i).enter().append("option").attr("value",function(n,t){return t}).text(function(n){return n.label}),i.length==2&&h.append("option").attr("value",i.length).text("Both"),u.runTimeOptions.measure==="default"?u.isFitnessChart&&i.length==2?(r.runTimeOptions.chart="Bar",f.drawMultiMeasureBars(i,r,o,t),h.property("value",2)):(c=i[0],c.isSelectedMeasure=!0,o.createBarChart(r,c,0,r.axisType,t)):u.runTimeOptions.measure==2&&i.length==2?(f.drawMultiMeasureBars(i,r,o,t),h.property("value",2)):(c=i[u.runTimeOptions.measure],c.isSelectedMeasure=!0,a=i.length>0?u.runTimeOptions.measure:0,o.createBarChart(r,c,a,r.axisType,t),h.property("value",u.runTimeOptions.measure))):(v={barIndex:0,points:i.map(function(n){return n.chartdata!==undefined?n.chartdata.YAxis[0]:[]}),legend:i.map(function(n){return n.label}),ytype:i[0].ytype,ytypes:i.map(function(n){return n.ytype}),IsGroupedBar:!0,chartdata:{GroupLegend:i.map(function(n){return n.label}),GroupName:"",Legend:i.map(function(n){return n.label}),XAxis:i[0].chartdata.XAxis,YAxis:i.map(function(n){return n.chartdata.YAxis[0]}),YAxisScaleIndex:i.map(function(n){return n.YAxisScaleIndex===undefined?undefined:1}),ytypes:i.map(function(n){return n.ytype})}},o.createBarChart(r,v,0,r.axisType,t)):_.each(s,function(n){return o.createBarChart(r,n,0,r.axisType,t)})},e.Line=function(n){var t=_.filter(st,function(n){return n.barIndex!==undefined}),i=new lineChart,f;t.length>1?t[0].points.length>1?(r.runtimeOptionsContainer.selectAll(".multipleLineMeasure").remove(),f=r.runtimeOptionsContainer.append("div").attr("class","multipleLineMeasure").attr("style","display:inline-block;margin:2px;").append("select").style("height","25px").on("change",function(){var u=d3.select(this).property("value"),f=t[u];r.svg.selectAll(".lineG").remove(),i.createLine(r,f,0,r.axisType,n)}),f.selectAll("option").remove(),f.selectAll("option").data(t).enter().append("option").attr("value",function(n,t){return t}).text(function(n){return n.label}),i.createLine(r,t[0],0,r.axisType,n)):_.each(t,function(t){return i.createLine(r,t,0,r.axisType,n)}):_.each(t,function(t){return i.createLine(r,t,0,r.axisType,n)}),u.yAxisRight&&_.each(it,function(t){return i.createLine(r,t,1,r.axisType,n)})},e.StackedBar=function(n){var t=_.filter(rt,function(n){return n.barIndex!==undefined}),e,i,f,o,s;u.yAxisRight&&(e=_.filter(ht,function(n){return n.barIndex!==undefined}),t=t.concat(e)),i=new stackedBar,t.length&&(t.length>1?t[0].points.length>1?(r.runtimeOptionsContainer.selectAll(".multiplestackedBarMeasure").remove(),f=r.runtimeOptionsContainer.append("div").attr("class","multiplestackedBarMeasure").attr("style","display:inline-block;margin:2px;float:right").append("select").style("height","25px").on("change",function(){var u=d3.select(this).property("value");r.svg.selectAll(".barGroup").remove(),i.createStackedBar(r,t[u],0,r.axisType,n)}),f.selectAll("option").remove(),f.selectAll("option").data(t).enter().append("option").attr("value",function(n,t){return t}).text(function(n){return n.label}),o=t[0],i.createStackedBar(r,o,0,r.axisType,n)):(s={barIndex:0,points:t.map(function(n){return n.chartdata!==undefined?n.chartdata.YAxis[0]:[]}),legend:t.map(function(n){return n.label}),IsGroupedBar:!0,chartdata:{GroupLegend:t.map(function(n){return n.label}),GroupName:"",Legend:t.map(function(n){return n.label}),XAxis:t[0].chartdata.XAxis,YAxis:t.map(function(n){return n.chartdata.YAxis[0]}),YAxisScaleIndex:t.map(function(n){return n.YAxisScaleIndex===undefined?undefined:1}),ytypes:t.map(function(n){return n.ytype})}},i.createStackedBar(r,s,0,r.axisType,n)):i.createStackedBar(r,t[0],0,r.axisType,n))},e.Mean=function(){var t,i=_.filter(o,function(n){return n.barIndex!==undefined}),e;i.map(function(n){n.yScaleIndex=0}),u.yAxisRight?(e=_.filter(u.yAxisRight.series,function(n){return n.barIndex!==undefined}),e.map(function(n){n.yScaleIndex=1}),t=i.concat(e)):t=i,f.drawMean(r,t,s.length>1)},e.Table=function(){var s=new TableChart,i,e,o;f.setupRunTimeContainer(r,n,b,k),r.drawChartSelectionDropdown(),i=r.runtimeOptionsContainer.append("div").attr("style","display:inline-block;margin:2px;"),e=function(){var n=i.append("button").attr("class","btn btn-default no-print");n.on("mouseenter",function(){f.ShowPopover(this,"Export data","")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){var i,t,r=f.getTableData(u),n;i=new Blob([r.join("\n")],{type:"text/csv"}),t=document.createElement("a"),n="VisualCoaching-",u.yAxisLeft&&(n=n+u.yAxisLeft.label),u.yAxisRight&&(n=n+"and "+u.yAxisRight.label),n=n+" vs "+u.xAxis.label+".csv",t.download=n,t.href=window.URL.createObjectURL(i),t.style.display="none",document.body.appendChild(t),t.click()}).append("i").attr("class","fa fa-download")},e(),o=f.getTableData(u),s.drawTable(r,n,o)},e.Heat=function(n){var i=new heatChart,t=_.filter(kt,function(n){return n.barIndex!==undefined});t.length>0&&_.each(t,function(t){return i.createHeatChart(r,t,0,r.axisType,n)}),r.drawChartSelectionDropdown()},e.Dot=function(n){var i=new dotChart,t=_.filter(yt,function(n){return n.barIndex!==undefined});t.length>0&&_.each(t,function(t){return i.createDotChart(r,t,0,r.axisType,n)}),r.drawChartSelectionDropdown()},e.GroupedBar=function(n){var t=_.filter(at,function(n){return n.barIndex!==undefined}),i=new groupedBarChart;t.length>0&&i.createGroupedBarChart(r,t[0],0,r.axisType,n)},e.BarPie=function(n){var t=_.filter(dt,function(n){return n.barIndex!==undefined}),i=new barPieChart;t.length>0&&i.createBarPieChart(r,t[0],0,r.axisType,n)};var vt=function(n){e.Area(n),e.Range(n,!0),e.Bar(n),e.StackedBar(n),e.Line(n),e.Mean(n),e.AvgLine(n),e.Dot(n),e.Heat(n),e.BarPie(n),e.GroupedBar(n)},ri=[],ui=[],et=[],ot=[],st=[],it=[],s=[],d=[],rt=[],ht=[],wt,bt=[],g,a,ct=[],lt=[],yt,kt,dt,at;et=_.filter(o,function(n){return n.type=="area"}),st=_.filter(o,function(n){return n.type=="line"}),s=_.filter(o,function(n){return n.type=="grouped bar"}),rt=_.filter(o,function(n){return n.type=="stacked bar"}),wt=_.filter(u.yAxisLeft.series,function(n){return n.type=="range"}),ct=_.filter(u.yAxisLeft.series,function(n){return n.type=="line"&&n.barIndex===undefined}),g=_.filter(u.yAxisLeft.series,function(n){return n.type=="radar"||n.type=="grouped radar"}),a=_.filter(u.yAxisLeft.series,function(n){return n.type=="pie"}),yt=_.filter(u.yAxisLeft.series,function(n){return n.type=="dot"}),kt=_.filter(u.yAxisLeft.series,function(n){return n.type=="heat"}),dt=_.filter(u.yAxisLeft.series,function(n){return n.type=="barPie"}),at=_.filter(u.yAxisLeft.series,function(n){return n.type=="barGrouped"}),u.yAxisRight&&(ot=_.filter(y,function(n){return n.type=="area"}),it=_.filter(y,function(n){return n.type=="line"}),d=_.filter(y,function(n){return n.type=="grouped bar"}),ht=_.filter(y,function(n){return n.type=="stacked bar"}),bt=_.filter(u.yAxisRight.series,function(n){return n.type=="range"}),lt=_.filter(u.yAxisRight.series,function(n){return n.type=="line"&&n.barIndex===undefined}),d.map(function(n){n.YAxisScaleIndex=1}),s=s.concat(d)),r.avgLineDataRight=lt,r.avgLineData=ct,ut=function(){var t,o,d,y,et,ot,st,ht,ct;if(f.setupRunTimeContainer(r,n,b,k),f.setupChartArea(r,n,b,k,ii,u.color),g.length>0){e.Radar();return}if(a.length>0){e.Pie();return}r.dateRange={end:ft.endDate(),start:ft.startDate(),groupBy:u.runtimeGroupBy===undefined?"":u.runtimeGroupBy()},f.setupXAxis(r,u,w,r.axisType,h,[],r.sortBy),r.yAxisLeft=u.yAxisLeft,r.addYAxis(u.yAxisLeft,"left"),u.yAxisRight&&r.addYAxis(u.yAxisRight,"right"),vt(!1),(u.showLegend===undefined||u.showLegend==!0)&&r.axisType==="Date"?l.setupLegend(r,n):r.isMultiMeasure===!0?l.setupLegend(r,n):r.axisType==="ordinal"?l.setupLegend(r,n):r.yAxisLeft&&r.yAxisLeft.shadingRanges&&r.yAxisLeft.shadingRanges.length&&l.setupLegend(r,n,!0),d3.select(n).style("position","relative"),t=r.runtimeOptionsContainer.append("div").attr("style","display:inline-block;margin:2px;float:left"),r.drawChartSelectionDropdown(),r.dateGroupSelectionDropdown(),r.testCountSelectionDropdown(),r.statisticsDropdown(),s.length>0&&(o=!1,u.isFitnessChart===!0?(s[0].points.length<2||s.length>1)&&(o=!0):(s.length>0&&it.length>0&&(o=!0),s[0].points.length<2&&s.length===1&&(o=!0),s[0].points.length>1&&s.length>1&&(o=!0)),t.append("button").attr("class","btn btn-default no-print").on("mouseenter",function(){f.ShowPopover(this,r.axisType==="Group"?"Show Date on Axis":"Show Legend on Axis","")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){var t,h,o;r.axisType==="Date"?(r.axisType="Group",y("Enable")):r.axisType==="Group"&&(r.axisType="Date",y("Disable")),f.hidePopover(this),t=!1,c=5,h=v?20:0,o=_.filter(u.yAxisLeft.series,function(n){return n.barIndex!==undefined}),r.axisType==="Date"?(t=u.xAxis.series.length>8,t===!0&&(c=20)):o[0].chartdata!==undefined&&(t=_.uniq(o[0].chartdata.GroupLegend).length>5,t===!0&&(c=d3.max(o[0].chartdata.GroupLegend.map(function(n){return n.length*3}))));var s=f.getChartDimensions(n,i(),c,tt),a=s.margins,p=s.width,b=s.height;f.setupChartArea(r,n,p,b,a,u.color),f.setupXAxis(r,u,w,r.axisType,t,[],r.sortBy),r.addYAxis(u.yAxisLeft,"left"),u.yAxisRight&&r.addYAxis(u.yAxisRight,"right"),vt(!1),v==!0&&f.brushFilter(r,e,r.axisType,t,u,w,n,r.sortBy),(u.showLegend===undefined||u.showLegend==!0)&&r.axisType==="Date"&&l.setupLegend(r,n),u.runTimeOptions.axis=r.axisType,u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1)}).classed("disabled",o).append("i").attr("class","fa fa-exchange")),d=function(){t.append("button").attr("class","no-print").on("mouseenter",function(){f.ShowPopover(this,v?"Hide fliter brush":"Show fliter brush","")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){var t,o,s,h;f.hidePopover(this),v=!v,t=!1,o=5,tt=v?20:0,s=_.filter(u.yAxisLeft.series,function(n){return n.barIndex!==undefined}),r.axisType==="Date"?(t=u.xAxis.series.length>8,t===!0&&(o=20)):s[0].chartdata!==undefined&&(t=_.uniq(s[0].chartdata.GroupLegend).length>5,t===!0&&(o=d3.max(s[0].chartdata.GroupLegend.map(function(n){return n.length*3})))),h=f.getChartDimensions(n,i(),o,tt),f.setupChartArea(r,n,h.width,h.height,h.margins,u.color),f.setupXAxis(r,u,w,r.axisType,t,[],r.sortBy),r.addYAxis(u.yAxisLeft,"left"),u.yAxisRight&&r.addYAxis(u.yAxisRight,"right"),vt(!1),v==!0&&f.brushFilter(r,e,r.axisType,t,u,w,n,r.sortBy),(u.showLegend===undefined||u.showLegend==!0)&&r.axisType==="Date"&&l.setupLegend(r,n)}).append("i").attr("class","fa fa-filter")},d(),y=function(n){p!==undefined&&(n==="Enable"?p.classed("disabled",!1):p.classed("disabled",!0))},et=function(){nt==="Bar"&&(p=t.append("button").attr("class","btn btn-default no-print"),p.on("mouseenter",function(){var t="";r.sortBy==="Default"?t="Show Descending":r.sortBy==="Descending"?t="Show Ascending":r.sortBy==="Ascending"&&(t="Show Default"),f.ShowPopover(this,t,"")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){var t,o;f.hidePopover(this),r.sortBy==="Default"?r.sortBy="Descending":r.sortBy==="Descending"?r.sortBy="Ascending":r.sortBy==="Ascending"&&(r.sortBy="Default"),r.sortBy==="Default"?d3.select(this).select("i").attr("class","fa fa-sort"):r.sortBy==="Ascending"?d3.select(this).select("i").attr("class","fa fa-sort-amount-asc"):r.sortBy==="Descending"&&d3.select(this).select("i").attr("class","fa fa-sort-amount-desc"),t=_.filter(u.yAxisLeft.series,function(n){return n.barIndex!==undefined}),r.axisType==="Date"?(h=u.xAxis.series.length>8,h===!0&&(c=20)):t[0].chartdata!==undefined&&(h=_.uniq(t[0].chartdata.GroupLegend).length>5,h===!0&&(c=d3.max(t[0].chartdata.GroupLegend.map(function(n){return n.length*3})))),o=f.getChartDimensions(n,i(),c,tt),f.setupChartArea(r,n,o.width,o.height,o.margins,u.color),f.setupXAxis(r,u,w,r.axisType,h,[],r.sortBy),r.addYAxis(u.yAxisLeft,"left"),u.yAxisRight&&r.addYAxis(u.yAxisRight,"right"),vt(!1),v==!0&&f.brushFilter(r,e,r.axisType,h,u,w,n,r.sortBy),(u.showLegend===undefined||u.showLegend==!0)&&r.axisType==="Date"&&l.setupLegend(r,n),u.runTimeOptions.sort=r.sortBy,u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1)}).append("i").attr("class","fa fa-sort"),r.sortBy==="Default"?p.select("i").attr("class","fa fa-sort"):r.sortBy==="Ascending"?p.select("i").attr("class","fa fa-sort-amount-asc"):r.sortBy==="Descending"&&p.select("i").attr("class","fa fa-sort-amount-desc"))},et(),y(r.axisType==="Date"?"Disable":"Enable"),ot=function(){var n=t.append("button").attr("class","btn btn-default no-print");n.on("mouseenter",function(){f.ShowPopover(this,"Export data","")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){var i,t,r=f.getTableData(u),n;i=new Blob([r.join("\n")],{type:"text/csv"}),t=document.createElement("a"),n="VisualCoaching-",u.yAxisLeft&&(n=n+u.yAxisLeft.label),u.yAxisRight&&(n=n+"and "+u.yAxisRight.label),n=n+" vs "+u.xAxis.label+".csv",t.download=n,t.href=window.URL.createObjectURL(i),t.style.display="none",document.body.appendChild(t),t.click()}).append("i").attr("class","fa fa-download")},ot(),st=function(){t.selectAll(".showLabel").remove();var n=t.append("button").attr("class","btn btn-default no-print showLabel");n.on("mouseenter",function(){f.hidePopover(this),f.ShowPopover(this,r.showLabels?"Hide Labels":"Show Labels","")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){f.hidePopover(this),r.showLabels=!r.showLabels,u.runTimeOptions.showLabels=r.showLabels,u.runtimeSettingSaveCount(u.runtimeSettingSaveCount()+1),ut()}).append("i").attr("class","fa fa-font")},(s.length||rt.length)&&st(),ht=function(){var n=t.append("button").attr("class","btn btn-default no-print");n.on("mouseenter",function(){f.hidePopover(this),f.ShowPopover(this,r.showGroupedData?"Un-group Data":"Group Data","")}).on("mouseleave",function(){f.hidePopover(this)}).on("click",function(){r.showGroupedData=!r.showGroupedData,ut()}).append("i").attr("class","fa fa-bar-chart")},at.length&&ht(),ct=function(){var n=t.append("button").on("click",function(){var t=$("#popover-content").html();f.ShowBigPopOver(this,t,"","bottom")}).attr("class","btn btn-default no-print").append("span").html("Exercise"),i=t.append("button").on("click",function(){console.log("Exercise")}).attr("class","btn btn-default no-print").append("span").html("Anatomy")},at.length&&ct()},ut(),gt=function(t){r.runtimeRedrawing=!0,d3.select(n).html(""),u.yAxisRight&&(ot=[],it=[],d=[],ht=[]),et=[],st=[],s=[],rt=[],g=[],a=[],yt=[];switch(t){case"Bar":s=o,u.yAxisRight&&(d=y,d.map(function(n){n.YAxisScaleIndex=1}),s=s.concat(d));break;case"Pie":a=JSON.parse(JSON.stringify(o));break;case"Line":st=o,u.yAxisRight&&(it=y);break;case"Area":et=o,u.yAxisRight&&(ot=y);break;case"Radar":g=JSON.parse(JSON.stringify(o));break;case"Stack":rt=o,u.yAxisRight&&(ht=y);break;case"Dot":yt=o;break;case"Heat":kt=o;break;case"Table":e.Table(!0);break;case"Bar + Pie":dt=o;break;case"GroupedBar":at=o}t!=="Table"&&ut()},ti=function(){u.runTimeOptions.chart!=="default"&&gt(u.runTimeOptions.chart)},ti()}}}};var TableChart=function(){function n(){}return n.prototype.drawTable=function(n,t,i){var r=d3.select(t).append("div").attr("style","overflow: auto; overflow-y: auto;font-size:12px;padding:5px;"),u=new helper;r.on("mouseleave",function(){u.hidePopover(this)}).on("mouseenter",function(){u.hidePopover(this)}).on("click",function(){u.hidePopover(this)});r.style("width","100%").style("height","320px");var e=r.append("table").attr("style","width: auto !important").attr("class","table"),o=e.selectAll(".tableRow").data(i).enter().append("tr").style("font-weight",function(n,t){return t===0?"bold":"normal"}),f=o.selectAll(".tableCol").data(function(n){return n}).enter().append("td");f.attr("style","padding:5px;border:1px solid #e2e2e2;text-align:right;"),f.html(function(n){return n})},n}(),areaChart=function(){function n(){}return n.prototype.createArea=function(n,t,i,r,u){var f,c;if(t.chartdata!==undefined&&(f=new helper,t.barIndex!==undefined)){var y=this,e=n.y[i],o=n.x;u===!1&&n.seriesList.push(t);var h=n.chartWidth/n.xAxisNumberValues,l=d3.svg.area().x(function(t){return n.isOrdinal()?n.x(t.xValue)+h/2:n.x(t.xValue)}).y0(n.height).y1(function(n){return e.y(n.yValue)}).defined(function(n){return n.yValue!=null}),a=d3.svg.line().x(function(t){return n.x(t.xValue)}).y(function(n){return e.y(n.yValue)}).defined(function(n){return n.yValue!=null}),v=f.FormatData(t.chartdata,n.xFormattedSeries,r,n.sortBy),s=n.chart.selectAll(".lineGroup").data(v).enter().append("g").attr("transform","translate("+n.x.rangeBand()/2+",0)").attr("class","lineG");t.hideDots||(c=s.selectAll(".circle").data(function(n){return n.values.filter(function(n){return o(n.xValue)!==undefined})}).enter().append("circle").attr("class","lineG").classed("node",!0).attr({fill:"#ffffff",stroke:function(t){return n.color(t.color)}}).attr("cx",function(t){return n.isOrdinal()?n.x(t.xValue)+h/2:n.x(t.xValue)}).attr("cy",function(n){return n.yValue!==null?e.y(n.yValue):-2e3}).on("mouseenter",function(i){var u,e,o,s;i.yValue!==null&&(u="",u=u+"<strong>"+t.label+"<\/strong>: ",i.yValue!==null&&(f.checkIfTime(t,i)===!0?(e=f.timeFormattedValue(t.ytype,i.yValue),u=u+(r!=="Date"?" <strong> (Avg) <\/strong> "+e:e)+"<br/>"):u=u+(r!=="Date"?" <strong> (Avg) <\/strong> "+i.yValue.toFixed(2):i.yValue.toFixed(2))+"<br/>"),o=r,t.chartdata&&t.chartdata.filterIsClientList&&r==="Group"&&(o="Client"),u=u+"<strong>"+o+"<\/strong>: "+i.xValue+"<br/>",s=t.label!==i.color?i.color:"",f.ShowPopover(this,u,s),n.xMouseTracker&&n.xMouseTracker({value:new Date(i.xValue)}))}).on("mouseleave",function(){f.hidePopover(this)}),c.attr("r",4)),s.append("path").attr("d",function(n){return l(n.values.filter(function(n){return o(n.xValue)!==undefined}))}).attr("fill-opacity",".3").attr("opacity",t.hideDots?"0.5":"1.0").attr("class","chartLine").attr("fill",function(t){return n.color(t.key)}),s.append("path").attr("d",function(n){return a(n.values.filter(function(n){return o(n.xValue)!==undefined}))}).attr("fill","none").attr("opacity",t.hideDots?"0.5":"1.0").attr("class","chartLine").attr("stroke",function(t){return n.color(t.key)})}},n}(),barChart=function(){function n(){}return n.prototype.createBarChart=function(n,t,i,r,u){var l,s,v,c;if(t.chartdata!==undefined&&t.barIndex!==undefined){var o=new helper,y=o.FormatData(t.chartdata,n.xFormattedSeries,r,n.sortBy),p=this,f=n.y[i];u===!1&&n.seriesList.push(t),l=n.x.rangeBand(),s=l/(n.width*1.2),s=s>.4?s:.15;var h=d3.scale.ordinal().domain(y.map(function(n){return n.key})).rangeBands([0,l],s),a=n.chart.selectAll(".barG").data(y).enter().append("g").attr("class","barGroup").attr("transform",function(n){return"translate("+h(n.key)+",0)"}),e=a.selectAll("rect").data(function(n){return n.values}).enter().append("rect").attr("width",h.rangeBand()).attr("y",function(n){return n.yValue==null||n.yValue==undefined?0:n.yValue<0?f.y(0):f.y(n.yValue)}).attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:n.x(t.xValue)});n.isMultiMeasure===!0?e.attr("fill",n.color(t.label)):e.attr("fill",function(t){return n.color(t.color)}),n.showLabels&&(v=a.selectAll(".barlabel").data(function(n){return n.values}).enter().append("text").attr("text-anchor","middle").style("font-size","12px").attr("dy",-3).attr("y",function(n){return n.yValue!==null&&n.yValue!==undefined?f.y(n.yValue):0}).attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:n.x(t.xValue)+h.rangeBand()/2}).text(function(n){return n.yValue===null||n.yValue===undefined?"":n.yValue%1==0?n.yValue:n.yValue.toFixed(2)}),v.each(function(t){if(t.YAxisScaleIndex!==undefined){var i=d3.select(this),r=n.y[t.YAxisScaleIndex];i.attr("y",function(n){return n.yValue!==null?r.y(n.yValue):0})}}));e.on("mouseenter",function(i,u){var f="",c;f=t.IsGroupedBar?f+"<strong>"+i.color+"<\/strong>: ":f+"<strong>"+t.label+"<\/strong>: ";var l=r,s="",e=i.xValue,h=t.label!==i.color?i.color:"";t.chartdata&&t.chartdata.filterIsClientList&&r==="Group"&&(l="Client",t.chartdata.filterIsClientList&&!t.chartdata.isFitnessChart&&(s=" <strong> (Avg) <\/strong> "),e=t.legend[u].label,h=e),i.yValue!==null&&(o.checkIfTime(t,i)===!0?(c=o.timeFormattedValue(t.ytype,i.yValue),f=f+(r!=="<\/strong>Date<\/strong>"?s+c:c)+"<br/>"):f=f+(r!=="<\/strong>Date<\/strong>"?s+i.yValue.toFixed(2):i.yValue.toFixed(2))+"<br/>"),i.date!==undefined&&(f=f+"<strong>Date:<\/strong> "+i.date+"<br/>"),f=f+"<strong>"+l+"<\/strong>: "+e+"<br/>",r==="ordinal"&&(h=e,f="<strong>"+i.color+"<\/strong>: "+i.yValue.toFixed(2)),o.ShowPopover(this,f,h),n.xMouseTracker&&n.xMouseTracker({value:new Date(i.xValue)})}).on("mouseleave",function(){o.hidePopover(this)}).on("contextmenu",function(n){if(n&&n.xValue&&n.xValue.indexOf("-")==4){var t=n.xValue,i=n.color;alert(t+", "+i)}d3.event.preventDefault()});n.x.rangeBand!==undefined&&r==="Client"&&a.attr("transform",function(n){return"translate("+h(n.key)+",0)"}),e.attr("height",function(t){if(t.yValue==null||f.y(t.yValue)==undefined||f.y(t.yValue)<0)return 0;var i=f.y.domain()[0]<0?f.y(0):n.height;return t.yValue<0?f.y(t.yValue)-f.y(0):i-f.y(t.yValue)}),e.each(function(t){if(t.YAxisScaleIndex!==undefined){var f=d3.select(this),i=n.y[t.YAxisScaleIndex],r=0,u=0,e=i.y.domain()[0]<0?i.y(0):n.height;t.yValue!==null&&t.yValue!==undefined&&(r=t.yValue<0?i.y(t.yValue)-i.y(0):e-i.y(t.yValue),u=t.yValue<0?i.y(0):i.y(t.yValue)),f.attr("height",r).attr("y",u)}}),n.isMultiMeasure===!0&&(c=d3.scale.ordinal().domain([0,1]).rangeBands([0,h.rangeBand()],.1),e.attr("transform","translate("+c(n.multiMeasureIndex)+",0)"),e.attr("width",c.rangeBand()),n.showLabels&&v.attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:n.x(t.xValue)+c(n.multiMeasureIndex)+c.rangeBand()/2})),f.y.domain()[0]<0&&n.chart.append("rect").attr("x",0).attr("width",n.width).attr("y",f.y(0)).attr("height",1)}},n}(),barPieChart=function(){function n(){}return n.prototype.createBarPieChart=function(n,t,i){function d(n){var t=d3.interpolate(this._current,n);return this._current=t(0),function(n){return y(t(n))}}var g=new helper,nt=this,e=[{xValue:"2018-03-16",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-16",part:"Shoulder",side:"right",yValue:1},{xValue:"2018-03-15",part:"Kee",side:"left",yValue:6},{xValue:"2018-03-15",part:"Kee",side:"right",yValue:10},{xValue:"2018-03-14",part:"Shoulder",side:"left",yValue:3},{xValue:"2018-03-14",part:"Shoulder",side:"right",yValue:1},{xValue:"2018-03-13",part:"Ankle",side:"left",yValue:6},{xValue:"2018-03-13",part:"Ankle",side:"right",yValue:9},{xValue:"2018-03-12",part:"Shoulder",side:"left",yValue:4},{xValue:"2018-03-12",part:"Shoulder",side:"right",yValue:3},{xValue:"2018-03-11",part:"Kee",side:"left",yValue:8},{xValue:"2018-03-11",part:"Kee",side:"right",yValue:9},{xValue:"2018-03-10",part:"Shoulder",side:"left",yValue:10},{xValue:"2018-03-10",part:"Shoulder",side:"right",yValue:2},{xValue:"2018-03-09",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-09",part:"Shoulder",side:"right",yValue:8},{xValue:"2018-03-08",part:"Eldow",side:"left",yValue:3},{xValue:"2018-03-08",part:"Eldow",side:"right",yValue:1},{xValue:"2018-03-07",part:"Shoulder",side:"left",yValue:7},{xValue:"2018-03-07",part:"Shoulder",side:"right",yValue:9},{xValue:"2018-03-06",part:"Eldow",side:"left",yValue:3},{xValue:"2018-03-06",part:"Eldow",side:"right",yValue:2},{xValue:"2018-03-16",part:"Kee",side:"left",yValue:9},{xValue:"2018-03-16",part:"Kee",side:"right",yValue:3},{xValue:"2018-03-15",part:"Shoulder",side:"left",yValue:7},{xValue:"2018-03-15",part:"Shoulder",side:"right",yValue:2},{xValue:"2018-03-14",part:"Ankle",side:"left",yValue:8},{xValue:"2018-03-14",part:"Ankle",side:"right",yValue:9},{xValue:"2018-03-13",part:"Shoulder",side:"left",yValue:2},{xValue:"2018-03-13",part:"Shoulder",side:"right",yValue:3},{xValue:"2018-03-12",part:"Kee",side:"left",yValue:7},{xValue:"2018-03-12",part:"Kee",side:"right",yValue:5},{xValue:"2018-03-11",part:"Eldow",side:"left",yValue:3},{xValue:"2018-03-11",part:"Eldow",side:"right",yValue:8},{xValue:"2018-03-10",part:"Shoulder",side:"left",yValue:4},{xValue:"2018-03-10",part:"Shoulder",side:"right",yValue:7},{xValue:"2018-03-09",part:"Kee",side:"left",yValue:6},{xValue:"2018-03-09",part:"Kee",side:"right",yValue:1},{xValue:"2018-03-08",part:"Eldow",side:"left",yValue:6},{xValue:"2018-03-08",part:"Eldow",side:"right",yValue:4},{xValue:"2018-03-07",part:"Kee",side:"left",yValue:3},{xValue:"2018-03-07",part:"Kee",side:"right",yValue:10},{xValue:"2018-03-06",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-06",part:"Shoulder",side:"right",yValue:4}],o=2*n.width/3,c,l,a,w;n.x.rangeBands([0,o],.05).domain(e.map(function(n){return n.xValue}));var s=d3.nest().key(function(n){return n.xValue}).entries(e).map(function(n){return n.y=d3.sum(n.values.map(function(n){return n.yValue})),n}),b=d3.nest().key(function(n){return n.part}).entries(e).map(function(n){return n.yValue=d3.sum(n.values.map(function(n){return n.yValue})),n}),f=n.y[i],h=s.map(function(n){return n.y});n.chart.selectAll(".axisLeft").remove(),n.chart.selectAll(".tickLines").remove(),n.chart.selectAll(".axisLeft").remove(),n.chart.selectAll(".xaxis").remove(),f.y.domain([d3.max(h),d3.min(h)]),c=d3.svg.axis().scale(f.y).orient("left"),n.chart.append("g").attr("class","y axis axisLeft").call(c),l=d3.svg.axis().scale(n.x).orient("bottom"),a=n.chart.append("g").attr("class","xaxis").attr("transform","translate(0,"+n.height+")").call(l),a.selectAll("line").style("stroke","#b3b3b3");var k=n.x.rangeBand(),tt=n.chart.selectAll(".barG").data(s).enter().append("rect").attr("fill",function(t){return n.color(t.color)}).attr("width",k).attr("y",function(n){return f.y(n.y)}).attr("x",function(t){return n.x(t.key)===undefined?-2e3:n.x(t.key)}).attr("height",function(t){return n.height-f.y(t.y)}).on("click",function(n){var t=n.values,i=d3.nest().key(function(n){return n.part}).entries(t).map(function(n){return n.yValue=d3.sum(n.values.map(function(n){return n.yValue})),n});w(i)}),v=n.chart.append("g").attr("transform","translate("+(o+n.width/4)+","+n.height/2+")"),y=d3.svg.arc().outerRadius(100).innerRadius(10),p=d3.layout.pie().sort(null).value(function(n){return n.yValue});v.selectAll("path").data(p(b)).enter().append("path").attr("d",y).each(function(n){this._current=n}).style("fill",function(t){return n.color(t.data.key)}),w=function(n){v.selectAll("path").data(p(n)).transition().duration(500).attrTween("d",d)}},n}(),groupedBarChart=function(){function n(){}return n.prototype.createGroupedBarChart=function(n,t,i){var o=new helper,d=this,h=[{xValue:"2018-03-16",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-16",part:"Ankle",side:"right",yValue:1},{xValue:"2018-03-16",part:"Kee",side:"left",yValue:9},{xValue:"2018-03-16",part:"Eldow",side:"right",yValue:3},{xValue:"2018-03-15",part:"Shoulder",side:"left",yValue:6},{xValue:"2018-03-15",part:"Ankle",side:"right",yValue:10},{xValue:"2018-03-15",part:"Kee",side:"left",yValue:7},{xValue:"2018-03-15",part:"Eldow",side:"right",yValue:2},{xValue:"2018-03-14",part:"Shoulder",side:"left",yValue:3},{xValue:"2018-03-14",part:"Ankle",side:"right",yValue:1},{xValue:"2018-03-14",part:"Kee",side:"left",yValue:8},{xValue:"2018-03-14",part:"Eldow",side:"right",yValue:9},{xValue:"2018-03-13",part:"Shoulder",side:"left",yValue:6},{xValue:"2018-03-13",part:"Ankle",side:"right",yValue:9},{xValue:"2018-03-13",part:"Kee",side:"left",yValue:2},{xValue:"2018-03-13",part:"Eldow",side:"right",yValue:3},{xValue:"2018-03-12",part:"Shoulder",side:"left",yValue:4},{xValue:"2018-03-12",part:"Ankle",side:"right",yValue:3},{xValue:"2018-03-12",part:"Kee",side:"left",yValue:7},{xValue:"2018-03-12",part:"Eldow",side:"right",yValue:5},{xValue:"2018-03-11",part:"Shoulder",side:"left",yValue:8},{xValue:"2018-03-11",part:"Ankle",side:"right",yValue:9},{xValue:"2018-03-11",part:"Kee",side:"left",yValue:3},{xValue:"2018-03-11",part:"Eldow",side:"right",yValue:8},{xValue:"2018-03-10",part:"Shoulder",side:"left",yValue:10},{xValue:"2018-03-10",part:"Ankle",side:"right",yValue:2},{xValue:"2018-03-10",part:"Kee",side:"left",yValue:4},{xValue:"2018-03-10",part:"Eldow",side:"right",yValue:7},{xValue:"2018-03-09",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-09",part:"Ankle",side:"right",yValue:8},{xValue:"2018-03-09",part:"Kee",side:"left",yValue:6},{xValue:"2018-03-09",part:"Eldow",side:"right",yValue:1},{xValue:"2018-03-08",part:"Shoulder",side:"left",yValue:3},{xValue:"2018-03-08",part:"Eldow",side:"right",yValue:1},{xValue:"2018-03-08",part:"Kee",side:"left",yValue:6},{xValue:"2018-03-08",part:"Ankle",side:"right",yValue:4},{xValue:"2018-03-07",part:"Shoulder",side:"left",yValue:7},{xValue:"2018-03-07",part:"Eldow",side:"right",yValue:9},{xValue:"2018-03-07",part:"Kee",side:"left",yValue:3},{xValue:"2018-03-07",part:"Ankle",side:"right",yValue:10},{xValue:"2018-03-06",part:"Ankle",side:"left",yValue:3},{xValue:"2018-03-06",part:"Eldow",side:"right",yValue:2},{xValue:"2018-03-06",part:"Kee",side:"left",yValue:5},{xValue:"2018-03-06",part:"Shoulder",side:"right",yValue:4}],w=n.width,e,f,s,l,a,v,y,c,k;if(n.x.rangeBands([0,w],.25).domain(h.map(function(n){return n.xValue})),e=n.showGroupedData?d3.nest().key(function(n){return n.xValue}).entries(h).map(function(n){return n.y=d3.sum(n.values.map(function(n){return n.yValue})),n}):d3.nest().key(function(n){return n.part}).entries(h).map(function(n){return n.y=d3.max(n.values.map(function(n){return n.yValue})),n}),f=n.y[i],s=e.map(function(n){return n.y}),n.chart.selectAll(".axisLeft").remove(),n.chart.selectAll(".tickLines").remove(),n.chart.selectAll(".axisLeft").remove(),n.chart.selectAll(".xaxis").remove(),l=d3.min(s)>0?0:d3.min(s),f.y.domain([l,d3.max(s)]),a=d3.svg.axis().scale(f.y).orient("left"),n.chart.append("g").attr("class","y axis axisLeft").call(a),v=d3.svg.axis().scale(n.x).orient("bottom"),y=n.chart.append("g").attr("class","xaxis").attr("transform","translate(0,"+n.height+")").call(v),y.selectAll("line").style("stroke","#b3b3b3"),c=n.x.rangeBand(),n.showGroupedData)k=n.chart.selectAll(".barG").data(e).enter().append("rect").attr("fill",function(t){return n.color(t.color)}).attr("width",c).attr("y",function(n){return f.y(n.y)}).attr("x",function(t){return n.x(t.key)===undefined?-2e3:n.x(t.key)}).attr("height",function(t){return n.height-f.y(t.y)}).on("mouseenter",function(n){var t="",i=n.key;n.values.forEach(function(n){t=t+"<strong>"+n.part+"<\/strong>: "+n.yValue+"<br/>"}),o.ShowPopover(this,t,i)}).on("mouseleave",function(){o.hidePopover(this)});else var p=d3.scale.ordinal().domain(e.map(function(n){return n.key})).rangeBands([0,c],.05),b=n.chart.selectAll(".barG").data(e).enter().append("g").attr("class","barGroup").attr("transform",function(n){return"translate("+p(n.key)+",0)"}),k=b.selectAll("rect").data(function(n){return n.values}).enter().append("rect").attr("fill",function(t){return n.color(t.part)}).attr("width",p.rangeBand()).attr("y",function(n){return n.yValue!==null&&n.yValue!==undefined?f.y(n.yValue):0}).attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:n.x(t.xValue)}).attr("height",function(t){return t.yValue==null||f.y(t.yValue)==undefined||f.y(t.yValue)<0?0:n.height-f.y(t.yValue)}).on("mouseenter",function(n){var t="",i=n.xValue;t=t+"<strong>"+n.part+"<\/strong>: "+n.yValue+"<br/>",o.ShowPopover(this,t,i)}).on("mouseleave",function(){o.hidePopover(this)})},n}(),lineChart=function(){function n(){}return n.prototype.createLine=function(n,t,i,r,u){var f,s,c;if(t.chartdata!==undefined&&(f=new helper,t.barIndex!==undefined)){var a=this,h=n.y[i],e=n.x;u===!1&&n.seriesList.push(t);var v=n.chartWidth/n.xAxisNumberValues,l=d3.svg.line().x(function(t){return n.x(t.xValue)}).y(function(n){return h.y(n.yValue)}).defined(function(n){return n.yValue!=null}),o=f.FormatData(t.chartdata,n.xFormattedSeries,r,n.sortBy);n.sortBy==="Ascending"?o.map(function(n){n.values.sort(function(n,t){return e.domain().indexOf(n.xValue)-e.domain().indexOf(t.xValue)})}):n.sortBy==="Descending"&&o.map(function(n){n.values.sort(function(n,t){return e.domain().indexOf(t.xValue)-e.domain().indexOf(n.xValue)})}),s=n.chart.selectAll(".lineGroup").data(o).enter().append("g").attr("transform","translate("+n.x.rangeBand()/2+",0)").attr("class","lineG"),t.hideDots||(c=s.selectAll(".circle").data(function(n){return n.values.filter(function(n){return e(n.xValue)!==undefined})}).enter().append("circle").attr("class","lineG").classed("node",!0).attr({fill:"#ffffff",stroke:function(t){return n.color(t.color)}}).attr("cx",function(t){return n.x(t.xValue)===undefined?-2e3:n.x(t.xValue)}).attr("cy",function(n){return n.yValue!==null?h.y(n.yValue):-2e3}).on("mouseenter",function(i){var u,e,o,s,h;i.yValue!==null&&(u="",u=u+"<strong>"+t.label+"<\/strong>: ",i.yValue!==null&&(f.checkIfTime(t,i)===!0?(e=f.timeFormattedValue(t.ytype,i.yValue),u=u+(r!=="Date"?" <strong> (Avg) <\/strong> "+e:e)+"<br/>"):(o=_.isString(i.yValue)?i.yValue:i.yValue.toFixed(2),u=u+(r!=="Date"?" <strong> (Avg) <\/strong> "+o:o)+"<br/>")),s=r,t.chartdata&&t.chartdata.filterIsClientList&&r==="Group"&&(s="Client"),u=u+"<strong>"+s+"<\/strong>: "+i.xValue+"<br/>",h=t.label!==i.color?i.color:"",f.ShowPopover(this,u,h),n.xMouseTracker&&n.xMouseTracker({value:new Date(i.xValue)}))}).on("mouseleave",function(){f.hidePopover(this)}),c.attr("r",4)),s.append("path").attr("d",function(n){return l(n.values.filter(function(n){return e(n.xValue)!==undefined}))}).attr("fill","none").attr("opacity",t.hideDots?"0.5":"1.0").attr("class","chartLine").attr("stroke",function(t){return n.color(t.key)})}},n}(),avgLine=function(){function n(){}return n.prototype.createAvgLine=function(n,t,i,r,u,f){var v=this,e,o=n.x,h=new helper,c=n.y[i],y=n.chartWidth/n.xAxisNumberValues,l,a,s;n.axisType==="Date"?e=t.map(function(t,i){return{xValue:n.xFormattedSeries[i],yValue:t}}):(l=d3.mean(t),e=o.domain().map(function(n){return{xValue:n,yValue:l}}),e.push({})),e=e.filter(function(n){return n.yValue!==null}),a=d3.svg.line().x(function(t,i){return n.axisType=="Date"?n.x(t.xValue)!==undefined?n.x(t.xValue):0:i===0?n.x(t.xValue)-n.x.rangeBand()/2:i===o.domain().length-1?n.x(t.xValue)+n.x.rangeBand()/2:n.x(t.xValue)!==undefined?n.x(t.xValue):0}).y(function(n){return c.y(n.yValue)}).defined(function(t){return t.yValue!=null&&n.x(t.xValue)!==undefined}),s=n.chart.append("g").attr("transform","translate("+n.x.rangeBand()/2+",0)").attr("class","lineG"),s.append("path").attr("d",function(){return a(e)}).attr("fill","none").attr("stroke-width","3").style("stroke-dasharray","5, 1").attr("stroke",function(){return n.color(f)});s.selectAll(".dot").data(e).enter().append("circle").attr("r",function(n){return n.yValue==undefined||n.yValue==null?0:4}).attr("cx",function(t,i){return n.x(t.xValue)==undefined?-5e4:n.axisType=="Date"?n.x(t.xValue):i===0?n.x(t.xValue)-n.x.rangeBand()/2:i===o.domain().length-1?n.x(t.xValue)+n.x.rangeBand()/2:n.x(t.xValue)}).attr("cy",function(n){return n.yValue==undefined||n.yValue==null?-5e4:c.y(n.yValue)}).attr("fill",function(){return n.color(f)}).on("mouseenter",function(n){h.ShowPopover(this,n.xValue+" : "+n.yValue,f)}).on("mouseleave",function(){h.hidePopover(this)})},n}(),heatChart=function(){function n(){}return n.prototype.createHeatChart=function(n,t,i,r,u){var h,e;if(t.chartdata!==undefined&&t.barIndex!==undefined){h=new helper,e=h.FormatData(t.chartdata,n.xFormattedSeries,r,n.sortBy),e=[{key:"first",values:[{xValue:"2018-03-16",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-16",part:"Shoulder",side:"right",yValue:1},{xValue:"2018-03-15",part:"Kee",side:"left",yValue:6},{xValue:"2018-03-15",part:"Kee",side:"right",yValue:10},{xValue:"2018-03-14",part:"Shoulder",side:"left",yValue:3},{xValue:"2018-03-14",part:"Shoulder",side:"right",yValue:1},{xValue:"2018-03-13",part:"Ankle",side:"left",yValue:6},{xValue:"2018-03-13",part:"Ankle",side:"right",yValue:9},{xValue:"2018-03-12",part:"Shoulder",side:"left",yValue:4},{xValue:"2018-03-12",part:"Shoulder",side:"right",yValue:3},{xValue:"2018-03-11",part:"Kee",side:"left",yValue:8},{xValue:"2018-03-11",part:"Kee",side:"right",yValue:9},{xValue:"2018-03-10",part:"Shoulder",side:"left",yValue:10},{xValue:"2018-03-10",part:"Shoulder",side:"right",yValue:2},{xValue:"2018-03-09",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-09",part:"Shoulder",side:"right",yValue:8},{xValue:"2018-03-08",part:"Eldow",side:"left",yValue:3},{xValue:"2018-03-08",part:"Eldow",side:"right",yValue:1},{xValue:"2018-03-07",part:"Shoulder",side:"left",yValue:7},{xValue:"2018-03-07",part:"Shoulder",side:"right",yValue:9},{xValue:"2018-03-06",part:"Eldow",side:"left",yValue:3},{xValue:"2018-03-06",part:"Eldow",side:"right",yValue:2},{xValue:"2018-03-16",part:"Kee",side:"left",yValue:9},{xValue:"2018-03-16",part:"Kee",side:"right",yValue:3},{xValue:"2018-03-15",part:"Shoulder",side:"left",yValue:7},{xValue:"2018-03-15",part:"Shoulder",side:"right",yValue:2},{xValue:"2018-03-14",part:"Ankle",side:"left",yValue:8},{xValue:"2018-03-14",part:"Ankle",side:"right",yValue:9},{xValue:"2018-03-13",part:"Shoulder",side:"left",yValue:2},{xValue:"2018-03-13",part:"Shoulder",side:"right",yValue:3},{xValue:"2018-03-12",part:"Kee",side:"left",yValue:7},{xValue:"2018-03-12",part:"Kee",side:"right",yValue:5},{xValue:"2018-03-11",part:"Eldow",side:"left",yValue:3},{xValue:"2018-03-11",part:"Eldow",side:"right",yValue:8},{xValue:"2018-03-10",part:"Shoulder",side:"left",yValue:4},{xValue:"2018-03-10",part:"Shoulder",side:"right",yValue:7},{xValue:"2018-03-09",part:"Kee",side:"left",yValue:6},{xValue:"2018-03-09",part:"Kee",side:"right",yValue:1},{xValue:"2018-03-08",part:"Eldow",side:"left",yValue:6},{xValue:"2018-03-08",part:"Eldow",side:"right",yValue:4},{xValue:"2018-03-07",part:"Kee",side:"left",yValue:3},{xValue:"2018-03-07",part:"Kee",side:"right",yValue:10},{xValue:"2018-03-06",part:"Shoulder",side:"left",yValue:5},{xValue:"2018-03-06",part:"Shoulder",side:"right",yValue:4}]}],n.chart.selectAll(".axisLeft").remove(),n.chart.selectAll(".tickLines").remove();var c=["Shoulder","Eldow","Kee","Ankle"],o=d3.scale.ordinal().domain(c).rangeBands([0,n.height],.05),l=d3.svg.axis().scale(o).orient("left");n.chart.append("g").attr("class","y axis").call(l).selectAll("text").attr("font-weight","normal");var a=["#ffff8c","#f9d057","#f29e2e","#e76818","#d7191c"],v=d3.scale.quantile().domain(e[0].values.map(function(n){return n.yValue})).range(a),p=this,w=n.y[i];u===!1&&n.seriesList.push(t);var y=n.x.rangeBand(),f=d3.scale.ordinal().domain(e.map(function(n){return n.key})).rangeBands([0,y],.05),s=n.chart.selectAll(".heatG").data(e).enter().append("g").attr("class","barGroup").attr("transform",function(n){return"translate("+f(n.key)+",0)"}),b=s.selectAll(".heat").data(function(n){return n.values}).enter().append("rect").attr("rx",20).attr("ry",20).attr("width",f.rangeBand()/2).attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:t.side==="right"?n.x(t.xValue)+f.rangeBand()/2:n.x(t.xValue)}).attr("y",function(n){return o(n.part)}).attr("height",o.rangeBand()).style("fill",function(n){return v(n.yValue)}),k=s.selectAll(".heat").data(function(n){return n.values}).enter().append("text").attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:t.side==="right"?n.x(t.xValue)+f.rangeBand()/2:n.x(t.xValue)}).attr("y",function(n){return o(n.part)}).attr("dx",f.rangeBand()/4).attr("dy",o.rangeBand()/2+5).attr("text-anchor","middle").style("fill","#fff").text(function(n){return n.side==="right"?"R":"L"});n.x.rangeBand!==undefined&&r==="Client"&&s.attr("transform",function(n){return"translate("+f(n.key)+",0)"})}},n}(),dotChart=function(){function n(){}return n.prototype.createDotChart=function(n,t,i,r,u){if(t.chartdata!==undefined&&t.barIndex!==undefined){var w=this,s=new helper,f=s.FormatData(t.chartdata,n.xFormattedSeries,r,n.sortBy);f=[{key:"first",values:[{xValue:"2018-03-16",part:"Ankle",side:"Left",direction:"Front",yValue:1},{xValue:"2018-03-16",part:"Ankle",side:"Right",direction:"Front",yValue:5},{xValue:"2018-03-16",part:"Ankle",side:"Left",direction:"Back",yValue:7},{xValue:"2018-03-16",part:"Ankle",side:"Right",direction:"Back",yValue:9},{xValue:"2018-03-16",part:"Shoulder",side:"Left",direction:"Front",yValue:10},{xValue:"2018-03-16",part:"Shoulder",side:"Right",direction:"Front",yValue:1},{xValue:"2018-03-16",part:"Shoulder",side:"Left",direction:"Back",yValue:5},{xValue:"2018-03-16",part:"Shoulder",side:"Right",direction:"Back",yValue:7},{xValue:"2018-03-16",part:"Kee",side:"Left",direction:"Front",yValue:3},{xValue:"2018-03-16",part:"Kee",side:"Right",direction:"Front",yValue:2},{xValue:"2018-03-16",part:"Kee",side:"Left",direction:"Back",yValue:4},{xValue:"2018-03-16",part:"Kee",side:"Right",direction:"Back",yValue:6},{xValue:"2018-03-16",part:"Eldow",side:"Left",direction:"Front",yValue:5},{xValue:"2018-03-16",part:"Eldow",side:"Right",direction:"Front",yValue:7},{xValue:"2018-03-16",part:"Eldow",side:"Left",direction:"Back",yValue:9},{xValue:"2018-03-16",part:"Eldow",side:"Right",direction:"Back",yValue:2},{xValue:"2018-03-15",part:"Ankle",side:"Left",direction:"Front",yValue:10},{xValue:"2018-03-15",part:"Ankle",side:"Right",direction:"Front",yValue:2},{xValue:"2018-03-15",part:"Ankle",side:"Left",direction:"Back",yValue:6},{xValue:"2018-03-15",part:"Ankle",side:"Right",direction:"Back",yValue:10},{xValue:"2018-03-15",part:"Shoulder",side:"Left",direction:"Front",yValue:1},{xValue:"2018-03-15",part:"Shoulder",side:"Right",direction:"Front",yValue:9},{xValue:"2018-03-15",part:"Shoulder",side:"Left",direction:"Back",yValue:3},{xValue:"2018-03-15",part:"Shoulder",side:"Right",direction:"Back",yValue:7},{xValue:"2018-03-15",part:"Kee",side:"Left",direction:"Front",yValue:6},{xValue:"2018-03-15",part:"Kee",side:"Right",direction:"Front",yValue:1},{xValue:"2018-03-15",part:"Kee",side:"Left",direction:"Back",yValue:6},{xValue:"2018-03-15",part:"Kee",side:"Right",direction:"Back",yValue:3},{xValue:"2018-03-15",part:"Eldow",side:"Left",direction:"Front",yValue:5},{xValue:"2018-03-15",part:"Eldow",side:"Right",direction:"Front",yValue:8},{xValue:"2018-03-15",part:"Eldow",side:"Left",direction:"Back",yValue:3},{xValue:"2018-03-15",part:"Eldow",side:"Right",direction:"Back",yValue:8},{xValue:"2018-03-14",part:"Ankle",side:"Left",direction:"Front",yValue:5},{xValue:"2018-03-14",part:"Ankle",side:"Right",direction:"Front",yValue:7},{xValue:"2018-03-14",part:"Ankle",side:"Left",direction:"Back",yValue:8},{xValue:"2018-03-14",part:"Ankle",side:"Right",direction:"Back",yValue:4},{xValue:"2018-03-14",part:"Shoulder",side:"Left",direction:"Front",yValue:1},{xValue:"2018-03-14",part:"Shoulder",side:"Right",direction:"Front",yValue:8},{xValue:"2018-03-14",part:"Shoulder",side:"Left",direction:"Back",yValue:7},{xValue:"2018-03-14",part:"Shoulder",side:"Right",direction:"Back",yValue:8},{xValue:"2018-03-14",part:"Kee",side:"Left",direction:"Front",yValue:4},{xValue:"2018-03-14",part:"Kee",side:"Right",direction:"Front",yValue:8},{xValue:"2018-03-14",part:"Kee",side:"Left",direction:"Back",yValue:9},{xValue:"2018-03-14",part:"Kee",side:"Right",direction:"Back",yValue:3},{xValue:"2018-03-14",part:"Eldow",side:"Left",direction:"Front",yValue:6},{xValue:"2018-03-14",part:"Eldow",side:"Right",direction:"Front",yValue:5},{xValue:"2018-03-14",part:"Eldow",side:"Left",direction:"Back",yValue:4},{xValue:"2018-03-14",part:"Eldow",side:"Right",direction:"Back",yValue:3},]}],n.chart.selectAll(".axisLeft").remove(),n.chart.selectAll(".tickLines").remove();var l=["Shoulder","Eldow","Kee","Ankle"],h=["#ffff8c","#f9d057","#f29e2e","#e76818","#d7191c"],c=d3.scale.quantile().domain(f[0].values.map(function(n){return n.yValue})).range(h),l=["Shoulder","Eldow","Kee","Ankle"],e={FrontShoulderLeft:[18,48],FrontShoulderRight:[60,45],BackShoulderLeft:[112,48],BackShoulderRight:[155,48],FrontEldowLeft:[12,80],FrontEldowRight:[65,80],BackEldowLeft:[105,80],BackEldowRight:[160,80],FrontKeeLeft:[28,160],FrontKeeRight:[50,160],BackKeeLeft:[125,160],BackKeeRight:[145,160],FrontAnkleLeft:[30,205],FrontAnkleRight:[45,205],BackAnkleLeft:[125,205],BackAnkleRight:[140,205]},a=d3.scale.ordinal().domain(l).rangeBands([0,n.height],.05),b=d3.svg.axis().scale(a).orient("left"),k=n.y[i];u===!1&&n.seriesList.push(t);var v=n.x.rangeBand(),y=d3.scale.ordinal().domain(f.map(function(n){return n.key})).rangeBands([0,v],.05),o=n.width/2-100,d=n.chart.append("svg:image").attr("preserveAspectRatio","none").attr("xlink:href","./Content/Images/mus.png").attr("x",o).attr("height",function(){return n.height}),p=n.chart.selectAll(".circleGroup").data(f).enter().append("g").attr("class","circleGroup").attr("transform",function(n){return"translate("+y(n.key)+",0)"}),g=p.selectAll(".heat").data(function(n){return n.values}).enter().append("circle").attr("r",7).attr("cx",function(n){return o+e[n.direction+n.part+n.side][0]}).attr("cy",function(n){return e[n.direction+n.part+n.side][1]}).style("fill",function(n){return c(n.yValue)})}},n}(),rangeChart=function(){function n(){}return n.prototype.createRange=function(n,t,i,r){var u=new helper,e=n.chart,f=n.y[r],l=n.x,a=n.color,o,s,h,c;e.selectAll(".chartRange").remove(),t[0].rangeBoundary==="top"?(s=t[0],o=t[1]):(s=t[1],o=t[0]),h=i.map(function(n,t){return{x:n,top:s.points[t],bottom:o.points[t]}}).filter(function(n){return l(n.x)!==undefined&&n.bottom!==null&&n.top!==null}),c=d3.svg.area().x(function(t){return n.x(t.x)+n.x.rangeBand()/2}).y0(function(n){return f.y(n.bottom)}).y1(function(n){return f.y(n.top)}),e.append("path").datum(h).attr("fill","#3598DB").attr("class","chartRange").attr("opacity","0.5").attr("d",c),e.selectAll(".points").data(h).enter().append("g").each(function(i){if(i.bottom!==null&&i.top!==null){d3.select(this).append("circle").attr("class","chartRange").attr("style","fill:#fff; stroke-width:3;stroke:#3598DB;cursor:pointer;").style("stroke-dasharray","3, 1").attr("r",3).attr("transform","translate("+(n.x(i.x)+n.x.rangeBand()/2)+","+f.y(i.top)+")").on("mouseenter",function(){var r=(i.top+i.bottom)/2,n="Highest: "+(i.bottom%1==0?i.bottom:i.bottom.toFixed(2)),f;n=n+"<\/br> Avg: "+(r%1==0?r:r.toFixed(2)),n=n+"<\/br> Lowest: "+(i.top%1==0?i.top:i.top.toFixed(2)),f=t[0].label+": "+i.x,u.ShowPopover(this,n,f)}).on("mouseleave",function(){u.hidePopover(this)});d3.select(this).append("circle").attr("class","chartRange").attr("style","fill:#fff; stroke-width:3;stroke:#3598DB;cursor:pointer;").style("stroke-dasharray","3, 1").attr("r",3).attr("transform","translate("+(n.x(i.x)+n.x.rangeBand()/2)+","+f.y(i.bottom)+")").on("mouseenter",function(){var n="Highest: "+(i.bottom%1==0?i.bottom:i.bottom.toFixed(2)),r=(i.top+i.bottom)/2,f;n=n+"<\/br>Avg: "+(r%1==0?r:r.toFixed(2)),n=n+"<\/br> Lowest: "+(i.top%1==0?i.top:i.top.toFixed(2)),f=t[0].label+": "+i.x,u.ShowPopover(this,n,f)}).on("mouseleave",function(){u.hidePopover(this)})}})},n}(),stackedBar=function(){function n(){}return n.prototype.createStackedBar=function(n,t,i,r,u){var h,e,y,l,o,a,f,s,p,w,c,v;if(t.chartdata!==undefined&&(h=new helper,e=h.FormatData(t.chartdata,n.xFormattedSeries,r,n.sortBy),e.length!==0)){y=d3.layout.stack(),y(e.map(function(n){return n.values.map(function(n){return n.y=n.yValue,n})})),l=n.x.rangeBand(),o=l/(n.width*1.2),o=o>.4?o:.15,a=d3.scale.ordinal().domain([1]).rangeBands([0,l],o),f=n.y[i],u===!1&&n.seriesList.push(t),s=d3.max(e[e.length-1].values.map(function(n){return n.y0+n.y})),p=s-f.y.domain()[0],s=s+p*.05,f.y.domain([f.y.domain()[0],s]),w=d3.svg.axis().scale(f.y).orient("left").ticks(4),n.chart.selectAll(".axisLeft").call(w),c=n.chart.selectAll(".barG").data(e).enter().append("g").attr("class","barGroup"),c.attr("transform",function(){return"translate("+a(1)+",0)"}),v=c.selectAll("rect").data(function(n){return n.values}).enter().append("rect").attr("class","stackedRect").attr("fill",function(t){return n.color(t.color)}).attr("height",function(n){return n.yValue!==null?f.y(n.yValue):0}).attr("width",a.rangeBand()).attr("y",function(n){return f.y(n.yValue!==null?n.y+n.y0:0)}).attr("x",function(t){return n.x(t.xValue)===undefined?-2e3:n.x(t.xValue)}),v.attr("height",function(n){return n.yValue==null?0:f.y(n.y0)-f.y(n.y+n.y0)}),f.y.domain()[0]>0&&c.each(function(n,t){t===0&&d3.select(this).selectAll(".stackedRect").attr("height",function(n){return n.yValue==null?0:f.y(f.y.domain()[0])-f.y(n.y+n.y0)})});v.on("mouseenter",function(i){var u="",f=t.label!==i.color?i.color:"";i.yValue!==null&&(u="<strong>"+f+"<\/strong>: "+(r!=="Date"?" <strong> (Avg) <\/strong> "+i.yValue.toFixed(2):i.yValue)+"<br/>"),u=u+"<strong>"+r+" <\/strong>: "+i.xValue+"<br/>",h.ShowPopover(this,u,f),n.xMouseTracker&&n.xMouseTracker({value:new Date(i.xValue)})}).on("mouseleave",function(){h.hidePopover(this)})}},n}(),pieChart=function(){function n(){}return n.prototype.drawPieChart=function(n,t,i){var a,s,h;n.xFormattedSeries=i.series,n.xFormattedSeries.length===0&&(n.xFormattedSeries=["No data"]);var d=this,f=Math.min(n.width,n.height)/2,r=d3.svg.arc().outerRadius(f-10).innerRadius(0),l=d3.layout.pie().sort(null).value(function(n){return n}),p=n.chart.attr("transform","translate("+n.totalWidth/2+","+(n.height/2+(n.margin.bottom+n.margin.top/2))+")"),w=p.append("g").attr("class","pie"),u=n.runtimeRedrawing===!0?t[0].points[0]:t[0].points;u=t[0].points[0],u.length===0&&(u=[1]),u=u.map(function(n){return n===null&&(n=0),n}),a=w.selectAll(".arc").data(l(u)).enter().append("g").attr("class","arc").on("mouseover",function(){}).on("click",function(t,i){n.seriesList[0].setFilter(n.xFormattedSeries[i])?(n.chart.selectAll(".arc").transition(200).style("fill-opacity",.1),d3.select(this).transition(200).style("fill-opacity",1)):n.chart.selectAll(".arc").transition(200).style("fill-opacity",1)}).on("mouseout",function(){}),a.append("path").attr("d",r).attr("stroke","#fff").style("fill",function(t,i){return n.color(n.xFormattedSeries[i])}),s=n.chart.selectAll(".labels").data(l(u)).enter().append("g"),h=s.append("line").style("stroke","#b3b3b3"),h.attr("x1",function(n){return r.centroid(n)[0]}).attr("y1",function(n){return r.centroid(n)[1]}).attr("x2",function(n){var i=r.centroid(n),u=Math.atan2(i[1],i[0]);return Math.cos(u)*f}).attr("y2",function(n){var i=r.centroid(n),u=Math.atan2(i[1],i[0]);return Math.sin(u)*f});var c=s.append("text").attr("x",function(n){var i=r.centroid(n),e=Math.atan2(i[1],i[0]),u=Math.cos(e)*f,o=u>0?1:-1;return u+5*o}).attr("y",function(n){var i=r.centroid(n),u=Math.atan2(i[1],i[0]);return Math.sin(u)*f}).attr("text-anchor",function(n){var i=r.centroid(n),u=Math.atan2(i[1],i[0]),e=Math.cos(u)*f;return e>0?"start":"end"}).attr("class","label-text").text(function(t,i){var r=(t.data/d3.sum(u)*100).toFixed(2);return n.xFormattedSeries[i]+" ("+t.data+") ("+r+"%) "}),b=.5,k=12,g,e,o,v,y=function(){var n=!1,t;c.each(function(){var u=this,r;e=d3.select(u),r=e.attr("y"),c.each(function(){var c=this,f,s,l,h;u!=c&&(o=d3.select(c),e.attr("text-anchor")==o.attr("text-anchor"))&&((f=o.attr("y"),s=r-f,Math.abs(s)>k)||(n=!0,l=s>0?1:-1,h=l*b,e.attr("y",+r+h),o.attr("y",+f-h)))})}),n&&(t=c[0],h.attr("y2",function(n,i){return v=d3.select(t[i]),v.attr("y")}),setTimeout(y,20))};y()},n}(),radarChart=function(){function n(){}return n.prototype.drawRadar=function(n,t,i){var v=1,c,o,e,g,s,w,a,h;t[0].ytype==="Distance (mm)"?v=1e3:t[0].ytype==="Distance (cm)"&&(v=100),t=JSON.parse(JSON.stringify(t)),_.each(t,function(n){n.points=_.map(n.points[0],function(n){return n*v})});var u=n,y=new helper,r={radius:1.5,w:n.width,h:n.height,factor:1,factorLegend:.85,levels:3,maxValue:parseInt(i.maxYValue),minValue:parseInt(i.minYValue),radians:2*Math.PI,opacityArea:.5,ToRight:5,color:d3.scale.category10()};if("undefined"!=typeof i)for(c in i)"undefined"!=typeof i[c]&&(r[c]=i[c]);r.maxValue=Math.max(r.maxValue,d3.max(t,function(n){return d3.max(n.points)})),r.minValue=Math.min(r.minValue,d3.min(t,function(n){return d3.min(n.points)})),r.minValue==r.maxValue&&(r.maxValue+=.1);var l=n.xFormattedSeries,f=l.length,p=r.factor*Math.min(r.w/2,r.h/2),b=d3.format("0.2f"),k,d="translate("+(n.width/2-120)+","+(n.margin.bottom+18)+")";for(u.chart.attr("transform",d),o=0;o<r.levels;o++)e=r.factor*p*((o+1)/r.levels),u.chart.selectAll(".levels").data(l).enter().append("svg:line").attr("x1",function(n,t){return e*(1-r.factor*Math.sin(t*r.radians/f))}).attr("y1",function(n,t){return e*(1-r.factor*Math.cos(t*r.radians/f))}).attr("x2",function(n,t){return e*(1-r.factor*Math.sin((t+1)*r.radians/f))}).attr("y2",function(n,t){return e*(1-r.factor*Math.cos((t+1)*r.radians/f))}).attr("class","line").style("stroke","grey").style("stroke-opacity","0.75").style("stroke-width","0.3px").attr("transform","translate("+(r.w/2-e+n.margin.left)+", "+(r.h/2-e)+")");for(o=0;o<r.levels;o++)e=r.factor*p*((o+1)/r.levels),u.chart.selectAll(".levels").data([1]).enter().append("svg:text").attr("x",function(){return e*(1-r.factor*Math.sin(0))}).attr("y",function(){return e*(1-r.factor*Math.cos(0))}).attr("class","radarAxisLabel").attr("transform","translate("+(r.w/2-e+r.ToRight+n.margin.left)+", "+(r.h/2-e)+")").attr("fill","#737373").text(b((o+1)*(r.maxValue-r.minValue)/r.levels+r.minValue));g=r.factor*p*(0/r.levels),u.chart.selectAll(".middleLevel").data([1]).enter().append("svg:text").attr("x",function(){return 0}).attr("y",function(){return 0}).attr("class","radarAxisLabel").attr("transform","translate("+(r.w/2+r.ToRight+n.margin.left)+", "+r.h/2+")").attr("fill","#737373").text(b(r.minValue)),s=0,w=u.chart.selectAll(".axis").data(l).enter().append("g").attr("class","axis"),w.append("line").attr("x1",r.w/2+n.margin.left).attr("y1",r.h/2).attr("x2",function(t,i){return r.w/2*(1-r.factor*Math.sin(i*r.radians/f))+n.margin.left}).attr("y2",function(n,t){return r.h/2*(1-r.factor*Math.cos(t*r.radians/f))}).attr("class","radarXAxisLine"),w.append("text").attr("class","radarXAxisValueText").text(function(t){return n.isSerialDate()?y.formatDate(n,t):t}).attr("text-anchor","middle").attr("dy","1.5em").attr("transform",function(){return"translate(0, -10)"}).attr("x",function(t,i){return r.w/2*(1-r.factorLegend*Math.sin(i*r.radians/f))-60*Math.sin(i*r.radians/f)+n.margin.left}).attr("y",function(n,t){return r.h/2*(1-Math.cos(t*r.radians/f))-20*Math.cos(t*r.radians/f)}),a=n.margin.left,t.forEach(function(n){if(n.cleanedPoints=[],!_.every(n.points,function(n){return n===null})){n.cleanedPoints=[];for(var i=0;i<n.points.length;i++)n.points[i]!==null&&n.cleanedPoints.push([i,n.points[i]])}}),t.forEach(function(n){if(n.cleanedPoints.length!==0){u.seriesList.push(n),h=[],u.chart.selectAll(".nodes").data(n.cleanedPoints,function(n){h.push([r.w/2*(1-(n[1]-r.minValue)/(r.maxValue-r.minValue)*r.factor*Math.sin(n[0]*r.radians/f))+a,r.h/2*(1-(n[1]-r.minValue)/(r.maxValue-r.minValue)*r.factor*Math.cos(n[0]*r.radians/f))])}),h.push(h[0]);u.chart.selectAll(".area").data([h]).enter().append("polygon").attr("class","radar-chart-serie"+s).style("stroke",u.color(n.label)).attr("points",function(n){for(var i="",t=0;t<n.length;t++)i=i+n[t][0]+","+n[t][1]+" ";return i}).style("fill",function(){return u.color(n.label)}).style("fill-opacity",r.opacityArea).on("mouseover",function(){u.chart.selectAll("polygon").transition(200).style("fill-opacity",.1),d3.select(this).transition(200).style("fill-opacity",.7)}).on("mouseout",function(){u.chart.selectAll("polygon").transition(200).style("fill-opacity",r.opacityArea)});s++}}),s=0,t.forEach(function(n){if(n.cleanedPoints.length!==0){u.chart.selectAll(".nodes").data(n.cleanedPoints).enter().append("svg:circle").attr("class","radar-chart-serie"+s).attr("r",r.radius).attr("alt",function(n){return Math.max(n[1],0)}).attr("cx",function(n){return h.push([r.w/2*(1-(n[1]-r.minValue)/(r.maxValue-r.minValue)*r.factor*Math.sin(n[0]*r.radians/f))+a,r.h/2*(1-(n[1]-r.minValue)/(r.maxValue-r.minValue)*r.factor*Math.cos(n[0]*r.radians/f))]),r.w/2*(1-(n[1]-r.minValue)/(r.maxValue-r.minValue)*r.factor*Math.sin(n[0]*r.radians/f))+a}).attr("cy",function(n){return r.h/2*(1-(n[1]-r.minValue)/(r.maxValue-r.minValue)*r.factor*Math.cos(n[0]*r.radians/f))}).attr("data-id",function(n){return n[0]}).style("fill","#fff").attr("stroke",u.color(n.label)).style("fill-opacity",.9).attr("stroke-width",2).on("mouseover",function(n){var r=n[0],f=n[1],e=l[r],o="polygon."+d3.select(this).attr("class"),t,i;u.chart.selectAll("polygon").transition(200).style("fill-opacity",.1),u.chart.selectAll(o).transition(200).style("fill-opacity",.7),t="",t=t+"<strong>"+e+"<\/strong>: "+f,i="",y.ShowPopover(this,t,i)}).on("mouseout",function(){k.transition(200).style("opacity",0),u.chart.selectAll("polygon").transition(200).style("fill-opacity",r.opacityArea),y.hidePopover(this)});s++}}),k=u.chart.append("text").style("opacity",0).attr("class","radarTooltip")},n}(),helper=function(){function n(){this.drawMean=function(n,t,i){var r,h,o,u,f,e,c,l,a,s;(n.statistics==="Mean"||n.statistics==="SD")&&(r=n.y[0],h=[],n.axisType==="Group"?(t[0].points.length>1&&t[0].chartdata.isFitnessChart?(a=t.filter(function(n){return n.isSelectedMeasure===!0}),o=a.length>0?a:t):o=t[0].points.length>1?t.filter(function(n){return n.isSelectedMeasure===!0}):t,e=[],o.map(function(n){n.chartdata.YAxis.map(function(n){return n.map(function(n){e.push(n)})})}),u=d3.mean(e),f=d3.deviation(e),c=r.y(u-f)<r.y.range()[1]?r.y.range()[1]:r.y(u-f),l=r.y(u+f)>r.y.range()[0]?r.y.range()[0]:r.y(u+f),u!==undefined&&h.push({val:r.y(u),label:"Mean : "+u.toFixed(2),color:"#b3b3b3",upper:c,lower:l,sd:f,mean:u})):(o=t[0].points.length>1&&i===!0?t.filter(function(n){return n.isSelectedMeasure===!0}):t,o.map(function(t){r=n.y[t.yScaleIndex],e=[],_.each(t.chartdata.YAxis,function(n){e=e.concat(n)}),u=d3.mean(e),f=d3.deviation(e),c=r.y(u-f)<r.y.range()[1]?r.y.range()[1]:r.y(u-f),l=r.y(u+f)>r.y.range()[0]?r.y.range()[0]:r.y(u+f),u!==undefined&&(t.YAxisScaleIndex!==undefined&&(r=n.y[t.YAxisScaleIndex]),h.push({val:r.y(u),label:t.label+" Mean: "+u.toFixed(2),color:n.color(t.label),upper:c,lower:l,sd:f,mean:u}))})),s=n.chart.selectAll(".mean").data(h).enter().append("g").attr("class","meanGroup").attr("transform",function(n){return"translate(0,"+n.val+")"}),(n.statistics==="Mean"||n.statistics==="SD")&&(s.append("line").attr("x1",0).attr("y1",0).attr("x2",n.width).attr("y2",0).attr("stroke","#000000").attr("stroke-width",2).attr("stroke-dasharray",6).style("shape-rendering","crispEdges"),s.append("text").attr("x",n.width-10).attr("y",-3).attr("text-anchor","end").text(function(n){return n.label})),n.statistics==="SD"&&(s.append("rect").attr("fill",function(n){return n.color}).attr("style","stroke: #b3b3b3; stroke-width: .5;fill-opacity:.2").attr("width",n.width).attr("y",function(n){return n.lower-n.val}).attr("height",function(n){return n.upper-n.lower}),s.append("text").attr("x",10).attr("y",function(n){return n.lower-n.val}).attr("dy",13).attr("text-anchor","start").text(function(n){return"Mean + SD: "+(n.mean+n.sd).toFixed(2)}),s.append("text").attr("x",10).attr("y",function(n){return n.upper-n.val}).attr("dy",-1).attr("text-anchor","start").text(function(n){return"Mean - SD: "+(n.mean-n.sd).toFixed(2)})))},this.setupRunTimeContainer=function(n,t,i){d3.select(t).select(".runtimeOptionsContainer").remove();d3.select(t).append("div").attr("class","no-print").attr("style","position: absolute;right: 4px;top:-31px;").append("i").attr("style","padding:5px; border:1px solid #f3f3f3;cursor:pointer;").attr("class","fa fa-bars").style("color",n.showRuntimeOptions?"#fff":"#000").style("background",n.showRuntimeOptions?"#b3b3b3":"#fff").on("click",function(){n.showRuntimeOptions=!n.showRuntimeOptions;var i=d3.select(this);n.showRuntimeOptions?(n.runtimeOptionsContainer.style("display","block"),i.style("color","#fff").style("background","#b3b3b3")):(n.runtimeOptionsContainer.style("display","none"),i.style("color","#000").style("background","#fff"))});n.runtimeOptionsContainer=d3.select(t).append("div").attr("class","runtimeOptionsContainer"),i>550?n.runtimeOptionsContainer.attr("style","position: absolute;right: 30px;top:-32px;z-index: 9;"):n.runtimeOptionsContainer.attr("style"," position: absolute; right: 4px; top: -2px;  display: block; width: 110px;border: 1px solid #f3f3f3;  background: #fff; text-align: right; z-index: 9; padding: 2px;"),n.runtimeOptionsContainer.style("display",n.showRuntimeOptions?"block":"none")},this.getTableData=function(n){var i=[],t,f;if(n!==undefined){t=[],t.push(n.xAxis.label),n.yAxisLeft&&n.yAxisLeft.series.forEach(function(i){i.barIndex!==undefined?i.chartdata.Legend.map(function(r){i.points.length>1&&n.yAxisLeft.series.length>1?t.push(r+" ("+i.label+") "):t.push(r)}):i.type==="line"&&n.showRange()?t.push(i.label):i.type==="line"&&n.showRange()&&t.push(i.label)}),n.yAxisRight&&n.yAxisRight.series.forEach(function(i){i.barIndex!==undefined?i.chartdata.Legend.map(function(r){i.points.length>1&&n.yAxisLeft.series.length>1?t.push(r+" ("+i.label+") "):t.push(r)}):i.type==="line"&&n.showRange()?t.push(i.label):i.type==="line"&&n.showRange()&&t.push(i.label)}),i.push(t);var e=d3.time.format(this.getDateFormat(main.dateFormat)),r=d3.time.format("%Y-%m-%d").parse,o=n.xAxis.axisType==="date"?function(n){return r(n)!==null?e(r(n)):n}:function(n){return n},u=function(n,t){var f,r,u,i;return n===null?"":_.isNumber(n)?t.type==="Time (hours)"?(n=n/60,f=Math.floor(n/60).toString(10),r=(Math.floor(n)%60).toString(10),f+":"+(r.length===1?"0":"")+r):t.type==="Time (seconds)"?(u=Math.floor(n).toString(10),i=(n-Math.floor(n)).toFixed(3).substr(1),u+(i!==".000"?i:"")):t.type==="Time (minutes)"?(r=Math.floor(n/60).toString(10),u=(Math.floor(n)%60).toString(10),i=(n-Math.floor(n)).toFixed(3).substr(1),r+":"+(u.length===1?"0":"")+u+(i!==".000"?i:"")):n.toFixed(2):n};n.xAxis.series.forEach(function(t,r){var f=[];f.push(o(t)),n.yAxisLeft&&n.yAxisLeft.series.forEach(function(t){t.barIndex!==undefined?t.points.forEach(function(n){return f.push(u(n[r],t))}):t.type==="line"&&n.showRange()&&f.push(t.points[r])}),n.yAxisRight&&n.yAxisRight.series.forEach(function(t){t.barIndex!==undefined?t.points.forEach(function(n){return f.push(u(n[r],t))}):t.type==="line"&&n.showRange()&&f.push(t.points[r])}),i.push(f)})}return f=i[0].map(function(n,t){return i.map(function(n){return n[t]})})},this.checkIfTime=function(n,t){return n.ytype&&(n.ytype.toLowerCase().indexOf("time")===0||n.ytype.toLowerCase().indexOf("duration")===0||n.ytype.indexOf("Time")===0)?!0:t.ytype&&(t.ytype.toLowerCase().indexOf("time")===0||t.ytype.toLowerCase().indexOf("duration")===0||t.ytype.indexOf("Time")===0)?!0:!1},this.timeFormattedValue=function(n,t){var f,r,u,i;return n==="Time (hours)"?(t=t/60,f=Math.floor(t/60).toString(10),r=(Math.floor(t)%60).toString(10),f+":"+(r.length===1?"0":"")+r):n==="Time (seconds)"?(u=Math.floor(t).toString(10),i=(t-Math.floor(t)).toFixed(3).substr(1),u+(i!==".000"?i:"")):(r=Math.floor(t/60).toString(10),u=(Math.floor(t)%60).toString(10),i=(t-Math.floor(t)).toFixed(3).substr(1),r+":"+(u.length===1?"0":"")+u+(i!==".000"?i:""))},this.drawMultiMeasureBars=function(n,t,i,r){var u=n[0],f=0;u.isSelectedMeasure=!0,t.isMultiMeasure=!0,t.multiMeasureIndex=0,n[t.multiMeasureIndex].YAxisScaleIndex!==undefined&&(f=n[t.multiMeasureIndex].YAxisScaleIndex),n[t.multiMeasureIndex].isSelectedMeasure=!0,i.createBarChart(t,u,t.multiMeasureIndex,t.axisType,r),u=n[1],u.isSelectedMeasure=!0,t.isMultiMeasure=!0,t.multiMeasureIndex=1,n[t.multiMeasureIndex].YAxisScaleIndex!==undefined&&(f=n[t.multiMeasureIndex].YAxisScaleIndex),n[t.multiMeasureIndex].isSelectedMeasure=!0,i.createBarChart(t,u,f,t.axisType,r),t.multiMeasureLegend=[n[0].label,n[1].label]};var n=d3.time.format("%Y-%m-%d");this.getDates=function(t,i){for(var u=[],r=t,f=function(n){var t=new Date(this.valueOf());return t.setDate(t.getDate()+n),t};r<=i;)u.push(r),r=f.call(r,1);return u.map(function(t){return n(t)})}}return n.prototype.ShowBigPopOver=function(n,t,i,r){$(n).popover({title:"",placement:r,container:"body",trigger:"manual",html:!0,content:t}),$(n).popover("show")},n.prototype.ShowPopover=function(n,t,i){$(n).popover({title:i,placement:"top",container:"body",trigger:"manual",html:!0,content:t}),$(n).popover("show")},n.prototype.hidePopover=function(n){$(n).popover("hide"),$(n).popover("destroy"),$("body").popover("hide"),$("body").popover("destroy"),$(".popover").popover("hide"),$(".popover").popover("destroy")},n.prototype.getChartDimensions=function(n,t,i,r){var f=$(n).css("width")?parseInt($(n).css("width")):960,e=300,o=t.marginTop?t.marginTop:40,s=t.marginRight?t.marginRight:60,h=t.marginBottom?t.marginBottom:25,c=t.marginLeft?t.marginLeft:50,u={top:o+15,right:s+15,bottom:h+i+r,left:c+15},l=f-u.left-u.right,a=e-u.top-u.bottom;return{width:l,height:a,margins:u}},n.prototype.formatDate=function(n,t){if(!t)return"";var i=t.getFullYear(),r=t.getMonth(),u=n.months[r],f=t.getDate();return f+" "+u+" "+i},n.prototype.FormatData=function(n,t,i){var u,f;return n===undefined?[]:(i==="Group"?(f=_.uniq(n.GroupLegend),u=n.isFitnessChart===!0&&n.filterIsClientList===!0?n.XAxis.map(function(t,i){return{key:t,values:n.GroupLegend.map(function(t,r){return{xValue:t,yValue:n.YAxis[r][i],color:t,date:n.XAxis[i],YAxisScaleIndex:n.YAxisScaleIndex===undefined?undefined:n.YAxisScaleIndex[i]}})}}):[{key:n.GroupName,values:f.map(function(t){var i=[];return n.GroupLegend.forEach(function(r,u){r===t&&i.push(d3.mean(_.filter(n.YAxis[u],function(n){return n!==null})))}),{xValue:t,yValue:d3.mean(i)!==undefined?d3.mean(i):null,color:t}})}]):(u=[],n.XAxis&&(u=n.YAxis.map(function(i,r){return{key:n.Legend[r],values:i.map(function(i,u){return{xValue:t[u],yValue:i,color:n.Legend[r],YAxisScaleIndex:n.YAxisScaleIndex===undefined?undefined:n.YAxisScaleIndex[r],ytype:n.ytypes?n.ytypes[r]:null}})}}))),u)},n.prototype.setupXAxisRadar=function(n,t){var f,r,u,e;n.xAxisType=t.axisType?t.axisType.toLowerCase():"serial",n.isOrdinal()?(n.xFormattedSeries=t.series,r=d3.min(n.xFormattedSeries),u=d3.max(n.xFormattedSeries),n.x=d3.scale.ordinal().rangeRoundBands([0,n.width+15],.2).domain(n.xFormattedSeries),n.xAxisNumberValues=n.xFormattedSeries.length):n.isSerialDate()?(f=d3.time.format("%Y-%m-%d").parse,n.xFormattedSeries=_.map(t.series,f),r=d3.min(n.xFormattedSeries),u=d3.max(n.xFormattedSeries),n.x=d3.scale.ordinal().rangeRoundBands([0,n.width+15],.2).domain(n.xFormattedSeries),n.xAxisNumberValues=n.xFormattedSeries.length):(n.xFormattedSeries=t.series,r=d3.min(n.xFormattedSeries)+-1,u=d3.max(n.xFormattedSeries)+1,n.x=d3.scale.linear().range([0,n.width+15]).domain([r,u]),n.xAxisNumberValues=u-r),e=d3.svg.axis().scale(n.x).orient("bottom")},n.prototype.setupXAxis=function(n,t,i,r,u,f,e){var p=r!=="ordinal"?r:"",nt=t.xAxis.axisType?t.xAxis.axisType.toLowerCase():"serial",ut=t.xAxis,tt=t.xAxis.filterIsClientList,h=n.dateRange,it=d3.time.format(i),v=d3.time.format("%Y-%m-%d").parse,w,y,l,s,a,b,k,o,d,g;if(n.xFormattedSeries=t.xAxis.series,n.x=d3.scale.ordinal().rangeBands([0,n.width],.05),f.length>0)n.x.domain(f);else if(r==="Group")if(w=_.filter(t.yAxisLeft.series,function(n){return n.barIndex!==undefined}),y=[],t.yAxisRight&&(y=_.filter(t.yAxisRight.series,function(n){return n.barIndex!==undefined})),l=w.concat(y),s=l[0].chartdata,l[0].isSelectedMeasure!==undefined&&(s=l.filter(function(n){return n.isSelectedMeasure===!0})[0].chartdata),a=[],s!==undefined){if(e!=="Default"){var t=s,rt=_.uniq(t.GroupLegend),c=rt.map(function(n){var i=[];return t.GroupLegend.forEach(function(r,u){r===n&&i.push(d3.mean(_.filter(t.YAxis[u],function(n){return n!==null})))}),{xValue:n,value:d3.mean(i)===undefined?0:d3.mean(i)}});e==="Ascending"?c=c.sort(function(n,t){return n.value-t.value}):e==="Descending"&&(c=c.sort(function(n,t){return t.value-n.value})),a=c.map(function(n){return n.xValue})}else a=s.GroupLegend.sort(function(n,t){return n<t?-1:1});n.x.domain(a),p=s.GroupName}else n.x.domain([""]);else h.groupBy==="Day"&&h.start!==null&&h.end!==null?(b=this.getDates(v(h.start),v(h.end)),n.x.domain(b)):n.x.domain(n.xFormattedSeries);k=d3.svg.axis().scale(n.x).orient("bottom"),o=n.chart.append("g").attr("class","xaxis").attr("transform","translate(0,"+n.height+")").call(k),o.selectAll("line").style("stroke","#b3b3b3"),r==="Date"&&(n.xFormattedSeries.length>0||n.x.domain().length>0)&&nt==="date"&&o.selectAll("text").text(function(n){var i=v(n);return it(i)}),r==="Group"&&(n.xFormattedSeries.length>0||n.x.domain().length>0)&&tt!==!1&&o.selectAll("text").text(function(n){var i=(n+"").split(" ");return i.length>1?i[1]+", "+i[0][0]:n}),d=n.width/n.x.domain().length,g=Math.round(n.x.domain().length/n.width*40),o.selectAll("text").each(function(n,t){d<20&&t%g!=0&&d3.select(this).text("")}),u===!0&&o.selectAll("text").style("text-anchor","end").attr("dx","-.8em").attr("dy",".15em").attr("transform",function(){return"rotate(-60)"}),o.append("text").attr("class","chart-label").attr("x",n.width/2).attr("y",n.margin.bottom+18).style("text-anchor","middle").style("text-transform","capitalize").text(p)},n.prototype.setupChartArea=function(n,t,i,r,u){n.totalWidth=i+u.left+u.right,n.width=i,n.height=r,n.margin=u,n.chartWidth=n.width-40,n.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d3.select(t).selectAll("svg").remove(),n.svg=d3.select(t).append("svg").attr("width",n.totalWidth).attr("height",n.height+u.top+u.bottom+20).append("g").attr("class","maing").attr("width",n.totalWidth).attr("height",n.height+u.top+u.bottom),n.chart=n.svg.append("g").attr("class","chart").attr("width",n.width).attr("height",n.height+u.top+u.bottom).attr("transform","translate("+u.left+","+u.top+")").attr("x",0).attr("y",0).on("mouseleave",function(){$(".popover").remove(),$(".popover").popover("destroy")}),n.overlayG=n.chart.append("g");var e=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf","#37bd9d","#ffbb23","#FB8383","#3598DB","#BE90D4","#9CDAEE","#F64747","#6C7A89","#ACD15F","#D2527F","#36D7B7","#F39C12","#5C97BF","#FDE3A7","#1B9E77","#E08283","#BDC3C7","#CE0073","#86E2D5","#EF92D2","#66A3D2","#FF7300","#00AF64","#DBA13A","#FF2100","#9CDAEE","#34AF8C","#CB5073","#B3F581","#9685E3","#FFE576","#FF8876","#00B83B","#E97BC8","#69A8D4","#80105B","#7FEFA4","#DF004A","#65B8D2","#DDB0EF","#BCDF62","#DFBC62","#6590A2","#E8762C","#4D6F9F","#D53448","#684B98","#DF7E62","#DFD162","#459E6E","#D45D6E","#5B4F9A","#DFC662","#6DBD53","#FFCB87","#E788E7","#8EC0E7","#BAD052","#9884E3","#FD868C","#89EF7E","#FFFB87","#FFB787","#75DECC","#B67EE1","#FFD787","#ED7DBC","#D2F983","#829FE1"];n.color=d3.scale.ordinal().range(e),n.y=[],n.isPieChart=!1},n.prototype.brushFilter=function(t,i,r,u,f,e,o,s){var v=t.x,h=t.x.copy(),y=t.svg,l=t.chart,p=t.svg.append("g").attr("transform","translate(65,"+(t.height+t.margin.top+t.margin.bottom-10)+")"),w=function(n){var r=+(n=="e"),i=r?1:-1,t=24;return"M"+.5*i+","+t+"A6,6 0 0 "+r+" "+6.5*i+","+(t+6)+"V"+(2*t-6)+"A6,6 0 0 "+r+" "+.5*i+","+2*t+"ZM"+2.5*i+","+(t+8)+"V"+(2*t-8)+"M"+4.5*i+","+(t+8)+"V"+(2*t-8)},a=d3.svg.brush().x(h).on("brush",function(){var c=a.extent(),u=h.domain().filter(function(n){return c[0]<=h(n)&&h(n)<=c[1]});u.length===0&&(u=v.domain()),y.select(".xaxis").remove();var p=u.length>8,w=new n,b=new legend;w.setupXAxis(t,f,e,r,p,u,s),l.selectAll(".barGroup").remove(),l.selectAll(".lineG").remove(),i.Area(!0),i.Range(!0,!0),i.Bar(!0),i.StackedBar(!0),i.Line(!0),i.Mean(!0),i.AvgLine(!0),i.Dot(!0),i.Heat(!0),i.BarPie(!0),i.GroupedBar(!0),(f.showLegend===undefined||f.showLegend==!0)&&b.setupLegend(t,o)}),c=p.call(a);c.selectAll("rect.background").style("visibility","visible").style("fill","#ecebeb"),c.selectAll("rect.extent").style("visibility","visible").style("fill","#b3b3b3"),c.selectAll("rect").attr("y",-4).attr("height",20),c.selectAll(".resize").append("path").attr("transform","translate( 0,-30)").attr("style","fill:none;stroke:#4e4a4a;shape-rendering: crispedges").attr("d",w)},n.prototype.runTimeChartValue=function(n,t){var i="Bar",r=_.filter(n.yAxisLeft.series,function(n){return n.barIndex!==undefined});if(r.length>0)switch(r[0].type){case"area":i="Area";break;case"line":i="Line";break;case"grouped bar":case"bar":i="Bar";break;case"stacked bar":i="Stack";break;case"radar":case"grouped radar":i="Radar";break;case"pie":i="Pie"}return t!=="default"&&(i=t),i},n.prototype.findMean=function(n){var r,i,u,t,f,e;if(n.axisType==="Group"){if(r=n[0].points.length>1&&n[0].chartdata.isFitnessChart?n:n[0].points.length>1?n.filter(function(n){return n.isSelectedMeasure===!0}):n,t=[],r.map(function(n){n.chartdata.YAxis.map(function(n){return n.map(function(n){t.push(n)})})}),i=d3.mean(t),u=d3.deviation(t),i!==undefined)return{sd:u,mean:i}}else n.map(function(n){return t=[],_.each(n.chartdata.YAxis,function(n){t=t.concat(n)}),i=d3.mean(t),u=d3.deviation(t),i!==undefined?{sd:u,mean:i}:void 0})},n.prototype.getDateFormat=function(n){var t="%y-%m-%d";switch(n){case"yyyy-mm-dd":t="%y.%m.%d";break;case"d/mm/yyyy":t="%d.%m.%y";break;case"mm/d/yyyy":t="%m.%d.%y"}return t},n}(),dataHelper=function(){function n(){}return n.prototype.setupYAxisLeft=function(n){_.each(n.yAxisLeft.series,function(t){t.pointsMin&&(n.yAxisLeft.series.push({type:"range",rangeBoundary:"top",points:t.pointsMin,label:t.label,hideLabel:!0}),n.yAxisLeft.series.push({type:"range",rangeBoundary:"bottom",points:t.pointsMax,label:t.label,hideLabel:!0})),t.pointsAvg&&n.yAxisLeft.series.splice(0,0,{type:"line",points:t.pointsAvg,label:t.label+" Avg",hideDots:!0}),t.pointsMin=null,t.pointsAvg=null}),_.each(n.yAxisLeft.series,function(t){t.ytype=n.yAxisLeft.type})},n.prototype.setupYAxisRight=function(n){n.yAxisRight&&_.each(n.yAxisRight.series,function(t){t.pointsMin&&(n.yAxisRight.series.push({type:"range",rangeBoundary:"top",points:t.pointsMin,label:t.label,hideLabel:!0}),n.yAxisRight.series.push({type:"range",rangeBoundary:"bottom",points:t.pointsMax,label:t.label,hideLabel:!0})),t.pointsAvg&&n.yAxisRight.series.splice(0,0,{type:"line",points:t.pointsAvg,label:t.label+" Avg",hideDots:!0}),t.pointsMin=null,t.pointsAvg=null}),n.yAxisRight&&_.each(n.yAxisRight.series,function(t){t.ytype=n.yAxisRight.type})},n}(),legend=function(){function n(){}return n.prototype.setupLegend=function(n,t,i){i===void 0&&(i=!1),d3.select(t).selectAll(".legendDiv").remove();var r=n.totalWidth,u=30,f=5;n.legendDiv=d3.select(t).append("div").attr("style","position: absolute; top: 5px; overflow-y: auto; overflow-x:hidden;").style("width",r+"px").style("height",u+"px").attr("class","legendDiv scroll"),n.legend=n.legendDiv.append("svg").attr("width",r).attr("height",30).attr("class","legend").style("position","absolute").attr("pointer-events","none"),this.displayLegend(n,null,"",i)},n.prototype.setupLegendRadar=function(n){var u=n.totalWidth,f=20,i=5;n.legend=n.svg.append("g").attr("class","legend").attr("width",u).attr("height",f).attr("pointer-events","none");var t=n.totalWidth/n.seriesList.length,i=15,r=n.legend.selectAll("g").data(n.seriesList).enter().append("g");r.append("circle").classed("node",!0).attr("r",5).attr("fill",function(t){return n.color(t.label)}).attr("cx",function(n,i){return 20+i*t}).attr("cy",function(){return i}),r.append("text").attr("fill",function(t){return n.color(t.label)}).attr("x",function(n,i){return 30+i*t}).attr("y",function(){return i+5}).text(function(n){return n.label})},n.prototype.displayLegend=function(n,t,i,r){var c,s,l,u,h,o,f,e,a;n.legend&&(n.isPieChart||(u=[],h=_.filter(n.seriesList,function(n){return n.barIndex!==undefined}),_.each(h,function(t){u=t.points.length>1?t.IsGroupedBar!==undefined?u.concat(t.legend.map(function(n){return{label:n}})):u.concat(t.legend.map(function(n){var t=n.label.split(" "),i=n.GroupName=="Name"?t.length>1?t[1]+", "+t[0][0]:n.label:n.label;return{label:i,labelColor:n.label}})):u.concat(n.seriesList.filter(function(n){return n.label!==undefined}))}),u=r?[]:_.unique(u,function(n){return n.label}),n.isMultiMeasure&&n.runTimeOptions!==undefined&&n.runTimeOptions.chart==="Bar"&&(u=[{label:n.multiMeasureLegend[0]},{label:n.multiMeasureLegend[1]}]),n.avgLineData.length>0&&(o=n.avgLineData[0].points.filter(function(n){return n!==null}),o.length>0&&u.push({label:n.avgLineData[0].label})),n.avgLineDataRight.length>0&&(o=n.avgLineDataRight[0].points.filter(function(n){return n!==null}),o.length>0&&u.push({label:n.avgLineDataRight[0].label})),n.yAxisLeft&&n.yAxisLeft.shadingRanges&&ko.unwrap(n.yAxisLeft.shadingRanges)&&_.map(ko.unwrap(n.yAxisLeft.shadingRanges),function(n){u.push({label:n.label,rangeColor:n.color})}),f=20,e=0,u=u.map(function(t){var i=t.label.length<5?t.label.length*15:t.label.length*8,r={label:t.label,width:i,x:f,y:e,color:t.rangeColor?t.rangeColor:n.color(t.labelColor===undefined?t.label:t.labelColor)};return f=f+15+i,f+15+i>n.totalWidth&&(f=20,e=e+15),r}),l=n.totalWidth/u.length,n.legend.attr("width",n.totalWidth).attr("height",e<30?30:e+15),c=15,a=24,n.legend.selectAll("g").remove(),s=n.legend.selectAll(".g").data(u).enter().append("g").attr("transform",function(n){return"translate("+n.x+","+n.y+")"}).classed("g",!0),s.append("circle").classed("node",!0).attr("r",5).attr("fill",function(n){return n.color}).attr("cy",function(){return 10}),s.append("text").attr("fill",function(n){return n.color}).attr("x",function(){return 15}).attr("y",function(){return 15}).text(function(n){return n.label})))},n}();ko.bindingHandlers.dateControl={init:function(n,t,i){var o=!!i().onlyMonday,r=i().dateFormat,u=i().todayBtn,f;!r&&main&&main.dateFormat&&(r=main.dateFormat),u==undefined&&(u=!1);var s=i().endDate,h=i().startDate,e={format:r,clearBtn:!0,todayBtn:u?"linked":!1,todayHighlight:!0,endDate:s,startDate:h,weekStart:1};o&&(e.daysOfWeekDisabled=[0,2,3,4,5,6]);$(n).datepicker(e).on("changeDate",function(n){var u=t(),f,i,r,e;if(ko.isWriteableObservable(u)){if(n.date=="Invalid Date")return u(undefined),!1;if(n.date==undefined)return u.valueHasMutated(),!1;f=n.date.getFullYear(),i=n.date.getMonth()+1,i<10&&(i="0"+i),r=n.date.getDate(),r<10&&(r="0"+r),e=f+"-"+i+"-"+r,u(e)}});f=ko.unwrap(t()),f==null?n.value="":$(n).datepicker("setDate",datePickerDate(f))},update:function(n,t,i){var f=ko.unwrap(t()),r,u;f==null?n.value="":$(n).datepicker("setDate",datePickerDate(f)),r=i().startDate,u=i().endDate,$(n).datepicker("setStartDate",r!==undefined&&r!==null?datePickerDate(r):null),$(n).datepicker("setEndDate",u!==undefined&&u!==null?datePickerDate(u):null),$(n).datepicker("hide"),$(n).trigger("blur")}},ko.bindingHandlers.colorPicker={init:function(n,t){var r=ko.unwrap(t()),u;if(n.value=r,u=$(n),u.tinycolorpicker(),r&&r[0]=="#")try{u.data("plugin_tinycolorpicker").setColor(r)}catch(f){}u.bind("change",function(n,i){t()(i)})},update:function(n,t){var r=ko.unwrap(t()),u;n.value=r,u=$(n),r&&r[0]=="#"&&u.data("plugin_tinycolorpicker").setColor(r)}},ko.bindingHandlers.colorPalette={init:function(n,t,i){var f="#fff",r=t(),u=$(n),e;u.spectrum({showPaletteOnly:!0,showPalette:!0,hideAfterPaletteSelect:!0,color:"blanchedalmond",palette:[["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"],["#000000","#0066FF","#AF593E","#01A368","#FF861F","#ED0A3F","#8359A3","#FBE870"]],standardColor:[],showSelectionPalette:!1,change:function(n){f=n.toHexString(),r(n.toHexString())},show:function(){u.spectrum("set",r()===""?"#fff":r())}}),u.spectrum("set",r()===""?"#fff":r());$(".no-fill").on("click",function(){f="#fff",u.spectrum("set","#fff"),u.spectrum("hide"),r("")});if(e=i.get("colorElement"),console.log(e),!!e)$("."+e).on("click",function(n){console.log("set value to current color: "+f),r(f),r.valueHasMutated(),n.stopPropagation(),n.preventDefault()})}},ko.bindingHandlers.dateRangeControl={init:function(n,t){var r="";main&&main.dateFormat&&(r=main.dateFormat);$(n).datepicker({format:r,clearBtn:!0,todayBtn:"linked",todayHighlight:!0,weekStart:1}).on("changeDate",function(n){var f=t(),i,e,r,u,o;if(i=$(n.target).hasClass("startDateRange")?f.start:f.end,ko.isWriteableObservable(i)){if(n.date=="Invalid Date"||n.date==undefined)return i(undefined),!1;e=n.date.getFullYear(),r=n.date.getMonth()+1,r<10&&(r="0"+r),u=n.date.getDate(),u<10&&(u="0"+u),o=e+"-"+r+"-"+u,i(o)}})},update:function(n,t){var u=ko.unwrap(t()),f=u.start(),e=u.end(),o=$(n).children("input.startDateRange")[0],s=$(n).children("input.endDateRange")[0],r;f==null?o.value="":(r=new Date(f),$(o).datepicker("setUTCDate",r)),e==null?s.value="":(r=new Date(e),$(s).datepicker("setUTCDate",r))}},Gauge=function(){function n(){}return n.prototype.setupChartArea=function(n,t,i,r,u,f){this.totalWidth=t,this.width=t,this.height=i,this.margin=r,this.chartWidth=this.width-40,this.svg=d3.select(n).append("svg").attr("width",this.totalWidth+r.left+r.right).attr("height",this.height+r.top+r.bottom).append("g").attr("class","maing").attr("width",this.width+r.left+r.right).attr("height",this.height+r.top+r.bottom).attr("transform","translate("+r.left+","+(r.top+25)+")"),this.chart=this.svg.append("g").attr("class","gauge").attr("width",this.width).attr("height",this.height).attr("x",0).attr("y",0).attr("transform","translate("+this.width/2+", "+this.height/2+")"),this.setupColors(u,f),this.y=[],this.arcCount=0},n.prototype.drawArcSection=function(n,t,i,r,u,f){var e=this.percToRad(.75+u/n/2),o=this.percToRad(.75+r/n/2),s=d3.svg.arc().outerRadius(this.radius-t).innerRadius(this.radius-t-i).startAngle(e).endAngle(o);this.chart.append("path").attr("fill",d3.rgb(f)).attr("d",s)},n.prototype.drawGauge=function(n){var l=this,e=n.sections,i=n.totalRange,r=n.showAsDecimal?parseFloat(n.dataValue+"")||0:Math.round(parseFloat(n.dataValue+"")||0),o,h,a,c,u,s;this.dataPercent=r/i/2,this.dataPercentHalf=r/i/2;var f=20,t=10,w=.75;if(this.radius=this.width/2,e)o=0,h=_.filter(e,function(n){return n.max!=null&&n.min!=null}),h.sort(function(n,t){return n.max-t.max}).forEach(function(n){l.drawArcSection(i,t,f,n.max,o,n.color),o=n.max}),a=d3.scale.linear().range([0,1]).domain([0,i]),c=this.radius;else{for(u=1;u<=Math.ceil(r);u++)this.drawArcSection(i,t,f,u,u-1,this.color(u));var b=.5-this.dataPercent,v=this.percToRad(this.dataPercent+.75),y=this.percToRad(1.25),p=d3.svg.arc().outerRadius(this.radius-t).innerRadius(this.radius-t-f).startAngle(v).endAngle(y);this.chart.append("path").attr("fill","#eee").attr("d",p)}n.value!==null?this.chart.append("text").attr("fill","#000").attr("font-size","30px").attr("text-anchor","middle").attr("y","40px").text(n.value):r&&this.chart.append("text").attr("fill","#000").attr("font-size","30px").attr("text-anchor","middle").attr("y","40px").text(n.showAsDecimal?r.toFixed(2):r),n.leftLabel&&this.chart.append("text").attr("font-size","10px").attr("fill","#666").attr("font-weight","bold").attr("text-anchor","middle").attr("dy","4px").attr("transform","translate(-"+(this.radius-t-f/2)+", "+t+")").text(n.leftLabel.toUpperCase()),n.rightLabel&&this.chart.append("text").attr("font-size","10px").attr("fill","#666").attr("font-weight","bold").attr("text-anchor","middle").attr("dy","4px").attr("transform","translate("+(this.radius-t-f/2)+", "+t+")").text(n.rightLabel.toUpperCase()),e&&(s=_.filter(e,function(n){return n.label}),s.length>0&&this.drawSectionLabels(c,t,i,s))},n.prototype.drawSectionLabels=function(n,t,i,r){var o=this,l=d3.svg.arc().outerRadius(n-t+25).innerRadius(n-t+5).startAngle(function(n){return o.percToRad(.75+(n.min-1)/i/2)}).endAngle(function(n){return o.percToRad(.75+n.max/i/2)}),u;for(this.chart.selectAll(".gaugeLabelPath").data(r).enter().append("path").attr("fill","#fff").attr("d",l).attr("id",function(n,t){return"arc"+t}),this.chart.selectAll(".gaugeLabelText").data(r).enter().append("text").attr("x",0).attr("dy",20).attr("text-anchor","middle").attr("class","gaugeLabel").append("textPath").attr("startOffset","21%").attr("xlink:href",function(n,t){return"#arc"+t}).text(function(n){return n.label}),u=0;u<r.length-1;u++){var a=r[u].max/i/2,f=this.percToRad(a),s=0,h=0,e=this.radius-t+2,c=e+15,v=s-e*Math.cos(f),y=h-e*Math.sin(f),p=s-c*Math.cos(f),w=h-c*Math.sin(f);this.chart.append("path").attr("class","gaugeLabelLine").attr("d","M "+v+" "+y+" L "+p+" "+w)}},n.prototype.setupColors=function(n,t){var r=["rgb(16, 163, 31)","rgb(63, 204, 41)","rgb(99, 230, 23)","rgb(147, 230, 23)","rgb(195, 230, 23)","rgb(255, 240, 26)","rgb(255, 186, 26)","rgb(230, 119, 23)","rgb(235, 91, 47)","rgb(235, 47, 47)"],u,f,i;for(n&&(r=r.reverse()),u=[],f=[],i=1;i<t+1;i++)u.push(r[Math.floor(i/t*10)-1]),f.push(i);this.color=d3.scale.ordinal().domain(f).range(u)},n.prototype.percToDeg=function(n){return n*360},n.prototype.percToRad=function(n){return this.degToRad(this.percToDeg(n))},n.prototype.degToRad=function(n){return n*Math.PI/180},n.prototype.drawNeedle=function(n){if(n.dataValue||n.value!==null){var t=7;this.chart.append("circle").attr("class","gaugeNeedleCircle").attr("cx",0).attr("cy",0).attr("r",t),this.chart.append("path").attr("class","gaugeNeedle").attr("d",this.calculateNeedle(t))}},n.prototype.calculateNeedle=function(n){var u=65,f=this.dataPercentHalf,t=this.percToRad(f),i=0,r=0,e=i-u*Math.cos(t),o=r-u*Math.sin(t),s=i-n*Math.cos(t-Math.PI/2),h=r-n*Math.sin(t-Math.PI/2),c=i-n*Math.cos(t+Math.PI/2),l=r-n*Math.sin(t+Math.PI/2);return"M "+s+" "+h+" L "+e+" "+o+" L "+c+" "+l},n.prototype.drawTicks=function(){for(var i,t=0;t<=10;t++)i=7,this.chart.append("path").attr("class","gaugeTicks").attr("d",this.calculateTicks(i,t/20))},n.prototype.calculateTicks=function(n,t){var i=this.percToRad(t),r=0,u=0,f=r-90*Math.cos(i),e=u-90*Math.sin(i),o=r-86*Math.cos(i),s=u-86*Math.sin(i);return"M "+o+" "+s+" L "+f+" "+e},n}(),ko.bindingHandlers.gauge={init:function(){},update:function(n,t,i){var r,o,f;if((n.innerHTML="",r=ko.unwrap(t()),r.totalRange&&r.lowerIsWorse!=undefined)&&!(r.dataValue>r.totalRange)){o=$(n).css("width")?parseInt($(n).css("width")):320,f=$(n).css("height")?parseInt($(n).css("height")):160,f==0&&(f=100);var s=i().marginTop?i().marginTop:25,h=i().marginRight?i().marginRight:25,c=i().marginBottom?i().marginBottom:25,l=i().marginLeft?i().marginLeft:25,u={top:s,right:h,bottom:c,left:l},a=o-u.left-u.right,v=f-u.top-u.bottom,e=new Gauge;e.setupChartArea(n,a,v,u,r.lowerIsWorse,r.totalRange),e.drawGauge(r),e.drawNeedle(r)}}},TestGauge=function(){function n(){}return n.prototype.setupChartArea=function(n,t,i,r,u,f){this.totalWidth=t,this.width=t,this.height=i,this.margin=r,this.chartWidth=this.width-40,this.svg=d3.select(n).append("svg").attr("width",this.totalWidth+r.left+r.right).attr("height",this.height+r.top+r.bottom).append("g").attr("class","maing").attr("width",this.width+r.left+r.right).attr("height",this.height+r.top+r.bottom).attr("transform","translate("+r.left+","+(r.top+25)+")"),this.chart=this.svg.append("g").attr("class","gauge").attr("width",this.width).attr("height",this.height).attr("x",0).attr("y",0).attr("transform","translate("+this.width/2+", "+this.height/2+")"),this.setupColors(u,f),this.y=[],this.arcCount=0},n.prototype.drawArcSection=function(n,t,i,r,u,f){var e=this.percToRad(.75+u/n/2),o=this.percToRad(.75+r/n/2),s=d3.svg.arc().outerRadius(this.radius-t).innerRadius(this.radius-t-i).startAngle(e).endAngle(o);this.chart.append("path").attr("fill",d3.rgb(f)).attr("d",s)},n.prototype.drawGauge=function(n){var l=this,e=n.sections,i=n.totalRange,f=parseInt(n.dataValue+"")||0,r,t,o,h,a,c,u,s;if(this.dataPercent=f/i/2,this.dataPercentHalf=f/i/2,r=20,t=10,this.radius=this.width/2,e)o=0,h=_.filter(e,function(n){return n.max!=null&&n.min!=null}),h.sort(function(n,t){return n.max-t.max}).forEach(function(n){l.drawArcSection(i,t,r,n.max,o,n.color),o=n.max}),a=d3.scale.linear().range([0,1]).domain([0,i]),c=this.radius;else{for(u=1;u<=f;u++)this.drawArcSection(i,t,r,u,u-1,this.color(u));var v=this.percToRad(this.dataPercent+.75),y=this.percToRad(1.25),p=d3.svg.arc().outerRadius(this.radius-t).innerRadius(this.radius-t-r).startAngle(v).endAngle(y);this.chart.append("path").attr("fill","#eee").attr("d",p)}f&&this.chart.append("text").attr("fill","#000").attr("font-size","30px").attr("text-anchor","middle").attr("y","40px").text(f),n.leftLabel&&this.chart.append("text").attr("font-size","10px").attr("fill","#666").attr("font-weight","bold").attr("text-anchor","middle").attr("dy","4px").attr("transform","translate(-"+(this.radius-t-r/2)+", "+t+")").text(n.leftLabel.toUpperCase()),n.rightLabel&&this.chart.append("text").attr("font-size","10px").attr("fill","#666").attr("font-weight","bold").attr("text-anchor","middle").attr("dy","4px").attr("transform","translate("+(this.radius-t-r/2)+", "+t+")").text(n.rightLabel.toUpperCase()),e&&(s=_.filter(e,function(n){return n.label}),s.length>0&&this.drawSectionLabels(c,t,i,s))},n.prototype.drawSectionLabels=function(n,t,i,r){var o=this,l=d3.svg.arc().outerRadius(n-t+25).innerRadius(n-t+5).startAngle(function(n){return o.percToRad(.75+n.min/i/2)}).endAngle(function(n){return o.percToRad(.75+n.max/i/2)}),u;for(this.chart.selectAll(".gaugeLabelPath").data(r).enter().append("path").attr("fill","#fff").attr("d",l).attr("id",function(n,t){return"arc"+t}),this.chart.selectAll(".gaugeLabelText").data(r).enter().append("text").attr("x",0).attr("dy",20).attr("text-anchor","middle").attr("class","gaugeLabel").append("textPath").attr("startOffset","25%").attr("xlink:href",function(n,t){return"#arc"+t}).text(function(n){return n.label}),u=0;u<r.length-1;u++){var a=r[u].max/i/2,f=this.percToRad(a),s=0,h=0,e=this.radius-t+2,c=e+15,v=s-e*Math.cos(f),y=h-e*Math.sin(f),p=s-c*Math.cos(f),w=h-c*Math.sin(f);this.chart.append("path").attr("class","gaugeLabelLine").attr("d","M "+v+" "+y+" L "+p+" "+w)}},n.prototype.setupColors=function(n,t){var r=["rgb(16, 163, 31)","rgb(63, 204, 41)","rgb(99, 230, 23)","rgb(147, 230, 23)","rgb(195, 230, 23)","rgb(255, 240, 26)","rgb(255, 186, 26)","rgb(230, 119, 23)","rgb(235, 91, 47)","rgb(235, 47, 47)"],u,f,i;for(n&&(r=r.reverse()),u=[],f=[],i=1;i<t+1;i++)u.push(r[Math.floor(i/t*10)-1]),f.push(i);this.color=d3.scale.ordinal().domain(f).range(u)},n.prototype.percToDeg=function(n){return n*360},n.prototype.percToRad=function(n){return this.degToRad(this.percToDeg(n))},n.prototype.degToRad=function(n){return n*Math.PI/180},n.prototype.drawNeedle=function(n){if(n.dataValue){var t=7;this.chart.append("circle").attr("class","gaugeNeedleCircle").attr("cx",0).attr("cy",0).attr("r",t),this.chart.append("path").attr("class","gaugeNeedle").attr("d",this.calculateNeedle(t))}},n.prototype.calculateNeedle=function(n){var u=65,f=this.dataPercentHalf,t=this.percToRad(f),i=0,r=0,e=i-u*Math.cos(t),o=r-u*Math.sin(t),s=i-n*Math.cos(t-Math.PI/2),h=r-n*Math.sin(t-Math.PI/2),c=i-n*Math.cos(t+Math.PI/2),l=r-n*Math.sin(t+Math.PI/2);return"M "+s+" "+h+" L "+e+" "+o+" L "+c+" "+l},n.prototype.drawTicks=function(){for(var i,t=0;t<=10;t++)i=7,this.chart.append("path").attr("class","gaugeTicks").attr("d",this.calculateTicks(i,t/20))},n.prototype.calculateTicks=function(n,t){var i=this.percToRad(t),r=0,u=0,f=r-90*Math.cos(i),e=u-90*Math.sin(i),o=r-86*Math.cos(i),s=u-86*Math.sin(i);return"M "+o+" "+s+" L "+f+" "+e},n}(),ko.bindingHandlers.testGauge={init:function(){},update:function(n,t,i){var r,o,f;if((n.innerHTML="",r=ko.unwrap(t()),r.totalRange&&r.lowerIsWorse!=undefined)&&!(r.dataValue>r.totalRange)){o=$(n).css("width")?parseInt($(n).css("width")):320,f=$(n).css("height")?parseInt($(n).css("height")):160,f==0&&(f=100);var s=i().marginTop?i().marginTop:25,h=i().marginRight?i().marginRight:25,c=i().marginBottom?i().marginBottom:25,l=i().marginLeft?i().marginLeft:25,u={top:s,right:h,bottom:c,left:l},a=o-u.left-u.right,v=f-u.top-u.bottom,e=new TestGauge;e.setupChartArea(n,a,v,u,r.lowerIsWorse,r.totalRange),e.drawGauge(r),e.drawNeedle(r)}}},SorenessControl=function(){function n(n,t){t===void 0&&(t=null);var i=this;this.value=n,this.canSave=t,this.currentJoint=ko.observable(null),this.currentMuscle=ko.observable(null),this.sideMap=["Both sides","Left side","Right side"],t&&ko.computed(function(){var n=!0;i.currentJoint()&&(n=!1),i.currentMuscle()&&(n=!1),t(n)})}return n.prototype.finish=function(){this.currentJoint()&&this.addJoint(!0),this.currentMuscle()&&this.addMuscle(!0),this.cancel()},n.prototype.cancel=function(){this.currentJoint(null),this.currentMuscle(null)},n.prototype.createMuscle=function(){var n=this;this.currentlyEditing=null,this.currentJoint(null),this.currentMuscle({type:ko.observable("muscle"),soreness:ko.observable(0),sorenessSide:ko.observable(-1),morphMuscle:ko.observable(),displayText:ko.computed(function(){if(n.currentMuscle()==null)return"";var t=n.sideMap[n.currentMuscle().sorenessSide()]+", ";return t+=mmap[n.currentMuscle().morphMuscle()]+", ",t+=n.currentMuscle().soreness()+"/10"})})},n.prototype.loadItem=function(n,t,i,r){r==="muscle"?this.loadMuscle(n,t,i):r==="joint"&&this.loadJoint(n,t,i)},n.prototype.loadJoint=function(n,t,i){var u=this,r;this.value().forEach(function(u){u.soreness()===n&&u.sorenessSide()===t&&u.morphMuscle()===i&&(r=u)}),r&&(this.currentlyEditing=r,this.currentMuscle(null),this.currentJoint({type:ko.observable("joint"),soreness:ko.observable(r.soreness()),sorenessSide:ko.observable(r.sorenessSide()),sorenessLocation:ko.observable(-1),morphMuscle:ko.observable(r.morphMuscle()),displayText:ko.computed(function(){if(u.currentJoint()==null)return"";var n=u.sideMap[u.currentJoint().sorenessSide()]+", ";return n+=mmap[u.currentJoint().morphMuscle()]+", ",n+=u.currentJoint().soreness()+"/10"})}))},n.prototype.loadMuscle=function(n,t,i){var u=this,r;this.value().forEach(function(u){u.soreness()===n&&u.sorenessSide()===t&&u.morphMuscle()===i&&(r=u)}),r&&(this.currentlyEditing=r,this.currentJoint(null),this.currentMuscle({type:ko.observable("muscle"),soreness:ko.observable(r.soreness()),sorenessSide:ko.observable(r.sorenessSide()),morphMuscle:ko.observable(r.morphMuscle()),displayText:ko.computed(function(){if(u.currentMuscle()==null)return"";var n=u.sideMap[u.currentMuscle().sorenessSide()]+", ";return n+=mmap[u.currentMuscle().morphMuscle()]+", ",n+=u.currentMuscle().soreness()+"/10"})}))},n.prototype.remove=function(n,t,i){var r;this.value().forEach(function(u){u.soreness()===n&&u.sorenessSide()===t&&u.morphMuscle()===i&&(r=u)}),this.value.remove(r)},n.prototype.createJoint=function(){var n=this;this.currentMuscle(null),this.currentJoint({type:ko.observable("joint"),soreness:ko.observable(0),sorenessSide:ko.observable(-1),sorenessLocation:ko.observable(-1),morphMuscle:ko.observable(),displayText:ko.computed(function(){if(n.currentJoint()==null)return"";var t=n.sideMap[n.currentJoint().sorenessSide()]+", ";return t+=mmap[n.currentJoint().morphMuscle()]+", ",t+=n.currentJoint().soreness()+"/10"})})},n.prototype.clearAll=function(){this.value([]),this.createMuscle()},n.prototype.addMuscle=function(n){if(!this.currentMuscle().morphMuscle()){n||alert("Please select a muscle");return}if(this.currentMuscle().sorenessSide()==-1){n||alert("Please select a side");return}if(this.currentMuscle().soreness()===0){n||alert("Please select a soreness level");return}this.value==undefined&&(this.value=ko.observableArray([])),this.currentlyEditing!=null&&this.remove(this.currentlyEditing.soreness,this.currentlyEditing.sorenessSide,this.currentlyEditing.morphMuscle),this.value.push({type:ko.observable(this.currentMuscle().type()),soreness:ko.observable(this.currentMuscle().soreness()),sorenessSide:ko.observable(this.currentMuscle().sorenessSide()),morphMuscle:ko.observable(this.currentMuscle().morphMuscle()),displayText:ko.observable(this.currentMuscle().displayText())}),this.createMuscle()},n.prototype.addJoint=function(n){if(!this.currentJoint().morphMuscle()){n||alert("Please select a joint");return}if(this.currentJoint().sorenessSide()==-1){n||alert("Please select a side");return}if(this.currentJoint().soreness()===0){n||alert("Please select a soreness level");return}this.value==undefined&&(this.value=ko.observableArray([])),this.currentlyEditing!=null&&this.remove(this.currentlyEditing.soreness,this.currentlyEditing.sorenessSide,this.currentlyEditing.morphMuscle),this.value.push({type:ko.observable(this.currentJoint().type()),soreness:ko.observable(this.currentJoint().soreness()),sorenessSide:ko.observable(this.currentJoint().sorenessSide()),sorenessLocation:ko.observable(this.currentJoint().sorenessLocation()),morphMuscle:ko.observable(this.currentJoint().morphMuscle()),displayText:ko.observable(this.currentJoint().displayText())}),this.createJoint()},n}(),ko.bindingHandlers.soreness={init:function(n,t,i,r,u){var s=i().canSave,f=t(),e,o;return f==undefined&&(f=ko.observableArray([])),e=new SorenessControl(f,s),o=u.createChildContext(e),ko.renderTemplate("tplSorenessView",o,{},n),{controlsDescendantBindings:!0}},update:function(){}},InjuryControl=function(){function n(n,t){var i=this;this.value=n,this.canSave=t,this.currentJoint=ko.observable(null),this.currentMuscle=ko.observable(null),this.currentIllness=ko.observable(null),this.sideMap=["Both sides","Left side","Right side"],this.severityMap=["Mild","Moderate","Severe"],t&&ko.computed(function(){var n=!0;i.currentJoint()&&(n=!1),i.currentMuscle()&&(n=!1),i.currentIllness()&&(n=!1),t(n)})}return n.prototype.finish=function(){this.currentJoint()&&this.addJoint(!0),this.currentMuscle()&&this.addMuscle(!0),this.currentIllness()&&this.addIllness(!0),this.cancel()},n.prototype.cancel=function(){this.currentJoint(null),this.currentMuscle(null),this.currentIllness(null)},n.prototype.createMuscle=function(){this.currentlyEditing=null,this.currentJoint(null),this.currentIllness(null),this.currentMuscle({type:ko.observable("muscle"),painScale:ko.observable(0),occurredDuring:ko.observable(),injurySide:ko.observable(-1),injuryNameMuscle:ko.observable(),injurySeverity:ko.observable(-1),morphMuscle:ko.observable(),displayText:this.calculateMuscleDisplay()})},n.prototype.calculateMuscleDisplay=function(){var n=this;return ko.computed(function(){var t=n.currentMuscle(),i;return t==null?"":(i=n.sideMap[t.injurySide()]+", ",i+=mmap[t.morphMuscle()]+", ",i+=t.injuryNameMuscle()+", ",i+=n.severityMap[t.injurySeverity()]+", ",i+=t.painScale()+"/10, ",i+=t.occurredDuring())})},n.prototype.calculateJointDisplay=function(){var n=this;return ko.computed(function(){var t=n.currentJoint(),i;return t==null?"":(i=n.sideMap[t.injurySide()]+", ",i+=mmap[t.morphMuscle()]+", ",i+=t.injuryNameJoint()+", ",i+=n.severityMap[t.injurySeverity()]+", ",i+=t.painScale()+"/10, ",i+=t.occurredDuring())})},n.prototype.createJoint=function(){this.currentlyEditing=null,this.currentMuscle(null),this.currentIllness(null),this.currentJoint({type:ko.observable("joint"),painScale:ko.observable(0),occurredDuring:ko.observable(),injurySide:ko.observable(-1),injuryLocation:ko.observable(-1),injuryNameJoint:ko.observable(),injurySeverity:ko.observable(-1),morphMuscle:ko.observable(),displayText:this.calculateJointDisplay()})},n.prototype.createIllness=function(){var n=this;this.currentlyEditing=null,this.currentMuscle(null),this.currentJoint(null),this.currentIllness({type:ko.observable("illness"),illnessSeverity:ko.observable(-1),illnessType:ko.observable(),displayText:ko.computed(function(){if(n.currentIllness()==null)return"";return n.currentIllness().illnessType()+", "+n.currentIllness().illnessSeverity()})})},n.prototype.loadJoint=function(n,t,i,r,u,f){var e;this.value().forEach(function(o){o.type()==="joint"&&ko.unwrap(o.painScale)===n&&ko.unwrap(o.occurredDuring)===t&&ko.unwrap(o.injurySide)===i&&ko.unwrap(o.injuryNameJoint)===r&&ko.unwrap(o.injurySeverity)===u&&ko.unwrap(o.morphMuscle)===f&&(e=o)}),e&&(this.currentlyEditing=e,this.currentMuscle(null),this.currentIllness(null),this.currentJoint({type:ko.observable("joint"),painScale:ko.observable(e.painScale()),occurredDuring:ko.observable(e.occurredDuring()),injurySide:ko.observable(e.injurySide()),injuryLocation:ko.observable(e.injuryLocation()),injuryNameJoint:ko.observable(e.injuryNameJoint()),injurySeverity:ko.observable(e.injurySeverity()),morphMuscle:ko.observable(e.morphMuscle()),displayText:this.calculateJointDisplay()}))},n.prototype.loadMuscle=function(n,t,i,r,u,f){var o=this,e;this.value().forEach(function(o){o.type()==="muscle"&&ko.unwrap(o.painScale)===n&&ko.unwrap(o.occurredDuring)===t&&ko.unwrap(o.injurySide)===i&&ko.unwrap(o.injuryNameMuscle)===r&&ko.unwrap(o.injurySeverity)===u&&ko.unwrap(o.morphMuscle)===f&&(e=o)}),e&&(this.currentlyEditing=e,this.currentJoint(null),this.currentIllness(null),this.currentMuscle({type:ko.observable("muscle"),painScale:ko.observable(e.painScale()),occurredDuring:ko.observable(e.occurredDuring()),injurySide:ko.observable(e.injurySide()),injuryNameMuscle:ko.observable(e.injuryNameMuscle()),injurySeverity:ko.observable(e.injurySeverity()),morphMuscle:ko.observable(e.morphMuscle()),displayText:this.calculateMuscleDisplay()}))},n.prototype.loadIllness=function(n,t){var r=this,i;this.value().forEach(function(r){r.type()==="illness"&&ko.unwrap(r.illnessSeverity)===t&&ko.unwrap(r.illnessType)===n&&(i=r)}),i&&(this.currentlyEditing=i,this.currentMuscle(null),this.currentJoint(null),this.currentIllness({type:ko.observable("illness"),illnessSeverity:ko.observable(i.illnessSeverity()),illnessType:ko.observable(i.illnessType()),displayText:ko.computed(function(){if(r.currentIllness()==null)return"";return r.currentIllness().illnessType()+", "+r.currentIllness().illnessSeverity()})}))},n.prototype.removeJoint=function(n,t,i,r,u,f){var e;this.value().forEach(function(o){ko.unwrap(o.painScale)===n&&ko.unwrap(o.occurredDuring)===t&&ko.unwrap(o.injurySide)===i&&ko.unwrap(o.injuryNameJoint)===r&&ko.unwrap(o.injurySeverity)===u&&ko.unwrap(o.morphMuscle)===f&&(e=o)}),this.value.remove(e)},n.prototype.removeMuscle=function(n,t,i,r,u,f){var e;this.value().forEach(function(o){ko.unwrap(o.painScale)===n&&ko.unwrap(o.occurredDuring)===t&&ko.unwrap(o.injurySide)===i&&ko.unwrap(o.injuryNameMuscle)===r&&ko.unwrap(o.injurySeverity)===u&&ko.unwrap(o.morphMuscle)===f&&(e=o)}),this.value.remove(e)},n.prototype.removeIllness=function(n,t){var i;this.value().forEach(function(r){ko.unwrap(r.illnessType)===n&&ko.unwrap(r.illnessSeverity)===t&&(i=r)}),this.value.remove(i)},n.prototype.clearAll=function(){this.value([]),this.createMuscle()},n.prototype.removeCurrent=function(){if(this.currentlyEditing.illnessType!=null){this.removeIllness(this.currentlyEditing.illnessType,this.currentlyEditing.illnessSeverity);return}if(this.currentlyEditing.injuryNameMuscle!=null){this.removeMuscle(this.currentlyEditing.painScale,this.currentlyEditing.occurredDuring,this.currentlyEditing.injurySide,this.currentlyEditing.injuryNameMuscle,this.currentlyEditing.injurySeverity,this.currentlyEditing.morphMuscle);return}this.removeJoint(this.currentlyEditing.painScale,this.currentlyEditing.occurredDuring,this.currentlyEditing.injurySide,this.currentlyEditing.injuryNameJoint,this.currentlyEditing.injurySeverity,this.currentlyEditing.morphMuscle);return},n.prototype.addMuscle=function(n){if(!this.currentMuscle().morphMuscle()){n||alert("Please select a muscle");return}if(!this.currentMuscle().occurredDuring()){n||alert("Please select during");return}if(this.currentMuscle().injurySide()==-1){n||alert("Please select a side");return}if(this.currentMuscle().injurySeverity()==-1){n||alert("Please select a severity");return}if(this.currentMuscle().painScale()===0){n||alert("Please select a pain scale value");return}this.currentlyEditing!=null&&this.removeCurrent(),this.value.push({type:ko.observable(this.currentMuscle().type()),painScale:ko.observable(this.currentMuscle().painScale()),occurredDuring:ko.observable(this.currentMuscle().occurredDuring()),injurySide:ko.observable(this.currentMuscle().injurySide()),injuryNameMuscle:ko.observable(this.currentMuscle().injuryNameMuscle()),injurySeverity:ko.observable(this.currentMuscle().injurySeverity()),morphMuscle:ko.observable(this.currentMuscle().morphMuscle()),displayText:ko.observable(this.currentMuscle().displayText())}),this.createMuscle()},n.prototype.addJoint=function(n){if(!this.currentJoint().morphMuscle()){n||alert("Please select a muscle");return}if(!this.currentJoint().occurredDuring()){n||alert("Please select during");return}if(this.currentJoint().injurySide()==-1){n||alert("Please select a side");return}if(this.currentJoint().injurySeverity()==-1){n||alert("Please select a severity");return}if(this.currentJoint().painScale()===0){n||alert("Please select a pain scale value");return}this.currentlyEditing!=null&&this.removeCurrent(),this.value.push({type:ko.observable(this.currentJoint().type()),painScale:ko.observable(this.currentJoint().painScale()),occurredDuring:ko.observable(this.currentJoint().occurredDuring()),injurySide:ko.observable(this.currentJoint().injurySide()),injuryLocation:ko.observable(this.currentJoint().injuryLocation()),injuryNameJoint:ko.observable(this.currentJoint().injuryNameJoint()),injurySeverity:ko.observable(this.currentJoint().injurySeverity()),morphMuscle:ko.observable(this.currentJoint().morphMuscle()),displayText:ko.observable(this.currentJoint().displayText())}),this.createJoint()},n.prototype.addIllness=function(n){if(!this.currentIllness().illnessSeverity()||this.currentIllness().illnessSeverity()==-1){n||alert("Please select a severity");return}this.currentlyEditing!=null&&this.removeCurrent(),this.value.push({type:ko.observable(this.currentIllness().type()),illnessSeverity:ko.observable(this.currentIllness().illnessSeverity()),illnessType:ko.observable(this.currentIllness().illnessType()),displayText:ko.observable(this.currentIllness().displayText())}),this.createIllness()},n}(),ko.bindingHandlers.injury={init:function(n,t,i,r,u){var s=i().canSave,f=t(),e,o;return f==undefined&&(f=ko.observableArray([])),e=new InjuryControl(f,s),o=u.createChildContext(e),ko.renderTemplate("tplInjuryView",o,{},n),{controlsDescendantBindings:!0}},update:function(){}},DurationSelect=function(){function n(n,t){var i=this;this.totalTime=n,this.editable=t,this.hours=ko.computed({read:function(){return Math.floor(i.totalTime()/3600)},write:function(n){i.totalTime(n*3600+i.minutes()*60+i.seconds())}}),this.minutes=ko.computed({read:function(){return Math.floor(i.totalTime()/60%60)},write:function(n){i.totalTime(i.hours()*3600+n*60+i.seconds())}}),this.seconds=ko.computed({read:function(){return i.totalTime()%60},write:function(n){i.totalTime(i.hours()*3600+i.minutes()*60+n)}})}return n}(),ko.bindingHandlers.durationSelect={init:function(n,t,i,r,u){var f=ko.unwrap(t()),e=new DurationSelect(f.value,f.editable),o=u.createChildContext(e);return ko.renderTemplate("tplDurationSelect",o,{},n),{controlsDescendantBindings:!0}},update:function(){}},ko.bindingHandlers.duration={init:function(n,t){var f=t();return document.addEventListener("click",function(n){var t=$(n.target),i;t.hasClass("durationRange")||(i=$(t[0].parentNode),i.hasClass("durationRange")||f(null))},!1),document.addEventListener("mousedown",function(n){var t=$(n.target),i;t.hasClass("durationRange")||(i=$(t[0].parentNode),i.hasClass("durationRange")||f(null))},!1),{controlsDescendantBindings:!0}},update:function(){}},Tabs=function(){function n(n,t,i){i===void 0&&(i=function(){}),this.tabs=n,this.selectTab=t,this.closeTab=i,this.selectedTab=ko.observable()}return n.prototype.selectTabIndex=function(n){this.selectedTab(ko.unwrap(this.tabs)[n])},n}(),_this=this,Dropzone.autoDiscover=!1,fileChangeEventSubscribed=!1,window.URL=window.URL||window.webkitURL,ko.bindingHandlers.dropzone={init:function(n,t){function p(){h=!1,w(e),w(c),f.removeAllFiles(),$(".dz-message").show(),u=[],o=0,l=!1,a=!1,s=!1}function w(n){n!==null&&clearTimeout(n)}function it(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);return n}function rt(n){var t=new XMLHttpRequest;t.open(n.type,n.url,!0),t.onload=function(){if(t.status>=200&&t.status<400){if(typeof n.success=="function"){var i=t.responseText;n.success(i)}}else typeof n.error=="function"&&n.error(t)},typeof n.error=="function"&&(t.onerror=n.error),t.send()}function k(n,i){var u=ko.unwrap(nt),r="";r=Array.isArray(u)?u.pop():u,$.getJSON("/api/2/exercise/SignedUrl?id="+encodeURIComponent(r)+"&fileName="+encodeURIComponent(n.name)+"&contentType="+encodeURIComponent(n.type)).done(function(u){var e=new UploadFile;e.id(r),e.name(n.name),t.value.push(e),n.getUrl=u.getUrl,n.dynamicUploadUrl=u.url,n.uploadFileObject=e,e.cancelFileUploadTrigger.subscribe(function(){f.removeFile(n)}),i(),d()})}function d(){o++,o===u.length&&(u=[],o=0)}function g(){i.processed=!0,setTimeout(function(){i.isValid=!1,i.errorMessage="",i.processed=!1},1e3)}var f,ut=_this,r,y,b;$(n).addClass("dropzone"),t=t()||{};var nt=t.id,tt=t.url,ft=function(n){rt({url:n,type:"DELETE",error:function(n){console.error("dropzone@err:",n)}})},h=!1,e,c,u=[],o=0,i={isValid:!1,errorMessage:"",processed:!1},l=!1,a=!1,s=!1,v=t.resetSignal;ko.isObservable(v)&&v.subscribe(function(){f.removeAllFiles(),$(".dz-message").show()}),r=t.controlType||"video",y=function(){this.on("addedfile",function(n){var f=this;u.push(n),setTimeout(function(){n.accepted||(h=!0,e!=null&&clearTimeout(e),e=setTimeout(function(){i.errorMessage=u.length>t.maxFiles?"Only allow maximum "+t.maxFiles+" "+r+" to upload each time":"Please only upload "+r+" files",i.isValid=!1,bootbox.alert(i.errorMessage),g(),p()},30)),h?(f.removeFile(n),$(".dz-message").show(),c!==null&&clearTimeout(c)):r==="video"?i.isValid=!0:r==="image"&&setTimeout(function(){u.length>t.maxFiles?(i.errorMessage="Only allow maximum "+t.maxFiles+" images to upload each time",i.isValid=!1,bootbox.alert(i.errorMessage),g(),p()):i.isValid=!0},20)},10)});this.on("removedfile",function(){});this.on("uploadprogress",function(n,t){if(r==="video"){var u=Math.min(parseInt(t+""),99);n.uploadFileObject.progress(u)}});var n=function(t,i){$.getJSON("/api/2/exercise/ConvertVideoProgress?id="+i).done(function(r){r.status=="COMPLETE"?(t.uploadFileObject.progress(100),t.uploadFileObject.url(t.getUrl)):r.status=="ERROR"||(t.uploadFileObject.progress(50),n(t,i))})};this.on("success",function(i){r==="video"?$.post("/api/2/exercise/ConvertVideo?sourceUrl="+encodeURIComponent(i.dynamicUploadUrl)+"&fileName="+encodeURIComponent(i.name)+"&includeAudio="+s).done(function(t){i.uploadFileObject.progress(50),n(i,t)}):r==="image"&&t.value("/2/dh.ashx?u=Images/Thumbnails/"+ko.unwrap(t.id)+".jpg")})},b=it(t,{method:"PUT",acceptedFiles:r+"/*",addRemoveLinks:!1,init:y,createImageThumbnails:!1,parallelUploads:6,autoProcessQueue:!0,uploadMultiple:!1,accept:function(n,u){n.accepted=!0,n.acceptInterval=setInterval(function(){if(i.isValid)if(r==="video")if(l)a&&(clearInterval(n.acceptInterval),k(n,u));else{clearInterval(n.acceptInterval),l=!0;var f=bootbox.prompt({title:"Do you wish to include Audio?<br>This applies to all selected videos.",inputType:"checkbox",className:"small",value:"1",inputOptions:[{text:"No",value:"1"},{text:"Yes",value:"0"}],callback:function(t){a=!0,s=t===null?!1:t[0]==="0",k(n,u)}});$(f.find(".modal-footer").find("button")[0]).remove();f.find(".modal-body").on("change",'input[type="checkbox"]',function(n){$(f).find(":checkbox").map(function(){this.checked=!1}),n.currentTarget.checked=!0})}else r==="image"&&(clearInterval(n.acceptInterval),n.dynamicUploadUrl=ko.unwrap(tt),t.fileChosen()?t.fileChosen.valueHasMutated():t.fileChosen(!0),u(),d());else!i.isValid&&i.errorMessage.length&&clearInterval(n.acceptInterval)},10)},url:function(n){return n[0].dynamicUploadUrl},sending:function(n,i){t.fileChosen()?t.fileChosen.valueHasMutated():t.fileChosen(!0),i.setRequestHeader("Content-Type",n.type);var r=i.send;i.send=function(){r.call(i,n)}}}),f=new Dropzone(n,b)}},UploadFile=function(){function n(){this.id=ko.observable(""),this.name=ko.observable(""),this.url=ko.observable(""),this.progress=ko.observable(0),this.dropzone=ko.observable(!0),this.cancelFileUploadTrigger=ko.observable(0)}return n}();var Container=function(){function n(n,t,i){i===void 0&&(i=!1),this.parentContainer=n,this.basePath=t,this.constrain=i,this.currentType="",this.currentView="",this.currentController=ko.observable(),this.history=ko.observableArray([])}return n.prototype.navigateTo=function(n){this.constrain?this.parse(n):this.parentContainer?this.parentContainer.navigateTo(this.basePath()+n):navigateTo(n)},n.prototype.setController=function(n,t,i){for(var o=[],e,u,f,r=3;r<arguments.length;r++)o[r-3]=arguments[r];e=this.currentType===t,u=e?this.currentController():i(),u.init&&u.init.apply(u,o),e||(this.currentType=t,f=$("#google_translate_element"),f&&(this.currentType.indexOf("Phone")>=0||this.currentType.indexOf("Snap2")>=0?f.hide():f.show()),this.currentView=n,this.currentController(u))},n.prototype.goBack=function(){return this.history().length>1?(this.history.pop(),this.parse(this.history.pop()),!0):(this.history().length&&this.history.pop(),!1)},n.prototype.parse=function(n){this.history.push(n),n?(currentContainer=this,crossroads.ignoreState=!0,crossroads.parse(n),crossroads.ignoreState=!1):(this.currentType="",this.currentView="",this.currentController(null))},n}(),currentContainer,Main=function(){function n(){var n,t,i;this.container=new Container(null,null),this.user="",this.dateFormat="",this.canAddTest=!1,this.unitFormat="metric",this.startup={startupPage:"Programs",defaultClient:null,defaultDashboard:null,defaultDashboardView:"Dashboard"},this.clipboards={week:ko.observableArray([]),session:ko.observable(),exercise:ko.observableArray([]),text:ko.observable(),day:ko.observable(),lastProgramType:ko.observable()},this.notification=new Notification2,this.notification2=new Notification2Extra,n=+new Date,this.user.length?setTimeout(function(){$.get("/Application/Home/PrivacyPolicy?_cache="+n).done(function(n){n==="no"&&showDialog($("#notificationTemplate"))})},100):(t=this,i=setInterval(function(){!t.user||(clearInterval(i),$.get("/Application/Home/PrivacyPolicy?_cache="+n).done(function(n){n==="no"&&showDialog($("#notificationTemplate"))}))},500)),privacy2&&this.checkPrivacy2()}return n.prototype.checkPrivacy2=function(){var n=+new Date,t,i;this.user.length?setTimeout(function(){$.get("/Application/Home/UfcPrivacyPolicy?_cache="+n).done(function(n){n==="no"&&showDialog($("#notificationTemplate2"))})},100):(t=this,i=setInterval(function(){!t.user||(clearInterval(i),$.get("/Application/Home/UfcPrivacyPolicy?_cache="+n).done(function(n){n==="no"&&showDialog($("#notificationTemplate2"))}))},500))},n.prototype.openExerciseWin=function(n){if(window.home){var t=new Container(null,null,!0);t.parse("Exercise/"+n),window.home.exercise(t),showDialog($("#"+window.home.exerciseModalId))}},n}(),Notification2=function(){function n(){this.title=ko.observable("We have recently updated our Privacy Policy and Terms of Service."),this.isPost25th=ko.pureComputed(function(){return!0}),this.agree=ko.observable(!1),this.p1=ko.observable("<ul class='notification-list'><li>Reflects the recent standards introduced by the EU data protection law - General Data Protection Regulation (<a href='https://www.eugdpr.org/' target='_blank'>GDPR<\/a>).<\/li><li>Provides clarity regarding how we collect, store, secure and use your personal data.<\/li><li>Takes effect May 25th, 2018.<\/li><\/ul>"),this.p2=ko.observable(" To continue using our services after May 25th, you will need to agree to the <a href='/Privacy' target='_blank'>Privacy Policy<\/a> and <a href='/TermsOfUse' target='_blank'>Terms of Service<\/a>"+(this.isPost25th()?".":", or you can agree now."))}return n.prototype.closeDialog=function(){this.agree()&&$.post("/Application/Home/PrivacyPolicy",{setting:"agree"}),$("#notificationTemplate").modal("hide")},n}(),Notification2Extra=function(){function n(){this.agree=ko.observable(!1),this.date=(new Date).toDateString()}return n.prototype.closeDialog=function(){this.agree()&&$.post("/Application/Home/UfcPrivacyPolicy",{setting:"agree"}),$("#notificationTemplate2").modal("hide")},n}(),main;parseHash=function(n,t){var i=main.container.currentController();if(i&&i.menuLinks&&i.container&&(i=i.container.currentController()),i&&i.saveBeforeExit&&!i.saveBeforeExit(n,t))return hasher.changed.active=!1,hasher.setHash(t),hasher.changed.active=!0,!1;if(i&&i.simpleSave)if(i.skipNextSave)i.skipNextSave=!1;else if(i.hasChanges())return hasher.changed.active=!1,hasher.setHash(t),hasher.changed.active=!0,promptToSave(i,n,t),!1;main.user||n=="signup"||(n="logon"),gotoSnap&&!n&&(n="snap"),currentContainer=main.container,shortcut.removeAll(),crossroads.parse(n)},templatesLoaded={},String.prototype.encodeHTML=encodeHTMLSource(),function(n){function t(n,t){t=t||"";var r=t.indexOf("?"),i=+new Date;return $.getJSON("/api/2/"+n+"/Get"+(t?"/"+t:"")+(r==-1?"?_cache="+i:"&_cache="+i))}function i(n){var t=+new Date;return $.getJSON("/api/2/"+n+"/GetAll?_cache="+t)}function r(n,t){t=t||"";var r=t.indexOf("?"),i=+new Date;return $.getJSON("/api/2/"+n+"/Get"+(t?"/"+t:"")+(r==-1?"?_cache="+i:"&_cache="+i))}function u(n,t){t=t||"";var r=t.indexOf("?"),i=+new Date;return $.getJSON("/api/2/"+n+"/GetForm"+(t?"/"+t:"")+(r==-1?"?_cache="+i:"&_cache="+i))}function f(n,t){return $.ajax({type:"POST",url:"/api/2/"+n,data:JSON.stringify(t),contentType:"application/json"})}function e(n,t){return $.ajax({type:"POST",url:"/api/"+n,data:JSON.stringify(t),contentType:"application/json"})}function o(n){return n&&n.responseJSON&&n.responseJSON.message?n.responseJSON.message:n&&n.responseText?n.responseText:n}n.read=t,n.readAll=i,n.readHACK2=r,n.readHACK=u,n.write=f,n.writeApi=e,n.getErrorMessage=o}(Data||(Data={})),SelectClients=function(){function n(n,t,i,r,u,f){var e=this;i===void 0&&(i=!1),r===void 0&&(r=!1),u===void 0&&(u=!1),f===void 0&&(f=!1),this.clientsGrid=n,this.onlyClientsAndCoaches=t,this.onlyLocalUsers=u,this.showForResources=f,this.showSelectButtons=ko.observable(!0),this.columns=[{id:"name",width:190,label:"Name",formatter:renderName},{id:"email",width:190,label:"Email"},{id:"category",width:85,label:"Category"},{id:"sport",width:190,label:"Sport"},{label:"Team",width:100,id:"team"},{id:"discipline",width:145,label:"Discipline"},{id:"group",width:115,label:"Group"},{id:"keyword",width:115,label:"Keyword"}],this.selectClientsId=_.uniqueId("selectClients"),this.stackOptions=[{name:"Name",value:[],display:"Name"},{name:"Sport, Name",value:[{id:"sport",text:"Sport"}],display:"Sport"},{name:"Team, Name",value:[{id:"team",text:"Team"}],display:"Team"},{name:"Discipline, Name",value:[{id:"discipline",text:"Discipline"}],display:"Discipline"},{name:"Group, Name",value:[{id:"group",text:"Group"}],display:"Group"},{name:"Sport, Team, Name",value:[{id:"sport",text:"Sport"},{id:"team",text:"Team"}],display:"Sport / Team"},{name:"Sport, Discipline, Name",value:[{id:"sport",text:"Sport"},{id:"discipline",text:"Discipline"}],display:"Sport / Discipline"},{name:"Sport, Group, Name",value:[{id:"sport",text:"Sport"},{id:"group",text:"Group"}],display:"Sport / Group"}],this.stackData=ko.observable(this.stackOptions[0].value),this.skipNextStackDataChange=ko.observable(!1),this.enableSort=ko.observable(!0),this.treeClick={selector:"li",method:"selectTree",scope:this},this.filters=ko.observableArray([]),this.forceShowClients=ko.observable(!1),this.currentTreeItem=ko.computed(function(){var n=e.stackData(),t=e.filters().length;return t>=n.length?"":n[t].text}),this.clientsLoaded=ko.observable(!1),this.clients=ko.observableArray([]),this.clientsFilter=ko.observable(""),this.filteredClients=ko.computed(function(){var n=e.filters(),t={};return e.selectClientsGrid&&e.selectClientsGrid.selectedRows&&_.each(e.selectClientsGrid.selectedRows(),function(n){n&&(t[n.id]=!0)}),_.filter(e.clients(),function(i){if(t[i.id])return!0;if(i.category==="Team"||i.category==="Find"||e.onlyClientsAndCoaches&&i.category!="Web Client"&&i.category!="Coach"||_.find(e.clientsGrid.data(),function(n){return n&&(n.email||"").toLowerCase()==(i.email||"").toLowerCase()}))return!1;for(var r=0;r<n.length;r++)if((i[n[r].id]||"")!=n[r].value)return!1;for(r=0;r<e.columns.length;r++)if((i[e.columns[r].id]||"").toLowerCase().indexOf(e.clientsFilter().toLowerCase())!=-1)return!0;return!1})}),this.loadedSelectClients=ko.observable(!1),this.selectClientsGrid={data:this.filteredClients,columns:this.columns,selectedRows:ko.observableArray([]),sortBy:ko.observable("name"),hideCheckbox:!1,keepSelected:!1,checkboxText:ko.observable("")},this.allowEmptySelection=ko.observable(!1),this.onlyCoaches=!1,this.loadLastSelectedOption(),i&&(this.selectClientsGrid.hideCheckbox=!0,this.showSelectButtons(!1)),this.allowEmptySelection(r),this.treeItems=ko.computed(function(){var t=e.stackData(),i=e.filters().length,r,n,u,f;return i>=t.length?[]:(r=t[i].id,n={},_.each(e.filteredClients(),function(t){var i=t[r]||"";n[i]=(n[i]||0)+1}),u=t[i].text,f=_.map(_.keys(n),function(t){return{id:r,value:t,text:t||"(No "+u+")",count:n[t]}}),_.sortBy(f,"value"))}),ko.computed(function(){e.clientsFilter()&&e.filteredClients().length<=10?e.forceShowClients(!0):e.forceShowClients(!1)}),this.stackData.subscribe(function(n){e.filters([]),e.skipNextStackDataChange()||window.localStorage.setItem(e.lastSelectedOptionKey(),JSON.stringify(n)),e.skipNextStackDataChange(!1)})}return n.prototype.levelUp=function(n){n==-1?this.filters.pop():this.filters.splice(n)},n.prototype.selectTree=function(n){this.filters.push(n)},n.prototype.loadLastSelectedOption=function(){var n=window.localStorage.getItem(this.lastSelectedOptionKey());if(n){var r=JSON.parse(n),t=_.map(r,function(n){return n.id}),i=_.find(this.stackOptions,function(n){var u=_.map(n.value,function(n){return n.id}),r,f,i;if(u.length!==t.length)return!1;for(r=t.sort(),f=u.sort(),i=0;i<r.length;i++)if(r[i]!==f[i])return!1;return!0});i&&this.stackData(i.value)}},n.prototype.lastSelectedOptionKey=function(){return main.user+"_selectedOption"},n.prototype.initFiltered=function(n,t){var i=this,r,u;return t===void 0&&(t=null),t&&(r=t.indexOf("<"),r!==-1&&(t=t.substring(r+1,t.length-1))),u={},_.each(_.map(n,function(n){var t=n.indexOf("<");return t!==-1&&(n=n.substring(t+1,n.length-1)),n}),function(n){n&&(u[n]=!0)}),$.getJSON(this.onlyLocalUsers?"/Api/1/Rule/GetOwnUsers":this.showForResources?"/Api/1/Rule/GetAllUsersForResources":"/Api/1/Rule/GetAllUsers").fail(function(n){console.log(n),alert("error:"+n)}).done(function(n){i.clients(_.filter(n,function(n){return!!u[n.email]})),t&&i.selectClientsGrid.selectedRows(_.filter(i.selectClientsGrid.data(),function(n){return n.email===t}))})},n.prototype.init=function(){var n=this;return $.getJSON(this.onlyLocalUsers?"/Api/1/Rule/GetOwnUsers":this.showForResources?"/Api/1/Rule/GetAllUsersForResources":"/Api/1/Rule/GetAllUsers").fail(function(n){console.log(n),alert("error:"+n)}).done(function(t){n.onlyCoaches?n.clients(_.filter(t,function(n){return n.category==="Coach"})):n.clients(t),n.clientsLoaded(!0)})},n.prototype.selectAllClients=function(){this.selectClientsGrid.ignoreUpdate=!0,this.selectClientsGrid.selectedRows(this.selectClientsGrid.data()),this.selectClientsGrid.ignoreUpdate=!1},n.prototype.clearAllClients=function(){this.selectClientsGrid.ignoreUpdate=!0,this.selectClientsGrid.selectedRows([]),this.selectClientsGrid.ignoreUpdate=!1},n.prototype.showAddClients=function(n,t,i,r){n===void 0&&(n=null),t===void 0&&(t=!1),i===void 0&&(i=!1),r===void 0&&(r=!1),n!==null&&(this.onlyLocalUsers=n),this.onlyCoaches=t,this.showForResources=i,this.init(),this.loadedSelectClients(!1),this.clientsFilter(""),r===!1&&showDialog($("#"+this.selectClientsId)),this.loadedSelectClients(!0)},n.prototype.actuallyShow=function(){showDialog($("#"+this.selectClientsId))},n.prototype.addNone=function(){this.clientsGrid.data([]),$("#"+this.selectClientsId).modal("hide")},n.prototype.addClients=function(){var n=this,t=_.filter(this.selectClientsGrid.selectedRows(),function(t){return t&&!_.find(n.clientsGrid.data(),function(n){return n&&n.email==t.email})});this.clientsGrid.data(this.clientsGrid.data().concat(t)),$("#"+this.selectClientsId).modal("hide")},n.prototype.toggleClients=function(){this.forceShowClients(!this.forceShowClients())},n}(),SelectClients2=function(){function n(n,t,i,r,u,f){var e=this;i===void 0&&(i=!1),r===void 0&&(r=!1),u===void 0&&(u=!1),f===void 0&&(f=!1),this.clientsGrid=n,this.onlyClientsAndCoaches=t,this.onlyLocalUsers=u,this.showForResources=f,this.showSelectButtons=ko.observable(!0),this.showExisting=ko.observable(!0),this.columns=[{id:"name",width:190,label:"Name",formatter:renderName},{id:"email",width:190,label:"Email"},{id:"category",width:85,label:"Category"},{id:"sport",width:190,label:"Sport"},{label:"Team",width:100,id:"team"},{id:"discipline",width:145,label:"Discipline"},{id:"group",width:115,label:"Group"},{id:"keyword",width:115,label:"Keyword"}],this.selectClientsId=_.uniqueId("selectClients"),this.stackOptions=[{name:"Name",value:[],display:"Name"},{name:"Sport, Name",value:[{id:"sport",text:"Sport"}],display:"Sport"},{name:"Team, Name",value:[{id:"team",text:"Team"}],display:"Team"},{name:"Discipline, Name",value:[{id:"discipline",text:"Discipline"}],display:"Discipline"},{name:"Group, Name",value:[{id:"group",text:"Group"}],display:"Group"},{name:"Sport, Team, Name",value:[{id:"sport",text:"Sport"},{id:"team",text:"Team"}],display:"Sport / Team"},{name:"Sport, Discipline, Name",value:[{id:"sport",text:"Sport"},{id:"discipline",text:"Discipline"}],display:"Sport / Discipline"},{name:"Sport, Group, Name",value:[{id:"sport",text:"Sport"},{id:"group",text:"Group"}],display:"Sport / Group"}],this.stackData=ko.observable(this.stackOptions[0].value),this.skipNextStackDataChange=ko.observable(!1),this.enableSort=ko.observable(!0),this.treeClick={selector:"li",method:"selectTree",scope:this},this.filters=ko.observableArray([]),this.forceShowClients=ko.observable(!1),this.currentTreeItem=ko.computed(function(){var n=e.stackData(),t=e.filters().length;return t>=n.length?"":n[t].text}),this.selectedClients=ko.observableArray([]),this.clientsLoaded=ko.observable(!1),this.clients=ko.observableArray([]),this.clientsFilter=ko.observable(""),this.filteredClients=ko.computed(function(){var n=e.filters(),i={},t;return e.selectClientsGrid&&e.selectClientsGrid.selectedRows&&_.each(e.selectClientsGrid.selectedRows(),function(n){n&&(i[n.id]=!0)}),t={},e.existingGrid&&e.existingGrid.data&&_.each(e.existingGrid.data(),function(n){n&&(t[n.id]=!0)}),_.filter(e.clients(),function(r){if(t[r.id])return!1;if(i[r.id])return!0;if(r.category==="Team"||r.category==="Find"||e.onlyClientsAndCoaches&&r.category!="Web Client"&&r.category!="Coach"||_.find(e.clientsGrid.data(),function(n){return n&&(n.email||"").toLowerCase()==(r.email||"").toLowerCase()}))return!1;for(var u=0;u<n.length;u++)if((r[n[u].id]||"")!=n[u].value)return!1;for(u=0;u<e.columns.length;u++)if((r[e.columns[u].id]||"").toLowerCase().indexOf(e.clientsFilter().toLowerCase())!=-1)return!0;return!1})}),this.loadedSelectClients=ko.observable(!1),this.selectClientsGrid={data:this.filteredClients,columns:this.columns,selectedRows:ko.observableArray([]),sortBy:ko.observable("name"),hideCheckbox:!1,keepSelected:!1,checkboxText:ko.observable("")},this.existingGrid={data:this.selectedClients,columns:this.columns,selectedRows:ko.observableArray([]),sortBy:ko.observable("name"),hideCheckbox:!1,keepSelected:!1,checkboxText:ko.observable("")},this.allowEmptySelection=ko.observable(!1),this.onlyCoaches=!1,this.loadLastSelectedOption(),i&&(this.selectClientsGrid.hideCheckbox=!0,this.showSelectButtons(!1)),this.allowEmptySelection(r),this.treeItems=ko.computed(function(){var t=e.stackData(),i=e.filters().length,r,n,u,f;return i>=t.length?[]:(r=t[i].id,n={},_.each(e.filteredClients(),function(t){var i=t[r]||"";n[i]=(n[i]||0)+1}),u=t[i].text,f=_.map(_.keys(n),function(t){return{id:r,value:t,text:t||"(No "+u+")",count:n[t]}}),_.sortBy(f,"value"))}),ko.computed(function(){e.clientsFilter()&&e.filteredClients().length<=10?e.forceShowClients(!0):e.forceShowClients(!1)}),this.stackData.subscribe(function(n){e.filters([]),e.skipNextStackDataChange()||window.localStorage.setItem(e.lastSelectedOptionKey(),JSON.stringify(n)),e.skipNextStackDataChange(!1)})}return n.prototype.levelUp=function(n){n==-1?this.filters.pop():this.filters.splice(n)},n.prototype.selectTree=function(n){this.filters.push(n)},n.prototype.removeExisting=function(){var n=this,t=this.existingGrid.selectedRows().slice();_.each(t,function(t){n.existingGrid.data.remove(t)})},n.prototype.addExisting=function(){this.showExisting(!1)},n.prototype.addBack=function(){this.showExisting(!0)},n.prototype.addAdd=function(){var n=this;_.each(this.selectClientsGrid.selectedRows(),function(t){_.find(n.existingGrid.data(),function(n){return n.id===t.id})||n.existingGrid.data.push(t)}),this.showExisting(!0)},n.prototype.loadLastSelectedOption=function(){var n=window.localStorage.getItem(this.lastSelectedOptionKey());if(n){var r=JSON.parse(n),t=_.map(r,function(n){return n.id}),i=_.find(this.stackOptions,function(n){var u=_.map(n.value,function(n){return n.id}),r,f,i;if(u.length!==t.length)return!1;for(r=t.sort(),f=u.sort(),i=0;i<r.length;i++)if(r[i]!==f[i])return!1;return!0});i&&this.stackData(i.value)}},n.prototype.lastSelectedOptionKey=function(){return main.user+"_selectedOption"},n.prototype.initFiltered=function(n,t){var i=this,r,u;return t===void 0&&(t=null),t&&(r=t.indexOf("<"),r!==-1&&(t=t.substring(r+1,t.length-1))),u={},_.each(_.map(n,function(n){var t=n.indexOf("<");return t!==-1&&(n=n.substring(t+1,n.length-1)),n}),function(n){n&&(u[n]=!0)}),$.getJSON(this.onlyLocalUsers?"/Api/1/Rule/GetOwnUsers":this.showForResources?"/Api/1/Rule/GetAllUsersForResources":"/Api/1/Rule/GetAllUsers").fail(function(n){console.log(n),alert("error:"+n)}).done(function(n){i.clients(_.filter(n,function(n){return!!u[n.email]})),t&&i.selectClientsGrid.selectedRows(_.filter(i.selectClientsGrid.data(),function(n){return n.email===t}))})},n.prototype.init=function(){var n=this;return $.getJSON(this.onlyLocalUsers?"/Api/1/Rule/GetOwnUsers":this.showForResources?"/Api/1/Rule/GetAllUsersForResources":"/Api/1/Rule/GetAllUsers").fail(function(n){console.log(n),alert("error:"+n)}).done(function(t){n.onlyCoaches?n.clients(_.filter(t,function(n){return n.category==="Coach"})):n.clients(t),n.clientsLoaded(!0)})},n.prototype.selectAllClients=function(){this.selectClientsGrid.ignoreUpdate=!0,this.selectClientsGrid.selectedRows(this.selectClientsGrid.data()),this.selectClientsGrid.ignoreUpdate=!1},n.prototype.clearAllClients=function(){this.selectClientsGrid.ignoreUpdate=!0,this.selectClientsGrid.selectedRows([]),this.selectClientsGrid.ignoreUpdate=!1},n.prototype.showAddClients=function(n,t,i,r){n===void 0&&(n=null),t===void 0&&(t=!1),i===void 0&&(i=!1),r===void 0&&(r=!1),n!==null&&(this.onlyLocalUsers=n),this.onlyCoaches=t,this.showForResources=i,this.init(),this.loadedSelectClients(!1),this.clientsFilter(""),r===!1&&showDialog($("#"+this.selectClientsId)),this.loadedSelectClients(!0)},n.prototype.actuallyShow=function(){showDialog($("#"+this.selectClientsId));var n=$("#"+this.selectClientsId).find(".existingGrid").data("grid");n.resizeCanvas()},n.prototype.addNone=function(){this.clientsGrid.data([]),$("#"+this.selectClientsId).modal("hide")},n.prototype.addClients=function(){this.clientsGrid.data(this.existingGrid.data()),$("#"+this.selectClientsId).modal("hide")},n.prototype.toggleClients=function(){this.forceShowClients(!this.forceShowClients())},n}(),function(n){function t(){addRoute("glossary/:id:",function(n,t){requireModule("glossary",function(i){n.setController("glossary_glossary","Glossary.Glossary",function(){return new i.Glossary(n)},t)})})}n.registerRoutes=t}(GlossaryController||(GlossaryController={})),function(n){function t(){addRoute("anatomySelector/:tab:",function(n,t){t===void 0&&(t="muscle"),requireModule("anatomy",function(i){n.setController("anatomy_anatomySelector","Anatomy.AnatomySelector",function(){return new i.AnatomySelector(n)},t)})}),addRoute("anatomy/:tab:/:rest*:",function(n,t,i){t===void 0&&(t="muscle"),i===void 0&&(i=null),requireModule("anatomy",function(r){n.setController("anatomy_anatomy","Anatomy.Anatomy",function(){return new r.Anatomy(n)},t,i)})}),addRoute("movements/:rest*:",function(n,t){requireModule("anatomy",function(i){n.setController("anatomy_movements","Anatomy.Movements",function(){return new i.Movements(n)},t)})}),addRoute("muscles/:id:/:rest*:",function(n,t,i){requireModule("anatomy",function(r){n.setController("anatomy_muscles","Anatomy.Muscles",function(){return new r.Muscles(n)},t,i)})}),addRoute("muscle/:id:",function(n,t){requireModule("anatomy",function(i){n.setController("anatomy_muscle","Anatomy.Muscle",function(){return new i.Muscle(n)},t)})}),addRoute("muscle2/:id:",function(n,t){requireModule("anatomy",function(i){n.setController("anatomy_muscle","Anatomy.Muscle",function(){return new i.Muscle(n)},t,!0)})}),addRoute("movement/:id:",function(n,t){requireModule("anatomy",function(i){n.setController("anatomy_movement","Anatomy.Movement",function(){return new i.Movement(n)},t)})})}n.registerRoutes=t}(AnatomyController||(AnatomyController={})),function(n){function t(){addRoute("exerciseLibrary",function(n,t){requireModule("exercises",function(i){n.setController("exercises_exerciseLibrary","Exercises.ExerciseLibrary",function(){return new i.ExerciseLibrary(n)},t)})}),addRoute("exercises/:rest*:",function(n){requireModule("exercises",function(t){window.home&&window.home.exercises?n.setController("exercises_search2","Exercises.Exercises",function(){return window.home.exercises}):n.setController("exercises_search2","Exercises.Exercises",function(){return new t.Exercises(n)})})}),addRoute("exercise/:id:",function(n,t){requireModule("exercises",function(i){n.setController("exercises_exercise","Exercises.Exercise",function(){return new i.Exercise(n)},t)})})}n.registerRoutes=t}(ExerciseController||(ExerciseController={})),function(n){function t(){addRoute("logon",function(n){requireModule("home",function(t){n.setController("home_logon","Home.Logon",function(){return new t.Logon(n)})})}),addRoute("home/:rest*:",function(n,t){requireModule("home",function(i){var r;window.location.href.indexOf("dashboard.visualcoaching")!=-1?(r="home_dashboardHome",t="dashboard",n.setController(r,"Home.HomeDashboard",function(){return new i.HomeDashboard(n)},!0,t)):(r="home_home",n.setController(r,"Home.Home",function(){return new i.Home(n)},!1,t))})}),addRoute("teamDiary",function(n){requireModule("home",function(t){n.setController("home_teams","Home.Teams",function(){return new t.Teams(n)})})}),addRoute("feed/:id:",function(n,t){requireModule("home",function(i){n.setController("home_feed","Home.Feed",function(){return new i.Feed(n)},t)})}),addRoute("today",function(n){requireModule("home",function(t){n.setController("home_today","Home.Today",function(){return new t.Today(n)})})}),addRoute("options",function(n){requireModule("home",function(t){n.setController("home_options","Home.Options",function(){return new t.Options(n)})})}),addRoute("signup",function(n){requireModule("signup",function(t){n.setController("signup_signup","Signup.Signup",function(){return new t.Signup(n)})})})}n.registerRoutes=t}(HomeController||(HomeController={})),function(n){function t(){addRoute("forms",function(n){requireModule("forms",function(t){n.setController("forms_forms","Forms.Forms",function(){return new t.Forms(n,!1,null,null,!1,!1,!1,!1)})})}),addRoute("forms?new={id}&selectedDate={date}&selectedUser={userId}",function(n,t,i,r){requireModule("forms",function(u){n.setController("forms_forms","Forms.Forms",function(){return new u.Forms(n,!1,i,r)},t)})}),addRoute("snap2/test",function(n){requireModule("forms",function(t){n.setController("forms_forms","Forms.Forms",function(){return new t.Forms(n,!0)},null,"snap")})}),addRoute("form?new={id}&date={date}&userId={userId}&return={rt}&createNew={cn}",function(n,t,i,r,u,f){requireModule("forms",function(e){n.setController("forms_form2","Forms.Form_"+t+"_"+i+"_"+r,function(){return new e.Form(n,!0)},null,t,i,r,!1,!0,decodeURIComponent(u),null,{},f)})}),addRoute("form?get={id}&date={date}&userId={userId}&return={rt}",function(n,t,i,r,u){requireModule("forms",function(f){n.setController("forms_form2","Forms.Form_"+t+"_"+i+"_"+r,function(){return new f.Form(n,!1,i,r)},t,null,null,null,!1,!0,decodeURIComponent(u))})}),addRoute("form?new={id}&date={date}&userId={userId}&return={rt}",function(n,t,i,r,u){requireModule("forms",function(f){n.setController("forms_form2","Forms.Form_"+t+"_"+i+"_"+r,function(){return new f.Form(n,!0)},null,t,i,r,!1,!0,decodeURIComponent(u))})}),addRoute("form?new={id}&date={date}&userId={userId}",function(n,t,i,r){requireModule("forms",function(u){n.setController("forms_form2","Forms.Form_"+t+"_"+i+"_"+r,function(){return new u.Form(n,!0)},null,t,i,r,!1,!0)})}),addRoute("form/view/{id}",function(n,t,i,r){requireModule("forms",function(u){n.setController("forms_form2","Forms.Form_"+t+"_"+i+"_"+r,function(){return new u.Form(n,!0)},null,t,null,null,!1,!1)})}),addRoute("formsList",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_formsList","Forms.FormsList",function(){return new t.FormsList(n)})})}),addRoute("diaryFormsList",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_formsList","Forms.DiaryFormsList",function(){return new t.FormsList(n,!1,"diary")})})}),addRoute("formsList/load",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_formsList","Forms.FormsList",function(){return new t.FormsList(n,!0)})})}),addRoute("templates/diary",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesDiary",function(){return new t.Templates(n,"diary")})})}),addRoute("templates/newDiary",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesNewDiary",function(){return new t.Templates(n,"diary",!1,!1,!0)})})}),addRoute("templates/diaryEditView",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesDiaryEditView",function(){return new t.Templates(n,"diary",!1,!0)})})});var n=0;addRoute("templates/testing/edit2",function(t){requireModule("forms_setup",function(i){t.setController("forms_setup_templates","FormsSetup.TemplatesTesting"+n++,function(){return new i.Templates(t,"testing",!1,!1,!1,!0)})})}),addRoute("batteryTemplate/new",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTestingNew",function(){return new t.Templates(n,"testing",!1,!1,!0,!0)})})}),addRoute("templates/testing/editView",function(t){requireModule("forms_setup",function(i){t.setController("forms_setup_templates","FormsSetup.TemplatesTestingEditView"+n++,function(){return new i.Templates(t,"testing",!1,!0)})})}),addRoute("templates/battery/edit",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTestingBattery",function(){return new t.Templates(n,"battery")})})}),addRoute("templates/testing/view",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTestingView",function(){return new t.Templates(n,"testing",!0)})})}),addRoute("templates/battery/view",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTestingBatteryView",function(){return new t.Templates(n,"battery",!0)})})}),addRoute("template/edit/:id:",function(n,t){requireModule("forms_setup",function(i){n.setController("forms_setup_template","FormsSetup.TemplateDiary",function(){return new i.Template(n,"diary")},t)})}),addRoute("testingTemplate/edit/:id:",function(n,t){requireModule("forms_setup",function(i){n.setController("forms_setup_template","FormsSetup.TemplateTesting",function(){return new i.Template(n,"testing")},t)})}),addRoute("testingTemplate/view/:id:",function(n,t){requireModule("forms",function(i){n.setController("forms_forms","FormsSetup.TemplateTesting",function(){return new i.Forms(n)},t,"templates/testing/view")})}),addRoute("batteryTemplate/edit/:id:",function(n,t){requireModule("forms_setup",function(i){n.setController("forms_setup_template","FormsSetup.TemplateBattery",function(){return new i.Template(n,"battery")},t)})}),addRoute("batteryTemplate/view/:id:",function(n,t){requireModule("forms",function(i){n.setController("forms_forms","FormsSetup.TemplateBattery",function(){return new i.Forms(n)},t,"templates/battery/view")})}),addRoute("form/{id}?return={rt}",function(n,t,i){requireModule("forms",function(r){n.setController("forms_form","Forms.Form3_"+t,function(){return new r.Form(n,!0)},t,null,null,null,!1,!1,decodeURIComponent(i))})}),addRoute("form/{id}",function(n,t){requireModule("forms",function(i){n.setController("forms_form","Forms.Form_"+t,function(){return new i.Form(n,!0)},t)})}),addRoute("templates/resource/tutorials",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTutorial",function(){return new t.Templates(n,"tutorials",!1,!0)})})}),addRoute("templates/resource/edit",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesResource",function(){return new t.Templates(n,"resource")})})}),addRoute("templates/resource/editNew",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesResourceCreateNew",function(){return new t.Templates(n,"resource",!1,!1,!0)})})}),addRoute("templates/resource/editView",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesResourceEditView",function(){return new t.Templates(n,"resource",!1,!0)})})}),addRoute("resourceTemplate/edit/:id:",function(n,t){requireModule("forms_setup",function(i){n.setController("forms_setup_template","FormsSetup.TemplateResource",function(){return new i.Template(n,"resource")},t)})}),addRoute("resourceTemplate/view/:id:",function(n,t){requireModule("forms",function(i){n.setController("forms_forms","Forms.formResource",function(){return new i.Forms(n)},t,"templates/testing/view")})})}n.registerRoutes=t}(FormsController||(FormsController={})),function(n){function t(){addRoute("clients",function(n){requireModule("clients",function(t){n.setController("clients_clientManager","Clients.ClientManager",function(){return new t.ClientManager(n)})})})}n.registerRoutes=t}(ClientsController||(ClientsController={})),function(n){function t(){addRoute("accounts/:page:",function(n,t){requireModule("accounts",function(i){n.setController("accounts_accounts","Accounts",function(){return new i.Accounts(n)},t)})}),addRoute("profile/cloud",function(n){requireModule("accounts",function(t){n.setController("accounts_profile","Profile",function(){return new t.Profile(n,!1)})})})}n.registerRoutes=t}(AccountsController||(AccountsController={})),function(n){function t(){addRoute("analysis",function(n){requireModule("analysis",function(t){n.setController("analysis_analysis","Analysis",function(){return new t.Analysis(n)})})});var n=0;addRoute("dashboardTemplatesShare",function(t){requireModule("forms_setup",function(i){t.setController("forms_setup_templates","dashboardTemplatesShare"+n++,function(){return new i.Templates(t,"dashboard")})})}),addRoute("dashboardTemplatesEdit",function(t){requireModule("forms_setup",function(i){t.setController("forms_setup_templates","dashboardTemplatesEdit"+n++,function(){return new i.Templates(t,"dashboard")})})}),addRoute("dashboardTemplate/edit",function(t){requireModule("analysis",function(i){t.setController("analysis_template","AnalysisTemplate"+n++,function(){return new i.Template(t)})})}),addRoute("dashboardTemplate/edit?ids={ids}",function(t,i){requireModule("analysis",function(r){t.setController("analysis_template","AnalysisTemplate"+n++,function(){return new r.Template(t)},null,i)})}),addRoute("dashboardTemplate/edit?fids={ids}",function(t,i){requireModule("analysis",function(r){t.setController("analysis_template","AnalysisTemplate"+n++,function(){return new r.Template(t)},null,decodeURIComponent(i),!0)})}),addRoute("dashboardTemplate/edit/{id}",function(t,i){requireModule("analysis",function(r){t.setController("analysis_template","AnalysisTemplate"+n++,function(){return new r.Template(t)},i)})}),addRoute("dashboard/:templateId:/:userId:",function(n,t,i){requireModule("analysis",function(r){n.setController("analysis_dashboard","Dashboard",function(){return new r.Dashboard(n)},i,t)})})}n.registerRoutes=t}(AnalysisController||(AnalysisController={})),function(n){function t(){addRoute("teams",function(n){requireModule("teams",function(t){n.setController("teams_teams","Teams.Teams",function(){return new t.Teams(n)})})}),addRoute("team/:id:",function(n,t){requireModule("teams",function(i){n.setController("teams_team","Teams.Team",function(){return new i.Team(n)},t)})})}n.registerRoutes=t}(TeamsController||(TeamsController={})),function(n){function t(){addRoute("rmSetup",function(n){requireModule("rm",function(t){n.setController("rm_rmBuilder","Rm.RepMaxBuilder",function(){return new t.RepMaxBuilder(n)})})})}n.registerRoutes=t}(RmController||(RmController={})),function(n){function t(){addRoute("rules",function(n){requireModule("rules",function(t){n.setController("rules_rules","Rules",function(){return new t.Rules(n)})})}),addRoute("rules_compliance",function(n){requireModule("rules",function(t){n.setController("rules_rules","RulesCompliance",function(){return new t.Rules(n,1)})})}),addRoute("rules_not_compliance",function(n){requireModule("rules",function(t){n.setController("rules_rules","RulesNotCompliance",function(){return new t.Rules(n,2)})})})}n.registerRoutes=t}(RulesController||(RulesController={})),function(n){function t(){var n,t;addRoute("programs",function(n,t){requireModule("programs",function(i){n.setController("programs_programs","Programs",function(){return new i.Programs(n,null)},t)})}),addRoute("programs2",function(n,t){requireModule("programs",function(i){n.setController("programs_programs2","Programs2",function(){return new i.Programs2(n)},t)})}),n=0,addRoute("program/{id}",function(t,i){requireModule("programs",function(r){t.setController("programs_program","Program"+n,function(){return new r.Program(t)},i),n++})}),addRoute("templateBuilder/save",function(n){requireModule("programs",function(t){n.setController("programs_templateBuilder","templateBuilder",function(){return new t.Program(n)},"templateBuilder"+window.templateId)})}),window.templateId=0,addRoute("templateBuilder/create",function(n){requireModule("programs",function(t){n.setController("programs_templateBuilder","templateBuilder"+window.templateId,function(){return new t.Program(n,!1,!0)},"templateBuilder"+window.templateId)})}),addRoute("templateBuilder/create?date={date}&user={user}&type={type}",function(n,t,i,r){requireModule("programs",function(u){n.setController("programs_templateBuilder","templateBuilder"+window.templateId,function(){return new u.Program(n,!1,!0)},"templateBuilder"+window.templateId,decodeURIComponent(t),decodeURIComponent(i),r)})}),addRoute("print/{id}",function(t,i){requireModule("programs",function(r){t.setController("programs_print","Program"+n,function(){return new r.Print},i),n++})}),addRoute("programSelector",function(n){requireModule("programs",function(t){n.setController("programs_programSelector","ProgramSelector",function(){return new t.ProgramSelector(n)})})}),t=0,addRoute("planner/{id}",function(n,i){requireModule("planner",function(r){n.setController("planner_planner","Planner"+t,function(){return new r.Planner(n,null)},i),t++})}),addRoute("planner",function(n){requireModule("planner",function(i){n.setController("planner_planner","Planner"+t,function(){return new i.Planner(n,null)},null),t++})}),addRoute("plannerSetup",function(n){requireModule("planner",function(t){n.setController("planner_plannerSetup","PlannerSetup",function(){return new t.PlannerSetup(n,null)})})})}n.registerRoutes=t}(ProgramsController||(ProgramsController={})),function(n){function t(){addRoute("unitConversion",function(n){requireModule("toolbox",function(t){n.setController("toolbox_unitConversion","Toolbox.UnitConversion",function(){return new t.UnitConversion(n)})})}),addRoute("bmi",function(n){requireModule("toolbox",function(t){n.setController("toolbox_bmi","Toolbox.Bmi",function(){return new t.Bmi(n)})})}),addRoute("whr",function(n){requireModule("toolbox",function(t){n.setController("toolbox_whr","Toolbox.Whr",function(){return new t.Whr(n)})})}),addRoute("rm",function(n){requireModule("toolbox",function(t){n.setController("toolbox_rm","Toolbox.RM",function(){return new t.RM(n)})})}),addRoute("paceCalculator",function(n){requireModule("toolbox",function(t){n.setController("toolbox_paceCalculator","Toolbox.PaceCalculator",function(){return new t.PaceCalculator(n)})})}),addRoute("hrCalculator",function(n){requireModule("toolbox",function(t){n.setController("toolbox_hrCalculator","Toolbox.hrCalculator",function(){return new t.hrCalculator(n)})})}),addRoute("paceTable/{myType}",function(n,t){requireModule("toolbox",function(i){n.setController("toolbox_paceTable","Toolbox.PaceTable",function(){return new i.PaceTable(n)},t)})}),addRoute("energySystem",function(n){requireModule("interplay",function(t){n.setController("interplay_energySystem","Interplay.EnergySystem",function(){return new t.EnergySystem(n)})})})}n.registerRoutes=t}(ToolboxController||(ToolboxController={})),function(n){function t(){addRoute("customExercise/{userAction}",function(n,t){requireModule("customExercise",function(i){n.setController("customExercise_exerciseEditor","ExerciseEditor_"+t,function(){return new i.ExerciseEditor(n,t)})})})}n.registerRoutes=t}(CustomExerciseController||(CustomExerciseController={})),function(n){function t(){addRoute("indexPage",function(n){requireModule("indexPage",function(t){n.setController("indexPage_indexPage","IndexPage.indexPage",function(){return new t.IndexPage(n)})})})}n.registerRoutes=t}(IndexPageController||(IndexPageController={})),function(n){function t(){var i,n,t;window.phoneRefresh=function(){i&&i.refresh&&i.refresh(),n&&n.refresh&&n.refresh()},addRoute("phonesupport",function(n){requireModule("phone",function(t){n.setController("phone_supportWrapper","Phone.SupportWrapper",function(){return new t.SupportWrapper})})}),addRoute("phone/dash",function(n){requireModule("analysis",function(t){notClient()?n.setController("analysis_dashboard","Dashboard",function(){return new t.Dashboard(n)},null,null,!0,!0,"phone"):n.setController("analysis_dashboard","Dashboard",function(){return new t.Dashboard(n)},main.userId,null,!0,!0,"phone")})}),addRoute("phone/resources/:rest*:",function(n,t){requireModule("phone",function(i){n.setController("phone_resourcesWrapper","Phone.Resources",function(){return new i.PhoneWrapper(n,"phone/resources/")},t||"templates/resource/edit")})}),addRoute("phone/options/:rest*:",function(n){requireModule("phone",function(t){n.setController("phone_resourcesWrapper","Phone.Resources",function(){return new t.PhoneWrapper(n,"phone/options/")},"options")})}),addRoute("phone/PhoneWrapperV2",function(n){requireModule("phone",function(t){n.setController("phone_phoneWrapper","Phone.PhoneWrapper",function(){return new t.PhoneWrapperV2(n)})})}),addRoute("phone/v2/snap",function(n){requireModule("phone",function(t){n.setController("phone_phoneWrapper","Phone.PhoneWrapper",function(){return new t.PhoneWrapperV2(n,!0)})})}),addRoute("phone/v2/snap/home",function(n){requireModule("phone",function(t){n.setController("phone_phoneHome","Phone.PhoneHome",function(){return new t.PhoneHome(n,!0)})})}),addRoute("phone/v2/home",function(n){requireModule("phone",function(t){n.setController("phone_phoneHome","Phone.PhoneHome",function(){return new t.PhoneHome(n)})})}),addRoute("phone/v2/coachHome/:rest*:",function(n,t){requireModule("phone",function(i){n.setController("phone_coachHome","Phone.CoachHome",function(){return new i.UserHome(n,{role:"coach"})},t)})}),addRoute("phone/v2/workboxSession/:pid:/:w:/:d:/:s:/:i:",function(n,t,i,r,u,f){requireModule("phone",function(e){n.setController("phone_sessionDetail","Phone.SessionDetail",function(){return new e.Session(n)},t,i,r,u,f,null,null)})}),addRoute("phone/v2/resSession/:pid:/:w:/:d:/:s:/:i:/:date:/:dateIndex:/:isPreview:/:previewType:",function(n,t,i,r,u,f,e,o,s,h){requireModule("phone",function(c){n.setController("phone_sessionDetail","Phone.SessionDetail",function(){return new c.Session(n,!1)},t,i,r,u,f,e,o,s,h)})}),addRoute("phone/v2/textSession/:pid:/:w:/:d:/:s:/:i:/:date:",function(n,t,i,r,u,f,e){requireModule("phone",function(o){n.setController("phone_tabletTextSession","Phone.TabletTextSession",function(){return new o.TabletTextSession(n,!1)},t,i,r,u,f,e)})}),t=0,addRoute("vcpResSession/:pid:/:w:/:d:/:s:/:i:/:date:/:dateIndex:/:isPreview:/:previewType:",function(n,i,r,u,f,e,o,s,h,c){requireModule("phone",function(l){n.setController("phone_sessionDetail","Phone.SessionDetail"+t,function(){return new l.Session(n,!0)},i,r,u,f,e,o,s,h,c),t++})}),addRoute("vcpTextSession/:pid:/:w:/:d:/:s:/:i:/:date:",function(n,i,r,u,f,e,o){requireModule("phone",function(s){n.setController("phone_tabletTextSession","Phone.TabletTextSession"+t,function(){return new s.TabletTextSession(n,!0)},i,r,u,f,e,o),t++})}),addRoute("phone/v2/history/:p:/:w:/:d:/:s:/:i:/:e:/:eName:/:unitB:",function(n,t,i,r,u,f,e,o,s){requireModule("phone",function(h){n.setController("phone_history","Phone.History",function(){return new h.History(n)},t,i,r,u,f,e,o,s)})}),addRoute("phone/v2/wellness?uid={userId}&wid={wid}&date={date}&return={returnUrl}",function(n,t,i,r,u){requireModule("forms",function(f){n.setController("forms_form2Wrapper","Forms.Form_"+i+"_"+r+"_"+t,function(){return new f.Form(n,!0)},null,i,r,t+"&programKey=999:999:999:999:999",!1,!0,u)})}),addRoute("phone/v2/form?new={id}&date={date}&userId={userId}&return={rt}&createNew={cn}",function(n,t,i,r,u,f){requireModule("forms",function(e){n.setController("forms_form2Wrapper","Forms.Form_"+t+"_"+i+"_"+r,function(){return new e.Form(n,!0)},null,t,i,r,!1,!0,decodeURIComponent(u),null,{},f)})}),addRoute("phone/v2/form?get={id}&date={date}&userId={userId}&return={rt}",function(n,t,i,r,u){requireModule("forms",function(f){n.setController("forms_form2Wrapper","Forms.Form_"+t+"_"+i+"_"+r,function(){return new f.Form(n,!1,i,r)},t,null,null,null,!1,!0,decodeURIComponent(u))})}),addRoute("phone/v2/form?new={id}&date={date}&userId={userId}&return={rt}",function(n,t,i,r,u){requireModule("forms",function(f){n.setController("forms_form2Wrapper","Forms.Form_"+t+"_"+i+"_"+r,function(){return new f.Form(n,!0)},null,t,i,r,!1,!0,decodeURIComponent(u))})}),addRoute("phone/v2/form?new={id}&date={date}&userId={userId}",function(n,t,i,r){requireModule("forms",function(u){n.setController("forms_form2Wrapper","Forms.Form_"+t+"_"+i+"_"+r,function(){return new u.Form(n,!0)},null,t,i,r,!1,!0)})}),addRoute("phone/v2/clientHome/:rest*:",function(n,t){requireModule("phone",function(i){n.setController("phone_clientHome","Phone.ClientHome",function(){return new i.UserHome(n,{role:"client"})},t)})}),addRoute("phone/v2/snap/addToCalendar/:clientEmail:/:addedType:/:pid:",function(n,t,i,r){requireModule("phone",function(u){n.setController("phone_clientHome","Phone.ClientHome",function(){return new u.UserHome(n,{role:"client"})},null,!0,t,i,r)})}),addRoute("phone/v2/dashboard/:userId:",function(n,t){requireModule("phone",function(i){n.setController("phone_wrapper","Phone.Wrapper",function(){return new i.Wrapper(n,"")},"phonedashboard/"+(t||""))})}),addRoute("phonedashboard/:userId:",function(n,t){requireModule("analysis",function(i){n.setController("analysis_dashboard","Dashboard",function(){return new i.Dashboard(n)},t,null,!0,!1,"phone",!0)})}),addRoute("phone/v2/snap/dashboard/:userId:",function(n,t){requireModule("analysis",function(i){n.setController("analysis_dashboard","Dashboard",function(){return new i.Dashboard(n)},t,null,!0,!1,"phone/v2/snap",!0)})}),addRoute("phone/v2/resource",function(n){requireModule("phone",function(t){n.setController("phone_wrapper","Phone.Wrapper",function(){return new t.Wrapper(n,"")},"phoneresource")})}),addRoute("phone/v2/tutorials",function(n){requireModule("phone",function(t){n.setController("phone_wrapper","Phone.Wrapper",function(){return new t.Wrapper(n,"")},"phonetutorials")})}),addRoute("phone/v2/test",function(n){requireModule("phone",function(t){n.setController("phone_wrapper","Phone.Wrapper",function(){return new t.Wrapper(n,"")},"phonetest")})}),addRoute("phoneresource",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTesting",function(){return new t.Templates(n,"resource",!0,!0)},!0)})}),addRoute("phone/v2/snap/resource",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTesting",function(){return new t.Templates(n,"resource")},!0)})}),addRoute("phone/v2/snap/tutorial",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTesting",function(){return new t.Templates(n,"tutorials")},!0)})}),addRoute("phonetutorials",function(n){requireModule("forms_setup",function(t){n.setController("forms_setup_templates","FormsSetup.TemplatesTesting",function(){return new t.Templates(n,"tutorials",!0,!0)},!0)})}),addRoute("phonetest",function(n){requireModule("forms",function(t){n.setController("forms_forms","Forms.Forms",function(){return new t.Forms(n)},null,"phone")})}),addRoute("phone/v2/test/view/{id}",function(n,t){requireModule("forms",function(i){n.setController("forms_forms","FormsSetup.TemplateTesting",function(){return new i.Forms(n)},t,"phone")})}),addRoute("phone/v2/options",function(n){requireModule("home",function(t){n.setController("home_options","Home.Options",function(){return new t.Options(n,!0)})})}),addRoute("phone/v2/profile",function(n){requireModule("accounts",function(t){n.setController("accounts_profile","Profile",function(){return new t.Profile(n,!0)})})}),addRoute("phone/TabletWrapperV2",function(n){requireModule("phone",function(t){n.setController("phone_tabletWrapper","Phone.TabletWrapper",function(){return new t.TabletWrapperV2(n)})})}),addRoute("phone/:rest*:",function(n,t){requireModule("phone",function(i){window.innerWidth>=640&&window.innerHeight>=480?n.setController("phone_tabletWrapper","Phone.TabletWrapper",function(){return new i.TabletWrapperV2(n)},t):n.setController("phone_phoneWrapper","Phone.PhoneWrapper",function(){return new i.PhoneWrapperV2(n)},t)})}),addRoute("pphone/:rest*:",function(n,t){requireModule("phone",function(i){n.setController("phone_phone","Phone.Phone",function(){return new i.PhoneWrapper(n,"pphone/")},t)})}),addRoute("pprogram/:rest*:",function(t,i){requireModule("phone",function(r){t.setController("phone_program","Phone.Program",function(){return n?n:n=new r.Program(t)},i)})})}n.registerRoutes=t}(PhoneController||(PhoneController={})),function(n){function t(){var n,t;addRoute("snap2/dash",function(n){requireModule("analysis",function(t){n.setController("analysis_dashboard","Dashboard",function(){return new t.Dashboard(n)},main.userId,2615,!0,!0)})}),addRoute("snap2/profile",function(n){requireModule("snap2",function(t){n.setController("snap2_profile","Snap2.Profile",function(){return new t.Profile(n)})})}),addRoute("snap2/wellness?wid={wid}&date={date}&return={returnUrl}",function(n,t,i,r){requireModule("forms",function(u){n.setController("forms_form2","Forms.Form_"+t+"_"+i+"_"+main.userId,function(){return new u.Form(n,!0)},null,t,i,main.userId+"&programKey=999:999:999:999:999",!1,!0,r)})}),addRoute("snap2/test",function(n){requireModule("forms",function(t){n.setController("forms_forms","Forms.Forms",function(){return new t.Forms(n,!0)},null,"snap")})}),addRoute("snap2/workout/search",function(n){requireModule("snap2",function(t){n.setController("snap2_programSearch","Snap2.ProgramSearch",function(){return new t.ProgramSearch(n,"Workout")})})}),addRoute("snap2/exercise/search",function(n){requireModule("snap2",function(t){n.setController("snap2_exerciseSearch","Snap2.ExerciseSearch",function(){return new t.ExerciseSearch(n)})})}),addRoute("snap2/program/search",function(n){requireModule("snap2",function(t){n.setController("snap2_programSearch","Snap2.ProgramSearch",function(){return new t.ProgramSearch(n,"Program")})})}),addRoute("snap2/favourite",function(n){requireModule("snap2",function(t){n.setController("snap2_programSearch","Snap2.ProgramSearch",function(){return new t.ProgramSearch(n,"Program")},!0)})}),addRoute("snap2/program/overview/prog={id}&return={returnUrl}",function(n,t,i){requireModule("snap2",function(r){n.setController("snap2_programOverview","Snap2.ProgramOverview",function(){return new r.ProgramOverview(n,"Program")},t,i,!0)})}),addRoute("snap2/workout/overview/prog={id}&return={returnUrl}&visible={visible}",function(n,t,i,r){requireModule("snap2",function(u){n.setController("snap2_programOverview","Snap2.ProgramOverview",function(){return new u.ProgramOverview(n,"Workout")},t,i,r)})}),addRoute("snap2/workout/detail/:rest*:",function(n,t){requireModule("snap2",function(i){n.setController("snap2_session","Snap2.programDetail",function(){return new i.ProgramDetail(n,"Workout")},t)})}),addRoute("snap2/session/detail/:rest*:",function(n,t){requireModule("snap2",function(i){n.setController("snap2_session","Snap2.programDetail",function(){return new i.ProgramDetail(n,"WeeklySession")},t)})}),addRoute("snap2/program/detail/:rest*:",function(n,t){requireModule("snap2",function(i){n.setController("snap2_session","Snap2.programDetail",function(){return new i.ProgramDetail(n,"Program")},t)})}),addRoute("snap2/program/preview/prog={id}&return={returnUrl}",function(n,t,i){requireModule("snap2",function(r){n.setController("snap2_programPreview","Snap2.programPreview",function(){return new r.ProgramPreview(n)},t,i)})}),addRoute("snap2/calendar/program/setup/:rest*:",function(n,t){requireModule("snap2",function(i){n.setController("snap2_calendar","Snap2.calendar",function(){return new i.SnapCalendar(n,"program")},t)})}),addRoute("snap2/calendar/:rest*:",function(n,t){requireModule("snap2",function(i){n.setController("snap2_calendar","Snap2.calendar",function(){return new i.SnapCalendar(n,"program")},t)})}),addRoute("snap2/wellness/calendar/wid={wid}&date={date}&return={returnUrl}",function(n,t,i,r){requireModule("snap2",function(u){n.setController("snap2_calendar","Snap2.calendar",function(){return new u.SnapCalendar(n,"wellness")},[t,i,r])})}),addRoute("s2phone/:rest*:",function(n,t){requireModule("snap2",function(i){n.setController("snap2_phone","Snap2.Phone",function(){return new i.PhoneWrapper(n)},t)})}),addRoute("snap2/creator",function(n){requireModule("snapCreator",function(t){n.setController("snapCreator_home","SnapCreator.Home",function(){return new t.Home(n)})})}),addRoute("snap2/exercise/creator",function(n){requireModule("snapCreator",function(t){n.setController("snapCreator_setupExercises","SnapCreator.SetupExercises",function(){return new t.SetupExercises(n)})})}),addRoute("snap2",function(n){requireModule("snap2",function(t){n.setController("snap2_home","Snap2.Home",function(){return new t.TabletWrapper(n)})})}),addRoute("snap/:rest*:",function(t,i){requireModule("snap",function(r){window.innerWidth>=640&&window.innerHeight>=480?t.setController("snap_tablet","Snap.Tablet",function(){return new r.TabletWrapper(t)},i):t.setController("snap_programs","Snap.Programs",function(){return n?n:n=new r.Programs(t)})})}),addRoute("sphone/:rest*:",function(n,t){requireModule("snap",function(i){n.setController("snap_phone","Snap.Phone",function(){return new i.PhoneWrapper(n)},t)})}),addRoute("sdash/:rest*:",function(n,t){requireModule("snap",function(i){n.setController("snap_dash","Snap.Phone",function(){return new i.PhoneWrapper(n)},t)})}),addRoute("sprogram/:id:",function(n,i){requireModule("snap",function(r){n.setController("snap_program","Snap.Program",function(){return t?t:t=new r.Program(n)},i)})})}n.registerRoutes=t}(SnapController||(SnapController={})),function(n){function t(n,t,i,r,u,f,e,o,s,h){return{type:"Gauge",showGauge:ko.observable(o),maxValue:ko.observable(s),showAsDecimal:ko.observable(h),name:ko.observable(null),label:ko.observable(n),leftLabel:ko.observable(t),rightLabel:ko.observable(i),metrics:ko.observableArray(_.map(r,function(n){return{item:ko.observable(n.item),ratio:ko.observable(n.ratio),lowerIsWorse:ko.observable(n.lowerIsWorse)}})),range:ko.observable(u),startRange:ko.observable(f),sections:ko.observableArray(_.map(e,function(n){return{min:ko.observable(n.min),max:ko.observable(n.max),color:ko.observable(n.color),label:ko.observable(n.label)}}))}}function i(){var i=[n.labelField(),n.booleanField("showGauge","Show Gauge",""),n.booleanField("showAsDecimal","Show as Decimal",""),n.numberField("maxValue","Max Value","","",!0,[]),n.text("leftLabel","Left Label","","",!1,!1),n.text("rightLabel","Right Label","","",!1,!1)];return i=i.concat([{type:"GaugeList",name:"metrics",label:"Gauge Fields",add:function(n){return n.push({item:ko.observable(""),ratio:ko.observable(1),lowerIsWorse:ko.observable(!1)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}]),i=i.concat([{type:"GaugeSectionsList",name:"sections",label:"Sections (optional)",add:function(n){return n.push({min:ko.observable(null),max:ko.observable(null),color:ko.observable(null),label:ko.observable(null)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}]),{type:"Gauge",designTemplate:"DesignGauge",title:"Gauge",properties:i,createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"",n.leftLabel||"",n.rightLabel||"",n.metrics||[],n.range||0,n.startRange||0,n.sections||[],_.isBoolean(n.showGauge)?n.showGauge:!0,n.maxValue||10,n.showAsDecimal||!1)}}}n.gaugeTemplate=i}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f,e,o,s,h,c){return{type:"TestGauge",test:ko.observable(n),name:ko.observable(null),label:ko.observable(t),leftLabel:ko.observable(i),rightLabel:ko.observable(r),metrics:ko.observableArray(_.map(u,function(n){return{item:ko.observable(n.item),ratio:ko.observable(n.ratio),lowerIsWorse:ko.observable(n.lowerIsWorse)}})),range:ko.observable(f),startRange:ko.observable(e),sections:ko.observableArray(_.map(o,function(n){return{min:ko.observable(n.min),max:ko.observable(n.max),color:ko.observable(n.color),label:ko.observable(n.label)}})),showGauge:ko.observable(s),maxValue:ko.observable(h),displayNotes:ko.observable(c)}}function i(){var i=[{type:"SelectTest",name:"test",label:"Select Test"},n.labelField(),n.booleanField("showGauge","Show Gauge","",!1),n.numberField("maxValue","Max Value","","",!0,[],!1),n.text("leftLabel","Left Label","","",!1,!1,!1),n.text("rightLabel","Right Label","","",!1,!1,!1)];return(isBeta||isSis)&&(i=i.concat([{type:"GaugeList",name:"metrics",label:"Gauge Fields",add:function(n){return n.push({item:ko.observable(""),ratio:ko.observable(1),lowerIsWorse:ko.observable(!1)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}])),i=i.concat([n.numberField("range","Number of days","","Number of days",!0,[{id:1,label:"days",conversion:1}],!1),n.numberField("startRange","Start days ago","","Start days ago",!0,[{id:1,label:"days",conversion:1}],!1),{type:"GaugeSectionsList",name:"sections",label:"Sections (optional)",add:function(n){return n.push({min:ko.observable(null),max:ko.observable(null),color:ko.observable(null),label:ko.observable(null)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}]),{type:"TestGauge",designTemplate:"DesignTestGauge",title:"Test Gauge",properties:i,createDesignField:function(n){return n===void 0&&(n={}),t(n.test,n.label||"",n.leftLabel||"",n.rightLabel||"",n.metrics||[],n.range||0,n.startRange||0,n.sections||[],n.showGauge||!1,n.maxValue||10,n.displayNotes||!1)}}}n.testGaugeTemplate=i}(Fields||(Fields={})),function(n){function u(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt){return{type:"Chart",name:null,range:t,groupBy:i,label:n,leftYLabel:f,rightYLabel:e,leftMin0:o,leftMinOverride:s,rightMin0:h,rightMinOverride:c,leftMax0:b,leftMaxOverride:k,rightMax0:d,rightMaxOverride:g,left:r,right:u,leftShading:l,rightShading:a,leftAxisType:v,rightAxisType:y,leftMultiplier:p,rightMultiplier:w,exerciseId:nt,displayNotes:tt}}function t(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt){return{type:"Chart",name:ko.observable(null),range:ko.observable(t),groupBy:ko.observable(i),label:ko.observable(n),leftYLabel:ko.observable(f),rightYLabel:ko.observable(e),leftMin0:ko.observable(o),leftMinOverride:ko.observable(s),rightMin0:ko.observable(h),rightMinOverride:ko.observable(c),leftMax0:ko.observable(b),leftMaxOverride:ko.observable(k),rightMax0:ko.observable(d),rightMaxOverride:ko.observable(g),left:ko.observableArray(_.map(r,function(n){return{item:ko.observable(n.item),type:ko.observable(n.type),operation:ko.observable(n.operation),legend:ko.observable(n.legend)}})),right:ko.observableArray(_.map(u,function(n){return{item:ko.observable(n.item),type:ko.observable(n.type),operation:ko.observable(n.operation),legend:ko.observable(n.legend)}})),leftShading:ko.observableArray(_.map(l,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),rightShading:ko.observableArray(_.map(a,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),leftAxisType:ko.observable(v),rightAxisType:ko.observable(y),leftMultiplier:ko.observable(p),rightMultiplier:ko.observable(w),exerciseId:ko.observable(nt),displayNotes:ko.observable(tt)}}function f(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt){return{type:"ChartResistance",name:ko.observable(null),range:ko.observable(t),groupBy:ko.observable(i),label:ko.observable(n),leftYLabel:ko.observable(f),rightYLabel:ko.observable(e),leftMin0:ko.observable(o),leftMinOverride:ko.observable(s),rightMin0:ko.observable(h),rightMinOverride:ko.observable(c),leftMax0:ko.observable(b),leftMaxOverride:ko.observable(k),rightMax0:ko.observable(d),rightMaxOverride:ko.observable(g),left:ko.observableArray(_.map(r,function(n){return{item:ko.observable(n.item),type:ko.observable(n.type),operation:ko.observable(n.operation),legend:ko.observable(n.legend||"")}})),right:ko.observableArray(_.map(u,function(n){return{item:ko.observable(n.item),type:ko.observable(n.type),operation:ko.observable(n.operation),legend:ko.observable(n.legend||"")}})),leftShading:ko.observableArray(_.map(l,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),rightShading:ko.observableArray(_.map(a,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),leftAxisType:ko.observable(v),rightAxisType:ko.observable(y),leftMultiplier:ko.observable(p),rightMultiplier:ko.observable(w),exerciseId:ko.observable(nt),displayNotes:ko.observable(tt)}}function i(t,i){var r=[n.label(i+" Y Axis"),n.text(t+"YLabel",i+" Y Axis Label","",i+" Y Axis Label",!1,!1,!1),n.numberField(t+"Multiplier","Multiplier","","Multiplier",!1,[],!1),n.optionField(t+"AxisType","Axis Type","",["Normal","Other","Time (hours)","Time (minutes)","Time (seconds)","Distance (km)","Distance (m)","Distance (cm)","Distance (mm)","Distance (mi)","Distance (ft)","Distance (in)"],!1,!1),n.numberLinkedWithSwitchField(t+"MinOverride",t+"Min0","Override Min Value","","",!1,[]),n.numberLinkedWithSwitchField(t+"MaxOverride",t+"Max0","Override Max Value","","",!1,[]),{type:"SeriesList",name:t,label:i+" Y Axis Field",add:function(n){return n.push({item:ko.observable(""),type:ko.observable("line"),operation:ko.observable("average"),legend:ko.observable("")})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}];return i==="Left"&&r.push({type:"ShadingList",name:t+"Shading",label:"Y Axis Shading",add:function(n){return n.push({minValue:ko.observable(null),maxValue:ko.observable(null),color:ko.observable(""),label:ko.observable("")})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}),r}function r(t){var r=[n.chartTitleField()];return t&&r.push(n.numberField("exerciseId","Exercise Id","","Exercise Id",!1,[],!1)),r=r.concat(i("left","Left")),r=r.concat(i("right","Right"))}function e(){return{type:"Chart",designTemplate:"DesignChart",title:"Chart",titleSmall:"(Diary Data)",properties:r(!1),createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"",n.range||0,n.groupBy||"Day",n.left||[],n.right||[],n.leftYLabel||"",n.rightYLabel||"",n.leftMin0||!1,n.leftMinOverride||0,n.rightMin0||!1,n.rightMinOverride||0,n.leftShading||[],n.rightShading||[],n.leftAxisType||"Normal",n.rightAxisType||"Normal",n.leftMultiplier||1,n.rightMultiplier||1,n.leftMax0||!1,n.leftMaxOverride||10,n.rightMax0||!1,n.rightMaxOverride||10,n.exerciseId||"",n.displayNotes||!1)}}}function o(){return{type:"ChartResistance",designTemplate:"DesignResistanceChart",title:"Chart",titleSmall:"(Resistance Data)",properties:r(!0),createDesignField:function(n){return n===void 0&&(n={}),f(n.label||"",n.range||0,n.groupBy||"Day",n.left||[],n.right||[],n.leftYLabel||"",n.rightYLabel||"",n.leftMin0||!1,n.leftMinOverride||0,n.rightMin0||!1,n.rightMinOverride||0,n.leftShading||[],n.rightShading||[],n.leftAxisType||"Normal",n.rightAxisType||"Normal",n.leftMultiplier||1,n.rightMultiplier||1,n.leftMax0||!1,n.leftMaxOverride||10,n.rightMax0||!1,n.rightMaxOverride||10,n.exerciseId||"",n.displayNotes||!1)}}}n.chartField=u,n.designChartField=t,n.chartTemplate=e,n.chartResistanceTemplate=o}(Fields||(Fields={})),function(n){function t(){return{type:"LineBreak"}}function i(){return{type:"LineBreak",designTemplate:"DesignLineBreak",title:"Line Break",properties:[n.label("Adds a line break so the next chart displays below.")],createDesignField:function(n){return n===void 0&&(n={}),t()}}}n.lineBreakTemplate=i}(Fields||(Fields={})),function(n){function r(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt){return{type:"TestChart",test:n,name:null,range:i,label:t,leftYLabel:f,rightYLabel:e,leftMin0:o,leftMinOverride:s,rightMin0:h,rightMinOverride:c,leftMax0:b,leftMaxOverride:k,rightMax0:d,rightMaxOverride:g,left:r,right:u,leftShading:l,rightShading:a,leftAxisType:v,rightAxisType:y,leftMultiplier:p,rightMultiplier:w,displayNotes:nt}}function t(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt){var tt=function(n){return ko.observableArray(_.map(n,function(n){return ko.observable(n)}))};return{type:"TestChart",test:ko.observable(n),name:ko.observable(null),range:ko.observable(i),label:ko.observable(t),leftYLabel:ko.observable(f),rightYLabel:ko.observable(e),leftMin0:ko.observable(o),leftMinOverride:ko.observable(s),rightMin0:ko.observable(h),rightMinOverride:ko.observable(c),leftMax0:ko.observable(b),leftMaxOverride:ko.observable(k),rightMax0:ko.observable(d),rightMaxOverride:ko.observable(g),left:ko.observableArray(_.map(r,function(n){return{items:tt(n.items),type:ko.observable(n.type),operation:ko.observable(n.operation)}})),right:ko.observableArray(_.map(u,function(n){return{items:tt(n.items),type:ko.observable(n.type),operation:ko.observable(n.operation)}})),leftShading:ko.observableArray(_.map(l,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),rightShading:ko.observableArray(_.map(a,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),leftAxisType:ko.observable(v),rightAxisType:ko.observable(y),leftMultiplier:ko.observable(p),rightMultiplier:ko.observable(w),displayNotes:ko.observable(nt)}}function i(t,i){var r=[n.label(i+" Y Axis"),n.text(t+"YLabel",i+" Y Axis Label","",i+" Y Axis Label",!1,!1,!1),n.numberField(t+"Multiplier","Multiplier","","Multiplier",!1,[],!1),n.optionField(t+"AxisType","Axis Type","",["Normal","Other","Time (hours)","Time (minutes)","Time (seconds)","Distance (km)","Distance (m)","Distance (cm)","Distance (mm)","Distance (mi)","Distance (ft)","Distance (in)"],!1,!1),n.numberLinkedWithSwitchField(t+"MinOverride",t+"Min0","Override Min Value","","",!1,[]),n.numberLinkedWithSwitchField(t+"MaxOverride",t+"Max0","Override Max Value","","",!1,[])];return i==="Left"&&r.push({type:"ShadingList",name:t+"Shading",label:"Y Axis Shading",add:function(n){return n.push({minValue:ko.observable(null),maxValue:ko.observable(null),color:ko.observable(""),label:ko.observable("")})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}),r}function u(){var t=[n.chartTitleField(),n.text("range","Number of tests","","Number of tests",!0,!1,!1)];return t=t.concat(i("left","Left")),t=t.concat(i("right","Right"))}function f(){return{type:"TestChart",designTemplate:"DesignTestChart",title:"Chart",titleSmall:"(Test Data)",properties:u(),createDesignField:function(n){return n===void 0&&(n={}),t(n.test||null,n.label||"",n.range||0,n.left||[],n.right||[],n.leftYLabel||"",n.rightYLabel||"",n.leftMin0||!1,n.leftMinOverride||0,n.rightMin0||!1,n.rightMinOverride||0,n.leftShading||[],n.rightShading||[],n.leftAxisType||"Normal",n.rightAxisType||"Normal",n.leftMultiplier||1,n.rightMultiplier||1,n.leftMax0||!1,n.leftMaxOverride||10,n.rightMax0||!1,n.rightMaxOverride||10,n.displayNotes||!1)}}}n.testChartField=r,n.designTestChartField=t,n.testChartTemplate=f}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st,ht){return{type:"TestChart2",test:n,name:null,range:r,groupBy:u,label:t,xLabel:i,x:f,swapLowerIsWorse:ht,repeatCount:e,repeatTitles:o,repeatNames:s,left:h,leftYLabel:c,leftYLabel2:d,leftMin0:l,leftMinOverride:a,leftShading:v,right:y,rightYLabel:p,rightYLabel2:g,rightMin0:w,rightMinOverride:b,rightShading:k,leftAxisType:nt,rightAxisType:tt,leftMultiplier:it,rightMultiplier:rt,leftMax0:ut,leftMaxOverride:ft,rightMax0:et,rightMaxOverride:ot,displayNotes:st}}function i(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st,ht){var ct=function(n){return ko.observableArray(_.map(n,function(n){return ko.observable(n)}))};return{type:"TestChart2",test:ko.observable(n),name:ko.observable(null),range:ko.observable(r),groupBy:ko.observable(u),label:ko.observable(t),xLabel:ko.observable(i),x:ko.observableArray(_.map(f,function(n){return{items:ct(n.items),type:ko.observable(n.type),operation:ko.observable(n.operation),legend:ko.observable(n.legend)}})),swapLowerIsWorse:ko.observable(ht),repeatCount:ko.observable(e),repeatTitles:ko.observable(o),repeatNames:ko.observable(s),leftYLabel:ko.observable(c),rightYLabel:ko.observable(p),leftYLabel2:ko.observable(d),rightYLabel2:ko.observable(g),leftMin0:ko.observable(l),leftMinOverride:ko.observable(a),rightMin0:ko.observable(w),rightMinOverride:ko.observable(b),left:ko.observableArray(_.map(h,function(n){return{items:ct(n.items),type:ko.observable(n.type),operation:ko.observable(n.operation)}})),right:ko.observableArray(_.map(y,function(n){return{items:ct(n.items),type:ko.observable(n.type),operation:ko.observable(n.operation)}})),leftShading:ko.observableArray(_.map(v,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),rightShading:ko.observableArray(_.map(k,function(n){return{minValue:ko.observable(n.minValue),maxValue:ko.observable(n.maxValue),color:ko.observable(n.color),label:ko.observable(n.label)}})),leftAxisType:ko.observable(nt),rightAxisType:ko.observable(tt),leftMultiplier:ko.observable(it),rightMultiplier:ko.observable(rt),leftMax0:ko.observable(ut),leftMaxOverride:ko.observable(ft),rightMax0:ko.observable(et),rightMaxOverride:ko.observable(ot),displayNotes:ko.observable(st)}}function r(){return[n.label("X Axis"),{type:"MultiSeriesList2",name:"x",label:"Diary Field",add:function(n){return n.push({items:ko.observableArray([]),type:ko.observable("line"),operation:ko.observable("average"),legend:ko.observable(null)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}}]}function u(){var t=[n.chartTitleField(),n.text("range","Number of entries","","Number of entries",!0,!1,!1),n.numberLinkedWithSwitchField("leftMaxOverride","leftMax0","Set Max Value","","",!1,[]),n.booleanField("swapLowerIsWorse","Swap Lower is Worse","",!0,!1)];return t=t.concat(r())}function f(){return{type:"TestChart2",designTemplate:"DesignTestChart2",title:"Chart",titleSmall:"(Radar)",properties:u(),createDesignField:function(n){return n===void 0&&(n={}),i(n.test||null,n.label||"",n.xLabel||"",n.range||1,n.groupBy||"Day",n.x||[],n.repeatCount||1,n.repeatTitles||[],n.repeatNames||[],n.left||[],n.leftYLabel||"",n.leftMin0||!1,n.leftMinOverride||0,n.leftShading||[],n.right||[],n.rightYLabel||"",n.rightMin0||!1,n.rightMinOverride||0,n.rightShading||[],n.leftYLabel2||"",n.rightYLabel2||"",n.leftAxisType,n.rightAxisType,n.leftMultiplier,n.rightMultiplier,n.leftMax0||!1,n.leftMaxOverride||10,n.rightMax0||!1,n.rightMaxOverride||10,n.displayNotes||!1)}}}n.testChart2Field=t,n.testChart2Template=f}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st){return{type:"TestChart3",test:n,name:null,range:r,groupBy:u,label:t,xLabel:i,x:f,repeatCount:e,repeatTitles:o,repeatNames:s,left:h,leftYLabel:c,leftYLabel2:d,leftMin0:l,leftMinOverride:a,leftShading:v,right:y,rightYLabel:p,rightYLabel2:g,rightMin0:w,rightMinOverride:b,rightShading:k,leftAxisType:nt,rightAxisType:tt,leftMultiplier:it,rightMultiplier:rt,leftMax0:ut,leftMaxOverride:ft,rightMax0:et,rightMaxOverride:ot,displayNotes:st}}n.testChart3Field=t}(Fields||(Fields={})),function(n){function t(n){return{type:"InjuryList",name:ko.observable(null),label:ko.observable(n)}}function i(){var i=[n.labelField()];return{type:"InjuryList",designTemplate:"DesignInjuryList",title:"Injury Table",properties:i,createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"")}}}n.injuryListTemplate=i}(Fields||(Fields={})),function(n){function t(n){return{type:"SorenessList",name:ko.observable(null),label:ko.observable(n)}}function i(){var i=[n.labelField()];return{type:"SorenessList",designTemplate:"DesignSorenessList",title:"Soreness Table",properties:i,createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"")}}}n.sorenessListTemplate=i}(Fields||(Fields={})),function(n){function t(n){return{type:"IllnessList",name:ko.observable(null),label:ko.observable(n)}}function i(){var i=[n.labelField()];return{type:"IllnessList",designTemplate:"DesignIllnessList",title:"Illness Table",properties:i,createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"")}}}n.illnessListTemplate=i}(Fields||(Fields={})),function(n){function t(n,t){return{type:"TestList",name:ko.observable(null),label:ko.observable(n),testId:ko.observable(t)}}function i(){var i=[n.labelField(),n.numberField("testId","Test Id",null,null,!0,[],!1)];return{type:"TestList",designTemplate:"DesignTestList",title:"Test Table",properties:i,createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"",n.testId||0)}}}n.testListTemplate=i}(Fields||(Fields={})),function(n){function t(){var t=n.text("label","Chart Title","The Label","Label",!0,!1,!1);return t.type="NameText",t}function i(){return n.text("label","Chart Title","The Label","Label",!0,!1,!1)}function r(){return n.text("label","Chart Title","Chart Title","Chart Title",!0,!1,!1)}function u(){return n.text("tooltip","Tooltip","The Tooltip","Tooltip",!1,!1,!1)}function f(){return n.text("placeholder","Placeholder","The Placeholder","Placeholder",!1,!1,!1)}function e(t,i){i===void 0&&(i=!0),n.templateMap[t.type]=t,i&&n.templates.push(t)}function o(t,i){i===void 0&&(i=!0),n.templateMap[t.type]=t,i&&n.analysisTemplates.push(t)}n.nameField=t,n.labelField=i,n.chartTitleField=r,n.tooltipField=u,n.placeholderField=f,n.templateMap={},n.templates=[],n.analysisTemplates=[],n.add=e,n.addAnalysis=o}(Fields||(Fields={})),function(n){function i(n,t){return t===void 0&&(t=null),{type:"LabelHtml",label:n,background:t}}function r(n,t){return t===void 0&&(t=null),{type:"Label",label:n,background:t}}function t(n,t){return{type:"Label",label:ko.observable(n),background:ko.observable(t),html:!1}}function u(){return{type:"Label",designTemplate:"DesignLabel",title:"Text Row",properties:[n.richText("label","Text Row","Text to display","Enter the text here",!0,!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"",n.background||"")}}}n.labelHtml=i,n.label=r,n.designLabel=t,n.labelTemplate=u}(Fields||(Fields={}));var redactorOps2={imageUpload:null,plugins:["fontcolor","fontsize"],buttons:["fontsize","bold","italic","underline","alignment","fontcolor"]},updatingRedactorElement=null,toHide2="";ko.bindingHandlers.redactor2={init:function(n,t,i){console.log("new one");var f=$(n);f.focus(function(){var e,r,s,u,o;if(!f.data("hasSummernote")){if(f.off("focus"),e="toolbarForField",$("#"+e).empty(),r=_.uniqueId("toolbar"),s='<div id="'+r+'"><\/div>',$(s).appendTo($("#"+e)),f.summernote({tabDisable:!1,dialogsInBody:!0,toolbarContainer:"#"+r,toolbar:[["font",["bold","italic","underline","fontsize","forecolor","backcolor"]]],callbacks:{onFocus:function(){toHide2&&($(toHide2).hide(),toHide2=""),$("#"+r).show(),$(n).click()},onBlur:function(){toHide2="#"+r}}}),u=i().background,u&&(n.parentElement.style.backgroundColor=u.peek(),n.style.backgroundColor=u.peek(),n.nextSibling&&n.nextSibling.style&&(n.nextSibling.style.backgroundColor=u.peek())),f.summernote("focus"),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){f.summernote("destroy")}),o=t(),ko.isObservable(o)){f.on("summernote.change",function(t,r){var e,s,h;f.data("isUpdating")?console.log("ignoring summernote"):(console.log("updating summernote"),o(r),e=i().background,e&&(n.nextSibling&&n.nextSibling.style?e(n.nextSibling.style.backgroundColor):e(n.style.backgroundColor)),s=i().redactorHeight,s&&(h=$(n.nextElementSibling).find(".note-editable").get(0).clientHeight,s(Math.max(h+2,20))))});f.on("summernote.changebk",function(){if(f.data("isUpdating"))console.log("ignoring summernote bk");else{console.log("updating summernote bk");var e=i().background;e&&(n.nextSibling&&n.nextSibling.style?e(n.nextSibling.style.backgroundColor):e(n.style.backgroundColor))}})}f.data("hasSummernote",!0)}})},update:function(n,t,i){var c=ko.unwrap(t())||"",f=$(n),l,e,o,s,h;f.data("hasSummernote")?(l=f.summernote("code"),l.replace(/[ \t\n]/g,"")!==c.replace(/[ \t\n]/g,"")&&(f.data("isUpdating",!0),f.summernote("code",c),f.data("isUpdating",!1))):n.innerHTML=c||"<p><br><\/p>",n.parent?(e=i().redactorHeight,e&&(f.data("hasSummernote")?(s=$(n.nextElementSibling).find(".note-editable").get(0).clientHeight,e(Math.max(s+2,20))):(o=n.lastElementChild,s=o?$(o).offset().top-$(n).offset().top+o.clientHeight:0,e(Math.max(s+2,20)))),h=i().background,h&&(n.style.backgroundColor=h.peek(),n.nextSibling&&n.nextSibling.style&&(n.nextSibling.style.backgroundColor=h.peek()))):setTimeout(function(){var t=i().redactorHeight,r,f,e,o,s,u;t&&(r=n.lastElementChild,f=r?$(r).offset().top-$(n).offset().top+r.clientHeight:0,n.clientHeight==0?(e=Math.max(f+2,20),o=t(),e>o&&t(e)):(s=Math.max(20,n.clientHeight),t(Math.max(f+2,s)))),u=i().background,u&&(n.style.backgroundColor=u.peek(),n.nextSibling&&n.nextSibling.style&&(n.nextSibling.style.backgroundColor=u.peek()))},10)}},function(n){function i(n,t,i,r,u,f,e){return{type:"RichText",name:n,label:t,tooltip:i,placeholder:r,required:u,multiple:f,displayNotes:e}}function r(n,t,i,r,u,f,e){return{type:"Text",name:n,label:t,tooltip:i,placeholder:r,required:u,multiple:f,displayNotes:e}}function t(n,t,i,r,u,f,e){return{type:"Text",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),placeholder:ko.observable(r),required:ko.observable(u),multiple:ko.observable(f),displayNotes:ko.observable(e)}}function u(){return{type:"Text",title:"Text Box",properties:[n.nameField(),n.tooltipField(),n.placeholderField(),n.booleanField("multiple","Multiple Lines","",!1,!1),n.booleanField("displayNotes","Display Notes Box","",!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),t(n.name||"",n.label||"",n.tooltip||"",n.placeholder||"",n.required||!1,n.multiple||!1,n.displayNotes||!1)}}}n.richText=i,n.text=r,n.designText=t,n.textTemplate=u}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f,e,o,s){return{type:"NumberLinked",name:n,label:t,tooltip:r,placeholder:u,required:f,units:e,linkedName:i,displayNotes:o,lowerIsWorse:s}}function i(n,t,i,r,u,f,e){return{type:"NumberLinkedWithSwitch",name:n,switchName:t,label:i,tooltip:r,units:e,placeholder:u,required:f,linkedName:n}}function r(n,t,i,r,u,f,e,o){return{type:"Number",name:n,label:t,tooltip:i,placeholder:r,required:u,units:f,displayNotes:e,lowerIsWorse:o}}function u(n,t,i,r,u,f,e,o){return{type:"Number",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),placeholder:ko.observable(r),required:ko.observable(u),units:ko.observableArray(f.map(function(n){return{id:ko.observable(n.id),label:ko.observable(n.label||n.name||""),conversion:ko.observable(n.conversion)}})),displayNotes:ko.observable(e),lowerIsWorse:ko.observable(o)}}function f(){return{type:"Number",title:"Number (Single Field)",properties:[n.nameField(),n.tooltipField(),n.placeholderField(),{type:"EditUnitList",name:"units",label:"Units",add:function(n){return n.push({id:ko.observable(0),label:ko.observable(""),conversion:ko.observable(1)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}},n.booleanField("displayNotes","Display Notes Box","",!1),n.booleanField("lowerIsWorse","Lower is Worse","",!1)],createDesignField:function(n){return n===void 0&&(n={}),u(n.name||"",n.label||"",n.tooltip||"",n.placeholder||"",n.required||!1,n.units||[],n.displayNotes||!1,n.lowerIsWorse||!1)}}}n.numberLinkedField=t,n.numberLinkedWithSwitchField=i,n.numberField=r,n.numberTemplate=f,n.defaultUnits=[]}(Fields||(Fields={})),function(n){function u(n){return r[n]||n}function i(n){for(var t=0;t<n.length;t++)n[t].label=u(n[t].label)}function f(n,t,r,u,f,e,o,s){return i(f),{type:"MultipleNumber",name:n,label:t,tooltip:r,required:u,units:f,unitsType:e,displayNotes:o,lowerIsWorse:s}}function e(n,t,r,u,f,e,o,s){return i(f),{type:"MultipleNumber",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(r),required:ko.observable(u),unitsType:e,units:ko.observableArray(f.map(function(n){return{id:ko.observable(n.id),label:ko.observable(n.label||n.name||""),conversion:ko.observable(n.conversion)}})),displayNotes:ko.observable(o),lowerIsWorse:ko.observable(s)}}function o(){return{type:"MultipleNumber",designTemplate:"DesignMultipleNumber",title:"Number (Multiple Fields)",properties:[n.nameField(),n.tooltipField(),{type:"EditMultipleNumberList",name:"units",label:"Units",add:function(n){return n.push({id:ko.observable(0),label:ko.observable(""),conversion:ko.observable(1)})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))},getList:function(t){return t.unitsType=="distance"?n.defaultMultipleUnitsDistance:t.unitsType=="duration"?[n.defaultMultipleUnits[0]]:t.unitsType=="height"?n.defaultMultipleUnitsHeight:n.defaultMultipleUnitsDistance}},n.booleanField("displayNotes","Display Notes Box","",!1,!1),n.booleanField("lowerIsWorse","Lower is Worse","",!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),e(n.name||"",n.label||"",n.tooltip||"",n.required||!1,n.units||[],n.unitsType||"custom",n.displayNotes||!1,n.lowerIsWorse||!1)}}}function t(n,t,i){return{id:n,label:t,conversion:i}}var r={Hours:"hr",Minutes:"min",Seconds:"sec",Milliseconds:"ms",Kilometers:"km",Meters:"m",Centimeters:"cm",Millimeters:"mm",Miles:"mi",Yards:"yd",Feet:"ft",Inches:"in"};n.shrinkUnits=i,n.multipleNumberField=f,n.multipleNumberTemplate=o,n.defaultMultipleUnits=[{label:"Duration",units:[t(1,"hr",.0166666666666667),t(2,"min",1),t(3,"sec",60),t(4,"ms",6e4)]},{label:"Distance (Metric)",units:[t(1,"km",1/1e3),t(2,"m",1),t(3,"cm",1/.01),t(4,"mm",1/.001)]},{label:"Distance (Imperial)",units:[t(1,"mi",1/1609.344),t(2,"yd",1/.9144),t(3,"ft",1/.3048),t(4,"in",1/.0254)]},{label:"Height (Metric)",units:[t(1,"m",1),t(2,"cm",1/.01)]},{label:"Height (Imperial)",units:[t(1,"ft",1/.3048),t(2,"in",1/.0254)]}],n.defaultMultipleUnitsDistance=[{label:"Metric",units:[t(1,"km",1/1e3),t(2,"m",1),t(3,"cm",1/.01),t(4,"mm",1/.001)]},{label:"Imperial",units:[t(1,"mi",1/1609.344),t(2,"yd",1/.9144),t(3,"ft",1/.3048),t(4,"in",1/.0254)]}],n.defaultMultipleUnitsHeight=[{label:"Metric",units:[t(1,"m",1),t(2,"cm",1/.01)]},{label:"Imperial",units:[t(1,"ft",1/.3048),t(2,"in",1/.0254)]}]}(Fields||(Fields={})),function(n){function t(n,t){for(var f=n.constantCount(),i=n.repeatNames().length,r,u;i<t;){for(r=ko.observableArray([]),u=0;u<f;u++)u==0?r.push({name:ko.observable("Stage "+(i+1))}):r.push({name:ko.observable("")});i++,n.repeatNames.push(r)}i>t&&n.repeatNames.splice(t,i-t)}function i(n,t){for(var i=n.repeatTitles().length;i<t;)i==0?n.repeatTitles.push({name:ko.observable("Stage")}):n.repeatTitles.push({name:ko.observable("")}),i++;i>t&&n.repeatTitles.splice(t,i-t),_.each(n.repeatNames(),function(n,r){for(i=n().length;i<t;)i==0?n.push({name:ko.observable("Stage "+(r+1))}):n.push({name:ko.observable("")}),i++;i>t&&n.splice(t,i-t)})}function r(n){return _.map(n.repeatNames(),function(n){return _.map(n(),function(n){return n.name()})})}function u(n){return _.map(n,function(n){return ko.observableArray(_.map(n,function(n){return{name:ko.observable(n)}}))})}function f(n,r,f,e,o,s,h){var c={type:"Group",group:ko.observable(r),repeatCount:ko.observable(f),constantCount:ko.observable(e),repeatNames:ko.observableArray(u(s||[])),repeatTitles:ko.observableArray(_.map(o||[],function(n){return{name:ko.observable(n)}})),items:ko.observableArray(n.process(h))};return c.repeatCount.subscribe(function(n){return t(c,n)}),c.constantCount.subscribe(function(n){return i(c,n)}),t(c,f),c}function e(){return{type:"Group",designTemplate:"DesignGroup",title:"Stage Test",properties:[{type:"GroupSetupRepeats",name:"repeats"}],createDesignField:function(n,t){return n===void 0&&(n={}),t===void 0&&(t=null),f(t,n.group||"",n.repeatCount||1,n.constantCount||0,n.repeatTitles,n.repeatNames,n.items||[])},toJSON:function(n,t){return{type:"Group",group:n.group(),repeatCount:n.repeatCount(),constantCount:n.constantCount(),repeatTitles:_.map(n.repeatTitles(),function(n){return n.name()}),repeatNames:r(n),items:_.map(n.items(),function(n){return t.saveField(n)})}}}}n.groupTemplate=e}(Fields||(Fields={})),yoyo1=[[1,1,1,5,10,40],[2,2,1,8,11.5,80],[3,3,1,11,13,120],[4,3,2,11,13,160],[5,4,1,12,13.5,200],[6,4,2,12,13.5,240],[7,4,3,12,13.5,280],[8,5,1,13,14,320],[9,5,2,13,14,360],[10,5,3,13,14,400],[11,5,4,13,14,440],[12,6,1,14,14.5,480],[13,6,2,14,14.5,520],[14,6,3,14,14.5,560],[15,6,4,14,14.5,600],[16,6,5,14,14.5,640],[17,6,6,14,14.5,680],[18,6,7,14,14.5,720],[19,6,8,14,14.5,760],[20,7,1,15,15,800],[21,7,2,15,15,840],[22,7,3,15,15,880],[23,7,4,15,15,920],[24,7,5,15,15,960],[25,7,6,15,15,1e3],[26,7,7,15,15,1040],[27,7,8,15,15,1080],[28,8,1,16,15.5,1120],[29,8,2,16,15.5,1160],[30,8,3,16,15.5,1200],[31,8,4,16,15.5,1240],[32,8,5,16,15.5,1280],[33,8,6,16,15.5,1320],[34,8,7,16,15.5,1360],[35,8,8,16,15.5,1400],[36,9,1,17,16,1440],[37,9,2,17,16,1480],[38,9,3,17,16,1520],[39,9,4,17,16,1560],[40,9,5,17,16,1600],[41,9,6,17,16,1640],[42,9,7,17,16,1680],[43,9,8,17,16,1720],[44,10,1,18,16.5,1760],[45,10,2,18,16.5,1800],[46,10,3,18,16.5,1840],[47,10,4,18,16.5,1880],[48,10,5,18,16.5,1920],[49,10,6,18,16.5,1960],[50,10,7,18,16.5,2e3],[51,10,8,18,16.5,2040],[52,11,1,19,17,2080],[53,11,2,19,17,2120],[54,11,3,19,17,2160],[55,11,4,19,17,2200],[56,11,5,19,17,2240],[57,11,6,19,17,2280],[58,11,7,19,17,2320],[59,11,8,19,17,2360],[60,12,1,20,17.5,2400],[61,12,2,20,17.5,2440],[62,12,3,20,17.5,2480],[63,12,4,20,17.5,2520],[64,12,5,20,17.5,2560],[65,12,6,20,17.5,2600],[66,12,7,20,17.5,2640],[67,12,8,20,17.5,2680],[68,13,1,21,18,2720],[69,13,2,21,18,2760],[70,13,3,21,18,2800],[71,13,4,21,18,2840],[72,13,5,21,18,2880],[73,13,6,21,18,2920],[74,13,7,21,18,2960],[75,13,8,21,18,3e3],[76,14,1,22,18.5,3040],[77,14,2,22,18.5,3080],[78,14,3,22,18.5,3120],[79,14,4,22,18.5,3160],[80,14,5,22,18.5,3200],[81,14,6,22,18.5,3240],[82,14,7,22,18.5,3280],[83,14,8,22,18.5,3320],[84,15,1,23,19,3360],[85,15,2,23,19,3400],[86,15,3,23,19,3440],[87,15,4,23,19,3480],[88,15,5,23,19,3520],[89,15,6,23,19,3560],[90,15,7,23,19,3600],[91,15,8,23,19,3640]],yoyo2=[[1,1,1,11,13,40],[2,2,1,15,15,80],[3,3,1,17,16,120],[4,3,2,17,16,160],[5,4,1,18,16.5,200],[6,4,2,18,16.5,240],[7,4,3,18,16.5,280],[8,5,1,19,17,320],[9,5,2,19,17,360],[10,5,3,19,17,400],[11,5,4,19,17,440],[12,6,1,20,17.5,480],[13,6,2,20,17.5,520],[14,6,3,20,17.5,560],[15,6,4,20,17.5,600],[16,6,5,20,17.5,640],[17,6,6,20,17.5,680],[18,6,7,20,17.5,720],[19,6,8,20,17.5,760],[20,7,1,21,18,800],[21,7,2,21,18,840],[22,7,3,21,18,880],[23,7,4,21,18,920],[24,7,5,21,18,960],[25,7,6,21,18,1e3],[26,7,7,21,18,1040],[27,7,8,21,18,1080],[28,8,1,22,18.5,1120],[29,8,2,22,18.5,1160],[30,8,3,22,18.5,1200],[31,8,4,22,18.5,1240],[32,8,5,22,18.5,1280],[33,8,6,22,18.5,1320],[34,8,7,22,18.5,1360],[35,8,8,22,18.5,1400],[36,9,1,23,19,1440],[37,9,2,23,19,1480],[38,9,3,23,19,1520],[39,9,4,23,19,1560],[40,9,5,23,19,1600],[41,9,6,23,19,1640],[42,9,7,23,19,1680],[43,9,8,23,19,1720],[44,10,1,24,19.5,1760],[45,10,2,24,19.5,1800],[46,10,3,24,19.5,1840],[47,10,4,24,19.5,1880],[48,10,5,24,19.5,1920],[49,10,6,24,19.5,1960],[50,10,7,24,19.5,2e3],[51,10,8,24,19.5,2040],[52,11,1,25,20,2080],[53,11,2,25,20,2120],[54,11,3,25,20,2160],[55,11,4,25,20,2200],[56,11,5,25,20,2240],[57,11,6,25,20,2280],[58,11,7,25,20,2320],[59,11,8,25,20,2360],[60,12,1,26,20.5,2400],[61,12,2,26,20.5,2440],[62,12,3,26,20.5,2480],[63,12,4,26,20.5,2520],[64,12,5,26,20.5,2560],[65,12,6,26,20.5,2600],[66,12,7,26,20.5,2640],[67,12,8,26,20.5,2680],[68,13,1,27,21,2720],[69,13,2,27,21,2760],[70,13,3,27,21,2800],[71,13,4,27,21,2840],[72,13,5,27,21,2880],[73,13,6,27,21,2920],[74,13,7,27,21,2960],[75,13,8,27,21,3e3],[76,14,1,28,21.5,3040],[77,14,2,28,21.5,3080],[78,14,3,28,21.5,3120],[79,14,4,28,21.5,3160],[80,14,5,28,21.5,3200],[81,14,6,28,21.5,3240],[82,14,7,28,21.5,3280],[83,14,8,28,21.5,3320],[84,15,1,29,22,3360],[85,15,2,29,22,3400],[86,15,3,29,22,3440],[87,15,4,29,22,3480],[88,15,5,29,22,3520],[89,15,6,29,22,3560],[90,15,7,29,22,3600],[91,15,8,29,22,3640]],function(n){function t(n,t,i,r,u,f,e){return{type:"Calculated",name:n,label:t,calculated:i,unit:r,enabled:u,displayNotes:f,lowerIsWorse:e}}function i(n,t,i,r,u,f,e){return{type:"Calculated",name:ko.observable(n),label:ko.observable(t),calculated:ko.observable(i),unit:ko.observable(r),enabled:ko.observable(u),displayNotes:ko.observable(f),lowerIsWorse:ko.observable(e)}}function r(n,t,i,r,u,f,e){var o=function(i){var o,h,r,u,s,f,e;if(i=i.toLowerCase(),o=t[i],h=!1,o&&o.type==="DurationTime"&&o.showMinutes===!1&&(h=!0),u=ko.unwrap(n[i]),_.isArray(u)){if(s=t[i],s){for(f=0,e=0;e<u.length;e++)r=parseFloat(ko.unwrap(u[e])),r=_.isNaN(r)?0:r,f+=r/s.units[e].conversion;return f=f*s.units[0].conversion}u=ko.unwrap(u[0])}return r=parseFloat(u),r=_.isNaN(r)?0:r,h&&(r*=60),r},s=function(n,t,i){for(var u=[],r=t;r<=i;r++)u.push(o(n+r));return u},h=function(t){var i=ko.unwrap(n[t]);return _.isArray(i)&&(i=ko.unwrap(i[0])),i},c=function(n){for(var i=0,t=0;t<n.length;t++)i+=n[t];return i},l=function(n,t){var i=[0,0,7,15,23,32,41,51,61,72,83,94,106,118,131,144,157,171,185,200,215,231,247];return i[n]+t},a=function(n,t){var i=_.find(yoyo1,function(i){return i[1]==n&&i[2]==t});return i?i:["","","","","",""]},v=function(n,t){var i=_.find(yoyo1,function(i){return i[3]==n&&i[2]==t});return i?i:["","","","","",""]},y=function(n,t){var i=_.find(yoyo2,function(i){return i[1]==n&&i[2]==t});return i?i:["","","","","",""]},p=function(n,t){var i=_.find(yoyo2,function(i){return i[3]==n&&i[2]==t});return i?i:["","","","","",""]},b=new Function("f","fa","index","v","sh","sum","yoyo1","yoyo2","userId","customRm","yoyo1SL","yoyo2SL","return "+r),w=u?new Function("f","fa","index","v","sh","sum","yoyo1","yoyo2","userId","customRm","yoyo1SL","yoyo2SL","return "+u):null;return ko.computed(function(){return w&&!w(o,s,i,h,l,c,a,y,f,e,v,p)?"":b(o,s,i,h,l,c,a,y,f,e,v,p)})}function u(){return{type:"Calculated",designTemplate:"DesignCalculated",title:"Calculated",properties:[n.nameField(),n.tooltipField(),n.text("unit","Unit","","",!1,!1,!1),n.text("calculated","Calculated","Calculated expression","Enter the calculated expression here",!0,!1,!1),n.text("enabled","Enabled","Enabled expression","Enter the enabled expression here",!0,!1,!1),n.booleanField("displayNotes","Display Notes Box","",!1,!1),n.booleanField("lowerIsWorse","Lower is Worse","",!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.calculated||"",n.unit||"",n.enabled||"",n.displayNotes||!1,n.lowerIsWorse||!1)}}}n.calculated=t,n.createCalculated=r,n.calculatedTemplate=u}(Fields||(Fields={})),function(n){function t(n,t,i,r,u){return{type:"Boolean",name:n,label:t,tooltip:i,worseIs:r,displayNotes:u}}function i(n,t,i,r,u){return{type:"Boolean",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),worseIs:ko.observable(r),displayNotes:ko.observable(u)}}function r(){return{type:"Boolean",title:"Yes/No",properties:[n.nameField(),n.tooltipField(),t("worseIs","Worse Is","",!1,!1),t("displayNotes","Display Notes Box","",!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.worseIs||!1,n.displayNotes||!1)}}}n.booleanField=t,n.booleanTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r,u){return{type:"Duration",name:n,label:t,tooltip:i,displayNotes:r,lowerIsWorse:u}}function i(n,t,i,r,u){return{type:"Duration",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),displayNotes:ko.observable(r),lowerIsWorse:ko.observable(u)}}function r(){return{type:"Duration",designTemplate:"DesignDuration",title:"Training Load",properties:[n.nameField(),n.tooltipField(),n.booleanField("displayNotes","Display Notes Box","",!1),n.booleanField("lowerIsWorse","Lower is Worse","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.displayNotes||!1,n.lowerIsWorse||!1)}}}n.durationField=t,n.durationTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f,e,o,s){return{type:"DurationTime",name:n,label:t,tooltip:i,showMilliseconds:r,showSeconds:u,showMinutes:f,showHours:e,displayNotes:o,lowerIsWorse:s}}function i(n,t,i,r,u,f,e,o,s){return{type:"DurationTime",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),showMilliseconds:ko.observable(r),showSeconds:ko.observable(u),showMinutes:ko.observable(f),showHours:ko.observable(e),displayNotes:ko.observable(o),lowerIsWorse:ko.observable(s)}}function r(){return{type:"DurationTime",designTemplate:"DesignDurationTime",title:"Duration (Time)",properties:[n.nameField(),n.tooltipField(),n.booleanField("showMilliseconds","Show Milliseconds","",!1),n.booleanField("showSeconds","Show Seconds","",!1),n.booleanField("showMinutes","Show Minutes","",!1),n.booleanField("showHours","Show Hours","",!1),n.booleanField("displayNotes","Display Notes Box","",!1),n.booleanField("lowerIsWorse","Lower is Worse","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.showMilliseconds!==!1,n.showSeconds!==!1,n.showMinutes!==!1,n.showHours!==!1,n.displayNotes||!1,n.lowerIsWorse||!1)}}}n.durationTimeField=t,n.durationTimeTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k){return{type:"Range",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),left:ko.observable(r),right:ko.observable(u),lowerIsWorse:ko.observable(f),maximum:ko.observable(e),text1:ko.observable(o),text2:ko.observable(s),text3:ko.observable(h),text4:ko.observable(c),text5:ko.observable(l),text6:ko.observable(a),text7:ko.observable(v),text8:ko.observable(y),text9:ko.observable(p),text10:ko.observable(w),displayNotes:ko.observable(b),fontSmaller:ko.observable(k)}}function i(){return{type:"Range",title:"Number (Range)",properties:[n.nameField(),n.tooltipField(),n.text("left","Left Text","","",!1,!1,!1),n.text("right","Right Text","","",!1,!1,!1),n.optionField("maximum","Maximum Value","",[2,3,4,5,6,7,8,9,10],!1,!1),n.booleanField("lowerIsWorse","Lower is Worse","",!1),n.text("text1","Text for 1","","",!1,!1,!1),n.text("text2","Text for 2","","",!1,!1,!1),n.text("text3","Text for 3","","",!1,!1,!1),n.text("text4","Text for 4","","",!1,!1,!1),n.text("text5","Text for 5","","",!1,!1,!1),n.text("text6","Text for 6","","",!1,!1,!1),n.text("text7","Text for 7","","",!1,!1,!1),n.text("text8","Text for 8","","",!1,!1,!1),n.text("text9","Text for 9","","",!1,!1,!1),n.text("text10","Text for 10","","",!1,!1,!1),n.booleanField("fontSmaller","Smaller Font","",!1),n.booleanField("displayNotes","Display Notes Box","",!1)],createDesignField:function(n){return n===void 0&&(n={}),t(n.name||"",n.label||"",n.tooltip||"",n.left||"",n.right||"",n.lowerIsWorse||!1,n.maximum||10,n.text1||"",n.text2||"",n.text3||"",n.text4||"",n.text5||"",n.text6||"",n.text7||"",n.text8||"",n.text9||"",n.text10||"",n.displayNotes||!1,n.fontSmaller||!1)}}}n.rangeTemplate=i}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f){return{type:"Option",name:n,label:t,tooltip:i,items:r,multiple:u,displayNotes:f}}function i(n,t,i,r,u,f){return{type:"Option",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),items:ko.observableArray(r.map(function(n){return{item:ko.observable(n)}})),multiple:ko.observable(u),displayNotes:ko.observable(f)}}function r(){return{type:"Option",designTemplate:"DesignOption",title:"Option",properties:[n.nameField(),n.tooltipField(),n.placeholderField(),n.booleanField("multiple","Multiple Results","Can the client select multiple results for this option",!1),{type:"EditList",name:"items",label:"Items",add:function(n){return n.push({item:ko.observable("")})},remove:function(n,t){return n.remove(t)},copy:function(n,t){t(JSON.parse(JSON.stringify(n)))}},n.booleanField("displayNotes","Display Notes Box","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.items||[],n.multiple||!1,n.displayNotes||!1)},toJSON:function(n){return{type:"Option",name:n.name(),label:n.label(),tooltip:n.tooltip(),items:n.items().map(function(n){return n.item()}),multiple:n.multiple(),displayNotes:n.displayNotes()}}}}n.optionField=t,n.optionTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r,u,f){return{type:"Time",name:n,label:t,endLabel:i,tooltip:r,displayEnd:u,displayNotes:f}}function i(n,t,i,r,u,f){return{type:"Time",name:ko.observable(n),label:ko.observable(t),endLabel:ko.observable(i),tooltip:ko.observable(r),displayEnd:ko.observable(u),displayNotes:ko.observable(f)}}function r(){return{type:"Time",title:"Time (am/pm)",properties:[n.nameField(),n.tooltipField(),n.booleanField("displayEnd","Display Time End","",!1),n.text("endLabel","End Label","End Label","End Label",!1,!1,!1),n.booleanField("displayNotes","Display Notes Box","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.endLabel||"",n.tooltip||"",n.displayEnd||!1,n.displayNotes||!1)}}}n.timeField=t,n.timeTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r){return{type:"Date",name:n,label:t,tooltip:i,displayNotes:r}}function i(n,t,i,r){return{type:"Date",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),displayNotes:ko.observable(r)}}function r(){return{type:"Date",title:"Date",properties:[n.nameField(),n.tooltipField(),n.booleanField("displayNotes","Display Notes Box","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.displayNotes||!1)}}}n.dateField=t,n.dateTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r){return{type:"Injury",name:n,label:t,tooltip:i,displayNotes:r}}function i(n,t,i,r){return{type:"Injury",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),displayNotes:ko.observable(r)}}function r(){return{type:"Injury",title:"Injury",properties:[n.nameField(),n.tooltipField(),n.booleanField("displayNotes","Display Notes Box","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.displayNotes||!1)}}}n.injuryField=t,n.injuryTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r){return{type:"Soreness",name:n,label:t,tooltip:i,displayNotes:r}}function i(n,t,i,r){return{type:"Soreness",name:ko.observable(n),label:ko.observable(t),tooltip:ko.observable(i),displayNotes:ko.observable(r)}}function r(){return{type:"Soreness",title:"Soreness",properties:[n.nameField(),n.tooltipField(),n.booleanField("displayNotes","Display Notes Box","",!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.name||"",n.label||"",n.tooltip||"",n.displayNotes||!1)}}}n.sorenessField=t,n.sorenessTemplate=r}(Fields||(Fields={})),function(n){function i(n,t){return{type:"Test",label:n,id:t,completeItem:ko.observable()}}function t(n,t){return{type:"Test",label:n,id:t,completeItem:ko.observable()}}function r(){return{type:"Test",title:"Test",properties:[],createDesignField:function(n){return n===void 0&&(n={}),t(n.label||"",n.id||0)},toJSON:function(n){return{type:"Test",label:n.label,id:n.id}}}}n.testField=i,n.testDesignField=t,n.testTemplate=r}(Fields||(Fields={})),function(n){function u(n){return{type:"Html",html:n}}function t(n){return{type:"Html",html:ko.observable(n)}}function f(){return{type:"Html",title:"Embed Code",properties:[n.text("html","Html","Html to display","Enter the html text here",!0,!0,!1)],createDesignField:function(n){return n===void 0&&(n={}),t(n.html||"")}}}function e(n,t){return{type:"Link",label:n,url:t}}function i(n,t){return{type:"Link",label:ko.observable(n),url:ko.observable(t)}}function o(n,t){return{type:"Label",label:ko.observable(n),background:ko.observable(t),html:!1}}function r(){return{type:"LineBreak"}}function s(){return{type:"Link",title:"Hyper-linked text",properties:[n.text("label","Display","Text to display","",!0,!1,!1),n.text("url","URL","URL to use","Enter the url here",!0,!0,!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.label||"",n.url||"")},toJSON:function(n){var t=n.url();return t&&t[0]!=="#"&&t.indexOf(":")===-1&&(t="http://"+t),{type:"Link",label:n.label(),url:t}}}}function h(){return{type:"Label",designTemplate:"DesignLabel",title:"Text Row",properties:[n.richText("label","Text Row","Text to display","Enter the text here",!0,!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),o(n.label||"",n.background||"")}}}function c(){return{type:"LineBreak",designTemplate:"DesignLineBreak",title:"Line Break",properties:[n.label("Adds a line break to ensure the following content goes on the next line")],createDesignField:function(n){return n===void 0&&(n={}),r()}}}n.html=u,n.designHtml=t,n.htmlTemplate=f,n.link=e,n.designLink=i,n.designLineBreak=r,n.linkTemplate=s,n.headingTemplate=h,n.linebreakTemplate=c}(Fields||(Fields={})),function(n){function t(n){return{type:"AppLink",appLink:n}}function i(n){return{type:"AppLink",appLink:ko.observable(n)}}function r(){return{type:"AppLink",title:"AppLink",properties:[n.text("appLink","AppLink","AppLink to display","Enter the appLink here",!0,!1,!1)],createDesignField:function(n){return n===void 0&&(n={}),i(n.appLink||"")}}}n.appLink=t,n.appLinkTemplate=r}(Fields||(Fields={})),function(n){function t(n,t,i,r,u){var f;if(u){var s=JSON.parse(u).fields[0],o=s.reconvertFactors,e=i-1;return e<0||e>=o.length?"":(f=t*o[e],Math.round(f).toString())}return i==1?t:(n==="Epley"?f=t*(1+.0333*i):n==="Lander"?f=t/(1.013-.0267123*i):n==="Brzycki"?f=t/(1.0278-.0278*i):n==="Lombardi"?f=t*Math.pow(i,.1):n==="Mayhew"?f=100*t/(52.2+41.9*Math.exp(-.055*i)):n==="O'Connor"?f=t*(1+.025*i):n==="Wathen"&&(f=100*t/(48.8+53.8*Math.exp(-.075*i))),Math.round(f).toString())}function i(n,t){return{type:"Rm",name:ko.observable(t),title:t,id:n,completeItem:ko.observable()}}function r(){return{type:"Rm",designTemplate:"DesignRm",title:"Rm",properties:[],createDesignField:function(n){return n===void 0&&(n={}),i(n.id,n.title||"")}}}n.calcRm=t,n.rmFields=[{type:"Text",multiple:!1,name:"testerid",label:"Tester ID",tooltip:"",placeholder:"",required:!1,units:[],legend:""},{type:"Number",name:"tem",label:"TEM",tooltip:"",placeholder:"",required:!1,units:[],legend:""},{type:"Number",name:"bodymass",label:"Body Mass",tooltip:"",placeholder:"",required:!1,units:[{id:0,label:"kg",conversion:1},{id:0,label:"lb",conversion:"2.204622622"}],legend:""},{type:"Number",name:"weightLifted",label:"Weight Lifted",tooltip:"",placeholder:"",required:!1,units:[{id:0,label:"kg",conversion:1},{id:0,label:"lb",conversion:"2.204622622"}],legend:""},{type:"Number",name:"repsCompleted",label:"Reps Completed",tooltip:"",placeholder:"",required:!1,units:[],legend:""},{type:"Calculated",name:"1rm",label:"1 RM",calculated:"Fields.calcRm('Epley', f('weightLifted'), f('repsCompleted'), userId, customRm)",unit:"",enabled:"f('weightLifted') && f('repsCompleted')",legend:""},{type:"Calculated",name:"relativestrength",label:"Relative Strength (%BM)",calculated:"(f('1rm')*100/f('bodymass')).toFixed()",unit:"",enabled:"f('1rm') && f('bodymass')",legend:""},{type:"Text",name:"notes",label:"Notes",tooltip:"",placeholder:"",required:!1,multiple:!0,legend:""}],n.rmTemplate=r}(Fields||(Fields={})),Fields.add(Fields.labelTemplate()),Fields.add(Fields.textTemplate()),Fields.add(Fields.numberTemplate()),Fields.add(Fields.multipleNumberTemplate()),Fields.add(Fields.durationTimeTemplate()),Fields.add(Fields.rangeTemplate()),Fields.add(Fields.booleanTemplate()),Fields.add(Fields.optionTemplate()),Fields.add(Fields.dateTemplate()),Fields.add(Fields.timeTemplate()),Fields.add(Fields.htmlTemplate()),Fields.add(Fields.linkTemplate()),Fields.add(Fields.appLinkTemplate(),!1),Fields.add(Fields.groupTemplate(),!1),Fields.add(Fields.sorenessTemplate(),!1),Fields.add(Fields.injuryTemplate(),!1),Fields.add(Fields.durationTemplate(),!1),Fields.add(Fields.testTemplate(),!1),Fields.add(Fields.calculatedTemplate(),!0),Fields.add(Fields.linebreakTemplate()),Fields.add(Fields.rmTemplate(),!1),hasLoadedAF=!1,function(n){function l(n){return"[object Function]"===ht.call(n)}function a(n){return"[object Array]"===ht.call(n)}function f(n,t){if(n)for(var i=0;i<n.length&&(!n[i]||!t(n[i],i,n));i+=1);}function tt(n,t){if(n)for(var i=n.length-1;-1<i&&(!n[i]||!t(n[i],i,n));i-=1);}function r(n,t){return pt.call(n,t)}function i(n,t){return r(n,t)&&n[t]}function h(n,t){for(var i in n)if(r(n,i)&&t(n[i],i))break}function it(n,t,i,u){return t&&h(t,function(t,f){(i||!r(n,f))&&(u&&"object"==typeof t&&t&&!a(t)&&!l(t)&&!(t instanceof RegExp)?(n[f]||(n[f]={}),it(n[f],t,i,u)):n[f]=t)}),n}function u(n,t){return function(){return t.apply(n,arguments)}}function et(n){throw n;}function ot(t){if(!t)return t;var i=n;return f(t.split("."),function(n){i=i[n]}),i}function c(n,t,i,r){return t=Error(t+"\nhttp://requirejs.org/docs/errors.html#"+n),t.requireType=n,t.requireModules=r,i&&(t.originalError=i),t}function lt(e){function ut(n,t,r){var e,u,f,o,s,a,h,y,t=t&&t.split("/"),c=v.map,l=c&&c["*"];if(n){for(n=n.split("/"),u=n.length-1,v.nodeIdCompat&&g.test(n[u])&&(n[u]=n[u].replace(g,"")),"."===n[0].charAt(0)&&t&&(u=t.slice(0,t.length-1),n=u.concat(n)),u=n,f=0;f<u.length;f++)(o=u[f],"."===o)?(u.splice(f,1),f-=1):".."===o&&!(0===f||1==f&&".."===u[2]||".."===u[f-1])&&0<f&&(u.splice(f-1,2),f-=2);n=n.join("/")}if(r&&c&&(t||l)){u=n.split("/"),f=u.length;n:for(;0<f;f-=1){if(s=u.slice(0,f).join("/"),t)for(o=t.length;0<o;o-=1)if((r=i(c,t.slice(0,o).join("/")))&&(r=i(r,s))){e=r,a=f;break n}!h&&l&&i(l,s)&&(h=i(l,s),y=f)}!e&&h&&(e=h,a=y),e&&(u.splice(0,a,e),n=u.join("/"))}return(e=i(v.pkgs,n))?e:n}function ei(n){o&&f(document.getElementsByTagName("script"),function(t){if(t.getAttribute("data-requiremodule")===n&&t.getAttribute("data-requirecontext")===s.contextName)return t.parentNode.removeChild(t),!0})}function vt(n){var t=i(v.paths,n);if(t&&a(t)&&1<t.length)return t.shift(),s.require.undef(n),s.makeRequire(null,{skipMap:!0})([n]),!0}function oi(n){var i,t=n?n.indexOf("!"):-1;return-1<t&&(i=n.substring(0,t),n=n.substring(t+1,n.length)),[i,n]}function k(n,t,r,u){var c,o,f=null,h=t?t.name:null,a=n,l=!0,e="";return n||(l=!1,n="_@r"+(li+=1)),n=oi(n),f=n[0],n=n[1],f&&(f=ut(f,h,u),o=i(w,f)),n&&(f?e=o&&o.normalize?o.normalize(n,function(n){return ut(n,h,u)}):-1===n.indexOf("!")?ut(n,h,u):n:(e=ut(n,h,u),n=oi(e),f=n[0],e=n[1],r=!0,c=s.nameToUrl(e))),r=f&&!o&&!r?"_unnormalized"+(ai+=1):"",{prefix:f,name:e,parentMap:t,unnormalized:!!r,url:c,originalName:a,isDefine:l,id:(f?f+"!"+e:e)+r}}function st(n){var r=n.id,t=i(y,r);return t||(t=y[r]=new s.Module(n)),t}function lt(n,t,u){var e=n.id,f=i(y,e);if(r(w,e)&&(!f||f.defineEmitComplete))"defined"===t&&u(w[e]);else if(f=st(n),f.error&&"error"===t)u(f.error);else f.on(t,u)}function d(n,r){var e=n.requireModules,u=!1;if(r)r(n);else if(f(e,function(t){(t=i(y,t))&&(t.error=n,t.events.error&&(u=!0,t.emit("error",n)))}),!u)t.onError(n)}function pt(){nt.length&&(wt.apply(rt,[rt.length,0].concat(nt)),nt=[])}function kt(n){delete y[n],delete ri[n]}function si(n,t,r){var u=n.map.id;n.error?n.emit("error",n.error):(t[u]=!0,f(n.depMaps,function(u,f){var e=u.id,o=i(y,e);!o||n.depMatched[f]||r[e]||(i(t,e)?(n.defineDep(f,w[e]),n.check()):si(o,t,r))}),r[u]=!0)}function dt(){var n,u,i=(n=1e3*v.waitSeconds)&&s.startTime+n<+new Date,t=[],e=[],r=!1,l=!0;if(!ni){if(ni=!0,h(ri,function(n){var f=n.map,o=f.id;if(n.enabled&&(f.isDefine||e.push(n),!n.error))if(!n.inited&&i)vt(o)?r=u=!0:(t.push(o),ei(o));else if(!n.inited&&n.fetched&&f.isDefine&&(r=!0,!f.prefix))return l=!1}),i&&t.length)return n=c("timeout","Load timeout for modules: "+t,null,t),n.contextName=s.contextName,d(n);l&&f(e,function(n){si(n,{},{})}),(!i||u)&&r&&(o||ct)&&!ii&&(ii=setTimeout(function(){ii=0,dt()},50)),ni=!1}}function gt(n){r(w,n[0])||st(k(n[0],null,!0)).init(n[1],n[2])}function hi(n){var n=n.currentTarget||n.srcElement,t=s.onScriptLoad;return n.detachEvent&&!ft?n.detachEvent("onreadystatechange",t):n.removeEventListener("load",t,!1),t=s.onScriptError,(!n.detachEvent||ft)&&n.removeEventListener("error",t,!1),{node:n,id:n&&n.getAttribute("data-requiremodule")}}function ci(){var n;for(pt();rt.length;){if(n=rt.shift(),null===n[0])return d(c("mismatch","Mismatched anonymous define() module: "+n[n.length-1]));gt(n)}}var ni,ti,s,ht,ii,v={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},y={},ri={},ui={},rt=[],w={},at={},fi={},li=1,ai=1;return ht={require:function(n){return n.require?n.require:n.require=s.makeRequire(n.map)},exports:function(n){return n.usingExports=!0,n.map.isDefine?n.exports?w[n.map.id]=n.exports:n.exports=w[n.map.id]={}:void 0},module:function(n){return n.module?n.module:n.module={id:n.map.id,uri:n.map.url,config:function(){return i(v.config,n.map.id)||{}},exports:n.exports||(n.exports={})}}},ti=function(n){this.events=i(ui,n.id)||{},this.map=n,this.shim=i(v.shim,n.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},ti.prototype={init:function(n,t,i,r){if(r=r||{},!this.inited){if(this.factory=t,i)this.on("error",i);else this.events.error&&(i=u(this,function(n){this.emit("error",n)}));this.depMaps=n&&n.slice(0),this.errback=i,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check()}},defineDep:function(n,t){this.depMatched[n]||(this.depMatched[n]=!0,this.depCount-=1,this.depExports[n]=t)},fetch:function(){if(!this.fetched){this.fetched=!0,s.startTime=+new Date;var n=this.map;if(this.shim)s.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],u(this,function(){return n.prefix?this.callPlugin():this.load()}));else return n.prefix?this.callPlugin():this.load()}},load:function(){var n=this.map.url;at[n]||(at[n]=!0,s.load(this.map.id,n))},check:function(){var i,r,u,n,f;if(this.enabled&&!this.enabling)if(u=this.map.id,r=this.depExports,n=this.exports,f=this.factory,this.inited){if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,1>this.depCount&&!this.defined){if(l(f)){if(this.events.error&&this.map.isDefine||t.onError!==et)try{n=s.execCb(u,f,r,n)}catch(e){i=e}else n=s.execCb(u,f,r,n);if(this.map.isDefine&&void 0===n&&((r=this.module)?n=r.exports:this.usingExports&&(n=this.exports)),i)return i.requireMap=this.map,i.requireModules=this.map.isDefine?[this.map.id]:null,i.requireType=this.map.isDefine?"define":"require",d(this.error=i)}else n=f;if(this.exports=n,this.map.isDefine&&!this.ignore&&(w[u]=n,t.onResourceLoad))t.onResourceLoad(s,this.map,this.depMaps);kt(u),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()},callPlugin:function(){var n=this.map,f=n.id,e=k(n.prefix);this.depMaps.push(e),lt(e,"defined",u(this,function(e){var l,o;o=i(fi,this.map.id);var a=this.map.name,w=this.map.parentMap?this.map.parentMap.name:null,p=s.makeRequire(n.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(e.normalize&&(a=e.normalize(a,function(n){return ut(n,w,!0)})||""),e=k(n.prefix+"!"+a,this.map.parentMap),lt(e,"defined",u(this,function(n){this.init([],function(){return n},null,{enabled:!0,ignore:!0})})),o=i(y,e.id)){if(this.depMaps.push(e),this.events.error)o.on("error",u(this,function(n){this.emit("error",n)}));o.enable()}}else o?(this.map.url=s.nameToUrl(o),this.load()):(l=u(this,function(n){this.init([],function(){return n},null,{enabled:!0})}),l.error=u(this,function(n){this.inited=!0,this.error=n,n.requireModules=[f],h(y,function(n){0===n.map.id.indexOf(f+"_unnormalized")&&kt(n.map.id)}),d(n)}),l.fromText=u(this,function(i,u){var e=n.name,o=k(e),h=b;u&&(i=u),h&&(b=!1),st(o),r(v.config,f)&&(v.config[e]=v.config[f]);try{t.exec(i)}catch(a){return d(c("fromtexteval","fromText eval for "+f+" failed: "+a,a,[f]))}h&&(b=!0),this.depMaps.push(o),s.completeLoad(e),p([e],l)}),e.load(n.name,p,l,v))})),s.enable(e,this),this.pluginMaps[e.id]=e},enable:function(){ri[this.map.id]=this,this.enabling=this.enabled=!0,f(this.depMaps,u(this,function(n,t){var f,e;if("string"==typeof n){if(n=k(n,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=n,f=i(ht,n.id)){this.depExports[t]=f(this);return}this.depCount+=1,lt(n,"defined",u(this,function(n){this.defineDep(t,n),this.check()})),this.errback&&lt(n,"error",u(this,this.errback))}f=n.id,e=y[f],r(ht,f)||!e||e.enabled||s.enable(n,this)})),h(this.pluginMaps,u(this,function(n){var t=i(y,n.id);t&&!t.enabled&&s.enable(n,this)})),this.enabling=!1,this.check()},on:function(n,t){var i=this.events[n];i||(i=this.events[n]=[]),i.push(t)},emit:function(n,t){f(this.events[n],function(n){n(t)}),"error"===n&&delete this.events[n]}},s={config:v,contextName:e,registry:y,defined:w,urlFetched:at,defQueue:rt,Module:ti,makeModuleMap:k,nextTick:t.nextTick,onError:d,configure:function(n){n.baseUrl&&"/"!==n.baseUrl.charAt(n.baseUrl.length-1)&&(n.baseUrl+="/");var t=v.shim,i={paths:!0,bundles:!0,config:!0,map:!0};h(n,function(n,t){i[t]?(v[t]||(v[t]={}),it(v[t],n,!0,!0)):v[t]=n}),n.bundles&&h(n.bundles,function(n,t){f(n,function(n){n!==t&&(fi[n]=t)})}),n.shim&&(h(n.shim,function(n,i){a(n)&&(n={deps:n}),(n.exports||n.init)&&!n.exportsFn&&(n.exportsFn=s.makeShimExports(n)),t[i]=n}),v.shim=t),n.packages&&f(n.packages,function(n){var t,n="string"==typeof n?{name:n}:n;t=n.name,n.location&&(v.paths[t]=n.location),v.pkgs[t]=n.name+"/"+(n.main||"main").replace(yt,"").replace(g,"")}),h(y,function(n,t){n.inited||n.map.unnormalized||(n.map=k(t))}),(n.deps||n.callback)&&s.require(n.deps||[],n.callback)},makeShimExports:function(t){return function(){var i;return t.init&&(i=t.init.apply(n,arguments)),i||t.exports&&ot(t.exports)}},makeRequire:function(n,u){function f(i,o,h){var a,v;return(u.enableBuildCallback&&o&&l(o)&&(o.__requireJsBuild=!0),"string"==typeof i)?l(o)?d(c("requireargs","Invalid require call"),h):n&&r(ht,i)?ht[i](y[n.id]):t.get?t.get(s,i,n,f):(a=k(i,n,!1,!0),a=a.id,r(w,a)?w[a]:d(c("notloaded",'Module name "'+a+'" has not been loaded yet for context: '+e+(n?"":". Use require([])")))):(ci(),s.nextTick(function(){ci(),v=st(k(null,n)),v.skipMap=u.skipMap,v.init(i,o,h,{enabled:!0}),dt()}),f)}return u=u||{},it(f,{isBrowser:o,toUrl:function(t){var r,i=t.lastIndexOf("."),u=t.split("/")[0];return-1!==i&&(!("."===u||".."===u)||1<i)&&(r=t.substring(i,t.length),t=t.substring(0,i)),s.nameToUrl(ut(t,n&&n.id,!0),r,!0)},defined:function(t){return r(w,k(t,n,!1,!0).id)},specified:function(t){return t=k(t,n,!1,!0).id,r(w,t)||r(y,t)}}),n||(f.undef=function(t){pt();var u=k(t,n,!0),r=i(y,t);ei(t),delete w[t],delete at[u.url],delete ui[t],tt(rt,function(n,i){n[0]===t&&rt.splice(i,1)}),r&&(r.events.defined&&(ui[t]=r.events),kt(t))}),f},enable:function(n){i(y,n.id)&&st(n).enable()},completeLoad:function(n){var u,t,f=i(v.shim,n)||{},e=f.exports;for(pt();rt.length;){if(t=rt.shift(),null===t[0]){if(t[0]=n,u)break;u=!0}else t[0]===n&&(u=!0);gt(t)}if(t=i(y,n),!u&&!r(w,n)&&t&&!t.inited){if(v.enforceDefine&&(!e||!ot(e)))return vt(n)?void 0:d(c("nodefine","No define call for "+n,null,[n]));gt([n,f.deps||[],f.exportsFn])}dt()},nameToUrl:function(n,r,u){var f,o,e;if((f=i(v.pkgs,n))&&(n=f),f=i(fi,n))return s.nameToUrl(f,r,u);if(t.jsExtRegExp.test(n))f=n+(r||"");else{for(f=v.paths,n=n.split("/"),o=n.length;0<o;o-=1)if(e=n.slice(0,o).join("/"),e=i(f,e)){a(e)&&(e=e[0]),n.splice(0,o,e);break}f=n.join("/"),f+=r||(/^data\:|\?/.test(f)||u?"":".js"),f=("/"===f.charAt(0)||f.match(/^[\w\+\.\-]+:/)?"":v.baseUrl)+f}return v.urlArgs?f+((-1===f.indexOf("?")?"?":"&")+v.urlArgs):f},load:function(n,i){t.load(s,n,i)},execCb:function(n,t,i,r){return t.apply(r,i)},onScriptLoad:function(n){("load"===n.type||bt.test((n.currentTarget||n.srcElement).readyState))&&(p=null,n=hi(n),s.completeLoad(n.id))},onScriptError:function(n){var t=hi(n);if(!vt(t.id))return d(c("scripterror","Script error for: "+t.id,n,[t.id]))}},s.require=s.makeRequire(),s}var t,v,y,k,rt,d,p,ut,e,st,at=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,vt=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,g=/\.js$/,yt=/^\.\//;v=Object.prototype;var ht=v.toString,pt=v.hasOwnProperty,wt=Array.prototype.splice,o=!!("undefined"!=typeof window&&"undefined"!=typeof navigator&&window.document),ct=!o&&"undefined"!=typeof importScripts,bt=o&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,ft="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),w={},s={},nt=[],b=!1;if("undefined"==typeof define){if("undefined"!=typeof requirejs){if(l(requirejs))return;s=requirejs,requirejs=void 0}"undefined"==typeof require||l(require)||(s=require,require=void 0),t=requirejs=function(n,r,u,f){var e,o="_";return a(n)||"string"==typeof n||(e=n,a(r)?(n=r,r=u,u=f):n=[]),e&&e.context&&(o=e.context),(f=i(w,o))||(f=w[o]=t.s.newContext(o)),e&&f.configure(e),f.require(n,r,u)},t.config=function(n){return t(n)},t.nextTick="undefined"!=typeof setTimeout?function(n){setTimeout(n,4)}:function(n){n()},require||(require=t),t.version="2.1.14",t.jsExtRegExp=/^\/|:|\?|\.js$/,t.isBrowser=o,v=t.s={contexts:w,newContext:lt},t({}),f(["toUrl","undef","defined","specified"],function(n){t[n]=function(){var t=w._;return t.require[n].apply(t,arguments)}}),o&&(y=v.head=document.getElementsByTagName("head")[0],k=document.getElementsByTagName("base")[0])&&(y=v.head=k.parentNode),t.onError=et,t.createNode=function(n){var t=n.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return t.type=n.scriptType||"text/javascript",t.charset="utf-8",t.async=!0,t},t.load=function(n,i,r){var u=n&&n.config||{};if(o)return u=t.createNode(u,i,r),u.setAttribute("data-requirecontext",n.contextName),u.setAttribute("data-requiremodule",i),u.attachEvent&&!(u.attachEvent.toString&&0>u.attachEvent.toString().indexOf("[native code"))&&!ft?(b=!0,u.attachEvent("onreadystatechange",n.onScriptLoad)):(u.addEventListener("load",n.onScriptLoad,!1),u.addEventListener("error",n.onScriptError,!1)),u.src=r,ut=u,k?y.insertBefore(u,k):y.appendChild(u),ut=null,u;if(ct)try{importScripts(r),n.completeLoad(i)}catch(f){n.onError(c("importscripts","importScripts failed for "+i+" at "+r,f,[i]))}},o&&!s.skipDataMain&&tt(document.getElementsByTagName("script"),function(n){return y||(y=n.parentNode),(rt=n.getAttribute("data-main"))?(e=rt,s.baseUrl||(d=e.split("/"),e=d.pop(),st=d.length?d.join("/")+"/":"./",s.baseUrl=st),e=e.replace(g,""),t.jsExtRegExp.test(e)&&(e=rt),s.deps=s.deps?s.deps.concat(e):[e],!0):void 0}),define=function(n,t,i){var r,u;"string"!=typeof n&&(i=t,t=n,n=null),a(t)||(i=t,t=null),!t&&l(i)&&(t=[],i.length&&(i.toString().replace(at,"").replace(vt,function(n,i){t.push(i)}),t=(1===i.length?["require"]:["require","exports","module"]).concat(t))),b&&((r=ut)||(p&&"interactive"===p.readyState||tt(document.getElementsByTagName("script"),function(n){if("interactive"===n.readyState)return p=n}),r=p),r&&(n||(n=r.getAttribute("data-requiremodule")),u=w[r.getAttribute("data-requirecontext")])),(u?u.defQueue:nt).push([n,t,i])},define.amd={jQuery:!0},t.exec=function(b){return eval(b)},t(s)}}(this);var isBeta=window.location.host.indexOf("beta.")!=-1||window.location.host.indexOf("localhost")!=-1||window.location.host.indexOf("preview")!=-1,isBranding=window.location.host.indexOf("visualcoaching")==-1||window.location.href.indexOf("branding")!=-1,isIE=~window.navigator.userAgent.indexOf("MSIE init")||~window.navigator.userAgent.indexOf("Trident/"),isPhone2=window.innerWidth<=640||window.innerHeight<=480;String.prototype.startsWith||(String.prototype.startsWith=function(n,t){return this.substr(!t||t<0?0:+t,n.length)===n}),window.location.host.indexOf("cloud.")!==-1&&window.location.protocol!=="https:"&&(window.location.protocol="https:"),safeLocalStorage={set:function(n,t){try{localStorage[n]=t}catch(i){}},get:function(n){try{return localStorage[n]}catch(t){return null}},setItem:function(n,t){try{localStorage[n]=t}catch(i){}},getItem:function(n){try{return localStorage[n]}catch(t){return null}},removeItem:function(n){try{localStorage.removeItem(n)}catch(t){}},getLength:function(){try{return localStorage.length}catch(n){return 0}},key:function(n){try{return localStorage.key(n)}catch(t){return null}},clear:function(){try{return localStorage.clear()}catch(n){return null}}},require.config({urlArgs:"bust=v16269q",waitSeconds:200,baseUrl:"/Content/Application",paths:{slickgrid:"/Content/SlickGrid-2.1.0/slick",redactor:"/Content/redactor/redactor.min",summernote:"/Content/summernote/summernote",d3:"/Content/d3/d3.min",dropzone:"/Content/dropzone/dropzone"},shim:{slickgrid:[]}}),window.onbeforeunload=function(n){for(var i=main.container,t,r;i;){if(t=i.currentController(),t&&t.simpleSave){if(t.hasChanges())return r="You have unsaved changes.",(n||window.event).returnValue=r,r}else if(t&&t.beforeUnload)return t.beforeUnload();if(t){if(i===t.container)break;i=t.container}else break}};var notStudent=ko.observable(!1),notSis=ko.observable(!1),notBrandingOrSis=ko.observable(!1),notClient=ko.observable(!1),hasShownExpiry=!1;$(function(){if(currentUserId){try{window.sessionStorage&&window.sessionStorage.currentUserId!=currentUserId&&(window.sessionStorage.clear(),window.sessionStorage.currentUserId=currentUserId)}catch(t){}try{var n=safeLocalStorage.get("user");n!=currentUser&&(safeLocalStorage.clear(),safeLocalStorage.set("user",currentUser))}catch(t){}}main=new Main,main.userId=currentUserId,main.user=currentUser,main.userDisplay=currentUserDisplay,main.userName=currentUserName,main.dateFormat=currentDateFormat,main.timeZone=currentTimeZone,main.unitFormat=currentUnitFormat,main.startup=startup,main.canAddTest=canAddTest,main.isStudent=isStudent,main.isSis=isSis,main.isClient=isClient,main.expiryDays=expiryDays,main.clipboards.clear=function(){main.clipboards.week([]),main.clipboards.session(null),main.clipboards.exercise([]),main.clipboards.text(null),main.clipboards.day(null)},notStudent(!main.isStudent),notSis(!main.isSis),notBrandingOrSis(notSis()&&!isBranding),notClient(!main.isClient),main.userDisplay||notClient(!0),$("body").addClass(window.location.host.indexOf("usaf.")!==-1?"nosvg":"usesvg"),ko.applyBindings(main),setupController(),checkExpiry(),$(document).ajaxError(function(n,t){t.status===401&&window.location.reload()})}),mp4data={}