UNPKG

@eledah/parto

Version:

Framework-agnostic argument map sunburst charts with light/dark themes

2 lines 68.6 kB
var Parto=(function(Dt){Object.defineProperty(Dt,Symbol.toStringTag,{value:"Module"});var Ft={legend:"Argument types",center:"Center",support:"Agree",attack:"Disagree",claim:"Claim",unknownSpeaker:"Unknown",intensity:"Intensity",confidence:"Confidence",statusLoading:"Loading map…",statusEmpty:"No map data yet.",statusError:"Could not load this argument map."},at={center:"#b08a3e",support:"#3f7652",attack:"#9f4f4f",border:"#ffffff"},b={colors:{...at},chart:{maxCenterRadius:.4,radiusPadding:5,minRadius:10,cornerRadius:3,strokeWidth:.5},spacing:{verticalGap:.01,padAngle:{inner:.025,outer:.012},radiusExponent:{base:1.2,perLevel:.2},exponentDepthThreshold:3}},un={center:"--pam-center",support:"--pam-support",attack:"--pam-attack",border:"--pam-border"};function hn(t){return!!(t&&(t.startsWith("#")||t.startsWith("rgb")))}function lt(t){const e=getComputedStyle(t);for(const[n,r]of Object.entries(un)){const i=e.getPropertyValue(r).trim();hn(i)&&(b.colors[n]=i)}}function he(t,e){for(const[n,r]of Object.entries({center:"--pam-center",support:"--pam-support",attack:"--pam-attack",border:"--pam-border"})){const i=e[n];i&&t.style.setProperty(r,i)}lt(t)}function cn(t){const e=[],n=new Map;for(const s of t)n.set(s.id,s);const r=t.find(s=>s.type==="thesis");if(!r)return{tree:null,warnings:["No thesis node found"]};const i=new Map;for(const s of t)for(const a of s.relations){if(!n.has(a.target_node_id))continue;const l=i.get(a.target_node_id)??[];l.push({childId:s.id,relationType:a.relation_type,reasoning:a.reasoning}),i.set(a.target_node_id,l)}const o=(s,a,l,h,u,f)=>{const c=f.join("/"),p={...s,children:[],value:1,relationType:l,relationReasoning:h,parentId:a,pathKey:c};if(u.has(s.id))return e.push(`Cycle detected at node ${s.id}; branch skipped`),p;const d=new Set(u);d.add(s.id);const m=i.get(s.id)??[];for(const y of m){const _=n.get(y.childId);if(!_)continue;const w=o(_,s.id,y.relationType,y.reasoning,d,[...f,y.childId]);p.children.push(w)}return p};return{tree:o(r,void 0,void 0,void 0,new Set,[r.id]),warnings:e}}function ce(t,e){if(!t)return null;if(t.id===e)return t;for(const n of t.children){const r=ce(n,e);if(r)return r}return null}function fn(t,e){if(!t||e.length===0)return null;let n=t;for(let r=1;r<e.length;r++){const i=e[r];if(n=n?.children.find(o=>o.id===i)??null,!n)return null}return n}function dn(t,e){const n=[],r=(i,o)=>{const s=[...o,i];if(i.id===e)return n.push(...s),!0;for(const a of i.children)if(r(a,s))return!0;return!1};return r(t,[]),n}function pn(t,e){return e&&t.id===e.id?"pam-arc--center":t.relationType==="attack"?"pam-arc--attack":"pam-arc--support"}function mn(t,e,n){return e&&t.id===e.id?n.center:t.relationType==="attack"?n.attack:n.support}var gn=class extends Error{constructor(t){super(t),this.name="ArgumentMapError"}},Q=class extends gn{issues;constructor(t){super(t.join("; ")),this.name="ValidationError",this.issues=t}};function yn(t){const e=[],n=[];if(!t||typeof t!="object")throw new Q(["Map data must be an object"]);const r=t;if(!Array.isArray(r.new_nodes))throw new Q(["Map data must include a new_nodes array"]);const i=[],o=new Set;let s=0;for(const l of r.new_nodes){if(!l||typeof l!="object"){e.push("Each node must be an object");continue}const h=l,u=String(h.id??"");if(!u){e.push("Node is missing id");continue}if(o.has(u)){e.push(`Duplicate node id: ${u}`);continue}o.add(u);const f=String(h.type??"");f==="thesis"&&(s+=1);const c=(Array.isArray(h.relations)?h.relations:[]).map(d=>{const m=d,y=String(m.relation_type??"");return y!=="support"&&y!=="attack"&&e.push(`Node ${u} has unsupported relation_type: ${y}`),{target_node_id:String(m.target_node_id??""),relation_type:y,reasoning:String(m.reasoning??"")}}),p={id:u,type:f,title:String(h.title??""),description:String(h.description??""),quote:String(h.quote??""),speaker:String(h.speaker??""),relations:c};if(h.score&&typeof h.score=="object"){const d=h.score;p.score={intensity:Number(d.intensity??0),confidence:Number(d.confidence??0)}}i.push(p)}if(e.length>0)throw new Q(e);if(s===0)throw new Q(["Map must include exactly one thesis node"]);if(s>1)throw new Q(["Map must include exactly one thesis node"]);const a=new Set(i.map(l=>l.id));for(const l of i)for(const h of l.relations)a.has(h.target_node_id)||n.push(`Node ${l.id} references missing target ${h.target_node_id}`);return{data:{new_nodes:i},warnings:n}}var _n=class{fullTree=null;zoomStack=[];setTree(t){this.fullTree=t,this.zoomStack=t?[t]:[]}getFocusRoot(){return this.zoomStack.length===0?null:this.zoomStack[this.zoomStack.length-1]??null}getFullTree(){return this.fullTree}getZoomPath(){return this.zoomStack.map(t=>({id:t.id,title:t.title,type:t.type,relationType:t.relationType}))}resetZoom(){this.fullTree&&(this.zoomStack=[this.fullTree])}zoomTo(t){if(!this.fullTree)return!1;const e=dn(this.fullTree,t);return e.length===0||!e[e.length-1]?!1:(this.zoomStack=e,!0)}zoomToPath(t){if(!this.fullTree||t.length===0||!fn(this.fullTree,t))return!1;const e=[];let n=this.fullTree;e.push(n);for(let r=1;r<t.length;r++){const i=t[r],o=n.children.find(s=>s.id===i);if(!o)return!1;e.push(o),n=o}return this.zoomStack=e,!0}zoomIn(t){return(t.children?.length??0)===0?!1:(this.zoomStack.push(t),!0)}zoomOut(){return this.zoomStack.length<=1?!1:(this.zoomStack.pop(),!0)}handleClick(t,e,n){if(e===0){this.zoomOut();return}if(n){const r=ce(this.getFocusRoot(),t.id);r&&this.zoomIn(r)}}},vn={value:()=>{}};function fe(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new yt(n)}function yt(t){this._=t}function wn(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}yt.prototype=fe.prototype={constructor:yt,on:function(t,e){var n=this._,r=wn(t+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o<s;)if((i=(t=r[o]).type)&&(i=xn(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<s;)if(i=(t=r[o]).type)n[i]=de(n[i],t.name,e);else if(e==null)for(i in n)n[i]=de(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new yt(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function xn(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function de(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=vn,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var bn="http://www.w3.org/1999/xhtml",pe={svg:"http://www.w3.org/2000/svg",xhtml:bn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _t(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),pe.hasOwnProperty(e)?{space:pe[e],local:t}:t}function $n(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n==="http://www.w3.org/1999/xhtml"&&e.documentElement.namespaceURI==="http://www.w3.org/1999/xhtml"?e.createElement(t):e.createElementNS(n,t)}}function An(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function me(t){var e=_t(t);return(e.local?An:$n)(e)}function kn(){}function qt(t){return t==null?kn:function(){return this.querySelector(t)}}function Cn(t){typeof t!="function"&&(t=qt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],s=o.length,a=r[i]=new Array(s),l,h,u=0;u<s;++u)(l=o[u])&&(h=t.call(l,l.__data__,u,o))&&("__data__"in l&&(h.__data__=l.__data__),a[u]=h);return new C(r,this._parents)}function Tn(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Nn(){return[]}function ge(t){return t==null?Nn:function(){return this.querySelectorAll(t)}}function En(t){return function(){return Tn(t.apply(this,arguments))}}function Mn(t){typeof t=="function"?t=En(t):t=ge(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var s=e[o],a=s.length,l,h=0;h<a;++h)(l=s[h])&&(r.push(t.call(l,l.__data__,h,s)),i.push(l));return new C(r,i)}function ye(t){return function(){return this.matches(t)}}function _e(t){return function(e){return e.matches(t)}}var Sn=Array.prototype.find;function Rn(t){return function(){return Sn.call(this.children,t)}}function zn(){return this.firstElementChild}function Ln(t){return this.select(t==null?zn:Rn(typeof t=="function"?t:_e(t)))}var On=Array.prototype.filter;function Pn(){return Array.from(this.children)}function In(t){return function(){return On.call(this.children,t)}}function Hn(t){return this.selectAll(t==null?Pn:In(typeof t=="function"?t:_e(t)))}function Dn(t){typeof t!="function"&&(t=ye(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],s=o.length,a=r[i]=[],l,h=0;h<s;++h)(l=o[h])&&t.call(l,l.__data__,h,o)&&a.push(l);return new C(r,this._parents)}function ve(t){return new Array(t.length)}function Fn(){return new C(this._enter||this._groups.map(ve),this._parents)}function vt(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}vt.prototype={constructor:vt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function qn(t){return function(){return t}}function Bn(t,e,n,r,i,o){for(var s=0,a,l=e.length,h=o.length;s<h;++s)(a=e[s])?(a.__data__=o[s],r[s]=a):n[s]=new vt(t,o[s]);for(;s<l;++s)(a=e[s])&&(i[s]=a)}function Xn(t,e,n,r,i,o,s){var a,l,h=new Map,u=e.length,f=o.length,c=new Array(u),p;for(a=0;a<u;++a)(l=e[a])&&(c[a]=p=s.call(l,l.__data__,a,e)+"",h.has(p)?i[a]=l:h.set(p,l));for(a=0;a<f;++a)p=s.call(t,o[a],a,o)+"",(l=h.get(p))?(r[a]=l,l.__data__=o[a],h.delete(p)):n[a]=new vt(t,o[a]);for(a=0;a<u;++a)(l=e[a])&&h.get(c[a])===l&&(i[a]=l)}function Zn(t){return t.__data__}function Vn(t,e){if(!arguments.length)return Array.from(this,Zn);var n=e?Xn:Bn,r=this._parents,i=this._groups;typeof t!="function"&&(t=qn(t));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),h=0;h<o;++h){var u=r[h],f=i[h],c=f.length,p=Yn(t.call(u,u&&u.__data__,h,r)),d=p.length,m=a[h]=new Array(d),y=s[h]=new Array(d);n(u,f,m,y,l[h]=new Array(c),p,e);for(var _=0,w=0,x,$;_<d;++_)if(x=m[_]){for(_>=w&&(w=_+1);!($=y[w])&&++w<d;);x._next=$||null}}return s=new C(s,r),s._enter=a,s._exit=l,s}function Yn(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Wn(){return new C(this._exit||this._groups.map(ve),this._parents)}function Kn(t,e,n){var r=this.enter(),i=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function Un(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var h=n[l],u=r[l],f=h.length,c=a[l]=new Array(f),p,d=0;d<f;++d)(p=h[d]||u[d])&&(c[d]=p);for(;l<i;++l)a[l]=n[l];return new C(a,this._parents)}function Gn(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,o=r[i],s;--i>=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function Qn(t){t||(t=Jn);function e(f,c){return f&&c?t(f.__data__,c.__data__):!f-!c}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s=n[o],a=s.length,l=i[o]=new Array(a),h,u=0;u<a;++u)(h=s[u])&&(l[u]=h);l.sort(e)}return new C(i,this._parents).order()}function Jn(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function jn(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function tr(){return Array.from(this)}function er(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}return null}function nr(){let t=0;for(const e of this)++t;return t}function rr(){return!this.node()}function ir(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,s=i.length,a;o<s;++o)(a=i[o])&&t.call(a,a.__data__,o,i);return this}function sr(t){return function(){this.removeAttribute(t)}}function or(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ar(t,e){return function(){this.setAttribute(t,e)}}function lr(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ur(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function hr(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function cr(t,e){var n=_t(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?or:sr:typeof e=="function"?n.local?hr:ur:n.local?lr:ar)(n,e))}function we(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function fr(t){return function(){this.style.removeProperty(t)}}function dr(t,e,n){return function(){this.style.setProperty(t,e,n)}}function pr(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function mr(t,e,n){return arguments.length>1?this.each((e==null?fr:typeof e=="function"?pr:dr)(t,e,n??"")):J(this.node(),t)}function J(t,e){return t.style.getPropertyValue(e)||we(t).getComputedStyle(t,null).getPropertyValue(e)}function gr(t){return function(){delete this[t]}}function yr(t,e){return function(){this[t]=e}}function _r(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function vr(t,e){return arguments.length>1?this.each((e==null?gr:typeof e=="function"?_r:yr)(t,e)):this.node()[t]}function xe(t){return t.trim().split(/^|\s+/)}function Bt(t){return t.classList||new be(t)}function be(t){this._node=t,this._names=xe(t.getAttribute("class")||"")}be.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $e(t,e){for(var n=Bt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function Ae(t,e){for(var n=Bt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function wr(t){return function(){$e(this,t)}}function xr(t){return function(){Ae(this,t)}}function br(t,e){return function(){(e.apply(this,arguments)?$e:Ae)(this,t)}}function $r(t,e){var n=xe(t+"");if(arguments.length<2){for(var r=Bt(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?br:e?wr:xr)(n,e))}function Ar(){this.textContent=""}function kr(t){return function(){this.textContent=t}}function Cr(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Tr(t){return arguments.length?this.each(t==null?Ar:(typeof t=="function"?Cr:kr)(t)):this.node().textContent}function Nr(){this.innerHTML=""}function Er(t){return function(){this.innerHTML=t}}function Mr(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Sr(t){return arguments.length?this.each(t==null?Nr:(typeof t=="function"?Mr:Er)(t)):this.node().innerHTML}function Rr(){this.nextSibling&&this.parentNode.appendChild(this)}function zr(){return this.each(Rr)}function Lr(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Or(){return this.each(Lr)}function Pr(t){var e=typeof t=="function"?t:me(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Ir(){return null}function Hr(t,e){var n=typeof t=="function"?t:me(t),r=e==null?Ir:typeof e=="function"?e:qt(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Dr(){var t=this.parentNode;t&&t.removeChild(this)}function Fr(){return this.each(Dr)}function qr(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Br(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Xr(t){return this.select(t?Br:qr)}function Zr(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Vr(t){return function(e){t.call(this,e,this.__data__)}}function Yr(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Wr(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,o;n<i;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function Kr(t,e,n){return function(){var r=this.__on,i,o=Vr(e);if(r){for(var s=0,a=r.length;s<a;++s)if((i=r[s]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=e;return}}this.addEventListener(t.type,o,n),i={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(i):this.__on=[i]}}function Ur(t,e,n){var r=Yr(t+""),i,o=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,h=a.length,u;l<h;++l)for(i=0,u=a[l];i<o;++i)if((s=r[i]).type===u.type&&s.name===u.name)return u.value}return}for(a=e?Kr:Wr,i=0;i<o;++i)this.each(a(r[i],e,n));return this}function ke(t,e,n){var r=we(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Gr(t,e){return function(){return ke(this,t,e)}}function Qr(t,e){return function(){return ke(this,t,e.apply(this,arguments))}}function Jr(t,e){return this.each((typeof e=="function"?Qr:Gr)(t,e))}function*jr(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length,s;i<o;++i)(s=r[i])&&(yield s)}var Ce=[null];function C(t,e){this._groups=t,this._parents=e}function j(){return new C([[document.documentElement]],Ce)}function ti(){return this}C.prototype=j.prototype={constructor:C,select:Cn,selectAll:Mn,selectChild:Ln,selectChildren:Hn,filter:Dn,data:Vn,enter:Fn,exit:Wn,join:Kn,merge:Un,selection:ti,order:Gn,sort:Qn,call:jn,nodes:tr,node:er,size:nr,empty:rr,each:ir,attr:cr,style:mr,property:vr,classed:$r,text:Tr,html:Sr,raise:zr,lower:Or,append:Pr,insert:Hr,remove:Fr,clone:Xr,datum:Zr,on:Ur,dispatch:Jr,[Symbol.iterator]:jr};function Te(t){return typeof t=="string"?new C([[document.querySelector(t)]],[document.documentElement]):new C([[t]],Ce)}function Xt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Ne(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function ut(){}var ht=.7,wt=1/ht,tt="\\s*([+-]?\\d+)\\s*",ct="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",S="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ei=/^#([0-9a-f]{3,8})$/,ni=new RegExp(`^rgb\\(${tt},${tt},${tt}\\)$`),ri=new RegExp(`^rgb\\(${S},${S},${S}\\)$`),ii=new RegExp(`^rgba\\(${tt},${tt},${tt},${ct}\\)$`),si=new RegExp(`^rgba\\(${S},${S},${S},${ct}\\)$`),oi=new RegExp(`^hsl\\(${ct},${S},${S}\\)$`),ai=new RegExp(`^hsla\\(${ct},${S},${S},${ct}\\)$`),Ee={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Xt(ut,et,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Me,formatHex:Me,formatHex8:li,formatHsl:ui,formatRgb:Se,toString:Se});function Me(){return this.rgb().formatHex()}function li(){return this.rgb().formatHex8()}function ui(){return Pe(this).formatHsl()}function Se(){return this.rgb().formatRgb()}function et(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ei.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Re(e):n===3?new k(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?xt(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?xt(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=ni.exec(t))?new k(e[1],e[2],e[3],1):(e=ri.exec(t))?new k(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ii.exec(t))?xt(e[1],e[2],e[3],e[4]):(e=si.exec(t))?xt(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=oi.exec(t))?Oe(e[1],e[2]/100,e[3]/100,1):(e=ai.exec(t))?Oe(e[1],e[2]/100,e[3]/100,e[4]):Ee.hasOwnProperty(t)?Re(Ee[t]):t==="transparent"?new k(NaN,NaN,NaN,0):null}function Re(t){return new k(t>>16&255,t>>8&255,t&255,1)}function xt(t,e,n,r){return r<=0&&(t=e=n=NaN),new k(t,e,n,r)}function hi(t){return t instanceof ut||(t=et(t)),t?(t=t.rgb(),new k(t.r,t.g,t.b,t.opacity)):new k}function bt(t,e,n,r){return arguments.length===1?hi(t):new k(t,e,n,r??1)}function k(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Xt(k,bt,Ne(ut,{brighter(t){return t=t==null?wt:Math.pow(wt,t),new k(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ht:Math.pow(ht,t),new k(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new k(V(this.r),V(this.g),V(this.b),$t(this.opacity))},displayable(){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:ze,formatHex:ze,formatHex8:ci,formatRgb:Le,toString:Le}));function ze(){return`#${Y(this.r)}${Y(this.g)}${Y(this.b)}`}function ci(){return`#${Y(this.r)}${Y(this.g)}${Y(this.b)}${Y((isNaN(this.opacity)?1:this.opacity)*255)}`}function Le(){const t=$t(this.opacity);return`${t===1?"rgb(":"rgba("}${V(this.r)}, ${V(this.g)}, ${V(this.b)}${t===1?")":`, ${t})`}`}function $t(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function V(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Y(t){return t=V(t),(t<16?"0":"")+t.toString(16)}function Oe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new E(t,e,n,r)}function Pe(t){if(t instanceof E)return new E(t.h,t.s,t.l,t.opacity);if(t instanceof ut||(t=et(t)),!t)return new E;if(t instanceof E)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=NaN,a=o-i,l=(o+i)/2;return a?(e===o?s=(n-r)/a+(n<r)*6:n===o?s=(r-e)/a+2:s=(e-n)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new E(s,a,l,t.opacity)}function fi(t,e,n,r){return arguments.length===1?Pe(t):new E(t,e,n,r??1)}function E(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Xt(E,fi,Ne(ut,{brighter(t){return t=t==null?wt:Math.pow(wt,t),new E(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ht:Math.pow(ht,t),new E(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new k(Zt(t>=240?t-240:t+120,i,r),Zt(t,i,r),Zt(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new E(Ie(this.h),At(this.s),At(this.l),$t(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=$t(this.opacity);return`${t===1?"hsl(":"hsla("}${Ie(this.h)}, ${At(this.s)*100}%, ${At(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Ie(t){return t=(t||0)%360,t<0?t+360:t}function At(t){return Math.max(0,Math.min(1,t||0))}function Zt(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}function He(t,e,n,r,i){var o=t*t,s=o*t;return((1-3*t+3*o-s)*e+(4-6*o+3*s)*n+(1+3*t+3*o-3*s)*r+s*i)/6}function di(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],o=t[r+1],s=r>0?t[r-1]:2*i-o,a=r<e-1?t[r+2]:2*o-i;return He((n-r/e)*e,s,i,o,a)}}function pi(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],o=t[r%e],s=t[(r+1)%e],a=t[(r+2)%e];return He((n-r/e)*e,i,o,s,a)}}var De=t=>()=>t;function mi(t,e){return function(n){return t+n*e}}function gi(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function yi(t){return(t=+t)==1?Fe:function(e,n){return n-e?gi(e,n,t):De(isNaN(e)?n:e)}}function Fe(t,e){var n=e-t;return n?mi(t,n):De(isNaN(t)?e:t)}var qe=(function t(e){var n=yi(e);function r(i,o){var s=n((i=bt(i)).r,(o=bt(o)).r),a=n(i.g,o.g),l=n(i.b,o.b),h=Fe(i.opacity,o.opacity);return function(u){return i.r=s(u),i.g=a(u),i.b=l(u),i.opacity=h(u),i+""}}return r.gamma=t,r})(1);function Be(t){return function(e){var n=e.length,r=new Array(n),i=new Array(n),o=new Array(n),s,a;for(s=0;s<n;++s)a=bt(e[s]),r[s]=a.r||0,i[s]=a.g||0,o[s]=a.b||0;return r=t(r),i=t(i),o=t(o),a.opacity=1,function(l){return a.r=r(l),a.g=i(l),a.b=o(l),a+""}}}var Lo=Be(di),Oo=Be(pi);function F(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var Vt=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yt=new RegExp(Vt.source,"g");function _i(t){return function(){return t}}function vi(t){return function(e){return t(e)+""}}function wi(t,e){var n=Vt.lastIndex=Yt.lastIndex=0,r,i,o,s=-1,a=[],l=[];for(t=t+"",e=e+"";(r=Vt.exec(t))&&(i=Yt.exec(e));)(o=i.index)>n&&(o=e.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,l.push({i:s,x:F(r,i)})),n=Yt.lastIndex;return n<e.length&&(o=e.slice(n),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?vi(l[0].x):_i(e):(e=l.length,function(h){for(var u=0,f;u<e;++u)a[(f=l[u]).i]=f.x(h);return a.join("")})}var Xe=180/Math.PI,Wt={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ze(t,e,n,r,i,o){var s,a,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*Xe,skewX:Math.atan(l)*Xe,scaleX:s,scaleY:a}}var kt;function xi(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Wt:Ze(e.a,e.b,e.c,e.d,e.e,e.f)}function bi(t){return t==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",t),!(t=kt.transform.baseVal.consolidate()))?Wt:(t=t.matrix,Ze(t.a,t.b,t.c,t.d,t.e,t.f))}function Ve(t,e,n,r){function i(h){return h.length?h.pop()+" ":""}function o(h,u,f,c,p,d){if(h!==f||u!==c){var m=p.push("translate(",null,e,null,n);d.push({i:m-4,x:F(h,f)},{i:m-2,x:F(u,c)})}else(f||c)&&p.push("translate("+f+e+c+n)}function s(h,u,f,c){h!==u?(h-u>180?u+=360:u-h>180&&(h+=360),c.push({i:f.push(i(f)+"rotate(",null,r)-2,x:F(h,u)})):u&&f.push(i(f)+"rotate("+u+r)}function a(h,u,f,c){h!==u?c.push({i:f.push(i(f)+"skewX(",null,r)-2,x:F(h,u)}):u&&f.push(i(f)+"skewX("+u+r)}function l(h,u,f,c,p,d){if(h!==f||u!==c){var m=p.push(i(p)+"scale(",null,",",null,")");d.push({i:m-4,x:F(h,f)},{i:m-2,x:F(u,c)})}else(f!==1||c!==1)&&p.push(i(p)+"scale("+f+","+c+")")}return function(h,u){var f=[],c=[];return h=t(h),u=t(u),o(h.translateX,h.translateY,u.translateX,u.translateY,f,c),s(h.rotate,u.rotate,f,c),a(h.skewX,u.skewX,f,c),l(h.scaleX,h.scaleY,u.scaleX,u.scaleY,f,c),h=u=null,function(p){for(var d=-1,m=c.length,y;++d<m;)f[(y=c[d]).i]=y.x(p);return f.join("")}}}var $i=Ve(xi,"px, ","px)","deg)"),Ai=Ve(bi,", ",")",")"),nt=0,ft=0,dt=0,Ye=1e3,Ct,pt,Tt=0,W=0,Nt=0,mt=typeof performance=="object"&&performance.now?performance:Date,We=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Kt(){return W||(We(ki),W=mt.now()+Nt)}function ki(){W=0}function Et(){this._call=this._time=this._next=null}Et.prototype=Ke.prototype={constructor:Et,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Kt():+n)+(e==null?0:+e),!this._next&&pt!==this&&(pt?pt._next=this:Ct=this,pt=this),this._call=t,this._time=n,Ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ut())}};function Ke(t,e,n){var r=new Et;return r.restart(t,e,n),r}function Ci(){Kt(),++nt;for(var t=Ct,e;t;)(e=W-t._time)>=0&&t._call.call(void 0,e),t=t._next;--nt}function Ue(){W=(Tt=mt.now())+Nt,nt=ft=0;try{Ci()}finally{nt=0,Ni(),W=0}}function Ti(){var t=mt.now(),e=t-Tt;e>Ye&&(Nt-=e,Tt=t)}function Ni(){for(var t,e=Ct,n,r=1/0;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:Ct=n);pt=t,Ut(r)}function Ut(t){nt||(ft&&(ft=clearTimeout(ft)),t-W>24?(t<1/0&&(ft=setTimeout(Ue,t-mt.now()-Nt)),dt&&(dt=clearInterval(dt))):(dt||(Tt=mt.now(),dt=setInterval(Ti,Ye)),nt=1,We(Ue)))}function Ge(t,e,n){var r=new Et;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var Ei=fe("start","end","cancel","interrupt"),Mi=[],Po=0,Io=1,Ho=2,Do=3,Fo=4,qo=5,Bo=6;function Mt(t,e,n,r,i,o){var s=t.__transition;if(!s)t.__transition={};else if(n in s)return;Si(t,n,{name:e,index:r,group:i,on:Ei,tween:Mi,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function Gt(t,e){var n=M(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function R(t,e){var n=M(t,e);if(n.state>3)throw new Error("too late; already running");return n}function M(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Si(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=Ke(o,0,n.time);function o(h){n.state=1,n.timer.restart(s,n.delay,n.time),n.delay<=h&&s(h-n.delay)}function s(h){var u,f,c,p;if(n.state!==1)return l();for(u in r)if(p=r[u],p.name===n.name){if(p.state===3)return Ge(s);p.state===4?(p.state=6,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=6,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(Ge(function(){n.state===3&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(h))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),n.state===2){for(n.state=3,i=new Array(c=n.tween.length),u=0,f=-1;u<c;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(i[++f]=p);i.length=f+1}}function a(h){for(var u=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(l),n.state=5,1),f=-1,c=i.length;++f<c;)i[f].call(t,u);n.state===5&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=6,n.timer.stop(),delete r[e];for(var h in r)return;delete t.__transition}}function Ri(t,e){var n=t.__transition,r,i,o=!0,s;if(n){e=e==null?null:e+"";for(s in n){if((r=n[s]).name!==e){o=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[s]}o&&delete t.__transition}}function zi(t){return this.each(function(){Ri(this,t)})}function Li(t,e){var n,r;return function(){var i=R(this,t),o=i.tween;if(o!==n){r=n=o;for(var s=0,a=r.length;s<a;++s)if(r[s].name===e){r=r.slice(),r.splice(s,1);break}}i.tween=r}}function Oi(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=R(this,t),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:e,value:n},l=0,h=i.length;l<h;++l)if(i[l].name===e){i[l]=a;break}l===h&&i.push(a)}o.tween=i}}function Pi(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=M(this.node(),n).tween,i=0,o=r.length,s;i<o;++i)if((s=r[i]).name===t)return s.value;return null}return this.each((e==null?Li:Oi)(n,t,e))}function Qt(t,e,n){var r=t._id;return t.each(function(){var i=R(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return M(i,r).value[e]}}function Qe(t,e){var n;return(typeof e=="number"?F:e instanceof et?qe:(n=et(e))?(e=n,qe):wi)(t,e)}function Ii(t){return function(){this.removeAttribute(t)}}function Hi(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Di(t,e,n){var r,i=n+"",o;return function(){var s=this.getAttribute(t);return s===i?null:s===r?o:o=e(r=s,n)}}function Fi(t,e,n){var r,i=n+"",o;return function(){var s=this.getAttributeNS(t.space,t.local);return s===i?null:s===r?o:o=e(r=s,n)}}function qi(t,e,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(t):(s=this.getAttribute(t),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=e(r=s,a)))}}function Bi(t,e,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(t.space,t.local):(s=this.getAttributeNS(t.space,t.local),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=e(r=s,a)))}}function Xi(t,e){var n=_t(t),r=n==="transform"?Ai:Qe;return this.attrTween(t,typeof e=="function"?(n.local?Bi:qi)(n,r,Qt(this,"attr."+t,e)):e==null?(n.local?Hi:Ii)(n):(n.local?Fi:Di)(n,r,e))}function Zi(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Vi(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Yi(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Vi(t,o)),n}return i._value=e,i}function Wi(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&Zi(t,o)),n}return i._value=e,i}function Ki(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=_t(t);return this.tween(n,(r.local?Yi:Wi)(r,e))}function Ui(t,e){return function(){Gt(this,t).delay=+e.apply(this,arguments)}}function Gi(t,e){return e=+e,function(){Gt(this,t).delay=e}}function Qi(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Ui:Gi)(e,t)):M(this.node(),e).delay}function Ji(t,e){return function(){R(this,t).duration=+e.apply(this,arguments)}}function ji(t,e){return e=+e,function(){R(this,t).duration=e}}function ts(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Ji:ji)(e,t)):M(this.node(),e).duration}function es(t,e){if(typeof e!="function")throw new Error;return function(){R(this,t).ease=e}}function ns(t){var e=this._id;return arguments.length?this.each(es(e,t)):M(this.node(),e).ease}function rs(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;R(this,t).ease=n}}function is(t){if(typeof t!="function")throw new Error;return this.each(rs(this._id,t))}function ss(t){typeof t!="function"&&(t=ye(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o=e[i],s=o.length,a=r[i]=[],l,h=0;h<s;++h)(l=o[h])&&t.call(l,l.__data__,h,o)&&a.push(l);return new I(r,this._parents,this._name,this._id)}function os(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var l=e[a],h=n[a],u=l.length,f=s[a]=new Array(u),c,p=0;p<u;++p)(c=l[p]||h[p])&&(f[p]=c);for(;a<r;++a)s[a]=e[a];return new I(s,this._parents,this._name,this._id)}function as(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function ls(t,e,n){var r,i,o=as(e)?Gt:R;return function(){var s=o(this,t),a=s.on;a!==r&&(i=(r=a).copy()).on(e,n),s.on=i}}function us(t,e){var n=this._id;return arguments.length<2?M(this.node(),n).on.on(t):this.each(ls(n,t,e))}function hs(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function cs(){return this.on("end.remove",hs(this._id))}function fs(t){var e=this._name,n=this._id;typeof t!="function"&&(t=qt(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a=r[s],l=a.length,h=o[s]=new Array(l),u,f,c=0;c<l;++c)(u=a[c])&&(f=t.call(u,u.__data__,c,a))&&("__data__"in u&&(f.__data__=u.__data__),h[c]=f,Mt(h[c],e,n,c,h,M(u,n)));return new I(o,this._parents,e,n)}function ds(t){var e=this._name,n=this._id;typeof t!="function"&&(t=ge(t));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var l=r[a],h=l.length,u,f=0;f<h;++f)if(u=l[f]){for(var c=t.call(u,u.__data__,f,l),p,d=M(u,n),m=0,y=c.length;m<y;++m)(p=c[m])&&Mt(p,e,n,m,c,d);o.push(c),s.push(u)}return new I(o,s,e,n)}var ps=j.prototype.constructor;function ms(){return new ps(this._groups,this._parents)}function gs(t,e){var n,r,i;return function(){var o=J(this,t),s=(this.style.removeProperty(t),J(this,t));return o===s?null:o===n&&s===r?i:i=e(n=o,r=s)}}function Je(t){return function(){this.style.removeProperty(t)}}function ys(t,e,n){var r,i=n+"",o;return function(){var s=J(this,t);return s===i?null:s===r?o:o=e(r=s,n)}}function _s(t,e,n){var r,i,o;return function(){var s=J(this,t),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(t),J(this,t))),s===l?null:s===r&&l===i?o:(i=l,o=e(r=s,a))}}function vs(t,e){var n,r,i,o="style."+e,s="end."+o,a;return function(){var l=R(this,t),h=l.on,u=l.value[o]==null?a||(a=Je(e)):void 0;(h!==n||i!==u)&&(r=(n=h).copy()).on(s,i=u),l.on=r}}function ws(t,e,n){var r=(t+="")=="transform"?$i:Qe;return e==null?this.styleTween(t,gs(t,r)).on("end.style."+t,Je(t)):typeof e=="function"?this.styleTween(t,_s(t,r,Qt(this,"style."+t,e))).each(vs(this._id,t)):this.styleTween(t,ys(t,r,e),n).on("end.style."+t,null)}function xs(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function bs(t,e,n){var r,i;function o(){var s=e.apply(this,arguments);return s!==i&&(r=(i=s)&&xs(t,s,n)),r}return o._value=e,o}function $s(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,bs(t,e,n??""))}function As(t){return function(){this.textContent=t}}function ks(t){return function(){var e=t(this);this.textContent=e??""}}function Cs(t){return this.tween("text",typeof t=="function"?ks(Qt(this,"text",t)):As(t==null?"":t+""))}function Ts(t){return function(e){this.textContent=t.call(this,e)}}function Ns(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&Ts(i)),e}return r._value=t,r}function Es(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Ns(t))}function Ms(){for(var t=this._name,e=this._id,n=je(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,h=0;h<a;++h)if(l=s[h]){var u=M(l,e);Mt(l,t,n,h,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new I(r,this._parents,t,n)}function Ss(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--i===0&&o()}};n.each(function(){var h=R(this,r),u=h.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),h.on=e}),i===0&&o()})}var Rs=0;function I(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function zs(t){return j().transition(t)}function je(){return++Rs}var H=j.prototype;I.prototype=zs.prototype={constructor:I,select:fs,selectAll:ds,selectChild:H.selectChild,selectChildren:H.selectChildren,filter:ss,merge:os,selection:ms,transition:Ms,call:H.call,nodes:H.nodes,node:H.node,size:H.size,empty:H.empty,each:H.each,on:us,attr:Xi,attrTween:Ki,style:ws,styleTween:$s,text:Cs,textTween:Es,remove:cs,tween:Pi,delay:Qi,duration:ts,ease:ns,easeVarying:is,end:Ss,[Symbol.iterator]:H[Symbol.iterator]};function Ls(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Os={time:null,delay:0,duration:250,ease:Ls};function Ps(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function Is(t){var e,n;t instanceof I?(e=t._id,t=t._name):(e=je(),(n=Os).time=Kt(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,h=0;h<a;++h)(l=s[h])&&Mt(l,t,e,h,s,n||Ps(l,e));return new I(r,this._parents,t,e)}j.prototype.interrupt=zi,j.prototype.transition=Is;var{abs:Xo,max:Zo,min:Vo}=Math;function tn(t){return[+t[0],+t[1]]}function Hs(t){return[tn(t[0]),tn(t[1])]}var Yo={name:"x",handles:["w","e"].map(Jt),input:function(t,e){return t==null?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},Wo={name:"y",handles:["n","s"].map(Jt),input:function(t,e){return t==null?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},Ko={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(Jt),input:function(t){return t==null?null:Hs(t)},output:function(t){return t}};function Jt(t){return{type:t}}var jt=Math.PI,te=2*jt,K=1e-6,Ds=te-K;function en(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Fs(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return en;const n=10**e;return function(r){this._+=r[0];for(let i=1,o=r.length;i<o;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}var ee=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?en:Fs(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,o){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+o}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,i=+i,i<0)throw new Error(`negative radius: ${i}`);let o=this._x1,s=this._y1,a=n-t,l=r-e,h=o-t,u=s-e,f=h*h+u*u;if(this._x1===null)this._append`M${this._x1=t},${this._y1=e}`;else if(f>K)if(!(Math.abs(u*a-l*h)>K)||!i)this._append`L${this._x1=t},${this._y1=e}`;else{let c=n-o,p=r-s,d=a*a+l*l,m=c*c+p*p,y=Math.sqrt(d),_=Math.sqrt(f),w=i*Math.tan((jt-Math.acos((d+f-m)/(2*y*_)))/2),x=w/_,$=w/y;Math.abs(x-1)>K&&this._append`L${t+x*h},${e+x*u}`,this._append`A${i},${i},0,0,${+(u*c>h*p)},${this._x1=t+$*a},${this._y1=e+$*l}`}}arc(t,e,n,r,i,o){if(t=+t,e=+e,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(r),a=n*Math.sin(r),l=t+s,h=e+a,u=1^o,f=o?r-i:i-r;this._x1===null?this._append`M${l},${h}`:(Math.abs(this._x1-l)>K||Math.abs(this._y1-h)>K)&&this._append`L${l},${h}`,n&&(f<0&&(f=f%te+te),f>Ds?this._append`A${n},${n},0,1,${u},${t-s},${e-a}A${n},${n},0,1,${u},${this._x1=l},${this._y1=h}`:f>K&&this._append`A${n},${n},0,${+(f>=jt)},${u},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function qs(){return new ee}qs.prototype=ee.prototype;function Bs(t){var e=0,n=t.children,r=n&&n.length;if(!r)e=1;else for(;--r>=0;)e+=n[r].value;t.value=e}function Xs(){return this.eachAfter(Bs)}function Zs(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this}function Vs(t,e){for(var n=this,r=[n],i,o,s=-1;n=r.pop();)if(t.call(e,n,++s,this),i=n.children)for(o=i.length-1;o>=0;--o)r.push(i[o]);return this}function Ys(t,e){for(var n=this,r=[n],i=[],o,s,a,l=-1;n=r.pop();)if(i.push(n),o=n.children)for(s=0,a=o.length;s<a;++s)r.push(o[s]);for(;n=i.pop();)t.call(e,n,++l,this);return this}function Ws(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r}function Ks(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})}function Us(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function Gs(t){for(var e=this,n=Qs(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r}function Qs(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}function Js(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function js(){return Array.from(this)}function to(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function eo(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function*no(){var t=this,e,n=[t],r,i,o;do for(e=n.reverse(),n=[];t=e.pop();)if(yield t,r=t.children)for(i=0,o=r.length;i<o;++i)n.push(r[i]);while(n.length)}function ne(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=so)):e===void 0&&(e=io);for(var n=new St(t),r,i=[n],o,s,a,l;r=i.pop();)if((s=e(r.data))&&(l=(s=Array.from(s)).length))for(r.children=s,a=l-1;a>=0;--a)i.push(o=s[a]=new St(s[a])),o.parent=r,o.depth=r.depth+1;return n.eachBefore(ao)}function ro(){return ne(this).eachBefore(oo)}function io(t){return t.children}function so(t){return Array.isArray(t)?t[1]:null}function oo(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function ao(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function St(t){this.data=t,this.depth=this.height=0,this.parent=null}St.prototype=ne.prototype={constructor:St,count:Xs,each:Zs,eachAfter:Ys,eachBefore:Vs,find:Ws,sum:Ks,sort:Us,path:Gs,ancestors:Js,descendants:js,leaves:to,links:eo,copy:ro,[Symbol.iterator]:no};function lo(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function uo(t,e,n,r,i){for(var o=t.children,s,a=-1,l=o.length,h=t.value&&(r-e)/t.value;++a<l;)s=o[a],s.y0=n,s.y1=i,s.x0=e,s.x1=e+=s.value*h}function nn(){var t=1,e=1,n=0,r=!1;function i(s){var a=s.height+1;return s.x0=s.y0=n,s.x1=t,s.y1=e/a,s.eachBefore(o(e,a)),r&&s.eachBefore(lo),s}function o(s,a){return function(l){l.children&&uo(l,l.x0,s*(l.depth+1)/a,l.x1,s*(l.depth+2)/a);var h=l.x0,u=l.y0,f=l.x1-n,c=l.y1-n;f<h&&(h=f=(h+f)/2),c<u&&(u=c=(u+c)/2),l.x0=h,l.y0=u,l.x1=f,l.y1=c}}return i.round=function(s){return arguments.length?(r=!!s,i):r},i.size=function(s){return arguments.length?(t=+s[0],e=+s[1],i):[t,e]},i.padding=function(s){return arguments.length?(n=+s,i):n},i}function q(t){return function(){return t}}var rn=Math.abs,A=Math.atan2,U=Math.cos,ho=Math.max,re=Math.min,z=Math.sin,rt=Math.sqrt,Uo=1e-12,gt=Math.PI,Rt=gt/2,co=2*gt;function fo(t){return t>1?0:t<-1?gt:Math.acos(t)}function sn(t){return t>=1?Rt:t<=-1?-Rt:Math.asin(t)}function po(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new ee(e)}function mo(t){return t.innerRadius}function go(t){return t.outerRadius}function yo(t){return t.startAngle}function _o(t){return t.endAngle}function vo(t){return t&&t.padAngle}function wo(t,e,n,r,i,o,s,a){var l=n-t,h=r-e,u=s-i,f=a-o,c=f*l-u*h;if(!(c*c<1e-12))return c=(u*(e-o)-f*(t-i))/c,[t+c*l,e+c*h]}function zt(t,e,n,r,i,o,s){var a=t-n,l=e-r,h=(s?o:-o)/rt(a*a+l*l),u=h*l,f=-h*a,c=t+u,p=e+f,d=n+u,m=r+f,y=(c+d)/2,_=(p+m)/2,w=d-c,x=m-p,$=w*w+x*x,L=i-o,O=c*m-d*p,B=(x<0?-1:1)*rt(ho(0,L*L*$-O*O)),X=(O*x-w*B)/$,Z=(-O*w-x*B)/$,P=(O*x+w*B)/$,T=(-O*w+x*B)/$,N=X-y,g=Z-_,v=P-y,G=T-_;return N*N+g*g>v*v+G*G&&(X=P,Z=T),{cx:X,cy:Z,x01:-u,y01:-f,x11:X*(i/L-1),y11:Z*(i/L-1)}}function xo(){var t=mo,e=go,n=q(0),r=null,i=yo,o=_o,s=vo,a=null,l=po(h);function h(){var u,f,c=+t.apply(this,arguments),p=+e.apply(this,arguments),d=i.apply(this,arguments)-Rt,m=o.apply(this,arguments)-Rt,y=rn(m-d),_=m>d;if(a||(a=u=l()),p<c&&(f=p,p=c,c=f),!(p>1e-12))a.moveTo(0,0);else if(y>co-1e-12)a.moveTo(p*U(d),p*z(d)),a.arc(0,0,p,d,m,!_),c>1e-12&&(a.moveTo(c*U(m),c*z(m)),a.arc(0,0,c,m,d,_));else{var w=d,x=m,$=d,L=m,O=y,B=y,X=s.apply(this,arguments)/2,Z=X>1e-12&&(r?+r.apply(this,arguments):rt(c*c+p*p)),P=re(rn(p-c)/2,+n.apply(this,arguments)),T=P,N=P,g,v;if(Z>1e-12){var G=sn(Z/c*z(X)),Lt=sn(Z/p*z(X));(O-=G*2)>1e-12?(G*=_?1:-1,$+=G,L-=G):(O=0,$=L=(d+m)/2),(B-=Lt*2)>1e-12?(Lt*=_?1:-1,w+=Lt,x-=Lt):(B=0,w=x=(d+m)/2)}var st=p*U(w),ot=p*z(w),Ot=c*U(L),Pt=c*z(L);if(P>1e-12){var It=p*U(x),Ht=p*z(x),ie=c*U($),se=c*z($),D;if(y<gt)if(D=wo(st,ot,ie,se,It,Ht,Ot,Pt)){var oe=st-D[0],ae=ot-D[1],le=It-D[0],ue=Ht-D[1],an=1/z(fo((oe*le+ae*ue)/(rt(oe*oe+ae*ae)*rt(le*le+ue*ue)))/2),ln=rt(D[0]*D[0]+D[1]*D[1]);T=re(P,(c-ln)/(an-1)),N=re(P,(p-ln)/(an+1))}else T=N=0}B>1e-12?N>1e-12?(g=zt(ie,se,st,ot,p,N,_),v=zt(It,Ht,Ot,Pt,p,N,_),a.moveTo(g.cx+g.x01,g.cy+g.y01),N<P?a.arc(g.cx,g.cy,N,A(g.y01,g.x01),A(v.y01,v.x01),!_):(a.arc(g.cx,g.cy,N,A(g.y01,g.x01),A(g.y11,g.x11),!_),a.arc(0,0,p,A(g.cy+g.y11,g.cx+g.x11),A(v.cy+v.y11,v.cx+v.x11),!_),a.arc(v.cx,v.cy,N,A(v.y11,v.x11),A(v.y01,v.x01),!_))):(a.moveTo(st,ot),a.arc(0,0,p,w,x,!_)):a.moveTo(st,ot),!(c>1e-12)||!(O>1e-12)?a.lineTo(Ot,Pt):T>1e-12?(g=zt(Ot,Pt,It,Ht,c,-T,_),v=zt(st,ot,ie,se,c,-T,_),a.lineTo(g.cx+g.x01,g.cy+g.y01),T<P?a.arc(g.cx,g.cy,T,A(g.y01,g.x01),A(v.y01,v.x01),!_):(a.arc(g.cx,g.cy,T,A(g.y01,g.x01),A(g.y11,g.x11),!_),a.arc(0,0,c,A(g.cy+g.y11,g.cx+g.x11),A(v.cy+v.y11,v.cx+v.x11),_),a.arc(v.cx,v.cy,T,A(v.y11,v.x11),A(v.y01,v.x01),!_))):a.arc(0,0,c,L,$,_)}if(a.closePath(),u)return a=null,u+""||null}return h.centroid=function(){var u=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,f=(+i.apply(this,arguments)+ +o.apply(this,arguments))/2-gt/2;return[U(f)*u,z(f)*u]},h.innerRadius=function(u){return arguments.length?(t=typeof u=="function"?u:q(+u),h):t},h.outerRadius=function(u){return arguments.length?(e=typeof u=="function"?u:q(+u),h):e},h.cornerRadius=function(u){return arguments.length?(n=typeof u=="function"?u:q(+u),h):n},h.padRadius=function(u){return arguments.length?(r=u==null?null:typeof u=="function"?u:q(+u),h):r},h.startAngle=function(u){return arguments.length?(i=typeof u=="function"?u:q(+u),h):i},h.endAngle=function(u){return arguments.length?(o=typeof u=="function"?u:q(+u),h):o},h.padAngle=function(u){return arguments.length?(s=typeof u=="function"?u:q(+u),h):s},h.context=function(u){return arguments.length?(a=u??null,h):a},h}function it(t,e,n){this.k=t,this.x=e,this.y=n}it.prototype={constructor:it,scale:function(t){return t===1?this:new it(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new it(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var bo=new it(1,0,0);$o.prototype=it.prototype;function $o(t){for(;!t.__zoom;)if(!(t=t.parentNode))return bo;return t.__zoom}var Ao=class{container;chartRoot;width=0;height=0;radius=0;svg;g;partition=nn();arc;legend=null;currentRoot=null;highlightId=null;resizeObserver=null;options;tooltipId;touchZoomPathKey=null;touchOutsideHandler=null;constructor(t,e){this.container=t,this.options=e,this.tooltipId=`pam-tooltip-${Math.random().toString(36).slice(2,9)}`,this.chartRoot=document.createElement("div"),this.chartRoot.className="pam-chart__canvas",t.appendChild(this.chartRoot),lt(t),this.svg=Te(this.chartRoot).append("svg").attr("width","100%").attr("height","100%").attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label",e.ariaLabel),this.g=this.svg.append("g"),(e.legend??!0)&&(this.legend=this.createLegend(e.labels??Ft),this.chartRoot.appendChild(this.legend)),this.partition=nn().size([2*Math.PI,this.radius]),this.arc=xo().startAngle(n=>n.x0).endAngle(n=>n.x1).padAngle(b.spacing.padAngle.inner).innerRadius(n=>n.y0).outerRadius(n=>n.y1),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(t),this.resize()}destroy(){this.unbindTouchOutsideDismiss(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.chartRoot.remove()}resize(){const t=this.chartRoot.getBoundingClientRect();this.width=t.width,this.height=t.height;const e=this.legend?.getBoundingClientRect().height??0,n=this.legend?Math.max(56,e+28):0,r=Math.max(0,this.height-n);this.radius=Math.min(this.width,r)/2-b.chart.radiusPadding,!(this.radius<b.chart.minRadius)&&(this.partition.size([2*Math.PI,this.radius]),this.svg.attr("viewBox",`0 0 ${this.width} ${this.height}`),this.g.attr("transform",`translate(${this.width/2}, ${r/2})`),this.currentRoot&&this.render(this.currentRoot))}setHighlight(t){this.highlightId=t,this.g.selectAll("path").classed("pam-arc--highlighted",e=>t===e.data.id).classed("pam-arc--dimmed",e=>t!=null&&t!==e.data.id)}render(t){this.touchZoomPathKey=null,this.unbindTouchOutsideDismiss(),this.currentRoot=t,lt(this.container);const e=b.colors,n=ne(t);let r=0;n.each(d=>{r=Math.max(r,d.depth)});const i=Math.max(r,1);this.partition(n);const o=n,s=(d,m,y)=>{if(d.x0=m,d.x1=y,d.children?.length){const _=(y-m)/d.children.length;d.children.forEach((w,x)=>{s(w,m+x*_,m+(x+1)*_)})}};s(o,0,2*Math.PI);const a=d=>{const m=d/this.radius,y=b.spacing.radiusExponent.base+(i-b.spacing.exponentDepthThreshold)*b.spacing.radiusExponent.perLevel;return Math.pow(m,y)*this.radius},l=this.radius*b.spacing.verticalGap,h=d=>{const m=d.depth/i;return b.spacing.padAngle.inner-m*(b.spacing.padAngle.inner-b.spacing.padAngle.outer)};this.arc.innerRadius(d=>a(d.y0)+l).outerRadius(d=>d.depth===0?Math.min(a(d.y1)-l,this.radius*b.chart.maxCenterRadius):a(d.y1)-l).padAngle(h).cornerRadius(b.chart.cornerRadius),this.g.selectAll("*").remove();const u=this.g.selectAll("path").data(o.descendants()).enter().append("path").attr("d",this.arc).attr("data-node-id",d=>d.data.id).attr("data-path-key",d=>d.data.pathKey).attr("class",d=>pn(d.data,t)).attr("tabindex","0").attr("role","button").attr("aria-label",d=>d.data.title).attr("aria-describedby",this.tooltipId).style("stroke",e.border).style("stroke-width",b.chart.strokeWidth).style("stroke-linejoin","round").style("cursor",this.options.zoomEnabled?"pointer":"default").classed("pam-arc--highlighted",d=>this.highlightId===d.data.id).classed("pam-arc--dimmed",d=>this.highlightId!=null&&this.highlightId!==d.data.id),f=(d,m)=>{u.classed("pam-arc--dimmed",y=>y.data.id!==m.data.id),u.classed("pam-arc--highlighted",y=>y.data.id===m.data.id);try{const y=mn(m.data,t,e),_=et(y);_&&(_.opacity=.28),Te(d.currentTarget).style("filter",`brightness(${m.depth===0?1.02:1.06}) drop-shadow(0 2px 5px ${_?.formatRgb()??y})`)}catch{}this.options.onHover?.(m.data,d)},c=()=>{u.classed("pam-arc--dimmed",!1).classed("pam-arc--highlighted",!1).style("filter","none"),this.highlightId&&this.setHighlight(this.highlightId),this.options.onLeave?.()},p=(d,m)=>{if(d.stopPropagation(),d.pointerType==="touch"){this.touchZoomPathKey===m.data.pathKey?(this.touchZoomPathKey=null,this.unbindTouchOutsideDismiss(),this.options.zoomEnabled&&this.options.onClick?.(m.data,m.depth,(m.data.children?.length??0)>0)):(this.touchZoomPathKey=m.data.pathKey,f(d,m),this.bindTouchOutsideDismiss(c));return}this.options.zoomEnabled&&this.options.onClick?.(m.data,m.depth,(m.data.children?.length??0)>0)};u.on("pointerenter",(d,m)=>{d.pointerType!=="touch"&&f(d,m)}).on("pointermove",(d,m)=>{d.pointerType!=="touch"&&f(d,m)}).on("pointerleave",d=>{d.pointerType!=="touch"&&c()}).on("focus",(d,m)=>f(d,m)).on("blur",()=>c()).on("click",(d,m)=>p(d,m)).on("keydown",(d,m)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),this.options.zoomEnabled&&this.options.onClick?.(m.data,m.depth,(m.data.children?.length??0)>0))})}getTooltipElementId(){return this.tooltipId}createLegend(t){const e=document.createElement("div");e.className="pam-chart__legend",e.setAttribute("role","list"),e.setAttribute("aria-label",t.legend??"Argument types");const n=[{type:"center",label:t.center},{type:"support",label:t.support},{type:"attack",label:t.attack}];for(const r of n){const i=document.createElement("span");i.className="pam-chart__legend-item",i.setAttribute("role","listitem");const o=document.createElement("span");o.className=`pam-chart__legend-swatch pam-chart__legend-swatch--${r.type}`,o.setAttribute("aria-hidden","true");const s=document.createElement("span");s.textContent=r.label,i.append(o,s),e.appendChild(i)}return e}bindTouchOutsideDismiss(t){this.unbindTouchOutsideDismiss(),this.touchOutsideHandler=e=>{const n=e.target;n&&this.container.contains(n)||(this.touchZoomPathKey=null,t(),this.unbindTouchOutsideDismiss())},window.setTimeout(()=>{this.touchOutsideHandler&&document.addEventListener("pointerdown",this.touchOutsideHandler,!0)},0)}unbindTouchOutsideDismiss(){this.touchOutsideHandler&&(document.removeEventListener("pointerdown",this.touchOutsideHandler,!0),this.touchOutsideHandler=null)}},Go=56;function ko(t,e,n){const r=e.getBoundingClientRect(),i=r.width||320,o=r.height||200,s=12;if(n==="touch"){let h=t.x-i/2,u=t.y-o-56;return h=Math.max(s,Math.min(h,window.innerWidth-i-s)),u=Math.max(s,Math.min(u,window.innerHeight-o-s)),{x:h,y:u}}let a=t.x+20,l=t.y+20;return a+i>window.innerWidth&&(a=t.x-i-20),l+o>window.innerHeight&&(l=t.y-o-20),{x:a,y:l}}function Co(t,e){return t.type==="thesis"?{text:e.center,className:"center"}:t.relationType==="attack"?{text:e.attack,className:"attack"}:t.relationType==="support"?{text:e.support,className:"support"}:{text:e.claim,className:"claim"}}function To(t,e=Ft){const n=document.createElement("div");n.className="pam-tooltip";const r=document.createElement("div");r.className="pam-tooltip__header";const i=Co(t,e),o=document.createElement("span");o.className=`pam-tooltip__type pam-tooltip__type--${i.className}`,o.textContent=i.text;const s=document.createElement("span");s.className="pam-tooltip__speaker",s.textContent=t.speaker||e.unknownSpeaker,r.append(o,s);const a=document.createElement("h3");if(a.className="pam-tooltip__title",a.textContent=t.title,n.append(r,a),t.description){const l=document.createElement("p");l.className="pam-tooltip__description",l.textContent=t.description,n.append(l)}if(t.relationType&&t.relationReasoning){const l=document.createElement("p");l.className="pam-tooltip__reasoning",l.textContent=t.relationReasoning,n.append(l)}if(t.quote){const l=document.createElement("blockquote");l.className="pam-tooltip__quote",l.textContent=`"${t.quote}"`,n.append(l)}if(t.score){const l=document.createElement("div");l.className="pam-tooltip__scores";const h=document.createElement("span");h.textContent=`${e.intensity}: ${Math.round(t.score.intensity*100)}%`;const u=document.createElement("span");u.textContent=`${e.confidence}: ${Math.round(t.score.confidence*100)}%`,l.append(h,u),n.append(l)}return n}function No(t){if("clientX"in t&&typeof t.clientX=="number"){const e="pointerType"in t?t.pointerType:void 0;return{x:t.clientX,y:t.clientY,pointerType:e}}return{x:0,y:0}}var Eo=class{element;rafId=null;position={x:0,y:0};pointerType;renderer;labels;visible=!1;constructor(t,e,n,r){this.renderer=n,this.labels=r,this.element=document.createElement("div"),this.element.id=e,this.element.className="pam-tooltip-host",this.element.setAttribute("role","region"),this.element.setAttribute("aria-live","polite"),t.appendChild(this.element)}show(t,e){const n=No(e);this.position={x:n.x,y:n.y},this.pointerType=n.pointerType,this.element.replaceChildren(this.renderer(t,this.labels)),this.element.classList.toggle("pam-tooltip-host--touch",n.pointerType==="touch"),this.element.classList.add("pam-tooltip-host--visible"),this.visible=!0,this.schedulePosition()}move(t){this.visible&&(this.position={x:t.clientX,y:t.clientY},this.pointerType=t.pointerType,this.element.classList.toggle("pam-tooltip-host--touch",t.pointerType==="touch"),this.schedulePosition())}hide(){this.visible=!1,this.pointerType=void 0,this.element.classList.remove("pam-tooltip-host--visible","pam-tooltip-host--touch"),this.element.replaceChildren(),this.rafId!=null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}setLabels(t){this.labels=t}destroy(){this.hide(),this.element.remove()}schedulePosition(){this.rafId!=null&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>{const t=this.element.firstElementChild;if(!t)return;const{x:e,y:n}=ko(this.position,t,this.pointerType);this.element.style.left=`${e}px`,this.element.style.top=`${n}px`})}},Mo=class{element;messages;state=null;constructor(t,e){this.messages=e,this.element=document.createElement("div"),this.element.className="pam-chart__status",this.element.setAttribute("role","status"),this.element.setAttribute("aria-live","polite"),this.element.hidden=!0,t.appendChild(this.element)}show(t,e){this.state=t,this.element.hidden=!1,this.element.className=`pam-chart__status pam-chart__status--${t}`;const n=e??this.messages[t];this.element.replaceChildren();const r=document.createElement("p");if(r.className="pam-chart__status-text",r.textContent=n,this.element.append(r),t==="loading"){const i=document.createElement("span");i.className="pam-chart__status-spinner",i.setAttribute("aria-hidden","true"),this.element.prepend(i)}}hide(){this.state=null,this.element.hidden=!0,this.element.replaceChildren(),this.element.className="pam-chart__status"}isVisible(){return this.state!==null}getState(){return this.state}destroy(){this.element.remove()}};function So(t){if(typeof t=="string"){const e=document.querySelector(t);if(!e)throw new Error(`Container not found: ${t}`);return e}return t}function Ro(t){return{...Ft,...t}}var zo=class{container;zoom=new _n;renderer;tooltip=null;options;themeMedia=null;themeListener=null;keydownHandler=null;status;constructor(t,e,n={}){this.container=So(t),this.container.classList.add("pam-chart");const r=n.direction??"inherit";if(r!=="inherit"&&this.container.setAttribute("dir",r),n.lang&&this.container.setAttribute("lang",n.lang),this.options={theme:n.theme??"auto",legend:n.legend??!0,zoom:n.zoom??!0,direction:r,lang:n.lang??"en",ariaLabel:n.ariaLabel??"Argument map chart",tooltip:n.tooltip??!0,labels:Ro(n.labels),onNodeHover:n.onNodeHover,onNodeLeave:n.onNodeLeave,onNodeClick:n.onNodeClick,onZoomChange:n.onZoomChange,onWarning:n.onWarning},n.colors&&he(this.container,n.colors),this.status=new Mo(this.container,{loading:this.options.labels.statusLoading,empty:this.options.labels.statusEmpty,error:this.options.labels.statusError}),this.renderer=new Ao(this.container,{ariaLabel:this.options.ariaLabel,legend:this.options.legend,labels:this.options.labels,zoomEnabled:this.options.zoom,onHover:(i,o)=>this.handleHover(i,o),onLeave:()=>this.handleLeave(),onClick:(i,o,s)=>this.handleClick(i,o,s)}),this.options.tooltip!==!1){const i=typeof this.options.tooltip=="function"?this.options.tooltip:To;this.tooltip=new Eo(document.body,this.renderer.getTooltipElementId(),i,this.options.labels)}this.applyTheme(this.options.theme),this.bindKeyboard(),e?this.setData(e):this.status.show("empty")}setData(t){try{const{data:e,warnings:n}=yn(t);for(const o of n)this.options.onWarning?.(o);const{tree:r,warnings:i}=cn(e.new_nodes);for(const o of i)this.options.onWarning?.(o);if(!r){this.options.onWarning?.("Could not build tree from map data"),this.status.show("error",this.options.labels.statusError);return}this.status.hide(),this.zoom.setTree(r),this.render(),this.emitZoomChange()}catch(e){const n=e instanceof Q?e.issues.join("; "):e instanceof Error?e.message:this.options.labels.statusError;this.options.onWarning?.(n),this.status.show("error",n)}}setLoading(t){t?(this.status.show("loading"),this.tooltip?.hide()):this.status.getState()==="loading"&&this.status.hide()}showError(t){this.options.onWarning?.(t??this.options.labels.statusError),this.status.show("error",t),this.tooltip?.hide()}setTheme(t){this.options.theme=t,this.applyTheme(t)}setColors(t){he(this.container,{center:t.center,support:t.support,attack:t.attack,border:t.border}),lt(this.container);const e=this.zoom.getFocusRoot();e&&this.renderer.render(e)}highlight(t){this.renderer.setHighlight(t)}zoomTo(t){this.zoom.zoomTo(t)&&(this.render(),this.emitZoomChange())}zoomToPath(t){this.zoom.zoomToPath(t)&&(this.render(),this.emitZoomChange())}zoomOut(){this.zoom.zoomOut()&&(this.render(),this.emitZoomChange())}resetZoom(){this.zoom.resetZoom(),this.render(),this.emitZoomChange()}resize(){this.renderer.resize()}getZoomPath(){return this.zoom.getZoomPath()}destroy(){this.themeMedia&&this.themeListener&&this.themeMedia.removeEventListener("change",this.themeListener),this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.tooltip?.destroy(),this.status.destroy(),this.renderer.destroy(),this.container.classList.remove("pam-chart","pam-chart--light","pam-chart--dark"),this.options.direction!=="inherit"&&this.container.removeAttribute("dir")}render(){const t=this.zoom.getFocusRoot();t&&this.renderer.render(t)}emitZoomChange(){this.options.onZoomChange?.(this.zoom.getZoomPath())}handleHover(t,e){this.tooltip?.show(t,e),this.options.onNodeHover?.(t,e)}handleLeave(){this.tooltip?.hide(),this.options.onNodeLeave?.()}handleClick(t,e,n){this.options.zoom&&(this.zoom.handleClick(t,e,n),this.render(),this.emitZoomChange()),this.options.onNodeClick?.(t,e,n)}applyTheme(t){this.container.classList.remove("pam-chart--light","pam-chart--dark");const e=n=>{this.container.classList.add(n==="light"?"pam-chart--light":"pam-chart--dark"),b.colors.center=at.center,b.colors.support=at.support,b.colors.attack=at.attack,b.colors.border=at.border,lt(this.container);const r=this.zoom.getFocusRoot();r&&this.renderer.render(r)};if(this.themeMedia&&this.themeListener&&(this.themeMedia.removeEventListener("change",this.themeListener),this.themeMedia=null,this.themeListener=null),t==="light"||t==="dark"){e(t);return}this.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e(this.themeMedia.matches?"dark":"light"),this.themeListener=n=>e(n.matches?"dark":"light"),this.themeMedia.addEventListener("change",this.themeListener)}bindKeyboard(){this.keydownHandler=t=>{this.options.zoom&&(t.key==="Escape"||t.key==="Backspace")&&this.zoom.zoomOut()&&(t.preventDefault(),this.render(),this.emitZoomChange())},document.addEventListener("keydown",this.keydownHandler)}};function on(t,e,n){return new zo(t,e,n)}return typeof window<"u"&&(window.Parto={createArgumentMap:on}),Dt.createArgumentMap=on,Dt})({});