"use strict";var resvg=(()=>{var O=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},L=(e,t,n,_)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of U(t))!M.call(e,i)&&i!==n&&O(e,i,{get:()=>t[i],enumerable:!(_=j(t,i))||_.enumerable});return e};var D=e=>L(O({},"__esModule",{value:!0}),e);var Y={};C(Y,{Resvg:()=>Q,initWasm:()=>K});var r,w=new Array(128).fill(void 0);w.push(void 0,null,!0,!1);var h=w.length;function c(e){h===w.length&&w.push(w.length+1);let t=h;return h=w[t],w[t]=e,t}function a(e){return w[e]}function P(e){e<132||(w[e]=h,h=e)}function f(e){let t=a(e);return P(e),t}var m=0,l=null;function x(){return(l===null||l.byteLength===0)&&(l=new Uint8Array(r.memory.buffer)),l}var F=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},N=typeof F.encodeInto=="function"?function(e,t){return F.encodeInto(e,t)}:function(e,t){let n=F.encode(e);return t.set(n),{read:e.length,written:n.length}};function B(e,t,n){if(n===void 0){let b=F.encode(e),u=t(b.length,1)>>>0;return x().subarray(u,u+b.length).set(b),m=b.length,u}let _=e.length,i=t(_,1)>>>0,g=x(),o=0;for(;o<_;o++){let b=e.charCodeAt(o);if(b>127)break;g[i+o]=b}if(o!==_){o!==0&&(e=e.slice(o)),i=n(i,_,_=o+e.length*3,1)>>>0;let b=x().subarray(i+o,i+_),u=N(e,b);o+=u.written,i=n(i,_,o,1)>>>0}return m=o,i}function d(e){return e==null}var p=null;function s(){return(p===null||p.byteLength===0)&&(p=new Int32Array(r.memory.buffer)),p}var T=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&T.decode();function R(e,t){return e=e>>>0,T.decode(x().subarray(e,e+t))}function J(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`);return e.ptr}function q(e,t){try{return e.apply(this,t)}catch(n){r.__wbindgen_exn_store(c(n))}}var k=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>r.__wbg_bbox_free(e>>>0)),y=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,k.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,k.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_bbox_free(t)}get x(){return r.__wbg_get_bbox_x(this.__wbg_ptr)}set x(t){r.__wbg_set_bbox_x(this.__wbg_ptr,t)}get y(){return r.__wbg_get_bbox_y(this.__wbg_ptr)}set y(t){r.__wbg_set_bbox_y(this.__wbg_ptr,t)}get width(){return r.__wbg_get_bbox_width(this.__wbg_ptr)}set width(t){r.__wbg_set_bbox_width(this.__wbg_ptr,t)}get height(){return r.__wbg_get_bbox_height(this.__wbg_ptr)}set height(t){r.__wbg_set_bbox_height(this.__wbg_ptr,t)}},E=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>r.__wbg_renderedimage_free(e>>>0)),W=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,E.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,E.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_renderedimage_free(t)}get width(){return r.renderedimage_width(this.__wbg_ptr)>>>0}get height(){return r.renderedimage_height(this.__wbg_ptr)>>>0}asPng(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.renderedimage_asPng(i,this.__wbg_ptr);var t=s()[i/4+0],n=s()[i/4+1],_=s()[i/4+2];if(_)throw f(n);return f(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}get pixels(){let t=r.renderedimage_pixels(this.__wbg_ptr);return f(t)}},H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>r.__wbg_resvg_free(e>>>0)),A=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_resvg_free(t)}constructor(t,n,_){try{let v=r.__wbindgen_add_to_stack_pointer(-16);var i=d(n)?0:B(n,r.__wbindgen_malloc,r.__wbindgen_realloc),g=m;r.resvg_new(v,c(t),i,g,d(_)?0:c(_));var o=s()[v/4+0],b=s()[v/4+1],u=s()[v/4+2];if(u)throw f(b);return this.__wbg_ptr=o>>>0,this}finally{r.__wbindgen_add_to_stack_pointer(16)}}get width(){return r.resvg_width(this.__wbg_ptr)}get height(){return r.resvg_height(this.__wbg_ptr)}render(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_render(i,this.__wbg_ptr);var t=s()[i/4+0],n=s()[i/4+1],_=s()[i/4+2];if(_)throw f(n);return W.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}toString(){let t,n;try{let g=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_toString(g,this.__wbg_ptr);var _=s()[g/4+0],i=s()[g/4+1];return t=_,n=i,R(_,i)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,n,1)}}innerBBox(){let t=r.resvg_innerBBox(this.__wbg_ptr);return t===0?void 0:y.__wrap(t)}getBBox(){let t=r.resvg_getBBox(this.__wbg_ptr);return t===0?void 0:y.__wrap(t)}cropByBBox(t,n,_){J(t,y),r.resvg_cropByBBox(this.__wbg_ptr,t.__wbg_ptr,!d(n),d(n)?0:n,d(_)?16777215:_?1:0)}imagesToResolve(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_imagesToResolve(i,this.__wbg_ptr);var t=s()[i/4+0],n=s()[i/4+1],_=s()[i/4+2];if(_)throw f(n);return f(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}resolveImage(t,n){try{let g=r.__wbindgen_add_to_stack_pointer(-16),o=B(t,r.__wbindgen_malloc,r.__wbindgen_realloc),b=m;r.resvg_resolveImage(g,this.__wbg_ptr,o,b,c(n));var _=s()[g/4+0],i=s()[g/4+1];if(i)throw f(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}};async function V(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(_){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",_);else throw _}let n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}function $(){let e={};return e.wbg={},e.wbg.__wbindgen_memory=function(){let t=r.memory;return c(t)},e.wbg.__wbg_buffer_12d079cc21e14bdb=function(t){let n=a(t).buffer;return c(n)},e.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(t,n,_){let i=new Uint8Array(a(t),n>>>0,_>>>0);return c(i)},e.wbg.__wbindgen_object_drop_ref=function(t){f(t)},e.wbg.__wbg_new_63b92bc8671ed464=function(t){let n=new Uint8Array(a(t));return c(n)},e.wbg.__wbg_new_28c511d9baebfa89=function(t,n){let _=new Error(R(t,n));return c(_)},e.wbg.__wbg_values_839f3396d5aac002=function(t){let n=a(t).values();return c(n)},e.wbg.__wbg_next_196c84450b364254=function(){return q(function(t){let n=a(t).next();return c(n)},arguments)},e.wbg.__wbg_done_298b57d23c0fc80c=function(t){return a(t).done},e.wbg.__wbg_value_d93c65011f51a456=function(t){let n=a(t).value;return c(n)},e.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6=function(t){let n;try{n=a(t)instanceof Uint8Array}catch{n=!1}return n},e.wbg.__wbindgen_string_get=function(t,n){let _=a(n),i=typeof _=="string"?_:void 0;var g=d(i)?0:B(i,r.__wbindgen_malloc,r.__wbindgen_realloc),o=m;s()[t/4+1]=o,s()[t/4+0]=g},e.wbg.__wbg_new_16b304a2cfa7ff4a=function(){let t=new Array;return c(t)},e.wbg.__wbindgen_string_new=function(t,n){let _=R(t,n);return c(_)},e.wbg.__wbg_push_a5b05aedc7234f9f=function(t,n){return a(t).push(a(n))},e.wbg.__wbg_length_c20a40f15020d68a=function(t){return a(t).length},e.wbg.__wbg_set_a47bac70306a19a7=function(t,n,_){a(t).set(a(n),_>>>0)},e.wbg.__wbindgen_throw=function(t,n){throw new Error(R(t,n))},e}function G(e,t){return r=e.exports,z.__wbindgen_wasm_module=t,p=null,l=null,r}async function z(e){if(r!==void 0)return r;typeof e>"u"&&(e=new URL("index_bg.wasm",void 0));let t=$();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:_}=await V(await e,t);return G(n,_)}var S=z;var I=!1,K=async e=>{if(I)throw new Error("Already initialized. The `initWasm()` function can be used only once.");await S(await e),I=!0},Q=class extends A{constructor(e,t){if(!I)throw new Error("Wasm has not been initialized. Call `initWasm()` function.");let n=t?.font;if(n&&X(n)){let _={...t,font:{...n,fontBuffers:void 0}};super(e,JSON.stringify(_),n.fontBuffers)}else super(e,JSON.stringify(t))}};function X(e){return Object.prototype.hasOwnProperty.call(e,"fontBuffers")}return D(Y);})();