@mlightcad/mtext-renderer 0.11.4 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14079,13 +14079,13 @@ class Vt {
14079
14079
  const Pp = Math.PI / 18;
14080
14080
  class Np {
14081
14081
  constructor(e) {
14082
- this.shapeCache = /* @__PURE__ */ new Map(), this.shapeData = /* @__PURE__ */ new Map(), this.fontData = e;
14082
+ this.shapeCache = /* @__PURE__ */ new Map(), this.subshapeCache = /* @__PURE__ */ new Map(), this.shapeData = /* @__PURE__ */ new Map(), this.fontData = e;
14083
14083
  }
14084
14084
  /**
14085
14085
  * Releases parsed shapes and cached shapes
14086
14086
  */
14087
14087
  release() {
14088
- this.shapeCache.clear(), this.shapeData.clear();
14088
+ this.shapeCache.clear(), this.subshapeCache.clear(), this.shapeData.clear();
14089
14089
  }
14090
14090
  /**
14091
14091
  * Parses a character's shape with the given font size.
@@ -14113,7 +14113,7 @@ class Np {
14113
14113
  const s = this.fontData.content.data;
14114
14114
  if (s[e]) {
14115
14115
  const i = s[e];
14116
- r = this.parseShape(i), this.shapeData.set(e, r), this.shapeCache.set(e, r);
14116
+ r = this.parseShape(i, { flushOnEnd: !0 }), this.shapeData.set(e, r), this.shapeCache.set(e, r);
14117
14117
  }
14118
14118
  }
14119
14119
  if (r) {
@@ -14178,10 +14178,10 @@ class Np {
14178
14178
  sp: a,
14179
14179
  isPenDown: o,
14180
14180
  scale: 1,
14181
- // Only flush a pen-down polyline on shape end when parsing a unifont
14182
- // subshape with inherited pen (amgdt %%132). Global flush regresses bigfont
14183
- // subshape caches (e.g. gbcbig.shx CJK glyphs).
14184
- flushEndPolyline: n.initialPenDown ?? !1
14181
+ // Top-level glyphs flush trailing pen-down strokes at 0x00. Subshape
14182
+ // primitives and inherited-pen unifont subshapes (amgdt %%132) opt in
14183
+ // via flushOnEnd; bigfont subshape cache keeps flush off to avoid regressions.
14184
+ flushEndPolyline: n.flushOnEnd ?? !1
14185
14185
  };
14186
14186
  for (let l = 0; l < e.length; l++) {
14187
14187
  const u = e[l];
@@ -14502,12 +14502,12 @@ class Np {
14502
14502
  const c = this.fontData.content.data[e];
14503
14503
  if (!c)
14504
14504
  return;
14505
- a = this.parseShape(c, { initialPenDown: !0 });
14506
- } else if (a = this.shapeCache.get(e), !a) {
14505
+ a = this.parseShape(c, { initialPenDown: !0, flushOnEnd: !0 });
14506
+ } else if (a = this.subshapeCache.get(e), !a) {
14507
14507
  const c = this.fontData.content.data[e];
14508
14508
  if (!c)
14509
14509
  return;
14510
- a = this.parseShape(c), this.shapeData.set(e, a), this.shapeCache.set(e, a);
14510
+ a = this.parseShape(c, { flushOnEnd: !1 }), this.shapeData.set(e, a), this.subshapeCache.set(e, a);
14511
14511
  }
14512
14512
  const o = a.normalizeToOrigin(!0);
14513
14513
  return this.scaleShapeByHeightAndWidth(o, r, n).offset(s, !1);
@@ -1,7 +1,7 @@
1
1
  (function(A,ue){typeof exports=="object"&&typeof module<"u"?ue(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],ue):(A=typeof globalThis<"u"?globalThis:A||self,ue(A.MTextRenderer={},A.THREE))})(this,function(A,ue){"use strict";function io(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const M=io(ue);class Vn{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(n=>n!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...n){for(const r of this.listeners)r.call(null,e,...n)}}const ao=t=>t.substring(t.lastIndexOf(".")+1),as=t=>t.split("/").pop(),at=t=>{const e=as(t);if(e){const n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t},oo=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],jn=t=>oo[t];class co{constructor(){this.cache=new Map}hasGeometry(e,n){const r=this.generateKey(e,n);return this.cache.has(r)}getGeometry(e,n){const r=this.generateKey(e,n);if(this.cache.has(r))return this.cache.get(r)}setGeometry(e,n,r){const s=this.generateKey(e,n);this.cache.set(s,r)}dispose(){for(const e of this.cache.values())e.dispose();this.cache.clear()}generateKey(e,n){return`${e}_${n}`}}class qn{constructor(e){this.names=new Set,this.unsupportedChars={},this.encoding=e.encoding,e.alias.forEach(n=>this.names.add(n)),this.cache=new co}getShapeByName(e,n){}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class $n extends M.Shape{constructor(){super(...arguments),this.width=0}}const Yn=(t,e)=>e.some(n=>t instanceof n);let os,cs;function lo(){return os||(os=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function uo(){return cs||(cs=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Xn=new WeakMap,Kn=new WeakMap,sn=new WeakMap;function ho(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",a)},i=()=>{n(mt(t.result)),s()},a=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",a)});return sn.set(e,t),e}function fo(t){if(Xn.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",a),t.removeEventListener("abort",a)},i=()=>{n(),s()},a=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",a),t.addEventListener("abort",a)});Xn.set(t,e)}let Zn={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Xn.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return mt(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function ls(t){Zn=t(Zn)}function po(t){return uo().includes(t)?function(...e){return t.apply(Jn(this),e),mt(this.request)}:function(...e){return mt(t.apply(Jn(this),e))}}function go(t){return typeof t=="function"?po(t):(t instanceof IDBTransaction&&fo(t),Yn(t,lo())?new Proxy(t,Zn):t)}function mt(t){if(t instanceof IDBRequest)return ho(t);if(Kn.has(t))return Kn.get(t);const e=go(t);return e!==t&&(Kn.set(t,e),sn.set(e,t)),e}const Jn=t=>sn.get(t);function mo(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(t,e),o=mt(a);return r&&a.addEventListener("upgradeneeded",c=>{r(mt(a.result),c.oldVersion,c.newVersion,mt(a.transaction),c)}),n&&a.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),o.then(c=>{i&&c.addEventListener("close",()=>i()),s&&c.addEventListener("versionchange",l=>s(l.oldVersion,l.newVersion,l))}).catch(()=>{}),o}const yo=["get","getKey","getAll","getAllKeys","count"],bo=["put","add","delete","clear"],Qn=new Map;function us(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Qn.get(e))return Qn.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=bo.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||yo.includes(n)))return;const i=async function(a,...o){const c=this.transaction(a,s?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(o.shift())),(await Promise.all([l[n](...o),s&&c.done]))[0]};return Qn.set(e,i),i}ls(t=>({...t,get:(e,n,r)=>us(e,n)||t.get(e,n,r),has:(e,n)=>!!us(e,n)||t.has(e,n)}));const xo=["continue","continuePrimaryKey","advance"],hs={},er=new WeakMap,fs=new WeakMap,vo={get(t,e){if(!xo.includes(e))return t[e];let n=hs[e];return n||(n=hs[e]=function(...r){er.set(this,fs.get(this)[e](...r))}),n}};async function*So(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const n=new Proxy(e,vo);for(fs.set(n,e),sn.set(n,Jn(e));e;)yield n,e=await(er.get(n)||e.continue()),er.delete(n)}function ps(t,e){return e===Symbol.asyncIterator&&Yn(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Yn(t,[IDBIndex,IDBObjectStore])}ls(t=>({...t,get(e,n,r){return ps(e,n)?So:t.get(e,n,r)},has(e,n){return ps(e,n)||t.has(e,n)}}));const yt={fonts:"fonts"},tr=[{version:1,stores:[{name:yt.fonts,keyPath:"name"}]},{version:2,stores:[{name:yt.fonts,keyPath:"name"}]}],De=class De{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("unload",()=>{this.close()})}static get instance(){return De._instance||(De._instance=new De),De._instance}async set(e,n){await(await this.getDatabase()).put(yt.fonts,{...n,name:e})}async get(e){return await(await this.getDatabase()).get(yt.fonts,e)}async find(e){const n=at(e).toLowerCase(),r=await this.get(n);return r||(await this.getAll()).find(i=>{var a;return i.name===n||((a=i.alias)==null?void 0:a.some(o=>o.toLowerCase()===n))})}async delete(e){await(await this.getDatabase()).delete(yt.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll(yt.fonts)}async clear(){await(await this.getDatabase()).clear(yt.fonts)}async has(e){return await this.get(e)!==void 0}close(){if(!this.isClosing){this.isClosing=!0;try{this.db&&(this.db.close(),this.db=void 0)}finally{this.isClosing=!1}}}async destroy(){this.close(),await indexedDB.deleteDatabase(De.DATABASE_NAME),De._instance=void 0}async getDatabase(){if(this.isClosing)throw new Error("Cannot perform operation while database is closing");return this.db?this.db:(this.db=await mo(De.DATABASE_NAME,De.DATABASE_VERSION,{upgrade:(e,n,r)=>this.handleUpgrade(e,n,r),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),De.instance.close()}}),this.db)}handleUpgrade(e,n,r){const s=tr.filter(i=>i.version>n&&(!r||i.version<=r));for(const i of s)this.applySchemaVersion(e,i)}applySchemaVersion(e,n){for(const r of n.stores)e.objectStoreNames.contains(r.name)||e.createObjectStore(r.name,{keyPath:r.keyPath})}};De.DATABASE_NAME="mlightcad",De.DATABASE_VERSION=tr[tr.length-1].version;let ot=De;const an={minimal:["txt","simkai"],r12r14:["txt","simplex","romans","gbcbig","simsun"],modern:["hztxt","simsun"],international:["txt","simplex","romans","simsun"],cjk:["gbcbig","hztxt","simsun","simkai"]},on={minimal:["simplex","amgdt"],r12r14:["simplex","amgdt"],modern:["simplex","amgdt"],international:["simplex","amgdt"],cjk:["simplex","amgdt"]};function nr(t){return Object.prototype.hasOwnProperty.call(an,t)}var rr=0,ds=-3;function Gt(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function wo(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new Gt,this.dtree=new Gt}var gs=new Gt,ms=new Gt,sr=new Uint8Array(30),ir=new Uint16Array(30),ys=new Uint8Array(30),bs=new Uint16Array(30),To=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xs=new Gt,$e=new Uint8Array(320);function vs(t,e,n,r){var s,i;for(s=0;s<n;++s)t[s]=0;for(s=0;s<30-n;++s)t[s+n]=s/n|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<t[s]}function Co(t,e){var n;for(n=0;n<7;++n)t.table[n]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,n=0;n<24;++n)t.trans[n]=256+n;for(n=0;n<144;++n)t.trans[24+n]=n;for(n=0;n<8;++n)t.trans[168+n]=280+n;for(n=0;n<112;++n)t.trans[176+n]=144+n;for(n=0;n<5;++n)e.table[n]=0;for(e.table[5]=32,n=0;n<32;++n)e.trans[n]=n}var Ss=new Uint16Array(16);function ar(t,e,n,r){var s,i;for(s=0;s<16;++s)t.table[s]=0;for(s=0;s<r;++s)t.table[e[n+s]]++;for(t.table[0]=0,i=0,s=0;s<16;++s)Ss[s]=i,i+=t.table[s];for(s=0;s<r;++s)e[n+s]&&(t.trans[Ss[e[n+s]]++]=s)}function ko(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function Ye(t,e,n){if(!e)return n;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,r+n}function or(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=0,r=0,s=0,i=t.tag;do r=2*r+(i&1),i>>>=1,++s,n+=e.table[s],r-=e.table[s];while(r>=0);return t.tag=i,t.bitcount-=s,e.trans[n+r]}function Fo(t,e,n){var r,s,i,a,o,c;for(r=Ye(t,5,257),s=Ye(t,5,1),i=Ye(t,4,4),a=0;a<19;++a)$e[a]=0;for(a=0;a<i;++a){var l=Ye(t,3,0);$e[To[a]]=l}for(ar(xs,$e,0,19),o=0;o<r+s;){var u=or(t,xs);switch(u){case 16:var h=$e[o-1];for(c=Ye(t,2,3);c;--c)$e[o++]=h;break;case 17:for(c=Ye(t,3,3);c;--c)$e[o++]=0;break;case 18:for(c=Ye(t,7,11);c;--c)$e[o++]=0;break;default:$e[o++]=u;break}}ar(e,$e,0,r),ar(n,$e,r,s)}function ws(t,e,n){for(;;){var r=or(t,e);if(r===256)return rr;if(r<256)t.dest[t.destLen++]=r;else{var s,i,a,o;for(r-=257,s=Ye(t,sr[r],ir[r]),i=or(t,n),a=t.destLen-Ye(t,ys[i],bs[i]),o=a;o<a+s;++o)t.dest[t.destLen++]=t.dest[o]}}}function Eo(t){for(var e,n,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],n=t.source[t.sourceIndex+3],n=256*n+t.source[t.sourceIndex+2],e!==(~n&65535))return ds;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,rr}function Ts(t,e){var n=new wo(t,e),r,s,i;do{switch(r=ko(n),s=Ye(n,2,0),s){case 0:i=Eo(n);break;case 1:i=ws(n,gs,ms);break;case 2:Fo(n,n.ltree,n.dtree),i=ws(n,n.ltree,n.dtree);break;default:i=ds}if(i!==rr)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}Co(gs,ms),vs(sr,ir,4,3),vs(ys,bs,2,1),sr[28]=0,ir[28]=258;function kt(t,e,n,r,s){return Math.pow(1-s,3)*t+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*n+Math.pow(s,3)*r}function bt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}bt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},bt.prototype.addPoint=function(t,e){typeof t=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},bt.prototype.addX=function(t){this.addPoint(t,null)},bt.prototype.addY=function(t){this.addPoint(null,t)},bt.prototype.addBezier=function(t,e,n,r,s,i,a,o){const c=[t,e],l=[n,r],u=[s,i],h=[a,o];this.addPoint(t,e),this.addPoint(a,o);for(let f=0;f<=1;f++){const p=6*c[f]-12*l[f]+6*u[f],y=-3*c[f]+9*l[f]-9*u[f]+3*h[f],m=3*l[f]-3*c[f];if(y===0){if(p===0)continue;const T=-m/p;0<T&&T<1&&(f===0&&this.addX(kt(c[f],l[f],u[f],h[f],T)),f===1&&this.addY(kt(c[f],l[f],u[f],h[f],T)));continue}const b=Math.pow(p,2)-4*m*y;if(b<0)continue;const v=(-p+Math.sqrt(b))/(2*y);0<v&&v<1&&(f===0&&this.addX(kt(c[f],l[f],u[f],h[f],v)),f===1&&this.addY(kt(c[f],l[f],u[f],h[f],v)));const w=(-p-Math.sqrt(b))/(2*y);0<w&&w<1&&(f===0&&this.addX(kt(c[f],l[f],u[f],h[f],w)),f===1&&this.addY(kt(c[f],l[f],u[f],h[f],w)))}},bt.prototype.addQuad=function(t,e,n,r,s,i){const a=t+.6666666666666666*(n-t),o=e+2/3*(r-e),c=a+1/3*(s-t),l=o+1/3*(i-e);this.addBezier(t,e,a,o,c,l,s,i)};var Cs=bt;function pe(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var Ht={};function ks(t,e){const n=Math.floor(t),r=t-n;if(Ht[e]||(Ht[e]={}),Ht[e][r]!==void 0){const i=Ht[e][r];return n+i}const s=+(Math.round(r+"e+"+e)+"e-"+e);return Ht[e][r]=s,n+s}function Fs(t){let e=[[]],n=0,r=0;for(let s=0;s<t.length;s+=1){const i=e[e.length-1],a=t[s],o=i[0],c=i[1],l=i[i.length-1],u=t[s+1];i.push(a),a.type==="M"?(n=a.x,r=a.y):a.type==="L"&&(!u||u.type==="Z")?Math.abs(a.x-n)>1||Math.abs(a.y-r)>1||i.pop():a.type==="L"&&l&&l.x===a.x&&l.y===a.y?i.pop():a.type==="Z"&&(o&&c&&l&&o.type==="M"&&c.type==="L"&&l.type==="L"&&l.x===o.x&&l.y===o.y&&(i.shift(),i[0].type="M"),s+1<t.length&&e.push([]))}return t=[].concat.apply([],e),t}function Ao(t){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},t)}function Oo(t){return parseInt(t)===t&&(t={decimalPlaces:t,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},t)}pe.prototype.fromSVG=function(t,e={}){typeof SVGPathElement<"u"&&t instanceof SVGPathElement&&(t=t.getAttribute("d")),e=Ao(e),this.commands=[];const n="0123456789",r="MmLlQqCcZzHhVv",s="SsTtAa",i="-+";let a={},o=[""],c=!1;function l(y){return y.filter(m=>m.length).map(m=>{let b=parseFloat(m);return(e.decimalPlaces||e.decimalPlaces===0)&&(b=ks(b,e.decimalPlaces)),b})}function u(y){if(!this.commands.length)return y;const m=this.commands[this.commands.length-1];for(let b=0;b<y.length;b++)y[b]+=m[b&1?"y":"x"];return y}function h(){if(a.type===void 0)return;const y=a.type.toUpperCase(),m=y!=="Z"&&a.type.toUpperCase()!==a.type;let b=l(o);if(o=[""],!b.length&&y!=="Z")return;m&&y!=="H"&&y!=="V"&&(b=u.apply(this,[b]));const v=this.commands.length&&this.commands[this.commands.length-1].x||0,w=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(y){case"M":this.moveTo(...b);break;case"L":this.lineTo(...b);break;case"V":for(let T=0;T<b.length;T++){let C=0;m&&(C=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(v,b[T]+C)}break;case"H":for(let T=0;T<b.length;T++){let C=0;m&&(C=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(b[T]+C,w)}break;case"C":this.bezierCurveTo(...b);break;case"Q":this.quadraticCurveTo(...b);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(const T in this.commands[this.commands.length-1])this.commands[this.commands.length-1][T]===void 0&&(this.commands[this.commands.length-1][T]=0)}for(let y=0;y<t.length;y++){const m=t.charAt(y),b=o[o.length-1];if(n.indexOf(m)>-1)o[o.length-1]+=m;else if(i.indexOf(m)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),m==="-")!a.type||b.indexOf("-")>0?c=!0:b.length?o.push("-"):o[o.length-1]=m;else if(!a.type||b.length>0)c=!0;else continue;else if(r.indexOf(m)>-1)a.type?(h.apply(this),a={type:m}):a.type=m;else{if(s.indexOf(m)>-1)throw new Error("Unsupported path command: "+m+". Currently supported commands are "+r.split("").join(", ")+".");` ,
2
2
  \r\f\v`.indexOf(m)>-1?o.push(""):m==="."?!a.type||b.indexOf(m)>-1?c=!0:o[o.length-1]+=m:c=!0}if(c)throw new Error("Unexpected character: "+m+" at offset "+y)}h.apply(this),e.optimize&&(this.commands=Fs(this.commands));const f=e.flipY;let p=e.flipYBase;if(f===!0&&e.flipYBase===void 0){const y=this.getBoundingBox();p=y.y1+y.y2}for(const y in this.commands){const m=this.commands[y];for(const b in m)["x","x1","x2"].includes(b)?this.commands[y][b]=e.x+m[b]*e.scale:["y","y1","y2"].includes(b)&&(this.commands[y][b]=e.y+(f?p-m[b]:m[b])*e.scale)}return this},pe.fromSVG=function(t,e){return new pe().fromSVG(t,e)},pe.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})},pe.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})},pe.prototype.curveTo=pe.prototype.bezierCurveTo=function(t,e,n,r,s,i){this.commands.push({type:"C",x1:t,y1:e,x2:n,y2:r,x:s,y:i})},pe.prototype.quadTo=pe.prototype.quadraticCurveTo=function(t,e,n,r){this.commands.push({type:"Q",x1:t,y1:e,x:n,y:r})},pe.prototype.close=pe.prototype.closePath=function(){this.commands.push({type:"Z"})},pe.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof Cs){const e=t;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,t)},pe.prototype.getBoundingBox=function(){const t=new Cs;let e=0,n=0,r=0,s=0;for(let i=0;i<this.commands.length;i++){const a=this.commands[i];switch(a.type){case"M":t.addPoint(a.x,a.y),e=r=a.x,n=s=a.y;break;case"L":t.addPoint(a.x,a.y),r=a.x,s=a.y;break;case"Q":t.addQuad(r,s,a.x1,a.y1,a.x,a.y),r=a.x,s=a.y;break;case"C":t.addBezier(r,s,a.x1,a.y1,a.x2,a.y2,a.x,a.y),r=a.x,s=a.y;break;case"Z":r=e,s=n;break;default:throw new Error("Unexpected path command "+a.type)}}return t.isEmpty()&&t.addPoint(0,0),t},pe.prototype.draw=function(t){const e=this._layers;if(e&&e.length){for(let r=0;r<e.length;r++)this.draw.call(e[r],t);return}const n=this._image;if(n){t.drawImage(n.image,n.x,n.y,n.width,n.height);return}t.beginPath();for(let r=0;r<this.commands.length;r+=1){const s=this.commands[r];s.type==="M"?t.moveTo(s.x,s.y):s.type==="L"?t.lineTo(s.x,s.y):s.type==="C"?t.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?t.quadraticCurveTo(s.x1,s.y1,s.x,s.y):s.type==="Z"&&this.stroke&&this.strokeWidth&&t.closePath()}this.fill&&(t.fillStyle=this.fill,t.fill()),this.stroke&&(t.strokeStyle=this.stroke,t.lineWidth=this.strokeWidth,t.stroke())},pe.prototype.toPathData=function(t){t=Oo(t);function e(o){const c=ks(o,t.decimalPlaces);return Math.round(o)===c?""+c:c.toFixed(t.decimalPlaces)}function n(){let o="";for(let c=0;c<arguments.length;c+=1){const l=arguments[c];l>=0&&c>0&&(o+=" "),o+=e(l)}return o}let r=this.commands;t.optimize&&(r=JSON.parse(JSON.stringify(this.commands)),r=Fs(r));const s=t.flipY;let i=t.flipYBase;if(s===!0&&i===void 0){const o=new pe;o.extend(r);const c=o.getBoundingBox();i=c.y1+c.y2}let a="";for(let o=0;o<r.length;o+=1){const c=r[o];c.type==="M"?a+="M"+n(c.x,s?i-c.y:c.y):c.type==="L"?a+="L"+n(c.x,s?i-c.y:c.y):c.type==="C"?a+="C"+n(c.x1,s?i-c.y1:c.y1,c.x2,s?i-c.y2:c.y2,c.x,s?i-c.y:c.y):c.type==="Q"?a+="Q"+n(c.x1,s?i-c.y1:c.y1,c.x,s?i-c.y:c.y):c.type==="Z"&&(a+="Z")}return a},pe.prototype.toSVG=function(t,e){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),e||(e=this.toPathData(t));let n='<path d="';return n+=e,n+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?n+=' fill="none"':n+=' fill="'+this.fill+'"'),this.stroke&&(n+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),n+="/>",n},pe.prototype.toDOMElement=function(t,e){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),e||(e=this.toPathData(t));const n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",e),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?n.setAttribute("fill","none"):n.setAttribute("fill",this.fill)),this.stroke&&(n.setAttribute("stroke",this.stroke),n.setAttribute("stroke-width",this.strokeWidth)),n};var Ft=pe;function Es(t){throw new Error(t)}function As(t,e){t||Es(e)}var H={fail:Es,argument:As,assert:As},Os=32768,Ls=2147483648,Lo=-32768,Io=32767+1/65536,Et={},D={},z={};function We(t){return function(){return t}}D.BYTE=function(t){return H.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]},z.BYTE=We(1),D.CHAR=function(t){return[t.charCodeAt(0)]},z.CHAR=We(1),D.CHARARRAY=function(t){(t===null||typeof t>"u")&&(t="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let n=0;n<t.length;n+=1)e[n]=t.charCodeAt(n);return e},z.CHARARRAY=function(t){return typeof t>"u"?0:t.length},D.USHORT=function(t){return[t>>8&255,t&255]},z.USHORT=We(2),D.SHORT=function(t){return t>=Os&&(t=-(2*Os-t)),[t>>8&255,t&255]},z.SHORT=We(2),D.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]},z.UINT24=We(3),D.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]},z.ULONG=We(4),D.LONG=function(t){return t>=Ls&&(t=-(2*Ls-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]},z.LONG=We(4),D.FLOAT=function(t){if(t>Io||t<Lo)throw new Error(`Value ${t} is outside the range of representable values in 16.16 format`);const e=Math.round(t*65536)<<0;return D.ULONG(e)},z.FLOAT=z.ULONG,D.FIXED=D.ULONG,z.FIXED=z.ULONG,D.FWORD=D.SHORT,z.FWORD=z.SHORT,D.UFWORD=D.USHORT,z.UFWORD=z.USHORT,D.F2DOT14=function(t){return D.USHORT(t*16384)},z.F2DOT14=z.USHORT,D.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]},z.LONGDATETIME=We(8),D.TAG=function(t){return H.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]},z.TAG=We(4),D.Card8=D.BYTE,z.Card8=z.BYTE,D.Card16=D.USHORT,z.Card16=z.USHORT,D.OffSize=D.BYTE,z.OffSize=z.BYTE,D.SID=D.USHORT,z.SID=z.USHORT,D.NUMBER=function(t){return t>=-107&&t<=107?[t+139]:t>=108&&t<=1131?(t=t-108,[(t>>8)+247,t&255]):t>=-1131&&t<=-108?(t=-t-108,[(t>>8)+251,t&255]):t>=-32768&&t<=32767?D.NUMBER16(t):D.NUMBER32(t)},z.NUMBER=function(t){return D.NUMBER(t).length},D.NUMBER16=function(t){return[28,t>>8&255,t&255]},z.NUMBER16=We(3),D.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]},z.NUMBER32=We(5),D.REAL=function(t){let e=t.toString();const n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(n){const i=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));e=(Math.round(t*i)/i).toString()}let r="";for(let i=0,a=e.length;i<a;i+=1){const o=e[i];o==="e"?r+=e[++i]==="-"?"c":"b":o==="."?r+="a":o==="-"?r+="e":r+=o}r+=r.length&1?"f":"ff";const s=[30];for(let i=0,a=r.length;i<a;i+=2)s.push(parseInt(r.substr(i,2),16));return s},z.REAL=function(t){return D.REAL(t).length},D.NAME=D.CHARARRAY,z.NAME=z.CHARARRAY,D.STRING=D.CHARARRAY,z.STRING=z.CHARARRAY,Et.UTF8=function(t,e,n){const r=[],s=n;for(let i=0;i<s;i++,e+=1)r[i]=t.getUint8(e);return String.fromCharCode.apply(null,r)},Et.UTF16=function(t,e,n){const r=[],s=n/2;for(let i=0;i<s;i++,e+=2)r[i]=t.getUint16(e);return String.fromCharCode.apply(null,r)},D.UTF16=function(t){const e=[];for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);e[e.length]=r>>8&255,e[e.length]=r&255}return e},z.UTF16=function(t){return t.length*2};var cn={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Et.MACSTRING=function(t,e,n,r){const s=cn[r];if(s===void 0)return;let i="";for(let a=0;a<n;a++){const o=t.getUint8(e+a);o<=127?i+=String.fromCharCode(o):i+=s[o&127]}return i};var ln=typeof WeakMap=="function"&&new WeakMap,un,Ro=function(t){if(!un){un={};for(let s in cn)un[s]=new String(s)}const e=un[t];if(e===void 0)return;if(ln){const s=ln.get(e);if(s!==void 0)return s}const n=cn[t];if(n===void 0)return;const r={};for(let s=0;s<n.length;s++)r[n.charCodeAt(s)]=s+128;return ln&&ln.set(e,r),r};D.MACSTRING=function(t,e){const n=Ro(e);if(n===void 0)return;const r=[];for(let s=0;s<t.length;s++){let i=t.charCodeAt(s);if(i>=128&&(i=n[i],i===void 0))return;r[s]=i}return r},z.MACSTRING=function(t,e){const n=D.MACSTRING(t,e);return n!==void 0?n.length:0};function cr(t){return t>=-128&&t<=127}function Mo(t,e,n){let r=0;const s=t.length;for(;e<s&&r<64&&t[e]===0;)++e,++r;return n.push(128|r-1),e}function Do(t,e,n){let r=0;const s=t.length;let i=e;for(;i<s&&r<64;){const a=t[i];if(!cr(a)||a===0&&i+1<s&&t[i+1]===0)break;++i,++r}n.push(r-1);for(let a=e;a<i;++a)n.push(t[a]+256&255);return i}function Bo(t,e,n){let r=0;const s=t.length;let i=e;for(;i<s&&r<64;){const a=t[i];if(a===0||cr(a)&&i+1<s&&cr(t[i+1]))break;++i,++r}n.push(64|r-1);for(let a=e;a<i;++a){const o=t[a];n.push(o+65536>>8&255,o+256&255)}return i}D.VARDELTAS=function(t){let e=0;const n=[];for(;e<t.length;){const r=t[e];r===0?e=Mo(t,e,n):r>=-128&&r<=127?e=Do(t,e,n):e=Bo(t,e,n)}return n},D.INDEX=function(t){let e=1;const n=[e],r=[];for(let o=0;o<t.length;o+=1){const c=D.OBJECT(t[o]);Array.prototype.push.apply(r,c),e+=c.length,n.push(e)}if(r.length===0)return[0,0];const s=[],i=1+Math.floor(Math.log(e)/Math.log(2))/8|0,a=[void 0,D.BYTE,D.USHORT,D.UINT24,D.ULONG][i];for(let o=0;o<n.length;o+=1){const c=a(n[o]);Array.prototype.push.apply(s,c)}return Array.prototype.concat(D.Card16(t.length),D.OffSize(i),s,r)},z.INDEX=function(t){return D.INDEX(t).length},D.DICT=function(t){let e=[];const n=Object.keys(t),r=n.length;for(let s=0;s<r;s+=1){const i=parseInt(n[s],0),a=t[i],o=D.OPERAND(a.value,a.type),c=D.OPERATOR(i);for(let l=0;l<o.length;l++)e.push(o[l]);for(let l=0;l<c.length;l++)e.push(c[l])}return e},z.DICT=function(t){return D.DICT(t).length},D.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]},D.OPERAND=function(t,e){let n=[];if(Array.isArray(e))for(let r=0;r<e.length;r+=1){H.argument(t.length===e.length,"Not enough arguments given for type"+e);const s=D.OPERAND(t[r],e[r]);for(let i=0;i<s.length;i++)n.push(s[i])}else if(e==="SID"){const r=D.NUMBER(t);for(let s=0;s<r.length;s++)n.push(r[s])}else if(e==="offset"){const r=D.NUMBER32(t);for(let s=0;s<r.length;s++)n.push(r[s])}else if(e==="number"){const r=D.NUMBER(t);for(let s=0;s<r.length;s++)n.push(r[s])}else if(e==="real"){const r=D.REAL(t);for(let s=0;s<r.length;s++)n.push(r[s])}else throw new Error("Unknown operand type "+e);return n},D.OP=D.BYTE,z.OP=z.BYTE;var hn=typeof WeakMap=="function"&&new WeakMap;D.CHARSTRING=function(t){if(hn){const r=hn.get(t);if(r!==void 0)return r}let e=[];const n=t.length;for(let r=0;r<n;r+=1){const s=t[r],i=D[s.type](s.value);for(let a=0;a<i.length;a++)e.push(i[a])}return hn&&hn.set(t,e),e},z.CHARSTRING=function(t){return D.CHARSTRING(t).length},D.OBJECT=function(t){const e=D[t.type];return H.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)},z.OBJECT=function(t){const e=z[t.type];return H.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)},D.TABLE=function(t){let e=[];const n=(t.fields||[]).length,r=[],s=[];for(let i=0;i<n;i+=1){const a=t.fields[i],o=D[a.type];H.argument(o!==void 0,"No encoding function for field type "+a.type+" ("+a.name+")");let c=t[a.name];c===void 0&&(c=a.value);const l=o(c);if(a.type==="TABLE")c.fields!==null&&(s.push(e.length),r.push(l)),e.push(0,0);else for(let u=0;u<l.length;u++)e.push(l[u])}for(let i=0;i<r.length;i+=1){const a=s[i],o=e.length;H.argument(o<65536,"Table "+t.tableName+" too big."),e[a]=o>>8,e[a+1]=o&255;for(let c=0;c<r[i].length;c++)e.push(r[i][c])}return e},z.TABLE=function(t){let e=0;const n=(t.fields||[]).length;for(let r=0;r<n;r+=1){const s=t.fields[r],i=z[s.type];H.argument(i!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");let a=t[s.name];a===void 0&&(a=s.value),e+=i(a),s.type==="TABLE"&&(e+=2)}return e},D.RECORD=D.TABLE,z.RECORD=z.TABLE,D.LITERAL=function(t){return t},z.LITERAL=function(t){return t.length};function he(t,e,n){if(e&&e.length)for(let r=0;r<e.length;r+=1){const s=e[r];this[s.name]=s.value}if(this.tableName=t,this.fields=e,n){const r=Object.keys(n);for(let s=0;s<r.length;s+=1){const i=r[s],a=n[i];this[i]!==void 0&&(this[i]=a)}}}he.prototype.encode=function(){return D.TABLE(this)},he.prototype.sizeOf=function(){return z.TABLE(this)};function At(t,e,n){n===void 0&&(n=e.length);const r=new Array(e.length+1);r[0]={name:t+"Count",type:"USHORT",value:n};for(let s=0;s<e.length;s++)r[s+1]={name:t+s,type:"USHORT",value:e[s]};return r}function lr(t,e,n){const r=e.length,s=new Array(r+1);s[0]={name:t+"Count",type:"USHORT",value:r};for(let i=0;i<r;i++)s[i+1]={name:t+i,type:"TABLE",value:n(e[i],i)};return s}function Ot(t,e,n){const r=e.length;let s=[];s[0]={name:t+"Count",type:"USHORT",value:r};for(let i=0;i<r;i++)s=s.concat(n(e[i],i));return s}function fn(t){t.format===1?he.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(At("glyph",t.glyphs))):t.format===2?he.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Ot("rangeRecord",t.ranges,function(e,n){return[{name:"startGlyphID"+n,type:"USHORT",value:e.start},{name:"endGlyphID"+n,type:"USHORT",value:e.end},{name:"startCoverageIndex"+n,type:"USHORT",value:e.index}]}))):H.assert(!1,"Coverage format must be 1 or 2.")}fn.prototype=Object.create(he.prototype),fn.prototype.constructor=fn;function pn(t){he.call(this,"scriptListTable",Ot("scriptRecord",t,function(e,n){const r=e.script;let s=r.defaultLangSys;return H.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+n,type:"TAG",value:e.tag},{name:"script"+n,type:"TABLE",value:new he("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new he("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(At("featureIndex",s.featureIndexes)))}].concat(Ot("langSys",r.langSysRecords,function(i,a){const o=i.langSys;return[{name:"langSysTag"+a,type:"TAG",value:i.tag},{name:"langSys"+a,type:"TABLE",value:new he("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:o.reqFeatureIndex}].concat(At("featureIndex",o.featureIndexes)))}]})))}]}))}pn.prototype=Object.create(he.prototype),pn.prototype.constructor=pn;function dn(t){he.call(this,"featureListTable",Ot("featureRecord",t,function(e,n){const r=e.feature;return[{name:"featureTag"+n,type:"TAG",value:e.tag},{name:"feature"+n,type:"TABLE",value:new he("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(At("lookupListIndex",r.lookupListIndexes)))}]}))}dn.prototype=Object.create(he.prototype),dn.prototype.constructor=dn;function gn(t,e){he.call(this,"lookupListTable",lr("lookup",t,function(n){let r=e[n.lookupType];return H.assert(!!r,"Unable to write GSUB lookup type "+n.lookupType+" tables."),new he("lookupTable",[{name:"lookupType",type:"USHORT",value:n.lookupType},{name:"lookupFlag",type:"USHORT",value:n.lookupFlag}].concat(lr("subtable",n.subtables,r)))}))}gn.prototype=Object.create(he.prototype),gn.prototype.constructor=gn;function mn(t){t.format===1?he.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:t.startGlyph}].concat(At("glyph",t.classes))):t.format===2?he.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Ot("rangeRecord",t.ranges,function(e,n){return[{name:"startGlyphID"+n,type:"USHORT",value:e.start},{name:"endGlyphID"+n,type:"USHORT",value:e.end},{name:"class"+n,type:"USHORT",value:e.classId}]}))):H.assert(!1,"Class format must be 1 or 2.")}mn.prototype=Object.create(he.prototype),mn.prototype.constructor=mn;var L={Table:he,Record:he,Coverage:fn,ClassDef:mn,ScriptList:pn,FeatureList:dn,LookupList:gn,ushortList:At,tableList:lr,recordList:Ot};function Is(t,e){return t.getUint8(e)}function yn(t,e){return t.getUint16(e,!1)}function _o(t,e){return t.getInt16(e,!1)}function Rs(t,e){return(t.getUint16(e)<<8)+t.getUint8(e+2)}function ur(t,e){return t.getUint32(e,!1)}function Uo(t,e){return t.getInt32(e,!1)}function Ms(t,e){const n=t.getInt16(e,!1),r=t.getUint16(e+2,!1);return n+r/65535}function Po(t,e){let n="";for(let r=e;r<e+4;r+=1)n+=String.fromCharCode(t.getInt8(r));return n}function No(t,e,n){let r=0;for(let s=0;s<n;s+=1)r<<=8,r+=t.getUint8(e+s);return r}function Go(t,e,n){const r=[];for(let s=e;s<n;s+=1)r.push(t.getUint8(s));return r}function Ho(t){let e="";for(let n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return e}var Wo={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},be={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function k(t,e){this.data=t,this.offset=e,this.relativeOffset=0}k.prototype.parseByte=function(){const t=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},k.prototype.parseChar=function(){const t=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},k.prototype.parseCard8=k.prototype.parseByte,k.prototype.parseUShort=function(){const t=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},k.prototype.parseCard16=k.prototype.parseUShort,k.prototype.parseSID=k.prototype.parseUShort,k.prototype.parseOffset16=k.prototype.parseUShort,k.prototype.parseShort=function(){const t=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},k.prototype.parseF2Dot14=function(){const t=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,t},k.prototype.parseUInt24=function(){const t=Rs(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,t},k.prototype.parseULong=function(){const t=ur(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},k.prototype.parseLong=function(){const t=Uo(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},k.prototype.parseOffset32=k.prototype.parseULong,k.prototype.parseFixed=function(){const t=Ms(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},k.prototype.parseString=function(t){const e=this.data,n=this.offset+this.relativeOffset;let r="";this.relativeOffset+=t;for(let s=0;s<t;s++)r+=String.fromCharCode(e.getUint8(n+s));return r},k.prototype.parseTag=function(){return this.parseString(4)},k.prototype.parseLongDateTime=function(){let t=ur(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t},k.prototype.parseVersion=function(t){const e=yn(this.data,this.offset+this.relativeOffset),n=yn(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+n/t/10},k.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=Wo[t]*e},k.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getUint32(r),r+=4;return this.relativeOffset+=t*4,e},k.prototype.parseOffset16List=k.prototype.parseUShortList=function(t){t===void 0&&(t=this.parseUShort());const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getUint16(r),r+=2;return this.relativeOffset+=t*2,e},k.prototype.parseShortList=function(t){const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getInt16(r),r+=2;return this.relativeOffset+=t*2,e},k.prototype.parseByteList=function(t){const e=new Array(t),n=this.data;let r=this.offset+this.relativeOffset;for(let s=0;s<t;s++)e[s]=n.getUint8(r++);return this.relativeOffset+=t,e},k.prototype.parseList=function(t,e){e||(e=t,t=this.parseUShort());const n=new Array(t);for(let r=0;r<t;r++)n[r]=e.call(this);return n},k.prototype.parseList32=function(t,e){e||(e=t,t=this.parseULong());const n=new Array(t);for(let r=0;r<t;r++)n[r]=e.call(this);return n},k.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());const n=new Array(t),r=Object.keys(e);for(let s=0;s<t;s++){const i={};for(let a=0;a<r.length;a++){const o=r[a],c=e[o];i[o]=c.call(this)}n[s]=i}return n},k.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());const n=new Array(t),r=Object.keys(e);for(let s=0;s<t;s++){const i={};for(let a=0;a<r.length;a++){const o=r[a],c=e[o];i[o]=c.call(this)}n[s]=i}return n},k.prototype.parseTupleRecords=function(t,e){let n=[];for(let r=0;r<t;r++){let s=[];for(let i=0;i<e;i++)s.push(this.parseF2Dot14());n.push(s)}return n},k.prototype.parseStruct=function(t){if(typeof t=="function")return t.call(this);{const e=Object.keys(t),n={};for(let r=0;r<e.length;r++){const s=e[r],i=t[s];n[s]=i.call(this)}return n}},k.prototype.parseValueRecord=function(t){if(t===void 0&&(t=this.parseUShort()),t===0)return;const e={};return t&1&&(e.xPlacement=this.parseShort()),t&2&&(e.yPlacement=this.parseShort()),t&4&&(e.xAdvance=this.parseShort()),t&8&&(e.yAdvance=this.parseShort()),t&16&&(e.xPlaDevice=void 0,this.parseShort()),t&32&&(e.yPlaDevice=void 0,this.parseShort()),t&64&&(e.xAdvDevice=void 0,this.parseShort()),t&128&&(e.yAdvDevice=void 0,this.parseShort()),e},k.prototype.parseValueRecordList=function(){const t=this.parseUShort(),e=this.parseUShort(),n=new Array(e);for(let r=0;r<e;r++)n[r]=this.parseValueRecord(t);return n},k.prototype.parsePointer=function(t){const e=this.parseOffset16();if(e>0)return new k(this.data,this.offset+e).parseStruct(t)},k.prototype.parsePointer32=function(t){const e=this.parseOffset32();if(e>0)return new k(this.data,this.offset+e).parseStruct(t)},k.prototype.parseListOfLists=function(t){const e=this.parseOffset16List(),n=e.length,r=this.relativeOffset,s=new Array(n);for(let i=0;i<n;i++){const a=e[i];if(a===0){s[i]=void 0;continue}if(this.relativeOffset=a,t){const o=this.parseOffset16List(),c=new Array(o.length);for(let l=0;l<o.length;l++)this.relativeOffset=a+o[l],c[l]=t.call(this);s[i]=c}else s[i]=this.parseUShortList()}return this.relativeOffset=r,s},k.prototype.parseCoverage=function(){const t=this.offset+this.relativeOffset,e=this.parseUShort(),n=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(n)};if(e===2){const r=new Array(n);for(let s=0;s<n;s++)r[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+t.toString(16)+": Coverage format must be 1 or 2.")},k.prototype.parseClassDef=function(){const t=this.offset+this.relativeOffset,e=this.parseUShort();return e===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:e===2?{format:2,ranges:this.parseRecordList({start:k.uShort,end:k.uShort,classId:k.uShort})}:(console.warn(`0x${t.toString(16)}: This font file uses an invalid ClassDef format of ${e}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:e})},k.list=function(t,e){return function(){return this.parseList(t,e)}},k.list32=function(t,e){return function(){return this.parseList32(t,e)}},k.recordList=function(t,e){return function(){return this.parseRecordList(t,e)}},k.recordList32=function(t,e){return function(){return this.parseRecordList32(t,e)}},k.pointer=function(t){return function(){return this.parsePointer(t)}},k.pointer32=function(t){return function(){return this.parsePointer32(t)}},k.tag=k.prototype.parseTag,k.byte=k.prototype.parseByte,k.uShort=k.offset16=k.prototype.parseUShort,k.uShortList=k.prototype.parseUShortList,k.uInt24=k.prototype.parseUInt24,k.uLong=k.offset32=k.prototype.parseULong,k.uLongList=k.prototype.parseULongList,k.fixed=k.prototype.parseFixed,k.f2Dot14=k.prototype.parseF2Dot14,k.struct=k.prototype.parseStruct,k.coverage=k.prototype.parseCoverage,k.classDef=k.prototype.parseClassDef;var Ds={reserved:k.uShort,reqFeatureIndex:k.uShort,featureIndexes:k.uShortList};k.prototype.parseScriptList=function(){return this.parsePointer(k.recordList({tag:k.tag,script:k.pointer({defaultLangSys:k.pointer(Ds),langSysRecords:k.recordList({tag:k.tag,langSys:k.pointer(Ds)})})}))||[]},k.prototype.parseFeatureList=function(){return this.parsePointer(k.recordList({tag:k.tag,feature:k.pointer({featureParams:k.offset16,lookupListIndexes:k.uShortList})}))||[]},k.prototype.parseLookupList=function(t){return this.parsePointer(k.list(k.pointer(function(){const e=this.parseUShort();H.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");const n=this.parseUShort(),r=n&16;return{lookupType:e,lookupFlag:n,subtables:this.parseList(k.pointer(t[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]},k.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){const t=this.parseUShort(),e=this.parseUShort();return H.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:k.offset32,featureTableSubstitutionOffset:k.offset32})})||[]},k.prototype.parseVariationStore=function(){const t=this.relativeOffset,e=this.parseUShort(),n={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=t+e+2,n},k.prototype.parseItemVariationStore=function(){const t=this.relativeOffset,e={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},n=this.parseOffset32(),r=this.parseUShort(),s=this.parseULongList(r);this.relativeOffset=t+n,e.variationRegions=this.parseVariationRegionList();for(let i=0;i<r;i++){const a=s[i];this.relativeOffset=t+a,e.itemVariationSubtables.push(this.parseItemVariationSubtable())}return e},k.prototype.parseVariationRegionList=function(){const t=this.parseUShort(),e=this.parseUShort();return this.parseRecordList(e,{regionAxes:k.recordList(t,{startCoord:k.f2Dot14,peakCoord:k.f2Dot14,endCoord:k.f2Dot14})})},k.prototype.parseItemVariationSubtable=function(){const t=this.parseUShort(),e=this.parseUShort(),n=this.parseUShortList(),r=n.length;return{regionIndexes:n,deltaSets:t&&r?this.parseDeltaSets(t,e,r):[]}},k.prototype.parseDeltaSetIndexMap=function(){const t=this.parseByte(),e=this.parseByte(),n=[];let r=0;switch(t){case 0:r=this.parseUShort();break;case 1:r=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${t}`)}if(!r)return{format:t,entryFormat:e};const s=(e&be.INNER_INDEX_BIT_COUNT_MASK)+1,i=((e&be.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let a=0;a<r;a++){let o;if(i===1)o=this.parseByte();else if(i===2)o=this.parseUShort();else if(i===3)o=this.parseUInt24();else if(i===4)o=this.parseULong();else throw new Error(`Invalid entry size of ${i}`);const c=o>>s,l=o&(1<<s)-1;n.push({outerIndex:c,innerIndex:l})}return{format:t,entryFormat:e,map:n}},k.prototype.parseDeltaSets=function(t,e,n){const r=Array.from({length:t},()=>[]),s=e&be.LONG_WORDS,i=e&be.WORD_DELTA_COUNT_MASK;if(i>n)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let c=0;c<t;c++)for(let l=0;l<n;l++)l<i?r[c].push(a()):r[c].push(o());return r},k.prototype.parseTupleVariationStoreList=function(t,e,n){const r=this.parseUShort(),i=this.parseUShort()&1,a=this.parseOffset32(),o=(i?this.parseULong:this.parseUShort).bind(this),c={};let l=o();i||(l*=2);let u;for(let h=0;h<r;h++){u=o(),i||(u*=2);const f=u-l;c[h]=f?this.parseTupleVariationStore(a+l,t,e,n,h):void 0,l=u}return c},k.prototype.parseTupleVariationStore=function(t,e,n,r,s){const i=this.relativeOffset;this.relativeOffset=t,n==="cvar"&&(this.relativeOffset+=4);const a=this.parseUShort(),o=!!(a&be.SHARED_POINT_NUMBERS),c=a&be.COUNT_MASK;let l=this.parseOffset16();const u=[];let h=[];for(let y=0;y<c;y++){const m=this.parseTupleVariationHeader(e,n);u.push(m)}this.relativeOffset!==t+l&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${t+l}, actually ${this.relativeOffset}`),this.relativeOffset=t+l),o&&(h=this.parsePackedPointNumbers());let f=this.relativeOffset;for(let y=0;y<c;y++){const m=u[y];m.privatePoints=[],this.relativeOffset=f,n==="cvar"&&!m.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),m.flags.privatePointNumbers&&(m.privatePoints=this.parsePackedPointNumbers()),delete m.flags;const b=this.offset,v=this.relativeOffset,w=T=>{let C,E;const R=()=>{let P=0;if(n==="gvar"){if(P=m.privatePoints.length||h.length,!P){const V=r.get(s);V.path,P=V.points.length,P+=4}}else n==="cvar"&&(P=r.length);this.offset=b,this.relativeOffset=v,C=this.parsePackedDeltas(P),n==="gvar"&&(E=this.parsePackedDeltas(P))};return{configurable:!0,get:function(){return C===void 0&&R(),T==="deltasY"?E:C},set:function(P){C===void 0&&R(),T==="deltasY"?E=P:C=P}}};Object.defineProperty(m,"deltas",w.call(this,"deltas")),n==="gvar"&&Object.defineProperty(m,"deltasY",w.call(this,"deltasY")),f+=m.variationDataSize,delete m.variationDataSize}this.relativeOffset=i;const p={headers:u};return p.sharedPoints=h,p},k.prototype.parseTupleVariationHeader=function(t,e){const n=this.parseUShort(),r=this.parseUShort(),s=!!(r&be.EMBEDDED_PEAK_TUPLE),i=!!(r&be.INTERMEDIATE_REGION),a=!!(r&be.PRIVATE_POINT_NUMBERS),o=s?void 0:r&be.TUPLE_INDEX_MASK,c=s?this.parseTupleRecords(1,t)[0]:void 0,l=i?this.parseTupleRecords(1,t)[0]:void 0,u=i?this.parseTupleRecords(1,t)[0]:void 0,h={variationDataSize:n,peakTuple:c,intermediateStartTuple:l,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:i,privatePointNumbers:a}};return e==="gvar"&&(h.sharedTupleRecordsIndex=o),h},k.prototype.parsePackedPointNumbers=function(){const t=this.parseByte(),e=[];let n=t;if(t>=128){const s=this.parseByte();n=(t&be.POINT_RUN_COUNT_MASK)<<8|s}let r=0;for(;e.length<n;){const s=this.parseByte(),i=!!(s&be.POINTS_ARE_WORDS);let a=(s&be.POINT_RUN_COUNT_MASK)+1;for(let o=0;o<a&&e.length<n;o++){let c;i?c=this.parseUShort():c=this.parseByte(),r=r+c,e.push(r)}}return e},k.prototype.parsePackedDeltas=function(t){const e=[];for(;e.length<t;){const n=this.parseByte(),r=!!(n&be.DELTAS_ARE_ZERO),s=!!(n&be.DELTAS_ARE_WORDS),i=(n&be.DELTA_RUN_COUNT_MASK)+1;for(let a=0;a<i&&e.length<t;a++)r?e.push(0):s?e.push(this.parseShort()):e.push(this.parseChar())}return e};var _={getByte:Is,getCard8:Is,getUShort:yn,getCard16:yn,getShort:_o,getUInt24:Rs,getULong:ur,getFixed:Ms,getTag:Po,getOffset:No,getBytes:Go,bytesToString:Ho,Parser:k},bn=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Bs={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},zo={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},_s={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Vo(t,e,n){switch(t){case 0:if(e===65535)return"und";if(n)return n[e];break;case 1:return Bs[e];case 3:return _s[e]}}var hr="utf-16",jo={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},qo={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function fr(t,e,n){switch(t){case 0:return hr;case 1:return qo[n]||jo[e];case 3:if(e===1||e===10)return hr;break}}var Us={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function $o(t){return Us[t]}function Yo(t,e,n){const r={},s=new _.Parser(t,e),i=s.parseUShort(),a=s.parseUShort(),o=s.offset+s.parseUShort();for(let c=0;c<a;c++){const l=s.parseUShort(),u=s.parseUShort(),h=s.parseUShort(),f=s.parseUShort(),p=bn[f]||f,y=s.parseUShort(),m=s.parseUShort(),b=Vo(l,h,n),v=fr(l,u,h),w=$o(l);if(v!==void 0&&b!==void 0&&w!==void 0){let T;if(v===hr?T=Et.UTF16(t,o+m,y):T=Et.MACSTRING(t,o+m,y,v),T){let C=r[w];C===void 0&&(C=r[w]={});let E=C[p];E===void 0&&(E=C[p]={}),E[b]=T}}}return i===1&&s.parseUShort(),r}function xn(t){const e={};for(let n in t)e[t[n]]=parseInt(n);return e}function Ps(t,e,n,r,s,i){return new L.Record("NameRecord",[{name:"platformID",type:"USHORT",value:t},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:n},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function Xo(t,e){const n=t.length,r=e.length-n+1;e:for(let s=0;s<r;s++)for(;s<r;s++){for(let i=0;i<n;i++)if(e[s+i]!==t[i])continue e;return s}return-1}function Ns(t,e){let n=Xo(t,e);if(n<0){n=e.length;let r=0;const s=t.length;for(;r<s;++r)e.push(t[r])}return n}function Ko(t,e){const n=xn(Us),r=xn(Bs),s=xn(_s),i=[],a=[];for(let c in t){let l;const u=[],h={},f=xn(bn),p=n[c];for(let y in t[c]){let m=f[y];if(m===void 0&&(m=y),l=parseInt(m),isNaN(l))throw new Error('Name table entry "'+y+'" does not exist, see nameTableNames for complete list.');h[l]=t[c][y],u.push(l)}for(let y=0;y<u.length;y++){l=u[y];const m=h[l];for(let b in m){const v=m[b];if(p===1||p===0){let w=r[b],T=zo[w];const C=fr(p,T,w);let E=D.MACSTRING(v,C);if(p===0&&(w=e.indexOf(b),w<0&&(w=e.length,e.push(b)),T=4,E=D.UTF16(v)),E!==void 0){const R=Ns(E,a);i.push(Ps(p,T,w,l,E.length,R))}}if(p===3){const w=s[b];if(w!==void 0){const T=D.UTF16(v),C=Ns(T,a);i.push(Ps(3,1,w,l,T.length,C))}}}}}i.sort(function(c,l){return c.platformID-l.platformID||c.encodingID-l.encodingID||c.languageID-l.languageID||c.nameID-l.nameID});const o=new L.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:i.length},{name:"stringOffset",type:"USHORT",value:6+i.length*12}]);for(let c=0;c<i.length;c++)o.fields.push({name:"record_"+c,type:"RECORD",value:i[c]});return o.fields.push({name:"strings",type:"LITERAL",value:a}),o}function vn(t,e,n=[]){if(e<256&&e in bn){if(n.length&&!n.includes(parseInt(e)))return;e=bn[e]}for(let r in t)for(let s in t[r])if(s===e||parseInt(s)===e)return t[r][s]}var Gs={parse:Yo,make:Ko,getNameByID:vn};function Zo(t,e,n,r){t.length=e.parseUShort(),t.language=e.parseUShort()-1;const s=e.parseByteList(t.length),i=Object.assign({},s),a=fr(n,r,t.language),o=cn[a];for(let c=0;c<o.length;c++)i[o.charCodeAt(c)]=s[128+c];t.glyphIndexMap=i}function Jo(t,e,n){e.parseUShort(),t.length=e.parseULong(),t.language=e.parseULong();let r;t.groupCount=r=e.parseULong(),t.glyphIndexMap={};for(let s=0;s<r;s+=1){const i=e.parseULong(),a=e.parseULong();let o=e.parseULong();for(let c=i;c<=a;c+=1)t.glyphIndexMap[c]=o,n===12&&o++}}function Qo(t,e,n,r,s){t.length=e.parseUShort(),t.language=e.parseUShort();let i;t.segCount=i=e.parseUShort()>>1,e.skip("uShort",3),t.glyphIndexMap={};const a=new _.Parser(n,r+s+14),o=new _.Parser(n,r+s+16+i*2),c=new _.Parser(n,r+s+16+i*4),l=new _.Parser(n,r+s+16+i*6);let u=r+s+16+i*8;for(let h=0;h<i-1;h+=1){let f;const p=a.parseUShort(),y=o.parseUShort(),m=c.parseShort(),b=l.parseUShort();for(let v=y;v<=p;v+=1)b!==0?(u=l.offset+l.relativeOffset-2,u+=b,u+=(v-y)*2,f=_.getUShort(n,u),f!==0&&(f=f+m&65535)):f=v+m&65535,t.glyphIndexMap[v]=f}}function ec(t,e){const n={};e.skip("uLong");const r=e.parseULong();for(let s=0;s<r;s+=1){const i=e.parseUInt24(),a={varSelector:i},o=e.parseOffset32(),c=e.parseOffset32(),l=e.relativeOffset;o&&(e.relativeOffset=o,a.defaultUVS=e.parseStruct({ranges:function(){return e.parseRecordList32({startUnicodeValue:e.parseUInt24,additionalCount:e.parseByte})}})),c&&(e.relativeOffset=c,a.nonDefaultUVS=e.parseStruct({uvsMappings:function(){const u={},h=e.parseRecordList32({unicodeValue:e.parseUInt24,glyphID:e.parseUShort});for(let f=0;f<h.length;f+=1)u[h[f].unicodeValue]=h[f];return u}})),n[i]=a,e.relativeOffset=l}t.varSelectorList=n}function tc(t,e){const n={};n.version=_.getUShort(t,e),H.argument(n.version===0,"cmap table version should be 0."),n.numTables=_.getUShort(t,e+2);let r=null,s=-1,i=-1,a=null,o=null;const c=[0,1,2,3,4,6],l=[0,1,10];for(let h=n.numTables-1;h>=0;h-=1)if(a=_.getUShort(t,e+4+h*8),o=_.getUShort(t,e+4+h*8+2),a===3&&l.includes(o)||a===0&&c.includes(o)||a===1&&o===0){if(i>0)continue;if(i=_.getULong(t,e+4+h*8+4),r)break}else if(a===0&&o===5){if(s=_.getULong(t,e+4+h*8+4),r=new _.Parser(t,e+s),r.parseUShort()!==14)s=-1,r=null;else if(i>0)break}if(i===-1)throw new Error("No valid cmap sub-tables found.");const u=new _.Parser(t,e+i);if(n.format=u.parseUShort(),n.format===0)Zo(n,u,a,o);else if(n.format===12||n.format===13)Jo(n,u,n.format);else if(n.format===4)Qo(n,u,t,e,i);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+n.format+", platformId "+a+", encodingId "+o+").");return r&&ec(n,r),n}function nc(t,e,n){t.segments.push({end:e,start:e,delta:-(e-n),offset:0,glyphIndex:n})}function rc(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function sc(t){if(t.length===0)return t;const e=[t[0]];for(let n=1;n<t.length;n++){const r=e[e.length-1],s=t[n];r.end+1===s.start&&r.delta===s.delta&&s.end!==65535?r.end=s.end:e.push(s)}return e}function ic(t){let e=!0,n;for(n=t.length-1;n>0;n-=1)if(t.get(n).unicode>65535){e=!1;break}let r=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||r.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),r.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new L.Table("cmap",r);for(s.segments=[],n=0;n<t.length;n+=1){const p=t.get(n);for(let y=0;y<p.unicodes.length;y+=1)nc(s,p.unicodes[y],n)}s.segments.sort(function(p,y){return p.start-y.start}),s.segments=sc(s.segments),rc(s);const i=s.segments.length;let a=0,o=[],c=[],l=[],u=[],h=[],f=[];for(n=0;n<i;n+=1){const p=s.segments[n];p.end<=65535&&p.start<=65535?(o.push({name:"end_"+n,type:"USHORT",value:p.end}),c.push({name:"start_"+n,type:"USHORT",value:p.start}),l.push({name:"idDelta_"+n,type:"SHORT",value:p.delta}),u.push({name:"idRangeOffset_"+n,type:"USHORT",value:p.offset}),p.glyphId!==void 0&&h.push({name:"glyph_"+n,type:"USHORT",value:p.glyphId})):a+=1,!e&&p.glyphIndex!==void 0&&(f.push({name:"cmap12Start_"+n,type:"ULONG",value:p.start}),f.push({name:"cmap12End_"+n,type:"ULONG",value:p.end}),f.push({name:"cmap12Glyph_"+n,type:"ULONG",value:p.glyphIndex}))}s.segCountX2=(i-a)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(i-a)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange;for(let p=0;p<o.length;p++)s.fields.push(o[p]);s.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let p=0;p<c.length;p++)s.fields.push(c[p]);for(let p=0;p<l.length;p++)s.fields.push(l[p]);for(let p=0;p<u.length;p++)s.fields.push(u[p]);for(let p=0;p<h.length;p++)s.fields.push(h[p]);if(s.cmap4Length=14+o.length*2+2+c.length*2+l.length*2+u.length*2+h.length*2,!e){const p=16+f.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:p},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:f.length/3});for(let y=0;y<f.length;y++)s.fields.push(f[y])}return s}var Hs={parse:tc,make:ic},Sn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],ac=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],oc=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],cc=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],pr=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],lc=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],xt=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Ws(t){this.font=t}Ws.prototype.charToGlyphIndex=function(t){const e=t.codePointAt(0),n=this.font.glyphs;if(n)for(let r=0;r<n.length;r+=1){const s=n.get(r);for(let i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return r}return null};function zs(t){this.cmap=t}zs.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function Vs(t,e){this.encoding=t,this.charset=e}Vs.prototype.charToGlyphIndex=function(t){const e=t.codePointAt(0),n=this.encoding[e];return this.charset.indexOf(n)};function dr(t){switch(t.version){case 1:this.names=xt.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(let e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<xt.length?this.names[e]=xt[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-xt.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(let e=0;e<t.numberOfGlyphs;e++)this.names[e]=xt[e+t.glyphNameIndex[e]];break;case 3:this.names=[];break;default:this.names=[];break}}dr.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)},dr.prototype.glyphIndexToName=function(t){return this.names[t]};function uc(t){let e;const n=t.tables.cmap.glyphIndexMap,r=Object.keys(n);for(let s=0;s<r.length;s+=1){const i=r[s],a=n[i];e=t.glyphs.get(a),e.addUnicode(parseInt(i))}for(let s=0;s<t.glyphs.length;s+=1)e=t.glyphs.get(s),t.cffEncoding?e.name=t.cffEncoding.charset[s]:t.glyphNames.names&&(e.name=t.glyphNames.glyphIndexToName(s))}function hc(t){t._IndexToUnicodeMap={};const e=t.tables.cmap.glyphIndexMap,n=Object.keys(e);for(let r=0;r<n.length;r+=1){const s=n[r];let i=e[s];t._IndexToUnicodeMap[i]===void 0?t._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:t._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function fc(t,e){e.lowMemory?hc(t):uc(t)}function pc(t,e,n,r,s){t.beginPath(),t.moveTo(e,n),t.lineTo(r,s),t.stroke()}var vt={line:pc};function dc(t,e){const n=new k(t,e),r=n.parseShort();r!==0&&console.warn("Only CPALv0 is currently fully supported.");const s=n.parseShort(),i=n.parseShort(),a=n.parseShort(),o=n.parseOffset32(),c=n.parseUShortList(i);n.relativeOffset=o;const l=n.parseULongList(a);return n.relativeOffset=o,{version:r,numPaletteEntries:s,colorRecords:l,colorRecordIndices:c}}function gc({version:t=0,numPaletteEntries:e=0,colorRecords:n=[],colorRecordIndices:r=[0]}){return H.argument(t===0,"Only CPALv0 are supported."),H.argument(n.length,"No colorRecords given."),H.argument(r.length,"No colorRecordIndices given."),r.length>1&&H.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new L.Table("CPAL",[{name:"version",type:"USHORT",value:t},{name:"numPaletteEntries",type:"USHORT",value:e||n.length},{name:"numPalettes",type:"USHORT",value:r.length},{name:"numColorRecords",type:"USHORT",value:n.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*r.length},...r.map((s,i)=>({name:"colorRecordIndices_"+i,type:"USHORT",value:s})),...n.map((s,i)=>({name:"colorRecords_"+i,type:"ULONG",value:s}))])}function js(t){var e=(t&4278190080)>>24,n=(t&16711680)>>16,r=(t&65280)>>8,s=t&255;return e=e+256&255,n=n+256&255,r=r+256&255,s=(s+256&255)/255,{b:e,g:n,r,a:s}}function gr(t,e,n=0,r="hexa"){if(e==65535)return"currentColor";const s=t&&t.tables&&t.tables.cpal;if(!s)return"currentColor";if(n>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const i=s.colorRecordIndices[n]+e;if(i>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${i})`);const a=js(s.colorRecords[i]);return r==="bgra"?a:Lt(a,r)}function ze(t){return("0"+parseInt(t).toString(16)).slice(-2)}function mc(t){const e=t.r/255,n=t.g/255,r=t.b/255,s=Math.max(e,n,r),i=Math.min(e,n,r);let a,o,c=(s+i)/2;if(s===i)a=o=0;else{const l=s-i;switch(o=c>.5?l/(2-s-i):l/(s+i),s){case e:a=(n-r)/l+(n<r?6:0);break;case n:a=(r-e)/l+2;break;case r:a=(e-n)/l+4;break}a/=6}return{h:a*360,s:o*100,l:c*100}}function yc(t){let{h:e,s:n,l:r,a:s}=t;e=e%360,n/=100,r/=100;const i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(e/60%2-1)),o=r-i/2;let c=0,l=0,u=0;return 0<=e&&e<60?(c=i,l=a,u=0):60<=e&&e<120?(c=a,l=i,u=0):120<=e&&e<180?(c=0,l=i,u=a):180<=e&&e<240?(c=0,l=a,u=i):240<=e&&e<300?(c=a,l=0,u=i):300<=e&&e<=360&&(c=i,l=0,u=a),{r:Math.round((c+o)*255),g:Math.round((l+o)*255),b:Math.round((u+o)*255),a:s}}function qs(t){return parseInt(`0x${ze(t.b)}${ze(t.g)}${ze(t.r)}${ze(t.a*255)}`,16)}function wn(t,e="hexa"){const n=e=="raw"||e=="cpal",r=Number.isInteger(t);let s=!0;if(r&&n||t==="currentColor")return t;if(typeof t=="object"){if(e=="bgra")return t;if(n)return qs(t)}else if(!r&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(t.trim())){switch(t=t.trim().substring(1),t.length){case 3:t={r:parseInt(t[0].repeat(2),16),g:parseInt(t[1].repeat(2),16),b:parseInt(t[2].repeat(2),16),a:1};break;case 4:t={r:parseInt(t[0].repeat(2),16),g:parseInt(t[1].repeat(2),16),b:parseInt(t[2].repeat(2),16),a:parseInt(t[3].repeat(2),16)/255};break;case 6:t={r:parseInt(t[0]+t[1],16),g:parseInt(t[2]+t[3],16),b:parseInt(t[4]+t[5],16),a:1};break;case 8:t={r:parseInt(t[0]+t[1],16),g:parseInt(t[2]+t[3],16),b:parseInt(t[4]+t[5],16),a:parseInt(t[6]+t[7],16)/255};break}if(e=="bgra")return t}else if(typeof document<"u"&&/^[a-z]+$/i.test(t)){const i=document.createElement("canvas").getContext("2d");i.fillStyle=t;const a=Lt(i.fillStyle,"hexa");a==="#000000ff"&&t.toLowerCase()!=="black"?s=!1:t=a}else{t=t.trim();const i=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(i.test(t)){const a=t.match(i).filter(o=>typeof o<"u");t={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(t)){const o=t.match(a).filter(c=>typeof c<"u");t=yc({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${t}`);return Lt(t,e)}function Lt(t,e="hexa"){if(t==="currentColor")return t;if(Number.isInteger(t)){if(e=="raw"||e=="cpal")return t;t=js(t)}else typeof t!="object"&&(t=wn(t,"bgra"));let n=["hsl","hsla"].includes(e)?mc(t):null;switch(e){case"rgba":return`rgba(${t.r}, ${t.g}, ${t.b}, ${parseFloat(t.a.toFixed(3))})`;case"rgb":return`rgb(${t.r}, ${t.g}, ${t.b})`;case"hex":case"hex6":case"hex-6":return`#${ze(t.r)}${ze(t.g)}${ze(t.b)}`;case"hexa":case"hex8":case"hex-8":return`#${ze(t.r)}${ze(t.g)}${ze(t.b)}${ze(t.a*255)}`;case"hsl":return`hsl(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%)`;case"hsla":return`hsla(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%, ${parseFloat(t.a.toFixed(3))})`;case"bgra":return t;case"raw":case"cpal":return qs(t);default:throw new Error("Unknown color format: "+e)}}var $s={parse:dc,make:gc,getPaletteColor:gr,parseColor:wn,formatColor:Lt};function bc(t,e){let n=e||new Ft;return{configurable:!0,get:function(){return typeof n=="function"&&(n=n()),n},set:function(r){n=r}}}function xe(t){this.bindConstructorValues(t)}xe.prototype.bindConstructorValues=function(t){if(this.index=t.index||0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name||null,this.unicode=t.unicode,this.unicodes=t.unicodes||(t.unicode!==void 0?[t.unicode]:[]),"xMin"in t&&(this.xMin=t.xMin),"yMin"in t&&(this.yMin=t.yMin),"xMax"in t&&(this.xMax=t.xMax),"yMax"in t&&(this.yMax=t.yMax),"advanceWidth"in t&&(this.advanceWidth=t.advanceWidth),"leftSideBearing"in t&&(this.leftSideBearing=t.leftSideBearing),"points"in t&&(this.points=t.points),Object.defineProperty(this,"path",bc(this,t.path))},xe.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)},xe.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},xe.prototype.getPath=function(t,e,n,r,s){t=t!==void 0?t:0,e=e!==void 0?e:0,n=n!==void 0?n:72,r=Object.assign({},s&&s.defaultRenderOptions,r);let i,a,o=r.xScale,c=r.yScale;const l=1/(this.path.unitsPerEm||1e3)*n;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,r.variation),i=u.path.commands),r.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,n,r)),a?(i=s.hinting.getCommands(a),t=Math.round(t),e=Math.round(e),o=c=1):(i=u.path.commands,o===void 0&&(o=l),c===void 0&&(c=l));const h=new Ft;if(r.drawSVG){const f=this.getSvgImage(s);if(f){const p=new Ft;return p._image={image:f.image,x:t+f.leftSideBearing*l,y:e-f.baseline*l,width:f.image.width*l,height:f.image.height*l},h._layers=[p],h}}if(r.drawLayers){const f=this.getLayers(s);if(f&&f.length){h._layers=[];for(let p=0;p<f.length;p+=1){const y=f[p];let m=gr(s,y.paletteIndex,r.usePalette);m==="currentColor"?m=r.fill||"black":m=Lt(m,r.colorFormat||"rgba"),r=Object.assign({},r,{fill:m}),h._layers.push(this.getPath.call(y.glyph,t,e,n,r,s))}return h}}h.fill=r.fill||this.path.fill,h.stroke=this.path.stroke,h.strokeWidth=this.path.strokeWidth*l;for(let f=0;f<i.length;f+=1){const p=i[f];p.type==="M"?h.moveTo(t+p.x*o,e+-p.y*c):p.type==="L"?h.lineTo(t+p.x*o,e+-p.y*c):p.type==="Q"?h.quadraticCurveTo(t+p.x1*o,e+-p.y1*c,t+p.x*o,e+-p.y*c):p.type==="C"?h.curveTo(t+p.x1*o,e+-p.y1*c,t+p.x2*o,e+-p.y2*c,t+p.x*o,e+-p.y*c):p.type==="Z"&&h.stroke&&h.strokeWidth&&h.closePath()}return h},xe.prototype.getLayers=function(t){if(!t)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return t.layers.get(this.index)},xe.prototype.getSvgImage=function(t){if(!t)throw new Error("The font object is required to read the svg table in order to get the image.");return t.svgImages.get(this.index)},xe.prototype.getContours=function(t=null){if(this.points===void 0&&!t)return[];const e=[];let n=[],r=t||this.points;for(let s=0;s<r.length;s+=1){const i=r[s];n.push(i),i.lastPointOfContour&&(e.push(n),n=[])}return H.argument(n.length===0,"There are still points left in the current contour."),e},xe.prototype.getMetrics=function(){const t=this.path.commands,e=[],n=[];for(let s=0;s<t.length;s+=1){const i=t[s];i.type!=="Z"&&(e.push(i.x),n.push(i.y)),(i.type==="Q"||i.type==="C")&&(e.push(i.x1),n.push(i.y1)),i.type==="C"&&(e.push(i.x2),n.push(i.y2))}const r={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,n),leftSideBearing:this.leftSideBearing};return isFinite(r.xMin)||(r.xMin=0),isFinite(r.xMax)||(r.xMax=this.advanceWidth),isFinite(r.yMin)||(r.yMin=0),isFinite(r.yMax)||(r.yMax=0),r.rightSideBearing=this.advanceWidth-r.leftSideBearing-(r.xMax-r.xMin),r},xe.prototype.draw=function(t,e,n,r,s,i){s=Object.assign({},i&&i.defaultRenderOptions,s),this.getPath(e,n,r,s,i).draw(t)},xe.prototype.drawPoints=function(t,e,n,r,s,i){if(s=Object.assign({},i&&i.defaultRenderOptions,s),s.drawLayers){const f=this.getLayers(i);if(f&&f.length){for(let p=0;p<f.length;p+=1)f[p].glyph.index!==this.index&&this.drawPoints.call(f[p].glyph,t,e,n,r);return}}function a(f,p,y,m){t.beginPath();for(let b=0;b<f.length;b+=1)t.moveTo(p+f[b].x*m,y+f[b].y*m),t.arc(p+f[b].x*m,y+f[b].y*m,2,0,Math.PI*2,!1);t.fill()}e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24;const o=1/this.path.unitsPerEm*r,c=[],l=[];let h=this.path.commands;i&&i.variation&&(h=i.variation.getTransform(this,s.variation).path.commands);for(let f=0;f<h.length;f+=1){const p=h[f];p.x!==void 0&&c.push({x:p.x,y:-p.y}),p.x1!==void 0&&l.push({x:p.x1,y:-p.y1}),p.x2!==void 0&&l.push({x:p.x2,y:-p.y2})}t.fillStyle="blue",a(c,e,n,o),t.fillStyle="red",a(l,e,n,o)},xe.prototype.drawMetrics=function(t,e,n,r){let s;e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:24,s=1/this.path.unitsPerEm*r,t.lineWidth=1,t.strokeStyle="black",vt.line(t,e,-1e4,e,1e4),vt.line(t,-1e4,n,1e4,n);const i=this.xMin||0;let a=this.yMin||0;const o=this.xMax||0;let c=this.yMax||0;const l=this.advanceWidth||0;t.strokeStyle="blue",vt.line(t,e+i*s,-1e4,e+i*s,1e4),vt.line(t,e+o*s,-1e4,e+o*s,1e4),vt.line(t,-1e4,n+-a*s,1e4,n+-a*s),vt.line(t,-1e4,n+-c*s,1e4,n+-c*s),t.strokeStyle="green",vt.line(t,e+l*s,-1e4,e+l*s,1e4)},xe.prototype.toPathData=function(t,e){t=Object.assign({},{variation:e&&e.defaultRenderOptions.variation},t);let n=this;e&&e.variation&&(n=e.variation.getTransform(this,t.variation));let r=n.points&&t.pointsTransform?t.pointsTransform(n.points):n.path;return t.pathTransform&&(r=t.pathTransform(r)),r.toPathData(t)},xe.prototype.fromSVG=function(t,e={}){return this.path.fromSVG(t,e)},xe.prototype.toSVG=function(t,e){const n=this.toPathData.apply(this,[t,e]);return this.path.toSVG(t,n)},xe.prototype.toDOMElement=function(t,e){t=Object.assign({},{variation:e&&e.defaultRenderOptions.variation},t);let n=this.path;return e&&e.variation&&(n=e.variation.getTransform(this,t.variation).path),n.toDOMElement(t)};var Wt=xe;function It(t,e,n){Object.defineProperty(t,e,{get:function(){return typeof t[n]>"u"&&t.path,t[n]},set:function(r){t[n]=r},enumerable:!0,configurable:!0})}function Tn(t,e){if(this.font=t,this.glyphs={},Array.isArray(e))for(let n=0;n<e.length;n++){const r=e[n];r.path.unitsPerEm=t.unitsPerEm,this.glyphs[n]=r}this.length=e&&e.length||0}typeof Symbol<"u"&&Symbol.iterator&&(Tn.prototype[Symbol.iterator]=function(){let t=-1;return{next:(function(){t++;const e=t>=this.length-1;return{value:this.get(t),done:e}}).bind(this)}}),Tn.prototype.get=function(t){if(this.font._push&&this.glyphs[t]===void 0){this.font._push(t),typeof this.glyphs[t]=="function"&&(this.glyphs[t]=this.glyphs[t]());let e=this.glyphs[t],n=this.font._IndexToUnicodeMap[t];if(n)for(let r=0;r<n.unicodes.length;r++)e.addUnicode(n.unicodes[r]);this.font.cffEncoding?e.name=this.font.cffEncoding.charset[t]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(t)),this.glyphs[t].advanceWidth=this.font._hmtxTableData[t].advanceWidth,this.glyphs[t].leftSideBearing=this.font._hmtxTableData[t].leftSideBearing}else typeof this.glyphs[t]=="function"&&(this.glyphs[t]=this.glyphs[t]());return this.glyphs[t]},Tn.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function xc(t,e){return new Wt({index:e,font:t})}function vc(t,e,n,r,s,i){return function(){const a=new Wt({index:e,font:t});return a.path=function(){n(a,r,s);const o=i(t.glyphs,a);return o.unitsPerEm=t.unitsPerEm,o},It(a,"numberOfContours","_numberOfContours"),It(a,"xMin","_xMin"),It(a,"xMax","_xMax"),It(a,"yMin","_yMin"),It(a,"yMax","_yMax"),It(a,"points","_points"),a}}function Sc(t,e,n,r,s){return function(){const i=new Wt({index:e,font:t});return i.path=function(){const a=n(t,i,r,s);return a.unitsPerEm=t.unitsPerEm,a},i}}var Xe={GlyphSet:Tn,glyphLoader:xc,ttfGlyphLoader:vc,cffGlyphLoader:Sc};function Ys(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Ys(t[n],e[n]))return!1;return!0}else return!1}var Xs=10;function Cn(t){let e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function Ke(t,e,n,r){const s=[],i=[],a=r>1?_.getULong(t,e):_.getCard16(t,e),o=r>1?4:2;let c,l;if(a!==0){const u=_.getByte(t,e+o);c=e+(a+1)*u+o;let h=e+o+1;for(let f=0;f<a+1;f+=1)s.push(_.getOffset(t,h,u)),h+=u;l=c+s[a]}else l=e+o;for(let u=0;u<s.length-1;u+=1){let h=_.getBytes(t,c+s[u],c+s[u+1]);n&&(h=n(h,t,e,r)),i.push(h)}return{objects:i,startOffset:e,endOffset:l}}function wc(t,e,n){const r=[],s=n>1?_.getULong(t,e):_.getCard16(t,e),i=n>1?4:2;let a,o;if(s!==0){const c=_.getByte(t,e+i);a=e+(s+1)*c+i;let l=e+i+1;for(let u=0;u<s+1;u+=1)r.push(_.getOffset(t,l,c)),l+=c;o=a+r[s]}else o=e+i;return{offsets:r,startOffset:e,endOffset:o}}function Tc(t,e,n,r,s,i){const a=i>1?_.getULong(n,r):_.getCard16(n,r),o=i>1?4:2;let c=0;if(a!==0){const u=_.getByte(n,r+o);c=r+(a+1)*u+o}return _.getBytes(n,c+e[t],c+e[t+1])}function Cc(t){let e="";const r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=t.parseByte(),i=s>>4,a=s&15;if(i===15||(e+=r[i],a===15))break;e+=r[a]}return parseFloat(e)}function kc(t,e){let n,r,s,i;if(e===28)return n=t.parseByte(),r=t.parseByte(),n<<8|r;if(e===29)return n=t.parseByte(),r=t.parseByte(),s=t.parseByte(),i=t.parseByte(),n<<24|r<<16|s<<8|i;if(e===30)return Cc(t);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return n=t.parseByte(),(e-247)*256+n+108;if(e>=251&&e<=254)return n=t.parseByte(),-(e-251)*256-n-108;throw new Error("Invalid b0 "+e)}function Fc(t){const e={};for(let n=0;n<t.length;n+=1){const r=t[n][0],s=t[n][1];let i;if(s.length===1?i=s[0]:i=s,Object.prototype.hasOwnProperty.call(e,r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=i}return e}function mr(t,e,n,r){e=e!==void 0?e:0;const s=new _.Parser(t,e),i=[];let a=[];n=n!==void 0?n:t.byteLength;let o=r<2?22:28;for(;s.relativeOffset<n;){let c=s.parseByte();if(c<o){if(c===12&&(c=1200+s.parseByte()),r>1&&c===23){_c(a);continue}i.push([c,a]),a=[]}else a.push(kc(s,c))}return Fc(i)}function zt(t,e){return e<=390?e=Sn[e]:t?e=t[e-391]:e=void 0,e}function yr(t,e,n){const r={};let s;for(let i=0;i<e.length;i+=1){const a=e[i];if(Array.isArray(a.type)){const o=[];o.length=a.type.length;for(let c=0;c<a.type.length;c++)s=t[a.op]!==void 0?t[a.op][c]:void 0,s===void 0&&(s=a.value!==void 0&&a.value[c]!==void 0?a.value[c]:null),a.type[c]==="SID"&&(s=zt(n,s)),o[c]=s;r[a.name]=o}else s=t[a.op],s===void 0&&(s=a.value!==void 0?a.value:null),a.type==="SID"&&(s=zt(n,s)),r[a.name]=s}return r}function Ec(t,e){const n={};if(n.formatMajor=_.getCard8(t,e),n.formatMinor=_.getCard8(t,e+1),n.formatMajor>2)throw new Error(`Unsupported CFF table version ${n.formatMajor}.${n.formatMinor}`);return n.size=_.getCard8(t,e+2),n.formatMajor<2?(n.offsetSize=_.getCard8(t,e+3),n.startOffset=e,n.endOffset=e+4):(n.topDictLength=_.getCard16(t,e+3),n.endOffset=e+8),n}var Ks=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Ac=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],Zs=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Oc=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],Lc=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Ic(t,e,n,r){const s=mr(t,e,t.byteLength,r);return yr(s,r>1?Ac:Ks,n)}function br(t,e,n,r,s){const i=mr(t,e,n,s);return yr(i,s>1?Oc:Zs,r)}function Rc(t,e,n){const r=mr(t,e,void 0,n);return yr(r,Lc)}function Mc(t,e,n){const r=[];for(let s=0;s<n.length;s++){const i=new DataView(new Uint8Array(n[s]).buffer),a=Rc(i,0,2),o=a.private[0],c=a.private[1];if(o!==0&&c!==0){const l=br(t,c+e,o,[],2);if(l.subrs){const u=c+l.subrs,h=Ke(t,u+e,void 0,2);a._subrs=h.objects,a._subrsBias=Cn(a._subrs)}a._privateDict=l}r.push(a)}return r}function xr(t,e,n,r,s){const i=[];for(let a=0;a<n.length;a+=1){const o=new DataView(new Uint8Array(n[a]).buffer),c=Ic(o,0,r,s);c._subrs=[],c._subrsBias=0,c._defaultWidthX=0,c._nominalWidthX=0;const l=s<2?c.private[0]:0,u=s<2?c.private[1]:0;if(l!==0&&u!==0){const h=br(t,u+e,l,r,s);if(c._defaultWidthX=h.defaultWidthX,c._nominalWidthX=h.nominalWidthX,h.subrs!==0){const f=u+h.subrs,p=Ke(t,f+e,void 0,s);c._subrs=p.objects,c._subrsBias=Cn(c._subrs)}c._privateDict=h}i.push(c)}return i}function Dc(t,e,n,r,s){let i,a;const o=new _.Parser(t,e);n-=1;const c=[".notdef"],l=o.parseCard8();if(l===0)for(let u=0;u<n;u+=1)i=o.parseSID(),s?c.push(i):c.push(zt(r,i)||i);else if(l===1)for(;c.length<=n;){i=o.parseSID(),a=o.parseCard8();for(let u=0;u<=a;u+=1)s?c.push("cid"+("00000"+i).slice(-5)):c.push(zt(r,i)||i),i+=1}else if(l===2)for(;c.length<=n;){i=o.parseSID(),a=o.parseCard16();for(let u=0;u<=a;u+=1)s?c.push("cid"+("00000"+i).slice(-5)):c.push(zt(r,i)||i),i+=1}else throw new Error("Unknown charset format "+l);return c}function Bc(t,e){let n;const r={},s=new _.Parser(t,e),i=s.parseCard8();if(i===0){const a=s.parseCard8();for(let o=0;o<a;o+=1)n=s.parseCard8(),r[n]=o}else if(i===1){const a=s.parseCard8();n=1;for(let o=0;o<a;o+=1){const c=s.parseCard8(),l=s.parseCard8();for(let u=c;u<=c+l;u+=1)r[u]=n,n+=1}}else throw new Error("Unknown encoding format "+i);return r}function _c(t){let e=t.pop();for(;t.length>e;)t.pop()}function Js(t,e){const n=t.tables.cff&&t.tables.cff.topDict&&t.tables.cff.topDict.paintType||0;return n===2&&(e.fill=null,e.stroke="black",e.strokeWidth=t.tables.cff.topDict.strokeWidth||0),n}function vr(t,e,n,r,s){let i,a,o,c;const l=new Ft,u=[];let h=0,f=!1,p=!1,y=0,m=0,b,v,w,T,C=0,E=[],R,P=0;const V=t.tables.cff2||t.tables.cff;if(w=V.topDict._defaultWidthX,T=V.topDict._nominalWidthX,s=s||t.variation&&t.variation.get(),e.getBlendPath||(e.getBlendPath=function(B){return vr(t,e,n,r,B)}),t.isCIDFont||r>1){const B=V.topDict._fdSelect?V.topDict._fdSelect[e.index]:0,U=V.topDict._fdArray[B];b=U._subrs,v=U._subrsBias,r>1?(E=V.topDict._vstore.itemVariationStore,C=U._privateDict.vsindex):(w=U._defaultWidthX,T=U._nominalWidthX)}else b=V.topDict._subrs,v=V.topDict._subrsBias;const X=Js(t,l);let W=w;function $(B,U){p&&X!==2&&l.closePath(),l.moveTo(B,U),p=!0}function re(){let B;B=(u.length&1)!==0,B&&!f&&(W=u.shift()+T),h+=u.length>>1,u.length=0,f=!0}function N(B){let U,te,Ee,st,He,fe,K,ee,de,ve,ge,ye,ae=0;for(;ae<B.length;){let we=B[ae];switch(ae+=1,we){case 1:re();break;case 3:re();break;case 4:u.length>1&&!f&&(W=u.shift()+T,f=!0),m+=u.pop(),$(y,m);break;case 5:for(;u.length>0;)y+=u.shift(),m+=u.shift(),l.lineTo(y,m);break;case 6:for(;u.length>0&&(y+=u.shift(),l.lineTo(y,m),u.length!==0);)m+=u.shift(),l.lineTo(y,m);break;case 7:for(;u.length>0&&(m+=u.shift(),l.lineTo(y,m),u.length!==0);)y+=u.shift(),l.lineTo(y,m);break;case 8:for(;u.length>0;)i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+u.shift(),l.curveTo(i,a,o,c,y,m);break;case 10:if(He=u.pop()+v,fe=b[He],fe){if(P>=Xs){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}P++,N(fe),P--}break;case 11:if(r>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(we=B[ae],ae+=1,we){case 35:i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),K=o+u.shift(),ee=c+u.shift(),de=K+u.shift(),ve=ee+u.shift(),ge=de+u.shift(),ye=ve+u.shift(),y=ge+u.shift(),m=ye+u.shift(),u.shift(),l.curveTo(i,a,o,c,K,ee),l.curveTo(de,ve,ge,ye,y,m);break;case 34:i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),K=o+u.shift(),ee=c,de=K+u.shift(),ve=c,ge=de+u.shift(),ye=m,y=ge+u.shift(),l.curveTo(i,a,o,c,K,ee),l.curveTo(de,ve,ge,ye,y,m);break;case 36:i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),K=o+u.shift(),ee=c,de=K+u.shift(),ve=c,ge=de+u.shift(),ye=ve+u.shift(),y=ge+u.shift(),l.curveTo(i,a,o,c,K,ee),l.curveTo(de,ve,ge,ye,y,m);break;case 37:i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),K=o+u.shift(),ee=c+u.shift(),de=K+u.shift(),ve=ee+u.shift(),ge=de+u.shift(),ye=ve+u.shift(),Math.abs(ge-y)>Math.abs(ye-m)?y=ge+u.shift():m=ye+u.shift(),l.curveTo(i,a,o,c,K,ee),l.curveTo(de,ve,ge,ye,y,m);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+we),u.length=0}break;case 14:if(r>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const it=pr[u.pop()],x=pr[u.pop()],d=u.pop(),g=u.pop();if(it&&x){e.isComposite=!0,e.components=[];const S=t.cffEncoding.charset.indexOf(it),F=t.cffEncoding.charset.indexOf(x);e.components.push({glyphIndex:F,dx:0,dy:0}),e.components.push({glyphIndex:S,dx:g,dy:d}),l.extend(t.glyphs.get(F).path);const O=t.glyphs.get(S),I=JSON.parse(JSON.stringify(O.path.commands));for(let q=0;q<I.length;q+=1){const j=I[q];j.type!=="Z"&&(j.x+=g,j.y+=d),(j.type==="Q"||j.type==="C")&&(j.x1+=g,j.y1+=d),j.type==="C"&&(j.x2+=g,j.y2+=d)}l.extend(I)}}else u.length>0&&!f&&(W=u.shift()+T,f=!0);p&&X!==2&&(l.closePath(),p=!1);break;case 15:if(r<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}C=u.pop();break;case 16:if(r<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}R||(R=t.variation&&s&&t.variation.process.getBlendVector(E,C,s));var J=u.pop(),Se=R?R.length:E.itemVariationSubtables[C].regionIndexes.length,Ae=J*Se,Oe=u.length-Ae,Le=Oe-J;if(R)for(let it=0;it<J;it++){var Be=u[Le+it];for(let x=0;x<Se;x++)Be+=R[x]*u[Oe++];u[Le+it]=Be}for(;Ae--;)u.pop();break;case 18:re();break;case 19:case 20:re(),ae+=h+7>>3;break;case 21:u.length>2&&!f&&(W=u.shift()+T,f=!0),m+=u.pop(),y+=u.pop(),$(y,m);break;case 22:u.length>1&&!f&&(W=u.shift()+T,f=!0),y+=u.pop(),$(y,m);break;case 23:re();break;case 24:for(;u.length>2;)i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+u.shift(),l.curveTo(i,a,o,c,y,m);y+=u.shift(),m+=u.shift(),l.lineTo(y,m);break;case 25:for(;u.length>6;)y+=u.shift(),m+=u.shift(),l.lineTo(y,m);i=y+u.shift(),a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+u.shift(),l.curveTo(i,a,o,c,y,m);break;case 26:for(u.length&1&&(y+=u.shift());u.length>0;)i=y,a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o,m=c+u.shift(),l.curveTo(i,a,o,c,y,m);break;case 27:for(u.length&1&&(m+=u.shift());u.length>0;)i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c,l.curveTo(i,a,o,c,y,m);break;case 28:U=B[ae],te=B[ae+1],u.push((U<<24|te<<16)>>16),ae+=2;break;case 29:if(He=u.pop()+t.gsubrsBias,fe=t.gsubrs[He],fe){if(P>=Xs){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}P++,N(fe),P--}break;case 30:for(;u.length>0&&(i=y,a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m),u.length!==0);)i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),m=c+u.shift(),y=o+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m);break;case 31:for(;u.length>0&&(i=y+u.shift(),a=m,o=i+u.shift(),c=a+u.shift(),m=c+u.shift(),y=o+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m),u.length!==0);)i=y,a=m+u.shift(),o=i+u.shift(),c=a+u.shift(),y=o+u.shift(),m=c+(u.length===1?u.shift():0),l.curveTo(i,a,o,c,y,m);break;default:we<32?console.log("Glyph "+e.index+": unknown operator "+we):we<247?u.push(we-139):we<251?(U=B[ae],ae+=1,u.push((we-247)*256+U+108)):we<255?(U=B[ae],ae+=1,u.push(-(we-251)*256-U-108)):(U=B[ae],te=B[ae+1],Ee=B[ae+2],st=B[ae+3],ae+=4,u.push((U<<24|te<<16|Ee<<8|st)/65536))}}}return N(n),t.variation&&s&&(l.commands=l.commands.map(B=>{const U=Object.keys(B);for(let te=0;te<U.length;te++){const Ee=U[te];Ee!=="type"&&(B[Ee]=Math.round(B[Ee]))}return B})),f&&(e.advanceWidth=W),l}function Qs(t,e,n,r,s){const i=[];let a;const o=new _.Parser(t,e),c=o.parseCard8();if(c===0)for(let l=0;l<n;l++){if(a=o.parseCard8(),a>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+r+")");i.push(a)}else if(c===3||s>1&&c===4){const l=c===4?o.parseULong():o.parseCard16();let u=c===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${c} range has bad initial GID ${u}`);let h;for(let f=0;f<l;f++){if(a=c===4?o.parseUShort():o.parseCard8(),h=c===4?o.parseULong():o.parseCard16(),a>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+r+")");if(h>n)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${h}`);for(;u<h;u++)i.push(a);u=h}if(h!==n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+h)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+c);return i}function Uc(t,e,n,r){let s;const i=Ec(t,e);i.formatMajor===2?s=n.tables.cff2={}:s=n.tables.cff={};const a=i.formatMajor>1?null:Ke(t,i.endOffset,_.bytesToString),o=i.formatMajor>1?null:Ke(t,a.endOffset),c=i.formatMajor>1?null:Ke(t,o.endOffset,_.bytesToString),l=Ke(t,i.formatMajor>1?e+i.size+i.topDictLength:c.endOffset,void 0,i.formatMajor);n.gsubrs=l.objects,n.gsubrsBias=Cn(n.gsubrs);let u;if(i.formatMajor>1){const f=e+i.size,p=_.getBytes(t,f,f+i.topDictLength);u=xr(t,0,[p],void 0,i.formatMajor)[0]}else{const f=xr(t,e,o.objects,c.objects,i.formatMajor);if(f.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+f.length);u=f[0]}if(s.topDict=u,u._privateDict&&(n.defaultWidthX=u._privateDict.defaultWidthX,n.nominalWidthX=u._privateDict.nominalWidthX),i.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(n.isCIDFont=!0),i.formatMajor>1){let f=u.fdArray,p=u.fdSelect;if(!f)throw new Error("This is a CFF2 font, but FDArray information is missing");const y=Ke(t,e+f,null,i.formatMajor),m=Mc(t,e,y.objects);u._fdArray=m,p&&(u._fdSelect=Qs(t,e+p,n.numGlyphs,m.length,i.formatMajor))}else if(n.isCIDFont){let f=u.fdArray,p=u.fdSelect;if(f===0||p===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");f+=e;const y=Ke(t,f),m=xr(t,e,y.objects,c.objects,i.formatMajor);u._fdArray=m,p+=e,u._fdSelect=Qs(t,p,n.numGlyphs,m.length,i.formatMajor)}if(i.formatMajor<2){const f=e+u.private[1],p=br(t,f,u.private[0],c.objects,i.formatMajor);if(n.defaultWidthX=p.defaultWidthX,n.nominalWidthX=p.nominalWidthX,p.subrs!==0){const y=f+p.subrs,m=Ke(t,y);n.subrs=m.objects,n.subrsBias=Cn(n.subrs)}else n.subrs=[],n.subrsBias=0}let h;if(r.lowMemory?(h=wc(t,e+u.charStrings,i.formatMajor),n.nGlyphs=h.offsets.length-(i.formatMajor>1?1:0)):(h=Ke(t,e+u.charStrings,null,i.formatMajor),n.nGlyphs=h.objects.length),i.formatMajor>1&&n.tables.maxp&&n.nGlyphs!==n.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${n.nGlyphs}) must correspond to the glyph count in the maxp table (${n.tables.maxp.numGlyphs})`),i.formatMajor<2){let f=[],p=[];u.charset===0?f=ac:u.charset===1?f=oc:u.charset===2?f=cc:f=Dc(t,e+u.charset,n.nGlyphs,c.objects,n.isCIDFont),u.encoding===0?p=pr:u.encoding===1?p=lc:p=Bc(t,e+u.encoding),n.cffEncoding=new Vs(p,f),n.encoding=n.encoding||n.cffEncoding}if(n.glyphs=new Xe.GlyphSet(n),r.lowMemory)n._push=function(f){const p=Tc(f,h.offsets,t,e+u.charStrings,void 0,i.formatMajor);n.glyphs.push(f,Xe.cffGlyphLoader(n,f,vr,p,i.formatMajor))};else for(let f=0;f<n.nGlyphs;f+=1){const p=h.objects[f];n.glyphs.push(f,Xe.cffGlyphLoader(n,f,vr,p,i.formatMajor))}if(u.vstore){const f=new _.Parser(t,e+u.vstore);u._vstore=f.parseVariationStore()}}function ei(t,e){let n,r=Sn.indexOf(t);return r>=0&&(n=r),r=e.indexOf(t),r>=0?n=r+Sn.length:(n=Sn.length+e.length,e.push(t)),n}function Pc(){return new L.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Nc(t){const e=new L.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let n=0;n<t.length;n+=1)e.names.push({name:"name_"+n,type:"NAME",value:t[n]});return e}function ti(t,e,n){const r={};for(let s=0;s<t.length;s+=1){const i=t[s];let a=e[i.name];a!==void 0&&!Ys(a,i.value)&&(i.type==="SID"&&(a=ei(a,n)),r[i.op]={name:i.name,type:i.type,value:a})}return r}function ni(t,e,n){const r=new L.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=ti(Ks,t,e),r}function ri(t){const e=new L.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:t}],e}function Gc(t){const e=new L.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(let n=0;n<t.length;n+=1)e.strings.push({name:"string_"+n,type:"STRING",value:t[n]});return e}function Hc(){return new L.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Wc(t,e){const n=new L.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let r=0;r<t.length;r+=1){const s=t[r],i=ei(s,e);n.fields.push({name:"glyph_"+r,type:"SID",value:i})}return n}function zc(t,e){const n=[],r=t.path;n.push({name:"width",type:"NUMBER",value:t.advanceWidth});let s=0,i=0;for(let a=0;a<r.commands.length;a+=1){let o,c,l=r.commands[a];if(l.type==="Q"){const u=.3333333333333333,h=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(u*s+h*l.x1),y1:Math.round(u*i+h*l.y1),x2:Math.round(u*l.x+h*l.x1),y2:Math.round(u*l.y+h*l.y1)}}if(l.type==="M")o=Math.round(l.x-s),c=Math.round(l.y-i),n.push({name:"dx",type:"NUMBER",value:o}),n.push({name:"dy",type:"NUMBER",value:c}),n.push({name:"rmoveto",type:"OP",value:21}),s=Math.round(l.x),i=Math.round(l.y);else if(l.type==="L")o=Math.round(l.x-s),c=Math.round(l.y-i),n.push({name:"dx",type:"NUMBER",value:o}),n.push({name:"dy",type:"NUMBER",value:c}),n.push({name:"rlineto",type:"OP",value:5}),s=Math.round(l.x),i=Math.round(l.y);else if(l.type==="C"){const u=Math.round(l.x1-s),h=Math.round(l.y1-i),f=Math.round(l.x2-l.x1),p=Math.round(l.y2-l.y1);o=Math.round(l.x-l.x2),c=Math.round(l.y-l.y2),n.push({name:"dx1",type:"NUMBER",value:u}),n.push({name:"dy1",type:"NUMBER",value:h}),n.push({name:"dx2",type:"NUMBER",value:f}),n.push({name:"dy2",type:"NUMBER",value:p}),n.push({name:"dx",type:"NUMBER",value:o}),n.push({name:"dy",type:"NUMBER",value:c}),n.push({name:"rrcurveto",type:"OP",value:8}),s=Math.round(l.x),i=Math.round(l.y)}}return n.push({name:"endchar",type:"OP",value:14}),n}function Vc(t,e){const n=new L.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let r=0;r<t.length;r+=1){const s=t.get(r),i=zc(s);n.charStrings.push({name:s.name,type:"CHARSTRING",value:i})}return n}function jc(t,e,n){const r=new L.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=ti(Zs,t,e),r}function qc(t,e){const n=new L.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i=e&&e.topDict||{};i.paintType&&(s.paintType=i.paintType,s.strokeWidth=i.strokeWidth||0);const a={},o=[];let c;for(let f=1;f<t.length;f+=1)c=t.get(f),o.push(c.name);const l=[];n.header=Pc(),n.nameIndex=Nc([e.postScriptName]);let u=ni(s,l);n.topDictIndex=ri(u),n.globalSubrIndex=Hc(),n.charsets=Wc(o,l),n.charStringsIndex=Vc(t),n.privateDict=jc(a,l),n.stringIndex=Gc(l);const h=n.header.sizeOf()+n.nameIndex.sizeOf()+n.topDictIndex.sizeOf()+n.stringIndex.sizeOf()+n.globalSubrIndex.sizeOf();return s.charset=h,s.encoding=0,s.charStrings=s.charset+n.charsets.sizeOf(),s.private[1]=s.charStrings+n.charStringsIndex.sizeOf(),u=ni(s,l),n.topDictIndex=ri(u),n}var Sr={parse:Uc,make:qc};function $c(t,e){const n={},r=new _.Parser(t,e);return n.version=r.parseVersion(),n.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,n.checkSumAdjustment=r.parseULong(),n.magicNumber=r.parseULong(),H.argument(n.magicNumber===1594834165,"Font header has wrong magic number."),n.flags=r.parseUShort(),n.unitsPerEm=r.parseUShort(),n.created=r.parseLongDateTime(),n.modified=r.parseLongDateTime(),n.xMin=r.parseShort(),n.yMin=r.parseShort(),n.xMax=r.parseShort(),n.yMax=r.parseShort(),n.macStyle=r.parseUShort(),n.lowestRecPPEM=r.parseUShort(),n.fontDirectionHint=r.parseShort(),n.indexToLocFormat=r.parseShort(),n.glyphDataFormat=r.parseShort(),n}function Yc(t){const e=Math.round(new Date().getTime()/1e3)+2082844800;let n=e,r=t.macStyle||0;return t.createdTimestamp&&(n=t.createdTimestamp+2082844800),new L.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:n},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:r},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],t)}var si={parse:$c,make:Yc};function Xc(t,e){const n={},r=new _.Parser(t,e);return n.version=r.parseVersion(),n.ascender=r.parseShort(),n.descender=r.parseShort(),n.lineGap=r.parseShort(),n.advanceWidthMax=r.parseUShort(),n.minLeftSideBearing=r.parseShort(),n.minRightSideBearing=r.parseShort(),n.xMaxExtent=r.parseShort(),n.caretSlopeRise=r.parseShort(),n.caretSlopeRun=r.parseShort(),n.caretOffset=r.parseShort(),r.relativeOffset+=8,n.metricDataFormat=r.parseShort(),n.numberOfHMetrics=r.parseUShort(),n}function Kc(t){return new L.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],t)}var ii={parse:Xc,make:Kc};function Zc(t,e,n,r,s){let i,a;const o=new _.Parser(t,e);for(let c=0;c<r;c+=1){c<n&&(i=o.parseUShort(),a=o.parseShort());const l=s.get(c);l.advanceWidth=i,l.leftSideBearing=a}}function Jc(t,e,n,r,s){t._hmtxTableData={};let i,a;const o=new _.Parser(e,n);for(let c=0;c<s;c+=1)c<r&&(i=o.parseUShort(),a=o.parseShort()),t._hmtxTableData[c]={advanceWidth:i,leftSideBearing:a}}function Qc(t,e,n,r,s,i,a){a.lowMemory?Jc(t,e,n,r,s):Zc(e,n,r,s,i)}function el(t){const e=new L.Table("hmtx",[]);for(let n=0;n<t.length;n+=1){const r=t.get(n),s=r.advanceWidth||0,i=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+n,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+n,type:"SHORT",value:i})}return e}var ai={parse:Qc,make:el};function tl(t){const e=new L.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:t.length}]);let n="";const r=12+t.length*4;for(let s=0;s<t.length;++s){let i=n.indexOf(t[s]);i<0&&(i=n.length,n+=t[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:r+i}),e.fields.push({name:"length "+s,type:"USHORT",value:t[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),e}function nl(t,e){const n=new _.Parser(t,e),r=n.parseULong();H.argument(r===1,"Unsupported ltag table version."),n.skip("uLong",1);const s=n.parseULong(),i=[];for(let a=0;a<s;a++){let o="";const c=e+n.parseUShort(),l=n.parseUShort();for(let u=c;u<c+l;++u)o+=String.fromCharCode(t.getInt8(u));i.push(o)}return i}var oi={make:tl,parse:nl};function rl(t,e){const n={},r=new _.Parser(t,e);return n.version=r.parseVersion(),n.numGlyphs=r.parseUShort(),n.version===1&&(n.maxPoints=r.parseUShort(),n.maxContours=r.parseUShort(),n.maxCompositePoints=r.parseUShort(),n.maxCompositeContours=r.parseUShort(),n.maxZones=r.parseUShort(),n.maxTwilightPoints=r.parseUShort(),n.maxStorage=r.parseUShort(),n.maxFunctionDefs=r.parseUShort(),n.maxInstructionDefs=r.parseUShort(),n.maxStackElements=r.parseUShort(),n.maxSizeOfInstructions=r.parseUShort(),n.maxComponentElements=r.parseUShort(),n.maxComponentDepth=r.parseUShort()),n}function sl(t){return new L.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var ci={parse:rl,make:sl},wr=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function il(t){for(let e=0;e<wr.length;e+=1){const n=wr[e];if(t>=n.begin&&t<n.end)return e}return-1}function al(t,e){const n={},r=new _.Parser(t,e);n.version=r.parseUShort(),n.xAvgCharWidth=r.parseShort(),n.usWeightClass=r.parseUShort(),n.usWidthClass=r.parseUShort(),n.fsType=r.parseUShort(),n.ySubscriptXSize=r.parseShort(),n.ySubscriptYSize=r.parseShort(),n.ySubscriptXOffset=r.parseShort(),n.ySubscriptYOffset=r.parseShort(),n.ySuperscriptXSize=r.parseShort(),n.ySuperscriptYSize=r.parseShort(),n.ySuperscriptXOffset=r.parseShort(),n.ySuperscriptYOffset=r.parseShort(),n.yStrikeoutSize=r.parseShort(),n.yStrikeoutPosition=r.parseShort(),n.sFamilyClass=r.parseShort(),n.panose=[];for(let s=0;s<10;s++)n.panose[s]=r.parseByte();return n.ulUnicodeRange1=r.parseULong(),n.ulUnicodeRange2=r.parseULong(),n.ulUnicodeRange3=r.parseULong(),n.ulUnicodeRange4=r.parseULong(),n.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),n.fsSelection=r.parseUShort(),n.usFirstCharIndex=r.parseUShort(),n.usLastCharIndex=r.parseUShort(),n.sTypoAscender=r.parseShort(),n.sTypoDescender=r.parseShort(),n.sTypoLineGap=r.parseShort(),n.usWinAscent=r.parseUShort(),n.usWinDescent=r.parseUShort(),n.version>=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n}function ol(t){return new L.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],t)}var Tr={parse:al,make:ol,unicodeRanges:wr,getUnicodeRange:il};function cl(t,e){const n={},r=new _.Parser(t,e);switch(n.version=r.parseVersion(),n.italicAngle=r.parseFixed(),n.underlinePosition=r.parseShort(),n.underlineThickness=r.parseShort(),n.isFixedPitch=r.parseULong(),n.minMemType42=r.parseULong(),n.maxMemType42=r.parseULong(),n.minMemType1=r.parseULong(),n.maxMemType1=r.parseULong(),n.version){case 1:n.names=xt.slice();break;case 2:n.numberOfGlyphs=r.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(let s=0;s<n.numberOfGlyphs;s++)n.glyphNameIndex[s]=r.parseUShort();n.names=[];for(let s=0;s<n.numberOfGlyphs;s++)if(n.glyphNameIndex[s]>=xt.length){const i=r.parseChar();n.names.push(r.parseString(i))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(let s=0;s<n.numberOfGlyphs;s++)n.offset[s]=r.parseChar();break}return n}function ll(t){const{italicAngle:e=Math.round((t.italicAngle||0)*65536),underlinePosition:n=0,underlineThickness:r=0,isFixedPitch:s=0,minMemType42:i=0,maxMemType42:a=0,minMemType1:o=0,maxMemType1:c=0}=t.tables.post||{};return new L.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:e},{name:"underlinePosition",type:"FWORD",value:n},{name:"underlineThickness",type:"FWORD",value:r},{name:"isFixedPitch",type:"ULONG",value:s},{name:"minMemType42",type:"ULONG",value:i},{name:"maxMemType42",type:"ULONG",value:a},{name:"minMemType1",type:"ULONG",value:o},{name:"maxMemType1",type:"ULONG",value:c}])}var li={parse:cl,make:ll},Ve=new Array(9);Ve[1]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(k.coverage),deltaGlyphId:this.parseShort()};if(n===2)return{substFormat:2,coverage:this.parsePointer(k.coverage),substitute:this.parseOffset16List()};H.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},Ve[2]=function(){const e=this.parseUShort();return H.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),sequences:this.parseListOfLists()}},Ve[3]=function(){const e=this.parseUShort();return H.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),alternateSets:this.parseListOfLists()}},Ve[4]=function(){const e=this.parseUShort();return H.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Rt={sequenceIndex:k.uShort,lookupListIndex:k.uShort};Ve[5]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:n,coverage:this.parsePointer(k.coverage),ruleSets:this.parseListOfLists(function(){const r=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,Rt)}})};if(n===2)return{substFormat:n,coverage:this.parsePointer(k.coverage),classDef:this.parsePointer(k.classDef),classSets:this.parseListOfLists(function(){const r=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,Rt)}})};if(n===3){const r=this.parseUShort(),s=this.parseUShort();return{substFormat:n,coverages:this.parseList(r,k.pointer(k.coverage)),lookupRecords:this.parseRecordList(s,Rt)}}H.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Ve[6]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{substFormat:1,coverage:this.parsePointer(k.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Rt)}})};if(n===2)return{substFormat:2,coverage:this.parsePointer(k.coverage),backtrackClassDef:this.parsePointer(k.classDef),inputClassDef:this.parsePointer(k.classDef),lookaheadClassDef:this.parsePointer(k.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Rt)}})};if(n===3)return{substFormat:3,backtrackCoverage:this.parseList(k.pointer(k.coverage)),inputCoverage:this.parseList(k.pointer(k.coverage)),lookaheadCoverage:this.parseList(k.pointer(k.coverage)),lookupRecords:this.parseRecordList(Rt)};H.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Ve[7]=function(){const e=this.parseUShort();H.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");const n=this.parseUShort(),r=new k(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:n,extension:Ve[n].call(r)}},Ve[8]=function(){const e=this.parseUShort();return H.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(k.coverage),backtrackCoverage:this.parseList(k.pointer(k.coverage)),lookaheadCoverage:this.parseList(k.pointer(k.coverage)),substitutes:this.parseUShortList()}};function ul(t,e){e=e||0;const n=new k(t,e),r=n.parseVersion(1);return H.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Ve)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Ve),variations:n.parseFeatureVariationsList()}}var St=new Array(9);St[1]=function(e){if(e.substFormat===1)return new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)},{name:"deltaGlyphID",type:"SHORT",value:e.deltaGlyphId}]);if(e.substFormat===2)return new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.ushortList("substitute",e.substitute)));H.fail("Lookup type 1 substFormat must be 1 or 2.")},St[2]=function(e){return H.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("seqSet",e.sequences,function(n){return new L.Table("sequenceSetTable",L.ushortList("sequence",n))})))},St[3]=function(e){return H.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("altSet",e.alternateSets,function(n){return new L.Table("alternateSetTable",L.ushortList("alternate",n))})))},St[4]=function(e){return H.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new L.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("ligSet",e.ligatureSets,function(n){return new L.Table("ligatureSetTable",L.tableList("ligature",n,function(r){return new L.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:r.ligGlyph}].concat(L.ushortList("component",r.components,r.components.length+1)))}))})))},St[5]=function(e){if(e.substFormat===1)return new L.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("sequenceRuleSet",e.ruleSets,function(n){return n?new L.Table("sequenceRuleSetTable",L.tableList("sequenceRule",n,function(r){let s=L.ushortList("seqLookup",[],r.lookupRecords.length).concat(L.ushortList("inputSequence",r.input,r.input.length+1));[s[0],s[1]]=[s[1],s[0]];for(let i=0;i<r.lookupRecords.length;i++){const a=r.lookupRecords[i];s=s.concat({name:"sequenceIndex"+i,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:a.lookupListIndex})}return new L.Table("sequenceRuleTable",s)})):new L.Table("NULL",null)})));if(e.substFormat===2)return new L.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)},{name:"classDef",type:"TABLE",value:new L.ClassDef(e.classDef)}].concat(L.tableList("classSeqRuleSet",e.classSets,function(n){return n?new L.Table("classSeqRuleSetTable",L.tableList("classSeqRule",n,function(r){let s=L.ushortList("classes",r.classes,r.classes.length+1).concat(L.ushortList("seqLookupCount",[],r.lookupRecords.length));for(let i=0;i<r.lookupRecords.length;i++){const a=r.lookupRecords[i];s=s.concat({name:"sequenceIndex"+i,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:a.lookupListIndex})}return new L.Table("classSeqRuleTable",s)})):new L.Table("NULL",null)})));if(e.substFormat===3){let n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"inputGlyphCount",type:"USHORT",value:e.coverages.length}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length});for(let s=0;s<e.coverages.length;s++){const i=e.coverages[s];n.push({name:"inputCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}for(let s=0;s<e.lookupRecords.length;s++){const i=e.lookupRecords[s];n=n.concat({name:"sequenceIndex"+s,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:i.lookupListIndex})}return new L.Table("contextualSubstitutionTable",n)}H.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},St[6]=function(e){if(e.substFormat===1)return new L.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new L.Coverage(e.coverage)}].concat(L.tableList("chainRuleSet",e.chainRuleSets,function(r){return new L.Table("chainRuleSetTable",L.tableList("chainRule",r,function(s){let i=L.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(L.ushortList("inputGlyph",s.input,s.input.length+1)).concat(L.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(L.ushortList("substitution",[],s.lookupRecords.length));for(let a=0;a<s.lookupRecords.length;a++){const o=s.lookupRecords[a];i=i.concat({name:"sequenceIndex"+a,type:"USHORT",value:o.sequenceIndex}).concat({name:"lookupListIndex"+a,type:"USHORT",value:o.lookupListIndex})}return new L.Table("chainRuleTable",i)}))})));if(e.substFormat===2)H.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){let n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length});for(let s=0;s<e.backtrackCoverage.length;s++){const i=e.backtrackCoverage[s];n.push({name:"backtrackCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length});for(let s=0;s<e.inputCoverage.length;s++){const i=e.inputCoverage[s];n.push({name:"inputCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length});for(let s=0;s<e.lookaheadCoverage.length;s++){const i=e.lookaheadCoverage[s];n.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new L.Coverage(i)})}n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length});for(let s=0;s<e.lookupRecords.length;s++){const i=e.lookupRecords[s];n=n.concat({name:"sequenceIndex"+s,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:i.lookupListIndex})}return new L.Table("chainContextTable",n)}H.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function hl(t){return new L.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new L.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new L.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new L.LookupList(t.lookups,St)}])}var ui={parse:ul,make:hl};function fl(t,e){const n=new _.Parser(t,e),r=n.parseULong();H.argument(r===1,"Unsupported META table version."),n.parseULong(),n.parseULong();const s=n.parseULong(),i={};for(let a=0;a<s;a++){const o=n.parseTag(),c=n.parseULong(),l=n.parseULong();if(o==="appl"||o==="bild")continue;const u=Et.UTF8(t,e+c,l);i[o]=u}return i}function pl(t){const e=Object.keys(t).length;let n="";const r=16+e*12,s=new L.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(let i in t){const a=n.length;n+=t[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:r+a}),s.fields.push({name:"length "+i,type:"ULONG",value:t[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),s}var hi={parse:fl,make:pl};function dl(t,e){const n=new k(t,e),r=n.parseUShort();r!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");const s=n.parseUShort(),i=n.parseOffset32(),a=n.parseOffset32(),o=n.parseUShort();n.relativeOffset=i;const c=n.parseRecordList(s,{glyphID:k.uShort,firstLayerIndex:k.uShort,numLayers:k.uShort});n.relativeOffset=a;const l=n.parseRecordList(o,{glyphID:k.uShort,paletteIndex:k.uShort});return{version:r,baseGlyphRecords:c,layerRecords:l}}function gl({version:t=0,baseGlyphRecords:e=[],layerRecords:n=[]}){H.argument(t===0,"Only COLRv0 supported.");const r=14,s=r+e.length*6;return new L.Table("COLR",[{name:"version",type:"USHORT",value:t},{name:"numBaseGlyphRecords",type:"USHORT",value:e.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:r},{name:"layerRecordsOffset",type:"ULONG",value:s},{name:"numLayerRecords",type:"USHORT",value:n.length},...e.map((i,a)=>[{name:"glyphID_"+a,type:"USHORT",value:i.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:i.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:i.numLayers}]).flat(),...n.map((i,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:i.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:i.paletteIndex}]).flat()])}var fi={parse:dl,make:gl};function ml(t,e){return[{name:"tag_"+t,type:"TAG",value:e.tag},{name:"minValue_"+t,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+t,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+t,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+t,type:"USHORT",value:0},{name:"nameID_"+t,type:"USHORT",value:e.axisNameID}]}function yl(t,e,n){const r={},s=new _.Parser(t,e);r.tag=s.parseTag(),r.minValue=s.parseFixed(),r.defaultValue=s.parseFixed(),r.maxValue=s.parseFixed(),s.skip("uShort",1);const i=s.parseUShort();return r.axisNameID=i,r.name=vn(n,i),r}function bl(t,e,n,r={}){const s=[{name:"nameID_"+t,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+t,type:"USHORT",value:0}];for(let i=0;i<n.length;++i){const a=n[i].tag;s.push({name:"axis_"+t+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return r&&r.postScriptNameID&&s.push({name:"postScriptNameID_",type:"USHORT",value:e.postScriptNameID!==void 0?e.postScriptNameID:65535}),s}function xl(t,e,n,r,s){const i={},a=new _.Parser(t,e),o=a.parseUShort();i.subfamilyNameID=o,i.name=vn(r,o,[2,17]),a.skip("uShort",1),i.coordinates={};for(let l=0;l<n.length;++l)i.coordinates[n[l].tag]=a.parseFixed();if(a.relativeOffset===s)return i.postScriptNameID=void 0,i.postScriptName=void 0,i;const c=a.parseUShort();return i.postScriptNameID=c==65535?void 0:c,i.postScriptName=i.postScriptNameID!==void 0?vn(r,c,[6]):"",i}function vl(t,e){const n=new L.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:t.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:t.instances.length},{name:"instanceSize",type:"USHORT",value:4+t.axes.length*4}]);n.offsetToData=n.sizeOf();for(let s=0;s<t.axes.length;s++)n.fields=n.fields.concat(ml(s,t.axes[s]));const r={};for(let s=0;s<t.instances.length;s++)if(t.instances[s].postScriptNameID!==void 0){n.instanceSize+=2,r.postScriptNameID=!0;break}for(let s=0;s<t.instances.length;s++)n.fields=n.fields.concat(bl(s,t.instances[s],t.axes,r));return n}function Sl(t,e,n){const r=new _.Parser(t,e),s=r.parseULong();H.argument(s===65536,"Unsupported fvar table version.");const i=r.parseOffset16();r.skip("uShort",1);const a=r.parseUShort(),o=r.parseUShort(),c=r.parseUShort(),l=r.parseUShort(),u=[];for(let p=0;p<a;p++)u.push(yl(t,e+i+p*o,n));const h=[],f=e+i+a*o;for(let p=0;p<c;p++)h.push(xl(t,f+p*l,u,n,l));return{axes:u,instances:h}}var pi={make:vl,parse:Sl},wl={tag:k.tag,nameID:k.uShort,ordering:k.uShort},Vt=new Array(5);Vt[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},Vt[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},Vt[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},Vt[4]=function(){const e=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(e,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function Tl(){const t=this.parseUShort(),e=Vt[t],n={format:t};return e===void 0?(console.warn(`Unknown axis value table format ${t}`),n):Object.assign(n,this.parseStruct(e.bind(this)))}function Cl(t,e,n){e||(e=0);const r=new _.Parser(t,e),s=r.parseUShort(),i=r.parseUShort();s!==1&&console.warn(`Unsupported STAT table version ${s}.${i}`);const a=[s,i],o=r.parseUShort(),c=r.parseUShort(),l=r.parseOffset32(),u=r.parseUShort(),h=r.parseOffset32(),f=s>1||i>0?r.parseUShort():void 0;n!==void 0&&H.argument(c>=n.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&H.argument(c>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const p=[];for(let b=0;b<c;b++)r.offset=e+l,r.relativeOffset=b*o,p.push(r.parseStruct(wl));r.offset=e,r.relativeOffset=h;const y=r.parseUShortList(u),m=[];for(let b=0;b<u;b++)r.offset=e+h,r.relativeOffset=y[b],m.push(Tl.apply(r));return{version:a,axes:p,values:m,elidedFallbackNameID:f}}var jt=new Array(5);jt[1]=function(e,n){return[{name:`format${e}`,type:"USHORT",value:1},{name:`axisIndex${e}`,type:"USHORT",value:n.axisIndex},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID},{name:`value${e}`,type:"FLOAT",value:n.value}]},jt[2]=function(e,n){return[{name:`format${e}`,type:"USHORT",value:2},{name:`axisIndex${e}`,type:"USHORT",value:n.axisIndex},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID},{name:`nominalValue${e}`,type:"FLOAT",value:n.nominalValue},{name:`rangeMinValue${e}`,type:"FLOAT",value:n.rangeMinValue},{name:`rangeMaxValue${e}`,type:"FLOAT",value:n.rangeMaxValue}]},jt[3]=function(e,n){return[{name:`format${e}`,type:"USHORT",value:3},{name:`axisIndex${e}`,type:"USHORT",value:n.axisIndex},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID},{name:`value${e}`,type:"FLOAT",value:n.value},{name:`linkedValue${e}`,type:"FLOAT",value:n.linkedValue}]},jt[4]=function(e,n){let r=[{name:`format${e}`,type:"USHORT",value:4},{name:`axisCount${e}`,type:"USHORT",value:n.axisValues.length},{name:`flags${e}`,type:"USHORT",value:n.flags},{name:`valueNameID${e}`,type:"USHORT",value:n.valueNameID}];for(let s=0;s<n.axisValues.length;s++)r=r.concat([{name:`format${e}axisIndex${s}`,type:"USHORT",value:n.axisValues[s].axisIndex},{name:`format${e}value${s}`,type:"FLOAT",value:n.axisValues[s].value}]);return r};function kl(t,e){return new L.Record("axisRecord_"+t,[{name:"axisTag_"+t,type:"TAG",value:e.tag},{name:"axisNameID_"+t,type:"USHORT",value:e.nameID},{name:"axisOrdering_"+t,type:"USHORT",value:e.ordering}])}function Fl(t,e){const n=e.format,r=jt[n];H.argument(r!==void 0,`Unknown axis value table format ${n}`);const s=r(t,e);return new L.Table("axisValueTable_"+t,s)}function El(t){const e=new L.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:t.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:t.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:t.elidedFallbackNameID}]);e.designAxesOffset=e.offsetToAxisValueOffsets=e.sizeOf();for(let i=0;i<t.axes.length;i++){const a=kl(i,t.axes[i]);e.offsetToAxisValueOffsets+=a.sizeOf(),e.fields=e.fields.concat(a.fields)}const n=[];let r=[],s=t.values.length*2;for(let i=0;i<t.values.length;i++){const a=Fl(i,t.values[i]);n.push({name:"offset_"+i,type:"USHORT",value:s}),s+=a.sizeOf(),r=r.concat(a.fields)}return e.fields=e.fields.concat(n),e.fields=e.fields.concat(r),e}var di={make:El,parse:Cl};function Al(t,e){return new L.Record("axisValueMap_"+t,[{name:"fromCoordinate_"+t,type:"F2DOT14",value:e.fromCoordinate},{name:"toCoordinate_"+t,type:"F2DOT14",value:e.toCoordinate}])}function Ol(t,e){const n=new L.Record("segmentMap_"+t,[{name:"positionMapCount_"+t,type:"USHORT",value:e.axisValueMaps.length}]);let r=[];for(let s=0;s<e.axisValueMaps.length;s++){const i=Al(`${t}_${s}`,e.axisValueMaps[s]);r=r.concat(i.fields)}return n.fields=n.fields.concat(r),n}function Ll(t,e){H.argument(t.axisSegmentMaps.length===e.axes.length,"avar axis count must correspond to fvar axis count");const n=new L.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:t.axisSegmentMaps.length}]);for(let r=0;r<t.axisSegmentMaps.length;r++){const s=Ol(r,t.axisSegmentMaps[r]);n.fields=n.fields.concat(s.fields)}return n}function Il(t,e,n){e||(e=0);const r=new k(t,e),s=r.parseUShort(),i=r.parseUShort();s!==1&&console.warn(`Unsupported avar table version ${s}.${i}`),r.skip("uShort",1);const a=r.parseUShort();H.argument(a===n.axes.length,"avar axis count must correspond to fvar axis count");const o=[];for(let c=0;c<a;c++){const l=[],u=r.parseUShort();for(let h=0;h<u;h++){const f=r.parseF2Dot14(),p=r.parseF2Dot14();l.push({fromCoordinate:f,toCoordinate:p})}o.push({axisValueMaps:l})}return{version:[s,i],axisSegmentMaps:o}}var gi={make:Ll,parse:Il};function Rl(t,e,n,r){const s=new _.Parser(t,e),i=s.parseTupleVariationStore(s.relativeOffset,n.axes.length,"cvar",r),a=s.parseUShort(),o=s.parseUShort();return a!==1&&console.warn(`Unsupported cvar table version ${a}.${o}`),{version:[a,o],...i}}function Ml(){console.warn("Writing of cvar tables is not yet supported.")}var mi={make:Ml,parse:Rl};function Dl(t,e,n,r){const s=new _.Parser(t,e),i=s.parseUShort(),a=s.parseUShort();i!==1&&console.warn(`Unsupported gvar table version ${i}.${a}`);const o=s.parseUShort();o!==n.axes.length&&console.warn(`axisCount ${o} in gvar table does not match the number of axes ${n.axes.length} in the fvar table!`);const c=s.parseUShort(),l=s.parsePointer32(function(){return this.parseTupleRecords(c,o)}),u=s.parseTupleVariationStoreList(o,"gvar",r);return{version:[i,a],sharedTuples:l,glyphVariations:u}}function Bl(){console.warn("Writing of gvar tables is not yet supported.")}var yi={make:Bl,parse:Dl};function _l(t,e){const n={},r=new _.Parser(t,e);n.version=r.parseUShort(),H.argument(n.version<=1,"Unsupported gasp table version."),n.numRanges=r.parseUShort(),n.gaspRanges=[];for(let s=0;s<n.numRanges;s++)n.gaspRanges[s]={rangeMaxPPEM:r.parseUShort(),rangeGaspBehavior:r.parseUShort()};return n}function Ul(t){const e=new L.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:t.numRanges}]);for(let n in t.gaspRanges)e.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:t.gaspRanges[n].rangeMaxPPEM}),e.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:t.gaspRanges[n].rangeGaspBehavior});return e}var bi={parse:_l,make:Ul};function Pl(t,e){const n=new Map,r=t.buffer,s=new k(t,e);if(s.parseUShort()!==0)return n;s.relativeOffset=s.parseOffset32();const a=t.byteOffset+e+s.relativeOffset,o=s.parseUShort(),c=new Map;for(let l=0;l<o;l++){const u=s.parseUShort(),h=s.parseUShort(),f=a+s.parseOffset32(),p=s.parseULong();let y=c.get(f);y===void 0&&(y=new Uint8Array(r,f,p),c.set(f,y));for(let m=u;m<=h;m++)n.set(m,y)}return n}function Nl(t){const e=Array.from(t.keys()).sort(),n=[],r=[],s=new Map;let i=0,a={endGlyphID:null};for(let f=0,p=e.length;f<p;f++){const y=e[f],m=t.get(y);let b=s.get(m);b===void 0&&(b=i,r.push(m),s.set(m,b),i+=m.byteLength),y-1===a.endGlyphID&&b===a.svgDocOffset?a.endGlyphID=y:(a={startGlyphID:y,endGlyphID:y,svgDocOffset:b,svgDocLength:m.byteLength},n.push(a))}const o=n.length,c=r.length,l=2+o*12,u=new Array(4+o*4+c);let h=0;u[h++]={name:"version",type:"USHORT",value:0},u[h++]={name:"svgDocumentListOffset",type:"ULONG",value:10},u[h++]={name:"reserved",type:"ULONG",value:0},u[h++]={name:"numEntries",type:"USHORT",value:o};for(let f=0;f<o;f++){const p="documentRecord_"+f,{startGlyphID:y,endGlyphID:m,svgDocOffset:b,svgDocLength:v}=n[f];u[h++]={name:p+"_startGlyphID",type:"USHORT",value:y},u[h++]={name:p+"_endGlyphID",type:"USHORT",value:m},u[h++]={name:p+"_svgDocOffset",type:"ULONG",value:l+b},u[h++]={name:p+"_svgDocLength",type:"ULONG",value:v}}for(let f=0;f<c;f++)u[h++]={name:"svgDoc_"+f,type:"LITERAL",value:r[f]};return new L.Table("SVG ",u)}var xi={make:Nl,parse:Pl};function vi(t){return Math.log(t)/Math.log(2)|0}function Cr(t){for(;t.length%4!==0;)t.push(0);let e=0;for(let n=0;n<t.length;n+=4)e+=(t[n]<<24)+(t[n+1]<<16)+(t[n+2]<<8)+t[n+3];return e%=Math.pow(2,32),e}function Si(t,e,n,r){return new L.Record("Table Record",[{name:"tag",type:"TAG",value:t!==void 0?t:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:n!==void 0?n:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function wi(t){const e=new L.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=t,e.numTables=t.length;const n=Math.pow(2,vi(e.numTables));e.searchRange=16*n,e.entrySelector=vi(n),e.rangeShift=e.numTables*16-e.searchRange;const r=[],s=[];let i=e.sizeOf()+Si().sizeOf()*e.numTables;for(;i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0});for(let a=0;a<t.length;a+=1){const o=t[a];H.argument(o.tableName.length===4,"Table name"+o.tableName+" is invalid.");const c=o.sizeOf(),l=Si(o.tableName,Cr(o.encode()),i,c);for(r.push({name:l.tag+" Table Record",type:"RECORD",value:l}),s.push({name:o.tableName+" table",type:"RECORD",value:o}),i+=c,H.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(a,o){return a.value.tag>o.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(s),e}function Ti(t,e,n){for(let r=0;r<e.length;r+=1){const s=t.charToGlyphIndex(e[r]);if(s>0)return t.glyphs.get(s).getMetrics()}return n}function Gl(t){let e=0;for(let n=0;n<t.length;n+=1)e+=t[n];return e/t.length}function Hl(t){const e=[],n=[],r=[],s=[],i=[],a=[],o=[];let c,l=0,u=0,h=0,f=0,p=0;for(let J=0;J<t.glyphs.length;J+=1){const Se=t.glyphs.get(J),Ae=Se.unicode|0;if(isNaN(Se.advanceWidth))throw new Error("Glyph "+Se.name+" ("+J+"): advanceWidth is not a number.");(c>Ae||c===void 0)&&Ae>0&&(c=Ae),l<Ae&&(l=Ae);const Oe=Tr.getUnicodeRange(Ae);if(Oe<32)u|=1<<Oe;else if(Oe<64)h|=1<<Oe-32;else if(Oe<96)f|=1<<Oe-64;else if(Oe<123)p|=1<<Oe-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(Se.name===".notdef")continue;const Le=Se.getMetrics();e.push(Le.xMin),n.push(Le.yMin),r.push(Le.xMax),s.push(Le.yMax),a.push(Le.leftSideBearing),o.push(Le.rightSideBearing),i.push(Se.advanceWidth)}const y={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:Gl(i),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};y.ascender=t.ascender,y.descender=t.descender;let m=0;t.weightClass>=600&&(m|=t.macStyleValues.BOLD),t.italicAngle<0&&(m|=t.macStyleValues.ITALIC);const b=si.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:y.xMin,yMin:y.yMin,xMax:y.xMax,yMax:y.yMax,lowestRecPPEM:3,macStyle:m,createdTimestamp:t.createdTimestamp}),v=ii.make({ascender:y.ascender,descender:y.descender,advanceWidthMax:y.advanceWidthMax,minLeftSideBearing:y.minLeftSideBearing,minRightSideBearing:y.minRightSideBearing,xMaxExtent:y.maxLeftSideBearing+(y.xMax-y.xMin),numberOfHMetrics:t.glyphs.length}),w=ci.make(t.glyphs.length),T=Tr.make(Object.assign({xAvgCharWidth:Math.round(y.advanceWidthAvg),usFirstCharIndex:c,usLastCharIndex:l,ulUnicodeRange1:u,ulUnicodeRange2:h,ulUnicodeRange3:f,ulUnicodeRange4:p,sTypoAscender:y.ascender,sTypoDescender:y.descender,sTypoLineGap:0,usWinAscent:y.yMax,usWinDescent:Math.abs(y.yMin),ulCodePageRange1:1,sxHeight:Ti(t,"xyvw",{yMax:Math.round(y.ascender/2)}).yMax,sCapHeight:Ti(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",y).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),C=ai.make(t.glyphs),E=Hs.make(t.glyphs),R=t.getEnglishName("fontFamily"),P=t.getEnglishName("fontSubfamily"),V=R+" "+P;let X=t.getEnglishName("postScriptName");X||(X=R.replace(/\s/g,"")+"-"+P);const W={};for(let J in t.names)W[J]=t.names[J];W.unicode=W.unicode||{},W.macintosh=W.macintosh||{},W.windows=W.windows||{};const $=t.names.unicode||{},re=t.names.macintosh||{},N=t.names.windows||{};for(const J in W){if(W[J]=W[J]||{},!W[J].uniqueID){const Se=t.getEnglishName("manufacturer")||"";W[J].uniqueID={en:`${Se}: ${V}`}}W[J].postScriptName||(W[J].postScriptName={en:X})}W.unicode.preferredFamily||(W.unicode.preferredFamily=$.fontFamily||re.fontFamily||N.fontFamily),W.macintosh.preferredFamily||(W.macintosh.preferredFamily=re.fontFamily||$.fontFamily||N.fontFamily),W.windows.preferredFamily||(W.windows.preferredFamily=N.fontFamily||$.fontFamily||re.fontFamily),W.unicode.preferredSubfamily||(W.unicode.preferredSubfamily=$.fontSubfamily||re.fontSubfamily||N.fontSubfamily),W.macintosh.preferredSubfamily||(W.macintosh.preferredSubfamily=re.fontSubfamily||$.fontSubfamily||N.fontSubfamily),W.windows.preferredSubfamily||(W.windows.preferredSubfamily=N.fontSubfamily||$.fontSubfamily||re.fontSubfamily);const B=[],U=Gs.make(W,B),te=B.length>0?oi.make(B):void 0,Ee=li.make(t),st=Sr.make(t.glyphs,{version:t.getEnglishName("version"),fullName:V,familyName:R,weightName:P,postScriptName:X,unitsPerEm:t.unitsPerEm,fontBBox:[0,y.yMin,y.ascender,y.advanceWidthMax],topDict:t.tables.cff&&t.tables.cff.topDict||{}}),He=t.metas&&Object.keys(t.metas).length>0?hi.make(t.metas):void 0,fe=[b,v,w,T,U,E,Ee,st,C];te&&fe.push(te);const K={gsub:ui,cpal:$s,colr:fi,stat:di,avar:gi,cvar:mi,fvar:pi,gvar:yi,gasp:bi,svg:xi},ee={avar:[t.tables.fvar],fvar:[t.names]};for(let J in K){const Se=t.tables[J];if(Se){const Ae=K[J].make.call(t,Se,...ee[J]||[]);Ae&&fe.push(Ae)}}He&&fe.push(He);const de=wi(fe),ve=de.encode(),ge=Cr(ve),ye=de.fields;let ae=!1;for(let J=0;J<ye.length;J+=1)if(ye[J].name==="head table"){ye[J].value.checkSumAdjustment=2981146554-ge,ae=!0;break}if(!ae)throw new Error("Could not find head table with checkSum to adjust.");return de}var Wl={make:wi,fontToTable:Hl,computeCheckSum:Cr};function kr(t,e){let n=0,r=t.length-1;for(;n<=r;){const s=n+r>>>1,i=t[s].tag;if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function Ci(t,e){let n=0,r=t.length-1;for(;n<=r;){const s=n+r>>>1,i=t[s];if(i===e)return s;i<e?n=s+1:r=s-1}return-n-1}function ki(t,e){let n,r=0,s=t.length-1;for(;r<=s;){const i=r+s>>>1;n=t[i];const a=n.start;if(a===e)return n;a<e?r=i+1:s=i-1}if(r>0)return n=t[r-1],e>n.end?0:n}function Fi(t,e){this.font=t,this.tableName=e}Fi.prototype={searchTag:kr,binSearch:Ci,getTable:function(t){let e=this.font.tables[this.tableName];return!e&&t&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let t=this.getTable();return t?t.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let t=this.getTable();if(!t)return;let e=!1;for(let n=0;n<t.scripts.length;n++){const r=t.scripts[n].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"},getScriptTable:function(t,e){const n=this.getTable(e);if(n){t=t||"DFLT";const r=n.scripts,s=kr(n.scripts,t);if(s>=0)return r[s].script;if(e){const i={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-s,0,i),i.script}}},getLangSysTable:function(t,e,n){const r=this.getScriptTable(t,n);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;const s=kr(r.langSysRecords,e);if(s>=0)return r.langSysRecords[s].langSys;if(n){const i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(t,e,n,r){const s=this.getLangSysTable(t,e,r);if(s){let i;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let c=0;c<a.length;c++)if(i=o[a[c]],i.tag===n)return i.feature;if(r){const c=o.length;return H.assert(c===0||n>=o[c-1].tag,"Features must be added in alphabetical order."),i={tag:n,feature:{params:0,lookupListIndexes:[]}},o.push(i),a.push(c),i.feature}}},getLookupTables:function(t,e,n,r,s){const i=this.getFeatureTable(t,e,n,s),a=[];if(i){let o;const c=i.lookupListIndexes,l=this.font.tables[this.tableName].lookups;for(let u=0;u<c.length;u++)o=l[c[u]],o.lookupType===r&&a.push(o);if(a.length===0&&s){o={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};const u=l.length;return l.push(o),c.push(u),[o]}}return a},getGlyphClass:function(t,e){switch(t.format){case 1:return t.startGlyph<=e&&e<t.startGlyph+t.classes.length?t.classes[e-t.startGlyph]:0;case 2:{const n=ki(t.ranges,e);return n?n.classId:0}}},getCoverageIndex:function(t,e){switch(t.format){case 1:{const n=Ci(t.glyphs,e);return n>=0?n:-1}case 2:{const n=ki(t.ranges,e);return n?n.index+e-n.start:-1}}},expandCoverage:function(t){if(t.format===1)return t.glyphs;{const e=[],n=t.ranges;for(let r=0;r<n.length;r++){const s=n[r],i=s.start,a=s.end;for(let o=i;o<=a;o++)e.push(o)}return e}}};var kn=Fi;function qt(t){kn.call(this,t,"gpos")}qt.prototype=kn.prototype,qt.prototype.init=function(){const t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)},qt.prototype.getKerningValue=function(t,e,n){for(let r=0;r<t.length;r++){const s=t[r].subtables;for(let i=0;i<s.length;i++){const a=s[i],o=this.getCoverageIndex(a.coverage,e);if(!(o<0))switch(a.posFormat){case 1:{let c=a.pairSets[o];for(let l=0;l<c.length;l++){let u=c[l];if(u.secondGlyph===n)return u.value1&&u.value1.xAdvance||0}break}case 2:{const c=this.getGlyphClass(a.classDef1,e),l=this.getGlyphClass(a.classDef2,n),u=a.classRecords[c][l];return u.value1&&u.value1.xAdvance||0}}}}return 0},qt.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};var zl=qt;function Vl(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function jl(t,e,n){let r=0,s=t.length-1,i=null;for(;r<=s;){const a=Math.floor((r+s)/2),o=t[a],c=o[e];if(c<n)r=a+1;else if(c>n)s=a-1;else{i=o;break}}return i}function ql(t,e,n){let r=0,s=t.length-1;for(;r<=s;){const i=Math.floor((r+s)/2),a=t[i];if(a[e]<n)r=i+1;else if(a[e]>n)s=i-1;else return i}return-1}function $l(t,e,n){let r=0,s=t.length;const i=(a,o)=>a[e]-o[e];for(;r<s;){const a=r+s>>>1;i(t[a],n)<0?r=a+1:s=a}return t.splice(r,0,n),r}function Ei(t){return t[0]===31&&t[1]===139&&t[2]===8}function Yl(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=10;const r=t.byteLength-8,s=e.getInt8(3);if(s&4&&(n+=2+e.getUint16(n,!0)),s&8)for(;n<r&&t[n++]!==0;);if(s&16)for(;n<r&&t[n++]!==0;);if(s&2&&(n+=2),n>=r)throw new Error("Can't find compressed blocks");const i=e.getUint32(e.byteLength-4,!0);return Ts(t.subarray(n,r),new Uint8Array(i))}function Ai(t){return{x:t.x,y:t.y,onCurve:t.onCurve,lastPointOfContour:t.lastPointOfContour}}function Xl(t){return{glyphIndex:t.glyphIndex,xScale:t.xScale,scale01:t.scale01,scale10:t.scale10,yScale:t.yScale,dx:t.dx,dy:t.dy}}function Ie(t){kn.call(this,t,"gsub")}function Fr(t,e,n){const r=t.subtables;for(let s=0;s<r.length;s++){const i=r[s];if(i.substFormat===e)return i}if(n)return r.push(n),n}Ie.prototype=kn.prototype,Ie.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Ie.prototype.getSingle=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,1);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage);let u;if(c.substFormat===1){const h=c.deltaGlyphId;for(u=0;u<l.length;u++){const f=l[u];r.push({sub:f,by:f+h})}}else{const h=c.substitute;for(u=0;u<l.length;u++)r.push({sub:l[u],by:h[u]})}}}return r},Ie.prototype.getMultiple=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,2);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage);let u;for(u=0;u<l.length;u++){const h=l[u],f=c.sequences[u];r.push({sub:h,by:f})}}}return r},Ie.prototype.getAlternates=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,3);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage),u=c.alternateSets;for(let h=0;h<l.length;h++)r.push({sub:l[h],by:u[h]})}}return r},Ie.prototype.getLigatures=function(t,e,n){const r=[],s=this.getLookupTables(e,n,t,4);for(let i=0;i<s.length;i++){const a=s[i].subtables;for(let o=0;o<a.length;o++){const c=a[o],l=this.expandCoverage(c.coverage),u=c.ligatureSets;for(let h=0;h<l.length;h++){const f=l[h],p=u[h];for(let y=0;y<p.length;y++){const m=p[y];r.push({sub:[f].concat(m.components),by:m.ligGlyph})}}}}return r},Ie.prototype.addSingle=function(t,e,n,r){const s=this.getLookupTables(n,r,t,1,!0)[0],i=Fr(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});H.assert(i.coverage.format===1,"Single: unable to modify coverage table format "+i.coverage.format);const a=e.sub;let o=this.binSearch(i.coverage.glyphs,a);o<0&&(o=-1-o,i.coverage.glyphs.splice(o,0,a),i.substitute.splice(o,0,0)),i.substitute[o]=e.by},Ie.prototype.addMultiple=function(t,e,n,r){H.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(n,r,t,2,!0)[0],i=Fr(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});H.assert(i.coverage.format===1,"Multiple: unable to modify coverage table format "+i.coverage.format);const a=e.sub;let o=this.binSearch(i.coverage.glyphs,a);o<0&&(o=-1-o,i.coverage.glyphs.splice(o,0,a),i.sequences.splice(o,0,0)),i.sequences[o]=e.by},Ie.prototype.addAlternate=function(t,e,n,r){const s=this.getLookupTables(n,r,t,3,!0)[0],i=Fr(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});H.assert(i.coverage.format===1,"Alternate: unable to modify coverage table format "+i.coverage.format);const a=e.sub;let o=this.binSearch(i.coverage.glyphs,a);o<0&&(o=-1-o,i.coverage.glyphs.splice(o,0,a),i.alternateSets.splice(o,0,0)),i.alternateSets[o]=e.by},Ie.prototype.addLigature=function(t,e,n,r){const s=this.getLookupTables(n,r,t,4,!0)[0];let i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),H.assert(i.coverage.format===1,"Ligature: unable to modify coverage table format "+i.coverage.format);const a=e.sub[0],o=e.sub.slice(1),c={ligGlyph:e.by,components:o};let l=this.binSearch(i.coverage.glyphs,a);if(l>=0){const u=i.ligatureSets[l];for(let h=0;h<u.length;h++)if(Vl(u[h].components,o))return;u.push(c)}else l=-1-l,i.coverage.glyphs.splice(l,0,a),i.ligatureSets.splice(l,0,[c])},Ie.prototype.getFeature=function(t,e,n){if(/ss\d\d/.test(t))return this.getSingle(t,e,n);switch(t){case"aalt":case"salt":return this.getSingle(t,e,n).concat(this.getAlternates(t,e,n));case"dlig":case"liga":case"rlig":return this.getLigatures(t,e,n);case"ccmp":return this.getMultiple(t,e,n).concat(this.getLigatures(t,e,n));case"stch":return this.getMultiple(t,e,n)}},Ie.prototype.add=function(t,e,n,r){if(/ss\d\d/.test(t))return this.addSingle(t,e,n,r);switch(t){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(t,e,n,r):this.addAlternate(t,e,n,r);case"dlig":case"liga":case"rlig":return this.addLigature(t,e,n,r);case"ccmp":return e.by instanceof Array?this.addMultiple(t,e,n,r):this.addLigature(t,e,n,r)}};var Kl=Ie,Oi=class{constructor(t){this.defaultValue=255,this.font=t}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(t){const e=[],n=this.cpal();if(!n)return e;for(let r=0;r<n.colorRecordIndices.length;r++){const s=n.colorRecordIndices[r],i=[];for(let a=s;a<s+n.numPaletteEntries;a++)i.push(Lt(n.colorRecords[a],t||"hexa"));e.push(i)}return e}toCPALcolor(t){return Array.isArray(t)?t.map(e=>wn(e,"raw")):wn(t,"raw")}fillPalette(t,e=[],n=this.cpal().numPaletteEntries){return t=Number.isInteger(t)?this.get(t,"raw"):t,Object.assign(Array(n).fill(this.defaultValue),this.toCPALcolor(t).concat(this.toCPALcolor(e)))}extend(t){if(this.ensureCPAL(Array(t).fill(this.defaultValue)))return;const e=this.cpal(),n=e.numPaletteEntries+t,r=this.getAll().map(s=>this.fillPalette(s,[],n));e.numPaletteEntries=n,e.colorRecords=this.toCPALcolor(r.flat()),this.updateIndices()}get(t,e="hexa"){return this.getAll(e)[t]||null}getColor(t,e=0,n="hexa"){return gr(this.font,t,e,n)}setColor(t,e,n=0){t=parseInt(t),n=parseInt(n);let r=this.getAll("raw"),s=r[n];if(!s)throw Error(`paletteIndex ${n} out of range`);const i=this.cpal(),a=i.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+t>a&&(this.extend(e.length+t-a),r=this.getAll("raw"),s=r[n]);for(let o=0;o<e.length;o++)s[o+t]=this.toCPALcolor(e[o]);i.colorRecords=r.flat(),this.updateIndices()}add(t){if(this.ensureCPAL(t))return;const e=this.cpal(),n=e.numPaletteEntries;t&&t.length?(t=this.toCPALcolor(t),t.length>n?this.extend(t.length-n):t.length<n&&(t=this.fillPalette(t)),e.colorRecordIndices.push(e.colorRecords.length),e.colorRecords.push(...t)):(e.colorRecordIndices.push(e.colorRecords.length),e.colorRecords.push(...Array(n).fill(this.defaultValue)))}delete(t){const e=this.getAll("raw");delete e[t];const n=this.cpal();n.colorRecordIndices.pop(),n.colorRecords=e.flat()}deleteColor(t,e){if(t===e)throw Error("replacementIndex cannot be the same as colorIndex");const n=this.cpal(),r=this.getAll("raw"),s=[];if(e>n.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${n.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;o<r.length;o++){const l=r[o].filter((u,h)=>h!==t);s.push(l)}const i=this.font.tables.colr;if(i){const o=i.layerRecords;for(let c=0;c<o.length;c++){const l=o[c].paletteIndex;if(l>t)o[c].paletteIndex-=1;else if(l===t){let u=0;for(let h=0;h<r.length;h++)if(e>t&&e<=t+r[h].length){u++;break}o[c].paletteIndex=e-u}}this.font.tables.colr={...i,layerRecords:o}}const a=s.flat();for(let o=0;o<r.length;o++)n.colorRecordIndices[o]-=o;n.numPaletteEntries=Math.max(0,n.numPaletteEntries-1),n.colorRecords=this.toCPALcolor(a)}ensureCPAL(t){return this.cpal()?!1:(!t||!t.length?t=[this.defaultValue]:t=this.toCPALcolor(t),this.font.tables.cpal={version:0,numPaletteEntries:t.length,colorRecords:t,colorRecordIndices:[0]},!0)}updateIndices(){const t=this.cpal(),e=Math.ceil(t.colorRecords.length/t.numPaletteEntries);t.colorRecordIndices=[];for(let n=0;n<e;n++)t.colorRecordIndices.push(n*t.numPaletteEntries)}},Zl=class{constructor(t){this.font=t}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(t){const e=this.font,n=[],r=e.tables.colr,s=e.tables.cpal;if(!r||!s)return n;const i=jl(r.baseGlyphRecords,"glyphID",t);if(!i)return n;const a=i.firstLayerIndex,o=i.numLayers;for(let c=0;c<o;c++){const l=r.layerRecords[a+c];n.push({glyph:e.glyphs.get(l.glyphID),paletteIndex:l.paletteIndex})}return n}add(t,e,n){const r=this.get(t);e=Array.isArray(e)?e:[e],n===void 0||n===1/0||n>r.length?n=r.length:n<0&&(n=r.length+1+n%(r.length+1),n>=r.length+1&&(n-=r.length+1));const s=[];for(let i=0;i<n;i++){const a=Number.isInteger(r[i].glyph)?r[i].glyph:r[i].glyph.index;s.push({glyphID:a,paletteIndex:r[i].paletteIndex})}for(const i of e){const a=Number.isInteger(i.glyph)?i.glyph:i.glyph.index;s.push({glyphID:a,paletteIndex:i.paletteIndex})}for(let i=n;i<r.length;i++){const a=Number.isInteger(r[i].glyph)?r[i].glyph:r[i].glyph.index;s.push({glyphID:a,paletteIndex:r[i].paletteIndex})}this.updateColrTable(t,s)}setPaletteIndex(t,e,n){let r=this.get(t);r[e]?(r=r.map((s,i)=>({glyphID:s.glyph.index,paletteIndex:i===e?n:s.paletteIndex})),this.updateColrTable(t,r)):console.error("Invalid layer index")}remove(t,e,n=e){let r=this.get(t);r=r.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),r.splice(e,n-e+1),this.updateColrTable(t,r)}updateColrTable(t,e){this.ensureCOLR();const r=this.font.tables.colr;let s=ql(r.baseGlyphRecords,"glyphID",t);if(s===-1){const u={glyphID:t,firstLayerIndex:r.layerRecords.length,numLayers:0};s=$l(r.baseGlyphRecords,"glyphID",u)}const a=r.baseGlyphRecords[s],o=a.numLayers,c=e.length,l=c-o;if(l>0){const u=e.slice(o).map(h=>({glyphID:h.glyphID,paletteIndex:h.paletteIndex}));r.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else l<0&&r.layerRecords.splice(a.firstLayerIndex+c,-l);for(let u=0;u<Math.min(o,c);u++)r.layerRecords[a.firstLayerIndex+u]={glyphID:e[u].glyphID,paletteIndex:e[u].paletteIndex};if(a.numLayers=c,l!==0)for(let u=0;u<r.baseGlyphRecords.length;u++){const h=r.baseGlyphRecords[u];u===s||h.firstLayerIndex<a.firstLayerIndex||(r.baseGlyphRecords[u].firstLayerIndex+=l)}}},Jl=class{constructor(t){this.font=t,this.cache=new WeakMap}get(t){const e=this.getOrCreateSvgImageCacheEntry(t);return e&&e.image}getAsync(t){const e=this.getOrCreateSvgImageCacheEntry(t);return e&&e.promise}getOrCreateSvgImageCacheEntry(t){const e=this.font.tables.svg;if(e===void 0)return;const n=e.get(t);if(n===void 0)return;let r=this.cache.get(n);r===void 0&&(r=Ql(n),this.cache.set(n,r));let s=r.images.get(t);return s===void 0&&(s=eu(this.font,r.template,t),s.promise.then(i=>{if(s.image=i,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(t)}catch(a){console.error("font.onGlyphUpdated",t,a)}}),r.images.set(t,s)),s}};function Ql(t){return{template:tu(t).then(su),images:new Map}}function eu(t,e,n){return{promise:e.then(r=>{let s;typeof r=="string"?s=r:(r[4]=n,s=r.join(""));const i=iu(s,t.unitsPerEm);return i.image.decode().then(()=>i)}),image:void 0}}var tu=typeof DecompressionStream=="function"?ru:nu;function nu(t){try{return Promise.resolve(new TextDecoder().decode(Ei(t)?Yl(t):t))}catch(e){return Promise.reject(e)}}function ru(t){if(Ei(t))return new Response(new Response(t).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(t))}catch(e){return Promise.reject(e)}}function su(t){const e=t.indexOf("<svg"),n=t.indexOf(">",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(t.substring(e,n)))return t;const r=t.lastIndexOf("</svg>");return[t.substring(0,n),"<defs>",t.substring(n,r),'</defs><use href="#glyph',"",'"/>',t.substring(r)]}function iu(t,e){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,s=r.viewBox.baseVal,i=r.width.baseVal,a=r.height.baseVal;let o=1,c=1;s.width>0&&s.height>0&&(i.unitType===1?(o=i.valueInSpecifiedUnits/s.width,c=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(c=a.valueInSpecifiedUnits/s.height,o=c):e&&(o=e/s.width,c=e/s.height));const l=document.createElement("div");l.style.position="fixed",l.style.visibility="hidden",l.appendChild(r),document.body.appendChild(l);const u=r.getBBox();document.body.removeChild(l);const h=(u.x-s.x)*o,f=(s.y-u.y)*c,p=u.width*o,y=u.height*c;r.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&r.setAttribute("width",p),c!==1&&r.setAttribute("height",y);const m=new Image(p,y);return m.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(r.outerHTML),{leftSideBearing:h,baseline:f,image:m}}var Er=new WeakMap;function Li(t,e,n,r,s){let i;return(e&r)>0?(i=t.parseByte(),e&s||(i=-i),i=n+i):(e&s)>0?i=n:i=n+t.parseShort(),i}function Ii(t,e,n){const r=new _.Parser(e,n);t._numberOfContours=r.parseShort(),t._xMin=r.parseShort(),t._yMin=r.parseShort(),t._xMax=r.parseShort(),t._yMax=r.parseShort();let s,i;if(t._numberOfContours>0){const a=t.endPointIndices=[];for(let c=0;c<t._numberOfContours;c+=1)a.push(r.parseUShort());t.instructionLength=r.parseUShort(),t.instructions=[];for(let c=0;c<t.instructionLength;c+=1)t.instructions.push(r.parseByte());const o=a[a.length-1]+1;s=[];for(let c=0;c<o;c+=1)if(i=r.parseByte(),s.push(i),(i&8)>0){const l=r.parseByte();for(let u=0;u<l;u+=1)s.push(i),c+=1}if(H.argument(s.length===o,"Bad flags."),a.length>0){const c=[];let l;if(o>0){for(let f=0;f<o;f+=1)i=s[f],l={},l.onCurve=!!(i&1),l.lastPointOfContour=a.indexOf(f)>=0,c.push(l);let u=0;for(let f=0;f<o;f+=1)i=s[f],l=c[f],l.x=Li(r,i,u,2,16),u=l.x;let h=0;for(let f=0;f<o;f+=1)i=s[f],l=c[f],l.y=Li(r,i,h,4,32),h=l.y}t.points=c}else t.points=[]}else if(t._numberOfContours===0)t.points=[];else{t.isComposite=!0,t.points=[],t.components=[];let a=!0;for(;a;){s=r.parseUShort();const o={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(o.dx=r.parseShort(),o.dy=r.parseShort()):o.matchedPoints=[r.parseUShort(),r.parseUShort()]:(s&2)>0?(o.dx=r.parseChar(),o.dy=r.parseChar()):o.matchedPoints=[r.parseByte(),r.parseByte()],(s&8)>0?o.xScale=o.yScale=r.parseF2Dot14():(s&64)>0?(o.xScale=r.parseF2Dot14(),o.yScale=r.parseF2Dot14()):(s&128)>0&&(o.xScale=r.parseF2Dot14(),o.scale01=r.parseF2Dot14(),o.scale10=r.parseF2Dot14(),o.yScale=r.parseF2Dot14()),t.components.push(o),a=!!(s&32)}if(s&256){t.instructionLength=r.parseUShort(),t.instructions=[];for(let o=0;o<t.instructionLength;o+=1)t.instructions.push(r.parseByte())}}}function Fn(t,e){const n=[];for(let r=0;r<t.length;r+=1){const s=t[r],i={x:e.xScale*s.x+e.scale10*s.y+e.dx,y:e.scale01*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};n.push(i)}return n}function au(t){const e=[];let n=[];for(let r=0;r<t.length;r+=1){const s=t[r];n.push(s),s.lastPointOfContour&&(e.push(n),n=[])}return H.argument(n.length===0,"There are still points left in the current contour."),e}function Ar(t){const e=new Ft;if(!t)return e;const n=au(t);for(let r=0;r<n.length;++r){const s=n[r];let i=s[s.length-1],a=s[0];if(i.onCurve)e.moveTo(i.x,i.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{const o={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5};e.moveTo(o.x,o.y)}for(let o=0;o<s.length;++o)if(i=a,a=s[(o+1)%s.length],i.onCurve)e.lineTo(i.x,i.y);else{let c=a;a.onCurve||(c={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5}),e.quadraticCurveTo(i.x,i.y,c.x,c.y)}e.closePath()}return e}function Ri(t,e){if(e.isComposite){Er.has(t)||Er.set(t,new Set);const n=Er.get(t);n.add(e.index);try{for(let r=0;r<e.components.length;r+=1){const s=e.components[r];if(n.has(s.glyphIndex))continue;const i=t.get(s.glyphIndex);if(i.getPath(),i.points){let a;if(s.matchedPoints===void 0)a=Fn(i.points,s);else{if(s.matchedPoints[0]>e.points.length-1||s.matchedPoints[1]>i.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let c=i.points[s.matchedPoints[1]];const l={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};c=Fn([c],l)[0],l.dx=o.x-c.x,l.dy=o.y-c.y,a=Fn(i.points,l)}e.points=e.points.concat(a)}}}finally{n.delete(e.index)}}return Ar(e.points)}function ou(t,e,n,r){const s=new Xe.GlyphSet(r);for(let i=0;i<n.length-1;i+=1){const a=n[i],o=n[i+1];a!==o?s.push(i,Xe.ttfGlyphLoader(r,i,Ii,t,e+a,Ri)):s.push(i,Xe.glyphLoader(r,i))}return s}function cu(t,e,n,r){const s=new Xe.GlyphSet(r);return r._push=function(i){const a=n[i],o=n[i+1];a!==o?s.push(i,Xe.ttfGlyphLoader(r,i,Ii,t,e+a,Ri)):s.push(i,Xe.glyphLoader(r,i))},s}function lu(t,e,n,r,s){return s.lowMemory?cu(t,e,n,r):ou(t,e,n,r)}var Mi={getPath:Ar,parse:lu},uu=class{constructor(t){this.font=t}normalizeCoordTags(t){for(const e in t)if(e.length<4){const n=e.padEnd(4," ");t[n]===void 0&&(t[n]=t[e]),delete t[e]}}getNormalizedCoords(t){t||(t=this.font.variation.get());let e=[];this.normalizeCoordTags(t);for(let n=0;n<this.fvar().axes.length;n++){const r=this.fvar().axes[n];let s=t[r.tag];s===void 0&&(s=r.defaultValue),s<r.defaultValue?e.push((s-r.defaultValue+Number.EPSILON)/(r.defaultValue-r.minValue+Number.EPSILON)):e.push((s-r.defaultValue+Number.EPSILON)/(r.maxValue-r.defaultValue+Number.EPSILON))}if(this.avar())for(let n=0;n<this.avar().axisSegmentMaps.length;n++){let r=this.avar().axisSegmentMaps[n];for(let s=0;s<r.axisValueMaps.length;s++){let i=r.axisValueMaps[s];if(s>=1&&e[n]<i.fromCoordinate){let a=r.axisValueMaps[s-1];e[n]=((e[n]-a.fromCoordinate)*(i.toCoordinate-a.toCoordinate)+Number.EPSILON)/(i.fromCoordinate-a.fromCoordinate+Number.EPSILON)+a.toCoordinate;break}}}return e}interpolatePoints(t,e,n){if(t.length===0)return;let r=0;for(;r<t.length;){let s=r,i=r,a=t[i];for(;!a.lastPointOfContour;)a=t[++i];for(;r<=i&&!n[r];)r++;if(r>i)continue;let o=r,c=r;for(r++;r<=i;)n[r]&&(this.deltaInterpolate(c+1,r-1,c,r,e,t),c=r),r++;c===o?this.deltaShift(s,i,c,e,t):(this.deltaInterpolate(c+1,i,c,o,e,t),o>0&&this.deltaInterpolate(s,o-1,c,o,e,t)),r=i+1}}deltaInterpolate(t,e,n,r,s,i){if(t>e)return;let a=["x","y"];for(let c=0;c<a.length;c++){let l=a[c];if(s[n][l]>s[r][l]){var o=n;n=r,r=o}let u=s[n][l],h=s[r][l],f=i[n][l],p=i[r][l];if(u!==h||f===p){let y=u===h?0:(p-f)/(h-u);for(let m=t;m<=e;m++){let b=s[m][l];b<=u?b+=f-u:b>=h?b+=p-h:b=f+(b-u)*y,i[m][l]=b}}}}deltaShift(t,e,n,r,s){let i=s[n].x-r[n].x,a=s[n].y-r[n].y;if(!(i===0&&a===0))for(let o=t;o<=e;o++)o!==n&&(s[o].x+=i,s[o].y+=a)}transformComponents(t,e,n,r,s,i){let a=0;for(let o=0;o<t.components.length;o++){const c=t.components[o],l=this.font.glyphs.get(c.glyphIndex),u=Xl(c),h=r.indexOf(o);h>-1&&(u.dx+=Math.round(s.deltas[h]*i),u.dy+=Math.round(s.deltasY[h]*i));const f=Fn(this.getTransform(l,n).points,u);e.splice(a,f.length,...f),a+=l.points.length}}applyTupleVariationStore(t,e,n,r="gvar",s={}){n||(n=this.font.variation.get());const i=this.getNormalizedCoords(n),{headers:a,sharedPoints:o}=t,c=this.fvar().axes.length;let l;r==="gvar"?l=e.map(Ai):r==="cvar"&&(l=[...e]);for(let u=0;u<a.length;u++){const h=a[u];let f=1;for(let y=0;y<c;y++){let m=[0];switch(r){case"gvar":m=h.peakTuple?h.peakTuple:this.gvar().sharedTuples[h.sharedTupleRecordsIndex];break;case"cvar":m=h.peakTuple;break}if(m[y]!==0){if(i[y]===0){f=0;break}if(h.intermediateStartTuple)if(i[y]<h.intermediateStartTuple[y]||i[y]>h.intermediateEndTuple[y]){f=0;break}else i[y]<m[y]?f=f*(i[y]-h.intermediateStartTuple[y]+Number.EPSILON)/(m[y]-h.intermediateStartTuple[y]+Number.EPSILON):f=f*(h.intermediateEndTuple[y]-i[y]+Number.EPSILON)/(h.intermediateEndTuple[y]-m[y]+Number.EPSILON);else{if(i[y]<Math.min(0,m[y])||i[y]>Math.max(0,m[y])){f=0;break}f=(f*i[y]+Number.EPSILON)/(m[y]+Number.EPSILON)}}}if(f===0)continue;const p=h.privatePoints.length?h.privatePoints:o;if(r==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,l,n,p,h,f);else if(p.length===0)for(let y=0;y<l.length;y++){const m=l[y];r==="gvar"?l[y]={x:Math.round(m.x+h.deltas[y]*f),y:Math.round(m.y+h.deltasY[y]*f),onCurve:m.onCurve,lastPointOfContour:m.lastPointOfContour}:r==="cvar"&&(l[y]=Math.round(m+h.deltas[y]*f))}else{let y;r==="gvar"?y=l.map(Ai):r==="cvar"&&(y=l);const m=Array(e.length).fill(!1);for(let b=0;b<p.length;b++){let v=p[b];if(v<e.length){let w=y[v];r==="gvar"?(m[v]=!0,w.x+=h.deltas[b]*f,w.y+=h.deltasY[b]*f):r==="cvar"&&(l[v]=Math.round(w+h.deltas[b]*f))}}if(r==="gvar"){this.interpolatePoints(y,l,m);for(let b=0;b<e.length;b++){let v=y[b].x-l[b].x,w=y[b].y-l[b].y;l[b].x=Math.round(l[b].x+v),l[b].y=Math.round(l[b].y+w)}}}}return l}getTransform(t,e){Number.isInteger(t)&&(t=this.font.glyphs.get(t));const n=t.getBlendPath,r=!!(t.points&&t.points.length);let s=t;if(n||r){if(e||(e=this.font.variation.get()),r){const i=this.gvar()&&this.gvar().glyphVariations[t.index];if(i){const a=t.points;let o=this.applyTupleVariationStore(i,a,e,"gvar",{glyph:t});s=new Wt(Object.assign({},t,{points:o,path:Ar(o)}))}}else if(n){const i=t.getBlendPath(e);s=new Wt(Object.assign({},t,{path:i}))}}return this.font.tables.hvar&&(t._advanceWidth=typeof t._advanceWidth<"u"?t._advanceWidth:t.advanceWidth,t.advanceWidth=s.advanceWidth=Math.round(t._advanceWidth+this.getVariableAdjustment(s.index,"hvar","advanceWidth",e)),t._leftSideBearing=typeof t._leftSideBearing<"u"?t._leftSideBearing:t.leftSideBearing,t.leftSideBearing=s.leftSideBearing=Math.round(t._leftSideBearing+this.getVariableAdjustment(s.index,"hvar","lsb",e))),s}getCvarTransform(t){const e=this.font.tables.cvt,n=this.cvar();return!e||!e.length||!n||!n.headers.length?e:this.applyTupleVariationStore(n,e,t,"cvar")}getVariableAdjustment(t,e,n,r){r=r||this.font.variation.get();let s,i;const a=this.font.tables[e];if(!a)throw Error(`trying to get variation adjustment from non-existent table "${a}"`);if(!a.itemVariationStore)throw Error(`trying to get variation adjustment from table "${a}" which does not have an itemVariationStore`);const o=a[n]&&a[n].map.length;if(o){let c=t;c>=o&&(c=o-1),{outerIndex:s,innerIndex:i}=a[n].map[c]}else s=0,i=t;return this.getDelta(a.itemVariationStore,s,i,r)}getDelta(t,e,n,r){if(e>=t.itemVariationSubtables.length)return 0;let s=t.itemVariationSubtables[e];if(n>=s.deltaSets.length)return 0;let i=s.deltaSets[n],a=this.getBlendVector(t,e,r),o=0;for(let c=0;c<s.regionIndexes.length;c++)o+=i[c]*a[c];return o}getBlendVector(t,e,n){n||(n=this.font.variation.get());let r=t.itemVariationSubtables[e];const s=this.getNormalizedCoords(n);let i=[];for(let a=0;a<r.regionIndexes.length;a++){let o=1,c=r.regionIndexes[a],l=t.variationRegions[c].regionAxes;for(let u=0;u<l.length;u++){let h=l[u],f;h.startCoord>h.peakCoord||h.peakCoord>h.endCoord||h.startCoord<0&&h.endCoord>0&&h.peakCoord!==0||h.peakCoord===0?f=1:s[u]<h.startCoord||s[u]>h.endCoord?f=0:s[u]===h.peakCoord?f=1:s[u]<h.peakCoord?f=(s[u]-h.startCoord+Number.EPSILON)/(h.peakCoord-h.startCoord+Number.EPSILON):f=(h.endCoord-s[u]+Number.EPSILON)/(h.endCoord-h.peakCoord+Number.EPSILON),o*=f}i[a]=o}return i}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},hu=class{constructor(t){this.font=t,this.process=new uu(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){const t=this.getDefaultInstanceIndex();t>-1?this.set(t):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((t,e)=>(t[e.tag]=e.defaultValue,t),{})}getDefaultInstanceIndex(){const t=this.getDefaultCoordinates();let e=this.getInstanceIndex(t);return e<0&&(e=this.fvar().instances.findIndex(n=>n.name&&n.name.en==="Regular")),e}getInstanceIndex(t){return this.fvar().instances.findIndex(e=>Object.keys(t).every(n=>e.coordinates[n]===t[n]))}getInstance(t){return this.fvar().instances&&this.fvar().instances[t]}set(t){let e;if(Number.isInteger(t)){const n=this.getInstance(t);if(!n)throw Error(`Invalid instance index ${t}`);e={...n.coordinates}}else e=t,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Di=1e6,En=64,An=1e4,Bi,wt,_i,Or;function Ui(t){this.font=t,this.getCommands=function(e){return Mi.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function fu(t){return t}function Pi(t){return Math.sign(t)*Math.round(Math.abs(t))}function pu(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function du(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function gu(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function mu(t){return Math.sign(t)*Math.floor(Math.abs(t))}var Ni=function(t){const e=this.srPeriod;let n=this.srPhase;const r=this.srThreshold;let s=1;return t<0&&(t=-t,s=-1),t+=r-n,t=Math.trunc(t/e)*e,t+=n,t<0?n*s:t*s},Ze={x:1,y:0,axis:"x",distance:function(t,e,n,r){return(n?t.xo:t.x)-(r?e.xo:e.x)},interpolate:function(t,e,n,r){let s,i,a,o,c,l,u;if(!r||r===this){if(s=t.xo-e.xo,i=t.xo-n.xo,c=e.x-e.xo,l=n.x-n.xo,a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){t.x=t.xo+(c+l)/2;return}t.x=t.xo+(c*o+l*a)/u;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(n,n,!1,!0),a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){Ze.setRelative(t,t,(c+l)/2,r,!0);return}Ze.setRelative(t,t,(c*o+l*a)/u,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,n,r,s){if(!r||r===this){t.x=(s?e.xo:e.x)+n;return}const i=s?e.xo:e.x,a=s?e.yo:e.y,o=i+n*r.x,c=a+n*r.y;t.x=o+(t.y-c)/r.normalSlope},slope:0,touch:function(t){t.xTouched=!0},touched:function(t){return t.xTouched},untouch:function(t){t.xTouched=!1}},Qe={x:0,y:1,axis:"y",distance:function(t,e,n,r){return(n?t.yo:t.y)-(r?e.yo:e.y)},interpolate:function(t,e,n,r){let s,i,a,o,c,l,u;if(!r||r===this){if(s=t.yo-e.yo,i=t.yo-n.yo,c=e.y-e.yo,l=n.y-n.yo,a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){t.y=t.yo+(c+l)/2;return}t.y=t.yo+(c*o+l*a)/u;return}if(s=r.distance(t,e,!0,!0),i=r.distance(t,n,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(n,n,!1,!0),a=Math.abs(s),o=Math.abs(i),u=a+o,u===0){Qe.setRelative(t,t,(c+l)/2,r,!0);return}Qe.setRelative(t,t,(c*o+l*a)/u,r,!0)},normalSlope:0,setRelative:function(t,e,n,r,s){if(!r||r===this){t.y=(s?e.yo:e.y)+n;return}const i=s?e.xo:e.x,a=s?e.yo:e.y,o=i+n*r.x,c=a+n*r.y;t.y=c+r.normalSlope*(t.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(t){t.yTouched=!0},touched:function(t){return t.yTouched},untouch:function(t){t.yTouched=!1}};Object.freeze(Ze),Object.freeze(Qe);function $t(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}$t.prototype.distance=function(t,e,n,r){return this.x*Ze.distance(t,e,n,r)+this.y*Qe.distance(t,e,n,r)},$t.prototype.interpolate=function(t,e,n,r){let s,i,a,o,c,l,u;if(a=r.distance(t,e,!0,!0),o=r.distance(t,n,!0,!0),s=r.distance(e,e,!1,!0),i=r.distance(n,n,!1,!0),c=Math.abs(a),l=Math.abs(o),u=c+l,u===0){this.setRelative(t,t,(s+i)/2,r,!0);return}this.setRelative(t,t,(s*l+i*c)/u,r,!0)},$t.prototype.setRelative=function(t,e,n,r,s){r=r||this;const i=s?e.xo:e.x,a=s?e.yo:e.y,o=i+n*r.x,c=a+n*r.y,l=r.normalSlope,u=this.slope,h=t.x,f=t.y;t.x=(u*h-l*o+c-f)/(u-l),t.y=u*(t.x-h)+f},$t.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function Yt(t,e){const n=Math.sqrt(t*t+e*e);return t/=n,e/=n,t===1&&e===0?Ze:t===0&&e===1?Qe:new $t(t,e)}function et(t,e,n,r){this.x=this.xo=Math.round(t*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=n,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}et.prototype.nextTouched=function(t){let e=this.nextPointOnContour;for(;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},et.prototype.prevTouched=function(t){let e=this.prevPointOnContour;for(;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Xt=Object.freeze(new et(0,0)),yu={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ct(t,e){switch(this.env=t,this.stack=[],this.prog=e,t){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Ze,this.round=Pi}}Ui.prototype.exec=function(t,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const n=this.font;let r=this._prepState;if(!r||r.ppem!==e){let s=this._fpgmState;if(!s){ct.prototype=yu,s=this._fpgmState=new ct("fpgm",n.tables.fpgm),s.funcs=[],s.font=n,s.instructionCount=0,s.callDepth=0;try{wt(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}ct.prototype=s,r=this._prepState=new ct("prep",n.tables.prep),r.ppem=e,r.instructionCount=0,r.callDepth=0;const i=n.variation&&n.variation.process.getCvarTransform()||n.tables.cvt;if(i){const a=r.cvt=new Array(i.length),o=e/n.unitsPerEm;for(let c=0;c<i.length;c++)a[c]=i[c]*o}else r.cvt=[];try{wt(r)}catch(a){this._errorState<2&&console.log("Hinting error in PREP:"+a),this._errorState=2}}if(!(this._errorState>1))try{return _i(t,r)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},_i=function(t,e){const n=e.ppem/e.font.unitsPerEm,r=n;let s=t.components,i,a,o;if(ct.prototype=e,!s)o=new ct("glyf",t.instructions),o.instructionCount=0,o.callDepth=0,Or(t,o,n,r),a=o.gZone;else{const c=e.font;a=[],i=[];for(let l=0;l<s.length;l++){const u=s[l],h=c.glyphs.get(u.glyphIndex);o=new ct("glyf",h.instructions),o.instructionCount=0,o.callDepth=0,Or(h,o,n,r);const f=Math.round(u.dx*n),p=Math.round(u.dy*r),y=o.gZone,m=o.contours;for(let v=0;v<y.length;v++){const w=y[v];w.xTouched=w.yTouched=!1,w.xo=w.x=w.x+f,w.yo=w.y=w.y+p}const b=a.length;a.push.apply(a,y);for(let v=0;v<m.length;v++)i.push(m[v]+b)}t.instructions&&!o.inhibitGridFit&&(o=new ct("glyf",t.instructions),o.gZone=o.z0=o.z1=o.z2=a,o.contours=i,a.push(new et(0,0),new et(Math.round(t.advanceWidth*n),0)),wt(o),a.length-=2)}return a},Or=function(t,e,n,r){const s=t.points||[],i=s.length,a=e.gZone=e.z0=e.z1=e.z2=[],o=e.contours=[];let c;for(let h=0;h<i;h++)c=s[h],a[h]=new et(c.x*n,c.y*r,c.lastPointOfContour,c.onCurve);let l,u;for(let h=0;h<i;h++)c=a[h],l||(l=c,o.push(h)),c.lastPointOfContour?(c.nextPointOnContour=l,l.prevPointOnContour=c,l=void 0):(u=a[h+1],c.nextPointOnContour=u,u.prevPointOnContour=c);e.inhibitGridFit||(a.push(new et(0,0),new et(Math.round(t.advanceWidth*n),0)),wt(e),a.length-=2)},wt=function(t){let e=t.prog;if(!e)return;const n=e.length;let r;for(t.ip=0;t.ip<n;t.ip++){if(++t.instructionCount>Di)throw new Error("Hinting instructions exceeded maximum of "+Di);if(r=Bi[e[t.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));r(t)}};function On(t){const e=t.tZone=new Array(t.gZone.length);for(let n=0;n<e.length;n++)e[n]=new et(0,0)}function Gi(t,e){const n=t.prog;let r=t.ip,s=1,i;do if(i=n[++r],i===88)s++;else if(i===89)s--;else if(i===64)r+=n[r+1]+1;else if(i===65)r+=2*n[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);t.ip=r}function Hi(t,e){e.fv=e.pv=e.dpv=t}function Wi(t,e){e.pv=e.dpv=t}function zi(t,e){e.fv=t}function Vi(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],a=e.z1[s];let o,c;t?(o=i.y-a.y,c=a.x-i.x):(o=a.x-i.x,c=a.y-i.y),e.pv=e.dpv=Yt(o,c)}function ji(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],a=e.z1[s];let o,c;t?(o=i.y-a.y,c=a.x-i.x):(o=a.x-i.x,c=a.y-i.y),e.fv=Yt(o,c)}function bu(t){const e=t.stack,n=e.pop(),r=e.pop();t.pv=t.dpv=Yt(r,n)}function xu(t){const e=t.stack,n=e.pop(),r=e.pop();t.fv=Yt(r,n)}function vu(t){const e=t.stack,n=t.pv;e.push(n.x*16384),e.push(n.y*16384)}function Su(t){const e=t.stack,n=t.fv;e.push(n.x*16384),e.push(n.y*16384)}function wu(t){t.fv=t.pv}function Tu(t){const e=t.stack,n=e.pop(),r=e.pop(),s=e.pop(),i=e.pop(),a=e.pop(),o=t.z0,c=t.z1,l=o[n],u=o[r],h=c[s],f=c[i],p=t.z2[a],y=l.x,m=l.y,b=u.x,v=u.y,w=h.x,T=h.y,C=f.x,E=f.y,R=(y-b)*(T-E)-(m-v)*(w-C),P=y*v-m*b,V=w*E-T*C;p.x=(P*(w-C)-V*(y-b))/R,p.y=(P*(T-E)-V*(m-v))/R}function Cu(t){t.rp0=t.stack.pop()}function ku(t){t.rp1=t.stack.pop()}function Fu(t){t.rp2=t.stack.pop()}function Eu(t){const e=t.stack.pop();switch(t.zp0=e,e){case 0:t.tZone||On(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Au(t){const e=t.stack.pop();switch(t.zp1=e,e){case 0:t.tZone||On(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ou(t){const e=t.stack.pop();switch(t.zp2=e,e){case 0:t.tZone||On(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Lu(t){const e=t.stack.pop();switch(t.zp0=t.zp1=t.zp2=e,e){case 0:t.tZone||On(t),t.z0=t.z1=t.z2=t.tZone;break;case 1:t.z0=t.z1=t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Iu(t){t.loop=t.stack.pop(),t.loop>An&&(t.loop=An)}function Ru(t){t.round=Pi}function Mu(t){t.round=du}function Du(t){const e=t.stack.pop();t.minDis=e/64}function Bu(t){Gi(t,!1)}function _u(t){const e=t.stack.pop();t.ip+=e-1}function Uu(t){const e=t.stack.pop();t.cvCutIn=e/64}function Pu(t){const e=t.stack;e.push(e[e.length-1])}function Lr(t){t.stack.pop()}function Nu(t){t.stack.length=0}function Gu(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n),e.push(r)}function Hu(t){const e=t.stack;e.push(e.length)}function Wu(t){const e=t.stack,n=e.pop();let r=e.pop();if(r>An&&(r=An),++t.callDepth>En)throw new Error("Hinting call depth exceeded maximum of "+En);const s=t.ip,i=t.prog;t.prog=t.funcs[n];for(let a=0;a<r;a++)wt(t);t.ip=s,t.prog=i,t.callDepth--}function zu(t){const e=t.stack.pop();if(++t.callDepth>En)throw new Error("Hinting call depth exceeded maximum of "+En);const n=t.ip,r=t.prog;t.prog=t.funcs[e],wt(t),t.ip=n,t.prog=r,t.callDepth--}function Vu(t){const e=t.stack,n=e.pop();e.push(e[e.length-n])}function ju(t){const e=t.stack,n=e.pop();e.push(e.splice(e.length-n,1)[0])}function qu(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");const e=t.stack,n=t.prog;let r=t.ip;const s=e.pop(),i=r;for(;n[++r]!==45;);t.ip=r,t.funcs[s]=n.slice(i+1,r)}function qi(t,e){const n=e.stack.pop(),r=e.z0[n],s=e.fv,i=e.pv;let a=i.distance(r,Xt);t&&(a=e.round(a)),s.setRelative(r,Xt,a,i),s.touch(r),e.rp0=e.rp1=n}function $i(t,e){const n=e.z2,r=n.length-2;let s,i,a;for(let o=0;o<r;o++)s=n[o],!t.touched(s)&&(i=s.prevTouched(t),i!==s&&(a=s.nextTouched(t),i===a&&t.setRelative(s,s,t.distance(i,i,!1,!0),t,!0),t.interpolate(s,i,a,t)))}function Yi(t,e){const n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,a=e.pv;let o=e.loop;const c=e.z2;for(;o--;){const l=n.pop(),u=c[l],h=a.distance(s,s,!1,!0);i.setRelative(u,u,h,a),i.touch(u)}e.loop=1}function Xi(t,e){const n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,a=e.pv,o=n.pop(),c=e.z2[e.contours[o]];let l=c;const u=a.distance(s,s,!1,!0);do l!==s&&i.setRelative(l,l,u,a),l=l.nextPointOnContour;while(l!==c)}function Ki(t,e){const n=e.stack,r=t?e.rp1:e.rp2,s=(t?e.z0:e.z1)[r],i=e.fv,a=e.pv,o=n.pop();let c;switch(o){case 0:c=e.tZone;break;case 1:c=e.gZone;break;default:throw new Error("Invalid zone")}let l;const u=a.distance(s,s,!1,!0),h=c.length-2;for(let f=0;f<h;f++)l=c[f],i.setRelative(l,l,u,a)}function $u(t){const e=t.stack;let n=t.loop;const r=t.fv,s=e.pop()/64,i=t.z2;for(;n--;){const a=e.pop(),o=i[a];r.setRelative(o,o,s),r.touch(o)}t.loop=1}function Yu(t){const e=t.stack,n=t.rp1,r=t.rp2;let s=t.loop;const i=t.z0[n],a=t.z1[r],o=t.fv,c=t.dpv,l=t.z2;for(;s--;){const u=e.pop(),h=l[u];o.interpolate(h,i,a,c),o.touch(h)}t.loop=1}function Zi(t,e){const n=e.stack,r=n.pop()/64,s=n.pop(),i=e.z1[s],a=e.z0[e.rp0],o=e.fv,c=e.pv;o.setRelative(i,a,r,c),o.touch(i),e.rp1=e.rp0,e.rp2=s,t&&(e.rp0=s)}function Xu(t){const e=t.stack,n=t.rp0,r=t.z0[n];let s=t.loop;const i=t.fv,a=t.pv,o=t.z1;for(;s--;){const c=e.pop(),l=o[c];i.setRelative(l,r,0,a),i.touch(l)}t.loop=1}function Ku(t){t.round=pu}function Ji(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z0[s],a=e.fv,o=e.pv;let c=e.cvt[r],l=o.distance(i,Xt);t&&(Math.abs(l-c)<e.cvCutIn&&(l=c),l=e.round(l)),a.setRelative(i,Xt,l,o),e.zp0===0&&(i.xo=i.x,i.yo=i.y),a.touch(i),e.rp0=e.rp1=s}function Zu(t){const e=t.prog;let n=t.ip;const r=t.stack,s=e[++n];for(let i=0;i<s;i++)r.push(e[++n]);t.ip=n}function Ju(t){let e=t.ip;const n=t.prog,r=t.stack,s=n[++e];for(let i=0;i<s;i++){let a=n[++e]<<8|n[++e];a&32768&&(a=-((a^65535)+1)),r.push(a)}t.ip=e}function Qu(t){const e=t.stack;let n=t.store;n||(n=t.store=[]);const r=e.pop(),s=e.pop();n[s]=r}function eh(t){const e=t.stack,n=t.store,r=e.pop(),s=n&&n[r]||0;e.push(s)}function th(t){const e=t.stack,n=e.pop(),r=e.pop();t.cvt[r]=n/64}function nh(t){const e=t.stack,n=e.pop();e.push(t.cvt[n]*64)}function Qi(t,e){const n=e.stack,r=n.pop(),s=e.z2[r];n.push(e.dpv.distance(s,Xt,t,!1)*64)}function ea(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z1[r],a=e.z0[s],o=e.dpv.distance(a,i,t,t);e.stack.push(Math.round(o*64))}function rh(t){t.stack.push(t.ppem)}function sh(t){t.autoFlip=!0}function ih(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r<n?1:0)}function ah(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r<=n?1:0)}function oh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r>n?1:0)}function ch(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r>=n?1:0)}function lh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n===r?1:0)}function uh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n!==r?1:0)}function hh(t){const e=t.stack,n=e.pop();e.push(Math.trunc(n)&1?1:0)}function fh(t){const e=t.stack,n=e.pop();e.push(Math.trunc(n)&1?0:1)}function ph(t){t.stack.pop()||Gi(t,!0)}function dh(t){}function gh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n&&r?1:0)}function mh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(n||r?1:0)}function yh(t){const e=t.stack,n=e.pop();e.push(n?0:1)}function Ir(t,e){const n=e.stack,r=n.pop(),s=e.fv,i=e.pv,a=e.ppem,o=e.deltaBase+(t-1)*16,c=e.deltaShift,l=e.z0;for(let u=0;u<r;u++){const h=n.pop(),f=n.pop();if(o+((f&240)>>4)!==a)continue;let y=(f&15)-8;y>=0&&y++;const m=l[h];s.setRelative(m,m,y*c,i)}}function bh(t){const n=t.stack.pop();t.deltaBase=n}function xh(t){const n=t.stack.pop();t.deltaShift=Math.pow(.5,n)}function vh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r+n)}function Sh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r-n)}function wh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r*64/n)}function Th(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(r*n/64)}function Ch(t){const e=t.stack,n=e.pop();e.push(Math.abs(n))}function kh(t){const e=t.stack;let n=e.pop();e.push(-n)}function Fh(t){const e=t.stack,n=e.pop();e.push(Math.floor(n/64)*64)}function Eh(t){const e=t.stack,n=e.pop();e.push(Math.ceil(n/64)*64)}function Ln(t,e){const n=e.stack,r=n.pop();n.push(e.round(r/64)*64)}function Ah(t){const e=t.stack,n=e.pop(),r=e.pop();t.cvt[r]=n*t.ppem/t.font.unitsPerEm}function Rr(t,e){const n=e.stack,r=n.pop(),s=e.ppem,i=e.deltaBase+(t-1)*16,a=e.deltaShift;for(let o=0;o<r;o++){const c=n.pop(),l=n.pop();if(i+((l&240)>>4)!==s)continue;let h=(l&15)-8;h>=0&&h++;const f=h*a;e.cvt[c]+=f}}function Oh(t){let e=t.stack.pop();t.round=Ni;let n;switch(e&192){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw new Error("invalid SROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function Lh(t){let e=t.stack.pop();t.round=Ni;let n;switch(e&192){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(t.srPeriod=n,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*n;break;case 32:t.srPhase=.5*n;break;case 48:t.srPhase=.75*n;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*n}function Ih(t){t.round=fu}function Rh(t){t.round=gu}function Mh(t){t.round=mu}function Dh(t){t.stack.pop()}function ta(t,e){const n=e.stack,r=n.pop(),s=n.pop(),i=e.z2[r],a=e.z1[s];let o,c;t?(o=i.y-a.y,c=a.x-i.x):(o=a.x-i.x,c=a.y-i.y),e.dpv=Yt(o,c)}function Bh(t){const e=t.stack,n=e.pop();let r=0;n&1&&(r=35),n&32&&(r|=4096),e.push(r)}function _h(t){const e=t.stack,n=e.pop(),r=e.pop(),s=e.pop();e.push(r),e.push(n),e.push(s)}function Uh(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(Math.max(r,n))}function Ph(t){const e=t.stack,n=e.pop(),r=e.pop();e.push(Math.min(r,n))}function Nh(t){t.stack.pop()}function Gh(t){const e=t.stack.pop();let n=t.stack.pop();switch(e){case 1:t.inhibitGridFit=!!n;return;case 2:t.ignoreCvt=!!n;return;default:throw new Error("invalid INSTCTRL[] selector")}}function lt(t,e){const n=e.stack,r=e.prog;let s=e.ip;for(let i=0;i<t;i++)n.push(r[++s]);e.ip=s}function ut(t,e){let n=e.ip;const r=e.prog,s=e.stack;for(let i=0;i<t;i++){let a=r[++n]<<8|r[++n];a&32768&&(a=-((a^65535)+1)),s.push(a)}e.ip=n}function G(t,e,n,r,s,i){const a=i.stack,o=t&&a.pop(),c=a.pop(),l=i.rp0,u=i.z0[l],h=i.z1[c],f=i.minDis,p=i.fv,y=i.dpv;let m,b,v;m=y.distance(h,u,!0,!0),b=m>=0?1:-1,m=Math.abs(m),t&&(v=i.cvt[o],r&&Math.abs(m-v)<i.cvCutIn&&(m=v)),n&&m<f&&(m=f),r&&(m=i.round(m)),p.setRelative(h,u,b*m,y),p.touch(h),i.rp1=i.rp0,i.rp2=c,e&&(i.rp0=c)}Bi=[Hi.bind(void 0,Qe),Hi.bind(void 0,Ze),Wi.bind(void 0,Qe),Wi.bind(void 0,Ze),zi.bind(void 0,Qe),zi.bind(void 0,Ze),Vi.bind(void 0,0),Vi.bind(void 0,1),ji.bind(void 0,0),ji.bind(void 0,1),bu,xu,vu,Su,wu,Tu,Cu,ku,Fu,Eu,Au,Ou,Lu,Iu,Ru,Mu,Du,Bu,_u,Uu,void 0,void 0,Pu,Lr,Nu,Gu,Hu,Vu,ju,void 0,void 0,void 0,Wu,zu,qu,void 0,qi.bind(void 0,0),qi.bind(void 0,1),$i.bind(void 0,Qe),$i.bind(void 0,Ze),Yi.bind(void 0,0),Yi.bind(void 0,1),Xi.bind(void 0,0),Xi.bind(void 0,1),Ki.bind(void 0,0),Ki.bind(void 0,1),$u,Yu,Zi.bind(void 0,0),Zi.bind(void 0,1),Xu,Ku,Ji.bind(void 0,0),Ji.bind(void 0,1),Zu,Ju,Qu,eh,th,nh,Qi.bind(void 0,0),Qi.bind(void 0,1),void 0,ea.bind(void 0,0),ea.bind(void 0,1),rh,void 0,sh,void 0,void 0,ih,ah,oh,ch,lh,uh,hh,fh,ph,dh,gh,mh,yh,Ir.bind(void 0,1),bh,xh,vh,Sh,wh,Th,Ch,kh,Fh,Eh,Ln.bind(void 0,0),Ln.bind(void 0,1),Ln.bind(void 0,2),Ln.bind(void 0,3),void 0,void 0,void 0,void 0,Ah,Ir.bind(void 0,2),Ir.bind(void 0,3),Rr.bind(void 0,1),Rr.bind(void 0,2),Rr.bind(void 0,3),Oh,Lh,void 0,void 0,Ih,void 0,Rh,Mh,Lr,Lr,void 0,void 0,void 0,void 0,void 0,Dh,ta.bind(void 0,0),ta.bind(void 0,1),Bh,void 0,_h,Uh,Ph,Nh,Gh,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,lt.bind(void 0,1),lt.bind(void 0,2),lt.bind(void 0,3),lt.bind(void 0,4),lt.bind(void 0,5),lt.bind(void 0,6),lt.bind(void 0,7),lt.bind(void 0,8),ut.bind(void 0,1),ut.bind(void 0,2),ut.bind(void 0,3),ut.bind(void 0,4),ut.bind(void 0,5),ut.bind(void 0,6),ut.bind(void 0,7),ut.bind(void 0,8),G.bind(void 0,0,0,0,0,0),G.bind(void 0,0,0,0,0,1),G.bind(void 0,0,0,0,0,2),G.bind(void 0,0,0,0,0,3),G.bind(void 0,0,0,0,1,0),G.bind(void 0,0,0,0,1,1),G.bind(void 0,0,0,0,1,2),G.bind(void 0,0,0,0,1,3),G.bind(void 0,0,0,1,0,0),G.bind(void 0,0,0,1,0,1),G.bind(void 0,0,0,1,0,2),G.bind(void 0,0,0,1,0,3),G.bind(void 0,0,0,1,1,0),G.bind(void 0,0,0,1,1,1),G.bind(void 0,0,0,1,1,2),G.bind(void 0,0,0,1,1,3),G.bind(void 0,0,1,0,0,0),G.bind(void 0,0,1,0,0,1),G.bind(void 0,0,1,0,0,2),G.bind(void 0,0,1,0,0,3),G.bind(void 0,0,1,0,1,0),G.bind(void 0,0,1,0,1,1),G.bind(void 0,0,1,0,1,2),G.bind(void 0,0,1,0,1,3),G.bind(void 0,0,1,1,0,0),G.bind(void 0,0,1,1,0,1),G.bind(void 0,0,1,1,0,2),G.bind(void 0,0,1,1,0,3),G.bind(void 0,0,1,1,1,0),G.bind(void 0,0,1,1,1,1),G.bind(void 0,0,1,1,1,2),G.bind(void 0,0,1,1,1,3),G.bind(void 0,1,0,0,0,0),G.bind(void 0,1,0,0,0,1),G.bind(void 0,1,0,0,0,2),G.bind(void 0,1,0,0,0,3),G.bind(void 0,1,0,0,1,0),G.bind(void 0,1,0,0,1,1),G.bind(void 0,1,0,0,1,2),G.bind(void 0,1,0,0,1,3),G.bind(void 0,1,0,1,0,0),G.bind(void 0,1,0,1,0,1),G.bind(void 0,1,0,1,0,2),G.bind(void 0,1,0,1,0,3),G.bind(void 0,1,0,1,1,0),G.bind(void 0,1,0,1,1,1),G.bind(void 0,1,0,1,1,2),G.bind(void 0,1,0,1,1,3),G.bind(void 0,1,1,0,0,0),G.bind(void 0,1,1,0,0,1),G.bind(void 0,1,1,0,0,2),G.bind(void 0,1,1,0,0,3),G.bind(void 0,1,1,0,1,0),G.bind(void 0,1,1,0,1,1),G.bind(void 0,1,1,0,1,2),G.bind(void 0,1,1,0,1,3),G.bind(void 0,1,1,1,0,0),G.bind(void 0,1,1,1,0,1),G.bind(void 0,1,1,1,0,2),G.bind(void 0,1,1,1,0,3),G.bind(void 0,1,1,1,1,0),G.bind(void 0,1,1,1,1,1),G.bind(void 0,1,1,1,1,2),G.bind(void 0,1,1,1,1,3)];var Hh=Ui;function Mt(t){this.char=t,this.state={},this.activeState=null}function Mr(t,e,n){this.contextName=n,this.startIndex=t,this.endOffset=e}function Wh(t,e,n){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=n}function Ce(t,e){this.context=t,this.index=e,this.length=t.length,this.current=t[e],this.backtrack=t.slice(0,e),this.lookahead=t.slice(e+1)}function In(t){this.eventId=t,this.subscribers=[]}function zh(t){const e=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let r=0;r<e.length;r++){const s=e[r];Object.defineProperty(this.events,s,{value:new In(s)})}if(t)for(let r=0;r<e.length;r++){const s=e[r],i=t[s];typeof i=="function"&&this.events[s].subscribe(i)}const n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let r=0;r<n.length;r++){const s=n[r];this.events[s].subscribe(this.updateContextsRanges)}}function oe(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],zh.call(this,t)}Mt.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState},Mt.prototype.getState=function(t){return this.state[t]||null},oe.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length},oe.prototype.composeRUD=function(t){const n=t.map(s=>this[s[0]].apply(this,s.slice(1).concat(!0))),r=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(n.every(r))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(r)};this.dispatch("composeRUD",[n.filter(s=>!r(s))])},oe.prototype.replaceRange=function(t,e,n,r){e=e!==null?e:this.tokens.length;const s=n.every(i=>i instanceof Mt);if(!isNaN(t)&&this.inboundIndex(t)&&s){const i=this.tokens.splice.apply(this.tokens,[t,e].concat(n));return r||this.dispatch("replaceToken",[t,e,n]),[i,n]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},oe.prototype.replaceToken=function(t,e,n){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof Mt){const r=this.tokens.splice(t,1,e);return n||this.dispatch("replaceToken",[t,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}},oe.prototype.removeRange=function(t,e,n){e=isNaN(e)?this.tokens.length:e;const r=this.tokens.splice(t,e);return n||this.dispatch("removeRange",[r,t,e]),r},oe.prototype.removeToken=function(t,e){if(!isNaN(t)&&this.inboundIndex(t)){const n=this.tokens.splice(t,1);return e||this.dispatch("removeToken",[n,t]),n}else return{FAIL:"removeToken: invalid token index."}},oe.prototype.insertToken=function(t,e,n){return t.every(s=>s instanceof Mt)?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),n||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}},oe.prototype.registerModifier=function(t,e,n){this.events.newToken.subscribe(function(r,s){const i=[r,s],a=e===null||e.apply(this,i)===!0,o=[r,s];if(a){let c=n.apply(this,o);r.setState(t,c)}}),this.registeredModifiers.push(t)},In.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:`invalid '${this.eventId}' event handler`}},In.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)},Ce.prototype.setCurrentIndex=function(t){this.index=t,this.current=this.context[t],this.backtrack=this.context.slice(0,t),this.lookahead=this.context.slice(t+1)},Ce.prototype.get=function(t){switch(!0){case t===0:return this.current;case(t<0&&Math.abs(t)<=this.backtrack.length):return this.backtrack.slice(t)[0];case(t>0&&t<=this.lookahead.length):return this.lookahead[t-1];default:return null}},oe.prototype.rangeToText=function(t){if(t instanceof Mr)return this.getRangeTokens(t).map(e=>e.char).join("")},oe.prototype.getText=function(){return this.tokens.map(t=>t.char).join("")},oe.prototype.getContext=function(t){let e=this.registeredContexts[t];return e||null},oe.prototype.on=function(t,e){const n=this.events[t];return n?n.subscribe(e):null},oe.prototype.dispatch=function(t,e){const n=this.events[t];if(n instanceof In)for(let r=0;r<n.subscribers.length;r++)n.subscribers[r].apply(this,e||[])},oe.prototype.registerContextChecker=function(t,e,n){if(this.getContext(t))return{FAIL:`context name '${t}' is already registered.`};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof n!="function")return{FAIL:"missing context end check."};const r=new Wh(t,e,n);return this.registeredContexts[t]=r,this.contextCheckers.push(r),r},oe.prototype.getRangeTokens=function(t){const e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))},oe.prototype.getContextRanges=function(t){const e=this.getContext(t);return e?e.ranges:{FAIL:`context checker '${t}' is not registered.`}},oe.prototype.resetContextsRanges=function(){const t=this.registeredContexts;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];n.ranges=[]}},oe.prototype.updateContextsRanges=function(){this.resetContextsRanges();const t=this.tokens.map(e=>e.char);for(let e=0;e<t.length;e++){const n=new Ce(t,e);this.runContextCheck(n)}this.dispatch("updateContextsRanges",[this.registeredContexts])},oe.prototype.setEndOffset=function(t,e){const n=this.getContext(e).openRange.startIndex;let r=new Mr(n,t,e);const s=this.getContext(e).ranges;return r.rangeId=`${e}.${s.length}`,s.push(r),this.getContext(e).openRange=null,r},oe.prototype.runContextCheck=function(t){const e=t.index;for(let n=0;n<this.contextCheckers.length;n++){const r=this.contextCheckers[n];let s=r.contextName,i=this.getContext(s).openRange;if(!i&&r.checkStart(t)&&(i=new Mr(e,null,s),this.getContext(s).openRange=i,this.dispatch("contextStart",[s,e])),i&&r.checkEnd(t)){const a=e-i.startIndex+1,o=this.setEndOffset(a,s);this.dispatch("contextEnd",[s,o])}}},oe.prototype.tokenize=function(t){this.tokens=[],this.resetContextsRanges();let e=Array.from(t);this.dispatch("start");for(let n=0;n<e.length;n++){const r=e[n],s=new Ce(e,n);this.dispatch("next",[s]),this.runContextCheck(s);let i=new Mt(r);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};var Vh=oe;function ht(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function na(t){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(t)}function ft(t){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(t)}function Rn(t){return/[\u0E00-\u0E7F]/.test(t)}function Mn(t){return/[A-z]/.test(t)}function jh(t){return/\s/.test(t)}function Re(t){this.font=t,this.features={}}function pt(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function dt(t,e){if(!t)return-1;switch(e.format){case 1:return e.glyphs.indexOf(t);case 2:{let n=e.ranges;for(let r=0;r<n.length;r++){const s=n[r];if(t>=s.start&&t<=s.end){let i=t-s.start;return s.index+i}}break}default:return-1}return-1}function qh(t,e){return dt(t,e.coverage)===-1?null:t+e.deltaGlyphId}function $h(t,e){let n=dt(t,e.coverage);return n===-1?null:e.substitute[n]}function Dr(t,e){let n=[];for(let r=0;r<t.length;r++){const s=t[r];let i=e.current;i=Array.isArray(i)?i[0]:i;const a=dt(i,s);a!==-1&&n.push(a)}return n.length!==t.length?-1:n}function Yh(t,e){const n=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<n)return[];let r=Dr(e.inputCoverage,t);if(r===-1)return[];const s=e.inputCoverage.length-1;if(t.lookahead.length<e.lookaheadCoverage.length)return[];let i=t.lookahead.slice(s);for(;i.length&&ft(i[0].char);)i.shift();const a=new Ce(i,0);let o=Dr(e.lookaheadCoverage,a),c=[].concat(t.backtrack);for(c.reverse();c.length&&ft(c[0].char);)c.shift();if(c.length<e.backtrackCoverage.length)return[];const l=new Ce(c,0);let u=Dr(e.backtrackCoverage,l);const h=r.length===e.inputCoverage.length&&o.length===e.lookaheadCoverage.length&&u.length===e.backtrackCoverage.length;let f=[];if(h)for(let p=0;p<e.lookupRecords.length;p++){const y=e.lookupRecords[p],m=y.lookupListIndex,b=this.getLookupByIndex(m);for(let v=0;v<b.subtables.length;v++){let w=b.subtables[v],T,C=this.getSubstitutionType(b,w);if(C==="71"?(C=this.getSubstitutionType(w,w.extension),T=this.getLookupMethod(w,w.extension),w=w.extension):T=this.getLookupMethod(b,w),C==="12"){const E=t.get(y.sequenceIndex),R=T(E);R&&f.push(R)}else if(C==="21"){const E=t.get(y.sequenceIndex),R=T(E);R&&f.push(R)}else throw new Error(`Substitution type ${C} is not supported in chaining substitution`)}}return f}function Xh(t,e){let n=t.current,r=dt(n,e.coverage);if(r===-1)return null;let s,i=e.ligatureSets[r];for(let a=0;a<i.length;a++){s=i[a];for(let o=0;o<s.components.length;o++){const c=t.lookahead[o],l=s.components[o];if(c!==l)break;if(o===s.components.length-1)return s}}return null}function Kh(t,e){let n=t.current;if(dt(n,e.coverage)===-1)return null;for(const s of e.ruleSets)for(const i of s){let a=!0;for(let o=0;o<i.input.length;o++)if(t.lookahead[o]!==i.input[o]){a=!1;break}if(a){let o=[];o.push(n);for(let l=0;l<i.input.length;l++)o.push(i.input[l]);const c=(l,u)=>{const{lookupListIndex:h,sequenceIndex:f}=u,{subtables:p}=this.getLookupByIndex(h);for(const y of p)dt(l[f],y.coverage)!==-1&&(l[f]=y.deltaGlyphId)};for(let l=0;l<i.lookupRecords.length;l++){const u=i.lookupRecords[l];c(o,u)}return o}}return null}function Zh(t,e){if(t.context.length<e.coverages.length)return[];for(let r=0;r<e.coverages.length;r++){let s=t.get(r);if(s=Array.isArray(s)?s[0]:s,dt(s,e.coverages[r])===-1)return[]}let n=[];for(let r=0;r<e.lookupRecords.length;r++){const s=e.lookupRecords[r],i=s.lookupListIndex,a=this.getLookupByIndex(i);for(let o=0;o<a.subtables.length;o++){let c=a.subtables[o],l,u=this.getSubstitutionType(a,c);if(u==="71"?(u=this.getSubstitutionType(c,c.extension),l=this.getLookupMethod(c,c.extension),c=c.extension):l=this.getLookupMethod(a,c),u==="12"){const h=t.get(s.sequenceIndex),f=l(h);f&&n.push(f)}else if(u==="21"){const h=t.get(s.sequenceIndex),f=l(h);f&&n.push(f)}}}return n}function Jh(t,e){let n=dt(t,e.coverage);return n===-1?null:e.sequences[n]}Re.prototype.getDefaultScriptFeaturesIndexes=function(){const t=this.font.tables.gsub.scripts;for(let e=0;e<t.length;e++){const n=t[e];if(n.tag==="DFLT")return n.script.defaultLangSys.featureIndexes}return[]},Re.prototype.getScriptFeaturesIndexes=function(t){if(!this.font.tables.gsub)return[];if(!t)return this.getDefaultScriptFeaturesIndexes();const n=this.font.tables.gsub.scripts;for(let r=0;r<n.length;r++){const s=n[r];if(s.tag===t&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;{let i=s.langSysRecords;if(i)for(let a=0;a<i.length;a++){const o=i[a];if(o.tag===t)return o.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Re.prototype.mapTagsToFeatures=function(t,e){let n={};for(let r=0;r<t.length;r++){const s=t[r].tag,i=t[r].feature;n[s]=i}this.features[e].tags=n},Re.prototype.getScriptFeatures=function(t){let e=this.features[t];if(Object.prototype.hasOwnProperty.call(this.features,t))return e;const n=this.getScriptFeaturesIndexes(t);if(!n)return null;const r=this.font.tables.gsub;return e=n.map(s=>r.features[s]),this.features[t]=e,this.mapTagsToFeatures(e,t),e},Re.prototype.getSubstitutionType=function(t,e){const n=t.lookupType.toString(),r=e.substFormat.toString();return n+r},Re.prototype.getLookupMethod=function(t,e){let n=this.getSubstitutionType(t,e);switch(n){case"11":return r=>qh.apply(this,[r,e]);case"12":return r=>$h.apply(this,[r,e]);case"63":return r=>Yh.apply(this,[r,e]);case"41":return r=>Xh.apply(this,[r,e]);case"21":return r=>Jh.apply(this,[r,e]);case"51":return r=>Kh.apply(this,[r,e]);case"53":return r=>Zh.apply(this,[r,e]);default:throw new Error(`substitutionType : ${n} lookupType: ${t.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}},Re.prototype.lookupFeature=function(t){let e=t.contextParams,n=e.index;const r=this.getFeature({tag:t.tag,script:t.script});if(!r)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${t.tag}' for script '${t.script}'.`);const s=this.getFeatureLookups(r),i=[].concat(e.context);for(let a=0;a<s.length;a++){const o=s[a],c=this.getLookupSubtables(o);for(let l=0;l<c.length;l++){let u=c[l],h=this.getSubstitutionType(o,u),f;h==="71"?(h=this.getSubstitutionType(u,u.extension),f=this.getLookupMethod(u,u.extension),u=u.extension):f=this.getLookupMethod(o,u);let p;switch(h){case"11":p=f(e.current),p&&i.splice(n,1,new pt({id:11,tag:t.tag,substitution:p}));break;case"12":p=f(e.current),p&&i.splice(n,1,new pt({id:12,tag:t.tag,substitution:p}));break;case"63":p=f(e),Array.isArray(p)&&p.length&&i.splice(n,1,new pt({id:63,tag:t.tag,substitution:p}));break;case"41":p=f(e),p&&i.splice(n,1,new pt({id:41,tag:t.tag,substitution:p}));break;case"21":p=f(e.current),p&&i.splice(n,1,new pt({id:21,tag:t.tag,substitution:p}));break;case"51":case"53":p=f(e),Array.isArray(p)&&p.length&&i.splice(n,1,new pt({id:parseInt(h),tag:t.tag,substitution:p}));break}e=new Ce(i,n),!(Array.isArray(p)&&!p.length)&&(p=null)}}return i.length?i:null},Re.prototype.supports=function(t){if(!t.script)return!1;this.getScriptFeatures(t.script);const e=Object.prototype.hasOwnProperty.call(this.features,t.script);if(!t.tag)return e;const n=this.features[t.script].some(r=>r.tag===t.tag);return e&&n},Re.prototype.getLookupSubtables=function(t){return t.subtables||null},Re.prototype.getLookupByIndex=function(t){return this.font.tables.gsub.lookups[t]||null},Re.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Re.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const n=this.features[e.script];return n?n.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var Qh=Re;function ef(t){const e=t.current,n=t.get(-1);return n===null&&ht(e)||!ht(n)&&ht(e)}function tf(t){const e=t.get(1);return e===null||!ht(e)}var nf={startCheck:ef,endCheck:tf};function rf(t){const e=t.current,n=t.get(-1);return(ht(e)||ft(e))&&!ht(n)}function sf(t){const e=t.get(1);switch(!0){case e===null:return!0;case(!ht(e)&&!ft(e)):{const n=jh(e);if(!n)return!0;if(n){let r=!1;if(r=t.lookahead.some(s=>ht(s)||ft(s)),!r)return!0}break}default:return!1}}var af={startCheck:rf,endCheck:sf};function of(t,e,n){e[n].setState(t.tag,t.substitution)}function cf(t,e,n){e[n].setState(t.tag,t.substitution)}function Br(t,e,n){for(let r=0;r<t.substitution.length;r++){const s=t.substitution[r],i=e[n+r];if(Array.isArray(s)){s.length?i.setState(t.tag,s[0]):i.setState("deleted",!0);continue}i.setState(t.tag,s)}}function lf(t,e,n){let r=e[n];r.setState(t.tag,t.substitution.ligGlyph);const s=t.substitution.components.length;for(let i=0;i<s;i++)r=e[n+i+1],r.setState("deleted",!0)}var ra={11:of,12:cf,63:Br,41:lf,51:Br,53:Br};function uf(t,e,n){t instanceof pt&&ra[t.id]&&ra[t.id](t,e,n)}var Tt=uf;function hf(t){let e=[].concat(t.backtrack);for(let n=e.length-1;n>=0;n--){const r=e[n],s=na(r),i=ft(r);if(!s&&!i)return!0;if(s)return!1}return!1}function ff(t){if(na(t.current))return!1;for(let e=0;e<t.lookahead.length;e++){const n=t.lookahead[e];if(!ft(n))return!0}return!1}function pf(t){const e="arab",n=this.featuresTags[e],r=this.tokenizer.getRangeTokens(t);if(r.length===1)return;let s=new Ce(r.map(a=>a.getState("glyphIndex")),0);const i=new Ce(r.map(a=>a.char),0);for(let a=0;a<r.length;a++){const o=r[a];if(ft(o.char))continue;s.setCurrentIndex(a),i.setCurrentIndex(a);let c=0;hf(i)&&(c|=1),ff(i)&&(c|=2);let l;switch(c){case 1:l="fina";break;case 2:l="init";break;case 3:l="medi";break}if(n.indexOf(l)===-1)continue;let u=this.query.lookupFeature({tag:l,script:e,contextParams:s});if(u instanceof Error){console.info(u.message);continue}for(let h=0;h<u.length;h++){const f=u[h];f instanceof pt&&(Tt(f,r,h),s.context[h]=f.substitution)}}}var df=pf;function sa(t,e){const n=t.map(r=>r.activeState.value);return new Ce(n,0)}function gf(t){const e="arab";let n=this.tokenizer.getRangeTokens(t),r=sa(n);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"rlig",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];Tt(o,n,s)}r=sa(n)}}}var mf=gf;function yf(t){return t.index===0&&t.context.length>1}function bf(t){return t.index===t.context.length-1}var xf={startCheck:yf,endCheck:bf};function ia(t,e){const n=t.map(r=>r.activeState.value);return new Ce(n,0)}function vf(t){const e="delf",n="ccmp";let r=this.tokenizer.getRangeTokens(t),s=ia(r);for(let i=0;i<s.context.length;i++){if(!this.query.getFeature({tag:n,script:e,contextParams:s}))continue;s.setCurrentIndex(i);let a=this.query.lookupFeature({tag:n,script:e,contextParams:s});if(a.length){for(let o=0;o<a.length;o++){const c=a[o];Tt(c,r,i)}s=ia(r)}}}var Sf=vf;function wf(t){const e=t.current,n=t.get(-1);return n===null&&Mn(e)||!Mn(n)&&Mn(e)}function Tf(t){const e=t.get(1);return e===null||!Mn(e)}var Cf={startCheck:wf,endCheck:Tf};function aa(t,e){const n=t.map(r=>r.activeState.value);return new Ce(n,0)}function kf(t){const e="latn";let n=this.tokenizer.getRangeTokens(t),r=aa(n);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"liga",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];Tt(o,n,s)}r=aa(n)}}}var Ff=kf;function Ef(t){const e=t.current,n=t.get(-1);return n===null&&Rn(e)||!Rn(n)&&Rn(e)}function Af(t){const e=t.get(1);return e===null||!Rn(e)}var Of={startCheck:Ef,endCheck:Af};function oa(t,e){const n=t.map(r=>r.activeState.value);return new Ce(n,e||0)}function Lf(t){const e="thai";let n=this.tokenizer.getRangeTokens(t),r=oa(n,0);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"ccmp",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];Tt(o,n,s)}r=oa(n,s)}}}var If=Lf;function ca(t,e){const n=t.map(r=>r.activeState.value);return new Ce(n,e||0)}function Rf(t){const e="thai";let n=this.tokenizer.getRangeTokens(t),r=ca(n,0);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"liga",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];Tt(o,n,s)}r=ca(n,s)}}}var Mf=Rf;function la(t,e){const n=t.map(r=>r.activeState.value);return new Ce(n,e||0)}function Df(t){const e="thai";let n=this.tokenizer.getRangeTokens(t),r=la(n,0);for(let s=0;s<r.context.length;s++){r.setCurrentIndex(s);let i=this.query.lookupFeature({tag:"rlig",script:e,contextParams:r});if(i.length){for(let a=0;a<i.length;a++){const o=i[a];Tt(o,n,s)}r=la(n,s)}}}var Bf=Df;function _r(t){if(t===null)return!1;const e=t.codePointAt(0);return e>=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function _f(t){const e=t.current,n=t.get(1);return n===null&&_r(e)||_r(n)}function Uf(t){const e=t.get(1);return e===null||!_r(e)}var Pf={startCheck:_f,endCheck:Uf};function Nf(t){const e=this.query.font,n=this.tokenizer.getRangeTokens(t);if(n[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const r=n[0].char.codePointAt(0),s=n[1].char.codePointAt(0),i=e.tables.cmap.varSelectorList[s];if(i!==void 0&&i.nonDefaultUVS){const a=i.nonDefaultUVS.uvsMappings;if(a[r]){const o=a[r].glyphID;e.glyphs.glyphs[o]!==void 0&&n[0].setState("glyphIndex",o)}}}}var Gf=Nf;function _e(t){this.baseDir=t||"ltr",this.tokenizer=new Vh,this.featuresTags={}}_e.prototype.setText=function(t){this.text=t},_e.prototype.contextChecks={ccmpReplacementCheck:xf,latinWordCheck:Cf,arabicWordCheck:nf,arabicSentenceCheck:af,thaiWordCheck:Of,unicodeVariationSequenceCheck:Pf};function Dt(t){const e=this.contextChecks[`${t}Check`];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function Hf(){return Dt.call(this,"ccmpReplacement"),Dt.call(this,"latinWord"),Dt.call(this,"arabicWord"),Dt.call(this,"arabicSentence"),Dt.call(this,"thaiWord"),Dt.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function Wf(){const t=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;e<t.length;e++){const n=t[e];let r=this.tokenizer.getRangeTokens(n);this.tokenizer.replaceRange(n.startIndex,n.endOffset,r.reverse())}}_e.prototype.registerFeatures=function(t,e){const n=e.filter(r=>this.query.supports({script:t,tag:r}));Object.prototype.hasOwnProperty.call(this.featuresTags,t)?this.featuresTags[t]=this.featuresTags[t].concat(n):this.featuresTags[t]=n},_e.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Qh(t));for(let n=0;n<e.length;n++){const r=e[n];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}},_e.prototype.registerModifier=function(t,e,n){this.tokenizer.registerModifier(t,e,n)};function Kt(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function zf(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;Kt.call(this);const e=this.tokenizer.getContextRanges("arabicWord");for(let n=0;n<e.length;n++){const r=e[n];df.call(this,r)}}function Vf(){Kt.call(this);const t=this.tokenizer.getContextRanges("ccmpReplacement");for(let e=0;e<t.length;e++){const n=t[e];Sf.call(this,n)}}function jf(){if(!this.hasFeatureEnabled("arab","rlig"))return;Kt.call(this);const t=this.tokenizer.getContextRanges("arabicWord");for(let e=0;e<t.length;e++){const n=t[e];mf.call(this,n)}}function qf(){if(!this.hasFeatureEnabled("latn","liga"))return;Kt.call(this);const t=this.tokenizer.getContextRanges("latinWord");for(let e=0;e<t.length;e++){const n=t[e];Ff.call(this,n)}}function $f(){const t=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let e=0;e<t.length;e++){const n=t[e];Gf.call(this,n)}}function Yf(){Kt.call(this);const t=this.tokenizer.getContextRanges("thaiWord");for(let e=0;e<t.length;e++){const n=t[e];this.hasFeatureEnabled("thai","liga")&&Mf.call(this,n),this.hasFeatureEnabled("thai","rlig")&&Bf.call(this,n),this.hasFeatureEnabled("thai","ccmp")&&If.call(this,n)}}_e.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)},_e.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&Vf.call(this),this.checkContextReady("arabicWord")&&(zf.call(this),jf.call(this)),this.checkContextReady("latinWord")&&qf.call(this),this.checkContextReady("arabicSentence")&&Wf.call(this),this.checkContextReady("thaiWord")&&Yf.call(this),this.checkContextReady("unicodeVariationSequence")&&$f.call(this)},_e.prototype.hasFeatureEnabled=function(t,e){return(this.featuresTags[t]||[]).indexOf(e)!==-1},_e.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),Hf.call(this),this.applyFeaturesToContexts())},_e.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()},_e.prototype.getTextGlyphs=function(t){this.processText(t);let e=[];for(let n=0;n<this.tokenizer.tokens.length;n++){const r=this.tokenizer.tokens[n];if(r.state.deleted)continue;const s=r.activeState.value;e.push(Array.isArray(s)?s[0]:s)}return e};var Xf=_e;function Ur(t){return{fontFamily:{en:t.familyName||" "},fontSubfamily:{en:t.styleName||" "},fullName:{en:t.fullName||t.familyName+" "+t.styleName},postScriptName:{en:t.postScriptName||(t.familyName+t.styleName).replace(/\s/g,"")},designer:{en:t.designer||" "},designerURL:{en:t.designerURL||" "},manufacturer:{en:t.manufacturer||" "},manufacturerURL:{en:t.manufacturerURL||" "},license:{en:t.license||" "},licenseURL:{en:t.licenseURL||" "},version:{en:t.version||"Version 0.1"},description:{en:t.description||" "},copyright:{en:t.copyright||" "},trademark:{en:t.trademark||" "}}}function Q(t){if(t=t||{},t.tables=t.tables||{},!t.empty){if(!t.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!t.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!t.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!t.ascender)throw new Error("When creating a new Font object, ascender is required.");if(t.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=Ur(t),this.names.macintosh=Ur(t),this.names.windows=Ur(t),this.unitsPerEm=t.unitsPerEm||1e3,this.ascender=t.ascender,this.descender=t.descender,this.createdTimestamp=t.createdTimestamp,this.italicAngle=t.italicAngle||0,this.weightClass=t.weightClass||0;let e=0;t.fsSelection?e=t.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!t.panose||!Array.isArray(t.panose))&&(t.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(t.tables,{os2:Object.assign({usWeightClass:t.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:t.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:t.panose[0]||0,bSerifStyle:t.panose[1]||0,bWeight:t.panose[2]||0,bProportion:t.panose[3]||0,bContrast:t.panose[4]||0,bStrokeVariation:t.panose[5]||0,bArmStyle:t.panose[6]||0,bLetterform:t.panose[7]||0,bMidline:t.panose[8]||0,bXHeight:t.panose[9]||0,fsSelection:e},t.tables.os2)})}this.supported=!0,this.glyphs=new Xe.GlyphSet(this,t.glyphs||[]),this.encoding=new Ws(this),this.position=new zl(this),this.substitution=new Kl(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,n,r)=>(e[n]=r,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new hu(this)),!0)}),this.palettes=new Oi(this),this.layers=new Zl(this),this.svgImages=new Jl(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new Hh(this):null}})}Q.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)>0},Q.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)},Q.prototype.charToGlyph=function(t){const e=this.charToGlyphIndex(t);let n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n},Q.prototype.updateFeatures=function(t){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(n=>t[n])}:e)},Q.prototype.stringToGlyphIndexes=function(t,e){const n=new Xf,r=i=>this.charToGlyphIndex(i.char);n.registerModifier("glyphIndex",null,r);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return n.applyFeatures(this,s),n.getTextGlyphs(t)},Q.prototype.stringToGlyphs=function(t,e){const n=this.stringToGlyphIndexes(t,e);let r=n.length;const s=new Array(r),i=this.glyphs.get(0);for(let a=0;a<r;a+=1)s[a]=this.glyphs.get(n[a])||i;return s},Q.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)},Q.prototype.nameToGlyph=function(t){const e=this.nameToGlyphIndex(t);let n=this.glyphs.get(e);return n||(n=this.glyphs.get(0)),n},Q.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""},Q.prototype.getKerningValue=function(t,e){t=t.index||t,e=e.index||e;const n=this.position.defaultKerningTables;return n?this.position.getKerningValue(n,t,e):this.kerningPairs[t+","+e]||0},Q.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Q.prototype.forEachGlyph=function(t,e,n,r,s,i){e=e!==void 0?e:0,n=n!==void 0?n:0,r=r!==void 0?r:72,s=Object.assign({},this.defaultRenderOptions,s);const a=1/this.unitsPerEm*r,o=this.stringToGlyphs(t,s);let c;if(s.kerning){const l=s.script||this.position.getDefaultScriptName();c=this.position.getKerningTables(l,s.language)}for(let l=0;l<o.length;l+=1){const u=o[l];if(i.call(this,u,e,n,r,s),u.advanceWidth&&(e+=u.advanceWidth*a),s.kerning&&l<o.length-1){const h=c?this.position.getKerningValue(c,u.index,o[l+1].index):this.getKerningValue(u,o[l+1]);e+=h*a}s.letterSpacing?e+=s.letterSpacing*r:s.tracking&&(e+=s.tracking/1e3*r)}return e},Q.prototype.getPath=function(t,e,n,r,s){s=Object.assign({},this.defaultRenderOptions,s);const i=new Ft;if(i._layers=[],Js(this,i),i.stroke){const a=1/(i.unitsPerEm||1e3)*r;i.strokeWidth*=a}return this.forEachGlyph(t,e,n,r,s,(a,o,c,l)=>{const u=a.getPath(o,c,l,s,this);if(s.drawSVG||s.drawLayers){const h=u._layers;if(h&&h.length){for(let f=0;f<h.length;f++){const p=h[f];i._layers.push(p)}return}}i.extend(u)}),i},Q.prototype.getPaths=function(t,e,n,r,s){s=Object.assign({},this.defaultRenderOptions,s);const i=[];return this.forEachGlyph(t,e,n,r,s,function(a,o,c,l){const u=a.getPath(o,c,l,s,this);i.push(u)}),i},Q.prototype.getAdvanceWidth=function(t,e,n){return n=Object.assign({},this.defaultRenderOptions,n),this.forEachGlyph(t,0,0,e,n,function(){})},Q.prototype.draw=function(t,e,n,r,s,i){this.getPath(e,n,r,s,i).draw(t)},Q.prototype.drawPoints=function(t,e,n,r,s,i){i=Object.assign({},this.defaultRenderOptions,i),this.forEachGlyph(e,n,r,s,i,function(a,o,c,l){a.drawPoints(t,o,c,l,i,this)})},Q.prototype.drawMetrics=function(t,e,n,r,s,i){i=Object.assign({},this.defaultRenderOptions,i),this.forEachGlyph(e,n,r,s,i,function(a,o,c,l){a.drawMetrics(t,o,c,l)})},Q.prototype.getEnglishName=function(t){const e=(this.names.unicode||this.names.macintosh||this.names.windows)[t];if(e)return e.en},Q.prototype.validate=function(){const t=[],e=this;function n(s,i){s||(console.warn(`[opentype.js] ${i}`),t.push(i))}function r(s){const i=e.getEnglishName(s);n(i&&i.trim().length>0,"No English "+s+" specified.")}if(r("fontFamily"),r("weightName"),r("manufacturer"),r("copyright"),r("version"),n(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let i=-1;for(let a=0;a<s.length;a++){const o=s[a].glyphID;if(n(i<s[a].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${o} comes after ${i}`),i>s[a].glyphID)break;i=o}}return t},Q.prototype.toTables=function(){return Wl.fontToTable(this)},Q.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Q.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),n=new ArrayBuffer(e.length),r=new Uint8Array(n);for(let s=0;s<e.length;s++)r[s]=e[s];return n},Q.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Q.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Q.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Q.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Q.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Kf=Q;function Zf(t,e){const n=new _.Parser(t,e),r=n.parseUShort(),s=n.parseUShort();r!==1&&console.warn(`Unsupported hvar table version ${r}.${s}`);const i=[r,s],a=n.parsePointer32(function(){return this.parseItemVariationStore()}),o=n.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),c=n.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),l=n.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:i,itemVariationStore:a,advanceWidth:o,lsb:c,rsb:l}}function Jf(){console.warn("Writing of hvar tables is not yet supported.")}var Qf={make:Jf,parse:Zf},ep=function(){return{coverage:this.parsePointer(k.coverage),attachPoints:this.parseList(k.pointer(k.uShortList))}},tp=function(){var t=this.parseUShort();if(H.argument(t===1||t===2||t===3,"Unsupported CaretValue table version."),t===1)return{coordinate:this.parseShort()};if(t===2)return{pointindex:this.parseShort()};if(t===3)return{coordinate:this.parseShort()}},np=function(){return this.parseList(k.pointer(tp))},rp=function(){return{coverage:this.parsePointer(k.coverage),ligGlyphs:this.parseList(k.pointer(np))}},sp=function(){return this.parseUShort(),this.parseList(k.pointer(k.coverage))};function ip(t,e){e=e||0;const n=new k(t,e),r=n.parseVersion(1);H.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var s={version:r,classDef:n.parsePointer(k.classDef),attachList:n.parsePointer(ep),ligCaretList:n.parsePointer(rp),markAttachClassDef:n.parsePointer(k.classDef)};return r>=1.2&&(s.markGlyphSets=n.parsePointer(sp)),s}var ap={parse:ip},je=new Array(10);je[1]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{posFormat:1,coverage:this.parsePointer(k.coverage),value:this.parseValueRecord()};if(n===2)return{posFormat:2,coverage:this.parsePointer(k.coverage),values:this.parseValueRecordList()};H.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},je[2]=function(){const e=this.offset+this.relativeOffset,n=this.parseUShort();H.assert(n===1||n===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const r=this.parsePointer(k.coverage),s=this.parseUShort(),i=this.parseUShort();if(n===1)return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(k.pointer(k.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(n===2){const a=this.parsePointer(k.classDef),o=this.parsePointer(k.classDef),c=this.parseUShort(),l=this.parseUShort();return{posFormat:n,coverage:r,valueFormat1:s,valueFormat2:i,classDef1:a,classDef2:o,class1Count:c,class2Count:l,classRecords:this.parseList(c,k.list(l,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}},je[3]=function(){return{error:"GPOS Lookup 3 not supported"}},je[4]=function(){return{error:"GPOS Lookup 4 not supported"}},je[5]=function(){return{error:"GPOS Lookup 5 not supported"}},je[6]=function(){return{error:"GPOS Lookup 6 not supported"}},je[7]=function(){return{error:"GPOS Lookup 7 not supported"}},je[8]=function(){return{error:"GPOS Lookup 8 not supported"}},je[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function op(t,e){e=e||0;const n=new k(t,e),r=n.parseVersion(1);return H.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(je)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(je),variations:n.parseFeatureVariationsList()}}var cp=new Array(10);function lp(t){return new L.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new L.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new L.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new L.LookupList(t.lookups,cp)}])}var up={parse:op,make:lp};function hp(t){const e={};t.skip("uShort");const n=t.parseUShort();H.argument(n===0,"Unsupported kern sub-table version."),t.skip("uShort",2);const r=t.parseUShort();t.skip("uShort",3);for(let s=0;s<r;s+=1){const i=t.parseUShort(),a=t.parseUShort(),o=t.parseShort();e[i+","+a]=o}return e}function fp(t){const e={};t.skip("uShort"),t.parseULong()>1&&console.warn("Only the first kern subtable is supported."),t.skip("uLong");const s=t.parseUShort()&255;if(t.skip("uShort"),s===0){const i=t.parseUShort();t.skip("uShort",3);for(let a=0;a<i;a+=1){const o=t.parseUShort(),c=t.parseUShort(),l=t.parseShort();e[o+","+c]=l}}return e}function pp(t,e){const n=new _.Parser(t,e),r=n.parseUShort();if(r===0)return hp(n);if(r===1)return fp(n);throw new Error("Unsupported kern table version ("+r+").")}var dp={parse:pp};function gp(t,e,n,r){const s=new _.Parser(t,e),i=r?s.parseUShort:s.parseULong,a=[];for(let o=0;o<n+1;o+=1){let c=i.call(s);r&&(c*=2),a.push(c)}return a}var mp={parse:gp};function ua(t,e){const n=[];let r=12;for(let s=0;s<e;s+=1){const i=_.getTag(t,r),a=_.getULong(t,r+4),o=_.getULong(t,r+8),c=_.getULong(t,r+12);n.push({tag:i,checksum:a,offset:o,length:c,compression:!1}),r+=16}return n}function yp(t,e){const n=[];let r=44;for(let s=0;s<e;s+=1){const i=_.getTag(t,r),a=_.getULong(t,r+4),o=_.getULong(t,r+8),c=_.getULong(t,r+12);let l;o<c?l="WOFF":l=!1,n.push({tag:i,offset:a,compression:l,compressedLength:o,length:c}),r+=20}return n}function Z(t,e){if(e.compression==="WOFF"){const n=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(Ts(n,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(r.buffer,0),offset:0}}else return{data:t,offset:e.offset}}function bp(t,e={}){let n,r;const s=new Kf({empty:!0});t.constructor!==ArrayBuffer&&(t=new Uint8Array(t).buffer);const i=new DataView(t,0);let a,o=[];const c=_.getTag(i,0);if(c==="\0\0\0"||c==="true"||c==="typ1")s.outlinesFormat="truetype",a=_.getUShort(i,4),o=ua(i,a);else if(c==="OTTO")s.outlinesFormat="cff",a=_.getUShort(i,4),o=ua(i,a);else if(c==="wOFF"){const N=_.getTag(i,4);if(N==="\0\0\0")s.outlinesFormat="truetype";else if(N==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+c);a=_.getUShort(i,12),o=yp(i,a)}else if(c==="wOF2"){const N="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+N)}else throw new Error("Unsupported OpenType signature "+c);let l,u,h,f,p,y,m,b,v,w,T,C,E,R,P,V,X,W;for(let N=0;N<a;N+=1){const B=o[N];let U;switch(B.tag){case"avar":m=B;break;case"cmap":U=Z(i,B),s.tables.cmap=Hs.parse(U.data,U.offset),s.encoding=new zs(s.tables.cmap);break;case"cvt ":U=Z(i,B),W=new _.Parser(U.data,U.offset),s.tables.cvt=W.parseShortList(B.length/2);break;case"fvar":h=B;break;case"STAT":f=B;break;case"gvar":p=B;break;case"cvar":y=B;break;case"fpgm":U=Z(i,B),W=new _.Parser(U.data,U.offset),s.tables.fpgm=W.parseByteList(B.length);break;case"head":U=Z(i,B),s.tables.head=si.parse(U.data,U.offset),s.unitsPerEm=s.tables.head.unitsPerEm,n=s.tables.head.indexToLocFormat;break;case"hhea":U=Z(i,B),s.tables.hhea=ii.parse(U.data,U.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"HVAR":E=B;break;case"hmtx":C=B;break;case"ltag":U=Z(i,B),r=oi.parse(U.data,U.offset);break;case"COLR":U=Z(i,B),s.tables.colr=fi.parse(U.data,U.offset);break;case"CPAL":U=Z(i,B),s.tables.cpal=$s.parse(U.data,U.offset);break;case"maxp":U=Z(i,B),s.tables.maxp=ci.parse(U.data,U.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":V=B;break;case"OS/2":U=Z(i,B),s.tables.os2=Tr.parse(U.data,U.offset);break;case"post":U=Z(i,B),s.tables.post=li.parse(U.data,U.offset),s.glyphNames=new dr(s.tables.post);break;case"prep":U=Z(i,B),W=new _.Parser(U.data,U.offset),s.tables.prep=W.parseByteList(B.length);break;case"glyf":b=B;break;case"loca":P=B;break;case"CFF ":l=B;break;case"CFF2":u=B;break;case"kern":R=B;break;case"GDEF":v=B;break;case"GPOS":w=B;break;case"GSUB":T=B;break;case"meta":X=B;break;case"gasp":try{U=Z(i,B),s.tables.gasp=bi.parse(U.data,U.offset)}catch(te){console.warn("Failed to parse gasp table, skipping."),console.warn(te)}break;case"SVG ":U=Z(i,B),s.tables.svg=xi.parse(U.data,U.offset);break}}const $=Z(i,V);if(s.tables.name=Gs.parse($.data,$.offset,r),s.names=s.tables.name,b&&P){const N=n===0,B=Z(i,P),U=mp.parse(B.data,B.offset,s.numGlyphs,N),te=Z(i,b);s.glyphs=Mi.parse(te.data,te.offset,U,s,e)}else if(l){const N=Z(i,l);Sr.parse(N.data,N.offset,s,e)}else if(u){const N=Z(i,u);Sr.parse(N.data,N.offset,s,e)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");const re=Z(i,C);if(ai.parse(s,re.data,re.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),fc(s,e),R){const N=Z(i,R);s.kerningPairs=dp.parse(N.data,N.offset)}else s.kerningPairs={};if(v){const N=Z(i,v);s.tables.gdef=ap.parse(N.data,N.offset)}if(w){const N=Z(i,w);s.tables.gpos=up.parse(N.data,N.offset),s.position.init()}if(T){const N=Z(i,T);s.tables.gsub=ui.parse(N.data,N.offset)}if(h){const N=Z(i,h);s.tables.fvar=pi.parse(N.data,N.offset,s.names)}if(f){const N=Z(i,f);s.tables.stat=di.parse(N.data,N.offset,s.tables.fvar)}if(p){h||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),b||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");const N=Z(i,p);s.tables.gvar=yi.parse(N.data,N.offset,s.tables.fvar,s.glyphs)}if(y){h||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),s.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),b||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");const N=Z(i,y);s.tables.cvar=mi.parse(N.data,N.offset,s.tables.fvar,s.tables.cvt||[])}if(m){h||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");const N=Z(i,m);s.tables.avar=gi.parse(N.data,N.offset,s.tables.fvar)}if(E){h||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),C||console.warn("This font provides an HVAR table, but no hmtx table to vary.");const N=Z(i,E);s.tables.hvar=Qf.parse(N.data,N.offset,s.tables.fvar)}if(X){const N=Z(i,X);s.tables.meta=hi.parse(N.data,N.offset),s.metas=s.tables.meta}return s.palettes=new Oi(s),s}function ha(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),i={},a={},o=t[0].morphTargetsRelative,c=new ue.BufferGeometry;let l=0;for(let u=0;u<t.length;++u){const h=t[u];let f=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in h.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;i[p]===void 0&&(i[p]=[]),i[p].push(h.attributes[p]),f++}if(f!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in h.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(h.morphAttributes[p])}if(e){let p;if(n)p=h.index.count;else if(h.attributes.position!==void 0)p=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,u),l+=p}}if(n){let u=0;const h=[];for(let f=0;f<t.length;++f){const p=t[f].index;for(let y=0;y<p.count;++y)h.push(p.getX(y)+u);u+=t[f].attributes.position.count}c.setIndex(h)}for(const u in i){const h=fa(i[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,h)}for(const u in a){const h=a[u][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<h;++f){const p=[];for(let m=0;m<a[u].length;++m)p.push(a[u][m][f]);const y=fa(p);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(y)}}return c}function fa(t){let e,n,r,s=-1,i=0;for(let l=0;l<t.length;++l){const u=t[l];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;i+=u.count*n}const a=new e(i),o=new ue.BufferAttribute(a,n,r);let c=0;for(let l=0;l<t.length;++l){const u=t[l];if(u.isInterleavedBufferAttribute){const h=c/n;for(let f=0,p=u.count;f<p;f++)for(let y=0;y<n;y++){const m=u.getComponent(f,y);o.setComponent(f+h,y,m)}}else a.set(u.array,c);c+=u.count*n}return s!==void 0&&(o.gpuType=s),o}function xp(t,e=1e-4){e=Math.max(e,Number.EPSILON);const n={},r=t.getIndex(),s=t.getAttribute("position"),i=r?r.count:s.count;let a=0;const o=Object.keys(t.attributes),c={},l={},u=[],h=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let w=0,T=o.length;w<T;w++){const C=o[w],E=t.attributes[C];c[C]=new E.constructor(new E.array.constructor(E.count*E.itemSize),E.itemSize,E.normalized);const R=t.morphAttributes[C];R&&(l[C]||(l[C]=[]),R.forEach((P,V)=>{const X=new P.array.constructor(P.count*P.itemSize);l[C][V]=new P.constructor(X,P.itemSize,P.normalized)}))}const p=e*.5,y=Math.log10(1/e),m=Math.pow(10,y),b=p*m;for(let w=0;w<i;w++){const T=r?r.getX(w):w;let C="";for(let E=0,R=o.length;E<R;E++){const P=o[E],V=t.getAttribute(P),X=V.itemSize;for(let W=0;W<X;W++)C+=`${~~(V[h[W]](T)*m+b)},`}if(C in n)u.push(n[C]);else{for(let E=0,R=o.length;E<R;E++){const P=o[E],V=t.getAttribute(P),X=t.morphAttributes[P],W=V.itemSize,$=c[P],re=l[P];for(let N=0;N<W;N++){const B=h[N],U=f[N];if($[U](a,V[B](T)),X)for(let te=0,Ee=X.length;te<Ee;te++)re[te][U](a,X[te][B](T))}}n[C]=a,u.push(a),a++}}const v=t.clone();for(const w in t.attributes){const T=c[w];if(v.setAttribute(w,new T.constructor(T.array.slice(0,a*T.itemSize),T.itemSize,T.normalized)),w in l)for(let C=0;C<l[w].length;C++){const E=l[w][C];v.morphAttributes[w][C]=new E.constructor(E.array.slice(0,a*E.itemSize),E.itemSize,E.normalized)}}return v.setIndex(u),v}new M.Vector2;function pa(t){const e=t.getAttribute("position");if(!e||e.count===0)return!0;const n=e.array;for(let r=0;r<n.length;r++)if(!Number.isFinite(n[r]))return!1;return!0}class da extends $n{constructor(e,n,r){super(),this.isFound=!1,this.char=e,this.fontSize=n,this.font=r,this.width=this.getCharWidth(e,n,r)}toGeometry(){let e=this.font.cache.getGeometry(this.char.charCodeAt(0),this.fontSize);if(e==null){const n=this.font.generateShapes(this.char,this.fontSize);return e=new M.ShapeGeometry(n,4),pa(e)?(e.hasAttribute("uv")&&e.deleteAttribute("uv"),e.hasAttribute("normal")&&e.deleteAttribute("normal"),xp(e,1e-6)):(e.dispose(),new M.BufferGeometry)}return pa(e)?e:new M.BufferGeometry}getCharWidth(e,n,r){const s=r.data.glyphs[e];return s?(this.isFound=!0,s.ha*n/r.data.resolution):(this.isFound=!1,0)}}class vp{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,n=100){const r=[],s=Sp(e,n,this.data);for(let i=0,a=s.length;i<a;i++)r.push(...s[i].toShapes());return r}}function Sp(t,e,n){const r=Array.from(t),s=e/n.resolution,i=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*s,a=[];let o=0,c=0;for(let l=0;l<r.length;l++){const u=r[l];if(u===`
3
3
  `)o=0,c-=i;else{const h=wp(u,s,o,c,n);o+=h.offsetX,a.push(h.path)}}return a}function wp(t,e,n,r,s){const i=s.glyphs[t]||s.glyphs["?"];if(!i){console.error('THREE.Font: character "'+t+'" does not exists in font family '+s.familyName+".");return}const a=new ue.ShapePath;let o,c,l,u,h,f,p,y;if(i.o){const m=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let b=0,v=m.length;b<v;)switch(m[b++]){case"m":o=m[b++]*e+n,c=m[b++]*e+r,a.moveTo(o,c);break;case"l":o=m[b++]*e+n,c=m[b++]*e+r,a.lineTo(o,c);break;case"q":l=m[b++]*e+n,u=m[b++]*e+r,h=m[b++]*e+n,f=m[b++]*e+r,a.quadraticCurveTo(h,f,l,u);break;case"b":l=m[b++]*e+n,u=m[b++]*e+r,h=m[b++]*e+n,f=m[b++]*e+r,p=m[b++]*e+n,y=m[b++]*e+r,a.bezierCurveTo(h,f,p,y,l,u);break}}return{offsetX:i.ha*e,path:a}}class Tp extends vp{generateShapes(e,n=100,r="ltr"){const s=[];return Cp(e,n,this.data,r).forEach(a=>{s.push(...Ip(a))}),s}}function Cp(t,e,n,r="ltr"){const s=Array.from(t),i=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*i,o=[];let c=0,l=0;(r==="rtl"||r==="tb")&&s.reverse();for(const u of s)if(u===`
4
- `)c=0,l-=a;else{const h=kp(u,i,c,l,n);if(!h)continue;r==="tb"?(c=0,l+=n.ascender*i):c+=h.offsetX,o.push(h.path)}return o}function kp(t,e,n,r,s){const i=s.glyphs[t]||s.glyphs["?"];if(!i){console.error(`THREE.Font: character "${t}" does not exist in font family ${s.familyName}.`);return}const a=new ue.ShapePath;if(i.o){const o=i.o.split(" ");let c=0;for(;c<o.length;){const l=o[c++];let u,h,f,p,y,m,b,v;switch(l){case"m":u=parseFloat(o[c++])*e+n,h=parseFloat(o[c++])*e+r,a.moveTo(u,h);break;case"l":u=parseFloat(o[c++])*e+n,h=parseFloat(o[c++])*e+r,a.lineTo(u,h);break;case"q":f=parseFloat(o[c++])*e+n,p=parseFloat(o[c++])*e+r,y=parseFloat(o[c++])*e+n,m=parseFloat(o[c++])*e+r,a.quadraticCurveTo(y,m,f,p);break;case"b":f=parseFloat(o[c++])*e+n,p=parseFloat(o[c++])*e+r,y=parseFloat(o[c++])*e+n,m=parseFloat(o[c++])*e+r,b=parseFloat(o[c++])*e+n,v=parseFloat(o[c++])*e+r,a.bezierCurveTo(y,m,b,v,f,p);break}}}return{offsetX:i.ha*e,path:a}}function Fp(t,e){let n=!1;const{x:r,y:s}=t,i=e.length;for(let a=0,o=i-1;a<i;o=a++){const c=e[a].x,l=e[a].y,u=e[o].x,h=e[o].y;l>s!=h>s&&r<(u-c)*(s-l)/(h-l)+c&&(n=!n)}return n}function Ep(t){const e=t.length,n=Array(e).fill(null);for(let r=0;r<e;r++){let s=null,i=1/0;for(let a=0;a<e;a++)if(r!==a&&t[r].every(o=>Fp(o,t[a]))){const o=Math.abs(ue.ShapeUtils.area(t[a]));o<i&&(i=o,s=a)}n[r]=s}return n}function Ap(t){const e=t.length,n=Array.from({length:e},()=>[]);for(let r=0;r<e;r++){const s=t[r];s!==null&&n[s].push(r)}return n}function Op(t){return t.map((e,n)=>e===null?n:-1).filter(e=>e>=0)}function Lp(t){const e=[];for(let n=t.length-1;n>=0;n--){const r=t[n];if(r instanceof ue.LineCurve)e.push(new ue.LineCurve(r.v2.clone(),r.v1.clone()));else if(r instanceof ue.QuadraticBezierCurve)e.push(new ue.QuadraticBezierCurve(r.v2.clone(),r.v1.clone(),r.v0.clone()));else if(r instanceof ue.CubicBezierCurve)e.push(new ue.CubicBezierCurve(r.v3.clone(),r.v2.clone(),r.v1.clone(),r.v0.clone()));else if(r instanceof ue.EllipseCurve)e.push(new ue.EllipseCurve(r.aX,r.aY,r.xRadius,r.yRadius,r.aEndAngle,r.aStartAngle,!r.aClockwise,r.aRotation));else if(typeof r.getPoints=="function"){const s=r.getPoints(8);for(let i=s.length-1;i>0;i--)e.push(new ue.LineCurve(s[i].clone(),s[i-1].clone()))}}return e}function ga(t,e){const n=ue.ShapeUtils.area(t.getPoints(32))>0,r=e===n?t.curves.slice():Lp(t.curves),s=new ue.Shape;return s.curves.push(...r),s}function Ip(t,e=32){const n=t.subPaths;if(!n||n.length===0)return[];const r=n.map(p=>p.getPoints(e)),s=Ep(r),i=Ap(s),a=Op(s),o=n.length,c=Array(o).fill(-1),l=Array(o).fill(-1);for(const p of a){const y=[{idx:p,d:0}];for(;y.length;){const m=y.pop();c[m.idx]=m.d,l[m.idx]=p;for(const b of i[m.idx])y.push({idx:b,d:m.d+1})}}const u=[],h=new Set;function f(p){const y=ga(n[p],!0);h.add(p);for(const m of i[p])if(!h.has(m)&&c[m]===c[p]+1){const b=ga(n[m],!1);y.holes.push(b),h.add(m)}u.push(y)}for(const p of a)f(p);for(let p=0;p<o;p++)h.has(p)||f(p);return u}class Rp{constructor(e=512){this.maxSize=e,this.map=new Map}get(e){const n=this.map.get(e);return n&&(this.map.delete(e),this.map.set(e,n)),n}set(e,n){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxSize){const r=this.map.keys().next().value;r!==void 0&&this.map.delete(r)}this.map.set(e,n)}has(e){return this.map.has(e)}clear(){this.map.clear()}}class Mp extends qn{constructor(e){super(e),this.type="mesh",this.glyphCache=new Rp(512);const n=e.data;if(n instanceof ArrayBuffer){const r=this.parseMeshFont(n);this.data=r.data,this.opentypeFont=r.font}else throw new Error("Invalid font cache data. Please remove font cache database named 'mlightcad' in IndexedDB and try again!");this.font=new Tp(this.data)}parseMeshFont(e){const n=bp(e),r=Math.round,s=n.charToGlyph("A"),i=s?n.unitsPerEm/(s.yMax||n.unitsPerEm):1,a={glyphs:{},familyName:n.getEnglishName("fullName"),ascender:r(n.ascender),descender:r(n.descender),underlinePosition:n.tables.post.underlinePosition,underlineThickness:n.tables.post.underlineThickness,boundingBox:{xMin:n.tables.head.xMin,xMax:n.tables.head.xMax,yMin:n.tables.head.yMin,yMax:n.tables.head.yMax},resolution:n.unitsPerEm||1e3,scaleFactor:i,original_font_information:n.tables.name};return{font:n,data:a}}opentypeHasGlyph(e){if(!this.opentypeFont)return!1;const n=this.opentypeFont.charToGlyphIndex(e);return n!=null&&n>0}hasChar(e){return this.opentypeHasGlyph(e)}hasCode(e){return this.hasChar(String.fromCodePoint(e))}_loadGlyphIfNeeded(e){if(this.data.glyphs[e]||!this.opentypeFont)return;const n=this.glyphCache.get(e);if(n){this.data.glyphs[e]=n;return}if(this.opentypeHasGlyph(e)){const r=this.opentypeFont.charToGlyph(e);if(!r||!r.path)return;const s=Math.round,i={ha:s(r.advanceWidth??0),x_min:s(r.xMin??0),x_max:s(r.xMax??0),o:""};r.path.commands.forEach(a=>{let o=a.type.toLowerCase();o==="c"&&(o="b"),i.o+=o+" ",a.x!==void 0&&a.y!==void 0&&(i.o+=s(a.x)+" "+s(a.y)+" "),a.x1!==void 0&&a.y1!==void 0&&(i.o+=s(a.x1)+" "+s(a.y1)+" "),a.x2!==void 0&&a.y2!==void 0&&(i.o+=s(a.x2)+" "+s(a.y2)+" ")}),this.data.glyphs[e]=i,this.glyphCache.set(e,i)}}generateShapes(e,n){for(const r of e)this._loadGlyphIfNeeded(r);return this.font.generateShapes(e,n)}getCharShape(e,n){if(this._loadGlyphIfNeeded(e),!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new da(e,n,this)}getCodeShape(e,n){return this.getCharShape(String.fromCodePoint(e),n)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return new da("?",e,this)}}class ke{static byteToSByte(e){return(e&127)-(e&128?128:0)}constructor(e){this.position=0,this.data=new DataView(e)}readBytes(e=1){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e);const n=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,n}skip(e){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e),this.position+=e}readUint8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(e=!0){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const n=this.data.getUint16(this.position,e);return this.position+=2,n}readInt16(){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readUint32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readInt32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readFloat32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}readFloat64(){this.data.byteLength<this.position+8&&this.throwOutOfRangeError(this.position+8);const e=this.data.getFloat64(this.position,!0);return this.position+=8,e}setPosition(e){this.data.byteLength<e&&this.throwOutOfRangeError(e),this.position=e}isEnd(){return this.position===this.data.byteLength-1}get currentPosition(){return this.position}get length(){return this.data.byteLength}throwOutOfRangeError(e){throw new Error(`Position ${e} is out of range for the data length ${this.data.byteLength}!`)}}var me=(t=>(t.SHAPES="shapes",t.BIGFONT="bigfont",t.UNIFONT="unifont",t))(me||{});class Dp{parse(e){const n=this.parseHeader(e).split(" "),r=n[1].toLocaleLowerCase();if(!Object.values(me).includes(r))throw new Error(`Invalid font type: ${r}`);return{fileHeader:n[0],fontType:r,fileVersion:n[2]}}parseHeader(e){let n="",r=0;for(;e.currentPosition<e.length-2&&r<1024;){const s=e.readUint8();if(s===13){const i=e.currentPosition,a=e.readUint8(),o=e.readUint8();if(a===10&&o===26)break;e.setPosition(i),n+=String.fromCharCode(s)}else n+=String.fromCharCode(s);r++}return n.trim()}}const Ue=10,Bp=[13,10,0];function ma(t){const e=t.indexOf(0);return e<0?{name:null,bytecode:t}:{name:e>0?new TextDecoder("ascii").decode(t.subarray(0,e)):null,bytecode:t.subarray(e+1)}}class _p{parse(e){try{e.readBytes(4);const n=e.readInt16();if(n<=0)throw new Error("Invalid shape count in font file");const r=[];for(let c=0;c<n;c++){const l=e.readUint16(),u=e.readUint16();u>0&&r.push({code:l,length:u})}const s={};for(const c of r)try{const l=e.readBytes(c.length);l.length===c.length&&(s[c.code]=l)}catch{console.warn(`Failed to read shape data for code ${c.code}`)}const i={},a={};for(const[c,l]of Object.entries(s)){const u=Number(c);if(u===0){i[u]=l;continue}const{name:h,bytecode:f}=ma(l);i[u]=f,h&&(a[h]=u)}const o={data:i,names:Object.keys(a).length>0?a:void 0,info:"",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1};if(0 in i){const c=i[0];try{const l=new TextDecoder().decode(c);let u=c.findIndex(h=>Bp.includes(h));u>=0&&(o.info=l.substring(0,u),u+3<c.length&&(o.baseUp=c[u+1],o.baseDown=c[u+2],o.height=o.baseDown+o.baseUp,o.width=o.height,o.orientation=c[u+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse font info block")}}return o}catch(n){return console.error("Error parsing shape font:",n),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1}}}}class Up{parse(e){try{e.readInt16();const n=e.readInt16(),r=e.readInt16();if(n<=0)throw new Error("Invalid character count in font file");e.skip(r*4);const s=[];for(let o=0;o<n;o++){const c=e.readUint16(),l=e.readUint16(),u=e.readUint32();(c!==0||l!==0||u!==0)&&s.push({code:c,length:l,offset:u})}const i={};for(const o of s)try{e.setPosition(o.offset);const c=e.readBytes(o.length);c.length===o.length&&(i[o.code]=c)}catch{console.warn(`Failed to read bigfont data for code ${o.code}`)}const a={data:i,info:"",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1};if(0 in i){const o=i[0];try{const c=this.utf8ArrayToStr(o);let l=c.pos;l>=0&&(a.info=c.text,l++,l+3<o.length&&(o.length-l>4?(a.height=o[l++],l++,a.orientation=o[l++]===0?"horizontal":"vertical",a.width=o[l++],a.baseUp=a.height,a.baseDown=0,a.isExtended=!0):(a.baseUp=o[l++],a.baseDown=o[l++],a.height=a.baseDown+a.baseUp,a.width=a.height,a.orientation=o[l]===0?"horizontal":"vertical")))}catch{console.warn("Failed to parse bigfont info block")}}return a}catch(n){return console.error("Error parsing big font:",n),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1}}}utf8ArrayToStr(e){let n="",r=0;for(;r<e.length;){const s=e[r];switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:{const i=e[r++];n+=String.fromCharCode((s&31)<<6|i&63);break}case 14:{const i=e[r++],a=e[r++];n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(a&63)<<0);break}}if(n.charCodeAt(n.length-1)===0)break;r++}return{text:n,pos:r}}}class Pp{parse(e){try{const n=e.readInt32();if(n<=0)throw new Error("Invalid character count in font file");const r=e.readInt16(),s=e.readBytes(r),i={data:{},info:"",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1};try{const c=new TextDecoder().decode(s);let l=c.indexOf("\0");l>=0&&(i.info=c.substring(0,l),l+3<s.length&&(i.baseUp=s[l+1],i.baseDown=s[l+2],i.height=i.baseUp+i.baseDown,i.width=i.height,i.orientation=s[l+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse unifont info block")}const a={},o={};for(let c=0;c<n-1;c++)try{const l=e.readUint16(),u=e.readUint16();if(u>0){const h=e.readBytes(u);if(h.length===u){const{name:f,bytecode:p}=ma(h);p.length>0&&(a[l]=p,f&&(o[f]=l))}}}catch{console.warn("Failed to read unifont character data");break}return i.data=a,i.names=Object.keys(o).length>0?o:void 0,i}catch(n){return console.error("Error parsing unifont:",n),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1}}}}class Np{static createParser(e){switch(e){case me.SHAPES:return new _p;case me.BIGFONT:return new Up;case me.UNIFONT:return new Pp;default:throw new Error(`Unsupported font type: ${e}`)}}}class ce{constructor(e=0,n=0){this.x=e,this.y=n}set(e,n){return this.x=e,this.y=n,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}clone(){return new ce(this.x,this.y)}add(e){return this.x+=e.x,this.y+=e.y,this}subtract(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e,this.y*=e,this}divide(e){return e!==0&&(this.x/=e,this.y/=e),this}multiplyScalars(e,n){return this.x*=e,this.y*=n,this}divideScalars(e,n){return e!==0&&(this.x/=e),n!==0&&(this.y/=n),this}distanceTo(e){const n=this.x-e.x,r=this.y-e.y;return Math.sqrt(n*n+r*r)}}const ya=Math.PI/4;class Zt{static fromBulge(e,n,r){const s=Math.max(-1,Math.min(1,r));return new Zt({start:e,end:n,bulge:s})}static fromOctant(e,n,r,s,i){return new Zt({center:e,radius:n,startOctant:r,octantCount:s,isClockwise:i})}constructor(e){if(e.start&&e.end&&e.bulge!==void 0){this.start=e.start.clone(),this.end=e.end.clone(),this.bulge=e.bulge,this.isClockwise=e.bulge<0;const n=this.end.clone().subtract(this.start),r=n.length();if(Math.abs(this.bulge)*r/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(n.y,n.x),this.endAngle=this.startAngle;return}const s=4*Math.atan(Math.abs(this.bulge));this.radius=r/(2*Math.sin(s/2));const i=this.start.clone().add(n.clone().divide(2)),a=new ce(-n.y,n.x);a.normalize(),a.multiply(Math.abs(this.radius*Math.cos(s/2))),this.center=i.clone(),this.isClockwise?this.center.subtract(a):this.center.add(a),this.startAngle=Math.atan2(this.start.y-this.center.y,this.start.x-this.center.x),this.endAngle=Math.atan2(this.end.y-this.center.y,this.end.x-this.center.x),this.isClockwise?this.endAngle>=this.startAngle&&(this.endAngle-=2*Math.PI):this.endAngle<=this.startAngle&&(this.endAngle+=2*Math.PI)}else if(e.center&&e.radius!==void 0&&e.startOctant!==void 0&&e.octantCount!==void 0&&e.isClockwise!==void 0){this.center=e.center.clone(),this.radius=e.radius,this.isClockwise=e.isClockwise,this.startAngle=e.startOctant*ya;const n=(e.octantCount===0?8:e.octantCount)*ya;this.endAngle=this.startAngle+(this.isClockwise?-n:n),this.start=this.center.clone().add(new ce(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new ce(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))}else throw new Error("Invalid arc parameters")}tessellate(e=Math.PI/18){if(this.radius===0)return[this.start.clone(),this.end.clone()];const n=[this.start.clone()],r=Math.abs(this.endAngle-this.startAngle),s=Math.max(1,Math.floor(r/e));for(let i=1;i<s;i++){const a=i/s,o=this.isClockwise?this.startAngle-a*r:this.startAngle+a*r;n.push(this.center.clone().add(new ce(this.radius*Math.cos(o),this.radius*Math.sin(o))))}return n.push(this.end?this.end.clone():this.center.clone().add(new ce(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),n}}class Jt{constructor(e,n=[]){this.lastPoint=e,this.polylines=n}get bbox(){if(this._bbox)return this._bbox;let e=1/0,n=-1/0,r=1/0,s=-1/0;return this.polylines.forEach(i=>{i.forEach(a=>{e=Math.min(e,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),s=Math.max(s,a.y)})}),this._bbox={minX:e,minY:r,maxX:n,maxY:s},this._bbox}offset(e,n=!0){var r,s;return n?new Jt((r=this.lastPoint)==null?void 0:r.clone().add(e),this.polylines.map(i=>i.map(a=>a.clone().add(e)))):((s=this.lastPoint)==null||s.add(e),this.polylines.forEach(i=>i.forEach(a=>a.add(e))),this._bbox&&(this._bbox.maxX+=e.x,this._bbox.minX+=e.x,this._bbox.maxY+=e.y,this._bbox.minY+=e.y),this)}normalizeToOrigin(e=!1){const n=this.bbox;return this.offset(new ce(-n.minX,-n.minY),e)}toSVG(e={}){const{strokeWidth:n="0.5%",strokeColor:r="black",isAutoFit:s=!1}=e;let i,a;if(s){const o=this.bbox,c=.2,l=o.maxX-o.minX,u=o.maxY-o.minY,h=l===0?u:l,f=u===0?l:u,p=o.minX-h*c,y=o.maxX+h*c,m=o.minY-f*c,b=o.maxY+f*c;a=this.polylines.map(v=>{let w="";return v.forEach((T,C)=>{const E=T.x,R=-T.y;w+=C===0?`M ${E} ${R} `:`L ${E} ${R} `}),`<path d="${w}" stroke="${r}" stroke-width="${n}" fill="none"/>`}).join(""),i=`${p} ${-b} ${y-p} ${b-m}`}else i="0 0 20 20",a=this.polylines.map(o=>{let c="";return o.forEach((l,u)=>{const h=l.x+5,f=-l.y+15;c+=u===0?`M ${h} ${f} `:`L ${h} ${f} `}),`<path d="${c}" stroke="${r}" stroke-width="${n}" fill="none"/>`}).join("");return`<svg width="100%" height="100%" viewBox="${i}" preserveAspectRatio="xMidYMid meet">${a}</svg>`}}const Gp=Math.PI/18;class Hp{constructor(e){this.shapeCache=new Map,this.shapeData=new Map,this.fontData=e}release(){this.shapeCache.clear(),this.shapeData.clear()}getCharShape(e,n){const r=n/this.fontData.content.height;return this.parseAndScale(e,{factor:r})}parseAndScale(e,n){if(e===0)return;let r;if(this.shapeCache.has(e))r=this.shapeCache.get(e);else{const s=this.fontData.content.data;if(s[e]){const i=s[e];r=this.parseShape(i),this.shapeData.set(e,r),this.shapeCache.set(e,r)}}if(r){if(n.factor!==void 0)return this.scaleShapeByFactor(r,n.factor);if(n.height!==void 0){const s=n.width??n.height;return this.scaleShapeByHeightAndWidth(r,n.height,s)}else return r}}scaleShapeByFactor(e,n){var r;return new Jt((r=e.lastPoint)==null?void 0:r.clone().multiply(n),e.polylines.map(s=>s.map(i=>i.clone().multiply(n))))}scaleShapeByHeightAndWidth(e,n,r){var s;const i=e.bbox,a=i.maxY-i.minY,o=i.maxX-i.minX,c=a>0?n/a:1,l=o>0?r/o:1,u=(s=e.lastPoint)==null?void 0:s.clone();u&&(u.x*=l,u.y*=c);const h=e.polylines.map(f=>f.map(p=>{const y=p.clone();return y.x*=l,y.y*=c,y}));return new Jt(u,h)}parseShape(e,n={}){let r=new ce;const s=[];let i=[];const a=[];let o=n.initialPenDown??!1;o&&i.push(r.clone());const c={currentPoint:r,polylines:s,currentPolyline:i,sp:a,isPenDown:o,scale:1,flushEndPolyline:n.initialPenDown??!1};for(let l=0;l<e.length;l++){const u=e[l];u<=15?l=this.handleSpecialCommand(u,e,l,c):this.handleVectorCommand(u,c)}return new Jt(c.currentPoint,c.polylines)}handleSpecialCommand(e,n,r,s){let i=r;switch(e){case 0:s.flushEndPolyline&&s.currentPolyline.length>1&&s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[],s.isPenDown=!1;break;case 1:s.isPenDown=!0,s.currentPolyline.push(s.currentPoint.clone());break;case 2:s.isPenDown=!1,s.currentPolyline.length>1&&s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[];break;case 3:i++,s.scale/=n[i];break;case 4:i++,s.scale*=n[i];break;case 5:if(s.sp.length===4)throw new Error("The position stack is only four locations deep");s.sp.push(s.currentPoint.clone());break;case 6:s.currentPoint=s.sp.pop()??s.currentPoint;break;case 7:i=this.handleSubshapeCommand(n,i,s);break;case 8:i=this.handleXYDisplacement(n,i,s);break;case 9:i=this.handleMultipleXYDisplacements(n,i,s);break;case 10:i=this.handleOctantArc(n,i,s);break;case 11:i=this.handleFractionalArc(n,i,s);break;case 12:i=this.handleBulgeArc(n,i,s);break;case 13:i=this.handleMultipleBulgeArcs(n,i,s);break;case 14:i=this.skipCode(n,++i);break}return i}handleVectorCommand(e,n){const r=(e&240)>>4,s=e&15,i=this.getVectorForDirection(s);n.currentPoint.add(i.multiply(r*n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone())}getVectorForDirection(e){const n=new ce;switch(e){case 0:n.x=1;break;case 1:n.x=1,n.y=.5;break;case 2:n.x=1,n.y=1;break;case 3:n.x=.5,n.y=1;break;case 4:n.y=1;break;case 5:n.x=-.5,n.y=1;break;case 6:n.x=-1,n.y=1;break;case 7:n.x=-1,n.y=.5;break;case 8:n.x=-1;break;case 9:n.x=-1,n.y=-.5;break;case 10:n.x=-1,n.y=-1;break;case 11:n.x=-.5,n.y=-1;break;case 12:n.y=-1;break;case 13:n.x=.5,n.y=-1;break;case 14:n.x=1,n.y=-1;break;case 15:n.x=1,n.y=-.5;break}return n}handleSubshapeCommand(e,n,r){let s=n,i=0,a,o=r.scale*this.fontData.content.height,c=o;const l=r.currentPoint.clone();switch(r.currentPolyline.length>1&&(r.polylines.push(r.currentPolyline.slice()),r.currentPolyline=[]),this.fontData.header.fontType){case me.SHAPES:s++,i=e[s];break;case me.BIGFONT:s++,i=e[s],i===0&&(s++,i=e[s++]<<8|e[s++],l.x=ke.byteToSByte(e[s++])*r.scale,l.y=ke.byteToSByte(e[s++])*r.scale,this.fontData.content.isExtended&&(c=e[s++]*r.scale),o=e[s]*r.scale);break;case me.UNIFONT:s++,i=e[s++]<<8|e[s++];break}if(i!==0)if(this.fontData.header.fontType===me.UNIFONT){const u=r.isPenDown;a=this.getScaledSubshapeAtInsertPoint(i,c,o,l,u),a!=null&&a.polylines.some(h=>h.length>=2)&&(r.polylines.push(...a.polylines.slice()),a.lastPoint&&(r.currentPoint=a.lastPoint.clone()),r.currentPolyline=[],r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone()))}else a=this.getScaledSubshapeAtInsertPoint(i,c,o,l),a&&r.polylines.push(...a.polylines.slice()),r.currentPolyline=[];return s}handleXYDisplacement(e,n,r){let s=n;const i=new ce;return i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),r.currentPoint.add(i.multiply(r.scale)),r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone()),s}handleMultipleXYDisplacements(e,n,r){let s=n;for(;;){const i=new ce;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0)break;r.currentPoint.add(i.multiply(r.scale)),r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone())}return s}handleOctantArc(e,n,r){var s;let i=n;const a=e[++i]*r.scale,o=ke.byteToSByte(e[++i]),c=(o&112)>>4;let l=o&7;const u=o<0,h=Math.PI/4*c,f=r.currentPoint.clone().subtract(new ce(Math.cos(h)*a,Math.sin(h)*a)),p=Zt.fromOctant(f,a,c,l,u);if(r.isPenDown){const y=p.tessellate();r.currentPolyline.pop(),r.currentPolyline.push(...y.slice())}return r.currentPoint=(s=p.tessellate().pop())==null?void 0:s.clone(),i}handleFractionalArc(e,n,r){let s=n;const i=e[++s],a=e[++s],o=e[++s],c=e[++s],l=(o*255+c)*r.scale,u=ke.byteToSByte(e[++s]),h=(u&112)>>4;let f=u&7;f===0&&(f=8),a!==0&&f--;const p=Math.PI/4;let y=p*f,m=Gp,b=1;u<0&&(m=-m,y=-y,b=-1);let v=p*h,w=v+y;v+=p*i/256*b,w+=p*a/256*b;const T=r.currentPoint.clone().subtract(new ce(l*Math.cos(v),l*Math.sin(v)));if(r.currentPoint=T.clone().add(new ce(l*Math.cos(w),l*Math.sin(w))),r.isPenDown){let C=v;const E=[];if(E.push(T.clone().add(new ce(l*Math.cos(C),l*Math.sin(C)))),m>0)for(;C+m<w;)C+=m,E.push(T.clone().add(new ce(l*Math.cos(C),l*Math.sin(C))));else for(;C+m>w;)C+=m,E.push(T.clone().add(new ce(l*Math.cos(C),l*Math.sin(C))));E.push(T.clone().add(new ce(l*Math.cos(w),l*Math.sin(w)))),r.currentPolyline.push(...E)}return s}handleBulgeArc(e,n,r){let s=n;const i=new ce;i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]);const a=ke.byteToSByte(e[++s]);return r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline),s}handleMultipleBulgeArcs(e,n,r){let s=n;for(;;){const i=new ce;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0)break;const a=ke.byteToSByte(e[++s]);r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline)}return s}skipCode(e,n){switch(e[n]){case 0:break;case 1:break;case 2:break;case 3:case 4:n++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case me.SHAPES:n++;break;case me.BIGFONT:n++,e[n]===0&&(n+=this.fontData.content.isExtended?6:5);break;case me.UNIFONT:n+=2;break}break;case 8:n+=2;break;case 9:for(;;){const r=e[++n],s=e[++n];if(r===0&&s===0)break}break;case 10:n+=2;break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;;){const r=e[++n],s=e[++n];if(r===0&&s===0)break;n++}break}return n}getScaledSubshapeAtInsertPoint(e,n,r,s,i=!1){let a;if(i){const c=this.fontData.content.data[e];if(!c)return;a=this.parseShape(c,{initialPenDown:!0})}else if(a=this.shapeCache.get(e),!a){const c=this.fontData.content.data[e];if(!c)return;a=this.parseShape(c),this.shapeData.set(e,a),this.shapeCache.set(e,a)}const o=a.normalizeToOrigin(!0);return this.scaleShapeByHeightAndWidth(o,r,n).offset(s,!1)}handleArcSegment(e,n,r,s,i,a){n.x*=s,n.y*=s,r<-127&&(r=-127);const o=e.clone();if(i)if(r===0)a.push(o.clone().add(n));else{const c=o.clone().add(n),l=Zt.fromBulge(o,c,r/127).tessellate();a.push(...l.slice(1))}return o.add(n),o}}class ba{constructor(e){if(e instanceof ArrayBuffer){const n=new ke(e),r=new Dp().parse(n),s=Np.createParser(r.fontType).parse(n);this.fontData={header:r,content:s}}else this.fontData=e;this.shapeParser=new Hp(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}hasShape(e){return this.getShapeCode(e)!==void 0}getShapeCode(e){const n=this.fontData.content.names;if(n)return n[e.toUpperCase()]}getShapeName(e){const n=this.fontData.content.names;if(n){for(const[r,s]of Object.entries(n))if(s===e)return r}}getShapeByName(e,n){const r=this.getShapeCode(e);if(r!==void 0)return this.getCharShape(r,n)}getCharShape(e,n){let r=this.shapeParser.getCharShape(e,n);return r&&this.fontData.header.fontType===me.BIGFONT&&r.bbox.minY<=n*.5&&(r=r.normalizeToOrigin()),r}release(){this.shapeParser.release()}}function Wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function zp(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var xa={exports:{}},Pr={},Dn={};Dn.byteLength=qp,Dn.toByteArray=Yp,Dn.fromByteArray=Zp;for(var Je=[],Pe=[],Vp=typeof Uint8Array<"u"?Uint8Array:Array,Nr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bt=0,jp=Nr.length;Bt<jp;++Bt)Je[Bt]=Nr[Bt],Pe[Nr.charCodeAt(Bt)]=Bt;Pe[45]=62,Pe[95]=63;function va(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function qp(t){var e=va(t),n=e[0],r=e[1];return(n+r)*3/4-r}function $p(t,e,n){return(e+n)*3/4-n}function Yp(t){var e,n=va(t),r=n[0],s=n[1],i=new Vp($p(t,r,s)),a=0,o=s>0?r-4:r,c;for(c=0;c<o;c+=4)e=Pe[t.charCodeAt(c)]<<18|Pe[t.charCodeAt(c+1)]<<12|Pe[t.charCodeAt(c+2)]<<6|Pe[t.charCodeAt(c+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return s===2&&(e=Pe[t.charCodeAt(c)]<<2|Pe[t.charCodeAt(c+1)]>>4,i[a++]=e&255),s===1&&(e=Pe[t.charCodeAt(c)]<<10|Pe[t.charCodeAt(c+1)]<<4|Pe[t.charCodeAt(c+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function Xp(t){return Je[t>>18&63]+Je[t>>12&63]+Je[t>>6&63]+Je[t&63]}function Kp(t,e,n){for(var r,s=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(Xp(r));return s.join("")}function Zp(t){for(var e,n=t.length,r=n%3,s=[],i=16383,a=0,o=n-r;a<o;a+=i)s.push(Kp(t,a,a+i>o?o:a+i));return r===1?(e=t[n-1],s.push(Je[e>>2]+Je[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],s.push(Je[e>>10]+Je[e>>4&63]+Je[e<<2&63]+"=")),s.join("")}var Gr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gr.read=function(t,e,n,r,s){var i,a,o=s*8-r-1,c=(1<<o)-1,l=c>>1,u=-7,h=n?s-1:0,f=n?-1:1,p=t[e+h];for(h+=f,i=p&(1<<-u)-1,p>>=-u,u+=o;u>0;i=i*256+t[e+h],h+=f,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=a*256+t[e+h],h+=f,u-=8);if(i===0)i=1-l;else{if(i===c)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,r),i=i-l}return(p?-1:1)*a*Math.pow(2,i-r)},Gr.write=function(t,e,n,r,s,i){var a,o,c,l=i*8-s-1,u=(1<<l)-1,h=u>>1,f=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,y=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+h>=1?e+=f/c:e+=f*Math.pow(2,1-h),e*c>=2&&(a++,c/=2),a+h>=u?(o=0,a=u):a+h>=1?(o=(e*c-1)*Math.pow(2,s),a=a+h):(o=e*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;t[n+p]=o&255,p+=y,o/=256,s-=8);for(a=a<<s|o,l+=s;l>0;t[n+p]=a&255,p+=y,a/=256,l-=8);t[n+p-y]|=m*128};/*!
4
+ `)c=0,l-=a;else{const h=kp(u,i,c,l,n);if(!h)continue;r==="tb"?(c=0,l+=n.ascender*i):c+=h.offsetX,o.push(h.path)}return o}function kp(t,e,n,r,s){const i=s.glyphs[t]||s.glyphs["?"];if(!i){console.error(`THREE.Font: character "${t}" does not exist in font family ${s.familyName}.`);return}const a=new ue.ShapePath;if(i.o){const o=i.o.split(" ");let c=0;for(;c<o.length;){const l=o[c++];let u,h,f,p,y,m,b,v;switch(l){case"m":u=parseFloat(o[c++])*e+n,h=parseFloat(o[c++])*e+r,a.moveTo(u,h);break;case"l":u=parseFloat(o[c++])*e+n,h=parseFloat(o[c++])*e+r,a.lineTo(u,h);break;case"q":f=parseFloat(o[c++])*e+n,p=parseFloat(o[c++])*e+r,y=parseFloat(o[c++])*e+n,m=parseFloat(o[c++])*e+r,a.quadraticCurveTo(y,m,f,p);break;case"b":f=parseFloat(o[c++])*e+n,p=parseFloat(o[c++])*e+r,y=parseFloat(o[c++])*e+n,m=parseFloat(o[c++])*e+r,b=parseFloat(o[c++])*e+n,v=parseFloat(o[c++])*e+r,a.bezierCurveTo(y,m,b,v,f,p);break}}}return{offsetX:i.ha*e,path:a}}function Fp(t,e){let n=!1;const{x:r,y:s}=t,i=e.length;for(let a=0,o=i-1;a<i;o=a++){const c=e[a].x,l=e[a].y,u=e[o].x,h=e[o].y;l>s!=h>s&&r<(u-c)*(s-l)/(h-l)+c&&(n=!n)}return n}function Ep(t){const e=t.length,n=Array(e).fill(null);for(let r=0;r<e;r++){let s=null,i=1/0;for(let a=0;a<e;a++)if(r!==a&&t[r].every(o=>Fp(o,t[a]))){const o=Math.abs(ue.ShapeUtils.area(t[a]));o<i&&(i=o,s=a)}n[r]=s}return n}function Ap(t){const e=t.length,n=Array.from({length:e},()=>[]);for(let r=0;r<e;r++){const s=t[r];s!==null&&n[s].push(r)}return n}function Op(t){return t.map((e,n)=>e===null?n:-1).filter(e=>e>=0)}function Lp(t){const e=[];for(let n=t.length-1;n>=0;n--){const r=t[n];if(r instanceof ue.LineCurve)e.push(new ue.LineCurve(r.v2.clone(),r.v1.clone()));else if(r instanceof ue.QuadraticBezierCurve)e.push(new ue.QuadraticBezierCurve(r.v2.clone(),r.v1.clone(),r.v0.clone()));else if(r instanceof ue.CubicBezierCurve)e.push(new ue.CubicBezierCurve(r.v3.clone(),r.v2.clone(),r.v1.clone(),r.v0.clone()));else if(r instanceof ue.EllipseCurve)e.push(new ue.EllipseCurve(r.aX,r.aY,r.xRadius,r.yRadius,r.aEndAngle,r.aStartAngle,!r.aClockwise,r.aRotation));else if(typeof r.getPoints=="function"){const s=r.getPoints(8);for(let i=s.length-1;i>0;i--)e.push(new ue.LineCurve(s[i].clone(),s[i-1].clone()))}}return e}function ga(t,e){const n=ue.ShapeUtils.area(t.getPoints(32))>0,r=e===n?t.curves.slice():Lp(t.curves),s=new ue.Shape;return s.curves.push(...r),s}function Ip(t,e=32){const n=t.subPaths;if(!n||n.length===0)return[];const r=n.map(p=>p.getPoints(e)),s=Ep(r),i=Ap(s),a=Op(s),o=n.length,c=Array(o).fill(-1),l=Array(o).fill(-1);for(const p of a){const y=[{idx:p,d:0}];for(;y.length;){const m=y.pop();c[m.idx]=m.d,l[m.idx]=p;for(const b of i[m.idx])y.push({idx:b,d:m.d+1})}}const u=[],h=new Set;function f(p){const y=ga(n[p],!0);h.add(p);for(const m of i[p])if(!h.has(m)&&c[m]===c[p]+1){const b=ga(n[m],!1);y.holes.push(b),h.add(m)}u.push(y)}for(const p of a)f(p);for(let p=0;p<o;p++)h.has(p)||f(p);return u}class Rp{constructor(e=512){this.maxSize=e,this.map=new Map}get(e){const n=this.map.get(e);return n&&(this.map.delete(e),this.map.set(e,n)),n}set(e,n){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxSize){const r=this.map.keys().next().value;r!==void 0&&this.map.delete(r)}this.map.set(e,n)}has(e){return this.map.has(e)}clear(){this.map.clear()}}class Mp extends qn{constructor(e){super(e),this.type="mesh",this.glyphCache=new Rp(512);const n=e.data;if(n instanceof ArrayBuffer){const r=this.parseMeshFont(n);this.data=r.data,this.opentypeFont=r.font}else throw new Error("Invalid font cache data. Please remove font cache database named 'mlightcad' in IndexedDB and try again!");this.font=new Tp(this.data)}parseMeshFont(e){const n=bp(e),r=Math.round,s=n.charToGlyph("A"),i=s?n.unitsPerEm/(s.yMax||n.unitsPerEm):1,a={glyphs:{},familyName:n.getEnglishName("fullName"),ascender:r(n.ascender),descender:r(n.descender),underlinePosition:n.tables.post.underlinePosition,underlineThickness:n.tables.post.underlineThickness,boundingBox:{xMin:n.tables.head.xMin,xMax:n.tables.head.xMax,yMin:n.tables.head.yMin,yMax:n.tables.head.yMax},resolution:n.unitsPerEm||1e3,scaleFactor:i,original_font_information:n.tables.name};return{font:n,data:a}}opentypeHasGlyph(e){if(!this.opentypeFont)return!1;const n=this.opentypeFont.charToGlyphIndex(e);return n!=null&&n>0}hasChar(e){return this.opentypeHasGlyph(e)}hasCode(e){return this.hasChar(String.fromCodePoint(e))}_loadGlyphIfNeeded(e){if(this.data.glyphs[e]||!this.opentypeFont)return;const n=this.glyphCache.get(e);if(n){this.data.glyphs[e]=n;return}if(this.opentypeHasGlyph(e)){const r=this.opentypeFont.charToGlyph(e);if(!r||!r.path)return;const s=Math.round,i={ha:s(r.advanceWidth??0),x_min:s(r.xMin??0),x_max:s(r.xMax??0),o:""};r.path.commands.forEach(a=>{let o=a.type.toLowerCase();o==="c"&&(o="b"),i.o+=o+" ",a.x!==void 0&&a.y!==void 0&&(i.o+=s(a.x)+" "+s(a.y)+" "),a.x1!==void 0&&a.y1!==void 0&&(i.o+=s(a.x1)+" "+s(a.y1)+" "),a.x2!==void 0&&a.y2!==void 0&&(i.o+=s(a.x2)+" "+s(a.y2)+" ")}),this.data.glyphs[e]=i,this.glyphCache.set(e,i)}}generateShapes(e,n){for(const r of e)this._loadGlyphIfNeeded(r);return this.font.generateShapes(e,n)}getCharShape(e,n){if(this._loadGlyphIfNeeded(e),!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new da(e,n,this)}getCodeShape(e,n){return this.getCharShape(String.fromCodePoint(e),n)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return new da("?",e,this)}}class ke{static byteToSByte(e){return(e&127)-(e&128?128:0)}constructor(e){this.position=0,this.data=new DataView(e)}readBytes(e=1){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e);const n=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,n}skip(e){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e),this.position+=e}readUint8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(e=!0){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const n=this.data.getUint16(this.position,e);return this.position+=2,n}readInt16(){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readUint32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readInt32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readFloat32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}readFloat64(){this.data.byteLength<this.position+8&&this.throwOutOfRangeError(this.position+8);const e=this.data.getFloat64(this.position,!0);return this.position+=8,e}setPosition(e){this.data.byteLength<e&&this.throwOutOfRangeError(e),this.position=e}isEnd(){return this.position===this.data.byteLength-1}get currentPosition(){return this.position}get length(){return this.data.byteLength}throwOutOfRangeError(e){throw new Error(`Position ${e} is out of range for the data length ${this.data.byteLength}!`)}}var me=(t=>(t.SHAPES="shapes",t.BIGFONT="bigfont",t.UNIFONT="unifont",t))(me||{});class Dp{parse(e){const n=this.parseHeader(e).split(" "),r=n[1].toLocaleLowerCase();if(!Object.values(me).includes(r))throw new Error(`Invalid font type: ${r}`);return{fileHeader:n[0],fontType:r,fileVersion:n[2]}}parseHeader(e){let n="",r=0;for(;e.currentPosition<e.length-2&&r<1024;){const s=e.readUint8();if(s===13){const i=e.currentPosition,a=e.readUint8(),o=e.readUint8();if(a===10&&o===26)break;e.setPosition(i),n+=String.fromCharCode(s)}else n+=String.fromCharCode(s);r++}return n.trim()}}const Ue=10,Bp=[13,10,0];function ma(t){const e=t.indexOf(0);return e<0?{name:null,bytecode:t}:{name:e>0?new TextDecoder("ascii").decode(t.subarray(0,e)):null,bytecode:t.subarray(e+1)}}class _p{parse(e){try{e.readBytes(4);const n=e.readInt16();if(n<=0)throw new Error("Invalid shape count in font file");const r=[];for(let c=0;c<n;c++){const l=e.readUint16(),u=e.readUint16();u>0&&r.push({code:l,length:u})}const s={};for(const c of r)try{const l=e.readBytes(c.length);l.length===c.length&&(s[c.code]=l)}catch{console.warn(`Failed to read shape data for code ${c.code}`)}const i={},a={};for(const[c,l]of Object.entries(s)){const u=Number(c);if(u===0){i[u]=l;continue}const{name:h,bytecode:f}=ma(l);i[u]=f,h&&(a[h]=u)}const o={data:i,names:Object.keys(a).length>0?a:void 0,info:"",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1};if(0 in i){const c=i[0];try{const l=new TextDecoder().decode(c);let u=c.findIndex(h=>Bp.includes(h));u>=0&&(o.info=l.substring(0,u),u+3<c.length&&(o.baseUp=c[u+1],o.baseDown=c[u+2],o.height=o.baseDown+o.baseUp,o.width=o.height,o.orientation=c[u+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse font info block")}}return o}catch(n){return console.error("Error parsing shape font:",n),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1}}}}class Up{parse(e){try{e.readInt16();const n=e.readInt16(),r=e.readInt16();if(n<=0)throw new Error("Invalid character count in font file");e.skip(r*4);const s=[];for(let o=0;o<n;o++){const c=e.readUint16(),l=e.readUint16(),u=e.readUint32();(c!==0||l!==0||u!==0)&&s.push({code:c,length:l,offset:u})}const i={};for(const o of s)try{e.setPosition(o.offset);const c=e.readBytes(o.length);c.length===o.length&&(i[o.code]=c)}catch{console.warn(`Failed to read bigfont data for code ${o.code}`)}const a={data:i,info:"",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1};if(0 in i){const o=i[0];try{const c=this.utf8ArrayToStr(o);let l=c.pos;l>=0&&(a.info=c.text,l++,l+3<o.length&&(o.length-l>4?(a.height=o[l++],l++,a.orientation=o[l++]===0?"horizontal":"vertical",a.width=o[l++],a.baseUp=a.height,a.baseDown=0,a.isExtended=!0):(a.baseUp=o[l++],a.baseDown=o[l++],a.height=a.baseDown+a.baseUp,a.width=a.height,a.orientation=o[l]===0?"horizontal":"vertical")))}catch{console.warn("Failed to parse bigfont info block")}}return a}catch(n){return console.error("Error parsing big font:",n),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1}}}utf8ArrayToStr(e){let n="",r=0;for(;r<e.length;){const s=e[r];switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:{const i=e[r++];n+=String.fromCharCode((s&31)<<6|i&63);break}case 14:{const i=e[r++],a=e[r++];n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(a&63)<<0);break}}if(n.charCodeAt(n.length-1)===0)break;r++}return{text:n,pos:r}}}class Pp{parse(e){try{const n=e.readInt32();if(n<=0)throw new Error("Invalid character count in font file");const r=e.readInt16(),s=e.readBytes(r),i={data:{},info:"",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1};try{const c=new TextDecoder().decode(s);let l=c.indexOf("\0");l>=0&&(i.info=c.substring(0,l),l+3<s.length&&(i.baseUp=s[l+1],i.baseDown=s[l+2],i.height=i.baseUp+i.baseDown,i.width=i.height,i.orientation=s[l+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse unifont info block")}const a={},o={};for(let c=0;c<n-1;c++)try{const l=e.readUint16(),u=e.readUint16();if(u>0){const h=e.readBytes(u);if(h.length===u){const{name:f,bytecode:p}=ma(h);p.length>0&&(a[l]=p,f&&(o[f]=l))}}}catch{console.warn("Failed to read unifont character data");break}return i.data=a,i.names=Object.keys(o).length>0?o:void 0,i}catch(n){return console.error("Error parsing unifont:",n),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,height:Ue,width:Ue,orientation:"horizontal",isExtended:!1}}}}class Np{static createParser(e){switch(e){case me.SHAPES:return new _p;case me.BIGFONT:return new Up;case me.UNIFONT:return new Pp;default:throw new Error(`Unsupported font type: ${e}`)}}}class ce{constructor(e=0,n=0){this.x=e,this.y=n}set(e,n){return this.x=e,this.y=n,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}clone(){return new ce(this.x,this.y)}add(e){return this.x+=e.x,this.y+=e.y,this}subtract(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e,this.y*=e,this}divide(e){return e!==0&&(this.x/=e,this.y/=e),this}multiplyScalars(e,n){return this.x*=e,this.y*=n,this}divideScalars(e,n){return e!==0&&(this.x/=e),n!==0&&(this.y/=n),this}distanceTo(e){const n=this.x-e.x,r=this.y-e.y;return Math.sqrt(n*n+r*r)}}const ya=Math.PI/4;class Zt{static fromBulge(e,n,r){const s=Math.max(-1,Math.min(1,r));return new Zt({start:e,end:n,bulge:s})}static fromOctant(e,n,r,s,i){return new Zt({center:e,radius:n,startOctant:r,octantCount:s,isClockwise:i})}constructor(e){if(e.start&&e.end&&e.bulge!==void 0){this.start=e.start.clone(),this.end=e.end.clone(),this.bulge=e.bulge,this.isClockwise=e.bulge<0;const n=this.end.clone().subtract(this.start),r=n.length();if(Math.abs(this.bulge)*r/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(n.y,n.x),this.endAngle=this.startAngle;return}const s=4*Math.atan(Math.abs(this.bulge));this.radius=r/(2*Math.sin(s/2));const i=this.start.clone().add(n.clone().divide(2)),a=new ce(-n.y,n.x);a.normalize(),a.multiply(Math.abs(this.radius*Math.cos(s/2))),this.center=i.clone(),this.isClockwise?this.center.subtract(a):this.center.add(a),this.startAngle=Math.atan2(this.start.y-this.center.y,this.start.x-this.center.x),this.endAngle=Math.atan2(this.end.y-this.center.y,this.end.x-this.center.x),this.isClockwise?this.endAngle>=this.startAngle&&(this.endAngle-=2*Math.PI):this.endAngle<=this.startAngle&&(this.endAngle+=2*Math.PI)}else if(e.center&&e.radius!==void 0&&e.startOctant!==void 0&&e.octantCount!==void 0&&e.isClockwise!==void 0){this.center=e.center.clone(),this.radius=e.radius,this.isClockwise=e.isClockwise,this.startAngle=e.startOctant*ya;const n=(e.octantCount===0?8:e.octantCount)*ya;this.endAngle=this.startAngle+(this.isClockwise?-n:n),this.start=this.center.clone().add(new ce(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new ce(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))}else throw new Error("Invalid arc parameters")}tessellate(e=Math.PI/18){if(this.radius===0)return[this.start.clone(),this.end.clone()];const n=[this.start.clone()],r=Math.abs(this.endAngle-this.startAngle),s=Math.max(1,Math.floor(r/e));for(let i=1;i<s;i++){const a=i/s,o=this.isClockwise?this.startAngle-a*r:this.startAngle+a*r;n.push(this.center.clone().add(new ce(this.radius*Math.cos(o),this.radius*Math.sin(o))))}return n.push(this.end?this.end.clone():this.center.clone().add(new ce(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),n}}class Jt{constructor(e,n=[]){this.lastPoint=e,this.polylines=n}get bbox(){if(this._bbox)return this._bbox;let e=1/0,n=-1/0,r=1/0,s=-1/0;return this.polylines.forEach(i=>{i.forEach(a=>{e=Math.min(e,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),s=Math.max(s,a.y)})}),this._bbox={minX:e,minY:r,maxX:n,maxY:s},this._bbox}offset(e,n=!0){var r,s;return n?new Jt((r=this.lastPoint)==null?void 0:r.clone().add(e),this.polylines.map(i=>i.map(a=>a.clone().add(e)))):((s=this.lastPoint)==null||s.add(e),this.polylines.forEach(i=>i.forEach(a=>a.add(e))),this._bbox&&(this._bbox.maxX+=e.x,this._bbox.minX+=e.x,this._bbox.maxY+=e.y,this._bbox.minY+=e.y),this)}normalizeToOrigin(e=!1){const n=this.bbox;return this.offset(new ce(-n.minX,-n.minY),e)}toSVG(e={}){const{strokeWidth:n="0.5%",strokeColor:r="black",isAutoFit:s=!1}=e;let i,a;if(s){const o=this.bbox,c=.2,l=o.maxX-o.minX,u=o.maxY-o.minY,h=l===0?u:l,f=u===0?l:u,p=o.minX-h*c,y=o.maxX+h*c,m=o.minY-f*c,b=o.maxY+f*c;a=this.polylines.map(v=>{let w="";return v.forEach((T,C)=>{const E=T.x,R=-T.y;w+=C===0?`M ${E} ${R} `:`L ${E} ${R} `}),`<path d="${w}" stroke="${r}" stroke-width="${n}" fill="none"/>`}).join(""),i=`${p} ${-b} ${y-p} ${b-m}`}else i="0 0 20 20",a=this.polylines.map(o=>{let c="";return o.forEach((l,u)=>{const h=l.x+5,f=-l.y+15;c+=u===0?`M ${h} ${f} `:`L ${h} ${f} `}),`<path d="${c}" stroke="${r}" stroke-width="${n}" fill="none"/>`}).join("");return`<svg width="100%" height="100%" viewBox="${i}" preserveAspectRatio="xMidYMid meet">${a}</svg>`}}const Gp=Math.PI/18;class Hp{constructor(e){this.shapeCache=new Map,this.subshapeCache=new Map,this.shapeData=new Map,this.fontData=e}release(){this.shapeCache.clear(),this.subshapeCache.clear(),this.shapeData.clear()}getCharShape(e,n){const r=n/this.fontData.content.height;return this.parseAndScale(e,{factor:r})}parseAndScale(e,n){if(e===0)return;let r;if(this.shapeCache.has(e))r=this.shapeCache.get(e);else{const s=this.fontData.content.data;if(s[e]){const i=s[e];r=this.parseShape(i,{flushOnEnd:!0}),this.shapeData.set(e,r),this.shapeCache.set(e,r)}}if(r){if(n.factor!==void 0)return this.scaleShapeByFactor(r,n.factor);if(n.height!==void 0){const s=n.width??n.height;return this.scaleShapeByHeightAndWidth(r,n.height,s)}else return r}}scaleShapeByFactor(e,n){var r;return new Jt((r=e.lastPoint)==null?void 0:r.clone().multiply(n),e.polylines.map(s=>s.map(i=>i.clone().multiply(n))))}scaleShapeByHeightAndWidth(e,n,r){var s;const i=e.bbox,a=i.maxY-i.minY,o=i.maxX-i.minX,c=a>0?n/a:1,l=o>0?r/o:1,u=(s=e.lastPoint)==null?void 0:s.clone();u&&(u.x*=l,u.y*=c);const h=e.polylines.map(f=>f.map(p=>{const y=p.clone();return y.x*=l,y.y*=c,y}));return new Jt(u,h)}parseShape(e,n={}){let r=new ce;const s=[];let i=[];const a=[];let o=n.initialPenDown??!1;o&&i.push(r.clone());const c={currentPoint:r,polylines:s,currentPolyline:i,sp:a,isPenDown:o,scale:1,flushEndPolyline:n.flushOnEnd??!1};for(let l=0;l<e.length;l++){const u=e[l];u<=15?l=this.handleSpecialCommand(u,e,l,c):this.handleVectorCommand(u,c)}return new Jt(c.currentPoint,c.polylines)}handleSpecialCommand(e,n,r,s){let i=r;switch(e){case 0:s.flushEndPolyline&&s.currentPolyline.length>1&&s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[],s.isPenDown=!1;break;case 1:s.isPenDown=!0,s.currentPolyline.push(s.currentPoint.clone());break;case 2:s.isPenDown=!1,s.currentPolyline.length>1&&s.polylines.push(s.currentPolyline.slice()),s.currentPolyline=[];break;case 3:i++,s.scale/=n[i];break;case 4:i++,s.scale*=n[i];break;case 5:if(s.sp.length===4)throw new Error("The position stack is only four locations deep");s.sp.push(s.currentPoint.clone());break;case 6:s.currentPoint=s.sp.pop()??s.currentPoint;break;case 7:i=this.handleSubshapeCommand(n,i,s);break;case 8:i=this.handleXYDisplacement(n,i,s);break;case 9:i=this.handleMultipleXYDisplacements(n,i,s);break;case 10:i=this.handleOctantArc(n,i,s);break;case 11:i=this.handleFractionalArc(n,i,s);break;case 12:i=this.handleBulgeArc(n,i,s);break;case 13:i=this.handleMultipleBulgeArcs(n,i,s);break;case 14:i=this.skipCode(n,++i);break}return i}handleVectorCommand(e,n){const r=(e&240)>>4,s=e&15,i=this.getVectorForDirection(s);n.currentPoint.add(i.multiply(r*n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone())}getVectorForDirection(e){const n=new ce;switch(e){case 0:n.x=1;break;case 1:n.x=1,n.y=.5;break;case 2:n.x=1,n.y=1;break;case 3:n.x=.5,n.y=1;break;case 4:n.y=1;break;case 5:n.x=-.5,n.y=1;break;case 6:n.x=-1,n.y=1;break;case 7:n.x=-1,n.y=.5;break;case 8:n.x=-1;break;case 9:n.x=-1,n.y=-.5;break;case 10:n.x=-1,n.y=-1;break;case 11:n.x=-.5,n.y=-1;break;case 12:n.y=-1;break;case 13:n.x=.5,n.y=-1;break;case 14:n.x=1,n.y=-1;break;case 15:n.x=1,n.y=-.5;break}return n}handleSubshapeCommand(e,n,r){let s=n,i=0,a,o=r.scale*this.fontData.content.height,c=o;const l=r.currentPoint.clone();switch(r.currentPolyline.length>1&&(r.polylines.push(r.currentPolyline.slice()),r.currentPolyline=[]),this.fontData.header.fontType){case me.SHAPES:s++,i=e[s];break;case me.BIGFONT:s++,i=e[s],i===0&&(s++,i=e[s++]<<8|e[s++],l.x=ke.byteToSByte(e[s++])*r.scale,l.y=ke.byteToSByte(e[s++])*r.scale,this.fontData.content.isExtended&&(c=e[s++]*r.scale),o=e[s]*r.scale);break;case me.UNIFONT:s++,i=e[s++]<<8|e[s++];break}if(i!==0)if(this.fontData.header.fontType===me.UNIFONT){const u=r.isPenDown;a=this.getScaledSubshapeAtInsertPoint(i,c,o,l,u),a!=null&&a.polylines.some(h=>h.length>=2)&&(r.polylines.push(...a.polylines.slice()),a.lastPoint&&(r.currentPoint=a.lastPoint.clone()),r.currentPolyline=[],r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone()))}else a=this.getScaledSubshapeAtInsertPoint(i,c,o,l),a&&r.polylines.push(...a.polylines.slice()),r.currentPolyline=[];return s}handleXYDisplacement(e,n,r){let s=n;const i=new ce;return i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),r.currentPoint.add(i.multiply(r.scale)),r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone()),s}handleMultipleXYDisplacements(e,n,r){let s=n;for(;;){const i=new ce;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0)break;r.currentPoint.add(i.multiply(r.scale)),r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone())}return s}handleOctantArc(e,n,r){var s;let i=n;const a=e[++i]*r.scale,o=ke.byteToSByte(e[++i]),c=(o&112)>>4;let l=o&7;const u=o<0,h=Math.PI/4*c,f=r.currentPoint.clone().subtract(new ce(Math.cos(h)*a,Math.sin(h)*a)),p=Zt.fromOctant(f,a,c,l,u);if(r.isPenDown){const y=p.tessellate();r.currentPolyline.pop(),r.currentPolyline.push(...y.slice())}return r.currentPoint=(s=p.tessellate().pop())==null?void 0:s.clone(),i}handleFractionalArc(e,n,r){let s=n;const i=e[++s],a=e[++s],o=e[++s],c=e[++s],l=(o*255+c)*r.scale,u=ke.byteToSByte(e[++s]),h=(u&112)>>4;let f=u&7;f===0&&(f=8),a!==0&&f--;const p=Math.PI/4;let y=p*f,m=Gp,b=1;u<0&&(m=-m,y=-y,b=-1);let v=p*h,w=v+y;v+=p*i/256*b,w+=p*a/256*b;const T=r.currentPoint.clone().subtract(new ce(l*Math.cos(v),l*Math.sin(v)));if(r.currentPoint=T.clone().add(new ce(l*Math.cos(w),l*Math.sin(w))),r.isPenDown){let C=v;const E=[];if(E.push(T.clone().add(new ce(l*Math.cos(C),l*Math.sin(C)))),m>0)for(;C+m<w;)C+=m,E.push(T.clone().add(new ce(l*Math.cos(C),l*Math.sin(C))));else for(;C+m>w;)C+=m,E.push(T.clone().add(new ce(l*Math.cos(C),l*Math.sin(C))));E.push(T.clone().add(new ce(l*Math.cos(w),l*Math.sin(w)))),r.currentPolyline.push(...E)}return s}handleBulgeArc(e,n,r){let s=n;const i=new ce;i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]);const a=ke.byteToSByte(e[++s]);return r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline),s}handleMultipleBulgeArcs(e,n,r){let s=n;for(;;){const i=new ce;if(i.x=ke.byteToSByte(e[++s]),i.y=ke.byteToSByte(e[++s]),i.x===0&&i.y===0)break;const a=ke.byteToSByte(e[++s]);r.currentPoint=this.handleArcSegment(r.currentPoint,i,a,r.scale,r.isPenDown,r.currentPolyline)}return s}skipCode(e,n){switch(e[n]){case 0:break;case 1:break;case 2:break;case 3:case 4:n++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case me.SHAPES:n++;break;case me.BIGFONT:n++,e[n]===0&&(n+=this.fontData.content.isExtended?6:5);break;case me.UNIFONT:n+=2;break}break;case 8:n+=2;break;case 9:for(;;){const r=e[++n],s=e[++n];if(r===0&&s===0)break}break;case 10:n+=2;break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;;){const r=e[++n],s=e[++n];if(r===0&&s===0)break;n++}break}return n}getScaledSubshapeAtInsertPoint(e,n,r,s,i=!1){let a;if(i){const c=this.fontData.content.data[e];if(!c)return;a=this.parseShape(c,{initialPenDown:!0,flushOnEnd:!0})}else if(a=this.subshapeCache.get(e),!a){const c=this.fontData.content.data[e];if(!c)return;a=this.parseShape(c,{flushOnEnd:!1}),this.shapeData.set(e,a),this.subshapeCache.set(e,a)}const o=a.normalizeToOrigin(!0);return this.scaleShapeByHeightAndWidth(o,r,n).offset(s,!1)}handleArcSegment(e,n,r,s,i,a){n.x*=s,n.y*=s,r<-127&&(r=-127);const o=e.clone();if(i)if(r===0)a.push(o.clone().add(n));else{const c=o.clone().add(n),l=Zt.fromBulge(o,c,r/127).tessellate();a.push(...l.slice(1))}return o.add(n),o}}class ba{constructor(e){if(e instanceof ArrayBuffer){const n=new ke(e),r=new Dp().parse(n),s=Np.createParser(r.fontType).parse(n);this.fontData={header:r,content:s}}else this.fontData=e;this.shapeParser=new Hp(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}hasShape(e){return this.getShapeCode(e)!==void 0}getShapeCode(e){const n=this.fontData.content.names;if(n)return n[e.toUpperCase()]}getShapeName(e){const n=this.fontData.content.names;if(n){for(const[r,s]of Object.entries(n))if(s===e)return r}}getShapeByName(e,n){const r=this.getShapeCode(e);if(r!==void 0)return this.getCharShape(r,n)}getCharShape(e,n){let r=this.shapeParser.getCharShape(e,n);return r&&this.fontData.header.fontType===me.BIGFONT&&r.bbox.minY<=n*.5&&(r=r.normalizeToOrigin()),r}release(){this.shapeParser.release()}}function Wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function zp(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var xa={exports:{}},Pr={},Dn={};Dn.byteLength=qp,Dn.toByteArray=Yp,Dn.fromByteArray=Zp;for(var Je=[],Pe=[],Vp=typeof Uint8Array<"u"?Uint8Array:Array,Nr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bt=0,jp=Nr.length;Bt<jp;++Bt)Je[Bt]=Nr[Bt],Pe[Nr.charCodeAt(Bt)]=Bt;Pe[45]=62,Pe[95]=63;function va(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function qp(t){var e=va(t),n=e[0],r=e[1];return(n+r)*3/4-r}function $p(t,e,n){return(e+n)*3/4-n}function Yp(t){var e,n=va(t),r=n[0],s=n[1],i=new Vp($p(t,r,s)),a=0,o=s>0?r-4:r,c;for(c=0;c<o;c+=4)e=Pe[t.charCodeAt(c)]<<18|Pe[t.charCodeAt(c+1)]<<12|Pe[t.charCodeAt(c+2)]<<6|Pe[t.charCodeAt(c+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return s===2&&(e=Pe[t.charCodeAt(c)]<<2|Pe[t.charCodeAt(c+1)]>>4,i[a++]=e&255),s===1&&(e=Pe[t.charCodeAt(c)]<<10|Pe[t.charCodeAt(c+1)]<<4|Pe[t.charCodeAt(c+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function Xp(t){return Je[t>>18&63]+Je[t>>12&63]+Je[t>>6&63]+Je[t&63]}function Kp(t,e,n){for(var r,s=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(Xp(r));return s.join("")}function Zp(t){for(var e,n=t.length,r=n%3,s=[],i=16383,a=0,o=n-r;a<o;a+=i)s.push(Kp(t,a,a+i>o?o:a+i));return r===1?(e=t[n-1],s.push(Je[e>>2]+Je[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],s.push(Je[e>>10]+Je[e>>4&63]+Je[e<<2&63]+"=")),s.join("")}var Gr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gr.read=function(t,e,n,r,s){var i,a,o=s*8-r-1,c=(1<<o)-1,l=c>>1,u=-7,h=n?s-1:0,f=n?-1:1,p=t[e+h];for(h+=f,i=p&(1<<-u)-1,p>>=-u,u+=o;u>0;i=i*256+t[e+h],h+=f,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=a*256+t[e+h],h+=f,u-=8);if(i===0)i=1-l;else{if(i===c)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,r),i=i-l}return(p?-1:1)*a*Math.pow(2,i-r)},Gr.write=function(t,e,n,r,s,i){var a,o,c,l=i*8-s-1,u=(1<<l)-1,h=u>>1,f=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,y=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+h>=1?e+=f/c:e+=f*Math.pow(2,1-h),e*c>=2&&(a++,c/=2),a+h>=u?(o=0,a=u):a+h>=1?(o=(e*c-1)*Math.pow(2,s),a=a+h):(o=e*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;t[n+p]=o&255,p+=y,o/=256,s-=8);for(a=a<<s|o,l+=s;l>0;t[n+p]=a&255,p+=y,a/=256,l-=8);t[n+p-y]|=m*128};/*!
5
5
  * The buffer module from node.js, for the browser.
6
6
  *
7
7
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -20408,13 +20408,13 @@ class os {
20408
20408
  const xm = Math.PI / 18;
20409
20409
  class bm {
20410
20410
  constructor(t) {
20411
- this.shapeCache = /* @__PURE__ */ new Map(), this.shapeData = /* @__PURE__ */ new Map(), this.fontData = t;
20411
+ this.shapeCache = /* @__PURE__ */ new Map(), this.subshapeCache = /* @__PURE__ */ new Map(), this.shapeData = /* @__PURE__ */ new Map(), this.fontData = t;
20412
20412
  }
20413
20413
  /**
20414
20414
  * Releases parsed shapes and cached shapes
20415
20415
  */
20416
20416
  release() {
20417
- this.shapeCache.clear(), this.shapeData.clear();
20417
+ this.shapeCache.clear(), this.subshapeCache.clear(), this.shapeData.clear();
20418
20418
  }
20419
20419
  /**
20420
20420
  * Parses a character's shape with the given font size.
@@ -20442,7 +20442,7 @@ class bm {
20442
20442
  const i = this.fontData.content.data;
20443
20443
  if (i[t]) {
20444
20444
  const r = i[t];
20445
- s = this.parseShape(r), this.shapeData.set(t, s), this.shapeCache.set(t, s);
20445
+ s = this.parseShape(r, { flushOnEnd: !0 }), this.shapeData.set(t, s), this.shapeCache.set(t, s);
20446
20446
  }
20447
20447
  }
20448
20448
  if (s) {
@@ -20507,10 +20507,10 @@ class bm {
20507
20507
  sp: a,
20508
20508
  isPenDown: o,
20509
20509
  scale: 1,
20510
- // Only flush a pen-down polyline on shape end when parsing a unifont
20511
- // subshape with inherited pen (amgdt %%132). Global flush regresses bigfont
20512
- // subshape caches (e.g. gbcbig.shx CJK glyphs).
20513
- flushEndPolyline: e.initialPenDown ?? !1
20510
+ // Top-level glyphs flush trailing pen-down strokes at 0x00. Subshape
20511
+ // primitives and inherited-pen unifont subshapes (amgdt %%132) opt in
20512
+ // via flushOnEnd; bigfont subshape cache keeps flush off to avoid regressions.
20513
+ flushEndPolyline: e.flushOnEnd ?? !1
20514
20514
  };
20515
20515
  for (let h = 0; h < t.length; h++) {
20516
20516
  const l = t[h];
@@ -20831,12 +20831,12 @@ class bm {
20831
20831
  const c = this.fontData.content.data[t];
20832
20832
  if (!c)
20833
20833
  return;
20834
- a = this.parseShape(c, { initialPenDown: !0 });
20835
- } else if (a = this.shapeCache.get(t), !a) {
20834
+ a = this.parseShape(c, { initialPenDown: !0, flushOnEnd: !0 });
20835
+ } else if (a = this.subshapeCache.get(t), !a) {
20836
20836
  const c = this.fontData.content.data[t];
20837
20837
  if (!c)
20838
20838
  return;
20839
- a = this.parseShape(c), this.shapeData.set(t, a), this.shapeCache.set(t, a);
20839
+ a = this.parseShape(c, { flushOnEnd: !1 }), this.shapeData.set(t, a), this.subshapeCache.set(t, a);
20840
20840
  }
20841
20841
  const o = a.normalizeToOrigin(!0);
20842
20842
  return this.scaleShapeByHeightAndWidth(o, s, e).offset(i, !1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@mlightcad/mtext-parser": "^1.5.0",
47
- "@mlightcad/shx-parser": "^1.3.4",
47
+ "@mlightcad/shx-parser": "^1.3.5",
48
48
  "iconv-lite": "^0.7.0",
49
49
  "idb": "^8.0.3",
50
50
  "opentype.js": "^2.0.0"