@pacem/pacem-foundation 1.0.6-ricci → 2.0.0-abel

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v1.0.6-ricci (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
6
- !function(){"use strict";Number.prototype.isCloseTo=function(t,e=14){const r=Number(`1e-${e}`);return this>t-r&&this<t+r},Number.prototype.roundoff=function(t=14){return parseFloat(this.toFixed(t))},Number.prototype.clamp=function(t,e){let r=this;return null==t||isNaN(t)||(r=Math.max(r,t)),null==e||isNaN(e)||(r=Math.min(r,e)),r},Number.prototype.toBase62=function(){for(var t=this,e="";0!=t;){e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(t%62)+e,t=Math.floor(t/62)}return e},Number.prototype.toBase36=function(){return this.toString(36)};const t=/^\/Date\([\d]+\)\/$/i;class Dates{static parse(e){let r;return"string"==typeof e?(r=t.test(e)?parseInt(e.substring(6)):Date.parse(e),new Date(r)):"number"==typeof e?new Date(e):e}static isLeapYear(t){return t%4==0&&t%100!=0||t%400==0}static daysInMonth(t,e){return[31,Dates.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),n=new Date(t),s=n.getMonth()+e,a=0;for(;s<0;)s+=12,a--;return n.setDate(1),n.setMonth(s%12),n.setFullYear(n.getFullYear()+a+Math.floor(s/12)),n.setDate(Math.min(r,Dates.daysInMonth(n.getFullYear(),n.getMonth()))),n}static addDays(t,e){return new Date(t.valueOf()+864e5*e)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}}class NullChecker{static isNull(t){return null==t}static isEmpty(t){try{return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t||"object"==typeof t&&0===Object.keys(t).length&&!Dates.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch(t){return!1}}static isNullOrEmpty(t){return NullChecker.isNull(t)||NullChecker.isEmpty(t)}}function e(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)&&(t.constructor===Object||void 0===t.constructor)}function r(t,n){const s=t;for(const t of Object.keys(n)){const a=n[t],i=s[t];e(a)?s[t]=r(e(i)?i:{},a):Array.isArray(a)?s[t]=a.slice():s[t]=a}return s}Array.prototype.distinct=function(){return Array.from(new Set(this))},Array.prototype.union=function(t){const e=NullChecker.isNullOrEmpty(this),r=NullChecker.isNullOrEmpty(t);return e&&r?[]:r?this.slice():e?t.slice():this.concat(t).distinct()},Array.prototype.moveWithin=function(t,e){const r="Index must be greater or equal than 0 and less or equal than the length of the array.";var n=this;if(t<0||t>n.length)throw new Error(r);if(e<0||e>n.length)throw new Error(r);n.splice(e,0,Array.prototype.splice.apply(n,[t,1])[0])},Array.prototype.equalsContent=function(t){if(null==t||this.length!==t.length)return!1;for(let e=0;e<this.length;e++)if(this[e]!==t[e])return!1;return!0},Array.prototype.cloneFrom=function(t){if(null==t)throw"Cannot clone array from null object.";const e=t.length;var r=this.length!==t.length;for(let n=0;n<e;n++){const e=t[n];this.length>n?this[n]!==e&&(this[n]=e,r=!0):(Array.prototype.push.apply(this,[e]),r=!0)}r&&this.splice(e)};class DeepMerger{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},r(e,t)}}class Blobs{static blobToDataURL(t){return new Promise((e,r)=>{const n=new FileReader;n.onload=t=>{e(t.target.result)},n.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length;const r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){const r=Blobs._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){const e=t.indexOf(",");if(-1===e)return Blobs.base64ToBlob(t);{const r=t.substring(e+1),n=t.substring(0,e).match(/:(.*?);/)[1];return Blobs.base64ToBlob(r,{type:n})}}static async blobToText(t,e){const r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",n,s=63){let a=r.toLowerCase();const i=()=>`${e};charset=${a}`;switch(a){case"utf-8":{const e=(new TextEncoder).encode(t),r=n?[new Uint8Array([239,187,191]),e]:[e];return new Blob(r,{type:i()})}case"utf-16":a="utf-16le",n??=!0;case"utf-16le":case"utf-16be":{const e="utf-16be"!==a,r=n?1:0,s=new ArrayBuffer(2*(t.length+r)),o=new DataView(s);n&&o.setUint16(0,65279,e);for(let n=0;n<t.length;n++)o.setUint16(2*(n+r),t.charCodeAt(n),e);return new Blob([s],{type:i()})}case"ascii":case"iso-8859-1":case"latin1":{const e="ascii"===a?127:255,n=new Uint8Array(t.length),o=s>0;for(let a=0;a<t.length;a++){const i=t.charCodeAt(a);if(i>e){if(!o)throw new Error(`Character "${t[a]}" cannot be encoded in ${r}.`);n[a]=s}else n[a]=i}return new Blob([n],{type:i()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}}const n=(t,e)=>{const r=t.match(e);return r?r[2]:null};const s=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,a=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,i=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,o=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,c=/^#[a-f0-9]{6}$/,l=/^#[a-f0-9]{3}$/;function u(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"r"in t&&"g"in t&&"b"in t&&"number"==typeof t.r&&"number"==typeof t.b&&"number"==typeof t.g&&(t.a??=1,t.r>=0&&t.r<=1&&t.g>=0&&t.g<=1&&t.b>=0&&t.b<=1&&t.a>=0&&t.a<=1)}function h(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&"number"==typeof t.h&&"number"==typeof t.s&&"number"==typeof t.l&&(t.a??=1,t.h>=0&&t.h<=360&&t.s>=0&&t.s<=1&&t.l>=0&&t.l<=1&&t.a>=0&&t.a<=1)}const d={adjustRgbChannel:t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),adjustRgbChannelInv:t=>t<=.00304?12.92*t:1.055*(Math.pow(t,1/2.4)-.055),adjustRgb:t=>({r:d.adjustRgbChannel(t.r),g:d.adjustRgbChannel(t.g),b:d.adjustRgbChannel(t.b),a:t.a}),adjustRgbInv:t=>({r:d.adjustRgbChannelInv(t.r),g:d.adjustRgbChannelInv(t.g),b:d.adjustRgbChannelInv(t.b),a:t.a}),X:t=>.4125*t.r+.3576*t.g+.1804*t.b,Y:t=>.2126*t.r+.7152*t.g+.0722*t.b,Z:t=>.0193*t.r+.1191*t.g+.9503*t.b,relativeLuminance:t=>{const e=d.adjustRgb(t);return d.Y(e)},rgbToCieXYZ:t=>{const e=d.adjustRgb(t);return{x:d.X(e),y:d.Y(e),z:d.Z(e),a:t.a}},cieXYZToRgb:t=>{const e=3.241*t.x-1.5374*t.y-.4986*t.z,r=-.9692*t.x+1.876*t.y+.0416*t.z,n=.0556*t.x-.204*t.y+1.057*t.z;return d.adjustRgbInv({r:e,g:r,b:n,a:t.a})},contrastRatio:(t,e)=>{const r=d.relativeLuminance(t)+.05,n=d.relativeLuminance(e)+.05;return r>n?r/n:n/r}};function p(t){return t.toString(16).padStart(2,"0")}class Colors{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){const e=t=>Math.min(1,Math.max(0,t));return null==t[3]&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),i.test(t)){let e=i.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(o.test(t)){let e=o.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(c.test(t)){let e=c.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(l.test(t)){let e=l.exec(t)[0],r=e.substr(1,1),n=e.substr(2,1),s=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+n+n),parseInt("0x"+s+s),1]))}if(s.test(t)){let e=s.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3])};return this.rgb(r)}if(a.test(t)){let e=a.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3]),a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){const e=function(t){const e=t.r,r=t.g,n=t.b;return(.5*(Math.max(e,r,n)+Math.min(e,r,n))).clamp(0,1)}(t),r=function(t,e){const r=t.r,n=t.g,s=t.b,a=Math.max(r,n,s),i=Math.min(r,n,s);return(0===e||1===e?0:(a-i)/(1-Math.abs(2*e-1))).clamp(0,1)}(t,e),n=function(t){const e=t.r,r=t.g,n=t.b,s=Math.max(e,r,n),a=Math.min(e,r,n);let i=0;return s!==a&&(i=s===e?((r-n)/(s-a)*60+360)%360:s===r?((n-e)/(s-a)*60+120)%360:((e-r)/(s-a)*60+240)%360),i.clamp(0,360)}(t);return{h:n,s:r,l:e,a:t.a}}static cieXYZ(t){return h(t)&&(t=this.rgb(t)),d.rgbToCieXYZ(t)}static rgb(t){if(!h(t)){const e=d.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}{const e=t.h,r=t.s,n=t.l,s=e/60,a=(1-Math.abs(2*n-1))*r,i=a*(1-Math.abs(s%2-1)),o=n-a/2,c=(e,r,n)=>this._clampRGB([e+o,r+o,n+o,t.a]);if(s<=1)return c(a,i,0);if(s<=2)return c(i,a,0);if(s<=3)return c(0,a,i);if(s<=4)return c(0,i,a);if(s<=5)return c(i,0,a);if(s<=6)return c(a,0,i)}}static stringify(t,e=1){if(h(t)){e??=1,t.a??=1;const r="number"==typeof e?e:1;return`hsla(${t.h.roundoff(r)},${(100*t.s).roundoff(r)}%,${(100*t.l).roundoff(r)}%,${t.a.roundoff()})`}if(u(t)){e??=!0,t.a??=1;const r="boolean"==typeof e?e:!!e,n=Math.round(255*t.r),s=Math.round(255*t.g),a=Math.round(255*t.b),i=t.a.roundoff();return 1===i?r?("#"+p(n)+p(s)+p(a)).toUpperCase():`rgb(${n},${s},${a})`:`rgba(${n},${s},${a},${i})`}}static contrastRatio(t,e){return h(t)&&(t=this.rgb(t)),h(e)&&(e=this.rgb(e)),d.contrastRatio(t,e)}static luminance(t){return h(t)&&(t=Colors.rgb(t)),d.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(u(t)){const r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(u(t)){const r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,n){r??=.5,n??=r;const s=(r+n).roundoff(),a=(r/s).roundoff(),i=(n/s).roundoff(),o=u(t),c=h(t),l=t=>u(t)||h(t)?Colors.cieXYZ(t):t;t=l(t),e=l(e);const d={x:(t.x*a+e.x*i).roundoff(),y:(t.y*a+e.y*i).roundoff(),z:(t.z*a+e.z*i).roundoff(),a:(t.a*a+e.a*i).roundoff()};return o?Colors.rgb(d):c?Colors.hsl(Colors.rgb(d)):d}}const g=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function f(t){const e=[];let r=t.match(g);return r&&r.length>0&&r.forEach(t=>e.push(parseFloat(t))),e}class Angle{static isAngle(t){return"object"==typeof t&&"vertex"in t&&Point.isPoint(t.vertex)&&"start"in t&&Point.isPoint(t.start)&&"end"in t&&Point.isPoint(t.end)}static value(t){if(NullChecker.isNullOrEmpty(t)||!Angle.isAngle(t))return Number.NaN;const{vertex:e,start:r,end:n}=t;return Angle.angleBetween(e,r,n)}static angleBetween(t,e,r){const n=e.x-t.x,s=e.y-t.y,a=r.x-t.x,i=r.y-t.y,o=n*a+s*i,c=n*i-s*a;return-Math.atan2(c,o)}}class Size{static parse(t){let e=f(t);if(e&&2===e.length)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return"object"==typeof t&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}}class Point{static parse(t){let e=f(t);if(e&&2===e.length)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return"object"==typeof t&&"x"in t&&"number"==typeof t.x&&"y"in t&&"number"==typeof t.y}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}}class Matrix2D{static isIdentity(t){return 1===t.a&&1===t.d&&0===t.b&&0===t.f&&0===t.c&&0===t.e}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){const r=Math.cos(e),n=Math.sin(e);return Matrix2D.multiply(t,{a:r,b:n,c:-n,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?"number"==typeof e?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:"number"==typeof e?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){const e=this.det(t);if(0===e)return null;const r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){const r=Math.sqrt(t.a*t.a+t.c*t.c),n=Math.sqrt(t.b*t.b+t.d*t.d),s=0!=r?t.a/r:0,a=0!=r?t.c/r:0,i=Math.atan2(a,s),{x:o,y:c}=e;return{scaleX:r,scaleY:n,rotation:i,translation:{x:t.e-o*(r*s-1)+c*r*a,y:t.f-c*(n*s-1)-o*n*a}}}static fromTransform([t,e,r],[n,s,a]){const i=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(i)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");const o=1/i;return{a:o*(n.x*(e.y-r.y)+s.x*(r.y-t.y)+a.x*(t.y-e.y)),b:o*(n.y*(e.y-r.y)+s.y*(r.y-t.y)+a.y*(t.y-e.y)),c:o*(n.x*(r.x-e.x)+s.x*(t.x-r.x)+a.x*(e.x-t.x)),d:o*(n.y*(r.x-e.x)+s.y*(t.x-r.x)+a.y*(e.x-t.x)),e:o*(n.x*(e.x*r.y-r.x*e.y)+s.x*(r.x*t.y-t.x*r.y)+a.x*(t.x*e.y-e.x*t.y)),f:o*(n.y*(e.x*r.y-r.x*e.y)+s.y*(r.x*t.y-t.x*r.y)+a.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}}class Rect{static parse(t){let e=f(t);if(e&&4===e.length)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return Point.isPoint(t)&&Size.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,n){let s=1;s=t.width/t.height>=e.width/e.height?e.width/t.width:e.height/t.height;const a=t.width*s,i=t.height*s,o=this._align({x:t.x,y:t.y,width:a,height:i},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _cover(t,e,r,n){let s=1;s=t.width/t.height<e.width/e.height?e.width/t.width:e.height/t.height;const a=t.width*s,i=t.height*s,o=this._align({x:t.x,y:t.y,width:a,height:i},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _align(t,e,r,n){let s=0,a=0;switch(r){case"left":s=e.x-t.x;break;case"right":s=e.x+e.width-t.width-t.x;break;default:s=e.x+.5*e.width-.5*t.width-t.x}switch(n){case"top":a=e.y-t.y;break;case"bottom":a=e.y+e.height-t.height-t.y;break;default:a=e.y+.5*e.height-.5*t.height-t.y}return{x:s,y:a}}static findTransform(t,e,r="stretch",n="center",s="middle"){switch(r){case"contain":return this._contain(t,e,n,s);case"cover":return this._cover(t,e,n,s);default:return this._stretch(t,e)}}static intersect(...t){const e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var n=r[0],s=1;s<r.length;s++){const t=r[s],a=Math.max(t.x,n.x),i=Math.max(t.y,n.y),o=Math.min(t.x+t.width,n.x+n.width)-a,c=Math.min(t.y+t.height,n.y+n.height)-i;if(o<0||c<=0)return e;n={x:a,y:i,width:o,height:c}}return n}static expand(t,...e){const r=Array.from(e||[]);let n=t.x,s=t.y,a=n,i=s;Rect.isRect(t)&&(a+=t.width,i+=t.height);for(let t of r)n=Math.min(t.x,n),s=Math.min(t.y,s),a=Math.max(t.x,a),i=Math.max(t.y,i);return{x:n,y:s,width:a-n,height:i-s}}}const y={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"};class Imaging{static async loadImage(t){const e=await fetch(t);if(!e.ok)return null;return await e.blob()}static async resizeImage(t,e,r,n){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");"string"==typeof t&&(t=await Imaging.loadImage(t));const s=await self.createImageBitmap(t),a=s.width,i=s.height,o=new OffscreenCanvas(a,i),c=o.getContext("2d");c.imageSmoothingEnabled=c.mozImageSmoothingEnabled=c.oImageSmoothingEnabled=c.webkitImageSmoothingEnabled=!0;const{quality:l,type:u,mode:h,align:d,valign:p,background:g}=Object.assign({},y,n??{}),f={width:a,height:i,x:0,y:0},x={x:0,y:0,width:e,height:r},m=Rect.findTransform(f,x,h,d,p);o.width=e,o.height=r,g&&(c.fillStyle=g,c.fillRect(0,0,o.width,o.height)),c.setTransform(m),c.drawImage(s,0,0);return await o.convertToBlob({quality:l,type:u})}}class Keys{static#t;static uniqueId(){let t=Keys.#t||Date.now();return Keys.#t=++t}static uniqueCode(){return Keys.uniqueId().toBase62()}static randomString(t){let e="";do{e+=(62*Math.random()).toBase62()}while(e.length<t);return e}}function x(t,e){const r=t.length,n=e.length,s=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let a=1;a<=r;a++)for(let r=1;r<=n;r++)t[a-1]===e[r-1]?s[a][r]=s[a-1][r-1]+1:s[a][r]=Math.max(s[a-1][r],s[a][r-1]);return s}function m(t,e,r,n=""){const s=t.length,a=e.length,i=[];let o=s,c=a,l=null;const u=()=>{l&&(i.push(l),l=null)};for(;o>0||c>0;){var h=null;let s=null;o>0&&c>0&&t[o-1]===e[c-1]?(h="=",s=t[o-1],o--,c--):c>0&&(0===o||r[o][c-1]>=r[o-1][c])?(h="+",s=e[c-1],c--):o>0&&(0===c||r[o-1][c]>r[o][c-1])&&(h="-",s=t[o-1],o--),h&&null!==s?l&&l.type===h?l.value=s+(l.value?n:"")+l.value:(u(),l={type:h,value:s}):u()}return u(),i.reverse()}class LexerClass{tokenize(t,e){const r=[];for(;t;){const n=t.length;for(let n of e){const e=n.exec(t,this),s=e?.length;if(s>0){Array.prototype.push.apply(r,e);const n=e[s-1];t=t.substr((n.index||0)+n.raw.length);break}}if(t.length>=n)throw new Error(`Cannot parse\n"${t}"\n using the provided grammar.`)}return r}}let b=class Parser{constructor(t=new LexerClass){this._lexer=t}parse(t,e,r){const n=this._lexer.tokenize(t,e);return r.render(n)}};function w(t){return(t??"").replace(/</g,"&lt;")}function k(t){return t?.index||void 0}function C(t){return t?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function $(t,e,r){const n=e.exec(t);return n&&n.length?r(n):null}const N=/(<!--)([\s\S]*?)(-->|$)/,M=/^ {0,3}(={3,}|_{3,}|-{3,})(\r?\n|$)/,R=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,S=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,I=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,v=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,A=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,L=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,_=/^( {0,3}([-+]).*\r?\n|$)((?!(?: {0,3}(?:\d+[.\)]|\r?\n\S))).*(\r?\n|$))*/,B=/^( {0,3}(\d+[.\)]).*\r?\n|$)((?!(?: {0,3}(?:[+-]|\r?\n\S))).*(\r?\n|$))*/,z=/^(?:[-+*]|\d+[.\)])/m,E=/^(?! {4,})(.+(\n(?! {0,3}```)(?! {0,3}([-+]|\d+[.\)]))(?! {4,})(?! {0,3}>).+)*)/,O=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,T=/!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,D=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,j=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,H=/(\*\*?|__?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1/,P=/(~~?|__?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,F=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,U=/^\s+/,q=/ {2,}\r?\n/,Y=/^[^\r\n]+/;var G,Q;function X(t=[]){const e={[Q.Comment]:{exec:(t,e)=>$(t,N,r=>{const n=k(r),s=[{type:G.Html,index:n,raw:r[0],text:r[2]}];if(n>0){const r=t.substr(0,n),a=e.tokenize(r,g);Array.prototype.unshift.apply(s,a)}return s})},[Q.Reference]:{exec:t=>$(t,O,t=>{const e=k(t),r=t[0],n=r,s="!"===t[1],a=t[2],i=t[3],o=t[4];return[{type:G.Reference,index:e,raw:r,text:n,id:a,image:s,url:i,title:o}]})}},r=[],n=[],s={};for(let e of t){let t,a="inline";switch("type"in e?(a=e.type,t=e.rule):t=e,a){case"block":r.push(t);break;case"code":if("lang"in e){const r=e.lang.toLowerCase();(s[r]=s[r]||[]).push(t)}break;default:const a={exec:(e,r)=>{const n=t.exec(e,r);return o(e,n,r),n}};n.push(a)}}const a={[Q.Text]:{exec:t=>$(t,Y,t=>{const e=t[0],r=e;return[{index:k(t),raw:e,text:r,type:G.Text}]})},[Q.Space]:{exec:t=>$(t,U,t=>{const e=t[0];return[{type:G.Space,raw:e,text:e}]})}},i={[Q.ImageOrLink]:{exec:(t,e)=>c(t,T,e,t=>{const r=k(t),n=t[0],s="!"===n.charAt(0),a=t[1],i=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\[/.test(t)&&/\]$/.test(t)))return/^\(/.test(t)&&/\)$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2]),o=C(function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\(/.test(t)&&/\)$/.test(t)))return/^\[/.test(t)&&/\]$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2])??a);return s?[{index:r,type:i?G.Image:G.ImageLike,raw:n,text:a,src:i,ref:o,tokens:e.tokenize(a,l)}]:[{index:r,type:i?G.Link:G.LinkLike,raw:n,text:a,href:i,ref:o,tokens:e.tokenize(a,l)}]})},[Q.Code]:{exec:(t,e)=>c(t,j,e,t=>{const e=w(t[1]);return[{type:G.Code,raw:t[0],text:e,index:k(t)}]})},[Q.EmphasizedLink]:{exec:(t,e)=>c(t,D,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=t[1].length>1?G.Bold:G.Italic,n=t[2];return[{index:k(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Q.Emphasize]:{exec:(t,e)=>c(t,H,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=t[1].length>1?G.Bold:G.Italic,n=t[2];return[{index:k(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Q.StrikeThrough]:{exec:(t,e)=>c(t,P,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=G.StrikeThrough,n=t[2];return[{index:k(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Q.Quote]:{exec:(t,e)=>c(t,F,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=G.Quote,n=t[2];return[{index:k(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Q.LineBreak]:{exec:(t,e)=>c(t,q,e,t=>{const e=t[0],r=e;return[{index:k(t),raw:e,text:r,type:G.LineBreak}]})}},o=(t,e,r)=>{const n=e?.length>0&&e[0].index;if(n>0){const s=t.substr(0,n),a=r.tokenize(s,l)||[];Array.prototype.unshift.apply(e,a)}},c=(t,e,r,n)=>{const s=$(t,e,r=>{if(e!=j){const e=j.exec(t);if(e&&e.length&&e.index<r.index)return null}return n(r)});return o(t,s,r),s},l=Object.values(i);Array.prototype.push.apply(l,n),l.push(a[Q.Text],a[Q.Space]);const u=t=>{const e=[a[Q.Text],a[Q.Space]],r=t?.toLowerCase()||"";return r&&r in s&&Array.prototype.unshift.apply(e,s[r]),e},h={[Q.Paragraph]:{exec:(t,e)=>$(t,E,t=>{const r=t[0],n=r;return[{type:G.Paragraph,raw:r,text:n,tokens:e.tokenize(n,l)}]})},[Q.Space]:a[Q.Space]},d=(t,e)=>{const r=/^ {0,3}(`{3,}|$|>|[+-]\s|\d+[.\)])/m.test(t)?g:l;return e.tokenize(t,r)},p={[Q.HorizontalRule]:{exec:(t,e)=>$(t,M,t=>{const e=t[0],r=e;return[{type:G.HorizontalRule,raw:e,text:r}]})},[Q.Heading]:{exec:(t,e)=>$(t,R,t=>{const r=t[2];return[{type:G.Heading,raw:t[0],text:r,level:t[1].length,ref:C(r),tokens:e.tokenize(r,l)}]})},[Q.Heading1]:{exec:(t,e)=>$(t,S,t=>{const r=t[1];return[{type:G.Heading,raw:t[0],text:r,level:1,ref:C(r),tokens:e.tokenize(r,l)}]})},[Q.Heading2]:{exec:(t,e)=>$(t,I,t=>{const r=t[1];return[{type:G.Heading,raw:t[0],text:r,level:2,ref:C(r),tokens:e.tokenize(r,l)}]})},[Q.CodeBlock]:{exec:(t,e)=>$(t,v,t=>{const r=t[0],n=w(r);return[{type:G.CodeBlock,raw:r,text:n,tokens:e.tokenize(n,[])}]})},[Q.Fences]:{exec:(t,e)=>$(t,A,t=>{const r=w(t[2]),n=t[1]?.toLowerCase();return[{type:G.CodeBlock,raw:t[0],text:r,lang:n,tokens:e.tokenize(r,u(n))}]})},[Q.BlockQuote]:{exec:(t,e)=>$(t,L,t=>{const r=t[0],n=r.replace(/^ {0,3}> */gm,"");return[{type:G.BlockQuote,raw:r,text:n,tokens:e.tokenize(n,[h[Q.Paragraph],h[Q.Space]])}]})},[Q.OrderedList]:{exec:(t,e)=>$(t,B,t=>{const r=t[0],n=r.replace(/^ {0,3}/gm,"").split(z).filter(t=>!NullChecker.isNullOrEmpty(t)).map(t=>t.trim());return[{type:G.OrderedList,start:parseInt(/\d/.exec(t[0])[0]),raw:r,text:r,tokens:n.map(t=>({type:G.ListItem,raw:t,text:t,tokens:d(t,e)}))}]})},[Q.UnorderedList]:{exec:(t,e)=>$(t,_,t=>{const r=t[0],n=r.replace(/^ {0,3}/gm,"").split(z).filter(t=>!NullChecker.isNullOrEmpty(t)).map(t=>t.trim());return[{type:G.UnorderedList,raw:r,text:r,tokens:n.map(t=>({type:G.ListItem,raw:t,text:t,tokens:d(t,e)}))}]})}},g=Object.values(p);return Array.prototype.push.apply(g,r),g.push(h[Q.Paragraph],h[Q.Space]),[e[Q.Comment],e[Q.Reference]].concat(g)}!function(t){t.Html="html",t.Text="text",t.Paragraph="paragraph",t.BlockQuote="blockquote",t.Space="space",t.Heading="heading",t.Bold="bold",t.Italic="italic",t.CodeBlock="codeblock",t.Code="code",t.Image="img",t.ImageLike="imglike",t.Link="link",t.LinkLike="linklike",t.LineBreak="br",t.StrikeThrough="strike",t.Quote="quote",t.HorizontalRule="hr",t.OrderedList="ol",t.UnorderedList="ul",t.ListItem="listitem",t.Reference="ref"}(G||(G={})),function(t){t[t.Comment=0]="Comment",t[t.Reference=1]="Reference",t[t.HorizontalRule=2]="HorizontalRule",t[t.Heading=3]="Heading",t[t.Heading1=4]="Heading1",t[t.Heading2=5]="Heading2",t[t.CodeBlock=6]="CodeBlock",t[t.Fences=7]="Fences",t[t.BlockQuote=8]="BlockQuote",t[t.OrderedList=9]="OrderedList",t[t.UnorderedList=10]="UnorderedList",t[t.Paragraph=11]="Paragraph",t[t.EmphasizedLink=12]="EmphasizedLink",t[t.ImageOrLink=13]="ImageOrLink",t[t.Emphasize=14]="Emphasize",t[t.StrikeThrough=15]="StrikeThrough",t[t.Quote=16]="Quote",t[t.Code=17]="Code",t[t.LineBreak=18]="LineBreak",t[t.Text=254]="Text",t[t.Space=255]="Space"}(Q||(Q={}));const Z=/[ \r\n]*\0+[ \r\n]*/g;class HtmlRenderer{constructor(t=(t,e)=>t?.text||""){this._extraItemRender=t,this._renderContent=t=>{const e=t.tokens;return NullChecker.isNullOrEmpty(e)?t.text:this._render(e)}}_rendeItem(t,e){const r=this._renderContent,n="\0";switch(t?.type){case G.Reference:return"";case G.Html:return t.raw;case G.BlockQuote:return`<blockquote>\n${r(t)}</blockquote>${n}`;case G.Bold:return`<b>${r(t)}</b>`;case G.CodeBlock:const s=t.lang;return`<pre>${n}<code${s?' class="'+s+'"':""}>${r(t)}</code>${n}</pre>${n}`;case G.Code:return`<code>${r(t)}</code>`;case G.HorizontalRule:return`<hr />${n}`;case G.Heading:const a=t.level;return`<h${a} id="${t.ref}">${r(t)}</h${a}>${n}`;case G.Image:case G.ImageLike:const i=t;let o=i.src,c="";const l=i.text,u=i.ref;if(!o&&u){const t=e.find(t=>t.type===G.Reference&&!0===t.image&&t.id?.toLowerCase()===u.toLowerCase());t&&(o=t.url,c=t.title??"")}return o?`<img src="${o}" alt="${l}"${c?' title="'+c+'"':""} />`:`![${r(t)}]`;case G.Italic:return`<i>${r(t)}</i>`;case G.StrikeThrough:return`<s>${r(t)}</s>`;case G.Quote:return`<q>${r(t)}</q>`;case G.LineBreak:return"<br />\0";case G.OrderedList:return`<ol start="${t.start}">\n${r(t)}</ol>${n}`;case G.UnorderedList:return`<ul>\n${r(t)}</ul>${n}`;case G.ListItem:return`\t<li>${r(t)}</li>${n}`;case G.Link:case G.LinkLike:const h=t;let d=h.href,p="";const g=h.ref;if(!d&&g){const t=e.find(t=>t.type===G.Reference&&!0!==t.image&&t.id?.toLowerCase()===g.toLowerCase());t&&(d=t.url,p=t.title??"")}return d?`<a href="${d}"${p?' title="'+p+'"':""}>${r(t)}</a>`:`[${r(t)}]`;case G.Paragraph:return`<p>${r(t)}</p>${n}`;case G.Text:case G.Space:return t.text}return this._extraItemRender(t,e)}_render(t){let e="";for(let r of t||[])e+=this._rendeItem(r,t);return e}render(t){return e=this._render(t),e?.replace(Z,"\n").trim();var e}}class TokenRenderer{_render(t){return NullChecker.isNullOrEmpty(t)?"":JSON.stringify(t)}render(t){return"["+t.filter(t=>!NullChecker.isNullOrEmpty(t)).map(this._render).join(",")+"]"}}var K=Object.freeze({__proto__:null,Parser:class Parser extends b{toHtml(t,e,r){const n=new HtmlRenderer(r);return NullChecker.isNullOrEmpty(e)?this.parse(t,n):this.parse(t,X(e),n)}tokenize(t,e){const r=this.parse(t,X(e),new TokenRenderer);return JSON.parse(r)}parse(t,e=X(),r=new HtmlRenderer){return(n=e)&&"object"==typeof n&&"function"==typeof n.render?super.parse(t,X(),e):super.parse(t,e,r);var n}}}),W=Object.freeze({__proto__:null,Markdown:K,Parser:b}),J=Object.freeze({__proto__:null,Angle:Angle,Arrays:class Arrays{static range(t,e,r=2){let n=t;NullChecker.isNull(e)&&(e=r=t,t=1);const s=(e-t)/(r-1),a=[];if(s>0)for(;a.length<r;)a.push(n.roundoff()),n+=s;return a}static chunkify(t,e){if(NullChecker.isNullOrEmpty(t))return[];if(e<=0||e%1!=0)throw new Error("Provide a positive integer number.");const r=Math.ceil(t.length/e);return Array.from({length:r},(r,n)=>{const s=n*e,a=s+e;return t.slice(s,a)})}},Blobs:Blobs,Colors:Colors,Compile:W,Dates:Dates,DeepMerger:DeepMerger,HistoryService:class HistoryService{constructor(t,e){this.#e=t,this.#r=e}#n=[];#s=[];#r;#e;get current(){return this.#e}get canUndo(){return this.#n.length>0}get canRedo(){return this.#s.length>0}set maxlength(t){this.#r=t}undo(){if(this.canUndo){const t=this.#n,e=this.#s,r=this.#e;e.unshift(r),this.#e=t.pop()}}redo(){if(this.canRedo){const t=this.#n,e=this.#s,r=this.#e;t.push(r),this.#e=e.shift()}}push(t){this.#s.splice(0),this.#n.push(this.#e),this.#e=t;const e=this.#r,r=this.#n;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#s.splice(0),this.#n.splice(0)}},Imaging:Imaging,Keys:Keys,Matrix2D:Matrix2D,NullChecker:NullChecker,Numbers:class Numbers{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){const n=t.toString(),s=parseInt(n,e);return n.endsWith(s.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}},Point:Point,Rect:Rect,Size:Size,Strings:class Strings{static leftPad(t,e,r){return t.toString().padStart(e,r)}static format(t,...e){const r=Array.from(e);let n=t;for(let t=0;t<r.length;t++){const e=new RegExp("(^|[^\\{])\\{"+t+"\\}($|[^\\}])","g");n=n.replaceAll(e,(e,...n)=>e.replace("{"+t+"}",r[t]))}const s=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(n);if(!NullChecker.isNullOrEmpty(s))throw new Error(`Missing argument at index ${s[2]}.`);return n}static diff(t,e,r="char"){switch(r){case"line":return function(t,e){const r=/\r?\n/,n=t.split(r),s=e.split(r);return m(n,s,x(n,s),"\n")}(t,e);case"word":return function(t,e){const r=/(\S+|\s+)/g,n=t.match(r)||[],s=e.match(r)||[];return m(n,s,x(n,s),"")}(t,e);default:return function(t,e){const r=t.split(""),n=e.split("");return m(r,n,x(r,n),"")}(t,e)}}static async hash(t,e="SHA-256"){const r=await crypto.subtle.digest(e,(new TextEncoder).encode(t));return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}},detect:function(t=navigator.userAgent){let e="unknown",r=null;switch(/ucbrowser/i.test(t)?e="UCBrowser":/edg/i.test(t)?e="Edge":/googlebot/i.test(t)?e="GoogleBot":/chromium/i.test(t)?e="Chromium":/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t)?e="Firefox":/; msie|trident/i.test(t)&&!/ucbrowser/i.test(t)?e="IE":/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t)?e="Chrome":/safari/i.test(t)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(t)?e="Safari":/opr|opera/i.test(t)&&(e="Opera"),e){case"UCBrowser":r=n(t,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":r=n(t,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":r=n(t,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":r=n(t,/(chromium)\/([\d\.]+)/i);break;case"Firefox":r=n(t,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":r=n(t,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":r=n(t,/(safari)\/([\d\.]+)/i);break;case"Opera":r=n(t,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{const e=n(t,/(trident)\/([\d\.]+)/i);r=e?`${parseFloat(e)+4}`:"7.0";break}default:r="0.0.0.0"}return{name:e,version:r}},parseAsNumericalArray:f});DeepMerger.merge(J)}();
6
+ !function(){"use strict";Number.prototype.isCloseTo=function(t,e=14){const r=Number(`1e-${e}`);return this>t-r&&this<t+r},Number.prototype.roundoff=function(t=14){return parseFloat(this.toFixed(t))},Number.prototype.clamp=function(t,e){let r=this;return null==t||isNaN(t)||(r=Math.max(r,t)),null==e||isNaN(e)||(r=Math.min(r,e)),r},Number.prototype.toBase62=function(){for(var t=this,e="";0!=t;){e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(t%62)+e,t=Math.floor(t/62)}return e},Number.prototype.toBase36=function(){return this.toString(36)};const t=/^\/Date\([\d]+\)\/$/i;class Dates{static parse(e){let r;return"string"==typeof e?(r=t.test(e)?parseInt(e.substring(6)):Date.parse(e),new Date(r)):"number"==typeof e?new Date(e):e}static isLeapYear(t){return t%4==0&&t%100!=0||t%400==0}static daysInMonth(t,e){return[31,Dates.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),n=new Date(t),s=n.getMonth()+e,i=0;for(;s<0;)s+=12,i--;return n.setDate(1),n.setMonth(s%12),n.setFullYear(n.getFullYear()+i+Math.floor(s/12)),n.setDate(Math.min(r,Dates.daysInMonth(n.getFullYear(),n.getMonth()))),n}static addDays(t,e){return new Date(t.valueOf()+864e5*e)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}}class NullChecker{static isNull(t){return null==t}static isEmpty(t){try{return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t||"object"==typeof t&&0===Object.keys(t).length&&!Dates.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch(t){return!1}}static isNullOrEmpty(t){return NullChecker.isNull(t)||NullChecker.isEmpty(t)}}function e(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)&&(t.constructor===Object||void 0===t.constructor)}function r(t,n){const s=t;for(const t of Object.keys(n)){const i=n[t],a=s[t];e(i)?s[t]=r(e(a)?a:{},i):Array.isArray(i)?s[t]=i.slice():s[t]=i}return s}Array.prototype.distinct=function(){return Array.from(new Set(this))},Array.prototype.union=function(t){const e=NullChecker.isNullOrEmpty(this),r=NullChecker.isNullOrEmpty(t);return e&&r?[]:r?this.slice():e?t.slice():this.concat(t).distinct()},Array.prototype.moveWithin=function(t,e){const r="Index must be greater or equal than 0 and less or equal than the length of the array.";var n=this;if(t<0||t>n.length)throw new Error(r);if(e<0||e>n.length)throw new Error(r);n.splice(e,0,Array.prototype.splice.apply(n,[t,1])[0])},Array.prototype.equalsContent=function(t){if(null==t||this.length!==t.length)return!1;for(let e=0;e<this.length;e++)if(this[e]!==t[e])return!1;return!0},Array.prototype.cloneFrom=function(t){if(null==t)throw"Cannot clone array from null object.";const e=t.length;var r=this.length!==t.length;for(let n=0;n<e;n++){const e=t[n];this.length>n?this[n]!==e&&(this[n]=e,r=!0):(Array.prototype.push.apply(this,[e]),r=!0)}r&&this.splice(e)};class DeepMerger{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},r(e,t)}}class Blobs{static blobToDataURL(t){return new Promise((e,r)=>{const n=new FileReader;n.onload=t=>{e(t.target.result)},n.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length;const r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){const r=Blobs._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){const e=t.indexOf(",");if(-1===e)return Blobs.base64ToBlob(t);{const r=t.substring(e+1),n=t.substring(0,e).match(/:(.*?);/)[1];return Blobs.base64ToBlob(r,{type:n})}}static async blobToText(t,e){const r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",n,s=63){let i=r.toLowerCase();const a=()=>`${e};charset=${i}`;switch(i){case"utf-8":{const e=(new TextEncoder).encode(t),r=n?[new Uint8Array([239,187,191]),e]:[e];return new Blob(r,{type:a()})}case"utf-16":i="utf-16le",n??=!0;case"utf-16le":case"utf-16be":{const e="utf-16be"!==i,r=n?1:0,s=new ArrayBuffer(2*(t.length+r)),o=new DataView(s);n&&o.setUint16(0,65279,e);for(let n=0;n<t.length;n++)o.setUint16(2*(n+r),t.charCodeAt(n),e);return new Blob([s],{type:a()})}case"ascii":case"iso-8859-1":case"latin1":{const e="ascii"===i?127:255,n=new Uint8Array(t.length),o=s>0;for(let i=0;i<t.length;i++){const a=t.charCodeAt(i);if(a>e){if(!o)throw new Error(`Character "${t[i]}" cannot be encoded in ${r}.`);n[i]=s}else n[i]=a}return new Blob([n],{type:a()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}}const n=(t,e)=>{const r=t.match(e);return r?r[2]:null};const s=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,i=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,a=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,o=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,c=/^#[a-f0-9]{6}$/,l=/^#[a-f0-9]{3}$/;function u(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"r"in t&&"g"in t&&"b"in t&&"number"==typeof t.r&&"number"==typeof t.b&&"number"==typeof t.g&&(t.a??=1,t.r>=0&&t.r<=1&&t.g>=0&&t.g<=1&&t.b>=0&&t.b<=1&&t.a>=0&&t.a<=1)}function h(t){return!NullChecker.isNullOrEmpty(t)&&"object"==typeof t&&"h"in t&&"s"in t&&"l"in t&&"number"==typeof t.h&&"number"==typeof t.s&&"number"==typeof t.l&&(t.a??=1,t.h>=0&&t.h<=360&&t.s>=0&&t.s<=1&&t.l>=0&&t.l<=1&&t.a>=0&&t.a<=1)}const p={adjustRgbChannel:t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),adjustRgbChannelInv:t=>t<=.00304?12.92*t:1.055*(Math.pow(t,1/2.4)-.055),adjustRgb:t=>({r:p.adjustRgbChannel(t.r),g:p.adjustRgbChannel(t.g),b:p.adjustRgbChannel(t.b),a:t.a}),adjustRgbInv:t=>({r:p.adjustRgbChannelInv(t.r),g:p.adjustRgbChannelInv(t.g),b:p.adjustRgbChannelInv(t.b),a:t.a}),X:t=>.4125*t.r+.3576*t.g+.1804*t.b,Y:t=>.2126*t.r+.7152*t.g+.0722*t.b,Z:t=>.0193*t.r+.1191*t.g+.9503*t.b,relativeLuminance:t=>{const e=p.adjustRgb(t);return p.Y(e)},rgbToCieXYZ:t=>{const e=p.adjustRgb(t);return{x:p.X(e),y:p.Y(e),z:p.Z(e),a:t.a}},cieXYZToRgb:t=>{const e=3.241*t.x-1.5374*t.y-.4986*t.z,r=-.9692*t.x+1.876*t.y+.0416*t.z,n=.0556*t.x-.204*t.y+1.057*t.z;return p.adjustRgbInv({r:e,g:r,b:n,a:t.a})},contrastRatio:(t,e)=>{const r=p.relativeLuminance(t)+.05,n=p.relativeLuminance(e)+.05;return r>n?r/n:n/r}};function d(t){return t.toString(16).padStart(2,"0")}class Colors{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){const e=t=>Math.min(1,Math.max(0,t));return null==t[3]&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),a.test(t)){let e=a.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(o.test(t)){let e=o.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(c.test(t)){let e=c.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(l.test(t)){let e=l.exec(t)[0],r=e.substr(1,1),n=e.substr(2,1),s=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+n+n),parseInt("0x"+s+s),1]))}if(s.test(t)){let e=s.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3])};return this.rgb(r)}if(i.test(t)){let e=i.exec(t);const r={h:parseFloat(e[1]),s:.01*parseFloat(e[2]),l:.01*parseFloat(e[3]),a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){const e=function(t){const e=t.r,r=t.g,n=t.b;return(.5*(Math.max(e,r,n)+Math.min(e,r,n))).clamp(0,1)}(t),r=function(t,e){const r=t.r,n=t.g,s=t.b,i=Math.max(r,n,s),a=Math.min(r,n,s);return(0===e||1===e?0:(i-a)/(1-Math.abs(2*e-1))).clamp(0,1)}(t,e),n=function(t){const e=t.r,r=t.g,n=t.b,s=Math.max(e,r,n),i=Math.min(e,r,n);let a=0;return s!==i&&(a=s===e?((r-n)/(s-i)*60+360)%360:s===r?((n-e)/(s-i)*60+120)%360:((e-r)/(s-i)*60+240)%360),a.clamp(0,360)}(t);return{h:n,s:r,l:e,a:t.a}}static cieXYZ(t){return h(t)&&(t=this.rgb(t)),p.rgbToCieXYZ(t)}static rgb(t){if(!h(t)){const e=p.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}{const e=t.h,r=t.s,n=t.l,s=e/60,i=(1-Math.abs(2*n-1))*r,a=i*(1-Math.abs(s%2-1)),o=n-i/2,c=(e,r,n)=>this._clampRGB([e+o,r+o,n+o,t.a]);if(s<=1)return c(i,a,0);if(s<=2)return c(a,i,0);if(s<=3)return c(0,i,a);if(s<=4)return c(0,a,i);if(s<=5)return c(a,0,i);if(s<=6)return c(i,0,a)}}static stringify(t,e=1){if(h(t)){e??=1,t.a??=1;const r="number"==typeof e?e:1;return`hsla(${t.h.roundoff(r)},${(100*t.s).roundoff(r)}%,${(100*t.l).roundoff(r)}%,${t.a.roundoff()})`}if(u(t)){e??=!0,t.a??=1;const r="boolean"==typeof e?e:!!e,n=Math.round(255*t.r),s=Math.round(255*t.g),i=Math.round(255*t.b),a=t.a.roundoff();return 1===a?r?("#"+d(n)+d(s)+d(i)).toUpperCase():`rgb(${n},${s},${i})`:`rgba(${n},${s},${i},${a})`}}static contrastRatio(t,e){return h(t)&&(t=this.rgb(t)),h(e)&&(e=this.rgb(e)),p.contrastRatio(t,e)}static luminance(t){return h(t)&&(t=Colors.rgb(t)),p.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(u(t)){const r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,h(t)){const r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(u(t)){const r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,n){r??=.5,n??=r;const s=(r+n).roundoff(),i=(r/s).roundoff(),a=(n/s).roundoff(),o=u(t),c=h(t),l=t=>u(t)||h(t)?Colors.cieXYZ(t):t;t=l(t),e=l(e);const p={x:(t.x*i+e.x*a).roundoff(),y:(t.y*i+e.y*a).roundoff(),z:(t.z*i+e.z*a).roundoff(),a:(t.a*i+e.a*a).roundoff()};return o?Colors.rgb(p):c?Colors.hsl(Colors.rgb(p)):p}}const g=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function f(t){const e=[];let r=t.match(g);return r&&r.length>0&&r.forEach(t=>e.push(parseFloat(t))),e}class Angle{static isAngle(t){return"object"==typeof t&&"vertex"in t&&Point.isPoint(t.vertex)&&"start"in t&&Point.isPoint(t.start)&&"end"in t&&Point.isPoint(t.end)}static value(t){if(NullChecker.isNullOrEmpty(t)||!Angle.isAngle(t))return Number.NaN;const{vertex:e,start:r,end:n}=t;return Angle.angleBetween(e,r,n)}static angleBetween(t,e,r){const n=e.x-t.x,s=e.y-t.y,i=r.x-t.x,a=r.y-t.y,o=n*i+s*a,c=n*a-s*i;return-Math.atan2(c,o)}}class Size{static parse(t){let e=f(t);if(e&&2===e.length)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return"object"==typeof t&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}}class Point{static parse(t){let e=f(t);if(e&&2===e.length)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return"object"==typeof t&&"x"in t&&"number"==typeof t.x&&"y"in t&&"number"==typeof t.y}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}}class Matrix2D{static isIdentity(t){return 1===t.a&&1===t.d&&0===t.b&&0===t.f&&0===t.c&&0===t.e}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){const r=Math.cos(e),n=Math.sin(e);return Matrix2D.multiply(t,{a:r,b:n,c:-n,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?"number"==typeof e?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:"number"==typeof e?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){const e=this.det(t);if(0===e)return null;const r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){const r=Math.sqrt(t.a*t.a+t.c*t.c),n=Math.sqrt(t.b*t.b+t.d*t.d),s=0!=r?t.a/r:0,i=0!=r?t.c/r:0,a=Math.atan2(i,s),{x:o,y:c}=e;return{scaleX:r,scaleY:n,rotation:a,translation:{x:t.e-o*(r*s-1)+c*r*i,y:t.f-c*(n*s-1)-o*n*i}}}static fromTransform([t,e,r],[n,s,i]){const a=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(a)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");const o=1/a;return{a:o*(n.x*(e.y-r.y)+s.x*(r.y-t.y)+i.x*(t.y-e.y)),b:o*(n.y*(e.y-r.y)+s.y*(r.y-t.y)+i.y*(t.y-e.y)),c:o*(n.x*(r.x-e.x)+s.x*(t.x-r.x)+i.x*(e.x-t.x)),d:o*(n.y*(r.x-e.x)+s.y*(t.x-r.x)+i.y*(e.x-t.x)),e:o*(n.x*(e.x*r.y-r.x*e.y)+s.x*(r.x*t.y-t.x*r.y)+i.x*(t.x*e.y-e.x*t.y)),f:o*(n.y*(e.x*r.y-r.x*e.y)+s.y*(r.x*t.y-t.x*r.y)+i.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}}class Rect{static parse(t){let e=f(t);if(e&&4===e.length)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return Point.isPoint(t)&&Size.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,n){let s=1;s=t.width/t.height>=e.width/e.height?e.width/t.width:e.height/t.height;const i=t.width*s,a=t.height*s,o=this._align({x:t.x,y:t.y,width:i,height:a},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _cover(t,e,r,n){let s=1;s=t.width/t.height<e.width/e.height?e.width/t.width:e.height/t.height;const i=t.width*s,a=t.height*s,o=this._align({x:t.x,y:t.y,width:i,height:a},e,r,n);return Matrix2D.translate({a:s,b:0,c:0,d:s,e:0,f:0},o)}static _align(t,e,r,n){let s=0,i=0;switch(r){case"left":s=e.x-t.x;break;case"right":s=e.x+e.width-t.width-t.x;break;default:s=e.x+.5*e.width-.5*t.width-t.x}switch(n){case"top":i=e.y-t.y;break;case"bottom":i=e.y+e.height-t.height-t.y;break;default:i=e.y+.5*e.height-.5*t.height-t.y}return{x:s,y:i}}static findTransform(t,e,r="stretch",n="center",s="middle"){switch(r){case"contain":return this._contain(t,e,n,s);case"cover":return this._cover(t,e,n,s);default:return this._stretch(t,e)}}static intersect(...t){const e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var n=r[0],s=1;s<r.length;s++){const t=r[s],i=Math.max(t.x,n.x),a=Math.max(t.y,n.y),o=Math.min(t.x+t.width,n.x+n.width)-i,c=Math.min(t.y+t.height,n.y+n.height)-a;if(o<0||c<=0)return e;n={x:i,y:a,width:o,height:c}}return n}static expand(t,...e){const r=Array.from(e||[]);let n=t.x,s=t.y,i=n,a=s;Rect.isRect(t)&&(i+=t.width,a+=t.height);for(let t of r)n=Math.min(t.x,n),s=Math.min(t.y,s),i=Math.max(t.x,i),a=Math.max(t.y,a);return{x:n,y:s,width:i-n,height:a-s}}}const y={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"};class Imaging{static async loadImage(t){const e=await fetch(t);if(!e.ok)return null;return await e.blob()}static async resizeImage(t,e,r,n){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");"string"==typeof t&&(t=await Imaging.loadImage(t));const s=await self.createImageBitmap(t),i=s.width,a=s.height,o=new OffscreenCanvas(i,a),c=o.getContext("2d");c.imageSmoothingEnabled=c.mozImageSmoothingEnabled=c.oImageSmoothingEnabled=c.webkitImageSmoothingEnabled=!0;const{quality:l,type:u,mode:h,align:p,valign:d,background:g}=Object.assign({},y,n??{}),f={width:i,height:a,x:0,y:0},m={x:0,y:0,width:e,height:r},w=Rect.findTransform(f,m,h,p,d);o.width=e,o.height=r,g&&(c.fillStyle=g,c.fillRect(0,0,o.width,o.height)),c.setTransform(w),c.drawImage(s,0,0);return await o.convertToBlob({quality:l,type:u})}}class Keys{static#t;static uniqueId(){let t=Keys.#t||Date.now();return Keys.#t=++t}static uniqueCode(){return Keys.uniqueId().toBase62()}static randomString(t){let e="";do{e+=(62*Math.random()).toBase62()}while(e.length<t);return e}}function m(t,e){const r=t.length,n=e.length,s=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let i=1;i<=r;i++)for(let r=1;r<=n;r++)t[i-1]===e[r-1]?s[i][r]=s[i-1][r-1]+1:s[i][r]=Math.max(s[i-1][r],s[i][r-1]);return s}function w(t,e,r,n=""){const s=t.length,i=e.length,a=[];let o=s,c=i,l=null;const u=()=>{l&&(a.push(l),l=null)};for(;o>0||c>0;){var h=null;let s=null;o>0&&c>0&&t[o-1]===e[c-1]?(h="=",s=t[o-1],o--,c--):c>0&&(0===o||r[o][c-1]>=r[o-1][c])?(h="+",s=e[c-1],c--):o>0&&(0===c||r[o-1][c]>r[o][c-1])&&(h="-",s=t[o-1],o--),h&&null!==s?l&&l.type===h?l.value=s+(l.value?n:"")+l.value:(u(),l={type:h,value:s}):u()}return u(),a.reverse()}class LexerClass{tokenize(t,e){const r=[];for(;t;){const n=t.length;for(let n of e){const e=n.exec(t,this),s=e?.length;if(s>0){Array.prototype.push.apply(r,e);const n=e[s-1];t=t.substr((n.index||0)+n.raw.length);break}}if(t.length>=n)throw new Error(`Cannot parse\n"${t}"\n using the provided grammar.`)}return r}}let x=class Parser{constructor(t=new LexerClass){this._lexer=t}parse(t,e,r){const n=this._lexer.tokenize(t,e);return r.render(n)}};var b;!function(t){t.Text="text",t.Space="space",t.Newline="newline",t.Comment="comment",t.DocComment="doc-comment",t.Keyword="keyword",t.Identifier="identifier",t.String="string",t.Regex="regex",t.Number="number",t.Bracket="bracket",t.Punctuation="punctuation",t.Operator="operator",t.Preprocessor="preprocessor",t.Tag="tag",t.TagName="tagname",t.Attribute="attribute",t.Entity="entity"}(b||(b={}));const k=new Map;function _(t){return(t??"").trim().toLowerCase()}class Syntaxes{static register(t){if(null==t)return;const e=[t.name].concat(t.aliases??[]);for(let r of e){const e=_(r);k.set(e,t)}}static get(t){const e=_(t);return k.get(e)??null}static names(){const t=k.keys();return Array.from(t)}}const S=[b.Identifier],$=[b.Space,b.Newline,b.Comment,b.DocComment];function C(t){return null!=t.combined}const v=new WeakMap;function T(t){return"include"in t}function A(t){return null==t||0===t.length?null:new Set(t)}function N(t,e){const r={};for(let t in e)r[t]=e[t].slice();for(let e in t){const n=r[e]??[];r[e]=t[e].concat(n)}return r}function R(t,e){const r={};for(let t in e)r[t]=e[t].slice();for(let e in t){const n=r[e]??[];r[e]=n.concat(t[e])}return r}function E(t,e=0){const r=t.lexical??{states:{}},n={start:r.start,states:r.states??{},keywords:r.keywords??{},keywordSources:r.keywordSources,keywordExceptAfter:r.keywordExceptAfter,insignificant:r.insignificant},s=t.extends?Syntaxes.get(t.extends):null;if(null==s||s===t||e>=16)return n;const i=E(s,e+1);return{start:n.start??i.start,states:N(n.states,i.states),keywords:R(n.keywords,i.keywords),keywordSources:n.keywordSources??i.keywordSources,keywordExceptAfter:n.keywordExceptAfter??i.keywordExceptAfter,insignificant:n.insignificant??i.insignificant}}function L(t,e,r){const n=t[e]??[];if(r.has(e))return[];r.add(e);const s=[];for(let e of n){if(!T(e)){s.push(e);continue}const n=L(t,e.include,r);Array.prototype.push.apply(s,n)}return r.delete(e),s}function M(t){const e=Array.isArray(t.type)?t.type:null,r=Array.isArray(t.type)?t.type[0]:t.type,n=function(t){const e=t.split(""),r=new Set(e);return Array.from(r).join("")}((t.flags??"").replace(/[yd]/g,"")),s=n+"y"+(e?"d":""),i=new RegExp(t.match,s),a=t.until?new RegExp(t.until,"y"):null,o=!0===t.pop?1:"number"==typeof t.pop?t.pop:0;var c;return{regex:i,type:r,groupTypes:e,when:null==(c=t.when)?null:{previousTypes:A(c.previousTypes),previousNotTypes:A(c.previousNotTypes),previousTexts:A(c.previousTexts),previousNotTexts:A(c.previousNotTexts)},pop:o,until:a,source:t.match,flags:n,next:t.next??null,push:t.push??null,embed:t.embed??null,hasTransition:o>0||!!t.next||!!t.push||!!t.embed}}function I(t){const e=new Map;for(let r in t)for(let n of t[r])e.set(n,r);return e}const z=/\\[1-9]|\\k<|\(\?<(?![=!])/;function B(t,e){return new RegExp(t+"|",e).exec("").length-1}function O(t){return null==t.when&&!z.test(t.source)&&(e=t.source,r=t.flags,!new RegExp("^(?:"+e+")$",r).test(""));var e,r}function F(t){const e=[];let r=[];const n=()=>{if(r.length>0){const t=function(t){if(1===t.length)return{rule:t[0],combined:null};const e=[];let r=1;for(let n of t)e.push(r),r+=1+B(n.source,n.flags);const n=t.map(t=>"("+t.source+")").join("|");return{rule:null,combined:new RegExp(n,t[0].flags+"y"),rules:t,groupIndices:e}}(r);e.push(t)}r=[]};for(let s of t)O(s)?(r.length>0&&r[0].flags!==s.flags&&n(),r.push(s)):(n(),e.push({rule:s,combined:null}));return n(),e}function j(t){const e=v.get(t);if(null!=e)return e;const r=E(t),n=new Map;for(let t in r.states){const e=new Set,s=F(L(r.states,t,e).map(M));n.set(t,s)}const s={name:t.name,start:r.start??"root",states:n,keywords:I(r.keywords),keywordSources:new Set(r.keywordSources??S),keywordExceptAfter:new Set(r.keywordExceptAfter??[]),insignificant:new Set(r.insignificant??$)};return v.set(t,s),s}class ScanRun{constructor(t,e){this._source=t,this._tokens=[],this._position=0,this._emitted=0,this._line=1,this._column=1,this._previous=null,this._emptyTransitions=0,this._stack=[{syntax:e,state:e.start,until:null}]}run(){const t=this._source.length;for(;this._position<t;)this._step();return this._flushText(),this._tokens}get _top(){const t=this._stack;return t[t.length-1]}_step(){const t=this._top;if(this._popOnUntil(t))return;const e=this._findRule(t);if(null==e)return void this._position++;this._flushText(),this._emitMatch(e,t.syntax),this._transition(e.rule,t.syntax);const r=e.match[0].length;this._position+=r,r>0&&(this._emptyTransitions=0)}_popOnUntil(t){const e=t.until;return!(null==e||this._stack.length<=1)&&(e.lastIndex=this._position,!!e.test(this._source)&&(this._flushText(),this._stack.pop(),!0))}_findRule(t){const e=t.syntax.states.get(t.state)??[];for(let t of e){const e=C(t)?this._tryCombined(t):this._trySingle(t.rule);if(null!=e)return e}return null}_trySingle(t){const e=this._tryRule(t);return null==e?null:{rule:t,match:e}}_tryCombined(t){const e=t.combined;e.lastIndex=this._position;const r=e.exec(this._source);if(null==r)return null;const n=t.groupIndices;for(let e=0;e<n.length;e++){if(void 0===r[n[e]])continue;const s=t.rules[e];return this._trySingle(s)}return null}_tryRule(t){if(null!=t.when&&!function(t,e){const r=e?.type??null,n=e?.raw??null;return!(null!=t.previousTypes&&!t.previousTypes.has(r)||null!=t.previousNotTypes&&t.previousNotTypes.has(r)||null!=t.previousTexts&&!t.previousTexts.has(n)||null!=t.previousNotTexts&&t.previousNotTexts.has(n))}(t.when,this._previous))return null;const e=t.regex;e.lastIndex=this._position;const r=e.exec(this._source);return null==r?null:r[0].length>0?r:!t.hasTransition||this._emptyTransitions>=64?null:(this._emptyTransitions++,r)}_emitMatch({rule:t,match:e},r){const n=e[0];null!=t.groupTypes?this._emitGroups(t,e,r):this._append(t.type,n,r)}_emitGroups(t,e,r){const n=e.indices,s=e.index,i=s+e[0].length,a=t.groupTypes;let o=s;for(let t=1;t<e.length;t++){const e=n[t];if(null==e||e[0]<o||e[1]===e[0])continue;if(e[0]>o){const t=this._source.slice(o,e[0]);this._append(b.Text,t,r)}const s=this._source.slice(e[0],e[1]),i=a[t-1]??a[a.length-1];this._append(i,s,r),o=e[1]}if(o<i){const t=this._source.slice(o,i);this._append(b.Text,t,r)}}_transition(t,e){const r=this._stack;for(let e=0;e<t.pop&&r.length>1;e++)r.pop();if(null!=t.next&&(this._top.state=t.next),null!=t.push&&r.push({syntax:e,state:t.push,until:null}),null==t.embed)return;const n=function(t){const e=Syntaxes.get(t);return null==e?null:j(e)}(t.embed);null!=n&&r.push({syntax:n,state:n.start,until:t.until})}_flushText(){if(this._emitted>=this._position)return;const t=this._source.slice(this._emitted,this._position),e=this._top.syntax;this._append(b.Text,t,e)}_resolveType(t,e,r){if(!r.keywordSources.has(t))return t;const n=this._previous?.raw;return r.keywordExceptAfter.has(n)?t:r.keywords.get(e)??t}_append(t,e,r){const n=this._resolveType(t,e,r),s={type:n,raw:e,text:e,index:this._emitted,line:this._line,column:this._column,depth:this._stack.length-1,syntax:r.name};this._tokens.push(s),this._advance(e),r.insignificant.has(n)||(this._previous=s)}_advance(t){this._emitted+=t.length;const e=t.lastIndexOf("\n");if(e<0)this._column+=t.length;else{for(let r=0;r<=e;r++)10===t.charCodeAt(r)&&this._line++;this._column=t.length-e}}}const D={name:b.Text,lexical:{states:{}}};class Scanner{tokenize(t,e){const r=t??"",n=j(("string"==typeof e?Syntaxes.get(e):e)??D);return new ScanRun(r,n).run()}}const U=Object.freeze({keyword:"code-keyword",preprocessor:"code-keyword",string:"code-string",regex:"code-string",number:"code-number",comment:"code-comment","doc-comment":"code-comment",tag:"code-tag",tagname:"code-tagname",attribute:"code-attribute"}),H={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};class HighlightRenderer{constructor(t=U){this._classes=t}render(t){let e="";for(let r of t??[])e+=this._renderToken(r);return e}_renderToken(t){const e=(t.raw??"").replace(/[&<>"]/g,t=>H[t]);const r=this._classes[t.type];return null==r?e:`<span class="${r}">${e}</span>`}}function P(t){return(t??"").replace(/</g,"&lt;")}function q(t){return(t??"").replace(/&(?!(?:#\d+|#x[\da-fA-F]+|\w+);)/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Q(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1));return e.split(/(?<!\\)\|/).map(t=>t.trim().replace(/\\\|/g,"|"))}function X(t){const e=t.startsWith(":"),r=t.endsWith(":");return e&&r?"center":r?"right":e?"left":null}function Y(t){return/^ */.exec(t)[0].length}const Z=new Scanner;function G(t){return t?.index||void 0}function W(t){return t?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function K(t,e,r){const n=e.exec(t);return n&&n.length?r(n):null}const J=/(<!--)([\s\S]*?)(-->|$)/,V=/^ {0,3}(={3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,}|(?:\*[ \t]*){3,})(\r?\n|$)/,tt=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,et=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,rt=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,nt=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,st=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,it=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,at=/^( {0,3}([-+]|\*(?=[ \t])).*(\r?\n|$))((?!(?: ?\d+[.\)]|\r?\n\S)).*(\r?\n|$))*/,ot=/^( {0,3}(\d+[.\)]).*(\r?\n|$))((?!(?: {0,2}(?:[-+]|\*[ \t])|\r?\n\S)).*(\r?\n|$))*/,ct=/^( *)([-+*]|\d+[.\)])([ \t]+|$)/,lt=/^\[([ xX])\][ \t]+/,ut=/^(?! {4,})(?=[ \t]*\S)(.+(\n(?![ \t]*(?:\n|$))(?! {0,3}```)(?! {0,3}([-+]|\*[ \t]|\d+[.\)]))(?! {0,3}#{1,6}[ \t])(?! {4,})(?! {0,3}>).+)*)/,ht=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,pt=/(?<!\\)!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,dt=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,gt=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,ft=/(\*\*?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1|(?<![A-Za-z0-9])(__?)((?!\3\s?)(?:(?!\3)[\S\s])*[^\s])\3(?![A-Za-z0-9])/,yt=/(~~?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,mt=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,wt=/^\s+/,xt=/^(?:[ \t]*\r?\n)+|^\s+/,bt=/(?: {2,}|\\)\r?\n/,kt=/^[^\r\n]+/,_t=/\\(&lt;|[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])/,St={"<":"&lt;","&lt;":"&lt;","&":"&amp;"},$t=/(?:<|&lt;)((?:https?|ftp|mailto):[^\s<>]+|[\w.+-]+@[\w-]+(?:\.[\w-]+)+)>/,Ct=/(?<![\w\/\\(\[<"'=;&@])(?:https?:\/\/|www\.)[^\s<>]*[^\s<>.,:;"'!?)\]*_~]/,vt=/\[\^([^\]\s]+)\]/,Tt=/^ {0,3}\[\^([^\]\s]+)\]: *([^\r\n]*(?:\r?\n {2,}[^\r\n]+)*)(\r?\n|$)+/,At=/^ {0,3}(\|?[^\r\n]*\|[^\r\n]*)\r?\n {0,3}(\|? *:?-+:? *(?:\| *:?-+:? *)*\|?) *(?:\r?\n|$)((?:(?! {0,3}(?:\r?\n|$))[^\r\n]*\|[^\r\n]*(?:\r?\n|$))*)/;var Nt,Rt;function Et(t=[]){const e={[Rt.Comment]:{exec:(t,e)=>K(t,J,r=>{const n=G(r),s=[{type:Nt.Html,index:n,raw:r[0],text:r[2]}];if(n>0){const r=t.substr(0,n),i=e.tokenize(r,y);Array.prototype.unshift.apply(s,i)}return s})},[Rt.Reference]:{exec:t=>K(t,ht,t=>{const e=G(t),r=t[0],n=r,s="!"===t[1],i=t[2],a=t[3],o=t[4];return[{type:Nt.Reference,index:e,raw:r,text:n,id:i,image:s,url:a,title:o}]})},[Rt.FootnoteDefinition]:{exec:(t,e)=>K(t,Tt,t=>{const r=t[0],n=W(t[1]),s=t[2].replace(/\r?\n {2,}/g," ");return[{type:Nt.FootnoteDefinition,index:G(t),raw:r,text:s,id:n,tokens:e.tokenize(s,l)}]})}},r=[],n=[],s={};for(let e of t){let t,i="inline";switch("type"in e?(i=e.type,t=e.rule):t=e,i){case"block":r.push(t);break;case"code":if("lang"in e){const r=e.lang.toLowerCase();(s[r]=s[r]||[]).push(t)}break;default:const i={exec:(e,r)=>{const n=t.exec(e,r);return o(e,n,r),n}};n.push(i)}}const i={[Rt.Text]:{exec:t=>K(t,kt,t=>{const e=t[0],r=e;return[{index:G(t),raw:e,text:r,type:Nt.Text}]})},[Rt.Space]:{exec:t=>K(t,wt,t=>{const e=t[0];return[{type:Nt.Space,raw:e,text:e}]})}},a={[Rt.ImageOrLink]:{exec:(t,e)=>c(t,pt,e,t=>{const r=G(t),n=t[0],s="!"===n.charAt(0),i=t[1],a=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\[/.test(t)&&/\]$/.test(t)))return/^\(/.test(t)&&/\)$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2]),o=function(t){if(!(NullChecker.isNullOrEmpty(t)||/^\(/.test(t)&&/\)$/.test(t)))return/^\[/.test(t)&&/\]$/.test(t)&&(t=t.substr(1,t.length-2)),t}(t[2])??i,c=W(o),{url:u,title:h}=function(t){if(NullChecker.isNullOrEmpty(t))return{url:t};const e=t.trim(),r=/^(\S*)\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\))\s*$/.exec(e);if(null==r)return{url:e};const n=r[2]??r[3]??r[4];return{url:r[1],title:n}}(a),p=e.tokenize(i,l);return s?[{index:r,type:u?Nt.Image:Nt.ImageLike,raw:n,text:i,src:u,title:h,ref:c,tokens:p}]:[{index:r,type:u?Nt.Link:Nt.LinkLike,raw:n,text:i,href:u,title:h,ref:c,tokens:p}]})},[Rt.Escape]:{exec:(t,e)=>c(t,_t,e,t=>{const e=St[t[1]]??t[1];return[{index:G(t),raw:t[0],text:e,type:Nt.Text}]})},[Rt.AutoLink]:{exec:(t,e)=>c(t,$t,e,t=>{const e=t[1],r=!/^[a-z]+:/i.test(e)?"mailto:"+e:e;return[{index:G(t),raw:t[0],text:e,href:r,type:Nt.Link,tokens:[{type:Nt.Text,raw:e,text:e}]}]})},[Rt.BareUrl]:{exec:(t,e)=>c(t,Ct,e,t=>{const e=t[0],r=/^www\./i.test(e)?"http://"+e:e;return[{index:G(t),raw:e,text:e,href:r,type:Nt.Link,tokens:[{type:Nt.Text,raw:e,text:e}]}]})},[Rt.FootnoteReference]:{exec:(t,e)=>c(t,vt,e,t=>{const e=W(t[1]);return[{index:G(t),raw:t[0],text:t[1],id:e,type:Nt.FootnoteReference}]})},[Rt.Code]:{exec:(t,e)=>c(t,gt,e,t=>{const e=P(t[1]);return[{type:Nt.Code,raw:t[0],text:e,index:G(t)}]})},[Rt.EmphasizedLink]:{exec:(t,e)=>c(t,dt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=t[1].length>1?Nt.Bold:Nt.Italic,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.Emphasize]:{exec:(t,e)=>c(t,ft,e,t=>{const r=t[1]??t[3],n=t[2]??t[4];if(NullChecker.isNullOrEmpty(n))return null;const s=r.length>1?Nt.Bold:Nt.Italic;return[{index:G(t),type:s,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.StrikeThrough]:{exec:(t,e)=>c(t,yt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=Nt.StrikeThrough,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.Quote]:{exec:(t,e)=>c(t,mt,e,t=>{if(t.length<3||NullChecker.isNullOrEmpty(t[2]))return null;const r=Nt.Quote,n=t[2];return[{index:G(t),type:r,raw:t[0],text:n,tokens:e.tokenize(n,l)}]})},[Rt.LineBreak]:{exec:(t,e)=>c(t,bt,e,t=>{const e=t[0],r=e;return[{index:G(t),raw:e,text:r,type:Nt.LineBreak}]})}},o=(t,e,r)=>{const n=e?.length>0&&e[0].index;if(n>0){const s=t.substr(0,n),i=r.tokenize(s,l)||[];Array.prototype.unshift.apply(e,i)}},c=(t,e,r,n)=>{const s=K(t,e,r=>{if(e!=gt){const e=gt.exec(t);if(e&&e.length&&e.index<r.index)return null}return n(r)});return o(t,s,r),s},l=[a[Rt.FootnoteReference],a[Rt.EmphasizedLink],a[Rt.ImageOrLink],a[Rt.Escape],a[Rt.AutoLink],a[Rt.Emphasize],a[Rt.StrikeThrough],a[Rt.Quote],a[Rt.Code],a[Rt.LineBreak],a[Rt.BareUrl]];Array.prototype.push.apply(l,n),l.push(i[Rt.Text],i[Rt.Space]);const u=t=>{const e=[i[Rt.Text],i[Rt.Space]],r=t?.toLowerCase()||"";return r&&r in s&&Array.prototype.unshift.apply(e,s[r]),e},h={[Rt.Paragraph]:{exec:(t,e)=>K(t,ut,t=>{const r=t[0],n=r.replace(/^[ \t]+/gm,"");return 0===n.trim().length?null:[{type:Nt.Paragraph,raw:r,text:n,tokens:e.tokenize(n,l)}]})},[Rt.Space]:{exec:t=>K(t,xt,t=>{const e=t[0];return[{type:Nt.Space,raw:e,text:e}]})}},p=(t,e)=>{const r=function(t){const e=t.replace(/\t/g," ").split(/\r?\n/),r=[];for(let t of e){const e=r[r.length-1],n=ct.exec(t);if(null!=n&&(null==e||n[1].length<e.indent)){const e=n[0].length,s=t.slice(e);r.push({indent:e,lines:[s]});continue}if(null==e)continue;const s=Math.min(e.indent,Y(t)),i=t.slice(s);e.lines.push(i)}return r.map(t=>t.lines.join("\n").replace(/\s+$/,""))}(t);return r.filter(t=>!NullChecker.isNullOrEmpty(t)).map(t=>{const r=lt.exec(t),n=r?t.slice(r[0].length):t,s=((t,e)=>{if(!/^ {0,3}(`{3,}|$|>|[-+*]\s|\d+[.\)]|#{1,6}\s|\|)/m.test(t))return e.tokenize(t,l);const r=e.tokenize(t,f),n=r[0];if(/\n[ \t]*\n/.test(t)||n?.type!==Nt.Paragraph)return r;const s=n.tokens??[],i=r.slice(1);return s.concat(i)})(n,e);if(null==r)return{type:Nt.ListItem,raw:t,text:n,tokens:s};const i=" "!==r[1];return{type:Nt.ListItem,raw:t,text:n,tokens:s,task:!0,checked:i}})},d=(t,e,r,n)=>{const s=e.map((e,s)=>{const i=t[s]??"",a=n.tokenize(i,l);return{type:Nt.TableCell,raw:i,text:i,header:r,align:e,tokens:a}}),i=t.join(" | ");return{type:Nt.TableRow,raw:i,text:i,header:r,tokens:s}},g={[Rt.HorizontalRule]:{exec:(t,e)=>K(t,V,t=>{const e=t[0],r=e;return[{type:Nt.HorizontalRule,raw:e,text:r}]})},[Rt.Heading]:{exec:(t,e)=>K(t,tt,t=>{const r=t[2].replace(/[ \t]+#+[ \t]*$/,"");return[{type:Nt.Heading,raw:t[0],text:r,level:t[1].length,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.Heading1]:{exec:(t,e)=>K(t,et,t=>{const r=t[1];return[{type:Nt.Heading,raw:t[0],text:r,level:1,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.Heading2]:{exec:(t,e)=>K(t,rt,t=>{const r=t[1];return[{type:Nt.Heading,raw:t[0],text:r,level:2,ref:W(r),tokens:e.tokenize(r,l)}]})},[Rt.CodeBlock]:{exec:(t,e)=>K(t,nt,t=>{const r=t[0],n=r.replace(/^ {4}/gm,"").replace(/\s+$/,""),s=P(n);return 0===n.length?null:[{type:Nt.CodeBlock,raw:r,text:s,tokens:e.tokenize(s,u(""))}]})},[Rt.Fences]:{exec:(t,e)=>K(t,st,t=>{const r=(t[1]??"").trim().split(/\s+/)[0].toLowerCase(),n=r in s?null:Syntaxes.get(r);if(null==n){const n=P(t[2]);return[{type:Nt.CodeBlock,raw:t[0],text:n,lang:r,tokens:e.tokenize(n,u(r))}]}const i=function(t){return(t??"").replace(/&lt;/g,"<")}(t[2]),a=Z.tokenize(i,n);return[{type:Nt.CodeBlock,raw:t[0],text:i,lang:r,syntax:n.name,highlighted:!0,tokens:a}]})},[Rt.BlockQuote]:{exec:(t,e)=>K(t,it,t=>{const r=t[0],n=r.replace(/^ {0,3}> ?/gm,"");return[{type:Nt.BlockQuote,raw:r,text:n,tokens:e.tokenize(n,f)}]})},[Rt.OrderedList]:{exec:(t,e)=>K(t,ot,t=>{const r=t[0],n=/\d+/.exec(r),s=parseInt(n[0]),i=p(r,e);return[{type:Nt.OrderedList,start:s,raw:r,text:r,tokens:i}]})},[Rt.UnorderedList]:{exec:(t,e)=>K(t,at,t=>{const r=t[0],n=p(r,e);return[{type:Nt.UnorderedList,raw:r,text:r,tokens:n}]})},[Rt.Table]:{exec:(t,e)=>K(t,At,t=>{const r=Q(t[1]),n=Q(t[2]);if(r.length!==n.length)return null;const s=n.map(X),i=t[3].split(/\r?\n/).filter(t=>t.trim().length>0),a=d(r,s,!0,e),o=i.map(t=>{const r=Q(t);return d(r,s,!1,e)}),c=[a].concat(o);return[{type:Nt.Table,raw:t[0],text:t[0],align:s,tokens:c}]})}},f=Object.values(g);Array.prototype.push.apply(f,r),f.push(h[Rt.Paragraph],h[Rt.Space]);const y=[e[Rt.Comment],e[Rt.FootnoteDefinition],e[Rt.Reference]].concat(f);return y}!function(t){t.Html="html",t.Text="text",t.Paragraph="paragraph",t.BlockQuote="blockquote",t.Space="space",t.Heading="heading",t.Bold="bold",t.Italic="italic",t.CodeBlock="codeblock",t.Code="code",t.Image="img",t.ImageLike="imglike",t.Link="link",t.LinkLike="linklike",t.LineBreak="br",t.StrikeThrough="strike",t.Quote="quote",t.HorizontalRule="hr",t.OrderedList="ol",t.UnorderedList="ul",t.ListItem="listitem",t.Reference="ref",t.Table="table",t.TableRow="tr",t.TableCell="td",t.FootnoteReference="fnref",t.FootnoteDefinition="fndef"}(Nt||(Nt={})),function(t){t[t.Comment=0]="Comment",t[t.Reference=1]="Reference",t[t.HorizontalRule=2]="HorizontalRule",t[t.Heading=3]="Heading",t[t.Heading1=4]="Heading1",t[t.Heading2=5]="Heading2",t[t.CodeBlock=6]="CodeBlock",t[t.Fences=7]="Fences",t[t.BlockQuote=8]="BlockQuote",t[t.OrderedList=9]="OrderedList",t[t.UnorderedList=10]="UnorderedList",t[t.Paragraph=11]="Paragraph",t[t.EmphasizedLink=12]="EmphasizedLink",t[t.ImageOrLink=13]="ImageOrLink",t[t.Emphasize=14]="Emphasize",t[t.StrikeThrough=15]="StrikeThrough",t[t.Quote=16]="Quote",t[t.Code=17]="Code",t[t.LineBreak=18]="LineBreak",t[t.FootnoteDefinition=19]="FootnoteDefinition",t[t.Table=20]="Table",t[t.Escape=21]="Escape",t[t.AutoLink=22]="AutoLink",t[t.FootnoteReference=23]="FootnoteReference",t[t.BareUrl=24]="BareUrl",t[t.Text=254]="Text",t[t.Space=255]="Space"}(Rt||(Rt={}));const Lt="\0",Mt=/[ \r\n]*\0+[ \r\n]*/g;function It(t){if(NullChecker.isNullOrEmpty(t))return"";return` title="${q(t)}"`}function zt(t){return null==t?"":` style="text-align: ${t}"`}class HtmlRenderer{constructor(t=(t,e)=>t?.text||""){this._extraItemRender=t,this.#e=[],this.#r=new Map,this.#n=[],this.#s=new HighlightRenderer,this._renderContent=t=>{const e=t.tokens;return NullChecker.isNullOrEmpty(e)?t.text:this._render(e)}}#e;#r;#n;#s;_collectDefinitions(t){for(let e of t??[])e?.type===Nt.Reference&&this.#e.push(e),e?.type!==Nt.FootnoteDefinition||this.#r.has(e.id)||this.#r.set(e.id,e),this._collectDefinitions(e?.tokens)}_findReference(t,e){if(NullChecker.isNullOrEmpty(t))return;const r=t.toLowerCase();return this.#e.find(t=>!0===t.image===e&&t.id?.toLowerCase()===r)}_renderCodeBlock(t){const e=Lt,r=t.lang;if(!0!==t.highlighted){return`<pre>${e}<code${r?' class="'+r+'"':""}>${this._renderContent(t)}</code>${e}</pre>${e}`}const n=[r,"code-highlighted"];"markup"===t.syntax&&n.push("code-markup");return`<pre>${e}<code class="${q(n.join(" "))}">${this.#s.render(t.tokens)}</code>${e}</pre>${e}`}_renderImage(t){let e=t.src,r=t.title;if(!e){const n=this._findReference(t.ref,!0);e=n?.url,r=n?.title}if(!e){return`![${this._renderContent(t)}]`}const n=It(r);return`<img src="${e}" alt="${t.text}"${n} />`}_renderLink(t){let e=t.href,r=t.title;if(!e){const n=this._findReference(t.ref,!1);e=n?.url,r=n?.title}const n=this._renderContent(t);if(!e)return`[${n}]`;return`<a href="${e}"${It(r)}>${n}</a>`}_renderListItem(t){const e=Lt,r=this._renderContent(t);if(!0!==t.task)return`\t<li>${r}</li>${e}`;return`\t<li class="task-list-item"><input type="checkbox" disabled${!0===t.checked?" checked":""} /> ${r}</li>${e}`}_renderTableRow(t){const e=Lt;let r="";for(let e of t.tokens??[]){const t=!0===e.header?"th":"td";r+=`<${t}${zt(e.align)}>${this._renderContent(e)}</${t}>`}return`<tr>${r}</tr>${e}`}_renderTable(t){const e=Lt,r=t.tokens??[],n=r.filter(t=>!0===t.header),s=r.filter(t=>!0!==t.header);let i=`<table>${e}<thead>${e}${n.map(t=>this._renderTableRow(t)).join("")}</thead>${e}`;if(s.length>0){i+=`<tbody>${e}${s.map(t=>this._renderTableRow(t)).join("")}</tbody>${e}`}return i+`</table>${e}`}_renderFootnoteReference(t){const e=t.id;if(!this.#r.has(e))return`[^${t.text}]`;const r=this.#n,n=!r.includes(e);n&&r.push(e);return`<sup class="footnote-ref"><a href="#fn-${e}"${n?` id="fnref-${e}"`:""}>${r.indexOf(e)+1}</a></sup>`}_renderFootnotes(){const t=this.#n;if(0===t.length)return"";const e=Lt;let r="";for(let n=0;n<t.length;n++){const s=t[n],i=this.#r.get(s);r+=`<li id="fn-${s}">${this._renderContent(i)} <a href="#fnref-${s}" class="footnote-backref">&#8617;</a></li>${e}`}return`<section class="footnotes">${e}<ol>${e}${r}</ol>${e}</section>${e}`}_rendeItem(t,e){const r=this._renderContent,n=Lt;switch(t?.type){case Nt.Reference:case Nt.FootnoteDefinition:return"";case Nt.Html:return t.raw;case Nt.BlockQuote:return`<blockquote>\n${r(t)}</blockquote>${n}`;case Nt.Bold:return`<b>${r(t)}</b>`;case Nt.CodeBlock:return this._renderCodeBlock(t);case Nt.Code:return`<code>${r(t)}</code>`;case Nt.HorizontalRule:return`<hr />${n}`;case Nt.Heading:const e=t.level;return`<h${e} id="${t.ref}">${r(t)}</h${e}>${n}`;case Nt.Image:case Nt.ImageLike:return this._renderImage(t);case Nt.Italic:return`<i>${r(t)}</i>`;case Nt.StrikeThrough:return`<s>${r(t)}</s>`;case Nt.Quote:return`<q>${r(t)}</q>`;case Nt.LineBreak:return"<br />\0";case Nt.OrderedList:return`<ol start="${t.start}">\n${r(t)}</ol>${n}`;case Nt.UnorderedList:return`<ul>\n${r(t)}</ul>${n}`;case Nt.ListItem:return this._renderListItem(t);case Nt.Link:case Nt.LinkLike:return this._renderLink(t);case Nt.Table:return this._renderTable(t);case Nt.FootnoteReference:return this._renderFootnoteReference(t);case Nt.Paragraph:return`<p>${r(t)}</p>${n}`;case Nt.Text:case Nt.Space:return t.text}return this._extraItemRender(t,e)}_render(t){let e="";for(let r of t||[])e+=this._rendeItem(r,t);return e}render(t){this.#e=[],this.#r.clear(),this.#n=[],this._collectDefinitions(t);const e=this._render(t),r=this._renderFootnotes();return n=e+r,n?.replace(Mt,"\n").trim();var n}}class TokenRenderer{_render(t){return NullChecker.isNullOrEmpty(t)?"":JSON.stringify(t)}render(t){return"["+t.filter(t=>!NullChecker.isNullOrEmpty(t)).map(this._render).join(",")+"]"}}var Bt=Object.freeze({__proto__:null,Parser:class Parser extends x{toHtml(t,e,r){const n=new HtmlRenderer(r);return NullChecker.isNullOrEmpty(e)?this.parse(t,n):this.parse(t,Et(e),n)}tokenize(t,e){const r=this.parse(t,Et(e),new TokenRenderer);return JSON.parse(r)}parse(t,e=Et(),r=new HtmlRenderer){const n=(t??"").replace(/\r\n?/g,"\n");if((s=e)&&"object"==typeof s&&"function"==typeof s.render){const t=Et();return super.parse(n,t,e)}var s;return super.parse(n,e,r)}}});const Ot={name:"javascript",aliases:["js","mjs","cjs","jsx","typescript","ts","tsx","script","ecmascript"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n

]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:"`",type:"string",push:"template"},{match:String.raw`"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\[\s\S]|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\r\n])*\]|[^/\\\[\r\n])+/[a-z]*`,type:"regex",when:{previousNotTypes:["identifier","number","string","regex"],previousNotTexts:[")","]","}","this","super","null","undefined","true","false","++","--"]}},{match:String.raw`0[xX][\da-fA-F_]+n?|0[bB][01_]+n?|0[oO][0-7_]+n?|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d[\d_]*)?n?`,type:"number"},{match:String.raw`#?[A-Za-z_$ -￿][\w$ -￿]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.(?!\d)|\.\.\.|[;,.]`,type:"punctuation"},{match:String.raw`>>>=|<<=|>>=|>>>|\*\*=|&&=|\|\|=|\?\?=|===|!==|=>|\*\*|\+\+|--|<<|>>|&&|\|\||\?\?|[-+*/%&|^<>!=]=?|[~?:@]`,type:"operator"}],template:[{match:"`",type:"string",pop:!0},{match:String.raw`\$\{`,type:"punctuation",push:"templateExpression"},{match:String.raw`(?:\\[\s\S]|\$(?!\{)|[^\\`+"`"+String.raw`$])+`,type:"string"}],templateExpression:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:["async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","import","in","instanceof","let","new","null","of","return","set","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield","abstract","accessor","any","as","asserts","bigint","boolean","declare","implements","infer","interface","is","keyof","module","namespace","never","number","object","override","package","private","protected","public","readonly","satisfies","string","symbol","type","unique","unknown"]},keywordExceptAfter:[".","?."]}},Ft={previousNotTexts:[".","?."]},jt={name:"pacem-binding",aliases:["pacem","binding"],extends:"javascript",lexical:{states:{root:[{match:String.raw`:host(?=\.)`,type:"binding-host",when:Ft},{match:String.raw`::[A-Za-z_$][\w$]*`,type:"binding-host-property"},{match:String.raw`\^+item(?![\w$])`,type:"binding-item"},{match:String.raw`\^+index(?![\w$])`,type:"binding-index"},{match:String.raw`#[A-Za-z_][\w]*`,type:"binding-element",when:Ft},{match:String.raw`\$?this(?![\w$])`,type:"binding-this",when:Ft}]}}},Dt={match:String.raw`\r\n|[\r\n]`,type:"newline"},Ut=[Dt,{match:String.raw`[ \t\f]+`,type:"space"},{match:'"',type:"string",push:"doubleQuoted"},{match:"'",type:"string",push:"singleQuoted"},{match:String.raw`[^\s=/>"']+`,type:"attribute"},{match:"=",type:"operator"},{match:"/",type:"punctuation"}],Ht=[{match:String.raw`\{\{`,type:"punctuation",embed:"pacem-binding",until:String.raw`\}\}`},{match:String.raw`\}\}`,type:"punctuation"}],Pt={name:"markup",aliases:["html","htm","xml","xhtml","svg"],lexical:{start:"root",states:{root:[{match:String.raw`<!--[\s\S]*?(?:-->|$)`,type:"comment"},{match:String.raw`<![^>]*>?`,type:"tag"},{match:String.raw`(<\/)([\w:.-]+)(\s*>?)`,type:["tag","tagname","tag"]},{match:String.raw`(<)(script)(?![\w:.-])`,flags:"i",type:["tag","tagname"],push:"scriptTag"},{match:String.raw`(<)([\w:.-]+)`,type:["tag","tagname"],push:"tag"},{match:String.raw`&(?:#\d+|#[xX][\da-fA-F]+|\w+);`,type:"entity"},Dt,{match:String.raw`[^<&\r\n]+`,type:"text"}],tag:[{match:String.raw`/?>`,type:"tag",pop:!0},{include:"attributes"}],scriptTag:[{match:"/>",type:"tag",pop:!0},{match:">",type:"tag",pop:!0,embed:"javascript",until:String.raw`<\/script`},{include:"attributes"}],attributes:Ut,doubleQuoted:[{match:'"',type:"string",pop:!0},...Ht,{match:String.raw`(?:[^"{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}],singleQuoted:[{match:"'",type:"string",pop:!0},...Ht,{match:String.raw`(?:[^'{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}]},insignificant:["space","newline","comment","text"]}},qt={name:"csharp",aliases:["cs","c#","c-sharp","dotnet"],lexical:{start:"root",states:{root:[{match:String.raw`///[^\r\n]*`,type:"doc-comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*[a-z]+[^\r\n]*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v\u00A0\uFEFF]+`,type:"space"},{match:String.raw`\$*("{3,})[\s\S]*?\1`,type:"string"},{match:String.raw`\$@"|@\$"`,type:"string",push:"interpolatedVerbatim"},{match:String.raw`\$"`,type:"string",push:"interpolated"},{match:String.raw`@"(?:[^"]|"")*"?`,type:"string"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F_]+[uUlL]*|0[bB][01_]+[uUlL]*|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?[fFdDmMuUlL]*`,type:"number"},{match:String.raw`@?[A-Za-z_\u00A0-\uFFFF][\w\u00A0-\uFFFF]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.|::|[;,.]`,type:"punctuation"},{match:String.raw`\?\?=|<<=|>>>=|>>=|>>>|=>|==|!=|<=|>=|&&|\|\||\?\?|\+\+|--|->|<<|[-+*/%&|^<>!=]=?|[~?:]`,type:"operator"}],interpolated:[{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`(?:\\.|[^"\\{}\r\n])+`,type:"string"}],interpolatedVerbatim:[{match:'""',type:"string"},{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`[^"{}]+`,type:"string"}],interpolation:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:["abstract","add","alias","and","args","as","ascending","async","await","base","bool","break","by","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","do","double","dynamic","else","enum","equals","event","explicit","extern","false","file","finally","fixed","float","for","foreach","from","get","global","goto","group","if","implicit","in","init","int","interface","internal","into","is","join","let","lock","long","managed","nameof","namespace","new","nint","not","notnull","nuint","null","object","on","operator","or","orderby","out","override","params","partial","private","protected","public","readonly","record","ref","remove","required","return","sbyte","scoped","sealed","select","set","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unmanaged","unsafe","ushort","using","value","var","virtual","void","volatile","when","where","while","with","yield"]},keywordExceptAfter:[".","?."]}},Qt={name:"c",aliases:["cpp","c++","cc","cxx","h","hpp","hxx","objc"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)|///[^\r\n]*`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*\w+(?:\\\r?\n|[^\r\n])*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v]+`,type:"space"},{match:String.raw`(?:u8|u|U|L)?R"([^()\\\s]{0,16})\([\s\S]*?\)\1"`,type:"string"},{match:String.raw`(?:u8|u|U|L)?"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`(?:u8|u|U|L)?'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F']+[uUlL]*|0[bB][01']+[uUlL]*|(?:\d[\d']*\.?[\d']*|\.\d[\d']*)(?:[eEpP][+-]?\d+)?[fFlLuU]*`,type:"number"},{match:String.raw`[A-Za-z_][\w]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`::|\.\.\.|->\*?|\.\*?|[;,]`,type:"punctuation"},{match:String.raw`<=>|<<=|>>=|<<|>>|\+\+|--|&&|\|\||[-+*/%&|^<>!=]=?|[~?:#]`,type:"operator"}]},keywords:{keyword:["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","bool","true","false","NULL","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","and","and_eq","asm","bitand","bitor","catch","char8_t","char16_t","char32_t","class","co_await","co_return","co_yield","compl","concept","consteval","constexpr","constinit","const_cast","decltype","delete","dynamic_cast","explicit","export","final","friend","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reinterpret_cast","requires","static_assert","static_cast","template","this","thread_local","throw","try","typeid","typename","using","virtual","wchar_t","xor","xor_eq"]},keywordExceptAfter:[".","->","::"]}},Xt={name:"json",aliases:["jsonc","json5","webmanifest"],lexical:{start:"root",states:{root:[{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:String.raw`(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')(?=\s*:)`,type:"attribute"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?|'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`-?(?:0[xX][\da-fA-F]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)|-?Infinity|NaN`,type:"number"},{match:String.raw`[A-Za-z_$][\w$]*`,type:"identifier"},{match:String.raw`[\[\]{}]`,type:"bracket"},{match:String.raw`[:,]`,type:"punctuation"}]},keywords:{keyword:["true","false","null"]}}},Yt={javascript:Ot,"pacem-binding":jt,markup:Pt,csharp:qt,c:Qt,json:Xt};for(let t in Yt){const e=Yt[t];Syntaxes.register(e)}var Zt=Object.freeze({__proto__:null,CSharpSyntax:qt,CSyntax:Qt,DefaultHighlightClasses:U,HighlightRenderer:HighlightRenderer,JavaScriptSyntax:Ot,JsonSyntax:Xt,Markdown:Bt,MarkupSyntax:Pt,PacemBindingSyntax:jt,Parser:x,Scanner:Scanner,get SyntaxTokenType(){return b},Syntaxes:Syntaxes}),Gt=Object.freeze({__proto__:null,Angle:Angle,Arrays:class Arrays{static range(t,e,r=2){let n=t;NullChecker.isNull(e)&&(e=r=t,t=1);const s=(e-t)/(r-1),i=[];if(s>0)for(;i.length<r;)i.push(n.roundoff()),n+=s;return i}static chunkify(t,e){if(NullChecker.isNullOrEmpty(t))return[];if(e<=0||e%1!=0)throw new Error("Provide a positive integer number.");const r=Math.ceil(t.length/e);return Array.from({length:r},(r,n)=>{const s=n*e,i=s+e;return t.slice(s,i)})}},Blobs:Blobs,Colors:Colors,Compile:Zt,Dates:Dates,DeepMerger:DeepMerger,HistoryService:class HistoryService{constructor(t,e){this.#i=t,this.#a=e}#o=[];#c=[];#a;#i;get current(){return this.#i}get canUndo(){return this.#o.length>0}get canRedo(){return this.#c.length>0}set maxlength(t){this.#a=t}undo(){if(this.canUndo){const t=this.#o,e=this.#c,r=this.#i;e.unshift(r),this.#i=t.pop()}}redo(){if(this.canRedo){const t=this.#o,e=this.#c,r=this.#i;t.push(r),this.#i=e.shift()}}push(t){this.#c.splice(0),this.#o.push(this.#i),this.#i=t;const e=this.#a,r=this.#o;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#c.splice(0),this.#o.splice(0)}},Imaging:Imaging,Keys:Keys,Matrix2D:Matrix2D,NullChecker:NullChecker,Numbers:class Numbers{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){const n=t.toString(),s=parseInt(n,e);return n.endsWith(s.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}},Point:Point,Rect:Rect,Size:Size,Strings:class Strings{static leftPad(t,e,r){return t.toString().padStart(e,r)}static format(t,...e){const r=Array.from(e);let n=t;for(let t=0;t<r.length;t++){const e=new RegExp("(^|[^\\{])\\{"+t+"\\}($|[^\\}])","g");n=n.replaceAll(e,(e,...n)=>e.replace("{"+t+"}",r[t]))}const s=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(n);if(!NullChecker.isNullOrEmpty(s))throw new Error(`Missing argument at index ${s[2]}.`);return n}static diff(t,e,r="char"){switch(r){case"line":return function(t,e){const r=/\r?\n/,n=t.split(r),s=e.split(r);return w(n,s,m(n,s),"\n")}(t,e);case"word":return function(t,e){const r=/(\S+|\s+)/g,n=t.match(r)||[],s=e.match(r)||[];return w(n,s,m(n,s),"")}(t,e);default:return function(t,e){const r=t.split(""),n=e.split("");return w(r,n,m(r,n),"")}(t,e)}}static async hash(t,e="SHA-256"){const r=await crypto.subtle.digest(e,(new TextEncoder).encode(t));return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("")}},detect:function(t=navigator.userAgent){let e="unknown",r=null;switch(/ucbrowser/i.test(t)?e="UCBrowser":/edg/i.test(t)?e="Edge":/googlebot/i.test(t)?e="GoogleBot":/chromium/i.test(t)?e="Chromium":/firefox|fxios/i.test(t)&&!/seamonkey/i.test(t)?e="Firefox":/; msie|trident/i.test(t)&&!/ucbrowser/i.test(t)?e="IE":/chrome|crios/i.test(t)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(t)?e="Chrome":/safari/i.test(t)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(t)?e="Safari":/opr|opera/i.test(t)&&(e="Opera"),e){case"UCBrowser":r=n(t,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":r=n(t,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":r=n(t,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":r=n(t,/(chromium)\/([\d\.]+)/i);break;case"Firefox":r=n(t,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":r=n(t,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":r=n(t,/(safari)\/([\d\.]+)/i);break;case"Opera":r=n(t,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{const e=n(t,/(trident)\/([\d\.]+)/i);r=e?`${parseFloat(e)+4}`:"7.0";break}default:r="0.0.0.0"}return{name:e,version:r}},parseAsNumericalArray:f});DeepMerger.merge(Gt)}();
@@ -1,13 +1,16 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v1.0.6-ricci (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
6
- var wt=Object.defineProperty;var W=(r,t)=>{for(var e in t)wt(r,e,{get:t[e],enumerable:!0})};Number.prototype.isCloseTo=function(r,t=14){let e=+`1e-${t}`;return this>r-e&&this<r+e};Number.prototype.roundoff=function(r=14){return parseFloat(this.toFixed(r))};Number.prototype.clamp=function(r,t){let e=this;return r!=null&&!isNaN(r)&&(e=Math.max(e,r)),t!=null&&!isNaN(t)&&(e=Math.min(e,t)),e};Number.prototype.toBase62=function(){for(var r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t=this,e="";t!=0;){var n=t%62;e=r.charAt(n)+e,t=Math.floor(t/62)}return e};Number.prototype.toBase36=function(){return this.toString(36)};var mt=/^\/Date\([\d]+\)\/$/i,M=class r{static parse(t){let e;return typeof t=="string"?(mt.test(t)?e=parseInt(t.substring(6)):e=Date.parse(t),new Date(e)):typeof t=="number"?new Date(t):t}static isLeapYear(t){return t%4===0&&t%100!==0||t%400===0}static daysInMonth(t,e){return[31,r.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let n=t.getDate(),s=new Date(t),i=s.getMonth()+e,a=0;for(;i<0;)i+=12,a--;return s.setDate(1),s.setMonth(i%12),s.setFullYear(s.getFullYear()+a+Math.floor(i/12)),s.setDate(Math.min(n,r.daysInMonth(s.getFullYear(),s.getMonth()))),s}static addDays(t,e){return new Date(t.valueOf()+e*864e5)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}};var k=class r{static isNull(t){return t==null}static isEmpty(t){try{return Array.isArray(t)&&t.length===0||typeof t=="string"&&t===""||typeof t=="object"&&Object.keys(t).length===0&&!M.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch{return!1}}static isNullOrEmpty(t){return r.isNull(t)||r.isEmpty(t)}};Array.prototype.distinct=function(){return Array.from(new Set(this))};Array.prototype.union=function(r){let t=k.isNullOrEmpty(this),e=k.isNullOrEmpty(r);return t&&e?[]:e?this.slice():t?r.slice():this.concat(r).distinct()};Array.prototype.moveWithin=function(r,t){let e="Index must be greater or equal than 0 and less or equal than the length of the array.";var n=this;if(r<0||r>n.length)throw new Error(e);if(t<0||t>n.length)throw new Error(e);n.splice(t,0,Array.prototype.splice.apply(n,[r,1])[0])};Array.prototype.equalsContent=function(r){if(r==null||this.length!==r.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==r[t])return!1;return!0};Array.prototype.cloneFrom=function(r){if(r==null)throw"Cannot clone array from null object.";let t=r.length;var e=this.length!==r.length;for(let n=0;n<t;n++){let s=r[n];this.length>n?this[n]!==s&&(this[n]=s,e=!0):(Array.prototype.push.apply(this,[s]),e=!0)}e&&this.splice(t)};function K(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)&&(r.constructor===Object||r.constructor===void 0)}function et(r,t){let e=r;for(let n of Object.keys(t)){let s=t[n],i=e[n];K(s)?e[n]=et(K(i)?i:{},s):Array.isArray(s)?e[n]=s.slice():e[n]=s}return e}var tt=class{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},et(e,t)}};var rt=class{static range(t,e,n=2){let s=t;k.isNull(e)&&(e=n=t,t=1);let i=(e-t)/(n-1),a=[];if(i>0)for(;a.length<n;)a.push(s.roundoff()),s+=i;return a}static chunkify(t,e){if(k.isNullOrEmpty(t))return[];if(e<=0||e%1!==0)throw new Error("Provide a positive integer number.");let n=Math.ceil(t.length/e);return Array.from({length:n},(s,i)=>{let a=i*e,h=a+e;return t.slice(a,h)})}};var nt=class r{static blobToDataURL(t){return new Promise((e,n)=>{let s=new FileReader;s.onload=i=>{e(i.target.result)},s.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length,n=new Uint8Array(e);for(;e--;)n[e]=t.charCodeAt(e);return n}static base64ToBlob(t,e){let n=r._b64ToUint8Array(atob(t));return new Blob([n],e)}static dataURLToBlob(t){let e=t.indexOf(",");if(e===-1)return r.base64ToBlob(t);{let n=t.substring(e+1),i=t.substring(0,e).match(/:(.*?);/)[1];return r.base64ToBlob(n,{type:i})}}static async blobToText(t,e){let n=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(n)}static textToBlob(t,e="text/plain",n="utf-8",s,i=63){let a=n.toLowerCase(),h=()=>`${e};charset=${a}`;switch(a){case"utf-8":{let f=new TextEncoder().encode(t),w=s?[new Uint8Array([239,187,191]),f]:[f];return new Blob(w,{type:h()})}case"utf-16":a="utf-16le",s??=!0;case"utf-16le":case"utf-16be":{let u=a!=="utf-16be",f=s?1:0,w=new ArrayBuffer((t.length+f)*2),g=new DataView(w);s&&g.setUint16(0,65279,u);for(let b=0;b<t.length;b++)g.setUint16((b+f)*2,t.charCodeAt(b),u);return new Blob([w],{type:h()})}case"ascii":case"iso-8859-1":case"latin1":{let u=a==="ascii"?127:255,f=new Uint8Array(t.length),w=i>0;for(let g=0;g<t.length;g++){let b=t.charCodeAt(g);if(b>u)if(w)f[g]=i;else throw new Error(`Character "${t[g]}" cannot be encoded in ${n}.`);else f[g]=b}return new Blob([f],{type:h()})}default:throw new Error(`Encoding "${n}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}};var E=(r,t)=>{let e=r.match(t);return e?e[2]:null};function he(r=navigator.userAgent){let t="unknown",e=null;switch(/ucbrowser/i.test(r)?t="UCBrowser":/edg/i.test(r)?t="Edge":/googlebot/i.test(r)?t="GoogleBot":/chromium/i.test(r)?t="Chromium":/firefox|fxios/i.test(r)&&!/seamonkey/i.test(r)?t="Firefox":/; msie|trident/i.test(r)&&!/ucbrowser/i.test(r)?t="IE":/chrome|crios/i.test(r)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(r)?t="Chrome":/safari/i.test(r)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(r)?t="Safari":/opr|opera/i.test(r)&&(t="Opera"),t){case"UCBrowser":e=E(r,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":e=E(r,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":e=E(r,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":e=E(r,/(chromium)\/([\d\.]+)/i);break;case"Firefox":e=E(r,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":e=E(r,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":e=E(r,/(safari)\/([\d\.]+)/i);break;case"Opera":e=E(r,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{let n=E(r,/(trident)\/([\d\.]+)/i);e=n?`${parseFloat(n)+4}`:"7.0";break}default:e="0.0.0.0";break}return{name:t,version:e}}var st=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,it=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,at=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,ot=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,ct=/^#[a-f0-9]{6}$/,lt=/^#[a-f0-9]{3}$/;function L(r){return!k.isNullOrEmpty(r)&&typeof r=="object"&&"r"in r&&"g"in r&&"b"in r&&typeof r.r=="number"&&typeof r.b=="number"&&typeof r.g=="number"?(r.a??=1,r.r>=0&&r.r<=1&&r.g>=0&&r.g<=1&&r.b>=0&&r.b<=1&&r.a>=0&&r.a<=1):!1}function B(r){return!k.isNullOrEmpty(r)&&typeof r=="object"&&"h"in r&&"s"in r&&"l"in r&&typeof r.h=="number"&&typeof r.s=="number"&&typeof r.l=="number"?(r.a??=1,r.h>=0&&r.h<=360&&r.s>=0&&r.s<=1&&r.l>=0&&r.l<=1&&r.a>=0&&r.a<=1):!1}function kt(r){let t=r.r,e=r.g,n=r.b;return(.5*(Math.max(t,e,n)+Math.min(t,e,n))).clamp(0,1)}var C={adjustRgbChannel:r=>r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4),adjustRgbChannelInv:r=>r<=.00304?r*12.92:1.055*(Math.pow(r,1/2.4)-.055),adjustRgb:r=>({r:C.adjustRgbChannel(r.r),g:C.adjustRgbChannel(r.g),b:C.adjustRgbChannel(r.b),a:r.a}),adjustRgbInv:r=>({r:C.adjustRgbChannelInv(r.r),g:C.adjustRgbChannelInv(r.g),b:C.adjustRgbChannelInv(r.b),a:r.a}),X:r=>.4125*r.r+.3576*r.g+.1804*r.b,Y:r=>.2126*r.r+.7152*r.g+.0722*r.b,Z:r=>.0193*r.r+.1191*r.g+.9503*r.b,relativeLuminance:r=>{let t=C.adjustRgb(r);return C.Y(t)},rgbToCieXYZ:r=>{let t=C.adjustRgb(r);return{x:C.X(t),y:C.Y(t),z:C.Z(t),a:r.a}},cieXYZToRgb:r=>{let t=3.241*r.x-1.5374*r.y-.4986*r.z,e=-.9692*r.x+1.876*r.y+.0416*r.z,n=.0556*r.x-.204*r.y+1.057*r.z;return C.adjustRgbInv({r:t,g:e,b:n,a:r.a})},contrastRatio:(r,t)=>{let e=C.relativeLuminance(r)+.05,n=C.relativeLuminance(t)+.05;return e>n?e/n:n/e}};function Ct(r,t){let e=r.r,n=r.g,s=r.b,i=Math.max(e,n,s),a=Math.min(e,n,s);return(t===0||t===1?0:(i-a)/(1-Math.abs(2*t-1))).clamp(0,1)}function It(r){let t=r.r,e=r.g,n=r.b,s=Math.max(t,e,n),i=Math.min(t,e,n),a=0;return s!==i&&(s===t?a=(60*((e-n)/(s-i))+360)%360:s===e?a=(60*((n-t)/(s-i))+120)%360:a=(60*((t-e)/(s-i))+240)%360),a.clamp(0,360)}function V(r){return r.toString(16).padStart(2,"0")}var ut=class r{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){let e=n=>Math.min(1,Math.max(0,n));return t[3]==null&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),at.test(t)){let e=at.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(ot.test(t)){let e=ot.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(ct.test(t)){let e=ct.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(lt.test(t)){let e=lt.exec(t)[0],n=e.substr(1,1),s=e.substr(2,1),i=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+n+n),parseInt("0x"+s+s),parseInt("0x"+i+i),1]))}if(st.test(t)){let e=st.exec(t),n={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01};return this.rgb(n)}if(it.test(t)){let e=it.exec(t),n={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01,a:parseFloat(e[4])};return this.rgb(n)}}static hsl(t){let e=kt(t),n=Ct(t,e);return{h:It(t),s:n,l:e,a:t.a}}static cieXYZ(t){return B(t)&&(t=this.rgb(t)),C.rgbToCieXYZ(t)}static rgb(t){if(B(t)){let e=t.h,n=t.s,s=t.l,i=e/60,a=(1-Math.abs(2*s-1))*n,h=a*(1-Math.abs(i%2-1)),u=s-a/2,f=(w,g,b)=>this._clampRGB([w+u,g+u,b+u,t.a]);if(i<=1)return f(a,h,0);if(i<=2)return f(h,a,0);if(i<=3)return f(0,a,h);if(i<=4)return f(0,h,a);if(i<=5)return f(h,0,a);if(i<=6)return f(a,0,h)}else{let e=C.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}}static stringify(t,e=1){if(B(t)){e??=1,t.a??=1;let n=typeof e=="number"?e:1;return`hsla(${t.h.roundoff(n)},${(t.s*100).roundoff(n)}%,${(t.l*100).roundoff(n)}%,${t.a.roundoff()})`}else if(L(t)){e??=!0,t.a??=1;let n=typeof e=="boolean"?e:!!e,s=Math.round(t.r*255),i=Math.round(t.g*255),a=Math.round(t.b*255),h=t.a.roundoff();return h===1?n?("#"+V(s)+V(i)+V(a)).toUpperCase():`rgb(${s},${i},${a})`:`rgba(${s},${i},${a},${h})`}}static contrastRatio(t,e){return B(t)&&(t=this.rgb(t)),B(e)&&(e=this.rgb(e)),C.contrastRatio(t,e)}static luminance(t){return B(t)&&(t=r.rgb(t)),C.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,B(t)){let n=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:n})}if(L(t)){let n=this.lighten(this.hsl(t),e);return this.rgb(n)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,B(t)){let n=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:n})}if(L(t)){let n=this.saturate(this.hsl(t),e);return this.rgb(n)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,n,s){n??=.5,s??=n;let i=(n+s).roundoff(),a=(n/i).roundoff(),h=(s/i).roundoff(),u=L(t),f=B(t),w=b=>L(b)||B(b)?r.cieXYZ(b):b;t=w(t),e=w(e);let g={x:(t.x*a+e.x*h).roundoff(),y:(t.y*a+e.y*h).roundoff(),z:(t.z*a+e.z*h).roundoff(),a:(t.a*a+e.a*h).roundoff()};return u?r.rgb(g):f?r.hsl(r.rgb(g)):g}};var $t=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function X(r){let t=[],e=r.match($t);return e&&e.length>0&&e.forEach(n=>t.push(parseFloat(n))),t}var ht=class r{static isAngle(t){return typeof t=="object"&&"vertex"in t&&z.isPoint(t.vertex)&&"start"in t&&z.isPoint(t.start)&&"end"in t&&z.isPoint(t.end)}static value(t){if(k.isNullOrEmpty(t)||!r.isAngle(t))return Number.NaN;let{vertex:e,start:n,end:s}=t;return r.angleBetween(e,n,s)}static angleBetween(t,e,n){let s={x:e.x-t.x,y:e.y-t.y},i={x:n.x-t.x,y:n.y-t.y},a=s.x*i.x+s.y*i.y,h=s.x*i.y-s.y*i.x;return-Math.atan2(h,a)}},P=class{static parse(t){let e=X(t);if(e&&e.length===2)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return typeof t=="object"&&"width"in t&&typeof t.width=="number"&&"height"in t&&typeof t.height=="number"}},z=class{static parse(t){let e=X(t);if(e&&e.length===2)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return typeof t=="object"&&"x"in t&&typeof t.x=="number"&&"y"in t&&typeof t.y=="number"}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var n of t)e.x+=n.x,e.y+=n.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}};var G=class r{static isIdentity(t){return t.a===1&&t.d===1&&t.b===0&&t.f===0&&t.c===0&&t.e===0}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,n=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*n,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){let n=Math.cos(e),s=Math.sin(e);return r.multiply(t,{a:n,b:s,c:-s,d:n,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?typeof e=="number"?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:typeof e=="number"?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){let e=this.det(t);if(e===0)return null;let n=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},n)}static toComponents(t,e={x:0,y:0}){let n=Math.sqrt(t.a*t.a+t.c*t.c),s=Math.sqrt(t.b*t.b+t.d*t.d),i=n!=0?t.a/n:0,a=n!=0?t.c/n:0,h=Math.atan2(a,i),{x:u,y:f}=e,w={x:t.e-u*(n*i-1)+f*n*a,y:t.f-f*(s*i-1)-u*s*a};return{scaleX:n,scaleY:s,rotation:h,translation:w}}static fromTransform([t,e,n],[s,i,a]){let h=t.x*(e.y-n.y)-t.y*(e.x-n.x)+(e.x*n.y-n.x*e.y);if(Math.abs(h)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");let u=1/h;return{a:u*(s.x*(e.y-n.y)+i.x*(n.y-t.y)+a.x*(t.y-e.y)),b:u*(s.y*(e.y-n.y)+i.y*(n.y-t.y)+a.y*(t.y-e.y)),c:u*(s.x*(n.x-e.x)+i.x*(t.x-n.x)+a.x*(e.x-t.x)),d:u*(s.y*(n.x-e.x)+i.y*(t.x-n.x)+a.y*(e.x-t.x)),e:u*(s.x*(e.x*n.y-n.x*e.y)+i.x*(n.x*t.y-t.x*n.y)+a.x*(t.x*e.y-e.x*t.y)),f:u*(s.y*(e.x*n.y-n.x*e.y)+i.y*(n.x*t.y-t.x*n.y)+a.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,n=12){return t.a.isCloseTo(e.a,n)&&t.b.isCloseTo(e.b,n)&&t.c.isCloseTo(e.c,n)&&t.d.isCloseTo(e.d,n)&&t.e.isCloseTo(e.e,n)&&t.f.isCloseTo(e.f,n)}};var Q=class r{static parse(t){let e=X(t);if(e&&e.length===4)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return z.isPoint(t)&&P.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,n,s){let i=1,a=t.width/t.height,h=e.width/e.height;a>=h?i=e.width/t.width:i=e.height/t.height;let u=t.width*i,f=t.height*i,w=this._align({x:t.x,y:t.y,width:u,height:f},e,n,s);return G.translate({a:i,b:0,c:0,d:i,e:0,f:0},w)}static _cover(t,e,n,s){let i=1,a=t.width/t.height,h=e.width/e.height;a<h?i=e.width/t.width:i=e.height/t.height;let u=t.width*i,f=t.height*i,w=this._align({x:t.x,y:t.y,width:u,height:f},e,n,s);return G.translate({a:i,b:0,c:0,d:i,e:0,f:0},w)}static _align(t,e,n,s){let i=0,a=0;switch(n){case"left":i=e.x-t.x;break;case"right":i=e.x+e.width-t.width-t.x;break;default:i=e.x+e.width*.5-t.width*.5-t.x;break}switch(s){case"top":a=e.y-t.y;break;case"bottom":a=e.y+e.height-t.height-t.y;break;default:a=e.y+e.height*.5-t.height*.5-t.y;break}return{x:i,y:a}}static findTransform(t,e,n="stretch",s="center",i="middle"){switch(n){case"contain":return this._contain(t,e,s,i);case"cover":return this._cover(t,e,s,i);default:return this._stretch(t,e)}}static intersect(...t){let e={x:0,y:0,height:0,width:0},n=Array.from(t||[]);if(n.length<=0)return e;for(var s=n[0],i=1;i<n.length;i++){let a=n[i],h=Math.max(a.x,s.x),u=Math.max(a.y,s.y),f=Math.min(a.x+a.width,s.x+s.width),w=Math.min(a.y+a.height,s.y+s.height),g=f-h,b=w-u;if(g<0||b<=0)return e;s={x:h,y:u,width:g,height:b}}return s}static expand(t,...e){let n=Array.from(e||[]),s=t.x,i=t.y,a=s,h=i;r.isRect(t)&&(a+=t.width,h+=t.height);for(let u of n)s=Math.min(u.x,s),i=Math.min(u.y,i),a=Math.max(u.x,a),h=Math.max(u.y,h);return{x:s,y:i,width:a-s,height:h-i}}};var ft=class{constructor(t,e){this.#e=t,this.#n=e}#t=[];#r=[];#n;#e;get current(){return this.#e}get canUndo(){return this.#t.length>0}get canRedo(){return this.#r.length>0}set maxlength(t){this.#n=t}undo(){if(this.canUndo){let t=this.#t,e=this.#r,n=this.#e;e.unshift(n),this.#e=t.pop()}}redo(){if(this.canRedo){let t=this.#t,e=this.#r,n=this.#e;t.push(n),this.#e=e.shift()}}push(t){this.#r.splice(0),this.#t.push(this.#e),this.#e=t;let e=this.#n,n=this.#t;e>0&&n.length>e&&n.splice(0,n.length-e)}reset(){this.#r.splice(0),this.#t.splice(0)}};var vt={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"},dt=class r{static async loadImage(t){let e=await fetch(t);return e.ok?await e.blob():null}static async resizeImage(t,e,n,s){if(e<=0||n<=0||isNaN(e)||isNaN(n))throw new Error("Invalid target size");typeof t=="string"&&(t=await r.loadImage(t));let i=await self.createImageBitmap(t),a=i.width,h=i.height,u=new OffscreenCanvas(a,h),f=u.getContext("2d");f.imageSmoothingEnabled=f.mozImageSmoothingEnabled=f.oImageSmoothingEnabled=f.webkitImageSmoothingEnabled=!0;let{quality:w,type:g,mode:b,align:F,valign:v,background:d}=Object.assign({},vt,s??{}),l={width:a,height:h,x:0,y:0},o={x:0,y:0,width:e,height:n},c=Q.findTransform(l,o,b,F,v);return u.width=e,u.height=n,d&&(f.fillStyle=d,f.fillRect(0,0,u.width,u.height)),f.setTransform(c),f.drawImage(i,0,0),await u.convertToBlob({quality:w,type:g})}};var xt=class r{static#t;static uniqueId(){let t=r.#t||Date.now();return r.#t=++t}static uniqueCode(){return r.uniqueId().toBase62()}static randomString(t){let e="";do e+=(Math.random()*62).toBase62();while(e.length<t);return e}};var pt=class{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,n){let s=t.toString(),i=parseInt(s,e);return s.endsWith(i.toString(e))?parseInt(t.toString(),e).toString(n):Number.NaN.toString()}};function A(r,t){let e=r.length,n=t.length,s=Array.from({length:e+1},()=>Array(n+1).fill(0));for(let i=1;i<=e;i++)for(let a=1;a<=n;a++)r[i-1]===t[a-1]?s[i][a]=s[i-1][a-1]+1:s[i][a]=Math.max(s[i-1][a],s[i][a-1]);return s}function q(r,t,e,n=""){let s=r.length,i=t.length,a=[],h=s,u=i,f=null,w=()=>{f&&(a.push(f),f=null)};for(;h>0||u>0;){var g=null;let b=null;h>0&&u>0&&r[h-1]===t[u-1]?(g="=",b=r[h-1],h--,u--):u>0&&(h===0||e[h][u-1]>=e[h-1][u])?(g="+",b=t[u-1],u--):h>0&&(u===0||e[h-1][u]>e[h][u-1])&&(g="-",b=r[h-1],h--),g&&b!==null?f&&f.type===g?f.value=b+(f.value?n:"")+f.value:(w(),f={type:g,value:b}):w()}return w(),a.reverse()}function Bt(r,t){let e=r.split(""),n=t.split(""),s=A(e,n);return q(e,n,s,"")}function Tt(r,t){let e=/(\S+|\s+)/g,n=r.match(e)||[],s=t.match(e)||[],i=A(n,s);return q(n,s,i,"")}function Et(r,t){let e=/\r?\n/,n=r.split(e),s=t.split(e),i=A(n,s);return q(n,s,i,`
7
- `)}var yt=class{static leftPad(t,e,n){return t.toString().padStart(e,n)}static format(t,...e){let n=Array.from(e),s=t;for(let a=0;a<n.length;a++){let h=new RegExp("(^|[^\\{])\\{"+a+"\\}($|[^\\}])","g");s=s.replaceAll(h,(u,...f)=>u.replace("{"+a+"}",n[a]))}let i=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(s);if(!k.isNullOrEmpty(i))throw new Error(`Missing argument at index ${i[2]}.`);return s}static diff(t,e,n="char"){switch(n){case"line":return Et(t,e);case"word":return Tt(t,e);default:return Bt(t,e)}}static async hash(t,e="SHA-256"){let n=await crypto.subtle.digest(e,new TextEncoder().encode(t));return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}};var bt={};W(bt,{Markdown:()=>D,Parser:()=>j});var D={};W(D,{Parser:()=>R});var J=class{tokenize(t,e){let n=[];for(;t;){let s=t.length;for(let i of e){let a=i.exec(t,this),h=a?.length;if(h>0){Array.prototype.push.apply(n,a);let u=a[h-1];t=t.substr((u.index||0)+u.raw.length);break}}if(t.length>=s)throw new Error(`Cannot parse
6
+ var Wt=Object.defineProperty;var kt=(n,t)=>{for(var e in t)Wt(n,e,{get:t[e],enumerable:!0})};Number.prototype.isCloseTo=function(n,t=14){let e=+`1e-${t}`;return this>n-e&&this<n+e};Number.prototype.roundoff=function(n=14){return parseFloat(this.toFixed(n))};Number.prototype.clamp=function(n,t){let e=this;return n!=null&&!isNaN(n)&&(e=Math.max(e,n)),t!=null&&!isNaN(t)&&(e=Math.min(e,t)),e};Number.prototype.toBase62=function(){for(var n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t=this,e="";t!=0;){var r=t%62;e=n.charAt(r)+e,t=Math.floor(t/62)}return e};Number.prototype.toBase36=function(){return this.toString(36)};var Kt=/^\/Date\([\d]+\)\/$/i,V=class n{static parse(t){let e;return typeof t=="string"?(Kt.test(t)?e=parseInt(t.substring(6)):e=Date.parse(t),new Date(e)):typeof t=="number"?new Date(t):t}static isLeapYear(t){return t%4===0&&t%100!==0||t%400===0}static daysInMonth(t,e){return[31,n.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}static isDate(t){return t instanceof Date&&!isNaN(t.valueOf())}static dateOnly(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}static addMonths(t,e){let r=t.getDate(),s=new Date(t),i=s.getMonth()+e,o=0;for(;i<0;)i+=12,o--;return s.setDate(1),s.setMonth(i%12),s.setFullYear(s.getFullYear()+o+Math.floor(i/12)),s.setDate(Math.min(r,n.daysInMonth(s.getFullYear(),s.getMonth()))),s}static addDays(t,e){return new Date(t.valueOf()+e*864e5)}static daysBetween(t,e){return(e.valueOf()-t.valueOf())/864e5}};var _=class n{static isNull(t){return t==null}static isEmpty(t){try{return Array.isArray(t)&&t.length===0||typeof t=="string"&&t===""||typeof t=="object"&&Object.keys(t).length===0&&!V.isDate(t)&&!(t instanceof RegExp)&&!(t instanceof FileSystemDirectoryHandle)&&!(t instanceof FileSystemFileHandle)}catch{return!1}}static isNullOrEmpty(t){return n.isNull(t)||n.isEmpty(t)}};Array.prototype.distinct=function(){return Array.from(new Set(this))};Array.prototype.union=function(n){let t=_.isNullOrEmpty(this),e=_.isNullOrEmpty(n);return t&&e?[]:e?this.slice():t?n.slice():this.concat(n).distinct()};Array.prototype.moveWithin=function(n,t){let e="Index must be greater or equal than 0 and less or equal than the length of the array.";var r=this;if(n<0||n>r.length)throw new Error(e);if(t<0||t>r.length)throw new Error(e);r.splice(t,0,Array.prototype.splice.apply(r,[n,1])[0])};Array.prototype.equalsContent=function(n){if(n==null||this.length!==n.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==n[t])return!1;return!0};Array.prototype.cloneFrom=function(n){if(n==null)throw"Cannot clone array from null object.";let t=n.length;var e=this.length!==n.length;for(let r=0;r<t;r++){let s=n[r];this.length>r?this[r]!==s&&(this[r]=s,e=!0):(Array.prototype.push.apply(this,[s]),e=!0)}e&&this.splice(t)};function _t(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)&&(n.constructor===Object||n.constructor===void 0)}function $t(n,t){let e=n;for(let r of Object.keys(t)){let s=t[r],i=e[r];_t(s)?e[r]=$t(_t(i)?i:{},s):Array.isArray(s)?e[r]=s.slice():e[r]=s}return e}var St=class{constructor(){}static merge(t,e){return e??=globalThis.Pacem??={},$t(e,t)}};var Ct=class{static range(t,e,r=2){let s=t;_.isNull(e)&&(e=r=t,t=1);let i=(e-t)/(r-1),o=[];if(i>0)for(;o.length<r;)o.push(s.roundoff()),s+=i;return o}static chunkify(t,e){if(_.isNullOrEmpty(t))return[];if(e<=0||e%1!==0)throw new Error("Provide a positive integer number.");let r=Math.ceil(t.length/e);return Array.from({length:r},(s,i)=>{let o=i*e,h=o+e;return t.slice(o,h)})}};var Tt=class n{static blobToDataURL(t){return new Promise((e,r)=>{let s=new FileReader;s.onload=i=>{e(i.target.result)},s.readAsDataURL(t)})}static _b64ToUint8Array(t){let e=t.length,r=new Uint8Array(e);for(;e--;)r[e]=t.charCodeAt(e);return r}static base64ToBlob(t,e){let r=n._b64ToUint8Array(atob(t));return new Blob([r],e)}static dataURLToBlob(t){let e=t.indexOf(",");if(e===-1)return n.base64ToBlob(t);{let r=t.substring(e+1),i=t.substring(0,e).match(/:(.*?);/)[1];return n.base64ToBlob(r,{type:i})}}static async blobToText(t,e){let r=await t.arrayBuffer();return new TextDecoder(e,{fatal:!1}).decode(r)}static textToBlob(t,e="text/plain",r="utf-8",s,i=63){let o=r.toLowerCase(),h=()=>`${e};charset=${o}`;switch(o){case"utf-8":{let d=new TextEncoder().encode(t),x=s?[new Uint8Array([239,187,191]),d]:[d];return new Blob(x,{type:h()})}case"utf-16":o="utf-16le",s??=!0;case"utf-16le":case"utf-16be":{let l=o!=="utf-16be",d=s?1:0,x=new ArrayBuffer((t.length+d)*2),w=new DataView(x);s&&w.setUint16(0,65279,l);for(let b=0;b<t.length;b++)w.setUint16((b+d)*2,t.charCodeAt(b),l);return new Blob([x],{type:h()})}case"ascii":case"iso-8859-1":case"latin1":{let l=o==="ascii"?127:255,d=new Uint8Array(t.length),x=i>0;for(let w=0;w<t.length;w++){let b=t.charCodeAt(w);if(b>l)if(x)d[w]=i;else throw new Error(`Character "${t[w]}" cannot be encoded in ${r}.`);else d[w]=b}return new Blob([d],{type:h()})}default:throw new Error(`Encoding "${r}" is not supported safely in the browser. Use UTF-8 or any supported encoding.`)}}};var L=(n,t)=>{let e=n.match(t);return e?e[2]:null};function Xn(n=navigator.userAgent){let t="unknown",e=null;switch(/ucbrowser/i.test(n)?t="UCBrowser":/edg/i.test(n)?t="Edge":/googlebot/i.test(n)?t="GoogleBot":/chromium/i.test(n)?t="Chromium":/firefox|fxios/i.test(n)&&!/seamonkey/i.test(n)?t="Firefox":/; msie|trident/i.test(n)&&!/ucbrowser/i.test(n)?t="IE":/chrome|crios/i.test(n)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(n)?t="Chrome":/safari/i.test(n)&&!/chromium|edg|ucbrowser|chrome|crios|opr|opera|fxios|firefox/i.test(n)?t="Safari":/opr|opera/i.test(n)&&(t="Opera"),t){case"UCBrowser":e=L(n,/(ucbrowser)\/([\d\.]+)/i);break;case"Edge":e=L(n,/(edge|edga|edgios|edg)\/([\d\.]+)/i);break;case"GoogleBot":e=L(n,/(googlebot)\/([\d\.]+)/i);break;case"Chromium":e=L(n,/(chromium)\/([\d\.]+)/i);break;case"Firefox":e=L(n,/(firefox|fxios)\/([\d\.]+)/i);break;case"Chrome":e=L(n,/(chrome|crios)\/([\d\.]+)/i);break;case"Safari":e=L(n,/(safari)\/([\d\.]+)/i);break;case"Opera":e=L(n,/(opera|opr)\/([\d\.]+)/i);break;case"IE":{let r=L(n,/(trident)\/([\d\.]+)/i);e=r?`${parseFloat(r)+4}`:"7.0";break}default:e="0.0.0.0";break}return{name:t,version:e}}var vt=/^hsl\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*\)$/,It=/^hsla\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)%\s*,\s*([\d\.]+)\)$/,Et=/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/,Ft=/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\)$/,Bt=/^#[a-f0-9]{6}$/,At=/^#[a-f0-9]{3}$/;function R(n){return!_.isNullOrEmpty(n)&&typeof n=="object"&&"r"in n&&"g"in n&&"b"in n&&typeof n.r=="number"&&typeof n.b=="number"&&typeof n.g=="number"?(n.a??=1,n.r>=0&&n.r<=1&&n.g>=0&&n.g<=1&&n.b>=0&&n.b<=1&&n.a>=0&&n.a<=1):!1}function A(n){return!_.isNullOrEmpty(n)&&typeof n=="object"&&"h"in n&&"s"in n&&"l"in n&&typeof n.h=="number"&&typeof n.s=="number"&&typeof n.l=="number"?(n.a??=1,n.h>=0&&n.h<=360&&n.s>=0&&n.s<=1&&n.l>=0&&n.l<=1&&n.a>=0&&n.a<=1):!1}function te(n){let t=n.r,e=n.g,r=n.b;return(.5*(Math.max(t,e,r)+Math.min(t,e,r))).clamp(0,1)}var S={adjustRgbChannel:n=>n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),adjustRgbChannelInv:n=>n<=.00304?n*12.92:1.055*(Math.pow(n,1/2.4)-.055),adjustRgb:n=>({r:S.adjustRgbChannel(n.r),g:S.adjustRgbChannel(n.g),b:S.adjustRgbChannel(n.b),a:n.a}),adjustRgbInv:n=>({r:S.adjustRgbChannelInv(n.r),g:S.adjustRgbChannelInv(n.g),b:S.adjustRgbChannelInv(n.b),a:n.a}),X:n=>.4125*n.r+.3576*n.g+.1804*n.b,Y:n=>.2126*n.r+.7152*n.g+.0722*n.b,Z:n=>.0193*n.r+.1191*n.g+.9503*n.b,relativeLuminance:n=>{let t=S.adjustRgb(n);return S.Y(t)},rgbToCieXYZ:n=>{let t=S.adjustRgb(n);return{x:S.X(t),y:S.Y(t),z:S.Z(t),a:n.a}},cieXYZToRgb:n=>{let t=3.241*n.x-1.5374*n.y-.4986*n.z,e=-.9692*n.x+1.876*n.y+.0416*n.z,r=.0556*n.x-.204*n.y+1.057*n.z;return S.adjustRgbInv({r:t,g:e,b:r,a:n.a})},contrastRatio:(n,t)=>{let e=S.relativeLuminance(n)+.05,r=S.relativeLuminance(t)+.05;return e>r?e/r:r/e}};function ee(n,t){let e=n.r,r=n.g,s=n.b,i=Math.max(e,r,s),o=Math.min(e,r,s);return(t===0||t===1?0:(i-o)/(1-Math.abs(2*t-1))).clamp(0,1)}function ne(n){let t=n.r,e=n.g,r=n.b,s=Math.max(t,e,r),i=Math.min(t,e,r),o=0;return s!==i&&(s===t?o=(60*((e-r)/(s-i))+360)%360:s===e?o=(60*((r-t)/(s-i))+120)%360:o=(60*((t-e)/(s-i))+240)%360),o.clamp(0,360)}function et(n){return n.toString(16).padStart(2,"0")}var Lt=class n{static{this.WCAG_MINIMUM_CONTRAST=3}static{this.WCAG_NORMAL_TEXT_CONTRAST=4.5}static{this.WCAG_SAFE_CONTRAST=7}static _clampRGB(t){let e=r=>Math.min(1,Math.max(0,r));return t[3]==null&&(t[3]=1),{r:e(t[0]),g:e(t[1]),b:e(t[2]),a:Math.min(1,Math.max(0,t[3]))}}static _normalize(t){return[t[0]/255,t[1]/255,t[2]/255,t[3]]}static parse(t){if(t=(t||"").toLowerCase(),Et.test(t)){let e=Et.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),1]))}if(Ft.test(t)){let e=Ft.exec(t);return this._clampRGB(this._normalize([parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),parseFloat(e[4])]))}if(Bt.test(t)){let e=Bt.exec(t)[0];return this._clampRGB(this._normalize([parseInt("0x"+e.substr(1,2)),parseInt("0x"+e.substr(3,2)),parseInt("0x"+e.substr(5,2)),1]))}if(At.test(t)){let e=At.exec(t)[0],r=e.substr(1,1),s=e.substr(2,1),i=e.substr(3,1);return this._clampRGB(this._normalize([parseInt("0x"+r+r),parseInt("0x"+s+s),parseInt("0x"+i+i),1]))}if(vt.test(t)){let e=vt.exec(t),r={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01};return this.rgb(r)}if(It.test(t)){let e=It.exec(t),r={h:parseFloat(e[1]),s:parseFloat(e[2])*.01,l:parseFloat(e[3])*.01,a:parseFloat(e[4])};return this.rgb(r)}}static hsl(t){let e=te(t),r=ee(t,e);return{h:ne(t),s:r,l:e,a:t.a}}static cieXYZ(t){return A(t)&&(t=this.rgb(t)),S.rgbToCieXYZ(t)}static rgb(t){if(A(t)){let e=t.h,r=t.s,s=t.l,i=e/60,o=(1-Math.abs(2*s-1))*r,h=o*(1-Math.abs(i%2-1)),l=s-o/2,d=(x,w,b)=>this._clampRGB([x+l,w+l,b+l,t.a]);if(i<=1)return d(o,h,0);if(i<=2)return d(h,o,0);if(i<=3)return d(0,o,h);if(i<=4)return d(0,h,o);if(i<=5)return d(h,0,o);if(i<=6)return d(o,0,h)}else{let e=S.cieXYZToRgb(t);return this._clampRGB([e.r,e.g,e.b,e.a])}}static stringify(t,e=1){if(A(t)){e??=1,t.a??=1;let r=typeof e=="number"?e:1;return`hsla(${t.h.roundoff(r)},${(t.s*100).roundoff(r)}%,${(t.l*100).roundoff(r)}%,${t.a.roundoff()})`}else if(R(t)){e??=!0,t.a??=1;let r=typeof e=="boolean"?e:!!e,s=Math.round(t.r*255),i=Math.round(t.g*255),o=Math.round(t.b*255),h=t.a.roundoff();return h===1?r?("#"+et(s)+et(i)+et(o)).toUpperCase():`rgb(${s},${i},${o})`:`rgba(${s},${i},${o},${h})`}}static contrastRatio(t,e){return A(t)&&(t=this.rgb(t)),A(e)&&(e=this.rgb(e)),S.contrastRatio(t,e)}static luminance(t){return A(t)&&(t=n.rgb(t)),S.relativeLuminance(t)}static lighten(t,e=.1){if(e||=0,A(t)){let r=Math.min(1,Math.max(0,t.l+e));return Object.assign({},t,{l:r})}if(R(t)){let r=this.lighten(this.hsl(t),e);return this.rgb(r)}return t}static darken(t,e=.1){return this.lighten(t,-e)}static saturate(t,e=.1){if(e||=0,A(t)){let r=Math.min(1,Math.max(0,t.s+e));return Object.assign({},t,{s:r})}if(R(t)){let r=this.saturate(this.hsl(t),e);return this.rgb(r)}return t}static desaturate(t,e=.1){return this.saturate(t,-e)}static interpolate(t,e,r,s){r??=.5,s??=r;let i=(r+s).roundoff(),o=(r/i).roundoff(),h=(s/i).roundoff(),l=R(t),d=A(t),x=b=>R(b)||A(b)?n.cieXYZ(b):b;t=x(t),e=x(e);let w={x:(t.x*o+e.x*h).roundoff(),y:(t.y*o+e.y*h).roundoff(),z:(t.z*o+e.z*h).roundoff(),a:(t.a*o+e.a*h).roundoff()};return l?n.rgb(w):d?n.hsl(n.rgb(w)):w}};var re=/[-+]?([\d]+(\.[\d]+(e-[\d]+)?)?|[\d]*(\.[\d]+(e-[\d]+)?))/g;function Y(n){let t=[],e=n.match(re);return e&&e.length>0&&e.forEach(r=>t.push(parseFloat(r))),t}var zt=class n{static isAngle(t){return typeof t=="object"&&"vertex"in t&&H.isPoint(t.vertex)&&"start"in t&&H.isPoint(t.start)&&"end"in t&&H.isPoint(t.end)}static value(t){if(_.isNullOrEmpty(t)||!n.isAngle(t))return Number.NaN;let{vertex:e,start:r,end:s}=t;return n.angleBetween(e,r,s)}static angleBetween(t,e,r){let s={x:e.x-t.x,y:e.y-t.y},i={x:r.x-t.x,y:r.y-t.y},o=s.x*i.x+s.y*i.y,h=s.x*i.y-s.y*i.x;return-Math.atan2(h,o)}},J=class{static parse(t){let e=Y(t);if(e&&e.length===2)return{width:e[0],height:e[1]};throw new Error(`Cannot parse "${t}" as a valid Size.`)}static isSize(t){return typeof t=="object"&&"width"in t&&typeof t.width=="number"&&"height"in t&&typeof t.height=="number"}},H=class{static parse(t){let e=Y(t);if(e&&e.length===2)return{x:e[0],y:e[1]};throw new Error(`Cannot parse "${t}" as a valid Point.`)}static isPoint(t){return typeof t=="object"&&"x"in t&&typeof t.x=="number"&&"y"in t&&typeof t.y=="number"}static distance(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static subtract(t,e){return{x:e.x-t.x,y:e.y-t.y}}static add(...t){var e={x:0,y:0};for(var r of t)e.x+=r.x,e.y+=r.y;return e}static multiply(t,e){return{x:t.x*e,y:t.y*e}}};var X=class n{static isIdentity(t){return t.a===1&&t.d===1&&t.b===0&&t.f===0&&t.c===0&&t.e===0}static get identity(){return{a:1,b:0,c:0,d:1,e:0,f:0}}static copy(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}static scale(t,e,r=e){return{a:t.a*e,b:t.b,c:t.c,d:t.d*r,e:t.e,f:t.f}}static translate(t,e){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e+e.x,f:t.f+e.y}}static rotate(t,e){let r=Math.cos(e),s=Math.sin(e);return n.multiply(t,{a:r,b:s,c:-s,d:r,e:0,f:0})}static multiply(t,e){return"x"in t&&"y"in t?typeof e=="number"?{x:t.x*e,y:t.y*e}:{x:t.x*e.a+t.y*e.c+e.e,y:t.x*e.b+t.y*e.d+e.f}:typeof e=="number"?{a:t.a*e,b:t.b*e,c:t.c*e,d:t.d*e,e:t.e*e,f:t.f*e}:{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,e:t.e*e.a+t.f*e.c+e.e,f:t.e*e.b+t.f*e.d+e.f}}static det(t){return t.a*t.d-t.c*t.b}static invert(t){let e=this.det(t);if(e===0)return null;let r=1/e;return this.multiply({a:t.d,b:-t.b,c:-t.c,d:t.a,e:-t.e*t.d+t.c*t.f,f:t.e*t.b-t.a*t.f},r)}static toComponents(t,e={x:0,y:0}){let r=Math.sqrt(t.a*t.a+t.c*t.c),s=Math.sqrt(t.b*t.b+t.d*t.d),i=r!=0?t.a/r:0,o=r!=0?t.c/r:0,h=Math.atan2(o,i),{x:l,y:d}=e,x={x:t.e-l*(r*i-1)+d*r*o,y:t.f-d*(s*i-1)-l*s*o};return{scaleX:r,scaleY:s,rotation:h,translation:x}}static fromTransform([t,e,r],[s,i,o]){let h=t.x*(e.y-r.y)-t.y*(e.x-r.x)+(e.x*r.y-r.x*e.y);if(Math.abs(h)<1e-10)throw new Error("Points are collinear; matrix is singular and cannot be solved.");let l=1/h;return{a:l*(s.x*(e.y-r.y)+i.x*(r.y-t.y)+o.x*(t.y-e.y)),b:l*(s.y*(e.y-r.y)+i.y*(r.y-t.y)+o.y*(t.y-e.y)),c:l*(s.x*(r.x-e.x)+i.x*(t.x-r.x)+o.x*(e.x-t.x)),d:l*(s.y*(r.x-e.x)+i.y*(t.x-r.x)+o.y*(e.x-t.x)),e:l*(s.x*(e.x*r.y-r.x*e.y)+i.x*(r.x*t.y-t.x*r.y)+o.x*(t.x*e.y-e.x*t.y)),f:l*(s.y*(e.x*r.y-r.x*e.y)+i.y*(r.x*t.y-t.x*r.y)+o.y*(t.x*e.y-e.x*t.y))}}static areClose(t,e,r=12){return t.a.isCloseTo(e.a,r)&&t.b.isCloseTo(e.b,r)&&t.c.isCloseTo(e.c,r)&&t.d.isCloseTo(e.d,r)&&t.e.isCloseTo(e.e,r)&&t.f.isCloseTo(e.f,r)}};var D=class n{static parse(t){let e=Y(t);if(e&&e.length===4)return{x:e[0],y:e[1],width:e[2],height:e[3]};throw new Error(`Cannot parse "${t}" as a valid Rect.`)}static isRect(t){return H.isPoint(t)&&J.isSize(t)}static _stretch(t,e){return{a:e.width/t.width,b:0,c:0,d:e.height/t.height,e:e.x-t.x,f:e.y-t.y}}static _contain(t,e,r,s){let i=1,o=t.width/t.height,h=e.width/e.height;o>=h?i=e.width/t.width:i=e.height/t.height;let l=t.width*i,d=t.height*i,x=this._align({x:t.x,y:t.y,width:l,height:d},e,r,s);return X.translate({a:i,b:0,c:0,d:i,e:0,f:0},x)}static _cover(t,e,r,s){let i=1,o=t.width/t.height,h=e.width/e.height;o<h?i=e.width/t.width:i=e.height/t.height;let l=t.width*i,d=t.height*i,x=this._align({x:t.x,y:t.y,width:l,height:d},e,r,s);return X.translate({a:i,b:0,c:0,d:i,e:0,f:0},x)}static _align(t,e,r,s){let i=0,o=0;switch(r){case"left":i=e.x-t.x;break;case"right":i=e.x+e.width-t.width-t.x;break;default:i=e.x+e.width*.5-t.width*.5-t.x;break}switch(s){case"top":o=e.y-t.y;break;case"bottom":o=e.y+e.height-t.height-t.y;break;default:o=e.y+e.height*.5-t.height*.5-t.y;break}return{x:i,y:o}}static findTransform(t,e,r="stretch",s="center",i="middle"){switch(r){case"contain":return this._contain(t,e,s,i);case"cover":return this._cover(t,e,s,i);default:return this._stretch(t,e)}}static intersect(...t){let e={x:0,y:0,height:0,width:0},r=Array.from(t||[]);if(r.length<=0)return e;for(var s=r[0],i=1;i<r.length;i++){let o=r[i],h=Math.max(o.x,s.x),l=Math.max(o.y,s.y),d=Math.min(o.x+o.width,s.x+s.width),x=Math.min(o.y+o.height,s.y+s.height),w=d-h,b=x-l;if(w<0||b<=0)return e;s={x:h,y:l,width:w,height:b}}return s}static expand(t,...e){let r=Array.from(e||[]),s=t.x,i=t.y,o=s,h=i;n.isRect(t)&&(o+=t.width,h+=t.height);for(let l of r)s=Math.min(l.x,s),i=Math.min(l.y,i),o=Math.max(l.x,o),h=Math.max(l.y,h);return{x:s,y:i,width:o-s,height:h-i}}};var Ht=class{constructor(t,e){this.#n=t,this.#r=e}#t=[];#e=[];#r;#n;get current(){return this.#n}get canUndo(){return this.#t.length>0}get canRedo(){return this.#e.length>0}set maxlength(t){this.#r=t}undo(){if(this.canUndo){let t=this.#t,e=this.#e,r=this.#n;e.unshift(r),this.#n=t.pop()}}redo(){if(this.canRedo){let t=this.#t,e=this.#e,r=this.#n;t.push(r),this.#n=e.shift()}}push(t){this.#e.splice(0),this.#t.push(this.#n),this.#n=t;let e=this.#r,r=this.#t;e>0&&r.length>e&&r.splice(0,r.length-e)}reset(){this.#e.splice(0),this.#t.splice(0)}};var se={mode:"stretch",align:"center",valign:"middle",quality:1,type:"image/jpeg"},Nt=class n{static async loadImage(t){let e=await fetch(t);return e.ok?await e.blob():null}static async resizeImage(t,e,r,s){if(e<=0||r<=0||isNaN(e)||isNaN(r))throw new Error("Invalid target size");typeof t=="string"&&(t=await n.loadImage(t));let i=await self.createImageBitmap(t),o=i.width,h=i.height,l=new OffscreenCanvas(o,h),d=l.getContext("2d");d.imageSmoothingEnabled=d.mozImageSmoothingEnabled=d.oImageSmoothingEnabled=d.webkitImageSmoothingEnabled=!0;let{quality:x,type:w,mode:b,align:N,valign:Q,background:Z}=Object.assign({},se,s??{}),z={width:o,height:h,x:0,y:0},q={x:0,y:0,width:e,height:r},p=D.findTransform(z,q,b,N,Q);return l.width=e,l.height=r,Z&&(d.fillStyle=Z,d.fillRect(0,0,l.width,l.height)),d.setTransform(p),d.drawImage(i,0,0),await l.convertToBlob({quality:x,type:w})}};var jt=class n{static#t;static uniqueId(){let t=n.#t||Date.now();return n.#t=++t}static uniqueCode(){return n.uniqueId().toBase62()}static randomString(t){let e="";do e+=(Math.random()*62).toBase62();while(e.length<t);return e}};var Gt=class{static round(t,e=1){return Math.round(t/e)*e}static log(t,e){return Math.log10(t)/Math.log10(e)}static rebase(t,e,r){let s=t.toString(),i=parseInt(s,e);return s.endsWith(i.toString(e))?parseInt(t.toString(),e).toString(r):Number.NaN.toString()}};function nt(n,t){let e=n.length,r=t.length,s=Array.from({length:e+1},()=>Array(r+1).fill(0));for(let i=1;i<=e;i++)for(let o=1;o<=r;o++)n[i-1]===t[o-1]?s[i][o]=s[i-1][o-1]+1:s[i][o]=Math.max(s[i-1][o],s[i][o-1]);return s}function rt(n,t,e,r=""){let s=n.length,i=t.length,o=[],h=s,l=i,d=null,x=()=>{d&&(o.push(d),d=null)};for(;h>0||l>0;){var w=null;let b=null;h>0&&l>0&&n[h-1]===t[l-1]?(w="=",b=n[h-1],h--,l--):l>0&&(h===0||e[h][l-1]>=e[h-1][l])?(w="+",b=t[l-1],l--):h>0&&(l===0||e[h-1][l]>e[h][l-1])&&(w="-",b=n[h-1],h--),w&&b!==null?d&&d.type===w?d.value=b+(d.value?r:"")+d.value:(x(),d={type:w,value:b}):x()}return x(),o.reverse()}function ie(n,t){let e=n.split(""),r=t.split(""),s=nt(e,r);return rt(e,r,s,"")}function oe(n,t){let e=/(\S+|\s+)/g,r=n.match(e)||[],s=t.match(e)||[],i=nt(r,s);return rt(r,s,i,"")}function ae(n,t){let e=/\r?\n/,r=n.split(e),s=t.split(e),i=nt(r,s);return rt(r,s,i,`
7
+ `)}var Rt=class{static leftPad(t,e,r){return t.toString().padStart(e,r)}static format(t,...e){let r=Array.from(e),s=t;for(let o=0;o<r.length;o++){let h=new RegExp("(^|[^\\{])\\{"+o+"\\}($|[^\\}])","g");s=s.replaceAll(h,(l,...d)=>l.replace("{"+o+"}",r[o]))}let i=/(^|[^\{}])\{(\d+)\}($|[^\}])/.exec(s);if(!_.isNullOrEmpty(i))throw new Error(`Missing argument at index ${i[2]}.`);return s}static diff(t,e,r="char"){switch(r){case"line":return ae(t,e);case"word":return oe(t,e);default:return ie(t,e)}}static async hash(t,e="SHA-256"){let r=await crypto.subtle.digest(e,new TextEncoder().encode(t));return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}};var Dt={};kt(Dt,{CSharpSyntax:()=>mt,CSyntax:()=>xt,DefaultHighlightClasses:()=>Zt,HighlightRenderer:()=>M,JavaScriptSyntax:()=>dt,JsonSyntax:()=>wt,Markdown:()=>pt,MarkupSyntax:()=>yt,PacemBindingSyntax:()=>gt,Parser:()=>P,Scanner:()=>O,SyntaxTokenType:()=>v,Syntaxes:()=>F});var pt={};kt(pt,{Parser:()=>ht});var st=class{tokenize(t,e){let r=[];for(;t;){let s=t.length;for(let i of e){let o=i.exec(t,this),h=o?.length;if(h>0){Array.prototype.push.apply(r,o);let l=o[h-1];t=t.substr((l.index||0)+l.raw.length);break}}if(t.length>=s)throw new Error(`Cannot parse
8
8
  "${t}"
9
- using the provided grammar.`)}return n}},j=class{constructor(t=new J){this._lexer=t}parse(t,e,n){let s=this._lexer.tokenize(t,e);return n.render(s)}};function Y(r){return(r??"").replace(/</g,"&lt;")}function Ft(r){if(!k.isNullOrEmpty(r)&&!(/^\(/.test(r)&&/\)$/.test(r)))return/^\[/.test(r)&&/\]$/.test(r)&&(r=r.substr(1,r.length-2)),r}function T(r){return r?.index||void 0}function Ht(r){if(!k.isNullOrEmpty(r)&&!(/^\[/.test(r)&&/\]$/.test(r)))return/^\(/.test(r)&&/\)$/.test(r)&&(r=r.substr(1,r.length-2)),r}function S(r){return r?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function $(r,t,e){let n=t.exec(r);return n&&n.length?e(n):null}var Lt=/(<!--)([\s\S]*?)(-->|$)/,Gt=/^ {0,3}(={3,}|_{3,}|-{3,})(\r?\n|$)/,jt=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,Nt=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,Mt=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,Pt=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,Xt=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,Qt=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,St=/^( {0,3}([-+]).*\r?\n|$)((?!(?: {0,3}(?:\d+[.\)]|\r?\n\S))).*(\r?\n|$))*/,Ot=/^( {0,3}(\d+[.\)]).*\r?\n|$)((?!(?: {0,3}(?:[+-]|\r?\n\S))).*(\r?\n|$))*/,gt=/^(?:[-+*]|\d+[.\)])/m,Zt=/^(?! {4,})(.+(\n(?! {0,3}```)(?! {0,3}([-+]|\d+[.\)]))(?! {4,})(?! {0,3}>).+)*)/,Vt=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,At=/!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,qt=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,U=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,Jt=/(\*\*?|__?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1/,Yt=/(~~?|__?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,Ut=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,_t=/^\s+/,Rt=/ {2,}\r?\n/,Dt=/^[^\r\n]+/,x;(function(r){r.Html="html",r.Text="text",r.Paragraph="paragraph",r.BlockQuote="blockquote",r.Space="space",r.Heading="heading",r.Bold="bold",r.Italic="italic",r.CodeBlock="codeblock",r.Code="code",r.Image="img",r.ImageLike="imglike",r.Link="link",r.LinkLike="linklike",r.LineBreak="br",r.StrikeThrough="strike",r.Quote="quote",r.HorizontalRule="hr",r.OrderedList="ol",r.UnorderedList="ul",r.ListItem="listitem",r.Reference="ref"})(x||(x={}));var y;(function(r){r[r.Comment=0]="Comment",r[r.Reference=1]="Reference",r[r.HorizontalRule=2]="HorizontalRule",r[r.Heading=3]="Heading",r[r.Heading1=4]="Heading1",r[r.Heading2=5]="Heading2",r[r.CodeBlock=6]="CodeBlock",r[r.Fences=7]="Fences",r[r.BlockQuote=8]="BlockQuote",r[r.OrderedList=9]="OrderedList",r[r.UnorderedList=10]="UnorderedList",r[r.Paragraph=11]="Paragraph",r[r.EmphasizedLink=12]="EmphasizedLink",r[r.ImageOrLink=13]="ImageOrLink",r[r.Emphasize=14]="Emphasize",r[r.StrikeThrough=15]="StrikeThrough",r[r.Quote=16]="Quote",r[r.Code=17]="Code",r[r.LineBreak=18]="LineBreak",r[r.Text=254]="Text",r[r.Space=255]="Space"})(y||(y={}));function O(r=[]){let t={[y.Comment]:{exec:(d,l)=>$(d,Lt,o=>{let c=T(o),p=[{type:x.Html,index:c,raw:o[0],text:o[2]}];if(c>0){let m=d.substr(0,c),I=l.tokenize(m,v);Array.prototype.unshift.apply(p,I)}return p})},[y.Reference]:{exec:d=>$(d,Vt,l=>{let o=T(l),c=l[0],p=c,m=l[1]==="!",I=l[2],H=l[3],N=l[4];return[{type:x.Reference,index:o,raw:c,text:p,id:I,image:m,url:H,title:N}]})}},e=[],n=[],s={};for(let d of r){let l,o="inline";switch("type"in d?(o=d.type,l=d.rule):l=d,o){case"block":e.push(l);break;case"code":if("lang"in d){let p=d.lang.toLowerCase();(s[p]=s[p]||[]).push(l)}break;default:let c={exec:(p,m)=>{let I=l.exec(p,m);return h(p,I,m),I}};n.push(c);break}}let i={[y.Text]:{exec:d=>$(d,Dt,l=>{let o=l[0],c=o;return[{index:T(l),raw:o,text:c,type:x.Text}]})},[y.Space]:{exec:d=>$(d,_t,l=>{let o=l[0];return[{type:x.Space,raw:o,text:o}]})}},a={[y.ImageOrLink]:{exec:(d,l)=>u(d,At,l,o=>{let c=T(o),p=o[0],m=p.charAt(0)==="!",I=o[1],H=Ht(o[2]),N=S(Ft(o[2])??I);return m?[{index:c,type:H?x.Image:x.ImageLike,raw:p,text:I,src:H,ref:N,tokens:l.tokenize(I,f)}]:[{index:c,type:H?x.Link:x.LinkLike,raw:p,text:I,href:H,ref:N,tokens:l.tokenize(I,f)}]})},[y.Code]:{exec:(d,l)=>u(d,U,l,o=>{let c=Y(o[1]);return[{type:x.Code,raw:o[0],text:c,index:T(o)}]})},[y.EmphasizedLink]:{exec:(d,l)=>u(d,qt,l,o=>{if(o.length<3||k.isNullOrEmpty(o[2]))return null;let c=o[1].length>1?x.Bold:x.Italic,p=o[2];return[{index:T(o),type:c,raw:o[0],text:p,tokens:l.tokenize(p,f)}]})},[y.Emphasize]:{exec:(d,l)=>u(d,Jt,l,o=>{if(o.length<3||k.isNullOrEmpty(o[2]))return null;let c=o[1].length>1?x.Bold:x.Italic,p=o[2];return[{index:T(o),type:c,raw:o[0],text:p,tokens:l.tokenize(p,f)}]})},[y.StrikeThrough]:{exec:(d,l)=>u(d,Yt,l,o=>{if(o.length<3||k.isNullOrEmpty(o[2]))return null;let c=x.StrikeThrough,p=o[2];return[{index:T(o),type:c,raw:o[0],text:p,tokens:l.tokenize(p,f)}]})},[y.Quote]:{exec:(d,l)=>u(d,Ut,l,o=>{if(o.length<3||k.isNullOrEmpty(o[2]))return null;let c=x.Quote,p=o[2];return[{index:T(o),type:c,raw:o[0],text:p,tokens:l.tokenize(p,f)}]})},[y.LineBreak]:{exec:(d,l)=>u(d,Rt,l,o=>{let c=o[0],p=c;return[{index:T(o),raw:c,text:p,type:x.LineBreak}]})}},h=(d,l,o)=>{let c=l?.length>0&&l[0].index;if(c>0){let p=d.substr(0,c),m=o.tokenize(p,f)||[];Array.prototype.unshift.apply(l,m)}},u=(d,l,o,c)=>{let p=$(d,l,m=>{if(l!=U){let I=U.exec(d);if(I&&I.length&&I.index<m.index)return null}return c(m)});return h(d,p,o),p},f=Object.values(a);Array.prototype.push.apply(f,n),f.push(i[y.Text],i[y.Space]);let w=d=>{let l=[i[y.Text],i[y.Space]],o=d?.toLowerCase()||"";return o&&o in s&&Array.prototype.unshift.apply(l,s[o]),l},g={[y.Paragraph]:{exec:(d,l)=>$(d,Zt,o=>{let c=o[0],p=c;return[{type:x.Paragraph,raw:c,text:p,tokens:l.tokenize(p,f)}]})},[y.Space]:i[y.Space]},b=(d,l)=>{let o=/^ {0,3}(`{3,}|$|>|[+-]\s|\d+[.\)])/m.test(d)?v:f;return l.tokenize(d,o)},F={[y.HorizontalRule]:{exec:(d,l)=>$(d,Gt,o=>{let c=o[0],p=c;return[{type:x.HorizontalRule,raw:c,text:p}]})},[y.Heading]:{exec:(d,l)=>$(d,jt,o=>{let c=o[2];return[{type:x.Heading,raw:o[0],text:c,level:o[1].length,ref:S(c),tokens:l.tokenize(c,f)}]})},[y.Heading1]:{exec:(d,l)=>$(d,Nt,o=>{let c=o[1];return[{type:x.Heading,raw:o[0],text:c,level:1,ref:S(c),tokens:l.tokenize(c,f)}]})},[y.Heading2]:{exec:(d,l)=>$(d,Mt,o=>{let c=o[1];return[{type:x.Heading,raw:o[0],text:c,level:2,ref:S(c),tokens:l.tokenize(c,f)}]})},[y.CodeBlock]:{exec:(d,l)=>$(d,Pt,o=>{let c=o[0],p=Y(c);return[{type:x.CodeBlock,raw:c,text:p,tokens:l.tokenize(p,[])}]})},[y.Fences]:{exec:(d,l)=>$(d,Xt,o=>{let c=Y(o[2]),p=o[1]?.toLowerCase();return[{type:x.CodeBlock,raw:o[0],text:c,lang:p,tokens:l.tokenize(c,w(p))}]})},[y.BlockQuote]:{exec:(d,l)=>$(d,Qt,o=>{let c=o[0],p=c.replace(/^ {0,3}> */gm,"");return[{type:x.BlockQuote,raw:c,text:p,tokens:l.tokenize(p,[g[y.Paragraph],g[y.Space]])}]})},[y.OrderedList]:{exec:(d,l)=>$(d,Ot,o=>{let c=o[0],p=c.replace(/^ {0,3}/gm,"").split(gt).filter(m=>!k.isNullOrEmpty(m)).map(m=>m.trim());return[{type:x.OrderedList,start:parseInt(/\d/.exec(o[0])[0]),raw:c,text:c,tokens:p.map(m=>({type:x.ListItem,raw:m,text:m,tokens:b(m,l)}))}]})},[y.UnorderedList]:{exec:(d,l)=>$(d,St,o=>{let c=o[0],p=c.replace(/^ {0,3}/gm,"").split(gt).filter(m=>!k.isNullOrEmpty(m)).map(m=>m.trim());return[{type:x.UnorderedList,raw:c,text:c,tokens:p.map(m=>({type:x.ListItem,raw:m,text:m,tokens:b(m,l)}))}]})}},v=Object.values(F);return Array.prototype.push.apply(v,e),v.push(g[y.Paragraph],g[y.Space]),[t[y.Comment],t[y.Reference]].concat(v)}var Wt="\0",Kt=/[ \r\n]*\0+[ \r\n]*/g;function te(r){return r?.replace(Kt,`
10
- `).trim()}var Z=class{constructor(t=(e,n)=>e?.text||""){this._extraItemRender=t,this._renderContent=e=>{let n=e.tokens;return k.isNullOrEmpty(n)?e.text:this._render(n)}}_rendeItem(t,e){let n=this._renderContent,s=Wt;switch(t?.type){case x.Reference:return"";case x.Html:return t.raw;case x.BlockQuote:return`<blockquote>
11
- ${n(t)}</blockquote>${s}`;case x.Bold:return`<b>${n(t)}</b>`;case x.CodeBlock:let i=t.lang;return`<pre>${s}<code${i?' class="'+i+'"':""}>${n(t)}</code>${s}</pre>${s}`;case x.Code:return`<code>${n(t)}</code>`;case x.HorizontalRule:return`<hr />${s}`;case x.Heading:let a=t.level,h=t.ref;return`<h${a} id="${h}">${n(t)}</h${a}>${s}`;case x.Image:case x.ImageLike:let u=t,f=u.src,w="",g=u.text,b=u.ref;if(!f&&b){let o=e.find(c=>c.type===x.Reference&&c.image===!0&&c.id?.toLowerCase()===b.toLowerCase());o&&(f=o.url,w=o.title??"")}return f?`<img src="${f}" alt="${g}"${w?' title="'+w+'"':""} />`:`![${n(t)}]`;case x.Italic:return`<i>${n(t)}</i>`;case x.StrikeThrough:return`<s>${n(t)}</s>`;case x.Quote:return`<q>${n(t)}</q>`;case x.LineBreak:return"<br />"+s;case x.OrderedList:return`<ol start="${t.start}">
12
- ${n(t)}</ol>${s}`;case x.UnorderedList:return`<ul>
13
- ${n(t)}</ul>${s}`;case x.ListItem:return` <li>${n(t)}</li>${s}`;case x.Link:case x.LinkLike:let F=t,v=F.href,d="",l=F.ref;if(!v&&l){let o=e.find(c=>c.type===x.Reference&&c.image!==!0&&c.id?.toLowerCase()===l.toLowerCase());o&&(v=o.url,d=o.title??"")}return v?`<a href="${v}"${d?' title="'+d+'"':""}>${n(t)}</a>`:`[${n(t)}]`;case x.Paragraph:return`<p>${n(t)}</p>${s}`;case x.Text:case x.Space:return t.text}return this._extraItemRender(t,e)}_render(t){let e="";for(let n of t||[])e+=this._rendeItem(n,t);return e}render(t){return te(this._render(t))}},_=class{_render(t){return k.isNullOrEmpty(t)?"":JSON.stringify(t)}render(t){return"["+t.filter(e=>!k.isNullOrEmpty(e)).map(this._render).join(",")+"]"}};function ee(r){return r&&typeof r=="object"&&typeof r.render=="function"}var R=class extends j{toHtml(t,e,n){let s=new Z(n);return k.isNullOrEmpty(e)?this.parse(t,s):this.parse(t,O(e),s)}tokenize(t,e){let n=this.parse(t,O(e),new _);return JSON.parse(n)}parse(t,e=O(),n=new Z){return ee(e)?super.parse(t,O(),e):super.parse(t,e,n)}};export{ht as Angle,rt as Arrays,nt as Blobs,ut as Colors,bt as Compile,M as Dates,tt as DeepMerger,ft as HistoryService,dt as Imaging,xt as Keys,G as Matrix2D,k as NullChecker,pt as Numbers,z as Point,Q as Rect,P as Size,yt as Strings,he as detect,X as parseAsNumericalArray};
9
+ using the provided grammar.`)}return r}},P=class{constructor(t=new st){this._lexer=t}parse(t,e,r){let s=this._lexer.tokenize(t,e);return r.render(s)}};var v;(function(n){n.Text="text",n.Space="space",n.Newline="newline",n.Comment="comment",n.DocComment="doc-comment",n.Keyword="keyword",n.Identifier="identifier",n.String="string",n.Regex="regex",n.Number="number",n.Bracket="bracket",n.Punctuation="punctuation",n.Operator="operator",n.Preprocessor="preprocessor",n.Tag="tag",n.TagName="tagname",n.Attribute="attribute",n.Entity="entity"})(v||(v={}));var it=new Map;function Xt(n){return(n??"").trim().toLowerCase()}var F=class{static register(t){if(t==null)return;let e=[t.name].concat(t.aliases??[]);for(let r of e){let s=Xt(r);it.set(s,t)}}static get(t){let e=Xt(t);return it.get(e)??null}static names(){let t=it.keys();return Array.from(t)}};var le="root",ue=[v.Identifier],he=[v.Space,v.Newline,v.Comment,v.DocComment],pe=64,de=16;function fe(n){return n.combined!=null}var Pt=new WeakMap;function ge(n){return"include"in n}function W(n){return n==null||n.length===0?null:new Set(n)}function ye(n){let t=n.split(""),e=new Set(t);return Array.from(e).join("")}function me(n,t){let e={};for(let r in t)e[r]=t[r].slice();for(let r in n){let s=e[r]??[];e[r]=n[r].concat(s)}return e}function xe(n,t){let e={};for(let r in t)e[r]=t[r].slice();for(let r in n){let s=e[r]??[];e[r]=s.concat(n[r])}return e}function Ot(n,t=0){let e=n.lexical??{states:{}},r={start:e.start,states:e.states??{},keywords:e.keywords??{},keywordSources:e.keywordSources,keywordExceptAfter:e.keywordExceptAfter,insignificant:e.insignificant},s=n.extends?F.get(n.extends):null;if(s==null||s===n||t>=de)return r;let i=Ot(s,t+1);return{start:r.start??i.start,states:me(r.states,i.states),keywords:xe(r.keywords,i.keywords),keywordSources:r.keywordSources??i.keywordSources,keywordExceptAfter:r.keywordExceptAfter??i.keywordExceptAfter,insignificant:r.insignificant??i.insignificant}}function Mt(n,t,e){let r=n[t]??[];if(e.has(t))return[];e.add(t);let s=[];for(let i of r){if(!ge(i)){s.push(i);continue}let o=Mt(n,i.include,e);Array.prototype.push.apply(s,o)}return e.delete(t),s}function we(n){return n==null?null:{previousTypes:W(n.previousTypes),previousNotTypes:W(n.previousNotTypes),previousTexts:W(n.previousTexts),previousNotTexts:W(n.previousNotTexts)}}function be(n){let t=Array.isArray(n.type)?n.type:null,e=Array.isArray(n.type)?n.type[0]:n.type,r=(n.flags??"").replace(/[yd]/g,""),s=ye(r),i=s+"y"+(t?"d":""),o=new RegExp(n.match,i),h=n.until?new RegExp(n.until,"y"):null,l=n.pop===!0?1:typeof n.pop=="number"?n.pop:0,d=we(n.when);return{regex:o,type:e,groupTypes:t,when:d,pop:l,until:h,source:n.match,flags:s,next:n.next??null,push:n.push??null,embed:n.embed??null,hasTransition:l>0||!!n.next||!!n.push||!!n.embed}}function ke(n){let t=new Map;for(let e in n)for(let r of n[e])t.set(r,e);return t}var _e=/\\[1-9]|\\k<|\(\?<(?![=!])/;function Se(n,t){return new RegExp(n+"|",t).exec("").length-1}function $e(n,t){return new RegExp("^(?:"+n+")$",t).test("")}function Ce(n){return n.when!=null||_e.test(n.source)?!1:!$e(n.source,n.flags)}function Te(n){if(n.length===1)return{rule:n[0],combined:null};let t=[],e=1;for(let o of n){t.push(e);let h=Se(o.source,o.flags);e+=1+h}let s=n.map(o=>"("+o.source+")").join("|");return{rule:null,combined:new RegExp(s,n[0].flags+"y"),rules:n,groupIndices:t}}function ve(n){let t=[],e=[],r=()=>{if(e.length>0){let s=Te(e);t.push(s)}e=[]};for(let s of n){if(!Ce(s)){r(),t.push({rule:s,combined:null});continue}e.length>0&&e[0].flags!==s.flags&&r(),e.push(s)}return r(),t}function Qt(n){let t=Pt.get(n);if(t!=null)return t;let e=Ot(n),r=new Map;for(let i in e.states){let o=new Set,l=Mt(e.states,i,o).map(be),d=ve(l);r.set(i,d)}let s={name:n.name,start:e.start??le,states:r,keywords:ke(e.keywords),keywordSources:new Set(e.keywordSources??ue),keywordExceptAfter:new Set(e.keywordExceptAfter??[]),insignificant:new Set(e.insignificant??he)};return Pt.set(n,s),s}function Ie(n){let t=F.get(n);return t==null?null:Qt(t)}function Ee(n,t){let e=t?.type??null,r=t?.raw??null;return n.previousTypes!=null&&!n.previousTypes.has(e)||n.previousNotTypes!=null&&n.previousNotTypes.has(e)||n.previousTexts!=null&&!n.previousTexts.has(r)?!1:n.previousNotTexts==null||!n.previousNotTexts.has(r)}var ot=class{constructor(t,e){this._source=t,this._tokens=[],this._position=0,this._emitted=0,this._line=1,this._column=1,this._previous=null,this._emptyTransitions=0,this._stack=[{syntax:e,state:e.start,until:null}]}run(){let t=this._source.length;for(;this._position<t;)this._step();return this._flushText(),this._tokens}get _top(){let t=this._stack;return t[t.length-1]}_step(){let t=this._top;if(this._popOnUntil(t))return;let e=this._findRule(t);if(e==null){this._position++;return}this._flushText(),this._emitMatch(e,t.syntax),this._transition(e.rule,t.syntax);let r=e.match[0].length;this._position+=r,r>0&&(this._emptyTransitions=0)}_popOnUntil(t){let e=t.until;return e==null||this._stack.length<=1||(e.lastIndex=this._position,!e.test(this._source))?!1:(this._flushText(),this._stack.pop(),!0)}_findRule(t){let e=t.syntax.states.get(t.state)??[];for(let r of e){let s=fe(r)?this._tryCombined(r):this._trySingle(r.rule);if(s!=null)return s}return null}_trySingle(t){let e=this._tryRule(t);return e==null?null:{rule:t,match:e}}_tryCombined(t){let e=t.combined;e.lastIndex=this._position;let r=e.exec(this._source);if(r==null)return null;let s=t.groupIndices;for(let i=0;i<s.length;i++){if(r[s[i]]===void 0)continue;let o=t.rules[i];return this._trySingle(o)}return null}_tryRule(t){if(t.when!=null&&!Ee(t.when,this._previous))return null;let e=t.regex;e.lastIndex=this._position;let r=e.exec(this._source);return r==null?null:r[0].length>0?r:!t.hasTransition||this._emptyTransitions>=pe?null:(this._emptyTransitions++,r)}_emitMatch({rule:t,match:e},r){let s=e[0];if(t.groupTypes==null){this._append(t.type,s,r);return}this._emitGroups(t,e,r)}_emitGroups(t,e,r){let s=e.indices,i=e.index,o=i+e[0].length,h=t.groupTypes,l=i;for(let d=1;d<e.length;d++){let x=s[d];if(x==null||x[0]<l||x[1]===x[0])continue;if(x[0]>l){let N=this._source.slice(l,x[0]);this._append(v.Text,N,r)}let w=this._source.slice(x[0],x[1]),b=h[d-1]??h[h.length-1];this._append(b,w,r),l=x[1]}if(l<o){let d=this._source.slice(l,o);this._append(v.Text,d,r)}}_transition(t,e){let r=this._stack;for(let i=0;i<t.pop&&r.length>1;i++)r.pop();if(t.next!=null&&(this._top.state=t.next),t.push!=null&&r.push({syntax:e,state:t.push,until:null}),t.embed==null)return;let s=Ie(t.embed);s!=null&&r.push({syntax:s,state:s.start,until:t.until})}_flushText(){if(this._emitted>=this._position)return;let t=this._source.slice(this._emitted,this._position),e=this._top.syntax;this._append(v.Text,t,e)}_resolveType(t,e,r){if(!r.keywordSources.has(t))return t;let s=this._previous?.raw;return r.keywordExceptAfter.has(s)?t:r.keywords.get(e)??t}_append(t,e,r){let s=this._resolveType(t,e,r),i={type:s,raw:e,text:e,index:this._emitted,line:this._line,column:this._column,depth:this._stack.length-1,syntax:r.name};this._tokens.push(i),this._advance(e),r.insignificant.has(s)||(this._previous=i)}_advance(t){this._emitted+=t.length;let e=t.lastIndexOf(`
10
+ `);if(e<0){this._column+=t.length;return}for(let r=0;r<=e;r++)t.charCodeAt(r)===10&&this._line++;this._column=t.length-e}},Fe={name:v.Text,lexical:{states:{}}},O=class{tokenize(t,e){let r=t??"",s=typeof e=="string"?F.get(e):e,i=Qt(s??Fe);return new ot(r,i).run()}};var Zt=Object.freeze({keyword:"code-keyword",preprocessor:"code-keyword",string:"code-string",regex:"code-string",number:"code-number",comment:"code-comment","doc-comment":"code-comment",tag:"code-tag",tagname:"code-tagname",attribute:"code-attribute"}),Be={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function Ae(n){return n.replace(/[&<>"]/g,t=>Be[t])}var M=class{constructor(t=Zt){this._classes=t}render(t){let e="";for(let r of t??[])e+=this._renderToken(r);return e}_renderToken(t){let e=Ae(t.raw??""),r=this._classes[t.type];return r==null?e:`<span class="${r}">${e}</span>`}};function at(n){return(n??"").replace(/</g,"&lt;")}function Le(n){if(!_.isNullOrEmpty(n)&&!(/^\(/.test(n)&&/\)$/.test(n)))return/^\[/.test(n)&&/\]$/.test(n)&&(n=n.substr(1,n.length-2)),n}function ze(n){if(_.isNullOrEmpty(n))return{url:n};let t=n.trim(),e=/^(\S*)\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\))\s*$/.exec(t);if(e==null)return{url:t};let r=e[2]??e[3]??e[4];return{url:e[1],title:r}}function Ut(n){return(n??"").replace(/&(?!(?:#\d+|#x[\da-fA-F]+|\w+);)/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function ct(n){let t=n.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!t.endsWith("\\|")&&(t=t.slice(0,-1)),t.split(/(?<!\\)\|/).map(r=>r.trim().replace(/\\\|/g,"|"))}function He(n){let t=n.startsWith(":"),e=n.endsWith(":");return t&&e?"center":e?"right":t?"left":null}function Ne(n){return/^ */.exec(n)[0].length}function je(n){let t=n.replace(/\t/g," ").split(/\r?\n/),e=[];for(let r of t){let s=e[e.length-1],i=We.exec(r);if(i!=null&&(s==null||i[1].length<s.indent)){let l=i[0].length,d=r.slice(l);e.push({indent:l,lines:[d]});continue}if(s==null)continue;let o=Math.min(s.indent,Ne(r)),h=r.slice(o);s.lines.push(h)}return e.map(r=>r.lines.join(`
11
+ `).replace(/\s+$/,""))}function Ge(n){return(n??"").replace(/&lt;/g,"<")}var Re=new O,Xe="markup";function T(n){return n?.index||void 0}function Pe(n){if(!_.isNullOrEmpty(n)&&!(/^\[/.test(n)&&/\]$/.test(n)))return/^\(/.test(n)&&/\)$/.test(n)&&(n=n.substr(1,n.length-2)),n}function j(n){return n?.replace(/[^\w]+/g," ").trim().replace(/ +/g,"-").toLowerCase()}function $(n,t,e){let r=t.exec(n);return r&&r.length?e(r):null}var Oe=/(<!--)([\s\S]*?)(-->|$)/,Me=/^ {0,3}(={3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,}|(?:\*[ \t]*){3,})(\r?\n|$)/,Qe=/^ {0,3}(#{1,6})\s+([^\n]+)(\r?\n|$)+/,Ze=/^ {0,3}([^\n]+)(\r?\n=+(\r?\n|$))+/,qe=/^ {0,3}([^\n]+)(\r?\n-+(\r?\n|$))+/,Ue=/^ {4,}.+(\r?\n {4,}.+)*(\r?\n|$)+/,Ve=/^ {0,3}``` *([^\n]*)\r?\n(([\s\S](?!\r?\n {0,3}```))*.(\r?\n)+) {0,3}```(\r?\n|$)+/,Je=/^ {0,3}> *([^\n]+)(\r?\n {0,3}> *([^\n]*))*(\r?\n|$)+/,Ye=/^( {0,3}([-+]|\*(?=[ \t])).*(\r?\n|$))((?!(?: ?\d+[.\)]|\r?\n\S)).*(\r?\n|$))*/,De=/^( {0,3}(\d+[.\)]).*(\r?\n|$))((?!(?: {0,2}(?:[-+]|\*[ \t])|\r?\n\S)).*(\r?\n|$))*/,We=/^( *)([-+*]|\d+[.\)])([ \t]+|$)/,Ke=/^\[([ xX])\][ \t]+/,tn=/^(?! {4,})(?=[ \t]*\S)(.+(\n(?![ \t]*(?:\n|$))(?! {0,3}```)(?! {0,3}([-+]|\*[ \t]|\d+[.\)]))(?! {0,3}#{1,6}[ \t])(?! {4,})(?! {0,3}>).+)*)/,en=/^ {0,3}(!?)\[([^\]]+)\]: +(\S+)(?: +['"\(](.+)['"\)])?(\r?\n|$)+/,nn=/(?<!\\)!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?(\[[^\[\]]*\]|\([^\(\)]*\))?/,rn=/(\*\*?|__?)(\[[^\]]*]\([^\)]+\))\1/,lt=/(?:(?<!\\)`)(.+?)(?:(?<!\\)`)/,sn=/(\*\*?)((?!\1\s?)(?:(?!\1)[\S\s])*[^\s])\1|(?<![A-Za-z0-9])(__?)((?!\3\s?)(?:(?!\3)[\S\s])*[^\s])\3(?![A-Za-z0-9])/,on=/(~~?)(?!\1\s?)([^\s][\s\S]*?(?!\1)[^\s])\1/,an=/(:")(?!":\s?)([^\s][\s\S]*?(?!":)[^\s])":/,cn=/^\s+/,ln=/^(?:[ \t]*\r?\n)+|^\s+/,un=/(?: {2,}|\\)\r?\n/,hn=/^[^\r\n]+/,pn=/\\(&lt;|[!"#$%&'()*+,\-./:;<=>?@\[\\\]^_`{|}~])/,dn={"<":"&lt;","&lt;":"&lt;","&":"&amp;"},fn=/(?:<|&lt;)((?:https?|ftp|mailto):[^\s<>]+|[\w.+-]+@[\w-]+(?:\.[\w-]+)+)>/,gn=/(?<![\w\/\\(\[<"'=;&@])(?:https?:\/\/|www\.)[^\s<>]*[^\s<>.,:;"'!?)\]*_~]/,yn=/\[\^([^\]\s]+)\]/,mn=/^ {0,3}\[\^([^\]\s]+)\]: *([^\r\n]*(?:\r?\n {2,}[^\r\n]+)*)(\r?\n|$)+/,xn=/^ {0,3}(\|?[^\r\n]*\|[^\r\n]*)\r?\n {0,3}(\|? *:?-+:? *(?:\| *:?-+:? *)*\|?) *(?:\r?\n|$)((?:(?! {0,3}(?:\r?\n|$))[^\r\n]*\|[^\r\n]*(?:\r?\n|$))*)/,g;(function(n){n.Html="html",n.Text="text",n.Paragraph="paragraph",n.BlockQuote="blockquote",n.Space="space",n.Heading="heading",n.Bold="bold",n.Italic="italic",n.CodeBlock="codeblock",n.Code="code",n.Image="img",n.ImageLike="imglike",n.Link="link",n.LinkLike="linklike",n.LineBreak="br",n.StrikeThrough="strike",n.Quote="quote",n.HorizontalRule="hr",n.OrderedList="ol",n.UnorderedList="ul",n.ListItem="listitem",n.Reference="ref",n.Table="table",n.TableRow="tr",n.TableCell="td",n.FootnoteReference="fnref",n.FootnoteDefinition="fndef"})(g||(g={}));var y;(function(n){n[n.Comment=0]="Comment",n[n.Reference=1]="Reference",n[n.HorizontalRule=2]="HorizontalRule",n[n.Heading=3]="Heading",n[n.Heading1=4]="Heading1",n[n.Heading2=5]="Heading2",n[n.CodeBlock=6]="CodeBlock",n[n.Fences=7]="Fences",n[n.BlockQuote=8]="BlockQuote",n[n.OrderedList=9]="OrderedList",n[n.UnorderedList=10]="UnorderedList",n[n.Paragraph=11]="Paragraph",n[n.EmphasizedLink=12]="EmphasizedLink",n[n.ImageOrLink=13]="ImageOrLink",n[n.Emphasize=14]="Emphasize",n[n.StrikeThrough=15]="StrikeThrough",n[n.Quote=16]="Quote",n[n.Code=17]="Code",n[n.LineBreak=18]="LineBreak",n[n.FootnoteDefinition=19]="FootnoteDefinition",n[n.Table=20]="Table",n[n.Escape=21]="Escape",n[n.AutoLink=22]="AutoLink",n[n.FootnoteReference=23]="FootnoteReference",n[n.BareUrl=24]="BareUrl",n[n.Text=254]="Text",n[n.Space=255]="Space"})(y||(y={}));function K(n=[]){let t={[y.Comment]:{exec:(p,u)=>$(p,Oe,a=>{let c=T(a),f=[{type:g.Html,index:c,raw:a[0],text:a[2]}];if(c>0){let m=p.substr(0,c),k=u.tokenize(m,q);Array.prototype.unshift.apply(f,k)}return f})},[y.Reference]:{exec:p=>$(p,en,u=>{let a=T(u),c=u[0],f=c,m=u[1]==="!",k=u[2],C=u[3],I=u[4];return[{type:g.Reference,index:a,raw:c,text:f,id:k,image:m,url:C,title:I}]})},[y.FootnoteDefinition]:{exec:(p,u)=>$(p,mn,a=>{let c=a[0],f=j(a[1]),m=a[2].replace(/\r?\n {2,}/g," ");return[{type:g.FootnoteDefinition,index:T(a),raw:c,text:m,id:f,tokens:u.tokenize(m,d)}]})}},e=[],r=[],s={};for(let p of n){let u,a="inline";switch("type"in p?(a=p.type,u=p.rule):u=p,a){case"block":e.push(u);break;case"code":if("lang"in p){let f=p.lang.toLowerCase();(s[f]=s[f]||[]).push(u)}break;default:let c={exec:(f,m)=>{let k=u.exec(f,m);return h(f,k,m),k}};r.push(c);break}}let i={[y.Text]:{exec:p=>$(p,hn,u=>{let a=u[0],c=a;return[{index:T(u),raw:a,text:c,type:g.Text}]})},[y.Space]:{exec:p=>$(p,cn,u=>{let a=u[0];return[{type:g.Space,raw:a,text:a}]})}},o={[y.ImageOrLink]:{exec:(p,u)=>l(p,nn,u,a=>{let c=T(a),f=a[0],m=f.charAt(0)==="!",k=a[1],C=Pe(a[2]),I=Le(a[2])??k,E=j(I),{url:B,title:U}=ze(C),bt=u.tokenize(k,d);return m?[{index:c,type:B?g.Image:g.ImageLike,raw:f,text:k,src:B,title:U,ref:E,tokens:bt}]:[{index:c,type:B?g.Link:g.LinkLike,raw:f,text:k,href:B,title:U,ref:E,tokens:bt}]})},[y.Escape]:{exec:(p,u)=>l(p,pn,u,a=>{let c=dn[a[1]]??a[1];return[{index:T(a),raw:a[0],text:c,type:g.Text}]})},[y.AutoLink]:{exec:(p,u)=>l(p,fn,u,a=>{let c=a[1],m=!/^[a-z]+:/i.test(c)?"mailto:"+c:c;return[{index:T(a),raw:a[0],text:c,href:m,type:g.Link,tokens:[{type:g.Text,raw:c,text:c}]}]})},[y.BareUrl]:{exec:(p,u)=>l(p,gn,u,a=>{let c=a[0],f=/^www\./i.test(c)?"http://"+c:c;return[{index:T(a),raw:c,text:c,href:f,type:g.Link,tokens:[{type:g.Text,raw:c,text:c}]}]})},[y.FootnoteReference]:{exec:(p,u)=>l(p,yn,u,a=>{let c=j(a[1]);return[{index:T(a),raw:a[0],text:a[1],id:c,type:g.FootnoteReference}]})},[y.Code]:{exec:(p,u)=>l(p,lt,u,a=>{let c=at(a[1]);return[{type:g.Code,raw:a[0],text:c,index:T(a)}]})},[y.EmphasizedLink]:{exec:(p,u)=>l(p,rn,u,a=>{if(a.length<3||_.isNullOrEmpty(a[2]))return null;let c=a[1].length>1?g.Bold:g.Italic,f=a[2];return[{index:T(a),type:c,raw:a[0],text:f,tokens:u.tokenize(f,d)}]})},[y.Emphasize]:{exec:(p,u)=>l(p,sn,u,a=>{let c=a[1]??a[3],f=a[2]??a[4];if(_.isNullOrEmpty(f))return null;let m=c.length>1?g.Bold:g.Italic;return[{index:T(a),type:m,raw:a[0],text:f,tokens:u.tokenize(f,d)}]})},[y.StrikeThrough]:{exec:(p,u)=>l(p,on,u,a=>{if(a.length<3||_.isNullOrEmpty(a[2]))return null;let c=g.StrikeThrough,f=a[2];return[{index:T(a),type:c,raw:a[0],text:f,tokens:u.tokenize(f,d)}]})},[y.Quote]:{exec:(p,u)=>l(p,an,u,a=>{if(a.length<3||_.isNullOrEmpty(a[2]))return null;let c=g.Quote,f=a[2];return[{index:T(a),type:c,raw:a[0],text:f,tokens:u.tokenize(f,d)}]})},[y.LineBreak]:{exec:(p,u)=>l(p,un,u,a=>{let c=a[0],f=c;return[{index:T(a),raw:c,text:f,type:g.LineBreak}]})}},h=(p,u,a)=>{let c=u?.length>0&&u[0].index;if(c>0){let f=p.substr(0,c),m=a.tokenize(f,d)||[];Array.prototype.unshift.apply(u,m)}},l=(p,u,a,c)=>{let f=$(p,u,m=>{if(u!=lt){let k=lt.exec(p);if(k&&k.length&&k.index<m.index)return null}return c(m)});return h(p,f,a),f},d=[o[y.FootnoteReference],o[y.EmphasizedLink],o[y.ImageOrLink],o[y.Escape],o[y.AutoLink],o[y.Emphasize],o[y.StrikeThrough],o[y.Quote],o[y.Code],o[y.LineBreak],o[y.BareUrl]];Array.prototype.push.apply(d,r),d.push(i[y.Text],i[y.Space]);let x=p=>{let u=[i[y.Text],i[y.Space]],a=p?.toLowerCase()||"";return a&&a in s&&Array.prototype.unshift.apply(u,s[a]),u},w={[y.Paragraph]:{exec:(p,u)=>$(p,tn,a=>{let c=a[0],f=c.replace(/^[ \t]+/gm,"");return f.trim().length===0?null:[{type:g.Paragraph,raw:c,text:f,tokens:u.tokenize(f,d)}]})},[y.Space]:{exec:p=>$(p,ln,u=>{let a=u[0];return[{type:g.Space,raw:a,text:a}]})}},b=(p,u)=>{if(!/^ {0,3}(`{3,}|$|>|[-+*]\s|\d+[.\)]|#{1,6}\s|\|)/m.test(p))return u.tokenize(p,d);let c=u.tokenize(p,z),f=c[0];if(!!/\n[ \t]*\n/.test(p)||f?.type!==g.Paragraph)return c;let k=f.tokens??[],C=c.slice(1);return k.concat(C)},N=(p,u)=>je(p).filter(f=>!_.isNullOrEmpty(f)).map(f=>{let m=Ke.exec(f),k=m?f.slice(m[0].length):f,C=b(k,u);if(m==null)return{type:g.ListItem,raw:f,text:k,tokens:C};let I=m[1]!==" ";return{type:g.ListItem,raw:f,text:k,tokens:C,task:!0,checked:I}}),Q=(p,u,a,c)=>{let f=u.map((C,I)=>{let E=p[I]??"",B=c.tokenize(E,d);return{type:g.TableCell,raw:E,text:E,header:a,align:C,tokens:B}}),m=p.join(" | ");return{type:g.TableRow,raw:m,text:m,header:a,tokens:f}},Z={[y.HorizontalRule]:{exec:(p,u)=>$(p,Me,a=>{let c=a[0],f=c;return[{type:g.HorizontalRule,raw:c,text:f}]})},[y.Heading]:{exec:(p,u)=>$(p,Qe,a=>{let c=a[2].replace(/[ \t]+#+[ \t]*$/,"");return[{type:g.Heading,raw:a[0],text:c,level:a[1].length,ref:j(c),tokens:u.tokenize(c,d)}]})},[y.Heading1]:{exec:(p,u)=>$(p,Ze,a=>{let c=a[1];return[{type:g.Heading,raw:a[0],text:c,level:1,ref:j(c),tokens:u.tokenize(c,d)}]})},[y.Heading2]:{exec:(p,u)=>$(p,qe,a=>{let c=a[1];return[{type:g.Heading,raw:a[0],text:c,level:2,ref:j(c),tokens:u.tokenize(c,d)}]})},[y.CodeBlock]:{exec:(p,u)=>$(p,Ue,a=>{let c=a[0],f=c.replace(/^ {4}/gm,"").replace(/\s+$/,""),m=at(f);return f.length===0?null:[{type:g.CodeBlock,raw:c,text:m,tokens:u.tokenize(m,x(""))}]})},[y.Fences]:{exec:(p,u)=>$(p,Ve,a=>{let c=(a[1]??"").trim(),f=c.split(/\s+/),m=f[0].toLowerCase(),k=m in s?null:F.get(m);if(k==null){let E=at(a[2]);return[{type:g.CodeBlock,raw:a[0],text:E,lang:m,tokens:u.tokenize(E,x(m))}]}let C=Ge(a[2]),I=Re.tokenize(C,k);return[{type:g.CodeBlock,raw:a[0],text:C,lang:m,syntax:k.name,highlighted:!0,tokens:I}]})},[y.BlockQuote]:{exec:(p,u)=>$(p,Je,a=>{let c=a[0],f=c.replace(/^ {0,3}> ?/gm,"");return[{type:g.BlockQuote,raw:c,text:f,tokens:u.tokenize(f,z)}]})},[y.OrderedList]:{exec:(p,u)=>$(p,De,a=>{let c=a[0],f=/\d+/.exec(c),m=parseInt(f[0]),k=N(c,u);return[{type:g.OrderedList,start:m,raw:c,text:c,tokens:k}]})},[y.UnorderedList]:{exec:(p,u)=>$(p,Ye,a=>{let c=a[0],f=N(c,u);return[{type:g.UnorderedList,raw:c,text:c,tokens:f}]})},[y.Table]:{exec:(p,u)=>$(p,xn,a=>{let c=ct(a[1]),f=ct(a[2]);if(c.length!==f.length)return null;let m=f.map(He),k=a[3].split(/\r?\n/).filter(B=>B.trim().length>0),C=Q(c,m,!0,u),I=k.map(B=>{let U=ct(B);return Q(U,m,!1,u)}),E=[C].concat(I);return[{type:g.Table,raw:a[0],text:a[0],align:m,tokens:E}]})}},z=Object.values(Z);Array.prototype.push.apply(z,e),z.push(w[y.Paragraph],w[y.Space]);let q=[t[y.Comment],t[y.FootnoteDefinition],t[y.Reference]].concat(z);return q}var G="\0",wn=/[ \r\n]*\0+[ \r\n]*/g;function bn(n){return n?.replace(wn,`
12
+ `).trim()}function qt(n){return _.isNullOrEmpty(n)?"":` title="${Ut(n)}"`}function kn(n){return n==null?"":` style="text-align: ${n}"`}var tt=class{constructor(t=(e,r)=>e?.text||""){this._extraItemRender=t,this.#t=[],this.#e=new Map,this.#r=[],this.#n=new M,this._renderContent=e=>{let r=e.tokens;return _.isNullOrEmpty(r)?e.text:this._render(r)}}#t;#e;#r;#n;_collectDefinitions(t){for(let e of t??[])e?.type===g.Reference&&this.#t.push(e),e?.type===g.FootnoteDefinition&&!this.#e.has(e.id)&&this.#e.set(e.id,e),this._collectDefinitions(e?.tokens)}_findReference(t,e){if(_.isNullOrEmpty(t))return;let r=t.toLowerCase();return this.#t.find(s=>s.image===!0===e&&s.id?.toLowerCase()===r)}_renderCodeBlock(t){let e=G,r=t.lang;if(t.highlighted!==!0){let h=r?' class="'+r+'"':"",l=this._renderContent(t);return`<pre>${e}<code${h}>${l}</code>${e}</pre>${e}`}let s=[r,"code-highlighted"];t.syntax===Xe&&s.push("code-markup");let i=Ut(s.join(" ")),o=this.#n.render(t.tokens);return`<pre>${e}<code class="${i}">${o}</code>${e}</pre>${e}`}_renderImage(t){let e=t.src,r=t.title;if(!e){let i=this._findReference(t.ref,!0);e=i?.url,r=i?.title}if(!e)return`![${this._renderContent(t)}]`;let s=qt(r);return`<img src="${e}" alt="${t.text}"${s} />`}_renderLink(t){let e=t.href,r=t.title;if(!e){let o=this._findReference(t.ref,!1);e=o?.url,r=o?.title}let s=this._renderContent(t);if(!e)return`[${s}]`;let i=qt(r);return`<a href="${e}"${i}>${s}</a>`}_renderListItem(t){let e=G,r=this._renderContent(t);return t.task!==!0?` <li>${r}</li>${e}`:` <li class="task-list-item"><input type="checkbox" disabled${t.checked===!0?" checked":""} /> ${r}</li>${e}`}_renderTableRow(t){let e=G,r="";for(let s of t.tokens??[]){let i=s.header===!0?"th":"td",o=kn(s.align),h=this._renderContent(s);r+=`<${i}${o}>${h}</${i}>`}return`<tr>${r}</tr>${e}`}_renderTable(t){let e=G,r=t.tokens??[],s=r.filter(l=>l.header===!0),i=r.filter(l=>l.header!==!0),o=s.map(l=>this._renderTableRow(l)).join(""),h=`<table>${e}<thead>${e}${o}</thead>${e}`;if(i.length>0){let l=i.map(d=>this._renderTableRow(d)).join("");h+=`<tbody>${e}${l}</tbody>${e}`}return h+`</table>${e}`}_renderFootnoteReference(t){let e=t.id;if(!this.#e.has(e))return`[^${t.text}]`;let r=this.#r,s=!r.includes(e);s&&r.push(e);let i=r.indexOf(e)+1,o=s?` id="fnref-${e}"`:"";return`<sup class="footnote-ref"><a href="#fn-${e}"${o}>${i}</a></sup>`}_renderFootnotes(){let t=this.#r;if(t.length===0)return"";let e=G,r="";for(let s=0;s<t.length;s++){let i=t[s],o=this.#e.get(i),h=this._renderContent(o);r+=`<li id="fn-${i}">${h} <a href="#fnref-${i}" class="footnote-backref">&#8617;</a></li>${e}`}return`<section class="footnotes">${e}<ol>${e}${r}</ol>${e}</section>${e}`}_rendeItem(t,e){let r=this._renderContent,s=G;switch(t?.type){case g.Reference:case g.FootnoteDefinition:return"";case g.Html:return t.raw;case g.BlockQuote:return`<blockquote>
13
+ ${r(t)}</blockquote>${s}`;case g.Bold:return`<b>${r(t)}</b>`;case g.CodeBlock:return this._renderCodeBlock(t);case g.Code:return`<code>${r(t)}</code>`;case g.HorizontalRule:return`<hr />${s}`;case g.Heading:let i=t.level,o=t.ref;return`<h${i} id="${o}">${r(t)}</h${i}>${s}`;case g.Image:case g.ImageLike:return this._renderImage(t);case g.Italic:return`<i>${r(t)}</i>`;case g.StrikeThrough:return`<s>${r(t)}</s>`;case g.Quote:return`<q>${r(t)}</q>`;case g.LineBreak:return"<br />"+s;case g.OrderedList:return`<ol start="${t.start}">
14
+ ${r(t)}</ol>${s}`;case g.UnorderedList:return`<ul>
15
+ ${r(t)}</ul>${s}`;case g.ListItem:return this._renderListItem(t);case g.Link:case g.LinkLike:return this._renderLink(t);case g.Table:return this._renderTable(t);case g.FootnoteReference:return this._renderFootnoteReference(t);case g.Paragraph:return`<p>${r(t)}</p>${s}`;case g.Text:case g.Space:return t.text}return this._extraItemRender(t,e)}_render(t){let e="";for(let r of t||[])e+=this._rendeItem(r,t);return e}render(t){this.#t=[],this.#e.clear(),this.#r=[],this._collectDefinitions(t);let e=this._render(t),r=this._renderFootnotes();return bn(e+r)}},ut=class{_render(t){return _.isNullOrEmpty(t)?"":JSON.stringify(t)}render(t){return"["+t.filter(e=>!_.isNullOrEmpty(e)).map(this._render).join(",")+"]"}};function _n(n){return n&&typeof n=="object"&&typeof n.render=="function"}var ht=class extends P{toHtml(t,e,r){let s=new tt(r);return _.isNullOrEmpty(e)?this.parse(t,s):this.parse(t,K(e),s)}tokenize(t,e){let r=this.parse(t,K(e),new ut);return JSON.parse(r)}parse(t,e=K(),r=new tt){let s=(t??"").replace(/\r\n?/g,`
16
+ `);if(_n(e)){let i=K();return super.parse(s,i,e)}return super.parse(s,e,r)}};var Sn=["identifier","number","string","regex"],$n=[")","]","}","this","super","null","undefined","true","false","++","--"],Cn=["async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","import","in","instanceof","let","new","null","of","return","set","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield","abstract","accessor","any","as","asserts","bigint","boolean","declare","implements","infer","interface","is","keyof","module","namespace","never","number","object","override","package","private","protected","public","readonly","satisfies","string","symbol","type","unique","unknown"],Tn=[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n

]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:"`",type:"string",push:"template"},{match:String.raw`"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\[\s\S]|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\r\n])*\]|[^/\\\[\r\n])+/[a-z]*`,type:"regex",when:{previousNotTypes:Sn,previousNotTexts:$n}},{match:String.raw`0[xX][\da-fA-F_]+n?|0[bB][01_]+n?|0[oO][0-7_]+n?|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d[\d_]*)?n?`,type:"number"},{match:String.raw`#?[A-Za-z_$ -￿][\w$ -￿]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.(?!\d)|\.\.\.|[;,.]`,type:"punctuation"},{match:String.raw`>>>=|<<=|>>=|>>>|\*\*=|&&=|\|\|=|\?\?=|===|!==|=>|\*\*|\+\+|--|<<|>>|&&|\|\||\?\?|[-+*/%&|^<>!=]=?|[~?:@]`,type:"operator"}],dt={name:"javascript",aliases:["js","mjs","cjs","jsx","typescript","ts","tsx","script","ecmascript"],lexical:{start:"root",states:{root:Tn,template:[{match:"`",type:"string",pop:!0},{match:String.raw`\$\{`,type:"punctuation",push:"templateExpression"},{match:String.raw`(?:\\[\s\S]|\$(?!\{)|[^\\`+"`"+String.raw`$])+`,type:"string"}],templateExpression:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:Cn},keywordExceptAfter:[".","?."]}};var ft={previousNotTexts:[".","?."]},gt={name:"pacem-binding",aliases:["pacem","binding"],extends:"javascript",lexical:{states:{root:[{match:String.raw`:host(?=\.)`,type:"binding-host",when:ft},{match:String.raw`::[A-Za-z_$][\w$]*`,type:"binding-host-property"},{match:String.raw`\^+item(?![\w$])`,type:"binding-item"},{match:String.raw`\^+index(?![\w$])`,type:"binding-index"},{match:String.raw`#[A-Za-z_][\w]*`,type:"binding-element",when:ft},{match:String.raw`\$?this(?![\w$])`,type:"binding-this",when:ft}]}}};var Jt={match:String.raw`\r\n|[\r\n]`,type:"newline"},vn=[Jt,{match:String.raw`[ \t\f]+`,type:"space"},{match:'"',type:"string",push:"doubleQuoted"},{match:"'",type:"string",push:"singleQuoted"},{match:String.raw`[^\s=/>"']+`,type:"attribute"},{match:"=",type:"operator"},{match:"/",type:"punctuation"}],Vt=[{match:String.raw`\{\{`,type:"punctuation",embed:"pacem-binding",until:String.raw`\}\}`},{match:String.raw`\}\}`,type:"punctuation"}],yt={name:"markup",aliases:["html","htm","xml","xhtml","svg"],lexical:{start:"root",states:{root:[{match:String.raw`<!--[\s\S]*?(?:-->|$)`,type:"comment"},{match:String.raw`<![^>]*>?`,type:"tag"},{match:String.raw`(<\/)([\w:.-]+)(\s*>?)`,type:["tag","tagname","tag"]},{match:String.raw`(<)(script)(?![\w:.-])`,flags:"i",type:["tag","tagname"],push:"scriptTag"},{match:String.raw`(<)([\w:.-]+)`,type:["tag","tagname"],push:"tag"},{match:String.raw`&(?:#\d+|#[xX][\da-fA-F]+|\w+);`,type:"entity"},Jt,{match:String.raw`[^<&\r\n]+`,type:"text"}],tag:[{match:String.raw`/?>`,type:"tag",pop:!0},{include:"attributes"}],scriptTag:[{match:"/>",type:"tag",pop:!0},{match:">",type:"tag",pop:!0,embed:"javascript",until:String.raw`<\/script`},{include:"attributes"}],attributes:vn,doubleQuoted:[{match:'"',type:"string",pop:!0},...Vt,{match:String.raw`(?:[^"{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}],singleQuoted:[{match:"'",type:"string",pop:!0},...Vt,{match:String.raw`(?:[^'{}]|\{(?!\{)|\}(?!\}))+`,type:"string"}]},insignificant:["space","newline","comment","text"]}};var In=["abstract","add","alias","and","args","as","ascending","async","await","base","bool","break","by","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","do","double","dynamic","else","enum","equals","event","explicit","extern","false","file","finally","fixed","float","for","foreach","from","get","global","goto","group","if","implicit","in","init","int","interface","internal","into","is","join","let","lock","long","managed","nameof","namespace","new","nint","not","notnull","nuint","null","object","on","operator","or","orderby","out","override","params","partial","private","protected","public","readonly","record","ref","remove","required","return","sbyte","scoped","sealed","select","set","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unmanaged","unsafe","ushort","using","value","var","virtual","void","volatile","when","where","while","with","yield"],En=[{match:String.raw`///[^\r\n]*`,type:"doc-comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*[a-z]+[^\r\n]*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v\u00A0\uFEFF]+`,type:"space"},{match:String.raw`\$*("{3,})[\s\S]*?\1`,type:"string"},{match:String.raw`\$@"|@\$"`,type:"string",push:"interpolatedVerbatim"},{match:String.raw`\$"`,type:"string",push:"interpolated"},{match:String.raw`@"(?:[^"]|"")*"?`,type:"string"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F_]+[uUlL]*|0[bB][01_]+[uUlL]*|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?[fFdDmMuUlL]*`,type:"number"},{match:String.raw`@?[A-Za-z_\u00A0-\uFFFF][\w\u00A0-\uFFFF]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`\?\.|::|[;,.]`,type:"punctuation"},{match:String.raw`\?\?=|<<=|>>>=|>>=|>>>|=>|==|!=|<=|>=|&&|\|\||\?\?|\+\+|--|->|<<|[-+*/%&|^<>!=]=?|[~?:]`,type:"operator"}],mt={name:"csharp",aliases:["cs","c#","c-sharp","dotnet"],lexical:{start:"root",states:{root:En,interpolated:[{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`(?:\\.|[^"\\{}\r\n])+`,type:"string"}],interpolatedVerbatim:[{match:'""',type:"string"},{match:'"',type:"string",pop:!0},{match:String.raw`\{\{|\}\}`,type:"string"},{match:String.raw`\{`,type:"punctuation",push:"interpolation"},{match:String.raw`[^"{}]+`,type:"string"}],interpolation:[{match:String.raw`\}`,type:"punctuation",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}],braces:[{match:String.raw`\}`,type:"bracket",pop:!0},{match:String.raw`\{`,type:"bracket",push:"braces"},{include:"root"}]},keywords:{keyword:In},keywordExceptAfter:[".","?."]}};var Fn=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","bool","true","false","NULL","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","and","and_eq","asm","bitand","bitor","catch","char8_t","char16_t","char32_t","class","co_await","co_return","co_yield","compl","concept","consteval","constexpr","constinit","const_cast","decltype","delete","dynamic_cast","explicit","export","final","friend","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reinterpret_cast","requires","static_assert","static_cast","template","this","thread_local","throw","try","typeid","typename","using","virtual","wchar_t","xor","xor_eq"],xt={name:"c",aliases:["cpp","c++","cc","cxx","h","hpp","hxx","objc"],lexical:{start:"root",states:{root:[{match:String.raw`/\*\*(?!/)[\s\S]*?(?:\*/|$)|///[^\r\n]*`,type:"doc-comment"},{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`(?<=^[ \t]*|[\r\n][ \t]*)#[ \t]*\w+(?:\\\r?\n|[^\r\n])*`,type:"preprocessor"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v]+`,type:"space"},{match:String.raw`(?:u8|u|U|L)?R"([^()\\\s]{0,16})\([\s\S]*?\)\1"`,type:"string"},{match:String.raw`(?:u8|u|U|L)?"(?:\\[\s\S]|[^"\\\r\n])*"?`,type:"string"},{match:String.raw`(?:u8|u|U|L)?'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`0[xX][\da-fA-F']+[uUlL]*|0[bB][01']+[uUlL]*|(?:\d[\d']*\.?[\d']*|\.\d[\d']*)(?:[eEpP][+-]?\d+)?[fFlLuU]*`,type:"number"},{match:String.raw`[A-Za-z_][\w]*`,type:"identifier"},{match:String.raw`[()\[\]{}]`,type:"bracket"},{match:String.raw`::|\.\.\.|->\*?|\.\*?|[;,]`,type:"punctuation"},{match:String.raw`<=>|<<=|>>=|<<|>>|\+\+|--|&&|\|\||[-+*/%&|^<>!=]=?|[~?:#]`,type:"operator"}]},keywords:{keyword:Fn},keywordExceptAfter:[".","->","::"]}};var wt={name:"json",aliases:["jsonc","json5","webmanifest"],lexical:{start:"root",states:{root:[{match:String.raw`/\*[\s\S]*?(?:\*/|$)`,type:"comment"},{match:String.raw`//[^\r\n]*`,type:"comment"},{match:String.raw`\r\n|[\r\n]`,type:"newline"},{match:String.raw`[ \t\f\v ]+`,type:"space"},{match:String.raw`(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')(?=\s*:)`,type:"attribute"},{match:String.raw`"(?:\\.|[^"\\\r\n])*"?|'(?:\\.|[^'\\\r\n])*'?`,type:"string"},{match:String.raw`-?(?:0[xX][\da-fA-F]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)|-?Infinity|NaN`,type:"number"},{match:String.raw`[A-Za-z_$][\w$]*`,type:"identifier"},{match:String.raw`[\[\]{}]`,type:"bracket"},{match:String.raw`[:,]`,type:"punctuation"}]},keywords:{keyword:["true","false","null"]}}};var Yt={javascript:dt,"pacem-binding":gt,markup:yt,csharp:mt,c:xt,json:wt};for(let n in Yt){let t=Yt[n];F.register(t)}export{zt as Angle,Ct as Arrays,Tt as Blobs,Lt as Colors,Dt as Compile,V as Dates,St as DeepMerger,Ht as HistoryService,Nt as Imaging,jt as Keys,X as Matrix2D,_ as NullChecker,Gt as Numbers,H as Point,D as Rect,J as Size,Rt as Strings,Xn as detect,Y as parseAsNumericalArray};