"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime");require("react");const h=require("react-markdown"),j=require("remark-gfm"),v=require("rehype-raw"),p=require("string-template"),_=/(\+?\%)[\(]([A-z0-9,.,-]+)\)/gi,q=/(\+?\#)[\(]([A-z0-9,.,-]+)\)/gi,N=/(\+?\#C)[\(]([A-z0-9,.,-]+)\)/gi,m=(n,e,o,s,r,g)=>{if(!r||!r.formatNumber)return e;let t,a=e;for(;(t=n.exec(e))!==null;){const u=t[2],c=t[1],x=((f,y=2)=>r.formatNumber(s?f/100:f,{maximumFractionDigits:y,...o,signDisplay:c&&c.startsWith("+")?"never":"auto"})).apply(void 0,u.split(","));a=a.replaceAll(t[0],x)}return a},d=(n,e,o,s)=>{if(!n||!e)return"";e.field&&e[`_${e.field}`]&&(e._value=e[`_${e.field}`]),!e.field&&e.category&&(e.field=e.category);let r=s?p(n,e):p(n,e).replace(/(?:\r\n|\r|\n)/g,"<br>");return r=m(_,r,{style:"percent"},!0,o),r=m(q,r,{style:"decimal"},!1,o),r=m(N,r,{notation:"compact"},!1,o),r},F=({tooltip:n,d:e,intl:o,tooltipEnableMarkdown:s})=>{if(!e||!n)return i.jsx("div",{});const r=e.datum||e.point||e,{color:g,data:t}=r||{},a=e.value||(e.datum?e.datum.value:null)||(e.point?e.point.data.y:null);if(t){let u;t.variables?u=typeof t.variables[e.id]=="object"?t.variables[e.id]:t.variables:u=t;const c={field:e.point?e.point.serieId:e.id||"",...u,value:a};t.measureFieldName&&t.variables&&(c.populationValue=t.variables[t.measureFieldName+"Population"]);const l=d(n,c,o,s);return l?s?i.jsx("div",{className:"chart tooltip",children:i.jsx(h,{children:l,remarkPlugins:[j],rehypePlugins:[v]})}):i.jsx("div",{className:"chart tooltip",children:i.jsx("div",{dangerouslySetInnerHTML:{__html:l}})}):i.jsx("div",{})}else return i.jsx("div",{})};exports.default=F;exports.formatContent=d;
