typeof Craft.Formie>"u"&&(Craft.Formie={});Craft.Formie.ChartColors={blue:{bg:"rgba(66,153,225, 0.1)",border:"#4299E1"},cyan:{bg:"rgba(56, 190, 201, 0.1)",border:"rgba(56, 190, 201, 0.75)"},orange:{bg:"rgba(237, 137, 54, 0.1)",border:"#ED8936"},red:{bg:"rgba(245, 101, 101, 0.1)",border:"#F56565"},green:{bg:"rgba(72, 187, 120, 0.1)",border:"#48BB78"},purple:{bg:"rgba(128, 90, 213, 0.1)",border:"#805AD5"},grey:{bg:"rgb(160, 174, 192, 0.1)",border:"#A0AEC0"},gridLines:"rgba(155, 155, 155, 0.1)",text:"hsl(209, 18%, 30%)",bgColors(){return[this.blue.bg,this.red.bg,this.orange.bg,this.green.bg,this.purple.bg,this.cyan.bg]},borderColors(){return[this.blue.border,this.red.border,this.orange.border,this.green.border,this.purple.border,this.cyan.border]},doughnutColors(){return[this.blue.border,this.red.border,this.orange.border,this.green.border,this.purple.border,this.grey.border]}};Craft.Formie.ChartCurrencyTicks=function(e,r,t){return new Intl.NumberFormat(window.formieCurrentLocale,{style:"currency",currency:window.formieCurrency}).format(e)};Craft.Formie.Chart=Garnish.Base.extend({defaults:{general:{options:{legend:{labels:{boxWidth:8,usePointStyle:!0},onClick(e,r){return!1}},tooltips:{bodyFontColor:Craft.Formie.ChartColors.text,backgroundColor:"#fff",borderColor:Craft.Formie.ChartColors.gridLines,borderWidth:1,caretPadding:6,caretSize:0,mode:"index",titleFontColor:Craft.Formie.ChartColors.text,enabled:!1,callbacks:{title(e,r){var t="";if(e[0].xLabel){t=e[0].xLabel;var a="MMM D",s=!0;r.labels.forEach(o=>{o.match(/^\d{4}\-\d{2}\-01$/g)||(s=!1)}),s&&(a="MMM YYYY"),t=moment(t).format(a)}return t},label(e,r){var t;return e.yLabel==""?t=r.datasets[e.datasetIndex].data[e.index]:t=e.yLabel,r.datasets[e.datasetIndex].yAxisID&&r.datasets[e.datasetIndex].yAxisID=="revenue"?t=Craft.Formie.ChartCurrencyTicks(t,0,[]):t=Craft.formatNumber(t),t}},custom(e){var r=document.getElementById("chartjs-tooltip");if(r||(r=document.createElement("div"),r.id="chartjs-tooltip",r.innerHTML='<div class="chartjs-tooltip-container"></div>',document.body.appendChild(r)),r.classList.add("formie-widget-chart-tooltip"),e.opacity===0){r.style.opacity=0;return}r.classList.remove("above","below","no-transform"),e.yAlign?r.classList.add(e.yAlign):r.classList.add("no-transform");function t(l){return l.lines}if(e.body){var a=e.title||[],s=e.body.map(t),o="<div>";a.forEach(l=>{l&&l!="null"&&(o+="<h3>"+l+"</h3>")}),s.forEach((l,u)=>{var i=e.labelColors[u],d="background:"+i.backgroundColor;d+="; border-color:"+i.borderColor;var g='<span class="legend-dot" style="'+d+'"></span>';o+='<div class="formie-widget-chart-tooltip-items">'+g+"<span>"+l+"</span></div>"}),o+="</div>";var b=r.querySelector(".chartjs-tooltip-container");b.innerHTML=o}var n=this._chart.canvas.getBoundingClientRect();r.style.opacity=1,r.style.position="absolute",r.style.left=n.left+window.pageXOffset+e.caretX+"px",r.style.top=n.top+window.pageYOffset+e.caretY+"px",r.style.fontFamily=e._bodyFontFamily,r.style.fontSize=e.bodyFontSize+"px",r.style.fontStyle=e._bodyFontStyle,r.style.pointerEvents="none"}}}},line:{options:{aspectRatio:2.5,legend:{labels:{boxWidth:6}},tooltips:{intersect:!1}}},doughnut:{options:{aspectRatio:1,cutoutPercentage:60,legend:{position:"bottom"}}}},datasetDefaults:{general:{},doughnut:{backgroundColor:Craft.Formie.ChartColors.doughnutColors(),borderColor:Craft.Formie.ChartColors.doughnutColors(),borderWidth:0},line:{borderWidth:3,pointRadius:2,pointHitRadius:4,lineTension:0}},globalDefaults:{defaultFontFamily:"system-ui, BlinkMacSystemFont, -apple-system, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"},rtl:!1,rtlDefaults:{options:{legend:{rtl:!0},tooltips:{rtl:!0}}},chart:null,init(e,r){if(moment.locale(window.formieCurrentLocale),this.$container=$("#"+e),this.rtl=$("body").hasClass("rtl"),this.$container.length&&r.chart){var t=this.getDefaultOptions(r.chart.type);t=deepmerge(t,r.chart),t=this.mergeRtlOptions(t),t.data&&t.data.datasets&&t.data.datasets.length&&(t.data.datasets=this.mergeDatasetsDefaults(t.data.datasets,t.type)),this.renderChart(t)}},getDefaultOptions(e){var r=this.defaults.general;return this.defaults[e]&&(r=deepmerge(r,this.defaults[e])),r},mergeDatasetsDefaults(e,r){if(this.datasetDefaults[r]==null)return e;for(var t=[],a=0,s,o=0;o<e.length;o++)s=deepmerge(this.datasetDefaults[r],e[o]),r=="line"&&(s=deepmerge(s,{backgroundColor:Craft.Formie.ChartColors.bgColors()[a],borderColor:Craft.Formie.ChartColors.borderColors()[a],pointBackgroundColor:Craft.Formie.ChartColors.borderColors()[a]})),t.push(s),a++,a==Craft.Formie.ChartColors.bgColors().length&&(a=0);return t},mergeRtlOptions(e){return this.rtl?deepmerge(e,this.rtlDefaults):e},renderChart(e){Chart.defaults.global=deepmerge(Chart.defaults.global,this.globalDefaults),this.chart=new Chart(this.$container,e)}});
//# sourceMappingURL=formie-widgets.js.map
