@bino-bi/bn-template-engine 1.0.0-next.21 → 1.0.0-next.23
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-28d5c266.entry.js → p-0a49cf00.entry.js} +1 -1
- package/dist/bn-template-engine/{p-b9e94127.entry.js → p-22b8d044.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6c7f0076.entry.js → p-251bb53d.entry.js} +1 -1
- package/dist/bn-template-engine/p-2aed639e.entry.js +1 -0
- package/dist/bn-template-engine/{p-7e9dbc93.entry.js → p-4616b879.entry.js} +1 -1
- package/dist/bn-template-engine/{p-99477a27.entry.js → p-629edcca.entry.js} +1 -1
- package/dist/bn-template-engine/p-686d8e44.entry.js +1 -0
- package/dist/bn-template-engine/{p-a4ea9a79.entry.js → p-68aa61cc.entry.js} +1 -1
- package/dist/bn-template-engine/{p-DwYUTvvI.js → p-B5x8M8OC.js} +1 -1
- package/dist/bn-template-engine/{p-fFtEvsY-.js → p-BGrnfif3.js} +1 -1
- package/dist/bn-template-engine/{p-6lOdN-fB.js → p-BVfLus3u.js} +1 -1
- package/dist/bn-template-engine/{p-CJThzFZm.js → p-BcZ5GQZ8.js} +1 -1
- package/dist/bn-template-engine/{p-CYE0I1Mx.js → p-Bca5V28_.js} +1 -1
- package/dist/bn-template-engine/p-C5UYpZUU.js +2 -0
- package/dist/bn-template-engine/{p-BgIpdpfH.js → p-C7T4DAAW.js} +1 -1
- package/dist/bn-template-engine/p-CDo04UEU.js +1 -0
- package/dist/bn-template-engine/p-CTrNbSXN.js +1 -0
- package/dist/bn-template-engine/{p-C5uvAEKI.js → p-CbciPY-M.js} +1 -1
- package/dist/bn-template-engine/{p-BpWWgN6k.js → p-CuR4S456.js} +1 -1
- package/dist/bn-template-engine/p-DWtTjg0f.js +1 -0
- package/dist/bn-template-engine/{p-eEfqksk-.js → p-DdqXNsKP.js} +1 -1
- package/dist/bn-template-engine/{p-B4JfKvVT.js → p-DtLI_CzV.js} +1 -1
- package/dist/bn-template-engine/p-UtNHLX1j.js +1 -0
- package/dist/bn-template-engine/{p-ba912130.entry.js → p-aecb5de3.entry.js} +1 -1
- package/dist/bn-template-engine/{p-687032d5.entry.js → p-ba43d46e.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6077155f.entry.js → p-c476e7bb.entry.js} +1 -1
- package/dist/bn-template-engine/{p-2d3ea756.entry.js → p-d7c670ec.entry.js} +1 -1
- package/dist/bn-template-engine/{p-a1380d7c.entry.js → p-e4a584a8.entry.js} +1 -1
- package/dist/bn-template-engine/{p-de29986f.entry.js → p-f12fb09b.entry.js} +1 -1
- package/dist/bn-template-engine/p-f9a721bb.entry.js +1 -0
- package/dist/cjs/{AxisConfig-D7CAyPLO.js → AxisConfig-DmP4U3JM.js} +1 -1
- package/dist/cjs/{LabelCollisionManager-DkdQ9Xdg.js → LabelCollisionManager-Cet3WPm0.js} +2 -2
- package/dist/cjs/{Order-IPfAP0q8.js → Order-DlKLywO_.js} +1 -1
- package/dist/cjs/{SVGStyle-BD8jApd4.js → SVGStyle-D78RaNnj.js} +2 -2
- package/dist/cjs/{SVGVariancesStyleGroup-BaWzR951.js → SVGVariancesStyleGroup-XvNAnYYA.js} +1 -1
- package/dist/cjs/{VarianceMeasure-BBWTgv2e.js → VarianceMeasure-BfZLlICl.js} +4 -4
- package/dist/cjs/{XYChartDataRow-BoR0CTfl.js → XYChartDataRow-B0NNOqxB.js} +4 -4
- package/dist/cjs/bn-asset_21.cjs.entry.js +1052 -314
- package/dist/cjs/bn-chart-bubble.cjs.entry.js +25 -15
- package/dist/cjs/bn-chart-bullet.cjs.entry.js +9 -9
- package/dist/cjs/bn-chart-scatter.cjs.entry.js +9 -9
- package/dist/cjs/bn-grid.cjs.entry.js +6 -6
- package/dist/cjs/bn-image.cjs.entry.js +6 -6
- package/dist/cjs/bn-internationalization.cjs.entry.js +4 -4
- package/dist/cjs/bn-ruleset.cjs.entry.js +4 -4
- package/dist/cjs/bn-template-engine.cjs.js +3 -3
- package/dist/cjs/bn-template.cjs.entry.js +2 -2
- package/dist/cjs/bn-text.cjs.entry.js +7 -7
- package/dist/cjs/bn-tree.cjs.entry.js +6 -6
- package/dist/cjs/{context-protocol-BBhT9B52.js → context-protocol-DeLmu5s2.js} +1 -1
- package/dist/cjs/editor-companion.cjs.entry.js +2 -2
- package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +6 -6
- package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +6 -6
- package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +6 -6
- package/dist/cjs/{index-CDKG4xmO.js → index-C1Z9vO7z.js} +61 -19
- package/dist/cjs/{layoutObserver-DUYYkDMQ.js → layoutObserver-CrzQQGpv.js} +5 -5
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{scaling-BIJQ2NV1.js → scaling-JAU6IJnR.js} +85 -3
- package/dist/cjs/{withBodyObserver-BKUE_ypL.js → withBodyObserver-DJO98AJ-.js} +2 -2
- package/dist/cjs/{withHasError-Cl2gTQzA.js → withHasError-BdDmiOXM.js} +1 -1
- package/dist/cjs/{withScalingGroup-D5clRvRe.js → withScalingGroup-Bu5gatHT.js} +3 -3
- package/dist/cjs/{withStyled-Cm9dWQhu.js → withStyled-50UepUwV.js} +8 -8
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +15 -5
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +6 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +149 -57
- package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +135 -28
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +30 -19
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +186 -49
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +9 -3
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +141 -22
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +36 -0
- package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +76 -19
- package/dist/collection/components/bn-table/bn-table.js +121 -49
- package/dist/collection/components/bn-table/ibcs-table.js +83 -42
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +20 -34
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -5
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +89 -0
- package/dist/collection/utils/autoFit.js +63 -0
- package/dist/collection/utils/constants.js +3 -3
- package/dist/collection/utils/dataAnalyzer.js +17 -8
- package/dist/collection/utils/scaling.js +79 -0
- package/dist/collection/utils/validate.js +3 -3
- package/dist/components/DataFormatDigits.js +1 -1
- package/dist/components/autoFit.js +1 -0
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet.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-grid.js +1 -1
- package/dist/components/bn-scaling-group.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/ibcs-chart-structure2.js +1 -1
- package/dist/components/ibcs-chart-time2.js +1 -1
- package/dist/components/ibcs-table2.js +1 -1
- package/dist/components/scaling.js +1 -0
- package/dist/components/validate.js +1 -1
- package/dist/components/withDataset.js +1 -1
- package/dist/components/withStyled.js +1 -1
- package/dist/esm/{AxisConfig-ByIP5J-9.js → AxisConfig-Cjy_RANi.js} +1 -1
- package/dist/esm/{LabelCollisionManager-DaNiDiM9.js → LabelCollisionManager-B_NUM9yq.js} +2 -2
- package/dist/esm/{Order-BQeJE_yi.js → Order-B-aF6Rwn.js} +1 -1
- package/dist/esm/{SVGStyle-BwBlY3Km.js → SVGStyle-8FfAtUF-.js} +2 -2
- package/dist/esm/{SVGVariancesStyleGroup-BpGW4CvN.js → SVGVariancesStyleGroup-DD4mIOjT.js} +1 -1
- package/dist/esm/{VarianceMeasure-CE3N8Bea.js → VarianceMeasure-DLOuIIJ7.js} +4 -4
- package/dist/esm/{XYChartDataRow-DeMI1JKU.js → XYChartDataRow-CKfILBFG.js} +4 -4
- package/dist/esm/bn-asset_21.entry.js +1052 -314
- package/dist/esm/bn-chart-bubble.entry.js +25 -15
- package/dist/esm/bn-chart-bullet.entry.js +9 -9
- package/dist/esm/bn-chart-scatter.entry.js +9 -9
- package/dist/esm/bn-grid.entry.js +6 -6
- package/dist/esm/bn-image.entry.js +6 -6
- package/dist/esm/bn-internationalization.entry.js +4 -4
- package/dist/esm/bn-ruleset.entry.js +4 -4
- package/dist/esm/bn-template-engine.js +4 -4
- package/dist/esm/bn-template.entry.js +2 -2
- package/dist/esm/bn-text.entry.js +7 -7
- package/dist/esm/bn-tree.entry.js +6 -6
- package/dist/esm/{context-protocol-d8MHrEo8.js → context-protocol-BoEL0caI.js} +1 -1
- package/dist/esm/editor-companion.entry.js +2 -2
- package/dist/esm/ibcs-chart-bubble.entry.js +6 -6
- package/dist/esm/ibcs-chart-bullet.entry.js +6 -6
- package/dist/esm/ibcs-chart-scatter.entry.js +6 -6
- package/dist/esm/{index-B_d-jp99.js → index-C5UYpZUU.js} +61 -19
- package/dist/esm/{layoutObserver-BJBEyhNf.js → layoutObserver-cgIXg2sg.js} +5 -5
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{scaling-BGnpSN1j.js → scaling-CxyNpMQM.js} +83 -4
- package/dist/esm/{withBodyObserver-IokS6fHD.js → withBodyObserver-Cb9ZC5_J.js} +2 -2
- package/dist/esm/{withHasError-DW_vMDUp.js → withHasError-Bh1Viz52.js} +1 -1
- package/dist/esm/{withScalingGroup-CC3UcvC5.js → withScalingGroup-Yv9nGGe1.js} +3 -3
- package/dist/esm/{withStyled-2l5Tx3cf.js → withStyled-By9Jd-Oy.js} +8 -8
- package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +5 -2
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +47 -19
- package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +17 -3
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +11 -3
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +52 -18
- package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +18 -3
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +12 -0
- package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +28 -8
- package/dist/types/components/bn-table/bn-table.d.ts +45 -19
- package/dist/types/components/bn-table/ibcs-table.d.ts +23 -6
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +9 -1
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +51 -0
- package/dist/types/components.d.ts +91 -55
- package/dist/types/stencil-public-runtime.d.ts +1 -0
- package/dist/types/utils/autoFit.d.ts +79 -0
- package/dist/types/utils/constants.d.ts +3 -3
- package/dist/types/utils/dataAnalyzer.d.ts +5 -1
- package/dist/types/utils/scaling.d.ts +63 -0
- package/dist/types/utils/validate.d.ts +2 -2
- package/package.json +1 -1
- package/readme.md +2 -0
- package/dist/bn-template-engine/p-2fba7c99.entry.js +0 -1
- package/dist/bn-template-engine/p-A8xyE4b1.js +0 -1
- package/dist/bn-template-engine/p-B_d-jp99.js +0 -2
- package/dist/bn-template-engine/p-BjBz5cSL.js +0 -1
- package/dist/bn-template-engine/p-C8Q0lsaU.js +0 -1
- package/dist/bn-template-engine/p-C9i1Xsib.js +0 -1
- package/dist/bn-template-engine/p-a8291de2.entry.js +0 -1
- package/dist/bn-template-engine/p-b5274369.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as i,writeTask as e,h as a,Host as s,transformTag as r,forceUpdate as n}from"@stencil/core/internal/client";import{v as o,a as l,i as h,q as d,r as u,k as p,s as c,m as v,t as m,h as g,u as y,w as b,b as f,c as w,x as S,n as O,y as R,z as T,f as D,A as _,B as E}from"./validate.js";import{w as C,g as M,p as F}from"./withDataset.js";import{w as A,a as N}from"./withHasError.js";import{w as G}from"./withScalingGroup.js";import{a as W}from"./context-protocol.js";import{w as U,a as P,i as j}from"./withTranslation.js";import{w as I}from"./withStyled.js";import{w as x}from"./withComponentStyle.js";import{w as L}from"./withRuleSet.js";import{o as k}from"./layoutObserver.js";import{D as B,I as J,d as V,M as z,B as $,T as q}from"./CompareUtil.js";import{a as H,b as Y,T as Z,d as K}from"./ibcs-table2.js";import{O as Q,a as X}from"./Order.js";const tt=t(class extends i{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling=.01,this.percentageScaling=.5,this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped="false",this.showMeasureScale="false",this.showGroupTitle="true",this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,I(this),A(this),this.errors=N(this),G(this),this.componentStyle=x(this),this.ruleSetConfig=L(this),C(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return h(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=U(this).t,this.resolveInherited=P(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}validateScenario(t){const i="ERR_scenarios";if(j(t))return void this.errors.remove(i);const e=o(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(j(t))return void this.errors.remove(i);const e=l(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="ERR_barColumns";if(h(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="ERR_barColumnWidth";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"auto"===(null==t?void 0:(""+t).trim().toLowerCase())||p(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";"auto"===(null==t?void 0:(""+t).trim().toLowerCase())||p(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."})}validateDataFormat(t){const i="ERR_dataFormat";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateGrouped(t){const i="ERR_grouped";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"grouped: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateShowGroupTitle(t){const i="ERR_showGroupTitle";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showGroupTitle: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="ERR_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="ERR_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="ERR_thereof",e=y(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="ERR_partof",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="ERR_order";if(j(t))return void this.errors.remove(i);const e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";j(t)||w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="ERR_measureType";S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="ERR_measureScale";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="ERR_dataFormatDigitsDecimal";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="ERR_dataFormatDigitsPercent";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="ERR_categoryWidth";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=T(t),e="ERR_categorythereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="ERR_interval",e=null==t?void 0:t.trim().toLowerCase();h(t)||e===H||e===Y||D(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="ERR_attributes",e=_(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateGrouped(this.grouped),this.validateShowGroupTitle(this.showGroupTitle),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateShowMeasureScale(this.showMeasureScale),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=k(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=M(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){const{mode:t}=F(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:a}=M(i);if(a<=0)return;this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled table by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o})))}prepareDataFormat(){var t;return B[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return"true"===this.grouped}prepareShowGroupTitle(){return"true"===this.showGroupTitle}prepareTableType(){var t;return Z[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){return null==this.thereof||""===this.thereof.trim()?[]:JSON.parse(this.thereof)}preparePartOf(){return null==this.partof||""===this.partof.trim()?[]:JSON.parse(this.partof)}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=this.resolveInherited("orderDirection",this.orderDirection),a=null!=i?i:this.order,s=null!=e?e:this.orderDirection,r="auto"===(null==a?void 0:a.trim().toLowerCase());let n=a;return r&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(n=this.datasetMeta.suggestedOrder),{hierarchy:n.split(",").map((t=>X[null==t?void 0:t.toUpperCase()])),direction:Q[null==s?void 0:s.toUpperCase()]}}prepareI18nMode(){return J.META}prepareI18n(){const t=W,i=new Map(["in","category","operation","there_of","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries()])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l;const d=this.resolveInherited("scenarios",this.scenarios),u=this.resolveInherited("variances",this.variances);if(void 0!==d||void 0!==u){this.errors.remove("AUTO_scenarios");let i=[];return void 0!==d?i=i.concat(d.split(",")):h(this.scenarios)||(i=i.concat(this.scenarios.split(","))),void 0!==u?i=i.concat(u.split(",")):(null===(t=this.variances)||void 0===t?void 0:t.trim().length)>0&&(i=i.concat(this.variances.split(","))),i.map((t=>t.trim()))}const p="auto"===(null===(i=this.scenarios)||void 0===i?void 0:i.trim().toLowerCase());if((h(this.scenarios)||p)&&h(this.variances))return(null===(a=null===(e=this.datasetMeta)||void 0===e?void 0:e.availableScenarios)||void 0===a?void 0:a.length)>0?(p?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[];let c=[];return p||h(this.scenarios)?(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0&&(p?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),c=c.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),c=c.concat(null===(n=this.scenarios)||void 0===n?void 0:n.split(","))),(null===(o=this.variances)||void 0===o?void 0:o.trim().length)>0&&(c=c.concat(null===(l=this.variances)||void 0===l?void 0:l.split(","))),c.map((t=>t.trim()))}prepareCategoryWidth(){var t;return h(this.categoryWidth)?V.INF:V[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return h(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return h(this.measureType)?z.VOLUME:z[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=JSON.parse(this.columnthereof),i=new Map;for(const[e,a]of Object.entries(t))!1===i.has(a.scenario)&&i.set(a.scenario,[]),i.get(a.scenario).push(a);return i}prepareInterval(){var t;const i="ERR_intervalConflict",e="ERR_intervalNoDate",a="ERR_intervalSetname",s=h(this.interval)?H:this.interval.trim().toLowerCase();return s!==H&&s!==Y&&!D(s)||s===H?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),H):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(e),this.errors.remove(a),H):(this.errors.remove(i),s===Y?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '—'."}):this.errors.remove(a),this.errors.remove(e),Y):(this.errors.remove(a),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),H):(this.errors.remove(e),s)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],e)=>"string"==typeof i?E(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),e=q[i];return e?$[e]:$[q.W10]}prepareBarColumns(){return h(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){var t;return this.pixelPerUnitGroupMap.has(this.unitScaling)?this.pixelPerUnitGroupMap.get(this.unitScaling):"auto"===(null===(t=this.unitScaling)||void 0===t?void 0:(""+t).trim().toLowerCase())?0:Number(this.unitScaling)}preparePercentageScaling(){var t;return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):"auto"===(null===(t=this.percentageScaling)||void 0===t?void 0:(""+t).trim().toLowerCase())?0:Number(this.percentageScaling)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}getEffectiveScaleFactor(){const{mode:t,factor:i}=F(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"71fe0e81888c25970edcaab0803cbdbd3b73d1fd",style:t},a("div",{key:"5afa87ac3a8b4d5864bb34acb8a4e84de12261ea"},a("ibcs-table",{key:"8a276ca87e342f8c3b3aac76c9915681c4b2a005",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}static get style(){return":host{display:inline-block;position:relative;overflow:hidden}"}},[1,"bn-table",{scale:[1],ruleset:[513],selectedStyle:[1,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[1],showMeasureScale:[1,"show-measure-scale"],showGroupTitle:[1,"show-group-title"],type:[1],limit:[2],thereof:[1],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32]},void 0,{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}]),it=tt,et=function(){"undefined"!=typeof customElements&&["bn-table","ibcs-table"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),tt);break;case"ibcs-table":customElements.get(r(t))||K()}}))};export{it as BnTable,et as defineCustomElement}
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as i,writeTask as e,h as a,Host as s,transformTag as r,forceUpdate as n}from"@stencil/core/internal/client";import{v as o,a as l,i as h,q as d,r as p,s as u,l as c,t as v,h as m,u as g,w as y,b as f,c as b,x as S,m as w,y as O,z as T,f as R,A as D,B as _}from"./validate.js";import{w as E,g as A}from"./withDataset.js";import{w as M,a as C}from"./withHasError.js";import{w as F}from"./withScalingGroup.js";import{a as U}from"./context-protocol.js";import{w as G,a as N,i as W}from"./withTranslation.js";import{w as P}from"./withStyled.js";import{w as j}from"./withComponentStyle.js";import{w as I}from"./withRuleSet.js";import{f as x,r as L,p as B}from"./scaling.js";import{o as J}from"./layoutObserver.js";import{D as k,I as $,d as V,M as z,B as q,T as H}from"./CompareUtil.js";import{a as Y,b as Z,T as K,d as Q}from"./ibcs-table2.js";import{O as X,a as tt}from"./Order.js";const it=t(class extends i{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped="false",this.showMeasureScale="false",this.showGroupTitle="true",this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{const i=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const e=1/t.unit;i(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" — auto-fitted to 1 em ≈ ${x(e)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const e=1/t.percentage;i(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" — auto-fitted to 1 em ≈ ${x(e)} percentage points.`}))}},P(this),M(this),this.errors=C(this),F(this),this.componentStyle=j(this),this.ruleSetConfig=I(this),E(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return h(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=G(this).t,this.resolveInherited=N(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}validateScenario(t){const i="ERR_scenarios";if(W(t))return void this.errors.remove(i);const e=o(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(W(t))return void this.errors.remove(i);const e=l(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="ERR_barColumns";if(h(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="ERR_barColumnWidth";p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===L(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===L(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="ERR_dataFormat";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateGrouped(t){const i="ERR_grouped";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"grouped: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateShowGroupTitle(t){const i="ERR_showGroupTitle";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showGroupTitle: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="ERR_type";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="ERR_limit";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="ERR_thereof",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="ERR_partof",e=y(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="ERR_order";if(W(t))return void this.errors.remove(i);const e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";W(t)||b(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="ERR_measureType";S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="ERR_measureScale";w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="ERR_dataFormatDigitsDecimal";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="ERR_dataFormatDigitsPercent";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="ERR_categoryWidth";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=T(t),e="ERR_categorythereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="ERR_interval",e=null==t?void 0:t.trim().toLowerCase();h(t)||e===Y||e===Z||R(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="ERR_attributes",e=D(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateGrouped(this.grouped),this.validateShowGroupTitle(this.showGroupTitle),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateShowMeasureScale(this.showMeasureScale),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=J(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=A(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){const{mode:t}=B(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:a}=A(i);if(a<=0)return;this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled table by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o})))}prepareDataFormat(){var t;return k[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return"true"===this.grouped}prepareShowGroupTitle(){return"true"===this.showGroupTitle}prepareTableType(){var t;return K[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){return null==this.thereof||""===this.thereof.trim()?[]:JSON.parse(this.thereof)}preparePartOf(){return null==this.partof||""===this.partof.trim()?[]:JSON.parse(this.partof)}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=this.resolveInherited("orderDirection",this.orderDirection),a=null!=i?i:this.order,s=null!=e?e:this.orderDirection,r="auto"===(null==a?void 0:a.trim().toLowerCase());let n=a;return r&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(n=this.datasetMeta.suggestedOrder),{hierarchy:n.split(",").map((t=>tt[null==t?void 0:t.toUpperCase()])),direction:X[null==s?void 0:s.toUpperCase()]}}prepareI18nMode(){return $.META}prepareI18n(){const t=U,i=new Map(["in","category","operation","there_of","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries()])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l;const d=this.resolveInherited("scenarios",this.scenarios),p=this.resolveInherited("variances",this.variances);if(void 0!==d||void 0!==p){this.errors.remove("AUTO_scenarios");let i=[];return void 0!==d?i=i.concat(d.split(",")):h(this.scenarios)||(i=i.concat(this.scenarios.split(","))),void 0!==p?i=i.concat(p.split(",")):(null===(t=this.variances)||void 0===t?void 0:t.trim().length)>0&&(i=i.concat(this.variances.split(","))),i.map((t=>t.trim()))}const u="auto"===(null===(i=this.scenarios)||void 0===i?void 0:i.trim().toLowerCase());if((h(this.scenarios)||u)&&h(this.variances))return(null===(a=null===(e=this.datasetMeta)||void 0===e?void 0:e.availableScenarios)||void 0===a?void 0:a.length)>0?(u?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[];let c=[];return u||h(this.scenarios)?(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0&&(u?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),c=c.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),c=c.concat(null===(n=this.scenarios)||void 0===n?void 0:n.split(","))),(null===(o=this.variances)||void 0===o?void 0:o.trim().length)>0&&(c=c.concat(null===(l=this.variances)||void 0===l?void 0:l.split(","))),c.map((t=>t.trim()))}prepareCategoryWidth(){var t;return h(this.categoryWidth)?V.INF:V[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return h(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return h(this.measureType)?z.VOLUME:z[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=JSON.parse(this.columnthereof),i=new Map;for(const[e,a]of Object.entries(t))!1===i.has(a.scenario)&&i.set(a.scenario,[]),i.get(a.scenario).push(a);return i}prepareInterval(){var t;const i="ERR_intervalConflict",e="ERR_intervalNoDate",a="ERR_intervalSetname",s=h(this.interval)?Y:this.interval.trim().toLowerCase();return s!==Y&&s!==Z&&!R(s)||s===Y?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),Y):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(e),this.errors.remove(a),Y):(this.errors.remove(i),s===Z?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '—'."}):this.errors.remove(a),this.errors.remove(e),Z):(this.errors.remove(a),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),Y):(this.errors.remove(e),s)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],e)=>"string"==typeof i?_(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),e=H[i];return e?q[e]:q[H.W10]}prepareBarColumns(){return h(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=L(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" — auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=L(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" — auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}getEffectiveScaleFactor(){const{mode:t,factor:i}=B(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"7960f554ac93c0fb6a09cf47f886827fff1aea84",style:t},a("div",{key:"e9f328144ab89bbde8c47111f7ce7de7a6c882db"},a("ibcs-table",{key:"a06695fad28dc30967784006c151abd47d2efd77",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}static get style(){return":host{display:inline-block;position:relative;overflow:hidden}"}},[1,"bn-table",{scale:[1],ruleset:[513],selectedStyle:[1,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[1],showMeasureScale:[1,"show-measure-scale"],showGroupTitle:[1,"show-group-title"],type:[1],limit:[2],thereof:[1],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32]},void 0,{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}]),et=it,at=function(){"undefined"!=typeof customElements&&["bn-table","ibcs-table"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),it);break;case"ibcs-table":customElements.get(r(t))||Q()}}))};export{et as BnTable,at as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as e,h as i,Host as o,transformTag as n}from"@stencil/core/internal/client";import{w as s,g as a
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as e,h as i,Host as o,transformTag as n}from"@stencil/core/internal/client";import{w as s,g as a}from"./withDataset.js";import{w as l}from"./withTranslation.js";import{w as r,a as d}from"./withHasError.js";import{w as c}from"./withStyled.js";import{w as f}from"./withComponentStyle.js";import{p as v}from"./scaling.js";import{s as u}from"./sanitizeHtml.js";const h=/\b(__proto__|globalThis)\b|\.constructor\b/,m=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.data={},c(this),r(this),this.errors=d(this),this.t=l(this).t,s(this,((t,e)=>{this.data=Object.assign(Object.assign({},this.data),{[t]:e})})),this.componentStyle=f(this)}validateValue(t){"string"!=typeof t||""===t?this.errors.addOrReplace({id:"no_value",type:"warning",message:"Empty value"}):this.errors.remove("no_value")}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const e=Number(t);isNaN(e)||e<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}componentWillLoad(){this.validateValue(this.value),this.validateScaling(this.scale)}evalTemplate(t){if(!t)return"";if(h.test(t))return this.errors.addOrReplace({id:"ERR_value_eval",type:"error",message:"Template contains forbidden pattern"}),"";try{const e=new Proxy({data:this.data,t:this.t},{has:()=>!0,get:(t,e)=>e===Symbol.unscopables?void 0:t[e],set:()=>!0}),i=Function("sandbox","with(sandbox){try{return`"+t+'`}catch(e){return""}}').call(e,e);return this.errors.remove("ERR_value_eval"),null!=i?i+"":""}catch(t){return this.errors.addOrReplace({id:"ERR_value_eval",type:"error",message:"Template evaluation failed: "+(t instanceof Error?t.message:t+"")}),""}}prepareStyle(){return this.componentStyle((t=>{var e,i,o,n,s,a,l,r,d,c,f,v,u,h,m,p,b,g,y,w,_,R;return{fontStyles:{font:`${null!==(n=null!==(i=null===(e=t["bn-text"])||void 0===e?void 0:e.fontSizePx)&&void 0!==i?i:null===(o=t.global)||void 0===o?void 0:o.fontSizePx)&&void 0!==n?n:13.3333}px ${null!==(r=null!==(a=null===(s=t["bn-text"])||void 0===s?void 0:s.fontFamily)&&void 0!==a?a:null===(l=t.global)||void 0===l?void 0:l.fontFamily)&&void 0!==r?r:"'Noto Sans', sans-serif"}`,size:null!==(v=null!==(c=null===(d=t["bn-text"])||void 0===d?void 0:d.fontSizePx)&&void 0!==c?c:null===(f=t.global)||void 0===f?void 0:f.fontSizePx)&&void 0!==v?v:13.3333,color:null!==(p=null!==(h=null===(u=t["bn-text"])||void 0===u?void 0:u.fontColor)&&void 0!==h?h:null===(m=t.global)||void 0===m?void 0:m.fontColor)&&void 0!==p?p:"#000000",background:null!==(w=null!==(g=null===(b=t["bn-text"])||void 0===b?void 0:b.fontBackgroundColor)&&void 0!==g?g:null===(y=t.global)||void 0===y?void 0:y.fontBackgroundColor)&&void 0!==w?w:"#ffffff",leading:null!==(R=null===(_=t["bn-text"])||void 0===_?void 0:_.leading)&&void 0!==R?R:1.8}}}))}applyScaling(t){const e=this.element,{mode:i,factor:o}=v(this.scale),{width:n,height:s}=a(e),l=e.scrollHeight>e.clientHeight+1?e.clientHeight:s,r=n,d=r>0&&e.scrollWidth>r+1,c=l>0&&e.scrollHeight>l+1,f=d||c;if(r<=0&&l<=0)return;if("none"===i){if(f){const t=[];d&&t.push(`w:${e.scrollWidth}>${Math.round(r)}`),c&&t.push(`h:${e.scrollHeight}>${Math.round(l)}`),this.errors.addOrReplace({id:"WARN_overflow",type:"warning",message:`Content overflows container (${t.join(", ")})`})}else this.errors.remove("WARN_overflow");return}if("factor"===i){if(f){const t=[];d&&t.push(`w:${e.scrollWidth}>${Math.round(r)}`),c&&t.push(`h:${e.scrollHeight}>${Math.round(l)}`),this.errors.addOrReplace({id:"WARN_overflow",type:"warning",message:`Content overflows with factor ${o} (${t.join(", ")})`})}else this.errors.remove("WARN_overflow");return}e.style.setProperty("--bn-font-size",t+"px");const u=e.scrollWidth,h=e.scrollHeight,m=e.clientHeight,p=h>m+1?m:s,b=r<=0||u<=r+1,g=p<=0||h<=p+1;if(b&&g)return void this.errors.remove("AUTO_scale");const y=Math.min(1,!b&&r>0?r/u:1,!g&&p>0?p/h:1);e.style.setProperty("--bn-font-size",t*y+"px"),"empty"===i?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled font by factor "+y.toFixed(3)}):this.errors.remove("AUTO_scale")}componentDidRender(){this.container.innerHTML=u(this.evalTemplate(this.value)),this.applyScaling(this.prepareStyle().fontStyles.size)}render(){const{fontStyles:t}=this.prepareStyle(),{mode:e,factor:n}=v(this.scale),s="factor"===e?t.size*n+"px":t.size+"px",a={"--bn-font-family":t.font.substring(t.font.indexOf("px ")+3),"--bn-font-size":s,"--bn-font-color":t.color,"--bn-font-background":t.background};return i(o,{key:"b5516777bb29ddddf3fb43ff518fdc383c86a812",style:a},i("div",{key:"dc325b0679f0a151ac60d32cae70f2a2f14ae205"},i("span",{key:"fcdc9c6cb9224428e7b47df3ac10336bcdffb260",class:"container",ref:t=>{this.container=t}})))}get element(){return this}static get watchers(){return{value:[{validateValue:0}],scale:[{validateScaling:0}]}}static get style(){return':host{padding:0.5em;display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000);background-color:var(--bn-font-background, white)}span.container p{margin:0}'}},[1,"bn-text",{value:[1],scale:[1],data:[32]},void 0,{value:[{validateValue:0}],scale:[{validateScaling:0}]}]),p=m,b=function(){"undefined"!=typeof customElements&&["bn-text"].forEach((t=>{"bn-text"===t&&(customElements.get(n(t))||customElements.define(n(t),m))}))};export{p as BnText,b as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as e,h as n,Host as s,transformTag as i}from"@stencil/core/internal/client";import{k as r,m as o}from"./validate.js";import{w as a,a as l}from"./withHasError.js";import{w as c}from"./withStyled.js";import{w as d}from"./withComponentStyle.js";const u=["*","/","+","-","x","÷","none"];function h(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function f(t,e,n){return t.find((t=>t.from===e&&t.to===n))}function p(t){return 2*(t-1)+1}function g(t){return 2*(t-1)+1}function v(t){return t<=1?1:2*(t-1)+1}function y(t,e){const n=t.getBoundingClientRect(),s=n.left-e.left,i=n.top-e.top;return{left:s,top:i,width:n.width,height:n.height,centerX:s+n.width/2,centerY:i+n.height/2}}function m(t,e,n){switch(n){case"ltr":return e?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return e?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return e?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return e?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function b(t,e,n,s,i=8){const r=-(s-1)*i/2+n*i;switch(e){case"ltr":return{x:t.left,y:t.centerY+r};case"rtl":return{x:t.left+t.width,y:t.centerY+r};case"ttb":return{x:t.centerX+r,y:t.top};case"btt":return{x:t.centerX+r,y:t.top+t.height}}}function w(t,e,n,s){switch(n){case"straight":return function(t,e){return{path:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,midpoint:{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}}(t,e);case"curved":return function(t,e,n){let s,i;if("ltr"===n||"rtl"===n){const n=(t.x+e.x)/2;s={x:n,y:t.y},i={x:n,y:e.y}}else{const n=(t.y+e.y)/2;s={x:t.x,y:n},i={x:e.x,y:n}}return{path:`M ${t.x} ${t.y} C ${s.x} ${s.y}, ${i.x} ${i.y}, ${e.x} ${e.y}`,midpoint:{x:.125*t.x+.375*s.x+.375*i.x+.125*e.x,y:.125*t.y+.375*s.y+.375*i.y+.125*e.y}}}(t,e,s);default:return function(t,e,n){let s,i;if("ltr"===n||"rtl"===n){const n=t.x+.7*(e.x-t.x);s=`M ${t.x} ${t.y} L ${n} ${t.y} L ${n} ${e.y} L ${e.x} ${e.y}`,i={x:n,y:(t.y+e.y)/2}}else{const n=t.y+.7*(e.y-t.y);s=`M ${t.x} ${t.y} L ${t.x} ${n} L ${e.x} ${n} L ${e.x} ${e.y}`,i={x:(t.x+e.x)/2,y:n}}return{path:s,midpoint:i}}(t,e,s)}}function x(t,e,n,s){const i=.7;switch(s){case"ltr":{const s=t.left+t.width;return{x:s+(Math.min(e.left,n.left)-s)*i,y:t.centerY}}case"rtl":{const s=t.left,r=Math.max(e.left+e.width,n.left+n.width);return{x:r+(s-r)*i,y:t.centerY}}case"ttb":{const s=t.top+t.height;return{x:t.centerX,y:s+(Math.min(e.top,n.top)-s)*i}}case"btt":{const s=t.top,r=Math.max(e.top+e.height,n.top+n.height);return{x:t.centerX,y:r+(s-r)*i}}}}function $(t,e,n){var s,i;return Object.assign({stroke:null!==(s=null==n?void 0:n.color)&&void 0!==s?s:t,strokeWidth:null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e},(null==n?void 0:n.dasharray)?{strokeDasharray:n.dasharray}:{})}const S=t(class extends e{validateEdgesProp(t){const e="ERR_edges",n=function(t){const e=[];if(!t||""===t.trim())return e.push("edges: value is required"),e;let n;try{n=JSON.parse(t)}catch(t){return e.push("edges: invalid JSON structure"),e}if(!Array.isArray(n))return e.push("edges: must be an array"),e;if(0===n.length)return e.push("edges: array must not be empty"),e;const s=new Set,i=new Set;n.forEach(((t,n)=>{if("object"!=typeof t||null===t)return void e.push(`edges[${n}]: must be an object`);const r=t;if("string"!=typeof r.from||""===r.from.trim()?e.push(`edges[${n}]: 'from' is required and must be a non-empty string`):s.add(r.from),"string"!=typeof r.to||""===r.to.trim()?e.push(`edges[${n}]: 'to' is required and must be a non-empty string`):(s.add(r.to),i.add(r.to)),void 0!==r.operator&&("string"==typeof r.operator&&u.includes(r.operator)||e.push(`edges[${n}]: 'operator' must be one of: ${u.join(", ")}`)),void 0!==r.label&&"string"!=typeof r.label&&e.push(`edges[${n}]: 'label' must be a string`),void 0!==r.style)if("object"!=typeof r.style||null===r.style)e.push(`edges[${n}]: 'style' must be an object`);else{const t=r.style;void 0!==t.color&&"string"!=typeof t.color&&e.push(`edges[${n}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&e.push(`edges[${n}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&e.push(`edges[${n}]: 'style.dasharray' must be a string`)}}));const r=Array.from(s).filter((t=>!i.has(t)));return 0===r.length?e.push("edges: tree has no root node (circular reference detected)"):r.length>1&&e.push("edges: tree has multiple root nodes: "+r.join(", ")),e}(t);n.length>0?(this.errors.addOrReplace({id:e,type:"error",message:"edges: "+n.join("; ")}),this.treeConfig=null):(this.errors.remove(e),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const e=JSON.parse(t);if(!Array.isArray(e))return null;const n=e,s=function(t){const e=new Map;for(const n of t){const t=e.get(n.from)||[];t.push(n.to),e.set(n.from,t)}return e}(n),i=function(t){const e=new Set;for(const n of t)e.add(n.from),e.add(n.to);return e}(n),r=function(t,e){const n=new Set;for(const e of t)n.add(e.to);const s=Array.from(e).filter((t=>!n.has(t)));return 1===s.length?s[0]:null}(n,i);return{edges:n,adjacencyList:s,rootNode:r,allNodes:i}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const e="ERR_direction",n=["ltr","rtl","ttb","btt"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`direction: invalid value '${t}', must be one of: ${n.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const e="ERR_levelSpacing";!r(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateNodeSpacing(t){const e="ERR_nodeSpacing";!r(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateEdgeStyle(t){const e="ERR_edgeStyle",n=["straight","orthogonal","curved"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${n.join(", ")}`})}validateShowOperators(t){const e="ERR_showOperators";o(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`show-operators: invalid value '${t}', must be 'true' or 'false'`})}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.treeConfig=null,this.layout=null,this.nodeRects=new Map,this.svgWidth=0,this.svgHeight=0,this.resizeObserver=null,this.gridContainer=null,this.direction="ltr",this.levelSpacing=60,this.nodeSpacing=20,this.edgeStyle="orthogonal",this.showOperators="true",c(this),a(this),this.errors=l(this),this.componentStyle=d(this)}getTreeStyle(){return this.componentStyle((t=>({edgeColor:t["bn-tree"].edgeColor,edgeWidth:t["bn-tree"].edgeWidth,operatorCircleRadius:t["bn-tree"].operatorCircleRadius,operatorFontSize:t.global.fontSizePx*t["bn-tree"].operatorFontSizeScale,operatorColor:t["bn-tree"].operatorColor})))}componentWillLoad(){this.validateEdgesProp(this.edges),this.validateDirection(this.direction),this.validateLevelSpacing(this.levelSpacing),this.validateNodeSpacing(this.nodeSpacing),this.validateEdgeStyle(this.edgeStyle),this.validateShowOperators(this.showOperators)}componentDidLoad(){this.setupResizeObserver(),requestAnimationFrame((()=>{this.updateNodeRects()}))}disconnectedCallback(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}setupResizeObserver(){var t;this.gridContainer=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"),this.gridContainer&&(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()})),this.resizeObserver.observe(this.gridContainer),this.element.querySelectorAll("[slot]").forEach((t=>{this.resizeObserver.observe(t)})))}recalculateLayout(){this.layout=this.treeConfig?function(t,e,n,s){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const i=function(t){const e=new Map;if(!t.rootNode)return e;const n=[{node:t.rootNode,level:0}],s=new Set;for(;n.length>0;){const{node:i,level:r}=n.shift();if(s.has(i))continue;s.add(i),e.set(i,r);const o=t.adjacencyList.get(i)||[];for(const t of o)s.has(t)||n.push({node:t,level:r+1})}return e}(t),r=function(t){const e=new Map;if(!t.rootNode)return e;let n=0;return function s(i){const r=e.get(i);if(r)return r;const o=t.adjacencyList.get(i)||[];if(0===o.length){const t={startIndex:n,endIndex:n};return e.set(i,t),n++,t}let a=1/0,l=-1/0;for(const t of o){const e=s(t);a=Math.min(a,e.startIndex),l=Math.max(l,e.endIndex)}const c={startIndex:a,endIndex:l};return e.set(i,c),c}(t.rootNode),e}(t),o=function(t,e,n,s){var i,r;const o=new Map,a=Math.max(...Array.from(e.values()));for(const l of t.allNodes){const t=null!==(i=e.get(l))&&void 0!==i?i:0,c=null!==(r=n.get(l))&&void 0!==r?r:{startIndex:0,endIndex:0};let d,u,h;switch(s){case"ltr":d=t+1,u=c.startIndex+1,h=c.endIndex-c.startIndex+1;break;case"rtl":d=a-t+1,u=c.startIndex+1,h=c.endIndex-c.startIndex+1;break;case"ttb":u=t+1,d=c.startIndex+1,h=1;break;case"btt":u=a-t+1,d=c.startIndex+1,h=1}o.set(l,{nodeId:l,level:t,index:c.startIndex,gridColumn:d,gridRow:u,gridRowSpan:h})}return o}(t,i,r,e),a=Math.max(...Array.from(i.values())),l=Math.max(...Array.from(r.values()).map((t=>t.endIndex))),{gridTemplateColumns:c,gridTemplateRows:d}=function(t,e,n,s,i){const r=t+1,o=e+1;if("ltr"===n||"rtl"===n){const t=[];for(let e=0;e<r;e++)t.push("auto"),e<r-1&&t.push(s+"px");const e=[];for(let t=0;t<o;t++)e.push("auto"),t<o-1&&e.push(i+"px");return{gridTemplateColumns:t.join(" "),gridTemplateRows:e.join(" ")}}{const t=[];for(let e=0;e<r;e++)t.push("auto"),e<r-1&&t.push(s+"px");const e=[];for(let t=0;t<o;t++)e.push("auto"),t<o-1&&e.push(i+"px");return{gridTemplateColumns:e.join(" "),gridTemplateRows:t.join(" ")}}}(a,l,e,n,s);return{positions:o,gridTemplateColumns:c,gridTemplateRows:d,maxLevel:a,maxIndex:l}}(this.treeConfig,this.direction,this.levelSpacing,this.nodeSpacing):null}updateNodeRects(){if(!this.treeConfig||!this.gridContainer)return;const t=this.gridContainer.getBoundingClientRect(),e=new Map;for(const n of this.treeConfig.allNodes){const s=this.element.querySelector(`[slot="${n}"]`);s&&e.set(n,y(s,t))}this.nodeRects=e,this.svgWidth=t.width,this.svgHeight=t.height}getSlotStyle(t){if(!this.layout)return{};const e=this.layout.positions.get(t);return e?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":p(e.gridColumn)+"","grid-row":`${g(e.gridRow)} / span ${v(e.gridRowSpan)}`,"align-self":"center"}:{"grid-row":g(e.gridRow)+"","grid-column":p(e.gridColumn)+"","justify-self":"center"}:{}}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const e=this.getTreeStyle(),s=[],i=[],r=new Map;for(const t of this.treeConfig.edges){const e=r.get(t.to)||[];e.push(t.from),r.set(t.to,e)}for(const t of this.treeConfig.edges){const i=this.nodeRects.get(t.from),o=this.nodeRects.get(t.to);if(!i||!o)continue;const a=m(i,!0,this.direction),l=r.get(t.to)||[];let c;if(l.length>1){const e=l.indexOf(t.from);c=b(o,this.direction,e,l.length)}else c=m(o,!1,this.direction);const{path:d}=w(a,c,this.edgeStyle,this.direction),u=$(e.edgeColor,e.edgeWidth,t.style);s.push(n("path",{key:`edge-${t.from}-${t.to}`,d,fill:"none",stroke:u.stroke,"stroke-width":u.strokeWidth,"stroke-dasharray":u.strokeDasharray}))}if("true"===this.showOperators)for(const[s,r]of this.treeConfig.adjacencyList.entries()){const o=this.nodeRects.get(s);if(o)for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1],d=f(this.treeConfig.edges,s,l);if(!(null==d?void 0:d.operator)||"none"===d.operator)continue;const u=this.nodeRects.get(l),p=this.nodeRects.get(c);if(!u||!p)continue;const g=null!==(t=d.label)&&void 0!==t?t:h(d.operator),v=x(o,u,p,this.direction);i.push(n("g",{key:`operator-${s}-${l}`,class:"operator-group"},n("circle",{cx:v.x,cy:v.y,r:e.operatorCircleRadius,fill:"white",stroke:e.edgeColor,"stroke-width":e.edgeWidth}),n("text",{x:v.x,y:v.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:e.operatorFontSize+"px",fill:e.operatorColor,fontWeight:"bold"}},g)))}}return n("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},s,i)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>n("div",{key:t,class:"tree-node",style:this.getSlotStyle(t)},n("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var e,n,s,i;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(n=t.global)||void 0===n?void 0:n.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(s=t.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(i=t.global)||void 0===i?void 0:i.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return n(s,{style:t},this.treeConfig&&this.layout?n("div",{class:"tree-container"},n("div",{class:"tree-grid",style:{display:"grid","grid-template-columns":this.layout.gridTemplateColumns,"grid-template-rows":this.layout.gridTemplateRows,position:"relative"}},this.renderEdges(),this.renderSlots())):n("div",{class:"tree-container tree-error"},n("slot",null)))}get element(){return this}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}],showOperators:[{validateShowOperators:0}]}}static get style(){return':host{display:inline-block;position:relative;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.tree-container{position:relative;display:inline-block}.tree-grid{position:relative;display:grid;align-items:center}.tree-node{position:relative;z-index:1;border:1px solid #404040;background:var(--bn-font-background, white)}.edge-layer{position:absolute;top:0;left:0;z-index:0;pointer-events:none;overflow:visible}.tree-error{display:flex;flex-wrap:wrap;gap:20px}'}},[257,"bn-tree",{edges:[1],direction:[1],levelSpacing:[2,"level-spacing"],nodeSpacing:[2,"node-spacing"],edgeStyle:[1,"edge-style"],i18nNamespace:[513,"i18n-namespace"],showOperators:[1,"show-operators"],treeConfig:[32],layout:[32],nodeRects:[32],svgWidth:[32],svgHeight:[32]},void 0,{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}],showOperators:[{validateShowOperators:0}]}]),R=S,k=function(){"undefined"!=typeof customElements&&["bn-tree"].forEach((t=>{"bn-tree"===t&&(customElements.get(i(t))||customElements.define(i(t),S))}))};export{R as BnTree,k as defineCustomElement}
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as e,h as n,Host as s,transformTag as i}from"@stencil/core/internal/client";import{o as r,l as o}from"./validate.js";import{w as a,a as l}from"./withHasError.js";import{w as c}from"./withStyled.js";import{w as d}from"./withComponentStyle.js";const u=["*","/","+","-","x","÷","none"];function h(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function f(t,e,n){return t.find((t=>t.from===e&&t.to===n))}function p(t){return 2*(t-1)+1}function g(t){return 2*(t-1)+1}function v(t){return t<=1?1:2*(t-1)+1}function y(t,e){const n=t.getBoundingClientRect(),s=n.left-e.left,i=n.top-e.top;return{left:s,top:i,width:n.width,height:n.height,centerX:s+n.width/2,centerY:i+n.height/2}}function m(t,e,n){switch(n){case"ltr":return e?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return e?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return e?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return e?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function b(t,e,n,s,i=8){const r=-(s-1)*i/2+n*i;switch(e){case"ltr":return{x:t.left,y:t.centerY+r};case"rtl":return{x:t.left+t.width,y:t.centerY+r};case"ttb":return{x:t.centerX+r,y:t.top};case"btt":return{x:t.centerX+r,y:t.top+t.height}}}function w(t,e,n,s){switch(n){case"straight":return function(t,e){return{path:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,midpoint:{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}}(t,e);case"curved":return function(t,e,n){let s,i;if("ltr"===n||"rtl"===n){const n=(t.x+e.x)/2;s={x:n,y:t.y},i={x:n,y:e.y}}else{const n=(t.y+e.y)/2;s={x:t.x,y:n},i={x:e.x,y:n}}return{path:`M ${t.x} ${t.y} C ${s.x} ${s.y}, ${i.x} ${i.y}, ${e.x} ${e.y}`,midpoint:{x:.125*t.x+.375*s.x+.375*i.x+.125*e.x,y:.125*t.y+.375*s.y+.375*i.y+.125*e.y}}}(t,e,s);default:return function(t,e,n){let s,i;if("ltr"===n||"rtl"===n){const n=t.x+.7*(e.x-t.x);s=`M ${t.x} ${t.y} L ${n} ${t.y} L ${n} ${e.y} L ${e.x} ${e.y}`,i={x:n,y:(t.y+e.y)/2}}else{const n=t.y+.7*(e.y-t.y);s=`M ${t.x} ${t.y} L ${t.x} ${n} L ${e.x} ${n} L ${e.x} ${e.y}`,i={x:(t.x+e.x)/2,y:n}}return{path:s,midpoint:i}}(t,e,s)}}function x(t,e,n,s){const i=.7;switch(s){case"ltr":{const s=t.left+t.width;return{x:s+(Math.min(e.left,n.left)-s)*i,y:t.centerY}}case"rtl":{const s=t.left,r=Math.max(e.left+e.width,n.left+n.width);return{x:r+(s-r)*i,y:t.centerY}}case"ttb":{const s=t.top+t.height;return{x:t.centerX,y:s+(Math.min(e.top,n.top)-s)*i}}case"btt":{const s=t.top,r=Math.max(e.top+e.height,n.top+n.height);return{x:t.centerX,y:r+(s-r)*i}}}}function $(t,e,n){var s,i;return Object.assign({stroke:null!==(s=null==n?void 0:n.color)&&void 0!==s?s:t,strokeWidth:null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e},(null==n?void 0:n.dasharray)?{strokeDasharray:n.dasharray}:{})}const S=t(class extends e{validateEdgesProp(t){const e="ERR_edges",n=function(t){const e=[];if(!t||""===t.trim())return e.push("edges: value is required"),e;let n;try{n=JSON.parse(t)}catch(t){return e.push("edges: invalid JSON structure"),e}if(!Array.isArray(n))return e.push("edges: must be an array"),e;if(0===n.length)return e.push("edges: array must not be empty"),e;const s=new Set,i=new Set;n.forEach(((t,n)=>{if("object"!=typeof t||null===t)return void e.push(`edges[${n}]: must be an object`);const r=t;if("string"!=typeof r.from||""===r.from.trim()?e.push(`edges[${n}]: 'from' is required and must be a non-empty string`):s.add(r.from),"string"!=typeof r.to||""===r.to.trim()?e.push(`edges[${n}]: 'to' is required and must be a non-empty string`):(s.add(r.to),i.add(r.to)),void 0!==r.operator&&("string"==typeof r.operator&&u.includes(r.operator)||e.push(`edges[${n}]: 'operator' must be one of: ${u.join(", ")}`)),void 0!==r.label&&"string"!=typeof r.label&&e.push(`edges[${n}]: 'label' must be a string`),void 0!==r.style)if("object"!=typeof r.style||null===r.style)e.push(`edges[${n}]: 'style' must be an object`);else{const t=r.style;void 0!==t.color&&"string"!=typeof t.color&&e.push(`edges[${n}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&e.push(`edges[${n}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&e.push(`edges[${n}]: 'style.dasharray' must be a string`)}}));const r=Array.from(s).filter((t=>!i.has(t)));return 0===r.length?e.push("edges: tree has no root node (circular reference detected)"):r.length>1&&e.push("edges: tree has multiple root nodes: "+r.join(", ")),e}(t);n.length>0?(this.errors.addOrReplace({id:e,type:"error",message:"edges: "+n.join("; ")}),this.treeConfig=null):(this.errors.remove(e),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const e=JSON.parse(t);if(!Array.isArray(e))return null;const n=e,s=function(t){const e=new Map;for(const n of t){const t=e.get(n.from)||[];t.push(n.to),e.set(n.from,t)}return e}(n),i=function(t){const e=new Set;for(const n of t)e.add(n.from),e.add(n.to);return e}(n),r=function(t,e){const n=new Set;for(const e of t)n.add(e.to);const s=Array.from(e).filter((t=>!n.has(t)));return 1===s.length?s[0]:null}(n,i);return{edges:n,adjacencyList:s,rootNode:r,allNodes:i}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const e="ERR_direction",n=["ltr","rtl","ttb","btt"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`direction: invalid value '${t}', must be one of: ${n.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const e="ERR_levelSpacing";!r(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateNodeSpacing(t){const e="ERR_nodeSpacing";!r(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateEdgeStyle(t){const e="ERR_edgeStyle",n=["straight","orthogonal","curved"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${n.join(", ")}`})}validateShowOperators(t){const e="ERR_showOperators";o(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`show-operators: invalid value '${t}', must be 'true' or 'false'`})}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.treeConfig=null,this.layout=null,this.nodeRects=new Map,this.svgWidth=0,this.svgHeight=0,this.resizeObserver=null,this.gridContainer=null,this.direction="ltr",this.levelSpacing=60,this.nodeSpacing=20,this.edgeStyle="orthogonal",this.showOperators="true",c(this),a(this),this.errors=l(this),this.componentStyle=d(this)}getTreeStyle(){return this.componentStyle((t=>({edgeColor:t["bn-tree"].edgeColor,edgeWidth:t["bn-tree"].edgeWidth,operatorCircleRadius:t["bn-tree"].operatorCircleRadius,operatorFontSize:t.global.fontSizePx*t["bn-tree"].operatorFontSizeScale,operatorColor:t["bn-tree"].operatorColor})))}componentWillLoad(){this.validateEdgesProp(this.edges),this.validateDirection(this.direction),this.validateLevelSpacing(this.levelSpacing),this.validateNodeSpacing(this.nodeSpacing),this.validateEdgeStyle(this.edgeStyle),this.validateShowOperators(this.showOperators)}componentDidLoad(){this.setupResizeObserver(),requestAnimationFrame((()=>{this.updateNodeRects()}))}disconnectedCallback(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}setupResizeObserver(){var t;this.gridContainer=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"),this.gridContainer&&(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()})),this.resizeObserver.observe(this.gridContainer),this.element.querySelectorAll("[slot]").forEach((t=>{this.resizeObserver.observe(t)})))}recalculateLayout(){this.layout=this.treeConfig?function(t,e,n,s){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const i=function(t){const e=new Map;if(!t.rootNode)return e;const n=[{node:t.rootNode,level:0}],s=new Set;for(;n.length>0;){const{node:i,level:r}=n.shift();if(s.has(i))continue;s.add(i),e.set(i,r);const o=t.adjacencyList.get(i)||[];for(const t of o)s.has(t)||n.push({node:t,level:r+1})}return e}(t),r=function(t){const e=new Map;if(!t.rootNode)return e;let n=0;return function s(i){const r=e.get(i);if(r)return r;const o=t.adjacencyList.get(i)||[];if(0===o.length){const t={startIndex:n,endIndex:n};return e.set(i,t),n++,t}let a=1/0,l=-1/0;for(const t of o){const e=s(t);a=Math.min(a,e.startIndex),l=Math.max(l,e.endIndex)}const c={startIndex:a,endIndex:l};return e.set(i,c),c}(t.rootNode),e}(t),o=function(t,e,n,s){var i,r;const o=new Map,a=Math.max(...Array.from(e.values()));for(const l of t.allNodes){const t=null!==(i=e.get(l))&&void 0!==i?i:0,c=null!==(r=n.get(l))&&void 0!==r?r:{startIndex:0,endIndex:0};let d,u,h;switch(s){case"ltr":d=t+1,u=c.startIndex+1,h=c.endIndex-c.startIndex+1;break;case"rtl":d=a-t+1,u=c.startIndex+1,h=c.endIndex-c.startIndex+1;break;case"ttb":u=t+1,d=c.startIndex+1,h=1;break;case"btt":u=a-t+1,d=c.startIndex+1,h=1}o.set(l,{nodeId:l,level:t,index:c.startIndex,gridColumn:d,gridRow:u,gridRowSpan:h})}return o}(t,i,r,e),a=Math.max(...Array.from(i.values())),l=Math.max(...Array.from(r.values()).map((t=>t.endIndex))),{gridTemplateColumns:c,gridTemplateRows:d}=function(t,e,n,s,i){const r=t+1,o=e+1;if("ltr"===n||"rtl"===n){const t=[];for(let e=0;e<r;e++)t.push("auto"),e<r-1&&t.push(s+"px");const e=[];for(let t=0;t<o;t++)e.push("auto"),t<o-1&&e.push(i+"px");return{gridTemplateColumns:t.join(" "),gridTemplateRows:e.join(" ")}}{const t=[];for(let e=0;e<r;e++)t.push("auto"),e<r-1&&t.push(s+"px");const e=[];for(let t=0;t<o;t++)e.push("auto"),t<o-1&&e.push(i+"px");return{gridTemplateColumns:e.join(" "),gridTemplateRows:t.join(" ")}}}(a,l,e,n,s);return{positions:o,gridTemplateColumns:c,gridTemplateRows:d,maxLevel:a,maxIndex:l}}(this.treeConfig,this.direction,this.levelSpacing,this.nodeSpacing):null}updateNodeRects(){if(!this.treeConfig||!this.gridContainer)return;const t=this.gridContainer.getBoundingClientRect(),e=new Map;for(const n of this.treeConfig.allNodes){const s=this.element.querySelector(`[slot="${n}"]`);s&&e.set(n,y(s,t))}this.nodeRects=e,this.svgWidth=t.width,this.svgHeight=t.height}getSlotStyle(t){if(!this.layout)return{};const e=this.layout.positions.get(t);return e?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":p(e.gridColumn)+"","grid-row":`${g(e.gridRow)} / span ${v(e.gridRowSpan)}`,"align-self":"center"}:{"grid-row":g(e.gridRow)+"","grid-column":p(e.gridColumn)+"","justify-self":"center"}:{}}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const e=this.getTreeStyle(),s=[],i=[],r=new Map;for(const t of this.treeConfig.edges){const e=r.get(t.to)||[];e.push(t.from),r.set(t.to,e)}for(const t of this.treeConfig.edges){const i=this.nodeRects.get(t.from),o=this.nodeRects.get(t.to);if(!i||!o)continue;const a=m(i,!0,this.direction),l=r.get(t.to)||[];let c;if(l.length>1){const e=l.indexOf(t.from);c=b(o,this.direction,e,l.length)}else c=m(o,!1,this.direction);const{path:d}=w(a,c,this.edgeStyle,this.direction),u=$(e.edgeColor,e.edgeWidth,t.style);s.push(n("path",{key:`edge-${t.from}-${t.to}`,d,fill:"none",stroke:u.stroke,"stroke-width":u.strokeWidth,"stroke-dasharray":u.strokeDasharray}))}if("true"===this.showOperators)for(const[s,r]of this.treeConfig.adjacencyList.entries()){const o=this.nodeRects.get(s);if(o)for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1],d=f(this.treeConfig.edges,s,l);if(!(null==d?void 0:d.operator)||"none"===d.operator)continue;const u=this.nodeRects.get(l),p=this.nodeRects.get(c);if(!u||!p)continue;const g=null!==(t=d.label)&&void 0!==t?t:h(d.operator),v=x(o,u,p,this.direction);i.push(n("g",{key:`operator-${s}-${l}`,class:"operator-group"},n("circle",{cx:v.x,cy:v.y,r:e.operatorCircleRadius,fill:"white",stroke:e.edgeColor,"stroke-width":e.edgeWidth}),n("text",{x:v.x,y:v.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:e.operatorFontSize+"px",fill:e.operatorColor,fontWeight:"bold"}},g)))}}return n("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},s,i)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>n("div",{key:t,class:"tree-node",style:this.getSlotStyle(t)},n("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var e,n,s,i;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(n=t.global)||void 0===n?void 0:n.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(s=t.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(i=t.global)||void 0===i?void 0:i.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return n(s,{style:t},this.treeConfig&&this.layout?n("div",{class:"tree-container"},n("div",{class:"tree-grid",style:{display:"grid","grid-template-columns":this.layout.gridTemplateColumns,"grid-template-rows":this.layout.gridTemplateRows,position:"relative"}},this.renderEdges(),this.renderSlots())):n("div",{class:"tree-container tree-error"},n("slot",null)))}get element(){return this}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}],showOperators:[{validateShowOperators:0}]}}static get style(){return':host{display:inline-block;position:relative;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.tree-container{position:relative;display:inline-block}.tree-grid{position:relative;display:grid;align-items:center}.tree-node{position:relative;z-index:1;border:1px solid #404040;background:var(--bn-font-background, white)}.edge-layer{position:absolute;top:0;left:0;z-index:0;pointer-events:none;overflow:visible}.tree-error{display:flex;flex-wrap:wrap;gap:20px}'}},[257,"bn-tree",{edges:[1],direction:[1],levelSpacing:[2,"level-spacing"],nodeSpacing:[2,"node-spacing"],edgeStyle:[1,"edge-style"],i18nNamespace:[513,"i18n-namespace"],showOperators:[1,"show-operators"],treeConfig:[32],layout:[32],nodeRects:[32],svgWidth:[32],svgHeight:[32]},void 0,{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}],showOperators:[{validateShowOperators:0}]}]),R=S,M=function(){"undefined"!=typeof customElements&&["bn-tree"].forEach((t=>{"bn-tree"===t&&(customElements.get(i(t))||customElements.define(i(t),S))}))};export{R as BnTree,M as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as i,h as s,Host as h,transformTag as e}from"@stencil/core/internal/client";import{S as n,F as r,a as o,b as a,P as l}from"./main.js";import{C as c,A as u,g as d,e as f}from"./CompareUtil.js";import{D as p,b as g}from"./DataFormatDigits.js";import{A as v,c as w,a as b,O as m}from"./Order.js";import{S as P}from"./SiPrefix.js";import{F as S,I as y,C as L,V as x}from"./formatter.js";import{g as M,a as k,I as C}from"./stackColors.js";import{d as T,g as A}from"./context-protocol.js";import{S as $}from"./StringAdapter.js";import{S as O}from"./SVGVariancesStyleGroup.js";class _{constructor(t,i,s,h,e,n,r,o,a=!1){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.spacings.barWidth-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,h){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<h/2&&(this.axisPosition.x=h/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class E{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class R{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class W{constructor(t){this.container=new n,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var D,N,X,B,Y;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(D||(D={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(N||(N={}));class V{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new w(new $).default(),this.level=u.CATEGORY,this.filter="",this.measureScale=new P,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class H{constructor(t,i,s,h,e,n){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n}adapt(t){const i=v.adaptArray(t.data,this.dataRowAdapter),s=v.adaptArray(t.scenarios,this.stringAdapter),h=new V(i,s);return c.isArray(t.variances)&&(h.variances=v.adaptArray(t.variances,this.stringAdapter)),c.isString(t.title)&&(h.title=t.title),c.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),c.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),c.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),c.isNumber(t.limit)&&(h.limit=t.limit),c.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),c.isExisting(t.level)&&(h.level=t.level),c.isString(t.filter)&&(h.filter=t.filter.trim()),c.isExisting(t.measureScale)&&(h.measureScale=p.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale)),c.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),c.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),c.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),c.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),h}default(){return new V([],[])}}class F{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===h||h===X.NEG?X.NEG:"pos"===h||h===X.POS?X.POS:X.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:X.NEU===this.variance?X.NEU:X.POS===this.variance?X.NEG:X.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class G{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class U{constructor(){}adapt(t){const i=new G;return c.isOperator(t.operation)&&(i.operation=t.operation),c.isNumber(t.rowGroupIndex)&&c.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),c.isNumber(t.categoryIndex)&&c.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),c.isNumber(t.subCategoryIndex)&&c.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),c.isNumber(t.columnGroupIndex)&&c.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),c.isNumber(t.columnSubGroupIndex)&&c.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new G}setActualValues(t,i){c.isNumber(t.ac1)&&(i.ac1=t.ac1),c.isNumber(t.ac2)&&(i.ac2=t.ac2),c.isNumber(t.ac3)&&(i.ac3=t.ac3),c.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){c.isNumber(t.pl1)&&(i.pl1=t.pl1),c.isNumber(t.pl2)&&(i.pl2=t.pl2),c.isNumber(t.pl3)&&(i.pl3=t.pl3),c.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){c.isNumber(t.pp1)&&(i.pp1=t.pp1),c.isNumber(t.pp2)&&(i.pp2=t.pp2),c.isNumber(t.pp3)&&(i.pp3=t.pp3),c.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){c.isNumber(t.fc1)&&(i.fc1=t.fc1),c.isNumber(t.fc2)&&(i.fc2=t.fc2),c.isNumber(t.fc3)&&(i.fc3=t.fc3),c.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class z{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class j{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new z(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return c.isExisting(t)&&(c.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),c.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),c.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),c.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),c.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),c.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.pattern=new R(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new z(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class I{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class K{adapt(t){const i=new I;return c.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),c.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),c.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),c.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),c.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),c.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),c.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),c.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),c.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),c.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),c.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),c.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),c.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),c.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),c.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new I}}!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(X||(X={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(B||(B={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(Y||(Y={}));class q{constructor(t,i,s,h,e,n,r,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.x=i,this.y=s,this.value=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||Y.Top,this.horizontalHookLocation=o||Y.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setMaxWidth(t){return this.maxWidth=t,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new P){var s;if(this.isEmpty())return this;const h=this.group;let e;const n=this.styles.fontStyles.background||"#ffffff";let r="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,h=t.percent,n=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,h=t.decimal,n=i.value,a="decimal"),e=S.number(Number(this.value),a,s,h,n),Number(this.value)<0&&(o="end"),this.isVarianceLabel&&Number(this.value)>=0&&(r="+")}else e=""+this.value,o="start";const a=h.text(r+e);a.move(this.x,this.y);const l=a.bbox().w,c=a.bbox().h;return null!=this.maxWidth&&l>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===Y.Right?(o="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===Y.Center&&(o="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===Y.Center?a.move(a.x(),a.y()-c/2):this.verticalHookLocation===Y.Bottom&&a.move(a.x(),a.y()-c),a.font({anchor:o}),null!=this.segmentFillColor?a.fill(M(this.segmentFillColor)):null==h||h.rect(l,.9*c).stroke(n).fill(n).opacity(.7).move(a.x(),a.y()+.1*c).insertBefore(a),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class Z{constructor(t,i,s,h){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=h,this.label=new q(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Y.Bottom,Y.Center),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class J{constructor(t,i,s,h,e,n,r,o=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Y.Left;s.value<0&&(i=Y.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new q(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Y.Center,i),this.scenarioLabel=this.getScenarioLabel(r)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new P){if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let s=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(s=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const h=this.convertToSVGStyle(s,"stroke");let e=this.convertToSVGStyle(s,"fill");const n=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=n){const t=this.styles.pattern.get(n);null!=t&&(e=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(e,h):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(e).stroke(h).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new P){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){return new q(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Y.Top:Y.Bottom,Y.Center)}}class Q{constructor(t,i,s,h,e,n,r,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new q(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Y.Bottom:Y.Top,Y.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class tt{constructor(t,i,s,h,e){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=Y.Left;s.value<0&&(i=Y.Right),this.label=new q(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Y.Center,i),this.label.setToRelativeVarianceLabel()}}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;if(null==this.dimensions)return this;const i=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),s=i.stroke;let h=i.fill;const e=this.barStyles[this.dataPoint.getScenario()];if(null!=e&&e.fillpattern){const t=this.styles.pattern.get(e.fillpattern);null!=t&&null!=t.pattern&&(h=t.pattern)}this.drawNeedleHead(h,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(h).stroke(s).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(t=this.label)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,h=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(h)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}}class it{constructor(t,i,s,h,e,n,r,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.baselineValue=e,this.segmentIndex=r,this.stackMode=o,this.totalValue=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new P){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,h=this.dataPoint.pixelPerUnit,e=this.position.getBarPositionX(),n=this.position.getBarWidth();let r,o;if(this.stackMode===d.RELATIVE){const t=h;r=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=e+this.baselineValue/Math.abs(this.totalValue)*t}else r=Math.abs(s*h),o=e+this.baselineValue*h;const a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},f={color:c,width:.5};this.barGroup.rect(Math.max(r,.5),n).fill(u).stroke(f).cy(a).x(o);const p=r-6;if(p>0){const h=o+r/2;if(this.stackMode===d.RELATIVE||this.stackMode===d.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new q(this.group,h,a,"STACK_SEG",i,this.styles,Y.Center,Y.Center).setSegmentFill(c).setMaxWidth(p).draw()}else new q(this.group,h,a,"STACK_SEG",s,this.styles,Y.Center,Y.Center).setSegmentFill(c).setMaxWidth(p).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new P){if(this.stackMode===d.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,h=this.position.getBarPositionY(this.index,!0);new q(this.group,s,h,"STACK_TOTAL",this.totalValue,this.styles,Y.Center,Y.Left).draw(t,i)}}class st{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new tt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new J(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Q(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Q(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class ht{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new F(0,X.AC1,1,X.NEU),this.highestDataPointValue=new F(0,X.AC1,1,X.NEU),this.smallestVarianceDataPointValue=new F(0,X.AC1,1,X.NEU),this.highestVarianceDataPointValue=new F(0,X.AC1,1,X.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=X.AC1,this.CSS_CATEGORIES="categories",this.state=D.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new P,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.highestStackedTotal=0,this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new y,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new _(new E(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new y}setConfig(t){var i;this.state=D.DIRTY,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.dataModel=this.populateModel(s,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==f.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.highestStackedTotal=this.findHighestStackedRowTotal(this.dataModel),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||S.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=D.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=D.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=T(this.tableName,t);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0}}getMaxBarValue(){var t,i;if(null!=this.stackConfig&&this.highestStackedTotal>0)return this.stackConfig.mode===d.RELATIVE?1:this.highestStackedTotal;const s=this.getVarianceType();return s===N.NONE&&null!=(null===(t=this.highestDataPointValue)||void 0===t?void 0:t.value)?Math.abs(this.highestDataPointValue.value):s===N.ABSOLUTE&&null!=(null===(i=this.highestVarianceDataPointValue)||void 0===i?void 0:i.value)?Math.abs(this.highestVarianceDataPointValue.value):0}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}toString(){const t=new n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===D.DIRTY&&(this.state=D.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=L(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":S.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=X.AC1;if(null!=t&&t.length>0){const s=new x(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=X.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${r}\n ORDER BY ${e}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new x(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(0===this.limit||this.limit>t.length)return;const h=[],e=t.slice(this.limit,t.length);this.createDataRows(e,h,i);const n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new F(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,X.NEU),scenario2:new F(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,X.NEU),scenario3:new F(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,X.NEU),scenario4:new F(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,X.NEU)}}),{id:9999,category:"REST",type:N.NONE,scenario1:new F(0,i[0],this.pixelPerUnit,X.NEU),scenario2:new F(0,i[1],this.pixelPerUnit,X.NEU),scenario3:new F(0,i[2],this.pixelPerUnit,X.NEU),scenario4:new F(0,i[3],this.pixelPerUnit,X.NEU)});s.push(n)}createDataRows(t,i,s){let h=t;this.limit>0&&(h=t.slice(0,this.limit)),h.forEach(((t,h)=>{i.push({id:h,category:t.category,type:N.NONE,scenario1:new F(t[s[0]],s[0],this.pixelPerUnit,X.NEU),scenario2:new F(t[s[1]],s[1],this.pixelPerUnit,X.NEU),scenario3:new F(t[s[2]],s[2],this.pixelPerUnit,X.NEU),scenario4:new F(t[s[3]],s[3],this.pixelPerUnit,X.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=`${i.hierarchy.toString()} ${null==i?void 0:i.direction}`),s}createSelectString(t,i){return t===u.CATEGORY&&i.hierarchy.includes(b.CATEGORYINDEX)?`${b.CATEGORYINDEX}, ${u.CATEGORY} as category`:t===u.ROWGROUP&&i.hierarchy.includes(b.ROWGROUPINDEX)?`${b.ROWGROUPINDEX}, ${u.ROWGROUP} as category`:t===u.SUBCATEGORY&&i.hierarchy.includes(b.SUBCATEGORYINDEX)?`${b.SUBCATEGORYINDEX}, ${u.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===u.CATEGORY&&i.hierarchy.includes(b.CATEGORYINDEX)?`${b.CATEGORYINDEX}, ${u.CATEGORY}`:t===u.ROWGROUP&&i.hierarchy.includes(b.ROWGROUPINDEX)?`${b.ROWGROUPINDEX}, ${u.ROWGROUP}`:t===u.SUBCATEGORY&&i.hierarchy.includes(b.SUBCATEGORYINDEX)?`${b.SUBCATEGORYINDEX}, ${u.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=L(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new F(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new F(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}findHighestStackedRowTotal(t){if(!this.stackConfig||0===t.length)return 0;const i=this.stackConfig.by===f.SCENARIOS;let s=0;for(const h of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=h[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>k(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=k(t.scenario);i.set(s,(i.get(s)||0)+Math.abs(t.value))}t=Math.max(...i.values())}else t=s.reduce(((t,i)=>t+Math.abs(i.value)),0)}else h.stackSegments&&h.stackSegments.length>0&&(t=h.stackSegments.reduce(((t,i)=>t+Math.abs(i.value)),0));t>s&&(s=t)}return s}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new x(t[e]);if(n.isValid){const t=this.mapScenarios(n,h),e=n.direction;let r=this.pixelPerUnit;"dr"===n.type&&(r=this.pixelPerPercentage);for(const h in i)s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?N.RELATIVE:N.ABSOLUTE,scenario1:new F(this.calculateVariance(n,i[h],t),n.base,r,e),scenario2:new F(null,null,null,null),scenario3:new F(null,null,null,null),scenario4:new F(null,null,null,null)})}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===N.RELATIVE?(i[h].value-i[e].value)/i[e].value:i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t){return L(S.number(t,"decimal",1,0),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;return t>=0&&(i+=L("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=L(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,L(S.number(t,"decimal",1,1),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i){const s=i.group().id("AxisAndDateLables");let h=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===N.RELATIVE&&(h=!0);let e=Y.Right,n=!0;t.scenario1.value<0&&(e=Y.Left,n=!1),new q(s,this.position.getCategoryPositionX(n),this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Y.Center,e).draw()})),new Z({scenarioType:this.axisScenario,labelText:this.title,isRelative:h},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),h=new st(this.position,s,this.styles,t.length,this.i18n);h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{h.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),h.createSecondaryBar(t.scenario2,i).draw(),h.createPrimaryMarker(t.scenario3,i).draw(),h.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new st(this.position,s,this.styles,t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===N.RELATIVE?h.createRelativeVarianceBar(t.scenario1,i).draw():h.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===f.SCENARIOS;t.forEach(((t,i)=>{const e=["scenario1","scenario2","scenario3","scenario4"],n=[];if(h){for(const i of e){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&n.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(n)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&n.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==n.length)if((h?new Set(n.map((t=>k(t.scenario)))):new Set).size>1){const t=new Map;for(const i of n){const s=k(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const h=[];for(const i of C)t.has(i)&&(h.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)h.push({prefix:i,segments:s});h.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=h.length-1-e;let o=0,a=null;t.segments.forEach((t=>{const h=new it(this.position,this.styles,t.dataPoint,i,o,t.scenario,r,this.stackConfig.mode,n,!0,s);h.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=h})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let e=n;!h&&t.stackSegments&&t.stackSegments.length>0&&(e=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?e.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&e.sort(((t,i)=>i.value-t.value));const r=e.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,a=null;e.forEach(((t,e)=>{const n=new it(this.position,this.styles,t.dataPoint,i,o,t.scenario,e,this.stackConfig.mode,r,h,s);n.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=n})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===f.SCENARIOS,h=i.group().id("StackedHeaders"),e=t[0];if(!s){const t=e.stackSegments;if(!t||0===t.length)return;const i=[...t];"asc"===this.stackConfig.order?i.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&i.sort(((t,i)=>i.value-t.value));const s=i.reduce(((t,i)=>t+Math.abs(i.value)),0),n=this.position.getBarPositionX(),r=this.position.getStackedHeaderPositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let e;e=this.stackConfig.mode===d.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const a=n+o+e/2,l=this.i18n.get(t.label)||t.label;new q(h,a,r,"STACK_HEADER",l,this.styles,Y.Bottom,Y.Center).draw(),o+=e}))}const n=["scenario1","scenario2","scenario3","scenario4"],r=[];for(const t of n){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===r.length)return;this.sortSegmentsByPropOrder(r);const o=new Set(r.map((t=>k(t.scenario)))),a=this.position.getBarPositionX(),l=this.position.getStackedHeaderPositionY();if(o.size>1){const t=new Map;for(const i of r){const s=k(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of C)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,h]of t)i.push({prefix:s,segments:h});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,e=a+(this.stackConfig.mode===d.RELATIVE?s:i*s)/2,n=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new q(h,e,l,"STACK_HEADER",n,this.styles,Y.Bottom,Y.Center).draw()}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0);let i=0;r.forEach((s=>{const e=s.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===d.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*e:Math.abs(s.value*e);const r=a+i+n/2,o=this.i18n.get(s.scenario)||s.scenario;new q(h,r,l,"STACK_HEADER",o,this.styles,Y.Bottom,Y.Center).draw(),i+=n}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:N.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(N.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(N.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(N.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===d.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(N.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);e=Math.abs(this.highestDataPointValue.getScaledUnit())+n+t}else if(N.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(N.ABSOLUTE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const h={[u.ROWGROUP]:"category",[u.ROWGROUPINDEX]:"category",[u.CATEGORY]:"subCategory",[u.CATEGORYINDEX]:"subCategory"}[s];if(!h)return;const e=s.toString(),n=t[0];let r;try{r=this.db.exec(`SELECT [${e}] as displayGroup, [${h}] as stackLabel, SUM([${n}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${e}], [${h}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of r){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new F(t.value,n,this.pixelPerUnit,X.NEU)}))):[]}}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new F(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new F(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new F(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new F(-h,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===N.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const et=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:m.ASC},this.level=u.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=A(this.element)),this.stores.db.db}render(){var t,i,e;if(void 0===this.chart)return s(h,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return s(h,null,s("p",{class:"warning"},t))}return s(h,null,s("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(i=this.chart)||void 0===i?void 0:i.getFooter()),s("div",{innerHTML:null===(e=this.chart)||void 0===e?void 0:e.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new ht(new y(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n),this.autoFitScaling(s,h),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new W(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new y(this.ruleSetConfig)),this.chart.setConfig(i),this.autoFitScaling(i,s),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new W(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,r=this.getDb();if(!n||n<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),this.chart=new ht(new y(this.ruleSetConfig),r,this.tableName,t,i),void this.chart.setI18n(this.i18n);h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),this.chart=new ht(new y(this.ruleSetConfig),r,this.tableName,t,i),this.chart.setI18n(this.i18n),this.chart.toString();const o=this.chart.getAllocatedCanvasWidth();if(o<=0)return;const a=this.chart.getMaxBarValue();h&&(t.pixelPerUnit=a>0?Math.max(.001,(n-(o-a))/a):.9*n/o),e&&(t.pixelPerPercentage=.9*n/o),this.chart=new ht(new y(this.ruleSetConfig),r,this.tableName,t,i),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?T(this.tableName,this.filter):"";return new H(new U,new w(new $),new $,new g,t,i).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig})}prepareStyle(){return new j(new K,new r,new o(new a),new O(new a),new l).adapt(this.styles)}get element(){return this}static get style(){return':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"ibcs-chart-structure",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function nt(){"undefined"!=typeof customElements&&["ibcs-chart-structure"].forEach((t=>{"ibcs-chart-structure"===t&&(customElements.get(e(t))||customElements.define(e(t),et))}))}export{et as I,nt as d}
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as i,h as s,Host as h,transformTag as e}from"@stencil/core/internal/client";import{S as n,F as r,a as o,b as a,P as l}from"./main.js";import{C as c,A as u,g as d,e as f}from"./CompareUtil.js";import{D as p,b as v}from"./DataFormatDigits.js";import{A as g,c as w,a as b,O as m}from"./Order.js";import{S as P}from"./SiPrefix.js";import{F as S,I as y,C as L,V as x}from"./formatter.js";import{g as M,a as k,I as C}from"./stackColors.js";import{c as T,a as A,s as $,M as O}from"./autoFit.js";import{d as _,g as E}from"./context-protocol.js";import{S as R}from"./StringAdapter.js";import{S as D}from"./SVGVariancesStyleGroup.js";class W{constructor(t,i,s,h,e,n,r,o,a=!1){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.spacings.barWidth-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,h){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<h/2&&(this.axisPosition.x=h/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class N{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class B{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class X{constructor(t){this.container=new n,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var V,Y,F,H,G;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(V||(V={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Y||(Y={}));class U{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new w(new R).default(),this.level=u.CATEGORY,this.filter="",this.measureScale=new P,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class j{constructor(t,i,s,h,e,n){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n}adapt(t){const i=g.adaptArray(t.data,this.dataRowAdapter),s=g.adaptArray(t.scenarios,this.stringAdapter),h=new U(i,s);return c.isArray(t.variances)&&(h.variances=g.adaptArray(t.variances,this.stringAdapter)),c.isString(t.title)&&(h.title=t.title),c.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),c.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),c.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),c.isNumber(t.limit)&&(h.limit=t.limit),c.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),c.isExisting(t.level)&&(h.level=t.level),c.isString(t.filter)&&(h.filter=t.filter.trim()),c.isExisting(t.measureScale)&&(h.measureScale=p.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale)),c.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),c.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),c.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),c.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),h}default(){return new U([],[])}}class z{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===h||h===F.NEG?F.NEG:"pos"===h||h===F.POS?F.POS:F.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:F.NEU===this.variance?F.NEU:F.POS===this.variance?F.NEG:F.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class I{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class K{constructor(){}adapt(t){const i=new I;return c.isOperator(t.operation)&&(i.operation=t.operation),c.isNumber(t.rowGroupIndex)&&c.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),c.isNumber(t.categoryIndex)&&c.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),c.isNumber(t.subCategoryIndex)&&c.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),c.isNumber(t.columnGroupIndex)&&c.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),c.isNumber(t.columnSubGroupIndex)&&c.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new I}setActualValues(t,i){c.isNumber(t.ac1)&&(i.ac1=t.ac1),c.isNumber(t.ac2)&&(i.ac2=t.ac2),c.isNumber(t.ac3)&&(i.ac3=t.ac3),c.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){c.isNumber(t.pl1)&&(i.pl1=t.pl1),c.isNumber(t.pl2)&&(i.pl2=t.pl2),c.isNumber(t.pl3)&&(i.pl3=t.pl3),c.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){c.isNumber(t.pp1)&&(i.pp1=t.pp1),c.isNumber(t.pp2)&&(i.pp2=t.pp2),c.isNumber(t.pp3)&&(i.pp3=t.pp3),c.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){c.isNumber(t.fc1)&&(i.fc1=t.fc1),c.isNumber(t.fc2)&&(i.fc2=t.fc2),c.isNumber(t.fc3)&&(i.fc3=t.fc3),c.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class q{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class Z{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new q(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return c.isExisting(t)&&(c.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),c.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),c.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),c.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),c.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),c.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.pattern=new B(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new q(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class J{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class Q{adapt(t){const i=new J;return c.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),c.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),c.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),c.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),c.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),c.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),c.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),c.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),c.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),c.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),c.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),c.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),c.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),c.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),c.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new J}}!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(F||(F={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(H||(H={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(G||(G={}));class tt{constructor(t,i,s,h,e,n,r,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.x=i,this.y=s,this.value=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||G.Top,this.horizontalHookLocation=o||G.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setMaxWidth(t){return this.maxWidth=t,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new P){var s;if(this.isEmpty())return this;const h=this.group;let e;const n=this.styles.fontStyles.background||"#ffffff";let r="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,h=t.percent,n=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,h=t.decimal,n=i.value,a="decimal"),e=S.number(Number(this.value),a,s,h,n),Number(this.value)<0&&(o="end"),this.isVarianceLabel&&Number(this.value)>=0&&(r="+")}else e=""+this.value,o="start";const a=h.text(r+e);a.move(this.x,this.y);const l=a.bbox().w,c=a.bbox().h;return null!=this.maxWidth&&l>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===G.Right?(o="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===G.Center&&(o="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===G.Center?a.move(a.x(),a.y()-c/2):this.verticalHookLocation===G.Bottom&&a.move(a.x(),a.y()-c),a.font({anchor:o}),null!=this.segmentFillColor?a.fill(M(this.segmentFillColor)):null==h||h.rect(l,.9*c).stroke(n).fill(n).opacity(.7).move(a.x(),a.y()+.1*c).insertBefore(a),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class it{constructor(t,i,s,h){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=h,this.label=new tt(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,G.Bottom,G.Center),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class st{constructor(t,i,s,h,e,n,r,o=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=G.Left;s.value<0&&(i=G.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new tt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,G.Center,i),this.scenarioLabel=this.getScenarioLabel(r)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new P){if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let s=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(s=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const h=this.convertToSVGStyle(s,"stroke");let e=this.convertToSVGStyle(s,"fill");const n=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=n){const t=this.styles.pattern.get(n);null!=t&&(e=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(e,h):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(e).stroke(h).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new P){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){return new tt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?G.Top:G.Bottom,G.Center)}}class ht{constructor(t,i,s,h,e,n,r,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new tt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?G.Bottom:G.Top,G.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class et{constructor(t,i,s,h,e){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=G.Left;s.value<0&&(i=G.Right),this.label=new tt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,G.Center,i),this.label.setToRelativeVarianceLabel()}}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;if(null==this.dimensions)return this;const i=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),s=i.stroke;let h=i.fill;const e=this.barStyles[this.dataPoint.getScenario()];if(null!=e&&e.fillpattern){const t=this.styles.pattern.get(e.fillpattern);null!=t&&null!=t.pattern&&(h=t.pattern)}this.drawNeedleHead(h,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(h).stroke(s).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(t=this.label)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,h=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(h)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}}class nt{constructor(t,i,s,h,e,n,r,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.baselineValue=e,this.segmentIndex=r,this.stackMode=o,this.totalValue=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new P){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,h=this.dataPoint.pixelPerUnit,e=this.position.getBarPositionX(),n=this.position.getBarWidth();let r,o;if(this.stackMode===d.RELATIVE){const t=h;r=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=e+this.baselineValue/Math.abs(this.totalValue)*t}else r=Math.abs(s*h),o=e+this.baselineValue*h;const a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},f={color:c,width:.5};this.barGroup.rect(Math.max(r,.5),n).fill(u).stroke(f).cy(a).x(o);const p=r-6;if(p>0){const h=o+r/2;if(this.stackMode===d.RELATIVE||this.stackMode===d.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new tt(this.group,h,a,"STACK_SEG",i,this.styles,G.Center,G.Center).setSegmentFill(c).setMaxWidth(p).draw()}else new tt(this.group,h,a,"STACK_SEG",s,this.styles,G.Center,G.Center).setSegmentFill(c).setMaxWidth(p).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new P){if(this.stackMode===d.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,h=this.position.getBarPositionY(this.index,!0);new tt(this.group,s,h,"STACK_TOTAL",this.totalValue,this.styles,G.Center,G.Left).draw(t,i)}}class rt{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new st(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new st(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new et(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new st(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new ht(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new ht(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class ot{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new z(0,F.AC1,1,F.NEU),this.highestDataPointValue=new z(0,F.AC1,1,F.NEU),this.smallestVarianceDataPointValue=new z(0,F.AC1,1,F.NEU),this.highestVarianceDataPointValue=new z(0,F.AC1,1,F.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=F.AC1,this.CSS_CATEGORIES="categories",this.state=V.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new P,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.highestStackedTotal=0,this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new y,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new W(new N(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new y}setConfig(t){var i;this.state=V.DIRTY,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.dataModel=this.populateModel(s,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==f.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.highestStackedTotal=this.findHighestStackedRowTotal(this.dataModel),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||S.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=V.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=V.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=_(this.tableName,t);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0}}getUnitBarExtent(){var t,i;const s=null!=this.stackConfig&&this.highestStackedTotal>0,h=this.getVarianceType(),e=h!==Y.NONE,n=e?this.highestVarianceDataPointValue:this.highestDataPointValue,r=e?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return T({fixedDomain:s?this.stackConfig.mode===d.RELATIVE?1:this.highestStackedTotal:void 0,relativeVariance:h===Y.RELATIVE,maxPositive:null!==(t=null==n?void 0:n.value)&&void 0!==t?t:0,minNegative:null!==(i=null==r?void 0:r.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,h;return A({relativeVariance:this.getVarianceType()===Y.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(h=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==h?h:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}toString(){const t=new n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===V.DIRTY&&(this.state=V.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=L(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":S.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=F.AC1;if(null!=t&&t.length>0){const s=new x(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=F.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${r}\n ORDER BY ${e}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new x(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(0===this.limit||this.limit>t.length)return;const h=[],e=t.slice(this.limit,t.length);this.createDataRows(e,h,i);const n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new z(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,F.NEU),scenario2:new z(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,F.NEU),scenario3:new z(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,F.NEU),scenario4:new z(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,F.NEU)}}),{id:9999,category:"REST",type:Y.NONE,scenario1:new z(0,i[0],this.pixelPerUnit,F.NEU),scenario2:new z(0,i[1],this.pixelPerUnit,F.NEU),scenario3:new z(0,i[2],this.pixelPerUnit,F.NEU),scenario4:new z(0,i[3],this.pixelPerUnit,F.NEU)});s.push(n)}createDataRows(t,i,s){let h=t;this.limit>0&&(h=t.slice(0,this.limit)),h.forEach(((t,h)=>{i.push({id:h,category:t.category,type:Y.NONE,scenario1:new z(t[s[0]],s[0],this.pixelPerUnit,F.NEU),scenario2:new z(t[s[1]],s[1],this.pixelPerUnit,F.NEU),scenario3:new z(t[s[2]],s[2],this.pixelPerUnit,F.NEU),scenario4:new z(t[s[3]],s[3],this.pixelPerUnit,F.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=`${i.hierarchy.toString()} ${null==i?void 0:i.direction}`),s}createSelectString(t,i){return t===u.CATEGORY&&i.hierarchy.includes(b.CATEGORYINDEX)?`${b.CATEGORYINDEX}, ${u.CATEGORY} as category`:t===u.ROWGROUP&&i.hierarchy.includes(b.ROWGROUPINDEX)?`${b.ROWGROUPINDEX}, ${u.ROWGROUP} as category`:t===u.SUBCATEGORY&&i.hierarchy.includes(b.SUBCATEGORYINDEX)?`${b.SUBCATEGORYINDEX}, ${u.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===u.CATEGORY&&i.hierarchy.includes(b.CATEGORYINDEX)?`${b.CATEGORYINDEX}, ${u.CATEGORY}`:t===u.ROWGROUP&&i.hierarchy.includes(b.ROWGROUPINDEX)?`${b.ROWGROUPINDEX}, ${u.ROWGROUP}`:t===u.SUBCATEGORY&&i.hierarchy.includes(b.SUBCATEGORYINDEX)?`${b.SUBCATEGORYINDEX}, ${u.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=L(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new z(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new z(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}findHighestStackedRowTotal(t){if(!this.stackConfig||0===t.length)return 0;const i=this.stackConfig.by===f.SCENARIOS;let s=0;for(const h of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=h[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>k(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=k(t.scenario);i.set(s,(i.get(s)||0)+Math.abs(t.value))}t=Math.max(...i.values())}else t=s.reduce(((t,i)=>t+Math.abs(i.value)),0)}else h.stackSegments&&h.stackSegments.length>0&&(t=h.stackSegments.reduce(((t,i)=>t+Math.abs(i.value)),0));t>s&&(s=t)}return s}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new x(t[e]);if(n.isValid){const t=this.mapScenarios(n,h),e=n.direction;let r=this.pixelPerUnit;"dr"===n.type&&(r=this.pixelPerPercentage);for(const h in i)s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?Y.RELATIVE:Y.ABSOLUTE,scenario1:new z(this.calculateVariance(n,i[h],t),n.base,r,e),scenario2:new z(null,null,null,null),scenario3:new z(null,null,null,null),scenario4:new z(null,null,null,null)})}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===Y.RELATIVE?(i[h].value-i[e].value)/i[e].value:i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t){return L(S.number(t,"decimal",1,0),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;return t>=0&&(i+=L("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=L(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,L(S.number(t,"decimal",1,1),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i){const s=i.group().id("AxisAndDateLables");let h=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===Y.RELATIVE&&(h=!0);let e=G.Right,n=!0;t.scenario1.value<0&&(e=G.Left,n=!1),new tt(s,this.position.getCategoryPositionX(n),this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,G.Center,e).draw()})),new it({scenarioType:this.axisScenario,labelText:this.title,isRelative:h},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),h=new rt(this.position,s,this.styles,t.length,this.i18n);h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{h.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),h.createSecondaryBar(t.scenario2,i).draw(),h.createPrimaryMarker(t.scenario3,i).draw(),h.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new rt(this.position,s,this.styles,t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===Y.RELATIVE?h.createRelativeVarianceBar(t.scenario1,i).draw():h.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===f.SCENARIOS;t.forEach(((t,i)=>{const e=["scenario1","scenario2","scenario3","scenario4"],n=[];if(h){for(const i of e){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&n.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(n)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&n.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==n.length)if((h?new Set(n.map((t=>k(t.scenario)))):new Set).size>1){const t=new Map;for(const i of n){const s=k(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const h=[];for(const i of C)t.has(i)&&(h.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)h.push({prefix:i,segments:s});h.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=h.length-1-e;let o=0,a=null;t.segments.forEach((t=>{const h=new nt(this.position,this.styles,t.dataPoint,i,o,t.scenario,r,this.stackConfig.mode,n,!0,s);h.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=h})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let e=n;!h&&t.stackSegments&&t.stackSegments.length>0&&(e=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?e.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&e.sort(((t,i)=>i.value-t.value));const r=e.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,a=null;e.forEach(((t,e)=>{const n=new nt(this.position,this.styles,t.dataPoint,i,o,t.scenario,e,this.stackConfig.mode,r,h,s);n.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=n})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===f.SCENARIOS,h=i.group().id("StackedHeaders"),e=t[0];if(!s){const t=e.stackSegments;if(!t||0===t.length)return;const i=[...t];"asc"===this.stackConfig.order?i.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&i.sort(((t,i)=>i.value-t.value));const s=i.reduce(((t,i)=>t+Math.abs(i.value)),0),n=this.position.getBarPositionX(),r=this.position.getStackedHeaderPositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let e;e=this.stackConfig.mode===d.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const a=n+o+e/2,l=this.i18n.get(t.label)||t.label;new tt(h,a,r,"STACK_HEADER",l,this.styles,G.Bottom,G.Center).draw(),o+=e}))}const n=["scenario1","scenario2","scenario3","scenario4"],r=[];for(const t of n){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===r.length)return;this.sortSegmentsByPropOrder(r);const o=new Set(r.map((t=>k(t.scenario)))),a=this.position.getBarPositionX(),l=this.position.getStackedHeaderPositionY();if(o.size>1){const t=new Map;for(const i of r){const s=k(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of C)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,h]of t)i.push({prefix:s,segments:h});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,e=a+(this.stackConfig.mode===d.RELATIVE?s:i*s)/2,n=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new tt(h,e,l,"STACK_HEADER",n,this.styles,G.Bottom,G.Center).draw()}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0);let i=0;r.forEach((s=>{const e=s.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===d.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*e:Math.abs(s.value*e);const r=a+i+n/2,o=this.i18n.get(s.scenario)||s.scenario;new tt(h,r,l,"STACK_HEADER",o,this.styles,G.Bottom,G.Center).draw(),i+=n}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:Y.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Y.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(Y.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(Y.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===d.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Y.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);e=Math.abs(this.highestDataPointValue.getScaledUnit())+n+t}else if(Y.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(Y.ABSOLUTE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const h={[u.ROWGROUP]:"category",[u.ROWGROUPINDEX]:"category",[u.CATEGORY]:"subCategory",[u.CATEGORYINDEX]:"subCategory"}[s];if(!h)return;const e=s.toString(),n=t[0];let r;try{r=this.db.exec(`SELECT [${e}] as displayGroup, [${h}] as stackLabel, SUM([${n}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${e}], [${h}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of r){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new z(t.value,n,this.pixelPerUnit,F.NEU)}))):[]}}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new z(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new z(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new z(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new z(-h,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===Y.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const at=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:m.ASC},this.level=u.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=E(this.element)),this.stores.db.db}render(){var t,i,e;if(void 0===this.chart)return s(h,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return s(h,null,s("p",{class:"warning"},t))}return s(h,null,s("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(i=this.chart)||void 0===i?void 0:i.getFooter()),s("div",{innerHTML:null===(e=this.chart)||void 0===e?void 0:e.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new ot(new y(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n);const e=s.pixelPerUnit<=0;this.autoFitScaling(s,h),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new X(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new y(this.ruleSetConfig)),this.chart.setConfig(i);const h=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(h?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new X(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:h?t.pixelPerUnit:void 0,percentage:e?t.pixelPerPercentage:void 0})},r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),a=()=>{this.chart=new ot(new y(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.toString(),this.chart.getAllocatedCanvasWidth());if(!r||r<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),a(),void n();h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void n();const u=Math.max(O,.9*r/c);let d=!1,f=!1,p=null;for(let i=0;i<=3;i++){const i=$({target:r,measured:c,unitExtent:h?this.chart.getUnitBarExtent():0,pctExtent:e?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(h&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),e&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=r+.5&&(p={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*r))break}let v=!1;if(h&&!d&&(t.pixelPerUnit=u,v=!0),e&&!f&&(t.pixelPerPercentage=u,v=!0),c>r+.5){if(p)d&&(t.pixelPerUnit=p.ppu),f&&(t.pixelPerPercentage=p.ppp);else{const i=r/c;h&&(t.pixelPerUnit=Math.max(O,t.pixelPerUnit*i)),e&&(t.pixelPerPercentage=Math.max(O,t.pixelPerPercentage*i))}v=!0}v&&a(),n()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?_(this.tableName,this.filter):"";return new j(new K,new w(new R),new R,new v,t,i).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig})}prepareStyle(){return new Z(new Q,new r,new o(new a),new D(new a),new l).adapt(this.styles)}get element(){return this}static get style(){return':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"ibcs-chart-structure",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],reportAutoScaling:[16],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function lt(){"undefined"!=typeof customElements&&["ibcs-chart-structure"].forEach((t=>{"ibcs-chart-structure"===t&&(customElements.get(e(t))||customElements.define(e(t),at))}))}export{at as I,lt as d}
|