@mlightcad/mtext-renderer 0.2.3 → 0.2.4

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
@@ -11965,6 +11965,7 @@ class gl {
11965
11965
  this.changeFont(e.changes.fontFace.family), this.currentFont && this.currentFont.includes(".shx") && console.log(`Doesn't support custom fonts: ${this.currentFont}`);
11966
11966
  break;
11967
11967
  }
11968
+ case "c":
11968
11969
  case "C":
11969
11970
  e.changes.aci ? e.changes.aci === 0 ? this._currentColor = this._options.byBlockColor : e.changes.aci === 256 ? this._currentColor = this._options.byLayerColor : this._currentColor = Da(e.changes.aci) : e.changes.rgb && (this._currentColor = (e.changes.rgb[0] << 16) + (e.changes.rgb[1] << 8) + e.changes.rgb[2]);
11970
11971
  break;
@@ -1,3 +1,3 @@
1
1
  (function(g,ge){typeof exports=="object"&&typeof module<"u"?ge(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],ge):(g=typeof globalThis<"u"?globalThis:g||self,ge(g.MTextRenderer={},g.THREE))})(this,function(g,ge){"use strict";function ga(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const A=ga(ge);class xt{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(r=>r!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...r){for(const n of this.listeners)n.call(null,e,...r)}}class St{constructor(){this.unsupportedChars={}}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class kt extends A.Shape{constructor(e){super(),this.width=0,this.char=e}}const Tt=(t,e)=>e.some(r=>t instanceof r);let gr,yr;function ya(){return gr||(gr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ma(){return yr||(yr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ft=new WeakMap,wt=new WeakMap,rt=new WeakMap;function ba(t){const e=new Promise((r,n)=>{const a=()=>{t.removeEventListener("success",s),t.removeEventListener("error",i)},s=()=>{r(Oe(t.result)),a()},i=()=>{n(t.error),a()};t.addEventListener("success",s),t.addEventListener("error",i)});return rt.set(e,t),e}function xa(t){if(Ft.has(t))return;const e=new Promise((r,n)=>{const a=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",i),t.removeEventListener("abort",i)},s=()=>{r(),a()},i=()=>{n(t.error||new DOMException("AbortError","AbortError")),a()};t.addEventListener("complete",s),t.addEventListener("error",i),t.addEventListener("abort",i)});Ft.set(t,e)}let Ct={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Ft.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Oe(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function mr(t){Ct=t(Ct)}function Sa(t){return ma().includes(t)?function(...e){return t.apply(Ot(this),e),Oe(this.request)}:function(...e){return Oe(t.apply(Ot(this),e))}}function ka(t){return typeof t=="function"?Sa(t):(t instanceof IDBTransaction&&xa(t),Tt(t,ya())?new Proxy(t,Ct):t)}function Oe(t){if(t instanceof IDBRequest)return ba(t);if(wt.has(t))return wt.get(t);const e=ka(t);return e!==t&&(wt.set(t,e),rt.set(e,t)),e}const Ot=t=>rt.get(t);function Ta(t,e,{blocked:r,upgrade:n,blocking:a,terminated:s}={}){const i=indexedDB.open(t,e),u=Oe(i);return n&&i.addEventListener("upgradeneeded",o=>{n(Oe(i.result),o.oldVersion,o.newVersion,Oe(i.transaction),o)}),r&&i.addEventListener("blocked",o=>r(o.oldVersion,o.newVersion,o)),u.then(o=>{s&&o.addEventListener("close",()=>s()),a&&o.addEventListener("versionchange",l=>a(l.oldVersion,l.newVersion,l))}).catch(()=>{}),u}const Fa=["get","getKey","getAll","getAllKeys","count"],wa=["put","add","delete","clear"],Et=new Map;function br(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Et.get(e))return Et.get(e);const r=e.replace(/FromIndex$/,""),n=e!==r,a=wa.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(a||Fa.includes(r)))return;const s=async function(i,...u){const o=this.transaction(i,a?"readwrite":"readonly");let l=o.store;return n&&(l=l.index(u.shift())),(await Promise.all([l[r](...u),a&&o.done]))[0]};return Et.set(e,s),s}mr(t=>({...t,get:(e,r,n)=>br(e,r)||t.get(e,r,n),has:(e,r)=>!!br(e,r)||t.has(e,r)}));const Ca=["continue","continuePrimaryKey","advance"],xr={},Ut=new WeakMap,Sr=new WeakMap,Oa={get(t,e){if(!Ca.includes(e))return t[e];let r=xr[e];return r||(r=xr[e]=function(...n){Ut.set(this,Sr.get(this)[e](...n))}),r}};async function*Ea(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const r=new Proxy(e,Oa);for(Sr.set(r,e),rt.set(r,Ot(e));e;)yield r,e=await(Ut.get(r)||e.continue()),Ut.delete(r)}function kr(t,e){return e===Symbol.asyncIterator&&Tt(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Tt(t,[IDBIndex,IDBObjectStore])}mr(t=>({...t,get(e,r,n){return kr(e,r)?Ea:t.get(e,r,n)},has(e,r){return kr(e,r)||t.has(e,r)}}));const Me={fonts:"fonts"},Lt=[{version:1,stores:[{name:Me.fonts,keyPath:"name"}]}],re=class re{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("unload",()=>{this.close()})}static get instance(){return re._instance||(re._instance=new re),re._instance}async set(e,r){await(await this.getDatabase()).put(Me.fonts,{...r,name:e})}async get(e){return await(await this.getDatabase()).get(Me.fonts,e)}async delete(e){await(await this.getDatabase()).delete(Me.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll(Me.fonts)}async clear(){await(await this.getDatabase()).clear(Me.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(re.DATABASE_NAME),re._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 Ta(re.DATABASE_NAME,re.DATABASE_VERSION,{upgrade:(e,r,n)=>this.handleUpgrade(e,r,n),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),re.instance.close()}}),this.db)}handleUpgrade(e,r,n){const a=Lt.filter(s=>s.version>r&&(!n||s.version<=n));for(const s of a)this.applySchemaVersion(e,s)}applySchemaVersion(e,r){for(const n of r.stores)e.objectStoreNames.contains(n.name)||e.createObjectStore(n.name,{keyPath:n.keyPath})}};re.DATABASE_NAME="mlightcad",re.DATABASE_VERSION=Lt[Lt.length-1].version;let ze=re;const Ua=t=>t.substring(t.lastIndexOf(".")+1),Tr=t=>t.split("/").pop(),Fr=t=>{const e=Tr(t);if(e){const r=e.lastIndexOf(".");return r===-1?e:e.substring(0,r)}return t},La=[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],Ra=t=>La[t];let Aa=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,r=100){const n=[],a=Da(e,r,this.data);for(let s=0,i=a.length;s<i;s++)n.push(...a[s].toShapes());return n}};function Da(t,e,r){const n=Array.from(t),a=e/r.resolution,s=(r.boundingBox.yMax-r.boundingBox.yMin+r.underlineThickness)*a,i=[];let u=0,o=0;for(let l=0;l<n.length;l++){const c=n[l];if(c===`
2
2
  `)u=0,o-=s;else{const p=Ma(c,a,u,o,r);u+=p.offsetX,i.push(p.path)}}return i}function Ma(t,e,r,n,a){const s=a.glyphs[t]||a.glyphs["?"];if(!s){console.error('THREE.Font: character "'+t+'" does not exists in font family '+a.familyName+".");return}const i=new ge.ShapePath;let u,o,l,c,p,h,f,v;if(s.o){const y=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let m=0,b=y.length;m<b;)switch(y[m++]){case"m":u=y[m++]*e+r,o=y[m++]*e+n,i.moveTo(u,o);break;case"l":u=y[m++]*e+r,o=y[m++]*e+n,i.lineTo(u,o);break;case"q":l=y[m++]*e+r,c=y[m++]*e+n,p=y[m++]*e+r,h=y[m++]*e+n,i.quadraticCurveTo(p,h,l,c);break;case"b":l=y[m++]*e+r,c=y[m++]*e+n,p=y[m++]*e+r,h=y[m++]*e+n,f=y[m++]*e+r,v=y[m++]*e+n,i.bezierCurveTo(p,h,f,v,l,c);break}}return{offsetX:s.ha*e,path:i}}class Ba extends ge.ExtrudeGeometry{constructor(e,r={}){const n=r.font;if(n===void 0)super();else{const a=n.generateShapes(e,r.size);r.depth===void 0&&r.height!==void 0&&console.warn("THREE.TextGeometry: .height is now depreciated. Please use .depth instead"),r.depth=r.depth!==void 0?r.depth:r.height!==void 0?r.height:50,r.bevelThickness===void 0&&(r.bevelThickness=10),r.bevelSize===void 0&&(r.bevelSize=8),r.bevelEnabled===void 0&&(r.bevelEnabled=!1),super(a,r)}this.type="TextGeometry"}}class wr extends kt{constructor(e,r,n){super(e),this.isFound=!1,this.fontSize=r,this.font=n,this.width=this.getCharWidth(e,r,n)}toGeometry(){return new Ba(this.char,{font:this.font.font,depth:0,size:this.fontSize,curveSegments:3,bevelSegments:3})}getCharWidth(e,r,n){const a=n.data.glyphs[e];return a?(this.isFound=!0,a.ha*r/n.data.resolution):(this.isFound=!1,0)}}/*! https://mths.be/codepointat v0.2.0 by @mathias */String.prototype.codePointAt||function(){var t=function(){try{var r={},n=Object.defineProperty,a=n(r,r,r)&&n}catch{}return a}(),e=function(r){if(this==null)throw TypeError();var n=String(this),a=n.length,s=r?Number(r):0;if(s!=s&&(s=0),!(s<0||s>=a)){var i=n.charCodeAt(s),u;return i>=55296&&i<=56319&&a>s+1&&(u=n.charCodeAt(s+1),u>=56320&&u<=57343)?(i-55296)*1024+u-56320+65536:i}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}();var Rt=0,Cr=-3;function We(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Pa(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new We,this.dtree=new We}var Or=new We,Er=new We,At=new Uint8Array(30),Dt=new Uint16Array(30),Ur=new Uint8Array(30),Lr=new Uint16Array(30),Ia=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rr=new We,he=new Uint8Array(320);function Ar(t,e,r,n){var a,s;for(a=0;a<r;++a)t[a]=0;for(a=0;a<30-r;++a)t[a+r]=a/r|0;for(s=n,a=0;a<30;++a)e[a]=s,s+=1<<t[a]}function Ga(t,e){var r;for(r=0;r<7;++r)t.table[r]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,r=0;r<24;++r)t.trans[r]=256+r;for(r=0;r<144;++r)t.trans[24+r]=r;for(r=0;r<8;++r)t.trans[168+r]=280+r;for(r=0;r<112;++r)t.trans[176+r]=144+r;for(r=0;r<5;++r)e.table[r]=0;for(e.table[5]=32,r=0;r<32;++r)e.trans[r]=r}var Dr=new Uint16Array(16);function Mt(t,e,r,n){var a,s;for(a=0;a<16;++a)t.table[a]=0;for(a=0;a<n;++a)t.table[e[r+a]]++;for(t.table[0]=0,s=0,a=0;a<16;++a)Dr[a]=s,s+=t.table[a];for(a=0;a<n;++a)e[r+a]&&(t.trans[Dr[e[r+a]]++]=a)}function Na(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=t.tag&1;return t.tag>>>=1,e}function fe(t,e,r){if(!e)return r;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,n+r}function Bt(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=0,n=0,a=0,s=t.tag;do n=2*n+(s&1),s>>>=1,++a,r+=e.table[a],n-=e.table[a];while(n>=0);return t.tag=s,t.bitcount-=a,e.trans[r+n]}function _a(t,e,r){var n,a,s,i,u,o;for(n=fe(t,5,257),a=fe(t,5,1),s=fe(t,4,4),i=0;i<19;++i)he[i]=0;for(i=0;i<s;++i){var l=fe(t,3,0);he[Ia[i]]=l}for(Mt(Rr,he,0,19),u=0;u<n+a;){var c=Bt(t,Rr);switch(c){case 16:var p=he[u-1];for(o=fe(t,2,3);o;--o)he[u++]=p;break;case 17:for(o=fe(t,3,3);o;--o)he[u++]=0;break;case 18:for(o=fe(t,7,11);o;--o)he[u++]=0;break;default:he[u++]=c;break}}Mt(e,he,0,n),Mt(r,he,n,a)}function Mr(t,e,r){for(;;){var n=Bt(t,e);if(n===256)return Rt;if(n<256)t.dest[t.destLen++]=n;else{var a,s,i,u;for(n-=257,a=fe(t,At[n],Dt[n]),s=Bt(t,r),i=t.destLen-fe(t,Ur[s],Lr[s]),u=i;u<i+a;++u)t.dest[t.destLen++]=t.dest[u]}}}function Ha(t){for(var e,r,n;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if(e=t.source[t.sourceIndex+1],e=256*e+t.source[t.sourceIndex],r=t.source[t.sourceIndex+3],r=256*r+t.source[t.sourceIndex+2],e!==(~r&65535))return Cr;for(t.sourceIndex+=4,n=e;n;--n)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,Rt}function za(t,e){var r=new Pa(t,e),n,a,s;do{switch(n=Na(r),a=fe(r,2,0),a){case 0:s=Ha(r);break;case 1:s=Mr(r,Or,Er);break;case 2:_a(r,r.ltree,r.dtree),s=Mr(r,r.ltree,r.dtree);break;default:s=Cr}if(s!==Rt)throw new Error("Data error")}while(!n);return r.destLen<r.dest.length?typeof r.dest.slice=="function"?r.dest.slice(0,r.destLen):r.dest.subarray(0,r.destLen):r.dest}Ga(Or,Er),Ar(At,Dt,4,3),Ar(Ur,Lr,2,1),At[28]=0,Dt[28]=258;var Wa=za;function Be(t,e,r,n,a){return Math.pow(1-a,3)*t+3*Math.pow(1-a,2)*a*e+3*(1-a)*Math.pow(a,2)*r+Math.pow(a,3)*n}function xe(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}xe.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},xe.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))},xe.prototype.addX=function(t){this.addPoint(t,null)},xe.prototype.addY=function(t){this.addPoint(null,t)},xe.prototype.addBezier=function(t,e,r,n,a,s,i,u){var o=[t,e],l=[r,n],c=[a,s],p=[i,u];this.addPoint(t,e),this.addPoint(i,u);for(var h=0;h<=1;h++){var f=6*o[h]-12*l[h]+6*c[h],v=-3*o[h]+9*l[h]-9*c[h]+3*p[h],y=3*l[h]-3*o[h];if(v===0){if(f===0)continue;var m=-y/f;0<m&&m<1&&(h===0&&this.addX(Be(o[h],l[h],c[h],p[h],m)),h===1&&this.addY(Be(o[h],l[h],c[h],p[h],m)));continue}var b=Math.pow(f,2)-4*y*v;if(!(b<0)){var k=(-f+Math.sqrt(b))/(2*v);0<k&&k<1&&(h===0&&this.addX(Be(o[h],l[h],c[h],p[h],k)),h===1&&this.addY(Be(o[h],l[h],c[h],p[h],k)));var x=(-f-Math.sqrt(b))/(2*v);0<x&&x<1&&(h===0&&this.addX(Be(o[h],l[h],c[h],p[h],x)),h===1&&this.addY(Be(o[h],l[h],c[h],p[h],x)))}}},xe.prototype.addQuad=function(t,e,r,n,a,s){var i=t+.6666666666666666*(r-t),u=e+2/3*(n-e),o=i+1/3*(a-t),l=u+1/3*(s-e);this.addBezier(t,e,i,u,o,l,a,s)};function _(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}_.prototype.moveTo=function(t,e){this.commands.push({type:"M",x:t,y:e})},_.prototype.lineTo=function(t,e){this.commands.push({type:"L",x:t,y:e})},_.prototype.curveTo=_.prototype.bezierCurveTo=function(t,e,r,n,a,s){this.commands.push({type:"C",x1:t,y1:e,x2:r,y2:n,x:a,y:s})},_.prototype.quadTo=_.prototype.quadraticCurveTo=function(t,e,r,n){this.commands.push({type:"Q",x1:t,y1:e,x:r,y:n})},_.prototype.close=_.prototype.closePath=function(){this.commands.push({type:"Z"})},_.prototype.extend=function(t){if(t.commands)t=t.commands;else if(t instanceof xe){var 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)},_.prototype.getBoundingBox=function(){for(var t=new xe,e=0,r=0,n=0,a=0,s=0;s<this.commands.length;s++){var i=this.commands[s];switch(i.type){case"M":t.addPoint(i.x,i.y),e=n=i.x,r=a=i.y;break;case"L":t.addPoint(i.x,i.y),n=i.x,a=i.y;break;case"Q":t.addQuad(n,a,i.x1,i.y1,i.x,i.y),n=i.x,a=i.y;break;case"C":t.addBezier(n,a,i.x1,i.y1,i.x2,i.y2,i.x,i.y),n=i.x,a=i.y;break;case"Z":n=e,a=r;break;default:throw new Error("Unexpected path command "+i.type)}}return t.isEmpty()&&t.addPoint(0,0),t},_.prototype.draw=function(t){t.beginPath();for(var e=0;e<this.commands.length;e+=1){var r=this.commands[e];r.type==="M"?t.moveTo(r.x,r.y):r.type==="L"?t.lineTo(r.x,r.y):r.type==="C"?t.bezierCurveTo(r.x1,r.y1,r.x2,r.y2,r.x,r.y):r.type==="Q"?t.quadraticCurveTo(r.x1,r.y1,r.x,r.y):r.type==="Z"&&t.closePath()}this.fill&&(t.fillStyle=this.fill,t.fill()),this.stroke&&(t.strokeStyle=this.stroke,t.lineWidth=this.strokeWidth,t.stroke())},_.prototype.toPathData=function(t){t=t!==void 0?t:2;function e(i){return Math.round(i)===i?""+Math.round(i):i.toFixed(t)}function r(){for(var i=arguments,u="",o=0;o<arguments.length;o+=1){var l=i[o];l>=0&&o>0&&(u+=" "),u+=e(l)}return u}for(var n="",a=0;a<this.commands.length;a+=1){var s=this.commands[a];s.type==="M"?n+="M"+r(s.x,s.y):s.type==="L"?n+="L"+r(s.x,s.y):s.type==="C"?n+="C"+r(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?n+="Q"+r(s.x1,s.y1,s.x,s.y):s.type==="Z"&&(n+="Z")}return n},_.prototype.toSVG=function(t){var e='<path d="';return e+=this.toPathData(t),e+='"',this.fill&&this.fill!=="black"&&(this.fill===null?e+=' fill="none"':e+=' fill="'+this.fill+'"'),this.stroke&&(e+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),e+="/>",e},_.prototype.toDOMElement=function(t){var e=this.toPathData(t),r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),r};function Br(t){throw new Error(t)}function Pr(t,e){t||Br(e)}var E={fail:Br,argument:Pr,assert:Pr},Ir=32768,Gr=2147483648,Pe={},S={},U={};function ie(t){return function(){return t}}S.BYTE=function(t){return E.argument(t>=0&&t<=255,"Byte value should be between 0 and 255."),[t]},U.BYTE=ie(1),S.CHAR=function(t){return[t.charCodeAt(0)]},U.CHAR=ie(1),S.CHARARRAY=function(t){typeof t>"u"&&(t="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var e=[],r=0;r<t.length;r+=1)e[r]=t.charCodeAt(r);return e},U.CHARARRAY=function(t){return typeof t>"u"?0:t.length},S.USHORT=function(t){return[t>>8&255,t&255]},U.USHORT=ie(2),S.SHORT=function(t){return t>=Ir&&(t=-(2*Ir-t)),[t>>8&255,t&255]},U.SHORT=ie(2),S.UINT24=function(t){return[t>>16&255,t>>8&255,t&255]},U.UINT24=ie(3),S.ULONG=function(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]},U.ULONG=ie(4),S.LONG=function(t){return t>=Gr&&(t=-(2*Gr-t)),[t>>24&255,t>>16&255,t>>8&255,t&255]},U.LONG=ie(4),S.FIXED=S.ULONG,U.FIXED=U.ULONG,S.FWORD=S.SHORT,U.FWORD=U.SHORT,S.UFWORD=S.USHORT,U.UFWORD=U.USHORT,S.LONGDATETIME=function(t){return[0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255]},U.LONGDATETIME=ie(8),S.TAG=function(t){return E.argument(t.length===4,"Tag should be exactly 4 ASCII characters."),[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]},U.TAG=ie(4),S.Card8=S.BYTE,U.Card8=U.BYTE,S.Card16=S.USHORT,U.Card16=U.USHORT,S.OffSize=S.BYTE,U.OffSize=U.BYTE,S.SID=S.USHORT,U.SID=U.USHORT,S.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?S.NUMBER16(t):S.NUMBER32(t)},U.NUMBER=function(t){return S.NUMBER(t).length},S.NUMBER16=function(t){return[28,t>>8&255,t&255]},U.NUMBER16=ie(3),S.NUMBER32=function(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]},U.NUMBER32=ie(5),S.REAL=function(t){var e=t.toString(),r=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(r){var n=parseFloat("1e"+((r[2]?+r[2]:0)+r[1].length));e=(Math.round(t*n)/n).toString()}for(var a="",s=0,i=e.length;s<i;s+=1){var u=e[s];u==="e"?a+=e[++s]==="-"?"c":"b":u==="."?a+="a":u==="-"?a+="e":a+=u}a+=a.length&1?"f":"ff";for(var o=[30],l=0,c=a.length;l<c;l+=2)o.push(parseInt(a.substr(l,2),16));return o},U.REAL=function(t){return S.REAL(t).length},S.NAME=S.CHARARRAY,U.NAME=U.CHARARRAY,S.STRING=S.CHARARRAY,U.STRING=U.CHARARRAY,Pe.UTF8=function(t,e,r){for(var n=[],a=r,s=0;s<a;s++,e+=1)n[s]=t.getUint8(e);return String.fromCharCode.apply(null,n)},Pe.UTF16=function(t,e,r){for(var n=[],a=r/2,s=0;s<a;s++,e+=2)n[s]=t.getUint16(e);return String.fromCharCode.apply(null,n)},S.UTF16=function(t){for(var e=[],r=0;r<t.length;r+=1){var n=t.charCodeAt(r);e[e.length]=n>>8&255,e[e.length]=n&255}return e},U.UTF16=function(t){return t.length*2};var Pt={"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":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Pe.MACSTRING=function(t,e,r,n){var a=Pt[n];if(a!==void 0){for(var s="",i=0;i<r;i++){var u=t.getUint8(e+i);u<=127?s+=String.fromCharCode(u):s+=a[u&127]}return s}};var nt=typeof WeakMap=="function"&&new WeakMap,at,Va=function(t){if(!at){at={};for(var e in Pt)at[e]=new String(e)}var r=at[t];if(r!==void 0){if(nt){var n=nt.get(r);if(n!==void 0)return n}var a=Pt[t];if(a!==void 0){for(var s={},i=0;i<a.length;i++)s[a.charCodeAt(i)]=i+128;return nt&&nt.set(r,s),s}}};S.MACSTRING=function(t,e){var r=Va(e);if(r!==void 0){for(var n=[],a=0;a<t.length;a++){var s=t.charCodeAt(a);if(s>=128&&(s=r[s],s===void 0))return;n[a]=s}return n}},U.MACSTRING=function(t,e){var r=S.MACSTRING(t,e);return r!==void 0?r.length:0};function It(t){return t>=-128&&t<=127}function qa(t,e,r){for(var n=0,a=t.length;e<a&&n<64&&t[e]===0;)++e,++n;return r.push(128|n-1),e}function Xa(t,e,r){for(var n=0,a=t.length,s=e;s<a&&n<64;){var i=t[s];if(!It(i)||i===0&&s+1<a&&t[s+1]===0)break;++s,++n}r.push(n-1);for(var u=e;u<s;++u)r.push(t[u]+256&255);return s}function Ya(t,e,r){for(var n=0,a=t.length,s=e;s<a&&n<64;){var i=t[s];if(i===0||It(i)&&s+1<a&&It(t[s+1]))break;++s,++n}r.push(64|n-1);for(var u=e;u<s;++u){var o=t[u];r.push(o+65536>>8&255,o+256&255)}return s}S.VARDELTAS=function(t){for(var e=0,r=[];e<t.length;){var n=t[e];n===0?e=qa(t,e,r):n>=-128&&n<=127?e=Xa(t,e,r):e=Ya(t,e,r)}return r},S.INDEX=function(t){for(var e=1,r=[e],n=[],a=0;a<t.length;a+=1){var s=S.OBJECT(t[a]);Array.prototype.push.apply(n,s),e+=s.length,r.push(e)}if(n.length===0)return[0,0];for(var i=[],u=1+Math.floor(Math.log(e)/Math.log(2))/8|0,o=[void 0,S.BYTE,S.USHORT,S.UINT24,S.ULONG][u],l=0;l<r.length;l+=1){var c=o(r[l]);Array.prototype.push.apply(i,c)}return Array.prototype.concat(S.Card16(t.length),S.OffSize(u),i,n)},U.INDEX=function(t){return S.INDEX(t).length},S.DICT=function(t){for(var e=[],r=Object.keys(t),n=r.length,a=0;a<n;a+=1){var s=parseInt(r[a],0),i=t[s];e=e.concat(S.OPERAND(i.value,i.type)),e=e.concat(S.OPERATOR(s))}return e},U.DICT=function(t){return S.DICT(t).length},S.OPERATOR=function(t){return t<1200?[t]:[12,t-1200]},S.OPERAND=function(t,e){var r=[];if(Array.isArray(e))for(var n=0;n<e.length;n+=1)E.argument(t.length===e.length,"Not enough arguments given for type"+e),r=r.concat(S.OPERAND(t[n],e[n]));else if(e==="SID")r=r.concat(S.NUMBER(t));else if(e==="offset")r=r.concat(S.NUMBER32(t));else if(e==="number")r=r.concat(S.NUMBER(t));else if(e==="real")r=r.concat(S.REAL(t));else throw new Error("Unknown operand type "+e);return r},S.OP=S.BYTE,U.OP=U.BYTE;var st=typeof WeakMap=="function"&&new WeakMap;S.CHARSTRING=function(t){if(st){var e=st.get(t);if(e!==void 0)return e}for(var r=[],n=t.length,a=0;a<n;a+=1){var s=t[a];r=r.concat(S[s.type](s.value))}return st&&st.set(t,r),r},U.CHARSTRING=function(t){return S.CHARSTRING(t).length},S.OBJECT=function(t){var e=S[t.type];return E.argument(e!==void 0,"No encoding function for type "+t.type),e(t.value)},U.OBJECT=function(t){var e=U[t.type];return E.argument(e!==void 0,"No sizeOf function for type "+t.type),e(t.value)},S.TABLE=function(t){for(var e=[],r=t.fields.length,n=[],a=[],s=0;s<r;s+=1){var i=t.fields[s],u=S[i.type];E.argument(u!==void 0,"No encoding function for field type "+i.type+" ("+i.name+")");var o=t[i.name];o===void 0&&(o=i.value);var l=u(o);i.type==="TABLE"?(a.push(e.length),e=e.concat([0,0]),n.push(l)):e=e.concat(l)}for(var c=0;c<n.length;c+=1){var p=a[c],h=e.length;E.argument(h<65536,"Table "+t.tableName+" too big."),e[p]=h>>8,e[p+1]=h&255,e=e.concat(n[c])}return e},U.TABLE=function(t){for(var e=0,r=t.fields.length,n=0;n<r;n+=1){var a=t.fields[n],s=U[a.type];E.argument(s!==void 0,"No sizeOf function for field type "+a.type+" ("+a.name+")");var i=t[a.name];i===void 0&&(i=a.value),e+=s(i),a.type==="TABLE"&&(e+=2)}return e},S.RECORD=S.TABLE,U.RECORD=U.TABLE,S.LITERAL=function(t){return t},U.LITERAL=function(t){return t.length};function z(t,e,r){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var n=0;n<e.length;n+=1){var a=e[n];this[a.name]=a.value}if(this.tableName=t,this.fields=e,r)for(var s=Object.keys(r),i=0;i<s.length;i+=1){var u=s[i],o=r[u];this[u]!==void 0&&(this[u]=o)}}z.prototype.encode=function(){return S.TABLE(this)},z.prototype.sizeOf=function(){return U.TABLE(this)};function Ve(t,e,r){r===void 0&&(r=e.length);var n=new Array(e.length+1);n[0]={name:t+"Count",type:"USHORT",value:r};for(var a=0;a<e.length;a++)n[a+1]={name:t+a,type:"USHORT",value:e[a]};return n}function Gt(t,e,r){var n=e.length,a=new Array(n+1);a[0]={name:t+"Count",type:"USHORT",value:n};for(var s=0;s<n;s++)a[s+1]={name:t+s,type:"TABLE",value:r(e[s],s)};return a}function qe(t,e,r){var n=e.length,a=[];a[0]={name:t+"Count",type:"USHORT",value:n};for(var s=0;s<n;s++)a=a.concat(r(e[s],s));return a}function it(t){t.format===1?z.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(Ve("glyph",t.glyphs))):t.format===2?z.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(qe("rangeRecord",t.ranges,function(e){return[{name:"startGlyphID",type:"USHORT",value:e.start},{name:"endGlyphID",type:"USHORT",value:e.end},{name:"startCoverageIndex",type:"USHORT",value:e.index}]}))):E.assert(!1,"Coverage format must be 1 or 2.")}it.prototype=Object.create(z.prototype),it.prototype.constructor=it;function ot(t){z.call(this,"scriptListTable",qe("scriptRecord",t,function(e,r){var n=e.script,a=n.defaultLangSys;return E.assert(!!a,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+r,type:"TAG",value:e.tag},{name:"script"+r,type:"TABLE",value:new z("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new z("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(Ve("featureIndex",a.featureIndexes)))}].concat(qe("langSys",n.langSysRecords,function(s,i){var u=s.langSys;return[{name:"langSysTag"+i,type:"TAG",value:s.tag},{name:"langSys"+i,type:"TABLE",value:new z("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:u.reqFeatureIndex}].concat(Ve("featureIndex",u.featureIndexes)))}]})))}]}))}ot.prototype=Object.create(z.prototype),ot.prototype.constructor=ot;function ut(t){z.call(this,"featureListTable",qe("featureRecord",t,function(e,r){var n=e.feature;return[{name:"featureTag"+r,type:"TAG",value:e.tag},{name:"feature"+r,type:"TABLE",value:new z("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(Ve("lookupListIndex",n.lookupListIndexes)))}]}))}ut.prototype=Object.create(z.prototype),ut.prototype.constructor=ut;function lt(t,e){z.call(this,"lookupListTable",Gt("lookup",t,function(r){var n=e[r.lookupType];return E.assert(!!n,"Unable to write GSUB lookup type "+r.lookupType+" tables."),new z("lookupTable",[{name:"lookupType",type:"USHORT",value:r.lookupType},{name:"lookupFlag",type:"USHORT",value:r.lookupFlag}].concat(Gt("subtable",r.subtables,n)))}))}lt.prototype=Object.create(z.prototype),lt.prototype.constructor=lt;var T={Table:z,Record:z,Coverage:it,ScriptList:ot,FeatureList:ut,LookupList:lt,ushortList:Ve,tableList:Gt,recordList:qe};function Nr(t,e){return t.getUint8(e)}function ct(t,e){return t.getUint16(e,!1)}function Za(t,e){return t.getInt16(e,!1)}function Nt(t,e){return t.getUint32(e,!1)}function _r(t,e){var r=t.getInt16(e,!1),n=t.getUint16(e+2,!1);return r+n/65535}function ja(t,e){for(var r="",n=e;n<e+4;n+=1)r+=String.fromCharCode(t.getInt8(n));return r}function Ka(t,e,r){for(var n=0,a=0;a<r;a+=1)n<<=8,n+=t.getUint8(e+a);return n}function Qa(t,e,r){for(var n=[],a=e;a<r;a+=1)n.push(t.getUint8(a));return n}function Ja(t){for(var e="",r=0;r<t.length;r+=1)e+=String.fromCharCode(t[r]);return e}var $a={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function d(t,e){this.data=t,this.offset=e,this.relativeOffset=0}d.prototype.parseByte=function(){var t=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},d.prototype.parseChar=function(){var t=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,t},d.prototype.parseCard8=d.prototype.parseByte,d.prototype.parseUShort=function(){var t=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},d.prototype.parseCard16=d.prototype.parseUShort,d.prototype.parseSID=d.prototype.parseUShort,d.prototype.parseOffset16=d.prototype.parseUShort,d.prototype.parseShort=function(){var t=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,t},d.prototype.parseF2Dot14=function(){var t=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,t},d.prototype.parseULong=function(){var t=Nt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},d.prototype.parseOffset32=d.prototype.parseULong,d.prototype.parseFixed=function(){var t=_r(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,t},d.prototype.parseString=function(t){var e=this.data,r=this.offset+this.relativeOffset,n="";this.relativeOffset+=t;for(var a=0;a<t;a++)n+=String.fromCharCode(e.getUint8(r+a));return n},d.prototype.parseTag=function(){return this.parseString(4)},d.prototype.parseLongDateTime=function(){var t=Nt(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t},d.prototype.parseVersion=function(t){var e=ct(this.data,this.offset+this.relativeOffset),r=ct(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t===void 0&&(t=4096),e+r/t/10},d.prototype.skip=function(t,e){e===void 0&&(e=1),this.relativeOffset+=$a[t]*e},d.prototype.parseULongList=function(t){t===void 0&&(t=this.parseULong());for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getUint32(n),n+=4;return this.relativeOffset+=t*4,e},d.prototype.parseOffset16List=d.prototype.parseUShortList=function(t){t===void 0&&(t=this.parseUShort());for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getUint16(n),n+=2;return this.relativeOffset+=t*2,e},d.prototype.parseShortList=function(t){for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getInt16(n),n+=2;return this.relativeOffset+=t*2,e},d.prototype.parseByteList=function(t){for(var e=new Array(t),r=this.data,n=this.offset+this.relativeOffset,a=0;a<t;a++)e[a]=r.getUint8(n++);return this.relativeOffset+=t,e},d.prototype.parseList=function(t,e){e||(e=t,t=this.parseUShort());for(var r=new Array(t),n=0;n<t;n++)r[n]=e.call(this);return r},d.prototype.parseList32=function(t,e){e||(e=t,t=this.parseULong());for(var r=new Array(t),n=0;n<t;n++)r[n]=e.call(this);return r},d.prototype.parseRecordList=function(t,e){e||(e=t,t=this.parseUShort());for(var r=new Array(t),n=Object.keys(e),a=0;a<t;a++){for(var s={},i=0;i<n.length;i++){var u=n[i],o=e[u];s[u]=o.call(this)}r[a]=s}return r},d.prototype.parseRecordList32=function(t,e){e||(e=t,t=this.parseULong());for(var r=new Array(t),n=Object.keys(e),a=0;a<t;a++){for(var s={},i=0;i<n.length;i++){var u=n[i],o=e[u];s[u]=o.call(this)}r[a]=s}return r},d.prototype.parseStruct=function(t){if(typeof t=="function")return t.call(this);for(var e=Object.keys(t),r={},n=0;n<e.length;n++){var a=e[n],s=t[a];r[a]=s.call(this)}return r},d.prototype.parseValueRecord=function(t){if(t===void 0&&(t=this.parseUShort()),t!==0){var 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}},d.prototype.parseValueRecordList=function(){for(var t=this.parseUShort(),e=this.parseUShort(),r=new Array(e),n=0;n<e;n++)r[n]=this.parseValueRecord(t);return r},d.prototype.parsePointer=function(t){var e=this.parseOffset16();if(e>0)return new d(this.data,this.offset+e).parseStruct(t)},d.prototype.parsePointer32=function(t){var e=this.parseOffset32();if(e>0)return new d(this.data,this.offset+e).parseStruct(t)},d.prototype.parseListOfLists=function(t){for(var e=this.parseOffset16List(),r=e.length,n=this.relativeOffset,a=new Array(r),s=0;s<r;s++){var i=e[s];if(i===0){a[s]=void 0;continue}if(this.relativeOffset=i,t){for(var u=this.parseOffset16List(),o=new Array(u.length),l=0;l<u.length;l++)this.relativeOffset=i+u[l],o[l]=t.call(this);a[s]=o}else a[s]=this.parseUShortList()}return this.relativeOffset=n,a},d.prototype.parseCoverage=function(){var t=this.offset+this.relativeOffset,e=this.parseUShort(),r=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(r)};if(e===2){for(var n=new Array(r),a=0;a<r;a++)n[a]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+t.toString(16)+": Coverage format must be 1 or 2.")},d.prototype.parseClassDef=function(){var t=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(e===2)return{format:2,ranges:this.parseRecordList({start:d.uShort,end:d.uShort,classId:d.uShort})};throw new Error("0x"+t.toString(16)+": ClassDef format must be 1 or 2.")},d.list=function(t,e){return function(){return this.parseList(t,e)}},d.list32=function(t,e){return function(){return this.parseList32(t,e)}},d.recordList=function(t,e){return function(){return this.parseRecordList(t,e)}},d.recordList32=function(t,e){return function(){return this.parseRecordList32(t,e)}},d.pointer=function(t){return function(){return this.parsePointer(t)}},d.pointer32=function(t){return function(){return this.parsePointer32(t)}},d.tag=d.prototype.parseTag,d.byte=d.prototype.parseByte,d.uShort=d.offset16=d.prototype.parseUShort,d.uShortList=d.prototype.parseUShortList,d.uLong=d.offset32=d.prototype.parseULong,d.uLongList=d.prototype.parseULongList,d.struct=d.prototype.parseStruct,d.coverage=d.prototype.parseCoverage,d.classDef=d.prototype.parseClassDef;var Hr={reserved:d.uShort,reqFeatureIndex:d.uShort,featureIndexes:d.uShortList};d.prototype.parseScriptList=function(){return this.parsePointer(d.recordList({tag:d.tag,script:d.pointer({defaultLangSys:d.pointer(Hr),langSysRecords:d.recordList({tag:d.tag,langSys:d.pointer(Hr)})})}))||[]},d.prototype.parseFeatureList=function(){return this.parsePointer(d.recordList({tag:d.tag,feature:d.pointer({featureParams:d.offset16,lookupListIndexes:d.uShortList})}))||[]},d.prototype.parseLookupList=function(t){return this.parsePointer(d.list(d.pointer(function(){var e=this.parseUShort();E.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var r=this.parseUShort(),n=r&16;return{lookupType:e,lookupFlag:r,subtables:this.parseList(d.pointer(t[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]},d.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var t=this.parseUShort(),e=this.parseUShort();E.argument(t===1&&e<1,"GPOS/GSUB feature variations table unknown.");var r=this.parseRecordList32({conditionSetOffset:d.offset32,featureTableSubstitutionOffset:d.offset32});return r})||[]};var w={getByte:Nr,getCard8:Nr,getUShort:ct,getCard16:ct,getShort:Za,getULong:Nt,getFixed:_r,getTag:ja,getOffset:Ka,getBytes:Qa,bytesToString:Ja,Parser:d};function es(t,e){e.parseUShort(),t.length=e.parseULong(),t.language=e.parseULong();var r;t.groupCount=r=e.parseULong(),t.glyphIndexMap={};for(var n=0;n<r;n+=1)for(var a=e.parseULong(),s=e.parseULong(),i=e.parseULong(),u=a;u<=s;u+=1)t.glyphIndexMap[u]=i,i++}function ts(t,e,r,n,a){t.length=e.parseUShort(),t.language=e.parseUShort();var s;t.segCount=s=e.parseUShort()>>1,e.skip("uShort",3),t.glyphIndexMap={};for(var i=new w.Parser(r,n+a+14),u=new w.Parser(r,n+a+16+s*2),o=new w.Parser(r,n+a+16+s*4),l=new w.Parser(r,n+a+16+s*6),c=n+a+16+s*8,p=0;p<s-1;p+=1)for(var h=void 0,f=i.parseUShort(),v=u.parseUShort(),y=o.parseShort(),m=l.parseUShort(),b=v;b<=f;b+=1)m!==0?(c=l.offset+l.relativeOffset-2,c+=m,c+=(b-v)*2,h=w.getUShort(r,c),h!==0&&(h=h+y&65535)):h=b+y&65535,t.glyphIndexMap[b]=h}function rs(t,e){var r={};r.version=w.getUShort(t,e),E.argument(r.version===0,"cmap table version should be 0."),r.numTables=w.getUShort(t,e+2);for(var n=-1,a=r.numTables-1;a>=0;a-=1){var s=w.getUShort(t,e+4+a*8),i=w.getUShort(t,e+4+a*8+2);if(s===3&&(i===0||i===1||i===10)||s===0&&(i===0||i===1||i===2||i===3||i===4)){n=w.getULong(t,e+4+a*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");var u=new w.Parser(t,e+n);if(r.format=u.parseUShort(),r.format===12)es(r,u);else if(r.format===4)ts(r,u,t,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+r.format+").");return r}function ns(t,e,r){t.segments.push({end:e,start:e,delta:-(e-r),offset:0,glyphIndex:r})}function as(t){t.segments.push({end:65535,start:65535,delta:1,offset:0})}function ss(t){var e=!0,r;for(r=t.length-1;r>0;r-=1){var n=t.get(r);if(n.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var a=[{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||(a=a.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),a=a.concat([{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}]);var s=new T.Table("cmap",a);for(s.segments=[],r=0;r<t.length;r+=1){for(var i=t.get(r),u=0;u<i.unicodes.length;u+=1)ns(s,i.unicodes[u],r);s.segments=s.segments.sort(function(k,x){return k.start-x.start})}as(s);var o=s.segments.length,l=0,c=[],p=[],h=[],f=[],v=[],y=[];for(r=0;r<o;r+=1){var m=s.segments[r];m.end<=65535&&m.start<=65535?(c=c.concat({name:"end_"+r,type:"USHORT",value:m.end}),p=p.concat({name:"start_"+r,type:"USHORT",value:m.start}),h=h.concat({name:"idDelta_"+r,type:"SHORT",value:m.delta}),f=f.concat({name:"idRangeOffset_"+r,type:"USHORT",value:m.offset}),m.glyphId!==void 0&&(v=v.concat({name:"glyph_"+r,type:"USHORT",value:m.glyphId}))):l+=1,!e&&m.glyphIndex!==void 0&&(y=y.concat({name:"cmap12Start_"+r,type:"ULONG",value:m.start}),y=y.concat({name:"cmap12End_"+r,type:"ULONG",value:m.end}),y=y.concat({name:"cmap12Glyph_"+r,type:"ULONG",value:m.glyphIndex}))}if(s.segCountX2=(o-l)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(o-l)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange,s.fields=s.fields.concat(c),s.fields.push({name:"reservedPad",type:"USHORT",value:0}),s.fields=s.fields.concat(p),s.fields=s.fields.concat(h),s.fields=s.fields.concat(f),s.fields=s.fields.concat(v),s.cmap4Length=14+c.length*2+2+p.length*2+h.length*2+f.length*2+v.length*2,!e){var b=16+y.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields=s.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:b},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:y.length/3}]),s.fields=s.fields.concat(y)}return s}var zr={parse:rs,make:ss},ht=[".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"],is=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],os=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Ee=[".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 Wr(t){this.font=t}Wr.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),r=this.font.glyphs;if(r){for(var n=0;n<r.length;n+=1)for(var a=r.get(n),s=0;s<a.unicodes.length;s+=1)if(a.unicodes[s]===e)return n}return null};function Vr(t){this.cmap=t}Vr.prototype.charToGlyphIndex=function(t){return this.cmap.glyphIndexMap[t.codePointAt(0)]||0};function ft(t,e){this.encoding=t,this.charset=e}ft.prototype.charToGlyphIndex=function(t){var e=t.codePointAt(0),r=this.encoding[e];return this.charset.indexOf(r)};function _t(t){switch(t.version){case 1:this.names=Ee.slice();break;case 2:this.names=new Array(t.numberOfGlyphs);for(var e=0;e<t.numberOfGlyphs;e++)t.glyphNameIndex[e]<Ee.length?this.names[e]=Ee[t.glyphNameIndex[e]]:this.names[e]=t.names[t.glyphNameIndex[e]-Ee.length];break;case 2.5:this.names=new Array(t.numberOfGlyphs);for(var r=0;r<t.numberOfGlyphs;r++)this.names[r]=Ee[r+t.glyphNameIndex[r]];break;case 3:this.names=[];break;default:this.names=[];break}}_t.prototype.nameToGlyphIndex=function(t){return this.names.indexOf(t)},_t.prototype.glyphIndexToName=function(t){return this.names[t]};function us(t){for(var e,r=t.tables.cmap.glyphIndexMap,n=Object.keys(r),a=0;a<n.length;a+=1){var s=n[a],i=r[s];e=t.glyphs.get(i),e.addUnicode(parseInt(s))}for(var u=0;u<t.glyphs.length;u+=1)e=t.glyphs.get(u),t.cffEncoding?t.isCIDFont?e.name="gid"+u:e.name=t.cffEncoding.charset[u]:t.glyphNames.names&&(e.name=t.glyphNames.glyphIndexToName(u))}function ls(t){t._IndexToUnicodeMap={};for(var e=t.tables.cmap.glyphIndexMap,r=Object.keys(e),n=0;n<r.length;n+=1){var a=r[n],s=e[a];t._IndexToUnicodeMap[s]===void 0?t._IndexToUnicodeMap[s]={unicodes:[parseInt(a)]}:t._IndexToUnicodeMap[s].unicodes.push(parseInt(a))}}function cs(t,e){e.lowMemory?ls(t):us(t)}function hs(t,e,r,n,a){t.beginPath(),t.moveTo(e,r),t.lineTo(n,a),t.stroke()}var Ue={line:hs};function fs(t,e){var r=e||new _;return{configurable:!0,get:function(){return typeof r=="function"&&(r=r()),r},set:function(n){r=n}}}function ne(t){this.bindConstructorValues(t)}ne.prototype.bindConstructorValues=function(t){this.index=t.index||0,this.name=t.name||null,this.unicode=t.unicode||void 0,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),Object.defineProperty(this,"path",fs(this,t.path))},ne.prototype.addUnicode=function(t){this.unicodes.length===0&&(this.unicode=t),this.unicodes.push(t)},ne.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},ne.prototype.getPath=function(t,e,r,n,a){t=t!==void 0?t:0,e=e!==void 0?e:0,r=r!==void 0?r:72;var s,i;n||(n={});var u=n.xScale,o=n.yScale;if(n.hinting&&a&&a.hinting&&(i=this.path&&a.hinting.exec(this,r)),i)s=a.hinting.getCommands(i),t=Math.round(t),e=Math.round(e),u=o=1;else{s=this.path.commands;var l=1/(this.path.unitsPerEm||1e3)*r;u===void 0&&(u=l),o===void 0&&(o=l)}for(var c=new _,p=0;p<s.length;p+=1){var h=s[p];h.type==="M"?c.moveTo(t+h.x*u,e+-h.y*o):h.type==="L"?c.lineTo(t+h.x*u,e+-h.y*o):h.type==="Q"?c.quadraticCurveTo(t+h.x1*u,e+-h.y1*o,t+h.x*u,e+-h.y*o):h.type==="C"?c.curveTo(t+h.x1*u,e+-h.y1*o,t+h.x2*u,e+-h.y2*o,t+h.x*u,e+-h.y*o):h.type==="Z"&&c.closePath()}return c},ne.prototype.getContours=function(){if(this.points===void 0)return[];for(var t=[],e=[],r=0;r<this.points.length;r+=1){var n=this.points[r];e.push(n),n.lastPointOfContour&&(t.push(e),e=[])}return E.argument(e.length===0,"There are still points left in the current contour."),t},ne.prototype.getMetrics=function(){for(var t=this.path.commands,e=[],r=[],n=0;n<t.length;n+=1){var a=t[n];a.type!=="Z"&&(e.push(a.x),r.push(a.y)),(a.type==="Q"||a.type==="C")&&(e.push(a.x1),r.push(a.y1)),a.type==="C"&&(e.push(a.x2),r.push(a.y2))}var s={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,r),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,r),leftSideBearing:this.leftSideBearing};return isFinite(s.xMin)||(s.xMin=0),isFinite(s.xMax)||(s.xMax=this.advanceWidth),isFinite(s.yMin)||(s.yMin=0),isFinite(s.yMax)||(s.yMax=0),s.rightSideBearing=this.advanceWidth-s.leftSideBearing-(s.xMax-s.xMin),s},ne.prototype.draw=function(t,e,r,n,a){this.getPath(e,r,n,a).draw(t)},ne.prototype.drawPoints=function(t,e,r,n){function a(p,h,f,v){t.beginPath();for(var y=0;y<p.length;y+=1)t.moveTo(h+p[y].x*v,f+p[y].y*v),t.arc(h+p[y].x*v,f+p[y].y*v,2,0,Math.PI*2,!1);t.closePath(),t.fill()}e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:24;for(var s=1/this.path.unitsPerEm*n,i=[],u=[],o=this.path,l=0;l<o.commands.length;l+=1){var c=o.commands[l];c.x!==void 0&&i.push({x:c.x,y:-c.y}),c.x1!==void 0&&u.push({x:c.x1,y:-c.y1}),c.x2!==void 0&&u.push({x:c.x2,y:-c.y2})}t.fillStyle="blue",a(i,e,r,s),t.fillStyle="red",a(u,e,r,s)},ne.prototype.drawMetrics=function(t,e,r,n){var a;e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:24,a=1/this.path.unitsPerEm*n,t.lineWidth=1,t.strokeStyle="black",Ue.line(t,e,-1e4,e,1e4),Ue.line(t,-1e4,r,1e4,r);var s=this.xMin||0,i=this.yMin||0,u=this.xMax||0,o=this.yMax||0,l=this.advanceWidth||0;t.strokeStyle="blue",Ue.line(t,e+s*a,-1e4,e+s*a,1e4),Ue.line(t,e+u*a,-1e4,e+u*a,1e4),Ue.line(t,-1e4,r+-i*a,1e4,r+-i*a),Ue.line(t,-1e4,r+-o*a,1e4,r+-o*a),t.strokeStyle="green",Ue.line(t,e+l*a,-1e4,e+l*a,1e4)};function pt(t,e,r){Object.defineProperty(t,e,{get:function(){return t.path,t[r]},set:function(n){t[r]=n},enumerable:!0,configurable:!0})}function Ht(t,e){if(this.font=t,this.glyphs={},Array.isArray(e))for(var r=0;r<e.length;r++){var n=e[r];n.path.unitsPerEm=t.unitsPerEm,this.glyphs[r]=n}this.length=e&&e.length||0}Ht.prototype.get=function(t){if(this.glyphs[t]===void 0){this.font._push(t),typeof this.glyphs[t]=="function"&&(this.glyphs[t]=this.glyphs[t]());var e=this.glyphs[t],r=this.font._IndexToUnicodeMap[t];if(r)for(var n=0;n<r.unicodes.length;n++)e.addUnicode(r.unicodes[n]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+t: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]},Ht.prototype.push=function(t,e){this.glyphs[t]=e,this.length++};function ps(t,e){return new ne({index:e,font:t})}function ds(t,e,r,n,a,s){return function(){var i=new ne({index:e,font:t});return i.path=function(){r(i,n,a);var u=s(t.glyphs,i);return u.unitsPerEm=t.unitsPerEm,u},pt(i,"xMin","_xMin"),pt(i,"xMax","_xMax"),pt(i,"yMin","_yMin"),pt(i,"yMax","_yMax"),i}}function vs(t,e,r,n){return function(){var a=new ne({index:e,font:t});return a.path=function(){var s=r(t,a,n);return s.unitsPerEm=t.unitsPerEm,s},a}}var pe={GlyphSet:Ht,glyphLoader:ps,ttfGlyphLoader:ds,cffGlyphLoader:vs};function qr(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r+=1)if(!qr(t[r],e[r]))return!1;return!0}else return!1}function zt(t){var e;return t.length<1240?e=107:t.length<33900?e=1131:e=32768,e}function Se(t,e,r){var n=[],a=[],s=w.getCard16(t,e),i,u;if(s!==0){var o=w.getByte(t,e+2);i=e+(s+1)*o+2;for(var l=e+3,c=0;c<s+1;c+=1)n.push(w.getOffset(t,l,o)),l+=o;u=i+n[s]}else u=e+2;for(var p=0;p<n.length-1;p+=1){var h=w.getBytes(t,i+n[p],i+n[p+1]);r&&(h=r(h)),a.push(h)}return{objects:a,startOffset:e,endOffset:u}}function gs(t,e){var r=[],n=w.getCard16(t,e),a,s;if(n!==0){var i=w.getByte(t,e+2);a=e+(n+1)*i+2;for(var u=e+3,o=0;o<n+1;o+=1)r.push(w.getOffset(t,u,i)),u+=i;s=a+r[n]}else s=e+2;return{offsets:r,startOffset:e,endOffset:s}}function ys(t,e,r,n,a){var s=w.getCard16(r,n),i=0;if(s!==0){var u=w.getByte(r,n+2);i=n+(s+1)*u+2}var o=w.getBytes(r,i+e[t],i+e[t+1]);return o}function ms(t){for(var e="",r=15,n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var a=t.parseByte(),s=a>>4,i=a&15;if(s===r||(e+=n[s],i===r))break;e+=n[i]}return parseFloat(e)}function bs(t,e){var r,n,a,s;if(e===28)return r=t.parseByte(),n=t.parseByte(),r<<8|n;if(e===29)return r=t.parseByte(),n=t.parseByte(),a=t.parseByte(),s=t.parseByte(),r<<24|n<<16|a<<8|s;if(e===30)return ms(t);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return r=t.parseByte(),(e-247)*256+r+108;if(e>=251&&e<=254)return r=t.parseByte(),-(e-251)*256-r-108;throw new Error("Invalid b0 "+e)}function xs(t){for(var e={},r=0;r<t.length;r+=1){var n=t[r][0],a=t[r][1],s=void 0;if(a.length===1?s=a[0]:s=a,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=s}return e}function Xr(t,e,r){e=e!==void 0?e:0;var n=new w.Parser(t,e),a=[],s=[];for(r=r!==void 0?r:t.length;n.relativeOffset<r;){var i=n.parseByte();i<=21?(i===12&&(i=1200+n.parseByte()),a.push([i,s]),s=[]):s.push(bs(n,i))}return xs(a)}function Xe(t,e){return e<=390?e=ht[e]:e=t[e-391],e}function Yr(t,e,r){for(var n={},a,s=0;s<e.length;s+=1){var i=e[s];if(Array.isArray(i.type)){var u=[];u.length=i.type.length;for(var o=0;o<i.type.length;o++)a=t[i.op]!==void 0?t[i.op][o]:void 0,a===void 0&&(a=i.value!==void 0&&i.value[o]!==void 0?i.value[o]:null),i.type[o]==="SID"&&(a=Xe(r,a)),u[o]=a;n[i.name]=u}else a=t[i.op],a===void 0&&(a=i.value!==void 0?i.value:null),i.type==="SID"&&(a=Xe(r,a)),n[i.name]=a}return n}function Ss(t,e){var r={};return r.formatMajor=w.getCard8(t,e),r.formatMinor=w.getCard8(t,e+1),r.size=w.getCard8(t,e+2),r.offsetSize=w.getCard8(t,e+3),r.startOffset=e,r.endOffset=e+4,r}var Zr=[{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"}],jr=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function ks(t,e){var r=Xr(t,0,t.byteLength);return Yr(r,Zr,e)}function Kr(t,e,r,n){var a=Xr(t,e,r);return Yr(a,jr,n)}function Qr(t,e,r,n){for(var a=[],s=0;s<r.length;s+=1){var i=new DataView(new Uint8Array(r[s]).buffer),u=ks(i,n);u._subrs=[],u._subrsBias=0,u._defaultWidthX=0,u._nominalWidthX=0;var o=u.private[0],l=u.private[1];if(o!==0&&l!==0){var c=Kr(t,l+e,o,n);if(u._defaultWidthX=c.defaultWidthX,u._nominalWidthX=c.nominalWidthX,c.subrs!==0){var p=l+c.subrs,h=Se(t,p+e);u._subrs=h.objects,u._subrsBias=zt(u._subrs)}u._privateDict=c}a.push(u)}return a}function Ts(t,e,r,n){var a,s,i=new w.Parser(t,e);r-=1;var u=[".notdef"],o=i.parseCard8();if(o===0)for(var l=0;l<r;l+=1)a=i.parseSID(),u.push(Xe(n,a));else if(o===1)for(;u.length<=r;){a=i.parseSID(),s=i.parseCard8();for(var c=0;c<=s;c+=1)u.push(Xe(n,a)),a+=1}else if(o===2)for(;u.length<=r;){a=i.parseSID(),s=i.parseCard16();for(var p=0;p<=s;p+=1)u.push(Xe(n,a)),a+=1}else throw new Error("Unknown charset format "+o);return u}function Fs(t,e,r){var n,a={},s=new w.Parser(t,e),i=s.parseCard8();if(i===0)for(var u=s.parseCard8(),o=0;o<u;o+=1)n=s.parseCard8(),a[n]=o;else if(i===1){var l=s.parseCard8();n=1;for(var c=0;c<l;c+=1)for(var p=s.parseCard8(),h=s.parseCard8(),f=p;f<=p+h;f+=1)a[f]=n,n+=1}else throw new Error("Unknown encoding format "+i);return new ft(a,r)}function Jr(t,e,r){var n,a,s,i,u=new _,o=[],l=0,c=!1,p=!1,h=0,f=0,v,y,m,b;if(t.isCIDFont){var k=t.tables.cff.topDict._fdSelect[e.index],x=t.tables.cff.topDict._fdArray[k];v=x._subrs,y=x._subrsBias,m=x._defaultWidthX,b=x._nominalWidthX}else v=t.tables.cff.topDict._subrs,y=t.tables.cff.topDict._subrsBias,m=t.tables.cff.topDict._defaultWidthX,b=t.tables.cff.topDict._nominalWidthX;var L=m;function C(O,H){p&&u.closePath(),u.moveTo(O,H),p=!0}function M(){var O;O=o.length%2!==0,O&&!c&&(L=o.shift()+b),l+=o.length>>1,o.length=0,c=!0}function R(O){for(var H,K,Q,ae,se,N,W,q,X,Y,V,j,B=0;B<O.length;){var Z=O[B];switch(B+=1,Z){case 1:M();break;case 3:M();break;case 4:o.length>1&&!c&&(L=o.shift()+b,c=!0),f+=o.pop(),C(h,f);break;case 5:for(;o.length>0;)h+=o.shift(),f+=o.shift(),u.lineTo(h,f);break;case 6:for(;o.length>0&&(h+=o.shift(),u.lineTo(h,f),o.length!==0);)f+=o.shift(),u.lineTo(h,f);break;case 7:for(;o.length>0&&(f+=o.shift(),u.lineTo(h,f),o.length!==0);)h+=o.shift(),u.lineTo(h,f);break;case 8:for(;o.length>0;)n=h+o.shift(),a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),h=s+o.shift(),f=i+o.shift(),u.curveTo(n,a,s,i,h,f);break;case 10:se=o.pop()+y,N=v[se],N&&R(N);break;case 11:return;case 12:switch(Z=O[B],B+=1,Z){case 35:n=h+o.shift(),a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),W=s+o.shift(),q=i+o.shift(),X=W+o.shift(),Y=q+o.shift(),V=X+o.shift(),j=Y+o.shift(),h=V+o.shift(),f=j+o.shift(),o.shift(),u.curveTo(n,a,s,i,W,q),u.curveTo(X,Y,V,j,h,f);break;case 34:n=h+o.shift(),a=f,s=n+o.shift(),i=a+o.shift(),W=s+o.shift(),q=i,X=W+o.shift(),Y=i,V=X+o.shift(),j=f,h=V+o.shift(),u.curveTo(n,a,s,i,W,q),u.curveTo(X,Y,V,j,h,f);break;case 36:n=h+o.shift(),a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),W=s+o.shift(),q=i,X=W+o.shift(),Y=i,V=X+o.shift(),j=Y+o.shift(),h=V+o.shift(),u.curveTo(n,a,s,i,W,q),u.curveTo(X,Y,V,j,h,f);break;case 37:n=h+o.shift(),a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),W=s+o.shift(),q=i+o.shift(),X=W+o.shift(),Y=q+o.shift(),V=X+o.shift(),j=Y+o.shift(),Math.abs(V-h)>Math.abs(j-f)?h=V+o.shift():f=j+o.shift(),u.curveTo(n,a,s,i,W,q),u.curveTo(X,Y,V,j,h,f);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Z),o.length=0}break;case 14:o.length>0&&!c&&(L=o.shift()+b,c=!0),p&&(u.closePath(),p=!1);break;case 18:M();break;case 19:case 20:M(),B+=l+7>>3;break;case 21:o.length>2&&!c&&(L=o.shift()+b,c=!0),f+=o.pop(),h+=o.pop(),C(h,f);break;case 22:o.length>1&&!c&&(L=o.shift()+b,c=!0),h+=o.pop(),C(h,f);break;case 23:M();break;case 24:for(;o.length>2;)n=h+o.shift(),a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),h=s+o.shift(),f=i+o.shift(),u.curveTo(n,a,s,i,h,f);h+=o.shift(),f+=o.shift(),u.lineTo(h,f);break;case 25:for(;o.length>6;)h+=o.shift(),f+=o.shift(),u.lineTo(h,f);n=h+o.shift(),a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),h=s+o.shift(),f=i+o.shift(),u.curveTo(n,a,s,i,h,f);break;case 26:for(o.length%2&&(h+=o.shift());o.length>0;)n=h,a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),h=s,f=i+o.shift(),u.curveTo(n,a,s,i,h,f);break;case 27:for(o.length%2&&(f+=o.shift());o.length>0;)n=h+o.shift(),a=f,s=n+o.shift(),i=a+o.shift(),h=s+o.shift(),f=i,u.curveTo(n,a,s,i,h,f);break;case 28:H=O[B],K=O[B+1],o.push((H<<24|K<<16)>>16),B+=2;break;case 29:se=o.pop()+t.gsubrsBias,N=t.gsubrs[se],N&&R(N);break;case 30:for(;o.length>0&&(n=h,a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),h=s+o.shift(),f=i+(o.length===1?o.shift():0),u.curveTo(n,a,s,i,h,f),o.length!==0);)n=h+o.shift(),a=f,s=n+o.shift(),i=a+o.shift(),f=i+o.shift(),h=s+(o.length===1?o.shift():0),u.curveTo(n,a,s,i,h,f);break;case 31:for(;o.length>0&&(n=h+o.shift(),a=f,s=n+o.shift(),i=a+o.shift(),f=i+o.shift(),h=s+(o.length===1?o.shift():0),u.curveTo(n,a,s,i,h,f),o.length!==0);)n=h,a=f+o.shift(),s=n+o.shift(),i=a+o.shift(),h=s+o.shift(),f=i+(o.length===1?o.shift():0),u.curveTo(n,a,s,i,h,f);break;default:Z<32?console.log("Glyph "+e.index+": unknown operator "+Z):Z<247?o.push(Z-139):Z<251?(H=O[B],B+=1,o.push((Z-247)*256+H+108)):Z<255?(H=O[B],B+=1,o.push(-(Z-251)*256-H-108)):(H=O[B],K=O[B+1],Q=O[B+2],ae=O[B+3],B+=4,o.push((H<<24|K<<16|Q<<8|ae)/65536))}}}return R(r),e.advanceWidth=L,u}function ws(t,e,r,n){var a=[],s,i=new w.Parser(t,e),u=i.parseCard8();if(u===0)for(var o=0;o<r;o++){if(s=i.parseCard8(),s>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+n+")");a.push(s)}else if(u===3){var l=i.parseCard16(),c=i.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var p,h=0;h<l;h++){if(s=i.parseCard8(),p=i.parseCard16(),s>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+n+")");if(p>r)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+p);for(;c<p;c++)a.push(s);c=p}if(p!==r)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+p)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+u);return a}function Cs(t,e,r,n){r.tables.cff={};var a=Ss(t,e),s=Se(t,a.endOffset,w.bytesToString),i=Se(t,s.endOffset),u=Se(t,i.endOffset,w.bytesToString),o=Se(t,u.endOffset);r.gsubrs=o.objects,r.gsubrsBias=zt(r.gsubrs);var l=Qr(t,e,i.objects,u.objects);if(l.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+l.length);var c=l[0];if(r.tables.cff.topDict=c,c._privateDict&&(r.defaultWidthX=c._privateDict.defaultWidthX,r.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(r.isCIDFont=!0),r.isCIDFont){var p=c.fdArray,h=c.fdSelect;if(p===0||h===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");p+=e;var f=Se(t,p),v=Qr(t,e,f.objects,u.objects);c._fdArray=v,h+=e,c._fdSelect=ws(t,h,r.numGlyphs,v.length)}var y=e+c.private[1],m=Kr(t,y,c.private[0],u.objects);if(r.defaultWidthX=m.defaultWidthX,r.nominalWidthX=m.nominalWidthX,m.subrs!==0){var b=y+m.subrs,k=Se(t,b);r.subrs=k.objects,r.subrsBias=zt(r.subrs)}else r.subrs=[],r.subrsBias=0;var x;n.lowMemory?(x=gs(t,e+c.charStrings),r.nGlyphs=x.offsets.length):(x=Se(t,e+c.charStrings),r.nGlyphs=x.objects.length);var L=Ts(t,e+c.charset,r.nGlyphs,u.objects);if(c.encoding===0?r.cffEncoding=new ft(is,L):c.encoding===1?r.cffEncoding=new ft(os,L):r.cffEncoding=Fs(t,e+c.encoding,L),r.encoding=r.encoding||r.cffEncoding,r.glyphs=new pe.GlyphSet(r),n.lowMemory)r._push=function(R){var O=ys(R,x.offsets,t,e+c.charStrings);r.glyphs.push(R,pe.cffGlyphLoader(r,R,Jr,O))};else for(var C=0;C<r.nGlyphs;C+=1){var M=x.objects[C];r.glyphs.push(C,pe.cffGlyphLoader(r,C,Jr,M))}}function $r(t,e){var r,n=ht.indexOf(t);return n>=0&&(r=n),n=e.indexOf(t),n>=0?r=n+ht.length:(r=ht.length+e.length,e.push(t)),r}function Os(){return new T.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 Es(t){var e=new T.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var r=0;r<t.length;r+=1)e.names.push({name:"name_"+r,type:"NAME",value:t[r]});return e}function en(t,e,r){for(var n={},a=0;a<t.length;a+=1){var s=t[a],i=e[s.name];i!==void 0&&!qr(i,s.value)&&(s.type==="SID"&&(i=$r(i,r)),n[s.op]={name:s.name,type:s.type,value:i})}return n}function tn(t,e){var r=new T.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=en(Zr,t,e),r}function rn(t){var e=new T.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:t}],e}function Us(t){var e=new T.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var r=0;r<t.length;r+=1)e.strings.push({name:"string_"+r,type:"STRING",value:t[r]});return e}function Ls(){return new T.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Rs(t,e){for(var r=new T.Record("Charsets",[{name:"format",type:"Card8",value:0}]),n=0;n<t.length;n+=1){var a=t[n],s=$r(a,e);r.fields.push({name:"glyph_"+n,type:"SID",value:s})}return r}function As(t){var e=[],r=t.path;e.push({name:"width",type:"NUMBER",value:t.advanceWidth});for(var n=0,a=0,s=0;s<r.commands.length;s+=1){var i=void 0,u=void 0,o=r.commands[s];if(o.type==="Q"){var l=.3333333333333333,c=2/3;o={type:"C",x:o.x,y:o.y,x1:Math.round(l*n+c*o.x1),y1:Math.round(l*a+c*o.y1),x2:Math.round(l*o.x+c*o.x1),y2:Math.round(l*o.y+c*o.y1)}}if(o.type==="M")i=Math.round(o.x-n),u=Math.round(o.y-a),e.push({name:"dx",type:"NUMBER",value:i}),e.push({name:"dy",type:"NUMBER",value:u}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(o.x),a=Math.round(o.y);else if(o.type==="L")i=Math.round(o.x-n),u=Math.round(o.y-a),e.push({name:"dx",type:"NUMBER",value:i}),e.push({name:"dy",type:"NUMBER",value:u}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(o.x),a=Math.round(o.y);else if(o.type==="C"){var p=Math.round(o.x1-n),h=Math.round(o.y1-a),f=Math.round(o.x2-o.x1),v=Math.round(o.y2-o.y1);i=Math.round(o.x-o.x2),u=Math.round(o.y-o.y2),e.push({name:"dx1",type:"NUMBER",value:p}),e.push({name:"dy1",type:"NUMBER",value:h}),e.push({name:"dx2",type:"NUMBER",value:f}),e.push({name:"dy2",type:"NUMBER",value:v}),e.push({name:"dx",type:"NUMBER",value:i}),e.push({name:"dy",type:"NUMBER",value:u}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(o.x),a=Math.round(o.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Ds(t){for(var e=new T.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),r=0;r<t.length;r+=1){var n=t.get(r),a=As(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:a})}return e}function Ms(t,e){var r=new T.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return r.dict=en(jr,t,e),r}function Bs(t,e){for(var r=new T.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"}]),n=1/e.unitsPerEm,a={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[n,0,0,n,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},s={},i=[],u,o=1;o<t.length;o+=1)u=t.get(o),i.push(u.name);var l=[];r.header=Os(),r.nameIndex=Es([e.postScriptName]);var c=tn(a,l);r.topDictIndex=rn(c),r.globalSubrIndex=Ls(),r.charsets=Rs(i,l),r.charStringsIndex=Ds(t),r.privateDict=Ms(s,l),r.stringIndex=Us(l);var p=r.header.sizeOf()+r.nameIndex.sizeOf()+r.topDictIndex.sizeOf()+r.stringIndex.sizeOf()+r.globalSubrIndex.sizeOf();return a.charset=p,a.encoding=0,a.charStrings=a.charset+r.charsets.sizeOf(),a.private[1]=a.charStrings+r.charStringsIndex.sizeOf(),c=tn(a,l),r.topDictIndex=rn(c),r}var nn={parse:Cs,make:Bs};function Ps(t,e){var r={},n=new w.Parser(t,e);return r.version=n.parseVersion(),r.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,r.checkSumAdjustment=n.parseULong(),r.magicNumber=n.parseULong(),E.argument(r.magicNumber===1594834165,"Font header has wrong magic number."),r.flags=n.parseUShort(),r.unitsPerEm=n.parseUShort(),r.created=n.parseLongDateTime(),r.modified=n.parseLongDateTime(),r.xMin=n.parseShort(),r.yMin=n.parseShort(),r.xMax=n.parseShort(),r.yMax=n.parseShort(),r.macStyle=n.parseUShort(),r.lowestRecPPEM=n.parseUShort(),r.fontDirectionHint=n.parseShort(),r.indexToLocFormat=n.parseShort(),r.glyphDataFormat=n.parseShort(),r}function Is(t){var e=Math.round(new Date().getTime()/1e3)+2082844800,r=e;return t.createdTimestamp&&(r=t.createdTimestamp+2082844800),new T.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:r},{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:0},{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 an={parse:Ps,make:Is};function Gs(t,e){var r={},n=new w.Parser(t,e);return r.version=n.parseVersion(),r.ascender=n.parseShort(),r.descender=n.parseShort(),r.lineGap=n.parseShort(),r.advanceWidthMax=n.parseUShort(),r.minLeftSideBearing=n.parseShort(),r.minRightSideBearing=n.parseShort(),r.xMaxExtent=n.parseShort(),r.caretSlopeRise=n.parseShort(),r.caretSlopeRun=n.parseShort(),r.caretOffset=n.parseShort(),n.relativeOffset+=8,r.metricDataFormat=n.parseShort(),r.numberOfHMetrics=n.parseUShort(),r}function Ns(t){return new T.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 sn={parse:Gs,make:Ns};function _s(t,e,r,n,a){for(var s,i,u=new w.Parser(t,e),o=0;o<n;o+=1){o<r&&(s=u.parseUShort(),i=u.parseShort());var l=a.get(o);l.advanceWidth=s,l.leftSideBearing=i}}function Hs(t,e,r,n,a){t._hmtxTableData={};for(var s,i,u=new w.Parser(e,r),o=0;o<a;o+=1)o<n&&(s=u.parseUShort(),i=u.parseShort()),t._hmtxTableData[o]={advanceWidth:s,leftSideBearing:i}}function zs(t,e,r,n,a,s,i){i.lowMemory?Hs(t,e,r,n,a):_s(e,r,n,a,s)}function Ws(t){for(var e=new T.Table("hmtx",[]),r=0;r<t.length;r+=1){var n=t.get(r),a=n.advanceWidth||0,s=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+r,type:"USHORT",value:a}),e.fields.push({name:"leftSideBearing_"+r,type:"SHORT",value:s})}return e}var on={parse:zs,make:Ws};function Vs(t){for(var e=new T.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:t.length}]),r="",n=12+t.length*4,a=0;a<t.length;++a){var s=r.indexOf(t[a]);s<0&&(s=r.length,r+=t[a]),e.fields.push({name:"offset "+a,type:"USHORT",value:n+s}),e.fields.push({name:"length "+a,type:"USHORT",value:t[a].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),e}function qs(t,e){var r=new w.Parser(t,e),n=r.parseULong();E.argument(n===1,"Unsupported ltag table version."),r.skip("uLong",1);for(var a=r.parseULong(),s=[],i=0;i<a;i++){for(var u="",o=e+r.parseUShort(),l=r.parseUShort(),c=o;c<o+l;++c)u+=String.fromCharCode(t.getInt8(c));s.push(u)}return s}var un={make:Vs,parse:qs};function Xs(t,e){var r={},n=new w.Parser(t,e);return r.version=n.parseVersion(),r.numGlyphs=n.parseUShort(),r.version===1&&(r.maxPoints=n.parseUShort(),r.maxContours=n.parseUShort(),r.maxCompositePoints=n.parseUShort(),r.maxCompositeContours=n.parseUShort(),r.maxZones=n.parseUShort(),r.maxTwilightPoints=n.parseUShort(),r.maxStorage=n.parseUShort(),r.maxFunctionDefs=n.parseUShort(),r.maxInstructionDefs=n.parseUShort(),r.maxStackElements=n.parseUShort(),r.maxSizeOfInstructions=n.parseUShort(),r.maxComponentElements=n.parseUShort(),r.maxComponentDepth=n.parseUShort()),r}function Ys(t){return new T.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:t}])}var ln={parse:Xs,make:Ys},cn=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],hn={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"},Zs={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},fn={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 js(t,e,r){switch(t){case 0:if(e===65535)return"und";if(r)return r[e];break;case 1:return hn[e];case 3:return fn[e]}}var Wt="utf-16",Ks={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"},Qs={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 pn(t,e,r){switch(t){case 0:return Wt;case 1:return Qs[r]||Ks[e];case 3:if(e===1||e===10)return Wt;break}}function Js(t,e,r){for(var n={},a=new w.Parser(t,e),s=a.parseUShort(),i=a.parseUShort(),u=a.offset+a.parseUShort(),o=0;o<i;o++){var l=a.parseUShort(),c=a.parseUShort(),p=a.parseUShort(),h=a.parseUShort(),f=cn[h]||h,v=a.parseUShort(),y=a.parseUShort(),m=js(l,p,r),b=pn(l,c,p);if(b!==void 0&&m!==void 0){var k=void 0;if(b===Wt?k=Pe.UTF16(t,u+y,v):k=Pe.MACSTRING(t,u+y,v,b),k){var x=n[f];x===void 0&&(x=n[f]={}),x[m]=k}}}return s===1&&a.parseUShort(),n}function Vt(t){var e={};for(var r in t)e[t[r]]=parseInt(r);return e}function dn(t,e,r,n,a,s){return new T.Record("NameRecord",[{name:"platformID",type:"USHORT",value:t},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:r},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:a},{name:"offset",type:"USHORT",value:s}])}function $s(t,e){var r=t.length,n=e.length-r+1;e:for(var a=0;a<n;a++)for(;a<n;a++){for(var s=0;s<r;s++)if(e[a+s]!==t[s])continue e;return a}return-1}function vn(t,e){var r=$s(t,e);if(r<0){r=e.length;for(var n=0,a=t.length;n<a;++n)e.push(t[n])}return r}function ei(t,e){var r,n=[],a={},s=Vt(cn);for(var i in t){var u=s[i];if(u===void 0&&(u=i),r=parseInt(u),isNaN(r))throw new Error('Name table entry "'+i+'" does not exist, see nameTableNames for complete list.');a[r]=t[i],n.push(r)}for(var o=Vt(hn),l=Vt(fn),c=[],p=[],h=0;h<n.length;h++){r=n[h];var f=a[r];for(var v in f){var y=f[v],m=1,b=o[v],k=Zs[b],x=pn(m,k,b),L=S.MACSTRING(y,x);L===void 0&&(m=0,b=e.indexOf(v),b<0&&(b=e.length,e.push(v)),k=4,L=S.UTF16(y));var C=vn(L,p);c.push(dn(m,k,b,r,L.length,C));var M=l[v];if(M!==void 0){var R=S.UTF16(y),O=vn(R,p);c.push(dn(3,1,M,r,R.length,O))}}}c.sort(function(Q,ae){return Q.platformID-ae.platformID||Q.encodingID-ae.encodingID||Q.languageID-ae.languageID||Q.nameID-ae.nameID});for(var H=new T.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+c.length*12}]),K=0;K<c.length;K++)H.fields.push({name:"record_"+K,type:"RECORD",value:c[K]});return H.fields.push({name:"strings",type:"LITERAL",value:p}),H}var gn={parse:Js,make:ei},qt=[{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 ti(t){for(var e=0;e<qt.length;e+=1){var r=qt[e];if(t>=r.begin&&t<r.end)return e}return-1}function ri(t,e){var r={},n=new w.Parser(t,e);r.version=n.parseUShort(),r.xAvgCharWidth=n.parseShort(),r.usWeightClass=n.parseUShort(),r.usWidthClass=n.parseUShort(),r.fsType=n.parseUShort(),r.ySubscriptXSize=n.parseShort(),r.ySubscriptYSize=n.parseShort(),r.ySubscriptXOffset=n.parseShort(),r.ySubscriptYOffset=n.parseShort(),r.ySuperscriptXSize=n.parseShort(),r.ySuperscriptYSize=n.parseShort(),r.ySuperscriptXOffset=n.parseShort(),r.ySuperscriptYOffset=n.parseShort(),r.yStrikeoutSize=n.parseShort(),r.yStrikeoutPosition=n.parseShort(),r.sFamilyClass=n.parseShort(),r.panose=[];for(var a=0;a<10;a++)r.panose[a]=n.parseByte();return r.ulUnicodeRange1=n.parseULong(),r.ulUnicodeRange2=n.parseULong(),r.ulUnicodeRange3=n.parseULong(),r.ulUnicodeRange4=n.parseULong(),r.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),r.fsSelection=n.parseUShort(),r.usFirstCharIndex=n.parseUShort(),r.usLastCharIndex=n.parseUShort(),r.sTypoAscender=n.parseShort(),r.sTypoDescender=n.parseShort(),r.sTypoLineGap=n.parseShort(),r.usWinAscent=n.parseUShort(),r.usWinDescent=n.parseUShort(),r.version>=1&&(r.ulCodePageRange1=n.parseULong(),r.ulCodePageRange2=n.parseULong()),r.version>=2&&(r.sxHeight=n.parseShort(),r.sCapHeight=n.parseShort(),r.usDefaultChar=n.parseUShort(),r.usBreakChar=n.parseUShort(),r.usMaxContent=n.parseUShort()),r}function ni(t){return new T.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 Xt={parse:ri,make:ni,unicodeRanges:qt,getUnicodeRange:ti};function ai(t,e){var r={},n=new w.Parser(t,e);switch(r.version=n.parseVersion(),r.italicAngle=n.parseFixed(),r.underlinePosition=n.parseShort(),r.underlineThickness=n.parseShort(),r.isFixedPitch=n.parseULong(),r.minMemType42=n.parseULong(),r.maxMemType42=n.parseULong(),r.minMemType1=n.parseULong(),r.maxMemType1=n.parseULong(),r.version){case 1:r.names=Ee.slice();break;case 2:r.numberOfGlyphs=n.parseUShort(),r.glyphNameIndex=new Array(r.numberOfGlyphs);for(var a=0;a<r.numberOfGlyphs;a++)r.glyphNameIndex[a]=n.parseUShort();r.names=[];for(var s=0;s<r.numberOfGlyphs;s++)if(r.glyphNameIndex[s]>=Ee.length){var i=n.parseChar();r.names.push(n.parseString(i))}break;case 2.5:r.numberOfGlyphs=n.parseUShort(),r.offset=new Array(r.numberOfGlyphs);for(var u=0;u<r.numberOfGlyphs;u++)r.offset[u]=n.parseChar();break}return r}function si(){return new T.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}var yn={parse:ai,make:si},oe=new Array(9);oe[1]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:1,coverage:this.parsePointer(d.coverage),deltaGlyphId:this.parseUShort()};if(r===2)return{substFormat:2,coverage:this.parsePointer(d.coverage),substitute:this.parseOffset16List()};E.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},oe[2]=function(){var e=this.parseUShort();return E.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(d.coverage),sequences:this.parseListOfLists()}},oe[3]=function(){var e=this.parseUShort();return E.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(d.coverage),alternateSets:this.parseListOfLists()}},oe[4]=function(){var e=this.parseUShort();return E.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(d.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Ie={sequenceIndex:d.uShort,lookupListIndex:d.uShort};oe[5]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:r,coverage:this.parsePointer(d.coverage),ruleSets:this.parseListOfLists(function(){var s=this.parseUShort(),i=this.parseUShort();return{input:this.parseUShortList(s-1),lookupRecords:this.parseRecordList(i,Ie)}})};if(r===2)return{substFormat:r,coverage:this.parsePointer(d.coverage),classDef:this.parsePointer(d.classDef),classSets:this.parseListOfLists(function(){var s=this.parseUShort(),i=this.parseUShort();return{classes:this.parseUShortList(s-1),lookupRecords:this.parseRecordList(i,Ie)}})};if(r===3){var n=this.parseUShort(),a=this.parseUShort();return{substFormat:r,coverages:this.parseList(n,d.pointer(d.coverage)),lookupRecords:this.parseRecordList(a,Ie)}}E.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},oe[6]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{substFormat:1,coverage:this.parsePointer(d.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ie)}})};if(r===2)return{substFormat:2,coverage:this.parsePointer(d.coverage),backtrackClassDef:this.parsePointer(d.classDef),inputClassDef:this.parsePointer(d.classDef),lookaheadClassDef:this.parsePointer(d.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ie)}})};if(r===3)return{substFormat:3,backtrackCoverage:this.parseList(d.pointer(d.coverage)),inputCoverage:this.parseList(d.pointer(d.coverage)),lookaheadCoverage:this.parseList(d.pointer(d.coverage)),lookupRecords:this.parseRecordList(Ie)};E.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},oe[7]=function(){var e=this.parseUShort();E.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var r=this.parseUShort(),n=new d(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:r,extension:oe[r].call(n)}},oe[8]=function(){var e=this.parseUShort();return E.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(d.coverage),backtrackCoverage:this.parseList(d.pointer(d.coverage)),lookaheadCoverage:this.parseList(d.pointer(d.coverage)),substitutes:this.parseUShortList()}};function ii(t,e){e=e||0;var r=new d(t,e),n=r.parseVersion(1);return E.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(oe)}:{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(oe),variations:r.parseFeatureVariationsList()}}var Ge=new Array(9);Ge[1]=function(e){return e.substFormat===1?new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.ushortList("substitute",e.substitute)))},Ge[2]=function(e){return E.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("seqSet",e.sequences,function(r){return new T.Table("sequenceSetTable",T.ushortList("sequence",r))})))},Ge[3]=function(e){return E.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("altSet",e.alternateSets,function(r){return new T.Table("alternateSetTable",T.ushortList("alternate",r))})))},Ge[4]=function(e){return E.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new T.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("ligSet",e.ligatureSets,function(r){return new T.Table("ligatureSetTable",T.tableList("ligature",r,function(n){return new T.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:n.ligGlyph}].concat(T.ushortList("component",n.components,n.components.length+1)))}))})))},Ge[6]=function(e){if(e.substFormat===1){var r=new T.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new T.Coverage(e.coverage)}].concat(T.tableList("chainRuleSet",e.chainRuleSets,function(s){return new T.Table("chainRuleSetTable",T.tableList("chainRule",s,function(i){var u=T.ushortList("backtrackGlyph",i.backtrack,i.backtrack.length).concat(T.ushortList("inputGlyph",i.input,i.input.length+1)).concat(T.ushortList("lookaheadGlyph",i.lookahead,i.lookahead.length)).concat(T.ushortList("substitution",[],i.lookupRecords.length));return i.lookupRecords.forEach(function(o,l){u=u.concat({name:"sequenceIndex"+l,type:"USHORT",value:o.sequenceIndex}).concat({name:"lookupListIndex"+l,type:"USHORT",value:o.lookupListIndex})}),new T.Table("chainRuleTable",u)}))})));return r}else if(e.substFormat===2)E.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(s,i){n.push({name:"backtrackCoverage"+i,type:"TABLE",value:new T.Coverage(s)})}),n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(s,i){n.push({name:"inputCoverage"+i,type:"TABLE",value:new T.Coverage(s)})}),n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(s,i){n.push({name:"lookaheadCoverage"+i,type:"TABLE",value:new T.Coverage(s)})}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(s,i){n=n.concat({name:"sequenceIndex"+i,type:"USHORT",value:s.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:s.lookupListIndex})});var a=new T.Table("chainContextTable",n);return a}E.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function oi(t){return new T.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new T.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new T.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new T.LookupList(t.lookups,Ge)}])}var mn={parse:ii,make:oi};function ui(t,e){var r=new w.Parser(t,e),n=r.parseULong();E.argument(n===1,"Unsupported META table version."),r.parseULong(),r.parseULong();for(var a=r.parseULong(),s={},i=0;i<a;i++){var u=r.parseTag(),o=r.parseULong(),l=r.parseULong(),c=Pe.UTF8(t,e+o,l);s[u]=c}return s}function li(t){var e=Object.keys(t).length,r="",n=16+e*12,a=new T.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:n},{name:"numTags",type:"ULONG",value:e}]);for(var s in t){var i=r.length;r+=t[s],a.fields.push({name:"tag "+s,type:"TAG",value:s}),a.fields.push({name:"offset "+s,type:"ULONG",value:n+i}),a.fields.push({name:"length "+s,type:"ULONG",value:t[s].length})}return a.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),a}var bn={parse:ui,make:li};function xn(t){return Math.log(t)/Math.log(2)|0}function Yt(t){for(;t.length%4!==0;)t.push(0);for(var e=0,r=0;r<t.length;r+=4)e+=(t[r]<<24)+(t[r+1]<<16)+(t[r+2]<<8)+t[r+3];return e%=Math.pow(2,32),e}function Sn(t,e,r,n){return new T.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:r!==void 0?r:0},{name:"length",type:"ULONG",value:n!==void 0?n:0}])}function kn(t){var e=new T.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;var r=Math.pow(2,xn(e.numTables));e.searchRange=16*r,e.entrySelector=xn(r),e.rangeShift=e.numTables*16-e.searchRange;for(var n=[],a=[],s=e.sizeOf()+Sn().sizeOf()*e.numTables;s%4!==0;)s+=1,a.push({name:"padding",type:"BYTE",value:0});for(var i=0;i<t.length;i+=1){var u=t[i];E.argument(u.tableName.length===4,"Table name"+u.tableName+" is invalid.");var o=u.sizeOf(),l=Sn(u.tableName,Yt(u.encode()),s,o);for(n.push({name:l.tag+" Table Record",type:"RECORD",value:l}),a.push({name:u.tableName+" table",type:"RECORD",value:u}),s+=o,E.argument(!isNaN(s),"Something went wrong calculating the offset.");s%4!==0;)s+=1,a.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(c,p){return c.value.tag>p.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(a),e}function Tn(t,e,r){for(var n=0;n<e.length;n+=1){var a=t.charToGlyphIndex(e[n]);if(a>0){var s=t.glyphs.get(a);return s.getMetrics()}}return r}function ci(t){for(var e=0,r=0;r<t.length;r+=1)e+=t[r];return e/t.length}function hi(t){for(var e=[],r=[],n=[],a=[],s=[],i=[],u=[],o,l=0,c=0,p=0,h=0,f=0,v=0;v<t.glyphs.length;v+=1){var y=t.glyphs.get(v),m=y.unicode|0;if(isNaN(y.advanceWidth))throw new Error("Glyph "+y.name+" ("+v+"): advanceWidth is not a number.");(o>m||o===void 0)&&m>0&&(o=m),l<m&&(l=m);var b=Xt.getUnicodeRange(m);if(b<32)c|=1<<b;else if(b<64)p|=1<<b-32;else if(b<96)h|=1<<b-64;else if(b<123)f|=1<<b-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(y.name!==".notdef"){var k=y.getMetrics();e.push(k.xMin),r.push(k.yMin),n.push(k.xMax),a.push(k.yMax),i.push(k.leftSideBearing),u.push(k.rightSideBearing),s.push(y.advanceWidth)}}var x={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,r),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,a),advanceWidthMax:Math.max.apply(null,s),advanceWidthAvg:ci(s),minLeftSideBearing:Math.min.apply(null,i),maxLeftSideBearing:Math.max.apply(null,i),minRightSideBearing:Math.min.apply(null,u)};x.ascender=t.ascender,x.descender=t.descender;var L=an.make({flags:3,unitsPerEm:t.unitsPerEm,xMin:x.xMin,yMin:x.yMin,xMax:x.xMax,yMax:x.yMax,lowestRecPPEM:3,createdTimestamp:t.createdTimestamp}),C=sn.make({ascender:x.ascender,descender:x.descender,advanceWidthMax:x.advanceWidthMax,minLeftSideBearing:x.minLeftSideBearing,minRightSideBearing:x.minRightSideBearing,xMaxExtent:x.maxLeftSideBearing+(x.xMax-x.xMin),numberOfHMetrics:t.glyphs.length}),M=ln.make(t.glyphs.length),R=Xt.make(Object.assign({xAvgCharWidth:Math.round(x.advanceWidthAvg),usFirstCharIndex:o,usLastCharIndex:l,ulUnicodeRange1:c,ulUnicodeRange2:p,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:x.ascender,sTypoDescender:x.descender,sTypoLineGap:0,usWinAscent:x.yMax,usWinDescent:Math.abs(x.yMin),ulCodePageRange1:1,sxHeight:Tn(t,"xyvw",{yMax:Math.round(x.ascender/2)}).yMax,sCapHeight:Tn(t,"HIKLEFJMNTZBDPRAGOQSUVWXY",x).yMax,usDefaultChar:t.hasChar(" ")?32:0,usBreakChar:t.hasChar(" ")?32:0},t.tables.os2)),O=on.make(t.glyphs),H=zr.make(t.glyphs),K=t.getEnglishName("fontFamily"),Q=t.getEnglishName("fontSubfamily"),ae=K+" "+Q,se=t.getEnglishName("postScriptName");se||(se=K.replace(/\s/g,"")+"-"+Q);var N={};for(var W in t.names)N[W]=t.names[W];N.uniqueID||(N.uniqueID={en:t.getEnglishName("manufacturer")+":"+ae}),N.postScriptName||(N.postScriptName={en:se}),N.preferredFamily||(N.preferredFamily=t.names.fontFamily),N.preferredSubfamily||(N.preferredSubfamily=t.names.fontSubfamily);var q=[],X=gn.make(N,q),Y=q.length>0?un.make(q):void 0,V=yn.make(),j=nn.make(t.glyphs,{version:t.getEnglishName("version"),fullName:ae,familyName:K,weightName:Q,postScriptName:se,unitsPerEm:t.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),B=t.metas&&Object.keys(t.metas).length>0?bn.make(t.metas):void 0,Z=[L,C,M,R,X,H,V,j,O];Y&&Z.push(Y),t.tables.gsub&&Z.push(mn.make(t.tables.gsub)),B&&Z.push(B);for(var dr=kn(Z),yl=dr.encode(),ml=Yt(yl),vr=dr.fields,da=!1,bt=0;bt<vr.length;bt+=1)if(vr[bt].name==="head table"){vr[bt].value.checkSumAdjustment=2981146554-ml,da=!0;break}if(!da)throw new Error("Could not find head table with checkSum to adjust.");return dr}var fi={make:kn,fontToTable:hi,computeCheckSum:Yt};function Zt(t,e){for(var r=0,n=t.length-1;r<=n;){var a=r+n>>>1,s=t[a].tag;if(s===e)return a;s<e?r=a+1:n=a-1}return-r-1}function Fn(t,e){for(var r=0,n=t.length-1;r<=n;){var a=r+n>>>1,s=t[a];if(s===e)return a;s<e?r=a+1:n=a-1}return-r-1}function wn(t,e){for(var r,n=0,a=t.length-1;n<=a;){var s=n+a>>>1;r=t[s];var i=r.start;if(i===e)return r;i<e?n=s+1:a=s-1}if(n>0)return r=t[n-1],e>r.end?0:r}function Ye(t,e){this.font=t,this.tableName=e}Ye.prototype={searchTag:Zt,binSearch:Fn,getTable:function(t){var e=this.font.tables[this.tableName];return!e&&t&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var t=this.getTable();return t?t.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var t=this.getTable();if(t){for(var e=!1,r=0;r<t.scripts.length;r++){var n=t.scripts[r].tag;if(n==="DFLT")return n;n==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(t,e){var r=this.getTable(e);if(r){t=t||"DFLT";var n=r.scripts,a=Zt(r.scripts,t);if(a>=0)return n[a].script;if(e){var s={tag:t,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-a,0,s),s.script}}},getLangSysTable:function(t,e,r){var n=this.getScriptTable(t,r);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;var a=Zt(n.langSysRecords,e);if(a>=0)return n.langSysRecords[a].langSys;if(r){var s={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-a,0,s),s.langSys}}},getFeatureTable:function(t,e,r,n){var a=this.getLangSysTable(t,e,n);if(a){for(var s,i=a.featureIndexes,u=this.font.tables[this.tableName].features,o=0;o<i.length;o++)if(s=u[i[o]],s.tag===r)return s.feature;if(n){var l=u.length;return E.assert(l===0||r>=u[l-1].tag,"Features must be added in alphabetical order."),s={tag:r,feature:{params:0,lookupListIndexes:[]}},u.push(s),i.push(l),s.feature}}},getLookupTables:function(t,e,r,n,a){var s=this.getFeatureTable(t,e,r,a),i=[];if(s){for(var u,o=s.lookupListIndexes,l=this.font.tables[this.tableName].lookups,c=0;c<o.length;c++)u=l[o[c]],u.lookupType===n&&i.push(u);if(i.length===0&&a){u={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};var p=l.length;return l.push(u),o.push(p),[u]}}return i},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:var r=wn(t.ranges,e);return r?r.classId:0}},getCoverageIndex:function(t,e){switch(t.format){case 1:var r=Fn(t.glyphs,e);return r>=0?r:-1;case 2:var n=wn(t.ranges,e);return n?n.index+e-n.start:-1}},expandCoverage:function(t){if(t.format===1)return t.glyphs;for(var e=[],r=t.ranges,n=0;n<r.length;n++)for(var a=r[n],s=a.start,i=a.end,u=s;u<=i;u++)e.push(u);return e}};function Ze(t){Ye.call(this,t,"gpos")}Ze.prototype=Ye.prototype,Ze.prototype.init=function(){var t=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(t)},Ze.prototype.getKerningValue=function(t,e,r){for(var n=0;n<t.length;n++)for(var a=t[n].subtables,s=0;s<a.length;s++){var i=a[s],u=this.getCoverageIndex(i.coverage,e);if(!(u<0))switch(i.posFormat){case 1:for(var o=i.pairSets[u],l=0;l<o.length;l++){var c=o[l];if(c.secondGlyph===r)return c.value1&&c.value1.xAdvance||0}break;case 2:var p=this.getGlyphClass(i.classDef1,e),h=this.getGlyphClass(i.classDef2,r),f=i.classRecords[p][h];return f.value1&&f.value1.xAdvance||0}}return 0},Ze.prototype.getKerningTables=function(t,e){if(this.font.tables.gpos)return this.getLookupTables(t,e,"kern",2)};function J(t){Ye.call(this,t,"gsub")}function pi(t,e){var r=t.length;if(r!==e.length)return!1;for(var n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}function jt(t,e,r){for(var n=t.subtables,a=0;a<n.length;a++){var s=n[a];if(s.substFormat===e)return s}if(r)return n.push(r),r}J.prototype=Ye.prototype,J.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},J.prototype.getSingle=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,1),s=0;s<a.length;s++)for(var i=a[s].subtables,u=0;u<i.length;u++){var o=i[u],l=this.expandCoverage(o.coverage),c=void 0;if(o.substFormat===1){var p=o.deltaGlyphId;for(c=0;c<l.length;c++){var h=l[c];n.push({sub:h,by:h+p})}}else{var f=o.substitute;for(c=0;c<l.length;c++)n.push({sub:l[c],by:f[c]})}}return n},J.prototype.getMultiple=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,2),s=0;s<a.length;s++)for(var i=a[s].subtables,u=0;u<i.length;u++){var o=i[u],l=this.expandCoverage(o.coverage),c=void 0;for(c=0;c<l.length;c++){var p=l[c],h=o.sequences[c];n.push({sub:p,by:h})}}return n},J.prototype.getAlternates=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,3),s=0;s<a.length;s++)for(var i=a[s].subtables,u=0;u<i.length;u++)for(var o=i[u],l=this.expandCoverage(o.coverage),c=o.alternateSets,p=0;p<l.length;p++)n.push({sub:l[p],by:c[p]});return n},J.prototype.getLigatures=function(t,e,r){for(var n=[],a=this.getLookupTables(e,r,t,4),s=0;s<a.length;s++)for(var i=a[s].subtables,u=0;u<i.length;u++)for(var o=i[u],l=this.expandCoverage(o.coverage),c=o.ligatureSets,p=0;p<l.length;p++)for(var h=l[p],f=c[p],v=0;v<f.length;v++){var y=f[v];n.push({sub:[h].concat(y.components),by:y.ligGlyph})}return n},J.prototype.addSingle=function(t,e,r,n){var a=this.getLookupTables(r,n,t,1,!0)[0],s=jt(a,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});E.assert(s.coverage.format===1,"Single: unable to modify coverage table format "+s.coverage.format);var i=e.sub,u=this.binSearch(s.coverage.glyphs,i);u<0&&(u=-1-u,s.coverage.glyphs.splice(u,0,i),s.substitute.splice(u,0,0)),s.substitute[u]=e.by},J.prototype.addMultiple=function(t,e,r,n){E.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var a=this.getLookupTables(r,n,t,2,!0)[0],s=jt(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});E.assert(s.coverage.format===1,"Multiple: unable to modify coverage table format "+s.coverage.format);var i=e.sub,u=this.binSearch(s.coverage.glyphs,i);u<0&&(u=-1-u,s.coverage.glyphs.splice(u,0,i),s.sequences.splice(u,0,0)),s.sequences[u]=e.by},J.prototype.addAlternate=function(t,e,r,n){var a=this.getLookupTables(r,n,t,3,!0)[0],s=jt(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});E.assert(s.coverage.format===1,"Alternate: unable to modify coverage table format "+s.coverage.format);var i=e.sub,u=this.binSearch(s.coverage.glyphs,i);u<0&&(u=-1-u,s.coverage.glyphs.splice(u,0,i),s.alternateSets.splice(u,0,0)),s.alternateSets[u]=e.by},J.prototype.addLigature=function(t,e,r,n){var a=this.getLookupTables(r,n,t,4,!0)[0],s=a.subtables[0];s||(s={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},a.subtables[0]=s),E.assert(s.coverage.format===1,"Ligature: unable to modify coverage table format "+s.coverage.format);var i=e.sub[0],u=e.sub.slice(1),o={ligGlyph:e.by,components:u},l=this.binSearch(s.coverage.glyphs,i);if(l>=0){for(var c=s.ligatureSets[l],p=0;p<c.length;p++)if(pi(c[p].components,u))return;c.push(o)}else l=-1-l,s.coverage.glyphs.splice(l,0,i),s.ligatureSets.splice(l,0,[o])},J.prototype.getFeature=function(t,e,r){if(/ss\d\d/.test(t))return this.getSingle(t,e,r);switch(t){case"aalt":case"salt":return this.getSingle(t,e,r).concat(this.getAlternates(t,e,r));case"dlig":case"liga":case"rlig":return this.getLigatures(t,e,r);case"ccmp":return this.getMultiple(t,e,r).concat(this.getLigatures(t,e,r));case"stch":return this.getMultiple(t,e,r)}},J.prototype.add=function(t,e,r,n){if(/ss\d\d/.test(t))return this.addSingle(t,e,r,n);switch(t){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(t,e,r,n):this.addAlternate(t,e,r,n);case"dlig":case"liga":case"rlig":return this.addLigature(t,e,r,n);case"ccmp":return e.by instanceof Array?this.addMultiple(t,e,r,n):this.addLigature(t,e,r,n)}};function di(){return typeof window<"u"}function vi(t){for(var e=new Buffer(t.byteLength),r=new Uint8Array(t),n=0;n<e.length;++n)e[n]=r[n];return e}function je(t,e){if(!t)throw e}function Cn(t,e,r,n,a){var s;return(e&n)>0?(s=t.parseByte(),e&a||(s=-s),s=r+s):(e&a)>0?s=r:s=r+t.parseShort(),s}function On(t,e,r){var n=new w.Parser(e,r);t.numberOfContours=n.parseShort(),t._xMin=n.parseShort(),t._yMin=n.parseShort(),t._xMax=n.parseShort(),t._yMax=n.parseShort();var a,s;if(t.numberOfContours>0){for(var i=t.endPointIndices=[],u=0;u<t.numberOfContours;u+=1)i.push(n.parseUShort());t.instructionLength=n.parseUShort(),t.instructions=[];for(var o=0;o<t.instructionLength;o+=1)t.instructions.push(n.parseByte());var l=i[i.length-1]+1;a=[];for(var c=0;c<l;c+=1)if(s=n.parseByte(),a.push(s),(s&8)>0)for(var p=n.parseByte(),h=0;h<p;h+=1)a.push(s),c+=1;if(E.argument(a.length===l,"Bad flags."),i.length>0){var f=[],v;if(l>0){for(var y=0;y<l;y+=1)s=a[y],v={},v.onCurve=!!(s&1),v.lastPointOfContour=i.indexOf(y)>=0,f.push(v);for(var m=0,b=0;b<l;b+=1)s=a[b],v=f[b],v.x=Cn(n,s,m,2,16),m=v.x;for(var k=0,x=0;x<l;x+=1)s=a[x],v=f[x],v.y=Cn(n,s,k,4,32),k=v.y}t.points=f}else t.points=[]}else if(t.numberOfContours===0)t.points=[];else{t.isComposite=!0,t.points=[],t.components=[];for(var L=!0;L;){a=n.parseUShort();var C={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(C.dx=n.parseShort(),C.dy=n.parseShort()):C.matchedPoints=[n.parseUShort(),n.parseUShort()]:(a&2)>0?(C.dx=n.parseChar(),C.dy=n.parseChar()):C.matchedPoints=[n.parseByte(),n.parseByte()],(a&8)>0?C.xScale=C.yScale=n.parseF2Dot14():(a&64)>0?(C.xScale=n.parseF2Dot14(),C.yScale=n.parseF2Dot14()):(a&128)>0&&(C.xScale=n.parseF2Dot14(),C.scale01=n.parseF2Dot14(),C.scale10=n.parseF2Dot14(),C.yScale=n.parseF2Dot14()),t.components.push(C),L=!!(a&32)}if(a&256){t.instructionLength=n.parseUShort(),t.instructions=[];for(var M=0;M<t.instructionLength;M+=1)t.instructions.push(n.parseByte())}}}function Kt(t,e){for(var r=[],n=0;n<t.length;n+=1){var a=t[n],s={x:e.xScale*a.x+e.scale01*a.y+e.dx,y:e.scale10*a.x+e.yScale*a.y+e.dy,onCurve:a.onCurve,lastPointOfContour:a.lastPointOfContour};r.push(s)}return r}function gi(t){for(var e=[],r=[],n=0;n<t.length;n+=1){var a=t[n];r.push(a),a.lastPointOfContour&&(e.push(r),r=[])}return E.argument(r.length===0,"There are still points left in the current contour."),e}function En(t){var e=new _;if(!t)return e;for(var r=gi(t),n=0;n<r.length;++n){var a=r[n],s=null,i=a[a.length-1],u=a[0];if(i.onCurve)e.moveTo(i.x,i.y);else if(u.onCurve)e.moveTo(u.x,u.y);else{var o={x:(i.x+u.x)*.5,y:(i.y+u.y)*.5};e.moveTo(o.x,o.y)}for(var l=0;l<a.length;++l)if(s=i,i=u,u=a[(l+1)%a.length],i.onCurve)e.lineTo(i.x,i.y);else{var c=u;s.onCurve||((i.x+s.x)*.5,(i.y+s.y)*.5),u.onCurve||(c={x:(i.x+u.x)*.5,y:(i.y+u.y)*.5}),e.quadraticCurveTo(i.x,i.y,c.x,c.y)}e.closePath()}return e}function Un(t,e){if(e.isComposite)for(var r=0;r<e.components.length;r+=1){var n=e.components[r],a=t.get(n.glyphIndex);if(a.getPath(),a.points){var s=void 0;if(n.matchedPoints===void 0)s=Kt(a.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>a.points.length-1)throw Error("Matched points out of range in "+e.name);var i=e.points[n.matchedPoints[0]],u=a.points[n.matchedPoints[1]],o={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};u=Kt([u],o)[0],o.dx=i.x-u.x,o.dy=i.y-u.y,s=Kt(a.points,o)}e.points=e.points.concat(s)}}return En(e.points)}function yi(t,e,r,n){for(var a=new pe.GlyphSet(n),s=0;s<r.length-1;s+=1){var i=r[s],u=r[s+1];i!==u?a.push(s,pe.ttfGlyphLoader(n,s,On,t,e+i,Un)):a.push(s,pe.glyphLoader(n,s))}return a}function mi(t,e,r,n){var a=new pe.GlyphSet(n);return n._push=function(s){var i=r[s],u=r[s+1];i!==u?a.push(s,pe.ttfGlyphLoader(n,s,On,t,e+i,Un)):a.push(s,pe.glyphLoader(n,s))},a}function bi(t,e,r,n,a){return a.lowMemory?mi(t,e,r,n):yi(t,e,r,n)}var Ln={getPath:En,parse:bi},Rn,Le,An,Qt;function Dn(t){this.font=t,this.getCommands=function(e){return Ln.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function xi(t){return t}function Mn(t){return Math.sign(t)*Math.round(Math.abs(t))}function Si(t){return Math.sign(t)*Math.round(Math.abs(t*2))/2}function ki(t){return Math.sign(t)*(Math.round(Math.abs(t)+.5)-.5)}function Ti(t){return Math.sign(t)*Math.ceil(Math.abs(t))}function Fi(t){return Math.sign(t)*Math.floor(Math.abs(t))}var Bn=function(t){var e=this.srPeriod,r=this.srPhase,n=this.srThreshold,a=1;return t<0&&(t=-t,a=-1),t+=n-r,t=Math.trunc(t/e)*e,t+=r,t<0?r*a:t*a},de={x:1,y:0,axis:"x",distance:function(t,e,r,n){return(r?t.xo:t.x)-(n?e.xo:e.x)},interpolate:function(t,e,r,n){var a,s,i,u,o,l,c;if(!n||n===this){if(a=t.xo-e.xo,s=t.xo-r.xo,o=e.x-e.xo,l=r.x-r.xo,i=Math.abs(a),u=Math.abs(s),c=i+u,c===0){t.x=t.xo+(o+l)/2;return}t.x=t.xo+(o*u+l*i)/c;return}if(a=n.distance(t,e,!0,!0),s=n.distance(t,r,!0,!0),o=n.distance(e,e,!1,!0),l=n.distance(r,r,!1,!0),i=Math.abs(a),u=Math.abs(s),c=i+u,c===0){de.setRelative(t,t,(o+l)/2,n,!0);return}de.setRelative(t,t,(o*u+l*i)/c,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(t,e,r,n,a){if(!n||n===this){t.x=(a?e.xo:e.x)+r;return}var s=a?e.xo:e.x,i=a?e.yo:e.y,u=s+r*n.x,o=i+r*n.y;t.x=u+(t.y-o)/n.normalSlope},slope:0,touch:function(t){t.xTouched=!0},touched:function(t){return t.xTouched},untouch:function(t){t.xTouched=!1}},ye={x:0,y:1,axis:"y",distance:function(t,e,r,n){return(r?t.yo:t.y)-(n?e.yo:e.y)},interpolate:function(t,e,r,n){var a,s,i,u,o,l,c;if(!n||n===this){if(a=t.yo-e.yo,s=t.yo-r.yo,o=e.y-e.yo,l=r.y-r.yo,i=Math.abs(a),u=Math.abs(s),c=i+u,c===0){t.y=t.yo+(o+l)/2;return}t.y=t.yo+(o*u+l*i)/c;return}if(a=n.distance(t,e,!0,!0),s=n.distance(t,r,!0,!0),o=n.distance(e,e,!1,!0),l=n.distance(r,r,!1,!0),i=Math.abs(a),u=Math.abs(s),c=i+u,c===0){ye.setRelative(t,t,(o+l)/2,n,!0);return}ye.setRelative(t,t,(o*u+l*i)/c,n,!0)},normalSlope:0,setRelative:function(t,e,r,n,a){if(!n||n===this){t.y=(a?e.yo:e.y)+r;return}var s=a?e.xo:e.x,i=a?e.yo:e.y,u=s+r*n.x,o=i+r*n.y;t.y=o+n.normalSlope*(t.x-u)},slope:Number.POSITIVE_INFINITY,touch:function(t){t.yTouched=!0},touched:function(t){return t.yTouched},untouch:function(t){t.yTouched=!1}};Object.freeze(de),Object.freeze(ye);function Ke(t,e){this.x=t,this.y=e,this.axis=void 0,this.slope=e/t,this.normalSlope=-t/e,Object.freeze(this)}Ke.prototype.distance=function(t,e,r,n){return this.x*de.distance(t,e,r,n)+this.y*ye.distance(t,e,r,n)},Ke.prototype.interpolate=function(t,e,r,n){var a,s,i,u,o,l,c;if(i=n.distance(t,e,!0,!0),u=n.distance(t,r,!0,!0),a=n.distance(e,e,!1,!0),s=n.distance(r,r,!1,!0),o=Math.abs(i),l=Math.abs(u),c=o+l,c===0){this.setRelative(t,t,(a+s)/2,n,!0);return}this.setRelative(t,t,(a*l+s*o)/c,n,!0)},Ke.prototype.setRelative=function(t,e,r,n,a){n=n||this;var s=a?e.xo:e.x,i=a?e.yo:e.y,u=s+r*n.x,o=i+r*n.y,l=n.normalSlope,c=this.slope,p=t.x,h=t.y;t.x=(c*p-l*u+o-h)/(c-l),t.y=c*(t.x-p)+h},Ke.prototype.touch=function(t){t.xTouched=!0,t.yTouched=!0};function Qe(t,e){var r=Math.sqrt(t*t+e*e);return t/=r,e/=r,t===1&&e===0?de:t===0&&e===1?ye:new Ke(t,e)}function me(t,e,r,n){this.x=this.xo=Math.round(t*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=r,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}me.prototype.nextTouched=function(t){for(var e=this.nextPointOnContour;!t.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},me.prototype.prevTouched=function(t){for(var e=this.prevPointOnContour;!t.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Je=Object.freeze(new me(0,0)),wi={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ke(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=de,this.round=Mn}}Dn.prototype.exec=function(t,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var r=this.font,n=this._prepState;if(!n||n.ppem!==e){var a=this._fpgmState;if(!a){ke.prototype=wi,a=this._fpgmState=new ke("fpgm",r.tables.fpgm),a.funcs=[],a.font=r,g.DEBUG&&(console.log("---EXEC FPGM---"),a.step=-1);try{Le(a)}catch(l){console.log("Hinting error in FPGM:"+l),this._errorState=3;return}}ke.prototype=a,n=this._prepState=new ke("prep",r.tables.prep),n.ppem=e;var s=r.tables.cvt;if(s)for(var i=n.cvt=new Array(s.length),u=e/r.unitsPerEm,o=0;o<s.length;o++)i[o]=s[o]*u;else n.cvt=[];g.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{Le(n)}catch(l){this._errorState<2&&console.log("Hinting error in PREP:"+l),this._errorState=2}}if(!(this._errorState>1))try{return An(t,n)}catch(l){this._errorState<1&&(console.log("Hinting error:"+l),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}},An=function(t,e){var r=e.ppem/e.font.unitsPerEm,n=r,a=t.components,s,i,u;if(ke.prototype=e,!a)u=new ke("glyf",t.instructions),g.DEBUG&&(console.log("---EXEC GLYPH---"),u.step=-1),Qt(t,u,r,n),i=u.gZone;else{var o=e.font;i=[],s=[];for(var l=0;l<a.length;l++){var c=a[l],p=o.glyphs.get(c.glyphIndex);u=new ke("glyf",p.instructions),g.DEBUG&&(console.log("---EXEC COMP "+l+"---"),u.step=-1),Qt(p,u,r,n);for(var h=Math.round(c.dx*r),f=Math.round(c.dy*n),v=u.gZone,y=u.contours,m=0;m<v.length;m++){var b=v[m];b.xTouched=b.yTouched=!1,b.xo=b.x=b.x+h,b.yo=b.y=b.y+f}var k=i.length;i.push.apply(i,v);for(var x=0;x<y.length;x++)s.push(y[x]+k)}t.instructions&&!u.inhibitGridFit&&(u=new ke("glyf",t.instructions),u.gZone=u.z0=u.z1=u.z2=i,u.contours=s,i.push(new me(0,0),new me(Math.round(t.advanceWidth*r),0)),g.DEBUG&&(console.log("---EXEC COMPOSITE---"),u.step=-1),Le(u),i.length-=2)}return i},Qt=function(t,e,r,n){for(var a=t.points||[],s=a.length,i=e.gZone=e.z0=e.z1=e.z2=[],u=e.contours=[],o,l=0;l<s;l++)o=a[l],i[l]=new me(o.x*r,o.y*n,o.lastPointOfContour,o.onCurve);for(var c,p,h=0;h<s;h++)o=i[h],c||(c=o,u.push(h)),o.lastPointOfContour?(o.nextPointOnContour=c,c.prevPointOnContour=o,c=void 0):(p=i[h+1],o.nextPointOnContour=p,p.prevPointOnContour=o);if(!e.inhibitGridFit){if(g.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var f=0;f<s;f++)console.log(f,i[f].x,i[f].y)}if(i.push(new me(0,0),new me(Math.round(t.advanceWidth*r),0)),Le(e),i.length-=2,g.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var v=0;v<s;v++)console.log(v,i[v].x,i[v].y)}}},Le=function(t){var e=t.prog;if(e){var r=e.length,n;for(t.ip=0;t.ip<r;t.ip++){if(g.DEBUG&&t.step++,n=Rn[e[t.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[t.ip]).toString(16));n(t)}}};function dt(t){for(var e=t.tZone=new Array(t.gZone.length),r=0;r<e.length;r++)e[r]=new me(0,0)}function Pn(t,e){var r=t.prog,n=t.ip,a=1,s;do if(s=r[++n],s===88)a++;else if(s===89)a--;else if(s===64)n+=r[n+1]+1;else if(s===65)n+=2*r[n+1]+1;else if(s>=176&&s<=183)n+=s-176+1;else if(s>=184&&s<=191)n+=(s-184+1)*2;else if(e&&a===1&&s===27)break;while(a>0);t.ip=n}function In(t,e){g.DEBUG&&console.log(e.step,"SVTCA["+t.axis+"]"),e.fv=e.pv=e.dpv=t}function Gn(t,e){g.DEBUG&&console.log(e.step,"SPVTCA["+t.axis+"]"),e.pv=e.dpv=t}function Nn(t,e){g.DEBUG&&console.log(e.step,"SFVTCA["+t.axis+"]"),e.fv=t}function _n(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z2[n],i=e.z1[a];g.DEBUG&&console.log("SPVTL["+t+"]",n,a);var u,o;t?(u=s.y-i.y,o=i.x-s.x):(u=i.x-s.x,o=i.y-s.y),e.pv=e.dpv=Qe(u,o)}function Hn(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z2[n],i=e.z1[a];g.DEBUG&&console.log("SFVTL["+t+"]",n,a);var u,o;t?(u=s.y-i.y,o=i.x-s.x):(u=i.x-s.x,o=i.y-s.y),e.fv=Qe(u,o)}function Ci(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"SPVFS[]",r,n),t.pv=t.dpv=Qe(n,r)}function Oi(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"SPVFS[]",r,n),t.fv=Qe(n,r)}function Ei(t){var e=t.stack,r=t.pv;g.DEBUG&&console.log(t.step,"GPV[]"),e.push(r.x*16384),e.push(r.y*16384)}function Ui(t){var e=t.stack,r=t.fv;g.DEBUG&&console.log(t.step,"GFV[]"),e.push(r.x*16384),e.push(r.y*16384)}function Li(t){t.fv=t.pv,g.DEBUG&&console.log(t.step,"SFVTPV[]")}function Ri(t){var e=t.stack,r=e.pop(),n=e.pop(),a=e.pop(),s=e.pop(),i=e.pop(),u=t.z0,o=t.z1,l=u[r],c=u[n],p=o[a],h=o[s],f=t.z2[i];g.DEBUG&&console.log("ISECT[], ",r,n,a,s,i);var v=l.x,y=l.y,m=c.x,b=c.y,k=p.x,x=p.y,L=h.x,C=h.y,M=(v-m)*(x-C)-(y-b)*(k-L),R=v*b-y*m,O=k*C-x*L;f.x=(R*(k-L)-O*(v-m))/M,f.y=(R*(x-C)-O*(y-b))/M}function Ai(t){t.rp0=t.stack.pop(),g.DEBUG&&console.log(t.step,"SRP0[]",t.rp0)}function Di(t){t.rp1=t.stack.pop(),g.DEBUG&&console.log(t.step,"SRP1[]",t.rp1)}function Mi(t){t.rp2=t.stack.pop(),g.DEBUG&&console.log(t.step,"SRP2[]",t.rp2)}function Bi(t){var e=t.stack.pop();switch(g.DEBUG&&console.log(t.step,"SZP0[]",e),t.zp0=e,e){case 0:t.tZone||dt(t),t.z0=t.tZone;break;case 1:t.z0=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Pi(t){var e=t.stack.pop();switch(g.DEBUG&&console.log(t.step,"SZP1[]",e),t.zp1=e,e){case 0:t.tZone||dt(t),t.z1=t.tZone;break;case 1:t.z1=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ii(t){var e=t.stack.pop();switch(g.DEBUG&&console.log(t.step,"SZP2[]",e),t.zp2=e,e){case 0:t.tZone||dt(t),t.z2=t.tZone;break;case 1:t.z2=t.gZone;break;default:throw new Error("Invalid zone pointer")}}function Gi(t){var e=t.stack.pop();switch(g.DEBUG&&console.log(t.step,"SZPS[]",e),t.zp0=t.zp1=t.zp2=e,e){case 0:t.tZone||dt(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 Ni(t){t.loop=t.stack.pop(),g.DEBUG&&console.log(t.step,"SLOOP[]",t.loop)}function _i(t){g.DEBUG&&console.log(t.step,"RTG[]"),t.round=Mn}function Hi(t){g.DEBUG&&console.log(t.step,"RTHG[]"),t.round=ki}function zi(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"SMD[]",e),t.minDis=e/64}function Wi(t){g.DEBUG&&console.log(t.step,"ELSE[]"),Pn(t,!1)}function Vi(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"JMPR[]",e),t.ip+=e-1}function qi(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"SCVTCI[]",e),t.cvCutIn=e/64}function Xi(t){var e=t.stack;g.DEBUG&&console.log(t.step,"DUP[]"),e.push(e[e.length-1])}function Jt(t){g.DEBUG&&console.log(t.step,"POP[]"),t.stack.pop()}function Yi(t){g.DEBUG&&console.log(t.step,"CLEAR[]"),t.stack.length=0}function Zi(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"SWAP[]"),e.push(r),e.push(n)}function ji(t){var e=t.stack;g.DEBUG&&console.log(t.step,"DEPTH[]"),e.push(e.length)}function Ki(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"LOOPCALL[]",r,n);var a=t.ip,s=t.prog;t.prog=t.funcs[r];for(var i=0;i<n;i++)Le(t),g.DEBUG&&console.log(++t.step,i+1<n?"next loopcall":"done loopcall",i);t.ip=a,t.prog=s}function Qi(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"CALL[]",e);var r=t.ip,n=t.prog;t.prog=t.funcs[e],Le(t),t.ip=r,t.prog=n,g.DEBUG&&console.log(++t.step,"returning from",e)}function Ji(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"CINDEX[]",r),e.push(e[e.length-r])}function $i(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"MINDEX[]",r),e.push(e.splice(e.length-r,1)[0])}function eo(t){if(t.env!=="fpgm")throw new Error("FDEF not allowed here");var e=t.stack,r=t.prog,n=t.ip,a=e.pop(),s=n;for(g.DEBUG&&console.log(t.step,"FDEF[]",a);r[++n]!==45;);t.ip=n,t.funcs[a]=r.slice(s+1,n)}function zn(t,e){var r=e.stack.pop(),n=e.z0[r],a=e.fv,s=e.pv;g.DEBUG&&console.log(e.step,"MDAP["+t+"]",r);var i=s.distance(n,Je);t&&(i=e.round(i)),a.setRelative(n,Je,i,s),a.touch(n),e.rp0=e.rp1=r}function Wn(t,e){var r=e.z2,n=r.length-2,a,s,i;g.DEBUG&&console.log(e.step,"IUP["+t.axis+"]");for(var u=0;u<n;u++)a=r[u],!t.touched(a)&&(s=a.prevTouched(t),s!==a&&(i=a.nextTouched(t),s===i&&t.setRelative(a,a,t.distance(s,s,!1,!0),t,!0),t.interpolate(a,s,i,t)))}function Vn(t,e){for(var r=e.stack,n=t?e.rp1:e.rp2,a=(t?e.z0:e.z1)[n],s=e.fv,i=e.pv,u=e.loop,o=e.z2;u--;){var l=r.pop(),c=o[l],p=i.distance(a,a,!1,!0);s.setRelative(c,c,p,i),s.touch(c),g.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-u)+": ":"")+"SHP["+(t?"rp1":"rp2")+"]",l)}e.loop=1}function qn(t,e){var r=e.stack,n=t?e.rp1:e.rp2,a=(t?e.z0:e.z1)[n],s=e.fv,i=e.pv,u=r.pop(),o=e.z2[e.contours[u]],l=o;g.DEBUG&&console.log(e.step,"SHC["+t+"]",u);var c=i.distance(a,a,!1,!0);do l!==a&&s.setRelative(l,l,c,i),l=l.nextPointOnContour;while(l!==o)}function Xn(t,e){var r=e.stack,n=t?e.rp1:e.rp2,a=(t?e.z0:e.z1)[n],s=e.fv,i=e.pv,u=r.pop();g.DEBUG&&console.log(e.step,"SHZ["+t+"]",u);var o;switch(u){case 0:o=e.tZone;break;case 1:o=e.gZone;break;default:throw new Error("Invalid zone")}for(var l,c=i.distance(a,a,!1,!0),p=o.length-2,h=0;h<p;h++)l=o[h],s.setRelative(l,l,c,i)}function to(t){for(var e=t.stack,r=t.loop,n=t.fv,a=e.pop()/64,s=t.z2;r--;){var i=e.pop(),u=s[i];g.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-r)+": ":"")+"SHPIX[]",i,a),n.setRelative(u,u,a),n.touch(u)}t.loop=1}function ro(t){for(var e=t.stack,r=t.rp1,n=t.rp2,a=t.loop,s=t.z0[r],i=t.z1[n],u=t.fv,o=t.dpv,l=t.z2;a--;){var c=e.pop(),p=l[c];g.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-a)+": ":"")+"IP[]",c,r,"<->",n),u.interpolate(p,s,i,o),u.touch(p)}t.loop=1}function Yn(t,e){var r=e.stack,n=r.pop()/64,a=r.pop(),s=e.z1[a],i=e.z0[e.rp0],u=e.fv,o=e.pv;u.setRelative(s,i,n,o),u.touch(s),g.DEBUG&&console.log(e.step,"MSIRP["+t+"]",n,a),e.rp1=e.rp0,e.rp2=a,t&&(e.rp0=a)}function no(t){for(var e=t.stack,r=t.rp0,n=t.z0[r],a=t.loop,s=t.fv,i=t.pv,u=t.z1;a--;){var o=e.pop(),l=u[o];g.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-a)+": ":"")+"ALIGNRP[]",o),s.setRelative(l,n,0,i),s.touch(l)}t.loop=1}function ao(t){g.DEBUG&&console.log(t.step,"RTDG[]"),t.round=Si}function Zn(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z0[a],i=e.fv,u=e.pv,o=e.cvt[n];g.DEBUG&&console.log(e.step,"MIAP["+t+"]",n,"(",o,")",a);var l=u.distance(s,Je);t&&(Math.abs(l-o)<e.cvCutIn&&(l=o),l=e.round(l)),i.setRelative(s,Je,l,u),e.zp0===0&&(s.xo=s.x,s.yo=s.y),i.touch(s),e.rp0=e.rp1=a}function so(t){var e=t.prog,r=t.ip,n=t.stack,a=e[++r];g.DEBUG&&console.log(t.step,"NPUSHB[]",a);for(var s=0;s<a;s++)n.push(e[++r]);t.ip=r}function io(t){var e=t.ip,r=t.prog,n=t.stack,a=r[++e];g.DEBUG&&console.log(t.step,"NPUSHW[]",a);for(var s=0;s<a;s++){var i=r[++e]<<8|r[++e];i&32768&&(i=-((i^65535)+1)),n.push(i)}t.ip=e}function oo(t){var e=t.stack,r=t.store;r||(r=t.store=[]);var n=e.pop(),a=e.pop();g.DEBUG&&console.log(t.step,"WS",n,a),r[a]=n}function uo(t){var e=t.stack,r=t.store,n=e.pop();g.DEBUG&&console.log(t.step,"RS",n);var a=r&&r[n]||0;e.push(a)}function lo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"WCVTP",r,n),t.cvt[n]=r/64}function co(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"RCVT",r),e.push(t.cvt[r]*64)}function jn(t,e){var r=e.stack,n=r.pop(),a=e.z2[n];g.DEBUG&&console.log(e.step,"GC["+t+"]",n),r.push(e.dpv.distance(a,Je,t,!1)*64)}function Kn(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z1[n],i=e.z0[a],u=e.dpv.distance(i,s,t,t);g.DEBUG&&console.log(e.step,"MD["+t+"]",n,a,"->",u),e.stack.push(Math.round(u*64))}function ho(t){g.DEBUG&&console.log(t.step,"MPPEM[]"),t.stack.push(t.ppem)}function fo(t){g.DEBUG&&console.log(t.step,"FLIPON[]"),t.autoFlip=!0}function po(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"LT[]",r,n),e.push(n<r?1:0)}function vo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"LTEQ[]",r,n),e.push(n<=r?1:0)}function go(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"GT[]",r,n),e.push(n>r?1:0)}function yo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"GTEQ[]",r,n),e.push(n>=r?1:0)}function mo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"EQ[]",r,n),e.push(r===n?1:0)}function bo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"NEQ[]",r,n),e.push(r!==n?1:0)}function xo(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"ODD[]",r),e.push(Math.trunc(r)%2?1:0)}function So(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"EVEN[]",r),e.push(Math.trunc(r)%2?0:1)}function ko(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"IF[]",e),e||(Pn(t,!0),g.DEBUG&&console.log(t.step,"EIF[]"))}function To(t){g.DEBUG&&console.log(t.step,"EIF[]")}function Fo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"AND[]",r,n),e.push(r&&n?1:0)}function wo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"OR[]",r,n),e.push(r||n?1:0)}function Co(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"NOT[]",r),e.push(r?0:1)}function $t(t,e){var r=e.stack,n=r.pop(),a=e.fv,s=e.pv,i=e.ppem,u=e.deltaBase+(t-1)*16,o=e.deltaShift,l=e.z0;g.DEBUG&&console.log(e.step,"DELTAP["+t+"]",n,r);for(var c=0;c<n;c++){var p=r.pop(),h=r.pop(),f=u+((h&240)>>4);if(f===i){var v=(h&15)-8;v>=0&&v++,g.DEBUG&&console.log(e.step,"DELTAPFIX",p,"by",v*o);var y=l[p];a.setRelative(y,y,v*o,s)}}}function Oo(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"SDB[]",r),t.deltaBase=r}function Eo(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"SDS[]",r),t.deltaShift=Math.pow(.5,r)}function Uo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"ADD[]",r,n),e.push(n+r)}function Lo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"SUB[]",r,n),e.push(n-r)}function Ro(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"DIV[]",r,n),e.push(n*64/r)}function Ao(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"MUL[]",r,n),e.push(n*r/64)}function Do(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"ABS[]",r),e.push(Math.abs(r))}function Mo(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"NEG[]",r),e.push(-r)}function Bo(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"FLOOR[]",r),e.push(Math.floor(r/64)*64)}function Po(t){var e=t.stack,r=e.pop();g.DEBUG&&console.log(t.step,"CEILING[]",r),e.push(Math.ceil(r/64)*64)}function vt(t,e){var r=e.stack,n=r.pop();g.DEBUG&&console.log(e.step,"ROUND[]"),r.push(e.round(n/64)*64)}function Io(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"WCVTF[]",r,n),t.cvt[n]=r*t.ppem/t.font.unitsPerEm}function er(t,e){var r=e.stack,n=r.pop(),a=e.ppem,s=e.deltaBase+(t-1)*16,i=e.deltaShift;g.DEBUG&&console.log(e.step,"DELTAC["+t+"]",n,r);for(var u=0;u<n;u++){var o=r.pop(),l=r.pop(),c=s+((l&240)>>4);if(c===a){var p=(l&15)-8;p>=0&&p++;var h=p*i;g.DEBUG&&console.log(e.step,"DELTACFIX",o,"by",h),e.cvt[o]+=h}}}function Go(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"SROUND[]",e),t.round=Bn;var r;switch(e&192){case 0:r=.5;break;case 64:r=1;break;case 128:r=2;break;default:throw new Error("invalid SROUND value")}switch(t.srPeriod=r,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*r;break;case 32:t.srPhase=.5*r;break;case 48:t.srPhase=.75*r;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*r}function No(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"S45ROUND[]",e),t.round=Bn;var r;switch(e&192){case 0:r=Math.sqrt(2)/2;break;case 64:r=Math.sqrt(2);break;case 128:r=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(t.srPeriod=r,e&48){case 0:t.srPhase=0;break;case 16:t.srPhase=.25*r;break;case 32:t.srPhase=.5*r;break;case 48:t.srPhase=.75*r;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?t.srThreshold=0:t.srThreshold=(e/8-.5)*r}function _o(t){g.DEBUG&&console.log(t.step,"ROFF[]"),t.round=xi}function Ho(t){g.DEBUG&&console.log(t.step,"RUTG[]"),t.round=Ti}function zo(t){g.DEBUG&&console.log(t.step,"RDTG[]"),t.round=Fi}function Wo(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"SCANCTRL[]",e)}function Qn(t,e){var r=e.stack,n=r.pop(),a=r.pop(),s=e.z2[n],i=e.z1[a];g.DEBUG&&console.log(e.step,"SDPVTL["+t+"]",n,a);var u,o;t?(u=s.y-i.y,o=i.x-s.x):(u=i.x-s.x,o=i.y-s.y),e.dpv=Qe(u,o)}function Vo(t){var e=t.stack,r=e.pop(),n=0;g.DEBUG&&console.log(t.step,"GETINFO[]",r),r&1&&(n=35),r&32&&(n|=4096),e.push(n)}function qo(t){var e=t.stack,r=e.pop(),n=e.pop(),a=e.pop();g.DEBUG&&console.log(t.step,"ROLL[]"),e.push(n),e.push(r),e.push(a)}function Xo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"MAX[]",r,n),e.push(Math.max(n,r))}function Yo(t){var e=t.stack,r=e.pop(),n=e.pop();g.DEBUG&&console.log(t.step,"MIN[]",r,n),e.push(Math.min(n,r))}function Zo(t){var e=t.stack.pop();g.DEBUG&&console.log(t.step,"SCANTYPE[]",e)}function jo(t){var e=t.stack.pop(),r=t.stack.pop();switch(g.DEBUG&&console.log(t.step,"INSTCTRL[]",e,r),e){case 1:t.inhibitGridFit=!!r;return;case 2:t.ignoreCvt=!!r;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Te(t,e){var r=e.stack,n=e.prog,a=e.ip;g.DEBUG&&console.log(e.step,"PUSHB["+t+"]");for(var s=0;s<t;s++)r.push(n[++a]);e.ip=a}function Fe(t,e){var r=e.ip,n=e.prog,a=e.stack;g.DEBUG&&console.log(e.ip,"PUSHW["+t+"]");for(var s=0;s<t;s++){var i=n[++r]<<8|n[++r];i&32768&&(i=-((i^65535)+1)),a.push(i)}e.ip=r}function F(t,e,r,n,a,s){var i=s.stack,u=t&&i.pop(),o=i.pop(),l=s.rp0,c=s.z0[l],p=s.z1[o],h=s.minDis,f=s.fv,v=s.dpv,y,m,b,k;m=y=v.distance(p,c,!0,!0),b=m>=0?1:-1,m=Math.abs(m),t&&(k=s.cvt[u],n&&Math.abs(m-k)<s.cvCutIn&&(m=k)),r&&m<h&&(m=h),n&&(m=s.round(m)),f.setRelative(p,c,b*m,v),f.touch(p),g.DEBUG&&console.log(s.step,(t?"MIRP[":"MDRP[")+(e?"M":"m")+(r?">":"_")+(n?"R":"_")+(a===0?"Gr":a===1?"Bl":a===2?"Wh":"")+"]",t?u+"("+s.cvt[u]+","+k+")":"",o,"(d =",y,"->",b*m,")"),s.rp1=s.rp0,s.rp2=o,e&&(s.rp0=o)}Rn=[In.bind(void 0,ye),In.bind(void 0,de),Gn.bind(void 0,ye),Gn.bind(void 0,de),Nn.bind(void 0,ye),Nn.bind(void 0,de),_n.bind(void 0,0),_n.bind(void 0,1),Hn.bind(void 0,0),Hn.bind(void 0,1),Ci,Oi,Ei,Ui,Li,Ri,Ai,Di,Mi,Bi,Pi,Ii,Gi,Ni,_i,Hi,zi,Wi,Vi,qi,void 0,void 0,Xi,Jt,Yi,Zi,ji,Ji,$i,void 0,void 0,void 0,Ki,Qi,eo,void 0,zn.bind(void 0,0),zn.bind(void 0,1),Wn.bind(void 0,ye),Wn.bind(void 0,de),Vn.bind(void 0,0),Vn.bind(void 0,1),qn.bind(void 0,0),qn.bind(void 0,1),Xn.bind(void 0,0),Xn.bind(void 0,1),to,ro,Yn.bind(void 0,0),Yn.bind(void 0,1),no,ao,Zn.bind(void 0,0),Zn.bind(void 0,1),so,io,oo,uo,lo,co,jn.bind(void 0,0),jn.bind(void 0,1),void 0,Kn.bind(void 0,0),Kn.bind(void 0,1),ho,void 0,fo,void 0,void 0,po,vo,go,yo,mo,bo,xo,So,ko,To,Fo,wo,Co,$t.bind(void 0,1),Oo,Eo,Uo,Lo,Ro,Ao,Do,Mo,Bo,Po,vt.bind(void 0,0),vt.bind(void 0,1),vt.bind(void 0,2),vt.bind(void 0,3),void 0,void 0,void 0,void 0,Io,$t.bind(void 0,2),$t.bind(void 0,3),er.bind(void 0,1),er.bind(void 0,2),er.bind(void 0,3),Go,No,void 0,void 0,_o,void 0,Ho,zo,Jt,Jt,void 0,void 0,void 0,void 0,void 0,Wo,Qn.bind(void 0,0),Qn.bind(void 0,1),Vo,void 0,qo,Xo,Yo,Zo,jo,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,Te.bind(void 0,1),Te.bind(void 0,2),Te.bind(void 0,3),Te.bind(void 0,4),Te.bind(void 0,5),Te.bind(void 0,6),Te.bind(void 0,7),Te.bind(void 0,8),Fe.bind(void 0,1),Fe.bind(void 0,2),Fe.bind(void 0,3),Fe.bind(void 0,4),Fe.bind(void 0,5),Fe.bind(void 0,6),Fe.bind(void 0,7),Fe.bind(void 0,8),F.bind(void 0,0,0,0,0,0),F.bind(void 0,0,0,0,0,1),F.bind(void 0,0,0,0,0,2),F.bind(void 0,0,0,0,0,3),F.bind(void 0,0,0,0,1,0),F.bind(void 0,0,0,0,1,1),F.bind(void 0,0,0,0,1,2),F.bind(void 0,0,0,0,1,3),F.bind(void 0,0,0,1,0,0),F.bind(void 0,0,0,1,0,1),F.bind(void 0,0,0,1,0,2),F.bind(void 0,0,0,1,0,3),F.bind(void 0,0,0,1,1,0),F.bind(void 0,0,0,1,1,1),F.bind(void 0,0,0,1,1,2),F.bind(void 0,0,0,1,1,3),F.bind(void 0,0,1,0,0,0),F.bind(void 0,0,1,0,0,1),F.bind(void 0,0,1,0,0,2),F.bind(void 0,0,1,0,0,3),F.bind(void 0,0,1,0,1,0),F.bind(void 0,0,1,0,1,1),F.bind(void 0,0,1,0,1,2),F.bind(void 0,0,1,0,1,3),F.bind(void 0,0,1,1,0,0),F.bind(void 0,0,1,1,0,1),F.bind(void 0,0,1,1,0,2),F.bind(void 0,0,1,1,0,3),F.bind(void 0,0,1,1,1,0),F.bind(void 0,0,1,1,1,1),F.bind(void 0,0,1,1,1,2),F.bind(void 0,0,1,1,1,3),F.bind(void 0,1,0,0,0,0),F.bind(void 0,1,0,0,0,1),F.bind(void 0,1,0,0,0,2),F.bind(void 0,1,0,0,0,3),F.bind(void 0,1,0,0,1,0),F.bind(void 0,1,0,0,1,1),F.bind(void 0,1,0,0,1,2),F.bind(void 0,1,0,0,1,3),F.bind(void 0,1,0,1,0,0),F.bind(void 0,1,0,1,0,1),F.bind(void 0,1,0,1,0,2),F.bind(void 0,1,0,1,0,3),F.bind(void 0,1,0,1,1,0),F.bind(void 0,1,0,1,1,1),F.bind(void 0,1,0,1,1,2),F.bind(void 0,1,0,1,1,3),F.bind(void 0,1,1,0,0,0),F.bind(void 0,1,1,0,0,1),F.bind(void 0,1,1,0,0,2),F.bind(void 0,1,1,0,0,3),F.bind(void 0,1,1,0,1,0),F.bind(void 0,1,1,0,1,1),F.bind(void 0,1,1,0,1,2),F.bind(void 0,1,1,0,1,3),F.bind(void 0,1,1,1,0,0),F.bind(void 0,1,1,1,0,1),F.bind(void 0,1,1,1,0,2),F.bind(void 0,1,1,1,0,3),F.bind(void 0,1,1,1,1,0),F.bind(void 0,1,1,1,1,1),F.bind(void 0,1,1,1,1,2),F.bind(void 0,1,1,1,1,3)];function Ne(t){this.char=t,this.state={},this.activeState=null}function tr(t,e,r){this.contextName=r,this.startIndex=t,this.endOffset=e}function Ko(t,e,r){this.contextName=t,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=r}function ue(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 gt(t){this.eventId=t,this.subscribers=[]}function Qo(t){var e=this,r=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];r.forEach(function(a){Object.defineProperty(e.events,a,{value:new gt(a)})}),t&&r.forEach(function(a){var s=t[a];typeof s=="function"&&e.events[a].subscribe(s)});var n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];n.forEach(function(a){e.events[a].subscribe(e.updateContextsRanges)})}function P(t){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Qo.call(this,t)}Ne.prototype.setState=function(t,e){return this.state[t]=e,this.activeState={key:t,value:this.state[t]},this.activeState},Ne.prototype.getState=function(t){return this.state[t]||null},P.prototype.inboundIndex=function(t){return t>=0&&t<this.tokens.length},P.prototype.composeRUD=function(t){var e=this,r=!0,n=t.map(function(s){return e[s[0]].apply(e,s.slice(1).concat(r))}),a=function(s){return typeof s=="object"&&s.hasOwnProperty("FAIL")};if(n.every(a))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(a)};this.dispatch("composeRUD",[n.filter(function(s){return!a(s)})])},P.prototype.replaceRange=function(t,e,r,n){e=e!==null?e:this.tokens.length;var a=r.every(function(i){return i instanceof Ne});if(!isNaN(t)&&this.inboundIndex(t)&&a){var s=this.tokens.splice.apply(this.tokens,[t,e].concat(r));return n||this.dispatch("replaceToken",[t,e,r]),[s,r]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},P.prototype.replaceToken=function(t,e,r){if(!isNaN(t)&&this.inboundIndex(t)&&e instanceof Ne){var n=this.tokens.splice(t,1,e);return r||this.dispatch("replaceToken",[t,e]),[n[0],e]}else return{FAIL:"replaceToken: invalid token or index."}},P.prototype.removeRange=function(t,e,r){e=isNaN(e)?this.tokens.length:e;var n=this.tokens.splice(t,e);return r||this.dispatch("removeRange",[n,t,e]),n},P.prototype.removeToken=function(t,e){if(!isNaN(t)&&this.inboundIndex(t)){var r=this.tokens.splice(t,1);return e||this.dispatch("removeToken",[r,t]),r}else return{FAIL:"removeToken: invalid token index."}},P.prototype.insertToken=function(t,e,r){var n=t.every(function(a){return a instanceof Ne});return n?(this.tokens.splice.apply(this.tokens,[e,0].concat(t)),r||this.dispatch("insertToken",[t,e]),t):{FAIL:"insertToken: invalid token(s)."}},P.prototype.registerModifier=function(t,e,r){this.events.newToken.subscribe(function(n,a){var s=[n,a],i=e===null||e.apply(this,s)===!0,u=[n,a];if(i){var o=r.apply(this,u);n.setState(t,o)}}),this.registeredModifiers.push(t)},gt.prototype.subscribe=function(t){return typeof t=="function"?this.subscribers.push(t)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}},gt.prototype.unsubscribe=function(t){this.subscribers.splice(t,1)},ue.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)},ue.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}},P.prototype.rangeToText=function(t){if(t instanceof tr)return this.getRangeTokens(t).map(function(e){return e.char}).join("")},P.prototype.getText=function(){return this.tokens.map(function(t){return t.char}).join("")},P.prototype.getContext=function(t){var e=this.registeredContexts[t];return e||null},P.prototype.on=function(t,e){var r=this.events[t];return r?r.subscribe(e):null},P.prototype.dispatch=function(t,e){var r=this,n=this.events[t];n instanceof gt&&n.subscribers.forEach(function(a){a.apply(r,e||[])})},P.prototype.registerContextChecker=function(t,e,r){if(this.getContext(t))return{FAIL:"context name '"+t+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof r!="function")return{FAIL:"missing context end check."};var n=new Ko(t,e,r);return this.registeredContexts[t]=n,this.contextCheckers.push(n),n},P.prototype.getRangeTokens=function(t){var e=t.startIndex+t.endOffset;return[].concat(this.tokens.slice(t.startIndex,e))},P.prototype.getContextRanges=function(t){var e=this.getContext(t);return e?e.ranges:{FAIL:"context checker '"+t+"' is not registered."}},P.prototype.resetContextsRanges=function(){var t=this.registeredContexts;for(var e in t)if(t.hasOwnProperty(e)){var r=t[e];r.ranges=[]}},P.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var t=this.tokens.map(function(n){return n.char}),e=0;e<t.length;e++){var r=new ue(t,e);this.runContextCheck(r)}this.dispatch("updateContextsRanges",[this.registeredContexts])},P.prototype.setEndOffset=function(t,e){var r=this.getContext(e).openRange.startIndex,n=new tr(r,t,e),a=this.getContext(e).ranges;return n.rangeId=e+"."+a.length,a.push(n),this.getContext(e).openRange=null,n},P.prototype.runContextCheck=function(t){var e=this,r=t.index;this.contextCheckers.forEach(function(n){var a=n.contextName,s=e.getContext(a).openRange;if(!s&&n.checkStart(t)&&(s=new tr(r,null,a),e.getContext(a).openRange=s,e.dispatch("contextStart",[a,r])),s&&n.checkEnd(t)){var i=r-s.startIndex+1,u=e.setEndOffset(i,a);e.dispatch("contextEnd",[a,u])}})},P.prototype.tokenize=function(t){this.tokens=[],this.resetContextsRanges();var e=Array.from(t);this.dispatch("start");for(var r=0;r<e.length;r++){var n=e[r],a=new ue(e,r);this.dispatch("next",[a]),this.runContextCheck(a);var s=new Ne(n);this.tokens.push(s),this.dispatch("newToken",[s,a])}return this.dispatch("end",[this.tokens]),this.tokens};function we(t){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(t)}function Jn(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 Ce(t){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(t)}function yt(t){return/[A-z]/.test(t)}function Jo(t){return/\s/.test(t)}function $(t){this.font=t,this.features={}}function Re(t){this.id=t.id,this.tag=t.tag,this.substitution=t.substitution}function $e(t,e){if(!t)return-1;switch(e.format){case 1:return e.glyphs.indexOf(t);case 2:for(var r=e.ranges,n=0;n<r.length;n++){var a=r[n];if(t>=a.start&&t<=a.end){var s=t-a.start;return a.index+s}}break;default:return-1}return-1}function $o(t,e){var r=$e(t,e.coverage);return r===-1?null:t+e.deltaGlyphId}function eu(t,e){var r=$e(t,e.coverage);return r===-1?null:e.substitute[r]}function rr(t,e){for(var r=[],n=0;n<t.length;n++){var a=t[n],s=e.current;s=Array.isArray(s)?s[0]:s;var i=$e(s,a);i!==-1&&r.push(i)}return r.length!==t.length?-1:r}function tu(t,e){var r=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(t.context.length<r)return[];var n=rr(e.inputCoverage,t);if(n===-1)return[];var a=e.inputCoverage.length-1;if(t.lookahead.length<e.lookaheadCoverage.length)return[];for(var s=t.lookahead.slice(a);s.length&&Ce(s[0].char);)s.shift();var i=new ue(s,0),u=rr(e.lookaheadCoverage,i),o=[].concat(t.backtrack);for(o.reverse();o.length&&Ce(o[0].char);)o.shift();if(o.length<e.backtrackCoverage.length)return[];var l=new ue(o,0),c=rr(e.backtrackCoverage,l),p=n.length===e.inputCoverage.length&&u.length===e.lookaheadCoverage.length&&c.length===e.backtrackCoverage.length,h=[];if(p)for(var f=0;f<e.lookupRecords.length;f++)for(var v=e.lookupRecords[f],y=v.lookupListIndex,m=this.getLookupByIndex(y),b=0;b<m.subtables.length;b++){var k=m.subtables[b],x=this.getLookupMethod(m,k),L=this.getSubstitutionType(m,k);if(L==="12")for(var C=0;C<n.length;C++){var M=t.get(C),R=x(M);R&&h.push(R)}}return h}function ru(t,e){var r=t.current,n=$e(r,e.coverage);if(n===-1)return null;for(var a,s=e.ligatureSets[n],i=0;i<s.length;i++){a=s[i];for(var u=0;u<a.components.length;u++){var o=t.lookahead[u],l=a.components[u];if(o!==l)break;if(u===a.components.length-1)return a}}return null}function nu(t,e){var r=$e(t,e.coverage);return r===-1?null:e.sequences[r]}$.prototype.getDefaultScriptFeaturesIndexes=function(){for(var t=this.font.tables.gsub.scripts,e=0;e<t.length;e++){var r=t[e];if(r.tag==="DFLT")return r.script.defaultLangSys.featureIndexes}return[]},$.prototype.getScriptFeaturesIndexes=function(t){var e=this.font.tables;if(!e.gsub)return[];if(!t)return this.getDefaultScriptFeaturesIndexes();for(var r=this.font.tables.gsub.scripts,n=0;n<r.length;n++){var a=r[n];if(a.tag===t&&a.script.defaultLangSys)return a.script.defaultLangSys.featureIndexes;var s=a.langSysRecords;if(s)for(var i=0;i<s.length;i++){var u=s[i];if(u.tag===t){var o=u.langSys;return o.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},$.prototype.mapTagsToFeatures=function(t,e){for(var r={},n=0;n<t.length;n++){var a=t[n].tag,s=t[n].feature;r[a]=s}this.features[e].tags=r},$.prototype.getScriptFeatures=function(t){var e=this.features[t];if(this.features.hasOwnProperty(t))return e;var r=this.getScriptFeaturesIndexes(t);if(!r)return null;var n=this.font.tables.gsub;return e=r.map(function(a){return n.features[a]}),this.features[t]=e,this.mapTagsToFeatures(e,t),e},$.prototype.getSubstitutionType=function(t,e){var r=t.lookupType.toString(),n=e.substFormat.toString();return r+n},$.prototype.getLookupMethod=function(t,e){var r=this,n=this.getSubstitutionType(t,e);switch(n){case"11":return function(a){return $o.apply(r,[a,e])};case"12":return function(a){return eu.apply(r,[a,e])};case"63":return function(a){return tu.apply(r,[a,e])};case"41":return function(a){return ru.apply(r,[a,e])};case"21":return function(a){return nu.apply(r,[a,e])};default:throw new Error("lookupType: "+t.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}},$.prototype.lookupFeature=function(t){var e=t.contextParams,r=e.index,n=this.getFeature({tag:t.tag,script:t.script});if(!n)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+t.tag+"' for script '"+t.script+"'.");for(var a=this.getFeatureLookups(n),s=[].concat(e.context),i=0;i<a.length;i++)for(var u=a[i],o=this.getLookupSubtables(u),l=0;l<o.length;l++){var c=o[l],p=this.getSubstitutionType(u,c),h=this.getLookupMethod(u,c),f=void 0;switch(p){case"11":f=h(e.current),f&&s.splice(r,1,new Re({id:11,tag:t.tag,substitution:f}));break;case"12":f=h(e.current),f&&s.splice(r,1,new Re({id:12,tag:t.tag,substitution:f}));break;case"63":f=h(e),Array.isArray(f)&&f.length&&s.splice(r,1,new Re({id:63,tag:t.tag,substitution:f}));break;case"41":f=h(e),f&&s.splice(r,1,new Re({id:41,tag:t.tag,substitution:f}));break;case"21":f=h(e.current),f&&s.splice(r,1,new Re({id:21,tag:t.tag,substitution:f}));break}e=new ue(s,r),!(Array.isArray(f)&&!f.length)&&(f=null)}return s.length?s:null},$.prototype.supports=function(t){if(!t.script)return!1;this.getScriptFeatures(t.script);var e=this.features.hasOwnProperty(t.script);if(!t.tag)return e;var r=this.features[t.script].some(function(n){return n.tag===t.tag});return e&&r},$.prototype.getLookupSubtables=function(t){return t.subtables||null},$.prototype.getLookupByIndex=function(t){var e=this.font.tables.gsub.lookups;return e[t]||null},$.prototype.getFeatureLookups=function(t){return t.lookupListIndexes.map(this.getLookupByIndex.bind(this))},$.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var r=this.features[e.script];return r?r.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function au(t){var e=t.current,r=t.get(-1);return r===null&&we(e)||!we(r)&&we(e)}function su(t){var e=t.get(1);return e===null||!we(e)}var iu={startCheck:au,endCheck:su};function ou(t){var e=t.current,r=t.get(-1);return(we(e)||Ce(e))&&!we(r)}function uu(t){var e=t.get(1);switch(!0){case e===null:return!0;case(!we(e)&&!Ce(e)):var r=Jo(e);if(!r)return!0;if(r){var n=!1;if(n=t.lookahead.some(function(a){return we(a)||Ce(a)}),!n)return!0}break;default:return!1}}var lu={startCheck:ou,endCheck:uu};function cu(t,e,r){e[r].setState(t.tag,t.substitution)}function hu(t,e,r){e[r].setState(t.tag,t.substitution)}function fu(t,e,r){t.substitution.forEach(function(n,a){var s=e[r+a];s.setState(t.tag,n)})}function pu(t,e,r){var n=e[r];n.setState(t.tag,t.substitution.ligGlyph);for(var a=t.substitution.components.length,s=0;s<a;s++)n=e[r+s+1],n.setState("deleted",!0)}var $n={11:cu,12:hu,63:fu,41:pu};function nr(t,e,r){t instanceof Re&&$n[t.id]&&$n[t.id](t,e,r)}function du(t){for(var e=[].concat(t.backtrack),r=e.length-1;r>=0;r--){var n=e[r],a=Jn(n),s=Ce(n);if(!a&&!s)return!0;if(a)return!1}return!1}function vu(t){if(Jn(t.current))return!1;for(var e=0;e<t.lookahead.length;e++){var r=t.lookahead[e],n=Ce(r);if(!n)return!0}return!1}function gu(t){var e=this,r="arab",n=this.featuresTags[r],a=this.tokenizer.getRangeTokens(t);if(a.length!==1){var s=new ue(a.map(function(u){return u.getState("glyphIndex")}),0),i=new ue(a.map(function(u){return u.char}),0);a.forEach(function(u,o){if(!Ce(u.char)){s.setCurrentIndex(o),i.setCurrentIndex(o);var l=0;du(i)&&(l|=1),vu(i)&&(l|=2);var c;switch(l){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(n.indexOf(c)!==-1){var p=e.query.lookupFeature({tag:c,script:r,contextParams:s});if(p instanceof Error)return console.info(p.message);p.forEach(function(h,f){h instanceof Re&&(nr(h,a,f),s.context[f]=h.substitution)})}}})}}function ea(t,e){var r=t.map(function(n){return n.activeState.value});return new ue(r,0)}function yu(t){var e=this,r="arab",n=this.tokenizer.getRangeTokens(t),a=ea(n);a.context.forEach(function(s,i){a.setCurrentIndex(i);var u=e.query.lookupFeature({tag:"rlig",script:r,contextParams:a});u.length&&(u.forEach(function(o){return nr(o,n,i)}),a=ea(n))})}function mu(t){var e=t.current,r=t.get(-1);return r===null&&yt(e)||!yt(r)&&yt(e)}function bu(t){var e=t.get(1);return e===null||!yt(e)}var xu={startCheck:mu,endCheck:bu};function ta(t,e){var r=t.map(function(n){return n.activeState.value});return new ue(r,0)}function Su(t){var e=this,r="latn",n=this.tokenizer.getRangeTokens(t),a=ta(n);a.context.forEach(function(s,i){a.setCurrentIndex(i);var u=e.query.lookupFeature({tag:"liga",script:r,contextParams:a});u.length&&(u.forEach(function(o){return nr(o,n,i)}),a=ta(n))})}function le(t){this.baseDir=t||"ltr",this.tokenizer=new P,this.featuresTags={}}le.prototype.setText=function(t){this.text=t},le.prototype.contextChecks={latinWordCheck:xu,arabicWordCheck:iu,arabicSentenceCheck:lu};function ar(t){var e=this.contextChecks[t+"Check"];return this.tokenizer.registerContextChecker(t,e.startCheck,e.endCheck)}function ku(){return ar.call(this,"latinWord"),ar.call(this,"arabicWord"),ar.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Tu(){var t=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(r){var n=t.tokenizer.getRangeTokens(r);t.tokenizer.replaceRange(r.startIndex,r.endOffset,n.reverse())})}le.prototype.registerFeatures=function(t,e){var r=this,n=e.filter(function(a){return r.query.supports({script:t,tag:a})});this.featuresTags.hasOwnProperty(t)?this.featuresTags[t]=this.featuresTags[t].concat(n):this.featuresTags[t]=n},le.prototype.applyFeatures=function(t,e){if(!t)throw new Error("No valid font was provided to apply features");this.query||(this.query=new $(t));for(var r=0;r<e.length;r++){var n=e[r];this.query.supports({script:n.script})&&this.registerFeatures(n.script,n.tags)}},le.prototype.registerModifier=function(t,e,r){this.tokenizer.registerModifier(t,e,r)};function sr(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Fu(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){sr.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(n){gu.call(t,n)})}}function wu(){var t=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var r=this.featuresTags[e];if(r.indexOf("rlig")!==-1){sr.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(a){yu.call(t,a)})}}}function Cu(){var t=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var r=this.featuresTags[e];if(r.indexOf("liga")!==-1){sr.call(this);var n=this.tokenizer.getContextRanges("latinWord");n.forEach(function(a){Su.call(t,a)})}}}le.prototype.checkContextReady=function(t){return!!this.tokenizer.getContext(t)},le.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Fu.call(this),wu.call(this)),this.checkContextReady("latinWord")&&Cu.call(this),this.checkContextReady("arabicSentence")&&Tu.call(this)},le.prototype.processText=function(t){(!this.text||this.text!==t)&&(this.setText(t),ku.call(this),this.applyFeaturesToContexts())},le.prototype.getBidiText=function(t){return this.processText(t),this.tokenizer.getText()},le.prototype.getTextGlyphs=function(t){this.processText(t);for(var e=[],r=0;r<this.tokenizer.tokens.length;r++){var n=this.tokenizer.tokens[r];if(!n.state.deleted){var a=n.activeState.value;e.push(Array.isArray(a)?a[0]:a)}}return e};function D(t){t=t||{},t.tables=t.tables||{},t.empty||(je(t.familyName,"When creating a new Font object, familyName is required."),je(t.styleName,"When creating a new Font object, styleName is required."),je(t.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),je(t.ascender,"When creating a new Font object, ascender is required."),je(t.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={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||" "}},this.unitsPerEm=t.unitsPerEm||1e3,this.ascender=t.ascender,this.descender=t.descender,this.createdTimestamp=t.createdTimestamp,this.tables=Object.assign(t.tables,{os2:Object.assign({usWeightClass:t.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:t.widthClass||this.usWidthClasses.MEDIUM,fsSelection:t.fsSelection||this.fsSelectionValues.REGULAR},t.tables.os2)})),this.supported=!0,this.glyphs=new pe.GlyphSet(this,t.glyphs||[]),this.encoding=new Wr(this),this.position=new Ze(this),this.substitution=new J(this),this.tables=this.tables||{},this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){if(this._hinting)return this._hinting;if(this.outlinesFormat==="truetype")return this._hinting=new Dn(this)}})}D.prototype.hasChar=function(t){return this.encoding.charToGlyphIndex(t)!==null},D.prototype.charToGlyphIndex=function(t){return this.encoding.charToGlyphIndex(t)},D.prototype.charToGlyph=function(t){var e=this.charToGlyphIndex(t),r=this.glyphs.get(e);return r||(r=this.glyphs.get(0)),r},D.prototype.updateFeatures=function(t){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(r){return t[r]})}:e})},D.prototype.stringToGlyphs=function(t,e){var r=this,n=new le,a=function(p){return r.charToGlyphIndex(p.char)};n.registerModifier("glyphIndex",null,a);var s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;n.applyFeatures(this,s);for(var i=n.getTextGlyphs(t),u=i.length,o=new Array(u),l=this.glyphs.get(0),c=0;c<u;c+=1)o[c]=this.glyphs.get(i[c])||l;return o},D.prototype.nameToGlyphIndex=function(t){return this.glyphNames.nameToGlyphIndex(t)},D.prototype.nameToGlyph=function(t){var e=this.nameToGlyphIndex(t),r=this.glyphs.get(e);return r||(r=this.glyphs.get(0)),r},D.prototype.glyphIndexToName=function(t){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(t):""},D.prototype.getKerningValue=function(t,e){t=t.index||t,e=e.index||e;var r=this.position.defaultKerningTables;return r?this.position.getKerningValue(r,t,e):this.kerningPairs[t+","+e]||0},D.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]},D.prototype.forEachGlyph=function(t,e,r,n,a,s){e=e!==void 0?e:0,r=r!==void 0?r:0,n=n!==void 0?n:72,a=Object.assign({},this.defaultRenderOptions,a);var i=1/this.unitsPerEm*n,u=this.stringToGlyphs(t,a),o;if(a.kerning){var l=a.script||this.position.getDefaultScriptName();o=this.position.getKerningTables(l,a.language)}for(var c=0;c<u.length;c+=1){var p=u[c];if(s.call(this,p,e,r,n,a),p.advanceWidth&&(e+=p.advanceWidth*i),a.kerning&&c<u.length-1){var h=o?this.position.getKerningValue(o,p.index,u[c+1].index):this.getKerningValue(p,u[c+1]);e+=h*i}a.letterSpacing?e+=a.letterSpacing*n:a.tracking&&(e+=a.tracking/1e3*n)}return e},D.prototype.getPath=function(t,e,r,n,a){var s=new _;return this.forEachGlyph(t,e,r,n,a,function(i,u,o,l){var c=i.getPath(u,o,l,a,this);s.extend(c)}),s},D.prototype.getPaths=function(t,e,r,n,a){var s=[];return this.forEachGlyph(t,e,r,n,a,function(i,u,o,l){var c=i.getPath(u,o,l,a,this);s.push(c)}),s},D.prototype.getAdvanceWidth=function(t,e,r){return this.forEachGlyph(t,0,0,e,r,function(){})},D.prototype.draw=function(t,e,r,n,a,s){this.getPath(e,r,n,a,s).draw(t)},D.prototype.drawPoints=function(t,e,r,n,a,s){this.forEachGlyph(e,r,n,a,s,function(i,u,o,l){i.drawPoints(t,u,o,l)})},D.prototype.drawMetrics=function(t,e,r,n,a,s){this.forEachGlyph(e,r,n,a,s,function(i,u,o,l){i.drawMetrics(t,u,o,l)})},D.prototype.getEnglishName=function(t){var e=this.names[t];if(e)return e.en},D.prototype.validate=function(){var t=this;function e(n,a){}function r(n){var a=t.getEnglishName(n);a&&a.trim().length>0}r("fontFamily"),r("weightName"),r("manufacturer"),r("copyright"),r("version"),this.unitsPerEm>0},D.prototype.toTables=function(){return fi.fontToTable(this)},D.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},D.prototype.toArrayBuffer=function(){for(var t=this.toTables(),e=t.encode(),r=new ArrayBuffer(e.length),n=new Uint8Array(r),a=0;a<e.length;a++)n[a]=e[a];return r},D.prototype.download=function(t){var e=this.getEnglishName("fontFamily"),r=this.getEnglishName("fontSubfamily");t=t||e.replace(/\s/g,"")+"-"+r+".otf";var n=this.toArrayBuffer();if(di())if(window.URL=window.URL||window.webkitURL,window.URL){var a=new DataView(n),s=new Blob([a],{type:"font/opentype"}),i=document.createElement("a");i.href=window.URL.createObjectURL(s),i.download=t;var u=document.createEvent("MouseEvents");u.initEvent("click",!0,!1),i.dispatchEvent(u)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var o=require("fs"),l=vi(n);o.writeFileSync(t,l)}},D.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},D.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},D.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function ra(t,e){var r=JSON.stringify(t),n=256;for(var a in e){var s=parseInt(a);if(!(!s||s<256)){if(JSON.stringify(e[a])===r)return s;n<=s&&(n=s+1)}}return e[n]=t,n}function Ou(t,e,r){var n=ra(e.name,r);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:n}]}function Eu(t,e,r){var n={},a=new w.Parser(t,e);return n.tag=a.parseTag(),n.minValue=a.parseFixed(),n.defaultValue=a.parseFixed(),n.maxValue=a.parseFixed(),a.skip("uShort",1),n.name=r[a.parseUShort()]||{},n}function Uu(t,e,r,n){for(var a=ra(e.name,n),s=[{name:"nameID_"+t,type:"USHORT",value:a},{name:"flags_"+t,type:"USHORT",value:0}],i=0;i<r.length;++i){var u=r[i].tag;s.push({name:"axis_"+t+" "+u,type:"FIXED",value:e.coordinates[u]<<16})}return s}function Lu(t,e,r,n){var a={},s=new w.Parser(t,e);a.name=n[s.parseUShort()]||{},s.skip("uShort",1),a.coordinates={};for(var i=0;i<r.length;++i)a.coordinates[r[i].tag]=s.parseFixed();return a}function Ru(t,e){var r=new T.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}]);r.offsetToData=r.sizeOf();for(var n=0;n<t.axes.length;n++)r.fields=r.fields.concat(Ou(n,t.axes[n],e));for(var a=0;a<t.instances.length;a++)r.fields=r.fields.concat(Uu(a,t.instances[a],t.axes,e));return r}function Au(t,e,r){var n=new w.Parser(t,e),a=n.parseULong();E.argument(a===65536,"Unsupported fvar table version.");var s=n.parseOffset16();n.skip("uShort",1);for(var i=n.parseUShort(),u=n.parseUShort(),o=n.parseUShort(),l=n.parseUShort(),c=[],p=0;p<i;p++)c.push(Eu(t,e+s+p*u,r));for(var h=[],f=e+s+i*u,v=0;v<o;v++)h.push(Lu(t,f+v*l,c,r));return{axes:c,instances:h}}var Du={make:Ru,parse:Au},Mu=function(){return{coverage:this.parsePointer(d.coverage),attachPoints:this.parseList(d.pointer(d.uShortList))}},Bu=function(){var t=this.parseUShort();if(E.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()}},Pu=function(){return this.parseList(d.pointer(Bu))},Iu=function(){return{coverage:this.parsePointer(d.coverage),ligGlyphs:this.parseList(d.pointer(Pu))}},Gu=function(){return this.parseUShort(),this.parseList(d.pointer(d.coverage))};function Nu(t,e){e=e||0;var r=new d(t,e),n=r.parseVersion(1);E.argument(n===1||n===1.2||n===1.3,"Unsupported GDEF table version.");var a={version:n,classDef:r.parsePointer(d.classDef),attachList:r.parsePointer(Mu),ligCaretList:r.parsePointer(Iu),markAttachClassDef:r.parsePointer(d.classDef)};return n>=1.2&&(a.markGlyphSets=r.parsePointer(Gu)),a}var _u={parse:Nu},ce=new Array(10);ce[1]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();if(r===1)return{posFormat:1,coverage:this.parsePointer(d.coverage),value:this.parseValueRecord()};if(r===2)return{posFormat:2,coverage:this.parsePointer(d.coverage),values:this.parseValueRecordList()};E.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},ce[2]=function(){var e=this.offset+this.relativeOffset,r=this.parseUShort();E.assert(r===1||r===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(d.coverage),a=this.parseUShort(),s=this.parseUShort();if(r===1)return{posFormat:r,coverage:n,valueFormat1:a,valueFormat2:s,pairSets:this.parseList(d.pointer(d.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(a),value2:this.parseValueRecord(s)}})))};if(r===2){var i=this.parsePointer(d.classDef),u=this.parsePointer(d.classDef),o=this.parseUShort(),l=this.parseUShort();return{posFormat:r,coverage:n,valueFormat1:a,valueFormat2:s,classDef1:i,classDef2:u,class1Count:o,class2Count:l,classRecords:this.parseList(o,d.list(l,function(){return{value1:this.parseValueRecord(a),value2:this.parseValueRecord(s)}}))}}},ce[3]=function(){return{error:"GPOS Lookup 3 not supported"}},ce[4]=function(){return{error:"GPOS Lookup 4 not supported"}},ce[5]=function(){return{error:"GPOS Lookup 5 not supported"}},ce[6]=function(){return{error:"GPOS Lookup 6 not supported"}},ce[7]=function(){return{error:"GPOS Lookup 7 not supported"}},ce[8]=function(){return{error:"GPOS Lookup 8 not supported"}},ce[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Hu(t,e){e=e||0;var r=new d(t,e),n=r.parseVersion(1);return E.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(ce)}:{version:n,scripts:r.parseScriptList(),features:r.parseFeatureList(),lookups:r.parseLookupList(ce),variations:r.parseFeatureVariationsList()}}var zu=new Array(10);function Wu(t){return new T.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new T.ScriptList(t.scripts)},{name:"features",type:"TABLE",value:new T.FeatureList(t.features)},{name:"lookups",type:"TABLE",value:new T.LookupList(t.lookups,zu)}])}var Vu={parse:Hu,make:Wu};function qu(t){var e={};t.skip("uShort");var r=t.parseUShort();E.argument(r===0,"Unsupported kern sub-table version."),t.skip("uShort",2);var n=t.parseUShort();t.skip("uShort",3);for(var a=0;a<n;a+=1){var s=t.parseUShort(),i=t.parseUShort(),u=t.parseShort();e[s+","+i]=u}return e}function Xu(t){var e={};t.skip("uShort");var r=t.parseULong();r>1&&console.warn("Only the first kern subtable is supported."),t.skip("uLong");var n=t.parseUShort(),a=n&255;if(t.skip("uShort"),a===0){var s=t.parseUShort();t.skip("uShort",3);for(var i=0;i<s;i+=1){var u=t.parseUShort(),o=t.parseUShort(),l=t.parseShort();e[u+","+o]=l}}return e}function Yu(t,e){var r=new w.Parser(t,e),n=r.parseUShort();if(n===0)return qu(r);if(n===1)return Xu(r);throw new Error("Unsupported kern table version ("+n+").")}var Zu={parse:Yu};function ju(t,e,r,n){for(var a=new w.Parser(t,e),s=n?a.parseUShort:a.parseULong,i=[],u=0;u<r+1;u+=1){var o=s.call(a);n&&(o*=2),i.push(o)}return i}var Ku={parse:ju};function na(t,e){for(var r=[],n=12,a=0;a<e;a+=1){var s=w.getTag(t,n),i=w.getULong(t,n+4),u=w.getULong(t,n+8),o=w.getULong(t,n+12);r.push({tag:s,checksum:i,offset:u,length:o,compression:!1}),n+=16}return r}function Qu(t,e){for(var r=[],n=44,a=0;a<e;a+=1){var s=w.getTag(t,n),i=w.getULong(t,n+4),u=w.getULong(t,n+8),o=w.getULong(t,n+12),l=void 0;u<o?l="WOFF":l=!1,r.push({tag:s,offset:i,compression:l,compressedLength:u,length:o}),n+=20}return r}function I(t,e){if(e.compression==="WOFF"){var r=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if(Wa(r,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var a=new DataView(n.buffer,0);return{data:a,offset:0}}else return{data:t,offset:e.offset}}function Ju(t,e){e=e??{};var r,n,a=new D({empty:!0}),s=new DataView(t,0),i,u=[],o=w.getTag(s,0);if(o==="\0\0\0"||o==="true"||o==="typ1")a.outlinesFormat="truetype",i=w.getUShort(s,4),u=na(s,i);else if(o==="OTTO")a.outlinesFormat="cff",i=w.getUShort(s,4),u=na(s,i);else if(o==="wOFF"){var l=w.getTag(s,4);if(l==="\0\0\0")a.outlinesFormat="truetype";else if(l==="OTTO")a.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+o);i=w.getUShort(s,12),u=Qu(s,i)}else throw new Error("Unsupported OpenType signature "+o);for(var c,p,h,f,v,y,m,b,k,x,L,C,M=0;M<i;M+=1){var R=u[M],O=void 0;switch(R.tag){case"cmap":O=I(s,R),a.tables.cmap=zr.parse(O.data,O.offset),a.encoding=new Vr(a.tables.cmap);break;case"cvt ":O=I(s,R),C=new w.Parser(O.data,O.offset),a.tables.cvt=C.parseShortList(R.length/2);break;case"fvar":p=R;break;case"fpgm":O=I(s,R),C=new w.Parser(O.data,O.offset),a.tables.fpgm=C.parseByteList(R.length);break;case"head":O=I(s,R),a.tables.head=an.parse(O.data,O.offset),a.unitsPerEm=a.tables.head.unitsPerEm,r=a.tables.head.indexToLocFormat;break;case"hhea":O=I(s,R),a.tables.hhea=sn.parse(O.data,O.offset),a.ascender=a.tables.hhea.ascender,a.descender=a.tables.hhea.descender,a.numberOfHMetrics=a.tables.hhea.numberOfHMetrics;break;case"hmtx":m=R;break;case"ltag":O=I(s,R),n=un.parse(O.data,O.offset);break;case"maxp":O=I(s,R),a.tables.maxp=ln.parse(O.data,O.offset),a.numGlyphs=a.tables.maxp.numGlyphs;break;case"name":x=R;break;case"OS/2":O=I(s,R),a.tables.os2=Xt.parse(O.data,O.offset);break;case"post":O=I(s,R),a.tables.post=yn.parse(O.data,O.offset),a.glyphNames=new _t(a.tables.post);break;case"prep":O=I(s,R),C=new w.Parser(O.data,O.offset),a.tables.prep=C.parseByteList(R.length);break;case"glyf":h=R;break;case"loca":k=R;break;case"CFF ":c=R;break;case"kern":b=R;break;case"GDEF":f=R;break;case"GPOS":v=R;break;case"GSUB":y=R;break;case"meta":L=R;break}}var H=I(s,x);if(a.tables.name=gn.parse(H.data,H.offset,n),a.names=a.tables.name,h&&k){var K=r===0,Q=I(s,k),ae=Ku.parse(Q.data,Q.offset,a.numGlyphs,K),se=I(s,h);a.glyphs=Ln.parse(se.data,se.offset,ae,a,e)}else if(c){var N=I(s,c);nn.parse(N.data,N.offset,a,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var W=I(s,m);if(on.parse(a,W.data,W.offset,a.numberOfHMetrics,a.numGlyphs,a.glyphs,e),cs(a,e),b){var q=I(s,b);a.kerningPairs=Zu.parse(q.data,q.offset)}else a.kerningPairs={};if(f){var X=I(s,f);a.tables.gdef=_u.parse(X.data,X.offset)}if(v){var Y=I(s,v);a.tables.gpos=Vu.parse(Y.data,Y.offset),a.position.init()}if(y){var V=I(s,y);a.tables.gsub=mn.parse(V.data,V.offset)}if(p){var j=I(s,p);a.tables.fvar=Du.parse(j.data,j.offset,a.names)}if(L){var B=I(s,L);a.tables.meta=bn.parse(B.data,B.offset),a.metas=a.tables.meta}return a}function $u(t){return((r,n)=>{const a=Math.round,s={},i=r.encoding.cmap.glyphIndexMap,u=Object.keys(i),o=r.glyphs.glyphs[i[65]];let l=1;o&&(l=r.unitsPerEm/o.yMax);for(let c=0;c<u.length;c++){const p=u[c],h=r.glyphs.glyphs[i[p]];if(p!==void 0){const f={ha:a(h.advanceWidth),x_min:a(h.xMin),x_max:a(h.xMax),o:""};h.path.commands.forEach(function(v){v.type.toLowerCase()==="c"&&(v.type="b"),f.o+=v.type.toLowerCase()+" ",v.x!==void 0&&v.y!==void 0&&(f.o+=a(v.x)+" "+a(v.y)+" "),v.x1!==void 0&&v.y1!==void 0&&(f.o+=a(v.x1)+" "+a(v.y1)+" "),v.x2!==void 0&&v.y2!==void 0&&(f.o+=a(v.x2)+" "+a(v.y2)+" ")}),s[String.fromCodePoint(h.unicode)]=f}}return{glyphs:s,familyName:r.getEnglishName("fullName"),ascender:a(r.ascender),descender:a(r.descender),underlinePosition:r.tables.post.underlinePosition,underlineThickness:r.tables.post.underlineThickness,boundingBox:{xMin:r.tables.head.xMin,xMax:r.tables.head.xMax,yMin:r.tables.head.yMin,yMax:r.tables.head.yMax},resolution:r.unitsPerEm||1e3,scaleFactor:l,original_font_information:r.tables.name}})(Ju(t))}class aa extends St{constructor(e){super(),this.type="mesh",e instanceof ArrayBuffer?this.data=$u(e):this.data=e,this.font=new Aa(this.data)}generateShapes(e,r){return this.font.generateShapes(e,r)}getCharShape(e,r){if(!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new wr(e,r,this)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return new wr("?",e,this)}}let ee=class{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 r=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,r}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 r=this.data.getUint16(this.position,e);return this.position+=2,r}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 te=(t=>(t.SHAPES="shapes",t.BIGFONT="bigfont",t.UNIFONT="unifont",t))(te||{});class el{parse(e){const r=this.parseHeader(e).split(" "),n=r[1].toLocaleLowerCase();if(!Object.values(te).includes(n))throw new Error(`Invalid font type: ${n}`);return{fileHeader:r[0],fontType:n,fileVersion:r[2]}}parseHeader(e){let r="",n=0;for(;e.currentPosition<e.length-2&&n<1024;){const a=e.readUint8();if(a===13){const s=e.currentPosition,i=e.readUint8(),u=e.readUint8();if(i===10&&u===26)break;e.setPosition(s),r+=String.fromCharCode(a)}else r+=String.fromCharCode(a);n++}return r.trim()}}class tl{parse(e){try{e.readBytes(4);const r=e.readInt16();if(r<=0)throw new Error("Invalid shape count in font file");const n=[];for(let i=0;i<r;i++){const u=e.readUint16(),o=e.readUint16();o>0&&n.push({code:u,length:o})}const a={};for(const i of n)try{const u=e.readBytes(i.length);u.length===i.length&&(a[i.code]=u)}catch{console.warn(`Failed to read shape data for code ${i.code}`)}const s={data:a,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in a){const i=a[0];try{const u=new TextDecoder().decode(i);let o=u.indexOf("\0");o>=0&&(s.info=u.substring(0,o),o+3<i.length&&(s.baseUp=i[o+1],s.baseDown=i[o+2],s.orientation=i[o+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse font info block")}}return s}catch(r){return console.error("Error parsing shape font:",r),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class rl{parse(e){try{e.readInt16();const r=e.readInt16(),n=e.readInt16();if(r<=0)throw new Error("Invalid character count in font file");e.skip(n*4);const a=[];for(let u=0;u<r;u++){const o=e.readUint16(!1),l=e.readUint16(),c=e.readUint32();(o!==0||l!==0||c!==0)&&a.push({code:o,length:l,offset:c})}const s={};for(const u of a)try{e.setPosition(u.offset);const o=e.readBytes(u.length);o.length===u.length&&(s[u.code]=o)}catch{console.warn(`Failed to read bigfont data for code ${u.code}`)}const i={data:s,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in s){const u=s[0];try{const o=this.utf8ArrayToStr(u);let l=o.indexOf("\0");l>=0&&(i.info=o.substring(0,l),l++,l+3<u.length&&(u.length-l===4?(i.baseUp=u[l++],i.baseDown=u[l++],i.orientation=u[l++]===0?"horizontal":"vertical"):(i.baseUp=u[l++],l++,i.orientation=u[l++]===0?"horizontal":"vertical",i.baseDown=u[l++],i.isExtended=!0)))}catch{console.warn("Failed to parse bigfont info block")}}return i}catch(r){return console.error("Error parsing big font:",r),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}utf8ArrayToStr(e){let r="",n=0;for(;n<e.length;){const a=e[n++];switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r+=String.fromCharCode(a);break;case 12:case 13:{const s=e[n++];r+=String.fromCharCode((a&31)<<6|s&63);break}case 14:{const s=e[n++],i=e[n++];r+=String.fromCharCode((a&15)<<12|(s&63)<<6|(i&63)<<0);break}}}return r}}class nl{parse(e){try{const r=e.readInt32();if(r<=0)throw new Error("Invalid character count in font file");const n=e.readInt16(),a=e.readBytes(n),s={data:{},info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};try{const u=new TextDecoder().decode(a);let o=u.indexOf("\0");o>=0&&(s.info=u.substring(0,o),o+3<a.length&&(s.baseUp=a[o+1],s.baseDown=a[o+2],s.orientation=a[o+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse unifont info block")}const i={};for(let u=0;u<r-1;u++)try{const o=e.readUint16(),l=e.readUint16();if(l>0){const c=e.readBytes(l);c.length===l&&(i[o]=c)}}catch{console.warn("Failed to read unifont character data");break}return s.data=i,s}catch(r){return console.error("Error parsing unifont:",r),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class al{static createParser(e){switch(e){case te.SHAPES:return new tl;case te.BIGFONT:return new rl;case te.UNIFONT:return new nl;default:throw new Error(`Unsupported font type: ${e}`)}}}class G{constructor(e=0,r=0){this.x=e,this.y=r}set(e,r){return this.x=e,this.y=r,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 G(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,r){return this.x*=e,this.y*=r,this}divideScalars(e,r){return e!==0&&(this.x/=e),r!==0&&(this.y/=r),this}distanceTo(e){const r=this.x-e.x,n=this.y-e.y;return Math.sqrt(r*r+n*n)}}const sa=Math.PI/4;class et{static fromBulge(e,r,n){const a=Math.max(-1,Math.min(1,n));return new et({start:e,end:r,bulge:a})}static fromOctant(e,r,n,a,s){return new et({center:e,radius:r,startOctant:n,octantCount:a,isClockwise:s})}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 r=this.end.clone().subtract(this.start),n=r.length();if(Math.abs(this.bulge)*n/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(r.y,r.x),this.endAngle=this.startAngle;return}const a=4*Math.atan(Math.abs(this.bulge));this.radius=n/(2*Math.sin(a/2));const s=this.start.clone().add(r.clone().divide(2)),i=new G(-r.y,r.x);i.normalize(),i.multiply(Math.abs(this.radius*Math.cos(a/2))),this.center=s.clone(),this.isClockwise?this.center.subtract(i):this.center.add(i),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*sa;const r=(e.octantCount===0?8:e.octantCount)*sa;this.endAngle=this.startAngle+(this.isClockwise?-r:r),this.start=this.center.clone().add(new G(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new G(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 r=[this.start.clone()],n=Math.abs(this.endAngle-this.startAngle),a=Math.max(1,Math.floor(n/e));for(let s=1;s<a;s++){const i=s/a,u=this.isClockwise?this.startAngle-i*n:this.startAngle+i*n;r.push(this.center.clone().add(new G(this.radius*Math.cos(u),this.radius*Math.sin(u))))}return r.push(this.end?this.end.clone():this.center.clone().add(new G(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),r}}let ir=class va{constructor(e,r=[]){this.lastPoint=e,this.polylines=r}get bbox(){let e=1/0,r=-1/0,n=1/0,a=-1/0;return this.polylines.forEach(s=>{s.forEach(i=>{e=Math.min(e,i.x),r=Math.max(r,i.x),n=Math.min(n,i.y),a=Math.max(a,i.y)})}),{minX:e,minY:n,maxX:r,maxY:a}}offset(e,r=!0){var n,a;return r?new va((n=this.lastPoint)==null?void 0:n.clone().add(e),this.polylines.map(s=>s.map(i=>i.clone().add(e)))):((a=this.lastPoint)==null||a.add(e),this.polylines.forEach(s=>s.forEach(i=>i.add(e))),this)}toSVG(e={}){const{strokeWidth:r="0.5%",strokeColor:n="black",isAutoFit:a=!1}=e;let s,i;if(a){const u=this.bbox,o=.2,l=u.maxX-u.minX,c=u.maxY-u.minY,p=u.minX-l*o,h=u.maxX+l*o,f=u.minY-c*o,v=u.maxY+c*o;i=this.polylines.map(y=>{let m="";return y.forEach((b,k)=>{const x=b.x,L=-b.y;m+=k===0?`M ${x} ${L} `:`L ${x} ${L} `}),`<path d="${m}" stroke="${n}" stroke-width="${r}" fill="none"/>`}).join(""),s=`${p} ${-v} ${h-p} ${v-f}`}else s="0 0 20 20",i=this.polylines.map(u=>{let o="";return u.forEach((l,c)=>{const p=l.x+5,h=-l.y+15;o+=c===0?`M ${p} ${h} `:`L ${p} ${h} `}),`<path d="${o}" stroke="${n}" stroke-width="${r}" fill="none"/>`}).join("");return`<svg width="100%" height="100%" viewBox="${s}" preserveAspectRatio="xMidYMid meet">${i}</svg>`}};const sl=Math.PI/18,ia=12;class il{constructor(e){this.shapeCache=new Map,this.shapeData=new Map,this.fontData=e}release(){this.shapeCache.clear(),this.shapeData.clear()}parse(e,r){var n;const a=`${e}_${r}`;if(this.shapeCache.has(a))return this.shapeCache.get(a);if(e===0)return;const s=this.fontData.content.data;let i;if(!this.shapeData.has(e)&&s[e]){const u=s[e],o=ia/this.fontData.content.baseUp;i=this.parseShape(u,o),this.shapeData.set(e,i)}if(this.shapeData.has(e)){const u=r/ia,o=this.shapeData.get(e);i=new ir((n=o.lastPoint)==null?void 0:n.clone().multiply(u),o.polylines.map(l=>l.map(c=>c.clone().multiply(u))))}return i}parseShape(e,r){const n={currentPoint:new G,polylines:[],currentPolyline:[],sp:[],isPenDown:!1,scale:r};for(let a=0;a<e.length;a++){const s=e[a];s<=15?a=this.handleSpecialCommand(s,e,a,n):this.handleVectorCommand(s,n)}return new ir(n.currentPoint,n.polylines)}handleSpecialCommand(e,r,n,a){let s=n;switch(e){case 0:a.currentPolyline=[],a.isPenDown=!1;break;case 1:a.isPenDown=!0,a.currentPolyline.push(a.currentPoint.clone());break;case 2:a.isPenDown=!1,a.currentPolyline.length>1&&a.polylines.push(a.currentPolyline.slice()),a.currentPolyline=[];break;case 3:s++,a.scale/=r[s];break;case 4:s++,a.scale*=r[s];break;case 5:if(a.sp.length===4)throw new Error("The position stack is only four locations deep");a.sp.push(a.currentPoint.clone());break;case 6:a.currentPoint=a.sp.pop()??a.currentPoint;break;case 7:s=this.handleSubshapeCommand(r,s,a);break;case 8:s=this.handleXYDisplacement(r,s,a);break;case 9:s=this.handleMultipleXYDisplacements(r,s,a);break;case 10:s=this.handleOctantArc(r,s,a);break;case 11:s=this.handleFractionalArc(r,s,a);break;case 12:s=this.handleBulgeArc(r,s,a);break;case 13:s=this.handleMultipleBulgeArcs(r,s,a);break;case 14:s=this.skipCode(r,++s);break}return s}handleVectorCommand(e,r){const n=(e&240)>>4,a=e&15,s=this.getVectorForDirection(a);r.currentPoint.add(s.multiply(n*r.scale)),r.isPenDown&&r.currentPolyline.push(r.currentPoint.clone())}getVectorForDirection(e){const r=new G;switch(e){case 0:r.x=1;break;case 1:r.x=1,r.y=.5;break;case 2:r.x=1,r.y=1;break;case 3:r.x=.5,r.y=1;break;case 4:r.y=1;break;case 5:r.x=-.5,r.y=1;break;case 6:r.x=-1,r.y=1;break;case 7:r.x=-1,r.y=.5;break;case 8:r.x=-1;break;case 9:r.x=-1,r.y=-.5;break;case 10:r.x=-1,r.y=-1;break;case 11:r.x=-.5,r.y=-1;break;case 12:r.y=-1;break;case 13:r.x=.5,r.y=-1;break;case 14:r.x=1,r.y=-1;break;case 15:r.x=1,r.y=-.5;break}return r}handleSubshapeCommand(e,r,n){let a=r,s=0,i,u=n.scale*this.fontData.content.baseUp,o=u;const l=n.currentPoint.clone();switch(n.currentPolyline.length>1&&(n.polylines.push(n.currentPolyline.slice()),n.currentPolyline=[]),this.fontData.header.fontType){case te.SHAPES:a++,s=e[a];break;case te.BIGFONT:a++,s=e[a],s===0&&(a++,s=e[a++]|e[a++]<<8,l.x=e[a++]*n.scale,l.y=e[a++]*n.scale,this.fontData.content.isExtended&&(o=e[a++]*n.scale),u=e[a]*n.scale);break;case te.UNIFONT:a++,s=e[a++]|e[a++]<<8;break}return s!==0&&(i=this.getShapeByCodeWithOffset(s,o,u,l),i&&(n.polylines.push(...i.polylines.slice()),n.currentPoint=i.lastPoint?i.lastPoint.clone():l.clone())),n.currentPolyline=[],a}handleXYDisplacement(e,r,n){let a=r;const s=new G;return s.x=ee.byteToSByte(e[++a]),s.y=ee.byteToSByte(e[++a]),n.currentPoint.add(s.multiply(n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone()),a}handleMultipleXYDisplacements(e,r,n){let a=r;for(;;){const s=new G;if(s.x=ee.byteToSByte(e[++a]),s.y=ee.byteToSByte(e[++a]),s.x===0&&s.y===0)break;n.currentPoint.add(s.multiply(n.scale)),n.isPenDown&&n.currentPolyline.push(n.currentPoint.clone())}return a}handleOctantArc(e,r,n){var a;let s=r;const i=e[++s]*n.scale,u=ee.byteToSByte(e[++s]),o=(u&112)>>4;let l=u&7;const c=u<0,p=Math.PI/4*o,h=n.currentPoint.clone().subtract(new G(Math.cos(p)*i,Math.sin(p)*i)),f=et.fromOctant(h,i,o,l,c);if(n.isPenDown){const v=f.tessellate();n.currentPolyline.pop(),n.currentPolyline.push(...v.slice())}return n.currentPoint=(a=f.tessellate().pop())==null?void 0:a.clone(),s}handleFractionalArc(e,r,n){let a=r;const s=e[++a],i=e[++a],u=e[++a],o=e[++a],l=(u*255+o)*n.scale,c=ee.byteToSByte(e[++a]),p=(c&112)>>4;let h=c&7;h===0&&(h=8),i!==0&&h--;const f=Math.PI/4;let v=f*h,y=sl,m=1;c<0&&(y=-y,v=-v,m=-1);let b=f*p,k=b+v;b+=f*s/256*m,k+=f*i/256*m;const x=n.currentPoint.clone().subtract(new G(l*Math.cos(b),l*Math.sin(b)));if(n.currentPoint=x.clone().add(new G(l*Math.cos(k),l*Math.sin(k))),n.isPenDown){let L=b;const C=[];if(C.push(x.clone().add(new G(l*Math.cos(L),l*Math.sin(L)))),y>0)for(;L+y<k;)L+=y,C.push(x.clone().add(new G(l*Math.cos(L),l*Math.sin(L))));else for(;L+y>k;)L+=y,C.push(x.clone().add(new G(l*Math.cos(L),l*Math.sin(L))));C.push(x.clone().add(new G(l*Math.cos(k),l*Math.sin(k)))),n.currentPolyline.push(...C)}return a}handleBulgeArc(e,r,n){let a=r;const s=new G;s.x=ee.byteToSByte(e[++a]),s.y=ee.byteToSByte(e[++a]);const i=ee.byteToSByte(e[++a]);return n.currentPoint=this.handleArcSegment(n.currentPoint,s,i,n.scale,n.isPenDown,n.currentPolyline),a}handleMultipleBulgeArcs(e,r,n){let a=r;for(;;){const s=new G;if(s.x=ee.byteToSByte(e[++a]),s.y=ee.byteToSByte(e[++a]),s.x===0&&s.y===0)break;const i=ee.byteToSByte(e[++a]);n.currentPoint=this.handleArcSegment(n.currentPoint,s,i,n.scale,n.isPenDown,n.currentPolyline)}return a}skipCode(e,r){switch(e[r]){case 0:break;case 1:break;case 2:break;case 3:case 4:r++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case te.SHAPES:r++;break;case te.BIGFONT:r++,e[r]===0&&(r+=5);break;case te.UNIFONT:r+=2;break}break;case 8:r+=2;break;case 9:for(;;){const n=e[++r],a=e[++r];if(n===0&&a===0)break}break;case 10:r+=2;break;case 11:r+=5;break;case 12:r+=3;break;case 13:for(;;){const n=e[++r],a=e[++r];if(n===0&&a===0)break;r++}break}return r}getShapeByCodeWithOffset(e,r,n,a){var s;const i=this.parse(e,n);if(i){if(r===n)return i.offset(a);{const u=(s=i.lastPoint)==null?void 0:s.clone();u&&(u.x*=r/n);const o=i.polylines.map(l=>l.map(c=>c.clone()));return o.forEach(l=>l.forEach(c=>c.x*=r/n)),new ir(u==null?void 0:u.add(a),o.map(l=>l.map(c=>c.add(a))))}}}handleArcSegment(e,r,n,a,s,i){r.x*=a,r.y*=a,n<-127&&(n=-127);const u=e.clone();if(s)if(n===0)i.push(u.clone().add(r));else{const o=u.clone().add(r),l=et.fromBulge(u,o,n/127).tessellate();i.push(...l.slice(1))}return u.add(r),u}}class ol{constructor(e){if(e instanceof ArrayBuffer){const r=new ee(e),n=new el().parse(r),a=al.createParser(n.fontType).parse(r);this.fontData={header:n,content:a}}else this.fontData=e;this.shapeParser=new il(this.fontData)}getCharShape(e,r){return this.shapeParser.parse(e,r)}release(){this.shapeParser.release()}}class or extends kt{constructor(e,r){super(e),this.shape=r,this.width=this.calcWidth()}calcWidth(){const e=this.shape.bbox;return e.maxX-e.minX}offset(e){return new or(this.char,this.shape.offset(e))}toGeometry(){const e=this.shape.polylines,r=[],n=[];let a=0;const s=new A.BufferGeometry;for(let i=0;i<e.length;i++){const u=e[i];for(let o=0;o<u.length;o++){const l=u[o];r.push(l.x,l.y,0),o===u.length-1||n.push(a,a+1),a++}}return s.setAttribute("position",new A.Float32BufferAttribute(r,3)),s.setIndex(n),s}}class oa extends St{constructor(e){super(),this.type="shx",this.font=new ol(e),this.data=this.font.fontData}generateShapes(e,r){const n=[];let a=0;for(let s=0;s<e.length;s++){const i=e[s];if(i===" "){a+=r;continue}const u=this.getCharShape(i,r);if(!u){a+=r,this.addUnsupportedChar(i);continue}n.push(u.offset(new G(a,0))),a+=u.width}return n}getScaleFactor(){return 1}getCharShape(e,r){let n=this.getCode(e);const a=this.font.getCharShape(n,r);return a?new or(e,a):void 0}getNotFoundTextShape(e){let r=this.font.fontData.header.fontType===te.BIGFONT?"?":"?";return this.getCharShape(r,e)}getCode(e){if(this.font.fontData.header.fontType===te.BIGFONT)throw new Error("Bigfont is not supported yet");return e.charCodeAt(0)}}class be{constructor(){}static get instance(){return be._instance||(be._instance=new be),be._instance}createFont(e){if(e.type==="shx")return new oa(e.data);if(e.type==="mesh")return new aa(e.data);throw new Error("Unsupported font data type")}createFontFromBuffer(e,r){const n=Ua(e).toLowerCase();if(n==="shx")return new oa(r);if(["ttf","otf","woff"].includes(n))return new aa(r);throw new Error(`Unsupported font file type: ${n}`)}}class Ae{constructor(){this.fontMapping={},this.fontMap=new Map,this.unsupportedChars={},this.missedFonts={},this.enableFontCache=!0,this.defaultFont="simsun",this.events={fontNotFound:new xt,fontLoaded:new xt},this.loader=new A.FileLoader,this.loader.setResponseType("arraybuffer"),this.fileNames=[]}static get instance(){return Ae._instance||(Ae._instance=new Ae),Ae._instance}setFontMapping(e){this.fontMapping=e}async loadFonts(e){e=Array.isArray(e)?e:[e];const r=[];for(let a=0;a<e.length;a++){const s=e[a];r.push(this.loadFont(s))}const n=[];return await Promise.allSettled(r).then(a=>{a.forEach((s,i)=>{const u=s.status==="fulfilled",o=e[i],l=Fr(o.toLowerCase());n.push({fontName:l,url:o,status:u}),u&&this.fileNames.push(l)})}),n}findAndReplaceFont(e){let r=this.fontMap.get(e.toLowerCase());if(r==null){const n=this.fontMapping[e];if(n)return r=this.fontMap.get(n.toLowerCase()),n}return r?e:this.defaultFont}getCharShape(e,r,n){if(this.fontMap.size===0)return;r==null&&(r="");let a=this.fontMap.get(r.toLowerCase());if(!a){this.recordMissedFonts(r);for(const[,s]of this.fontMap)if(s.getCharShape(e,n)){a=s;break}}return a==null?void 0:a.getCharShape(e,n)}getFontScaleFactor(e){const r=this.fontMap.get(e.toLowerCase());return r?r.getScaleFactor():1}getFontType(e){const r=this.fontMap.get(e.toLowerCase());return r==null?void 0:r.type}getNotFoundTextShape(e){for(const[,r]of this.fontMap){const n=r.getNotFoundTextShape(e);if(n)return n}}recordMissedFonts(e){e&&(this.missedFonts[e]||(this.missedFonts[e]=0),this.missedFonts[e]++,this.events.fontNotFound.dispatch({fontName:e,count:this.missedFonts[e]}))}async loadFont(e){const r=Tr(e);if(!r)throw new Error(`Invalid font url: ${e}`);const n=Fr(e).toLowerCase(),a=await ze.instance.get(n);if(a){const s=be.instance.createFont(a);this.fontMap.set(n,s)}else{const s=await this.loader.loadAsync(e),i=be.instance.createFontFromBuffer(r,s);i&&(this.fontMap.set(n,i),this.enableFontCache&&await ze.instance.set(n,{name:n,type:i.type,data:i.data}))}this.events.fontLoaded.dispatch({fontName:n})}async getAllFontsFromCache(){if(this.fontMap.size!==0)return;const e=await ze.instance.getAll();for(const r of e){const{name:n}=r;if(this.fileNames&&!this.fileNames.includes(n))continue;const a=be.instance.createFont(r);this.fontMap.set(n,a)}}getUnsupportedChar(){for(const[,e]of this.fontMap)Object.assign(this.unsupportedChars,e.unsupportedChars);return this.unsupportedChars}release(){this.fontMap.clear()}}class ul{constructor(){this._avaiableFonts=[]}get avaiableFonts(){return this._avaiableFonts}async getAvaiableFonts(){if(this._avaiableFonts.length==0){const e="https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/fonts/",r=e+"fonts.json";try{const n=await fetch(r);this._avaiableFonts=await n.json()}catch{throw new Error(`Filed to get avaiable font from '${r}'`)}this._avaiableFonts.forEach(n=>{n.url=e+n.file})}return this._avaiableFonts}async load(e){e.length==0&&await this.getAvaiableFonts();const r=[];return e.forEach(n=>{const a=n.toLowerCase(),s=this._avaiableFonts.find(i=>i.name.findIndex(u=>u.toLowerCase()===a)>=0);s&&r.push(s.url)}),await Ae.instance.loadFonts(r)}}var _e=(t=>(t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t[t.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",t[t.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",t[t.BY_STYLE=5]="BY_STYLE",t))(_e||{}),ua=(t=>(t[t.TopLeft=1]="TopLeft",t[t.TopCenter=2]="TopCenter",t[t.TopRight=3]="TopRight",t[t.MiddleLeft=4]="MiddleLeft",t[t.MiddleCenter=5]="MiddleCenter",t[t.MiddleRight=6]="MiddleRight",t[t.BottomLeft=7]="BottomLeft",t[t.BottomCenter=8]="BottomCenter",t[t.BottomRight=9]="BottomRight",t))(ua||{}),He=(t=>(t[t.NONE=0]="NONE",t[t.WORD=1]="WORD",t[t.STACK=2]="STACK",t[t.SPACE=3]="SPACE",t[t.NBSP=4]="NBSP",t[t.TABULATOR=5]="TABULATOR",t[t.NEW_PARAGRAPH=6]="NEW_PARAGRAPH",t[t.NEW_COLUMN=7]="NEW_COLUMN",t[t.WRAP_AT_DIMLINE=8]="WRAP_AT_DIMLINE",t[t.PROPERTIES_CHANGED=9]="PROPERTIES_CHANGED",t))(He||{}),tt=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.MIDDLE=1]="MIDDLE",t[t.TOP=2]="TOP",t))(tt||{}),ve=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.CENTER=3]="CENTER",t[t.JUSTIFIED=4]="JUSTIFIED",t[t.DISTRIBUTED=5]="DISTRIBUTED",t))(ve||{});const ll={c:"Ø",d:"°",p:"±"},cl={l:1,r:2,c:3,j:4,d:5};class hl{constructor(e,r,n=!1){this.ctxStack=[],this.continueStroke=!1,this.inStackContext=!1,this.scanner=new ur(e),this.ctx=r??new mt,this.lastCtx=this.ctx.copy(),this.yieldPropertyCommands=n}decodeMultiByteChar(e){try{const r=new Uint8Array([parseInt(e.substr(0,2),16),parseInt(e.substr(2,2),16)]),n=new TextDecoder("gbk").decode(r);if(n!=="▯")return n;const a=new TextDecoder("big5").decode(r);return a!=="▯"?a:"▯"}catch{return"▯"}}pushCtx(){this.ctxStack.push(this.ctx)}popCtx(){this.ctxStack.length>0&&(this.ctx=this.ctxStack.pop())}parseStacking(){const e=new ur(this.extractExpression(!0));let r="",n="",a="";const s=()=>{let o=e.peek(),l=!1;return o.charCodeAt(0)<32&&(o=" "),o==="\\"&&(l=!0,e.consume(1),o=e.peek()),e.consume(1),[o,l]},i=()=>{let o="";for(;e.hasData;){const[l,c]=s();if(!c&&(l==="/"||l==="#"||l==="^"))return[o,l];o+=l}return[o,""]},u=o=>{let l="",c=o;for(;e.hasData;){const[p,h]=s();if(!(c&&p===" ")){if(c=!1,!h&&p===";")break;l+=p}}return l};return[r,a]=i(),a&&(n=u(a==="^")),r===""&&n.includes("I/")?[2,[" "," ","/"]]:a==="^"?[2,[r,n,"^"]]:[2,[r,n,a]]}parseProperties(e){const r=this.ctx.copy();switch(e){case"L":r.underline=!0,this.continueStroke=!0;break;case"l":r.underline=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"O":r.overline=!0,this.continueStroke=!0;break;case"o":r.overline=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"K":r.strikeThrough=!0,this.continueStroke=!0;break;case"k":r.strikeThrough=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"A":this.parseAlign(r);break;case"C":this.parseAciColor(r);break;case"c":this.parseRgbColor(r);break;case"H":this.parseHeight(r);break;case"W":this.parseWidth(r);break;case"Q":this.parseOblique(r);break;case"T":this.parseCharTracking(r);break;case"p":this.parseParagraphProperties(r);break;case"f":case"F":this.parseFontProperties(r);break;default:throw new Error(`Unknown command: ${e}`)}if(this.continueStroke=r.hasAnyStroke,r.continueStroke=this.continueStroke,this.ctx=r,this.yieldPropertyCommands){const n=this.getPropertyChanges(this.lastCtx,r);if(Object.keys(n).length>0)return this.lastCtx=this.ctx.copy(),{command:e,changes:n}}}getPropertyChanges(e,r){const n={};if(e.underline!==r.underline&&(n.underline=r.underline),e.overline!==r.overline&&(n.overline=r.overline),e.strikeThrough!==r.strikeThrough&&(n.strikeThrough=r.strikeThrough),e.color.aci!==r.color.aci&&(n.aci=r.color.aci),e.color.rgbValue!==r.color.rgbValue&&(n.rgb=r.color.rgb),e.align!==r.align&&(n.align=r.align),JSON.stringify(e.fontFace)!==JSON.stringify(r.fontFace)&&(n.fontFace=r.fontFace),(e.capHeight.value!==r.capHeight.value||e.capHeight.isRelative!==r.capHeight.isRelative)&&(n.capHeight=r.capHeight),(e.widthFactor.value!==r.widthFactor.value||e.widthFactor.isRelative!==r.widthFactor.isRelative)&&(n.widthFactor=r.widthFactor),(e.charTrackingFactor.value!==r.charTrackingFactor.value||e.charTrackingFactor.isRelative!==r.charTrackingFactor.isRelative)&&(n.charTrackingFactor=r.charTrackingFactor),e.oblique!==r.oblique&&(n.oblique=r.oblique),JSON.stringify(e.paragraph)!==JSON.stringify(r.paragraph)){const a={};e.paragraph.indent!==r.paragraph.indent&&(a.indent=r.paragraph.indent),e.paragraph.align!==r.paragraph.align&&(a.align=r.paragraph.align),e.paragraph.left!==r.paragraph.left&&(a.left=r.paragraph.left),e.paragraph.right!==r.paragraph.right&&(a.right=r.paragraph.right),JSON.stringify(e.paragraph.tab_stops)!==JSON.stringify(r.paragraph.tab_stops)&&(a.tab_stops=r.paragraph.tab_stops),Object.keys(a).length>0&&(n.paragraph=a)}return n}parseAlign(e){const r=this.scanner.get();"012".includes(r)?e.align=parseInt(r):e.align=0,this.consumeOptionalTerminator()}parseHeight(e){const r=this.extractFloatExpression(!0);if(r)try{r.endsWith("x")?e.capHeight={value:parseFloat(r.slice(0,-1)),isRelative:!0}:e.capHeight={value:parseFloat(r),isRelative:!1}}catch{this.scanner.consume(-r.length);return}this.consumeOptionalTerminator()}parseWidth(e){const r=this.extractFloatExpression(!0);if(r)try{r.endsWith("x")?e.widthFactor={value:parseFloat(r.slice(0,-1)),isRelative:!0}:e.widthFactor={value:parseFloat(r),isRelative:!1}}catch{this.scanner.consume(-r.length);return}this.consumeOptionalTerminator()}parseCharTracking(e){const r=this.extractFloatExpression(!0);if(r)try{r.endsWith("x")?e.charTrackingFactor={value:Math.abs(parseFloat(r.slice(0,-1))),isRelative:!0}:e.charTrackingFactor={value:Math.abs(parseFloat(r)),isRelative:!1}}catch{this.scanner.consume(-r.length);return}this.consumeOptionalTerminator()}parseFloatValueOrFactor(e){const r=this.extractFloatExpression(!0);if(r)if(r.endsWith("x")){const n=parseFloat(r.slice(0,-1));e*=n}else e=parseFloat(r);return e}parseOblique(e){const r=this.extractFloatExpression(!1);r&&(e.oblique=parseFloat(r)),this.consumeOptionalTerminator()}parseAciColor(e){const r=this.extractIntExpression();if(r){const n=parseInt(r);n<257&&(e.color.aci=n)}this.consumeOptionalTerminator()}parseRgbColor(e){const r=this.extractIntExpression();if(r){const n=parseInt(r)&16777215;e.color.rgbValue=n}this.consumeOptionalTerminator()}extractFloatExpression(e=!1){const r=e?/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/:/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/,n=this.scanner.tail.match(r);if(n){const a=n[0];return this.scanner.consume(a.length),a}return""}extractIntExpression(){const e=this.scanner.tail.match(/^\d+/);if(e){const r=e[0];return this.scanner.consume(r.length),r}return""}extractExpression(e=!1){const r=this.scanner.find(";",e);if(r<0){const s=this.scanner.tail;return this.scanner.consume(s.length),s}const n=this.scanner.peek(r-this.scanner.currentIndex-1)==="\\",a=this.scanner.tail.slice(0,r-this.scanner.currentIndex+(n?1:0));return this.scanner.consume(a.length+1),a}parseFontProperties(e){const r=this.extractExpression().split("|");if(r.length>0&&r[0]){const n=r[0];let a="Regular",s=400;for(const i of r.slice(1))i.startsWith("b1")?s=700:i.startsWith("i1")&&(a="Italic");e.fontFace={family:n,style:a,weight:s}}}parseParagraphProperties(e){const r=new ur(this.extractExpression());let n=e.paragraph.indent,a=e.paragraph.left,s=e.paragraph.right,i=e.paragraph.align,u=[];const o=()=>{const l=r.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);if(l){const c=parseFloat(l[0]);for(r.consume(l[0].length);r.peek()===",";)r.consume(1);return c}return 0};for(;r.hasData;)switch(r.get()){case"i":n=o();break;case"l":a=o();break;case"r":s=o();break;case"x":break;case"q":{const l=r.get();for(i=cl[l]||0;r.peek()===",";)r.consume(1);break}case"t":for(u=[];r.hasData;){const l=r.peek();if(l==="r"||l==="c"){r.consume(1);const c=o();u.push(l+c.toString())}else{const c=o();isNaN(c)?r.consume(1):u.push(c)}}break}e.paragraph={indent:n,left:a,right:s,align:i,tab_stops:u}}consumeOptionalTerminator(){this.scanner.peek()===";"&&this.scanner.consume(1)}*parse(){let e=null;const r=()=>{var n;let a="";for(;this.scanner.hasData;){let s=!1,i=this.scanner.peek();const u=this.scanner.currentIndex;if(i.charCodeAt(0)<32){if(this.scanner.consume(1),i===" ")return[5,null];if(i===`
3
- `)return[6,null];i=" "}if(i==="\\")if("\\{}".includes(this.scanner.peek(1)))s=!0,this.scanner.consume(1),i=this.scanner.peek();else{if(a)return[1,a];this.scanner.consume(1);const o=this.scanner.get();switch(o){case"~":return[4,null];case"P":return[6,null];case"N":return[7,null];case"X":return[8,null];case"S":{this.inStackContext=!0;const l=this.parseStacking();return this.inStackContext=!1,l}case"m":case"M":if(this.scanner.peek()==="+"){this.scanner.consume(1);const l=(n=this.scanner.tail.match(/^[0-9A-Fa-f]{4}/))==null?void 0:n[0];if(l){this.scanner.consume(4);const c=this.decodeMultiByteChar(l);return a?[1,a]:[1,c]}this.scanner.consume(-1)}a+="\\M";continue;default:if(o)try{const l=this.parseProperties(o);if(this.yieldPropertyCommands&&l)return this.lastCtx=this.ctx.copy(),[9,l];continue}catch{const l=this.scanner.tail.slice(u,this.scanner.currentIndex);a+=l}}continue}if(i==="%"&&this.scanner.peek(1)==="%"){const o=this.scanner.peek(2).toLowerCase(),l=ll[o];if(l){this.scanner.consume(3),a+=l;continue}else{this.scanner.consume(3);continue}}if(i===" ")return a?(this.scanner.consume(1),e=3,[1,a]):(this.scanner.consume(1),[3,null]);if(!s){if(i==="{"){if(a)return[1,a];this.scanner.consume(1),this.pushCtx();continue}else if(i==="}"){if(a)return[1,a];this.scanner.consume(1),this.popCtx();continue}}if(!this.inStackContext&&i==="^"){const o=this.scanner.peek(1);if(o){const l=o.charCodeAt(0);if(this.scanner.consume(2),l===32)a+="^";else{if(l===73)return a?[1,a]:[5,null];if(l===74)return a?[1,a]:[6,null];if(l===77)continue;a+="▯"}continue}}this.scanner.consume(1),i.charCodeAt(0)>=32&&(a+=i)}return a?[1,a]:[0,null]};for(;;){const[n,a]=r();if(n)yield new la(n,this.ctx,a),e&&(yield new la(e,this.ctx,null),e=null);else break}}}class ur{constructor(e){this.text=e,this.textLen=e.length,this._index=0}get currentIndex(){return this._index}get isEmpty(){return this._index>=this.textLen}get hasData(){return this._index<this.textLen}get(){if(this.isEmpty)return"";const e=this.text[this._index];return this._index++,e}consume(e=1){this._index=Math.max(0,Math.min(this._index+e,this.textLen))}peek(e=0){const r=this._index+e;return r>=this.textLen||r<0?"":this.text[r]}find(e,r=!1){let n=this._index;for(;n<this.textLen;){if(r&&this.text[n]==="\\"){if(n+1<this.textLen){if(this.text[n+1]===e)return n+1;n+=2;continue}n++;continue}if(this.text[n]===e)return n;n++}return-1}get tail(){return this.text.slice(this._index)}isNextSpace(){return this.peek()===" "}consumeSpaces(){let e=0;for(;this.isNextSpace();)this.consume(),e++;return e}}class lr{constructor(e){this._aci=256,this._rgbValue=null,Array.isArray(e)?this.rgb=e:typeof e=="number"?this.aci=e:this.aci=256}get aci(){return this._aci}set aci(e){if(e===null)this._aci=null;else if(e>=0&&e<=256)this._aci=e,this._rgbValue=null;else throw new Error("ACI not in range [0, 256]")}get rgb(){if(this._rgbValue===null)return null;const e=this._rgbValue>>16&255,r=this._rgbValue>>8&255,n=this._rgbValue&255;return[e,r,n]}set rgb(e){if(e){const[r,n,a]=e;this._rgbValue=(r&255)<<16|(n&255)<<8|a&255,this._aci=null}else this._rgbValue=null}get isRgb(){return this._rgbValue!==null}get isAci(){return this._rgbValue===null&&this._aci!==null}get rgbValue(){return this._rgbValue}set rgbValue(e){e===null?this._rgbValue=null:(this._rgbValue=e&16777215,this._aci=null)}copy(){const e=new lr;return e._aci=this._aci,e._rgbValue=this._rgbValue,e}toObject(){return{aci:this._aci,rgb:this.rgb,rgbValue:this._rgbValue}}equals(e){return this._aci===e._aci&&this._rgbValue===e._rgbValue}}class mt{constructor(){this._stroke=0,this.continueStroke=!1,this.color=new lr,this.align=0,this.fontFace={family:"",style:"Regular",weight:400},this._capHeight={value:1,isRelative:!1},this._widthFactor={value:1,isRelative:!1},this._charTrackingFactor={value:1,isRelative:!1},this.oblique=0,this.paragraph={indent:0,left:0,right:0,align:0,tab_stops:[]}}get capHeight(){return this._capHeight}set capHeight(e){this._capHeight={value:Math.abs(e.value),isRelative:e.isRelative}}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get charTrackingFactor(){return this._charTrackingFactor}set charTrackingFactor(e){this._charTrackingFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get aci(){return this.color.aci}set aci(e){this.color.aci=e}get rgb(){return this.color.rgb}set rgb(e){this.color.rgb=e}get underline(){return!!(this._stroke&1)}set underline(e){this._setStrokeState(1,e)}get strikeThrough(){return!!(this._stroke&4)}set strikeThrough(e){this._setStrokeState(4,e)}get overline(){return!!(this._stroke&2)}set overline(e){this._setStrokeState(2,e)}get hasAnyStroke(){return!!this._stroke}_setStrokeState(e,r=!0){r?this._stroke|=e:this._stroke&=~e}copy(){const e=new mt;return e._stroke=this._stroke,e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e._capHeight={...this._capHeight},e._widthFactor={...this._widthFactor},e._charTrackingFactor={...this._charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e}}class la{constructor(e,r,n){this.type=e,this.ctx=r,this.data=n}}function ca(t,e=!1){const r=t[0].index!==null,n=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),s={},i={},u=t[0].morphTargetsRelative,o=new ge.BufferGeometry;let l=0;for(let c=0;c<t.length;++c){const p=t[c];let h=0;if(r!==(p.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in p.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(p.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(u!==p.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in p.morphAttributes){if(!a.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;i[f]===void 0&&(i[f]=[]),i[f].push(p.morphAttributes[f])}if(e){let f;if(r)f=p.index.count;else if(p.attributes.position!==void 0)f=p.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;o.addGroup(l,f,c),l+=f}}if(r){let c=0;const p=[];for(let h=0;h<t.length;++h){const f=t[h].index;for(let v=0;v<f.count;++v)p.push(f.getX(v)+c);c+=t[h].attributes.position.count}o.setIndex(p)}for(const c in s){const p=ha(s[c]);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;o.setAttribute(c,p)}for(const c in i){const p=i[c][0].length;if(p===0)break;o.morphAttributes=o.morphAttributes||{},o.morphAttributes[c]=[];for(let h=0;h<p;++h){const f=[];for(let y=0;y<i[c].length;++y)f.push(i[c][y][h]);const v=ha(f);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;o.morphAttributes[c].push(v)}}return o}function ha(t){let e,r,n,a=-1,s=0;for(let l=0;l<t.length;++l){const c=t[l];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(r===void 0&&(r=c.itemSize),r!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(a===-1&&(a=c.gpuType),a!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*r}const i=new e(s),u=new ge.BufferAttribute(i,r,n);let o=0;for(let l=0;l<t.length;++l){const c=t[l];if(c.isInterleavedBufferAttribute){const p=o/r;for(let h=0,f=c.count;h<f;h++)for(let v=0;v<r;v++){const y=c.getComponent(h,v);u.setComponent(h+p,v,y)}}else i.set(c.array,o);o+=c.count*r}return a!==void 0&&(u.gpuType=a),u}const fl=new A.Vector3,pl=1.666666;class dl{constructor(e,r,n,a){this._currentUnderline=!1,this._currentOverline=!1,this._currentStrikeThrough=!1,this._currentObliqueAngle=0,this._style=e,this._styleManager=r,this._fontManager=n,this._options=a,this._totalHeight=0,this._hOffset=0,this._vOffset=0,this._lineCount=1,this._currentLineObjects=[],this._currentHorizontalAlignment=a.horizontalAlignment,this._currentFont=this.textStyle.font.toLowerCase(),this._currentWidthFactor=a.widthFactor,this._currentWordSpace=1,this._currentColor=a.byLayerColor,this._currentFontSizeScaleFactor=1,this._currentMaxFontSize=0,this._currentObliqueAngle=e.obliqueAngle||0,this.initLineParams(),this._currentBlankWidth=this.calculateBlankWidth()}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get totalHeight(){return this._lineCount==1?this.currentMaxFontSize:this._totalHeight+this.currentLineHeight}get maxWidth(){return this._options.maxWidth}get flowDirection(){return this._options.flowDirection}get defaultHorizontalAlignment(){return this._options.horizontalAlignment}get defaultWidthFactor(){return this._options.widthFactor}get defaultFontSize(){return this._options.fontSize}get defaultLineSpaceFactor(){return this._options.lineSpaceFactor}get currentFont(){return this._currentFont}get currentHorizontalAlignment(){return this._currentHorizontalAlignment}get currentFontScaleFactor(){return this._currentFontScaleFactor}get currentFontSize(){return this._currentFontSize}get currentFontSizeScaleFactor(){return this._currentFontSizeScaleFactor}get currentLineHeight(){return this.defaultLineSpaceFactor*this._currentFontSize*pl+this.currentMaxFontSize}get currentMaxFontSize(){return this._currentMaxFontSize}get currentWordSpace(){return this._currentWordSpace}get currentWidthFactor(){return this._currentWidthFactor}get currentColor(){return this._currentColor}get currentLineObjects(){return this._currentLineObjects}get hOffset(){return this._hOffset}set hOffset(e){this._hOffset=e}get vOffset(){return this._vOffset}set vOffset(e){this._vOffset=e}get currentObliqueAngle(){return this._currentObliqueAngle}processFormat(e){switch(e.command){case"f":case"F":if(e.changes.fontFace){this.changeFont(e.changes.fontFace.family),this.currentFont&&this.currentFont.includes(".shx")&&console.log(`Doesn't support custom fonts: ${this.currentFont}`);break}case"C":e.changes.aci?e.changes.aci===0?this._currentColor=this._options.byBlockColor:e.changes.aci===256?this._currentColor=this._options.byLayerColor:this._currentColor=Ra(e.changes.aci):e.changes.rgb&&(this._currentColor=(e.changes.rgb[0]<<16)+(e.changes.rgb[1]<<8)+e.changes.rgb[2]);break;case"W":e.changes.widthFactor&&(e.changes.widthFactor.isRelative?this._currentWidthFactor=e.changes.widthFactor.value*this.maxWidth:this._currentWidthFactor=e.changes.widthFactor.value*.93);break;case"H":e.changes.capHeight&&(e.changes.capHeight.isRelative?this.changeFontSizeScaleFactor(e.changes.capHeight.value):this.changeFontHeight(e.changes.capHeight.value));break;case"T":e.changes.charTrackingFactor&&(e.changes.charTrackingFactor.isRelative?this._currentWordSpace=e.changes.charTrackingFactor.value:this._currentWordSpace=e.changes.charTrackingFactor.value);break;case"q":e.changes.paragraph&&e.changes.paragraph.align&&(this._currentHorizontalAlignment=e.changes.paragraph.align);break;case"L":this._currentUnderline=!0;break;case"l":this._currentUnderline=!1;break;case"O":this._currentOverline=!0;break;case"o":this._currentOverline=!1;break;case"K":this._currentStrikeThrough=!0;break;case"k":this._currentStrikeThrough=!1;break;case"Q":e.changes.oblique!==void 0&&(this._currentObliqueAngle=e.changes.oblique);break}}processText(e){const r=[],n=[],a=new A.Group;for(const s of e)if(s.type===He.NEW_PARAGRAPH)this.startNewLine(),this.processGeometries(r,n,a);else if(s.type===He.WORD){const i=s.data;Array.isArray(i)?i.forEach(u=>this.processWord(u,r,n)):typeof i=="string"&&i.length>0&&this.processWord(i,r,n),this.processGeometries(r,n,a)}else s.type===He.SPACE?this.processBlank():s.type===He.PROPERTIES_CHANGED?(this.processFormat(s.data),this.processGeometries(r,n,a)):s.type===He.STACK&&(this.processStack(s.data,r,n),this.processGeometries(r,n,a));return(r.length>0||n.length>0)&&this.processGeometries(r,n,a),a}processGeometries(e,r,n){if(e.length>0||r.length>0){const a=this.toThreeObject(e,r);n.add(a),e.length=0,r.length=0}}processWord(e,r,n){for(let a=0;a<e.length;a++)this.processChar(e[a],r,n)}processStack(e,r,n){const[a,s,i]=e,u=this._hOffset,o=this._vOffset,l=this._currentWordSpace,c=this._currentFontSize,p=this._currentFontSizeScaleFactor;this._hOffset=u,this._currentWordSpace=1;let h=0;for(let b=0;b<a.length;b++){const k=this.getCharShape(a[b]);k&&(h+=k.width*this.currentWidthFactor)}this._hOffset=u;let f=0;for(let b=0;b<s.length;b++){const k=this.getCharShape(s[b]);k&&(f+=k.width*this.currentWidthFactor)}const v=Math.max(h,f),y=(v-h)/2,m=(v-f)/2;if(i==="^"){if(this._currentFontSizeScaleFactor=p*.7,this.calcuateLineParams(),a&&!s){const b=[],k=[];this._hOffset=u,this._vOffset=o+c*.1;for(let x=0;x<a.length;x++)this.processChar(a[x],b,k);r.push(...b),n.push(...k),this._hOffset=u+h}else if(!a&&s){const b=[],k=[];this._hOffset=u,this._vOffset=o-c*.3;for(let x=0;x<s.length;x++)this.processChar(s[x],b,k);r.push(...b),n.push(...k),this._hOffset=u+f}this._currentFontSizeScaleFactor=p,this.calcuateLineParams()}else{const b=[],k=[];this._hOffset=u+y,this._vOffset=o+this.currentFontSize*.3;for(let C=0;C<a.length;C++)this.processChar(a[C],b,k);r.push(...b),n.push(...k);const x=[],L=[];this._hOffset=u+m,this._vOffset=o-this.currentFontSize*.6;for(let C=0;C<s.length;C++)this.processChar(s[C],x,L);if(r.push(...x),n.push(...L),i==="/"||i==="#"){const C=new A.BufferGeometry,M=new Float32Array([u,o-this.currentFontSize*.8,0,u+v,o-this.currentFontSize*.8,0]);C.setAttribute("position",new A.BufferAttribute(M,3)),C.setIndex(null),n.push(C)}this._hOffset=u+v}this._vOffset=o,this._currentWordSpace=l}processBlank(){this._hOffset+=this._currentBlankWidth}processChar(e,r,n){const a=this.getCharShape(e);if(!a){this.processBlank();return}const s=a.toGeometry();if(s.scale(this.currentWidthFactor,1,1),this.currentObliqueAngle){const h=this.currentObliqueAngle*Math.PI/180,f=new A.Matrix4;f.set(1,Math.tan(h),0,0,0,1,0,0,0,0,1,0,0,0,0,1),s.applyMatrix4(f)}this.hOffset>(this.maxWidth||1/0)&&this.startNewLine();let i=this.hOffset,u=this.flowDirection==_e.BOTTOM_TO_TOP?this.vOffset:this.vOffset-this.currentFontSize,o=a.width*this.currentWidthFactor,l=this.currentFontSize;s.translate(i,u,0),this.currentHorizontalAlignment==ve.DISTRIBUTED?this._hOffset+=a.width*this.currentWidthFactor:this._hOffset+=a.width*this.currentWordSpace*this.currentWidthFactor,r.push(s);const c=l*.05,p=.001;if(this._currentUnderline){const h=new A.BufferGeometry,f=u-c;h.setAttribute("position",new A.BufferAttribute(new Float32Array([i,f,p,i+o,f,p]),3)),h.setIndex(null),n.push(h)}if(this._currentOverline){const h=new A.BufferGeometry,f=u+l+c;h.setAttribute("position",new A.BufferAttribute(new Float32Array([i,f,p,i+o,f,p]),3)),h.setIndex(null),n.push(h)}if(this._currentStrikeThrough){const h=new A.BufferGeometry,f=u+l/2;h.setAttribute("position",new A.BufferAttribute(new Float32Array([i,f,p,i+o,f,p]),3)),h.setIndex(null),n.push(h)}}processLastLine(){this.processAlignment()}initLineParams(){this.calcuateLineParams()}changeFontHeight(e){this.calcuateLineParams(e)}changeFont(e){let r=e;this._options.removeFontExtension&&(r=e.replace(/\.(ttf|otf|woff|shx)$/,"")),this._currentFont=this.fontManager.findAndReplaceFont(r),this._currentBlankWidth=this.calculateBlankWidth(),this.calcuateLineParams()}changeFontSizeScaleFactor(e){this._currentFontSizeScaleFactor*=e,this.calcuateLineParams()}calcuateLineParams(e){this._currentFontScaleFactor=this.fontManager.getFontScaleFactor(this.currentFont);const r=e||this.defaultFontSize||this.textStyle.fixedTextHeight;this._currentFontSize=r*this.currentFontScaleFactor*this.currentFontSizeScaleFactor}getCharShape(e){let r=this.fontManager.getCharShape(e,this.currentFont,this.currentFontSize);return this.textStyle.bigFont&&!r&&(r=this.fontManager.getCharShape(e,this.textStyle.bigFont,this.currentFontSize)),r||(r=this.fontManager.getCharShape(e,"",this.currentFontSize)),r||(r=this.fontManager.getNotFoundTextShape(this.currentFontSize)),this.currentFontSize>this.currentMaxFontSize&&(this._currentMaxFontSize=this.currentFontSize),r}startNewLine(){this._hOffset=0,this.flowDirection==_e.BOTTOM_TO_TOP?this._vOffset+=this.currentLineHeight:this._vOffset-=this.currentLineHeight,this._lineCount++,this.processAlignment(),this._currentLineObjects=[],this._lineCount==2?this._totalHeight=this.currentMaxFontSize:this._totalHeight=this._totalHeight+this.currentLineHeight}processAlignment(){const e=[];if(this.currentLineObjects.forEach(n=>n.traverse(a=>{"geometry"in a&&e.push(a.geometry)})),e.length==0)return;let r;if(e.forEach((n,a)=>{n.boundingBox||n.computeBoundingBox(),a===0?r=n.boundingBox:r.union(n.boundingBox)}),r){const n=r.getSize(fl);switch(this.currentHorizontalAlignment){case ve.LEFT:break;case ve.CENTER:e.forEach(a=>a.translate((this.maxWidth-n.x)/2,0,0));break;case ve.RIGHT:e.forEach(a=>a.translate(this.maxWidth-n.x,0,0));break;case ve.DISTRIBUTED:if(e.length>1){const a=(this.maxWidth-n.x)/(e.length-1);for(let s=1;s<e.length;s++)e[s].translate(a*s,0,0)}break}}}calculateBlankWidth(){return this.fontManager.getFontType(this.currentFont)==="shx"?this.currentFontSize*.5:this.currentFontSize*.3}toThreeObject(e,r){const n=new A.Group,a=this.currentColor,s=e.filter(u=>u instanceof A.ExtrudeGeometry);if(s.length>0){const u=new A.Mesh;u.geometry=ca(s),u.material=this.styleManager.getMeshBasicMaterial(a),u.userData.bboxIntersectionCheck=!0,n.add(u)}const i=[...r,...e.filter(u=>!(u instanceof A.ExtrudeGeometry))];if(i.length>0){const u=new A.LineSegments;u.geometry=ca(i),u.material=this.styleManager.getLineBasicMaterial(a),u.userData.bboxIntersectionCheck=!0,n.add(u)}return n.children.length===1?n.children[0]:n}}const cr=new A.Vector3,De=new A.Vector3,hr=new A.Vector3,fr=new A.Quaternion,pr=new A.Matrix4,fa=new A.Matrix4,pa=new A.Vector3(1,0,0);class vl extends A.Object3D{constructor(e,r,n,a,s={byLayerColor:16777215,byBlockColor:16777215}){super(),this._style=r,this._styleManager=n,this._fontManager=a,this._colorSettings={byLayerColor:s.byLayerColor,byBlockColor:s.byBlockColor},this._box=new A.Box3,this._boxes=[];const i=this.loadMText(e,r);i&&(this.getBoxes(i,this._boxes),this._boxes.forEach(u=>this.box.union(u)),this.add(i))}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get box(){return this._box}set box(e){this._box.copy(e)}raycast(e,r){this._boxes.forEach(n=>{if(e.ray.intersectBox(n,cr)){const a=e.ray.origin.distanceTo(cr);r.push({distance:a,point:cr.clone(),object:this,face:null,faceIndex:void 0,uv:void 0})}})}loadMText(e,r){const{object:n,height:a}=this.createMTextGroup(e,r);if(!n)return;n.matrix.decompose(De,fr,hr),e.position&&(De.x+=e.position.x,De.y+=e.position.y,n.matrix.compose(De,fr,hr));const s=e.width,i=this.calculateAnchorPoint(s,a,e.attachmentPoint,e.drawingDirection);n.traverse(l=>{"geometry"in l&&l.geometry.translate(i.x,i.y,0),l.layers.enableAll()});let u=e.rotation||0;if(e.directionVector){const l=e.directionVector,c=new A.Vector3(l.x,l.y,l.z),p=c.clone().cross(pa),h=pa.angleTo(c);u=p.z>0?-h:h}n.matrix.compose(De,fr,hr);const o=e.position?De.clone().sub(e.position):De;return pr.makeTranslation(-o.x,-o.y,0),fa.makeRotationZ(u),n.matrix.multiply(pr),n.matrix.multiply(fa),n.matrix.multiply(pr.invert()),n.matrix.decompose(n.position,n.quaternion,n.scale),n}createMTextGroup(e,r){if(r&&r.font&&r.font.endsWith(".shx")){const y=`${r.font}_${r.name}`;this.styleManager.unsupportedTextStyles[y]||(this.styleManager.unsupportedTextStyles[y]=0),this.styleManager.unsupportedTextStyles[y]++}const n=e.width||0;let a=ve.LEFT;e.width&&e.attachmentPoint&&([1,4,7].includes(e.attachmentPoint)?a=ve.LEFT:[2,5,8].includes(e.attachmentPoint)?a=ve.CENTER:[3,6,9].includes(e.attachmentPoint)&&(a=ve.RIGHT));let s=tt.BOTTOM;e.attachmentPoint&&([1,2,3].includes(e.attachmentPoint)?s=tt.TOP:[4,5,6].includes(e.attachmentPoint)?s=tt.MIDDLE:[7,8,9].includes(e.attachmentPoint)&&(s=tt.BOTTOM));const i=e.height||0,u=e.lineSpaceFactor||.3,o=e.drawingDirection??_e.LEFT_TO_RIGHT,l={fontSize:i,widthFactor:e.widthFactor??1,lineSpaceFactor:u,horizontalAlignment:a,maxWidth:n,flowDirection:o,byBlockColor:this._colorSettings.byBlockColor,byLayerColor:this._colorSettings.byLayerColor,removeFontExtension:!0},c=new mt;c.fontFace.family=r.font,c.capHeight={value:e.height||1,isRelative:!0},c.widthFactor={value:e.widthFactor??1,isRelative:!0},c.align=s,c.paragraph.align=a;const h=new hl(e.text,c,!0).parse(),f=new dl(r,this.styleManager,this.fontManager,l),v=f.processText(h);return f.processLastLine(),{object:v,height:f.totalHeight}}calculateAnchorPoint(e,r,n,a){let s=0,i=0;switch(n){case void 0:case 1:s=0,i=0;break;case 2:s-=e/2,i=0;break;case 3:s-=e,i=0;break;case 4:s=0,i+=r/2;break;case 5:s-=e/2,i+=r/2;break;case 6:s-=e,i+=r/2;break;case 7:s=0,i+=r;break;case 8:s-=e/2,i+=r;break;case 9:s-=e,i+=r;break}return a==_e.BOTTOM_TO_TOP&&(i-=r),{x:s,y:i}}getBoxes(e,r){if(e.updateWorldMatrix(!1,!1),e instanceof A.Line||e instanceof A.Mesh){const a=e.geometry;a.boundingBox===null&&a.computeBoundingBox();const s=new A.Box3().copy(a.boundingBox);s.applyMatrix4(e.matrixWorld),r.push(s)}const n=e.children;for(let a=0,s=n.length;a<s;a++)this.getBoxes(n[a],r)}}class gl{constructor(){this.lineBasicMaterials={},this.meshBasicMaterials={},this.unsupportedTextStyles={}}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new A.MeshBasicMaterial({color:e})),this.meshBasicMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new A.LineBasicMaterial({color:e})),this.lineBasicMaterials[e]}}g.BaseFont=St,g.BaseTextShape=kt,g.DefaultFontLoader=ul,g.EventManager=xt,g.FontFactory=be,g.FontManager=Ae,g.MText=vl,g.MTextAttachmentPoint=ua,g.MTextFlowDirection=_e,g.StyleManager=gl,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
3
+ `)return[6,null];i=" "}if(i==="\\")if("\\{}".includes(this.scanner.peek(1)))s=!0,this.scanner.consume(1),i=this.scanner.peek();else{if(a)return[1,a];this.scanner.consume(1);const o=this.scanner.get();switch(o){case"~":return[4,null];case"P":return[6,null];case"N":return[7,null];case"X":return[8,null];case"S":{this.inStackContext=!0;const l=this.parseStacking();return this.inStackContext=!1,l}case"m":case"M":if(this.scanner.peek()==="+"){this.scanner.consume(1);const l=(n=this.scanner.tail.match(/^[0-9A-Fa-f]{4}/))==null?void 0:n[0];if(l){this.scanner.consume(4);const c=this.decodeMultiByteChar(l);return a?[1,a]:[1,c]}this.scanner.consume(-1)}a+="\\M";continue;default:if(o)try{const l=this.parseProperties(o);if(this.yieldPropertyCommands&&l)return this.lastCtx=this.ctx.copy(),[9,l];continue}catch{const l=this.scanner.tail.slice(u,this.scanner.currentIndex);a+=l}}continue}if(i==="%"&&this.scanner.peek(1)==="%"){const o=this.scanner.peek(2).toLowerCase(),l=ll[o];if(l){this.scanner.consume(3),a+=l;continue}else{this.scanner.consume(3);continue}}if(i===" ")return a?(this.scanner.consume(1),e=3,[1,a]):(this.scanner.consume(1),[3,null]);if(!s){if(i==="{"){if(a)return[1,a];this.scanner.consume(1),this.pushCtx();continue}else if(i==="}"){if(a)return[1,a];this.scanner.consume(1),this.popCtx();continue}}if(!this.inStackContext&&i==="^"){const o=this.scanner.peek(1);if(o){const l=o.charCodeAt(0);if(this.scanner.consume(2),l===32)a+="^";else{if(l===73)return a?[1,a]:[5,null];if(l===74)return a?[1,a]:[6,null];if(l===77)continue;a+="▯"}continue}}this.scanner.consume(1),i.charCodeAt(0)>=32&&(a+=i)}return a?[1,a]:[0,null]};for(;;){const[n,a]=r();if(n)yield new la(n,this.ctx,a),e&&(yield new la(e,this.ctx,null),e=null);else break}}}class ur{constructor(e){this.text=e,this.textLen=e.length,this._index=0}get currentIndex(){return this._index}get isEmpty(){return this._index>=this.textLen}get hasData(){return this._index<this.textLen}get(){if(this.isEmpty)return"";const e=this.text[this._index];return this._index++,e}consume(e=1){this._index=Math.max(0,Math.min(this._index+e,this.textLen))}peek(e=0){const r=this._index+e;return r>=this.textLen||r<0?"":this.text[r]}find(e,r=!1){let n=this._index;for(;n<this.textLen;){if(r&&this.text[n]==="\\"){if(n+1<this.textLen){if(this.text[n+1]===e)return n+1;n+=2;continue}n++;continue}if(this.text[n]===e)return n;n++}return-1}get tail(){return this.text.slice(this._index)}isNextSpace(){return this.peek()===" "}consumeSpaces(){let e=0;for(;this.isNextSpace();)this.consume(),e++;return e}}class lr{constructor(e){this._aci=256,this._rgbValue=null,Array.isArray(e)?this.rgb=e:typeof e=="number"?this.aci=e:this.aci=256}get aci(){return this._aci}set aci(e){if(e===null)this._aci=null;else if(e>=0&&e<=256)this._aci=e,this._rgbValue=null;else throw new Error("ACI not in range [0, 256]")}get rgb(){if(this._rgbValue===null)return null;const e=this._rgbValue>>16&255,r=this._rgbValue>>8&255,n=this._rgbValue&255;return[e,r,n]}set rgb(e){if(e){const[r,n,a]=e;this._rgbValue=(r&255)<<16|(n&255)<<8|a&255,this._aci=null}else this._rgbValue=null}get isRgb(){return this._rgbValue!==null}get isAci(){return this._rgbValue===null&&this._aci!==null}get rgbValue(){return this._rgbValue}set rgbValue(e){e===null?this._rgbValue=null:(this._rgbValue=e&16777215,this._aci=null)}copy(){const e=new lr;return e._aci=this._aci,e._rgbValue=this._rgbValue,e}toObject(){return{aci:this._aci,rgb:this.rgb,rgbValue:this._rgbValue}}equals(e){return this._aci===e._aci&&this._rgbValue===e._rgbValue}}class mt{constructor(){this._stroke=0,this.continueStroke=!1,this.color=new lr,this.align=0,this.fontFace={family:"",style:"Regular",weight:400},this._capHeight={value:1,isRelative:!1},this._widthFactor={value:1,isRelative:!1},this._charTrackingFactor={value:1,isRelative:!1},this.oblique=0,this.paragraph={indent:0,left:0,right:0,align:0,tab_stops:[]}}get capHeight(){return this._capHeight}set capHeight(e){this._capHeight={value:Math.abs(e.value),isRelative:e.isRelative}}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get charTrackingFactor(){return this._charTrackingFactor}set charTrackingFactor(e){this._charTrackingFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get aci(){return this.color.aci}set aci(e){this.color.aci=e}get rgb(){return this.color.rgb}set rgb(e){this.color.rgb=e}get underline(){return!!(this._stroke&1)}set underline(e){this._setStrokeState(1,e)}get strikeThrough(){return!!(this._stroke&4)}set strikeThrough(e){this._setStrokeState(4,e)}get overline(){return!!(this._stroke&2)}set overline(e){this._setStrokeState(2,e)}get hasAnyStroke(){return!!this._stroke}_setStrokeState(e,r=!0){r?this._stroke|=e:this._stroke&=~e}copy(){const e=new mt;return e._stroke=this._stroke,e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e._capHeight={...this._capHeight},e._widthFactor={...this._widthFactor},e._charTrackingFactor={...this._charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e}}class la{constructor(e,r,n){this.type=e,this.ctx=r,this.data=n}}function ca(t,e=!1){const r=t[0].index!==null,n=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),s={},i={},u=t[0].morphTargetsRelative,o=new ge.BufferGeometry;let l=0;for(let c=0;c<t.length;++c){const p=t[c];let h=0;if(r!==(p.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in p.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(p.attributes[f]),h++}if(h!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(u!==p.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in p.morphAttributes){if(!a.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;i[f]===void 0&&(i[f]=[]),i[f].push(p.morphAttributes[f])}if(e){let f;if(r)f=p.index.count;else if(p.attributes.position!==void 0)f=p.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;o.addGroup(l,f,c),l+=f}}if(r){let c=0;const p=[];for(let h=0;h<t.length;++h){const f=t[h].index;for(let v=0;v<f.count;++v)p.push(f.getX(v)+c);c+=t[h].attributes.position.count}o.setIndex(p)}for(const c in s){const p=ha(s[c]);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;o.setAttribute(c,p)}for(const c in i){const p=i[c][0].length;if(p===0)break;o.morphAttributes=o.morphAttributes||{},o.morphAttributes[c]=[];for(let h=0;h<p;++h){const f=[];for(let y=0;y<i[c].length;++y)f.push(i[c][y][h]);const v=ha(f);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;o.morphAttributes[c].push(v)}}return o}function ha(t){let e,r,n,a=-1,s=0;for(let l=0;l<t.length;++l){const c=t[l];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(r===void 0&&(r=c.itemSize),r!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(a===-1&&(a=c.gpuType),a!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*r}const i=new e(s),u=new ge.BufferAttribute(i,r,n);let o=0;for(let l=0;l<t.length;++l){const c=t[l];if(c.isInterleavedBufferAttribute){const p=o/r;for(let h=0,f=c.count;h<f;h++)for(let v=0;v<r;v++){const y=c.getComponent(h,v);u.setComponent(h+p,v,y)}}else i.set(c.array,o);o+=c.count*r}return a!==void 0&&(u.gpuType=a),u}const fl=new A.Vector3,pl=1.666666;class dl{constructor(e,r,n,a){this._currentUnderline=!1,this._currentOverline=!1,this._currentStrikeThrough=!1,this._currentObliqueAngle=0,this._style=e,this._styleManager=r,this._fontManager=n,this._options=a,this._totalHeight=0,this._hOffset=0,this._vOffset=0,this._lineCount=1,this._currentLineObjects=[],this._currentHorizontalAlignment=a.horizontalAlignment,this._currentFont=this.textStyle.font.toLowerCase(),this._currentWidthFactor=a.widthFactor,this._currentWordSpace=1,this._currentColor=a.byLayerColor,this._currentFontSizeScaleFactor=1,this._currentMaxFontSize=0,this._currentObliqueAngle=e.obliqueAngle||0,this.initLineParams(),this._currentBlankWidth=this.calculateBlankWidth()}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get totalHeight(){return this._lineCount==1?this.currentMaxFontSize:this._totalHeight+this.currentLineHeight}get maxWidth(){return this._options.maxWidth}get flowDirection(){return this._options.flowDirection}get defaultHorizontalAlignment(){return this._options.horizontalAlignment}get defaultWidthFactor(){return this._options.widthFactor}get defaultFontSize(){return this._options.fontSize}get defaultLineSpaceFactor(){return this._options.lineSpaceFactor}get currentFont(){return this._currentFont}get currentHorizontalAlignment(){return this._currentHorizontalAlignment}get currentFontScaleFactor(){return this._currentFontScaleFactor}get currentFontSize(){return this._currentFontSize}get currentFontSizeScaleFactor(){return this._currentFontSizeScaleFactor}get currentLineHeight(){return this.defaultLineSpaceFactor*this._currentFontSize*pl+this.currentMaxFontSize}get currentMaxFontSize(){return this._currentMaxFontSize}get currentWordSpace(){return this._currentWordSpace}get currentWidthFactor(){return this._currentWidthFactor}get currentColor(){return this._currentColor}get currentLineObjects(){return this._currentLineObjects}get hOffset(){return this._hOffset}set hOffset(e){this._hOffset=e}get vOffset(){return this._vOffset}set vOffset(e){this._vOffset=e}get currentObliqueAngle(){return this._currentObliqueAngle}processFormat(e){switch(e.command){case"f":case"F":if(e.changes.fontFace){this.changeFont(e.changes.fontFace.family),this.currentFont&&this.currentFont.includes(".shx")&&console.log(`Doesn't support custom fonts: ${this.currentFont}`);break}case"c":case"C":e.changes.aci?e.changes.aci===0?this._currentColor=this._options.byBlockColor:e.changes.aci===256?this._currentColor=this._options.byLayerColor:this._currentColor=Ra(e.changes.aci):e.changes.rgb&&(this._currentColor=(e.changes.rgb[0]<<16)+(e.changes.rgb[1]<<8)+e.changes.rgb[2]);break;case"W":e.changes.widthFactor&&(e.changes.widthFactor.isRelative?this._currentWidthFactor=e.changes.widthFactor.value*this.maxWidth:this._currentWidthFactor=e.changes.widthFactor.value*.93);break;case"H":e.changes.capHeight&&(e.changes.capHeight.isRelative?this.changeFontSizeScaleFactor(e.changes.capHeight.value):this.changeFontHeight(e.changes.capHeight.value));break;case"T":e.changes.charTrackingFactor&&(e.changes.charTrackingFactor.isRelative?this._currentWordSpace=e.changes.charTrackingFactor.value:this._currentWordSpace=e.changes.charTrackingFactor.value);break;case"q":e.changes.paragraph&&e.changes.paragraph.align&&(this._currentHorizontalAlignment=e.changes.paragraph.align);break;case"L":this._currentUnderline=!0;break;case"l":this._currentUnderline=!1;break;case"O":this._currentOverline=!0;break;case"o":this._currentOverline=!1;break;case"K":this._currentStrikeThrough=!0;break;case"k":this._currentStrikeThrough=!1;break;case"Q":e.changes.oblique!==void 0&&(this._currentObliqueAngle=e.changes.oblique);break}}processText(e){const r=[],n=[],a=new A.Group;for(const s of e)if(s.type===He.NEW_PARAGRAPH)this.startNewLine(),this.processGeometries(r,n,a);else if(s.type===He.WORD){const i=s.data;Array.isArray(i)?i.forEach(u=>this.processWord(u,r,n)):typeof i=="string"&&i.length>0&&this.processWord(i,r,n),this.processGeometries(r,n,a)}else s.type===He.SPACE?this.processBlank():s.type===He.PROPERTIES_CHANGED?(this.processFormat(s.data),this.processGeometries(r,n,a)):s.type===He.STACK&&(this.processStack(s.data,r,n),this.processGeometries(r,n,a));return(r.length>0||n.length>0)&&this.processGeometries(r,n,a),a}processGeometries(e,r,n){if(e.length>0||r.length>0){const a=this.toThreeObject(e,r);n.add(a),e.length=0,r.length=0}}processWord(e,r,n){for(let a=0;a<e.length;a++)this.processChar(e[a],r,n)}processStack(e,r,n){const[a,s,i]=e,u=this._hOffset,o=this._vOffset,l=this._currentWordSpace,c=this._currentFontSize,p=this._currentFontSizeScaleFactor;this._hOffset=u,this._currentWordSpace=1;let h=0;for(let b=0;b<a.length;b++){const k=this.getCharShape(a[b]);k&&(h+=k.width*this.currentWidthFactor)}this._hOffset=u;let f=0;for(let b=0;b<s.length;b++){const k=this.getCharShape(s[b]);k&&(f+=k.width*this.currentWidthFactor)}const v=Math.max(h,f),y=(v-h)/2,m=(v-f)/2;if(i==="^"){if(this._currentFontSizeScaleFactor=p*.7,this.calcuateLineParams(),a&&!s){const b=[],k=[];this._hOffset=u,this._vOffset=o+c*.1;for(let x=0;x<a.length;x++)this.processChar(a[x],b,k);r.push(...b),n.push(...k),this._hOffset=u+h}else if(!a&&s){const b=[],k=[];this._hOffset=u,this._vOffset=o-c*.3;for(let x=0;x<s.length;x++)this.processChar(s[x],b,k);r.push(...b),n.push(...k),this._hOffset=u+f}this._currentFontSizeScaleFactor=p,this.calcuateLineParams()}else{const b=[],k=[];this._hOffset=u+y,this._vOffset=o+this.currentFontSize*.3;for(let C=0;C<a.length;C++)this.processChar(a[C],b,k);r.push(...b),n.push(...k);const x=[],L=[];this._hOffset=u+m,this._vOffset=o-this.currentFontSize*.6;for(let C=0;C<s.length;C++)this.processChar(s[C],x,L);if(r.push(...x),n.push(...L),i==="/"||i==="#"){const C=new A.BufferGeometry,M=new Float32Array([u,o-this.currentFontSize*.8,0,u+v,o-this.currentFontSize*.8,0]);C.setAttribute("position",new A.BufferAttribute(M,3)),C.setIndex(null),n.push(C)}this._hOffset=u+v}this._vOffset=o,this._currentWordSpace=l}processBlank(){this._hOffset+=this._currentBlankWidth}processChar(e,r,n){const a=this.getCharShape(e);if(!a){this.processBlank();return}const s=a.toGeometry();if(s.scale(this.currentWidthFactor,1,1),this.currentObliqueAngle){const h=this.currentObliqueAngle*Math.PI/180,f=new A.Matrix4;f.set(1,Math.tan(h),0,0,0,1,0,0,0,0,1,0,0,0,0,1),s.applyMatrix4(f)}this.hOffset>(this.maxWidth||1/0)&&this.startNewLine();let i=this.hOffset,u=this.flowDirection==_e.BOTTOM_TO_TOP?this.vOffset:this.vOffset-this.currentFontSize,o=a.width*this.currentWidthFactor,l=this.currentFontSize;s.translate(i,u,0),this.currentHorizontalAlignment==ve.DISTRIBUTED?this._hOffset+=a.width*this.currentWidthFactor:this._hOffset+=a.width*this.currentWordSpace*this.currentWidthFactor,r.push(s);const c=l*.05,p=.001;if(this._currentUnderline){const h=new A.BufferGeometry,f=u-c;h.setAttribute("position",new A.BufferAttribute(new Float32Array([i,f,p,i+o,f,p]),3)),h.setIndex(null),n.push(h)}if(this._currentOverline){const h=new A.BufferGeometry,f=u+l+c;h.setAttribute("position",new A.BufferAttribute(new Float32Array([i,f,p,i+o,f,p]),3)),h.setIndex(null),n.push(h)}if(this._currentStrikeThrough){const h=new A.BufferGeometry,f=u+l/2;h.setAttribute("position",new A.BufferAttribute(new Float32Array([i,f,p,i+o,f,p]),3)),h.setIndex(null),n.push(h)}}processLastLine(){this.processAlignment()}initLineParams(){this.calcuateLineParams()}changeFontHeight(e){this.calcuateLineParams(e)}changeFont(e){let r=e;this._options.removeFontExtension&&(r=e.replace(/\.(ttf|otf|woff|shx)$/,"")),this._currentFont=this.fontManager.findAndReplaceFont(r),this._currentBlankWidth=this.calculateBlankWidth(),this.calcuateLineParams()}changeFontSizeScaleFactor(e){this._currentFontSizeScaleFactor*=e,this.calcuateLineParams()}calcuateLineParams(e){this._currentFontScaleFactor=this.fontManager.getFontScaleFactor(this.currentFont);const r=e||this.defaultFontSize||this.textStyle.fixedTextHeight;this._currentFontSize=r*this.currentFontScaleFactor*this.currentFontSizeScaleFactor}getCharShape(e){let r=this.fontManager.getCharShape(e,this.currentFont,this.currentFontSize);return this.textStyle.bigFont&&!r&&(r=this.fontManager.getCharShape(e,this.textStyle.bigFont,this.currentFontSize)),r||(r=this.fontManager.getCharShape(e,"",this.currentFontSize)),r||(r=this.fontManager.getNotFoundTextShape(this.currentFontSize)),this.currentFontSize>this.currentMaxFontSize&&(this._currentMaxFontSize=this.currentFontSize),r}startNewLine(){this._hOffset=0,this.flowDirection==_e.BOTTOM_TO_TOP?this._vOffset+=this.currentLineHeight:this._vOffset-=this.currentLineHeight,this._lineCount++,this.processAlignment(),this._currentLineObjects=[],this._lineCount==2?this._totalHeight=this.currentMaxFontSize:this._totalHeight=this._totalHeight+this.currentLineHeight}processAlignment(){const e=[];if(this.currentLineObjects.forEach(n=>n.traverse(a=>{"geometry"in a&&e.push(a.geometry)})),e.length==0)return;let r;if(e.forEach((n,a)=>{n.boundingBox||n.computeBoundingBox(),a===0?r=n.boundingBox:r.union(n.boundingBox)}),r){const n=r.getSize(fl);switch(this.currentHorizontalAlignment){case ve.LEFT:break;case ve.CENTER:e.forEach(a=>a.translate((this.maxWidth-n.x)/2,0,0));break;case ve.RIGHT:e.forEach(a=>a.translate(this.maxWidth-n.x,0,0));break;case ve.DISTRIBUTED:if(e.length>1){const a=(this.maxWidth-n.x)/(e.length-1);for(let s=1;s<e.length;s++)e[s].translate(a*s,0,0)}break}}}calculateBlankWidth(){return this.fontManager.getFontType(this.currentFont)==="shx"?this.currentFontSize*.5:this.currentFontSize*.3}toThreeObject(e,r){const n=new A.Group,a=this.currentColor,s=e.filter(u=>u instanceof A.ExtrudeGeometry);if(s.length>0){const u=new A.Mesh;u.geometry=ca(s),u.material=this.styleManager.getMeshBasicMaterial(a),u.userData.bboxIntersectionCheck=!0,n.add(u)}const i=[...r,...e.filter(u=>!(u instanceof A.ExtrudeGeometry))];if(i.length>0){const u=new A.LineSegments;u.geometry=ca(i),u.material=this.styleManager.getLineBasicMaterial(a),u.userData.bboxIntersectionCheck=!0,n.add(u)}return n.children.length===1?n.children[0]:n}}const cr=new A.Vector3,De=new A.Vector3,hr=new A.Vector3,fr=new A.Quaternion,pr=new A.Matrix4,fa=new A.Matrix4,pa=new A.Vector3(1,0,0);class vl extends A.Object3D{constructor(e,r,n,a,s={byLayerColor:16777215,byBlockColor:16777215}){super(),this._style=r,this._styleManager=n,this._fontManager=a,this._colorSettings={byLayerColor:s.byLayerColor,byBlockColor:s.byBlockColor},this._box=new A.Box3,this._boxes=[];const i=this.loadMText(e,r);i&&(this.getBoxes(i,this._boxes),this._boxes.forEach(u=>this.box.union(u)),this.add(i))}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get box(){return this._box}set box(e){this._box.copy(e)}raycast(e,r){this._boxes.forEach(n=>{if(e.ray.intersectBox(n,cr)){const a=e.ray.origin.distanceTo(cr);r.push({distance:a,point:cr.clone(),object:this,face:null,faceIndex:void 0,uv:void 0})}})}loadMText(e,r){const{object:n,height:a}=this.createMTextGroup(e,r);if(!n)return;n.matrix.decompose(De,fr,hr),e.position&&(De.x+=e.position.x,De.y+=e.position.y,n.matrix.compose(De,fr,hr));const s=e.width,i=this.calculateAnchorPoint(s,a,e.attachmentPoint,e.drawingDirection);n.traverse(l=>{"geometry"in l&&l.geometry.translate(i.x,i.y,0),l.layers.enableAll()});let u=e.rotation||0;if(e.directionVector){const l=e.directionVector,c=new A.Vector3(l.x,l.y,l.z),p=c.clone().cross(pa),h=pa.angleTo(c);u=p.z>0?-h:h}n.matrix.compose(De,fr,hr);const o=e.position?De.clone().sub(e.position):De;return pr.makeTranslation(-o.x,-o.y,0),fa.makeRotationZ(u),n.matrix.multiply(pr),n.matrix.multiply(fa),n.matrix.multiply(pr.invert()),n.matrix.decompose(n.position,n.quaternion,n.scale),n}createMTextGroup(e,r){if(r&&r.font&&r.font.endsWith(".shx")){const y=`${r.font}_${r.name}`;this.styleManager.unsupportedTextStyles[y]||(this.styleManager.unsupportedTextStyles[y]=0),this.styleManager.unsupportedTextStyles[y]++}const n=e.width||0;let a=ve.LEFT;e.width&&e.attachmentPoint&&([1,4,7].includes(e.attachmentPoint)?a=ve.LEFT:[2,5,8].includes(e.attachmentPoint)?a=ve.CENTER:[3,6,9].includes(e.attachmentPoint)&&(a=ve.RIGHT));let s=tt.BOTTOM;e.attachmentPoint&&([1,2,3].includes(e.attachmentPoint)?s=tt.TOP:[4,5,6].includes(e.attachmentPoint)?s=tt.MIDDLE:[7,8,9].includes(e.attachmentPoint)&&(s=tt.BOTTOM));const i=e.height||0,u=e.lineSpaceFactor||.3,o=e.drawingDirection??_e.LEFT_TO_RIGHT,l={fontSize:i,widthFactor:e.widthFactor??1,lineSpaceFactor:u,horizontalAlignment:a,maxWidth:n,flowDirection:o,byBlockColor:this._colorSettings.byBlockColor,byLayerColor:this._colorSettings.byLayerColor,removeFontExtension:!0},c=new mt;c.fontFace.family=r.font,c.capHeight={value:e.height||1,isRelative:!0},c.widthFactor={value:e.widthFactor??1,isRelative:!0},c.align=s,c.paragraph.align=a;const h=new hl(e.text,c,!0).parse(),f=new dl(r,this.styleManager,this.fontManager,l),v=f.processText(h);return f.processLastLine(),{object:v,height:f.totalHeight}}calculateAnchorPoint(e,r,n,a){let s=0,i=0;switch(n){case void 0:case 1:s=0,i=0;break;case 2:s-=e/2,i=0;break;case 3:s-=e,i=0;break;case 4:s=0,i+=r/2;break;case 5:s-=e/2,i+=r/2;break;case 6:s-=e,i+=r/2;break;case 7:s=0,i+=r;break;case 8:s-=e/2,i+=r;break;case 9:s-=e,i+=r;break}return a==_e.BOTTOM_TO_TOP&&(i-=r),{x:s,y:i}}getBoxes(e,r){if(e.updateWorldMatrix(!1,!1),e instanceof A.Line||e instanceof A.Mesh){const a=e.geometry;a.boundingBox===null&&a.computeBoundingBox();const s=new A.Box3().copy(a.boundingBox);s.applyMatrix4(e.matrixWorld),r.push(s)}const n=e.children;for(let a=0,s=n.length;a<s;a++)this.getBoxes(n[a],r)}}class gl{constructor(){this.lineBasicMaterials={},this.meshBasicMaterials={},this.unsupportedTextStyles={}}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new A.MeshBasicMaterial({color:e})),this.meshBasicMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new A.LineBasicMaterial({color:e})),this.lineBasicMaterials[e]}}g.BaseFont=St,g.BaseTextShape=kt,g.DefaultFontLoader=ul,g.EventManager=xt,g.FontFactory=be,g.FontManager=Ae,g.MText=vl,g.MTextAttachmentPoint=ua,g.MTextFlowDirection=_e,g.StyleManager=gl,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/mtext-renderer",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "AutoCAD MText renderer based on Three.js",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",