/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) * @license MIT * * Originally forked from (with the author's permission): * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard */ /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ var Bp=Object.create;var ir=Object.defineProperty;var _p=Object.getOwnPropertyDescriptor;var Gp=Object.getOwnPropertyNames;var Hp=Object.getPrototypeOf,Vp=Object.prototype.hasOwnProperty;var ki=g=>{throw TypeError(g)};var zp=(g,f,p)=>f in g?ir(g,f,{enumerable:!0,configurable:!0,writable:!0,value:p}):g[f]=p;var jp=(g,f)=>()=>(f||g((f={exports:{}}).exports,f),f.exports);var Wp=(g,f,p,h)=>{if(f&&typeof f=="object"||typeof f=="function")for(let y of Gp(f))!Vp.call(g,y)&&y!==p&&ir(g,y,{get:()=>f[y],enumerable:!(h=_p(f,y))||h.enumerable});return g};var qp=(g,f,p)=>(p=g!=null?Bp(Hp(g)):{},Wp(f||!g||!g.__esModule?ir(p,"default",{value:g,enumerable:!0}):p,g));var ye=(g,f,p)=>zp(g,typeof f!="symbol"?f+"":f,p),ar=(g,f,p)=>f.has(g)||ki("Cannot "+p);var b=(g,f,p)=>(ar(g,f,"read from private field"),p?p.call(g):f.get(g)),K=(g,f,p)=>f.has(g)?ki("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(g):f.set(g,p),V=(g,f,p,h)=>(ar(g,f,"write to private field"),h?h.call(g,p):f.set(g,p),p),R=(g,f,p)=>(ar(g,f,"access private method"),p);var vs=(g,f,p,h)=>({set _(y){V(g,f,y,p)},get _(){return b(g,f,h)}});var Oi=jp((Ci,xs)=>{var Ti=(()=>{var g=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,y=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!h.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(s=f(t,r))||s.enumerable});return e},T=e=>k(g({},"__esModule",{value:!0}),e),O={};y(O,{BoundingBox:()=>ws,Font:()=>yi,Glyph:()=>fn,Path:()=>Wt,_parse:()=>F,load:()=>Mp,loadSync:()=>Pp,parse:()=>Up});var w=0,E=-3;function j(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function H(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new j,this.dtree=new j}var Q=new j,X=new j,fe=new Uint8Array(30),J=new Uint16Array(30),Se=new Uint8Array(30),$=new Uint16Array(30),ee=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ne=new j,se=new Uint8Array(320);function pe(e,t,n,s){var r,o;for(r=0;r>>=1,t}function Be(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,s+n}function zt(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++r,n+=t.table[r],s-=t.table[r];while(s>=0);return e.tag=o,e.bitcount-=r,t.trans[n+s]}function Wi(e,t,n){var s,r,o,i,a,l;for(s=Be(e,5,257),r=Be(e,5,1),o=Be(e,4,4),i=0;i<19;++i)se[i]=0;for(i=0;i8;)e.sourceIndex--,e.bitcount-=8;if(t=e.source[e.sourceIndex+1],t=256*t+e.source[e.sourceIndex],n=e.source[e.sourceIndex+3],n=256*n+e.source[e.sourceIndex+2],t!==(~n&65535))return E;for(e.sourceIndex+=4,s=t;s;--s)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,w}function Er(e,t){var n=new H(e,t),s,r,o;do{switch(s=wt(n),r=Be(n,2,0),r){case 0:o=qi(n);break;case 1:o=wr(n,Q,X);break;case 2:Wi(n,n.ltree,n.dtree),o=wr(n,n.ltree,n.dtree);break;default:o=E}if(o!==w)throw new Error("Data error")}while(!s);return n.destLenthis.x2&&(this.x2=e)),typeof t=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},jt.prototype.addX=function(e){this.addPoint(e,null)},jt.prototype.addY=function(e){this.addPoint(null,e)},jt.prototype.addBezier=function(e,t,n,s,r,o,i,a){let l=[e,t],c=[n,s],u=[r,o],m=[i,a];this.addPoint(e,t),this.addPoint(i,a);for(let d=0;d<=1;d++){let x=6*l[d]-12*c[d]+6*u[d],v=-3*l[d]+9*c[d]-9*u[d]+3*m[d],S=3*c[d]-3*l[d];if(v===0){if(x===0)continue;let z=-S/x;01||Math.abs(i.y-s)>1||o.pop():i.type==="L"&&c&&c.x===i.x&&c.y===i.y?o.pop():i.type==="Z"&&(a&&l&&c&&a.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===a.x&&c.y===a.y&&(o.shift(),o[0].type="M"),r+1S.length).map(S=>{let I=parseFloat(S);return(t.decimalPlaces||t.decimalPlaces===0)&&(I=Lr(I,t.decimalPlaces)),I})}function u(v){if(!this.commands.length)return v;let S=this.commands[this.commands.length-1];for(let I=0;I-1)a[a.length-1]+=S;else if(o.indexOf(S)>-1)if(!i.type&&!this.commands.length&&(i.type="L"),S==="-")!i.type||I.indexOf("-")>0?l=!0:I.length?a.push("-"):a[a.length-1]=S;else if(!i.type||I.length>0)l=!0;else continue;else if(s.indexOf(S)>-1)i.type?(m.apply(this),i={type:S}):i.type=S;else{if(r.indexOf(S)>-1)throw new Error("Unsupported path command: "+S+". Currently supported commands are "+s.split("").join(", ")+".");` , \r\f\v`.indexOf(S)>-1?a.push(""):S==="."?!i.type||I.indexOf(S)>-1?l=!0:a[a.length-1]+=S:l=!0}if(l)throw new Error("Unexpected character: "+S+" at offset "+v)}m.apply(this),t.optimize&&(this.commands=Ar(this.commands));let d=t.flipY,x=t.flipYBase;if(d===!0&&t.flipYBase===void 0){let v=this.getBoundingBox();x=v.y1+v.y2}for(let v in this.commands){let S=this.commands[v];for(let I in S)["x","x1","x2"].includes(I)?this.commands[v][I]=t.x+S[I]*t.scale:["y","y1","y2"].includes(I)&&(this.commands[v][I]=t.y+(d?x-S[I]:S[I])*t.scale)}return this},ve.fromSVG=function(e,t){return new ve().fromSVG(e,t)},ve.prototype.moveTo=function(e,t){this.commands.push({type:"M",x:e,y:t})},ve.prototype.lineTo=function(e,t){this.commands.push({type:"L",x:e,y:t})},ve.prototype.curveTo=ve.prototype.bezierCurveTo=function(e,t,n,s,r,o){this.commands.push({type:"C",x1:e,y1:t,x2:n,y2:s,x:r,y:o})},ve.prototype.quadTo=ve.prototype.quadraticCurveTo=function(e,t,n,s){this.commands.push({type:"Q",x1:e,y1:t,x:n,y:s})},ve.prototype.close=ve.prototype.closePath=function(){this.commands.push({type:"Z"})},ve.prototype.extend=function(e){if(e.commands)e=e.commands;else if(e instanceof ws){let t=e;this.moveTo(t.x1,t.y1),this.lineTo(t.x2,t.y1),this.lineTo(t.x2,t.y2),this.lineTo(t.x1,t.y2),this.close();return}Array.prototype.push.apply(this.commands,e)},ve.prototype.getBoundingBox=function(){let e=new ws,t=0,n=0,s=0,r=0;for(let o=0;o=0&&l>0&&(a+=" "),a+=t(c)}return a}let s=this.commands;e.optimize&&(s=JSON.parse(JSON.stringify(this.commands)),s=Ar(s));let r=e.flipY,o=e.flipYBase;if(r===!0&&o===void 0){let a=new ve;a.extend(s);let l=a.getBoundingBox();o=l.y1+l.y2}let i="";for(let a=0;a=0&&e<=255,"Byte value should be between 0 and 255."),[e]},W.BYTE=tt(1),D.CHAR=function(e){return[e.charCodeAt(0)]},W.CHAR=tt(1),D.CHARARRAY=function(e){(e===null||typeof e>"u")&&(e="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let t=[];for(let n=0;n"u"?0:e.length},D.USHORT=function(e){return[e>>8&255,e&255]},W.USHORT=tt(2),D.SHORT=function(e){return e>=Fr&&(e=-(2*Fr-e)),[e>>8&255,e&255]},W.SHORT=tt(2),D.UINT24=function(e){return[e>>16&255,e>>8&255,e&255]},W.UINT24=tt(3),D.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]},W.ULONG=tt(4),D.LONG=function(e){return e>=Ur&&(e=-(2*Ur-e)),[e>>24&255,e>>16&255,e>>8&255,e&255]},W.LONG=tt(4),D.FLOAT=function(e){if(e>Zi||e>24&255,e>>16&255,e>>8&255,e&255]},W.LONGDATETIME=tt(8),D.TAG=function(e){return B.argument(e.length===4,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},W.TAG=tt(4),D.Card8=D.BYTE,W.Card8=W.BYTE,D.Card16=D.USHORT,W.Card16=W.USHORT,D.OffSize=D.BYTE,W.OffSize=W.BYTE,D.SID=D.USHORT,W.SID=W.USHORT,D.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?(e=e-108,[(e>>8)+247,e&255]):e>=-1131&&e<=-108?(e=-e-108,[(e>>8)+251,e&255]):e>=-32768&&e<=32767?D.NUMBER16(e):D.NUMBER32(e)},W.NUMBER=function(e){return D.NUMBER(e).length},D.NUMBER16=function(e){return[28,e>>8&255,e&255]},W.NUMBER16=tt(3),D.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,e&255]},W.NUMBER32=tt(5),D.REAL=function(e){let t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){let o=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*o)/o).toString()}let s="";for(let o=0,i=t.length;o>8&255,t[t.length]=s&255}return t},W.UTF16=function(e){return e.length*2};var jn={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};an.MACSTRING=function(e,t,n,s){let r=jn[s];if(r===void 0)return;let o="";for(let i=0;i=128&&(o=n[o],o===void 0))return;s[r]=o}return s},W.MACSTRING=function(e,t){let n=D.MACSTRING(e,t);return n!==void 0?n.length:0};function Es(e){return e>=-128&&e<=127}function Qi(e,t,n){let s=0,r=e.length;for(;t>8&255,a+256&255)}return o}D.VARDELTAS=function(e){let t=0,n=[];for(;t=-128&&s<=127?t=Ji(e,t,n):t=ea(e,t,n)}return n},D.INDEX=function(e){let t=1,n=[t],s=[];for(let a=0;a>8,t[i+1]=a&255;for(let l=0;l0)return new C(this.data,this.offset+t).parseStruct(e)},C.prototype.parsePointer32=function(e){let t=this.parseOffset32();if(t>0)return new C(this.data,this.offset+t).parseStruct(e)},C.prototype.parseListOfLists=function(e){let t=this.parseOffset16List(),n=t.length,s=this.relativeOffset,r=new Array(n);for(let o=0;o>4)+1;for(let i=0;i>r,c=a&(1<[]),r=t&Ie.LONG_WORDS,o=t&Ie.WORD_DELTA_COUNT_MASK;if(o>n)throw Error("wordCount must be less than or equal to regionIndexCount");let i=(r?this.parseLong:this.parseShort).bind(this),a=(r?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let Y,re,ie=()=>{let ae=0;if(n==="gvar"){if(ae=S.privatePoints.length||m.length,!ae){let me=s.get(r);me.path,ae=me.points.length,ae+=4}}else n==="cvar"&&(ae=s.length);this.offset=I,this.relativeOffset=_,Y=this.parsePackedDeltas(ae),n==="gvar"&&(re=this.parsePackedDeltas(ae))};return{configurable:!0,get:function(){return Y===void 0&&ie(),z==="deltasY"?re:Y},set:function(ae){Y===void 0&&ie(),z==="deltasY"?re=ae:Y=ae}}};Object.defineProperty(S,"deltas",P.call(this,"deltas")),n==="gvar"&&Object.defineProperty(S,"deltasY",P.call(this,"deltasY")),d+=S.variationDataSize,delete S.variationDataSize}this.relativeOffset=o;let x={headers:u};return x.sharedPoints=m,x},C.prototype.parseTupleVariationHeader=function(e,t){let n=this.parseUShort(),s=this.parseUShort(),r=!!(s&Ie.EMBEDDED_PEAK_TUPLE),o=!!(s&Ie.INTERMEDIATE_REGION),i=!!(s&Ie.PRIVATE_POINT_NUMBERS),a=r?void 0:s&Ie.TUPLE_INDEX_MASK,l=r?this.parseTupleRecords(1,e)[0]:void 0,c=o?this.parseTupleRecords(1,e)[0]:void 0,u=o?this.parseTupleRecords(1,e)[0]:void 0,m={variationDataSize:n,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:r,intermediateRegion:o,privatePointNumbers:i}};return t==="gvar"&&(m.sharedTupleRecordsIndex=a),m},C.prototype.parsePackedPointNumbers=function(){let e=this.parseByte(),t=[],n=e;if(e>=128){let r=this.parseByte();n=(e&Ie.POINT_RUN_COUNT_MASK)<<8|r}let s=0;for(;t.length>1,t.skip("uShort",3),e.glyphIndexMap={};let i=new F.Parser(n,s+r+14),a=new F.Parser(n,s+r+16+o*2),l=new F.Parser(n,s+r+16+o*4),c=new F.Parser(n,s+r+16+o*6),u=s+r+16+o*8;for(let m=0;m=0;m-=1)if(i=F.getUShort(e,t+4+m*8),a=F.getUShort(e,t+4+m*8+2),i===3&&c.includes(a)||i===0&&l.includes(a)||i===1&&a===0){if(o>0)continue;if(o=F.getULong(e,t+4+m*8+4),s)break}else if(i===0&&a===5){if(r=F.getULong(e,t+4+m*8+4),s=new F.Parser(e,t+r),s.parseUShort()!==14)r=-1,s=null;else if(o>0)break}if(o===-1)throw new Error("No valid cmap sub-tables found.");let u=new F.Parser(e,t+o);if(n.format=u.parseUShort(),n.format===0)ma(n,u,i,a);else if(n.format===12||n.format===13)ya(n,u,n.format);else if(n.format===4)ba(n,u,e,t,o);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+n.format+", platformId "+i+", encodingId "+a+").");return s&&va(n,s),n}function Sa(e,t,n){e.segments.push({end:t,start:t,delta:-(t-n),offset:0,glyphIndex:n})}function ka(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function Ta(e){if(e.length===0)return e;let t=[e[0]];for(let n=1;n0;n-=1)if(e.get(n).unicode>65535){t=!1;break}let s=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:t?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:t?12:20}];t||s.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),s.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let r=new A.Table("cmap",s);for(r.segments=[],n=0;n1&&B.argument(t,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new A.Table("CPAL",[{name:"version",type:"USHORT",value:e},{name:"numPaletteEntries",type:"USHORT",value:t||n.length},{name:"numPalettes",type:"USHORT",value:s.length},{name:"numColorRecords",type:"USHORT",value:n.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*s.length},...s.map((r,o)=>({name:"colorRecordIndices_"+o,type:"USHORT",value:r})),...n.map((r,o)=>({name:"colorRecords_"+o,type:"ULONG",value:r}))])}function Yr(e){var t=(e&4278190080)>>24,n=(e&16711680)>>16,s=(e&65280)>>8,r=e&255;return t=t+256&255,n=n+256&255,s=s+256&255,r=(r+256&255)/255,{b:t,g:n,r:s,a:r}}function Ms(e,t,n=0,s="hexa"){if(t==65535)return"currentColor";let r=e&&e.tables&&e.tables.cpal;if(!r)return"currentColor";if(n>r.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${r.colorRecordIndices.length}, index: ${t})`);if(t>r.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${r.numPaletteEntries}, index: ${t})`);let o=r.colorRecordIndices[n]+t;if(o>r.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${r.colorRecords.length}, lookupIndex: ${o})`);let i=Yr(r.colorRecords[o]);return s==="bgra"?i:cn(i,s)}function nt(e){return("0"+parseInt(e).toString(16)).slice(-2)}function Ma(e){let t=e.r/255,n=e.g/255,s=e.b/255,r=Math.max(t,n,s),o=Math.min(t,n,s),i,a,l=(r+o)/2;if(r===o)i=a=0;else{let c=r-o;switch(a=l>.5?c/(2-r-o):c/(r+o),r){case t:i=(n-s)/c+(ntypeof a<"u");e={r:Math.round(parseFloat(i[1])/(i[2]?.39215686274509803:1)),g:Math.round(parseFloat(i[3])/(i[4]?.39215686274509803:1)),b:Math.round(parseFloat(i[5])/(i[6]?.39215686274509803:1)),a:i[7]?parseFloat(i[7])/(i[8]?100:1):1}}else{let i=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(i.test(e)){let a=e.match(i).filter(l=>typeof l<"u");e=Pa({h:parseFloat(a[1])*(a[2]==="turn"?360:1),s:parseFloat(a[3]),l:parseFloat(a[4]),a:a[5]?parseFloat(a[5])/(a[6]?100:1):1})}else r=!1}}if(!r)throw new Error(`Invalid color format: ${e}`);return cn(e,t)}function cn(e,t="hexa"){if(e==="currentColor")return e;if(Number.isInteger(e)){if(t=="raw"||t=="cpal")return e;e=Yr(e)}else typeof e!="object"&&(e=rs(e,"bgra"));let n=["hsl","hsla"].includes(t)?Ma(e):null;switch(t){case"rgba":return`rgba(${e.r}, ${e.g}, ${e.b}, ${parseFloat(e.a.toFixed(3))})`;case"rgb":return`rgb(${e.r}, ${e.g}, ${e.b})`;case"hex":case"hex6":case"hex-6":return`#${nt(e.r)}${nt(e.g)}${nt(e.b)}`;case"hexa":case"hex8":case"hex-8":return`#${nt(e.r)}${nt(e.g)}${nt(e.b)}${nt(e.a*255)}`;case"hsl":return`hsl(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%)`;case"hsla":return`hsla(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%, ${parseFloat(e.a.toFixed(3))})`;case"bgra":return e;case"raw":case"cpal":return Zr(e);default:throw new Error("Unknown color format: "+t)}}var Kr={parse:Fa,make:Ua,getPaletteColor:Ms,parseColor:rs,formatColor:cn};function Na(e,t){let n=t||new Wt;return{configurable:!0,get:function(){return typeof n=="function"&&(n=n()),n},set:function(s){n=s}}}function we(e){this.bindConstructorValues(e)}we.prototype.bindConstructorValues=function(e){if(this.index=e.index||0,e.name===".notdef"?e.unicode=void 0:e.name===".null"&&(e.unicode=0),e.unicode===0&&e.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=e.name||null,this.unicode=e.unicode,this.unicodes=e.unicodes||(e.unicode!==void 0?[e.unicode]:[]),"xMin"in e&&(this.xMin=e.xMin),"yMin"in e&&(this.yMin=e.yMin),"xMax"in e&&(this.xMax=e.xMax),"yMax"in e&&(this.yMax=e.yMax),"advanceWidth"in e&&(this.advanceWidth=e.advanceWidth),"leftSideBearing"in e&&(this.leftSideBearing=e.leftSideBearing),"points"in e&&(this.points=e.points),Object.defineProperty(this,"path",Na(this,e.path))},we.prototype.addUnicode=function(e){this.unicodes.length===0&&(this.unicode=e),this.unicodes.push(e)},we.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},we.prototype.getPath=function(e,t,n,s,r){e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:72,s=Object.assign({},r&&r.defaultRenderOptions,s);let o,i,a=s.xScale,l=s.yScale,c=1/(this.path.unitsPerEm||1e3)*n,u=this;r&&r.variation&&(u=r.variation.getTransform(this,s.variation),o=u.path.commands),s.hinting&&r&&r.hinting&&(i=u.path&&r.hinting.exec(u,n,s)),i?(o=r.hinting.getCommands(i),e=Math.round(e),t=Math.round(t),a=l=1):(o=u.path.commands,a===void 0&&(a=c),l===void 0&&(l=c));let m=new Wt;if(s.drawSVG){let d=this.getSvgImage(r);if(d){let x=new Wt;return x._image={image:d.image,x:e+d.leftSideBearing*c,y:t-d.baseline*c,width:d.image.width*c,height:d.image.height*c},m._layers=[x],m}}if(s.drawLayers){let d=this.getLayers(r);if(d&&d.length){m._layers=[];for(let x=0;x"u"&&e.path,e[n]},set:function(s){e[n]=s},enumerable:!0,configurable:!0})}function os(e,t){if(this.font=e,this.glyphs={},Array.isArray(t))for(let n=0;n=this.length-1;return{value:this.get(e),done:t}}.bind(this)}}),os.prototype.get=function(e){if(this.font._push&&this.glyphs[e]===void 0){this.font._push(e),typeof this.glyphs[e]=="function"&&(this.glyphs[e]=this.glyphs[e]());let t=this.glyphs[e],n=this.font._IndexToUnicodeMap[e];if(n)for(let s=0;s1?F.getULong(e,t):F.getCard16(e,t),a=s>1?4:2,l,c;if(i!==0){let u=F.getByte(e,t+a);l=t+(i+1)*u+a;let m=t+a+1;for(let d=0;d1?F.getULong(e,t):F.getCard16(e,t),o=n>1?4:2,i,a;if(r!==0){let l=F.getByte(e,t+o);i=t+(r+1)*l+o;let c=t+o+1;for(let u=0;u1?F.getULong(n,s):F.getCard16(n,s),a=o>1?4:2,l=0;if(i!==0){let u=F.getByte(n,s+a);l=s+(i+1)*u+a}let c=F.getBytes(n,l+t[e],l+t[e+1]);return r&&(c=r(c)),c}function za(e){let t="",s=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let r=e.parseByte(),o=r>>4,i=r&15;if(o===15||(t+=s[o],i===15))break;t+=s[i]}return parseFloat(t)}function ja(e,t){let n,s,r,o;if(t===28)return n=e.parseByte(),s=e.parseByte(),n<<8|s;if(t===29)return n=e.parseByte(),s=e.parseByte(),r=e.parseByte(),o=e.parseByte(),n<<24|s<<16|r<<8|o;if(t===30)return za(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return n=e.parseByte(),(t-247)*256+n+108;if(t>=251&&t<=254)return n=e.parseByte(),-(t-251)*256-n-108;throw new Error("Invalid b0 "+t)}function Wa(e){let t={};for(let n=0;n1&&l===23){Ja(i);continue}o.push([l,i]),i=[]}else i.push(ja(r,l,s))}return Wa(o)}function wn(e,t){return t<=390?t=ss[t]:e?t=e[t-391]:t=void 0,t}function Ns(e,t,n){let s={},r;for(let o=0;o2)throw new Error(`Unsupported CFF table version ${n.formatMajor}.${n.formatMinor}`);return n.size=F.getCard8(e,t+2),n.formatMajor<2?(n.offsetSize=F.getCard8(e,t+3),n.startOffset=t,n.endOffset=t+4):(n.topDictLength=F.getCard16(e,t+3),n.endOffset=t+8),n}var eo=[{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"}],to=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],no=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],so=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],$a=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Xa(e,t,n,s){let r=Ps(e,t,e.byteLength,s);return Ns(r,s>1?to:eo,n)}function Bs(e,t,n,s,r){let o=Ps(e,t,n,r);return Ns(o,r>1?so:no,s)}function Ya(e,t,n){let s=Ps(e,t,void 0,n);return Ns(s,$a)}function Za(e,t,n){let s=[];for(let r=0;rt;)e.pop()}function ro(e,t){let n=e.tables.cff&&e.tables.cff.topDict&&e.tables.cff.topDict.paintType||0;return n===2&&(t.fill=null,t.stroke="black",t.strokeWidth=e.tables.cff.topDict.strokeWidth||0),n}function Gs(e,t,n,s,r){let o,i,a,l,c=new Wt,u=[],m=0,d=!1,x=!1,v=0,S=0,I,_,P,z,Y=0,re=[],ie,ae=0,me=e.tables.cff2||e.tables.cff;if(P=me.topDict._defaultWidthX,z=me.topDict._nominalWidthX,r=r||e.variation&&e.variation.get(),t.getBlendPath||(t.getBlendPath=function(U){return Gs(e,t,n,s,U)}),e.isCIDFont||s>1){let U=me.topDict._fdSelect?me.topDict._fdSelect[t.index]:0,M=me.topDict._fdArray[U];I=M._subrs,_=M._subrsBias,s>1?(re=me.topDict._vstore.itemVariationStore,Y=M._privateDict.vsindex):(P=M._defaultWidthX,z=M._nominalWidthX)}else I=me.topDict._subrs,_=me.topDict._subrsBias;let ot=ro(e,c),Z=P;function Ve(U,M){x&&ot!==2&&c.closePath(),c.moveTo(U,M),x=!0}function De(){let U;U=(u.length&1)!==0,U&&!d&&(Z=u.shift()+z),m+=u.length>>1,u.length=0,d=!0}function G(U){let M,Ee,Mt,ms,Kt,it,Fe,Ke,Le,ze,Ue,Me,ge=0;for(;ge1&&!d&&(Z=u.shift()+z,d=!0),S+=u.pop(),Ve(v,S);break;case 5:for(;u.length>0;)v+=u.shift(),S+=u.shift(),c.lineTo(v,S);break;case 6:for(;u.length>0&&(v+=u.shift(),c.lineTo(v,S),u.length!==0);)S+=u.shift(),c.lineTo(v,S);break;case 7:for(;u.length>0&&(S+=u.shift(),c.lineTo(v,S),u.length!==0);)v+=u.shift(),c.lineTo(v,S);break;case 8:for(;u.length>0;)o=v+u.shift(),i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),v=a+u.shift(),S=l+u.shift(),c.curveTo(o,i,a,l,v,S);break;case 10:if(Kt=u.pop()+_,it=I[Kt],it){if(ae>=Jr){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}ae++,G(it),ae--}break;case 11:if(s>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Je=U[ge],ge+=1,Je){case 35:o=v+u.shift(),i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),Fe=a+u.shift(),Ke=l+u.shift(),Le=Fe+u.shift(),ze=Ke+u.shift(),Ue=Le+u.shift(),Me=ze+u.shift(),v=Ue+u.shift(),S=Me+u.shift(),u.shift(),c.curveTo(o,i,a,l,Fe,Ke),c.curveTo(Le,ze,Ue,Me,v,S);break;case 34:o=v+u.shift(),i=S,a=o+u.shift(),l=i+u.shift(),Fe=a+u.shift(),Ke=l,Le=Fe+u.shift(),ze=l,Ue=Le+u.shift(),Me=S,v=Ue+u.shift(),c.curveTo(o,i,a,l,Fe,Ke),c.curveTo(Le,ze,Ue,Me,v,S);break;case 36:o=v+u.shift(),i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),Fe=a+u.shift(),Ke=l,Le=Fe+u.shift(),ze=l,Ue=Le+u.shift(),Me=ze+u.shift(),v=Ue+u.shift(),c.curveTo(o,i,a,l,Fe,Ke),c.curveTo(Le,ze,Ue,Me,v,S);break;case 37:o=v+u.shift(),i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),Fe=a+u.shift(),Ke=l+u.shift(),Le=Fe+u.shift(),ze=Ke+u.shift(),Ue=Le+u.shift(),Me=ze+u.shift(),Math.abs(Ue-v)>Math.abs(Me-S)?v=Ue+u.shift():S=Me+u.shift(),c.curveTo(o,i,a,l,Fe,Ke),c.curveTo(Le,ze,Ue,Me,v,S);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+Je),u.length=0}break;case 14:if(s>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){let Qt=Fs[u.pop()],mn=Fs[u.pop()],ys=u.pop(),bs=u.pop();if(Qt&&mn){t.isComposite=!0,t.components=[];let xi=e.cffEncoding.charset.indexOf(Qt),Si=e.cffEncoding.charset.indexOf(mn);t.components.push({glyphIndex:Si,dx:0,dy:0}),t.components.push({glyphIndex:xi,dx:bs,dy:ys}),c.extend(e.glyphs.get(Si).path);let Np=e.glyphs.get(xi),rr=JSON.parse(JSON.stringify(Np.path.commands));for(let or=0;or0&&!d&&(Z=u.shift()+z,d=!0);x&&ot!==2&&(c.closePath(),x=!1);break;case 15:if(s<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}Y=u.pop();break;case 16:if(s<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}ie||(ie=e.variation&&r&&e.variation.process.getBlendVector(re,Y,r));var le=u.pop(),_e=ie?ie.length:re.itemVariationSubtables[Y].regionIndexes.length,Qe=le*_e,at=u.length-Qe,Ct=at-le;if(ie)for(let Qt=0;Qt>3;break;case 21:u.length>2&&!d&&(Z=u.shift()+z,d=!0),S+=u.pop(),v+=u.pop(),Ve(v,S);break;case 22:u.length>1&&!d&&(Z=u.shift()+z,d=!0),v+=u.pop(),Ve(v,S);break;case 23:De();break;case 24:for(;u.length>2;)o=v+u.shift(),i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),v=a+u.shift(),S=l+u.shift(),c.curveTo(o,i,a,l,v,S);v+=u.shift(),S+=u.shift(),c.lineTo(v,S);break;case 25:for(;u.length>6;)v+=u.shift(),S+=u.shift(),c.lineTo(v,S);o=v+u.shift(),i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),v=a+u.shift(),S=l+u.shift(),c.curveTo(o,i,a,l,v,S);break;case 26:for(u.length&1&&(v+=u.shift());u.length>0;)o=v,i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),v=a,S=l+u.shift(),c.curveTo(o,i,a,l,v,S);break;case 27:for(u.length&1&&(S+=u.shift());u.length>0;)o=v+u.shift(),i=S,a=o+u.shift(),l=i+u.shift(),v=a+u.shift(),S=l,c.curveTo(o,i,a,l,v,S);break;case 28:M=U[ge],Ee=U[ge+1],u.push((M<<24|Ee<<16)>>16),ge+=2;break;case 29:if(Kt=u.pop()+e.gsubrsBias,it=e.gsubrs[Kt],it){if(ae>=Jr){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}ae++,G(it),ae--}break;case 30:for(;u.length>0&&(o=v,i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),v=a+u.shift(),S=l+(u.length===1?u.shift():0),c.curveTo(o,i,a,l,v,S),u.length!==0);)o=v+u.shift(),i=S,a=o+u.shift(),l=i+u.shift(),S=l+u.shift(),v=a+(u.length===1?u.shift():0),c.curveTo(o,i,a,l,v,S);break;case 31:for(;u.length>0&&(o=v+u.shift(),i=S,a=o+u.shift(),l=i+u.shift(),S=l+u.shift(),v=a+(u.length===1?u.shift():0),c.curveTo(o,i,a,l,v,S),u.length!==0);)o=v,i=S+u.shift(),a=o+u.shift(),l=i+u.shift(),v=a+u.shift(),S=l+(u.length===1?u.shift():0),c.curveTo(o,i,a,l,v,S);break;default:Je<32?console.log("Glyph "+t.index+": unknown operator "+Je):Je<247?u.push(Je-139):Je<251?(M=U[ge],ge+=1,u.push((Je-247)*256+M+108)):Je<255?(M=U[ge],ge+=1,u.push(-(Je-251)*256-M-108)):(M=U[ge],Ee=U[ge+1],Mt=U[ge+2],ms=U[ge+3],ge+=4,u.push((M<<24|Ee<<16|Mt<<8|ms)/65536))}}}return G(n),e.variation&&r&&(c.commands=c.commands.map(U=>{let M=Object.keys(U);for(let Ee=0;Ee=s)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+s+")");o.push(i)}else if(l===3||r>1&&l===4){let c=l===4?a.parseULong():a.parseCard16(),u=l===4?a.parseULong():a.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let m;for(let d=0;d=s)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+s+")");if(m>n)throw new Error(`CFF Table CID Font FDSelect format ${r} range has bad GID ${m}`);for(;u1?null:yt(e,o.endOffset,F.bytesToString),a=o.formatMajor>1?null:yt(e,i.endOffset),l=o.formatMajor>1?null:yt(e,a.endOffset,F.bytesToString),c=yt(e,o.formatMajor>1?t+o.size+o.topDictLength:l.endOffset,void 0,o.formatMajor);n.gsubrs=c.objects,n.gsubrsBias=is(n.gsubrs);let u;if(o.formatMajor>1){let d=t+o.size,x=F.getBytes(e,d,d+o.topDictLength);u=_s(e,0,[x],void 0,o.formatMajor)[0]}else{let d=_s(e,t,a.objects,l.objects,o.formatMajor);if(d.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+d.length);u=d[0]}if(r.topDict=u,u._privateDict&&(n.defaultWidthX=u._privateDict.defaultWidthX,n.nominalWidthX=u._privateDict.nominalWidthX),o.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(n.isCIDFont=!0),o.formatMajor>1){let d=u.fdArray,x=u.fdSelect;if(!d)throw new Error("This is a CFF2 font, but FDArray information is missing");let v=yt(e,t+d,null,o.formatMajor),S=Za(e,t,v.objects);u._fdArray=S,x&&(u._fdSelect=oo(e,t+x,n.numGlyphs,S.length,o.formatMajor))}else if(n.isCIDFont){let d=u.fdArray,x=u.fdSelect;if(d===0||x===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");d+=t;let v=yt(e,d),S=_s(e,t,v.objects,l.objects,o.formatMajor);u._fdArray=S,x+=t,u._fdSelect=oo(e,x,n.numGlyphs,S.length,o.formatMajor)}if(o.formatMajor<2){let d=t+u.private[1],x=Bs(e,d,u.private[0],l.objects,o.formatMajor);if(n.defaultWidthX=x.defaultWidthX,n.nominalWidthX=x.nominalWidthX,x.subrs!==0){let v=d+x.subrs,S=yt(e,v);n.subrs=S.objects,n.subrsBias=is(n.subrs)}else n.subrs=[],n.subrsBias=0}let m;if(s.lowMemory?(m=Ha(e,t+u.charStrings,o.formatMajor),n.nGlyphs=m.offsets.length-(o.formatMajor>1?1:0)):(m=yt(e,t+u.charStrings,null,o.formatMajor),n.nGlyphs=m.objects.length),o.formatMajor>1&&n.tables.maxp&&n.nGlyphs!==n.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${n.nGlyphs}) must correspond to the glyph count in the maxp table (${n.tables.maxp.numGlyphs})`),o.formatMajor<2){let d=[],x=[];u.charset===0?d=Oa:u.charset===1?d=Ia:u.charset===2?d=wa:d=Ka(e,t+u.charset,n.nGlyphs,l.objects,n.isCIDFont),u.encoding===0?x=Fs:u.encoding===1?x=Ea:x=Qa(e,t+u.encoding),n.cffEncoding=new Xr(x,d),n.encoding=n.encoding||n.cffEncoding}if(n.glyphs=new mt.GlyphSet(n),s.lowMemory)n._push=function(d){let x=Va(d,m.offsets,e,t+u.charStrings,void 0,o.formatMajor);n.glyphs.push(d,mt.cffGlyphLoader(n,d,Gs,x,o.formatMajor))};else for(let d=0;d=0&&(n=s),s=t.indexOf(e),s>=0?n=s+ss.length:(n=ss.length+t.length,t.push(e)),n}function tl(){return new A.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 nl(e){let t=new A.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);t.names=[];for(let n=0;n1?to:eo,e,t),s}function uo(e){let t=new A.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return t.topDicts=[{name:"topDict_0",type:"TABLE",value:e}],t}function sl(e){let t=new A.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);t.strings=[];for(let n=0;n1?so:no,e,t),s}function ul(e,t){let s=new A.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/t.unitsPerEm,o={version:t.version,fullName:t.fullName,familyName:t.familyName,weight:t.weightName,fontBBox:t.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i=t&&t.topDict||{};i.paintType&&(o.paintType=i.paintType,o.strokeWidth=i.strokeWidth||0);let a={},l=[],c;for(let x=1;x=n.begin&&e=1&&(n.ulCodePageRange1=s.parseULong(),n.ulCodePageRange2=s.parseULong()),n.version>=2&&(n.sxHeight=s.parseShort(),n.sCapHeight=s.parseShort(),n.usDefaultChar=s.parseUShort(),n.usBreakChar=s.parseUShort(),n.usMaxContent=s.parseUShort()),n}function Cl(e){return new A.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}],e)}var zs={parse:Tl,make:Cl,unicodeRanges:Vs,getUnicodeRange:kl};function Ol(e,t){let n={},s=new F.Parser(e,t);switch(n.version=s.parseVersion(),n.italicAngle=s.parseFixed(),n.underlinePosition=s.parseShort(),n.underlineThickness=s.parseShort(),n.isFixedPitch=s.parseULong(),n.minMemType42=s.parseULong(),n.maxMemType42=s.parseULong(),n.minMemType1=s.parseULong(),n.maxMemType1=s.parseULong(),n.version){case 1:n.names=qt.slice();break;case 2:n.numberOfGlyphs=s.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(let r=0;r=qt.length){let o=s.parseChar();n.names.push(s.parseString(o))}break;case 2.5:n.numberOfGlyphs=s.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(let r=0;r[{name:"glyphID_"+i,type:"USHORT",value:o.glyphID},{name:"firstLayerIndex_"+i,type:"USHORT",value:o.firstLayerIndex},{name:"numLayers_"+i,type:"USHORT",value:o.numLayers}]).flat(),...n.map((o,i)=>[{name:"LayerGlyphID_"+i,type:"USHORT",value:o.glyphID},{name:"paletteIndex_"+i,type:"USHORT",value:o.paletteIndex}]).flat()])}var vo={parse:Rl,make:Dl};function Fl(e,t){return[{name:"tag_"+e,type:"TAG",value:t.tag},{name:"minValue_"+e,type:"FIXED",value:t.minValue<<16},{name:"defaultValue_"+e,type:"FIXED",value:t.defaultValue<<16},{name:"maxValue_"+e,type:"FIXED",value:t.maxValue<<16},{name:"flags_"+e,type:"USHORT",value:0},{name:"nameID_"+e,type:"USHORT",value:t.axisNameID}]}function Ul(e,t,n){let s={},r=new F.Parser(e,t);s.tag=r.parseTag(),s.minValue=r.parseFixed(),s.defaultValue=r.parseFixed(),s.maxValue=r.parseFixed(),r.skip("uShort",1);let o=r.parseUShort();return s.axisNameID=o,s.name=ns(n,o),s}function Ml(e,t,n,s={}){let r=[{name:"nameID_"+e,type:"USHORT",value:t.subfamilyNameID},{name:"flags_"+e,type:"USHORT",value:0}];for(let o=0;o1||o>0?s.parseUShort():void 0;n!==void 0&&B.argument(l>=n.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&B.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let x=[];for(let I=0;Ia.value.tag?1:-1}),t.fields=t.fields.concat(s),t.fields=t.fields.concat(r),t}function Ao(e,t,n){for(let s=0;s0)return e.glyphs.get(r).getMetrics()}return n}function su(e){let t=0;for(let n=0;nQe||l===void 0)&&Qe>0&&(l=Qe),c 123 are reserved for internal usage");if(_e.name===".notdef")continue;let Ct=_e.getMetrics();t.push(Ct.xMin),n.push(Ct.yMin),s.push(Ct.xMax),r.push(Ct.yMax),i.push(Ct.leftSideBearing),a.push(Ct.rightSideBearing),o.push(_e.advanceWidth)}let v={xMin:Math.min.apply(null,t),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,s),yMax:Math.max.apply(null,r),advanceWidthMax:Math.max.apply(null,o),advanceWidthAvg:su(o),minLeftSideBearing:Math.min.apply(null,i),maxLeftSideBearing:Math.max.apply(null,i),minRightSideBearing:Math.min.apply(null,a)};v.ascender=e.ascender,v.descender=e.descender;let S=0;e.weightClass>=600&&(S|=e.macStyleValues.BOLD),e.italicAngle<0&&(S|=e.macStyleValues.ITALIC);let I=co.make({flags:3,unitsPerEm:e.unitsPerEm,xMin:v.xMin,yMin:v.yMin,xMax:v.xMax,yMax:v.yMax,lowestRecPPEM:3,macStyle:S,createdTimestamp:e.createdTimestamp}),_=fo.make({ascender:v.ascender,descender:v.descender,advanceWidthMax:v.advanceWidthMax,minLeftSideBearing:v.minLeftSideBearing,minRightSideBearing:v.minRightSideBearing,xMaxExtent:v.maxLeftSideBearing+(v.xMax-v.xMin),numberOfHMetrics:e.glyphs.length}),P=go.make(e.glyphs.length),z=zs.make(Object.assign({xAvgCharWidth:Math.round(v.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:m,ulUnicodeRange3:d,ulUnicodeRange4:x,sTypoAscender:v.ascender,sTypoDescender:v.descender,sTypoLineGap:0,usWinAscent:v.yMax,usWinDescent:Math.abs(v.yMin),ulCodePageRange1:1,sxHeight:Ao(e,"xyvw",{yMax:Math.round(v.ascender/2)}).yMax,sCapHeight:Ao(e,"HIKLEFJMNTZBDPRAGOQSUVWXY",v).yMax,usDefaultChar:e.hasChar(" ")?32:0,usBreakChar:e.hasChar(" ")?32:0},e.tables.os2)),Y=po.make(e.glyphs),re=Wr.make(e.glyphs),ie=e.getEnglishName("fontFamily"),ae=e.getEnglishName("fontSubfamily"),me=ie+" "+ae,ot=e.getEnglishName("postScriptName");ot||(ot=ie.replace(/\s/g,"")+"-"+ae);let Z={};for(let le in e.names)Z[le]=e.names[le];Z.unicode=Z.unicode||{},Z.macintosh=Z.macintosh||{},Z.windows=Z.windows||{};let Ve=e.names.unicode||{},De=e.names.macintosh||{},G=e.names.windows||{};for(let le in Z){if(Z[le]=Z[le]||{},!Z[le].uniqueID){let _e=e.getEnglishName("manufacturer")||"";Z[le].uniqueID={en:`${_e}: ${me}`}}Z[le].postScriptName||(Z[le].postScriptName={en:ot})}Z.unicode.preferredFamily||(Z.unicode.preferredFamily=Ve.fontFamily||De.fontFamily||G.fontFamily),Z.macintosh.preferredFamily||(Z.macintosh.preferredFamily=De.fontFamily||Ve.fontFamily||G.fontFamily),Z.windows.preferredFamily||(Z.windows.preferredFamily=G.fontFamily||Ve.fontFamily||De.fontFamily),Z.unicode.preferredSubfamily||(Z.unicode.preferredSubfamily=Ve.fontSubfamily||De.fontSubfamily||G.fontSubfamily),Z.macintosh.preferredSubfamily||(Z.macintosh.preferredSubfamily=De.fontSubfamily||Ve.fontSubfamily||G.fontSubfamily),Z.windows.preferredSubfamily||(Z.windows.preferredSubfamily=G.fontSubfamily||Ve.fontSubfamily||De.fontSubfamily);let U=[],M=jr.make(Z,U),Ee=U.length>0?ho.make(U):void 0,Mt=mo.make(e),ms=Hs.make(e.glyphs,{version:e.getEnglishName("version"),fullName:me,familyName:ie,weightName:ae,postScriptName:ot,unitsPerEm:e.unitsPerEm,fontBBox:[0,v.yMin,v.ascender,v.advanceWidthMax],topDict:e.tables.cff&&e.tables.cff.topDict||{}}),Kt=e.metas&&Object.keys(e.metas).length>0?bo.make(e.metas):void 0,it=[I,_,P,z,M,re,Mt,ms,Y];Ee&&it.push(Ee);let Fe={gsub:yo,cpal:Kr,colr:vo,stat:So,avar:ko,cvar:To,fvar:xo,gvar:Co,gasp:Oo,svg:Io},Ke={avar:[e.tables.fvar],fvar:[e.names]};for(let le in Fe){let _e=e.tables[le];if(_e){let Qe=Fe[le].make.call(e,_e,...Ke[le]||[]);Qe&&it.push(Qe)}}Kt&&it.push(Kt);let Le=Lo(it),ze=Le.encode(),Ue=js(ze),Me=Le.fields,ge=!1;for(let le=0;le>>1,o=e[r].tag;if(o===t)return r;o>>1,o=e[r];if(o===t)return r;o>>1;n=e[o];let i=n.start;if(i===t)return n;i0)return n=e[s-1],t>n.end?0:n}function Fo(e,t){this.font=e,this.tableName=t}Fo.prototype={searchTag:Ws,binSearch:Ro,getTable:function(e){let t=this.font.tables[this.tableName];return!t&&e&&(t=this.font.tables[this.tableName]=this.createDefaultTable()),t},getScriptNames:function(){let e=this.getTable();return e?e.scripts.map(function(t){return t.tag}):[]},getDefaultScriptName:function(){let e=this.getTable();if(!e)return;let t=!1;for(let n=0;n=0)return s[r].script;if(t){let o={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return s.splice(-1-r,0,o),o.script}}},getLangSysTable:function(e,t,n){let s=this.getScriptTable(e,n);if(s){if(!t||t==="dflt"||t==="DFLT")return s.defaultLangSys;let r=Ws(s.langSysRecords,t);if(r>=0)return s.langSysRecords[r].langSys;if(n){let o={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return s.langSysRecords.splice(-1-r,0,o),o.langSys}}},getFeatureTable:function(e,t,n,s){let r=this.getLangSysTable(e,t,s);if(r){let o,i=r.featureIndexes,a=this.font.tables[this.tableName].features;for(let l=0;l=a[l-1].tag,"Features must be added in alphabetical order."),o={tag:n,feature:{params:0,lookupListIndexes:[]}},a.push(o),i.push(l),o.feature}}},getLookupTables:function(e,t,n,s,r){let o=this.getFeatureTable(e,t,n,r),i=[];if(o){let a,l=o.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?n:-1}case 2:{let n=Do(e.ranges,t);return n?n.index+t-n.start:-1}}},expandCoverage:function(e){if(e.format===1)return e.glyphs;{let t=[],n=e.ranges;for(let s=0;sn)r=i-1;else{o=a;break}}return o}function uu(e,t,n){let s=0,r=e.length-1;for(;s<=r;){let o=Math.floor((s+r)/2),i=e[o];if(i[t]n)r=o-1;else return o}return-1}function cu(e,t,n){let s=0,r=e.length,o=(i,a)=>i[t]-a[t];for(;s>>1;o(e[i],n)<0?s=i+1:r=i}return e.splice(s,0,n),s}function Uo(e){return e[0]===31&&e[1]===139&&e[2]===8}function fu(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=10,s=e.byteLength-8,r=t.getInt8(3);if(r&4&&(n+=2+t.getUint16(n,!0)),r&8)for(;n=s)throw new Error("Can't find compressed blocks");let o=t.getUint32(t.byteLength-4,!0);return Er(e.subarray(n,s),new Uint8Array(o))}function Mo(e){return{x:e.x,y:e.y,onCurve:e.onCurve,lastPointOfContour:e.lastPointOfContour}}function pu(e){return{glyphIndex:e.glyphIndex,xScale:e.xScale,scale01:e.scale01,scale10:e.scale10,yScale:e.yScale,dx:e.dx,dy:e.dy}}function Ge(e){as.call(this,e,"gsub")}function qs(e,t,n){let s=e.subtables;for(let r=0;r1,'Multiple: "by" must be an array of two or more ids');let r=this.getLookupTables(n,s,e,2,!0)[0],o=qs(r,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});B.assert(o.coverage.format===1,"Multiple: unable to modify coverage table format "+o.coverage.format);let i=t.sub,a=this.binSearch(o.coverage.glyphs,i);a<0&&(a=-1-a,o.coverage.glyphs.splice(a,0,i),o.sequences.splice(a,0,0)),o.sequences[a]=t.by},Ge.prototype.addAlternate=function(e,t,n,s){let r=this.getLookupTables(n,s,e,3,!0)[0],o=qs(r,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});B.assert(o.coverage.format===1,"Alternate: unable to modify coverage table format "+o.coverage.format);let i=t.sub,a=this.binSearch(o.coverage.glyphs,i);a<0&&(a=-1-a,o.coverage.glyphs.splice(a,0,i),o.alternateSets.splice(a,0,0)),o.alternateSets[a]=t.by},Ge.prototype.addLigature=function(e,t,n,s){let r=this.getLookupTables(n,s,e,4,!0)[0],o=r.subtables[0];o||(o={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},r.subtables[0]=o),B.assert(o.coverage.format===1,"Ligature: unable to modify coverage table format "+o.coverage.format);let i=t.sub[0],a=t.sub.slice(1),l={ligGlyph:t.by,components:a},c=this.binSearch(o.coverage.glyphs,i);if(c>=0){let u=o.ligatureSets[c];for(let m=0;mrs(t,"raw")):rs(e,"raw")}fillPalette(e,t=[],n=this.cpal().numPaletteEntries){return e=Number.isInteger(e)?this.get(e,"raw"):e,Object.assign(Array(n).fill(this.defaultValue),this.toCPALcolor(e).concat(this.toCPALcolor(t)))}extend(e){if(this.ensureCPAL(Array(e).fill(this.defaultValue)))return;let t=this.cpal(),n=t.numPaletteEntries+e,s=this.getAll().map(r=>this.fillPalette(r,[],n));t.numPaletteEntries=n,t.colorRecords=this.toCPALcolor(s.flat()),this.updateIndices()}get(e,t="hexa"){return this.getAll(t)[e]||null}getColor(e,t=0,n="hexa"){return Ms(this.font,e,t,n)}setColor(e,t,n=0){e=parseInt(e),n=parseInt(n);let s=this.getAll("raw"),r=s[n];if(!r)throw Error(`paletteIndex ${n} out of range`);let o=this.cpal(),i=o.numPaletteEntries;Array.isArray(t)||(t=[t]),t.length+e>i&&(this.extend(t.length+e-i),s=this.getAll("raw"),r=s[n]);for(let a=0;an?this.extend(e.length-n):e.lengthn.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${n.numPaletteEntries-1}, replacementIndex: ${t})`);for(let a=0;am!==e);r.push(c)}let o=this.font.tables.colr;if(o){let a=o.layerRecords;for(let l=0;le)a[l].paletteIndex-=1;else if(c===e){let u=0;for(let m=0;me&&t<=e+s[m].length){u++;break}a[l].paletteIndex=t-u}}this.font.tables.colr={...o,layerRecords:a}}let i=r.flat();for(let a=0;as.length?n=s.length:n<0&&(n=s.length+1+n%(s.length+1),n>=s.length+1&&(n-=s.length+1));let r=[];for(let o=0;o({glyphID:r.glyph.index,paletteIndex:o===t?n:r.paletteIndex})),this.updateColrTable(e,s)):console.error("Invalid layer index")}remove(e,t,n=t){let s=this.get(e);s=s.map(r=>({glyphID:r.glyph.index,paletteIndex:r.paletteIndex})),s.splice(t,n-t+1),this.updateColrTable(e,s)}updateColrTable(e,t){this.ensureCOLR();let s=this.font.tables.colr,r=uu(s.baseGlyphRecords,"glyphID",e);if(r===-1){let u={glyphID:e,firstLayerIndex:s.layerRecords.length,numLayers:0};r=cu(s.baseGlyphRecords,"glyphID",u)}let i=s.baseGlyphRecords[r],a=i.numLayers,l=t.length,c=l-a;if(c>0){let u=t.slice(a).map(m=>({glyphID:m.glyphID,paletteIndex:m.paletteIndex}));s.layerRecords.splice(i.firstLayerIndex+a,0,...u)}else c<0&&s.layerRecords.splice(i.firstLayerIndex+l,-c);for(let u=0;u{if(r.image=o,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(e)}catch(i){console.error("font.onGlyphUpdated",e,i)}}),s.images.set(e,r)),r}};function mu(e){return{template:bu(e).then(Su),images:new Map}}function yu(e,t,n){return{promise:t.then(s=>{let r;typeof s=="string"?r=s:(s[4]=n,r=s.join(""));let o=ku(r,e.unitsPerEm);return o.image.decode().then(()=>o)}),image:void 0}}var bu=typeof DecompressionStream=="function"?xu:vu;function vu(e){try{return Promise.resolve(new TextDecoder().decode(Uo(e)?fu(e):e))}catch(t){return Promise.reject(t)}}function xu(e){if(Uo(e))return new Response(new Response(e).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(e))}catch(t){return Promise.reject(t)}}function Su(e){let t=e.indexOf("",t+4)+1;if(/ id=['"]glyph\d+['"]/.test(e.substring(t,n)))return e;let s=e.lastIndexOf("");return[e.substring(0,n),"",e.substring(n,s),'',e.substring(s)]}function ku(e,t){let s=new DOMParser().parseFromString(e,"image/svg+xml").documentElement,r=s.viewBox.baseVal,o=s.width.baseVal,i=s.height.baseVal,a=1,l=1;r.width>0&&r.height>0&&(o.unitType===1?(a=o.valueInSpecifiedUnits/r.width,l=i.unitType===1?i.valueInSpecifiedUnits/r.height:a):i.unitType===1?(l=i.valueInSpecifiedUnits/r.height,a=l):t&&(a=t/r.width,l=t/r.height));let c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(s),document.body.appendChild(c);let u=s.getBBox();document.body.removeChild(c);let m=(u.x-r.x)*a,d=(r.y-u.y)*l,x=u.width*a,v=u.height*l;s.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),a!==1&&s.setAttribute("width",x),l!==1&&s.setAttribute("height",v);let S=new Image(x,v);return S.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(s.outerHTML),{leftSideBearing:m,baseline:d,image:S}}var $s=new WeakMap;function No(e,t,n,s,r){let o;return(t&s)>0?(o=e.parseByte(),(t&r)===0&&(o=-o),o=n+o):(t&r)>0?o=n:o=n+e.parseShort(),o}function Bo(e,t,n){let s=new F.Parser(t,n);e._numberOfContours=s.parseShort(),e._xMin=s.parseShort(),e._yMin=s.parseShort(),e._xMax=s.parseShort(),e._yMax=s.parseShort();let r,o;if(e._numberOfContours>0){let i=e.endPointIndices=[];for(let l=0;l0){let c=s.parseByte();for(let u=0;u0){let l=[],c;if(a>0){for(let d=0;d=0,l.push(c);let u=0;for(let d=0;d0?(r&2)>0?(a.dx=s.parseShort(),a.dy=s.parseShort()):a.matchedPoints=[s.parseUShort(),s.parseUShort()]:(r&2)>0?(a.dx=s.parseChar(),a.dy=s.parseChar()):a.matchedPoints=[s.parseByte(),s.parseByte()],(r&8)>0?a.xScale=a.yScale=s.parseF2Dot14():(r&64)>0?(a.xScale=s.parseF2Dot14(),a.yScale=s.parseF2Dot14()):(r&128)>0&&(a.xScale=s.parseF2Dot14(),a.scale01=s.parseF2Dot14(),a.scale10=s.parseF2Dot14(),a.yScale=s.parseF2Dot14()),e.components.push(a),i=!!(r&32)}if(r&256){e.instructionLength=s.parseUShort(),e.instructions=[];for(let a=0;at.points.length-1||r.matchedPoints[1]>o.points.length-1)throw Error("Matched points out of range in "+t.name);let a=t.points[r.matchedPoints[0]],l=o.points[r.matchedPoints[1]],c={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};l=ls([l],c)[0],c.dx=a.x-l.x,c.dy=a.y-l.y,i=ls(o.points,c)}t.points=t.points.concat(i)}}}finally{n.delete(t.index)}}return Xs(t.points)}function Cu(e,t,n,s){let r=new mt.GlyphSet(s);for(let o=0;o=1&&t[n]o)continue;let a=s,l=s;for(s++;s<=o;)n[s]&&(this.deltaInterpolate(l+1,s-1,l,s,t,e),l=s),s++;l===a?this.deltaShift(r,o,l,t,e):(this.deltaInterpolate(l+1,o,l,a,t,e),a>0&&this.deltaInterpolate(r,a-1,l,a,t,e)),s=o+1}}deltaInterpolate(e,t,n,s,r,o){if(e>t)return;let i=["x","y"];for(let l=0;lr[s][c]){var a=n;n=s,s=a}let u=r[n][c],m=r[s][c],d=o[n][c],x=o[s][c];if(u!==m||d===x){let v=u===m?0:(x-d)/(m-u);for(let S=e;S<=t;S++){let I=r[S][c];I<=u?I+=d-u:I>=m?I+=x-m:I=d+(I-u)*v,o[S][c]=I}}}}deltaShift(e,t,n,s,r){let o=r[n].x-s[n].x,i=r[n].y-s[n].y;if(!(o===0&&i===0))for(let a=e;a<=t;a++)a!==n&&(r[a].x+=o,r[a].y+=i)}transformComponents(e,t,n,s,r,o){let i=0;for(let a=0;a-1&&(u.dx+=Math.round(r.deltas[m]*o),u.dy+=Math.round(r.deltasY[m]*o));let d=ls(this.getTransform(c,n).points,u);t.splice(i,d.length,...d),i+=c.points.length}}applyTupleVariationStore(e,t,n,s="gvar",r={}){n||(n=this.font.variation.get());let o=this.getNormalizedCoords(n),{headers:i,sharedPoints:a}=e,l=this.fvar().axes.length,c;s==="gvar"?c=t.map(Mo):s==="cvar"&&(c=[...t]);for(let u=0;um.intermediateEndTuple[v]){d=0;break}else o[v]Math.max(0,S[v])){d=0;break}d=(d*o[v]+Number.EPSILON)/(S[v]+Number.EPSILON)}}}if(d===0)continue;let x=m.privatePoints.length?m.privatePoints:a;if(s==="gvar"&&r.glyph&&r.glyph.isComposite)this.transformComponents(r.glyph,c,n,x,m,d);else if(x.length===0)for(let v=0;v=a&&(l=a-1),{outerIndex:r,innerIndex:o}=i[n].map[l]}else r=0,o=e;return this.getDelta(i.itemVariationStore,r,o,s)}getDelta(e,t,n,s){if(t>=e.itemVariationSubtables.length)return 0;let r=e.itemVariationSubtables[t];if(n>=r.deltaSets.length)return 0;let o=r.deltaSets[n],i=this.getBlendVector(e,t,s),a=0;for(let l=0;lm.peakCoord||m.peakCoord>m.endCoord||m.startCoord<0&&m.endCoord>0&&m.peakCoord!==0||m.peakCoord===0?d=1:r[u]m.endCoord?d=0:r[u]===m.peakCoord?d=1:r[u]-1?this.set(e):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((e,t)=>(e[t.tag]=t.defaultValue,e),{})}getDefaultInstanceIndex(){let e=this.getDefaultCoordinates(),t=this.getInstanceIndex(e);return t<0&&(t=this.fvar().instances.findIndex(n=>n.name&&n.name.en==="Regular")),t}getInstanceIndex(e){return this.fvar().instances.findIndex(t=>Object.keys(e).every(n=>t.coordinates[n]===e[n]))}getInstance(e){return this.fvar().instances&&this.fvar().instances[e]}set(e){let t;if(Number.isInteger(e)){let n=this.getInstance(e);if(!n)throw Error(`Invalid instance index ${e}`);t={...n.coordinates}}else t=e,this.process.normalizeCoordTags(t);t=Object.assign({},this.font.defaultRenderOptions.variation,t),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:t})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Ho=1e6,us=64,cs=1e4,Vo,Yt,zo,Ys;function jo(e){this.font=e,this.getCommands=function(t){return Go.getPath(t).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Lu(e){return e}function Wo(e){return Math.sign(e)*Math.round(Math.abs(e))}function Au(e){return Math.sign(e)*Math.round(Math.abs(e*2))/2}function Ru(e){return Math.sign(e)*(Math.round(Math.abs(e)+.5)-.5)}function Du(e){return Math.sign(e)*Math.ceil(Math.abs(e))}function Fu(e){return Math.sign(e)*Math.floor(Math.abs(e))}var qo=function(e){let t=this.srPeriod,n=this.srPhase,s=this.srThreshold,r=1;return e<0&&(e=-e,r=-1),e+=s-n,e=Math.trunc(e/t)*t,e+=n,e<0?n*r:e*r},bt={x:1,y:0,axis:"x",distance:function(e,t,n,s){return(n?e.xo:e.x)-(s?t.xo:t.x)},interpolate:function(e,t,n,s){let r,o,i,a,l,c,u;if(!s||s===this){if(r=e.xo-t.xo,o=e.xo-n.xo,l=t.x-t.xo,c=n.x-n.xo,i=Math.abs(r),a=Math.abs(o),u=i+a,u===0){e.x=e.xo+(l+c)/2;return}e.x=e.xo+(l*a+c*i)/u;return}if(r=s.distance(e,t,!0,!0),o=s.distance(e,n,!0,!0),l=s.distance(t,t,!1,!0),c=s.distance(n,n,!1,!0),i=Math.abs(r),a=Math.abs(o),u=i+a,u===0){bt.setRelative(e,e,(l+c)/2,s,!0);return}bt.setRelative(e,e,(l*a+c*i)/u,s,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(e,t,n,s,r){if(!s||s===this){e.x=(r?t.xo:t.x)+n;return}let o=r?t.xo:t.x,i=r?t.yo:t.y,a=o+n*s.x,l=i+n*s.y;e.x=a+(e.y-l)/s.normalSlope},slope:0,touch:function(e){e.xTouched=!0},touched:function(e){return e.xTouched},untouch:function(e){e.xTouched=!1}},kt={x:0,y:1,axis:"y",distance:function(e,t,n,s){return(n?e.yo:e.y)-(s?t.yo:t.y)},interpolate:function(e,t,n,s){let r,o,i,a,l,c,u;if(!s||s===this){if(r=e.yo-t.yo,o=e.yo-n.yo,l=t.y-t.yo,c=n.y-n.yo,i=Math.abs(r),a=Math.abs(o),u=i+a,u===0){e.y=e.yo+(l+c)/2;return}e.y=e.yo+(l*a+c*i)/u;return}if(r=s.distance(e,t,!0,!0),o=s.distance(e,n,!0,!0),l=s.distance(t,t,!1,!0),c=s.distance(n,n,!1,!0),i=Math.abs(r),a=Math.abs(o),u=i+a,u===0){kt.setRelative(e,e,(l+c)/2,s,!0);return}kt.setRelative(e,e,(l*a+c*i)/u,s,!0)},normalSlope:0,setRelative:function(e,t,n,s,r){if(!s||s===this){e.y=(r?t.yo:t.y)+n;return}let o=r?t.xo:t.x,i=r?t.yo:t.y,a=o+n*s.x,l=i+n*s.y;e.y=l+s.normalSlope*(e.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(e){e.yTouched=!0},touched:function(e){return e.yTouched},untouch:function(e){e.yTouched=!1}};Object.freeze(bt),Object.freeze(kt);function Rn(e,t){this.x=e,this.y=t,this.axis=void 0,this.slope=t/e,this.normalSlope=-e/t,Object.freeze(this)}Rn.prototype.distance=function(e,t,n,s){return this.x*bt.distance(e,t,n,s)+this.y*kt.distance(e,t,n,s)},Rn.prototype.interpolate=function(e,t,n,s){let r,o,i,a,l,c,u;if(i=s.distance(e,t,!0,!0),a=s.distance(e,n,!0,!0),r=s.distance(t,t,!1,!0),o=s.distance(n,n,!1,!0),l=Math.abs(i),c=Math.abs(a),u=l+c,u===0){this.setRelative(e,e,(r+o)/2,s,!0);return}this.setRelative(e,e,(r*c+o*l)/u,s,!0)},Rn.prototype.setRelative=function(e,t,n,s,r){s=s||this;let o=r?t.xo:t.x,i=r?t.yo:t.y,a=o+n*s.x,l=i+n*s.y,c=s.normalSlope,u=this.slope,m=e.x,d=e.y;e.x=(u*m-c*a+l-d)/(u-c),e.y=u*(e.x-m)+d},Rn.prototype.touch=function(e){e.xTouched=!0,e.yTouched=!0};function Dn(e,t){let n=Math.sqrt(e*e+t*t);return e/=n,t/=n,e===1&&t===0?bt:e===0&&t===1?kt:new Rn(e,t)}function Tt(e,t,n,s){this.x=this.xo=Math.round(e*64)/64,this.y=this.yo=Math.round(t*64)/64,this.lastPointOfContour=n,this.onCurve=s,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Tt.prototype.nextTouched=function(e){let t=this.nextPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.nextPointOnContour;return t},Tt.prototype.prevTouched=function(e){let t=this.prevPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.prevPointOnContour;return t};var Fn=Object.freeze(new Tt(0,0)),Uu={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Et(e,t){switch(this.env=e,this.stack=[],this.prog=t,e){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=bt,this.round=Wo}}jo.prototype.exec=function(e,t){if(typeof t!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let n=this.font,s=this._prepState;if(!s||s.ppem!==t){let r=this._fpgmState;if(!r){Et.prototype=Uu,r=this._fpgmState=new Et("fpgm",n.tables.fpgm),r.funcs=[],r.font=n,r.instructionCount=0,r.callDepth=0;try{Yt(r)}catch(i){console.log("Hinting error in FPGM:"+i),this._errorState=3;return}}Et.prototype=r,s=this._prepState=new Et("prep",n.tables.prep),s.ppem=t,s.instructionCount=0,s.callDepth=0;let o=n.variation&&n.variation.process.getCvarTransform()||n.tables.cvt;if(o){let i=s.cvt=new Array(o.length),a=t/n.unitsPerEm;for(let l=0;l1))try{return zo(e,s)}catch(r){this._errorState<1&&(console.log("Hinting error:"+r),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},zo=function(e,t){let n=t.ppem/t.font.unitsPerEm,s=n,r=e.components,o,i,a;if(Et.prototype=t,!r)a=new Et("glyf",e.instructions),a.instructionCount=0,a.callDepth=0,Ys(e,a,n,s),i=a.gZone;else{let l=t.font;i=[],o=[];for(let c=0;cHo)throw new Error("Hinting instructions exceeded maximum of "+Ho);if(s=Vo[t[e.ip]],!s)throw new Error("unknown instruction: 0x"+Number(t[e.ip]).toString(16));s(e)}};function fs(e){let t=e.tZone=new Array(e.gZone.length);for(let n=0;n=176&&o<=183)s+=o-176+1;else if(o>=184&&o<=191)s+=(o-184+1)*2;else if(t&&r===1&&o===27)break;while(r>0);e.ip=s}function Xo(e,t){t.fv=t.pv=t.dpv=e}function Yo(e,t){t.pv=t.dpv=e}function Zo(e,t){t.fv=e}function Ko(e,t){let n=t.stack,s=n.pop(),r=n.pop(),o=t.z2[s],i=t.z1[r],a,l;e?(a=o.y-i.y,l=i.x-o.x):(a=i.x-o.x,l=i.y-o.y),t.pv=t.dpv=Dn(a,l)}function Qo(e,t){let n=t.stack,s=n.pop(),r=n.pop(),o=t.z2[s],i=t.z1[r],a,l;e?(a=o.y-i.y,l=i.x-o.x):(a=i.x-o.x,l=i.y-o.y),t.fv=Dn(a,l)}function Mu(e){let t=e.stack,n=t.pop(),s=t.pop();e.pv=e.dpv=Dn(s,n)}function Pu(e){let t=e.stack,n=t.pop(),s=t.pop();e.fv=Dn(s,n)}function Nu(e){let t=e.stack,n=e.pv;t.push(n.x*16384),t.push(n.y*16384)}function Bu(e){let t=e.stack,n=e.fv;t.push(n.x*16384),t.push(n.y*16384)}function _u(e){e.fv=e.pv}function Gu(e){let t=e.stack,n=t.pop(),s=t.pop(),r=t.pop(),o=t.pop(),i=t.pop(),a=e.z0,l=e.z1,c=a[n],u=a[s],m=l[r],d=l[o],x=e.z2[i],v=c.x,S=c.y,I=u.x,_=u.y,P=m.x,z=m.y,Y=d.x,re=d.y,ie=(v-I)*(z-re)-(S-_)*(P-Y),ae=v*_-S*I,me=P*re-z*Y;x.x=(ae*(P-Y)-me*(v-I))/ie,x.y=(ae*(z-re)-me*(S-_))/ie}function Hu(e){e.rp0=e.stack.pop()}function Vu(e){e.rp1=e.stack.pop()}function zu(e){e.rp2=e.stack.pop()}function ju(e){let t=e.stack.pop();switch(e.zp0=t,t){case 0:e.tZone||fs(e),e.z0=e.tZone;break;case 1:e.z0=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Wu(e){let t=e.stack.pop();switch(e.zp1=t,t){case 0:e.tZone||fs(e),e.z1=e.tZone;break;case 1:e.z1=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function qu(e){let t=e.stack.pop();switch(e.zp2=t,t){case 0:e.tZone||fs(e),e.z2=e.tZone;break;case 1:e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function $u(e){let t=e.stack.pop();switch(e.zp0=e.zp1=e.zp2=t,t){case 0:e.tZone||fs(e),e.z0=e.z1=e.z2=e.tZone;break;case 1:e.z0=e.z1=e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Xu(e){e.loop=e.stack.pop(),e.loop>cs&&(e.loop=cs)}function Yu(e){e.round=Wo}function Zu(e){e.round=Ru}function Ku(e){let t=e.stack.pop();e.minDis=t/64}function Qu(e){$o(e,!1)}function Ju(e){let t=e.stack.pop();e.ip+=t-1}function ec(e){let t=e.stack.pop();e.cvCutIn=t/64}function tc(e){let t=e.stack;t.push(t[t.length-1])}function Zs(e){e.stack.pop()}function nc(e){e.stack.length=0}function sc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(n),t.push(s)}function rc(e){let t=e.stack;t.push(t.length)}function oc(e){let t=e.stack,n=t.pop(),s=t.pop();if(s>cs&&(s=cs),++e.callDepth>us)throw new Error("Hinting call depth exceeded maximum of "+us);let r=e.ip,o=e.prog;e.prog=e.funcs[n];for(let i=0;ius)throw new Error("Hinting call depth exceeded maximum of "+us);let n=e.ip,s=e.prog;e.prog=e.funcs[t],Yt(e),e.ip=n,e.prog=s,e.callDepth--}function ac(e){let t=e.stack,n=t.pop();t.push(t[t.length-n])}function lc(e){let t=e.stack,n=t.pop();t.push(t.splice(t.length-n,1)[0])}function uc(e){if(e.env!=="fpgm")throw new Error("FDEF not allowed here");let t=e.stack,n=e.prog,s=e.ip,r=t.pop(),o=s;for(;n[++s]!==45;);e.ip=s,e.funcs[r]=n.slice(o+1,s)}function Jo(e,t){let n=t.stack.pop(),s=t.z0[n],r=t.fv,o=t.pv,i=o.distance(s,Fn);e&&(i=t.round(i)),r.setRelative(s,Fn,i,o),r.touch(s),t.rp0=t.rp1=n}function ei(e,t){let n=t.z2,s=n.length-2,r,o,i;for(let a=0;an?1:0)}function Oc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(s>=n?1:0)}function Ic(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(n===s?1:0)}function wc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(n!==s?1:0)}function Ec(e){let t=e.stack,n=t.pop();t.push(Math.trunc(n)&1?1:0)}function Lc(e){let t=e.stack,n=t.pop();t.push(Math.trunc(n)&1?0:1)}function Ac(e){let t=e.stack.pop(),n;t||$o(e,!0)}function Rc(e){}function Dc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(n&&s?1:0)}function Fc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(n||s?1:0)}function Uc(e){let t=e.stack,n=t.pop();t.push(n?0:1)}function Ks(e,t){let n=t.stack,s=n.pop(),r=t.fv,o=t.pv,i=t.ppem,a=t.deltaBase+(e-1)*16,l=t.deltaShift,c=t.z0;for(let u=0;u>4)!==i)continue;let v=(d&15)-8;v>=0&&v++;let S=c[m];r.setRelative(S,S,v*l,o)}}function Mc(e){let n=e.stack.pop();e.deltaBase=n}function Pc(e){let n=e.stack.pop();e.deltaShift=Math.pow(.5,n)}function Nc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(s+n)}function Bc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(s-n)}function _c(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(s*64/n)}function Gc(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(s*n/64)}function Hc(e){let t=e.stack,n=t.pop();t.push(Math.abs(n))}function Vc(e){let t=e.stack,n=t.pop();t.push(-n)}function zc(e){let t=e.stack,n=t.pop();t.push(Math.floor(n/64)*64)}function jc(e){let t=e.stack,n=t.pop();t.push(Math.ceil(n/64)*64)}function ps(e,t){let n=t.stack,s=n.pop();n.push(t.round(s/64)*64)}function Wc(e){let t=e.stack,n=t.pop(),s=t.pop();e.cvt[s]=n*e.ppem/e.font.unitsPerEm}function Qs(e,t){let n=t.stack,s=n.pop(),r=t.ppem,o=t.deltaBase+(e-1)*16,i=t.deltaShift;for(let a=0;a>4)!==r)continue;let m=(c&15)-8;m>=0&&m++;let d=m*i;t.cvt[l]+=d}}function qc(e){let t=e.stack.pop();e.round=qo;let n;switch(t&192){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=n,t&48){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*n;break;case 32:e.srPhase=.5*n;break;case 48:e.srPhase=.75*n;break;default:throw new Error("invalid SROUND value")}t&=15,t===0?e.srThreshold=0:e.srThreshold=(t/8-.5)*n}function $c(e){let t=e.stack.pop();e.round=qo;let n;switch(t&192){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=n,t&48){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*n;break;case 32:e.srPhase=.5*n;break;case 48:e.srPhase=.75*n;break;default:throw new Error("invalid S45ROUND value")}t&=15,t===0?e.srThreshold=0:e.srThreshold=(t/8-.5)*n}function Xc(e){e.round=Lu}function Yc(e){e.round=Du}function Zc(e){e.round=Fu}function Kc(e){let t=e.stack.pop()}function li(e,t){let n=t.stack,s=n.pop(),r=n.pop(),o=t.z2[s],i=t.z1[r],a,l;e?(a=o.y-i.y,l=i.x-o.x):(a=i.x-o.x,l=i.y-o.y),t.dpv=Dn(a,l)}function Qc(e){let t=e.stack,n=t.pop(),s=0;n&1&&(s=35),n&32&&(s|=4096),t.push(s)}function Jc(e){let t=e.stack,n=t.pop(),s=t.pop(),r=t.pop();t.push(s),t.push(n),t.push(r)}function ef(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(Math.max(s,n))}function tf(e){let t=e.stack,n=t.pop(),s=t.pop();t.push(Math.min(s,n))}function nf(e){let t=e.stack.pop()}function sf(e){let t=e.stack.pop(),n=e.stack.pop();switch(t){case 1:e.inhibitGridFit=!!n;return;case 2:e.ignoreCvt=!!n;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Lt(e,t){let n=t.stack,s=t.prog,r=t.ip;for(let o=0;o=0?1:-1,I=Math.abs(I),e&&(P=o.cvt[a],s&&Math.abs(I-P)=0&&ethis[r[0]].apply(this,r.slice(1).concat(!0))),s=r=>typeof r=="object"&&Object.prototype.hasOwnProperty.call(r,"FAIL");if(n.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(s)};this.dispatch("composeRUD",[n.filter(r=>!s(r))])},he.prototype.replaceRange=function(e,t,n,s){t=t!==null?t:this.tokens.length;let r=n.every(o=>o instanceof dn);if(!isNaN(e)&&this.inboundIndex(e)&&r){let o=this.tokens.splice.apply(this.tokens,[e,t].concat(n));return s||this.dispatch("replaceToken",[e,t,n]),[o,n]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},he.prototype.replaceToken=function(e,t,n){if(!isNaN(e)&&this.inboundIndex(e)&&t instanceof dn){let s=this.tokens.splice(e,1,t);return n||this.dispatch("replaceToken",[e,t]),[s[0],t]}else return{FAIL:"replaceToken: invalid token or index."}},he.prototype.removeRange=function(e,t,n){t=isNaN(t)?this.tokens.length:t;let s=this.tokens.splice(e,t);return n||this.dispatch("removeRange",[s,e,t]),s},he.prototype.removeToken=function(e,t){if(!isNaN(e)&&this.inboundIndex(e)){let n=this.tokens.splice(e,1);return t||this.dispatch("removeToken",[n,e]),n}else return{FAIL:"removeToken: invalid token index."}},he.prototype.insertToken=function(e,t,n){return e.every(r=>r instanceof dn)?(this.tokens.splice.apply(this.tokens,[t,0].concat(e)),n||this.dispatch("insertToken",[e,t]),e):{FAIL:"insertToken: invalid token(s)."}},he.prototype.registerModifier=function(e,t,n){this.events.newToken.subscribe(function(s,r){let o=[s,r],i=t===null||t.apply(this,o)===!0,a=[s,r];if(i){let l=n.apply(this,a);s.setState(e,l)}}),this.registeredModifiers.push(e)},hs.prototype.subscribe=function(e){return typeof e=="function"?this.subscribers.push(e)-1:{FAIL:`invalid '${this.eventId}' event handler`}},hs.prototype.unsubscribe=function(e){this.subscribers.splice(e,1)},Re.prototype.setCurrentIndex=function(e){this.index=e,this.current=this.context[e],this.backtrack=this.context.slice(0,e),this.lookahead=this.context.slice(e+1)},Re.prototype.get=function(e){switch(!0){case e===0:return this.current;case(e<0&&Math.abs(e)<=this.backtrack.length):return this.backtrack.slice(e)[0];case(e>0&&e<=this.lookahead.length):return this.lookahead[e-1];default:return null}},he.prototype.rangeToText=function(e){if(e instanceof Js)return this.getRangeTokens(e).map(t=>t.char).join("")},he.prototype.getText=function(){return this.tokens.map(e=>e.char).join("")},he.prototype.getContext=function(e){let t=this.registeredContexts[e];return t||null},he.prototype.on=function(e,t){let n=this.events[e];return n?n.subscribe(t):null},he.prototype.dispatch=function(e,t){let n=this.events[e];if(n instanceof hs)for(let s=0;st.char);for(let t=0;t=r.start&&e<=r.end){let o=e-r.start;return r.index+o}}break}default:return-1}return-1}function cf(e,t){return Ut(e,t.coverage)===-1?null:e+t.deltaGlyphId}function ff(e,t){let n=Ut(e,t.coverage);return n===-1?null:t.substitute[n]}function er(e,t){let n=[];for(let s=0;s{let{lookupListIndex:m,sequenceIndex:d}=u,{subtables:x}=this.getLookupByIndex(m);for(let v of x)Ut(c[d],v.coverage)!==-1&&(c[d]=v.deltaGlyphId)};for(let c=0;cs.features[r]),this.features[e]=t,this.mapTagsToFeatures(t,e),t},He.prototype.getSubstitutionType=function(e,t){let n=e.lookupType.toString(),s=t.substFormat.toString();return n+s},He.prototype.getLookupMethod=function(e,t){let n=this.getSubstitutionType(e,t);switch(n){case"11":return s=>cf.apply(this,[s,t]);case"12":return s=>ff.apply(this,[s,t]);case"63":return s=>pf.apply(this,[s,t]);case"41":return s=>hf.apply(this,[s,t]);case"21":return s=>mf.apply(this,[s,t]);case"51":return s=>df.apply(this,[s,t]);case"53":return s=>gf.apply(this,[s,t]);default:throw new Error(`substitutionType : ${n} lookupType: ${e.lookupType} - substFormat: ${t.substFormat} is not yet supported`)}},He.prototype.lookupFeature=function(e){let t=e.contextParams,n=t.index,s=this.getFeature({tag:e.tag,script:e.script});if(!s)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${e.tag}' for script '${e.script}'.`);let r=this.getFeatureLookups(s),o=[].concat(t.context);for(let i=0;is.tag===e.tag);return t&&n},He.prototype.getLookupSubtables=function(e){return e.subtables||null},He.prototype.getLookupByIndex=function(e){return this.font.tables.gsub.lookups[e]||null},He.prototype.getFeatureLookups=function(e){return e.lookupListIndexes.map(this.getLookupByIndex.bind(this))},He.prototype.getFeature=function(t){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,t.script)||this.getScriptFeatures(t.script);let n=this.features[t.script];return n?n.tags[t.tag]?this.features[t.script].tags[t.tag]:null:{FAIL:`No feature for script ${t.script}`}};var yf=He;function bf(e){let t=e.current,n=e.get(-1);return n===null&&Rt(t)||!Rt(n)&&Rt(t)}function vf(e){let t=e.get(1);return t===null||!Rt(t)}var xf={startCheck:bf,endCheck:vf};function Sf(e){let t=e.current,n=e.get(-1);return(Rt(t)||Dt(t))&&!Rt(n)}function kf(e){let t=e.get(1);switch(!0){case t===null:return!0;case(!Rt(t)&&!Dt(t)):{let n=uf(t);if(!n)return!0;if(n){let s=!1;if(s=e.lookahead.some(r=>Rt(r)||Dt(r)),!s)return!0}break}default:return!1}}var Tf={startCheck:Sf,endCheck:kf};function Cf(e,t,n){t[n].setState(e.tag,e.substitution)}function Of(e,t,n){t[n].setState(e.tag,e.substitution)}function tr(e,t,n){for(let s=0;s=0;n--){let s=t[n],r=ui(s),o=Dt(s);if(!r&&!o)return!0;if(r)return!1}return!1}function Lf(e){if(ui(e.current))return!1;for(let t=0;ti.getState("glyphIndex")),0),o=new Re(s.map(i=>i.char),0);for(let i=0;is.activeState.value);return new Re(n,t||0)}function Df(e){let t="arab",n=this.tokenizer.getRangeTokens(e),s=fi(n);for(let r=0;r1}function Mf(e){return e.index===e.context.length-1}var Pf={startCheck:Uf,endCheck:Mf};function pi(e,t){let n=e.map(s=>s.activeState.value);return new Re(n,t||0)}function Nf(e){let t="delf",n="ccmp",s=this.tokenizer.getRangeTokens(e),r=pi(s);for(let o=0;os.activeState.value);return new Re(n,t||0)}function Vf(e){let t="latn",n=this.tokenizer.getRangeTokens(e),s=hi(n);for(let r=0;rs.activeState.value);return new Re(n,t||0)}function $f(e){let t="thai",n=this.tokenizer.getRangeTokens(e),s=di(n,0);for(let r=0;rs.activeState.value);return new Re(n,t||0)}function Yf(e){let t="thai",n=this.tokenizer.getRangeTokens(e),s=gi(n,0);for(let r=0;rs.activeState.value);return new Re(n,t||0)}function Kf(e){let t="thai",n=this.tokenizer.getRangeTokens(e),s=mi(n,0);for(let r=0;r=6155&&t<=6157||t>=65024&&t<=65039||t>=917760&&t<=917999}function Jf(e){let t=e.current,n=e.get(1);return n===null&&nr(t)||nr(n)}function ep(e){let t=e.get(1);return t===null||!nr(t)}var tp={startCheck:Jf,endCheck:ep};function np(e){let t=this.query.font,n=this.tokenizer.getRangeTokens(e);if(n[1].setState("deleted",!0),t.tables.cmap&&t.tables.cmap.varSelectorList){let s=n[0].char.codePointAt(0),r=n[1].char.codePointAt(0),o=t.tables.cmap.varSelectorList[r];if(o!==void 0&&o.nonDefaultUVS){let i=o.nonDefaultUVS.uvsMappings;if(i[s]){let a=i[s].glyphID;t.glyphs.glyphs[a]!==void 0&&n[0].setState("glyphIndex",a)}}}}var sp=np;function Ze(e){this.baseDir=e||"ltr",this.tokenizer=new lf,this.featuresTags={}}Ze.prototype.setText=function(e){this.text=e},Ze.prototype.contextChecks={ccmpReplacementCheck:Pf,latinWordCheck:Hf,arabicWordCheck:xf,arabicSentenceCheck:Tf,thaiWordCheck:qf,unicodeVariationSequenceCheck:tp};function gn(e){let t=this.contextChecks[`${e}Check`];return this.tokenizer.registerContextChecker(e,t.startCheck,t.endCheck)}function rp(){return gn.call(this,"ccmpReplacement"),gn.call(this,"latinWord"),gn.call(this,"arabicWord"),gn.call(this,"arabicSentence"),gn.call(this,"thaiWord"),gn.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function op(){let e=this.tokenizer.getContextRanges("arabicSentence");for(let t=0;tthis.query.supports({script:e,tag:s}));Object.prototype.hasOwnProperty.call(this.featuresTags,e)?this.featuresTags[e]=this.featuresTags[e].concat(n):this.featuresTags[e]=n},Ze.prototype.applyFeatures=function(e,t){if(!e)throw new Error("No valid font was provided to apply features");this.query||(this.query=new yf(e));for(let n=0;n0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=sr(e),this.names.macintosh=sr(e),this.names.windows=sr(e),this.unitsPerEm=e.unitsPerEm||1e3,this.ascender=e.ascender,this.descender=e.descender,this.createdTimestamp=e.createdTimestamp,this.italicAngle=e.italicAngle||0,this.weightClass=e.weightClass||0;let t=0;e.fsSelection?t=e.fsSelection:(this.italicAngle<0?t|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(t|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(t|=this.fsSelectionValues.BOLD),t===0&&(t=this.fsSelectionValues.REGULAR)),(!e.panose||!Array.isArray(e.panose))&&(e.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(e.tables,{os2:Object.assign({usWeightClass:e.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:e.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:e.panose[0]||0,bSerifStyle:e.panose[1]||0,bWeight:e.panose[2]||0,bProportion:e.panose[3]||0,bContrast:e.panose[4]||0,bStrokeVariation:e.panose[5]||0,bArmStyle:e.panose[6]||0,bLetterform:e.panose[7]||0,bMidline:e.panose[8]||0,bXHeight:e.panose[9]||0,fsSelection:t},e.tables.os2)})}this.supported=!0,this.glyphs=new mt.GlyphSet(this,e.glyphs||[]),this.encoding=new qr(this),this.position=new iu(this),this.substitution=new hu(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(t,n,s)=>(t[n]=s,t.fvar&&(t.gvar||t.cff2)&&!this.variation&&(this.variation=new Eu(this)),!0)}),this.palettes=new Po(this),this.layers=new du(this),this.svgImages=new gu(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new rf(this):null}})}oe.prototype.hasChar=function(e){return this.encoding.charToGlyphIndex(e)>0},oe.prototype.charToGlyphIndex=function(e){return this.encoding.charToGlyphIndex(e)},oe.prototype.charToGlyph=function(e){let t=this.charToGlyphIndex(e),n=this.glyphs.get(t);return n||(n=this.glyphs.get(0)),n},oe.prototype.updateFeatures=function(e){return this.defaultRenderOptions.features.map(t=>t.script==="latn"?{script:"latn",tags:t.tags.filter(n=>e[n])}:t)},oe.prototype.stringToGlyphIndexes=function(e,t){let n=new pp,s=o=>this.charToGlyphIndex(o.char);n.registerModifier("glyphIndex",null,s);let r=t?this.updateFeatures(t.features):this.defaultRenderOptions.features;return n.applyFeatures(this,r),n.getTextGlyphs(e)},oe.prototype.stringToGlyphs=function(e,t){let n=this.stringToGlyphIndexes(e,t),s=n.length,r=new Array(s),o=this.glyphs.get(0);for(let i=0;i{let u=i.getPath(a,l,c,r,this);if(r.drawSVG||r.drawLayers){let m=u._layers;if(m&&m.length){for(let d=0;d0,"No English "+r+" specified.")}if(s("fontFamily"),s("weightName"),s("manufacturer"),s("copyright"),s("version"),n(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let r=this.tables.colr.baseGlyphRecords,o=-1;for(let i=0;ir[i].glyphID)break;o=a}}return e},oe.prototype.toTables=function(){return ou.fontToTable(this)},oe.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},oe.prototype.toArrayBuffer=function(){let t=this.toTables().encode(),n=new ArrayBuffer(t.length),s=new Uint8Array(n);for(let r=0;r=1.2&&(r.markGlyphSets=n.parsePointer(xp)),r}var kp={parse:Sp},rt=new Array(10);rt[1]=function(){let t=this.offset+this.relativeOffset,n=this.parseUShort();if(n===1)return{posFormat:1,coverage:this.parsePointer(C.coverage),value:this.parseValueRecord()};if(n===2)return{posFormat:2,coverage:this.parsePointer(C.coverage),values:this.parseValueRecordList()};B.assert(!1,"0x"+t.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},rt[2]=function(){let t=this.offset+this.relativeOffset,n=this.parseUShort();B.assert(n===1||n===2,"0x"+t.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let s=this.parsePointer(C.coverage),r=this.parseUShort(),o=this.parseUShort();if(n===1)return{posFormat:n,coverage:s,valueFormat1:r,valueFormat2:o,pairSets:this.parseList(C.pointer(C.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(r),value2:this.parseValueRecord(o)}})))};if(n===2){let i=this.parsePointer(C.classDef),a=this.parsePointer(C.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:n,coverage:s,valueFormat1:r,valueFormat2:o,classDef1:i,classDef2:a,class1Count:l,class2Count:c,classRecords:this.parseList(l,C.list(c,function(){return{value1:this.parseValueRecord(r),value2:this.parseValueRecord(o)}}))}}},rt[3]=function(){return{error:"GPOS Lookup 3 not supported"}},rt[4]=function(){return{error:"GPOS Lookup 4 not supported"}},rt[5]=function(){return{error:"GPOS Lookup 5 not supported"}},rt[6]=function(){return{error:"GPOS Lookup 6 not supported"}},rt[7]=function(){return{error:"GPOS Lookup 7 not supported"}},rt[8]=function(){return{error:"GPOS Lookup 8 not supported"}},rt[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Tp(e,t){t=t||0;let n=new C(e,t),s=n.parseVersion(1);return B.argument(s===1||s===1.1,"Unsupported GPOS table version "+s),s===1?{version:s,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(rt)}:{version:s,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(rt),variations:n.parseFeatureVariationsList()}}var Cp=new Array(10);function Op(e){return new A.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new A.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new A.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new A.LookupList(e.lookups,Cp)}])}var Ip={parse:Tp,make:Op};function wp(e){let t={};e.skip("uShort");let n=e.parseUShort();B.argument(n===0,"Unsupported kern sub-table version."),e.skip("uShort",2);let s=e.parseUShort();e.skip("uShort",3);for(let r=0;r1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");let r=e.parseUShort()&255;if(e.skip("uShort"),r===0){let o=e.parseUShort();e.skip("uShort",3);for(let i=0;i({...Ti,default:Ti}))});var Gi=qp(Oi());import{tracingChannel as $p,channel as Xp}from"node:diagnostics_channel";var Ce=Xp("lru-cache:metrics"),Mn=$p("lru-cache"),Yp=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,lr=()=>Ce.hasSubscribers||Mn.hasSubscribers,Li=new Set,Ii=typeof process=="object"&&process?process:{},Zp=(g,f,p,h)=>{typeof Ii.emitWarning=="function"?Ii.emitWarning(g,f,p,h):console.error(`[${p}] ${f}: ${g}`)},Kp=g=>!Li.has(g),Pt=g=>!!g&&g===Math.floor(g)&&g>0&&isFinite(g),Ai=g=>Pt(g)?g<=Math.pow(2,8)?Uint8Array:g<=Math.pow(2,16)?Uint16Array:g<=Math.pow(2,32)?Uint32Array:g<=Number.MAX_SAFE_INTEGER?Ss:null:null,Ss=class extends Array{constructor(g){super(g),this.fill(0)}},xt,bn,Qp=(xt=class{constructor(f,p){ye(this,"heap");ye(this,"length");if(!b(xt,bn))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new p(f),this.length=0}static create(f){let p=Ai(f);if(!p)return[];V(xt,bn,!0);let h=new xt(f,p);return V(xt,bn,!1),h}push(f){this.heap[this.length++]=f}pop(){return this.heap[--this.length]}},bn=new WeakMap,K(xt,bn,!1),xt),wi,Ei,et,je,lt,Jt,ut,vn,xn,ct,xe,ft,be,ce,q,Pe,We,Ae,ke,pt,Te,ht,dt,qe,$e,gt,Sn,Ne,en,L,ur,tn,Ot,Bn,Xe,Di,nn,kn,_n,Nt,Bt,cr,yn,ks,Fi,Ui,Ts,ue,fr,Mi,Pi,Pn,pr,Nn,_t,hr,Tn,Ri=(Tn=class{constructor(f){K(this,L);K(this,et);K(this,je);K(this,lt);K(this,Jt);K(this,ut);K(this,vn);K(this,xn);K(this,ct);ye(this,"ttl");ye(this,"ttlResolution");ye(this,"ttlAutopurge");ye(this,"updateAgeOnGet");ye(this,"updateAgeOnHas");ye(this,"allowStale");ye(this,"noDisposeOnSet");ye(this,"noUpdateTTL");ye(this,"maxEntrySize");ye(this,"sizeCalculation");ye(this,"noDeleteOnFetchRejection");ye(this,"noDeleteOnStaleGet");ye(this,"allowStaleOnFetchAbort");ye(this,"allowStaleOnFetchRejection");ye(this,"ignoreFetchAbort");ye(this,"backgroundFetchSize");K(this,xe);K(this,ft);K(this,be);K(this,ce);K(this,q);K(this,Pe);K(this,We);K(this,Ae);K(this,ke);K(this,pt);K(this,Te);K(this,ht);K(this,dt);K(this,qe);K(this,$e);K(this,gt);K(this,Sn);K(this,Ne);K(this,en);K(this,tn,()=>{});K(this,Ot,()=>{});K(this,Bn,()=>{});K(this,Xe,()=>!1);K(this,nn,f=>{});K(this,kn,(f,p,h)=>{});K(this,_n,(f,p,h,y)=>{if(h||y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});ye(this,wi,"LRUCache");let{max:p=0,ttl:h,ttlResolution:y=1,ttlAutopurge:k,updateAgeOnGet:T,updateAgeOnHas:O,allowStale:w,dispose:E,onInsert:j,disposeAfter:H,noDisposeOnSet:Q,noUpdateTTL:X,maxSize:fe=0,maxEntrySize:J=0,sizeCalculation:Se,fetchMethod:$,memoMethod:ee,noDeleteOnFetchRejection:ne,noDeleteOnStaleGet:se,allowStaleOnFetchRejection:pe,allowStaleOnFetchAbort:Vt,ignoreFetchAbort:St,backgroundFetchSize:It=1,perf:wt}=f;if(this.backgroundFetchSize=It,wt!==void 0&&typeof wt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(V(this,ct,wt??Yp),p!==0&&!Pt(p))throw new TypeError("max option must be a nonnegative integer");let Be=p?Ai(p):Array;if(!Be)throw new Error("invalid max value: "+p);if(V(this,et,p),V(this,je,fe),this.maxEntrySize=J||b(this,je),this.sizeCalculation=Se,this.sizeCalculation){if(!b(this,je)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(ee!==void 0&&typeof ee!="function")throw new TypeError("memoMethod must be a function if defined");if(V(this,xn,ee),$!==void 0&&typeof $!="function")throw new TypeError("fetchMethod must be a function if specified");if(V(this,vn,$),V(this,Sn,!!$),V(this,be,new Map),V(this,ce,Array.from({length:p}).fill(void 0)),V(this,q,Array.from({length:p}).fill(void 0)),V(this,Pe,new Be(p)),V(this,We,new Be(p)),V(this,Ae,0),V(this,ke,0),V(this,pt,Qp.create(p)),V(this,xe,0),V(this,ft,0),typeof E=="function"&&V(this,lt,E),typeof j=="function"&&V(this,Jt,j),typeof H=="function"?(V(this,ut,H),V(this,Te,[])):(V(this,ut,void 0),V(this,Te,void 0)),V(this,gt,!!b(this,lt)),V(this,en,!!b(this,Jt)),V(this,Ne,!!b(this,ut)),this.noDisposeOnSet=!!Q,this.noUpdateTTL=!!X,this.noDeleteOnFetchRejection=!!ne,this.allowStaleOnFetchRejection=!!pe,this.allowStaleOnFetchAbort=!!Vt,this.ignoreFetchAbort=!!St,this.maxEntrySize!==0){if(b(this,je)!==0&&!Pt(b(this,je)))throw new TypeError("maxSize must be a positive integer if specified");if(!Pt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");R(this,L,Di).call(this)}if(this.allowStale=!!w,this.noDeleteOnStaleGet=!!se,this.updateAgeOnGet=!!T,this.updateAgeOnHas=!!O,this.ttlResolution=Pt(y)||y===0?y:1,this.ttlAutopurge=!!k,this.ttl=h||0,this.ttl){if(!Pt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");R(this,L,ur).call(this)}if(b(this,et)===0&&this.ttl===0&&b(this,je)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!b(this,et)&&!b(this,je)){let zt="LRU_CACHE_UNBOUNDED";Kp(zt)&&(Li.add(zt),Zp("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",zt,Tn))}}get perf(){return b(this,ct)}static unsafeExposeInternals(f){return{starts:b(f,dt),ttls:b(f,qe),autopurgeTimers:b(f,$e),sizes:b(f,ht),keyMap:b(f,be),keyList:b(f,ce),valList:b(f,q),next:b(f,Pe),prev:b(f,We),get head(){return b(f,Ae)},get tail(){return b(f,ke)},free:b(f,pt),isBackgroundFetch:p=>{var h;return R(h=f,L,ue).call(h,p)},backgroundFetch:(p,h,y,k)=>{var T;return R(T=f,L,Ts).call(T,p,h,y,k)},moveToTail:p=>{var h;return R(h=f,L,Nn).call(h,p)},indexes:p=>{var h;return R(h=f,L,Nt).call(h,p)},rindexes:p=>{var h;return R(h=f,L,Bt).call(h,p)},isStale:p=>{var h;return b(h=f,Xe).call(h,p)}}}get max(){return b(this,et)}get maxSize(){return b(this,je)}get calculatedSize(){return b(this,ft)}get size(){return b(this,xe)}get fetchMethod(){return b(this,vn)}get memoMethod(){return b(this,xn)}get dispose(){return b(this,lt)}get onInsert(){return b(this,Jt)}get disposeAfter(){return b(this,ut)}getRemainingTTL(f){return b(this,be).has(f)?1/0:0}*entries(){for(let f of R(this,L,Nt).call(this))b(this,q)[f]!==void 0&&b(this,ce)[f]!==void 0&&!R(this,L,ue).call(this,b(this,q)[f])&&(yield[b(this,ce)[f],b(this,q)[f]])}*rentries(){for(let f of R(this,L,Bt).call(this))b(this,q)[f]!==void 0&&b(this,ce)[f]!==void 0&&!R(this,L,ue).call(this,b(this,q)[f])&&(yield[b(this,ce)[f],b(this,q)[f]])}*keys(){for(let f of R(this,L,Nt).call(this)){let p=b(this,ce)[f];p!==void 0&&!R(this,L,ue).call(this,b(this,q)[f])&&(yield p)}}*rkeys(){for(let f of R(this,L,Bt).call(this)){let p=b(this,ce)[f];p!==void 0&&!R(this,L,ue).call(this,b(this,q)[f])&&(yield p)}}*values(){for(let f of R(this,L,Nt).call(this))b(this,q)[f]!==void 0&&!R(this,L,ue).call(this,b(this,q)[f])&&(yield b(this,q)[f])}*rvalues(){for(let f of R(this,L,Bt).call(this))b(this,q)[f]!==void 0&&!R(this,L,ue).call(this,b(this,q)[f])&&(yield b(this,q)[f])}[(Ei=Symbol.iterator,wi=Symbol.toStringTag,Ei)](){return this.entries()}find(f,p={}){for(let h of R(this,L,Nt).call(this)){let y=b(this,q)[h],k=R(this,L,ue).call(this,y)?y.__staleWhileFetching:y;if(k!==void 0&&f(k,b(this,ce)[h],this))return R(this,L,Pn).call(this,b(this,ce)[h],p)}}forEach(f,p=this){for(let h of R(this,L,Nt).call(this)){let y=b(this,q)[h],k=R(this,L,ue).call(this,y)?y.__staleWhileFetching:y;k!==void 0&&f.call(p,k,b(this,ce)[h],this)}}rforEach(f,p=this){for(let h of R(this,L,Bt).call(this)){let y=b(this,q)[h],k=R(this,L,ue).call(this,y)?y.__staleWhileFetching:y;k!==void 0&&f.call(p,k,b(this,ce)[h],this)}}purgeStale(){let f=!1;for(let p of R(this,L,Bt).call(this,{allowStale:!0}))b(this,Xe).call(this,p)&&(R(this,L,_t).call(this,b(this,ce)[p],"expire"),f=!0);return f}info(f){let p=b(this,be).get(f);if(p===void 0)return;let h=b(this,q)[p],y=R(this,L,ue).call(this,h)?h.__staleWhileFetching:h;if(y===void 0)return;let k={value:y};if(b(this,qe)&&b(this,dt)){let T=b(this,qe)[p],O=b(this,dt)[p];if(T&&O){let w=T-(b(this,ct).now()-O);k.ttl=w,k.start=Date.now()}}return b(this,ht)&&(k.size=b(this,ht)[p]),k}dump(){let f=[];for(let p of R(this,L,Nt).call(this,{allowStale:!0})){let h=b(this,ce)[p],y=b(this,q)[p],k=R(this,L,ue).call(this,y)?y.__staleWhileFetching:y;if(k===void 0||h===void 0)continue;let T={value:k};if(b(this,qe)&&b(this,dt)){T.ttl=b(this,qe)[p];let O=b(this,ct).now()-b(this,dt)[p];T.start=Math.floor(Date.now()-O)}b(this,ht)&&(T.size=b(this,ht)[p]),f.unshift([h,T])}return f}load(f){this.clear();for(let[p,h]of f){if(h.start){let y=Date.now()-h.start;h.start=b(this,ct).now()-y}R(this,L,yn).call(this,p,h.value,h)}}set(f,p,h={}){let{status:y=Ce.hasSubscribers?{}:void 0}=h;h.status=y,y&&(y.op="set",y.key=f,p!==void 0&&(y.value=p),y.cache=this);let k=R(this,L,yn).call(this,f,p,h);return y&&Ce.hasSubscribers&&Ce.publish(y),k}pop(){var f;try{for(;b(this,xe);){let p=b(this,q)[b(this,Ae)];if(R(this,L,ks).call(this,!0),R(this,L,ue).call(this,p)){if(p.__staleWhileFetching)return p.__staleWhileFetching}else if(p!==void 0)return p}}finally{if(b(this,Ne)&&b(this,Te)){let p=b(this,Te),h;for(;h=p?.shift();)(f=b(this,ut))==null||f.call(this,...h)}}}has(f,p={}){let{status:h=Ce.hasSubscribers?{}:void 0}=p;p.status=h,h&&(h.op="has",h.key=f,h.cache=this);let y=R(this,L,Fi).call(this,f,p);return Ce.hasSubscribers&&Ce.publish(h),y}peek(f,p={}){let{status:h=lr()?{}:void 0}=p;h&&(h.op="peek",h.key=f,h.cache=this),p.status=h;let y=R(this,L,Ui).call(this,f,p);return Ce.hasSubscribers&&Ce.publish(h),y}fetch(f,p={}){let h=Mn.hasSubscribers,{status:y=lr()?{}:void 0}=p;p.status=y,y&&p.context&&(y.context=p.context);let k=R(this,L,fr).call(this,f,p);return y&&h&&(y.trace=!0,Mn.tracePromise(()=>k,y).catch(()=>{})),k}forceFetch(f,p={}){let h=Mn.hasSubscribers,{status:y=lr()?{}:void 0}=p;p.status=y,y&&p.context&&(y.context=p.context);let k=R(this,L,Mi).call(this,f,p);return y&&h&&(y.trace=!0,Mn.tracePromise(()=>k,y).catch(()=>{})),k}memo(f,p={}){let{status:h=Ce.hasSubscribers?{}:void 0}=p;p.status=h,h&&(h.op="memo",h.key=f,p.context&&(h.context=p.context),h.cache=this);let y=R(this,L,Pi).call(this,f,p);return h&&(h.value=y),Ce.hasSubscribers&&Ce.publish(h),y}get(f,p={}){let{status:h=Ce.hasSubscribers?{}:void 0}=p;p.status=h,h&&(h.op="get",h.key=f,h.cache=this);let y=R(this,L,Pn).call(this,f,p);return h&&(y!==void 0&&(h.value=y),Ce.hasSubscribers&&Ce.publish(h)),y}delete(f){return R(this,L,_t).call(this,f,"delete")}clear(){return R(this,L,hr).call(this,"delete")}},et=new WeakMap,je=new WeakMap,lt=new WeakMap,Jt=new WeakMap,ut=new WeakMap,vn=new WeakMap,xn=new WeakMap,ct=new WeakMap,xe=new WeakMap,ft=new WeakMap,be=new WeakMap,ce=new WeakMap,q=new WeakMap,Pe=new WeakMap,We=new WeakMap,Ae=new WeakMap,ke=new WeakMap,pt=new WeakMap,Te=new WeakMap,ht=new WeakMap,dt=new WeakMap,qe=new WeakMap,$e=new WeakMap,gt=new WeakMap,Sn=new WeakMap,Ne=new WeakMap,en=new WeakMap,L=new WeakSet,ur=function(){let f=new Ss(b(this,et)),p=new Ss(b(this,et));V(this,qe,f),V(this,dt,p);let h=this.ttlAutopurge?Array.from({length:b(this,et)}):void 0;V(this,$e,h),V(this,Bn,(O,w,E=b(this,ct).now())=>{p[O]=w!==0?E:0,f[O]=w,y(O,w)}),V(this,tn,O=>{p[O]=f[O]!==0?b(this,ct).now():0,y(O,f[O])});let y=this.ttlAutopurge?(O,w)=>{if(h?.[O]&&(clearTimeout(h[O]),h[O]=void 0),w&&w!==0&&h){let E=setTimeout(()=>{b(this,Xe).call(this,O)&&R(this,L,_t).call(this,b(this,ce)[O],"expire")},w+1);E.unref&&E.unref(),h[O]=E}}:()=>{};V(this,Ot,(O,w)=>{if(f[w]){let E=f[w],j=p[w];if(!E||!j)return;O.ttl=E,O.start=j,O.now=k||T();let H=O.now-j;O.remainingTTL=E-H}});let k=0,T=()=>{let O=b(this,ct).now();if(this.ttlResolution>0){k=O;let w=setTimeout(()=>k=0,this.ttlResolution);w.unref&&w.unref()}return O};this.getRemainingTTL=O=>{let w=b(this,be).get(O);if(w===void 0)return 0;let E=f[w],j=p[w];if(!E||!j)return 1/0;let H=(k||T())-j;return E-H},V(this,Xe,O=>{let w=p[O],E=f[O];return!!E&&!!w&&(k||T())-w>E})},tn=new WeakMap,Ot=new WeakMap,Bn=new WeakMap,Xe=new WeakMap,Di=function(){let f=new Ss(b(this,et));V(this,ft,0),V(this,ht,f),V(this,nn,p=>{V(this,ft,b(this,ft)-f[p]),f[p]=0}),V(this,_n,(p,h,y,k)=>{if(!Pt(y)){if(R(this,L,ue).call(this,h))return this.backgroundFetchSize;if(k){if(typeof k!="function")throw new TypeError("sizeCalculation must be a function");if(y=k(h,p),!Pt(y))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return y}),V(this,kn,(p,h,y)=>{if(f[p]=h,b(this,je)){let k=b(this,je)-f[p];for(;b(this,ft)>k;)R(this,L,ks).call(this,!0)}V(this,ft,b(this,ft)+f[p]),y&&(y.entrySize=h,y.totalCalculatedSize=b(this,ft))})},nn=new WeakMap,kn=new WeakMap,_n=new WeakMap,Nt=function*({allowStale:f=this.allowStale}={}){if(b(this,xe))for(let p=b(this,ke);R(this,L,cr).call(this,p)&&((f||!b(this,Xe).call(this,p))&&(yield p),p!==b(this,Ae));)p=b(this,We)[p]},Bt=function*({allowStale:f=this.allowStale}={}){if(b(this,xe))for(let p=b(this,Ae);R(this,L,cr).call(this,p)&&((f||!b(this,Xe).call(this,p))&&(yield p),p!==b(this,ke));)p=b(this,Pe)[p]},cr=function(f){return f!==void 0&&b(this,be).get(b(this,ce)[f])===f},yn=function(f,p,h,y){var fe,J,Se,$;let{ttl:k=this.ttl,start:T,noDisposeOnSet:O=this.noDisposeOnSet,sizeCalculation:w=this.sizeCalculation,status:E}=h,j=R(this,L,ue).call(this,p);if(p===void 0)return E&&(E.set="deleted"),this.delete(f),this;let{noUpdateTTL:H=this.noUpdateTTL}=h;E&&!j&&(E.value=p);let Q=b(this,_n).call(this,f,p,h.size||0,w,E);if(this.maxEntrySize&&Q>this.maxEntrySize)return R(this,L,_t).call(this,f,"set"),E&&(E.set="miss",E.maxEntrySizeExceeded=!0),this;let X=b(this,xe)===0?void 0:b(this,be).get(f);if(X===void 0)X=b(this,xe)===0?b(this,ke):b(this,pt).length!==0?b(this,pt).pop():b(this,xe)===b(this,et)?R(this,L,ks).call(this,!1):b(this,xe),b(this,ce)[X]=f,b(this,q)[X]=p,b(this,be).set(f,X),b(this,Pe)[b(this,ke)]=X,b(this,We)[X]=b(this,ke),V(this,ke,X),vs(this,xe)._++,b(this,kn).call(this,X,Q,E),E&&(E.set="add"),H=!1,b(this,en)&&!j&&((fe=b(this,Jt))==null||fe.call(this,p,f,"add"));else{R(this,L,Nn).call(this,X);let ee=b(this,q)[X];if(p!==ee){if(!O)if(R(this,L,ue).call(this,ee)){ee!==y&&ee.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:ne}=ee;ne!==void 0&&ne!==p&&(b(this,gt)&&((J=b(this,lt))==null||J.call(this,ne,f,"set")),b(this,Ne)&&b(this,Te)?.push([ne,f,"set"]))}else b(this,gt)&&((Se=b(this,lt))==null||Se.call(this,ee,f,"set")),b(this,Ne)&&b(this,Te)?.push([ee,f,"set"]);if(b(this,nn).call(this,X),b(this,kn).call(this,X,Q,E),b(this,q)[X]=p,!j){let ne=ee&&R(this,L,ue).call(this,ee)?ee.__staleWhileFetching:ee,se=ne===void 0?"add":p!==ne?"replace":"update";E&&(E.set=se,ne!==void 0&&(E.oldValue=ne)),b(this,en)&&this.onInsert?.(p,f,se)}}else j||(E&&(E.set="update"),b(this,en)&&this.onInsert?.(p,f,"update"))}if(k!==0&&!b(this,qe)&&R(this,L,ur).call(this),b(this,qe)&&(H||b(this,Bn).call(this,X,k,T),E&&b(this,Ot).call(this,E,X)),!O&&b(this,Ne)&&b(this,Te)){let ee=b(this,Te),ne;for(;ne=ee?.shift();)($=b(this,ut))==null||$.call(this,...ne)}return this},ks=function(f){var O;let p=b(this,Ae),h=b(this,ce)[p],y=b(this,q)[p],k=R(this,L,ue).call(this,y);k&&y.__abortController.abort(new Error("evicted"));let T=k?y.__staleWhileFetching:y;return(b(this,gt)||b(this,Ne))&&T!==void 0&&(b(this,gt)&&((O=b(this,lt))==null||O.call(this,T,h,"evict")),b(this,Ne)&&b(this,Te)?.push([T,h,"evict"])),b(this,nn).call(this,p),b(this,$e)?.[p]&&(clearTimeout(b(this,$e)[p]),b(this,$e)[p]=void 0),f&&(b(this,ce)[p]=void 0,b(this,q)[p]=void 0,b(this,pt).push(p)),b(this,xe)===1?(V(this,Ae,V(this,ke,0)),b(this,pt).length=0):V(this,Ae,b(this,Pe)[p]),b(this,be).delete(h),vs(this,xe)._--,p},Fi=function(f,p={}){let{updateAgeOnHas:h=this.updateAgeOnHas,status:y}=p,k=b(this,be).get(f);if(k!==void 0){let T=b(this,q)[k];if(R(this,L,ue).call(this,T)&&T.__staleWhileFetching===void 0)return!1;if(b(this,Xe).call(this,k))y&&(y.has="stale",b(this,Ot).call(this,y,k));else return h&&b(this,tn).call(this,k),y&&(y.has="hit",b(this,Ot).call(this,y,k)),!0}else y&&(y.has="miss");return!1},Ui=function(f,p){let{status:h,allowStale:y=this.allowStale}=p,k=b(this,be).get(f);if(k===void 0||!y&&b(this,Xe).call(this,k)){h&&(h.peek=k===void 0?"miss":"stale");return}let T=b(this,q)[k],O=R(this,L,ue).call(this,T)?T.__staleWhileFetching:T;return h&&(O!==void 0?(h.peek="hit",h.value=O):h.peek="miss"),O},Ts=function(f,p,h,y){let k=p===void 0?void 0:b(this,q)[p];if(R(this,L,ue).call(this,k))return k;let T=new AbortController,{signal:O}=h;O?.addEventListener("abort",()=>T.abort(O.reason),{signal:T.signal});let w={signal:T.signal,options:h,context:y},E=(J,Se=!1)=>{let{aborted:$}=T.signal,ee=h.ignoreFetchAbort&&J!==void 0,ne=h.ignoreFetchAbort||!!(h.allowStaleOnFetchAbort&&J!==void 0);if(h.status&&($&&!Se?(h.status.fetchAborted=!0,h.status.fetchError=T.signal.reason,ee&&(h.status.fetchAbortIgnored=!0)):h.status.fetchResolved=!0),$&&!ee&&!Se)return H(T.signal.reason,ne);let se=X,pe=b(this,q)[p];return(pe===X||pe===void 0&&ee&&Se)&&(J===void 0?se.__staleWhileFetching!==void 0?b(this,q)[p]=se.__staleWhileFetching:R(this,L,_t).call(this,f,"fetch"):(h.status&&(h.status.fetchUpdated=!0),R(this,L,yn).call(this,f,J,w.options,se))),J},j=J=>(h.status&&(h.status.fetchRejected=!0,h.status.fetchError=J),H(J,!1)),H=(J,Se)=>{let{aborted:$}=T.signal,ee=$&&h.allowStaleOnFetchAbort,ne=ee||h.allowStaleOnFetchRejection,se=ne||h.noDeleteOnFetchRejection,pe=X;if(b(this,q)[p]===X&&(!se||!Se&&pe.__staleWhileFetching===void 0?R(this,L,_t).call(this,f,"fetch"):ee||(b(this,q)[p]=pe.__staleWhileFetching)),ne)return h.status&&pe.__staleWhileFetching!==void 0&&(h.status.returnedStale=!0),pe.__staleWhileFetching;if(pe.__returned===pe)throw J},Q=(J,Se)=>{var ee;let $=(ee=b(this,vn))==null?void 0:ee.call(this,f,k,w);T.signal.addEventListener("abort",()=>{(!h.ignoreFetchAbort||h.allowStaleOnFetchAbort)&&(J(void 0),h.allowStaleOnFetchAbort&&(J=ne=>E(ne,!0)))}),$&&$ instanceof Promise?$.then(ne=>J(ne===void 0?void 0:ne),Se):$!==void 0&&J($)};h.status&&(h.status.fetchDispatched=!0);let X=new Promise(Q).then(E,j),fe=Object.assign(X,{__abortController:T,__staleWhileFetching:k,__returned:void 0});return p===void 0?(R(this,L,yn).call(this,f,fe,{...w.options,status:void 0}),p=b(this,be).get(f)):b(this,q)[p]=fe,fe},ue=function(f){if(!b(this,Sn))return!1;let p=f;return!!p&&p instanceof Promise&&p.hasOwnProperty("__staleWhileFetching")&&p.__abortController instanceof AbortController},fr=async function(f,p={}){let{allowStale:h=this.allowStale,updateAgeOnGet:y=this.updateAgeOnGet,noDeleteOnStaleGet:k=this.noDeleteOnStaleGet,ttl:T=this.ttl,noDisposeOnSet:O=this.noDisposeOnSet,size:w=0,sizeCalculation:E=this.sizeCalculation,noUpdateTTL:j=this.noUpdateTTL,noDeleteOnFetchRejection:H=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Q=this.allowStaleOnFetchRejection,ignoreFetchAbort:X=this.ignoreFetchAbort,allowStaleOnFetchAbort:fe=this.allowStaleOnFetchAbort,context:J,forceRefresh:Se=!1,status:$,signal:ee}=p;if($&&($.op="fetch",$.key=f,Se&&($.forceRefresh=!0),$.cache=this),!b(this,Sn))return $&&($.fetch="get"),R(this,L,Pn).call(this,f,{allowStale:h,updateAgeOnGet:y,noDeleteOnStaleGet:k,status:$});let ne={allowStale:h,updateAgeOnGet:y,noDeleteOnStaleGet:k,ttl:T,noDisposeOnSet:O,size:w,sizeCalculation:E,noUpdateTTL:j,noDeleteOnFetchRejection:H,allowStaleOnFetchRejection:Q,allowStaleOnFetchAbort:fe,ignoreFetchAbort:X,status:$,signal:ee},se=b(this,be).get(f);if(se===void 0){$&&($.fetch="miss");let pe=R(this,L,Ts).call(this,f,se,ne,J);return pe.__returned=pe}else{let pe=b(this,q)[se];if(R(this,L,ue).call(this,pe)){let wt=h&&pe.__staleWhileFetching!==void 0;return $&&($.fetch="inflight",wt&&($.returnedStale=!0)),wt?pe.__staleWhileFetching:pe.__returned=pe}let Vt=b(this,Xe).call(this,se);if(!Se&&!Vt)return $&&($.fetch="hit"),R(this,L,Nn).call(this,se),y&&b(this,tn).call(this,se),$&&b(this,Ot).call(this,$,se),pe;let St=R(this,L,Ts).call(this,f,se,ne,J),It=St.__staleWhileFetching!==void 0&&h;return $&&($.fetch=Vt?"stale":"refresh",It&&Vt&&($.returnedStale=!0)),It?St.__staleWhileFetching:St.__returned=St}},Mi=async function(f,p={}){let h=await R(this,L,fr).call(this,f,p);if(h===void 0)throw new Error("fetch() returned undefined");return h},Pi=function(f,p={}){let h=b(this,xn);if(!h)throw new Error("no memoMethod provided to constructor");let{context:y,status:k,forceRefresh:T,...O}=p;k&&T&&(k.forceRefresh=!0);let w=R(this,L,Pn).call(this,f,O),E=T||w===void 0;if(k&&(k.memo=E?"miss":"hit",E||(k.value=w)),!E)return w;let j=h(f,w,{options:O,context:y});return k&&(k.value=j),R(this,L,yn).call(this,f,j,O),j},Pn=function(f,p={}){let{allowStale:h=this.allowStale,updateAgeOnGet:y=this.updateAgeOnGet,noDeleteOnStaleGet:k=this.noDeleteOnStaleGet,status:T}=p,O=b(this,be).get(f);if(O===void 0){T&&(T.get="miss");return}let w=b(this,q)[O],E=R(this,L,ue).call(this,w);return T&&b(this,Ot).call(this,T,O),b(this,Xe).call(this,O)?E?(T&&(T.get="stale-fetching"),h&&w.__staleWhileFetching!==void 0?(T&&(T.returnedStale=!0),w.__staleWhileFetching):void 0):(k||R(this,L,_t).call(this,f,"expire"),T&&(T.get="stale"),h?(T&&(T.returnedStale=!0),w):void 0):(T&&(T.get=E?"fetching":"hit"),R(this,L,Nn).call(this,O),y&&b(this,tn).call(this,O),E?w.__staleWhileFetching:w)},pr=function(f,p){b(this,We)[p]=f,b(this,Pe)[f]=p},Nn=function(f){f!==b(this,ke)&&(f===b(this,Ae)?V(this,Ae,b(this,Pe)[f]):R(this,L,pr).call(this,b(this,We)[f],b(this,Pe)[f]),R(this,L,pr).call(this,b(this,ke),f),V(this,ke,f))},_t=function(f,p){var y,k;Ce.hasSubscribers&&Ce.publish({op:"delete",delete:p,key:f,cache:this});let h=!1;if(b(this,xe)!==0){let T=b(this,be).get(f);if(T!==void 0)if(b(this,$e)?.[T]&&(clearTimeout(b(this,$e)?.[T]),b(this,$e)[T]=void 0),h=!0,b(this,xe)===1)R(this,L,hr).call(this,p);else{b(this,nn).call(this,T);let O=b(this,q)[T];if(R(this,L,ue).call(this,O)?O.__abortController.abort(new Error("deleted")):(b(this,gt)||b(this,Ne))&&(b(this,gt)&&((y=b(this,lt))==null||y.call(this,O,f,p)),b(this,Ne)&&b(this,Te)?.push([O,f,p])),b(this,be).delete(f),b(this,ce)[T]=void 0,b(this,q)[T]=void 0,T===b(this,ke))V(this,ke,b(this,We)[T]);else if(T===b(this,Ae))V(this,Ae,b(this,Pe)[T]);else{let w=b(this,We)[T];b(this,Pe)[w]=b(this,Pe)[T];let E=b(this,Pe)[T];b(this,We)[E]=b(this,We)[T]}vs(this,xe)._--,b(this,pt).push(T)}}if(b(this,Ne)&&b(this,Te)?.length){let T=b(this,Te),O;for(;O=T?.shift();)(k=b(this,ut))==null||k.call(this,...O)}return h},hr=function(f){var p,h;for(let y of R(this,L,Bt).call(this,{allowStale:!0})){let k=b(this,q)[y];if(R(this,L,ue).call(this,k))k.__abortController.abort(new Error("deleted"));else{let T=b(this,ce)[y];b(this,gt)&&((p=b(this,lt))==null||p.call(this,k,T,f)),b(this,Ne)&&b(this,Te)?.push([k,T,f])}}if(b(this,be).clear(),b(this,q).fill(void 0),b(this,ce).fill(void 0),b(this,qe)&&b(this,dt)){b(this,qe).fill(0),b(this,dt).fill(0);for(let y of b(this,$e)??[])y!==void 0&&clearTimeout(y);b(this,$e)?.fill(void 0)}if(b(this,ht)&&b(this,ht).fill(0),V(this,Ae,0),V(this,ke,0),b(this,pt).length=0,V(this,ft,0),V(this,xe,0),b(this,Ne)&&b(this,Te)){let y=b(this,Te),k;for(;k=y?.shift();)(h=b(this,ut))==null||h.call(this,...k)}},Tn);function Gn(g){let f={individual:{},range:[]},p=new WeakMap;for(let h of g)gr(f,h,p);return f}function gr(g,f,p){for(let[h,y]of Object.entries(f.individual))if(g.individual[h])Cn(g.individual[h],y,p);else{let k=!1;for(let[T,{range:O,entry:w}]of g.range.entries()){let E=dr(Number(h),O);if(E.both!==null){k=!0,g.individual[h]=y,Cn(g.individual[h],Oe(w),p),g.range.splice(T,1);for(let j of E.second)Array.isArray(j)?g.range.push({range:j,entry:Oe(w)}):g.individual[j]=Oe(w)}}k||(g.individual[h]=y)}for(let{range:h,entry:y}of f.range){let k=[h];for(let T=0;Tf.lookup.index||g.lookup.index===f.lookup.index&&g.lookup.subIndex>f.lookup.subIndex)&&(g.lookup=f.lookup),f.forward&&(g.forward?gr(g.forward,f.forward,p):g.forward=f.forward),f.reverse&&(g.reverse?gr(g.reverse,f.reverse,p):g.reverse=f.reverse))}function Jp(g,f){let p={first:[],second:[],both:null};if(g[0]f[1]){let h=Math.max(g[0],f[1]),y=g[1];p.first.push(sn(h,y))}else if(f[1]>g[1]){let h=Math.max(g[1],f[0]),y=f[1];p.second.push(sn(h,y))}return p}function dr(g,f){if(gf[1])return{first:[g],second:[f],both:null};let p={first:[],second:[],both:g};return f[0]g&&p.second.push(sn(g+1,f[1])),p}function sn(g,f){return f-g===1?g:[g,f]}function Oe(g,f=new Map){if(f.has(g))return f.get(g);let p={};return f.set(g,p),g.forward&&(p.forward=Ni(g.forward,f)),g.reverse&&(p.reverse=Ni(g.reverse,f)),g.lookup&&(p.lookup={contextRange:g.lookup.contextRange.slice(),index:g.lookup.index,length:g.lookup.length,subIndex:g.lookup.subIndex,substitutions:g.lookup.substitutions.slice()}),p}function Ni(g,f=new Map){let p={};for(let[h,y]of Object.entries(g.individual))p[h]=Oe(y,f);return{individual:p,range:g.range.map(({range:h,entry:y})=>({range:h.slice(),entry:Oe(y,f)}))}}function Hn(g,f,p,h){let y=f[h],k=g[y];if(!k)return;let T=k.lookup;if(k.reverse){let w=eh(k.reverse,f,p);(!T&&w||w&&T&&(T.index>w.index||T.index===w.index&&T.subIndex>w.subIndex))&&(T=w)}if(++h>=f.length||!k.forward)return T;let O=Hn(k.forward,f,p,h);return(!T&&O||O&&T&&(T.index>O.index||T.index===O.index&&T.subIndex>O.subIndex))&&(T=O),T}function eh(g,f,p){let h=g[f[--p]],y=h&&h.lookup;for(;h&&((!y&&h.lookup||h.lookup&&y&&y.index>h.lookup.index)&&(y=h.lookup),!(--p<0||!h.reverse));)h=h.reverse[f[p]];return y}function Cs(g,f,p){let h=!1;for(let y=0;yy.start<=f&&y.end>=f);return h?h.index:null}}function Ye(g){switch(g.format){case 1:return g.glyphs.map((p,h)=>({glyphId:p,index:h}));case 2:let f=[];for(let[p,h]of g.ranges.entries())h.end===h.start?f.push({glyphId:h.start,index:p}):f.push({glyphId:[h.start,h.end+1],index:p});return f}}function Bi(g,f){let p=f[0],h=Os(g,p),y=f[0]+1,k=new Map;for(;y({entry:w,substitutions:[...T.substitutions,E]})))}return k}function Gt(g,f){let p=[],h=new Set;for(let y of f){if(h.has(y.entry))continue;h.add(y.entry),y.entry.forward??={individual:{},range:[]};let k={};for(let T of g)Array.isArray(T)?y.entry.forward.range.push({entry:k,range:T}):y.entry.forward.individual[T]=k;p.push({entry:k,substitutions:y.substitutions})}return p}function Ht(g,f){let p=[],h=new Set;for(let y of f){if(h.has(y.entry))continue;h.add(y.entry),y.entry.reverse??={individual:{},range:[]};let k={};for(let T of g)Array.isArray(T)?y.entry.reverse.range.push({entry:k,range:T}):y.entry.reverse.individual[T]=k;p.push({entry:k,substitutions:y.substitutions})}return p}function rn(g,f,p,h,y){let k=[];if(!Array.isArray(y))g.individual[y]={},k.push({entry:g.individual[y],substitution:nh(f,p,h,y)});else{let T=th(f,p,h,y);for(let[O,w]of T){let E={};Array.isArray(O)?g.range.push({range:O,entry:E}):g.individual[O]={},k.push({entry:E,substitution:w})}}return k}function th(g,f,p,h){for(let y of g.filter(k=>k.sequenceIndex===p))for(let k of f[y.lookupListIndex].subtables){let T=Bi(k,h);if(!Array.from(T.values()).every(O=>O!==null))return T}return new Map([[h,null]])}function nh(g,f,p,h){for(let y of g.filter(k=>k.sequenceIndex===p))for(let k of f[y.lookupListIndex].subtables){let T=Os(k,h);if(T!==null)return T}return null}function yr(g,f,p){let h={individual:{},range:[]},y=Ye(g.coverage);for(let{glyphId:k,index:T}of y){let O=g.chainRuleSets[T];if(O)for(let[w,E]of O.entries()){let j=rn(h,E.lookupRecords,f,0,k).map(({entry:H,substitution:Q})=>({entry:H,substitutions:[Q]}));for(let[H,Q]of E.input.entries())j=On([Q],H+1,j,E.lookupRecords,f);for(let H of E.lookahead)j=Gt([H],j);for(let H of E.backtrack)j=Ht([H],j);for(let{entry:H,substitutions:Q}of j)H.lookup={substitutions:Q,length:E.input.length+1,index:p,subIndex:w,contextRange:[-1*E.backtrack.length,1+E.input.length+E.lookahead.length]}}}return h}function vr(g,f){return g.format===2?Array.isArray(f)?sh(g,f):new Map([[f,br(g,f)]]):new Map([[f,null]])}function sh(g,f){let p=f[0],h=br(g,p),y=f[0]+1,k=new Map;for(;y=f)return p.classId;return null}function Is(g,f){switch(g.format){case 2:let p=[];for(let h of g.ranges)h.classId===f&&(h.end===h.start?p.push(h.start):p.push([h.start,h.end+1]));return p;default:return[]}}function xr(g,f,p){let h=[],y=Ye(g.coverage);for(let{glyphId:k}of y){let T=vr(g.inputClassDef,k);for(let[O,w]of T.entries()){if(w===null)continue;let E=g.chainClassSet[w];if(E)for(let[j,H]of E.entries()){let Q={individual:{},range:[]},X=rn(Q,H.lookupRecords,f,0,O).map(({entry:fe,substitution:J})=>({entry:fe,substitutions:[J]}));for(let[fe,J]of H.input.entries())X=On(Is(g.inputClassDef,J),fe+1,X,H.lookupRecords,f);for(let fe of H.lookahead)X=Gt(Is(g.lookaheadClassDef,fe),X);for(let fe of H.backtrack)X=Ht(Is(g.backtrackClassDef,fe),X);for(let{entry:fe,substitutions:J}of X)fe.lookup={substitutions:J,index:p,subIndex:j,length:H.input.length+1,contextRange:[-1*H.backtrack.length,1+H.input.length+H.lookahead.length]};h.push(Q)}}}return Gn(h)}function Sr(g,f,p){let h={individual:{},range:[]},y=Ye(g.inputCoverage[0]);for(let{glyphId:k}of y){let T=rn(h,g.lookupRecords,f,0,k).map(({entry:O,substitution:w})=>({entry:O,substitutions:[w]}));for(let[O,w]of g.inputCoverage.slice(1).entries())T=On(Ye(w).map(E=>E.glyphId),O+1,T,g.lookupRecords,f);for(let O of g.lookaheadCoverage)T=Gt(Ye(O).map(w=>w.glyphId),T);for(let O of g.backtrackCoverage)T=Ht(Ye(O).map(w=>w.glyphId),T);for(let{entry:O,substitutions:w}of T)O.lookup={substitutions:w,index:p,subIndex:0,length:g.inputCoverage.length,contextRange:[-1*g.backtrackCoverage.length,g.inputCoverage.length+g.lookaheadCoverage.length]}}return h}function kr(g,f){let p={individual:{},range:[]},h=Ye(g.coverage);for(let{glyphId:y,index:k}of h){let T={};Array.isArray(y)?p.range.push({entry:T,range:y}):p.individual[y]=T;let O=[{entry:T,substitutions:[g.substitutes[k]]}];for(let w of g.lookaheadCoverage)O=Gt(Ye(w).map(E=>E.glyphId),O);for(let w of g.backtrackCoverage)O=Ht(Ye(w).map(E=>E.glyphId),O);for(let{entry:w,substitutions:E}of O)w.lookup={substitutions:E,index:f,subIndex:0,length:1,contextRange:[-1*g.backtrackCoverage.length,1+g.lookaheadCoverage.length]}}return p}function Vn(g,f=new Map){let p={};for(let[h,y]of Object.entries(g.individual))p[h]=_i(y,f);for(let{range:h,entry:y}of g.range){let k=_i(y,f);for(let T=h[0];T0&&(this._cache=new Ri({maxSize:p.cacheSize,sizeCalculation:((O,w)=>w.length)}));let y=(this._font.tables.gsub&&this._font.tables.gsub.features.filter(O=>O.tag==="calt")||[]).reduce((O,w)=>[...O,...w.feature.lookupListIndexes],[]),k=this._font.tables.gsub&&this._font.tables.gsub.lookups||[],T=k.filter((O,w)=>y.some(E=>E===w));for(let[O,w]of T.entries()){let E=[];switch(w.lookupType){case 6:for(let[H,Q]of w.subtables.entries())switch(Q.substFormat){case 1:E.push(yr(Q,k,H));break;case 2:E.push(xr(Q,k,H));break;case 3:E.push(Sr(Q,k,H));break}break;case 8:for(let[H,Q]of w.subtables.entries())E.push(kr(Q,H));break}let j=Vn(Gn(E));this._lookupTrees.push({tree:j,processForward:w.lookupType!==8});for(let H of Object.keys(j))this._glyphLookups[H]||(this._glyphLookups[H]=[]),this._glyphLookups[H].push(O)}}findLigatures(f){let p=this._cache&&this._cache.get(f);if(p&&!Array.isArray(p))return p;let h=[];for(let T of f)h.push(this._font.charToGlyphIndex(T));if(this._lookupTrees.length===0)return{inputGlyphs:h,outputGlyphs:h,contextRanges:[]};let y=this._findInternal(h.slice()),k={inputGlyphs:h,outputGlyphs:y.sequence,contextRanges:y.ranges};return this._cache&&this._cache.set(f,k),k}findLigatureRanges(f){if(this._lookupTrees.length===0)return[];let p=this._cache&&this._cache.get(f);if(p)return Array.isArray(p)?p:p.contextRanges;let h=[];for(let k of f)h.push(this._font.charToGlyphIndex(k));let y=this._findInternal(h);return this._cache&&this._cache.set(f,y.ranges),y.ranges}_findInternal(f){let p=[],h=this._getNextLookup(f,0);for(;h.index!==null;){let y=this._lookupTrees[h.index];if(y.processForward){let k=h.last;for(let T=h.first;T=k&&(k=T+O.length+1),T+=O.length-1}}}else for(let k=h.last-1;k>=h.first;k--){let T=Hn(y.tree,f,k,k);if(T){for(let O=0;O=p){(h.index===null||O<=h.index)&&(h.index=O,h.first>y&&(h.first=y),h.last=y+1);break}}}return h}};function Hi(g,f){let p=Gi.parse(g);return new Tr(p,{cacheSize:0,...f})}function Or(g){if(typeof g!="string")throw new Error("Font family must be a string");let f={input:g,offset:0},p=[],h="";for(;f.offset=6||!/[\dA-Fa-f]/.test(p))return g.offset--,Cr(f);f+=p}return Cr(f)}function Cr(g){return String.fromCodePoint(parseInt(g,16))}var zn;async function Ir(g,f){if(!zn){if(typeof navigator<"u"&&"fonts"in navigator){try{let y=await navigator.permissions.request?.({name:"local-fonts"});if(y&&y.state!=="granted")throw new Error("Permission to access local fonts not granted.")}catch(y){if(y instanceof Error&&y.name!=="TypeError")throw y}let h={};try{let y=await navigator.fonts.query();for(let k of y)h.hasOwnProperty(k.family)||(h[k.family]=[]),h[k.family].push(k);zn=Promise.resolve(h)}catch(y){y instanceof Error&&console.error(y.name,y.message)}}else if(typeof window<"u"&&"queryLocalFonts"in window){let h={};try{let y=await window.queryLocalFonts();for(let k of y)h.hasOwnProperty(k.family)||(h[k.family]=[]),h[k.family].push(k);zn=Promise.resolve(h)}catch(y){y instanceof Error&&console.error(y.name,y.message)}}zn??=Promise.resolve({})}let p=await zn;for(let h of Or(g)){if(ih.includes(h))return;if(p.hasOwnProperty(h)&&p[h].length>0){let y=p[h][0];if("blob"in y){let T=await(await y.blob()).arrayBuffer();return Hi(T,{cacheSize:f})}return}}}var ih=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"];var ah=1e5;function zi(g,f=[]){let p,h,y=0,k;return g.registerCharacterJoiner(T=>{let O=g.options.fontFamily;if(O&&(y===0||p!==O)){h=void 0,y=1,p=O;let w=p;Ir(w,ah).then(E=>{w===g.options.fontFamily&&(y=2,h=E,E&&g.refresh(0,g.rows-1))}).catch(E=>{w===g.options.fontFamily&&(y=3,g.options.logLevel==="debug"&&console.debug(k,new Error("Failure while loading font")),h=void 0,k=E)})}return h&&y===2?h.findLigatureRanges(T).map(w=>[w[0],w[1]]):lh(T,f)})}function lh(g,f){let p=[];for(let h=0;h","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","","/>","~~>","==","!=","/=","~=","<>","===","!==","!===","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","