@bino-bi/bn-template-engine 1.0.0-alpha.12 → 1.0.0-alpha.13
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-3c827826.entry.js +1 -0
- package/dist/bn-template-engine/{p-3b73ffc7.entry.js → p-82023539.entry.js} +1 -1
- package/dist/bn-template-engine/p-BjBz5cSL.js +1 -0
- package/dist/cjs/bn-asset_21.cjs.entry.js +46 -19
- package/dist/cjs/bn-internationalization.cjs.entry.js +1 -1
- package/dist/cjs/{withBodyObserver-D7BKWN2N.js → withBodyObserver-BKUE_ypL.js} +12 -7
- package/dist/collection/components/bn-dataset/bn-dataset.js +33 -14
- package/dist/collection/components/bn-datasource/bn-datasource.js +12 -4
- package/dist/collection/utils/withBodyObserver.js +12 -7
- package/dist/components/bn-dataset.js +1 -1
- package/dist/components/bn-datasource.js +1 -1
- package/dist/components/withBodyObserver.js +1 -1
- package/dist/esm/bn-asset_21.entry.js +46 -19
- package/dist/esm/bn-internationalization.entry.js +1 -1
- package/dist/esm/{withBodyObserver-AFk2wwHT.js → withBodyObserver-IokS6fHD.js} +12 -7
- package/package.json +1 -1
- package/dist/bn-template-engine/p-230095a5.entry.js +0 -1
- package/dist/bn-template-engine/p-DSXNgKLa.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as i,H as s,g as e,f as n,d as r,e as h,F as o}from"./p-B_d-jp99.js";import{w as a,a as l,r as c}from"./p-B4JfKvVT.js";import{g as u,c as d,a as f,b as p,d as v,D as m,e as g}from"./p-DHheVOfP.js";import{w as b}from"./p-DSXNgKLa.js";import{a as w,v as y,c as S,b as x,d as O,e as _,f as M,g as R,i as $,h as k,j as E,w as T,k as P,A as L,O as A,l as C,S as N,m as D,n as U,o as G,p as F,D as W,q as Y,C as z,r as I,s as B,t as H,u as j,x as V,y as X,z as J,B as q,E as Q,F as K,I as Z,T as tt,M as it,G as st,H as et,J as nt,K as rt,L as ht,N as ot,P as at,Q as lt,R as ct,U as ut}from"./p-BVFHvEXF.js";import{a as dt,w as ft,g as pt,p as vt}from"./p-CQnZV3JG.js";const mt=class{constructor(i){t(this,i),a(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=u(this.element));try{const i=t.replace(/\s/g,"");this.stores.assets.set(this.name,i)}catch(i){console.error("Error parsing asset",i,t),this.stores.assets.set(this.name,void 0)}}))}render(){return i(s,{key:"dfec9f90136278bddab194479301aa3fa5bc1e72"})}get element(){return e(this)}};mt.style=":host{display:none}";const gt=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=w(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"f43978af1c6658c6fa165093c3ada6b5f3b5986d",style:this.getFontStyles()},i("slot",{key:"b9c97432089676fc373b1d5ee59573ef5681a5c5"}))}get element(){return e(this)}};gt.style=':host{flex:1;min-height:0;position:relative;overflow:hidden;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const bt=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=w(this)}render(){return i(s,{key:"92bcbc010336d3a542c86e182831bbfddda2aa9b",style:this.prepareStyle()},i("slot",{key:"d836aa5443283df158dcb50345aee0df97f74a6e"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}};bt.style=':host{display:flex;flex-direction:column;justify-content:space-between;flex:1;min-height:0;padding:0.25em;margin:0.5em;background-origin:content-box;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(.border){box-sizing:border-box;-webkit-box-sizing:border-box;border:0.1em solid #ddd}div{color:var(--bn-font-color, black)}';const wt=t=>{let i,s;const r=()=>{"function"==typeof t.validateUnitScaling&&t.validateUnitScaling(t.unitScaling),"function"==typeof t.validatePercentageScaling&&t.validatePercentageScaling(t.percentageScaling)},h=t.connectedCallback;t.connectedCallback=()=>{const o=e(t);s=u(o),(()=>{const i=s.scalingGroups.state;for(const s of Object.keys(i))void 0!==i[s]?t.pixelPerUnitGroupMap.set(s,i[s]):t.pixelPerUnitGroupMap.delete(s)})(),r(),i=s.scalingGroups.on("set",((i,s)=>{void 0!==s?t.pixelPerUnitGroupMap.set(i,s):t.pixelPerUnitGroupMap.delete(i),r(),n(e(t))})),c(h,t)};const o=t.disconnectedCallback;t.disconnectedCallback=()=>{c(i),d(e(t)),c(o,t)}},yt="inherited-page",St="bn-layout-page";function xt(t){return"inherited-closest"===t||t===yt}function Ot(t,i){let s=t.parentNode;for(;s;){if(s instanceof HTMLElement){const t=s.nodeName.toLowerCase();if(i===yt){if(t===St)return s}else if("bn-layout-card"===t||t===St)return s}if(s.parentNode)s=s.parentNode;else{if(!(s instanceof ShadowRoot))break;s=s.host}}}const _t=(t,i)=>{const s=new Map;let r,h=null;const o=t.connectedCallback;t.connectedCallback=()=>{(()=>{const o=e(t);s.clear();const a=[];for(const e of i){const i=t[e.propName];if("string"!=typeof i||!xt(i))continue;if(r||(r=Ot(o,i)),!r)continue;const n=r.getAttribute(e.ancestorAttr);null!=n&&s.set(e.propName,n),a.push(e.ancestorAttr)}r&&a.length>0&&(h=new MutationObserver((()=>{for(const e of i){if(!xt(t[e.propName]))continue;const i=r.getAttribute(e.ancestorAttr);null!=i?s.set(e.propName,i):s.delete(e.propName)}n(t)})),h.observe(r,{attributes:!0,attributeFilter:a}))})(),c(o,t)};const a=t.disconnectedCallback;return t.disconnectedCallback=()=>{h&&(h.disconnect(),h=null),r=void 0,s.clear(),c(a,t)},(t,i)=>{if(xt(i))return s.get(t)}};function Mt(t,i,s=80){let e=null,n=!1,r=-1,h=-1;const o=function(t){var i;const s=t.parentElement;return(null===(i=null==s?void 0:s.assignedSlot)||void 0===i?void 0:i.parentElement)?s.assignedSlot.parentElement:s}(t);if(!o)return{disconnect(){}};const a=new ResizeObserver((t=>{var a;if(n)return;let l,c;const u=t[0];if(null===(a=null==u?void 0:u.contentBoxSize)||void 0===a?void 0:a.length){const t=u.contentBoxSize[0];l=t.inlineSize,c=t.blockSize}else l=o.clientWidth,c=o.clientHeight;Math.abs(l-r)<=2&&Math.abs(c-h)<=2||(r=l,h=c,null!=e&&clearTimeout(e),e=setTimeout((()=>{n||i()}),s))}));return a.observe(o),{disconnect(){n=!0,null!=e&&clearTimeout(e),a.disconnect()}}}const Rt=class{validateScenario(t){const i="ERR_scenarios";if(xt(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(xt(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="ERR_unitScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||x(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||x(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const i="ERR_level";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(xt(t))return void this.errors.remove(i);const s=_(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";xt(t)||M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLimit(t){const i="ERR_limit";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowCategories(t){const i="ERR_showCategories";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";k(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateStack(t){const i="ERR_stack",s=E(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(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(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,T(this),a(this),dt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),wt(this),this.componentStyle=w(this),this.t=ft(this).t,this.resolveInherited=_t(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){const{mode:t}=vt(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkWidthOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkWidthOverflow();const i=this.element,{height:s}=pt(i);if(s<=0)return void this.checkWidthOverflow();this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollHeight,h=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkWidthOverflow();const o=Math.max(.3,h*(s-1)/n);Math.abs(o-h)<.01||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=o}))),this.checkWidthOverflow()}componentDidLoad(){this.layoutObserver=Mt(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=pt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=pt(this.element);this._lastScaledParentHeight=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}checkWidthOverflow(){var t;const i="WARN_overflow",s=String(null!==(t=this.unitScaling)&&void 0!==t?t:"").trim().toLowerCase();if(""===s||"auto"===s)return void this.errors.remove(i);const e=pt(this.element);e.width>0&&this.element.scrollWidth>e.width+1?this.errors.addOrReplace({id:i,type:"error",message:`Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(e.width)}px). Reduce unit-scaling or set to "auto".`}):this.errors.remove(i)}prepareDimension(){const t=pt(this.element),i=this.prepareVariances();return this.canvasWidthSegmented=t.width/(1+i.length),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return P(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?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):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):P(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=f,i=new Map([].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){var t;if(this.pixelPerUnitGroupMap.has(this.percentageScaling))return this.pixelPerUnitGroupMap.get(this.percentageScaling);if("auto"===(null===(t=this.percentageScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_percentageScaling"),0;const i=Number(this.percentageScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_percentageScaling"),100*i):(this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:"percentage-scaling: not set, auto-calculated to fit available space."}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return P(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),L[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),L[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let h;return P(e)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),h=this.datasetMeta.suggestedOrder):h=e:(this.errors.remove("AUTO_order"),h=e),{hierarchy:null==h?void 0:h.split(",").map((t=>C[null==t?void 0:t.toUpperCase()])),direction:A[null==n?void 0:n.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(P(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===N.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||U.ABSOLUTE,order:t.order||D.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{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:""}}}}prepareMeasureScale(){return P(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"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,s){const e=this.getEffectiveScaleFactor(),n=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),h=this.prepareStackConfig(),o=this.prepareScenarios(),a=(null==h?void 0:h.by)===N.DIMENSIONS?o.slice(0,1):o;return i("ibcs-chart-structure",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:a,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:n>0?n*e:0,pixelPerPercentage:r>0?r*e:0,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(s),stackConfig:h,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:t,factor:i}=vt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const h=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":h*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"0af8bafa9e2e24eda4f09a9b1f9f9dfed9a34b0b",style:n},i("div",{key:"eb8b0337984e0207783b84d90438f0d32010fd21",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};Rt.style=':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}';class $t{constructor(t){this.type="",this.base="",this.delta="",this.direction="",this.isValid=!1;const i=/(d|dr)(pl\d|ac\d|fc\d|pp\d)_(pl\d|ac\d|fc\d|pp\d)_(pos|neg|neu)/;if(i.test(t)){const s=i.exec(t);null!=s&&(this.type=String(s[1]),this.base=String(s[2]),this.delta=String(s[3]),this.direction=String(s[4]),this.isValid=!0)}}}var kt;!function(t){t.OPERATION="operation",t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CURRENTROW="currentRow",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex",t.COLUMNGROUP="columnGroup",t.COLUMNGROUPINDEX="columnIndex",t.COLUMNSUBGROUP="columnSubGroup",t.COLUMNSUBGROUPINDEX="columnSubGroupIndex",t.AC1="ac1",t.AC2="ac2",t.AC3="ac3",t.AC4="ac4",t.PP1="pp1",t.PP2="pp2",t.PP3="pp3",t.PP4="pp4",t.FC1="fc1",t.FC2="fc2",t.FC3="fc3",t.FC4="fc4",t.PL1="pl1",t.PL2="pl2",t.PL3="pl3",t.PL4="pl4",t.TOTALROWCOUNT="totalRowCnt",t.ROWNR="rowNr",t.TYPE="type"}(kt||(kt={}));var Et,Tt,Pt={},Lt=p(function(){if(Et)return Pt;Et=1;var t={};return Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.default=function(i,s){void 0===s&&(s={});var e=JSON.stringify({text:i,options:s});if(t[e])return t[e];s.font=s.font||"Times",s.fontSize=s.fontSize||"16px",s.fontWeight=s.fontWeight||"normal",s.width=s.width||"auto";var n=function(t,i){var s=document.createElement("div"),e=document.createTextNode(t);return s.appendChild(e),s.style.fontFamily=i.font,s.style.fontSize=i.fontSize,s.style.fontWeight=i.fontWeight,s.style.position="absolute",s.style.visibility="hidden",s.style.left="-999px",s.style.top="-999px",s.style.width=i.width,s.style.height="auto",document.body.appendChild(s),s}(i,s),r={width:n.offsetWidth,height:n.offsetHeight};return function(t){t.parentNode.removeChild(t)}(n),t[e]=r,r},Pt}());class At{static number(t,i="decimal",s=1,e=0,n=1){return(t/n).toLocaleString("de-DE",{style:i,useGrouping:!0,maximumFractionDigits:s,minimumFractionDigits:e}).replace(/\s+(%)/g,"$1").replace(/\s/g,this.postfixSeperator).replace(/\./g,this.tsdDelimiter)}static translateScenarioLabel(t,i){if(null==t)return"";const s=new $t(t);if(!s.isValid)return`${i.get(t)||t}`;let e,n;return kt.AC1===s.base?(e=i.get("dr"===s.type?"ibcssymbol_delta_ac_relative":"ibcssymbol_delta_ac"),n=i.get(s.delta)||s.delta):(e=i.get("dr"===s.type?"ibcssymbol_delta_generic_relative":"ibcssymbol_delta_generic"),n=`${i.get(s.base)||s.base} - ${i.get(s.delta)||s.delta}`),void 0===e&&(e="{%}"),`${e.replace("{%}",n)}`}static getMaxWidthOfArrayItems(t,i,s){return Lt(t.map((t=>At.translateScenarioLabel(t,i))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:s.fontStyles.font,fontSize:s.fontStyles.size+"px"}).width}}At.tsdDelimiter=".",At.postfixSeperator=",",function(t){t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex"}(Tt||(Tt={}));const Ct=class{validateScenario(t){const i="ERR_scenarios";if(xt(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(xt(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="ERR_syncSpaceLeft";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateLimit(t){const i="ERR_limit";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||x(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";"auto"===(null==t?void 0:t.toString().trim().toLowerCase())||x(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const i="ERR_level";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(xt(t))return void this.errors.remove(i);const s=_(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";xt(t)||M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateInterval(t){const i="ERR_dateInterval";G(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateChartMode(t){const i="ERR_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="ERR_maxBars";!R(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="ERR_stack",s=E(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(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")}validateAxisLabelsMode(t){const i="ERR_axisLabelsMode";F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLineFullWidth(t){const i="ERR_lineFullWidth";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"lineFullWidth: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowCategories(t){const i="ERR_showCategories";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";k(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayAvg(t){const i="ERR_grouped";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayAvg: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayMedian(t){const i="ERR_grouped";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayMedian: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.limit=0,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth="true",this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.showOverlayAvg="true",this.showOverlayMedian="false",this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,T(this),a(this),dt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),wt(this),this.componentStyle=w(this),this.t=ft(this).t,this.resolveInherited=_t(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLimit(this.limit),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateLineFullWidth(this.lineFullWidth),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateShowOverlayAvg(this.showOverlayAvg),this.validateShowOverlayMedian(this.showOverlayMedian),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){const{mode:t}=vt(this.scale);if("auto"!==t&&"empty"!==t){this._autoScaleGuard=!1;const t=pt(this.element),i="WARN_overflow";return void(t.width>0&&this.element.scrollWidth>t.width+1?this.errors.addOrReplace({id:i,type:"warning",message:"Chart exceeds available space and will be cut off. Check unit-scaling value."}):this.errors.remove(i))}if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:s}=pt(i);if(s<=0)return;this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,h=this.appliedScaleFactor;if(n<=s+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,h*(s-1)/n);Math.abs(o-h)<.01||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=o})))}componentDidLoad(){this.layoutObserver=Mt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=pt(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=pt(this.element);this._lastObservedWidth=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}prepareDimension(){const t=pt(this.element),i=this.prepareScenarios(),s=this.prepareVariances();return this.canvasWidthSegmented=t.width/(i.length+s.length||1),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return P(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?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):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareAvg(){return"true"===this.showOverlayAvg}prepareMedian(){return"true"===this.showOverlayMedian}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):P(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideAxisLabels(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=f,i=new Map([].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){var t;if(this.pixelPerUnitGroupMap.has(this.percentageScaling))return this.pixelPerUnitGroupMap.get(this.percentageScaling);if("auto"===(null===(t=this.percentageScaling)||void 0===t?void 0:t.toString().trim().toLowerCase()))return this.errors.remove("AUTO_percentageScaling"),0;const i=Number(this.percentageScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_percentageScaling"),100*i):(this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:"percentage-scaling: not set, auto-calculated to fit available space."}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return P(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),Tt[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),Tt[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t,i,s;const e=this.resolveInherited("order",this.order),n=this.resolveInherited("orderDirection",this.orderDirection),r=null!=e?e:this.order,h=null!=n?n:this.orderDirection;let o=(P(this.level)||"auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase()))&&(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?this.datasetMeta.suggestedLevel:this.level;const a="auto"===(null==r?void 0:r.trim().toLowerCase());return P(r)||a?(null===(s=this.datasetMeta)||void 0===s?void 0:s.suggestedLevel)&&(a?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${o}`})):(this.errors.remove("AUTO_order"),"levelindex"===(null==r?void 0:r.toLocaleLowerCase())&&(o+="Index")),{hierarchy:[C[null==o?void 0:o.toUpperCase()]],direction:A[null==h?void 0:h.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:.3,labelToColum:i["bn-chart-time"].scaleFactors.labelToColum,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:At.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return P(this.dateInterval)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(e?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:`dateInterval: not set, auto-detected: ${this.datasetMeta.suggestedDateInterval}`}),W[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?W.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),W[null===(s=this.dateInterval)||void 0===s?void 0:s.toUpperCase()])}prepareIntervalSpanLimit(){return this.intervalSpanLimit}prepareAxisLabelsMode(){var t;return Y[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{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:""}}}}prepareMeasureScale(){return P(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"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(P(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===N.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||U.ABSOLUTE,order:t.order||D.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return"true"===this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?z.LINE:"auto"===i?z.AUTO:z.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=pt(this.element).width,h=this.getEffectiveScaleFactor(),o=this.preparePixelPerUnit(),a=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),c=this.prepareScenarios(),u=(null==l?void 0:l.by)===N.DIMENSIONS?c.slice(0,1):c;return i("ibcs-chart-time",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:u,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(s),pixelPerUnit:o>0?o*h:0,pixelPerPercentage:a>0?a*h:0,limit:this.prepareLimit(),leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,n),styles:n,i18n:e,order:this.prepareOrder(),level:this.prepareLevel(),dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(s),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:t,factor:i}=vt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const h=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":h*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"fbef96ebdfa241564095c6def748082bfec0e6a4",style:n},i("div",{key:"77d3168f126a779db1e0fbeed2f8a220a2f36792",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}}};Ct.style=":host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}";const Nt=class{constructor(i){t(this,i),this.name="_default",a(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=u(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("JSON_PARSE")}catch(t){this.errors.addOrReplace({id:"JSON_PARSE",type:"error",message:`bn-component-style: Failed to parse JSON body — ${t.message}`}),console.error(t)}}))}render(){return i(s,{key:"e9298c6ce5b0b51260165e78dcf19efdef0646f9"})}get element(){return e(this)}};Nt.style="bn-component-style{display:none}";const Dt=class{constructor(i){t(this,i),this.currentPageUpdate=void 0,a(this),this.errors=l(this)}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=v(this.element),this.locale&&(this.stores.context.state.locale=this.locale),this.currentPageUpdate=setTimeout((()=>{this.element.querySelectorAll("bn-page, bn-layout-page").forEach(((t,i)=>{if("bn-layout-page"===t.localName)t.setAttribute("page-number",(i+1).toString());else{const s=t.querySelector("bn-footer");s&&s.setAttribute("page-number",(i+1).toString())}}))}),250)}disconnectedCallback(){this.currentPageUpdate&&clearTimeout(this.currentPageUpdate)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"b92019b909e271225baca2cf740c8301e324164e"},i("slot",{key:"87bac4bb29bca32d961afe31355dc1bd48fff0f8"}))}get element(){return e(this)}static get watchers(){return{locale:[{setLocale:0}]}}};Dt.style=":host{display:block}";const Ut=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],Gt=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function Ft(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function Wt(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var Yt=Uint8Array,zt=Uint16Array,It=Int32Array,Bt=new Yt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ht=new Yt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),jt=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vt=function(t,i){for(var s=new zt(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new It(s[30]);for(e=1;e<30;++e)for(var r=s[e];r<s[e+1];++r)n[r]=r-s[e]<<5|e;return{b:s,r:n}},Xt=Vt(Bt,2),Jt=Xt.b,qt=Xt.r;Jt[28]=258,qt[258]=28;for(var Qt=Vt(Ht,0).b,Kt=new zt(32768),Zt=0;Zt<32768;++Zt){var ti=(43690&Zt)>>1|(21845&Zt)<<1;Kt[Zt]=((65280&(ti=(61680&(ti=(52428&ti)>>2|(13107&ti)<<2))>>4|(3855&ti)<<4))>>8|(255&ti)<<8)>>1}var ii=function(t,i,s){for(var e=t.length,n=0,r=new zt(i);n<e;++n)t[n]&&++r[t[n]-1];var h,o=new zt(i);for(n=1;n<i;++n)o[n]=o[n-1]+r[n-1]<<1;if(s){h=new zt(1<<i);var a=15-i;for(n=0;n<e;++n)if(t[n])for(var l=n<<4|t[n],c=i-t[n],u=o[t[n]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)h[Kt[u]>>a]=l}else for(h=new zt(e),n=0;n<e;++n)t[n]&&(h[n]=Kt[o[t[n]-1]++]>>15-t[n]);return h},si=new Yt(288);for(Zt=0;Zt<144;++Zt)si[Zt]=8;for(Zt=144;Zt<256;++Zt)si[Zt]=9;for(Zt=256;Zt<280;++Zt)si[Zt]=7;for(Zt=280;Zt<288;++Zt)si[Zt]=8;var ei=new Yt(32);for(Zt=0;Zt<32;++Zt)ei[Zt]=5;var ni=ii(si,9,1),ri=ii(ei,5,1),hi=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},oi=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},ai=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},li=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ci=function(t,i,s){var e=new Error(i||li[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,ci),!s)throw e;return e},ui=new Yt(0);function di(t,i){var s,e,n=function(t){31==t[0]&&139==t[1]&&8==t[2]||ci(6,"invalid gzip data");var i=t[3],s=10;4&i&&(s+=2+(t[10]|t[11]<<8));for(var e=(i>>3&1)+(i>>4&1);e>0;e-=!t[s++]);return s+(2&i)}(t);return n+8>t.length&&ci(6,"invalid gzip data"),function(t,i,s,e){var n=t.length;if(!n||i.f&&!i.l)return s||new Yt(0);var r=!s,h=r||2!=i.i;r&&(s=new Yt(3*n));var o,a,l=function(t){var i=s.length;if(t>i){var e=new Yt(Math.max(2*i,t));e.set(s),s=e}},c=i.f||0,u=i.p||0,d=i.b||0,f=i.l,p=i.d,v=i.m,m=i.n,g=8*n;do{if(!f){c=oi(t,u,1);var b=oi(t,u+1,3);if(u+=3,!b){var w=t[(T=4+((u+7)/8|0))-4]|t[T-3]<<8,y=T+w;if(y>n){ci(0);break}h&&l(d+w),s.set(t.subarray(T,y),d),i.b=d+=w,i.p=u=8*y,i.f=c;continue}if(1==b)f=ni,p=ri,v=9,m=5;else if(2==b){var S=oi(t,u,31)+257,x=oi(t,u+10,15)+4,O=S+oi(t,u+5,31)+1;u+=14;for(var _=new Yt(O),M=new Yt(19),R=0;R<x;++R)M[jt[R]]=oi(t,u+3*R,7);u+=3*x;var $=hi(M),k=(1<<$)-1,E=ii(M,$,1);for(R=0;R<O;){var T,P=E[oi(t,u,k)];if(u+=15&P,(T=P>>4)<16)_[R++]=T;else{var L=0,A=0;for(16==T?(A=3+oi(t,u,3),u+=2,L=_[R-1]):17==T?(A=3+oi(t,u,7),u+=3):18==T&&(A=11+oi(t,u,127),u+=7);A--;)_[R++]=L}}var C=_.subarray(0,S),N=_.subarray(S);v=hi(C),m=hi(N),f=ii(C,v,1),p=ii(N,m,1)}else ci(1);if(u>g){ci(0);break}}h&&l(d+131072);for(var D=(1<<v)-1,U=(1<<m)-1,G=u;;G=u){var F=(L=f[ai(t,u)&D])>>4;if((u+=15&L)>g){ci(0);break}if(L||ci(2),F<256)s[d++]=F;else{if(256==F){G=u,f=null;break}var W=F-254;F>264&&(W=oi(t,u,(1<<(I=Bt[R=F-257]))-1)+Jt[R],u+=I);var Y=p[ai(t,u)&U],z=Y>>4;if(Y||ci(3),u+=15&Y,N=Qt[z],z>3){var I=Ht[z];N+=ai(t,u)&(1<<I)-1,u+=I}if(u>g){ci(0);break}h&&l(d+131072);var B=d+W;if(d<N){var H=0-N,j=Math.min(N,B);for(H+d<0&&ci(3);d<j;++d)s[d]=e[H+d]}for(;d<B;++d)s[d]=s[d-N]}}i.l=f,i.p=G,i.b=d,i.f=c,f&&(c=1,i.m=v,i.d=p,i.n=m)}while(!c);return d!=s.length&&r?(o=s,(null==(a=d)||a>o.length)&&(a=o.length),new Yt(o.subarray(0,a))):s.subarray(0,d)}(t.subarray(n,-8),{i:2},new Yt(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var fi="undefined"!=typeof TextDecoder&&new TextDecoder;try{fi.decode(ui,{stream:!0})}catch(t){}function pi(t){return I(t)}function vi(t){const i=t.indexOf(":");if(-1===i)throw new Error("Invalid compressed format: missing ':' separator");const s=t.slice(0,i),e=t.slice(i+1),n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const h=di(r);return{hash:s,json:(new TextDecoder).decode(h)}}const mi=class{constructor(i){t(this,i),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,a(this),this.errors=l(this),((t,i)=>{let s,n=[],r=[];const h=t=>{let e;try{e=s.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){e=[]}i()},o=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(s.db.subscribe(t,(()=>h(t)))),h(t))}))},a=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(e(t).getAttribute("datasources")||"").split(","),o())}))})),l=t.connectedCallback;t.connectedCallback=()=>{const i=e(t);s=u(i),r=(i.getAttribute("datasources")||"").split(","),o(),a.observe(i,{attributes:!0,attributeFilter:["datasources"]}),c(l,t)};const f=t.disconnectedCallback;t.disconnectedCallback=()=>{a.disconnect(),n.forEach((t=>t())),n=[],d(e(t)),c(f,t)}})(this,(()=>{this.executeQuery()})),b(this,(t=>{const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastBodyHash=null,this.fetchAndStore(i),void this.startPolling()}let s,e;if(null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null),!this.raw&&this.static)try{const i=vi(t);s=i.hash,e=i.json}catch(i){return void console.error("Error decoding compressed dataset",i,String(t).slice(0,200))}else s=pi(t),e=t;s!==this.lastBodyHash&&(this.lastBodyHash=s,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=u(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let i;if(this.static){try{i=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),i=[]}t.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query)try{t.views&&null!=t.views[this.name]&&t.exec(`DROP VIEW \`${this.name}\``),t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,i=[],void this.publish(i)}try{i=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){console.error("bn-dataset: SQL execution failed",t,this.query),i=[]}}this.publish(i)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const i={};for(const t of Gt)i[t]=new Set;const s={};for(const t of Ut)s[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const h=Array.isArray(t)?t:[];for(let t=0;t<h.length;t++){const o=h[t];if(null==o)continue;for(const t of Gt){const s=o[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of Ut){const i=o[t];if(Ft(i)){const e=s[t];e.hasData=!0,(null===e.min||i<e.min)&&(e.min=i),(null===e.max||i>e.max)&&(e.max=i)}}const a=o.date;if(null!=a&&""!==a){const t=String(a);e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const o=Ut.map((t=>({key:t,hasData:s[t].hasData,min:s[t].min,max:s[t].max}))),a=o.filter((t=>t.hasData)).map((t=>t.key)),l=Wt(i.rowGroup),c=Wt(i.category),u=Wt(i.subCategory),d=Wt(i.columnGroup),f=Wt(i.columnSubGroup),p={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let v="category";return u.hasData?v="subCategory":c.hasData?v="category":l.hasData&&(v="rowGroup"),{rowCount:h.length,scenarios:o,availableScenarios:a,rowGroup:l,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:p,suggestedLevel:v,suggestedOrder:v,suggestedDateInterval:p.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;if(this.clearPolling(),(null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db)&&this.name){const t=this.stores.db.db;try{t.views&&null!=t.views[this.name]&&t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],this.stores.db.notify(this.name)}}isUrl(t){return t.startsWith("http://")||t.startsWith("https://")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=u(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.stores.db.db.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null,this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-dataset: error fetching URL",i,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"d8f90bd66e8d9aafc83c0818cc0e6573a3186568"})}get element(){return e(this)}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}};mi.style="bn-dataset{display:none}";const gi=class{constructor(i){t(this,i),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,a(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=u(this.element));const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastHash=null,this.fetchAndStore(i),void this.startPolling()}null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null);try{let i,s;if(this.raw)i=pi(t),s=t;else{const e=vi(t);i=e.hash,s=e.json}if(i===this.lastHash)return;this.lastHash=i;const e=JSON.parse(s);this.publish(e)}catch(i){console.error("Error parsing datasource",i,String(t).slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i,s,e;this.clearPolling(),(null===(e=null===(s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db)||void 0===s?void 0:s.tables)||void 0===e?void 0:e[this.name])&&(delete this.stores.db.db.tables[this.name],this.stores.db.notify(this.name))}isUrl(t){return t.startsWith("http://")||t.startsWith("https://")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=u(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-datasource: error fetching URL",i,t),this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"541bcc84a90dc736d62f1c596e0b9e3e5a54ebf3"})}get element(){return e(this)}static get watchers(){return{interval:[{onIntervalChange:0}]}}};gi.style="bn-datasource{display:none}";const bi=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,a(this),this.errors=l(this),this.componentStyle=w(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}isValidHttpUrl(t){let i;try{i=new URL(t)}catch(t){return!1}return"http:"===i.protocol||"https:"===i.protocol}prepareAssetUrl(t){return this.isValidHttpUrl(t)?t:`./assets/${t}.png`}render(){return i(s,{key:"c445ca8c8abde56b46564932a6fcd079aa1e640d",id:this.displayPageNumber||this.text||this.code?"container-page-footer":"container",style:this.getFontStyles()},i("div",{key:"2e5829597d228c78acbbbf130bfc440092456cb4",id:"footer-text"},null!=this.text?i("span",{class:"note"},this.text):""),i("div",{key:"a2c98bf85fc41fa0aebc35fded0528cd8ba4948f",id:"code"},null!=this.code?i("img",{class:"image",src:h(`${this.prepareAssetUrl(this.code)}`)}):""),i("div",{key:"e879c6ed16996d8b505d64426e2253f3057863f5",id:"page-number"},this.displayPageNumber?i("span",{class:"page"},this.pageNumber):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};bi.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-footer){box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd}div#footer-text{font-size:0.6em;display:inline}div#code{flex:1;display:inline;text-align:right;padding-right:1em}div#page-number{font-size:0.6em;display:inline}.image{z-index:2;background-color:transparent;border:transparent;height:1.2em;width:auto}';const wi=class{constructor(i){t(this,i),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.titleNamespace="_system",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this),this.resolveInherited=_t(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"}])}connectedCallback(){this.stores=u(this.element),this.reflectInheritedAttrs()}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i&&0!==i.length?this.calculateFractions(i[0]):"minmax(0, 1fr)"}getGridTemplateRows(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g),s=i?i.length:1;return this.cardFitToContent?Array(s).fill("auto").join(" "):Array(s).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplatePattern(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.cardCustomTemplate:this.templateMap.get(t)}async getNumberOfSlot(t){const i=this.getTemplatePattern(t);return this.extractSlotNames(i).length}componentDidUpdate(){}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}reflectInheritedAttrs(){const t=[{prop:"titleScenarios",attr:"title-scenarios"},{prop:"titleVariances",attr:"title-variances"},{prop:"titleOrder",attr:"title-order"},{prop:"titleOrderDirection",attr:"title-order-direction"}];for(const{prop:i,attr:s}of t){const t=this.resolveInherited(i,this[i]);void 0!==t&&this.element.setAttribute(s,t)}}prepareTitleImage(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){var t,s,e,n;const r=this.getLayoutStyle(),h=this.extractSlotNames(r["grid-template-areas"]);return i("bn-card",{key:"c39b6a8cf843b7b8d9b380215a3553288acd3647",styles:this.styles,class:this.setCardClass()},i("div",{key:"3206bff73cb01fad7223e3fd889e015992e535c6",class:"cardtitle"},i("bn-title",{key:"d410c817dd185a26bb7623dd3649c999516f706a",namespace:this.titleNamespace,"business-unit":this.titleBusinessUnit,scenarios:null!==(t=this.resolveInherited("titleScenarios",this.titleScenarios))&&void 0!==t?t:this.titleScenarios,variances:null!==(s=this.resolveInherited("titleVariances",this.titleVariances))&&void 0!==s?s:this.titleVariances,order:null!==(e=this.resolveInherited("titleOrder",this.titleOrder))&&void 0!==e?e:this.titleOrder,"order-direction":null!==(n=this.resolveInherited("titleOrderDirection",this.titleOrderDirection))&&void 0!==n?n:this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?i("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),i("bn-body",{key:"f56b1b70127cd2173e425cf723dbea2b62037d88"},i("div",{key:"e5766b5b28dd1d14fdbaf721baf72668502fcbec",style:r},this.getSlots(h))),i("bn-footer",{key:"bafb89f89c89aaf0e31fa754f0e834330b031627",text:this.footerText,"page-number":0,"display-page-number":"false"}))}get element(){return e(this)}};wi.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}';const yi=class{constructor(i){t(this,i),this.messageText="",this.messageImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.titleNamespace="_system",this.footerDisplayPageNumber=!0,this.pageLayout="full",this.pageCustomTemplate='"a b" "c d"',this.pageGridGap="0",this.pageFitToContent=!1,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this)}getCommonStyles(){let t="100%";return!0===this.pageFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.pageGridGap+"px"}}getGridTemplateRows(t){const i=this.getTemplateAreas(t).match(/"[\w\d\s.]+"/g),s=i?i.length:1;return this.pageFitToContent?Array(s).fill("auto").join(" "):Array(s).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplateAreas(this.pageLayout),"grid-template-columns":this.getGridTemplateColumns(this.pageLayout),"grid-template-rows":this.getGridTemplateRows(this.pageLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplateAreas(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t)}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){if(!1===this.templateMap.has(t)&&"custom-template"!==t)return"1fr";let i;i="custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t);const s=i.match(/"[\w\d\s.]+"/g);return this.calculateFractions(s[0])}async getNumberOfSlot(t){const i=this.getTemplateAreas(t);return this.extractSlotNames(i).length}componentDidUpdate(){const t=this.element.closest("bn-context").getAttribute("render-orientation");if(t&&t!==this.pageOrientation){const t=this.element.shadowRoot.querySelector("bn-page"),i=this.element.closest("bn-layout-page");i&&t&&(t.style.transform="rotate(-90deg) translate(-100%)",t.style.transformOrigin="top left",i.style.width=`${t.clientHeight}px`,i.style.height=`${t.clientWidth}px`)}}render(){const t=this.getLayoutStyle(),s=this.extractSlotNames(t["grid-template-areas"]);return i("bn-page",{key:"958dbce3b000c62d287f6263fed495523786e28d",styles:this.styles,format:this.pageFormat,orientation:this.pageOrientation},i("bn-message",{key:"cdb559c63a0466ccaa1cd807d027dd127e3b3efe",text:this.messageText,image:this.messageImage}),i("bn-title",{key:"48fafd3fc8be7d49df4939bd5db63908b36e523f",namespace:this.titleNamespace,"business-unit":this.titleBusinessUnit,scenarios:this.titleScenarios,variances:this.titleVariances,order:this.titleOrder,"order-direction":this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),i("bn-body",{key:"93c9f7b2c345c8bc6fdb20d35fa406ee919379eb"},i("div",{key:"64e4db5a7b6265bcd73b700227b5f033c99facdc",style:t},this.getSlots(s))),i("bn-footer",{key:"f7b69e9fcfbdde742a2d547f81c50dd78a3ed02f",text:this.footerText,"page-number":this.pageNumber,"display-page-number":this.footerDisplayPageNumber}))}get element(){return e(this)}};yi.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}';const Si=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=w(this)}connectedCallback(){this.stores=u(this.element)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}prepareAssetUrl(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){return i(s,{key:"bbe7f6098aa6f3a5495b36557b218a82ec2ccbca",id:this.text||this.image?"container-page-message":"container",style:this.getFontStyles()},i("div",{key:"d89297da5605b0ee1cc757b1771b6a48525a24e5",id:"message-text"},null!=this.text&&""!==this.text?i("span",{class:"note"},this.text):""),i("div",{key:"70bc74b0a8a5a39fdd2931cf86faada294142a26",id:"page-image"},null!=this.image&&""!==this.image?i("img",{class:"image",src:this.prepareAssetUrl(this.image)}):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};Si.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-message){height:4.55em;box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:0.1em solid #ddd}div#message-text{font-size:1.4em;overflow:clip;display:inline}.image{z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}';const xi=["xga","hd","full-hd","4k","4k2k","a4","a3","a2","a1","a0","letter","legal"],Oi=["landscape","portrait"],_i=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=w(this)}validateFormat(t){const i="ERR_format";P(t)||xi.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${xi.join(", ")}`})}validateOrientation(t){const i="ERR_orientation";P(t)||Oi.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${Oi.join(", ")}`})}render(){return i(s,{key:"b4d682a8f6e83f77c58236265eaf9d1327809c6f",format:this.format,orientation:this.orientation,style:this.prepareStyle()},i("slot",{key:"ef49c43c1f8926c4c968b752608627adbe330d6c"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}static get watchers(){return{format:[{validateFormat:0}],orientation:[{validateOrientation:0}]}}};_i.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}:host([format=xga]){height:768px;width:1024px}:host([format=xga][orientation=portrait]){height:1024px;width:768px}:host([format=xga][orientation=landscape]){height:768px;width:1024px}:host([format=hd]){height:720px;width:1280px}:host([format=hd][orientation=portrait]){height:1280px;width:720px}:host([format=hd][orientation=landscape]){height:720px;width:1280px}:host([format=full_hd]){height:1080px;width:1920px}:host([format=full_hd][orientation=portrait]){height:1920px;width:1080px}:host([format=full_hd][orientation=landscape]){height:1080px;width:1920px}:host([format="4k"]){height:2160px;width:3840px}:host([format="4k"][orientation=portrait]){height:3840px;width:2160px}:host([format="4k"][orientation=landscape]){height:2160px;width:3840px}:host([format="4k2k"]){height:2160px;width:4096px}:host([format="4k2k"][orientation=portrait]){height:4096px;width:2160px}:host([format="4k2k"][orientation=landscape]){height:2160px;width:4096px}:host([format=a6]){height:5.83in;width:4.13in}:host([format=a6][orientation=portrait]){height:5.83in;width:4.13in}:host([format=a6][orientation=landscape]){height:4.13in;width:5.83in}:host([format=a5]){height:8.27in;width:5.83in}:host([format=a5][orientation=portrait]){height:8.27in;width:5.83in}:host([format=a5][orientation=landscape]){height:5.83in;width:8.27in}:host([format=a4]){height:11.6in;width:8.17in}:host([format=a4][orientation=portrait]){height:11.6in;width:8.17in}:host([format=a4][orientation=landscape]){height:8.17in;width:11.6in}:host([format=a3]){height:16.54in;width:11.7in}:host([format=a3][orientation=portrait]){height:16.54in;width:11.7in}:host([format=a3][orientation=landscape]){height:11.7in;width:16.54in}:host([format=a2]){height:23.4in;width:16.54in}:host([format=a2][orientation=portrait]){height:23.4in;width:16.54in}:host([format=a2][orientation=landscape]){height:16.54in;width:23.4in}:host([format=a1]){height:33.1in;width:23.4in}:host([format=a1][orientation=portrait]){height:33.1in;width:23.4in}:host([format=a1][orientation=landscape]){height:23.4in;width:33.1in}:host([format=a0]){height:46.8in;width:33.1in}:host([format=a0][orientation=portrait]){height:46.8in;width:33.1in}:host([format=a0][orientation=landscape]){height:33.1in;width:46.8in}:host([format=letter]){height:11in;width:8.5in}:host([format=letter][orientation=portrait]){height:11in;width:8.5in}:host([format=letter][orientation=landscape]){height:8.5in;width:11in}:host([format=legal]){height:14in;width:8.5in}:host([format=legal][orientation=portrait]){height:14in;width:8.5in}:host([format=legal][orientation=landscape]){height:8.5in;width:14in}:host([format=tabloid]){height:17in;width:11in}:host([format=tabloid][orientation=portrait]){height:17in;width:11in}:host([format=tabloid][orientation=landscape]){height:11in;width:17in}:host([format=ledger]){height:11in;width:17in}:host([format=ledger][orientation=portrait]){height:17in;width:11in}:host([format=ledger][orientation=landscape]){height:11in;width:17in}';const Mi=class{constructor(i){t(this,i),a(this),this.errors=l(this)}connectedCallback(){this.stores=u(this.element),this.pushToStore()}onNameChange(t,i){i&&i!==t&&this.stores&&this.stores.scalingGroups.state[i]===this.value&&this.stores.scalingGroups.set(i,void 0),this.pushToStore()}onValueChange(){this.pushToStore()}pushToStore(){var t;if(!this.stores)return;const i=null===(t=this.name)||void 0===t?void 0:t.toString().trim();"auto"!==(null==i?void 0:i.toLowerCase())?(this.errors.remove("ERR_reserved_name"),i?(this.errors.remove("ERR_empty_name"),this.stores.scalingGroups.set(i,this.value)):this.errors.addOrReplace({id:"ERR_empty_name",type:"warning",message:"bn-scaling-group: name is required."})):this.errors.addOrReplace({id:"ERR_reserved_name",type:"warning",message:'bn-scaling-group: name "auto" is reserved and cannot be used.'})}render(){return i(s,{key:"5f38a91595cb1494b275d48345bf821fddb9b904"})}get element(){return e(this)}static get watchers(){return{name:[{onNameChange:0}],value:[{onValueChange:0}]}}};var Ri,$i,ki,Ei,Ti;Mi.style="bn-scaling-group{display:none}",function(t){t[t.ALL=-1]="ALL"}(Ri||(Ri={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}($i||($i={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(ki||(ki={})),function(t){t.ASC="asc",t.DESC="desc"}(Ei||(Ei={})),function(t){t.HEADER="HEADER",t.GROUPHEAD="GROUPHEAD",t.SEPERATORLINE="SEPERATORLINE",t.SUM="SUM",t.GROUPSUM="GROUP_SUM",t.DRILLELEMENT="DRILLELEMENT",t.STANDARD="STANDARD",t.PARTELEMENT="PARTELEMENT",t.ENTRY="ENTRY"}(Ti||(Ti={}));const Pi=class{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(i){t(this,i),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.tableTitle="",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._autoScaleGuard=!1,T(this),a(this),this.errors=l(this),wt(this),this.componentStyle=w(this),dt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.t=ft(this).t,this.resolveInherited=_t(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(xt(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(xt(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="ERR_barColumns";if(P(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="ERR_barColumnWidth";B(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.toString().trim().toLowerCase())||x(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.toString().trim().toLowerCase())||x(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";H(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateGrouped(t){const i="ERR_grouped";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"grouped: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowGroupTitle(t){const i="ERR_showGroupTitle";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showGroupTitle: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateType(t){const i="ERR_type";j(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateLimit(t){const i="ERR_limit";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateThereOf(t){const i="ERR_thereof",s=V(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="ERR_partof",s=X(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="ERR_order";if(xt(t))return void this.errors.remove(i);const s=_(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";xt(t)||M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureType(t){const i="ERR_measureType";J(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="ERR_measureScale";k(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="ERR_dataFormatDigitsDecimal";R(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";R(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";q(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=Q(t),s="ERR_categorythereof";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(s)}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.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=Mt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=pt(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}=vt(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:s}=pt(i);if(s<=0)return;this._lastScaledParentWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,h=this.appliedScaleFactor;if(n<=s+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,h*(s-1)/n);Math.abs(o-h)<.001||(i.style.setProperty("--bn-font-size",e*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,r((()=>{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 ki[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),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let h=e;return r&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(h=this.datasetMeta.suggestedOrder),{hierarchy:h.split(",").map((t=>C[null==t?void 0:t.toUpperCase()])),direction:A[null==n?void 0:n.toUpperCase()]}}prepareI18nMode(){return Z.META}prepareI18n(){const t=f,i=new Map(["in","category","operation","there_of","part_of","SUM_TOTAL"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,s,e,n,r,h,o,a;const l=this.resolveInherited("scenarios",this.scenarios),c=this.resolveInherited("variances",this.variances);if(void 0!==l||void 0!==c){this.errors.remove("AUTO_scenarios");let i=[];return void 0!==l?i=i.concat(l.split(",")):P(this.scenarios)||(i=i.concat(this.scenarios.split(","))),void 0!==c?i=i.concat(c.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((P(this.scenarios)||u)&&P(this.variances))return(null===(e=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===e?void 0:e.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 d=[];return u||P(this.scenarios)?(null===(r=null===(n=this.datasetMeta)||void 0===n?void 0:n.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(",")}`}),d=d.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),d=d.concat(null===(h=this.scenarios)||void 0===h?void 0:h.split(","))),(null===(o=this.variances)||void 0===o?void 0:o.trim().length)>0&&(d=d.concat(null===(a=this.variances)||void 0===a?void 0:a.split(","))),d.map((t=>t.trim()))}prepareCategoryWidth(){var t;return P(this.categoryWidth)?tt.INF:tt[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return P(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 P(this.measureType)?it.VOLUME:it[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[s,e]of Object.entries(t))!1===i.has(e.scenario)&&i.set(e.scenario,[]),i.get(e.scenario).push(e);return i}prepareTableTitle(){return""===this.tableTitle||null==this.tableTitle?"SUM_TOTAL":this.tableTitle}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(),s=et[i];return s?st[s]:st[et.W10]}prepareBarColumns(){return P(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.toString().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.toString().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}=vt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const h=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":h*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),e=this.getEffectiveScaleFactor();return i(s,{key:"469aa0d5b00e111af96d33764640fa92eb5ed5cc",style:t},i("div",{key:"f02443601b7e644c243b48ad09af411a8460b659"},i("ibcs-table",{key:"242ee74a5715c83a267e3f02daab09b9baca0c57",tableName:this.datasetName,dataVersion:this.dataVersion,"table-title":this.prepareTableTitle(),scenarios:this.prepareScenarios(),"scenarios-data-format":this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),type:this.prepareTableType(),"category-width":this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),"i18n-mode":this.prepareI18nMode(),"measure-scale":this.prepareMeasureScale(),"measure-type":this.prepareMeasureType(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),scaleFactor:e})))}get element(){return e(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}]}}};Pi.style=":host{display:inline-block;position:relative;overflow:hidden}";const Li=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",T(this),a(this),this.t=ft(this).t,this.errors=l(this),this.componentStyle=w(this)}validateScenario(t){const i="ERR_scenarios",s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances",s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateOrder(t){const i=_(t),s="ERR_order";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"order: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(s)}validateOrderDirection(t){const i="ERR_orderDirection";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const i="ERR_measures",s=nt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"measures: invalid value(s) '"+(null==s?void 0:s.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(i)}validateDateStart(t){const i="ERR_dateStart";rt(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const i="ERR_dateEnd";rt(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const i="ERR_dateFormat";G(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const i="ERR_dateLink";ht(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=f,i=new Map(["SEPERATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareI18nMode(){return Z.META}prepareTitleOrder(){var t;return P(this.order)||P(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:A[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return P(this.dateStart)&&P(this.dateEnd)||P(this.dateLink)?null:{start:m.fromISO(this.dateStart),end:m.fromISO(this.dateEnd),format:W[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:ot[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){return P(this.measures)?[]:JSON.parse(this.measures)}prepareScenarios(){var t,i,s,e;if(P(this.scenarios)&&P(this.variances))return[];let n=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(n=n.concat(null===(i=this.scenarios)||void 0===i?void 0:i.split(","))),(null===(s=this.variances)||void 0===s?void 0:s.trim().length)>0&&(n=n.concat(null===(e=this.variances)||void 0===e?void 0:e.split(","))),n.map((t=>t.trim()))}prepareBusinessUnit(){return P(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"e84349bd356bc6ac3a3f3dccad01b0ef7d818077",style:t},i("ibcs-title",{key:"cde3f65fff090e3ade3909a4d3c0b103e5b91ba5",businessUnit:this.prepareBusinessUnit(),scenarios:this.prepareScenarios(),measures:this.prepareMeasures(),timeperiod:this.prepareTitleTimePeriod(),order:this.prepareTitleOrder(),i18n:this.prepareI18n(),"i18n-mode":this.prepareI18nMode()}))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}};Li.style=':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const Ai={},Ci=[];function Ni(t,i){if(Array.isArray(t))for(const s of t)Ni(s,i);else if("object"!=typeof t)Ui(Object.getOwnPropertyNames(i)),Ai[t]=Object.assign(Ai[t]||{},i);else for(const i in t)Ni(i,t[i])}function Di(t){return Ai[t]||{}}function Ui(t){Ci.push(...t)}function Gi(t,i){let s;const e=t.length,n=[];for(s=0;s<e;s++)n.push(i(t[s]));return n}function Fi(t){return t%360*Math.PI/180}function Wi(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Yi(t,i,s,e){return null!=i&&null!=s||(e=e||t.bbox(),null==i?i=e.width/e.height*s:null==s&&(s=e.height/e.width*i)),{width:i,height:s}}function zi(t,i){const s=t.origin;let e=null!=t.ox?t.ox:null!=t.originX?t.originX:"center",n=null!=t.oy?t.oy:null!=t.originY?t.originY:"center";null!=s&&([e,n]=Array.isArray(s)?s:"object"==typeof s?[s.x,s.y]:[s,s]);const r="string"==typeof e,h="string"==typeof n;if(r||h){const{height:t,width:s,x:o,y:a}=i.bbox();r&&(e=e.includes("left")?o:e.includes("right")?o+s:o+s/2),h&&(n=n.includes("top")?a:n.includes("bottom")?a+t:a+t/2)}return[e,n]}const Ii=new Set(["desc","metadata","title"]),Bi=t=>Ii.has(t.nodeName),Hi=(t,i,s={})=>{const e={...i};for(const t in e)e[t].valueOf()===s[t]&&delete e[t];Object.keys(e).length?t.node.setAttribute("data-svgjs",JSON.stringify(e)):(t.node.removeAttribute("data-svgjs"),t.node.removeAttribute("svgjs:data"))},ji="http://www.w3.org/2000/svg",Vi="http://www.w3.org/2000/xmlns/",Xi="http://www.w3.org/1999/xlink",Ji={window:"undefined"==typeof window?null:window,document:"undefined"==typeof document?null:document};class qi{}const Qi={},Ki="___SYMBOL___ROOT___";function Zi(t,i=ji){return Ji.document.createElementNS(i,t)}function ts(t,i=!1){if(t instanceof qi)return t;if("object"==typeof t)return es(t);if(null==t)return new Qi[Ki];if("string"==typeof t&&"<"!==t.trim().charAt(0))return es(Ji.document.querySelector(t));const s=i?Ji.document.createElement("div"):Zi("svg");return s.innerHTML=t.trim(),t=es(s.firstElementChild),s.removeChild(s.firstElementChild),t}function is(t,i){return i&&(i instanceof Ji.window.Node||i.ownerDocument&&i instanceof i.ownerDocument.defaultView.Node)?i:Zi(t)}function ss(t){if(!t)return null;if(t.instance instanceof qi)return t.instance;if("#document-fragment"===t.nodeName)return new Qi.Fragment(t);let i=Wi(t.nodeName||"Dom");return"LinearGradient"===i||"RadialGradient"===i?i="Gradient":Qi[i]||(i="Dom"),new Qi[i](t)}let es=ss;function ns(t,i=t.name,s=!1){return Qi[i]=t,s&&(Qi[Ki]=t),Ui(Object.getOwnPropertyNames(t.prototype)),t}let rs=1e3;function hs(t){return"Svgjs"+Wi(t)+rs++}function os(t){for(let i=t.children.length-1;i>=0;i--)os(t.children[i]);return t.id?(t.id=hs(t.nodeName),t):t}function as(t,i){let s,e;for(e=(t=Array.isArray(t)?t:[t]).length-1;e>=0;e--)for(s in i)t[e].prototype[s]=i[s]}function ls(t){return function(...i){const s=i[i.length-1];return!s||s.constructor!==Object||s instanceof Array?t.apply(this,i):t.apply(this,i.slice(0,-1)).attr(s)}}Ni("Dom",{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},prev:function(){return this.siblings()[this.position()-1]},forward:function(){const t=this.position();return this.parent().add(this.remove(),t+1),this},backward:function(){const t=this.position();return this.parent().add(this.remove(),t?t-1:0),this},front:function(){return this.parent().add(this.remove()),this},back:function(){return this.parent().add(this.remove(),0),this},before:function(t){(t=ts(t)).remove();const i=this.position();return this.parent().add(t,i),this},after:function(t){(t=ts(t)).remove();const i=this.position();return this.parent().add(t,i+1),this},insertBefore:function(t){return(t=ts(t)).before(this),this},insertAfter:function(t){return(t=ts(t)).after(this),this}});const cs=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,us=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,ds=/rgb\((\d+),(\d+),(\d+)\)/,fs=/(#[a-z_][a-z0-9\-_]*)/i,ps=/\)\s*,?\s*/,vs=/\s/g,ms=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,gs=/^rgb\(/,bs=/^(\s+)?$/,ws=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ys=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,Ss=/[\s,]+/,xs=/[MLHVCSQTAZ]/i;function Os(t){const i=Math.round(t),s=Math.max(0,Math.min(255,i)).toString(16);return 1===s.length?"0"+s:s}function _s(t,i){for(let s=i.length;s--;)if(null==t[i[s]])return!1;return!0}function Ms(t,i,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(i-t)*s:s<.5?i:s<2/3?t+(i-t)*(2/3-s)*6:t}Ni("Dom",{classes:function(){const t=this.attr("class");return null==t?[]:t.trim().split(Ss)},hasClass:function(t){return-1!==this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){const i=this.classes();i.push(t),this.attr("class",i.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter((function(i){return i!==t})).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)}}),Ni("Dom",{css:function(t,i){const s={};if(0===arguments.length)return this.node.style.cssText.split(/\s*;\s*/).filter((function(t){return!!t.length})).forEach((function(t){const i=t.split(/\s*:\s*/);s[i[0]]=i[1]})),s;if(arguments.length<2){if(Array.isArray(t)){for(const i of t)s[i]=this.node.style.getPropertyValue(i);return s}if("string"==typeof t)return this.node.style.getPropertyValue(t);if("object"==typeof t)for(const i in t)this.node.style.setProperty(i,null==t[i]||bs.test(t[i])?"":t[i])}return 2===arguments.length&&this.node.style.setProperty(t,null==i||bs.test(i)?"":i),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),Ni("Dom",{data:function(t,i,s){if(null==t)return this.data(Gi(function(t){let i;const s=t.length,e=[];for(i=0;i<s;i++)0===t[i].nodeName.indexOf("data-")&&e.push(t[i]);return e}(this.node.attributes),(t=>t.nodeName.slice(5))));if(t instanceof Array){const i={};for(const s of t)i[s]=this.data(s);return i}if("object"==typeof t)for(i in t)this.data(i,t[i]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(i){return this.attr("data-"+t)}else this.attr("data-"+t,null===i?null:!0===s||"string"==typeof i||"number"==typeof i?i:JSON.stringify(i));return this}}),Ni("Dom",{remember:function(t,i){if("object"==typeof arguments[0])for(const i in t)this.remember(i,t[i]);else{if(1===arguments.length)return this.memory()[t];this.memory()[t]=i}return this},forget:function(){if(0===arguments.length)this._memory={};else for(let t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory=this._memory||{}}});class Rs{constructor(...t){this.init(...t)}static isColor(t){return t&&(t instanceof Rs||this.isRgb(t)||this.test(t))}static isRgb(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b}static random(t="vibrant",i){const{random:s,round:e,sin:n,PI:r}=Math;if("vibrant"===t){const t=24*s()+57,i=38*s()+45,e=360*s();return new Rs(t,i,e,"lch")}if("sine"===t){const t=e(80*n(2*r*(i=null==i?s():i)/.5+.01)+150),h=e(50*n(2*r*i/.5+4.6)+200),o=e(100*n(2*r*i/.5+2.3)+150);return new Rs(t,h,o)}if("pastel"===t){const t=8*s()+86,i=17*s()+9,e=360*s();return new Rs(t,i,e,"lch")}if("dark"===t){const t=10+10*s(),i=50*s()+86,e=360*s();return new Rs(t,i,e,"lch")}if("rgb"===t){const t=255*s(),i=255*s(),e=255*s();return new Rs(t,i,e)}if("lab"===t){const t=100*s(),i=256*s()-128,e=256*s()-128;return new Rs(t,i,e,"lab")}if("grey"===t){const t=255*s();return new Rs(t,t,t)}throw new Error("Unsupported random color mode")}static test(t){return"string"==typeof t&&(ms.test(t)||gs.test(t))}cmyk(){const{_a:t,_b:i,_c:s}=this.rgb(),[e,n,r]=[t,i,s].map((t=>t/255)),h=Math.min(1-e,1-n,1-r);return 1===h?new Rs(0,0,0,1,"cmyk"):new Rs((1-e-h)/(1-h),(1-n-h)/(1-h),(1-r-h)/(1-h),h,"cmyk")}hsl(){const{_a:t,_b:i,_c:s}=this.rgb(),[e,n,r]=[t,i,s].map((t=>t/255)),h=Math.max(e,n,r),o=Math.min(e,n,r),a=(h+o)/2,l=h===o,c=h-o;return new Rs(360*(l?0:h===e?((n-r)/c+(n<r?6:0))/6:h===n?((r-e)/c+2)/6:h===r?((e-n)/c+4)/6:0),100*(l?0:a>.5?c/(2-h-o):c/(h+o)),100*a,"hsl")}init(t=0,i=0,s=0,e=0,n="rgb"){if(t=t||0,this.space)for(const t in this.space)delete this[this.space[t]];if("number"==typeof t)n="string"==typeof e?e:n,e="string"==typeof e?0:e,Object.assign(this,{_a:t,_b:i,_c:s,_d:e,space:n});else if(t instanceof Array)this.space=i||("string"==typeof t[3]?t[3]:t[4])||"rgb",Object.assign(this,{_a:t[0],_b:t[1],_c:t[2],_d:t[3]||0});else if(t instanceof Object){const s=function(t,i){const s=_s(t,"rgb")?{_a:t.r,_b:t.g,_c:t.b,_d:0,space:"rgb"}:_s(t,"xyz")?{_a:t.x,_b:t.y,_c:t.z,_d:0,space:"xyz"}:_s(t,"hsl")?{_a:t.h,_b:t.s,_c:t.l,_d:0,space:"hsl"}:_s(t,"lab")?{_a:t.l,_b:t.a,_c:t.b,_d:0,space:"lab"}:_s(t,"lch")?{_a:t.l,_b:t.c,_c:t.h,_d:0,space:"lch"}:_s(t,"cmyk")?{_a:t.c,_b:t.m,_c:t.y,_d:t.k,space:"cmyk"}:{_a:0,_b:0,_c:0,space:"rgb"};return s.space=i||s.space,s}(t,i);Object.assign(this,s)}else if("string"==typeof t)if(gs.test(t)){const i=t.replace(vs,""),[s,e,n]=ds.exec(i).slice(1,4).map((t=>parseInt(t)));Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}else{if(!ms.test(t))throw Error("Unsupported string format, can't construct Color");{const i=t=>parseInt(t,16),[,s,e,n]=us.exec(function(t){return 4===t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}(t)).map(i);Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}}const{_a:r,_b:h,_c:o,_d:a}=this;Object.assign(this,"rgb"===this.space?{r,g:h,b:o}:"xyz"===this.space?{x:r,y:h,z:o}:"hsl"===this.space?{h:r,s:h,l:o}:"lab"===this.space?{l:r,a:h,b:o}:"lch"===this.space?{l:r,c:h,h:o}:"cmyk"===this.space?{c:r,m:h,y:o,k:a}:{})}lab(){const{x:t,y:i,z:s}=this.xyz();return new Rs(116*i-16,500*(t-i),200*(i-s),"lab")}lch(){const{l:t,a:i,b:s}=this.lab(),e=Math.sqrt(i**2+s**2);let n=180*Math.atan2(s,i)/Math.PI;return n<0&&(n*=-1,n=360-n),new Rs(t,e,n,"lch")}rgb(){if("rgb"===this.space)return this;if("lab"===(t=this.space)||"xyz"===t||"lch"===t){let{x:t,y:i,z:s}=this;if("lab"===this.space||"lch"===this.space){let{l:e,a:n,b:r}=this;if("lch"===this.space){const{c:t,h:i}=this,s=Math.PI/180;n=t*Math.cos(s*i),r=t*Math.sin(s*i)}const h=(e+16)/116,o=n/500+h,a=h-r/200,l=16/116,c=.008856,u=7.787;t=.95047*(o**3>c?o**3:(o-l)/u),i=1*(h**3>c?h**3:(h-l)/u),s=1.08883*(a**3>c?a**3:(a-l)/u)}const e=3.2406*t+-1.5372*i+-.4986*s,n=-.9689*t+1.8758*i+.0415*s,r=.0557*t+-.204*i+1.057*s,h=Math.pow,o=.0031308,a=e>o?1.055*h(e,1/2.4)-.055:12.92*e,l=n>o?1.055*h(n,1/2.4)-.055:12.92*n,c=r>o?1.055*h(r,1/2.4)-.055:12.92*r;return new Rs(255*a,255*l,255*c)}if("hsl"===this.space){let{h:t,s:i,l:s}=this;if(t/=360,i/=100,s/=100,0===i)return s*=255,new Rs(s,s,s);const e=s<.5?s*(1+i):s+i-s*i,n=2*s-e,r=255*Ms(n,e,t+1/3),h=255*Ms(n,e,t),o=255*Ms(n,e,t-1/3);return new Rs(r,h,o)}if("cmyk"===this.space){const{c:t,m:i,y:s,k:e}=this,n=255*(1-Math.min(1,t*(1-e)+e)),r=255*(1-Math.min(1,i*(1-e)+e)),h=255*(1-Math.min(1,s*(1-e)+e));return new Rs(n,r,h)}return this;var t}toArray(){const{_a:t,_b:i,_c:s,_d:e,space:n}=this;return[t,i,s,e,n]}toHex(){const[t,i,s]=this._clamped().map(Os);return`#${t}${i}${s}`}toRgb(){const[t,i,s]=this._clamped();return`rgb(${t},${i},${s})`}toString(){return this.toHex()}xyz(){const{_a:t,_b:i,_c:s}=this.rgb(),[e,n,r]=[t,i,s].map((t=>t/255)),h=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,o=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,a=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,l=(.4124*h+.3576*o+.1805*a)/.95047,c=(.2126*h+.7152*o+.0722*a)/1,u=(.0193*h+.1192*o+.9505*a)/1.08883,d=l>.008856?Math.pow(l,1/3):7.787*l+16/116,f=c>.008856?Math.pow(c,1/3):7.787*c+16/116,p=u>.008856?Math.pow(u,1/3):7.787*u+16/116;return new Rs(d,f,p,"xyz")}_clamped(){const{_a:t,_b:i,_c:s}=this.rgb(),{max:e,min:n,round:r}=Math;return[t,i,s].map((t=>e(0,n(r(t),255))))}}class $s{constructor(...t){this.init(...t)}clone(){return new $s(this)}init(t,i){const s=Array.isArray(t)?{x:t[0],y:t[1]}:"object"==typeof t?{x:t.x,y:t.y}:{x:t,y:i};return this.x=null==s.x?0:s.x,this.y=null==s.y?0:s.y,this}toArray(){return[this.x,this.y]}transform(t){return this.clone().transformO(t)}transformO(t){Es.isMatrixLike(t)||(t=new Es(t));const{x:i,y:s}=this;return this.x=t.a*i+t.c*s+t.e,this.y=t.b*i+t.d*s+t.f,this}}function ks(t,i){return Math.abs(i-t)<1e-6}class Es{constructor(...t){this.init(...t)}static formatTransforms(t){const i="both"===t.flip||!0===t.flip,s=t.flip&&(i||"x"===t.flip)?-1:1,e=t.flip&&(i||"y"===t.flip)?-1:1,n=t.skew&&t.skew.length?t.skew[0]:isFinite(t.skew)?t.skew:isFinite(t.skewX)?t.skewX:0,r=t.skew&&t.skew.length?t.skew[1]:isFinite(t.skew)?t.skew:isFinite(t.skewY)?t.skewY:0,h=t.scale&&t.scale.length?t.scale[0]*s:isFinite(t.scale)?t.scale*s:isFinite(t.scaleX)?t.scaleX*s:s,o=t.scale&&t.scale.length?t.scale[1]*e:isFinite(t.scale)?t.scale*e:isFinite(t.scaleY)?t.scaleY*e:e,a=t.shear||0,l=t.rotate||t.theta||0,c=new $s(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),u=c.x,d=c.y,f=new $s(t.position||t.px||t.positionX||NaN,t.py||t.positionY||NaN),p=f.x,v=f.y,m=new $s(t.translate||t.tx||t.translateX,t.ty||t.translateY),g=m.x,b=m.y,w=new $s(t.relative||t.rx||t.relativeX,t.ry||t.relativeY);return{scaleX:h,scaleY:o,skewX:n,skewY:r,shear:a,theta:l,rx:w.x,ry:w.y,tx:g,ty:b,ox:u,oy:d,px:p,py:v}}static fromArray(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}static isMatrixLike(t){return null!=t.a||null!=t.b||null!=t.c||null!=t.d||null!=t.e||null!=t.f}static matrixMultiply(t,i,s){const e=t.b*i.a+t.d*i.b,n=t.a*i.c+t.c*i.d,r=t.b*i.c+t.d*i.d,h=t.e+t.a*i.e+t.c*i.f,o=t.f+t.b*i.e+t.d*i.f;return s.a=t.a*i.a+t.c*i.b,s.b=e,s.c=n,s.d=r,s.e=h,s.f=o,s}around(t,i,s){return this.clone().aroundO(t,i,s)}aroundO(t,i,s){const e=t||0,n=i||0;return this.translateO(-e,-n).lmultiplyO(s).translateO(e,n)}clone(){return new Es(this)}decompose(t=0,i=0){const s=this.a,e=this.b,n=this.c,r=this.d,h=this.e,o=this.f,a=s*r-e*n,l=a>0?1:-1,c=l*Math.sqrt(s*s+e*e),u=Math.atan2(l*e,l*s),d=180/Math.PI*u,f=Math.cos(u),p=Math.sin(u),v=(s*n+e*r)/a,m=n*c/(v*s-e)||r*c/(v*e+s);return{scaleX:c,scaleY:m,shear:v,rotate:d,translateX:h-t+t*f*c+i*(v*f*c-p*m),translateY:o-i+t*p*c+i*(v*p*c+f*m),originX:t,originY:i,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}equals(t){if(t===this)return!0;const i=new Es(t);return ks(this.a,i.a)&&ks(this.b,i.b)&&ks(this.c,i.c)&&ks(this.d,i.d)&&ks(this.e,i.e)&&ks(this.f,i.f)}flip(t,i){return this.clone().flipO(t,i)}flipO(t,i){return"x"===t?this.scaleO(-1,1,i,0):"y"===t?this.scaleO(1,-1,0,i):this.scaleO(-1,-1,t,i||t)}init(t){const i=Es.fromArray([1,0,0,1,0,0]);return t=t instanceof Qs?t.matrixify():"string"==typeof t?Es.fromArray(t.split(Ss).map(parseFloat)):Array.isArray(t)?Es.fromArray(t):"object"==typeof t&&Es.isMatrixLike(t)?t:"object"==typeof t?(new Es).transform(t):6===arguments.length?Es.fromArray([].slice.call(arguments)):i,this.a=null!=t.a?t.a:i.a,this.b=null!=t.b?t.b:i.b,this.c=null!=t.c?t.c:i.c,this.d=null!=t.d?t.d:i.d,this.e=null!=t.e?t.e:i.e,this.f=null!=t.f?t.f:i.f,this}inverse(){return this.clone().inverseO()}inverseO(){const t=this.a,i=this.b,s=this.c,e=this.d,n=this.e,r=this.f,h=t*e-i*s;if(!h)throw new Error("Cannot invert "+this);const o=e/h,a=-i/h,l=-s/h,c=t/h,u=-(o*n+l*r),d=-(a*n+c*r);return this.a=o,this.b=a,this.c=l,this.d=c,this.e=u,this.f=d,this}lmultiply(t){return this.clone().lmultiplyO(t)}lmultiplyO(t){const i=t instanceof Es?t:new Es(t);return Es.matrixMultiply(i,this,this)}multiply(t){return this.clone().multiplyO(t)}multiplyO(t){const i=t instanceof Es?t:new Es(t);return Es.matrixMultiply(this,i,this)}rotate(t,i,s){return this.clone().rotateO(t,i,s)}rotateO(t,i=0,s=0){t=Fi(t);const e=Math.cos(t),n=Math.sin(t),{a:r,b:h,c:o,d:a,e:l,f:c}=this;return this.a=r*e-h*n,this.b=h*e+r*n,this.c=o*e-a*n,this.d=a*e+o*n,this.e=l*e-c*n+s*n-i*e+i,this.f=c*e+l*n-i*n-s*e+s,this}scale(){return this.clone().scaleO(...arguments)}scaleO(t,i=t,s=0,e=0){3===arguments.length&&(e=s,s=i,i=t);const{a:n,b:r,c:h,d:o,e:a,f:l}=this;return this.a=n*t,this.b=r*i,this.c=h*t,this.d=o*i,this.e=a*t-s*t+s,this.f=l*i-e*i+e,this}shear(t,i,s){return this.clone().shearO(t,i,s)}shearO(t,i=0,s=0){const{a:e,b:n,c:r,d:h,e:o,f:a}=this;return this.a=e+n*t,this.c=r+h*t,this.e=o+a*t-s*t,this}skew(){return this.clone().skewO(...arguments)}skewO(t,i=t,s=0,e=0){3===arguments.length&&(e=s,s=i,i=t),t=Fi(t),i=Fi(i);const n=Math.tan(t),r=Math.tan(i),{a:h,b:o,c:a,d:l,e:c,f:u}=this;return this.a=h+o*n,this.b=o+h*r,this.c=a+l*n,this.d=l+a*r,this.e=c+u*n-e*n,this.f=u+c*r-s*r,this}skewX(t,i,s){return this.skew(t,0,i,s)}skewY(t,i,s){return this.skew(0,t,i,s)}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}toString(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}transform(t){if(Es.isMatrixLike(t))return new Es(t).multiplyO(this);const i=Es.formatTransforms(t),{x:s,y:e}=new $s(i.ox,i.oy).transform(this),n=(new Es).translateO(i.rx,i.ry).lmultiplyO(this).translateO(-s,-e).scaleO(i.scaleX,i.scaleY).skewO(i.skewX,i.skewY).shearO(i.shear).rotateO(i.theta).translateO(s,e);if(isFinite(i.px)||isFinite(i.py)){const t=new $s(s,e).transform(n),r=isFinite(i.px)?i.px-t.x:0,h=isFinite(i.py)?i.py-t.y:0;n.translateO(r,h)}return n.translateO(i.tx,i.ty),n}translate(t,i){return this.clone().translateO(t,i)}translateO(t,i){return this.e+=t||0,this.f+=i||0,this}valueOf(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}}function Ts(){if(!Ts.nodes){const t=ts().size(2,0);t.node.style.cssText=["opacity: 0","position: absolute","left: -100%","top: -100%","overflow: hidden"].join(";"),t.attr("focusable","false"),t.attr("aria-hidden","true");const i=t.path().node;Ts.nodes={svg:t,path:i}}return Ts.nodes.svg.node.parentNode||Ts.nodes.svg.addTo(Ji.document.body||Ji.document.documentElement),Ts.nodes}function Ps(t){return!(t.width||t.height||t.x||t.y)}ns(Es,"Matrix");class Ls{constructor(...t){this.init(...t)}addOffset(){return this.x+=Ji.window.pageXOffset,this.y+=Ji.window.pageYOffset,new Ls(this)}init(t){return t="string"==typeof t?t.split(Ss).map(parseFloat):Array.isArray(t)?t:"object"==typeof t?[null!=t.left?t.left:t.x,null!=t.top?t.top:t.y,t.width,t.height]:4===arguments.length?[].slice.call(arguments):[0,0,0,0],this.x=t[0]||0,this.y=t[1]||0,this.width=this.w=t[2]||0,this.height=this.h=t[3]||0,this.x2=this.x+this.w,this.y2=this.y+this.h,this.cx=this.x+this.w/2,this.cy=this.y+this.h/2,this}isNulled(){return Ps(this)}merge(t){const i=Math.min(this.x,t.x),s=Math.min(this.y,t.y),e=Math.max(this.x+this.width,t.x+t.width)-i,n=Math.max(this.y+this.height,t.y+t.height)-s;return new Ls(i,s,e,n)}toArray(){return[this.x,this.y,this.width,this.height]}toString(){return this.x+" "+this.y+" "+this.width+" "+this.height}transform(t){t instanceof Es||(t=new Es(t));let i=1/0,s=-1/0,e=1/0,n=-1/0;return[new $s(this.x,this.y),new $s(this.x2,this.y),new $s(this.x,this.y2),new $s(this.x2,this.y2)].forEach((function(r){r=r.transform(t),i=Math.min(i,r.x),s=Math.max(s,r.x),e=Math.min(e,r.y),n=Math.max(n,r.y)})),new Ls(i,e,s-i,n-e)}}function As(t,i,s){let e;try{if(e=i(t.node),Ps(e)&&(n=t.node)!==Ji.document&&!(Ji.document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===Ji.document}).call(Ji.document.documentElement,n))throw new Error("Element not in the dom")}catch(i){e=s(t)}var n;return e}Ni({viewbox:{viewbox(t,i,s,e){return null==t?new Ls(this.attr("viewBox")):this.attr("viewBox",new Ls(t,i,s,e))},zoom(t,i){let{width:s,height:e}=this.attr(["width","height"]);if((s||e)&&"string"!=typeof s&&"string"!=typeof e||(s=this.node.clientWidth,e=this.node.clientHeight),!s||!e)throw new Error("Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element");const n=this.viewbox(),r=s/n.width,h=e/n.height,o=Math.min(r,h);if(null==t)return o;let a=o/t;a===1/0&&(a=Number.MAX_SAFE_INTEGER/100),i=i||new $s(s/2/r+n.x,e/2/h+n.y);const l=new Ls(n).transform(new Es({scale:a,origin:i}));return this.viewbox(l)}}}),ns(Ls,"Box");class Cs extends Array{constructor(t=[],...i){if(super(t,...i),"number"==typeof t)return this;this.length=0,this.push(...t)}}as([Cs],{each(t,...i){return this.map("function"==typeof t?(i,s,e)=>t.call(i,i,s,e):s=>s[t](...i))},toArray(){return Array.prototype.concat.apply([],this)}});const Ns=["toArray","constructor","each"];function Ds(t,i){return new Cs(Gi((i||Ji.document).querySelectorAll(t),(function(t){return ss(t)})))}Cs.extend=function(t){t=t.reduce(((t,i)=>(Ns.includes(i)||"_"===i[0]||(i in Array.prototype&&(t["$"+i]=Array.prototype[i]),t[i]=function(...t){return this.each(i,...t)}),t)),{}),as([Cs],t)};let Us=0;const Gs={};function Fs(t){let i=t.getEventHolder();return i===Ji.window&&(i=Gs),i.events||(i.events={}),i.events}function Ws(t){return t.getEventTarget()}function Ys(t,i,s,e,n){const r=s.bind(e||t),h=ts(t),o=Fs(h),a=Ws(h);i=Array.isArray(i)?i:i.split(Ss),s._svgjsListenerId||(s._svgjsListenerId=++Us),i.forEach((function(t){const i=t.split(".")[0],e=t.split(".")[1]||"*";o[i]=o[i]||{},o[i][e]=o[i][e]||{},o[i][e][s._svgjsListenerId]=r,a.addEventListener(i,r,n||!1)}))}function zs(t,i,s,e){const n=ts(t),r=Fs(n),h=Ws(n);("function"!=typeof s||(s=s._svgjsListenerId))&&(i=Array.isArray(i)?i:(i||"").split(Ss)).forEach((function(t){const i=t&&t.split(".")[0],o=t&&t.split(".")[1];let a,l;if(s)r[i]&&r[i][o||"*"]&&(h.removeEventListener(i,r[i][o||"*"][s],e||!1),delete r[i][o||"*"][s]);else if(i&&o){if(r[i]&&r[i][o]){for(l in r[i][o])zs(h,[i,o].join("."),l);delete r[i][o]}}else if(o)for(t in r)for(a in r[t])o===a&&zs(h,[t,o].join("."));else if(i){if(r[i]){for(a in r[i])zs(h,[i,a].join("."));delete r[i]}}else{for(t in r)zs(h,t);!function(t){let i=t.getEventHolder();i===Ji.window&&(i=Gs),i.events&&(i.events={})}(n)}}))}class Is extends qi{addEventListener(){}dispatch(t,i,s){return function(t,i,s,e){const n=Ws(t);return i instanceof Ji.window.Event||(i=new Ji.window.CustomEvent(i,{detail:s,cancelable:!0,...e})),n.dispatchEvent(i),i}(this,t,i,s)}dispatchEvent(t){const i=this.getEventHolder().events;if(!i)return!0;const s=i[t.type];for(const i in s)for(const e in s[i])s[i][e](t);return!t.defaultPrevented}fire(t,i,s){return this.dispatch(t,i,s),this}getEventHolder(){return this}getEventTarget(){return this}off(t,i,s){return zs(this,t,i,s),this}on(t,i,s,e){return Ys(this,t,i,s,e),this}removeEventListener(){}}function Bs(){}ns(Is,"EventTarget");const Hs={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","text-anchor":"start"};class js extends Array{constructor(...t){super(...t),this.init(...t)}clone(){return new this.constructor(this)}init(t){return"number"==typeof t||(this.length=0,this.push(...this.parse(t))),this}parse(t=[]){return t instanceof Array?t:t.trim().split(Ss).map(parseFloat)}toArray(){return Array.prototype.concat.apply([],this)}toSet(){return new Set(this)}toString(){return this.join(" ")}valueOf(){const t=[];return t.push(...this),t}}class Vs{constructor(...t){this.init(...t)}convert(t){return new Vs(this.value,t)}divide(t){return t=new Vs(t),new Vs(this/t,this.unit||t.unit)}init(t,i){return i=Array.isArray(t)?t[1]:i,t=Array.isArray(t)?t[0]:t,this.value=0,this.unit=i||"","number"==typeof t?this.value=isNaN(t)?0:isFinite(t)?t:t<0?-34e37:34e37:"string"==typeof t?(i=t.match(cs))&&(this.value=parseFloat(i[1]),"%"===i[5]?this.value/=100:"s"===i[5]&&(this.value*=1e3),this.unit=i[5]):t instanceof Vs&&(this.value=t.valueOf(),this.unit=t.unit),this}minus(t){return t=new Vs(t),new Vs(this-t,this.unit||t.unit)}plus(t){return t=new Vs(t),new Vs(this+t,this.unit||t.unit)}times(t){return t=new Vs(t),new Vs(this*t,this.unit||t.unit)}toArray(){return[this.value,this.unit]}toJSON(){return this.toString()}toString(){return("%"===this.unit?~~(1e8*this.value)/1e6:"s"===this.unit?this.value/1e3:this.value)+this.unit}valueOf(){return this.value}}const Xs=new Set(["fill","stroke","color","bgcolor","stop-color","flood-color","lighting-color"]),Js=[];class qs extends Is{constructor(t,i){super(),this.node=t,this.type=t.nodeName,i&&t!==i&&this.attr(i)}add(t,i){return(t=ts(t)).removeNamespace&&this.node instanceof Ji.window.SVGElement&&t.removeNamespace(),null==i?this.node.appendChild(t.node):t.node!==this.node.childNodes[i]&&this.node.insertBefore(t.node,this.node.childNodes[i]),this}addTo(t,i){return ts(t).put(this,i)}children(){return new Cs(Gi(this.node.children,(function(t){return ss(t)})))}clear(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}clone(t=!0,i=!0){this.writeDataToDom();let s=this.node.cloneNode(t);return i&&(s=os(s)),new this.constructor(s)}each(t,i){const s=this.children();let e,n;for(e=0,n=s.length;e<n;e++)t.apply(s[e],[e,s]),i&&s[e].each(t,i);return this}element(t,i){return this.put(new qs(Zi(t),i))}first(){return ss(this.node.firstChild)}get(t){return ss(this.node.childNodes[t])}getEventHolder(){return this.node}getEventTarget(){return this.node}has(t){return this.index(t)>=0}html(t,i){return this.xml(t,i,"http://www.w3.org/1999/xhtml")}id(t){return void 0!==t||this.node.id||(this.node.id=hs(this.type)),this.attr("id",t)}index(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}last(){return ss(this.node.lastChild)}matches(t){const i=this.node,s=i.matches||i.matchesSelector||i.msMatchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||null;return s&&s.call(i,t)}parent(t){let i=this;if(!i.node.parentNode)return null;if(i=ss(i.node.parentNode),!t)return i;do{if("string"==typeof t?i.matches(t):i instanceof t)return i}while(i=ss(i.node.parentNode));return i}put(t,i){return t=ts(t),this.add(t,i),t}putIn(t,i){return ts(t).add(this,i)}remove(){return this.parent()&&this.parent().removeElement(this),this}removeElement(t){return this.node.removeChild(t.node),this}replace(t){return t=ts(t),this.node.parentNode&&this.node.parentNode.replaceChild(t.node,this.node),t}round(t=2,i=null){const s=10**t,e=this.attr(i);for(const t in e)"number"==typeof e[t]&&(e[t]=Math.round(e[t]*s)/s);return this.attr(e),this}svg(t,i){return this.xml(t,i,ji)}toString(){return this.id()}words(t){return this.node.textContent=t,this}wrap(t){const i=this.parent();if(!i)return this.addTo(t);const s=i.index(this);return i.put(t,s).put(this)}writeDataToDom(){return this.each((function(){this.writeDataToDom()})),this}xml(t,i,s){if("boolean"==typeof t&&(s=i,i=t,t=null),null==t||"function"==typeof t){i=null==i||i,this.writeDataToDom();let s=this;if(null!=t){if(s=ss(s.node.cloneNode(!0)),i){const i=t(s);if(s=i||s,!1===i)return""}s.each((function(){const i=t(this),s=i||this;!1===i?this.remove():i&&this!==s&&this.replace(s)}),!0)}return i?s.node.outerHTML:s.node.innerHTML}i=null!=i&&i;const e=Zi("wrapper",s),n=Ji.document.createDocumentFragment();e.innerHTML=t;for(let t=e.children.length;t--;)n.appendChild(e.firstElementChild);const r=this.parent();return i?this.replace(n)&&r:this.add(n)}}as(qs,{attr:function(t,i,s){if(null==t){t={},i=this.node.attributes;for(const s of i)t[s.nodeName]=ws.test(s.nodeValue)?parseFloat(s.nodeValue):s.nodeValue;return t}if(t instanceof Array)return t.reduce(((t,i)=>(t[i]=this.attr(i),t)),{});if("object"==typeof t&&t.constructor===Object)for(i in t)this.attr(i,t[i]);else if(null===i)this.node.removeAttribute(t);else{if(null==i)return null==(i=this.node.getAttribute(t))?Hs[t]:ws.test(i)?parseFloat(i):i;"number"==typeof(i=Js.reduce(((i,s)=>s(t,i,this)),i))?i=new Vs(i):Xs.has(t)&&Rs.isColor(i)?i=new Rs(i):i.constructor===Array&&(i=new js(i)),"leading"===t?this.leading&&this.leading(i):"string"==typeof s?this.node.setAttributeNS(s,t,i.toString()):this.node.setAttribute(t,i.toString()),!this.rebuild||"font-size"!==t&&"x"!==t||this.rebuild()}return this},find:function(t){return Ds(t,this.node)},findOne:function(t){return ss(this.node.querySelector(t))}}),ns(qs,"Dom");class Qs extends qs{constructor(t,i){super(t,i),this.dom={},this.node.instance=this,(t.hasAttribute("data-svgjs")||t.hasAttribute("svgjs:data"))&&this.setData(JSON.parse(t.getAttribute("data-svgjs"))??JSON.parse(t.getAttribute("svgjs:data"))??{})}center(t,i){return this.cx(t).cy(i)}cx(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)}cy(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)}defs(){const t=this.root();return t&&t.defs()}dmove(t,i){return this.dx(t).dy(i)}dx(t=0){return this.x(new Vs(t).plus(this.x()))}dy(t=0){return this.y(new Vs(t).plus(this.y()))}getEventHolder(){return this}height(t){return this.attr("height",t)}move(t,i){return this.x(t).y(i)}parents(t=this.root()){const i="string"==typeof t;i||(t=ts(t));const s=new Cs;let e=this;for(;(e=e.parent())&&e.node!==Ji.document&&"#document-fragment"!==e.nodeName&&(s.push(e),i||e.node!==t.node)&&(!i||!e.matches(t));)if(e.node===this.root().node)return null;return s}reference(t){if(!(t=this.attr(t)))return null;const i=(t+"").match(fs);return i?ts(i[1]):null}root(){const t=this.parent(Qi[Ki]);return t&&t.root()}setData(t){return this.dom=t,this}size(t,i){const s=Yi(this,t,i);return this.width(new Vs(s.width)).height(new Vs(s.height))}width(t){return this.attr("width",t)}writeDataToDom(){return Hi(this,this.dom),super.writeDataToDom()}x(t){return this.attr("x",t)}y(t){return this.attr("y",t)}}as(Qs,{bbox:function(){const t=As(this,(t=>t.getBBox()),(t=>{try{const i=t.clone().addTo(Ts().svg).show(),s=i.node.getBBox();return i.remove(),s}catch(i){throw new Error(`Getting bbox of element "${t.node.nodeName}" is not possible: ${i.toString()}`)}}));return new Ls(t)},rbox:function(t){const i=As(this,(t=>t.getBoundingClientRect()),(t=>{throw new Error(`Getting rbox of element "${t.node.nodeName}" is not possible`)})),s=new Ls(i);return t?s.transform(t.screenCTM().inverseO()):s.addOffset()},inside:function(t,i){const s=this.bbox();return t>s.x&&i>s.y&&t<s.x+s.width&&i<s.y+s.height},point:function(t,i){return new $s(t,i).transformO(this.screenCTM().inverseO())},ctm:function(){return new Es(this.node.getCTM())},screenCTM:function(){try{if("function"==typeof this.isRoot&&!this.isRoot()){const t=this.rect(1,1),i=t.node.getScreenCTM();return t.remove(),new Es(i)}return new Es(this.node.getScreenCTM())}catch(t){return console.warn(`Cannot get CTM from SVG node ${this.node.nodeName}. Is the element rendered?`),new Es}}}),ns(Qs,"Element");const Ks={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,i){return"color"===i?t:t+"-"+i}};["fill","stroke"].forEach((function(t){const i={};let s;i[t]=function(i){if(void 0===i)return this.attr(t);if("string"==typeof i||i instanceof Rs||Rs.isRgb(i)||i instanceof Qs)this.attr(t,i);else for(s=Ks[t].length-1;s>=0;s--)null!=i[Ks[t][s]]&&this.attr(Ks.prefix(t,Ks[t][s]),i[Ks[t][s]]);return this},Ni(["Element","Runner"],i)})),Ni(["Element","Runner"],{matrix:function(t,i,s,e,n,r){return null==t?new Es(this):this.attr("transform",new Es(t,i,s,e,n,r))},rotate:function(t,i,s){return this.transform({rotate:t,ox:i,oy:s},!0)},skew:function(t,i,s,e){return this.transform(1===arguments.length||3===arguments.length?{skew:t,ox:i,oy:s}:{skew:[t,i],ox:s,oy:e},!0)},shear:function(t,i,s){return this.transform({shear:t,ox:i,oy:s},!0)},scale:function(t,i,s,e){return this.transform(1===arguments.length||3===arguments.length?{scale:t,ox:i,oy:s}:{scale:[t,i],ox:s,oy:e},!0)},translate:function(t,i){return this.transform({translate:[t,i]},!0)},relative:function(t,i){return this.transform({relative:[t,i]},!0)},flip:function(t="both",i="center"){return-1==="xybothtrue".indexOf(t)&&(i=t,t="both"),this.transform({flip:t,origin:i},!0)},opacity:function(t){return this.attr("opacity",t)}}),Ni("radius",{radius:function(t,i=t){return"radialGradient"===(this._element||this).type?this.attr("r",new Vs(t)):this.rx(t).ry(i)}}),Ni("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new $s(this.node.getPointAtLength(t))}}),Ni(["Element","Runner"],{font:function(t,i){if("object"==typeof t){for(i in t)this.font(i,t[i]);return this}return"leading"===t?this.leading(i):this.attr("anchor"===t?"text-anchor":"size"===t||"family"===t||"weight"===t||"stretch"===t||"variant"===t||"style"===t?"font-"+t:t,i)}}),Ni("Element",["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel","contextmenu","wheel","pointerdown","pointermove","pointerup","pointerleave","pointercancel"].reduce((function(t,i){return t[i]=function(t){return null===t?this.off(i):this.on(i,t),this},t}),{})),Ni("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(ps).slice(0,-1).map((function(t){const i=t.trim().split("(");return[i[0],i[1].split(Ss).map((function(t){return parseFloat(t)}))]})).reverse().reduce((function(t,i){return"matrix"===i[0]?t.lmultiply(Es.fromArray(i[1])):t[i[0]].apply(t,i[1])}),new Es)},toParent:function(t,i){if(this===t)return this;if(Bi(this.node))return this.addTo(t,i);const s=this.screenCTM(),e=t.screenCTM().inverse();return this.addTo(t,i).untransform().transform(e.multiply(s)),this},toRoot:function(t){return this.toParent(this.root(),t)},transform:function(t,i){if(null==t||"string"==typeof t){const i=new Es(this).decompose();return null==t?i:i[t]}Es.isMatrixLike(t)||(t={...t,origin:zi(t,this)});const s=new Es(!0===i?this:i||!1).transform(t);return this.attr("transform",s)}});class Zs extends Qs{flatten(){return this.each((function(){if(this instanceof Zs)return this.flatten().ungroup()})),this}ungroup(t=this.parent(),i=t.index(this)){return i=-1===i?t.children().length:i,this.each((function(s,e){return e[e.length-s-1].toParent(t,i)})),this.remove()}}ns(Zs,"Container");class te extends Zs{constructor(t,i=t){super(is("defs",t),i)}flatten(){return this}ungroup(){return this}}ns(te,"Defs");class ie extends Qs{}function se(t){return this.attr("rx",t)}function ee(t){return this.attr("ry",t)}function ne(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function re(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function he(t){return this.attr("cx",t)}function oe(t){return this.attr("cy",t)}function ae(t){return null==t?2*this.rx():this.rx(new Vs(t).divide(2))}function le(t){return null==t?2*this.ry():this.ry(new Vs(t).divide(2))}ns(ie,"Shape");var ce=Object.freeze({__proto__:null,cx:he,cy:oe,height:le,rx:se,ry:ee,width:ae,x:ne,y:re});class ue extends ie{constructor(t,i=t){super(is("ellipse",t),i)}size(t,i){const s=Yi(this,t,i);return this.rx(new Vs(s.width).divide(2)).ry(new Vs(s.height).divide(2))}}as(ue,ce),Ni("Container",{ellipse:ls((function(t=0,i=t){return this.put(new ue).size(t,i).move(0,0)}))}),ns(ue,"Ellipse");class de extends qs{constructor(t=Ji.document.createDocumentFragment()){super(t)}xml(t,i,s){if("boolean"==typeof t&&(s=i,i=t,t=null),null==t||"function"==typeof t){const t=new qs(Zi("wrapper",s));return t.add(this.node.cloneNode(!0)),t.xml(!1,s)}return super.xml(t,!1,s)}}function fe(t,i){return this.attr("radialGradient"===(this._element||this).type?{fx:new Vs(t),fy:new Vs(i)}:{x1:new Vs(t),y1:new Vs(i)})}function pe(t,i){return this.attr("radialGradient"===(this._element||this).type?{cx:new Vs(t),cy:new Vs(i)}:{x2:new Vs(t),y2:new Vs(i)})}ns(de,"Fragment");var ve=Object.freeze({__proto__:null,from:fe,to:pe});class me extends Zs{constructor(t,i){super(is(t+"Gradient","string"==typeof t?null:t),i)}attr(t,i,s){return"transform"===t&&(t="gradientTransform"),super.attr(t,i,s)}bbox(){return new Ls}targets(){return Ds("svg [fill*="+this.id()+"]")}toString(){return this.url()}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}url(){return"url(#"+this.id()+")"}}as(me,ve),Ni({Container:{gradient(...t){return this.defs().gradient(...t)}},Defs:{gradient:ls((function(t,i){return this.put(new me(t)).update(i)}))}}),ns(me,"Gradient");class ge extends Zs{constructor(t,i=t){super(is("pattern",t),i)}attr(t,i,s){return"transform"===t&&(t="patternTransform"),super.attr(t,i,s)}bbox(){return new Ls}targets(){return Ds("svg [fill*="+this.id()+"]")}toString(){return this.url()}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}url(){return"url(#"+this.id()+")"}}Ni({Container:{pattern(...t){return this.defs().pattern(...t)}},Defs:{pattern:ls((function(t,i,s){return this.put(new ge).update(s).attr({x:0,y:0,width:t,height:i,patternUnits:"userSpaceOnUse"})}))}}),ns(ge,"Pattern");class be extends ie{constructor(t,i=t){super(is("image",t),i)}load(t,i){if(!t)return this;const s=new Ji.window.Image;return Ys(s,"load",(function(t){const e=this.parent(ge);0===this.width()&&0===this.height()&&this.size(s.width,s.height),e instanceof ge&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,t)}),this),Ys(s,"load error",(function(){zs(s)})),this.attr("href",s.src=t,Xi)}}Js.push((function(t,i,s){return"fill"!==t&&"stroke"!==t||ys.test(i)&&(i=s.root().defs().image(i)),i instanceof be&&(i=s.root().defs().pattern(0,0,(t=>{t.add(i)}))),i})),Ni({Container:{image:ls((function(t,i){return this.put(new be).size(0,0).load(t,i)}))}}),ns(be,"Image");class we extends js{bbox(){let t=-1/0,i=-1/0,s=1/0,e=1/0;return this.forEach((function(n){t=Math.max(n[0],t),i=Math.max(n[1],i),s=Math.min(n[0],s),e=Math.min(n[1],e)})),new Ls(s,e,t-s,i-e)}move(t,i){const s=this.bbox();if(t-=s.x,i-=s.y,!isNaN(t)&&!isNaN(i))for(let s=this.length-1;s>=0;s--)this[s]=[this[s][0]+t,this[s][1]+i];return this}parse(t=[0,0]){const i=[];(t=t instanceof Array?Array.prototype.concat.apply([],t):t.trim().split(Ss).map(parseFloat)).length%2!=0&&t.pop();for(let s=0,e=t.length;s<e;s+=2)i.push([t[s],t[s+1]]);return i}size(t,i){let s;const e=this.bbox();for(s=this.length-1;s>=0;s--)e.width&&(this[s][0]=(this[s][0]-e.x)*t/e.width+e.x),e.height&&(this[s][1]=(this[s][1]-e.y)*i/e.height+e.y);return this}toLine(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}}toString(){const t=[];for(let i=0,s=this.length;i<s;i++)t.push(this[i].join(","));return t.join(" ")}transform(t){return this.clone().transformO(t)}transformO(t){Es.isMatrixLike(t)||(t=new Es(t));for(let i=this.length;i--;){const[s,e]=this[i];this[i][0]=t.a*s+t.c*e+t.e,this[i][1]=t.b*s+t.d*e+t.f}return this}}var ye=Object.freeze({__proto__:null,MorphArray:we,height:function(t){const i=this.bbox();return null==t?i.height:this.size(i.width,t)},width:function(t){const i=this.bbox();return null==t?i.width:this.size(t,i.height)},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}});let Se=class extends ie{constructor(t,i=t){super(is("line",t),i)}array(){return new we([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])}move(t,i){return this.attr(this.array().move(t,i).toLine())}plot(t,i,s,e){return null==t?this.array():(t=void 0!==i?{x1:t,y1:i,x2:s,y2:e}:new we(t).toLine(),this.attr(t))}size(t,i){const s=Yi(this,t,i);return this.attr(this.array().size(s.width,s.height).toLine())}};as(Se,ye),Ni({Container:{line:ls((function(...t){return Se.prototype.plot.apply(this.put(new Se),null!=t[0]?t:[0,0,0,0])}))}}),ns(Se,"Line");let xe=class extends Zs{constructor(t,i=t){super(is("marker",t),i)}height(t){return this.attr("markerHeight",t)}orient(t){return this.attr("orient",t)}ref(t,i){return this.attr("refX",t).attr("refY",i)}toString(){return"url(#"+this.id()+")"}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}width(t){return this.attr("markerWidth",t)}};function Oe(t,i){return function(s){return null==s?this[t]:(this[t]=s,i&&i.call(this),this)}}Ni({Container:{marker(...t){return this.defs().marker(...t)}},Defs:{marker:ls((function(t,i,s){return this.put(new xe).size(t,i).ref(t/2,i/2).viewbox(0,0,t,i).attr("orient","auto").update(s)}))},marker:{marker(t,i,s,e){let n=["marker"];return"all"!==t&&n.push(t),n=n.join("-"),t=arguments[1]instanceof xe?arguments[1]:this.defs().marker(i,s,e),this.attr(n,t)}}}),ns(xe,"Marker");const _e={"-":function(t){return t},"<>":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)},bezier:function(t,i,s,e){return function(n){return n<0?t>0?i/t*n:s>0?e/s*n:0:n>1?s<1?(1-e)/(1-s)*n+(e-s)/(1-s):t<1?(1-i)/(1-t)*n+(i-t)/(1-t):1:3*n*(1-n)**2*i+3*n**2*(1-n)*e+n**3}},steps:function(t,i="end"){i=i.split("-").reverse()[0];let s=t;return"none"===i?--s:"both"===i&&++s,(e,n=!1)=>{let r=Math.floor(e*t);const h=e*r%1==0;return"start"!==i&&"both"!==i||++r,n&&h&&--r,e>=0&&r<0&&(r=0),e<=1&&r>s&&(r=s),r/s}}};class Me{done(){return!1}}class Re extends Me{constructor(t=">"){super(),this.ease=_e[t]||t}step(t,i,s){return"number"!=typeof t?s<1?t:i:t+(i-t)*this.ease(s)}}class $e extends Me{constructor(t){super(),this.stepper=t}done(t){return t.done}step(t,i,s,e){return this.stepper(t,i,s,e)}}function ke(){const t=(this._duration||500)/1e3,i=Math.PI,s=Math.log((this._overshoot||0)/100+1e-10),e=-s/Math.sqrt(i*i+s*s),n=3.9/(e*t);this.d=2*e*n,this.k=n*n}as(class extends $e{constructor(t=500,i=0){super(),this.duration(t).overshoot(i)}step(t,i,s,e){if("string"==typeof t)return t;if(e.done=s===1/0,s===1/0)return i;if(0===s)return t;s>100&&(s=16);const n=e.velocity||0,r=-this.d*n-this.k*(t-i),h=t+n*(s/=1e3)+r*s*s/2;return e.velocity=n+r*s,e.done=Math.abs(i-h)+Math.abs(n)<.002,e.done?i:h}},{duration:Oe("_duration",ke),overshoot:Oe("_overshoot",ke)}),as(class extends $e{constructor(t=.1,i=.01,s=0,e=1e3){super(),this.p(t).i(i).d(s).windup(e)}step(t,i,s,e){if("string"==typeof t)return t;if(e.done=s===1/0,s===1/0)return i;if(0===s)return t;const n=i-t;let r=(e.integral||0)+n*s;const h=(n-(e.error||0))/s,o=this._windup;return!1!==o&&(r=Math.max(-o,Math.min(r,o))),e.error=n,e.integral=r,e.done=Math.abs(n)<.001,e.done?i:t+(this.P*n+this.I*r+this.D*h)}},{windup:Oe("_windup"),p:Oe("P"),i:Oe("I"),d:Oe("D")});const Ee={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},Te={M:function(t,i,s){return i.x=s.x=t[0],i.y=s.y=t[1],["M",i.x,i.y]},L:function(t,i){return i.x=t[0],i.y=t[1],["L",t[0],t[1]]},H:function(t,i){return i.x=t[0],["H",t[0]]},V:function(t,i){return i.y=t[0],["V",t[0]]},C:function(t,i){return i.x=t[4],i.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},S:function(t,i){return i.x=t[2],i.y=t[3],["S",t[0],t[1],t[2],t[3]]},Q:function(t,i){return i.x=t[2],i.y=t[3],["Q",t[0],t[1],t[2],t[3]]},T:function(t,i){return i.x=t[0],i.y=t[1],["T",t[0],t[1]]},Z:function(t,i,s){return i.x=s.x,i.y=s.y,["Z"]},A:function(t,i){return i.x=t[5],i.y=t[6],["A",t[0],t[1],t[2],t[3],t[4],t[5],t[6]]}},Pe="mlhvqtcsaz".split("");for(let t=0,i=Pe.length;t<i;++t)Te[Pe[t]]=function(t){return function(i,s,e){if("H"===t)i[0]=i[0]+s.x;else if("V"===t)i[0]=i[0]+s.y;else if("A"===t)i[5]=i[5]+s.x,i[6]=i[6]+s.y;else for(let t=0,e=i.length;t<e;++t)i[t]=i[t]+(t%2?s.y:s.x);return Te[t](i,s,e)}}(Pe[t].toUpperCase());function Le(t){return t.segment.length&&t.segment.length-1===Ee[t.segment[0].toUpperCase()]}function Ae(t,i){t.inNumber&&Ce(t,!1);const s=xs.test(i);if(s)t.segment=[i];else{const i=t.lastCommand,s=i.toLowerCase();t.segment=["m"===s?i===s?"l":"L":i]}return t.inSegment=!0,t.lastCommand=t.segment[0],s}function Ce(t,i){if(!t.inNumber)throw new Error("Parser Error");t.number&&t.segment.push(parseFloat(t.number)),t.inNumber=i,t.number="",t.pointSeen=!1,t.hasExponent=!1,Le(t)&&Ne(t)}function Ne(t){t.inSegment=!1,t.absolute&&(t.segment=function(t){return Te[t.segment[0]](t.segment.slice(1),t.p,t.p0)}(t)),t.segments.push(t.segment)}function De(t){if(!t.segment.length)return!1;const i="A"===t.segment[0].toUpperCase(),s=t.segment.length;return i&&(4===s||5===s)}function Ue(t){return"E"===t.lastToken.toUpperCase()}const Ge=new Set([" ",",","\t","\n","\r","\f"]);class Fe extends js{bbox(){return Ts().path.setAttribute("d",this.toString()),new Ls(Ts.nodes.path.getBBox())}move(t,i){const s=this.bbox();if(t-=s.x,i-=s.y,!isNaN(t)&&!isNaN(i))for(let s,e=this.length-1;e>=0;e--)s=this[e][0],"M"===s||"L"===s||"T"===s?(this[e][1]+=t,this[e][2]+=i):"H"===s?this[e][1]+=t:"V"===s?this[e][1]+=i:"C"===s||"S"===s||"Q"===s?(this[e][1]+=t,this[e][2]+=i,this[e][3]+=t,this[e][4]+=i,"C"===s&&(this[e][5]+=t,this[e][6]+=i)):"A"===s&&(this[e][6]+=t,this[e][7]+=i);return this}parse(t="M0 0"){return Array.isArray(t)&&(t=Array.prototype.concat.apply([],t).toString()),function(t,i=!0){let s=0,e="";const n={segment:[],inNumber:!1,number:"",lastToken:"",inSegment:!1,segments:[],pointSeen:!1,hasExponent:!1,absolute:i,p0:new $s,p:new $s};for(;n.lastToken=e,e=t.charAt(s++);)if(n.inSegment||!Ae(n,e))if("."!==e)if(isNaN(parseInt(e)))if(Ge.has(e))n.inNumber&&Ce(n,!1);else if("-"!==e&&"+"!==e)if("E"!==e.toUpperCase()){if(xs.test(e)){if(n.inNumber)Ce(n,!1);else{if(!Le(n))throw new Error("parser Error");Ne(n)}--s}}else n.number+=e,n.hasExponent=!0;else{if(n.inNumber&&!Ue(n)){Ce(n,!1),--s;continue}n.number+=e,n.inNumber=!0}else{if("0"===n.number||De(n)){n.inNumber=!0,n.number=e,Ce(n,!0);continue}n.inNumber=!0,n.number+=e}else{if(n.pointSeen||n.hasExponent){Ce(n,!1),--s;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=e}return n.inNumber&&Ce(n,!1),n.inSegment&&Le(n)&&Ne(n),n.segments}(t)}size(t,i){const s=this.bbox();let e,n;for(s.width=0===s.width?1:s.width,s.height=0===s.height?1:s.height,e=this.length-1;e>=0;e--)n=this[e][0],"M"===n||"L"===n||"T"===n?(this[e][1]=(this[e][1]-s.x)*t/s.width+s.x,this[e][2]=(this[e][2]-s.y)*i/s.height+s.y):"H"===n?this[e][1]=(this[e][1]-s.x)*t/s.width+s.x:"V"===n?this[e][1]=(this[e][1]-s.y)*i/s.height+s.y:"C"===n||"S"===n||"Q"===n?(this[e][1]=(this[e][1]-s.x)*t/s.width+s.x,this[e][2]=(this[e][2]-s.y)*i/s.height+s.y,this[e][3]=(this[e][3]-s.x)*t/s.width+s.x,this[e][4]=(this[e][4]-s.y)*i/s.height+s.y,"C"===n&&(this[e][5]=(this[e][5]-s.x)*t/s.width+s.x,this[e][6]=(this[e][6]-s.y)*i/s.height+s.y)):"A"===n&&(this[e][1]=this[e][1]*t/s.width,this[e][2]=this[e][2]*i/s.height,this[e][6]=(this[e][6]-s.x)*t/s.width+s.x,this[e][7]=(this[e][7]-s.y)*i/s.height+s.y);return this}toString(){return function(t){let i="";for(let s=0,e=t.length;s<e;s++)i+=t[s][0],null!=t[s][1]&&(i+=t[s][1],null!=t[s][2]&&(i+=" ",i+=t[s][2],null!=t[s][3]&&(i+=" ",i+=t[s][3],i+=" ",i+=t[s][4],null!=t[s][5]&&(i+=" ",i+=t[s][5],i+=" ",i+=t[s][6],null!=t[s][7]&&(i+=" ",i+=t[s][7])))));return i+" "}(this)}}const We=t=>{const i=typeof t;return"number"===i?Vs:"string"===i?Rs.isColor(t)?Rs:Ss.test(t)?xs.test(t)?Fe:js:cs.test(t)?Vs:ze:je.indexOf(t.constructor)>-1?t.constructor:Array.isArray(t)?js:"object"===i?He:ze};class Ye{constructor(t){this._stepper=t||new Re("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}at(t){return this._morphObj.morph(this._from,this._to,t,this._stepper,this._context)}done(){return this._context.map(this._stepper.done).reduce((function(t,i){return t&&i}),!0)}from(t){return null==t?this._from:(this._from=this._set(t),this)}stepper(t){return null==t?this._stepper:(this._stepper=t,this)}to(t){return null==t?this._to:(this._to=this._set(t),this)}type(t){return null==t?this._type:(this._type=t,this)}_set(t){this._type||this.type(We(t));let i=new this._type(t);return this._type===Rs&&(i=this._to?i[this._to[4]]():this._from?i[this._from[4]]():i),this._type===He&&(i=this._to?i.align(this._to):this._from?i.align(this._from):i),i=i.toConsumable(),this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(i.length)).map(Object).map((function(t){return t.done=!0,t})),i}}class ze{constructor(...t){this.init(...t)}init(t){return t=Array.isArray(t)?t[0]:t,this.value=t,this}toArray(){return[this.value]}valueOf(){return this.value}}class Ie{constructor(...t){this.init(...t)}init(t){return Array.isArray(t)&&(t={scaleX:t[0],scaleY:t[1],shear:t[2],rotate:t[3],translateX:t[4],translateY:t[5],originX:t[6],originY:t[7]}),Object.assign(this,Ie.defaults,t),this}toArray(){const t=this;return[t.scaleX,t.scaleY,t.shear,t.rotate,t.translateX,t.translateY,t.originX,t.originY]}}Ie.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};const Be=(t,i)=>t[0]<i[0]?-1:t[0]>i[0]?1:0;class He{constructor(...t){this.init(...t)}align(t){const i=this.values;for(let s=0,e=i.length;s<e;++s){if(i[s+1]===t[s+1]){if(i[s+1]===Rs&&t[s+7]!==i[s+7]){const i=t[s+7],e=new Rs(this.values.splice(s+3,5))[i]().toArray();this.values.splice(s+3,0,...e)}s+=i[s+2]+2;continue}if(!t[s+1])return this;const e=(new t[s+1]).toArray();i.splice(s,i[s+2]+3,t[s],t[s+1],t[s+2],...e),s+=i[s+2]+2}return this}init(t){if(this.values=[],Array.isArray(t))return void(this.values=t.slice());t=t||{};const i=[];for(const s in t){const e=We(t[s]),n=new e(t[s]).toArray();i.push([s,e,n.length,...n])}return i.sort(Be),this.values=i.reduce(((t,i)=>t.concat(i)),[]),this}toArray(){return this.values}valueOf(){const t={},i=this.values;for(;i.length;){const s=i.shift(),e=i.shift(),n=i.shift(),r=i.splice(0,n);t[s]=new e(r)}return t}}const je=[ze,Ie,He];class Ve extends ie{constructor(t,i=t){super(is("path",t),i)}array(){return this._array||(this._array=new Fe(this.attr("d")))}clear(){return delete this._array,this}height(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}move(t,i){return this.attr("d",this.array().move(t,i))}plot(t){return null==t?this.array():this.clear().attr("d","string"==typeof t?t:this._array=new Fe(t))}size(t,i){const s=Yi(this,t,i);return this.attr("d",this.array().size(s.width,s.height))}width(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)}x(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}y(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}}Ve.prototype.MorphArray=Fe,Ni({Container:{path:ls((function(t){return this.put(new Ve).plot(t||new Fe)}))}}),ns(Ve,"Path");var Xe=Object.freeze({__proto__:null,array:function(){return this._array||(this._array=new we(this.attr("points")))},clear:function(){return delete this._array,this},move:function(t,i){return this.attr("points",this.array().move(t,i))},plot:function(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new we(t))},size:function(t,i){const s=Yi(this,t,i);return this.attr("points",this.array().size(s.width,s.height))}});class Je extends ie{constructor(t,i=t){super(is("polygon",t),i)}}Ni({Container:{polygon:ls((function(t){return this.put(new Je).plot(t||new we)}))}}),as(Je,ye),as(Je,Xe),ns(Je,"Polygon");class qe extends ie{constructor(t,i=t){super(is("polyline",t),i)}}Ni({Container:{polyline:ls((function(t){return this.put(new qe).plot(t||new we)}))}}),as(qe,ye),as(qe,Xe),ns(qe,"Polyline");class Qe extends ie{constructor(t,i=t){super(is("rect",t),i)}}as(Qe,{rx:se,ry:ee}),Ni({Container:{rect:ls((function(t,i){return this.put(new Qe).size(t,i)}))}}),ns(Qe,"Rect");class Ke{constructor(){this._first=null,this._last=null}first(){return this._first&&this._first.value}last(){return this._last&&this._last.value}push(t){const i=void 0!==t.next?t:{value:t,next:null,prev:null};return this._last?(i.prev=this._last,this._last.next=i,this._last=i):(this._last=i,this._first=i),i}remove(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this._last&&(this._last=t.prev),t===this._first&&(this._first=t.next),t.prev=null,t.next=null}shift(){const t=this._first;return t?(this._first=t.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,t.value):null}}const Ze={nextDraw:null,frames:new Ke,timeouts:new Ke,immediates:new Ke,timer:()=>Ji.window.performance||Ji.window.Date,transforms:[],frame(t){const i=Ze.frames.push({run:t});return null===Ze.nextDraw&&(Ze.nextDraw=Ji.window.requestAnimationFrame(Ze._draw)),i},timeout(t,i){i=i||0;const s=Ze.timer().now()+i,e=Ze.timeouts.push({run:t,time:s});return null===Ze.nextDraw&&(Ze.nextDraw=Ji.window.requestAnimationFrame(Ze._draw)),e},immediate(t){const i=Ze.immediates.push(t);return null===Ze.nextDraw&&(Ze.nextDraw=Ji.window.requestAnimationFrame(Ze._draw)),i},cancelFrame(t){null!=t&&Ze.frames.remove(t)},clearTimeout(t){null!=t&&Ze.timeouts.remove(t)},cancelImmediate(t){null!=t&&Ze.immediates.remove(t)},_draw(t){let i=null;const s=Ze.timeouts.last();for(;(i=Ze.timeouts.shift())&&(t>=i.time?i.run():Ze.timeouts.push(i),i!==s););let e=null;const n=Ze.frames.last();for(;e!==n&&(e=Ze.frames.shift());)e.run(t);let r=null;for(;r=Ze.immediates.shift();)r();Ze.nextDraw=Ze.timeouts.first()||Ze.frames.first()?Ji.window.requestAnimationFrame(Ze._draw):null}},tn=function(t){const i=t.start,s=t.runner.duration();return{start:i,duration:s,end:i+s,runner:t.runner}},sn=function(){const t=Ji.window;return(t.performance||t.Date).now()};class en extends Is{constructor(t=sn){super(),this._timeSource=t,this.terminate()}active(){return!!this._nextFrame}finish(){return this.time(this.getEndTimeOfTimeline()+1),this.pause()}getEndTime(){const t=this.getLastRunnerInfo(),i=t?t.runner.duration():0;return(t?t.start:this._time)+i}getEndTimeOfTimeline(){const t=this._runners.map((t=>t.start+t.runner.duration()));return Math.max(0,...t)}getLastRunnerInfo(){return this.getRunnerInfoById(this._lastRunnerId)}getRunnerInfoById(t){return this._runners[this._runnerIds.indexOf(t)]||null}pause(){return this._paused=!0,this._continue()}persist(t){return null==t?this._persist:(this._persist=t,this)}play(){return this._paused=!1,this.updateTime()._continue()}reverse(t){const i=this.speed();if(null==t)return this.speed(-i);const s=Math.abs(i);return this.speed(t?-s:s)}schedule(t,i,s){if(null==t)return this._runners.map(tn);let e=0;const n=this.getEndTime();if(i=i||0,null==s||"last"===s||"after"===s)e=n;else if("absolute"===s||"start"===s)e=i,i=0;else if("now"===s)e=this._time;else if("relative"===s){const s=this.getRunnerInfoById(t.id);s&&(e=s.start+i,i=0)}else{if("with-last"!==s)throw new Error('Invalid value for the "when" parameter');{const t=this.getLastRunnerInfo();e=t?t.start:this._time}}t.unschedule(),t.timeline(this);const r=t.persist(),h={persist:null===r?this._persist:r,start:e+i,runner:t};return this._lastRunnerId=t.id,this._runners.push(h),this._runners.sort(((t,i)=>t.start-i.start)),this._runnerIds=this._runners.map((t=>t.runner.id)),this.updateTime()._continue(),this}seek(t){return this.time(this._time+t)}source(t){return null==t?this._timeSource:(this._timeSource=t,this)}speed(t){return null==t?this._speed:(this._speed=t,this)}stop(){return this.time(0),this.pause()}time(t){return null==t?this._time:(this._time=t,this._continue(!0))}unschedule(t){const i=this._runnerIds.indexOf(t.id);return i<0||(this._runners.splice(i,1),this._runnerIds.splice(i,1),t.timeline(null)),this}updateTime(){return this.active()||(this._lastSourceTime=this._timeSource()),this}_continue(t=!1){return Ze.cancelFrame(this._nextFrame),this._nextFrame=null,t?this._stepImmediate():(this._paused||(this._nextFrame=Ze.frame(this._step)),this)}_stepFn(t=!1){const i=this._timeSource();let s=i-this._lastSourceTime;t&&(s=0);const e=this._speed*s+(this._time-this._lastStepTime);this._lastSourceTime=i,t||(this._time+=e,this._time=this._time<0?0:this._time),this._lastStepTime=this._time,this.fire("time",this._time);for(let t=this._runners.length;t--;){const i=this._runners[t];this._time-i.start<=0&&i.runner.reset()}let n=!1;for(let t=0,i=this._runners.length;t<i;t++){const s=this._runners[t],r=s.runner;let h=e;const o=this._time-s.start;o<=0?n=!0:(o<h&&(h=o),r.active()&&(r.step(h).done?!0!==s.persist&&r.duration()-r.time()+this._time+s.persist<this._time&&(r.unschedule(),--t,--i):n=!0))}return n&&!(this._speed<0&&0===this._time)||this._runnerIds.length&&this._speed<0&&this._time>0?this._continue():(this.pause(),this.fire("finished")),this}terminate(){this._startTime=0,this._speed=1,this._persist=0,this._nextFrame=null,this._paused=!0,this._runners=[],this._runnerIds=[],this._lastRunnerId=-1,this._time=0,this._lastSourceTime=0,this._lastStepTime=0,this._step=this._stepFn.bind(this,!1),this._stepImmediate=this._stepFn.bind(this,!0)}}Ni({Element:{timeline:function(t){return null==t?(this._timeline=this._timeline||new en,this._timeline):(this._timeline=t,this)}}});class nn extends Is{constructor(t){super(),this.id=nn.id++,t="function"==typeof(t=null==t?400:t)?new $e(t):t,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration="number"==typeof t&&t,this._isDeclarative=t instanceof $e,this._stepper=this._isDeclarative?t:new Re,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new Es,this.transformId=1,this._haveReversed=!1,this._reverse=!1,this._loopsDone=0,this._swing=!1,this._wait=0,this._times=1,this._frameId=null,this._persist=!!this._isDeclarative||null}static sanitise(t,i,s){let e=1,n=!1,r=0;return i=i??0,s=s||"last","object"!=typeof(t=t??400)||t instanceof Me||(i=t.delay??i,s=t.when??s,n=t.swing||n,e=t.times??e,r=t.wait??r,t=t.duration??400),{duration:t,delay:i,swing:n,times:e,wait:r,when:s}}active(t){return null==t?this.enabled:(this.enabled=t,this)}addTransform(t){return this.transforms.lmultiplyO(t),this}after(t){return this.on("finished",t)}animate(t,i,s){const e=nn.sanitise(t,i,s),n=new nn(e.duration);return this._timeline&&n.timeline(this._timeline),this._element&&n.element(this._element),n.loop(e).schedule(e.delay,e.when)}clearTransform(){return this.transforms=new Es,this}clearTransformsFromQueue(){this.done&&this._timeline&&this._timeline._runnerIds.includes(this.id)||(this._queue=this._queue.filter((t=>!t.isTransform)))}delay(t){return this.animate(0,t)}duration(){return this._times*(this._wait+this._duration)-this._wait}during(t){return this.queue(null,t)}ease(t){return this._stepper=new Re(t),this}element(t){return null==t?this._element:(this._element=t,t._prepareRunner(),this)}finish(){return this.step(1/0)}loop(t,i,s){return"object"==typeof t&&(i=t.swing,s=t.wait,t=t.times),this._times=t||1/0,this._swing=i||!1,this._wait=s||0,!0===this._times&&(this._times=1/0),this}loops(t){const i=this._duration+this._wait;if(null==t){const t=Math.floor(this._time/i);return Math.min(t+(this._time-t*i)/this._duration,this._times)}const s=Math.floor(t);return this.time(i*s+this._duration*(t%1))}persist(t){return null==t?this._persist:(this._persist=t,this)}position(t){const i=this._time,s=this._duration,e=this._wait,n=this._swing,r=this._reverse;let h;if(null==t){const t=function(t){const i=n*Math.floor(t%(2*(e+s))/(e+s)),h=i&&!r||!i&&r,o=Math.pow(-1,h)*(t%(e+s))/s+h;return Math.max(Math.min(o,1),0)},o=this._times*(e+s)-e;return h=i<=0?Math.round(t(1e-5)):i<o?t(i):Math.round(t(o-1e-5)),h}const o=Math.floor(this.loops()),a=n&&o%2==0;return h=o+(a&&!r||r&&a?t:1-t),this.loops(h)}progress(t){return null==t?Math.min(1,this._time/this.duration()):this.time(t*this.duration())}queue(t,i,s,e){return this._queue.push({initialiser:t||Bs,runner:i||Bs,retarget:s,isTransform:e,initialised:!1,finished:!1}),this.timeline()&&this.timeline()._continue(),this}reset(){return this._reseted||(this.time(0),this._reseted=!0),this}reverse(t){return this._reverse=null==t?!this._reverse:t,this}schedule(t,i,s){if(t instanceof en||(s=i,i=t,t=this.timeline()),!t)throw Error("Runner cannot be scheduled without timeline");return t.schedule(this,i,s),this}step(t){if(!this.enabled)return this;this._time+=t=null==t?16:t;const i=this.position(),s=this._lastPosition!==i&&this._time>=0;this._lastPosition=i;const e=this.duration(),n=this._lastTime<=0&&this._time>0,r=this._lastTime<e&&this._time>=e;this._lastTime=this._time,n&&this.fire("start",this);const h=this._isDeclarative;this.done=!h&&!r&&this._time>=e,this._reseted=!1;let o=!1;return(s||h)&&(this._initialise(s),this.transforms=new Es,o=this._run(h?t:i),this.fire("step",this)),this.done=this.done||o&&h,r&&this.fire("finished",this),this}time(t){return null==t?this._time:(this.step(t-this._time),this)}timeline(t){return void 0===t?this._timeline:(this._timeline=t,this)}unschedule(){const t=this.timeline();return t&&t.unschedule(this),this}_initialise(t){if(t||this._isDeclarative)for(let i=0,s=this._queue.length;i<s;++i){const s=this._queue[i],e=this._isDeclarative||!s.initialised&&t;t=!s.finished,e&&t&&(s.initialiser.call(this),s.initialised=!0)}}_rememberMorpher(t,i){if(this._history[t]={morpher:i,caller:this._queue[this._queue.length-1]},this._isDeclarative){const t=this.timeline();t&&t.play()}}_run(t){let i=!0;for(let s=0,e=this._queue.length;s<e;++s){const e=this._queue[s],n=e.runner.call(this,t);e.finished=e.finished||!0===n,i=i&&e.finished}return i}_tryRetarget(t,i,s){if(this._history[t]){if(!this._history[t].caller.initialised){const i=this._queue.indexOf(this._history[t].caller);return this._queue.splice(i,1),!1}this._history[t].caller.retarget?this._history[t].caller.retarget.call(this,i,s):this._history[t].morpher.to(i),this._history[t].caller.finished=!1;const e=this.timeline();return e&&e.play(),!0}return!1}}nn.id=0;class rn{constructor(t=new Es,i=-1,s=!0){this.transforms=t,this.id=i,this.done=s}clearTransformsFromQueue(){}}as([nn,rn],{mergeWith(t){return new rn(t.transforms.lmultiply(this.transforms),t.id)}});const hn=(t,i)=>t.lmultiplyO(i),on=t=>t.transforms;function an(){const t=this._transformationRunners.runners.map(on).reduce(hn,new Es);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}class ln{constructor(){this.runners=[],this.ids=[]}add(t){if(this.runners.includes(t))return;const i=t.id+1;return this.runners.push(t),this.ids.push(i),this}clearBefore(t){const i=this.ids.indexOf(t+1)||1;return this.ids.splice(0,i,0),this.runners.splice(0,i,new rn).forEach((t=>t.clearTransformsFromQueue())),this}edit(t,i){const s=this.ids.indexOf(t+1);return this.ids.splice(s,1,t+1),this.runners.splice(s,1,i),this}getByID(t){return this.runners[this.ids.indexOf(t+1)]}length(){return this.ids.length}merge(){let t=null;for(let i=0;i<this.runners.length;++i){const s=this.runners[i];if(!(t&&s.done&&t.done)||s._timeline&&s._timeline._runnerIds.includes(s.id)||t._timeline&&t._timeline._runnerIds.includes(t.id))t=s;else{this.remove(s.id);const e=s.mergeWith(t);this.edit(t.id,e),t=e,--i}}return this}remove(t){const i=this.ids.indexOf(t+1);return this.ids.splice(i,1),this.runners.splice(i,1),this}}Ni({Element:{animate(t,i,s){const e=nn.sanitise(t,i,s),n=this.timeline();return new nn(e.duration).loop(e).element(this).timeline(n.play()).schedule(e.delay,e.when)},delay(t,i){return this.animate(0,t,i)},_clearTransformRunnersBefore(t){this._transformationRunners.clearBefore(t.id)},_currentTransform(t){return this._transformationRunners.runners.filter((i=>i.id<=t.id)).map(on).reduce(hn,new Es)},_addRunner(t){this._transformationRunners.add(t),Ze.cancelImmediate(this._frameId),this._frameId=Ze.immediate(an.bind(this))},_prepareRunner(){null==this._frameId&&(this._transformationRunners=(new ln).add(new rn(new Es(this))))}}}),as(nn,{attr(t,i){return this.styleAttr("attr",t,i)},css(t,i){return this.styleAttr("css",t,i)},styleAttr(t,i,s){if("string"==typeof i)return this.styleAttr(t,{[i]:s});let e=i;if(this._tryRetarget(t,e))return this;let n=new Ye(this._stepper).to(e),r=Object.keys(e);return this.queue((function(){n=n.from(this.element()[t](r))}),(function(i){return this.element()[t](n.at(i).valueOf()),n.done()}),(function(i){const s=Object.keys(i),h=(o=r,s.filter((t=>!o.includes(t))));var o;if(h.length){const i=this.element()[t](h),s=new He(n.from()).valueOf();Object.assign(s,i),n.from(s)}const a=new He(n.to()).valueOf();Object.assign(a,i),n.to(a),r=s,e=i})),this._rememberMorpher(t,n),this},zoom(t,i){if(this._tryRetarget("zoom",t,i))return this;let s=new Ye(this._stepper).to(new Vs(t));return this.queue((function(){s=s.from(this.element().zoom())}),(function(t){return this.element().zoom(s.at(t),i),s.done()}),(function(t,e){i=e,s.to(t)})),this._rememberMorpher("zoom",s),this},transform(t,i,s){if(i=t.relative||i,this._isDeclarative&&!i&&this._tryRetarget("transform",t))return this;const e=Es.isMatrixLike(t);s=null!=t.affine?t.affine:null!=s?s:!e;const n=new Ye(this._stepper).type(s?Ie:Es);let r,h,o,a,l;return this.queue((function(){h=h||this.element(),r=r||zi(t,h),l=new Es(i?void 0:h),h._addRunner(this),i||h._clearTransformRunnersBefore(this)}),(function(c){i||this.clearTransform();const{x:u,y:d}=new $s(r).transform(h._currentTransform(this));let f=new Es({...t,origin:[u,d]}),p=this._isDeclarative&&o?o:l;if(s){f=f.decompose(u,d),p=p.decompose(u,d);const t=f.rotate,i=p.rotate,s=[t-360,t,t+360],e=s.map((t=>Math.abs(t-i))),n=Math.min(...e),r=e.indexOf(n);f.rotate=s[r]}i&&(e||(f.rotate=t.rotate||0),this._isDeclarative&&a&&(p.rotate=a)),n.from(p),n.to(f);const v=n.at(c);return a=v.rotate,o=new Es(v),this.addTransform(o),h._addRunner(this),n.done()}),(function(i){(i.origin||"center").toString()!==(t.origin||"center").toString()&&(r=zi(i,h)),t={...i,origin:r}}),!0),this._isDeclarative&&this._rememberMorpher("transform",n),this},x(t){return this._queueNumber("x",t)},y(t){return this._queueNumber("y",t)},ax(t){return this._queueNumber("ax",t)},ay(t){return this._queueNumber("ay",t)},dx(t=0){return this._queueNumberDelta("x",t)},dy(t=0){return this._queueNumberDelta("y",t)},dmove(t,i){return this.dx(t).dy(i)},_queueNumberDelta(t,i){if(i=new Vs(i),this._tryRetarget(t,i))return this;const s=new Ye(this._stepper).to(i);let e=null;return this.queue((function(){e=this.element()[t](),s.from(e),s.to(e+i)}),(function(i){return this.element()[t](s.at(i)),s.done()}),(function(t){s.to(e+new Vs(t))})),this._rememberMorpher(t,s),this},_queueObject(t,i){if(this._tryRetarget(t,i))return this;const s=new Ye(this._stepper).to(i);return this.queue((function(){s.from(this.element()[t]())}),(function(i){return this.element()[t](s.at(i)),s.done()})),this._rememberMorpher(t,s),this},_queueNumber(t,i){return this._queueObject(t,new Vs(i))},cx(t){return this._queueNumber("cx",t)},cy(t){return this._queueNumber("cy",t)},move(t,i){return this.x(t).y(i)},amove(t,i){return this.ax(t).ay(i)},center(t,i){return this.cx(t).cy(i)},size(t,i){let s;return t&&i||(s=this._element.bbox()),t||(t=s.width/s.height*i),i||(i=s.height/s.width*t),this.width(t).height(i)},width(t){return this._queueNumber("width",t)},height(t){return this._queueNumber("height",t)},plot(t,i,s,e){if(4===arguments.length)return this.plot([t,i,s,e]);if(this._tryRetarget("plot",t))return this;const n=new Ye(this._stepper).type(this._element.MorphArray).to(t);return this.queue((function(){n.from(this._element.array())}),(function(t){return this._element.plot(n.at(t)),n.done()})),this._rememberMorpher("plot",n),this},leading(t){return this._queueNumber("leading",t)},viewbox(t,i,s,e){return this._queueObject("viewbox",new Ls(t,i,s,e))},update(t){return"object"!=typeof t?this.update({offset:arguments[0],color:arguments[1],opacity:arguments[2]}):(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",t.offset),this)}}),as(nn,{rx:se,ry:ee,from:fe,to:pe}),ns(nn,"Runner");class cn extends Zs{constructor(t,i=t){super(is("svg",t),i),this.namespace()}defs(){return this.isRoot()?ss(this.node.querySelector("defs"))||this.put(new te):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof Ji.window.SVGElement)&&"#document-fragment"!==this.node.parentNode.nodeName}namespace(){return this.isRoot()?this.attr({xmlns:ji,version:"1.1"}).attr("xmlns:xlink",Xi,Vi):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,Vi).attr("xmlns:svgjs",null,Vi)}root(){return this.isRoot()?this:super.root()}}Ni({Container:{nested:ls((function(){return this.put(new cn)}))}}),ns(cn,"Svg",!0);class un extends Zs{constructor(t,i=t){super(is("symbol",t),i)}}Ni({Container:{symbol:ls((function(){return this.put(new un)}))}}),ns(un,"Symbol");var dn=Object.freeze({__proto__:null,amove:function(t,i){return this.ax(t).ay(i)},ax:function(t){return this.attr("x",t)},ay:function(t){return this.attr("y",t)},build:function(t){return this._build=!!t,this},center:function(t,i,s=this.bbox()){return this.cx(t,s).cy(i,s)},cx:function(t,i=this.bbox()){return null==t?i.cx:this.attr("x",this.attr("x")+t-i.cx)},cy:function(t,i=this.bbox()){return null==t?i.cy:this.attr("y",this.attr("y")+t-i.cy)},length:function(){return this.node.getComputedTextLength()},move:function(t,i,s=this.bbox()){return this.x(t,s).y(i,s)},plain:function(t){return!1===this._build&&this.clear(),this.node.appendChild(Ji.document.createTextNode(t)),this},x:function(t,i=this.bbox()){return null==t?i.x:this.attr("x",this.attr("x")+t-i.x)},y:function(t,i=this.bbox()){return null==t?i.y:this.attr("y",this.attr("y")+t-i.y)}});class fn extends ie{constructor(t,i=t){super(is("text",t),i),this.dom.leading=this.dom.leading??new Vs(1.3),this._rebuild=!0,this._build=!1}leading(t){return null==t?this.dom.leading:(this.dom.leading=new Vs(t),this.rebuild())}rebuild(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){const t=this;let i=0;const s=this.dom.leading;this.each((function(e){if(Bi(this.node))return;const n=Ji.window.getComputedStyle(this.node).getPropertyValue("font-size"),r=s*new Vs(n);this.dom.newLined&&(this.attr("x",t.attr("x")),"\n"===this.text()?i+=r:(this.attr("dy",e?r+i:0),i=0))})),this.fire("rebuild")}return this}setData(t){return this.dom=t,this.dom.leading=new Vs(t.leading||1.3),this}writeDataToDom(){return Hi(this,this.dom,{leading:1.3}),this}text(t){if(void 0===t){const i=this.node.childNodes;let s=0;t="";for(let e=0,n=i.length;e<n;++e)"textPath"===i[e].nodeName||Bi(i[e])?0===e&&(s=e+1):(e!==s&&3!==i[e].nodeType&&!0===ss(i[e]).dom.newLined&&(t+="\n"),t+=i[e].textContent);return t}if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else for(let i=0,s=(t=(t+"").split("\n")).length;i<s;i++)this.newLine(t[i]);return this.build(!1).rebuild()}}as(fn,dn),Ni({Container:{text:ls((function(t=""){return this.put(new fn).text(t)})),plain:ls((function(t=""){return this.put(new fn).plain(t)}))}}),ns(fn,"Text");class pn extends ie{constructor(t,i=t){super(is("tspan",t),i),this._build=!1}dx(t){return this.attr("dx",t)}dy(t){return this.attr("dy",t)}newLine(){this.dom.newLined=!0;const t=this.parent();if(!(t instanceof fn))return this;const i=t.index(this),s=Ji.window.getComputedStyle(this.node).getPropertyValue("font-size"),e=t.dom.leading*new Vs(s);return this.dy(i?e:0).attr("x",t.x())}text(t){return null==t?this.node.textContent+(this.dom.newLined?"\n":""):("function"==typeof t?(this.clear().build(!0),t.call(this,this),this.build(!1)):this.plain(t),this)}}as(pn,dn),Ni({Tspan:{tspan:ls((function(t=""){const i=new pn;return this._build||this.clear(),this.put(i).text(t)}))},Text:{newLine:function(t=""){return this.tspan(t).newLine()}}}),ns(pn,"Tspan");class vn extends ie{constructor(t,i=t){super(is("circle",t),i)}radius(t){return this.attr("r",t)}rx(t){return this.attr("r",t)}ry(t){return this.rx(t)}size(t){return this.radius(new Vs(t).divide(2))}}as(vn,{x:ne,y:re,cx:he,cy:oe,width:ae,height:le}),Ni({Container:{circle:ls((function(t=0){return this.put(new vn).size(t).move(0,0)}))}}),ns(vn,"Circle");class mn extends Zs{constructor(t,i=t){super(is("clipPath",t),i)}remove(){return this.targets().forEach((function(t){t.unclip()})),super.remove()}targets(){return Ds("svg [clip-path*="+this.id()+"]")}}Ni({Container:{clip:ls((function(){return this.defs().put(new mn)}))},Element:{clipper(){return this.reference("clip-path")},clipWith(t){const i=t instanceof mn?t:this.parent().clip().add(t);return this.attr("clip-path","url(#"+i.id()+")")},unclip(){return this.attr("clip-path",null)}}}),ns(mn,"ClipPath");class gn extends Qs{constructor(t,i=t){super(is("foreignObject",t),i)}}Ni({Container:{foreignObject:ls((function(t,i){return this.put(new gn).size(t,i)}))}}),ns(gn,"ForeignObject");var bn=Object.freeze({__proto__:null,dmove:function(t,i){return this.children().forEach((s=>{let e;try{e=s.node instanceof Ji.window.SVGSVGElement?new Ls(s.attr(["x","y","width","height"])):s.bbox()}catch(t){return}const n=new Es(s),r=n.translate(t,i).transform(n.inverse()),h=new $s(e.x,e.y).transform(r);s.move(h.x,h.y)})),this},dx:function(t){return this.dmove(t,0)},dy:function(t){return this.dmove(0,t)},height:function(t,i=this.bbox()){return null==t?i.height:this.size(i.width,t,i)},move:function(t=0,i=0,s=this.bbox()){return this.dmove(t-s.x,i-s.y)},size:function(t,i,s=this.bbox()){const e=Yi(this,t,i,s),n=e.width/s.width,r=e.height/s.height;return this.children().forEach((t=>{const i=new $s(s).transform(new Es(t).inverse());t.scale(n,r,i.x,i.y)})),this},width:function(t,i=this.bbox()){return null==t?i.width:this.size(t,i.height,i)},x:function(t,i=this.bbox()){return null==t?i.x:this.move(t,i.y,i)},y:function(t,i=this.bbox()){return null==t?i.y:this.move(i.x,t,i)}});class wn extends Zs{constructor(t,i=t){super(is("g",t),i)}}as(wn,bn),Ni({Container:{group:ls((function(){return this.put(new wn)}))}}),ns(wn,"G");class yn extends Zs{constructor(t,i=t){super(is("a",t),i)}target(t){return this.attr("target",t)}to(t){return this.attr("href",t,Xi)}}as(yn,bn),Ni({Container:{link:ls((function(t){return this.put(new yn).to(t)}))},Element:{unlink(){const t=this.linker();if(!t)return this;const i=t.parent();if(!i)return this.remove();const s=i.index(t);return i.add(this,s),t.remove(),this},linkTo(t){let i=this.linker();return i||(i=new yn,this.wrap(i)),"function"==typeof t?t.call(i,i):i.to(t),this},linker(){const t=this.parent();return t&&"a"===t.node.nodeName.toLowerCase()?t:null}}}),ns(yn,"A");class Sn extends Zs{constructor(t,i=t){super(is("mask",t),i)}remove(){return this.targets().forEach((function(t){t.unmask()})),super.remove()}targets(){return Ds("svg [mask*="+this.id()+"]")}}Ni({Container:{mask:ls((function(){return this.defs().put(new Sn)}))},Element:{masker(){return this.reference("mask")},maskWith(t){const i=t instanceof Sn?t:this.parent().mask().add(t);return this.attr("mask","url(#"+i.id()+")")},unmask(){return this.attr("mask",null)}}}),ns(Sn,"Mask");class xn extends Qs{constructor(t,i=t){super(is("stop",t),i)}update(t){return("number"==typeof t||t instanceof Vs)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new Vs(t.offset)),this}}Ni({Gradient:{stop:function(t,i,s){return this.put(new xn).update(t,i,s)}}}),ns(xn,"Stop");class On extends Qs{constructor(t,i=t){super(is("style",t),i)}addText(t=""){return this.node.textContent+=t,this}font(t,i,s={}){return this.rule("@font-face",{fontFamily:t,src:i,...s})}rule(t,i){return this.addText(function(t,i){if(!t)return"";if(!i)return t;let s=t+"{";for(const t in i)s+=t.replace(/([A-Z])/g,(function(t,i){return"-"+i.toLowerCase()}))+":"+i[t]+";";return s+="}",s}(t,i))}}Ni("Dom",{style(t,i){return this.put(new On).rule(t,i)},fontface(t,i,s){return this.put(new On).font(t,i,s)}}),ns(On,"Style");class _n extends fn{constructor(t,i=t){super(is("textPath",t),i)}array(){const t=this.track();return t?t.array():null}plot(t){const i=this.track();let s=null;return i&&(s=i.plot(t)),null==t?s:this}track(){return this.reference("href")}}Ni({Container:{textPath:ls((function(t,i){return t instanceof fn||(t=this.text(t)),t.path(i)}))},Text:{path:ls((function(t,i=!0){const s=new _n;let e;if(t instanceof Ve||(t=this.defs().path(t)),s.attr("href","#"+t,Xi),i)for(;e=this.node.firstChild;)s.node.appendChild(e);return this.put(s)})),textPath(){return this.findOne("textPath")}},Path:{text:ls((function(t){return t instanceof fn||(t=(new fn).addTo(this.parent()).text(t)),t.path(this)})),targets(){return Ds("svg textPath").filter((t=>(t.attr("href")||"").includes(this.id())))}}}),_n.prototype.MorphArray=Fe,ns(_n,"TextPath");class Mn extends ie{constructor(t,i=t){super(is("use",t),i)}use(t,i){return this.attr("href",(i||"")+"#"+t,Xi)}}Ni({Container:{use:ls((function(t,i){return this.put(new Mn).use(t,i)}))}}),ns(Mn,"Use"),as([cn,un,be,ge,xe],Di("viewbox")),as([Se,qe,Je,Ve],Di("marker")),as(fn,Di("Text")),as(Ve,Di("Path")),as(te,Di("Defs")),as([fn,pn],Di("Tspan")),as([Qe,ue,me,nn],Di("radius")),as(Is,Di("EventTarget")),as(qs,Di("Dom")),as(Qs,Di("Element")),as(ie,Di("Shape")),as([Zs,de],Di("Container")),as(me,Di("Gradient")),as(nn,Di("Runner")),Cs.extend([...new Set(Ci)]),function(t=[]){je.push(...[].concat(t))}([Vs,Rs,Ls,Es,js,we,Fe,$s]),as(je,{to(t){return(new Ye).type(this.constructor).from(this.toArray()).to(t)},fromArray(t){return this.init(t),this},toConsumable(){return this.toArray()},morph(t,i,s,e,n){return this.fromArray(t.map((function(t,r){return e.step(t,i[r],s,n[r],n)})))}});let Rn=class{constructor(t,i,s,e,n,r,h,o){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=e,this.leftSideLengthSync=n,this.topSideLabelHeight=r>0?this.fontSize:0,this.leftSideLabelLength=this.calculateSideLabelLength(r,h,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}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,e){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<e/2&&(this.axisPosition.x=e/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){return t?.5*this.getBarWidth()+this.spacings.scenarioLabelToBar:-(.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}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const e=t/2;let n=i;return e>n&&(n=e),s>n&&(n=s),n}},$n=class{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}},kn=class{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}},En=class{constructor(t){this.container=new cn,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 Tn,Pn,Ln;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Tn||(Tn={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Pn||(Pn={}));class An{constructor(t="",i=1){this.prefix=t,this.value=i}}!function(t){t[t.Y=1e24]="Y",t[t.Z=1e21]="Z",t[t.E=1e18]="E",t[t.P=1e15]="P",t[t.T=1e12]="T",t[t.G=1e9]="G",t[t.M=1e6]="M",t[t.k=1e3]="k",t[t.h=100]="h",t[t.da=10]="da",t[t.d=.1]="d",t[t.c=.01]="c",t[t.m=.001]="m",t[t.my=1e-6]="my",t[t.n=1e-9]="n",t[t.p=1e-12]="p",t[t.f=1e-15]="f",t[t.a=1e-18]="a",t[t.z=1e-21]="z",t[t.y=1e-24]="y"}(Ln||(Ln={}));class Cn{static calculateMeasureScale(t,i,s,e){var n,r;if("_"===e)return new An;if(null!=e&&[...this.unitsLeast,...this.unitsGreat].includes(e))return this.lookupPrefix(e);if(0===s.length||!i)return new An;const h=`SELECT MAX(GREATEST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`,o=`SELECT MIN(LEAST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`;let a,l=h;"LEAST"===(null==e?void 0:e.toUpperCase())&&(l=o);try{a=null!==(r=null===(n=t.exec(l)[0])||void 0===n?void 0:n.prefixvalue)&&void 0!==r?r:0}catch(t){return console.error("DataAnalyzer: measure-scale query failed",l,t),new An}return this.determinePrefix(Math.abs(a))}static determinePrefix(t){if(t>=1e3){const i=Math.floor(Math.floor(Math.abs(t)).toString().length/3),s=+Math.pow(1e3,i);return new An(this.unitsGreat[i-1],s)}if(t<=.001){const i=Math.floor(Math.abs(t).toString().length/3),s=1/Math.pow(1e3,i);return new An(this.unitsLeast[i-1],s)}return new An}static lookupPrefix(t){return new An(t,Ln[t])}}Cn.unitsGreat=["k","M","G","T","P","E","Z","Y"],Cn.unitsLeast=["m","my","n","p","P","f","a","z","y"];class Nn{adapt(t){return at.adaptDefaultString(t)}default(){return""}}class Dn{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 ct(new Nn).default(),this.level=L.CATEGORY,this.filter="",this.measureScale=new An,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class Un{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=at.adaptArray(t.data,this.dataRowAdapter),s=at.adaptArray(t.scenarios,this.stringAdapter),e=new Dn(i,s);return lt.isArray(t.variances)&&(e.variances=at.adaptArray(t.variances,this.stringAdapter)),lt.isString(t.title)&&(e.title=t.title),lt.isBoolean(t.hideCategories)&&(e.hideCategories=t.hideCategories),lt.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),lt.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),lt.isNumber(t.limit)&&(e.limit=t.limit),lt.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),lt.isExisting(t.level)&&(e.level=t.level),lt.isString(t.filter)&&(e.filter=t.filter.trim()),lt.isExisting(t.measureScale)&&(e.measureScale=Cn.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),lt.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),lt.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),lt.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),lt.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),e}default(){return new Dn([],[])}}let Gn=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===Hn.NEG?Hn.NEG:"pos"===e||e===Hn.POS?Hn.POS:Hn.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:Hn.NEU===this.variance?Hn.NEU:Hn.POS===this.variance?Hn.NEG:Hn.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 Fn{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 Wn{constructor(){}adapt(t){const i=new Fn;return lt.isOperator(t.operation)&&(i.operation=t.operation),lt.isNumber(t.rowGroupIndex)&<.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),lt.isNumber(t.categoryIndex)&<.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),lt.isNumber(t.subCategoryIndex)&<.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),lt.isNumber(t.columnGroupIndex)&<.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),lt.isNumber(t.columnSubGroupIndex)&<.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 Fn}setActualValues(t,i){lt.isNumber(t.ac1)&&(i.ac1=t.ac1),lt.isNumber(t.ac2)&&(i.ac2=t.ac2),lt.isNumber(t.ac3)&&(i.ac3=t.ac3),lt.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){lt.isNumber(t.pl1)&&(i.pl1=t.pl1),lt.isNumber(t.pl2)&&(i.pl2=t.pl2),lt.isNumber(t.pl3)&&(i.pl3=t.pl3),lt.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){lt.isNumber(t.pp1)&&(i.pp1=t.pp1),lt.isNumber(t.pp2)&&(i.pp2=t.pp2),lt.isNumber(t.pp3)&&(i.pp3=t.pp3),lt.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){lt.isNumber(t.fc1)&&(i.fc1=t.fc1),lt.isNumber(t.fc2)&&(i.fc2=t.fc2),lt.isNumber(t.fc3)&&(i.fc3=t.fc3),lt.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Yn{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class zn{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Yn(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return lt.isExisting(t)&&(lt.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),lt.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),lt.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),lt.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),lt.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),lt.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 kn(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Yn(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class In{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 Bn{adapt(t){const i=new In;return lt.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),lt.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),lt.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),lt.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),lt.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),lt.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),lt.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),lt.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),lt.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),lt.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),lt.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),lt.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),lt.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),lt.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),lt.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new In}}var Hn,jn;!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"}(Hn||(Hn={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(jn||(jn={}));const Vn=["pl","fc","pp","ac"];function Xn(t){return t.replace(/\d+$/,"")}function Jn(t){return.299*parseInt(t.slice(1,3),16)+.587*parseInt(t.slice(3,5),16)+.114*parseInt(t.slice(5,7),16)>128?"#000000":"#ffffff"}var qn;!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"}(qn||(qn={}));let Qn=class{constructor(t,i,s,e,n,r,h,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=n,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),e))),this.styles=r,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=h||qn.Top,this.horizontalHookLocation=o||qn.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 An){var s;if(this.isEmpty())return this;const e=this.group;let n;const r=this.styles.fontStyles.background||"#ffffff";let h="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,e=t.percent,r=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,e=t.decimal,r=i.value,a="decimal"),n=At.number(Number(this.value),a,s,e,r),Number(this.value)<0&&(o="end"),this.isVarianceLabel&&Number(this.value)>=0&&(h="+")}else n=""+this.value,o="start";const a=e.text(h+n);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===qn.Right?(o="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===qn.Center&&(o="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===qn.Center?a.move(a.x(),a.y()-c/2):this.verticalHookLocation===qn.Bottom&&a.move(a.x(),a.y()-c),a.font({anchor:o}),null!=this.segmentFillColor?a.fill(Jn(this.segmentFillColor)):null==e||e.rect(l,.9*c).stroke(r).fill(r).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}},Kn=class{constructor(t,i,s,e){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=e,this.label=new Qn(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,qn.Bottom,qn.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 Zn{constructor(t,i,s,e,n,r,h,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=e,this.isPrimaryBar=n,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=r,this.styles=i,null!=r&&(this.barGroup=r.group().id(r.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=qn.Left;s.value<0&&(i=qn.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new Qn(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,qn.Center,i),this.scenarioLabel=this.getScenarioLabel(h)}}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 An){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 e=this.convertToSVGStyle(s,"stroke");let n=this.convertToSVGStyle(s,"fill");const r=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=r){const t=this.styles.pattern.get(r);null!=t&&(n=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(n).stroke(e).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(),e=this.position.getBarWidth(),n=this.dimensions.barLength,{breakGap:r}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(n,e).fill(t).stroke(i).x(s-n).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s-n-r-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-n-r,r)):(this.barGroup.rect(n,e).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s+n+r).cy(this.dimensions.yPos),this.drawBreakIndicator(s+n,r))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),e=this.dimensions.yPos-s/2,n=t+i/2,r=.35*i,h=s/3;let o=`M ${n-r} ${e}`;for(let t=0;t<3;t++)o+=` L ${n-r-.3*i} ${e+h*(t+.5)} L ${n-r} ${e+h*(t+1)}`;let a=`M ${n+r} ${e}`;for(let t=0;t<3;t++)a+=` L ${n+r+.3*i} ${e+h*(t+.5)} L ${n+r} ${e+h*(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,e){const n=i.getScaledUnit(),r=Math.abs(n);if(this.overflowConfig&&r>0){const h="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(r>h){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(r-h)/a*o:0;const l=h+i+this.overdriveWidth;return n<0?{clipped:!1,barLength:h,xPos:t.getBarPositionX()-h,yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*h,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:h,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*h,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}}}return n<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()+n,yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()-.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:n,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()+.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}}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 An){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 Qn(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?qn.Top:qn.Bottom,qn.Center)}}let tr=class{constructor(t,i,s,e,n,r,h,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=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,h,a),this.scenarioLabel=this.getScenarioLabel(o,n,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 Qn(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?qn.Bottom:qn.Top,qn.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)}},ir=class{constructor(t,i,s,e,n){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=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,e);let i=qn.Left;s.value<0&&(i=qn.Right),this.label=new Qn(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,qn.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 e=i.fill;const n=this.barStyles[this.dataPoint.getScenario()];if(null!=n&&n.fillpattern){const t=this.styles.pattern.get(n.fillpattern);null!=t&&null!=t.pattern&&(e=t.pattern)}this.drawNeedleHead(e,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(e).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,e=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(e)}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 sr{constructor(t,i,s,e,n,r,h,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=h,this.stackMode=o,this.totalValue=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${e}_seg_${h}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new An){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidth();let h,o;if(this.stackMode===U.RELATIVE){const t=e;h=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=n+this.baselineValue/Math.abs(this.totalValue)*t}else h=Math.abs(s*e),o=n+this.baselineValue*e;const a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};this.barGroup.rect(Math.max(h,.5),r).fill(u).stroke(d).cy(a).x(o);const f=h-6;if(f>0){const e=o+h/2;if(this.stackMode===U.RELATIVE||this.stackMode===U.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Qn(this.group,e,a,"STACK_SEG",i,this.styles,qn.Center,qn.Center).setSegmentFill(c).setMaxWidth(f).draw()}else new Qn(this.group,e,a,"STACK_SEG",s,this.styles,qn.Center,qn.Center).setSegmentFill(c).setMaxWidth(f).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new An){if(this.stackMode===U.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,e=this.position.getBarPositionY(this.index,!0);new Qn(this.group,s,e,"STACK_TOTAL",this.totalValue,this.styles,qn.Center,qn.Left).draw(t,i)}}let er=class{constructor(t,i,s,e,n){this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),h=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:h,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,e,n,r;const h=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Zn(this.position,this.styles,t,i,!0,h,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,e,n,r;const h=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Zn(this.position,this.styles,t,i,!0,h,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,e,n,r;const h=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);return new ir(this.position,this.styles,t,i,h).updateLabelGroup(o)}createSecondaryBar(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===e?void 0:e.group().id(""+i);let r=null;return this.isFirsttDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Zn(this.position,this.styles,t,i,!1,n,r,this.overflowConfig)}createPrimaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===e?void 0:e.group().id(""+i),r=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 h=null;return this.isFirstDataPoint(i)&&(h=`${this.i18n.get(t.scenario)||t.scenario}`),new tr(this.position,n,r,t.scenario,this.styles,t,i,h,!0)}createSecondaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===e?void 0:e.group().id(""+i),r=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 h=null;return this.isLastDataPoint(i)&&(h=`${this.i18n.get(t.scenario)||t.scenario}`),new tr(this.position,n,r,t.scenario,this.styles,t,i,h,!1)}isFirstDataPoint(t){return 0===t}};class nr{constructor(){this._dateFormat={year:"YYYY",quarter:"Q[Q] YYYY",month:"MMM YYYY",locale:"[KW]WW YYYY",day:"DD.MM.YYYY"},this._dateLinkFormat={avg:"Ø[DATE]",interval:"[DATE]..[DATE]",start:".[DATE]",end:"[DATE].",ytd:"_[DATE]",ytg:"[DATE]_",cum:"[DATE]_[DATE]",mat:"~[DATE]",none:"[DATE]"},this._scenarioMap=new Map,this._fallBackScenario={name:"Series",group:"Series",colorIndex:10,sortIndex:120},this.createScenarioMapEntry("ac","AC",10,400),this.createScenarioMapEntry("fc","FC",30,300),this.createScenarioMapEntry("pl","PL",50,200),this.createScenarioMapEntry("bu","BU",50,200),this.createScenarioMapEntry("pp","PP",20,100),this.createScenarioMapEntry("py","PY",20,100),this.createScenarioMapEntry("dac","dAC",10,1400),this.createScenarioMapEntry("dfc","dFC",30,1300),this.createScenarioMapEntry("dpl","dPL",50,1200),this.createScenarioMapEntry("dbu","dBU",50,1200),this.createScenarioMapEntry("dpp","dPP",20,1100),this.createScenarioMapEntry("dpy","dPY",20,1100),this.createScenarioMapEntry("drac","drAC",10,2400),this.createScenarioMapEntry("drfc","drFC",30,2300),this.createScenarioMapEntry("drpl","drPL",50,2200),this.createScenarioMapEntry("drbu","drBU",50,2200),this.createScenarioMapEntry("drpp","drPP",20,2100),this.createScenarioMapEntry("drpy","drPY",20,2100)}createScenarioMapEntry(t,i,s,e){const n=i,r=s;[1,2,3,4].forEach((s=>{this._scenarioMap.set(t+s,{name:i+s,group:n,colorIndex:r,sortIndex:e+10*s})}))}getScenario(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t):this._fallBackScenario}getScenarioGroup(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).name:this._fallBackScenario.name}getScenarioColorIndex(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).colorIndex:this._fallBackScenario.colorIndex}getScenarioSorIndex(t){const i=this.normalizeVarianceScenario(t);return this._scenarioMap.has(i)?this._scenarioMap.get(i).sortIndex:this._fallBackScenario.sortIndex}normalizeVarianceScenario(t){if(null==t)return"";const i=new $t(t);return i.isValid?i.type+i.delta:t}}class rr{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.smallestDataPointValue=new Gn(0,Hn.AC1,1,Hn.NEU),this.highestDataPointValue=new Gn(0,Hn.AC1,1,Hn.NEU),this.smallestVarianceDataPointValue=new Gn(0,Hn.AC1,1,Hn.NEU),this.highestVarianceDataPointValue=new Gn(0,Hn.AC1,1,Hn.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=Hn.AC1,this.CSS_CATEGORIES="categories",this.state=Tn.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new An,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.overflowConfig=null,this.highestStackedTotal=0,this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new nr,this.i18n=this.createI18n(new Map),this.styles=n,this.setConfig(e),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 Rn(new $n(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i)}setStyles(t){this.styles=t}setConfig(t){var i;this.state=Tn.DIRTY,this.sortScenariosbyVisualisationRules(t),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(t.scenarios,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==N.SCENARIOS&&this.populateDimensionStackSegments(t.scenarios,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.title=t.title||At.translateScenarioLabel(null===(i=null==t?void 0:t.variances)||void 0===i?void 0:i.toString(),this.i18n),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;t.scenarios.sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t)}createI18n(t){this.state=Tn.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=Tn.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(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===U.RELATIVE?1:this.highestStackedTotal;const s=this.getVarianceType();return s===Pn.NONE&&null!=(null===(t=this.highestDataPointValue)||void 0===t?void 0:t.value)?Math.abs(this.highestDataPointValue.value):s===Pn.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.dataModel.length+1)*this.position.spacings.categoryWidth+this.styles.padding.top+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}toString(){const t=new cn;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===Tn.DIRTY&&(this.state=Tn.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=Lt(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?" ":At.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=Hn.AC1;if(null!=t&&t.length>0){const s=new $t(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=Hn.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const e=[],n=this.createOrderStr(i,s),r=this.createSelectString(i,s),h=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${r} ${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 ${h}\n ORDER BY ${n}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,e,t),this.crateRESTRow(o,t,e),e}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new $t(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 e=[],n=t.slice(this.limit,t.length);this.createDataRows(n,e,i);const r=e.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new Gn(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,Hn.NEU),scenario2:new Gn(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,Hn.NEU),scenario3:new Gn(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,Hn.NEU),scenario4:new Gn(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,Hn.NEU)}}),{id:9999,category:"REST",type:Pn.NONE,scenario1:new Gn(0,i[0],this.pixelPerUnit,Hn.NEU),scenario2:new Gn(0,i[1],this.pixelPerUnit,Hn.NEU),scenario3:new Gn(0,i[2],this.pixelPerUnit,Hn.NEU),scenario4:new Gn(0,i[3],this.pixelPerUnit,Hn.NEU)});s.push(r)}createDataRows(t,i,s){let e=t;this.limit>0&&(e=t.slice(0,this.limit)),e.forEach(((t,e)=>{i.push({id:e,category:t.category,type:Pn.NONE,scenario1:new Gn(t[s[0]],s[0],this.pixelPerUnit,Hn.NEU),scenario2:new Gn(t[s[1]],s[1],this.pixelPerUnit,Hn.NEU),scenario3:new Gn(t[s[2]],s[2],this.pixelPerUnit,Hn.NEU),scenario4:new Gn(t[s[3]],s[3],this.pixelPerUnit,Hn.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===L.CATEGORY&&i.hierarchy.includes(C.CATEGORYINDEX)?`${C.CATEGORYINDEX}, ${L.CATEGORY} as category`:t===L.ROWGROUP&&i.hierarchy.includes(C.ROWGROUPINDEX)?`${C.ROWGROUPINDEX}, ${L.ROWGROUP} as category`:t===L.SUBCATEGORY&&i.hierarchy.includes(C.SUBCATEGORYINDEX)?`${C.SUBCATEGORYINDEX}, ${L.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===L.CATEGORY&&i.hierarchy.includes(C.CATEGORYINDEX)?`${C.CATEGORYINDEX}, ${L.CATEGORY}`:t===L.ROWGROUP&&i.hierarchy.includes(C.ROWGROUPINDEX)?`${C.ROWGROUPINDEX}, ${L.ROWGROUP}`:t===L.SUBCATEGORY&&i.hierarchy.includes(C.SUBCATEGORYINDEX)?`${C.SUBCATEGORYINDEX}, ${L.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=Lt(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 Gn(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 Gn(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===N.SCENARIOS;let s=0;for(const e of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>Xn(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=Xn(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 e.stackSegments&&e.stackSegments.length>0&&(t=e.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 e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new $t(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction;let h=this.pixelPerUnit;"dr"===r.type&&(h=this.pixelPerPercentage);for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Pn.RELATIVE:Pn.ABSOLUTE,scenario1:new Gn(this.calculateVariance(r,i[e],t),r.base,h,n),scenario2:new Gn(null,null,null,null),scenario3:new Gn(null,null,null,null),scenario4:new Gn(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n?null:t.type===Pn.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}calculateTextBoxWidth(t){return Lt(At.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+=Lt("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=Lt(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,Lt(At.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 e=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===Pn.RELATIVE&&(e=!0);let n=qn.Right,r=!0;t.scenario1.value<0&&(n=qn.Left,r=!1),new Qn(s,this.position.getCategoryPositionX(r),this.position.getBarCenterPositionY(i),"",t.category,this.styles,qn.Center,n).draw()})),new Kn({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new er(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new er(this.position,s,this.styles,t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===Pn.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===N.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e)for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Xn(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Xn(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of Vn)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),h=e.length-1-n;let o=0,a=null;t.segments.forEach((t=>{const e=new sr(this.position,this.styles,t.dataPoint,i,o,t.scenario,h,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=e})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let n=r;!e&&t.stackSegments&&t.stackSegments.length>0&&(n=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?n.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&n.sort(((t,i)=>i.value-t.value));const h=n.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,a=null;n.forEach(((t,n)=>{const r=new sr(this.position,this.styles,t.dataPoint,i,o,t.scenario,n,this.stackConfig.mode,h,e,s);r.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=r})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===N.SCENARIOS,e=i.group().id("StackedHeaders"),n=t[0];if(!s){const t=n.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),r=this.position.getBarPositionX(),h=this.position.getAxisTitlePositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===U.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const a=r+o+n/2,l=this.i18n.get(t.label)||t.label;new Qn(e,a,h,"STACK_HEADER",l,this.styles,qn.Bottom,qn.Center).draw(),o+=n}))}const r=["scenario1","scenario2","scenario3","scenario4"],h=[];for(const t of r){const i=n[t];i&&!i.isEmpty()&&null!=i.value&&h.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===h.length)return;const o=new Set(h.map((t=>Xn(t.scenario)))),a=this.position.getBarPositionX(),l=this.position.getAxisTitlePositionY();if(o.size>1){const t=new Map;for(const i of h){const s=Xn(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of Vn)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,n=a+(this.stackConfig.mode===U.RELATIVE?s:i*s)/2,r=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Qn(e,n,l,"STACK_HEADER",r,this.styles,qn.Bottom,qn.Center).draw()}))}else{"asc"===this.stackConfig.order?h.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&h.sort(((t,i)=>i.value-t.value));const t=h.reduce(((t,i)=>t+Math.abs(i.value)),0);let i=0;h.forEach((s=>{const n=s.dataPoint.pixelPerUnit;let r;r=this.stackConfig.mode===U.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*n:Math.abs(s.value*n);const h=a+i+r/2,o=this.i18n.get(s.scenario)||s.scenario;new Qn(e,h,l,"STACK_HEADER",o,this.styles,qn.Bottom,qn.Center).draw(),i+=r}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:Pn.NONE}calculateLeftSideWidth(t){var i,s,e;let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Pn.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);n=Math.abs(this.smallestDataPointValue.getScaledUnit())+r+t}else if(Pn.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);n=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(Pn.ABSOLUTE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}calculateRightSideWidth(t){var i,s,e;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===U.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Pn.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);n=Math.abs(this.highestDataPointValue.getScaledUnit())+r+t}else if(Pn.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);n=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(Pn.ABSOLUTE===t&&null!=(null===(e=this.highestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[L.ROWGROUP]:"category",[L.ROWGROUPINDEX]:"category",[L.CATEGORY]:"subCategory",[L.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let h;try{h=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of h){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 Gn(t.value,r,this.pixelPerUnit,Hn.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,e=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new Gn(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new Gn(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new Gn(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new Gn(-e,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()===Pn.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,e=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,n=s.getScaledUnit(),r=null!=e.value?Math.abs(e.getScaledUnit()):0,h=Math.max(n,r);if(h<=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 h<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:h-f,scenarioCutOffset:u}}}class hr{constructor(t=2,i=1){this.percent=t,this.decimal=i}}class or{adapt(t){const i=new hr;return lt.isNumber(t.percent)&&(i.percent=t.percent),lt.isNumber(t.decimal)&&(i.decimal=t.decimal),i}default(){return new hr}}class ar{constructor(){this.font="16px Arial",this.size=16,this.color="#000000",this.background="#ffffff",this.leading=1.8}}class lr{adapt(t){const i=new ar;return lt.isString(t.font)&&(i.font=t.font),lt.isNumber(t.size)&&(i.size=t.size),lt.isString(t.color)&&(i.color=t.color),lt.isString(t.background)&&(i.background=t.background),lt.isNumber(t.leading)&&(i.leading=t.leading),i}default(){return new ar}}class cr{constructor(t,i,s,e){this.ac=t,this.fc=i,this.pp=s,this.pl=e}getSVGStyle(t){return"ac"===t?this.ac:"fc"===t?this.fc:"pp"===t?this.pp:"pl"===t?this.pl:this.ac}}class ur{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new cr(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL());return lt.isExisting(t.ac)&&(i.ac=this.svgStyleAdapter.adapt(t.ac)),lt.isExisting(t.fc)&&(i.fc=this.svgStyleAdapter.adapt(t.fc)),lt.isExisting(t.pp)&&(i.pp=this.svgStyleAdapter.adapt(t.pp)),lt.isExisting(t.pl)&&(i.pl=this.svgStyleAdapter.adapt(t.pl)),i}default(){return new cr(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL())}}let dr=class{constructor(){this.top=10,this.left=10,this.right=10,this.bottom=10}};class fr{adapt(t){const i=new dr;return lt.isNumber(t.top)&&(i.top=t.top),lt.isNumber(t.left)&&(i.left=t.left),lt.isNumber(t.right)&&(i.right=t.right),lt.isNumber(t.bottom)&&(i.bottom=t.bottom),i}default(){return new dr}}class pr{constructor(t="#000000",i="#000000",s=.1){this.stroke=t,this.fill=i,this.width=s}}class vr{adapt(t){const i=new pr(t.stroke,t.fill,t.width);return lt.isString(t.fillpattern)&&(i.fillpattern=t.fillpattern),lt.isString(t.dasharray)&&(i.dasharray=t.dasharray),i}default(){return new pr("#000000","#000000",.3)}defaultAC(){return new pr("#000000","#000000",.3)}defaultFC(){const t=new pr("#000000","#000000",.3);return t.dasharray="10 5 5 5",t.fillpattern="fc",t}defaultPP(){return new pr("#999999","#999999",.3)}defaultPL(){return new pr("#000000","#ffffff",.3)}defaultPos(){return new pr("#00ff00","#00ff00",.3)}defaultNeg(){return new pr("#ff0000","#ff0000",.3)}defaultNeu(){return new pr("#999999","#999999",.3)}}class mr{constructor(t,i,s){this.pos=t,this.neg=i,this.neu=s,this.needleHeadColour="#000000"}getSVGStyle(t){return"pos"===t?this.pos:"neg"===t?this.neg:this.neu}}class gr{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new mr(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu());return lt.isExisting(t.pos)&&(i.pos=this.svgStyleAdapter.adapt(t.pos)),lt.isExisting(t.neg)&&(i.neg=this.svgStyleAdapter.adapt(t.neg)),lt.isExisting(t.pp)&&(i.neu=this.svgStyleAdapter.adapt(t.neu)),lt.isString(t.needleHeadColour)&&(i.needleHeadColour=t.needleHeadColour),i}default(){return new mr(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu())}}const br=class{constructor(i){t(this,i),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:A.ASC},this.level=L.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=u(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new rr(new nr,i,this.tableName,s,e),this.chart.setI18n(this.i18n),this.autoFitScaling(s,e),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new En(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.setConfig(i),this.autoFitScaling(i,s),this.chart.setAvailableWidth((null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new En(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,h=this.getDb();if(!r||r<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),this.chart=new rr(new nr,h,this.tableName,t,i),void this.chart.setI18n(this.i18n);e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),this.chart=new rr(new nr,h,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();e&&(t.pixelPerUnit=a>0?Math.max(.001,(r-(o-a))/a):.9*r/o),n&&(t.pixelPerPercentage=.9*r/o),this.chart=new rr(new nr,h,this.tableName,t,i),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?g(this.tableName,this.filter):"";return new Un(new Wn,new ct(new Nn),new Nn,new or,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 zn(new Bn,new lr,new ur(new vr),new gr(new vr),new fr).adapt(this.styles)}get element(){return e(this)}};br.style=':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}';class wr{constructor(){this.scenarioOffset=.3,this.scenarioLabelToColumn=.3,this.labelToColumn=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.columnWidth=2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=3,this.axisTickLength=.3}}class yr{adapt(t){const i=new wr;return lt.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),lt.isNumber(t.scenarioLabelToColumn)&&(i.scenarioLabelToColumn=t.scenarioLabelToColumn),lt.isNumber(t.labelToColumn)&&(i.labelToColumn=t.labelToColumn),lt.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),lt.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),lt.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),lt.isNumber(t.columnWidth)&&(i.columnWidth=t.columnWidth),lt.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),lt.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),lt.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),lt.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),lt.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),lt.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),lt.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),lt.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new wr}}class Sr{constructor(t,i,s,e,n,r,h){this.categoryPosition={x:0,y:0},this.spacings=new wr,this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontStlye=s,this.dataLabelHeight=this.caluculateDataLabelHeight(),this.axisPosition={x:0,y:0},this.columnValue={min:e,max:n},this.numberOfColumns=r,this.leftSideLabelLength=h,this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}caluculateDataLabelHeight(){return 1.1*Lt("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth+this.leftSideLabelLength+.5*this.spacings.columnWidth}getAxisPositionY(t){let i=this.columnValue.max.getScaledUnit();return t&&(i=this.columnValue.max.getScaledPercentUnit()+this.getNeedleWidth()),i+this.dataLabelHeight+this.spacings.labelToAxis+this.padding.top}getAxisPositionX(){return this.padding.left+this.leftSideLabelLength}getColumnPositionX(t,i){return i?this.getColumnCenterPositionX(t):this.getColumnCenterPositionX(t)-this.spacings.scenarioOffset}getColumnPositionY(){return this.columnValue.max.getScaledUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.padding.top}getNeedlePositionY(){return this.columnValue.max.getScaledPercentUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.getNeedleWidth()+this.padding.top}getMarkerPositionX(t,i){return i?this.getColumnCenterPositionX(t)-this.spacings.markerOffset-.5*this.getColumnWidth():this.getColumnCenterPositionX(t)+this.spacings.markerOffset+.5*this.getColumnWidth()}getMarkerPositionY(){return this.getColumnPositionY()}getAxisTitlePositionX(t){const i=t.width();return this.axisPosition.x-i}getAxisTitlePositionY(t,i){let s=this.columnValue.max.getScaledUnit();return i&&(s=this.columnValue.max.getScaledPercentUnit()),t?s+this.dataLabelHeight+this.spacings.labelToAxis:s}getColumnDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getColumnPositionY()+Math.abs(t)+i:this.getColumnPositionY()-t-i}getNeedleDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getNeedlePositionY()+Math.abs(t)+i+2*this.getNeedleWidth():this.getNeedlePositionY()-t-i-2*this.getNeedleWidth()}getAxisEndPositionX(){return this.getAxisPositionX()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getColumnWidth(){return this.spacings.columnWidth}getNeedleWidth(){return this.spacings.needleWidth}getNeedleHeadWidth(){return this.spacings.needleHeadWidth}getScenarioLabelPositionOffsetX(t){return t?.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn:-(.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn)}calculateSpacings(){this.spacings={scenarioOffset:this.fontStlye.size*this.scaleFactors.scenarioOffset,scenarioLabelToColumn:this.fontStlye.size*this.scaleFactors.scenarioLabelToColumn,markerOffset:this.fontStlye.size*this.scaleFactors.markerOffset,labelToColumn:this.fontStlye.size*this.scaleFactors.labelToColumn,labelToAxis:this.fontStlye.size*this.scaleFactors.labelToAxis,needleWidth:this.fontStlye.size*this.scaleFactors.needleWidth,needleHeadWidth:this.fontStlye.size*this.scaleFactors.needleHeadWidth,columnWidth:this.fontStlye.size*this.scaleFactors.columnWidth,varianceAxisLineWidth:this.fontStlye.size*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontStlye.size*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontStlye.size*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontStlye.size*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontStlye.size*this.scaleFactors.markerWidth,categoryWidth:this.fontStlye.size*this.scaleFactors.categoryWidth,axisTickLength:this.fontStlye.size*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left+.5*this.spacings.columnWidth,y:this.padding.top}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY(!1)}}getMarkerScenarioLabelPositionOffsetX(t){return t?this.spacings.labelToColumn-this.fontStlye.size:this.spacings.labelToColumn+.5*this.spacings.markerWidth}}class xr{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 Or{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"},this.markerRight={bottom:"0,"+s,top:"0,0",right:s+","+s/2},this.markerRightBackground={bottom:"0,"+i,top:"0,0",right:i+","+i/2},this.markerLeft={bottom:s+","+s,top:s+",0",left:"0,"+s/2},this.markerLeftBackground={bottom:i+","+i,top:i+",0",Left:"0,"+i/2}}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}}rightMarkerPatternStrings(){return{background:this.markerRightBackground.top+" "+this.markerRightBackground.right+" "+this.markerRightBackground.bottom+" "+this.markerRightBackground.top,foreground:this.markerRight.top+" "+this.markerRight.right+" "+this.markerRight.bottom+" "+this.markerRight.top,bgOffset:this.bgOffset}}leftMarkerPatternStrings(){return{background:this.markerLeftBackground.top+" "+this.markerLeftBackground.Left+" "+this.markerLeftBackground.bottom+" "+this.markerLeftBackground.top,foreground:this.markerLeft.top+" "+this.markerLeft.left+" "+this.markerLeft.bottom+" "+this.markerLeft.top,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t.set("marker-right",this.rightMarkerPatternStrings()),t.set("marker-left",this.leftMarkerPatternStrings()),t}}class _r{constructor(t){this.container=new cn,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-time-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var Mr;!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"}(Mr||(Mr={}));class Rr{constructor(t,i,s,e,n,r,h,o){this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.isRelativeLabel=!1,this.segmentFillColor=null,this.x=i,this.y=s,this.value=n,this.group=t.group().id(this.createElementID(t.toString(),e)),this.styles=r,this.isVarianceLabel=!1,this.verticalHookLocation=h||Mr.Top,this.horizontalHookLocation=o||Mr.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}updateGroup(t){return this.group=t,this}draw(t=!0,i={percent:2,decimal:1},s=new An){if(this.isEmpty())return this;const e=this.group;let n,r="";if(!1===Number.isNaN(Number(this.value))){let t="percent",e=i.percent,h=i.percent,o=1;!1===this.isRelativeLabel&&(e=i.decimal,h=i.decimal,o=s.value,t="decimal"),n=At.number(Number(this.value),t,e,h,o),this.isVarianceLabel&&Number(this.value)>=0&&(r="+")}else n=""+this.value;const h=this.drawLabel(e,r+n);return!1===t&&(h.addClass("hide"),e.addClass("hide")),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}forceStringTypeDraw(){return this.drawLabel(this.group,""+this.value),this}drawLabel(t,i){const s=this.styles.fontStyles.background||"#ffffff";let e="start";const n=t.text(i);n.move(this.x,this.y);const r=n.bbox().w,h=n.bbox().h;let o=0,a=0;const l=n.x();let c=n.y();return this.horizontalHookLocation===Mr.Left?(e="left",o=n.x()):this.horizontalHookLocation===Mr.Center?(e="middle",o=n.x()-(r+2)/2):this.horizontalHookLocation===Mr.Right&&(e="end",o=n.x()-r),this.verticalHookLocation===Mr.Center?(c=n.y()-1.2*h/2,a=c+.2*h):this.verticalHookLocation===Mr.Top?(c-=h/4,a=c+.2*h):this.verticalHookLocation===Mr.Bottom&&(c-=h,a=c+.2*h),n.move(l,c),n.font({anchor:e}),null!=this.segmentFillColor?n.fill(Jn(this.segmentFillColor)):t.rect(r+2,.8*h).stroke(s).fill(s).opacity(.9).move(o-1,a).insertBefore(n),n}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}}const $r={ac:1,pp:2,fc:3,pl:4};var kr,Er,Tr;!function(t){t[t.Above=0]="Above",t[t.Below=1]="Below",t[t.Left=2]="Left",t[t.Right=3]="Right"}(kr||(kr={}));class Pr{constructor(){this.labels=[],this.scenarioLabels=[]}clear(){this.labels=[],this.scenarioLabels=[]}register(t){this.labels.push(t)}hasCollision(t){return this.labels.some((i=>this.intersects(t,i)))}getOptimalPlacement(t,i,s,e,n,r,h,o){const a=$r[h]||99,l=r/2;for(const r of o){const h=this.calculatePlacementForDirection(t,i,s,e,n,l,8,r);if(!this.hasCollision(h.bounds))return h}for(const r of o){const h=this.calculatePlacementForDirection(t,i,s,e,n,l,8,r);if(!this.collidesWithHigherPriority(h.bounds,a))return h}return null}calculatePlacementForDirection(t,i,s,e,n,r,h,o){let a,l,c,u,d,f;switch(o){case kr.Above:a=t,l=i-r-h,c=Mr.Bottom,u=Mr.Center,d=t-s/2,f=i-r-h-e;break;case kr.Below:a=t,l=i+r+h,c=Mr.Top,u=Mr.Center,d=t-s/2,f=i+r+h-e/4;break;case kr.Left:a=t-r-h,l=i,c=Mr.Center,u=Mr.Right,d=t-r-h-s,f=i-.6*e;break;case kr.Right:a=t+r+h,l=i,c=Mr.Center,u=Mr.Left,d=t+r+h,f=i-.6*e}return{labelX:a,labelY:l,verticalHook:c,horizontalHook:u,bounds:{x:d,y:f,width:s,height:e,pointIndex:n,preferredHook:c}}}collidesWithHigherPriority(t,i){return this.labels.some((s=>!!s.scenarioType&&(($r[s.scenarioType]||99)<i&&this.intersects(t,s))))}shouldHideScenarioLabel(t,i,s,e=20){const n=$r[s]||99;return!(n<=1)&&this.scenarioLabels.some((s=>{if(($r[s.scenarioType]||99)>=n)return!1;const r=Math.abs(i-s.y),h=Math.abs(t-s.x);return r<e&&h<e}))}registerScenarioLabel(t,i,s){this.scenarioLabels.push({x:t,y:i,scenarioType:s})}intersects(t,i){return!(t.x+t.width<i.x||i.x+i.width<t.x||t.y+t.height<i.y||i.y+i.height<t.y)}getLabelCount(){return this.labels.length}}class Lr{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===Er.NEG?Er.NEG:"pos"===e||e===Er.POS?Er.POS:Er.NEU}isEmpty(){return void 0===this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:this.value>1.45?1.45*this.pixelPerUnit:this.value<-1.45?-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:Er.NEU===this.variance?Er.NEU:Er.POS===this.variance?Er.NEG:Er.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 Ar{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 Cr{constructor(){}adapt(t){const i=new Ar;return lt.isString(t.date)&&(i.date=this.parseDateString(t.date)),lt.isOperator(t.operation)&&(i.operation=t.operation),lt.isNumber(t.rowGroupIndex)&<.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),lt.isNumber(t.categoryIndex)&<.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),lt.isNumber(t.subCategoryIndex)&<.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),lt.isNumber(t.columnGroupIndex)&<.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),lt.isNumber(t.columnSubGroupIndex)&<.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}parseDateString(t){if("string"!=typeof t)return;const i=m.fromISO(t);if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' — skipping row`)}default(){return new Ar}setActualValues(t,i){lt.isNumber(t.ac1)&&(i.ac1=t.ac1),lt.isNumber(t.ac2)&&(i.ac2=t.ac2),lt.isNumber(t.ac3)&&(i.ac3=t.ac3),lt.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){lt.isNumber(t.pl1)&&(i.pl1=t.pl1),lt.isNumber(t.pl2)&&(i.pl2=t.pl2),lt.isNumber(t.pl3)&&(i.pl3=t.pl3),lt.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){lt.isNumber(t.pp1)&&(i.pp1=t.pp1),lt.isNumber(t.pp2)&&(i.pp2=t.pp2),lt.isNumber(t.pp3)&&(i.pp3=t.pp3),lt.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){lt.isNumber(t.fc1)&&(i.fc1=t.fc1),lt.isNumber(t.fc2)&&(i.fc2=t.fc2),lt.isNumber(t.fc3)&&(i.fc3=t.fc3),lt.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Nr{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class Dr{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Nr(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return lt.isExisting(t)&&(lt.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),lt.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),lt.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),lt.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),lt.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),lt.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 Or(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Nr(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}!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"}(Er||(Er={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(Tr||(Tr={}));class Ur{constructor(t,i,s){this.ID_AXIS="axis",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.isRelative=t.isRelative||!1,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){null==i&&(i=""),t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&this.drawAxisTitle(this.svgGroup,this.labelText),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(this.isRelative),this.position.getAxisEndPositionX(),this.position.getAxisPositionY(this.isRelative)).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class Gr{constructor(t,i,s,e,n,r,h,o=null){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.isVarianceColumn=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveHeight=0,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryColumn=n,this.position=t,this.columnBarStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=r,this.styles=i,this.columnGroup=r.group().id(r.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,e,n),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(h))}setAsVariance(){var t;return this.isVarianceColumn=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new An){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.convertToSVGStyle(s,"stroke"),n=this.getFillStyle(s);null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(n).stroke(e).y(this.dimensions.yPos).cx(this.dimensions.xPos)),this.drawColumnDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.columnGroup||!this.overflowConfig)return;const s=this.position.getColumnPositionY(),e=this.position.getColumnWidth(),n=this.dimensions.columnLength,{breakGap:r}=this.overflowConfig,h=s-n;this.columnGroup.rect(e,n).fill(t).stroke(i).y(h).cx(this.dimensions.xPos);const o=h-r-this.overdriveHeight;this.columnGroup.rect(e,this.overdriveHeight).fill(t).stroke(i).y(o).cx(this.dimensions.xPos),this.drawBreakIndicator(h,r)}drawBreakIndicator(t,i){if(!this.columnGroup)return;const s=this.position.getColumnWidth(),e=this.dimensions.xPos-s/2,n=t-i/2,r=.35*i,h=s/3;let o=`M ${e} ${n-r}`;for(let t=0;t<3;t++)o+=` L ${e+h*(t+.5)} ${n-r-.3*i} L ${e+h*(t+1)} ${n-r}`;let a=`M ${e} ${n+r}`;for(let t=0;t<3;t++)a+=` L ${e+h*(t+.5)} ${n+r+.3*i} L ${e+h*(t+1)} ${n+r}`;this.columnGroup.rect(s+2,i).fill("#ffffff").stroke("none").y(t-i).cx(this.dimensions.xPos),this.columnGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.columnGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s){const e=t.getScaledUnit();if(this.overflowConfig&&e>0){const n="ac"===t.getScenario()?this.overflowConfig.cutHeight:this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset;if(e>n){this.isOverflowing=!0;const{breakGap:t,overdriveZoneHeight:r,maxOverflow:h}=this.overflowConfig;this.overdriveHeight=h>0?(e-n)/h*r:0;const o=n+t+this.overdriveHeight,a=this.position.getColumnPositionY();return{clipped:!1,columnLength:n,xPos:this.position.getColumnPositionX(i,s),yPos:a-n,labelYPos:a-o-this.position.spacings.labelToColumn,scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:a-.5*n}}}return e<0?{clipped:!1,columnLength:Math.abs(e),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY(),labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()+.5*Math.abs(e)}:{clipped:!1,columnLength:e,xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-e,labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-.5*Math.abs(e)}}getDataLabel(t){let i=Mr.Bottom;null!=t.value&&t.value<0&&(i=Mr.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new Rr(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,Mr.Center)}getScenarioLabel(t){return new Rr(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,Mr.Center,this.isPrimaryColumn?Mr.Left:Mr.Right)}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.isVarianceColumn||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawColumnDataLabel(t,i=new An){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryColumn,t,i)}getFillStyle(t){var i,s,e,n;const r=this.columnBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceColumn?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.columnBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class Fr{constructor(t,i,s,e,n,r,h,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,h,a),this.scenarioLabel=this.getScenarioLabel(o,n,a))}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-this.dimensions.columnLength).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()+Math.abs(t.getScaledUnit())}:{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()-Math.abs(t.getScaledUnit())}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new Rr(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,Mr.Center,s?Mr.Right:Mr.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class Wr{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.dataLabel=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(t,s,e),this.dataLabel=new Rr(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,s.value,this.styles,Mr.Center,Mr.Center),this.dataLabel.setToRelativeVarianceLabel())}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.dataLabel)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;const i=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],s=this.convertToSVGStyle(i,"stroke");let e=this.convertToSVGStyle(i,"fill");const n=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),r=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),h=this.barStyles[this.dataPoint.getScenario()];if(null!=h&&h.fillpattern){const t=this.styles.pattern.get(h.fillpattern);null!=t&&(e=t.pattern)}this.dimensions.clipped?this.createClippedNeedleHead(e,s):this.createNeedleHead(n,r),this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(e).stroke(s),null===(t=this.dataLabel)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,columnLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY(),clipped:i.isClipped()}:{columnLength:i.getScaledPercentUnit(),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY()-i.getScaledPercentUnit(),labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:i.isClipped()}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}createClippedNeedleHead(t,i){const s=this.barGroup.polygon("0,0 5,9 -5,9 0,0 0,5 5,13 -5,13 0,5").fill(t).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i);null!=this.dataPoint.value&&this.dataPoint.value<0&&s.flip("y")}createNeedleHead(t,i){this.barGroup.rect(2*this.position.getNeedleWidth(),this.position.getNeedleHeadWidth()).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadYPosition(){let t=this.dimensions.yPos;return null!=this.dataPoint.value&&this.dataPoint.value<0&&(t+=this.dimensions.columnLength),t}}const Yr={ac:{markerFill:"#000000",markerStroke:"#000000",lineColor:"#000000"},pp:{markerFill:"#999999",markerStroke:"#999999",lineColor:"#999999"},fc:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000",lineDashArray:"4,4"},pl:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000"}};class zr{constructor(t,i,s,e,n,r,h,o,a=null){this.MARKER_SIZE=8,this.LINE_WIDTH=2,this.ID_LINE_PREFIX="LINE",this.ID_MARKER_PREFIX="MARKER",this.ID_LABEL_PREFIX="LABEL",this.ESTIMATED_LABEL_WIDTH=56,this.ESTIMATED_LABEL_HEIGHT=24,this.position=t,this.styles=i,this.dataPoints=s,this.scenarioGroup=e,this.labelGroup=n,this.scenarioName=r,this.scenarioLabel=h,this.collisionManager=a}draw(t={percent:2,decimal:1},i=new An){return this.drawGeometry(),this.drawLabels(t,i),this}drawGeometry(){if(0===this.dataPoints.length)return this;const t=this.getLineStyle();return this.drawLines(t),this.drawMarkers(t),this}drawLabels(t={percent:2,decimal:1},i=new An){return 0===this.dataPoints.length||(this.drawScenarioLabel(),this.drawValueLabels(t,i)),this}getLineStyle(){var t,i;const s=(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac";return Yr[s]||Yr.ac}getScenarioVariant(){var t;const i=parseInt((null===(t=this.scenarioName)||void 0===t?void 0:t.slice(-1))||"1",10);return isNaN(i)?1:Math.min(Math.max(i,1),4)}drawSquareMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.rect(this.MARKER_SIZE,this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).move(i-n,s-n)}drawCircleMarker(t,i,s,e){t.circle(this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).center(i,s)}drawTriangleMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i-n},${s+n} ${i+n},${s+n}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawDiamondMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i+n},${s} ${i},${s+n} ${i-n},${s}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawLines(t){const i=this.scenarioGroup.group().id(this.ID_LINE_PREFIX);for(let s=1;s<this.dataPoints.length;s++){const e=this.dataPoints[s-1],n=this.dataPoints[s];if(e.dataPoint.isEmpty()||n.dataPoint.isEmpty())continue;const r=this.position.getColumnCenterPositionX(e.index),h=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit(),o=this.position.getColumnCenterPositionX(n.index),a=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit(),l=i.line([[r,h],[o,a]]).stroke({color:t.lineColor,width:this.LINE_WIDTH,linecap:"round"}).fill("none");t.lineDashArray&&l.attr("stroke-dasharray",t.lineDashArray)}}drawMarkers(t){const i=this.scenarioGroup.group().id(this.ID_MARKER_PREFIX),s=this.getScenarioVariant();for(const e of this.dataPoints){if(e.dataPoint.isEmpty())continue;const n=this.position.getColumnCenterPositionX(e.index),r=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit();switch(s){case 2:this.drawCircleMarker(i,n,r,t);break;case 3:this.drawTriangleMarker(i,n,r,t);break;case 4:this.drawDiamondMarker(i,n,r,t);break;default:this.drawSquareMarker(i,n,r,t)}}}getLabelPositionPriority(t){const i=this.dataPoints[t];let s=null;for(let i=t+1;i<this.dataPoints.length;i++)if(!this.dataPoints[i].dataPoint.isEmpty()){s=this.dataPoints[i];break}let e=null;for(let i=t-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){e=this.dataPoints[i];break}const n=i.dataPoint.getScaledUnit();return e&&s&&e.dataPoint.getScaledUnit()>n&&s.dataPoint.getScaledUnit()>n?[kr.Below,kr.Left,kr.Right,kr.Above]:[kr.Above,kr.Left,kr.Right,kr.Below]}getScenarioType(){var t,i;return(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac"}drawValueLabels(t,i){const s=this.getScenarioType();for(let e=0;e<this.dataPoints.length;e++){const n=this.dataPoints[e];if(n.dataPoint.isEmpty()||null===n.dataPoint.value)continue;const r=this.position.getColumnCenterPositionX(n.index),h=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit();let o=r,a=h-this.MARKER_SIZE/2-2,l=Mr.Bottom,c=Mr.Center;if(this.collisionManager){const t=this.getLabelPositionPriority(e),i=this.collisionManager.getOptimalPlacement(r,h,this.ESTIMATED_LABEL_WIDTH,this.ESTIMATED_LABEL_HEIGHT,n.index,this.MARKER_SIZE,s,t);if(null===i)continue;o=i.labelX,a=i.labelY,l=i.verticalHook,c=i.horizontalHook;const u=Object.assign(Object.assign({},i.bounds),{scenarioType:s});this.collisionManager.register(u)}new Rr(this.labelGroup,o,a,this.ID_LABEL_PREFIX,n.dataPoint.value,this.styles,l,c).draw(!0,t,i)}}drawScenarioLabel(){if(!this.scenarioLabel)return;let t=null;for(let i=this.dataPoints.length-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){t=this.dataPoints[i];break}if(!t)return;const i=this.position.getColumnCenterPositionX(t.index)+this.MARKER_SIZE+4,s=this.position.getColumnPositionY()-t.dataPoint.getScaledUnit(),e=this.getScenarioType();if(this.collisionManager){if(this.collisionManager.shouldHideScenarioLabel(i,s,e))return;this.collisionManager.registerScenarioLabel(i,s,e)}new Rr(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,Mr.Center,Mr.Left).forceStringTypeDraw()}}class Ir{constructor(t,i,s,e,n,r,h,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=h,this.stackMode=o,this.totalValue=a,this.group=c,this.columnGroup=c.group().id(`stacked_col_${e}_seg_${h}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new An){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit;let n,r;const h=this.position.getColumnPositionY();if(this.stackMode===U.RELATIVE){const t=e;n=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,r=h-this.baselineValue/Math.abs(this.totalValue)*t-n}else n=Math.abs(s*e),r=h-this.baselineValue*e-n;const o=this.position.getColumnCenterPositionX(this.index),a=this.position.getColumnWidth(),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};if(this.columnGroup.rect(a,Math.max(n,.5)).fill(u).stroke(d).y(r).cx(o),n>=18){const e=r+n/2;if(this.stackMode===U.RELATIVE||this.stackMode===U.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Rr(this.group,o,e,"STACK_SEG",i,this.styles,Mr.Center,Mr.Center).setSegmentFill(c).forceStringTypeDraw()}else new Rr(this.group,o,e,"STACK_SEG",s,this.styles,Mr.Center,Mr.Center).setSegmentFill(c).draw(!0,t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new An){if(this.stackMode===U.RELATIVE)return;const s=this.position.getColumnCenterPositionX(this.index),e=this.position.getColumnPositionY();new Rr(this.group,s,e-this.totalValue*this.dataPoint.pixelPerUnit-this.position.spacings.labelToColumn,"STACK_TOTAL",this.totalValue,this.styles,Mr.Bottom,Mr.Center).draw(!0,t,i)}}const Br={ac:{fill:"#000000",opacity:.3,lineColor:"#000000"},pp:{fill:"#999999",opacity:.3,lineColor:"#999999"},fc:{fill:"#000000",opacity:.2,lineColor:"#000000",dashArray:"4,4"},pl:{fill:"#000000",opacity:.1,lineColor:"#000000"}},Hr=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class jr{constructor(t,i,s,e,n,r){this.group=t.group().id(`area_fill_${n}`),this.upperPoints=i,this.lowerPoints=s,this.scenarioType=e,this.segmentIndex=n,this.isScenarioStack=r}draw(){if(this.upperPoints.length<2||this.lowerPoints.length<2)return;let t,i,s=`M ${this.upperPoints[0].x},${this.upperPoints[0].y}`;for(let t=1;t<this.upperPoints.length;t++)s+=` L ${this.upperPoints[t].x},${this.upperPoints[t].y}`;for(let t=this.lowerPoints.length-1;t>=0;t--)s+=` L ${this.lowerPoints[t].x},${this.lowerPoints[t].y}`;if(s+=" Z",this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=Br[s]||Br.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,Hr.length-1);t=Hr[s].fill,i=Hr[s].opacity}this.group.path(s).fill(t).opacity(i).stroke("none")}drawBoundaryLine(){if(this.upperPoints.length<2)return;let t,i="#000000";if(this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=Br[s]||Br.ac;i=e.lineColor,t=e.dashArray}const s=this.group.polyline(this.upperPoints.map((t=>[t.x,t.y]))).fill("none").stroke({color:i,width:1.5});t&&s.attr("stroke-dasharray",t)}}class Vr{constructor(t,i,s,e,n,r,h,o){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.isVarianceLine=!1,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.previousDimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=n,this.isPrimaryLine=r,this.position=t,this.LineBarStyles=i.barStyles,this.scenarioGroup=h,this.styles=i,this.LineGroup=h.group().id(h.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,n,r),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(o)),this.previousDimensions=this.createDimensions(e,n-1,r)}setAsVariance(){var t;return this.isVarianceLine=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new An){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.getFillStyle(s);null!=this.LineGroup&&this.LineGroup.line([[this.previousDimensions.xPos,this.previousDimensions.yPos],[this.dimensions.xPos,this.dimensions.yPos]]).fill(e).stroke({color:"#f06",width:3,linecap:"round"}),this.drawLineDataLabel(t,i),this.drawScenarioLabel()}createDimensions(t,i,s){return{clipped:!1,columnLength:t.getScaledUnit(),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-t.getScaledUnit(),labelYPos:this.position.getColumnDataLabelPositionY(t.getScaledUnit()),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-t.getScaledUnit()}}getDataLabel(t){let i=Mr.Bottom;return null!=t.value&&t.value<0&&(i=Mr.Top),new Rr(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,Mr.Center)}getScenarioLabel(t){return new Rr(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,Mr.Bottom,Mr.Left)}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.isVarianceLine||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawLineDataLabel(t,i=new An){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryLine,t,i)}getFillStyle(t){var i,s,e,n;const r=this.LineBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceLine?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.LineBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class Xr{constructor(t,i,s,e,n){this.pixelPerUnit=1,this.collisionManager=null,this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),h=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:h,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}createLine(t,i,s,e){const n=this.svgGroups.scenario1.group().id(""+e),r=this.svgGroups.scenario1Label.group().id(""+e);let h=null;return this.isLastDataPoint(e-1)&&(h=t),new Vr(this.position,this.styles,i,s,e,!1,n,h).updateLabelGroup(r)}createPrimaryBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Gr(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e)}createVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Gr(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e).setAsVariance()}createRelativeVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);return new Wr(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i){const s=this.svgGroups.scenario2.group().id(""+i);let e=null;return this.isFirstDataPoint(i)&&(e=`${this.i18n.get(t.scenario)||t.scenario}`),new Gr(this.position,this.styles,t,i,!1,s,e,this.overflowConfig)}createPrimaryMarker(t,i){const s=this.svgGroups.scenario3.group().id(""+i),e=this.styles.pattern.get("marker-right")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Fr(this.position,s,e,t.scenario,this.styles,t,i,n,!0)}createSecondaryMarker(t,i){const s=this.svgGroups.scenario4.group().id(""+i),e=this.styles.pattern.get("marker-left")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new Fr(this.position,s,e,t.scenario,this.styles,t,i,n,!1)}isLastDataPoint(t){return this.elementCnt-1===t}isFirstDataPoint(t){return 0===t}setCollisionManager(t){this.collisionManager=t}moveLabelsToFront(){this.svgGroups.scenario1Label.front()}createLineSeries(t,i){const s=this.svgGroups.parent.group().id("LineSeries_"+i),e=this.svgGroups.scenario1Label.group().id("LineSeries_Label_"+i),n=`${this.i18n.get(i)||i}`;return new zr(this.position,this.styles,t,s,e,i,n,this.i18n,this.collisionManager)}}var Jr,qr;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Jr||(Jr={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(qr||(qr={}));class Qr{constructor(t,i,s,e,n,r=0){this.CSS_CATEGORIES="categories",this.dataModel=[],this.variancesDataModel=[],this.title="",this.smallestDataPointValue=new Lr(0,Er.AC1,1,Er.NEU),this.highestDataPointValue=new Lr(0,Er.AC1,1,Er.NEU),this.smallestVarianceDataPointValue=new Lr(0,Er.AC1,1,Er.NEU),this.highestVarianceDataPointValue=new Lr(0,Er.AC1,1,Er.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=Er.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=Jr.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=W.DAY,this.locale="de",this.axisLabelsMode=Y.SMART,this.intervalSpanLimit=32,this.measureScale=new An,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=z.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.db=i,this.tableName=s,this.ruleSet=t||new nr,this.i18n=this.createI18n(new Map),this.styles=n,this.availableWidth=r,this.setConfig(e),this.position=this.createElementPosition(e.scenarios)}updatePosition(t){this.position=this.createElementPosition(t)}setStyles(t){this.styles=t}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===z.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestVarianceDataPointValue:this.highestDataPointValue).getScaledUnit();if(i<=0)return null;const s=this.styles.fontStyles.size,e=1.5*s,n=.3*s,r=t-(this.position.dataLabelHeight+this.position.spacings.labelToColumn+this.position.padding.top+this.position.padding.bottom+this.position.spacings.labelToAxis+s)-e-n,h=.8*s;if(r<=h)return null;const o=r-h;return i<=o?null:{cutHeight:r,overdriveZoneHeight:e,breakGap:n,maxOverflow:i-o,scenarioCutOffset:h}}setConfig(t){var i;this.state=Jr.DIRTY,this.sortScenariosbyVisualisationRules(t),this.setSource(t.filter),this.hideAxisLabels=t.hideAxisLabels||!1,this.pixelPerUnit=t.pixelPerUnit,this.pixelPerPercentage=t.pixelPerPercentage,this.axisLabelsMode=t.axisLabelsMode,this.intervalSpanLimit=t.intervalSpanLimit,this.dateInterval=this.findDateInterval(t.dateInterval),this.dataModel=this.populateModel(t.scenarios,this.dateInterval,t.level,t.sortOrder),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.title=t.title||At.translateScenarioLabel(null===(i=null==t?void 0:t.variances)||void 0===i?void 0:i.toString(),this.i18n),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.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync,this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.showOverlayMedian=t.showOverlayMedian,this.showOverlayAvg=t.showOverlayAvg,this.chartMode=t.chartMode,this.maxBars=t.maxBars,this.stackConfig=t.stackConfig,this.lineFullWidth=t.lineFullWidth,this.lastScenarios=t.scenarios,this.updatePosition(t.scenarios)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":At.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}sortScenariosbyVisualisationRules(t){const i=this;t.scenarios.sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t)}setSource(t){var i,s;if(this.state=Jr.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(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}}getAllocatedCanvasWidth(){const t=this.position.getAxisEndPositionX(),i=3*this.styles.fontStyles.size,s=Math.max(this.axisCategoryArea.width,this.scenariosArea.width);return Math.max(t+i,s>0?s+this.position.leftSideLabelLength:0)}getAllocatedCanvasHeight(){if(null==this.smallestVarianceDataPointValue.value||null==this.highestVarianceDataPointValue.value||null==this.smallestDataPointValue.value||null==this.highestDataPointValue.value)return 0;const t=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===qr.RELATIVE)),i=this.position.getAxisPositionY(t),s=this.position.spacings.labelToAxis+this.position.dataLabelHeight+this.styles.padding.bottom;let e;if(this.isOnSameAxisSide())e=i+s;else{const t=this.isVarianceChart()?this.smallestVarianceDataPointValue:this.smallestDataPointValue;e=i+Math.abs(t.getScaledUnit())+this.position.spacings.labelToColumn+this.position.dataLabelHeight+s}const n=this.isOnSameAxisSide();return Math.max(e,n?this.axisCategoryArea.height+this.scenariosArea.height:this.scenariosArea.height)}toString(){const t=new cn;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){this.cleanSVGforRedraw(t),this.state===Jr.DIRTY&&(this.state=Jr.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===z.LINE?(this.drawStackedAreaScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):this.determineEffectiveChartMode()===z.LINE?(this.drawLineScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawOverlayLayer(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}determineEffectiveChartMode(){return this.chartMode===z.LINE||this.chartMode===z.AUTO&&this.dataModel.length>this.maxBars?z.LINE:z.BAR}setPattern(t,i){this.styles.pattern.set(t,i)}hasNoData(){return 0===this.dataModel.length}isOnSameAxisSide(){return null!=this.smallestVarianceDataPointValue.value&&null!=this.highestVarianceDataPointValue.value&&null!=this.smallestDataPointValue.value&&null!=this.highestDataPointValue.value&&(this.isVarianceChart()?Math.sign(this.smallestVarianceDataPointValue.value)===Math.sign(this.highestVarianceDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value):Math.sign(this.smallestDataPointValue.value)===Math.sign(this.highestDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value))}createI18n(t){this.state=Jr.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])}createElementPosition(t){let i;const s=Lt(t.filter(((t,i)=>1===i||2===i)).map((t=>At.translateScenarioLabel(t,this.i18n))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,e=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let n,r;if(i=s>e?s:e,null!=this.position&&(i+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(i=this.leftSideOffsetForHorizontalSync),this.isVarianceChart()?(n=this.smallestVarianceDataPointValue,r=this.highestVarianceDataPointValue):(n=this.smallestDataPointValue,r=this.highestDataPointValue),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig;r=new Lr(t+i+s,r.scenario,1,r.variance)}let h=this.styles.scaleFactors;const o=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&o===z.LINE){const t=this.styles.fontStyles.size,s=this.styles.padding,e=this.styles.scaleFactors,n=this.availableWidth-(s.left+s.right+t*e.scenarioOffset+i+t*e.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*e.columnWidth),s=new wr;Object.assign(s,e),s.categoryWidth=i,h=s}}return new Sr(new xr(this.styles.padding),h,this.styles.fontStyles,n,r,this.dataModel.length,i)}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=Lt(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}setAxisScenario(t){let i=Er.AC1;if(null!=t&&t.length>0){const s=new $t(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=Er.AC1),i}populateModel(t,i,s,e){if(0===this.rowCount||!this.fromExpr)return[];let n=this.queryDataSet(i,"","");return this.detectNaNCells(t,n),n=this.leftOuterJoinDates(n,i),this.createDataRows(n,t)}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new $t(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)))}findDateInterval(t){var i,s,e;if(t!==W.AUTO)return t;const n=this.queryMinMaxDates();let r=W.DAY;return null!=(null===(i=n[0])||void 0===i?void 0:i.mindate)&&(r=(new ut).calculateDistanceType(null===(s=n[0])||void 0===s?void 0:s.mindate,null===(e=n[0])||void 0===e?void 0:e.maxdate,this.intervalSpanLimit)),r}queryMinMaxDates(){var t,i;let s;try{s=this.db.exec(`SELECT MAX(date) as maxdate, MIN(date) as mindate FROM ${this.fromExpr}`)}catch(t){return console.error("TimeChart: min/max date query failed",t),[{}]}return null!=(null===(t=s[0])||void 0===t?void 0:t.mindate)&&(s[0].mindate=Qr.coerceDateTime(s[0].mindate)),null!=(null===(i=s[0])||void 0===i?void 0:i.maxdate)&&(s[0].maxdate=Qr.coerceDateTime(s[0].maxdate)),s}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=m.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=m.fromMillis(t);return i.isValid?i:void 0}return"boolean"==typeof t.isValid?t:void 0}}queryDataSet(t,i,s){const e=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],n=`normalizeDate([date], '${t}' , '${this.locale}') as calcdate`;let r;try{r=this.db.exec(`SELECT p.calcdate ${i},\n ${e.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(",")}\n\n FROM (SELECT ${n} ${i},\n ac1,\n ac2,\n ac3,\n ac4,\n pp1,\n pp2,\n pp3,\n pp4,\n fc1,\n fc2,\n fc3,\n fc4,\n pl1,\n pl2,\n pl3,\n pl4\n FROM ${this.fromExpr}) as p\n GROUP BY calcdate ${s}\n ORDER BY calcdate asc`)}catch(t){return console.error("TimeChart: queryDataSet failed",t),[]}return r}createDataRows(t,i){const s=[];return t.forEach(((t,e)=>{s.push({id:e,category:t.category,type:qr.NONE,date:t.calcdate,scenario1:new Lr(t[i[0]],i[0],this.pixelPerUnit,Er.NEU),scenario2:new Lr(t[i[1]],i[1],this.pixelPerUnit,Er.NEU),scenario3:new Lr(t[i[2]],i[2],this.pixelPerUnit,Er.NEU),scenario4:new Lr(t[i[3]],i[3],this.pixelPerUnit,Er.NEU)})})),s}findSmallestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Lr(0,"default",i,Er.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])t&&null!=t.value&&t.value<Number(s.value)&&(s=t);return s}findHighestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Lr(0,"default",i,Er.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])null!=t&&t.value>Number(s.value)&&(s=t);return s}populateVarianceModel(t,i){const s=[];if(null==t||0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new $t(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction,h="dr"===r.type?this.pixelPerPercentage:this.pixelPerUnit;for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?qr.RELATIVE:qr.ABSOLUTE,date:i[e].date,scenario1:new Lr(this.calculateVariance(r,i[e],t),r.delta,h,n),scenario2:new Lr(null,null,null,null),scenario3:new Lr(null,null,null,null),scenario4:new Lr(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n||null==i[e].value||null==i[n].value?null:t.type===qr.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}cleanSVGforRedraw(t){t.clear()}isVarianceChart(){return this.variancesDataModel&&this.variancesDataModel.length>0}createDateFactory(){return new ut}drawAxisAndLabels(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLables");let n=!1;if(!1===this.hideAxisLabels)t.forEach(((t,i)=>{let r=Mr.Top,h=this.position.spacings.labelToAxis;t.scenario1.value<0&&(r=Mr.Bottom,h*=-1),t.type===qr.RELATIVE&&(n=!0);let o=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===Y.SMART?(o=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==W.YEAR&&(o=s.getShortDateString(t.date,this.dateInterval))):this.axisLabelsMode===Y.SHORT&&(o=s.getShortDateString(t.date,this.dateInterval)),new Rr(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+h,"",o,this.styles,r,Mr.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===qr.RELATIVE&&(n=!0)}new Ur({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw(),this.axisCategoryArea={height:e.height(),width:e.width()}}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new Xr(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw(),!1===t.scenario1.isEmpty()&&(n=!0)}));let r=0;!1===n&&(r=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight),this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom+r,width:s.width()+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new Pr,h=new Xr(this.position,n,this.styles,t.length,this.i18n);h.setCollisionManager(r);const o=["ac1","pp1","fc1","pl1"],a=[[],[],[],[]];t.forEach(((t,i)=>{["scenario1","scenario2","scenario3","scenario4"].forEach(((s,e)=>{t[s]&&a[e].push({dataPoint:t[s],index:i})}))}));const l=[];for(let t=0;t<a.length;t++){const i=a[t];if(i.length>0&&i.some((t=>!t.dataPoint.isEmpty()))){const n=(null===(e=null===(s=i[0])||void 0===s?void 0:s.dataPoint)||void 0===e?void 0:e.scenario)||o[t],r=n.slice(0,2).toLowerCase();l.push({points:i,scenarioName:n,scenarioType:r})}}l.sort(((t,i)=>($r[i.scenarioType]||99)-($r[t.scenarioType]||99)));const c=[];for(const t of l){const i=h.createLineSeries(t.points,t.scenarioName);c.push({series:i,scenarioType:t.scenarioType})}for(const t of c)t.series.drawGeometry();h.moveLabelsToFront();const u=[...c].sort(((t,i)=>($r[t.scenarioType]||99)-($r[i.scenarioType]||99)));for(const t of u)t.series.drawLabels(this.dataFormatDigits,this.measureScale);const d=this.position.getColumnPositionY();this.scenariosArea={height:Math.max(n.height()+this.styles.padding.top,d)+this.styles.padding.bottom,width:n.width()+this.position.spacings.columnWidth}}drawAxisAndLabelsForLineChart(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLabelsLine"),n=!1,r=t.length-1;!1===this.hideAxisLabels&&t.forEach(((i,h)=>{if(!this.shouldShowLineChartAxisLabel(t,h))return;let o,a=Mr.Top,l=this.position.spacings.labelToAxis;i.scenario1.value<0&&(a=Mr.Bottom,l*=-1),this.lineFullWidth&&this.availableWidth>0?this.axisLabelsMode===Y.SMART?(o=s.getSmartDateString(i.date,this.dateInterval),0===h&&this.dateInterval!==W.YEAR&&(o=s.getShortDateString(i.date,this.dateInterval))):o=this.axisLabelsMode===Y.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):o=s.getShortDateString(i.date,this.dateInterval),new Rr(e,this.position.getColumnCenterPositionX(h),this.position.getAxisPositionY(n)+l,"",o,this.styles,a,Mr.Center).forceStringTypeDraw(),h>0&&h<r&&this.isYearChange(t,h)&&this.drawYearSeparatorLine(e,h,n)})),new Ur({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw(),this.axisCategoryArea={height:e.height(),width:e.width()}}shouldShowLineChartAxisLabel(t,i){return!!(this.lineFullWidth&&this.availableWidth>0)||(0===i||i===t.length-1||this.isYearChange(t,i))}isYearChange(t,i){var s,e;if(0===i)return!1;const n=null===(s=t[i])||void 0===s?void 0:s.date,r=null===(e=t[i-1])||void 0===e?void 0:e.date;return!(!n||!r)&&n.year!==r.year}drawYearSeparatorLine(t,i,s){const e=this.position.getColumnCenterPositionX(i)-this.position.spacings.columnWidth/2,n=this.position.columnValue.max.getScaledUnit()+this.position.dataLabelHeight,r=this.position.getAxisPositionY(s)-n,h=this.position.getAxisPositionY(s);t.line([[e,r],[e,h]]).stroke({color:"#999999",width:1,dasharray:"4,4"}).attr("stroke-dasharray","4,4")}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Xr(this.position,s,this.styles,t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===qr.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom,width:s.width()+this.position.spacings.columnWidth},s}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===N.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e)for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Xn(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Xn(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of Vn)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),h=e.length-1-n;let o=0,a=null;t.segments.forEach((t=>{const e=new Ir(this.position,this.styles,t.dataPoint,i,o,t.scenario,h,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),a=e})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}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 n=0,h=null;r.forEach(((r,o)=>{const a=new Ir(this.position,this.styles,r.dataPoint,i,n,r.scenario,o,this.stackConfig.mode,t,e,s);a.draw(this.dataFormatDigits,this.measureScale),n+=Math.abs(r.value),h=a})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}})),this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom,width:s.width()+this.position.spacings.columnWidth}}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;if(this.stackConfig.by!==N.SCENARIOS)return;const s=i.group().id("StackedHeaders"),e=t[0],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;const h=new Set(r.map((t=>Xn(t.scenario)))),o=this.position.getColumnPositionY(),a=this.position.getColumnCenterPositionX(0)-this.position.getColumnWidth()/2-this.position.spacings.labelToColumn;if(h.size>1){const t=new Map;for(const i of r){const s=Xn(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of Vn)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),e=t.segments[0].dataPoint.pixelPerUnit,n=o-(this.stackConfig.mode===U.RELATIVE?e:i*e)/2,r=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Rr(s,a,n,"STACK_HEADER",r,this.styles,Mr.Center,Mr.Right).forceStringTypeDraw()}))}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),i=r[0].dataPoint.pixelPerUnit;let e=0;r.forEach((n=>{let r;r=this.stackConfig.mode===U.RELATIVE?(0!==t?Math.abs(n.value)/t:0)*i:Math.abs(n.value*i);const h=o-e-r/2,l=this.i18n.get(n.scenario)||n.scenario;new Rr(s,a,h,"STACK_HEADER",l,this.styles,Mr.Center,Mr.Right).forceStringTypeDraw(),e+=r}))}}drawStackedAreaScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedAreaScenarios"),e=this.stackConfig.by===N.SCENARIOS,n=this.stackConfig.mode,r=["scenario1","scenario2","scenario3","scenario4"];if(0===(e?r.filter((i=>t.some((t=>t[i]&&!t[i].isEmpty())))).length:1))return;const h=[],o=[],a=[];for(const i of r)t.some((t=>t[i]&&!t[i].isEmpty()))&&a.push(i);for(let i=0;i<a.length;i++){const s=a[i],e=[];for(let r=0;r<t.length;r++){const o=t[r][s],l=o&&!o.isEmpty()&&null!=o.value?o.value:0,c=i>0?h[i-1][r]:0;if(n===U.RELATIVE){const i=a.reduce(((i,s)=>{const e=t[r][s];return i+(e&&!e.isEmpty()&&null!=e.value?Math.abs(e.value):0)}),0),s=0!==i?Math.abs(l)/i:0;e.push(c+s)}else e.push(c+l)}h.push(e);const r=t[0][s];o.push((null==r?void 0:r.scenario)||"ac1")}const l=this.position.getColumnPositionY(),c=this.pixelPerUnit,u=t=>t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l-t*c}))),d=t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l})));for(let t=0;t<h.length;t++){const i=u(h[t]),n=0===t?d:u(h[t-1]),r=new jr(s,i,n,e?o[t]:null,t,e);r.draw(),r.drawBoundaryLine()}this.scenariosArea={height:s.height()+this.styles.padding.top+this.styles.padding.bottom,width:s.width()+this.position.spacings.columnWidth}}drawOverlayLayer(t,i){const s=i.group().id("Overlay"),e=new Xr(this.position,s,this.styles,t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=t.reduce(((t,i)=>{var s;return t+((null===(s=i.scenario1)||void 0===s?void 0:s.value)||0)}),0),s=t.filter((t=>{var i;return void 0!==(null===(i=t.scenario1)||void 0===i?void 0:i.value)})).length,e=s>0?i/s:0,n=Object.assign(Object.assign({},t[0]),{scenario1:new Lr(e,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),r=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Lr(e,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[n,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Lr(e,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),r]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Ø ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}if(!0===this.showOverlayMedian){let i=null;const s=function(t){const i=t.map((t=>{var i;return null===(i=t.scenario1)||void 0===i?void 0:i.value})).filter((t=>void 0!==t)).sort(((t,i)=>t-i)),s=i.length%2==0?(i[i.length/2-1]+i[i.length/2])/2:i[Math.floor(i.length/2)],e=Object.assign(Object.assign({},t[0]),{scenario1:new Lr(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Lr(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Lr(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Mdn ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}}leftOuterJoinDates(t,i){const s=t.map((t=>t.calcdate)).filter((t=>null!=t&&"boolean"==typeof t.isValid&&t.isValid));if(0===s.length)return t;const e=m.max(...s),n=m.min(...s),r=(new ut).datesBetween(n,e,i,this.intervalSpanLimit),h=new Map;return r.forEach(((t,i)=>{h.set(t.toISO(),{id:i,calcdate:t,category:null,ac1:null,ac2:null,ac3:null,ac4:null,pp1:null,pp2:null,pp3:null,pp4:null,fc1:null,fc2:null,fc3:null,fc4:null,pl1:null,pl2:null,pl3:null,pl4:null,isEmpty:!0})})),t.forEach((t=>{const i=t.calcdate.toISO(),s=h.get(i);s&&s.isEmpty&&h.set(i,{id:s.id,calcdate:t.calcdate,category:t.category,ac1:t.ac1,ac2:t.ac2,ac3:t.ac3,ac4:t.ac4,pp1:t.pp1,pp2:t.pp2,pp3:t.pp3,pp4:t.pp4,fc1:t.fc1,fc2:t.fc2,fc3:t.fc3,fc4:t.fc4,pl1:t.pl1,pl2:t.pl2,pl3:t.pl3,pl4:t.pl4,isEmpty:!1})})),Array.from(h.values())}}class Kr{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideAxisLabels=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new ct(new Nn).default(),this.level=L.CATEGORY,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=W.AUTO,this.axisLabelsMode=Y.SMART,this.intervalSpanLimit=28,this.filter="",this.measureScale=new An,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.showOverlayMedian=!0,this.showOverlayAvg=!0,this.chartMode=z.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0}}class Zr{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=at.adaptArray(t.data,this.dataRowAdapter),s=at.adaptArray(t.scenarios,this.stringAdapter),e=new Kr(i,s);return lt.isArray(t.variances)&&(e.variances=at.adaptArray(t.variances,this.stringAdapter)),lt.isString(t.title)&&(e.title=t.title),lt.isBoolean(t.hideAxisLabels)&&(e.hideAxisLabels=t.hideAxisLabels),lt.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),lt.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),lt.isNumber(t.limit)&&(e.limit=t.limit),lt.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),lt.isExisting(t.level)&&(e.level=t.level),lt.isExisting(t.dateInterval)&&(e.dateInterval=t.dateInterval),lt.isExisting(t.axisLabelsMode)&&(e.axisLabelsMode=t.axisLabelsMode),lt.isNumber(t.leftSideOffsetForHorizontalSync)&&(e.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync),lt.isNumber(t.intervalSpanLimit)&&(e.intervalSpanLimit=t.intervalSpanLimit),lt.isString(t.filter)&&(e.filter=t.filter),lt.isExisting(t.measureScale)&&(e.measureScale=Cn.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),lt.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),lt.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),lt.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),lt.isBoolean(t.showOverlayAvg)&&(e.showOverlayAvg=t.showOverlayAvg),lt.isBoolean(t.showOverlayMedian)&&(e.showOverlayMedian=t.showOverlayMedian),lt.isExisting(t.chartMode)&&(e.chartMode=t.chartMode),lt.isNumber(t.maxBars)&&(e.maxBars=t.maxBars),lt.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),lt.isBoolean(t.lineFullWidth)&&(e.lineFullWidth=t.lineFullWidth),e}default(){return new Kr([],[])}}const th=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.scenarios=[],this.variances=[],this.hideAxisLabels=!1,this.pixelPerUnit=2,this.pixelPerPercentage=50,this.limit=0,this.leftSideOffsetForHorizontalSync=-1,this.i18n=new Map,this.order={hierarchy:[],direction:A.ASC},this.level=L.CATEGORY,this.dateInterval=W.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=Y.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=z.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.prepareConfig(),s=this.prepareStyle(),e=this.containerWidth||0;this.chart=new Qr(new nr,this.getDb(),this.tableName,i,s,e),this.chart.setI18n(this.i18n),this.autoFitScaling(i,s),this.chart.setAvailableHeight((null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new _r(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.setAvailableWidth(this.containerWidth||0),this.chart.setConfig(i),this.autoFitScaling(i,s),this.chart.setAvailableHeight((null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new _r(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=null===(s=this.parentDimensions)||void 0===s?void 0:s.height,h=this.containerWidth||0;if(!r||r<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),this.chart=new Qr(new nr,this.getDb(),this.tableName,t,i,h),void this.chart.setI18n(this.i18n);e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),this.chart=new Qr(new nr,this.getDb(),this.tableName,t,i,h),this.chart.setI18n(this.i18n),this.chart.toString();const o=this.chart.getAllocatedCanvasHeight();if(o<=0)return;const a=.9*r/o;e&&(t.pixelPerUnit=a),n&&(t.pixelPerPercentage=a),this.chart=new Qr(new nr,this.getDb(),this.tableName,t,i,h),this.chart.setI18n(this.i18n)}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?g(this.tableName,this.filter):"";return new Zr(new Cr,new ct(new Nn),new Nn,new or,t,i).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideAxisLabels:this.hideAxisLabels,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,dateInterval:this.dateInterval,axisLabelsMode:this.axisLabelsMode,limit:this.limit,sortOrder:this.order,leftSideOffsetForHorizontalSync:this.leftSideOffsetForHorizontalSync,intervalSpanLimit:this.intervalSpanLimit,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,showOverlayMedian:this.showOverlayMedian,showOverlayAvg:this.showOverlayAvg,chartMode:this.chartMode,maxBars:this.maxBars,stackConfig:this.stackConfig,lineFullWidth:this.lineFullWidth})}prepareStyle(){return new Dr(new yr,new lr,new ur(new vr),new gr(new vr),new fr).adapt(this.styles)}get element(){return e(this)}};th.style=':host{position:relative;display:inline-block}.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-default{stroke:black;stroke-width:0.1em}.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}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}';class ih{constructor(t,i,s,e,n,r,h,o,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=i,this.value=s,this.prefix=r||"",this.cssStyle=e||"",this.prefixStyle=h||"prefix",this.type=n,this.mark=void 0,this.colSpan=o||1,this.measureScale=a||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const i of this.value.toString().split("<br/>"))t.push(i);return t}draw(t){let i=this.value;if("undefined"===i||void 0===i||null==i)return"";if(Number.isNaN(Number(i)))return i;if(""===this.type||void 0===this.type||null==this.type)return i;let s=t.percent,e=t.percent;return"decimal"===this.type&&(i=+i/this.measureScale,s=t.decimal,e=t.decimal),At.number(Number(i),this.type,s,e)}drawPrefix(){return null==this.prefix?"":this.prefix}}class sh{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case Ti.HEADER:return"groupheader";case Ti.SEPERATORLINE:return"";case Ti.DRILLELEMENT:return"ofit";case Ti.PARTELEMENT:return"partof";case Ti.STANDARD:return"";case Ti.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,i,s,e,n,r,h,o,a,l=!1,c){let u=r;"category"===i&&null!=o&&(u=`category-${o.toString()}`),this.type===Ti.HEADER?u="headerlabel":this.type===Ti.SEPERATORLINE&&(u=i),this.type===Ti.PARTELEMENT&&("percent"===e&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",u="")),"-"===t&&(u="");let d="prefix-first";h&&(d="prefix-second"),s&&(u=`${u} ${s}`);const f=new ih(i,this.elements.length,t,u,e,n,d,1,a);f.isBarChart=l,f.columnStats=c,this.elements.push(f)}}const eh={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},nh="#666666";function rh(t,i){return`pattern-${t}-${i.replace("#","")}`}const hh=({styles:t})=>{const s=t.scaleFactor,e=6*s,n=[{id:rh("pos",t.positive.stroke),stroke:t.positive.stroke,fill:t.positive.fill},{id:rh("neg",t.negative.stroke),stroke:t.negative.stroke,fill:t.negative.fill},{id:rh("neu",t.neutral.stroke),stroke:t.neutral.stroke,fill:t.neutral.fill}];return i("defs",null,n.map((t=>i("pattern",{id:t.id,patternUnits:"userSpaceOnUse",width:e,height:e},i("rect",{width:e,height:e,fill:"#ffffff"}),i("line",{x1:"0",y1:e,x2:e,y2:"0",stroke:t.stroke,"stroke-width":1.5*s})))))};function oh(t,i,s=1){let e,n;const r=t>=0?"+":"";if(i)return e=100*t,r+Math.round(e).toString()+"%";{let i;return e=t/s,n=Math.abs(e),i=n>=1e9?(e/1e9).toFixed(n>=1e10?0:1)+"B":n>=1e6?(e/1e6).toFixed(n>=1e7?0:1)+"M":n>=1e3?(e/1e3).toFixed(n>=1e4?0:1)+"K":e.toFixed(n>=10?0:1),i=i.replace(/\.0([KMB]?)$/,"$1"),r+i}}function ah(t){const i=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(i)}function lh(t){const i=t.slice(0,2).toLowerCase();return"pp"===i?"pp":"fc"===i?"fc":"pl"===i?"pl":"ac"}function ch(t,i,s,e){return ah(t)?function(t,i){const s=lh(t);return i.scenarios[s]}(t,e):function(t,i,s){const e=t>=0;return i?e?s.positive:s.negative:e?s.negative:s.positive}(i,s,e)}const uh=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:h,formattedValue:o,measureScale:a,maxBarWidth:l=10,styles:c=eh}=t,u=c.scaleFactor,d=c.fontSize,f=38*u,p=l*d,v=4*u,m=.15*p,g=p-v-m,b=Math.abs(s)*c.unitScaling*d,w=b>g,y=Math.max(0,n.absMax*c.unitScaling*d-g),S=Math.max(0,b-g),x=y>0?S/y*m:0,O=n.min<0,_=n.max>0,M=O?p:0,R=(O?f:0)+(M+(_?p:0))+(_?f:0),$=2*u,k=r-2*$,E=(O?f:0)+M,T=$,P=s>=0,L=ch(e,s,h,c),A=function(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${rh(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}(L,ah(e)?lh(e):h?P?"pos":"neg":P?"neg":"pos"),{stroke:C,strokeWidth:N}="outlined"===(D=L).fillpattern?{stroke:D.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0};var D;const U=o||oh(s,!1,a),G=w?g:b,F=w?g+v+x:b,W=P?E+F+4*u:E-F-4*u,Y=P?"start":"end";return i("svg",{width:R,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(hh,{styles:c}),i("line",{x1:E,y1:0,x2:E,y2:r,stroke:nh,"stroke-width":1*u}),G>0&&i("rect",{x:P?E:E-G,y:T,width:G,height:k,fill:A,stroke:C,"stroke-width":N*u}),w&&x>0&&i("rect",{x:P?E+g+v:E-g-v-x,y:T,width:x,height:k,fill:A,stroke:C,"stroke-width":N*u}),w&&function(t,s,e,n,r){const h=t+s/2,o=.35*s,a=n/3,l=.3*s;let c=`M ${h-o} ${e}`;for(let t=0;t<3;t++)c+=` L ${h-o-l} ${e+a*(t+.5)} L ${h-o} ${e+a*(t+1)}`;let u=`M ${h+o} ${e}`;for(let t=0;t<3;t++)u+=` L ${h+o+l} ${e+a*(t+.5)} L ${h+o} ${e+a*(t+1)}`;return[i("rect",{x:t,y:e-1,width:s,height:n+2,fill:"#ffffff"}),i("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*r}),i("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*r})]}(P?E+g:E-g-v,v,T,k,u),i("text",{x:W,y:r/2,dy:"0.35em","text-anchor":Y,fill:c.fontColor,"font-size":d,"font-family":c.fontFamily},U))},dh=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:h,formattedValue:o,measureScale:a,maxBarWidth:l=10,styles:c=eh}=t,u=c.scaleFactor,d=c.fontSize,f=Math.round(.67*l*d),p=5*u,v=n.min<0?f+p:0,m=v+(n.max>0?f+p:0),g=m+45*u,b=v,w=r/2,y=100*Math.abs(s)*c.percentageScaling*d,S=y>f,x=Math.min(y,f),O=s>=0,_=O?b+x:b-x,M=ch(e,s,h,c),R=3*u,$=o||oh(s,!0,a),k=m+4*u;return i("svg",{width:g,height:r,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i("line",{x1:b,y1:0,x2:b,y2:r,stroke:nh,"stroke-width":1*u}),!S&&i("circle",{cx:_,cy:w,r:R,fill:c.fontColor}),i("line",{x1:b,y1:w,x2:_,y2:w,stroke:M.fill,"stroke-width":2*u}),S&&O&&i("polygon",{points:`${b+f},${w} ${b+f-6*u},${w-3*u} ${b+f-6*u},${w+3*u}`,fill:M.fill}),S&&!O&&i("polygon",{points:`${b-f},${w} ${b-f+6*u},${w-3*u} ${b-f+6*u},${w+3*u}`,fill:M.fill}),i("text",{x:k,y:r/2,dy:"0.35em","text-anchor":"start",fill:c.fontColor,"font-size":d,"font-style":"italic","font-family":c.fontFamily},$))},fh=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=eh}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?dh:uh,Object.assign({},t))};class ph{constructor(t){this.groups=[kt.CATEGORY,kt.CATEGORYINDEX],ki.OPT!==t.type&&ki.OPTNOTOTAL!==t.type||this.groups.unshift(kt.OPERATION),t.grouped&&(this.groups.push(kt.ROWGROUP),this.groups.push(kt.ROWGROUPINDEX))}toString(){return this.groups.map((t=>`${t}`)).toString()}noCategory(){return this.groups.filter((t=>t!==kt.CATEGORY))}toArray(){return this.groups}}class vh{constructor(t,i){this.hasPartOf=!1,this.config=t,this.i18n=i}execute(t,i){var s;this.db=t,this.fromExpr=i;const e=[],n=[],r=[],h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),o=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),a=this.getRelativeScenarios(),l=new ph(this.config),c=this.config.grouped?[kt.ROWGROUP,kt.ROWGROUPINDEX]:[];let u,d=["",""];this.config.sortOrder.hierarchy.length>0&&(d=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{u=t.exec(`SELECT COUNT(DISTINCT ${kt.CATEGORY}) as ${kt.TOTALROWCOUNT} ${c.length>0?","+c:""}\n FROM ${i} ${c.length>0?"GROUP BY "+c:""}\n ORDER BY ${d[0]}`)}catch(t){return console.error("DataQuery: meta query failed",t),[]}return 0===u.length||1===u.length&&0===(null!==(s=u[0][kt.TOTALROWCOUNT])&&void 0!==s?s:0)&&0===c.length?[]:(u.forEach((t=>{const i=t.rowGroup&&t.rowGroup.length>0?`WHERE ${kt.ROWGROUP} = '${t.rowGroup}'`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,e),this.createDataRow(e,t,l,h,i,d,s),this.createRestRow(t,e,l,h,i,d),this.createGroupSumRow(e,n,t,o,d)})),this.createTotalSumRow(e,n,o),e.forEach((i=>{try{r.push(t.exec(i))}catch(t){console.error("DataQuery: SQL query execution failed",i,t)}})),this.detectNaNCells(this.config.scenarios,r),this.createThereOfDrillRows(h,d,r),this.createPartOfDrillRows(h,d,n,r),this.createThereOfDrillColumns(this.config.categoryThereOf,r),this.calculateColumnGroupRest(r,this.config.categoryThereOf),this.calculateRelativeVariances(r,a),r)}detectNaNCells(t,i){i.forEach((i=>{i.map((i=>(t.forEach((t=>{const s=new $t(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)))}))}createPartOfDrillRows(t,i,s,e){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===ki.LIST)return;const n=this.createPartOfQuery(t,i);let r=[];const h=this.db;n.forEach((function(t){r.push(...h.exec(t))}));const o=this.exctractScenarioNames(t),a=[];s.forEach((function(t){a.push(...h.exec(t))}));const l=new Map;a.forEach((t=>l.set(t[kt.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,o),r.forEach((function(t){o.forEach((i=>{try{t[i]=t[i]/l.get(t[kt.ROWGROUP])[i]}catch(s){console.error("DataQuery: partOf drill row calculation failed",i,s),t[i]=Number.NaN}}))})),this.injectDrillRowsToResultRows(r,e)}createRestRow(t,i,s,e,n,r){t.totalRowCnt-this.config.limit>0&&0!==this.config.limit&&i.push(`SELECT ${kt.ROWNR}, 1 as ${kt.ROWGROUPINDEX} , 'ENTRY' as ${kt.TYPE}, 'NO_GROUP' as ${kt.ROWGROUP}, 'REST' as ${kt.CATEGORY} , SUM(ac1) as ac1, SUM(pp1) as pp1, SUM(dpp1_ac1_pos) as dpp1_ac1_pos, SUM(drpp1_ac1_pos) as drpp1_ac1_pos, SUM(dr_pp1) as dr_pp1 FROM (SELECT ROWNUM() AS ${kt.ROWNR}, ${i.length} as ${kt.ROWGROUPINDEX} , 'ENTRY' as ${kt.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${kt.ROWGROUP}, ${s} ${e.length>0?",".concat(e):""} FROM ${this.fromExpr} ${n} GROUP BY ${s} ORDER BY ${r[0]}) t WHERE t.rowNr > ${this.config.limit}`)}createDataRow(t,i,s,e,n,r,h){t.push(`SELECT ROWNUM() AS ${kt.ROWNR},\n ${t.length} as ${kt.ROWGROUPINDEX},\n 'ENTRY' as ${kt.TYPE},\n '${i.rowGroup||"NO_GROUP"}' as ${kt.ROWGROUP},\n '${kt.CATEGORYINDEX}',\n ${s} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n GROUP BY ${s}\n ORDER BY ${r[0]} ${h}`)}createGroupHeaderRow(t,i){!0===this.config.grouped&&i.push(`SELECT ROWNUM() AS ${kt.ROWNR},\n ${i.length} as ${kt.ROWGROUPINDEX},\n 'GROUPHEAD' as ${kt.TYPE},\n '${t.rowGroup}' as ${kt.ROWGROUP} ${this.config.showGroupTitle?`,'${t.rowGroup}' as ${kt.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}createGroupSumRow(t,i,s,e,n){!0!==this.config.grouped||ki.SUM!==this.config.type&&ki.SUMNOTOTAL!==this.config.type&&ki.OPT!==this.config.type&&ki.OPTNOTOTAL!==this.config.type||(t.push(`SELECT ${t.length} as ${kt.ROWGROUPINDEX},\n '=' as ${kt.OPERATION},\n '${s.rowGroup}' as ${kt.ROWGROUP},\n ROWNUM() AS ${kt.ROWNR},\n 'GROUP_SUM' as ${kt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${kt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `),i.push(`SELECT ${t.length} as ${kt.ROWGROUPINDEX},\n '=' as ${kt.OPERATION},\n '${s.rowGroup}' as ${kt.ROWGROUP},\n ROWNUM() AS ${kt.ROWNR},\n 'GROUP_SUM' as ${kt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${kt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `))}createTotalSumRow(t,i,s){if(ki.SUM===this.config.type||ki.OPT===this.config.type){const i=`${this.hasPartOf&&!1===this.config.grouped?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} `:""}${this.config.title}`;t.push(`SELECT ${t.length} as ${kt.ROWGROUPINDEX},\n '${i}' as ${kt.ROWGROUP},\n '=' as ${kt.OPERATION},\n 'SUM' as ${kt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${kt.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${kt.ROWGROUP},\n '=' as ${kt.OPERATION},\n 'SUM' as ${kt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,i){const s=new Map;return t.forEach((function(t){const e=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(e)){const n=s.get(e);i.forEach((i=>{try{n[i]+=t[i]}catch(t){console.error("DataQuery: drill row aggregation failed",i,t)}}))}else s.set(e,t)})),[...s.values()]}injectDrillRowsToResultRows(t,i){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){i.forEach((function(i){const e=i.findIndex((i=>i.category===t.category&&i.rowGroup===t.rowGroup));if(e>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const i=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,i+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[kt.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[kt.ROWNR],0,t)}}))}));else{const e=this.findDuplicateSubCategories(t);t.forEach((function(t){i.forEach((function(i){const n=i.findIndex((i=>null!=i.category&&i.category===t.category));if(n>=0){if(s.has(`${t.category}`)){const i=s.get(`${t.category}`)||0;s.set(`${t.category}`,i+1)}else s.set(`${t.category}`,1);(1===t[kt.ROWNR]||e.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),i.splice(n+t[kt.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,i,s){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const e=[],n=[];this.config.thereOf.forEach((s=>{let n=!0,r="1 <> 1 OR ( ";null!=s.category&&0!==s.category.length&&s.category.trim()&&(r+=` ${kt.CATEGORY} = '${s.category}'`,n=!1),null!=s.rowGroup&&0!==s.rowGroup.length&&s.rowGroup.trim()&&(r+=` ${n?"":"AND"} ${kt.ROWGROUP} = '${s.rowGroup}'`,n=!1),null!=s.subCategory&&0!==s.subCategory.length&&s.subCategory.trim()&&(r+=` ${n?"":"AND"} ${kt.SUBCATEGORY} = '${s.subCategory}'`),r+=")",e.push(`SELECT ROWNUM() AS ${kt.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${kt.TYPE},\n ${kt.CATEGORY},\n ${kt.SUBCATEGORY},\n ${kt.ROWGROUP} as ${kt.ROWGROUP},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${r}\n GROUP BY ${kt.ROWGROUP}, ${kt.CATEGORY}, ${kt.SUBCATEGORY}\n ORDER BY ${i[1]}`)}));const r=this.db;e.forEach((function(t){n.push(...r.exec(t))})),this.injectDrillRowsToResultRows(n,s)}calculateRelativeVariances(t,i){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[kt.TYPE]&&i.forEach(((i,s)=>{t[s]=t[s]/t[i]}))}))}))}calculateColumnGroupRest(t,i){if(null==i||0===i.size)return;const s=new Map,e=new Map;i.forEach(((t,i)=>{const n=t,r=[];for(const t of n)r.push(`${i}##${t.name}`);s.set(i,r),e.set(`${i}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[kt.TYPE]&&s.forEach(((i,s)=>{let n=0;i.forEach((i=>{void 0!==t[i]&&(n+=t[i])})),t[`${s}##REST`]=t[s]-n,0!==t[`${s}##REST`]&&e.set(`${s}##REST`,!0)}))}))}));const n=Array.from(e.entries()).filter((([t,i])=>!i)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const i of n)delete t[i]}))}))}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((i=>{const s=this.createRelativeScenario(i);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,i,s){const e=new $t(t);return ki.OPT===s||ki.OPTNOTOTAL===s?e.isValid?"dr"===e.type?`SUM(${e.base} - ${e.delta}) as ${t}, SUM(${e.delta}) as dr_${e.delta}`:`SUM(${e.base} - ${e.delta}) as ${t}`:i?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:e.isValid?"dr"===e.type?`SUM((${e.base} * transformOperator(operation)) - (${e.delta} * transformOperator(operation))) as ${t}, SUM(${e.delta} * transformOperator(operation)) as dr_${e.delta}`:`SUM((${e.base} * transformOperator(operation))- (${e.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}createOrderString(t){return[`${t.hierarchy.toString()} ${t.direction}`,`${t.hierarchy.toString()} ${Ei.ASC===t.direction?Ei.DESC:Ei.ASC}`]}createRelativeScenario(t){const i=new $t(t);return i.isValid&&"dr"===i.type?{key:`${t}`,value:`dr_${i.delta}`}:null}exctractScenarioNames(t){const i=[];return t.split(",").forEach((t=>t.length>=2?i.push(t.split("as")[1].trim()):null)),i}findDuplicateSubCategories(t){const i=t.map((t=>({count:1,subCategory:t.subCategory}))).reduce(((t,i)=>(t[i.subCategory]=(t[i.subCategory]||0)+i.count,t)),{});return Object.keys(i).filter((t=>i[t]>1))}createPartOfQuery(t,i){var s;const e=[];let n="1 <> 1 ",r=` ${kt.ROWGROUP}`,h="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${kt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${kt.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${kt.ROWGROUP} `,h="1"),n+=")"})),e.push(`SELECT ${h} AS ${kt.ROWNR},\n 'PARTELEMENT' as ${kt.TYPE},\n ${kt.CATEGORY},\n ${r},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${kt.ROWGROUP}, ${kt.CATEGORY}, ${kt.TYPE}\n ORDER BY ${i[1]}`),e}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,i){if(null==t||0===t.size)return;const s=[],e=[],n=this.fromExpr;t.forEach(((t,i)=>{let e="1 <> 1 ";t.forEach((t=>{e+=` or columnGroup = '${t.name}' `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)e.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(e,i)}injectDrillColumnsToResultRows(t,i){const s="##";for(const e of t)for(const t of i)for(const i of t)i.type===e.rowlevel&&("ENTRY"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):"DRILLELEMENT"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val:"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):("SUM"===e.rowlevel||"GROUP_SUM"===e.rowlevel)&&("COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup]=e.val),"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val)))}}class mh{constructor(){this.normalizedHeader=[]}createHeader(t,i,s,e,n,r){const h=[];this.normalizedHeader=this.normalizeHeader(t,i);const o=new sh(0,0,Ti.HEADER),a=new sh(1,0,Ti.SEPERATORLINE);for(const t of this.normalizedHeader)o.createElement(At.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,e,n,r),null,null,null,null),a.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null);return h.push(o),h.push(a),h}setHeaderPrefix(t,i,s,e,n){let r="";return"category"===t.name&&n&&(0===s.prefix.length&&0===e.length||(r=At.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=At.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i){let s=[{name:kt.CATEGORY,group:kt.CATEGORY,type:kt.CATEGORY,order:void 0}];return ki.OPT!==t&&ki.OPTNOTOTAL!==t||(s=[{name:kt.OPERATION,group:kt.OPERATION,type:kt.OPERATION,order:void 0},{name:kt.CATEGORY,group:kt.CATEGORY,type:kt.CATEGORY,order:void 0}]),[...s,...i]}createBodyRows(t,i,s,e){const n=[];let r=-1;const h=new vh(t,i).execute(s,e),o=this.calculateColumnStatistics(h,t.barColumns);for(const s of h)r+=1,n.push(...this.createRow(t.i18n,i,t.scenariosUnitType,s,r,-1,t.categoryWidth,t.measureScale,t.barColumns,o));return n}calculateColumnStatistics(t,i){const s=new Map;if(!i||0===i.length)return s;const e=new Map;for(const t of i)s.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),e.set(t,[]);for(const n of t)for(const t of n)for(const n of i){const i=this.extractColumnValue(t,n);if(null!==i&&!isNaN(i)){const t=s.get(n);t.min=Math.min(t.min,i),t.max=Math.max(t.max,i),e.get(n).push(Math.abs(i))}}for(const[t,i]of s){i.min!==1/0&&i.max!==-1/0||(i.min=0,i.max=0),i.absMax=Math.max(Math.abs(i.min),Math.abs(i.max));const n=e.get(t);if(n.length>0){n.sort(((t,i)=>t-i));const t=Math.floor(n.length/2);i.median=n.length%2==0?(n[t-1]+n[t])/2:n[t]}s.set(t,i)}return s}extractColumnValue(t,i){if(void 0!==t[i]){const s=Number(t[i]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===i||s.endsWith("##"+i)||s===i+"##"+i){const i=Number(t[s]);if(!isNaN(i))return i}return null}createRow(t,i,s,e,n,r,h,o,a,l){var c;const u=[];for(const d of e){const f=d[kt.ROWGROUP],p=d[kt.SUBCATEGORY],v=d[kt.TYPE],m=d[kt.ROWNR]>=2,g=this.createDetailRow(v,r+=1,n,e.length);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(d,e),r=null!==(c=null==a?void 0:a.includes(e.type))&&void 0!==c&&c,u=r?null==l?void 0:l.get(e.type):void 0;g.createElement(this.translateSumCellLabel(t,i,n,f,p,v,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),this.translateCellPrefix(i,v,e.type),this.translateScenarioCSS(e.type,n),m,h,null==o?void 0:o.value,r,u)}u.push(g)}return u}getRawDataRowElement(t,i){return i.name===i.group&&i.name===i.type?t[i.name]:i.name===i.group&&i.name!==i.type?t[i.type+"##"+i.name]:t[i.type+"##"+i.group+"##"+i.name]}createDetailRow(t,i,s,e){switch(t){case Ti.GROUPHEAD:return new sh(i,s,Ti.HEADER);case Ti.SUM:case Ti.GROUPSUM:return new sh(e+2,s,Ti.SUM);case Ti.DRILLELEMENT:return new sh(e+2,s,Ti.DRILLELEMENT);case Ti.PARTELEMENT:return new sh(e+2,s,Ti.PARTELEMENT);default:return new sh(i,s,Ti.STANDARD)}}translateSumCellLabel(t,i,s,e,n,r,h){return!1===Number.isNaN(Number(s))||this.isOperationColumn(h)?s:this.isGroupHeadCategory(r,h)||this.isEntryCategory(r,h)?t===Z.ALL?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,h)?t===Z.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,h)?t===Z.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,h)?t===Z.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,i){const s=new $t(t);let e="pos";return i<0&&(e="neg"),s.isValid?e+"_"+s.direction+("dr"===s.type?" relative_variance":""):t}setCellType(t,i){if("category"===t)return"";let s;const e=new $t(t);return i===K.PERCENT?(s="percent",e.isValid&&"d"===e.type&&(s="decimal")):(s="decimal",e.isValid&&"dr"===e.type&&(s="percent")),s}isDrillElementCategory(t,i){return"DRILLELEMENT"===t&&"category"===i}isPartElementCategory(t,i){return"PARTELEMENT"===t&&"category"===i}isSumElementCategory(t,i){return("GROUP_SUM"===t||"SUM"===t)&&"category"===i}isEntryCategory(t,i){return"ENTRY"===t&&"category"===i}isGroupHeadCategory(t,i){return"GROUPHEAD"===t&&"category"===i}translateCellPrefix(t,i,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(i,s)||this.isEntryCategory(i,s)?null:this.isDrillElementCategory(i,s)?`${t.get("there_of")} `:this.isPartElementCategory(i,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class gh{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.ruleSet=t||new nr,this.db=i,this.dataSetFactory=new mh,this.config=this.initConfig(e),this.i18n=this.initI18n(new Map),this.setSource(s,e.filter),this.state=$i.DIRTY}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){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"],["in","in"],["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 this.state=$i.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=$i.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}setConfig(t){this.config=this.initConfig(t)}setSource(t,i){var s,e;if(!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=g(t,i);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(e=null===(s=t[0])||void 0===s?void 0:s.cnt)&&void 0!==e?e:0}catch(t){this.rowCount=0}const n=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder);this.headerRows=this.dataSetFactory.createHeader(this.config.type,n,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale),this.bodyRows=0===this.rowCount?[]:this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr),this.state=$i.UP_TO_DATE}update(){const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=$i.UP_TO_DATE}getHeader(){return this.state===$i.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===$i.DIRTY&&this.update(),this.bodyRows}normalizeScenarios(t,i,s){var e;const n=[];for(const r of t){if(null==i?void 0:i.has(r)){const t=i.get(r);for(const i of t){n.push({name:i.name,group:i.name,type:r,order:void 0});for(const t of i.subGroups)n.push({name:t,group:i.name,type:r,order:void 0})}n.push({name:"REST",group:"REST",type:r,order:void 0})}let t;(null===(e=null==s?void 0:s.hierarchy)||void 0===e?void 0:e.at(0))===r&&(t=s.direction),n.push({name:r,group:r,type:r,order:t})}return n}hasNoData(){return 0===this.rowCount}}class bh{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=K.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.sortOrder=new ct(new Nn).default(),this.type=ki.LIST,this.limit=0,this.i18n=Z.ALL,this.categoryWidth=tt.W25,this.measureScale=new An,this.measureUnit="",this.measureType=it.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[]}}class wh{constructor(t,i,s,e,n){this.tableDrillGroupAdapter=t,this.stringAdapter=i,this.orderAdapter=s,this.db=e,this.fromExpr=n}adapt(t){const i=new bh;return lt.isString(t.title)&&(i.title=t.title),lt.isArray(t.scenarios)&&(i.scenarios=at.adaptArray(t.scenarios,this.stringAdapter)),lt.isExisting(t.scenariosUnitType)&&(i.scenariosUnitType=t.scenariosUnitType),lt.isBoolean(t.grouped)&&(i.grouped=t.grouped),lt.isBoolean(t.showGroupTitle)&&(i.showGroupTitle=t.showGroupTitle),lt.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),lt.isArray(t.thereOf)&&(i.thereOf=at.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),lt.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),lt.isArray(t.partOf)&&(i.partOf=at.adaptArray(t.partOf,this.tableDrillGroupAdapter)),lt.isExisting(t.order)&&(i.sortOrder=this.orderAdapter.adapt(t.order)),lt.isExisting(t.type)&&(i.type=t.type),lt.isNumber(t.limit)&&(i.limit=t.limit),lt.isExisting(t.i18n)&&(i.i18n=t.i18n),lt.isExisting(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),lt.isExisting(t.measureScale)&&(i.measureScale=Cn.calculateMeasureScale(this.db,this.fromExpr,i.scenarios,t.measureScale)),lt.isExisting(t.measureType)&&(i.measureType=t.measureType),lt.isString(t.measureUnit)&&(i.measureUnit=t.measureUnit),lt.isString(t.filter)&&(i.filter=t.filter.trim()),lt.isArray(t.barColumns)&&(i.barColumns=t.barColumns),i}default(){return new bh}}class yh{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class Sh{constructor(){}adapt(t){const i=new yh;return lt.isString(t.rowGroup)&&(i.rowGroup=t.rowGroup),lt.isString(t.category)&&(i.category=t.category),lt.isString(t.subCategory)&&(i.subCategory=t.subCategory),lt.isString(t.partOf)&&(i.partOf=t.partOf),i}default(){return new yh}}const xh=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.tableTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=K.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:Ei.ASC},this.categorythereof=new Map,this.type=ki.LIST,this.categoryWidth=tt.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=Z.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=it.VOLUME,this.filter="",this.barColumns=[],this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new hr,this.componentStyle=w(this)}render(){return i(s,null,(()=>{if(void 0!==this.table){if(this.table.hasNoData()){const t=this.i18n.get("NO_DATA")||"==No Data==";return i("p",{class:"warning"},t)}return i("table",null,i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map((t=>i("th",{colSpan:t.colSpan,class:t.cssStyle},t.getAsHeaderList().map(((s,e,n)=>i("span",null,e===n.length-1?i("span",{class:" "===s?"table-footer":""},s,t.drawPrefix()," "):i("span",null,s,t.drawPrefix(),i("br",null)))))))))))),i("tbody",null,this.table.getBody().map((t=>i("tr",{class:t.cssStyle},null==t?void 0:t.getCells().map((s=>i("td",{colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},null!=s.prefix?i("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",s.isBarChart&&s.columnStats&&t.type!==Ti.SUM?i(fh,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,maxBarWidth:this.barColumnMaxWidth,styles:this.barChartStyles}):s.draw(this.componentDataFormatDigits)))))))))}})())}componentWillRender(){this.stores||(this.stores=u(this.element));const t=this.stores.db.db,i=this.prepareConfig(t);this.componentDataFormatDigits=(new or).adapt(this.dataFormatDigits),this.table=new gh(new nr,t,this.tableName,i),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){const i=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new wh(new Sh,new Nn,new ct(new Nn),t,i).adapt({title:this.tableTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns})}prepareBarChartStyles(){return this.componentStyle((t=>{var i,s,e,n,r,h,o,a,l,c,u,d,f,p,v,m,g,b,w,y,S,x,O,_,M,R;const $=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,k=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(e=null==$?void 0:$.pos)||void 0===e?void 0:e.stroke)||"#008f96",fill:(null===(n=null==$?void 0:$.pos)||void 0===n?void 0:n.fill)||"#008f96",fillpattern:(null===(r=null==$?void 0:$.pos)||void 0===r?void 0:r.fillpattern)||"solid"},negative:{stroke:(null===(h=null==$?void 0:$.neg)||void 0===h?void 0:h.stroke)||"#ff0000",fill:(null===(o=null==$?void 0:$.neg)||void 0===o?void 0:o.fill)||"#ff0000",fillpattern:(null===(a=null==$?void 0:$.neg)||void 0===a?void 0:a.fillpattern)||"solid"},neutral:{stroke:(null===(l=null==$?void 0:$.neu)||void 0===l?void 0:l.stroke)||"#808080",fill:(null===(c=null==$?void 0:$.neu)||void 0===c?void 0:c.fill)||"#808080",fillpattern:(null===(u=null==$?void 0:$.neu)||void 0===u?void 0:u.fillpattern)||"outlined"},scenarios:{ac:{stroke:(null===(d=null==k?void 0:k.ac)||void 0===d?void 0:d.stroke)||"#404040",fill:(null===(f=null==k?void 0:k.ac)||void 0===f?void 0:f.fill)||"#404040",fillpattern:(null===(p=null==k?void 0:k.ac)||void 0===p?void 0:p.fillpattern)||"solid"},pp:{stroke:(null===(v=null==k?void 0:k.pp)||void 0===v?void 0:v.stroke)||"#A6A6A6",fill:(null===(m=null==k?void 0:k.pp)||void 0===m?void 0:m.fill)||"#A6A6A6",fillpattern:(null===(g=null==k?void 0:k.pp)||void 0===g?void 0:g.fillpattern)||"solid"},fc:{stroke:(null===(b=null==k?void 0:k.fc)||void 0===b?void 0:b.stroke)||"#404040",fill:(null===(w=null==k?void 0:k.fc)||void 0===w?void 0:w.fill)||"#ffffff",fillpattern:(null===(y=null==k?void 0:k.fc)||void 0===y?void 0:y.fillpattern)||"hatched"},pl:{stroke:(null===(S=null==k?void 0:k.pl)||void 0===S?void 0:S.stroke)||"#404040",fill:(null===(x=null==k?void 0:k.pl)||void 0===x?void 0:x.fill)||"#ffffff",fillpattern:(null===(O=null==k?void 0:k.pl)||void 0===O?void 0:O.fillpattern)||"outlined"}},fontColor:(null===(_=t.global)||void 0===_?void 0:_.fontColor)||"#000000",fontSize:.85*((null===(M=t.global)||void 0===M?void 0:M.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:(null===(R=t.global)||void 0===R?void 0:R.fontFamily)||"'Noto Sans', sans-serif",unitScaling:this.unitScaling>0?this.unitScaling:this.autoUnitScaling(),percentageScaling:this.percentageScaling>0?this.percentageScaling:this.autoPercentageScaling(),scaleFactor:this.scaleFactor}}))}autoUnitScaling(){const t=this.componentStyle((t=>{var i;return.85*((null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333)*this.scaleFactor})),i=this.barColumnMaxWidth*t*.8,s=this.getMaxAbsValue();return s<=0||t<=0?.01:i/(s*t)}autoPercentageScaling(){const t=this.componentStyle((t=>{var i;return.85*((null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333)*this.scaleFactor})),i=.8*Math.round(.67*this.barColumnMaxWidth*t),s=this.getMaxRelativeValue();return s<=0||t<=0?.5:i/(s*t)}getMaxAbsValue(){if(!this.table)return 0;let t=0;for(const i of this.table.getBody())if(i.type!==Ti.SUM)for(const s of i.getCells())s.isBarChart&&s.columnStats&&!s.key.startsWith("dr")&&(t=Math.max(t,s.columnStats.absMax));return t}getMaxRelativeValue(){if(!this.table)return 0;let t=0;for(const i of this.table.getBody())if(i.type!==Ti.SUM)for(const s of i.getCells())s.isBarChart&&s.columnStats&&s.key.startsWith("dr")&&(t=Math.max(t,100*s.columnStats.absMax));return t}get element(){return e(this)}};xh.style=':host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';class Oh{constructor(){}createMeasures(t,i,s){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let n="",r="";for(let h=0;h<e;h++){let o="";h>0&&(o=i.get("SEPERATOR_WS")),e>1&&h===e-1&&(o=i.get("CONNECTOR_WS")),s===Z.ALL?(n=(i.get(n)||n)+o+(i.get(t[h].name)||t[h].name),r=i.get(t[h].unit)||t[h].unit):(n=n+o+t[h].name,r=t[h].unit)}return[{name:n,unit:r}]}return t}createDimension(t,i,s,e,n){let r="";void 0!==i&&(r=(new ut).getDateLinkString(i.start,i.end,i.link,i.format,n));return r+t.map((t=>{let i="";return null!=s&&null!=s.hierarchy&&s.hierarchy.find((i=>i===t))&&(i=e.get("asc"===s.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",At.translateScenarioLabel(t,e),i)})).toString()}allMeasuresUseSameUnit(t){const i=new Map;return t.forEach((function(t){i.set(t.unit,!0)})),1===i.size}}class _h{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=Z.ALL,this.intervalSpanLimit=32}}class Mh{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new _h;return lt.isString(t.businessunit)&&(i.businessunit=t.businessunit),lt.isArray(t.measures)&&(i.measures=at.adaptArray(t.measures,this.measureEntryAdapter)),lt.isArray(t.scenarios)&&(i.scenarios=at.adaptArray(t.scenarios,this.stringAdapter)),lt.isExisting(t.timeperiod)&&(i.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),lt.isNumber(t.intervalSpanLimit)&&(i.intervalSpanLimit=t.intervalSpanLimit),lt.isExisting(t.i18nMode)&&(i.i18nMode=t.i18nMode),lt.isExisting(t.order)&&(i.order=this.orderAdapter.adapt(t.order)),i}default(){return new _h}}var Rh;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Rh||(Rh={}));class $h{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new _h,this.state=Rh.DIRTY,this.ruleSet=t||new nr,this.dataSetFactory=new Oh,this.state=Rh.DIRTY,this.setI18n(new Map)}setI18n(t){this.state=Rh.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"],["pp3","PL3"],["ac4","AC4"],["py4","PY4"],["fc4","FC4"],["pp4","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","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...i,...t||new Map])}update(){return Rh.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit),this.state=Rh.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=Rh.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class kh{constructor(t="",i=""){this.name=t,this.unit=i}}class Eh{construnctor(){}adapt(t){const i=new kh;return lt.isString(t.name)&&(i.name=t.name),lt.isString(t.unit)&&(i.unit=t.unit),i}default(){return new kh("","")}}class Th{constructor(t=m.now(),i=m.now(),s=W.AUTO,e=ot.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class Ph{construnctor(){}adapt(t){const i=new Th;return lt.isDate(t.start)&&(i.start=t.start),lt.isDate(t.end)&&(i.end=t.end),lt.isExisting(t.format)&&(i.format=t.format),lt.isExisting(t.link)&&(i.link=t.link),i}default(){return new Th}}const Lh=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:A.ASC},this.i18n=new Map,this.i18nMode=Z.ALL,this.title=new $h(new nr)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((i=>{this[i]=t[i]}))}render(){return i("div",{key:"314cf7dad025643a6cdc190312eb100a310f076b"},i("div",{key:"b2e5c89f5d9d08987d09d0ee46e63b5889ede87c"},this.title.unit),i("div",{key:"d9cb4aa0cc02d8b354eb61609d4e22f4641e10a1"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPERATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"ccbfb094dd5fa097fe339b03958ea3854e87083e"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new $h(new nr),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new Mh(new Eh,new Ph,new ct(new Nn),new Nn).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order})}};Lh.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}';export{mt as bn_asset,gt as bn_body,bt as bn_card,Rt as bn_chart_structure,Ct as bn_chart_time,Nt as bn_component_style,Dt as bn_context,mi as bn_dataset,gi as bn_datasource,bi as bn_footer,wi as bn_layout_card,yi as bn_layout_page,Si as bn_message,_i as bn_page,Mi as bn_scaling_group,Pi as bn_table,Li as bn_title,br as ibcs_chart_structure,th as ibcs_chart_time,xh as ibcs_table,Lh as ibcs_title}
|