UNPKG

highcharts

Version:
13 lines 30.2 kB
/** * Highcharts JS v13.0.1 (2026-08-17) * @module highcharts/modules/exporting * @requires highcharts * * Exporting module * * (c) 2010-2026 Highsoft AS * Author: Torstein Hønsi * * A commercial license may be required depending on use, * see www.highcharts.com/license */import*as e from"../highcharts.js";let t={};t.n=e=>{let n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},t.d=(e,n)=>{if(Array.isArray(n))for(var i=0;i<n.length;){var r=n[i++],o=n[i++];t.o(e,r)?0===o&&i++:0===o?Object.defineProperty(e,r,{enumerable:!0,value:n[i++]}):Object.defineProperty(e,r,{enumerable:!0,get:o})}else for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let n=e.default;var i,r,o=t.n(n);let a=e.default.AST;var l=t.n(a);let s=e.default.Chart;var c=t.n(s),h=i||(i={});h.compose=function(e){return e.navigation||(e.navigation=new d(e)),e};class d{constructor(e){this.updates=[],this.chart=e}addUpdate(e){this.chart.navigation.updates.push(e)}update(e,t){this.updates.forEach(n=>{n.call(this.chart,e,t)})}}h.Additions=d;let p=i,{isSafari:u,win:g,win:{document:f}}=o(),m=g.URL||g.webkitURL||g;function y(e,t){let n=g.navigator,i=f.createElement("a");if("string"!=typeof e&&!(e instanceof String)&&n.msSaveOrOpenBlob)return void n.msSaveOrOpenBlob(e,t);if(e=""+e,n.userAgent.length>1e3)throw Error("Input too long");let r=/Edge\/\d+/.test(n.userAgent);if((u&&"string"==typeof e&&0===e.indexOf("data:application/pdf")||r||e.length>2e6)&&!(e=function(e){let t=e.replace(/filename=.*;/,"").match(/data:([^;]*)(;base64)?,([A-Z+\d\/]+)/i);if(t&&t.length>3&&g.atob&&g.ArrayBuffer&&g.Uint8Array&&g.Blob&&m.createObjectURL){let e=g.atob(t[3]),n=new g.ArrayBuffer(e.length),i=new g.Uint8Array(n);for(let t=0;t<i.length;++t)i[t]=e.charCodeAt(t);return m.createObjectURL(new g.Blob([i],{type:t[1]}))}}(e)||""))throw Error("Failed to convert to blob");if(void 0!==i.download)i.href=e,i.download=t,f.body.appendChild(i),i.click(),f.body.removeChild(i);else try{if(!g.open(e,"chart"))throw Error("Failed to open window")}catch{g.location.href=e}}let{isTouchDevice:x}=o(),v={exporting:{allowHTML:!0,allowTableSorting:!0,local:!0,type:"image/png",url:`https://export-svg.highcharts.com?v=${o().version}`,pdfFont:{normal:void 0,bold:void 0,bolditalic:void 0,italic:void 0},printMaxWidth:780,scale:2,buttons:{contextButton:{className:"highcharts-contextbutton",menuClassName:"highcharts-contextmenu",symbol:"menu",titleKey:"contextButtonTitle",menuItems:["viewFullscreen","printChart","separator","downloadPNG","downloadJPEG","downloadSVG"]}},menuItemDefinitions:{viewFullscreen:{textKey:"viewFullscreen",onclick:function(){this.fullscreen?.toggle()}},printChart:{textKey:"printChart",onclick:function(){this.exporting?.print()}},separator:{separator:!0},downloadPNG:{textKey:"downloadPNG",onclick:async function(){await this.exporting?.exportChart()}},downloadJPEG:{textKey:"downloadJPEG",onclick:async function(){await this.exporting?.exportChart({type:"image/jpeg"})}},downloadPDF:{textKey:"downloadPDF",onclick:async function(){await this.exporting?.exportChart({type:"application/pdf"})}},downloadSVG:{textKey:"downloadSVG",onclick:async function(){await this.exporting?.exportChart({type:"image/svg+xml"})}}}},lang:{viewFullscreen:"View in full screen",exitFullscreen:"Exit from full screen",printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"},navigation:{buttonOptions:{symbolSize:14,symbolX:14.5,symbolY:13.5,align:"right",buttonSpacing:5,height:28,y:-5,verticalAlign:"top",width:28,symbolFill:"var(--highcharts-neutral-color-60)",symbolStroke:"var(--highcharts-neutral-color-60)",symbolStrokeWidth:3,theme:{fill:"var(--highcharts-background-color)",padding:5,stroke:"none","stroke-linecap":"round"}},menuStyle:{border:"none",borderRadius:"3px",background:"var(--highcharts-background-color)",padding:"0.5em"},menuItemStyle:{background:"none",borderRadius:"3px",color:"var(--highcharts-neutral-color-80)",padding:"0.5em",fontSize:x?"0.9em":"0.8em",transition:"background 250ms, color 250ms"},menuItemHoverStyle:{background:"var(--highcharts-neutral-color-5)"}}};!function(e){let t=[];function n(e,t,n,i){return[["M",e,t+2.5],["L",e+n,t+2.5],["M",e,t+i/2+.5],["L",e+n,t+i/2+.5],["M",e,t+i-1.5],["L",e+n,t+i-1.5]]}function i(e,t,n,i){let r=i/3-2,o=[];return o.concat(this.circle(n-r,t,r,r),this.circle(n-r,t+r+4,r,r),this.circle(n-r,t+2*(r+4),r,r))}e.compose=function(e){if(-1===t.indexOf(e)){t.push(e);let r=e.prototype.symbols;r.menu=n,r.menuball=i.bind(r)}}}(r||(r={}));let w=r,{composed:b}=o();function S(){this.fullscreen=new E(this)}class E{static compose(e){(0,n.pushUnique)(b,"Fullscreen")&&(0,n.addEvent)(e,"beforeRender",S)}constructor(e){this.chart=e,this.isOpen=!1;let t=e.renderTo;!this.browserProps&&("function"==typeof t.requestFullscreen?this.browserProps={fullscreenChange:"fullscreenchange",requestFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen"}:t.mozRequestFullScreen?this.browserProps={fullscreenChange:"mozfullscreenchange",requestFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen"}:t.webkitRequestFullScreen?this.browserProps={fullscreenChange:"webkitfullscreenchange",requestFullscreen:"webkitRequestFullScreen",exitFullscreen:"webkitExitFullscreen"}:t.msRequestFullscreen&&(this.browserProps={fullscreenChange:"MSFullscreenChange",requestFullscreen:"msRequestFullscreen",exitFullscreen:"msExitFullscreen"}))}close(){let e=this,t=e.chart,i=t.options.chart;(0,n.fireEvent)(t,"fullscreenClose",void 0,function(){e.isOpen&&e.browserProps&&t.container.ownerDocument instanceof Document&&t.container.ownerDocument[e.browserProps.exitFullscreen](),e.unbindFullscreenEvent&&(e.unbindFullscreenEvent=e.unbindFullscreenEvent()),t.setSize(e.origWidth,e.origHeight,!1),e.origWidth=void 0,e.origHeight=void 0,i.width=e.origWidthOption,i.height=e.origHeightOption,e.origWidthOption=void 0,e.origHeightOption=void 0,e.isOpen=!1,e.setButtonText()})}open(){let e=this,t=e.chart,i=t.options.chart;(0,n.fireEvent)(t,"fullscreenOpen",void 0,function(){if(i&&(e.origWidthOption=i.width,e.origHeightOption=i.height),e.origWidth=t.chartWidth,e.origHeight=t.chartHeight,e.browserProps){let i=(0,n.addEvent)(t.container.ownerDocument,e.browserProps.fullscreenChange,function(){e.isOpen?(e.isOpen=!1,e.close()):(t.setSize(null,null,!1),e.isOpen=!0,e.setButtonText())}),r=(0,n.addEvent)(t,"destroy",i);e.unbindFullscreenEvent=()=>{i(),r()};let o=t.renderTo[e.browserProps.requestFullscreen]();o&&o.catch(function(){alert("Full screen is not supported inside a frame.")})}})}setButtonText(){let e=this.chart,t=e.exporting?.divElements,n=e.options.exporting,i=n&&n.buttons&&n.buttons.contextButton.menuItems,r=e.options.lang;if(n?.menuItemDefinitions&&r?.exitFullscreen&&r.viewFullscreen&&i&&t){let e=t[i.indexOf("viewFullscreen")];e&&l().setElementHTML(e,this.isOpen?r.exitFullscreen:n.menuItemDefinitions.viewFullscreen?.text||r.viewFullscreen)}}toggle(){this.isOpen?this.close():this.open()}}let{win:C}=o(),O={ajax:function(e){let t={json:"application/json",xml:"application/xml",text:"text/plain",octet:"application/octet-stream"},i=new XMLHttpRequest;function r(t,n){e.error&&e.error(t,n)}if(!e.url)return!1;i.open((e.type||"get").toUpperCase(),e.url,!0),e.headers?.["Content-Type"]||i.setRequestHeader("Content-Type",t[e.dataType||"json"]||t.text),(0,n.objectEach)(e.headers,function(e,t){i.setRequestHeader(t,e)}),e.responseType&&(i.responseType=e.responseType),i.onreadystatechange=function(){let t;if(4===i.readyState){if(200===i.status){if("blob"!==e.responseType&&(t=i.responseText,"json"===e.dataType))try{t=JSON.parse(t)}catch(e){if(e instanceof Error)return r(i,e)}return e.success?.(t,i)}r(i,i.responseText)}},e.data&&"string"!=typeof e.data&&(e.data=JSON.stringify(e.data)),i.send(e.data)},getJSON:function(e,t){O.ajax({url:e,success:t,dataType:"json",headers:{"Content-Type":"text/plain"}})}};O.post=async function(e,t,i){let r=new C.FormData;(0,n.objectEach)(t,function(e,t){r.append(t,e)}),r.append("b64","true");let o=await C.fetch(e,{method:"POST",body:r,...i});if(o.ok){let e=await o.text(),i=document.createElement("a");i.href=`data:${t.type};base64,${e}`,i.download=t.filename,i.click(),(0,n.discardElement)(i)}};let{defaultOptions:T,setOptions:F}=o(),{composed:k,doc:R,isFirefox:N,isMS:A,isSafari:P,SVG_NS:M,win:D}=o();l().allowedAttributes.push("data-z-index","fill-opacity","filter","preserveAspectRatio","rx","ry","stroke-dasharray","stroke-linejoin","stroke-opacity","text-anchor","transform","transform-origin","version","viewBox","visibility","xmlns","xmlns:xlink"),l().allowedTags.push("desc","clippath","fedropshadow","femorphology","g","image");let L=D.URL||D.webkitURL||D;class I{constructor(e,t){this.options={},this.chart=e,this.options=t,this.btnCount=0,this.buttonOffset=0,this.divElements=[],this.svgElements=[]}static hyphenate(e){return e.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()})}static async imageToDataURL(e,t,n){let i=await I.loadImage(e),r=R.createElement("canvas"),o=r?.getContext("2d");if(o)return r.height=i.height*t,r.width=i.width*t,o.drawImage(i,0,0,r.width,r.height),r.toDataURL(n);throw Error("No canvas found!")}static async fetchCSS(e){try{let t=await fetch(e),n=await t.text(),i=new CSSStyleSheet;return i.replaceSync(n),i}catch{(0,n.error)(`Warning: Failed to fetch CSS from ${e}`,!1)}}static extractFontFamilies(e){return e?e.split(",").map(e=>e.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean):[]}static selectorAffectsSVG(e,t){try{if(t.matches(e))return!0;return!!t.querySelector(e)}catch{return!1}}static collectSVGInlineFonts(e,t){for(let n of[e,...Array.from(e.querySelectorAll("text, tspan"))]){let e=n.getAttribute("style")||"",i=n.getAttribute("font-family")||"";if(e.indexOf("font-family")>-1){let n=e.match(/font-family\s*:\s*([^;]+)/i);for(let e of I.extractFontFamilies(n?.[1]))t.add(e)}for(let e of I.extractFontFamilies(i))t.add(e)}}static async handleStyleSheet(e,t,n,i,r=new Set){let o=e.href;if(o){if(r.has(o))return;r.add(o)}try{for(let a of Array.from(e.cssRules)){if(a instanceof CSSImportRule)try{let e=await I.fetchCSS(a.href);e&&await I.handleStyleSheet(e,t,n,i,r)}catch{}if(a instanceof CSSStyleRule&&I.selectorAffectsSVG(a.selectorText,i))for(let e of I.extractFontFamilies(a.style.fontFamily))n.add(e);if(a instanceof CSSFontFaceRule){let e=a.cssText;if(o){let t=/url\(\s*(['"]?)(?![a-z]+:|\/\/)([^'")]+?)\1\s*\)/gi;e=e.replace(t,(e,t,n)=>{let i=new URL(n,o).href;return`url(${t}${i}${t})`})}t.push(e)}}}catch(e){if("SecurityError"===e.name&&o)try{let e=await I.fetchCSS(o);e&&await I.handleStyleSheet(e,t,n,i,r)}catch{}}}static async fetchStyleSheets(e){let t=[],n=new Set;for(let i of(I.collectSVGInlineFonts(e,n),Array.from(R.styleSheets)))await I.handleStyleSheet(i,t,n,e);return n.size?t.filter(e=>{let t=e.match(/font-family\s*:\s*([^;]+);?/i);return I.extractFontFamilies(t?.[1]).some(e=>n.has(e))}):t}static async inlineFonts(e){let t=await I.fetchStyleSheets(e),n=/url\(([^)]+)\)/g,i=[],r=t.join("\n"),o;for(;o=n.exec(r);){let e=o[1].replace(/['"]/g,"");i.includes(e)||i.push(e)}let a=e=>{let t="",n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)},l={};for(let e of i)try{let t=await fetch(e),n=t.headers.get("Content-Type")||"",i=a(await t.arrayBuffer());l[e]=`data:${n};base64,${i}`}catch{}r=r.replace(n,(e,t)=>{let n=t.replace(/['"]/g,"");return`url(${l[n]||n})`});let s=document.createElementNS("http://www.w3.org/2000/svg","style");return s.textContent=r,e.append(s),e}static loadImage(e){return new Promise((t,n)=>{let i=new D.Image;i.crossOrigin="Anonymous",i.onload=()=>{setTimeout(()=>{t(i)},I.loadEventDeferDelay)},i.onerror=e=>{n(e)},i.src=e})}static prepareImageOptions(e){let t=e?.type||"image/png",n=e?.libURL||T.exporting?.libURL;return{type:t,filename:(e?.filename||"chart")+"."+("image/svg+xml"===t?"svg":t.split("/")[1]),scale:e?.scale||1,libURL:n?.slice(-1)!=="/"?n+"/":n}}static sanitizeDOM(e){e.querySelectorAll("foreignObject").forEach(e=>{["width","height"].forEach(t=>{let n=e.getAttribute(t);n&&e.setAttribute(t,Math.ceil(1.15*parseInt(n,10)))})})}static sanitizeSVG(e,t){let n=e.lastIndexOf("</svg>");return n>-1&&(e=e.substr(0,n+6)),e=e.replace(/(<(?:img|br).*?(?=\>))>/g,"$1 />").replace(/(<svg(?![^>]*xmlns=)[^>]*)>/g,'$1 xmlns="http://www.w3.org/2000/svg">').replace(/zIndex="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery\d+="[^"]+"/g,"").replace(/url\(("|&quot;)(.*?)("|&quot;)\;?\)/g,"url($2)").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ (NS\d+\:)?href=/g," xlink:href=").replace(/(<image[^>]*) xlink:href=/g,"$1 href=").replace(/\n+/g," ").replace(/&nbsp;/g,"\xa0").replace(/&shy;/g,"\xad")}static svgToDataURL(e){let t=D.navigator.userAgent,n=t.indexOf("WebKit")>-1&&0>t.indexOf("Chrome");try{if(!n&&-1===e.indexOf("<foreignObject"))return L.createObjectURL(new D.Blob([e],{type:"image/svg+xml;charset-utf-16"}))}catch{}return"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(e)}addButton(e){let t,i=this,r=i.chart,o=r.renderer,a=(0,n.merge)(r.options.navigation?.buttonOptions,e),l=a.onclick,s=a.menuItems,c=a.symbolSize||12;if(!1===a.enabled||!a.theme)return;let h=r.styledMode?{}:a.theme,d=()=>{};l?d=function(e){e&&e.stopPropagation(),l.call(r,e,r)}:s&&(d=function(e){e&&e.stopPropagation(),i.contextMenu(p.menuClassName,s,p.translateX||0,p.translateY||0,p.width||0,p.height||0,p),p.setState(2)}),a.text&&a.symbol?h.paddingLeft=(0,n.pick)(h.paddingLeft,30):a.text||(0,n.extend)(h,{width:a.width,height:a.height,padding:0});let p=o.button(a.text||"",0,0,d,h,void 0,void 0,void 0,void 0,a.useHTML).addClass(e.className||"").attr({title:(0,n.pick)(r.options.lang[a._titleKey||a.titleKey],"")});p.menuClassName=e.menuClassName||"highcharts-menu-"+i.btnCount++,a.symbol&&(t=o.symbol(a.symbol,Math.round((a.symbolX||0)-c/2),Math.round((a.symbolY||0)-c/2),c,c,{width:c,height:c}).addClass("highcharts-button-symbol").attr({zIndex:1}).add(p),r.styledMode||t.attr({stroke:a.symbolStroke,fill:a.symbolFill,"stroke-width":a.symbolStrokeWidth||1})),p.add(i.group).align((0,n.extend)(a,{width:p.width,x:(0,n.pick)(a.x,i.buttonOffset)}),!0,"spacingBox"),i.buttonOffset+=((p.width||0)+(a.buttonSpacing||0))*("right"===a.align?-1:1),i.svgElements.push(p,t)}afterPrint(){let e=this.chart;if(!this.printReverseInfo)return;let{childNodes:t,origDisplay:i,resetParams:r}=this.printReverseInfo;this.moveContainers(e.renderTo),[].forEach.call(t,function(e,t){1===e.nodeType&&(e.style.display=i[t]||"")}),this.isPrinting=!1,r&&e.setSize.apply(e,r),delete this.printReverseInfo,I.printingChart=void 0,(0,n.fireEvent)(e,"afterPrint")}beforePrint(){let e=this.chart,t=R.body,i=this.options.printMaxWidth,r={childNodes:t.childNodes,origDisplay:[],resetParams:void 0};this.isPrinting=!0,e.pointer?.reset(void 0,0),(0,n.fireEvent)(e,"beforePrint"),i&&e.chartWidth>i&&(r.resetParams=[e.options.chart.width,void 0,!1],e.setSize(i,void 0,!1)),[].forEach.call(r.childNodes,function(e,t){1===e.nodeType&&(r.origDisplay[t]=e.style.display,e.style.display="none")}),this.moveContainers(t),this.printReverseInfo=r}contextMenu(e,t,i,r,o,a,s){let c=this,h=c.chart,d=h.options.navigation,{chartWidth:p,chartHeight:u}=h,g="cache-"+e,f=Math.max(o,a),m,y=h[g];y||(c.contextMenuEl=h[g]=y=(0,n.createElement)("div",{className:e},{position:"absolute",zIndex:1e3,padding:f+"px",pointerEvents:"auto",...h.renderer.style},h.scrollablePlotArea?.fixedDiv||h.container),m=(0,n.createElement)("ul",{className:"highcharts-menu"},h.styledMode?{}:{listStyle:"none",margin:0,padding:0},y),h.styledMode||(0,n.css)(m,(0,n.extend)({MozBoxShadow:"3px 3px 10px #0008",WebkitBoxShadow:"3px 3px 10px #0008",boxShadow:"3px 3px 10px #0008"},d?.menuStyle||{})),y.hideMenu=function(){(0,n.css)(y,{display:"none"}),s&&s.setState(0),h.exporting&&(h.exporting.openMenu=!1),(0,n.css)(h.renderTo,{overflow:"hidden"}),(0,n.css)(h.container,{overflow:"hidden"}),(0,n.internalClearTimeout)(y.hideTimer),(0,n.fireEvent)(h,"exportMenuHidden")},c.events?.push((0,n.addEvent)(y,"mouseleave",function(){y.hideTimer=D.setTimeout(y.hideMenu,500)}),(0,n.addEvent)(y,"mouseenter",function(){(0,n.internalClearTimeout)(y.hideTimer)}),(0,n.addEvent)(R,"mouseup",function(t){h.pointer?.inClass(t.target,e)||y.hideMenu()}),(0,n.addEvent)(y,"click",function(){h.exporting?.openMenu&&y.hideMenu()})),t.forEach(function(e){if("string"==typeof e&&c.options.menuItemDefinitions?.[e]&&(e=c.options.menuItemDefinitions[e]),(0,n.isObject)(e,!0)){let t;e.separator?(t=(0,n.createElement)("li",{className:"highcharts-menu-item highcharts-separator",role:"separator"},void 0,m),h.styledMode||(0,n.css)(t,{border:"none",backgroundColor:"var(--highcharts-neutral-color-40)",height:"0.5px",margin:"10px 0",padding:0,listStyle:"none","pointer-events":"none"})):("viewData"===e.textKey&&c.isDataTableVisible&&(e.textKey="hideData"),t=(0,n.createElement)("li",{className:"highcharts-menu-item",onclick:function(t){t&&t.stopPropagation(),y.hideMenu(),"string"!=typeof e&&e.onclick&&e.onclick.apply(h,arguments)}},void 0,m),l().setElementHTML(t,e.text||h.options.lang[e.textKey]),h.styledMode||(t.onmouseover=function(){(0,n.css)(this,d?.menuItemHoverStyle||{})},t.onmouseout=function(){(0,n.css)(this,d?.menuItemStyle||{})},(0,n.css)(t,(0,n.extend)({cursor:"pointer"},d?.menuItemStyle||{})))),c.divElements.push(t)}}),c.divElements.push(m,y),c.menuHeight=y.offsetHeight,c.menuWidth=y.offsetWidth);let x={display:"block"};i+(c.menuWidth||0)>p?x.right=p-i-o-f+"px":x.left=i-f+"px",r+a+(c.menuHeight||0)>u&&s.alignOptions?.verticalAlign!=="top"?x.bottom=u-r-f+"px":x.top=r+a-f+"px",(0,n.css)(y,x),(0,n.css)(h.renderTo,{overflow:""}),(0,n.css)(h.container,{overflow:""}),h.exporting&&(h.exporting.openMenu=!0),(0,n.fireEvent)(h,"exportMenuShown")}destroy(e){let t,i=e?e.target:this.chart,{divElements:r,events:o,svgElements:a}=this;a.forEach((e,n)=>{e&&(e.onclick=e.ontouchstart=null,i[t="cache-"+e.menuClassName]&&delete i[t],a[n]=e.destroy())}),a.length=0,this.group&&(this.group.destroy(),delete this.group),r.forEach(function(e,t){e&&((0,n.internalClearTimeout)(e.hideTimer),(0,n.removeEvent)(e,"mouseleave"),r[t]=e.onmouseout=e.onmouseover=e.ontouchstart=e.onclick=null,(0,n.discardElement)(e))}),r.length=0,o&&(o.forEach(function(e){e()}),o.length=0)}async downloadSVG(e,t){let i,r={svg:e,exportingOptions:t,exporting:this};if((0,n.fireEvent)(I.prototype,"downloadSVG",r),r.defaultPrevented)return;let{type:o,filename:a,scale:l,libURL:s}=I.prepareImageOptions(t);if("application/pdf"===o)throw Error("Offline exporting logic for PDF type is not found.");if("image/svg+xml"===o){if(void 0!==D.MSBlobBuilder){let t=new D.MSBlobBuilder;t.append(e),i=t.getBlob("image/svg+xml")}else i=I.svgToDataURL(e);y(i,a)}else{i=I.svgToDataURL(e);try{I.objectURLRevoke=!0;let e=await I.imageToDataURL(i,l,o);y(e,a)}catch(d){if("No canvas found!"===d.message)throw d;if(e.length>1e8)throw Error("Input too long");let t=R.createElement("canvas"),i=t.getContext("2d"),r=e.match(/^<svg[^>]*\s{,1000}width\s{,1000}=\s{,1000}\"?(\d+)\"?[^>]*>/),h=e.match(/^<svg[^>]*\s{0,1000}height\s{,1000}=\s{,1000}\"?(\d+)\"?[^>]*>/);if(i&&r&&h){let d=r[1]*l,p=h[1]*l;if(t.width=d,t.height=p,!D.canvg){var c;if(!s)throw Error("Image export requires canvg. Set exporting.libURL or preload canvg.");I.objectURLRevoke=!0,await (c=s+"canvg.js",new Promise((e,t)=>{let i=f.getElementsByTagName("head")[0],r=f.createElement("script");r.type="text/javascript",r.src=c,r.onload=()=>{e()},r.onerror=()=>{let e=`Error loading script ${c}`;(0,n.error)(e),t(Error(e))},i.appendChild(r)}))}D.canvg.Canvg.fromString(i,e).start(),y(D.navigator.msSaveOrOpenBlob?t.msToBlob():t.toDataURL(o),a)}}finally{if(I.objectURLRevoke)try{L.revokeObjectURL(i)}catch{}}}}async exportChart(e,t){if((e=(0,n.merge)(this.options,e)).local)await this.localExport(e,t||{});else{let n=await this.getSVGForExport(e,t);e.url&&await O.post(e.url,{filename:e.filename?e.filename.replace(/\//g,"-"):this.getFilename(),type:e.type,width:e.width,scale:e.scale,svg:n},e.fetchOptions)}}async fallbackToServer(e,t){!1===e.fallbackToExportServer?e.error?e.error(e,t):(0,n.error)(t?.message||28,!0,this.chart):"application/pdf"===e.type?(e.local=!1,await this.exportChart(e)):(0,n.error)(t.message,!1)}getChartHTML(e){let t=this.chart;return e&&this.inlineStyles(),this.resolveCSSVariables(),I.sanitizeDOM(t.renderer.box),t.container.querySelectorAll("canvas").forEach(function(e){let i=e.toDataURL("image/png"),r=e.parentNode,o=t.renderer.image(i,0,0,e.width,e.height);(0,n.css)(o.element,{width:e.style.width,height:e.style.height}),r.parentNode.insertBefore(o.element,r),r.remove()}),t.container.innerHTML}getFilename(){let e=this.chart.userOptions.title?.text,t=this.options.filename;return t?t.replace(/\//g,"-"):("string"==typeof e&&(t=e.toLowerCase().replace(/<\/?[^>]+(>|$)/g,"").replace(/[\s_]+/g,"-").replace(/[^a-z\d\-]/g,"").replace(/^[\-]+/g,"").replace(/[\-]+/g,"-").substr(0,24).replace(/[\-]+$/g,"")),(!t||t.length<5)&&(t="chart"),t)}getSVG(e,t){let i=this.chart,r,o,a=(0,n.merge)(i.options,e);a.plotOptions=(0,n.merge)(i.userOptions.plotOptions,e?.plotOptions),a.time=(0,n.merge)(i.userOptions.time,e?.time);let l=(0,n.createElement)("div",void 0,{position:"absolute",top:"-9999em",width:i.chartWidth+"px",height:i.chartHeight+"px"},R.body),s=i.renderTo.style.width,c=i.renderTo.style.height,h=a.exporting?.sourceWidth||a.chart.width||/px$/.test(s)&&parseInt(s,10)||(a.isGantt?800:600),d=a.exporting?.sourceHeight||a.chart.height||/px$/.test(c)&&parseInt(c,10)||400;(0,n.extend)(a.chart,{animation:!1,renderTo:l,forExport:!0,renderer:"SVGRenderer",width:h,height:d}),a.exporting&&(a.exporting.enabled=!1),delete a.data,a.series=[],i.series.forEach(function(e){(o=(0,n.merge)(e.userOptions,{animation:!1,enableMouseTracking:!1,showCheckbox:!1,visible:e.visible})).isInternal||a?.series?.push(o)});let p={};i.axes.forEach(function(e){e.userOptions.internalKey||(e.userOptions.internalKey=(0,n.uniqueKey)()),a&&!e.options.isInternal&&(p[e.coll]||(p[e.coll]=!0,a[e.coll]=[]),a[e.coll].push((0,n.merge)(e.userOptions,{visible:e.visible,type:e.type,uniqueNames:e.uniqueNames})))}),a.colorAxis=i.userOptions.colorAxis;let u=t=>{e&&["xAxis","yAxis","series"].forEach(function(n){e[n]&&t.update({[n]:e[n]})}),i.axes.forEach(function(i){let r=(0,n.find)(t.axes,e=>e.options.internalKey===i.userOptions.internalKey);if(r){let t=i.getExtremes(),o=(0,n.splat)(e?.[i.coll]||{})[0],a="min"in o?o.min:t.userMin,l="max"in o?o.max:t.userMax;(void 0!==a&&a!==r.min||void 0!==l&&l!==r.max)&&r.setExtremes(a??void 0,l??void 0,!0,!1)}});let o=t.exporting;return o?.options.applyStyleSheets&&this.applyShadowDOMStyles(t),(0,n.fireEvent)(i,"getSVG",{chartCopy:t}),r=o?.getChartHTML(i.styledMode||a?.exporting?.applyStyleSheets)||"",r=I.sanitizeSVG(r,a),(0,n.fireEvent)(i,"afterGetSVG",{chartCopy:t,svg:r}),a=void 0,t.destroy(),(0,n.discardElement)(l),r};return t?new Promise(e=>new i.constructor(a||{},function(t){i.callback?.call(this,t);let r=(0,n.addEvent)(this,"render",function(){r(),e(u(this))})})):u(new i.constructor(a,i.callback))}applyShadowDOMStyles(e){let t=this.chart,i=[],r=t.container,o;for(;r&&(!(o=r.getRootNode())||"object"!=typeof o.host);)r=r.parentNode,o=null;o?.querySelectorAll("style").forEach(t=>{let n=t.cloneNode(!0);e.renderer.defs.element.appendChild(n),i.push(n)}),(0,n.addEvent)(t,"afterGetSVG",()=>{i.forEach(e=>{e.remove()})})}async getSVGForExport(e,t){let i=this.options;return await this.getSVG((0,n.merge)({chart:{borderRadius:0}},i.chartOptions,t,{exporting:{sourceWidth:e?.sourceWidth||i.sourceWidth,sourceHeight:e?.sourceHeight||i.sourceHeight}}),!0)}inlineStyles(){let e,t=I.inlineDenylist,i=I.inlineAllowlist,r={},o=(0,n.createElement)("iframe",void 0,{width:"1px",height:"1px",visibility:"hidden"},R.body),a=o.contentWindow?.document;a&&a.body.appendChild(a.createElementNS(M,"svg")),!function o(l){let s,c,h,d,p,u,g={};if(a&&1===l.nodeType&&-1===I.unstyledElements.indexOf(l.nodeName)){if(s=D.getComputedStyle(l,null),c="svg"===l.nodeName?{}:D.getComputedStyle(l.parentNode,null),!r[l.nodeName]){e=a.getElementsByTagName("svg")[0],h=a.createElementNS(l.namespaceURI,l.nodeName),e.appendChild(h);let t=D.getComputedStyle(h,null),n={};for(let e in t)e.length<1e3&&"string"==typeof t[e]&&!/^\d+$/.test(e)&&(n[e]=t[e]);r[l.nodeName]=n,"text"===l.nodeName&&delete r.text.fill,e.removeChild(h)}for(let e in s)(N||A||P||Object.hasOwnProperty.call(s,e))&&function(e,n){if(d=p=!1,i.length){for(u=i.length;u--&&!p;)p=i[u].test(n);d=!p}for("transform"===n&&"none"===e&&(d=!0),u=t.length;u--&&!d;){if(n.length>1e3)throw Error("Input too long");d=t[u].test(n)||"function"==typeof e}!d&&(c[n]!==e||"svg"===l.nodeName)&&r[l.nodeName][n]!==e&&(I.inlineToAttributes&&-1===I.inlineToAttributes.indexOf(n)?g[n]=e:e&&l.setAttribute(I.hyphenate(n),e))}(s[e],e);if((0,n.css)(l,g),"svg"===l.nodeName&&l.setAttribute("stroke-width","1px"),"text"===l.nodeName)return;[].forEach.call(l.children||l.childNodes,o)}}(this.chart.container.querySelector("svg")),e.parentNode.removeChild(e),o.parentNode.removeChild(o)}async localExport(e,t){let i=this.chart,r,o,a=null,l;if(A&&i.styledMode&&!I.inlineAllowlist.length&&I.inlineAllowlist.push(/^blockSize/,/^border/,/^caretColor/,/^color/,/^columnRule/,/^columnRuleColor/,/^cssFloat/,/^cursor/,/^fill$/,/^fillOpacity/,/^font/,/^inlineSize/,/^length/,/^lineHeight/,/^opacity/,/^outline/,/^parentRule/,/^rx$/,/^ry$/,/^stroke/,/^textAlign/,/^textAnchor/,/^textDecoration/,/^transform/,/^vectorEffect/,/^visibility/,/^x$/,/^y$/),A&&("application/pdf"===e.type||i.container.getElementsByTagName("image").length&&"image/svg+xml"!==e.type)||"application/pdf"===e.type&&[].some.call(i.container.getElementsByTagName("image"),function(e){let t=e.getAttribute("href");return""!==t&&"string"==typeof t&&0!==t.indexOf("data:")}))return void await this.fallbackToServer(e,Error("Image type not supported for this chart/browser."));let s=(0,n.addEvent)(i,"afterGetSVG",e=>{o=e.chartCopy.options,l=(r=e.chartCopy.container.cloneNode(!0))&&r.getElementsByTagName("image")||[]});try{let i;for(let n of(await this.getSVGForExport(e,t),l?Array.from(l):[]))if(a=n.getAttributeNS("http://www.w3.org/1999/xlink","href")){I.objectURLRevoke=!1;let t=await I.imageToDataURL(a,e?.scale||1,e?.type||"image/png");n.setAttributeNS("http://www.w3.org/1999/xlink","href",t)}else n.parentNode.removeChild(n);let s=r?.querySelector("svg");s&&!e.chartOptions?.chart?.style?.fontFamily&&await I.inlineFonts(s);let c=(i=r?.innerHTML,I.sanitizeSVG(i||"",o));if(c.indexOf("<foreignObject")>-1&&"image/svg+xml"!==e.type&&(A||"application/pdf"===e.type))throw Error("Image type not supported for charts with embedded HTML");return await this.downloadSVG(c,(0,n.extend)({filename:this.getFilename()},e)),c}catch(t){await this.fallbackToServer(e,t)}finally{s()}}moveContainers(e){let t=this.chart,{scrollablePlotArea:n}=t;(n?[n.fixedDiv,n.scrollingContainer]:[t.container]).forEach(function(t){e.appendChild(t)})}print(){let e=this.chart;this.isPrinting||(I.printingChart=e,P||this.beforePrint(),setTimeout(()=>{D.focus(),D.print(),P||setTimeout(()=>{e.exporting?.afterPrint()},1e3)},1))}render(){let e=this,{chart:t,options:i}=e,r=e?.isDirty||!e?.svgElements.length;e.buttonOffset=0,e.isDirty&&e.destroy(),r&&!1!==i.enabled&&(e.events=[],e.group||(e.group=t.renderer.g("exporting-group").attr({zIndex:3}).add()),(0,n.objectEach)(i?.buttons,function(t){e.addButton(t)}),e.isDirty=!1)}resolveCSSVariables(){Array.from(this.chart.container.querySelectorAll("*")).forEach(e=>{["color","fill","stop-color","stroke"].forEach(t=>{let n=e.getAttribute(t);n?.includes("var(")&&e.setAttribute(t,getComputedStyle(e).getPropertyValue(t));let i=e.style?.[t];i?.includes("var(")&&(e.style[t]=getComputedStyle(e).getPropertyValue(t))})})}update(e,t){this.isDirty=!0,(0,n.merge)(!0,this.options,e),(0,n.pick)(t,!0)&&this.chart.redraw()}}I.inlineAllowlist=[],I.inlineDenylist=[/-/,/^(clipPath|cssText|d|height|width)$/,/^font$/,/[lL]ogical(Width|Height)$/,/^parentRule$/,/^(cssRules|ownerRules)$/,/perspective/,/TapHighlightColor/,/^transition/,/^length$/,/^\d+$/],I.inlineToAttributes=["fill","stroke","strokeLinecap","strokeLinejoin","strokeWidth","textAnchor","x","y"],I.loadEventDeferDelay=150*!!A,I.unstyledElements=["clipPath","defs","desc"],function(e){function t(e){let t=e.exporting;t&&(t.render(),(0,n.addEvent)(e,"redraw",function(){this.exporting?.render()}),(0,n.addEvent)(e,"destroy",function(){this.exporting?.destroy()}))}function i(){let t=this;t.options.exporting&&(t.exporting=new e(t,t.options.exporting),p.compose(t).navigation.addUpdate((e,i)=>{t.exporting&&(t.exporting.isDirty=!0,(0,n.merge)(!0,t.options.navigation,e),(0,n.pick)(i,!0)&&t.redraw())}))}function r({alignTo:e,key:t,textPxLength:i}){let r=this.options.exporting,{align:o,buttonSpacing:a=0,verticalAlign:l,width:s=0}=(0,n.merge)(this.options.navigation?.buttonOptions,r?.buttons?.contextButton),c=e.width-i,h=s+a;(r?.enabled??!0)&&"title"===t&&"right"===o&&"top"===l&&c<2*h&&(c<h?e.width-=h:this.title?.alignValue!=="left"&&(e.x-=h-c/2))}e.compose=function(o,a){w.compose(a),E.compose(o),(0,n.pushUnique)(k,"Exporting")&&((0,n.extend)(c().prototype,{exportChart:async function(e,t){await this.exporting?.exportChart(e,t)},getChartHTML:function(e){return this.exporting?.getChartHTML(e)},getFilename:function(){return this.exporting?.getFilename()},getSVG:function(e){return this.exporting?.getSVG(e,!1)},print:function(){return this.exporting?.print()}}),o.prototype.callbacks.push(t),(0,n.addEvent)(o,"afterInit",i),(0,n.addEvent)(o,"layOutTitle",r),P&&D.matchMedia("print").addListener(function(t){e.printingChart&&(t.matches?e.printingChart.exporting?.beforePrint():e.printingChart.exporting?.afterPrint())}),F(v))}}(I||(I={}));let U=o();U.Exporting=I,U.HttpUtilities=U.HttpUtilities||O,U.ajax=U.HttpUtilities.ajax,U.getJSON=U.HttpUtilities.getJSON,U.post=U.HttpUtilities.post,I.compose(U.Chart,U.Renderer);let G=o();export{G as default};