-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.min.js
1 lines (1 loc) · 103 KB
/
index.min.js
1
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).solarSystemAnimation=e()}(this,(function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function i(t){for(var i=1;i<arguments.length;i++){var s=null!=arguments[i]?arguments[i]:{};i%2?n(Object(s),!0).forEach((function(n){e(t,n,s[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):n(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}function s(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function o(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,l=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return o=t.done,t},e:function(t){l=!0,r=t},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw r}}}}"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(t),i=1;i<arguments.length;i++){var s=arguments[i];if(null!=s)for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=s[a])}return n},writable:!0,configurable:!0}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),i=n.length>>>0;if(0===i)return!1;var s,a,r=0|e,o=Math.max(r>=0?r:i-Math.abs(r),0);for(;o<i;){if((s=n[o])===(a=t)||"number"==typeof s&&"number"==typeof a&&isNaN(s)&&isNaN(a))return!0;o++}return!1}}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),n=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var i=arguments[1],s=0;s<n;){var a=e[s];if(t.call(i,a,s,e))return a;s++}}}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),n=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var i=arguments[1],s=0;s<n;){var a=e[s];if(t.call(i,a,s,e))return s;s++}return-1}}),Object.values||(Object.values=function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=t[e[n]];return i}),Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=[e[n],t[e[n]]];return i});var l={addElement:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"div",i=e.append(n).classed("fdg-".concat(n),!0).classed("fdg-".concat(t),!0).classed("fdg-".concat(n,"--").concat(t),!0);return i},arcTween:function(t,e){return function(n){var i=d3.interpolate(n.endAngle,t);return function(t){return n.endAngle=i(t),e(n)}}},csv:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=t.join(", ");return e&&(n=n.replace(/, ([^,]*)$/," and $1")),n},mergeDeep:function e(){for(var n=function(e){return e&&"object"===t(e)},i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return s.reduce((function(t,i){return Object.keys(i).forEach((function(s){var a=t[s],r=i[s];Array.isArray(a)&&Array.isArray(r)?t[s]=r:n(a)&&n(r)?t[s]=e(a,r):t[s]=r})),t}),{})},wrap:function(t,e){t.each((function(){for(var t,n=d3.select(this),i=n.text().split(/\s+/).reverse(),s=[],a=0,r=n.style("font-size"),o=parseFloat(r),l=r.replace(o,""),c=n.attr("x"),u=n.attr("y"),d=parseFloat(n.attr("dy")),h=n.text(null).append("tspan").attr("x",c).attr("y",u).attr("dy",d+"rem");t=i.pop();)s.push(t),h.text(s.join(" ")),h.node().getComputedTextLength()>e&&(s.pop(),h.text(s.join(" ")),s=[t],h=n.append("tspan").attr("x",c).attr("y",u).attr("dy",++a*o+d+l).text(t))}))}};var c=i(i(i(i(i(i(i(i(i(i({},{id_var:"id",event_var:"event",event_order_var:"event_order",event_position_var:"event_position",start_timepoint_var:"stdy",end_timepoint_var:"endy",duration_var:"duration"}),i(i(i({},{colorBy:{type:"frequency",variable:null,label:null,mirror:!0,stratify:!0,colorScheme:"RdYlGn",colorSchemes:["blue","orange","red","purple","green","grey"],nColors:6},color:"rgb(170,170,170)",fill:null}),{sizeBy:{type:"frequency",variable:null,label:null},minRadius:null,maxRadius:10,staticRadius:null}),{shapeBy:{type:"categorical",variable:null,label:null,shapes:["circle","square","triangle","diamond","star","triangleDown"]},shape:"circle"})),{freqTable:{display:!0,title:null,columns:["label","id","event"],header:!0,bars:!0,structure:"vertical",includeEventCentral:!1,displayIndividuals:!0,countType:"id"}}),{playPause:"play",delay:5e3,speed:"medium",speeds:{slow:Math.pow(2,10),medium:Math.pow(2,8),fast:Math.pow(2,6)},speedChange:null,timepoint:0,timeUnit:"day",timeRelative:null,duration:null,loop:!0,resetDelay:15e3}),{width:{main:null,sidebar:null,canvas:null},height:{main:null},orbitRadius:null}),{manyBody:"forceManyBodyReuse",chargeStrength:null,collisionPadding:1,staticChargeStrength:null,drawStaticSeparately:!1,staticLayout:"circular"}),{modal:!0,modalSpeed:1e4,modalIndex:0,modalPosition:"center",modalWidth:"50%",explanation:["Each shape in this animation represents an individual.",'As <span class = "fdg-emphasized">time progresses</span> and individuals experience events, their shape gravitates toward the focus or "planet" representing that event.','The <span class = "fdg-emphasized">annotations</span> at each focus represent the [event-count-type].','The <span class = "fdg-emphasized">number of events</span> an individual has experienced determines the [frequency-aesthetic] of their shape.','<span class = "fdg-emphasized">Static shapes</span> represent individuals who never experience an event.','Use the <span class = "fdg-emphasized">controls</span> on the right to interact with and alter the animation.',"Continue watching to learn how these individuals progress."],information:null}),{events:null,individualUnit:"individual",individualLabel:"Individuals",eventUnit:"event",eventLabel:"Events",eventCentral:null,eventCount:!0,eventCountType:"current-id",eventChangeCount:null,eventLabelFontWeight:"bold",eventLabelFontSize:"1.5rem",eventCountFontWeight:"bold",eventCountFontSize:"1rem",eventFocusLabelChange:null}),{hideControls:!1,focusOffset:"heuristic",stratificationPositioning:"circular",annotations:null,enforceFocusVicinity:!1,stateChange:"chronological",stateChangeAnnotation:!0,displayProgress:!0,footnotes:[],root:{"left-margin":"25%"},orbitShape:"circle"}),{},{update:function(){var t=this;["frequency","continuous","categorical",null].includes(this.settings.colorBy.type)||(alert("[ '".concat(this.settings.colorBy.type,"' ] is not a valid [ colorBy.type ] setting. Please choose one of [ 'frequency' ], [ 'continuous' ], or [ 'categorical' ]. Defaulting to [ 'frequency' ].")),this.settings.colorBy.type="frequency"),["frequency","continuous",null].includes(this.settings.sizeBy.type)||(alert("[ '".concat(this.settings.sizeBy.type,"' ] is not a valid [ sizeBy.type ] setting. Please choose one of [ 'frequency' ] or [ 'continuous' ]. Defaulting to [ 'frequency' ].")),this.settings.sizeBy.type="frequency"),["categorical",null].includes(this.settings.shapeBy.type)||(alert("[ '".concat(this.settings.shapeBy.type,"' ] is not a valid [ shapeBy.type ] setting. Please choose [ 'categorical' ]. Defaulting to [ null ].")),this.settings.shapeBy.type=null),this.settings.stratify="categorical"===this.settings.colorBy.type,this.settings.colorify=null!==this.settings.colorBy.type,this.settings.sizify="frequency"===this.settings.sizeBy.type||"continuous"===this.settings.sizeBy.type&&null!==this.settings.sizeBy.variable,this.settings.shapify=null!==this.settings.shapeBy.variable,"horizontal"!==this.settings.freqTable.structure||this.settings.stratify||(this.settings.freqTable.structure="vertical"),"horizontal"===this.settings.freqTable.structure&&(this.settings.freqTable.bars=!1);var e=[];Array.isArray(this.settings.explanation)&&(this.settings.explanation=this.settings.explanation.map((function(e){return e=e.replace("[event-count-type]","current-id"===t.settings.eventCountType?"number of individuals currently experiencing the event":"cumulative-id"===t.settings.eventCountType?"number of individuals who have ever experienced the event":"total number of events"),/\[frequency-aesthetic]/.test(e)&&(e="frequency"===t.settings.colorBy.type&&"frequency"===t.settings.sizeBy.type?e.replace("[frequency-aesthetic]","color and size"):"frequency"===t.settings.colorBy.type?e.replace("[frequency-aesthetic]","color"):"frequency"===t.settings.sizeBy.type?e.replace("[frequency-aesthetic]","size"):null),e})),e=e.concat(this.settings.explanation.filter((function(e){return null!==e&&!(t.settings.hideControls&&e.includes("controls"))})))),Array.isArray(this.settings.information)&&(e=e.concat(this.settings.information)),this.settings.text=e.filter((function(t){return"string"==typeof t})),this.settings.sequences?(this.settings.loop=!1,this.settings.runSequences=!0,this.settings.animationTrack="sequence",this.settings.sequences.forEach((function(t){t.eventIndex=0}))):(this.settings.runSequences=!1,this.settings.animationTrack="full"),"ordered"===this.settings.stateChange&&(this.settings.displayProgress=!1)}});function u(t){var e=this.util.addElement("controls",t).classed("fdg-hidden",this.settings.hideControls);return{controlsContainer:e,hide:this.util.addElement("hide",e,"span")}}function d(t){var e=this.util.addElement("timer",t);return e.width=e.node().clientWidth,e.innerRadius=e.width/8,e.svg=this.util.addElement("timer__svg",e,"svg").attr("width",e.width).attr("height",e.width),e.arc=d3.arc().innerRadius(e.width/2.25).outerRadius(e.width/2-1).startAngle(0),e.g=this.util.addElement("timer__path",e.svg,"g").attr("transform","translate(".concat(e.width/2,",").concat(e.width/2,")")),e.background=this.util.addElement("timer__path",e.g,"path").classed("fdg-timer__path--background",!0).datum({endAngle:2*Math.PI}).attr("d",e.arc),e.foreground=this.util.addElement("timer__path",e.g,"path").classed("fdg-timer__path--foreground",!0).datum({endAngle:0}).attr("d",e.arc),e.percentComplete=this.util.addElement("timer__percent-complete",e.g,"text").text("0%"),e}function h(t){var e=this.settings.resetDelay/1e3;return this.util.addElement("countdown",t).classed("fdg-sidebar__label",!0).selectAll("div").data(d3.range(-1,e)).join("div").text((function(t){return"Looping in ".concat(t+1," second").concat(0===t?"":"s")})).classed("fdg-hidden",(function(t){return t!==e-1})).classed("fdg-invisible",(function(t){return t===e-1}))}function g(t){var e=this.util.addElement("sidebar",t);this.settings.width.sidebar=e.node().clientWidth;var n=this.util.addElement("events",e).html(this.settings.eventLabel),i=this.util.addElement("legends",e),s=this.util.addElement("progress",e).classed("fdg-hidden",!this.settings.displayProgress);return{sidebarContainer:e,events:n,legends:i,progress:s,timepoint:this.util.addElement("timepoint",s).classed("fdg-sidebar__label",!0).html("".concat(this.settings.timepoint," ").concat(1!==this.settings.timepoint?this.settings.timeUnit+"s":this.settings.timeUnit)),timeRelative:this.util.addElement("time-relative",s).classed("fdg-sidebar__sub-label",!0).html(this.settings.timeRelative),timer:d.call(this,s),countdown:h.call(this,s),freqTable:this.util.addElement("freq-table",e)}}function f(t){var e=this,n=this.util.addElement("animation",t);this.settings.width.canvas=n.node().clientWidth;var i=this.util.addElement("svg--background",n,"svg").attr("width",this.settings.width.main).attr("height",this.settings.height.main).style("position","absolute").style("left",-this.settings.width.sidebar).style("top",0),s=this.util.addElement("canvas",n,"canvas").attr("width",this.settings.width.canvas).attr("height",this.settings.height.main);s.context=s.node().getContext("2d");var a=this.util.addElement("svg--foreground",n,"svg").attr("width",this.settings.width.canvas).attr("height",this.settings.height.main),r=this.util.addElement("sequence-overlay",a,"g").classed("fdg-focus-annotation",!0).classed("fdg-hidden",!this.settings.stateChangeAnnotation).attr("transform","translate(20,20)");r.background=this.util.addElement("sequence-overlay__background",r,"text").classed("fdg-focus-annotation__background fdg-focus-annotation__text",!0).attr("alignment-baseline","hanging"),r.background.sequence=this.util.addElement("sequence-overlay__background__sequence",r.background,"tspan").classed("fdg-focus-annotation__label",!0).attr("x",0).attr("y",0).attr("alignment-baseline","hanging"),r.background.event=this.util.addElement("sequence-overlay__background__event",r.background,"tspan").classed("fdg-focus-annotation__event-count",!0).attr("x",0).attr("y",30).attr("alignment-baseline","hanging"),r.foreground=this.util.addElement("sequence-overlay__foreground",r,"text").classed("fdg-focus-annotation__foreground fdg-focus-annotation__text",!0).attr("alignment-baseline","hanging"),r.foreground.sequence=this.util.addElement("sequence-overlay__foreground__sequence",r.foreground,"tspan").classed("fdg-focus-annotation__label",!0).attr("x",0).attr("y",0).attr("alignment-baseline","hanging"),r.foreground.event=this.util.addElement("sequence-overlay__foreground__event",r.foreground,"tspan").classed("fdg-focus-annotation__event-count",!0).attr("x",0).attr("y",30).attr("alignment-baseline","hanging");var o=this.util.addElement("custom-annotations",a,"g"),l=this.util.addElement("focus-annotations",a,"g"),c=this.util.addElement("modal",n).attr("class",(function(t){return"fdg-modal ".concat(e.settings.modalPosition.split("-").map((function(t){return"fdg-modal--".concat(t)})).join(" ")," fdg-modal--").concat(e.settings.modalPosition)})).classed("fdg-hidden",0===this.settings.text.length).style("width",/^\d{1,3}%$/.test(this.settings.modalWidth)?this.settings.modalWidth:"50%"),u=this.util.addElement("modal__text",c),d=this.util.addElement("footnotes",n);return d.selectAll("div.fdg-footnote").data(this.settings.footnotes).join("div").classed("fdg-footnote",!0).html((function(t){return t})),{canvasContainer:n,svgBackground:i,canvas:s,svgForeground:a,sequenceOverlay:r,focusAnnotations:l,customAnnotations:o,modal:u,footnotes:d}}function y(t){var e=this;this.settings.orbitRadius=this.settings.width.canvas/(t.orbit.length+1),this.settings.center={x:this.settings.orbitRadius/2,y:this.settings.height.main/2},t.orbit.forEach((function(t,n){t.cx=e.settings.center.x,t.cy=e.settings.center.y,t.r=(n+1)*e.settings.orbitRadius,t.rx=t.r,t.ry=t.r-t.r*n/(n+2),t.rAdj=t.r,t.rAdjPrev=t.r})),t.event.forEach((function(n,i){n.radius=n.order*e.settings.orbitRadius,n.rx=n.radius;var s=t.orbit.findIndex((function(t){return t.values.includes(n)}));n.ry="circle"===e.settings.orbitShape||0===i?n.radius:n.radius-n.radius*s/(s+2),n.theta=2*Math.PI*n.position/360,n.x=0===n.order?e.settings.center.x:e.settings.center.x+n.rx*Math.cos(n.theta),n.y=0===n.order?e.settings.center.y:e.settings.center.y+n.ry*Math.sin(n.theta)}))}function v(){var t=this;this.forceSimulation&&this.forceSimulation.force("center")&&!0===this.settings.removeCenterForce&&this.forceSimulation.force("center",null),this.forceSimulation.alpha(1).force("x",d3.forceX().x((function(t){return t.value.coordinates.x})).strength(.3)).force("y",d3.forceY().y((function(t){return t.value.coordinates.y})).strength(.3)).force("collide",d3.forceCollide().radius((function(e){return e.value.size+t.settings.collisionPadding}))).restart()}function p(t,e,n){var i=void 0===e?null:e,s=function(t,e){var n=atob(t);if(e){for(var i=new Uint8Array(n.length),s=0,a=n.length;s<a;++s)i[s]=n.charCodeAt(s);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return n}(t,void 0!==n&&n),a=s.indexOf("\n",10)+1,r=s.substring(a)+(i?"//# sourceMappingURL="+i:""),o=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(o)}var m,b,x,C,B=(m="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIHNlbGYuaW1wb3J0U2NyaXB0cygnaHR0cHM6Ly9kM2pzLm9yZy9kMy1kaXNwYXRjaC52Mi5taW4uanMnKTsKICAgIHNlbGYuaW1wb3J0U2NyaXB0cygnaHR0cHM6Ly9kM2pzLm9yZy9kMy1xdWFkdHJlZS52Mi5taW4uanMnKTsKICAgIHNlbGYuaW1wb3J0U2NyaXB0cygnaHR0cHM6Ly9kM2pzLm9yZy9kMy10aW1lci52Mi5taW4uanMnKTsKICAgIHNlbGYuaW1wb3J0U2NyaXB0cygnaHR0cHM6Ly9kM2pzLm9yZy9kMy1mb3JjZS52Mi5taW4uanMnKTsgLy9zZWxmLmltcG9ydFNjcmlwdHMoJ2h0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vZDMtZm9yY2UtcmV1c2VAMS4wLjEvYnVpbGQvZDMtZm9yY2UtcmV1c2UubWluLmpzJyk7CgogICAgc2VsZi5pbXBvcnRTY3JpcHRzKCdodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2QzLWZvcmNlLXNhbXBsZWRAMS4wLjAvYnVpbGQvZDMtZm9yY2Utc2FtcGxlZC5taW4uanMnKTsKCiAgICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZlbnQpIHsKICAgICAgdmFyIF9ldmVudCRkYXRhID0gZXZlbnQuZGF0YSwKICAgICAgICAgIG5vZGVzID0gX2V2ZW50JGRhdGEubm9kZXMsCiAgICAgICAgICBsYXlvdXQgPSBfZXZlbnQkZGF0YS5sYXlvdXQsCiAgICAgICA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SxNQUFNLEdBQUcsR0FBbEMsQ0FEdEI7SUFBQSxHQUVLSyxLQUZMLENBRVcsR0FGWCxFQUVnQkYsRUFBRSxDQUFDTyxXQUFILENBQWViLFdBQVcsR0FBRyxDQUE3QixDQUZoQixFQXZCcUI7SUEyQnpCOztJQUNBSyxFQUFBQSxVQUFVLENBQUNTLElBQVgsR0E1QnlCOztJQStCekIsT0FDSSxJQUFJQyxDQUFDLEdBQUcsQ0FBUixFQUNJQyxDQUFDLEdBQUdDLElBQUksQ0FBQ0MsSUFBTCxDQUFVRCxJQUFJLENBQUNFLEdBQUwsQ0FBU2QsVUFBVSxDQUFDZSxRQUFYLEVBQVQsSUFBa0NILElBQUksQ0FBQ0UsR0FBTCxDQUFTLElBQUlkLFVBQVUsQ0FBQ2dCLFVBQVgsRUFBYixDQUE1QyxDQUZaLEVBR0lOLENBQUMsR0FBR0MsQ0FIUixFQUlJLEVBQUVELENBSk4sRUFLRTtJQUNFVixJQUFBQSxVQUFVLENBQUNpQixJQUFYO0lBQ0gsR0F0Q3dCOzs7SUF5Q3pCQyxFQUFBQSxXQUFXLENBQUM7SUFBRTFCLElBQUFBLEtBQUssRUFBTEEsS0FBRjtJQUFTTSxJQUFBQSxNQUFNLEVBQU5BLE1BQVQ7SUFBaUJDLElBQUFBLEVBQUUsRUFBRkE7SUFBakIsR0FBRCxDQUFYO0lBQ0gsQ0ExQ0Q7Ozs7OzsifQ==",x=!1,function(t){return C=C||p(m,b,x),new Worker(C,t)});function k(t,e,n,i){var s=new B;return s.postMessage({nodes:t,layout:this.settings.staticLayout,strength:this.settings.chargeStrength,orbitRadius:this.settings.orbitRadius,x:e,y:n,radius:this.settings.minRadius,id:i}),s}function I(t,e){var n=this;t.onmessage=function(t){var e="fdg-static--".concat(t.data.id.replace(/[^0-9_a-z]/gi,"-"));n.layout.svgBackground.selectAll(".".concat(e)).remove();var i=n.layout.svgBackground.insert("g",":first-child").classed("fdg-static ".concat(e),!0).attr("transform","translate(".concat(n.settings.width.sidebar,",0)"));"radial"==n.settings.staticLayout&&i.attr("transform","translate(".concat(n.settings.width.sidebar+n.settings.orbitRadius/2,",").concat(n.settings.height/2,")"));var s=i.selectAll(".fdg-static__mark").data(t.data.nodes).join("circle"===n.settings.shape?"circle":"rect").classed("fdg-static__mark",!0).attr("fill",(function(t){return t.color})).attr("fill-opacity",.25);"circle"===n.settings.shape?s.attr("cx",(function(t){return t.x})).attr("cy",(function(t){return t.y})).attr("r",t.data.radius):s.attr("x",(function(e){return e.x-t.data.radius})).attr("y",(function(e){return e.y-t.data.radius})).attr("width",2*t.data.radius).attr("height",2*t.data.radius)}}function A(){var t=this;if(this.settings.drawStaticSeparately){this.layout.svgBackground.selectAll(".fdg-static").remove();var e=this.data.nested.filter((function(t){return t.value.noStateChange})).map((function(t){return{key:t.key,colorValue:t.value.colorValue,color:t.value.color}}));if("categorical"===this.settings.colorBy.type&&this.settings.colorBy.stratify)this.metadata.event[0].foci.forEach((function(n){var i=e.filter((function(t){return t.colorValue===n.key})),s=k.call(t,i,n.x,n.y,n.key);I.call(t,s)}));else{var n=k.call(this,e,this.settings.orbitRadius/2,this.settings.height.main/2,"main");I.call(this,n)}}}function q(t,e){var n=this,i=d3.min(t,(function(t){return t.start_timepoint})),s=d3.max(t,(function(t){return t.end_timepoint})),a=t.find((function(t,e){return t.start_timepoint<=n.settings.timepoint&&n.settings.timepoint<=t.end_timepoint}));switch(!0){case void 0!==e:a=t[e];break;case this.settings.timepoint>=s:a=t[t.length-1];break;case this.settings.timepoint<i:a=t[0];break;case void 0===a:a=t.slice().sort((function(t,e){return e.start_timepoint-t.start_timepoint})).find((function(t){return t.start_timepoint<=n.settings.timepoint}))}return a}function _(t){var e=this;return t.filter((function(t){return t.start_timepoint<=e.settings.timepoint})).sort((function(t,e){return t.start_timepoint-e.start_timepoint})).filter((function(t,n,i){var s=i[n-1]?i[n-1].event:null;return!e.settings.eventChangeCount.includes(s)&&e.settings.eventChangeCount.includes(t.event)})).length}function Q(t,e){return{colorValue:"frequency"===this.settings.colorBy.type?_.call(this,t):null!==this.settings.colorBy.variable?e[this.settings.colorBy.variable]:null,sizeValue:"frequency"===this.settings.sizeBy.type?_.call(this,t):null!==this.settings.sizeBy.variable?e[this.settings.sizeBy.variable]:null,shapeValue:"frequency"===this.settings.shapeBy.type?_.call(this,t):null!==this.settings.shapeBy.variable?e[this.settings.shapeBy.variable]:null}}function S(t,e){var n=this.settings.stratify&&this.settings.colorBy.stratify?this.metadata.event.find((function(e){return e.key===t.event})).foci.find((function(t){return t.key===e})):this.metadata.event.find((function(e){return e.key===t.event}));return{x:n.x,y:n.y}}function w(t){return this.settings.stratify&&"frequency"===this.settings.sizeBy.type?this.metadata.strata.find((function(e){return e.key===t})).colorScale:this.scales.color}function F(t,e){var n=void 0!==t?t(e):"rgb(170,170,170)",i=n.replace("rgb","rgba").replace(")",", 0.5)"),s=n.replace("rgb","rgba").replace(")",", 1)");return{color:n,fill:i,stroke:s}}function L(t,e){return void 0!==t?t(e):this.settings.minRadius}function U(t,e){return void 0!==t?t(e):this.settings.shape}function E(t,e){var n=F.call(this,this.scales.color,t.colorValue),s=L.call(this,this.scales.size,t.sizeValue),a=U.call(this,this.scales.shape,t.shapeValue);return i(i({},n),{},{size:s,shape:a})}function M(t){var e=this;t.nested.forEach((function(t,n){var i,s=q.call(e,t.value.group);t.value.state!==s&&(t.value.statePrevious=t.value.state,t.value.state=s);var a=Q.call(e,t.value.group,t.value.state);t.value.colorScale=w.call(e,a.colorValue);var r=E.call(e,a,t.value.colorScale);t.value.distance=Math.sqrt(Math.pow(t.x-e.settings.center.x,2)+Math.pow(t.y-e.settings.center.y,2)),t.value.distanceFromFocus=Math.sqrt(Math.pow(t.x-t.value.coordinates.x,2)+Math.pow(t.y-t.value.coordinates.y,2)),t.value.inVicinityOfFocus=t.value.distanceFromFocus<e.settings.orbitRadius/16,t.value.transitTime++;var o=500/Math.ceil(Math.sqrt(e.settings.speeds[e.settings.speed]));(!1===e.settings.enforceFocusVicinity||t.value.inVicinityOfFocus||(null===(i=t.value.statePrevious)||void 0===i?void 0:i.event)===e.settings.eventCentral||t.value.transitTime>o)&&(t.value.transitTime=0,t.value.coordinates=S.call(e,t.value.state,a.colorValue)),Object.assign(t.value,a,r)}))}function Z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["value"],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return t.filter((function(t,i){return e.reduce((function(t,e){return t[e]}),t)===n}))}function R(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!n)return new Set(t.map((function(t){return t.key})));t.forEach((function(t){e.add(t.key)}))}function N(t,e,n,i){return t.filter((function(t){return t.start_timepoint<=e&&t.event===n&&(void 0===i||t[i.key]===i.value)})).length}function V(t,e,n){var i="cumulative-id"===this.settings.eventCountType?t.nIdsCumulative:t.nIds,s=t.nEvents,a=t!==e?t.individuals.length:n.id.length,r=t!==e?e.nEvents:e.nEventsTotal;return{idNumerator:i,eventNumerator:s,idDenominator:a,eventDenominator:r,idProportion:i/a,eventProportion:s/r}}function z(t){var e=d3.format(",d")(t.freqs.idNumerator),n=d3.format(",d")(t.freqs.eventNumerator),i=d3.format(".1%")(t.freqs.idDenominator>0?t.freqs.idProportion:0),s=d3.format(".1%")(t.freqs.eventDenominator>0?t.freqs.eventProportion:0);return{idNumerator:e,eventNumerator:n,idPercent:i,eventPercent:s,idNumeratorPercent:"".concat(e," (").concat(i,")"),eventNumeratorPercent:"".concat(n," (").concat(s,")")}}function W(t){var e=this,n=[{key:"label",label:"",value:t.label}];return"vertical"===this.settings.freqTable.structure?this.settings.freqTable.columns.forEach((function(i){"id"===i&&n.push({key:"id",label:e.settings.individualLabel,value:t.fmt.idNumeratorPercent}),"event"===i&&n.push({key:"event",label:e.settings.evetLabel,value:t.fmt.eventNumerator})})):("id"===this.settings.freqTable.countType?n.push({key:"id",label:this.settings.individualLabel,value:t.fmt.idNumeratorPercent}):n.push({key:"event",label:this.settings.eventLabel,value:t.fmt.eventNumerator}),t.foci&&t.foci.forEach((function(t){"id"===e.settings.freqTable.countType?n.push({key:"id--".concat(t.key),label:t.key,value:t.fmt.idNumeratorPercent}):n.push({key:"event--".concat(t.key),label:t.key,value:t.fmt.eventNumerator})}))),n}function G(t){var e=this;this.metadata.event.forEach((function(n){n.data=Z(t.nested,["value","state","event"],n.key),n.ids=R(n.data,n.ids),n.nIds=n.ids.size,R(n.data,n.idsCumulative,!0),n.nIdsCumulative=n.idsCumulative.size,n.nEvents=N(t,e.settings.timepoint,n.key),n.freqs=V.call(e,n,n,e.metadata),n.fmt=z.call(e,n),n.change=n.nIds-n.nIdsPrevious,n.foci&&n.foci.forEach((function(i){i.data=Z(n.data,["value","colorValue"],i.key),i.ids=R(i.data,i.ids),i.nIds=i.ids.size,R(i.data,i.idsCumulative,!0),i.nIdsCumulative=i.idsCumulative.size,i.nEvents=N(t,e.settings.timepoint,n.key,{key:e.settings.colorBy.variable,value:i.key}),i.freqs=V.call(e,i,n,e.metadata),i.fmt=z.call(e,i),i.cells=W.call(e,i),i.change=i.nIds-i.nIdsPrevious})),n.cells=W.call(e,n)}))}function J(t){this.metadata.event.forEach((function(t){t.prevCount=t.count,t.foci&&t.foci.forEach((function(t){t.prevCount=t.count}))})),M.call(this,t),G.call(this,t)}function T(){var t=this;this.settings.width.main=this.layout.main.node().clientWidth,this.settings.height.main=this.layout.main.node().clientHeight,this.settings.width.sidebar=this.layout.sidebarContainer.node().clientWidth,this.settings.width.canvas=this.layout.canvasContainer.node().clientWidth,this.layout.timer.width=this.layout.timer.node().clientWidth,this.layout.timer.svg.attr("width",this.layout.timer.width).attr("height",this.layout.timer.width),this.layout.timer.arc.innerRadius(this.layout.timer.width/2.25).outerRadius(this.layout.timer.width/2),this.layout.timer.g.attr("transform","translate(".concat(this.layout.timer.width/2,",").concat(this.layout.timer.width/2,")")),this.layout.timer.background.attr("d",this.layout.timer.arc),this.layout.timer.foreground.attr("d",this.layout.timer.arc),this.layout.svgBackground.attr("width",this.settings.width.main).attr("height",this.settings.height.main).style("left",-this.settings.width.sidebar),this.layout.canvas.attr("width",this.settings.width.canvas).attr("height",this.settings.height.main),this.layout.svgForeground.attr("width",this.settings.width.canvas).attr("height",this.settings.height.main),y.call(this,this.metadata),this.orbits.attr("cx",(function(t){return t.cx})).attr("cy",(function(t){return t.cy})).attr("r",(function(t){return t.r})),this.layout.svgBackground.select("g.fdg-g--orbits").attr("transform","translate(".concat(this.settings.width.sidebar,",0)")),"categorical"===this.settings.colorBy.type&&this.settings.colorBy.stratify&&this.metadata.event.forEach((function(e,n){e.foci.forEach((function(i,s){i.x=e.x+50*Math.cos(i.angle),i.dx=e.x+(0===n?75:50)*Math.cos(i.angle),i.y=e.y+50*Math.sin(i.angle),i.dy=e.y+(0===n?75:50)*Math.sin(i.angle),"orbital"===t.settings.stratificationPositioning&&(i.theta=e.theta+t.settings.arcLength*t.settings.offsets[s]/(2*Math.PI*e.radius)*360,i.x=0===e.order?i.x:t.settings.center.x+e.radius*Math.cos(i.theta),i.dx=i.x,i.y=0===e.order?i.y:t.settings.center.y+e.radius*Math.sin(i.theta),i.dy=i.y)})),e.fociLabels.selectAll("text.fdg-focus-annotation__text").attr("x",(function(t){return t.dx})).attr("y",(function(t){return t.dy}))})),J.call(this,this.sequence?this.sequence.data:this.data),v.call(this),A.call(this),this.focusAnnotations.attr("transform",(function(t){return"translate(".concat(t.x,",").concat(t.y,")")})),this.customAnnotations&&(this.settings.annotations.forEach((function(e){e.radius=e.orbit*t.settings.orbitRadius,e.theta=2*Math.PI*e.angle/360,e.x=t.settings.center.x+e.radius*Math.cos(e.theta),e.y=0===e.order?t.settings.center.y:t.settings.center.y+e.radius*Math.sin(e.theta)})),this.customAnnotations.attr("transform",(function(t){return"translate(".concat(t.x,",").concat(t.y,")")})))}function X(){var t=this,e=this.controls.container.append("div").classed("fdg-control--display",!0),n=e.append("div").classed("fdg-display-controls",!0).datum({state:!this.settings.minimizeControls,symbol:this.settings.minimizeControls?"+":"-"}).html((function(t){return"Controls <span class = 'fdg-expand'>".concat(t.symbol,"</span>")})).attr("title",(function(t){return t.state?"Hide controls.":"Display controls."}));return n.on("click",(function(e){e.state=!e.state,e.symbol=e.state?"-":"+",t.controls.display.inputs.html("Controls <span class = 'fdg-expand'>".concat(e.symbol,"</span>")).attr("title",(function(t){return t.state?"Hide controls.":"Display controls."})),t.controls.containers.each((function(){this.classList.toggle("fdg-control--collapsed")}))})),{container:e,inputs:n}}function Y(t){return t.transition().duration(this.settings.modalSpeed).style("opacity",0)}function O(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];e&&this.settings.sequenceIndex++;var n=this.settings.sequences[this.settings.sequenceIndex],i=this.metadata.orbit.find((function(t){return+t.key===n.start_order}));return n.events=i?i.values:[this.metadata.event.find((function(e){return e.key===t.settings.eventCentral}))],Y.call(this,this.layout.sequenceOverlay.background.sequence),Y.call(this,this.layout.sequenceOverlay.foreground.sequence),Y.call(this,this.layout.sequenceOverlay.background.event),Y.call(this,this.layout.sequenceOverlay.foreground.event),n}function j(t,e){return t.html(e).style("opacity",0).transition().duration(this.settings.modalSpeed/5).style("opacity",1)}function P(t){var e=this;return d3.nest().key((function(t){return t.id})).rollup((function(t){var n=d3.sum(t,(function(t){return t.duration})),s=1===t.length&&t[0].event===e.settings.eventCentral,a=q.call(e,t,0),r=Q.call(e,t,a),o=S.call(e,a,r.colorValue),l=Math.sqrt(Math.pow(o.x-e.settings.center.x,2)+Math.pow(o.y-e.settings.center.y,2)),c=w.call(e,r.colorValue),u=E.call(e,r,c);return i(i({index:e.metadata.id.findIndex((function(t){return t.key===a.id})),group:t,duration:n,noStateChange:s,stateprevious:null,state:a,transitTime:0},r),{},{coordinates:o,distance:l,colorScale:c},u)})).entries(t)}function H(t){return function(){return t}}function D(t,e,n,i){if(isNaN(e)||isNaN(n))return t;var s,a,r,o,l,c,u,d,h,g=t._root,f={data:i},y=t._x0,v=t._y0,p=t._x1,m=t._y1;if(!g)return t._root=f,t;for(;g.length;)if((c=e>=(a=(y+p)/2))?y=a:p=a,(u=n>=(r=(v+m)/2))?v=r:m=r,s=g,!(g=g[d=u<<1|c]))return s[d]=f,t;if(o=+t._x.call(null,g.data),l=+t._y.call(null,g.data),e===o&&n===l)return f.next=g,s?s[d]=f:t._root=f,t;do{s=s?s[d]=new Array(4):t._root=new Array(4),(c=e>=(a=(y+p)/2))?y=a:p=a,(u=n>=(r=(v+m)/2))?v=r:m=r}while((d=u<<1|c)==(h=(l>=r)<<1|o>=a));return s[h]=g,s[d]=f,t}function K(t,e,n,i,s){this.node=t,this.x0=e,this.y0=n,this.x1=i,this.y1=s}function $(t){return t[0]}function tt(t){return t[1]}function et(t,e,n){var i=new nt(null==e?$:e,null==n?tt:n,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function nt(t,e,n,i,s,a){this._x=t,this._y=e,this._x0=n,this._y0=i,this._x1=s,this._y1=a,this._root=void 0}function it(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var st=et.prototype=nt.prototype;function at(t){return function(){return t}}function rt(){var t,e,n,i,s,a,r,o,l=at(-30),c=0,u=1,d=1/0,h=function(){return 15},g=function(t){return Math.pow(t.length,.75)},f=function(t){return Math.pow(t.length,.25)},y=function(t){return t.length<100?1:t.length<200?3:Math.sqrt(t.length)},v=Math.random;function p(e){var n,i,a,r,o=Math.floor(v()*t.length),l=t[o],c=(e.x-l.x)*(e.x-l.x)+(e.y-l.y)*(e.y-l.y),u=-1/0,d=-1;if(!(e.nearest.indexOf(o)>=0))if(e.nearest.length<s)e.nearest.push(o);else{for(;++d<e.nearest.length;)n=e.nearest[d],i=t[n],(a=Math.hypot(e.x-i.x,e.y-i.y))>u&&(r=d,u=a);c<u&&(e.nearest[r]=o)}}function m(s){var a,l,c,h,g,f,y;for(l=function(e,n){n=Math.floor(n);var i,s,a,r=t.length,o=r-n;for(i=r-1;i>=o;--i)a=e[s=Math.floor(v()*i)],e[s]=e[i],e[i]=a;return e.slice(o)}(i,r),a=l.length-1;a>=0;--a)(c=t[l[a]])!==s&&((y=(g=c.x-s.x)*g+(f=c.y-s.y)*f)>=d||(0===g&&(y+=(g=1e-6*(v()-.5))*g),0===f&&(y+=(f=1e-6*(v()-.5))*f),y<u&&(y=Math.sqrt(u*y)),h=n[s.index]*e*o/y,s.vx+=g*h,s.vy+=f*h))}function b(i){var a,r,l,c,h,g,f;if(s&&p(i),r=i.nearest,s)for(a=r.length-1;a>=0;--a)(l=t[r[a]])!==i&&((f=(h=l.x-i.x)*h+(g=l.y-i.y)*g)>=d||(0===h&&(f+=(h=1e-6*(v()-.5))*h),0===g&&(f+=(g=1e-6*(v()-.5))*g),f<u&&(f=Math.sqrt(u*f)),c=n[i.index]*e*o/f,i.vx+=h*c,i.vy+=g*c))}function x(n){var i=0,r=c,o=t.length,l=c+a;for(e=n;i<o||r<l;++i,++r)r<l&&m(t[r%o]),s&&i<o&&b(t[i]);c=l%o}function C(){if(t){var c,u,d=t.length;for(i=new Array(d),c=0;c<d;++c)i[c]=c;for(n=new Array(d),s=(s=Math.min(Math.ceil(h(t)),d))<0?0:Math.min(s,t.length),a=(a=Math.ceil(g(t)))<0?0:Math.min(a,d),r=(r=Math.ceil(f(t)))<0?0:Math.min(r,d),o=y(t),e=1,c=0;c<d;++c)for(u=t[c],n[u.index]=+l(u,c,t),u.nearest=[];u.nearest.length<s;)p(u)}}return x.initialize=function(e){t=e,C()},x.strength=function(t){return arguments.length?(l="function"==typeof t?t:at(+t),C(),x):l},x.distanceMin=function(t){return arguments.length?(u=t*t,x):Math.sqrt(u)},x.distanceMax=function(t){return arguments.length?(d=t*t,x):Math.sqrt(d)},x.neighborSize=function(t){return arguments.length?(h="function"==typeof t?t:at(+t),C(),x):h},x.updateSize=function(t){return arguments.length?(g="function"==typeof t?t:at(+t),C(),x):g},x.sampleSize=function(t){return arguments.length?(f="function"==typeof t?t:at(+t),C(),x):f},x.chargeMultiplier=function(t){return arguments.length?(y="function"==typeof t?t:at(+t),C(),x):y},x.source=function(t){return arguments.length?(v=t,x):v},x}function ot(t){this.layout.canvas.context.moveTo(t.x+t.size,t.y),this.layout.canvas.context.arc(t.x,t.y,t.value.size,0,2*Math.PI),this.settings.fill&&(this.layout.canvas.context.fillStyle=t.value.fill,this.layout.canvas.context.fill()),this.layout.canvas.context.strokeStyle=t.value.stroke,this.layout.canvas.context.stroke()}function lt(t){this.layout.canvas.context.rect(t.x-t.value.size,t.y-t.value.size,2*t.value.size,2*t.value.size),this.settings.fill&&(this.layout.canvas.context.fillStyle=t.value.fill,this.layout.canvas.context.fill()),this.layout.canvas.context.strokeStyle=t.value.stroke,this.layout.canvas.context.stroke()}function ct(t){var e=this.layout.canvas.context,n=2*t.value.size/Math.sqrt(3),i=(t.x,t.y,[t.x,t.y-n]),s=[t.x-n,t.y+n],a=[t.x+n,t.y+n];e.moveTo.apply(e,i),e.lineTo.apply(e,s),e.lineTo.apply(e,a),e.lineTo.apply(e,i),this.settings.fill&&(this.layout.canvas.context.fillStyle=t.value.fill,this.layout.canvas.context.fill()),this.layout.canvas.context.strokeStyle=t.value.stroke,this.layout.canvas.context.stroke()}function ut(t){var e=this.layout.canvas.context,n=t.value.size*Math.sqrt(2);e.moveTo(t.x,t.y-n),e.lineTo(t.x+n,t.y),e.lineTo(t.x,t.y+n),e.lineTo(t.x-n,t.y),e.lineTo(t.x,t.y-n),this.settings.fill&&(this.layout.canvas.context.fillStyle=t.value.fill,this.layout.canvas.context.fill()),this.layout.canvas.context.strokeStyle=t.value.stroke,this.layout.canvas.context.stroke()}function dt(t){var e=this.layout.canvas.context,n=Math.PI/5,i=.75*t.value.size,s=1.5*t.value.size,a=Math.PI/2*3,r=t.x,o=t.y;e.beginPath(),e.moveTo(t.x,t.y-s);for(var l=0;l<5;l++)r=t.x+Math.cos(a)*s,o=t.y+Math.sin(a)*s,e.lineTo(r,o),a+=n,r=t.x+Math.cos(a)*i,o=t.y+Math.sin(a)*i,e.lineTo(r,o),a+=n;e.lineTo(t.x,t.y-s),e.closePath(),e.strokeStyle=t.value.stroke,e.stroke(),e.fillStyle=t.value.fill,e.fill()}function ht(t){var e=this.layout.canvas.context,n=2*t.value.size/Math.sqrt(3),i=(t.x,t.y,[t.x,t.y+n]),s=[t.x-n,t.y-n],a=[t.x+n,t.y-n];e.moveTo.apply(e,i),e.lineTo.apply(e,s),e.lineTo.apply(e,a),e.lineTo.apply(e,i),this.settings.fill&&(this.layout.canvas.context.fillStyle=t.value.fill,this.layout.canvas.context.fill()),this.layout.canvas.context.strokeStyle=t.value.stroke,this.layout.canvas.context.stroke()}function gt(t){var e=this;this.layout.canvas.context.clearRect(0,0,this.settings.width.canvas,this.settings.height.main),this.layout.canvas.context.save(),t.nested.sort((function(t,e){return t.value.stateChanges-e.value.stateChanges})).forEach((function(t,n){switch(e.layout.canvas.context.beginPath(),t.value.shape){case"circle":ot.call(e,t);break;case"square":lt.call(e,t);break;case"triangle":ct.call(e,t);break;case"diamond":ut.call(e,t);break;case"star":dt.call(e,t);break;case"triangleDown":ht.call(e,t);break;default:ot.call(e,t)}})),this.layout.canvas.context.restore()}function ft(t){var e=this;return d3.forceSimulation().nodes(t.nested.filter((function(t){return!(e.settings.drawStaticSeparately&&t.value.noStateChange)}))).alphaDecay(.01).velocityDecay(.9).force("center",d3.forceCenter(d3.mean(t.nested,(function(t){return t.value.coordinates.x})),d3.mean(t.nested,(function(t){return t.value.coordinates.y})))).force("x",d3.forceX().x((function(t){return t.value.coordinates.x})).strength(.3)).force("y",d3.forceY().y((function(t){return t.value.coordinates.y})).strength(.3)).force("charge","forceManyBodyReuse"===this.settings.manyBody?function(){var t,e,n,i,s,a,r,o=0,l=H(-30),c=1,u=1/0,d=.81;function h(){return 1e-6*(Math.random()-.5)}function g(t){return t.x}function f(t){return t.y}function y(s){var r,l=t.length;for(i&&!a(o,t)||(i=et(t,g,f).visitAfter(p),t.update.push(o)),n=s,r=0;r<l;++r)e=t[r],i.visit(m);++o}function v(){if(t){o=0,t.update=[],a=s(),i=null;var e,n,c=t.length;for(r=new Array(c),e=0;e<c;++e)n=t[e],r[n.index]=+l(n,e,t)}}function p(t){var e,n,i,s,a,o=0,l=0;if(t.length){for(i=s=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(o+=e.value,l+=n,i+=n*e.x,s+=n*e.y);t.x=i/l,t.y=s/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{o+=r[e.data.index]}while(e=e.next)}t.value=o}function m(t,i,s,a){if(!t.value)return!0;var o=t.x-e.x,l=t.y-e.y,g=a-i,f=o*o+l*l;if(g*g/d<f)return f<u&&(0===o&&(f+=(o=h())*o),0===l&&(f+=(l=h())*l),f<c&&(f=Math.sqrt(c*f)),e.vx+=o*t.value*n/f,e.vy+=l*t.value*n/f),!0;if(!(t.length||f>=u)){(t.data!==e||t.next)&&(0===o&&(f+=(o=h())*o),0===l&&(f+=(l=h())*l),f<c&&(f=Math.sqrt(c*f)));do{t.data!==e&&(f=(o=t.data.x-e.x)*o+(l=t.data.y-e.y)*l,0===o&&(f+=(o=h())*o),0===l&&(f+=(l=h())*l),f<c&&(f=Math.sqrt(c*f)),g=r[t.data.index]*n/f,e.vx+=o*g,e.vy+=l*g)}while(t=t.next)}}return s=function(){return function(t){return t%13==0}},y.initialize=function(e){t=e,v()},y.strength=function(t){return arguments.length?(l="function"==typeof t?t:H(+t),v(),y):l},y.distanceMin=function(t){return arguments.length?(c=t*t,y):Math.sqrt(c)},y.distanceMax=function(t){return arguments.length?(u=t*t,y):Math.sqrt(u)},y.theta=function(t){return arguments.length?(d=t*t,y):Math.sqrt(d)},y.update=function(t){return arguments.length?(a=(s=t)(),y):s},y}().strength(this.settings.chargeStrength):"forceManyBodySampled"===this.settings.manyBody?rt().strength(this.settings.chargeStrength*this.metadata.id.length/1e3):d3.forceManyBody().strength(this.settings.chargeStrength)).force("collide",d3.forceCollide().radius((function(t){return t.value.size+e.settings.collisionPadding}))).on("tick",gt.bind(this,t))}function yt(){this.layout.timepoint.text("".concat(this.settings.timepoint," ").concat(1!==this.settings.timepoint?this.settings.timeUnit+"s":this.settings.timeUnit)),this.layout.progress.attr("title","The animation is ".concat(d3.format(".1%")(this.settings.progress)," complete with ").concat(this.settings.duration-this.settings.timepoint," ").concat(this.settings.timeUnit.split(" ")[0]," to go.")),this.layout.timer.foreground.transition().duration(this.settings.speed).attrTween("d",this.util.arcTween(this.settings.progress*Math.PI*2,this.layout.timer.arc)),this.layout.timer.percentComplete.text(this.settings.progress<.0095?d3.format(".1%")(this.settings.progress):d3.format(".0%")(this.settings.progress)),this.controls.timepoint.inputs.property("value",this.settings.timepoint)}function vt(t){if(this.settings.colorify&&"categorical"===this.settings.colorBy.type){var e=d3.nest().key((function(t){return t.value.colorValue})).rollup((function(t){return t.length})).entries(t.nested);this.legends.color.counts.text((function(t){var n=e.find((function(e){return e.key===t})),i=n?n.value:0;return d3.format(",d")(i)}))}if(this.settings.shapify&&"categorical"===this.settings.shapeBy.type){var n=d3.nest().key((function(t){return t.value.shapeValue})).rollup((function(t){return t.length})).entries(t.nested);this.legends.shape.counts.text((function(t){var e=n.find((function(e){return e.key===t})),i=e?e.value:0;return d3.format(",d")(i)}))}}function pt(){var t=this;this.settings.eventCount&&this.focusAnnotations.selectAll("tspan.fdg-focus-annotation__event-count").text((function(e){return"cumulative-event"===t.settings.eventCountType?e.fmt.eventNumerator:e.fmt.idNumeratorPercent})),"categorical"===this.settings.colorBy.type&&this.settings.colorBy.stratify&&this.metadata.event.forEach((function(e){e.fociLabels.selectAll("text").text((function(e){return"cumulative-event"===t.settings.eventCountType?e.fmt.eventNumeratorPercent:e.fmt.idNumeratorPercent}))}))}function mt(){var t=this,e=d3.max(this.layout.freqTable.tr.data(),(function(t){return t.freqs.idProportion}));this.layout.freqTable.tr.each((function(n){var i=n.freqs.idProportion/e,s=d3.format(".1%")(i);d3.select(this).selectAll("td").data(n.cells).join("td").style("background",(function(e,n){return"id"===e.key&&t.settings.freqTable.bars?"linear-gradient(to right, var(--background-darkest) 0, var(--background-darkest) ".concat(s,", transparent ").concat(s,")"):null})).text((function(t){return t.value}))}))}function bt(t){var e=this;this.settings.progress="ordered"===this.settings.stateChange?(this.settings.timepoint-1)/(this.settings.duration-1):this.settings.timepoint/this.settings.duration,yt.call(this),vt.call(this,t),pt.call(this),mt.call(this),this.settings.annotations&&Array.isArray(this.settings.annotations)&&this.customAnnotations.filter((function(t){return t.timepoint<=e.settings.timepoint&&0==+d3.select(this).attr("opacity")})).transition().duration(this.settings.modalSpeed/2).attr("opacity",1)}function xt(){var t=this;this.settings.timepoint<this.settings.duration?(void 0!==this.prevEvent&&this.currEvent.orbitLabel===this.prevEvent.orbitLabel||(this.layout.sequenceOverlay.background.sequence.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){t.layout.sequenceOverlay.background.sequence.html(t.currEvent.orbitLabel||t.currEvent.key).style("opacity",0).transition().duration(t.settings.modalSpeed/5).style("opacity",1)})),this.layout.sequenceOverlay.foreground.sequence.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){t.layout.sequenceOverlay.foreground.sequence.html(t.currEvent.orbitLabel||t.currEvent.key).style("opacity",0).transition().duration(t.settings.modalSpeed/5).style("opacity",1)}))),this.currEvent.orbitLabel&&this.currEvent.key&&(this.layout.sequenceOverlay.background.event.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){t.layout.sequenceOverlay.background.event.html(t.currEvent.key).style("opacity",0).transition().duration(t.settings.modalSpeed/5).style("opacity",1)})),this.layout.sequenceOverlay.foreground.event.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){t.layout.sequenceOverlay.foreground.event.html(t.currEvent.key).style("opacity",0).transition().duration(t.settings.modalSpeed/5).style("opacity",1)})))):(this.layout.sequenceOverlay.background.sequence.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){return t.layout.sequenceOverlay.background.sequence.html(null)})),this.layout.sequenceOverlay.foreground.sequence.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){return t.layout.sequenceOverlay.foreground.sequence.html(null)})),this.layout.sequenceOverlay.background.event.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){return t.layout.sequenceOverlay.background.event.html(null)})),this.layout.sequenceOverlay.foreground.event.style("opacity",1).transition().duration(this.settings.modalSpeed/5).style("opacity",0).on("end",(function(){return t.layout.sequenceOverlay.foreground.event.html(null)})))}function Ct(){var t,e=this;"ordered"===this.settings.stateChange&&(this.prevEvent=this.currEvent,this.currEvent=this.metadata.event.find((function(t){return t.start_timepoint<=e.settings.timepoint&&e.settings.timepoint<=t.end_timepoint})),this.settings.timepoint===(null===(t=this.currEvent)||void 0===t?void 0:t.start_timepoint)&&(this.interval.stop(),xt.call(this),void 0!==this.prevEvent?this.timeout=d3.timeout((function(){e.interval=Rt.call(e,e.data)}),this.settings.modalSpeed):this.interval=Rt.call(this,this.data)))}function Bt(){var t=this;this.orbits.each((function(e){e.rAdjPrev=e.rAdj;var n=d3.merge(e.values.map((function(t){return t.data}))).map((function(t){return t.value.distance})),i=(n.length?Math.max(d3.median(n),e.r):e.r)-e.rAdjPrev;e.rAdj=isNaN(i)?e.rAdjPrev:e.rAdjPrev+Math.min(i/10,t.settings.orbitRadius/100),d3.select(this).transition().duration(t.settings.speeds[t.settings.speed]).attr("r",e.rAdj)}))}function kt(t){J.call(this,t),Bt.call(this),bt.call(this,t)}function It(){var t=this,e=this.settings.resetDelay/1e3-1;return this.layout.countdown.classed("fdg-invisible",!1).classed("fdg-hidden",(function(t){return t!==e})),d3.interval((function(){e--,t.layout.countdown.classed("fdg-hidden",(function(t){return t!==e}))}),1e3)}function At(t){d3.select(this).transition().duration(t/15).delay(t-t/15*2).style("opacity",0)}function qt(t,e){t.style("opacity",0).transition().duration(e/15).style("opacity",1).on("end",(function(){At.call(this,e)}))}function _t(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"outline",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"thick groove rgba(215,25,28,0)",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"thick groove rgba(215,25,28,.5)",s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];s?t.style(e,n).transition().duration(this.settings.modalSpeed/15).style(e,i).transition().duration(this.settings.modalSpeed/15).delay(this.settings.modalSpeed-this.settings.modalSpeed/15*2).style(e,n).on("end",(function(){return t.style(e,null)})):(t.style(e,i),d3.timeout((function(){t.style(e,null)}),this.settings.modalSpeed))}function Qt(){switch(this.modalText=this.settings.text[this.settings.modalIndex],this.settings.modalIndex===this.settings.text.length-1&&this.modal&&this.modal.stop(),this.layout.modal.html(this.modalText).call(qt,this.settings.modalSpeed),!0){case/time/i.test(this.modalText):_t.call(this,this.layout.progress);break;case/annotations/i.test(this.modalText):_t.call(this,this.layout.focusAnnotations.selectAll(".fdg-focus-annotation__event-count"));break;case/number of events.*color/i.test(this.modalText):_t.call(this,this.legends.color);break;case/number of events.*size/i.test(this.modalText):_t.call(this,this.legends.size);break;case/static/i.test(this.modalText):_t.call(this,this.layout.svgBackground.selectAll(".fdg-static__mark"),"stroke","rgba(215,25,28,0)","rgba(215,25,28,.5)",!1);break;case/controls/i.test(this.modalText):!1===this.settings.hideControls&&_t.call(this,this.layout.controlsContainer.classed("fdg-hidden",this.settings.hideControls))}}function St(){var t=this;Qt.call(this),this.modal=d3.interval((function(){t.settings.modalIndex++,Qt.call(t)}),this.settings.modalSpeed)}function wt(t){var e=this;this.settings.timepoint=0,this.settings.progress=0,this.settings.modalIndex=0,this.controls.timepoint.inputs.attr("value",0),this.settings.runSequences&&(this.settings.sequenceIndex=0,this.settings.eventIndex=0,this.sequence=O.call(this,!1)),this.metadata.event.forEach((function(t){t.prevCount=0,t.count=0,t.cumulative=0,t.ids=new Set,t.nIds=0,t.idsCumulative=new Set,t.nIdsCumulative=0})),t.nested.forEach((function(t){t.value.statePrevious=null,t.value.state=q.call(e,t.value.group);var n=Q.call(e,t.value.group,t.value.state);t.value.coordinates=S.call(e,t.value.state,n.colorValue),t.value.colorScale=w.call(e,n.colorValue);var i=E.call(e,n,t.value.colorScale);Object.assign(t.value,n,i)})),this.modal&&this.modal.stop(),St.call(this),this.settings.annotations&&Array.isArray(this.settings.annotations)&&this.customAnnotations.attr("opacity",(function(t){return t.timepoint>e.settings.timepoint?0:1}))}function Ft(t,e){var n=this;this.timeout&&this.timeout.stop();var i=d3.timeout((function(){wt.call(n,t),yt.call(n),e.stop(),i.stop(),n.layout.countdown.classed("fdg-invisible",(function(t){return t===n.settings.resetDelay/1e3-1})).classed("fdg-hidden",(function(t){return t!==n.settings.resetDelay/1e3-1})),n.interval=Rt.call(n,t)}),this.settings.resetDelay);return i}function Lt(t){this.interval.stop(),v.call(this);var e=It.call(this);this.timeout=Ft.call(this,t,e)}function Ut(){var t=this;this.sequence.eventIndex++;var e=this.sequence.events.find((function(e,n){return n===t.sequence.eventIndex}));return Y.call(this,this.layout.sequenceOverlay.background.event),Y.call(this,this.layout.sequenceOverlay.foreground.event),e}function Et(){Y.call(this,this.layout.sequenceOverlay.background.sequence),Y.call(this,this.layout.sequenceOverlay.foreground.sequence),Y.call(this,this.layout.sequenceOverlay.background.event),Y.call(this,this.layout.sequenceOverlay.foreground.event)}function Mt(){this.interval&&this.interval.stop(),this.settings.sequenceIndex<this.settings.sequences.length-1||this.sequence.events&&this.sequence.eventIndex<this.sequence.events.length-1?(this.sequence.eventIndex===this.sequence.events.length-1?this.sequence=O.call(this):this.sequence.event=Ut.call(this),this.timeout=Nt.call(this)):Et.call(this)}st.copy=function(){var t,e,n=new nt(this._x,this._y,this._x0,this._y0,this._x1,this._y1),i=this._root;if(!i)return n;if(!i.length)return n._root=it(i),n;for(t=[{source:i,target:n._root=new Array(4)}];i=t.pop();)for(var s=0;s<4;++s)(e=i.source[s])&&(e.length?t.push({source:e,target:i.target[s]=new Array(4)}):i.target[s]=it(e));return n},st.add=function(t){var e=+this._x.call(null,t),n=+this._y.call(null,t);return D(this.cover(e,n),e,n,t)},st.addAll=function(t){var e,n,i,s,a=t.length,r=new Array(a),o=new Array(a),l=1/0,c=1/0,u=-1/0,d=-1/0;for(n=0;n<a;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(s=+this._y.call(null,e))||(r[n]=i,o[n]=s,i<l&&(l=i),i>u&&(u=i),s<c&&(c=s),s>d&&(d=s));if(l>u||c>d)return this;for(this.cover(l,c).cover(u,d),n=0;n<a;++n)D(this,r[n],o[n],t[n]);return this},st.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,i=this._y0,s=this._x1,a=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,a=(i=Math.floor(e))+1;else{for(var r,o,l=s-n,c=this._root;n>t||t>=s||i>e||e>=a;)switch(o=(e<i)<<1|t<n,(r=new Array(4))[o]=c,c=r,l*=2,o){case 0:s=n+l,a=i+l;break;case 1:n=s-l,a=i+l;break;case 2:s=n+l,i=a-l;break;case 3:n=s-l,i=a-l}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=i,this._x1=s,this._y1=a,this},st.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},st.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},st.find=function(t,e,n){var i,s,a,r,o,l,c,u=this._x0,d=this._y0,h=this._x1,g=this._y1,f=[],y=this._root;for(y&&f.push(new K(y,u,d,h,g)),null==n?n=1/0:(u=t-n,d=e-n,h=t+n,g=e+n,n*=n);l=f.pop();)if(!(!(y=l.node)||(s=l.x0)>h||(a=l.y0)>g||(r=l.x1)<u||(o=l.y1)<d))if(y.length){var v=(s+r)/2,p=(a+o)/2;f.push(new K(y[3],v,p,r,o),new K(y[2],s,p,v,o),new K(y[1],v,a,r,p),new K(y[0],s,a,v,p)),(c=(e>=p)<<1|t>=v)&&(l=f[f.length-1],f[f.length-1]=f[f.length-1-c],f[f.length-1-c]=l)}else{var m=t-+this._x.call(null,y.data),b=e-+this._y.call(null,y.data),x=m*m+b*b;if(x<n){var C=Math.sqrt(n=x);u=t-C,d=e-C,h=t+C,g=e+C,i=y.data}}return i},st.remove=function(t){if(isNaN(a=+this._x.call(null,t))||isNaN(r=+this._y.call(null,t)))return this;var e,n,i,s,a,r,o,l,c,u,d,h,g=this._root,f=this._x0,y=this._y0,v=this._x1,p=this._y1;if(!g)return this;if(g.length)for(;;){if((c=a>=(o=(f+v)/2))?f=o:v=o,(u=r>=(l=(y+p)/2))?y=l:p=l,e=g,!(g=g[d=u<<1|c]))return this;if(!g.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(n=e,h=d)}for(;g.data!==t;)if(i=g,!(g=g.next))return this;return(s=g.next)&&delete g.next,i?(s?i.next=s:delete i.next,this):e?(s?e[d]=s:delete e[d],(g=e[0]||e[1]||e[2]||e[3])&&g===(e[3]||e[2]||e[1]||e[0])&&!g.length&&(n?n[h]=g:this._root=g),this):(this._root=s,this)},st.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},st.root=function(){return this._root},st.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},st.visit=function(t){var e,n,i,s,a,r,o=[],l=this._root;for(l&&o.push(new K(l,this._x0,this._y0,this._x1,this._y1));e=o.pop();)if(!t(l=e.node,i=e.x0,s=e.y0,a=e.x1,r=e.y1)&&l.length){var c=(i+a)/2,u=(s+r)/2;(n=l[3])&&o.push(new K(n,c,u,a,r)),(n=l[2])&&o.push(new K(n,i,u,c,r)),(n=l[1])&&o.push(new K(n,c,s,a,u)),(n=l[0])&&o.push(new K(n,i,s,c,u))}return this},st.visitAfter=function(t){var e,n=[],i=[];for(this._root&&n.push(new K(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var s=e.node;if(s.length){var a,r=e.x0,o=e.y0,l=e.x1,c=e.y1,u=(r+l)/2,d=(o+c)/2;(a=s[0])&&n.push(new K(a,r,o,u,d)),(a=s[1])&&n.push(new K(a,u,o,l,d)),(a=s[2])&&n.push(new K(a,r,d,u,c)),(a=s[3])&&n.push(new K(a,u,d,l,c))}i.push(e)}for(;e=i.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},st.x=function(t){return arguments.length?(this._x=t,this):this._x},st.y=function(t){return arguments.length?(this._y=t,this):this._y};var Zt=function(t,e){var n=this;if(this.settings.timepoint+=!!e,Array.isArray(this.settings.speedChange)&&this.settings.speedChange.map((function(t){return t.timepoint})).includes(this.settings.timepoint)&&(this.settings.speed=this.settings.speedChange.find((function(t){return t.timepoint===n.settings.timepoint})).speed,this.interval&&this.interval.stop(),this.interval=Rt.call(this,this.sequence?this.sequence.data:this.data)),Array.isArray(this.settings.eventFocusLabelChange)&&this.settings.eventFocusLabelChange.map((function(t){return t.timepoint})).includes(this.settings.timepoint)){var i=this.settings.eventFocusLabelChange.find((function(t){return t.timepoint===n.settings.timepoint}));this.focusAnnotations.filter((function(t){return t.key===i.old_label})).selectAll(".fdg-focus-annotation__label tspan").text(i.new_label)}Ct.call(this),this.settings.timepoint<=this.settings.duration?kt.call(this,t):this.sequence?Mt.call(this):!0===this.settings.loop&&Lt.call(this,t),v.call(this)};function Rt(t){return d3.interval(Zt.bind(this,t),this.settings.speeds[this.settings.speed])}function Nt(){var t=this;this.controls.sequences.inputs.classed("fdg-button--current",(function(e){return e.label===t.sequence.label})),this.sequence.event=this.sequence.events.find((function(e,n){return n===t.sequence.eventIndex})),this.settings.timepoint=0,this.layout.timepoint.html("0 days"),this.layout.timer.percentComplete.html("0%"),0===this.sequence.eventIndex&&(this.layout.timeRelative.html(this.sequence.timeRelative||this.settings.timeRelative),this.sequence.backgroundSequence=j.call(this,this.layout.sequenceOverlay.background.sequence,this.sequence.label),this.sequence.foregroundSequence=j.call(this,this.layout.sequenceOverlay.foreground.sequence,this.sequence.label)),this.sequence.backgroundEvent=j.call(this,this.layout.sequenceOverlay.background.event,"".concat(this.settings.individualUnit.replace(/^(.)/,(function(t){return t.toUpperCase()})),"s: ").concat(this.sequence.event.key)),this.sequence.foregroundEvent=j.call(this,this.layout.sequenceOverlay.foreground.event,"".concat(this.settings.individualUnit.replace(/^(.)/,(function(t){return t.toUpperCase()})),"s: ").concat(this.sequence.event.key)),0===this.sequence.eventIndex&&(this.sequence.data=this.data.filter((function(e){return t.sequence.start_order<=e.event_order&&e.event_order<=t.sequence.end_order})).map((function(t){return i({},t)}))),0===this.sequence.eventIndex&&d3.nest().key((function(t){return t.id})).rollup((function(e){var n=e[0],i=n.start_timepoint,s=0;return e.forEach((function(e,a){s+=e.duration,e.duration_cumulative=s,e.start_timepoint=e===n?1:e.start_timepoint-i+1,e.end_timepoint=e.start_timepoint+e.duration-1,t.sequence.duration&&e.start_timepoint>t.sequence.duration&&(e.start_timepoint=t.sequence.duration),t.sequence.duration&&e.end_timepoint>t.sequence.duration&&(e.end_timepoint=t.sequence.duration)})),e})).entries(this.sequence.data),0===this.sequence.eventIndex&&(this.sequence.data.nested=P.call(this,this.sequence.data),this.sequence.data.nested.forEach((function(e){var n=t.nodes.find((function(t){return t.key===e.key}));for(var i in n)!1===["key","value"].includes(i)&&(e[i]=n[i])}))),this.sequence.data.nested.forEach((function(e){e.value.locked=e.value.state.event!==t.sequence.event.key}));var e=d3.max(this.sequence.data.nested.filter((function(t){return!1===t.value.locked})),(function(t){return t.value.state.duration}))+1;return this.settings.duration=this.sequence.duration?Math.min(this.sequence.duration,e):e,this.forceSimulation&&this.forceSimulation.stop(),this.forceSimulation=ft.call(this,this.sequence.data),this.nodes=this.forceSimulation.nodes(),this.forceSimulation.force("center",null),J.call(this,this.sequence.data),bt.call(this,this.sequence.data),this.interval&&this.interval.stop(),d3.timeout((function(){t.interval=Rt.call(t,t.sequence.data)}),this.settings.modalSpeed)}function Vt(t){var e=this;this.settings.animationTrack="sequence",this.layout.sequenceOverlay.classed("fdg-hidden",!1),this.settings.sequenceIndex=this.settings.sequences.findIndex((function(e){return e===t})),this.sequence=O.call(this,!1),this.sequence.eventIndex=0,this.timeout=d3.timeout((function(){Nt.call(e)}),1e3)}var zt=[{action:"play",label:"Play",html:"►"},{action:"pause",label:"Pause",html:"❚❚"}];function Wt(){var t=this;this.settings.playPause=zt.find((function(e){return e.action!==t.settings.playPause})).action,this.controls.playPause.inputs.attr("title","".concat(zt.find((function(e){return e.action!==t.settings.playPause})).label," animation")).html(zt.find((function(e){return e.action!==t.settings.playPause})).html),this.interval&&this.interval.stop(),"play"===this.settings.playPause&&(this.interval=Rt.call(this,this.sequence?this.sequence.data:this.data))}function Gt(t){var e=this;console.log("full animation"),this.settings.animationTrack="full",this.settings.duration=this.settings_initial.duration,this.settings.loop=this.settings_initial.loop,this.layout.sequenceOverlay.classed("fdg-hidden",!0),this.layout.timeRelative.html(this.settings_initial.timeRelative),this.interval&&this.interval.stop(),this.forceSimulation&&this.forceSimulation.stop(),this.forceSimulation=ft.call(this,this.data),wt.call(this,this.data),this.timeout=d3.timeout((function(){e.interval=Rt.call(e,e.data)}),1e3),"play"!==this.settings.playPause&&Wt.call(this)}function Jt(){var t=this;if(this.settings.sequences){var e=this,n=this.util.addElement("sequences",this.layout.controls).classed("fdg-control fdg-control--sequences",!0),i=n.selectAll("div").data([this].concat(s(this.settings.sequences))).join("div").classed("fdg-button fdg-button--sequence",!0).attr("title",(function(e){return"View ".concat(e!==t?"sequence ".concat(e.label):"full animation",".")})).text((function(e,n){return e.label?e.label:e===t?"Full Animation":"Sequence ".concat(n+1)}));return i.on("click",(function(t){i.classed("fdg-button--current",!1),this.classList.toggle("fdg-button--current"),e.interval&&e.interval.stop(),e.timeout&&e.timeout.stop(),delete e.sequence,e.sequence=t!==e?t:null,t!==e?Vt.call(e,t):Gt.call(e,t)})),{container:n,inputs:i}}}function Tt(){if(this.settings.sequences){var t=this.util.addElement("sequences",this.layout.controls).classed("fdg-control fdg-control--step-sequences",!0),e=t.selectAll("div").data(["<<",">>"]).join("div").classed("fdg-button fdg-button--step-sequence",!0).attr("title",(function(t){return"<<"===t?"View previous sequence.":"View next sequence."})).style("width","35%").style("float",(function(t,e){return 0===e?"left":"right"})).text((function(t,e){return t}));return e.on("click",(function(t){})),{container:t,inputs:e}}}function Xt(){var t=this,e=this,n=this.controls.container.append("div").classed("fdg-control fdg-control--speed",!0),i=n.selectAll("div").data(Object.keys(this.settings.speeds).map((function(e){return{label:e,value:t.settings.speeds[e]}}))).enter().append("div").attr("class",(function(e){return"fdg-button ".concat(e.label," ").concat(e.label===t.settings.speed?"fdg-button--current":"")})).attr("title",(function(e){return"Advance the animation every ".concat(t.settings.speeds[e.label]/1e3," second(s).")})).text((function(t){return t.label}));return i.on("click",(function(t){e.settings.speed=t.label,i.classed("fdg-button--current",(function(e){return e.label===t.label})),"play"===e.settings.playPause&&(e.interval&&e.interval.stop(),e.interval=Rt.call(e,e.sequence?e.sequence.data:e.data))})),{container:n,inputs:i}}function Yt(){var t=this,e=this.controls.container.append("div").classed("fdg-control fdg-control--play-pause",!0),n=e.append("div").classed("fdg-button fdg-input",!0).attr("title","".concat(zt.find((function(e){return e.action!==t.settings.playPause})).label," animation.")).html(zt.find((function(e){return e.action!==t.settings.playPause})).html);return n.on("click",(function(){t.timeout&&t.timeout.stop(),Wt.call(t)})),{container:e,inputs:n}}function Ot(){var t=this,e=this,n=this.controls.container.append("div").classed("fdg-control fdg-control--timepoint",!0).classed("fdg-hidden","ordered"===this.settings.stateChange),i=n.append("div").classed("fdg-button fdg-input",!0).append("input").attr("type","number").attr("title","Choose a timepoint.").attr("value",+this.settings.timepoint).attr("min",1).attr("max",this.settings.duration);return i.on("click",(function(){"pause"!==t.settings.playPause&&Wt.call(t)})),i.on("change",(function(){"pause"!==e.settings.playPause&&Wt.call(e),e.settings.timepoint=+this.value-1,Zt.call(e,e.sequence?e.sequence.data:e.data,!0)})),{container:n,inputs:i}}function jt(){var t=this,e=this.controls.container.append("div").classed("fdg-control fdg-control--reset",!0),n=e.append("div").classed("fdg-button fdg-input",!0).attr("title","Reset animation.").html("↺");return n.on("click",(function(){t.timeout&&t.timeout.stop(),t.interval&&t.interval.stop(),t.settings.runSequences&&(t.settings.sequences.forEach((function(t){t.eventIndex=0})),t.settings.sequenceIndex=0,t.sequence=O.call(t,!1)),wt.call(t,"sequence"===t.settings.animationTrack?t.sequence.data:t.data),t.forceSimulation&&t.forceSimulation.stop(),t.forceSimulation=ft.call(t,"sequence"===t.settings.animationTrack?t.sequence.data:t.data),"play"===t.settings.playPause&&(t.timeout=d3.timeout((function(){"sequence"===t.settings.animationTrack?Nt.call(t):t.interval=Rt.call(t,t.data)}),1e3))})),{container:e,inputs:n}}function Pt(){var t,e,n=this;if("frequency"===this.settings.colorBy.type||"frequency"===this.settings.sizeBy.type){var i=this;(e=(t=this.controls.container.append("div").classed("fdg-control fdg-control--event-list",!0)).selectAll("div").data(this.metadata.event).enter().append("div").attr("class",(function(t){return"fdg-button ".concat(n.settings.eventChangeCount.includes(t.key)?"fdg-button--current":"")})).attr("title",(function(t){return"".concat(n.settings.eventChangeCount.includes(t.key)?"Remove":"Add"," ").concat(t.key," ").concat(n.settings.eventChangeCount.includes(t.key)?"from":"to"," the list of events that control bubble ").concat("frequency"===n.settings.colorBy.type&&"frequency"===n.settings.sizeBy.type?"color and size":"frequency"===n.settings.colorBy.type?"color":"frequency"===n.settings.sizeBy.type?"size":"[ something isn't right here ].",".")})).text((function(t){return t.key}))).on("click",(function(t){var e=this;this.classList.toggle("fdg-button--current"),i.settings.eventChangeCount.includes(this.textContent)?i.settings.eventChangeCount.splice(i.settings.eventChangeCount.findIndex((function(t){return t===e.textContent})),1):i.settings.eventChangeCount.push(this.textContent),this.title="".concat(i.settings.eventChangeCount.includes(t.key)?"Remove":"Add"," ").concat(t.key," ").concat(i.settings.eventChangeCount.includes(t.key)?"from":"to"," the list of events that control bubble ").concat("frequency"===i.settings.colorBy.type&&"frequency"===i.settings.sizeBy.type?"color and size":"frequency"===i.settings.colorBy.type?"color":"frequency"===i.settings.sizeBy.type?"size":"[ something isn't right here ].","."),i.legends.container.classed("fdg-invisible",0===i.settings.eventChangeCount.length).selectAll("span.fdg-measure").text(i.util.csv(i.settings.eventChangeCount)),Zt.call(i,i.data,!1)}))}return{container:t,inputs:e}}function Ht(){this.controls={container:this.layout.controlsContainer},this.controls.display=X.call(this),this.controls.playPause=Yt.call(this),this.controls.timepoint=Ot.call(this),this.controls.sequences=Jt.call(this),this.controls.stepSequences=Tt.call(this),this.controls.speed=Xt.call(this),this.controls.reset=jt.call(this),this.controls.eventList=Pt.call(this),this.controls.containers=this.controls.container.selectAll(".fdg-control"),this.controls.buttons=this.controls.container.selectAll(".fdg-button"),this.controls.container.selectAll(".fdg-button").on("mousedown",(function(){this.classList.toggle("fdg-button--clicked")})).on("mouseup",(function(){this.classList.toggle("fdg-button--clicked")})).on("mouseout",(function(){this.classList.contains("fdg-button--clicked")&&this.classList.toggle("fdg-button--clicked")})),this.controls.containers.each((function(){this.classList.toggle("fdg-control--collapsed")}))}var Dt={color:function(t,e){var n=this;return t.selectAll("rect.legend-mark").data(this.scales.color.range()).enter().append("rect").classed("legend-mark",!0).attr("x",(function(t,i){return i*(e[0]/n.settings.colorBy.nColors)})).attr("y",0).attr("width",e[0]/this.settings.colorBy.nColors).attr("height",e[1]/3).attr("fill",(function(t){return t})).attr("fill-opacity",.5).attr("stroke",(function(t){return t})).attr("stroke-opacity",1)},size:function(t,e){var n=this,i=t.selectAll("circle.legend-mark").data(d3.range(this.settings.colorBy.nColors)).join("circle"===this.settings.shape?"circle":"rect").classed("legend-mark",!0).attr("fill",(function(t){return"#aaa"})).attr("fill-opacity",.5).attr("stroke",(function(t){return"#aaa"})).attr("stroke-opacity",1);return"circle"===this.settings.shape?i.attr("cx",(function(t,i){return i*(e[0]/n.settings.colorBy.nColors)+e[0]/n.settings.colorBy.nColors/2})).attr("cy",e[1]/4).attr("r",(function(t,e){return e+n.settings.minRadius})):"square"===this.settings.shape&&i.attr("x",(function(t,i){return i*(e[0]/n.settings.colorBy.nColors)+e[0]/n.settings.colorBy.nColors/2-(i+n.settings.minRadius)})).attr("y",(function(t,i){return e[1]/4-(i+n.settings.minRadius)})).attr("width",(function(t,e){return 2*(e+n.settings.minRadius)})).attr("height",(function(t,e){return 2*(e+n.settings.minRadius)})),i},both:function(t,e){var n=this,i=t.selectAll("circle.legend-mark").data(this.scales.color.range()).join("circle"===this.settings.shape?"circle":"rect").classed("legend-mark",!0).attr("fill",(function(t){return t})).attr("fill-opacity",.5).attr("stroke",(function(t){return t})).attr("stroke-opacity",1);return"circle"===this.settings.shape?i.attr("cx",(function(t,i){return i*(e[0]/n.settings.colorBy.nColors)+e[0]/n.settings.colorBy.nColors/2})).attr("cy",e[1]/4).attr("r",(function(t,e){return e+n.settings.minRadius})):"square"===this.settings.shape&&i.attr("x",(function(t,i){return i*(e[0]/n.settings.colorBy.nColors)+e[0]/n.settings.colorBy.nColors/2-(i+n.settings.minRadius)})).attr("y",(function(t,i){return e[1]/4-(i+n.settings.minRadius)})).attr("width",(function(t,e){return 2*(e+n.settings.minRadius)})).attr("height",(function(t,e){return 2*(e+n.settings.minRadius)})),i}};function Kt(t){var e=[200,50],n=this.legends.container.append("div"),i=(n.append("div").classed("fdg-sidebar__label fdg-legend__label",!0).html("Number of events"),n.append("svg").attr("width",e[0]).attr("height",e[1]).append("g").attr("transform","translate(".concat(this.legends.svgWidth/2-this.legends.radius-6,",0)")));Dt[t].call(this,i,e),i.append("text").attr("x",e[0]/this.settings.colorBy.nColors/2).attr("y",e[1]/2+16).attr("text-anchor","middle").html("0"),i.append("text").attr("x",e[0]-e[0]/this.settings.colorBy.nColors/2).attr("y",e[1]/2+16).attr("text-anchor","middle").html("".concat(this.settings.colorBy.nColors-1,"+"));return n}function $t(){var t;return"frequency"===this.settings.colorBy.type&&"frequency"===this.settings.sizeBy.type?t=Kt.call(this,"both"):"frequency"===this.settings.colorBy.type?t=Kt.call(this,"color"):"frequency"===this.settings.sizeBy.type&&(t=Kt.call(this,"size")),t}function te(t,e){var n=this.legends.container.append("div");return n.table=n.append("table"),n.header=n.table.append("thead").append("tr").selectAll("th").data([t,"n"]).join("th").attr("class",(function(t,e){return 0===e?"fdg-sidebar__label fdg-legend__label":null})).attr("colspan",(function(t,e){return 0===e?2:null})).style("text-align",(function(t,e){return 0===e?"left":"right"})).html((function(t){return t})),n.rows=n.table.append("tbody").selectAll("tr").data(e).join("tr"),n.symbols=n.rows.append("td").append("svg").style("width",this.legends.svgWidth).style("height",this.legends.svgHeight).append("g").attr("transform","translate(0,2)"),n.labels=n.rows.append("td").html((function(t){return t})),n.counts=n.rows.append("td"),n}function ee(){var t=this,e=te.call(this,this.settings.colorBy.label,this.scales.color.domain());return e.symbols.append("circle").attr("cx",this.legends.svgWidth/2).attr("cy",this.legends.svgHeight/2).attr("r",this.legends.radius).attr("fill",(function(e){return t.scales.color(e)})),e.counts.text((function(e){return d3.format(",d")(t.metadata.id.filter((function(t){return t.colorStratum===e})).length)})),e}function ne(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:256,n=document.createElement("canvas");n.width=e,n.height=1;for(var i=n.getContext("2d"),s=0;s<e;++s)i.fillStyle=t(s/(e-1)),i.fillRect(s,0,1,1);return n}function ie(){var t=this.legends.container.append("div");return t.node().appendChild(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.color,i=e.title,s=e.tickSize,a=void 0===s?6:s,r=e.width,o=void 0===r?320:r,l=e.height,c=void 0===l?44+a:l,u=e.marginTop,d=void 0===u?18:u,h=e.marginRight,g=void 0===h?0:h,f=e.marginBottom,y=void 0===f?16+a:f,v=e.marginLeft,p=void 0===v?0:v,m=e.ticks,b=void 0===m?o/64:m,x=e.tickFormat,C=e.tickValues,B=d3.create("svg").attr("width",o).attr("height",c).attr("viewBox",[0,0,o,c]).style("overflow","visible"),k=function(t){return t.selectAll(".tick line").attr("y1",d+y-c)};if(n.interpolate){var I=Math.min(n.domain().length,n.range().length);t=n.copy().rangeRound(d3.quantize(d3.interpolate(p,o-g),I)),B.append("image").attr("x",p).attr("y",d).attr("width",o-p-g).attr("height",c-d-y).attr("preserveAspectRatio","none").attr("xlink:href",ne.call(this,n.copy().domain(d3.quantize(d3.interpolate(0,1),I))).toDataURL())}else if(n.interpolator){if(t=Object.assign(n.copy().interpolator(d3.interpolateRound(p,o-g)),{range:function(){return[p,o-g]}}),B.append("image").attr("x",p).attr("y",d).attr("width",o-p-g).attr("height",c-d-y).attr("preserveAspectRatio","none").attr("xlink:href",ne.call(this,n.interpolator()).toDataURL()),!t.ticks){if(void 0===C){var A=Math.round(b+1);C=d3.range(A).map((function(t){return d3.quantile(n.domain(),t/(A-1))}))}"function"!=typeof x&&(x=d3.format(void 0===x?",f":x))}}else if(n.invertExtent){var q=n.thresholds?n.thresholds():n.quantiles?n.quantiles():n.domain(),_=void 0===x?function(t){return t}:"string"==typeof x?d3.format(x):x;t=d3.scaleLinear().domain([-1,n.range().length-1]).rangeRound([p,o-g]),B.append("g").selectAll("rect").data(n.range()).join("rect").attr("x",(function(e,n){return t(n-1)})).attr("y",d).attr("width",(function(e,n){return t(n)-t(n-1)})).attr("height",c-d-y).attr("fill",(function(t){return t})),C=d3.range(q.length),x=function(t){return _(q[t],t)}}else t=d3.scaleBand().domain(n.domain()).rangeRound([p,o-g]),B.append("g").selectAll("rect").data(n.domain()).join("rect").attr("x",t).attr("y",d).attr("width",Math.max(0,t.bandwidth()-1)).attr("height",c-d-y).attr("fill",n),k=function(){};return B.append("g").attr("transform","translate(0,".concat(c-y,")")).call(d3.axisBottom(t).ticks(b,"string"==typeof x?x:void 0).tickFormat("function"==typeof x?x:void 0).tickSize(a).tickValues(C)).call(k).call((function(t){return t.select(".domain").remove()})).call((function(t){return t.append("text").classed("fdg-sidebar__label fdg-legend__label",!0).attr("x",p).attr("y",d+y-c-6).attr("fill","currentColor").attr("text-anchor","middle").attr("transform","translate(".concat(o/2,",0)")).attr("font-weight","bold").attr("font-size","1.25rem").html(i)})),B.node()}({color:this.scales.color,title:this.settings.colorBy.label,width:200,height:50,tickValues:[this.scales.color.domain()[0],(this.scales.color.domain()[1]-this.scales.color.domain()[0])/2,this.scales.color.domain()[1]]})),t}function se(){var t;if(this.settings.colorify){switch(this.settings.colorBy.type){case"frequency":t=$t.call(this);break;case"categorical":t=ee.call(this);break;case"continuous":t=ie.call(this);break;default:return}t.classed("fdg-legend fdg-legend--color fdg-legend--".concat(this.settings.colorBy.type),!0)}return t}function ae(){var t;return this.settings.sizify&&"frequency"!==this.settings.colorBy.type&&(t=Kt.call(this,"size").classed("fdg-legend fdg-legend--size fdg-legend--".concat(this.settings.sizeBy.type),!0)),t}function re(t){Math.PI,Math.pow(this.legends.radius,2);return t.append("circle").attr("cx",this.legends.svgWidth/2).attr("cy",this.legends.svgHeight/2).attr("r",this.legends.radius).attr("fill","none").attr("stroke","#444")}function oe(t){var e=Math.sqrt(Math.PI)*this.legends.radius;return t.append("rect").attr("x",this.legends.svgWidth/2-e/2).attr("y",this.legends.svgHeight/2-e/2).attr("width",e).attr("height",e).attr("fill","none").attr("stroke","#444")}function le(t){var e=2.69*this.legends.radius*Math.sqrt(3)/2,n=this.legends.svgWidth/2,i=e/2,s=[n,i-e/2],a=[n-e/2,i+e/2],r=[n+e/2,i+e/2];return t.append("polygon").attr("points",[s,a,r]).attr("fill","none").attr("stroke","#444")}function ce(t){var e=Math.sqrt(Math.PI)*this.legends.radius,n=this.legends.svgWidth/2,i=this.legends.svgHeight/2;return t.append("rect").attr("transform","rotate(45 ".concat(n," ").concat(i,")")).attr("x",n).attr("y",i).attr("width",e).attr("height",e).attr("fill","none").attr("stroke","#444")}function ue(t){for(var e=Math.PI/5,n=.6*this.legends.radius,i=1.2*this.legends.radius,s=2*this.legends.radius/Math.sqrt(3),a=Math.PI/2*3,r=this.legends.svgWidth/2,o=this.legends.svgHeight/2+s,l=[r,o],c=[],u=0;u<5;u++)r=l[0]+Math.cos(a)*i,o=l[1]+Math.sin(a)*i,c.push([r,o]),a+=e,r=l[0]+Math.cos(a)*n,o=l[1]+Math.sin(a)*n,c.push([r,o]),a+=e;return t.append("polygon").attr("points",c).attr("fill","none").attr("stroke","#444")}function de(t){var e=2.69*this.legends.radius*Math.sqrt(3)/2,n=this.legends.svgWidth/2,i=e/2,s=[n-e/2,i-e/2],a=[n+e/2,i-e/2],r=[n,i+e/2];return t.append("polygon").attr("points",[s,a,r]).attr("fill","none").attr("stroke","#444")}function he(){var t,e=this,n=this;if(this.settings.shapify){t=te.call(this,this.settings.shapeBy.label,this.scales.shape.domain()).classed("fdg-legend fdg-legend--shape fdg-legend--".concat(this.settings.shapeBy.type),!0);var i={circle:re,square:oe,triangle:le,diamond:ce,star:ue,triangleDown:de};t.symbols.each((function(t,e){i[n.scales.shape(t)].call(n,d3.select(this)).classed("fdg-legend__shape",!0).classed("fdg-legend__symbol",!0)})),t.counts.text((function(t){return d3.format(",d")(e.metadata.id.filter((function(e){return e.shapeStratum===t})).length)}))}return t}function ge(){this.legends={container:this.layout.legends,svgWidth:40},this.legends.svgHeight=this.legends.svgWidth/2,this.legends.radius=this.legends.svgHeight/2-3,this.legends.color=se.call(this),this.legends.size=ae.call(this),this.legends.shape=he.call(this)}function fe(){var t=this,e=this,n={container:this.layout.freqTable.classed("fdg-hidden",!1===this.settings.freqTable.display).classed("fdg-freq-table--vertical","vertical"===this.settings.freqTable.structure).classed("fdg-freq-table--horizontal","horizontal"===this.settings.freqTable.structure)};return n.title=this.util.addElement("freq-table__title",n.container).classed("fdg-sidebar__label",!0).text("vertical"===this.settings.freqTable.structure?this.settings.freqTable.title:"id"===this.settings.freqTable.countType?"Number of ".concat(this.settings.individualLabel):"Number of ".concat(this.settings.eventLabel)),n.table=n.container.append("table").classed("fdg-freq-table__table",!0),n.thead=n.table.append("thead").classed("fdg-freq-table__thead",!0).classed("fdg-hidden",!1===this.settings.freqTable.header),n.th=n.thead.selectAll("th").data("vertical"===this.settings.freqTable.structure?this.settings.freqTable.columns:["","Total"].concat(s(this.metadata.strata.map((function(t){return t.key}))))).join("th").attr("class",(function(t,e){return"fdg-freq-table__th--".concat(0===e?"label":1===e?"individual":2===e?"event":e)})).classed("fdg-freq-table__th",!0).text((function(e){return"label"===e?"":"id"===e?t.settings.individualLabel:"event"===e?t.settings.eventLabel:e})),this.settings.freqTable.bars&&n.th.filter((function(t){return"id"===t})).html((function(e){return"".concat(t.settings.individualLabel," <span ","class = 'fdg-info-icon'"," ").concat("categorical"===t.settings.colorBy.type?"title = 'Gray background represents the percentage of individuals in the given group at the given state'":"title = 'Gray background represents the percentage of individuals at the given state'",">ⓘ</span>")})),n.tbody=n.table.append("tbody").classed("fdg-freq-table__tbody",!0),n.tr=n.tbody.selectAll("tr").data(this.data.freqTable.filter((function(e){return!(!1===t.settings.freqTable.includeEventCentral&&e.state===t.settings.eventCentral||"horizontal"===t.settings.freqTable.structure&&!e.foci)}))).join("tr").attr("class",(function(t){return t.state!==t.label?"fdg-freq-table__tr--subgroup":null})).classed("fdg-freq-table__tr",!0).style("font-size",(function(t){return t.group!==t.value?"1rem":"1.25rem"})),n.tr.each((function(t,n){d3.select(this).selectAll("td").data(t.cells).join("td").attr("class",(function(t,n){return"vertical"===e.settings.freqTable.structure?"fdg-freq-table__td--".concat(t.key):"fdg-freq-table__td--".concat("label"===t.key?"label":"freq")})).classed("fdg-freq-table__td",!0).style("background",(function(n,i){return 1===i&&e.settings.freqTable.bars?"linear-gradient(to right, var(--background-darkest) 0, var(--background-darkest) ".concat(t.proportionFmt,", transparent ").concat(t.proportionFmt,")"):null})).text((function(t){return t.value}))})),n.td=n.tr.selectAll("td"),n}function ye(){var t=this.layout.svgBackground.append("g").classed("fdg-g fdg-g--orbits",!0).attr("transform","translate(".concat(this.settings.width.sidebar,",0)"));return t.append("defs").selectAll("filter").data(this.metadata.orbit).join("filter").attr("id",(function(t,e){return"orbit--".concat(e)})).append("feDropShadow").attr("dx",0).attr("dy",0).attr("stdDeviation",5).attr("flood-color","black"),t.selectAll(".fdg-orbit").data(this.metadata.orbit).join(this.settings.orbitShape).classed("fdg-orbit",!0).attr("cx",(function(t){return t.cx})).attr("cy",(function(t){return t.cy})).attr("r",(function(t){return t.r})).attr("rx",(function(t){return t.rx})).attr("ry",(function(t){return t.ry})).attr("fill","none").attr("stroke","#aaa").attr("stroke-width","2.5").style("filter",(function(t,e){return"url(#orbit--".concat(e,")")}))}function ve(t){return Math.round(t.x)===Math.round(this.settings.orbitRadius/2)}function pe(t){return 1===t.order||Math.round(t.x)<Math.round(this.settings.width.canvas/2)}function me(t){t.key===this.settings.eventCentral||"none"===this.settings.focusOffset||"heuristic"===this.settings.focusOffset&&ve.call(this,t),"above"===this.settings.focusOffset||"heuristic"===this.settings.focusOffset&&pe.call(this,t),"below"===this.settings.focusOffset||"heuristic"===this.settings.focusOffset&&pe.call(this,t);return t.key===this.settings.eventCentral||"none"===this.settings.focusOffset?0:"heuristic"===this.settings.focusOffset&&0===t.position?Math.round(this.settings.orbitRadius/4):0}function be(t){return Math.round(t.y)===Math.round(this.settings.height.main/2)}function xe(t){return Math.round(t.y)<Math.round(this.settings.height.main/2)}function Ce(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=be.call(this,t)?"middle":xe.call(this,t)?"hanging":"baseline";return e&&(n="hanging"===n?"baseline":"baseline"===n?"hanging":n),n}function Be(t){var e=t.key===this.settings.eventCentral||"none"===this.settings.focusOffset||"heuristic"===this.settings.focusOffset&&be.call(this,t),n="above"===this.settings.focusOffset||"heuristic"===this.settings.focusOffset&&!0===xe.call(this,t),i="below"===this.settings.focusOffset||"heuristic"===this.settings.focusOffset&&!1===xe.call(this,t);return e?0:n?-Math.round(this.settings.height.main/12):i?Math.round(this.settings.height.main/12):0}function ke(t){var e=this,n=t.append("tspan").classed("fdg-focus-annotation__label",!0).attr("x",0).attr("text-anchor","middle").attr("alignment-baseline","middle").style("font-size",this.settings.eventLabelFontSize).style("font-weight",this.settings.eventLabelFontWeight).text((function(t){return t.key}));return"categorical"===this.settings.colorBy.type&&this.settings.colorBy.stratify&&n.attr("alignment-baseline",(function(t){return Ce.call(e,t,!0)})),n}function Ie(t){return t.append("tspan").classed("fdg-focus-annotation__event-count",!0).classed("fdg-hidden",!1===this.settings.eventCount).attr("x",0).attr("dy","1.3em").attr("text-anchor","middle").attr("alignment-baseline","middle").style("font-size",this.settings.eventCountFontSize).style("font-weight",this.settings.eventCountFontWeight)}function Ae(t,e,n){var i=this;"categorical"===this.settings.colorBy.type&&this.settings.colorBy.stratify&&(t.style("transform",(function(t){return"translate(".concat(be.call(i,t)?"-5em,0":"0,-5em",")")})),e.attr("text-anchor",(function(t){return t.key===i.settings.eventCentral?"start":"middle"})),n.attr("text-anchor","middle").classed("fdg-hidden",!0))}function qe(){var t=this,e=this,n=this.layout.focusAnnotations.selectAll("g.fdg-focus-annotation").data(this.metadata.event).join("g").classed("fdg-focus-annotation",!0).attr("transform",(function(t){return"translate(".concat(t.x,",").concat(t.y,")")}));return["background","foreground"].forEach((function(i){var s=n.append("text").classed("fdg-focus-annotation__text fdg-focus-annotation__".concat(i),!0);s.each((function(t,n){d3.select(this).attr("transform",(function(t){return"translate(".concat(me.call(e,t),",").concat(Be.call(e,t),")")}))}));var a=ke.call(t,s).attr("y",0).attr("dy",0);t.util.wrap(a,t.settings.orbitRadius);var r=Ie.call(t,s);Ae.call(t,s,a,r)})),"categorical"===this.settings.colorBy.type&&this.settings.colorBy.stratify&&this.metadata.event.forEach((function(e){e.fociLabels=t.layout.focusAnnotations.append("g").classed("fdg-focus-annotation fdg-focus-annotation--categorical",!0),["background","foreground"].forEach((function(n){e.fociLabels.selectAll("text.fdg-focus-annotation__".concat(n)).data(e.foci).join("text").classed("fdg-focus-annotation__event-count fdg-focus-annotation__text fdg-focus-annotation__".concat(n),!0).attr("x",(function(t){return t.dx})).attr("dx",(function(n){return e.key===t.settings.eventCentral?null:"-1em"})).attr("y",(function(t){return t.dy})).attr("text-anchor",(function(n){return e.key===t.settings.eventCentral?"middle":"end"})).attr("alignment-baseline",(function(e){return Ce.call(t,e,!0)}))}))})),n}function _e(){var t,e=this;return this.settings.annotations&&Array.isArray(this.settings.annotations)&&(this.settings.annotations.forEach((function(t){t.radius=t.orbit*e.settings.orbitRadius,t.theta=2*Math.PI*t.angle/360,t.x=e.settings.center.x+t.radius*Math.cos(t.theta),t.y=0===t.order?e.settings.center.y:e.settings.center.y+t.radius*Math.sin(t.theta)})),(t=this.layout.customAnnotations.selectAll("g.fdg-custom-annotation").data(this.settings.annotations).join("g").classed("fdg-custom-annotation",!0).attr("transform",(function(t){return"translate(".concat(t.x,",").concat(t.y,")")})).attr("opacity",(function(t){return t.timepoint>e.settings.timepoint?0:1}))).html((function(t){return t.value}))),t}function Qe(){Ht.call(this),ge.call(this),this.layout.freqTable=fe.call(this),this.orbits=ye.call(this),this.focusAnnotations=qe.call(this),this.customAnnotations=_e.call(this)}function Se(){var t=this.util.addElement("main",d3.select(this.element)).datum(this);for(var e in this.settings.width={main:t.node().clientWidth},this.settings.height={main:t.node().clientHeight},this.settings.root)document.querySelector(":root").style.setProperty("--".concat(e),this.settings.root[e],"important");var n=u.call(this,t),s=g.call(this,t),a=f.call(this,t);return window.addEventListener("resize",T.bind(this)),i(i(i(i({main:t},n),s),a),{},{dataDriven:Qe})}function we(){var t=this,e=d3.nest().key((function(t){return t.id})).rollup((function(e){return{duration:d3.sum(e,(function(t){return+t.duration})),static:1===e.length,colorStratum:"categorical"===t.settings.colorBy.type?e[0][t.settings.colorBy.variable]:null,shapeStratum:"categorical"===t.settings.shapeBy.type?e[0][t.settings.shapeBy.variable]:null}})).entries(this.data);return e.forEach((function(t,e){Object.assign(t,t.value)})),e}function Fe(t){var e=this;this.settings.duration=this.settings.duration||d3.max(t.id,(function(t){return t.duration})),this.settings.text=this.settings.text.filter((function(n){return!(/static/i.test(n)&&(t.id.every((function(t){return!1===t.static}))||!1===e.settings.drawStaticSeparately))})).map((function(t){return t.replace("[duration]",d3.format(",d")(e.settings.duration))})),this.settings.minRadius=this.settings.minRadius||Math.max(Math.min(3e3/t.id.filter((function(t){return!(e.settings.drawStaticSeparately&&t.static)})).length,this.settings.maxRadius),1),this.settings.staticRadius=this.settings.staticRadius||Math.max(3e3/t.id.length,1),this.settings.maxRadius=this.settings.minRadius+this.settings.colorBy.nColors,this.settings.chargeStrength=-2e3/t.id.filter((function(t){return!(e.settings.drawStaticSeparately&&t.static)})).length,this.settings.staticChargeStrength=-2e3/t.id.length,this.settings.fill=this.settings.fill||t.id.length<=2500}function Le(){var t=d3.nest().key((function(t){return t.event})).rollup((function(t){var e=t[0];return{order:parseInt(e.event_order),position:e.hasOwnProperty("event_position")?parseInt(e.event_position):null,ids:new Set,nIds:0,nIdsPrevious:0,idsCumulative:new Set,nIdsCumulative:0,nEvents:0,nEventsTotal:t.length,allIds:s(new Set(t.map((function(t){return t.id}))).values()).sort()}})).entries(this.data).sort((function(t,e){return t.value.order-e.value.order||t.value.position-e.value.position}));return t.map((function(e,n){return Object.assign(e,e.value),delete e.value,e.start_timepoint=0===n?1:t[n-1].end_timepoint+1,e.end_timepoint=e.start_timepoint+e.allIds.length-1,e.rank=n,e}))}function Ue(t){this.settings.eventCentral=this.settings.eventCentral||t.event[0].key,this.settings.eventChangeCount=this.settings.eventChangeCount||t.event.slice(1).map((function(t){return t.key}))}function Ee(t){var e=this,n=d3.nest().key((function(t){return t.order})).entries(t.event.filter((function(t){return t.key!==e.settings.eventCentral})));return n.forEach((function(t,i){t.label=Array.isArray(e.settings.orbitLabels)&&e.settings.orbitLabels.length===n.length?e.settings.orbitLabels[i]:"Orbit ".concat(i+1),t.values.sort((function(t,e){return t.position-e.position})).forEach((function(e){e.orbitLabel=t.label}))})),n}function Me(t){var e,n=this;return this.settings.stratify&&(e=d3.nest().key((function(t){return t[n.settings.colorBy.variable]})).entries(this.data).sort((function(t,e){var i=(Array.isArray(n.settings.colorBy.order)?n.settings.colorBy.order.indexOf(t.key):null)-(Array.isArray(n.settings.colorBy.order)?n.settings.colorBy.order.indexOf(e.key):null),s=t.key<e.key?-1:1;return i||s})),this.settings.colorBy.nStrata=e.length,this.settings.colorBy.theta=2*Math.PI/this.settings.colorBy.nStrata,e.forEach((function(e,i){var s=n.settings.colorBy.colorSchemes[i];e.colorScheme=d3["scheme".concat(s.substring(0,1).toUpperCase()).concat(s.substring(1),"s")],e.colorScale=d3.scaleLinear().domain(d3.range(n.settings.nColors)).range(e.colorScheme[9].reverse().slice(0,n.settings.nColors).reverse()).clamp(!0),e.individuals=t.id.filter((function(t){return t.colorStratum===e.key})),e.duration=d3.max(e.individuals,(function(t){return t.duration})),e.nIndividuals=e.individuals.length,e.nEvents=e.values.length,e.angle=n.settings.colorBy.nStrata%2?(n.settings.colorBy.nStrata-i-1)*n.settings.colorBy.theta:(n.settings.colorBy.nStrata-i-1)*n.settings.colorBy.theta+Math.PI/n.settings.colorBy.nStrata}))),e}function Ze(t){var e,n=this;return this.settings.shapify&&(e=d3.nest().key((function(t){return t[n.settings.shapeBy.variable]})).entries(this.data).sort((function(t,e){var i=(Array.isArray(n.settings.shapeBy.order)?n.settings.shapeBy.order.indexOf(t.key):null)-(Array.isArray(n.settings.shapeBy.order)?n.settings.shapeBy.order.indexOf(e.key):null),s=t.key<e.key?-1:1;return i||s}))),e}function Re(t){var e;if(this.settings.colorify){var n,i=this.settings.colorBy,s="frequency"===i.type?d3.range(i.nColors):"continuous"===i.type?d3.extent(this.data,(function(t){return t[i.variable]})):"categorical"===i.type?t.strata.map((function(t){return t.key})):null;switch(i.type){case"frequency":n=i.mirror?d3["scheme".concat(i.colorScheme)][i.nColors].reverse():d3["scheme".concat(i.colorScheme)][i.nColors],e=d3.scaleLinear().domain(s).range(n).clamp(!0);break;case"continuous":if(e=d3.scaleSequential(d3["interpolate".concat(i.colorScheme)]).domain(s),i.mirror){var a=e.interpolator();e.interpolator((function(t){return a(1-t)}))}break;case"categorical":var r=d3["scheme".concat(i.colorScheme)];n=r.every((function(t){return"string"==typeof t}))?r:r[Math.min(Math.max(3,s.length),9)],e=d3.scaleOrdinal().domain(s).range(n.map((function(t){return d3.rgb(t)+""})));break;default:e=null}}return e}function Ne(t){var e;if(this.settings.sizify){var n=this.settings.sizeBy,i="frequency"===n.type?[0,this.settings.colorBy.nColors]:"continuous"===n.type?d3.extent(this.data,(function(t){return t[n.variable]})):null,s=[this.settings.minRadius,this.settings.maxRadius];e=d3.scaleLinear().domain(i).range(s).clamp(!0)}return e}function Ve(t){var e;if(this.settings.shapify){var n=this.settings.shapeBy,i="categorical"===n.type?t.shape.map((function(t){return t.key})):null,s=n.shapes;e=d3.scaleOrdinal().domain(i).range(s)}return e}function ze(t){return{color:Re.call(this,t),size:Ne.call(this,t),shape:Ve.call(this,t)}}function We(t){var e=this;"categorical"===this.settings.colorBy.type&&("orbital"===this.settings.stratificationPositioning&&(this.settings.arcLength=this.settings.orbitRadius/200,this.settings.offsets="orbital"===this.settings.stratificationPositioning?t.strata.length%2?d3.range(-Math.floor(t.strata.length/2),Math.floor(t.strata.length/2)+1):d3.range(-t.strata.length/2+.5,t.strata.length/2+.5):null),t.event.forEach((function(n,s){n.foci=t.strata.map((function(t,a){var r=i(i({},t),{},{x:n.x+50*Math.cos(t.angle),dx:n.x+(0===s?75:50)*Math.cos(t.angle),y:n.y+50*Math.sin(t.angle),dy:n.y+(0===s?75:50)*Math.sin(t.angle),ids:new Set,nIds:0,nIdsPrevious:0,idsCumulative:new Set,nIdsCumulative:0,nEvents:0});return"orbital"===e.settings.stratificationPositioning&&(r.theta=n.theta+e.settings.arcLength*e.settings.offsets[a]/(2*Math.PI*n.radius)*360,r.x=0===n.order?r.x:e.settings.center.x+n.radius*Math.cos(r.theta),r.dx=r.x,r.y=0===n.order?r.y:e.settings.center.y+n.radius*Math.sin(r.theta),r.dy=r.y),r}))})))}function Ge(t){var e=this,n=d3.merge(t.event.map((function(n){var i="categorical"===e.settings.colorBy.type?[n].concat(s(n.foci)):[n];return i.forEach((function(i){i.state=n.key,i.label=i.key,i.freqs=V.call(e,i,n,t),i.fmt=z.call(e,i)})),i})));return n.forEach((function(t){t.cells=W.call(e,t)})),n}function Je(){var t={};return t.id=we.call(this),Fe.call(this,t),t.event=Le.call(this),Ue.call(this,t),t.orbit=Ee.call(this,t),y.call(this,t),t.strata=Me.call(this,t),t.shape=Ze.call(this,t),this.scales=ze.call(this,t),We.call(this,t),this.data.freqTable=Ge.call(this,t),t}function Te(){var t,e={},n=o(Object.keys(this.settings).filter((function(t){return/_var$/.test(t)})));try{for(n.s();!(t=n.n()).done;){var i=t.value;e[i.replace(/_var$/,"")]=this.data[0].hasOwnProperty(this.settings[i])}}catch(t){n.e(t)}finally{n.f()}return e}function Xe(){var t=this;this.data.forEach((function(e){var n,i=o(Object.keys(t.settings).filter((function(t){return/_var$/.test(t)})));try{for(i.s();!(n=i.n()).done;){var s=n.value,a=s.replace(/_var$/,"");e[a]=["event_order","start_timepoint","end_timepoint","duration"].includes(a)?+e[t.settings[s]]:e[t.settings[s]]}}catch(t){i.e(t)}finally{i.f()}}))}function Ye(t){d3.nest().key((function(t){return t.id})).rollup((function(e){e.forEach((function(n,i){t.duration&&!t.start_timepoint&&(0===i?(n.start_timepoint=1,n.end_timepoint=n.duration):(n.start_timepoint=e[i-1].end_timepoint+1,n.end_timepoint=n.start_timepoint+n.duration-1)),t.start_timepoint&&!t.end_timepoint&&(n.end_timepoint=i<e.length-1?e[i+1].start_timepoint-1:n.duration?n.start_timepoint+n.duration-1:n.start_timepoint),!t.duration&&t.start_timepoint&&t.end_timepoint&&(n.duration=n.end_timepoint-n.start_timepoint+1)})),e.sort((function(t,e){var n=t.start_timepoint-e.start_timepoint,i=t.end_timepoint-e.end_timepoint,s=t.event_order-e.event_order;return n||i||s})).forEach((function(t,e){t.sequence=e}))})).entries(this.data)}function Oe(){var t=this;"ordered"===this.settings.stateChange&&this.metadata&&(console.log(this.metadata),d3.nest().key((function(t){return t.id})).rollup((function(e){e.sort((function(t,e){return t.event_order-e.event_order||t.event_position-e.event_position||(t.event<e.event?-1:1)})),e.forEach((function(n,i){var s=t.metadata.event.find((function(t){return t.key===n.event})),a=t.metadata.event.find((function(t){var n;return t.key===(null===(n=e[i-1])||void 0===n?void 0:n.event)}));0===i?(n.start_timepoint=1,n.end_timepoint=n.start_timepoint+s.allIds.findIndex((function(t){return t===n.id}))):(n.start_timepoint=a.allIds.findIndex((function(t){return t===n.id}))+a.start_timepoint+1,n.end_timepoint=s.allIds.findIndex((function(t){return t===n.id}))+s.start_timepoint,n.duration=n.end_timepoint-n.start_timepoint+1)}))})).entries(this.data),this.settings.duration=this.metadata.id.length*this.metadata.orbit.length+1)}function je(t){var e=this.data.every((function(t){return/^-?\d+\.?\d*$/.test(t.id)||/^-?\d*\.?\d+$/.test(t.id)}));this.data.sort((function(t,n){var i=e?+t.id-+n.id:t.id<n.id?-1:n.id<t.id?1:0,s=t.start_timepoint-n.start_timepoint;return i||s}))}var Pe={mutate:function(){var t=Te.call(this);Xe.call(this),Ye.call(this,t),Oe.call(this),je.call(this,t)},structure:P};function He(){var t=this;this.settings_initial=i({},this.settings),this.metadata.event.forEach((function(e){e.data=t.data.nested.filter((function(t){return t.value.state.event===e.key}))})),St.call(this),A.call(this),kt.call(this,this.data),this.forceSimulation=ft.call(this,this.data),this.nodes=this.forceSimulation.nodes(),this.settings.removeCenterForce=!0,"play"===this.settings.playPause&&(this.timeout=d3.timeout((function(){!0===t.settings.runSequences?(t.sequence=O.call(t,!1),Nt.call(t)):t.interval=Rt.call(t,t.data)}),this.settings.delay))}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"body",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={data:t,element:e,settings:l.mergeDeep(c,n),util:l};return c.update.call(i),i.layout=Se.call(i),Pe.mutate.call(i),i.metadata=Je.call(i),i.data.nested=Pe.structure.call(i,i.data),i.layout.dataDriven.call(i),He.call(i),i}}));