@flourish/sdk 3.16.0 → 3.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_NOTES.md +12 -0
- package/lib/cmd/assign-version-number.js +1 -1
- package/lib/cmd/help.js +1 -1
- package/lib/cmd/publish.js +34 -13
- package/lib/cmd/run.js +2 -1
- package/lib/cmd/version.js +1 -1
- package/lib/log.js +7 -7
- package/lib/sdk.js +96 -68
- package/lib/validate_config.js +7 -6
- package/package.json +13 -6
- package/server/columns.js +59 -12
- package/server/comms_js.js +3 -5
- package/server/data.js +180 -8
- package/server/index.js +49 -19
- package/server/index_html.js +17 -8
- package/server/json.js +27 -1
- package/server/views/index.html +9 -4
- package/site/embedded.js +1 -1
- package/site/images/data_type_date.svg +6 -0
- package/site/images/data_type_number.svg +5 -0
- package/site/images/data_type_region.svg +4 -0
- package/site/images/data_type_string.svg +5 -0
- package/site/images/flourish_in_canva.png +0 -0
- package/site/images/montage.jpg +0 -0
- package/site/script.js +2 -1
- package/site/sdk.css +1 -1
- package/site/talk_to_server.js +1 -1
- package/test/lib/sdk.js +9 -0
- package/test/lib/validate_config.js +7 -5
- package/utils/state.js +2 -0
- package/test/mocha.opts +0 -2
package/site/script.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
var Flourish=function(t){"use strict";var e={value:function(){}};function n(){for(var t,e=0,n=arguments.length,i={};e<n;++e){if(!(t=arguments[e]+"")||t in i)throw new Error("illegal type: "+t);i[t]=[]}return new r(i)}function r(t){this._=t}function i(t,e){return t.trim().split(/^|\s+/).map((function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function o(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function a(t,n,r){for(var i=0,o=t.length;i<o;++i)if(t[i].name===n){t[i]=e,t=t.slice(0,i).concat(t.slice(i+1));break}return null!=r&&t.push({name:n,value:r}),t}function s(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function u(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function l(){}r.prototype=n.prototype={constructor:r,on:function(t,e){var n,r=this._,s=i(t+"",r),u=-1,l=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++u<l;)if(n=(t=s[u]).type)r[n]=a(r[n],t.name,e);else if(null==e)for(n in r)r[n]=a(r[n],t.name,null);return this}for(;++u<l;)if((n=(t=s[u]).type)&&(n=o(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new r(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var c=.7,f=1/c,p="\\s*([+-]?\\d+)\\s*",d="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",h="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",v=/^#([0-9a-f]{3})$/,g=/^#([0-9a-f]{6})$/,m=new RegExp("^rgb\\("+[p,p,p]+"\\)$"),y=new RegExp("^rgb\\("+[h,h,h]+"\\)$"),_=new RegExp("^rgba\\("+[p,p,p,d]+"\\)$"),w=new RegExp("^rgba\\("+[h,h,h,d]+"\\)$"),b=new RegExp("^hsl\\("+[d,h,h]+"\\)$"),x=new RegExp("^hsla\\("+[d,h,h,d]+"\\)$"),A={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function E(t){var e;return t=(t+"").trim().toLowerCase(),(e=v.exec(t))?new D((e=parseInt(e[1],16))>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):(e=g.exec(t))?C(parseInt(e[1],16)):(e=m.exec(t))?new D(e[1],e[2],e[3],1):(e=y.exec(t))?new D(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=_.exec(t))?k(e[1],e[2],e[3],e[4]):(e=w.exec(t))?k(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=b.exec(t))?T(e[1],e[2]/100,e[3]/100,1):(e=x.exec(t))?T(e[1],e[2]/100,e[3]/100,e[4]):A.hasOwnProperty(t)?C(A[t]):"transparent"===t?new D(NaN,NaN,NaN,0):null}function C(t){return new D(t>>16&255,t>>8&255,255&t,1)}function k(t,e,n,r){return r<=0&&(t=e=n=NaN),new D(t,e,n,r)}function S(t){return t instanceof l||(t=E(t)),t?new D((t=t.rgb()).r,t.g,t.b,t.opacity):new D}function N(t,e,n,r){return 1===arguments.length?S(t):new D(t,e,n,null==r?1:r)}function D(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function F(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function T(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new B(t,e,n,r)}function M(t){if(t instanceof B)return new B(t.h,t.s,t.l,t.opacity);if(t instanceof l||(t=E(t)),!t)return new B;if(t instanceof B)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n<r):n===o?(r-e)/s+2:(e-n)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new B(a,s,u,t.opacity)}function B(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function L(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}s(l,E,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),s(D,N,u(l,{brighter:function(t){return t=null==t?f:Math.pow(f,t),new D(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?c:Math.pow(c,t),new D(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return"#"+F(this.r)+F(this.g)+F(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),s(B,(function(t,e,n,r){return 1===arguments.length?M(t):new B(t,e,n,null==r?1:r)}),u(l,{brighter:function(t){return t=null==t?f:Math.pow(f,t),new B(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?c:Math.pow(c,t),new B(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new D(L(t>=240?t-240:t+120,i,r),L(t,i,r),L(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var q=Math.PI/180,O=180/Math.PI,R=.96422,P=.82521,j=4/29,I=6/29,U=3*I*I;function H(t){if(t instanceof z)return new z(t.l,t.a,t.b,t.opacity);if(t instanceof J){if(isNaN(t.h))return new z(t.l,0,0,t.opacity);var e=t.h*q;return new z(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof D||(t=S(t));var n,r,i=$(t.r),o=$(t.g),a=$(t.b),s=X((.2225045*i+.7168786*o+.0606169*a)/1);return i===o&&o===a?n=r=s:(n=X((.4360747*i+.3850649*o+.1430804*a)/R),r=X((.0139322*i+.0971045*o+.7141733*a)/P)),new z(116*s-16,500*(n-s),200*(s-r),t.opacity)}function z(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function X(t){return t>.008856451679035631?Math.pow(t,1/3):t/U+j}function W(t){return t>I?t*t*t:U*(t-j)}function V(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function $(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function G(t){if(t instanceof J)return new J(t.h,t.c,t.l,t.opacity);if(t instanceof z||(t=H(t)),0===t.a&&0===t.b)return new J(NaN,0,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*O;return new J(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function J(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}s(z,(function(t,e,n,r){return 1===arguments.length?H(t):new z(t,e,n,null==r?1:r)}),u(l,{brighter:function(t){return new z(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new z(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return new D(V(3.1338561*(e=R*W(e))-1.6168667*(t=1*W(t))-.4906146*(n=P*W(n))),V(-.9787684*e+1.9161415*t+.033454*n),V(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}})),s(J,(function(t,e,n,r){return 1===arguments.length?G(t):new J(t,e,n,null==r?1:r)}),u(l,{brighter:function(t){return new J(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new J(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return H(this).rgb()}}));var Y=-.14861,K=1.78277,Z=-.29227,Q=-.90649,tt=1.97294,et=tt*Q,nt=tt*K,rt=K*Z-Q*Y;function it(t){if(t instanceof ot)return new ot(t.h,t.s,t.l,t.opacity);t instanceof D||(t=S(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(rt*r+et*e-nt*n)/(rt+et-nt),o=r-i,a=(tt*(n-i)-Z*o)/Q,s=Math.sqrt(a*a+o*o)/(tt*i*(1-i)),u=s?Math.atan2(a,o)*O-120:NaN;return new ot(u<0?u+360:u,s,i,t.opacity)}function ot(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function at(t){return function(){return t}}function st(t){return 1==(t=+t)?ut:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):at(isNaN(e)?n:e)}}function ut(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):at(isNaN(t)?e:t)}s(ot,(function(t,e,n,r){return 1===arguments.length?it(t):new ot(t,e,n,null==r?1:r)}),u(l,{brighter:function(t){return t=null==t?f:Math.pow(f,t),new ot(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?c:Math.pow(c,t),new ot(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*q,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new D(255*(e+n*(Y*r+K*i)),255*(e+n*(Z*r+Q*i)),255*(e+n*(tt*r)),this.opacity)}}));var lt=function t(e){var n=st(e);function r(t,e){var r=n((t=N(t)).r,(e=N(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=ut(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return r.gamma=t,r}(1);function ct(t,e){return e-=t=+t,function(n){return t+e*n}}var ft=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pt=new RegExp(ft.source,"g");function dt(t,e){var n,r,i,o=ft.lastIndex=pt.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=ft.exec(t))&&(r=pt.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:ct(n,r)})),o=pt.lastIndex;return o<e.length&&(i=e.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)s[(n=u[r]).i]=n.x(t);return s.join("")})}var ht,vt,gt,mt,yt=180/Math.PI,_t={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function wt(t,e,n,r,i,o){var a,s,u;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*yt,skewX:Math.atan(u)*yt,scaleX:a,scaleY:s}}function bt(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(o,a){var s=[],u=[];return o=t(o),a=t(a),function(t,r,i,o,a,s){if(t!==i||r!==o){var u=a.push("translate(",null,e,null,n);s.push({i:u-4,x:ct(t,i)},{i:u-2,x:ct(r,o)})}else(i||o)&&a.push("translate("+i+e+o+n)}(o.translateX,o.translateY,a.translateX,a.translateY,s,u),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:ct(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,a.rotate,s,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:ct(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,a.skewX,s,u),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:ct(t,n)},{i:s-2,x:ct(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(t){for(var e,n=-1,r=u.length;++n<r;)s[(e=u[n]).i]=e.x(t);return s.join("")}}}var xt=bt((function(t){return"none"===t?_t:(ht||(ht=document.createElement("DIV"),vt=document.documentElement,gt=document.defaultView),ht.style.transform=t,t=gt.getComputedStyle(vt.appendChild(ht),null).getPropertyValue("transform"),vt.removeChild(ht),wt(+(t=t.slice(7,-1).split(","))[0],+t[1],+t[2],+t[3],+t[4],+t[5]))}),"px, ","px)","deg)"),At=bt((function(t){return null==t?_t:(mt||(mt=document.createElementNS("http://www.w3.org/2000/svg","g")),mt.setAttribute("transform",t),(t=mt.transform.baseVal.consolidate())?wt((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):_t)}),", ",")",")"),Et="http://www.w3.org/1999/xhtml",Ct={svg:"http://www.w3.org/2000/svg",xhtml:Et,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function kt(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Ct.hasOwnProperty(e)?{space:Ct[e],local:t}:t}function St(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Et&&e.documentElement.namespaceURI===Et?e.createElement(t):e.createElementNS(n,t)}}function Nt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Dt(t){var e=kt(t);return(e.local?Nt:St)(e)}function Ft(){}function Tt(t){return null==t?Ft:function(){return this.querySelector(t)}}function Mt(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Bt(){return[]}function Lt(t){return null==t?Bt:function(){return this.querySelectorAll(t)}}function qt(t){return function(){return this.matches(t)}}function Ot(t){return function(e){return e.matches(t)}}var Rt=Array.prototype.find;function Pt(){return this.firstElementChild}var jt=Array.prototype.filter;function It(){return this.children}function Ut(t){return new Array(t.length)}function Ht(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function zt(t){return function(){return t}}function Xt(t,e,n,r,i,o){for(var a,s=0,u=e.length,l=o.length;s<l;++s)(a=e[s])?(a.__data__=o[s],r[s]=a):n[s]=new Ht(t,o[s]);for(;s<u;++s)(a=e[s])&&(i[s]=a)}function Wt(t,e,n,r,i,o,a){var s,u,l,c=new Map,f=e.length,p=o.length,d=new Array(f);for(s=0;s<f;++s)(u=e[s])&&(d[s]=l=a.call(u,u.__data__,s,e)+"",c.has(l)?i[s]=u:c.set(l,u));for(s=0;s<p;++s)l=a.call(t,o[s],s,o)+"",(u=c.get(l))?(r[s]=u,u.__data__=o[s],c.delete(l)):n[s]=new Ht(t,o[s]);for(s=0;s<f;++s)(u=e[s])&&c.get(d[s])===u&&(i[s]=u)}function Vt(t){return t.__data__}function $t(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Gt(t){return function(){this.removeAttribute(t)}}function Jt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Yt(t,e){return function(){this.setAttribute(t,e)}}function Kt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Zt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Qt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function te(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ee(t){return function(){this.style.removeProperty(t)}}function ne(t,e,n){return function(){this.style.setProperty(t,e,n)}}function re(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ie(t,e){return t.style.getPropertyValue(e)||te(t).getComputedStyle(t,null).getPropertyValue(e)}function oe(t){return function(){delete this[t]}}function ae(t,e){return function(){this[t]=e}}function se(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function ue(t){return t.trim().split(/^|\s+/)}function le(t){return t.classList||new ce(t)}function ce(t){this._node=t,this._names=ue(t.getAttribute("class")||"")}function fe(t,e){for(var n=le(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function pe(t,e){for(var n=le(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function de(t){return function(){fe(this,t)}}function he(t){return function(){pe(this,t)}}function ve(t,e){return function(){(e.apply(this,arguments)?fe:pe)(this,t)}}function ge(){this.textContent=""}function me(t){return function(){this.textContent=t}}function ye(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function _e(){this.innerHTML=""}function we(t){return function(){this.innerHTML=t}}function be(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function xe(){this.nextSibling&&this.parentNode.appendChild(this)}function Ae(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ee(){return null}function Ce(){var t=this.parentNode;t&&t.removeChild(this)}function ke(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Se(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ne(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function De(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Fe(t,e,n){return function(){var r,i=this.__on,o=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var a=0,s=i.length;a<s;++a)if((r=i[a]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),void(r.value=e);this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function Te(t,e,n){var r=te(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Me(t,e){return function(){return Te(this,t,e)}}function Be(t,e){return function(){return Te(this,t,e.apply(this,arguments))}}Ht.prototype={constructor:Ht,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},ce.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Le=[null];function qe(t,e){this._groups=t,this._parents=e}function Oe(){return new qe([[document.documentElement]],Le)}function Re(t){return"string"==typeof t?new qe([[document.querySelector(t)]],[document.documentElement]):new qe([[t]],Le)}qe.prototype=Oe.prototype={constructor:qe,select:function(t){"function"!=typeof t&&(t=Tt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a,s=e[i],u=s.length,l=r[i]=new Array(u),c=0;c<u;++c)(o=s[c])&&(a=t.call(o,o.__data__,c,s))&&("__data__"in o&&(a.__data__=o.__data__),l[c]=a);return new qe(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);return null==e?[]:Mt(e)}}(t):Lt(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var a,s=e[o],u=s.length,l=0;l<u;++l)(a=s[l])&&(r.push(t.call(a,a.__data__,l,s)),i.push(a));return new qe(r,i)},selectChild:function(t){return this.select(null==t?Pt:function(t){return function(){return Rt.call(this.children,t)}}("function"==typeof t?t:Ot(t)))},selectChildren:function(t){return this.selectAll(null==t?It:function(t){return function(){return jt.call(this.children,t)}}("function"==typeof t?t:Ot(t)))},filter:function(t){"function"!=typeof t&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a=e[i],s=a.length,u=r[i]=[],l=0;l<s;++l)(o=a[l])&&t.call(o,o.__data__,l,a)&&u.push(o);return new qe(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Vt);var n=e?Wt:Xt,r=this._parents,i=this._groups;"function"!=typeof t&&(t=zt(t));for(var o=i.length,a=new Array(o),s=new Array(o),u=new Array(o),l=0;l<o;++l){var c=r[l],f=i[l],p=f.length,d=Mt(t.call(c,c&&c.__data__,l,r)),h=d.length,v=s[l]=new Array(h),g=a[l]=new Array(h),m=u[l]=new Array(p);n(c,f,v,g,m,d,e);for(var y,_,w=0,b=0;w<h;++w)if(y=v[w]){for(w>=b&&(b=w+1);!(_=g[b])&&++b<h;);y._next=_||null}}return(a=new qe(a,r))._enter=s,a._exit=u,a},enter:function(){return new qe(this._enter||this._groups.map(Ut),this._parents)},exit:function(){return new qe(this._exit||this._groups.map(Ut),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=e&&(i=e(i)),null==n?o.remove():n(o),r&&i?r.merge(i).order():i},merge:function(t){if(!(t instanceof qe))throw new Error("invalid merge");for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s)for(var u,l=e[s],c=n[s],f=l.length,p=a[s]=new Array(f),d=0;d<f;++d)(u=l[d]||c[d])&&(p[d]=u);for(;s<r;++s)a[s]=e[s];return new qe(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],o=i.length-1,a=i[o];--o>=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=$t);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a,s=n[o],u=s.length,l=i[o]=new Array(u),c=0;c<u;++c)(a=s[c])&&(l[c]=a);l.sort(e)}return new qe(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,o=e[n],a=0,s=o.length;a<s;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,e){var n=kt(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?Jt:Gt:"function"==typeof e?n.local?Qt:Zt:n.local?Kt:Yt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?ee:"function"==typeof e?re:ne)(t,e,null==n?"":n)):ie(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?oe:"function"==typeof e?se:ae)(t,e)):this.node()[t]},classed:function(t,e){var n=ue(t+"");if(arguments.length<2){for(var r=le(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?ve:e?de:he)(n,e))},text:function(t){return arguments.length?this.each(null==t?ge:("function"==typeof t?ye:me)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?_e:("function"==typeof t?be:we)(t)):this.node().innerHTML},raise:function(){return this.each(xe)},lower:function(){return this.each(Ae)},append:function(t){var e="function"==typeof t?t:Dt(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:Dt(t),r=null==e?Ee:"function"==typeof e?e:Tt(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(Ce)},clone:function(t){return this.select(t?Se:ke)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=Ne(t+""),a=o.length;if(!(arguments.length<2)){for(s=e?Fe:De,r=0;r<a;++r)this.each(s(o[r],e,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(r=0,u=s[l];r<a;++r)if((i=o[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?Be:Me)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,a=i.length;o<a;++o)(r=i[o])&&(yield r)}};var Pe,je,Ie=0,Ue=0,He=0,ze=0,Xe=0,We=0,Ve="object"==typeof performance&&performance.now?performance:Date,$e="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ge(){return Xe||($e(Je),Xe=Ve.now()+We)}function Je(){Xe=0}function Ye(){this._call=this._time=this._next=null}function Ke(t,e,n){var r=new Ye;return r.restart(t,e,n),r}function Ze(){Xe=(ze=Ve.now())+We,Ie=Ue=0;try{!function(){Ge(),++Ie;for(var t,e=Pe;e;)(t=Xe-e._time)>=0&&e._call.call(null,t),e=e._next;--Ie}()}finally{Ie=0,function(){var t,e,n=Pe,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Pe=e);je=t,tn(r)}(),Xe=0}}function Qe(){var t=Ve.now(),e=t-ze;e>1e3&&(We-=e,ze=t)}function tn(t){Ie||(Ue&&(Ue=clearTimeout(Ue)),t-Xe>24?(t<1/0&&(Ue=setTimeout(Ze,t-Ve.now()-We)),He&&(He=clearInterval(He))):(He||(ze=Ve.now(),He=setInterval(Qe,1e3)),Ie=1,$e(Ze)))}function en(t,e,n){var r=new Ye;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Ye.prototype=Ke.prototype={constructor:Ye,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Ge():+n)+(null==e?0:+e),this._next||je===this||(je?je._next=this:Pe=this,je=this),this._call=t,this._time=n,tn()},stop:function(){this._call&&(this._call=null,this._time=1/0,tn())}};var nn=n("start","end","cancel","interrupt"),rn=[];function on(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(o){var l,c,f,p;if(1!==n.state)return u();for(l in i)if((p=i[l]).name===n.name){if(3===p.state)return en(a);4===p.state?(p.state=6,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete i[l]):+l<e&&(p.state=6,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete i[l])}if(en((function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(o))})),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(f=n.tween.length),l=0,c=-1;l<f;++l)(p=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=p);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),o=-1,a=r.length;++o<a;)r[o].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=Ke(o,0,n.time)}(t,n,{name:e,index:r,group:i,on:nn,tween:rn,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function an(t,e){var n=un(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function sn(t,e){var n=un(t,e);if(n.state>3)throw new Error("too late; already running");return n}function un(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function ln(t,e){var n,r;return function(){var i=sn(this,t),o=i.tween;if(o!==n)for(var a=0,s=(r=n=o).length;a<s;++a)if(r[a].name===e){(r=r.slice()).splice(a,1);break}i.tween=r}}function cn(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var o=sn(this,t),a=o.tween;if(a!==r){i=(r=a).slice();for(var s={name:e,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===e){i[u]=s;break}u===l&&i.push(s)}o.tween=i}}function fn(t,e,n){var r=t._id;return t.each((function(){var t=sn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return un(t,r).value[e]}}function pn(t,e){var n;return("number"==typeof e?ct:e instanceof E?lt:(n=E(e))?(e=n,lt):dt)(t,e)}function dn(t){return function(){this.removeAttribute(t)}}function hn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function vn(t,e,n){var r,i,o=n+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=e(r=a,n)}}function gn(t,e,n){var r,i,o=n+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=e(r=a,n)}}function mn(t,e,n){var r,i,o;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttribute(t))===(s=u+"")?null:a===r&&s===i?o:(i=s,o=e(r=a,u));this.removeAttribute(t)}}function yn(t,e,n){var r,i,o;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttributeNS(t.space,t.local))===(s=u+"")?null:a===r&&s===i?o:(i=s,o=e(r=a,u));this.removeAttributeNS(t.space,t.local)}}function _n(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function wn(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function bn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&wn(t,i)),n}return i._value=e,i}function xn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&_n(t,i)),n}return i._value=e,i}function An(t,e){return function(){an(this,t).delay=+e.apply(this,arguments)}}function En(t,e){return e=+e,function(){an(this,t).delay=e}}function Cn(t,e){return function(){sn(this,t).duration=+e.apply(this,arguments)}}function kn(t,e){return e=+e,function(){sn(this,t).duration=e}}function Sn(t,e){if("function"!=typeof e)throw new Error;return function(){sn(this,t).ease=e}}function Nn(t,e,n){var r,i,o=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?an:sn;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}var Dn=Oe.prototype.constructor;function Fn(t){return function(){this.style.removeProperty(t)}}function Tn(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Mn(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&Tn(t,o,n)),r}return o._value=e,o}function Bn(t){return function(e){this.textContent=t.call(this,e)}}function Ln(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&Bn(r)),e}return r._value=t,r}var qn=0;function On(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Rn(){return++qn}var Pn=Oe.prototype;On.prototype=function(t){return Oe().transition(t)}.prototype={constructor:On,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Tt(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var s,u,l=r[a],c=l.length,f=o[a]=new Array(c),p=0;p<c;++p)(s=l[p])&&(u=t.call(s,s.__data__,p,l))&&("__data__"in s&&(u.__data__=s.__data__),f[p]=u,on(f[p],e,n,p,f,un(s,n)));return new On(o,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Lt(t));for(var r=this._groups,i=r.length,o=[],a=[],s=0;s<i;++s)for(var u,l=r[s],c=l.length,f=0;f<c;++f)if(u=l[f]){for(var p,d=t.call(u,u.__data__,f,l),h=un(u,n),v=0,g=d.length;v<g;++v)(p=d[v])&&on(p,e,n,v,d,h);o.push(d),a.push(u)}return new On(o,a,e,n)},filter:function(t){"function"!=typeof t&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a=e[i],s=a.length,u=r[i]=[],l=0;l<s;++l)(o=a[l])&&t.call(o,o.__data__,l,a)&&u.push(o);return new On(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s)for(var u,l=e[s],c=n[s],f=l.length,p=a[s]=new Array(f),d=0;d<f;++d)(u=l[d]||c[d])&&(p[d]=u);for(;s<r;++s)a[s]=e[s];return new On(a,this._parents,this._name,this._id)},selection:function(){return new Dn(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Rn(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a,s=r[o],u=s.length,l=0;l<u;++l)if(a=s[l]){var c=un(a,e);on(a,t,n,l,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new On(r,this._parents,t,n)},call:Pn.call,nodes:Pn.nodes,node:Pn.node,size:Pn.size,empty:Pn.empty,each:Pn.each,on:function(t,e){var n=this._id;return arguments.length<2?un(this.node(),n).on.on(t):this.each(Nn(n,t,e))},attr:function(t,e){var n=kt(t),r="transform"===n?At:pn;return this.attrTween(t,"function"==typeof e?(n.local?yn:mn)(n,r,fn(this,"attr."+t,e)):null==e?(n.local?hn:dn)(n):(n.local?gn:vn)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=kt(t);return this.tween(n,(r.local?bn:xn)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?xt:pn;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=ie(this,t),a=(this.style.removeProperty(t),ie(this,t));return o===a?null:o===n&&a===r?i:i=e(n=o,r=a)}}(t,r)).on("end.style."+t,Fn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var a=ie(this,t),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=ie(this,t)),a===u?null:a===r&&u===i?o:(i=u,o=e(r=a,s))}}(t,r,fn(this,"style."+t,e))).each(function(t,e){var n,r,i,o,a="style."+e,s="end."+a;return function(){var u=sn(this,t),l=u.on,c=null==u.value[a]?o||(o=Fn(e)):void 0;l===n&&i===c||(r=(n=l).copy()).on(s,i=c),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var a=ie(this,t);return a===o?null:a===r?i:i=e(r=a,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,Mn(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(fn(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,Ln(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=un(this.node(),n).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?ln:cn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?An:En)(e,t)):un(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Cn:kn)(e,t)):un(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(Sn(e,t)):un(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;sn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise((function(o,a){var s={value:a},u={value:function(){0==--i&&o()}};n.each((function(){var n=sn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),n.on=e})),0===i&&o()}))},[Symbol.iterator]:Pn[Symbol.iterator]};var jn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function In(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Oe.prototype.interrupt=function(t){return this.each((function(){!function(t,e){var n,r,i,o=t.__transition,a=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete t.__transition}}(this,t)}))},Oe.prototype.transition=function(t){var e,n;t instanceof On?(e=t._id,t=t._name):(e=Rn(),(n=jn).time=Ge(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a,s=r[o],u=s.length,l=0;l<u;++l)(a=s[l])&&on(a,t,e,l,s,n||In(a,e));return new On(r,this._parents,t,e)};var Un={},Hn={};function zn(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+"]"})).join(",")+"}")}function Xn(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],o=t.length,a=0,s=0,u=o<=0,l=!1;function c(){if(u)return Hn;if(l)return l=!1,Un;var e,r,i=a;if(34===t.charCodeAt(i)){for(;a++<o&&34!==t.charCodeAt(a)||34===t.charCodeAt(++a););return(e=a)>=o?u=!0:10===(r=t.charCodeAt(a++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(a)&&++a),t.slice(i+1,e-1).replace(/""/g,'"')}for(;a<o;){if(10===(r=t.charCodeAt(e=a++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(a)&&++a;else if(r!==n)continue;return t.slice(i,e)}return u=!0,t.slice(i,o)}for(10===t.charCodeAt(o-1)&&--o,13===t.charCodeAt(o-1)&&--o;(r=c())!==Hn;){for(var f=[];r!==Un&&r!==Hn;)f.push(r),r=c();e&&null==(f=e(f,s++))||i.push(f)}return i}function i(e){return e.map(o).join(t)}function o(t){return null==t?"":e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,o=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=zn(t);return function(r,i){return e(n(r),i,t)}}(t,e):zn(t)}));return o.columns=i||[],o},parseRows:r,format:function(e,n){return null==n&&(n=function(t){var e=Object.create(null),n=[];return t.forEach((function(t){for(var r in t)r in e||n.push(e[r]=r)})),n}(e)),[n.map(o).join(t)].concat(e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))).join("\n")},formatRows:function(t){return t.map(i).join("\n")}}}Xn(","),Xn("\t");function Wn(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}var Vn=Wn("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),$n=Wn("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Gn=Wn("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Jn=Wn("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"),Yn="http://www.w3.org/1999/xhtml",Kn={svg:"http://www.w3.org/2000/svg",xhtml:Yn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Zn(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Kn.hasOwnProperty(e)?{space:Kn[e],local:t}:t}function Qn(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Yn&&e.documentElement.namespaceURI===Yn?e.createElement(t):e.createElementNS(n,t)}}function tr(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function er(t){var e=Zn(t);return(e.local?tr:Qn)(e)}function nr(){}function rr(t){return null==t?nr:function(){return this.querySelector(t)}}function ir(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function or(){return[]}function ar(t){return function(e){return e.matches(t)}}var sr=Array.prototype.find;function ur(){return this.firstElementChild}var lr=Array.prototype.filter;function cr(){return this.children}function fr(t){return new Array(t.length)}function pr(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function dr(t){return function(){return t}}function hr(t,e,n,r,i,o){for(var a,s=0,u=e.length,l=o.length;s<l;++s)(a=e[s])?(a.__data__=o[s],r[s]=a):n[s]=new pr(t,o[s]);for(;s<u;++s)(a=e[s])&&(i[s]=a)}function vr(t,e,n,r,i,o,a){var s,u,l,c=new Map,f=e.length,p=o.length,d=new Array(f);for(s=0;s<f;++s)(u=e[s])&&(d[s]=l=a.call(u,u.__data__,s,e)+"",c.has(l)?i[s]=u:c.set(l,u));for(s=0;s<p;++s)l=a.call(t,o[s],s,o)+"",(u=c.get(l))?(r[s]=u,u.__data__=o[s],c.delete(l)):n[s]=new pr(t,o[s]);for(s=0;s<f;++s)(u=e[s])&&c.get(d[s])===u&&(i[s]=u)}function gr(t){return t.__data__}function mr(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function yr(t){return function(){this.removeAttribute(t)}}function _r(t){return function(){this.removeAttributeNS(t.space,t.local)}}function wr(t,e){return function(){this.setAttribute(t,e)}}function br(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function xr(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Ar(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Er(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Cr(t){return function(){this.style.removeProperty(t)}}function kr(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Sr(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function Nr(t,e){return t.style.getPropertyValue(e)||Er(t).getComputedStyle(t,null).getPropertyValue(e)}function Dr(t){return function(){delete this[t]}}function Fr(t,e){return function(){this[t]=e}}function Tr(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Mr(t){return t.trim().split(/^|\s+/)}function Br(t){return t.classList||new Lr(t)}function Lr(t){this._node=t,this._names=Mr(t.getAttribute("class")||"")}function qr(t,e){for(var n=Br(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Or(t,e){for(var n=Br(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Rr(t){return function(){qr(this,t)}}function Pr(t){return function(){Or(this,t)}}function jr(t,e){return function(){(e.apply(this,arguments)?qr:Or)(this,t)}}function Ir(){this.textContent=""}function Ur(t){return function(){this.textContent=t}}function Hr(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function zr(){this.innerHTML=""}function Xr(t){return function(){this.innerHTML=t}}function Wr(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Vr(){this.nextSibling&&this.parentNode.appendChild(this)}function $r(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Gr(){return null}function Jr(){var t=this.parentNode;t&&t.removeChild(this)}function Yr(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Kr(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Zr(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function Qr(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function ti(t,e,n){return function(){var r,i=this.__on,o=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var a=0,s=i.length;a<s;++a)if((r=i[a]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),void(r.value=e);this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function ei(t,e,n){var r=Er(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function ni(t,e){return function(){return ei(this,t,e)}}function ri(t,e){return function(){return ei(this,t,e.apply(this,arguments))}}pr.prototype={constructor:pr,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},Lr.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ii,oi,ai,si,ui,li=[null];function ci(t,e){this._groups=t,this._parents=e}function fi(t){return"string"==typeof t?new ci([[document.querySelector(t)]],[document.documentElement]):new ci([[t]],li)}function pi(t){return"string"==typeof t?new ci([document.querySelectorAll(t)],[document.documentElement]):new ci([null==t?[]:ir(t)],li)}function di(){if(!ai)return null;var t=ai.nodes()[1].value;if("custom"===si&&""!=t){var e=parseInt(t,10);return isNaN(e)?null:e}return null}function hi(){ui&&ui.preview_pane&&ui.preview_pane.setFixedHeight&&ui.preview_pane.setFixedHeight(di())}function vi(t){si=t,hi(),"custom"===t?(fi("#editor-custom-inputs").style("opacity",1),fi(".preview-holder").style("width",ai.nodes()[0].value+"px").select("iframe").style("width",ai.nodes()[0].value+"px")):(fi("#editor-custom-inputs").style("opacity",0),fi(".preview-holder").attr("style",null).select("iframe").style("width",null)),pi("#preview-menu .preview-mode").classed("selected",(function(){return this.id=="editor-"+t})),fi("#editor-rotate").classed("active",(function(){return"auto"!==t})),fi(".row.editor").classed("mobile",(function(){return"mobile"==t})),fi(".row.editor").classed("tablet",(function(){return"tablet"==t})),fi(".preview-holder").on("webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd transitionend",mi),ii=t}function gi(t){return ui=t,ai=pi("#editor-custom-inputs input"),mi(),pi("#preview-menu .preview-mode").on("click",(function(){vi(this.getAttribute("data-target"))})),ai.on("change",(function(){vi(this.getAttribute("data-target"))})),vi("auto"),function(){var t,e,n=document.querySelector("#resize-handle"),r=document.querySelector(".preview-holder");function i(i){"editor-custom"!==i.target.parentElement.id&&(t=r.getBoundingClientRect().width,n.parentElement.parentElement.querySelector("#resize-overlay").classList.add("dragging"),n.parentElement.classList.add("dragging"),e=i.clientX,fi(".preview-holder").style("transition","none"),vi("custom"),document.addEventListener("mousemove",o),document.addEventListener("mouseup",a),i.preventDefault())}function o(n){var i=n.clientX-e,o=t+2*i;r.style.width=o+"px",r.querySelector("iframe").style.width=o-4+"px",mi(),ui.preview_pane.resize()}function a(){t=r.getBoundingClientRect().width,fi(".preview-holder").style("transition",null),n.parentElement.parentElement.querySelector("#resize-overlay").classList.remove("dragging"),n.parentElement.classList.remove("dragging"),mi(),ui.preview_pane.resize(),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)}n.addEventListener("mousedown",i)}(),window.innerWidth<=768&&(oi="auto"),window.addEventListener("resize",(function(){ii&&mi(),window.innerWidth<=768?oi||(oi=ii,vi("auto")):oi&&(vi(oi),oi=null),ui.preview_pane.resize()})),{getHeightSetting:di}}function mi(){var t=fi(".preview-holder").node().getBoundingClientRect();ai.nodes()[0].value=Math.round(t.width),""!==ai.nodes()[1].value&&"custom"===si&&(ai.nodes()[1].value=Math.round(t.height))}ci.prototype=function(){return new ci([[document.documentElement]],li)}.prototype={constructor:ci,select:function(t){"function"!=typeof t&&(t=rr(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a,s=e[i],u=s.length,l=r[i]=new Array(u),c=0;c<u;++c)(o=s[c])&&(a=t.call(o,o.__data__,c,s))&&("__data__"in o&&(a.__data__=o.__data__),l[c]=a);return new ci(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);return null==e?[]:ir(e)}}(t):function(t){return null==t?or:function(){return this.querySelectorAll(t)}}(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var a,s=e[o],u=s.length,l=0;l<u;++l)(a=s[l])&&(r.push(t.call(a,a.__data__,l,s)),i.push(a));return new ci(r,i)},selectChild:function(t){return this.select(null==t?ur:function(t){return function(){return sr.call(this.children,t)}}("function"==typeof t?t:ar(t)))},selectChildren:function(t){return this.selectAll(null==t?cr:function(t){return function(){return lr.call(this.children,t)}}("function"==typeof t?t:ar(t)))},filter:function(t){"function"!=typeof t&&(t=function(t){return function(){return this.matches(t)}}(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,a=e[i],s=a.length,u=r[i]=[],l=0;l<s;++l)(o=a[l])&&t.call(o,o.__data__,l,a)&&u.push(o);return new ci(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,gr);var n=e?vr:hr,r=this._parents,i=this._groups;"function"!=typeof t&&(t=dr(t));for(var o=i.length,a=new Array(o),s=new Array(o),u=new Array(o),l=0;l<o;++l){var c=r[l],f=i[l],p=f.length,d=ir(t.call(c,c&&c.__data__,l,r)),h=d.length,v=s[l]=new Array(h),g=a[l]=new Array(h),m=u[l]=new Array(p);n(c,f,v,g,m,d,e);for(var y,_,w=0,b=0;w<h;++w)if(y=v[w]){for(w>=b&&(b=w+1);!(_=g[b])&&++b<h;);y._next=_||null}}return(a=new ci(a,r))._enter=s,a._exit=u,a},enter:function(){return new ci(this._enter||this._groups.map(fr),this._parents)},exit:function(){return new ci(this._exit||this._groups.map(fr),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=e&&(i=e(i)),null==n?o.remove():n(o),r&&i?r.merge(i).order():i},merge:function(t){if(!(t instanceof ci))throw new Error("invalid merge");for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s)for(var u,l=e[s],c=n[s],f=l.length,p=a[s]=new Array(f),d=0;d<f;++d)(u=l[d]||c[d])&&(p[d]=u);for(;s<r;++s)a[s]=e[s];return new ci(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],o=i.length-1,a=i[o];--o>=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=mr);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a,s=n[o],u=s.length,l=i[o]=new Array(u),c=0;c<u;++c)(a=s[c])&&(l[c]=a);l.sort(e)}return new ci(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,o=e[n],a=0,s=o.length;a<s;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,e){var n=Zn(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?_r:yr:"function"==typeof e?n.local?Ar:xr:n.local?br:wr)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?Cr:"function"==typeof e?Sr:kr)(t,e,null==n?"":n)):Nr(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Dr:"function"==typeof e?Tr:Fr)(t,e)):this.node()[t]},classed:function(t,e){var n=Mr(t+"");if(arguments.length<2){for(var r=Br(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?jr:e?Rr:Pr)(n,e))},text:function(t){return arguments.length?this.each(null==t?Ir:("function"==typeof t?Hr:Ur)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?zr:("function"==typeof t?Wr:Xr)(t)):this.node().innerHTML},raise:function(){return this.each(Vr)},lower:function(){return this.each($r)},append:function(t){var e="function"==typeof t?t:er(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:er(t),r=null==e?Gr:"function"==typeof e?e:rr(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(Jr)},clone:function(t){return this.select(t?Kr:Yr)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=Zr(t+""),a=o.length;if(!(arguments.length<2)){for(s=e?ti:Qr,r=0;r<a;++r)this.each(s(o[r],e,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(r=0,u=s[l];r<a;++r)if((i=o[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?ri:ni)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,a=i.length;o<a;++o)(r=i[o])&&(yield r)}};var yi,_i,wi=25,bi=10,xi=10,Ai={};function Ei(t,e,n,r,i,o,a){var s=n-t/2-xi,u=n+t/2+xi,l=t/2+Math.min(0,s-i.left)+Math.max(0,u-i.right);return{pos:[l,a],shape:l-bi<5?[-l,-15*o,Math.max(bi,5-l),-10*o]:l+bi>t-5?[Math.min(-10,t-l-5),-10*o,Math.min(bi,t-l),-15*o]:[-10,-10*o,bi,-10*o]}}function Ci(t,e,n,r,i,o,a){var s=r-e/2-xi,u=r+e/2+xi,l=e/2+Math.min(0,s-i.top)+Math.max(0,u-i.bottom);return{pos:[a,l],shape:l-bi<5?[-15*o,-l,-10*o,Math.max(bi,5-l)]:l+bi>e-5?[-10*o,Math.min(-10,e-l-5),-15*o,Math.min(bi,e-l)]:[-10*o,-10,-10*o,bi]}}function ki(t,e,n,r,i,o){var a=Ai[t](e,n,r,i,o),s=r-wi-a.pos[0],u=i-wi-a.pos[1];return{left:s,top:u,right:s+e+50,bottom:u+n+50}}function Si(t,e,n){var r,i=document.createElementNS("http://www.w3.org/2000/svg",t);if(e)for(r in e)i.setAttribute(r,e[r]);var o=i.style;if(n)for(r in n)o[r]=n[r];return i}function Ni(){return yi||((yi=document.createElement("div")).id="flourish-popup-constrainer",(_i=yi.style).overflow="hidden",_i.pointerEvents="none",_i.position="absolute",_i.left="0",_i.top="0",_i.margin="0",_i.padding="0",document.body.appendChild(yi),this._resizeConstrainer(),yi)}Ai.bottom=function(t,e){return{shape:[-10,-10,bi,-10],pos:[t/2,e+xi]}},Ai.top=function(t,e){return{shape:[-10,xi,bi,xi],pos:[t/2,-10]}},Ai.left=function(t,e){return{shape:[xi,bi,xi,-10],pos:[-10,e/2]}},Ai.right=function(t,e){return{shape:[-10,bi,-10,-10],pos:[t+xi,e/2]}},Ai.topLeft=function(t,e){return{shape:[15,xi,xi,15],pos:[-10,-10]}},Ai.bottomLeft=function(t,e){return{shape:[15,-10,xi,-15],pos:[-10,e+xi]}},Ai.topRight=function(t,e){return{shape:[-15,xi,-10,15],pos:[t+xi,-10]}},Ai.bottomRight=function(t,e){return{shape:[-15,-10,-10,-15],pos:[t+xi,e+xi]}},Ai.bottomFlexible=function(t,e,n,r,i){return Ei(t,0,n,0,i,1,e+xi)},Ai.topFlexible=function(t,e,n,r,i){return Ei(t,0,n,0,i,-1,-10)},Ai.rightFlexible=function(t,e,n,r,i){return Ci(0,e,0,r,i,1,t+xi)},Ai.leftFlexible=function(t,e,n,r,i){return Ci(0,e,0,r,i,-1,-10)};var Di,Fi=1,Ti={container:document.body,maxWidth:"70%",point:null,html:null,directions:["bottom","top","left","right","topLeft","bottomLeft","topRight","bottomRight","bottomFlexible","topFlexible","leftFlexible","rightFlexible"],fallbackFit:"horizontal"};function Mi(){for(var t in this.unique_id=Fi++,this.is_visible=!0,Ti)this["_"+t]=Ti[t];this.handlers={click:[]}}function Bi(t){Mi.prototype[t]=function(e){return void 0===e?this["_"+t]:(this["_"+t]=e,this)}}for(var Li in Ti)Bi(Li);function qi(){return new Mi}function Oi(){Di=qi().container(document.body),function(t){t.on("mouseover",Ri).on("mouseout",Pi)}(pi(".popup"))}function Ri(){if(this.getAttribute("data-popup-head")||this.getAttribute("data-popup-body")){var t=this.getAttribute("data-popup-position"),e=this.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height,i=this.getAttribute("data-popup-head")||null,o=this.getAttribute("data-popup-body")||null,a="",s=["top","topFlexible"];i&&(a+="<h1>"+i+"</h1>"),o&&(a+="<p>"+o+"</p>"),t&&("left"===t?(s=["right","rightFlexible"],n=e.left,r=e.top+e.height/2):"right"===t?(s=["left","leftFlexible"],n=e.right,r=e.top+e.height/2):"top"===t?(s=["bottom","bottomFlexible"],n=e.left+e.width/2,r=e.top):"bottom"===t&&(s=["top","topFlexible"],n=e.left+e.width/2,r=e.top+e.height)),Di.point(n,r).html(a).directions(s).draw()}}function Pi(){Di.hide()}function ji(t){if(t=t.toUpperCase(),!/^[A-Z]+$/.test(t))throw new Error("Invalid column spec: "+t);for(var e=0,n=0;n<t.length;n++)e=26*e+(t.charCodeAt(n)-64);return e-1}function Ii(t){t+=1;for(var e="";t>0;){var n=Math.floor(t/26),r=t%26;0==r&&(n-=1,r+=26),e=String.fromCharCode(64+r)+e,t=n}return e}function Ui(t){var e=t.match(/\s*(?:[-–—:]|\.\.)\s*/);if(!e)throw new Error("Failed to parse column range: "+t);for(var n=t.substr(0,e.index),r=t.substr(e.index+e[0].length),i=ji(n),o=ji(r),a=[],s=o>=i?1:-1,u=Math.abs(o-i)+1,l=0;l<u;l++)a.push(i+l*s);return a}function Hi(t,e){return Ii(t)+"-"+Ii(e)}function zi(t,e){var n={};if(!(t.type in t)){if(t.optional)return n;throw new Error("Data binding must specify '"+t.type+"': "+JSON.stringify(t))}var r=t[t.type].indexOf("::");if(-1==r)throw new Error("Invalid data binding: "+t[t.type]);var i=t[t.type].substr(0,r);n.data_table_id=e[i];var o=t[t.type].substr(r+2);if("column"==t.type)n.column=ji(o);else{if("columns"!=t.type)throw new Error("Unknown data binding type: "+t.type);n.columns=function(t){var e=[],n=(t=t.replace(/^\s+|\s+$/g,"")).split(/\s*,\s*/);1==n.length&&""===n[0]&&(n=[]);for(var r=0;r<n.length;r++){var i=n[r];/^[A-Za-z]+$/.test(i)?e.push(ji(i)):Array.prototype.push.apply(e,Ui(i))}return e}(o)}return n}function Xi(t,e,n,r){var i=n?e[t.data_table_id]+"::":"";if("column"in t)return i+Ii(t.column);if("columns"in t)return i+function(t){for(var e=function(t){for(var e,n,r=[],i=0;i<t.length;i++)i>0&&t[i]==t[i-1]+1?n=t[i]:(void 0!==e&&r.push([e,n]),e=n=t[i]);return void 0!==e&&r.push([e,n]),r}(t),n=[],r=0;r<e.length;r++){var i=e[r];i[0]==i[1]?n.push(Ii(i[0])):n.push(Hi(i[0],i[1]))}return n.join(",")}(t.columns);if(r)return"";throw new Error("Data binding must have .column or .columns")}Mi.prototype.point=function(t,e){if(void 0===t)return this._point;if(Array.isArray(t))this._point=[t[0],t[1]];else if(void 0!==e)this._point=[t,e];else if(t instanceof HTMLElement||t instanceof SVGElement){var n=t.getBoundingClientRect();this._point=[Math.floor(n.left+n.width/2),Math.floor(n.top+n.height/2)]}else console.error("Popup: could not understand argument");return this},Mi.prototype.directions=function(t){return void 0===t?this._directions:("string"==typeof t&&(t=[t]),this._directions=t.slice(),this)},Mi.prototype.text=function(t){return this._html=t.replace(/[&<>]/g,(function(t){return{"&":"&","<":"<",">":">"}[t]})),this},Mi.prototype.on=function(t,e){if(!(t in this.handlers))throw new Error("Popup.on: No such event: "+t);return this.handlers[t].push(e),this},Mi.prototype.fire=function(t,e){if(!(t in this.handlers))throw new Error("Popup.fire: No such event: "+t);for(var n=this.handlers[t],r=0;r<n.length;r++)n[r].call(this,e);return this},Mi.prototype._getElement=function(){var t=this,e="flourish-popup-"+t.unique_id,n=document.getElementById(e);if(!n){(n=document.createElement("div")).className="flourish-popup",n.id=e;var r=n.style;r.display="none",r.margin=r.padding=0,r.position="absolute",r.width="80px",r.height="40px",r.boxSizing="border-box",n.addEventListener("click",(function(e){t.fire("click",e)}),!1);var i=Si("svg",{class:"flourish-popup-svg"},{position:"absolute",top:0,left:0,bottom:0,right:0}),o=Si("filter",{id:"dropshadow-"+t.unique_id,height:"130%"});o.appendChild(Si("feGaussianBlur",{in:"SourceAlpha",stdDeviation:5})),o.appendChild(Si("feOffset",{dx:0,dy:2,result:"offsetblur"}));var a=Si("feComponentTransfer");a.appendChild(Si("feFuncA",{type:"linear",slope:.2})),o.appendChild(a);var s=Si("feMerge");o.appendChild(s),s.appendChild(Si("feMergeNode")),s.appendChild(Si("feMergeNode",{in:"SourceGraphic"})),i.appendChild(o);var u=Si("g",{filter:"url(#dropshadow-"+t.unique_id+")",fill:"white",stroke:"none"});u.appendChild(Si("rect",{x:wi,y:wi,rx:5})),u.appendChild(Si("path")),i.appendChild(u),n.appendChild(i);var l=document.createElement("div");l.className="flourish-popup-content",(r=l.style).position="absolute",r.top=r.left="25px",r.padding="10px",n.appendChild(l),t._getConstrainer().appendChild(n)}return t._resizeConstrainer(),n},Mi.prototype._getConstrainer=Ni,Mi.prototype._resizeConstrainer=function(){yi||Ni.call(this);var t=_i.display;_i.display="none",_i.width=document.documentElement.scrollWidth+"px",_i.height=document.documentElement.scrollHeight+"px",_i.display=t},Mi.prototype.draw=function(){var t=this;if(t.is_visible=!0,t._point){var e=document.documentElement.getBoundingClientRect(),n=t._point[0],r=t._point[1],i=t._container.getBoundingClientRect();n<i.left?n=i.left:n>i.right&&(n=i.right),r<i.top?r=i.top:r>i.bottom&&(r=i.bottom);var o=n-e.left,a=r-e.top,s=t._getElement(),u=s.style,l=s.querySelector(".flourish-popup-svg"),c=l.querySelector("g"),f=c.querySelector("rect"),p=c.querySelector("path"),d=s.querySelector(".flourish-popup-content");u.display="block",t._getConstrainer().style.display="block",d.style.maxWidth=function(e){return t._maxWidth.match(/^\d+(?:\.\d+)?%$/)?e.width*parseFloat(t._maxWidth)/100:t._maxWidth.match(/^\d+(?:\.\d+)?(?:px)?$/)?parseFloat(t._maxWidth):(null!=t._maxWidth&&console.error("Popup: Unknown value for maxWidth: "+t._maxWidth),e.width)}(i)+"px",t._inner_html!=t._html&&(d.innerHTML=t._inner_html=t._html);var h,v,g=d.getBoundingClientRect();do{h=Math.ceil(g.width),v=Math.ceil(g.height),u.width=h+50+"px",u.height=v+50+"px",g=d.getBoundingClientRect()}while(h!=Math.ceil(g.width)||v!=Math.ceil(g.height));f.setAttribute("width",h),f.setAttribute("height",v),l.setAttribute("width",h+50),l.setAttribute("height",v+50);for(var m,y,_=null,w=null,b=null,x=1/0,A=1/0,E=0;E<t._directions.length;E++){var C=t._directions[E],k=ki(C,h,v,n,r,i),S=Math.max(0,Math.floor(i.left)-k.left-15)+Math.max(0,k.right-Math.ceil(i.right)-15),N=Math.max(0,Math.floor(i.top)-k.top-15)+Math.max(0,k.bottom-Math.ceil(i.bottom)-15);if(0==S&&0==N){_=C;break}(S<x||S==x&&N<m)&&(x=S,m=N,w=C),(N<A||N==A&&S<y)&&(A=N,y=S,b=C)}return _?C=_:"horizontal"==t._fallbackFit?C=w:"vertical"==t._fallbackFit?C=b:(console.warn("Popup: failed to point box of size ("+h+", "+v+") at ("+n+", "+r+") within ("+i.left+", "+i.top+", "+i.right+", "+i.bottom+")"),C=t._directions[0]),function(t,e,n,r,i,o,a,s,u,l){var c=Ai[t](r,i,s,u,l);e.left=o-wi-c.pos[0]+"px",e.top=a-wi-c.pos[1]+"px",n.setAttribute("d","M0,0L"+c.shape.join(",")+"Z"),n.setAttribute("transform","translate("+(c.pos[0]+wi)+","+(c.pos[1]+wi)+")")}(C,u,p,h,v,o,a,n,r,i),t}console.error("Popup: cannot draw popup till point() has been specified")},Mi.prototype.hide=function(){return this.is_visible?(this.is_visible=!1,this._getElement().style.display="none",this._getConstrainer().style.display="none",this):this},qi.version="2.1.2";var Wi,Vi,$i,Gi,Ji=[{full:"#F4B1C5",light:"#FFDDE7"},{full:"#967EC6",light:"#D0C5E5"},{full:"#C67EBD",light:"#E5C5E1"},{full:"#7E91C6",light:"#C5CDE5"},{full:"#7EB0C6",light:"#C5DBE5"},{full:"#7EC69B",light:"#C5E5D2"},{full:"#B3C67E",light:"#DDE5C5"},{full:"#C69B7E",light:"#E5D2C5"}],Yi={},Ki=void 0,Zi=0;function Qi(){fi(this.parentNode).classed("open",(function(){return!fi(this).classed("open")}))}function to(t,e){Ki={},Zi=0,t.template_id&&t.dataTables((function(n){if(n)return console.error("Failed to get data tables: "+n);var r=t.dataBindingsForCurrentTemplate(),i=t.getDataTableNames();Vi.html("");var o,a=null;"string"!=typeof e[0]&&(e=["Data"].concat(e));for(var s=0;s<e.length;s++){var u,l=e[s];if("string"!=typeof l){var c=r[l.dataset]&&r[l.dataset][l.key];!o&&c&&(o=c.data_table_id,u.selectAll("option").property("selected",(function(){return this.getAttribute("data-id")==o})));var f=o&&c&&c.data_table_id!==o;Ki[l.dataset+"-"+l.key]=l.type,eo(a?a.append("div"):Vi.append("div"),l,c,i,f)}else{if((a=Vi.append("div").attr("class","data-block open")).append("h2").attr("class","no-select").text(l).on("click",Qi),s!==e.length-1){var p=e[s+1];"string"==typeof p&&(a.append("p").text(p),s+=1)}for(var d in a.append("div").attr("class","datatable-selector-container"),(u=a.select(".datatable-selector-container").append("select").attr("class","datatable-selector").attr("data-index",s).attr("disabled",!Wi.visualisation.can_edit||null)).on("change",(function(){Di.hide();for(var t=+this.dataset.index+1;t<e.length&&"string"!=typeof e[t];t++){var n=e[t];ro(Vi.select("input#data-binding-"+n.dataset+"-"+n.key).node(),n)}})),Wi.visualisation.getDataTableNames())u.append("option").attr("data-id",d).html(Wi.visualisation.getDataTableNames()[d]);o=null}}Wi.spreadsheet&&Wi.spreadsheet.updateHighlights()}))}function eo(t,e,n,r,i){Ji[Zi]||(Zi=0),t.attr("class","settings-option option-type-"+e.type);var o=void 0===n?"":Xi(n,r,i,e.optional);Yi[e.dataset]||(Yi[e.dataset]={}),Yi[e.dataset][e.key]=Zi,t.append("h3").text(e.name),"column"!=e.type||e.optional||t.append("span").attr("class","required").text("REQUIRED"),t.append("input").attr("id","data-binding-"+e.dataset+"-"+e.key).attr("name",e.dataset+"-"+e.key).attr("disabled",!Wi.visualisation.can_edit||null).each((function(){this.value=o})).attr("data-value",o).attr("type","text").call(function(t){return function(e){e.on("change",(function(){Di.hide(),ro(this,t)})).on("keydown",(function(){Wi.confirm.blank()})).on("blur",(function(){Di.hide()}))}}(e)).style("background",Ji[Zi].light).style("border-color",Ji[Zi].full),t.append("p").html(e.description),Zi++}function no(t,e){Wi.confirm.saving(),Wi.visualisation.updateDataBindings(t,(function(t){if(t)return Wi.confirm.error(t.message||t),console.error("Failed to save data binding:",t),void Wi.analytics("send","exception",{exDescription:t.message||t,exFatal:!0});Wi.analytics("send","event","visualisation","change_data_binding",Wi.visualisation.id),Wi.confirm.saved(),e&&e()}))}function ro(t,e){var n,r=t.parentElement.parentElement.querySelector(".datatable-selector").value,i=t.value.indexOf("::")>-1,o={type:e.type};if("column"==o.type?o.column=i?t.value:r+"::"+t.value:o.columns=i?t.value:r+"::"+t.value,e.optional&&!t.value)n=null;else{try{n=zi(o,Wi.visualisation.getDataTableIds())}catch(e){return console.error("Failed to parse data binding",e),t.value=t.getAttribute("data-value"),void Di.point(t).text("Invalid column specification").draw()}if(!n.data_table_id)return t.value=t.getAttribute("data-value"),void Di.point(t).text("No such data table").draw()}var a={};a[e.dataset]={},a[e.dataset][e.key]=n,no(a,(function(){t.setAttribute("data-value",t.value),Wi.preview_pane.updateData((function(e){if(e){var n=t.value&&-1!==t.value.indexOf(/[,-]/)?"these columns":"this column";Di.point(t).text("One or more values in "+n+" are causing an error").draw(),t.value=t.getAttribute("data-value")}})),Wi.spreadsheet&&Wi.spreadsheet.updateHighlights(),Wi.template_settings&&Wi.template_settings.populate()}))}function io(t){Wi=t,Vi=fi(".side-panel .data-bindings"),Wi.data_bindings={update:function(t){t&&(Wi.template_data_bindings=t),to(Wi.visualisation,Wi.template_data_bindings)},modify:function(t){no(t,(function(){to(Wi.visualisation,Wi.template_data_bindings)}))}},fi(".add-data-binding h2").on("click",Qi)}function oo(){if(null==$i){var t=function(){var t=window.location;"about:srcdoc"==t.href&&(t=window.parent.location);var e={};return function(t,n,r){for(;r=n.exec(t);)e[decodeURIComponent(r[1])]=decodeURIComponent(r[2])}(t.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),e}();$i="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return $i}function ao(t){var e=t||window.innerWidth;return e>999?650:e>599?575:400}function so(t,e){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),Gi)return t=parseInt(t,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:t},"*");var r={sender:"Flourish",context:"iframe.resize",method:"resize",height:t,src:n.location.toString()};if(e)for(var i in e)r[i]=e[i];n.parent.postMessage(JSON.stringify(r),"*")}}function uo(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function lo(t){window.addEventListener("message",(function(e){if(null!=e.source&&(e.origin===document.location.origin||e.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var n;try{n=JSON.parse(e.data)}catch(t){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(e.data))}if("Flourish"===n.sender){for(var r=document.querySelectorAll("iframe"),i=0;i<r.length;i++)if(r[i].contentWindow==e.source||r[i].contentWindow==e.source.parent)return void t(n,r[i]);console.warn("could not find frame",n)}}})),uo()&&(window.addEventListener("resize",co),co())}function co(){for(var t=document.querySelectorAll(".flourish-embed"),e=0;e<t.length;e++){var n=t[e];if(!n.getAttribute("data-width")){var r=n.querySelector("iframe"),i=window.getComputedStyle(n),o=n.offsetWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);r.style.width=o+"px"}}}function fo(t,e,n,r){var i;n&&"number"==typeof n?(i=n,n+="px"):n&&n.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(i=parseFloat(n)),r&&"number"==typeof r&&(r+="px");var o=document.createElement("iframe");return o.setAttribute("scrolling","no"),o.setAttribute("frameborder","0"),o.setAttribute("title","Interactive or visual content"),e.appendChild(o),n?o.style.width=n:uo()?o.style.width=e.offsetWidth+"px":o.style.width="100%",!!r||(t.match(/\?/)?t+="&auto=1":t+="?auto=1",r=ao(i||o.offsetWidth)+"px"),r&&("%"===r.charAt(r.length-1)&&(r=parseFloat(r)/100*e.parentNode.offsetHeight+"px"),o.style.height=r),o.setAttribute("src",t),o}var po=function(){document.body.classList.add("loading")},ho=function(){document.body.classList.remove("loading")};function vo(t,e,n,r,i){null==n&&(n=[{text:"Okay",keyCode:13}]);var o,a=fi("body").append("div").attr("class","dialog"),s=a.append("div").attr("class","dialog-inner"),u=s.append("div").classed("text",!0);if(u.append("h1").text(t),"string"==typeof e)o=r?u.append("div").html(e):u.append("p").text(e);else if("object"==typeof e){if(o=u.append(e.type),e.value&&(o.node().value=e.value),e.attributes)for(var l in e.attributes)o.attr(l,e.attributes[l]);o.node().focus()}var c=s;null!=i&&"object"==typeof i&&function(t,e,n,r){r&&t.classed("business",!0);var i=t.append("div").attr("class","text");i.append("p").text(e),i.append("ul").selectAll("li").data(n).enter().append("li").html((function(t){return t})).append("i").attr("class","fa fa-check")}(c=c.append("div").attr("class","upgrade"),i.message,i.list,i.is_business);var f=c.append("div").attr("class","btns"),p={};function d(t){if(t.which in p){var e=p[t.which];document.removeEventListener("keydown",d),e.callback&&e.callback(o.node().value),a.remove(),t.preventDefault()}}return n.forEach((function(t){var e=f.append(t.tag_name||"div").attr("class","btn").style("margin-right","0.75em").text(t.text).on("click",(function(){document.removeEventListener("keydown",d),t.callback&&t.callback(o.node().value),a.remove()}));t.class&&e.classed(t.class,!0),t.keyCode&&(p[t.keyCode]=t),t.href&&e.attr("href",t.href)})),document.addEventListener("keydown",d),a}var go,mo,yo,_o,wo,bo,xo,Ao,Eo="/api/file/upload";function Co(t){(t||document).querySelectorAll("input[type=url]").forEach((function(t){ko(t)}))}function ko(t,e){var n=t.ownerDocument.createElement("button");n.type="button",n.className="upload",n.setAttribute("title","Upload a file from your computer"),n.innerHTML="⬆︎",t.insertAdjacentElement("afterend",n),e||(n.onclick=So)}function So(){var t=this.previousSibling,e=t.getAttribute("accept");t.disabled=!0,t.classList.toggle("uploading",!0),No({accept:e,success:function(e){var n;t.disabled=!1,t.classList.toggle("uploading",!1),t.value=e,"createEvent"in document?(n=document.createEvent("Event")).initEvent("change",!0,!0):n=new Event("change",{bubbles:!0}),t.dispatchEvent(n)},failure:function(){t.disabled=!1,t.classList.toggle("uploading",!1)}})}function No(t){var e=document.getElementById("file-uploader");e||((e=document.createElement("input")).type="file",e.setAttribute("id","file-uploader"),e.style.display="none",document.body.appendChild(e)),t.accept?e.setAttribute("accept",t.accept):e.removeAttribute("accept"),e.onchange=function(){var n,r,i,o;po(),n=e.files,r=t.success,i=t.failure,function(t,e){var n={filename:t.name,content_type:t.type,size:t.size};Do(Eo,n,(function(t,n){return t?e(t):e(null,JSON.parse(n.responseText))}))}(o=n[0],(function(t,e){if(t)return ho(),vo("Upload error","There was a problem uploading your file: "+t),void console.error(t);var n=function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}({file:o},e.fields);Do(e.upload_url,n,(function(t,n){ho(),t?(vo("Upload error","There was a problem uploading your file ("+n.status+")."),console.error(t),i&&i()):r(e.file_url)}))})),e.parentNode.removeChild(e)},e.click()}function Do(t,e,n){var r=new XMLHttpRequest,i=new FormData;if("object"==typeof e){for(var o in e)e.hasOwnProperty(o)&&"file"!==o&&i.append(o,e[o]);e.hasOwnProperty("file")&&i.append("file",e.file)}r.onload=function(){if(r.status>=200&&r.status<300)n(null,r);else try{var e=JSON.parse(r.responseText).error;n(e,r)}catch(e){n(new Error("POST "+t+" received status code: "+r.status),r)}},r.open("POST",t,!0),r.send(i)}function Fo(){return{setup:Co,addButton:ko,startUpload:No}}function To(t,e,n){for(var r in e||(e=[]),n||(n={}),t)e.push(r),"object"==typeof t[r]&&To(t[r],e,n),n[e.join(".")]=t[r],e.pop();return n}function Mo(t){var e={};for(var n in t){for(var r=e,i=n.indexOf("."),o=0;i>=0;i=n.indexOf(".",o=i+1)){var a=n.substring(o,i);a in r||(r[a]={}),r=r[a]}r[n.substring(o)]=t[n]}return e}function Bo(t){if(null==t)return t;var e,n={};for(var r in t)Array.isArray(t[r])?n[r]=t[r].slice():(e=t[r],Array.isArray(e)||"object"!=typeof e||null==e?n[r]=t[r]:n[r]=Bo(t[r]));return n}var Lo,qo,Oo=null;function Ro(){return"MessageChannel"in window}function Po(t,e,n){return xo=!1,Ao=t,Oo=null,t&&t.template_id?go.on("load",function(t,e,n){var r=t.template_id;return function(){hi(),Ao&&Ao.template_id==r&&(go.on("load",null),Wo((function(t,i){t?console.error("Failed to get default state"):Ao&&Ao.template_id==r&&Vo((function(t,o){t?console.error("Failed to call hasData"):Ao&&Ao.template_id==r&&(o?Ao.refreshDataBindings((function(t){t?console.error("Failed to refresh data bindings"):Ao&&Ao.template_id==r&&Ao.prepareData((function(t,o){t?console.error("Failed to prepare data for template"):Ao&&Ao.template_id==r&&ea({data:o,state:e,draw:!0},(function(t,e){Oo=i,n(t,e)}))}))})):ea({state:e,draw:!0},(function(t,e){Oo=i,n(t,e)})))}))})))}}(t,e,n)).attr("src","/template/"+t.template_id+"/embed/?auto=1&environment="+yo):go.on("load",null).attr("src","about:blank")}function jo(t,e,n,r){var i="about:blank"===go.attr("src");if(xo=!1,e){var o=t[e]||"/template/"+e+"/embed";o+="?environment="+yo,r&&(o+="&auto=1"),i?a():go.transition().duration(250).style("opacity",0).on("end",a)}else go.transition().duration(250).style("opacity",0).on("end",(function(){go.on("load",null).attr("src","about:blank")}));function a(){go.on("load",function(t){return function(){Wo((function(e,n){e?console.error("Failed to get default state"):(Oo=n,t())}))}}((function(){n(),i||go.transition().duration(250).style("opacity",1)}))).attr("src",o)}}function Io(t,e){var n=t.template_id;t.refreshDataBindings((function(r){r?console.error("Failed to fetch data bindings"):t.prepareData((function(t,r){if(Ao&&Ao.template_id==n)return t?(console.error("Failed to prepare data for template"),void e(t)):void e(void 0,r)}))}))}function Uo(t,e){Io(t,(function(t,n){if(t)return e(t);ea({data:n,update:!0},e)}))}function Ho(t,e,n){Io(t,(function(t,r){if(t)return n(t);ea({data:r,state:e,overwrite_state:!0,update:!0},n)}))}function zo(t,e,n){if(Ro()){var r=new MessageChannel;r.port1.onmessage=function(t){var e=t.data;if("string"==typeof e){if(!n)return;return n(void 0,JSON.parse(e))}if("object"==typeof e){if("result"in e){if(!n)return;return n(void 0,e.result)}if("error"in e){if(!n)return;return n(e.error)}console.error("Unrecognised response to message",e)}else console.error("Unrecognised response to message",e)},mo.contentWindow.postMessage({sender:"Flourish",method:t,argument:e},"*",[r.port2])}}function Xo(t,e){zo("setState",Mo(t),e)}function Wo(t,e){"function"!=typeof t?zo("getState",t,e):zo("getState",void 0,t)}function Vo(t){zo("hasData",void 0,t)}function $o(t,e){zo("setData",t,e)}function Go(t){zo("getData",void 0,t)}function Jo(t){zo("draw",void 0,t),xo=!0}function Yo(t){bo&&bo.clear(),xo&&zo("update",void 0,t)}function Ko(t,e){zo("snapshot",t,e)}function Zo(){return Bo(Oo)}function Qo(t,e){zo("setFixedHeight",t,e)}function ta(t){if(mo.parentNode.offsetWidth){if(void 0!==t)qo=null!=t;else if(qo)return;var e=t||wo&&wo.responsive_menu&&wo.responsive_menu.getHeightSetting()||_o.getHeightForBreakpoint(mo.offsetWidth);"number"==typeof e&&(e+="px"),mo.style.height=e}}function ea(t,e){xo?delete t.draw:t.draw&&(xo=!0),t.state&&(t.state=Mo(t.state)),bo&&bo.clear(),zo("sync",t,(function(n,r){null!=n||"success"!==r?(t.draw&&(xo=!1),function n(r){r?e&&e(r):function(t,e){return t.data?($o(t.data,e),delete t.data,!1):t.state?(Xo(t.state,e),delete t.state,!1):t.draw?(Jo(e),delete t.draw,!1):!t.update||(Yo(e),delete t.update,!1)}(t,n)&&e&&e(void 0)}(n)):e&&e(void 0)}))}function na(t,e,n,r){var i;return go=fi(t),mo=go.node(),yo=e,wo=n,bo=r,Lo=Fo(),Gi="#amp=1"==window.location.hash,_o={createEmbedIframe:fo,isFixedHeight:oo,getHeightForBreakpoint:ao,startEventListeners:lo,notifyParentWindow:so,isSafari:uo},mo.style.height=_o.getHeightForBreakpoint(mo.offsetWidth)+"px",_o.startEventListeners((function(t){var e,n;"resize"==t.method?ta(t.height):"request-upload"==t.method?(e=t.name,n=t.accept,Lo.startUpload({accept:n||"image/*,video/*,audio/*",success:function(t){var n={};n[e]=t,ea({state:n,update:!0})},failure:function(t){console.error("Upload failed",t)}})):"warn"==t.method&&(bo&&bo.warn(t),console.warn("Warning from template:",t.message,t.explanation))})),Ro()||(i=mo.parentNode)&&fi(i).append("div").attr("class","unsupported-notice").html("<h3>Please update your browser</h3><p>This page only works with newer versions of your browser.</p>"),{loadVisualisation:Po,loadTemplate:jo,updateData:Uo,updateDataAndState:Ho,setState:Xo,getState:Wo,getDefaultState:Zo,hasData:Vo,setData:$o,getData:Go,draw:Jo,update:Yo,snapshot:Ko,setFixedHeight:Qo,resize:ta,sync:ea}}var ra,ia,oa=!1,aa=[];function sa(){Re(".flourish-warn-list").classed("visible",!1),oa=!1}function ua(){return Re(".flourish-warn-btn").on("click",(function(){oa?sa():(Re(".flourish-warn-list").classed("visible",!0),oa=!0)})),{clear:ca,warn:fa}}function la(){Re(".flourish-warn-container").classed("visible",aa.length),aa.length>100&&(aa.length=100);var t=Re(".flourish-warn-list ul").selectAll("li").data(aa),e=t.enter().append("li");e.append("i").attr("class","fa fa-warning"),e.append("p").attr("class","message"),e.append("p").attr("class","explanation");var n=t.merge(e);n.select(".message").text((function(t){return t.message||""})),n.select(".explanation").text((function(t){return t.explanation||""})),t.exit().remove()}function ca(){aa=[],la(),sa()}function fa(t){aa.unshift(t),la()}function pa(){var t=ra.visualisation,e=t.getTemplate(),n=!1,r=!1,i=!1;function o(){var t=ra.template_settings.getSettingsForCurrentTemplate(),e=ra.visualisation.settingsForCurrentTemplate(),n={};for(var r in e)r in t&&(n[r]=e[r]);ia.loadVisualisation(ra.visualisation,n,(function(){ra.template_settings.populate(),ho()})),mi()}e.getSettings((function(t,e){t?console.error("Failed to get template settings: "+t):(ra.template_settings.update(e),n=!0,r&&i&&o())})),e.getDataBindings((function(t,e){t?console.error("Failed to get template data bindings: "+t):(ra.data_bindings.update(e),r=!0,n&&i&&o())})),t.refreshDataBindings((function(t){t?console.error("Failed to get template data bindings: "+t):(i=!0,r&&n&&o())}))}function da(t){ia.updateData(ra.visualisation,t)}var ha="Add new value: ";function va(t,e,n,r,i){var o;t.setAttribute("data-autocomplete",e),t.setAttribute("autocomplete","off"),t.insertAdjacentHTML("afterend",'<i class="fa fa-chevron-down clickable"></i><div class="dropdown autocomplete" id="'+e+'"></div>');var a=fi(document.getElementById(e));a.classed("click-to-open",!0);var s=a.append("div").attr("class","dropdown-list");function u(t){if(1===t.length)return"dropdown-category";var e="dropdown-item";return o&&t[0]===o&&(e+=" current"),e}function l(t){s.selectAll("div").remove(),s.selectAll("div").data(t).enter().append("div").attr("class",u).attr("data-value",(function(t){return"string"==typeof t?t||null:t[1]})).html((function(t){return i?i(t,this):"string"==typeof t?t:t[0]})),t.length||s.append("div").attr("class","dropdown-item disabled").text("No matches found")}function c(){a.classed("open",!1)}function f(t){var e=t.textContent;return 0===e.indexOf(ha)&&(e=e.substr(ha.length)),e}return a.on("mousedown",(function(e){var n=e.target;n.hasAttribute("data-value")?(t.value=f(n),t.setAttribute("data-value",n.getAttribute("data-value")),c(),fi(t).dispatch("change")):e.preventDefault()})),fi(t).on("keydown.autocomplete",(function(e){var n,r;9==e.keyCode||13==e.keyCode?(n=s.select(".selected")).empty()||(t.value=f(n.node()),t.setAttribute("data-value",n.attr("data-value")),c(),fi(t).dispatch("change"),t.blur()):40==e.keyCode?((n=s.select(".selected")).empty()||(r=n.node().nextSibling),r||(r=s.select(".dropdown-item[data-value]").node()),s.selectAll(".selected").classed("selected",!1),fi(r).classed("selected",!0)):38==e.keyCode&&((n=s.select(".selected")).empty()||(r=n.node().previousSibling),r||(r=s.select(".dropdown-item:last-child").node()),s.selectAll(".selected").classed("selected",!1),fi(r).classed("selected",!0))})).on("input.autocomplete",(function(){var e,i=t.value,o=i.toLowerCase(),a=!1;if(fi(t).attr("data-value",i),i){e=[];for(var s=0;s<n.length;s++){var u=("string"==typeof n[s]?n[s]:n[s][0]).toLowerCase();u==o&&(a=!0),0==u.indexOf(o)&&e.push(n[s])}r&&!a&&e.unshift([ha+i,i])}else e=n;l(e)})).on("focus.autocomplete",(function(){o=t.value,l(n),a.classed("open",!0)})).on("blur.autocomplete",c),{options:function(t){if(!arguments.length)return n;l(n=t)}}}var ga="https://fonts.googleapis.com/css?family=",ma=["Source Sans Pro","Roboto Condensed","Merriweather","Lora","Playfair Display","Coda","Lobster","Cabin Sketch"],ya="Same as parent",_a=[],wa=[],ba={};function xa(t){return ga+t.replace(/ /g,"+")+":400,700"}function Aa(t){var e=wa.concat(_a,ma.map((function(t){return{name:t,url:xa(t)}})));return t&&e.unshift({name:ya}),e}function Ea(t){return Aa(!0).find((function(e){return e.name==t}))}var Ca=!1;function ka(t){return t.substr(t.lastIndexOf("=")+1).replace(/\+/g," ")}function Sa(t){var e=t.target,n=e.value;if(n&&(0==n.indexOf(ga)&&(n=e.value=ka(n)),!Ea(n))){if(/^https?:\/\//.test(n)){Ca||(Na(n),e.value="");var r=n;return n=e.value=ka(r),wa.push({name:n,url:r}),void Da()}var i=xa(n);try{var o=new XMLHttpRequest;if(o.open("HEAD",i,!1),o.send(),404==o.status)throw"Font not found";wa.push({name:n,url:i}),Da()}catch(t){Na(n),e.value=""}}}function Na(t){vo("Unrecognised font “"+t+"”","Fonts must be chosen from Google Fonts. Visit <a href='https://fonts.google.com'>fonts.google.com</a> to find more",null,!0)}function Da(){var t,e,n=Object.keys(ba);for(t=0;t<n.length;++t)(e=ba[n[t]]).autocomplete.options(Aa(e.can_inherit).map((function(t){return t.name})))}var Fa={initialize:function(t,e,n){var r=!!e.optional;Ca=n,t.classList.add("font-menu"),ba[e.property]={autocomplete:va(t,e.property+"-dropdown",Aa(r).map((function(t){return t.name})),!0),can_inherit:r},t.addEventListener("change",Sa)},update:function(t,e){var n=e?e.name:ya;t.value=n,Ea(n)||(n!=ya&&wa.push({name:n,url:e.url}),Da())},getValue:function(t){if(/^https?:\/\//.test(t.value))return{name:ka(t.value),url:t.value};var e=t.value;if(e==ya)return null;var n=Ea(e);return n||{name:e,url:xa(e)}},replaceThemeFonts:function(t){_a=(t||[]).map((function(t){return{name:t.name,url:t.url}})),Da()}},Ta="$";function Ma(){}function Ba(t,e){var n=new Ma;if(t instanceof Ma)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==e)for(;++i<o;)n.set(i,t[i]);else for(;++i<o;)n.set(e(r=t[i],i,t),r)}else if(t)for(var a in t)n.set(a,t[a]);return n}function La(){}Ma.prototype=Ba.prototype={constructor:Ma,has:function(t){return Ta+t in this},get:function(t){return this[Ta+t]},set:function(t,e){return this[Ta+t]=e,this},remove:function(t){var e=Ta+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===Ta&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===Ta&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===Ta&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===Ta&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===Ta&&++t;return t},empty:function(){for(var t in this)if(t[0]===Ta)return!1;return!0},each:function(t){for(var e in this)e[0]===Ta&&t(this[e],e.slice(1),this)}};var qa=Ba.prototype;La.prototype=function(t,e){var n=new La;if(t instanceof La)t.each((function(t){n.add(t)}));else if(t){var r=-1,i=t.length;if(null==e)for(;++r<i;)n.add(t[r]);else for(;++r<i;)n.add(e(t[r],r,t))}return n}.prototype={constructor:La,has:qa.has,add:function(t){return this[Ta+(t+="")]=t,this},remove:qa.remove,clear:qa.clear,values:qa.keys,size:qa.size,empty:qa.empty,each:qa.each};var Oa={};function Ra(t){t.running||(t.running=!0,Pa(t,(function(){t.running=!1})))}function Pa(t,e){t.request=function(t,e){var r="method"in t?t.method:"POST",i="request_type"in t?t.request_type:"application/json",o="response_type"in t?t.response_type:"application/json",a=t.url,s=t.payload,u=t.callback;if(s){if("function"!=typeof s)throw new Error("Internal error: processRequestThen: payload must be a function, not "+typeof s,s);"string"!=typeof(s=s())&&(s=JSON.stringify(s))}var l=function(t,e){var r,i,o,a,s=n("beforesend","progress","load","error"),u=Ba(),l=new XMLHttpRequest,c=null,f=null,p=0;function d(t){var e,n=l.status;if(!n&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(l)||n>=200&&n<300||304===n){if(o)try{e=o.call(r,l)}catch(t){return void s.call("error",r,t)}else e=l;s.call("load",r,e)}else s.call("error",r,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(t)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=l.ontimeout=d:l.onreadystatechange=function(t){l.readyState>3&&d(t)},l.onprogress=function(t){s.call("progress",r,t)},r={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?u.get(t):(null==e?u.remove(t):u.set(t,e+""),r)},mimeType:function(t){return arguments.length?(i=null==t?null:t+"",r):i},responseType:function(t){return arguments.length?(a=t,r):a},timeout:function(t){return arguments.length?(p=+t,r):p},user:function(t){return arguments.length<1?c:(c=null==t?null:t+"",r)},password:function(t){return arguments.length<1?f:(f=null==t?null:t+"",r)},response:function(t){return o=t,r},get:function(t,e){return r.send("GET",t,e)},post:function(t,e){return r.send("POST",t,e)},send:function(e,n,o){return l.open(e,t,!0,c,f),null==i||u.has("accept")||u.set("accept",i+",*/*"),l.setRequestHeader&&u.each((function(t,e){l.setRequestHeader(e,t)})),null!=i&&l.overrideMimeType&&l.overrideMimeType(i),null!=a&&(l.responseType=a),p>0&&(l.timeout=p),null==o&&"function"==typeof n&&(o=n,n=null),null!=o&&1===o.length&&(o=function(t){return function(e,n){t(null==e?n:null)}}(o)),null!=o&&r.on("error",o).on("load",(function(t){o(null,t)})),s.call("beforesend",r,l),l.send(null==n?null:n),r},abort:function(){return l.abort(),r},on:function(){var t=s.on.apply(s,arguments);return t===s?r:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return r.get(e)}return r}(a);i&&"GET"!==r&&l.header("Content-Type",i);o&&l.mimeType(o);return l.on("error",(function(t){var n;try{n=JSON.parse(t.target.responseText),u(n.error)}catch(e){u("Internal error: "+t.target.responseText)}e()})),l.on("load",(function(t){var n=t.responseText;"application/json"===o&&(n=JSON.parse(n));try{u(void 0,n)}catch(t){console.error(t.stack)}e()})),l.send(r,s),l}(t.items.shift(),(function(){t.request=null,0==t.items.length?e():Pa(t,e)}))}function ja(t,e){void 0===e&&(e="default"),e in Oa||(Oa[e]={items:[],running:!1,name:e}),Oa[e].items.push(t),Ra(Oa[e])}var Ia,Ua,Ha={update:function(t,e){ja({url:"/api/user",method:"POST",payload:function(){return{fields:t}},callback:e})},isUsernameAvailable:function(t,e){ja({url:"/api/user/username?u="+encodeURIComponent(t),method:"GET",callback:e})},getReviewCount:function(t){ja({url:"/api/reviews/count",method:"GET",callback:t})},logHistory:function(t){ja({url:"/api/history",method:"POST",payload:function(){return t},callback:function(){}})},addApiKey:function(t){ja({url:"/api/user/api_keys",method:"PUT",callback:t})},getApiKeys:function(t){ja({url:"/api/user/api_keys",method:"GET",callback:t})},deleteApiKey:function(t,e){ja({url:"/api/user/api_keys/"+t,method:"DELETE",callback:e})},fetchProjects:function(t,e,n,r,i,o,a,s){var u="";e&&(u+="&folder="+encodeURIComponent(e)),n&&(u+="&sort="+encodeURIComponent(n)),r&&(u+="&filter="+encodeURIComponent(r)),i&&(u+="&offset="+encodeURIComponent(i)),o&&(u+="&limit="+encodeURIComponent(o)),a&&(u+="&search="+encodeURIComponent(a)),s&&(u+="&is_recent=true"),ja({url:"/api/user/projects?"+u,method:"GET",callback:t})},addTag:function(t,e){ja({url:"/api/user/tag/"+encodeURIComponent(t),method:"PUT",callback:e})},renameTag:function(t,e,n){ja({url:"/api/user/tag/"+encodeURIComponent(t)+"/"+encodeURIComponent(e),method:"PUT",callback:n})},removeTag:function(t,e){ja({url:"/api/user/tag/"+encodeURIComponent(t),method:"DELETE",callback:e})},fetchFolders:function(t){ja({url:"/api/user/folders",method:"GET",callback:t})}};function za(t){var e;if(Ia=fi(".detailed-settings"),(Ua=Ia.append("div").attr("class","settings-block")).append("h2").text("Back to settings").on("click",(function(){Ia.transition().duration(100).style("opacity",0).on("end",(function(){fi(this).html("").style("display","none"),fi(".template-settings").style("display","block").style("opacity",0).transition().duration(500).style("opacity",1)})),Ia.node()})),"string"==typeof t)e=Ua.append("div").html(t);else if("object"==typeof t&&(e=Ua.append(t.type),t.value&&(Ua.node().value=t.value),t.attributes))for(var n in t.attributes)e.attr(n,t.attributes[n]);return e.node().focus(),fi(".template-settings").style("display","none"),Ia.style("display","block").style("opacity",0).transition().duration(500).style("opacity",1),Ia.node()}var Xa,Wa,Va,$a,Ga={},Ja={},Ya={"Flourish 1":{scheme:"flourish_default_1",colors:["#1D6996","#EDAD08","#73AF48","#94346E","#38A6A5","#E17C05","#5F4690","#0F8554","#6F4070","#CC503E","#994E95","#666666"]},"Flourish 2":{scheme:"flourish_default_2",colors:["#11A579","#CC503E","#3969AC","#F2B701","#7F3C8D","#80BA5A","#E68310","#CF1C90","#008695","#F97B72","#4B4B8F","#A5AA99"]},Rainbow:{colors:["#5F4690","#1D6996","#38A6A5","#0F8554","#73AF48","#EDAD08","#E17C05","#CC503E","#94346E","#6F4070","#994E95","#666666"]},Pastel:{colors:["#66C5CC","#F6CF71","#F89C74","#DCB0F2","#87C55F","#9EB9F3","#FE88B1","#C9DB74","#8BE0A4","#B497E7","#D3B484","#B3B3B3"]},Antique:{colors:["#855C75","#D9AF6B","#AF6458","#736F4C","#526A83","#625377","#68855C","#9C9C5E","#A06177","#8C785D","#467378","#7C7C7C"]},Accent:{scheme:"schemeAccent",colors:Vn},Dark:{scheme:"schemeDark2",colors:$n},Paired:{scheme:"schemePaired",colors:Gn},Pale:{scheme:"schemePastel1",colors:Jn},"Farrow & Ball":{colors:["#EDD8C4","#C4A999","#F9C1C0","#B76A4C","#8F483C","#783027","#8A1D2E","#602A1F","#893838","#BD795A","#DC6130","#AD3B34","#ECE8BD","#F7E28A","#EBEB82","#FAD862","#F1CA61","#F5C03B","#F9E7D4","#F4E4AC","#EFD491","#DAC589","#D2B15E","#CD9344","#EFEFCC","#E8E7CA","#CAD5AD","#B9B495","#73806F","#636F65","#BDAB65","#889A73","#829C7A","#6C7855","#81B693","#BBBEA0","#99A286","#AAC0B3","#427E7F","#769194","#ECF3EC","#EBEBD4","#D0D9C9","#9EAF9F","#7A8E8D","#516365","#DBE5DC","#C4C9C5","#CBD7D7","#AABEBF","#66839A","#A0D2CD","#56AAC5","#535E7D","#2E3548","#48606E","#2C3437"]}},Ka={};function Za(){var t,e={};for(t in Ka)e[t]=Ka[t];for(t in Ya)e[t]=Ya[t];return e}var Qa="Edit color palette";function ts(t){t&&t.length?(Ka={},t.forEach((function(t){var e=Object.keys(t)[0];Ka[e]={colors:t[e]}}))):Ka={},function(){for(var t in Ga){Ga[t].options(ns())}}()}function es(){if(void 0!==Xa)return Xa;var t=document.createElement("input");return t.setAttribute("type","color"),t.setAttribute("value","!"),Xa="color"==t.type&&"!"!==t.value}function ns(){var t=[],e=Za();for(var n in t.push([Qa,""]),e)t.push([n,e[n].colors.join("|")]);return t}function rs(t,e){var n=t[0],r=t[1];if(!r)return"<em><i class='fa fa-pencil'></i>"+Qa+"</em>";Array.isArray(r)||(r=r.split("|"));var i="";return e&&n&&(i+="<label>"+n+"</label>"),r.forEach((function(t,e){i+="<span data-index="+e+" style='background-color:"+t+"'></span>"})),i}function is(t,e){var n,r,i=Za(),o=t.parentNode.querySelector(".color-swatches");if(Array.isArray(e))r=e;else if("string"==typeof e){if(i[e])n=e;else for(var a in i)if(i[a].scheme==e){n=a;break}n&&(r=i[n].colors)}if(!r||!r.length)return t.parentNode.classList.remove("custom"),t.removeAttribute("data-value"),t.value="",void(o.innerHTML="");o.innerHTML=rs([null,r]),t.setAttribute("data-value",r.join("|"))}function os(t){$a=t.target,t.dataTransfer.setData("text/plain","x"),event.dataTransfer.effectAllowed="move",fi($a).classed("dragging",!0),pi(".palette p:not(.dragging) input").style("pointer-events","none")}function as(t){t.preventDefault();var e=fi(".palette").selectAll("[draggable='true']").style("border-color",null),n=fi(t.target);if("true"===n.attr("draggable")){var r="bottom";if(n.node()===e.nodes()[0]){var i=t.target.getBoundingClientRect(),o=i.top+i.height/2;t.clientY<o&&(r="top")}fi(t.target).style("border-"+r,"1px solid black")}}function ss(t){if($a){for(var e=t.target;e&&("P"!==e.tagName||!e.nextSibling);)e=e.parentNode;if(e){var n=e.nextSibling;if(e===fi(".palette").selectAll("[draggable='true']").style("border-color",null).nodes()[0]){var r=e.getBoundingClientRect(),i=r.top+r.height/2;t.clientY<i&&(n=e)}e.parentNode.insertBefore($a,n),$a=!1,cs()}}}function us(){fi($a).classed("dragging",!1),pi(".palette *").style("border-bottom",null).style("border-top",null),pi(".palette p input").style("pointer-events",null)}function ls(t){for(var e=t.target;e&&"BUTTON"!==e.tagName;)e=e.parentNode;e&&(e.classList.contains("fa-plus-square")?function(t){var e=t.target.parentNode,n=fs("#000000");e.insertAdjacentHTML("beforebegin",n),cs()}(t):e.classList.contains("fa-times")&&function(t){t.parentNode.childNodes.length>2?t.parentNode.removeChild(t):("INPUT"==t.firstChild.tagName?t.firstChild.value="#000000":t.firstChild.style.backgroundColor="#000000",t.firstChild.nextSibling.value="#000000");cs()}(e.parentNode))}function cs(){for(var t=Va.getAttribute("data-autocomplete"),e=Ga[t],n=[],r=Wa.querySelectorAll(".palette input[type=text]"),i=0;i<r.length;i++)n.push(r[i].value);var o=e.options();Ja[t]?o[0][1]=n.join("|"):o.unshift(["Custom",n.join("|")]),Ja[t]=n,e.options(o),is(Va,n),fi(Va).dispatch("change")}function fs(t){var e="<p draggable=true><span class='swatch-handle'>.. .. ..</span>";return es()?e+="<input type='color' value='"+t+"'>":e+="<span class='swatch-color' style='background-color:"+t+"'></span>",e+="<input type='text' value='"+t+"'><button type='button' class='fa fa-times'></button></p>"}function ps(t){var e=t.target,n=e.value,r=e.parentNode;if(!n)return r.parentNode.removeChild(r),void cs();var i=E(n);if(!i)return console.warn("bad color",n),"color"==e.type?e.value=e.nextSibling.value:es()?e.value=e.previousSibling.value:e.value=e.previousSibling.style.backgroundColor,void(Di.point(e).text(n+" is not a valid color").draw()._getElement().style.zIndex=115);"color"==e.type?e.nextSibling.value=n:es()?e.previousSibling.value=i.hex():e.previousSibling.style.backgroundColor=n,cs()}var ds,hs,vs,gs={initialize:function(t,e){e.choices&&ts(e.choices),t.type="text",t.classList.add("colors");var n=document.createElement("span");n.setAttribute("class","color-swatches"),t.parentNode.insertBefore(n,t);var r=t.getAttribute("name")+"-dropdown";Ga[r]=va(t,r,ns(),!1,rs),t.addEventListener("change",(function(e){t.value==Qa?(e.stopImmediatePropagation(),t.value="",function(t){Va=t;var e=(Wa=za({type:"div",attributes:{class:"palette"}})).querySelector(".palette"),n=function(t,e){e||(e=t.parentNode.querySelector(".color-swatches"));for(var n=[],r=0;r<e.childNodes.length;r++)if(!e.childNodes[r].classList.contains("fa")){var i=e.childNodes[r].style.backgroundColor,o=E(i);o?n.push(o.hex()):(console.warn("Bad color",i),n.push("#000000"))}return n}(t),r="";n.forEach((function(t){r+=fs(t)})),r+="<p><button class='fa fa-plus-square clickable'></button></p>",e.innerHTML=r,e.addEventListener("change",ps),e.addEventListener("dragstart",os),e.addEventListener("dragover",as),e.addEventListener("drop",ss),e.addEventListener("dragend",us),e.addEventListener("click",ls)}(t)):is(t,(t.getAttribute("data-value")||"").split("|"))}))},update:is,getValue:function(t){var e=t.getAttribute("data-value");return e?e.split("|"):null},replaceThemeColors:ts},ms=void 0;function ys(t){fi(t.parentNode).classed("open",(function(){return!fi(this).classed("open")}))}function _s(t){if(t){ms={};for(var e=0,n=null,r=null,i=ds&&ds.user?ds.user.template_settings_overrides:{},o=0;o<t.length;o++){var a=t[o];if("string"!=typeof a){if("object"!=typeof a||n||r||(e++,r=vs.append("div").attr("class","toplevel-settings-block")),"hidden"!==a.type){var s=n||r;if(a.new_section&&(s.append("div").classed("settings-divider",!0),"string"==typeof a.new_section&&s.append("h3").classed("settings-subhead",!0).text(a.new_section)),void 0!==a.show_if){if(a.show_condition)throw new Error("BUG: show_if present as well as show_condition");a.show_condition=[{type:"show",condition:a.show_if}],delete a.show_if}else if(void 0!==a.hide_if){if(a.show_condition)throw new Error("BUG: hide_if present as well as show_condition");a.show_condition=[{type:"hide",condition:a.hide_if}],delete a.hide_if}ms[a.property]=a.type,ws(s.append("div"),a,i)}}else r=null,(n=vs.append("div").attr("class","settings-block")).append("h2").attr("class","no-select").attr("tabindex","0").text(a).on("click",(function(){ys(this)})).on("keyup",(function(t){13===t.keyCode&&ys(this)})),n.classed("open",e<1),"State documentation"===a&&n.style("display","none"),e++}pi(".upgrade-setting").on("click",(function(){!function(t,e,n,r,i){var o=[],a=[];i?(o.push(["Upgrade to a business account so you can:"]),a.push(["Add custom logos, colours and styles to keep projects on-brand","Remove Flourish logo","Manage your team with collaboration and approval features","And <a href='https://flourish.studio/pricing' target='_blank'>many other benefits</a>"])):(o.push(["Upgrade your account to:"]),a.push(["Keep your data and projects private","Download projects","Get priority support"]));var s=Math.floor(Math.random()*o.length),u=Math.floor(Math.random()*a.length),l="title"+s+"-list"+u,c="upgrade-click",f=[];i?f.push({text:"Email us",class:"convert",tag_name:"a",href:"mailto:sales@flourish.studio?subject=Business%20upgrade%20enquiry",keyCode:13,callback:function(){t.analytics("send","event",c,r,l),Ha.logHistory({category:"upgrade",action:"clicked",detail:r})}}):f.push({text:"Upgrade now",class:"convert",keyCode:13,callback:function(){t.analytics("send","event",c,r,l),Ha.logHistory({category:"upgrade",action:"clicked",detail:r}),setTimeout((function(){window.location.href="/choose-subscription"}),1e3)}}),f.push({text:"Maybe later",keyCode:27,class:"secondary",callback:function(){t.analytics("send","event","upgrade-close",r,l),Ha.logHistory({category:"upgrade",action:"closed",detail:r})}}),t.analytics("send","event","upgrade-open",r,l),Ha.logHistory({category:"upgrade",action:"viewed",detail:r}),vo(e,n,f,!0,{message:o[s],list:a[u],is_business:i})}(ds,"This is a premium feature","Upgrade your plan to change this setting.","upgrade-settings",!0)})),Oi()}}function ws(t,e,n){e.upgrade=e.property in n;var r=e.choices&&("buttons"==e.style||"boolean"==e.type);t.attr("class","settings-option option-type-"+e.type+(r?" settings-buttons":"")+(e.upgrade?" upgrade-setting":""));var i=t.append("label").attr("for","setting-"+e.property).classed("hidden",null==e.name).append("h3").text(e.name).classed("no-select",!0);e.upgrade?i.append("i").attr("class","popup fa fa-star setting-tooltip tooltip-upgrade").style("font-family","FontAwesome").style("background-color","#93366e").attr("data-popup-head","This is a premium feature").attr("data-popup-body",e.description?e.description.replace(/\[\[/g,"").replace(/\]\]/g,""):"").attr("data-popup-position","top"):e.description&&i.append("i").attr("class","popup fa fa-question setting-tooltip tooltip-help").style("font-family","FontAwesome").attr("data-popup-body",e.description.replace(/\[\[/g,"").replace(/\]\]/g,"")).attr("data-popup-position","top"),e.width&&t.classed("width-"+e.width.replace(/ /g,"-"),!0);var o="input";if("text"!=e.type&&"code"!=e.type||(o="textarea"),"code"==e.type){var a=!1;t.append("i").attr("class","popup fa fa-reply clickable wrap-control").attr("data-popup-body","Wrap/unwrap text").attr("data-popup-position","top").on("click",(function(){a=!a,fi(this.parentNode).select("textarea").attr("wrap",a?null:"off"),fi(this).classed("selected",a)}))}var s=t.append(o).attr("id","setting-"+e.property).attr("name",e.property).attr("disabled",!ds.visualisation.can_edit||null),u=s.node();if("colors"==e.type)gs.initialize(u,e);else if("font"==e.type)Fa.initialize(u,e,ds.user&&null!=ds.user.company_id);else if("number"==e.type)u.setAttribute("type","number"),null!=e.min&&u.setAttribute("min",e.min),null!=e.max&&u.setAttribute("max",e.max),e.step&&u.setAttribute("step",e.step);else if("url"==e.type)u.setAttribute("type","url"),hs.addButton(u,e.upgrade);else if(r){s.remove(),s=t.append("div").attr("id","setting-"+e.property).attr("name",e.property).classed("buttons-container",!0).classed("large","large"==e.size),u=s.node();var l=e.choices.length,c=[3,4,5],f=function(){if(l<=2)return{column_count:l,rows:1};var t=c.map((function(t){return{column_count:t,orphans:l%t/t,rows:l/t}})).filter((function(t){return t.rows>=1})).sort((function(t,e){return t.rows>e.rows?1:t.rows<e.rows?-1:0})),e=t.filter((function(t){return 0===t.orphans}));return 1===e.length||e.length>1?e[0]:0===e.length?t.sort((function(t,e){return t.orphans>e.orphans?-1:t.orphans<e.orphans?1:0}))[0]:void 0}();e.choices.forEach((function(t,n){s.append("input").attr("type","radio").attr("name",e.property).attr("value",t[1]).attr("id",e.property+"_"+n).attr("disabled",!ds.visualisation.can_edit||null).call(bs(e));var r=s.append("label").attr("for",e.property+"_"+n).style("width",100/f.column_count+"%").style("background-image",t[2]?"url("+t[2]+")":null).style("border-radius",(function(){var t=f.column_count,e=Math.ceil(f.rows),r=t*e-l;return e<=1?0===n?"3px 0 0 3px":n===t-1?"0 3px 3px 0":null:e>1?0===n?"3px 0 0 0":n===t-1?"0 3px 0 0":n===l-(t-r)?"0 0 0 3px":n===l-1&&0===r?"0 0 3px 0":null:null})),i=t[0].match(/fa-(\S*)/g),o=t[0].match(/^data:image\/(svg|svg\+xml|png|jpg);base64,[A-Z-a-z0-9+/=]*$/);i?r.append("i").attr("class","fa "+i[0]):o?r.append("img").attr("src",t[0]):r.text(t[0])}))}else"boolean"==e.type?(u.setAttribute("type","checkbox"),t.append("label").attr("class","slider").attr("for","setting-"+e.property)):u.setAttribute("type","text");if("code"==e.type&&(u.setAttribute("wrap","off"),s.on("keydown.tab",(function(t){var e=t;if(9===e.keyCode&&!(e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault();var n=this.selectionStart;this.value=this.value.substring(0,n)+"\t"+this.value.substring(this.selectionEnd),this.selectionEnd=n+1}}))),e.choices&&"string"==e.type&&"buttons"!=e.style&&va(u,e.property+"-dropdown",e.choices,e.choices_other),"color"==e.type){fi(u).classed("color",!0).style("display","none");var p=fi(u.parentNode).append("div").attr("class","color-picker");e.optional&&p.append("button").attr("class","cancel-setting popup").html("<svg><use xlink:href='#cancel-setting'></use></svg>").attr("data-popup-body","If cleared, the color will be set automatically based on the theme or context").on("click",(function(){u.value="",s.dispatch("change"),fi(this.parentNode).classed("is-null",!0)})),p.append("div").attr("class","color-wrapper").append("input").attr("type","color").on("change",(function(){u.value=this.value,s.dispatch("change"),fi(this.parentNode.parentNode).classed("is-null",!1)})).on("focus",(function(){fi(this.parentNode.parentNode).classed("active",!0)})).on("blur",(function(){fi(this.parentNode.parentNode).classed("active",!1)}))}e.placeholder&&u.setAttribute("placeholder",e.placeholder),e.size&&u.classList.add("size-"+e.size),s.call(bs(e))}function bs(t){return function(e){var n=!1;e.on("change",(function(){var e=this;Di.hide(),n=!0,ds.preview_pane.getState(t.property,(function(r,i){return r?(console.error("Failed to get state property "+t.property,r),void(n=!1)):function(t,e){if("number"!==e.type)return!0;if(""===t.value)return!!e.optional||(Di.point(t).text("A value is required").draw(),!1);var n=parseFloat(t.value);return e.hasOwnProperty("min")&&n<e.min?(Di.point(t).text("Value cannot be less than "+e.min).draw(),t.value=e.min):e.hasOwnProperty("max")&&n>e.max&&(Di.point(t).text("Value cannot be greater than "+e.max).draw(),t.value=e.max),!0}(e,t)?void function(t,e,n){r=e.property,i=100,o=Cs,a=[t,e,n],clearTimeout(xs[r]),xs[r]=setTimeout((function(){o.apply(window,a),delete xs[r]}),i);var r,i,o,a}(e,t,(function(r){if(!r)return n=!1,void("SELECT"==e.tagName&&fi(e).dispatch("blur"));var o="radio"==e.type?e.nextSibling:e;Di.point(o).text("Not changed: "+r).draw();var a={};a[t.property]=i,ds.preview_pane.setState(a,(function(r){if(r)return console.error("Failed to revert setting "+t.property+" to value: "+i),void(n=!1);ds.preview_pane.update((function(r){if(r)return console.error("Failed to update after reverting setting "+t.property+" to value: "+i),void(n=!1);Es(e,i),n=!1}))}))})):(e.value=i,void(n=!1))}))})).on("keydown",(function(t){ds.confirm.blank(),13==t.keyCode&&Di.hide()})).on("blur",(function(){if(!n){var e=this;Di.hide(),ds.preview_pane.getState(t.property,(function(n,r){n?console.error("Failed to get state property "+t.property,n):Es(e,r)}))}}))}}var xs={};function As(t,e,n){if(t.classList.contains("colors"))return gs.getValue(t);if(t.classList.contains("font-menu")){var r=Fa.getValue(t);return e&&!r?n?null:"":r}if(t.classList.contains("buttons-container")){for(var i,o=t.querySelectorAll("input[type='radio']"),a=0;a<o.length;a++)if(o[a].checked){i=o[a];break}if(!i)return n?null:"";t=i}switch(t.getAttribute("type")){case"checkbox":return t.checked;case"number":return e&&!t.value.length?n?null:"":+t.value;case"radio":if(t.parentNode.parentNode.classList.contains("option-type-boolean"))return"true"==t.value;default:return e&&t.classList.contains("color")&&!t.value.length?n?null:"":t.hasAttribute("data-value")?t.getAttribute("data-value"):t.value}}function Es(t,e){if(t.classList.contains("colors"))gs.update(t,e);else if(t.classList.contains("font-menu"))Fa.update(t,e);else if("checkbox"==t.getAttribute("type"))t.checked=e;else if(t.classList.contains("color"))t.value=e,fi(t.parentNode).select(".color-picker").classed("is-null",null===e),fi(t.parentNode).select(".color-wrapper input").node().value=e;else if(t.getAttribute("data-autocomplete")){for(var n=function(t){for(var e=0;e<ds.settings.length;e++){var n=ds.settings[e];if(n.property===t)return n}}(t.name),r=0;r<n.choices.length;r++){var i,o,a=n.choices[r];if("string"==typeof a?i=o=a:(i=a[1],o=a[0]),e==i)return t.value=o,void t.setAttribute("data-value",i)}t.value=e,t.setAttribute("data-value",e)}else if(t.className.indexOf("buttons-container")>-1){var s=t.querySelectorAll("input[type='radio']");for(r=0;r<s.length;r++)s[r].value===""+e&&(s[r].checked=!0)}else t.value=e}function Cs(t,e,n){var r={},i=As(t,e.optional);if(r[e.property]=i,!("choices"in e)||"colors"===e.type||function(t,e){return!!t.choices_other||-1!==t.choices.map((function(t){return t instanceof Array?t[1]:t})).indexOf(e)}(e,i)){ds.confirm.saving();var o=!1,a={};a[e.property]=As(t,e.optional,!0),ds.preview_pane.setState(a,(function(t){if(t)return s(t);ds.preview_pane.update((function(t){if(t)return s(t);ds.visualisation.updateSettings(r,(function(t){if(t)return s(t);ds.analytics("send","event","visualisation","change_setting",ds.visualisation.id),Ss(),ds.confirm.saved(),n&&n()}))}))}))}else n&&n("You can only choose values from the list");function s(r){o||(ds.preview_pane.getState(e.property,(function(e,i){if(e)return console.error("Failed to get state",e),void ds.confirm.error(e);Es(t,i),Ss(),ds.confirm.blank(),n&&n(r)})),o=!0)}}function ks(t,e){return/^data\./.test(t)?function(t,e){var n=t.split(".");return ds.visualisation.__sdk__?function(t,e){for(var n=null,r=ds.template_data_bindings,i=0;i<r.length;i++){var o=r[i];if("string"!=typeof o&&(o.dataset===t[1]&&o.key===t[2])){n=o;break}}if(!n)throw new Error("Bug: data binding not found - these should already have been checked");return"column"===n.type?!!n.column===e:!!n.columns.split("::")[1]===e}(n,e):function(t,e){return!!document.getElementById("data-binding-"+t[1]+"-"+t[2]).value===e}(n,e)}(t,e):function(t,e){var n=document.getElementById("setting-"+t);if(!n)return console.error("Could not find input for setting",t),!1;var r=As(n);if(e instanceof Array)return-1!==e.indexOf(r);return r===e}(t,e)}function Ss(){ds.settings.filter((function(t){return"object"==typeof t&&"show_condition"in t})).forEach((function(t){var e=t.show_condition.every((function(t){var e="show"===t.type,n=t.condition;if("boolean"==typeof n)return e===n;if("string"==typeof n)return e===ks(n,!0);for(var r in n)if(!ks(r,n[r]))return!1===e;return e})),n=document.getElementById("setting-"+t.property);if(n){for(var r=n;!r.classList.contains("settings-option");)r=r.parentNode;if(fi(r).classed("hidden",!e),t.new_section)for(var i=r.previousSibling;i&&(fi(i).classed("settings-divider")||fi(i).classed("settings-subhead"));)fi(i).classed("hidden",!e),i=i.previousSibling}else console.error("Could not find input",t.property)}));for(var t=document.querySelectorAll(".template-settings .settings-block"),e=0;e<t.length;e++){var n=t[e];n.classList.contains("hidden")?null!==n.querySelector(".settings-option:not(.hidden)")&&n.classList.remove("hidden"):null==n.querySelector(".settings-option:not(.hidden)")&&n.classList.add("hidden")}}function Ns(t,e,n){return ds=t,hs=Fo(),(vs=fi(".side-panel .template-settings")).on("submit",(function(t){t.preventDefault()})),gs.replaceThemeColors(e),Fa.replaceThemeFonts(n),_s(ds.settings),fi(".side-panel-scrollbox").on("scroll",(function(){Di.hide()})),{update:function(t){vs.html(""),fi(".current-template").style("opacity","1"),_s(ds.settings=t)},populate:function(){ds.preview_pane.getState((function(t,e){if(t)console.error("Failed to get state",t);else{var n=To(e);for(var r in n){var i=document.getElementById("setting-"+r);i&&Es(i,n[r])}Ss()}}))},getSettingsForCurrentTemplate:function(){return ms}}}function Ds(t,e,n){function r(){}this.visualisation=t,this.settings=e,this.template_data_bindings=n,this.template_settings=Ns(this),io(this),this.preview_pane=function(t){ra=t;var e=ua();return{loadTemplate:pa,updateData:da,sync:(ia=na("iframe#preview","editor",ra,e)).sync,setState:ia.setState,getState:ia.getState,hasData:ia.hasData,setData:ia.setData,getData:ia.getData,draw:ia.draw,update:ia.update,getDefaultState:ia.getDefaultState,snapshot:ia.snapshot,setFixedHeight:ia.setFixedHeight,resize:ia.resize}}(this),this.responsive_menu=gi(this),this.confirm={on:r,blank:r,saved:r,saving:r,error:r},this.analytics=r,this.tour={fireEvent:r}}var Fs={},Ts={};function Ms(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function Bs(t){var e=Object.create(null),n=[];return t.forEach((function(t){for(var r in t)r in e||n.push(e[r]=r)})),n}function Ls(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function qs(t){var e,n=t.getUTCHours(),r=t.getUTCMinutes(),i=t.getUTCSeconds(),o=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":((e=t.getUTCFullYear())<0?"-"+Ls(-e,6):e>9999?"+"+Ls(e,6):Ls(e,4))+"-"+Ls(t.getUTCMonth()+1,2)+"-"+Ls(t.getUTCDate(),2)+(o?"T"+Ls(n,2)+":"+Ls(r,2)+":"+Ls(i,2)+"."+Ls(o,3)+"Z":i?"T"+Ls(n,2)+":"+Ls(r,2)+":"+Ls(i,2)+"Z":r||n?"T"+Ls(n,2)+":"+Ls(r,2)+"Z":"")}var Os=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],o=t.length,a=0,s=0,u=o<=0,l=!1;function c(){if(u)return Ts;if(l)return l=!1,Fs;var e,r,i=a;if(34===t.charCodeAt(i)){for(;a++<o&&34!==t.charCodeAt(a)||34===t.charCodeAt(++a););return(e=a)>=o?u=!0:10===(r=t.charCodeAt(a++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(a)&&++a),t.slice(i+1,e-1).replace(/""/g,'"')}for(;a<o;){if(10===(r=t.charCodeAt(e=a++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(a)&&++a;else if(r!==n)continue;return t.slice(i,e)}return u=!0,t.slice(i,o)}for(10===t.charCodeAt(o-1)&&--o,13===t.charCodeAt(o-1)&&--o;(r=c())!==Ts;){for(var f=[];r!==Fs&&r!==Ts;)f.push(r),r=c();e&&null==(f=e(f,s++))||i.push(f)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return a(e[t])})).join(t)}))}function o(e){return e.map(a).join(t)}function a(t){return null==t?"":t instanceof Date?qs(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,o=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Ms(t);return function(r,i){return e(n(r),i,t)}}(t,e):Ms(t)}));return o.columns=i||[],o},parseRows:r,format:function(e,n){return null==n&&(n=Bs(e)),[n.map(a).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Bs(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(o).join("\n")},formatRow:o,formatValue:a}}(",").parseRows,Rs="$";function Ps(){}function js(t,e){var n=new Ps;if(t instanceof Ps)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==e)for(;++i<o;)n.set(i,t[i]);else for(;++i<o;)n.set(e(r=t[i],i,t),r)}else if(t)for(var a in t)n.set(a,t[a]);return n}function Is(){}Ps.prototype=js.prototype={constructor:Ps,has:function(t){return Rs+t in this},get:function(t){return this[Rs+t]},set:function(t,e){return this[Rs+t]=e,this},remove:function(t){var e=Rs+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===Rs&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===Rs&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===Rs&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===Rs&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===Rs&&++t;return t},empty:function(){for(var t in this)if(t[0]===Rs)return!1;return!0},each:function(t){for(var e in this)e[0]===Rs&&t(this[e],e.slice(1),this)}};var Us=js.prototype;Is.prototype=function(t,e){var n=new Is;if(t instanceof Is)t.each((function(t){n.add(t)}));else if(t){var r=-1,i=t.length;if(null==e)for(;++r<i;)n.add(t[r]);else for(;++r<i;)n.add(e(t[r],r,t))}return n}.prototype={constructor:Is,has:Us.has,add:function(t){return this[Rs+(t+="")]=t,this},remove:Us.remove,clear:Us.clear,values:Us.keys,size:Us.size,empty:Us.empty,each:Us.each};var Hs,zs,Xs={value:function(){}};function Ws(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r)throw new Error("illegal type: "+t);r[t]=[]}return new Vs(r)}function Vs(t){this._=t}function $s(t,e){return t.trim().split(/^|\s+/).map((function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function Gs(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Js(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Xs,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function Ys(t,e,n){var r;r="object"==typeof e?e.id:e,this.id=r,this.visualisation=t,this.api_prefix="/api/data_table"}function Ks(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?Ks(t):t}))}function Zs(t){this.id=t}function Qs(t,e){var n=[],r=[],i=0,o=[];for(var a in o.column_names={},t)if(void 0!==t[a].columns||void 0!==t[a].column){var s=t[a];if(s.key=a,s.data_table_id in e){var u=e[s.data_table_id];if(0!=u.length){if("columns"in s&&null!=s.columns){var l=u[0].length;s.columns=s.columns.filter((function(t){return t<l})),o.column_names[a]=s.columns.map((function(t){return e[s.data_table_id][0][t]}))}else{if(!("column"in s)||null==s.column)throw new Error("Data binding includes no column(s) specification: "+JSON.stringify(s));o.column_names[a]=u[0][s.column]}-1==r.indexOf(s.data_table_id)&&(r.push(s.data_table_id),i=Math.max(i,e[s.data_table_id].length-1)),n.push(s)}else console.warn("Empty data table")}else{var c=[];for(var f in e)c.push(f);console.error("Data table id "+s.data_table_id+" not in "+JSON.stringify(c))}}for(var p=0;p<i;p++){for(var d={},h=0;h<n.length;h++){s=n[h];var v=e[s.data_table_id];p+1>=v.length||("columns"in s&&null!=s.columns?d[s.key]=s.columns.filter((function(t){return t<v[p+1].length})).map((function(t){return v[p+1][t]})):"column"in s&&null!=s.column&&(s.column>=v[p+1].length?d[s.key]="":d[s.key]=v[p+1][s.column]))}o.push(d)}return o}function tu(t,e,n){var r=this;r.id=1,r.template_id=1,r.api_prefix="/api/visualisation",r.can_edit=!0,r.__sdk__=!0,n.data_tables&&(this.data_tables=n.data_tables.map((function(t){return new Ys(r,t)}))),n.data_bindings&&(this.data_bindings=n.data_bindings)}Vs.prototype=Ws.prototype={constructor:Vs,on:function(t,e){var n,r=this._,i=$s(t+"",r),o=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<a;)if(n=(t=i[o]).type)r[n]=Js(r[n],t.name,e);else if(null==e)for(n in r)r[n]=Js(r[n],t.name,null);return this}for(;++o<a;)if((n=(t=i[o]).type)&&(n=Gs(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Vs(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}},Ys.prototype.csv=function(t){if(this.cached_data)t(void 0,Ks(this.cached_data));else{var e=this;!function(t,e){var n,r,i,o,a=Ws("beforesend","progress","load","error"),s=js(),u=new XMLHttpRequest,l=null,c=null,f=0;function p(t){var e,r=u.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(u)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,u)}catch(t){return void a.call("error",n,t)}else e=u;a.call("load",n,e)}else a.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in u)&&/^(http(s)?:)?\/\//.test(t)&&(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=u.ontimeout=p:u.onreadystatechange=function(t){u.readyState>3&&p(t)},u.onprogress=function(t){a.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(o=t,n):o},timeout:function(t){return arguments.length?(f=+t,n):f},user:function(t){return arguments.length<1?l:(l=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,p){return u.open(e,t,!0,l,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),u.setRequestHeader&&s.each((function(t,e){u.setRequestHeader(e,t)})),null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=o&&(u.responseType=o),f>0&&(u.timeout=f),null==p&&"function"==typeof i&&(p=i,i=null),null!=p&&1===p.length&&(p=function(t){return function(e,n){t(null==e?n:null)}}(p)),null!=p&&n.on("error",p).on("load",(function(t){p(null,t)})),a.call("beforesend",n,u),u.send(null==i?null:i),n},abort:function(){return u.abort(),n},on:function(){var t=a.on.apply(a,arguments);return t===a?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}}(this.api_prefix+"/"+this.id+"/csv",(function(n,r){e.cached_data=Os(r.response),t(void 0,Ks(e.cached_data))}))}},Ys.prototype.saveData=function(t,e){e()},Ys.prototype.save=function(t,e){e()},Ys.prototype.delete=function(t){t()},Zs.prototype.getSettings=function(t){t(void 0,window.Flourish.app.settings)},Zs.prototype.getDataBindings=function(t){t(void 0,window.Flourish.app.template_data_bindings)},Zs.prototype.refreshDataBindings=function(t){t(void 0)},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 r=arguments[1],i=0;i<n;){var o=e[i];if(t.call(r,o,i,e))return i;i++}return-1},configurable:!0,writable:!0}),tu.prototype.save=function(t,e){this.version_number++,e(void 0)},tu.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new Zs(this.template_id)),this._template):null},tu.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},tu.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},tu.prototype.refreshDataBindings=function(t){t()},tu.prototype.updateDataBindings=function(t,e){var n=this;n.version_number++,n.data_bindings||(n.data_bindings={}),n.template_id in n.data_bindings||(n.data_bindings[n.template_id]={});var r=n.data_bindings[n.template_id];for(var i in t)for(var o in t[i]){var a=t[i][o];r[i][o]=a}e(void 0)},tu.prototype.updateSettings=function(t,e){var n=this;n.version_number++,n.settings||(n.settings={}),n.template_id in n.settings||(n.settings[n.template_id]={});var r=n.settings[n.template_id];for(var i in t){var o=t[i];r[i]=o}e(void 0)},tu.prototype.getDataTables=function(t){t(void 0,window.Flourish.app.data_tables)},tu.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new Ys(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},tu.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},tu.prototype.prepareData=function(t){var e=this.dataBindingsForCurrentTemplate();this.dataTables((function(n,r){if(n)return t(n);for(var i={},o=0,a=0;a<r.length;a++)!function(n){n.csv((function(a,s){if(a)throw a;if(i[n.id]=s,++o==r.length){var u={};for(var l in e)u[l]=Qs(e[l],i);t(void 0,u)}}))}(r[a]);0==r.length&&t(void 0,{})}))},tu.prototype.createDataTable=function(t,e){e()},tu.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},tu.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},tu.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0};var eu=!1;function nu(){Hs&&Hs.classList.remove("shown")}function ru(){this.close(),eu||(Hs&&setTimeout((function(){Hs.classList.add("shown")}),1e3),setTimeout(iu,250))}function iu(){ou().addEventListener("open",(function(){window.location.reload()}))}function ou(){var t=new window.WebSocket(zs);return t.addEventListener("open",nu),t.addEventListener("close",ru),t}return t.Visualisation=tu,t.initSDK=function(t,e,n){Oi(),window.Flourish=window.Flourish||{},window.Flourish.app=new Ds(t,e,n)},t.talkToServer=function(){Hs=document.getElementById("error-server-down"),zs=window.location.origin.replace(/^http(s?):\/\//,"ws$1://"),window.addEventListener("beforeunload",(function(){eu=!0})),ou()},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
1
|
+
var Flourish=function(t){"use strict";function e(t){return parseInt(t).toString()===""+t&&t>=0}function n(t,e,n){return t.map((function(t){var r={};return Object.keys(e).forEach((function(n){r[n]=t[e[n]]})),Object.keys(n).forEach((function(e){var i=n[e];Array.isArray(i)||(i=[i]),r[e]=i.map((function(e){return t[e]}))})),r}))}function r(t,e,r){var i=n(t,e=e||{},r=r||{});return i.column_names={},Object.keys(e).forEach((function(t){i.column_names[t]=e[t]})),Object.keys(r).forEach((function(t){var e=r[t];i.column_names[t]=Array.isArray(e)?e:[e]})),i}function i(t,r,i){!function(t,n){var r;if(!Object.keys(t).every((function(n){return e(t[n])})))throw r="All column_bindings values should be non-negative integers",new TypeError(r);if(!Object.keys(n).every((function(t){var r=n[t];return Array.isArray(r)?r.every(e):e(r)})))throw r="All columns_bindings values should be non-negative integers or arrays thereof",new TypeError(r)}(r=r||{},i=i||{});var a=t[0],o=n(t.slice(1),r,i);return o.column_names={},Object.keys(r).forEach((function(t){o.column_names[t]=a[r[t]]})),Object.keys(i).forEach((function(t){var e=i[t];o.column_names[t]=(Array.isArray(e)?e:[e]).map((function(t){return a[t]}))})),o}function a(t,e,n){return(Array.isArray(t[0])?i:r)(t,e,n)}var o="http://www.w3.org/1999/xhtml",s={svg:"http://www.w3.org/2000/svg",xhtml:o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function u(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),s.hasOwnProperty(e)?{space:s[e],local:t}:t}function l(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===o&&e.documentElement.namespaceURI===o?e.createElement(t):e.createElementNS(n,t)}}function c(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function d(t){var e=u(t);return(e.local?c:l)(e)}function f(){}function p(t){return null==t?f:function(){return this.querySelector(t)}}function h(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function m(){return[]}function v(t){return null==t?m:function(){return this.querySelectorAll(t)}}function g(t){return function(){return this.matches(t)}}function y(t){return function(e){return e.matches(t)}}var _=Array.prototype.find;function b(){return this.firstElementChild}var w=Array.prototype.filter;function x(){return this.children}function A(t){return new Array(t.length)}function E(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function T(t){return function(){return t}}function C(t,e,n,r,i,a){for(var o,s=0,u=e.length,l=a.length;s<l;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new E(t,a[s]);for(;s<u;++s)(o=e[s])&&(i[s]=o)}function k(t,e,n,r,i,a,o){var s,u,l,c=new Map,d=e.length,f=a.length,p=new Array(d);for(s=0;s<d;++s)(u=e[s])&&(p[s]=l=o.call(u,u.__data__,s,e)+"",c.has(l)?i[s]=u:c.set(l,u));for(s=0;s<f;++s)l=o.call(t,a[s],s,a)+"",(u=c.get(l))?(r[s]=u,u.__data__=a[s],c.delete(l)):n[s]=new E(t,a[s]);for(s=0;s<d;++s)(u=e[s])&&c.get(p[s])===u&&(i[s]=u)}function D(t){return t.__data__}function F(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function S(t){return function(){this.removeAttribute(t)}}function M(t){return function(){this.removeAttributeNS(t.space,t.local)}}function N(t,e){return function(){this.setAttribute(t,e)}}function L(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function O(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function U(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function R(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function B(t){return function(){this.style.removeProperty(t)}}function j(t,e,n){return function(){this.style.setProperty(t,e,n)}}function H(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function I(t,e){return t.style.getPropertyValue(e)||R(t).getComputedStyle(t,null).getPropertyValue(e)}function z(t){return function(){delete this[t]}}function P(t,e){return function(){this[t]=e}}function q(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Y(t){return t.trim().split(/^|\s+/)}function $(t){return t.classList||new V(t)}function V(t){this._node=t,this._names=Y(t.getAttribute("class")||"")}function W(t,e){for(var n=$(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function G(t,e){for(var n=$(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function X(t){return function(){W(this,t)}}function J(t){return function(){G(this,t)}}function Z(t,e){return function(){(e.apply(this,arguments)?W:G)(this,t)}}function K(){this.textContent=""}function Q(t){return function(){this.textContent=t}}function tt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function et(){this.innerHTML=""}function nt(t){return function(){this.innerHTML=t}}function rt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function it(){this.nextSibling&&this.parentNode.appendChild(this)}function at(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ot(){return null}function st(){var t=this.parentNode;t&&t.removeChild(this)}function ut(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function lt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ct(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function dt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function ft(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function pt(t,e,n){var r=R(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function ht(t,e){return function(){return pt(this,t,e)}}function mt(t,e){return function(){return pt(this,t,e.apply(this,arguments))}}E.prototype={constructor:E,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},V.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var vt,gt,yt,_t,bt,wt=[null];function xt(t,e){this._groups=t,this._parents=e}function At(){return new xt([[document.documentElement]],wt)}function Et(t){return"string"==typeof t?new xt([[document.querySelector(t)]],[document.documentElement]):new xt([[t]],wt)}function Tt(t){return Et(d(t).call(document.documentElement))}function Ct(t){return"string"==typeof t?new xt([document.querySelectorAll(t)],[document.documentElement]):new xt([null==t?[]:h(t)],wt)}function kt(){if(!yt)return null;var t=yt.nodes()[1].value;if("custom"===_t&&""!=t){var e=parseInt(t,10);return isNaN(e)?null:e}return null}function Dt(){bt&&bt.preview_pane&&bt.preview_pane.setFixedHeight&&bt.preview_pane.setFixedHeight(kt())}function Ft(t,e=!1){_t=t,Dt(),"custom"===t?(Et("#editor-custom-inputs").style("opacity",1),Et(".preview-holder").style("width",yt.nodes()[0].value+"px").select("iframe").style("width",yt.nodes()[0].value+"px")):(Et("#editor-custom-inputs").style("opacity",0),Et(".preview-holder").attr("style",null).select("iframe").style("width",null)),e||Et(".preview-holder").style("max-width","none"),Ct("#preview-menu .preview-mode").classed("selected",(function(){return this.id=="editor-"+t})),Et("#editor-rotate").classed("active",(function(){return"auto"!==t})),Et(".row.editor").classed("mobile",(function(){return"mobile"==t})),Et(".row.editor").classed("tablet",(function(){return"tablet"==t})),Et(".preview-holder").on("webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd transitionend",Mt),vt=t}function St(t){return bt=t,yt=Ct("#editor-custom-inputs input"),Mt(),Ct("#preview-menu .preview-mode").on("click",(function(){Ft(this.getAttribute("data-target"))})),yt.on("change",(function(){Ft(this.getAttribute("data-target"))})),Ft("auto",!0),function(){var t,e,n=document.querySelector("#resize-handle"),r=document.querySelector(".preview-holder");function i(i){"editor-custom"!==i.target.parentElement.id&&(t=r.getBoundingClientRect().width,n.parentElement.parentElement.querySelector("#resize-overlay").classList.add("dragging"),n.parentElement.classList.add("dragging"),e=i.clientX,Et(".preview-holder").style("transition","none"),Ft("custom"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",o),i.preventDefault())}function a(n){var i=n.clientX-e,a=t+2*i;r.style.width=a+"px",r.querySelector("iframe").style.width=a-4+"px",Mt(),bt.preview_pane.resize()}function o(){t=r.getBoundingClientRect().width,Et(".preview-holder").style("transition",null),n.parentElement.parentElement.querySelector("#resize-overlay").classList.remove("dragging"),n.parentElement.classList.remove("dragging"),Mt(),bt.preview_pane.resize(),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",o)}n.addEventListener("mousedown",i)}
|
|
2
|
+
/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */(),window.innerWidth<=768&&(gt="auto"),window.addEventListener("resize",(function(){vt&&Mt(),window.innerWidth<=768?gt||(gt=vt,Ft("auto")):gt&&(Ft(gt),gt=null),bt.preview_pane.resize()})),{getHeightSetting:kt}}function Mt(){var t=Et(".preview-holder").node().getBoundingClientRect();yt.nodes()[0].value=Math.round(t.width),""!==yt.nodes()[1].value&&"custom"===_t&&(yt.nodes()[1].value=Math.round(t.height))}xt.prototype=At.prototype={constructor:xt,select:function(t){"function"!=typeof t&&(t=p(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],u=s.length,l=r[i]=new Array(u),c=0;c<u;++c)(a=s[c])&&(o=t.call(a,a.__data__,c,s))&&("__data__"in a&&(o.__data__=a.__data__),l[c]=o);return new xt(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);return null==e?[]:h(e)}}(t):v(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],u=s.length,l=0;l<u;++l)(o=s[l])&&(r.push(t.call(o,o.__data__,l,s)),i.push(o));return new xt(r,i)},selectChild:function(t){return this.select(null==t?b:function(t){return function(){return _.call(this.children,t)}}("function"==typeof t?t:y(t)))},selectChildren:function(t){return this.selectAll(null==t?x:function(t){return function(){return w.call(this.children,t)}}("function"==typeof t?t:y(t)))},filter:function(t){"function"!=typeof t&&(t=g(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,u=r[i]=[],l=0;l<s;++l)(a=o[l])&&t.call(a,a.__data__,l,o)&&u.push(a);return new xt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,D);var n=e?k:C,r=this._parents,i=this._groups;"function"!=typeof t&&(t=T(t));for(var a=i.length,o=new Array(a),s=new Array(a),u=new Array(a),l=0;l<a;++l){var c=r[l],d=i[l],f=d.length,p=h(t.call(c,c&&c.__data__,l,r)),m=p.length,v=s[l]=new Array(m),g=o[l]=new Array(m),y=u[l]=new Array(f);n(c,d,v,g,y,p,e);for(var _,b,w=0,x=0;w<m;++w)if(_=v[w]){for(w>=x&&(x=w+1);!(b=g[x])&&++x<m;);_._next=b||null}}return(o=new xt(o,r))._enter=s,o._exit=u,o},enter:function(){return new xt(this._enter||this._groups.map(A),this._parents)},exit:function(){return new xt(this._exit||this._groups.map(A),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=e&&(i=e(i)),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){if(!(t instanceof xt))throw new Error("invalid merge");for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var u,l=e[s],c=n[s],d=l.length,f=o[s]=new Array(d),p=0;p<d;++p)(u=l[p]||c[p])&&(f[p]=u);for(;s<r;++s)o[s]=e[s];return new xt(o,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=F);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],u=s.length,l=i[a]=new Array(u),c=0;c<u;++c)(o=s[c])&&(l[c]=o);l.sort(e)}return new xt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=u(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?M:S:"function"==typeof e?n.local?U:O:n.local?L:N)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?B:"function"==typeof e?H:j)(t,e,null==n?"":n)):I(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?z:"function"==typeof e?q:P)(t,e)):this.node()[t]},classed:function(t,e){var n=Y(t+"");if(arguments.length<2){for(var r=$(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?Z:e?X:J)(n,e))},text:function(t){return arguments.length?this.each(null==t?K:("function"==typeof t?tt:Q)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?et:("function"==typeof t?rt:nt)(t)):this.node().innerHTML},raise:function(){return this.each(it)},lower:function(){return this.each(at)},append:function(t){var e="function"==typeof t?t:d(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:d(t),r=null==e?ot:"function"==typeof e?e:p(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(st)},clone:function(t){return this.select(t?lt:ut)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=ct(t+""),o=a.length;if(!(arguments.length<2)){for(s=e?ft:dt,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(r=0,u=s[l];r<o;++r)if((i=a[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?mt:ht)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};var Nt=Object.hasOwnProperty,Lt=Object.setPrototypeOf,Ot=Object.isFrozen,Ut=Object.getPrototypeOf,Rt=Object.getOwnPropertyDescriptor,Bt=Object.freeze,jt=Object.seal,Ht=Object.create,It="undefined"!=typeof Reflect&&Reflect,zt=It.apply,Pt=It.construct;zt||(zt=function(t,e,n){return t.apply(e,n)}),Bt||(Bt=function(t){return t}),jt||(jt=function(t){return t}),Pt||(Pt=function(t,e){return new(Function.prototype.bind.apply(t,[null].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(e))))});var qt,Yt=te(Array.prototype.forEach),$t=te(Array.prototype.pop),Vt=te(Array.prototype.push),Wt=te(String.prototype.toLowerCase),Gt=te(String.prototype.match),Xt=te(String.prototype.replace),Jt=te(String.prototype.indexOf),Zt=te(String.prototype.trim),Kt=te(RegExp.prototype.test),Qt=(qt=TypeError,function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return Pt(qt,e)});function te(t){return function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return zt(t,e,r)}}function ee(t,e){Lt&&Lt(t,null);for(var n=e.length;n--;){var r=e[n];if("string"==typeof r){var i=Wt(r);i!==r&&(Ot(e)||(e[n]=i),r=i)}t[r]=!0}return t}function ne(t){var e=Ht(null),n=void 0;for(n in t)zt(Nt,t,[n])&&(e[n]=t[n]);return e}function re(t,e){for(;null!==t;){var n=Rt(t,e);if(n){if(n.get)return te(n.get);if("function"==typeof n.value)return te(n.value)}t=Ut(t)}return function(t){return console.warn("fallback value for",t),null}}var ie=Bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ae=Bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),oe=Bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),se=Bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ue=Bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),le=Bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ce=Bt(["#text"]),de=Bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),fe=Bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pe=Bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),he=Bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),me=jt(/\{\{[\s\S]*|[\s\S]*\}\}/gm),ve=jt(/<%[\s\S]*|[\s\S]*%>/gm),ge=jt(/^data-[\-\w.\u00B7-\uFFFF]/),ye=jt(/^aria-[\-\w]+$/),_e=jt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),be=jt(/^(?:\w+script|data):/i),we=jt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xe="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};function Ae(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}var Ee=function(){return"undefined"==typeof window?null:window},Te=function(t,e){if("object"!==(void 0===t?"undefined":xe(t))||"function"!=typeof t.createPolicy)return null;var n=null,r="data-tt-policy-suffix";e.currentScript&&e.currentScript.hasAttribute(r)&&(n=e.currentScript.getAttribute(r));var i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};var Ce,ke,De=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ee(),n=function(e){return t(e)};if(n.version="2.2.8",n.removed=[],!e||!e.document||9!==e.document.nodeType)return n.isSupported=!1,n;var r=e.document,i=e.document,a=e.DocumentFragment,o=e.HTMLTemplateElement,s=e.Node,u=e.Element,l=e.NodeFilter,c=e.NamedNodeMap,d=void 0===c?e.NamedNodeMap||e.MozNamedAttrMap:c,f=e.Text,p=e.Comment,h=e.DOMParser,m=e.trustedTypes,v=u.prototype,g=re(v,"cloneNode"),y=re(v,"nextSibling"),_=re(v,"childNodes"),b=re(v,"parentNode");if("function"==typeof o){var w=i.createElement("template");w.content&&w.content.ownerDocument&&(i=w.content.ownerDocument)}var x=Te(m,r),A=x&&tt?x.createHTML(""):"",E=i,T=E.implementation,C=E.createNodeIterator,k=E.createDocumentFragment,D=r.importNode,F={};try{F=ne(i).documentMode?i.documentMode:{}}catch(t){}var S={};n.isSupported="function"==typeof b&&T&&void 0!==T.createHTMLDocument&&9!==F;var M=me,N=ve,L=ge,O=ye,U=be,R=we,B=_e,j=null,H=ee({},[].concat(Ae(ie),Ae(ae),Ae(oe),Ae(ue),Ae(ce))),I=null,z=ee({},[].concat(Ae(de),Ae(fe),Ae(pe),Ae(he))),P=null,q=null,Y=!0,$=!0,V=!1,W=!1,G=!1,X=!1,J=!1,Z=!1,K=!1,Q=!0,tt=!1,et=!0,nt=!0,rt=!1,it={},at=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ot=null,st=ee({},["audio","video","img","source","image","track"]),ut=null,lt=ee({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ct="http://www.w3.org/1998/Math/MathML",dt="http://www.w3.org/2000/svg",ft="http://www.w3.org/1999/xhtml",pt=ft,ht=null,mt=i.createElement("form"),vt=function(t){ht&&ht===t||(t&&"object"===(void 0===t?"undefined":xe(t))||(t={}),t=ne(t),j="ALLOWED_TAGS"in t?ee({},t.ALLOWED_TAGS):H,I="ALLOWED_ATTR"in t?ee({},t.ALLOWED_ATTR):z,ut="ADD_URI_SAFE_ATTR"in t?ee(ne(lt),t.ADD_URI_SAFE_ATTR):lt,ot="ADD_DATA_URI_TAGS"in t?ee(ne(st),t.ADD_DATA_URI_TAGS):st,P="FORBID_TAGS"in t?ee({},t.FORBID_TAGS):{},q="FORBID_ATTR"in t?ee({},t.FORBID_ATTR):{},it="USE_PROFILES"in t&&t.USE_PROFILES,Y=!1!==t.ALLOW_ARIA_ATTR,$=!1!==t.ALLOW_DATA_ATTR,V=t.ALLOW_UNKNOWN_PROTOCOLS||!1,W=t.SAFE_FOR_TEMPLATES||!1,G=t.WHOLE_DOCUMENT||!1,Z=t.RETURN_DOM||!1,K=t.RETURN_DOM_FRAGMENT||!1,Q=!1!==t.RETURN_DOM_IMPORT,tt=t.RETURN_TRUSTED_TYPE||!1,J=t.FORCE_BODY||!1,et=!1!==t.SANITIZE_DOM,nt=!1!==t.KEEP_CONTENT,rt=t.IN_PLACE||!1,B=t.ALLOWED_URI_REGEXP||B,pt=t.NAMESPACE||pt,W&&($=!1),K&&(Z=!0),it&&(j=ee({},[].concat(Ae(ce))),I=[],!0===it.html&&(ee(j,ie),ee(I,de)),!0===it.svg&&(ee(j,ae),ee(I,fe),ee(I,he)),!0===it.svgFilters&&(ee(j,oe),ee(I,fe),ee(I,he)),!0===it.mathMl&&(ee(j,ue),ee(I,pe),ee(I,he))),t.ADD_TAGS&&(j===H&&(j=ne(j)),ee(j,t.ADD_TAGS)),t.ADD_ATTR&&(I===z&&(I=ne(I)),ee(I,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&ee(ut,t.ADD_URI_SAFE_ATTR),nt&&(j["#text"]=!0),G&&ee(j,["html","head","body"]),j.table&&(ee(j,["tbody"]),delete P.tbody),Bt&&Bt(t),ht=t)},gt=ee({},["mi","mo","mn","ms","mtext"]),yt=ee({},["foreignobject","desc","title","annotation-xml"]),_t=ee({},ae);ee(_t,oe),ee(_t,se);var bt=ee({},ue);ee(bt,le);var wt=function(t){var e=b(t);e&&e.tagName||(e={namespaceURI:ft,tagName:"template"});var n=Wt(t.tagName),r=Wt(e.tagName);if(t.namespaceURI===dt)return e.namespaceURI===ft?"svg"===n:e.namespaceURI===ct?"svg"===n&&("annotation-xml"===r||gt[r]):Boolean(_t[n]);if(t.namespaceURI===ct)return e.namespaceURI===ft?"math"===n:e.namespaceURI===dt?"math"===n&&yt[r]:Boolean(bt[n]);if(t.namespaceURI===ft){if(e.namespaceURI===dt&&!yt[r])return!1;if(e.namespaceURI===ct&&!gt[r])return!1;var i=ee({},["title","style","font","a","script"]);return!bt[n]&&(i[n]||!_t[n])}return!1},xt=function(t){Vt(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=A}catch(e){t.remove()}}},At=function(t,e){try{Vt(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Vt(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!I[t])if(Z||K)try{xt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Et=function(t){var e=void 0,n=void 0;if(J)t="<remove></remove>"+t;else{var r=Gt(t,/^[\r\n\t ]+/);n=r&&r[0]}var a=x?x.createHTML(t):t;if(pt===ft)try{e=(new h).parseFromString(a,"text/html")}catch(t){}e&&e.documentElement||((e=T.createDocument(pt,"template",null)).documentElement.innerHTML=a);var o=e.body||e.documentElement;return t&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),G?e.documentElement:o},Tt=function(t){return C.call(t.ownerDocument||t,t,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT,(function(){return l.FILTER_ACCEPT}),!1)},Ct=function(t){return!(t instanceof f||t instanceof p)&&!("string"==typeof t.nodeName&&"string"==typeof t.textContent&&"function"==typeof t.removeChild&&t.attributes instanceof d&&"function"==typeof t.removeAttribute&&"function"==typeof t.setAttribute&&"string"==typeof t.namespaceURI&&"function"==typeof t.insertBefore)},kt=function(t){return"object"===(void 0===s?"undefined":xe(s))?t instanceof s:t&&"object"===(void 0===t?"undefined":xe(t))&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Dt=function(t,e,r){S[t]&&Yt(S[t],(function(t){t.call(n,e,r,ht)}))},Ft=function(t){var e=void 0;if(Dt("beforeSanitizeElements",t,null),Ct(t))return xt(t),!0;if(Gt(t.nodeName,/[\u0080-\uFFFF]/))return xt(t),!0;var r=Wt(t.nodeName);if(Dt("uponSanitizeElement",t,{tagName:r,allowedTags:j}),!kt(t.firstElementChild)&&(!kt(t.content)||!kt(t.content.firstElementChild))&&Kt(/<[/\w]/g,t.innerHTML)&&Kt(/<[/\w]/g,t.textContent))return xt(t),!0;if(!j[r]||P[r]){if(nt&&!at[r]){var i=b(t)||t.parentNode,a=_(t)||t.childNodes;if(a&&i)for(var o=a.length-1;o>=0;--o)i.insertBefore(g(a[o],!0),y(t))}return xt(t),!0}return t instanceof u&&!wt(t)?(xt(t),!0):"noscript"!==r&&"noembed"!==r||!Kt(/<\/no(script|embed)/i,t.innerHTML)?(W&&3===t.nodeType&&(e=t.textContent,e=Xt(e,M," "),e=Xt(e,N," "),t.textContent!==e&&(Vt(n.removed,{element:t.cloneNode()}),t.textContent=e)),Dt("afterSanitizeElements",t,null),!1):(xt(t),!0)},St=function(t,e,n){if(et&&("id"===e||"name"===e)&&(n in i||n in mt))return!1;if($&&Kt(L,e));else if(Y&&Kt(O,e));else{if(!I[e]||q[e])return!1;if(ut[e]);else if(Kt(B,Xt(n,R,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Jt(n,"data:")||!ot[t]){if(V&&!Kt(U,Xt(n,R,"")));else if(n)return!1}else;}return!0},Mt=function(t){var e=void 0,r=void 0,i=void 0,a=void 0;Dt("beforeSanitizeAttributes",t,null);var o=t.attributes;if(o){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:I};for(a=o.length;a--;){var u=e=o[a],l=u.name,c=u.namespaceURI;if(r=Zt(e.value),i=Wt(l),s.attrName=i,s.attrValue=r,s.keepAttr=!0,s.forceKeepAttr=void 0,Dt("uponSanitizeAttribute",t,s),r=s.attrValue,!s.forceKeepAttr&&(At(l,t),s.keepAttr))if(Kt(/\/>/i,r))At(l,t);else{W&&(r=Xt(r,M," "),r=Xt(r,N," "));var d=t.nodeName.toLowerCase();if(St(d,i,r))try{c?t.setAttributeNS(c,l,r):t.setAttribute(l,r),$t(n.removed)}catch(t){}}}Dt("afterSanitizeAttributes",t,null)}},Nt=function t(e){var n=void 0,r=Tt(e);for(Dt("beforeSanitizeShadowDOM",e,null);n=r.nextNode();)Dt("uponSanitizeShadowNode",n,null),Ft(n)||(n.content instanceof a&&t(n.content),Mt(n));Dt("afterSanitizeShadowDOM",e,null)};return n.sanitize=function(t,i){var o=void 0,u=void 0,l=void 0,c=void 0,d=void 0;if(t||(t="\x3c!--\x3e"),"string"!=typeof t&&!kt(t)){if("function"!=typeof t.toString)throw Qt("toString is not a function");if("string"!=typeof(t=t.toString()))throw Qt("dirty is not a string, aborting")}if(!n.isSupported){if("object"===xe(e.toStaticHTML)||"function"==typeof e.toStaticHTML){if("string"==typeof t)return e.toStaticHTML(t);if(kt(t))return e.toStaticHTML(t.outerHTML)}return t}if(X||vt(i),n.removed=[],"string"==typeof t&&(rt=!1),rt);else if(t instanceof s)1===(u=(o=Et("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===u.nodeName||"HTML"===u.nodeName?o=u:o.appendChild(u);else{if(!Z&&!W&&!G&&-1===t.indexOf("<"))return x&&tt?x.createHTML(t):t;if(!(o=Et(t)))return Z?null:A}o&&J&&xt(o.firstChild);for(var f=Tt(rt?t:o);l=f.nextNode();)3===l.nodeType&&l===c||Ft(l)||(l.content instanceof a&&Nt(l.content),Mt(l),c=l);if(c=null,rt)return t;if(Z){if(K)for(d=k.call(o.ownerDocument);o.firstChild;)d.appendChild(o.firstChild);else d=o;return Q&&(d=D.call(r,d,!0)),d}var p=G?o.outerHTML:o.innerHTML;return W&&(p=Xt(p,M," "),p=Xt(p,N," ")),x&&tt?x.createHTML(p):p},n.setConfig=function(t){vt(t),X=!0},n.clearConfig=function(){ht=null,X=!1},n.isValidAttribute=function(t,e,n){ht||vt({});var r=Wt(t),i=Wt(e);return St(r,i,n)},n.addHook=function(t,e){"function"==typeof e&&(S[t]=S[t]||[],Vt(S[t],e))},n.removeHook=function(t){S[t]&&$t(S[t])},n.removeHooks=function(t){S[t]&&(S[t]=[])},n.removeAllHooks=function(){S={}},n}(),Fe=25,Se=10,Me=10,Ne={};function Le(t,e,n,r,i,a,o){var s=n-t/2-Me,u=n+t/2+Me,l=t/2+Math.min(0,s-i.left)+Math.max(0,u-i.right);return{pos:[l,o],shape:l-Se<5?[-l,-15*a,Math.max(Se,5-l),-10*a]:l+Se>t-5?[Math.min(-10,t-l-5),-10*a,Math.min(Se,t-l),-15*a]:[-10,-10*a,Se,-10*a]}}function Oe(t,e,n,r,i,a,o){var s=r-e/2-Me,u=r+e/2+Me,l=e/2+Math.min(0,s-i.top)+Math.max(0,u-i.bottom);return{pos:[o,l],shape:l-Se<5?[-15*a,-l,-10*a,Math.max(Se,5-l)]:l+Se>e-5?[-10*a,Math.min(-10,e-l-5),-15*a,Math.min(Se,e-l)]:[-10*a,-10,-10*a,Se]}}function Ue(t,e,n,r,i,a){var o=Ne[t](e,n,r,i,a),s=r-Fe-o.pos[0],u=i-Fe-o.pos[1];return{left:s,top:u,right:s+e+50,bottom:u+n+50}}function Re(t,e,n){var r,i=document.createElementNS("http://www.w3.org/2000/svg",t);if(e)for(r in e)i.setAttribute(r,e[r]);var a=i.style;if(n)for(r in n)a[r]=n[r];return i}function Be(){return Ce||((Ce=document.createElement("div")).id="flourish-popup-constrainer",(ke=Ce.style).overflow="hidden",ke.pointerEvents="none",ke.position="absolute",ke.left="0",ke.top="0",ke.margin="0",ke.padding="0",document.body.appendChild(Ce),this._resizeConstrainer(),Ce)}Ne.bottom=function(t,e){return{shape:[-10,-10,Se,-10],pos:[t/2,e+Me]}},Ne.top=function(t,e){return{shape:[-10,Me,Se,Me],pos:[t/2,-10]}},Ne.left=function(t,e){return{shape:[Me,Se,Me,-10],pos:[-10,e/2]}},Ne.right=function(t,e){return{shape:[-10,Se,-10,-10],pos:[t+Me,e/2]}},Ne.topLeft=function(t,e){return{shape:[15,Me,Me,15],pos:[-10,-10]}},Ne.bottomLeft=function(t,e){return{shape:[15,-10,Me,-15],pos:[-10,e+Me]}},Ne.topRight=function(t,e){return{shape:[-15,Me,-10,15],pos:[t+Me,-10]}},Ne.bottomRight=function(t,e){return{shape:[-15,-10,-10,-15],pos:[t+Me,e+Me]}},Ne.bottomFlexible=function(t,e,n,r,i){return Le(t,0,n,0,i,1,e+Me)},Ne.topFlexible=function(t,e,n,r,i){return Le(t,0,n,0,i,-1,-10)},Ne.rightFlexible=function(t,e,n,r,i){return Oe(0,e,0,r,i,1,t+Me)},Ne.leftFlexible=function(t,e,n,r,i){return Oe(0,e,0,r,i,-1,-10)};var je,He=1,Ie={container:document.body,maxWidth:"70%",point:null,html:null,directions:["bottom","top","left","right","topLeft","bottomLeft","topRight","bottomRight","bottomFlexible","topFlexible","leftFlexible","rightFlexible"],fallbackFit:"horizontal"};function ze(){for(var t in this.unique_id=He++,this.is_visible=!0,Ie)this["_"+t]=Ie[t];this.handlers={click:[]}}function Pe(t){ze.prototype[t]=function(e){return void 0===e?this["_"+t]:(this["_"+t]=e,this)}}for(var qe in Ie)Pe(qe);function Ye(){return new ze}function $e(){je=Ye().container(document.body),function(t){t.on("mouseover",Ve).on("mouseout",We)}(Ct(".popup"))}function Ve(){if(this.getAttribute("data-popup-head")||this.getAttribute("data-popup-body")){var t=this.getAttribute("data-popup-position"),e=this.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height,i=this.getAttribute("data-popup-head")||null,a=this.getAttribute("data-popup-body")||null,o="",s=["top","topFlexible"];i&&(o+=Tt("h1").html(De.sanitize(i)).node().outerHTML),a&&(o+=Tt("p").html(De.sanitize(a)).node().outerHTML),t&&("left"===t?(s=["right","rightFlexible"],n=e.left,r=e.top+e.height/2):"right"===t?(s=["left","leftFlexible"],n=e.right,r=e.top+e.height/2):"top"===t?(s=["bottom","bottomFlexible"],n=e.left+e.width/2,r=e.top):"bottom"===t&&(s=["top","topFlexible"],n=e.left+e.width/2,r=e.top+e.height)),je.point(n,r).html(o).directions(s).draw()}}function We(){je.hide()}ze.prototype.point=function(t,e){if(void 0===t)return this._point;if(Array.isArray(t))this._point=[t[0],t[1]];else if(void 0!==e)this._point=[t,e];else if(t instanceof HTMLElement||t instanceof SVGElement){var n=t.getBoundingClientRect();this._point=[Math.floor(n.left+n.width/2),Math.floor(n.top+n.height/2)]}else console.error("Popup: could not understand argument");return this},ze.prototype.directions=function(t){return void 0===t?this._directions:("string"==typeof t&&(t=[t]),this._directions=t.slice(),this)},ze.prototype.text=function(t){return this._html=function(t){return t.replace(/[&<>]/g,(function(t){return{"&":"&","<":"<",">":">"}[t]}))}(t),this},ze.prototype.on=function(t,e){if(!(t in this.handlers))throw new Error("Popup.on: No such event: "+t);return this.handlers[t].push(e),this},ze.prototype.fire=function(t,e){if(!(t in this.handlers))throw new Error("Popup.fire: No such event: "+t);for(var n=this.handlers[t],r=0;r<n.length;r++)n[r].call(this,e);return this},ze.prototype._getElement=function(){var t=this,e="flourish-popup-"+t.unique_id,n=document.getElementById(e);if(!n){(n=document.createElement("div")).className="flourish-popup",n.id=e;var r=n.style;r.display="none",r.margin=r.padding=0,r.position="absolute",r.width="80px",r.height="40px",r.boxSizing="border-box",n.addEventListener("click",(function(e){t.fire("click",e)}),!1);var i=Re("svg",{class:"flourish-popup-svg"},{position:"absolute",top:0,left:0,bottom:0,right:0}),a=Re("filter",{id:"dropshadow-"+t.unique_id,height:"130%"});a.appendChild(Re("feGaussianBlur",{in:"SourceAlpha",stdDeviation:5})),a.appendChild(Re("feOffset",{dx:0,dy:2,result:"offsetblur"}));var o=Re("feComponentTransfer");o.appendChild(Re("feFuncA",{type:"linear",slope:.2})),a.appendChild(o);var s=Re("feMerge");a.appendChild(s),s.appendChild(Re("feMergeNode")),s.appendChild(Re("feMergeNode",{in:"SourceGraphic"})),i.appendChild(a);var u=Re("g",{filter:"url(#dropshadow-"+t.unique_id+")",fill:"white",stroke:"none"});u.appendChild(Re("rect",{x:Fe,y:Fe,rx:5})),u.appendChild(Re("path")),i.appendChild(u),n.appendChild(i);var l=document.createElement("div");l.className="flourish-popup-content",(r=l.style).position="absolute",r.top=r.left="25px",r.padding="10px",n.appendChild(l),t._getConstrainer().appendChild(n)}return t._resizeConstrainer(),n},ze.prototype._getConstrainer=Be,ze.prototype._resizeConstrainer=function(){Ce||Be.call(this);var t=ke.display;ke.display="none",ke.width=document.documentElement.scrollWidth+"px",ke.height=document.documentElement.scrollHeight+"px",ke.display=t},ze.prototype.draw=function(){var t=this;if(t.is_visible=!0,t._point){var e=document.documentElement.getBoundingClientRect(),n=t._point[0],r=t._point[1],i=t._container.getBoundingClientRect();n<i.left?n=i.left:n>i.right&&(n=i.right),r<i.top?r=i.top:r>i.bottom&&(r=i.bottom);var a=n-e.left,o=r-e.top,s=t._getElement(),u=s.style,l=s.querySelector(".flourish-popup-svg"),c=l.querySelector("g"),d=c.querySelector("rect"),f=c.querySelector("path"),p=s.querySelector(".flourish-popup-content");u.display="block",p.style.maxWidth=function(e){return t._maxWidth.match(/^\d+(?:\.\d+)?%$/)?e.width*parseFloat(t._maxWidth)/100:t._maxWidth.match(/^\d+(?:\.\d+)?(?:px)?$/)?parseFloat(t._maxWidth):(null!=t._maxWidth&&console.error("Popup: Unknown value for maxWidth: "+t._maxWidth),e.width)}(i)+"px",t._inner_html!=t._html&&(p.innerHTML=t._inner_html=t._html);var h,m,v=p.getBoundingClientRect();do{h=Math.ceil(v.width),m=Math.ceil(v.height),u.width=h+50+"px",u.height=m+50+"px",v=p.getBoundingClientRect()}while(h!=Math.ceil(v.width)||m!=Math.ceil(v.height));d.setAttribute("width",h),d.setAttribute("height",m),l.setAttribute("width",h+50),l.setAttribute("height",m+50);for(var g,y,_=null,b=null,w=null,x=1/0,A=1/0,E=0;E<t._directions.length;E++){var T=t._directions[E],C=Ue(T,h,m,n,r,i),k=Math.max(0,Math.floor(i.left)-C.left-15)+Math.max(0,C.right-Math.ceil(i.right)-15),D=Math.max(0,Math.floor(i.top)-C.top-15)+Math.max(0,C.bottom-Math.ceil(i.bottom)-15);if(0==k&&0==D){_=T;break}(k<x||k==x&&D<g)&&(x=k,g=D,b=T),(D<A||D==A&&k<y)&&(A=D,y=k,w=T)}return _?T=_:"horizontal"==t._fallbackFit?T=b:"vertical"==t._fallbackFit?T=w:(console.warn("Popup: failed to point box of size ("+h+", "+m+") at ("+n+", "+r+") within ("+i.left+", "+i.top+", "+i.right+", "+i.bottom+")"),T=t._directions[0]),function(t,e,n,r,i,a,o,s,u,l){var c=Ne[t](r,i,s,u,l);e.left=a-Fe-c.pos[0]+"px",e.top=o-Fe-c.pos[1]+"px",n.setAttribute("d","M0,0L"+c.shape.join(",")+"Z"),n.setAttribute("transform","translate("+(c.pos[0]+Fe)+","+(c.pos[1]+Fe)+")")}(T,u,f,h,m,a,o,n,r,i),t}console.error("Popup: cannot draw popup till point() has been specified")},ze.prototype.hide=function(){return this.is_visible?(this.is_visible=!1,this._getElement().style.display="none",this):this},Ye.version="2.1.5";const Ge=Math.pow(2,31)-1,Xe=Math.pow(2,15);function Je(t,e){if(t=t.toUpperCase(),!/^[A-Z]+$/.test(t)){if(!t){if(e)return-1;throw new Error("Non-optional data binding must specify column")}throw function(t){try{tn(t)}catch(t){return!1}return!0}(t)?new Error("You can only select one column"):new Error("Invalid column specification: "+t)}for(var n=0,r=0;r<t.length;r++)n=26*n+(t.charCodeAt(r)-64);return n-1>Ge&&console.warn("Column index out of range"),Math.min(n-1,Ge)}function Ze(t){t+=1;for(var e="";t>0;){var n=Math.floor(t/26),r=t%26;0==r&&(n-=1,r+=26),e=String.fromCharCode(64+r)+e,t=n}return e}function Ke(t){var e=t.match(/\s*(?:[-–—:]|\.\.)\s*/);if(!e)throw new Error("Failed to parse column range: "+t);var n=t.substr(0,e.index),r=t.substr(e.index+e[0].length),i=Je(n),a=Je(r),o=[],s=a>=i?1:-1,u=Math.abs(a-i)+1;u>Xe&&(console.warn("Truncating excessively long range"),u=Xe);for(var l=0;l<u;l++)o.push(i+l*s);return o}function Qe(t,e){return Ze(t)+"-"+Ze(e)}function tn(t){var e=[],n=(t=t.replace(/^\s+|\s+$/g,"")).split(/\s*,\s*/);1==n.length&&""===n[0]&&(n=[]);for(var r=0;r<n.length;r++){var i=n[r];/^[A-Za-z]+$/.test(i)?e.push(Je(i)):Array.prototype.push.apply(e,Ke(i))}return e}function en(t){for(var e=function(t){if(!t.length)return[];for(var e=[],n=t[0],r=t[0],i=null,a=0;a<t.length-1;a++){var o=t[a+1]-t[a];null!==i||1!==Math.abs(o)?o!==i?(e.push([n,r]),n=r=t[a+1],i=null):r=t[a+1]:(r=t[a+1],i=o)}return e.push([n,r]),e}(t),n=[],r=0;r<e.length;r++){var i=e[r];i[0]==i[1]?n.push(Ze(i[0])):n.push(Qe(i[0],i[1]))}return n.join(",")}function nn(t,e,n,r){var i=n?e[t.data_table_id]+"::":"";if("column"in t)return i+Ze(t.column);if("columns"in t)return i+en(t.columns);if(r)return"";throw new Error("Data binding must have .column or .columns")}var rn=new Date,an=new Date;function on(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=function(e){return t(e=new Date(+e)),e},i.ceil=function(n){return t(n=new Date(n-1)),e(n,1),t(n),n},i.round=function(t){var e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=function(t,n){return e(t=new Date(+t),null==n?1:Math.floor(n)),t},i.range=function(n,r,a){var o,s=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return s;do{s.push(o=new Date(+n)),e(n,a),t(n)}while(o<n&&n<r);return s},i.filter=function(n){return on((function(e){if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)}),(function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}))},n&&(i.count=function(e,r){return rn.setTime(+e),an.setTime(+r),t(rn),t(an),Math.floor(n(rn,an))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(e){return r(e)%t==0}:function(e){return i.count(0,e)%t==0}):i:null}),i}var sn=864e5,un=6048e5,ln=on((function(t){t.setHours(0,0,0,0)}),(function(t,e){t.setDate(t.getDate()+e)}),(function(t,e){return(e-t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/sn}),(function(t){return t.getDate()-1}));function cn(t){return on((function(e){e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)}),(function(t,e){t.setDate(t.getDate()+7*e)}),(function(t,e){return(e-t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/un}))}var dn=cn(0),fn=cn(1);cn(2),cn(3);var pn=cn(4);cn(5),cn(6);var hn=on((function(t){t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,e){t.setFullYear(t.getFullYear()+e)}),(function(t,e){return e.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));hn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?on((function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,n){e.setFullYear(e.getFullYear()+n*t)})):null};var mn=on((function(t){t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCDate(t.getUTCDate()+e)}),(function(t,e){return(e-t)/sn}),(function(t){return t.getUTCDate()-1}));function vn(t){return on((function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCDate(t.getUTCDate()+7*e)}),(function(t,e){return(e-t)/un}))}var gn=vn(0),yn=vn(1);vn(2),vn(3);var _n=vn(4);vn(5),vn(6);var bn=on((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCFullYear(t.getUTCFullYear()+e)}),(function(t,e){return e.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));function wn(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function xn(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function An(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}bn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?on((function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null};var En,Tn,Cn,kn={"-":"",_:" ",0:"0"},Dn=/^\s*\d+/,Fn=/^%/,Sn=/[\\^$*+?|[\]().{}]/g;function Mn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function Nn(t){return t.replace(Sn,"\\$&")}function Ln(t){return new RegExp("^(?:"+t.map(Nn).join("|")+")","i")}function On(t){for(var e={},n=-1,r=t.length;++n<r;)e[t[n].toLowerCase()]=n;return e}function Un(t,e,n){var r=Dn.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Rn(t,e,n){var r=Dn.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Bn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function jn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Hn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function In(t,e,n){var r=Dn.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function zn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Pn(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function qn(t,e,n){var r=Dn.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Yn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function $n(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Vn(t,e,n){var r=Dn.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Wn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Gn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Xn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Jn(t,e,n){var r=Dn.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Zn(t,e,n){var r=Dn.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Kn(t,e,n){var r=Fn.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Qn(t,e,n){var r=Dn.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function tr(t,e,n){var r=Dn.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function er(t,e){return Mn(t.getDate(),e,2)}function nr(t,e){return Mn(t.getHours(),e,2)}function rr(t,e){return Mn(t.getHours()%12||12,e,2)}function ir(t,e){return Mn(1+ln.count(hn(t),t),e,3)}function ar(t,e){return Mn(t.getMilliseconds(),e,3)}function or(t,e){return ar(t,e)+"000"}function sr(t,e){return Mn(t.getMonth()+1,e,2)}function ur(t,e){return Mn(t.getMinutes(),e,2)}function lr(t,e){return Mn(t.getSeconds(),e,2)}function cr(t){var e=t.getDay();return 0===e?7:e}function dr(t,e){return Mn(dn.count(hn(t)-1,t),e,2)}function fr(t){var e=t.getDay();return e>=4||0===e?pn(t):pn.ceil(t)}function pr(t,e){return t=fr(t),Mn(pn.count(hn(t),t)+(4===hn(t).getDay()),e,2)}function hr(t){return t.getDay()}function mr(t,e){return Mn(fn.count(hn(t)-1,t),e,2)}function vr(t,e){return Mn(t.getFullYear()%100,e,2)}function gr(t,e){return Mn((t=fr(t)).getFullYear()%100,e,2)}function yr(t,e){return Mn(t.getFullYear()%1e4,e,4)}function _r(t,e){var n=t.getDay();return Mn((t=n>=4||0===n?pn(t):pn.ceil(t)).getFullYear()%1e4,e,4)}function br(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Mn(e/60|0,"0",2)+Mn(e%60,"0",2)}function wr(t,e){return Mn(t.getUTCDate(),e,2)}function xr(t,e){return Mn(t.getUTCHours(),e,2)}function Ar(t,e){return Mn(t.getUTCHours()%12||12,e,2)}function Er(t,e){return Mn(1+mn.count(bn(t),t),e,3)}function Tr(t,e){return Mn(t.getUTCMilliseconds(),e,3)}function Cr(t,e){return Tr(t,e)+"000"}function kr(t,e){return Mn(t.getUTCMonth()+1,e,2)}function Dr(t,e){return Mn(t.getUTCMinutes(),e,2)}function Fr(t,e){return Mn(t.getUTCSeconds(),e,2)}function Sr(t){var e=t.getUTCDay();return 0===e?7:e}function Mr(t,e){return Mn(gn.count(bn(t)-1,t),e,2)}function Nr(t){var e=t.getUTCDay();return e>=4||0===e?_n(t):_n.ceil(t)}function Lr(t,e){return t=Nr(t),Mn(_n.count(bn(t),t)+(4===bn(t).getUTCDay()),e,2)}function Or(t){return t.getUTCDay()}function Ur(t,e){return Mn(yn.count(bn(t)-1,t),e,2)}function Rr(t,e){return Mn(t.getUTCFullYear()%100,e,2)}function Br(t,e){return Mn((t=Nr(t)).getUTCFullYear()%100,e,2)}function jr(t,e){return Mn(t.getUTCFullYear()%1e4,e,4)}function Hr(t,e){var n=t.getUTCDay();return Mn((t=n>=4||0===n?_n(t):_n.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ir(){return"+0000"}function zr(){return"%"}function Pr(t){return+t}function qr(t){return Math.floor(+t/1e3)}function Yr(t){throw new TypeError("Expected a value of type string but got a value of type "+typeof t)}function $r(t){return function(e){return"string"!=typeof e&&Yr(e),(e=e.trim())?t(e):null}}En=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,u=t.shortMonths,l=Ln(i),c=On(i),d=Ln(a),f=On(a),p=Ln(o),h=On(o),m=Ln(s),v=On(s),g=Ln(u),y=On(u),_={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:er,e:er,f:or,g:gr,G:_r,H:nr,I:rr,j:ir,L:ar,m:sr,M:ur,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Pr,s:qr,S:lr,u:cr,U:dr,V:pr,w:hr,W:mr,x:null,X:null,y:vr,Y:yr,Z:br,"%":zr},b={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return u[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:wr,e:wr,f:Cr,g:Br,G:Hr,H:xr,I:Ar,j:Er,L:Tr,m:kr,M:Dr,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Pr,s:qr,S:Fr,u:Sr,U:Mr,V:Lr,w:Or,W:Ur,x:null,X:null,y:Rr,Y:jr,Z:Ir,"%":zr},w={a:function(t,e,n){var r=p.exec(e.slice(n));return r?(t.w=h[r[0].toLowerCase()],n+r[0].length):-1},A:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=f[r[0].toLowerCase()],n+r[0].length):-1},b:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.m=y[r[0].toLowerCase()],n+r[0].length):-1},B:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=v[r[0].toLowerCase()],n+r[0].length):-1},c:function(t,n,r){return E(t,e,n,r)},d:$n,e:$n,f:Zn,g:zn,G:In,H:Wn,I:Wn,j:Vn,L:Jn,m:Yn,M:Gn,p:function(t,e,n){var r=l.exec(e.slice(n));return r?(t.p=c[r[0].toLowerCase()],n+r[0].length):-1},q:qn,Q:Qn,s:tr,S:Xn,u:Rn,U:Bn,V:jn,w:Un,W:Hn,x:function(t,e,r){return E(t,n,e,r)},X:function(t,e,n){return E(t,r,e,n)},y:zn,Y:In,Z:Pn,"%":Kn};function x(t,e){return function(n){var r,i,a,o=[],s=-1,u=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++s<l;)37===t.charCodeAt(s)&&(o.push(t.slice(u,s)),null!=(i=kn[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),u=s+1);return o.push(t.slice(u,s)),o.join("")}}function A(t,e){return function(n){var r,i,a=An(1900,void 0,1);if(E(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=xn(An(a.y,0,1))).getUTCDay(),r=i>4||0===i?yn.ceil(r):yn(r),r=mn.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=wn(An(a.y,0,1))).getDay(),r=i>4||0===i?fn.ceil(r):fn(r),r=ln.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),i="Z"in a?xn(An(a.y,0,1)).getUTCDay():wn(An(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,xn(a)):wn(a)}}function E(t,e,n,r){for(var i,a,o=0,s=e.length,u=n.length;o<s;){if(r>=u)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in kn?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return _.x=x(n,_),_.X=x(r,_),_.c=x(e,_),b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),{format:function(t){var e=x(t+="",_);return e.toString=function(){return t},e},parse:function(t){var e=A(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=A(t+="",!0);return e.toString=function(){return t},e}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),Tn=En.format,Cn=En.parse,En.utcFormat,En.utcParse;var Vr=new Date(1972,3,27,19,45,5),Wr={"%b %d":[{regex:/^june\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,5,t.split(/\s/)[1])}},{regex:/^july\s(3[01]|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,6,t.split(/\s/)[1])}},{regex:/^sept\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,8,t.split(/\s/)[1])}}],"%d %b":[{regex:/^(0?[1-9]|[1-9][0-9])\sjune$/i,toDate:function(t){return new Date(null,5,t.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\sjuly$/i,toDate:function(t){return new Date(null,6,t.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\ssept$/i,toDate:function(t){return new Date(null,8,t.split(/\s/)[0])}}]};function Gr(t){return function(e){var n=null;return t.forEach((function(t){e.match(t.regex)&&(n=t.toDate(e))})),n}}function Xr(t,e){var n,r=Cn(t),i=Tn(t);return n=$r("function"==typeof e?function(t){return e(t,null!==r(t))}:function(t){return null!==r(t)}),Object.freeze({test:n,parse:$r((function(e){return r(e)||(Wr[t]?Gr(Wr[t])(e):null)})),format:function(t){return i(t)},type:"datetime",description:t,id:"datetime$"+t,example:i(Vr)})}var Jr=Object.freeze([Xr("%Y-%m-%dT%H:%M:%S.%LZ"),Xr("%d/%m/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3})),Xr("%d/%m/%y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&!isNaN(n[2])})),Xr("%m/%d/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3})),Xr("%m/%d/%y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&!isNaN(n[2])})),Xr("%Y/%m/%d",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12&&n[2]>0&&n[2]<=31})),Xr("%d-%m-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3})),Xr("%d-%m-%y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&!isNaN(n[2])})),Xr("%m-%d-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3})),Xr("%m-%d-%y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&!isNaN(n[2])})),Xr("%Y-%m-%d",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12&&n[2]>0&&n[2]<=31})),Xr("%d %b %Y",(function(t,e){if(!e)return!1;var n=t.split(" ").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d %B %Y",(function(t,e){if(!e)return!1;var n=t.split(" ").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d %b %y"),Xr("%d %B %y"),Xr("%d-%b-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d-%B-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d-%b-%y"),Xr("%d-%B-%y"),Xr("%m/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>=1e3})),Xr("%m/%y"),Xr("%b %Y",(function(t,e){return!!e&&t.split(" ").map(parseFloat)[1]>=1e3})),Xr("%B %Y",(function(t,e){return!!e&&t.split(" ").map(parseFloat)[1]>=1e3})),Xr("%b %y"),Xr("%B %y"),Xr("%d %b",(function(t,e){return!!e||!!Gr(Wr["%d %b"])(t)})),Xr("%d %B"),Xr("%b %d",(function(t,e){return!!e||!!Gr(Wr["%b %d"])(t)})),Xr("%B %d"),Xr("%d-%m",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12})),Xr("%m-%d"),Xr("%d/%m"),Xr("%m/%d"),Xr("%Y",(function(t,e){if(!e)return!1;var n=parseFloat(t);return n>1499&&n<2200})),Xr("%B"),Xr("%b"),Xr("%X"),Xr("%I:%M %p"),Xr("%H:%M"),Xr("%H:%M:%S"),Xr("%-I%p"),Xr("Q%q %Y",(function(t,e){return!!e&&6===t.replace(/\s/g,"").length})),Xr("%Y Q%q",(function(t,e){return!!e&&6===t.replace(/\s/g,"").length}))]);function Zr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}var Kr,Qr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ti(t){if(!(e=Qr.exec(t)))throw new Error("invalid format: "+t);var e;return new ei({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function ei(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function ni(t,e){var n=Zr(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}ti.prototype=ei.prototype,ei.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var ri={"%":function(t,e){return(100*t).toFixed(e)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},g:function(t,e){return t.toPrecision(e)},o:function(t){return Math.round(t).toString(8)},p:function(t,e){return ni(100*t,e)},r:ni,s:function(t,e){var n=Zr(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Kr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Zr(t,Math.max(0,e+a-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function ii(t){return t}var ai=Array.prototype.map,oi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function si(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?ii:(e=ai.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),a.push(t.substring(i-=s,i+s)),!((u+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?ii:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(ai.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"-":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function d(t){var e=(t=ti(t)).fill,n=t.align,d=t.sign,f=t.symbol,p=t.zero,h=t.width,m=t.comma,v=t.precision,g=t.trim,y=t.type;"n"===y?(m=!0,y="g"):ri[y]||(void 0===v&&(v=12),g=!0,y="g"),(p||"0"===e&&"="===n)&&(p=!0,e="0",n="=");var _="$"===f?i:"#"===f&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",b="$"===f?a:/[%p]/.test(y)?u:"",w=ri[y],x=/[defgprs%]/.test(y);function A(t){var i,a,u,f=_,A=b;if("c"===y)A=w(t)+A,t="";else{var E=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),v),g&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),E&&0==+t&&"+"!==d&&(E=!1),f=(E?"("===d?d:l:"-"===d||"("===d?"":d)+f,A=("s"===y?oi[8+Kr/3]:"")+A+(E&&"("===d?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(u=t.charCodeAt(i))||u>57){A=(46===u?o+t.slice(i+1):t.slice(i))+A,t=t.slice(0,i);break}}m&&!p&&(t=r(t,1/0));var T=f.length+t.length+A.length,C=T<h?new Array(h-T+1).join(e):"";switch(m&&p&&(t=r(C+t,C.length?h-A.length:1/0),C=""),n){case"<":t=f+t+A+C;break;case"=":t=f+C+t+A;break;case"^":t=C.slice(0,T=C.length>>1)+f+t+A+C.slice(T);break;default:t=C+f+t+A}return s(t)}return v=void 0===v?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v)),A.toString=function(){return t+""},A}return{format:d,formatPrefix:function(t,e){var n,r=d(((t=ti(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor((n=e,((n=Zr(Math.abs(n)))?n[1]:NaN)/3)))),a=Math.pow(10,-i),o=oi[8+i/3];return function(t){return r(a*t)+o}}}}var ui={test:$r((function(t){return/^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:$r((function(t){return parseFloat(t.replace(/,/g,""))})),description:"Comma thousand separator, point decimal mark",thousand_separator:",",decimal_mark:".",id:"number$comma_point",example:"12,235.56"},li={test:$r((function(t){return/^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:$r((function(t){return parseFloat(t.replace(/\s/g,""))})),description:"Space thousand separator, point decimal mark",thousand_separator:" ",decimal_mark:".",id:"number$space_point",example:"12 235.56"},ci={test:$r((function(t){return/^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:$r((function(t){return parseFloat(t)})),description:"No thousand separator, point decimal mark",thousand_separator:"",decimal_mark:".",id:"number$none_point",example:"12235.56"},di={test:$r((function(t){return/^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:$r((function(t){return parseFloat(t.replace(/\./g,"").replace(/,/,"."))})),description:"Point thousand separator, comma decimal mark",thousand_separator:".",decimal_mark:",",id:"number$point_comma",example:"12.235,56"},fi={test:$r((function(t){return/^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:$r((function(t){return parseFloat(t.replace(/\s/g,"").replace(/,/,"."))})),description:"Space thousand separator, comma decimal mark",thousand_separator:" ",decimal_mark:",",id:"number$space_comma",example:"12 235,56"},pi={test:$r((function(t){return/^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:$r((function(t){return parseFloat(t.replace(/,/,"."))})),description:"No thousand separator, comma decimal mark",thousand_separator:"",decimal_mark:",",id:"number$none_comma",example:"12235,56"},hi=Object.freeze([ui,li,di,fi,ci,pi]);hi.forEach((function(t){t.type="number",t.format=function(t){var e,n,r=si({decimal:t.decimal_mark,thousands:t.thousand_separator,grouping:[3],currency:["",""]});return function(t,i){return i||(i=",.2f"),i!==n&&(n=i,e=r.format(n)),e(t)}}(t),Object.freeze(t)}));var mi,vi=Object.freeze({test:function(t){return"string"==typeof t||Yr(t)},parse:function(t){return"string"==typeof t?t:Yr(t)},format:function(t){if("string"==typeof t)return t},type:"string",description:"Arbitrary string",id:"string$arbitrary_string"}),gi=Object.freeze({datetime:Jr,number:hi}),yi=Object.freeze(["datetime","number","string"]),_i=Object.freeze({n_max:250,n_failing_values:0,failure_fraction:.05,sort:!0}),bi=Object.freeze(Object.keys(_i));function wi(t,e){return t.index-e.index}function xi(t,e){return e.n_success-t.n_success||wi(t,e)}function Ai(t){return(""+t).trim()}function Ei(t){return void 0===t?function(t){return Ai(t)}:"function"==typeof t?function(e,n){return Ai(t(e,n))}:function(e){return Ai(e[""+t])}}function Ti(t){t?Array.isArray(t)||(t=[t]):t=yi;var e=t.reduce((function(t,e){var n=gi[e];return n&&Array.prototype.push.apply(t,n),t}),[]),n=-1!==t.indexOf("string"),r=bi.reduce((function(t,e){return t[e]=_i[e],t}),{}),i=function(t,i){i=Ei(i);var a=t.map(i).filter((function(t){return t}));if(!a.length)return n?[vi]:[];var o=Math.min(r.n_max,a.length),s=Math.floor(o*r.failure_fraction),u=r.n_failing_values,l=r.sort?xi:wi,c=e.slice().reduce((function(t,e,n){for(var r=c=0,i=[],l=!1,c=0;c<o;c++){var d=a[c];if(!e.test(d)&&(++r>s?l=!0:-1===i.indexOf(d)&&(i.push(d),i.length>u&&(l=!0)),l))break}return l||t.push({interp:e,n_success:o-r,index:n}),t}),[]).sort(l).map((function(t){return t.interp}));return n&&c.push(vi),c};return bi.forEach((function(t){var e;i[(e=t,e.replace(/_(\w)/g,(function(t,e){return e.toUpperCase()})))]=function(e){return void 0===e?r[t]:(r[t]=e,i)}})),i}function Ci(t,e,n,r){var i=[],a=[],o=0,s=[],u={};function l(t,e){if(!u[t])return{};var n=u[t];return n[e]?n[e]:{}}for(var c in s.column_names={},s.metadata={},n){var d={},f=n[c];if(f){for(let t=0;t<f.length;t++){const e=f[t].type_id,n=f[t].output_format_id,r=n&&"auto"!==n?n:e;d[f[t].index]={type_id:e,output_format_id:r}}u[c]=d}}for(var p in t)if(null!==t[p]&&(void 0!==t[p].columns||void 0!==t[p].column)){var h=t[p];if(h.template_data_binding=r[p],h.key=p,h.data_table_id in e){var m=e[h.data_table_id];if(0!=m.length){if("columns"in h&&null!=h.columns){var v=m[0].length;h.columns=h.columns.filter((function(t){return t<v})),s.column_names[p]=h.columns.map((function(t){return m[0][t]})),s.metadata[p]=h.columns.map((function(t){const{type_id:e,output_format_id:n}=l(h.data_table_id,t);return e?{type:e.split("$")[0],type_id:e,output_format_id:n}:null}))}else{if(!("column"in h)||null==h.column)throw new Error("Data binding includes no column(s) specification: "+JSON.stringify(h));{s.column_names[p]=m[0][h.column];const{type_id:t,output_format_id:e}=l(h.data_table_id,h.column);t&&(s.metadata[p]={type:t.split("$")[0],type_id:t,output_format_id:e})}}-1==a.indexOf(h.data_table_id)&&(a.push(h.data_table_id),o=Math.max(o,m.length-1)),i.push(h)}else console.warn("Empty data table")}else{var g=[];for(var y in e)g.push(y);console.error("Data table id "+h.data_table_id+" not in "+JSON.stringify(g))}}function _(t,e,n){if(!t.template_data_binding.data_type)return n;var r=function(t,e){const{type_id:n}=l(t,e);if(n)return Ti.getInterpretation(n)}(t.data_table_id,e),i=r?r.parse(n):n;return Number.isNaN(i)&&(i=null),i}for(var b=0;b<o;b++){for(var w={},x=0;x<i.length;x++){var A=e[(h=i[x]).data_table_id];b+1>=A.length||("columns"in h&&null!=h.columns?w[h.key]=h.columns.filter((function(t){return t<A[b+1].length})).map((function(t){return _(h,t,A[b+1][t])})):"column"in h&&null!=h.column&&(h.column>=A[b+1].length?w[h.key]=_(h,h.column,""):w[h.key]=_(h,h.column,A[b+1][h.column])))}s.push(w)}return s}function ki(t){return function(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<n;i++){for(var a=[],o=0;o<e;o++)a.push(t[o][i]);r.push(a)}return r}(t).map((function(t,e){const n=function(t){const e=t.length;return e>100?t.slice(10,e-10):e>50?t.slice(5,e-5):e>30?t.slice(4,e-4):e>20?t.slice(3,e-3):e>10?t.slice(2,e-2):e>1?t.slice(1,e):t.slice(0,1)}(t);let r;r=n.length>2e3?function(t,e){if(t.length<=2*e)return t;const n=function(t){let e=t;return function(){e|=0,e=e+1831565813|0;var t=Math.imul(e^e>>>15,1|e);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}(t.length);for(;t.length>e;){const e=Math.floor(n()*t.length);t.splice(e,1)}return t}(n,1e3):n;const i=(a=r,o=a.filter((function(t){return t&&!Fi.includes(t.trim())})).map(Mi),Si(o))[0].id;var a,o;return{type_id:i,index:e,output_format_id:i}}))}function Di(t){for(var e=t.length;e-- >1&&(!t[e]||!t[e].length||Array.isArray(t[e])&&-1==t[e].findIndex((function(t){return null!==t&&""!==t})));)t.splice(e,1);return t}Ti.DATETIME_IDS=Object.freeze(Jr.map((function(t){return t.id}))),Ti.NUMBER_IDS=Object.freeze(hi.map((function(t){return t.id}))),Ti.STRING_IDS=Object.freeze([vi.id]),Ti.getInterpretation=(mi=Jr.concat(hi,vi).reduce((function(t,e){return t[e.id]=e,t}),{}),function(t){return mi[t]}),Ti._createAccessorFunction=Ei,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 r=arguments[1],i=0;i<n;){var a=e[i];if(t.call(r,a,i,e))return i;i++}return-1},configurable:!0,writable:!0});var Fi=["#DIV/0","#N/A","#NAME?","#NULL!","#NUM!","#REF!","#VALUE!","#ERROR!"],Si=Ti().nMax(1/0).nFailingValues(8).failureFraction(.1);function Mi(t){return(t=t||"").replace(/[€£$¥%º]/g,"")}let Ni,Li={};const Oi=t=>{const e=Et(".dialog");if(t.which in Li){var n=Li[t.which];n.callback&&n.callback(Ni.node().value),e.remove(),t.preventDefault()}};function Ui(t,e,{buttons:n=[{text:"Okay",keyCode:13}],is_html:r=!1,upgrade:i=null,is_loading:a=!1,width:o="420px"}={}){var s=Et("body").append("div").attr("class","dialog").attr("tabindex",0),u=s.append("div").attr("class","dialog-inner").style("width",o),l=u.append("div").attr("class","text"+(a?" loading":""));if("string"==typeof t?l.append("h1").text(t):t instanceof HTMLElement&&l.append("h1").append((()=>t)),"string"==typeof e)Ni=r?l.append("div").classed("loading-spinner",a).html(e):l.append("p").text(e);else if(e instanceof HTMLElement)Ni=l.append((()=>e));else if("object"==typeof e){if(Ni=l.append(e.type),e.value&&(Ni.node().value=e.value),e.attributes)for(var c in e.attributes)Ni.attr(c,e.attributes[c]);Ni.node().focus()}var d=u;null!=i&&"object"==typeof i&&function(t,e,n,r){r&&t.classed("business",!0);var i=t.append("div").attr("class","text");i.append("p").text(e),i.append("ul").selectAll("li").data(n).enter().append("li").html((function(t){return t})).append("i").attr("class","fa fa-check")}(d=d.append("div").attr("class","upgrade"),i.message,i.list,i.is_business);var f=d.append("div").attr("class","btns"+(a?" loading":""));return Li={},n.forEach((function(t){var e=f.append(t.tag_name||"div").attr("class","btn").attr("data-testid","dialog-button").style("margin-right",a?"0":"0.75em").text(t.text).on("click",(function(){t.callback&&t.callback(Ni.node().value,s),s.remove()}));t.class&&e.classed(t.class,!0),t.keyCode&&(Li[t.keyCode]=t),t.href&&e.attr("href",t.href),t.fa_icon&&e.append("i").lower().attr("class","fa "+t.fa_icon)})),s.node().addEventListener("keydown",Oi),s.node().focus(),s}var Ri="Add new value: ";function Bi(t,e,n,{allow_other_option:r=!1,custom_renderer:i=null,match_anywhere:a=!1}={}){if(t.setAttribute("data-autocomplete",e),t.setAttribute("autocomplete","off"),!document.getElementById(e)){const n=Tt("i").classed("fa fa-chevron-down clickable",!0),r=Tt("div").classed("dropdown autocomplete",!0).attr("id",e);t.insertAdjacentHTML("afterend",n.node().outerHTML+r.node().outerHTML)}var o,s=Et(document.getElementById(e));s.classed("click-to-open",!0);var u=s.append("div").attr("class","dropdown-list");function l(t){if(1===t.length)return"dropdown-category";var e="dropdown-item";return o&&t[0]===o&&(e+=" current"),e}function c(t){u.selectAll("div").remove(),u.selectAll("div").data(t).enter().append("div").attr("class",l).attr("data-value",(function(t){return"string"==typeof t?t||null:t[1]})).each((function(t){const e=Et(this);if(!i){const n=Array.isArray(t)?t[0]:t;return void e.text(n)}let n=i(t,this);if(n){if(Array.isArray(n)||(n=[n]),n.find((t=>"string"!=typeof t&&!(t instanceof HTMLElement))))throw new Error("Autocomplete elements must be strings or HTMLElements");e.node().append(...n)}})),t.length||u.append("div").attr("class","dropdown-item disabled").text("No matches found")}function d(){s.classed("open",!1)}function f(t){var e=t.textContent;return 0===e.indexOf(Ri)&&(e=e.substr(Ri.length)),e}return s.on("mousedown",(function(e){var n=e.target;n.hasAttribute("data-value")?(t.value=f(n),t.setAttribute("data-value",n.getAttribute("data-value")),d(),Et(t).dispatch("change")):e.preventDefault()})),Et(t).on("keydown.autocomplete",(function(e){var n,r;9==e.keyCode||13==e.keyCode?(n=u.select(".selected")).empty()||(t.value=f(n.node()),t.setAttribute("data-value",n.attr("data-value")),d(),Et(t).dispatch("change"),t.blur()):40==e.keyCode?((n=u.select(".selected")).empty()||(r=n.node().nextSibling),r||(r=u.select(".dropdown-item[data-value]").node()),u.selectAll(".selected").classed("selected",!1),Et(r).classed("selected",!0)):38==e.keyCode&&((n=u.select(".selected")).empty()||(r=n.node().previousSibling),r||(r=u.select(".dropdown-item:last-child").node()),u.selectAll(".selected").classed("selected",!1),Et(r).classed("selected",!0))})).on("input.autocomplete",(function(){var e,i,o=t.value,s=o.toLowerCase(),u=!1;if(Et(t).attr("data-value",o),i=a?(t,e)=>t.includes(e):(t,e)=>0===t.indexOf(e),o){e=[];for(var l=0;l<n.length;l++){var d=("string"==typeof n[l]?n[l]:n[l][0]).toLowerCase();d==s&&(u=!0),i(d,s)&&e.push(n[l])}r&&!u&&e.unshift([Ri+o,o])}else e=n;c(e)})).on("focus.autocomplete",(function(){o=t.value,c(n),s.classed("open",!0)})).on("blur.autocomplete",d),{options:function(t){if(!arguments.length)return n;c(n=t)}}}var ji={number:{text:"Number",symbol:"/images/data_type_number.svg"},datetime:{text:"Date/time",symbol:"/images/data_type_date.svg"},string:{text:"Text",symbol:"/images/data_type_string.svg"}};Ti.STRING_IDS[0];var Hi,Ii,zi,Pi=[{full:"#F4B1C5",light:"#FFDDE7"},{full:"#967EC6",light:"#D0C5E5"},{full:"#C67EBD",light:"#E5C5E1"},{full:"#7E91C6",light:"#C5CDE5"},{full:"#7EB0C6",light:"#C5DBE5"},{full:"#7EC69B",light:"#C5E5D2"},{full:"#B3C67E",light:"#DDE5C5"},{full:"#C69B7E",light:"#E5D2C5"}],qi={},Yi={},$i=0;function Vi(t,e){$i=0;var n=!1;t.template_id&&t.dataTables((function(r,i){if(r)return console.error("Failed to get data tables: "+r);Yi={};var a=t.dataBindingsForCurrentTemplate(),o=t.getDataTableNames(),s=Et(".sheet-tab.selected").size()>0?Et(".sheet-tab.selected").datum().id:null;Ii.html("");var u=null;"string"!=typeof e[0]&&(e=["Data"].concat(e));for(var l,c=[],d=0;d<e.length;d++){var f=e[d];if("string"!=typeof f){if(null===l.template_sheet){var p=(f.columns||f.column||"").split("::")[0];if(p)for(var h in o)if(o[h]===p){l.template_sheet=+h;break}}if(null===l.visualisation_sheet){var m=a[f.dataset]&&a[f.dataset][f.key];m&&(l.visualisation_sheet=m.data_table_id)}l.bindings.push(f),d===e.length-1&&c.push(l)}else if(void 0!==l&&c.push(l),l={title:f,description:null,bindings:[],template_sheet:null,visualisation_sheet:null},d<e.length-1){var v=e[d+1];"string"==typeof v&&(l.description=v,d+=1)}}for(d=0;d<c.length;d++){var g=c[d],y=g.bindings,_=g.visualisation_sheet||g.template_sheet||i[0].id,b=(u=Ii.append("div").attr("class","data-block").attr("data-sheet",o[_]).style("display",_===s?null:"none")).append("h2").attr("class","no-select");b.append("i").attr("class","fa fa-table"),b.append("span").text(" "+g.title),g.description&&u.append("p").text(g.description);var w=u.append("div").attr("class","data-bindings-header");w.append("p").attr("class","data-bindings-title").text("Select columns to visualise");for(var x=0;x<y.length;x++){var A=y[x];A.data_type&&(n=!0);var E=a[A.dataset]&&a[A.dataset][A.key],T=E?E.data_table_id:_;Yi[A.dataset]||(Yi[A.dataset]={}),Yi[A.dataset][A.key]=T,T!==_&&T===s&&u.style("display",null),Wi(u.append("div"),A,E,o,T!==s)}n&&w.append("p").attr("class","data-bindings-reset clickable").html("<i class='fa fa-magic'></i> Auto set columns").on("click",(function(){Ui("Automatically choose your columns","<i class='fa fa-magic'></i> Flourish will interpret your data to determine which columns to visualize",{is_html:!0,buttons:[{text:"Continue",keyCode:13,class:"primary",callback:function(){Hi.spreadsheet.inferDataBindings()}},{text:"Cancel",keyCode:27,class:"secondary"}]})}))}Hi.spreadsheet&&(Hi.spreadsheet.updateHighlights(),Hi.spreadsheet.updateTabs())}))}function Wi(t,e,n,r,i){Pi[$i]||($i=0),t.attr("class","settings-option option-type-"+e.type).style("display",i?"none":null);var a=null==n?"":nn(n,r,!1,e.optional);qi[e.dataset]||(qi[e.dataset]={}),qi[e.dataset][e.key]=$i;var o="column"===e.type&&!e.optional,s=o&&!n;t.classed("empty-required-binding",s);var u=t.append("div").attr("class","data-binding-title").on("click",(function(){Et(this).select("input").node().focus()}));u.append("h3").text(e.name).append("i").attr("class","fa fa-question setting-tooltip").style("display",e.description||e.data_type?null:"none"),"column"!=e.type||e.optional||u.select("h3").append("span").attr("class","required").text("Required"),u.append("input").attr("id","data-binding-"+e.dataset+"-"+e.key).attr("name",e.dataset+"-"+e.key).attr("disabled",!Hi.visualisation.can_edit||null).attr("autocomplete","off").attr("title",'Type in column IDs here, for example "A" or "A,B,D" or "A-D"').each((function(){this.value=a})).attr("data-value",a).attr("type","text").call(function(t){return function(e){e.on("change",(function(){je.hide(),function(t,e){var n=t.parentElement.parentElement.parentElement.getAttribute("data-sheet"),r=t.value.indexOf("::")>-1,i={type:e.type};"column"==i.type?i.column=r?t.value:n+"::"+t.value:i.columns=r?t.value:n+"::"+t.value;var a,o=t.getBoundingClientRect(),s=[o.left-5,o.top+.5*o.height];if(t.value||"column"!=i.type){try{var u=nn(a=function(t,e){var n={};if(!(t.type in t)){if(t.optional)return n;throw new Error("Data binding must specify '"+t.type+"': "+JSON.stringify(t))}var r=t[t.type].indexOf("::");if(-1==r)throw new Error("Invalid data binding: "+t[t.type]);var i=t[t.type].substr(0,r);n.data_table_id=e[i];var a=t[t.type].substr(r+2);if("column"==t.type)n.column=Je(a,t.optional);else{if("columns"!=t.type)throw new Error("Unknown data binding type: "+t.type);n.columns=tn(a)}return n}(i,Hi.visualisation.getDataTableIds()),Hi.visualisation.getDataTableNames(),!1,e.optional);t.value.toUpperCase()!==u&&(t.value=u)}catch(e){return console.error("Failed to parse data binding",e),je.point(s).text(e.message).draw(),t.value=t.getAttribute("data-value"),void(zi=!0)}if(Et(t.parentElement.parentElement).classed("empty-required-binding",!1),!a.data_table_id)return t.value=t.getAttribute("data-value"),je.point(s).text("No such data table").draw(),void(zi=!0);if(e.data_type){const n=Hi.spreadsheet.getTypeAnnotatedColumns();if("column"===i.type){const r=n[a.column];if(!r)return je.point(s).html(`<h1>Column '${t.value}' does not exist</h1><p>Choose a column from the data table</p>`).draw(),t.value=t.getAttribute("data-value"),void(zi=!0);if(Xi(e,r))return t.value=t.getAttribute("data-value"),je.point(s).html(`\n\t\t\t\t\t\t<h1>This column selection does not accept ${Ji([r.type])} columns</h1>\n\t\t\t\t\t\t<p style="font-size:1em; margin-top:0.75em;">Choose a different column or check/change the column’s type in the header row with the following types:</p>\n\t\t\t\t\t\t<div style="font-size: 1em; margin-top: 0.75em;">${Ji(e.data_type)}</div>\n\t\t\t\t\t`).draw(),void(zi=!0)}else{const r=n.filter((t=>a.columns.includes(t.index))).filter((t=>Xi(e,t)));if(r.length){t.value=t.getAttribute("data-value");var l=r.map((t=>t.type)).reduce(((t,e)=>t.includes(e)?t:[...t,e]),[]).reduce(((t,e,n,r)=>1===r.length?Ji([e]):(n<r.length-1?t+=`${n>0?",":""} ${Ji([e])}`:t+=`or ${Ji([e])}`,t)),"");return je.point(s).html(`\n\t\t\t\t\t\t<h1>This column selection does not accept ${l} columns</h1>\n\t\t\t\t\t\t<p style="font-size:1em; margin-top:0.75em;">Choose a different column or check/change the column’s type in the header row with the following types:</p>\n\t\t\t\t\t\t<div style="font-size: 1em; margin-top: 0.75em;">${Ji(e.data_type)}</div>\n\t\t\t\t\t`).draw(),void(zi=!0)}}}}else if(a=null,!e.optional)return t.value=t.getAttribute("data-value"),je.point(s).text("This column selection is required").draw(),void(zi=!0);Hi.spreadsheet.updateTabs();var c={};c[e.dataset]={},c[e.dataset][e.key]=a,Gi(c,(function(){t.setAttribute("data-value",t.value);var e=Zi();e?(Et(".publish-btn").classed("disabled",!0),Et(".republish-btn").classed("disabled",!0),Ct(".download-btn").classed("disabled",!0),Et("body").classed("impossible",!0)):(Et(".publish-btn").classed("disabled",!1),Et(".republish-btn").classed("disabled",!1),Ct(".download-btn").classed("disabled",!1),Et("body").classed("impossible",!1),Hi.visualisation.getState((function(t){Hi.visualisation.prepareData((function(e,n){e?console.error("Failed to prepare data for template"):Hi.preview_pane.getDrawCalled()?Hi.preview_pane.sync({data:n,state:t,update:!0}):(Hi.preview_pane.sync({data:n,state:t,draw:!0}),Hi.preview_pane.setDrawCalled(!0))}))}))),Hi.spreadsheet&&Hi.spreadsheet.updateHighlights(),Hi.template_settings&&(e?Hi.template_settings.setReadOnly():Hi.template_settings.unsetReadOnly(),Hi.template_settings.populate()),Hi.theme_chooser.enableOrDisable()}))}(this,t)})).on("keydown",(function(){Hi.confirm.blank()})).on("focus",(function(){zi||je.hide(),zi=!1,Ct(".data-bindings .settings-option").classed("open",!1),Et(this.parentElement.parentElement).classed("open",!0)}))}}(e)).style("background",Pi[$i].light).style("border-color",Pi[$i].full),s&&Hi.template_settings.setReadOnly(),o&&t.append("div").attr("class","data-binding-required").append("p").text("This column selection is required. The visualisation will not update while this field is empty.");var l,c=t.append("div").attr("class","data-binding-description");if(e.description&&c.append("p").text(e.description),e.data_type){var d=c.append("div").attr("class","data-binding-data-types");d.append("p").text("Accepted column types");for(var f=Array.isArray(e.data_type)?e.data_type:[e.data_type],p=0;p<f.length;p++)l="string"==typeof f[p]?f[p]:f[p].type,d.append("span").attr("class","type-symbol data-binding-type-symbol").attr("title",ji[l].text+" column.").style("background-image","url("+ji[l].symbol+")")}$i++}function Gi(t,e){Hi.confirm.saving(),Hi.visualisation.updateDataBindings(t,(function(t){if(t)return Hi.confirm.error(t.message||t),console.error("Failed to save data binding:",t),void Hi.analytics("send","exception",{exDescription:t.message||t,exFatal:!0});Hi.analytics("send","event","visualisation","change_data_binding",Hi.visualisation.id),Hi.confirm.saved(),Ki(),e&&e()}))}function Xi(t,e){return!(Array.isArray(t.data_type)?t.data_type:[t.data_type]).some((t=>"string"==typeof t?t===e.type:t.type===e.type))}function Ji(t){return t.map((t=>`\n\t\t<span class="column-type">\n\t\t<span class="type-symbol" title="${ji[t].text} column" style="background-image: url(${ji[t].symbol});"></span>\n\t\t<h2>${ji[t].text}</h2>\n\t\t</span>\n\t\t`)).join("")}function Zi(){var t=Hi.visualisation.dataBindingsForCurrentTemplate(),e=Hi.template_data_bindings,n={};return e.forEach((function(t){"string"!=typeof t&&(n[t.dataset]||(n[t.dataset]={}),n[t.dataset][t.key]=t)})),e.some((function(e){if("string"!=typeof e&&"column"===e.type&&!n[e.dataset][e.key].optional)return!t[e.dataset]||null==t[e.dataset][e.key]}))}function Ki(t=!0){if(Zi())Et("body").classed("impossible",!0),Et(".empty-label").html("<i class='fa fa-exclamation-triangle'></i> Oops! It looks like one of the required column selections is empty."),Et(".empty-details").html("Head over to the <span class='data-tab-icon'><i class='fa fa-table'></i> Data</span> tab to choose a suitable column.");else if(Et("body").classed("impossible")){const e=Hi.visualisation?Hi.visualisation:Hi.story;e.status&&e.status.requested_by?Hi.confirm_published.awaitingReview(e.status,e.can_review,Hi.user):Hi.visualisation.embed_url&&t?Hi.confirm_published.edited():(Hi.confirm_published.unpublished(),Et("body").classed("impossible",!1),Et(".empty-label").text(""),Et(".empty-details").text(""))}}var Qi,ta,ea,na,ra,ia,aa,oa,sa,ua=!1;function la(t){if(ua&&window.top!==window.self){var e=window;"srcdoc"===e.location.pathname&&(e=e.parent);var n,r=(n={},window._Flourish_template_id&&(n.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(n.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(n.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(n.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(n.story_id=window.Flourish.app.story.id,n.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(n.slide_index=window.Flourish.app.current_slide.index+1),n),i={sender:"Flourish",method:"customerAnalytics"};for(var a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);for(var a in t)t.hasOwnProperty(a)&&(i[a]=t[a]);e.parent.postMessage(JSON.stringify(i),"*")}}function ca(t){if("function"!=typeof t)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(t)}function da(){ua=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(t){document.body.addEventListener(t.event_name,(function(){la({action:t.action_name})}),t.use_capture)}))}function fa(){if(null==Qi){var t=function(){var t=window.location;"about:srcdoc"==t.href&&(t=window.parent.location);var e={};return function(t,n,r){for(;r=n.exec(t);)e[decodeURIComponent(r[1])]=decodeURIComponent(r[2])}(t.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),e}();Qi="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return Qi}function pa(t){var e=t||window.innerWidth;return e>999?650:e>599?575:400}function ha(t,e){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),ta)return t=parseInt(t,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:t},"*");var r={sender:"Flourish",context:"iframe.resize",method:"resize",height:t,src:n.location.toString()};if(e)for(var i in e)r[i]=e[i];n.parent.postMessage(JSON.stringify(r),"*")}}function ma(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function va(t){return"string"==typeof t||t instanceof String}function ga(t){return"warn"!==t.method?(console.warn("BUG: validateWarnMessage called for method"+t.method),!1):!(null!=t.message&&!va(t.message))&&!(null!=t.explanation&&!va(t.explanation))}function ya(t){return"resize"!==t.method?(console.warn("BUG: validateResizeMessage called for method"+t.method),!1):!!va(t.src)&&(!!va(t.context)&&!!("number"==typeof(e=t.height)?!isNaN(e)&&e>=0:va(e)&&/\d/.test(e)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(e)));var e}function _a(t){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function ba(t){return"customerAnalytics"===t.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+t.method),!1)}function wa(t){return"request-upload"!==t.method?(console.warn("BUG: validateResizeMessage called for method"+t.method),!1):!!va(t.name)&&!(null!=t.accept&&!va(t.accept))}function xa(t,e){var n=function(t){for(var e={warn:ga,resize:ya,setSetting:_a,customerAnalytics:ba,"request-upload":wa},n={},r=0;r<t.length;r++){var i=t[r];if(!e[i])throw new Error("No validator found for method "+i);n[i]=e[i]}return n}(e);window.addEventListener("message",(function(e){if(null!=e.source&&(e.origin===document.location.origin||e.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var r;try{r=JSON.parse(e.data)}catch(t){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(e.data))}if("Flourish"===r.sender)if(r.method)if(Object.prototype.hasOwnProperty.call(n,r.method))if(n[r.method](r)){for(var i=document.querySelectorAll("iframe"),a=0;a<i.length;a++)if(i[a].contentWindow==e.source||i[a].contentWindow==e.source.parent)return void t(r,i[a]);console.warn("could not find frame",r)}else console.warn("Validation failed for the message",r);else console.warn("No validator implemented for message",r);else console.warn("The 'method' property was missing from message",r)}})),ma()&&(window.addEventListener("resize",Aa),Aa())}function Aa(){for(var t=document.querySelectorAll(".flourish-embed"),e=0;e<t.length;e++){var n=t[e];if(!n.getAttribute("data-width")){var r=n.querySelector("iframe");if(r){var i=window.getComputedStyle(n),a=n.offsetWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);r.style.width=a+"px"}}}}function Ea(t,e,n,r,i){var a=document.createElement("iframe");if(a.setAttribute("scrolling","no"),a.setAttribute("frameborder","0"),a.setAttribute("title","Interactive or visual content"),a.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),e.appendChild(a),a.offsetParent||"fixed"===getComputedStyle(a).position)Ta(t,e,a,n,r,i);else{var o={embed_url:t,container:e,iframe:a,width:n,height:r,play_on_load:i};if(window._flourish_poll_items?window._flourish_poll_items.push(o):window._flourish_poll_items=[o],window._flourish_poll_items.length>1)return a;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(t){return!t.iframe.offsetParent||(Ta(t.embed_url,t.container,t.iframe,t.width,t.height,t.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return a}function Ta(t,e,n,r,i,a){var o;return r&&"number"==typeof r?(o=r,r+="px"):r&&r.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(o=parseFloat(r)),i&&"number"==typeof i&&(i+="px"),r?n.style.width=r:ma()?n.style.width=e.offsetWidth+"px":n.style.width="100%",!!i||(t.match(/\?/)?t+="&auto=1":t+="?auto=1",i=pa(o||n.offsetWidth)+"px"),i&&("%"===i.charAt(i.length-1)&&(i=parseFloat(i)/100*e.parentNode.offsetHeight+"px"),n.style.height=i),n.setAttribute("src",t+(a?"#play-on-load":"")),n}function Ca(t,e,n){for(var r in e||(e=[]),n||(n={}),t)e.push(r),"object"==typeof t[r]&&Ca(t[r],e,n),n[e.join(".")]=t[r],e.pop();return n}function ka(t){var e={};for(var n in t){for(var r=e,i=n.indexOf("."),a=0;i>=0;i=n.indexOf(".",a=i+1)){var o=n.substring(a,i);o in r||(r[o]={}),r=r[o]}r[n.substring(a)]=t[n]}return e}function Da(t){if(null==t)return t;var e,n={};for(var r in t)Array.isArray(t[r])?n[r]=t[r].slice():(e=t[r],Array.isArray(e)||"object"!=typeof e||null==e?n[r]=t[r]:n[r]=Da(t[r]));return n}var Fa,Sa=null;function Ma(){return"MessageChannel"in window}var Na=null;function La(){Na&&ea.removeEventListener("load",Na),Na=null}function Oa(t){La(),ea.addEventListener("load",t),Na=t}var Ua=null;function Ra(){Ua&&(cancelAnimationFrame(Ua),Ua=null)}function Ba(t,e){Ra();var n=null,r=function(i){null==n&&(n=i);var a=i-n,o=Math.min(1,Math.max(0,a/t));ea.style.opacity=1-o,1==o?(Ua=null,e()):Ua=requestAnimationFrame(r)};Ua=requestAnimationFrame(r)}function ja(t,e,n){return io(!1),sa=t?t.visualisation?t.visualisation:t.current_slide.visualisation:null,Sa=null,sa&&sa.template_id?(Oa(function(t,e,n){var r=t.visualisation?t.visualisation.template_id:t.current_slide.visualisation.template_id,i=t.current_slide?t.current_slide.id:null;return function(){Dt(),!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||(La(),Va((function(a,o){a?console.error("Failed to get default state"):!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||Wa((function(a,s){if(a)console.error("Failed to call hasData");else if(sa&&sa.template_id==r&&(!t.current_slide||t.current_slide.id===i)){var u=!1;t.visualisation&&(u=t.data_bindings.requiredBindingsAreUnset()),s?sa.refreshDataBindings((function(a){a?console.error("Failed to refresh data bindings"):!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||sa.prepareData((function(a,s){a?console.error("Failed to prepare data for template"):!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||no({data:s,state:e,draw:!u},(function(t,e){Sa=o,n(t,e)}))}))})):no({state:e,draw:!u},(function(t,e){Sa=o,n(t,e)}))}}))})))}}(t,e,n)),ea.src="/template/"+sa.template_id+"/embed/?auto=1&environment="+na+"&is_read_only="+(t.is_read_only?"1":"0"),ea):(La(),ea.src="about:blank",ea)}function Ha(t,e,n,r){var i="about:blank"===ea.src;if(io(!1),e){var a=t[e]||"/template/"+e+"/embed";a+="?environment="+na,r&&(a+="&auto=1"),i?o():Ba(250,o)}else Ba(250,(function(){La(),ea.src="about:blank"}));function o(){Oa(function(t){return function(){Va((function(e,n){e?console.error("Failed to get default state"):(Sa=n,t())}))}}((function(){n(),i||function(t){Ra();var e=null,n=function(r){null==e&&(e=r);var i=r-e,a=Math.min(1,Math.max(0,i/t));ea.style.opacity=a,Ua=1==a?null:requestAnimationFrame(n)};Ua=requestAnimationFrame(n)}(250)}))),ea.src=a}}function Ia(t,e){var n=t.template_id;t.refreshDataBindings((function(r){r?console.error("Failed to fetch data bindings"):t.prepareData((function(t,r){if(sa&&sa.template_id==n)return t?(console.error("Failed to prepare data for template"),void e(t)):void e(void 0,r)}))}))}function za(t,e){Ia(t,(function(t,n){if(t)return e(t);no({data:n,update:!0},e)}))}function Pa(t,e){Ia(t,(function(t,n){if(t)return e(t);no({data:n,update:!1},e)}))}function qa(t,e,n){Ia(t,(function(t,r){if(t)return n(t);no({data:r,state:e,overwrite_state:!0,update:!0},n)}))}function Ya(t,e,n){if(Ma()){var r=new MessageChannel;r.port1.onmessage=function(t){var e=t.data;if("string"==typeof e){if(!n)return;return n(void 0,JSON.parse(e))}if("object"==typeof e){if("result"in e){if(!n)return;return n(void 0,e.result)}if("error"in e){if(!n)return;return n(e.error)}console.error("Unrecognised response to message",e)}else console.error("Unrecognised response to message",e)},ea.contentWindow.postMessage({sender:"Flourish",method:t,argument:e},"*",[r.port2])}}function $a(t,e){Ya("setState",ka(t),e)}function Va(t,e){"function"!=typeof t?Ya("getState",t,e):Ya("getState",void 0,t)}function Wa(t){Ya("hasData",void 0,t)}function Ga(t,e){Ya("setData",t,e)}function Xa(t){Ya("getData",void 0,t)}function Ja(t){Ya("draw",void 0,t),io(!0)}function Za(t){aa&&aa.clear(),ro()&&Ya("update",void 0,t)}function Ka(t,e){Ya("snapshot",t,e)}function Qa(){return Da(Sa)}function to(t,e){Ya("setFixedHeight",t,e)}function eo(t){if(ea.parentNode.offsetWidth){if(void 0!==t)Fa=null!=t;else if(Fa)return;var e=t||ia&&ia.responsive_menu&&ia.responsive_menu.getHeightSetting()||ra.getHeightForBreakpoint(ea.offsetWidth),n=typeof e;("number"===n||"string"===n&&!isNaN(e))&&(e+="px"),ea.style.height=e}}function no(t,e){ro()?delete t.draw:t.draw&&io(!0),t.state&&(t.state=ka(t.state)),aa&&aa.clear(),Ya("sync",t,(function(n,r){null!=n||"success"!==r?(t.draw&&io(!1),function n(r){r?e&&e(r):function(t,e){return t.data?(Ga(t.data,e),delete t.data,!1):t.state?($a(t.state,e),delete t.state,!1):t.draw?(Ja(e),delete t.draw,!1):!t.update||(Za(e),delete t.update,!1)}(t,n)&&e&&e(void 0)}(n)):e&&e(void 0)}))}function ro(){return oa}function io(t){oa=t}function ao(t,e,n,r,i){return ea=document.querySelector(t),na=e,ia=n,aa=r,i||(i={}),ta="#amp=1"==window.location.hash,ra={createEmbedIframe:Ea,isFixedHeight:fa,getHeightForBreakpoint:pa,startEventListeners:xa,notifyParentWindow:ha,isSafari:ma,initCustomerAnalytics:da,addAnalyticsListener:ca,sendCustomerAnalyticsMessage:la},ea.style.height=ra.getHeightForBreakpoint(ea.offsetWidth)+"px",ra.startEventListeners((function(t){"resize"==t.method?eo(t.height):"warn"==t.method?(aa&&aa.warn(t),console.warn("Warning from template:",t.message,t.explanation)):t.method in i&&i[t.method](t)}),["resize","warn","customerAnalytics","setSetting","request-upload"]),Ma()||function(t){if(t){var e=document.createElement("div");e.className="unsupported-notice",e.innerHTML="<h3>Please update your browser</h3><p>This page only works with newer versions of your browser.</p>",t.appendChild(e)}}(ea.parentNode),{loadVisualisation:ja,loadTemplate:Ha,updateData:za,updateDataAndState:qa,updateDataNotPreview:Pa,setState:$a,getState:Va,getDefaultState:Qa,hasData:Wa,setData:Ga,getData:Xa,draw:Ja,update:Za,snapshot:Ka,setFixedHeight:to,resize:eo,sync:no,getDrawCalled:ro,setDrawCalled:io}}var oo=function(t=document.body){t.classList.add("loading")},so=function(t=document.body){t.classList.remove("loading")},uo="/api/file/upload";function lo(t){(t||document).querySelectorAll("input[type=url]").forEach((function(t){co(t)}))}function co(t,e){var n=t.ownerDocument.createElement("button");n.type="button",n.className="upload",n.setAttribute("title","Upload a file from your computer"),n.innerHTML="⬆︎",t.insertAdjacentElement("afterend",n),e||(n.onclick=fo)}function fo(){var t=this.previousSibling,e=t.getAttribute("accept");t.disabled=!0,t.classList.toggle("uploading",!0),po({accept:e,success:function(e){var n;t.disabled=!1,t.classList.toggle("uploading",!1),t.value=e,"createEvent"in document?(n=document.createEvent("Event")).initEvent("change",!0,!0):n=new Event("change",{bubbles:!0}),t.dispatchEvent(n)},failure:function(){t.disabled=!1,t.classList.toggle("uploading",!1)}})}function po(t){var e=document.getElementById("file-uploader");e||((e=document.createElement("input")).type="file",e.setAttribute("id","file-uploader"),e.style.display="none",document.body.appendChild(e)),t.accept?e.setAttribute("accept",t.accept):e.removeAttribute("accept"),e.onchange=function(){var n,r,i,a;oo(),n=e.files,r=t.success,i=t.failure,function(t,e){var n={filename:t.name,content_type:t.type,size:t.size};ho(uo,n,(function(t,n){return t?e(t):e(null,JSON.parse(n.responseText))}))}(a=n[0],(function(t,e){if(t)return so(),Ui("Upload error","There was a problem uploading your file: "+t),void console.error(t);var n=function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}({file:a},e.fields);ho(e.upload_url,n,(function(t,n){so(),t?(Ui("Upload error","There was a problem uploading your file ("+n.status+")."),console.error(t),i&&i()):r(e.file_url)}))})),e.parentNode.removeChild(e)},e.click()}function ho(t,e,n){var r=new XMLHttpRequest,i=new FormData;if("object"==typeof e){for(var a in e)e.hasOwnProperty(a)&&"file"!==a&&i.append(a,e[a]);e.hasOwnProperty("file")&&i.append("file",e.file)}window.Flourish.csrf_token&&i.append("csrf_token",window.Flourish.csrf_token),r.onload=function(){if(r.status>=200&&r.status<300)n(null,r);else try{var e=JSON.parse(r.responseText).error;n(e,r)}catch(e){n(new Error("POST "+t+" received status code: "+r.status),r)}},r.open("POST",t,!0),r.send(i)}var mo="https://fonts.googleapis.com/css?family=",vo=["Source Sans Pro","Roboto Condensed","Merriweather","Lora","Playfair Display","Coda","Lobster","Cabin Sketch"],go="Same as parent",yo=[],_o=[],bo={};function wo(t){return mo+t.replace(/ /g,"+")+":400,700"}function xo(t){var e=_o.concat(yo,vo.map((function(t){return{name:t,url:wo(t)}})));return t&&e.unshift({name:go}),e}function Ao(t){return xo(!0).find((function(e){return e.name==t}))}var Eo=!1;function To(t){return t.substr(t.lastIndexOf("=")+1).replace(/\+/g," ")}function Co(t){var e=t.target,n=e.value;if(n&&(0==n.indexOf(mo)&&(n=e.value=To(n)),!Ao(n))){if(/^https?:\/\//.test(n)){Eo||(ko(n),e.value="");var r=n;return n=e.value=To(r),_o.push({name:n,url:r}),void Do()}var i=wo(n);try{var a=new XMLHttpRequest;if(a.open("HEAD",i,!1),a.send(),404==a.status)throw"Font not found";_o.push({name:n,url:i}),Do()}catch(t){ko(n),e.value=""}}}function ko(t){Ui("Unrecognised font “"+t+"”","Fonts must be chosen from Google Fonts. Visit <a href='https://fonts.google.com'>fonts.google.com</a> to find more",{is_html:!0})}function Do(){var t,e,n=Object.keys(bo);for(t=0;t<n.length;++t)(e=bo[n[t]]).autocomplete.options(xo(e.can_inherit).map((function(t){return t.name})))}var Fo={initialize:function(t,e,n){var r=!!e.optional;Eo=n,t.classList.add("font-menu"),bo[e.property]={autocomplete:Bi(t,e.property+"-dropdown",xo(r).map((function(t){return t.name})),{allow_other_option:!0}),can_inherit:r},t.addEventListener("change",Co)},update:function(t,e){var n=e?e.name:go;t.value=n,Ao(n)||(n!=go&&_o.push({name:n,url:e.url}),Do())},getValue:function(t){if(/^https?:\/\//.test(t.value))return{name:To(t.value),url:t.value};var e=t.value;if(e==go)return null;var n=Ao(e);return n||{name:e,url:wo(e)}},replaceThemeFonts:function(t){yo=(t||[]).map((function(t){return{name:t.name,url:t.url}})),Do()}},So="$";function Mo(){}function No(t,e){var n=new Mo;if(t instanceof Mo)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,a=t.length;if(null==e)for(;++i<a;)n.set(i,t[i]);else for(;++i<a;)n.set(e(r=t[i],i,t),r)}else if(t)for(var o in t)n.set(o,t[o]);return n}function Lo(){}Mo.prototype=No.prototype={constructor:Mo,has:function(t){return So+t in this},get:function(t){return this[So+t]},set:function(t,e){return this[So+t]=e,this},remove:function(t){var e=So+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===So&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===So&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===So&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===So&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===So&&++t;return t},empty:function(){for(var t in this)if(t[0]===So)return!1;return!0},each:function(t){for(var e in this)e[0]===So&&t(this[e],e.slice(1),this)}};var Oo=No.prototype;Lo.prototype={constructor:Lo,has:Oo.has,add:function(t){return this[So+(t+="")]=t,this},remove:Oo.remove,clear:Oo.clear,values:Oo.keys,size:Oo.size,empty:Oo.empty,each:Oo.each};var Uo={value:function(){}};function Ro(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Bo(r)}function Bo(t){this._=t}function jo(t,e){return t.trim().split(/^|\s+/).map((function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function Ho(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Io(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Uo,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function zo(t,e,n,r,i){for(var a in t.getVersionNumber=function(){return t.version_number},t.setVersionNumber=function(e){t.version_number=e},t.id=e,t.version_number=n||0,r)t[a]=r[a];if(i)for(var a in i)t[a]=i[a]}Bo.prototype=Ro.prototype={constructor:Bo,on:function(t,e){var n,r=this._,i=jo(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=Io(r[n],t.name,e);else if(null==e)for(n in r)r[n]=Io(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=Ho(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Bo(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var Po={};function qo(t){t.running||(t.running=!0,Yo(t,(function(){t.running=!1})))}function Yo(t,e){t.request=function(t,e){var n="method"in t?t.method:"POST",r="request_type"in t?t.request_type:"application/json",i="response_type"in t?t.response_type:"application/json",a=t.url,o=t.payload,s=t.callback;!o&&$o(n)&&(o=function(){return{}});if(o){if("function"!=typeof o)throw new Error("Internal error: processRequestThen: payload must be a function, not "+typeof o,o);"object"==typeof(o=o())&&$o(n)&&(window.Flourish&&window.Flourish.csrf_token||console.trace("window.Flourish.csrf_token missing"),o.csrf_token=window.Flourish.csrf_token),"string"!=typeof o&&(o=JSON.stringify(o))}var u=function(t,e){var n,r,i,a,o=Ro("beforesend","progress","load","error"),s=No(),u=new XMLHttpRequest,l=null,c=null,d=0;function f(t){var e,r=u.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(u)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,u)}catch(t){return void o.call("error",n,t)}else e=u;o.call("load",n,e)}else o.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in u)&&/^(http(s)?:)?\/\//.test(t)&&(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=u.ontimeout=f:u.onreadystatechange=function(t){u.readyState>3&&f(t)},u.onprogress=function(t){o.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(a=t,n):a},timeout:function(t){return arguments.length?(d=+t,n):d},user:function(t){return arguments.length<1?l:(l=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,f){return u.open(e,t,!0,l,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),u.setRequestHeader&&s.each((function(t,e){u.setRequestHeader(e,t)})),null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=a&&(u.responseType=a),d>0&&(u.timeout=d),null==f&&"function"==typeof i&&(f=i,i=null),null!=f&&1===f.length&&(f=function(t){return function(e,n){t(null==e?n:null)}}(f)),null!=f&&n.on("error",f).on("load",(function(t){f(null,t)})),o.call("beforesend",n,u),u.send(null==i?null:i),n},abort:function(){return u.abort(),n},on:function(){var t=o.on.apply(o,arguments);return t===o?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}return n}(a);r&&"GET"!==n&&u.header("Content-Type",r);i&&u.mimeType(i);return u.on("error",(function(t){var n;try{n=JSON.parse(t.target.responseText),s(n.error)}catch(e){s("Internal error: "+t.target.responseText)}e()})),u.on("load",(function(t){var n=t.responseText;"application/json"===i&&(n=JSON.parse(n));try{s(void 0,n)}catch(t){console.error(t.stack)}e()})),u.send(n,o),u}(t.items.shift(),(function(){t.request=null,0==t.items.length?e():Yo(t,e)}))}function $o(t){return["POST","PUT","DELETE"].includes(t)}function Vo(t,e){void 0===e&&(e="default"),e in Po||(Po[e]={items:[],running:!1,name:e}),Po[e].items.push(t),qo(Po[e])}function Wo(t,e){for(var n in e)t[n]=e[n];return t}function Go(t,e,n,r){"function"==typeof n&&(r=n,n=!1),n&&Wo(t,e),Vo({url:t.api_prefix+"/"+t.id,payload:function(){return{version_number:t.getVersionNumber(),fields:e}},callback:function(i,a){if(i)return r(i);n||Wo(t,e),t.setVersionNumber(a.version_number),r(void 0)}})}function Xo(t,e){t.delete_requested=!0,Vo({url:t.api_prefix+"/"+t.id,method:"DELETE",payload:function(){return{version_number:t.getVersionNumber()}},callback:function(n,r){if(n)return e(n);t.setVersionNumber(r.version_number),t.is_deleted=!0,e(void 0,r)}})}var Jo={update:function(t,e){Vo({url:"/api/user",method:"POST",payload:function(){return{fields:t}},callback:e})},isUsernameAvailable:function(t,e){Vo({url:"/api/user/username?u="+encodeURIComponent(t),method:"GET",callback:e})},getReviewCount:function(t){Vo({url:"/api/reviews/count",method:"GET",callback:t})},logHistory:function(t){Vo({url:"/api/history",method:"POST",payload:function(){return t},callback:function(){}})},addApiKey:function(t){Vo({url:"/api/user/api_keys",method:"PUT",callback:t})},getApiKeys:function(t){Vo({url:"/api/user/api_keys",method:"GET",callback:t})},deleteApiKey:function(t,e){Vo({url:"/api/user/api_keys/"+t,method:"DELETE",callback:e})},fetchProjects:function(t,e,n,r,i,a,o,s){var u="";e&&(u+="&folder="+encodeURIComponent(e)),n&&(u+="&sort="+encodeURIComponent(n)),r&&(u+="&filter="+encodeURIComponent(r)),i&&(u+="&offset="+encodeURIComponent(i)),a&&(u+="&limit="+encodeURIComponent(a)),o&&(u+="&search="+encodeURIComponent(o)),s&&(u+="&is_recent=true"),Vo({url:"/api/user/projects?"+u,method:"GET",callback:t})},addTag:function(t,e){Vo({url:"/api/user/tag/"+encodeURIComponent(t),method:"PUT",callback:e})},renameTag:function(t,e,n){Vo({url:"/api/user/tag/"+encodeURIComponent(t)+"/"+encodeURIComponent(e),method:"PUT",callback:n})},removeTag:function(t,e){Vo({url:"/api/user/tag/"+encodeURIComponent(t),method:"DELETE",callback:e})},fetchFolders:function(t){Vo({url:"/api/user/folders",method:"GET",callback:t})},setSamlProviderId:function(t,e,n){Vo({url:"/api/user/"+encodeURIComponent(t)+"/change_saml_provider_id",method:"POST",payload:function(){return{saml_provider_id:e}},callback:n})}};function Zo(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Ko(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Qo(){}var ts=.7,es=1/ts,ns="\\s*([+-]?\\d+)\\s*",rs="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",is="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",as=/^#([0-9a-f]{3,8})$/,os=new RegExp("^rgb\\("+[ns,ns,ns]+"\\)$"),ss=new RegExp("^rgb\\("+[is,is,is]+"\\)$"),us=new RegExp("^rgba\\("+[ns,ns,ns,rs]+"\\)$"),ls=new RegExp("^rgba\\("+[is,is,is,rs]+"\\)$"),cs=new RegExp("^hsl\\("+[rs,is,is]+"\\)$"),ds=new RegExp("^hsla\\("+[rs,is,is,rs]+"\\)$"),fs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function ps(){return this.rgb().formatHex()}function hs(){return this.rgb().formatRgb()}function ms(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=as.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?vs(e):3===n?new bs(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?gs(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?gs(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=os.exec(t))?new bs(e[1],e[2],e[3],1):(e=ss.exec(t))?new bs(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=us.exec(t))?gs(e[1],e[2],e[3],e[4]):(e=ls.exec(t))?gs(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=cs.exec(t))?Es(e[1],e[2]/100,e[3]/100,1):(e=ds.exec(t))?Es(e[1],e[2]/100,e[3]/100,e[4]):fs.hasOwnProperty(t)?vs(fs[t]):"transparent"===t?new bs(NaN,NaN,NaN,0):null}function vs(t){return new bs(t>>16&255,t>>8&255,255&t,1)}function gs(t,e,n,r){return r<=0&&(t=e=n=NaN),new bs(t,e,n,r)}function ys(t){return t instanceof Qo||(t=ms(t)),t?new bs((t=t.rgb()).r,t.g,t.b,t.opacity):new bs}function _s(t,e,n,r){return 1===arguments.length?ys(t):new bs(t,e,n,null==r?1:r)}function bs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ws(){return"#"+As(this.r)+As(this.g)+As(this.b)}function xs(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function As(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Es(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Cs(t,e,n,r)}function Ts(t){if(t instanceof Cs)return new Cs(t.h,t.s,t.l,t.opacity);if(t instanceof Qo||(t=ms(t)),!t)return new Cs;if(t instanceof Cs)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,u=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=u<.5?a+i:2-a-i,o*=60):s=u>0&&u<1?0:o,new Cs(o,s,u,t.opacity)}function Cs(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function ks(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function Ds(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}Zo(Qo,ms,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:ps,formatHex:ps,formatHsl:function(){return Ts(this).formatHsl()},formatRgb:hs,toString:hs}),Zo(bs,_s,Ko(Qo,{brighter:function(t){return t=null==t?es:Math.pow(es,t),new bs(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?ts:Math.pow(ts,t),new bs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ws,formatHex:ws,formatRgb:xs,toString:xs})),Zo(Cs,(function(t,e,n,r){return 1===arguments.length?Ts(t):new Cs(t,e,n,null==r?1:r)}),Ko(Qo,{brighter:function(t){return t=null==t?es:Math.pow(es,t),new Cs(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?ts:Math.pow(ts,t),new Cs(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new bs(ks(t>=240?t-240:t+120,i,r),ks(t,i,r),ks(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Fs=Ds("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Ss=Ds("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Ms=Ds("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Ns=Ds("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2");function Ls(t){return function(){return t}}function Os(t){return 1==(t=+t)?Us:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Ls(isNaN(e)?n:e)}}function Us(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Ls(isNaN(t)?e:t)}var Rs=function t(e){var n=Os(e);function r(t,e){var r=n((t=_s(t)).r,(e=_s(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=Us(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function Bs(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var js=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hs=new RegExp(js.source,"g");function Is(t,e){var n,r,i,a=js.lastIndex=Hs.lastIndex=0,o=-1,s=[],u=[];for(t+="",e+="";(n=js.exec(t))&&(r=Hs.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,u.push({i:o,x:Bs(n,r)})),a=Hs.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)s[(n=u[r]).i]=n.x(t);return s.join("")})}var zs,Ps,qs,Ys,$s=180/Math.PI,Vs={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ws(t,e,n,r,i,a){var o,s,u;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*$s,skewX:Math.atan(u)*$s,scaleX:o,scaleY:s}}function Gs(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],u=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var u=o.push("translate(",null,e,null,n);s.push({i:u-4,x:Bs(t,i)},{i:u-2,x:Bs(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,s,u),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Bs(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,s,u),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Bs(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,s,u),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:Bs(t,n)},{i:s-2,x:Bs(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,u),a=o=null,function(t){for(var e,n=-1,r=u.length;++n<r;)s[(e=u[n]).i]=e.x(t);return s.join("")}}}var Xs,Js,Zs=Gs((function(t){return"none"===t?Vs:(zs||(zs=document.createElement("DIV"),Ps=document.documentElement,qs=document.defaultView),zs.style.transform=t,t=qs.getComputedStyle(Ps.appendChild(zs),null).getPropertyValue("transform"),Ps.removeChild(zs),Ws(+(t=t.slice(7,-1).split(","))[0],+t[1],+t[2],+t[3],+t[4],+t[5]))}),"px, ","px)","deg)"),Ks=Gs((function(t){return null==t?Vs:(Ys||(Ys=document.createElementNS("http://www.w3.org/2000/svg","g")),Ys.setAttribute("transform",t),(t=Ys.transform.baseVal.consolidate())?Ws((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Vs)}),", ",")",")"),Qs=0,tu=0,eu=0,nu=0,ru=0,iu=0,au="object"==typeof performance&&performance.now?performance:Date,ou="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function su(){return ru||(ou(uu),ru=au.now()+iu)}function uu(){ru=0}function lu(){this._call=this._time=this._next=null}function cu(t,e,n){var r=new lu;return r.restart(t,e,n),r}function du(){ru=(nu=au.now())+iu,Qs=tu=0;try{!function(){su(),++Qs;for(var t,e=Xs;e;)(t=ru-e._time)>=0&&e._call.call(null,t),e=e._next;--Qs}()}finally{Qs=0,function(){var t,e,n=Xs,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Xs=e);Js=t,pu(r)}(),ru=0}}function fu(){var t=au.now(),e=t-nu;e>1e3&&(iu-=e,nu=t)}function pu(t){Qs||(tu&&(tu=clearTimeout(tu)),t-ru>24?(t<1/0&&(tu=setTimeout(du,t-au.now()-iu)),eu&&(eu=clearInterval(eu))):(eu||(nu=au.now(),eu=setInterval(fu,1e3)),Qs=1,ou(du)))}function hu(t,e,n){var r=new lu;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}lu.prototype=cu.prototype={constructor:lu,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?su():+n)+(null==e?0:+e),this._next||Js===this||(Js?Js._next=this:Xs=this,Js=this),this._call=t,this._time=n,pu()},stop:function(){this._call&&(this._call=null,this._time=1/0,pu())}};var mu=Ro("start","end","cancel","interrupt"),vu=[];function gu(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var l,c,d,f;if(1!==n.state)return u();for(l in i)if((f=i[l]).name===n.name){if(3===f.state)return hu(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[l])}if(hu((function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))})),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(d=n.tween.length),l=0,c=-1;l<d;++l)(f=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=cu(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:mu,tween:vu,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function yu(t,e){var n=bu(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function _u(t,e){var n=bu(t,e);if(n.state>3)throw new Error("too late; already running");return n}function bu(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function wu(t,e){var n,r;return function(){var i=_u(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function xu(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=_u(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===e){i[u]=s;break}u===l&&i.push(s)}a.tween=i}}function Au(t,e,n){var r=t._id;return t.each((function(){var t=_u(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return bu(t,r).value[e]}}function Eu(t,e){var n;return("number"==typeof e?Bs:e instanceof ms?Rs:(n=ms(e))?(e=n,Rs):Is)(t,e)}function Tu(t){return function(){this.removeAttribute(t)}}function Cu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ku(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Du(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function Fu(t,e,n){var r,i,a;return function(){var o,s,u=n(this);if(null!=u)return(o=this.getAttribute(t))===(s=u+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,u));this.removeAttribute(t)}}function Su(t,e,n){var r,i,a;return function(){var o,s,u=n(this);if(null!=u)return(o=this.getAttributeNS(t.space,t.local))===(s=u+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,u));this.removeAttributeNS(t.space,t.local)}}function Mu(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Nu(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Lu(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Nu(t,i)),n}return i._value=e,i}function Ou(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Mu(t,i)),n}return i._value=e,i}function Uu(t,e){return function(){yu(this,t).delay=+e.apply(this,arguments)}}function Ru(t,e){return e=+e,function(){yu(this,t).delay=e}}function Bu(t,e){return function(){_u(this,t).duration=+e.apply(this,arguments)}}function ju(t,e){return e=+e,function(){_u(this,t).duration=e}}function Hu(t,e){if("function"!=typeof e)throw new Error;return function(){_u(this,t).ease=e}}function Iu(t,e,n){var r,i,a=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?yu:_u;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}var zu=At.prototype.constructor;function Pu(t){return function(){this.style.removeProperty(t)}}function qu(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Yu(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&qu(t,a,n)),r}return a._value=e,a}function $u(t){return function(e){this.textContent=t.call(this,e)}}function Vu(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&$u(r)),e}return r._value=t,r}var Wu=0;function Gu(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Xu(){return++Wu}var Ju=At.prototype;Gu.prototype={constructor:Gu,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=p(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,u,l=r[o],c=l.length,d=a[o]=new Array(c),f=0;f<c;++f)(s=l[f])&&(u=t.call(s,s.__data__,f,l))&&("__data__"in s&&(u.__data__=s.__data__),d[f]=u,gu(d[f],e,n,f,d,bu(s,n)));return new Gu(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=v(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var u,l=r[s],c=l.length,d=0;d<c;++d)if(u=l[d]){for(var f,p=t.call(u,u.__data__,d,l),h=bu(u,n),m=0,g=p.length;m<g;++m)(f=p[m])&&gu(f,e,n,m,p,h);a.push(p),o.push(u)}return new Gu(a,o,e,n)},filter:function(t){"function"!=typeof t&&(t=g(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,u=r[i]=[],l=0;l<s;++l)(a=o[l])&&t.call(a,a.__data__,l,o)&&u.push(a);return new Gu(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var u,l=e[s],c=n[s],d=l.length,f=o[s]=new Array(d),p=0;p<d;++p)(u=l[p]||c[p])&&(f[p]=u);for(;s<r;++s)o[s]=e[s];return new Gu(o,this._parents,this._name,this._id)},selection:function(){return new zu(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Xu(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],u=s.length,l=0;l<u;++l)if(o=s[l]){var c=bu(o,e);gu(o,t,n,l,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Gu(r,this._parents,t,n)},call:Ju.call,nodes:Ju.nodes,node:Ju.node,size:Ju.size,empty:Ju.empty,each:Ju.each,on:function(t,e){var n=this._id;return arguments.length<2?bu(this.node(),n).on.on(t):this.each(Iu(n,t,e))},attr:function(t,e){var n=u(t),r="transform"===n?Ks:Eu;return this.attrTween(t,"function"==typeof e?(n.local?Su:Fu)(n,r,Au(this,"attr."+t,e)):null==e?(n.local?Cu:Tu)(n):(n.local?Du:ku)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=u(t);return this.tween(n,(r.local?Lu:Ou)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Zs:Eu;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=I(this,t),o=(this.style.removeProperty(t),I(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,Pu(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=I(this,t),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=I(this,t)),o===u?null:o===r&&u===i?a:(i=u,a=e(r=o,s))}}(t,r,Au(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var u=_u(this,t),l=u.on,c=null==u.value[o]?a||(a=Pu(e)):void 0;l===n&&i===c||(r=(n=l).copy()).on(s,i=c),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=I(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,Yu(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Au(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,Vu(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=bu(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?wu:xu)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Uu:Ru)(e,t)):bu(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Bu:ju)(e,t)):bu(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(Hu(e,t)):bu(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;_u(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise((function(a,o){var s={value:o},u={value:function(){0==--i&&a()}};n.each((function(){var n=_u(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),n.on=e})),0===i&&a()}))},[Symbol.iterator]:Ju[Symbol.iterator]};var Zu,Ku,Qu={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function tl(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function el(t){var e;if(Zu=Et(".detailed-settings"),(Ku=Zu.append("div").attr("class","settings-block")).append("h2").text("Back to settings").on("click",(function(){Zu.transition().duration(100).style("opacity",0).on("end",(function(){Et(this).html("").style("display","none"),Et(".template-settings").style("display","block").style("opacity",0).transition().duration(500).style("opacity",1)})),Zu.node()})),"string"==typeof t)e=Ku.append("div").html(t);else if("object"==typeof t&&(e=Ku.append(t.type),t.value&&(Ku.node().value=t.value),t.attributes))for(var n in t.attributes)e.attr(n,t.attributes[n]);return e.node().focus(),Et(".template-settings").style("display","none"),Zu.style("display","block").style("opacity",0).transition().duration(500).style("opacity",1),Zu.node()}At.prototype.interrupt=function(t){return this.each((function(){!function(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}(this,t)}))},At.prototype.transition=function(t){var e,n;t instanceof Gu?(e=t._id,t=t._name):(e=Xu(),(n=Qu).time=su(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],u=s.length,l=0;l<u;++l)(o=s[l])&&gu(o,t,e,l,s,n||tl(o,e));return new Gu(r,this._parents,t,e)};var nl,rl,il,al,ol={},sl={},ul={"Flourish 1":{scheme:"flourish_default_1",colors:["#1D6996","#EDAD08","#73AF48","#94346E","#38A6A5","#E17C05","#5F4690","#0F8554","#6F4070","#CC503E","#994E95","#666666"]},"Flourish 2":{scheme:"flourish_default_2",colors:["#11A579","#CC503E","#3969AC","#F2B701","#7F3C8D","#80BA5A","#E68310","#CF1C90","#008695","#F97B72","#4B4B8F","#A5AA99"]},Rainbow:{colors:["#5F4690","#1D6996","#38A6A5","#0F8554","#73AF48","#EDAD08","#E17C05","#CC503E","#94346E","#6F4070","#994E95","#666666"]},Pastel:{colors:["#66C5CC","#F6CF71","#F89C74","#DCB0F2","#87C55F","#9EB9F3","#FE88B1","#C9DB74","#8BE0A4","#B497E7","#D3B484","#B3B3B3"]},Antique:{colors:["#855C75","#D9AF6B","#AF6458","#736F4C","#526A83","#625377","#68855C","#9C9C5E","#A06177","#8C785D","#467378","#7C7C7C"]},Accent:{scheme:"schemeAccent",colors:Fs},Dark:{scheme:"schemeDark2",colors:Ss},Paired:{scheme:"schemePaired",colors:Ms},Pale:{scheme:"schemePastel1",colors:Ns},"Farrow & Ball":{colors:["#EDD8C4","#C4A999","#F9C1C0","#B76A4C","#8F483C","#783027","#8A1D2E","#602A1F","#893838","#BD795A","#DC6130","#AD3B34","#ECE8BD","#F7E28A","#EBEB82","#FAD862","#F1CA61","#F5C03B","#F9E7D4","#F4E4AC","#EFD491","#DAC589","#D2B15E","#CD9344","#EFEFCC","#E8E7CA","#CAD5AD","#B9B495","#73806F","#636F65","#BDAB65","#889A73","#829C7A","#6C7855","#81B693","#BBBEA0","#99A286","#AAC0B3","#427E7F","#769194","#ECF3EC","#EBEBD4","#D0D9C9","#9EAF9F","#7A8E8D","#516365","#DBE5DC","#C4C9C5","#CBD7D7","#AABEBF","#66839A","#A0D2CD","#56AAC5","#535E7D","#2E3548","#48606E","#2C3437"]}},ll={};function cl(){var t,e={};for(t in ll)e[t]=ll[t];for(t in ul)e[t]=ul[t];return e}var dl="Edit color palette";function fl(t){t&&t.length?(ll={},t.forEach((function(t){var e=Object.keys(t)[0];ll[e]={colors:t[e]}}))):ll={},function(){for(var t in ol){ol[t].options(hl())}}()}function pl(){if(void 0!==nl)return nl;var t=document.createElement("input");return t.setAttribute("type","color"),t.setAttribute("value","!"),nl="color"==t.type&&"!"!==t.value}function hl(){var t=[],e=cl();for(var n in t.push([dl,""]),e)t.push([n,e[n].colors.join("|")]);return t}function ml(t,e){var n=t[0],r=t[1];if(!r){const t=Tt("em");return t.append("i").classed("fa fa-pencil",!0),t.node().append(dl),t.node()}Array.isArray(r)||(r=r.split("|"));const i=[];if(e&&n){const t=Tt("label").text(n);i.push(t.node())}return r.forEach((function(t,e){const n=Tt("span").attr("data-index",e).style("background-color",t);i.push(n.node())})),i}function vl(t,e){var n,r,i=cl(),a=t.parentNode.querySelector(".color-swatches");if(Array.isArray(e))r=e;else if("string"==typeof e){if(i[e])n=e;else for(var o in i)if(i[o].scheme==e){n=o;break}n&&(r=i[n].colors)}if(!r||!r.length)return t.parentNode.classList.remove("custom"),t.removeAttribute("data-value"),t.value="",void(a.innerHTML="");a.innerHTML="",a.append(...ml([null,r])),t.setAttribute("data-value",r.join("|"))}function gl(t){al=t.target,t.dataTransfer.setData("text/plain","x"),event.dataTransfer.effectAllowed="move",Et(al).classed("dragging",!0),Ct(".palette p:not(.dragging) input").style("pointer-events","none")}function yl(t){t.preventDefault();var e=Et(".palette").selectAll("[draggable='true']").style("border-color",null),n=Et(t.target);if("true"===n.attr("draggable")){var r="bottom";if(n.node()===e.nodes()[0]){var i=t.target.getBoundingClientRect(),a=i.top+i.height/2;t.clientY<a&&(r="top")}Et(t.target).style("border-"+r,"1px solid black")}}function _l(t){if(al){for(var e=t.target;e&&("P"!==e.tagName||!e.nextSibling);)e=e.parentNode;if(e){var n=e.nextSibling;if(e===Et(".palette").selectAll("[draggable='true']").style("border-color",null).nodes()[0]){var r=e.getBoundingClientRect(),i=r.top+r.height/2;t.clientY<i&&(n=e)}e.parentNode.insertBefore(al,n),al=!1,xl()}}}function bl(){Et(al).classed("dragging",!1),Ct(".palette *").style("border-bottom",null).style("border-top",null),Ct(".palette p input").style("pointer-events",null)}function wl(t){for(var e=t.target;e&&"BUTTON"!==e.tagName;)e=e.parentNode;e&&(e.classList.contains("fa-plus-square")?function(t){var e=t.target.parentNode,n=Al("#000000");e.insertAdjacentHTML("beforebegin",n),xl()}(t):e.classList.contains("fa-times")&&function(t){t.parentNode.childNodes.length>2?t.parentNode.removeChild(t):("INPUT"==t.firstChild.tagName?t.firstChild.value="#000000":t.firstChild.style.backgroundColor="#000000",t.firstChild.nextSibling.value="#000000");xl()}(e.parentNode))}function xl(){for(var t=il.getAttribute("data-autocomplete"),e=ol[t],n=[],r=rl.querySelectorAll(".palette input[type=text]"),i=0;i<r.length;i++)n.push(r[i].value);var a=e.options();sl[t]?a[0][1]=n.join("|"):a.unshift(["Custom",n.join("|")]),sl[t]=n,e.options(a),vl(il,n),Et(il).dispatch("change")}function Al(t){const e=Tt("p").attr("draggable",!0);return e.append("span").classed("swatch-handle",!0).text(".. .. .."),pl()?e.append("input").attr("type","color").attr("value",t):e.append("span").classed("swatch-color",!0).style("background-color",t),e.append("input").attr("type","text").attr("value",t),e.append("button").attr("type","button").classed("fa fa-times",!0),e.node().outerHTML}function El(t){var e=t.target,n=e.value,r=e.parentNode;if(!n)return r.parentNode.removeChild(r),void xl();var i=ms(n);if(!i)return console.warn("bad color",n),"color"==e.type?e.value=e.nextSibling.value:pl()?e.value=e.previousSibling.value:e.value=e.previousSibling.style.backgroundColor,void(je.point(e).text(n+" is not a valid color").draw()._getElement().style.zIndex=115);"color"==e.type?e.nextSibling.value=n:pl()?e.previousSibling.value=i.hex():e.previousSibling.style.backgroundColor=n,xl()}var Tl,Cl,kl,Dl={initialize:function(t,e){e.choices&&fl(e.choices),t.type="text",t.classList.add("colors");var n=document.createElement("span");n.setAttribute("class","color-swatches"),t.parentNode.insertBefore(n,t);var r=t.getAttribute("name")+"-dropdown";ol[r]=Bi(t,r,hl(),{custom_renderer:ml}),t.addEventListener("change",(function(e){t.value==dl?(e.stopImmediatePropagation(),t.value="",function(t){il=t;var e=(rl=el({type:"div",attributes:{class:"palette"}})).querySelector(".palette"),n=function(t,e){e||(e=t.parentNode.querySelector(".color-swatches"));for(var n=[],r=0;r<e.childNodes.length;r++)if(!e.childNodes[r].classList.contains("fa")){var i=e.childNodes[r].style.backgroundColor,a=ms(i);a?n.push(a.hex()):(console.warn("Bad color",i),n.push("#000000"))}return n}(t),r="";n.forEach((function(t){r+=Al(t)})),r+="<p><button class='fa fa-plus-square clickable'></button></p>",e.innerHTML=r,e.addEventListener("change",El),e.addEventListener("dragstart",gl),e.addEventListener("dragover",yl),e.addEventListener("drop",_l),e.addEventListener("dragend",bl),e.addEventListener("click",wl)}(t)):vl(t,(t.getAttribute("data-value")||"").split("|"))}))},update:vl,getValue:function(t){var e=t.getAttribute("data-value");return e?e.split("|"):null},replaceThemeColors:fl},Fl=void 0,Sl=/fa-(\S*)/g,Ml=/^data:image\/(svg|svg\+xml|png|jpg);base64,[A-Z-a-z0-9+/=]*$/;function Nl(t){Et(t.parentNode).classed("open",(function(){return!Et(this).classed("open")}))}function Ll(t){if(t){Fl={};for(var e=0,n=null,r=null,i=Tl&&Tl.user?Tl.user.template_settings_overrides:{},a=0;a<t.length;a++){var o=t[a];if("string"!=typeof o){if("object"!=typeof o||n||r||(e++,r=kl.append("div").attr("class","toplevel-settings-block")),"hidden"!==o.type){var s=n||r;if(o.new_section&&(s.append("div").classed("settings-divider",!0),"string"==typeof o.new_section&&s.append("h3").classed("settings-subhead",!0).text(o.new_section)),void 0!==o.show_if){if(o.show_condition)throw new Error("BUG: show_if present as well as show_condition");o.show_condition=[{type:"show",condition:o.show_if}],delete o.show_if}else if(void 0!==o.hide_if){if(o.show_condition)throw new Error("BUG: hide_if present as well as show_condition");o.show_condition=[{type:"hide",condition:o.hide_if}],delete o.hide_if}Fl[o.property]=o.type,Ol(s.append("div"),o,i)}}else r=null,(n=kl.append("div").attr("class","settings-block")).append("h2").attr("class","no-select").attr("tabindex","0").text(o).on("click",(function(){Nl(this)})).on("keyup",(function(t){13===t.keyCode&&Nl(this)})),n.classed("open",e<1),"State documentation"===o&&n.style("display","none"),e++}Ct(".upgrade-setting").on("click",(function(){!function(t,e,n,r,i){var a=[],o=[];i?(a.push(["Upgrade to a business account so you can:"]),o.push(["Add custom logos, colours and styles to keep projects on-brand","Remove Flourish logo","Manage your team with collaboration and approval features","And <a href='https://flourish.studio/pricing' target='_blank'>many other benefits</a>"])):(a.push(["Upgrade your account to:"]),o.push(["Keep your data and projects private","Download projects","Get priority support"]));var s=Math.floor(Math.random()*a.length),u=Math.floor(Math.random()*o.length),l="title"+s+"-list"+u,c="upgrade-click",d=[];i?d.push({text:"Email us",class:"convert",tag_name:"a",href:"mailto:sales@flourish.studio?subject=Business%20upgrade%20enquiry",keyCode:13,callback:function(){t.analytics("send","event",c,r,l),Jo.logHistory({category:"upgrade",action:"clicked",detail:r})}}):d.push({text:"Upgrade now",class:"convert",keyCode:13,callback:function(){t.analytics("send","event",c,r,l),Jo.logHistory({category:"upgrade",action:"clicked",detail:r}),setTimeout((function(){window.location.href="/choose-subscription"}),1e3)}}),d.push({text:"Maybe later",keyCode:27,class:"secondary",callback:function(){t.analytics("send","event","upgrade-close",r,l),Jo.logHistory({category:"upgrade",action:"closed",detail:r})}}),t.analytics("send","event","upgrade-open",r,l),Jo.logHistory({category:"upgrade",action:"viewed",detail:r}),Ui(e,n,{buttons:d,is_html:!0,upgrade:{message:a[s],list:o[u],is_business:i}})}(Tl,"This is a premium feature","Upgrade your plan to change this setting.","upgrade-settings",!0)})),$e()}}function Ol(t,e,n){e.upgrade=e.property in n;var r=e.choices&&("buttons"==e.style||"boolean"==e.type);t.attr("class","settings-option option-type-"+e.type+(r?" settings-buttons":"")+(e.upgrade?" upgrade-setting":""));var i=t.append("label").attr("for","setting-"+e.property).classed("hidden",null==e.name).append("h3").text(e.name).classed("no-select",!0);e.upgrade?i.append("i").attr("class","popup fa fa-star setting-tooltip tooltip-upgrade").style("font-family","FontAwesome").style("background-color","#93366e").attr("data-popup-head","This is a premium feature").attr("data-popup-body",e.description?e.description.replace(/\[\[/g,"").replace(/\]\]/g,""):"").attr("data-popup-position","top"):e.description&&i.append("i").attr("class","popup fa fa-question setting-tooltip tooltip-help").style("font-family","FontAwesome").attr("data-popup-body",e.description.replace(/\[\[/g,"").replace(/\]\]/g,"")).attr("data-popup-position","top"),e.width&&t.classed("width-"+e.width.replace(/ /g,"-"),!0);var a="input";if("text"!=e.type&&"code"!=e.type||(a="textarea"),"code"==e.type){var o=!1;t.append("i").attr("class","popup fa fa-reply clickable wrap-control").attr("data-popup-body","Wrap/unwrap text").attr("data-popup-position","top").on("click",(function(){o=!o,Et(this.parentNode).select("textarea").attr("wrap",o?null:"off"),Et(this).classed("selected",o)}))}var s=t.append(a).attr("id","setting-"+e.property).attr("class","setting").attr("name",e.property).attr("disabled",!Tl.visualisation.can_edit||null),u=s.node();if("colors"==e.type)Dl.initialize(u,e);else if("font"==e.type)Fo.initialize(u,e,Tl.user&&null!=Tl.user.company_id);else if("number"==e.type)u.setAttribute("type","number"),null!=e.min&&u.setAttribute("min",e.min),null!=e.max&&u.setAttribute("max",e.max),e.step&&u.setAttribute("step",e.step);else if("url"==e.type)u.setAttribute("type","url"),Cl.addButton(u,e.upgrade);else if(r){s.remove(),s=t.append("div").attr("id","setting-"+e.property).attr("name",e.property).classed("buttons-container",!0).classed("large","large"==e.size),u=s.node();var l=e.choices.length,c=[3,4,5],d=function(){if(l<=2)return{column_count:l,rows:1};var t=c.map((function(t){return{column_count:t,orphans:l%t/t,rows:l/t}})).filter((function(t){return t.rows>=1})).sort((function(t,e){return t.rows>e.rows?1:t.rows<e.rows?-1:0})),e=t.filter((function(t){return 0===t.orphans}));return 1===e.length||e.length>1?e[0]:0===e.length?t.sort((function(t,e){return t.orphans>e.orphans?-1:t.orphans<e.orphans?1:0}))[0]:void 0}();e.choices.forEach((function(t,n){s.append("input").attr("type","radio").attr("name",e.property).attr("value",t[1]).attr("id",e.property+"_"+n).attr("class","setting").attr("disabled",!Tl.visualisation.can_edit||null).call(Ul(e)),Hl(t,s.append("label").attr("for",e.property+"_"+n).style("width",100/d.column_count+"%").style("border-radius",(function(){var t=d.column_count,e=Math.ceil(d.rows),r=t*e-l;return e<=1?0===n?"3px 0 0 3px":n===t-1?"0 3px 3px 0":null:e>1?0===n?"3px 0 0 0":n===t-1?"0 3px 0 0":n===l-(t-r)?"0 0 0 3px":n===l-1&&0===r?"0 0 3px 0":null:null})).node())}))}else"boolean"==e.type?(u.setAttribute("type","checkbox"),t.append("label").attr("class","slider").attr("for","setting-"+e.property)):u.setAttribute("type","text");if("code"==e.type&&(u.setAttribute("wrap","off"),s.on("keydown.tab",(function(t){var e=t;if(9===e.keyCode&&!(e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault();var n=this.selectionStart;this.value=this.value.substring(0,n)+"\t"+this.value.substring(this.selectionEnd),this.selectionEnd=n+1}}))),e.choices&&"string"==e.type&&"buttons"!=e.style&&Bi(u,e.property+"-dropdown",e.choices,{allow_other_option:e.choices_other,custom_renderer:Hl}),"color"==e.type){Et(u).classed("color",!0).style("display","none");var f=Et(u.parentNode).append("div").attr("class","color-picker"),p=f.append("div").attr("class","color-wrapper");e.optional&&f.append("button").attr("class","cancel-setting popup").html("<svg><use xlink:href='#cancel-setting'></use></svg>").attr("data-popup-body","If cleared, the color will be set automatically based on the theme or context").on("click",(function(){u.value="",s.dispatch("change"),Et(this.parentNode).classed("is-null",!0)})),p.append("input").attr("type","color").on("change",(function(){u.value=this.value,s.dispatch("change"),Et(this.parentNode.parentNode).classed("is-null",!1)})).on("focus",(function(){Et(this.parentNode.parentNode).classed("active",!0)})).on("blur",(function(){Et(this.parentNode.parentNode).classed("active",!1)}))}e.placeholder&&u.setAttribute("placeholder",e.placeholder),e.size&&u.classList.add("size-"+e.size),s.call(Ul(e))}function Ul(t){return function(e){var n=!1;e.on("change",(function(){var e=this;je.hide(),n=!0,Tl.preview_pane.getState(t.property,(function(r,i){return r?(console.error("Failed to get state property "+t.property,r),void(n=!1)):function(t,e){if("number"!==e.type)return!0;if(""===t.value)return!!e.optional||(je.point(t).text("A value is required").draw(),!1);var n=parseFloat(t.value);return e.hasOwnProperty("min")&&n<e.min?(je.point(t).text("Value cannot be less than "+e.min).draw(),t.value=e.min):e.hasOwnProperty("max")&&n>e.max&&(je.point(t).text("Value cannot be greater than "+e.max).draw(),t.value=e.max),!0}(e,t)?void function(t,e,n){r=e.property,i=100,a=Il,o=[t,e,n],clearTimeout(Rl[r]),Rl[r]=setTimeout((function(){a.apply(window,o),delete Rl[r]}),i);var r,i,a,o}(e,t,(function(r){if(!r)return n=!1,void("SELECT"==e.tagName&&Et(e).dispatch("blur"));var a="radio"==e.type?e.nextSibling:e;je.point(a).text("Not changed: "+r).draw();var o={};o[t.property]=i,Tl.preview_pane.setState(o,(function(r){if(r)return console.error("Failed to revert setting "+t.property+" to value: "+i),void(n=!1);Tl.preview_pane.update((function(r){if(r)return console.error("Failed to update after reverting setting "+t.property+" to value: "+i),void(n=!1);jl(e,i),n=!1}))}))})):(e.value=i,void(n=!1))}))})).on("keydown",(function(t){Tl.confirm.blank(),13==t.keyCode&&je.hide()})).on("blur",(function(){if(!n){var e=this;je.hide(),Tl.preview_pane.getState(t.property,(function(n,r){n?console.error("Failed to get state property "+t.property,n):jl(e,r)}))}}))}}var Rl={};function Bl(t,e,n){if(t.classList.contains("colors"))return Dl.getValue(t);if(t.classList.contains("font-menu")){var r=Fo.getValue(t);return e&&!r?n?null:"":r}if(t.classList.contains("buttons-container")){for(var i,a=t.querySelectorAll("input[type='radio']"),o=0;o<a.length;o++)if(a[o].checked){i=a[o];break}if(!i)return n?null:"";t=i}switch(t.getAttribute("type")){case"checkbox":return t.checked;case"number":return e&&!t.value.length?n?null:"":+t.value;case"radio":if(t.parentNode.parentNode.classList.contains("option-type-boolean"))return"true"==t.value;default:return e&&t.classList.contains("color")&&!t.value.length?n?null:"":t.hasAttribute("data-value")?t.getAttribute("data-value"):t.value}}function jl(t,e){if(t.classList.contains("colors"))Dl.update(t,e);else if(t.classList.contains("font-menu"))Fo.update(t,e);else if("checkbox"==t.getAttribute("type"))t.checked=e;else if(t.classList.contains("color"))t.value=e,Et(t.parentNode).select(".color-picker").classed("is-null",null===e),Et(t.parentNode).select(".color-wrapper input").node().value=e;else if(t.getAttribute("data-autocomplete")){for(var n=function(t){for(var e=0;e<Tl.settings.length;e++){var n=Tl.settings[e];if(n.property===t)return n}}(t.name),r=0;r<n.choices.length;r++){var i,a,o=n.choices[r];if("string"==typeof o?i=a=o:(i=o[1],a=o[0]),e==i)return t.value=a,void t.setAttribute("data-value",i)}t.value=e,t.setAttribute("data-value",e)}else if(t.className.indexOf("buttons-container")>-1){var s=t.querySelectorAll("input[type='radio']");for(r=0;r<s.length;r++)s[r].value===""+e&&(s[r].checked=!0)}else t.value=e}function Hl(t,e){var n=Et(e);if("string"!=typeof t){var r=t[2];r&&(r.match(Sl)?n.append("i").attr("class","fa "+r):r.match(Ml)&&n.append("img").attr("src",r));var i=t[0];i.match(Sl)?n.append("i").attr("class","fa "+i):i.match(Ml)?n.append("img").attr("src",i):n.node().append(i)}else n.text(t)}function Il(t,e,n){var r={},i=Bl(t,e.optional);if(r[e.property]=i,!("choices"in e)||"colors"===e.type||function(t,e){return!!t.choices_other||-1!==t.choices.map((function(t){return t instanceof Array?t[1]:t})).indexOf(e)}(e,i)){Tl.confirm.saving();var a=!1,o={};o[e.property]=Bl(t,e.optional,!0),Tl.preview_pane.setState(o,(function(t){if(t)return s(t);Tl.preview_pane.update((function(t){if(t)return s(t);Tl.visualisation.updateSettings(r,(function(t){if(t)return s(t);Tl.analytics("send","event","visualisation","change_setting",Tl.visualisation.id),Pl(),Tl.confirm.saved(),n&&n()}))}))}))}else n&&n("You can only choose values from the list");function s(r){a||(Tl.preview_pane.getState(e.property,(function(e,i){if(e)return console.error("Failed to get state",e),void Tl.confirm.error(e);jl(t,i),Pl(),Tl.confirm.blank(),n&&n(r)})),a=!0)}}function zl(t,e){return/^data\./.test(t)?function(t,e){var n=t.split(".");return Tl.visualisation.__sdk__?function(t,e){if(t.length>=4)return;for(var n=null,r=Tl.template_data_bindings,i=0;i<r.length;i++){var a=r[i];if("string"!=typeof a&&(a.dataset===t[1]&&a.key===t[2])){n=a;break}}if(!n)throw new Error("Bug: data binding not found - these should already have been checked");return"column"===n.type?!!n.column===e:!!n.columns.split("::")[1]===e}(n,e):function(t,e){if(t.length<4){return!!document.getElementById("data-binding-"+t[1]+"-"+t[2]).value===e}if("type"!==t[3])throw new Error("Fourth part of name must be “type”");var n=Tl.visualisation.template_id,r=Tl.visualisation.data_bindings[n][t[1]][t[2]];if(null==r)return!1;for(var i,a=Tl.visualisation.data_tables,o=r.data_table_id,s=r.columns||[r.column],u=0;u<a.length;u++)if(a[u].id===o){i=a[u].column_types;break}var l=!1;for(u=0;u<s.length;u++){var c=i[s[u]].type_id.split("$")[0];if(l=-1!==(Array.isArray(e)?e:[e]).indexOf(c))break}return l}(n,e)}(t,e):function(t,e){var n=document.getElementById("setting-"+t);if(!n)return console.error("Could not find input for setting",t),!1;var r=Bl(n);if(e instanceof Array)return-1!==e.indexOf(r);return r===e}(t,e)}function Pl(){Tl.settings.filter((function(t){return"object"==typeof t&&"show_condition"in t})).forEach((function(t){var e=t.show_condition.every((function(t){var e="show"===t.type,n=t.condition;if("boolean"==typeof n)return e===n;if("string"==typeof n)return e===zl(n,!0);for(var r in n)if(!zl(r,n[r]))return!1===e;return e})),n=document.getElementById("setting-"+t.property);if(n){for(var r=n;!r.classList.contains("settings-option");)r=r.parentNode;if(Et(r).classed("hidden",!e),t.new_section)for(var i=r.previousSibling;i&&(Et(i).classed("settings-divider")||Et(i).classed("settings-subhead"));)Et(i).classed("hidden",!e),i=i.previousSibling}else console.error("Could not find input",t.property)}));for(var t=document.querySelectorAll(".template-settings .settings-block"),e=0;e<t.length;e++){var n=t[e];n.classList.contains("hidden")?null!==n.querySelector(".settings-option:not(.hidden)")&&n.classList.remove("hidden"):null==n.querySelector(".settings-option:not(.hidden)")&&n.classList.add("hidden")}}function ql(t,e,n){return Tl=t,Cl={setup:lo,addButton:co,startUpload:po},(kl=Et(".side-panel .template-settings")).on("submit",(function(t){t.preventDefault()})),Dl.replaceThemeColors(e),Fo.replaceThemeFonts(n),Ll(Tl.settings),Et(".side-panel-scrollbox").on("scroll",(function(){je.hide()})),{update:function(t){kl.html(""),Et(".current-template").style("opacity","1"),Ll(Tl.settings=t)},populate:function(){Tl.preview_pane.getState((function(t,e){if(t)console.error("Failed to get state",t);else{var n=Ca(e);for(var r in n){var i=document.getElementById("setting-"+r);i&&jl(i,n[r])}Pl()}}))},getSettingsForCurrentTemplate:function(){return Fl},setReadOnly:function(){Ct(".setting").each((function(){Et(this).attr("disabled",!0)}))},unsetReadOnly:function(){Ct(".setting").each((function(){Et(this).attr("disabled",null)}))}}}var Yl,$l,Vl=!1,Wl=[];function Gl(){Et(".flourish-warn-list").classed("visible",!1),Vl=!1}function Xl(){return Et(".flourish-warn-btn").on("click",(function(){Vl?Gl():(Et(".flourish-warn-list").classed("visible",!0),Vl=!0)})),{clear:Zl,warn:Kl}}function Jl(){Et(".flourish-warn-container").classed("visible",Wl.length),Wl.length>100&&(Wl.length=100);var t=Et(".flourish-warn-list ul").selectAll("li").data(Wl),e=t.enter().append("li");e.append("i").attr("class","fa fa-warning"),e.append("p").attr("class","message"),e.append("p").attr("class","explanation");var n=t.merge(e);n.select(".message").text((function(t){return t.message||""})),n.select(".explanation").text((function(t){return t.explanation||""})),t.exit().remove()}function Zl(){Wl=[],Jl(),Gl()}function Kl(t){Wl.unshift(t),Jl()}function Ql(t){var e=Yl.visualisation,n=e.getTemplate(),r=!1,i=!1,a=!1;function o(){var e=Yl.template_settings.getSettingsForCurrentTemplate(),n=Yl.visualisation.settingsForCurrentTemplate(),r={};for(var i in n)i in e&&(r[i]=n[i]);$l.loadVisualisation(Yl,r,(function(){Yl.template_settings.populate(),Yl.data_bindings.updateRequiredBindingsOverlay(!1),so(),t&&t()})),Mt()}n.getSettings((function(t,e){t?console.error("Failed to get template settings: "+t):(Yl.template_settings.update(e),r=!0,i&&a&&o())})),n.getDataBindings((function(t,e){t?console.error("Failed to get template data bindings: "+t):(Yl.data_bindings.update(e),i=!0,r&&a&&o())})),e.refreshDataBindings((function(t){t?console.error("Failed to get template data bindings: "+t):(a=!0,i&&r&&o())}))}function tc(t){$l.updateData(Yl.visualisation,t)}function ec(t){$l.updateDataNotPreview(Yl.visualisation,t)}function nc(t){Yl=t;var e=Xl();return{loadTemplate:Ql,updateData:tc,updateDataNotPreview:ec,sync:($l=ao("iframe#preview","editor",Yl,e,{setSetting({name:t,value:e}){const n=function(t){return document.getElementById("setting-"+t)}(t);n?(jl(n,e),n.dispatchEvent(new Event("change"))):console.log(`Could not find setting ${t}`)}})).sync,setState:$l.setState,getState:$l.getState,hasData:$l.hasData,setData:$l.setData,getData:$l.getData,draw:$l.draw,update:$l.update,getDefaultState:$l.getDefaultState,snapshot:$l.snapshot,setFixedHeight:$l.setFixedHeight,resize:$l.resize,getDrawCalled:$l.getDrawCalled,setDrawCalled:$l.setDrawCalled}}var rc={},ic={};function ac(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function oc(t){var e=Object.create(null),n=[];return t.forEach((function(t){for(var r in t)r in e||n.push(e[r]=r)})),n}function sc(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function uc(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+sc(-t,6):t>9999?"+"+sc(t,6):sc(t,4)}(t.getUTCFullYear())+"-"+sc(t.getUTCMonth()+1,2)+"-"+sc(t.getUTCDate(),2)+(i?"T"+sc(e,2)+":"+sc(n,2)+":"+sc(r,2)+"."+sc(i,3)+"Z":r?"T"+sc(e,2)+":"+sc(n,2)+":"+sc(r,2)+"Z":n||e?"T"+sc(e,2)+":"+sc(n,2)+"Z":"")}var lc=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,u=a<=0,l=!1;function c(){if(u)return ic;if(l)return l=!1,rc;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=a?u=!0:10===(r=t.charCodeAt(o++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return u=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=c())!==ic;){for(var d=[];r!==rc&&r!==ic;)d.push(r),r=c();e&&null==(d=e(d,s++))||i.push(d)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?uc(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=ac(t);return function(r,i){return e(n(r),i,t)}}(t,e):ac(t)}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=oc(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=oc(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}(","),cc=lc.parseRows,dc=lc.formatRows;function fc(t,e,n){zo(this,"object"==typeof e?(n=e).id:e,void 0,n,{getVersionNumber:function(){return t.version_number},setVersionNumber:function(e){t.version_number=e}}),this.visualisation=t,this.api_prefix="/api/data_table"}function pc(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?pc(t):t}))}function hc(t){this.id=t}function mc(t,e,n){if(zo(this,t,e,n),this.api_prefix="/api/visualisation",this.data_tables){var r=this;this.data_tables=this.data_tables.map((function(t){return new fc(r,t)}))}}function vc(t,e,n){Vo({url:t.api_prefix+"/"+t.id+"/data_bindings",method:"POST",payload:function(){return{version_number:t.version_number,data_bindings:e}},callback:function(r,i){if(r)return n(r);t.version_number=i.version_number,t.data_bindings||(t.data_bindings={}),t.template_id in t.data_bindings||(t.data_bindings[t.template_id]={});var a=t.data_bindings[t.template_id];for(var o in e)for(var s in e[o]){var u=e[o][s];a[o]||(a[o]={}),null===u?delete a[o][s]:a[o][s]=u}n(void 0)}})}function gc(t,e,n){Vo({url:t.api_prefix+"/"+t.id+"/settings",payload:function(){return{version_number:t.version_number,settings:e}},callback:function(r,i){if(r)return n(r);t.version_number=i.version_number,t.settings||(t.settings={}),t.template_id in t.settings||(t.settings[t.template_id]={});var a=t.settings[t.template_id];for(var o in e){var s=e[o];a[o]=s}n(void 0)}})}function yc(t,e,n,r){Vo({url:t.api_prefix+"/"+t.id+"/publish",payload:function(){return{password:n,anyone_can_duplicate:r}},callback:function(n,r){if(n)return e(n);t.version_number=r.version_number,t.embed_url=r.embed_url,t.showcase_url=r.showcase_url,t.is_password_protected=r.is_password_protected,t.anyone_can_duplicate=r.anyone_can_duplicate,e(void 0,r)}})}function _c(t,e){for(var n in e)"object"!=typeof t[n]||null==t[n]||Array.isArray(t[n])||"object"!=typeof e[n]||null==e[n]||Array.isArray(e[n])?t[n]=e[n]:_c(t[n],e[n])}function bc(t,e,n,r){function i(){}this.visualisation=t,this.settings=e,this.template_data_bindings=n,this.public_url_prefix=r,this.is_read_only=!1,this.template_settings=ql(this),this.data_bindings=(Hi=this,Ii=Et(".data-bindings"),{update:function(t){t&&(Hi.template_data_bindings=t),Vi(Hi.visualisation,Hi.template_data_bindings)},modify:function(t,e=!1){Gi(t,(function(){Vi(Hi.visualisation,Hi.template_data_bindings),e&&Hi.preview_pane.updateData((t=>{if(t)return console.error("Failed to update preview pane: "+t)}))}))},requiredBindingsAreUnset:Zi,updateRequiredBindingsOverlay:Ki}),this.preview_pane=nc(this),this.responsive_menu=St(this),this.confirm={on:i,blank:i,saved:i,saving:i,error:i},this.analytics=i,this.tour={fireEvent:i},window.addEventListener("hashchange",(()=>{this.loadFromUrlHash()}))}fc.prototype.getColumnTypes=function(t){Vo({url:this.api_prefix+"/"+this.id,method:"GET",callback:function(e,n){if(e)return t(e);t(void 0,pc(n.column_types||[]))}},"load-data")},fc.prototype.csv=function(t){this.cached_data?t(void 0,pc(this.cached_data)):this.csvPromise().then((e=>t(null,e)),(e=>t(e)))},fc.prototype.csvPromise=async function(){if(this.cached_data)return pc(this.cached_data);const t=this;return new Promise(((e,n)=>{Vo({url:this.api_prefix+"/"+this.id+"/csv",response_type:"text/csv; charset=utf-8",method:"GET",callback(r,i){if(r)return n(r);t.cached_data=cc(i),e(pc(t.cached_data))}},"load-data")}))},fc.prototype.saveData=function(t,e){var n=this,r=Di(pc(t));Vo({url:this.api_prefix+"/"+this.id+"/csv",payload:function(){return{version_number:n.getVersionNumber(),data:dc(r)}},callback:function(t,i){if(t)return e(t);n.setVersionNumber(i.version_number),n.cached_data=r,e(void 0)}})},fc.prototype.updateFromUrl=function(t,e){var n=this;Vo({url:this.api_prefix+"/"+this.id+"/csv-url",payload:function(){return{live_csv_url:t,version_number:n.getVersionNumber()}},callback:function(r,i){if(r)return e(r);n.setVersionNumber(i.version_number),n.live_csv_url=t,t?n.updateFromLiveCsvUrl((function(t,r){if(t)return n.last_remote_data_error_message=t,e(t);var i,a=((i=Di(cc(r.csv))).forEach((function(t){for(var e=0;e<t.length;e++)t[e]&&"string"==typeof t[e]&&(t[e]=t[e].trim())})),i);n.cached_data=a,n.setVersionNumber(r.version_number),n.t_updated=r.t_updated,n.last_remote_data_error_message=null,e(void 0,a,r.new_column_types)})):(n.t_updated=i.t_updated,n.last_remote_data_error_message=null,e(void 0,null,null))}})},fc.prototype.updateFromLiveCsvUrl=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/update-from-live-csv-url",payload:function(){return{version_number:e.getVersionNumber()}},callback:function(n,r){if(n)return t(n);e.setVersionNumber(r.version_number),t(void 0,r)}})},fc.prototype.save=function(t,e){return Go(this,t,e)},fc.prototype.delete=function(t){return Xo(this,t)},hc.prototype.getSettings=function(t){if(this.settings)t(void 0,this.settings);else{var e=this;Vo({url:"/api/template/"+this.id+"/settings",method:"GET",callback:function(n,r){if(n)return t(n);e.settings=r.settings,t(void 0,e.settings)}})}},hc.prototype.getDataBindings=function(t){Vo({url:"/api/template/"+this.id+"/data_bindings",method:"GET",callback:t})},mc.prototype.save=function(t,e){this.is_listed||(t.is_listed=!0),Go(this,t,e)},mc.prototype.setTemplateId=function(t,e){Go(this,{template_id:t},e)},mc.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new hc(this.template_id)),this._template):null},mc.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},mc.prototype.getState=function(t){this.template_id||t({});var e=this.settingsForCurrentTemplate();this.getTemplate().getSettings((function(n,r){if(n)throw n;for(var i={},a=0;a<r.length;a++){var o=r[a];o.property in e&&(i[o.property]=e[o.property])}t(ka(i))}))},mc.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},mc.prototype.refreshDataBindings=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/data_bindings",method:"GET",callback:function(n,r){if(n)return t(n);e.data_bindings=r,t()}})},mc.prototype.resetToTheme=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/reset_to_theme",method:"POST",payload:function(){return{version_number:e.version_number}},callback:function(n,r){if(n)return t(n);e.version_number=r.version_number,t(void 0)}})},mc.prototype.updateDataBindings=function(t,e){var n=this;if(this.is_listed)return vc(n,t,e);this.save({is_listed:!0},(function(r){return r?e(r):vc(n,t,e)}))},mc.prototype.updateSettings=function(t,e){var n=this;if(this.is_listed)return gc(n,t,e);this.save({is_listed:!0},(function(r){return r?e(r):gc(n,t,e)}))},mc.prototype.refreshSettings=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/settings",method:"GET",callback:function(n,r){if(n)return t(n);e.settings=r,t()}})},mc.prototype.getThemeFontsAndColors=function(t){Vo({url:this.api_prefix+"/"+this.id+"/theme-fonts-and-colors",method:"GET",callback:function(e,n){if(e)return t(e);t(void 0,n.fonts,n.colors)}})},mc.prototype.getDataTables=function(t){Vo({url:this.api_prefix+"/"+this.id+"/data",method:"GET",callback:function(e,n){return e?t(e):t(void 0,n.data)}})},mc.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new fc(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},mc.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},mc.prototype.prepareData=function(t){var e=this;if(!e.data_bindings)throw new Error("No data bindings loaded");var n=e.template_id;e.dataTables((function(r,i){if(r)return t(r);if(e.template_id==n){for(var a={},o={},s=0,u=0;u<i.length;u++)!function(r){o[r.id]=r.column_types,r.csv((function(u,l){if(u)throw u;e.template_id==n&&(a[r.id]=l,++s==i.length&&e.getTemplate().getDataBindings((function(n,r){if(n)throw n;var i={};r.forEach((function(t){"string"!=typeof t&&(t.dataset in i||(i[t.dataset]={}),i[t.dataset][t.key]=t)}));var s={},u=e.dataBindingsForCurrentTemplate();for(var l in u)s[l]=Ci(u[l],a,o,i[l]);for(l in i)s[l]||(s[l]=[],s[l].column_names={},s[l].metadata={});t(void 0,s)})))}))}(i[u]);0==i.length&&t(void 0,{})}}))},mc.prototype.delete=function(t){Xo(this,t)},mc.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},mc.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},mc.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0},mc.prototype.duplicate=function(t){Vo({url:this.api_prefix+"/"+this.id+"/duplicate",callback:t})},mc.prototype.publish=function(t,e,n){var r=this;if(this.is_listed)return yc(r,t,e,n);this.save({is_listed:!0},(function(i){return i?t(i):yc(r,t,e,n)}))},mc.prototype.unpublish=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/unpublish",callback:function(n,r){if(n)return t(n);e.version_number=r.version_number,e.embed_url=r.embed_url,e.showcase_url=r.showcase_url,t(void 0,r)}})},mc.prototype.published=function(){return!!this.showcase_url},mc.prototype.sendForReview=function(t,e,n){var r=this;Vo({url:"/api/reviews",payload:function(){return{project_id:r.id,project_type:"visualisation",reviewers:t,message:e}},callback:function(t,e){r.status=e,n(t,e)}})},mc.prototype.approve=function(t,e){var n=this;Vo({url:"/api/review/"+t+"/approve",callback:function(t,r){return n.status=r,e(t,r)}})},mc.prototype.decline=function(t,e,n){var r=this;Vo({url:"/api/review/"+t+"/decline",payload:function(){return{message:e}},callback:function(t,e){r.status=e,n(t,e)}})},mc.prototype.cancelReview=function(t,e){var n=this;Vo({url:"/api/review/"+t+"/cancel",callback:function(t,r){n.status=r,e(t,r)}})},mc.list=function(t){Vo({url:"/api/visualisations",method:"GET",callback:t})},mc.getById=function(t,e){Vo({url:"/api/visualisation/"+t,method:"GET",callback:function(n,r){if(n)return e(n);e(void 0,new mc(t,r.version_number,r))}})},mc.getPublishedJson=function(t,e,n){Vo({url:`${e}visualisation/${t}/visualisation.json`,method:"GET",callback(t,e){if(t)return n(t);n(void 0,e)}})},mc.createFromTemplate=function(t,e){Vo({url:"/api/template/"+t+"/visualisations",method:"PUT",callback:e})},mc.createFromVisualisation=function(t,e){Vo({url:"/api/visualisation/"+t+"/duplicate",callback:e})},mc.setAsStaffPick=function(t,e){Vo({url:"/api/visualisation/"+t+"/set_staff_pick",method:"POST",callback:e})},mc.unsetAsStaffPick=function(t,e){Vo({url:"/api/visualisation/"+t+"/unset_staff_pick",method:"POST",callback:e})},mc.setTag=function(t,e,n){Vo({url:"/api/visualisation/"+t+"/folder/"+encodeURIComponent(e),method:"PUT",callback:n})},mc.removeTag=function(t,e,n){Vo({url:"/api/visualisation/"+t+"/tag/"+encodeURIComponent(e),method:"DELETE",callback:n})},bc.prototype.loadFromUrlHash=async function(){if(!window.location.hash)return;const t=window.location.hash.slice(1),e=(n=mc.getPublishedJson,function(...t){return new Promise(((e,i)=>{n.call(r,...t,(function(t,n){if(t)return i(t);e(n)}))}))});var n,r;try{const n=await e(t,this.public_url_prefix);this.updateFromJson(n)}catch(t){console.error(t)}},bc.prototype.updateFromJson=function({state:t,bindings:e,data:n}){const r={};for(const[t,i]of Object.entries(e)){const e={},o={};for(const[t,n]of Object.entries(i))Array.isArray(n)?o[t]=n:e[t]=n;const s=a(n[t],e,o);r[t]=s}const i={};_c(i,this.preview_pane.getDefaultState()),_c(i,t),this.preview_pane.sync({state:i,data:r,overwrite_state:!0,update:!0},(()=>this.template_settings.populate()))};var wc={},xc={};function Ac(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function Ec(t){var e=Object.create(null),n=[];return t.forEach((function(t){for(var r in t)r in e||n.push(e[r]=r)})),n}function Tc(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Cc(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+Tc(-t,6):t>9999?"+"+Tc(t,6):Tc(t,4)}(t.getUTCFullYear())+"-"+Tc(t.getUTCMonth()+1,2)+"-"+Tc(t.getUTCDate(),2)+(i?"T"+Tc(e,2)+":"+Tc(n,2)+":"+Tc(r,2)+"."+Tc(i,3)+"Z":r?"T"+Tc(e,2)+":"+Tc(n,2)+":"+Tc(r,2)+"Z":n||e?"T"+Tc(e,2)+":"+Tc(n,2)+"Z":"")}var kc=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,u=a<=0,l=!1;function c(){if(u)return xc;if(l)return l=!1,wc;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=a?u=!0:10===(r=t.charCodeAt(o++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return u=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=c())!==xc;){for(var d=[];r!==wc&&r!==xc;)d.push(r),r=c();e&&null==(d=e(d,s++))||i.push(d)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?Cc(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Ac(t);return function(r,i){return e(n(r),i,t)}}(t,e):Ac(t)}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=Ec(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Ec(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}(",").parseRows,Dc="$";function Fc(){}function Sc(t,e){var n=new Fc;if(t instanceof Fc)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,a=t.length;if(null==e)for(;++i<a;)n.set(i,t[i]);else for(;++i<a;)n.set(e(r=t[i],i,t),r)}else if(t)for(var o in t)n.set(o,t[o]);return n}function Mc(){}Fc.prototype=Sc.prototype={constructor:Fc,has:function(t){return Dc+t in this},get:function(t){return this[Dc+t]},set:function(t,e){return this[Dc+t]=e,this},remove:function(t){var e=Dc+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===Dc&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===Dc&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===Dc&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===Dc&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===Dc&&++t;return t},empty:function(){for(var t in this)if(t[0]===Dc)return!1;return!0},each:function(t){for(var e in this)e[0]===Dc&&t(this[e],e.slice(1),this)}};var Nc=Sc.prototype;Mc.prototype={constructor:Mc,has:Nc.has,add:function(t){return this[Dc+(t+="")]=t,this},remove:Nc.remove,clear:Nc.clear,values:Nc.keys,size:Nc.size,empty:Nc.empty,each:Nc.each};var Lc,Oc,Uc={value:function(){}};function Rc(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Bc(r)}function Bc(t){this._=t}function jc(t,e){return t.trim().split(/^|\s+/).map((function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function Hc(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Ic(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Uc,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function zc(t,e,n){var r;r="object"==typeof e?e.id:e,this.id=r,this.visualisation=t,this.api_prefix="/api/data_table"}function Pc(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?Pc(t):t}))}function qc(t){this.id=t}function Yc(t,e,n){var r=this;r.id=1,r.template_id=1,r.api_prefix="/api/visualisation",r.can_edit=!0,r.__sdk__=!0,n.data_tables&&(this.data_tables=n.data_tables.map((function(t){return new zc(r,t)}))),n.data_bindings&&(this.data_bindings=n.data_bindings)}Bc.prototype=Rc.prototype={constructor:Bc,on:function(t,e){var n,r=this._,i=jc(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=Ic(r[n],t.name,e);else if(null==e)for(n in r)r[n]=Ic(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=Hc(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Bc(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}},zc.prototype.csv=function(t){if(this.cached_data)t(void 0,Pc(this.cached_data));else{var e=this;!function(t,e){var n,r,i,a,o=Rc("beforesend","progress","load","error"),s=Sc(),u=new XMLHttpRequest,l=null,c=null,d=0;function f(t){var e,r=u.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(u)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,u)}catch(t){return void o.call("error",n,t)}else e=u;o.call("load",n,e)}else o.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in u)&&/^(http(s)?:)?\/\//.test(t)&&(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=u.ontimeout=f:u.onreadystatechange=function(t){u.readyState>3&&f(t)},u.onprogress=function(t){o.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(a=t,n):a},timeout:function(t){return arguments.length?(d=+t,n):d},user:function(t){return arguments.length<1?l:(l=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,f){return u.open(e,t,!0,l,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),u.setRequestHeader&&s.each((function(t,e){u.setRequestHeader(e,t)})),null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=a&&(u.responseType=a),d>0&&(u.timeout=d),null==f&&"function"==typeof i&&(f=i,i=null),null!=f&&1===f.length&&(f=function(t){return function(e,n){t(null==e?n:null)}}(f)),null!=f&&n.on("error",f).on("load",(function(t){f(null,t)})),o.call("beforesend",n,u),u.send(null==i?null:i),n},abort:function(){return u.abort(),n},on:function(){var t=o.on.apply(o,arguments);return t===o?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}}(this.api_prefix+"/"+this.id+"/csv",(function(n,r){e.cached_data=kc(r.response),t(void 0,Pc(e.cached_data))}))}},zc.prototype.saveData=function(t,e){e()},zc.prototype.save=function(t,e){e()},zc.prototype.delete=function(t){t()},qc.prototype.getSettings=function(t){t(void 0,window.Flourish.app.settings)},qc.prototype.getDataBindings=function(t){t(void 0,window.Flourish.app.template_data_bindings)},qc.prototype.refreshDataBindings=function(t){t(void 0)},Yc.prototype.save=function(t,e){this.version_number++,e(void 0)},Yc.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new qc(this.template_id)),this._template):null},Yc.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},Yc.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},Yc.prototype.refreshDataBindings=function(t){t()},Yc.prototype.updateDataBindings=function(t,e){var n=this;n.version_number++,n.data_bindings||(n.data_bindings={}),n.template_id in n.data_bindings||(n.data_bindings[n.template_id]={});var r=n.data_bindings[n.template_id];for(var i in t)for(var a in t[i]){var o=t[i][a];r[i][a]=o}e(void 0)},Yc.prototype.updateSettings=function(t,e){var n=this;n.version_number++,n.settings||(n.settings={}),n.template_id in n.settings||(n.settings[n.template_id]={});var r=n.settings[n.template_id];for(var i in t){var a=t[i];r[i]=a}e(void 0)},Yc.prototype.getDataTables=function(t){t(void 0,window.Flourish.app.data_tables)},Yc.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new zc(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},Yc.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},Yc.prototype.prepareData=function(t){var e=this;if(!e.data_bindings)throw new Error("No data bindings loaded");var n=e.template_id;e.dataTables((function(r,i){if(r)return t(r);if(e.template_id==n){for(var a={},o={},s=0,u=0;u<i.length;u++)!function(r){r.csv((function(u,l){if(u)throw u;e.template_id==n&&(o[r.id]=ki(l),a[r.id]=l,++s==i.length&&e.getTemplate().getDataBindings((function(n,r){if(n)throw n;var i={};r.forEach((function(t){"string"!=typeof t&&(t.dataset in i||(i[t.dataset]={}),i[t.dataset][t.key]=t)}));var s={},u=e.dataBindingsForCurrentTemplate();for(var l in u)s[l]=Ci(u[l],a,o,i[l]);for(l in i)s[l]||(s[l]=[],s[l].column_names={},s[l].metadata={});t(void 0,s)})))}))}(i[u]);0==i.length&&t(void 0,{})}}))},Yc.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},Yc.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},Yc.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0};var $c=!1;function Vc(){Lc&&Lc.classList.remove("shown")}function Wc(){this.close(),$c||(Lc&&setTimeout((function(){Lc.classList.add("shown")}),1e3),setTimeout(Gc,250))}function Gc(){Xc().addEventListener("open",(function(){window.location.reload()}))}function Xc(){var t=new window.WebSocket(Oc);return t.addEventListener("open",Vc),t.addEventListener("close",Wc),t}return t.Visualisation=Yc,t.initSDK=function(t,e,n,r){return $e(),window.Flourish=window.Flourish||{},window.Flourish.app=new bc(t,e,n,r),window.Flourish.app},t.talkToServer=function(){Lc=document.getElementById("error-server-down"),Oc=window.location.origin.replace(/^http(s?):\/\//,"ws$1://"),window.addEventListener("beforeunload",(function(){$c=!0})),Xc()},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
2
3
|
//# sourceMappingURL=script.js.map
|