|
1
|
|
-(()=>{"use strict";var t={5338:(t,e,n)=>{var r=n(5795);e.H=r.createRoot,r.hydrateRoot},5795:t=>{t.exports=window.ReactDOM}},e={};const n=window.React;var r=function n(r){var o=e[r];if(void 0!==o)return o.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,n),a.exports}(5338);const o="linear-gradient(135deg, #0040E3, #18D4FD)",a=(t,e,n=!1)=>{return null==(r=e)||""===r||Array.isArray(r)&&0===r.length||"object"==typeof r&&0===Object.keys(r).length||"string"==typeof r&&""===r.trim()||"number"==typeof r&&0===r?"":`${t}: ${e}${n?" !important":""};`;var r},i=(t,e=!0,n=!0,r=!0)=>{const{type:i="solid",color:l="",gradient:s=o,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&&r?`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:r,width:o,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: ${o};\n\t\t}\n\t\t${d} canvas{\n\t\t\t${i(r)};\n\t\t}\n\t\t`.replace(/\s+/g," ")}})},c=({attributes:t,id:e,isBackend:r=!1})=>{const{data:o,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=r?[o,a,i,s,c,d,u,b,p,g,m,y,$,h,v,k,f,w.current]:[];return(0,n.useEffect)((()=>{r&&(w.current.innerHTML="",w.current.innerHTML="<canvas>Your browser does not support the canvas element.</canvas>");const n=w.current.ownerDocument,o=n.querySelector(`#${e} .${l} canvas`),a=o&&new Chart(o,(t=>{const{data:e,type:n,textColor:r,isXScale:o,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:r}},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:o,ticks:{color:r},grid:{display:a,color:s}},y:{display:i,beginAtZero:!0,ticks:{color:r},grid:{display:l,color:s}}}}}})(t));f&&S?.current.addEventListener("click",(()=>{const t=n.createElement("a");t.href=a.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,r.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")}))}))})(); |
|
1
|
+(()=>{"use strict";const t=window.ReactDOM,e=window.React;new class{constructor(t={}){this.defaultOptions={allowedTags:["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","defs","clipPath","mask","linearGradient","radialGradient","stop","style","title","desc"],allowedAttributes:["id","class","style","transform","xmlns","xmlns:xlink","version","baseProfile","xml:space","d","x","y","width","height","cx","cy","r","rx","ry","points","x1","y1","x2","y2","viewBox","preserveAspectRatio","overflow","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","opacity","color","paint-order","vector-effect","shape-rendering","display","visibility","clip-path","clip-rule","clipPathUnits","mask","maskUnits","maskContentUnits","offset","stop-color","stop-opacity","gradientUnits","gradientTransform","spreadMethod","fx","fy","fr","dx","dy","text-anchor","dominant-baseline","alignment-baseline","font-family","font-size","font-style","font-weight","letter-spacing","word-spacing","textLength","lengthAdjust","role","focusable","aria-hidden","aria-label","aria-labelledby","aria-describedby"],allowedProtocols:["http","https","data"],removeScripts:!0,removeEvents:!0,removeExternalResources:!0,sanitizeStyle:!0},this.options={...this.defaultOptions,...t},this.allowedTagSet=new Set(this.options.allowedTags.map((t=>t.toLowerCase()))),this.allowedAttributeSet=new Set(this.options.allowedAttributes.map((t=>t.toLowerCase())))}sanitize(t){if("string"!=typeof t||""===t.trim())return"";const e=(new DOMParser).parseFromString(t,"image/svg+xml"),r=e.documentElement;return!r||"svg"!==r.localName.toLowerCase()||e.getElementsByTagName("parsererror").length?"":(this.removeScripts(e),this.sanitizeElements(e),(new XMLSerializer).serializeToString(e.documentElement))}async sanitizeFile(t){const e=await fetch(t),r=await e.text();return this.sanitize(`${r}`)}removeScripts(t){this.options.removeScripts&&Array.from(t.querySelectorAll("*")).forEach((t=>{t.localName.toLowerCase().includes("script")&&t.remove()}))}sanitizeElements(t){Array.from(t.querySelectorAll("*")).forEach((t=>{const e=t.localName.toLowerCase();this.allowedTagSet.has(e)?("style"===e&&this.options.sanitizeStyle&&(t.textContent=this.sanitizeCss(t.textContent)),this.sanitizeAttributes(t)):t.remove()}))}sanitizeAttributes(t){Array.from(t.attributes).forEach((e=>{const r=e.name,i=r.toLowerCase(),s=e.value;if(this.options.removeEvents&&i.startsWith("on"))return void t.removeAttribute(r);if(this.options.removeExternalResources&&("href"===i||i.endsWith(":href"))&&!this.isAllowedUrl(s))return void t.removeAttribute(r);const o=i.replace("xlink:","");this.allowedAttributeSet.has(i)||this.allowedAttributeSet.has(o)?this.options.removeExternalResources&&this.hasExternalUrl(s)?t.removeAttribute(r):"style"===i&&this.options.sanitizeStyle&&t.setAttribute(r,this.sanitizeCss(s)):t.removeAttribute(r)}))}hasExternalUrl(t){return!("string"!=typeof t||!/url\s*\(/i.test(t))&&Array.from(t.matchAll(/url\s*\(\s*['"]?([^'")]*)/gi)).some((([,t])=>!t.trim().startsWith("#")))}isAllowedUrl(t){const e=String(t||"").trim();if(e.startsWith("#"))return!0;if(/^data:/i.test(e))return this.options.allowedProtocols.includes("data")&&/^data:image\/(png|jpe?g|gif|webp);base64,/i.test(e);try{return this.options.allowedProtocols.includes(new URL(e).protocol.replace(":",""))}catch{return!1}}sanitizeCss(t){return String(t||"").replace(/expression\s*\(/gi,"").replace(/javascript:/gi,"").replace(/behavior\s*:/gi,"").replace(/binding\s*:/gi,"").replace(/@import[^;]*;?/gi,"").replace(/url\s*\(\s*(['"]?)(?!#)[^)]*\)/gi,"none")}};const r="linear-gradient(135deg, #0040E3, #18D4FD)",i=t=>{const e=(t=>{try{const e=new URL(t);return["http:","https:"].includes(e.protocol)?e.toString():null}catch(e){return"string"==typeof t&&t.startsWith("/")&&!t.startsWith("//")?t:null}})(t);return e?`url('${e.replace(/['"()]/g,"")}')`:"none"},s=(t,e)=>{return null==(r=e)||""===r||Array.isArray(r)&&0===r.length||"object"==typeof r&&0===Object.keys(r).length||"string"==typeof r&&""===r.trim()||"number"==typeof r&&0===r?"":`${t}: ${e};`;var r},o=(t,e=!0,o=!0,n=!0)=>{const{type:a="solid",color:l="",gradient:c=r,image:d={},position:u="center center",attachment:p="",repeat:h="no-repeat",size:m="",overlayColor:g=""}=t||{};return"gradient"===a&&o?s("background",c):"image"===a&&n?`background: ${i(d?.url)};\n\t\t\t\t${s("background-color",g)}\n\t\t\t\t${s("background-position",u)}\n\t\t\t\t${s("background-size",m)}\n\t\t\t\t${s("background-repeat",h)}\n\t\t\t\t${s("background-attachment",p)}\n\t\t\t\t${s("background-repeat",h)}\n\t\t\t\tbackground-blend-mode: overlay;`:e&&s("background",l)},n="bBlocksChart",a=window.ReactJSXRuntime,l=({attributes:t,id:e})=>{const{background:r,width:i,height:s,alignment:l}=t,c=`#${e}`,d=`${c} .${n}`;return(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n\t\t${c}{\n\t\t\ttext-align: ${l};\n\t\t}\n\t\t${d}{\n\t\t\theight: ${s};\n\t\t}\n\t\t${d},\n\t\t${c} .downloadArea{\n\t\t\twidth: ${i};\n\t\t}\n\t\t${d} canvas{\n\t\t\t${o(r)};\n\t\t}\n\t\t`.replace(/\s+/g," ")}})},c=({attributes:t,id:r,isBackend:i=!1})=>{const{data:s,type:o,textColor:l,isXScale:c,isXGridLine:d,isYScale:u,isYGridLine:p,gridLineColor:h,isTitle:m,title:g,titleFontSize:b,titleColor:y,isSubtitle:f,subtitle:w,subtitleFontSize:v,subtitleColor:x,isDownload:S}=t,k=(0,e.useRef)(null),A=(0,e.useRef)(null),C=i?[s,o,l,c,d,u,p,h,m,g,b,y,f,w,v,x,S,k.current]:[];return(0,e.useEffect)((()=>{i&&(k.current.innerHTML="",k.current.innerHTML="<canvas>Your browser does not support the canvas element.</canvas>");const e=k.current.ownerDocument,s=e.querySelector(`#${r} .${n} canvas`),o=s&&new Chart(s,(t=>{const{data:e,type:r,textColor:i,isXScale:s,isXGridLine:o,isYScale:n,isYGridLine:a,gridLineColor:l,isTitle:c,title:d,titleFontSize:u,titleColor:p,isSubtitle:h,subtitle:m,subtitleFontSize:g,subtitleColor:b}=t;return{type:r,data:e,options:{maintainAspectRatio:!1,plugins:{legend:{position:"top",labels:{usePointStyle:!0,color:i}},title:{display:c,text:d,color:p,font:{size:u,family:"Roboto"},padding:{bottom:10}},subtitle:{display:h,text:m,color:b,font:{size:g,family:"Roboto"},padding:{bottom:15}},tooltip:{position:"nearest",usePointStyle:!0}},scales:{x:{display:s,ticks:{color:i},grid:{display:o,color:l}},y:{display:n,beginAtZero:!0,ticks:{color:i},grid:{display:a,color:l}}}}}})(t));S&&A?.current.addEventListener("click",(()=>{const t=e.createElement("a");t.href=o.toBase64Image(),t.download="b-chart.png",t.click()}))}),C),(0,a.jsxs)(a.Fragment,{children:[S&&(0,a.jsx)("div",{className:"downloadArea",children:(0,a.jsx)("div",{className:"downloadChart",ref:A,children:"Download Chart"})}),(0,a.jsx)("div",{className:n,ref:k,children:(0,a.jsx)("canvas",{children:"Your browser does not support the canvas element."})})]})};document.addEventListener("DOMContentLoaded",(()=>{document.querySelectorAll(".wp-block-b-blocks-chart").forEach((e=>{const r=JSON.parse(e.dataset.attributes);(0,t.createRoot)(e).render((0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l,{attributes:r,id:e.id}),(0,a.jsx)(c,{attributes:r,id:e.id})]})),e?.removeAttribute("data-attributes")}))}))})(); |