@veyforma/charts 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/veyforma-charts.cjs +2 -2
- package/dist/veyforma-charts.js +2 -2
- package/dist/veyforma-charts.min.js +2 -2
- package/dist/veyforma-charts.mjs +2 -2
- package/dist/veyforma-heatmap.min.js +1 -1
- package/dist/veyforma-pla.min.js +1 -1
- package/dist/veyforma-tornado.min.js +1 -1
- package/package.json +4 -4
- package/src/veyforma-charts.js +1 -1
package/dist/veyforma-charts.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
2
|
var __vfRoot = typeof window !== "undefined" ? window : {};
|
|
3
3
|
/*!
|
|
4
4
|
* Veyforma Exposure Heatmap v1.2.0
|
|
@@ -2935,7 +2935,7 @@ var __vfRoot = typeof window !== "undefined" ? window : {};
|
|
|
2935
2935
|
}
|
|
2936
2936
|
|
|
2937
2937
|
root.VeyformaCharts = {
|
|
2938
|
-
version: "1.0.
|
|
2938
|
+
version: "1.0.2",
|
|
2939
2939
|
/** Exposure heatmap: concentrations by any two fields, e.g. sector × country. */
|
|
2940
2940
|
heatmap: function (target, options) { return need("VeyHeatmap").create(target, options); },
|
|
2941
2941
|
/** Risk-factor tornado: down and up impact per factor, with convexity, limits and hedges. */
|
package/dist/veyforma-charts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
2
|
/*!
|
|
3
3
|
* Veyforma Exposure Heatmap v1.2.0
|
|
4
4
|
* A dependency-free heatmap that reveals concentrations, for example
|
|
@@ -2934,7 +2934,7 @@
|
|
|
2934
2934
|
}
|
|
2935
2935
|
|
|
2936
2936
|
root.VeyformaCharts = {
|
|
2937
|
-
version: "1.0.
|
|
2937
|
+
version: "1.0.2",
|
|
2938
2938
|
/** Exposure heatmap: concentrations by any two fields, e.g. sector × country. */
|
|
2939
2939
|
heatmap: function (target, options) { return need("VeyHeatmap").create(target, options); },
|
|
2940
2940
|
/** Risk-factor tornado: down and up impact per factor, with convexity, limits and hedges. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
2
|
-
(function(Y){"use strict";var Ct="1.2.0",kt="http://www.w3.org/2000/svg",St=0,_t={low:"#fbf1ea",mid:"#ef8a54",high:"#9a3412",empty:"#ffffff",limit:"#111111",cellText:"#000000",cellTextOnDark:"#ffffff",totalBar:"#111111",totalBarOpacity:.12,headerText:"#555555",text:"#111111",mutedText:"#6b6b6b",summaryBackground:"#f6f6f6",background:"transparent",tooltipBackground:"#111111",tooltipText:"#ffffff",focus:"#2563eb",fontFamily:"inherit",fontSize:12,cellRadius:3,cellGap:2},Mt={veyforma:{},mono:{low:"#f4f4f4",mid:"#9a9a9a",high:"#111111",empty:"#ffffff",limit:"#111111"},"colour-safe":{low:"#eef3fb",mid:"#6d9be0",high:"#1d3f8f",limit:"#d9730d"},ocean:{low:"#ecf6f8",mid:"#5aaec0",high:"#0c3b5e",limit:"#be123c",summaryBackground:"#eef5f8"},forest:{low:"#f1f5ea",mid:"#8fb36b",high:"#22441a",limit:"#a8590b",summaryBackground:"#f2f4ee"},corporate:{low:"#eef1f6",mid:"#8195b8",high:"#1e3a6e",limit:"#b91c1c",summaryBackground:"#f1f4f8",cellRadius:0},midnight:{background:"#111418",low:"#1e242c",mid:"#2f6aa8",high:"#9cd0ff",empty:"#111418",limit:"#fbbf24",cellText:"#000000",cellTextOnDark:"#ffffff",totalBar:"#9cd0ff",totalBarOpacity:.18,headerText:"#c3c9d2",text:"#f3f4f6",mutedText:"#a3abb8",summaryBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd"}};function At(h){if((h==null||h==="")&&(h="veyforma"),typeof h=="string")return Mt.hasOwnProperty(h)||(bt('Unknown theme "'+h+'". The "veyforma" theme is used instead.'),h="veyforma"),ft({},_t,Mt[h]);if(typeof h!="object")return bt("The theme option must be a theme name or an object."),ft({},_t);var w=h.extends?At(h.extends):ft({},_t),g=ft(w,h);return delete g.extends,["low","mid","high","empty"].forEach(function(v){pt(g[v])||(bt('Theme colour "'+v+'" must be a hex value such as "#9a3412". The default is used instead.'),g[v]=_t[v])}),g}function ft(h){for(var w=1;w<arguments.length;w++){var g=arguments[w];if(g)for(var v in g)Object.prototype.hasOwnProperty.call(g,v)&&(h[v]=g[v])}return h}function wt(h,w,g){return Math.min(g,Math.max(w,h))}function bt(h){Y.console&&Y.console.warn("VeyHeatmap: "+h)}function ot(h,w,g){var v=document.createElementNS(kt,h);if(w)for(var e in w)w[e]!=null&&v.setAttribute(e,w[e]);return g&&g.appendChild(v),v}function V(h,w,g){var v=document.createElement(h);return w&&(v.className=w),g&&g.appendChild(v),v}function pt(h){if(typeof h!="string")return null;var w=h.trim().replace(/^#/,"");if(w.length===3&&(w=w.split("").map(function(v){return v+v}).join("")),!/^[0-9a-fA-F]{6}$/.test(w))return null;var g=parseInt(w,16);return[g>>16&255,g>>8&255,g&255]}function Rt(h){return"#"+h.map(function(w){var g=Math.round(wt(w,0,255)).toString(16);return g.length<2?"0"+g:g}).join("")}function $t(h,w,g){return[h[0]+(w[0]-h[0])*g,h[1]+(w[1]-h[1])*g,h[2]+(w[2]-h[2])*g]}function ae(h){var w=pt(h.low),g=pt(h.mid),v=pt(h.high);return function(e){return e=wt(e,0,1),Rt(e<.5?$t(w,g,e*2):$t(g,v,(e-.5)*2))}}function dt(h,w){var g=I(h),v=I(w);return(Math.max(g,v)+.05)/(Math.min(g,v)+.05)}function I(h){var w=pt(h);if(!w)return 1;var g=w.map(function(v){return v/=255,v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4)});return .2126*g[0]+.7152*g[1]+.0722*g[2]}var J=null;function et(h,w,g,v){if(!J){var e=document.createElement("canvas");J=e.getContext&&e.getContext("2d")}return J?(J.font=(g||400)+" "+w+"px "+v,J.measureText(String(h)).width):String(h).length*w*.6}function ht(h,w,g,v,e){if(h=String(h),et(h,g,v,e)<=w)return h;for(var r=0,i=h.length;r<i;){var u=Math.ceil((r+i)/2);et(h.slice(0,u)+"\u2026",g,v,e)<=w?r=u:i=u-1}return r>0?h.slice(0,r).replace(/\s+$/,"")+"\u2026":""}function Ft(h,w,g,v,e){for(var r=String(h).split(/\s+/),i=[],u="",c=0;c<r.length;c++){var p=u?u+" "+r[c]:r[c];et(p,g,v,e)>w&&u?(i.push(u),u=r[c]):u=p}u&&i.push(u);var _=i.length<=2&&i.every(function(t){return et(t,g,v,e)<=w});return _?i:null}function yt(h){var w=Math.round(h*1e4)/100;return String(w)+"%"}function Dt(h,w){var g=h.decimals!=null?h.decimals:0,v=h.prefix||"",e=h.suffix||"",r={};function i(t,n){return r[t]||(r[t]=new Intl.NumberFormat(w||void 0,n)),r[t]}function u(t,n){n==null&&(n=g);var a=Math.pow(10,-n);if(t>0&&t<a/2)return"<"+v+i("f"+n,{minimumFractionDigits:n,maximumFractionDigits:n}).format(a)+e;var l=v+i("f"+n,{minimumFractionDigits:n,maximumFractionDigits:n}).format(Math.abs(t))+e;return t>=0?l:h.negatives==="brackets"?"("+l+")":"\u2212"+l}function c(t){return e?u(t,0):(t<0?"\u2212":"")+v+i("c",{notation:"compact",maximumFractionDigits:1}).format(Math.abs(t))}function p(t,n){return n==null&&(n=1),i("p"+n,{minimumFractionDigits:n,maximumFractionDigits:n}).format(t*100)+"%"}function _(t){return i("n",{maximumFractionDigits:0}).format(t)}return{value:u,compact:c,percent:p,count:_}}function it(h,w){return String(h).replace(/\{(\w+)\}/g,function(g,v){return w[v]!=null?w[v]:g})}var xt="\0other";function ut(h){if(Array.isArray(h.values)){var w=h.rowLabels,g=h.columnLabels,v=vt&&vt.get(h.values);if(v&&v.grid&&v.gridRows===w&&v.gridCols===g)return v.grid;if(!Array.isArray(w)||!Array.isArray(g))throw new Error("VeyHeatmap: a values grid needs rowLabels and columnLabels.");if(h.values.length!==w.length)throw new Error("VeyHeatmap: values has "+h.values.length+" rows but rowLabels has "+w.length+".");var e=[];h.values.forEach(function(p,_){if(!Array.isArray(p)||p.length!==g.length)throw new Error("VeyHeatmap: row "+(_+1)+" of values needs "+g.length+" numbers.");p.forEach(function(t,n){e.push({row:w[_],column:g[n],value:t})})});var r={records:e,rows:"row",columns:"column",dimensions:{row:{label:h.rowTitle||"Row",order:w.slice(),ordered:!0},column:{label:h.columnTitle||"Column",order:g.slice(),ordered:!0}}};if(vt){var i=vt.get(h.values)||{};i.grid=r,i.gridRows=w,i.gridCols=g,vt.set(h.values,i)}return r}if(!Array.isArray(h.records)||!h.records.length)throw new Error("VeyHeatmap: data needs records, or values with rowLabels and columnLabels.");var u=Object.keys(h.records[0]).filter(function(p){return p!=="value"}),c=ft({},h.dimensions||{});return u.forEach(function(p){c[p]||(c[p]={label:p.charAt(0).toUpperCase()+p.slice(1)})}),{records:h.records,rows:h.rows||u[0],columns:h.columns||u[1],dimensions:c}}var vt=typeof WeakMap=="function"?new WeakMap:null;function Zt(h,w,g,v){var e=w+""+g,r=vt&&v?vt.get(v):null;if(r&&r[e])return r[e];for(var i=new Map,u=new Map,c=new Map,p=0,_=h.records,t=_.length,n=0;n<t;n++){var a=_[n],l=a[w],o=a[g];if(l==null||l==="")throw new Error("VeyHeatmap: record "+(n+1)+' has no "'+w+'".');if(o==null||o==="")throw new Error("VeyHeatmap: record "+(n+1)+' has no "'+g+'".');var s=a.value,m=typeof s=="number"?s:Number(s);if(s==null||s===""||!isFinite(m))throw new Error("VeyHeatmap: record "+(n+1)+" has no numeric value.");if(m<0)throw new Error("VeyHeatmap: record "+(n+1)+" is negative. Exposure values must be zero or more.");typeof l!="string"&&(l=String(l)),typeof o!="string"&&(o=String(o));var f=i.get(l);f||(f=new Map,i.set(l,f),u.set(l,0)),f.set(o,(f.get(o)||0)+m),u.set(l,u.get(l)+m),c.set(o,(c.get(o)||0)+m),p+=m}var b=function(y){var x={};return y.forEach(function(M,d){x[d]=M}),x},k={cell:function(y,x){var M=i.get(y);return M&&M.get(x)||0},rowTot:b(u),colTot:b(c),rowSeen:Array.from(u.keys()),colSeen:Array.from(c.keys()),total:p};return vt&&v&&(r||(r={},vt.set(v,r)),r[e]=k),k}function Tt(h,w,g){var v=ut(h),e=w.rows||v.rows,r=w.columns||v.columns;if(!e||!r)throw new Error("VeyHeatmap: choose a field for the rows and a field for the columns.");if(e===r)throw new Error('VeyHeatmap: rows and columns cannot both use "'+e+'".');var i=ft({label:e},v.dimensions[e]),u=ft({label:r},v.dimensions[r]),c=Zt(v,e,r,Array.isArray(h.values)?h.values:h.records),p=c.rowTot,_=c.colTot,t=c.rowSeen,n=c.colSeen,a=c.total;function l(f,b,k,y,x){var M=f.slice();if(Array.isArray(k.order)){var d=k.order.map(String);M.sort(function(A,H){var lt=d.indexOf(A),tt=d.indexOf(H);return lt<0&&(lt=d.length+f.indexOf(A)),tt<0&&(tt=d.length+f.indexOf(H)),lt-tt})}var T=M.slice().sort(function(A,H){return b[H]-b[A]||M.indexOf(A)-M.indexOf(H)}),C=y==="total"||y!=="natural"&&!k.ordered,R=C?T:M,O=R.map(function(A){return{key:A,label:A,members:[A]}});if(x&&x>0&&R.length>x+1){var j=T.slice(0,x),E=R.filter(function(A){return j.indexOf(A)>=0}),S=R.filter(function(A){return j.indexOf(A)<0});O=E.map(function(A){return{key:A,label:A,members:[A]}}),O.push({key:xt,label:it(g.other,{count:S.length}),members:S,other:!0})}return O.forEach(function(A){A.total=A.members.reduce(function(H,lt){return H+b[lt]},0)}),O}var o=l(t,p,i,w.sortRows,w.topRows),s=l(n,_,u,w.sortColumns,w.topColumns),m=o.map(function(f){return s.map(function(b){var k=0;return f.members.forEach(function(y){b.members.forEach(function(x){k+=c.cell(y,x)})}),k})});return{rowKey:e,colKey:r,rowDim:i,colDim:u,rows:o,cols:s,values:m,total:a}}function Jt(h,w){var g=[],v=0;h.values.forEach(function(i,u){i.forEach(function(c,p){var _=h.total>0?c/h.total:0;v+=_*_*1e4,g.push({r:u,c:p,value:c,share:_})})}),g.sort(function(i,u){return u.value-i.value});var e=g.slice(0,5).reduce(function(i,u){return i+u.share},0),r=w>0?g.filter(function(i){return i.share>w+1e-12}):[];return{hhi:v,effective:v>0?1e4/v:0,largest:g[0],top5:e,above:r}}var Ht={data:null,theme:"veyforma",locale:void 0,rows:void 0,columns:void 0,valueMode:"amount",scale:"linear",sortRows:"auto",sortColumns:"auto",topRows:0,topColumns:0,fit:"auto",limit:void 0,totals:!0,cellLabels:"auto",cellHeight:void 0,summary:!0,legend:!0,tooltip:!0,animate:!0,labels:null,ariaLabel:void 0,tooltipFormatter:null,onClick:null,caption:!0,annotations:null,onAnnotationsChange:null,toolbar:!0},te={total:"Total",other:"Other ({count})",empty:"No exposure",totalExposure:"Total exposure",largest:"Largest concentration",hhi:"Concentration (HHI)",aboveLimit:"Above limit",top5:"Top 5 cells",hhiNote:"Like {n} equal-sized cells",aboveNote:"Cells above {limit} of total",gridNote:"{rows} {rowDim} \xD7 {cols} {colDim}",top5Note:"Share of total exposure",exposure:"Exposure",shareOfTotal:"Share of total",shareOfRow:"Share of {row}",shareOfColumn:"Share of {column}",limitLegend:"Above {limit} limit",limitTip:"Above the {limit} limit",rowTotalTip:"{label} total",scrollNote:"Scroll sideways to see all {columns}.",groupNote:"Smaller {columns} are grouped as Other to fit this screen. Tap an Other cell to see which.",includes:"Other includes {list}"};function Vt(){if(!document.getElementById("vhm-styles")){var h=".vhm{position:relative;color:var(--vhm-text);background:var(--vhm-bg);font-family:var(--vhm-font);line-height:1.4}.vhm.vhm-filled{padding:14px 14px 8px;border-radius:10px}.vhm-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px;margin:0 0 12px}.vhm-stat{background:var(--vhm-summary-bg);border-radius:10px;padding:10px 12px;min-width:0}.vhm-stat-label{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vhm-muted)}.vhm-stat-value{font-size:20px;font-weight:650;letter-spacing:-.01em;margin-top:2px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vhm-stat-note{font-size:11.5px;color:var(--vhm-muted);margin-top:1px;overflow-wrap:anywhere}.vhm-legend{display:flex;flex-wrap:wrap;align-items:center;gap:6px 18px;font-size:12px;margin:0 0 10px}.vhm-legend>span{display:inline-flex;align-items:center;gap:6px}.vhm-legend .vhm-ramp{display:inline-flex;flex-direction:column;align-items:stretch;gap:2px}.vhm-ramp-bar{width:150px;height:10px;border-radius:3px}.vhm-ramp-ticks{display:flex;justify-content:space-between;gap:8px;font-size:11px;color:var(--vhm-muted);font-variant-numeric:tabular-nums}.vhm-plot-host{overflow-x:auto;-webkit-overflow-scrolling:touch}.vhm-plot{display:block;overflow:visible;outline:none}.vhm-plot:focus-visible{outline:2px solid var(--vhm-focus);outline-offset:4px;border-radius:4px}.vhm-animate .vhm-cell{animation:vhm-fade .45s ease both}@keyframes vhm-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vhm-animate .vhm-cell{animation:none}}.vhm-scroll-note{font-size:11.5px;color:var(--vhm-muted);margin-top:4px}.vhm-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vhm-tip-bg);color:var(--vhm-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5}.vhm-tip.vhm-on{opacity:1;transform:none}.vhm-tip b{font-weight:600}.vhm-table{width:100%;border-collapse:collapse;font-size:13px}.vhm-table th,.vhm-table td{text-align:right;padding:7px 6px;border-bottom:1px solid rgba(127,127,127,.25);font-variant-numeric:tabular-nums;white-space:nowrap}.vhm-table th:first-child,.vhm-table td:first-child{text-align:left}.vhm-table th{font-weight:600;font-size:12px}.vhm-table tr.vhm-total td{font-weight:600}",w=document.createElement("style");w.id="vhm-styles",w.appendChild(document.createTextNode(h)),(document.head||document.documentElement).appendChild(w)}}function W(h,w){var g=typeof h=="string"?document.querySelector(h):h;if(!g||g.nodeType!==1)throw new Error("VeyHeatmap: container not found ("+h+").");if(!w||!w.data)throw new Error("VeyHeatmap: options.data is required.");Vt(),this.id=++St,this.container=g,this.options=ft({},Ht,w),this.element=V("div","vhm"),this.summaryEl=V("div","vhm-summary",this.element),this.legendEl=V("div","vhm-legend",this.element),this.plotHost=V("div","vhm-plot-host",this.element),this.noteEl=V("div","vhm-scroll-note",this.element),this.tipEl=V("div","vhm-tip",this.element),this.tipEl.setAttribute("role","tooltip"),this.tipEl.id="vhm-tip-"+this.id,g.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=null;var v=this;Y.ResizeObserver?(this._observer=new Y.ResizeObserver(function(){var e=Math.round(v.element.clientWidth);e&&e!==v._lastWidth&&v.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){v.redraw()},Y.addEventListener("resize",this._onResize)),this._onDocTap=function(e){v.element.contains(e.target)||v._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&Y.VeyformaToolkit&&(this.toolkit=Y.VeyformaToolkit.attach(this,this.options.toolbar))}W.prototype.update=function(h){return h?(h.data&&h.data!==this.options.data&&this.options.animate&&(this._animateNext=!0,this._active=null),(h.rows||h.columns||h.topRows!=null||h.topColumns!=null)&&(this._active=null),h.animate===!0&&(this._animateNext=!0),ft(this.options,h),this.redraw()):this},W.prototype.setData=function(h){return vt&&h&&(Array.isArray(h.records)&&vt.delete(h.records),Array.isArray(h.values)&&vt.delete(h.values)),this.update({data:h})},W.prototype.setTheme=function(h){return this.update({theme:h})},W.prototype.getTheme=function(){return At(this.options.theme)},W.prototype._labels=function(){return ft({},te,this.options.labels)},W.prototype._limit=function(){var h=this.options,w=h.limit!==void 0?h.limit:h.data.limit&&h.data.limit.share;return w=Number(w),isFinite(w)&&w>0&&w<1?w:0},W.prototype.getMatrix=function(){var h=Tt(this.options.data,this.options,this._labels()),w=function(g){return{key:g.key===xt?null:g.key,label:g.label,total:g.total,other:!!g.other,members:g.members.slice()}};return{rowField:h.rowKey,columnField:h.colKey,rows:h.rows.map(w),columns:h.cols.map(w),values:h.values.map(function(g){return g.slice()}),total:h.total}},W.prototype.getStats=function(){var h=Tt(this.options.data,ft({},this.options,{topRows:0,topColumns:0}),this._labels()),w=this._limit(),g=Jt(h,w),v=function(e){return{row:h.rows[e.r].label,column:h.cols[e.c].label,value:e.value,share:e.share}};return{total:h.total,rows:h.rows.length,columns:h.cols.length,hhi:g.hhi,effectiveCells:g.effective,top5Share:g.top5,largest:g.largest?v(g.largest):null,limit:w||null,aboveLimit:g.above.map(v)}},W.prototype.createTable=function(){var h=this.options,w=h.data,g=this._labels(),v=Tt(w,h,g),e=Dt(w,h.locale),r=document.createElement("table");if(r.className="vhm-table",w.title){var i=V("caption",null,r);i.textContent=w.title,i.style.cssText="text-align:left;font-weight:600;padding:0 6px 6px"}var u=V("tr",null,V("thead",null,r)),c=V("th",null,u);c.scope="col",c.textContent=v.rowDim.label,v.cols.forEach(function(n){var a=V("th",null,u);a.scope="col",a.textContent=n.label});var p=V("th",null,u);p.scope="col",p.textContent=g.total;var _=V("tbody",null,r);v.rows.forEach(function(n,a){var l=V("tr",null,_),o=V("th",null,l);o.scope="row",o.textContent=n.label,o.style.textAlign="left",o.style.fontWeight="400",v.values[a].forEach(function(s){V("td",null,l).textContent=s?e.value(s):"\u2014"}),V("td",null,l).textContent=e.value(n.total)});var t=V("tr","vhm-total",_);return V("td",null,t).textContent=g.total,v.cols.forEach(function(n){V("td",null,t).textContent=e.value(n.total)}),V("td",null,t).textContent=e.value(v.total),r},W.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&Y.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},W.prototype._hideTip=function(){this.tipEl.classList.remove("vhm-on"),this._focusRect&&this._focusRect.setAttribute("opacity",0),this._boldReset&&this._boldReset()},W.prototype._placeTip=function(h,w,g){var v=this.tipEl;v.textContent="",h.forEach(function(t,n){n&&v.appendChild(document.createElement("br"));var a=n===0?document.createElement("b"):document.createTextNode("");a.textContent=t,v.appendChild(a)});var e=this.element.getBoundingClientRect(),r=g&&g.clientX?g.clientX:w.left+w.width/2,i=g&&g.clientY?g.clientY:w.top;v.classList.add("vhm-on");var u=v.offsetWidth,c=v.offsetHeight,p=wt(r-e.left-u/2,4,Math.max(4,e.width-u-4)),_=i-e.top-c-14;_<0&&(_=(w.bottom!=null?w.bottom:i)-e.top+10),v.style.left=p+"px",v.style.top=_+"px"},W.prototype.redraw=function(){var h=this.options,w=h.data,g=this,v=At(h.theme),e=this._labels(),r=Tt(w,h,e),i=Dt(w,h.locale),u=h.topRows>0||h.topColumns>0?Tt(w,ft({},h,{topRows:0,topColumns:0}),e):r,c=this._limit(),p=Jt(u,c),_=this.element,t=ae(v),n=v.background&&v.background!=="transparent"?v.background:"#ffffff",a=v.fontFamily==="inherit"?Y.getComputedStyle?Y.getComputedStyle(this.container).fontFamily:"sans-serif":v.fontFamily,l=_.style;l.setProperty("--vhm-text",v.text),l.setProperty("--vhm-muted",v.mutedText),l.setProperty("--vhm-bg",v.background),l.setProperty("--vhm-font",a),l.setProperty("--vhm-focus",v.focus),l.setProperty("--vhm-tip-bg",v.tooltipBackground),l.setProperty("--vhm-tip-text",v.tooltipText),l.setProperty("--vhm-summary-bg",v.summaryBackground),_.classList.toggle("vhm-filled",!!v.background&&v.background!=="transparent"),_.classList.toggle("vhm-animate",!!this._animateNext);var o=Math.max(this.plotHost.clientWidth||_.clientWidth||0,280);this._lastWidth=Math.round(_.clientWidth);var s=o<560,m=Number(v.fontSize)||12,f=s?m-1.5:m-.5,b=s?m-2:m-1,k=h.cellHeight||(s?28:34),y=Math.max(0,Number(v.cellGap)||0),x=s?26:34,M=Math.max.apply(null,r.rows.map(function(L){return et(L.label,f,400,a)})),d=Math.min(Math.ceil(M)+12,Math.round(o*(s?.3:.26))),T=h.totals?Math.max(s?50:70,Math.ceil(et(i.value(Math.max.apply(null,r.rows.map(function(L){return L.total}))),m-1,600,a))+12):0;h.totals&&s&&(T=Math.min(T,64));var C=h.totals?8:0,R=o-d-C-T-2,O=h.fit||"auto",j=!1,E=Math.floor(R/x),S=O==="group"||O==="auto"&&!r.colDim.ordered&&!(h.topColumns>0);S&&r.cols.length>E&&E>=3&&(r=Tt(w,ft({},h,{topColumns:E-1}),e),j=!0);var A=r.rows.length,H=r.cols.length,lt=(r.rowDim.plural||r.rowDim.label).toLowerCase(),tt=(r.colDim.plural||r.colDim.label).toLowerCase(),D=h.valueMode;["amount","shareOfTotal","shareOfRow","shareOfColumn"].indexOf(D)<0&&(D="amount");for(var K=function(L,z){var $=r.values[L][z];return D==="shareOfTotal"?r.total?$/r.total:0:D==="shareOfRow"?r.rows[L].total?$/r.rows[L].total:0:D==="shareOfColumn"?r.cols[z].total?$/r.cols[z].total:0:$},q=0,X=0;X<A;X++)for(var Q=0;Q<H;Q++)q=Math.max(q,K(X,Q));var Z=h.scale==="sqrt",P=function(L){if(q<=0)return 0;var z=L/q;return Z?Math.sqrt(z):z},N=function(L,z){return D==="amount"?z?i.compact(L):i.value(L):i.percent(L,z?0:1)},F=this.summaryEl;if(F.textContent="",F.style.display=h.summary?"":"none",h.summary){var B=function(L,z,$){var G=V("div","vhm-stat",F);V("div","vhm-stat-label",G).textContent=L,V("div","vhm-stat-value",G).textContent=z,$&&(V("div","vhm-stat-note",G).textContent=$)};B(e.totalExposure,i.value(r.total),it(e.gridNote,{rows:u.rows.length,rowDim:lt,cols:u.cols.length,colDim:tt})),p.largest&&B(e.largest,i.percent(p.largest.share),u.rows[p.largest.r].label+" \xD7 "+u.cols[p.largest.c].label+" \xB7 "+i.value(p.largest.value)),B(e.hhi,i.count(p.hhi),it(e.hhiNote,{n:i.count(Math.round(p.effective))})),c?B(e.aboveLimit,i.count(p.above.length),it(e.aboveNote,{limit:yt(c)})):B(e.top5,i.percent(p.top5),e.top5Note)}var U=this.legendEl;if(U.textContent="",U.style.display=h.legend?"":"none",h.legend){var nt=V("span","vhm-ramp",U),st=V("span","vhm-ramp-bar",nt);st.style.background="linear-gradient(to right,"+[0,.25,.5,.75,1].map(function(L){return t(L)}).join(",")+")";var at=V("span","vhm-ramp-ticks",nt),zt=Z?q*.25:q*.5;[0,zt,q].forEach(function(L){V("span",null,at).textContent=N(L,!0)});var mt=V("span",null,U),gt=ot("svg",{width:14,height:14,"aria-hidden":"true"},mt);if(ot("rect",{x:1,y:1,width:12,height:12,rx:2,fill:v.empty,stroke:v.mutedText,"stroke-opacity":.45,"stroke-dasharray":"2 2"},gt),mt.appendChild(document.createTextNode(e.empty)),c){var Et=V("span",null,U),jt=ot("svg",{width:14,height:14,"aria-hidden":"true"},Et);ot("rect",{x:1.5,y:1.5,width:11,height:11,rx:2,fill:t(.7),stroke:v.limit,"stroke-width":2},jt),ot("rect",{x:3.5,y:3.5,width:7,height:7,rx:1,fill:"none",stroke:n,"stroke-width":1},jt),Et.appendChild(document.createTextNode(it(e.limitLegend,{limit:yt(c)})))}}var rt=R/H,Wt=!1;rt<x&&(rt=x,Wt=!0),R=rt*H;var Kt=r.cols.map(function(L){return Ft(L.label,rt-4,f,400,a)}),ee=Kt.some(function(L){return L===null}),ne=Math.max.apply(null,r.cols.map(function(L){return et(L.label,f,400,a)})),oe=Math.min(ne,140),Xt=ee?Math.ceil(oe*.7071+f+10):Math.max.apply(null,Kt.map(function(L){return L.length}))*(f+3)+10,ce=ee?Math.max(0,oe*.7071-T-C):0,ie=d+R+C+T+2+ce;ie>o+.5&&(Wt=!0);var ye=Xt,Ee=h.totals?k:0,xe=ye+A*k+(h.totals?C+Ee:0)+4,fe=d,Bt=function(L){return fe+L*rt},Lt=function(L){return ye+L*k};this.plotHost.textContent="",this.noteEl.textContent=Wt?it(e.scrollNote,{columns:tt}):j?it(e.groupNote,{columns:tt}):"",this.noteEl.style.display=Wt||j?"":"none";var Nt=ot("svg",{class:"vhm-plot",viewBox:"0 0 "+ie+" "+xe,width:ie,height:xe,tabindex:0,role:"img","aria-label":h.ariaLabel||[w.title,r.rowDim.label+" by "+r.colDim.label,p.largest?e.largest+": "+u.rows[p.largest.r].label+" \xD7 "+u.cols[p.largest.c].label+", "+i.percent(p.largest.share):null].filter(Boolean).join(". ")},this.plotHost);Wt||(Nt.style.width="100%",Nt.style.height="auto");var Gt=function(L,z,$){var G=ot("text",ft({"font-family":a},L),$||Nt);return G.textContent=z,G},ke=[];r.cols.forEach(function(L,z){var $=Bt(z)+rt/2,G=ot("g",null,Nt);if(ee){var ct=Xt-6;Gt({x:$-2,y:ct,"text-anchor":"start",transform:"rotate(-45 "+($-2)+" "+ct+")","font-size":f,fill:L.other?v.mutedText:v.headerText},ht(L.label,140,f,400,a),G)}else{var qt=Kt[z];qt.forEach(function(Qt,Fe){Gt({x:$,y:Xt-6-(qt.length-1-Fe)*(f+3),"text-anchor":"middle","font-size":f,fill:L.other?v.mutedText:v.headerText},Qt,G)})}ke.push(G)}),h.totals&&Gt({x:fe+R+C+T-4,y:Xt-6,"text-anchor":"end","font-size":f,"font-weight":600,fill:v.text},e.total);var Le=r.rows.map(function(L,z){var $=ht(L.label,d-12,f,400,a),G=Gt({x:d-8,y:Lt(z)+k/2+f*.35,"text-anchor":"end","font-size":f,fill:L.other?v.mutedText:v.headerText},$);if($!==L.label){var ct=ot("title",null,G);ct.textContent=L.label}return G});h.totals&&Gt({x:d-8,y:Lt(A)+C+k/2+f*.35,"text-anchor":"end","font-size":f,"font-weight":600,fill:v.text},e.total);for(var Ut=ot("g",null,Nt),Ce=h.cellLabels===!0||h.cellLabels==="auto",Pt=0;Pt<A;Pt++)for(var Ot=0;Ot<H;Ot++){var le=r.values[Pt][Ot],pe=K(Pt,Ot),de=le>0?t(P(pe)):v.empty,re=ot("rect",{x:Bt(Ot)+y/2,y:Lt(Pt)+y/2,width:Math.max(rt-y,1),height:Math.max(k-y,1),rx:Math.min(v.cellRadius,rt/4),fill:de,class:"vhm-cell","data-r":Pt,"data-c":Ot},Ut);if(le>0||(re.setAttribute("stroke",v.mutedText),re.setAttribute("stroke-opacity",.45),re.setAttribute("stroke-dasharray","2 2"),re.setAttribute("stroke-width",1)),re.style.animationDelay=Math.min((Pt+Ot)*18,500)+"ms",c&&r.total>0&&le/r.total>c+1e-12&&!r.rows[Pt].other&&!r.cols[Ot].other&&(ot("rect",{x:Bt(Ot)+y/2+1,y:Lt(Pt)+y/2+1,width:Math.max(rt-y-2,1),height:Math.max(k-y-2,1),rx:Math.min(v.cellRadius,rt/4),fill:"none",stroke:v.limit,"stroke-width":2,"pointer-events":"none"},Ut),ot("rect",{x:Bt(Ot)+y/2+3,y:Lt(Pt)+y/2+3,width:Math.max(rt-y-6,1),height:Math.max(k-y-6,1),rx:Math.max(0,Math.min(v.cellRadius,rt/4)-1),fill:"none",stroke:n,"stroke-width":1,"pointer-events":"none"},Ut)),Ce&&le>0&&k-y>=16){var Se=rt-y-8,se=N(pe,!1);if(et(se,b,500,a)>Se&&(se=N(pe,!0)),et(se,b,500,a)<=Se){var Ae=dt(de,v.cellTextOnDark)>dt(de,v.cellText)?v.cellTextOnDark:v.cellText;Gt({x:Bt(Ot)+rt/2,y:Lt(Pt)+k/2+b*.35,"text-anchor":"middle","font-size":b,"font-weight":500,fill:Ae,"pointer-events":"none",class:"vhm-cell-label"},se,Ut)}}}var Yt=null;if(h.totals){Yt=ot("g",null,Nt);var Re=Math.max.apply(null,r.rows.map(function(L){return L.total}))||1,ze=Math.max.apply(null,r.cols.map(function(L){return L.total}))||1,me=fe+R+C;r.rows.forEach(function(L,z){var $=Math.max(2,(T-2)*L.total/Re);ot("rect",{x:me,y:Lt(z)+y/2+3,width:$,height:k-y-6,rx:2,fill:v.totalBar,"fill-opacity":v.totalBarOpacity,"data-tr":z},Yt);var G=i.value(L.total);et(G,m-1,600,a)>T-6&&(G=i.compact(L.total)),Gt({x:me+T-4,y:Lt(z)+k/2+(m-1)*.35,"text-anchor":"end","font-size":m-1,"font-weight":600,fill:v.text,"pointer-events":"none"},G,Yt)});var ve=Lt(A)+C;r.cols.forEach(function(L,z){var $=Math.max(2,(k-y-4)*L.total/ze);ot("rect",{x:Bt(z)+y/2+2,y:ve+k-y/2-2-$,width:Math.max(rt-y-4,1),height:$,rx:2,fill:v.totalBar,"fill-opacity":v.totalBarOpacity,"data-tc":z},Yt);var G=i.value(L.total);et(G,b,600,a)>rt-y-6&&(G=i.compact(L.total)),et(G,b,600,a)<=rt-y-6&&Gt({x:Bt(z)+rt/2,y:ve+k/2+b*.35,"text-anchor":"middle","font-size":b,"font-weight":600,fill:v.text,"pointer-events":"none"},G,Yt)});var be=i.value(r.total);et(be,m-1,700,a)>T-6&&(be=i.compact(r.total)),Gt({x:me+T-4,y:ve+k/2+(m-1)*.35,"text-anchor":"end","font-size":m-1,"font-weight":700,fill:v.text},be)}this._focusRect=ot("rect",{x:0,y:0,width:0,height:0,rx:Math.min(v.cellRadius+1,6),fill:"none",stroke:v.text,"stroke-width":2,opacity:0,"pointer-events":"none"},Nt);var ge=function(L,z){var $=r.values[L][z];return{row:r.rows[L].label,column:r.cols[z].label,rowIndex:L,columnIndex:z,value:$,shareOfTotal:r.total?$/r.total:0,shareOfRow:r.rows[L].total?$/r.rows[L].total:0,shareOfColumn:r.cols[z].total?$/r.cols[z].total:0,aboveLimit:!!(c&&r.total&&$/r.total>c+1e-12&&!r.rows[L].other&&!r.cols[z].other),rowMembers:r.rows[L].members.slice(),columnMembers:r.cols[z].members.slice()}},ue=[];this._boldReset=function(){ue.forEach(function(L){L.removeAttribute("font-weight")}),ue=[]};var Ne=function(L,z){g._boldReset();var $=Le[L];$.setAttribute("font-weight",600),ue.push($),Array.prototype.forEach.call(ke[z].childNodes,function(G){G.setAttribute("font-weight",600),ue.push(G)})},he=function(L,z,$){if(g._active=[L,z],g._focusRect.setAttribute("x",Bt(z)+y/2-1),g._focusRect.setAttribute("y",Lt(L)+y/2-1),g._focusRect.setAttribute("width",rt-y+2),g._focusRect.setAttribute("height",k-y+2),g._focusRect.setAttribute("opacity",1),Ne(L,z),!!h.tooltip){var G=ge(L,z),ct;typeof h.tooltipFormatter=="function"?(ct=h.tooltipFormatter(G,i),Array.isArray(ct)||(ct=[String(ct)])):(ct=[G.row+" \xD7 "+G.column],G.value?(ct.push(e.exposure+": "+i.value(G.value)),ct.push(e.shareOfTotal+": "+i.percent(G.shareOfTotal)),ct.push(it(e.shareOfRow,{row:G.row})+": "+i.percent(G.shareOfRow)),ct.push(it(e.shareOfColumn,{column:G.column})+": "+i.percent(G.shareOfColumn)),G.aboveLimit&&ct.push(it(e.limitTip,{limit:yt(c)}))):ct.push(e.empty),r.rows[L].other&&ct.push(it(e.includes,{list:r.rows[L].members.join(", ")})),r.cols[z].other&&ct.push(it(e.includes,{list:r.cols[z].members.join(", ")})));var qt=Nt.getBoundingClientRect(),Qt=qt.width/ie;g._placeTip(ct,{left:qt.left+Bt(z)*Qt,top:qt.top+Lt(L)*Qt,width:rt*Qt,bottom:qt.top+(Lt(L)+k)*Qt},$)}},_e=function(L,z,$){var G=L?r.rows[z]:r.cols[z],ct=[it(e.rowTotalTip,{label:G.label}),i.value(G.total)+" \xB7 "+i.percent(r.total?G.total/r.total:0)+" "+e.shareOfTotal.toLowerCase()];G.other&&ct.push(G.members.join(", ")),g._placeTip(ct,{left:$.clientX,top:$.clientY,width:0},$)};Ut.addEventListener("mousemove",function(L){var z=L.target;!z.hasAttribute||!z.hasAttribute("data-r")||he(+z.getAttribute("data-r"),+z.getAttribute("data-c"),L)}),Ut.addEventListener("pointerdown",function(L){var z=L.target;!z.hasAttribute||!z.hasAttribute("data-r")||he(+z.getAttribute("data-r"),+z.getAttribute("data-c"),L)}),Ut.addEventListener("mouseleave",function(){g._hideTip()}),typeof h.onClick=="function"&&(Ut.style.cursor="pointer",Ut.addEventListener("click",function(L){var z=L.target;!z.hasAttribute||!z.hasAttribute("data-r")||h.onClick(ge(+z.getAttribute("data-r"),+z.getAttribute("data-c")),L)})),Yt&&(Yt.addEventListener("mousemove",function(L){var z=L.target;z.hasAttribute&&z.hasAttribute("data-tr")?_e(!0,+z.getAttribute("data-tr"),L):z.hasAttribute&&z.hasAttribute("data-tc")&&_e(!1,+z.getAttribute("data-tc"),L)}),Yt.addEventListener("mouseleave",function(){g._hideTip()})),this._geom={rows:r.rows,cols:r.cols,cx:Bt,cy:Lt,cellW:rt,cellH:k,gap:y},Nt.setAttribute("aria-describedby",this.tipEl.id);var we=[0,0];if(p.largest){var Te=r.rows.map(function(L){return L.key}).indexOf(u.rows[p.largest.r].key),Me=r.cols.map(function(L){return L.key}).indexOf(u.cols[p.largest.c].key);Te>=0&&Me>=0&&(we=[Te,Me])}return Nt.addEventListener("focus",function(){var L=g._active&&g._active[0]<A&&g._active[1]<H?g._active:we;he(L[0],L[1])}),Nt.addEventListener("blur",function(){g._hideTip()}),Nt.addEventListener("keydown",function(L){var z=g._active&&g._active[0]<A&&g._active[1]<H?g._active.slice():we.slice();if(L.key==="ArrowLeft")z[1]=Math.max(0,z[1]-1);else if(L.key==="ArrowRight")z[1]=Math.min(H-1,z[1]+1);else if(L.key==="ArrowUp")z[0]=Math.max(0,z[0]-1);else if(L.key==="ArrowDown")z[0]=Math.min(A-1,z[0]+1);else if(L.key==="Home")z[1]=0;else if(L.key==="End")z[1]=H-1;else if((L.key==="Enter"||L.key===" ")&&typeof h.onClick=="function"){L.preventDefault(),h.onClick(ge(z[0],z[1]),L);return}else return;L.preventDefault(),he(z[0],z[1])}),this._hideTip(),this._animateNext=!1,this};function It(h,w){if(w==null)return-1;w=String(w);for(var g=0;g<h.length;g++)if(h[g].label===w||h[g].key===w||h[g].members.indexOf(w)>=0)return g;return-1}W.prototype.howToRead=function(){var h=Tt(this.options.data,this.options,this._labels()),w=(h.rowDim.label||"row").toLowerCase(),g=(h.colDim.label||"column").toLowerCase();return"Each cell is the exposure where a "+w+" meets a "+g+"; darker cells hold more. The bars on the right and along the bottom are the totals for each "+w+" and "+g+". HHI measures concentration: the higher it is, the more the book depends on a few cells."+(this._limit()?" Cells with a double outline are above the concentration limit.":"")},W.prototype.describe=function(){var h=this.getStats(),w=Dt(this.options.data,this.options.locale),g=Tt(this.options.data,this.options,this._labels()),v=["In this example total exposure is "+w.value(h.total)+" across "+h.rows+" "+(g.rowDim.plural||g.rowDim.label).toLowerCase()+" and "+h.columns+" "+(g.colDim.plural||g.colDim.label).toLowerCase()+"."];return h.largest&&v.push("The largest cell is "+h.largest.row+" \xD7 "+h.largest.column+" with "+w.value(h.largest.value)+" ("+w.percent(h.largest.share)+" of the total)."),v.push("HHI is "+w.count(h.hhi)+", like "+w.count(Math.round(h.effectiveCells))+" equal-sized cells."),h.limit&&v.push(h.aboveLimit.length+" "+(h.aboveLimit.length===1?"cell is":"cells are")+" above the "+yt(h.limit)+" limit."),v.join(" ")},W.prototype.getExportData=function(){var h=this.options,w=h.data,g=this._labels(),v=Tt(w,ft({},h,{topRows:0,topColumns:0}),g),e=Dt(w,h.locale),r=this.getStats(),i=this._limit(),u={prefix:w.prefix||"",suffix:w.suffix||"",decimals:w.decimals!=null?w.decimals:0,negatives:w.negatives},c=[{label:v.rowDim.label,type:"text"}].concat(v.cols.map(function(s){return{label:s.label,type:"number",unit:u}}),[{label:g.total,type:"number",unit:u}]),p=v.rows.map(function(s,m){return[s.label].concat(v.values[m],[s.total])});p.push([g.total].concat(v.cols.map(function(s){return s.total}),[v.total]));var _=v.rows.map(function(s,m){return[s.label].concat(v.values[m].map(function(f){return f?e.value(f):"\u2014"}),[e.value(s.total)])});_.push([g.total].concat(v.cols.map(function(s){return e.value(s.total)}),[e.value(v.total)]));var t=[];v.rows.forEach(function(s,m){v.cols.forEach(function(f,b){var k=v.values[m][b];k&&t.push([s.label,f.label,k,v.total?k/v.total:0])})}),t.sort(function(s,m){return m[2]-s[2]});var n=function(s){return i&&s>i+1e-12?"Yes":"No"},a=[[g.totalExposure,r.total,e.value(r.total)],[g.hhi,r.hhi,e.count(r.hhi)],["Effective number of cells",r.effectiveCells,e.count(Math.round(r.effectiveCells))],[g.top5,r.top5Share,e.percent(r.top5Share)]];r.largest&&a.push([g.largest,r.largest.share,r.largest.row+" \xD7 "+r.largest.column+" \xB7 "+e.percent(r.largest.share)]),i&&(a.push(["Limit (share of total)",i,yt(i)]),a.push([g.aboveLimit,r.aboveLimit.length,e.count(r.aboveLimit.length)]));var l=(h.annotations||[]).map(function(s,m){return[String(m+1),String(s.row||""),String(s.column||""),s.text||""]}),o=[{name:"Matrix",columns:c,rows:p,text:_,bold:p.map(function(s,m){return m===p.length-1})},{name:"Cells",columns:[{label:v.rowDim.label,type:"text"},{label:v.colDim.label,type:"text"},{label:g.exposure,type:"number",unit:u},{label:g.shareOfTotal,type:"percent",decimals:2},{label:g.aboveLimit,type:"text"}],rows:t.map(function(s){return[s[0],s[1],s[2],s[3],n(s[3])]}),text:t.map(function(s){return[s[0],s[1],e.value(s[2]),e.percent(s[3],2),n(s[3])]})},{name:"Concentration",columns:[{label:"Measure",type:"text"},{label:"Value",type:"general"},{label:"As shown",type:"text"}],rows:a,text:a.map(function(s){return[s[0],typeof s[1]=="number"?String(Number(s[1].toPrecision(10))):String(s[1]),s[2]]})}];return l.length&&o.push({name:"Notes",columns:[{label:"No.",type:"text"},{label:v.rowDim.label,type:"text"},{label:v.colDim.label,type:"text"},{label:"Note",type:"text"}],rows:l}),{title:w.title||"Exposure heatmap",subtitle:w.subtitle||"",summary:this.describe(),library:"Veyforma Exposure Heatmap "+Ct,sheets:o,meta:[["Method","HHI = 10,000 \xD7 sum of squared cell shares; effective number of cells = 10,000 \xF7 HHI; a cell is above the limit when its share is strictly greater"],["Grid",v.rowDim.label+" \xD7 "+v.colDim.label+", full grid without Other grouping"],["Unit",w.unit],["Limit",i?yt(i)+" of total":null],["As of",w.asOf],["Data source",w.source]]}},W.prototype._annotationPoint=function(h){var w=this._geom;if(!w||!h)return null;var g=It(w.rows,h.row),v=It(w.cols,h.column);if(g<0||v<0)return null;var e=w.rows[g]&&w.rows[g].other||w.cols[v]&&w.cols[v].other;return{x:w.cx(v)+w.gap/2+11,y:w.cy(g)+w.gap/2+11,inside:!0,where:e?"shown in Other":null}},W.prototype._annotationTarget=function(h){var w=this._geom,g,v;if(!w)return null;if(h){var e=h.target;if(!e||!e.getAttribute||e.getAttribute("data-r")==null)return null;g=+e.getAttribute("data-r"),v=+e.getAttribute("data-c")}else if(this._active)g=this._active[0],v=this._active[1];else return null;return!w.rows[g]||!w.cols[v]||w.rows[g].other||w.cols[v].other?null:{row:w.rows[g].label,column:w.cols[v].label}},W.prototype._annotationLabel=function(h){return[h.row,h.column].filter(Boolean).join(" \xD7 ")},Y.VeyHeatmap={version:Ct,create:function(h,w){return new W(h,w)},registerTheme:function(h,w){if(!h||typeof h!="string")throw new Error("VeyHeatmap: registerTheme needs a name.");return Mt[h]=At(w||{}),Mt[h]},getTheme:function(h){return At(h)},listThemes:function(){return Object.keys(Mt)}}})(typeof window<"u"?window:void 0);(function(Y){"use strict";var Ct="1.0.0",kt="http://www.w3.org/2000/svg",St=0,_t={down:"#4b5563",up:"#c2410c",hedge:"#2f6fed",contribution:"#a63d16",convexity:"#111827",limit:"#b91c1c",grid:"#ececec",axis:"#9ca3af",text:"#111827",mutedText:"#4b5563",axisText:"#4b5563",cardBackground:"#f9fafb",background:"transparent",tooltipBackground:"#111827",tooltipText:"#ffffff",focus:"#c2410c",accent:"#c2410c",fontFamily:"inherit",fontSize:12},Mt={veyforma:{},mono:{down:"#8a8a8a",up:"#111111",hedge:"#8a8a8a",contribution:"#111111",convexity:"#111111",limit:"#111111",accent:"#111111",focus:"#111111"},"colour-safe":{down:"#2166ac",up:"#b2182b",hedge:"#1b7837",contribution:"#762a83",limit:"#b2182b",accent:"#2166ac"},ocean:{down:"#64748b",up:"#0c6e8f",hedge:"#c2410c",contribution:"#0c3b5e",cardBackground:"#eef5f8",accent:"#0c6e8f"},forest:{down:"#78716c",up:"#4d6b31",hedge:"#2f6fed",contribution:"#22311a",cardBackground:"#f2f4ee",accent:"#4d6b31"},corporate:{down:"#64748b",up:"#1d4ed8",hedge:"#c2410c",contribution:"#1e293b",cardBackground:"#f1f4f8",accent:"#1d4ed8"},midnight:{background:"#111418",down:"#a3abb8",up:"#f08a5d",hedge:"#93c5fd",contribution:"#f08a5d",convexity:"#f3f4f6",limit:"#fb7185",grid:"#252a31",axis:"#4b5563",text:"#f3f4f6",mutedText:"#a3abb8",axisText:"#a3abb8",cardBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd",accent:"#f08a5d"}},At={data:null,view:"factors",sort:"swing",top:15,shockScale:1,whatIf:null,theme:"veyforma",locale:void 0,animate:!0,summary:!0,legend:!0,labels:null,ariaLabel:void 0,caption:!0,annotations:null,onAnnotationsChange:null,onItemClick:null,exportRows:2e4,toolbar:!0},ft={factors:"Impact by risk factor",groups:"Impact by group",contribution:"Share of the combined move",down:"Down shock",up:"Up shock",swing:"Swing",worst:"Worst result",convexity:"Convexity",linear:"Linear part",limit:"Limit",largest:"Largest driver",worstShock:"Worst single shock",topShare:"Top {n} factors",combined:"Combined move",contributionAdds:"Adds to the combined move",hedge:"Hedges (lowers it)",standalone:"Stand-alone",other:"Other {n} factors",whatIf:"What-if",interaction:"Interaction",noData:"n/a"};function wt(e){for(var r=1;r<arguments.length;r++){var i=arguments[r];if(i)for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(e[u]=i[u])}return e}var bt={};function ot(e){bt[e]||(bt[e]=1,Y.console&&console.warn&&console.warn("VeyRiskTornado: "+e))}function V(e){throw new Error("VeyRiskTornado: "+e)}function pt(e,r,i){return Math.min(i,Math.max(r,e))}function Rt(e,r){return String(e).replace(/\{(\w+)\}/g,function(i,u){return r[u]!=null?r[u]:i})}function $t(e){return e=String(e),/^[A-Z0-9]{2}/.test(e)?e:e.charAt(0).toLowerCase()+e.slice(1)}function ae(e){return typeof e=="number"?e:e==null||e===""?NaN:+e}function dt(e,r,i){var u=document.createElementNS(kt,e);if(r)for(var c in r)r[c]!=null&&u.setAttribute(c,r[c]);return i&&i.appendChild(u),u}function I(e,r,i){var u=document.createElement(e);return r&&(u.className=r),i&&i.appendChild(u),u}var J=null;function et(e,r,i,u){if(!J){var c=document.createElement("canvas");J=c.getContext&&c.getContext("2d")}return J?(J.font=(i||400)+" "+r+"px "+u,J.measureText(String(e)).width):String(e).length*r*.6}function ht(e,r,i,u,c){if(e=String(e),et(e,i,u,c)<=r)return e;for(;e.length>2&&et(e+"\u2026",i,u,c)>r;)e=e.slice(0,-1);return e.replace(/\s+$/,"")+"\u2026"}function Ft(e){var r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(e||"").trim());if(!r)return null;var i=r[1].length===3?r[1].replace(/./g,"$&$&"):r[1],u=parseInt(i,16);return[u>>16&255,u>>8&255,u&255]}function yt(e){var r=e.map(function(i){return i/=255,i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Dt(e,r){var i=Ft(e),u=Ft(r);if(!i||!u)return 21;var c=yt(i),p=yt(u);return(Math.max(c,p)+.05)/(Math.min(c,p)+.05)}function it(e,r,i){var u=Ft(e),c=Ft(r);if(!u||!c||Dt(e,r)>=i)return e;for(var p=yt(c)>.4,_=0,t=e;_<=1&&Dt(t,r)<i;)_+=.05,t="#"+u.map(function(n){var a=p?n*(1-_):n+(255-n)*_;return("0"+Math.round(a).toString(16)).slice(-2)}).join("");return t}function xt(e,r){var i=e.decimals!=null?e.decimals:0,u=e.ratioDecimals!=null?e.ratioDecimals:1,c=e.prefix||"",p=e.suffix||"",_={},t=e.negatives==="brackets";function n(f){return _[f]||(_[f]=new Intl.NumberFormat(r||void 0,{minimumFractionDigits:f,maximumFractionDigits:f})),_[f]}function a(f,b){if(f==null||!isFinite(f))return"\u2013";b==null&&(b=i);var k=Number(f.toFixed(b)),y=c+n(b).format(Math.abs(k))+p;return k>=0?y:t?"("+y+")":"\u2212"+y}function l(f,b){var k=a(f,b);return f!=null&&Number(f.toFixed(b??i))>0?"+"+k:k}function o(f,b){return f==null||!isFinite(f)?"\u2013":(f<0?"\u2212":"")+n(b??u).format(Math.abs(f)*100)+"%"}function s(f,b){if(f==null||!isFinite(f))return"\u2013";var k=b??Math.max(u,1),y=Number((f*100).toFixed(k));return(y>0?"+":y<0?"\u2212":"")+n(k).format(Math.abs(y))+" pp"}function m(f,b){return f==null||!isFinite(f)?"\u2013":n(b??1).format(f*100)+"%"}return{value:a,signed:l,ratio:o,pp:s,percent:m,nf:n}}function ut(e,r){var i=ae(e);return isFinite(i)||V(r+" must be a number."),i}function vt(e,r){var i=ut(e,r);return(i<-1||i>1)&&V(r+" must be between \u22121 and 1."),i}function Zt(e,r,i){var u=e.factors;(!Array.isArray(u)||!u.length)&&V("data.factors must be a non-empty array of risk factors.");var c={};return u.map(function(p,_){(!p||typeof p!="object")&&V("data.factors["+_+"] is not an object."),p.key==null&&p.label==null&&V("data.factors["+_+"] needs a key or a label.");var t=String(p.key!=null?p.key:p.label),n='factor "'+t+'"';c[t]&&V(n+" is used twice."),c[t]=1;var a=p.group!=null?String(p.group):"Other",l=p.shockDown!=null?ut(p.shockDown,n+": shockDown"):p.shock!=null?-Math.abs(ut(p.shock,n+": shock")):null,o=p.shockUp!=null?ut(p.shockUp,n+": shockUp"):p.shock!=null?Math.abs(ut(p.shock,n+": shock")):null,s,m,f;if(p.delta!=null){var b=ut(p.delta,n+": delta"),k=p.gamma!=null?ut(p.gamma,n+": gamma"):0;(l==null||o==null)&&V(n+": delta needs shockDown and shockUp (or shock).");var y=l*r,x=o*r;s=b*y+.5*k*y*y,m=b*x+.5*k*x*x,f="taylor"}else{(p.down==null||p.up==null)&&V(n+" needs down and up impacts, or delta (and gamma) with a shock.");var M=ut(p.down,n+": down"),d=ut(p.up,n+": up");if(r===1)s=M,m=d;else{var T=(d-M)/2,C=(d+M)/2;s=-T*r+C*r*r,m=T*r+C*r*r}f="revaluation"}var R=1;return i&&(i[t]!=null&&(R*=ut(i[t],"whatIf."+t)),i[a]!=null&&a!==t&&(R*=ut(i[a],"whatIf."+a))),{key:t,label:p.label!=null?String(p.label):t,group:a,unit:p.unit!=null?String(p.unit):"",shockDown:l==null?null:l*r,shockUp:o==null?null:o*r,down:s*R,up:m*R,source:f,index:_}})}function Tt(e,r,i){var u=e.length,c=new Array(u),p,_;if(r&&r.matrix){var t=r.matrix;for(p=0;p<u;p++){var n=0,a=t[p];for(_=0;_<u;_++)n+=(p===_?1:a[_])*i[_];c[p]=n}return c}var l=r?r.within:0,o=r?r.across:0,s={},m=0;for(p=0;p<u;p++)s[e[p].group]=(s[e[p].group]||0)+i[p],m+=i[p];for(p=0;p<u;p++){var f=s[e[p].group];c[p]=i[p]+l*(f-i[p])+o*(m-f)}return c}function Jt(e,r){var i=e.correlation;if(i==null)return null;if(typeof i!="object"&&V("data.correlation must be { within, across } or { matrix }."),i.matrix){var u=i.matrix;return(!Array.isArray(u)||u.length!==r||u.some(function(c){return!Array.isArray(c)||c.length!==r}))&&V("data.correlation.matrix must be square with one row per factor."),u.forEach(function(c,p){c.forEach(function(_,t){vt(_,"data.correlation.matrix["+p+"]["+t+"]")})}),{matrix:u}}return{within:i.within!=null?vt(i.within,"data.correlation.within"):0,across:i.across!=null?vt(i.across,"data.correlation.across"):0}}function Ht(e,r){r=r||{},(!e||typeof e!="object")&&V("data is required.");var i=r.shockScale!=null?ut(r.shockScale,"shockScale"):1;i>0||V("shockScale must be more than 0.");var u=r.whatIf&&Object.keys(r.whatIf).length?r.whatIf:null,c=Zt(e,i,u),p=c.length;u&&Object.keys(u).forEach(function(S){c.some(function(A){return A.key===S||A.group===S})||ot('whatIf: there is no factor or group "'+S+'", so it changes nothing.')});var _=e.higherIsBetter!==!1,t=function(S){return _?-S:S},n=e.limit!=null?Math.abs(ut(e.limit,"data.limit")):null,a=Jt(e,p),l=c.map(function(S){return(S.up-S.down)/2}),o=Tt(c,a,l),s=0,m;for(m=0;m<p;m++)s+=l[m]*o[m];var f=Math.sqrt(Math.max(0,s)),b=0,k=0,y=0,x=0;c.forEach(function(S,A){S.swing=Math.abs(S.up-S.down),S.linear=l[A],S.convexity=(S.up+S.down)/2,S.asymmetry=Math.abs(S.linear)+Math.abs(S.convexity)>0?Math.abs(S.convexity)/(Math.abs(S.linear)+Math.abs(S.convexity)):0,S.worst=t(S.down)>=t(S.up)?"down":"up",S.worstValue=S[S.worst],S.best=S.worst==="down"?"up":"down",S.breach=n!=null&&t(S.worstValue)>n+1e-12*Math.max(1,n),S.standalone=Math.abs(l[A]),S.contribution=f>0?l[A]*o[A]/f:0,b+=S.swing,k+=S.down,y+=S.up,x+=S.standalone});var M=c.slice().sort(r.sort==="worst"?function(S,A){return t(A.worstValue)-t(S.worstValue)||S.index-A.index}:function(S,A){return A.swing-S.swing||S.index-A.index}),d=0;M.forEach(function(S,A){S.rank=A+1,S.share=b>0?S.swing/b:0,d+=S.share,S.cumShare=d});var T={},C=[];c.forEach(function(S,A){var H=T[S.group];H||(H=T[S.group]={key:S.group,label:S.group,factors:[],idx:[],down:0,up:0,contribution:0,standaloneSum:0},C.push(H)),H.factors.push(S.key),H.idx.push(A),H.down+=S.down,H.up+=S.up,H.contribution+=S.contribution,H.standaloneSum+=S.standalone}),C.forEach(function(S){S.swing=Math.abs(S.up-S.down),S.linear=(S.up-S.down)/2,S.convexity=(S.up+S.down)/2,S.worst=t(S.down)>=t(S.up)?"down":"up",S.worstValue=S[S.worst],S.breach=n!=null&&t(S.worstValue)>n+1e-12*Math.max(1,n),S.share=b>0?S.swing/b:0;for(var A=S.idx.map(function(q){return c[q]}),H=S.idx.map(function(q){return l[q]}),lt=a&&a.matrix?{matrix:S.idx.map(function(q){return S.idx.map(function(X){return a.matrix[q][X]})})}:a,tt=Tt(A,lt,H),D=0,K=0;K<H.length;K++)D+=H[K]*tt[K];S.standalone=Math.sqrt(Math.max(0,D)),delete S.idx});var R=p>=10?5:Math.max(1,Math.ceil(p/2)),O=M.slice(0,R).reduce(function(S,A){return S+A.share},0),j={factors:c,order:M,groups:C,higherIsBetter:_,limit:n,base:e.base!=null?ut(e.base,"data.base"):null,totalSwing:b,sumDown:k,sumUp:y,sigma:f,standalone:x,diversification:x-f,correlated:!!a,topN:R,topShare:O,breaches:c.filter(function(S){return S.breach}).length,shockScale:i,whatIf:u};if(j.worstFactor=c.slice().sort(function(S,A){return t(A.worstValue)-t(S.worstValue)||S.index-A.index})[0],e.joint&&(e.joint.down!=null||e.joint.up!=null)&&(i===1&&!u?(j.joint={down:e.joint.down!=null?ut(e.joint.down,"data.joint.down"):null,up:e.joint.up!=null?ut(e.joint.up,"data.joint.up"):null},j.interaction={down:j.joint.down!=null?j.joint.down-k:null,up:j.joint.up!=null?j.joint.up-y:null}):j.jointHidden=!0),u){var E=Ht(e,{shockScale:i,sort:r.sort});j.baseline={totalSwing:E.totalSwing,sigma:E.sigma,worstValue:E.worstFactor.worstValue,worstFactor:E.worstFactor.key}}return j}function te(){if(!document.getElementById("vtr-styles")){var e=".vtr{position:relative;color:var(--vtr-text);background:var(--vtr-bg);font-family:var(--vtr-font);line-height:1.4}.vtr.vtr-filled{padding:14px 14px 8px;border-radius:10px}.vtr-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:0 0 10px}.vtr-stat{background:var(--vtr-card);border-radius:8px;padding:9px 12px;min-width:0}.vtr-stat .k{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vtr-card-muted);font-weight:600;overflow-wrap:anywhere;hyphens:auto}.vtr-stat .v{font-size:19px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vtr-stat .n{font-size:12px;color:var(--vtr-card-muted)}.vtr-stat .v.vtr-wrap{white-space:normal;overflow-wrap:anywhere;line-height:1.2;font-size:17px}.vtr-scope{font-size:12px;color:var(--vtr-muted);margin:0 0 4px}.vtr-legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;margin:0 0 6px;color:var(--vtr-text)}.vtr-legend span{display:inline-flex;align-items:center;gap:6px}.vtr-legend i{display:inline-block;width:12px;height:12px;border-radius:3px}.vtr-legend i.vtr-tick{width:3px;height:14px;border-radius:1px}.vtr-legend i.vtr-ring{background:transparent!important;border:2px solid;border-radius:2px;width:9px;height:9px;transform:rotate(45deg)}.vtr-plot{display:block;width:100%;height:auto;overflow:visible;outline:none}.vtr-plot:focus-visible{outline:2px solid var(--vtr-focus);outline-offset:4px;border-radius:4px}.vtr-animate .vtr-grow{animation:vtr-fade .45s ease both}@keyframes vtr-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vtr-animate .vtr-grow{animation:none}}.vtr-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vtr-tip-bg);color:var(--vtr-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}.vtr-tip.vtr-on{opacity:1;transform:none}.vtr-tip b{font-weight:600}.vtr-table{border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums;margin:0 0 14px;min-width:100%}.vtr-table caption{text-align:left;font-weight:700;padding:0 0 6px}.vtr-table th,.vtr-table td{padding:5px 8px;border-bottom:1px solid rgba(127,127,127,.25);text-align:right;white-space:nowrap}.vtr-table th:first-child,.vtr-table td:first-child{text-align:left}.vtr-table tr.vtr-breach td{color:var(--vtr-hedge);font-weight:600}@media (max-width:420px){.vtr-summary{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))}.vtr-stat{padding:8px 10px}.vtr-stat .v{font-size:17px}}",r=I("style");r.id="vtr-styles",r.textContent=e,(document.head||document.documentElement).appendChild(r)}}function Vt(e){var r;(e==null||e==="")&&(e="veyforma"),typeof e=="string"?(Mt.hasOwnProperty(e)||(ot('Unknown theme "'+e+'". The "veyforma" theme is used instead.'),e="veyforma"),r=wt({},_t,Mt[e])):typeof e=="object"?(r=wt(e.extends?Vt(e.extends):wt({},_t),e),delete r.extends):(ot("The theme option must be a theme name or an object."),r=wt({},_t));var i=/^#/.test(r.background)?r.background:"#ffffff",u=/^#/.test(r.cardBackground)?r.cardBackground:i;return["axisText","mutedText"].forEach(function(c){r[c]=it(r[c],i,4.5)}),r.cardMuted=it(r.mutedText,u,4.5),r.hedgeText=it(it(r.hedge,i,4.5),u,4.5),r.limitText=it(it(r.limit,i,4.5),u,4.5),r.accentText=it(r.accent,i,4.5),r}function W(e,r){var i=typeof e=="string"?document.querySelector(e):e;(!i||i.nodeType!==1)&&V("container not found ("+e+")."),(!r||!r.data)&&V("options.data is required."),te(),this.id=++St,this.container=i,this.options=wt({},At,r),this.element=I("div","vtr"),this.element.setAttribute("role","figure"),this.summaryEl=I("div","vtr-summary",this.element),this.scopeEl=I("p","vtr-scope",this.element),this.legendEl=I("div","vtr-legend",this.element),this.plotHost=I("div","vtr-plot-host",this.element),this.tipEl=I("div","vtr-tip",this.element),this.tipEl.setAttribute("role","tooltip"),i.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=-1;var u=this;Y.ResizeObserver?(this._observer=new Y.ResizeObserver(function(){var c=Math.round(u.element.clientWidth);c&&Math.abs(c-u._lastWidth)>1&&u.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){u.redraw()},Y.addEventListener("resize",this._onResize)),this._onDocTap=function(c){u.element.contains(c.target)||u._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&Y.VeyformaToolkit&&(this.toolkit=Y.VeyformaToolkit.attach(this,this.options.toolbar))}W.prototype.update=function(e){return e?(e.data&&e.data!==this.options.data&&this.options.animate&&(this._animateNext=!0),e.view&&e.view!==this.options.view&&this.options.animate&&(this._animateNext=!0),wt(this.options,e),this.redraw()):this},W.prototype.setData=function(e){return this._res=null,this.update({data:e})},W.prototype.setView=function(e){return this.update({view:e})},W.prototype.setTheme=function(e){return this.update({theme:e})},W.prototype.getTheme=function(){return Vt(this.options.theme)},W.prototype._opts=function(){return{shockScale:this.options.shockScale,whatIf:this.options.whatIf,sort:this.options.sort}},W.prototype.getResult=function(){return Ht(this.options.data,this._opts())},W.prototype.getFactor=function(e){return this.getResult().factors.filter(function(r){return r.key===String(e)})[0]||null},W.prototype.setWhatIf=function(e){return this.update({whatIf:e})},W.prototype.setShockScale=function(e){return this.update({shockScale:e})},W.prototype._labels=function(){return wt({},ft,this.options.labels)},W.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&Y.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},W.prototype._hideTip=function(){this.tipEl.classList.remove("vtr-on"),this._hlEl&&this._hlEl.setAttribute("opacity",0)},W.prototype._placeTip=function(e,r,i){var u=this.tipEl;u.textContent="",e.forEach(function(l,o){o&&u.appendChild(document.createElement("br"));var s=o===0?document.createElement("b"):document.createElement("span");s.textContent=l,u.appendChild(s)});var c=this.element.getBoundingClientRect(),p=i&&i.clientX?i.clientX:r.left+r.width/2,_=i&&i.clientY?i.clientY:r.top+10;u.classList.add("vtr-on");var t=u.offsetWidth,n=u.offsetHeight;u.style.left=pt(p-c.left-t/2,4,Math.max(4,c.width-t-4))+"px";var a=_-c.top-n-14;a<0&&(a=_-c.top+18),u.style.top=a+"px"};function It(e,r,i){r>e||(r=e+1);var u=r-e,c=Math.pow(10,Math.floor(Math.log(u/i)/Math.LN10)),p=u/i/c;p>=7.5?c*=10:p>=3.5?c*=5:p>=1.5&&(c*=2);for(var _=Math.floor(e/c+1e-9)*c,t=Math.ceil(r/c-1e-9)*c,n=[],a=_;a<=t+c/2;a+=c)n.push(Math.round(a/c)*c);return{lo:_,hi:t,ticks:n,step:c}}function h(e,r,i,u,c){var p=dt("text",wt({x:r,y:i},c||{}),e);return p.textContent=u,p}W.prototype._bindInteraction=function(e,r,i,u,c,p){var _=this,t=this._items,n=this.options;function a(o){for(var s=e.getBoundingClientRect(),m=(o.clientX-s.left)*(r/s.width),f=(o.clientY-s.top)*(i/s.height),b=0;b<t.length;b++){var k=t[b];if(m>=k.x&&m<=k.x+k.w&&f>=k.y&&f<=k.y+k.h)return b}return-1}function l(o,s){if(o<0){_._hideTip();return}_._active=o;var m=t[o],f=_._hlEl;f.setAttribute("x",m.x-4),f.setAttribute("y",m.y),f.setAttribute("width",m.w+8),f.setAttribute("height",m.h),f.setAttribute("opacity",1);var b=e.getBoundingClientRect(),k=b.width/r,y={left:b.left+m.px*k,top:b.top+m.py*(b.height/i),width:0,height:0};_._placeTip(_._tipLines(m),y,s&&s.clientX?s:null)}e.addEventListener("pointermove",function(o){l(a(o),o)}),e.addEventListener("pointerleave",function(){_._hideTip()}),e.addEventListener("click",function(o){var s=a(o);s>=0&&typeof n.onItemClick=="function"&&n.onItemClick(_._detail(t[s]),o)}),e.addEventListener("keydown",function(o){var s=_._active;if(o.key==="ArrowRight"||o.key==="ArrowDown")s=Math.min(t.length-1,s+1);else if(o.key==="ArrowLeft"||o.key==="ArrowUp")s=Math.max(0,s<0?0:s-1);else if(o.key==="Home")s=0;else if(o.key==="End")s=t.length-1;else if(o.key==="Escape"){_._hideTip();return}else if((o.key==="Enter"||o.key===" ")&&s>=0){typeof n.onItemClick=="function"&&n.onItemClick(_._detail(t[s]),o),o.preventDefault();return}else return;o.preventDefault(),l(s,null)}),e.addEventListener("blur",function(){_._hideTip()})},W.prototype.createTable=function(){var e=this.getExportData(),r=I("div","vtr-tables");return e.sheets.forEach(function(i){if(i.name!=="Notes"){var u=I("table","vtr-table",r);I("caption",null,u).textContent=i.name;var c=I("tr",null,I("thead",null,u));i.columns.forEach(function(_){var t=I("th",null,c);t.scope="col",t.textContent=_.label});var p=I("tbody",null,u);i.text.forEach(function(_,t){var n=I("tr",i.flag&&i.flag[t]?"vtr-breach":null,p);_.forEach(function(a,l){var o=I(l?"td":"th",null,n);l||(o.scope="row"),o.textContent=a})})}}),r};function w(e,r,i){if(e==null||!isFinite(e))return"";var u=Number(Math.abs(e).toFixed(4)).toLocaleString(i||void 0,{maximumFractionDigits:4});return(e>0?"+":e<0?"\u2212":"")+u+(r?r==="%"?"%":" "+r:"")}W.prototype.redraw=function(){var e=this.options,r=e.data,i=this._labels(),u=this._res=Ht(r,this._opts()),c=Vt(e.theme),p=xt(r,e.locale),_=this.element,t=_.style,n=c.fontFamily==="inherit"?Y.getComputedStyle?Y.getComputedStyle(this.container).fontFamily:"sans-serif":c.fontFamily,a=c.background&&c.background!=="transparent",l=a?c.background:"#ffffff";t.setProperty("--vtr-text",c.text),t.setProperty("--vtr-muted",c.mutedText),t.setProperty("--vtr-bg",a?c.background:"transparent"),t.setProperty("--vtr-font",n),t.setProperty("--vtr-card",c.cardBackground),t.setProperty("--vtr-card-muted",c.cardMuted),t.setProperty("--vtr-tip-bg",c.tooltipBackground),t.setProperty("--vtr-tip-text",c.tooltipText),t.setProperty("--vtr-focus",c.focus),t.setProperty("--vtr-hedge",c.limitText),_.classList.toggle("vtr-filled",!!a),_.setAttribute("aria-label",e.ariaLabel||r.title||"Risk-factor tornado");var o=e.view;["factors","groups","contribution"].indexOf(o)<0&&(ot('Unknown view "'+o+'". The factor view is shown instead.'),o="factors"),e.sort!=="swing"&&e.sort!=="worst"&&ot('Unknown sort "'+e.sort+'". Factors are ranked by swing instead.'),this._view=o,this._renderSummary(u,p,i);var s=[i[o],e.shockScale!=null&&+e.shockScale!=1?"shocks \xD7"+ +e.shockScale:null,r.unit||null,u.whatIf?i.whatIf+" applied":null].filter(Boolean).join(" \xB7 ");this.scopeEl.textContent=s,this._renderLegend(o,c,i,u);var m=Math.max(280,Math.round(this.plotHost.clientWidth||_.clientWidth||720));this._lastWidth=Math.round(_.clientWidth);var f=c.fontSize||12;this.plotHost.textContent="";var b=dt("svg",{class:"vtr-plot",role:"img",tabindex:0,"font-family":n},this.plotHost);b.style.fontSize=f+"px";var k=this._animateNext&&e.animate;this._animateNext=!1,k&&b.classList.add("vtr-animate");var y={svg:b,W:m,fs:f,theme:c,f:p,L:i,family:n,bg:l,res:u,items:[],points:{}},x=o==="contribution"?this._drawContribution(y):this._drawRows(y,o);return b.setAttribute("viewBox","0 0 "+m+" "+x),b.setAttribute("width",m),b.setAttribute("height",x),b.setAttribute("aria-label",(e.ariaLabel||r.title||"Risk-factor tornado")+". "+this.describe()),this._items=y.items,this._points=y.points,this._hlEl=dt("rect",{x:0,y:0,width:0,height:0,rx:4,fill:c.text,"fill-opacity":.06,opacity:0,"pointer-events":"none"},b),b.insertBefore(this._hlEl,b.firstChild),this._bindInteraction(b,m,x,c,i,p),this},W.prototype._shockNames=function(){var e=this._labels(),r=this.options.data.shockLabels||{};return{down:r.down||e.down,up:r.up||e.up}},W.prototype._renderSummary=function(e,r,i){var u=this.summaryEl,c=this.options;if(u.textContent="",u.style.display=c.summary===!1?"none":"",c.summary===!1)return;function p(a,l,o,s){var m=I("div","vtr-stat",u);I("div","k",m).textContent=a,I("div",s?"v vtr-wrap":"v",m).textContent=l,o&&(I("div","n",m).textContent=o)}var _=this._shockNames(),t=e.order[0],n=e.worstFactor;p(i.largest,t.label,i.swing.toLowerCase()+" "+r.value(t.swing)+" \xB7 "+r.percent(t.share,0)+" of the total",!0),p(i.worstShock,r.signed(n.worstValue),n.label+", "+_[n.worst].toLowerCase()+(e.limit!=null?e.breaches?" \xB7 "+e.breaches+" beyond the limit":" \xB7 within the limit":"")+(e.baseline?" \xB7 was "+r.signed(e.baseline.worstValue):"")),p(Rt(i.topShare,{n:e.topN}),r.percent(e.topShare,0),"of the total swing across "+e.factors.length+" factors"),p(i.combined,"\xB1"+r.value(e.sigma),e.baseline?i.whatIf+": was \xB1"+r.value(e.baseline.sigma):e.correlated?e.standalone>0?r.percent(e.diversification/e.standalone,0)+" below the sum of stand-alone moves":"":"factors treated as independent"),Array.prototype.forEach.call(u.querySelectorAll(".vtr-stat .v"),function(a){a.style.fontSize="";for(var l=parseFloat(Y.getComputedStyle?Y.getComputedStyle(a).fontSize:19)||19;a.scrollWidth>a.clientWidth&&l>12;)l-=1,a.style.fontSize=l+"px"})},W.prototype._renderLegend=function(e,r,i,u){var c=this.legendEl,p=this._shockNames();c.textContent="",c.style.display=this.options.legend===!1?"none":"";function _(t,n,a){var l=I("span",null,c),o=I("i",a||null,l);a==="vtr-ring"?o.style.borderColor=t:o.style.background=t,l.appendChild(document.createTextNode(n))}if(e==="contribution"){_(r.contribution,i.contributionAdds),_(r.hedge,i.hedge),_(r.convexity,i.standalone,"vtr-ring");return}_(r.down,p.down),_(r.up,p.up),u.factors.some(function(t){return t.asymmetry>=.1})&&_(r.convexity,i.convexity+" (midpoint)","vtr-ring"),u.limit!=null&&_(r.limit,i.limit,"vtr-tick")};function g(e,r){var i=Math.min(Math.max.apply(null,r.map(function(c){return et(c,e.fs,600,e.family)}))+12,e.W*.34),u=e.W-i<260;return{nameW:u?0:i,narrow:u}}function v(e,r,i,u,c,p,_,t,n){var a=e.theme,l=e.fs,o=e.family,s=e.W,m=e.f,f=-1/0,b=Math.max.apply(null,i.ticks.map(function(y){return et(m.value(y),l-1,400,o)})),k=Math.max(1,Math.ceil((b+10)/((_-p)/Math.max(1,i.ticks.length-1))));i.ticks.forEach(function(y,x){if(dt("line",{x1:u(y),x2:u(y),y1:t,y2:n,stroke:y===0?a.axis:a.grid,"stroke-width":y===0?1.2:1},r),!(x%k)){var M=m.value(y),d=et(M,l-1,400,o),T=d/2,C=u(y),R=C-T<0?"start":C+T>s?"end":"middle",O=R==="start"?C:R==="end"?C-d:C-T;O<f+8||(f=O+d,h(r,C,c+l,M,{"text-anchor":R,fill:a.axisText,"font-size":l-1,class:"vtr-tick"}))}})}W.prototype._rowsFor=function(e,r,i){if(r==="groups")return e.groups.slice().sort(function(a,l){return l.swing-a.swing}).map(function(a){return{kind:"group",obj:a,name:a.label,down:a.down,up:a.up,breach:a.breach,convexity:a.convexity,asym:Math.abs(a.linear)+Math.abs(a.convexity)>0?Math.abs(a.convexity)/(Math.abs(a.linear)+Math.abs(a.convexity)):0}});var u=+this.options.top>0?Math.floor(+this.options.top):e.order.length,c=e.order.slice(0,u).map(function(a){return{kind:"factor",obj:a,name:a.rank+". "+a.label,down:a.down,up:a.up,breach:a.breach,convexity:a.convexity,asym:a.asymmetry}}),p=e.order.slice(u);if(p.length){var _=0,t=0,n=0;p.forEach(function(a){_+=a.down,t+=a.up,n+=a.swing}),c.push({kind:"other",obj:{count:p.length,down:_,up:t,swing:n,share:e.totalSwing>0?n/e.totalSwing:0,factors:p},name:Rt(i.other,{n:p.length}),down:_,up:t,breach:!1,convexity:(_+t)/2,asym:0})}return c},W.prototype._drawRows=function(e,r){var i=e.res,u=e.theme,c=e.f,p=e.L,_=e.fs,t=e.family,n=e.W,a=e.svg,l=i.higherIsBetter,o=this._rowsFor(i,r,p),s=g(e,o.map(function(F){return F.name})),m=i.limit!=null?l?-i.limit:i.limit:null,f=[];o.forEach(function(F){f.push(F.down,F.up)});var b=Math.min.apply(null,f.concat([0,m??0])),k=Math.max.apply(null,f.concat([0,m??0])),y=function(F){return et(c.signed(F),_-1,600,t)+6},x=Math.max.apply(null,[4].concat(f.filter(function(F){return F<0}).map(y))),M=Math.max.apply(null,[4].concat(f.filter(function(F){return F>=0}).map(y))),d=s.nameW+x,T=n-M,C=It(b,k,Math.max(2,Math.min(6,Math.floor((T-d)/90)))),R=function(F){return d+(pt(F,C.lo,C.hi)-C.lo)/(C.hi-C.lo)*(T-d)},O=4,j=Math.max(36,_*3),E=s.narrow?_+4:0,S=O+_+6,A=S+o.length*(j+E),H=dt("g",{class:"vtr-rows"},a);v(e,H,C,R,O,d,T,S,A);var lt=dt("g",null,H),tt=dt("g",{class:"vtr-cvx-layer"},H),D=dt("g",null,H);m!=null&&dt("line",{x1:R(m),x2:R(m),y1:S-2,y2:A,stroke:u.limit,"stroke-width":1.6,"stroke-dasharray":"5 3",class:"vtr-limit"},tt);var K=this._shockNames(),q=this;o.forEach(function(F,B){var U=S+B*(j+E)+E,nt=Math.max(j*.32,_),st=U+(j-2*nt-3)/2,at=F.breach?u.limitText:F.kind==="other"?u.mutedText:u.text,zt=ht(F.name,s.narrow?n:s.nameW-8,_,F.kind==="other"?400:600,t);if(s.narrow&&dt("rect",{x:0,y:U-3-_*.95,width:et(zt,_,600,t)+4,height:_*1.25,fill:e.bg,class:"vtr-lbg"},D),h(D,0,s.narrow?U-3:U+j/2+_*.35,ht(F.name,s.narrow?n:s.nameW-8,_,F.kind==="other"?400:600,t),{fill:at,"font-size":_,"font-weight":F.kind==="other"?400:600,class:"vtr-name"}),[["down",st],["up",st+nt+3]].forEach(function(jt){var rt=F[jt[0]],Wt=R(Math.min(0,rt)),Kt=R(Math.max(0,rt)),ee=F.kind!=="other"&&F.obj.worst===jt[0];dt("rect",{x:Wt,y:jt[1],width:Math.max(.8,Kt-Wt),height:nt,rx:2,fill:u[jt[0]],class:"vtr-grow vtr-bar","data-shock":jt[0]},lt);var ne=F.breach&&ee,oe=c.signed(rt),Xt=et(oe,_-1,ne?700:400,t),ce=rt<0?Wt-4-Xt:Kt+4;dt("rect",{x:ce-2,y:jt[1]+nt/2-(_-1)*.6,width:Xt+4,height:(_-1)*1.2,fill:e.bg,class:"vtr-lbg"},D),h(D,rt<0?Wt-4:Kt+4,jt[1]+nt/2+(_-1)*.35,c.signed(rt),{"text-anchor":rt<0?"end":"start",fill:ne?u.limitText:u.text,"font-size":_-1,"font-weight":ne?700:400,class:"vtr-val"})}),F.asym>=.1){var mt=R(F.convexity),gt=st+nt+1.5;dt("path",{d:"M"+mt+","+(gt-4)+"L"+(mt+4)+","+gt+"L"+mt+","+(gt+4)+"L"+(mt-4)+","+gt+"Z",fill:e.bg,stroke:u.convexity,"stroke-width":1.5,class:"vtr-cvx"},tt)}var Et=R(Math.max(0,F.down,F.up));F.kind==="factor"&&(e.points[F.obj.key]={x:Et,y:st}),F.kind==="group"&&(e.points["group:"+F.obj.key]={x:Et,y:st}),e.items.push({kind:F.kind,obj:F.obj,x:0,y:U-E,w:n,h:j+E,px:Et,py:st})}),r==="groups"&&i.factors.forEach(function(F){e.points[F.key]||(e.points[F.key]=e.points["group:"+F.group])});var X=[];if(m!=null&&X.push(p.limit+" "+c.signed(m)+(i.breaches?": "+i.breaches+" factor"+(i.breaches>1?"s":"")+" beyond it":": no factor beyond it")),r==="factors"){var Q=o.filter(function(F){return F.kind==="factor"}).length;if(X.push("Each factor shocked alone"+(Q<i.factors.length?"; top "+Q+" of "+i.factors.length+", the rest summed":"")),i.interaction){var Z=i.interaction,P=[];Z.down!=null&&P.push(K.down.toLowerCase()+" together "+c.signed(i.joint.down)+" vs sum "+c.signed(i.sumDown)),Z.up!=null&&P.push(K.up.toLowerCase()+" together "+c.signed(i.joint.up)+" vs sum "+c.signed(i.sumUp)),X.push("All factors "+P.join(", "))}}else X.push("Every factor in the group shocked the same way at once (sum of single shocks)");var N=A+_+8;return X.forEach(function(F){h(a,0,N,ht(F+".",n,_-1,400,t),{fill:u.mutedText,"font-size":_-1,class:"vtr-note"}),N+=_+3}),Math.ceil(N-_+6)},W.prototype._drawContribution=function(e){var r=e.res,i=e.theme,u=e.f,c=e.L,p=e.fs,_=e.family,t=e.W,n=e.svg,a=r.factors.slice().sort(function(D,K){return Math.abs(K.contribution)-Math.abs(D.contribution)||D.index-K.index}),l=+this.options.top>0?Math.floor(+this.options.top):a.length,o=a.slice(l),s=a.slice(0,l).sort(function(D,K){return K.contribution-D.contribution}).map(function(D){return{kind:"factor",obj:D,name:D.label,v:D.contribution,k:D.standalone}});if(o.length){var m=0,f=0;o.forEach(function(D){m+=D.contribution,f+=D.standalone}),s.push({kind:"other",obj:{count:o.length,contribution:m,standalone:f,factors:o},name:Rt(c.other,{n:o.length}),v:m,k:null})}var b=g(e,s.map(function(D){return D.name})),k=Math.max.apply(null,s.map(function(D){return et(u.signed(D.v),p,700,_)}))+10,y=b.nameW,x=t-k,M=Math.max(24,p*2),d=b.narrow?p+4:0,T=4,C=Math.min(0,Math.min.apply(null,s.map(function(D){return D.v}))),R=Math.max.apply(null,s.map(function(D){return Math.max(D.v,D.k||0)}))||1,O=It(C,R,Math.max(2,Math.min(6,Math.floor((x-y)/90)))),j=function(D){return y+(pt(D,O.lo,O.hi)-O.lo)/(O.hi-O.lo)*(x-y)},E=T+p+6,S=E+s.length*(M+d),A=dt("g",{class:"vtr-contrib"},n);v(e,A,O,j,T,y,x,E,S),s.forEach(function(D,K){var q=E+K*(M+d)+d,X=M*.56,Q=q+(M-X)/2,Z=D.v<0;h(A,0,b.narrow?q-3:Q+X/2+p*.35,ht(D.name,b.narrow?t-k:b.nameW-8,p,D.kind==="other"?400:600,_),{fill:D.kind==="other"?i.mutedText:i.text,"font-size":p,"font-weight":D.kind==="other"?400:600,class:"vtr-name"});var P=j(Math.min(0,D.v)),N=j(Math.max(0,D.v));if(dt("rect",{x:P,y:Q,width:Math.max(.8,N-P),height:X,rx:2,fill:Z?i.hedge:i.contribution,class:"vtr-grow vtr-cbar"+(Z?" vtr-hedge":"")},A),D.k!=null){var F=j(D.k),B=Q+X/2;dt("path",{d:"M"+F+","+(B-5)+"L"+(F+5)+","+B+"L"+F+","+(B+5)+"L"+(F-5)+","+B+"Z",fill:e.bg,stroke:i.convexity,"stroke-width":1.6,class:"vtr-sa"},A)}h(A,t,Q+X/2+p*.35,u.signed(D.v),{"text-anchor":"end",fill:Z?i.hedgeText:i.text,"font-size":p,"font-weight":700,class:"vtr-val"}),D.kind==="factor"&&(e.points[D.obj.key]={x:Z?P:N,y:Q}),e.items.push({kind:D.kind,obj:D.obj,contrib:!0,x:0,y:q-d,w:t,h:M+d,px:Z?P:N,py:Q})});var H=r.correlated?this.options.data.correlation.matrix?"with the correlation matrix given":"with correlations of "+u.percent(this.options.data.correlation.within||0,0)+" within groups and "+u.percent(this.options.data.correlation.across||0,0)+" across":"no correlations given, so factors are treated as independent and none can hedge another",lt=["Shares add up to the combined move of \xB1"+u.value(r.sigma)+"; stand-alone moves add up to "+u.value(r.standalone),"Combined "+H],tt=S+p+8;return lt.forEach(function(D){h(n,0,tt,ht(D+".",t,p-1,400,_),{fill:i.mutedText,"font-size":p-1,class:"vtr-note"}),tt+=p+3}),Math.ceil(tt-p+6)},W.prototype._tipLines=function(e){var r=this.options,i=xt(r.data,r.locale),u=this._labels(),c=this._res,p=this._shockNames(),_=r.locale,t=function(s){return c.base!=null?" \u2192 "+i.value(c.base+s):""};if(e.kind==="other"){var n=e.obj;return e.contrib?[Rt(u.other,{n:n.count}),"Shares together "+i.signed(n.contribution)]:[Rt(u.other,{n:n.count}),p.down+" (sum) "+i.signed(n.down),p.up+" (sum) "+i.signed(n.up),u.swing+" together "+i.value(n.swing)+" ("+i.percent(n.share,0)+" of the total)"]}if(e.kind==="group"){var a=e.obj;return[a.label+" \xB7 "+a.factors.length+" factor"+(a.factors.length>1?"s":""),p.down+" "+i.signed(a.down)+t(a.down),p.up+" "+i.signed(a.up)+t(a.up),u.swing+" "+i.value(a.swing)+" ("+i.percent(a.share,0)+" of the total)","Combined move of the group \xB1"+i.value(a.standalone)+" \xB7 share of the total \xB1"+i.value(c.sigma)+": "+i.signed(a.contribution)].concat(a.breach?[u.worst+" beyond the limit"]:[])}var l=e.obj,o=[l.label,l.group+" \xB7 rank "+l.rank+" of "+c.factors.length,p.down+(l.shockDown!=null?" ("+w(l.shockDown,l.unit,_)+")":"")+" "+i.signed(l.down)+t(l.down),p.up+(l.shockUp!=null?" ("+w(l.shockUp,l.unit,_)+")":"")+" "+i.signed(l.up)+t(l.up),u.swing+" "+i.value(l.swing)+" \xB7 "+i.percent(l.share,0)+" of the total (top "+l.rank+": "+i.percent(l.cumShare,0)+")",u.linear+" \xB1"+i.value(Math.abs(l.linear))+" \xB7 "+u.convexity.toLowerCase()+" "+i.signed(l.convexity),"Share of the combined move "+i.signed(l.contribution)+" (stand-alone "+i.value(l.standalone)+")"];return l.breach&&o.push(p[l.worst]+" is beyond the limit of "+i.value(c.limit)),o},W.prototype._detail=function(e){if(!e)return null;var r=this._view;if(e.kind==="other")return{view:r,kind:"other",count:e.obj.count,down:e.obj.down,up:e.obj.up,swing:e.obj.swing,contribution:e.obj.contribution,factors:e.obj.factors.map(function(c){return c.key})};if(e.kind==="group"){var i=e.obj;return{view:r,kind:"group",key:i.key,label:i.label,factors:i.factors.slice(),down:i.down,up:i.up,swing:i.swing,share:i.share,linear:i.linear,convexity:i.convexity,worst:i.worst,worstValue:i.worstValue,breach:i.breach,contribution:i.contribution,standalone:i.standalone}}var u=e.obj;return{view:r,kind:"factor",key:u.key,label:u.label,group:u.group,unit:u.unit,shockDown:u.shockDown,shockUp:u.shockUp,down:u.down,up:u.up,swing:u.swing,share:u.share,cumShare:u.cumShare,rank:u.rank,linear:u.linear,convexity:u.convexity,asymmetry:u.asymmetry,worst:u.worst,worstValue:u.worstValue,breach:u.breach,contribution:u.contribution,standalone:u.standalone,source:u.source}},W.prototype.howToRead=function(){var e=this._view||this.options.view;return e==="contribution"?"Each bar is one factor's share of the combined move when all factors move together with their correlations. Shares add up exactly to the combined move; a bar to the left means the factor hedges the others. The diamond marks the factor's move on its own, so the gap between the diamond and the bar is diversification.":e==="groups"?"Each row is one group of factors, such as a risk class, with every factor in it shocked down (upper bar) and up (lower bar) at the same time. Rows are sorted by swing, the distance between the two results.":"Each row is one risk factor, shocked down (upper bar) and up (lower bar) on its own while everything else stays put. Rows are ranked by swing, the distance between the two results, so the factors that matter most are at the top. A diamond marks the midpoint of the two results when they are clearly unequal (convexity)"+(this._res&&this._res.limit!=null?"; the dashed line is the loss limit.":".")},W.prototype.describe=function(){var e=this.options,r=xt(e.data,e.locale),i=this._labels(),u=this._res||Ht(e.data,this._opts()),c=this._shockNames(),p=[],_=u.order[0];p.push("The largest driver is "+_.label+": "+c.down.toLowerCase()+" gives "+r.signed(_.down)+" and "+c.up.toLowerCase()+" "+r.signed(_.up)+", a swing of "+r.value(_.swing)+" ("+r.percent(_.share,0)+" of the total swing)."),u.factors.length>u.topN&&p.push("The top "+u.topN+" of "+u.factors.length+" factors explain "+r.percent(u.topShare,0)+".");var t=u.worstFactor;p.push("The worst single shock is "+t.label+" "+c[t.worst].toLowerCase()+" at "+r.signed(t.worstValue)+(u.limit!=null?u.breaches?", beyond the limit of "+r.value(u.limit)+" ("+u.breaches+" factor"+(u.breaches>1?"s":"")+" in all)":", within the limit of "+r.value(u.limit):"")+".");var n=u.factors.filter(function(o){return o.asymmetry>=.25&&o.swing>0}).sort(function(o,s){return Math.abs(s.convexity)-Math.abs(o.convexity)});if(n.length&&p.push(n.length+" factor"+(n.length>1?"s are":" is")+" strongly asymmetric, led by "+n[0].label+" (convexity "+r.signed(n[0].convexity)+"), so a bigger shock would cost more than in proportion."),u.correlated){var a=u.factors.slice().sort(function(o,s){return s.contribution-o.contribution}),l=u.factors.filter(function(o){return o.contribution<0}).sort(function(o,s){return o.contribution-s.contribution});p.push("Moving together with their correlations, the factors give a combined move of \xB1"+r.value(u.sigma)+", "+r.percent(u.standalone>0?u.diversification/u.standalone:0,0)+" less than the sum of their stand-alone moves; "+a[0].label+" contributes most ("+r.signed(a[0].contribution)+")"+(l.length?" and "+l[0].label+" hedges the most ("+r.signed(l[0].contribution)+")":"")+".")}return u.interaction&&u.interaction.down!=null&&p.push("Shocked all at once, the down case gives "+r.signed(u.joint.down)+" against "+r.signed(u.sumDown)+" for the sum of single shocks, an interaction of "+r.signed(u.interaction.down)+"."),u.baseline&&p.push("The what-if changes the worst single shock from "+r.signed(u.baseline.worstValue)+" to "+r.signed(t.worstValue)+"."),p.join(" ")},W.prototype.getExportData=function(){var e=this.options,r=e.data,i=this._labels(),u=xt(r,e.locale),c=this._res||Ht(r,this._opts()),p=this._shockNames(),_=e.locale,t={prefix:r.prefix||"",suffix:r.suffix||"",decimals:r.decimals!=null?r.decimals:0,negatives:r.negatives},n=function(d){return{label:d,type:"number",unit:t}},a=function(d){return{label:d,type:"number",unit:{decimals:4}}},l=function(d){return{label:d,type:"percent",decimals:1}},o=function(d){return{label:d,type:"text"}},s=[],m=e.exportRows!=null?e.exportRows:2e4,f=c.order,b=f.length>m;b&&(f=f.slice(0,m));var k=f.map(function(d){return[d.rank,d.label,d.group,d.unit,d.shockDown,d.shockUp,d.down,d.up,d.swing,d.share,d.cumShare,d.linear,d.convexity,p[d.worst],d.worstValue,d.breach?"Yes":"No",d.contribution,d.standalone]});s.push({name:"Factors",columns:[{label:"Rank",type:"number",unit:{decimals:0}},o("Risk factor"),o("Group"),o("Shock unit"),a("Shock down"),a("Shock up"),n(p.down),n(p.up),n(i.swing),l("Share of total swing"),l("Cumulative share"),n(i.linear),n(i.convexity),o("Worst shock"),n(i.worst),o("Beyond limit"),n("Share of combined move"),n("Stand-alone move")],rows:k,text:f.map(function(d){return[String(d.rank),d.label,d.group,d.unit,w(d.shockDown,"",_)||"\u2013",w(d.shockUp,"",_)||"\u2013",u.signed(d.down),u.signed(d.up),u.value(d.swing),u.percent(d.share),u.percent(d.cumShare),u.signed(d.linear),u.signed(d.convexity),p[d.worst],u.signed(d.worstValue),d.breach?"Yes":"No",u.signed(d.contribution),u.value(d.standalone)]}),flag:f.map(function(d){return d.breach})}),s.push({name:"Groups",columns:[o("Group"),{label:"Factors",type:"number",unit:{decimals:0}},n(p.down+" (sum)"),n(p.up+" (sum)"),n(i.swing),l("Share of total swing"),n(i.worst),o("Beyond limit"),n("Share of combined move"),n("Group combined move")],rows:c.groups.map(function(d){return[d.label,d.factors.length,d.down,d.up,d.swing,d.share,d.worstValue,d.breach?"Yes":"No",d.contribution,d.standalone]}),text:c.groups.map(function(d){return[d.label,String(d.factors.length),u.signed(d.down),u.signed(d.up),u.value(d.swing),u.percent(d.share),u.signed(d.worstValue),d.breach?"Yes":"No",u.signed(d.contribution),u.value(d.standalone)]}),flag:c.groups.map(function(d){return d.breach})});var y=[["Total swing",c.totalSwing],["Sum of "+p.down.toLowerCase()+" impacts",c.sumDown],["Sum of "+p.up.toLowerCase()+" impacts",c.sumUp]];c.joint&&(c.joint.down!=null&&y.push(["All factors "+p.down.toLowerCase()+" together",c.joint.down],[i.interaction+" ("+p.down.toLowerCase()+")",c.interaction.down]),c.joint.up!=null&&y.push(["All factors "+p.up.toLowerCase()+" together",c.joint.up],[i.interaction+" ("+p.up.toLowerCase()+")",c.interaction.up])),y.push([i.combined+" (\xB1)",c.sigma],["Sum of stand-alone moves",c.standalone],["Diversification",c.diversification]),c.limit!=null&&y.push([i.limit,c.limit]),s.push({name:"Summary",columns:[o("Item"),n("Amount")],rows:y,text:y.map(function(d){return[d[0],/Sum|Interaction|together/.test(d[0])?u.signed(d[1]):u.value(d[1])]})});var x=(e.annotations||[]).map(function(d,T){return[String(T+1),d.factor!=null?String(d.factor):"Group: "+String(d.group||""),d.text||""]});x.length&&s.push({name:"Notes",columns:[o("No."),o("Factor or group"),o("Note")],rows:x});var M=r.correlation;return{title:r.title||"Risk-factor tornado",subtitle:r.subtitle||"",summary:this.describe(),library:"Veyforma Risk-Factor Tornado "+Ct,sheets:s,meta:[["Unit",r.unit],["As of",r.asOf],["Desk",r.desk],["Measure",c.higherIsBetter?"Higher is better (for example P&L)":"Lower is better (for example capital)"],["Ranking",e.sort==="worst"?"By worst result":"By swing"],["Shocks",p.down+" / "+p.up+(c.shockScale!==1?", scaled \xD7"+c.shockScale:"")],["What-if",c.whatIf?Object.keys(c.whatIf).map(function(d){return d+" \xD7 "+c.whatIf[d]}).join(", "):null],["Correlation",M?M.matrix?"Matrix given":"Within groups "+(M.within||0)+", across "+(M.across||0):"None given (independent factors)"],["Limit",c.limit!=null?u.value(c.limit)+" ("+c.breaches+" beyond)":null],["Method","Impact = given down/up result, or \u0394\xB7s + \xBD\u0393\xB7s\xB2; swing = |up \u2212 down|; linear part L = (up \u2212 down) \xF7 2, convexity C = (up + down) \xF7 2; a shock k times larger \u2248 L\xB7k + C\xB7k\xB2; combined move \u03C3 = \u221A(L\u1D40 \u03C1 L); factor share = L_k (\u03C1L)_k \xF7 \u03C3 (Euler allocation, adds up to \u03C3)"+(b?"; factor sheet limited to the "+m+" largest swings":"")],["Data source",r.source]]}},W.prototype._annotationPoint=function(e){var r=this._points||{};return e.factor!=null?r[String(e.factor)]||null:e.group!=null&&r["group:"+String(e.group)]||null},W.prototype._annotationTarget=function(e){var r=this._items||[],i=null;if(!e)i=r[this._active];else for(var u=this.plotHost.querySelector("svg"),c=u.getBoundingClientRect(),p=u.viewBox.baseVal,_=(e.clientX-c.left)*(p.width/c.width),t=(e.clientY-c.top)*(p.height/c.height),n=0;n<r.length;n++){var a=r[n];if(_>=a.x&&_<=a.x+a.w&&t>=a.y&&t<=a.y+a.h){i=a;break}}return!i||i.kind==="other"?null:i.kind==="group"?{group:i.obj.key}:{factor:i.obj.key}},W.prototype._annotationLabel=function(e){if(e.group!=null)return String(e.group);var r=(this._res||this.getResult()).factors.filter(function(i){return i.key===String(e.factor)})[0];return r?r.label:String(e.factor||"")},Y.VeyRiskTornado={version:Ct,create:function(e,r){return new W(e,r)},compute:function(e,r){return Ht(e,r)},listThemes:function(){return Object.keys(Mt)},getTheme:function(e){return Vt(e)},defaults:{options:At,labels:ft,theme:_t}}})(typeof window<"u"?window:void 0);(function(Y){"use strict";var Ct="1.0.0",kt="http://www.w3.org/2000/svg",St=0,_t={hpl:"#111827",rtpl:"#c2410c",unexplained:"#6b7280",contribution:"#a63d16",offset:"#2f6fed",standalone:"#111827",zones:{green:"#15803d",amber:"#b45309",red:"#b91c1c"},outside:"#d1d5db",grid:"#ececec",axis:"#9ca3af",text:"#111827",mutedText:"#4b5563",axisText:"#4b5563",cardBackground:"#f9fafb",background:"transparent",tooltipBackground:"#111827",tooltipText:"#ffffff",focus:"#c2410c",accent:"#c2410c",fontFamily:"inherit",fontSize:12},Mt={veyforma:{},mono:{hpl:"#111111",rtpl:"#6b6b6b",unexplained:"#8a8a8a",contribution:"#111111",offset:"#8a8a8a",zones:{green:"#111111",amber:"#4b4b4b",red:"#111111"},accent:"#111111",focus:"#111111"},"colour-safe":{hpl:"#1f2937",rtpl:"#d55e00",unexplained:"#6b7280",contribution:"#cc3311",offset:"#0072b2",zones:{green:"#007a5e",amber:"#a35c00",red:"#b2182b"},accent:"#0072b2"},ocean:{hpl:"#0c3b5e",rtpl:"#0e7490",contribution:"#0c3b5e",offset:"#c2410c",cardBackground:"#eef5f8",accent:"#0e7490"},forest:{hpl:"#22311a",rtpl:"#4d6b31",contribution:"#22311a",offset:"#2f6fed",cardBackground:"#f2f4ee",accent:"#4d6b31"},corporate:{hpl:"#1e293b",rtpl:"#1d4ed8",contribution:"#1e293b",offset:"#c2410c",cardBackground:"#f1f4f8",accent:"#1d4ed8"},midnight:{background:"#111418",hpl:"#f3f4f6",rtpl:"#f08a5d",unexplained:"#8b93a1",contribution:"#f08a5d",offset:"#93c5fd",standalone:"#f3f4f6",zones:{green:"#4ade80",amber:"#fbbf24",red:"#fb7185"},outside:"#374151",grid:"#252a31",axis:"#4b5563",text:"#f3f4f6",mutedText:"#a3abb8",axisText:"#a3abb8",cardBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd",accent:"#f08a5d"}},At={spearmanGreen:.8,spearmanRed:.7,ksGreen:.09,ksRed:.12},ft={data:null,view:"factors",window:250,fix:null,thresholds:null,top:15,pathSteps:5,theme:"veyforma",locale:void 0,animate:!0,summary:!0,legend:!0,labels:null,ariaLabel:void 0,caption:!0,annotations:null,onAnnotationsChange:null,onItemClick:null,exportDays:2e4,toolbar:!0},wt={factors:"Unexplained P&L by risk factor",daily:"HPL and RTPL by day",distribution:"Distribution of HPL and RTPL",hpl:"HPL (front office)",rtpl:"RTPL (risk model)",unexplained:"Unexplained (HPL \u2212 RTPL)",adds:"Adds to unexplained volatility",offsets:"Offsets other gaps",standalone:"Gap on its own",test:"PLA test",unexplainedCard:"Unexplained P&L",largest:"Largest driver",path:"Path to green",green:"Green",amber:"Amber",red:"Red",na:"n/a",other:"Other {n} factors",unattributed:"Unattributed",notModelled:"not in the risk model",ifFixed:"If fixed",outside:"Outside the test window"};function bt(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(a)for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(t[l]=a[l])}return t}var ot={};function V(t){ot[t]||(ot[t]=1,Y.console&&console.warn&&console.warn("VeyPlaAttribution: "+t))}function pt(t){throw new Error("VeyPlaAttribution: "+t)}function Rt(t,n,a){return Math.min(a,Math.max(n,t))}function $t(t,n){return String(t).replace(/\{(\w+)\}/g,function(a,l){return n[l]!=null?n[l]:a})}function ae(t){return t=String(t),/^[A-Z0-9]{2}/.test(t)?t:t.charAt(0).toLowerCase()+t.slice(1)}function dt(t){return typeof t=="number"?t:t==null||t===""?NaN:+t}function I(t,n,a){var l=document.createElementNS(kt,t);if(n)for(var o in n)n[o]!=null&&l.setAttribute(o,n[o]);return a&&a.appendChild(l),l}function J(t,n,a){var l=document.createElement(t);return n&&(l.className=n),a&&a.appendChild(l),l}var et=null;function ht(t,n,a,l){if(!et){var o=document.createElement("canvas");et=o.getContext&&o.getContext("2d")}return et?(et.font=(a||400)+" "+n+"px "+l,et.measureText(String(t)).width):String(t).length*n*.6}function Ft(t,n,a,l,o){if(t=String(t),ht(t,a,l,o)<=n)return t;for(;t.length>2&&ht(t+"\u2026",a,l,o)>n;)t=t.slice(0,-1);return t.replace(/\s+$/,"")+"\u2026"}function yt(t){var n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(t||"").trim());if(!n)return null;var a=n[1].length===3?n[1].replace(/./g,"$&$&"):n[1],l=parseInt(a,16);return[l>>16&255,l>>8&255,l&255]}function Dt(t){var n=t.map(function(a){return a/=255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n[0]+.7152*n[1]+.0722*n[2]}function it(t,n){var a=yt(t),l=yt(n);if(!a||!l)return 21;var o=Dt(a),s=Dt(l);return(Math.max(o,s)+.05)/(Math.min(o,s)+.05)}function xt(t,n,a){var l=yt(t),o=yt(n);if(!l||!o||it(t,n)>=a)return t;for(var s=Dt(o)>.4,m=0,f=t;m<=1&&it(f,n)<a;)m+=.05,f="#"+l.map(function(b){var k=s?b*(1-m):b+(255-b)*m;return("0"+Math.round(k).toString(16)).slice(-2)}).join("");return f}function ut(t,n){var a=t.decimals!=null?t.decimals:0,l=t.ratioDecimals!=null?t.ratioDecimals:1,o=t.prefix||"",s=t.suffix||"",m={},f=t.negatives==="brackets";function b(T){return m[T]||(m[T]=new Intl.NumberFormat(n||void 0,{minimumFractionDigits:T,maximumFractionDigits:T})),m[T]}function k(T,C){if(T==null||!isFinite(T))return"\u2013";C==null&&(C=a);var R=Number(T.toFixed(C)),O=o+b(C).format(Math.abs(R))+s;return R>=0?O:f?"("+O+")":"\u2212"+O}function y(T,C){var R=k(T,C);return T!=null&&Number(T.toFixed(C??a))>0?"+"+R:R}function x(T,C){return T==null||!isFinite(T)?"\u2013":(T<0?"\u2212":"")+b(C??l).format(Math.abs(T)*100)+"%"}function M(T,C){if(T==null||!isFinite(T))return"\u2013";var R=C??Math.max(l,1),O=Number((T*100).toFixed(R));return(O>0?"+":O<0?"\u2212":"")+b(R).format(Math.abs(O))+" pp"}function d(T,C){return T==null||!isFinite(T)?"\u2013":b(C??1).format(T*100)+"%"}return{value:k,signed:y,ratio:x,pp:M,percent:d,nf:b}}function vt(t,n){var a=dt(t);return isFinite(a)||pt(n+" must be a number."),a}function Zt(t){var n=t.length,a=new Array(n),l=new Array(n),o,s;for(o=0;o<n;o++)a[o]=o;for(a.sort(function(b,k){return t[b]-t[k]}),o=0;o<n;o=s){for(s=o;s<n&&t[a[s]]===t[a[o]];)s++;for(var m=(o+s+1)/2,f=o;f<s;f++)l[a[f]]=m}return l}function Tt(t,n){var a=t.length,l=0,o=0,s;for(s=0;s<a;s++)l+=t[s],o+=n[s];l/=a,o/=a;var m=0,f=0,b=0;for(s=0;s<a;s++){var k=t[s]-l,y=n[s]-o;m+=k*y,f+=k*k,b+=y*y}return f>0&&b>0?m/Math.sqrt(f*b):null}function Jt(t,n){return Tt(Zt(t),Zt(n))}function Ht(t,n){for(var a=t.slice().sort(function(M,d){return M-d}),l=n.slice().sort(function(M,d){return M-d}),o=a.length,s=l.length,m=0,f=0,b=0,k=a.length?a[0]:0;m<o&&f<s;){for(var y=Math.min(a[m],l[f]);m<o&&a[m]===y;)m++;for(;f<s&&l[f]===y;)f++;var x=Math.abs(m/o-f/s);x>b+1e-15&&(b=x,k=y)}return{d:b,at:k}}function te(t,n,a){return t==null?"red":(t=Math.round(t*1e12)/1e12,n=Math.round(n*1e12)/1e12,t>a.spearmanGreen&&n<a.ksGreen?"green":t<a.spearmanRed||n>a.ksRed?"red":"amber")}function Vt(t,n){return Math.max(0,n.spearmanGreen-(t.spearman==null?-1:t.spearman))/.1+Math.max(0,t.ks-n.ksGreen)/.03}function W(t,n,a){var l=Jt(t,n),o=Ht(t,n);return{spearman:l,ks:o.d,ksAt:o.at,zone:te(l,o.d,a)}}function It(t){var n=t.length,a=0,l=0,o;for(o=0;o<n;o++)a+=t[o];for(a/=n,o=0;o<n;o++)l+=(t[o]-a)*(t[o]-a);return Math.sqrt(l/n)}function h(t){for(var n=0,a=0;a<t.length;a++)n+=t[a];return t.length?n/t.length:0}function w(t){(!t||typeof t!="object")&&pt("data is required.");var n=t.dates;(!Array.isArray(n)||n.length<2)&&pt("data.dates must be an array of at least two days.");var a=n.length,l=function(x,M,d){return x==null&&d?null:((!Array.isArray(x)||x.length!==a)&&pt(M+" must be an array with one value per date ("+a+")."),x.map(function(T,C){return vt(T,M+"["+C+"]")}))};(!Array.isArray(t.factors)||!t.factors.length)&&pt("data.factors must be a non-empty array of risk factors.");var o={},s=t.factors.map(function(x,M){(!x||typeof x!="object")&&pt("data.factors["+M+"] is not an object."),x.key==null&&x.label==null&&pt("data.factors["+M+"] needs a key or a label.");var d=String(x.key!=null?x.key:x.label),T='factor "'+d+'"';o[d]&&pt(T+" is used twice."),o[d]=1;var C=l(x.hpl,T+": hpl"),R=l(x.rtpl,T+": rtpl",!0);return{key:d,label:x.label!=null?String(x.label):d,group:x.group!=null?String(x.group):"Other",modelled:R!=null,hpl:C,rtpl:R||C.map(function(){return 0}),index:M}}),m=l(t.hplTotal,"data.hplTotal",!0),f=l(t.rtplTotal,"data.rtplTotal",!0);if(m||f){var b=new Array(a),k=new Array(a),y;for(y=0;y<a;y++)b[y]=0,k[y]=0,s.forEach(function(x){b[y]+=x.hpl[y],k[y]+=x.rtpl[y]});s.push({key:"__unattributed",label:t.unattributedLabel||wt.unattributed,group:"Unattributed",modelled:!0,unattributed:!0,hpl:b.map(function(x,M){return m?m[M]-x:0}),rtpl:k.map(function(x,M){return f?f[M]-x:0}),index:s.length})}return{dates:n.map(String),factors:s,n:a}}function g(t,n){n=n||{};var a=w(t),l=a.n,o=a.factors,s=bt({},At,n.thresholds||{}),m=n.window!=null?Math.floor(vt(n.window,"window")):250;m>=2||pt("window must be at least 2 days.");var f=m>l;f&&(m=l);var b=l-m,k={};(n.fix||[]).forEach(function(P){o.some(function(N){return N.key===String(P)})||V('fix: there is no factor "'+P+'", so it changes nothing.'),k[String(P)]=1}),o.forEach(function(P){P.fixed=!!k[P.key],P.rt=P.fixed?P.hpl:P.rtpl,P.gap=P.hpl.map(function(N,F){return N-P.rt[F]})});var y=new Array(l),x=new Array(l),M=new Array(l),d,T;for(d=0;d<l;d++){var C=0,R=0;for(T=0;T<o.length;T++)C+=o[T].hpl[d],R+=o[T].rt[d];y[d]=C,x[d]=R,M[d]=C-R}var O=y.slice(b),j=x.slice(b),E=M.slice(b),S={dates:a.dates,hpl:y,rtpl:x,unexplained:M,start:b,window:m,shortWindow:f,thresholds:s,fixed:Object.keys(k)};S.test=W(O,j,s);var A=It(E),H=It(O),lt=h(E);S.sdUnexplained=A,S.sdHpl=H,S.meanUnexplained=lt,S.volRatio=H>0?A/H:null,S.meanRatio=H>0?lt/H:null,S.varRatio=H>0?A*A/(H*H):null,o.forEach(function(P){var N=P.gap.slice(b),F=h(N),B=0;for(d=0;d<m;d++)B+=(N[d]-F)*(E[d]-lt);for(B/=m,P.meanGap=F,P.sdGap=It(N),P.contribution=A>0?B/A:0,P.share=A>0?P.contribution/A:0,P.hplSum=0,P.rtplSum=0,d=b;d<l;d++)P.hplSum+=P.hpl[d],P.rtplSum+=P.rt[d];if(P.hasGap=P.sdGap>0||F!==0,P.hasGap){var U=j.map(function(nt,st){return nt+N[st]});P.ifFixed=W(O,U,s)}else P.ifFixed=S.test});var tt=o.slice().sort(function(P,N){return Math.abs(N.contribution)-Math.abs(P.contribution)||P.index-N.index});tt.forEach(function(P,N){P.rank=N+1}),S.factors=o,S.order=tt;for(var D=n.pathSteps!=null?Math.max(0,Math.floor(n.pathSteps)):5,K=[],q=j.slice(),X=S.test,Q={};X.zone!=="green"&&K.length<D;){var Z=null;if(o.forEach(function(P){if(!(Q[P.key]||P.fixed||!P.hasGap)){var N=P.gap.slice(b),F=q.map(function(nt,st){return nt+N[st]}),B=W(O,F,s),U=Vt(B,s);(!Z||U<Z.d-1e-12||Math.abs(U-Z.d)<=1e-12&&(B.spearman||-1)>(Z.t.spearman||-1))&&(Z={f:P,t:B,d:U,R:F})}}),!Z||Z.d>=Vt(X,s)-1e-12)break;Q[Z.f.key]=1,K.push({key:Z.f.key,label:Z.f.label,test:Z.t}),q=Z.R,X=Z.t}return S.path=K,S.pathReachesGreen=S.test.zone==="green"||K.length>0&&K[K.length-1].test.zone==="green",S.distribution={hpl:O.slice().sort(function(P,N){return P-N}),rtpl:j.slice().sort(function(P,N){return P-N})},S}function v(){if(!document.getElementById("vpa-styles")){var t=".vpa{position:relative;color:var(--vpa-text);background:var(--vpa-bg);font-family:var(--vpa-font);line-height:1.4}.vpa.vpa-filled{padding:14px 14px 8px;border-radius:10px}.vpa-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:0 0 10px}.vpa-stat{background:var(--vpa-card);border-radius:8px;padding:9px 12px;min-width:0}.vpa-stat .k{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vpa-card-muted);font-weight:600;overflow-wrap:anywhere;hyphens:auto}.vpa-stat .v{font-size:19px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vpa-stat .n{font-size:12px;color:var(--vpa-card-muted)}.vpa-stat .v.vpa-zone{font-weight:800}.vpa-stat .v.vpa-wrap{white-space:normal;overflow-wrap:anywhere;line-height:1.2;font-size:17px}.vpa-scope{font-size:12px;color:var(--vpa-muted);margin:0 0 4px}.vpa-legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;margin:0 0 6px;color:var(--vpa-text)}.vpa-legend span{display:inline-flex;align-items:center;gap:6px}.vpa-legend i{display:inline-block;width:12px;height:12px;border-radius:3px}.vpa-legend i.vpa-tick{width:16px;height:3px;border-radius:1px}.vpa-legend i.vpa-ring{background:transparent!important;border:2px solid;border-radius:2px;width:9px;height:9px;transform:rotate(45deg)}.vpa-plot{display:block;width:100%;height:auto;overflow:visible;outline:none}.vpa-plot:focus-visible{outline:2px solid var(--vpa-focus);outline-offset:4px;border-radius:4px}.vpa-animate .vpa-grow{animation:vpa-fade .45s ease both}@keyframes vpa-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vpa-animate .vpa-grow{animation:none}}.vpa-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vpa-tip-bg);color:var(--vpa-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}.vpa-tip.vpa-on{opacity:1;transform:none}.vpa-tip b{font-weight:600}.vpa-table{border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums;margin:0 0 14px;min-width:100%}.vpa-table caption{text-align:left;font-weight:700;padding:0 0 6px}.vpa-table th,.vpa-table td{padding:5px 8px;border-bottom:1px solid rgba(127,127,127,.25);text-align:right;white-space:nowrap}.vpa-table th:first-child,.vpa-table td:first-child{text-align:left}.vpa-table tr.vpa-breach td{color:var(--vpa-hedge);font-weight:600}@media (max-width:420px){.vpa-summary{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))}.vpa-stat{padding:8px 10px}.vpa-stat .v{font-size:17px}}",n=J("style");n.id="vpa-styles",n.textContent=t,(document.head||document.documentElement).appendChild(n)}}function e(t){var n;(t==null||t==="")&&(t="veyforma"),typeof t=="string"?(Mt.hasOwnProperty(t)||(V('Unknown theme "'+t+'". The "veyforma" theme is used instead.'),t="veyforma"),n=bt({},_t,Mt[t])):typeof t=="object"?(n=bt(t.extends?e(t.extends):bt({},_t),t),delete n.extends):(V("The theme option must be a theme name or an object."),n=bt({},_t));var a=/^#/.test(n.background)?n.background:"#ffffff",l=/^#/.test(n.cardBackground)?n.cardBackground:a;return["axisText","mutedText"].forEach(function(o){n[o]=xt(n[o],a,4.5)}),n.cardMuted=xt(n.mutedText,l,4.5),n.offsetText=xt(xt(n.offset,a,4.5),l,4.5),n.zoneText={},["green","amber","red"].forEach(function(o){n.zoneText[o]=xt(xt(n.zones[o],a,4.5),l,4.5)}),n.accentText=xt(n.accent,a,4.5),n}function r(t,n){var a=typeof t=="string"?document.querySelector(t):t;(!a||a.nodeType!==1)&&pt("container not found ("+t+")."),(!n||!n.data)&&pt("options.data is required."),v(),this.id=++St,this.container=a,this.options=bt({},ft,n),this.element=J("div","vpa"),this.element.setAttribute("role","figure"),this.summaryEl=J("div","vpa-summary",this.element),this.scopeEl=J("p","vpa-scope",this.element),this.legendEl=J("div","vpa-legend",this.element),this.plotHost=J("div","vpa-plot-host",this.element),this.tipEl=J("div","vpa-tip",this.element),this.tipEl.setAttribute("role","tooltip"),a.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=-1;var l=this;Y.ResizeObserver?(this._observer=new Y.ResizeObserver(function(){var o=Math.round(l.element.clientWidth);o&&Math.abs(o-l._lastWidth)>1&&l.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){l.redraw()},Y.addEventListener("resize",this._onResize)),this._onDocTap=function(o){l.element.contains(o.target)||l._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&Y.VeyformaToolkit&&(this.toolkit=Y.VeyformaToolkit.attach(this,this.options.toolbar))}r.prototype.update=function(t){return t?(t.data&&t.data!==this.options.data&&this.options.animate&&(this._animateNext=!0),t.view&&t.view!==this.options.view&&this.options.animate&&(this._animateNext=!0),bt(this.options,t),this.redraw()):this},r.prototype.setData=function(t){return this._res=null,this.update({data:t})},r.prototype.setView=function(t){return this.update({view:t})},r.prototype.setTheme=function(t){return this.update({theme:t})},r.prototype.getTheme=function(){return e(this.options.theme)},r.prototype._opts=function(){return{window:this.options.window,fix:this.options.fix,thresholds:this.options.thresholds}},r.prototype.getResult=function(){return g(this.options.data,this._opts())},r.prototype.getFactor=function(t){return this.getResult().factors.filter(function(n){return n.key===String(t)})[0]||null},r.prototype.setFix=function(t){return this.update({fix:t})},r.prototype.setWindow=function(t){return this.update({window:t})},r.prototype._labels=function(){return bt({},wt,this.options.labels)},r.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&Y.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},r.prototype._hideTip=function(){this.tipEl.classList.remove("vpa-on"),this._hlEl&&this._hlEl.setAttribute("opacity",0)},r.prototype._placeTip=function(t,n,a){var l=this.tipEl;l.textContent="",t.forEach(function(y,x){x&&l.appendChild(document.createElement("br"));var M=x===0?document.createElement("b"):document.createElement("span");M.textContent=y,l.appendChild(M)});var o=this.element.getBoundingClientRect(),s=a&&a.clientX?a.clientX:n.left+n.width/2,m=a&&a.clientY?a.clientY:n.top+10;l.classList.add("vpa-on");var f=l.offsetWidth,b=l.offsetHeight;l.style.left=Rt(s-o.left-f/2,4,Math.max(4,o.width-f-4))+"px";var k=m-o.top-b-14;k<0&&(k=m-o.top+18),l.style.top=k+"px"};function i(t,n,a){n>t||(n=t+1);var l=n-t,o=Math.pow(10,Math.floor(Math.log(l/a)/Math.LN10)),s=l/a/o;s>=7.5?o*=10:s>=3.5?o*=5:s>=1.5&&(o*=2);for(var m=Math.floor(t/o+1e-9)*o,f=Math.ceil(n/o-1e-9)*o,b=[],k=m;k<=f+o/2;k+=o)b.push(Math.round(k/o)*o);return{lo:m,hi:f,ticks:b,step:o}}function u(t,n,a,l,o){var s=I("text",bt({x:n,y:a},o||{}),t);return s.textContent=l,s}r.prototype._bindInteraction=function(t,n,a,l,o,s){var m=this,f=this._items,b=this.options;function k(x){for(var M=t.getBoundingClientRect(),d=(x.clientX-M.left)*(n/M.width),T=(x.clientY-M.top)*(a/M.height),C=0;C<f.length;C++){var R=f[C];if(d>=R.x&&d<=R.x+R.w&&T>=R.y&&T<=R.y+R.h)return C}return-1}function y(x,M){if(x<0){m._hideTip();return}m._active=x;var d=f[x],T=m._hlEl;T.setAttribute("x",d.x-4),T.setAttribute("y",d.y),T.setAttribute("width",d.w+8),T.setAttribute("height",d.h),T.setAttribute("opacity",1);var C=t.getBoundingClientRect(),R=C.width/n,O={left:C.left+d.px*R,top:C.top+d.py*(C.height/a),width:0,height:0};m._placeTip(m._tipLines(d),O,M&&M.clientX?M:null)}t.addEventListener("pointermove",function(x){y(k(x),x)}),t.addEventListener("pointerleave",function(){m._hideTip()}),t.addEventListener("click",function(x){var M=k(x);M>=0&&typeof b.onItemClick=="function"&&b.onItemClick(m._detail(f[M]),x)}),t.addEventListener("keydown",function(x){var M=m._active;if(x.key==="ArrowRight"||x.key==="ArrowDown")M=Math.min(f.length-1,M+1);else if(x.key==="ArrowLeft"||x.key==="ArrowUp")M=Math.max(0,M<0?0:M-1);else if(x.key==="Home")M=0;else if(x.key==="End")M=f.length-1;else if(x.key==="Escape"){m._hideTip();return}else if((x.key==="Enter"||x.key===" ")&&M>=0){typeof b.onItemClick=="function"&&b.onItemClick(m._detail(f[M]),x),x.preventDefault();return}else return;x.preventDefault(),y(M,null)}),t.addEventListener("blur",function(){m._hideTip()})},r.prototype.createTable=function(){var t=this.getExportData(),n=J("div","vpa-tables");return t.sheets.forEach(function(a){if(a.name!=="Notes"){var l=J("table","vpa-table",n);J("caption",null,l).textContent=a.name;var o=J("tr",null,J("thead",null,l));a.columns.forEach(function(m){var f=J("th",null,o);f.scope="col",f.textContent=m.label});var s=J("tbody",null,l);a.text.forEach(function(m,f){var b=J("tr",a.flag&&a.flag[f]?"vpa-breach":null,s);m.forEach(function(k,y){var x=J(y?"td":"th",null,b);y||(x.scope="row"),x.textContent=k})})}}),n},r.prototype.redraw=function(){var t=this.options,n=t.data,a=this._labels(),l=this._res=g(n,bt(this._opts(),{pathSteps:t.pathSteps})),o=e(t.theme),s=ut(n,t.locale),m=this.element,f=m.style,b=o.fontFamily==="inherit"?Y.getComputedStyle?Y.getComputedStyle(this.container).fontFamily:"sans-serif":o.fontFamily,k=o.background&&o.background!=="transparent",y=k?o.background:"#ffffff";f.setProperty("--vpa-text",o.text),f.setProperty("--vpa-muted",o.mutedText),f.setProperty("--vpa-bg",k?o.background:"transparent"),f.setProperty("--vpa-font",b),f.setProperty("--vpa-card",o.cardBackground),f.setProperty("--vpa-card-muted",o.cardMuted),f.setProperty("--vpa-tip-bg",o.tooltipBackground),f.setProperty("--vpa-tip-text",o.tooltipText),f.setProperty("--vpa-focus",o.focus),f.setProperty("--vpa-hedge",o.zoneText.red),m.classList.toggle("vpa-filled",!!k),m.setAttribute("aria-label",t.ariaLabel||n.title||"P&L attribution");var x=t.view;["factors","daily","distribution"].indexOf(x)<0&&(V('Unknown view "'+x+'". The factor view is shown instead.'),x="factors"),l.shortWindow&&!this._warnedShort&&(V("There are fewer days than the "+(t.window||250)+"-day window; all "+l.window+" are used."),this._warnedShort=!0),this._view=x,this._renderSummary(l,s,a,o),this.scopeEl.textContent=[a[x],l.window+"-day window",n.unit||null,l.fixed.length?l.fixed.length+" fix"+(l.fixed.length>1?"es":"")+" applied":null].filter(Boolean).join(" \xB7 "),this._renderLegend(x,o,a,l);var M=Math.max(280,Math.round(this.plotHost.clientWidth||m.clientWidth||720));this._lastWidth=Math.round(m.clientWidth);var d=o.fontSize||12;this.plotHost.textContent="";var T=I("svg",{class:"vpa-plot",role:"img",tabindex:0,"font-family":b},this.plotHost);T.style.fontSize=d+"px";var C=this._animateNext&&t.animate;this._animateNext=!1,C&&T.classList.add("vpa-animate");var R={svg:T,W:M,fs:d,theme:o,f:s,L:a,family:b,bg:y,res:l,items:[],points:{}},O=x==="daily"?this._drawDaily(R):x==="distribution"?this._drawDistribution(R):this._drawFactors(R);return T.setAttribute("viewBox","0 0 "+M+" "+O),T.setAttribute("width",M),T.setAttribute("height",O),T.setAttribute("aria-label",(t.ariaLabel||n.title||"P&L attribution")+". "+this.describe()),this._items=R.items,this._points=R.points,this._hlEl=I("rect",{x:0,y:0,width:0,height:0,rx:4,fill:o.text,"fill-opacity":.06,opacity:0,"pointer-events":"none"},T),T.insertBefore(this._hlEl,T.firstChild),this._bindInteraction(T,M,O,o,a,s),this};function c(t){return t==null?"n/a":t.toFixed(2)}r.prototype._zoneName=function(t){var n=this._labels();return n[t]||t},r.prototype._renderSummary=function(t,n,a,l){var o=this.summaryEl,s=this.options,m=this;if(o.textContent="",o.style.display=s.summary===!1?"none":"",s.summary===!1)return;function f(y,x,M,d,T){var C=J("div","vpa-stat",o);J("div","k",C).textContent=y;var R=J("div",d?"v "+d:"v",C);R.textContent=x,T&&(R.style.color=T),M&&(J("div","n",C).textContent=M)}var b=t.test,k=t.order[0];f(a.test,this._zoneName(b.zone),"Spearman "+c(b.spearman)+" \xB7 KS "+c(b.ks)+" ("+t.window+" days)","vpa-zone",l.zoneText[b.zone]),f(a.unexplainedCard,"\xB1"+n.value(t.sdUnexplained),(t.volRatio!=null?n.percent(t.volRatio,0)+" of HPL volatility \xB7 ":"")+"mean "+n.signed(t.meanUnexplained)+" a day"),f(a.largest,k.label,n.percent(k.share,0)+" of the unexplained volatility","vpa-wrap"),b.zone==="green"?f(a.path,"Already green","margin: Spearman +"+(b.spearman-t.thresholds.spearmanGreen).toFixed(2)+", KS \u2212"+(t.thresholds.ksGreen-b.ks).toFixed(2)):t.pathReachesGreen?f(a.path,"Fix "+t.path.length+" factor"+(t.path.length>1?"s":""),t.path.map(function(y){return y.label}).join(", ")+" \u2192 Spearman "+c(t.path[t.path.length-1].test.spearman)+", KS "+c(t.path[t.path.length-1].test.ks),"vpa-wrap"):f(a.path,t.path.length?"Not within "+t.path.length+" fix"+(t.path.length>1?"es":""):"No single fix helps",t.path.length?"best reached: "+this._zoneName(t.path[t.path.length-1].test.zone).toLowerCase():"the gap is spread across factors"),Array.prototype.forEach.call(o.querySelectorAll(".vpa-stat .v"),function(y){y.style.fontSize="";for(var x=parseFloat(Y.getComputedStyle?Y.getComputedStyle(y).fontSize:19)||19;y.scrollWidth>y.clientWidth&&x>12;)x-=1,y.style.fontSize=x+"px"})},r.prototype._renderLegend=function(t,n,a,l){var o=this.legendEl;o.textContent="",o.style.display=this.options.legend===!1?"none":"";function s(m,f,b){var k=J("span",null,o),y=J("i",b||null,k);b==="vpa-ring"?y.style.borderColor=m:y.style.background=m,k.appendChild(document.createTextNode(f))}if(t==="factors"){s(n.contribution,a.adds),s(n.offset,a.offsets),s(n.standalone,a.standalone,"vpa-ring");return}s(n.hpl,a.hpl,"vpa-tick"),s(n.rtpl,a.rtpl,"vpa-tick"),t==="daily"&&(s(n.unexplained,a.unexplained),l.start>0&&s(n.outside,a.outside))};function p(t,n){var a=Math.min(Math.max.apply(null,n.map(function(o){return ht(o,t.fs,600,t.family)}))+12,t.W*.34),l=t.W-a<300;return{nameW:l?0:a,narrow:l}}function _(t,n,a,l,o,s,m,f,b,k){var y=t.theme,x=t.fs,M=t.family,d=t.W,T=-1/0;a.ticks.forEach(function(C){I("line",{x1:l(C),x2:l(C),y1:f,y2:b,stroke:C===0?y.axis:y.grid,"stroke-width":C===0?1.2:1},n);var R=k(C),O=ht(R,x-1,400,M),j=l(C),E=j-O/2<0?"start":j+O/2>d?"end":"middle",S=E==="start"?j:E==="end"?j-O:j-O/2;S<T+8||(T=S+O,u(n,j,o+x,R,{"text-anchor":E,fill:y.axisText,"font-size":x-1,class:"vpa-tick"}))})}r.prototype._drawFactors=function(t){var n=t.res,a=t.theme,l=t.f,o=t.L,s=t.fs,m=t.family,f=t.W,b=t.svg,k=this,y=+this.options.top>0?Math.floor(+this.options.top):n.order.length,x=n.order.slice(y),M=n.order.slice(0,y).sort(function(N,F){return F.contribution-N.contribution}).map(function(N){return{kind:"factor",obj:N,name:N.label+(N.modelled?"":" *"),v:N.contribution,k:N.sdGap}});if(x.length){var d=0,T=0;x.forEach(function(N){d+=N.contribution,T+=N.sdGap}),M.push({kind:"other",obj:{count:x.length,contribution:d,factors:x},name:$t(o.other,{n:x.length}),v:d,k:null})}var C=p(t,M.map(function(N){return N.name})),R=Math.max(ht("\u2192 "+o.amber,s-1,600,m),ht("\u2192 "+o.green,s-1,600,m),ht("\u2192 "+o.red,s-1,600,m))+14,O=Math.max.apply(null,M.map(function(N){return ht(l.signed(N.v),s,700,m)}))+10,j=C.nameW,E=f-O-R,S=Math.max(26,s*2.1),A=C.narrow?s+4:0,H=4,lt=Math.min(0,Math.min.apply(null,M.map(function(N){return N.v}))),tt=Math.max.apply(null,M.map(function(N){return Math.max(N.v,N.k||0)}))||1,D=i(lt,tt,Math.max(2,Math.min(6,Math.floor((E-j)/90)))),K=function(N){return j+(Rt(N,D.lo,D.hi)-D.lo)/(D.hi-D.lo)*(E-j)},q=H+s+6,X=q+M.length*(S+A),Q=I("g",{class:"vpa-factors"},b);_(t,Q,D,K,H,j,E,q,X,function(N){return l.value(N)}),u(Q,f,H+s,o.ifFixed,{"text-anchor":"end",fill:a.axisText,"font-size":s-1,class:"vpa-tick"}),M.forEach(function(N,F){var B=q+F*(S+A)+A,U=S*.56,nt=B+(S-U)/2,st=N.v<0&&l.value(-N.v)!==l.value(0);u(Q,0,C.narrow?B-3:nt+U/2+s*.35,Ft(N.name,C.narrow?f-R:C.nameW-8,s,N.kind==="other"?400:600,m),{fill:N.kind==="other"?a.mutedText:a.text,"font-size":s,"font-weight":N.kind==="other"?400:600,class:"vpa-name"});var at=K(Math.min(0,N.v)),zt=K(Math.max(0,N.v));if(I("rect",{x:at,y:nt,width:Math.max(.8,zt-at),height:U,rx:2,fill:st?a.offset:a.contribution,class:"vpa-grow vpa-cbar"+(st?" vpa-offset":"")},Q),N.k!=null){var mt=K(N.k),gt=nt+U/2;I("path",{d:"M"+mt+","+(gt-5)+"L"+(mt+5)+","+gt+"L"+mt+","+(gt+5)+"L"+(mt-5)+","+gt+"Z",fill:t.bg,stroke:a.standalone,"stroke-width":1.6,class:"vpa-sa"},Q)}if(u(Q,f-R,nt+U/2+s*.35,l.signed(N.v),{"text-anchor":"end",fill:st?a.offsetText:a.text,"font-size":s,"font-weight":700,class:"vpa-val"}),N.kind==="factor"){var Et=N.obj.ifFixed.zone;u(Q,f,nt+U/2+s*.35,"\u2192 "+k._zoneName(Et),{"text-anchor":"end",fill:a.zoneText[Et],"font-size":s-1,"font-weight":600,class:"vpa-zonefix"}),t.points[N.obj.key]={x:st?at:zt,y:nt}}t.items.push({kind:N.kind,obj:N.obj,x:0,y:B-A,w:f,h:S+A,px:st?at:zt,py:nt})});var Z=["Shares add up to the unexplained volatility of \xB1"+l.value(n.sdUnexplained)+" a day over "+n.window+" days"];n.factors.some(function(N){return!N.modelled})&&Z.push("* "+o.notModelled+" (RTPL taken as zero)"),Z.push("\u201C"+o.ifFixed+"\u201D: test zone with that factor's RTPL set equal to its HPL");var P=X+s+8;return Z.forEach(function(N){u(b,0,P,Ft(N+".",f,s-1,400,m),{fill:a.mutedText,"font-size":s-1,class:"vpa-note"}),P+=s+3}),Math.ceil(P-s+6)},r.prototype._drawDaily=function(t){var n=t.res,a=t.theme,l=t.f,o=t.L,s=t.fs,m=t.family,f=t.W,b=t.svg,k=n.dates.length,y=n.hpl.concat(n.rtpl,n.unexplained),x=i(Math.min(0,Math.min.apply(null,y)),Math.max(0,Math.max.apply(null,y)),f<480?4:6),M=Math.max.apply(null,x.ticks.map(function(B){return ht(l.value(B),s-1,400,m)})),d=M+10,T=f-4,C=6,R=f<480?220:300,O=C+R,j=function(B){return d+(B+.5)/k*(T-d)},E=function(B){return C+(x.hi-Rt(B,x.lo,x.hi))/(x.hi-x.lo)*R},S=I("g",{class:"vpa-daily"},b);n.start>0&&I("rect",{x:d,y:C,width:j(n.start)-(T-d)/k/2-d,height:R,fill:a.outside,"fill-opacity":.35,class:"vpa-outside"},S),x.ticks.forEach(function(B){I("line",{x1:d,x2:T,y1:E(B),y2:E(B),stroke:B===0?a.axis:a.grid,"stroke-width":B===0?1.2:1},S),u(S,d-6,E(B)+(s-1)*.35,l.value(B),{"text-anchor":"end",fill:a.axisText,"font-size":s-1,class:"vpa-tick"})});var A=Math.max(.6,(T-d)/k*.7);n.unexplained.forEach(function(B,U){var nt=E(Math.max(0,B)),st=E(Math.min(0,B));I("rect",{x:j(U)-A/2,y:nt,width:A,height:Math.max(.6,st-nt),fill:a.unexplained,"fill-opacity":U<n.start?.4:.85,class:"vpa-grow vpa-ubar"},S)});var H=function(B){return B.map(function(U,nt){return(nt?"L":"M")+j(nt).toFixed(2)+","+E(U).toFixed(2)}).join("")};I("path",{d:H(n.hpl),fill:"none",stroke:a.hpl,"stroke-width":1.6,"stroke-linejoin":"round",class:"vpa-line vpa-hpl"},S),I("path",{d:H(n.rtpl),fill:"none",stroke:a.rtpl,"stroke-width":1.6,"stroke-dasharray":"4 2","stroke-linejoin":"round",class:"vpa-line vpa-rtpl"},S);for(var lt=ht(n.dates[0],s-1,400,m)+16,tt=Math.max(1,Math.ceil(lt/((T-d)/k))),D=-1/0,K=0;K<k;K+=tt){var q=j(K),X=ht(n.dates[K],s-1,400,m),Q=q-X/2<0?"start":q+X/2>f?"end":"middle",Z=Q==="start"?q:Q==="end"?q-X:q-X/2;Z<D+8||(D=Z+X,u(S,q,O+s+9,n.dates[K],{"text-anchor":Q,fill:a.axisText,"font-size":s-1,class:"vpa-tick"}))}var P=(T-d)/k;n.dates.forEach(function(B,U){t.items.push({kind:"day",index:U,x:j(U)-P/2,y:C,w:P,h:R,px:j(U),py:E(Math.max(n.hpl[U],n.rtpl[U]))}),t.points["date:"+B]={x:j(U),y:E(Math.max(n.hpl[U],n.rtpl[U]))}});var N=["Unexplained P&L \xB1"+l.value(n.sdUnexplained)+" a day ("+(n.volRatio!=null?l.percent(n.volRatio,0)+" of HPL volatility":"")+") over the last "+n.window+" days"],F=O+s*2+17;return N.forEach(function(B){u(b,0,F,Ft(B+".",f,s-1,400,m),{fill:a.mutedText,"font-size":s-1,class:"vpa-note"}),F+=s+3}),Math.ceil(F-s+6)},r.prototype._drawDistribution=function(t){var n=t.res,a=t.theme,l=t.f,o=t.L,s=t.fs,m=t.family,f=t.W,b=t.svg,k=n.distribution,y=k.hpl.length,x=n.thresholds,M=Math.min(k.hpl[0],k.rtpl[0]),d=Math.max(k.hpl[y-1],k.rtpl[y-1]),T=i(M,d,f<480?4:6),C=ht("100%",s-1,400,m)+10,R=f-6,O=8,j=f<480?200:270,E=O+j,S=function(at){return C+(Rt(at,T.lo,T.hi)-T.lo)/(T.hi-T.lo)*(R-C)},A=function(at){return O+(1-at)*j},H=I("g",{class:"vpa-dist"},b);[0,.25,.5,.75,1].forEach(function(at){I("line",{x1:C,x2:R,y1:A(at),y2:A(at),stroke:at===0?a.axis:a.grid},H),u(H,C-6,A(at)+(s-1)*.35,Math.round(at*100)+"%",{"text-anchor":"end",fill:a.axisText,"font-size":s-1,class:"vpa-tick"})}),_(t,H,T,S,E+8,C,R,O,E,function(at){return l.value(at)});var lt=function(at){var zt="M"+S(T.lo)+","+A(0);return at.forEach(function(mt,gt){zt+="L"+S(mt).toFixed(2)+","+A(gt/y).toFixed(2)+"L"+S(mt).toFixed(2)+","+A((gt+1)/y).toFixed(2)}),zt+"L"+S(T.hi)+","+A(1)};I("path",{d:lt(k.hpl),fill:"none",stroke:a.hpl,"stroke-width":1.8,class:"vpa-line vpa-hpl"},H),I("path",{d:lt(k.rtpl),fill:"none",stroke:a.rtpl,"stroke-width":1.8,"stroke-dasharray":"4 2",class:"vpa-line vpa-rtpl"},H);var tt=function(at,zt){for(var mt=0,gt=at.length;mt<gt;){var Et=mt+gt>>1;at[Et]<=zt?mt=Et+1:gt=Et}return mt/at.length},D=n.test.ksAt,K=tt(k.hpl,D),q=tt(k.rtpl,D),X=S(D),Q=n.test.zone;I("line",{x1:X,x2:X,y1:A(K),y2:A(q),stroke:a.zoneText[Q],"stroke-width":3,class:"vpa-ksline"},H);var Z="KS "+c(n.test.ks),P=ht(Z,s,700,m),N=X+8+P>f?X-8:X+8;I("rect",{x:(X+8+P>f?N-P:N)-3,y:(A(K)+A(q))/2-s*.7,width:P+6,height:s*1.4,rx:3,fill:t.bg,class:"vpa-lbg"},H),u(H,N,(A(K)+A(q))/2+s*.35,Z,{"text-anchor":X+8+P>f?"end":"start",fill:a.zoneText[Q],"font-size":s,"font-weight":700,class:"vpa-kslabel"});for(var F=0;F<=20;F++){var B=T.lo+(T.hi-T.lo)*F/20,U=(R-C)/20;t.items.push({kind:"point",value:B,ph:tt(k.hpl,B),pr:tt(k.rtpl,B),x:S(B)-U/2,y:O,w:U,h:j,px:S(B),py:A(Math.max(tt(k.hpl,B),tt(k.rtpl,B)))})}var nt=["Spearman "+c(n.test.spearman)+" (green above "+x.spearmanGreen.toFixed(2)+", red below "+x.spearmanRed.toFixed(2)+") \xB7 KS "+c(n.test.ks)+" (green below "+x.ksGreen.toFixed(2)+", red above "+x.ksRed.toFixed(2)+")","Share of the "+n.window+" days with P&L at or below each value"],st=E+s*2+12;return nt.forEach(function(at){u(b,0,st,Ft(at+".",f,s-1,400,m),{fill:a.mutedText,"font-size":s-1,class:"vpa-note"}),st+=s+3}),Math.ceil(st-s+6)},r.prototype._tipLines=function(t){var n=this.options,a=ut(n.data,n.locale),l=this._labels(),o=this._res,s=this;if(t.kind==="other")return[$t(l.other,{n:t.obj.count}),"Together "+a.signed(t.obj.contribution)+" of the unexplained volatility"];if(t.kind==="day"){var m=t.index,f=o.factors.map(function(y){return{l:y.label,g:y.gap[m]}}).filter(function(y){return y.g!==0}).sort(function(y,x){return Math.abs(x.g)-Math.abs(y.g)}).slice(0,3);return[o.dates[m]+(m<o.start?" \xB7 "+l.outside.toLowerCase():""),l.hpl+" "+a.signed(o.hpl[m]),l.rtpl+" "+a.signed(o.rtpl[m]),l.unexplained+" "+a.signed(o.unexplained[m])].concat(f.length?["Largest gaps: "+f.map(function(y){return y.l+" "+a.signed(y.g)}).join(", ")]:[])}if(t.kind==="point")return["P&L at or below "+a.signed(t.value),"HPL "+a.percent(t.ph,0)+" of days \xB7 RTPL "+a.percent(t.pr,0),"Gap "+a.percent(Math.abs(t.ph-t.pr),0)+" (KS is the largest gap: "+c(o.test.ks)+")"];var b=t.obj,k=b.ifFixed;return[b.label+(b.modelled?"":" ("+l.notModelled+")"),b.group+" \xB7 rank "+b.rank+" of "+o.factors.length,"Share of unexplained volatility "+a.signed(b.contribution)+" ("+a.percent(b.share,0)+")","Gap on its own \xB1"+a.value(b.sdGap)+" a day \xB7 mean "+a.signed(b.meanGap),"HPL "+a.signed(b.hplSum)+" \xB7 RTPL "+a.signed(b.rtplSum)+" over "+o.window+" days",l.ifFixed+": "+s._zoneName(k.zone).toLowerCase()+" (Spearman "+c(k.spearman)+", KS "+c(k.ks)+")"]},r.prototype._detail=function(t){if(!t)return null;var n=this._res,a=this._view;if(t.kind==="other")return{view:a,kind:"other",count:t.obj.count,contribution:t.obj.contribution,factors:t.obj.factors.map(function(s){return s.key})};if(t.kind==="day"){var l=t.index;return{view:a,kind:"day",date:n.dates[l],hpl:n.hpl[l],rtpl:n.rtpl[l],unexplained:n.unexplained[l],inWindow:l>=n.start,gaps:n.factors.map(function(s){return{key:s.key,gap:s.gap[l]}})}}if(t.kind==="point")return{view:a,kind:"point",value:t.value,hplShare:t.ph,rtplShare:t.pr};var o=t.obj;return{view:a,kind:"factor",key:o.key,label:o.label,group:o.group,modelled:o.modelled,fixed:o.fixed,rank:o.rank,contribution:o.contribution,share:o.share,sdGap:o.sdGap,meanGap:o.meanGap,hplSum:o.hplSum,rtplSum:o.rtplSum,ifFixed:{spearman:o.ifFixed.spearman,ks:o.ifFixed.ks,zone:o.ifFixed.zone}}},r.prototype.howToRead=function(){var t=this._view||this.options.view;return t==="daily"?"The dark line is front-office hypothetical P&L (HPL) and the dashed line the risk model's P&L (RTPL), day by day. Grey bars are the difference, the unexplained P&L. Only the most recent days, inside the test window, count for the test.":t==="distribution"?"Each line shows the share of days with P&L at or below a value, for HPL and for RTPL. If the risk model matched the front office, the two lines would sit on top of each other. The coloured bar marks the largest gap between them, the Kolmogorov-Smirnov (KS) statistic.":"Each bar is one risk factor's share of the unexplained P&L volatility (HPL \u2212 RTPL). Shares add up exactly to the total; a bar to the left means the factor's gap offsets other gaps. The diamond is the factor's gap on its own, and the right column shows the test zone the desk would reach if that factor's gap were closed."},r.prototype.describe=function(){var t=this.options,n=ut(t.data,t.locale),a=this._labels(),l=this._res||g(t.data,this._opts()),o=l.test,s=l.thresholds,m=[],f=this,b=[];(o.spearman==null||o.spearman<=s.spearmanGreen)&&b.push("Spearman "+c(o.spearman)+(o.spearman!=null&&o.spearman>=s.spearmanRed?" is below "+s.spearmanGreen.toFixed(2):" is below "+s.spearmanRed.toFixed(2))),o.ks>=s.ksGreen&&b.push("KS "+c(o.ks)+(o.ks<=s.ksRed?" is above "+s.ksGreen.toFixed(2):" is above "+s.ksRed.toFixed(2))),m.push("Over the last "+l.window+" days the desk is in the "+this._zoneName(o.zone).toLowerCase()+" zone of the P&L attribution test"+(b.length?": "+b.join(" and ")+".":" (Spearman "+c(o.spearman)+", KS "+c(o.ks)+").")),m.push("Unexplained P&L is \xB1"+n.value(l.sdUnexplained)+" a day"+(l.volRatio!=null?", "+n.percent(l.volRatio,0)+" of the front office's P&L volatility":"")+".");var k=l.order[0],y=l.order[1];m.push(k.label+(k.modelled?"":", which is not in the risk model,")+" explains "+n.percent(k.share,0)+" of it"+(y?", followed by "+y.label+" ("+n.percent(y.share,0)+")":"")+".");var x=l.factors.filter(function(d){return d.share<-.02}).sort(function(d,T){return d.contribution-T.contribution});if(x.length&&m.push("The gap on "+x[0].label+" partly offsets the others."),o.zone!=="green")if(l.pathReachesGreen){var M=l.path[l.path.length-1].test;m.push("Closing the gap on "+l.path.map(function(d){return d.label}).join(" and ")+" would bring the desk to green (Spearman "+c(M.spearman)+", KS "+c(M.ks)+").")}else l.path.length&&m.push("Even closing the gaps on "+l.path.map(function(d){return d.label}).join(", ")+" only reaches "+this._zoneName(l.path[l.path.length-1].test.zone).toLowerCase()+".");return l.fixed.length&&m.push("Fixes applied: "+l.fixed.join(", ")+"."),m.join(" ")},r.prototype.getExportData=function(){var t=this.options,n=t.data,a=this._labels(),l=ut(n,t.locale),o=this._res||g(n,this._opts()),s=this,m=o.thresholds,f={prefix:n.prefix||"",suffix:n.suffix||"",decimals:n.decimals!=null?n.decimals:0,negatives:n.negatives},b=function(E){return{label:E,type:"number",unit:f}},k=function(E){return{label:E,type:"number",unit:{decimals:3}}},y=function(E){return{label:E,type:"percent",decimals:1}},x=function(E){return{label:E,type:"text"}},M=[];M.push({name:"Factors",columns:[{label:"Rank",type:"number",unit:{decimals:0}},x("Risk factor"),x("Group"),x("In risk model"),x("Fixed"),b("HPL over window"),b("RTPL over window"),b("Mean daily gap"),b("Gap volatility"),b("Share of unexplained volatility"),y("Share (%)"),k("Spearman if fixed"),k("KS if fixed"),x("Zone if fixed")],rows:o.order.map(function(E){return[E.rank,E.label,E.group,E.modelled?"Yes":"No",E.fixed?"Yes":"No",E.hplSum,E.rtplSum,E.meanGap,E.sdGap,E.contribution,E.share,E.ifFixed.spearman,E.ifFixed.ks,s._zoneName(E.ifFixed.zone)]}),text:o.order.map(function(E){return[String(E.rank),E.label,E.group,E.modelled?"Yes":"No",E.fixed?"Yes":"No",l.signed(E.hplSum),l.signed(E.rtplSum),l.signed(E.meanGap),l.value(E.sdGap),l.signed(E.contribution),l.percent(E.share),c(E.ifFixed.spearman),c(E.ifFixed.ks),s._zoneName(E.ifFixed.zone)]}),flag:o.order.map(function(E){return!E.modelled})});for(var d=t.exportDays!=null?t.exportDays:2e4,T=Math.max(0,o.dates.length-d),C=[],R=T;R<o.dates.length;R++)C.push(R);M.push({name:"Daily",columns:[x("Date"),b("HPL"),b("RTPL"),b("Unexplained"),x("In test window")],rows:C.map(function(E){return[o.dates[E],o.hpl[E],o.rtpl[E],o.unexplained[E],E>=o.start?"Yes":"No"]}),text:C.map(function(E){return[o.dates[E],l.signed(o.hpl[E]),l.signed(o.rtpl[E]),l.signed(o.unexplained[E]),E>=o.start?"Yes":"No"]})});var O=[["Spearman correlation",o.test.spearman,"green above "+m.spearmanGreen+", red below "+m.spearmanRed],["Kolmogorov-Smirnov statistic",o.test.ks,"green below "+m.ksGreen+", red above "+m.ksRed],["Unexplained volatility \xF7 HPL volatility",o.volRatio,""],["Mean unexplained \xF7 HPL volatility",o.meanRatio,""],["Variance of unexplained \xF7 variance of HPL",o.varRatio,""]];o.path.forEach(function(E,S){O.push(["Path step "+(S+1)+": fix "+E.label+" \u2192 Spearman",E.test.spearman,s._zoneName(E.test.zone)],["Path step "+(S+1)+": fix "+E.label+" \u2192 KS",E.test.ks,s._zoneName(E.test.zone)])}),M.push({name:"Test",columns:[x("Measure"),k("Value"),x("Note")],rows:O,text:O.map(function(E){return[E[0],E[1]==null?"n/a":E[1].toFixed(3),E[2]]})});var j=(t.annotations||[]).map(function(E,S){return[String(S+1),E.factor!=null?String(E.factor):"Date: "+String(E.date||""),E.text||""]});return j.length&&M.push({name:"Notes",columns:[x("No."),x("Factor or date"),x("Note")],rows:j}),{title:n.title||"P&L attribution",subtitle:n.subtitle||"",summary:this.describe(),library:"Veyforma P&L Attribution "+Ct,sheets:M,meta:[["Unit",n.unit],["As of",n.asOf],["Desk",n.desk],["Test window",o.window+" days ("+o.dates[o.start]+" to "+o.dates[o.dates.length-1]+")"],["PLA test zone",s._zoneName(o.test.zone)+" (Spearman "+c(o.test.spearman)+", KS "+c(o.test.ks)+")"],["Fixes applied",o.fixed.length?o.fixed.join(", "):null],["Method","Spearman = correlation of the ranks of daily HPL and RTPL (ties averaged); KS = largest gap between their empirical distribution functions; green if Spearman > "+m.spearmanGreen+" and KS < "+m.ksGreen+", red if Spearman < "+m.spearmanRed+" or KS > "+m.ksRed+`, otherwise amber; factor share = cov(gap, unexplained) \xF7 sd(unexplained), adds up to sd(unexplained); "if fixed" sets that factor's RTPL equal to its HPL`+(T>0?"; daily sheet limited to the last "+d+" days":"")],["Data source",n.source]]}},r.prototype._annotationPoint=function(t){var n=this._points||{};return t.factor!=null?n[String(t.factor)]||null:t.date!=null&&n["date:"+String(t.date)]||null},r.prototype._annotationTarget=function(t){var n=this._items||[],a=null;if(!t)a=n[this._active];else for(var l=this.plotHost.querySelector("svg"),o=l.getBoundingClientRect(),s=l.viewBox.baseVal,m=(t.clientX-o.left)*(s.width/o.width),f=(t.clientY-o.top)*(s.height/o.height),b=0;b<n.length;b++){var k=n[b];if(m>=k.x&&m<=k.x+k.w&&f>=k.y&&f<=k.y+k.h){a=k;break}}return a?a.kind==="factor"?{factor:a.obj.key}:a.kind==="day"?{date:this._res.dates[a.index]}:null:null},r.prototype._annotationLabel=function(t){if(t.date!=null)return String(t.date);var n=(this._res||this.getResult()).factors.filter(function(a){return a.key===String(t.factor)})[0];return n?n.label:String(t.factor||"")},Y.VeyPlaAttribution={version:Ct,create:function(t,n){return new r(t,n)},compute:function(t,n){return g(t,n)},test:function(t,n,a){return W(t,n,bt({},At,a||{}))},thresholds:At,listThemes:function(){return Object.keys(Mt)},getTheme:function(t){return e(t)},defaults:{options:ft,labels:wt,theme:_t}}})(typeof window<"u"?window:void 0);(function(Y){"use strict";function Ct(kt){var St=Y[kt];if(!St)throw new Error("VeyformaCharts: "+kt+" is not loaded. Load its script before veyforma-charts.js, or use the bundled dist/veyforma-charts.js.");return St}Y.VeyformaCharts={version:"1.0.0",heatmap:function(kt,St){return Ct("VeyHeatmap").create(kt,St)},tornado:function(kt,St){return Ct("VeyRiskTornado").create(kt,St)},plaAttribution:function(kt,St){return Ct("VeyPlaAttribution").create(kt,St)}}})(typeof window<"u"?window:void 0);
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
|
+
(function(Y){"use strict";var Ct="1.2.0",kt="http://www.w3.org/2000/svg",St=0,_t={low:"#fbf1ea",mid:"#ef8a54",high:"#9a3412",empty:"#ffffff",limit:"#111111",cellText:"#000000",cellTextOnDark:"#ffffff",totalBar:"#111111",totalBarOpacity:.12,headerText:"#555555",text:"#111111",mutedText:"#6b6b6b",summaryBackground:"#f6f6f6",background:"transparent",tooltipBackground:"#111111",tooltipText:"#ffffff",focus:"#2563eb",fontFamily:"inherit",fontSize:12,cellRadius:3,cellGap:2},Mt={veyforma:{},mono:{low:"#f4f4f4",mid:"#9a9a9a",high:"#111111",empty:"#ffffff",limit:"#111111"},"colour-safe":{low:"#eef3fb",mid:"#6d9be0",high:"#1d3f8f",limit:"#d9730d"},ocean:{low:"#ecf6f8",mid:"#5aaec0",high:"#0c3b5e",limit:"#be123c",summaryBackground:"#eef5f8"},forest:{low:"#f1f5ea",mid:"#8fb36b",high:"#22441a",limit:"#a8590b",summaryBackground:"#f2f4ee"},corporate:{low:"#eef1f6",mid:"#8195b8",high:"#1e3a6e",limit:"#b91c1c",summaryBackground:"#f1f4f8",cellRadius:0},midnight:{background:"#111418",low:"#1e242c",mid:"#2f6aa8",high:"#9cd0ff",empty:"#111418",limit:"#fbbf24",cellText:"#000000",cellTextOnDark:"#ffffff",totalBar:"#9cd0ff",totalBarOpacity:.18,headerText:"#c3c9d2",text:"#f3f4f6",mutedText:"#a3abb8",summaryBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd"}};function At(h){if((h==null||h==="")&&(h="veyforma"),typeof h=="string")return Mt.hasOwnProperty(h)||(bt('Unknown theme "'+h+'". The "veyforma" theme is used instead.'),h="veyforma"),ft({},_t,Mt[h]);if(typeof h!="object")return bt("The theme option must be a theme name or an object."),ft({},_t);var w=h.extends?At(h.extends):ft({},_t),g=ft(w,h);return delete g.extends,["low","mid","high","empty"].forEach(function(v){pt(g[v])||(bt('Theme colour "'+v+'" must be a hex value such as "#9a3412". The default is used instead.'),g[v]=_t[v])}),g}function ft(h){for(var w=1;w<arguments.length;w++){var g=arguments[w];if(g)for(var v in g)Object.prototype.hasOwnProperty.call(g,v)&&(h[v]=g[v])}return h}function wt(h,w,g){return Math.min(g,Math.max(w,h))}function bt(h){Y.console&&Y.console.warn("VeyHeatmap: "+h)}function ot(h,w,g){var v=document.createElementNS(kt,h);if(w)for(var e in w)w[e]!=null&&v.setAttribute(e,w[e]);return g&&g.appendChild(v),v}function V(h,w,g){var v=document.createElement(h);return w&&(v.className=w),g&&g.appendChild(v),v}function pt(h){if(typeof h!="string")return null;var w=h.trim().replace(/^#/,"");if(w.length===3&&(w=w.split("").map(function(v){return v+v}).join("")),!/^[0-9a-fA-F]{6}$/.test(w))return null;var g=parseInt(w,16);return[g>>16&255,g>>8&255,g&255]}function Rt(h){return"#"+h.map(function(w){var g=Math.round(wt(w,0,255)).toString(16);return g.length<2?"0"+g:g}).join("")}function $t(h,w,g){return[h[0]+(w[0]-h[0])*g,h[1]+(w[1]-h[1])*g,h[2]+(w[2]-h[2])*g]}function ae(h){var w=pt(h.low),g=pt(h.mid),v=pt(h.high);return function(e){return e=wt(e,0,1),Rt(e<.5?$t(w,g,e*2):$t(g,v,(e-.5)*2))}}function dt(h,w){var g=I(h),v=I(w);return(Math.max(g,v)+.05)/(Math.min(g,v)+.05)}function I(h){var w=pt(h);if(!w)return 1;var g=w.map(function(v){return v/=255,v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4)});return .2126*g[0]+.7152*g[1]+.0722*g[2]}var J=null;function et(h,w,g,v){if(!J){var e=document.createElement("canvas");J=e.getContext&&e.getContext("2d")}return J?(J.font=(g||400)+" "+w+"px "+v,J.measureText(String(h)).width):String(h).length*w*.6}function ht(h,w,g,v,e){if(h=String(h),et(h,g,v,e)<=w)return h;for(var r=0,i=h.length;r<i;){var u=Math.ceil((r+i)/2);et(h.slice(0,u)+"\u2026",g,v,e)<=w?r=u:i=u-1}return r>0?h.slice(0,r).replace(/\s+$/,"")+"\u2026":""}function Ft(h,w,g,v,e){for(var r=String(h).split(/\s+/),i=[],u="",c=0;c<r.length;c++){var p=u?u+" "+r[c]:r[c];et(p,g,v,e)>w&&u?(i.push(u),u=r[c]):u=p}u&&i.push(u);var _=i.length<=2&&i.every(function(t){return et(t,g,v,e)<=w});return _?i:null}function yt(h){var w=Math.round(h*1e4)/100;return String(w)+"%"}function Dt(h,w){var g=h.decimals!=null?h.decimals:0,v=h.prefix||"",e=h.suffix||"",r={};function i(t,n){return r[t]||(r[t]=new Intl.NumberFormat(w||void 0,n)),r[t]}function u(t,n){n==null&&(n=g);var a=Math.pow(10,-n);if(t>0&&t<a/2)return"<"+v+i("f"+n,{minimumFractionDigits:n,maximumFractionDigits:n}).format(a)+e;var l=v+i("f"+n,{minimumFractionDigits:n,maximumFractionDigits:n}).format(Math.abs(t))+e;return t>=0?l:h.negatives==="brackets"?"("+l+")":"\u2212"+l}function c(t){return e?u(t,0):(t<0?"\u2212":"")+v+i("c",{notation:"compact",maximumFractionDigits:1}).format(Math.abs(t))}function p(t,n){return n==null&&(n=1),i("p"+n,{minimumFractionDigits:n,maximumFractionDigits:n}).format(t*100)+"%"}function _(t){return i("n",{maximumFractionDigits:0}).format(t)}return{value:u,compact:c,percent:p,count:_}}function it(h,w){return String(h).replace(/\{(\w+)\}/g,function(g,v){return w[v]!=null?w[v]:g})}var xt="\0other";function ut(h){if(Array.isArray(h.values)){var w=h.rowLabels,g=h.columnLabels,v=vt&&vt.get(h.values);if(v&&v.grid&&v.gridRows===w&&v.gridCols===g)return v.grid;if(!Array.isArray(w)||!Array.isArray(g))throw new Error("VeyHeatmap: a values grid needs rowLabels and columnLabels.");if(h.values.length!==w.length)throw new Error("VeyHeatmap: values has "+h.values.length+" rows but rowLabels has "+w.length+".");var e=[];h.values.forEach(function(p,_){if(!Array.isArray(p)||p.length!==g.length)throw new Error("VeyHeatmap: row "+(_+1)+" of values needs "+g.length+" numbers.");p.forEach(function(t,n){e.push({row:w[_],column:g[n],value:t})})});var r={records:e,rows:"row",columns:"column",dimensions:{row:{label:h.rowTitle||"Row",order:w.slice(),ordered:!0},column:{label:h.columnTitle||"Column",order:g.slice(),ordered:!0}}};if(vt){var i=vt.get(h.values)||{};i.grid=r,i.gridRows=w,i.gridCols=g,vt.set(h.values,i)}return r}if(!Array.isArray(h.records)||!h.records.length)throw new Error("VeyHeatmap: data needs records, or values with rowLabels and columnLabels.");var u=Object.keys(h.records[0]).filter(function(p){return p!=="value"}),c=ft({},h.dimensions||{});return u.forEach(function(p){c[p]||(c[p]={label:p.charAt(0).toUpperCase()+p.slice(1)})}),{records:h.records,rows:h.rows||u[0],columns:h.columns||u[1],dimensions:c}}var vt=typeof WeakMap=="function"?new WeakMap:null;function Zt(h,w,g,v){var e=w+""+g,r=vt&&v?vt.get(v):null;if(r&&r[e])return r[e];for(var i=new Map,u=new Map,c=new Map,p=0,_=h.records,t=_.length,n=0;n<t;n++){var a=_[n],l=a[w],o=a[g];if(l==null||l==="")throw new Error("VeyHeatmap: record "+(n+1)+' has no "'+w+'".');if(o==null||o==="")throw new Error("VeyHeatmap: record "+(n+1)+' has no "'+g+'".');var s=a.value,m=typeof s=="number"?s:Number(s);if(s==null||s===""||!isFinite(m))throw new Error("VeyHeatmap: record "+(n+1)+" has no numeric value.");if(m<0)throw new Error("VeyHeatmap: record "+(n+1)+" is negative. Exposure values must be zero or more.");typeof l!="string"&&(l=String(l)),typeof o!="string"&&(o=String(o));var f=i.get(l);f||(f=new Map,i.set(l,f),u.set(l,0)),f.set(o,(f.get(o)||0)+m),u.set(l,u.get(l)+m),c.set(o,(c.get(o)||0)+m),p+=m}var b=function(y){var x={};return y.forEach(function(M,d){x[d]=M}),x},k={cell:function(y,x){var M=i.get(y);return M&&M.get(x)||0},rowTot:b(u),colTot:b(c),rowSeen:Array.from(u.keys()),colSeen:Array.from(c.keys()),total:p};return vt&&v&&(r||(r={},vt.set(v,r)),r[e]=k),k}function Tt(h,w,g){var v=ut(h),e=w.rows||v.rows,r=w.columns||v.columns;if(!e||!r)throw new Error("VeyHeatmap: choose a field for the rows and a field for the columns.");if(e===r)throw new Error('VeyHeatmap: rows and columns cannot both use "'+e+'".');var i=ft({label:e},v.dimensions[e]),u=ft({label:r},v.dimensions[r]),c=Zt(v,e,r,Array.isArray(h.values)?h.values:h.records),p=c.rowTot,_=c.colTot,t=c.rowSeen,n=c.colSeen,a=c.total;function l(f,b,k,y,x){var M=f.slice();if(Array.isArray(k.order)){var d=k.order.map(String);M.sort(function(A,H){var lt=d.indexOf(A),tt=d.indexOf(H);return lt<0&&(lt=d.length+f.indexOf(A)),tt<0&&(tt=d.length+f.indexOf(H)),lt-tt})}var T=M.slice().sort(function(A,H){return b[H]-b[A]||M.indexOf(A)-M.indexOf(H)}),C=y==="total"||y!=="natural"&&!k.ordered,R=C?T:M,O=R.map(function(A){return{key:A,label:A,members:[A]}});if(x&&x>0&&R.length>x+1){var j=T.slice(0,x),E=R.filter(function(A){return j.indexOf(A)>=0}),S=R.filter(function(A){return j.indexOf(A)<0});O=E.map(function(A){return{key:A,label:A,members:[A]}}),O.push({key:xt,label:it(g.other,{count:S.length}),members:S,other:!0})}return O.forEach(function(A){A.total=A.members.reduce(function(H,lt){return H+b[lt]},0)}),O}var o=l(t,p,i,w.sortRows,w.topRows),s=l(n,_,u,w.sortColumns,w.topColumns),m=o.map(function(f){return s.map(function(b){var k=0;return f.members.forEach(function(y){b.members.forEach(function(x){k+=c.cell(y,x)})}),k})});return{rowKey:e,colKey:r,rowDim:i,colDim:u,rows:o,cols:s,values:m,total:a}}function Jt(h,w){var g=[],v=0;h.values.forEach(function(i,u){i.forEach(function(c,p){var _=h.total>0?c/h.total:0;v+=_*_*1e4,g.push({r:u,c:p,value:c,share:_})})}),g.sort(function(i,u){return u.value-i.value});var e=g.slice(0,5).reduce(function(i,u){return i+u.share},0),r=w>0?g.filter(function(i){return i.share>w+1e-12}):[];return{hhi:v,effective:v>0?1e4/v:0,largest:g[0],top5:e,above:r}}var Ht={data:null,theme:"veyforma",locale:void 0,rows:void 0,columns:void 0,valueMode:"amount",scale:"linear",sortRows:"auto",sortColumns:"auto",topRows:0,topColumns:0,fit:"auto",limit:void 0,totals:!0,cellLabels:"auto",cellHeight:void 0,summary:!0,legend:!0,tooltip:!0,animate:!0,labels:null,ariaLabel:void 0,tooltipFormatter:null,onClick:null,caption:!0,annotations:null,onAnnotationsChange:null,toolbar:!0},te={total:"Total",other:"Other ({count})",empty:"No exposure",totalExposure:"Total exposure",largest:"Largest concentration",hhi:"Concentration (HHI)",aboveLimit:"Above limit",top5:"Top 5 cells",hhiNote:"Like {n} equal-sized cells",aboveNote:"Cells above {limit} of total",gridNote:"{rows} {rowDim} \xD7 {cols} {colDim}",top5Note:"Share of total exposure",exposure:"Exposure",shareOfTotal:"Share of total",shareOfRow:"Share of {row}",shareOfColumn:"Share of {column}",limitLegend:"Above {limit} limit",limitTip:"Above the {limit} limit",rowTotalTip:"{label} total",scrollNote:"Scroll sideways to see all {columns}.",groupNote:"Smaller {columns} are grouped as Other to fit this screen. Tap an Other cell to see which.",includes:"Other includes {list}"};function Vt(){if(!document.getElementById("vhm-styles")){var h=".vhm{position:relative;color:var(--vhm-text);background:var(--vhm-bg);font-family:var(--vhm-font);line-height:1.4}.vhm.vhm-filled{padding:14px 14px 8px;border-radius:10px}.vhm-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px;margin:0 0 12px}.vhm-stat{background:var(--vhm-summary-bg);border-radius:10px;padding:10px 12px;min-width:0}.vhm-stat-label{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vhm-muted)}.vhm-stat-value{font-size:20px;font-weight:650;letter-spacing:-.01em;margin-top:2px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vhm-stat-note{font-size:11.5px;color:var(--vhm-muted);margin-top:1px;overflow-wrap:anywhere}.vhm-legend{display:flex;flex-wrap:wrap;align-items:center;gap:6px 18px;font-size:12px;margin:0 0 10px}.vhm-legend>span{display:inline-flex;align-items:center;gap:6px}.vhm-legend .vhm-ramp{display:inline-flex;flex-direction:column;align-items:stretch;gap:2px}.vhm-ramp-bar{width:150px;height:10px;border-radius:3px}.vhm-ramp-ticks{display:flex;justify-content:space-between;gap:8px;font-size:11px;color:var(--vhm-muted);font-variant-numeric:tabular-nums}.vhm-plot-host{overflow-x:auto;-webkit-overflow-scrolling:touch}.vhm-plot{display:block;overflow:visible;outline:none}.vhm-plot:focus-visible{outline:2px solid var(--vhm-focus);outline-offset:4px;border-radius:4px}.vhm-animate .vhm-cell{animation:vhm-fade .45s ease both}@keyframes vhm-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vhm-animate .vhm-cell{animation:none}}.vhm-scroll-note{font-size:11.5px;color:var(--vhm-muted);margin-top:4px}.vhm-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vhm-tip-bg);color:var(--vhm-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5}.vhm-tip.vhm-on{opacity:1;transform:none}.vhm-tip b{font-weight:600}.vhm-table{width:100%;border-collapse:collapse;font-size:13px}.vhm-table th,.vhm-table td{text-align:right;padding:7px 6px;border-bottom:1px solid rgba(127,127,127,.25);font-variant-numeric:tabular-nums;white-space:nowrap}.vhm-table th:first-child,.vhm-table td:first-child{text-align:left}.vhm-table th{font-weight:600;font-size:12px}.vhm-table tr.vhm-total td{font-weight:600}",w=document.createElement("style");w.id="vhm-styles",w.appendChild(document.createTextNode(h)),(document.head||document.documentElement).appendChild(w)}}function W(h,w){var g=typeof h=="string"?document.querySelector(h):h;if(!g||g.nodeType!==1)throw new Error("VeyHeatmap: container not found ("+h+").");if(!w||!w.data)throw new Error("VeyHeatmap: options.data is required.");Vt(),this.id=++St,this.container=g,this.options=ft({},Ht,w),this.element=V("div","vhm"),this.summaryEl=V("div","vhm-summary",this.element),this.legendEl=V("div","vhm-legend",this.element),this.plotHost=V("div","vhm-plot-host",this.element),this.noteEl=V("div","vhm-scroll-note",this.element),this.tipEl=V("div","vhm-tip",this.element),this.tipEl.setAttribute("role","tooltip"),this.tipEl.id="vhm-tip-"+this.id,g.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=null;var v=this;Y.ResizeObserver?(this._observer=new Y.ResizeObserver(function(){var e=Math.round(v.element.clientWidth);e&&e!==v._lastWidth&&v.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){v.redraw()},Y.addEventListener("resize",this._onResize)),this._onDocTap=function(e){v.element.contains(e.target)||v._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&Y.VeyformaToolkit&&(this.toolkit=Y.VeyformaToolkit.attach(this,this.options.toolbar))}W.prototype.update=function(h){return h?(h.data&&h.data!==this.options.data&&this.options.animate&&(this._animateNext=!0,this._active=null),(h.rows||h.columns||h.topRows!=null||h.topColumns!=null)&&(this._active=null),h.animate===!0&&(this._animateNext=!0),ft(this.options,h),this.redraw()):this},W.prototype.setData=function(h){return vt&&h&&(Array.isArray(h.records)&&vt.delete(h.records),Array.isArray(h.values)&&vt.delete(h.values)),this.update({data:h})},W.prototype.setTheme=function(h){return this.update({theme:h})},W.prototype.getTheme=function(){return At(this.options.theme)},W.prototype._labels=function(){return ft({},te,this.options.labels)},W.prototype._limit=function(){var h=this.options,w=h.limit!==void 0?h.limit:h.data.limit&&h.data.limit.share;return w=Number(w),isFinite(w)&&w>0&&w<1?w:0},W.prototype.getMatrix=function(){var h=Tt(this.options.data,this.options,this._labels()),w=function(g){return{key:g.key===xt?null:g.key,label:g.label,total:g.total,other:!!g.other,members:g.members.slice()}};return{rowField:h.rowKey,columnField:h.colKey,rows:h.rows.map(w),columns:h.cols.map(w),values:h.values.map(function(g){return g.slice()}),total:h.total}},W.prototype.getStats=function(){var h=Tt(this.options.data,ft({},this.options,{topRows:0,topColumns:0}),this._labels()),w=this._limit(),g=Jt(h,w),v=function(e){return{row:h.rows[e.r].label,column:h.cols[e.c].label,value:e.value,share:e.share}};return{total:h.total,rows:h.rows.length,columns:h.cols.length,hhi:g.hhi,effectiveCells:g.effective,top5Share:g.top5,largest:g.largest?v(g.largest):null,limit:w||null,aboveLimit:g.above.map(v)}},W.prototype.createTable=function(){var h=this.options,w=h.data,g=this._labels(),v=Tt(w,h,g),e=Dt(w,h.locale),r=document.createElement("table");if(r.className="vhm-table",w.title){var i=V("caption",null,r);i.textContent=w.title,i.style.cssText="text-align:left;font-weight:600;padding:0 6px 6px"}var u=V("tr",null,V("thead",null,r)),c=V("th",null,u);c.scope="col",c.textContent=v.rowDim.label,v.cols.forEach(function(n){var a=V("th",null,u);a.scope="col",a.textContent=n.label});var p=V("th",null,u);p.scope="col",p.textContent=g.total;var _=V("tbody",null,r);v.rows.forEach(function(n,a){var l=V("tr",null,_),o=V("th",null,l);o.scope="row",o.textContent=n.label,o.style.textAlign="left",o.style.fontWeight="400",v.values[a].forEach(function(s){V("td",null,l).textContent=s?e.value(s):"\u2014"}),V("td",null,l).textContent=e.value(n.total)});var t=V("tr","vhm-total",_);return V("td",null,t).textContent=g.total,v.cols.forEach(function(n){V("td",null,t).textContent=e.value(n.total)}),V("td",null,t).textContent=e.value(v.total),r},W.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&Y.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},W.prototype._hideTip=function(){this.tipEl.classList.remove("vhm-on"),this._focusRect&&this._focusRect.setAttribute("opacity",0),this._boldReset&&this._boldReset()},W.prototype._placeTip=function(h,w,g){var v=this.tipEl;v.textContent="",h.forEach(function(t,n){n&&v.appendChild(document.createElement("br"));var a=n===0?document.createElement("b"):document.createTextNode("");a.textContent=t,v.appendChild(a)});var e=this.element.getBoundingClientRect(),r=g&&g.clientX?g.clientX:w.left+w.width/2,i=g&&g.clientY?g.clientY:w.top;v.classList.add("vhm-on");var u=v.offsetWidth,c=v.offsetHeight,p=wt(r-e.left-u/2,4,Math.max(4,e.width-u-4)),_=i-e.top-c-14;_<0&&(_=(w.bottom!=null?w.bottom:i)-e.top+10),v.style.left=p+"px",v.style.top=_+"px"},W.prototype.redraw=function(){var h=this.options,w=h.data,g=this,v=At(h.theme),e=this._labels(),r=Tt(w,h,e),i=Dt(w,h.locale),u=h.topRows>0||h.topColumns>0?Tt(w,ft({},h,{topRows:0,topColumns:0}),e):r,c=this._limit(),p=Jt(u,c),_=this.element,t=ae(v),n=v.background&&v.background!=="transparent"?v.background:"#ffffff",a=v.fontFamily==="inherit"?Y.getComputedStyle?Y.getComputedStyle(this.container).fontFamily:"sans-serif":v.fontFamily,l=_.style;l.setProperty("--vhm-text",v.text),l.setProperty("--vhm-muted",v.mutedText),l.setProperty("--vhm-bg",v.background),l.setProperty("--vhm-font",a),l.setProperty("--vhm-focus",v.focus),l.setProperty("--vhm-tip-bg",v.tooltipBackground),l.setProperty("--vhm-tip-text",v.tooltipText),l.setProperty("--vhm-summary-bg",v.summaryBackground),_.classList.toggle("vhm-filled",!!v.background&&v.background!=="transparent"),_.classList.toggle("vhm-animate",!!this._animateNext);var o=Math.max(this.plotHost.clientWidth||_.clientWidth||0,280);this._lastWidth=Math.round(_.clientWidth);var s=o<560,m=Number(v.fontSize)||12,f=s?m-1.5:m-.5,b=s?m-2:m-1,k=h.cellHeight||(s?28:34),y=Math.max(0,Number(v.cellGap)||0),x=s?26:34,M=Math.max.apply(null,r.rows.map(function(L){return et(L.label,f,400,a)})),d=Math.min(Math.ceil(M)+12,Math.round(o*(s?.3:.26))),T=h.totals?Math.max(s?50:70,Math.ceil(et(i.value(Math.max.apply(null,r.rows.map(function(L){return L.total}))),m-1,600,a))+12):0;h.totals&&s&&(T=Math.min(T,64));var C=h.totals?8:0,R=o-d-C-T-2,O=h.fit||"auto",j=!1,E=Math.floor(R/x),S=O==="group"||O==="auto"&&!r.colDim.ordered&&!(h.topColumns>0);S&&r.cols.length>E&&E>=3&&(r=Tt(w,ft({},h,{topColumns:E-1}),e),j=!0);var A=r.rows.length,H=r.cols.length,lt=(r.rowDim.plural||r.rowDim.label).toLowerCase(),tt=(r.colDim.plural||r.colDim.label).toLowerCase(),D=h.valueMode;["amount","shareOfTotal","shareOfRow","shareOfColumn"].indexOf(D)<0&&(D="amount");for(var K=function(L,z){var $=r.values[L][z];return D==="shareOfTotal"?r.total?$/r.total:0:D==="shareOfRow"?r.rows[L].total?$/r.rows[L].total:0:D==="shareOfColumn"?r.cols[z].total?$/r.cols[z].total:0:$},q=0,X=0;X<A;X++)for(var Q=0;Q<H;Q++)q=Math.max(q,K(X,Q));var Z=h.scale==="sqrt",P=function(L){if(q<=0)return 0;var z=L/q;return Z?Math.sqrt(z):z},N=function(L,z){return D==="amount"?z?i.compact(L):i.value(L):i.percent(L,z?0:1)},F=this.summaryEl;if(F.textContent="",F.style.display=h.summary?"":"none",h.summary){var B=function(L,z,$){var G=V("div","vhm-stat",F);V("div","vhm-stat-label",G).textContent=L,V("div","vhm-stat-value",G).textContent=z,$&&(V("div","vhm-stat-note",G).textContent=$)};B(e.totalExposure,i.value(r.total),it(e.gridNote,{rows:u.rows.length,rowDim:lt,cols:u.cols.length,colDim:tt})),p.largest&&B(e.largest,i.percent(p.largest.share),u.rows[p.largest.r].label+" \xD7 "+u.cols[p.largest.c].label+" \xB7 "+i.value(p.largest.value)),B(e.hhi,i.count(p.hhi),it(e.hhiNote,{n:i.count(Math.round(p.effective))})),c?B(e.aboveLimit,i.count(p.above.length),it(e.aboveNote,{limit:yt(c)})):B(e.top5,i.percent(p.top5),e.top5Note)}var U=this.legendEl;if(U.textContent="",U.style.display=h.legend?"":"none",h.legend){var nt=V("span","vhm-ramp",U),st=V("span","vhm-ramp-bar",nt);st.style.background="linear-gradient(to right,"+[0,.25,.5,.75,1].map(function(L){return t(L)}).join(",")+")";var at=V("span","vhm-ramp-ticks",nt),zt=Z?q*.25:q*.5;[0,zt,q].forEach(function(L){V("span",null,at).textContent=N(L,!0)});var mt=V("span",null,U),gt=ot("svg",{width:14,height:14,"aria-hidden":"true"},mt);if(ot("rect",{x:1,y:1,width:12,height:12,rx:2,fill:v.empty,stroke:v.mutedText,"stroke-opacity":.45,"stroke-dasharray":"2 2"},gt),mt.appendChild(document.createTextNode(e.empty)),c){var Et=V("span",null,U),jt=ot("svg",{width:14,height:14,"aria-hidden":"true"},Et);ot("rect",{x:1.5,y:1.5,width:11,height:11,rx:2,fill:t(.7),stroke:v.limit,"stroke-width":2},jt),ot("rect",{x:3.5,y:3.5,width:7,height:7,rx:1,fill:"none",stroke:n,"stroke-width":1},jt),Et.appendChild(document.createTextNode(it(e.limitLegend,{limit:yt(c)})))}}var rt=R/H,Wt=!1;rt<x&&(rt=x,Wt=!0),R=rt*H;var Kt=r.cols.map(function(L){return Ft(L.label,rt-4,f,400,a)}),ee=Kt.some(function(L){return L===null}),ne=Math.max.apply(null,r.cols.map(function(L){return et(L.label,f,400,a)})),oe=Math.min(ne,140),Xt=ee?Math.ceil(oe*.7071+f+10):Math.max.apply(null,Kt.map(function(L){return L.length}))*(f+3)+10,ce=ee?Math.max(0,oe*.7071-T-C):0,ie=d+R+C+T+2+ce;ie>o+.5&&(Wt=!0);var ye=Xt,Ee=h.totals?k:0,xe=ye+A*k+(h.totals?C+Ee:0)+4,fe=d,Bt=function(L){return fe+L*rt},Lt=function(L){return ye+L*k};this.plotHost.textContent="",this.noteEl.textContent=Wt?it(e.scrollNote,{columns:tt}):j?it(e.groupNote,{columns:tt}):"",this.noteEl.style.display=Wt||j?"":"none";var Nt=ot("svg",{class:"vhm-plot",viewBox:"0 0 "+ie+" "+xe,width:ie,height:xe,tabindex:0,role:"img","aria-label":h.ariaLabel||[w.title,r.rowDim.label+" by "+r.colDim.label,p.largest?e.largest+": "+u.rows[p.largest.r].label+" \xD7 "+u.cols[p.largest.c].label+", "+i.percent(p.largest.share):null].filter(Boolean).join(". ")},this.plotHost);Wt||(Nt.style.width="100%",Nt.style.height="auto");var Gt=function(L,z,$){var G=ot("text",ft({"font-family":a},L),$||Nt);return G.textContent=z,G},ke=[];r.cols.forEach(function(L,z){var $=Bt(z)+rt/2,G=ot("g",null,Nt);if(ee){var ct=Xt-6;Gt({x:$-2,y:ct,"text-anchor":"start",transform:"rotate(-45 "+($-2)+" "+ct+")","font-size":f,fill:L.other?v.mutedText:v.headerText},ht(L.label,140,f,400,a),G)}else{var qt=Kt[z];qt.forEach(function(Qt,Fe){Gt({x:$,y:Xt-6-(qt.length-1-Fe)*(f+3),"text-anchor":"middle","font-size":f,fill:L.other?v.mutedText:v.headerText},Qt,G)})}ke.push(G)}),h.totals&&Gt({x:fe+R+C+T-4,y:Xt-6,"text-anchor":"end","font-size":f,"font-weight":600,fill:v.text},e.total);var Le=r.rows.map(function(L,z){var $=ht(L.label,d-12,f,400,a),G=Gt({x:d-8,y:Lt(z)+k/2+f*.35,"text-anchor":"end","font-size":f,fill:L.other?v.mutedText:v.headerText},$);if($!==L.label){var ct=ot("title",null,G);ct.textContent=L.label}return G});h.totals&&Gt({x:d-8,y:Lt(A)+C+k/2+f*.35,"text-anchor":"end","font-size":f,"font-weight":600,fill:v.text},e.total);for(var Ut=ot("g",null,Nt),Ce=h.cellLabels===!0||h.cellLabels==="auto",Pt=0;Pt<A;Pt++)for(var Ot=0;Ot<H;Ot++){var le=r.values[Pt][Ot],pe=K(Pt,Ot),de=le>0?t(P(pe)):v.empty,re=ot("rect",{x:Bt(Ot)+y/2,y:Lt(Pt)+y/2,width:Math.max(rt-y,1),height:Math.max(k-y,1),rx:Math.min(v.cellRadius,rt/4),fill:de,class:"vhm-cell","data-r":Pt,"data-c":Ot},Ut);if(le>0||(re.setAttribute("stroke",v.mutedText),re.setAttribute("stroke-opacity",.45),re.setAttribute("stroke-dasharray","2 2"),re.setAttribute("stroke-width",1)),re.style.animationDelay=Math.min((Pt+Ot)*18,500)+"ms",c&&r.total>0&&le/r.total>c+1e-12&&!r.rows[Pt].other&&!r.cols[Ot].other&&(ot("rect",{x:Bt(Ot)+y/2+1,y:Lt(Pt)+y/2+1,width:Math.max(rt-y-2,1),height:Math.max(k-y-2,1),rx:Math.min(v.cellRadius,rt/4),fill:"none",stroke:v.limit,"stroke-width":2,"pointer-events":"none"},Ut),ot("rect",{x:Bt(Ot)+y/2+3,y:Lt(Pt)+y/2+3,width:Math.max(rt-y-6,1),height:Math.max(k-y-6,1),rx:Math.max(0,Math.min(v.cellRadius,rt/4)-1),fill:"none",stroke:n,"stroke-width":1,"pointer-events":"none"},Ut)),Ce&&le>0&&k-y>=16){var Se=rt-y-8,se=N(pe,!1);if(et(se,b,500,a)>Se&&(se=N(pe,!0)),et(se,b,500,a)<=Se){var Ae=dt(de,v.cellTextOnDark)>dt(de,v.cellText)?v.cellTextOnDark:v.cellText;Gt({x:Bt(Ot)+rt/2,y:Lt(Pt)+k/2+b*.35,"text-anchor":"middle","font-size":b,"font-weight":500,fill:Ae,"pointer-events":"none",class:"vhm-cell-label"},se,Ut)}}}var Yt=null;if(h.totals){Yt=ot("g",null,Nt);var Re=Math.max.apply(null,r.rows.map(function(L){return L.total}))||1,ze=Math.max.apply(null,r.cols.map(function(L){return L.total}))||1,me=fe+R+C;r.rows.forEach(function(L,z){var $=Math.max(2,(T-2)*L.total/Re);ot("rect",{x:me,y:Lt(z)+y/2+3,width:$,height:k-y-6,rx:2,fill:v.totalBar,"fill-opacity":v.totalBarOpacity,"data-tr":z},Yt);var G=i.value(L.total);et(G,m-1,600,a)>T-6&&(G=i.compact(L.total)),Gt({x:me+T-4,y:Lt(z)+k/2+(m-1)*.35,"text-anchor":"end","font-size":m-1,"font-weight":600,fill:v.text,"pointer-events":"none"},G,Yt)});var ve=Lt(A)+C;r.cols.forEach(function(L,z){var $=Math.max(2,(k-y-4)*L.total/ze);ot("rect",{x:Bt(z)+y/2+2,y:ve+k-y/2-2-$,width:Math.max(rt-y-4,1),height:$,rx:2,fill:v.totalBar,"fill-opacity":v.totalBarOpacity,"data-tc":z},Yt);var G=i.value(L.total);et(G,b,600,a)>rt-y-6&&(G=i.compact(L.total)),et(G,b,600,a)<=rt-y-6&&Gt({x:Bt(z)+rt/2,y:ve+k/2+b*.35,"text-anchor":"middle","font-size":b,"font-weight":600,fill:v.text,"pointer-events":"none"},G,Yt)});var be=i.value(r.total);et(be,m-1,700,a)>T-6&&(be=i.compact(r.total)),Gt({x:me+T-4,y:ve+k/2+(m-1)*.35,"text-anchor":"end","font-size":m-1,"font-weight":700,fill:v.text},be)}this._focusRect=ot("rect",{x:0,y:0,width:0,height:0,rx:Math.min(v.cellRadius+1,6),fill:"none",stroke:v.text,"stroke-width":2,opacity:0,"pointer-events":"none"},Nt);var ge=function(L,z){var $=r.values[L][z];return{row:r.rows[L].label,column:r.cols[z].label,rowIndex:L,columnIndex:z,value:$,shareOfTotal:r.total?$/r.total:0,shareOfRow:r.rows[L].total?$/r.rows[L].total:0,shareOfColumn:r.cols[z].total?$/r.cols[z].total:0,aboveLimit:!!(c&&r.total&&$/r.total>c+1e-12&&!r.rows[L].other&&!r.cols[z].other),rowMembers:r.rows[L].members.slice(),columnMembers:r.cols[z].members.slice()}},ue=[];this._boldReset=function(){ue.forEach(function(L){L.removeAttribute("font-weight")}),ue=[]};var Ne=function(L,z){g._boldReset();var $=Le[L];$.setAttribute("font-weight",600),ue.push($),Array.prototype.forEach.call(ke[z].childNodes,function(G){G.setAttribute("font-weight",600),ue.push(G)})},he=function(L,z,$){if(g._active=[L,z],g._focusRect.setAttribute("x",Bt(z)+y/2-1),g._focusRect.setAttribute("y",Lt(L)+y/2-1),g._focusRect.setAttribute("width",rt-y+2),g._focusRect.setAttribute("height",k-y+2),g._focusRect.setAttribute("opacity",1),Ne(L,z),!!h.tooltip){var G=ge(L,z),ct;typeof h.tooltipFormatter=="function"?(ct=h.tooltipFormatter(G,i),Array.isArray(ct)||(ct=[String(ct)])):(ct=[G.row+" \xD7 "+G.column],G.value?(ct.push(e.exposure+": "+i.value(G.value)),ct.push(e.shareOfTotal+": "+i.percent(G.shareOfTotal)),ct.push(it(e.shareOfRow,{row:G.row})+": "+i.percent(G.shareOfRow)),ct.push(it(e.shareOfColumn,{column:G.column})+": "+i.percent(G.shareOfColumn)),G.aboveLimit&&ct.push(it(e.limitTip,{limit:yt(c)}))):ct.push(e.empty),r.rows[L].other&&ct.push(it(e.includes,{list:r.rows[L].members.join(", ")})),r.cols[z].other&&ct.push(it(e.includes,{list:r.cols[z].members.join(", ")})));var qt=Nt.getBoundingClientRect(),Qt=qt.width/ie;g._placeTip(ct,{left:qt.left+Bt(z)*Qt,top:qt.top+Lt(L)*Qt,width:rt*Qt,bottom:qt.top+(Lt(L)+k)*Qt},$)}},_e=function(L,z,$){var G=L?r.rows[z]:r.cols[z],ct=[it(e.rowTotalTip,{label:G.label}),i.value(G.total)+" \xB7 "+i.percent(r.total?G.total/r.total:0)+" "+e.shareOfTotal.toLowerCase()];G.other&&ct.push(G.members.join(", ")),g._placeTip(ct,{left:$.clientX,top:$.clientY,width:0},$)};Ut.addEventListener("mousemove",function(L){var z=L.target;!z.hasAttribute||!z.hasAttribute("data-r")||he(+z.getAttribute("data-r"),+z.getAttribute("data-c"),L)}),Ut.addEventListener("pointerdown",function(L){var z=L.target;!z.hasAttribute||!z.hasAttribute("data-r")||he(+z.getAttribute("data-r"),+z.getAttribute("data-c"),L)}),Ut.addEventListener("mouseleave",function(){g._hideTip()}),typeof h.onClick=="function"&&(Ut.style.cursor="pointer",Ut.addEventListener("click",function(L){var z=L.target;!z.hasAttribute||!z.hasAttribute("data-r")||h.onClick(ge(+z.getAttribute("data-r"),+z.getAttribute("data-c")),L)})),Yt&&(Yt.addEventListener("mousemove",function(L){var z=L.target;z.hasAttribute&&z.hasAttribute("data-tr")?_e(!0,+z.getAttribute("data-tr"),L):z.hasAttribute&&z.hasAttribute("data-tc")&&_e(!1,+z.getAttribute("data-tc"),L)}),Yt.addEventListener("mouseleave",function(){g._hideTip()})),this._geom={rows:r.rows,cols:r.cols,cx:Bt,cy:Lt,cellW:rt,cellH:k,gap:y},Nt.setAttribute("aria-describedby",this.tipEl.id);var we=[0,0];if(p.largest){var Te=r.rows.map(function(L){return L.key}).indexOf(u.rows[p.largest.r].key),Me=r.cols.map(function(L){return L.key}).indexOf(u.cols[p.largest.c].key);Te>=0&&Me>=0&&(we=[Te,Me])}return Nt.addEventListener("focus",function(){var L=g._active&&g._active[0]<A&&g._active[1]<H?g._active:we;he(L[0],L[1])}),Nt.addEventListener("blur",function(){g._hideTip()}),Nt.addEventListener("keydown",function(L){var z=g._active&&g._active[0]<A&&g._active[1]<H?g._active.slice():we.slice();if(L.key==="ArrowLeft")z[1]=Math.max(0,z[1]-1);else if(L.key==="ArrowRight")z[1]=Math.min(H-1,z[1]+1);else if(L.key==="ArrowUp")z[0]=Math.max(0,z[0]-1);else if(L.key==="ArrowDown")z[0]=Math.min(A-1,z[0]+1);else if(L.key==="Home")z[1]=0;else if(L.key==="End")z[1]=H-1;else if((L.key==="Enter"||L.key===" ")&&typeof h.onClick=="function"){L.preventDefault(),h.onClick(ge(z[0],z[1]),L);return}else return;L.preventDefault(),he(z[0],z[1])}),this._hideTip(),this._animateNext=!1,this};function It(h,w){if(w==null)return-1;w=String(w);for(var g=0;g<h.length;g++)if(h[g].label===w||h[g].key===w||h[g].members.indexOf(w)>=0)return g;return-1}W.prototype.howToRead=function(){var h=Tt(this.options.data,this.options,this._labels()),w=(h.rowDim.label||"row").toLowerCase(),g=(h.colDim.label||"column").toLowerCase();return"Each cell is the exposure where a "+w+" meets a "+g+"; darker cells hold more. The bars on the right and along the bottom are the totals for each "+w+" and "+g+". HHI measures concentration: the higher it is, the more the book depends on a few cells."+(this._limit()?" Cells with a double outline are above the concentration limit.":"")},W.prototype.describe=function(){var h=this.getStats(),w=Dt(this.options.data,this.options.locale),g=Tt(this.options.data,this.options,this._labels()),v=["In this example total exposure is "+w.value(h.total)+" across "+h.rows+" "+(g.rowDim.plural||g.rowDim.label).toLowerCase()+" and "+h.columns+" "+(g.colDim.plural||g.colDim.label).toLowerCase()+"."];return h.largest&&v.push("The largest cell is "+h.largest.row+" \xD7 "+h.largest.column+" with "+w.value(h.largest.value)+" ("+w.percent(h.largest.share)+" of the total)."),v.push("HHI is "+w.count(h.hhi)+", like "+w.count(Math.round(h.effectiveCells))+" equal-sized cells."),h.limit&&v.push(h.aboveLimit.length+" "+(h.aboveLimit.length===1?"cell is":"cells are")+" above the "+yt(h.limit)+" limit."),v.join(" ")},W.prototype.getExportData=function(){var h=this.options,w=h.data,g=this._labels(),v=Tt(w,ft({},h,{topRows:0,topColumns:0}),g),e=Dt(w,h.locale),r=this.getStats(),i=this._limit(),u={prefix:w.prefix||"",suffix:w.suffix||"",decimals:w.decimals!=null?w.decimals:0,negatives:w.negatives},c=[{label:v.rowDim.label,type:"text"}].concat(v.cols.map(function(s){return{label:s.label,type:"number",unit:u}}),[{label:g.total,type:"number",unit:u}]),p=v.rows.map(function(s,m){return[s.label].concat(v.values[m],[s.total])});p.push([g.total].concat(v.cols.map(function(s){return s.total}),[v.total]));var _=v.rows.map(function(s,m){return[s.label].concat(v.values[m].map(function(f){return f?e.value(f):"\u2014"}),[e.value(s.total)])});_.push([g.total].concat(v.cols.map(function(s){return e.value(s.total)}),[e.value(v.total)]));var t=[];v.rows.forEach(function(s,m){v.cols.forEach(function(f,b){var k=v.values[m][b];k&&t.push([s.label,f.label,k,v.total?k/v.total:0])})}),t.sort(function(s,m){return m[2]-s[2]});var n=function(s){return i&&s>i+1e-12?"Yes":"No"},a=[[g.totalExposure,r.total,e.value(r.total)],[g.hhi,r.hhi,e.count(r.hhi)],["Effective number of cells",r.effectiveCells,e.count(Math.round(r.effectiveCells))],[g.top5,r.top5Share,e.percent(r.top5Share)]];r.largest&&a.push([g.largest,r.largest.share,r.largest.row+" \xD7 "+r.largest.column+" \xB7 "+e.percent(r.largest.share)]),i&&(a.push(["Limit (share of total)",i,yt(i)]),a.push([g.aboveLimit,r.aboveLimit.length,e.count(r.aboveLimit.length)]));var l=(h.annotations||[]).map(function(s,m){return[String(m+1),String(s.row||""),String(s.column||""),s.text||""]}),o=[{name:"Matrix",columns:c,rows:p,text:_,bold:p.map(function(s,m){return m===p.length-1})},{name:"Cells",columns:[{label:v.rowDim.label,type:"text"},{label:v.colDim.label,type:"text"},{label:g.exposure,type:"number",unit:u},{label:g.shareOfTotal,type:"percent",decimals:2},{label:g.aboveLimit,type:"text"}],rows:t.map(function(s){return[s[0],s[1],s[2],s[3],n(s[3])]}),text:t.map(function(s){return[s[0],s[1],e.value(s[2]),e.percent(s[3],2),n(s[3])]})},{name:"Concentration",columns:[{label:"Measure",type:"text"},{label:"Value",type:"general"},{label:"As shown",type:"text"}],rows:a,text:a.map(function(s){return[s[0],typeof s[1]=="number"?String(Number(s[1].toPrecision(10))):String(s[1]),s[2]]})}];return l.length&&o.push({name:"Notes",columns:[{label:"No.",type:"text"},{label:v.rowDim.label,type:"text"},{label:v.colDim.label,type:"text"},{label:"Note",type:"text"}],rows:l}),{title:w.title||"Exposure heatmap",subtitle:w.subtitle||"",summary:this.describe(),library:"Veyforma Exposure Heatmap "+Ct,sheets:o,meta:[["Method","HHI = 10,000 \xD7 sum of squared cell shares; effective number of cells = 10,000 \xF7 HHI; a cell is above the limit when its share is strictly greater"],["Grid",v.rowDim.label+" \xD7 "+v.colDim.label+", full grid without Other grouping"],["Unit",w.unit],["Limit",i?yt(i)+" of total":null],["As of",w.asOf],["Data source",w.source]]}},W.prototype._annotationPoint=function(h){var w=this._geom;if(!w||!h)return null;var g=It(w.rows,h.row),v=It(w.cols,h.column);if(g<0||v<0)return null;var e=w.rows[g]&&w.rows[g].other||w.cols[v]&&w.cols[v].other;return{x:w.cx(v)+w.gap/2+11,y:w.cy(g)+w.gap/2+11,inside:!0,where:e?"shown in Other":null}},W.prototype._annotationTarget=function(h){var w=this._geom,g,v;if(!w)return null;if(h){var e=h.target;if(!e||!e.getAttribute||e.getAttribute("data-r")==null)return null;g=+e.getAttribute("data-r"),v=+e.getAttribute("data-c")}else if(this._active)g=this._active[0],v=this._active[1];else return null;return!w.rows[g]||!w.cols[v]||w.rows[g].other||w.cols[v].other?null:{row:w.rows[g].label,column:w.cols[v].label}},W.prototype._annotationLabel=function(h){return[h.row,h.column].filter(Boolean).join(" \xD7 ")},Y.VeyHeatmap={version:Ct,create:function(h,w){return new W(h,w)},registerTheme:function(h,w){if(!h||typeof h!="string")throw new Error("VeyHeatmap: registerTheme needs a name.");return Mt[h]=At(w||{}),Mt[h]},getTheme:function(h){return At(h)},listThemes:function(){return Object.keys(Mt)}}})(typeof window<"u"?window:void 0);(function(Y){"use strict";var Ct="1.0.0",kt="http://www.w3.org/2000/svg",St=0,_t={down:"#4b5563",up:"#c2410c",hedge:"#2f6fed",contribution:"#a63d16",convexity:"#111827",limit:"#b91c1c",grid:"#ececec",axis:"#9ca3af",text:"#111827",mutedText:"#4b5563",axisText:"#4b5563",cardBackground:"#f9fafb",background:"transparent",tooltipBackground:"#111827",tooltipText:"#ffffff",focus:"#c2410c",accent:"#c2410c",fontFamily:"inherit",fontSize:12},Mt={veyforma:{},mono:{down:"#8a8a8a",up:"#111111",hedge:"#8a8a8a",contribution:"#111111",convexity:"#111111",limit:"#111111",accent:"#111111",focus:"#111111"},"colour-safe":{down:"#2166ac",up:"#b2182b",hedge:"#1b7837",contribution:"#762a83",limit:"#b2182b",accent:"#2166ac"},ocean:{down:"#64748b",up:"#0c6e8f",hedge:"#c2410c",contribution:"#0c3b5e",cardBackground:"#eef5f8",accent:"#0c6e8f"},forest:{down:"#78716c",up:"#4d6b31",hedge:"#2f6fed",contribution:"#22311a",cardBackground:"#f2f4ee",accent:"#4d6b31"},corporate:{down:"#64748b",up:"#1d4ed8",hedge:"#c2410c",contribution:"#1e293b",cardBackground:"#f1f4f8",accent:"#1d4ed8"},midnight:{background:"#111418",down:"#a3abb8",up:"#f08a5d",hedge:"#93c5fd",contribution:"#f08a5d",convexity:"#f3f4f6",limit:"#fb7185",grid:"#252a31",axis:"#4b5563",text:"#f3f4f6",mutedText:"#a3abb8",axisText:"#a3abb8",cardBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd",accent:"#f08a5d"}},At={data:null,view:"factors",sort:"swing",top:15,shockScale:1,whatIf:null,theme:"veyforma",locale:void 0,animate:!0,summary:!0,legend:!0,labels:null,ariaLabel:void 0,caption:!0,annotations:null,onAnnotationsChange:null,onItemClick:null,exportRows:2e4,toolbar:!0},ft={factors:"Impact by risk factor",groups:"Impact by group",contribution:"Share of the combined move",down:"Down shock",up:"Up shock",swing:"Swing",worst:"Worst result",convexity:"Convexity",linear:"Linear part",limit:"Limit",largest:"Largest driver",worstShock:"Worst single shock",topShare:"Top {n} factors",combined:"Combined move",contributionAdds:"Adds to the combined move",hedge:"Hedges (lowers it)",standalone:"Stand-alone",other:"Other {n} factors",whatIf:"What-if",interaction:"Interaction",noData:"n/a"};function wt(e){for(var r=1;r<arguments.length;r++){var i=arguments[r];if(i)for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(e[u]=i[u])}return e}var bt={};function ot(e){bt[e]||(bt[e]=1,Y.console&&console.warn&&console.warn("VeyRiskTornado: "+e))}function V(e){throw new Error("VeyRiskTornado: "+e)}function pt(e,r,i){return Math.min(i,Math.max(r,e))}function Rt(e,r){return String(e).replace(/\{(\w+)\}/g,function(i,u){return r[u]!=null?r[u]:i})}function $t(e){return e=String(e),/^[A-Z0-9]{2}/.test(e)?e:e.charAt(0).toLowerCase()+e.slice(1)}function ae(e){return typeof e=="number"?e:e==null||e===""?NaN:+e}function dt(e,r,i){var u=document.createElementNS(kt,e);if(r)for(var c in r)r[c]!=null&&u.setAttribute(c,r[c]);return i&&i.appendChild(u),u}function I(e,r,i){var u=document.createElement(e);return r&&(u.className=r),i&&i.appendChild(u),u}var J=null;function et(e,r,i,u){if(!J){var c=document.createElement("canvas");J=c.getContext&&c.getContext("2d")}return J?(J.font=(i||400)+" "+r+"px "+u,J.measureText(String(e)).width):String(e).length*r*.6}function ht(e,r,i,u,c){if(e=String(e),et(e,i,u,c)<=r)return e;for(;e.length>2&&et(e+"\u2026",i,u,c)>r;)e=e.slice(0,-1);return e.replace(/\s+$/,"")+"\u2026"}function Ft(e){var r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(e||"").trim());if(!r)return null;var i=r[1].length===3?r[1].replace(/./g,"$&$&"):r[1],u=parseInt(i,16);return[u>>16&255,u>>8&255,u&255]}function yt(e){var r=e.map(function(i){return i/=255,i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Dt(e,r){var i=Ft(e),u=Ft(r);if(!i||!u)return 21;var c=yt(i),p=yt(u);return(Math.max(c,p)+.05)/(Math.min(c,p)+.05)}function it(e,r,i){var u=Ft(e),c=Ft(r);if(!u||!c||Dt(e,r)>=i)return e;for(var p=yt(c)>.4,_=0,t=e;_<=1&&Dt(t,r)<i;)_+=.05,t="#"+u.map(function(n){var a=p?n*(1-_):n+(255-n)*_;return("0"+Math.round(a).toString(16)).slice(-2)}).join("");return t}function xt(e,r){var i=e.decimals!=null?e.decimals:0,u=e.ratioDecimals!=null?e.ratioDecimals:1,c=e.prefix||"",p=e.suffix||"",_={},t=e.negatives==="brackets";function n(f){return _[f]||(_[f]=new Intl.NumberFormat(r||void 0,{minimumFractionDigits:f,maximumFractionDigits:f})),_[f]}function a(f,b){if(f==null||!isFinite(f))return"\u2013";b==null&&(b=i);var k=Number(f.toFixed(b)),y=c+n(b).format(Math.abs(k))+p;return k>=0?y:t?"("+y+")":"\u2212"+y}function l(f,b){var k=a(f,b);return f!=null&&Number(f.toFixed(b??i))>0?"+"+k:k}function o(f,b){return f==null||!isFinite(f)?"\u2013":(f<0?"\u2212":"")+n(b??u).format(Math.abs(f)*100)+"%"}function s(f,b){if(f==null||!isFinite(f))return"\u2013";var k=b??Math.max(u,1),y=Number((f*100).toFixed(k));return(y>0?"+":y<0?"\u2212":"")+n(k).format(Math.abs(y))+" pp"}function m(f,b){return f==null||!isFinite(f)?"\u2013":n(b??1).format(f*100)+"%"}return{value:a,signed:l,ratio:o,pp:s,percent:m,nf:n}}function ut(e,r){var i=ae(e);return isFinite(i)||V(r+" must be a number."),i}function vt(e,r){var i=ut(e,r);return(i<-1||i>1)&&V(r+" must be between \u22121 and 1."),i}function Zt(e,r,i){var u=e.factors;(!Array.isArray(u)||!u.length)&&V("data.factors must be a non-empty array of risk factors.");var c={};return u.map(function(p,_){(!p||typeof p!="object")&&V("data.factors["+_+"] is not an object."),p.key==null&&p.label==null&&V("data.factors["+_+"] needs a key or a label.");var t=String(p.key!=null?p.key:p.label),n='factor "'+t+'"';c[t]&&V(n+" is used twice."),c[t]=1;var a=p.group!=null?String(p.group):"Other",l=p.shockDown!=null?ut(p.shockDown,n+": shockDown"):p.shock!=null?-Math.abs(ut(p.shock,n+": shock")):null,o=p.shockUp!=null?ut(p.shockUp,n+": shockUp"):p.shock!=null?Math.abs(ut(p.shock,n+": shock")):null,s,m,f;if(p.delta!=null){var b=ut(p.delta,n+": delta"),k=p.gamma!=null?ut(p.gamma,n+": gamma"):0;(l==null||o==null)&&V(n+": delta needs shockDown and shockUp (or shock).");var y=l*r,x=o*r;s=b*y+.5*k*y*y,m=b*x+.5*k*x*x,f="taylor"}else{(p.down==null||p.up==null)&&V(n+" needs down and up impacts, or delta (and gamma) with a shock.");var M=ut(p.down,n+": down"),d=ut(p.up,n+": up");if(r===1)s=M,m=d;else{var T=(d-M)/2,C=(d+M)/2;s=-T*r+C*r*r,m=T*r+C*r*r}f="revaluation"}var R=1;return i&&(i[t]!=null&&(R*=ut(i[t],"whatIf."+t)),i[a]!=null&&a!==t&&(R*=ut(i[a],"whatIf."+a))),{key:t,label:p.label!=null?String(p.label):t,group:a,unit:p.unit!=null?String(p.unit):"",shockDown:l==null?null:l*r,shockUp:o==null?null:o*r,down:s*R,up:m*R,source:f,index:_}})}function Tt(e,r,i){var u=e.length,c=new Array(u),p,_;if(r&&r.matrix){var t=r.matrix;for(p=0;p<u;p++){var n=0,a=t[p];for(_=0;_<u;_++)n+=(p===_?1:a[_])*i[_];c[p]=n}return c}var l=r?r.within:0,o=r?r.across:0,s={},m=0;for(p=0;p<u;p++)s[e[p].group]=(s[e[p].group]||0)+i[p],m+=i[p];for(p=0;p<u;p++){var f=s[e[p].group];c[p]=i[p]+l*(f-i[p])+o*(m-f)}return c}function Jt(e,r){var i=e.correlation;if(i==null)return null;if(typeof i!="object"&&V("data.correlation must be { within, across } or { matrix }."),i.matrix){var u=i.matrix;return(!Array.isArray(u)||u.length!==r||u.some(function(c){return!Array.isArray(c)||c.length!==r}))&&V("data.correlation.matrix must be square with one row per factor."),u.forEach(function(c,p){c.forEach(function(_,t){vt(_,"data.correlation.matrix["+p+"]["+t+"]")})}),{matrix:u}}return{within:i.within!=null?vt(i.within,"data.correlation.within"):0,across:i.across!=null?vt(i.across,"data.correlation.across"):0}}function Ht(e,r){r=r||{},(!e||typeof e!="object")&&V("data is required.");var i=r.shockScale!=null?ut(r.shockScale,"shockScale"):1;i>0||V("shockScale must be more than 0.");var u=r.whatIf&&Object.keys(r.whatIf).length?r.whatIf:null,c=Zt(e,i,u),p=c.length;u&&Object.keys(u).forEach(function(S){c.some(function(A){return A.key===S||A.group===S})||ot('whatIf: there is no factor or group "'+S+'", so it changes nothing.')});var _=e.higherIsBetter!==!1,t=function(S){return _?-S:S},n=e.limit!=null?Math.abs(ut(e.limit,"data.limit")):null,a=Jt(e,p),l=c.map(function(S){return(S.up-S.down)/2}),o=Tt(c,a,l),s=0,m;for(m=0;m<p;m++)s+=l[m]*o[m];var f=Math.sqrt(Math.max(0,s)),b=0,k=0,y=0,x=0;c.forEach(function(S,A){S.swing=Math.abs(S.up-S.down),S.linear=l[A],S.convexity=(S.up+S.down)/2,S.asymmetry=Math.abs(S.linear)+Math.abs(S.convexity)>0?Math.abs(S.convexity)/(Math.abs(S.linear)+Math.abs(S.convexity)):0,S.worst=t(S.down)>=t(S.up)?"down":"up",S.worstValue=S[S.worst],S.best=S.worst==="down"?"up":"down",S.breach=n!=null&&t(S.worstValue)>n+1e-12*Math.max(1,n),S.standalone=Math.abs(l[A]),S.contribution=f>0?l[A]*o[A]/f:0,b+=S.swing,k+=S.down,y+=S.up,x+=S.standalone});var M=c.slice().sort(r.sort==="worst"?function(S,A){return t(A.worstValue)-t(S.worstValue)||S.index-A.index}:function(S,A){return A.swing-S.swing||S.index-A.index}),d=0;M.forEach(function(S,A){S.rank=A+1,S.share=b>0?S.swing/b:0,d+=S.share,S.cumShare=d});var T={},C=[];c.forEach(function(S,A){var H=T[S.group];H||(H=T[S.group]={key:S.group,label:S.group,factors:[],idx:[],down:0,up:0,contribution:0,standaloneSum:0},C.push(H)),H.factors.push(S.key),H.idx.push(A),H.down+=S.down,H.up+=S.up,H.contribution+=S.contribution,H.standaloneSum+=S.standalone}),C.forEach(function(S){S.swing=Math.abs(S.up-S.down),S.linear=(S.up-S.down)/2,S.convexity=(S.up+S.down)/2,S.worst=t(S.down)>=t(S.up)?"down":"up",S.worstValue=S[S.worst],S.breach=n!=null&&t(S.worstValue)>n+1e-12*Math.max(1,n),S.share=b>0?S.swing/b:0;for(var A=S.idx.map(function(q){return c[q]}),H=S.idx.map(function(q){return l[q]}),lt=a&&a.matrix?{matrix:S.idx.map(function(q){return S.idx.map(function(X){return a.matrix[q][X]})})}:a,tt=Tt(A,lt,H),D=0,K=0;K<H.length;K++)D+=H[K]*tt[K];S.standalone=Math.sqrt(Math.max(0,D)),delete S.idx});var R=p>=10?5:Math.max(1,Math.ceil(p/2)),O=M.slice(0,R).reduce(function(S,A){return S+A.share},0),j={factors:c,order:M,groups:C,higherIsBetter:_,limit:n,base:e.base!=null?ut(e.base,"data.base"):null,totalSwing:b,sumDown:k,sumUp:y,sigma:f,standalone:x,diversification:x-f,correlated:!!a,topN:R,topShare:O,breaches:c.filter(function(S){return S.breach}).length,shockScale:i,whatIf:u};if(j.worstFactor=c.slice().sort(function(S,A){return t(A.worstValue)-t(S.worstValue)||S.index-A.index})[0],e.joint&&(e.joint.down!=null||e.joint.up!=null)&&(i===1&&!u?(j.joint={down:e.joint.down!=null?ut(e.joint.down,"data.joint.down"):null,up:e.joint.up!=null?ut(e.joint.up,"data.joint.up"):null},j.interaction={down:j.joint.down!=null?j.joint.down-k:null,up:j.joint.up!=null?j.joint.up-y:null}):j.jointHidden=!0),u){var E=Ht(e,{shockScale:i,sort:r.sort});j.baseline={totalSwing:E.totalSwing,sigma:E.sigma,worstValue:E.worstFactor.worstValue,worstFactor:E.worstFactor.key}}return j}function te(){if(!document.getElementById("vtr-styles")){var e=".vtr{position:relative;color:var(--vtr-text);background:var(--vtr-bg);font-family:var(--vtr-font);line-height:1.4}.vtr.vtr-filled{padding:14px 14px 8px;border-radius:10px}.vtr-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:0 0 10px}.vtr-stat{background:var(--vtr-card);border-radius:8px;padding:9px 12px;min-width:0}.vtr-stat .k{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vtr-card-muted);font-weight:600;overflow-wrap:anywhere;hyphens:auto}.vtr-stat .v{font-size:19px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vtr-stat .n{font-size:12px;color:var(--vtr-card-muted)}.vtr-stat .v.vtr-wrap{white-space:normal;overflow-wrap:anywhere;line-height:1.2;font-size:17px}.vtr-scope{font-size:12px;color:var(--vtr-muted);margin:0 0 4px}.vtr-legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;margin:0 0 6px;color:var(--vtr-text)}.vtr-legend span{display:inline-flex;align-items:center;gap:6px}.vtr-legend i{display:inline-block;width:12px;height:12px;border-radius:3px}.vtr-legend i.vtr-tick{width:3px;height:14px;border-radius:1px}.vtr-legend i.vtr-ring{background:transparent!important;border:2px solid;border-radius:2px;width:9px;height:9px;transform:rotate(45deg)}.vtr-plot{display:block;width:100%;height:auto;overflow:visible;outline:none}.vtr-plot:focus-visible{outline:2px solid var(--vtr-focus);outline-offset:4px;border-radius:4px}.vtr-animate .vtr-grow{animation:vtr-fade .45s ease both}@keyframes vtr-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vtr-animate .vtr-grow{animation:none}}.vtr-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vtr-tip-bg);color:var(--vtr-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}.vtr-tip.vtr-on{opacity:1;transform:none}.vtr-tip b{font-weight:600}.vtr-table{border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums;margin:0 0 14px;min-width:100%}.vtr-table caption{text-align:left;font-weight:700;padding:0 0 6px}.vtr-table th,.vtr-table td{padding:5px 8px;border-bottom:1px solid rgba(127,127,127,.25);text-align:right;white-space:nowrap}.vtr-table th:first-child,.vtr-table td:first-child{text-align:left}.vtr-table tr.vtr-breach td{color:var(--vtr-hedge);font-weight:600}@media (max-width:420px){.vtr-summary{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))}.vtr-stat{padding:8px 10px}.vtr-stat .v{font-size:17px}}",r=I("style");r.id="vtr-styles",r.textContent=e,(document.head||document.documentElement).appendChild(r)}}function Vt(e){var r;(e==null||e==="")&&(e="veyforma"),typeof e=="string"?(Mt.hasOwnProperty(e)||(ot('Unknown theme "'+e+'". The "veyforma" theme is used instead.'),e="veyforma"),r=wt({},_t,Mt[e])):typeof e=="object"?(r=wt(e.extends?Vt(e.extends):wt({},_t),e),delete r.extends):(ot("The theme option must be a theme name or an object."),r=wt({},_t));var i=/^#/.test(r.background)?r.background:"#ffffff",u=/^#/.test(r.cardBackground)?r.cardBackground:i;return["axisText","mutedText"].forEach(function(c){r[c]=it(r[c],i,4.5)}),r.cardMuted=it(r.mutedText,u,4.5),r.hedgeText=it(it(r.hedge,i,4.5),u,4.5),r.limitText=it(it(r.limit,i,4.5),u,4.5),r.accentText=it(r.accent,i,4.5),r}function W(e,r){var i=typeof e=="string"?document.querySelector(e):e;(!i||i.nodeType!==1)&&V("container not found ("+e+")."),(!r||!r.data)&&V("options.data is required."),te(),this.id=++St,this.container=i,this.options=wt({},At,r),this.element=I("div","vtr"),this.element.setAttribute("role","figure"),this.summaryEl=I("div","vtr-summary",this.element),this.scopeEl=I("p","vtr-scope",this.element),this.legendEl=I("div","vtr-legend",this.element),this.plotHost=I("div","vtr-plot-host",this.element),this.tipEl=I("div","vtr-tip",this.element),this.tipEl.setAttribute("role","tooltip"),i.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=-1;var u=this;Y.ResizeObserver?(this._observer=new Y.ResizeObserver(function(){var c=Math.round(u.element.clientWidth);c&&Math.abs(c-u._lastWidth)>1&&u.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){u.redraw()},Y.addEventListener("resize",this._onResize)),this._onDocTap=function(c){u.element.contains(c.target)||u._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&Y.VeyformaToolkit&&(this.toolkit=Y.VeyformaToolkit.attach(this,this.options.toolbar))}W.prototype.update=function(e){return e?(e.data&&e.data!==this.options.data&&this.options.animate&&(this._animateNext=!0),e.view&&e.view!==this.options.view&&this.options.animate&&(this._animateNext=!0),wt(this.options,e),this.redraw()):this},W.prototype.setData=function(e){return this._res=null,this.update({data:e})},W.prototype.setView=function(e){return this.update({view:e})},W.prototype.setTheme=function(e){return this.update({theme:e})},W.prototype.getTheme=function(){return Vt(this.options.theme)},W.prototype._opts=function(){return{shockScale:this.options.shockScale,whatIf:this.options.whatIf,sort:this.options.sort}},W.prototype.getResult=function(){return Ht(this.options.data,this._opts())},W.prototype.getFactor=function(e){return this.getResult().factors.filter(function(r){return r.key===String(e)})[0]||null},W.prototype.setWhatIf=function(e){return this.update({whatIf:e})},W.prototype.setShockScale=function(e){return this.update({shockScale:e})},W.prototype._labels=function(){return wt({},ft,this.options.labels)},W.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&Y.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},W.prototype._hideTip=function(){this.tipEl.classList.remove("vtr-on"),this._hlEl&&this._hlEl.setAttribute("opacity",0)},W.prototype._placeTip=function(e,r,i){var u=this.tipEl;u.textContent="",e.forEach(function(l,o){o&&u.appendChild(document.createElement("br"));var s=o===0?document.createElement("b"):document.createElement("span");s.textContent=l,u.appendChild(s)});var c=this.element.getBoundingClientRect(),p=i&&i.clientX?i.clientX:r.left+r.width/2,_=i&&i.clientY?i.clientY:r.top+10;u.classList.add("vtr-on");var t=u.offsetWidth,n=u.offsetHeight;u.style.left=pt(p-c.left-t/2,4,Math.max(4,c.width-t-4))+"px";var a=_-c.top-n-14;a<0&&(a=_-c.top+18),u.style.top=a+"px"};function It(e,r,i){r>e||(r=e+1);var u=r-e,c=Math.pow(10,Math.floor(Math.log(u/i)/Math.LN10)),p=u/i/c;p>=7.5?c*=10:p>=3.5?c*=5:p>=1.5&&(c*=2);for(var _=Math.floor(e/c+1e-9)*c,t=Math.ceil(r/c-1e-9)*c,n=[],a=_;a<=t+c/2;a+=c)n.push(Math.round(a/c)*c);return{lo:_,hi:t,ticks:n,step:c}}function h(e,r,i,u,c){var p=dt("text",wt({x:r,y:i},c||{}),e);return p.textContent=u,p}W.prototype._bindInteraction=function(e,r,i,u,c,p){var _=this,t=this._items,n=this.options;function a(o){for(var s=e.getBoundingClientRect(),m=(o.clientX-s.left)*(r/s.width),f=(o.clientY-s.top)*(i/s.height),b=0;b<t.length;b++){var k=t[b];if(m>=k.x&&m<=k.x+k.w&&f>=k.y&&f<=k.y+k.h)return b}return-1}function l(o,s){if(o<0){_._hideTip();return}_._active=o;var m=t[o],f=_._hlEl;f.setAttribute("x",m.x-4),f.setAttribute("y",m.y),f.setAttribute("width",m.w+8),f.setAttribute("height",m.h),f.setAttribute("opacity",1);var b=e.getBoundingClientRect(),k=b.width/r,y={left:b.left+m.px*k,top:b.top+m.py*(b.height/i),width:0,height:0};_._placeTip(_._tipLines(m),y,s&&s.clientX?s:null)}e.addEventListener("pointermove",function(o){l(a(o),o)}),e.addEventListener("pointerleave",function(){_._hideTip()}),e.addEventListener("click",function(o){var s=a(o);s>=0&&typeof n.onItemClick=="function"&&n.onItemClick(_._detail(t[s]),o)}),e.addEventListener("keydown",function(o){var s=_._active;if(o.key==="ArrowRight"||o.key==="ArrowDown")s=Math.min(t.length-1,s+1);else if(o.key==="ArrowLeft"||o.key==="ArrowUp")s=Math.max(0,s<0?0:s-1);else if(o.key==="Home")s=0;else if(o.key==="End")s=t.length-1;else if(o.key==="Escape"){_._hideTip();return}else if((o.key==="Enter"||o.key===" ")&&s>=0){typeof n.onItemClick=="function"&&n.onItemClick(_._detail(t[s]),o),o.preventDefault();return}else return;o.preventDefault(),l(s,null)}),e.addEventListener("blur",function(){_._hideTip()})},W.prototype.createTable=function(){var e=this.getExportData(),r=I("div","vtr-tables");return e.sheets.forEach(function(i){if(i.name!=="Notes"){var u=I("table","vtr-table",r);I("caption",null,u).textContent=i.name;var c=I("tr",null,I("thead",null,u));i.columns.forEach(function(_){var t=I("th",null,c);t.scope="col",t.textContent=_.label});var p=I("tbody",null,u);i.text.forEach(function(_,t){var n=I("tr",i.flag&&i.flag[t]?"vtr-breach":null,p);_.forEach(function(a,l){var o=I(l?"td":"th",null,n);l||(o.scope="row"),o.textContent=a})})}}),r};function w(e,r,i){if(e==null||!isFinite(e))return"";var u=Number(Math.abs(e).toFixed(4)).toLocaleString(i||void 0,{maximumFractionDigits:4});return(e>0?"+":e<0?"\u2212":"")+u+(r?r==="%"?"%":" "+r:"")}W.prototype.redraw=function(){var e=this.options,r=e.data,i=this._labels(),u=this._res=Ht(r,this._opts()),c=Vt(e.theme),p=xt(r,e.locale),_=this.element,t=_.style,n=c.fontFamily==="inherit"?Y.getComputedStyle?Y.getComputedStyle(this.container).fontFamily:"sans-serif":c.fontFamily,a=c.background&&c.background!=="transparent",l=a?c.background:"#ffffff";t.setProperty("--vtr-text",c.text),t.setProperty("--vtr-muted",c.mutedText),t.setProperty("--vtr-bg",a?c.background:"transparent"),t.setProperty("--vtr-font",n),t.setProperty("--vtr-card",c.cardBackground),t.setProperty("--vtr-card-muted",c.cardMuted),t.setProperty("--vtr-tip-bg",c.tooltipBackground),t.setProperty("--vtr-tip-text",c.tooltipText),t.setProperty("--vtr-focus",c.focus),t.setProperty("--vtr-hedge",c.limitText),_.classList.toggle("vtr-filled",!!a),_.setAttribute("aria-label",e.ariaLabel||r.title||"Risk-factor tornado");var o=e.view;["factors","groups","contribution"].indexOf(o)<0&&(ot('Unknown view "'+o+'". The factor view is shown instead.'),o="factors"),e.sort!=="swing"&&e.sort!=="worst"&&ot('Unknown sort "'+e.sort+'". Factors are ranked by swing instead.'),this._view=o,this._renderSummary(u,p,i);var s=[i[o],e.shockScale!=null&&+e.shockScale!=1?"shocks \xD7"+ +e.shockScale:null,r.unit||null,u.whatIf?i.whatIf+" applied":null].filter(Boolean).join(" \xB7 ");this.scopeEl.textContent=s,this._renderLegend(o,c,i,u);var m=Math.max(280,Math.round(this.plotHost.clientWidth||_.clientWidth||720));this._lastWidth=Math.round(_.clientWidth);var f=c.fontSize||12;this.plotHost.textContent="";var b=dt("svg",{class:"vtr-plot",role:"img",tabindex:0,"font-family":n},this.plotHost);b.style.fontSize=f+"px";var k=this._animateNext&&e.animate;this._animateNext=!1,k&&b.classList.add("vtr-animate");var y={svg:b,W:m,fs:f,theme:c,f:p,L:i,family:n,bg:l,res:u,items:[],points:{}},x=o==="contribution"?this._drawContribution(y):this._drawRows(y,o);return b.setAttribute("viewBox","0 0 "+m+" "+x),b.setAttribute("width",m),b.setAttribute("height",x),b.setAttribute("aria-label",(e.ariaLabel||r.title||"Risk-factor tornado")+". "+this.describe()),this._items=y.items,this._points=y.points,this._hlEl=dt("rect",{x:0,y:0,width:0,height:0,rx:4,fill:c.text,"fill-opacity":.06,opacity:0,"pointer-events":"none"},b),b.insertBefore(this._hlEl,b.firstChild),this._bindInteraction(b,m,x,c,i,p),this},W.prototype._shockNames=function(){var e=this._labels(),r=this.options.data.shockLabels||{};return{down:r.down||e.down,up:r.up||e.up}},W.prototype._renderSummary=function(e,r,i){var u=this.summaryEl,c=this.options;if(u.textContent="",u.style.display=c.summary===!1?"none":"",c.summary===!1)return;function p(a,l,o,s){var m=I("div","vtr-stat",u);I("div","k",m).textContent=a,I("div",s?"v vtr-wrap":"v",m).textContent=l,o&&(I("div","n",m).textContent=o)}var _=this._shockNames(),t=e.order[0],n=e.worstFactor;p(i.largest,t.label,i.swing.toLowerCase()+" "+r.value(t.swing)+" \xB7 "+r.percent(t.share,0)+" of the total",!0),p(i.worstShock,r.signed(n.worstValue),n.label+", "+_[n.worst].toLowerCase()+(e.limit!=null?e.breaches?" \xB7 "+e.breaches+" beyond the limit":" \xB7 within the limit":"")+(e.baseline?" \xB7 was "+r.signed(e.baseline.worstValue):"")),p(Rt(i.topShare,{n:e.topN}),r.percent(e.topShare,0),"of the total swing across "+e.factors.length+" factors"),p(i.combined,"\xB1"+r.value(e.sigma),e.baseline?i.whatIf+": was \xB1"+r.value(e.baseline.sigma):e.correlated?e.standalone>0?r.percent(e.diversification/e.standalone,0)+" below the sum of stand-alone moves":"":"factors treated as independent"),Array.prototype.forEach.call(u.querySelectorAll(".vtr-stat .v"),function(a){a.style.fontSize="";for(var l=parseFloat(Y.getComputedStyle?Y.getComputedStyle(a).fontSize:19)||19;a.scrollWidth>a.clientWidth&&l>12;)l-=1,a.style.fontSize=l+"px"})},W.prototype._renderLegend=function(e,r,i,u){var c=this.legendEl,p=this._shockNames();c.textContent="",c.style.display=this.options.legend===!1?"none":"";function _(t,n,a){var l=I("span",null,c),o=I("i",a||null,l);a==="vtr-ring"?o.style.borderColor=t:o.style.background=t,l.appendChild(document.createTextNode(n))}if(e==="contribution"){_(r.contribution,i.contributionAdds),_(r.hedge,i.hedge),_(r.convexity,i.standalone,"vtr-ring");return}_(r.down,p.down),_(r.up,p.up),u.factors.some(function(t){return t.asymmetry>=.1})&&_(r.convexity,i.convexity+" (midpoint)","vtr-ring"),u.limit!=null&&_(r.limit,i.limit,"vtr-tick")};function g(e,r){var i=Math.min(Math.max.apply(null,r.map(function(c){return et(c,e.fs,600,e.family)}))+12,e.W*.34),u=e.W-i<260;return{nameW:u?0:i,narrow:u}}function v(e,r,i,u,c,p,_,t,n){var a=e.theme,l=e.fs,o=e.family,s=e.W,m=e.f,f=-1/0,b=Math.max.apply(null,i.ticks.map(function(y){return et(m.value(y),l-1,400,o)})),k=Math.max(1,Math.ceil((b+10)/((_-p)/Math.max(1,i.ticks.length-1))));i.ticks.forEach(function(y,x){if(dt("line",{x1:u(y),x2:u(y),y1:t,y2:n,stroke:y===0?a.axis:a.grid,"stroke-width":y===0?1.2:1},r),!(x%k)){var M=m.value(y),d=et(M,l-1,400,o),T=d/2,C=u(y),R=C-T<0?"start":C+T>s?"end":"middle",O=R==="start"?C:R==="end"?C-d:C-T;O<f+8||(f=O+d,h(r,C,c+l,M,{"text-anchor":R,fill:a.axisText,"font-size":l-1,class:"vtr-tick"}))}})}W.prototype._rowsFor=function(e,r,i){if(r==="groups")return e.groups.slice().sort(function(a,l){return l.swing-a.swing}).map(function(a){return{kind:"group",obj:a,name:a.label,down:a.down,up:a.up,breach:a.breach,convexity:a.convexity,asym:Math.abs(a.linear)+Math.abs(a.convexity)>0?Math.abs(a.convexity)/(Math.abs(a.linear)+Math.abs(a.convexity)):0}});var u=+this.options.top>0?Math.floor(+this.options.top):e.order.length,c=e.order.slice(0,u).map(function(a){return{kind:"factor",obj:a,name:a.rank+". "+a.label,down:a.down,up:a.up,breach:a.breach,convexity:a.convexity,asym:a.asymmetry}}),p=e.order.slice(u);if(p.length){var _=0,t=0,n=0;p.forEach(function(a){_+=a.down,t+=a.up,n+=a.swing}),c.push({kind:"other",obj:{count:p.length,down:_,up:t,swing:n,share:e.totalSwing>0?n/e.totalSwing:0,factors:p},name:Rt(i.other,{n:p.length}),down:_,up:t,breach:!1,convexity:(_+t)/2,asym:0})}return c},W.prototype._drawRows=function(e,r){var i=e.res,u=e.theme,c=e.f,p=e.L,_=e.fs,t=e.family,n=e.W,a=e.svg,l=i.higherIsBetter,o=this._rowsFor(i,r,p),s=g(e,o.map(function(F){return F.name})),m=i.limit!=null?l?-i.limit:i.limit:null,f=[];o.forEach(function(F){f.push(F.down,F.up)});var b=Math.min.apply(null,f.concat([0,m??0])),k=Math.max.apply(null,f.concat([0,m??0])),y=function(F){return et(c.signed(F),_-1,600,t)+6},x=Math.max.apply(null,[4].concat(f.filter(function(F){return F<0}).map(y))),M=Math.max.apply(null,[4].concat(f.filter(function(F){return F>=0}).map(y))),d=s.nameW+x,T=n-M,C=It(b,k,Math.max(2,Math.min(6,Math.floor((T-d)/90)))),R=function(F){return d+(pt(F,C.lo,C.hi)-C.lo)/(C.hi-C.lo)*(T-d)},O=4,j=Math.max(36,_*3),E=s.narrow?_+4:0,S=O+_+6,A=S+o.length*(j+E),H=dt("g",{class:"vtr-rows"},a);v(e,H,C,R,O,d,T,S,A);var lt=dt("g",null,H),tt=dt("g",{class:"vtr-cvx-layer"},H),D=dt("g",null,H);m!=null&&dt("line",{x1:R(m),x2:R(m),y1:S-2,y2:A,stroke:u.limit,"stroke-width":1.6,"stroke-dasharray":"5 3",class:"vtr-limit"},tt);var K=this._shockNames(),q=this;o.forEach(function(F,B){var U=S+B*(j+E)+E,nt=Math.max(j*.32,_),st=U+(j-2*nt-3)/2,at=F.breach?u.limitText:F.kind==="other"?u.mutedText:u.text,zt=ht(F.name,s.narrow?n:s.nameW-8,_,F.kind==="other"?400:600,t);if(s.narrow&&dt("rect",{x:0,y:U-3-_*.95,width:et(zt,_,600,t)+4,height:_*1.25,fill:e.bg,class:"vtr-lbg"},D),h(D,0,s.narrow?U-3:U+j/2+_*.35,ht(F.name,s.narrow?n:s.nameW-8,_,F.kind==="other"?400:600,t),{fill:at,"font-size":_,"font-weight":F.kind==="other"?400:600,class:"vtr-name"}),[["down",st],["up",st+nt+3]].forEach(function(jt){var rt=F[jt[0]],Wt=R(Math.min(0,rt)),Kt=R(Math.max(0,rt)),ee=F.kind!=="other"&&F.obj.worst===jt[0];dt("rect",{x:Wt,y:jt[1],width:Math.max(.8,Kt-Wt),height:nt,rx:2,fill:u[jt[0]],class:"vtr-grow vtr-bar","data-shock":jt[0]},lt);var ne=F.breach&&ee,oe=c.signed(rt),Xt=et(oe,_-1,ne?700:400,t),ce=rt<0?Wt-4-Xt:Kt+4;dt("rect",{x:ce-2,y:jt[1]+nt/2-(_-1)*.6,width:Xt+4,height:(_-1)*1.2,fill:e.bg,class:"vtr-lbg"},D),h(D,rt<0?Wt-4:Kt+4,jt[1]+nt/2+(_-1)*.35,c.signed(rt),{"text-anchor":rt<0?"end":"start",fill:ne?u.limitText:u.text,"font-size":_-1,"font-weight":ne?700:400,class:"vtr-val"})}),F.asym>=.1){var mt=R(F.convexity),gt=st+nt+1.5;dt("path",{d:"M"+mt+","+(gt-4)+"L"+(mt+4)+","+gt+"L"+mt+","+(gt+4)+"L"+(mt-4)+","+gt+"Z",fill:e.bg,stroke:u.convexity,"stroke-width":1.5,class:"vtr-cvx"},tt)}var Et=R(Math.max(0,F.down,F.up));F.kind==="factor"&&(e.points[F.obj.key]={x:Et,y:st}),F.kind==="group"&&(e.points["group:"+F.obj.key]={x:Et,y:st}),e.items.push({kind:F.kind,obj:F.obj,x:0,y:U-E,w:n,h:j+E,px:Et,py:st})}),r==="groups"&&i.factors.forEach(function(F){e.points[F.key]||(e.points[F.key]=e.points["group:"+F.group])});var X=[];if(m!=null&&X.push(p.limit+" "+c.signed(m)+(i.breaches?": "+i.breaches+" factor"+(i.breaches>1?"s":"")+" beyond it":": no factor beyond it")),r==="factors"){var Q=o.filter(function(F){return F.kind==="factor"}).length;if(X.push("Each factor shocked alone"+(Q<i.factors.length?"; top "+Q+" of "+i.factors.length+", the rest summed":"")),i.interaction){var Z=i.interaction,P=[];Z.down!=null&&P.push(K.down.toLowerCase()+" together "+c.signed(i.joint.down)+" vs sum "+c.signed(i.sumDown)),Z.up!=null&&P.push(K.up.toLowerCase()+" together "+c.signed(i.joint.up)+" vs sum "+c.signed(i.sumUp)),X.push("All factors "+P.join(", "))}}else X.push("Every factor in the group shocked the same way at once (sum of single shocks)");var N=A+_+8;return X.forEach(function(F){h(a,0,N,ht(F+".",n,_-1,400,t),{fill:u.mutedText,"font-size":_-1,class:"vtr-note"}),N+=_+3}),Math.ceil(N-_+6)},W.prototype._drawContribution=function(e){var r=e.res,i=e.theme,u=e.f,c=e.L,p=e.fs,_=e.family,t=e.W,n=e.svg,a=r.factors.slice().sort(function(D,K){return Math.abs(K.contribution)-Math.abs(D.contribution)||D.index-K.index}),l=+this.options.top>0?Math.floor(+this.options.top):a.length,o=a.slice(l),s=a.slice(0,l).sort(function(D,K){return K.contribution-D.contribution}).map(function(D){return{kind:"factor",obj:D,name:D.label,v:D.contribution,k:D.standalone}});if(o.length){var m=0,f=0;o.forEach(function(D){m+=D.contribution,f+=D.standalone}),s.push({kind:"other",obj:{count:o.length,contribution:m,standalone:f,factors:o},name:Rt(c.other,{n:o.length}),v:m,k:null})}var b=g(e,s.map(function(D){return D.name})),k=Math.max.apply(null,s.map(function(D){return et(u.signed(D.v),p,700,_)}))+10,y=b.nameW,x=t-k,M=Math.max(24,p*2),d=b.narrow?p+4:0,T=4,C=Math.min(0,Math.min.apply(null,s.map(function(D){return D.v}))),R=Math.max.apply(null,s.map(function(D){return Math.max(D.v,D.k||0)}))||1,O=It(C,R,Math.max(2,Math.min(6,Math.floor((x-y)/90)))),j=function(D){return y+(pt(D,O.lo,O.hi)-O.lo)/(O.hi-O.lo)*(x-y)},E=T+p+6,S=E+s.length*(M+d),A=dt("g",{class:"vtr-contrib"},n);v(e,A,O,j,T,y,x,E,S),s.forEach(function(D,K){var q=E+K*(M+d)+d,X=M*.56,Q=q+(M-X)/2,Z=D.v<0;h(A,0,b.narrow?q-3:Q+X/2+p*.35,ht(D.name,b.narrow?t-k:b.nameW-8,p,D.kind==="other"?400:600,_),{fill:D.kind==="other"?i.mutedText:i.text,"font-size":p,"font-weight":D.kind==="other"?400:600,class:"vtr-name"});var P=j(Math.min(0,D.v)),N=j(Math.max(0,D.v));if(dt("rect",{x:P,y:Q,width:Math.max(.8,N-P),height:X,rx:2,fill:Z?i.hedge:i.contribution,class:"vtr-grow vtr-cbar"+(Z?" vtr-hedge":"")},A),D.k!=null){var F=j(D.k),B=Q+X/2;dt("path",{d:"M"+F+","+(B-5)+"L"+(F+5)+","+B+"L"+F+","+(B+5)+"L"+(F-5)+","+B+"Z",fill:e.bg,stroke:i.convexity,"stroke-width":1.6,class:"vtr-sa"},A)}h(A,t,Q+X/2+p*.35,u.signed(D.v),{"text-anchor":"end",fill:Z?i.hedgeText:i.text,"font-size":p,"font-weight":700,class:"vtr-val"}),D.kind==="factor"&&(e.points[D.obj.key]={x:Z?P:N,y:Q}),e.items.push({kind:D.kind,obj:D.obj,contrib:!0,x:0,y:q-d,w:t,h:M+d,px:Z?P:N,py:Q})});var H=r.correlated?this.options.data.correlation.matrix?"with the correlation matrix given":"with correlations of "+u.percent(this.options.data.correlation.within||0,0)+" within groups and "+u.percent(this.options.data.correlation.across||0,0)+" across":"no correlations given, so factors are treated as independent and none can hedge another",lt=["Shares add up to the combined move of \xB1"+u.value(r.sigma)+"; stand-alone moves add up to "+u.value(r.standalone),"Combined "+H],tt=S+p+8;return lt.forEach(function(D){h(n,0,tt,ht(D+".",t,p-1,400,_),{fill:i.mutedText,"font-size":p-1,class:"vtr-note"}),tt+=p+3}),Math.ceil(tt-p+6)},W.prototype._tipLines=function(e){var r=this.options,i=xt(r.data,r.locale),u=this._labels(),c=this._res,p=this._shockNames(),_=r.locale,t=function(s){return c.base!=null?" \u2192 "+i.value(c.base+s):""};if(e.kind==="other"){var n=e.obj;return e.contrib?[Rt(u.other,{n:n.count}),"Shares together "+i.signed(n.contribution)]:[Rt(u.other,{n:n.count}),p.down+" (sum) "+i.signed(n.down),p.up+" (sum) "+i.signed(n.up),u.swing+" together "+i.value(n.swing)+" ("+i.percent(n.share,0)+" of the total)"]}if(e.kind==="group"){var a=e.obj;return[a.label+" \xB7 "+a.factors.length+" factor"+(a.factors.length>1?"s":""),p.down+" "+i.signed(a.down)+t(a.down),p.up+" "+i.signed(a.up)+t(a.up),u.swing+" "+i.value(a.swing)+" ("+i.percent(a.share,0)+" of the total)","Combined move of the group \xB1"+i.value(a.standalone)+" \xB7 share of the total \xB1"+i.value(c.sigma)+": "+i.signed(a.contribution)].concat(a.breach?[u.worst+" beyond the limit"]:[])}var l=e.obj,o=[l.label,l.group+" \xB7 rank "+l.rank+" of "+c.factors.length,p.down+(l.shockDown!=null?" ("+w(l.shockDown,l.unit,_)+")":"")+" "+i.signed(l.down)+t(l.down),p.up+(l.shockUp!=null?" ("+w(l.shockUp,l.unit,_)+")":"")+" "+i.signed(l.up)+t(l.up),u.swing+" "+i.value(l.swing)+" \xB7 "+i.percent(l.share,0)+" of the total (top "+l.rank+": "+i.percent(l.cumShare,0)+")",u.linear+" \xB1"+i.value(Math.abs(l.linear))+" \xB7 "+u.convexity.toLowerCase()+" "+i.signed(l.convexity),"Share of the combined move "+i.signed(l.contribution)+" (stand-alone "+i.value(l.standalone)+")"];return l.breach&&o.push(p[l.worst]+" is beyond the limit of "+i.value(c.limit)),o},W.prototype._detail=function(e){if(!e)return null;var r=this._view;if(e.kind==="other")return{view:r,kind:"other",count:e.obj.count,down:e.obj.down,up:e.obj.up,swing:e.obj.swing,contribution:e.obj.contribution,factors:e.obj.factors.map(function(c){return c.key})};if(e.kind==="group"){var i=e.obj;return{view:r,kind:"group",key:i.key,label:i.label,factors:i.factors.slice(),down:i.down,up:i.up,swing:i.swing,share:i.share,linear:i.linear,convexity:i.convexity,worst:i.worst,worstValue:i.worstValue,breach:i.breach,contribution:i.contribution,standalone:i.standalone}}var u=e.obj;return{view:r,kind:"factor",key:u.key,label:u.label,group:u.group,unit:u.unit,shockDown:u.shockDown,shockUp:u.shockUp,down:u.down,up:u.up,swing:u.swing,share:u.share,cumShare:u.cumShare,rank:u.rank,linear:u.linear,convexity:u.convexity,asymmetry:u.asymmetry,worst:u.worst,worstValue:u.worstValue,breach:u.breach,contribution:u.contribution,standalone:u.standalone,source:u.source}},W.prototype.howToRead=function(){var e=this._view||this.options.view;return e==="contribution"?"Each bar is one factor's share of the combined move when all factors move together with their correlations. Shares add up exactly to the combined move; a bar to the left means the factor hedges the others. The diamond marks the factor's move on its own, so the gap between the diamond and the bar is diversification.":e==="groups"?"Each row is one group of factors, such as a risk class, with every factor in it shocked down (upper bar) and up (lower bar) at the same time. Rows are sorted by swing, the distance between the two results.":"Each row is one risk factor, shocked down (upper bar) and up (lower bar) on its own while everything else stays put. Rows are ranked by swing, the distance between the two results, so the factors that matter most are at the top. A diamond marks the midpoint of the two results when they are clearly unequal (convexity)"+(this._res&&this._res.limit!=null?"; the dashed line is the loss limit.":".")},W.prototype.describe=function(){var e=this.options,r=xt(e.data,e.locale),i=this._labels(),u=this._res||Ht(e.data,this._opts()),c=this._shockNames(),p=[],_=u.order[0];p.push("The largest driver is "+_.label+": "+c.down.toLowerCase()+" gives "+r.signed(_.down)+" and "+c.up.toLowerCase()+" "+r.signed(_.up)+", a swing of "+r.value(_.swing)+" ("+r.percent(_.share,0)+" of the total swing)."),u.factors.length>u.topN&&p.push("The top "+u.topN+" of "+u.factors.length+" factors explain "+r.percent(u.topShare,0)+".");var t=u.worstFactor;p.push("The worst single shock is "+t.label+" "+c[t.worst].toLowerCase()+" at "+r.signed(t.worstValue)+(u.limit!=null?u.breaches?", beyond the limit of "+r.value(u.limit)+" ("+u.breaches+" factor"+(u.breaches>1?"s":"")+" in all)":", within the limit of "+r.value(u.limit):"")+".");var n=u.factors.filter(function(o){return o.asymmetry>=.25&&o.swing>0}).sort(function(o,s){return Math.abs(s.convexity)-Math.abs(o.convexity)});if(n.length&&p.push(n.length+" factor"+(n.length>1?"s are":" is")+" strongly asymmetric, led by "+n[0].label+" (convexity "+r.signed(n[0].convexity)+"), so a bigger shock would cost more than in proportion."),u.correlated){var a=u.factors.slice().sort(function(o,s){return s.contribution-o.contribution}),l=u.factors.filter(function(o){return o.contribution<0}).sort(function(o,s){return o.contribution-s.contribution});p.push("Moving together with their correlations, the factors give a combined move of \xB1"+r.value(u.sigma)+", "+r.percent(u.standalone>0?u.diversification/u.standalone:0,0)+" less than the sum of their stand-alone moves; "+a[0].label+" contributes most ("+r.signed(a[0].contribution)+")"+(l.length?" and "+l[0].label+" hedges the most ("+r.signed(l[0].contribution)+")":"")+".")}return u.interaction&&u.interaction.down!=null&&p.push("Shocked all at once, the down case gives "+r.signed(u.joint.down)+" against "+r.signed(u.sumDown)+" for the sum of single shocks, an interaction of "+r.signed(u.interaction.down)+"."),u.baseline&&p.push("The what-if changes the worst single shock from "+r.signed(u.baseline.worstValue)+" to "+r.signed(t.worstValue)+"."),p.join(" ")},W.prototype.getExportData=function(){var e=this.options,r=e.data,i=this._labels(),u=xt(r,e.locale),c=this._res||Ht(r,this._opts()),p=this._shockNames(),_=e.locale,t={prefix:r.prefix||"",suffix:r.suffix||"",decimals:r.decimals!=null?r.decimals:0,negatives:r.negatives},n=function(d){return{label:d,type:"number",unit:t}},a=function(d){return{label:d,type:"number",unit:{decimals:4}}},l=function(d){return{label:d,type:"percent",decimals:1}},o=function(d){return{label:d,type:"text"}},s=[],m=e.exportRows!=null?e.exportRows:2e4,f=c.order,b=f.length>m;b&&(f=f.slice(0,m));var k=f.map(function(d){return[d.rank,d.label,d.group,d.unit,d.shockDown,d.shockUp,d.down,d.up,d.swing,d.share,d.cumShare,d.linear,d.convexity,p[d.worst],d.worstValue,d.breach?"Yes":"No",d.contribution,d.standalone]});s.push({name:"Factors",columns:[{label:"Rank",type:"number",unit:{decimals:0}},o("Risk factor"),o("Group"),o("Shock unit"),a("Shock down"),a("Shock up"),n(p.down),n(p.up),n(i.swing),l("Share of total swing"),l("Cumulative share"),n(i.linear),n(i.convexity),o("Worst shock"),n(i.worst),o("Beyond limit"),n("Share of combined move"),n("Stand-alone move")],rows:k,text:f.map(function(d){return[String(d.rank),d.label,d.group,d.unit,w(d.shockDown,"",_)||"\u2013",w(d.shockUp,"",_)||"\u2013",u.signed(d.down),u.signed(d.up),u.value(d.swing),u.percent(d.share),u.percent(d.cumShare),u.signed(d.linear),u.signed(d.convexity),p[d.worst],u.signed(d.worstValue),d.breach?"Yes":"No",u.signed(d.contribution),u.value(d.standalone)]}),flag:f.map(function(d){return d.breach})}),s.push({name:"Groups",columns:[o("Group"),{label:"Factors",type:"number",unit:{decimals:0}},n(p.down+" (sum)"),n(p.up+" (sum)"),n(i.swing),l("Share of total swing"),n(i.worst),o("Beyond limit"),n("Share of combined move"),n("Group combined move")],rows:c.groups.map(function(d){return[d.label,d.factors.length,d.down,d.up,d.swing,d.share,d.worstValue,d.breach?"Yes":"No",d.contribution,d.standalone]}),text:c.groups.map(function(d){return[d.label,String(d.factors.length),u.signed(d.down),u.signed(d.up),u.value(d.swing),u.percent(d.share),u.signed(d.worstValue),d.breach?"Yes":"No",u.signed(d.contribution),u.value(d.standalone)]}),flag:c.groups.map(function(d){return d.breach})});var y=[["Total swing",c.totalSwing],["Sum of "+p.down.toLowerCase()+" impacts",c.sumDown],["Sum of "+p.up.toLowerCase()+" impacts",c.sumUp]];c.joint&&(c.joint.down!=null&&y.push(["All factors "+p.down.toLowerCase()+" together",c.joint.down],[i.interaction+" ("+p.down.toLowerCase()+")",c.interaction.down]),c.joint.up!=null&&y.push(["All factors "+p.up.toLowerCase()+" together",c.joint.up],[i.interaction+" ("+p.up.toLowerCase()+")",c.interaction.up])),y.push([i.combined+" (\xB1)",c.sigma],["Sum of stand-alone moves",c.standalone],["Diversification",c.diversification]),c.limit!=null&&y.push([i.limit,c.limit]),s.push({name:"Summary",columns:[o("Item"),n("Amount")],rows:y,text:y.map(function(d){return[d[0],/Sum|Interaction|together/.test(d[0])?u.signed(d[1]):u.value(d[1])]})});var x=(e.annotations||[]).map(function(d,T){return[String(T+1),d.factor!=null?String(d.factor):"Group: "+String(d.group||""),d.text||""]});x.length&&s.push({name:"Notes",columns:[o("No."),o("Factor or group"),o("Note")],rows:x});var M=r.correlation;return{title:r.title||"Risk-factor tornado",subtitle:r.subtitle||"",summary:this.describe(),library:"Veyforma Risk-Factor Tornado "+Ct,sheets:s,meta:[["Unit",r.unit],["As of",r.asOf],["Desk",r.desk],["Measure",c.higherIsBetter?"Higher is better (for example P&L)":"Lower is better (for example capital)"],["Ranking",e.sort==="worst"?"By worst result":"By swing"],["Shocks",p.down+" / "+p.up+(c.shockScale!==1?", scaled \xD7"+c.shockScale:"")],["What-if",c.whatIf?Object.keys(c.whatIf).map(function(d){return d+" \xD7 "+c.whatIf[d]}).join(", "):null],["Correlation",M?M.matrix?"Matrix given":"Within groups "+(M.within||0)+", across "+(M.across||0):"None given (independent factors)"],["Limit",c.limit!=null?u.value(c.limit)+" ("+c.breaches+" beyond)":null],["Method","Impact = given down/up result, or \u0394\xB7s + \xBD\u0393\xB7s\xB2; swing = |up \u2212 down|; linear part L = (up \u2212 down) \xF7 2, convexity C = (up + down) \xF7 2; a shock k times larger \u2248 L\xB7k + C\xB7k\xB2; combined move \u03C3 = \u221A(L\u1D40 \u03C1 L); factor share = L_k (\u03C1L)_k \xF7 \u03C3 (Euler allocation, adds up to \u03C3)"+(b?"; factor sheet limited to the "+m+" largest swings":"")],["Data source",r.source]]}},W.prototype._annotationPoint=function(e){var r=this._points||{};return e.factor!=null?r[String(e.factor)]||null:e.group!=null&&r["group:"+String(e.group)]||null},W.prototype._annotationTarget=function(e){var r=this._items||[],i=null;if(!e)i=r[this._active];else for(var u=this.plotHost.querySelector("svg"),c=u.getBoundingClientRect(),p=u.viewBox.baseVal,_=(e.clientX-c.left)*(p.width/c.width),t=(e.clientY-c.top)*(p.height/c.height),n=0;n<r.length;n++){var a=r[n];if(_>=a.x&&_<=a.x+a.w&&t>=a.y&&t<=a.y+a.h){i=a;break}}return!i||i.kind==="other"?null:i.kind==="group"?{group:i.obj.key}:{factor:i.obj.key}},W.prototype._annotationLabel=function(e){if(e.group!=null)return String(e.group);var r=(this._res||this.getResult()).factors.filter(function(i){return i.key===String(e.factor)})[0];return r?r.label:String(e.factor||"")},Y.VeyRiskTornado={version:Ct,create:function(e,r){return new W(e,r)},compute:function(e,r){return Ht(e,r)},listThemes:function(){return Object.keys(Mt)},getTheme:function(e){return Vt(e)},defaults:{options:At,labels:ft,theme:_t}}})(typeof window<"u"?window:void 0);(function(Y){"use strict";var Ct="1.0.0",kt="http://www.w3.org/2000/svg",St=0,_t={hpl:"#111827",rtpl:"#c2410c",unexplained:"#6b7280",contribution:"#a63d16",offset:"#2f6fed",standalone:"#111827",zones:{green:"#15803d",amber:"#b45309",red:"#b91c1c"},outside:"#d1d5db",grid:"#ececec",axis:"#9ca3af",text:"#111827",mutedText:"#4b5563",axisText:"#4b5563",cardBackground:"#f9fafb",background:"transparent",tooltipBackground:"#111827",tooltipText:"#ffffff",focus:"#c2410c",accent:"#c2410c",fontFamily:"inherit",fontSize:12},Mt={veyforma:{},mono:{hpl:"#111111",rtpl:"#6b6b6b",unexplained:"#8a8a8a",contribution:"#111111",offset:"#8a8a8a",zones:{green:"#111111",amber:"#4b4b4b",red:"#111111"},accent:"#111111",focus:"#111111"},"colour-safe":{hpl:"#1f2937",rtpl:"#d55e00",unexplained:"#6b7280",contribution:"#cc3311",offset:"#0072b2",zones:{green:"#007a5e",amber:"#a35c00",red:"#b2182b"},accent:"#0072b2"},ocean:{hpl:"#0c3b5e",rtpl:"#0e7490",contribution:"#0c3b5e",offset:"#c2410c",cardBackground:"#eef5f8",accent:"#0e7490"},forest:{hpl:"#22311a",rtpl:"#4d6b31",contribution:"#22311a",offset:"#2f6fed",cardBackground:"#f2f4ee",accent:"#4d6b31"},corporate:{hpl:"#1e293b",rtpl:"#1d4ed8",contribution:"#1e293b",offset:"#c2410c",cardBackground:"#f1f4f8",accent:"#1d4ed8"},midnight:{background:"#111418",hpl:"#f3f4f6",rtpl:"#f08a5d",unexplained:"#8b93a1",contribution:"#f08a5d",offset:"#93c5fd",standalone:"#f3f4f6",zones:{green:"#4ade80",amber:"#fbbf24",red:"#fb7185"},outside:"#374151",grid:"#252a31",axis:"#4b5563",text:"#f3f4f6",mutedText:"#a3abb8",axisText:"#a3abb8",cardBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd",accent:"#f08a5d"}},At={spearmanGreen:.8,spearmanRed:.7,ksGreen:.09,ksRed:.12},ft={data:null,view:"factors",window:250,fix:null,thresholds:null,top:15,pathSteps:5,theme:"veyforma",locale:void 0,animate:!0,summary:!0,legend:!0,labels:null,ariaLabel:void 0,caption:!0,annotations:null,onAnnotationsChange:null,onItemClick:null,exportDays:2e4,toolbar:!0},wt={factors:"Unexplained P&L by risk factor",daily:"HPL and RTPL by day",distribution:"Distribution of HPL and RTPL",hpl:"HPL (front office)",rtpl:"RTPL (risk model)",unexplained:"Unexplained (HPL \u2212 RTPL)",adds:"Adds to unexplained volatility",offsets:"Offsets other gaps",standalone:"Gap on its own",test:"PLA test",unexplainedCard:"Unexplained P&L",largest:"Largest driver",path:"Path to green",green:"Green",amber:"Amber",red:"Red",na:"n/a",other:"Other {n} factors",unattributed:"Unattributed",notModelled:"not in the risk model",ifFixed:"If fixed",outside:"Outside the test window"};function bt(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(a)for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(t[l]=a[l])}return t}var ot={};function V(t){ot[t]||(ot[t]=1,Y.console&&console.warn&&console.warn("VeyPlaAttribution: "+t))}function pt(t){throw new Error("VeyPlaAttribution: "+t)}function Rt(t,n,a){return Math.min(a,Math.max(n,t))}function $t(t,n){return String(t).replace(/\{(\w+)\}/g,function(a,l){return n[l]!=null?n[l]:a})}function ae(t){return t=String(t),/^[A-Z0-9]{2}/.test(t)?t:t.charAt(0).toLowerCase()+t.slice(1)}function dt(t){return typeof t=="number"?t:t==null||t===""?NaN:+t}function I(t,n,a){var l=document.createElementNS(kt,t);if(n)for(var o in n)n[o]!=null&&l.setAttribute(o,n[o]);return a&&a.appendChild(l),l}function J(t,n,a){var l=document.createElement(t);return n&&(l.className=n),a&&a.appendChild(l),l}var et=null;function ht(t,n,a,l){if(!et){var o=document.createElement("canvas");et=o.getContext&&o.getContext("2d")}return et?(et.font=(a||400)+" "+n+"px "+l,et.measureText(String(t)).width):String(t).length*n*.6}function Ft(t,n,a,l,o){if(t=String(t),ht(t,a,l,o)<=n)return t;for(;t.length>2&&ht(t+"\u2026",a,l,o)>n;)t=t.slice(0,-1);return t.replace(/\s+$/,"")+"\u2026"}function yt(t){var n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(t||"").trim());if(!n)return null;var a=n[1].length===3?n[1].replace(/./g,"$&$&"):n[1],l=parseInt(a,16);return[l>>16&255,l>>8&255,l&255]}function Dt(t){var n=t.map(function(a){return a/=255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*n[0]+.7152*n[1]+.0722*n[2]}function it(t,n){var a=yt(t),l=yt(n);if(!a||!l)return 21;var o=Dt(a),s=Dt(l);return(Math.max(o,s)+.05)/(Math.min(o,s)+.05)}function xt(t,n,a){var l=yt(t),o=yt(n);if(!l||!o||it(t,n)>=a)return t;for(var s=Dt(o)>.4,m=0,f=t;m<=1&&it(f,n)<a;)m+=.05,f="#"+l.map(function(b){var k=s?b*(1-m):b+(255-b)*m;return("0"+Math.round(k).toString(16)).slice(-2)}).join("");return f}function ut(t,n){var a=t.decimals!=null?t.decimals:0,l=t.ratioDecimals!=null?t.ratioDecimals:1,o=t.prefix||"",s=t.suffix||"",m={},f=t.negatives==="brackets";function b(T){return m[T]||(m[T]=new Intl.NumberFormat(n||void 0,{minimumFractionDigits:T,maximumFractionDigits:T})),m[T]}function k(T,C){if(T==null||!isFinite(T))return"\u2013";C==null&&(C=a);var R=Number(T.toFixed(C)),O=o+b(C).format(Math.abs(R))+s;return R>=0?O:f?"("+O+")":"\u2212"+O}function y(T,C){var R=k(T,C);return T!=null&&Number(T.toFixed(C??a))>0?"+"+R:R}function x(T,C){return T==null||!isFinite(T)?"\u2013":(T<0?"\u2212":"")+b(C??l).format(Math.abs(T)*100)+"%"}function M(T,C){if(T==null||!isFinite(T))return"\u2013";var R=C??Math.max(l,1),O=Number((T*100).toFixed(R));return(O>0?"+":O<0?"\u2212":"")+b(R).format(Math.abs(O))+" pp"}function d(T,C){return T==null||!isFinite(T)?"\u2013":b(C??1).format(T*100)+"%"}return{value:k,signed:y,ratio:x,pp:M,percent:d,nf:b}}function vt(t,n){var a=dt(t);return isFinite(a)||pt(n+" must be a number."),a}function Zt(t){var n=t.length,a=new Array(n),l=new Array(n),o,s;for(o=0;o<n;o++)a[o]=o;for(a.sort(function(b,k){return t[b]-t[k]}),o=0;o<n;o=s){for(s=o;s<n&&t[a[s]]===t[a[o]];)s++;for(var m=(o+s+1)/2,f=o;f<s;f++)l[a[f]]=m}return l}function Tt(t,n){var a=t.length,l=0,o=0,s;for(s=0;s<a;s++)l+=t[s],o+=n[s];l/=a,o/=a;var m=0,f=0,b=0;for(s=0;s<a;s++){var k=t[s]-l,y=n[s]-o;m+=k*y,f+=k*k,b+=y*y}return f>0&&b>0?m/Math.sqrt(f*b):null}function Jt(t,n){return Tt(Zt(t),Zt(n))}function Ht(t,n){for(var a=t.slice().sort(function(M,d){return M-d}),l=n.slice().sort(function(M,d){return M-d}),o=a.length,s=l.length,m=0,f=0,b=0,k=a.length?a[0]:0;m<o&&f<s;){for(var y=Math.min(a[m],l[f]);m<o&&a[m]===y;)m++;for(;f<s&&l[f]===y;)f++;var x=Math.abs(m/o-f/s);x>b+1e-15&&(b=x,k=y)}return{d:b,at:k}}function te(t,n,a){return t==null?"red":(t=Math.round(t*1e12)/1e12,n=Math.round(n*1e12)/1e12,t>a.spearmanGreen&&n<a.ksGreen?"green":t<a.spearmanRed||n>a.ksRed?"red":"amber")}function Vt(t,n){return Math.max(0,n.spearmanGreen-(t.spearman==null?-1:t.spearman))/.1+Math.max(0,t.ks-n.ksGreen)/.03}function W(t,n,a){var l=Jt(t,n),o=Ht(t,n);return{spearman:l,ks:o.d,ksAt:o.at,zone:te(l,o.d,a)}}function It(t){var n=t.length,a=0,l=0,o;for(o=0;o<n;o++)a+=t[o];for(a/=n,o=0;o<n;o++)l+=(t[o]-a)*(t[o]-a);return Math.sqrt(l/n)}function h(t){for(var n=0,a=0;a<t.length;a++)n+=t[a];return t.length?n/t.length:0}function w(t){(!t||typeof t!="object")&&pt("data is required.");var n=t.dates;(!Array.isArray(n)||n.length<2)&&pt("data.dates must be an array of at least two days.");var a=n.length,l=function(x,M,d){return x==null&&d?null:((!Array.isArray(x)||x.length!==a)&&pt(M+" must be an array with one value per date ("+a+")."),x.map(function(T,C){return vt(T,M+"["+C+"]")}))};(!Array.isArray(t.factors)||!t.factors.length)&&pt("data.factors must be a non-empty array of risk factors.");var o={},s=t.factors.map(function(x,M){(!x||typeof x!="object")&&pt("data.factors["+M+"] is not an object."),x.key==null&&x.label==null&&pt("data.factors["+M+"] needs a key or a label.");var d=String(x.key!=null?x.key:x.label),T='factor "'+d+'"';o[d]&&pt(T+" is used twice."),o[d]=1;var C=l(x.hpl,T+": hpl"),R=l(x.rtpl,T+": rtpl",!0);return{key:d,label:x.label!=null?String(x.label):d,group:x.group!=null?String(x.group):"Other",modelled:R!=null,hpl:C,rtpl:R||C.map(function(){return 0}),index:M}}),m=l(t.hplTotal,"data.hplTotal",!0),f=l(t.rtplTotal,"data.rtplTotal",!0);if(m||f){var b=new Array(a),k=new Array(a),y;for(y=0;y<a;y++)b[y]=0,k[y]=0,s.forEach(function(x){b[y]+=x.hpl[y],k[y]+=x.rtpl[y]});s.push({key:"__unattributed",label:t.unattributedLabel||wt.unattributed,group:"Unattributed",modelled:!0,unattributed:!0,hpl:b.map(function(x,M){return m?m[M]-x:0}),rtpl:k.map(function(x,M){return f?f[M]-x:0}),index:s.length})}return{dates:n.map(String),factors:s,n:a}}function g(t,n){n=n||{};var a=w(t),l=a.n,o=a.factors,s=bt({},At,n.thresholds||{}),m=n.window!=null?Math.floor(vt(n.window,"window")):250;m>=2||pt("window must be at least 2 days.");var f=m>l;f&&(m=l);var b=l-m,k={};(n.fix||[]).forEach(function(P){o.some(function(N){return N.key===String(P)})||V('fix: there is no factor "'+P+'", so it changes nothing.'),k[String(P)]=1}),o.forEach(function(P){P.fixed=!!k[P.key],P.rt=P.fixed?P.hpl:P.rtpl,P.gap=P.hpl.map(function(N,F){return N-P.rt[F]})});var y=new Array(l),x=new Array(l),M=new Array(l),d,T;for(d=0;d<l;d++){var C=0,R=0;for(T=0;T<o.length;T++)C+=o[T].hpl[d],R+=o[T].rt[d];y[d]=C,x[d]=R,M[d]=C-R}var O=y.slice(b),j=x.slice(b),E=M.slice(b),S={dates:a.dates,hpl:y,rtpl:x,unexplained:M,start:b,window:m,shortWindow:f,thresholds:s,fixed:Object.keys(k)};S.test=W(O,j,s);var A=It(E),H=It(O),lt=h(E);S.sdUnexplained=A,S.sdHpl=H,S.meanUnexplained=lt,S.volRatio=H>0?A/H:null,S.meanRatio=H>0?lt/H:null,S.varRatio=H>0?A*A/(H*H):null,o.forEach(function(P){var N=P.gap.slice(b),F=h(N),B=0;for(d=0;d<m;d++)B+=(N[d]-F)*(E[d]-lt);for(B/=m,P.meanGap=F,P.sdGap=It(N),P.contribution=A>0?B/A:0,P.share=A>0?P.contribution/A:0,P.hplSum=0,P.rtplSum=0,d=b;d<l;d++)P.hplSum+=P.hpl[d],P.rtplSum+=P.rt[d];if(P.hasGap=P.sdGap>0||F!==0,P.hasGap){var U=j.map(function(nt,st){return nt+N[st]});P.ifFixed=W(O,U,s)}else P.ifFixed=S.test});var tt=o.slice().sort(function(P,N){return Math.abs(N.contribution)-Math.abs(P.contribution)||P.index-N.index});tt.forEach(function(P,N){P.rank=N+1}),S.factors=o,S.order=tt;for(var D=n.pathSteps!=null?Math.max(0,Math.floor(n.pathSteps)):5,K=[],q=j.slice(),X=S.test,Q={};X.zone!=="green"&&K.length<D;){var Z=null;if(o.forEach(function(P){if(!(Q[P.key]||P.fixed||!P.hasGap)){var N=P.gap.slice(b),F=q.map(function(nt,st){return nt+N[st]}),B=W(O,F,s),U=Vt(B,s);(!Z||U<Z.d-1e-12||Math.abs(U-Z.d)<=1e-12&&(B.spearman||-1)>(Z.t.spearman||-1))&&(Z={f:P,t:B,d:U,R:F})}}),!Z||Z.d>=Vt(X,s)-1e-12)break;Q[Z.f.key]=1,K.push({key:Z.f.key,label:Z.f.label,test:Z.t}),q=Z.R,X=Z.t}return S.path=K,S.pathReachesGreen=S.test.zone==="green"||K.length>0&&K[K.length-1].test.zone==="green",S.distribution={hpl:O.slice().sort(function(P,N){return P-N}),rtpl:j.slice().sort(function(P,N){return P-N})},S}function v(){if(!document.getElementById("vpa-styles")){var t=".vpa{position:relative;color:var(--vpa-text);background:var(--vpa-bg);font-family:var(--vpa-font);line-height:1.4}.vpa.vpa-filled{padding:14px 14px 8px;border-radius:10px}.vpa-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:0 0 10px}.vpa-stat{background:var(--vpa-card);border-radius:8px;padding:9px 12px;min-width:0}.vpa-stat .k{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vpa-card-muted);font-weight:600;overflow-wrap:anywhere;hyphens:auto}.vpa-stat .v{font-size:19px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vpa-stat .n{font-size:12px;color:var(--vpa-card-muted)}.vpa-stat .v.vpa-zone{font-weight:800}.vpa-stat .v.vpa-wrap{white-space:normal;overflow-wrap:anywhere;line-height:1.2;font-size:17px}.vpa-scope{font-size:12px;color:var(--vpa-muted);margin:0 0 4px}.vpa-legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;margin:0 0 6px;color:var(--vpa-text)}.vpa-legend span{display:inline-flex;align-items:center;gap:6px}.vpa-legend i{display:inline-block;width:12px;height:12px;border-radius:3px}.vpa-legend i.vpa-tick{width:16px;height:3px;border-radius:1px}.vpa-legend i.vpa-ring{background:transparent!important;border:2px solid;border-radius:2px;width:9px;height:9px;transform:rotate(45deg)}.vpa-plot{display:block;width:100%;height:auto;overflow:visible;outline:none}.vpa-plot:focus-visible{outline:2px solid var(--vpa-focus);outline-offset:4px;border-radius:4px}.vpa-animate .vpa-grow{animation:vpa-fade .45s ease both}@keyframes vpa-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vpa-animate .vpa-grow{animation:none}}.vpa-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vpa-tip-bg);color:var(--vpa-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}.vpa-tip.vpa-on{opacity:1;transform:none}.vpa-tip b{font-weight:600}.vpa-table{border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums;margin:0 0 14px;min-width:100%}.vpa-table caption{text-align:left;font-weight:700;padding:0 0 6px}.vpa-table th,.vpa-table td{padding:5px 8px;border-bottom:1px solid rgba(127,127,127,.25);text-align:right;white-space:nowrap}.vpa-table th:first-child,.vpa-table td:first-child{text-align:left}.vpa-table tr.vpa-breach td{color:var(--vpa-hedge);font-weight:600}@media (max-width:420px){.vpa-summary{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))}.vpa-stat{padding:8px 10px}.vpa-stat .v{font-size:17px}}",n=J("style");n.id="vpa-styles",n.textContent=t,(document.head||document.documentElement).appendChild(n)}}function e(t){var n;(t==null||t==="")&&(t="veyforma"),typeof t=="string"?(Mt.hasOwnProperty(t)||(V('Unknown theme "'+t+'". The "veyforma" theme is used instead.'),t="veyforma"),n=bt({},_t,Mt[t])):typeof t=="object"?(n=bt(t.extends?e(t.extends):bt({},_t),t),delete n.extends):(V("The theme option must be a theme name or an object."),n=bt({},_t));var a=/^#/.test(n.background)?n.background:"#ffffff",l=/^#/.test(n.cardBackground)?n.cardBackground:a;return["axisText","mutedText"].forEach(function(o){n[o]=xt(n[o],a,4.5)}),n.cardMuted=xt(n.mutedText,l,4.5),n.offsetText=xt(xt(n.offset,a,4.5),l,4.5),n.zoneText={},["green","amber","red"].forEach(function(o){n.zoneText[o]=xt(xt(n.zones[o],a,4.5),l,4.5)}),n.accentText=xt(n.accent,a,4.5),n}function r(t,n){var a=typeof t=="string"?document.querySelector(t):t;(!a||a.nodeType!==1)&&pt("container not found ("+t+")."),(!n||!n.data)&&pt("options.data is required."),v(),this.id=++St,this.container=a,this.options=bt({},ft,n),this.element=J("div","vpa"),this.element.setAttribute("role","figure"),this.summaryEl=J("div","vpa-summary",this.element),this.scopeEl=J("p","vpa-scope",this.element),this.legendEl=J("div","vpa-legend",this.element),this.plotHost=J("div","vpa-plot-host",this.element),this.tipEl=J("div","vpa-tip",this.element),this.tipEl.setAttribute("role","tooltip"),a.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=-1;var l=this;Y.ResizeObserver?(this._observer=new Y.ResizeObserver(function(){var o=Math.round(l.element.clientWidth);o&&Math.abs(o-l._lastWidth)>1&&l.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){l.redraw()},Y.addEventListener("resize",this._onResize)),this._onDocTap=function(o){l.element.contains(o.target)||l._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&Y.VeyformaToolkit&&(this.toolkit=Y.VeyformaToolkit.attach(this,this.options.toolbar))}r.prototype.update=function(t){return t?(t.data&&t.data!==this.options.data&&this.options.animate&&(this._animateNext=!0),t.view&&t.view!==this.options.view&&this.options.animate&&(this._animateNext=!0),bt(this.options,t),this.redraw()):this},r.prototype.setData=function(t){return this._res=null,this.update({data:t})},r.prototype.setView=function(t){return this.update({view:t})},r.prototype.setTheme=function(t){return this.update({theme:t})},r.prototype.getTheme=function(){return e(this.options.theme)},r.prototype._opts=function(){return{window:this.options.window,fix:this.options.fix,thresholds:this.options.thresholds}},r.prototype.getResult=function(){return g(this.options.data,this._opts())},r.prototype.getFactor=function(t){return this.getResult().factors.filter(function(n){return n.key===String(t)})[0]||null},r.prototype.setFix=function(t){return this.update({fix:t})},r.prototype.setWindow=function(t){return this.update({window:t})},r.prototype._labels=function(){return bt({},wt,this.options.labels)},r.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&Y.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},r.prototype._hideTip=function(){this.tipEl.classList.remove("vpa-on"),this._hlEl&&this._hlEl.setAttribute("opacity",0)},r.prototype._placeTip=function(t,n,a){var l=this.tipEl;l.textContent="",t.forEach(function(y,x){x&&l.appendChild(document.createElement("br"));var M=x===0?document.createElement("b"):document.createElement("span");M.textContent=y,l.appendChild(M)});var o=this.element.getBoundingClientRect(),s=a&&a.clientX?a.clientX:n.left+n.width/2,m=a&&a.clientY?a.clientY:n.top+10;l.classList.add("vpa-on");var f=l.offsetWidth,b=l.offsetHeight;l.style.left=Rt(s-o.left-f/2,4,Math.max(4,o.width-f-4))+"px";var k=m-o.top-b-14;k<0&&(k=m-o.top+18),l.style.top=k+"px"};function i(t,n,a){n>t||(n=t+1);var l=n-t,o=Math.pow(10,Math.floor(Math.log(l/a)/Math.LN10)),s=l/a/o;s>=7.5?o*=10:s>=3.5?o*=5:s>=1.5&&(o*=2);for(var m=Math.floor(t/o+1e-9)*o,f=Math.ceil(n/o-1e-9)*o,b=[],k=m;k<=f+o/2;k+=o)b.push(Math.round(k/o)*o);return{lo:m,hi:f,ticks:b,step:o}}function u(t,n,a,l,o){var s=I("text",bt({x:n,y:a},o||{}),t);return s.textContent=l,s}r.prototype._bindInteraction=function(t,n,a,l,o,s){var m=this,f=this._items,b=this.options;function k(x){for(var M=t.getBoundingClientRect(),d=(x.clientX-M.left)*(n/M.width),T=(x.clientY-M.top)*(a/M.height),C=0;C<f.length;C++){var R=f[C];if(d>=R.x&&d<=R.x+R.w&&T>=R.y&&T<=R.y+R.h)return C}return-1}function y(x,M){if(x<0){m._hideTip();return}m._active=x;var d=f[x],T=m._hlEl;T.setAttribute("x",d.x-4),T.setAttribute("y",d.y),T.setAttribute("width",d.w+8),T.setAttribute("height",d.h),T.setAttribute("opacity",1);var C=t.getBoundingClientRect(),R=C.width/n,O={left:C.left+d.px*R,top:C.top+d.py*(C.height/a),width:0,height:0};m._placeTip(m._tipLines(d),O,M&&M.clientX?M:null)}t.addEventListener("pointermove",function(x){y(k(x),x)}),t.addEventListener("pointerleave",function(){m._hideTip()}),t.addEventListener("click",function(x){var M=k(x);M>=0&&typeof b.onItemClick=="function"&&b.onItemClick(m._detail(f[M]),x)}),t.addEventListener("keydown",function(x){var M=m._active;if(x.key==="ArrowRight"||x.key==="ArrowDown")M=Math.min(f.length-1,M+1);else if(x.key==="ArrowLeft"||x.key==="ArrowUp")M=Math.max(0,M<0?0:M-1);else if(x.key==="Home")M=0;else if(x.key==="End")M=f.length-1;else if(x.key==="Escape"){m._hideTip();return}else if((x.key==="Enter"||x.key===" ")&&M>=0){typeof b.onItemClick=="function"&&b.onItemClick(m._detail(f[M]),x),x.preventDefault();return}else return;x.preventDefault(),y(M,null)}),t.addEventListener("blur",function(){m._hideTip()})},r.prototype.createTable=function(){var t=this.getExportData(),n=J("div","vpa-tables");return t.sheets.forEach(function(a){if(a.name!=="Notes"){var l=J("table","vpa-table",n);J("caption",null,l).textContent=a.name;var o=J("tr",null,J("thead",null,l));a.columns.forEach(function(m){var f=J("th",null,o);f.scope="col",f.textContent=m.label});var s=J("tbody",null,l);a.text.forEach(function(m,f){var b=J("tr",a.flag&&a.flag[f]?"vpa-breach":null,s);m.forEach(function(k,y){var x=J(y?"td":"th",null,b);y||(x.scope="row"),x.textContent=k})})}}),n},r.prototype.redraw=function(){var t=this.options,n=t.data,a=this._labels(),l=this._res=g(n,bt(this._opts(),{pathSteps:t.pathSteps})),o=e(t.theme),s=ut(n,t.locale),m=this.element,f=m.style,b=o.fontFamily==="inherit"?Y.getComputedStyle?Y.getComputedStyle(this.container).fontFamily:"sans-serif":o.fontFamily,k=o.background&&o.background!=="transparent",y=k?o.background:"#ffffff";f.setProperty("--vpa-text",o.text),f.setProperty("--vpa-muted",o.mutedText),f.setProperty("--vpa-bg",k?o.background:"transparent"),f.setProperty("--vpa-font",b),f.setProperty("--vpa-card",o.cardBackground),f.setProperty("--vpa-card-muted",o.cardMuted),f.setProperty("--vpa-tip-bg",o.tooltipBackground),f.setProperty("--vpa-tip-text",o.tooltipText),f.setProperty("--vpa-focus",o.focus),f.setProperty("--vpa-hedge",o.zoneText.red),m.classList.toggle("vpa-filled",!!k),m.setAttribute("aria-label",t.ariaLabel||n.title||"P&L attribution");var x=t.view;["factors","daily","distribution"].indexOf(x)<0&&(V('Unknown view "'+x+'". The factor view is shown instead.'),x="factors"),l.shortWindow&&!this._warnedShort&&(V("There are fewer days than the "+(t.window||250)+"-day window; all "+l.window+" are used."),this._warnedShort=!0),this._view=x,this._renderSummary(l,s,a,o),this.scopeEl.textContent=[a[x],l.window+"-day window",n.unit||null,l.fixed.length?l.fixed.length+" fix"+(l.fixed.length>1?"es":"")+" applied":null].filter(Boolean).join(" \xB7 "),this._renderLegend(x,o,a,l);var M=Math.max(280,Math.round(this.plotHost.clientWidth||m.clientWidth||720));this._lastWidth=Math.round(m.clientWidth);var d=o.fontSize||12;this.plotHost.textContent="";var T=I("svg",{class:"vpa-plot",role:"img",tabindex:0,"font-family":b},this.plotHost);T.style.fontSize=d+"px";var C=this._animateNext&&t.animate;this._animateNext=!1,C&&T.classList.add("vpa-animate");var R={svg:T,W:M,fs:d,theme:o,f:s,L:a,family:b,bg:y,res:l,items:[],points:{}},O=x==="daily"?this._drawDaily(R):x==="distribution"?this._drawDistribution(R):this._drawFactors(R);return T.setAttribute("viewBox","0 0 "+M+" "+O),T.setAttribute("width",M),T.setAttribute("height",O),T.setAttribute("aria-label",(t.ariaLabel||n.title||"P&L attribution")+". "+this.describe()),this._items=R.items,this._points=R.points,this._hlEl=I("rect",{x:0,y:0,width:0,height:0,rx:4,fill:o.text,"fill-opacity":.06,opacity:0,"pointer-events":"none"},T),T.insertBefore(this._hlEl,T.firstChild),this._bindInteraction(T,M,O,o,a,s),this};function c(t){return t==null?"n/a":t.toFixed(2)}r.prototype._zoneName=function(t){var n=this._labels();return n[t]||t},r.prototype._renderSummary=function(t,n,a,l){var o=this.summaryEl,s=this.options,m=this;if(o.textContent="",o.style.display=s.summary===!1?"none":"",s.summary===!1)return;function f(y,x,M,d,T){var C=J("div","vpa-stat",o);J("div","k",C).textContent=y;var R=J("div",d?"v "+d:"v",C);R.textContent=x,T&&(R.style.color=T),M&&(J("div","n",C).textContent=M)}var b=t.test,k=t.order[0];f(a.test,this._zoneName(b.zone),"Spearman "+c(b.spearman)+" \xB7 KS "+c(b.ks)+" ("+t.window+" days)","vpa-zone",l.zoneText[b.zone]),f(a.unexplainedCard,"\xB1"+n.value(t.sdUnexplained),(t.volRatio!=null?n.percent(t.volRatio,0)+" of HPL volatility \xB7 ":"")+"mean "+n.signed(t.meanUnexplained)+" a day"),f(a.largest,k.label,n.percent(k.share,0)+" of the unexplained volatility","vpa-wrap"),b.zone==="green"?f(a.path,"Already green","margin: Spearman +"+(b.spearman-t.thresholds.spearmanGreen).toFixed(2)+", KS \u2212"+(t.thresholds.ksGreen-b.ks).toFixed(2)):t.pathReachesGreen?f(a.path,"Fix "+t.path.length+" factor"+(t.path.length>1?"s":""),t.path.map(function(y){return y.label}).join(", ")+" \u2192 Spearman "+c(t.path[t.path.length-1].test.spearman)+", KS "+c(t.path[t.path.length-1].test.ks),"vpa-wrap"):f(a.path,t.path.length?"Not within "+t.path.length+" fix"+(t.path.length>1?"es":""):"No single fix helps",t.path.length?"best reached: "+this._zoneName(t.path[t.path.length-1].test.zone).toLowerCase():"the gap is spread across factors"),Array.prototype.forEach.call(o.querySelectorAll(".vpa-stat .v"),function(y){y.style.fontSize="";for(var x=parseFloat(Y.getComputedStyle?Y.getComputedStyle(y).fontSize:19)||19;y.scrollWidth>y.clientWidth&&x>12;)x-=1,y.style.fontSize=x+"px"})},r.prototype._renderLegend=function(t,n,a,l){var o=this.legendEl;o.textContent="",o.style.display=this.options.legend===!1?"none":"";function s(m,f,b){var k=J("span",null,o),y=J("i",b||null,k);b==="vpa-ring"?y.style.borderColor=m:y.style.background=m,k.appendChild(document.createTextNode(f))}if(t==="factors"){s(n.contribution,a.adds),s(n.offset,a.offsets),s(n.standalone,a.standalone,"vpa-ring");return}s(n.hpl,a.hpl,"vpa-tick"),s(n.rtpl,a.rtpl,"vpa-tick"),t==="daily"&&(s(n.unexplained,a.unexplained),l.start>0&&s(n.outside,a.outside))};function p(t,n){var a=Math.min(Math.max.apply(null,n.map(function(o){return ht(o,t.fs,600,t.family)}))+12,t.W*.34),l=t.W-a<300;return{nameW:l?0:a,narrow:l}}function _(t,n,a,l,o,s,m,f,b,k){var y=t.theme,x=t.fs,M=t.family,d=t.W,T=-1/0;a.ticks.forEach(function(C){I("line",{x1:l(C),x2:l(C),y1:f,y2:b,stroke:C===0?y.axis:y.grid,"stroke-width":C===0?1.2:1},n);var R=k(C),O=ht(R,x-1,400,M),j=l(C),E=j-O/2<0?"start":j+O/2>d?"end":"middle",S=E==="start"?j:E==="end"?j-O:j-O/2;S<T+8||(T=S+O,u(n,j,o+x,R,{"text-anchor":E,fill:y.axisText,"font-size":x-1,class:"vpa-tick"}))})}r.prototype._drawFactors=function(t){var n=t.res,a=t.theme,l=t.f,o=t.L,s=t.fs,m=t.family,f=t.W,b=t.svg,k=this,y=+this.options.top>0?Math.floor(+this.options.top):n.order.length,x=n.order.slice(y),M=n.order.slice(0,y).sort(function(N,F){return F.contribution-N.contribution}).map(function(N){return{kind:"factor",obj:N,name:N.label+(N.modelled?"":" *"),v:N.contribution,k:N.sdGap}});if(x.length){var d=0,T=0;x.forEach(function(N){d+=N.contribution,T+=N.sdGap}),M.push({kind:"other",obj:{count:x.length,contribution:d,factors:x},name:$t(o.other,{n:x.length}),v:d,k:null})}var C=p(t,M.map(function(N){return N.name})),R=Math.max(ht("\u2192 "+o.amber,s-1,600,m),ht("\u2192 "+o.green,s-1,600,m),ht("\u2192 "+o.red,s-1,600,m))+14,O=Math.max.apply(null,M.map(function(N){return ht(l.signed(N.v),s,700,m)}))+10,j=C.nameW,E=f-O-R,S=Math.max(26,s*2.1),A=C.narrow?s+4:0,H=4,lt=Math.min(0,Math.min.apply(null,M.map(function(N){return N.v}))),tt=Math.max.apply(null,M.map(function(N){return Math.max(N.v,N.k||0)}))||1,D=i(lt,tt,Math.max(2,Math.min(6,Math.floor((E-j)/90)))),K=function(N){return j+(Rt(N,D.lo,D.hi)-D.lo)/(D.hi-D.lo)*(E-j)},q=H+s+6,X=q+M.length*(S+A),Q=I("g",{class:"vpa-factors"},b);_(t,Q,D,K,H,j,E,q,X,function(N){return l.value(N)}),u(Q,f,H+s,o.ifFixed,{"text-anchor":"end",fill:a.axisText,"font-size":s-1,class:"vpa-tick"}),M.forEach(function(N,F){var B=q+F*(S+A)+A,U=S*.56,nt=B+(S-U)/2,st=N.v<0&&l.value(-N.v)!==l.value(0);u(Q,0,C.narrow?B-3:nt+U/2+s*.35,Ft(N.name,C.narrow?f-R:C.nameW-8,s,N.kind==="other"?400:600,m),{fill:N.kind==="other"?a.mutedText:a.text,"font-size":s,"font-weight":N.kind==="other"?400:600,class:"vpa-name"});var at=K(Math.min(0,N.v)),zt=K(Math.max(0,N.v));if(I("rect",{x:at,y:nt,width:Math.max(.8,zt-at),height:U,rx:2,fill:st?a.offset:a.contribution,class:"vpa-grow vpa-cbar"+(st?" vpa-offset":"")},Q),N.k!=null){var mt=K(N.k),gt=nt+U/2;I("path",{d:"M"+mt+","+(gt-5)+"L"+(mt+5)+","+gt+"L"+mt+","+(gt+5)+"L"+(mt-5)+","+gt+"Z",fill:t.bg,stroke:a.standalone,"stroke-width":1.6,class:"vpa-sa"},Q)}if(u(Q,f-R,nt+U/2+s*.35,l.signed(N.v),{"text-anchor":"end",fill:st?a.offsetText:a.text,"font-size":s,"font-weight":700,class:"vpa-val"}),N.kind==="factor"){var Et=N.obj.ifFixed.zone;u(Q,f,nt+U/2+s*.35,"\u2192 "+k._zoneName(Et),{"text-anchor":"end",fill:a.zoneText[Et],"font-size":s-1,"font-weight":600,class:"vpa-zonefix"}),t.points[N.obj.key]={x:st?at:zt,y:nt}}t.items.push({kind:N.kind,obj:N.obj,x:0,y:B-A,w:f,h:S+A,px:st?at:zt,py:nt})});var Z=["Shares add up to the unexplained volatility of \xB1"+l.value(n.sdUnexplained)+" a day over "+n.window+" days"];n.factors.some(function(N){return!N.modelled})&&Z.push("* "+o.notModelled+" (RTPL taken as zero)"),Z.push("\u201C"+o.ifFixed+"\u201D: test zone with that factor's RTPL set equal to its HPL");var P=X+s+8;return Z.forEach(function(N){u(b,0,P,Ft(N+".",f,s-1,400,m),{fill:a.mutedText,"font-size":s-1,class:"vpa-note"}),P+=s+3}),Math.ceil(P-s+6)},r.prototype._drawDaily=function(t){var n=t.res,a=t.theme,l=t.f,o=t.L,s=t.fs,m=t.family,f=t.W,b=t.svg,k=n.dates.length,y=n.hpl.concat(n.rtpl,n.unexplained),x=i(Math.min(0,Math.min.apply(null,y)),Math.max(0,Math.max.apply(null,y)),f<480?4:6),M=Math.max.apply(null,x.ticks.map(function(B){return ht(l.value(B),s-1,400,m)})),d=M+10,T=f-4,C=6,R=f<480?220:300,O=C+R,j=function(B){return d+(B+.5)/k*(T-d)},E=function(B){return C+(x.hi-Rt(B,x.lo,x.hi))/(x.hi-x.lo)*R},S=I("g",{class:"vpa-daily"},b);n.start>0&&I("rect",{x:d,y:C,width:j(n.start)-(T-d)/k/2-d,height:R,fill:a.outside,"fill-opacity":.35,class:"vpa-outside"},S),x.ticks.forEach(function(B){I("line",{x1:d,x2:T,y1:E(B),y2:E(B),stroke:B===0?a.axis:a.grid,"stroke-width":B===0?1.2:1},S),u(S,d-6,E(B)+(s-1)*.35,l.value(B),{"text-anchor":"end",fill:a.axisText,"font-size":s-1,class:"vpa-tick"})});var A=Math.max(.6,(T-d)/k*.7);n.unexplained.forEach(function(B,U){var nt=E(Math.max(0,B)),st=E(Math.min(0,B));I("rect",{x:j(U)-A/2,y:nt,width:A,height:Math.max(.6,st-nt),fill:a.unexplained,"fill-opacity":U<n.start?.4:.85,class:"vpa-grow vpa-ubar"},S)});var H=function(B){return B.map(function(U,nt){return(nt?"L":"M")+j(nt).toFixed(2)+","+E(U).toFixed(2)}).join("")};I("path",{d:H(n.hpl),fill:"none",stroke:a.hpl,"stroke-width":1.6,"stroke-linejoin":"round",class:"vpa-line vpa-hpl"},S),I("path",{d:H(n.rtpl),fill:"none",stroke:a.rtpl,"stroke-width":1.6,"stroke-dasharray":"4 2","stroke-linejoin":"round",class:"vpa-line vpa-rtpl"},S);for(var lt=ht(n.dates[0],s-1,400,m)+16,tt=Math.max(1,Math.ceil(lt/((T-d)/k))),D=-1/0,K=0;K<k;K+=tt){var q=j(K),X=ht(n.dates[K],s-1,400,m),Q=q-X/2<0?"start":q+X/2>f?"end":"middle",Z=Q==="start"?q:Q==="end"?q-X:q-X/2;Z<D+8||(D=Z+X,u(S,q,O+s+9,n.dates[K],{"text-anchor":Q,fill:a.axisText,"font-size":s-1,class:"vpa-tick"}))}var P=(T-d)/k;n.dates.forEach(function(B,U){t.items.push({kind:"day",index:U,x:j(U)-P/2,y:C,w:P,h:R,px:j(U),py:E(Math.max(n.hpl[U],n.rtpl[U]))}),t.points["date:"+B]={x:j(U),y:E(Math.max(n.hpl[U],n.rtpl[U]))}});var N=["Unexplained P&L \xB1"+l.value(n.sdUnexplained)+" a day ("+(n.volRatio!=null?l.percent(n.volRatio,0)+" of HPL volatility":"")+") over the last "+n.window+" days"],F=O+s*2+17;return N.forEach(function(B){u(b,0,F,Ft(B+".",f,s-1,400,m),{fill:a.mutedText,"font-size":s-1,class:"vpa-note"}),F+=s+3}),Math.ceil(F-s+6)},r.prototype._drawDistribution=function(t){var n=t.res,a=t.theme,l=t.f,o=t.L,s=t.fs,m=t.family,f=t.W,b=t.svg,k=n.distribution,y=k.hpl.length,x=n.thresholds,M=Math.min(k.hpl[0],k.rtpl[0]),d=Math.max(k.hpl[y-1],k.rtpl[y-1]),T=i(M,d,f<480?4:6),C=ht("100%",s-1,400,m)+10,R=f-6,O=8,j=f<480?200:270,E=O+j,S=function(at){return C+(Rt(at,T.lo,T.hi)-T.lo)/(T.hi-T.lo)*(R-C)},A=function(at){return O+(1-at)*j},H=I("g",{class:"vpa-dist"},b);[0,.25,.5,.75,1].forEach(function(at){I("line",{x1:C,x2:R,y1:A(at),y2:A(at),stroke:at===0?a.axis:a.grid},H),u(H,C-6,A(at)+(s-1)*.35,Math.round(at*100)+"%",{"text-anchor":"end",fill:a.axisText,"font-size":s-1,class:"vpa-tick"})}),_(t,H,T,S,E+8,C,R,O,E,function(at){return l.value(at)});var lt=function(at){var zt="M"+S(T.lo)+","+A(0);return at.forEach(function(mt,gt){zt+="L"+S(mt).toFixed(2)+","+A(gt/y).toFixed(2)+"L"+S(mt).toFixed(2)+","+A((gt+1)/y).toFixed(2)}),zt+"L"+S(T.hi)+","+A(1)};I("path",{d:lt(k.hpl),fill:"none",stroke:a.hpl,"stroke-width":1.8,class:"vpa-line vpa-hpl"},H),I("path",{d:lt(k.rtpl),fill:"none",stroke:a.rtpl,"stroke-width":1.8,"stroke-dasharray":"4 2",class:"vpa-line vpa-rtpl"},H);var tt=function(at,zt){for(var mt=0,gt=at.length;mt<gt;){var Et=mt+gt>>1;at[Et]<=zt?mt=Et+1:gt=Et}return mt/at.length},D=n.test.ksAt,K=tt(k.hpl,D),q=tt(k.rtpl,D),X=S(D),Q=n.test.zone;I("line",{x1:X,x2:X,y1:A(K),y2:A(q),stroke:a.zoneText[Q],"stroke-width":3,class:"vpa-ksline"},H);var Z="KS "+c(n.test.ks),P=ht(Z,s,700,m),N=X+8+P>f?X-8:X+8;I("rect",{x:(X+8+P>f?N-P:N)-3,y:(A(K)+A(q))/2-s*.7,width:P+6,height:s*1.4,rx:3,fill:t.bg,class:"vpa-lbg"},H),u(H,N,(A(K)+A(q))/2+s*.35,Z,{"text-anchor":X+8+P>f?"end":"start",fill:a.zoneText[Q],"font-size":s,"font-weight":700,class:"vpa-kslabel"});for(var F=0;F<=20;F++){var B=T.lo+(T.hi-T.lo)*F/20,U=(R-C)/20;t.items.push({kind:"point",value:B,ph:tt(k.hpl,B),pr:tt(k.rtpl,B),x:S(B)-U/2,y:O,w:U,h:j,px:S(B),py:A(Math.max(tt(k.hpl,B),tt(k.rtpl,B)))})}var nt=["Spearman "+c(n.test.spearman)+" (green above "+x.spearmanGreen.toFixed(2)+", red below "+x.spearmanRed.toFixed(2)+") \xB7 KS "+c(n.test.ks)+" (green below "+x.ksGreen.toFixed(2)+", red above "+x.ksRed.toFixed(2)+")","Share of the "+n.window+" days with P&L at or below each value"],st=E+s*2+12;return nt.forEach(function(at){u(b,0,st,Ft(at+".",f,s-1,400,m),{fill:a.mutedText,"font-size":s-1,class:"vpa-note"}),st+=s+3}),Math.ceil(st-s+6)},r.prototype._tipLines=function(t){var n=this.options,a=ut(n.data,n.locale),l=this._labels(),o=this._res,s=this;if(t.kind==="other")return[$t(l.other,{n:t.obj.count}),"Together "+a.signed(t.obj.contribution)+" of the unexplained volatility"];if(t.kind==="day"){var m=t.index,f=o.factors.map(function(y){return{l:y.label,g:y.gap[m]}}).filter(function(y){return y.g!==0}).sort(function(y,x){return Math.abs(x.g)-Math.abs(y.g)}).slice(0,3);return[o.dates[m]+(m<o.start?" \xB7 "+l.outside.toLowerCase():""),l.hpl+" "+a.signed(o.hpl[m]),l.rtpl+" "+a.signed(o.rtpl[m]),l.unexplained+" "+a.signed(o.unexplained[m])].concat(f.length?["Largest gaps: "+f.map(function(y){return y.l+" "+a.signed(y.g)}).join(", ")]:[])}if(t.kind==="point")return["P&L at or below "+a.signed(t.value),"HPL "+a.percent(t.ph,0)+" of days \xB7 RTPL "+a.percent(t.pr,0),"Gap "+a.percent(Math.abs(t.ph-t.pr),0)+" (KS is the largest gap: "+c(o.test.ks)+")"];var b=t.obj,k=b.ifFixed;return[b.label+(b.modelled?"":" ("+l.notModelled+")"),b.group+" \xB7 rank "+b.rank+" of "+o.factors.length,"Share of unexplained volatility "+a.signed(b.contribution)+" ("+a.percent(b.share,0)+")","Gap on its own \xB1"+a.value(b.sdGap)+" a day \xB7 mean "+a.signed(b.meanGap),"HPL "+a.signed(b.hplSum)+" \xB7 RTPL "+a.signed(b.rtplSum)+" over "+o.window+" days",l.ifFixed+": "+s._zoneName(k.zone).toLowerCase()+" (Spearman "+c(k.spearman)+", KS "+c(k.ks)+")"]},r.prototype._detail=function(t){if(!t)return null;var n=this._res,a=this._view;if(t.kind==="other")return{view:a,kind:"other",count:t.obj.count,contribution:t.obj.contribution,factors:t.obj.factors.map(function(s){return s.key})};if(t.kind==="day"){var l=t.index;return{view:a,kind:"day",date:n.dates[l],hpl:n.hpl[l],rtpl:n.rtpl[l],unexplained:n.unexplained[l],inWindow:l>=n.start,gaps:n.factors.map(function(s){return{key:s.key,gap:s.gap[l]}})}}if(t.kind==="point")return{view:a,kind:"point",value:t.value,hplShare:t.ph,rtplShare:t.pr};var o=t.obj;return{view:a,kind:"factor",key:o.key,label:o.label,group:o.group,modelled:o.modelled,fixed:o.fixed,rank:o.rank,contribution:o.contribution,share:o.share,sdGap:o.sdGap,meanGap:o.meanGap,hplSum:o.hplSum,rtplSum:o.rtplSum,ifFixed:{spearman:o.ifFixed.spearman,ks:o.ifFixed.ks,zone:o.ifFixed.zone}}},r.prototype.howToRead=function(){var t=this._view||this.options.view;return t==="daily"?"The dark line is front-office hypothetical P&L (HPL) and the dashed line the risk model's P&L (RTPL), day by day. Grey bars are the difference, the unexplained P&L. Only the most recent days, inside the test window, count for the test.":t==="distribution"?"Each line shows the share of days with P&L at or below a value, for HPL and for RTPL. If the risk model matched the front office, the two lines would sit on top of each other. The coloured bar marks the largest gap between them, the Kolmogorov-Smirnov (KS) statistic.":"Each bar is one risk factor's share of the unexplained P&L volatility (HPL \u2212 RTPL). Shares add up exactly to the total; a bar to the left means the factor's gap offsets other gaps. The diamond is the factor's gap on its own, and the right column shows the test zone the desk would reach if that factor's gap were closed."},r.prototype.describe=function(){var t=this.options,n=ut(t.data,t.locale),a=this._labels(),l=this._res||g(t.data,this._opts()),o=l.test,s=l.thresholds,m=[],f=this,b=[];(o.spearman==null||o.spearman<=s.spearmanGreen)&&b.push("Spearman "+c(o.spearman)+(o.spearman!=null&&o.spearman>=s.spearmanRed?" is below "+s.spearmanGreen.toFixed(2):" is below "+s.spearmanRed.toFixed(2))),o.ks>=s.ksGreen&&b.push("KS "+c(o.ks)+(o.ks<=s.ksRed?" is above "+s.ksGreen.toFixed(2):" is above "+s.ksRed.toFixed(2))),m.push("Over the last "+l.window+" days the desk is in the "+this._zoneName(o.zone).toLowerCase()+" zone of the P&L attribution test"+(b.length?": "+b.join(" and ")+".":" (Spearman "+c(o.spearman)+", KS "+c(o.ks)+").")),m.push("Unexplained P&L is \xB1"+n.value(l.sdUnexplained)+" a day"+(l.volRatio!=null?", "+n.percent(l.volRatio,0)+" of the front office's P&L volatility":"")+".");var k=l.order[0],y=l.order[1];m.push(k.label+(k.modelled?"":", which is not in the risk model,")+" explains "+n.percent(k.share,0)+" of it"+(y?", followed by "+y.label+" ("+n.percent(y.share,0)+")":"")+".");var x=l.factors.filter(function(d){return d.share<-.02}).sort(function(d,T){return d.contribution-T.contribution});if(x.length&&m.push("The gap on "+x[0].label+" partly offsets the others."),o.zone!=="green")if(l.pathReachesGreen){var M=l.path[l.path.length-1].test;m.push("Closing the gap on "+l.path.map(function(d){return d.label}).join(" and ")+" would bring the desk to green (Spearman "+c(M.spearman)+", KS "+c(M.ks)+").")}else l.path.length&&m.push("Even closing the gaps on "+l.path.map(function(d){return d.label}).join(", ")+" only reaches "+this._zoneName(l.path[l.path.length-1].test.zone).toLowerCase()+".");return l.fixed.length&&m.push("Fixes applied: "+l.fixed.join(", ")+"."),m.join(" ")},r.prototype.getExportData=function(){var t=this.options,n=t.data,a=this._labels(),l=ut(n,t.locale),o=this._res||g(n,this._opts()),s=this,m=o.thresholds,f={prefix:n.prefix||"",suffix:n.suffix||"",decimals:n.decimals!=null?n.decimals:0,negatives:n.negatives},b=function(E){return{label:E,type:"number",unit:f}},k=function(E){return{label:E,type:"number",unit:{decimals:3}}},y=function(E){return{label:E,type:"percent",decimals:1}},x=function(E){return{label:E,type:"text"}},M=[];M.push({name:"Factors",columns:[{label:"Rank",type:"number",unit:{decimals:0}},x("Risk factor"),x("Group"),x("In risk model"),x("Fixed"),b("HPL over window"),b("RTPL over window"),b("Mean daily gap"),b("Gap volatility"),b("Share of unexplained volatility"),y("Share (%)"),k("Spearman if fixed"),k("KS if fixed"),x("Zone if fixed")],rows:o.order.map(function(E){return[E.rank,E.label,E.group,E.modelled?"Yes":"No",E.fixed?"Yes":"No",E.hplSum,E.rtplSum,E.meanGap,E.sdGap,E.contribution,E.share,E.ifFixed.spearman,E.ifFixed.ks,s._zoneName(E.ifFixed.zone)]}),text:o.order.map(function(E){return[String(E.rank),E.label,E.group,E.modelled?"Yes":"No",E.fixed?"Yes":"No",l.signed(E.hplSum),l.signed(E.rtplSum),l.signed(E.meanGap),l.value(E.sdGap),l.signed(E.contribution),l.percent(E.share),c(E.ifFixed.spearman),c(E.ifFixed.ks),s._zoneName(E.ifFixed.zone)]}),flag:o.order.map(function(E){return!E.modelled})});for(var d=t.exportDays!=null?t.exportDays:2e4,T=Math.max(0,o.dates.length-d),C=[],R=T;R<o.dates.length;R++)C.push(R);M.push({name:"Daily",columns:[x("Date"),b("HPL"),b("RTPL"),b("Unexplained"),x("In test window")],rows:C.map(function(E){return[o.dates[E],o.hpl[E],o.rtpl[E],o.unexplained[E],E>=o.start?"Yes":"No"]}),text:C.map(function(E){return[o.dates[E],l.signed(o.hpl[E]),l.signed(o.rtpl[E]),l.signed(o.unexplained[E]),E>=o.start?"Yes":"No"]})});var O=[["Spearman correlation",o.test.spearman,"green above "+m.spearmanGreen+", red below "+m.spearmanRed],["Kolmogorov-Smirnov statistic",o.test.ks,"green below "+m.ksGreen+", red above "+m.ksRed],["Unexplained volatility \xF7 HPL volatility",o.volRatio,""],["Mean unexplained \xF7 HPL volatility",o.meanRatio,""],["Variance of unexplained \xF7 variance of HPL",o.varRatio,""]];o.path.forEach(function(E,S){O.push(["Path step "+(S+1)+": fix "+E.label+" \u2192 Spearman",E.test.spearman,s._zoneName(E.test.zone)],["Path step "+(S+1)+": fix "+E.label+" \u2192 KS",E.test.ks,s._zoneName(E.test.zone)])}),M.push({name:"Test",columns:[x("Measure"),k("Value"),x("Note")],rows:O,text:O.map(function(E){return[E[0],E[1]==null?"n/a":E[1].toFixed(3),E[2]]})});var j=(t.annotations||[]).map(function(E,S){return[String(S+1),E.factor!=null?String(E.factor):"Date: "+String(E.date||""),E.text||""]});return j.length&&M.push({name:"Notes",columns:[x("No."),x("Factor or date"),x("Note")],rows:j}),{title:n.title||"P&L attribution",subtitle:n.subtitle||"",summary:this.describe(),library:"Veyforma P&L Attribution "+Ct,sheets:M,meta:[["Unit",n.unit],["As of",n.asOf],["Desk",n.desk],["Test window",o.window+" days ("+o.dates[o.start]+" to "+o.dates[o.dates.length-1]+")"],["PLA test zone",s._zoneName(o.test.zone)+" (Spearman "+c(o.test.spearman)+", KS "+c(o.test.ks)+")"],["Fixes applied",o.fixed.length?o.fixed.join(", "):null],["Method","Spearman = correlation of the ranks of daily HPL and RTPL (ties averaged); KS = largest gap between their empirical distribution functions; green if Spearman > "+m.spearmanGreen+" and KS < "+m.ksGreen+", red if Spearman < "+m.spearmanRed+" or KS > "+m.ksRed+`, otherwise amber; factor share = cov(gap, unexplained) \xF7 sd(unexplained), adds up to sd(unexplained); "if fixed" sets that factor's RTPL equal to its HPL`+(T>0?"; daily sheet limited to the last "+d+" days":"")],["Data source",n.source]]}},r.prototype._annotationPoint=function(t){var n=this._points||{};return t.factor!=null?n[String(t.factor)]||null:t.date!=null&&n["date:"+String(t.date)]||null},r.prototype._annotationTarget=function(t){var n=this._items||[],a=null;if(!t)a=n[this._active];else for(var l=this.plotHost.querySelector("svg"),o=l.getBoundingClientRect(),s=l.viewBox.baseVal,m=(t.clientX-o.left)*(s.width/o.width),f=(t.clientY-o.top)*(s.height/o.height),b=0;b<n.length;b++){var k=n[b];if(m>=k.x&&m<=k.x+k.w&&f>=k.y&&f<=k.y+k.h){a=k;break}}return a?a.kind==="factor"?{factor:a.obj.key}:a.kind==="day"?{date:this._res.dates[a.index]}:null:null},r.prototype._annotationLabel=function(t){if(t.date!=null)return String(t.date);var n=(this._res||this.getResult()).factors.filter(function(a){return a.key===String(t.factor)})[0];return n?n.label:String(t.factor||"")},Y.VeyPlaAttribution={version:Ct,create:function(t,n){return new r(t,n)},compute:function(t,n){return g(t,n)},test:function(t,n,a){return W(t,n,bt({},At,a||{}))},thresholds:At,listThemes:function(){return Object.keys(Mt)},getTheme:function(t){return e(t)},defaults:{options:ft,labels:wt,theme:_t}}})(typeof window<"u"?window:void 0);(function(Y){"use strict";function Ct(kt){var St=Y[kt];if(!St)throw new Error("VeyformaCharts: "+kt+" is not loaded. Load its script before veyforma-charts.js, or use the bundled dist/veyforma-charts.js.");return St}Y.VeyformaCharts={version:"1.0.2",heatmap:function(kt,St){return Ct("VeyHeatmap").create(kt,St)},tornado:function(kt,St){return Ct("VeyRiskTornado").create(kt,St)},plaAttribution:function(kt,St){return Ct("VeyPlaAttribution").create(kt,St)}}})(typeof window<"u"?window:void 0);
|
package/dist/veyforma-charts.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
2
|
var __vfRoot = typeof window !== "undefined" ? window : {};
|
|
3
3
|
/*!
|
|
4
4
|
* Veyforma Exposure Heatmap v1.2.0
|
|
@@ -2935,7 +2935,7 @@ var __vfRoot = typeof window !== "undefined" ? window : {};
|
|
|
2935
2935
|
}
|
|
2936
2936
|
|
|
2937
2937
|
root.VeyformaCharts = {
|
|
2938
|
-
version: "1.0.
|
|
2938
|
+
version: "1.0.2",
|
|
2939
2939
|
/** Exposure heatmap: concentrations by any two fields, e.g. sector × country. */
|
|
2940
2940
|
heatmap: function (target, options) { return need("VeyHeatmap").create(target, options); },
|
|
2941
2941
|
/** Risk-factor tornado: down and up impact per factor, with convexity, limits and hedges. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
2
|
(function(I){"use strict";var Pt="1.2.0",fe="http://www.w3.org/2000/svg",ce=0,bt={low:"#fbf1ea",mid:"#ef8a54",high:"#9a3412",empty:"#ffffff",limit:"#111111",cellText:"#000000",cellTextOnDark:"#ffffff",totalBar:"#111111",totalBarOpacity:.12,headerText:"#555555",text:"#111111",mutedText:"#6b6b6b",summaryBackground:"#f6f6f6",background:"transparent",tooltipBackground:"#111111",tooltipText:"#ffffff",focus:"#2563eb",fontFamily:"inherit",fontSize:12,cellRadius:3,cellGap:2},st={veyforma:{},mono:{low:"#f4f4f4",mid:"#9a9a9a",high:"#111111",empty:"#ffffff",limit:"#111111"},"colour-safe":{low:"#eef3fb",mid:"#6d9be0",high:"#1d3f8f",limit:"#d9730d"},ocean:{low:"#ecf6f8",mid:"#5aaec0",high:"#0c3b5e",limit:"#be123c",summaryBackground:"#eef5f8"},forest:{low:"#f1f5ea",mid:"#8fb36b",high:"#22441a",limit:"#a8590b",summaryBackground:"#f2f4ee"},corporate:{low:"#eef1f6",mid:"#8195b8",high:"#1e3a6e",limit:"#b91c1c",summaryBackground:"#f1f4f8",cellRadius:0},midnight:{background:"#111418",low:"#1e242c",mid:"#2f6aa8",high:"#9cd0ff",empty:"#111418",limit:"#fbbf24",cellText:"#000000",cellTextOnDark:"#ffffff",totalBar:"#9cd0ff",totalBarOpacity:.18,headerText:"#c3c9d2",text:"#f3f4f6",mutedText:"#a3abb8",summaryBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd"}};function ut(t){if((t==null||t==="")&&(t="veyforma"),typeof t=="string")return st.hasOwnProperty(t)||(Mt('Unknown theme "'+t+'". The "veyforma" theme is used instead.'),t="veyforma"),S({},bt,st[t]);if(typeof t!="object")return Mt("The theme option must be a theme name or an object."),S({},bt);var r=t.extends?ut(t.extends):S({},bt),o=S(r,t);return delete o.extends,["low","mid","high","empty"].forEach(function(e){ft(o[e])||(Mt('Theme colour "'+e+'" must be a hex value such as "#9a3412". The default is used instead.'),o[e]=bt[e])}),o}function S(t){for(var r=1;r<arguments.length;r++){var o=arguments[r];if(o)for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&(t[e]=o[e])}return t}function At(t,r,o){return Math.min(o,Math.max(r,t))}function Mt(t){I.console&&I.console.warn("VeyHeatmap: "+t)}function R(t,r,o){var e=document.createElementNS(fe,t);if(r)for(var n in r)r[n]!=null&&e.setAttribute(n,r[n]);return o&&o.appendChild(e),e}function E(t,r,o){var e=document.createElement(t);return r&&(e.className=r),o&&o.appendChild(e),e}function ft(t){if(typeof t!="string")return null;var r=t.trim().replace(/^#/,"");if(r.length===3&&(r=r.split("").map(function(e){return e+e}).join("")),!/^[0-9a-fA-F]{6}$/.test(r))return null;var o=parseInt(r,16);return[o>>16&255,o>>8&255,o&255]}function he(t){return"#"+t.map(function(r){var o=Math.round(At(r,0,255)).toString(16);return o.length<2?"0"+o:o}).join("")}function It(t,r,o){return[t[0]+(r[0]-t[0])*o,t[1]+(r[1]-t[1])*o,t[2]+(r[2]-t[2])*o]}function me(t){var r=ft(t.low),o=ft(t.mid),e=ft(t.high);return function(n){return n=At(n,0,1),he(n<.5?It(r,o,n*2):It(o,e,(n-.5)*2))}}function Gt(t,r){var o=qt(t),e=qt(r);return(Math.max(o,e)+.05)/(Math.min(o,e)+.05)}function qt(t){var r=ft(t);if(!r)return 1;var o=r.map(function(e){return e/=255,e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)});return .2126*o[0]+.7152*o[1]+.0722*o[2]}var ct=null;function z(t,r,o,e){if(!ct){var n=document.createElement("canvas");ct=n.getContext&&n.getContext("2d")}return ct?(ct.font=(o||400)+" "+r+"px "+e,ct.measureText(String(t)).width):String(t).length*r*.6}function Ut(t,r,o,e,n){if(t=String(t),z(t,o,e,n)<=r)return t;for(var a=0,s=t.length;a<s;){var f=Math.ceil((a+s)/2);z(t.slice(0,f)+"\u2026",o,e,n)<=r?a=f:s=f-1}return a>0?t.slice(0,a).replace(/\s+$/,"")+"\u2026":""}function pe(t,r,o,e,n){for(var a=String(t).split(/\s+/),s=[],f="",m=0;m<a.length;m++){var c=f?f+" "+a[m]:a[m];z(c,o,e,n)>r&&f?(s.push(f),f=a[m]):f=c}f&&s.push(f);var C=s.length<=2&&s.every(function(v){return z(v,o,e,n)<=r});return C?s:null}function at(t){var r=Math.round(t*1e4)/100;return String(r)+"%"}function gt(t,r){var o=t.decimals!=null?t.decimals:0,e=t.prefix||"",n=t.suffix||"",a={};function s(v,h){return a[v]||(a[v]=new Intl.NumberFormat(r||void 0,h)),a[v]}function f(v,h){h==null&&(h=o);var d=Math.pow(10,-h);if(v>0&&v<d/2)return"<"+e+s("f"+h,{minimumFractionDigits:h,maximumFractionDigits:h}).format(d)+n;var w=e+s("f"+h,{minimumFractionDigits:h,maximumFractionDigits:h}).format(Math.abs(v))+n;return v>=0?w:t.negatives==="brackets"?"("+w+")":"\u2212"+w}function m(v){return n?f(v,0):(v<0?"\u2212":"")+e+s("c",{notation:"compact",maximumFractionDigits:1}).format(Math.abs(v))}function c(v,h){return h==null&&(h=1),s("p"+h,{minimumFractionDigits:h,maximumFractionDigits:h}).format(v*100)+"%"}function C(v){return s("n",{maximumFractionDigits:0}).format(v)}return{value:f,compact:m,percent:c,count:C}}function F(t,r){return String(t).replace(/\{(\w+)\}/g,function(o,e){return r[e]!=null?r[e]:o})}var Yt="\0other";function ve(t){if(Array.isArray(t.values)){var r=t.rowLabels,o=t.columnLabels,e=W&&W.get(t.values);if(e&&e.grid&&e.gridRows===r&&e.gridCols===o)return e.grid;if(!Array.isArray(r)||!Array.isArray(o))throw new Error("VeyHeatmap: a values grid needs rowLabels and columnLabels.");if(t.values.length!==r.length)throw new Error("VeyHeatmap: values has "+t.values.length+" rows but rowLabels has "+r.length+".");var n=[];t.values.forEach(function(c,C){if(!Array.isArray(c)||c.length!==o.length)throw new Error("VeyHeatmap: row "+(C+1)+" of values needs "+o.length+" numbers.");c.forEach(function(v,h){n.push({row:r[C],column:o[h],value:v})})});var a={records:n,rows:"row",columns:"column",dimensions:{row:{label:t.rowTitle||"Row",order:r.slice(),ordered:!0},column:{label:t.columnTitle||"Column",order:o.slice(),ordered:!0}}};if(W){var s=W.get(t.values)||{};s.grid=a,s.gridRows=r,s.gridCols=o,W.set(t.values,s)}return a}if(!Array.isArray(t.records)||!t.records.length)throw new Error("VeyHeatmap: data needs records, or values with rowLabels and columnLabels.");var f=Object.keys(t.records[0]).filter(function(c){return c!=="value"}),m=S({},t.dimensions||{});return f.forEach(function(c){m[c]||(m[c]={label:c.charAt(0).toUpperCase()+c.slice(1)})}),{records:t.records,rows:t.rows||f[0],columns:t.columns||f[1],dimensions:m}}var W=typeof WeakMap=="function"?new WeakMap:null;function de(t,r,o,e){var n=r+""+o,a=W&&e?W.get(e):null;if(a&&a[n])return a[n];for(var s=new Map,f=new Map,m=new Map,c=0,C=t.records,v=C.length,h=0;h<v;h++){var d=C[h],w=d[r],A=d[o];if(w==null||w==="")throw new Error("VeyHeatmap: record "+(h+1)+' has no "'+r+'".');if(A==null||A==="")throw new Error("VeyHeatmap: record "+(h+1)+' has no "'+o+'".');var u=d.value,y=typeof u=="number"?u:Number(u);if(u==null||u===""||!isFinite(y))throw new Error("VeyHeatmap: record "+(h+1)+" has no numeric value.");if(y<0)throw new Error("VeyHeatmap: record "+(h+1)+" is negative. Exposure values must be zero or more.");typeof w!="string"&&(w=String(w)),typeof A!="string"&&(A=String(A));var T=s.get(w);T||(T=new Map,s.set(w,T),f.set(w,0)),T.set(A,(T.get(A)||0)+y),f.set(w,f.get(w)+y),m.set(A,(m.get(A)||0)+y),c+=y}var O=function(b){var H={};return b.forEach(function(j,B){H[B]=j}),H},x={cell:function(b,H){var j=s.get(b);return j&&j.get(H)||0},rowTot:O(f),colTot:O(m),rowSeen:Array.from(f.keys()),colSeen:Array.from(m.keys()),total:c};return W&&e&&(a||(a={},W.set(e,a)),a[n]=x),x}function X(t,r,o){var e=ve(t),n=r.rows||e.rows,a=r.columns||e.columns;if(!n||!a)throw new Error("VeyHeatmap: choose a field for the rows and a field for the columns.");if(n===a)throw new Error('VeyHeatmap: rows and columns cannot both use "'+n+'".');var s=S({label:n},e.dimensions[n]),f=S({label:a},e.dimensions[a]),m=de(e,n,a,Array.isArray(t.values)?t.values:t.records),c=m.rowTot,C=m.colTot,v=m.rowSeen,h=m.colSeen,d=m.total;function w(T,O,x,b,H){var j=T.slice();if(Array.isArray(x.order)){var B=x.order.map(String);j.sort(function(_,D){var tt=B.indexOf(_),et=B.indexOf(D);return tt<0&&(tt=B.length+T.indexOf(_)),et<0&&(et=B.length+T.indexOf(D)),tt-et})}var N=j.slice().sort(function(_,D){return O[D]-O[_]||j.indexOf(_)-j.indexOf(D)}),Y=b==="total"||b!=="natural"&&!x.ordered,G=Y?N:j,Z=G.map(function(_){return{key:_,label:_,members:[_]}});if(H&&H>0&&G.length>H+1){var nt=N.slice(0,H),ht=G.filter(function(_){return nt.indexOf(_)>=0}),wt=G.filter(function(_){return nt.indexOf(_)<0});Z=ht.map(function(_){return{key:_,label:_,members:[_]}}),Z.push({key:Yt,label:F(o.other,{count:wt.length}),members:wt,other:!0})}return Z.forEach(function(_){_.total=_.members.reduce(function(D,tt){return D+O[tt]},0)}),Z}var A=w(v,c,s,r.sortRows,r.topRows),u=w(h,C,f,r.sortColumns,r.topColumns),y=A.map(function(T){return u.map(function(O){var x=0;return T.members.forEach(function(b){O.members.forEach(function(H){x+=m.cell(b,H)})}),x})});return{rowKey:n,colKey:a,rowDim:s,colDim:f,rows:A,cols:u,values:y,total:d}}function Kt(t,r){var o=[],e=0;t.values.forEach(function(s,f){s.forEach(function(m,c){var C=t.total>0?m/t.total:0;e+=C*C*1e4,o.push({r:f,c,value:m,share:C})})}),o.sort(function(s,f){return f.value-s.value});var n=o.slice(0,5).reduce(function(s,f){return s+f.share},0),a=r>0?o.filter(function(s){return s.share>r+1e-12}):[];return{hhi:e,effective:e>0?1e4/e:0,largest:o[0],top5:n,above:a}}var be={data:null,theme:"veyforma",locale:void 0,rows:void 0,columns:void 0,valueMode:"amount",scale:"linear",sortRows:"auto",sortColumns:"auto",topRows:0,topColumns:0,fit:"auto",limit:void 0,totals:!0,cellLabels:"auto",cellHeight:void 0,summary:!0,legend:!0,tooltip:!0,animate:!0,labels:null,ariaLabel:void 0,tooltipFormatter:null,onClick:null,caption:!0,annotations:null,onAnnotationsChange:null,toolbar:!0},ge={total:"Total",other:"Other ({count})",empty:"No exposure",totalExposure:"Total exposure",largest:"Largest concentration",hhi:"Concentration (HHI)",aboveLimit:"Above limit",top5:"Top 5 cells",hhiNote:"Like {n} equal-sized cells",aboveNote:"Cells above {limit} of total",gridNote:"{rows} {rowDim} \xD7 {cols} {colDim}",top5Note:"Share of total exposure",exposure:"Exposure",shareOfTotal:"Share of total",shareOfRow:"Share of {row}",shareOfColumn:"Share of {column}",limitLegend:"Above {limit} limit",limitTip:"Above the {limit} limit",rowTotalTip:"{label} total",scrollNote:"Scroll sideways to see all {columns}.",groupNote:"Smaller {columns} are grouped as Other to fit this screen. Tap an Other cell to see which.",includes:"Other includes {list}"};function we(){if(!document.getElementById("vhm-styles")){var t=".vhm{position:relative;color:var(--vhm-text);background:var(--vhm-bg);font-family:var(--vhm-font);line-height:1.4}.vhm.vhm-filled{padding:14px 14px 8px;border-radius:10px}.vhm-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px;margin:0 0 12px}.vhm-stat{background:var(--vhm-summary-bg);border-radius:10px;padding:10px 12px;min-width:0}.vhm-stat-label{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vhm-muted)}.vhm-stat-value{font-size:20px;font-weight:650;letter-spacing:-.01em;margin-top:2px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vhm-stat-note{font-size:11.5px;color:var(--vhm-muted);margin-top:1px;overflow-wrap:anywhere}.vhm-legend{display:flex;flex-wrap:wrap;align-items:center;gap:6px 18px;font-size:12px;margin:0 0 10px}.vhm-legend>span{display:inline-flex;align-items:center;gap:6px}.vhm-legend .vhm-ramp{display:inline-flex;flex-direction:column;align-items:stretch;gap:2px}.vhm-ramp-bar{width:150px;height:10px;border-radius:3px}.vhm-ramp-ticks{display:flex;justify-content:space-between;gap:8px;font-size:11px;color:var(--vhm-muted);font-variant-numeric:tabular-nums}.vhm-plot-host{overflow-x:auto;-webkit-overflow-scrolling:touch}.vhm-plot{display:block;overflow:visible;outline:none}.vhm-plot:focus-visible{outline:2px solid var(--vhm-focus);outline-offset:4px;border-radius:4px}.vhm-animate .vhm-cell{animation:vhm-fade .45s ease both}@keyframes vhm-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vhm-animate .vhm-cell{animation:none}}.vhm-scroll-note{font-size:11.5px;color:var(--vhm-muted);margin-top:4px}.vhm-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vhm-tip-bg);color:var(--vhm-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5}.vhm-tip.vhm-on{opacity:1;transform:none}.vhm-tip b{font-weight:600}.vhm-table{width:100%;border-collapse:collapse;font-size:13px}.vhm-table th,.vhm-table td{text-align:right;padding:7px 6px;border-bottom:1px solid rgba(127,127,127,.25);font-variant-numeric:tabular-nums;white-space:nowrap}.vhm-table th:first-child,.vhm-table td:first-child{text-align:left}.vhm-table th{font-weight:600;font-size:12px}.vhm-table tr.vhm-total td{font-weight:600}",r=document.createElement("style");r.id="vhm-styles",r.appendChild(document.createTextNode(t)),(document.head||document.documentElement).appendChild(r)}}function L(t,r){var o=typeof t=="string"?document.querySelector(t):t;if(!o||o.nodeType!==1)throw new Error("VeyHeatmap: container not found ("+t+").");if(!r||!r.data)throw new Error("VeyHeatmap: options.data is required.");we(),this.id=++ce,this.container=o,this.options=S({},be,r),this.element=E("div","vhm"),this.summaryEl=E("div","vhm-summary",this.element),this.legendEl=E("div","vhm-legend",this.element),this.plotHost=E("div","vhm-plot-host",this.element),this.noteEl=E("div","vhm-scroll-note",this.element),this.tipEl=E("div","vhm-tip",this.element),this.tipEl.setAttribute("role","tooltip"),this.tipEl.id="vhm-tip-"+this.id,o.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=null;var e=this;I.ResizeObserver?(this._observer=new I.ResizeObserver(function(){var n=Math.round(e.element.clientWidth);n&&n!==e._lastWidth&&e.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){e.redraw()},I.addEventListener("resize",this._onResize)),this._onDocTap=function(n){e.element.contains(n.target)||e._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&I.VeyformaToolkit&&(this.toolkit=I.VeyformaToolkit.attach(this,this.options.toolbar))}L.prototype.update=function(t){return t?(t.data&&t.data!==this.options.data&&this.options.animate&&(this._animateNext=!0,this._active=null),(t.rows||t.columns||t.topRows!=null||t.topColumns!=null)&&(this._active=null),t.animate===!0&&(this._animateNext=!0),S(this.options,t),this.redraw()):this},L.prototype.setData=function(t){return W&&t&&(Array.isArray(t.records)&&W.delete(t.records),Array.isArray(t.values)&&W.delete(t.values)),this.update({data:t})},L.prototype.setTheme=function(t){return this.update({theme:t})},L.prototype.getTheme=function(){return ut(this.options.theme)},L.prototype._labels=function(){return S({},ge,this.options.labels)},L.prototype._limit=function(){var t=this.options,r=t.limit!==void 0?t.limit:t.data.limit&&t.data.limit.share;return r=Number(r),isFinite(r)&&r>0&&r<1?r:0},L.prototype.getMatrix=function(){var t=X(this.options.data,this.options,this._labels()),r=function(o){return{key:o.key===Yt?null:o.key,label:o.label,total:o.total,other:!!o.other,members:o.members.slice()}};return{rowField:t.rowKey,columnField:t.colKey,rows:t.rows.map(r),columns:t.cols.map(r),values:t.values.map(function(o){return o.slice()}),total:t.total}},L.prototype.getStats=function(){var t=X(this.options.data,S({},this.options,{topRows:0,topColumns:0}),this._labels()),r=this._limit(),o=Kt(t,r),e=function(n){return{row:t.rows[n.r].label,column:t.cols[n.c].label,value:n.value,share:n.share}};return{total:t.total,rows:t.rows.length,columns:t.cols.length,hhi:o.hhi,effectiveCells:o.effective,top5Share:o.top5,largest:o.largest?e(o.largest):null,limit:r||null,aboveLimit:o.above.map(e)}},L.prototype.createTable=function(){var t=this.options,r=t.data,o=this._labels(),e=X(r,t,o),n=gt(r,t.locale),a=document.createElement("table");if(a.className="vhm-table",r.title){var s=E("caption",null,a);s.textContent=r.title,s.style.cssText="text-align:left;font-weight:600;padding:0 6px 6px"}var f=E("tr",null,E("thead",null,a)),m=E("th",null,f);m.scope="col",m.textContent=e.rowDim.label,e.cols.forEach(function(h){var d=E("th",null,f);d.scope="col",d.textContent=h.label});var c=E("th",null,f);c.scope="col",c.textContent=o.total;var C=E("tbody",null,a);e.rows.forEach(function(h,d){var w=E("tr",null,C),A=E("th",null,w);A.scope="row",A.textContent=h.label,A.style.textAlign="left",A.style.fontWeight="400",e.values[d].forEach(function(u){E("td",null,w).textContent=u?n.value(u):"\u2014"}),E("td",null,w).textContent=n.value(h.total)});var v=E("tr","vhm-total",C);return E("td",null,v).textContent=o.total,e.cols.forEach(function(h){E("td",null,v).textContent=n.value(h.total)}),E("td",null,v).textContent=n.value(e.total),a},L.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&I.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},L.prototype._hideTip=function(){this.tipEl.classList.remove("vhm-on"),this._focusRect&&this._focusRect.setAttribute("opacity",0),this._boldReset&&this._boldReset()},L.prototype._placeTip=function(t,r,o){var e=this.tipEl;e.textContent="",t.forEach(function(v,h){h&&e.appendChild(document.createElement("br"));var d=h===0?document.createElement("b"):document.createTextNode("");d.textContent=v,e.appendChild(d)});var n=this.element.getBoundingClientRect(),a=o&&o.clientX?o.clientX:r.left+r.width/2,s=o&&o.clientY?o.clientY:r.top;e.classList.add("vhm-on");var f=e.offsetWidth,m=e.offsetHeight,c=At(a-n.left-f/2,4,Math.max(4,n.width-f-4)),C=s-n.top-m-14;C<0&&(C=(r.bottom!=null?r.bottom:s)-n.top+10),e.style.left=c+"px",e.style.top=C+"px"},L.prototype.redraw=function(){var t=this.options,r=t.data,o=this,e=ut(t.theme),n=this._labels(),a=X(r,t,n),s=gt(r,t.locale),f=t.topRows>0||t.topColumns>0?X(r,S({},t,{topRows:0,topColumns:0}),n):a,m=this._limit(),c=Kt(f,m),C=this.element,v=me(e),h=e.background&&e.background!=="transparent"?e.background:"#ffffff",d=e.fontFamily==="inherit"?I.getComputedStyle?I.getComputedStyle(this.container).fontFamily:"sans-serif":e.fontFamily,w=C.style;w.setProperty("--vhm-text",e.text),w.setProperty("--vhm-muted",e.mutedText),w.setProperty("--vhm-bg",e.background),w.setProperty("--vhm-font",d),w.setProperty("--vhm-focus",e.focus),w.setProperty("--vhm-tip-bg",e.tooltipBackground),w.setProperty("--vhm-tip-text",e.tooltipText),w.setProperty("--vhm-summary-bg",e.summaryBackground),C.classList.toggle("vhm-filled",!!e.background&&e.background!=="transparent"),C.classList.toggle("vhm-animate",!!this._animateNext);var A=Math.max(this.plotHost.clientWidth||C.clientWidth||0,280);this._lastWidth=Math.round(C.clientWidth);var u=A<560,y=Number(e.fontSize)||12,T=u?y-1.5:y-.5,O=u?y-2:y-1,x=t.cellHeight||(u?28:34),b=Math.max(0,Number(e.cellGap)||0),H=u?26:34,j=Math.max.apply(null,a.rows.map(function(i){return z(i.label,T,400,d)})),B=Math.min(Math.ceil(j)+12,Math.round(A*(u?.3:.26))),N=t.totals?Math.max(u?50:70,Math.ceil(z(s.value(Math.max.apply(null,a.rows.map(function(i){return i.total}))),y-1,600,d))+12):0;t.totals&&u&&(N=Math.min(N,64));var Y=t.totals?8:0,G=A-B-Y-N-2,Z=t.fit||"auto",nt=!1,ht=Math.floor(G/H),wt=Z==="group"||Z==="auto"&&!a.colDim.ordered&&!(t.topColumns>0);wt&&a.cols.length>ht&&ht>=3&&(a=X(r,S({},t,{topColumns:ht-1}),n),nt=!0);var _=a.rows.length,D=a.cols.length,tt=(a.rowDim.plural||a.rowDim.label).toLowerCase(),et=(a.colDim.plural||a.colDim.label).toLowerCase(),it=t.valueMode;["amount","shareOfTotal","shareOfRow","shareOfColumn"].indexOf(it)<0&&(it="amount");for(var $t=function(i,l){var g=a.values[i][l];return it==="shareOfTotal"?a.total?g/a.total:0:it==="shareOfRow"?a.rows[i].total?g/a.rows[i].total:0:it==="shareOfColumn"?a.cols[l].total?g/a.cols[l].total:0:g},rt=0,kt=0;kt<_;kt++)for(var Lt=0;Lt<D;Lt++)rt=Math.max(rt,$t(kt,Lt));var Jt=t.scale==="sqrt",xe=function(i){if(rt<=0)return 0;var l=i/rt;return Jt?Math.sqrt(l):l},Ot=function(i,l){return it==="amount"?l?s.compact(i):s.value(i):s.percent(i,l?0:1)},Rt=this.summaryEl;if(Rt.textContent="",Rt.style.display=t.summary?"":"none",t.summary){var mt=function(i,l,g){var p=E("div","vhm-stat",Rt);E("div","vhm-stat-label",p).textContent=i,E("div","vhm-stat-value",p).textContent=l,g&&(E("div","vhm-stat-note",p).textContent=g)};mt(n.totalExposure,s.value(a.total),F(n.gridNote,{rows:f.rows.length,rowDim:tt,cols:f.cols.length,colDim:et})),c.largest&&mt(n.largest,s.percent(c.largest.share),f.rows[c.largest.r].label+" \xD7 "+f.cols[c.largest.c].label+" \xB7 "+s.value(c.largest.value)),mt(n.hhi,s.count(c.hhi),F(n.hhiNote,{n:s.count(Math.round(c.effective))})),m?mt(n.aboveLimit,s.count(c.above.length),F(n.aboveNote,{limit:at(m)})):mt(n.top5,s.percent(c.top5),n.top5Note)}var pt=this.legendEl;if(pt.textContent="",pt.style.display=t.legend?"":"none",t.legend){var Qt=E("span","vhm-ramp",pt),ye=E("span","vhm-ramp-bar",Qt);ye.style.background="linear-gradient(to right,"+[0,.25,.5,.75,1].map(function(i){return v(i)}).join(",")+")";var Te=E("span","vhm-ramp-ticks",Qt),Ee=Jt?rt*.25:rt*.5;[0,Ee,rt].forEach(function(i){E("span",null,Te).textContent=Ot(i,!0)});var Zt=E("span",null,pt),Ce=R("svg",{width:14,height:14,"aria-hidden":"true"},Zt);if(R("rect",{x:1,y:1,width:12,height:12,rx:2,fill:e.empty,stroke:e.mutedText,"stroke-opacity":.45,"stroke-dasharray":"2 2"},Ce),Zt.appendChild(document.createTextNode(n.empty)),m){var te=E("span",null,pt),ee=R("svg",{width:14,height:14,"aria-hidden":"true"},te);R("rect",{x:1.5,y:1.5,width:11,height:11,rx:2,fill:v(.7),stroke:e.limit,"stroke-width":2},ee),R("rect",{x:3.5,y:3.5,width:7,height:7,rx:1,fill:"none",stroke:h,"stroke-width":1},ee),te.appendChild(document.createTextNode(F(n.limitLegend,{limit:at(m)})))}}var k=G/D,vt=!1;k<H&&(k=H,vt=!0),G=k*D;var Dt=a.cols.map(function(i){return pe(i.label,k-4,T,400,d)}),St=Dt.some(function(i){return i===null}),_e=Math.max.apply(null,a.cols.map(function(i){return z(i.label,T,400,d)})),re=Math.min(_e,140),xt=St?Math.ceil(re*.7071+T+10):Math.max.apply(null,Dt.map(function(i){return i.length}))*(T+3)+10,Ae=St?Math.max(0,re*.7071-N-Y):0,yt=B+G+Y+N+2+Ae;yt>A+.5&&(vt=!0);var oe=xt,Me=t.totals?x:0,ae=oe+_*x+(t.totals?Y+Me:0)+4,Ht=B,K=function(i){return Ht+i*k},V=function(i){return oe+i*x};this.plotHost.textContent="",this.noteEl.textContent=vt?F(n.scrollNote,{columns:et}):nt?F(n.groupNote,{columns:et}):"",this.noteEl.style.display=vt||nt?"":"none";var P=R("svg",{class:"vhm-plot",viewBox:"0 0 "+yt+" "+ae,width:yt,height:ae,tabindex:0,role:"img","aria-label":t.ariaLabel||[r.title,a.rowDim.label+" by "+a.colDim.label,c.largest?n.largest+": "+f.rows[c.largest.r].label+" \xD7 "+f.cols[c.largest.c].label+", "+s.percent(c.largest.share):null].filter(Boolean).join(". ")},this.plotHost);vt||(P.style.width="100%",P.style.height="auto");var $=function(i,l,g){var p=R("text",S({"font-family":d},i),g||P);return p.textContent=l,p},ne=[];a.cols.forEach(function(i,l){var g=K(l)+k/2,p=R("g",null,P);if(St){var M=xt-6;$({x:g-2,y:M,"text-anchor":"start",transform:"rotate(-45 "+(g-2)+" "+M+")","font-size":T,fill:i.other?e.mutedText:e.headerText},Ut(i.label,140,T,400,d),p)}else{var ot=Dt[l];ot.forEach(function(lt,He){$({x:g,y:xt-6-(ot.length-1-He)*(T+3),"text-anchor":"middle","font-size":T,fill:i.other?e.mutedText:e.headerText},lt,p)})}ne.push(p)}),t.totals&&$({x:Ht+G+Y+N-4,y:xt-6,"text-anchor":"end","font-size":T,"font-weight":600,fill:e.text},n.total);var ke=a.rows.map(function(i,l){var g=Ut(i.label,B-12,T,400,d),p=$({x:B-8,y:V(l)+x/2+T*.35,"text-anchor":"end","font-size":T,fill:i.other?e.mutedText:e.headerText},g);if(g!==i.label){var M=R("title",null,p);M.textContent=i.label}return p});t.totals&&$({x:B-8,y:V(_)+Y+x/2+T*.35,"text-anchor":"end","font-size":T,"font-weight":600,fill:e.text},n.total);for(var J=R("g",null,P),Le=t.cellLabels===!0||t.cellLabels==="auto",q=0;q<_;q++)for(var U=0;U<D;U++){var Tt=a.values[q][U],Nt=$t(q,U),zt=Tt>0?v(xe(Nt)):e.empty,dt=R("rect",{x:K(U)+b/2,y:V(q)+b/2,width:Math.max(k-b,1),height:Math.max(x-b,1),rx:Math.min(e.cellRadius,k/4),fill:zt,class:"vhm-cell","data-r":q,"data-c":U},J);if(Tt>0||(dt.setAttribute("stroke",e.mutedText),dt.setAttribute("stroke-opacity",.45),dt.setAttribute("stroke-dasharray","2 2"),dt.setAttribute("stroke-width",1)),dt.style.animationDelay=Math.min((q+U)*18,500)+"ms",m&&a.total>0&&Tt/a.total>m+1e-12&&!a.rows[q].other&&!a.cols[U].other&&(R("rect",{x:K(U)+b/2+1,y:V(q)+b/2+1,width:Math.max(k-b-2,1),height:Math.max(x-b-2,1),rx:Math.min(e.cellRadius,k/4),fill:"none",stroke:e.limit,"stroke-width":2,"pointer-events":"none"},J),R("rect",{x:K(U)+b/2+3,y:V(q)+b/2+3,width:Math.max(k-b-6,1),height:Math.max(x-b-6,1),rx:Math.max(0,Math.min(e.cellRadius,k/4)-1),fill:"none",stroke:h,"stroke-width":1,"pointer-events":"none"},J)),Le&&Tt>0&&x-b>=16){var ie=k-b-8,Et=Ot(Nt,!1);if(z(Et,O,500,d)>ie&&(Et=Ot(Nt,!0)),z(Et,O,500,d)<=ie){var Oe=Gt(zt,e.cellTextOnDark)>Gt(zt,e.cellText)?e.cellTextOnDark:e.cellText;$({x:K(U)+k/2,y:V(q)+x/2+O*.35,"text-anchor":"middle","font-size":O,"font-weight":500,fill:Oe,"pointer-events":"none",class:"vhm-cell-label"},Et,J)}}}var Q=null;if(t.totals){Q=R("g",null,P);var Re=Math.max.apply(null,a.rows.map(function(i){return i.total}))||1,De=Math.max.apply(null,a.cols.map(function(i){return i.total}))||1,Ft=Ht+G+Y;a.rows.forEach(function(i,l){var g=Math.max(2,(N-2)*i.total/Re);R("rect",{x:Ft,y:V(l)+b/2+3,width:g,height:x-b-6,rx:2,fill:e.totalBar,"fill-opacity":e.totalBarOpacity,"data-tr":l},Q);var p=s.value(i.total);z(p,y-1,600,d)>N-6&&(p=s.compact(i.total)),$({x:Ft+N-4,y:V(l)+x/2+(y-1)*.35,"text-anchor":"end","font-size":y-1,"font-weight":600,fill:e.text,"pointer-events":"none"},p,Q)});var Bt=V(_)+Y;a.cols.forEach(function(i,l){var g=Math.max(2,(x-b-4)*i.total/De);R("rect",{x:K(l)+b/2+2,y:Bt+x-b/2-2-g,width:Math.max(k-b-4,1),height:g,rx:2,fill:e.totalBar,"fill-opacity":e.totalBarOpacity,"data-tc":l},Q);var p=s.value(i.total);z(p,O,600,d)>k-b-6&&(p=s.compact(i.total)),z(p,O,600,d)<=k-b-6&&$({x:K(l)+k/2,y:Bt+x/2+O*.35,"text-anchor":"middle","font-size":O,"font-weight":600,fill:e.text,"pointer-events":"none"},p,Q)});var Vt=s.value(a.total);z(Vt,y-1,700,d)>N-6&&(Vt=s.compact(a.total)),$({x:Ft+N-4,y:Bt+x/2+(y-1)*.35,"text-anchor":"end","font-size":y-1,"font-weight":700,fill:e.text},Vt)}this._focusRect=R("rect",{x:0,y:0,width:0,height:0,rx:Math.min(e.cellRadius+1,6),fill:"none",stroke:e.text,"stroke-width":2,opacity:0,"pointer-events":"none"},P);var Wt=function(i,l){var g=a.values[i][l];return{row:a.rows[i].label,column:a.cols[l].label,rowIndex:i,columnIndex:l,value:g,shareOfTotal:a.total?g/a.total:0,shareOfRow:a.rows[i].total?g/a.rows[i].total:0,shareOfColumn:a.cols[l].total?g/a.cols[l].total:0,aboveLimit:!!(m&&a.total&&g/a.total>m+1e-12&&!a.rows[i].other&&!a.cols[l].other),rowMembers:a.rows[i].members.slice(),columnMembers:a.cols[l].members.slice()}},Ct=[];this._boldReset=function(){Ct.forEach(function(i){i.removeAttribute("font-weight")}),Ct=[]};var Se=function(i,l){o._boldReset();var g=ke[i];g.setAttribute("font-weight",600),Ct.push(g),Array.prototype.forEach.call(ne[l].childNodes,function(p){p.setAttribute("font-weight",600),Ct.push(p)})},_t=function(i,l,g){if(o._active=[i,l],o._focusRect.setAttribute("x",K(l)+b/2-1),o._focusRect.setAttribute("y",V(i)+b/2-1),o._focusRect.setAttribute("width",k-b+2),o._focusRect.setAttribute("height",x-b+2),o._focusRect.setAttribute("opacity",1),Se(i,l),!!t.tooltip){var p=Wt(i,l),M;typeof t.tooltipFormatter=="function"?(M=t.tooltipFormatter(p,s),Array.isArray(M)||(M=[String(M)])):(M=[p.row+" \xD7 "+p.column],p.value?(M.push(n.exposure+": "+s.value(p.value)),M.push(n.shareOfTotal+": "+s.percent(p.shareOfTotal)),M.push(F(n.shareOfRow,{row:p.row})+": "+s.percent(p.shareOfRow)),M.push(F(n.shareOfColumn,{column:p.column})+": "+s.percent(p.shareOfColumn)),p.aboveLimit&&M.push(F(n.limitTip,{limit:at(m)}))):M.push(n.empty),a.rows[i].other&&M.push(F(n.includes,{list:a.rows[i].members.join(", ")})),a.cols[l].other&&M.push(F(n.includes,{list:a.cols[l].members.join(", ")})));var ot=P.getBoundingClientRect(),lt=ot.width/yt;o._placeTip(M,{left:ot.left+K(l)*lt,top:ot.top+V(i)*lt,width:k*lt,bottom:ot.top+(V(i)+x)*lt},g)}},le=function(i,l,g){var p=i?a.rows[l]:a.cols[l],M=[F(n.rowTotalTip,{label:p.label}),s.value(p.total)+" \xB7 "+s.percent(a.total?p.total/a.total:0)+" "+n.shareOfTotal.toLowerCase()];p.other&&M.push(p.members.join(", ")),o._placeTip(M,{left:g.clientX,top:g.clientY,width:0},g)};J.addEventListener("mousemove",function(i){var l=i.target;!l.hasAttribute||!l.hasAttribute("data-r")||_t(+l.getAttribute("data-r"),+l.getAttribute("data-c"),i)}),J.addEventListener("pointerdown",function(i){var l=i.target;!l.hasAttribute||!l.hasAttribute("data-r")||_t(+l.getAttribute("data-r"),+l.getAttribute("data-c"),i)}),J.addEventListener("mouseleave",function(){o._hideTip()}),typeof t.onClick=="function"&&(J.style.cursor="pointer",J.addEventListener("click",function(i){var l=i.target;!l.hasAttribute||!l.hasAttribute("data-r")||t.onClick(Wt(+l.getAttribute("data-r"),+l.getAttribute("data-c")),i)})),Q&&(Q.addEventListener("mousemove",function(i){var l=i.target;l.hasAttribute&&l.hasAttribute("data-tr")?le(!0,+l.getAttribute("data-tr"),i):l.hasAttribute&&l.hasAttribute("data-tc")&&le(!1,+l.getAttribute("data-tc"),i)}),Q.addEventListener("mouseleave",function(){o._hideTip()})),this._geom={rows:a.rows,cols:a.cols,cx:K,cy:V,cellW:k,cellH:x,gap:b},P.setAttribute("aria-describedby",this.tipEl.id);var jt=[0,0];if(c.largest){var se=a.rows.map(function(i){return i.key}).indexOf(f.rows[c.largest.r].key),ue=a.cols.map(function(i){return i.key}).indexOf(f.cols[c.largest.c].key);se>=0&&ue>=0&&(jt=[se,ue])}return P.addEventListener("focus",function(){var i=o._active&&o._active[0]<_&&o._active[1]<D?o._active:jt;_t(i[0],i[1])}),P.addEventListener("blur",function(){o._hideTip()}),P.addEventListener("keydown",function(i){var l=o._active&&o._active[0]<_&&o._active[1]<D?o._active.slice():jt.slice();if(i.key==="ArrowLeft")l[1]=Math.max(0,l[1]-1);else if(i.key==="ArrowRight")l[1]=Math.min(D-1,l[1]+1);else if(i.key==="ArrowUp")l[0]=Math.max(0,l[0]-1);else if(i.key==="ArrowDown")l[0]=Math.min(_-1,l[0]+1);else if(i.key==="Home")l[1]=0;else if(i.key==="End")l[1]=D-1;else if((i.key==="Enter"||i.key===" ")&&typeof t.onClick=="function"){i.preventDefault(),t.onClick(Wt(l[0],l[1]),i);return}else return;i.preventDefault(),_t(l[0],l[1])}),this._hideTip(),this._animateNext=!1,this};function Xt(t,r){if(r==null)return-1;r=String(r);for(var o=0;o<t.length;o++)if(t[o].label===r||t[o].key===r||t[o].members.indexOf(r)>=0)return o;return-1}L.prototype.howToRead=function(){var t=X(this.options.data,this.options,this._labels()),r=(t.rowDim.label||"row").toLowerCase(),o=(t.colDim.label||"column").toLowerCase();return"Each cell is the exposure where a "+r+" meets a "+o+"; darker cells hold more. The bars on the right and along the bottom are the totals for each "+r+" and "+o+". HHI measures concentration: the higher it is, the more the book depends on a few cells."+(this._limit()?" Cells with a double outline are above the concentration limit.":"")},L.prototype.describe=function(){var t=this.getStats(),r=gt(this.options.data,this.options.locale),o=X(this.options.data,this.options,this._labels()),e=["In this example total exposure is "+r.value(t.total)+" across "+t.rows+" "+(o.rowDim.plural||o.rowDim.label).toLowerCase()+" and "+t.columns+" "+(o.colDim.plural||o.colDim.label).toLowerCase()+"."];return t.largest&&e.push("The largest cell is "+t.largest.row+" \xD7 "+t.largest.column+" with "+r.value(t.largest.value)+" ("+r.percent(t.largest.share)+" of the total)."),e.push("HHI is "+r.count(t.hhi)+", like "+r.count(Math.round(t.effectiveCells))+" equal-sized cells."),t.limit&&e.push(t.aboveLimit.length+" "+(t.aboveLimit.length===1?"cell is":"cells are")+" above the "+at(t.limit)+" limit."),e.join(" ")},L.prototype.getExportData=function(){var t=this.options,r=t.data,o=this._labels(),e=X(r,S({},t,{topRows:0,topColumns:0}),o),n=gt(r,t.locale),a=this.getStats(),s=this._limit(),f={prefix:r.prefix||"",suffix:r.suffix||"",decimals:r.decimals!=null?r.decimals:0,negatives:r.negatives},m=[{label:e.rowDim.label,type:"text"}].concat(e.cols.map(function(u){return{label:u.label,type:"number",unit:f}}),[{label:o.total,type:"number",unit:f}]),c=e.rows.map(function(u,y){return[u.label].concat(e.values[y],[u.total])});c.push([o.total].concat(e.cols.map(function(u){return u.total}),[e.total]));var C=e.rows.map(function(u,y){return[u.label].concat(e.values[y].map(function(T){return T?n.value(T):"\u2014"}),[n.value(u.total)])});C.push([o.total].concat(e.cols.map(function(u){return n.value(u.total)}),[n.value(e.total)]));var v=[];e.rows.forEach(function(u,y){e.cols.forEach(function(T,O){var x=e.values[y][O];x&&v.push([u.label,T.label,x,e.total?x/e.total:0])})}),v.sort(function(u,y){return y[2]-u[2]});var h=function(u){return s&&u>s+1e-12?"Yes":"No"},d=[[o.totalExposure,a.total,n.value(a.total)],[o.hhi,a.hhi,n.count(a.hhi)],["Effective number of cells",a.effectiveCells,n.count(Math.round(a.effectiveCells))],[o.top5,a.top5Share,n.percent(a.top5Share)]];a.largest&&d.push([o.largest,a.largest.share,a.largest.row+" \xD7 "+a.largest.column+" \xB7 "+n.percent(a.largest.share)]),s&&(d.push(["Limit (share of total)",s,at(s)]),d.push([o.aboveLimit,a.aboveLimit.length,n.count(a.aboveLimit.length)]));var w=(t.annotations||[]).map(function(u,y){return[String(y+1),String(u.row||""),String(u.column||""),u.text||""]}),A=[{name:"Matrix",columns:m,rows:c,text:C,bold:c.map(function(u,y){return y===c.length-1})},{name:"Cells",columns:[{label:e.rowDim.label,type:"text"},{label:e.colDim.label,type:"text"},{label:o.exposure,type:"number",unit:f},{label:o.shareOfTotal,type:"percent",decimals:2},{label:o.aboveLimit,type:"text"}],rows:v.map(function(u){return[u[0],u[1],u[2],u[3],h(u[3])]}),text:v.map(function(u){return[u[0],u[1],n.value(u[2]),n.percent(u[3],2),h(u[3])]})},{name:"Concentration",columns:[{label:"Measure",type:"text"},{label:"Value",type:"general"},{label:"As shown",type:"text"}],rows:d,text:d.map(function(u){return[u[0],typeof u[1]=="number"?String(Number(u[1].toPrecision(10))):String(u[1]),u[2]]})}];return w.length&&A.push({name:"Notes",columns:[{label:"No.",type:"text"},{label:e.rowDim.label,type:"text"},{label:e.colDim.label,type:"text"},{label:"Note",type:"text"}],rows:w}),{title:r.title||"Exposure heatmap",subtitle:r.subtitle||"",summary:this.describe(),library:"Veyforma Exposure Heatmap "+Pt,sheets:A,meta:[["Method","HHI = 10,000 \xD7 sum of squared cell shares; effective number of cells = 10,000 \xF7 HHI; a cell is above the limit when its share is strictly greater"],["Grid",e.rowDim.label+" \xD7 "+e.colDim.label+", full grid without Other grouping"],["Unit",r.unit],["Limit",s?at(s)+" of total":null],["As of",r.asOf],["Data source",r.source]]}},L.prototype._annotationPoint=function(t){var r=this._geom;if(!r||!t)return null;var o=Xt(r.rows,t.row),e=Xt(r.cols,t.column);if(o<0||e<0)return null;var n=r.rows[o]&&r.rows[o].other||r.cols[e]&&r.cols[e].other;return{x:r.cx(e)+r.gap/2+11,y:r.cy(o)+r.gap/2+11,inside:!0,where:n?"shown in Other":null}},L.prototype._annotationTarget=function(t){var r=this._geom,o,e;if(!r)return null;if(t){var n=t.target;if(!n||!n.getAttribute||n.getAttribute("data-r")==null)return null;o=+n.getAttribute("data-r"),e=+n.getAttribute("data-c")}else if(this._active)o=this._active[0],e=this._active[1];else return null;return!r.rows[o]||!r.cols[e]||r.rows[o].other||r.cols[e].other?null:{row:r.rows[o].label,column:r.cols[e].label}},L.prototype._annotationLabel=function(t){return[t.row,t.column].filter(Boolean).join(" \xD7 ")},I.VeyHeatmap={version:Pt,create:function(t,r){return new L(t,r)},registerTheme:function(t,r){if(!t||typeof t!="string")throw new Error("VeyHeatmap: registerTheme needs a name.");return st[t]=ut(r||{}),st[t]},getTheme:function(t){return ut(t)},listThemes:function(){return Object.keys(st)}}})(typeof window<"u"?window:void 0);
|
package/dist/veyforma-pla.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
2
|
(function(K){"use strict";var mt="1.0.0",Lt="http://www.w3.org/2000/svg",Tt=0,nt={hpl:"#111827",rtpl:"#c2410c",unexplained:"#6b7280",contribution:"#a63d16",offset:"#2f6fed",standalone:"#111827",zones:{green:"#15803d",amber:"#b45309",red:"#b91c1c"},outside:"#d1d5db",grid:"#ececec",axis:"#9ca3af",text:"#111827",mutedText:"#4b5563",axisText:"#4b5563",cardBackground:"#f9fafb",background:"transparent",tooltipBackground:"#111827",tooltipText:"#ffffff",focus:"#c2410c",accent:"#c2410c",fontFamily:"inherit",fontSize:12},pt={veyforma:{},mono:{hpl:"#111111",rtpl:"#6b6b6b",unexplained:"#8a8a8a",contribution:"#111111",offset:"#8a8a8a",zones:{green:"#111111",amber:"#4b4b4b",red:"#111111"},accent:"#111111",focus:"#111111"},"colour-safe":{hpl:"#1f2937",rtpl:"#d55e00",unexplained:"#6b7280",contribution:"#cc3311",offset:"#0072b2",zones:{green:"#007a5e",amber:"#a35c00",red:"#b2182b"},accent:"#0072b2"},ocean:{hpl:"#0c3b5e",rtpl:"#0e7490",contribution:"#0c3b5e",offset:"#c2410c",cardBackground:"#eef5f8",accent:"#0e7490"},forest:{hpl:"#22311a",rtpl:"#4d6b31",contribution:"#22311a",offset:"#2f6fed",cardBackground:"#f2f4ee",accent:"#4d6b31"},corporate:{hpl:"#1e293b",rtpl:"#1d4ed8",contribution:"#1e293b",offset:"#c2410c",cardBackground:"#f1f4f8",accent:"#1d4ed8"},midnight:{background:"#111418",hpl:"#f3f4f6",rtpl:"#f08a5d",unexplained:"#8b93a1",contribution:"#f08a5d",offset:"#93c5fd",standalone:"#f3f4f6",zones:{green:"#4ade80",amber:"#fbbf24",red:"#fb7185"},outside:"#374151",grid:"#252a31",axis:"#4b5563",text:"#f3f4f6",mutedText:"#a3abb8",axisText:"#a3abb8",cardBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd",accent:"#f08a5d"}},dt={spearmanGreen:.8,spearmanRed:.7,ksGreen:.09,ksRed:.12},vt={data:null,view:"factors",window:250,fix:null,thresholds:null,top:15,pathSteps:5,theme:"veyforma",locale:void 0,animate:!0,summary:!0,legend:!0,labels:null,ariaLabel:void 0,caption:!0,annotations:null,onAnnotationsChange:null,onItemClick:null,exportDays:2e4,toolbar:!0},ut={factors:"Unexplained P&L by risk factor",daily:"HPL and RTPL by day",distribution:"Distribution of HPL and RTPL",hpl:"HPL (front office)",rtpl:"RTPL (risk model)",unexplained:"Unexplained (HPL \u2212 RTPL)",adds:"Adds to unexplained volatility",offsets:"Offsets other gaps",standalone:"Gap on its own",test:"PLA test",unexplainedCard:"Unexplained P&L",largest:"Largest driver",path:"Path to green",green:"Green",amber:"Amber",red:"Red",na:"n/a",other:"Other {n} factors",unattributed:"Unattributed",notModelled:"not in the risk model",ifFixed:"If fixed",outside:"Outside the test window"};function Y(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];if(a)for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t}var gt={};function Q(t){gt[t]||(gt[t]=1,K.console&&console.warn&&console.warn("VeyPlaAttribution: "+t))}function j(t){throw new Error("VeyPlaAttribution: "+t)}function at(t,e,a){return Math.min(a,Math.max(e,t))}function xt(t,e){return String(t).replace(/\{(\w+)\}/g,function(a,r){return e[r]!=null?e[r]:a})}function Gt(t){return t=String(t),/^[A-Z0-9]{2}/.test(t)?t:t.charAt(0).toLowerCase()+t.slice(1)}function Mt(t){return typeof t=="number"?t:t==null||t===""?NaN:+t}function G(t,e,a){var r=document.createElementNS(Lt,t);if(e)for(var n in e)e[n]!=null&&r.setAttribute(n,e[n]);return a&&a.appendChild(r),r}function P(t,e,a){var r=document.createElement(t);return e&&(r.className=e),a&&a.appendChild(r),r}var tt=null;function B(t,e,a,r){if(!tt){var n=document.createElement("canvas");tt=n.getContext&&n.getContext("2d")}return tt?(tt.font=(a||400)+" "+e+"px "+r,tt.measureText(String(t)).width):String(t).length*e*.6}function rt(t,e,a,r,n){if(t=String(t),B(t,a,r,n)<=e)return t;for(;t.length>2&&B(t+"\u2026",a,r,n)>e;)t=t.slice(0,-1);return t.replace(/\s+$/,"")+"\u2026"}function it(t){var e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(t||"").trim());if(!e)return null;var a=e[1].length===3?e[1].replace(/./g,"$&$&"):e[1],r=parseInt(a,16);return[r>>16&255,r>>8&255,r&255]}function ft(t){var e=t.map(function(a){return a/=255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)});return .2126*e[0]+.7152*e[1]+.0722*e[2]}function bt(t,e){var a=it(t),r=it(e);if(!a||!r)return 21;var n=ft(a),i=ft(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function q(t,e,a){var r=it(t),n=it(e);if(!r||!n||bt(t,e)>=a)return t;for(var i=ft(n)>.4,s=0,l=t;s<=1&&bt(l,e)<a;)s+=.05,l="#"+r.map(function(p){var f=i?p*(1-s):p+(255-p)*s;return("0"+Math.round(f).toString(16)).slice(-2)}).join("");return l}function ot(t,e){var a=t.decimals!=null?t.decimals:0,r=t.ratioDecimals!=null?t.ratioDecimals:1,n=t.prefix||"",i=t.suffix||"",s={},l=t.negatives==="brackets";function p(u){return s[u]||(s[u]=new Intl.NumberFormat(e||void 0,{minimumFractionDigits:u,maximumFractionDigits:u})),s[u]}function f(u,v){if(u==null||!isFinite(u))return"\u2013";v==null&&(v=a);var b=Number(u.toFixed(v)),k=n+p(v).format(Math.abs(b))+i;return b>=0?k:l?"("+k+")":"\u2212"+k}function c(u,v){var b=f(u,v);return u!=null&&Number(u.toFixed(v??a))>0?"+"+b:b}function o(u,v){return u==null||!isFinite(u)?"\u2013":(u<0?"\u2212":"")+p(v??r).format(Math.abs(u)*100)+"%"}function m(u,v){if(u==null||!isFinite(u))return"\u2013";var b=v??Math.max(r,1),k=Number((u*100).toFixed(b));return(k>0?"+":k<0?"\u2212":"")+p(b).format(Math.abs(k))+" pp"}function h(u,v){return u==null||!isFinite(u)?"\u2013":p(v??1).format(u*100)+"%"}return{value:f,signed:c,ratio:o,pp:m,percent:h,nf:p}}function yt(t,e){var a=Mt(t);return isFinite(a)||j(e+" must be a number."),a}function wt(t){var e=t.length,a=new Array(e),r=new Array(e),n,i;for(n=0;n<e;n++)a[n]=n;for(a.sort(function(p,f){return t[p]-t[f]}),n=0;n<e;n=i){for(i=n;i<e&&t[a[i]]===t[a[n]];)i++;for(var s=(n+i+1)/2,l=n;l<i;l++)r[a[l]]=s}return r}function zt(t,e){var a=t.length,r=0,n=0,i;for(i=0;i<a;i++)r+=t[i],n+=e[i];r/=a,n/=a;var s=0,l=0,p=0;for(i=0;i<a;i++){var f=t[i]-r,c=e[i]-n;s+=f*c,l+=f*f,p+=c*c}return l>0&&p>0?s/Math.sqrt(l*p):null}function Et(t,e){return zt(wt(t),wt(e))}function Pt(t,e){for(var a=t.slice().sort(function(m,h){return m-h}),r=e.slice().sort(function(m,h){return m-h}),n=a.length,i=r.length,s=0,l=0,p=0,f=a.length?a[0]:0;s<n&&l<i;){for(var c=Math.min(a[s],r[l]);s<n&&a[s]===c;)s++;for(;l<i&&r[l]===c;)l++;var o=Math.abs(s/n-l/i);o>p+1e-15&&(p=o,f=c)}return{d:p,at:f}}function Rt(t,e,a){return t==null?"red":(t=Math.round(t*1e12)/1e12,e=Math.round(e*1e12)/1e12,t>a.spearmanGreen&&e<a.ksGreen?"green":t<a.spearmanRed||e>a.ksRed?"red":"amber")}function kt(t,e){return Math.max(0,e.spearmanGreen-(t.spearman==null?-1:t.spearman))/.1+Math.max(0,t.ks-e.ksGreen)/.03}function st(t,e,a){var r=Et(t,e),n=Pt(t,e);return{spearman:r,ks:n.d,ksAt:n.at,zone:Rt(r,n.d,a)}}function ht(t){var e=t.length,a=0,r=0,n;for(n=0;n<e;n++)a+=t[n];for(a/=e,n=0;n<e;n++)r+=(t[n]-a)*(t[n]-a);return Math.sqrt(r/e)}function St(t){for(var e=0,a=0;a<t.length;a++)e+=t[a];return t.length?e/t.length:0}function Ft(t){(!t||typeof t!="object")&&j("data is required.");var e=t.dates;(!Array.isArray(e)||e.length<2)&&j("data.dates must be an array of at least two days.");var a=e.length,r=function(o,m,h){return o==null&&h?null:((!Array.isArray(o)||o.length!==a)&&j(m+" must be an array with one value per date ("+a+")."),o.map(function(u,v){return yt(u,m+"["+v+"]")}))};(!Array.isArray(t.factors)||!t.factors.length)&&j("data.factors must be a non-empty array of risk factors.");var n={},i=t.factors.map(function(o,m){(!o||typeof o!="object")&&j("data.factors["+m+"] is not an object."),o.key==null&&o.label==null&&j("data.factors["+m+"] needs a key or a label.");var h=String(o.key!=null?o.key:o.label),u='factor "'+h+'"';n[h]&&j(u+" is used twice."),n[h]=1;var v=r(o.hpl,u+": hpl"),b=r(o.rtpl,u+": rtpl",!0);return{key:h,label:o.label!=null?String(o.label):h,group:o.group!=null?String(o.group):"Other",modelled:b!=null,hpl:v,rtpl:b||v.map(function(){return 0}),index:m}}),s=r(t.hplTotal,"data.hplTotal",!0),l=r(t.rtplTotal,"data.rtplTotal",!0);if(s||l){var p=new Array(a),f=new Array(a),c;for(c=0;c<a;c++)p[c]=0,f[c]=0,i.forEach(function(o){p[c]+=o.hpl[c],f[c]+=o.rtpl[c]});i.push({key:"__unattributed",label:t.unattributedLabel||ut.unattributed,group:"Unattributed",modelled:!0,unattributed:!0,hpl:p.map(function(o,m){return s?s[m]-o:0}),rtpl:f.map(function(o,m){return l?l[m]-o:0}),index:i.length})}return{dates:e.map(String),factors:i,n:a}}function et(t,e){e=e||{};var a=Ft(t),r=a.n,n=a.factors,i=Y({},dt,e.thresholds||{}),s=e.window!=null?Math.floor(yt(e.window,"window")):250;s>=2||j("window must be at least 2 days.");var l=s>r;l&&(s=r);var p=r-s,f={};(e.fix||[]).forEach(function(x){n.some(function(g){return g.key===String(x)})||Q('fix: there is no factor "'+x+'", so it changes nothing.'),f[String(x)]=1}),n.forEach(function(x){x.fixed=!!f[x.key],x.rt=x.fixed?x.hpl:x.rtpl,x.gap=x.hpl.map(function(g,C){return g-x.rt[C]})});var c=new Array(r),o=new Array(r),m=new Array(r),h,u;for(h=0;h<r;h++){var v=0,b=0;for(u=0;u<n.length;u++)v+=n[u].hpl[h],b+=n[u].rt[h];c[h]=v,o[h]=b,m[h]=v-b}var k=c.slice(p),L=o.slice(p),d=m.slice(p),y={dates:a.dates,hpl:c,rtpl:o,unexplained:m,start:p,window:s,shortWindow:l,thresholds:i,fixed:Object.keys(f)};y.test=st(k,L,i);var _=ht(d),M=ht(k),$=St(d);y.sdUnexplained=_,y.sdHpl=M,y.meanUnexplained=$,y.volRatio=M>0?_/M:null,y.meanRatio=M>0?$/M:null,y.varRatio=M>0?_*_/(M*M):null,n.forEach(function(x){var g=x.gap.slice(p),C=St(g),w=0;for(h=0;h<s;h++)w+=(g[h]-C)*(d[h]-$);for(w/=s,x.meanGap=C,x.sdGap=ht(g),x.contribution=_>0?w/_:0,x.share=_>0?x.contribution/_:0,x.hplSum=0,x.rtplSum=0,h=p;h<r;h++)x.hplSum+=x.hpl[h],x.rtplSum+=x.rt[h];if(x.hasGap=x.sdGap>0||C!==0,x.hasGap){var T=L.map(function(N,U){return N+g[U]});x.ifFixed=st(k,T,i)}else x.ifFixed=y.test});var O=n.slice().sort(function(x,g){return Math.abs(g.contribution)-Math.abs(x.contribution)||x.index-g.index});O.forEach(function(x,g){x.rank=g+1}),y.factors=n,y.order=O;for(var D=e.pathSteps!=null?Math.max(0,Math.floor(e.pathSteps)):5,R=[],H=L.slice(),A=y.test,W={};A.zone!=="green"&&R.length<D;){var E=null;if(n.forEach(function(x){if(!(W[x.key]||x.fixed||!x.hasGap)){var g=x.gap.slice(p),C=H.map(function(N,U){return N+g[U]}),w=st(k,C,i),T=kt(w,i);(!E||T<E.d-1e-12||Math.abs(T-E.d)<=1e-12&&(w.spearman||-1)>(E.t.spearman||-1))&&(E={f:x,t:w,d:T,R:C})}}),!E||E.d>=kt(A,i)-1e-12)break;W[E.f.key]=1,R.push({key:E.f.key,label:E.f.label,test:E.t}),H=E.R,A=E.t}return y.path=R,y.pathReachesGreen=y.test.zone==="green"||R.length>0&&R[R.length-1].test.zone==="green",y.distribution={hpl:k.slice().sort(function(x,g){return x-g}),rtpl:L.slice().sort(function(x,g){return x-g})},y}function At(){if(!document.getElementById("vpa-styles")){var t=".vpa{position:relative;color:var(--vpa-text);background:var(--vpa-bg);font-family:var(--vpa-font);line-height:1.4}.vpa.vpa-filled{padding:14px 14px 8px;border-radius:10px}.vpa-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:0 0 10px}.vpa-stat{background:var(--vpa-card);border-radius:8px;padding:9px 12px;min-width:0}.vpa-stat .k{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vpa-card-muted);font-weight:600;overflow-wrap:anywhere;hyphens:auto}.vpa-stat .v{font-size:19px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vpa-stat .n{font-size:12px;color:var(--vpa-card-muted)}.vpa-stat .v.vpa-zone{font-weight:800}.vpa-stat .v.vpa-wrap{white-space:normal;overflow-wrap:anywhere;line-height:1.2;font-size:17px}.vpa-scope{font-size:12px;color:var(--vpa-muted);margin:0 0 4px}.vpa-legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;margin:0 0 6px;color:var(--vpa-text)}.vpa-legend span{display:inline-flex;align-items:center;gap:6px}.vpa-legend i{display:inline-block;width:12px;height:12px;border-radius:3px}.vpa-legend i.vpa-tick{width:16px;height:3px;border-radius:1px}.vpa-legend i.vpa-ring{background:transparent!important;border:2px solid;border-radius:2px;width:9px;height:9px;transform:rotate(45deg)}.vpa-plot{display:block;width:100%;height:auto;overflow:visible;outline:none}.vpa-plot:focus-visible{outline:2px solid var(--vpa-focus);outline-offset:4px;border-radius:4px}.vpa-animate .vpa-grow{animation:vpa-fade .45s ease both}@keyframes vpa-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vpa-animate .vpa-grow{animation:none}}.vpa-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vpa-tip-bg);color:var(--vpa-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}.vpa-tip.vpa-on{opacity:1;transform:none}.vpa-tip b{font-weight:600}.vpa-table{border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums;margin:0 0 14px;min-width:100%}.vpa-table caption{text-align:left;font-weight:700;padding:0 0 6px}.vpa-table th,.vpa-table td{padding:5px 8px;border-bottom:1px solid rgba(127,127,127,.25);text-align:right;white-space:nowrap}.vpa-table th:first-child,.vpa-table td:first-child{text-align:left}.vpa-table tr.vpa-breach td{color:var(--vpa-hedge);font-weight:600}@media (max-width:420px){.vpa-summary{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))}.vpa-stat{padding:8px 10px}.vpa-stat .v{font-size:17px}}",e=P("style");e.id="vpa-styles",e.textContent=t,(document.head||document.documentElement).appendChild(e)}}function lt(t){var e;(t==null||t==="")&&(t="veyforma"),typeof t=="string"?(pt.hasOwnProperty(t)||(Q('Unknown theme "'+t+'". The "veyforma" theme is used instead.'),t="veyforma"),e=Y({},nt,pt[t])):typeof t=="object"?(e=Y(t.extends?lt(t.extends):Y({},nt),t),delete e.extends):(Q("The theme option must be a theme name or an object."),e=Y({},nt));var a=/^#/.test(e.background)?e.background:"#ffffff",r=/^#/.test(e.cardBackground)?e.cardBackground:a;return["axisText","mutedText"].forEach(function(n){e[n]=q(e[n],a,4.5)}),e.cardMuted=q(e.mutedText,r,4.5),e.offsetText=q(q(e.offset,a,4.5),r,4.5),e.zoneText={},["green","amber","red"].forEach(function(n){e.zoneText[n]=q(q(e.zones[n],a,4.5),r,4.5)}),e.accentText=q(e.accent,a,4.5),e}function S(t,e){var a=typeof t=="string"?document.querySelector(t):t;(!a||a.nodeType!==1)&&j("container not found ("+t+")."),(!e||!e.data)&&j("options.data is required."),At(),this.id=++Tt,this.container=a,this.options=Y({},vt,e),this.element=P("div","vpa"),this.element.setAttribute("role","figure"),this.summaryEl=P("div","vpa-summary",this.element),this.scopeEl=P("p","vpa-scope",this.element),this.legendEl=P("div","vpa-legend",this.element),this.plotHost=P("div","vpa-plot-host",this.element),this.tipEl=P("div","vpa-tip",this.element),this.tipEl.setAttribute("role","tooltip"),a.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=-1;var r=this;K.ResizeObserver?(this._observer=new K.ResizeObserver(function(){var n=Math.round(r.element.clientWidth);n&&Math.abs(n-r._lastWidth)>1&&r.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){r.redraw()},K.addEventListener("resize",this._onResize)),this._onDocTap=function(n){r.element.contains(n.target)||r._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&K.VeyformaToolkit&&(this.toolkit=K.VeyformaToolkit.attach(this,this.options.toolbar))}S.prototype.update=function(t){return t?(t.data&&t.data!==this.options.data&&this.options.animate&&(this._animateNext=!0),t.view&&t.view!==this.options.view&&this.options.animate&&(this._animateNext=!0),Y(this.options,t),this.redraw()):this},S.prototype.setData=function(t){return this._res=null,this.update({data:t})},S.prototype.setView=function(t){return this.update({view:t})},S.prototype.setTheme=function(t){return this.update({theme:t})},S.prototype.getTheme=function(){return lt(this.options.theme)},S.prototype._opts=function(){return{window:this.options.window,fix:this.options.fix,thresholds:this.options.thresholds}},S.prototype.getResult=function(){return et(this.options.data,this._opts())},S.prototype.getFactor=function(t){return this.getResult().factors.filter(function(e){return e.key===String(t)})[0]||null},S.prototype.setFix=function(t){return this.update({fix:t})},S.prototype.setWindow=function(t){return this.update({window:t})},S.prototype._labels=function(){return Y({},ut,this.options.labels)},S.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&K.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},S.prototype._hideTip=function(){this.tipEl.classList.remove("vpa-on"),this._hlEl&&this._hlEl.setAttribute("opacity",0)},S.prototype._placeTip=function(t,e,a){var r=this.tipEl;r.textContent="",t.forEach(function(c,o){o&&r.appendChild(document.createElement("br"));var m=o===0?document.createElement("b"):document.createElement("span");m.textContent=c,r.appendChild(m)});var n=this.element.getBoundingClientRect(),i=a&&a.clientX?a.clientX:e.left+e.width/2,s=a&&a.clientY?a.clientY:e.top+10;r.classList.add("vpa-on");var l=r.offsetWidth,p=r.offsetHeight;r.style.left=at(i-n.left-l/2,4,Math.max(4,n.width-l-4))+"px";var f=s-n.top-p-14;f<0&&(f=s-n.top+18),r.style.top=f+"px"};function ct(t,e,a){e>t||(e=t+1);var r=e-t,n=Math.pow(10,Math.floor(Math.log(r/a)/Math.LN10)),i=r/a/n;i>=7.5?n*=10:i>=3.5?n*=5:i>=1.5&&(n*=2);for(var s=Math.floor(t/n+1e-9)*n,l=Math.ceil(e/n-1e-9)*n,p=[],f=s;f<=l+n/2;f+=n)p.push(Math.round(f/n)*n);return{lo:s,hi:l,ticks:p,step:n}}function I(t,e,a,r,n){var i=G("text",Y({x:e,y:a},n||{}),t);return i.textContent=r,i}S.prototype._bindInteraction=function(t,e,a,r,n,i){var s=this,l=this._items,p=this.options;function f(o){for(var m=t.getBoundingClientRect(),h=(o.clientX-m.left)*(e/m.width),u=(o.clientY-m.top)*(a/m.height),v=0;v<l.length;v++){var b=l[v];if(h>=b.x&&h<=b.x+b.w&&u>=b.y&&u<=b.y+b.h)return v}return-1}function c(o,m){if(o<0){s._hideTip();return}s._active=o;var h=l[o],u=s._hlEl;u.setAttribute("x",h.x-4),u.setAttribute("y",h.y),u.setAttribute("width",h.w+8),u.setAttribute("height",h.h),u.setAttribute("opacity",1);var v=t.getBoundingClientRect(),b=v.width/e,k={left:v.left+h.px*b,top:v.top+h.py*(v.height/a),width:0,height:0};s._placeTip(s._tipLines(h),k,m&&m.clientX?m:null)}t.addEventListener("pointermove",function(o){c(f(o),o)}),t.addEventListener("pointerleave",function(){s._hideTip()}),t.addEventListener("click",function(o){var m=f(o);m>=0&&typeof p.onItemClick=="function"&&p.onItemClick(s._detail(l[m]),o)}),t.addEventListener("keydown",function(o){var m=s._active;if(o.key==="ArrowRight"||o.key==="ArrowDown")m=Math.min(l.length-1,m+1);else if(o.key==="ArrowLeft"||o.key==="ArrowUp")m=Math.max(0,m<0?0:m-1);else if(o.key==="Home")m=0;else if(o.key==="End")m=l.length-1;else if(o.key==="Escape"){s._hideTip();return}else if((o.key==="Enter"||o.key===" ")&&m>=0){typeof p.onItemClick=="function"&&p.onItemClick(s._detail(l[m]),o),o.preventDefault();return}else return;o.preventDefault(),c(m,null)}),t.addEventListener("blur",function(){s._hideTip()})},S.prototype.createTable=function(){var t=this.getExportData(),e=P("div","vpa-tables");return t.sheets.forEach(function(a){if(a.name!=="Notes"){var r=P("table","vpa-table",e);P("caption",null,r).textContent=a.name;var n=P("tr",null,P("thead",null,r));a.columns.forEach(function(s){var l=P("th",null,n);l.scope="col",l.textContent=s.label});var i=P("tbody",null,r);a.text.forEach(function(s,l){var p=P("tr",a.flag&&a.flag[l]?"vpa-breach":null,i);s.forEach(function(f,c){var o=P(c?"td":"th",null,p);c||(o.scope="row"),o.textContent=f})})}}),e},S.prototype.redraw=function(){var t=this.options,e=t.data,a=this._labels(),r=this._res=et(e,Y(this._opts(),{pathSteps:t.pathSteps})),n=lt(t.theme),i=ot(e,t.locale),s=this.element,l=s.style,p=n.fontFamily==="inherit"?K.getComputedStyle?K.getComputedStyle(this.container).fontFamily:"sans-serif":n.fontFamily,f=n.background&&n.background!=="transparent",c=f?n.background:"#ffffff";l.setProperty("--vpa-text",n.text),l.setProperty("--vpa-muted",n.mutedText),l.setProperty("--vpa-bg",f?n.background:"transparent"),l.setProperty("--vpa-font",p),l.setProperty("--vpa-card",n.cardBackground),l.setProperty("--vpa-card-muted",n.cardMuted),l.setProperty("--vpa-tip-bg",n.tooltipBackground),l.setProperty("--vpa-tip-text",n.tooltipText),l.setProperty("--vpa-focus",n.focus),l.setProperty("--vpa-hedge",n.zoneText.red),s.classList.toggle("vpa-filled",!!f),s.setAttribute("aria-label",t.ariaLabel||e.title||"P&L attribution");var o=t.view;["factors","daily","distribution"].indexOf(o)<0&&(Q('Unknown view "'+o+'". The factor view is shown instead.'),o="factors"),r.shortWindow&&!this._warnedShort&&(Q("There are fewer days than the "+(t.window||250)+"-day window; all "+r.window+" are used."),this._warnedShort=!0),this._view=o,this._renderSummary(r,i,a,n),this.scopeEl.textContent=[a[o],r.window+"-day window",e.unit||null,r.fixed.length?r.fixed.length+" fix"+(r.fixed.length>1?"es":"")+" applied":null].filter(Boolean).join(" \xB7 "),this._renderLegend(o,n,a,r);var m=Math.max(280,Math.round(this.plotHost.clientWidth||s.clientWidth||720));this._lastWidth=Math.round(s.clientWidth);var h=n.fontSize||12;this.plotHost.textContent="";var u=G("svg",{class:"vpa-plot",role:"img",tabindex:0,"font-family":p},this.plotHost);u.style.fontSize=h+"px";var v=this._animateNext&&t.animate;this._animateNext=!1,v&&u.classList.add("vpa-animate");var b={svg:u,W:m,fs:h,theme:n,f:i,L:a,family:p,bg:c,res:r,items:[],points:{}},k=o==="daily"?this._drawDaily(b):o==="distribution"?this._drawDistribution(b):this._drawFactors(b);return u.setAttribute("viewBox","0 0 "+m+" "+k),u.setAttribute("width",m),u.setAttribute("height",k),u.setAttribute("aria-label",(t.ariaLabel||e.title||"P&L attribution")+". "+this.describe()),this._items=b.items,this._points=b.points,this._hlEl=G("rect",{x:0,y:0,width:0,height:0,rx:4,fill:n.text,"fill-opacity":.06,opacity:0,"pointer-events":"none"},u),u.insertBefore(this._hlEl,u.firstChild),this._bindInteraction(u,m,k,n,a,i),this};function F(t){return t==null?"n/a":t.toFixed(2)}S.prototype._zoneName=function(t){var e=this._labels();return e[t]||t},S.prototype._renderSummary=function(t,e,a,r){var n=this.summaryEl,i=this.options,s=this;if(n.textContent="",n.style.display=i.summary===!1?"none":"",i.summary===!1)return;function l(c,o,m,h,u){var v=P("div","vpa-stat",n);P("div","k",v).textContent=c;var b=P("div",h?"v "+h:"v",v);b.textContent=o,u&&(b.style.color=u),m&&(P("div","n",v).textContent=m)}var p=t.test,f=t.order[0];l(a.test,this._zoneName(p.zone),"Spearman "+F(p.spearman)+" \xB7 KS "+F(p.ks)+" ("+t.window+" days)","vpa-zone",r.zoneText[p.zone]),l(a.unexplainedCard,"\xB1"+e.value(t.sdUnexplained),(t.volRatio!=null?e.percent(t.volRatio,0)+" of HPL volatility \xB7 ":"")+"mean "+e.signed(t.meanUnexplained)+" a day"),l(a.largest,f.label,e.percent(f.share,0)+" of the unexplained volatility","vpa-wrap"),p.zone==="green"?l(a.path,"Already green","margin: Spearman +"+(p.spearman-t.thresholds.spearmanGreen).toFixed(2)+", KS \u2212"+(t.thresholds.ksGreen-p.ks).toFixed(2)):t.pathReachesGreen?l(a.path,"Fix "+t.path.length+" factor"+(t.path.length>1?"s":""),t.path.map(function(c){return c.label}).join(", ")+" \u2192 Spearman "+F(t.path[t.path.length-1].test.spearman)+", KS "+F(t.path[t.path.length-1].test.ks),"vpa-wrap"):l(a.path,t.path.length?"Not within "+t.path.length+" fix"+(t.path.length>1?"es":""):"No single fix helps",t.path.length?"best reached: "+this._zoneName(t.path[t.path.length-1].test.zone).toLowerCase():"the gap is spread across factors"),Array.prototype.forEach.call(n.querySelectorAll(".vpa-stat .v"),function(c){c.style.fontSize="";for(var o=parseFloat(K.getComputedStyle?K.getComputedStyle(c).fontSize:19)||19;c.scrollWidth>c.clientWidth&&o>12;)o-=1,c.style.fontSize=o+"px"})},S.prototype._renderLegend=function(t,e,a,r){var n=this.legendEl;n.textContent="",n.style.display=this.options.legend===!1?"none":"";function i(s,l,p){var f=P("span",null,n),c=P("i",p||null,f);p==="vpa-ring"?c.style.borderColor=s:c.style.background=s,f.appendChild(document.createTextNode(l))}if(t==="factors"){i(e.contribution,a.adds),i(e.offset,a.offsets),i(e.standalone,a.standalone,"vpa-ring");return}i(e.hpl,a.hpl,"vpa-tick"),i(e.rtpl,a.rtpl,"vpa-tick"),t==="daily"&&(i(e.unexplained,a.unexplained),r.start>0&&i(e.outside,a.outside))};function Ct(t,e){var a=Math.min(Math.max.apply(null,e.map(function(n){return B(n,t.fs,600,t.family)}))+12,t.W*.34),r=t.W-a<300;return{nameW:r?0:a,narrow:r}}function _t(t,e,a,r,n,i,s,l,p,f){var c=t.theme,o=t.fs,m=t.family,h=t.W,u=-1/0;a.ticks.forEach(function(v){G("line",{x1:r(v),x2:r(v),y1:l,y2:p,stroke:v===0?c.axis:c.grid,"stroke-width":v===0?1.2:1},e);var b=f(v),k=B(b,o-1,400,m),L=r(v),d=L-k/2<0?"start":L+k/2>h?"end":"middle",y=d==="start"?L:d==="end"?L-k:L-k/2;y<u+8||(u=y+k,I(e,L,n+o,b,{"text-anchor":d,fill:c.axisText,"font-size":o-1,class:"vpa-tick"}))})}S.prototype._drawFactors=function(t){var e=t.res,a=t.theme,r=t.f,n=t.L,i=t.fs,s=t.family,l=t.W,p=t.svg,f=this,c=+this.options.top>0?Math.floor(+this.options.top):e.order.length,o=e.order.slice(c),m=e.order.slice(0,c).sort(function(g,C){return C.contribution-g.contribution}).map(function(g){return{kind:"factor",obj:g,name:g.label+(g.modelled?"":" *"),v:g.contribution,k:g.sdGap}});if(o.length){var h=0,u=0;o.forEach(function(g){h+=g.contribution,u+=g.sdGap}),m.push({kind:"other",obj:{count:o.length,contribution:h,factors:o},name:xt(n.other,{n:o.length}),v:h,k:null})}var v=Ct(t,m.map(function(g){return g.name})),b=Math.max(B("\u2192 "+n.amber,i-1,600,s),B("\u2192 "+n.green,i-1,600,s),B("\u2192 "+n.red,i-1,600,s))+14,k=Math.max.apply(null,m.map(function(g){return B(r.signed(g.v),i,700,s)}))+10,L=v.nameW,d=l-k-b,y=Math.max(26,i*2.1),_=v.narrow?i+4:0,M=4,$=Math.min(0,Math.min.apply(null,m.map(function(g){return g.v}))),O=Math.max.apply(null,m.map(function(g){return Math.max(g.v,g.k||0)}))||1,D=ct($,O,Math.max(2,Math.min(6,Math.floor((d-L)/90)))),R=function(g){return L+(at(g,D.lo,D.hi)-D.lo)/(D.hi-D.lo)*(d-L)},H=M+i+6,A=H+m.length*(y+_),W=G("g",{class:"vpa-factors"},p);_t(t,W,D,R,M,L,d,H,A,function(g){return r.value(g)}),I(W,l,M+i,n.ifFixed,{"text-anchor":"end",fill:a.axisText,"font-size":i-1,class:"vpa-tick"}),m.forEach(function(g,C){var w=H+C*(y+_)+_,T=y*.56,N=w+(y-T)/2,U=g.v<0&&r.value(-g.v)!==r.value(0);I(W,0,v.narrow?w-3:N+T/2+i*.35,rt(g.name,v.narrow?l-b:v.nameW-8,i,g.kind==="other"?400:600,s),{fill:g.kind==="other"?a.mutedText:a.text,"font-size":i,"font-weight":g.kind==="other"?400:600,class:"vpa-name"});var z=R(Math.min(0,g.v)),Z=R(Math.max(0,g.v));if(G("rect",{x:z,y:N,width:Math.max(.8,Z-z),height:T,rx:2,fill:U?a.offset:a.contribution,class:"vpa-grow vpa-cbar"+(U?" vpa-offset":"")},W),g.k!=null){var V=R(g.k),X=N+T/2;G("path",{d:"M"+V+","+(X-5)+"L"+(V+5)+","+X+"L"+V+","+(X+5)+"L"+(V-5)+","+X+"Z",fill:t.bg,stroke:a.standalone,"stroke-width":1.6,class:"vpa-sa"},W)}if(I(W,l-b,N+T/2+i*.35,r.signed(g.v),{"text-anchor":"end",fill:U?a.offsetText:a.text,"font-size":i,"font-weight":700,class:"vpa-val"}),g.kind==="factor"){var J=g.obj.ifFixed.zone;I(W,l,N+T/2+i*.35,"\u2192 "+f._zoneName(J),{"text-anchor":"end",fill:a.zoneText[J],"font-size":i-1,"font-weight":600,class:"vpa-zonefix"}),t.points[g.obj.key]={x:U?z:Z,y:N}}t.items.push({kind:g.kind,obj:g.obj,x:0,y:w-_,w:l,h:y+_,px:U?z:Z,py:N})});var E=["Shares add up to the unexplained volatility of \xB1"+r.value(e.sdUnexplained)+" a day over "+e.window+" days"];e.factors.some(function(g){return!g.modelled})&&E.push("* "+n.notModelled+" (RTPL taken as zero)"),E.push("\u201C"+n.ifFixed+"\u201D: test zone with that factor's RTPL set equal to its HPL");var x=A+i+8;return E.forEach(function(g){I(p,0,x,rt(g+".",l,i-1,400,s),{fill:a.mutedText,"font-size":i-1,class:"vpa-note"}),x+=i+3}),Math.ceil(x-i+6)},S.prototype._drawDaily=function(t){var e=t.res,a=t.theme,r=t.f,n=t.L,i=t.fs,s=t.family,l=t.W,p=t.svg,f=e.dates.length,c=e.hpl.concat(e.rtpl,e.unexplained),o=ct(Math.min(0,Math.min.apply(null,c)),Math.max(0,Math.max.apply(null,c)),l<480?4:6),m=Math.max.apply(null,o.ticks.map(function(w){return B(r.value(w),i-1,400,s)})),h=m+10,u=l-4,v=6,b=l<480?220:300,k=v+b,L=function(w){return h+(w+.5)/f*(u-h)},d=function(w){return v+(o.hi-at(w,o.lo,o.hi))/(o.hi-o.lo)*b},y=G("g",{class:"vpa-daily"},p);e.start>0&&G("rect",{x:h,y:v,width:L(e.start)-(u-h)/f/2-h,height:b,fill:a.outside,"fill-opacity":.35,class:"vpa-outside"},y),o.ticks.forEach(function(w){G("line",{x1:h,x2:u,y1:d(w),y2:d(w),stroke:w===0?a.axis:a.grid,"stroke-width":w===0?1.2:1},y),I(y,h-6,d(w)+(i-1)*.35,r.value(w),{"text-anchor":"end",fill:a.axisText,"font-size":i-1,class:"vpa-tick"})});var _=Math.max(.6,(u-h)/f*.7);e.unexplained.forEach(function(w,T){var N=d(Math.max(0,w)),U=d(Math.min(0,w));G("rect",{x:L(T)-_/2,y:N,width:_,height:Math.max(.6,U-N),fill:a.unexplained,"fill-opacity":T<e.start?.4:.85,class:"vpa-grow vpa-ubar"},y)});var M=function(w){return w.map(function(T,N){return(N?"L":"M")+L(N).toFixed(2)+","+d(T).toFixed(2)}).join("")};G("path",{d:M(e.hpl),fill:"none",stroke:a.hpl,"stroke-width":1.6,"stroke-linejoin":"round",class:"vpa-line vpa-hpl"},y),G("path",{d:M(e.rtpl),fill:"none",stroke:a.rtpl,"stroke-width":1.6,"stroke-dasharray":"4 2","stroke-linejoin":"round",class:"vpa-line vpa-rtpl"},y);for(var $=B(e.dates[0],i-1,400,s)+16,O=Math.max(1,Math.ceil($/((u-h)/f))),D=-1/0,R=0;R<f;R+=O){var H=L(R),A=B(e.dates[R],i-1,400,s),W=H-A/2<0?"start":H+A/2>l?"end":"middle",E=W==="start"?H:W==="end"?H-A:H-A/2;E<D+8||(D=E+A,I(y,H,k+i+9,e.dates[R],{"text-anchor":W,fill:a.axisText,"font-size":i-1,class:"vpa-tick"}))}var x=(u-h)/f;e.dates.forEach(function(w,T){t.items.push({kind:"day",index:T,x:L(T)-x/2,y:v,w:x,h:b,px:L(T),py:d(Math.max(e.hpl[T],e.rtpl[T]))}),t.points["date:"+w]={x:L(T),y:d(Math.max(e.hpl[T],e.rtpl[T]))}});var g=["Unexplained P&L \xB1"+r.value(e.sdUnexplained)+" a day ("+(e.volRatio!=null?r.percent(e.volRatio,0)+" of HPL volatility":"")+") over the last "+e.window+" days"],C=k+i*2+17;return g.forEach(function(w){I(p,0,C,rt(w+".",l,i-1,400,s),{fill:a.mutedText,"font-size":i-1,class:"vpa-note"}),C+=i+3}),Math.ceil(C-i+6)},S.prototype._drawDistribution=function(t){var e=t.res,a=t.theme,r=t.f,n=t.L,i=t.fs,s=t.family,l=t.W,p=t.svg,f=e.distribution,c=f.hpl.length,o=e.thresholds,m=Math.min(f.hpl[0],f.rtpl[0]),h=Math.max(f.hpl[c-1],f.rtpl[c-1]),u=ct(m,h,l<480?4:6),v=B("100%",i-1,400,s)+10,b=l-6,k=8,L=l<480?200:270,d=k+L,y=function(z){return v+(at(z,u.lo,u.hi)-u.lo)/(u.hi-u.lo)*(b-v)},_=function(z){return k+(1-z)*L},M=G("g",{class:"vpa-dist"},p);[0,.25,.5,.75,1].forEach(function(z){G("line",{x1:v,x2:b,y1:_(z),y2:_(z),stroke:z===0?a.axis:a.grid},M),I(M,v-6,_(z)+(i-1)*.35,Math.round(z*100)+"%",{"text-anchor":"end",fill:a.axisText,"font-size":i-1,class:"vpa-tick"})}),_t(t,M,u,y,d+8,v,b,k,d,function(z){return r.value(z)});var $=function(z){var Z="M"+y(u.lo)+","+_(0);return z.forEach(function(V,X){Z+="L"+y(V).toFixed(2)+","+_(X/c).toFixed(2)+"L"+y(V).toFixed(2)+","+_((X+1)/c).toFixed(2)}),Z+"L"+y(u.hi)+","+_(1)};G("path",{d:$(f.hpl),fill:"none",stroke:a.hpl,"stroke-width":1.8,class:"vpa-line vpa-hpl"},M),G("path",{d:$(f.rtpl),fill:"none",stroke:a.rtpl,"stroke-width":1.8,"stroke-dasharray":"4 2",class:"vpa-line vpa-rtpl"},M);var O=function(z,Z){for(var V=0,X=z.length;V<X;){var J=V+X>>1;z[J]<=Z?V=J+1:X=J}return V/z.length},D=e.test.ksAt,R=O(f.hpl,D),H=O(f.rtpl,D),A=y(D),W=e.test.zone;G("line",{x1:A,x2:A,y1:_(R),y2:_(H),stroke:a.zoneText[W],"stroke-width":3,class:"vpa-ksline"},M);var E="KS "+F(e.test.ks),x=B(E,i,700,s),g=A+8+x>l?A-8:A+8;G("rect",{x:(A+8+x>l?g-x:g)-3,y:(_(R)+_(H))/2-i*.7,width:x+6,height:i*1.4,rx:3,fill:t.bg,class:"vpa-lbg"},M),I(M,g,(_(R)+_(H))/2+i*.35,E,{"text-anchor":A+8+x>l?"end":"start",fill:a.zoneText[W],"font-size":i,"font-weight":700,class:"vpa-kslabel"});for(var C=0;C<=20;C++){var w=u.lo+(u.hi-u.lo)*C/20,T=(b-v)/20;t.items.push({kind:"point",value:w,ph:O(f.hpl,w),pr:O(f.rtpl,w),x:y(w)-T/2,y:k,w:T,h:L,px:y(w),py:_(Math.max(O(f.hpl,w),O(f.rtpl,w)))})}var N=["Spearman "+F(e.test.spearman)+" (green above "+o.spearmanGreen.toFixed(2)+", red below "+o.spearmanRed.toFixed(2)+") \xB7 KS "+F(e.test.ks)+" (green below "+o.ksGreen.toFixed(2)+", red above "+o.ksRed.toFixed(2)+")","Share of the "+e.window+" days with P&L at or below each value"],U=d+i*2+12;return N.forEach(function(z){I(p,0,U,rt(z+".",l,i-1,400,s),{fill:a.mutedText,"font-size":i-1,class:"vpa-note"}),U+=i+3}),Math.ceil(U-i+6)},S.prototype._tipLines=function(t){var e=this.options,a=ot(e.data,e.locale),r=this._labels(),n=this._res,i=this;if(t.kind==="other")return[xt(r.other,{n:t.obj.count}),"Together "+a.signed(t.obj.contribution)+" of the unexplained volatility"];if(t.kind==="day"){var s=t.index,l=n.factors.map(function(c){return{l:c.label,g:c.gap[s]}}).filter(function(c){return c.g!==0}).sort(function(c,o){return Math.abs(o.g)-Math.abs(c.g)}).slice(0,3);return[n.dates[s]+(s<n.start?" \xB7 "+r.outside.toLowerCase():""),r.hpl+" "+a.signed(n.hpl[s]),r.rtpl+" "+a.signed(n.rtpl[s]),r.unexplained+" "+a.signed(n.unexplained[s])].concat(l.length?["Largest gaps: "+l.map(function(c){return c.l+" "+a.signed(c.g)}).join(", ")]:[])}if(t.kind==="point")return["P&L at or below "+a.signed(t.value),"HPL "+a.percent(t.ph,0)+" of days \xB7 RTPL "+a.percent(t.pr,0),"Gap "+a.percent(Math.abs(t.ph-t.pr),0)+" (KS is the largest gap: "+F(n.test.ks)+")"];var p=t.obj,f=p.ifFixed;return[p.label+(p.modelled?"":" ("+r.notModelled+")"),p.group+" \xB7 rank "+p.rank+" of "+n.factors.length,"Share of unexplained volatility "+a.signed(p.contribution)+" ("+a.percent(p.share,0)+")","Gap on its own \xB1"+a.value(p.sdGap)+" a day \xB7 mean "+a.signed(p.meanGap),"HPL "+a.signed(p.hplSum)+" \xB7 RTPL "+a.signed(p.rtplSum)+" over "+n.window+" days",r.ifFixed+": "+i._zoneName(f.zone).toLowerCase()+" (Spearman "+F(f.spearman)+", KS "+F(f.ks)+")"]},S.prototype._detail=function(t){if(!t)return null;var e=this._res,a=this._view;if(t.kind==="other")return{view:a,kind:"other",count:t.obj.count,contribution:t.obj.contribution,factors:t.obj.factors.map(function(i){return i.key})};if(t.kind==="day"){var r=t.index;return{view:a,kind:"day",date:e.dates[r],hpl:e.hpl[r],rtpl:e.rtpl[r],unexplained:e.unexplained[r],inWindow:r>=e.start,gaps:e.factors.map(function(i){return{key:i.key,gap:i.gap[r]}})}}if(t.kind==="point")return{view:a,kind:"point",value:t.value,hplShare:t.ph,rtplShare:t.pr};var n=t.obj;return{view:a,kind:"factor",key:n.key,label:n.label,group:n.group,modelled:n.modelled,fixed:n.fixed,rank:n.rank,contribution:n.contribution,share:n.share,sdGap:n.sdGap,meanGap:n.meanGap,hplSum:n.hplSum,rtplSum:n.rtplSum,ifFixed:{spearman:n.ifFixed.spearman,ks:n.ifFixed.ks,zone:n.ifFixed.zone}}},S.prototype.howToRead=function(){var t=this._view||this.options.view;return t==="daily"?"The dark line is front-office hypothetical P&L (HPL) and the dashed line the risk model's P&L (RTPL), day by day. Grey bars are the difference, the unexplained P&L. Only the most recent days, inside the test window, count for the test.":t==="distribution"?"Each line shows the share of days with P&L at or below a value, for HPL and for RTPL. If the risk model matched the front office, the two lines would sit on top of each other. The coloured bar marks the largest gap between them, the Kolmogorov-Smirnov (KS) statistic.":"Each bar is one risk factor's share of the unexplained P&L volatility (HPL \u2212 RTPL). Shares add up exactly to the total; a bar to the left means the factor's gap offsets other gaps. The diamond is the factor's gap on its own, and the right column shows the test zone the desk would reach if that factor's gap were closed."},S.prototype.describe=function(){var t=this.options,e=ot(t.data,t.locale),a=this._labels(),r=this._res||et(t.data,this._opts()),n=r.test,i=r.thresholds,s=[],l=this,p=[];(n.spearman==null||n.spearman<=i.spearmanGreen)&&p.push("Spearman "+F(n.spearman)+(n.spearman!=null&&n.spearman>=i.spearmanRed?" is below "+i.spearmanGreen.toFixed(2):" is below "+i.spearmanRed.toFixed(2))),n.ks>=i.ksGreen&&p.push("KS "+F(n.ks)+(n.ks<=i.ksRed?" is above "+i.ksGreen.toFixed(2):" is above "+i.ksRed.toFixed(2))),s.push("Over the last "+r.window+" days the desk is in the "+this._zoneName(n.zone).toLowerCase()+" zone of the P&L attribution test"+(p.length?": "+p.join(" and ")+".":" (Spearman "+F(n.spearman)+", KS "+F(n.ks)+").")),s.push("Unexplained P&L is \xB1"+e.value(r.sdUnexplained)+" a day"+(r.volRatio!=null?", "+e.percent(r.volRatio,0)+" of the front office's P&L volatility":"")+".");var f=r.order[0],c=r.order[1];s.push(f.label+(f.modelled?"":", which is not in the risk model,")+" explains "+e.percent(f.share,0)+" of it"+(c?", followed by "+c.label+" ("+e.percent(c.share,0)+")":"")+".");var o=r.factors.filter(function(h){return h.share<-.02}).sort(function(h,u){return h.contribution-u.contribution});if(o.length&&s.push("The gap on "+o[0].label+" partly offsets the others."),n.zone!=="green")if(r.pathReachesGreen){var m=r.path[r.path.length-1].test;s.push("Closing the gap on "+r.path.map(function(h){return h.label}).join(" and ")+" would bring the desk to green (Spearman "+F(m.spearman)+", KS "+F(m.ks)+").")}else r.path.length&&s.push("Even closing the gaps on "+r.path.map(function(h){return h.label}).join(", ")+" only reaches "+this._zoneName(r.path[r.path.length-1].test.zone).toLowerCase()+".");return r.fixed.length&&s.push("Fixes applied: "+r.fixed.join(", ")+"."),s.join(" ")},S.prototype.getExportData=function(){var t=this.options,e=t.data,a=this._labels(),r=ot(e,t.locale),n=this._res||et(e,this._opts()),i=this,s=n.thresholds,l={prefix:e.prefix||"",suffix:e.suffix||"",decimals:e.decimals!=null?e.decimals:0,negatives:e.negatives},p=function(d){return{label:d,type:"number",unit:l}},f=function(d){return{label:d,type:"number",unit:{decimals:3}}},c=function(d){return{label:d,type:"percent",decimals:1}},o=function(d){return{label:d,type:"text"}},m=[];m.push({name:"Factors",columns:[{label:"Rank",type:"number",unit:{decimals:0}},o("Risk factor"),o("Group"),o("In risk model"),o("Fixed"),p("HPL over window"),p("RTPL over window"),p("Mean daily gap"),p("Gap volatility"),p("Share of unexplained volatility"),c("Share (%)"),f("Spearman if fixed"),f("KS if fixed"),o("Zone if fixed")],rows:n.order.map(function(d){return[d.rank,d.label,d.group,d.modelled?"Yes":"No",d.fixed?"Yes":"No",d.hplSum,d.rtplSum,d.meanGap,d.sdGap,d.contribution,d.share,d.ifFixed.spearman,d.ifFixed.ks,i._zoneName(d.ifFixed.zone)]}),text:n.order.map(function(d){return[String(d.rank),d.label,d.group,d.modelled?"Yes":"No",d.fixed?"Yes":"No",r.signed(d.hplSum),r.signed(d.rtplSum),r.signed(d.meanGap),r.value(d.sdGap),r.signed(d.contribution),r.percent(d.share),F(d.ifFixed.spearman),F(d.ifFixed.ks),i._zoneName(d.ifFixed.zone)]}),flag:n.order.map(function(d){return!d.modelled})});for(var h=t.exportDays!=null?t.exportDays:2e4,u=Math.max(0,n.dates.length-h),v=[],b=u;b<n.dates.length;b++)v.push(b);m.push({name:"Daily",columns:[o("Date"),p("HPL"),p("RTPL"),p("Unexplained"),o("In test window")],rows:v.map(function(d){return[n.dates[d],n.hpl[d],n.rtpl[d],n.unexplained[d],d>=n.start?"Yes":"No"]}),text:v.map(function(d){return[n.dates[d],r.signed(n.hpl[d]),r.signed(n.rtpl[d]),r.signed(n.unexplained[d]),d>=n.start?"Yes":"No"]})});var k=[["Spearman correlation",n.test.spearman,"green above "+s.spearmanGreen+", red below "+s.spearmanRed],["Kolmogorov-Smirnov statistic",n.test.ks,"green below "+s.ksGreen+", red above "+s.ksRed],["Unexplained volatility \xF7 HPL volatility",n.volRatio,""],["Mean unexplained \xF7 HPL volatility",n.meanRatio,""],["Variance of unexplained \xF7 variance of HPL",n.varRatio,""]];n.path.forEach(function(d,y){k.push(["Path step "+(y+1)+": fix "+d.label+" \u2192 Spearman",d.test.spearman,i._zoneName(d.test.zone)],["Path step "+(y+1)+": fix "+d.label+" \u2192 KS",d.test.ks,i._zoneName(d.test.zone)])}),m.push({name:"Test",columns:[o("Measure"),f("Value"),o("Note")],rows:k,text:k.map(function(d){return[d[0],d[1]==null?"n/a":d[1].toFixed(3),d[2]]})});var L=(t.annotations||[]).map(function(d,y){return[String(y+1),d.factor!=null?String(d.factor):"Date: "+String(d.date||""),d.text||""]});return L.length&&m.push({name:"Notes",columns:[o("No."),o("Factor or date"),o("Note")],rows:L}),{title:e.title||"P&L attribution",subtitle:e.subtitle||"",summary:this.describe(),library:"Veyforma P&L Attribution "+mt,sheets:m,meta:[["Unit",e.unit],["As of",e.asOf],["Desk",e.desk],["Test window",n.window+" days ("+n.dates[n.start]+" to "+n.dates[n.dates.length-1]+")"],["PLA test zone",i._zoneName(n.test.zone)+" (Spearman "+F(n.test.spearman)+", KS "+F(n.test.ks)+")"],["Fixes applied",n.fixed.length?n.fixed.join(", "):null],["Method","Spearman = correlation of the ranks of daily HPL and RTPL (ties averaged); KS = largest gap between their empirical distribution functions; green if Spearman > "+s.spearmanGreen+" and KS < "+s.ksGreen+", red if Spearman < "+s.spearmanRed+" or KS > "+s.ksRed+`, otherwise amber; factor share = cov(gap, unexplained) \xF7 sd(unexplained), adds up to sd(unexplained); "if fixed" sets that factor's RTPL equal to its HPL`+(u>0?"; daily sheet limited to the last "+h+" days":"")],["Data source",e.source]]}},S.prototype._annotationPoint=function(t){var e=this._points||{};return t.factor!=null?e[String(t.factor)]||null:t.date!=null&&e["date:"+String(t.date)]||null},S.prototype._annotationTarget=function(t){var e=this._items||[],a=null;if(!t)a=e[this._active];else for(var r=this.plotHost.querySelector("svg"),n=r.getBoundingClientRect(),i=r.viewBox.baseVal,s=(t.clientX-n.left)*(i.width/n.width),l=(t.clientY-n.top)*(i.height/n.height),p=0;p<e.length;p++){var f=e[p];if(s>=f.x&&s<=f.x+f.w&&l>=f.y&&l<=f.y+f.h){a=f;break}}return a?a.kind==="factor"?{factor:a.obj.key}:a.kind==="day"?{date:this._res.dates[a.index]}:null:null},S.prototype._annotationLabel=function(t){if(t.date!=null)return String(t.date);var e=(this._res||this.getResult()).factors.filter(function(a){return a.key===String(t.factor)})[0];return e?e.label:String(t.factor||"")},K.VeyPlaAttribution={version:mt,create:function(t,e){return new S(t,e)},compute:function(t,e){return et(t,e)},test:function(t,e,a){return st(t,e,Y({},dt,a||{}))},thresholds:dt,listThemes:function(){return Object.keys(pt)},getTheme:function(t){return lt(t)},defaults:{options:vt,labels:ut,theme:nt}}})(typeof window<"u"?window:void 0);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @veyforma/charts v1.0.
|
|
1
|
+
/*! @veyforma/charts v1.0.2 · MIT License · Copyright (c) 2026 Veyforma · https://github.com/veyforma/veyforma-charts */
|
|
2
2
|
(function(B){"use strict";var St="1.0.0",Ft="http://www.w3.org/2000/svg",It=0,lt={down:"#4b5563",up:"#c2410c",hedge:"#2f6fed",contribution:"#a63d16",convexity:"#111827",limit:"#b91c1c",grid:"#ececec",axis:"#9ca3af",text:"#111827",mutedText:"#4b5563",axisText:"#4b5563",cardBackground:"#f9fafb",background:"transparent",tooltipBackground:"#111827",tooltipText:"#ffffff",focus:"#c2410c",accent:"#c2410c",fontFamily:"inherit",fontSize:12},vt={veyforma:{},mono:{down:"#8a8a8a",up:"#111111",hedge:"#8a8a8a",contribution:"#111111",convexity:"#111111",limit:"#111111",accent:"#111111",focus:"#111111"},"colour-safe":{down:"#2166ac",up:"#b2182b",hedge:"#1b7837",contribution:"#762a83",limit:"#b2182b",accent:"#2166ac"},ocean:{down:"#64748b",up:"#0c6e8f",hedge:"#c2410c",contribution:"#0c3b5e",cardBackground:"#eef5f8",accent:"#0c6e8f"},forest:{down:"#78716c",up:"#4d6b31",hedge:"#2f6fed",contribution:"#22311a",cardBackground:"#f2f4ee",accent:"#4d6b31"},corporate:{down:"#64748b",up:"#1d4ed8",hedge:"#c2410c",contribution:"#1e293b",cardBackground:"#f1f4f8",accent:"#1d4ed8"},midnight:{background:"#111418",down:"#a3abb8",up:"#f08a5d",hedge:"#93c5fd",contribution:"#f08a5d",convexity:"#f3f4f6",limit:"#fb7185",grid:"#252a31",axis:"#4b5563",text:"#f3f4f6",mutedText:"#a3abb8",axisText:"#a3abb8",cardBackground:"#1b2027",tooltipBackground:"#f3f4f6",tooltipText:"#111418",focus:"#93c5fd",accent:"#f08a5d"}},Mt={data:null,view:"factors",sort:"swing",top:15,shockScale:1,whatIf:null,theme:"veyforma",locale:void 0,animate:!0,summary:!0,legend:!0,labels:null,ariaLabel:void 0,caption:!0,annotations:null,onAnnotationsChange:null,onItemClick:null,exportRows:2e4,toolbar:!0},_t={factors:"Impact by risk factor",groups:"Impact by group",contribution:"Share of the combined move",down:"Down shock",up:"Up shock",swing:"Swing",worst:"Worst result",convexity:"Convexity",linear:"Linear part",limit:"Limit",largest:"Largest driver",worstShock:"Worst single shock",topShare:"Top {n} factors",combined:"Combined move",contributionAdds:"Adds to the combined move",hedge:"Hedges (lowers it)",standalone:"Stand-alone",other:"Other {n} factors",whatIf:"What-if",interaction:"Interaction",noData:"n/a"};function P(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];if(n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}var Et={};function nt(t){Et[t]||(Et[t]=1,B.console&&console.warn&&console.warn("VeyRiskTornado: "+t))}function I(t){throw new Error("VeyRiskTornado: "+t)}function wt(t,e,n){return Math.min(n,Math.max(e,t))}function ot(t,e){return String(t).replace(/\{(\w+)\}/g,function(n,o){return e[o]!=null?e[o]:n})}function Ht(t){return t=String(t),/^[A-Z0-9]{2}/.test(t)?t:t.charAt(0).toLowerCase()+t.slice(1)}function Dt(t){return typeof t=="number"?t:t==null||t===""?NaN:+t}function A(t,e,n){var o=document.createElementNS(Ft,t);if(e)for(var r in e)e[r]!=null&&o.setAttribute(r,e[r]);return n&&n.appendChild(o),o}function _(t,e,n){var o=document.createElement(t);return e&&(o.className=e),n&&n.appendChild(o),o}var rt=null;function U(t,e,n,o){if(!rt){var r=document.createElement("canvas");rt=r.getContext&&r.getContext("2d")}return rt?(rt.font=(n||400)+" "+e+"px "+o,rt.measureText(String(t)).width):String(t).length*e*.6}function it(t,e,n,o,r){if(t=String(t),U(t,n,o,r)<=e)return t;for(;t.length>2&&U(t+"\u2026",n,o,r)>e;)t=t.slice(0,-1);return t.replace(/\s+$/,"")+"\u2026"}function ut(t){var e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(t||"").trim());if(!e)return null;var n=e[1].length===3?e[1].replace(/./g,"$&$&"):e[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function bt(t){var e=t.map(function(n){return n/=255,n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)});return .2126*e[0]+.7152*e[1]+.0722*e[2]}function Tt(t,e){var n=ut(t),o=ut(e);if(!n||!o)return 21;var r=bt(n),i=bt(o);return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}function X(t,e,n){var o=ut(t),r=ut(e);if(!o||!r||Tt(t,e)>=n)return t;for(var i=bt(r)>.4,s=0,u=t;s<=1&&Tt(u,e)<n;)s+=.05,u="#"+o.map(function(c){var a=i?c*(1-s):c+(255-c)*s;return("0"+Math.round(a).toString(16)).slice(-2)}).join("");return u}function ct(t,e){var n=t.decimals!=null?t.decimals:0,o=t.ratioDecimals!=null?t.ratioDecimals:1,r=t.prefix||"",i=t.suffix||"",s={},u=t.negatives==="brackets";function c(m){return s[m]||(s[m]=new Intl.NumberFormat(e||void 0,{minimumFractionDigits:m,maximumFractionDigits:m})),s[m]}function a(m,v){if(m==null||!isFinite(m))return"\u2013";v==null&&(v=n);var x=Number(m.toFixed(v)),y=r+c(v).format(Math.abs(x))+i;return x>=0?y:u?"("+y+")":"\u2212"+y}function f(m,v){var x=a(m,v);return m!=null&&Number(m.toFixed(v??n))>0?"+"+x:x}function d(m,v){return m==null||!isFinite(m)?"\u2013":(m<0?"\u2212":"")+c(v??o).format(Math.abs(m)*100)+"%"}function p(m,v){if(m==null||!isFinite(m))return"\u2013";var x=v??Math.max(o,1),y=Number((m*100).toFixed(x));return(y>0?"+":y<0?"\u2212":"")+c(x).format(Math.abs(y))+" pp"}function w(m,v){return m==null||!isFinite(m)?"\u2013":c(v??1).format(m*100)+"%"}return{value:a,signed:f,ratio:d,pp:p,percent:w,nf:c}}function F(t,e){var n=Dt(t);return isFinite(n)||I(e+" must be a number."),n}function gt(t,e){var n=F(t,e);return(n<-1||n>1)&&I(e+" must be between \u22121 and 1."),n}function Rt(t,e,n){var o=t.factors;(!Array.isArray(o)||!o.length)&&I("data.factors must be a non-empty array of risk factors.");var r={};return o.map(function(i,s){(!i||typeof i!="object")&&I("data.factors["+s+"] is not an object."),i.key==null&&i.label==null&&I("data.factors["+s+"] needs a key or a label.");var u=String(i.key!=null?i.key:i.label),c='factor "'+u+'"';r[u]&&I(c+" is used twice."),r[u]=1;var a=i.group!=null?String(i.group):"Other",f=i.shockDown!=null?F(i.shockDown,c+": shockDown"):i.shock!=null?-Math.abs(F(i.shock,c+": shock")):null,d=i.shockUp!=null?F(i.shockUp,c+": shockUp"):i.shock!=null?Math.abs(F(i.shock,c+": shock")):null,p,w,m;if(i.delta!=null){var v=F(i.delta,c+": delta"),x=i.gamma!=null?F(i.gamma,c+": gamma"):0;(f==null||d==null)&&I(c+": delta needs shockDown and shockUp (or shock).");var y=f*e,E=d*e;p=v*y+.5*x*y*y,w=v*E+.5*x*E*E,m="taylor"}else{(i.down==null||i.up==null)&&I(c+" needs down and up impacts, or delta (and gamma) with a shock.");var M=F(i.down,c+": down"),l=F(i.up,c+": up");if(e===1)p=M,w=l;else{var N=(l-M)/2,T=(l+M)/2;p=-N*e+T*e*e,w=N*e+T*e*e}m="revaluation"}var L=1;return n&&(n[u]!=null&&(L*=F(n[u],"whatIf."+u)),n[a]!=null&&a!==u&&(L*=F(n[a],"whatIf."+a))),{key:u,label:i.label!=null?String(i.label):u,group:a,unit:i.unit!=null?String(i.unit):"",shockDown:f==null?null:f*e,shockUp:d==null?null:d*e,down:p*L,up:w*L,source:m,index:s}})}function Ct(t,e,n){var o=t.length,r=new Array(o),i,s;if(e&&e.matrix){var u=e.matrix;for(i=0;i<o;i++){var c=0,a=u[i];for(s=0;s<o;s++)c+=(i===s?1:a[s])*n[s];r[i]=c}return r}var f=e?e.within:0,d=e?e.across:0,p={},w=0;for(i=0;i<o;i++)p[t[i].group]=(p[t[i].group]||0)+n[i],w+=n[i];for(i=0;i<o;i++){var m=p[t[i].group];r[i]=n[i]+f*(m-n[i])+d*(w-m)}return r}function Wt(t,e){var n=t.correlation;if(n==null)return null;if(typeof n!="object"&&I("data.correlation must be { within, across } or { matrix }."),n.matrix){var o=n.matrix;return(!Array.isArray(o)||o.length!==e||o.some(function(r){return!Array.isArray(r)||r.length!==e}))&&I("data.correlation.matrix must be square with one row per factor."),o.forEach(function(r,i){r.forEach(function(s,u){gt(s,"data.correlation.matrix["+i+"]["+u+"]")})}),{matrix:o}}return{within:n.within!=null?gt(n.within,"data.correlation.within"):0,across:n.across!=null?gt(n.across,"data.correlation.across"):0}}function K(t,e){e=e||{},(!t||typeof t!="object")&&I("data is required.");var n=e.shockScale!=null?F(e.shockScale,"shockScale"):1;n>0||I("shockScale must be more than 0.");var o=e.whatIf&&Object.keys(e.whatIf).length?e.whatIf:null,r=Rt(t,n,o),i=r.length;o&&Object.keys(o).forEach(function(h){r.some(function(k){return k.key===h||k.group===h})||nt('whatIf: there is no factor or group "'+h+'", so it changes nothing.')});var s=t.higherIsBetter!==!1,u=function(h){return s?-h:h},c=t.limit!=null?Math.abs(F(t.limit,"data.limit")):null,a=Wt(t,i),f=r.map(function(h){return(h.up-h.down)/2}),d=Ct(r,a,f),p=0,w;for(w=0;w<i;w++)p+=f[w]*d[w];var m=Math.sqrt(Math.max(0,p)),v=0,x=0,y=0,E=0;r.forEach(function(h,k){h.swing=Math.abs(h.up-h.down),h.linear=f[k],h.convexity=(h.up+h.down)/2,h.asymmetry=Math.abs(h.linear)+Math.abs(h.convexity)>0?Math.abs(h.convexity)/(Math.abs(h.linear)+Math.abs(h.convexity)):0,h.worst=u(h.down)>=u(h.up)?"down":"up",h.worstValue=h[h.worst],h.best=h.worst==="down"?"up":"down",h.breach=c!=null&&u(h.worstValue)>c+1e-12*Math.max(1,c),h.standalone=Math.abs(f[k]),h.contribution=m>0?f[k]*d[k]/m:0,v+=h.swing,x+=h.down,y+=h.up,E+=h.standalone});var M=r.slice().sort(e.sort==="worst"?function(h,k){return u(k.worstValue)-u(h.worstValue)||h.index-k.index}:function(h,k){return k.swing-h.swing||h.index-k.index}),l=0;M.forEach(function(h,k){h.rank=k+1,h.share=v>0?h.swing/v:0,l+=h.share,h.cumShare=l});var N={},T=[];r.forEach(function(h,k){var j=N[h.group];j||(j=N[h.group]={key:h.group,label:h.group,factors:[],idx:[],down:0,up:0,contribution:0,standaloneSum:0},T.push(j)),j.factors.push(h.key),j.idx.push(k),j.down+=h.down,j.up+=h.up,j.contribution+=h.contribution,j.standaloneSum+=h.standalone}),T.forEach(function(h){h.swing=Math.abs(h.up-h.down),h.linear=(h.up-h.down)/2,h.convexity=(h.up+h.down)/2,h.worst=u(h.down)>=u(h.up)?"down":"up",h.worstValue=h[h.worst],h.breach=c!=null&&u(h.worstValue)>c+1e-12*Math.max(1,c),h.share=v>0?h.swing/v:0;for(var k=h.idx.map(function(z){return r[z]}),j=h.idx.map(function(z){return f[z]}),at=a&&a.matrix?{matrix:h.idx.map(function(z){return h.idx.map(function(V){return a.matrix[z][V]})})}:a,H=Ct(k,at,j),b=0,W=0;W<j.length;W++)b+=j[W]*H[W];h.standalone=Math.sqrt(Math.max(0,b)),delete h.idx});var L=i>=10?5:Math.max(1,Math.ceil(i/2)),D=M.slice(0,L).reduce(function(h,k){return h+k.share},0),C={factors:r,order:M,groups:T,higherIsBetter:s,limit:c,base:t.base!=null?F(t.base,"data.base"):null,totalSwing:v,sumDown:x,sumUp:y,sigma:m,standalone:E,diversification:E-m,correlated:!!a,topN:L,topShare:D,breaches:r.filter(function(h){return h.breach}).length,shockScale:n,whatIf:o};if(C.worstFactor=r.slice().sort(function(h,k){return u(k.worstValue)-u(h.worstValue)||h.index-k.index})[0],t.joint&&(t.joint.down!=null||t.joint.up!=null)&&(n===1&&!o?(C.joint={down:t.joint.down!=null?F(t.joint.down,"data.joint.down"):null,up:t.joint.up!=null?F(t.joint.up,"data.joint.up"):null},C.interaction={down:C.joint.down!=null?C.joint.down-x:null,up:C.joint.up!=null?C.joint.up-y:null}):C.jointHidden=!0),o){var R=K(t,{shockScale:n,sort:e.sort});C.baseline={totalSwing:R.totalSwing,sigma:R.sigma,worstValue:R.worstFactor.worstValue,worstFactor:R.worstFactor.key}}return C}function Vt(){if(!document.getElementById("vtr-styles")){var t=".vtr{position:relative;color:var(--vtr-text);background:var(--vtr-bg);font-family:var(--vtr-font);line-height:1.4}.vtr.vtr-filled{padding:14px 14px 8px;border-radius:10px}.vtr-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px;margin:0 0 10px}.vtr-stat{background:var(--vtr-card);border-radius:8px;padding:9px 12px;min-width:0}.vtr-stat .k{font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--vtr-card-muted);font-weight:600;overflow-wrap:anywhere;hyphens:auto}.vtr-stat .v{font-size:19px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vtr-stat .n{font-size:12px;color:var(--vtr-card-muted)}.vtr-stat .v.vtr-wrap{white-space:normal;overflow-wrap:anywhere;line-height:1.2;font-size:17px}.vtr-scope{font-size:12px;color:var(--vtr-muted);margin:0 0 4px}.vtr-legend{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12px;margin:0 0 6px;color:var(--vtr-text)}.vtr-legend span{display:inline-flex;align-items:center;gap:6px}.vtr-legend i{display:inline-block;width:12px;height:12px;border-radius:3px}.vtr-legend i.vtr-tick{width:3px;height:14px;border-radius:1px}.vtr-legend i.vtr-ring{background:transparent!important;border:2px solid;border-radius:2px;width:9px;height:9px;transform:rotate(45deg)}.vtr-plot{display:block;width:100%;height:auto;overflow:visible;outline:none}.vtr-plot:focus-visible{outline:2px solid var(--vtr-focus);outline-offset:4px;border-radius:4px}.vtr-animate .vtr-grow{animation:vtr-fade .45s ease both}@keyframes vtr-fade{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.vtr-animate .vtr-grow{animation:none}}.vtr-tip{position:absolute;left:0;top:0;pointer-events:none;background:var(--vtr-tip-bg);color:var(--vtr-tip-text);font-size:12px;line-height:1.45;padding:8px 10px;border-radius:8px;opacity:0;transform:translateY(4px);transition:opacity .12s,transform .12s;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}.vtr-tip.vtr-on{opacity:1;transform:none}.vtr-tip b{font-weight:600}.vtr-table{border-collapse:collapse;font-size:12px;font-variant-numeric:tabular-nums;margin:0 0 14px;min-width:100%}.vtr-table caption{text-align:left;font-weight:700;padding:0 0 6px}.vtr-table th,.vtr-table td{padding:5px 8px;border-bottom:1px solid rgba(127,127,127,.25);text-align:right;white-space:nowrap}.vtr-table th:first-child,.vtr-table td:first-child{text-align:left}.vtr-table tr.vtr-breach td{color:var(--vtr-hedge);font-weight:600}@media (max-width:420px){.vtr-summary{grid-template-columns:repeat(auto-fit,minmax(118px,1fr))}.vtr-stat{padding:8px 10px}.vtr-stat .v{font-size:17px}}",e=_("style");e.id="vtr-styles",e.textContent=t,(document.head||document.documentElement).appendChild(e)}}function ht(t){var e;(t==null||t==="")&&(t="veyforma"),typeof t=="string"?(vt.hasOwnProperty(t)||(nt('Unknown theme "'+t+'". The "veyforma" theme is used instead.'),t="veyforma"),e=P({},lt,vt[t])):typeof t=="object"?(e=P(t.extends?ht(t.extends):P({},lt),t),delete e.extends):(nt("The theme option must be a theme name or an object."),e=P({},lt));var n=/^#/.test(e.background)?e.background:"#ffffff",o=/^#/.test(e.cardBackground)?e.cardBackground:n;return["axisText","mutedText"].forEach(function(r){e[r]=X(e[r],n,4.5)}),e.cardMuted=X(e.mutedText,o,4.5),e.hedgeText=X(X(e.hedge,n,4.5),o,4.5),e.limitText=X(X(e.limit,n,4.5),o,4.5),e.accentText=X(e.accent,n,4.5),e}function S(t,e){var n=typeof t=="string"?document.querySelector(t):t;(!n||n.nodeType!==1)&&I("container not found ("+t+")."),(!e||!e.data)&&I("options.data is required."),Vt(),this.id=++It,this.container=n,this.options=P({},Mt,e),this.element=_("div","vtr"),this.element.setAttribute("role","figure"),this.summaryEl=_("div","vtr-summary",this.element),this.scopeEl=_("p","vtr-scope",this.element),this.legendEl=_("div","vtr-legend",this.element),this.plotHost=_("div","vtr-plot-host",this.element),this.tipEl=_("div","vtr-tip",this.element),this.tipEl.setAttribute("role","tooltip"),n.appendChild(this.element),this._animateNext=!!this.options.animate,this._lastWidth=0,this._active=-1;var o=this;B.ResizeObserver?(this._observer=new B.ResizeObserver(function(){var r=Math.round(o.element.clientWidth);r&&Math.abs(r-o._lastWidth)>1&&o.redraw()}),this._observer.observe(this.element)):(this._onResize=function(){o.redraw()},B.addEventListener("resize",this._onResize)),this._onDocTap=function(r){o.element.contains(r.target)||o._hideTip()},document.addEventListener("pointerdown",this._onDocTap),this.redraw(),this.options.toolbar!==!1&&B.VeyformaToolkit&&(this.toolkit=B.VeyformaToolkit.attach(this,this.options.toolbar))}S.prototype.update=function(t){return t?(t.data&&t.data!==this.options.data&&this.options.animate&&(this._animateNext=!0),t.view&&t.view!==this.options.view&&this.options.animate&&(this._animateNext=!0),P(this.options,t),this.redraw()):this},S.prototype.setData=function(t){return this._res=null,this.update({data:t})},S.prototype.setView=function(t){return this.update({view:t})},S.prototype.setTheme=function(t){return this.update({theme:t})},S.prototype.getTheme=function(){return ht(this.options.theme)},S.prototype._opts=function(){return{shockScale:this.options.shockScale,whatIf:this.options.whatIf,sort:this.options.sort}},S.prototype.getResult=function(){return K(this.options.data,this._opts())},S.prototype.getFactor=function(t){return this.getResult().factors.filter(function(e){return e.key===String(t)})[0]||null},S.prototype.setWhatIf=function(t){return this.update({whatIf:t})},S.prototype.setShockScale=function(t){return this.update({shockScale:t})},S.prototype._labels=function(){return P({},_t,this.options.labels)},S.prototype.destroy=function(){this.toolkit&&this.toolkit.destroy&&this.toolkit.destroy(),this._observer&&this._observer.disconnect(),this._onResize&&B.removeEventListener("resize",this._onResize),document.removeEventListener("pointerdown",this._onDocTap),this.element.parentNode&&this.element.parentNode.removeChild(this.element)},S.prototype._hideTip=function(){this.tipEl.classList.remove("vtr-on"),this._hlEl&&this._hlEl.setAttribute("opacity",0)},S.prototype._placeTip=function(t,e,n){var o=this.tipEl;o.textContent="",t.forEach(function(f,d){d&&o.appendChild(document.createElement("br"));var p=d===0?document.createElement("b"):document.createElement("span");p.textContent=f,o.appendChild(p)});var r=this.element.getBoundingClientRect(),i=n&&n.clientX?n.clientX:e.left+e.width/2,s=n&&n.clientY?n.clientY:e.top+10;o.classList.add("vtr-on");var u=o.offsetWidth,c=o.offsetHeight;o.style.left=wt(i-r.left-u/2,4,Math.max(4,r.width-u-4))+"px";var a=s-r.top-c-14;a<0&&(a=s-r.top+18),o.style.top=a+"px"};function Lt(t,e,n){e>t||(e=t+1);var o=e-t,r=Math.pow(10,Math.floor(Math.log(o/n)/Math.LN10)),i=o/n/r;i>=7.5?r*=10:i>=3.5?r*=5:i>=1.5&&(r*=2);for(var s=Math.floor(t/r+1e-9)*r,u=Math.ceil(e/r-1e-9)*r,c=[],a=s;a<=u+r/2;a+=r)c.push(Math.round(a/r)*r);return{lo:s,hi:u,ticks:c,step:r}}function $(t,e,n,o,r){var i=A("text",P({x:e,y:n},r||{}),t);return i.textContent=o,i}S.prototype._bindInteraction=function(t,e,n,o,r,i){var s=this,u=this._items,c=this.options;function a(d){for(var p=t.getBoundingClientRect(),w=(d.clientX-p.left)*(e/p.width),m=(d.clientY-p.top)*(n/p.height),v=0;v<u.length;v++){var x=u[v];if(w>=x.x&&w<=x.x+x.w&&m>=x.y&&m<=x.y+x.h)return v}return-1}function f(d,p){if(d<0){s._hideTip();return}s._active=d;var w=u[d],m=s._hlEl;m.setAttribute("x",w.x-4),m.setAttribute("y",w.y),m.setAttribute("width",w.w+8),m.setAttribute("height",w.h),m.setAttribute("opacity",1);var v=t.getBoundingClientRect(),x=v.width/e,y={left:v.left+w.px*x,top:v.top+w.py*(v.height/n),width:0,height:0};s._placeTip(s._tipLines(w),y,p&&p.clientX?p:null)}t.addEventListener("pointermove",function(d){f(a(d),d)}),t.addEventListener("pointerleave",function(){s._hideTip()}),t.addEventListener("click",function(d){var p=a(d);p>=0&&typeof c.onItemClick=="function"&&c.onItemClick(s._detail(u[p]),d)}),t.addEventListener("keydown",function(d){var p=s._active;if(d.key==="ArrowRight"||d.key==="ArrowDown")p=Math.min(u.length-1,p+1);else if(d.key==="ArrowLeft"||d.key==="ArrowUp")p=Math.max(0,p<0?0:p-1);else if(d.key==="Home")p=0;else if(d.key==="End")p=u.length-1;else if(d.key==="Escape"){s._hideTip();return}else if((d.key==="Enter"||d.key===" ")&&p>=0){typeof c.onItemClick=="function"&&c.onItemClick(s._detail(u[p]),d),d.preventDefault();return}else return;d.preventDefault(),f(p,null)}),t.addEventListener("blur",function(){s._hideTip()})},S.prototype.createTable=function(){var t=this.getExportData(),e=_("div","vtr-tables");return t.sheets.forEach(function(n){if(n.name!=="Notes"){var o=_("table","vtr-table",e);_("caption",null,o).textContent=n.name;var r=_("tr",null,_("thead",null,o));n.columns.forEach(function(s){var u=_("th",null,r);u.scope="col",u.textContent=s.label});var i=_("tbody",null,o);n.text.forEach(function(s,u){var c=_("tr",n.flag&&n.flag[u]?"vtr-breach":null,i);s.forEach(function(a,f){var d=_(f?"td":"th",null,c);f||(d.scope="row"),d.textContent=a})})}}),e};function dt(t,e,n){if(t==null||!isFinite(t))return"";var o=Number(Math.abs(t).toFixed(4)).toLocaleString(n||void 0,{maximumFractionDigits:4});return(t>0?"+":t<0?"\u2212":"")+o+(e?e==="%"?"%":" "+e:"")}S.prototype.redraw=function(){var t=this.options,e=t.data,n=this._labels(),o=this._res=K(e,this._opts()),r=ht(t.theme),i=ct(e,t.locale),s=this.element,u=s.style,c=r.fontFamily==="inherit"?B.getComputedStyle?B.getComputedStyle(this.container).fontFamily:"sans-serif":r.fontFamily,a=r.background&&r.background!=="transparent",f=a?r.background:"#ffffff";u.setProperty("--vtr-text",r.text),u.setProperty("--vtr-muted",r.mutedText),u.setProperty("--vtr-bg",a?r.background:"transparent"),u.setProperty("--vtr-font",c),u.setProperty("--vtr-card",r.cardBackground),u.setProperty("--vtr-card-muted",r.cardMuted),u.setProperty("--vtr-tip-bg",r.tooltipBackground),u.setProperty("--vtr-tip-text",r.tooltipText),u.setProperty("--vtr-focus",r.focus),u.setProperty("--vtr-hedge",r.limitText),s.classList.toggle("vtr-filled",!!a),s.setAttribute("aria-label",t.ariaLabel||e.title||"Risk-factor tornado");var d=t.view;["factors","groups","contribution"].indexOf(d)<0&&(nt('Unknown view "'+d+'". The factor view is shown instead.'),d="factors"),t.sort!=="swing"&&t.sort!=="worst"&&nt('Unknown sort "'+t.sort+'". Factors are ranked by swing instead.'),this._view=d,this._renderSummary(o,i,n);var p=[n[d],t.shockScale!=null&&+t.shockScale!=1?"shocks \xD7"+ +t.shockScale:null,e.unit||null,o.whatIf?n.whatIf+" applied":null].filter(Boolean).join(" \xB7 ");this.scopeEl.textContent=p,this._renderLegend(d,r,n,o);var w=Math.max(280,Math.round(this.plotHost.clientWidth||s.clientWidth||720));this._lastWidth=Math.round(s.clientWidth);var m=r.fontSize||12;this.plotHost.textContent="";var v=A("svg",{class:"vtr-plot",role:"img",tabindex:0,"font-family":c},this.plotHost);v.style.fontSize=m+"px";var x=this._animateNext&&t.animate;this._animateNext=!1,x&&v.classList.add("vtr-animate");var y={svg:v,W:w,fs:m,theme:r,f:i,L:n,family:c,bg:f,res:o,items:[],points:{}},E=d==="contribution"?this._drawContribution(y):this._drawRows(y,d);return v.setAttribute("viewBox","0 0 "+w+" "+E),v.setAttribute("width",w),v.setAttribute("height",E),v.setAttribute("aria-label",(t.ariaLabel||e.title||"Risk-factor tornado")+". "+this.describe()),this._items=y.items,this._points=y.points,this._hlEl=A("rect",{x:0,y:0,width:0,height:0,rx:4,fill:r.text,"fill-opacity":.06,opacity:0,"pointer-events":"none"},v),v.insertBefore(this._hlEl,v.firstChild),this._bindInteraction(v,w,E,r,n,i),this},S.prototype._shockNames=function(){var t=this._labels(),e=this.options.data.shockLabels||{};return{down:e.down||t.down,up:e.up||t.up}},S.prototype._renderSummary=function(t,e,n){var o=this.summaryEl,r=this.options;if(o.textContent="",o.style.display=r.summary===!1?"none":"",r.summary===!1)return;function i(a,f,d,p){var w=_("div","vtr-stat",o);_("div","k",w).textContent=a,_("div",p?"v vtr-wrap":"v",w).textContent=f,d&&(_("div","n",w).textContent=d)}var s=this._shockNames(),u=t.order[0],c=t.worstFactor;i(n.largest,u.label,n.swing.toLowerCase()+" "+e.value(u.swing)+" \xB7 "+e.percent(u.share,0)+" of the total",!0),i(n.worstShock,e.signed(c.worstValue),c.label+", "+s[c.worst].toLowerCase()+(t.limit!=null?t.breaches?" \xB7 "+t.breaches+" beyond the limit":" \xB7 within the limit":"")+(t.baseline?" \xB7 was "+e.signed(t.baseline.worstValue):"")),i(ot(n.topShare,{n:t.topN}),e.percent(t.topShare,0),"of the total swing across "+t.factors.length+" factors"),i(n.combined,"\xB1"+e.value(t.sigma),t.baseline?n.whatIf+": was \xB1"+e.value(t.baseline.sigma):t.correlated?t.standalone>0?e.percent(t.diversification/t.standalone,0)+" below the sum of stand-alone moves":"":"factors treated as independent"),Array.prototype.forEach.call(o.querySelectorAll(".vtr-stat .v"),function(a){a.style.fontSize="";for(var f=parseFloat(B.getComputedStyle?B.getComputedStyle(a).fontSize:19)||19;a.scrollWidth>a.clientWidth&&f>12;)f-=1,a.style.fontSize=f+"px"})},S.prototype._renderLegend=function(t,e,n,o){var r=this.legendEl,i=this._shockNames();r.textContent="",r.style.display=this.options.legend===!1?"none":"";function s(u,c,a){var f=_("span",null,r),d=_("i",a||null,f);a==="vtr-ring"?d.style.borderColor=u:d.style.background=u,f.appendChild(document.createTextNode(c))}if(t==="contribution"){s(e.contribution,n.contributionAdds),s(e.hedge,n.hedge),s(e.convexity,n.standalone,"vtr-ring");return}s(e.down,i.down),s(e.up,i.up),o.factors.some(function(u){return u.asymmetry>=.1})&&s(e.convexity,n.convexity+" (midpoint)","vtr-ring"),o.limit!=null&&s(e.limit,n.limit,"vtr-tick")};function jt(t,e){var n=Math.min(Math.max.apply(null,e.map(function(r){return U(r,t.fs,600,t.family)}))+12,t.W*.34),o=t.W-n<260;return{nameW:o?0:n,narrow:o}}function Nt(t,e,n,o,r,i,s,u,c){var a=t.theme,f=t.fs,d=t.family,p=t.W,w=t.f,m=-1/0,v=Math.max.apply(null,n.ticks.map(function(y){return U(w.value(y),f-1,400,d)})),x=Math.max(1,Math.ceil((v+10)/((s-i)/Math.max(1,n.ticks.length-1))));n.ticks.forEach(function(y,E){if(A("line",{x1:o(y),x2:o(y),y1:u,y2:c,stroke:y===0?a.axis:a.grid,"stroke-width":y===0?1.2:1},e),!(E%x)){var M=w.value(y),l=U(M,f-1,400,d),N=l/2,T=o(y),L=T-N<0?"start":T+N>p?"end":"middle",D=L==="start"?T:L==="end"?T-l:T-N;D<m+8||(m=D+l,$(e,T,r+f,M,{"text-anchor":L,fill:a.axisText,"font-size":f-1,class:"vtr-tick"}))}})}S.prototype._rowsFor=function(t,e,n){if(e==="groups")return t.groups.slice().sort(function(a,f){return f.swing-a.swing}).map(function(a){return{kind:"group",obj:a,name:a.label,down:a.down,up:a.up,breach:a.breach,convexity:a.convexity,asym:Math.abs(a.linear)+Math.abs(a.convexity)>0?Math.abs(a.convexity)/(Math.abs(a.linear)+Math.abs(a.convexity)):0}});var o=+this.options.top>0?Math.floor(+this.options.top):t.order.length,r=t.order.slice(0,o).map(function(a){return{kind:"factor",obj:a,name:a.rank+". "+a.label,down:a.down,up:a.up,breach:a.breach,convexity:a.convexity,asym:a.asymmetry}}),i=t.order.slice(o);if(i.length){var s=0,u=0,c=0;i.forEach(function(a){s+=a.down,u+=a.up,c+=a.swing}),r.push({kind:"other",obj:{count:i.length,down:s,up:u,swing:c,share:t.totalSwing>0?c/t.totalSwing:0,factors:i},name:ot(n.other,{n:i.length}),down:s,up:u,breach:!1,convexity:(s+u)/2,asym:0})}return r},S.prototype._drawRows=function(t,e){var n=t.res,o=t.theme,r=t.f,i=t.L,s=t.fs,u=t.family,c=t.W,a=t.svg,f=n.higherIsBetter,d=this._rowsFor(n,e,i),p=jt(t,d.map(function(g){return g.name})),w=n.limit!=null?f?-n.limit:n.limit:null,m=[];d.forEach(function(g){m.push(g.down,g.up)});var v=Math.min.apply(null,m.concat([0,w??0])),x=Math.max.apply(null,m.concat([0,w??0])),y=function(g){return U(r.signed(g),s-1,600,u)+6},E=Math.max.apply(null,[4].concat(m.filter(function(g){return g<0}).map(y))),M=Math.max.apply(null,[4].concat(m.filter(function(g){return g>=0}).map(y))),l=p.nameW+E,N=c-M,T=Lt(v,x,Math.max(2,Math.min(6,Math.floor((N-l)/90)))),L=function(g){return l+(wt(g,T.lo,T.hi)-T.lo)/(T.hi-T.lo)*(N-l)},D=4,C=Math.max(36,s*3),R=p.narrow?s+4:0,h=D+s+6,k=h+d.length*(C+R),j=A("g",{class:"vtr-rows"},a);Nt(t,j,T,L,D,l,N,h,k);var at=A("g",null,j),H=A("g",{class:"vtr-cvx-layer"},j),b=A("g",null,j);w!=null&&A("line",{x1:L(w),x2:L(w),y1:h-2,y2:k,stroke:o.limit,"stroke-width":1.6,"stroke-dasharray":"5 3",class:"vtr-limit"},H);var W=this._shockNames(),z=this;d.forEach(function(g,Q){var st=h+Q*(C+R)+R,tt=Math.max(C*.32,s),et=st+(C-2*tt-3)/2,Bt=g.breach?o.limitText:g.kind==="other"?o.mutedText:o.text,zt=it(g.name,p.narrow?c:p.nameW-8,s,g.kind==="other"?400:600,u);if(p.narrow&&A("rect",{x:0,y:st-3-s*.95,width:U(zt,s,600,u)+4,height:s*1.25,fill:t.bg,class:"vtr-lbg"},b),$(b,0,p.narrow?st-3:st+C/2+s*.35,it(g.name,p.narrow?c:p.nameW-8,s,g.kind==="other"?400:600,u),{fill:Bt,"font-size":s,"font-weight":g.kind==="other"?400:600,class:"vtr-name"}),[["down",et],["up",et+tt+3]].forEach(function(q){var J=g[q[0]],mt=L(Math.min(0,J)),xt=L(Math.max(0,J)),Ut=g.kind!=="other"&&g.obj.worst===q[0];A("rect",{x:mt,y:q[1],width:Math.max(.8,xt-mt),height:tt,rx:2,fill:o[q[0]],class:"vtr-grow vtr-bar","data-shock":q[0]},at);var kt=g.breach&&Ut,Ot=r.signed(J),At=U(Ot,s-1,kt?700:400,u),Pt=J<0?mt-4-At:xt+4;A("rect",{x:Pt-2,y:q[1]+tt/2-(s-1)*.6,width:At+4,height:(s-1)*1.2,fill:t.bg,class:"vtr-lbg"},b),$(b,J<0?mt-4:xt+4,q[1]+tt/2+(s-1)*.35,r.signed(J),{"text-anchor":J<0?"end":"start",fill:kt?o.limitText:o.text,"font-size":s-1,"font-weight":kt?700:400,class:"vtr-val"})}),g.asym>=.1){var ft=L(g.convexity),pt=et+tt+1.5;A("path",{d:"M"+ft+","+(pt-4)+"L"+(ft+4)+","+pt+"L"+ft+","+(pt+4)+"L"+(ft-4)+","+pt+"Z",fill:t.bg,stroke:o.convexity,"stroke-width":1.5,class:"vtr-cvx"},H)}var yt=L(Math.max(0,g.down,g.up));g.kind==="factor"&&(t.points[g.obj.key]={x:yt,y:et}),g.kind==="group"&&(t.points["group:"+g.obj.key]={x:yt,y:et}),t.items.push({kind:g.kind,obj:g.obj,x:0,y:st-R,w:c,h:C+R,px:yt,py:et})}),e==="groups"&&n.factors.forEach(function(g){t.points[g.key]||(t.points[g.key]=t.points["group:"+g.group])});var V=[];if(w!=null&&V.push(i.limit+" "+r.signed(w)+(n.breaches?": "+n.breaches+" factor"+(n.breaches>1?"s":"")+" beyond it":": no factor beyond it")),e==="factors"){var O=d.filter(function(g){return g.kind==="factor"}).length;if(V.push("Each factor shocked alone"+(O<n.factors.length?"; top "+O+" of "+n.factors.length+", the rest summed":"")),n.interaction){var Y=n.interaction,G=[];Y.down!=null&&G.push(W.down.toLowerCase()+" together "+r.signed(n.joint.down)+" vs sum "+r.signed(n.sumDown)),Y.up!=null&&G.push(W.up.toLowerCase()+" together "+r.signed(n.joint.up)+" vs sum "+r.signed(n.sumUp)),V.push("All factors "+G.join(", "))}}else V.push("Every factor in the group shocked the same way at once (sum of single shocks)");var Z=k+s+8;return V.forEach(function(g){$(a,0,Z,it(g+".",c,s-1,400,u),{fill:o.mutedText,"font-size":s-1,class:"vtr-note"}),Z+=s+3}),Math.ceil(Z-s+6)},S.prototype._drawContribution=function(t){var e=t.res,n=t.theme,o=t.f,r=t.L,i=t.fs,s=t.family,u=t.W,c=t.svg,a=e.factors.slice().sort(function(b,W){return Math.abs(W.contribution)-Math.abs(b.contribution)||b.index-W.index}),f=+this.options.top>0?Math.floor(+this.options.top):a.length,d=a.slice(f),p=a.slice(0,f).sort(function(b,W){return W.contribution-b.contribution}).map(function(b){return{kind:"factor",obj:b,name:b.label,v:b.contribution,k:b.standalone}});if(d.length){var w=0,m=0;d.forEach(function(b){w+=b.contribution,m+=b.standalone}),p.push({kind:"other",obj:{count:d.length,contribution:w,standalone:m,factors:d},name:ot(r.other,{n:d.length}),v:w,k:null})}var v=jt(t,p.map(function(b){return b.name})),x=Math.max.apply(null,p.map(function(b){return U(o.signed(b.v),i,700,s)}))+10,y=v.nameW,E=u-x,M=Math.max(24,i*2),l=v.narrow?i+4:0,N=4,T=Math.min(0,Math.min.apply(null,p.map(function(b){return b.v}))),L=Math.max.apply(null,p.map(function(b){return Math.max(b.v,b.k||0)}))||1,D=Lt(T,L,Math.max(2,Math.min(6,Math.floor((E-y)/90)))),C=function(b){return y+(wt(b,D.lo,D.hi)-D.lo)/(D.hi-D.lo)*(E-y)},R=N+i+6,h=R+p.length*(M+l),k=A("g",{class:"vtr-contrib"},c);Nt(t,k,D,C,N,y,E,R,h),p.forEach(function(b,W){var z=R+W*(M+l)+l,V=M*.56,O=z+(M-V)/2,Y=b.v<0;$(k,0,v.narrow?z-3:O+V/2+i*.35,it(b.name,v.narrow?u-x:v.nameW-8,i,b.kind==="other"?400:600,s),{fill:b.kind==="other"?n.mutedText:n.text,"font-size":i,"font-weight":b.kind==="other"?400:600,class:"vtr-name"});var G=C(Math.min(0,b.v)),Z=C(Math.max(0,b.v));if(A("rect",{x:G,y:O,width:Math.max(.8,Z-G),height:V,rx:2,fill:Y?n.hedge:n.contribution,class:"vtr-grow vtr-cbar"+(Y?" vtr-hedge":"")},k),b.k!=null){var g=C(b.k),Q=O+V/2;A("path",{d:"M"+g+","+(Q-5)+"L"+(g+5)+","+Q+"L"+g+","+(Q+5)+"L"+(g-5)+","+Q+"Z",fill:t.bg,stroke:n.convexity,"stroke-width":1.6,class:"vtr-sa"},k)}$(k,u,O+V/2+i*.35,o.signed(b.v),{"text-anchor":"end",fill:Y?n.hedgeText:n.text,"font-size":i,"font-weight":700,class:"vtr-val"}),b.kind==="factor"&&(t.points[b.obj.key]={x:Y?G:Z,y:O}),t.items.push({kind:b.kind,obj:b.obj,contrib:!0,x:0,y:z-l,w:u,h:M+l,px:Y?G:Z,py:O})});var j=e.correlated?this.options.data.correlation.matrix?"with the correlation matrix given":"with correlations of "+o.percent(this.options.data.correlation.within||0,0)+" within groups and "+o.percent(this.options.data.correlation.across||0,0)+" across":"no correlations given, so factors are treated as independent and none can hedge another",at=["Shares add up to the combined move of \xB1"+o.value(e.sigma)+"; stand-alone moves add up to "+o.value(e.standalone),"Combined "+j],H=h+i+8;return at.forEach(function(b){$(c,0,H,it(b+".",u,i-1,400,s),{fill:n.mutedText,"font-size":i-1,class:"vtr-note"}),H+=i+3}),Math.ceil(H-i+6)},S.prototype._tipLines=function(t){var e=this.options,n=ct(e.data,e.locale),o=this._labels(),r=this._res,i=this._shockNames(),s=e.locale,u=function(p){return r.base!=null?" \u2192 "+n.value(r.base+p):""};if(t.kind==="other"){var c=t.obj;return t.contrib?[ot(o.other,{n:c.count}),"Shares together "+n.signed(c.contribution)]:[ot(o.other,{n:c.count}),i.down+" (sum) "+n.signed(c.down),i.up+" (sum) "+n.signed(c.up),o.swing+" together "+n.value(c.swing)+" ("+n.percent(c.share,0)+" of the total)"]}if(t.kind==="group"){var a=t.obj;return[a.label+" \xB7 "+a.factors.length+" factor"+(a.factors.length>1?"s":""),i.down+" "+n.signed(a.down)+u(a.down),i.up+" "+n.signed(a.up)+u(a.up),o.swing+" "+n.value(a.swing)+" ("+n.percent(a.share,0)+" of the total)","Combined move of the group \xB1"+n.value(a.standalone)+" \xB7 share of the total \xB1"+n.value(r.sigma)+": "+n.signed(a.contribution)].concat(a.breach?[o.worst+" beyond the limit"]:[])}var f=t.obj,d=[f.label,f.group+" \xB7 rank "+f.rank+" of "+r.factors.length,i.down+(f.shockDown!=null?" ("+dt(f.shockDown,f.unit,s)+")":"")+" "+n.signed(f.down)+u(f.down),i.up+(f.shockUp!=null?" ("+dt(f.shockUp,f.unit,s)+")":"")+" "+n.signed(f.up)+u(f.up),o.swing+" "+n.value(f.swing)+" \xB7 "+n.percent(f.share,0)+" of the total (top "+f.rank+": "+n.percent(f.cumShare,0)+")",o.linear+" \xB1"+n.value(Math.abs(f.linear))+" \xB7 "+o.convexity.toLowerCase()+" "+n.signed(f.convexity),"Share of the combined move "+n.signed(f.contribution)+" (stand-alone "+n.value(f.standalone)+")"];return f.breach&&d.push(i[f.worst]+" is beyond the limit of "+n.value(r.limit)),d},S.prototype._detail=function(t){if(!t)return null;var e=this._view;if(t.kind==="other")return{view:e,kind:"other",count:t.obj.count,down:t.obj.down,up:t.obj.up,swing:t.obj.swing,contribution:t.obj.contribution,factors:t.obj.factors.map(function(r){return r.key})};if(t.kind==="group"){var n=t.obj;return{view:e,kind:"group",key:n.key,label:n.label,factors:n.factors.slice(),down:n.down,up:n.up,swing:n.swing,share:n.share,linear:n.linear,convexity:n.convexity,worst:n.worst,worstValue:n.worstValue,breach:n.breach,contribution:n.contribution,standalone:n.standalone}}var o=t.obj;return{view:e,kind:"factor",key:o.key,label:o.label,group:o.group,unit:o.unit,shockDown:o.shockDown,shockUp:o.shockUp,down:o.down,up:o.up,swing:o.swing,share:o.share,cumShare:o.cumShare,rank:o.rank,linear:o.linear,convexity:o.convexity,asymmetry:o.asymmetry,worst:o.worst,worstValue:o.worstValue,breach:o.breach,contribution:o.contribution,standalone:o.standalone,source:o.source}},S.prototype.howToRead=function(){var t=this._view||this.options.view;return t==="contribution"?"Each bar is one factor's share of the combined move when all factors move together with their correlations. Shares add up exactly to the combined move; a bar to the left means the factor hedges the others. The diamond marks the factor's move on its own, so the gap between the diamond and the bar is diversification.":t==="groups"?"Each row is one group of factors, such as a risk class, with every factor in it shocked down (upper bar) and up (lower bar) at the same time. Rows are sorted by swing, the distance between the two results.":"Each row is one risk factor, shocked down (upper bar) and up (lower bar) on its own while everything else stays put. Rows are ranked by swing, the distance between the two results, so the factors that matter most are at the top. A diamond marks the midpoint of the two results when they are clearly unequal (convexity)"+(this._res&&this._res.limit!=null?"; the dashed line is the loss limit.":".")},S.prototype.describe=function(){var t=this.options,e=ct(t.data,t.locale),n=this._labels(),o=this._res||K(t.data,this._opts()),r=this._shockNames(),i=[],s=o.order[0];i.push("The largest driver is "+s.label+": "+r.down.toLowerCase()+" gives "+e.signed(s.down)+" and "+r.up.toLowerCase()+" "+e.signed(s.up)+", a swing of "+e.value(s.swing)+" ("+e.percent(s.share,0)+" of the total swing)."),o.factors.length>o.topN&&i.push("The top "+o.topN+" of "+o.factors.length+" factors explain "+e.percent(o.topShare,0)+".");var u=o.worstFactor;i.push("The worst single shock is "+u.label+" "+r[u.worst].toLowerCase()+" at "+e.signed(u.worstValue)+(o.limit!=null?o.breaches?", beyond the limit of "+e.value(o.limit)+" ("+o.breaches+" factor"+(o.breaches>1?"s":"")+" in all)":", within the limit of "+e.value(o.limit):"")+".");var c=o.factors.filter(function(d){return d.asymmetry>=.25&&d.swing>0}).sort(function(d,p){return Math.abs(p.convexity)-Math.abs(d.convexity)});if(c.length&&i.push(c.length+" factor"+(c.length>1?"s are":" is")+" strongly asymmetric, led by "+c[0].label+" (convexity "+e.signed(c[0].convexity)+"), so a bigger shock would cost more than in proportion."),o.correlated){var a=o.factors.slice().sort(function(d,p){return p.contribution-d.contribution}),f=o.factors.filter(function(d){return d.contribution<0}).sort(function(d,p){return d.contribution-p.contribution});i.push("Moving together with their correlations, the factors give a combined move of \xB1"+e.value(o.sigma)+", "+e.percent(o.standalone>0?o.diversification/o.standalone:0,0)+" less than the sum of their stand-alone moves; "+a[0].label+" contributes most ("+e.signed(a[0].contribution)+")"+(f.length?" and "+f[0].label+" hedges the most ("+e.signed(f[0].contribution)+")":"")+".")}return o.interaction&&o.interaction.down!=null&&i.push("Shocked all at once, the down case gives "+e.signed(o.joint.down)+" against "+e.signed(o.sumDown)+" for the sum of single shocks, an interaction of "+e.signed(o.interaction.down)+"."),o.baseline&&i.push("The what-if changes the worst single shock from "+e.signed(o.baseline.worstValue)+" to "+e.signed(u.worstValue)+"."),i.join(" ")},S.prototype.getExportData=function(){var t=this.options,e=t.data,n=this._labels(),o=ct(e,t.locale),r=this._res||K(e,this._opts()),i=this._shockNames(),s=t.locale,u={prefix:e.prefix||"",suffix:e.suffix||"",decimals:e.decimals!=null?e.decimals:0,negatives:e.negatives},c=function(l){return{label:l,type:"number",unit:u}},a=function(l){return{label:l,type:"number",unit:{decimals:4}}},f=function(l){return{label:l,type:"percent",decimals:1}},d=function(l){return{label:l,type:"text"}},p=[],w=t.exportRows!=null?t.exportRows:2e4,m=r.order,v=m.length>w;v&&(m=m.slice(0,w));var x=m.map(function(l){return[l.rank,l.label,l.group,l.unit,l.shockDown,l.shockUp,l.down,l.up,l.swing,l.share,l.cumShare,l.linear,l.convexity,i[l.worst],l.worstValue,l.breach?"Yes":"No",l.contribution,l.standalone]});p.push({name:"Factors",columns:[{label:"Rank",type:"number",unit:{decimals:0}},d("Risk factor"),d("Group"),d("Shock unit"),a("Shock down"),a("Shock up"),c(i.down),c(i.up),c(n.swing),f("Share of total swing"),f("Cumulative share"),c(n.linear),c(n.convexity),d("Worst shock"),c(n.worst),d("Beyond limit"),c("Share of combined move"),c("Stand-alone move")],rows:x,text:m.map(function(l){return[String(l.rank),l.label,l.group,l.unit,dt(l.shockDown,"",s)||"\u2013",dt(l.shockUp,"",s)||"\u2013",o.signed(l.down),o.signed(l.up),o.value(l.swing),o.percent(l.share),o.percent(l.cumShare),o.signed(l.linear),o.signed(l.convexity),i[l.worst],o.signed(l.worstValue),l.breach?"Yes":"No",o.signed(l.contribution),o.value(l.standalone)]}),flag:m.map(function(l){return l.breach})}),p.push({name:"Groups",columns:[d("Group"),{label:"Factors",type:"number",unit:{decimals:0}},c(i.down+" (sum)"),c(i.up+" (sum)"),c(n.swing),f("Share of total swing"),c(n.worst),d("Beyond limit"),c("Share of combined move"),c("Group combined move")],rows:r.groups.map(function(l){return[l.label,l.factors.length,l.down,l.up,l.swing,l.share,l.worstValue,l.breach?"Yes":"No",l.contribution,l.standalone]}),text:r.groups.map(function(l){return[l.label,String(l.factors.length),o.signed(l.down),o.signed(l.up),o.value(l.swing),o.percent(l.share),o.signed(l.worstValue),l.breach?"Yes":"No",o.signed(l.contribution),o.value(l.standalone)]}),flag:r.groups.map(function(l){return l.breach})});var y=[["Total swing",r.totalSwing],["Sum of "+i.down.toLowerCase()+" impacts",r.sumDown],["Sum of "+i.up.toLowerCase()+" impacts",r.sumUp]];r.joint&&(r.joint.down!=null&&y.push(["All factors "+i.down.toLowerCase()+" together",r.joint.down],[n.interaction+" ("+i.down.toLowerCase()+")",r.interaction.down]),r.joint.up!=null&&y.push(["All factors "+i.up.toLowerCase()+" together",r.joint.up],[n.interaction+" ("+i.up.toLowerCase()+")",r.interaction.up])),y.push([n.combined+" (\xB1)",r.sigma],["Sum of stand-alone moves",r.standalone],["Diversification",r.diversification]),r.limit!=null&&y.push([n.limit,r.limit]),p.push({name:"Summary",columns:[d("Item"),c("Amount")],rows:y,text:y.map(function(l){return[l[0],/Sum|Interaction|together/.test(l[0])?o.signed(l[1]):o.value(l[1])]})});var E=(t.annotations||[]).map(function(l,N){return[String(N+1),l.factor!=null?String(l.factor):"Group: "+String(l.group||""),l.text||""]});E.length&&p.push({name:"Notes",columns:[d("No."),d("Factor or group"),d("Note")],rows:E});var M=e.correlation;return{title:e.title||"Risk-factor tornado",subtitle:e.subtitle||"",summary:this.describe(),library:"Veyforma Risk-Factor Tornado "+St,sheets:p,meta:[["Unit",e.unit],["As of",e.asOf],["Desk",e.desk],["Measure",r.higherIsBetter?"Higher is better (for example P&L)":"Lower is better (for example capital)"],["Ranking",t.sort==="worst"?"By worst result":"By swing"],["Shocks",i.down+" / "+i.up+(r.shockScale!==1?", scaled \xD7"+r.shockScale:"")],["What-if",r.whatIf?Object.keys(r.whatIf).map(function(l){return l+" \xD7 "+r.whatIf[l]}).join(", "):null],["Correlation",M?M.matrix?"Matrix given":"Within groups "+(M.within||0)+", across "+(M.across||0):"None given (independent factors)"],["Limit",r.limit!=null?o.value(r.limit)+" ("+r.breaches+" beyond)":null],["Method","Impact = given down/up result, or \u0394\xB7s + \xBD\u0393\xB7s\xB2; swing = |up \u2212 down|; linear part L = (up \u2212 down) \xF7 2, convexity C = (up + down) \xF7 2; a shock k times larger \u2248 L\xB7k + C\xB7k\xB2; combined move \u03C3 = \u221A(L\u1D40 \u03C1 L); factor share = L_k (\u03C1L)_k \xF7 \u03C3 (Euler allocation, adds up to \u03C3)"+(v?"; factor sheet limited to the "+w+" largest swings":"")],["Data source",e.source]]}},S.prototype._annotationPoint=function(t){var e=this._points||{};return t.factor!=null?e[String(t.factor)]||null:t.group!=null&&e["group:"+String(t.group)]||null},S.prototype._annotationTarget=function(t){var e=this._items||[],n=null;if(!t)n=e[this._active];else for(var o=this.plotHost.querySelector("svg"),r=o.getBoundingClientRect(),i=o.viewBox.baseVal,s=(t.clientX-r.left)*(i.width/r.width),u=(t.clientY-r.top)*(i.height/r.height),c=0;c<e.length;c++){var a=e[c];if(s>=a.x&&s<=a.x+a.w&&u>=a.y&&u<=a.y+a.h){n=a;break}}return!n||n.kind==="other"?null:n.kind==="group"?{group:n.obj.key}:{factor:n.obj.key}},S.prototype._annotationLabel=function(t){if(t.group!=null)return String(t.group);var e=(this._res||this.getResult()).factors.filter(function(n){return n.key===String(t.factor)})[0];return e?e.label:String(t.factor||"")},B.VeyRiskTornado={version:St,create:function(t,e){return new S(t,e)},compute:function(t,e){return K(t,e)},listThemes:function(){return Object.keys(vt)},getTheme:function(t){return ht(t)},defaults:{options:Mt,labels:_t,theme:lt}}})(typeof window<"u"?window:void 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veyforma/charts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Zero-dependency JavaScript charts for finance and risk: exposure heatmap, risk-factor tornado and P&L attribution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"charts",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"zero-dependency",
|
|
18
18
|
"accessible"
|
|
19
19
|
],
|
|
20
|
-
"homepage": "https://github.
|
|
20
|
+
"homepage": "https://veyforma.github.io/veyforma-charts/examples/",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/
|
|
23
|
+
"url": "git+https://github.com/Veyforma/veyforma-charts.git"
|
|
24
24
|
},
|
|
25
|
-
"bugs": "https://github.com/
|
|
25
|
+
"bugs": "https://github.com/Veyforma/veyforma-charts/issues",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"author": "Veyforma (https://www.veyforma.com)",
|
|
28
28
|
"type": "module",
|
package/src/veyforma-charts.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
root.VeyformaCharts = {
|
|
18
|
-
version: "1.0.
|
|
18
|
+
version: "1.0.2",
|
|
19
19
|
/** Exposure heatmap: concentrations by any two fields, e.g. sector × country. */
|
|
20
20
|
heatmap: function (target, options) { return need("VeyHeatmap").create(target, options); },
|
|
21
21
|
/** Risk-factor tornado: down and up impact per factor, with convexity, limits and hedges. */
|