diff --git a/css/extension.css b/css/extension.css new file mode 100644 index 0000000..a8253ce --- /dev/null +++ b/css/extension.css @@ -0,0 +1,459 @@ +#extension-privacy-manager-view .clicked{ + border-left:10px solid white; + background-color:rgba(255,255,255,.1); +} + +#extension-privacy-manager-icon{ + display: inline-block; + width: 5rem; + height: 2rem; + background-image: url('../images/menu-icon.svg'); + background-size: contain; + background-size: 4rem; + background-repeat: no-repeat; + background-position: 0; +} + +#extension-privacy-manager-icon:hover{ + background-image: url('../images/menu-icon-open.svg'); +} + + +#extension-privacy-manager-view button{ + font-size: 1.6rem; + padding: 0.5rem 1rem; + border: none; + border-radius: 0.5rem; +} + +/* TABS */ + +.extension-privacy-manager-tab-buttons{ + border-bottom:1px solid white; + margin-top: 4rem; +} + +#extension-privacy-manager-view .extension-privacy-manager-tab-buttons button{ + position: relative; + top: 1px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + + +#extension-privacy-manager-view .extension-privacy-manager-tab-buttons button.extension-privacy-manager-button-active{ + color: white; + background-color:transparent; + border-top: 1px solid white; + border-left: 1px solid white; + border-right: 1px solid white; + border-bottom: 1px solid #5d9bc7; +} + +#extension-privacy-manager-view .extension-privacy-manager-tab-buttons button:not(.extension-privacy-manager-button-active){ + background-color: rgba(0,0,0,.1); + color: white; +} + +#extension-privacy-manager-content-container h3{ + margin-top:3rem; +} + +.zoom { + cursor: move; + fill: none; + pointer-events: all; +} + +.extension-privacy-manager-hidden{ + display:none; +} + + + + + +#extension-privacy-manager-view li{ + padding:1rem; + margin-bottom:1rem; +} + +#main-menu #extension-privacy-manager-menu-item { + background-image: url('../images/menu-icon.svg'); +} + + +#extension-privacy-manager-view { + height: 100%; /*calc(100% - 7.6rem);*/ + box-sizing: border-box; + /*overflow: auto;*/ + overflow: scroll; + position: absolute; + top: 7.6rem; + left: 0; + padding: 2rem; +} + + +#extension-privacy-manager-content { + display:flex; + flex-direction: column; + /*align-items: center; + justify-content: center;*/ + flex-direction: column; + overflow: auto; + position: relative; + text-align: left; + font-size: 1.6rem; + color: #fff; + /*max-width: 60rem; + margin: 0 auto;*/ + /*width: calc(100% - 6rem);*/ + height:auto; +} + +#extension-privacy-manager-content-container{ + height:100%; + max-height: 100%; +} + +#extension-privacy-manager-thing-display{ + /*margin-left: 1rem; + padding:1rem;*/ +} + +#extension-privacy-manager-content label{ + min-width: 100px; + display: inline-block; +} + +#extension-privacy-manager-content input:invalid{ + /*border:2px solid red;*/ +} + +#extension-privacy-manager-tab-sculptor{ + width:100%; + overflow-x: hidden; +} + + + + +.extension-privacy-manager-inline{ + display:flex; + flex-wrap:wrap; + align-items:center; + margin-bottom: 1rem; +} + +.extension-privacy-manager-inline-date, +.extension-privacy-manager-inline-time{ + justify-content: space-between; +} + + +.extension-privacy-manager-inline > span { + max-width: 50%; + display: flex; + width: 30%; + box-sizing: border-box; + align-items: center; + justify-content: space-between; + background-color: rgba(0,0,0,.05); + border-radius: .5rem; +} + +.extension-privacy-manager-inline > span > span{ + display:inline-block; + padding:.2rem; + width: 2rem; + text-align: center; +} + +.extension-privacy-manager-inline > button{ + /*max-width: 49%;*/ + +} + +#extension-privacy-manager-options-pane-buttons button{ + width:100%; + flex-grow:1; + background-color: #48779a; + color: white; + margin-bottom: 1.5rem; +} + + +#extension-privacy-manager-thing-list{ + margin-top:0; + width:100%; + list-style: none; + padding-left: 0; +} + +#extension-privacy-manager-thing-list li{ + background-color:rgba(0,0,0,.1); + border-right:1rem solid transparent; +} + +#extension-privacy-manager-thing-list li:hover{ + background-color: rgba(255,255,255,.1); +} + +#extension-privacy-manager-thing-display{ + /*width:calc(100% - 12rem);*/ + background-color:rgba(255,255,255,.1); + width:100%; +} + +#extension-privacy-manager-thing-dataviz{ + padding:1rem 0 0 0; + overflow: hidden; + height:400px; +} + + +#extension-privacy-manager-thing-dataviz > svg, +#extension-privacy-manager-thing-dataviz > div{ + /*border:1px solid red;*/ +} + +#extension-privacy-manager-thing-dataviz-svg{ + /*width:800px; + height:500px;*/ + overflow:visible; +} + +.extension-privacy-manager-line-path{ + fill:none; + stroke:red; + stroke-width: 2; +} + + + +/* OPTIONS PANE */ + + + +#extension-privacy-manager-thing-options{ + padding:2rem; + display:none; + /*border-top:1px solid white;*/ + background-color: rgba(0,0,0,.1); +} + + +#extension-privacy-manager-input-change-value{ + height:auto; + font-size:4rem; + padding:1rem; + width: 100%; + box-sizing: border-box; + margin-bottom: 3rem; +} + + + + +/* BUTTONS */ +#extension-privacy-manager-shutdown, +#extension-privacy-manager-reboot, +#extension-privacy-manager-fullscreen-button, +#extension-privacy-manager-form-submit { + font-size: 1.6rem; + padding: 0.5rem 1rem; + border: none; + border-radius: 0.5rem; + margin: 1rem 0; +} + +#extension-privacy-manager-shutdown:hover, +#extension-privacy-manager-reboot:hover, +#extension-privacy-manager-fullscreen-button:hover, +#extension-privacy-manager-form-submit:hover{ + background-color: LightGreen; +} + + +.extension-privacy-manager-checkbox-container{ + text-align:left; + width:100px; + display: inline-block; + margin-top:1rem; +} + + +#extension-privacy-manager-form-browser-time-button{ + margin-left:100px; +} + + +#extension-privacy-manager-form-ntp{ + -moz-transform: scale(1.50); + -webkit-transform: scale(1.50); + -o-transform: scale(1.50); + transform: scale(1.50); + margin-right: .5rem; + margin-top: 1.5rem; +} + + +#extension-privacy-manager-content .control-label{ + font-size: 1.5rem; + font-weight: bold; + margin-bottom: 0.5rem; + margin-top:1rem; +} + + +#extension-privacy-manager-content .field-description{ + margin-top: .5rem; + font-size: 1.5rem; + margin-bottom: 0.5rem; + padding-left: 100px; +} + + +#extension-privacy-manager-picker select{ + padding: 1rem 1rem 1rem 1rem; + font-size: 2rem; + text-align: center; + background-color: #d2d9de; + margin-right: .2rem; + border: none; + flex-grow: 1; + border-radius: .5rem; +} + + +#extension-privacy-manager-response{ + padding: 2rem; + background-color: rgba(255,0,0,.9); + border-radius: .5rem; + opacity:0; +} + + + + + +/* + +INTERNAL LOGS + +*/ + + +.extension-privacy-manager-deletable_item{ + background-color:rgba(255,255,255,.1); + border-radius:.5rem; +} + +.extension-privacy-manager-deletable_item:hover{ + background-color:red; + cursor: pointer; +} +.extension-privacy-manager-deletable_item::before{ + content: " X "; + color:white; + padding: .7rem .4rem .3rem .8rem; + background-color: red; + border-radius: 1.5rem; + margin-right: 1rem; + margin-top: .2rem; + display: inline-block; + padding: .7rem .8rem .4rem .9rem; + font-size: 1rem; + font-weight: bold; +} +.extension-privacy-manager-deletable_item:hover::before{ + color:red; + background-color: white; +} + + +#extension-privacy-manager-button-delete-all-logs{ + margin-top:2rem; + cursor:pointer; +} +#extension-privacy-manager-button-delete-all-logs:hover{ + background-color:red; +} + + + + + + + + + + + +@media screen and (min-width: 801px) { + #extension-privacy-manager-view{ + left:9.6rem; + top: 0; + height:100vh; + position:absolute; + width: calc(100% - 7.6rem); + } + + .extension-privacy-manager-inline-date{ + margin-right:3rem; + } + + #extension-privacy-manager-content{ + + } + + #extension-privacy-manager-content-container{ + height:auto; + width: calc(100% - 3rem); + } + + /* + .extension-privacy-manager-tab{ + width: calc(100% - 12rem); + } + */ + + #extension-privacy-manager-data-sculptor{ + /*border:1px solid white; + padding:1rem;*/ + display:flex; + /*flex-wrap:wrap;*/ + } + + #extension-privacy-manager-thing-left{ + width:12rem; + min-width:300px; + } + + .extension-privacy-manager-inline{ + display:inline-block; + } + + #extension-privacy-manager-input-change-value{ + width:20rem; + } + + .extension-privacy-manager-inline > span{ + display:inline; + background-color: transparent; + } + + .extension-privacy-manager-inline > button{ + margin-right:4rem; + } + + #extension-privacy-manager-options-pane-buttons button{ + width:auto; + } + + #extension-privacy-manager-response{ + width: calc(100% - 22rem); + } + +} \ No newline at end of file diff --git a/images/menu-icon-open.svg b/images/menu-icon-open.svg new file mode 100644 index 0000000..c2a621f --- /dev/null +++ b/images/menu-icon-open.svg @@ -0,0 +1,125 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/menu-icon.svg b/images/menu-icon.svg new file mode 100644 index 0000000..f5caf89 --- /dev/null +++ b/images/menu-icon.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/js/d3.min.js b/js/d3.min.js new file mode 100644 index 0000000..11c7aca --- /dev/null +++ b/js/d3.min.js @@ -0,0 +1,2 @@ +// https://d3js.org v5.14.2 Copyright 2019 Mike Bostock +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";function n(t,n){return tn?1:t>=n?0:NaN}function e(t){var e;return 1===t.length&&(e=t,t=function(t,r){return n(e(t),r)}),{left:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}var r=e(n),i=r.right,o=r.left;function a(t,n){return[t,n]}function u(t){return null===t?NaN:+t}function c(t,n){var e,r,i=t.length,o=0,a=-1,c=0,f=0;if(null==n)for(;++a1)return f/(o-1)}function f(t,n){var e=c(t,n);return e?Math.sqrt(e):e}function s(t,n){var e,r,i,o=t.length,a=-1;if(null==n){for(;++a=e)for(r=i=e;++ae&&(r=e),i=e)for(r=i=e;++ae&&(r=e),i0)return[t];if((r=n0)for(t=Math.ceil(t/a),n=Math.floor(n/a),o=new Array(i=Math.ceil(n-t+1));++u=0?(o>=y?10:o>=_?5:o>=b?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=y?10:o>=_?5:o>=b?2:1)}function w(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=y?i*=10:o>=_?i*=5:o>=b&&(i*=2),n=1)return+e(t[r-1],r-1,t);var r,i=(r-1)*n,o=Math.floor(i),a=+e(t[o],o,t);return a+(+e(t[o+1],o+1,t)-a)*(i-o)}}function T(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o=e)for(r=e;++or&&(r=e)}else for(;++o=e)for(r=e;++or&&(r=e);return r}function A(t){for(var n,e,r,i=t.length,o=-1,a=0;++o=0;)for(n=(r=t[i]).length;--n>=0;)e[--a]=r[n];return e}function S(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o=e)for(r=e;++oe&&(r=e)}else for(;++o=e)for(r=e;++oe&&(r=e);return r}function k(t){if(!(i=t.length))return[];for(var n=-1,e=S(t,E),r=new Array(e);++n=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})}function X(t,n){for(var e,r=0,i=t.length;r0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(n)?{space:$[n],local:t}:t}function Z(t){var n=W(t);return(n.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===G&&n.documentElement.namespaceURI===G?n.createElement(t):n.createElementNS(e,t)}})(n)}function Q(){}function K(t){return null==t?Q:function(){return this.querySelector(t)}}function J(){return[]}function tt(t){return null==t?J:function(){return this.querySelectorAll(t)}}function nt(t){return function(){return this.matches(t)}}function et(t){return new Array(t.length)}function rt(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}rt.prototype={constructor:rt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var it="$";function ot(t,n,e,r,i,o){for(var a,u=0,c=n.length,f=o.length;un?1:t>=n?0:NaN}function ct(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ft(t,n){return t.style.getPropertyValue(n)||ct(t).getComputedStyle(t,null).getPropertyValue(n)}function st(t){return t.trim().split(/^|\s+/)}function lt(t){return t.classList||new ht(t)}function ht(t){this._node=t,this._names=st(t.getAttribute("class")||"")}function dt(t,n){for(var e=lt(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Mt={};(t.event=null,"undefined"!=typeof document)&&("onmouseenter"in document.documentElement||(Mt={mouseenter:"mouseover",mouseleave:"mouseout"}));function Nt(t,n,e){return t=Tt(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function Tt(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function At(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r=m&&(m=b+1);!(_=g[m])&&++m=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=ut);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof n?function(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}:function(t,n,e){return function(){this.style.setProperty(t,n,e)}})(t,n,null==e?"":e)):ft(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?function(t){return function(){delete this[t]}}:"function"==typeof n?function(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}:function(t,n){return function(){this[t]=n}})(t,n)):this.node()[t]},classed:function(t,n){var e=st(t+"");if(arguments.length<2){for(var r=lt(this.node()),i=-1,o=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?St:At,null==e&&(e=!1),r=0;r>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?new bn(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?new bn(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=on.exec(t))?new bn(n[1],n[2],n[3],1):(n=an.exec(t))?new bn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=un.exec(t))?gn(n[1],n[2],n[3],n[4]):(n=cn.exec(t))?gn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=fn.exec(t))?Mn(n[1],n[2]/100,n[3]/100,1):(n=sn.exec(t))?Mn(n[1],n[2]/100,n[3]/100,n[4]):ln.hasOwnProperty(t)?vn(ln[t]):"transparent"===t?new bn(NaN,NaN,NaN,0):null}function vn(t){return new bn(t>>16&255,t>>8&255,255&t,1)}function gn(t,n,e,r){return r<=0&&(t=n=e=NaN),new bn(t,n,e,r)}function yn(t){return t instanceof Jt||(t=pn(t)),t?new bn((t=t.rgb()).r,t.g,t.b,t.opacity):new bn}function _n(t,n,e,r){return 1===arguments.length?yn(t):new bn(t,n,e,null==r?1:r)}function bn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function mn(){return"#"+wn(this.r)+wn(this.g)+wn(this.b)}function xn(){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 wn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Mn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new An(t,n,e,r)}function Nn(t){if(t instanceof An)return new An(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=pn(t)),!t)return new An;if(t instanceof An)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&c<1?0:a,new An(a,u,c,t.opacity)}function Tn(t,n,e,r){return 1===arguments.length?Nn(t):new An(t,n,e,null==r?1:r)}function An(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Sn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}Qt(Jt,pn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:hn,formatHex:hn,formatHsl:function(){return Nn(this).formatHsl()},formatRgb:dn,toString:dn}),Qt(bn,_n,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new bn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new bn(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:mn,formatHex:mn,formatRgb:xn,toString:xn})),Qt(An,Tn,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new An(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new An(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new bn(Sn(t>=240?t-240:t+120,i,r),Sn(t,i,r),Sn(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 kn=Math.PI/180,En=180/Math.PI,Cn=.96422,Pn=1,zn=.82521,Rn=4/29,Dn=6/29,qn=3*Dn*Dn,Ln=Dn*Dn*Dn;function Un(t){if(t instanceof Bn)return new Bn(t.l,t.a,t.b,t.opacity);if(t instanceof Vn)return Gn(t);t instanceof bn||(t=yn(t));var n,e,r=Hn(t.r),i=Hn(t.g),o=Hn(t.b),a=Fn((.2225045*r+.7168786*i+.0606169*o)/Pn);return r===i&&i===o?n=e=a:(n=Fn((.4360747*r+.3850649*i+.1430804*o)/Cn),e=Fn((.0139322*r+.0971045*i+.7141733*o)/zn)),new Bn(116*a-16,500*(n-a),200*(a-e),t.opacity)}function On(t,n,e,r){return 1===arguments.length?Un(t):new Bn(t,n,e,null==r?1:r)}function Bn(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Fn(t){return t>Ln?Math.pow(t,1/3):t/qn+Rn}function Yn(t){return t>Dn?t*t*t:qn*(t-Rn)}function In(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function jn(t){if(t instanceof Vn)return new Vn(t.h,t.c,t.l,t.opacity);if(t instanceof Bn||(t=Un(t)),0===t.a&&0===t.b)return new Vn(NaN,0=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r180||e<-180?e-360*Math.round(e/360):e):ue(isNaN(t)?n:t)}function se(t){return 1==(t=+t)?le:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):ue(isNaN(n)?e:n)}}function le(t,n){var e=n-t;return e?ce(t,e):ue(isNaN(t)?n:t)}Qt(re,ee,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new re(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new re(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*kn,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),r=Math.cos(t),i=Math.sin(t);return new bn(255*(n+e*($n*r+Wn*i)),255*(n+e*(Zn*r+Qn*i)),255*(n+e*(Kn*r)),this.opacity)}}));var he=function t(n){var e=se(n);function r(t,n){var r=e((t=_n(t)).r,(n=_n(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=le(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function de(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;eo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,c.push({i:a,x:_e(e,r)})),o=xe.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:_e(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,c),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:_e(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,c),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:_e(t,e)},{i:u-2,x:_e(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,c),o=a=null,function(t){for(var n,e=-1,r=c.length;++e=0&&n._call.call(null,t),n=n._next;--Ke}function hr(){rr=(er=or.now())+ir,Ke=Je=0;try{lr()}finally{Ke=0,function(){var t,n,e=Ze,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ze=n);Qe=t,pr(r)}(),rr=0}}function dr(){var t=or.now(),n=t-er;n>nr&&(ir-=n,er=t)}function pr(t){Ke||(Je&&(Je=clearTimeout(Je)),t-rr>24?(t<1/0&&(Je=setTimeout(hr,t-or.now()-ir)),tr&&(tr=clearInterval(tr))):(tr||(er=or.now(),tr=setInterval(dr,nr)),Ke=1,ar(hr)))}function vr(t,n,e){var r=new fr;return n=null==n?0:+n,r.restart(function(e){r.stop(),t(e+n)},n,e),r}fr.prototype=sr.prototype={constructor:fr,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?ur():+e)+(null==n?0:+n),this._next||Qe===this||(Qe?Qe._next=this:Ze=this,Qe=this),this._call=t,this._time=e,pr()},stop:function(){this._call&&(this._call=null,this._time=1/0,pr())}};var gr=I("start","end","cancel","interrupt"),yr=[],_r=0,br=1,mr=2,xr=3,wr=4,Mr=5,Nr=6;function Tr(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(c){var f,s,l,h;if(e.state!==br)return u();for(f in i)if((h=i[f]).name===e.name){if(h.state===xr)return vr(o);h.state===wr?(h.state=Nr,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+f_r)throw new Error("too late; already scheduled");return e}function Sr(t,n){var e=kr(t,n);if(e.state>xr)throw new Error("too late; already running");return e}function kr(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Er(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>mr&&e.state=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?Ar:Sr;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=W(t),r="transform"===e?De:Pr;return this.attrTween(t,"function"==typeof n?(e.local?function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttributeNS(t.space,t.local))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttributeNS(t.space,t.local)}}:function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttribute(t))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttribute(t)}})(e,r,Cr(this,"attr."+t,n)):null==n?(e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(e):(e.local?function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=n(r=a,e)}}:function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=n(r=a,e)}})(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=W(t);return this.tween(e,(r.local?function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}(t,i)),e}return i._value=n,i}:function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}(t,i)),e}return i._value=n,i})(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Re:Pr;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=ft(this,t),a=(this.style.removeProperty(t),ft(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,Rr(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=ft(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=ft(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,Cr(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=Sr(this,t),f=c.on,s=null==c.value[a]?o||(o=Rr(n)):void 0;f===e&&i===s||(r=(e=f).copy()).on(u,i=s),c.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=ft(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(Cr(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=kr(this.node(),e).tween,o=0,a=i.length;o0&&(r=o-P),M<0?d=p-z:M>0&&(u=c-z),x=xi,B.attr("cursor",Ei.selection),I());break;default:return}bi()},!0).on("keyup.brush",function(){switch(t.event.keyCode){case 16:R&&(g=y=R=!1,I());break;case 18:x===Mi&&(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=wi,I());break;case 32:x===xi&&(t.event.altKey?(w&&(f=h-P*w,r=o+P*w),M&&(d=p-z*M,u=c+z*M),x=Mi):(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=wi),B.attr("cursor",Ei[m]),I());break;default:return}bi()},!0),Ht(t.event.view)}_i(),Er(b),s.call(b),U.start()}function Y(){var t=D(b);!R||g||y||(Math.abs(t[0]-L[0])>Math.abs(t[1]-L[1])?y=!0:g=!0),L=t,v=!0,bi(),I()}function I(){var t;switch(P=L[0]-q[0],z=L[1]-q[1],x){case xi:case mi:w&&(P=Math.max(S-r,Math.min(E-f,P)),o=r+P,h=f+P),M&&(z=Math.max(k-u,Math.min(C-d,z)),c=u+z,p=d+z);break;case wi:w<0?(P=Math.max(S-r,Math.min(E-r,P)),o=r+P,h=f):w>0&&(P=Math.max(S-f,Math.min(E-f,P)),o=r,h=f+P),M<0?(z=Math.max(k-u,Math.min(C-u,z)),c=u+z,p=d):M>0&&(z=Math.max(k-d,Math.min(C-d,z)),c=u,p=d+z);break;case Mi:w&&(o=Math.max(S,Math.min(E,r-P*w)),h=Math.max(S,Math.min(E,f+P*w))),M&&(c=Math.max(k,Math.min(C,u-z*M)),p=Math.max(k,Math.min(C,d+z*M)))}h1e-6)if(Math.abs(s*u-c*f)>1e-6&&i){var h=e-o,d=r-a,p=u*u+c*c,v=h*h+d*d,g=Math.sqrt(p),y=Math.sqrt(l),_=i*Math.tan((Wi-Math.acos((p+l-v)/(2*g*y)))/2),b=_/y,m=_/g;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*f)+","+(n+b*s)),this._+="A"+i+","+i+",0,0,"+ +(s*h>f*d)+","+(this._x1=t+m*u)+","+(this._y1=n+m*c)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),u=e*Math.sin(r),c=t+a,f=n+u,s=1^o,l=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+c+","+f:(Math.abs(this._x1-c)>1e-6||Math.abs(this._y1-f)>1e-6)&&(this._+="L"+c+","+f),e&&(l<0&&(l=l%Zi+Zi),l>Qi?this._+="A"+e+","+e+",0,1,"+s+","+(t-a)+","+(n-u)+"A"+e+","+e+",0,1,"+s+","+(this._x1=c)+","+(this._y1=f):l>1e-6&&(this._+="A"+e+","+e+",0,"+ +(l>=Wi)+","+s+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};function oo(){}function ao(t,n){var e=new oo;if(t instanceof oo)t.each(function(t,n){e.set(n,t)});else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++ir!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function mo(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function xo(){}var wo=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Mo(){var t=1,n=1,e=M,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(go);else{var r=s(t),i=r[0],a=r[1];n=w(i,a,n),n=g(Math.floor(i/n)*n,Math.floor(a/n)*n,n)}return n.map(function(n){return o(t,n)})}function o(e,i){var o=[],u=[];return function(e,r,i){var o,u,c,f,s,l,h=new Array,d=new Array;o=u=-1,f=e[0]>=r,wo[f<<1].forEach(p);for(;++o=r,wo[c|f<<1].forEach(p);wo[f<<0].forEach(p);for(;++u=r,s=e[u*t]>=r,wo[f<<1|s<<2].forEach(p);++o=r,l=s,s=e[u*t+o+1]>=r,wo[c|f<<1|s<<2|l<<3].forEach(p);wo[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,wo[s<<2].forEach(p);for(;++o=r,wo[s<<2|l<<3].forEach(p);function p(t){var n,e,r=[t[0][0]+o,t[0][1]+u],c=[t[1][0]+o,t[1][1]+u],f=a(r),s=a(c);(n=d[f])?(e=h[s])?(delete d[n.end],delete h[e.start],n===e?(n.ring.push(c),i(n.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[n.end],n.ring.push(c),d[n.end=s]=n):(n=h[s])?(e=d[f])?(delete h[n.start],delete d[e.end],n===e?(n.ring.push(c),i(n.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[n.start],n.ring.unshift(r),h[n.start=f]=n):h[f]=d[s]={start:f,end:s,ring:[r,c]}}wo[s<<3].forEach(p)}(e,i,function(t){r(t,e,i),function(t){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n0?o.push([t]):u.push(t)}),u.forEach(function(t){for(var n,e=0,r=o.length;e0&&a0&&u0&&o>0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?yo(vo.call(t)):yo(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:xo,i):r===u},i}function No(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[u-o+a*r]),n.data[u-e+a*r]=c/Math.min(u+1,r-1+o-u,o))}function To(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[a+(u-o)*r]),n.data[a+(u-e)*r]=c/Math.min(u+1,i-1+o-u,o))}function Ao(t){return t[0]}function So(t){return t[1]}function ko(){return 1}var Eo={},Co={},Po=34,zo=10,Ro=13;function Do(t){return new Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+'] || ""'}).join(",")+"}")}function qo(t){var n=Object.create(null),e=[];return t.forEach(function(t){for(var r in t)r in n||e.push(n[r]=r)}),e}function Lo(t,n){var e=t+"",r=e.length;return r9999?"+"+Lo(t,6):Lo(t,4)}(t.getUTCFullYear())+"-"+Lo(t.getUTCMonth()+1,2)+"-"+Lo(t.getUTCDate(),2)+(i?"T"+Lo(n,2)+":"+Lo(e,2)+":"+Lo(r,2)+"."+Lo(i,3)+"Z":r?"T"+Lo(n,2)+":"+Lo(e,2)+":"+Lo(r,2)+"Z":e||n?"T"+Lo(n,2)+":"+Lo(e,2)+"Z":"")}function Oo(t){var n=new RegExp('["'+t+"\n\r]"),e=t.charCodeAt(0);function r(t,n){var r,i=[],o=t.length,a=0,u=0,c=o<=0,f=!1;function s(){if(c)return Co;if(f)return f=!1,Eo;var n,r,i=a;if(t.charCodeAt(i)===Po){for(;a++=o?c=!0:(r=t.charCodeAt(a++))===zo?f=!0:r===Ro&&(f=!0,t.charCodeAt(a)===zo&&++a),t.slice(i+1,n-1).replace(/""/g,'"')}for(;a=(o=(v+y)/2))?v=o:y=o,(s=e>=(a=(g+_)/2))?g=a:_=a,i=d,!(d=d[l=s<<1|f]))return i[l]=p,t;if(u=+t._x.call(null,d.data),c=+t._y.call(null,d.data),n===u&&e===c)return p.next=d,i?i[l]=p:t._root=p,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(f=n>=(o=(v+y)/2))?v=o:y=o,(s=e>=(a=(g+_)/2))?g=a:_=a}while((l=s<<1|f)==(h=(c>=a)<<1|u>=o));return i[h]=d,i[l]=p,t}function ya(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function _a(t){return t[0]}function ba(t){return t[1]}function ma(t,n,e){var r=new xa(null==n?_a:n,null==e?ba:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function xa(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function wa(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var Ma=ma.prototype=xa.prototype;function Na(t){return t.x+t.vx}function Ta(t){return t.y+t.vy}function Aa(t){return t.index}function Sa(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}function ka(t){return t.x}function Ea(t){return t.y}Ma.copy=function(){var t,n,e=new xa(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=wa(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=wa(n));return e},Ma.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return ga(this.cover(n,e),n,e,t)},Ma.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),c=1/0,f=1/0,s=-1/0,l=-1/0;for(e=0;es&&(s=r),il&&(l=i));if(c>s||f>l)return this;for(this.cover(c,f).cover(s,l),e=0;et||t>=i||r>n||n>=o;)switch(u=(nh||(o=c.y0)>d||(a=c.x1)=y)<<1|t>=g)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var _=t-+this._x.call(null,v.data),b=n-+this._y.call(null,v.data),m=_*_+b*b;if(m=(u=(p+g)/2))?p=u:g=u,(s=a>=(c=(v+y)/2))?v=c:y=c,n=d,!(d=d[l=s<<1|f]))return this;if(!d.length)break;(n[l+1&3]||n[l+2&3]||n[l+3&3])&&(e=n,h=l)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):n?(i?n[l]=i:delete n[l],(d=n[0]||n[1]||n[2]||n[3])&&d===(n[3]||n[2]||n[1]||n[0])&&!d.length&&(e?e[h]=d:this._root=d),this):(this._root=i,this)},Ma.removeAll=function(t){for(var n=0,e=t.length;n1?r[0]+r.slice(2):r,+t.slice(e+1)]}function Ra(t){return(t=za(Math.abs(t)))?t[1]:NaN}var Da,qa=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function La(t){if(!(n=qa.exec(t)))throw new Error("invalid format: "+t);var n;return new Ua({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function Ua(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 Oa(t,n){var e=za(t,n);if(!e)return t+"";var r=e[0],i=e[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")}La.prototype=Ua.prototype,Ua.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 Ba={"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return Oa(100*t,n)},r:Oa,s:function(t,n){var e=za(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(Da=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+za(t,Math.max(0,n+o-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function Fa(t){return t}var Ya,Ia=Array.prototype.map,Ha=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ja(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?Fa:(n=Ia.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,u=n[0],c=0;i>0&&u>0&&(c+u+1>r&&(u=Math.max(1,r-c)),o.push(t.substring(i-=u,i+u)),!((c+=u+1)>r));)u=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?Fa:function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}}(Ia.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",f=void 0===t.minus?"-":t.minus+"",s=void 0===t.nan?"NaN":t.nan+"";function l(t){var n=(t=La(t)).fill,e=t.align,l=t.sign,h=t.symbol,d=t.zero,p=t.width,v=t.comma,g=t.precision,y=t.trim,_=t.type;"n"===_?(v=!0,_="g"):Ba[_]||(void 0===g&&(g=12),y=!0,_="g"),(d||"0"===n&&"="===e)&&(d=!0,n="0",e="=");var b="$"===h?i:"#"===h&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",m="$"===h?o:/[%p]/.test(_)?c:"",x=Ba[_],w=/[defgprs%]/.test(_);function M(t){var i,o,c,h=b,M=m;if("c"===_)M=x(t)+M,t="";else{var N=(t=+t)<0;if(t=isNaN(t)?s:x(Math.abs(t),g),y&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r0){if(!+t[r])break t;i=0}}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),N&&0==+t&&(N=!1),h=(N?"("===l?l:f:"-"===l||"("===l?"":l)+h,M=("s"===_?Ha[8+Da/3]:"")+M+(N&&"("===l?")":""),w)for(i=-1,o=t.length;++i(c=t.charCodeAt(i))||c>57){M=(46===c?a+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}v&&!d&&(t=r(t,1/0));var T=h.length+t.length+M.length,A=T>1)+h+t+M+A.slice(T);break;default:t=A+h+t+M}return u(t)}return g=void 0===g?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=La(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ra(n)/3))),i=Math.pow(10,-r),o=Ha[8+r/3];return function(t){return e(i*t)+o}}}}function Xa(n){return Ya=ja(n),t.format=Ya.format,t.formatPrefix=Ya.formatPrefix,Ya}function Va(t){return Math.max(0,-Ra(Math.abs(t)))}function Ga(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ra(n)/3)))-Ra(Math.abs(t)))}function $a(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Ra(n)-Ra(t))+1}function Wa(){return new Za}function Za(){this.reset()}Xa({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"}),Za.prototype={constructor:Za,reset:function(){this.s=this.t=0},add:function(t){Ka(Qa,t,this.t),Ka(this,Qa.s,this.s),this.s?this.t+=Qa.t:this.s=Qa.t},valueOf:function(){return this.s}};var Qa=new Za;function Ka(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Ja=1e-6,tu=1e-12,nu=Math.PI,eu=nu/2,ru=nu/4,iu=2*nu,ou=180/nu,au=nu/180,uu=Math.abs,cu=Math.atan,fu=Math.atan2,su=Math.cos,lu=Math.ceil,hu=Math.exp,du=Math.log,pu=Math.pow,vu=Math.sin,gu=Math.sign||function(t){return t>0?1:t<0?-1:0},yu=Math.sqrt,_u=Math.tan;function bu(t){return t>1?0:t<-1?nu:Math.acos(t)}function mu(t){return t>1?eu:t<-1?-eu:Math.asin(t)}function xu(t){return(t=vu(t/2))*t}function wu(){}function Mu(t,n){t&&Tu.hasOwnProperty(t.type)&&Tu[t.type](t,n)}var Nu={Feature:function(t,n){Mu(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=su(n=(n*=au)/2+ru),a=vu(n),u=Ru*a,c=zu*o+u*su(i),f=u*r*vu(i);Du.add(fu(f,c)),Pu=t,zu=o,Ru=a}function Yu(t){return[fu(t[1],t[0]),mu(t[2])]}function Iu(t){var n=t[0],e=t[1],r=su(e);return[r*su(n),r*vu(n),vu(e)]}function Hu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ju(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Xu(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Vu(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Gu(t){var n=yu(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var $u,Wu,Zu,Qu,Ku,Ju,tc,nc,ec,rc,ic,oc,ac,uc,cc,fc,sc,lc,hc,dc,pc,vc,gc,yc,_c,bc,mc=Wa(),xc={point:wc,lineStart:Nc,lineEnd:Tc,polygonStart:function(){xc.point=Ac,xc.lineStart=Sc,xc.lineEnd=kc,mc.reset(),Lu.polygonStart()},polygonEnd:function(){Lu.polygonEnd(),xc.point=wc,xc.lineStart=Nc,xc.lineEnd=Tc,Du<0?($u=-(Zu=180),Wu=-(Qu=90)):mc>Ja?Qu=90:mc<-Ja&&(Wu=-90),rc[0]=$u,rc[1]=Zu},sphere:function(){$u=-(Zu=180),Wu=-(Qu=90)}};function wc(t,n){ec.push(rc=[$u=t,Zu=t]),nQu&&(Qu=n)}function Mc(t,n){var e=Iu([t*au,n*au]);if(nc){var r=ju(nc,e),i=ju([r[1],-r[0],0],r);Gu(i),i=Yu(i);var o,a=t-Ku,u=a>0?1:-1,c=i[0]*ou*u,f=uu(a)>180;f^(u*KuQu&&(Qu=o):f^(u*Ku<(c=(c+360)%360-180)&&cQu&&(Qu=n)),f?tEc($u,Zu)&&(Zu=t):Ec(t,Zu)>Ec($u,Zu)&&($u=t):Zu>=$u?(t<$u&&($u=t),t>Zu&&(Zu=t)):t>Ku?Ec($u,t)>Ec($u,Zu)&&(Zu=t):Ec(t,Zu)>Ec($u,Zu)&&($u=t)}else ec.push(rc=[$u=t,Zu=t]);nQu&&(Qu=n),nc=e,Ku=t}function Nc(){xc.point=Mc}function Tc(){rc[0]=$u,rc[1]=Zu,xc.point=wc,nc=null}function Ac(t,n){if(nc){var e=t-Ku;mc.add(uu(e)>180?e+(e>0?360:-360):e)}else Ju=t,tc=n;Lu.point(t,n),Mc(t,n)}function Sc(){Lu.lineStart()}function kc(){Ac(Ju,tc),Lu.lineEnd(),uu(mc)>Ja&&($u=-(Zu=180)),rc[0]=$u,rc[1]=Zu,nc=null}function Ec(t,n){return(n-=t)<0?n+360:n}function Cc(t,n){return t[0]-n[0]}function Pc(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nnu?t+Math.round(-t/iu)*iu:t,n]}function Vc(t,n,e){return(t%=iu)?n||e?jc($c(t),Wc(n,e)):$c(t):n||e?Wc(n,e):Xc}function Gc(t){return function(n,e){return[(n+=t)>nu?n-iu:n<-nu?n+iu:n,e]}}function $c(t){var n=Gc(t);return n.invert=Gc(-t),n}function Wc(t,n){var e=su(t),r=vu(t),i=su(n),o=vu(n);function a(t,n){var a=su(n),u=su(t)*a,c=vu(t)*a,f=vu(n),s=f*e+u*r;return[fu(c*i-s*o,u*e-f*r),mu(s*i+c*o)]}return a.invert=function(t,n){var a=su(n),u=su(t)*a,c=vu(t)*a,f=vu(n),s=f*i-c*o;return[fu(c*i+f*o,u*e+s*r),mu(s*e-u*r)]},a}function Zc(t){function n(n){return(n=t(n[0]*au,n[1]*au))[0]*=ou,n[1]*=ou,n}return t=Vc(t[0]*au,t[1]*au,t.length>2?t[2]*au:0),n.invert=function(n){return(n=t.invert(n[0]*au,n[1]*au))[0]*=ou,n[1]*=ou,n},n}function Qc(t,n,e,r,i,o){if(e){var a=su(n),u=vu(n),c=r*e;null==i?(i=n+r*iu,o=n-c/2):(i=Kc(a,i),o=Kc(a,o),(r>0?io)&&(i+=r*iu));for(var f,s=i;r>0?s>o:s1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function tf(t,n){return uu(t[0]-n[0])=0;--o)i.point((s=f[o])[0],s[1]);else r(h.x,h.p.x,-1,i);h=h.p}f=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function rf(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,T=N*M,A=T>nu,S=v*x;if(of.add(fu(S*N*vu(T),g*w+S*su(T))),a+=A?M+N*iu:M,A^d>=e^b>=e){var k=ju(Iu(h),Iu(_));Gu(k);var E=ju(o,k);Gu(E);var C=(A^M>=0?-1:1)*mu(E[2]);(r>C||r===C&&(k[0]||k[1]))&&(u+=A^M>=0?1:-1)}}return(a<-Ja||a0){for(l||(i.polygonStart(),l=!0),i.lineStart(),t=0;t1&&2&c&&h.push(h.pop().concat(h.shift())),a.push(h.filter(ff))}return h}}function ff(t){return t.length>1}function sf(t,n){return((t=t.x)[0]<0?t[1]-eu-Ja:eu-t[1])-((n=n.x)[0]<0?n[1]-eu-Ja:eu-n[1])}var lf=cf(function(){return!0},function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?nu:-nu,c=uu(o-e);uu(c-nu)0?eu:-eu),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&c>=nu&&(uu(e-i)Ja?cu((vu(n)*(o=su(r))*vu(e)-vu(r)*(i=su(n))*vu(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}},function(t,n,e,r){var i;if(null==t)i=e*eu,r.point(-nu,i),r.point(0,i),r.point(nu,i),r.point(nu,0),r.point(nu,-i),r.point(0,-i),r.point(-nu,-i),r.point(-nu,0),r.point(-nu,i);else if(uu(t[0]-n[0])>Ja){var o=t[0]0,i=uu(n)>Ja;function o(t,e){return su(t)*su(e)>n}function a(t,e,r){var i=[1,0,0],o=ju(Iu(t),Iu(e)),a=Hu(o,o),u=o[0],c=a-u*u;if(!c)return!r&&t;var f=n*a/c,s=-n*u/c,l=ju(i,o),h=Vu(i,f);Xu(h,Vu(o,s));var d=l,p=Hu(h,d),v=Hu(d,d),g=p*p-v*(Hu(h,h)-1);if(!(g<0)){var y=yu(g),_=Vu(d,(-p-y)/v);if(Xu(_,h),_=Yu(_),!r)return _;var b,m=t[0],x=e[0],w=t[1],M=e[1];x0^_[1]<(uu(_[0]-m)nu^(m<=_[0]&&_[0]<=x)){var A=Vu(d,(-p+y)/v);return Xu(A,h),[_,Yu(A)]}}}function u(n,e){var i=r?t:nu-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return cf(o,function(t){var n,e,c,f,s;return{lineStart:function(){f=c=!1,s=1},point:function(l,h){var d,p=[l,h],v=o(l,h),g=r?v?0:u(l,h):v?u(l+(l<0?nu:-nu),h):0;if(!n&&(f=c=v)&&t.lineStart(),v!==c&&(!(d=a(n,p))||tf(n,d)||tf(p,d))&&(p[0]+=Ja,p[1]+=Ja,v=o(p[0],p[1])),v!==c)s=0,v?(t.lineStart(),d=a(p,n),t.point(d[0],d[1])):(d=a(n,p),t.point(d[0],d[1]),t.lineEnd()),n=d;else if(i&&n&&r^v){var y;g&e||!(y=a(p,n,!0))||(s=0,r?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!v||n&&tf(n,p)||t.point(p[0],p[1]),n=p,c=v,e=g},lineEnd:function(){c&&t.lineEnd(),n=null},clean:function(){return s|(f&&c)<<1}}},function(n,r,i,o){Qc(o,t,e,i,n,r)},r?[0,-t]:[-nu,t-nu])}var df=1e9,pf=-df;function vf(t,n,e,r){function i(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function o(i,o,u,f){var s=0,l=0;if(null==i||(s=a(i,u))!==(l=a(o,u))||c(i,o)<0^u>0)do{f.point(0===s||3===s?t:e,s>1?r:n)}while((s=(s+u+4)%4)!==l);else f.point(o[0],o[1])}function a(r,i){return uu(r[0]-t)0?0:3:uu(r[0]-e)0?2:1:uu(r[1]-n)0?1:0:i>0?3:2}function u(t,n){return c(t.x,n.x)}function c(t,n){var e=a(t,1),r=a(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}return function(a){var c,f,s,l,h,d,p,v,g,y,_,b=a,m=Jc(),x={point:w,lineStart:function(){x.point=M,f&&f.push(s=[]);y=!0,g=!1,p=v=NaN},lineEnd:function(){c&&(M(l,h),d&&g&&m.rejoin(),c.push(m.result()));x.point=w,g&&b.lineEnd()},polygonStart:function(){b=m,c=[],f=[],_=!0},polygonEnd:function(){var n=function(){for(var n=0,e=0,i=f.length;er&&(h-o)*(r-a)>(d-a)*(t-o)&&++n:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--n;return n}(),e=_&&n,i=(c=A(c)).length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&ef(c,u,n,o,a),a.polygonEnd());b=a,c=f=s=null}};function w(t,n){i(t,n)&&b.point(t,n)}function M(o,a){var u=i(o,a);if(f&&s.push([o,a]),y)l=o,h=a,d=u,y=!1,u&&(b.lineStart(),b.point(o,a));else if(u&&g)b.point(o,a);else{var c=[p=Math.max(pf,Math.min(df,p)),v=Math.max(pf,Math.min(df,v))],m=[o=Math.max(pf,Math.min(df,o)),a=Math.max(pf,Math.min(df,a))];!function(t,n,e,r,i,o){var a,u=t[0],c=t[1],f=0,s=1,l=n[0]-u,h=n[1]-c;if(a=e-u,l||!(a>0)){if(a/=l,l<0){if(a0){if(a>s)return;a>f&&(f=a)}if(a=i-u,l||!(a<0)){if(a/=l,l<0){if(a>s)return;a>f&&(f=a)}else if(l>0){if(a0)){if(a/=h,h<0){if(a0){if(a>s)return;a>f&&(f=a)}if(a=o-c,h||!(a<0)){if(a/=h,h<0){if(a>s)return;a>f&&(f=a)}else if(h>0){if(a0&&(t[0]=u+f*l,t[1]=c+f*h),s<1&&(n[0]=u+s*l,n[1]=c+s*h),!0}}}}}(c,m,t,n,e,r)?u&&(b.lineStart(),b.point(o,a),_=!1):(g||(b.lineStart(),b.point(c[0],c[1])),b.point(m[0],m[1]),u||b.lineEnd(),_=!1)}p=o,v=a,g=u}return x}}var gf,yf,_f,bf=Wa(),mf={sphere:wu,point:wu,lineStart:function(){mf.point=wf,mf.lineEnd=xf},lineEnd:wu,polygonStart:wu,polygonEnd:wu};function xf(){mf.point=mf.lineEnd=wu}function wf(t,n){gf=t*=au,yf=vu(n*=au),_f=su(n),mf.point=Mf}function Mf(t,n){t*=au;var e=vu(n*=au),r=su(n),i=uu(t-gf),o=su(i),a=r*vu(i),u=_f*e-yf*r*o,c=yf*e+_f*r*o;bf.add(fu(yu(a*a+u*u),c)),gf=t,yf=e,_f=r}function Nf(t){return bf.reset(),ku(t,mf),+bf}var Tf=[null,null],Af={type:"LineString",coordinates:Tf};function Sf(t,n){return Tf[0]=t,Tf[1]=n,Nf(Af)}var kf={Feature:function(t,n){return Cf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r0&&(i=Sf(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))Ja}).map(c)).concat(g(lu(o/d)*d,i,d).filter(function(t){return uu(t%v)>Ja}).map(f))}return _.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},_.outline=function(){return{type:"Polygon",coordinates:[s(r).concat(l(a).slice(1),s(e).reverse().slice(1),l(u).reverse().slice(1))]}},_.extent=function(t){return arguments.length?_.extentMajor(t).extentMinor(t):_.extentMinor()},_.extentMajor=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),u>a&&(t=u,u=a,a=t),_.precision(y)):[[r,u],[e,a]]},_.extentMinor=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],o=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),o>i&&(e=o,o=i,i=e),_.precision(y)):[[n,o],[t,i]]},_.step=function(t){return arguments.length?_.stepMajor(t).stepMinor(t):_.stepMinor()},_.stepMajor=function(t){return arguments.length?(p=+t[0],v=+t[1],_):[p,v]},_.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],_):[h,d]},_.precision=function(h){return arguments.length?(y=+h,c=Lf(o,i,90),f=Uf(n,t,y),s=Lf(u,a,90),l=Uf(r,e,y),_):y},_.extentMajor([[-180,-90+Ja],[180,90-Ja]]).extentMinor([[-180,-80-Ja],[180,80+Ja]])}function Bf(t){return t}var Ff,Yf,If,Hf,jf=Wa(),Xf=Wa(),Vf={point:wu,lineStart:wu,lineEnd:wu,polygonStart:function(){Vf.lineStart=Gf,Vf.lineEnd=Zf},polygonEnd:function(){Vf.lineStart=Vf.lineEnd=Vf.point=wu,jf.add(uu(Xf)),Xf.reset()},result:function(){var t=jf/2;return jf.reset(),t}};function Gf(){Vf.point=$f}function $f(t,n){Vf.point=Wf,Ff=If=t,Yf=Hf=n}function Wf(t,n){Xf.add(Hf*t-If*n),If=t,Hf=n}function Zf(){Wf(Ff,Yf)}var Qf=1/0,Kf=Qf,Jf=-Qf,ts=Jf,ns={point:function(t,n){tJf&&(Jf=t);nts&&(ts=n)},lineStart:wu,lineEnd:wu,polygonStart:wu,polygonEnd:wu,result:function(){var t=[[Qf,Kf],[Jf,ts]];return Jf=ts=-(Kf=Qf=1/0),t}};var es,rs,is,os,as=0,us=0,cs=0,fs=0,ss=0,ls=0,hs=0,ds=0,ps=0,vs={point:gs,lineStart:ys,lineEnd:ms,polygonStart:function(){vs.lineStart=xs,vs.lineEnd=ws},polygonEnd:function(){vs.point=gs,vs.lineStart=ys,vs.lineEnd=ms},result:function(){var t=ps?[hs/ps,ds/ps]:ls?[fs/ls,ss/ls]:cs?[as/cs,us/cs]:[NaN,NaN];return as=us=cs=fs=ss=ls=hs=ds=ps=0,t}};function gs(t,n){as+=t,us+=n,++cs}function ys(){vs.point=_s}function _s(t,n){vs.point=bs,gs(is=t,os=n)}function bs(t,n){var e=t-is,r=n-os,i=yu(e*e+r*r);fs+=i*(is+t)/2,ss+=i*(os+n)/2,ls+=i,gs(is=t,os=n)}function ms(){vs.point=gs}function xs(){vs.point=Ms}function ws(){Ns(es,rs)}function Ms(t,n){vs.point=Ns,gs(es=is=t,rs=os=n)}function Ns(t,n){var e=t-is,r=n-os,i=yu(e*e+r*r);fs+=i*(is+t)/2,ss+=i*(os+n)/2,ls+=i,hs+=(i=os*t-is*n)*(is+t),ds+=i*(os+n),ps+=3*i,gs(is=t,os=n)}function Ts(t){this._context=t}Ts.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._context.moveTo(t,n),this._point=1;break;case 1:this._context.lineTo(t,n);break;default:this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,iu)}},result:wu};var As,Ss,ks,Es,Cs,Ps=Wa(),zs={point:wu,lineStart:function(){zs.point=Rs},lineEnd:function(){As&&Ds(Ss,ks),zs.point=wu},polygonStart:function(){As=!0},polygonEnd:function(){As=null},result:function(){var t=+Ps;return Ps.reset(),t}};function Rs(t,n){zs.point=Ds,Ss=Es=t,ks=Cs=n}function Ds(t,n){Es-=t,Cs-=n,Ps.add(yu(Es*Es+Cs*Cs)),Es=t,Cs=n}function qs(){this._string=[]}function Ls(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Us(t){return function(n){var e=new Os;for(var r in t)e[r]=t[r];return e.stream=n,e}}function Os(){}function Bs(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),ku(e,t.stream(ns)),n(ns.result()),null!=r&&t.clipExtent(r),t}function Fs(t,n,e){return Bs(t,function(e){var r=n[1][0]-n[0][0],i=n[1][1]-n[0][1],o=Math.min(r/(e[1][0]-e[0][0]),i/(e[1][1]-e[0][1])),a=+n[0][0]+(r-o*(e[1][0]+e[0][0]))/2,u=+n[0][1]+(i-o*(e[1][1]+e[0][1]))/2;t.scale(150*o).translate([a,u])},e)}function Ys(t,n,e){return Fs(t,[[0,0],n],e)}function Is(t,n,e){return Bs(t,function(e){var r=+n,i=r/(e[1][0]-e[0][0]),o=(r-i*(e[1][0]+e[0][0]))/2,a=-i*e[0][1];t.scale(150*i).translate([o,a])},e)}function Hs(t,n,e){return Bs(t,function(e){var r=+n,i=r/(e[1][1]-e[0][1]),o=-i*e[0][0],a=(r-i*(e[1][1]+e[0][1]))/2;t.scale(150*i).translate([o,a])},e)}qs.prototype={_radius:4.5,_circle:Ls(4.5),pointRadius:function(t){return(t=+t)!==this._radius&&(this._radius=t,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._string.push("M",t,",",n),this._point=1;break;case 1:this._string.push("L",t,",",n);break;default:null==this._circle&&(this._circle=Ls(this._radius)),this._string.push("M",t,",",n,this._circle)}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}return null}},Os.prototype={constructor:Os,point:function(t,n){this.stream.point(t,n)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var js=16,Xs=su(30*au);function Vs(t,n){return+n?function(t,n){function e(r,i,o,a,u,c,f,s,l,h,d,p,v,g){var y=f-r,_=s-i,b=y*y+_*_;if(b>4*n&&v--){var m=a+h,x=u+d,w=c+p,M=yu(m*m+x*x+w*w),N=mu(w/=M),T=uu(uu(w)-1)n||uu((y*E+_*C)/b-.5)>.3||a*h+u*d+c*p2?t[2]%360*au:0,S()):[g*ou,y*ou,_*ou]},T.angle=function(t){return arguments.length?(b=t%360*au,S()):b*ou},T.precision=function(t){return arguments.length?(a=Vs(u,N=t*t),k()):yu(N)},T.fitExtent=function(t,n){return Fs(T,t,n)},T.fitSize=function(t,n){return Ys(T,t,n)},T.fitWidth=function(t,n){return Is(T,t,n)},T.fitHeight=function(t,n){return Hs(T,t,n)},function(){return n=t.apply(this,arguments),T.invert=n.invert&&A,S()}}function Qs(t){var n=0,e=nu/3,r=Zs(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*au,e=t[1]*au):[n*ou,e*ou]},i}function Ks(t,n){var e=vu(t),r=(e+vu(n))/2;if(uu(r)0?n<-eu+Ja&&(n=-eu+Ja):n>eu-Ja&&(n=eu-Ja);var e=i/pu(ul(n),r);return[e*vu(r*t),i-e*su(r*t)]}return o.invert=function(t,n){var e=i-n,o=gu(r)*yu(t*t+e*e);return[fu(t,uu(e))/r*gu(e),2*cu(pu(i/o,1/r))-eu]},o}function fl(t,n){return[t,n]}function sl(t,n){var e=su(t),r=t===n?vu(t):(e-su(n))/(n-t),i=e/r+t;if(uu(r)=0;)n+=e[r].value;else n=1;t.value=n}function Sl(t,n){var e,r,i,o,a,u=new Pl(t),c=+t.value&&(u.value=t.value),f=[u];for(null==n&&(n=kl);e=f.pop();)if(c&&(e.value=+e.data.value),(i=n(e.data))&&(a=i.length))for(e.children=new Array(a),o=a-1;o>=0;--o)f.push(r=e.children[o]=new Pl(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(Cl)}function kl(t){return t.children}function El(t){t.data=t.data.data}function Cl(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function Pl(t){this.data=t,this.depth=this.height=0,this.parent=null}gl.invert=function(t,n){for(var e,r=n,i=r*r,o=i*i*i,a=0;a<12&&(o=(i=(r-=e=(r*(ll+hl*i+o*(dl+pl*i))-n)/(ll+3*hl*i+o*(7*dl+9*pl*i)))*r)*i*i,!(uu(e)Ja&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},ml.invert=el(mu),xl.invert=el(function(t){return 2*cu(t)}),wl.invert=function(t,n){return[-n,2*cu(hu(t))-eu]},Pl.prototype=Sl.prototype={constructor:Pl,count:function(){return this.eachAfter(Al)},each:function(t){var n,e,r,i,o=this,a=[o];do{for(n=a.reverse(),a=[];o=n.pop();)if(t(o),e=o.children)for(r=0,i=e.length;r=0;--e)i.push(n[e]);return this},sum:function(t){return this.eachAfter(function(n){for(var e=+t(n.data)||0,r=n.children,i=r&&r.length;--i>=0;)e+=r[i].value;n.value=e})},sort:function(t){return this.eachBefore(function(n){n.children&&n.children.sort(t)})},path:function(t){for(var n=this,e=function(t,n){if(t===n)return t;var e=t.ancestors(),r=n.ancestors(),i=null;for(t=e.pop(),n=r.pop();t===n;)i=t,t=e.pop(),n=r.pop();return i}(n,t),r=[n];n!==e;)n=n.parent,r.push(n);for(var i=r.length;t!==e;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},descendants:function(){var t=[];return this.each(function(n){t.push(n)}),t},leaves:function(){var t=[];return this.eachBefore(function(n){n.children||t.push(n)}),t},links:function(){var t=this,n=[];return t.each(function(e){e!==t&&n.push({source:e.parent,target:e})}),n},copy:function(){return Sl(this).eachBefore(El)}};var zl=Array.prototype.slice;function Rl(t){for(var n,e,r=0,i=(t=function(t){for(var n,e,r=t.length;r;)e=Math.random()*r--|0,n=t[r],t[r]=t[e],t[e]=n;return t}(zl.call(t))).length,o=[];r0&&e*e>r*r+i*i}function Ul(t,n){for(var e=0;e(a*=a)?(r=(f+a-i)/(2*f),o=Math.sqrt(Math.max(0,a/f-r*r)),e.x=t.x-r*u-o*c,e.y=t.y-r*c+o*u):(r=(f+i-a)/(2*f),o=Math.sqrt(Math.max(0,i/f-r*r)),e.x=n.x+r*u-o*c,e.y=n.y+r*c+o*u)):(e.x=n.x+e.r,e.y=n.y)}function Il(t,n){var e=t.r+n.r-1e-6,r=n.x-t.x,i=n.y-t.y;return e>0&&e*e>r*r+i*i}function Hl(t){var n=t._,e=t.next._,r=n.r+e.r,i=(n.x*e.r+e.x*n.r)/r,o=(n.y*e.r+e.y*n.r)/r;return i*i+o*o}function jl(t){this._=t,this.next=null,this.previous=null}function Xl(t){if(!(i=t.length))return 0;var n,e,r,i,o,a,u,c,f,s,l;if((n=t[0]).x=0,n.y=0,!(i>1))return n.r;if(e=t[1],n.x=-e.r,e.x=n.r,e.y=0,!(i>2))return n.r+e.r;Yl(e,n,r=t[2]),n=new jl(n),e=new jl(e),r=new jl(r),n.next=r.previous=e,e.next=n.previous=r,r.next=e.previous=n;t:for(u=3;uh&&(h=u),g=s*s*v,(d=Math.max(h/g,g/l))>p){s-=u;break}p=d}y.push(a={value:s,dice:c1?n:1)},e}(ph);var yh=function t(n){function e(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,u,c,f,s,l=-1,h=a.length,d=t.value;++l1?n:1)},e}(ph);function _h(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function bh(t,n){return t[0]-n[0]||t[1]-n[1]}function mh(t){for(var n=t.length,e=[0,1],r=2,i=2;i1&&_h(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function xh(){return Math.random()}var wh=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,1===arguments.length?(e=t,t=0):e-=t,function(){return n()*e+t}}return e.source=t,e}(xh),Mh=function t(n){function e(t,e){var r,i;return t=null==t?0:+t,e=null==e?1:+e,function(){var o;if(null!=r)o=r,r=null;else do{r=2*n()-1,o=2*n()-1,i=r*r+o*o}while(!i||i>1);return t+e*o*Math.sqrt(-2*Math.log(i)/i)}}return e.source=t,e}(xh),Nh=function t(n){function e(){var t=Mh.source(n).apply(this,arguments);return function(){return Math.exp(t())}}return e.source=t,e}(xh),Th=function t(n){function e(t){return function(){for(var e=0,r=0;rr&&(n=e,e=r,r=n),function(t){return Math.max(e,Math.min(r,t))}}function Yh(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i2?Ih:Yh,i=o=null,l}function l(n){return isNaN(n=+n)?e:(i||(i=r(a.map(t),u,c)))(t(f(n)))}return l.invert=function(e){return f(n((o||(o=r(u,a.map(t),_e)))(e)))},l.domain=function(t){return arguments.length?(a=Ph.call(t,Lh),f===Oh||(f=Fh(a)),s()):a.slice()},l.range=function(t){return arguments.length?(u=zh.call(t),s()):u.slice()},l.rangeRound=function(t){return u=zh.call(t),c=Ne,s()},l.clamp=function(t){return arguments.length?(f=t?Fh(a):Oh,l):f!==Oh},l.interpolate=function(t){return arguments.length?(c=t,s()):c},l.unknown=function(t){return arguments.length?(e=t,l):e},function(e,r){return t=e,n=r,s()}}function Xh(t,n){return jh()(t,n)}function Vh(n,e,r,i){var o,a=w(n,e,r);switch((i=La(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=Ga(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=$a(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=Va(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function Gh(t){var n=t.domain;return t.ticks=function(t){var e=n();return m(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return Vh(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i=n(),o=0,a=i.length-1,u=i[o],c=i[a];return c0?r=x(u=Math.floor(u/r)*r,c=Math.ceil(c/r)*r,e):r<0&&(r=x(u=Math.ceil(u*r)/r,c=Math.floor(c*r)/r,e)),r>0?(i[o]=Math.floor(u/r)*r,i[a]=Math.ceil(c/r)*r,n(i)):r<0&&(i[o]=Math.ceil(u*r)/r,i[a]=Math.floor(c*r)/r,n(i)),t},t}function $h(t,n){var e,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a0){for(;hc)break;v.push(l)}}else for(;h=1;--s)if(!((l=f*s)c)break;v.push(l)}}else v=m(h,d,Math.min(d-h,p)).map(r);return n?v.reverse():v},i.tickFormat=function(n,o){if(null==o&&(o=10===a?".0e":","),"function"!=typeof o&&(o=t.format(o)),n===1/0)return o;null==n&&(n=10);var u=Math.max(1,a*n/i.ticks().length);return function(t){var n=t/r(Math.round(e(t)));return n*a0))return u;do{u.push(a=new Date(+e)),n(e,o),t(e)}while(a=n)for(;t(n),!e(n);)n.setTime(n-1)},function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;n(t,-1),!e(t););else for(;--r>=0;)for(;n(t,1),!e(t););})},e&&(i.count=function(n,r){return sd.setTime(+n),ld.setTime(+r),t(sd),t(ld),Math.floor(e(sd,ld))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(n){return r(n)%t==0}:function(n){return i.count(0,n)%t==0}):i:null}),i}var dd=hd(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});dd.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?hd(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):dd:null};var pd=dd.range,vd=6e4,gd=6048e5,yd=hd(function(t){t.setTime(t-t.getMilliseconds())},function(t,n){t.setTime(+t+1e3*n)},function(t,n){return(n-t)/1e3},function(t){return t.getUTCSeconds()}),_d=yd.range,bd=hd(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())},function(t,n){t.setTime(+t+n*vd)},function(t,n){return(n-t)/vd},function(t){return t.getMinutes()}),md=bd.range,xd=hd(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-t.getMinutes()*vd)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),wd=xd.range,Md=hd(function(t){t.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*vd)/864e5},function(t){return t.getDate()-1}),Nd=Md.range;function Td(t){return hd(function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+7*n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*vd)/gd})}var Ad=Td(0),Sd=Td(1),kd=Td(2),Ed=Td(3),Cd=Td(4),Pd=Td(5),zd=Td(6),Rd=Ad.range,Dd=Sd.range,qd=kd.range,Ld=Ed.range,Ud=Cd.range,Od=Pd.range,Bd=zd.range,Fd=hd(function(t){t.setDate(1),t.setHours(0,0,0,0)},function(t,n){t.setMonth(t.getMonth()+n)},function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())},function(t){return t.getMonth()}),Yd=Fd.range,Id=hd(function(t){t.setMonth(0,1),t.setHours(0,0,0,0)},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t,n){return n.getFullYear()-t.getFullYear()},function(t){return t.getFullYear()});Id.every=function(t){return isFinite(t=Math.floor(t))&&t>0?hd(function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)},function(n,e){n.setFullYear(n.getFullYear()+e*t)}):null};var Hd=Id.range,jd=hd(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*vd)},function(t,n){return(n-t)/vd},function(t){return t.getUTCMinutes()}),Xd=jd.range,Vd=hd(function(t){t.setUTCMinutes(0,0,0)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getUTCHours()}),Gd=Vd.range,$d=hd(function(t){t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+n)},function(t,n){return(n-t)/864e5},function(t){return t.getUTCDate()-1}),Wd=$d.range;function Zd(t){return hd(function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+7*n)},function(t,n){return(n-t)/gd})}var Qd=Zd(0),Kd=Zd(1),Jd=Zd(2),tp=Zd(3),np=Zd(4),ep=Zd(5),rp=Zd(6),ip=Qd.range,op=Kd.range,ap=Jd.range,up=tp.range,cp=np.range,fp=ep.range,sp=rp.range,lp=hd(function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCMonth(t.getUTCMonth()+n)},function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())},function(t){return t.getUTCMonth()}),hp=lp.range,dp=hd(function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)},function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()},function(t){return t.getUTCFullYear()});dp.every=function(t){return isFinite(t=Math.floor(t))&&t>0?hd(function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)}):null};var pp=dp.range;function vp(t){if(0<=t.y&&t.y<100){var n=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return n.setFullYear(t.y),n}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function gp(t){if(0<=t.y&&t.y<100){var n=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return n.setUTCFullYear(t.y),n}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function yp(t,n,e){return{y:t,m:n,d:e,H:0,M:0,S:0,L:0}}function _p(t){var n=t.dateTime,e=t.date,r=t.time,i=t.periods,o=t.days,a=t.shortDays,u=t.months,c=t.shortMonths,f=Ap(i),s=Sp(i),l=Ap(o),h=Sp(o),d=Ap(a),p=Sp(a),v=Ap(u),g=Sp(u),y=Ap(c),_=Sp(c),b={a:function(t){return a[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:null,d:$p,e:$p,f:Jp,H:Wp,I:Zp,j:Qp,L:Kp,m:tv,M:nv,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Ev,s:Cv,S:ev,u:rv,U:iv,V:ov,w:av,W:uv,x:null,X:null,y:cv,Y:fv,Z:sv,"%":kv},m={a:function(t){return a[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:lv,e:lv,f:gv,H:hv,I:dv,j:pv,L:vv,m:yv,M:_v,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Ev,s:Cv,S:bv,u:mv,U:xv,V:wv,w:Mv,W:Nv,x:null,X:null,y:Tv,Y:Av,Z:Sv,"%":kv},x={a:function(t,n,e){var r=d.exec(n.slice(e));return r?(t.w=p[r[0].toLowerCase()],e+r[0].length):-1},A:function(t,n,e){var r=l.exec(n.slice(e));return r?(t.w=h[r[0].toLowerCase()],e+r[0].length):-1},b:function(t,n,e){var r=y.exec(n.slice(e));return r?(t.m=_[r[0].toLowerCase()],e+r[0].length):-1},B:function(t,n,e){var r=v.exec(n.slice(e));return r?(t.m=g[r[0].toLowerCase()],e+r[0].length):-1},c:function(t,e,r){return N(t,n,e,r)},d:Op,e:Op,f:jp,H:Fp,I:Fp,j:Bp,L:Hp,m:Up,M:Yp,p:function(t,n,e){var r=f.exec(n.slice(e));return r?(t.p=s[r[0].toLowerCase()],e+r[0].length):-1},q:Lp,Q:Vp,s:Gp,S:Ip,u:Ep,U:Cp,V:Pp,w:kp,W:zp,x:function(t,n,r){return N(t,e,n,r)},X:function(t,n,e){return N(t,r,n,e)},y:Dp,Y:Rp,Z:qp,"%":Xp};function w(t,n){return function(e){var r,i,o,a=[],u=-1,c=0,f=t.length;for(e instanceof Date||(e=new Date(+e));++u53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=gp(yp(o.y,0,1))).getUTCDay(),r=i>4||0===i?Kd.ceil(r):Kd(r),r=$d.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=vp(yp(o.y,0,1))).getDay(),r=i>4||0===i?Sd.ceil(r):Sd(r),r=Md.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?gp(yp(o.y,0,1)).getUTCDay():vp(yp(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,gp(o)):vp(o)}}function N(t,n,e,r){for(var i,o,a=0,u=n.length,c=e.length;a=c)return-1;if(37===(i=n.charCodeAt(a++))){if(i=n.charAt(a++),!(o=x[i in mp?n.charAt(a++):i])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}return b.x=w(e,b),b.X=w(r,b),b.c=w(n,b),m.x=w(e,m),m.X=w(r,m),m.c=w(n,m),{format:function(t){var n=w(t+="",b);return n.toString=function(){return t},n},parse:function(t){var n=M(t+="",!1);return n.toString=function(){return t},n},utcFormat:function(t){var n=w(t+="",m);return n.toString=function(){return t},n},utcParse:function(t){var n=M(t+="",!0);return n.toString=function(){return t},n}}}var bp,mp={"-":"",_:" ",0:"0"},xp=/^\s*\d+/,wp=/^%/,Mp=/[\\^$*+?|[\]().{}]/g;function Np(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o68?1900:2e3),e+r[0].length):-1}function qp(t,n,e){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(e,e+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),e+r[0].length):-1}function Lp(t,n,e){var r=xp.exec(n.slice(e,e+1));return r?(t.q=3*r[0]-3,e+r[0].length):-1}function Up(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function Op(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function Bp(t,n,e){var r=xp.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function Fp(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function Yp(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function Ip(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function Hp(t,n,e){var r=xp.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function jp(t,n,e){var r=xp.exec(n.slice(e,e+6));return r?(t.L=Math.floor(r[0]/1e3),e+r[0].length):-1}function Xp(t,n,e){var r=wp.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function Vp(t,n,e){var r=xp.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Gp(t,n,e){var r=xp.exec(n.slice(e));return r?(t.s=+r[0],e+r[0].length):-1}function $p(t,n){return Np(t.getDate(),n,2)}function Wp(t,n){return Np(t.getHours(),n,2)}function Zp(t,n){return Np(t.getHours()%12||12,n,2)}function Qp(t,n){return Np(1+Md.count(Id(t),t),n,3)}function Kp(t,n){return Np(t.getMilliseconds(),n,3)}function Jp(t,n){return Kp(t,n)+"000"}function tv(t,n){return Np(t.getMonth()+1,n,2)}function nv(t,n){return Np(t.getMinutes(),n,2)}function ev(t,n){return Np(t.getSeconds(),n,2)}function rv(t){var n=t.getDay();return 0===n?7:n}function iv(t,n){return Np(Ad.count(Id(t)-1,t),n,2)}function ov(t,n){var e=t.getDay();return t=e>=4||0===e?Cd(t):Cd.ceil(t),Np(Cd.count(Id(t),t)+(4===Id(t).getDay()),n,2)}function av(t){return t.getDay()}function uv(t,n){return Np(Sd.count(Id(t)-1,t),n,2)}function cv(t,n){return Np(t.getFullYear()%100,n,2)}function fv(t,n){return Np(t.getFullYear()%1e4,n,4)}function sv(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+Np(n/60|0,"0",2)+Np(n%60,"0",2)}function lv(t,n){return Np(t.getUTCDate(),n,2)}function hv(t,n){return Np(t.getUTCHours(),n,2)}function dv(t,n){return Np(t.getUTCHours()%12||12,n,2)}function pv(t,n){return Np(1+$d.count(dp(t),t),n,3)}function vv(t,n){return Np(t.getUTCMilliseconds(),n,3)}function gv(t,n){return vv(t,n)+"000"}function yv(t,n){return Np(t.getUTCMonth()+1,n,2)}function _v(t,n){return Np(t.getUTCMinutes(),n,2)}function bv(t,n){return Np(t.getUTCSeconds(),n,2)}function mv(t){var n=t.getUTCDay();return 0===n?7:n}function xv(t,n){return Np(Qd.count(dp(t)-1,t),n,2)}function wv(t,n){var e=t.getUTCDay();return t=e>=4||0===e?np(t):np.ceil(t),Np(np.count(dp(t),t)+(4===dp(t).getUTCDay()),n,2)}function Mv(t){return t.getUTCDay()}function Nv(t,n){return Np(Kd.count(dp(t)-1,t),n,2)}function Tv(t,n){return Np(t.getUTCFullYear()%100,n,2)}function Av(t,n){return Np(t.getUTCFullYear()%1e4,n,4)}function Sv(){return"+0000"}function kv(){return"%"}function Ev(t){return+t}function Cv(t){return Math.floor(+t/1e3)}function Pv(n){return bp=_p(n),t.timeFormat=bp.format,t.timeParse=bp.parse,t.utcFormat=bp.utcFormat,t.utcParse=bp.utcParse,bp}Pv({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"]});var zv=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var Rv=+new Date("2000-01-01T00:00:00.000Z")?function(t){var n=new Date(t);return isNaN(n)?null:n}:t.utcParse("%Y-%m-%dT%H:%M:%S.%LZ"),Dv=1e3,qv=60*Dv,Lv=60*qv,Uv=24*Lv,Ov=7*Uv,Bv=30*Uv,Fv=365*Uv;function Yv(t){return new Date(t)}function Iv(t){return t instanceof Date?+t:+new Date(+t)}function Hv(t,n,r,i,o,a,u,c,f){var s=Xh(Oh,Oh),l=s.invert,h=s.domain,d=f(".%L"),p=f(":%S"),v=f("%I:%M"),g=f("%I %p"),y=f("%a %d"),_=f("%b %d"),b=f("%B"),m=f("%Y"),x=[[u,1,Dv],[u,5,5*Dv],[u,15,15*Dv],[u,30,30*Dv],[a,1,qv],[a,5,5*qv],[a,15,15*qv],[a,30,30*qv],[o,1,Lv],[o,3,3*Lv],[o,6,6*Lv],[o,12,12*Lv],[i,1,Uv],[i,2,2*Uv],[r,1,Ov],[n,1,Bv],[n,3,3*Bv],[t,1,Fv]];function M(e){return(u(e)=1?Ey:t<=-1?-Ey:Math.asin(t)}function zy(t){return t.innerRadius}function Ry(t){return t.outerRadius}function Dy(t){return t.startAngle}function qy(t){return t.endAngle}function Ly(t){return t&&t.padAngle}function Uy(t,n,e,r,i,o,a){var u=t-e,c=n-r,f=(a?o:-o)/Ay(u*u+c*c),s=f*c,l=-f*u,h=t+s,d=n+l,p=e+s,v=r+l,g=(h+p)/2,y=(d+v)/2,_=p-h,b=v-d,m=_*_+b*b,x=i-o,w=h*v-p*d,M=(b<0?-1:1)*Ay(My(0,x*x*m-w*w)),N=(w*b-_*M)/m,T=(-w*_-b*M)/m,A=(w*b+_*M)/m,S=(-w*_+b*M)/m,k=N-g,E=T-y,C=A-g,P=S-y;return k*k+E*E>C*C+P*P&&(N=A,T=S),{cx:N,cy:T,x01:-s,y01:-l,x11:N*(i/x-1),y11:T*(i/x-1)}}function Oy(t){this._context=t}function By(t){return new Oy(t)}function Fy(t){return t[0]}function Yy(t){return t[1]}function Iy(){var t=Fy,n=Yy,e=by(!0),r=null,i=By,o=null;function a(a){var u,c,f,s=a.length,l=!1;for(null==r&&(o=i(f=Ji())),u=0;u<=s;++u)!(u=s;--l)u.point(g[l],y[l]);u.lineEnd(),u.areaEnd()}v&&(g[f]=+t(h,f,c),y[f]=+e(h,f,c),u.point(n?+n(h,f,c):g[f],r?+r(h,f,c):y[f]))}if(d)return u=null,d+""||null}function f(){return Iy().defined(i).curve(a).context(o)}return c.x=function(e){return arguments.length?(t="function"==typeof e?e:by(+e),n=null,c):t},c.x0=function(n){return arguments.length?(t="function"==typeof n?n:by(+n),c):t},c.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:by(+t),c):n},c.y=function(t){return arguments.length?(e="function"==typeof t?t:by(+t),r=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:by(+t),c):e},c.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:by(+t),c):r},c.lineX0=c.lineY0=function(){return f().x(t).y(e)},c.lineY1=function(){return f().x(t).y(r)},c.lineX1=function(){return f().x(n).y(e)},c.defined=function(t){return arguments.length?(i="function"==typeof t?t:by(!!t),c):i},c.curve=function(t){return arguments.length?(a=t,null!=o&&(u=a(o)),c):a},c.context=function(t){return arguments.length?(null==t?o=u=null:u=a(o=t),c):o},c}function jy(t,n){return nt?1:n>=t?0:NaN}function Xy(t){return t}Oy.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var Vy=$y(By);function Gy(t){this._curve=t}function $y(t){function n(n){return new Gy(t(n))}return n._curve=t,n}function Wy(t){var n=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?n($y(t)):n()._curve},t}function Zy(){return Wy(Iy().curve(Vy))}function Qy(){var t=Hy().curve(Vy),n=t.curve,e=t.lineX0,r=t.lineX1,i=t.lineY0,o=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return Wy(e())},delete t.lineX0,t.lineEndAngle=function(){return Wy(r())},delete t.lineX1,t.lineInnerRadius=function(){return Wy(i())},delete t.lineY0,t.lineOuterRadius=function(){return Wy(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n($y(t)):n()._curve},t}function Ky(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}Gy.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,n){this._curve.point(n*Math.sin(t),n*-Math.cos(t))}};var Jy=Array.prototype.slice;function t_(t){return t.source}function n_(t){return t.target}function e_(t){var n=t_,e=n_,r=Fy,i=Yy,o=null;function a(){var a,u=Jy.call(arguments),c=n.apply(this,u),f=e.apply(this,u);if(o||(o=a=Ji()),t(o,+r.apply(this,(u[0]=c,u)),+i.apply(this,u),+r.apply(this,(u[0]=f,u)),+i.apply(this,u)),a)return o=null,a+""||null}return a.source=function(t){return arguments.length?(n=t,a):n},a.target=function(t){return arguments.length?(e=t,a):e},a.x=function(t){return arguments.length?(r="function"==typeof t?t:by(+t),a):r},a.y=function(t){return arguments.length?(i="function"==typeof t?t:by(+t),a):i},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a}function r_(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n=(n+r)/2,e,n,i,r,i)}function i_(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n,e=(e+i)/2,r,e,r,i)}function o_(t,n,e,r,i){var o=Ky(n,e),a=Ky(n,e=(e+i)/2),u=Ky(r,e),c=Ky(r,i);t.moveTo(o[0],o[1]),t.bezierCurveTo(a[0],a[1],u[0],u[1],c[0],c[1])}var a_={draw:function(t,n){var e=Math.sqrt(n/ky);t.moveTo(e,0),t.arc(0,0,e,0,Cy)}},u_={draw:function(t,n){var e=Math.sqrt(n/5)/2;t.moveTo(-3*e,-e),t.lineTo(-e,-e),t.lineTo(-e,-3*e),t.lineTo(e,-3*e),t.lineTo(e,-e),t.lineTo(3*e,-e),t.lineTo(3*e,e),t.lineTo(e,e),t.lineTo(e,3*e),t.lineTo(-e,3*e),t.lineTo(-e,e),t.lineTo(-3*e,e),t.closePath()}},c_=Math.sqrt(1/3),f_=2*c_,s_={draw:function(t,n){var e=Math.sqrt(n/f_),r=e*c_;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},l_=Math.sin(ky/10)/Math.sin(7*ky/10),h_=Math.sin(Cy/10)*l_,d_=-Math.cos(Cy/10)*l_,p_={draw:function(t,n){var e=Math.sqrt(.8908130915292852*n),r=h_*e,i=d_*e;t.moveTo(0,-e),t.lineTo(r,i);for(var o=1;o<5;++o){var a=Cy*o/5,u=Math.cos(a),c=Math.sin(a);t.lineTo(c*e,-u*e),t.lineTo(u*r-c*i,c*r+u*i)}t.closePath()}},v_={draw:function(t,n){var e=Math.sqrt(n),r=-e/2;t.rect(r,r,e,e)}},g_=Math.sqrt(3),y_={draw:function(t,n){var e=-Math.sqrt(n/(3*g_));t.moveTo(0,2*e),t.lineTo(-g_*e,-e),t.lineTo(g_*e,-e),t.closePath()}},__=Math.sqrt(3)/2,b_=1/Math.sqrt(12),m_=3*(b_/2+1),x_={draw:function(t,n){var e=Math.sqrt(n/m_),r=e/2,i=e*b_,o=r,a=e*b_+e,u=-o,c=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,c),t.lineTo(-.5*r-__*i,__*r+-.5*i),t.lineTo(-.5*o-__*a,__*o+-.5*a),t.lineTo(-.5*u-__*c,__*u+-.5*c),t.lineTo(-.5*r+__*i,-.5*i-__*r),t.lineTo(-.5*o+__*a,-.5*a-__*o),t.lineTo(-.5*u+__*c,-.5*c-__*u),t.closePath()}},w_=[a_,u_,s_,v_,p_,y_,x_];function M_(){}function N_(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function T_(t){this._context=t}function A_(t){this._context=t}function S_(t){this._context=t}function k_(t,n){this._basis=new T_(t),this._beta=n}T_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:N_(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:N_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},A_.prototype={areaStart:M_,areaEnd:M_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x2=t,this._y2=n;break;case 1:this._point=2,this._x3=t,this._y3=n;break;case 2:this._point=3,this._x4=t,this._y4=n,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+n)/6);break;default:N_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},S_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var e=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+n)/6;this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 3:this._point=4;default:N_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},k_.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,n=this._y,e=t.length-1;if(e>0)for(var r,i=t[0],o=n[0],a=t[e]-i,u=n[e]-o,c=-1;++c<=e;)r=c/e,this._basis.point(this._beta*t[c]+(1-this._beta)*(i+r*a),this._beta*n[c]+(1-this._beta)*(o+r*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}};var E_=function t(n){function e(t){return 1===n?new T_(t):new k_(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function C_(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function P_(t,n){this._context=t,this._k=(1-n)/6}P_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:C_(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:C_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var z_=function t(n){function e(t){return new P_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function R_(t,n){this._context=t,this._k=(1-n)/6}R_.prototype={areaStart:M_,areaEnd:M_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:C_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var D_=function t(n){function e(t){return new R_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function q_(t,n){this._context=t,this._k=(1-n)/6}q_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:C_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var L_=function t(n){function e(t){return new q_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function U_(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>Sy){var u=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,c=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*u-t._x0*t._l12_2a+t._x2*t._l01_2a)/c,i=(i*u-t._y0*t._l12_2a+t._y2*t._l01_2a)/c}if(t._l23_a>Sy){var f=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,s=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*f+t._x1*t._l23_2a-n*t._l12_2a)/s,a=(a*f+t._y1*t._l23_2a-e*t._l12_2a)/s}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2)}function O_(t,n){this._context=t,this._alpha=n}O_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:U_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var B_=function t(n){function e(t){return n?new O_(t,n):new P_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function F_(t,n){this._context=t,this._alpha=n}F_.prototype={areaStart:M_,areaEnd:M_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:U_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Y_=function t(n){function e(t){return n?new F_(t,n):new R_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function I_(t,n){this._context=t,this._alpha=n}I_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:U_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var H_=function t(n){function e(t){return n?new I_(t,n):new q_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function j_(t){this._context=t}function X_(t){return t<0?-1:1}function V_(t,n,e){var r=t._x1-t._x0,i=n-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(e-t._y1)/(i||r<0&&-0),u=(o*i+a*r)/(r+i);return(X_(o)+X_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function G_(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function $_(t,n,e){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,u=(o-r)/3;t._context.bezierCurveTo(r+u,i+u*n,o-u,a-u*e,o,a)}function W_(t){this._context=t}function Z_(t){this._context=new Q_(t)}function Q_(t){this._context=t}function K_(t){this._context=t}function J_(t){var n,e,r=t.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],n=1;n=0;--n)i[n]=(a[n]-i[n+1])/o[n];for(o[r-1]=(t[r]+i[r-1])/2,n=0;n1)for(var e,r,i,o=1,a=t[n[0]],u=a.length;o=0;)e[n]=n;return e}function rb(t,n){return t[n]}function ib(t){var n=t.map(ob);return eb(t).sort(function(t,e){return n[t]-n[e]})}function ob(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++eo&&(o=n,r=e);return r}function ab(t){var n=t.map(ub);return eb(t).sort(function(t,e){return n[t]-n[e]})}function ub(t){for(var n,e=0,r=-1,i=t.length;++r0)){if(o/=h,h<0){if(o0){if(o>l)return;o>s&&(s=o)}if(o=r-c,h||!(o<0)){if(o/=h,h<0){if(o>l)return;o>s&&(s=o)}else if(h>0){if(o0)){if(o/=d,d<0){if(o0){if(o>l)return;o>s&&(s=o)}if(o=i-f,d||!(o<0)){if(o/=d,d<0){if(o>l)return;o>s&&(s=o)}else if(d>0){if(o0||l<1)||(s>0&&(t[0]=[c+s*h,f+s*d]),l<1&&(t[1]=[c+l*h,f+l*d]),!0)}}}}}function mb(t,n,e,r,i){var o=t[1];if(o)return!0;var a,u,c=t[0],f=t.left,s=t.right,l=f[0],h=f[1],d=s[0],p=s[1],v=(l+d)/2,g=(h+p)/2;if(p===h){if(v=r)return;if(l>d){if(c){if(c[1]>=i)return}else c=[v,e];o=[v,i]}else{if(c){if(c[1]1)if(l>d){if(c){if(c[1]>=i)return}else c=[(e-u)/a,e];o=[(i-u)/a,i]}else{if(c){if(c[1]=r)return}else c=[n,a*n+u];o=[r,a*r+u]}else{if(c){if(c[0]=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,n),this._context.lineTo(t,n);else{var e=this._x*(1-this._t)+t*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,n)}}this._x=t,this._y=n}},lb.prototype={constructor:lb,insert:function(t,n){var e,r,i;if(t){if(n.P=t,n.N=t.N,t.N&&(t.N.P=n),t.N=n,t.R){for(t=t.R;t.L;)t=t.L;t.L=n}else t.R=n;e=t}else this._?(t=vb(this._),n.P=null,n.N=t,t.P=t.L=n,e=t):(n.P=n.N=null,this._=n,e=null);for(n.L=n.R=null,n.U=e,n.C=!0,t=n;e&&e.C;)e===(r=e.U).L?(i=r.R)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.R&&(db(this,e),e=(t=e).U),e.C=!1,r.C=!0,pb(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(pb(this,e),e=(t=e).U),e.C=!1,r.C=!0,db(this,r)),e=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var n,e,r,i=t.U,o=t.L,a=t.R;if(e=o?a?vb(a):o:a,i?i.L===t?i.L=e:i.R=e:this._=e,o&&a?(r=e.C,e.C=t.C,e.L=o,o.U=e,e!==a?(i=e.U,e.U=t.U,t=e.R,i.L=t,e.R=a,a.U=e):(e.U=i,i=e,t=e.R)):(r=t.C,t=e),t&&(t.U=i),!r)if(t&&t.C)t.C=!1;else{do{if(t===this._)break;if(t===i.L){if((n=i.R).C&&(n.C=!1,i.C=!0,db(this,i),n=i.R),n.L&&n.L.C||n.R&&n.R.C){n.R&&n.R.C||(n.L.C=!1,n.C=!0,pb(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,db(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,pb(this,i),n=i.L),n.L&&n.L.C||n.R&&n.R.C){n.L&&n.L.C||(n.R.C=!1,n.C=!0,db(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,pb(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}};var Nb,Tb=[];function Ab(){hb(this),this.x=this.y=this.arc=this.site=this.cy=null}function Sb(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i[0],u=i[1],c=r[0]-a,f=r[1]-u,s=o[0]-a,l=o[1]-u,h=2*(c*l-f*s);if(!(h>=-Ib)){var d=c*c+f*f,p=s*s+l*l,v=(l*d-f*p)/h,g=(c*p-s*d)/h,y=Tb.pop()||new Ab;y.arc=t,y.site=i,y.x=v+a,y.y=(y.cy=g+u)+Math.sqrt(v*v+g*g),t.circle=y;for(var _=null,b=Bb._;b;)if(y.yYb)u=u.L;else{if(!((i=o-Lb(u,a))>Yb)){r>-Yb?(n=u.P,e=u):i>-Yb?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}!function(t){Ob[t.index]={site:t,halfedges:[]}}(t);var c=Pb(t);if(Ub.insert(n,c),n||e){if(n===e)return kb(n),e=Pb(n.site),Ub.insert(c,e),c.edge=e.edge=gb(n.site,c.site),Sb(n),void Sb(e);if(e){kb(n),kb(e);var f=n.site,s=f[0],l=f[1],h=t[0]-s,d=t[1]-l,p=e.site,v=p[0]-s,g=p[1]-l,y=2*(h*g-d*v),_=h*h+d*d,b=v*v+g*g,m=[(g*_-d*b)/y+s,(h*b-v*_)/y+l];_b(e.edge,f,p,m),c.edge=gb(f,t,null,m),e.edge=gb(t,p,null,m),Sb(n),Sb(e)}else c.edge=gb(n.site,c.site)}}function qb(t,n){var e=t.site,r=e[0],i=e[1],o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var u=(e=a.site)[0],c=e[1],f=c-n;if(!f)return u;var s=u-r,l=1/o-1/f,h=s/f;return l?(-h+Math.sqrt(h*h-2*l*(s*s/(-2*f)-c+f/2+i-o/2)))/l+r:(r+u)/2}function Lb(t,n){var e=t.N;if(e)return qb(e,n);var r=t.site;return r[1]===n?r[0]:1/0}var Ub,Ob,Bb,Fb,Yb=1e-6,Ib=1e-12;function Hb(t,n,e){return(t[0]-e[0])*(n[1]-t[1])-(t[0]-n[0])*(e[1]-t[1])}function jb(t,n){return n[1]-t[1]||n[0]-t[0]}function Xb(t,n){var e,r,i,o=t.sort(jb).pop();for(Fb=[],Ob=new Array(t.length),Ub=new lb,Bb=new lb;;)if(i=Nb,o&&(!i||o[1]Yb||Math.abs(i[0][1]-i[1][1])>Yb)||delete Fb[o]}(a,u,c,f),function(t,n,e,r){var i,o,a,u,c,f,s,l,h,d,p,v,g=Ob.length,y=!0;for(i=0;iYb||Math.abs(v-h)>Yb)&&(c.splice(u,0,Fb.push(yb(a,d,Math.abs(p-t)Yb?[t,Math.abs(l-t)Yb?[Math.abs(h-r)Yb?[e,Math.abs(l-e)Yb?[Math.abs(h-n)=u)return null;var c=t-i.site[0],f=n-i.site[1],s=c*c+f*f;do{i=o.cells[r=a],a=null,i.halfedges.forEach(function(e){var r=o.edges[e],u=r.left;if(u!==i.site&&u||(u=r.right)){var c=t-u[0],f=n-u[1],l=c*c+f*f;lr?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Zb.prototype=$b.prototype,t.FormatSpecifier=Ua,t.active=function(t,n){var e,r,i=t.__transition;if(i)for(r in n=null==n?null:n+"",i)if((e=i[r]).state>br&&e.name===n)return new qr([[t]],vi,n,+r);return null},t.arc=function(){var t=zy,n=Ry,e=by(0),r=null,i=Dy,o=qy,a=Ly,u=null;function c(){var c,f,s=+t.apply(this,arguments),l=+n.apply(this,arguments),h=i.apply(this,arguments)-Ey,d=o.apply(this,arguments)-Ey,p=my(d-h),v=d>h;if(u||(u=c=Ji()),lSy)if(p>Cy-Sy)u.moveTo(l*wy(h),l*Ty(h)),u.arc(0,0,l,h,d,!v),s>Sy&&(u.moveTo(s*wy(d),s*Ty(d)),u.arc(0,0,s,d,h,v));else{var g,y,_=h,b=d,m=h,x=d,w=p,M=p,N=a.apply(this,arguments)/2,T=N>Sy&&(r?+r.apply(this,arguments):Ay(s*s+l*l)),A=Ny(my(l-s)/2,+e.apply(this,arguments)),S=A,k=A;if(T>Sy){var E=Py(T/s*Ty(N)),C=Py(T/l*Ty(N));(w-=2*E)>Sy?(m+=E*=v?1:-1,x-=E):(w=0,m=x=(h+d)/2),(M-=2*C)>Sy?(_+=C*=v?1:-1,b-=C):(M=0,_=b=(h+d)/2)}var P=l*wy(_),z=l*Ty(_),R=s*wy(x),D=s*Ty(x);if(A>Sy){var q,L=l*wy(b),U=l*Ty(b),O=s*wy(m),B=s*Ty(m);if(p1?0:t<-1?ky:Math.acos(t)}((F*I+Y*H)/(Ay(F*F+Y*Y)*Ay(I*I+H*H)))/2),X=Ay(q[0]*q[0]+q[1]*q[1]);S=Ny(A,(s-X)/(j-1)),k=Ny(A,(l-X)/(j+1))}}M>Sy?k>Sy?(g=Uy(O,B,P,z,l,k,v),y=Uy(L,U,R,D,l,k,v),u.moveTo(g.cx+g.x01,g.cy+g.y01),kSy&&w>Sy?S>Sy?(g=Uy(R,D,L,U,s,-S,v),y=Uy(P,z,O,B,s,-S,v),u.lineTo(g.cx+g.x01,g.cy+g.y01),S>a,f=i+2*u>>a,s=yo(20);function l(r){var i=new Float32Array(c*f),l=new Float32Array(c*f);r.forEach(function(r,o,s){var l=+t(r,o,s)+u>>a,h=+n(r,o,s)+u>>a,d=+e(r,o,s);l>=0&&l=0&&h>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),No({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),No({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a);var d=s(i);if(!Array.isArray(d)){var p=T(i);d=w(0,p,d),(d=g(0,Math.floor(p/d)*d,d)).shift()}return Mo().thresholds(d).size([c,f])(i).map(h)}function h(t){return t.value*=Math.pow(2,-2*a),t.coordinates.forEach(d),t}function d(t){t.forEach(p)}function p(t){t.forEach(v)}function v(t){t[0]=t[0]*Math.pow(2,a)-u,t[1]=t[1]*Math.pow(2,a)-u}function y(){return c=r+2*(u=3*o)>>a,f=i+2*u>>a,l}return l.x=function(n){return arguments.length?(t="function"==typeof n?n:yo(+n),l):t},l.y=function(t){return arguments.length?(n="function"==typeof t?t:yo(+t),l):n},l.weight=function(t){return arguments.length?(e="function"==typeof t?t:yo(+t),l):e},l.size=function(t){if(!arguments.length)return[r,i];var n=Math.ceil(t[0]),e=Math.ceil(t[1]);if(!(n>=0||n>=0))throw new Error("invalid size");return r=n,i=e,y()},l.cellSize=function(t){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(t)/Math.LN2),y()},l.thresholds=function(t){return arguments.length?(s="function"==typeof t?t:Array.isArray(t)?yo(vo.call(t)):yo(t),l):s},l.bandwidth=function(t){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return o=Math.round((Math.sqrt(4*t*t+1)-1)/2),y()},l},t.contours=Mo,t.create=function(t){return Rt(Z(t).call(document.documentElement))},t.creator=Z,t.cross=function(t,n,e){var r,i,o,u,c=t.length,f=n.length,s=new Array(c*f);for(null==e&&(e=a),r=o=0;rt?1:n>=t?0:NaN},t.deviation=f,t.dispatch=I,t.drag=function(){var n,e,r,i,o=Gt,a=$t,u=Wt,c=Zt,f={},s=I("start","drag","end"),l=0,h=0;function d(t){t.on("mousedown.drag",p).filter(c).on("touchstart.drag",y).on("touchmove.drag",_).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(){if(!i&&o.apply(this,arguments)){var u=m("mouse",a.apply(this,arguments),Bt,this,arguments);u&&(Rt(t.event.view).on("mousemove.drag",v,!0).on("mouseup.drag",g,!0),Ht(t.event.view),Yt(),r=!1,n=t.event.clientX,e=t.event.clientY,u("start"))}}function v(){if(It(),!r){var i=t.event.clientX-n,o=t.event.clientY-e;r=i*i+o*o>h}f.mouse("drag")}function g(){Rt(t.event.view).on("mousemove.drag mouseup.drag",null),jt(t.event.view,r),It(),f.mouse("end")}function y(){if(o.apply(this,arguments)){var n,e,r=t.event.changedTouches,i=a.apply(this,arguments),u=r.length;for(n=0;nc+d||if+d||ou.index){var p=c-a.x-a.vx,v=f-a.y-a.vy,g=p*p+v*v;gt.r&&(t.r=t[n].r)}function u(){if(n){var r,i,o=n.length;for(e=new Array(o),r=0;r=a)){(t.data!==n||t.next)&&(0===s&&(d+=(s=va())*s),0===l&&(d+=(l=va())*l),d1?(null==e?u.remove(t):u.set(t,d(e)),n):u.get(t)},find:function(n,e,r){var i,o,a,u,c,f=0,s=t.length;for(null==r?r=1/0:r*=r,f=0;f1?(f.on(t,e),n):f.on(t)}}},t.forceX=function(t){var n,e,r,i=pa(.1);function o(t){for(var i,o=0,a=n.length;o=.12&&i<.234&&r>=-.425&&r<-.214?u:i>=.166&&i<.234&&r>=-.214&&r<-.115?c:a).invert(t)},s.stream=function(e){return t&&n===e?t:(r=[a.stream(n=e),u.stream(e),c.stream(e)],i=r.length,t={point:function(t,n){for(var e=-1;++eEc(r[0],r[1])&&(r[1]=i[1]),Ec(i[0],r[1])>Ec(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,n=0,r=o[e=o.length-1];n<=e;r=i,++n)i=o[n],(u=Ec(r[1],i[0]))>a&&(a=u,$u=i[0],Zu=r[1])}return ec=rc=null,$u===1/0||Wu===1/0?[[NaN,NaN],[NaN,NaN]]:[[$u,Wu],[Zu,Qu]]},t.geoCentroid=function(t){ic=oc=ac=uc=cc=fc=sc=lc=hc=dc=pc=0,ku(t,zc);var n=hc,e=dc,r=pc,i=n*n+e*e+r*r;return i2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=wl,t.gray=function(t,n){return new Bn(t,0,0,null==n?1:n)},t.hcl=Xn,t.hierarchy=Sl,t.histogram=function(){var t=v,n=s,e=M;function r(r){var o,a,u=r.length,c=new Array(u);for(o=0;ol;)h.pop(),--d;var p,v=new Array(d+1);for(o=0;o<=d;++o)(p=v[o]=[]).x0=o>0?h[o-1]:s,p.x1=o1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return sy.h=360*t-100,sy.s=1.5-1.5*n,sy.l=.8-.9*n,sy+""},t.interpolateRdBu=gg,t.interpolateRdGy=_g,t.interpolateRdPu=Fg,t.interpolateRdYlBu=mg,t.interpolateRdYlGn=wg,t.interpolateReds=iy,t.interpolateRgb=he,t.interpolateRgbBasis=pe,t.interpolateRgbBasisClosed=ve,t.interpolateRound=Ne,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,ly.r=255*(n=Math.sin(t))*n,ly.g=255*(n=Math.sin(t+hy))*n,ly.b=255*(n=Math.sin(t+dy))*n,ly+""},t.interpolateSpectral=Ng,t.interpolateString=we,t.interpolateTransformCss=Re,t.interpolateTransformSvg=De,t.interpolateTurbo=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"},t.interpolateViridis=vy,t.interpolateWarm=cy,t.interpolateYlGn=jg,t.interpolateYlGnBu=Ig,t.interpolateYlOrBr=Vg,t.interpolateYlOrRd=$g,t.interpolateZoom=Fe,t.interrupt=Er,t.interval=function(t,n,e){var r=new fr,i=n;return null==n?(r.restart(t,n,e),r):(n=+n,e=null==e?ur():+e,r.restart(function o(a){a+=i,r.restart(o,i+=n,e),t(a)},n,e),r)},t.isoFormat=zv,t.isoParse=Rv,t.json=function(t,n){return fetch(t,n).then(fa)},t.keys=function(t){var n=[];for(var e in t)n.push(e);return n},t.lab=On,t.lch=function(t,n,e,r){return 1===arguments.length?jn(t):new Vn(e,n,t,null==r?1:r)},t.line=Iy,t.lineRadial=Zy,t.linkHorizontal=function(){return e_(r_)},t.linkRadial=function(){var t=e_(o_);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.linkVertical=function(){return e_(i_)},t.local=qt,t.map=ao,t.matcher=nt,t.max=T,t.mean=function(t,n){var e,r=t.length,i=r,o=-1,a=0;if(null==n)for(;++o=r.length)return null!=t&&e.sort(t),null!=n?n(e):e;for(var c,f,s,l=-1,h=e.length,d=r[i++],p=ao(),v=a();++lr.length)return e;var a,u=i[o-1];return null!=n&&o>=r.length?a=e.entries():(a=[],e.each(function(n,e){a.push({key:e,values:t(n,o)})})),null!=u?a.sort(function(t,n){return u(t.key,n.key)}):a}(o(t,0,fo,so),0)},key:function(t){return r.push(t),e},sortKeys:function(t){return i[r.length-1]=t,e},sortValues:function(n){return t=n,e},rollup:function(t){return n=t,e}}},t.now=ur,t.pack=function(){var t=null,n=1,e=1,r=$l;function i(i){return i.x=n/2,i.y=e/2,t?i.eachBefore(Ql(t)).eachAfter(Kl(r,.5)).eachBefore(Jl(1)):i.eachBefore(Ql(Zl)).eachAfter(Kl($l,1)).eachAfter(Kl(r,i.r/Math.min(n,e))).eachBefore(Jl(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=Vl(n),i):t},i.size=function(t){return arguments.length?(n=+t[0],e=+t[1],i):[n,e]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Wl(+t),i):r},i},t.packEnclose=Rl,t.packSiblings=function(t){return Xl(t),t},t.pairs=function(t,n){null==n&&(n=a);for(var e=0,r=t.length-1,i=t[0],o=new Array(r<0?0:r);e0&&(d+=l);for(null!=n?p.sort(function(t,e){return n(v[t],v[e])}):null!=e&&p.sort(function(t,n){return e(a[t],a[n])}),u=0,f=d?(y-h*b)/d:0;u0?l*f:0)+b,v[c]={data:a[c],index:u,value:l,startAngle:g,endAngle:s,padAngle:_};return v}return a.value=function(n){return arguments.length?(t="function"==typeof n?n:by(+n),a):t},a.sortValues=function(t){return arguments.length?(n=t,e=null,a):n},a.sort=function(t){return arguments.length?(e=t,n=null,a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:by(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:by(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:by(+t),a):o},a},t.piecewise=function(t,n){for(var e=0,r=n.length-1,i=n[0],o=new Array(r<0?0:r);eu!=f>u&&a<(c-e)*(u-r)/(f-r)+e&&(s=!s),c=e,f=r;return s},t.polygonHull=function(t){if((e=t.length)<3)return null;var n,e,r=new Array(e),i=new Array(e);for(n=0;n=0;--n)f.push(t[r[o[n]][2]]);for(n=+u;n0?a[n-1]:r[0],n=o?[a[o-1],r]:[a[n-1],a[n]]},c.unknown=function(t){return arguments.length?(n=t,c):c},c.thresholds=function(){return a.slice()},c.copy=function(){return t().domain([e,r]).range(u).unknown(n)},kh.apply(Gh(c),arguments)},t.scaleSequential=function t(){var n=Gh(jv()(Oh));return n.copy=function(){return Xv(n,t())},Eh.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=nd(jv()).domain([1,10]);return n.copy=function(){return Xv(n,t()).base(n.base())},Eh.apply(n,arguments)},t.scaleSequentialPow=Vv,t.scaleSequentialQuantile=function t(){var e=[],r=Oh;function o(t){if(!isNaN(t=+t))return r((i(e,t)-1)/(e.length-1))}return o.domain=function(t){if(!arguments.length)return e.slice();e=[];for(var r,i=0,a=t.length;i0)for(var e,r,i,o,a,u,c=0,f=t[n[0]].length;c0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):(r[0]=0,r[1]=i)},t.stackOffsetExpand=function(t,n){if((r=t.length)>0){for(var e,r,i,o=0,a=t[0].length;o0){for(var e,r=0,i=t[n[0]],o=i.length;r0&&(r=(e=t[n[0]]).length)>0){for(var e,r,i,o=0,a=1;a0)throw new Error("cycle");return o}return e.id=function(n){return arguments.length?(t=Gl(n),e):t},e.parentId=function(t){return arguments.length?(n=Gl(t),e):n},e},t.style=ft,t.sum=function(t,n){var e,r=t.length,i=-1,o=0;if(null==n)for(;++i=0;--i)u.push(e=n.children[i]=new hh(r[i],i)),e.parent=n;return(a.parent=new hh(null,0)).children=[a],a}(i);if(c.eachAfter(o),c.parent.m=-c.z,c.eachBefore(a),r)i.eachBefore(u);else{var f=i,s=i,l=i;i.eachBefore(function(t){t.xs.x&&(s=t),t.depth>l.depth&&(l=t)});var h=f===s?1:t(f,s)/2,d=h-f.x,p=n/(s.x+h+d),v=e/(l.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*p,t.y=t.depth*v})}return i}function o(n){var e=n.children,r=n.parent.children,i=n.i?r[n.i-1]:null;if(e){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(n);var o=(e[0].z+e[e.length-1].z)/2;i?(n.z=i.z+t(n._,i._),n.m=n.z-o):n.z=o}else i&&(n.z=i.z+t(n._,i._));n.parent.A=function(n,e,r){if(e){for(var i,o=n,a=n,u=e,c=o.parent.children[0],f=o.m,s=a.m,l=u.m,h=c.m;u=fh(u),o=ch(o),u&&o;)c=ch(c),(a=fh(a)).a=n,(i=u.z+l-o.z-f+t(u._,o._))>0&&(sh(lh(u,n,r),n,i),f+=i,s+=i),l+=u.m,f+=o.m,h+=c.m,s+=a.m;u&&!fh(a)&&(a.t=u,a.m+=l-s),o&&!ch(c)&&(c.t=o,c.m+=f-h,r=n)}return r}(n,i,n.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=n,t.y=t.depth*e}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.treemap=function(){var t=gh,n=!1,e=1,r=1,i=[0],o=$l,a=$l,u=$l,c=$l,f=$l;function s(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(l),i=[0],n&&t.eachBefore(th),t}function l(n){var e=i[n.depth],r=n.x0+e,s=n.y0+e,l=n.x1-e,h=n.y1-e;l=e-1){var s=u[n];return s.x0=i,s.y0=o,s.x1=a,void(s.y1=c)}for(var l=f[n],h=r/2+l,d=n+1,p=e-1;d>>1;f[v]c-o){var _=(i*y+a*g)/r;t(n,d,g,i,o,_,c),t(d,e,y,_,o,a,c)}else{var b=(o*y+c*g)/r;t(n,d,g,i,o,a,b),t(d,e,y,i,b,a,c)}}(0,c,t.value,n,e,r,i)},t.treemapDice=nh,t.treemapResquarify=yh,t.treemapSlice=dh,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?dh:nh)(t,n,e,r,i)},t.treemapSquarify=gh,t.tsv=ca,t.tsvFormat=Zo,t.tsvFormatBody=Qo,t.tsvFormatRow=Jo,t.tsvFormatRows=Ko,t.tsvFormatValue=ta,t.tsvParse=$o,t.tsvParseRows=Wo,t.utcDay=$d,t.utcDays=Wd,t.utcFriday=ep,t.utcFridays=fp,t.utcHour=Vd,t.utcHours=Gd,t.utcMillisecond=dd,t.utcMilliseconds=pd,t.utcMinute=jd,t.utcMinutes=Xd,t.utcMonday=Kd,t.utcMondays=op,t.utcMonth=lp,t.utcMonths=hp,t.utcSaturday=rp,t.utcSaturdays=sp,t.utcSecond=yd,t.utcSeconds=_d,t.utcSunday=Qd,t.utcSundays=ip,t.utcThursday=np,t.utcThursdays=cp,t.utcTuesday=Jd,t.utcTuesdays=ap,t.utcWednesday=tp,t.utcWednesdays=up,t.utcWeek=Qd,t.utcWeeks=ip,t.utcYear=dp,t.utcYears=pp,t.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},t.variance=c,t.version="5.14.2",t.voronoi=function(){var t=fb,n=sb,e=null;function r(r){return new Xb(r.map(function(e,i){var o=[Math.round(t(e,i,r)/Yb)*Yb,Math.round(n(e,i,r)/Yb)*Yb];return o.index=i,o.data=e,o}),e)}return r.polygons=function(t){return r(t).polygons()},r.links=function(t){return r(t).links()},r.triangles=function(t){return r(t).triangles()},r.x=function(n){return arguments.length?(t="function"==typeof n?n:cb(+n),r):t},r.y=function(t){return arguments.length?(n="function"==typeof t?t:cb(+t),r):n},r.extent=function(t){return arguments.length?(e=null==t?null:[[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]],r):e&&[[e[0][0],e[0][1]],[e[1][0],e[1][1]]]},r.size=function(t){return arguments.length?(e=null==t?null:[[0,0],[+t[0],+t[1]]],r):e&&[e[1][0]-e[0][0],e[1][1]-e[0][1]]},r},t.window=ct,t.xml=la,t.zip=function(){return k(arguments)},t.zoom=function(){var n,e,r=Jb,i=tm,o=im,a=em,u=rm,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,l=Fe,h=I("start","zoom","end"),d=500,p=150,v=0;function g(t){t.property("__zoom",nm).on("wheel.zoom",M).on("mousedown.zoom",N).on("dblclick.zoom",T).filter(u).on("touchstart.zoom",A).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(t,n){return(n=Math.max(c[0],Math.min(c[1],n)))===t.k?t:new $b(n,t.x,t.y)}function _(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new $b(t.k,r,i)}function b(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function m(t,n,e){t.on("start.zoom",function(){x(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).end()}).tween("zoom",function(){var t=this,r=arguments,o=x(t,r),a=i.apply(t,r),u=null==e?b(a):"function"==typeof e?e.apply(t,r):e,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),f=t.__zoom,s="function"==typeof n?n.apply(t,r):n,h=l(f.invert(u).concat(c/f.k),s.invert(u).concat(c/s.k));return function(t){if(1===t)t=s;else{var n=h(t),e=c/n[2];t=new $b(e,u[0]-n[0]*e,u[1]-n[1]*e)}o.zoom(null,t)}})}function x(t,n,e){return!e&&t.__zooming||new w(t,n)}function w(t,n){this.that=t,this.args=n,this.active=0,this.extent=i.apply(t,n),this.taps=0}function M(){if(r.apply(this,arguments)){var t=x(this,arguments),n=this.__zoom,e=Math.max(c[0],Math.min(c[1],n.k*Math.pow(2,a.apply(this,arguments)))),i=Bt(this);if(t.wheel)t.mouse[0][0]===i[0]&&t.mouse[0][1]===i[1]||(t.mouse[1]=n.invert(t.mouse[0]=i)),clearTimeout(t.wheel);else{if(n.k===e)return;t.mouse=[i,n.invert(i)],Er(this),t.start()}Kb(),t.wheel=setTimeout(function(){t.wheel=null,t.end()},p),t.zoom("mouse",o(_(y(n,e),t.mouse[0],t.mouse[1]),t.extent,f))}}function N(){if(!e&&r.apply(this,arguments)){var n=x(this,arguments,!0),i=Rt(t.event.view).on("mousemove.zoom",function(){if(Kb(),!n.moved){var e=t.event.clientX-u,r=t.event.clientY-c;n.moved=e*e+r*r>v}n.zoom("mouse",o(_(n.that.__zoom,n.mouse[0]=Bt(n.that),n.mouse[1]),n.extent,f))},!0).on("mouseup.zoom",function(){i.on("mousemove.zoom mouseup.zoom",null),jt(t.event.view,n.moved),Kb(),n.end()},!0),a=Bt(this),u=t.event.clientX,c=t.event.clientY;Ht(t.event.view),Qb(),n.mouse=[a,this.__zoom.invert(a)],Er(this),n.start()}}function T(){if(r.apply(this,arguments)){var n=this.__zoom,e=Bt(this),a=n.invert(e),u=n.k*(t.event.shiftKey?.5:2),c=o(_(y(n,u),e,a),i.apply(this,arguments),f);Kb(),s>0?Rt(this).transition().duration(s).call(m,c,e):Rt(this).call(g.transform,c)}}function A(){if(r.apply(this,arguments)){var e,i,o,a,u=t.event.touches,c=u.length,f=x(this,arguments,t.event.changedTouches.length===c);for(Qb(),i=0;i { + for (let key in things){ + var thing_id = things[key]['href'].substr(things[key]['href'].lastIndexOf('/') + 1); + this.thing_title_lookup_table[thing_id] = things[key]['title']; + } + }); + + var latest_property_id = 4; + + fetch(`/extensions/${this.id}/views/content.html`) + .then((res) => res.text()) + .then((text) => { + this.content = text; + }) + .catch((e) => console.error('Failed to fetch content:', e)); + } + + create_thing_list(body){ + //console.log("Creating main thing list"); + + const pre = document.getElementById('extension-privacy-manager-response-data'); + const thing_list = document.getElementById('extension-privacy-manager-thing-list'); + + for (var key in body['data']) { + + var dataline = JSON.parse(body['data'][key]['name']); + //console.log(Object.keys(dataline)); + + var this_object = this; + //console.log(this_object); + + var node = document.createElement("LI"); // Create a
  • node + node.setAttribute("data-property-id", body['data'][key]['id']); + node.setAttribute("data-data-type", body['data'][key]['data_type']); + var human_readable_thing_title = dataline['thing']; + if( human_readable_thing_title in this.thing_title_lookup_table ){ + human_readable_thing_title = this.thing_title_lookup_table[human_readable_thing_title]; + } + var textnode = document.createTextNode(human_readable_thing_title + ' - ' + dataline['property']); // Create a text node + node.onclick = function() { this_object.thing_list_click(this) }; + node.appendChild(textnode); + thing_list.appendChild(node); + } + pre.innerText = ""; + } + + + + display_thing_data(property_id,data_type,raw_data){ // Uses json to generate dataviz + const dataviz = document.getElementById('extension-privacy-manager-thing-dataviz'); + var data = [] + + for( var key in raw_data ){ + data.push({'date': raw_data[key]['date'], 'value': raw_data[key]['value']}); + } + + var elem = document.getElementById("extension-privacy-manager-thing-dataviz-svg > *"); + if( elem != null ){ + elem.parentNode.removeChild(elem); + } + + + //var svg = d3.select("#extension-privacy-manager-thing-dataviz").append("svg"), + var svg = d3.select("#extension-privacy-manager-thing-dataviz-svg"), + margin = {top: 20, right: 20, bottom: 110, left: 40}, + margin2 = {top: 430, right: 20, bottom: 30, left: 40}, + width = +svg.attr("width") - margin.left - margin.right, + height = +svg.attr("height") - margin.top - margin.bottom, + height2 = +svg.attr("height") - margin2.top - margin2.bottom; + + + svg.selectAll("*").remove(); + + var date_array = []; + var value_array = []; + + data.forEach(function (arrayItem) { + date_array.push( new Date(arrayItem['date']) ); + value_array.push( arrayItem['value'] ); + }); + + + // Dimensions and margins + var svg = d3.select("#extension-privacy-manager-thing-dataviz-svg"); + + //var width = +svg.attr("width") + var width = document.getElementById('extension-privacy-manager-thing-dataviz').offsetWidth; + console.log("offsetWidth = " + width); + document.getElementById('extension-privacy-manager-thing-dataviz-svg').style.width = width + "px"; + //console.log(); + + var height = +svg.attr("height") + + width = width - 50; + height = height - 50; + + //var margin = {top: (0.1*width), right: (0.1*width), bottom: (0.1*width), left: (0.1*width)}; + //var margin = {top: 0, right: (0.1*width), bottom: (0.1*width), left: (0.1*width)}; + var margin = {top: 10, right: 0, bottom: 0, left: 50}; + + // create a clipping region + svg.append("defs").append("clipPath") + .attr("id", "clip") + .append("rect") + .attr("width", width) + .attr("height", height); + + // Give the data a bit more space at the top and bottom + var extra_low = d3.min(value_array) - 1; + var extra_high = d3.max(value_array) + 1; + + // Check if the minimum and maximum date range has changed/expanded. This is used when deleting data. + var minimum_time = d3.min(date_array) + var maximum_time = d3.max(date_array) + + if(minimum_time < this.min_time){ + this.min_time = minimum_time; + } + if(maximum_time > this.max_time){ + this.max_time = maximum_time; + } + + // create scale objects + var xScale = d3.scaleTime() + //.domain(d3.extent(date_array)) + .domain([minimum_time,maximum_time]) + .range([0, width]); + var yScale = d3.scaleLinear() + //.domain(d3.extent(value_array)) + .domain([d3.min(value_array) - 1, d3.max(value_array) + 1]) + .range([height, 0]); + + // create axes + var xAxis = d3.axisBottom(xScale); + //.ticks(20, "s"); + + + var yAxis = d3.axisLeft(yScale) + .ticks(20, "s"); + + // Draw Axis + var gX = svg.append('g') + .attr('transform', 'translate(' + margin.left + ',' + (margin.top + height) + ')') + .call(xAxis); + var gY = svg.append('g') + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + .call(yAxis); + + // Rectangle for the zoom function + var rectangle_overlay = svg.append("rect") + .attr("width", width) + .attr("height", height) + .style("fill", "none") + .style("pointer-events", "all") + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + //rectangle_overlay.call(zoom); + + // Create datapoints holder + var points_g = svg.append("g") + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + .attr("clip-path", "url(#clip)") + .classed("points_g", true); + + + // Draw Datapoints + var points = points_g.selectAll("circle").data(data); + + points = points.enter().append("circle") + .attr('cx', function(d) {return xScale(new Date(d.date))}) + .attr('cy', function(d) {return yScale(d.value)}) + .attr('r', 5) + .style("fill-opacity", .5) + .attr('class', 'extension-privacy-manager-svg-circle') + .attr("data-value", function(d) { return d.value; }) + .attr("data-date", function(d) { return d.date; }) + .attr("data-property-id", property_id ) + .attr("data-data-type", data_type ); + + // Points mouse events + points_g.selectAll("circle") + .on("mouseover", function(d) { + //console.log(this); + this.setAttribute('fill-opacity', 1); + this.setAttribute('r', 7); + }) + .on("mouseout", function(d) { + //console.log(this); + this.setAttribute('fill-opacity', .5); + this.setAttribute('r', 5); + }) + .on("click", function(d) { + //console.log(this); + //console.log( this.getAttribute("data-date") ); + //console.log( this.getAttribute("data-value") ); + //console.log( this.getAttribute("data-property-id") ); + //console.log( this.getAttribute("data-data-type") ); + + document.getElementById('extension-privacy-manager-thing-options').style.display = 'block'; + + // reset all circle to blue + d3.selectAll('.extension-privacy-manager-svg-circle') + .style('fill', 'black'); + + d3.select(this).style("fill", "magenta"); + + document.getElementById('extension-privacy-manager-input-change-old-epoch').value = this.getAttribute("data-date"); + + var select = new Date(Number(this.getAttribute("data-date"))); + console.log("selected point as date object = " + select); + + document.getElementById('extension-privacy-manager-input-change-value').value = this.getAttribute("data-value"); + document.getElementById('extension-privacy-manager-input-change-property-id').value = this.getAttribute("data-property-id"); + + document.getElementById('extension-privacy-manager-input-second').value = select.getSeconds(); + document.getElementById('extension-privacy-manager-input-minute').value = select.getMinutes(); //select.toLocaleDateString("en-UK",{minute: '2-digit'}); + document.getElementById('extension-privacy-manager-input-hour').value = select.getHours(); + document.getElementById('extension-privacy-manager-input-day').value = select.getDate(); + document.getElementById('extension-privacy-manager-input-month').value = select.getMonth(); + document.getElementById('extension-privacy-manager-input-year').value = select.getFullYear(); + document.getElementById('extension-privacy-manager-input-millis').value = select.getMilliseconds(); + }) + + + // Zooming + var zoom = d3.zoom() + .scaleExtent([.5, 20]) + .extent([[0, 0], [width, height]]) + .on("zoom", zoomed); + + rectangle_overlay.call(zoom); + + function zoomed() { + + // Create new scale + var new_xScale = d3.event.transform.rescaleX(xScale); + var new_yScale = d3.event.transform.rescaleY(yScale); + + // Update axis + gX.call(xAxis.scale(new_xScale)); + + points.data(data) + .attr('cx', function(d) {return new_xScale(d.date)}) + .attr('cy', function(d) {return yScale(d.value)}) + } + + } + + + + + // HELPER METHODS + + hasClass(ele,cls) { + //console.log(ele); + //console.log(cls); + return !!ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); + } + + addClass(ele,cls) { + if (!this.hasClass(ele,cls)) ele.className += " "+cls; + } + + removeClass(ele,cls) { + if (this.hasClass(ele,cls)) { + var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); + ele.className=ele.className.replace(reg,' '); + } + } + + + thing_list_click(the_target){ + const pre = document.getElementById('extension-privacy-manager-response-data'); + + // Update CSS + var remove_click_css_list = document.querySelectorAll('#extension-privacy-manager-thing-list > *'); + for (var i=0, max=remove_click_css_list.length; i < max; i++) { + this.removeClass(remove_click_css_list[i],"clicked"); + } + this.addClass(the_target,"clicked"); + + var target_property_id = the_target.getAttribute('data-property-id'); + var target_data_type = the_target.getAttribute('data-data-type'); + //console.log(target_data_type); + document.getElementById('extension-privacy-manager-input-change-data-type').value = target_data_type; // Make sure this is always populated with the correct data type. Bit of a clumsy use of hidden fields, should improve later. + //console.log(target_thing_id); + + // Get data for selected thing + window.API.postJson( + `/extensions/${this.id}/api/get_property_data`, + {'property_id': target_property_id, 'data_type':target_data_type} + ).then((body) => { + this.display_thing_data(target_property_id, target_data_type, body['data']); + //pre.innerText = JSON.stringify(body, null, 2); + //pre.innerText = body['state']; + }).catch((e) => { + console.log("Privacy manager: error getting property data"); + pre.innerText = e.toString(); + }); + + } + + + show() { + this.view.innerHTML = this.content; + + const pre = document.getElementById('extension-privacy-manager-response-data'); + const thing_list = document.getElementById('extension-privacy-manager-thing-list'); + const dataviz = document.getElementById('extension-privacy-manager-thing-dataviz'); + + const tab_button_sculptor = document.getElementById('extension-privacy-manager-tab-button-sculptor'); + const tab_button_internal = document.getElementById('extension-privacy-manager-tab-button-internal'); + + const tab_sculptor = document.getElementById('extension-privacy-manager-tab-sculptor'); + const tab_internal = document.getElementById('extension-privacy-manager-tab-internal'); + + const button_change_point = document.getElementById('extension-privacy-manager-button-change-point'); + const button_create_point = document.getElementById('extension-privacy-manager-button-create-point'); + const button_delete_point = document.getElementById('extension-privacy-manager-button-delete-point'); + const button_delete_before = document.getElementById('extension-privacy-manager-button-delete-before'); + const button_delete_after = document.getElementById('extension-privacy-manager-button-delete-after'); + + const input_change_value = document.getElementById('extension-privacy-manager-input-change-value'); + const input_change_property_id = document.getElementById('extension-privacy-manager-input-change-property-id'); + const input_change_data_type = document.getElementById('extension-privacy-manager-input-change-data-type'); + + pre.innerText = ""; + + + + // TABS + + // Data sculptor + tab_button_sculptor.addEventListener('click', () => { + this.addClass(tab_button_sculptor,"extension-privacy-manager-button-active"); + this.removeClass(tab_button_internal,"extension-privacy-manager-button-active"); + + this.addClass(tab_internal,"extension-privacy-manager-hidden"); + this.removeClass(tab_sculptor,"extension-privacy-manager-hidden"); + }); + + // Internal logs tab + tab_button_internal.addEventListener('click', () => { + this.addClass(tab_button_internal,"extension-privacy-manager-button-active"); + this.removeClass(tab_button_sculptor,"extension-privacy-manager-button-active"); + + this.addClass(tab_sculptor,"extension-privacy-manager-hidden"); + this.removeClass(tab_internal,"extension-privacy-manager-hidden"); + + window.API.postJson( + `/extensions/${this.id}/api/internal_logs`, + {'action':'get' ,'filename':'all'} + + ).then((body) => { + //thing_list.innerText = body['data']; + this.show_internal_logs(body['data']); + + }).catch((e) => { + //pre.innerText = e.toString(); + console.log("Privacy manager: error in show function"); + console.log(e.toString()); + }); + + }); + + + // CHANGE POINT + button_change_point.addEventListener('click', () => { + //console.log("Changing point"); + //console.log(input_change_date.value); + this.change_handler("change"); + }); + + + // CREATE POINT + button_create_point.addEventListener('click', () => { + //console.log("Creating a new point"); + this.change_handler("create"); + }); + + + // DELETE POINT + button_delete_point.addEventListener('click', () => { + //console.log("clicked delete"); + this.delete_handler("delete-point"); + }); + + // DELETE ALL BEFORE + button_delete_before.addEventListener('click', () => { + //console.log("clicked delete before"); + this.delete_handler("delete-before"); + }); + + // DELETE ALL AFTER + button_delete_after.addEventListener('click', () => { + //console.log("clicked delete after"); + this.delete_handler("delete-after"); + }); + + + + // Get list of properties for sculptor + + window.API.postJson( + `/extensions/${this.id}/api/init` //,{'init':1} + + ).then((body) => { + //thing_list.innerText = body['data']; + this.create_thing_list(body); + + }).catch((e) => { + //pre.innerText = e.toString(); + console.log("Privacy manager: error in show function"); + console.log(e.toString()); + }); + + + + // + // INITIALISE INTERNAL LOGS BUTTONS + // + + // DELETE ALL INTERNAL LOGS + document.getElementById('extension-privacy-manager-button-delete-all-logs').addEventListener('click', () => { + console.log("clicked delete all internal logs"); + this.delete_internal_logs("all"); + }); + + + } + + + get_new_date(){ + var fresh_date = new Date(0); + console.log(fresh_date); + fresh_date.setFullYear( document.getElementById('extension-privacy-manager-input-year').value ); + fresh_date.setMonth( document.getElementById('extension-privacy-manager-input-month').value ); + fresh_date.setDate( document.getElementById('extension-privacy-manager-input-day').value ); + fresh_date.setHours( document.getElementById('extension-privacy-manager-input-hour').value ); + fresh_date.setMinutes( document.getElementById('extension-privacy-manager-input-minute').value ); + fresh_date.setSeconds( document.getElementById('extension-privacy-manager-input-second').value ); + fresh_date.setMilliseconds( document.getElementById('extension-privacy-manager-input-millis').value ); + + console.log(document.getElementById('extension-privacy-manager-input-year').value); + console.log(document.getElementById('extension-privacy-manager-input-month').value); + console.log(document.getElementById('extension-privacy-manager-input-day').value); + console.log(document.getElementById('extension-privacy-manager-input-hour').value); + console.log(document.getElementById('extension-privacy-manager-input-minute').value); + console.log(document.getElementById('extension-privacy-manager-input-second').value); + console.log(document.getElementById('extension-privacy-manager-input-millis').value); + + console.log("new date stamp: " + fresh_date.valueOf() ); + + return fresh_date.valueOf(); + } + + + change_handler(action){ + const pre = document.getElementById('extension-privacy-manager-response-data'); + + var input_change_value = document.getElementById('extension-privacy-manager-input-change-value').value; + var updating_property_id = document.getElementById('extension-privacy-manager-input-change-property-id').value; + var updating_data_type = document.getElementById('extension-privacy-manager-input-change-data-type').value; + var old_date_stamp = document.getElementById('extension-privacy-manager-input-change-old-epoch').value; + var new_date_stamp = this.get_new_date(); // reconnect all the pieces from the dropdowns (and the hidden milliseconds value) into the new date + + console.log("____action = " + action); + console.log("property = " + updating_property_id); + console.log("of type = " + updating_data_type); + console.log("old_date_stamp = " + old_date_stamp); + console.log("new_date_stamp = " + new_date_stamp); + + + if( action == "create" && old_date_stamp == new_date_stamp ){ + console.log("Shouldn't make a new point at the same date as the old one.") + pre.innerText = "Please change the date of the new point."; + return + } + + window.API.postJson( + `/extensions/${this.id}/api/point_change_value`, + {'action':action, 'property_id':updating_property_id, 'data_type': updating_data_type ,'new_value':input_change_value, 'old_date': old_date_stamp, 'new_date': new_date_stamp,} + ).then((body) => { + //thing_list.innerText = body['data']; + //console.log(body); + document.getElementById('extension-privacy-manager-input-change-old-epoch').value = new_date_stamp; // Move new timestamp into "old timestamp" role, in case the user wants to change it again immediately. + this.display_thing_data(updating_property_id, updating_data_type, body['data']); + + }).catch((e) => { + console.log("Privacy manager: error in change handler"); + pre.innerText = e.toString(); + }); + } + + + + delete_handler(action){ + console.log("Deleting point(s). Action:"); + console.log(action); + //console.log(input_change_date.value); + + console.log("min-time: " + this.min_time); + console.log("min-time: " + this.max_time); + + const pre = document.getElementById('extension-privacy-manager-response-data'); + const options_pane = document.getElementById('extension-privacy-manager-thing-options'); + //const input_change_value = document.getElementById('extension-privacy-manager-input-change-value'); + + var updating_data_type = document.getElementById('extension-privacy-manager-input-change-data-type').value; + var updating_property_id = document.getElementById('extension-privacy-manager-input-change-property-id').value; + + // In the future users could delete a selection + + const selected_point_date = document.getElementById('extension-privacy-manager-input-change-old-epoch').value; + if( action == "delete-point" ){ + var start_date_stamp = selected_point_date + var end_date_stamp = selected_point_date; //this.get_new_date(); // reconnect all the pieces from the dropdowns (and the hidden milliseconds value) into the new date + } + else if( action == "delete-before" ){ + var start_date_stamp = this.min_time.getTime(); //toUTCString(); + var end_date_stamp = selected_point_date; + } + else if( action == "delete-after" ){ + var start_date_stamp = selected_point_date + var end_date_stamp = this.max_time.getTime(); //.toUTCString(); + } + + console.log("____action = " + action); + console.log("property = " + updating_property_id); + console.log("of type = " + updating_data_type); + console.log("end_date_stamp = " + end_date_stamp); + console.log("start_date_stamp = " + start_date_stamp); + + options_pane.style.opacity = .5; + + + window.API.postJson( + `/extensions/${this.id}/api/point_delete`, + {'action':action, 'property_id':updating_property_id, 'data_type':updating_data_type, 'start_date':start_date_stamp, 'end_date':end_date_stamp} + ).then((body) => { + options_pane.style.opacity = 1; + //console.log(body['data']); + + document.getElementById('extension-privacy-manager-input-change-old-epoch').value = ""; + document.getElementById('extension-privacy-manager-input-change-value').value = ""; + + // Update the dataviz + this.display_thing_data(updating_property_id, updating_data_type, body['data']); + + }).catch((e) => { + console.log("Privacy manager: error in deletion handler"); + pre.innerText = e.toString(); + }); + + } // End of button delete point add listener + + + + + + // + // INTERNAL LOGS + // + + + show_internal_logs(file_list) { + + const pre = document.getElementById('extension-privacy-manager-response-data'); + const logs_list = document.getElementById('extension-privacy-manager-logs-list'); + + file_list.sort(); + //console.log(file_list) + + logs_list.innerHTML = ""; + + for (var key in file_list) { + + var this_object = this; + + var node = document.createElement("LI"); // Create a
  • node + node.setAttribute("class", "extension-privacy-manager-deletable_item" ); + node.setAttribute("data-filename", file_list[key] ); + + var textnode = document.createTextNode( file_list[key] ); // Create a text node + node.onclick = function() { + this_object.delete_internal_logs( file_list[key] ) + }; + node.appendChild(textnode); + + logs_list.appendChild(node); + } + pre.innerText = ""; + } + + + + delete_internal_logs(filename){ + //console.log("Deleting log files. filename:"); + //console.log(filename); + + const pre = document.getElementById('extension-privacy-manager-response-data'); + const logs_list = document.getElementById('extension-privacy-manager-logs-list'); + + window.API.postJson( + `/extensions/${this.id}/api/internal_logs`, + {'action':'delete', 'filename':filename} + + ).then((body) => { + //console.log(body); + this.show_internal_logs(body['data']); + + }).catch((e) => { + console.log("Privacy manager: error in internal log deletion handler"); + pre.innerText = e.toString(); + }); + + } // End of button delete point add listener + + } + + new PrivacyManager(); + +})(); + + diff --git a/main.py b/main.py new file mode 100644 index 0000000..5d104ce --- /dev/null +++ b/main.py @@ -0,0 +1,40 @@ +"""Privacy Manager add-on for Mozilla WebThings Gateway.""" + +from os import path +import functools +import gateway_addon +import signal +import sys +import time + +sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib')) + +#from pkg.power_settings import PowerSettingsAdapter # noqa +from pkg.privacy_manager import PrivacyManagerAPIHandler # noqa + + + +_HANDLER = None + +print = functools.partial(print, flush=True) + + +def cleanup(signum, frame): + """Clean up any resources before exiting.""" + if _HANDLER is not None: + _HANDLER.close_proxy() + + sys.exit(0) + + +if __name__ == '__main__': + signal.signal(signal.SIGINT, cleanup) + signal.signal(signal.SIGTERM, cleanup) + #_HANDLER = PowerSettingsAdapter(verbose=True) + _HANDLER = PrivacyManagerAPIHandler(verbose=True) + + + # Wait until the proxy stops running, indicating that the gateway shut us + # down. + while _HANDLER.proxy_running(): + time.sleep(2) \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..8523145 --- /dev/null +++ b/manifest.json @@ -0,0 +1,54 @@ +{ + "author": "Candle", + "content_scripts": [ + { + "css": [ + "css/extension.css", + "css/tail.datetime.css" + ], + "js": [ + "js/extension.js", + "js/d3.min.js" + ] + } + ], + "description": "Manage and sculpt your data", + "gateway_specific_settings": { + "webthings": { + "exec": "python3 {path}/main.py", + "primary_type": "extension", + "strict_max_version": "*", + "strict_min_version": "0.10.0" + } + }, + "homepage_url": "https://github.com/createcandle/privacy-manager", + "id": "privacy-manager", + "license": "MPL-2.0", + "manifest_version": 1, + "name": "Privacy Manager", + "options": { + "default": { + "Debugging": false + }, + "schema": { + "properties": { + "Debugging": { + "description": "Debugging allows you to diagnose any issues with the add-on. If enabled it will result in a lot more debug data in the internal log (which can be found under Settings -> Developer -> View internal logs).", + "type": "boolean" + } + }, + "required": [ + "Debugging" + ], + "type": "object" + } + }, + "short_name": "Privacy", + "version": "0.0.1", + "web_accessible_resources": [ + "css/*.css", + "images/*.svg", + "js/*.js", + "views/*.html" + ] +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..5741ee5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1122 @@ +{ + "name": "example-extension", + "version": "0.0.3", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/generator": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.0.tgz", + "integrity": "sha512-Ms8Mo7YBdMMn1BYuNtKuP/z0TgEIhbcyB8HVR6PPNYp4P61lMsABiS4A3VG1qznjXVCf3r+fVHhm4efTYVsySA==", + "dev": true, + "requires": { + "@babel/types": "^7.6.0", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/helper-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", + "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", + "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", + "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "dev": true, + "requires": { + "@babel/types": "^7.4.4" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.0.tgz", + "integrity": "sha512-+o2q111WEx4srBs7L9eJmcwi655eD8sXniLqMB93TBK9GrNzGrxDWSjiqz2hLU0Ha8MTXFIP0yd9fNdP+m43ZQ==", + "dev": true + }, + "@babel/template": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.6.0.tgz", + "integrity": "sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.6.0", + "@babel/types": "^7.6.0" + } + }, + "@babel/traverse": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.0.tgz", + "integrity": "sha512-93t52SaOBgml/xY74lsmt7xOR4ufYvhb5c5qiM6lu4J/dWGMAfAh6eKw4PjLes6DI6nQgearoxnFJk60YchpvQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.6.0", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.6.0", + "@babel/types": "^7.6.0", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.1.tgz", + "integrity": "sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "acorn": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "dev": true + }, + "acorn-jsx": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz", + "integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==", + "dev": true + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, + "babel-eslint": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.0.3.tgz", + "integrity": "sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.0.0", + "@babel/traverse": "^7.0.0", + "@babel/types": "^7.0.0", + "eslint-visitor-keys": "^1.0.0", + "resolve": "^1.12.0" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.5.1.tgz", + "integrity": "sha512-32h99BoLYStT1iq1v2P9uwpyznQ4M2jRiFB6acitKz52Gqn+vPaMDUTB1bYi1WN4Nquj2w+t+bimYUG83DC55A==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.2", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.4.1", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + } + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", + "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.0.0" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "espree": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.1.tgz", + "integrity": "sha512-EYbr8XZUhWbYCqQRW0duU5LxzL5bETN6AjKBGy1302qqzPaCH10QbRg3Wvco79Z8x9WbiE8HYB4e75xl6qUYvQ==", + "dev": true, + "requires": { + "acorn": "^7.0.0", + "acorn-jsx": "^5.0.2", + "eslint-visitor-keys": "^1.1.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", + "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "inquirer": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz", + "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==", + "dev": true, + "requires": { + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^2.0.0", + "lodash": "^4.17.12", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^2.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "rxjs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", + "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + } + } +} diff --git a/package.sh b/package.sh new file mode 100644 index 0000000..ff4352c --- /dev/null +++ b/package.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +version=$(grep '"version":' manifest.json | cut -d: -f2 | cut -d\" -f2) + +rm -rf SHA256SUMS package +rm -rf ._* +mkdir package +cp *.py manifest.json LICENSE README.md package/ +cp -r pkg css images js views package/ +cd package +find . -type f \! -name SHA256SUMS -exec sha256sum {} \; >> SHA256SUMS +cd .. + +tar czf "privacy-manager-${version}.tgz" package +sha256sum "privacy-manager-${version}.tgz" diff --git a/pkg/privacy_manager.py b/pkg/privacy_manager.py new file mode 100644 index 0000000..71d4cd8 --- /dev/null +++ b/pkg/privacy_manager.py @@ -0,0 +1,651 @@ +"""Power Settings API handler.""" + + +import functools +import json +import os +#from os import listdir +#from os.path import isfile, join +from time import sleep +import datetime +import subprocess +import sqlite3 +import requests + +try: + from gateway_addon import APIHandler, APIResponse + #print("succesfully loaded APIHandler and APIResponse from gateway_addon") +except: + print("Import APIHandler and APIResponse from gateway_addon failed. Use at least WebThings Gateway version 0.10") + +try: + from gateway_addon import Adapter, Device, Database +except: + print("Gateway not loaded?!") + +print = functools.partial(print, flush=True) + + +class PrivacyManagerAPIHandler(APIHandler): + """Power settings API handler.""" + + def __init__(self, verbose=False): + """Initialize the object.""" + #print("INSIDE API HANDLER INIT") + + + + + self.server = 'http://127.0.0.1:8080' + self.DEV = True + self.DEBUG = False + + self.things = [] # Holds all the things, updated via the API. Used to display a nicer thing name instead of the technical internal ID. + self.data_types_lookup_table = {} + + try: + manifest_fname = os.path.join( + os.path.dirname(__file__), + '..', + 'manifest.json' + ) + + with open(manifest_fname, 'rt') as f: + manifest = json.load(f) + + APIHandler.__init__(self, manifest['id']) + self.manager_proxy.add_api_handler(self) + + + # LOAD CONFIG + try: + self.add_from_config() + except Exception as ex: + print("Error loading config: " + str(ex)) + + + if self.DEBUG: + print("self.manager_proxy = " + str(self.manager_proxy)) + print("Created new API HANDLER: " + str(manifest['id'])) + except Exception as e: + print("Failed to init UX extension API handler: " + str(e)) + + try: + self.addon_path = os.path.join(os.path.expanduser('~'), '.mozilla-iot', 'addons', 'privacy-manager') + self.log_dir_path = os.path.join(os.path.expanduser('~'), '.mozilla-iot', 'log') + self.log_db_path = os.path.join(self.log_dir_path, 'logs.sqlite3') + + except Exception as e: + print("Failed to further init UX extension API handler: " + str(e)) + + # Respond to gateway version + try: + if self.DEBUG: + print(self.gateway_version) + except: + print("self.gateway_version did not exist") + + while(True): + sleep(1) + + + + + # Read the settings from the add-on settings page + def add_from_config(self): + """Attempt to add all configured devices.""" + try: + database = Database('privacy-manager') + if not database.open(): + print("Could not open settings database") + return + + config = database.load_config() + database.close() + + except: + print("Error! Failed to open settings database.") + + if not config: + print("Error loading config from database") + return + + if self.DEV: + print(str(config)) + + if 'Debugging' in config: + self.DEBUG = bool(config['Debugging']) + if self.DEBUG: + print("-Debugging preference was in config: " + str(self.DEBUG)) + + + + def handle_request(self, request): + """ + Handle a new API request for this handler. + + request -- APIRequest object + """ + + try: + + if request.method != 'POST': + return APIResponse(status=404) + + if request.path == '/init' or request.path == '/get_property_data' or request.path == '/point_change_value' or request.path == '/point_delete' or request.path == '/internal_logs': + + try: + + if request.path == '/init': + + # Get the list of properties that are being logged + try: + data = self.get_init_data() + if isinstance(data, str): + state = 'error' + else: + state = 'ok' + + return APIResponse( + status=200, + content_type='application/json', + content=json.dumps({'state' : state, 'data' : data}), + ) + except Exception as ex: + print("Error getting init data: " + str(ex)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("Error while getting thing data: " + str(ex)), + ) + + + + elif request.path == '/get_property_data': + try: + target_data_type = self.data_types_lookup_table[int(request.body['property_id'])] + print("target data type from internal lookup table: " + str(target_data_type)) + data = self.get_property_data( str(request.body['property_id']), target_data_type ) + if isinstance(data, str): + state = 'error' + else: + state = 'ok' + + return APIResponse( + status=200, + content_type='application/json', + content=json.dumps({'state' : state, 'data' : data}), + ) + except Exception as ex: + print("Error getting thing data: " + str(ex)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("Error while getting thing data: " + str(ex)), + ) + + + elif request.path == '/point_change_value': + try: + data = [] + target_data_type = self.data_types_lookup_table[int(request.body['property_id'])] + print("target data type from internal lookup table: " + str(target_data_type)) + # action, data_type, property_id, new_value, old_date, new_date + data = self.point_change_value( str(request.body['action']), target_data_type, str(request.body['property_id']), str(request.body['new_value']), str(request.body['old_date']), str(request.body['new_date']) ) + if isinstance(data, str): + state = 'error' + else: + state = 'ok' + + return APIResponse( + status=200, + content_type='application/json', + content=json.dumps({'state' : state, 'data' : data}), + ) + except Exception as ex: + print("Error getting thing data: " + str(ex)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("Error while changing point: " + str(ex)), + ) + + + + + elif request.path == '/point_delete': + print("POINT DELETE CALLED") + try: + data = [] + + target_data_type = self.data_types_lookup_table[int(request.body['property_id'])] + print("target data type from internal lookup table: " + str(target_data_type)) + + data = self.point_delete(str(request.body['property_id']), target_data_type, str(request.body['start_date']), str(request.body['end_date']) ) #new_value,date,property_id + if isinstance(data, str): + state = 'error' + else: + state = 'ok' + + return APIResponse( + status=200, + content_type='application/json', + content=json.dumps({'state' : state, 'data' : data}), + ) + except Exception as ex: + print("Error deleting point(s): " + str(ex)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("Error while deleting point(s): " + str(ex)), + ) + + + + + elif request.path == '/internal_logs': + print("INTERNAL LOGS CALLED") + try: + data = [] + + action = "get" + filename = "all" + try: + filename = str(request.body['filename']) + except: + print("No specific filename provided") + try: + action = str(request.body['action']) + except: + print("No specific action provided, will read data.") + + data = self.internal_logs(action, filename) + if isinstance(data, str): + state = 'error' + else: + state = 'ok' + + return APIResponse( + status=200, + content_type='application/json', + content=json.dumps({'state' : state, 'data' : data}), + ) + except Exception as ex: + print("Error deleting point(s): " + str(ex)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("Error while getting logs data: " + str(ex)), + ) + + + else: + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("API error"), + ) + + + except Exception as ex: + print(str(ex)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("Error"), + ) + + else: + return APIResponse(status=404) + + except Exception as e: + print("Failed to handle UX extension API request: " + str(e)) + return APIResponse( + status=500, + content_type='application/json', + content=json.dumps("API Error"), + ) + + + + + # INIT + def get_init_data(self): + if self.DEBUG: + print("Getting the initialisation data") + + try: + db = sqlite3.connect(':memory:') + db = sqlite3.connect(self.log_db_path) + except Exception as e: + print("Error opening log file: " + str(e)) + return "Error opening log file: " + str(e) + + # Get list of properties that are being logged from database + try: + result = [] + cursor = db.cursor() + cursor.execute("SELECT id,descr,maxAge FROM metricIds") + all_rows = cursor.fetchall() + #if self.DEBUG: + #print(str(all_rows)); + for row in all_rows: + + # Get human readable title, if it's available. + current_title = str(row[0]) + data_type = "none" + try: + cursor.execute("SELECT value FROM metricsNumber WHERE id=?", (row[0],)) + data_check = cursor.fetchall() + if len(data_check) > 0: + data_type = "metricsNumber" + self.data_types_lookup_table[row[0]] = 'metricsNumber' + if self.DEBUG: + print("Data type for this log is Number") + else: + try: + cursor.execute("SELECT value FROM metricsBoolean WHERE id=?", (row[0],)) + data_check = cursor.fetchall() + if len(data_check) > 0: + data_type = "metricsBoolean" + self.data_types_lookup_table[row[0]] = 'metricsBoolean' + if self.DEBUG: + print("Data type for this log is Boolean") + else: + print("Datatype also wasn't boolean. Must be other?") + # TODO here support for "other" can be added later, if necessary + except Exception as ex: + print("Error querying if boolean data exists for this item: " + str(ex)) + + except Exception as ex: + print("Error getting test data to determine data type: " + str(ex)) + + #print("data_type = " + str(data_type)) + result.append( {'id':row[0],'name':row[1], 'data_type':data_type} ) + + db.close() + return result + + except Exception as e: + print("Init: Error reading data: " + str(e)) + try: + db.close() + except: + pass + return "Init: general error reading data: " + str(e) + + + + # GET ALL DATA FOR A SINGLE THING + def get_property_data(self, property_id, data_type): + if self.DEBUG: + print("Getting data for thing " + str(property_id) + " of type " + str(data_type)) + result = [] + + if property_id == None or data_type == None: + print("No thing ID or data type provided") + return result + + if not data_type in ("metricsBoolean", "metricsNumber", "metricsOther"): + print("data_type not of allowed type") + return "error" + + try: + db = sqlite3.connect(':memory:') + db = sqlite3.connect(self.log_db_path) + except Exception as e: + print("Error opening log database: " + str(e)) + return "Error opening log database: " + str(e) + + try: + cursor = db.cursor() + cursor.execute("SELECT date, value FROM " + data_type + " WHERE id=?",(property_id,)) + all_rows = cursor.fetchall() + + for row in all_rows: + #print('date: {0}, value: {1}'.format(row[0],row[1])) + result.append( {'date':row[0],'value':row[1]} ) + + db.close() + return result + + except Exception as e: + print("Get property data: error reading data: " + str(e)) + try: + db.close() + except: + pass + return "get_property_data: error reading data: " + str(e) + + return "ok" + + + + + # CHANGE VALUE OF A SINGLE POINT + def point_change_value(self, action, data_type, property_id, new_value, old_date, new_date): + print("Asked to change/create data point for property " + str(property_id) + " of type " + str(data_type) + " in table " + str(action) + " to " + str(new_value)) + result = "error" + + if property_id == None or action == None: + print("No action set or property ID provided") + return "error" + + if not data_type in ("metricsBoolean", "metricsNumber", "metricsOther"): + print("data_type not of allowed type") + return "error" + + if data_type == "metricsBoolean": + if float(new_value) >= 1: + new_value = 1 + else: + new_value = 0 + elif data_type == "metricsNumber": + try: + new_value = int(new_value) + except: + new_value = float(new_value) + + try: + new_date = int(new_date) + old_date = int(old_date) + property_id = int(property_id) + except: + print("Error: the date and/or property strings could not be turned into an int") + return "error" + + if self.DEBUG: + print("action: " + str(action)) + print("At old date " + str(old_date)) + print("and new date " + str(new_date)) + print("changing value to " + str(new_value)) + print("for property " + str(property_id)) + print("of type " + str(data_type)) + + try: + db = sqlite3.connect(':memory:') + db = sqlite3.connect(self.log_db_path) + except Exception as e: + print("Error opening log file: " + str(e)) + return "Error opening log file: " + str(e) + + try: + cursor = db.cursor() + + if action == "change": + cursor.execute("UPDATE " + data_type + " SET value=?,date=? WHERE date=? AND id=?", (new_value,new_date,old_date,property_id)) + if cursor.rowcount == 1: + db.commit() + #result = "ok" + result = [] + + else: + return "error" #result = "error" + + + elif action == "create": + print("Creating a new data point") + #INSERT INTO projects(name,begin_date,end_date) VALUES(?,?,?) + #cursor.execute("INSERT INTO employees VALUES(1, 'John', 700, 'HR', 'Manager', '2017-01-04')" + command = "INSERT INTO {}(id,date,value) VALUES({},{},{})".format(data_type, property_id, new_date, new_value) + print("COMMAND = " + str(command)) + cursor.execute(command) + #cursor.execute("INSERT INTO " + data_type + " VALUES ?,?,?", (property_id, new_date, new_value,)) + db.commit() + + # update cursor position? + cursor.close() + cursor = db.cursor() + result = [] + + # If all went well, get all the data points. + cursor.execute("SELECT date, value FROM " + data_type + " WHERE id=?", (property_id,)) + all_rows = cursor.fetchall() + #if self.DEBUG: + + for row in all_rows: + #print('date: {0}, value: {1}'.format(row[0],row[1])) + result.append( {'date':row[0],'value':row[1]} ) + + db.close() + return result + + except Exception as e: + print("Error changing point data: " + str(e)) + try: + db.close() + except: + pass + return "Error changing point data: " + str(e) + + + + + + # DELETE A SINGLE POINT + + def point_delete(self,property_id,data_type,start_date,end_date): + + result = "error" + + if property_id == None: + print("No property ID provided") + return result + + if not data_type in ("metricsBoolean", "metricsNumber", "metricsOther"): + print("data_type not of allowed type") + return "error" + + if self.DEBUG: + print("Delete from " + str(start_date)) + print("to " + str(end_date)) + print("for ID " + str(property_id)) + print("of data_type " + str(data_type)) + + try: + db = sqlite3.connect(':memory:') + db = sqlite3.connect(self.log_db_path) + except Exception as e: + print("Error opening log file: " + str(e)) + return "Error opening log file: " + str(e) + + try: + cursor = db.cursor() + + cursor.execute("DELETE FROM " + data_type + " WHERE id=? AND date>=? AND date<=?", (property_id,start_date,end_date,)) + print("cursor.rowcount after deletion = " + str(cursor.rowcount)) + if cursor.rowcount > 0: + db.commit() + result = [] + #cursor.close() + #cursor = db.cursor() + #Get all the data points. + cursor.execute("SELECT date, value FROM " + data_type + " WHERE id=?", (property_id,)) + all_rows = cursor.fetchall() + + for row in all_rows: + print('date: {0}, value: {1}'.format(row[0],row[1])) + result.append( {'date':row[0],'value':row[1]} ) + + else: + result = "error" + + print(str(result)) + db.close() + return result + + except Exception as e: + print("Error deleting a point: " + str(e)) + try: + db.close() + except: + pass + return "Error deleting a point: " + str(e) + + + + + + + def internal_logs(self,action,filename): + print("in internal logs method. Filename: " + str(filename)) + + result = [] + + try: + # First we delete what needs to be deleted. + if action == "delete": + for fname in os.listdir(self.log_dir_path): + if fname.startswith("run-app.log"): + if filename == "all": + try: + os.remove(os.path.join(self.log_dir_path, fname)) + if self.DEBUG: + print("File deleted") + except Exception as ex: + if self.DEBUG: + print("Could not delete file: " + str(ex)) + elif str(filename) == str(fname): + print("WILL DELETE A SINGLE FILE: " + str(filename)) + try: + os.remove(os.path.join(self.log_dir_path, fname)) + if self.DEBUG: + print("File deleted") + except Exception as ex: + if self.DEBUG: + print("Could not delete file: " + str(ex)) + + # Secondly, we send a list of (remaining) existing files. + for fname in os.listdir(self.log_dir_path): + if fname.startswith("run-app.log"): + result.append(fname) + + + except Exception as ex: + print("Error in log handler: " + str(ex)) + + return result + + + def unload(self): + if self.DEBUG: + print("Shutting down") + + + + +def run_command(cmd, timeout_seconds=60): + try: + + p = subprocess.run(cmd, timeout=timeout_seconds, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True) + + if p.returncode == 0: + return p.stdout + '\n' + "Command success" #.decode('utf-8') + #yield("Command success") + else: + if p.stderr: + return "Error: " + str(p.stderr) + '\n' + "Command failed" #.decode('utf-8')) + + except Exception as e: + print("Error running Arduino CLI command: " + str(e)) + \ No newline at end of file diff --git a/views/content.html b/views/content.html new file mode 100644 index 0000000..7c4aeec --- /dev/null +++ b/views/content.html @@ -0,0 +1,301 @@ +
    + +
    +

    Privacy manager

    +
    + + +
    + +
    +

    Data sculptor

    +
    +
    +
      +
      +
      +
      + +
      +
      +
      +

      Selected point

      + + + + + +
      +
      + + Y + + + M + + + D + +
      + +
      + + h + + + m + + + s + +
      +
      + +
      + +
      + +
      + + + + + + + +
      +
      +
      + +
      +
      +
      +
      + + +
      +

      Internal logs

      +
      + +
      + + +
      +
      + +
      +

      +
      +
      + +
      +
      + + + + +