@bino-bi/bn-template-engine 1.0.0-next.42 → 1.0.0-next.44
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/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-3836531f.entry.js → p-3c4af59a.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +190 -64
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.css +74 -2
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +50 -3
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +55 -17
- package/dist/collection/components/bn-table/utils/elements/TableRow.js +15 -5
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +2 -4
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +8 -6
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +50 -28
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +8 -1
- package/dist/collection/utils/layoutState/baseline.js +5 -1
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/p-AwH1w8Mu.js +1 -0
- package/dist/components/p-B2bvM2Ig.js +1 -0
- package/dist/components/{p-CUSAlS2o.js → p-BfUdaxZ9.js} +1 -1
- package/dist/components/{p-ChaSU4fh.js → p-C2ycO60j.js} +1 -1
- package/dist/components/{p-chnyMHJT.js → p-CyfGkLMh.js} +1 -1
- package/dist/components/{p-DM4Up10X.js → p-DnDL1pPc.js} +1 -1
- package/dist/components/p-JofGXz75.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +190 -64
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +11 -0
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +10 -0
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +6 -1
- package/package.json +1 -1
- package/dist/components/p-B2L2q2Ks.js +0 -1
- package/dist/components/p-Bn7J1pgl.js +0 -1
- package/dist/components/p-XFZYX7DZ.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as t,p as e,H as i,f as n,a as o,t as s}from"./p-D6YGOYV1.js";import{b as r,a as l,F as a,O as h,T as c,c as u}from"./p-BZXiWkDS.js";import{m as d,a as f,b as p}from"./p-DaOm9YwQ.js";import{p as v,n as m,r as $,d as g}from"./p-BzjGUtYh.js";import{F as b,V as w,Q as y,s as S,a as R,I as E,b as M}from"./p-CniN8ALm.js";import{S as O,I as N,D as _,C as G,d as U,M as x}from"./p-B5tixDPM.js";import{N as T,r as k}from"./p-fCjsrD7I.js";import{D as L,w as C}from"./p-Dq9dG0Kr.js";import{D as P,b as A}from"./p-sLbQ7yZ1.js";import{p as W,c as D}from"./p-16rjcQ0t.js";import{d as B,g as F}from"./p-DDvWTgk1.js";import{D as H,a as I,b as Y}from"./p-7ieJFBUk.js";import{A as j}from"./p-BXg3v5AO.js";import{S as z}from"./p-BPGLOHUe.js";import{S as Q}from"./p-CeE4_3wQ.js";import{w as X}from"./p-DjPWZfry.js";const V="none",Z="setname";function q(t){return t===Z?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function K(t){if("string"==typeof t?""===t.trim():"number"!=typeof t)return;const e=Number(t);return Number.isFinite(e)?e:void 0}function J(t){if(null==t)return"";if("string"==typeof t)return t.trim();const e=tt(t);return e?e.toISO():String(t)}function tt(t){if(null!=t){if("string"==typeof t){const e=L.fromISO(t,{zone:"utc"});return e.isValid?e:void 0}if("number"==typeof t){const e=L.fromMillis(t,{zone:"utc"});return e.isValid?e:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const et=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class it{constructor(t,e,i,n,o,s,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=i,this.prefix=s||"",this.cssStyle=n||"",this.prefixStyle=r||"prefix",this.type=o,this.mark=void 0,this.colSpan=l||1,this.measureScale=a||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const e of this.value.toString().split("<br/>"))t.push(e);return t}draw(t,e){return this.format(this.value,t,e)}roundsToZero(t,e){return"number"==typeof this.value&&!!this.type&&this.draw(t,e)===this.format(0,t,e)}format(t,e,i){let n=t;if("undefined"===n||void 0===n||null==n)return"";if(Number.isNaN(Number(n)))return n;if(""===this.type||void 0===this.type||null==this.type)return n;let o=e.percent,s=e.percent;return"percentpoint"===this.type?b.number(Number(n),"percent",o,s,1,i).replace(et,""):("decimal"===this.type&&(n=+n/this.measureScale,o=e.decimal,s=e.decimal),b.number(Number(n),this.type,o,s,1,i))}drawPrefix(){return null==this.prefix?"":this.prefix}}class nt{constructor(t,e,i){this.index=t,this.groupindex=e,this.type=i,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case r.HEADER:return"groupheader";case r.SEPERATORLINE:return"";case r.DRILLELEMENT:return"ofit";case r.PARTELEMENT:return"partof";case r.STANDARD:return"";case r.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,i,n,o,s,l,a,h,c=!1,u,d=1,f){let p=s;"category"===e&&null!=a&&(p=`category-${a.toString()}`),this.type===r.HEADER?p="headerlabel":this.type===r.SEPERATORLINE&&(p=null!=s?s:e),this.type===r.PARTELEMENT&&("percent"===n&&(t="-"),"category"!==e&&"operation"!==e&&(n="percent",p="")),("-"===t||t===T&&"percent"===n)&&(p="");let v="prefix-first";l&&(v="prefix-second"),i&&(p=`${p} ${i}`);const m=new it(e,this.elements.length,t,p,n,o,v,d,h);m.isBarChart=c,m.columnStats=u,m.waterfall=f,this.elements.push(m)}}const ot=.85,st=.3,rt=.25,lt={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};let at;function ht(t,e,i,n,o=!1){const s=()=>function(t,e){var i;let n=0;for(const e of t)n+=null!==(i=lt[e])&&void 0!==i?i:/[0-9+]/.test(e)?.59:.72;return n*e*1.1}(t,e)*(o?1.08:1),r=function(){var t,e,i;if(void 0===at)try{at="undefined"==typeof document?null:null!==(i=null===(e=(t=document.createElement("canvas")).getContext)||void 0===e?void 0:e.call(t,"2d"))&&void 0!==i?i:null}catch(t){at=null}return at}();if(r){r.font="1px __bn_font_sentinel__";const l=r.font;if(r.font=`${n?"italic ":""}${o?"bold ":""}${e}px ${i}`,r.font===l)return s();const a=r.measureText(t).width;if(Number.isFinite(a)&&(a>0||""===t))return a+.15*e}return s()}function ct(t,e){return Math.max(0,(t-.5)*e)}function ut(t,e,i){const n=void 0!==t.neg,o=void 0!==t.pos||!n,s=(t,n)=>t?e+i+(null!=n?n:0):0;return{sides:(n?1:0)+(o?1:0),neg:s(n,t.neg),pos:s(o,t.pos)}}function dt(t,e,i,n){const{sides:o,neg:s,pos:r}=ut(e,i,n),l=s+r>0?Math.min(1,t/(s+r)):1,a=Math.max(0,(t-(s+r)*l)/o);return{extent:a,axisX:void 0!==e.neg?s*l+a:0}}function ft(t,e,i,n){const o=ct(t,e),{sides:s,neg:r,pos:l}=ut(i,n/2,st*e);return r+l+s*function(t,e,i){return Math.min(1*e,t/(2*i))}(o,e,s)<=o+1e-6}function pt(t,e){const i=.15*t;return{maxBarWidth:t,breakGap:e,overdriveZoneWidth:i,cutWidth:Math.max(0,t-e-i)}}function vt(t,e,i,n){var o,s;const r=ct(t,e),l=st*e,{extent:a,axisX:h}=dt(r,i,rt*e/2,l),c=Math.min(.3*e,.2*a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?a:0;const p=Math.max(0,null!==(o=null==n?void 0:n.neg)&&void 0!==o?o:0),v=Math.max(0,null!==(s=null==n?void 0:n.pos)&&void 0!==s?s:0);u&&d&&p+v>0&&(f=(c+(2*a*.85-2*c)*p/(p+v))/.85);const m=d?u?2*a-f:a:0;return{totalWidth:r,neg:pt(f,c),pos:pt(m,c),axisX:u?h-a+f:0,labelGap:l}}function mt(t,e,i,n,o){var s,r;const l=ct(t,e),a=st*e,{extent:h,axisX:c}=dt(l,i,n/2,a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?h:0,p=d?h:0;if(o&&u&&d){const t=2*h,e=Math.max(0,null!==(s=o.neg)&&void 0!==s?s:0),i=Math.max(0,null!==(r=o.pos)&&void 0!==r?r:0);e+i<=t+1e-6?(f=e+(t-e-i)/2,p=t-f):e<h?(f=e,p=t-f):i<h&&(p=i,f=t-p)}return{totalWidth:l,maxPinLength:Math.max(f,p),negPinLength:f,posPinLength:p,axisX:u?c-h+f:0,labelGap:a}}function $t(t,e,i){const n=ct(t,e),o=st*e,s=Math.min(2.85*e,n/4);let r=s,l=s;const a=i?i.max-i.min:0;if(i&&a>0){const t=(t,e)=>Math.max(0,...i.labels.filter((e=>e.pointsLeft===t)).map((n=>n.width+o-(t?n.end-i.min:i.max-n.end)*e)));r=t(!0,0),l=t(!1,0);const e=n/2;for(let i=0;i<8;i++){const i=Math.max(0,n-r-l)/a,o=Math.min(r,t(!0,i)),s=Math.min(l,t(!1,i)),h=o+s<=e||o===r&&s===l;if(r=o,l=s,h)break}if(r+l>e)if(Math.min(r,l)>s){const t=e/(r+l);r*=t,l*=t}else r<=l?l=e-r:r=e-l}return{totalWidth:n,labelAreaLeft:r,labelAreaRight:l,barAreaWidth:n-r-l,labelGap:o}}const gt={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11.333305,emPx:13.3333,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},bt="#666666";function wt(t,e){return`pattern-${t}-${e.replace("#","")}`}const yt=({styles:e})=>{const i=e.scaleFactor,n=6*i,o=[{id:wt("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:wt("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:wt("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill},...["ac","pp","fc","pl"].map((t=>({id:wt(t,e.scenarios[t].stroke),stroke:e.scenarios[t].stroke,fill:e.scenarios[t].fill})))];return t("defs",null,o.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:n,height:n},t("rect",{width:n,height:n,fill:"#ffffff"}),t("line",{x1:"0",y1:n,x2:n,y2:"0",stroke:e.stroke,"stroke-width":1.5*i})))))};function St(t,e,i=1,n,o=0,s=!0,r){const l=(e,i)=>(t>0&&e!==i?"+":"")+e;if(e){const e=(t,e)=>s?b.number(t,"percent",e,e,1,n):b.number(100*t,"decimal",e,e,1,n),i=i=>l(e(t,i),e(0,i));let r=Math.min(20,Math.max(0,Math.trunc(o)||0));for(;r>0&&i(r).length>7;)r--;return i(r)}const a=t/i;if(void 0!==r){const t=t=>b.number(t,"decimal",r,r,1,n);return l(t(a),t(0))}const h=Math.abs(a);let c=1,u="";h>=9995e5?(c=1e9,u="B"):h>=999500?(c=1e6,u="M"):h>=999.5&&(c=1e3,u="K");const d=h>=10*c?0:1;return l(b.number(a/c,"decimal",d,0,1,n),b.number(0,"decimal",d,0,1,n))+u}function Rt(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function Et(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function Mt(t,e){if(Rt(t))return null;const i=new w(t);if(!i.isValid)return null;const n=Et(i.base),o=Et(i.delta);return{minuend:e.scenarios[n],minuendSlot:n,reference:e.scenarios[o],referenceSlot:o}}const Ot=({x:e,height:i,look:n,styles:o})=>{const s=o.scaleFactor,r=rt*o.emPx,{reference:l,referenceSlot:a}=n;let h;if("outlined"===l.fillpattern){const n=r/2-.5*s;h=[e-n,e+n].map((e=>t("line",{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":1*s})))}else h=t("line","hatched"===l.fillpattern?{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":r,"stroke-dasharray":""+2*s}:{x1:e,y1:0,x2:e,y2:i,stroke:l.fill,"stroke-width":r});return t("g",{class:`variance-axis axis-${a}`},h)};function Nt(t){return void 0!==t.pos||void 0===t.neg}function _t(t,e){return{neg:t.min<0?e:void 0,pos:t.max>0?e:void 0}}function Gt(t,e,i,n){return Rt(t)?function(t,e){const i=Et(t);return e.scenarios[i]}(t,n):function(t,e,i){const n=t>=0;return e?n?i.positive:i.negative:n?i.negative:i.positive}(e,i,n)}function Ut(t,e){const i=t.fillpattern;return"hatched"===i?`url(#${wt(e,t.stroke)})`:"outlined"===i?"transparent":t.fill}function xt(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Tt=e=>{const{value:i,scenario:n,columnStats:o,height:s,isPositiveGood:r,formattedValue:l,measureScale:a,locale:h,decimalDigits:c,columnWidthEm:u=10,labelWidths:d,sideMax:f,bold:p,styles:v=gt}=e,m=v.scaleFactor,$=v.fontSize,g=l||St(i,!1,a,h,0,!0,c),b=null!=d?d:_t(o,ht(g,$,v.fontFamily,!1,p)),w=i>0||0===i&&Nt(b),{neg:y=Math.max(0,-o.min),pos:S=Math.max(0,o.max)}=null!=f?f:{},R=vt(u,v.emPx,b,{neg:y,pos:S}),{totalWidth:E,axisX:M,labelGap:O}=R,{breakGap:N,overdriveZoneWidth:_,cutWidth:G}=w?R.pos:R.neg,U=Math.abs(i)*v.unitScaling*$,x=U-G>1e-6,T=Math.max(0,(w?S:y)*v.unitScaling*$-G),k=Math.max(0,U-G),L=T>0?k/T*_:0,C=2*m,P=s-2*C,A=C,W=Mt(n,v),D=Gt(n,i,r,v),B=null==W?void 0:W.minuend.fillpattern,F="hatched"===B||"outlined"===B?Object.assign(Object.assign({},D),{fillpattern:B}):D,H=Ut(F,Rt(n)?Et(n):r?w?"pos":"neg":w?"neg":"pos"),{stroke:I,strokeWidth:Y}=W&&"hatched"===F.fillpattern?{stroke:F.stroke,strokeWidth:1}:xt(F),j=W?rt*v.emPx/2:0,z=w?M+j:M-j,Q=x?G:U,X=x?G+N+L:U,V=w?z+X+O:z-X-O,Z=w?"start":"end";return t("svg",{width:E,height:s,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(yt,{styles:v}),!W&&t("line",{x1:M,y1:0,x2:M,y2:s,stroke:bt,"stroke-width":1*m}),Q>0&&t("rect",{x:w?z:z-Q,y:A,width:Q,height:P,fill:H,stroke:I,"stroke-width":Y*m}),x&&L>0&&t("rect",{x:w?z+G+N:z-G-N-L,y:A,width:L,height:P,fill:H,stroke:I,"stroke-width":Y*m}),x&&function(e,i,n,o,s){const r=e+i/2,l=.35*i,a=o/3,h=.3*i;let c=`M ${r-l} ${n}`;for(let t=0;t<3;t++)c+=` L ${r-l-h} ${n+a*(t+.5)} L ${r-l} ${n+a*(t+1)}`;let u=`M ${r+l} ${n}`;for(let t=0;t<3;t++)u+=` L ${r+l+h} ${n+a*(t+.5)} L ${r+l} ${n+a*(t+1)}`;return[t("rect",{x:e,y:n-1,width:i,height:o+2,fill:"#ffffff"}),t("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*s}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*s})]}(w?z+G:z-G-N,N,A,P,m),W&&t(Ot,{x:M,height:s,look:W,styles:v}),t("text",{x:V,y:s/2,dy:"0.35em","text-anchor":Z,fill:v.fontColor,"font-size":$,"font-family":v.fontFamily},g))},kt=e=>{var i,n;const{value:o,scenario:s,columnStats:r,height:l,isPositiveGood:a,formattedValue:h,measureScale:c,locale:u,percentDigits:d,percentSign:f,columnWidthEm:p=10,labelWidths:v,sideMax:m,bold:$,styles:g=gt}=e,b=g.scaleFactor,w=g.fontSize,y=10*b,S=100*g.percentageScaling*w,R=h||St(o,!0,c,u,d,f),E=ht(R,w,g.fontFamily,!0,$),M=null!=v?v:_t(r,E),{neg:O=Math.max(0,-r.min),pos:N=Math.max(0,r.max)}=null!=m?m:{},{totalWidth:_,negPinLength:G,posPinLength:U,axisX:x,labelGap:T}=mt(p,g.emPx,M,y,{neg:O*S,pos:N*S}),k=l/2,L=Math.abs(o)*S,C=o>0||0===o&&Nt(M),P=C?U:G,A=L-P>1e-6,W=C?1:-1,D=x+W*Math.min(L,P),B=Gt(s,o,a,g),F=Mt(s,g),H=null!==(i=null==F?void 0:F.minuend)&&void 0!==i?i:g.scenarios.ac,I=x+W*(P+y/2),Y=1.2*y,j=I-W*Y,z=.2*w,Q=E+2*z,X=Math.abs(j-x)-rt*g.emPx/2,V=A&&X>=Q+2*z,Z=j-W*(z+Q/2)-Q/2,q=V?Z+Q/2:(A?I:D+W*(y/2))+W*T;return t("svg",{width:_,height:l,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t(yt,{styles:g}),A?t("polygon",{points:`${I},${k} ${j},${k-Y/2} ${j},${k+Y/2}`,fill:B.fill}):t("rect",{x:D-y/2,y:k-y/2,width:y,height:y,fill:"outlined"===H.fillpattern?"#ffffff":Ut(H,null!==(n=null==F?void 0:F.minuendSlot)&&void 0!==n?n:"ac"),stroke:H.stroke,"stroke-width":1*b}),t("line",{x1:x,y1:k,x2:A?j:D,y2:k,stroke:B.fill,"stroke-width":3*b}),V&&t("rect",{class:"pin-label-band",x:Z,y:k-3*b/2,width:Q,height:3*b,fill:"#ffffff","fill-opacity":"0.5"}),F?t(Ot,{x,height:l,look:F,styles:g}):t("line",{x1:x,y1:0,x2:x,y2:l,stroke:bt,"stroke-width":1*b}),t("text",{x:q,y:l/2,dy:"0.35em","text-anchor":V?"middle":C?"start":"end",fill:g.fontColor,"font-size":w,"font-style":"italic","font-family":g.fontFamily},R))},Lt=e=>{const{value:i,columnStats:n,isRelative:o,styles:s=gt}=e;return null==i||isNaN(i)||!n||0===n.absMax?t("span",{class:"bar-chart-empty",style:{color:s.fontColor,fontStyle:"italic"}},"-"):t(o?kt:Tt,Object.assign({},e))};function Ct(t,e,i,n,o,s=!1){const r=St(t,"partof"===e,i,n,0,!0,o);return s?r:r.replace(/^\+/,"")}const Pt=e=>{var i;const{value:n,scenario:o,height:s,isPositiveGood:r,measureScale:l,locale:a,decimalDigits:h,columnWidthEm:c=10,styles:u=gt,waterfall:d,geometry:f,bold:p,connectorReach:v={top:0,bottom:0}}=e,m=u.scaleFactor,$=u.fontSize,g=d.max-d.min;if(null==n||isNaN(n)||g<=0)return t("span",{class:"bar-chart-empty",style:{color:u.fontColor,fontStyle:"italic"}},"-");const{totalWidth:b,labelAreaLeft:w,barAreaWidth:y,labelGap:S}=null!=f?f:$t(c,u.emPx),R=y/g,E=t=>w+(t-d.min)*R,M=2*m,O=s-2*M,N=M,_=E(0),G=E(d.start),U=E(d.end),x=Math.min(G,U),T=Math.abs(U-G),k=Mt(o,u),L=Gt(o,n,r,u),C=null==k?void 0:k.minuend.fillpattern,P="hatched"===C||"outlined"===C?Object.assign(Object.assign({},L),{fillpattern:C}):L,A=Ut(P,k?L===u.positive?"pos":"neg":Et(o)),{stroke:W,strokeWidth:D}=k&&"hatched"===P.fillpattern?{stroke:P.stroke,strokeWidth:1}:xt(P),B=Ct(n,d.kind,l,a,h,null!==k),F=U<G,H=F?x-S:x+T+S,I=F?"end":"start",Y=ht(B,$,u.fontFamily,!1,p),j=S/2,z=(F?H-Y:H)-j,Q=(F?H:H+Y)+j,X=t=>t>z&&t<Q,V=void 0!==d.parentEnd?E(d.parentEnd):void 0,Z=s/2-$/2,q=s/2+$/2,K=(t,e,i,n=0)=>t+n>z&&t-n<Q?[[e,Math.min(i,Z)],[Math.max(e,q),i]].filter((([t,e])=>e>t)):[[e,i]],J=-v.top,tt=s+v.bottom;return t("svg",{width:b,height:s,class:"cell-bar-chart waterfall-bar"+(k?" variance-waterfall":""),style:{overflow:"visible"}},t(yt,{styles:u}),!k&&!X(_)&&t("line",{x1:_,y1:0,x2:_,y2:s,stroke:bt,"stroke-width":1*m}),void 0!==d.parentStart&&void 0!==d.parentEnd&&t("line",{x1:E(d.parentStart),y1:0,x2:E(d.parentStart),y2:s,stroke:bt,"stroke-width":1*m,"stroke-dasharray":`${2*m},${2*m}`}),void 0!==d.parentStart&&void 0!==V&&!X(V)&&t("line",{x1:V,y1:0,x2:V,y2:s,stroke:bt,"stroke-width":1*m,"stroke-dasharray":`${2*m},${2*m}`}),null===(i=d.connectors)||void 0===i?void 0:i.map((({at:e,part:i})=>K(E(e),"bottom"===i?N+O:J,"top"===i?N:tt).map((([i,n])=>t("line",{class:"waterfall-connector",x1:E(e),y1:i,x2:E(e),y2:n,stroke:bt,"stroke-width":1*m}))))),T>0&&t("rect",{x,y:N,width:T,height:O,fill:A,stroke:W,"stroke-width":D*m}),k&&K(_,J,tt,rt*u.emPx/2).map((([e,i])=>t("g",{transform:`translate(0,${e})`},t(Ot,{x:_,height:i-e,look:k,styles:u})))),t("text",{x:H,y:s/2,dy:"0.35em","text-anchor":I,fill:u.fontColor,"font-size":$,"font-family":u.fontFamily},B))},At=`IFNULL(${y.ROWGROUP}, '')`;class Wt{constructor(t){this.groups=[y.CATEGORY,y.CATEGORYINDEX],l.OPT!==t.type&&l.OPTNOTOTAL!==t.type||this.groups.unshift(y.OPERATION),t.grouped&&(this.groups.push(y.ROWGROUP),this.groups.push(y.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===y.ROWGROUP?At:t)).toString()}select(){return this.groups.map((t=>t===y.ROWGROUP?`${At} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==y.CATEGORY))}toArray(){return this.groups}}function Dt(t,e){return Math.abs(t-e)<=1e-9*Math.max(1,Math.abs(t),Math.abs(e))}function Bt(t,e){const i=(t,e,i)=>{var n;t.connectors=[...null!==(n=t.connectors)&&void 0!==n?n:[],{at:e,part:i}]},n=(t,e,n,o)=>{i(t,o,"bottom"),e.forEach((t=>i(t,o,"through"))),i(n,o,"top")};let o=null;for(const i of t){if(null===i){o=null;continue}const{main:t,children:s}=i,r="anchor"===t.kind?t.end:t.start;if(o&&!i.gapAbove&&Dt(o.main.end,r)&&n(o.main,e?s:o.children,t,r),!i.gapAbove&&!i.gapBelow&&(s.forEach(((t,e)=>{e>0&&n(s[e-1],[],t,t.start)})),s.length>0)){const i=s[s.length-1];e?Dt(i.end,t.end)&&n(i,[],t,t.end):n(t,[],s[0],t.start)}o=i.gapBelow?null:i}}class Ft{constructor(){this.geometry=new Map,this.columns=new Set}set(t,e,i){let n=this.geometry.get(t);n||(n=new Map,this.geometry.set(t,n)),n.set(e,i),this.columns.add(e)}get(t,e){var i;return null===(i=this.geometry.get(t))||void 0===i?void 0:i.get(e)}has(t){return this.columns.has(t)}}function Ht(t){for(const e of t)for(const t of e){const e=t[y.TYPE];if(e===r.SUM||e===r.GROUPSUM||e===r.DRILLELEMENT||e===r.PARTELEMENT)return!0}return!1}function It(t){return`${t}__signed`}function Yt(t){var e;return"-"===(null!==(e=t[y.OPERATION])&&void 0!==e?e:t.restOperation)?-1:1}function jt(t,e,i){const n=t[e];if(null==n)return null;const o=Number(n);if(isNaN(o))return null;if((i===l.OPT||i===l.OPTNOTOTAL)&&t[y.TYPE]===r.ENTRY){const i=t[It(e)];return"number"==typeof i?i:Yt(t)*o}return o}function zt(t,e){return null==t&&null==e?e:(null!=t?t:0)+(null!=e?e:0)}class Qt{constructor(t,e){this.hasPartOf=!1,this.params=[],this.sortSelect="",this.hasBlankRowGroup=!1,this.config=t,this.i18n=e}execute(t,e){var i;this.db=t,this.fromExpr=e;for(const t of[...this.config.scenarios,...this.config.categoryThereOf.keys()])if(!a.test(t))throw new Error(`invalid identifier "${t}"`);const n=[],o=[],s=[],r=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),h=this.getRelativeScenarios(),c=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),u=new Wt(this.config),d=this.config.interval===Z?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var e,i;return null!==(i=null===(e=W(t))||void 0===e?void 0:e.column)&&void 0!==i?i:t})),direction:this.config.sortOrder.direction};let f=["",""];d.hierarchy.length>0&&(f=this.createOrderString(d)),this.hasPartOf=this.checkConfigForPartOf();const{hierarchy:p,direction:v}=d,m=p.filter((t=>t===y.ROWGROUP||t===y.ROWGROUPINDEX||t.toUpperCase()in O)),$=m.filter((t=>t.toUpperCase()in O)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),g=m.length>0?m.map((t=>`${t} ${v}`)).toString():`${y.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${y.CATEGORY}) as ${y.TOTALROWCOUNT} ${this.config.grouped?`, ${At} as ${y.ROWGROUP}, FIRST(${y.ROWGROUPINDEX}) as ${y.ROWGROUPINDEX}${$}`:""}\n FROM ${e} ${this.config.grouped?`GROUP BY ${At} ORDER BY ${g}`:""}`);return 0===b.length||1===b.length&&0===(null!==(i=b[0][y.TOTALROWCOUNT])&&void 0!==i?i:0)&&!this.config.grouped?[]:(this.hasBlankRowGroup=this.config.grouped&&b.some((t=>""===t.rowGroup)),b.forEach((t=>{const e=this.config.grouped?""===t.rowGroup?`WHERE (${y.ROWGROUP} IS NULL OR ${y.ROWGROUP} = '')`:`WHERE ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let i="";this.config.limit&&(i=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,n),this.createDataRow(n,t,u,r,c,e,f,i),this.createRestRow(t,n,u,r,e,f),this.createGroupSumRow(n,o,t,l,e,f)})),this.createTotalSumRow(n,o,l),n.forEach((t=>s.push(this.exec(t)))),this.hasRunningSum()&&this.accumulateGroupSums(s,[...new Set(this.exctractScenarioNames(l))]),this.detectNaNCells(this.config.scenarios,s),this.createThereOfDrillRows(r,c,f,s),this.createPartOfDrillRows(r,f,o,s),this.createIntervalColumns(s),this.createThereOfDrillColumns(this.config.categoryThereOf,s),this.calculateColumnGroupRest(s,this.config.categoryThereOf),this.calculateRelativeVariances(s,h),s)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const i=new w(t);!0===i.isValid?0!==e[i.base+"_cnt"]&&0!==e[i.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,i,n){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===l.LIST)return;const o=this.createPartOfQuery(t,e);let s=[];const r=this.db,a=this.params;o.forEach((t=>{s.push(...this.exec(t))}));const h=this.exctractScenarioNames(t),c=[];i.forEach((function(t){c.push(...r.exec(t,a))}));const u=new Map;c.forEach((t=>u.set(t[y.ROWGROUP],t))),s=this.reduceResDrillByCategoryGroups(s,h),s.forEach((function(t){h.forEach((e=>{try{t[e]=t[e]/u.get(t[y.ROWGROUP])[e]}catch(i){console.error("DataQuery: partOf drill row calculation failed",e,i),t[e]=Number.NaN}}))})),this.injectDrillRowsToResultRows(s,n)}createRestRow(t,e,i,n,o,s){var r;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const a=this.exctractScenarioNames(n).map((t=>`SUM(${t}) as ${t}`)).join(", "),h=this.exctractScenarioNames(n).filter((t=>{var e;return null===(e=this.config.barColumns)||void 0===e?void 0:e.includes(t)})).map((t=>`, SUM(${t} * transformOperator(operation)) as ${It(t)}`)).join(""),c=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type?`, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${h}`:"";e.push(`SELECT ${y.ROWNR}, 1 as ${y.ROWGROUPINDEX} , 'ENTRY' as ${y.TYPE}, 'NO_GROUP' as ${y.ROWGROUP}, ${this.bind(String(null!==(r=t.rowGroup)&&void 0!==r?r:""))} as restRowGroup, 'REST' as ${y.CATEGORY}${c} ${a.length>0?", "+a:""} FROM (SELECT ROWNUM() AS ${y.ROWNR}, ${e.length} as ${y.ROWGROUPINDEX} , 'ENTRY' as ${y.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${y.ROWGROUP}, ${i.select()} ${n.length>0?",".concat(n):""}${this.sortSelect} FROM ${this.fromExpr} ${o} GROUP BY ${i} ORDER BY ${s[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,i,n,o,s,r,l){t.push(`SELECT ROWNUM() AS ${y.ROWNR},\n ${t.length} as ${y.ROWGROUPINDEX},\n 'ENTRY' as ${y.TYPE},\n ${this.bind(String(e.rowGroup||"NO_GROUP"))} as ${y.ROWGROUP},\n '${y.CATEGORYINDEX}',\n ${i.select()} ${n.length>0?",".concat(n):""} ${o.length>0?",".concat(o):""}${this.sortSelect}\n FROM ${this.fromExpr} ${s}\n GROUP BY ${i}\n ORDER BY ${r[0]} ${l}`)}createGroupHeaderRow(t,e){if(!0===this.config.grouped&&(this.config.showGroupTitle||!this.hasGroupSum())){const i=this.bind(String(t.rowGroup)),n=""===t.rowGroup?this.bind("-"):i;e.push(`SELECT ROWNUM() AS ${y.ROWNR},\n ${e.length} as ${y.ROWGROUPINDEX},\n 'GROUPHEAD' as ${y.TYPE},\n ${i} as ${y.ROWGROUP} ${this.config.showGroupTitle?`,${n} as ${y.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return l.SUM===this.config.type||l.SUMNOTOTAL===this.config.type||l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type}hasRunningSum(){return this.config.runningSum&&this.config.grouped&&this.hasGroupSum()&&0===this.config.categoryThereOf.size}accumulateGroupSums(t,e){const i={};for(const n of t)for(const t of n)if("GROUP_SUM"===t[y.TYPE])for(const n of e)i[n]=zt(i[n],t[n]),t[n]=i[n]}createGroupSumRow(t,e,i,n,o,s){if(!0===this.config.grouped&&this.hasGroupSum()){const r=this.bind(String(i.rowGroup));t.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n '=' as ${y.OPERATION},\n ${r} as ${y.ROWGROUP},\n ROWNUM() AS ${y.ROWNR},\n 'GROUP_SUM' as ${y.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `),e.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n '=' as ${y.OPERATION},\n ${r} as ${y.ROWGROUP},\n ROWNUM() AS ${y.ROWNR},\n 'GROUP_SUM' as ${y.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `)}}createTotalSumRow(t,e,i){var n;if(l.SUM===this.config.type||l.OPT===this.config.type){const e=(null===(n=this.config.title)||void 0===n?void 0:n.trim())||"SUM_TOTAL",o=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n ${this.bind(o)} as ${y.ROWGROUP},\n '=' as ${y.OPERATION},\n 'SUM' as ${y.TYPE} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}e.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${y.ROWGROUP},\n '=' as ${y.OPERATION},\n 'SUM' as ${y.TYPE} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const i=new Map;return t.forEach((function(t){const n=t.rowNr+t.rowGroup+t.type+t.category;if(i.has(n)){const o=i.get(n);e.forEach((e=>{try{o[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else i.set(n,t)})),[...i.values()]}injectDrillRowsToResultRows(t,e){const i=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const n=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(n>=0){if(i.has(`${t.category}_${t.rowGroup}`)){const e=i.get(`${t.category}_${t.rowGroup}`)||0;i.set(`${t.category}_${t.rowGroup}`,e+1)}else i.set(`${t.category}_${t.rowGroup}`,1);t[y.ROWNR]=i.get(`${t.category}_${t.rowGroup}`),e.splice(n+t[y.ROWNR],0,t)}}))}));else{const n=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const o=e.findIndex((e=>null!=e.category&&e.category===t.category));if(o>=0){if(i.has(`${t.category}`)){const e=i.get(`${t.category}`)||0;i.set(`${t.category}`,e+1)}else i.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&n.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(o+t[y.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,i,n){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const o=[],s=[];this.config.thereOf.forEach((n=>{let s=!0,r="1 <> 1 OR ( ";null!=n.category&&0!==n.category.length&&n.category.trim()&&(r+=` ${y.CATEGORY} = ${this.bind(n.category)}`,s=!1),null!=n.rowGroup&&0!==n.rowGroup.length&&n.rowGroup.trim()&&(r+=` ${s?"":"AND"} ${y.ROWGROUP} = ${this.bind(n.rowGroup)}`,s=!1),null!=n.subCategory&&0!==n.subCategory.length&&n.subCategory.trim()&&(r+=` ${s?"":"AND"} ${y.SUBCATEGORY} = ${this.bind(n.subCategory)}`),r+=")",o.push(`SELECT ROWNUM() AS ${y.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${y.TYPE},\n ${y.CATEGORY},\n ${y.SUBCATEGORY},\n ${this.drillRowGroup} as ${y.ROWGROUP},\n ${t} ${e.length>0?",".concat(e):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${r}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.SUBCATEGORY}\n ORDER BY ${i[1]}`)})),o.forEach((t=>{s.push(...this.exec(t))})),this.injectDrillRowsToResultRows(s,n)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[y.TYPE]&&e.forEach(((e,i)=>{var n;t[i]=null!==(n=k(t[i],t[e]))&&void 0!==n?n:T}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const i=new Map,n=new Map;e.forEach(((t,e)=>{const o=t,s=[];for(const t of o)s.push(`${e}##${t.name}`);i.set(e,s),n.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[y.TYPE]&&i.forEach(((e,i)=>{let o=0;e.forEach((e=>{void 0!==t[e]&&(o+=t[e])})),t[`${i}##REST`]=t[i]-o,0!==t[`${i}##REST`]&&n.set(`${i}##REST`,!0)}))}))}));const o=Array.from(n.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of o)delete t[e]}))}))}createIntervalColumns(t){var e,i,n,o,s;if(this.config.interval===V||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const r="##",a=`(SELECT *, ${q(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),c=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),u=[...new Set(this.exctractScenarioNames(h))],d=this.getRelativeScenarios(),f=new Wt(this.config),p=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type,v=this.config.grouped&&(l.SUM===this.config.type||l.SUMNOTOTAL===this.config.type||l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type),m=this.checkConfigForPartOf()&&this.config.type!==l.LIST,$=t=>this.exec(t),g=t=>(this.config.scenarios.forEach((e=>{const i=new w(e);!0===i.isValid?0!==t[i.base+"_cnt"]&&0!==t[i.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),d.forEach(((e,i)=>{var n;t[i]=null!==(n=k(t[i],t[e]))&&void 0!==n?n:T})),t),b=(t,e,i)=>{for(const n of this.config.scenarios)t[n+r+i]=e[n]},S=$(`SELECT ${f.select()}, __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n GROUP BY ${f}, __interval`),R=t=>"ENTRY"===t.type&&null!=t.restRowGroup;if(this.config.limit>0)for(let n=0;n<t.length;n++){const o=t[n].find(R);if(!o)continue;let s;for(let e=n-1;e>=0&&!s;e--){const i=t[e].filter((t=>"ENTRY"===t.type&&!R(t)));i.length>0&&(s=i)}if(!s)continue;const r=new Set(s.map((t=>t.category))),l=s[0].rowGroup,a=new Map;for(const t of S){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const n=J(t.__interval);let o=a.get(n);o||(o={},a.set(n,o));for(const n of u)o[n]=(null!==(e=o[n])&&void 0!==e?e:0)+(null!==(i=t[n])&&void 0!==i?i:0)}a.forEach(((t,e)=>{b(o,g(t),e)}))}for(const e of S){const i=J(e.__interval);g(e);for(const n of t)for(const t of n)"ENTRY"!==t.type||R(t)||t.category!==e.category||this.config.grouped&&t.rowGroup!==e.rowGroup||p&&t.operation!==e.operation||b(t,e,i)}const E=v||m&&this.config.grouped?$(`SELECT ${At} as ${y.ROWGROUP}, __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n GROUP BY ${At}, __interval`):[],M=new Map;if(E.forEach((t=>M.set(`${t.rowGroup}${r}${J(t.__interval)}`,t))),v&&this.hasRunningSum()){const e=[...new Set(this.exctractScenarioNames(c))],i=t.flat().filter((t=>"GROUP_SUM"===t.type));for(const t of new Set(E.map((t=>J(t.__interval))))){let n;for(const o of i){const i=M.get(`${o.rowGroup}${r}${t}`);if(i){null!=n||(n={});for(const t of e)n[t]=zt(n[t],i[t])}n&&b(o,g(Object.assign({},n)),t)}}}else if(v)for(const e of E){const i=J(e.__interval),n=g(Object.assign({},e));for(const o of t)for(const t of o)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&b(t,n,i)}const O=l.SUM===this.config.type||l.OPT===this.config.type,N=O||m&&!this.config.grouped?$(`SELECT __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n GROUP BY __interval`):[],_=new Map;if(N.forEach((t=>_.set(J(t.__interval),t))),O)for(const e of N){const i=J(e.__interval),n=g(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&b(t,n,i)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const e=[];this.config.thereOf.forEach((t=>{e.push(...$(`SELECT ${this.drillRowGroup} as ${y.ROWGROUP}, ${y.CATEGORY}, ${y.SUBCATEGORY}, __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.SUBCATEGORY}, __interval`))}));for(const i of e){const e=J(i.__interval);g(i);for(const n of t)for(const t of n)"DRILLELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&(t.subCategory!==i.subCategory&&t.subCategory!==`${i.subCategory} (${i.rowGroup})`||b(t,i,e))}}if(m){let e="1 <> 1 ";null===(n=this.config.partOf)||void 0===n||n.forEach((t=>{e+=`OR (${y.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(e+=`and ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`),e+=")"}));const i=$(`SELECT ${y.CATEGORY}, ${this.config.grouped?`${y.ROWGROUP}`:`'SUM_TOTAL' as ${y.ROWGROUP}`}, __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n WHERE ${e}\n GROUP BY ${y.ROWGROUP}, ${y.CATEGORY}, __interval`),l=new Map;for(const t of i){const e=`${t.rowGroup}${r}${t.category}${r}${J(t.__interval)}`,i=l.get(e);if(i)for(const e of u)i[e]=(null!==(o=i[e])&&void 0!==o?o:0)+(null!==(s=t[e])&&void 0!==s?s:0);else l.set(e,t)}l.forEach((e=>{const i=J(e.__interval),n=this.config.grouped?M.get(`${e.rowGroup}${r}${i}`):_.get(i);for(const t of u)e[t]=e[t]/(n?n[t]:Number.NaN);g(e);for(const n of t)for(const t of n)"PARTELEMENT"===t.type&&t.category===e.category&&t.rowGroup===e.rowGroup&&b(t,e,i)}))}}createThereOfWhereClause(t){let e=!0,i="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(i+=` ${y.CATEGORY} = ${this.bind(t.category)}`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=` ${e?"":"AND"} ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(i+=` ${e?"":"AND"} ${y.SUBCATEGORY} = ${this.bind(t.subCategory)}`),i+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const i=this.createRelativeScenario(e);null!=i&&t.set(i.key,i.value)})),t}translateScenarioSQL(t,e,i){const n=new w(t);if(l.OPT===i||l.OPTNOTOTAL===i){if(n.isValid){const i=e?" * transformOperator(operation)":"",o=e?`SUM((${n.base} - ${n.delta})${i}) as ${t}`:`SUM(${n.base} - ${n.delta}) as ${t}`;return"dr"===n.type?`${o}, SUM(${n.delta}${i}) as dr_${n.delta}`:o}return e?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}return n.isValid?"dr"===n.type?`SUM((${n.base} * transformOperator(operation)) - (${n.delta} * transformOperator(operation))) as ${t}, SUM(${n.delta} * transformOperator(operation)) as dr_${n.delta}`:`SUM((${n.base} * transformOperator(operation))- (${n.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,i=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==l.OPT&&this.config.type!==l.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${e}) as ${t.alias}`;case"first":return`FIRST(${e}) as ${t.alias}`;case"last":return`LAST(${e}) as ${t.alias}`;case"min":return`MIN(${e}) as ${t.alias}`;case"max":return`MAX(${e}) as ${t.alias}`;case"avg":return i?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return i?`SUM(${e} * transformOperator(operation)) as ${t.alias}`:`SUM(${e}) as ${t.alias}`;case"lit":{const e=t.arg;return`${this.bind(""===e||Number.isNaN(Number(e))?e:Number(e))} as ${t.alias}`}}}get drillRowGroup(){return this.config.grouped?At:y.ROWGROUP}exec(t){const e=this.db.exec(t,this.params);return this.config.grouped&&e.forEach((t=>t.rowGroup=null==t.rowGroup?"":String(t.rowGroup))),e}bind(t){return`$${this.params.push(t)-1} `}createOrderString(t){const e=h.ASC===t.direction?h.DESC:h.ASC,i=new Map;t.hierarchy.forEach(((t,e)=>{const n=W(t),o=null==n?void 0:n.bucket;("variance"===(null==n?void 0:n.kind)||"scenario"===(null==n?void 0:n.kind)&&void 0!==o)&&i.set(e,this.translateSortKeySQL(n,o,e))})),this.sortSelect=[...i.values()].map((t=>`, ${t}`)).join("");const n=t.hierarchy.some((t=>{var e;const i=null===(e=W(t))||void 0===e?void 0:e.kind;return"scenario"===i||"variance"===i}));n&&(this.sortSelect+=`, CASE WHEN ${y.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`);const o=(t,e,n)=>i.has(e)?`__sortnull${e} asc, __sort${e} ${n}`:`${t} ${n}`,s=t.hierarchy.map(((e,i)=>o(e,i,t.direction))).toString(),r=t.hierarchy.map(((t,i)=>o(t,i,e))).toString();return n?[`__sortrest asc, ${s}`,`__sortrest desc, ${r}`]:[s,r]}translateSortKeySQL(t,e,i){const n=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",o=void 0===e?"":`TRIM(CAST(${q(Z)} AS STRING)) = ${this.bind(e)}`,s=t=>`SUM(${o?`(CASE WHEN ${o} THEN ${t} ELSE 0 END)`:t}${n})`,r=t=>`SUM(CASE WHEN ${o?`${o} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${s(t.column)} as __sort${i}, CASE WHEN ${r(t.column)} THEN 1 ELSE 0 END as __sortnull${i}`;const a=`(${s(t.base)} - ${s(t.delta)})`;let h=a,c=`${r(t.base)} OR ${r(t.delta)}`;if("dr"===t.type){const e=s(t.delta),i=`ABS(${e}) <= ABS(${a}) * 0.000000001`;h=`CASE WHEN ${i} THEN 0 ELSE ${a} / ABS(${e}) END`,c+=` OR ${i}`}return`${h} as __sort${i}, CASE WHEN ${c} THEN 1 ELSE 0 END as __sortnull${i}`}createRelativeScenario(t){const e=new w(t);return e.isValid&&"dr"===e.type?{key:`${t}`,value:`dr_${e.delta}`}:null}exctractScenarioNames(t){const e=[];return t.split(",").forEach((t=>t.length>=2?e.push(t.split("as")[1].trim()):null)),e}findDuplicateSubCategories(t){const e=t.map((t=>({count:1,subCategory:`${t.category}##${t.subCategory}`}))).reduce(((t,e)=>(t[e.subCategory]=(t[e.subCategory]||0)+e.count,t)),{});return Object.keys(e).filter((t=>e[t]>1))}createPartOfQuery(t,e){var i;const n=[];let o="1 <> 1 ",s=` ${this.drillRowGroup} as ${y.ROWGROUP}`,r="ROWNUM()";return null===(i=this.config.partOf)||void 0===i||i.forEach((t=>{o+=`OR (${y.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(o+=`and ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(s=` 'SUM_TOTAL' as ${y.ROWGROUP} `,r="1"),o+=")"})),n.push(`SELECT ${r} AS ${y.ROWNR},\n 'PARTELEMENT' as ${y.TYPE},\n ${y.CATEGORY},\n ${s},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.TYPE}\n ORDER BY ${e[1]}`),n}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const i=[],n=[],o=this.fromExpr;t.forEach(((t,e)=>{let n="1 <> 1 ";t.forEach((t=>{n+=` or columnGroup = ${this.bind(String(t.name))} `})),i.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),i.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),i.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),i.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of i)n.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(n,e)}injectDrillColumnsToResultRows(t,e){const i="##";for(const n of t)for(const t of e)for(const e of t)if(e.type===n.rowlevel)if("ENTRY"===n.rowlevel)"COLUMNGROUP"===n.columnlevel&&e.category===n.category?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val);else if("DRILLELEMENT"===n.rowlevel){if(!this.config.grouped&&e.rowGroup!==n.rowGroup)continue;"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val:"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val)}else("SUM"===n.rowlevel||"GROUP_SUM"===n.rowlevel)&&("COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup]=n.val),"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val))}}class Xt{constructor(t){this.ruleSet=t,this.normalizedHeader=[],this.attributesByAlias=new Map,this.hasBlankRowGroup=!1,this.dateBuckets=!1,this.unsignedEntries=!1}underlineClass(t){return this.ruleSet&&/^(ac|pp|fc|pl)[1-4]$/.test(t)?S(this.ruleSet.getScenarioColorIndex(t))+t.slice(2):null}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,e,i,n,o,s,l=[],a=0){const h=[];this.attributesByAlias=new Map(l.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,l,a);const c=this.normalizedHeader.some((t=>void 0!==t.bucket));c&&h.push(this.createIntervalBandRow());const u=new nt(c?1:0,0,r.HEADER),d=new nt(c?2:1,0,r.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);u.createElement(e?i.get(e.label)||e.label:b.translateScenarioLabel(t.name,i),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,i,n,o,s),null,null,null,null),d.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return h.push(u),h.push(d),h}createIntervalBandRow(){const t=new nt(0,0,r.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const i=this.normalizedHeader[e];if(void 0===i.bucket){t.createElement(null,i.type,"filler",null,null,null,null,null,null),e+=1;continue}let n=1;for(;e+n<this.normalizedHeader.length&&this.normalizedHeader[e+n].bucket===i.bucket;)n+=1;t.createElement(i.bucketLabel,i.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,n),e+=n}return t}setHeaderPrefix(t,e,i,n,o){let s="";return"category"===t.name&&o&&(0===i.prefix.length&&0===n.length||(s=b.translateScenarioLabel("in",e)+" "+i.prefix+n)),t.order&&(s+=b.translateScenarioLabel("ORDER_"+t.order,e)),s}normalizeHeader(t,e,i,n=0){let o=[{name:y.CATEGORY,group:y.CATEGORY,type:y.CATEGORY,order:void 0}];l.OPT!==t&&l.OPTNOTOTAL!==t||(o=[{name:y.OPERATION,group:y.OPERATION,type:y.OPERATION,order:void 0},{name:y.CATEGORY,group:y.CATEGORY,type:y.CATEGORY,order:void 0}]);const s=i.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e.slice(0,n),...o,...s,...e.slice(n)]}createBodyRows(t,e,i,n){var o;const s=[];let a=-1;const h=new Qt(t,e);var u;this.dateBuckets=(u=t.interval)!==V&&u!==Z,this.unsignedEntries=l.OPT===t.type||l.OPTNOTOTAL===t.type;const d=h.execute(i,n);this.hasBlankRowGroup=h.hasBlankRowGroup;const f=this.calculateColumnStatistics(d,t.barColumns,t.interval!==V),p=t.thereOfPosition===c.ABOVE,v=null!==(o=t.barColumns)&&void 0!==o?o:[],m=v.filter((t=>t.toUpperCase().trim()in O)),$=[...m.length>0&&Ht(d)?m:[],...t.varianceWaterfall?v.filter((t=>"d"===new w(t).type)):[]],g=$.length>0&&t.interval===V&&0===t.categoryThereOf.size?function(t,e,i,n=!1,o=!1){const s=new Ft,a=i===l.OPT||i===l.OPTNOTOTAL;for(const l of e){const e=new w(l).isValid;let h,c=0,u=0;const d=[],f=[];let p=null;const v=(t,e)=>(d.push(e),s.set(t,l,e),e),m=t=>{p=t&&{main:t,children:[],gapAbove:!1,gapBelow:!1},f.push(p)};for(const s of t)for(const t of s){const s=t[y.TYPE];if(s===r.GROUPHEAD){n||(c=0),h=void 0,m(null);continue}const d=jt(t,l,i);if(s===r.ENTRY){if(null===d){h=void 0,m(null);continue}m(v(t,{start:c,end:c+d,min:0,max:0,kind:"cascade"})),h={start:c,end:c+d,sign:a?Yt(t):1},u=h.start,c+=d}else if(s===r.SUM||s===r.GROUPSUM){if(null===d){h=void 0,m(null);continue}m(v(t,{start:0,end:d,min:0,max:0,kind:"anchor"})),h={start:0,end:d,sign:1},u=0,c=s!==r.GROUPSUM||n?d:0}else if(!e||s!==r.DRILLELEMENT&&s!==r.PARTELEMENT){if(s===r.DRILLELEMENT){if(null===d||void 0===h)continue;const e=u+(Math.sign(h.end-h.start)||1)*Math.abs(d);v(t,{start:u,end:e,min:0,max:0,kind:"thereof",parentStart:h.start,parentEnd:h.end}),u=e}else if(s===r.PARTELEMENT){if(null===d||void 0===h)continue;const e=u+d*(h.end-h.start);v(t,{start:u,end:e,min:0,max:0,kind:"partof",parentStart:h.start,parentEnd:h.end}),u=e}}else if(s===r.DRILLELEMENT&&null!==d&&void 0!==h&&p){const e=u+h.sign*d;p.children.push(v(t,{start:u,end:e,min:0,max:0,kind:"thereof"})),u=e}else p&&(o&&s===r.DRILLELEMENT?p.gapAbove=!0:p.gapBelow=!0)}e&&Bt(f,o);let $=0,g=0;for(const t of d)$=Math.min($,t.start,t.end),g=Math.max(g,t.start,t.end);for(const t of d)t.min=$,t.max=g}return s}(d,$,t.type,h.hasRunningSum(),p):void 0;for(const i of d)a+=1,s.push(...this.createRow(t.i18n,e,t.scenariosUnitType,i,a,-1,t.categoryWidth,t.measureScale,t.barColumns,f,g,p));return s}calculateColumnStatistics(t,e,i=!1){const n=new Map;if(!e||0===e.length)return n;const o=new Map;for(const t of e)n.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),o.set(t,[]);for(const s of t)for(const t of s){const s=t[y.TYPE];if(s!==r.SUM&&s!==r.GROUPSUM)for(const s of e){const e=i?this.extractIntervalColumnValues(t,s):[this.extractColumnValue(t,s)];for(const t of e)if(null!==t&&!isNaN(t)){const e=n.get(s);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),o.get(s).push(Math.abs(t))}}}for(const[t,e]of n){e.min!==1/0&&e.max!==-1/0||(e.min=0,e.max=0),e.absMax=Math.max(Math.abs(e.min),Math.abs(e.max));const i=o.get(t);if(i.length>0){i.sort(((t,e)=>t-e));const t=Math.floor(i.length/2);e.median=i.length%2==0?(i[t-1]+i[t])/2:i[t]}n.set(t,e)}return n}extractIntervalColumnValues(t,e){const i=e+"##",n=[];for(const e of Object.keys(t))if(e.startsWith(i)){const i=Number(t[e]);n.push(isNaN(i)?null:i)}return n}extractColumnValue(t,e){if(void 0!==t[e]){const i=Number(t[e]);return isNaN(i)?null:i}for(const i of Object.keys(t))if(i===e||i.endsWith("##"+e)||i===e+"##"+e){const e=Number(t[i]);if(!isNaN(e))return e}return null}createRow(t,e,i,n,o,s,l,a,h,c,u,d=!1){var f,p,m;const $=[];let g,b,S=-1;for(const R of n){const E=R[y.ROWGROUP],M=""===E?"-":E,O=R[y.SUBCATEGORY],N=R[y.TYPE],_=R[y.ROWNR]>=2;b=null!==(p=null!==(f=R.operation)&&void 0!==f?f:R.restOperation)&&void 0!==p?p:b;const G=d&&N===r.DRILLELEMENT&&void 0!==g&&g[y.CATEGORY]===R[y.CATEGORY]&&("NO_GROUP"===g[y.ROWGROUP]||g[y.ROWGROUP]===E),U=this.createDetailRow(N,s+=1,o,n.length);U.key=this.rowKey(R);for(const n of this.normalizedHeader){const o=this.getRawDataRowElement(R,n),s=null!==(m=null==h?void 0:h.includes(n.type))&&void 0!==m&&m,d=s&&void 0===n.bucket&&n.name===n.group&&n.name===n.type?null==u?void 0:u.get(R,n.type):void 0,f=s&&!(N===r.PARTELEMENT&&new w(n.type).isValid&&(null==u?void 0:u.has(n.type))),p=f?null==c?void 0:c.get(n.type):void 0;U.createElement(this.translateSumCellLabel(t,e,o,M,O,N,n.type),n.type,this.createColumnType(n),this.setCellType(n.type,i),G?null:this.translateCellPrefix(e,N,n.type),this.translateScenarioCSS(n.type,o,b),_,l,null==a?void 0:a.value,f,p,1,d);const $=U.elements[U.elements.length-1];this.dateBuckets&&void 0!==n.bucket&&($.date=v(n.bucket));const g=new w(n.type);g.isValid&&($.direction=this.resolveDirection(g,b))}G?(U.cssStyle="ofit-above",$[S].cssStyle="ofit-sum",$.splice(S,0,U),S+=1):(N===r.ENTRY&&(S=$.length,g=R),$.push(U))}return $}rowKey(t){var e;const i=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case r.ENTRY:return{rowGroup:i,category:t.category,subCategory:t.subCategory};case r.DRILLELEMENT:return{rowGroup:i,category:t.category,subCategory:null!==(e=t.rawSubCategory)&&void 0!==e?e:t.subCategory};case r.GROUPSUM:return{rowGroup:i,row:"subtotal"};case r.SUM:return{row:"total"};default:return}}getRawDataRowElement(t,e){return void 0!==e.bucket?t[e.type+"##"+e.bucket]:e.name===e.group&&e.name===e.type?t[e.name]:e.name===e.group&&e.name!==e.type?t[e.type+"##"+e.name]:t[e.type+"##"+e.group+"##"+e.name]}createDetailRow(t,e,i,n){switch(t){case r.GROUPHEAD:return new nt(e,i,r.HEADER);case r.SUM:case r.GROUPSUM:return new nt(n+2,i,r.SUM);case r.DRILLELEMENT:return new nt(n+2,i,r.DRILLELEMENT);case r.PARTELEMENT:return new nt(n+2,i,r.PARTELEMENT);default:return new nt(e,i,r.STANDARD)}}translateSumCellLabel(t,e,i,n,o,s,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(i))||this.isOperationColumn(r)?i:this.isGroupHeadCategory(s,r)?t===N.ALL?`${e.get(i)||i}`:i:this.isEntryCategory(s,r)?t===N.ALL||"REST"===i?`${e.get(i)||i}`:i:this.isDrillElementCategory(s,r)?t===N.ALL?`${e.get(o)||o}`:`${o}`:this.isPartElementCategory(s,r)?t===N.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:`${n}`:this.isSumElementCategory(s,r)?t===N.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:n:"GROUPHEAD"===s&&null==i||i===T?i:Number.isNaN(Number(i))?"-":Number(i)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e,i){if(this.attributesByAlias.has(t))return"attribute";const n=new w(t);let o="pos";return e<0&&(o="neg"),n.isValid?o+"_"+this.resolveDirection(n,i)+("dr"===n.type?" relative_variance":""):t}resolveDirection(t,e){return R(t.direction,e,!this.unsignedEntries)}setCellType(t,e){if("category"===t)return"";const i=this.attributesByAlias.get(t);if(i)return i.isNumeric?"decimal":"";let n;const o=new w(t);return e===_.PERCENT?(n="percent",o.isValid&&"d"===o.type&&(n="percentpoint")):(n="decimal",o.isValid&&"dr"===o.type&&(n="percent")),n}isDrillElementCategory(t,e){return"DRILLELEMENT"===t&&"category"===e}isPartElementCategory(t,e){return"PARTELEMENT"===t&&"category"===e}isSumElementCategory(t,e){return("GROUP_SUM"===t||"SUM"===t)&&"category"===e}isEntryCategory(t,e){return"ENTRY"===t&&"category"===e}isGroupHeadCategory(t,e){return"GROUPHEAD"===t&&"category"===e}translateCellPrefix(t,e,i){return this.isOperationColumn(i)||this.isGroupHeadCategory(e,i)||this.isEntryCategory(e,i)?null:this.isDrillElementCategory(e,i)?`${t.get("thereof")} `:this.isPartElementCategory(e,i)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class Vt{constructor(t,e,i,n){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new E,this.db=e,this.dataSetFactory=new Xt(this.ruleSet),this.config=this.initConfig(n),this.i18n=this.initI18n(new Map),this.setSource(i,n.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const e=new Map([["",""],["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=u.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=u.DIRTY;const e=t,i=this;return t.scenarios.sort(((t,e)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var i,n;if(this.state=u.DIRTY,this.fromExpr=B(this.db,t,e),!this.fromExpr)return void(this.rowCount=0);const o=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(n=null===(i=o[0])||void 0===i?void 0:i.cnt)&&void 0!==n?n:0}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes,Math.min(this.categoryIntervalPosition(),this.intervalBuckets.length)*this.config.scenarios.length),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=u.UP_TO_DATE}getHeader(){return this.state===u.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===u.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===u.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===V||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=V:(this.config.interval=function(t,e,i){var n;if(i!==P.AUTO)return i;const o=t.exec(`SELECT [date] as d FROM ${e}`);let s,r;for(const t of o){const e=null===(n=tt(t.d))||void 0===n?void 0:n.toMillis();void 0!==e&&(s=void 0===s?e:Math.min(s,e),r=void 0===r?e:Math.max(r,e))}return void 0===s||void 0===r?P.DAY:(new A).calculateDistanceType(L.fromMillis(s),L.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,i,n){if(i===Z){const n=t.exec(`SELECT ${q(i)} as __interval, COALESCE([setnameIndex],[setNameIndex]) as __index FROM ${e}`),o=new Set,s=new Map,r=[];for(const t of n){const e=J(t.__interval);o.has(e)||(o.add(e),r.push({key:e,label:0===e.length?"-":e}));const i=K(t.__index),n=s.get(e);void 0!==i&&(void 0===n||i<n)&&s.set(e,i)}if(s.size>0){const t=t=>{var e;return null!==(e=s.get(t.key))&&void 0!==e?e:Number.POSITIVE_INFINITY};r.sort(((e,i)=>t(e)===t(i)?0:t(e)<t(i)?-1:1))}return r}const o=t.exec(`SELECT ${q(i)} as __interval FROM ${e}`),s=new Set,r=[];for(const t of o){const e=tt(t.__interval);if(!e)continue;const i=e.toISO();s.has(i)||(s.add(i),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new A;return l.setLocale(n),r.map((t=>({key:t.toISO(),label:l.getDateString(t,i)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=V))}normalizeScenarios(t,e,i,n=[]){var o;const s=[],r=null===(o=null==i?void 0:i.hierarchy)||void 0===o?void 0:o.map((t=>W(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),l=this.config.interval===Z?null==r?void 0:r.bucket:void 0,a=(t,e)=>{var n;return null==r||(null===(n=W(t))||void 0===n?void 0:n.column)!==r.column||void 0!==l&&l!==e?void 0:i.direction};if(n.length>0){for(const e of n)for(const i of t)s.push({name:i,group:i,type:i,order:a(i,e.key),bucket:e.key,bucketLabel:e.label});return s}for(const i of t){if(null==e?void 0:e.has(i)){const t=e.get(i);for(const e of t){s.push({name:e.name,group:e.name,type:i,order:void 0});for(const t of e.subGroups)s.push({name:t,group:e.name,type:i,order:void 0})}s.push({name:"REST",group:"REST",type:i,order:void 0})}s.push({name:i,group:i,type:i,order:a(i)})}return s}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,e;if(this.hasNoData()||this.state!==u.UP_TO_DATE)return;const i=(null!==(e=null===(t=this.config.sortOrder)||void 0===t?void 0:t.hierarchy)&&void 0!==e?e:[]).map((t=>{var e;return null===(e=W(t))||void 0===e?void 0:e.bucket})).filter((t=>void 0!==t));if(0===i.length)return;if(this.config.interval!==Z)return`order: '@${i[0]}' needs interval setname, the bucket is ignored.`;const n=i.find((t=>!this.intervalBuckets.some((e=>e.key===t))));return void 0===n?void 0:`order: setname '${n}' not found, the rows are not sorted by it.`}categoryIntervalPosition(){const t=this.config.categoryIntervalPosition;return Number.isInteger(t)&&t>0?t:0}categoryIntervalPositionWarning(){const t=this.categoryIntervalPosition();if(t<=0||this.hasNoData()||this.state!==u.UP_TO_DATE)return;const e=this.intervalBuckets.length;return 0===e?{id:"WARN_categoryIntervalPositionNoInterval",message:"categoryIntervalPosition: needs an active interval, the value is ignored."}:t>e?{id:"WARN_categoryIntervalPositionRange",message:`categoryIntervalPosition: '${t}' is greater than the number of interval groups, ${e} is used.`}:void 0}hasBlankRowGroup(){return this.dataSetFactory.hasBlankRowGroup}}class Zt{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=_.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereOf=[],this.thereOfPosition=c.BELOW,this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new D(new z).default(),this.type=l.LIST,this.limit=0,this.i18n=N.ALL,this.categoryWidth=U.W25,this.measureScale=new Q,this.measureUnit="",this.measureType=x.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.locale="de"}}class qt{constructor(t,e,i,n,o,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=i,this.db=n,this.fromExpr=o,this.onQueryError=s}adapt(t){const e=new Zt;return G.isString(t.title)&&(e.title=t.title),G.isArray(t.scenarios)&&(e.scenarios=j.adaptArray(t.scenarios,this.stringAdapter)),G.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),G.isBoolean(t.grouped)&&(e.grouped=t.grouped),G.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),G.isBoolean(t.runningSum)&&(e.runningSum=t.runningSum),G.isBoolean(t.varianceWaterfall)&&(e.varianceWaterfall=t.varianceWaterfall),t.thereOfPosition===c.ABOVE&&(e.thereOfPosition=c.ABOVE),G.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),G.isArray(t.thereOf)&&(e.thereOf=j.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),G.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),G.isArray(t.partOf)&&(e.partOf=j.adaptArray(t.partOf,this.tableDrillGroupAdapter)),G.isArray(t.attributes)&&(e.attributes=t.attributes),G.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),G.isExisting(t.type)&&(e.type=t.type),G.isNumber(t.limit)&&(e.limit=t.limit),G.isExisting(t.i18n)&&(e.i18n=t.i18n),G.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),G.isExisting(t.measureScale)&&(e.measureScale=H.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),G.isExisting(t.measureType)&&(e.measureType=t.measureType),G.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),G.isString(t.filter)&&(e.filter=t.filter.trim()),G.isArray(t.barColumns)&&(e.barColumns=t.barColumns),G.isString(t.interval)&&(e.interval=t.interval),G.isNumber(t.categoryIntervalPosition)&&(e.categoryIntervalPosition=t.categoryIntervalPosition),G.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Zt}}class Kt{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class Jt{constructor(){}adapt(t){const e=new Kt;return G.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),G.isString(t.category)&&(e.category=t.category),G.isString(t.subCategory)&&(e.subCategory=t.subCategory),G.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new Kt}}const te=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=_.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereof=[],this.thereofPosition=c.BELOW,this.partof=[],this.order={hierarchy:[],direction:h.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=l.LIST,this.categoryWidth=U.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=N.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=x.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new I,this.barColumnLayouts=new Map,this.waterfallGeometries=new Map,this.relayout=()=>{(this.barColumnLayouts.size>0||this.waterfallGeometries.size>0)&&n(this)},C(this),this.componentStyle=X(this)}connectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.relayout)}disconnectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.removeEventListener("loadingdone",this.relayout)}async getLayoutDetail(t,e){var i,n,o;const s={regions:[],metadata:{},diagnostics:[]},r=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector("table");if(s.metadata.hasNoData=null===(o=null===(n=this.table)||void 0===n?void 0:n.hasNoData())||void 0===o||o,!this.table||!r)return s;const l=r.querySelector("thead"),a=r.querySelector("tbody");l&&s.regions.push({id:"header",rect:d(l,t)}),a&&s.regions.push({id:"body",rect:d(a,t)});const h=this.table.getHeader(),c=this.table.getBody(),u=this.table.getColumns();if(s.metadata.headerRowCount=h.length,s.metadata.rowCount=c.length,s.metadata.columnCount=u.length,s.metadata.cellCount=c.reduce(((t,e)=>t+e.getCells().length),0),"full"!==e)return s;const v=[],m=[],g=(e,i,n)=>{const o=n?Array.from(n.children).filter((t=>"tr"===t.localName)):[];i.forEach(((i,n)=>{const r=o[n];if(!r)return;v.push({section:e,index:n,type:i.type,rect:d(r,t),point:$(r)});const l=i.getCells(),a=Array.from(r.children);l.length===a.length?l.forEach(((i,o)=>{var s,r;const l=a[o],h={kind:"header"===e?"headerCell":"cell",row:n,column:i.index,key:i.key||void 0,colSpan:i.colSpan,value:null!==(s=i.value)&&void 0!==s?s:void 0,text:(null===(r=l.textContent)||void 0===r?void 0:r.trim())||void 0,type:i.type||void 0,rect:d(l,t),point:$(l)};h.point&&(h.content=f(l,t),h.contentSign=p(l)||void 0);const c=l.querySelector("svg.cell-bar-chart");c&&(h.bar={variant:c.classList.contains("waterfall-bar")?"waterfall":c.classList.contains("relative-variance")?"relative":"absolute",rect:d(c,t)}),m.push(h)})):s.diagnostics.push({id:`WARN_layout_cell_pairing_${e}_${n}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${e} row ${n} (${l.length} vs ${a.length}); cell details skipped for this row.`})}))};return g("header",h,l),g("body",c,a),s.elements=m,s.table={rows:v,columns:u.map(((t,e)=>({index:e,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},s}render(){var e;return t(o,{class:{"no-data":!0===(null===(e=this.table)||void 0===e?void 0:e.hasNoData())}},(()=>{var e,i,n,o;if(void 0===this.table)return;if(this.table.hasNoData()){const i=null!==(e=this.i18n.get("no-data"))&&void 0!==e?e:"No Data";return t("div",{class:"empty-state"},i)}const s=null===(o=null===(n=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===n?void 0:n.state)||void 0===o?void 0:o.locale;return t("table",null,t("thead",null,this.table.getHeader().map((e=>t("tr",{class:e.cssStyle},e.getCells().map((e=>t("th",{colSpan:e.colSpan,class:e.cssStyle},e.getAsHeaderList().map(((i,n,o)=>t("span",null,n===o.length-1?t("span",{class:" "===i?"table-footer":""},i,e.drawPrefix()," "):t("span",null,i,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",Object.assign({class:e.cssStyle},g(e.key,"element")),null==e?void 0:e.getCells().map((i=>{var n,o,l,a,h;return t("td",Object.assign({colSpan:i.colSpan,class:i.type?`${this.cellClass(i,s)} ${i.type}`:i.cssStyle},e.key&&null!=i.value&&""!==i.value&&"-"!==i.value?g(Object.assign(Object.assign({},e.key),{date:i.date,scenario:i.key}),"element"):{}),null!=i.prefix?t("span",{class:this.cellClass(i,s)+" "+i.prefixStyle},i.drawPrefix()):"",!i.isBarChart||!i.columnStats||i.value===T||!this.showGroupTitle&&e.type===r.HEADER||void 0===i.waterfall&&e.type===r.SUM||void 0!==i.direction&&i.waterfall&&i.waterfall.max===i.waterfall.min?i.draw(this.componentDataFormatDigits,s):void 0!==i.waterfall?t(Pt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===i.direction,measureScale:ie(i),locale:s,decimalDigits:ne(i,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:i.waterfall,geometry:this.waterfallGeometries.get(i.key),bold:ee(e),connectorReach:this.connectorReach(e)}):t(Lt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:i.key.startsWith("dr"),isPositiveGood:"pos"===i.direction,measureScale:ie(i),locale:s,decimalDigits:ne(i,this.componentDataFormatDigits),percentDigits:null!==(o=null===(n=this.barColumnLayouts.get(i.key))||void 0===n?void 0:n.percentDigits)&&void 0!==o?o:this.componentDataFormatDigits.percent,percentSign:null===(l=this.barColumnLayouts.get(i.key))||void 0===l?void 0:l.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(a=this.barColumnLayouts.get(i.key))||void 0===a?void 0:a.labels,sideMax:null===(h=this.barColumnLayouts.get(i.key))||void 0===h?void 0:h.sideMax,bold:ee(e),styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,e,i,n,o,s,r,l,a,h,c;this.stores||(this.stores=F(this.element));const u=this.stores.db.db;this.componentDataFormatDigits=(new Y).adapt(this.dataFormatDigits);try{const e=this.prepareConfig(u);this.table=new Vt(new E(this.ruleSetConfig),u,this.tableName,e),this.table.setI18n(this.i18n),this.table.hasNoData()||this.table.getBody(),null===(t=this.errors)||void 0===t||t.remove("ERR_sql")}catch(t){console.error("bn-table-renderer: query failed",t),this.table=void 0,null===(e=this.errors)||void 0===e||e.addOrReplace({id:"ERR_sql",type:"error",message:`Query failed: ${t instanceof Error?t.message:t}`})}(null===(i=this.table)||void 0===i?void 0:i.hasBlankRowGroup())?null===(n=this.errors)||void 0===n||n.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(o=this.errors)||void 0===o||o.remove("WARN_blankRowGroup");const d=null===(s=this.table)||void 0===s?void 0:s.orderBucketWarning();d?null===(r=this.errors)||void 0===r||r.addOrReplace({id:"WARN_orderBucket",type:"warning",message:d}):null===(l=this.errors)||void 0===l||l.remove("WARN_orderBucket");const f=null===(a=this.table)||void 0===a?void 0:a.categoryIntervalPositionWarning();for(const t of["WARN_categoryIntervalPositionNoInterval","WARN_categoryIntervalPositionRange"])(null==f?void 0:f.id)===t?null===(h=this.errors)||void 0===h||h.addOrReplace({id:t,type:"warning",message:f.message}):null===(c=this.errors)||void 0===c||c.remove(t);this.barColumnLayouts=this.collectBarColumnLayouts(),this.waterfallGeometries=this.collectWaterfallGeometries(),this.barChartStyles=this.prepareBarChartStyles()}cellClass(t,e){return void 0!==t.direction&&t.roundsToZero(this.componentDataFormatDigits,e)?t.cssStyle.replace(/^(pos|neg)_\w+/,"zero"):t.cssStyle}prepareConfig(t){var e,i,n;const o=B(t,this.tableName,this.filter);return new qt(new Jt,new z,new D(new z,!0),t,o,(t=>{throw t})).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereOf:this.thereof,thereOfPosition:this.thereofPosition,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,categoryIntervalPosition:this.categoryIntervalPosition,locale:(null===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale)||"de"})}prepareBarChartStyles(){var t;const e=!(this.unitScaling>0),i=!(this.percentageScaling>0),n=e?this.autoUnitScaling():this.unitScaling,o=i?this.autoPercentageScaling():this.percentageScaling;return(e||i)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:e?n:void 0,percentage:i?o:void 0})),this.componentStyle((t=>{var e,i,s,r,l,a,h,c,u,d,f,p,v,$,g,b,w,y,S,R,O,N,_,G,U,x;const T=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,k=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.barStyles;return{positive:{stroke:(null===(s=null==T?void 0:T.pos)||void 0===s?void 0:s.stroke)||"#008f96",fill:(null===(r=null==T?void 0:T.pos)||void 0===r?void 0:r.fill)||"#008f96",fillpattern:m(null===(l=null==T?void 0:T.pos)||void 0===l?void 0:l.fillpattern)||"solid"},negative:{stroke:(null===(a=null==T?void 0:T.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(h=null==T?void 0:T.neg)||void 0===h?void 0:h.fill)||"#ff0000",fillpattern:m(null===(c=null==T?void 0:T.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==T?void 0:T.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==T?void 0:T.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:m(null===(f=null==T?void 0:T.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:M({ac:{stroke:(null===(p=null==k?void 0:k.ac)||void 0===p?void 0:p.stroke)||"#404040",fill:(null===(v=null==k?void 0:k.ac)||void 0===v?void 0:v.fill)||"#404040",fillpattern:m(null===($=null==k?void 0:k.ac)||void 0===$?void 0:$.fillpattern)||"solid"},pp:{stroke:(null===(g=null==k?void 0:k.pp)||void 0===g?void 0:g.stroke)||"#A6A6A6",fill:(null===(b=null==k?void 0:k.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:m(null===(w=null==k?void 0:k.pp)||void 0===w?void 0:w.fillpattern)||"solid"},fc:{stroke:(null===(y=null==k?void 0:k.fc)||void 0===y?void 0:y.stroke)||"#404040",fill:(null===(S=null==k?void 0:k.fc)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:m(null===(R=null==k?void 0:k.fc)||void 0===R?void 0:R.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==k?void 0:k.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(N=null==k?void 0:k.pl)||void 0===N?void 0:N.fill)||"#ffffff",fillpattern:m(null===(_=null==k?void 0:k.pl)||void 0===_?void 0:_.fillpattern)||"outlined"}},new E(this.ruleSetConfig)),fontColor:(null===(G=t.global)||void 0===G?void 0:G.fontColor)||"#000000",fontSize:((null===(U=t.global)||void 0===U?void 0:U.fontSizePx)||13.3333)*ot*this.scaleFactor,emPx:((null===(x=t.global)||void 0===x?void 0:x.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:n,percentageScaling:o,scaleFactor:this.scaleFactor}}))}labelFontFamily(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif"}))}emPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){var t;const e=this.emPx(),i=e*ot;let n=1/0;for(const{isRelative:o,absMax:s,labels:r,sideMax:l}of this.barColumnLayouts.values()){if(o||s<=0)continue;const a=vt(this.barColumnMaxWidth,e,r,l);for(const e of["neg","pos"]){const o=null!==(t=l[e])&&void 0!==t?t:0;if(o<=0)continue;const{maxBarWidth:s,cutWidth:r}=a[e];n=Math.min(n,Math.min(.8*s,r)/(o*i))}}return Number.isFinite(n)&&i>0?n:.01}autoPercentageScaling(){var t,e;const i=this.emPx(),n=i*ot;let o=1/0;for(const{isRelative:s,absMax:r,labels:l,sideMax:a}of this.barColumnLayouts.values()){if(!s||r<=0)continue;const h=10*this.scaleFactor,{negPinLength:c,posPinLength:u}=mt(this.barColumnMaxWidth,i,l,h),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(e=a.pos)&&void 0!==e?e:0));o=Math.min(o,(c+u)/(d*n))}return Number.isFinite(o)&&n>0?o:.5}collectBarColumnLayouts(){var t,e,i,n;const o=new Map;if(!this.table||this.table.hasNoData())return o;const s=new Map;for(const e of this.table.getBody())if(e.type!==r.SUM)for(const i of e.getCells())i.isBarChart&&i.columnStats&&void 0===i.waterfall&&("number"!=typeof i.value||isNaN(i.value)||s.set(i.key,[...null!==(t=s.get(i.key))&&void 0!==t?t:[],{cell:i,bold:ee(e)}]));const l=this.emPx(),a=l*ot,h=10*this.scaleFactor,c=null===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale,u=this.labelFontFamily();for(const[t,e]of s){const i=t.startsWith("dr"),n=e.map((({cell:t})=>t.value)),s=(t,o)=>{var s;const r={neg:n.some((t=>t<0))?0:void 0,pos:n.some((t=>t>0))?0:void 0},l=Nt(r);for(const{cell:n,bold:h}of e){const e=n.value,d=e>0||0===e&&l?"pos":"neg",f=St(e,i,ie(n),c,t,o,ne(n,this.componentDataFormatDigits));r[d]=Math.max(null!==(s=r[d])&&void 0!==s?s:0,ht(f,a,u,i,h))}return r};let r=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=s(r,d);for(;i&&(r>0||d)&&!ft(this.barColumnMaxWidth,l,f,h);)r>0?r--:d=!1,f=s(r,d);const p=Math.max(...n.map(Math.abs))*(i?100:1),v={neg:void 0===f.neg?void 0:Math.max(0,...n.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...n)};o.set(t,{isRelative:i,absMax:p,labels:f,sideMax:v,percentDigits:r,percentSign:d})}return o}connectorReach(t){const e=this.emPx();return{top:.1*e,bottom:t.type===r.SUM?.5*e:0}}collectWaterfallGeometries(){var t,e,i,n;const o=new Map;if(!this.table||this.table.hasNoData())return o;const s=this.emPx(),r=s*ot,l=null===(i=null===(e=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===e?void 0:e.state)||void 0===i?void 0:i.locale,a=this.labelFontFamily(),h=new Map;for(const t of this.table.getBody())for(const e of t.getCells()){if(!e.isBarChart||!e.columnStats||void 0===e.waterfall)continue;if("number"!=typeof e.value||isNaN(e.value))continue;const{start:i,end:o,min:s,max:c,kind:u}=e.waterfall,d=Ct(e.value,u,ie(e),l,ne(e,this.componentDataFormatDigits),void 0!==e.direction),f=null!==(n=h.get(e.key))&&void 0!==n?n:{min:s,max:c,labels:[]};f.labels.push({end:o,pointsLeft:o<i,width:ht(d,r,a,!1,ee(t))}),h.set(e.key,f)}for(const[t,e]of h)o.set(t,$t(this.barColumnMaxWidth,s,e));return o}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral,td.zero{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.cell-bar-chart),tr.partof td:has(.cell-bar-chart),tr.share td:has(.cell-bar-chart){padding:0 0.4166666667em}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}'}},[1,"bn-table-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],scenarios:[16],scenariosDataFormat:[1,"scenarios-data-format"],grouped:[4],limit:[2],showGroupTitle:[4,"show-group-title"],runningSum:[4,"running-sum"],varianceWaterfall:[4,"variance-waterfall"],thereof:[16],thereofPosition:[1,"thereof-position"],partof:[16],order:[16],categorythereof:[16],attributeColumns:[16],type:[1],categoryWidth:[1,"category-width"],dataFormatDigits:[16],ruleSetConfig:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],measureType:[1,"measure-type"],filter:[1],barColumns:[16],interval:[1],categoryIntervalPosition:[2,"category-interval-position"],barColumnMaxWidth:[2,"bar-column-max-width"],unitScaling:[2,"unit-scaling"],percentageScaling:[2,"percentage-scaling"],reportAutoScaling:[16],errors:[16],scaleFactor:[2,"scale-factor"],getLayoutDetail:[64]}]);function ee(t){return t.type===r.SUM||"ofit-sum"===t.cssStyle}function ie(t){return"percentpoint"===t.type?.01:t.measureScale}function ne(t,e){return"percentpoint"===t.type?e.percent:"decimal"===t.type?e.decimal:void 0}function oe(){"undefined"!=typeof customElements&&["bn-table-renderer"].forEach((t=>{"bn-table-renderer"===t&&(customElements.get(s(t))||customElements.define(s(t),te))}))}export{te as B,V as I,Z as a,K as c,oe as d}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,H as i,h as s,a as e,t as n}from"./p-D6YGOYV1.js";import{r as h,m as o,g as r,d as a}from"./p-DDvWTgk1.js";import{C as l,I as d}from"./p-CniN8ALm.js";import{w as c}from"./p-Dq9dG0Kr.js";import{e as u,r as m}from"./p-ClruFZD_.js";import{S as v,F as f,a as p,P as w}from"./p-eWxolPDU.js";import{d as g,S as x}from"./p-BzjGUtYh.js";import{X as y,r as b,a as M,x as $,f as L,b as j,c as S,P,F as W,d as k,S as D}from"./p-CUSAlS2o.js";import{N as C}from"./p-BJmwHV0a.js";import{a as T,r as N,i as z}from"./p-BXXjh6We.js";import{s as E}from"./p-Xb6Ilq8u.js";class A{constructor(t,i){this.xScale=t,this.yScale=i}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const i=t.filter((t=>t>0)).sort(((t,i)=>t-i));if(0===i.length)return[];const s=t=>i[Math.min(i.length-1,Math.floor(t*i.length))];let e=A.ladderValues(s(.25),s(.75));if(e.length<2&&(e=A.ladderValues(i[0],i[i.length-1])),0===e.length)return[];if(1===e.length)return e;if(e.length<=4)return e;const n=[];for(let t=0;t<4;t++)n.push(e[Math.round(t*(e.length-1)/3)]);return[...new Set(n)]}static ladderValues(t,i){if(t<=0||i<t)return[];const s=[];for(let e=Math.floor(Math.log10(t))-1;e<=Math.ceil(Math.log10(i));e++)for(const n of[1,2,5]){const h=n*Math.pow(10,e);h>=t&&h<=i&&s.push(h)}return s}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const i=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),s=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return i>=s?null:[i,s]}samples(t){const i=this.visibleRange(t);if(null===i)return null;const[s,e]=i,n=[];for(let i=0;i<64;i++){const h=s*Math.pow(e/s,i/63);n.push({x:this.xScale.scale(h),y:this.yScale.scale(t/h)})}return n}path(t){const i=this.samples(t);return null===i?null:i.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const i=this.visibleRange(t);if(null===i)return null;const s=i[1],e=s>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(s),y:this.yScale.scale(t/s),edge:e?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const i=this.xScale.domainMin,s=this.xScale.domainMax,e=this.yScale.domainMin,n=this.yScale.domainMax,h=this.xScale.scale(i),o=this.xScale.scale(s),r=this.yScale.scale(n),a=this.yScale.scale(e);if(t>=s*n)return null;if(t<=i*e)return`M ${h} ${r} L ${o} ${r} L ${o} ${a} L ${h} ${a} Z`;const l=this.samples(t),[d,c]=this.visibleRange(t),u=d>i,m=c>=s-1e-9*Math.abs(s),v=l.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`));return m||v.push(`L ${o} ${a}`),v.push(`L ${o} ${r}`),u||v.push(`L ${h} ${r}`),v.push("Z"),v.join(" ")}}class V{constructor(t,i,s,e,n,h){var o,r;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=h,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.config=Object.assign(Object.assign({},e),{x:T(e.x),y:T(e.y)});const a=new y;let l=[];try{""!==s&&(l=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=u(t)}const d=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=b(d,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=N(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=N(e.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"}},domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var h,o,r;return t.text(i).font({size:null!==(h=n.size)&&void 0!==h?h:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(r=n.color)&&void 0!==r?r:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var i;return{label:""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=N(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:i,overflowed:s}=h(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),o(this.primaryColorIndex(),i,"dot")}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}toString(){const t=new v;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s,e,n,h,o,r,a,l,d;this.warnings=this.data.warnings.slice();const c=this.em,u=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",v=t.group(),f=new M(this.styles),p=this.legendModel(),w=this.config.legend.show&&p.entries.length>0,g=w?f.measure(p,this.config.legend.position):{width:0,height:0},x=null!==this.config.iso,y=x?Math.max(3*c,...this.isoValueLabels().map((t=>this.textWidth(t)+c)),this.textWidth(null!==(i=this.config.iso.label)&&void 0!==i?i:"",!0)+c,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${m} ${this.config.iso.unit}`:"")+c):0,b="right"===this.config.legend.position?Math.max(w?g.width+c:0,y):y,j=""!==this.config.chartTitle?1.6*c:0,S=this.axisTitle(this.config.y,m),P=this.axisTitle(this.config.x,m),k=""!==S?1.4*c:.4*c,D=1.4*c+(""!==P?1.3*c:0);let T,N=3*c,z={x:0,y:0,width:0,height:0},E=[];const A=Math.max(1,this.data.facets.length),V=null===(s=this.config.facet)||void 0===s?void 0:s.columns,X=C.domain(null!==(n=null===(e=this.data.extents)||void 0===e?void 0:e.xMin)&&void 0!==n?n:0,null!==(o=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),B=C.domain(null!==(a=null===(r=this.data.extents)||void 0===r?void 0:r.yMin)&&void 0!==a?a:0,null!==(d=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==d?d:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-u.left-u.right-N-b);z={x:u.left+N,y:u.top+j+k,width:t,height:t/this.config.aspect},T=new W(A,V,z,this.styles.scaleFactors.panelGap*c);const i=T.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*c)))),e=new C(B[0],B[1],i,0);E=e.ticks(s);const n=$(E,this.yPercent);N=Math.max(...E.map((t=>this.textWidth(L(t,n,this.styles.locale,this.yPercent)))),c)+this.styles.scaleFactors.axisTickLength*c+.4*c}this.canvasHeight=z.y+z.height+D+("bottom"===this.config.legend.position&&w?g.height+c:0)+u.bottom,""!==this.config.chartTitle&&this.drawText(v,this.config.chartTitle,u.left,u.top+c,{bold:!0}),""!==S&&this.drawAxisTitleText(v,this.config.y,m,u.left,z.y-.6*c,"start");const F=this.buildPanels(T,X,B),I=F[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(F[0].rect.width/(7*c))))),O=$(I,this.xPercent),Y=$(E,this.yPercent);let G=!1;x&&(X[0]>0&&B[0]>0?G=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,F[0],{key:"",points:[]},I,E,O,Y,!0,!0,G):this.data.facets.forEach(((t,i)=>{this.drawPanel(v,F[i],t,I,E,O,Y,T.isOuterLeft(i),T.isOuterBottom(i),G,this.data.facets.length>1?t.key:"")})),""!==P&&this.drawAxisTitleText(v,this.config.x,m,z.x+z.width,z.y+z.height+2.6*c,"end"),w&&("right"===this.config.legend.position?f.draw(v,p,z.x+z.width+c,z.y,"right"):f.draw(v,p,z.x,z.y+z.height+D,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,n,h){var o;const r=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===h?(this.drawText(t,r,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(r,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,r,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,r,e,n,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let n=0;n<t.count;n++){const h=t.panelRect(n),o=new C(i[0],i[1],h.x,h.x+h.width),r=new C(s[0],s[1],h.y+h.height,h.y);e.push({rect:h,xScale:o,yScale:r,frame:new j(o,r,h,this.styles)})}return e}drawPanel(t,i,s,e,n,h,o,r,a,l,d=""){var c,u;const m=t.group(),v=this.em;i.frame.drawBands(m,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(m,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*v?e:void 0),l&&null!==this.config.iso&&this.drawIso(m,i),i.frame.drawRefLines(m,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(m);const f=this.styles.scaleFactors.pointRadius*v,p=new P(i.rect,this.styles.scaleFactors.labelToMark*v),w=[];for(const t of s.points){const e=null!==(u=null===(c=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===c?void 0:c.index)&&void 0!==u?u:0,n=this.seriesTreatment(e),h=i.xScale.scale(t.x),o=i.yScale.scale(t.y);w.push({point:t,cx:h,cy:o,treatment:n});const r=m.circle(2*f).center(h,o).fill(n.fill).stroke({color:n.stroke,width:n.strokeWidth}).attr(g(S(t,s.key,this.config),"element"));void 0!==n.dasharray&&r.attr("stroke-dasharray",n.dasharray),p.registerMark(h,o,f)}this.drawPointLabels(m,p,w,f,s.key),i.frame.drawTickLabels(m,{ticksX:e,ticksY:n,xDecimals:h,yDecimals:o,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:a,showYLabels:r}),""!==d&&i.frame.drawPanelTitle(m,d)}drawPointLabels(t,i,s,e,n){const h=s.reduce(((t,i)=>t+i.cx),0)/Math.max(1,s.length),o=s.reduce(((t,i)=>t+i.cy),0)/Math.max(1,s.length),r=[...s].sort(((t,i)=>Math.hypot(i.cx-h,i.cy-o)-Math.hypot(t.cx-h,t.cy-o))),{selected:a,unknownNames:l}=i.selectCandidates(r,this.config.labels.points,this.config.labels.max,(t=>t.point.name));l.length>0&&this.addWarningOnce("xy-label-unknown",{names:l.join(", ")});const d=new Map,c=a.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:e,width:this.textWidth(t.point.name),height:1.1*this.em};return d.set(i,t.point),i}));for(const s of i.place(c))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(g(S(d.get(s.candidate),n,this.config),"label"))}drawIso(t,i){const s=this.config.iso,e=new A(i.xScale,i.yScale),n=this.i18nMap.get("axis.in")||"in",h=this.isoValues(),o=this.isoValueLabels();if(void 0!==s.highlight){const i=e.regionPath(s.highlight.from);null!==i&&t.path(i).fill(this.styles.axisStyles.pl.fill).stroke("none")}const r={color:this.styles.axisStyles.fc.stroke,width:E(this.styles.scaleFactors.gridLineWidth,this.em)};let a=null;for(const[i,s]of h.entries()){const n=e.path(s);if(null===n)continue;t.path(n).fill("none").stroke(r);const h=e.exitPoint(s);null!==h&&(this.drawText(t,o[i],h.x+.4*this.em,"right"===h.edge?h.y+.35*this.em:h.y-.5*this.em,{}),(null===a||h.y<a.y)&&(a=h))}if(null!==a&&void 0!==s.label&&""!==s.label){const i=void 0!==s.unit&&""!==s.unit?`${n} ${s.unit}`:"";this.drawText(t,s.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==i&&this.drawText(t,i,a.x+.4*this.em,a.y-.5*this.em,{})}}isoValues(){const t=this.config.iso;return"auto"!==t.values?t.values:A.autoK(this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))))}isoValueLabels(){const t=this.isoValues(),i=Math.max(0,...t.map((t=>C.stepDecimals(Math.abs(t)))));return t.map((t=>L(t,i,this.styles.locale)))}}const X=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],B=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",c(this)}getDb(){return this.stores||(this.stores=r(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=a(this.getDb(),this.tableName,this.filter);this.chart=new V(new d(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),m(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of X){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new k(new D,new f,new p(new x),new w).adapt(this.styles);return s.locale=(null===(i=null===(t=r(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return s(e,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(e,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(e,null,s("div",{innerHTML:this.svgMarkup}))}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}'}},[1,"bn-chart-scatter-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],iso:[16],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function F(){"undefined"!=typeof customElements&&["bn-chart-scatter-renderer"].forEach((t=>{"bn-chart-scatter-renderer"===t&&(customElements.get(n(t))||customElements.define(n(t),B))}))}export{B,F as d}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as n}from"./p-CMCnX0iM.js";const t="data-bn-baseline",r=n=>Math.round(100*n)/100;function o(o,a){const i=o.querySelector(`[${t}]`),s=null!=i?i:o.querySelector('g[id="axis"] line');if(!s)return{};const u=n(a);return"frame"===s.getAttribute(t)?function(n,t){const o=t.toLocal(n.getBoundingClientRect());return{x:r(o.x),y:r(o.y+o.height)}}(s,u):function(n,t){const o=t.toLocal(n.getBoundingClientRect());return o.width>=o.height?{x:r(o.x),y:r(o.y+o.height/2)}:{x:r(o.x+o.width/2),y:r(o.y)}}(s,u)}function a(n,t){var r,a,i;const s=null===(i=null===(a=null===(r=n.shadowRoot)||void 0===r?void 0:r.querySelector(t))||void 0===a?void 0:a.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas");return s?o(s,n):{}}function i(t,o){var a;if(!t)return{};const i=n(o),s={},u=t.querySelector("thead");if(u){const n=i.toLocal(u.getBoundingClientRect());s.y=r(n.y+n.height)}const c=n=>n?Array.from(n.children).filter((n=>"tr"===n.localName)):[],e=c(u),l=null!==(a=e[e.length-1])&&void 0!==a?a:c(t.querySelector("tbody"))[0],d=l?Array.from(l.children):[],v=n=>n.classList.contains("category")||n.classList.contains("operation"),f=d.some(v)?d.find((n=>!v(n))):d[1];return f&&(s.x=r(i.toLocal(f.getBoundingClientRect()).x)),s}export{t as B,a,i as b,o as r}
|