(()=>{"use strict";var t={5795:t=>{t.exports=window.ReactDOM},8744:(t,e,n)=>{var o=n(5795);e.H=o.createRoot,o.hydrateRoot}},e={};const n=window.React;var o=function n(o){var r=e[o];if(void 0!==r)return r.exports;var a=e[o]={exports:{}};return t[o](a,a.exports,n),a.exports}(8744);const r="linear-gradient(135deg, #0040E3, #18D4FD)",a=(t,e,n=!1)=>{return null==(o=e)||""===o||Array.isArray(o)&&0===o.length||"object"==typeof o&&0===Object.keys(o).length||"string"==typeof o&&""===o.trim()||"number"==typeof o&&0===o?"":`${t}: ${e}${n?" !important":""};`;var o},i=(t,e=!0,n=!0,o=!0)=>{const{type:i="solid",color:l="",gradient:s=r,image:c={},position:d="center center",attachment:u="",repeat:b="no-repeat",size:p="",overlayColor:g=""}=t||{};return"gradient"===i&&n?a("background",s):"image"===i&&o?`background: url(${c?.url});\n\t\t\t\t${a("background-color",g)}\n\t\t\t\t${a("background-position",d)}\n\t\t\t\t${a("background-size",p)}\n\t\t\t\t${a("background-repeat",b)}\n\t\t\t\t${a("background-attachment",u)}\n\t\t\t\t${a("background-repeat",b)}\n\t\t\t\tbackground-blend-mode: overlay;`:e&&a("background",l)},l="bBlocksChart",s=({attributes:t,id:e})=>{const{background:o,width:r,height:a,alignment:s}=t,c=`#${e}`,d=`${c} .${l}`;return(0,n.createElement)("style",{dangerouslySetInnerHTML:{__html:`\n\t\t${c}{\n\t\t\ttext-align: ${s};\n\t\t}\n\t\t${d}{\n\t\t\theight: ${a};\n\t\t}\n\t\t${d},\n\t\t${c} .downloadArea{\n\t\t\twidth: ${r};\n\t\t}\n\t\t${d} canvas{\n\t\t\t${i(o)};\n\t\t}\n\t\t`.replace(/\s+/g," ")}})},c=({attributes:t,id:e,isBackend:o=!1})=>{const{data:r,type:a,textColor:i,isXScale:s,isXGridLine:c,isYScale:d,isYGridLine:u,gridLineColor:b,isTitle:p,title:g,titleFontSize:m,titleColor:y,isSubtitle:$,subtitle:h,subtitleFontSize:v,subtitleColor:k,isDownload:f}=t,w=(0,n.useRef)(null),S=(0,n.useRef)(null),E=o?[r,a,i,s,c,d,u,b,p,g,m,y,$,h,v,k,f]:[];return(0,n.useEffect)((()=>{o&&(w.current.innerHTML="",w.current.innerHTML="<canvas>Your browser does not support the canvas element.</canvas>");const n=document.querySelector(`#${e} .${l} canvas`),r=n&&new Chart(n,(t=>{const{data:e,type:n,textColor:o,isXScale:r,isXGridLine:a,isYScale:i,isYGridLine:l,gridLineColor:s,isTitle:c,title:d,titleFontSize:u,titleColor:b,isSubtitle:p,subtitle:g,subtitleFontSize:m,subtitleColor:y}=t;return{type:n,data:e,options:{maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{usePointStyle:!0,color:o}},title:{display:c,text:d,color:b,font:{size:u,family:"Roboto"},padding:{bottom:10}},subtitle:{display:p,text:g,color:y,font:{size:m,family:"Roboto"},padding:{bottom:15}},tooltip:{position:"nearest",usePointStyle:!0}},scales:{x:{display:r,ticks:{color:o},grid:{display:a,color:s}},y:{display:i,beginAtZero:!0,ticks:{color:o},grid:{display:l,color:s}}}}}})(t));f&&S?.current.addEventListener("click",(()=>{const t=document.createElement("a");t.href=r.toBase64Image(),t.download="b-chart.png",t.click()}))}),E),(0,n.createElement)(n.Fragment,null,f&&(0,n.createElement)("div",{className:"downloadArea"},(0,n.createElement)("div",{className:"downloadChart",ref:S},"Download Chart")),(0,n.createElement)("div",{className:l,ref:w},(0,n.createElement)("canvas",null,"Your browser does not support the canvas element.")))};document.addEventListener("DOMContentLoaded",(()=>{document.querySelectorAll(".wp-block-b-blocks-chart").forEach((t=>{const e=JSON.parse(t.dataset.attributes);(0,o.H)(t).render((0,n.createElement)(n.Fragment,null,(0,n.createElement)(s,{attributes:e,id:t.id}),(0,n.createElement)(c,{attributes:e,id:t.id}))),t?.removeAttribute("data-attributes")}))}))})();