@bino-bi/bn-template-engine 1.0.0-next.53 → 1.0.0-next.55

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.
Files changed (112) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-3379df20.entry.js +1 -0
  3. package/dist/bn-template-engine/{p-9a24e486.entry.js → p-471ea1b2.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-fdf42a77.entry.js → p-776e091f.entry.js} +1 -1
  5. package/dist/bn-template-engine/p-B6SpWzpW.js +1 -0
  6. package/dist/bn-template-engine/{p-NxJ6P79y.js → p-BXkVoFbt.js} +1 -1
  7. package/dist/bn-template-engine/{p-BL07yV8P.js → p-CZmA8CIL.js} +1 -1
  8. package/dist/bn-template-engine/{p-Dvlw60RF.js → p-CzzF-PBk.js} +1 -1
  9. package/dist/bn-template-engine/{p-Bvunba5p.js → p-DBRtHV59.js} +1 -1
  10. package/dist/bn-template-engine/{p-b75a4b52.entry.js → p-e905e4ee.entry.js} +1 -1
  11. package/dist/bn-template-engine/{p-150bdb68.entry.js → p-ef63af53.entry.js} +1 -1
  12. package/dist/bn-template-engine/{p-ddc1b2a9.entry.js → p-f62c59b0.entry.js} +1 -1
  13. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +34 -19
  14. package/dist/cjs/bn-grid.cjs.entry.js +3 -3
  15. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  16. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  17. package/dist/cjs/bn-ruleset.cjs.entry.js +2 -2
  18. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  19. package/dist/cjs/{localFrame-C4RBw_zT.js → localFrame-J1QUlhHH.js} +1 -1
  20. package/dist/cjs/{withBodyObserver-CIGVLQEB.js → withBodyObserver-DhrwVmn_.js} +1 -1
  21. package/dist/cjs/{withHasError-CZFrIJw0.js → withHasError-DOXAxUCF.js} +2 -0
  22. package/dist/cjs/{withStyled-BISQLGLe.js → withStyled-CHR4d8Hl.js} +1 -1
  23. package/dist/cjs/{withTranslation-B7T30EVU.js → withTranslation-Vuxqw9J7.js} +2 -2
  24. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +6 -2
  25. package/dist/collection/components/bn-annotation-layer/utils/marks.js +7 -4
  26. package/dist/collection/components/bn-annotation-list/bn-annotation-list.js +6 -2
  27. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +2 -1
  28. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +1 -0
  29. package/dist/collection/components/bn-chart-structure/utils/elements/Axis.js +1 -1
  30. package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +2 -0
  31. package/dist/collection/stores/componentStyles.js +2 -0
  32. package/dist/collection/utils/layoutState/svgChartElements.js +4 -4
  33. package/dist/components/bn-annotation-layer.js +1 -1
  34. package/dist/components/bn-annotation-list.js +1 -1
  35. package/dist/components/bn-asset.js +1 -1
  36. package/dist/components/bn-body.js +1 -1
  37. package/dist/components/bn-card.js +1 -1
  38. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  39. package/dist/components/bn-chart-bubble.js +1 -1
  40. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  41. package/dist/components/bn-chart-bullet.js +1 -1
  42. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  43. package/dist/components/bn-chart-scatter.js +1 -1
  44. package/dist/components/bn-chart-structure-renderer.js +1 -1
  45. package/dist/components/bn-chart-structure.js +1 -1
  46. package/dist/components/bn-chart-time-renderer.js +1 -1
  47. package/dist/components/bn-chart-time.js +1 -1
  48. package/dist/components/bn-component-style.js +1 -1
  49. package/dist/components/bn-context.js +1 -1
  50. package/dist/components/bn-dataset.js +1 -1
  51. package/dist/components/bn-datasource.js +1 -1
  52. package/dist/components/bn-footer.js +1 -1
  53. package/dist/components/bn-grid.js +1 -1
  54. package/dist/components/bn-image.js +1 -1
  55. package/dist/components/bn-internationalization.js +1 -1
  56. package/dist/components/bn-layout-card.js +1 -1
  57. package/dist/components/bn-layout-page.js +1 -1
  58. package/dist/components/bn-message.js +1 -1
  59. package/dist/components/bn-page.js +1 -1
  60. package/dist/components/bn-ruleset.js +1 -1
  61. package/dist/components/bn-scaling-group.js +1 -1
  62. package/dist/components/bn-table-renderer.js +1 -1
  63. package/dist/components/bn-table.js +1 -1
  64. package/dist/components/bn-text.js +1 -1
  65. package/dist/components/bn-title.js +1 -1
  66. package/dist/components/bn-tree.js +1 -1
  67. package/dist/components/p-5LbdDgZ5.js +1 -0
  68. package/dist/components/{p-dSUX43yf.js → p-BAvpRnjI.js} +1 -1
  69. package/dist/components/{p-DRU71K0s.js → p-BCTmWVaW.js} +1 -1
  70. package/dist/components/{p-Bp5Xj4-s.js → p-BPvwrhvq.js} +1 -1
  71. package/dist/components/{p-CZSp0rSS.js → p-BQD7EWUn.js} +1 -1
  72. package/dist/components/p-BY1Y1Ipv.js +1 -0
  73. package/dist/components/{p-DdvG1D18.js → p-Bmb0YBzz.js} +1 -1
  74. package/dist/components/{p-CiljAoC5.js → p-BpyLanO3.js} +1 -1
  75. package/dist/components/p-CFF7b9FT.js +1 -0
  76. package/dist/components/p-CFY-zEXs.js +1 -0
  77. package/dist/components/{p-DMAaBt7n.js → p-CTX2pUU7.js} +1 -1
  78. package/dist/components/{p-DKcw-1ot.js → p-CThV2et_.js} +1 -1
  79. package/dist/components/{p-CHJ6WE0l.js → p-CWSjn_DC.js} +1 -1
  80. package/dist/components/{p-jEqo8YD5.js → p-ChMe_jnA.js} +1 -1
  81. package/dist/components/p-ClFDt6Bk.js +1 -0
  82. package/dist/components/{p-LHIKI9Dp.js → p-D7pKezNW.js} +1 -1
  83. package/dist/components/{p-NdDdfez6.js → p-Dmsa7xm_.js} +1 -1
  84. package/dist/components/{p-BOwmXBm-.js → p-LB2R8XbL.js} +1 -1
  85. package/dist/components/{p-JG4Sx1lE.js → p-NkLVO7n9.js} +1 -1
  86. package/dist/components/{p-D65TnLS9.js → p-OR6uR6gy.js} +1 -1
  87. package/dist/components/{p-2t-lysdb.js → p-YuXVqXS_.js} +1 -1
  88. package/dist/components/{p-4xaxuPVU.js → p-tz4QGm3s.js} +1 -1
  89. package/dist/esm/bn-annotation-layer_30.entry.js +34 -19
  90. package/dist/esm/bn-grid.entry.js +3 -3
  91. package/dist/esm/bn-image.entry.js +2 -2
  92. package/dist/esm/bn-internationalization.entry.js +2 -2
  93. package/dist/esm/bn-ruleset.entry.js +2 -2
  94. package/dist/esm/bn-text.entry.js +3 -3
  95. package/dist/esm/{localFrame-WNu1bAPm.js → localFrame-wBZfmzjd.js} +1 -1
  96. package/dist/esm/{withBodyObserver-wJgSN1Pj.js → withBodyObserver-DgAvBnkB.js} +1 -1
  97. package/dist/esm/{withHasError-BDWEBrrb.js → withHasError-CRNW6htv.js} +2 -0
  98. package/dist/esm/{withStyled-CrTxIZ0Q.js → withStyled-BBzg5lxJ.js} +1 -1
  99. package/dist/esm/{withTranslation-BtSJmx1J.js → withTranslation-D1H_U5az.js} +2 -2
  100. package/dist/schemas/theme.schema.json +12 -0
  101. package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +1 -1
  102. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +1 -0
  103. package/dist/types/stores/componentStyles.d.ts +4 -0
  104. package/dist/types/utils/annotations.d.ts +2 -0
  105. package/package.json +1 -1
  106. package/dist/bn-template-engine/p-0d8eade3.entry.js +0 -1
  107. package/dist/bn-template-engine/p-7pLJBHT2.js +0 -1
  108. package/dist/components/p-6242qMx1.js +0 -1
  109. package/dist/components/p-9a9XB5Y8.js +0 -1
  110. package/dist/components/p-BXP6aagM.js +0 -1
  111. package/dist/components/p-Bs5V6Ibu.js +0 -1
  112. package/dist/components/p-CZzlLTQc.js +0 -1
@@ -1 +1 @@
1
- import{r as t,h as s,a as i,g as o}from"./p-GstO_GU5.js";import{w as e}from"./p-BL07yV8P.js";import{w as r,a,g as n,f as h,R as c}from"./p-7pLJBHT2.js";import{e as b}from"./p-ClruFZD_.js";const f=class{constructor(s){t(this,s),this.namespace="_system",r(this),this.errors=a(this),e(this,(t=>{if(this.stores||(this.stores=n(this.element)),""!==t.trim())try{const s=JSON.parse(t);if(null===s||"object"!=typeof s||Array.isArray(s))throw new Error("not a JSON object.");const i=h(s);for(const[t,s]of Object.entries(c))t in i&&!(s in i)&&(i[s]=i[t]);const o=this.namespace||"_system",e=Object.assign({},this.stores.internationalization.get(o));e[this.code]=Object.assign(Object.assign({},e[this.code]),i),this.stores.internationalization.set(o,e),this.errors.remove("ERR_body")}catch(t){this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${b(t)}`})}else this.errors.remove("ERR_body")}))}render(){return s(i,{key:"7e7454bf0b02ea746a736daaabb09c9ff52b3775"})}get element(){return o(this)}};f.style="bn-internationalization{display:none}";export{f as bn_internationalization}
1
+ import{r as t,h as s,a as i,g as o}from"./p-GstO_GU5.js";import{w as e}from"./p-CZmA8CIL.js";import{w as r,a,g as n,f as h,R as c}from"./p-B6SpWzpW.js";import{e as b}from"./p-ClruFZD_.js";const p=class{constructor(s){t(this,s),this.namespace="_system",r(this),this.errors=a(this),e(this,(t=>{if(this.stores||(this.stores=n(this.element)),""!==t.trim())try{const s=JSON.parse(t);if(null===s||"object"!=typeof s||Array.isArray(s))throw new Error("not a JSON object.");const i=h(s);for(const[t,s]of Object.entries(c))t in i&&!(s in i)&&(i[s]=i[t]);const o=this.namespace||"_system",e=Object.assign({},this.stores.internationalization.get(o));e[this.code]=Object.assign(Object.assign({},e[this.code]),i),this.stores.internationalization.set(o,e),this.errors.remove("ERR_body")}catch(t){this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${b(t)}`})}else this.errors.remove("ERR_body")}))}render(){return s(i,{key:"7e7454bf0b02ea746a736daaabb09c9ff52b3775"})}get element(){return o(this)}};p.style="bn-internationalization{display:none}";export{p as bn_internationalization}
@@ -1 +1 @@
1
- import{r as t,h as i,a as e,g as o}from"./p-GstO_GU5.js";import{L as s}from"./p-DY5fMUX8.js";import{l as n,o as l,r,m as a,a as d}from"./p-Dvlw60RF.js";import{w as h,a as c}from"./p-7pLJBHT2.js";import{w as u,a as v}from"./p-NxJ6P79y.js";function f(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);return Array.isArray(i)?i.map(((t,i)=>{var e,o,s;return"string"==typeof t?{label:t,id:String(i)}:"object"==typeof t&&null!==t?{label:null!==(o=null!==(e=t.label)&&void 0!==e?e:t.name)&&void 0!==o?o:String(i),id:null!==(s=t.id)&&void 0!==s?s:String(i)}:{label:String(t),id:String(i)}})):[]}catch(t){return console.error("parseHeaders: failed to parse JSON",t),[]}}function p(t,i){return`${t.id}-${i.id}`}function g(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);if(!Array.isArray(i))return["Headers must be an array"];const e=[],o=new Set;return i.forEach(((t,i)=>{"object"==typeof t&&null!==t&&void 0!==t.id&&("string"!=typeof t.id?e.push(`Header[${i}]: 'id' must be a string`):o.has(t.id)?e.push(`Header[${i}]: duplicate id '${t.id}'`):o.add(t.id),void 0!==t.label&&"string"!=typeof t.label&&e.push(`Header[${i}]: 'label' must be a string`))})),e}catch(t){return console.error("validateHeadersJson: failed to parse JSON",t),["Invalid JSON structure"]}}const b=["auto","equal"],m=["top","center","bottom","baseline"],w=["left","center","right","baseline"],y={top:"flex-start",center:"center",bottom:"flex-end",baseline:"flex-start"},S={left:"stretch",center:"center",right:"flex-end",baseline:"stretch"};function x(t){if(null===t||""===t.trim())return 1;const i=Number(t);return Number.isInteger(i)&&i>=1?i:void 0}function $(t,i,e){var o,s;const n=Array.from({length:t},(()=>Array(i))),l=[],r=[];for(let a=0;a<t;a++)for(let d=0;d<i;d++){const h=n[a][d];if(h){r.push({row:a,column:d,by:h});continue}const c=e(a,d),u=Math.min(null!==(o=null==c?void 0:c.rowSpan)&&void 0!==o?o:1,t-a);let v=1;const f=Math.min(null!==(s=null==c?void 0:c.columnSpan)&&void 0!==s?s:1,i-d);for(;v<f&&!n[a][d+v];)v++;const p={row:a,column:d,rowSpan:u,columnSpan:v};for(let t=a;t<a+u;t++)for(let i=d;i<d+v;i++)n[t][i]=p;l.push(p)}return{cells:l,covered:r}}const C=t=>Math.round(100*t)/100,R=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]),O=new Set(["bn-layout-card"]),j={top:"--bn-baseline-offset-top",left:"--bn-baseline-offset-left",right:"--bn-baseline-offset-right"},H=["row-span","column-span","cell-background"],k=class{validateRowHeaders(t){const i="ERR_rowHeaders",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:`row-headers: ${e.join("; ")}`}):this.errors.remove(i),this.updateGridConfig()}validateColumnHeaders(t){const i="ERR_columnHeaders",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:`column-headers: ${e.join("; ")}`}):this.errors.remove(i),this.updateGridConfig()}validateCellHeight(t){this.resolvedHeight=this.validateChoice("cell-height","ERR_cellHeight",t,b,"auto")}validateCellWidth(t){this.resolvedWidth=this.validateChoice("cell-width","ERR_cellWidth",t,b,"auto")}validateCellVerticalAlign(t){this.resolvedVertical=this.validateChoice("cell-vertical-align","ERR_cellVerticalAlign",t,m,"top"),this.schedule()}validateCellHorizontalAlign(t){this.resolvedHorizontal=this.validateChoice("cell-horizontal-align","ERR_cellHorizontalAlign",t,w,"left"),this.schedule()}validateCellCaptions(t){const i=function(t){if(void 0===t||""===t.trim())return{};let i;try{i=JSON.parse(t)}catch(t){return}if("object"!=typeof i||null===i||Array.isArray(i))return;const e={};for(const[t,o]of Object.entries(i)){if("string"!=typeof o)return;""!==o&&(e[t]=o)}return e}(t);i?this.errors.remove("ERR_cellCaptions"):this.errors.addOrReplace({id:"ERR_cellCaptions",type:"error",message:"cell-captions: not a JSON object from slot name to text."}),this.captions=null!=i?i:{}}constructor(i){t(this,i),this.gridConfig={rows:[],columns:[]},this.resolvedHeight="auto",this.resolvedWidth="auto",this.resolvedVertical="top",this.resolvedHorizontal="left",this.captions={},this.offsets={},this.cellAttributes={},this.placed=[],this.frames=new Map,this.observed=new WeakSet,this.scheduled=!1,this.run=0,this.adjustments=0,this.chartTitle="",this.rowHeaders="[]",this.columnHeaders="[]",this.showRowHeaders=!0,this.showColumnHeaders=!0,this.showBorders=!0,this.rowHeaderWidth="auto",this.cellGap="0px",this.cellHeight="auto",this.cellWidth="auto",this.cellVerticalAlign="top",this.cellHorizontalAlign="left",this.cellCaptions="",this.schedule=()=>{if(!this.isBaselineMode())return this.run++,Object.keys(this.offsets).length>0&&(this.offsets={}),void this.applyFrameOffsets();this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.align().catch((t=>console.error("bn-grid: aligning the baselines failed",t))).finally(t)}))}))))},u(this),this.holdStatus=h(this),this.errors=c(this),this.componentStyle=v(this)}connectedCallback(){var t;this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver((()=>{this.readCellAttributes(),this.checkCoveredSlots(),this.schedule()})),this.mutationObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot",...H]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule),this.readCellAttributes()}disconnectedCallback(){var t,i,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(e=document.fonts)||void 0===e||e.removeEventListener("loadingdone",this.schedule),this.run++}componentDidRender(){this.schedule()}validateChoice(t,i,e,o,s){return null==e||""===e?(this.errors.remove(i),s):o.includes(e)?(this.errors.remove(i),e):(this.errors.addOrReplace({id:i,type:"error",message:`${t}: "${e}" is not one of ${o.join(", ")}.`}),s)}readCellAttributes(){const t={},i=[];for(const e of Array.from(this.element.children)){const o=e.getAttribute("slot");if(null===o)continue;const s=t=>{const s=x(e.getAttribute(t));return void 0===s&&i.push(`${t} of slot "${o}"`),null!=s?s:1},n={rowSpan:s("row-span"),columnSpan:s("column-span")},l=e.getAttribute("cell-background");l&&(n.background=l),(n.rowSpan>1||n.columnSpan>1||n.background)&&(t[o]=n)}i.length>0?this.errors.addOrReplace({id:"ERR_cellSpan",type:"error",message:`${i.join(", ")}: not a whole number from 1.`}):this.errors.remove("ERR_cellSpan"),JSON.stringify(t)!==JSON.stringify(this.cellAttributes)&&(this.cellAttributes=t)}placeDataCells(){const{rows:t,columns:i}=this.gridConfig,e=(e,o)=>p(t[e],i[o]),{cells:o}=$(t.length,i.length,((t,i)=>this.cellAttributes[e(t,i)]));this.placed=o.map((t=>Object.assign(Object.assign({},t),{slot:e(t.row,t.column)}))),this.checkCoveredSlots()}checkCoveredSlots(){var t;const{rows:i,columns:e}=null!==(t=this.gridConfig)&&void 0!==t?t:{rows:[],columns:[]},o=(t,o)=>p(i[t],e[o]),{covered:s}=$(i.length,e.length,((t,i)=>this.cellAttributes[o(t,i)])),n=new Set(Array.from(this.element.children).map((t=>t.getAttribute("slot")))),l=s.filter((({row:t,column:i})=>n.has(o(t,i))));if(l.length>0){const t=l.map((({row:t,column:i,by:e})=>`"${o(t,i)}" (covered by "${o(e.row,e.column)}")`));this.errors.addOrReplace({id:"WARN_cellSpan",type:"warning",message:`a span covers the slot ${t.join(", ")}: its content is not shown.`})}else this.errors.remove("WARN_cellSpan")}isBaselineMode(){return"baseline"===this.resolvedVertical||"baseline"===this.resolvedHorizontal}contentIn(t){const i=Array.from(this.element.children).find((i=>i.getAttribute("slot")===t));if(!i)return{};const e=[i,...Array.from(i.querySelectorAll("*"))],o=e.find((t=>t.localName.startsWith("bn-")&&!R.has(t.localName)&&!O.has(t.localName))),s=o?e.find((t=>O.has(t.localName)&&t.contains(o))):void 0;return{visual:o,frame:s}}applyFrameOffsets(){this.frames.forEach(((t,i)=>{const e=this.offsets[i];Object.keys(j).forEach((i=>{const o=null==e?void 0:e[i];o?t.style.setProperty(j[i],`${o}px`):t.style.removeProperty(j[i])}))}))}async align(){var t;const i=++this.run;if(!this.element.isConnected||!this.isBaselineMode())return;const e=this.placed,o=e.map((({slot:t})=>this.contentIn(t))),s=o.map((t=>t.visual));if(await Promise.all(s.map((t=>{var i;return null===(i=null==t?void 0:t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;s.forEach((t=>t&&this.observe(t)));const l=await Promise.all(s.map((t=>"function"==typeof(null==t?void 0:t.getBaseline)?t.getBaseline().catch((()=>({}))):Promise.resolve({}))));if(i!==this.run)return;const r=n(this.element),a=new Map;null===(t=this.element.shadowRoot)||void 0===t||t.querySelectorAll(".grid-slot").forEach((t=>{var i;a.set(null!==(i=t.getAttribute("data-slot"))&&void 0!==i?i:"",t)})),this.frames=new Map,o.forEach((({frame:t},i)=>t&&this.frames.set(e[i].slot,t)));const d=function(t,i,e){const o={};for(const i of t)o[i.slot]={};const s=(i,e,s,n,l)=>{var r,a;const d=new Map;for(const o of t)(null!==(r=o[e])&&void 0!==r?r:1)>1||d.set(o[i],[...null!==(a=d.get(o[i]))&&void 0!==a?a:[],o]);for(const t of d.values()){const i=t.map((t=>{const i=s(t);return void 0===i?void 0:i-n(t)})),e=i.filter((t=>void 0!==t)),r=e.length>0?Math.max(...e):0,a=i.map((t=>void 0===t?void 0:C(r-t))),d=Math.max(0,...a.filter((t=>void 0!==t)));t.forEach(((t,i)=>l(o[t.slot],a[i],d)))}};return i&&s("row","rowSpan",(t=>t.y),(t=>t.top),((t,i)=>{void 0===i?t.bottom=!0:t.top=i})),e&&s("column","columnSpan",(t=>t.x),(t=>t.left),((t,i,e)=>{void 0!==i&&(t.left=i);const o=C(e-(null!=i?i:0));o>0&&(t.right=o)})),o}(e.map((({slot:t,row:i,column:e,rowSpan:n,columnSpan:d},h)=>{const c=s[h],u=l[h],v=o[h].frame,f=null!=v?v:a.get(t),p=t=>parseFloat((null==f?void 0:f.style.getPropertyValue(t))||"0")||0,g={slot:t,row:i,column:e,rowSpan:n,columnSpan:d,top:p(v?j.top:"padding-top"),left:p(v?j.left:"margin-left")};if(c){const t=r.toLocal(c.getBoundingClientRect());void 0!==u.y&&(g.y=t.y+u.y),void 0!==u.x&&(g.x=t.x+u.x)}return g})),"baseline"===this.resolvedVertical,"baseline"===this.resolvedHorizontal);if(function(t,i){var e,o,s,n,l,r,a,d;const h=new Set([...Object.keys(t),...Object.keys(i)]);for(const c of h){const h=null!==(e=t[c])&&void 0!==e?e:{},u=null!==(o=i[c])&&void 0!==o?o:{};if(Boolean(h.bottom)!==Boolean(u.bottom))return!1;if(Math.abs((null!==(s=h.top)&&void 0!==s?s:0)-(null!==(n=u.top)&&void 0!==n?n:0))>=.5)return!1;if(Math.abs((null!==(l=h.left)&&void 0!==l?l:0)-(null!==(r=u.left)&&void 0!==r?r:0))>=.5)return!1;if(Math.abs((null!==(a=h.right)&&void 0!==a?a:0)-(null!==(d=u.right)&&void 0!==d?d:0))>=.5)return!1}return!0}(d,this.offsets))this.adjustments=0;else{if(this.adjustments>=5)return console.warn("bn-grid: the baselines did not settle; the cells keep their last alignment."),void(this.adjustments=0);this.adjustments++,this.offsets=d,this.applyFrameOffsets(),this.schedule()}}observe(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t));const e=t=>{var i;t&&(this.observed.has(t)||(this.observed.add(t),null===(i=this.mutationObserver)||void 0===i||i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["x1","y1","x2","y2","x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}async getLayoutState(t){var i,e,o,n;const h=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",c=l(this.element),u=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),{rows:v,columns:f}=this.gridConfig,p={version:s,tag:this.element.localName,id:d(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:a(this.element,c),em:{fontSizePx:u,appliedScaleFactor:1},regions:[],metadata:{title:this.chartTitle||void 0,rowCount:v.length,columnCount:f.length,cellCount:this.placed.length},diagnostics:r(this.element)},g=null===(o=this.element.shadowRoot)||void 0===o?void 0:o.querySelector(".grid-container");if(g&&p.regions.push({id:"grid",rect:a(g,c)}),"full"!==h||!g)return p;const b=[],m=t=>b.push(t),w=g.querySelector(".grid-title");return w&&m({kind:"gridTitle",label:(null===(n=w.textContent)||void 0===n?void 0:n.trim())||void 0,rect:a(w,c)}),g.querySelectorAll(".grid-header-col").forEach(((t,i)=>{var e,o;m({kind:"gridHeader",columnId:null===(e=f[i])||void 0===e?void 0:e.id,label:(null===(o=t.textContent)||void 0===o?void 0:o.trim())||void 0,rect:a(t,c)})})),g.querySelectorAll(".grid-header-row").forEach(((t,i)=>{var e,o;m({kind:"gridHeader",rowId:null===(e=v[i])||void 0===e?void 0:e.id,label:(null===(o=t.textContent)||void 0===o?void 0:o.trim())||void 0,rect:a(t,c)})})),g.querySelectorAll(".grid-cell").forEach(((t,i)=>{var e,o,s,n;const l=this.placed[i];m(Object.assign(Object.assign(Object.assign({kind:"gridCell",rowId:l?null===(e=v[l.row])||void 0===e?void 0:e.id:void 0,columnId:l?null===(o=f[l.column])||void 0===o?void 0:o.id:void 0,slot:null!==(n=null===(s=t.querySelector("slot"))||void 0===s?void 0:s.getAttribute("name"))&&void 0!==n?n:void 0},(null==l?void 0:l.rowSpan)>1?{rowSpan:l.rowSpan}:{}),(null==l?void 0:l.columnSpan)>1?{columnSpan:l.columnSpan}:{}),{rect:a(t,c)}))})),g.querySelectorAll(".grid-caption").forEach((t=>{var i,e,o,s;m({kind:"gridCaption",slot:null!==(o=null===(e=null===(i=t.parentElement)||void 0===i?void 0:i.querySelector("slot"))||void 0===e?void 0:e.getAttribute("name"))&&void 0!==o?o:void 0,label:(null===(s=t.textContent)||void 0===s?void 0:s.trim())||void 0,rect:a(t,c)})})),p.elements=b,p}getGridStyle(){return this.componentStyle((t=>t["bn-grid"]))}componentWillLoad(){this.validateRowHeaders(this.rowHeaders),this.validateColumnHeaders(this.columnHeaders),this.validateCellHeight(this.cellHeight),this.validateCellWidth(this.cellWidth),this.validateCellVerticalAlign(this.cellVerticalAlign),this.validateCellHorizontalAlign(this.cellHorizontalAlign),this.validateCellCaptions(this.cellCaptions),this.readCellAttributes()}componentWillRender(){this.placeDataCells()}updateGridConfig(){var t;this.gridConfig=(t=this.columnHeaders,{rows:f(this.rowHeaders),columns:f(t)})}shouldShowRowHeaders(){return this.showRowHeaders&&this.gridConfig.rows.length>0}shouldShowColumnHeaders(){return this.showColumnHeaders&&this.gridConfig.columns.length>0}shouldShowBorders(){return this.showBorders}getGridTemplateColumns(){const t=[];this.shouldShowRowHeaders()&&t.push(this.rowHeaderWidth);const i=this.gridConfig.columns.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedWidth?"minmax(0, 1fr)":"auto");return t.join(" ")}getGridTemplateRows(){const t=[];this.chartTitle&&t.push("auto"),this.shouldShowColumnHeaders()&&t.push("auto");const i=this.gridConfig.rows.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedHeight?"1fr":"auto");return t.join(" ")}renderTitle(){if(!this.chartTitle)return null;const t=(this.shouldShowRowHeaders()?1:0)+this.gridConfig.columns.length;return i("div",{class:"grid-title",style:{"grid-column":`1 / span ${t}`,"grid-row":"1"}},this.chartTitle)}renderColumnHeaders(){if(!this.shouldShowColumnHeaders())return null;const t=this.getGridStyle(),e=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",o=this.shouldShowRowHeaders()?2:1,s=this.chartTitle?2:1;return this.gridConfig.columns.map(((n,l)=>{const r=l>0;return i("div",{key:`col-header-${n.id}`,class:"grid-header grid-header-col",style:{"grid-column":String(o+l),"grid-row":String(s),"border-left":r?e:"none",padding:`${t.cellPadding}px`,"padding-left":r?`${t.cellPadding+4}px`:`${t.cellPadding}px`}},n.label)}))}renderDataCells(){const t=this.getGridStyle(),e=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",o=this.shouldShowRowHeaders()?2:1,s=(this.chartTitle?1:0)+(this.shouldShowColumnHeaders()?1:0)+1,n=[],l=(t,i)=>i>1?`${t} / span ${i}`:String(t);return this.gridConfig.rows.length>0&&this.gridConfig.columns.length>0&&this.gridConfig.rows.forEach(((r,a)=>{if(this.shouldShowRowHeaders()){const o=a>0;n.push(i("div",{key:`row-header-${r.id}`,class:"grid-header grid-header-row",style:{"grid-column":"1","grid-row":String(s+a),"border-top":o?e:"none",padding:`${t.cellPadding}px`,"padding-top":o?`${t.cellPadding+4}px`:`${t.cellPadding}px`}},r.label))}this.placed.filter((t=>t.row===a)).forEach((({slot:r,column:d,rowSpan:h,columnSpan:c})=>{var u,v;const f=d>0,p=a>0,g=null!==(v=null===(u=this.cellAttributes[r])||void 0===u?void 0:u.background)&&void 0!==v?v:t.cellBackground&&"transparent"!==t.cellBackground?t.cellBackground:void 0;n.push(i("div",{key:`cell-${r}`,class:"grid-cell","data-bn-fit-content":"",style:Object.assign(Object.assign({"grid-column":l(o+d,c),"grid-row":l(s+a,h),"border-left":f?e:"none","border-top":p?e:"none","padding-left":f?`${t.cellPadding+4}px`:"0","padding-top":p?`${t.cellPadding+4}px`:"0"},this.cellAlignStyle()),g?{"background-color":g}:{})},this.renderCellContent(r,t)))}))})),n}cellAlignStyle(){return"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal?{}:{display:"flex","flex-direction":"column","justify-content":y[this.resolvedVertical],"align-items":S[this.resolvedHorizontal]}}renderCellContent(t,e){var o;const s=this.captions[t],n=void 0!==s?i("div",{class:"grid-caption",style:{"font-size":`${e.captionFontSize}px`,"font-weight":String(e.captionFontWeight),color:e.captionColor,"margin-bottom":`${e.captionGap}px`,"align-self":"flex-start"}},s):null,l={};"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal||(l["align-self"]="stretch","center"!==this.resolvedHorizontal&&"right"!==this.resolvedHorizontal||(l.display="flex",l["flex-direction"]="column",l["align-items"]=S[this.resolvedHorizontal])),"center"===this.resolvedVertical?(l["margin-top"]="auto",l["margin-bottom"]="auto"):"bottom"===this.resolvedVertical&&(l["margin-top"]="auto");const r=this.frames.has(t)?{bottom:null===(o=this.offsets[t])||void 0===o?void 0:o.bottom}:this.offsets[t];return(null==r?void 0:r.bottom)&&(l["margin-top"]="auto"),(null==r?void 0:r.top)&&(l["padding-top"]=`${r.top}px`),(null==r?void 0:r.left)&&(l["margin-left"]=`${r.left}px`),(null==r?void 0:r.right)&&(l["margin-right"]=`${r.right}px`),[n,i("div",{class:"grid-slot","data-slot":t,style:l},i("slot",{name:t}))]}getFontStyles(){return this.componentStyle((t=>{var i,e,o,s;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(o=t.global)||void 0===o?void 0:o.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t="equal"===this.resolvedWidth,o=Object.assign(Object.assign({display:t?"grid":"inline-grid"},t?{width:"100%"}:{}),{"grid-template-columns":this.getGridTemplateColumns(),"grid-template-rows":this.getGridTemplateRows(),gap:this.cellGap});return i(e,{key:"97d858fb6f5704dfd46638c8e5c6a74927e702e0",style:t?Object.assign(Object.assign({},this.getFontStyles()),{display:"block"}):this.getFontStyles()},i("div",{key:"1e218eac5865574fcb4572d1aaea60f1d87d8948",class:"grid-container",style:o},this.renderTitle(),this.renderColumnHeaders(),this.renderDataCells()),i("slot",{key:"aabefa01213c69c0303f1df06f5575973253677e"}))}get element(){return o(this)}static get watchers(){return{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}}};k.style=':host{display:inline-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)}.grid-container{display:inline-grid;box-sizing:border-box}.grid-title{font-weight:normal;padding-bottom:8px}.grid-header{display:flex;align-items:flex-end;box-sizing:border-box}.grid-header-row{justify-content:flex-end;padding-right:8px}.grid-header-col{white-space:nowrap;justify-content:flex-start}.grid-cell{position:relative;box-sizing:border-box}';export{k as bn_grid}
1
+ import{r as t,h as i,a as e,g as o}from"./p-GstO_GU5.js";import{L as s}from"./p-DY5fMUX8.js";import{l as n,o as l,r,m as a,a as d}from"./p-CzzF-PBk.js";import{w as h,a as c}from"./p-B6SpWzpW.js";import{w as u,a as v}from"./p-BXkVoFbt.js";function f(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);return Array.isArray(i)?i.map(((t,i)=>{var e,o,s;return"string"==typeof t?{label:t,id:String(i)}:"object"==typeof t&&null!==t?{label:null!==(o=null!==(e=t.label)&&void 0!==e?e:t.name)&&void 0!==o?o:String(i),id:null!==(s=t.id)&&void 0!==s?s:String(i)}:{label:String(t),id:String(i)}})):[]}catch(t){return console.error("parseHeaders: failed to parse JSON",t),[]}}function p(t,i){return`${t.id}-${i.id}`}function g(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);if(!Array.isArray(i))return["Headers must be an array"];const e=[],o=new Set;return i.forEach(((t,i)=>{"object"==typeof t&&null!==t&&void 0!==t.id&&("string"!=typeof t.id?e.push(`Header[${i}]: 'id' must be a string`):o.has(t.id)?e.push(`Header[${i}]: duplicate id '${t.id}'`):o.add(t.id),void 0!==t.label&&"string"!=typeof t.label&&e.push(`Header[${i}]: 'label' must be a string`))})),e}catch(t){return console.error("validateHeadersJson: failed to parse JSON",t),["Invalid JSON structure"]}}const b=["auto","equal"],m=["top","center","bottom","baseline"],w=["left","center","right","baseline"],y={top:"flex-start",center:"center",bottom:"flex-end",baseline:"flex-start"},S={left:"stretch",center:"center",right:"flex-end",baseline:"stretch"};function x(t){if(null===t||""===t.trim())return 1;const i=Number(t);return Number.isInteger(i)&&i>=1?i:void 0}function $(t,i,e){var o,s;const n=Array.from({length:t},(()=>Array(i))),l=[],r=[];for(let a=0;a<t;a++)for(let d=0;d<i;d++){const h=n[a][d];if(h){r.push({row:a,column:d,by:h});continue}const c=e(a,d),u=Math.min(null!==(o=null==c?void 0:c.rowSpan)&&void 0!==o?o:1,t-a);let v=1;const f=Math.min(null!==(s=null==c?void 0:c.columnSpan)&&void 0!==s?s:1,i-d);for(;v<f&&!n[a][d+v];)v++;const p={row:a,column:d,rowSpan:u,columnSpan:v};for(let t=a;t<a+u;t++)for(let i=d;i<d+v;i++)n[t][i]=p;l.push(p)}return{cells:l,covered:r}}const C=t=>Math.round(100*t)/100,O=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]),R=new Set(["bn-layout-card"]),j={top:"--bn-baseline-offset-top",left:"--bn-baseline-offset-left",right:"--bn-baseline-offset-right"},H=["row-span","column-span","cell-background"],k=class{validateRowHeaders(t){const i="ERR_rowHeaders",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:`row-headers: ${e.join("; ")}`}):this.errors.remove(i),this.updateGridConfig()}validateColumnHeaders(t){const i="ERR_columnHeaders",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:`column-headers: ${e.join("; ")}`}):this.errors.remove(i),this.updateGridConfig()}validateCellHeight(t){this.resolvedHeight=this.validateChoice("cell-height","ERR_cellHeight",t,b,"auto")}validateCellWidth(t){this.resolvedWidth=this.validateChoice("cell-width","ERR_cellWidth",t,b,"auto")}validateCellVerticalAlign(t){this.resolvedVertical=this.validateChoice("cell-vertical-align","ERR_cellVerticalAlign",t,m,"top"),this.schedule()}validateCellHorizontalAlign(t){this.resolvedHorizontal=this.validateChoice("cell-horizontal-align","ERR_cellHorizontalAlign",t,w,"left"),this.schedule()}validateCellCaptions(t){const i=function(t){if(void 0===t||""===t.trim())return{};let i;try{i=JSON.parse(t)}catch(t){return}if("object"!=typeof i||null===i||Array.isArray(i))return;const e={};for(const[t,o]of Object.entries(i)){if("string"!=typeof o)return;""!==o&&(e[t]=o)}return e}(t);i?this.errors.remove("ERR_cellCaptions"):this.errors.addOrReplace({id:"ERR_cellCaptions",type:"error",message:"cell-captions: not a JSON object from slot name to text."}),this.captions=null!=i?i:{}}constructor(i){t(this,i),this.gridConfig={rows:[],columns:[]},this.resolvedHeight="auto",this.resolvedWidth="auto",this.resolvedVertical="top",this.resolvedHorizontal="left",this.captions={},this.offsets={},this.cellAttributes={},this.placed=[],this.frames=new Map,this.observed=new WeakSet,this.scheduled=!1,this.run=0,this.adjustments=0,this.chartTitle="",this.rowHeaders="[]",this.columnHeaders="[]",this.showRowHeaders=!0,this.showColumnHeaders=!0,this.showBorders=!0,this.rowHeaderWidth="auto",this.cellGap="0px",this.cellHeight="auto",this.cellWidth="auto",this.cellVerticalAlign="top",this.cellHorizontalAlign="left",this.cellCaptions="",this.schedule=()=>{if(!this.isBaselineMode())return this.run++,Object.keys(this.offsets).length>0&&(this.offsets={}),void this.applyFrameOffsets();this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.align().catch((t=>console.error("bn-grid: aligning the baselines failed",t))).finally(t)}))}))))},u(this),this.holdStatus=h(this),this.errors=c(this),this.componentStyle=v(this)}connectedCallback(){var t;this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver((()=>{this.readCellAttributes(),this.checkCoveredSlots(),this.schedule()})),this.mutationObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot",...H]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule),this.readCellAttributes()}disconnectedCallback(){var t,i,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(e=document.fonts)||void 0===e||e.removeEventListener("loadingdone",this.schedule),this.run++}componentDidRender(){this.schedule()}validateChoice(t,i,e,o,s){return null==e||""===e?(this.errors.remove(i),s):o.includes(e)?(this.errors.remove(i),e):(this.errors.addOrReplace({id:i,type:"error",message:`${t}: "${e}" is not one of ${o.join(", ")}.`}),s)}readCellAttributes(){const t={},i=[];for(const e of Array.from(this.element.children)){const o=e.getAttribute("slot");if(null===o)continue;const s=t=>{const s=x(e.getAttribute(t));return void 0===s&&i.push(`${t} of slot "${o}"`),null!=s?s:1},n={rowSpan:s("row-span"),columnSpan:s("column-span")},l=e.getAttribute("cell-background");l&&(n.background=l),(n.rowSpan>1||n.columnSpan>1||n.background)&&(t[o]=n)}i.length>0?this.errors.addOrReplace({id:"ERR_cellSpan",type:"error",message:`${i.join(", ")}: not a whole number from 1.`}):this.errors.remove("ERR_cellSpan"),JSON.stringify(t)!==JSON.stringify(this.cellAttributes)&&(this.cellAttributes=t)}placeDataCells(){const{rows:t,columns:i}=this.gridConfig,e=(e,o)=>p(t[e],i[o]),{cells:o}=$(t.length,i.length,((t,i)=>this.cellAttributes[e(t,i)]));this.placed=o.map((t=>Object.assign(Object.assign({},t),{slot:e(t.row,t.column)}))),this.checkCoveredSlots()}checkCoveredSlots(){var t;const{rows:i,columns:e}=null!==(t=this.gridConfig)&&void 0!==t?t:{rows:[],columns:[]},o=(t,o)=>p(i[t],e[o]),{covered:s}=$(i.length,e.length,((t,i)=>this.cellAttributes[o(t,i)])),n=new Set(Array.from(this.element.children).map((t=>t.getAttribute("slot")))),l=s.filter((({row:t,column:i})=>n.has(o(t,i))));if(l.length>0){const t=l.map((({row:t,column:i,by:e})=>`"${o(t,i)}" (covered by "${o(e.row,e.column)}")`));this.errors.addOrReplace({id:"WARN_cellSpan",type:"warning",message:`a span covers the slot ${t.join(", ")}: its content is not shown.`})}else this.errors.remove("WARN_cellSpan")}isBaselineMode(){return"baseline"===this.resolvedVertical||"baseline"===this.resolvedHorizontal}contentIn(t){const i=Array.from(this.element.children).find((i=>i.getAttribute("slot")===t));if(!i)return{};const e=[i,...Array.from(i.querySelectorAll("*"))],o=e.find((t=>t.localName.startsWith("bn-")&&!O.has(t.localName)&&!R.has(t.localName))),s=o?e.find((t=>R.has(t.localName)&&t.contains(o))):void 0;return{visual:o,frame:s}}applyFrameOffsets(){this.frames.forEach(((t,i)=>{const e=this.offsets[i];Object.keys(j).forEach((i=>{const o=null==e?void 0:e[i];o?t.style.setProperty(j[i],`${o}px`):t.style.removeProperty(j[i])}))}))}async align(){var t;const i=++this.run;if(!this.element.isConnected||!this.isBaselineMode())return;const e=this.placed,o=e.map((({slot:t})=>this.contentIn(t))),s=o.map((t=>t.visual));if(await Promise.all(s.map((t=>{var i;return null===(i=null==t?void 0:t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;s.forEach((t=>t&&this.observe(t)));const l=await Promise.all(s.map((t=>"function"==typeof(null==t?void 0:t.getBaseline)?t.getBaseline().catch((()=>({}))):Promise.resolve({}))));if(i!==this.run)return;const r=n(this.element),a=new Map;null===(t=this.element.shadowRoot)||void 0===t||t.querySelectorAll(".grid-slot").forEach((t=>{var i;a.set(null!==(i=t.getAttribute("data-slot"))&&void 0!==i?i:"",t)})),this.frames=new Map,o.forEach((({frame:t},i)=>t&&this.frames.set(e[i].slot,t)));const d=function(t,i,e){const o={};for(const i of t)o[i.slot]={};const s=(i,e,s,n,l)=>{var r,a;const d=new Map;for(const o of t)(null!==(r=o[e])&&void 0!==r?r:1)>1||d.set(o[i],[...null!==(a=d.get(o[i]))&&void 0!==a?a:[],o]);for(const t of d.values()){const i=t.map((t=>{const i=s(t);return void 0===i?void 0:i-n(t)})),e=i.filter((t=>void 0!==t)),r=e.length>0?Math.max(...e):0,a=i.map((t=>void 0===t?void 0:C(r-t))),d=Math.max(0,...a.filter((t=>void 0!==t)));t.forEach(((t,i)=>l(o[t.slot],a[i],d)))}};return i&&s("row","rowSpan",(t=>t.y),(t=>t.top),((t,i)=>{void 0===i?t.bottom=!0:t.top=i})),e&&s("column","columnSpan",(t=>t.x),(t=>t.left),((t,i,e)=>{void 0!==i&&(t.left=i);const o=C(e-(null!=i?i:0));o>0&&(t.right=o)})),o}(e.map((({slot:t,row:i,column:e,rowSpan:n,columnSpan:d},h)=>{const c=s[h],u=l[h],v=o[h].frame,f=null!=v?v:a.get(t),p=t=>parseFloat((null==f?void 0:f.style.getPropertyValue(t))||"0")||0,g={slot:t,row:i,column:e,rowSpan:n,columnSpan:d,top:p(v?j.top:"padding-top"),left:p(v?j.left:"margin-left")};if(c){const t=r.toLocal(c.getBoundingClientRect());void 0!==u.y&&(g.y=t.y+u.y),void 0!==u.x&&(g.x=t.x+u.x)}return g})),"baseline"===this.resolvedVertical,"baseline"===this.resolvedHorizontal);if(function(t,i){var e,o,s,n,l,r,a,d;const h=new Set([...Object.keys(t),...Object.keys(i)]);for(const c of h){const h=null!==(e=t[c])&&void 0!==e?e:{},u=null!==(o=i[c])&&void 0!==o?o:{};if(Boolean(h.bottom)!==Boolean(u.bottom))return!1;if(Math.abs((null!==(s=h.top)&&void 0!==s?s:0)-(null!==(n=u.top)&&void 0!==n?n:0))>=.5)return!1;if(Math.abs((null!==(l=h.left)&&void 0!==l?l:0)-(null!==(r=u.left)&&void 0!==r?r:0))>=.5)return!1;if(Math.abs((null!==(a=h.right)&&void 0!==a?a:0)-(null!==(d=u.right)&&void 0!==d?d:0))>=.5)return!1}return!0}(d,this.offsets))this.adjustments=0;else{if(this.adjustments>=5)return console.warn("bn-grid: the baselines did not settle; the cells keep their last alignment."),void(this.adjustments=0);this.adjustments++,this.offsets=d,this.applyFrameOffsets(),this.schedule()}}observe(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t));const e=t=>{var i;t&&(this.observed.has(t)||(this.observed.add(t),null===(i=this.mutationObserver)||void 0===i||i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["x1","y1","x2","y2","x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}async getLayoutState(t){var i,e,o,n;const h=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",c=l(this.element),u=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),{rows:v,columns:f}=this.gridConfig,p={version:s,tag:this.element.localName,id:d(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:a(this.element,c),em:{fontSizePx:u,appliedScaleFactor:1},regions:[],metadata:{title:this.chartTitle||void 0,rowCount:v.length,columnCount:f.length,cellCount:this.placed.length},diagnostics:r(this.element)},g=null===(o=this.element.shadowRoot)||void 0===o?void 0:o.querySelector(".grid-container");if(g&&p.regions.push({id:"grid",rect:a(g,c)}),"full"!==h||!g)return p;const b=[],m=t=>b.push(t),w=g.querySelector(".grid-title");return w&&m({kind:"gridTitle",label:(null===(n=w.textContent)||void 0===n?void 0:n.trim())||void 0,rect:a(w,c)}),g.querySelectorAll(".grid-header-col").forEach(((t,i)=>{var e,o;m({kind:"gridHeader",columnId:null===(e=f[i])||void 0===e?void 0:e.id,label:(null===(o=t.textContent)||void 0===o?void 0:o.trim())||void 0,rect:a(t,c)})})),g.querySelectorAll(".grid-header-row").forEach(((t,i)=>{var e,o;m({kind:"gridHeader",rowId:null===(e=v[i])||void 0===e?void 0:e.id,label:(null===(o=t.textContent)||void 0===o?void 0:o.trim())||void 0,rect:a(t,c)})})),g.querySelectorAll(".grid-cell").forEach(((t,i)=>{var e,o,s,n;const l=this.placed[i];m(Object.assign(Object.assign(Object.assign({kind:"gridCell",rowId:l?null===(e=v[l.row])||void 0===e?void 0:e.id:void 0,columnId:l?null===(o=f[l.column])||void 0===o?void 0:o.id:void 0,slot:null!==(n=null===(s=t.querySelector("slot"))||void 0===s?void 0:s.getAttribute("name"))&&void 0!==n?n:void 0},(null==l?void 0:l.rowSpan)>1?{rowSpan:l.rowSpan}:{}),(null==l?void 0:l.columnSpan)>1?{columnSpan:l.columnSpan}:{}),{rect:a(t,c)}))})),g.querySelectorAll(".grid-caption").forEach((t=>{var i,e,o,s;m({kind:"gridCaption",slot:null!==(o=null===(e=null===(i=t.parentElement)||void 0===i?void 0:i.querySelector("slot"))||void 0===e?void 0:e.getAttribute("name"))&&void 0!==o?o:void 0,label:(null===(s=t.textContent)||void 0===s?void 0:s.trim())||void 0,rect:a(t,c)})})),p.elements=b,p}getGridStyle(){return this.componentStyle((t=>t["bn-grid"]))}componentWillLoad(){this.validateRowHeaders(this.rowHeaders),this.validateColumnHeaders(this.columnHeaders),this.validateCellHeight(this.cellHeight),this.validateCellWidth(this.cellWidth),this.validateCellVerticalAlign(this.cellVerticalAlign),this.validateCellHorizontalAlign(this.cellHorizontalAlign),this.validateCellCaptions(this.cellCaptions),this.readCellAttributes()}componentWillRender(){this.placeDataCells()}updateGridConfig(){var t;this.gridConfig=(t=this.columnHeaders,{rows:f(this.rowHeaders),columns:f(t)})}shouldShowRowHeaders(){return this.showRowHeaders&&this.gridConfig.rows.length>0}shouldShowColumnHeaders(){return this.showColumnHeaders&&this.gridConfig.columns.length>0}shouldShowBorders(){return this.showBorders}getGridTemplateColumns(){const t=[];this.shouldShowRowHeaders()&&t.push(this.rowHeaderWidth);const i=this.gridConfig.columns.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedWidth?"minmax(0, 1fr)":"auto");return t.join(" ")}getGridTemplateRows(){const t=[];this.chartTitle&&t.push("auto"),this.shouldShowColumnHeaders()&&t.push("auto");const i=this.gridConfig.rows.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedHeight?"1fr":"auto");return t.join(" ")}renderTitle(){if(!this.chartTitle)return null;const t=(this.shouldShowRowHeaders()?1:0)+this.gridConfig.columns.length;return i("div",{class:"grid-title",style:{"grid-column":`1 / span ${t}`,"grid-row":"1"}},this.chartTitle)}renderColumnHeaders(){if(!this.shouldShowColumnHeaders())return null;const t=this.getGridStyle(),e=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",o=this.shouldShowRowHeaders()?2:1,s=this.chartTitle?2:1;return this.gridConfig.columns.map(((n,l)=>{const r=l>0;return i("div",{key:`col-header-${n.id}`,class:"grid-header grid-header-col",style:{"grid-column":String(o+l),"grid-row":String(s),"border-left":r?e:"none",padding:`${t.cellPadding}px`,"padding-left":r?`${t.cellPadding+4}px`:`${t.cellPadding}px`}},n.label)}))}renderDataCells(){const t=this.getGridStyle(),e=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",o=this.shouldShowRowHeaders()?2:1,s=(this.chartTitle?1:0)+(this.shouldShowColumnHeaders()?1:0)+1,n=[],l=(t,i)=>i>1?`${t} / span ${i}`:String(t);return this.gridConfig.rows.length>0&&this.gridConfig.columns.length>0&&this.gridConfig.rows.forEach(((r,a)=>{if(this.shouldShowRowHeaders()){const o=a>0;n.push(i("div",{key:`row-header-${r.id}`,class:"grid-header grid-header-row",style:{"grid-column":"1","grid-row":String(s+a),"border-top":o?e:"none",padding:`${t.cellPadding}px`,"padding-top":o?`${t.cellPadding+4}px`:`${t.cellPadding}px`}},r.label))}this.placed.filter((t=>t.row===a)).forEach((({slot:r,column:d,rowSpan:h,columnSpan:c})=>{var u,v;const f=d>0,p=a>0,g=null!==(v=null===(u=this.cellAttributes[r])||void 0===u?void 0:u.background)&&void 0!==v?v:t.cellBackground&&"transparent"!==t.cellBackground?t.cellBackground:void 0;n.push(i("div",{key:`cell-${r}`,class:"grid-cell","data-bn-fit-content":"",style:Object.assign(Object.assign({"grid-column":l(o+d,c),"grid-row":l(s+a,h),"border-left":f?e:"none","border-top":p?e:"none","padding-left":f?`${t.cellPadding+4}px`:"0","padding-top":p?`${t.cellPadding+4}px`:"0"},this.cellAlignStyle()),g?{"background-color":g}:{})},this.renderCellContent(r,t)))}))})),n}cellAlignStyle(){return"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal?{}:{display:"flex","flex-direction":"column","justify-content":y[this.resolvedVertical],"align-items":S[this.resolvedHorizontal]}}renderCellContent(t,e){var o;const s=this.captions[t],n=void 0!==s?i("div",{class:"grid-caption",style:{"font-size":`${e.captionFontSize}px`,"font-weight":String(e.captionFontWeight),color:e.captionColor,"margin-bottom":`${e.captionGap}px`,"align-self":"flex-start"}},s):null,l={};"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal||(l["align-self"]="stretch","center"!==this.resolvedHorizontal&&"right"!==this.resolvedHorizontal||(l.display="flex",l["flex-direction"]="column",l["align-items"]=S[this.resolvedHorizontal])),"center"===this.resolvedVertical?(l["margin-top"]="auto",l["margin-bottom"]="auto"):"bottom"===this.resolvedVertical&&(l["margin-top"]="auto");const r=this.frames.has(t)?{bottom:null===(o=this.offsets[t])||void 0===o?void 0:o.bottom}:this.offsets[t];return(null==r?void 0:r.bottom)&&(l["margin-top"]="auto"),(null==r?void 0:r.top)&&(l["padding-top"]=`${r.top}px`),(null==r?void 0:r.left)&&(l["margin-left"]=`${r.left}px`),(null==r?void 0:r.right)&&(l["margin-right"]=`${r.right}px`),[n,i("div",{class:"grid-slot","data-slot":t,style:l},i("slot",{name:t}))]}getFontStyles(){return this.componentStyle((t=>{var i,e,o,s;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(o=t.global)||void 0===o?void 0:o.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t="equal"===this.resolvedWidth,o=Object.assign(Object.assign({display:t?"grid":"inline-grid"},t?{width:"100%"}:{}),{"grid-template-columns":this.getGridTemplateColumns(),"grid-template-rows":this.getGridTemplateRows(),gap:this.cellGap});return i(e,{key:"97d858fb6f5704dfd46638c8e5c6a74927e702e0",style:t?Object.assign(Object.assign({},this.getFontStyles()),{display:"block"}):this.getFontStyles()},i("div",{key:"1e218eac5865574fcb4572d1aaea60f1d87d8948",class:"grid-container",style:o},this.renderTitle(),this.renderColumnHeaders(),this.renderDataCells()),i("slot",{key:"aabefa01213c69c0303f1df06f5575973253677e"}))}get element(){return o(this)}static get watchers(){return{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}}};k.style=':host{display:inline-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)}.grid-container{display:inline-grid;box-sizing:border-box}.grid-title{font-weight:normal;padding-bottom:8px}.grid-header{display:flex;align-items:flex-end;box-sizing:border-box}.grid-header-row{justify-content:flex-end;padding-right:8px}.grid-header-col{white-space:nowrap;justify-content:flex-start}.grid-cell{position:relative;box-sizing:border-box}';export{k as bn_grid}