md2x 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -23
- package/dist/chunks/chunk-Q6QMPHEY.js +1552 -0
- package/dist/chunks/chunk-UZ7TETMS.js +415 -0
- package/dist/chunks/docx-exporter-GL6CNCQD.js +1 -0
- package/dist/chunks/mcp-server-4TPUOZXJ.js +49 -0
- package/dist/core-worker.js +1764 -0
- package/dist/index.js +1 -1
- package/dist/md2x.js +8 -5
- package/dist/renderer/core-worker-browser.js +1775 -0
- package/dist/renderer/live-runtime-canvas.js +1 -1
- package/dist/renderer/live-runtime-dot.js +1 -1
- package/dist/renderer/live-runtime-html.js +1 -1
- package/dist/renderer/live-runtime-infographic.js +1 -1
- package/dist/renderer/live-runtime-md2x.js +4 -4
- package/dist/renderer/live-runtime-mermaid.js +1 -1
- package/dist/renderer/live-runtime-svg.js +1 -1
- package/dist/renderer/live-runtime-vega.js +1 -1
- package/dist/types/node/src/host/browser-renderer.d.ts +1 -175
- package/dist/types/node/src/host/core.d.ts +59 -0
- package/dist/types/node/src/host/index.d.ts +4 -49
- package/dist/types/node/src/host/node-exporter.d.ts +1 -90
- package/dist/types/node/src/host/node-platform.d.ts +1 -23
- package/dist/types/node/src/host/templates-data.d.ts +5 -0
- package/dist/types/node/src/host/themes-data.d.ts +2385 -0
- package/dist/types/node/src/host/types.d.ts +251 -0
- package/dist/types/node/src/index.d.ts +2 -3
- package/package.json +13 -3
- package/dist/chunks/chunk-2LPNL4GA.js +0 -1
- package/dist/chunks/chunk-3P5X57NT.js +0 -262
- package/dist/chunks/chunk-3VL755NO.js +0 -1
- package/dist/chunks/chunk-5DPTQTJJ.js +0 -1
- package/dist/chunks/chunk-AK6TXLWO.js +0 -1
- package/dist/chunks/chunk-CN4F5HOV.js +0 -5
- package/dist/chunks/chunk-CVKZIRZW.js +0 -5
- package/dist/chunks/chunk-DFROP2PD.js +0 -11
- package/dist/chunks/chunk-DJGIYXVP.js +0 -3
- package/dist/chunks/chunk-EFKQH5UR.js +0 -108
- package/dist/chunks/chunk-FXZD57XY.js +0 -532
- package/dist/chunks/chunk-IENSDROB.js +0 -1
- package/dist/chunks/chunk-LLCWR7UA.js +0 -1
- package/dist/chunks/chunk-MHCTK6WW.js +0 -1
- package/dist/chunks/chunk-NM6J3ND7.js +0 -1
- package/dist/chunks/chunk-PARPCLXM.js +0 -1
- package/dist/chunks/chunk-PUOHPY5L.js +0 -16
- package/dist/chunks/chunk-R65AQGTF.js +0 -1
- package/dist/chunks/chunk-R6G2575A.js +0 -3
- package/dist/chunks/chunk-TRGQPVRY.js +0 -2
- package/dist/chunks/chunk-URO5RPHJ.js +0 -9
- package/dist/chunks/chunk-YFL3W3OS.js +0 -1
- package/dist/chunks/chunk-Z4LVGK7Y.js +0 -1
- package/dist/chunks/docx-exporter-ZZ76JXFU.js +0 -1
- package/dist/chunks/rehype-highlight-Y4Q4RX67.js +0 -1
- package/dist/chunks/rehype-katex-FXTCTSUE.js +0 -1
- package/dist/chunks/rehype-stringify-4CQSSRDL.js +0 -1
- package/dist/chunks/remark-gfm-BUZ4SLP3.js +0 -1
- package/dist/chunks/remark-math-HEZQAPFK.js +0 -1
- package/dist/chunks/remark-parse-QC7TSXTK.js +0 -1
- package/dist/chunks/remark-rehype-C2LX643P.js +0 -1
- package/dist/chunks/remark-super-sub-EP2AQS54.js +0 -1
- package/dist/chunks/theme-manager-AZBU2SLL.js +0 -1
- package/dist/chunks/theme-to-css-GLV3WYDU.js +0 -85
- package/dist/chunks/unified-PU53JLVJ.js +0 -1
- package/dist/chunks/unist-util-visit-SBSD62C6.js +0 -1
- package/dist/templates/html/example.html +0 -35
- package/dist/templates/svelte/example.svelte +0 -18
- package/dist/templates/vue/PrinterComponent.vue +0 -875
- package/dist/templates/vue/example.vue +0 -17
- package/dist/templates/vue/mapLibre.vue +0 -371
- package/dist/themes/code-themes/business-contrast.json +0 -31
- package/dist/themes/code-themes/colorful.json +0 -32
- package/dist/themes/code-themes/cool-modern.json +0 -31
- package/dist/themes/code-themes/high-contrast.json +0 -31
- package/dist/themes/code-themes/light-clean.json +0 -31
- package/dist/themes/code-themes/warm-book.json +0 -31
- package/dist/themes/color-schemes/candy.json +0 -34
- package/dist/themes/color-schemes/cool.json +0 -34
- package/dist/themes/color-schemes/coral.json +0 -34
- package/dist/themes/color-schemes/dino.json +0 -34
- package/dist/themes/color-schemes/forest.json +0 -34
- package/dist/themes/color-schemes/garden.json +0 -34
- package/dist/themes/color-schemes/neutral.json +0 -34
- package/dist/themes/color-schemes/ocean.json +0 -34
- package/dist/themes/color-schemes/rainbow.json +0 -43
- package/dist/themes/color-schemes/sakura.json +0 -34
- package/dist/themes/color-schemes/sepia.json +0 -34
- package/dist/themes/color-schemes/space.json +0 -34
- package/dist/themes/color-schemes/starry.json +0 -34
- package/dist/themes/color-schemes/sunset.json +0 -34
- package/dist/themes/color-schemes/warm.json +0 -34
- package/dist/themes/font-config.json +0 -184
- package/dist/themes/layout-schemes/academic.json +0 -40
- package/dist/themes/layout-schemes/book.json +0 -40
- package/dist/themes/layout-schemes/document.json +0 -40
- package/dist/themes/layout-schemes/magazine.json +0 -40
- package/dist/themes/layout-schemes/student.json +0 -40
- package/dist/themes/layout-schemes/technical.json +0 -40
- package/dist/themes/presets/academic.json +0 -24
- package/dist/themes/presets/business.json +0 -22
- package/dist/themes/presets/candy.json +0 -23
- package/dist/themes/presets/century.json +0 -22
- package/dist/themes/presets/coral.json +0 -22
- package/dist/themes/presets/default.json +0 -22
- package/dist/themes/presets/dinosaur.json +0 -23
- package/dist/themes/presets/elegant.json +0 -22
- package/dist/themes/presets/forest.json +0 -22
- package/dist/themes/presets/garamond.json +0 -22
- package/dist/themes/presets/garden.json +0 -23
- package/dist/themes/presets/handwritten.json +0 -23
- package/dist/themes/presets/heiti.json +0 -22
- package/dist/themes/presets/magazine.json +0 -24
- package/dist/themes/presets/manuscript.json +0 -22
- package/dist/themes/presets/minimal.json +0 -22
- package/dist/themes/presets/mixed.json +0 -24
- package/dist/themes/presets/newspaper.json +0 -24
- package/dist/themes/presets/ocean.json +0 -22
- package/dist/themes/presets/palatino.json +0 -22
- package/dist/themes/presets/rainbow.json +0 -23
- package/dist/themes/presets/space.json +0 -23
- package/dist/themes/presets/starry.json +0 -23
- package/dist/themes/presets/sunset.json +0 -22
- package/dist/themes/presets/swiss.json +0 -22
- package/dist/themes/presets/technical.json +0 -22
- package/dist/themes/presets/typewriter.json +0 -23
- package/dist/themes/presets/verdana.json +0 -22
- package/dist/themes/presets/water.json +0 -22
- package/dist/themes/registry.json +0 -270
- package/dist/themes/table-styles/academic.json +0 -30
- package/dist/themes/table-styles/borderless.json +0 -26
- package/dist/themes/table-styles/compact.json +0 -24
- package/dist/themes/table-styles/grid.json +0 -22
- package/dist/themes/table-styles/high-contrast.json +0 -22
- package/dist/themes/table-styles/minimal-gray.json +0 -26
- package/dist/themes/table-styles/modern-tech.json +0 -34
- package/dist/themes/table-styles/professional.json +0 -34
- package/dist/themes/table-styles/zebra.json +0 -22
- package/dist/types/src/utils/theme-to-css.d.ts +0 -171
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";(()=>{var Ze=Object.create;var Be=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var nt=(r,e)=>()=>(r&&(e=r(r=0)),e);var le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var it=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of et(e))!rt.call(r,i)&&i!==t&&Be(r,i,{get:()=>e[i],enumerable:!(n=Qe(e,i))||n.enumerable});return r};var ot=(r,e,t)=>(t=r!=null?Ze(tt(r)):{},it(e||!r||!r.__esModule?Be(t,"default",{value:r,enumerable:!0}):t,r));var Se=le(ee=>{"use strict";x();ee.byteLength=at;ee.toByteArray=ct;ee.fromByteArray=ft;var _=[],L=[],st=typeof Uint8Array<"u"?Uint8Array:Array,ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(j=0,Te=ce.length;j<Te;++j)_[j]=ce[j],L[ce.charCodeAt(j)]=j;var j,Te;L[45]=62;L[95]=63;function Re(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function at(r){var e=Re(r),t=e[0],n=e[1];return(t+n)*3/4-n}function lt(r,e,t){return(e+t)*3/4-t}function ct(r){var e,t=Re(r),n=t[0],i=t[1],o=new st(lt(r,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=L[r.charCodeAt(c)]<<18|L[r.charCodeAt(c+1)]<<12|L[r.charCodeAt(c+2)]<<6|L[r.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=L[r.charCodeAt(c)]<<2|L[r.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=L[r.charCodeAt(c)]<<10|L[r.charCodeAt(c+1)]<<4|L[r.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ut(r){return _[r>>18&63]+_[r>>12&63]+_[r>>6&63]+_[r&63]}function pt(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(ut(n));return i.join("")}function ft(r){for(var e,t=r.length,n=t%3,i=[],o=16383,s=0,a=t-n;s<a;s+=o)i.push(pt(r,s,s+o>a?a:s+o));return n===1?(e=r[t-1],i.push(_[e>>2]+_[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(_[e>>10]+_[e>>4&63]+_[e<<2&63]+"=")),i.join("")}});var ve=le(ue=>{x();ue.read=function(r,e,t,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,u=c>>1,p=-7,f=t?i-1:0,h=t?-1:1,d=r[e+f];for(f+=h,o=d&(1<<-p)-1,d>>=-p,p+=a;p>0;o=o*256+r[e+f],f+=h,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=n;p>0;s=s*256+r[e+f],f+=h,p-=8);if(o===0)o=1-u;else{if(o===c)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(d?-1:1)*s*Math.pow(2,o-n)};ue.write=function(r,e,t,n,i,o){var s,a,c,u=o*8-i-1,p=(1<<u)-1,f=p>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,w=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=p):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+f>=1?e+=h/c:e+=h*Math.pow(2,1-f),e*c>=2&&(s++,c/=2),s+f>=p?(a=0,s=p):s+f>=1?(a=(e*c-1)*Math.pow(2,i),s=s+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;r[t+d]=a&255,d+=w,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;r[t+d]=s&255,d+=w,s/=256,u-=8);r[t+d-w]|=m*128}});var We=le(V=>{"use strict";x();var pe=Se(),z=ve(),Ce=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;V.Buffer=l;V.SlowBuffer=wt;V.INSPECT_MAX_BYTES=50;var te=2147483647;V.kMaxLength=te;l.TYPED_ARRAY_SUPPORT=dt();!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function dt(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}});Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function $(r){if(r>te)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,l.prototype),e}function l(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return me(r)}return Ue(r,e,t)}l.poolSize=8192;function Ue(r,e,t){if(typeof r=="string")return mt(r,e);if(ArrayBuffer.isView(r))return yt(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(k(r,ArrayBuffer)||r&&k(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(k(r,SharedArrayBuffer)||r&&k(r.buffer,SharedArrayBuffer)))return de(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return l.from(n,e,t);let i=gt(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return l.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}l.from=function(r,e,t){return Ue(r,e,t)};Object.setPrototypeOf(l.prototype,Uint8Array.prototype);Object.setPrototypeOf(l,Uint8Array);function Me(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function ht(r,e,t){return Me(r),r<=0?$(r):e!==void 0?typeof t=="string"?$(r).fill(e,t):$(r).fill(e):$(r)}l.alloc=function(r,e,t){return ht(r,e,t)};function me(r){return Me(r),$(r<0?0:ye(r)|0)}l.allocUnsafe=function(r){return me(r)};l.allocUnsafeSlow=function(r){return me(r)};function mt(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Le(r,e)|0,n=$(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function fe(r){let e=r.length<0?0:ye(r.length)|0,t=$(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function yt(r){if(k(r,Uint8Array)){let e=new Uint8Array(r);return de(e.buffer,e.byteOffset,e.byteLength)}return fe(r)}function de(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,l.prototype),n}function gt(r){if(l.isBuffer(r)){let e=ye(r.length)|0,t=$(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||we(r.length)?$(0):fe(r);if(r.type==="Buffer"&&Array.isArray(r.data))return fe(r.data)}function ye(r){if(r>=te)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+te.toString(16)+" bytes");return r|0}function wt(r){return+r!=r&&(r=0),l.alloc(+r)}l.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==l.prototype};l.compare=function(e,t){if(k(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),k(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=l.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let s=e[n];if(k(s,Uint8Array))o+s.length>i.length?(l.isBuffer(s)||(s=l.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(l.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Le(r,e){if(l.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||k(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return he(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Oe(r).length;default:if(i)return n?-1:he(r).length;e=(""+e).toLowerCase(),i=!0}}l.byteLength=Le;function xt(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return It(this,e,t);case"utf8":case"utf-8":return ke(this,e,t);case"ascii":return Ct(this,e,t);case"latin1":case"binary":return At(this,e,t);case"base64":return St(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ft(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function H(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}l.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)H(this,t,t+1);return this};l.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)H(this,t,t+3),H(this,t+1,t+2);return this};l.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)H(this,t,t+7),H(this,t+1,t+6),H(this,t+2,t+5),H(this,t+3,t+4);return this};l.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ke(this,0,e):xt.apply(this,arguments)};l.prototype.toLocaleString=l.prototype.toString;l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.inspect=function(){let e="",t=V.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Ce&&(l.prototype[Ce]=l.prototype.inspect);l.prototype.compare=function(e,t,n,i,o){if(k(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-t,c=Math.min(s,a),u=this.slice(i,o),p=e.slice(t,n);for(let f=0;f<c;++f)if(u[f]!==p[f]){s=u[f],a=p[f];break}return s<a?-1:a<s?1:0};function _e(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,we(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,n)),l.isBuffer(e))return e.length===0?-1:Ae(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Ae(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Ae(r,e,t,n,i){let o=1,s=r.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,a/=2,t/=2}function c(p,f){return o===1?p[f]:p.readUInt16BE(f*o)}let u;if(i){let p=-1;for(u=t;u<s;u++)if(c(r,u)===c(e,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===a)return p*o}else p!==-1&&(u-=u-p),p=-1}else for(t+a>s&&(t=s-a),u=t;u>=0;u--){let p=!0;for(let f=0;f<a;f++)if(c(r,u+f)!==c(e,f)){p=!1;break}if(p)return u}return-1}l.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};l.prototype.indexOf=function(e,t,n){return _e(this,e,t,n,!0)};l.prototype.lastIndexOf=function(e,t,n){return _e(this,e,t,n,!1)};function Et(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(we(a))return s;r[t+s]=a}return s}function bt(r,e,t,n){return re(he(e,r.length-t),r,t,n)}function Bt(r,e,t,n){return re(_t(e),r,t,n)}function Tt(r,e,t,n){return re(Oe(e),r,t,n)}function Rt(r,e,t,n){return re(kt(e,r.length-t),r,t,n)}l.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Et(this,e,t,n);case"utf8":case"utf-8":return bt(this,e,t,n);case"ascii":case"latin1":case"binary":return Bt(this,e,t,n);case"base64":return Tt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function St(r,e,t){return e===0&&t===r.length?pe.fromByteArray(r):pe.fromByteArray(r.slice(e,t))}function ke(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=t){let c,u,p,f;switch(a){case 1:o<128&&(s=o);break;case 2:c=r[i+1],(c&192)===128&&(f=(o&31)<<6|c&63,f>127&&(s=f));break;case 3:c=r[i+1],u=r[i+2],(c&192)===128&&(u&192)===128&&(f=(o&15)<<12|(c&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:c=r[i+1],u=r[i+2],p=r[i+3],(c&192)===128&&(u&192)===128&&(p&192)===128&&(f=(o&15)<<18|(c&63)<<12|(u&63)<<6|p&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return vt(n)}var Ie=4096;function vt(r){let e=r.length;if(e<=Ie)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Ie));return t}function Ct(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function At(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function It(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=Pt[r[o]];return i}function Ft(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}l.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,l.prototype),i};function C(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return i};l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e=e>>>0,t||C(e,1,this.length),this[e]};l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||C(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||C(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||C(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readBigUInt64LE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});l.prototype.readBigUInt64BE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});l.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};l.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=t,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};l.prototype.readInt8=function(e,t){return e=e>>>0,t||C(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){e=e>>>0,t||C(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(e,t){e=e>>>0,t||C(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(e,t){return e=e>>>0,t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return e=e>>>0,t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readBigInt64LE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});l.prototype.readBigInt64BE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});l.prototype.readFloatLE=function(e,t){return e=e>>>0,t||C(e,4,this.length),z.read(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return e=e>>>0,t||C(e,4,this.length),z.read(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||C(e,8,this.length),z.read(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||C(e,8,this.length),z.read(this,e,!1,52,8)};function U(r,e,t,n,i,o){if(!l.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;U(this,e,t,n,a,0)}let o=1,s=0;for(this[t]=e&255;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n};l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;U(this,e,t,n,a,0)}let o=n-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n};l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,1,255,0),this[t]=e&255,t+1};l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Pe(r,e,t,n,i){He(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function $e(r,e,t,n,i){He(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}l.prototype.writeBigUInt64LE=D(function(e,t=0){return Pe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeBigUInt64BE=D(function(e,t=0){return $e(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);U(this,e,t,n,c-1,-c)}let o=0,s=1,a=0;for(this[t]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[t+o-1]!==0&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n};l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);U(this,e,t,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[t+o+1]!==0&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n};l.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};l.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};l.prototype.writeBigInt64LE=D(function(e,t=0){return Pe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});l.prototype.writeBigInt64BE=D(function(e,t=0){return $e(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function De(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ne(r,e,t,n,i){return e=+e,t=t>>>0,i||De(r,e,t,4,34028234663852886e22,-34028234663852886e22),z.write(r,e,t,n,23,4),t+4}l.prototype.writeFloatLE=function(e,t,n){return Ne(this,e,t,!0,n)};l.prototype.writeFloatBE=function(e,t,n){return Ne(this,e,t,!1,n)};function je(r,e,t,n,i){return e=+e,t=t>>>0,i||De(r,e,t,8,17976931348623157e292,-17976931348623157e292),z.write(r,e,t,n,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,n){return je(this,e,t,!0,n)};l.prototype.writeDoubleBE=function(e,t,n){return je(this,e,t,!1,n)};l.prototype.copy=function(e,t,n,i){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};l.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!l.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let s=l.isBuffer(e)?e:l.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var W={};function ge(r,e,t){W[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ge("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ge("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ge("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=Fe(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=Fe(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Fe(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Ut(r,e,t){q(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&K(e,r.length-(t+1))}function He(r,e,t,n,i,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${t}${s}`,new W.ERR_OUT_OF_RANGE("value",a,r)}Ut(n,i,o)}function q(r,e){if(typeof r!="number")throw new W.ERR_INVALID_ARG_TYPE(e,"number",r)}function K(r,e,t){throw Math.floor(r)!==r?(q(r,t),new W.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new W.ERR_BUFFER_OUT_OF_BOUNDS:new W.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Mt=/[^+/0-9A-Za-z-_]/g;function Lt(r){if(r=r.split("=")[0],r=r.trim().replace(Mt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function he(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function _t(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function kt(r,e){let t,n,i,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Oe(r){return pe.toByteArray(Lt(r))}function re(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function k(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function we(r){return r!==r}var Pt=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e})();function D(r){return typeof BigInt>"u"?$t:r}function $t(){throw new Error("BigInt not supported")}});var ze,x=nt(()=>{"use strict";ze=ot(We(),1);globalThis.Buffer=ze.Buffer});x();x();x();x();var G=class{constructor(e){this._initialized=!1;this.type=e}createContainer(){let e=document.createElement("div");return e.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),e.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(e),e}removeContainer(e){e&&e.parentNode&&e.parentNode.removeChild(e)}async initialize(e=null){this._initialized=!0}isInitialized(){return this._initialized}async render(e,t){throw new Error("render() must be implemented by subclass")}async mountToDom(e,t,n){let i=await this.render(e,t);if(!i||!i.base64){let s=document.createElement("div");return s.textContent=`Renderer returned empty result: ${this.type}`,n.appendChild(s),{root:s,cleanup:()=>{try{s.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,n.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(e){if(!e||typeof e=="string"&&e.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(e){return e}calculateCanvasScale(e){let n=e?.fontSize||12;return 14/16*(n/12)*4}async renderSvgToCanvas(e,t,n,i=null){return e=e.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,s)=>{let a=new Image;a.crossOrigin="Anonymous";let c=btoa(unescape(encodeURIComponent(e)));a.src=`data:image/svg+xml;base64,${c}`,a.onload=()=>{let u=document.createElement("canvas");u.width=t,u.height=n;let p=u.getContext("2d");i&&(p.font=`14px ${i}`),p.drawImage(a,0,0,t,n),o(u)},a.onerror=u=>{s(new Error("Failed to load SVG into image for rendering"))}})}};x();x();function qe(r){if(typeof document>"u")return Nt(r);try{let e=document.createElement("template");return e.innerHTML=r,Dt(e.content),e.innerHTML}catch{return r}}function Dt(r){let e=new Set(["SCRIPT","IFRAME","OBJECT","EMBED","AUDIO","VIDEO"]),t=[];for(Array.from(r.childNodes).forEach(n=>{n.nodeType===Node.ELEMENT_NODE?t.push(n):n.nodeType===Node.COMMENT_NODE&&n.remove()});t.length>0;){let n=t.pop();if(e.has(n.tagName)){n.remove();continue}let i=Array.from(n.attributes||[]);for(let o of i)(o.name.startsWith("on")||o.name==="href"&&o.value.trim().toLowerCase().startsWith("javascript:"))&&n.removeAttribute(o.name);Array.from(n.childNodes).forEach(o=>{o.nodeType===Node.ELEMENT_NODE?t.push(o):o.nodeType===Node.COMMENT_NODE&&o.remove()})}}function Ve(r){if(typeof document>"u")return jt(r);let e=document.createElement("div");return e.innerHTML=r,e.textContent.trim().length>0||e.querySelector("*")!==null}function Nt(r){let e=r;return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<iframe\b[\s\S]*?<\/iframe>/gi,"").replace(/<object\b[\s\S]*?<\/object>/gi,"").replace(/<embed\b[\s\S]*?<\/embed>/gi,"").replace(/<audio\b[\s\S]*?<\/audio>/gi,"").replace(/<video\b[\s\S]*?<\/video>/gi,""),e=e.replace(/\son[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),e=e.replace(/\shref\s*=\s*(["'])\s*javascript:[\s\S]*?\1/gi,' href="#"'),e}function jt(r){let e=(r||"").replace(/<!--[\s\S]*?-->/g,"").replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").trim();return e?!!(e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim().length>0||/<(img|svg|table|pre|code|hr|br|math|canvas|iframe|object|embed)\b/i.test(e)):!1}x();var Ge=null;function Je(){return Ge?.fetch?Ge.fetch:{fetchAsDataUrl:async()=>null}}var ne=class extends G{constructor(){super("html")}async render(e,t){return this.validateInput(e),await this.renderHtmlToPng(e,t)}async convertRemoteImagesToBase64(e){let t=Je(),n=e.querySelectorAll("img[src]"),i=Array.from(n).map(async o=>{let s=o.getAttribute("src");if(!s||s.startsWith("data:")||s.startsWith("blob:")||!s.startsWith("http://")&&!s.startsWith("https://"))return;let a=await t.fetchAsDataUrl(s);a&&o.setAttribute("src",a)});await Promise.all(i)}async renderHtmlToPng(e,t){let n=qe(e);if(!Ve(n))return null;let i=t?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",o=this.calculateCanvasScale(t),s="http://www.w3.org/2000/svg",a=2e3*o,c=2e3*o,u=document.createElementNS(s,"svg");u.setAttribute("xmlns",s),u.setAttribute("width",String(a)),u.setAttribute("height",String(c));let p=document.createElementNS(s,"foreignObject");p.setAttribute("width",String(a)),p.setAttribute("height",String(c));let f=document.createElement("div");f.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),f.style.cssText=`display: inline-block; overflow: hidden; outline: 1px solid #ff0000; outline-offset: 0; transform: scale(${o}); transform-origin: top left;`;let h=document.createElement("div");h.style.cssText=`display: inline-block; font-family: ${i};`,h.innerHTML=n,await this.convertRemoteImagesToBase64(h),f.appendChild(h),p.appendChild(f),u.appendChild(p);let d=new XMLSerializer().serializeToString(u),w="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(d),m=new Image;m.src=w,await m.decode();let T=document.createElement("canvas");T.width=m.naturalWidth,T.height=m.naturalHeight;let E=T.getContext("2d",{willReadFrequently:!0});if(!E)throw new Error("Failed to get canvas 2D context");E.drawImage(m,0,0);let y=T.width,b=T.height,R=E.getImageData(0,0,y,1).data,S=1;for(let M=y-1;M>=0;M--){let N=M*4;if(R[N]>200&&R[N+1]<50&&R[N+2]<50){S=M;break}}let A=E.getImageData(0,0,1,b).data,g=1;for(let M=b-1;M>=0;M--){let N=M*4;if(A[N]>200&&A[N+1]<50&&A[N+2]<50){g=M;break}}let v=Math.ceil(o),I=Math.max(1,S-v),Y=Math.max(1,g-v),B=document.createElement("canvas");B.width=I,B.height=Y;let F=B.getContext("2d");if(!F)throw new Error("Failed to get canvas 2D context");return F.drawImage(T,0,0,I,Y,0,0,I,Y),{base64:B.toDataURL("image/png").replace(/^data:image\/png;base64,/,""),width:B.width,height:B.height,format:"png"}}};async function J(r){return await import(r)}function Ht(r){let e=String(r||"").trim();return e&&(e.endsWith("/")?e:`${e}/`)}function se(r){let e=String(r||"").trim();return e&&(e.endsWith("/")?e.slice(0,-1):e)}function Ee(r,e){let t=Ht(e);if(!t)return r;let n=c=>{try{return new URL(c,t).href}catch{return t+c}},i=t.includes("esm.sh/"),o=se(t),s={svelte:i?o:n("src/runtime/index.js"),"svelte/internal":n(i?"internal":"src/runtime/internal/index.js"),"svelte/internal/client":n(i?"internal/client":"src/runtime/internal/client/index.js"),"svelte/internal/server":n(i?"internal/server":"src/runtime/internal/server/index.js"),"svelte/internal/disclose-version":n(i?"internal/disclose-version":"src/runtime/internal/disclose-version/index.js"),"svelte/store":n(i?"store":"src/runtime/store/index.js"),"svelte/animate":n(i?"animate":"src/runtime/animate/index.js"),"svelte/easing":n(i?"easing":"src/runtime/easing/index.js"),"svelte/motion":n(i?"motion":"src/runtime/motion/index.js"),"svelte/transition":n(i?"transition":"src/runtime/transition/index.js")},a=String(r||"");for(let[c,u]of Object.entries(s))a=a.split(`'${c}'`).join(`'${u}'`),a=a.split(`"${c}"`).join(`"${u}"`);return i&&o&&(a=a.split("'svelte/").join(`'${o}/`),a=a.split('"svelte/').join(`"${o}/`)),a}function Ot(r,e){let t=String(r||"").trim().toLowerCase(),n=String(e||"").trim();return!t||!n||n.includes("/")||n.includes("\\")||n.includes("://")||n.startsWith("file://")?n:`${t}/${n}`}function Ye(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function Wt(r){let e=String(r||"");return!/<span\b/i.test(e)&&!/\bhljs\b/i.test(e)?e:e.replace(/<[^>]*>/g,"")}function zt(r){let e="",t=!1,n=!1,i=!1,o=u=>/[A-Za-z_$]/.test(u),s=u=>/[A-Za-z0-9_$-]/.test(u),a=u=>{for(let p=u.length-1;p>=0;p--){let f=u[p];if(!/\s/.test(f))return f}return""},c=u=>{let p=u;for(;p<r.length&&/\s/.test(r[p]);)p++;let f=r[p];if(!f||!o(f))return!1;let h=p+1;for(;h<r.length&&s(r[h]);)h++;for(;h<r.length&&/\s/.test(r[h]);)h++;return r[h]===":"};for(let u=0;u<r.length;u++){let p=r[u];if(i){e+=p,i=!1;continue}if(p==="\\"){e+=p,i=!0;continue}if(!n&&p==="'"){t=!t,e+=p;continue}if(!t&&p==='"'){n=!n,e+=p;continue}if(!t&&!n){let f=p==="\r"&&r[u+1]===`
|
|
1
|
+
"use strict";(()=>{var Ze=Object.create;var Be=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var nt=(r,e)=>()=>(r&&(e=r(r=0)),e);var le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var it=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of et(e))!rt.call(r,i)&&i!==t&&Be(r,i,{get:()=>e[i],enumerable:!(n=Qe(e,i))||n.enumerable});return r};var ot=(r,e,t)=>(t=r!=null?Ze(tt(r)):{},it(e||!r||!r.__esModule?Be(t,"default",{value:r,enumerable:!0}):t,r));var Re=le(ee=>{"use strict";x();ee.byteLength=at;ee.toByteArray=ct;ee.fromByteArray=ft;var _=[],L=[],st=typeof Uint8Array<"u"?Uint8Array:Array,ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(j=0,Te=ce.length;j<Te;++j)_[j]=ce[j],L[ce.charCodeAt(j)]=j;var j,Te;L[45]=62;L[95]=63;function Se(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function at(r){var e=Se(r),t=e[0],n=e[1];return(t+n)*3/4-n}function lt(r,e,t){return(e+t)*3/4-t}function ct(r){var e,t=Se(r),n=t[0],i=t[1],o=new st(lt(r,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=L[r.charCodeAt(c)]<<18|L[r.charCodeAt(c+1)]<<12|L[r.charCodeAt(c+2)]<<6|L[r.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=L[r.charCodeAt(c)]<<2|L[r.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=L[r.charCodeAt(c)]<<10|L[r.charCodeAt(c+1)]<<4|L[r.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ut(r){return _[r>>18&63]+_[r>>12&63]+_[r>>6&63]+_[r&63]}function pt(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(ut(n));return i.join("")}function ft(r){for(var e,t=r.length,n=t%3,i=[],o=16383,s=0,a=t-n;s<a;s+=o)i.push(pt(r,s,s+o>a?a:s+o));return n===1?(e=r[t-1],i.push(_[e>>2]+_[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(_[e>>10]+_[e>>4&63]+_[e<<2&63]+"=")),i.join("")}});var ve=le(ue=>{x();ue.read=function(r,e,t,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,u=c>>1,p=-7,f=t?i-1:0,h=t?-1:1,d=r[e+f];for(f+=h,o=d&(1<<-p)-1,d>>=-p,p+=a;p>0;o=o*256+r[e+f],f+=h,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=n;p>0;s=s*256+r[e+f],f+=h,p-=8);if(o===0)o=1-u;else{if(o===c)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(d?-1:1)*s*Math.pow(2,o-n)};ue.write=function(r,e,t,n,i,o){var s,a,c,u=o*8-i-1,p=(1<<u)-1,f=p>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,w=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=p):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+f>=1?e+=h/c:e+=h*Math.pow(2,1-f),e*c>=2&&(s++,c/=2),s+f>=p?(a=0,s=p):s+f>=1?(a=(e*c-1)*Math.pow(2,i),s=s+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;r[t+d]=a&255,d+=w,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;r[t+d]=s&255,d+=w,s/=256,u-=8);r[t+d-w]|=m*128}});var ze=le(V=>{"use strict";x();var pe=Re(),W=ve(),Ce=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;V.Buffer=l;V.SlowBuffer=wt;V.INSPECT_MAX_BYTES=50;var te=2147483647;V.kMaxLength=te;l.TYPED_ARRAY_SUPPORT=dt();!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function dt(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}});Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function $(r){if(r>te)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,l.prototype),e}function l(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return me(r)}return Ue(r,e,t)}l.poolSize=8192;function Ue(r,e,t){if(typeof r=="string")return mt(r,e);if(ArrayBuffer.isView(r))return yt(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(k(r,ArrayBuffer)||r&&k(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(k(r,SharedArrayBuffer)||r&&k(r.buffer,SharedArrayBuffer)))return de(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return l.from(n,e,t);let i=gt(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return l.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}l.from=function(r,e,t){return Ue(r,e,t)};Object.setPrototypeOf(l.prototype,Uint8Array.prototype);Object.setPrototypeOf(l,Uint8Array);function Me(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function ht(r,e,t){return Me(r),r<=0?$(r):e!==void 0?typeof t=="string"?$(r).fill(e,t):$(r).fill(e):$(r)}l.alloc=function(r,e,t){return ht(r,e,t)};function me(r){return Me(r),$(r<0?0:ye(r)|0)}l.allocUnsafe=function(r){return me(r)};l.allocUnsafeSlow=function(r){return me(r)};function mt(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Le(r,e)|0,n=$(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function fe(r){let e=r.length<0?0:ye(r.length)|0,t=$(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function yt(r){if(k(r,Uint8Array)){let e=new Uint8Array(r);return de(e.buffer,e.byteOffset,e.byteLength)}return fe(r)}function de(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,l.prototype),n}function gt(r){if(l.isBuffer(r)){let e=ye(r.length)|0,t=$(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||we(r.length)?$(0):fe(r);if(r.type==="Buffer"&&Array.isArray(r.data))return fe(r.data)}function ye(r){if(r>=te)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+te.toString(16)+" bytes");return r|0}function wt(r){return+r!=r&&(r=0),l.alloc(+r)}l.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==l.prototype};l.compare=function(e,t){if(k(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),k(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=l.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let s=e[n];if(k(s,Uint8Array))o+s.length>i.length?(l.isBuffer(s)||(s=l.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(l.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Le(r,e){if(l.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||k(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return he(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Oe(r).length;default:if(i)return n?-1:he(r).length;e=(""+e).toLowerCase(),i=!0}}l.byteLength=Le;function xt(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return It(this,e,t);case"utf8":case"utf-8":return ke(this,e,t);case"ascii":return Ct(this,e,t);case"latin1":case"binary":return At(this,e,t);case"base64":return Rt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ft(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function H(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}l.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)H(this,t,t+1);return this};l.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)H(this,t,t+3),H(this,t+1,t+2);return this};l.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)H(this,t,t+7),H(this,t+1,t+6),H(this,t+2,t+5),H(this,t+3,t+4);return this};l.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ke(this,0,e):xt.apply(this,arguments)};l.prototype.toLocaleString=l.prototype.toString;l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.inspect=function(){let e="",t=V.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Ce&&(l.prototype[Ce]=l.prototype.inspect);l.prototype.compare=function(e,t,n,i,o){if(k(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-t,c=Math.min(s,a),u=this.slice(i,o),p=e.slice(t,n);for(let f=0;f<c;++f)if(u[f]!==p[f]){s=u[f],a=p[f];break}return s<a?-1:a<s?1:0};function _e(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,we(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,n)),l.isBuffer(e))return e.length===0?-1:Ae(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Ae(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Ae(r,e,t,n,i){let o=1,s=r.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,a/=2,t/=2}function c(p,f){return o===1?p[f]:p.readUInt16BE(f*o)}let u;if(i){let p=-1;for(u=t;u<s;u++)if(c(r,u)===c(e,p===-1?0:u-p)){if(p===-1&&(p=u),u-p+1===a)return p*o}else p!==-1&&(u-=u-p),p=-1}else for(t+a>s&&(t=s-a),u=t;u>=0;u--){let p=!0;for(let f=0;f<a;f++)if(c(r,u+f)!==c(e,f)){p=!1;break}if(p)return u}return-1}l.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};l.prototype.indexOf=function(e,t,n){return _e(this,e,t,n,!0)};l.prototype.lastIndexOf=function(e,t,n){return _e(this,e,t,n,!1)};function Et(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(we(a))return s;r[t+s]=a}return s}function bt(r,e,t,n){return re(he(e,r.length-t),r,t,n)}function Bt(r,e,t,n){return re(_t(e),r,t,n)}function Tt(r,e,t,n){return re(Oe(e),r,t,n)}function St(r,e,t,n){return re(kt(e,r.length-t),r,t,n)}l.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Et(this,e,t,n);case"utf8":case"utf-8":return bt(this,e,t,n);case"ascii":case"latin1":case"binary":return Bt(this,e,t,n);case"base64":return Tt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Rt(r,e,t){return e===0&&t===r.length?pe.fromByteArray(r):pe.fromByteArray(r.slice(e,t))}function ke(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=t){let c,u,p,f;switch(a){case 1:o<128&&(s=o);break;case 2:c=r[i+1],(c&192)===128&&(f=(o&31)<<6|c&63,f>127&&(s=f));break;case 3:c=r[i+1],u=r[i+2],(c&192)===128&&(u&192)===128&&(f=(o&15)<<12|(c&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:c=r[i+1],u=r[i+2],p=r[i+3],(c&192)===128&&(u&192)===128&&(p&192)===128&&(f=(o&15)<<18|(c&63)<<12|(u&63)<<6|p&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return vt(n)}var Ie=4096;function vt(r){let e=r.length;if(e<=Ie)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Ie));return t}function Ct(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function At(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function It(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=Pt[r[o]];return i}function Ft(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}l.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,l.prototype),i};function C(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return i};l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e=e>>>0,t||C(e,1,this.length),this[e]};l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||C(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||C(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||C(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readBigUInt64LE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});l.prototype.readBigUInt64BE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});l.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};l.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||C(e,t,this.length);let i=t,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*t)),s};l.prototype.readInt8=function(e,t){return e=e>>>0,t||C(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){e=e>>>0,t||C(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(e,t){e=e>>>0,t||C(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(e,t){return e=e>>>0,t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return e=e>>>0,t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readBigInt64LE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});l.prototype.readBigInt64BE=D(function(e){e=e>>>0,q(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});l.prototype.readFloatLE=function(e,t){return e=e>>>0,t||C(e,4,this.length),W.read(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return e=e>>>0,t||C(e,4,this.length),W.read(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||C(e,8,this.length),W.read(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||C(e,8,this.length),W.read(this,e,!1,52,8)};function U(r,e,t,n,i,o){if(!l.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;U(this,e,t,n,a,0)}let o=1,s=0;for(this[t]=e&255;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n};l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;U(this,e,t,n,a,0)}let o=n-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n};l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,1,255,0),this[t]=e&255,t+1};l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Pe(r,e,t,n,i){He(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function $e(r,e,t,n,i){He(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}l.prototype.writeBigUInt64LE=D(function(e,t=0){return Pe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeBigUInt64BE=D(function(e,t=0){return $e(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);U(this,e,t,n,c-1,-c)}let o=0,s=1,a=0;for(this[t]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[t+o-1]!==0&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n};l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);U(this,e,t,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[t+o+1]!==0&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n};l.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};l.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};l.prototype.writeBigInt64LE=D(function(e,t=0){return Pe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});l.prototype.writeBigInt64BE=D(function(e,t=0){return $e(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function De(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ne(r,e,t,n,i){return e=+e,t=t>>>0,i||De(r,e,t,4,34028234663852886e22,-34028234663852886e22),W.write(r,e,t,n,23,4),t+4}l.prototype.writeFloatLE=function(e,t,n){return Ne(this,e,t,!0,n)};l.prototype.writeFloatBE=function(e,t,n){return Ne(this,e,t,!1,n)};function je(r,e,t,n,i){return e=+e,t=t>>>0,i||De(r,e,t,8,17976931348623157e292,-17976931348623157e292),W.write(r,e,t,n,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,n){return je(this,e,t,!0,n)};l.prototype.writeDoubleBE=function(e,t,n){return je(this,e,t,!1,n)};l.prototype.copy=function(e,t,n,i){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};l.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!l.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let s=l.isBuffer(e)?e:l.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var z={};function ge(r,e,t){z[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ge("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ge("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);ge("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=Fe(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=Fe(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Fe(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Ut(r,e,t){q(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&K(e,r.length-(t+1))}function He(r,e,t,n,i,o){if(r>t||r<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${t}${s}`,new z.ERR_OUT_OF_RANGE("value",a,r)}Ut(n,i,o)}function q(r,e){if(typeof r!="number")throw new z.ERR_INVALID_ARG_TYPE(e,"number",r)}function K(r,e,t){throw Math.floor(r)!==r?(q(r,t),new z.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new z.ERR_BUFFER_OUT_OF_BOUNDS:new z.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Mt=/[^+/0-9A-Za-z-_]/g;function Lt(r){if(r=r.split("=")[0],r=r.trim().replace(Mt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function he(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function _t(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function kt(r,e){let t,n,i,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Oe(r){return pe.toByteArray(Lt(r))}function re(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function k(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function we(r){return r!==r}var Pt=(function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e})();function D(r){return typeof BigInt>"u"?$t:r}function $t(){throw new Error("BigInt not supported")}});var We,x=nt(()=>{"use strict";We=ot(ze(),1);globalThis.Buffer=We.Buffer});x();x();x();x();var G=class{constructor(e){this._initialized=!1;this.type=e}createContainer(){let e=document.createElement("div");return e.id="render-container-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),e.style.cssText="position: absolute; left: -9999px; top: -9999px;",document.body.appendChild(e),e}removeContainer(e){e&&e.parentNode&&e.parentNode.removeChild(e)}async initialize(e=null){this._initialized=!0}isInitialized(){return this._initialized}async render(e,t){throw new Error("render() must be implemented by subclass")}async mountToDom(e,t,n){let i=await this.render(e,t);if(!i||!i.base64){let s=document.createElement("div");return s.textContent=`Renderer returned empty result: ${this.type}`,n.appendChild(s),{root:s,cleanup:()=>{try{s.remove()}catch{}}}}let o=document.createElement("img");return o.style.maxWidth="100%",o.style.height="auto",o.alt=`${this.type} diagram`,o.src=`data:image/${i.format};base64,${i.base64}`,n.appendChild(o),{root:o,cleanup:()=>{try{o.remove()}catch{}}}}validateInput(e){if(!e||typeof e=="string"&&e.trim()==="")throw new Error(`Empty ${this.type} input provided`)}preprocessInput(e){return e}calculateCanvasScale(e){return(e?.fontSize||12)/12*4}async renderSvgToCanvas(e,t,n,i=null){return e=e.replace(/<style>/,"<style>foreignObject { overflow: visible; }"),new Promise((o,s)=>{let a=new Image;a.crossOrigin="Anonymous";let c=btoa(unescape(encodeURIComponent(e)));a.src=`data:image/svg+xml;base64,${c}`,a.onload=()=>{let u=document.createElement("canvas");u.width=t,u.height=n;let p=u.getContext("2d");i&&(p.font=`14px ${i}`),p.drawImage(a,0,0,t,n),o(u)},a.onerror=u=>{s(new Error("Failed to load SVG into image for rendering"))}})}};x();x();function qe(r){if(typeof document>"u")return Nt(r);try{let e=document.createElement("template");return e.innerHTML=r,Dt(e.content),e.innerHTML}catch{return r}}function Dt(r){let e=new Set(["SCRIPT","IFRAME","OBJECT","EMBED","AUDIO","VIDEO"]),t=[];for(Array.from(r.childNodes).forEach(n=>{n.nodeType===Node.ELEMENT_NODE?t.push(n):n.nodeType===Node.COMMENT_NODE&&n.remove()});t.length>0;){let n=t.pop();if(e.has(n.tagName)){n.remove();continue}let i=Array.from(n.attributes||[]);for(let o of i)(o.name.startsWith("on")||o.name==="href"&&o.value.trim().toLowerCase().startsWith("javascript:"))&&n.removeAttribute(o.name);Array.from(n.childNodes).forEach(o=>{o.nodeType===Node.ELEMENT_NODE?t.push(o):o.nodeType===Node.COMMENT_NODE&&o.remove()})}}function Ve(r){if(typeof document>"u")return jt(r);let e=document.createElement("div");return e.innerHTML=r,e.textContent.trim().length>0||e.querySelector("*")!==null}function Nt(r){let e=r;return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<iframe\b[\s\S]*?<\/iframe>/gi,"").replace(/<object\b[\s\S]*?<\/object>/gi,"").replace(/<embed\b[\s\S]*?<\/embed>/gi,"").replace(/<audio\b[\s\S]*?<\/audio>/gi,"").replace(/<video\b[\s\S]*?<\/video>/gi,""),e=e.replace(/\son[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),e=e.replace(/\shref\s*=\s*(["'])\s*javascript:[\s\S]*?\1/gi,' href="#"'),e}function jt(r){let e=(r||"").replace(/<!--[\s\S]*?-->/g,"").replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").trim();return e?!!(e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim().length>0||/<(img|svg|table|pre|code|hr|br|math|canvas|iframe|object|embed)\b/i.test(e)):!1}x();var Ge=null;function Je(){return Ge?.fetch?Ge.fetch:{fetchAsDataUrl:async()=>null}}var ne=class extends G{constructor(){super("html")}async render(e,t){return this.validateInput(e),await this.renderHtmlToPng(e,t)}async convertRemoteImagesToBase64(e){let t=Je(),n=e.querySelectorAll("img[src]"),i=Array.from(n).map(async o=>{let s=o.getAttribute("src");if(!s||s.startsWith("data:")||s.startsWith("blob:")||!s.startsWith("http://")&&!s.startsWith("https://"))return;let a=await t.fetchAsDataUrl(s);a&&o.setAttribute("src",a)});await Promise.all(i)}async renderHtmlToPng(e,t){let n=qe(e);if(!Ve(n))return null;let i=t?.fontFamily||"'SimSun', 'Times New Roman', Times, serif",o=this.calculateCanvasScale(t),s="http://www.w3.org/2000/svg",a=2e3*o,c=2e3*o,u=document.createElementNS(s,"svg");u.setAttribute("xmlns",s),u.setAttribute("width",String(a)),u.setAttribute("height",String(c));let p=document.createElementNS(s,"foreignObject");p.setAttribute("width",String(a)),p.setAttribute("height",String(c));let f=document.createElement("div");f.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),f.style.cssText=`display: inline-block; overflow: hidden; outline: 1px solid #ff0000; outline-offset: 0; transform: scale(${o}); transform-origin: top left;`;let h=document.createElement("div");h.style.cssText=`display: inline-block; font-family: ${i};`,h.innerHTML=n,await this.convertRemoteImagesToBase64(h),f.appendChild(h),p.appendChild(f),u.appendChild(p);let d=new XMLSerializer().serializeToString(u),w="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(d),m=new Image;m.src=w,await m.decode();let T=document.createElement("canvas");T.width=m.naturalWidth,T.height=m.naturalHeight;let E=T.getContext("2d",{willReadFrequently:!0});if(!E)throw new Error("Failed to get canvas 2D context");E.drawImage(m,0,0);let y=T.width,b=T.height,S=E.getImageData(0,0,y,1).data,R=1;for(let M=y-1;M>=0;M--){let N=M*4;if(S[N]>200&&S[N+1]<50&&S[N+2]<50){R=M;break}}let A=E.getImageData(0,0,1,b).data,g=1;for(let M=b-1;M>=0;M--){let N=M*4;if(A[N]>200&&A[N+1]<50&&A[N+2]<50){g=M;break}}let v=Math.ceil(o),I=Math.max(1,R-v),Y=Math.max(1,g-v),B=document.createElement("canvas");B.width=I,B.height=Y;let F=B.getContext("2d");if(!F)throw new Error("Failed to get canvas 2D context");return F.drawImage(T,0,0,I,Y,0,0,I,Y),{base64:B.toDataURL("image/png").replace(/^data:image\/png;base64,/,""),width:B.width,height:B.height,format:"png"}}};async function J(r){return await import(r)}function Ht(r){let e=String(r||"").trim();return e&&(e.endsWith("/")?e:`${e}/`)}function se(r){let e=String(r||"").trim();return e&&(e.endsWith("/")?e.slice(0,-1):e)}function Ee(r,e){let t=Ht(e);if(!t)return r;let n=c=>{try{return new URL(c,t).href}catch{return t+c}},i=t.includes("esm.sh/"),o=se(t),s={svelte:i?o:n("src/runtime/index.js"),"svelte/internal":n(i?"internal":"src/runtime/internal/index.js"),"svelte/internal/client":n(i?"internal/client":"src/runtime/internal/client/index.js"),"svelte/internal/server":n(i?"internal/server":"src/runtime/internal/server/index.js"),"svelte/internal/disclose-version":n(i?"internal/disclose-version":"src/runtime/internal/disclose-version/index.js"),"svelte/store":n(i?"store":"src/runtime/store/index.js"),"svelte/animate":n(i?"animate":"src/runtime/animate/index.js"),"svelte/easing":n(i?"easing":"src/runtime/easing/index.js"),"svelte/motion":n(i?"motion":"src/runtime/motion/index.js"),"svelte/transition":n(i?"transition":"src/runtime/transition/index.js")},a=String(r||"");for(let[c,u]of Object.entries(s))a=a.split(`'${c}'`).join(`'${u}'`),a=a.split(`"${c}"`).join(`"${u}"`);return i&&o&&(a=a.split("'svelte/").join(`'${o}/`),a=a.split('"svelte/').join(`"${o}/`)),a}function Ot(r,e){let t=String(r||"").trim().toLowerCase(),n=String(e||"").trim();return!t||!n||n.includes("/")||n.includes("\\")||n.includes("://")||n.startsWith("file://")?n:`${t}/${n}`}function Ye(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function zt(r){let e=String(r||"");return!/<span\b/i.test(e)&&!/\bhljs\b/i.test(e)?e:e.replace(/<[^>]*>/g,"")}function Wt(r){let e="",t=!1,n=!1,i=!1,o=u=>/[A-Za-z_$]/.test(u),s=u=>/[A-Za-z0-9_$-]/.test(u),a=u=>{for(let p=u.length-1;p>=0;p--){let f=u[p];if(!/\s/.test(f))return f}return""},c=u=>{let p=u;for(;p<r.length&&/\s/.test(r[p]);)p++;let f=r[p];if(!f||!o(f))return!1;let h=p+1;for(;h<r.length&&s(r[h]);)h++;for(;h<r.length&&/\s/.test(r[h]);)h++;return r[h]===":"};for(let u=0;u<r.length;u++){let p=r[u];if(i){e+=p,i=!1;continue}if(p==="\\"){e+=p,i=!0;continue}if(!n&&p==="'"){t=!t,e+=p;continue}if(!t&&p==='"'){n=!n,e+=p;continue}if(!t&&!n){let f=p==="\r"&&r[u+1]===`
|
|
2
2
|
`;if(p===`
|
|
3
3
|
`||p==="\r"){let d=a(e);d&&!"{[,:".includes(d)&&c(u+1)&&(e+=","),e+=p,f&&(e+=`
|
|
4
|
-
`,u++);continue}}e+=p}return e}function qt(r){let e="",t=!1,n=!1,i=!1;for(let o=0;o<r.length;o++){let s=r[o];if(i){e+=s,i=!1;continue}if(s==="\\\\"){e+=s,i=!0;continue}if(!n&&s==="'"){t=!t,e+=s;continue}if(!t&&s==='"'){n=!n,e+=s;continue}if(!t&&!n&&s===","){let a=o+1;for(;a<r.length&&/\s/.test(r[a]);)a++;let c=r[a];if(c==="}"||c==="]")continue}e+=s}return e}function Vt(r){let e="",t=!1,n=!1,i=!1;for(let o=0;o<r.length;o++){let s=r[o];if(i){e+=s,i=!1;continue}if(s==="\\\\"){e+=s,i=!0;continue}if(!n&&s==="'"){t=!t,e+='"';continue}if(!t&&s==='"'){n=!n,e+=s;continue}if(t&&s==='"'){e+='\\\\"';continue}e+=s}return e}function Gt(r){let e="",t=0,n=!1,i=!1,o=!1,s=c=>/[A-Za-z_$]/.test(c),a=c=>/[A-Za-z0-9_$-]/.test(c);for(;t<r.length;){let c=r[t];if(o){e+=c,o=!1,t++;continue}if(c==="\\\\"){e+=c,o=!0,t++;continue}if(!i&&c==="'"){n=!n,e+=c,t++;continue}if(!n&&c==='"'){i=!i,e+=c,t++;continue}if(!n&&!i){let u=e.length-1;for(;u>=0&&/\s/.test(e[u]);)u--;let p=u>=0?e[u]:"";if((p==="{"||p===","||p==="")&&s(c)){let h=t+1;for(;h<r.length&&a(r[h]);)h++;let d=h;for(;d<r.length&&/\s/.test(r[d]);)d++;if(r[d]===":"){let w=r.slice(t,h);e+=`"${w}"`,t=h;continue}}}e+=c,t++}return e}function be(r){let e=
|
|
4
|
+
`,u++);continue}}e+=p}return e}function qt(r){let e="",t=!1,n=!1,i=!1;for(let o=0;o<r.length;o++){let s=r[o];if(i){e+=s,i=!1;continue}if(s==="\\\\"){e+=s,i=!0;continue}if(!n&&s==="'"){t=!t,e+=s;continue}if(!t&&s==='"'){n=!n,e+=s;continue}if(!t&&!n&&s===","){let a=o+1;for(;a<r.length&&/\s/.test(r[a]);)a++;let c=r[a];if(c==="}"||c==="]")continue}e+=s}return e}function Vt(r){let e="",t=!1,n=!1,i=!1;for(let o=0;o<r.length;o++){let s=r[o];if(i){e+=s,i=!1;continue}if(s==="\\\\"){e+=s,i=!0;continue}if(!n&&s==="'"){t=!t,e+='"';continue}if(!t&&s==='"'){n=!n,e+=s;continue}if(t&&s==='"'){e+='\\\\"';continue}e+=s}return e}function Gt(r){let e="",t=0,n=!1,i=!1,o=!1,s=c=>/[A-Za-z_$]/.test(c),a=c=>/[A-Za-z0-9_$-]/.test(c);for(;t<r.length;){let c=r[t];if(o){e+=c,o=!1,t++;continue}if(c==="\\\\"){e+=c,o=!0,t++;continue}if(!i&&c==="'"){n=!n,e+=c,t++;continue}if(!n&&c==='"'){i=!i,e+=c,t++;continue}if(!n&&!i){let u=e.length-1;for(;u>=0&&/\s/.test(e[u]);)u--;let p=u>=0?e[u]:"";if((p==="{"||p===","||p==="")&&s(c)){let h=t+1;for(;h<r.length&&a(r[h]);)h++;let d=h;for(;d<r.length&&/\s/.test(r[d]);)d++;if(r[d]===":"){let w=r.slice(t,h);e+=`"${w}"`,t=h;continue}}}e+=c,t++}return e}function be(r){let e=zt(String(r||"").trim());if(!e)throw new Error("Empty md2x block");let t=Wt(e.trim().startsWith("{")?e:`{${e}
|
|
5
5
|
}`);try{let u=JSON.parse(t);if(!Ye(u))throw new Error("md2x config must be an object");let p=String(u.type||"").trim(),f=String(u.template||"").trim();if(!p||p!=="vue"&&p!=="html"&&p!=="svelte")throw new Error('md2x.type must be "vue", "html", or "svelte"');if(!f)throw new Error("md2x.template is required");let h=typeof u.allowTemplateAssets=="boolean"?u.allowTemplateAssets:typeof u.allowCdn=="boolean"?u.allowCdn:void 0,d=typeof u.allowScripts=="boolean"?u.allowScripts:void 0;return{type:p,template:f,data:u.data,allowTemplateAssets:h,allowScripts:d}}catch{}let n=qt(Gt(Vt(t))),i;try{i=JSON.parse(n)}catch(u){throw new Error(`Invalid md2x config (expected object literal): ${u.message}`)}if(!Ye(i))throw new Error("md2x config must be an object");let o=String(i.type||"").trim(),s=String(i.template||"").trim();if(!o||o!=="vue"&&o!=="html"&&o!=="svelte")throw new Error('md2x.type must be "vue", "html", or "svelte"');if(!s)throw new Error("md2x.template is required");let a=typeof i.allowTemplateAssets=="boolean"?i.allowTemplateAssets:typeof i.allowCdn=="boolean"?i.allowCdn:void 0,c=typeof i.allowScripts=="boolean"?i.allowScripts:void 0;return{type:o,template:s,data:i.data,allowTemplateAssets:a,allowScripts:c}}function Jt(r){return JSON.stringify(r).replace(/</g,"\\u003c")}function O(r,e){let t=Jt(e??null);return String(r||"").split("templateData").join(`(${t})`)}function ie(r){if(!Array.isArray(r))return[];let e=[],t=new Set;for(let n of r){if(typeof n!="string")continue;let i=n.trim();i&&(t.has(i)||(t.add(i),e.push(i)))}return e}function Yt(r){if(!r||typeof r!="object")return null;let e=r.assets;if(!e||typeof e!="object")return null;let t=ie(e.scripts),n=ie(e.styles);return!t.length&&!n.length?null:{assets:{scripts:t,styles:n}}}function X(r){let e=String(r||"");if(!e)return{source:e,templateConfig:null};let t=0;for(e.charCodeAt(0)===65279&&(t=1);t<e.length&&/\s/.test(e[t]);)t++;if(e.slice(t,t+4)!=="<!--")return{source:e,templateConfig:null};let n=e.indexOf("-->",t+4);if(n===-1)return{source:e,templateConfig:null};let i=e.slice(t+4,n).trim(),o="TemplateConfig:";if(!i.startsWith(o))return{source:e,templateConfig:null};let s=i.slice(o.length).trim(),a=e.slice(n+3);a.startsWith(`\r
|
|
6
6
|
`)?a=a.slice(2):(a.startsWith(`
|
|
7
7
|
`)||a.startsWith("\r"))&&(a=a.slice(1));let c=e.slice(0,t)+a;if(!s)return{source:c,templateConfig:null};try{let u=JSON.parse(s);return{source:c,templateConfig:Yt(u)}}catch(u){return{source:c,templateConfig:null,error:u.message}}}function Ke(r){let e=String(r||"").trim();if(!e)return e;try{return new URL(e,document.baseURI).href}catch{return e}}async function Kt(r){let e=Ke(r);if(!e)return;let t=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"');document.querySelector(`link[rel="stylesheet"][href="${t}"]`)||await new Promise(i=>{let o=document.createElement("link");o.rel="stylesheet",o.href=e,o.onload=()=>i(),o.onerror=()=>i(),document.head.appendChild(o)})}async function Z(r){let e=ie(r?.assets?.scripts),t=ie(r?.assets?.styles);for(let n of t)await Kt(n);for(let n of e)await xe(Ke(n))}async function xe(r,e){if(e&&globalThis[e])return;let t=globalThis.CSS?.escape?globalThis.CSS.escape(r):r.replace(/"/g,'\\"'),n=document.querySelector(`script[src="${t}"]`);if(n){if(n.__md2xLoaded)return;await new Promise((i,o)=>{n.addEventListener("load",()=>i(),{once:!0}),n.addEventListener("error",()=>o(new Error("Failed to load script: "+r)),{once:!0})}),n.__md2xLoaded=!0;return}await new Promise((i,o)=>{let s=document.createElement("script");s.src=r,s.async=!1,s.onload=()=>{s.__md2xLoaded=!0,i()},s.onerror=()=>{s.__md2xLoaded=!0,o(new Error("Failed to load script: "+r))},document.head.appendChild(s)})}var oe=class extends G{constructor(){super("md2x");this.htmlRenderer=new ne;this.vueReady=null;this.svelteCompilerReady=null}getTemplateSource(t,n,i){let o=String(i||"").trim(),s=Ot(n,o),a=t??{},c=[];s&&c.push(s),o&&o!==s&&c.push(o);try{s&&c.push(new URL(s,document.baseURI).href)}catch{}try{o&&c.push(new URL(o,document.baseURI).href)}catch{}for(let u of c){let p=a[u];if(typeof p=="string")return{templateRef:s||o,source:p}}return{templateRef:s||o,source:null}}async ensureVueRuntime(t){if(this.vueReady)return this.vueReady;let n=t?.vue||"https://unpkg.com/vue@3/dist/vue.global.js",i=t?.vueSfcLoader||"https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js";return this.vueReady=(async()=>{await xe(n,"Vue"),await xe(i,"vue3-sfc-loader")})(),this.vueReady}async ensureSvelteCompiler(t){if(this.svelteCompilerReady)return this.svelteCompilerReady;let n=t?.svelteCompiler||"https://esm.sh/svelte@5/compiler";return this.svelteCompilerReady=(async()=>await J(n))(),this.svelteCompilerReady}async renderAsErrorPng(t,n){let i=`<div style="font-family: sans-serif; font-size: 12px; color: #b00020;">
|
|
8
8
|
<div style="font-weight: 600; margin-bottom: 6px;">md2x render error</div>
|
|
9
9
|
<pre style="white-space: pre-wrap; margin: 0;">${t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>
|
|
10
|
-
</div>`;return await this.htmlRenderer.render(i,n)}async runHtmlTemplateScripts(t,n){let i=n??{},o=Array.from(t.querySelectorAll("script")),s=a=>{let c=String(a||"").trim();if(!c)return null;if(typeof i[c]=="string")return i[c];try{let u=new URL(c,document.baseURI).href;if(typeof i[u]=="string")return i[u]}catch{}return null};for(let a of o){let c=a.parentNode;if(!c)continue;if(String(a.getAttribute("type")||"").trim().toLowerCase()==="module")throw new Error('md2x html template: <script type="module"> is not supported for PNG rendering');let p=a.getAttribute("src");if(p){let h=s(p);if(h==null)throw new Error(`md2x html template: external <script src="${p}"> is not supported unless it is provided via templateFiles`);let d=document.createElement("script");for(let w of Array.from(a.attributes||[])){let m=String(w?.name||"");if(m&&!(m==="src"||m==="async"||m==="defer"))try{d.setAttribute(m,w.value)}catch{}}d.textContent=String(h||""),c.replaceChild(d,a);continue}let f=document.createElement("script");for(let h of Array.from(a.attributes||[])){let d=String(h?.name||"");if(d&&!(d==="async"||d==="defer"))try{f.setAttribute(d,h.value)}catch{}}f.textContent=a.textContent||"",c.replaceChild(f,a)}}async renderHtmlTemplate(t,n,i){let{templateRef:o,source:s}=this.getTemplateSource(n,t.type,t.template);if(!s)return await this.renderAsErrorPng(`Missing md2x template: ${o||t.template}`,i);let a=X(s);if(t.allowTemplateAssets){if(a.error)return await this.renderAsErrorPng(`Invalid TemplateConfig JSON: ${a.error}`,i);try{await Z(a.templateConfig)}catch(f){return await this.renderAsErrorPng(`Failed to load TemplateConfig assets: ${f.message}`,i)}}let c=O(a.source,t.data);if(!t.allowScripts)return await this.htmlRenderer.render(c,i);let u=this.createContainer();u.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let p=document.createElement("div");p.style.cssText="display: inline-block;",u.appendChild(p);try{p.innerHTML=c,await this.runHtmlTemplateScripts(p,n);for(let f of Array.from(p.querySelectorAll("script")))try{f.remove()}catch{}try{typeof globalThis.requestAnimationFrame=="function"&&await new Promise(f=>globalThis.requestAnimationFrame(()=>f()))}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}return await this.htmlRenderer.render(p.innerHTML,i)}finally{this.removeContainer(u)}}async renderSvelteTemplate(t,n,i,o){let{templateRef:s,source:a}=this.getTemplateSource(n,t.type,t.template);if(!a)return await this.renderAsErrorPng(`Missing md2x template: ${s||t.template}`,o);let c=X(a);if(t.allowTemplateAssets){if(c.error)return await this.renderAsErrorPng(`Invalid TemplateConfig JSON: ${c.error}`,o);try{await Z(c.templateConfig)}catch(A){return await this.renderAsErrorPng(`Failed to load TemplateConfig assets: ${A.message}`,o)}}let u;try{u=await this.ensureSvelteCompiler(i)}catch(A){return await this.renderAsErrorPng(`Svelte compiler unavailable: ${A.message}`,o)}let p=u?.compile||u?.default?.compile||u?.svelte?.compile;if(typeof p!="function")return await this.renderAsErrorPng("Svelte compiler not available (missing compile())",o);let f=O(c.source,t.data),h;try{try{h=p(f,{filename:s||t.template||"md2x.svelte",generate:"client"})}catch{h=p(f,{filename:s||t.template||"md2x.svelte",generate:"dom"})}}catch(A){return await this.renderAsErrorPng(`Failed to compile Svelte template: ${A.message}`,o)}let d=String(h?.js?.code||""),w=String(h?.css?.code||"");if(!d.trim())return await this.renderAsErrorPng("Svelte compile returned no JS output",o);let m=i?.svelteBase||"https://esm.sh/svelte@5/",T=Ee(d,m),E=this.createContainer();E.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let y=document.createElement("div");y.style.cssText="display: inline-block;",E.appendChild(y);let b=null,
|
|
11
|
-
`),document.head.appendChild(
|
|
10
|
+
</div>`;return await this.htmlRenderer.render(i,n)}async runHtmlTemplateScripts(t,n){let i=n??{},o=Array.from(t.querySelectorAll("script")),s=a=>{let c=String(a||"").trim();if(!c)return null;if(typeof i[c]=="string")return i[c];try{let u=new URL(c,document.baseURI).href;if(typeof i[u]=="string")return i[u]}catch{}return null};for(let a of o){let c=a.parentNode;if(!c)continue;if(String(a.getAttribute("type")||"").trim().toLowerCase()==="module")throw new Error('md2x html template: <script type="module"> is not supported for PNG rendering');let p=a.getAttribute("src");if(p){let h=s(p);if(h==null)throw new Error(`md2x html template: external <script src="${p}"> is not supported unless it is provided via templateFiles`);let d=document.createElement("script");for(let w of Array.from(a.attributes||[])){let m=String(w?.name||"");if(m&&!(m==="src"||m==="async"||m==="defer"))try{d.setAttribute(m,w.value)}catch{}}d.textContent=String(h||""),c.replaceChild(d,a);continue}let f=document.createElement("script");for(let h of Array.from(a.attributes||[])){let d=String(h?.name||"");if(d&&!(d==="async"||d==="defer"))try{f.setAttribute(d,h.value)}catch{}}f.textContent=a.textContent||"",c.replaceChild(f,a)}}async renderHtmlTemplate(t,n,i){let{templateRef:o,source:s}=this.getTemplateSource(n,t.type,t.template);if(!s)return await this.renderAsErrorPng(`Missing md2x template: ${o||t.template}`,i);let a=X(s);if(t.allowTemplateAssets){if(a.error)return await this.renderAsErrorPng(`Invalid TemplateConfig JSON: ${a.error}`,i);try{await Z(a.templateConfig)}catch(f){return await this.renderAsErrorPng(`Failed to load TemplateConfig assets: ${f.message}`,i)}}let c=O(a.source,t.data);if(!t.allowScripts)return await this.htmlRenderer.render(c,i);let u=this.createContainer();u.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let p=document.createElement("div");p.style.cssText="display: inline-block;",u.appendChild(p);try{p.innerHTML=c,await this.runHtmlTemplateScripts(p,n);for(let f of Array.from(p.querySelectorAll("script")))try{f.remove()}catch{}try{typeof globalThis.requestAnimationFrame=="function"&&await new Promise(f=>globalThis.requestAnimationFrame(()=>f()))}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}return await this.htmlRenderer.render(p.innerHTML,i)}finally{this.removeContainer(u)}}async renderSvelteTemplate(t,n,i,o){let{templateRef:s,source:a}=this.getTemplateSource(n,t.type,t.template);if(!a)return await this.renderAsErrorPng(`Missing md2x template: ${s||t.template}`,o);let c=X(a);if(t.allowTemplateAssets){if(c.error)return await this.renderAsErrorPng(`Invalid TemplateConfig JSON: ${c.error}`,o);try{await Z(c.templateConfig)}catch(A){return await this.renderAsErrorPng(`Failed to load TemplateConfig assets: ${A.message}`,o)}}let u;try{u=await this.ensureSvelteCompiler(i)}catch(A){return await this.renderAsErrorPng(`Svelte compiler unavailable: ${A.message}`,o)}let p=u?.compile||u?.default?.compile||u?.svelte?.compile;if(typeof p!="function")return await this.renderAsErrorPng("Svelte compiler not available (missing compile())",o);let f=O(c.source,t.data),h;try{try{h=p(f,{filename:s||t.template||"md2x.svelte",generate:"client"})}catch{h=p(f,{filename:s||t.template||"md2x.svelte",generate:"dom"})}}catch(A){return await this.renderAsErrorPng(`Failed to compile Svelte template: ${A.message}`,o)}let d=String(h?.js?.code||""),w=String(h?.css?.code||"");if(!d.trim())return await this.renderAsErrorPng("Svelte compile returned no JS output",o);let m=i?.svelteBase||"https://esm.sh/svelte@5/",T=Ee(d,m),E=this.createContainer();E.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let y=document.createElement("div");y.style.cssText="display: inline-block;",E.appendChild(y);let b=null,S=null,R=null;try{try{R=URL.createObjectURL(new Blob([T],{type:"text/javascript"}))}catch(F){throw new Error("Unable to create Blob URL for compiled Svelte module: "+F.message)}let g=(await J(R))?.default;if(typeof g!="function")throw new Error("Compiled Svelte module has no default component export");let v=await J(se(m)),I=v?.mount;if(S=typeof v?.unmount=="function"?v.unmount:null,typeof I!="function")throw new Error("Svelte runtime mount() not available");b=I(g,{target:y});try{typeof globalThis.requestAnimationFrame=="function"&&await new Promise(F=>globalThis.requestAnimationFrame(()=>F()))}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}let B=(w.trim()?`<style>${w}</style>`:"")+y.innerHTML;return await this.htmlRenderer.render(B,o)}catch(A){return await this.renderAsErrorPng(`Failed to render Svelte template: ${A.message}`,o)}finally{try{b&&S&&S(b)}catch{}try{R&&URL.revokeObjectURL(R)}catch{}this.removeContainer(E)}}async renderVueTemplate(t,n,i,o){let{templateRef:s,source:a}=this.getTemplateSource(n,t.type,t.template);if(!a)return await this.renderAsErrorPng(`Missing md2x template: ${s||t.template}`,o);let c=X(a);try{await this.ensureVueRuntime(i)}catch(y){return await this.renderAsErrorPng(`Vue runtime unavailable: ${y.message}`,o)}if(t.allowTemplateAssets){if(c.error)return await this.renderAsErrorPng(`Invalid TemplateConfig JSON: ${c.error}`,o);try{await Z(c.templateConfig)}catch(y){return await this.renderAsErrorPng(`Failed to load TemplateConfig assets: ${y.message}`,o)}}let u=globalThis.Vue,p=globalThis["vue3-sfc-loader"];if(!u||!p||typeof p.loadModule!="function")return await this.renderAsErrorPng("Vue runtime not available (missing Vue / vue3-sfc-loader)",o);let f=[],h=O(c.source,t.data),d=s||t.template,w={moduleCache:{vue:u},getFile:async y=>{if(y===d||y.endsWith("/"+d)||y.endsWith("\\"+d))return h;let b=n??{};if(typeof b[y]=="string")return b[y];try{let S=new URL(y,document.baseURI).href;if(typeof b[S]=="string")return b[S]}catch{}return null},addStyle:y=>{typeof y=="string"&&y.trim()&&f.push(y)}},m=this.createContainer();m.style.cssText="position: absolute; left: -9999px; top: -9999px; display: inline-block; background: transparent; padding: 0; margin: 0;";let T=document.createElement("div");T.style.cssText="display: inline-block;",m.appendChild(T);let E=null;try{let y=await p.loadModule(d,w);E=u.createApp({render:()=>u.h(y)}),E.mount(T);try{await u.nextTick()}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}let S=(f.length?`<style>${f.join("\\n")}</style>`:"")+T.innerHTML;return await this.htmlRenderer.render(S,o)}finally{try{E&&typeof E.unmount=="function"&&E.unmount()}catch{}this.removeContainer(m)}}async render(t,n){let i=typeof t=="string"?t:t.code;this.validateInput(i);let o=be(i),s=typeof t=="string"?void 0:t.templateFiles,a=typeof t=="string"?void 0:t.cdn;return o.type==="html"?await this.renderHtmlTemplate(o,s,n):o.type==="vue"?await this.renderVueTemplate(o,s,a,n):o.type==="svelte"?await this.renderSvelteTemplate(o,s,a,n):await this.renderAsErrorPng(`Unsupported md2x type: ${o.type}`,n)}};var ae=class extends oe{async mountToDom(e,t,n){let i=typeof e=="string"?e:e.code;this.validateInput(i);let o=be(i),s=typeof e=="string"?void 0:e.templateFiles,a=typeof e=="string"?void 0:e.cdn,{templateRef:c,source:u}=this.getTemplateSource(s,o.type,o.template);if(!u){let d=document.createElement("div");return d.textContent=`Missing md2x template: ${c||o.template}`,{root:d,cleanup:()=>{}}}let p=X(u);if(o.allowTemplateAssets){if(p.error){let d=document.createElement("div");return d.textContent=`Invalid TemplateConfig JSON: ${p.error}`,{root:d,cleanup:()=>{}}}await Z(p.templateConfig)}let f=n??(()=>{let d=document.createElement("div");return d.style.cssText="position: absolute; left: 0; top: 0; display: inline-block; background: transparent; padding: 0; margin: 0;",document.body.appendChild(d),d})();try{f.innerHTML=""}catch{}if(o.type==="html"){let d=document.createElement("div");d.style.cssText="display: inline-block;",f.appendChild(d);let w=O(p.source,o.data);d.innerHTML=w;let m=()=>{try{d.remove()}catch{}n||this.removeContainer(f)};return o.allowScripts&&await this.runHtmlTemplateScripts(d,s),{root:f,cleanup:m}}if(o.type==="vue"){try{await this.ensureVueRuntime(a)}catch(g){let v=document.createElement("div");return v.textContent=`Vue runtime unavailable: ${g.message}`,{root:v,cleanup:()=>{}}}let d=globalThis.Vue,w=globalThis["vue3-sfc-loader"];if(!d||!w||typeof w.loadModule!="function"){let g=document.createElement("div");return g.textContent="Vue runtime not available (missing Vue / vue3-sfc-loader)",{root:g,cleanup:()=>{}}}let m=[],T=O(p.source,o.data),E=c||o.template,y={moduleCache:{vue:d},getFile:async g=>{if(g===E||g.endsWith("/"+E)||g.endsWith("\\"+E))return T;let v=s??{};if(typeof v[g]=="string")return v[g];try{let I=new URL(g,document.baseURI).href;if(typeof v[I]=="string")return v[I]}catch{}return null},addStyle:g=>{typeof g=="string"&&g.trim()&&m.push(g)}},b=document.createElement("div");b.style.cssText="display: inline-block;",f.appendChild(b);let S=null,R=null;try{let g=await w.loadModule(E,y);S=d.createApp({render:()=>d.h(g)}),S.mount(b);try{await d.nextTick()}catch{}try{document.fonts?.ready&&await document.fonts.ready}catch{}m.length&&(R=document.createElement("style"),R.textContent=m.join(`
|
|
11
|
+
`),document.head.appendChild(R))}catch(g){try{b.textContent=`Failed to mount Vue template: ${g.message}`}catch{}}return{root:f,cleanup:()=>{try{S&&typeof S.unmount=="function"&&S.unmount()}catch{}try{b.remove()}catch{}try{R&&R.remove()}catch{}n||this.removeContainer(f)}}}if(o.type==="svelte"){let d;try{d=await this.ensureSvelteCompiler(a)}catch(B){let F=document.createElement("div");return F.textContent=`Svelte compiler unavailable: ${B.message}`,{root:F,cleanup:()=>{}}}let w=d?.compile||d?.default?.compile||d?.svelte?.compile;if(typeof w!="function"){let B=document.createElement("div");return B.textContent="Svelte compiler not available (missing compile())",{root:B,cleanup:()=>{}}}let m=O(p.source,o.data),T;try{try{T=w(m,{filename:c||o.template||"md2x.svelte",generate:"client"})}catch{T=w(m,{filename:c||o.template||"md2x.svelte",generate:"dom"})}}catch(B){let F=document.createElement("div");return F.textContent=`Failed to compile Svelte template: ${B.message}`,{root:F,cleanup:()=>{}}}let E=String(T?.js?.code||""),y=String(T?.css?.code||"");if(!E.trim()){let B=document.createElement("div");return B.textContent="Svelte compile returned no JS output",{root:B,cleanup:()=>{}}}let b=a?.svelteBase||"https://esm.sh/svelte@5/",S=Ee(E,b),R=document.createElement("div");R.style.cssText="display: inline-block;",f.appendChild(R);let A=null,g=null,v=null,I=null;try{v=URL.createObjectURL(new Blob([S],{type:"text/javascript"}));let F=(await J(v))?.default;if(typeof F!="function")throw new Error("Compiled Svelte module has no default component export");let Q=await J(se(b)),M=Q?.mount;if(g=typeof Q?.unmount=="function"?Q.unmount:null,typeof M!="function")throw new Error("Svelte runtime mount() not available");A=M(F,{target:R}),y.trim()&&(I=document.createElement("style"),I.textContent=y,document.head.appendChild(I))}catch(B){try{R.textContent=`Failed to mount Svelte template: ${B.message}`}catch{}}return{root:f,cleanup:()=>{try{A&&g&&g(A)}catch{}try{v&&URL.revokeObjectURL(v)}catch{}try{R.remove()}catch{}try{I&&I.remove()}catch{}n||this.removeContainer(f)}}}let h=document.createElement("div");return h.textContent=`Unsupported md2x type: ${o.type}`,{root:h,cleanup:()=>{}}}};x();function Xt(){return globalThis}function Zt(){let r=Xt();return r.__md2x_renderer_registry__||(r.__md2x_renderer_registry__=new Map),r.__md2x_renderer_registry__}function Xe(r){Zt().set(r.type,r)}Xe(new ae);})();
|
|
12
12
|
/*! Bundled license information:
|
|
13
13
|
|
|
14
14
|
ieee754/index.js:
|