@mylasertools/kerfscript 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/language.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /*! @mylasertools/kerfscript | (c) MyLaserTools | AGPL-3.0-only or commercial licence, see COMMERCIAL-LICENSE.md. Includes Clipper2 (BSL-1.0), opentype.js, tiny-inflate and string.prototype.codepointat (MIT), see THIRD-PARTY-NOTICES.md. */
2
- "use strict";var bn=Object.defineProperty;var wa=Object.getOwnPropertyDescriptor;var ka=Object.getOwnPropertyNames;var Ea=Object.prototype.hasOwnProperty;var Pa=(n,e,t)=>e in n?bn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var La=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ta=(n,e)=>{for(var t in e)bn(n,t,{get:e[t],enumerable:!0})},Ia=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ka(e))!Ea.call(n,s)&&s!==t&&bn(n,s,{get:()=>e[s],enumerable:!(r=wa(e,s))||r.enumerable});return n};var Ca=n=>Ia(bn({},"__esModule",{value:!0}),n);var b=(n,e,t)=>Pa(n,typeof e!="symbol"?e+"":e,t);var xi=La((tg,vi)=>{vi.exports={}});var ap={};Ta(ap,{analyze:()=>Kh,complete:()=>rp,definition:()=>ma,hover:()=>tp,outline:()=>ip,problems:()=>op,references:()=>va,rename:()=>Jh,renameTarget:()=>xa,signatureHelp:()=>sp});module.exports=Ca(ap);var _t=(n,e=!0)=>`line ${n.line}${e?`, column ${n.col}`:""}${n.file?` in <${n.file}>`:""}`;var R=class extends Error{constructor(t,r){super(r?`${t} (${_t(r)})`:t);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=t,r&&(this.line=r.line,this.col=r.col,this.file=r.file)}addFrame(t,r,s){let i=this.trace.find(o=>o.name===r&&o.line===s.line&&o.col===s.col&&o.file===s.file);i?i.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:t,name:r,line:s.line,col:s.col,...s.file&&{file:s.file},count:1})}},Ma=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function Ct(n,e){let t=[],r=[],s=0,i=1,o=0,a=()=>({line:i,col:s-o+1,offset:s,...e&&{file:e}}),l=u=>{for(let c=0;c<u;c++)n[s]===`
2
+ "use strict";var Sn=Object.defineProperty;var ka=Object.getOwnPropertyDescriptor;var Ea=Object.getOwnPropertyNames;var Pa=Object.prototype.hasOwnProperty;var La=(n,e,t)=>e in n?Sn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ta=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ia=(n,e)=>{for(var t in e)Sn(n,t,{get:e[t],enumerable:!0})},Ma=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ea(e))!Pa.call(n,s)&&s!==t&&Sn(n,s,{get:()=>e[s],enumerable:!(r=ka(e,s))||r.enumerable});return n};var Ca=n=>Ma(Sn({},"__esModule",{value:!0}),n);var k=(n,e,t)=>La(n,typeof e!="symbol"?e+"":e,t);var yi=Ta((rg,xi)=>{xi.exports={}});var up={};Ia(up,{analyze:()=>Qh,complete:()=>ip,definition:()=>va,hover:()=>rp,outline:()=>ap,problems:()=>lp,references:()=>xa,rename:()=>ep,renameTarget:()=>ya,signatureHelp:()=>op});module.exports=Ca(up);var Xt=(n,e=!0)=>`line ${n.line}${e?`, column ${n.col}`:""}${n.file?` in <${n.file}>`:""}`;var N=class extends Error{constructor(t,r){super(r?`${t} (${Xt(r)})`:t);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=t,r&&(this.line=r.line,this.col=r.col,this.file=r.file)}addFrame(t,r,s){let i=this.trace.find(o=>o.name===r&&o.line===s.line&&o.col===s.col&&o.file===s.file);i?i.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:t,name:r,line:s.line,col:s.col,...s.file&&{file:s.file},count:1})}},Aa=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function It(n,e){let t=[],r=[],s=0,i=1,o=0,a=()=>({line:i,col:s-o+1,offset:s,...e&&{file:e}}),l=u=>{for(let c=0;c<u;c++)n[s]===`
3
3
  `&&(i++,o=s+1),s++};for(;s<n.length;){let u=n[s];if(u===" "||u===" "||u==="\r"||u===`
4
4
  `){l(1);continue}if(u==="/"&&n[s+1]==="/"){let f=n.indexOf(`
5
5
  `,s),p=f<0?n.length:f,d=/^[ \t]*$/.test(n.slice(n.lastIndexOf(`
6
- `,s-1)+1,s));r.push({text:n.slice(s+2,p).trim(),line:i,block:!1,own:d,start:s,end:p}),s=p;continue}if(u==="/"&&n[s+1]==="*"){let f=a(),p=n.indexOf("*/",s+2);if(p<0)throw new R("Unclosed block comment",f);r.push({text:n.slice(s+2,p).trim(),line:f.line,block:!0,own:!0,start:s,end:p+2}),l(p+2-s);continue}let c=a();if(/[0-9]/.test(u)||u==="."&&/[0-9]/.test(n[s+1]??"")){let f=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(n.slice(s));t.push({type:"num",value:f[0],pos:c,end:s+f[0].length}),l(f[0].length);continue}if(/[A-Za-z_$]/.test(u)){let f=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(n.slice(s));t.push({type:"id",value:f[0],pos:c,end:s+f[0].length}),l(f[0].length);continue}if(u==='"'){let f="";for(l(1);s<n.length&&n[s]!=='"';){if(n[s]==="\\"){let p=n[s+1];if(p==="n")f+=`
7
- `;else if(p==="t")f+=" ";else if(p==="u"){let d=n.slice(s+2,s+6);if(!/^[0-9a-fA-F]{4}$/.test(d))throw new R("Bad \\u escape",a());f+=String.fromCharCode(parseInt(d,16)),l(4)}else f+=p;l(2);continue}if(n[s]===`
8
- `)throw new R("Unclosed string",c);f+=n[s],l(1)}if(s>=n.length)throw new R("Unclosed string",c);l(1),t.push({type:"str",value:f,pos:c,end:s});continue}if(u==="<"&&/^<[A-Za-z0-9_./-]+>/.test(n.slice(s))){let f=t[t.length-1];if(f&&f.type==="id"&&(f.value==="use"||f.value==="include")){let p=/^<([A-Za-z0-9_./-]+)>/.exec(n.slice(s));t.push({type:"str",value:p[1],pos:c,end:s+p[0].length}),l(p[0].length);continue}}let h=Ma.find(f=>n.startsWith(f,s));if(!h)throw new R(`Unexpected character "${u}"`,c);t.push({type:"punct",value:h,pos:c,end:s+h.length}),l(h.length)}return t.push({type:"eof",value:"",pos:a(),end:s}),{tokens:t,comments:r}}var gr=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function it(n,e){let{tokens:t,comments:r}=Ct(n,e),s=new mr(t),i=[];for(;!s.at("eof");)i.push(...s.statement());return{program:{body:i},comments:r}}var jt=class jt{constructor(e){this.tokens=e;this.i=0}peek(e=0){return this.tokens[Math.min(this.i+e,this.tokens.length-1)]}at(e,t,r=0){let s=this.peek(r);return s.type===e&&(t===void 0||s.value===t)}isP(e,t=0){return this.at("punct",e,t)}isK(e,t=0){return this.at("id",e,t)}next(){return this.tokens[this.i++]}fail(e,t=this.peek()){let r=t.type==="eof"?"end of file":`"${t.value}"`;throw new R(`${e}, found ${r}`,t.pos)}expectP(e){return this.isP(e)||this.fail(`Expected "${e}"`),this.next()}separator(e){this.isP(e)||(this.isP(",")||this.fail(`Expected "," or "${e}"`),this.next())}ident(){let e=this.peek();return(e.type!=="id"||gr.has(e.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let e=this.stmt();for(let t of e)t.end=this.last();return e}stmt(){let e=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let o=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),o.push(...this.statement());return this.next(),[{kind:"block",body:o,pos:e.pos}]}if(this.isK("module")){this.next();let o=this.ident(),a=this.params();return[{kind:"module",name:o.value,params:a,body:this.body(),pos:e.pos,namePos:o.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let o=this.ident(),a=this.params();this.expectP("=");let l=this.expr();return this.expectP(";"),[{kind:"function",name:o.value,params:a,body:l,pos:e.pos,namePos:o.pos}]}if(this.isK("use")||this.isK("include")){this.next();let o=this.peek();return o.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:o.value,include:e.value==="include",pos:e.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(this.isK("if")){this.next(),this.expectP("(");let o=this.expr();this.expectP(")");let a=this.body(),l=[];return this.isK("else")&&(this.next(),l=this.body()),[{kind:"if",cond:o,then:a,else:l,pos:e.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(e.type==="id"&&this.isP("=",1)){let o=this.ident().value;this.next();let a=this.peek().pos.offset,l=this.expr(),u=this.expectP(";").pos.offset;return[{kind:"assign",name:o,value:l,span:[a,u],pos:e.pos}]}let t=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(t=this.next().value);let r=this.peek();(r.type!=="id"||gr.has(r.value))&&this.fail("Expected a statement"),this.next();let s=this.args(),i=this.body();return[{kind:"call",name:r.value,args:s,children:i,modifier:t,pos:r.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let e=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),e.push(...this.statement());return this.next(),e}return this.statement()}params(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=this.ident(),r=null;this.isP("=")&&(this.next(),r=this.expr()),e.push({name:t.value,default:r,pos:t.pos}),this.separator(")")}return this.next(),e}args(){this.expectP("(");let e=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let t=this.next();this.next(),e.push({name:t.value,value:this.expr(),pos:t.pos})}else e.push({name:null,value:this.expr()});this.separator(")")}return this.next(),e}assigns(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=this.ident();this.expectP("="),e.push({name:t.value,value:this.expr(),pos:t.pos}),this.separator(")")}return this.next(),e}expr(){let e=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let r=this.params(),s=this.expr();return{kind:"lambda",params:r,body:s,pos:e.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let r=this.assigns(),s=this.expr();return{kind:"let",assigns:r,body:s,pos:e.pos,end:this.last()}}let t=this.binary(0);if(this.isP("?")){this.next();let r=this.expr();this.expectP(":");let s=this.expr();return{kind:"ternary",cond:t,then:r,else:s,pos:e.pos}}return t}binary(e){if(e>=jt.LEVELS.length)return this.unary();let t=this.binary(e+1);for(;this.at("punct")&&jt.LEVELS[e].includes(this.peek().value);){let r=this.next(),s=this.binary(e+1);t={kind:"binary",op:r.value,left:t,right:s,pos:r.pos}}return t}unary(){if(this.isP("-")||this.isP("!")||this.isP("+")){let e=this.next();return{kind:"unary",op:e.value,arg:this.unary(),pos:e.pos}}return this.power()}power(){let e=this.postfix();if(this.isP("^")){let t=this.next();return{kind:"binary",op:"^",left:e,right:this.unary(),pos:t.pos}}return e}postfix(){let e=this.primary();for(;;){let t=this.peek();if(this.isP("("))e={kind:"call",callee:e,args:this.args(),pos:e.pos};else if(this.isP("[")){this.next();let r=this.expr();this.expectP("]"),e={kind:"index",target:e,index:r,pos:t.pos}}else if(this.isP("."))this.next(),e={kind:"member",target:e,name:this.ident().value,pos:t.pos};else return e}}primary(){let e=this.peek();if(e.type==="num")return this.next(),{kind:"num",value:Number(e.value),pos:e.pos};if(e.type==="str")return this.next(),{kind:"str",value:e.value,pos:e.pos};if(e.type==="id")return e.value==="true"||e.value==="false"?(this.next(),{kind:"bool",value:e.value==="true",pos:e.pos}):e.value==="undef"?(this.next(),{kind:"undef",pos:e.pos}):(gr.has(e.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:e.value,pos:e.pos});if(this.isP("(")){this.next();let t=this.expr();return this.expectP(")"),t}if(this.isP("["))return this.list();this.fail("Expected a value")}list(){let e=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:e.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let t=this.expr();if(this.isP(":")){this.next();let s=null,i=this.expr();return this.isP(":")&&(this.next(),s=i,i=this.expr()),this.expectP("]"),{kind:"range",start:t,step:s,end:i,pos:e.pos}}let r=[{kind:"item",expr:t}];return this.listRest(r,e.pos)}return this.listRest([],e.pos)}listRest(e,t){if(e.length){if(this.isP("]"))return this.next(),{kind:"list",items:e,pos:t};this.separator("]")}for(;!this.isP("]");)e.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:e,pos:t}}listItem(){let e=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let t=this.assigns(),r=this.listItem();return{kind:"for",assigns:t,body:r,pos:e.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let t=this.expr();this.expectP(")");let r=this.listItem(),s=null;return this.isK("else")&&(this.next(),s=this.listItem()),{kind:"if",cond:t,then:r,else:s}}if(this.isK("let")&&this.isP("(",1)){this.next();let t=this.assigns(),r=this.listItem();return{kind:"let",assigns:t,body:r,pos:e.pos,end:this.last()}}if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let t=this.listItem();return this.expectP(")"),t}return{kind:"item",expr:this.expr()}}};jt.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var mr=jt;function Ls(n){switch(n.kind){case"num":case"str":case"bool":return{ok:!0,value:n.value};case"unary":return n.op==="-"&&n.arg.kind==="num"?{ok:!0,value:-n.arg.value}:{ok:!1};case"list":{let e=[];for(let t of n.items){if(t.kind!=="item")return{ok:!1};let r=Ls(t.expr);if(!r.ok||typeof r.value!="number")return{ok:!1};e.push(r.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function Ps(n){let e=Number(n.trim());return n.trim()!==""&&Number.isFinite(e)?e:void 0}function Ts(n){let{program:e,comments:t}=it(n),r=t.filter(a=>a.block&&/^\[[^\]]+\]$/.test(a.text)),s=new Map(t.filter(a=>!a.block&&!a.own).map(a=>[a.line,a.text])),i=new Map(t.filter(a=>!a.block&&a.own).map(a=>[a.line,a.text])),o=[];for(let a of e.body){if(a.kind!=="assign"||/^\$f[nas]$/.test(a.name))continue;let l=Ls(a.value);if(!l.ok)continue;let u=r.filter(g=>g.line<=a.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(u.toLowerCase()==="hidden")continue;let c=s.get(a.pos.line),h=i.get(a.pos.line-1)??"",f=l.value,p={name:a.name,caption:h,group:u,type:typeof f=="number"||Array.isArray(f)?"number":typeof f=="boolean"?"boolean":"string",initial:f,span:a.span},d=c?/^\[(.*)\]$/.exec(c.trim()):null;if(d){let g=d[1];if(g.includes(",")||/[a-zA-Z"]/.test(g)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(g))p.options=g.split(",").map(y=>{let[x,I]=y.split(":").map(L=>L.trim().replace(/^"|"$/g,"")),k=Ps(x),F=p.type==="number"&&k!==void 0?k:x;return{name:I??x,value:F}});else{let y=g.split(":").map(Ps);y.every(x=>x!==void 0)&&(y.length===1?p.max=y[0]:y.length===2?(p.min=y[0],p.max=y[1]):(p.min=y[0],p.step=y[1],p.max=y[2]))}}o.push(p)}return{parameters:o}}var w=(n,e,t)=>({name:n,...t!==void 0&&{default:t},...e&&{doc:e}}),Le=(n,e,t)=>({...w(n,e,t),named:!0}),vr="max(3 * $thickness, 6)",Sn=[w("value")],Aa=[w("x")],Ce=(n,e)=>({name:n,kind:"function",params:Aa,section:"Numbers and vectors",doc:e}),Mt=(n,e)=>({name:n,kind:"function",params:Sn,section:"Types",doc:`Whether the value is ${e}`}),Is=(n,e)=>({name:n,kind:"function",params:[w("text","The text to measure",'""'),w("size","Font size in millimetres","10"),w("font","Font name","$font"),Le("halign","left, center or right",'"left"'),Le("valign","baseline, top, center or bottom",'"baseline"'),Le("spacing","Letter spacing factor","1")],section:"Text measurements",doc:e}),wn=[{name:"rect",kind:"module",params:[w("size","A number, or [width, height]","1"),w("center","Centre the rectangle on the origin instead of its corner","false"),Le("r","Corner radius","0")],section:"Shapes",doc:"A rectangle with its corner at the origin"},{name:"square",kind:"module",params:[w("size","A number, or [width, height]","1"),w("center","Centre the square on the origin instead of its corner","false"),Le("r","Corner radius","0")],section:"Shapes",doc:"Another name for rect()"},{name:"circle",kind:"module",params:[w("r","Radius","1"),Le("d","Diameter, instead of r")],section:"Shapes",doc:"A circle centred on the origin"},{name:"ellipse",kind:"module",params:[w("r","[rx, ry], or one radius for both","1")],section:"Shapes",doc:"An ellipse centred on the origin"},{name:"regular_polygon",kind:"module",params:[w("n","Number of corners","6"),w("r","Distance to the corners","10")],section:"Shapes",doc:"A regular polygon centred on the origin"},{name:"star",kind:"module",params:[w("n","Number of points","5"),w("r","Radius of the points","10"),w("inner","Radius between the points","r * 0.45")],section:"Shapes",doc:"A star centred on the origin"},{name:"polygon",kind:"module",params:[w("points","A list of [x, y] points"),w("paths","Lists of point indexes, one per outline; holes come from even-odd fill")],section:"Shapes",doc:"A shape from a list of points"},{name:"path",kind:"module",params:[w("d",'SVG path data, as "M0 0 L10 0 L5 8 Z"'),Le("fill",'"evenodd" or "nonzero"','"evenodd"')],section:"Shapes",doc:"Shapes from SVG path data: closed subpaths become areas, open ones lines"},{name:"text",kind:"module",params:[w("text","The text",'""'),w("size","Font size in millimetres","10"),w("font","Font name","$font"),Le("halign","left, center or right",'"left"'),Le("valign","baseline, top, center or bottom",'"baseline"'),Le("spacing","Letter spacing factor","1")],section:"Shapes",doc:"Text as shapes; the font must be available to the renderer"},{name:"line",kind:"module",params:[w("from","Start point","[0, 0]"),w("to","End point","[10, 0]")],section:"Shapes",doc:"A straight line, not an area"},{name:"polyline",kind:"module",params:[w("points","A list of [x, y] points"),w("closed","Join the last point to the first","false")],section:"Shapes",doc:"Lines through a list of points"},{name:"arc",kind:"module",params:[w("r","Radius","10"),w("start","Start angle in degrees","0"),w("end","End angle in degrees","90")],section:"Shapes",doc:"An arc line around the origin"},{name:"translate",kind:"module",params:[w("v","[x, y]","[0, 0]")],children:!0,section:"Transforms",doc:"Move the children by x and y"},{name:"rotate",kind:"module",params:[w("a","Angle in degrees, anticlockwise","0"),Le("center","The point to turn around, [x, y]")],children:!0,section:"Transforms",doc:"Rotate the children around the origin or a point"},{name:"scale",kind:"module",params:[w("v","One factor, or [sx, sy]","1")],children:!0,section:"Transforms",doc:"Scale the children"},{name:"mirror",kind:"module",params:[w("v","[nx, ny], perpendicular to the mirror line","[1, 0]")],children:!0,section:"Transforms",doc:"Reflect the children across a line through the origin"},{name:"multmatrix",kind:"module",params:[w("m","A 2 \xD7 3 or 3 \xD7 3 matrix")],children:!0,section:"Transforms",doc:"Apply a transformation matrix to the children"},{name:"union",kind:"module",params:[],children:!0,section:"Combining",doc:"Join the children"},{name:"group",kind:"module",params:[],children:!0,section:"Combining",doc:"Another name for union()"},{name:"difference",kind:"module",params:[],children:!0,section:"Combining",doc:"Remove every later child's area from every layer of the first child"},{name:"intersection",kind:"module",params:[],children:!0,section:"Combining",doc:"Keep only the area common to all children"},{name:"hull",kind:"module",params:[],children:!0,section:"Combining",doc:"The convex hull of the children; each part inside gets its own"},{name:"offset",kind:"module",params:[w("r","Grow (positive) or shrink areas with rounded corners"),Le("delta","Grow or shrink areas with sharp corners","0"),Le("chamfer","Cut the corners off when growing by delta","false")],children:!0,section:"Combining",doc:"Grow or shrink the areas of the children"},{name:"stroke",kind:"module",params:[w("width","Width of the area around each line","1")],children:!0,section:"Combining",doc:"Turn lines into areas, for cutting single-line art"},{name:"outline",kind:"module",params:[],children:!0,section:"Combining",doc:"Turn areas into their outline lines"},{name:"cut",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the cut layer"},{name:"score",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the score layer: lines marked without cutting through"},{name:"engrave",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the engrave layer: areas filled in"},{name:"guide",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the guide layer, which is not cut"},{name:"layer",kind:"module",params:[w("name","Layer name"),w("mode",'"cut", "line", "fill" or "guide"'),w("color",'Colour in the output, as "#00aa00"')],children:!0,section:"Layers",doc:"Put the children on a layer, defining it on first use"},{name:"part",kind:"module",params:[w("name","Part name",'"part"'),w("qty","Number of copies to cut","1"),Le("at","Where the part goes in the assembled view, [x, y, z]"),Le("rotate","How the part is turned in the assembled view, [x, y, z] in degrees")],children:!0,section:"Parts and sheets",doc:"A named part, with its thickness, kerf and material"},{name:"material",kind:"module",params:[w("thickness","Sets $thickness"),w("kerf","Sets $kerf"),w("name","Sets $material")],children:!0,section:"Parts and sheets",doc:"Set the thickness, kerf and material name for the children"},{name:"finger_rect",kind:"module",params:[w("size","[width, height]"),w("edges",'"out", "in" or "flat", or [bottom, right, top, left]','"out"'),w("finger","Finger width",vr)],section:"Joinery",doc:"A rectangle with finger joints, notched $thickness deep"},{name:"finger_holes",kind:"module",params:[w("length","Length of the edge that plugs in"),w("edge",'"out" or "in", the kind of edge that plugs in','"out"'),w("finger","Finger width",vr)],section:"Joinery",doc:"A row of slots along x for a finger edge to plug into"},{name:"tslot",kind:"module",params:[w("d","Screw diameter","3"),w("length","Screw length into the panel","12"),w("nut","Nut size, [width, height]","[d * 1.85, d * 0.8]"),w("nut_at","Distance of the nut from the edge","length / 2")],section:"Joinery",doc:"A T-slot for a screw and nut, opening at y = 0; subtract it from a panel edge"},{name:"living_hinge",kind:"module",params:[w("size","[width, height]"),w("spacing","Distance between the rows of cuts","1.5"),w("bridge","Uncut length between cuts","3"),w("cut","Length of each cut","max(bridge * 2, (height - 3 * bridge) / 2)")],section:"Joinery",doc:"A straight-line flex pattern of cut lines filling [width, height]"},{name:"children",kind:"module",params:[w("index","Which child, from 0, or a list of them")],section:"Other",doc:"Run the child statements passed to the current module"},{name:"echo",kind:"both",params:[],rest:!0,anyNamed:!0,section:"Other",doc:"Write values to the output without making shapes"},{name:"assert",kind:"both",params:[w("condition","Stops the program when false"),w("message","Says why")],section:"Other",doc:"Stop with an error when the condition is false"},Ce("abs","Absolute value"),Ce("sign","Sign as -1, 0 or 1"),Ce("floor","Round down"),Ce("ceil","Round up"),Ce("round","Round to the nearest integer, halves away from zero"),Ce("sqrt","Square root"),Ce("exp","e raised to x"),Ce("ln","Natural logarithm"),{name:"log",kind:"function",params:[w("x"),w("base",void 0,"10")],forms:["log(x)","log(base, x)"],section:"Numbers and vectors",doc:"Logarithm, base 10 or a chosen base; with two values the base comes first"},Ce("sin","Sine of an angle in degrees"),Ce("cos","Cosine of an angle in degrees"),Ce("tan","Tangent of an angle in degrees"),Ce("asin","Inverse sine, in degrees"),Ce("acos","Inverse cosine, in degrees"),Ce("atan","Inverse tangent, in degrees"),{name:"atan2",kind:"function",params:[w("y"),w("x")],section:"Numbers and vectors",doc:"The angle of the point [x, y] from the x axis, in degrees"},{name:"pow",kind:"function",params:[w("x"),w("y")],section:"Numbers and vectors",doc:"x raised to y"},{name:"min",kind:"function",params:[w("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The smallest of a list, or of several values"},{name:"max",kind:"function",params:[w("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The largest of a list, or of several values"},{name:"clamp",kind:"function",params:[w("x"),w("low"),w("high")],section:"Numbers and vectors",doc:"x limited to the interval from low to high"},{name:"lerp",kind:"function",params:[w("a"),w("b"),w("t","0 gives a, 1 gives b")],section:"Numbers and vectors",doc:"Interpolate between numbers or vectors"},{name:"norm",kind:"function",params:[w("v")],section:"Numbers and vectors",doc:"The length of a vector"},{name:"cross",kind:"function",params:[w("a"),w("b")],section:"Numbers and vectors",doc:"Cross product: a number for 2D vectors, a vector for 3D ones"},{name:"len",kind:"function",params:Sn,section:"Lists and strings",doc:"Number of items in a list or characters in a string"},{name:"concat",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Join lists and single values into one list"},{name:"reverse",kind:"function",params:Sn,section:"Lists and strings",doc:"A list or string in reverse order"},{name:"sum",kind:"function",params:[w("values","A list of numbers")],section:"Lists and strings",doc:"The sum of a list of numbers"},{name:"slice",kind:"function",params:[w("value","A list or string"),w("start","First index","0"),w("end","Index after the last; the length when left out")],section:"Lists and strings",doc:"Part of a list or string"},{name:"str",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Values as text, joined"},{name:"chr",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Text from Unicode code points"},{name:"ord",kind:"function",params:[w("text")],section:"Lists and strings",doc:"The first character's Unicode code point"},{name:"upper",kind:"function",params:[w("text")],section:"Lists and strings",doc:"Text in capitals"},{name:"lower",kind:"function",params:[w("text")],section:"Lists and strings",doc:"Text in small letters"},{name:"split",kind:"function",params:[w("text"),w("separator",void 0,'" "')],section:"Lists and strings",doc:"Text split into a list of strings"},{name:"join",kind:"function",params:[w("values"),w("separator",void 0,'""')],section:"Lists and strings",doc:"Values joined into one string"},{name:"search",kind:"function",params:[w("value"),w("list","A list or string")],section:"Lists and strings",doc:"Index of the first equal item, or undef"},{name:"contains",kind:"function",params:[w("value","A list or string"),w("item")],section:"Lists and strings",doc:"Whether a list contains an item or a string contains a substring"},{name:"lookup",kind:"function",params:[w("x"),w("table","A list of [x, y] pairs")],section:"Lists and strings",doc:"Interpolate in a table; outside it, the nearest end"},Mt("is_num","a number other than NaN"),Mt("is_string","a string"),Mt("is_bool","true or false"),Mt("is_list","a list"),Mt("is_undef","undef"),Mt("is_function","a function"),{name:"type_of",kind:"function",params:Sn,section:"Types",doc:"The type name: number, string, boolean, undef, list, range or function"},{name:"rands",kind:"function",params:[w("min"),w("max"),w("count"),w("seed","The same seed gives the same list","1")],section:"Random values",doc:"A list of count numbers between min and max"},Is("text_width","The advance width of the text, including spacing"),Is("text_metrics","The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),{name:"finger_count",kind:"function",params:[w("length","Edge length"),w("finger","Finger width",vr)],section:"Joint dimensions",doc:"The odd number of fingers finger_rect() puts on an edge of that length"}],Oa=new Map(wn.map(n=>[n.name,n])),At=n=>Oa.get(n);function kn(n){let e=n.params.map(t=>t.default===void 0?t.name:`${t.name} = ${t.default}`);return n.rest&&e.push("..."),`${n.name}(${e.join(", ")})`}var tt={"kerf/box":`// kerf/box: finger-jointed boxes.
6
+ `,s-1)+1,s));r.push({text:n.slice(s+2,p).trim(),line:i,block:!1,own:d,start:s,end:p}),s=p;continue}if(u==="/"&&n[s+1]==="*"){let f=a(),p=n.indexOf("*/",s+2);if(p<0)throw new N("Unclosed block comment",f);r.push({text:n.slice(s+2,p).trim(),line:f.line,block:!0,own:!0,start:s,end:p+2}),l(p+2-s);continue}let c=a();if(/[0-9]/.test(u)||u==="."&&/[0-9]/.test(n[s+1]??"")){let f=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(n.slice(s));t.push({type:"num",value:f[0],pos:c,end:s+f[0].length}),l(f[0].length);continue}if(/[A-Za-z_$]/.test(u)){let f=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(n.slice(s));t.push({type:"id",value:f[0],pos:c,end:s+f[0].length}),l(f[0].length);continue}if(u==='"'){let f="";for(l(1);s<n.length&&n[s]!=='"';){if(n[s]==="\\"){let p=n[s+1];if(p==="n")f+=`
7
+ `;else if(p==="t")f+=" ";else if(p==="u"){let d=n.slice(s+2,s+6);if(!/^[0-9a-fA-F]{4}$/.test(d))throw new N("Bad \\u escape",a());f+=String.fromCharCode(parseInt(d,16)),l(4)}else f+=p;l(2);continue}if(n[s]===`
8
+ `)throw new N("Unclosed string",c);f+=n[s],l(1)}if(s>=n.length)throw new N("Unclosed string",c);l(1),t.push({type:"str",value:f,pos:c,end:s});continue}if(u==="<"&&/^<[A-Za-z0-9_./-]+>/.test(n.slice(s))){let f=t[t.length-1];if(f&&f.type==="id"&&(f.value==="use"||f.value==="include")){let p=/^<([A-Za-z0-9_./-]+)>/.exec(n.slice(s));t.push({type:"str",value:p[1],pos:c,end:s+p[0].length}),l(p[0].length);continue}}let h=Aa.find(f=>n.startsWith(f,s));if(!h)throw new N(`Unexpected character "${u}"`,c);t.push({type:"punct",value:h,pos:c,end:s+h.length}),l(h.length)}return t.push({type:"eof",value:"",pos:a(),end:s}),{tokens:t,comments:r}}var gr=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function ot(n,e){let{tokens:t,comments:r}=It(n,e),s=new mr(t),i=[];for(;!s.at("eof");)i.push(...s.statement());return{program:{body:i},comments:r}}var Wt=class Wt{constructor(e){this.tokens=e;this.i=0}peek(e=0){return this.tokens[Math.min(this.i+e,this.tokens.length-1)]}at(e,t,r=0){let s=this.peek(r);return s.type===e&&(t===void 0||s.value===t)}isP(e,t=0){return this.at("punct",e,t)}isK(e,t=0){return this.at("id",e,t)}next(){return this.tokens[this.i++]}fail(e,t=this.peek()){let r=t.type==="eof"?"end of file":`"${t.value}"`;throw new N(`${e}, found ${r}`,t.pos)}expectP(e){return this.isP(e)||this.fail(`Expected "${e}"`),this.next()}separator(e){this.isP(e)||(this.isP(",")||this.fail(`Expected "," or "${e}"`),this.next())}ident(){let e=this.peek();return(e.type!=="id"||gr.has(e.value))&&this.fail("Expected a name"),this.next()}last(){return this.tokens[this.i-1].end}statement(){let e=this.stmt();for(let t of e)t.end=this.last();return e}stmt(){let e=this.peek();if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let o=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),o.push(...this.statement());return this.next(),[{kind:"block",body:o,pos:e.pos}]}if(this.isK("module")){this.next();let o=this.ident(),a=this.params();return[{kind:"module",name:o.value,params:a,body:this.body(),pos:e.pos,namePos:o.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let o=this.ident(),a=this.params();this.expectP("=");let l=this.expr();return this.expectP(";"),[{kind:"function",name:o.value,params:a,body:l,pos:e.pos,namePos:o.pos}]}if(this.isK("use")||this.isK("include")){this.next();let o=this.peek();return o.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:o.value,include:e.value==="include",pos:e.pos}]}if(this.isK("for"))return this.next(),[{kind:"for",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(this.isK("if")){this.next(),this.expectP("(");let o=this.expr();this.expectP(")");let a=this.body(),l=[];return this.isK("else")&&(this.next(),l=this.body()),[{kind:"if",cond:o,then:a,else:l,pos:e.pos}]}if(this.isK("let")&&this.isP("(",1))return this.next(),[{kind:"let",assigns:this.assigns(),body:this.body(),pos:e.pos}];if(e.type==="id"&&this.isP("=",1)){let o=this.ident().value;this.next();let a=this.peek().pos.offset,l=this.expr(),u=this.expectP(";").pos.offset;return[{kind:"assign",name:o,value:l,span:[a,u],pos:e.pos}]}let t=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(t=this.next().value);let r=this.peek();(r.type!=="id"||gr.has(r.value))&&this.fail("Expected a statement"),this.next();let s=this.args(),i=this.body();return[{kind:"call",name:r.value,args:s,children:i,modifier:t,pos:r.pos}]}body(){if(this.isP(";"))return this.next(),[];if(this.isP("{")){this.next();let e=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),e.push(...this.statement());return this.next(),e}return this.statement()}params(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=this.ident(),r=null;this.isP("=")&&(this.next(),r=this.expr()),e.push({name:t.value,default:r,pos:t.pos}),this.separator(")")}return this.next(),e}args(){this.expectP("(");let e=[];for(;!this.isP(")");){if(this.at("id")&&this.isP("=",1)){let t=this.next();this.next(),e.push({name:t.value,value:this.expr(),pos:t.pos})}else e.push({name:null,value:this.expr()});this.separator(")")}return this.next(),e}assigns(){this.expectP("(");let e=[];for(;!this.isP(")");){let t=this.ident();this.expectP("="),e.push({name:t.value,value:this.expr(),pos:t.pos}),this.separator(")")}return this.next(),e}expr(){let e=this.peek();if(this.isK("function")&&this.isP("(",1)){this.next();let r=this.params(),s=this.expr();return{kind:"lambda",params:r,body:s,pos:e.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let r=this.assigns(),s=this.expr();return{kind:"let",assigns:r,body:s,pos:e.pos,end:this.last()}}let t=this.binary(0);if(this.isP("?")){this.next();let r=this.expr();this.expectP(":");let s=this.expr();return{kind:"ternary",cond:t,then:r,else:s,pos:e.pos}}return t}binary(e){if(e>=Wt.LEVELS.length)return this.unary();let t=this.binary(e+1);for(;this.at("punct")&&Wt.LEVELS[e].includes(this.peek().value);){let r=this.next(),s=this.binary(e+1);t={kind:"binary",op:r.value,left:t,right:s,pos:r.pos}}return t}unary(){if(this.isP("-")||this.isP("!")||this.isP("+")){let e=this.next();return{kind:"unary",op:e.value,arg:this.unary(),pos:e.pos}}return this.power()}power(){let e=this.postfix();if(this.isP("^")){let t=this.next();return{kind:"binary",op:"^",left:e,right:this.unary(),pos:t.pos}}return e}postfix(){let e=this.primary();for(;;){let t=this.peek();if(this.isP("("))e={kind:"call",callee:e,args:this.args(),pos:e.pos};else if(this.isP("[")){this.next();let r=this.expr();this.expectP("]"),e={kind:"index",target:e,index:r,pos:t.pos}}else if(this.isP("."))this.next(),e={kind:"member",target:e,name:this.ident().value,pos:t.pos};else return e}}primary(){let e=this.peek();if(e.type==="num")return this.next(),{kind:"num",value:Number(e.value),pos:e.pos};if(e.type==="str")return this.next(),{kind:"str",value:e.value,pos:e.pos};if(e.type==="id")return e.value==="true"||e.value==="false"?(this.next(),{kind:"bool",value:e.value==="true",pos:e.pos}):e.value==="undef"?(this.next(),{kind:"undef",pos:e.pos}):(gr.has(e.value)&&this.fail("Expected a value"),this.next(),{kind:"var",name:e.value,pos:e.pos});if(this.isP("(")){this.next();let t=this.expr();return this.expectP(")"),t}if(this.isP("["))return this.list();this.fail("Expected a value")}list(){let e=this.expectP("[");if(this.isP("]"))return this.next(),{kind:"list",items:[],pos:e.pos};if(!this.isK("for")&&!this.isK("if")&&!this.isK("each")&&!(this.isK("let")&&this.isP("(",1))&&!(this.isP("(")&&(this.isK("for",1)||this.isK("if",1)))){let t=this.expr();if(this.isP(":")){this.next();let s=null,i=this.expr();return this.isP(":")&&(this.next(),s=i,i=this.expr()),this.expectP("]"),{kind:"range",start:t,step:s,end:i,pos:e.pos}}let r=[{kind:"item",expr:t}];return this.listRest(r,e.pos)}return this.listRest([],e.pos)}listRest(e,t){if(e.length){if(this.isP("]"))return this.next(),{kind:"list",items:e,pos:t};this.separator("]")}for(;!this.isP("]");)e.push(this.listItem()),this.separator("]");return this.next(),{kind:"list",items:e,pos:t}}listItem(){let e=this.peek();if(this.isK("for")&&this.isP("(",1)){this.next();let t=this.assigns(),r=this.listItem();return{kind:"for",assigns:t,body:r,pos:e.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let t=this.expr();this.expectP(")");let r=this.listItem(),s=null;return this.isK("else")&&(this.next(),s=this.listItem()),{kind:"if",cond:t,then:r,else:s}}if(this.isK("let")&&this.isP("(",1)){this.next();let t=this.assigns(),r=this.listItem();return{kind:"let",assigns:t,body:r,pos:e.pos,end:this.last()}}if(this.isK("each"))return this.next(),{kind:"each",expr:this.expr()};if(this.isP("(")&&(this.isK("for",1)||this.isK("if",1))){this.next();let t=this.listItem();return this.expectP(")"),t}return{kind:"item",expr:this.expr()}}};Wt.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var mr=Wt;function Ls(n){switch(n.kind){case"num":case"str":case"bool":return{ok:!0,value:n.value};case"unary":return n.op==="-"&&n.arg.kind==="num"?{ok:!0,value:-n.arg.value}:{ok:!1};case"list":{let e=[];for(let t of n.items){if(t.kind!=="item")return{ok:!1};let r=Ls(t.expr);if(!r.ok||typeof r.value!="number")return{ok:!1};e.push(r.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function Ps(n){let e=Number(n.trim());return n.trim()!==""&&Number.isFinite(e)?e:void 0}function Ts(n){let{program:e,comments:t}=ot(n),r=t.filter(a=>a.block&&/^\[[^\]]+\]$/.test(a.text)),s=new Map(t.filter(a=>!a.block&&!a.own).map(a=>[a.line,a.text])),i=new Map(t.filter(a=>!a.block&&a.own).map(a=>[a.line,a.text])),o=[];for(let a of e.body){if(a.kind!=="assign"||/^\$f[nas]$/.test(a.name))continue;let l=Ls(a.value);if(!l.ok)continue;let u=r.filter(g=>g.line<=a.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(u.toLowerCase()==="hidden")continue;let c=s.get(a.pos.line),h=i.get(a.pos.line-1)??"",f=l.value,p={name:a.name,caption:h,group:u,type:typeof f=="number"||Array.isArray(f)?"number":typeof f=="boolean"?"boolean":"string",initial:f,span:a.span},d=c?/^\[(.*)\]$/.exec(c.trim()):null;if(d){let g=d[1];if(g.includes(",")||/[a-zA-Z"]/.test(g)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(g))p.options=g.split(",").map(m=>{let[x,L]=m.split(":").map(E=>E.trim().replace(/^"|"$/g,"")),b=Ps(x),M=p.type==="number"&&b!==void 0?b:x;return{name:L??x,value:M}});else{let m=g.split(":").map(Ps);m.every(x=>x!==void 0)&&(m.length===1?p.max=m[0]:m.length===2?(p.min=m[0],p.max=m[1]):(p.min=m[0],p.step=m[1],p.max=m[2]))}}o.push(p)}return{parameters:o}}var P=(n,e,t)=>({name:n,...t!==void 0&&{default:t},...e&&{doc:e}}),Le=(n,e,t)=>({...P(n,e,t),named:!0}),vr="max(3 * $thickness, 6)",wn=[P("value")],Oa=[P("x")],Me=(n,e)=>({name:n,kind:"function",params:Oa,section:"Numbers and vectors",doc:e}),Mt=(n,e)=>({name:n,kind:"function",params:wn,section:"Types",doc:`Whether the value is ${e}`}),Is=(n,e)=>({name:n,kind:"function",params:[P("text","The text to measure",'""'),P("size","Font size in millimetres","10"),P("font","Font name","$font"),Le("halign","left, center or right",'"left"'),Le("valign","baseline, top, center or bottom",'"baseline"'),Le("spacing","Letter spacing factor","1")],section:"Text measurements",doc:e}),kn=[{name:"rect",kind:"module",params:[P("size","A number, or [width, height]","1"),P("center","Centre the rectangle on the origin instead of its corner","false"),Le("r","Corner radius","0")],section:"Shapes",doc:"A rectangle with its corner at the origin"},{name:"square",kind:"module",params:[P("size","A number, or [width, height]","1"),P("center","Centre the square on the origin instead of its corner","false"),Le("r","Corner radius","0")],section:"Shapes",doc:"Another name for rect()"},{name:"circle",kind:"module",params:[P("r","Radius","1"),Le("d","Diameter, instead of r")],section:"Shapes",doc:"A circle centred on the origin"},{name:"ellipse",kind:"module",params:[P("r","[rx, ry], or one radius for both","1")],section:"Shapes",doc:"An ellipse centred on the origin"},{name:"regular_polygon",kind:"module",params:[P("n","Number of corners","6"),P("r","Distance to the corners","10")],section:"Shapes",doc:"A regular polygon centred on the origin"},{name:"star",kind:"module",params:[P("n","Number of points","5"),P("r","Radius of the points","10"),P("inner","Radius between the points","r * 0.45")],section:"Shapes",doc:"A star centred on the origin"},{name:"polygon",kind:"module",params:[P("points","A list of [x, y] points"),P("paths","Lists of point indexes, one per outline; holes come from even-odd fill")],section:"Shapes",doc:"A shape from a list of points"},{name:"path",kind:"module",params:[P("d",'SVG path data, as "M0 0 L10 0 L5 8 Z"'),Le("fill",'"evenodd" or "nonzero"','"evenodd"')],section:"Shapes",doc:"Shapes from SVG path data: closed subpaths become areas, open ones lines"},{name:"text",kind:"module",params:[P("text","The text",'""'),P("size","Font size in millimetres","10"),P("font","Font name","$font"),Le("halign","left, center or right",'"left"'),Le("valign","baseline, top, center or bottom",'"baseline"'),Le("spacing","Letter spacing factor","1")],section:"Shapes",doc:"Text as shapes; the font must be available to the renderer"},{name:"line",kind:"module",params:[P("from","Start point","[0, 0]"),P("to","End point","[10, 0]")],section:"Shapes",doc:"A straight line, not an area"},{name:"polyline",kind:"module",params:[P("points","A list of [x, y] points"),P("closed","Join the last point to the first","false")],section:"Shapes",doc:"Lines through a list of points"},{name:"arc",kind:"module",params:[P("r","Radius","10"),P("start","Start angle in degrees","0"),P("end","End angle in degrees","90")],section:"Shapes",doc:"An arc line around the origin"},{name:"translate",kind:"module",params:[P("v","[x, y]","[0, 0]")],children:!0,section:"Transforms",doc:"Move the children by x and y"},{name:"rotate",kind:"module",params:[P("a","Angle in degrees, anticlockwise","0"),Le("center","The point to turn around, [x, y]")],children:!0,section:"Transforms",doc:"Rotate the children around the origin or a point"},{name:"scale",kind:"module",params:[P("v","One factor, or [sx, sy]","1")],children:!0,section:"Transforms",doc:"Scale the children"},{name:"mirror",kind:"module",params:[P("v","[nx, ny], perpendicular to the mirror line","[1, 0]")],children:!0,section:"Transforms",doc:"Reflect the children across a line through the origin"},{name:"multmatrix",kind:"module",params:[P("m","A 2 \xD7 3 or 3 \xD7 3 matrix")],children:!0,section:"Transforms",doc:"Apply a transformation matrix to the children"},{name:"union",kind:"module",params:[],children:!0,section:"Combining",doc:"Join the children"},{name:"group",kind:"module",params:[],children:!0,section:"Combining",doc:"Another name for union()"},{name:"difference",kind:"module",params:[],children:!0,section:"Combining",doc:"Remove every later child's area from every layer of the first child"},{name:"intersection",kind:"module",params:[],children:!0,section:"Combining",doc:"Keep only the area common to all children"},{name:"hull",kind:"module",params:[],children:!0,section:"Combining",doc:"The convex hull of the children; each part inside gets its own"},{name:"offset",kind:"module",params:[P("r","Grow (positive) or shrink areas with rounded corners"),Le("delta","Grow or shrink areas with sharp corners","0"),Le("chamfer","Cut the corners off when growing by delta","false")],children:!0,section:"Combining",doc:"Grow or shrink the areas of the children"},{name:"stroke",kind:"module",params:[P("width","Width of the area around each line","1")],children:!0,section:"Combining",doc:"Turn lines into areas, for cutting single-line art"},{name:"outline",kind:"module",params:[],children:!0,section:"Combining",doc:"Turn areas into their outline lines"},{name:"cut",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the cut layer"},{name:"score",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the score layer: lines marked without cutting through"},{name:"engrave",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the engrave layer: areas filled in"},{name:"guide",kind:"module",params:[],children:!0,section:"Layers",doc:"Put the children on the guide layer, which is not cut"},{name:"layer",kind:"module",params:[P("name","Layer name"),P("mode",'"cut", "line", "fill" or "guide"'),P("color",'Colour in the output, as "#00aa00"')],children:!0,section:"Layers",doc:"Put the children on a layer, defining it on first use"},{name:"part",kind:"module",params:[P("name","Part name",'"part"'),P("qty","Number of copies to cut","1"),Le("at","Where the part goes in the assembled view, [x, y, z]"),Le("rotate","How the part is turned in the assembled view, [x, y, z] in degrees")],children:!0,section:"Parts and sheets",doc:"A named part, with its thickness, kerf and material"},{name:"material",kind:"module",params:[P("thickness","Sets $thickness"),P("kerf","Sets $kerf"),P("name","Sets $material")],children:!0,section:"Parts and sheets",doc:"Set the thickness, kerf and material name for the children"},{name:"finger_rect",kind:"module",params:[P("size","[width, height]"),P("edges",'"out", "in" or "flat", or [bottom, right, top, left]','"out"'),P("finger","Finger width",vr)],section:"Joinery",doc:"A rectangle with finger joints, notched $thickness deep"},{name:"finger_holes",kind:"module",params:[P("length","Length of the edge that plugs in"),P("edge",'"out" or "in", the kind of edge that plugs in','"out"'),P("finger","Finger width",vr)],section:"Joinery",doc:"A row of slots along x for a finger edge to plug into"},{name:"tslot",kind:"module",params:[P("d","Screw diameter","3"),P("length","Screw length into the panel","12"),P("nut","Nut size, [width, height]","[d * 1.85, d * 0.8]"),P("nut_at","Distance of the nut from the edge","length / 2")],section:"Joinery",doc:"A T-slot for a screw and nut, opening at y = 0; subtract it from a panel edge"},{name:"living_hinge",kind:"module",params:[P("size","[width, height]"),P("spacing","Distance between the rows of cuts","1.5"),P("bridge","Uncut length between cuts","3"),P("cut","Length of each cut","max(bridge * 2, (height - 3 * bridge) / 2)")],section:"Joinery",doc:"A straight-line flex pattern of cut lines filling [width, height]"},{name:"children",kind:"module",params:[P("index","Which child, from 0, or a list of them")],section:"Other",doc:"Run the child statements passed to the current module"},{name:"echo",kind:"both",params:[],rest:!0,anyNamed:!0,section:"Other",doc:"Write values to the output without making shapes"},{name:"assert",kind:"both",params:[P("condition","Stops the program when false"),P("message","Says why")],section:"Other",doc:"Stop with an error when the condition is false"},Me("abs","Absolute value"),Me("sign","Sign as -1, 0 or 1"),Me("floor","Round down"),Me("ceil","Round up"),Me("round","Round to the nearest integer, halves away from zero"),Me("sqrt","Square root"),Me("exp","e raised to x"),Me("ln","Natural logarithm"),{name:"log",kind:"function",params:[P("x"),P("base",void 0,"10")],forms:["log(x)","log(base, x)"],section:"Numbers and vectors",doc:"Logarithm, base 10 or a chosen base; with two values the base comes first"},Me("sin","Sine of an angle in degrees"),Me("cos","Cosine of an angle in degrees"),Me("tan","Tangent of an angle in degrees"),Me("asin","Inverse sine, in degrees"),Me("acos","Inverse cosine, in degrees"),Me("atan","Inverse tangent, in degrees"),{name:"atan2",kind:"function",params:[P("y"),P("x")],section:"Numbers and vectors",doc:"The angle of the point [x, y] from the x axis, in degrees"},{name:"pow",kind:"function",params:[P("x"),P("y")],section:"Numbers and vectors",doc:"x raised to y"},{name:"min",kind:"function",params:[P("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The smallest of a list, or of several values"},{name:"max",kind:"function",params:[P("values","A list, or the first of several values")],rest:!0,section:"Numbers and vectors",doc:"The largest of a list, or of several values"},{name:"clamp",kind:"function",params:[P("x"),P("low"),P("high")],section:"Numbers and vectors",doc:"x limited to the interval from low to high"},{name:"lerp",kind:"function",params:[P("a"),P("b"),P("t","0 gives a, 1 gives b")],section:"Numbers and vectors",doc:"Interpolate between numbers or vectors"},{name:"norm",kind:"function",params:[P("v")],section:"Numbers and vectors",doc:"The length of a vector"},{name:"cross",kind:"function",params:[P("a"),P("b")],section:"Numbers and vectors",doc:"Cross product: a number for 2D vectors, a vector for 3D ones"},{name:"len",kind:"function",params:wn,section:"Lists and strings",doc:"Number of items in a list or characters in a string"},{name:"concat",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Join lists and single values into one list"},{name:"reverse",kind:"function",params:wn,section:"Lists and strings",doc:"A list or string in reverse order"},{name:"sum",kind:"function",params:[P("values","A list of numbers")],section:"Lists and strings",doc:"The sum of a list of numbers"},{name:"slice",kind:"function",params:[P("value","A list or string"),P("start","First index","0"),P("end","Index after the last; the length when left out")],section:"Lists and strings",doc:"Part of a list or string"},{name:"str",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Values as text, joined"},{name:"chr",kind:"function",params:[],rest:!0,section:"Lists and strings",doc:"Text from Unicode code points"},{name:"ord",kind:"function",params:[P("text")],section:"Lists and strings",doc:"The first character's Unicode code point"},{name:"upper",kind:"function",params:[P("text")],section:"Lists and strings",doc:"Text in capitals"},{name:"lower",kind:"function",params:[P("text")],section:"Lists and strings",doc:"Text in small letters"},{name:"split",kind:"function",params:[P("text"),P("separator",void 0,'" "')],section:"Lists and strings",doc:"Text split into a list of strings"},{name:"join",kind:"function",params:[P("values"),P("separator",void 0,'""')],section:"Lists and strings",doc:"Values joined into one string"},{name:"search",kind:"function",params:[P("value"),P("list","A list or string")],section:"Lists and strings",doc:"Index of the first equal item, or undef"},{name:"contains",kind:"function",params:[P("value","A list or string"),P("item")],section:"Lists and strings",doc:"Whether a list contains an item or a string contains a substring"},{name:"lookup",kind:"function",params:[P("x"),P("table","A list of [x, y] pairs")],section:"Lists and strings",doc:"Interpolate in a table; outside it, the nearest end"},Mt("is_num","a number other than NaN"),Mt("is_string","a string"),Mt("is_bool","true or false"),Mt("is_list","a list"),Mt("is_undef","undef"),Mt("is_function","a function"),{name:"type_of",kind:"function",params:wn,section:"Types",doc:"The type name: number, string, boolean, undef, list, range or function"},{name:"rands",kind:"function",params:[P("min"),P("max"),P("count"),P("seed","The same seed gives the same list","1")],section:"Random values",doc:"A list of count numbers between min and max"},Is("text_width","The advance width of the text, including spacing"),Is("text_metrics","The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),{name:"finger_count",kind:"function",params:[P("length","Edge length"),P("finger","Finger width",vr)],section:"Joint dimensions",doc:"The odd number of fingers finger_rect() puts on an edge of that length"}],Fa=new Map(kn.map(n=>[n.name,n])),Ct=n=>Fa.get(n);function En(n){let e=n.params.map(t=>t.default===void 0?t.name:`${t.name} = ${t.default}`);return n.rest&&e.push("..."),`${n.name}(${e.join(", ")})`}var nt={"kerf/box":`// kerf/box: finger-jointed boxes.
9
9
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
10
10
 
11
11
  // Box from its outer size [width, depth, height] in the current material.
@@ -371,45 +371,45 @@ module tab_rect(size, edges = true, count = undef, width = undef) {
371
371
  if (e[2]) translate([w, h]) rotate(180) tabs(w, count, width);
372
372
  if (e[3]) translate([0, h]) rotate(270) tabs(h, count, width);
373
373
  }
374
- `};var Fa=/^(?:[A-Za-z_$][A-Za-z0-9_]*|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?|"(?:[^"\\]|\\.)*"?|<=|>=|==|!=|&&|\|\|)/,Cs=(n,e)=>Math.max(1,Fa.exec(n.slice(e-1))?.[0].length??1);var Ms=Math.PI/180;function As(n,e){let t=new Array(16).fill(0);for(let r=0;r<4;r++)for(let s=0;s<4;s++)for(let i=0;i<4;i++)t[r*4+s]+=n[r*4+i]*e[i*4+s];return t}function xr(n,e){let t=Math.cos(e*Ms),r=Math.sin(e*Ms);return n===0?[1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1]:n===1?[t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1]:[t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1]}var Rs=n=>Math.abs(n)<1e-12?0:n;function Sr(n){let[e,t,r]=n.rotate,s=As(xr(2,r),As(xr(1,t),xr(0,e)));return s[3]=n.at[0],s[7]=n.at[1],s[11]=n.at[2],s.map(Rs)}function Us(n,e,t,r){return[n[0]*e+n[1]*t+n[2]*r+n[3],n[4]*e+n[5]*t+n[6]*r+n[7],n[8]*e+n[9]*t+n[10]*r+n[11]]}function Da(n){let[e,t,r]=[n[3],n[7],n[11]],s=[n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]];return[s[0],s[1],s[2],-(s[0]*e+s[1]*t+s[2]*r),s[3],s[4],s[5],-(s[3]*e+s[4]*t+s[5]*r),s[6],s[7],s[8],-(s[6]*e+s[7]*t+s[8]*r),0,0,0,1]}function Pn(n){let[e,t,r,s]=[1/0,1/0,-1/0,-1/0];for(let i of n)for(let[o,a]of i)e=Math.min(e,o),t=Math.min(t,a),r=Math.max(r,o),s=Math.max(s,a);return[e,t,r,s]}function Ns(n){let[e,t,r,s]=Pn(n.outline),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of[e,r])for(let l of[t,s])for(let u of[0,n.thickness]){let c=Us(n.matrix,a,l,u);for(let h=0;h<3;h++)i[h]=Math.min(i[h],c[h]),o[h]=Math.max(o[h],c[h])}return[i,o]}function Bs(n,e,t=10){let r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let[c,h]of n.map(Ns))for(let f=0;f<3;f++)r[f]=Math.min(r[f],c[f]),s[f]=Math.max(s[f],h[f]);let i=e.map(c=>Pn(c.outline)),o=i.reduce((c,[h,,f])=>Math.max(c,f-h),s[0]-r[0]),a=0,l=0,u=0;return e.map((c,h)=>{let[f,p,d,g]=i[h];a>0&&a+d-f>o&&(a=0,l+=u+t,u=0);let y=[1,0,0,s[0]+t+a-f,0,1,0,r[1]+l-p,0,0,1,r[2],0,0,0,1];return a+=d-f+t,u=Math.max(u,g-p),{...c,matrix:y.map(Rs)}})}var Ra=(n,e,t)=>[0,1,2].every(r=>n[0][r]<e[1][r]-t&&e[0][r]<n[1][r]-t),En=(n,e)=>n[0]*e[0]+n[1]*e[1]+n[2]*e[2],yr=(n,e)=>[n[1]*e[2]-n[2]*e[1],n[2]*e[0]-n[0]*e[2],n[0]*e[1]-n[1]*e[0]],Os=(n,e,t=1)=>[n[0]+e[0]*t,n[1]+e[1]*t,n[2]+e[2]*t],Ln=n=>[n[2],n[6],n[10]],Fs=n=>[n[3],n[7],n[11]],Ua=(n,e)=>[n[0]*e[0]+n[1]*e[1]+n[2]*e[2],n[4]*e[0]+n[5]*e[1]+n[6]*e[2],n[8]*e[0]+n[9]*e[1]+n[10]*e[2]];function Ot(n,e,t){let r=t[0]*t[0]+t[1]*t[1],s=[];for(let i of n)for(let o=0,a=i.length-1;o<i.length;a=o++){let l=i[a],u=i[o],c=t[0]*(l[1]-e[1])-t[1]*(l[0]-e[0]),h=t[0]*(u[1]-e[1])-t[1]*(u[0]-e[0]);if(c>0==h>0)continue;let f=c/(c-h),p=l[0]+(u[0]-l[0])*f-e[0],d=l[1]+(u[1]-l[1])*f-e[1];s.push((p*t[0]+d*t[1])/r)}return s.sort((i,o)=>i-o)}function br(n,e,t){let r=0,s=0,i=0;for(;s+1<n.length&&i+1<e.length;){let o=Math.min(n[s+1],e[i+1])-Math.max(n[s],e[i]);o>t&&(r+=o),n[s+1]<e[i+1]?s+=2:i+=2}return r}function Tn(n,e,t,r){let s=n+t,i=e-t;if(i<=s)return{at:[],size:0};let o=Math.max(4,Math.ceil((i-s)/r));return{at:Array.from({length:o},(a,l)=>s+(i-s)*(l+.5)/o),size:(i-s)/o}}function Ds(n,e,t){let r=Us(n,e[0],e[1],e[2]),s=Ua(n,t);return[[r[0],r[1]],[s[0],s[1]]]}function Na(n,e,t,r,s,i,o){let a=Ln(n.matrix),l=Ln(e.matrix),u=yr(a,l),c=Math.hypot(...u),h=[u[0]/c,u[1]/c,u[2]/c],f=yr(h,a),p=En(l,f),d=Fs(n.matrix),g=En(l,Fs(e.matrix)),y=Tn(0,n.thickness,s,i),x=0;for(let I of y.at){let k=Os(d,a,I),F=(g-En(l,k))/p,L=(g+e.thickness-En(l,k))/p,U=Tn(Math.min(F,L),Math.max(F,L),s,i);for(let P of U.at){let T=Os(k,f,P),[H,S]=Ds(t,T,h),[D,ce]=Ds(r,T,h);if(x+=br(Ot(n.outline,H,S),Ot(e.outline,D,ce),s)*y.size*U.size,x>o)return!0}}return!1}function Ba(n,e,t,r,s,i){let o=[0,1,2,3].flatMap(P=>[0,1,2,3].map(T=>{let H=0;for(let S=0;S<4;S++)H+=t[P*4+S]*e.matrix[S*4+T];return H})),a=o[11],l=o[11]+o[10]*e.thickness,u=Math.min(n.thickness,Math.max(a,l))-Math.max(0,Math.min(a,l));if(u<=r)return!1;let c=e.outline.map(P=>P.map(([T,H])=>[o[0]*T+o[1]*H+o[3],o[4]*T+o[5]*H+o[7]])),[h,f,p,d]=Pn(n.outline),[g,y,x,I]=Pn(c),k=Tn(Math.max(f,y),Math.min(d,I),r,s),F=0;for(let P of k.at)if(F+=br(Ot(n.outline,[0,P],[1,0]),Ot(c,[0,P],[1,0]),r)*k.size*u,F>i)return!0;let L=Tn(Math.max(h,g),Math.min(p,x),r,s),U=0;for(let P of L.at)if(U+=br(Ot(n.outline,[P,0],[0,1]),Ot(c,[P,0],[0,1]),r)*L.size*u,U>i)return!0;return!1}function Gs(n,e=1/0,t=.05,r=.25,s=1){let i=n.map(Ns),o=n.map(c=>Da(c.matrix)),a=n.map((c,h)=>h).sort((c,h)=>i[c][0][0]-i[h][0][0]),l=[],u=0;for(let c=0;c<a.length;c++)for(let h=c+1;h<a.length;h++){let f=a[c],p=a[h];if(i[p][0][0]>=i[f][1][0]-t)break;if(!Ra(i[f],i[p],t))continue;if(++u>e)return{found:l,complete:!1};let[d,g]=f<p?[n[f],n[p]]:[n[p],n[f]],[y,x]=f<p?[o[f],o[p]]:[o[p],o[f]];(Math.hypot(...yr(Ln(d.matrix),Ln(g.matrix)))<1e-9?Ba(d,g,y,t,r,s):Na(d,g,y,x,t,r,s))&&l.push([d,g])}return{found:l,complete:!0}}var ze=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="range",ot=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="function",zs=n=>typeof n=="number",Ft=(n,e)=>n&&Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function wr(n,e,t=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&t<32){for(let r of e)wr(n,r,t+1);return}throw new Error(`Setting "${n}" must be a number, string, boolean or list`)}}function Cn(n,e){let t=[];if(n.step===0||(n.step>0?n.start>n.end:n.start<n.end))return t;let r=Math.floor((n.end-n.start)/n.step+1e-9)+1;if(r>e)throw new Error(`a range of ${r} items is more than the limit of ${e}`);for(let s=0;s<r;s++)t.push(n.start+s*n.step);return t}function Fe(n){return n===void 0||n===!1||n===0||n===""?!1:Array.isArray(n)?n.length>0:typeof n=="number"?!Number.isNaN(n):!0}var $s=(n,e)=>ze(n)&&ze(e)?n.start===e.start&&n.step===e.step&&n.end===e.end:n===e;function Zt(n,e,t){if(t?.(),!Array.isArray(n)||!Array.isArray(e))return $s(n,e);let r=new Map,s=[],i=(o,a)=>{let l=r.get(o);return l?.has(a)?!0:o.length!==a.length?!1:(l||r.set(o,l=new Set),l.add(a),s.push([o,a,0]),!0)};if(!i(n,e))return!1;for(;s.length;){let o=s[s.length-1];if(o[2]===o[0].length){s.pop();continue}let a=o[0][o[2]],l=o[1][o[2]++];if(t?.(),Array.isArray(a)&&Array.isArray(l)?!i(a,l):!$s(a,l))return!1}return!0}function Ne(n){return n===void 0?"undef":Array.isArray(n)?"list":ze(n)?"range":ot(n)?"function":typeof n}function Ga(n){return n===void 0?"undef":typeof n=="string"?JSON.stringify(n):typeof n=="number"?In(n):ze(n)?`[${In(n.start)}:${In(n.step)}:${In(n.end)}]`:ot(n)?`function(${n.params.map(e=>e.name).join(", ")})`:String(n)}function Dt(n,e,t=!1){if(typeof n=="string"&&!t)return{text:n.length>e?n.slice(0,Math.max(e,0)):n,whole:n.length<=e};let r=[],s=0,i=u=>{r.push(u),s+=u.length},o=[],a=n;for(;;){Array.isArray(a)?(i("["),o.push([a,0])):i(Ga(a));let u=!1;for(;o.length&&!u;){let c=o[o.length-1];c[1]<c[0].length?(c[1]&&i(", "),a=c[0][c[1]++],u=!0):(o.pop(),i("]"))}if(!u||s>e)break}let l=r.join("");return s>e?{text:l.slice(0,Math.max(e,0)),whole:!1}:{text:l,whole:!0}}function Hs(n,e,t){let r=[],s=0;for(let i of n){r.length&&(s+=e.length);let o=Dt(i,t-s);if(!o.whole)return;s+=o.text.length,r.push(o.text)}return r.join(e)}function xt(n){let e=Dt(n,200,!0);return e.whole?e.text:e.text+"..."}var He=n=>typeof n=="string"?n:xt(n);function Ee(n){let e=!1;for(;Array.isArray(n)&&n.length===1;)n=n[0],e=!0;return Array.isArray(n)?n.length?NaN:0:e&&(n===void 0||typeof n=="boolean")?n===void 0?0:NaN:typeof n=="object"?NaN:Number(n)}function In(n){return Number.isInteger(n)?String(n):String(Number(n.toPrecision(10)))}var yt=Math.PI/180,W=(n,e,t)=>({params:n.replace("...","").split(",").map(r=>r.trim()).filter(Boolean),rest:n.endsWith("..."),order:t,run:e});function Xs(n,e,t){return n.order?[]:n.params.filter((r,s)=>s<e.length&&t.has(r))}function qs(n,e,t){if(n.rest){let i=[...e];return n.params.forEach((o,a)=>{t.has(o)&&(i[a]=t.get(o))}),i}if(!n.order)return n.params.map((i,o)=>t.has(i)?t.get(i):e[o]);let r=e.length+n.params.filter(i=>t.has(i)).length,s=n.order(r).filter(i=>!t.has(i));return n.params.map(i=>t.has(i)?t.get(i):e[s.indexOf(i)])}function kr(n,e,t,r){let s=Hs(n,e,t.maxLength);if(s===void 0)throw new Error(`${r}(): the text would be longer than the limit of ${t.maxLength} characters`);return t.step(Math.ceil(s.length/8)),s}function Z(n,e){if(typeof n!="number")throw new Error(`${e}() needs a number, got ${Ne(n)}`);return n}function Ze(n,e,t){if(Array.isArray(n))return n;if(ze(n))return Cn(n,t.maxLength);if(typeof n=="string")return[...n];throw new Error(`${e}() needs a list, got ${Ne(n)}`)}var $a=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function Ws(n,e,t){if($a.has(n))return 0;let r=0;for(let s of e)if(typeof s=="string")r+=s.length;else if(Array.isArray(s))r+=n==="len"?0:s.length;else if(ze(s)&&s.step!==0){let i=Math.floor((s.end-s.start)/s.step)+1;i>0&&(r+=Math.min(i,t+1))}return r}var Me=n=>W("x",e=>typeof e[0]=="number"?Er(n(e[0])):void 0);function Er(n){let e=Math.round(n);return Math.abs(n-e)<1e-12?e:n}function za(n){let e=Math.floor(n)>>>0||2654435769;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function Vs(n,e,t){let r=n.length===1&&Array.isArray(n[0])?n[0]:n;if(r.length)return e(r.map(s=>Z(s,t)))}var Pr={abs:Me(Math.abs),sign:Me(Math.sign),floor:Me(Math.floor),ceil:Me(Math.ceil),round:Me(n=>n<0?-Math.round(-n):Math.round(n)),sqrt:Me(Math.sqrt),exp:Me(Math.exp),ln:Me(Math.log),log:W("x, base",(n,e)=>e.given<2?Er(Math.log10(Z(n[0],"log"))):Math.log(Z(n[0],"log"))/Math.log(Z(n[1],"log")),n=>n>=2?["base","x"]:["x","base"]),sin:Me(n=>Math.sin(n*yt)),cos:Me(n=>Math.cos(n*yt)),tan:Me(n=>Math.tan(n*yt)),asin:Me(n=>Math.asin(n)/yt),acos:Me(n=>Math.acos(n)/yt),atan:Me(n=>Math.atan(n)/yt),atan2:W("y, x",n=>Er(Math.atan2(Z(n[0],"atan2"),Z(n[1],"atan2"))/yt)),pow:W("x, y",n=>Math.pow(Z(n[0],"pow"),Z(n[1],"pow"))),min:W("values...",n=>Vs(n,e=>e.reduce((t,r)=>r<t?r:t,1/0),"min")),max:W("values...",n=>Vs(n,e=>e.reduce((t,r)=>r>t?r:t,-1/0),"max")),clamp:W("x, low, high",n=>Math.min(Math.max(Z(n[0],"clamp"),Z(n[1],"clamp")),Z(n[2],"clamp"))),lerp:W("a, b, t",n=>{let e=Z(n[2],"lerp");if(Array.isArray(n[0])&&Array.isArray(n[1])){let t=n[1];return n[0].map((r,s)=>Z(r,"lerp")+(Z(t[s],"lerp")-Z(r,"lerp"))*e)}return Z(n[0],"lerp")+(Z(n[1],"lerp")-Z(n[0],"lerp"))*e}),norm:W("v",(n,e)=>Math.sqrt(Ze(n[0],"norm",e).reduce((t,r)=>t+Z(r,"norm")**2,0))),cross:W("a, b",(n,e)=>{let t=Ze(n[0],"cross",e).map(s=>Z(s,"cross")),r=Ze(n[1],"cross",e).map(s=>Z(s,"cross"));return t.length===2?t[0]*r[1]-t[1]*r[0]:[t[1]*r[2]-t[2]*r[1],t[2]*r[0]-t[0]*r[2],t[0]*r[1]-t[1]*r[0]]}),len:W("value",n=>typeof n[0]=="string"?[...n[0]].length:Array.isArray(n[0])?n[0].length:void 0),concat:W("...",(n,e)=>{let t=n.reduce((r,s)=>r+(Array.isArray(s)?s.length:1),0);if(t>e.maxLength)throw new Error(`concat(): a list of ${t} items is more than the limit of ${e.maxLength}`);return n.flatMap(r=>Array.isArray(r)?r:[r])}),reverse:W("value",(n,e)=>typeof n[0]=="string"?[...n[0]].reverse().join(""):[...Ze(n[0],"reverse",e)].reverse()),sum:W("values",(n,e)=>Ze(n[0],"sum",e).reduce((t,r)=>t+Z(r,"sum"),0)),slice:W("value, start, end",(n,e)=>{let r=(typeof n[0]=="string"?[...n[0]]:Ze(n[0],"slice",e)).slice(Z(n[1]??0,"slice"),n[2]===void 0?void 0:Z(n[2],"slice"));return typeof n[0]=="string"?r.join(""):r}),str:W("...",(n,e)=>kr(n,"",e,"str")),chr:W("...",n=>n.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(Z(e,"chr"))).join("")),ord:W("text",n=>typeof n[0]=="string"&&n[0].length?n[0].codePointAt(0):void 0),upper:W("text",n=>typeof n[0]=="string"?n[0].toUpperCase():void 0),lower:W("text",n=>typeof n[0]=="string"?n[0].toLowerCase():void 0),split:W("text, separator",n=>typeof n[0]=="string"?n[0].split(typeof n[1]=="string"?n[1]:" "):void 0),join:W("values, separator",(n,e)=>kr(Ze(n[0],"join",e),typeof n[1]=="string"?n[1]:"",e,"join")),search:W("value, list",(n,e)=>{let r=(typeof n[1]=="string"?[...n[1]]:Ze(n[1],"search",e)).findIndex(s=>Zt(s,n[0],e.step));return r<0?void 0:r}),contains:W("value, item",(n,e)=>typeof n[0]=="string"?n[0].includes(kr([n[1]],"",e,"contains")):Ze(n[0],"contains",e).some(t=>Zt(t,n[1],e.step))),lookup:W("x, table",(n,e)=>{let t=Z(n[0],"lookup"),r=Ze(n[1],"lookup",e);if(!r.length)return;let s=r.map(i=>[Z(i[0],"lookup"),Z(i[1],"lookup")]).sort((i,o)=>i[0]-o[0]);if(t<=s[0][0])return s[0][1];for(let i=1;i<s.length;i++)if(t<=s[i][0]){let[o,a]=s[i-1],[l,u]=s[i];return a+(t-o)/(l-o)*(u-a)}return s[s.length-1][1]}),rands:W("min, max, count, seed",n=>{let e=Z(n[0],"rands"),t=Z(n[1],"rands"),r=Z(n[2],"rands"),s=za(n[3]===void 0?1:Z(n[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(r)),1e6)},()=>e+(t-e)*s())}),is_num:W("value",n=>zs(n[0])&&!Number.isNaN(n[0])),is_string:W("value",n=>typeof n[0]=="string"),is_bool:W("value",n=>typeof n[0]=="boolean"),is_list:W("value",n=>Array.isArray(n[0])),is_undef:W("value",n=>n[0]===void 0),is_function:W("value",n=>ot(n[0])),type_of:W("value",n=>Ne(n[0]))};var Q;(function(n){n[n.NoClip=0]="NoClip",n[n.Intersection=1]="Intersection",n[n.Union=2]="Union",n[n.Difference=3]="Difference",n[n.Xor=4]="Xor"})(Q||(Q={}));var ke;(function(n){n[n.Subject=0]="Subject",n[n.Clip=1]="Clip"})(ke||(ke={}));var V;(function(n){n[n.EvenOdd=0]="EvenOdd",n[n.NonZero=1]="NonZero",n[n.Positive=2]="Positive",n[n.Negative=3]="Negative"})(V||(V={}));var X;(function(n){n[n.IsOn=0]="IsOn",n[n.IsInside=1]="IsInside",n[n.IsOutside=2]="IsOutside"})(X||(X={}));var Rt=Number.MAX_SAFE_INTEGER,me=Math.floor(Math.sqrt(Rt));function Mn(n,e){return!Number.isSafeInteger(n)||!Number.isSafeInteger(e)?!1:n===0||e===0?!0:Math.abs(n)<=Rt/Math.abs(e)}function _s(n,e){return Math.abs(n)+Math.abs(e)<=Rt}function Lr(n,e,t,r){if(Mn(n,e)&&Mn(t,r)){let s=n*e,i=t*r;if(_s(s,i))return s-i}return Number.isSafeInteger(n)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(r)?Number(BigInt(n)*BigInt(e)-BigInt(t)*BigInt(r)):n*e-t*r}function Tr(n,e,t,r){if(Mn(n,e)&&Mn(t,r)){let s=n*e,i=t*r;if(_s(s,i))return s+i}return Number.isSafeInteger(n)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(r)?Number(BigInt(n)*BigInt(e)+BigInt(t)*BigInt(r)):n*e+t*r}var Ir=BigInt(0),An=BigInt(2),Ha=BigInt(4),Va=BigInt(64),Xa=BigInt("0xFFFFFFFFFFFFFFFF"),Ar=BigInt("9223372036854775807"),Yt=Number(Ar/Ha),js=Number(Ar),Zs=1e-12,qa=.1,Cr=Math.floor(me/2),Wa=Math.floor(Math.sqrt(Math.sqrt(Rt/4)));function _a(n){if(!Number.isFinite(n))throw new RangeError("Scale must be a finite number");let e=Math.abs(n);return e===0?Number.POSITIVE_INFINITY:Rt/e}function ja(n,e,t){if(!Number.isFinite(n)||Math.abs(n)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${t}`)}function Za(n,e){if(!Number.isFinite(n)||Math.abs(n)>Rt)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function Ya(n,e,t){let r=e.x-n.x,s=t.y-e.y,i=e.y-n.y,o=t.x-e.x;return Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me?r*s-i*o:Lr(r,s,i,o)}function Be(n,e,t){let r=e.x-n.x,s=t.y-e.y,i=e.y-n.y,o=t.x-e.x;if(Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}let a=BigInt(r)*BigInt(s),l=BigInt(i)*BigInt(o);return a===l?0:a>l?1:-1}function Ka(n){if(n<-8||n>8)throw new Error("Error: Precision is out of range.")}function Ja(n){return Math.abs(n)<=Zs}function Qa(n){return n<0?-1:n>0?1:0}function el(n,e){let t=BigInt(n),r=BigInt(e),s=t*r;return{lo64:s&Xa,hi64:s>>Va}}function Ys(n,e,t,r){let s=Math.abs(n),i=Math.abs(e),o=Math.abs(t),a=Math.abs(r);if(s<me&&i<me&&o<me&&a<me)return n*e===t*r;let l=(n<0?-1:n>0?1:0)*(e<0?-1:e>0?1:0),u=(t<0?-1:t>0?1:0)*(r<0?-1:r>0?1:0);if(l!==u)return!1;if(l===0)return!0;if(!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a))return n*e===t*r;let c=BigInt(s),h=BigInt(i),f=BigInt(o),p=BigInt(a);return c*h===f*p}function tl(n,e,t){let r=e.x-n.x,s=t.y-e.y,i=e.y-n.y,o=t.x-e.x;return Ys(r,s,i,o)}function nl(n,e,t){let r=e.x-n.x,s=t.x-e.x,i=e.y-n.y,o=t.y-e.y;return Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me?r*s+i*o:Tr(r,s,i,o)}function rl(n,e,t){let r=e.x-n.x,s=t.x-e.x,i=e.y-n.y,o=t.y-e.y;if(Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me){let l=r*s+i*o;return l>0?1:l<0?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let l=r*s+i*o;return l>0?1:l<0?-1:0}let a=BigInt(r)*BigInt(s)+BigInt(i)*BigInt(o);return a===Ir?0:a>Ir?1:-1}function sl(n){let e=n.length;if(e<3)return 0;let t=!0;for(let i=0;i<e&&t;i++){let o=n[i];(Math.abs(o.x)>=Cr||Math.abs(o.y)>=Cr)&&(t=!1)}let r=n[e-1];if(t){let i=0;for(let o of n)i+=(r.y+o.y)*(r.x-o.x),r=o;return i*.5}let s=Ir;for(let i of n){let o=r.y+i.y,a=r.x-i.x;if(Number.isSafeInteger(o)&&Number.isSafeInteger(a))s+=BigInt(o)*BigInt(a);else if(Number.isSafeInteger(r.y)&&Number.isSafeInteger(i.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(i.x)){let l=BigInt(r.y)+BigInt(i.y),u=BigInt(r.x)-BigInt(i.x);s+=l*u}else s+=BigInt(Math.round(o*a));r=i}return Number(s)*.5}function il(n,e){return n.y*e.x-e.y*n.x}function ol(n,e){return n.x*e.x+n.y*e.y}function al(n){let e=Math.round(n);return n===e-.5&&(e&1)!==0?e-1:e}function ll(n){return n>=Yt||n<=-Yt?js:Math.round(n)}function ul(n,e,t,r){let s=e.y-n.y,i=e.x-n.x,o=r.y-t.y,a=r.x-t.x,l=Lr(s,a,o,i);if(l===0)return null;let u=Lr(n.x-t.x,o,n.y-t.y,a)/l;return u<=0?{x:n.x,y:n.y,z:n.z||0}:u>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(n.x+u*i),y:Math.trunc(n.y+u*s),z:0}}function cl(n,e,t,r){let s=e.y-n.y,i=e.x-n.x,o=r.y-t.y,a=r.x-t.x,l=s*a-o*i;if(l===0)return{success:!1,ip:{x:0,y:0,z:0}};let u=((n.x-t.x)*o-(n.y-t.y)*a)/l,c;return u<=0?c={...n,z:0}:u>=1?c={...e,z:0}:c={x:n.x+u*i,y:n.y+u*s,z:0},{success:!0,ip:c}}function fl(n,e,t,r,s=!1){if(!s){let u=Be(n,t,r),c=Be(e,t,r),h=Be(t,n,e),f=Be(r,n,e);return u!==0&&c!==0&&u!==c&&h!==0&&f!==0&&h!==f}let i=Be(n,t,r),o=Be(e,t,r);if(i!==0&&i===o)return!1;let a=Be(t,n,e),l=Be(r,n,e);return a!==0&&a===l?!1:i!==0||o!==0||a!==0||l!==0}function Ks(n){if(n.length===0)return{left:0,top:0,right:0,bottom:0};let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let t of n)t.x<e.left&&(e.left=t.x),t.x>e.right&&(e.right=t.x),t.y<e.top&&(e.top=t.y),t.y>e.bottom&&(e.bottom=t.y);return e.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:e}function hl(n,e,t){if(e.x===t.x&&e.y===t.y)return{x:e.x,y:e.y,z:0};let r=t.x-e.x,s=t.y-e.y,i=Tr(n.x-e.x,r,n.y-e.y,s)/Tr(r,r,s,s),o=i<0?0:i>1?1:i;return{x:Math.round(e.x+o*r),y:Math.round(e.y+o*s),z:0}}function Mr(n,e){let t=e.length,r=0;if(t<3)return X.IsOutside;for(;r<t&&e[r].y===n.y;)r++;if(r===t)return X.IsOutside;let s=e[r].y<n.y,i=s,o=0,a=r+1,l=t;for(;;){if(a===l){if(l===0||r===0)break;l=r,a=0}if(s)for(;a<l&&e[a].y<n.y;)a++;else for(;a<l&&e[a].y>n.y;)a++;if(a===l)continue;let c=e[a],h=a>0?e[a-1]:e[t-1];if(c.y===n.y){if(c.x===n.x||c.y===h.y&&n.x<h.x!=n.x<c.x)return X.IsOn;if(a++,a===r)break;continue}if(!(n.x<c.x&&n.x<h.x))if(n.x>h.x&&n.x>c.x)o=1-o;else{let f=Be(h,c,n);if(f===0)return X.IsOn;f<0===s&&(o=1-o)}s=!s,a++}if(s===i)return o===0?X.IsOutside:X.IsInside;a===t&&(a=0);let u=a===0?Be(e[t-1],e[0],n):Be(e[a-1],e[a],n);return u===0?X.IsOn:(u<0===s&&(o=1-o),o===0?X.IsOutside:X.IsInside)}function pl(n,e){let t=X.IsOn;for(let a of n)switch(Mr(a,e)){case X.IsOutside:if(t===X.IsOutside)return!1;t=X.IsOutside;break;case X.IsInside:if(t===X.IsInside)return!0;t=X.IsInside;break;default:break}let r=Ks(n),s,i;return Number.isSafeInteger(r.left)&&Number.isSafeInteger(r.right)&&Math.abs(r.left)+Math.abs(r.right)>Number.MAX_SAFE_INTEGER?(s=Number((BigInt(r.left)+BigInt(r.right))/An),i=Number((BigInt(r.top)+BigInt(r.bottom))/An)):(s=Math.round((r.left+r.right)/2),i=Math.round((r.top+r.bottom)/2)),Mr({x:s,y:i},e)!==X.IsOutside}var $={MaxInt64:Ar,MaxCoord:Yt,max_coord:Yt,min_coord:-Yt,Invalid64:js,floatingPointTolerance:Zs,defaultMinimumEdgeLength:qa,maxCoordForSafeAreaProduct:Cr,maxCoordForSafeCrossSq:Wa,maxSafeCoordinateForScale:_a,checkSafeScaleValue:ja,ensureSafeInteger:Za,crossProduct:Ya,crossProductSign:Be,checkPrecision:Ka,isAlmostZero:Ja,triSign:Qa,multiplyUInt64:el,productsAreEqual:Ys,isCollinear:tl,dotProduct:nl,dotProductSign:rl,area:sl,crossProductD:il,dotProductD:ol,roundToEven:al,checkCastInt64:ll,getLineIntersectPt:ul,getLineIntersectPtD:cl,segsIntersect:fl,getBounds:Ks,getClosestPtOnSegment:hl,pointInPolygon:Mr,path2ContainsPath1:pl},Ye={create(n=0,e=0,t=0){return{x:Math.round(n),y:Math.round(e),z:t}},fromPointD(n){return $.ensureSafeInteger(n.x,"Point64Utils.fromPointD"),$.ensureSafeInteger(n.y,"Point64Utils.fromPointD"),{x:Math.round(n.x),y:Math.round(n.y),z:n.z||0}},scale(n,e){return{x:Math.round(n.x*e),y:Math.round(n.y*e),z:n.z||0}},equals(n,e){return n.x===e.x&&n.y===e.y},add(n,e){if(Number.isSafeInteger(n.x)&&Number.isSafeInteger(e.x)&&Number.isSafeInteger(n.y)&&Number.isSafeInteger(e.y)){let t=n.x+e.x,r=n.y+e.y;return Number.isSafeInteger(t)&&Number.isSafeInteger(r)?{x:t,y:r,z:0}:{x:Number(BigInt(n.x)+BigInt(e.x)),y:Number(BigInt(n.y)+BigInt(e.y)),z:0}}return{x:n.x+e.x,y:n.y+e.y,z:0}},subtract(n,e){return{x:n.x-e.x,y:n.y-e.y,z:0}},toString(n){return n.z!==void 0&&n.z!==0?`${n.x},${n.y},${n.z} `:`${n.x},${n.y} `}},On={create(n=0,e=0,t=0){return{x:n,y:e,z:t}},fromPoint64(n){return{x:n.x,y:n.y,z:n.z||0}},scale(n,e){return{x:n.x*e,y:n.y*e,z:n.z||0}},equals(n,e){return $.isAlmostZero(n.x-e.x)&&$.isAlmostZero(n.y-e.y)},negate(n){n.x=-n.x,n.y=-n.y},toString(n,e=2){return n.z!==void 0&&n.z!==0?`${n.x.toFixed(e)},${n.y.toFixed(e)},${n.z}`:`${n.x.toFixed(e)},${n.y.toFixed(e)}`}},bt={create(n=0,e=0,t=0,r=0){return{left:n,top:e,right:t,bottom:r}},createInvalid(){return{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER}},width(n){return n.right-n.left},height(n){return n.bottom-n.top},isEmpty(n){return n.bottom<=n.top||n.right<=n.left},isValid(n){return n.left<Number.MAX_SAFE_INTEGER},midPoint(n){if(Number.isSafeInteger(n.left)&&Number.isSafeInteger(n.right)&&Math.abs(n.left)+Math.abs(n.right)>Number.MAX_SAFE_INTEGER){let e=Number((BigInt(n.left)+BigInt(n.right))/An),t=Number((BigInt(n.top)+BigInt(n.bottom))/An);return{x:e,y:t}}return{x:Math.round((n.left+n.right)/2),y:Math.round((n.top+n.bottom)/2)}},contains(n,e){return e.x>n.left&&e.x<n.right&&e.y>n.top&&e.y<n.bottom},containsRect(n,e){return e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom},intersects(n,e){return Math.max(n.left,e.left)<=Math.min(n.right,e.right)&&Math.max(n.top,e.top)<=Math.min(n.bottom,e.bottom)},asPath(n){return[{x:n.left,y:n.top,z:0},{x:n.right,y:n.top,z:0},{x:n.right,y:n.bottom,z:0},{x:n.left,y:n.bottom,z:0}]}},Or={create(n=0,e=0,t=0,r=0){return{left:n,top:e,right:t,bottom:r}},createInvalid(){return{left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE}},width(n){return n.right-n.left},height(n){return n.bottom-n.top},isEmpty(n){return n.bottom<=n.top||n.right<=n.left},midPoint(n){return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}},contains(n,e){return e.x>n.left&&e.x<n.right&&e.y>n.top&&e.y<n.bottom},containsRect(n,e){return e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom},intersects(n,e){return Math.max(n.left,e.left)<Math.min(n.right,e.right)&&Math.max(n.top,e.top)<Math.min(n.bottom,e.bottom)},asPath(n){return[{x:n.left,y:n.top,z:0},{x:n.right,y:n.top,z:0},{x:n.right,y:n.bottom,z:0},{x:n.left,y:n.bottom,z:0}]}};var Js=Object.freeze(bt.createInvalid()),Qs=Object.freeze(Or.createInvalid());var Kt=BigInt(0),dl=BigInt(2),ei=BigInt(4),Y;(function(n){n[n.None=0]="None",n[n.OpenStart=1]="OpenStart",n[n.OpenEnd=2]="OpenEnd",n[n.LocalMax=4]="LocalMax",n[n.LocalMin=8]="LocalMin"})(Y||(Y={}));var Fr=class{constructor(){b(this,"data",[])}push(e){this.data.push(e),this.siftUp(this.data.length-1)}pop(){if(this.data.length===0)return null;let e=this.data[0],t=this.data.pop();return this.data.length>0&&(this.data[0]=t,this.siftDown(0)),e}clear(){this.data.length=0}siftUp(e){let t=this.data[e];for(;e>0;){let r=e-1>>1;if(this.data[r]>=t)break;this.data[e]=this.data[r],e=r}this.data[e]=t}siftDown(e){let t=this.data.length,r=this.data[e];for(;;){let s=(e<<1)+1;if(s>=t)break;let i=s+1,o=s;if(i<t&&this.data[i]>this.data[s]&&(o=i),this.data[o]<=r)break;this.data[e]=this.data[o],e=o}this.data[e]=r}},Jt=class{constructor(e,t,r){b(this,"pt");b(this,"next",null);b(this,"prev",null);b(this,"flags");this.pt=e,this.flags=t,this.prev=r}},Qt=class{constructor(e,t,r=!1){b(this,"vertex");b(this,"polytype");b(this,"isOpen");this.vertex=e,this.polytype=t,this.isOpen=r}equals(e){return e!==null&&this.vertex===e.vertex}};function ti(n,e,t){return{pt:n,edge1:e,edge2:t}}var nt=class{constructor(e,t){b(this,"pt");b(this,"next");b(this,"prev");b(this,"outrec");b(this,"horz");this.pt=e,this.outrec=t,this.next=this,this.prev=this,this.horz=null}},Te;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right"})(Te||(Te={}));var Dr;(function(n){n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top"})(Dr||(Dr={}));var Fn=class{constructor(){b(this,"idx",0);b(this,"owner",null);b(this,"frontEdge",null);b(this,"backEdge",null);b(this,"pts",null);b(this,"polypath",null);b(this,"bounds",{left:0,top:0,right:0,bottom:0});b(this,"path",[]);b(this,"isOpen",!1);b(this,"splits",null);b(this,"recursiveSplit",null)}},Dn=class{constructor(e){b(this,"leftOp");b(this,"rightOp");b(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},en=class{constructor(e,t){b(this,"op1");b(this,"op2");this.op1=e,this.op2=t}};function gl(n,e){return n.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:n.leftOp.pt.x-e.leftOp.pt.x}function ml(n,e){return n.pt.y!==e.pt.y?n.pt.y>e.pt.y?-1:1:n.pt.x!==e.pt.x?n.pt.x<e.pt.x?-1:1:n.edge1.curX!==e.edge1.curX?n.edge1.curX<e.edge1.curX?-1:1:n.edge2.curX<e.edge2.curX?-1:n.edge2.curX>e.edge2.curX?1:0}var tn=class{constructor(){b(this,"bot",{x:0,y:0});b(this,"top",{x:0,y:0});b(this,"curX",0);b(this,"dx",0);b(this,"windDx",0);b(this,"windCount",0);b(this,"windCount2",0);b(this,"outrec",null);b(this,"prevInAEL",null);b(this,"nextInAEL",null);b(this,"prevInSEL",null);b(this,"nextInSEL",null);b(this,"jump",null);b(this,"vertexTop",null);b(this,"localMin",null);b(this,"isLeftBound",!1);b(this,"joinWith",Te.None)}},Ut={addLocMin(n,e,t,r){if((n.flags&Y.LocalMin)!==Y.None)return;n.flags|=Y.LocalMin;let s=new Qt(n,e,t);r.push(s)},addPathsToVertexList(n,e,t,r,s){for(let i=0,o=n.length;i<o;i++){let a=n[i],l=null,u=null,c=null;for(let d=0,g=a.length;d<g;d++){let y=a[d];if(l===null)l=new Jt(y,Y.None,null),s.push(l),u=l,c=y;else if(!(c.x===y.x&&c.y===y.y)){let x=new Jt(y,Y.None,u);u.next=x,u=x,c=y}}if(u?.prev==null||(!t&&u.pt.x===l.pt.x&&u.pt.y===l.pt.y&&(u=u.prev),u.next=l,l.prev=u,!t&&u.next===u))continue;let h;if(t){let d=l.next;for(;d!==l&&d.pt.y===l.pt.y;)d=d.next;h=d.pt.y<=l.pt.y,h?(l.flags=Y.OpenStart,Ut.addLocMin(l,e,!0,r)):l.flags=Y.OpenStart|Y.LocalMax}else{for(u=l.prev;u!==l&&u.pt.y===l.pt.y;)u=u.prev;if(u===l)continue;h=u.pt.y>l.pt.y}let f=h;u=l;let p=l.next;for(;p!==l;)p.pt.y>u.pt.y&&h?(u.flags|=Y.LocalMax,h=!1):p.pt.y<u.pt.y&&!h&&(h=!0,Ut.addLocMin(u,e,t,r)),u=p,p=p.next;t?(u.flags|=Y.OpenEnd,h?u.flags|=Y.LocalMax:Ut.addLocMin(u,e,t,r)):h!==f&&(f?Ut.addLocMin(u,e,!1,r):u.flags|=Y.LocalMax)}}};var Rn=class{constructor(e=null){b(this,"parent");b(this,"children",[]);this.parent=e}get isHole(){return this.getIsHole()}getLevel(){let e=0,t=this.parent;for(;t!==null;)++e,t=t.parent;return e}get level(){return this.getLevel()}getIsHole(){let e=this.getLevel();return e!==0&&(e&1)===0}get count(){return this.children.length}clear(){this.children.length=0}toStringInternal(e,t){let r="",s=" ".repeat(t),i=this.children.length===1?"":"s";(t&1)===0?r+=`${s}+- hole (${e}) contains ${this.children.length} nested polygon${i}.
374
+ `};var Da=/^(?:[A-Za-z_$][A-Za-z0-9_]*|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?|"(?:[^"\\]|\\.)*"?|<=|>=|==|!=|&&|\|\|)/,Ms=(n,e)=>Math.max(1,Da.exec(n.slice(e-1))?.[0].length??1);var Cs=Math.PI/180;function As(n,e){let t=new Array(16).fill(0);for(let r=0;r<4;r++)for(let s=0;s<4;s++)for(let i=0;i<4;i++)t[r*4+s]+=n[r*4+i]*e[i*4+s];return t}function xr(n,e){let t=Math.cos(e*Cs),r=Math.sin(e*Cs);return n===0?[1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1]:n===1?[t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1]:[t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1]}var Rs=n=>Math.abs(n)<1e-12?0:n;function Sr(n){let[e,t,r]=n.rotate,s=As(xr(2,r),As(xr(1,t),xr(0,e)));return s[3]=n.at[0],s[7]=n.at[1],s[11]=n.at[2],s.map(Rs)}function Us(n,e,t,r){return[n[0]*e+n[1]*t+n[2]*r+n[3],n[4]*e+n[5]*t+n[6]*r+n[7],n[8]*e+n[9]*t+n[10]*r+n[11]]}function Ra(n){let[e,t,r]=[n[3],n[7],n[11]],s=[n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]];return[s[0],s[1],s[2],-(s[0]*e+s[1]*t+s[2]*r),s[3],s[4],s[5],-(s[3]*e+s[4]*t+s[5]*r),s[6],s[7],s[8],-(s[6]*e+s[7]*t+s[8]*r),0,0,0,1]}function Ln(n){let[e,t,r,s]=[1/0,1/0,-1/0,-1/0];for(let i of n)for(let[o,a]of i)e=Math.min(e,o),t=Math.min(t,a),r=Math.max(r,o),s=Math.max(s,a);return[e,t,r,s]}function Ns(n){let[e,t,r,s]=Ln(n.outline),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a of[e,r])for(let l of[t,s])for(let u of[0,n.thickness]){let c=Us(n.matrix,a,l,u);for(let h=0;h<3;h++)i[h]=Math.min(i[h],c[h]),o[h]=Math.max(o[h],c[h])}return[i,o]}function Bs(n,e,t=10){let r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let[c,h]of n.map(Ns))for(let f=0;f<3;f++)r[f]=Math.min(r[f],c[f]),s[f]=Math.max(s[f],h[f]);let i=e.map(c=>Ln(c.outline)),o=i.reduce((c,[h,,f])=>Math.max(c,f-h),s[0]-r[0]),a=0,l=0,u=0;return e.map((c,h)=>{let[f,p,d,g]=i[h];a>0&&a+d-f>o&&(a=0,l+=u+t,u=0);let m=[1,0,0,s[0]+t+a-f,0,1,0,r[1]+l-p,0,0,1,r[2],0,0,0,1];return a+=d-f+t,u=Math.max(u,g-p),{...c,matrix:m.map(Rs)}})}var Ua=(n,e,t)=>[0,1,2].every(r=>n[0][r]<e[1][r]-t&&e[0][r]<n[1][r]-t),Pn=(n,e)=>n[0]*e[0]+n[1]*e[1]+n[2]*e[2],yr=(n,e)=>[n[1]*e[2]-n[2]*e[1],n[2]*e[0]-n[0]*e[2],n[0]*e[1]-n[1]*e[0]],Os=(n,e,t=1)=>[n[0]+e[0]*t,n[1]+e[1]*t,n[2]+e[2]*t],Tn=n=>[n[2],n[6],n[10]],Fs=n=>[n[3],n[7],n[11]],Na=(n,e)=>[n[0]*e[0]+n[1]*e[1]+n[2]*e[2],n[4]*e[0]+n[5]*e[1]+n[6]*e[2],n[8]*e[0]+n[9]*e[1]+n[10]*e[2]];function At(n,e,t){let r=t[0]*t[0]+t[1]*t[1],s=[];for(let i of n)for(let o=0,a=i.length-1;o<i.length;a=o++){let l=i[a],u=i[o],c=t[0]*(l[1]-e[1])-t[1]*(l[0]-e[0]),h=t[0]*(u[1]-e[1])-t[1]*(u[0]-e[0]);if(c>0==h>0)continue;let f=c/(c-h),p=l[0]+(u[0]-l[0])*f-e[0],d=l[1]+(u[1]-l[1])*f-e[1];s.push((p*t[0]+d*t[1])/r)}return s.sort((i,o)=>i-o)}function br(n,e,t){let r=0,s=0,i=0;for(;s+1<n.length&&i+1<e.length;){let o=Math.min(n[s+1],e[i+1])-Math.max(n[s],e[i]);o>t&&(r+=o),n[s+1]<e[i+1]?s+=2:i+=2}return r}function In(n,e,t,r){let s=n+t,i=e-t;if(i<=s)return{at:[],size:0};let o=Math.max(4,Math.ceil((i-s)/r));return{at:Array.from({length:o},(a,l)=>s+(i-s)*(l+.5)/o),size:(i-s)/o}}function Ds(n,e,t){let r=Us(n,e[0],e[1],e[2]),s=Na(n,t);return[[r[0],r[1]],[s[0],s[1]]]}function Ba(n,e,t,r,s,i,o){let a=Tn(n.matrix),l=Tn(e.matrix),u=yr(a,l),c=Math.hypot(...u),h=[u[0]/c,u[1]/c,u[2]/c],f=yr(h,a),p=Pn(l,f),d=Fs(n.matrix),g=Pn(l,Fs(e.matrix)),m=In(0,n.thickness,s,i),x=0;for(let L of m.at){let b=Os(d,a,L),M=(g-Pn(l,b))/p,E=(g+e.thickness-Pn(l,b))/p,O=In(Math.min(M,E),Math.max(M,E),s,i);for(let w of O.at){let T=Os(b,f,w),[U,S]=Ds(t,T,h),[A,W]=Ds(r,T,h);if(x+=br(At(n.outline,U,S),At(e.outline,A,W),s)*m.size*O.size,x>o)return!0}}return!1}function Ga(n,e,t,r,s,i){let o=[0,1,2,3].flatMap(w=>[0,1,2,3].map(T=>{let U=0;for(let S=0;S<4;S++)U+=t[w*4+S]*e.matrix[S*4+T];return U})),a=o[11],l=o[11]+o[10]*e.thickness,u=Math.min(n.thickness,Math.max(a,l))-Math.max(0,Math.min(a,l));if(u<=r)return!1;let c=e.outline.map(w=>w.map(([T,U])=>[o[0]*T+o[1]*U+o[3],o[4]*T+o[5]*U+o[7]])),[h,f,p,d]=Ln(n.outline),[g,m,x,L]=Ln(c),b=In(Math.max(f,m),Math.min(d,L),r,s),M=0;for(let w of b.at)if(M+=br(At(n.outline,[0,w],[1,0]),At(c,[0,w],[1,0]),r)*b.size*u,M>i)return!0;let E=In(Math.max(h,g),Math.min(p,x),r,s),O=0;for(let w of E.at)if(O+=br(At(n.outline,[w,0],[0,1]),At(c,[w,0],[0,1]),r)*E.size*u,O>i)return!0;return!1}function Gs(n,e=1/0,t=.05,r=.25,s=1){let i=n.map(Ns),o=n.map(c=>Ra(c.matrix)),a=n.map((c,h)=>h).sort((c,h)=>i[c][0][0]-i[h][0][0]),l=[],u=0;for(let c=0;c<a.length;c++)for(let h=c+1;h<a.length;h++){let f=a[c],p=a[h];if(i[p][0][0]>=i[f][1][0]-t)break;if(!Ua(i[f],i[p],t))continue;if(++u>e)return{found:l,complete:!1};let[d,g]=f<p?[n[f],n[p]]:[n[p],n[f]],[m,x]=f<p?[o[f],o[p]]:[o[p],o[f]];(Math.hypot(...yr(Tn(d.matrix),Tn(g.matrix)))<1e-9?Ga(d,g,m,t,r,s):Ba(d,g,m,x,t,r,s))&&l.push([d,g])}return{found:l,complete:!0}}var ze=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="range",at=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="function",zs=n=>typeof n=="number",Ot=(n,e)=>n&&Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function wr(n,e,t=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&t<32){for(let r of e)wr(n,r,t+1);return}throw new Error(`Setting "${n}" must be a number, string, boolean or list`)}}function Cn(n,e){let t=[];if(n.step===0||(n.step>0?n.start>n.end:n.start<n.end))return t;let r=Math.floor((n.end-n.start)/n.step+1e-9)+1;if(r>e)throw new Error(`a range of ${r} items is more than the limit of ${e}`);for(let s=0;s<r;s++)t.push(n.start+s*n.step);return t}function Fe(n){return n===void 0||n===!1||n===0||n===""?!1:Array.isArray(n)?n.length>0:typeof n=="number"?!Number.isNaN(n):!0}var $s=(n,e)=>ze(n)&&ze(e)?n.start===e.start&&n.step===e.step&&n.end===e.end:n===e;function _t(n,e,t){if(t?.(),!Array.isArray(n)||!Array.isArray(e))return $s(n,e);let r=new Map,s=[],i=(o,a)=>{let l=r.get(o);return l?.has(a)?!0:o.length!==a.length?!1:(l||r.set(o,l=new Set),l.add(a),s.push([o,a,0]),!0)};if(!i(n,e))return!1;for(;s.length;){let o=s[s.length-1];if(o[2]===o[0].length){s.pop();continue}let a=o[0][o[2]],l=o[1][o[2]++];if(t?.(),Array.isArray(a)&&Array.isArray(l)?!i(a,l):!$s(a,l))return!1}return!0}function Ne(n){return n===void 0?"undef":Array.isArray(n)?"list":ze(n)?"range":at(n)?"function":typeof n}function $a(n){return n===void 0?"undef":typeof n=="string"?JSON.stringify(n):typeof n=="number"?Mn(n):ze(n)?`[${Mn(n.start)}:${Mn(n.step)}:${Mn(n.end)}]`:at(n)?`function(${n.params.map(e=>e.name).join(", ")})`:String(n)}function Ft(n,e,t=!1){if(typeof n=="string"&&!t)return{text:n.length>e?n.slice(0,Math.max(e,0)):n,whole:n.length<=e};let r=[],s=0,i=u=>{r.push(u),s+=u.length},o=[],a=n;for(;;){Array.isArray(a)?(i("["),o.push([a,0])):i($a(a));let u=!1;for(;o.length&&!u;){let c=o[o.length-1];c[1]<c[0].length?(c[1]&&i(", "),a=c[0][c[1]++],u=!0):(o.pop(),i("]"))}if(!u||s>e)break}let l=r.join("");return s>e?{text:l.slice(0,Math.max(e,0)),whole:!1}:{text:l,whole:!0}}function Hs(n,e,t){let r=[],s=0;for(let i of n){r.length&&(s+=e.length);let o=Ft(i,t-s);if(!o.whole)return;s+=o.text.length,r.push(o.text)}return r.join(e)}function vt(n){let e=Ft(n,200,!0);return e.whole?e.text:e.text+"..."}var He=n=>typeof n=="string"?n:vt(n);function Ee(n){let e=!1;for(;Array.isArray(n)&&n.length===1;)n=n[0],e=!0;return Array.isArray(n)?n.length?NaN:0:e&&(n===void 0||typeof n=="boolean")?n===void 0?0:NaN:typeof n=="object"?NaN:Number(n)}function Mn(n){return Number.isInteger(n)?String(n):String(Number(n.toPrecision(10)))}var xt=Math.PI/180,Z=(n,e,t)=>({params:n.replace("...","").split(",").map(r=>r.trim()).filter(Boolean),rest:n.endsWith("..."),order:t,run:e});function qs(n,e,t){return n.order?[]:n.params.filter((r,s)=>s<e.length&&t.has(r))}function Xs(n,e,t){if(n.rest){let i=[...e];return n.params.forEach((o,a)=>{t.has(o)&&(i[a]=t.get(o))}),i}if(!n.order)return n.params.map((i,o)=>t.has(i)?t.get(i):e[o]);let r=e.length+n.params.filter(i=>t.has(i)).length,s=n.order(r).filter(i=>!t.has(i));return n.params.map(i=>t.has(i)?t.get(i):e[s.indexOf(i)])}function kr(n,e,t,r){let s=Hs(n,e,t.maxLength);if(s===void 0)throw new Error(`${r}(): the text would be longer than the limit of ${t.maxLength} characters`);return t.step(Math.ceil(s.length/8)),s}function K(n,e){if(typeof n!="number")throw new Error(`${e}() needs a number, got ${Ne(n)}`);return n}function Ze(n,e,t){if(Array.isArray(n))return n;if(ze(n))return Cn(n,t.maxLength);if(typeof n=="string")return[...n];throw new Error(`${e}() needs a list, got ${Ne(n)}`)}var za=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function Ws(n,e,t){if(za.has(n))return 0;let r=0;for(let s of e)if(typeof s=="string")r+=s.length;else if(Array.isArray(s))r+=n==="len"?0:s.length;else if(ze(s)&&s.step!==0){let i=Math.floor((s.end-s.start)/s.step)+1;i>0&&(r+=Math.min(i,t+1))}return r}var Ce=n=>Z("x",e=>typeof e[0]=="number"?Er(n(e[0])):void 0);function Er(n){let e=Math.round(n);return Math.abs(n-e)<1e-12?e:n}function Ha(n){let e=Math.floor(n)>>>0||2654435769;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function Vs(n,e,t){let r=n.length===1&&Array.isArray(n[0])?n[0]:n;if(r.length)return e(r.map(s=>K(s,t)))}var Pr={abs:Ce(Math.abs),sign:Ce(Math.sign),floor:Ce(Math.floor),ceil:Ce(Math.ceil),round:Ce(n=>n<0?-Math.round(-n):Math.round(n)),sqrt:Ce(Math.sqrt),exp:Ce(Math.exp),ln:Ce(Math.log),log:Z("x, base",(n,e)=>e.given<2?Er(Math.log10(K(n[0],"log"))):Math.log(K(n[0],"log"))/Math.log(K(n[1],"log")),n=>n>=2?["base","x"]:["x","base"]),sin:Ce(n=>Math.sin(n*xt)),cos:Ce(n=>Math.cos(n*xt)),tan:Ce(n=>Math.tan(n*xt)),asin:Ce(n=>Math.asin(n)/xt),acos:Ce(n=>Math.acos(n)/xt),atan:Ce(n=>Math.atan(n)/xt),atan2:Z("y, x",n=>Er(Math.atan2(K(n[0],"atan2"),K(n[1],"atan2"))/xt)),pow:Z("x, y",n=>Math.pow(K(n[0],"pow"),K(n[1],"pow"))),min:Z("values...",n=>Vs(n,e=>e.reduce((t,r)=>r<t?r:t,1/0),"min")),max:Z("values...",n=>Vs(n,e=>e.reduce((t,r)=>r>t?r:t,-1/0),"max")),clamp:Z("x, low, high",n=>Math.min(Math.max(K(n[0],"clamp"),K(n[1],"clamp")),K(n[2],"clamp"))),lerp:Z("a, b, t",n=>{let e=K(n[2],"lerp");if(Array.isArray(n[0])&&Array.isArray(n[1])){let t=n[1];return n[0].map((r,s)=>K(r,"lerp")+(K(t[s],"lerp")-K(r,"lerp"))*e)}return K(n[0],"lerp")+(K(n[1],"lerp")-K(n[0],"lerp"))*e}),norm:Z("v",(n,e)=>Math.sqrt(Ze(n[0],"norm",e).reduce((t,r)=>t+K(r,"norm")**2,0))),cross:Z("a, b",(n,e)=>{let t=Ze(n[0],"cross",e).map(s=>K(s,"cross")),r=Ze(n[1],"cross",e).map(s=>K(s,"cross"));return t.length===2?t[0]*r[1]-t[1]*r[0]:[t[1]*r[2]-t[2]*r[1],t[2]*r[0]-t[0]*r[2],t[0]*r[1]-t[1]*r[0]]}),len:Z("value",n=>typeof n[0]=="string"?[...n[0]].length:Array.isArray(n[0])?n[0].length:void 0),concat:Z("...",(n,e)=>{let t=n.reduce((r,s)=>r+(Array.isArray(s)?s.length:1),0);if(t>e.maxLength)throw new Error(`concat(): a list of ${t} items is more than the limit of ${e.maxLength}`);return n.flatMap(r=>Array.isArray(r)?r:[r])}),reverse:Z("value",(n,e)=>typeof n[0]=="string"?[...n[0]].reverse().join(""):[...Ze(n[0],"reverse",e)].reverse()),sum:Z("values",(n,e)=>Ze(n[0],"sum",e).reduce((t,r)=>t+K(r,"sum"),0)),slice:Z("value, start, end",(n,e)=>{let r=(typeof n[0]=="string"?[...n[0]]:Ze(n[0],"slice",e)).slice(K(n[1]??0,"slice"),n[2]===void 0?void 0:K(n[2],"slice"));return typeof n[0]=="string"?r.join(""):r}),str:Z("...",(n,e)=>kr(n,"",e,"str")),chr:Z("...",n=>n.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(K(e,"chr"))).join("")),ord:Z("text",n=>typeof n[0]=="string"&&n[0].length?n[0].codePointAt(0):void 0),upper:Z("text",n=>typeof n[0]=="string"?n[0].toUpperCase():void 0),lower:Z("text",n=>typeof n[0]=="string"?n[0].toLowerCase():void 0),split:Z("text, separator",n=>typeof n[0]=="string"?n[0].split(typeof n[1]=="string"?n[1]:" "):void 0),join:Z("values, separator",(n,e)=>kr(Ze(n[0],"join",e),typeof n[1]=="string"?n[1]:"",e,"join")),search:Z("value, list",(n,e)=>{let r=(typeof n[1]=="string"?[...n[1]]:Ze(n[1],"search",e)).findIndex(s=>_t(s,n[0],e.step));return r<0?void 0:r}),contains:Z("value, item",(n,e)=>typeof n[0]=="string"?n[0].includes(kr([n[1]],"",e,"contains")):Ze(n[0],"contains",e).some(t=>_t(t,n[1],e.step))),lookup:Z("x, table",(n,e)=>{let t=K(n[0],"lookup"),r=Ze(n[1],"lookup",e);if(!r.length)return;let s=r.map(i=>[K(i[0],"lookup"),K(i[1],"lookup")]).sort((i,o)=>i[0]-o[0]);if(t<=s[0][0])return s[0][1];for(let i=1;i<s.length;i++)if(t<=s[i][0]){let[o,a]=s[i-1],[l,u]=s[i];return a+(t-o)/(l-o)*(u-a)}return s[s.length-1][1]}),rands:Z("min, max, count, seed",n=>{let e=K(n[0],"rands"),t=K(n[1],"rands"),r=K(n[2],"rands"),s=Ha(n[3]===void 0?1:K(n[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(r)),1e6)},()=>e+(t-e)*s())}),is_num:Z("value",n=>zs(n[0])&&!Number.isNaN(n[0])),is_string:Z("value",n=>typeof n[0]=="string"),is_bool:Z("value",n=>typeof n[0]=="boolean"),is_list:Z("value",n=>Array.isArray(n[0])),is_undef:Z("value",n=>n[0]===void 0),is_function:Z("value",n=>at(n[0])),type_of:Z("value",n=>Ne(n[0]))};var ie;(function(n){n[n.NoClip=0]="NoClip",n[n.Intersection=1]="Intersection",n[n.Union=2]="Union",n[n.Difference=3]="Difference",n[n.Xor=4]="Xor"})(ie||(ie={}));var ke;(function(n){n[n.Subject=0]="Subject",n[n.Clip=1]="Clip"})(ke||(ke={}));var q;(function(n){n[n.EvenOdd=0]="EvenOdd",n[n.NonZero=1]="NonZero",n[n.Positive=2]="Positive",n[n.Negative=3]="Negative"})(q||(q={}));var X;(function(n){n[n.IsOn=0]="IsOn",n[n.IsInside=1]="IsInside",n[n.IsOutside=2]="IsOutside"})(X||(X={}));var Dt=Number.MAX_SAFE_INTEGER,me=Math.floor(Math.sqrt(Dt));function An(n,e){return!Number.isSafeInteger(n)||!Number.isSafeInteger(e)?!1:n===0||e===0?!0:Math.abs(n)<=Dt/Math.abs(e)}function _s(n,e){return Math.abs(n)+Math.abs(e)<=Dt}function Lr(n,e,t,r){if(An(n,e)&&An(t,r)){let s=n*e,i=t*r;if(_s(s,i))return s-i}return Number.isSafeInteger(n)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(r)?Number(BigInt(n)*BigInt(e)-BigInt(t)*BigInt(r)):n*e-t*r}function Tr(n,e,t,r){if(An(n,e)&&An(t,r)){let s=n*e,i=t*r;if(_s(s,i))return s+i}return Number.isSafeInteger(n)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(r)?Number(BigInt(n)*BigInt(e)+BigInt(t)*BigInt(r)):n*e+t*r}var Ir=BigInt(0),On=BigInt(2),Va=BigInt(4),qa=BigInt(64),Xa=BigInt("0xFFFFFFFFFFFFFFFF"),Ar=BigInt("9223372036854775807"),jt=Number(Ar/Va),js=Number(Ar),Zs=1e-12,Wa=.1,Mr=Math.floor(me/2),_a=Math.floor(Math.sqrt(Math.sqrt(Dt/4)));function ja(n){if(!Number.isFinite(n))throw new RangeError("Scale must be a finite number");let e=Math.abs(n);return e===0?Number.POSITIVE_INFINITY:Dt/e}function Za(n,e,t){if(!Number.isFinite(n)||Math.abs(n)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${t}`)}function Ya(n,e){if(!Number.isFinite(n)||Math.abs(n)>Dt)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function Ka(n,e,t){let r=e.x-n.x,s=t.y-e.y,i=e.y-n.y,o=t.x-e.x;return Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me?r*s-i*o:Lr(r,s,i,o)}function Be(n,e,t){let r=e.x-n.x,s=t.y-e.y,i=e.y-n.y,o=t.x-e.x;if(Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let u=r*s,c=i*o;return u>c?1:u<c?-1:0}let a=BigInt(r)*BigInt(s),l=BigInt(i)*BigInt(o);return a===l?0:a>l?1:-1}function Ja(n){if(n<-8||n>8)throw new Error("Error: Precision is out of range.")}function Qa(n){return Math.abs(n)<=Zs}function el(n){return n<0?-1:n>0?1:0}function tl(n,e){let t=BigInt(n),r=BigInt(e),s=t*r;return{lo64:s&Xa,hi64:s>>qa}}function Ys(n,e,t,r){let s=Math.abs(n),i=Math.abs(e),o=Math.abs(t),a=Math.abs(r);if(s<me&&i<me&&o<me&&a<me)return n*e===t*r;let l=(n<0?-1:n>0?1:0)*(e<0?-1:e>0?1:0),u=(t<0?-1:t>0?1:0)*(r<0?-1:r>0?1:0);if(l!==u)return!1;if(l===0)return!0;if(!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a))return n*e===t*r;let c=BigInt(s),h=BigInt(i),f=BigInt(o),p=BigInt(a);return c*h===f*p}function nl(n,e,t){let r=e.x-n.x,s=t.y-e.y,i=e.y-n.y,o=t.x-e.x;return Ys(r,s,i,o)}function rl(n,e,t){let r=e.x-n.x,s=t.x-e.x,i=e.y-n.y,o=t.y-e.y;return Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me?r*s+i*o:Tr(r,s,i,o)}function sl(n,e,t){let r=e.x-n.x,s=t.x-e.x,i=e.y-n.y,o=t.y-e.y;if(Math.abs(r)<me&&Math.abs(s)<me&&Math.abs(i)<me&&Math.abs(o)<me){let l=r*s+i*o;return l>0?1:l<0?-1:0}if(!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||!Number.isSafeInteger(o)){let l=r*s+i*o;return l>0?1:l<0?-1:0}let a=BigInt(r)*BigInt(s)+BigInt(i)*BigInt(o);return a===Ir?0:a>Ir?1:-1}function il(n){let e=n.length;if(e<3)return 0;let t=!0;for(let i=0;i<e&&t;i++){let o=n[i];(Math.abs(o.x)>=Mr||Math.abs(o.y)>=Mr)&&(t=!1)}let r=n[e-1];if(t){let i=0;for(let o of n)i+=(r.y+o.y)*(r.x-o.x),r=o;return i*.5}let s=Ir;for(let i of n){let o=r.y+i.y,a=r.x-i.x;if(Number.isSafeInteger(o)&&Number.isSafeInteger(a))s+=BigInt(o)*BigInt(a);else if(Number.isSafeInteger(r.y)&&Number.isSafeInteger(i.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(i.x)){let l=BigInt(r.y)+BigInt(i.y),u=BigInt(r.x)-BigInt(i.x);s+=l*u}else s+=BigInt(Math.round(o*a));r=i}return Number(s)*.5}function ol(n,e){return n.y*e.x-e.y*n.x}function al(n,e){return n.x*e.x+n.y*e.y}function ll(n){let e=Math.round(n);return n===e-.5&&(e&1)!==0?e-1:e}function ul(n){return n>=jt||n<=-jt?js:Math.round(n)}function cl(n,e,t,r){let s=e.y-n.y,i=e.x-n.x,o=r.y-t.y,a=r.x-t.x,l=Lr(s,a,o,i);if(l===0)return null;let u=Lr(n.x-t.x,o,n.y-t.y,a)/l;return u<=0?{x:n.x,y:n.y,z:n.z||0}:u>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(n.x+u*i),y:Math.trunc(n.y+u*s),z:0}}function fl(n,e,t,r){let s=e.y-n.y,i=e.x-n.x,o=r.y-t.y,a=r.x-t.x,l=s*a-o*i;if(l===0)return{success:!1,ip:{x:0,y:0,z:0}};let u=((n.x-t.x)*o-(n.y-t.y)*a)/l,c;return u<=0?c={...n,z:0}:u>=1?c={...e,z:0}:c={x:n.x+u*i,y:n.y+u*s,z:0},{success:!0,ip:c}}function hl(n,e,t,r,s=!1){if(!s){let u=Be(n,t,r),c=Be(e,t,r),h=Be(t,n,e),f=Be(r,n,e);return u!==0&&c!==0&&u!==c&&h!==0&&f!==0&&h!==f}let i=Be(n,t,r),o=Be(e,t,r);if(i!==0&&i===o)return!1;let a=Be(t,n,e),l=Be(r,n,e);return a!==0&&a===l?!1:i!==0||o!==0||a!==0||l!==0}function Ks(n){if(n.length===0)return{left:0,top:0,right:0,bottom:0};let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let t of n)t.x<e.left&&(e.left=t.x),t.x>e.right&&(e.right=t.x),t.y<e.top&&(e.top=t.y),t.y>e.bottom&&(e.bottom=t.y);return e.left===Number.MAX_SAFE_INTEGER?{left:0,top:0,right:0,bottom:0}:e}function pl(n,e,t){if(e.x===t.x&&e.y===t.y)return{x:e.x,y:e.y,z:0};let r=t.x-e.x,s=t.y-e.y,i=Tr(n.x-e.x,r,n.y-e.y,s)/Tr(r,r,s,s),o=i<0?0:i>1?1:i;return{x:Math.round(e.x+o*r),y:Math.round(e.y+o*s),z:0}}function Cr(n,e){let t=e.length,r=0;if(t<3)return X.IsOutside;for(;r<t&&e[r].y===n.y;)r++;if(r===t)return X.IsOutside;let s=e[r].y<n.y,i=s,o=0,a=r+1,l=t;for(;;){if(a===l){if(l===0||r===0)break;l=r,a=0}if(s)for(;a<l&&e[a].y<n.y;)a++;else for(;a<l&&e[a].y>n.y;)a++;if(a===l)continue;let c=e[a],h=a>0?e[a-1]:e[t-1];if(c.y===n.y){if(c.x===n.x||c.y===h.y&&n.x<h.x!=n.x<c.x)return X.IsOn;if(a++,a===r)break;continue}if(!(n.x<c.x&&n.x<h.x))if(n.x>h.x&&n.x>c.x)o=1-o;else{let f=Be(h,c,n);if(f===0)return X.IsOn;f<0===s&&(o=1-o)}s=!s,a++}if(s===i)return o===0?X.IsOutside:X.IsInside;a===t&&(a=0);let u=a===0?Be(e[t-1],e[0],n):Be(e[a-1],e[a],n);return u===0?X.IsOn:(u<0===s&&(o=1-o),o===0?X.IsOutside:X.IsInside)}function dl(n,e){let t=X.IsOn;for(let a of n)switch(Cr(a,e)){case X.IsOutside:if(t===X.IsOutside)return!1;t=X.IsOutside;break;case X.IsInside:if(t===X.IsInside)return!0;t=X.IsInside;break;default:break}let r=Ks(n),s,i;return Number.isSafeInteger(r.left)&&Number.isSafeInteger(r.right)&&Math.abs(r.left)+Math.abs(r.right)>Number.MAX_SAFE_INTEGER?(s=Number((BigInt(r.left)+BigInt(r.right))/On),i=Number((BigInt(r.top)+BigInt(r.bottom))/On)):(s=Math.round((r.left+r.right)/2),i=Math.round((r.top+r.bottom)/2)),Cr({x:s,y:i},e)!==X.IsOutside}var V={MaxInt64:Ar,MaxCoord:jt,max_coord:jt,min_coord:-jt,Invalid64:js,floatingPointTolerance:Zs,defaultMinimumEdgeLength:Wa,maxCoordForSafeAreaProduct:Mr,maxCoordForSafeCrossSq:_a,maxSafeCoordinateForScale:ja,checkSafeScaleValue:Za,ensureSafeInteger:Ya,crossProduct:Ka,crossProductSign:Be,checkPrecision:Ja,isAlmostZero:Qa,triSign:el,multiplyUInt64:tl,productsAreEqual:Ys,isCollinear:nl,dotProduct:rl,dotProductSign:sl,area:il,crossProductD:ol,dotProductD:al,roundToEven:ll,checkCastInt64:ul,getLineIntersectPt:cl,getLineIntersectPtD:fl,segsIntersect:hl,getBounds:Ks,getClosestPtOnSegment:pl,pointInPolygon:Cr,path2ContainsPath1:dl},Ye={create(n=0,e=0,t=0){return{x:Math.round(n),y:Math.round(e),z:t}},fromPointD(n){return V.ensureSafeInteger(n.x,"Point64Utils.fromPointD"),V.ensureSafeInteger(n.y,"Point64Utils.fromPointD"),{x:Math.round(n.x),y:Math.round(n.y),z:n.z||0}},scale(n,e){return{x:Math.round(n.x*e),y:Math.round(n.y*e),z:n.z||0}},equals(n,e){return n.x===e.x&&n.y===e.y},add(n,e){if(Number.isSafeInteger(n.x)&&Number.isSafeInteger(e.x)&&Number.isSafeInteger(n.y)&&Number.isSafeInteger(e.y)){let t=n.x+e.x,r=n.y+e.y;return Number.isSafeInteger(t)&&Number.isSafeInteger(r)?{x:t,y:r,z:0}:{x:Number(BigInt(n.x)+BigInt(e.x)),y:Number(BigInt(n.y)+BigInt(e.y)),z:0}}return{x:n.x+e.x,y:n.y+e.y,z:0}},subtract(n,e){return{x:n.x-e.x,y:n.y-e.y,z:0}},toString(n){return n.z!==void 0&&n.z!==0?`${n.x},${n.y},${n.z} `:`${n.x},${n.y} `}},Fn={create(n=0,e=0,t=0){return{x:n,y:e,z:t}},fromPoint64(n){return{x:n.x,y:n.y,z:n.z||0}},scale(n,e){return{x:n.x*e,y:n.y*e,z:n.z||0}},equals(n,e){return V.isAlmostZero(n.x-e.x)&&V.isAlmostZero(n.y-e.y)},negate(n){n.x=-n.x,n.y=-n.y},toString(n,e=2){return n.z!==void 0&&n.z!==0?`${n.x.toFixed(e)},${n.y.toFixed(e)},${n.z}`:`${n.x.toFixed(e)},${n.y.toFixed(e)}`}},yt={create(n=0,e=0,t=0,r=0){return{left:n,top:e,right:t,bottom:r}},createInvalid(){return{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER}},width(n){return n.right-n.left},height(n){return n.bottom-n.top},isEmpty(n){return n.bottom<=n.top||n.right<=n.left},isValid(n){return n.left<Number.MAX_SAFE_INTEGER},midPoint(n){if(Number.isSafeInteger(n.left)&&Number.isSafeInteger(n.right)&&Math.abs(n.left)+Math.abs(n.right)>Number.MAX_SAFE_INTEGER){let e=Number((BigInt(n.left)+BigInt(n.right))/On),t=Number((BigInt(n.top)+BigInt(n.bottom))/On);return{x:e,y:t}}return{x:Math.round((n.left+n.right)/2),y:Math.round((n.top+n.bottom)/2)}},contains(n,e){return e.x>n.left&&e.x<n.right&&e.y>n.top&&e.y<n.bottom},containsRect(n,e){return e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom},intersects(n,e){return Math.max(n.left,e.left)<=Math.min(n.right,e.right)&&Math.max(n.top,e.top)<=Math.min(n.bottom,e.bottom)},asPath(n){return[{x:n.left,y:n.top,z:0},{x:n.right,y:n.top,z:0},{x:n.right,y:n.bottom,z:0},{x:n.left,y:n.bottom,z:0}]}},Or={create(n=0,e=0,t=0,r=0){return{left:n,top:e,right:t,bottom:r}},createInvalid(){return{left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE}},width(n){return n.right-n.left},height(n){return n.bottom-n.top},isEmpty(n){return n.bottom<=n.top||n.right<=n.left},midPoint(n){return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}},contains(n,e){return e.x>n.left&&e.x<n.right&&e.y>n.top&&e.y<n.bottom},containsRect(n,e){return e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom},intersects(n,e){return Math.max(n.left,e.left)<Math.min(n.right,e.right)&&Math.max(n.top,e.top)<Math.min(n.bottom,e.bottom)},asPath(n){return[{x:n.left,y:n.top,z:0},{x:n.right,y:n.top,z:0},{x:n.right,y:n.bottom,z:0},{x:n.left,y:n.bottom,z:0}]}};var Js=Object.freeze(yt.createInvalid()),Qs=Object.freeze(Or.createInvalid());var Zt=BigInt(0),gl=BigInt(2),ei=BigInt(4),J;(function(n){n[n.None=0]="None",n[n.OpenStart=1]="OpenStart",n[n.OpenEnd=2]="OpenEnd",n[n.LocalMax=4]="LocalMax",n[n.LocalMin=8]="LocalMin"})(J||(J={}));var Fr=class{constructor(){k(this,"data",[])}push(e){this.data.push(e),this.siftUp(this.data.length-1)}pop(){if(this.data.length===0)return null;let e=this.data[0],t=this.data.pop();return this.data.length>0&&(this.data[0]=t,this.siftDown(0)),e}clear(){this.data.length=0}siftUp(e){let t=this.data[e];for(;e>0;){let r=e-1>>1;if(this.data[r]>=t)break;this.data[e]=this.data[r],e=r}this.data[e]=t}siftDown(e){let t=this.data.length,r=this.data[e];for(;;){let s=(e<<1)+1;if(s>=t)break;let i=s+1,o=s;if(i<t&&this.data[i]>this.data[s]&&(o=i),this.data[o]<=r)break;this.data[e]=this.data[o],e=o}this.data[e]=r}},Yt=class{constructor(e,t,r){k(this,"pt");k(this,"next",null);k(this,"prev",null);k(this,"flags");this.pt=e,this.flags=t,this.prev=r}},Kt=class{constructor(e,t,r=!1){k(this,"vertex");k(this,"polytype");k(this,"isOpen");this.vertex=e,this.polytype=t,this.isOpen=r}equals(e){return e!==null&&this.vertex===e.vertex}};function ti(n,e,t){return{pt:n,edge1:e,edge2:t}}var rt=class{constructor(e,t){k(this,"pt");k(this,"next");k(this,"prev");k(this,"outrec");k(this,"horz");this.pt=e,this.outrec=t,this.next=this,this.prev=this,this.horz=null}},Te;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right"})(Te||(Te={}));var Dr;(function(n){n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top"})(Dr||(Dr={}));var Dn=class{constructor(){k(this,"idx",0);k(this,"owner",null);k(this,"frontEdge",null);k(this,"backEdge",null);k(this,"pts",null);k(this,"polypath",null);k(this,"bounds",{left:0,top:0,right:0,bottom:0});k(this,"path",[]);k(this,"isOpen",!1);k(this,"splits",null);k(this,"recursiveSplit",null)}},Rn=class{constructor(e){k(this,"leftOp");k(this,"rightOp");k(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},Jt=class{constructor(e,t){k(this,"op1");k(this,"op2");this.op1=e,this.op2=t}};function ml(n,e){return n.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:n.leftOp.pt.x-e.leftOp.pt.x}function vl(n,e){return n.pt.y!==e.pt.y?n.pt.y>e.pt.y?-1:1:n.pt.x!==e.pt.x?n.pt.x<e.pt.x?-1:1:n.edge1.curX!==e.edge1.curX?n.edge1.curX<e.edge1.curX?-1:1:n.edge2.curX<e.edge2.curX?-1:n.edge2.curX>e.edge2.curX?1:0}var Qt=class{constructor(){k(this,"bot",{x:0,y:0});k(this,"top",{x:0,y:0});k(this,"curX",0);k(this,"dx",0);k(this,"windDx",0);k(this,"windCount",0);k(this,"windCount2",0);k(this,"outrec",null);k(this,"prevInAEL",null);k(this,"nextInAEL",null);k(this,"prevInSEL",null);k(this,"nextInSEL",null);k(this,"jump",null);k(this,"vertexTop",null);k(this,"localMin",null);k(this,"isLeftBound",!1);k(this,"joinWith",Te.None)}},Rt={addLocMin(n,e,t,r){if((n.flags&J.LocalMin)!==J.None)return;n.flags|=J.LocalMin;let s=new Kt(n,e,t);r.push(s)},addPathsToVertexList(n,e,t,r,s){for(let i=0,o=n.length;i<o;i++){let a=n[i],l=null,u=null,c=null;for(let d=0,g=a.length;d<g;d++){let m=a[d];if(l===null)l=new Yt(m,J.None,null),s.push(l),u=l,c=m;else if(!(c.x===m.x&&c.y===m.y)){let x=new Yt(m,J.None,u);u.next=x,u=x,c=m}}if(u?.prev==null||(!t&&u.pt.x===l.pt.x&&u.pt.y===l.pt.y&&(u=u.prev),u.next=l,l.prev=u,!t&&u.next===u))continue;let h;if(t){let d=l.next;for(;d!==l&&d.pt.y===l.pt.y;)d=d.next;h=d.pt.y<=l.pt.y,h?(l.flags=J.OpenStart,Rt.addLocMin(l,e,!0,r)):l.flags=J.OpenStart|J.LocalMax}else{for(u=l.prev;u!==l&&u.pt.y===l.pt.y;)u=u.prev;if(u===l)continue;h=u.pt.y>l.pt.y}let f=h;u=l;let p=l.next;for(;p!==l;)p.pt.y>u.pt.y&&h?(u.flags|=J.LocalMax,h=!1):p.pt.y<u.pt.y&&!h&&(h=!0,Rt.addLocMin(u,e,t,r)),u=p,p=p.next;t?(u.flags|=J.OpenEnd,h?u.flags|=J.LocalMax:Rt.addLocMin(u,e,t,r)):h!==f&&(f?Rt.addLocMin(u,e,!1,r):u.flags|=J.LocalMax)}}};var Un=class{constructor(e=null){k(this,"parent");k(this,"children",[]);this.parent=e}get isHole(){return this.getIsHole()}getLevel(){let e=0,t=this.parent;for(;t!==null;)++e,t=t.parent;return e}get level(){return this.getLevel()}getIsHole(){let e=this.getLevel();return e!==0&&(e&1)===0}get count(){return this.children.length}clear(){this.children.length=0}toStringInternal(e,t){let r="",s=" ".repeat(t),i=this.children.length===1?"":"s";(t&1)===0?r+=`${s}+- hole (${e}) contains ${this.children.length} nested polygon${i}.
375
375
  `:r+=`${s}+- polygon (${e}) contains ${this.children.length} hole${i}.
376
376
  `;for(let o=0;o<this.count;o++)this.children[o].count>0&&(r+=this.children[o].toStringInternal(o,t+1));return r}toString(){if(this.level>0)return"";let e=this.children.length===1?"":"s",t=`Polytree with ${this.children.length} polygon${e}.
377
377
  `;for(let r=0;r<this.count;r++)this.children[r].count>0&&(t+=this.children[r].toStringInternal(r,1));return t+`
378
- `}},Un=class n extends Rn{constructor(t=null){super(t);b(this,"polygon",null)}get poly(){return this.polygon}addChild(t){let r=new n(this);return r.polygon=t,this.children.push(r),r}child(t){if(t<0||t>=this.children.length)throw new Error("Index out of range");return this.children[t]}area(){let t=this.polygon===null?0:Rr.area(this.polygon);for(let r of this.children)t+=r.area();return t}};var nn=class extends Un{};var m=class m{constructor(){b(this,"cliptype",Q.NoClip);b(this,"fillrule",V.EvenOdd);b(this,"actives",null);b(this,"sel",null);b(this,"minimaList",[]);b(this,"intersectList",[]);b(this,"vertexList",[]);b(this,"outrecList",[]);b(this,"scanlineHeap",new Fr);b(this,"scanlineSet",new Set);b(this,"scanlineArr",[]);b(this,"useScanlineArray",!1);b(this,"horzSegList",[]);b(this,"horzJoinList",[]);b(this,"currentLocMin",0);b(this,"currentBotY",0);b(this,"curXValidAtTop",!1);b(this,"isSortedMinimaList",!1);b(this,"hasOpenPaths",!1);b(this,"usingPolytree",!1);b(this,"succeeded",!1);b(this,"zCallbackInternal");b(this,"preserveCollinear",!0);b(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,t){return e.x===t.x&&e.y===t.y}setZ(e,t,r){let s=this.zCallbackInternal;s&&(m.getPolyType(e)===ke.Subject?(this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:this.xyEqual(r,t.bot)?r.z=t.bot.z??0:this.xyEqual(r,t.top)?r.z=t.top.z??0:r.z=0,s(e.bot,e.top,t.bot,t.top,r)):(this.xyEqual(r,t.bot)?r.z=t.bot.z??0:this.xyEqual(r,t.top)?r.z=t.top.z??0:this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:r.z=0,s(t.bot,t.top,e.bot,e.top,r)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return m.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return m.openPathsEnabled&&e.localMin.isOpen&&m.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(Y.OpenStart|Y.OpenEnd))!==Y.None}static getPrevHotEdge(e){let t=e.prevInAEL;if(!m.openPathsEnabled){for(;t!==null&&!m.isHotEdge(t);)t=t.prevInAEL;return t}for(;t!==null&&(t.localMin.isOpen||!m.isHotEdge(t));)t=t.prevInAEL;return t}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,t){let r=t.y-e.y;return r!==0?(t.x-e.x)/r:t.x>e.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(e,t){return t===e.top.y||e.top.x===e.bot.x?e.top.x:t===e.bot.y?e.bot.x:$.roundToEven(e.bot.x+e.dx*(t-e.bot.y))}static isHorizontal(e){return e.dx===Number.NEGATIVE_INFINITY||e.dx===Number.POSITIVE_INFINITY}static isHeadingRightHorz(e){return e.dx===Number.NEGATIVE_INFINITY}static isHeadingLeftHorz(e){return e.dx===Number.POSITIVE_INFINITY}static getPolyType(e){return e.localMin.polytype}static isSamePolyType(e,t){return e.localMin.polytype===t.localMin.polytype}static setDx(e){e.dx=m.getDx(e.bot,e.top)}static nextVertex(e){return e.windDx>0?e.vertexTop.next:e.vertexTop.prev}static prevPrevVertex(e){return e.windDx>0?e.vertexTop.prev.prev:e.vertexTop.next.next}static isMaximaVertex(e){return(e.flags&Y.LocalMax)!==Y.None}static isMaximaEdge(e){return(e.vertexTop.flags&Y.LocalMax)!==Y.None}static getMaximaPair(e){let t=e.nextInAEL;for(;t!==null;){if(t.vertexTop===e.vertexTop)return t;t=t.nextInAEL}return null}boundingBoxesOverlap(e,t,r,s){let i=e.x<t.x?e.x:t.x;if((r.x>s.x?r.x:s.x)<i)return!1;let a=e.x>t.x?e.x:t.x,l=r.x<s.x?r.x:s.x;if(a<l)return!1;let u=e.y<t.y?e.y:t.y;if((r.y>s.y?r.y:s.y)<u)return!1;let h=e.y>t.y?e.y:t.y,f=r.y<s.y?r.y:s.y;return h>=f}clearSolutionOnly(){for(;this.actives!==null;)this.deleteFromAEL(this.actives);this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.disposeIntersectNodes(),this.outrecList.length=0,this.horzSegList.length=0,this.horzJoinList.length=0}clear(){this.clearSolutionOnly(),this.minimaList.length=0,this.vertexList.length=0,this.currentLocMin=0,this.isSortedMinimaList=!1,this.hasOpenPaths=!1}reset(){this.isSortedMinimaList||(this.minimaList.sort((e,t)=>t.vertex.pt.y-e.vertex.pt.y),this.isSortedMinimaList=!0),this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.useScanlineArray=this.minimaList.length<=16;for(let e=this.minimaList.length-1;e>=0;e--)this.insertScanline(this.minimaList[e].vertex.pt.y);this.currentBotY=0,this.currentLocMin=0,this.actives=null,this.sel=null,this.curXValidAtTop=!1,this.succeeded=!0}upgradeScanlineStructureFromArray(){let e=this.scanlineArr;for(let t=0,r=e.length;t<r;t++){let s=e[t];this.scanlineSet.add(s),this.scanlineHeap.push(s)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let t=this.scanlineArr;for(let r=0,s=t.length;r<s;r++)if(t[r]===e)return;t.push(e),t.length>64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(e)||(this.scanlineSet.add(e),this.scanlineHeap.push(e))}popScanline(){if(this.useScanlineArray){let t=this.scanlineArr,r=t.length;if(r===0)return null;let s=0,i=t[0];for(let o=1;o<r;o++){let a=t[o];a>i&&(i=a,s=o)}return t[s]=t[r-1],t.pop(),i}let e=this.scanlineHeap.pop();return e===null?null:(this.scanlineSet.delete(e),e)}hasLocMinAtY(e){return this.currentLocMin<this.minimaList.length&&this.minimaList[this.currentLocMin].vertex.pt.y===e}popLocalMinima(){return this.minimaList[this.currentLocMin++]}addPath(e,t,r=!1){let s=[e];this.addPaths(s,t,r)}addPaths(e,t,r=!1){r&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,Ut.addPathsToVertexList(e,t,r,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let t of e.minimaList)this.minimaList.push(new Qt(t.vertex,t.polytype,t.isOpen)),t.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let t=e.prevInAEL,r=e.nextInAEL;t===null&&r===null&&e!==this.actives||(t!==null?t.nextInAEL=r:this.actives=r,r!==null&&(r.prevInAEL=t))}getBounds(){let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let t of this.vertexList){let r=t;do r.pt.x<e.left&&(e.left=r.pt.x),r.pt.x>e.right&&(e.right=r.pt.x),r.pt.y<e.top&&(e.top=r.pt.y),r.pt.y>e.bottom&&(e.bottom=r.pt.y),r=r.next;while(r!==t)}return bt.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,t){if(e===Q.NoClip)return;m.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=t,this.cliptype=e,this.reset();let r=this.popScanline();if(r!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(r);let s;for(;(s=this.popHorz())!==null;)this.doHorizontal(s);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=r;let i=this.popScanline();if(i===null)break;for(r=i,this.doIntersections(r),this.doTopOfScanbeam(r);(s=this.popHorz())!==null;)this.doHorizontal(s)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let t=this.popLocalMinima(),r;(t.vertex.flags&Y.OpenStart)!==Y.None?r=null:(r=new tn,r.bot=t.vertex.pt,r.curX=t.vertex.pt.x,r.windDx=-1,r.vertexTop=t.vertex.prev,r.top=t.vertex.prev.pt,r.outrec=null,r.localMin=t,m.setDx(r));let s;if((t.vertex.flags&Y.OpenEnd)!==Y.None?s=null:(s=new tn,s.bot=t.vertex.pt,s.curX=t.vertex.pt.x,s.windDx=1,s.vertexTop=t.vertex.next,s.top=t.vertex.next.pt,s.outrec=null,s.localMin=t,m.setDx(s)),r!==null&&s!==null){if(m.isHorizontal(r)){if(m.isHeadingRightHorz(r)){let o=r;r=s,s=o}}else if(m.isHorizontal(s)){if(m.isHeadingLeftHorz(s)){let o=r;r=s,s=o}}else if(r.dx<s.dx){let o=r;r=s,s=o}}else r===null&&(r=s,s=null);let i;if(r.isLeftBound=!0,this.insertLeftEdge(r),m.openPathsEnabled?m.isOpen(r)?(this.setWindCountForOpenPathEdge(r),i=this.isContributingOpen(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)),s!==null){for(s.windCount=r.windCount,s.windCount2=r.windCount2,this.insertRightEdge(r,s),i&&(this.addLocalMinPoly(r,s,r.bot,!0),m.isHorizontal(r)||this.checkJoinLeft(r,r.bot));s.nextInAEL!==null&&this.isValidAelOrder(s.nextInAEL,s);)this.intersectEdges(s,s.nextInAEL,s.bot),this.swapPositionsInAEL(s,s.nextInAEL);m.isHorizontal(s)?this.pushHorz(s):(this.checkJoinRight(s,s.bot),this.insertScanline(s.top.y))}else i&&m.openPathsEnabled&&this.startOpenPath(r,r.bot);m.isHorizontal(r)?this.pushHorz(r):this.insertScanline(r.top.y)}}pushHorz(e){e.nextInSEL=this.sel,this.sel=e}popHorz(){let e=this.sel;return e===null?null:(this.sel=this.sel.nextInSEL,e)}doHorizontal(e){if(!m.openPathsEnabled){this.doHorizontalClosed(e);return}let t=m.isOpen(e),r=e.bot.y,s=t?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:i,leftX:o,rightX:a}=this.resetHorzDirection(e,s),l=o,u=a;if(m.isHotEdge(e)){let c=this.addOutPt(e,{x:e.curX,y:r});this.addToHorzSegList(c)}for(;;){let c=i?e.nextInAEL:e.prevInAEL;for(;c!==null;){if(c.vertexTop===s){if(m.isHotEdge(e)&&this.isJoined(c)&&this.split(c,c.top),m.isHotEdge(e)){for(;e.vertexTop!==s;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);i?this.addLocalMaxPoly(e,c,e.top):this.addLocalMaxPoly(c,e,e.top)}this.deleteFromAEL(c),this.deleteFromAEL(e);return}if(s!==e.vertexTop||m.isOpenEnd(e)){if(i&&c.curX>u||!i&&c.curX<l)break;if(c.curX===e.top.x&&!m.isHorizontal(c)){let p=m.nextVertex(e).pt;if(m.isOpen(c)&&!m.isSamePolyType(c,e)&&!m.isHotEdge(c)){if(i&&m.topX(c,p.y)>p.x||!i&&m.topX(c,p.y)<p.x)break}else if(i&&m.topX(c,p.y)>=p.x||!i&&m.topX(c,p.y)<=p.x)break}}let f={x:c.curX,y:r};i?(this.intersectEdges(e,c,f),this.swapPositionsInAEL(e,c),this.checkJoinLeft(c,f),e.curX=c.curX,c=e.nextInAEL):(this.intersectEdges(c,e,f),this.swapPositionsInAEL(c,e),this.checkJoinRight(c,f),e.curX=c.curX,c=e.prevInAEL),m.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(t&&m.isOpenEnd(e)){m.isHotEdge(e)&&(this.addOutPt(e,e.top),m.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(m.nextVertex(e).pt.y!==e.top.y)break;m.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let h=this.resetHorzDirection(e,s);l=h.leftX,u=h.rightX}if(m.isHotEdge(e)){let c=this.addOutPt(e,e.top);this.addToHorzSegList(c)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let t=e.bot.y,r=this.getCurrYMaximaVertex(e),{isLeftToRight:s,leftX:i,rightX:o}=this.resetHorzDirection(e,r),a=i,l=o;if(m.isHotEdge(e)){let u=this.addOutPt(e,{x:e.curX,y:t});this.addToHorzSegList(u)}for(;;){let u=s?e.nextInAEL:e.prevInAEL;for(;u!==null;){if(u.vertexTop===r){if(m.isHotEdge(e)&&this.isJoined(u)&&this.split(u,u.top),m.isHotEdge(e)){for(;e.vertexTop!==r;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);s?this.addLocalMaxPoly(e,u,e.top):this.addLocalMaxPoly(u,e,e.top)}this.deleteFromAEL(u),this.deleteFromAEL(e);return}if(r!==e.vertexTop){if(s&&u.curX>l||!s&&u.curX<a)break;if(u.curX===e.top.x&&!m.isHorizontal(u)){let f=m.nextVertex(e).pt,p=m.topX(u,f.y);if(s&&p>=f.x||!s&&p<=f.x)break}}let h={x:u.curX,y:t};s?(this.intersectEdges(e,u,h),this.swapPositionsInAEL(e,u),this.checkJoinLeft(u,h),e.curX=u.curX,u=e.nextInAEL):(this.intersectEdges(u,e,h),this.swapPositionsInAEL(u,e),this.checkJoinRight(u,h),e.curX=u.curX,u=e.prevInAEL),m.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(m.nextVertex(e).pt.y!==e.top.y)break;m.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let c=this.resetHorzDirection(e,r);a=c.leftX,l=c.rightX}if(m.isHotEdge(e)){let u=this.addOutPt(e,e.top);this.addToHorzSegList(u)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,t=0;for(let r=0,s=e.length;r<s;r++){let i=e[r];this.updateHorzSegment(i)&&(e[t++]=i)}if(!(t<2)){e.length=t,this.horzSegList.sort(gl);for(let r=0;r<t-1;r++){let s=this.horzSegList[r];for(let i=r+1;i<t;i++){let o=this.horzSegList[i];if(o.leftOp.pt.x>=s.rightOp.pt.x||o.leftToRight===s.leftToRight||o.rightOp.pt.x<=s.leftOp.pt.x)continue;let a=s.leftOp.pt.y;if(s.leftToRight){for(;s.leftOp.next.pt.y===a&&s.leftOp.next.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.next;for(;o.leftOp.prev.pt.y===a&&o.leftOp.prev.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.prev;let l=new en(this.duplicateOp(s.leftOp,!0),this.duplicateOp(o.leftOp,!1));this.horzJoinList.push(l)}else{for(;s.leftOp.prev.pt.y===a&&s.leftOp.prev.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.prev;for(;o.leftOp.next.pt.y===a&&o.leftOp.next.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.next;let l=new en(this.duplicateOp(o.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(l)}}}}}updateHorzSegment(e){let t=e.leftOp,r=this.getRealOutRec(t.outrec),s=r.frontEdge!==null,i=t.pt.y,o=t,a=t;if(s){let u=r.pts,c=u.next;for(;o!==c&&o.prev.pt.y===i;)o=o.prev;for(;a!==u&&a.next.pt.y===i;)a=a.next}else{for(;o.prev!==a&&o.prev.pt.y===i;)o=o.prev;for(;a.next!==o&&a.next.pt.y===i;)a=a.next}let l=this.setHorzSegHeadingForward(e,o,a)&&e.leftOp.horz===null;return l?e.leftOp.horz=e:e.rightOp=null,l}setHorzSegHeadingForward(e,t,r){return t.pt.x===r.pt.x?!1:(t.pt.x<r.pt.x?(e.leftOp=t,e.rightOp=r,e.leftToRight=!0):(e.leftOp=r,e.rightOp=t,e.leftToRight=!1),!0)}duplicateOp(e,t){let r=new nt(e.pt,e.outrec);return t?(r.next=e.next,r.next.prev=r,r.prev=e,e.next=r):(r.prev=e.prev,r.prev.next=r,r.next=e,e.prev=r),r}getRealOutRec(e){for(;e!==null&&e.pts===null;)e=e.owner;return e}doIntersections(e){this.buildIntersectList(e)&&(this.processIntersectList(),this.disposeIntersectNodes())}doTopOfScanbeam(e){let t=this.curXValidAtTop;this.curXValidAtTop=!1,this.sel=null;let r=this.actives;for(;r!==null;){if(r.top.y===e)if(r.curX=r.top.x,m.isMaximaEdge(r)){r=this.doMaxima(r);continue}else m.isHotEdge(r)&&this.addOutPt(r,r.top),this.updateEdgeIntoAEL(r),m.isHorizontal(r)&&this.pushHorz(r);else t||(r.curX=m.topX(r,e));r=r.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let t=this.getRealOutRec(e.op1.outrec),r=this.getRealOutRec(e.op2.outrec),s=e.op1.next,i=e.op2.prev;if(e.op1.next=e.op2,e.op2.prev=e.op1,s.prev=i,i.next=s,t===r){let o=this.newOutRec();o.pts=s,this.fixOutRecPts(o),t.pts.outrec===o&&(t.pts=e.op1,t.pts.outrec=t),this.usingPolytree?(this.path1InsidePath2(t.pts,o.pts)?([o.pts,t.pts]=[t.pts,o.pts],this.fixOutRecPts(t),this.fixOutRecPts(o),o.owner=t):this.path1InsidePath2(o.pts,t.pts)?o.owner=t:o.owner=t.owner,t.splits===null&&(t.splits=[]),t.splits.push(o.idx)):o.owner=t}else r.pts=null,this.usingPolytree?(this.setOwner(r,t),this.moveSplits(r,t)):r.owner=t}}fixOutRecPts(e){let t=e.pts;do t.outrec=e,t=t.next;while(t!==e.pts)}path1InsidePath2(e,t){let r=X.IsOn,s=e;do{switch(this.pointInOpPolygon(s.pt,t)){case X.IsOutside:if(r===X.IsOutside)return!1;r=X.IsOutside;break;case X.IsInside:if(r===X.IsInside)return!0;r=X.IsInside;break;default:break}s=s.next}while(s!==e);return $.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(t))}pointInOpPolygon(e,t){if(t===t.next||t.prev===t.next)return X.IsOutside;let r=t;do{if(t.pt.y!==e.y)break;t=t.next}while(t!==r);if(t.pt.y===e.y)return X.IsOutside;let s=t.pt.y<e.y,i=s,o=0;for(r=t.next;r!==t;){if(s)for(;r!==t&&r.pt.y<e.y;)r=r.next;else for(;r!==t&&r.pt.y>e.y;)r=r.next;if(r===t)break;if(r.pt.y===e.y){if(r.pt.x===e.x||r.pt.y===r.prev.pt.y&&e.x<r.prev.pt.x!=e.x<r.pt.x)return X.IsOn;if(r=r.next,r===t)break;continue}if(r.pt.x<=e.x||r.prev.pt.x<=e.x)if(r.prev.pt.x<e.x&&r.pt.x<e.x)o=1-o;else{let a=$.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return X.IsOn;a<0===s&&(o=1-o)}s=!s,r=r.next}if(s===i)return o===0?X.IsOutside:X.IsInside;{let a=$.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return X.IsOn;a<0===s&&(o=1-o)}return o===0?X.IsOutside:X.IsInside}getCleanPath(e){let t=[],r=e;for(;r.next!==e&&(r.pt.x===r.next.pt.x&&r.pt.x===r.prev.pt.x||r.pt.y===r.next.pt.y&&r.pt.y===r.prev.pt.y);)r=r.next;t.push(r.pt);let s=r;for(r=r.next;r!==e;)(r.pt.x!==r.next.pt.x||r.pt.x!==s.pt.x)&&(r.pt.y!==r.next.pt.y||r.pt.y!==s.pt.y)&&(t.push(r.pt),s=r),r=r.next;return t}moveSplits(e,t){if(e.splits!==null){t.splits===null&&(t.splits=[]);for(let r of e.splits)r!==t.idx&&t.splits.push(r);e.splits=null}}buildIntersectList(e){if(this.actives?.nextInAEL===null)return!1;if(!this.adjustCurrXAndCopyToSEL(e))return this.curXValidAtTop=!0,!1;let t=this.sel;for(;t!==null&&t.jump!==null;){let r=null;for(;t!==null&&t.jump!==null;){let s=t,i=t.jump,o=i,a=i?.jump||null;for(t.jump=a;t!==o&&i!==a;)if(i.curX<t.curX){let l=i.prevInSEL;for(;this.addNewIntersectNode(l,i,e),l!==t;)l=l.prevInSEL;if(l=i,i=this.extractFromSEL(l),o=i,t!==null&&this.insert1Before2InSEL(l,t),t!==s)continue;s=l,s.jump=a,r===null?this.sel=s:r.jump=s}else t=t.nextInSEL;r=s,t=a}t=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(ml);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let r=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[r]);)r++;[this.intersectList[r],this.intersectList[e]]=[this.intersectList[e],this.intersectList[r]]}let t=this.intersectList[e];this.intersectEdges(t.edge1,t.edge2,t.pt),this.swapPositionsInAEL(t.edge1,t.edge2),t.edge1.curX=t.pt.x,t.edge2.curX=t.pt.x,this.checkJoinLeft(t.edge2,t.pt,!0),this.checkJoinRight(t.edge1,t.pt,!0)}}edgesAdjacentInAEL(e){return e.edge1.nextInAEL===e.edge2||e.edge1.prevInAEL===e.edge2}adjustCurrXAndCopyToSEL(e){let t=this.actives;this.sel=t;let r=Number.NEGATIVE_INFINITY,s=!1;for(;t!==null;){t.prevInSEL=t.prevInAEL,t.nextInSEL=t.nextInAEL,t.jump=t.nextInSEL;let i=m.topX(t,e);t.curX=i,i<r&&(s=!0),r=i,t=t.nextInAEL}return s}doMaxima(e){let t=e.prevInAEL,r=e.nextInAEL;if(m.isOpenEnd(e))return m.isHotEdge(e)&&this.addOutPt(e,e.top),m.isHorizontal(e)||(m.isHotEdge(e)&&(m.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),r;let s=m.getMaximaPair(e);if(s===null)return r;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(s)&&this.split(s,s.top);r!==s;)this.intersectEdges(e,r,e.top),this.swapPositionsInAEL(e,r),r=e.nextInAEL;return m.isOpen(e)?(m.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(s),this.deleteFromAEL(e),t!==null?t.nextInAEL:this.actives):(m.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(e),this.deleteFromAEL(s),t!==null?t.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=m.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,m.setDx(e),this.isJoined(e)&&this.split(e,e.bot),m.isHorizontal(e)){m.openPathsEnabled?m.isOpen(e)||this.trimHorz(e,this.preserveCollinear):this.trimHorz(e,this.preserveCollinear);return}this.insertScanline(e.top.y),this.checkJoinLeft(e,e.bot),this.checkJoinRight(e,e.bot,!0)}trimHorz(e,t){let r=!1,s=m.nextVertex(e).pt;for(;s.y===e.top.y&&!(t&&s.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=m.nextVertex(e),e.top=s,r=!0,m.isMaximaVertex(e.vertexTop)));)s=m.nextVertex(e).pt;r&&m.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new Dn(e))}addNewIntersectNode(e,t,r){let s=$.getLineIntersectPt(e.bot,e.top,t.bot,t.top);if(s===null&&(s={x:e.curX,y:r}),s.y>this.currentBotY||s.y<r){let o=Math.abs(e.dx),a=Math.abs(t.dx);o>100&&a>100?o>a?s=$.getClosestPtOnSegment(s,e.bot,e.top):s=$.getClosestPtOnSegment(s,t.bot,t.top):o>100?s=$.getClosestPtOnSegment(s,e.bot,e.top):a>100?s=$.getClosestPtOnSegment(s,t.bot,t.top):(s.y<r?s.y=r:s.y=this.currentBotY,o<a?s.x=m.topX(e,s.y):s.x=m.topX(t,s.y))}let i=ti(s,e,t);this.intersectList.push(i)}extractFromSEL(e){let t=e.nextInSEL;return t!==null&&(t.prevInSEL=e.prevInSEL),e.prevInSEL.nextInSEL=t,t}insert1Before2InSEL(e,t){e.prevInSEL=t.prevInSEL,e.prevInSEL!==null&&(e.prevInSEL.nextInSEL=e),e.nextInSEL=t,t.prevInSEL=e}getCurrYMaximaVertexOpen(e){let t=e.vertexTop;if(e.windDx>0)for(;t.next.pt.y===t.pt.y&&(t.flags&(Y.OpenEnd|Y.LocalMax))===Y.None;)t=t.next;else for(;t.prev.pt.y===t.pt.y&&(t.flags&(Y.OpenEnd|Y.LocalMax))===Y.None;)t=t.prev;return m.isMaximaVertex(t)||(t=null),t}getCurrYMaximaVertex(e){let t=e.vertexTop;if(e.windDx>0)for(;t.next.pt.y===t.pt.y;)t=t.next;else for(;t.prev.pt.y===t.pt.y;)t=t.prev;return m.isMaximaVertex(t)||(t=null),t}resetHorzDirection(e,t){if(e.bot.x===e.top.x){let r=e.curX,s=e.curX,i=e.nextInAEL;for(;i!==null&&i.vertexTop!==t;)i=i.nextInAEL;return{isLeftToRight:i!==null,leftX:r,rightX:s}}return e.curX<e.top.x?{isLeftToRight:!0,leftX:e.curX,rightX:e.top.x}:{isLeftToRight:!1,leftX:e.top.x,rightX:e.curX}}getLastOp(e){let t=e.outrec;return e===t.frontEdge?t.pts:t.pts.next}insertLeftEdge(e){if(this.actives===null)e.prevInAEL=null,e.nextInAEL=null,this.actives=e;else if(!this.isValidAelOrder(this.actives,e))e.prevInAEL=null,e.nextInAEL=this.actives,this.actives.prevInAEL=e,this.actives=e;else{let t=this.actives;for(;t.nextInAEL!==null&&this.isValidAelOrder(t.nextInAEL,e);)t=t.nextInAEL;t.joinWith===Te.Right&&(t=t.nextInAEL),e.nextInAEL=t.nextInAEL,t.nextInAEL!==null&&(t.nextInAEL.prevInAEL=e),e.prevInAEL=t,t.nextInAEL=e}}insertRightEdge(e,t){t.nextInAEL=e.nextInAEL,e.nextInAEL!==null&&(e.nextInAEL.prevInAEL=t),t.prevInAEL=e,e.nextInAEL=t}setWindCountForOpenPathEdge(e){let t=this.actives;if(this.fillrule===V.EvenOdd){let r=0,s=0;for(;t!==e;)m.getPolyType(t)===ke.Clip?s++:m.isOpen(t)||r++,t=t.nextInAEL;e.windCount=m.isOdd(r)?1:0,e.windCount2=m.isOdd(s)?1:0}else for(;t!==e;)m.getPolyType(t)===ke.Clip?e.windCount2+=t.windDx:m.isOpen(t)||(e.windCount+=t.windDx),t=t.nextInAEL}setWindCountForClosedPathEdge(e){let t=e.prevInAEL,r=m.getPolyType(e);if(!m.openPathsEnabled){for(;t!==null&&m.getPolyType(t)!==r;)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===V.EvenOdd?(e.windCount=e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL):(t.windCount*t.windDx<0?Math.abs(t.windCount)>1?t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx:e.windCount=e.windDx:t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL),this.fillrule===V.EvenOdd)for(;t!==e;)m.getPolyType(t)!==r&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)m.getPolyType(t)!==r&&(e.windCount2+=t.windDx),t=t.nextInAEL;return}for(;t!==null&&(m.getPolyType(t)!==r||m.isOpen(t));)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===V.EvenOdd?(e.windCount=e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL):(t.windCount*t.windDx<0?Math.abs(t.windCount)>1?t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx:e.windCount=m.isOpen(e)?1:e.windDx:t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL),this.fillrule===V.EvenOdd)for(;t!==e;)m.getPolyType(t)!==r&&!m.isOpen(t)&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)m.getPolyType(t)!==r&&!m.isOpen(t)&&(e.windCount2+=t.windDx),t=t.nextInAEL}isContributingOpen(e){let t,r;switch(this.fillrule){case V.Positive:r=e.windCount>0,t=e.windCount2>0;break;case V.Negative:r=e.windCount<0,t=e.windCount2<0;break;default:r=e.windCount!==0,t=e.windCount2!==0;break}switch(this.cliptype){case Q.Intersection:return t;case Q.Union:return!r&&!t;default:return!t}}isContributingClosed(e){switch(this.fillrule){case V.Positive:if(e.windCount!==1)return!1;break;case V.Negative:if(e.windCount!==-1)return!1;break;case V.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case Q.Intersection:return this.fillrule===V.Positive?e.windCount2>0:this.fillrule===V.Negative?e.windCount2<0:e.windCount2!==0;case Q.Union:return this.fillrule===V.Positive?e.windCount2<=0:this.fillrule===V.Negative?e.windCount2>=0:e.windCount2===0;case Q.Difference:{let t=this.fillrule===V.Positive?e.windCount2<=0:this.fillrule===V.Negative?e.windCount2>=0:e.windCount2===0;return m.getPolyType(e)===ke.Subject?t:!t}case Q.Xor:return!0;default:return!1}}addLocalMinPoly(e,t,r,s=!1){let i=this.newOutRec();if(e.outrec=i,t.outrec=i,m.isOpen(e))i.owner=null,i.isOpen=!0,e.windDx>0?this.setSides(i,e,t):this.setSides(i,t,e);else{i.isOpen=!1;let a=m.getPrevHotEdge(e);a!==null?(this.usingPolytree&&this.setOwner(i,a.outrec),i.owner=a.outrec,this.outrecIsAscending(a)===s?this.setSides(i,t,e):this.setSides(i,e,t)):(i.owner=null,s?this.setSides(i,e,t):this.setSides(i,t,e))}let o=new nt(r,i);return i.pts=o,o}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new Fn;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,t){let r=this.newOutRec();r.isOpen=!0,e.windDx>0?(r.frontEdge=e,r.backEdge=null):(r.frontEdge=null,r.backEdge=e),e.outrec=r;let s=new nt(t,r);return r.pts=s,s}checkJoinLeft(e,t,r=!1){let s=e.prevInAEL;s!==null&&(!r&&e.curX!==s.curX||!m.isHotEdge(e)||!m.isHotEdge(s)||m.isHorizontal(e)||m.isHorizontal(s)||m.isOpen(e)||m.isOpen(s)||(t.y<e.top.y+2||t.y<s.top.y+2)&&(e.bot.y>t.y||s.bot.y>t.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,s.bot,s.top)||$.isCollinear(e.top,t,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(s,e,t):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),s.joinWith=Te.Right,e.joinWith=Te.Left))}checkJoinRight(e,t,r=!1){let s=e.nextInAEL;s!==null&&(!r&&e.curX!==s.curX||!m.isHotEdge(e)||!m.isHotEdge(s)||m.isHorizontal(e)||m.isHorizontal(s)||m.isOpen(e)||m.isOpen(s)||(t.y<e.top.y+2||t.y<s.top.y+2)&&(e.bot.y>t.y||s.bot.y>t.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,s.bot,s.top)||$.isCollinear(e.top,t,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(e,s,t):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),e.joinWith=Te.Right,s.joinWith=Te.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,t,r){let s=e.x-t.x,i=e.y-t.y,o=r.x-t.x,a=r.y-t.y;if(o===0&&a===0)return!1;let l=$.maxCoordForSafeCrossSq;if(Math.abs(s)<l&&Math.abs(i)<l&&Math.abs(o)<l&&Math.abs(a)<l){let c=s*a-o*i;return c*c/(o*o+a*a)>.25}if(Number.isSafeInteger(s)&&Number.isSafeInteger(i)&&Number.isSafeInteger(o)&&Number.isSafeInteger(a)){let c=BigInt(s)*BigInt(a)-BigInt(o)*BigInt(i),h=c*c,f=BigInt(o)*BigInt(o)+BigInt(a)*BigInt(a);return ei*h>f}let u=s*a-o*i;return u*u/(o*o+a*a)>.25}intersectEdges(e,t,r){let s;if(this.hasOpenPaths&&(m.isOpen(e)||m.isOpen(t))){if(m.isOpen(e)&&m.isOpen(t))return;if(m.isOpen(t)){let u=e;e=t,t=u}if(this.isJoined(t)&&this.split(t,r),this.cliptype===Q.Union){if(!m.isHotEdge(t))return}else if(t.localMin.polytype===ke.Subject)return;switch(this.fillrule){case V.Positive:if(t.windCount!==1)return;break;case V.Negative:if(t.windCount!==-1)return;break;default:if(Math.abs(t.windCount)!==1)return;break}if(m.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,t,s.pt),m.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(r.x===e.localMin.vertex.pt.x&&r.y===e.localMin.vertex.pt.y&&!m.isOpenEndVertex(e.localMin.vertex)){let u=this.findEdgeWithMatchingLocMin(e);if(u!==null&&m.isHotEdge(u)){e.outrec=u.outrec,e.windDx>0?this.setSides(u.outrec,e,u):this.setSides(u.outrec,u,e);return}s=this.startOpenPath(e,r)}else s=this.startOpenPath(e,r);this.setZ(e,t,s.pt);return}this.isJoined(e)&&this.split(e,r),this.isJoined(t)&&this.split(t,r);let i,o;switch(e.localMin.polytype===t.localMin.polytype?this.fillrule===V.EvenOdd?(i=e.windCount,e.windCount=t.windCount,t.windCount=i):(e.windCount+t.windDx===0?e.windCount=-e.windCount:e.windCount+=t.windDx,t.windCount-e.windDx===0?t.windCount=-t.windCount:t.windCount-=e.windDx):(this.fillrule!==V.EvenOdd?e.windCount2+=t.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==V.EvenOdd?t.windCount2-=e.windDx:t.windCount2=t.windCount2===0?1:0),this.fillrule){case V.Positive:i=e.windCount,o=t.windCount;break;case V.Negative:i=-e.windCount,o=-t.windCount;break;default:i=Math.abs(e.windCount),o=Math.abs(t.windCount);break}let a=i===0||i===1,l=o===0||o===1;if(!(!m.isHotEdge(e)&&!a||!m.isHotEdge(t)&&!l))if(m.isHotEdge(e)&&m.isHotEdge(t))if(i!==0&&i!==1||o!==0&&o!==1||e.localMin.polytype!==t.localMin.polytype&&this.cliptype!==Q.Xor)s=this.addLocalMaxPoly(e,t,r),s&&this.setZ(e,t,s.pt);else if(m.isFront(e)||e.outrec===t.outrec){s=this.addLocalMaxPoly(e,t,r),s&&this.setZ(e,t,s.pt);let u=this.addLocalMinPoly(e,t,r);this.setZ(e,t,u.pt)}else{s=this.addOutPt(e,r),this.setZ(e,t,s.pt);let u=this.addOutPt(t,r);this.setZ(e,t,u.pt),this.swapOutrecs(e,t)}else if(m.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,t,s.pt),this.swapOutrecs(e,t);else if(m.isHotEdge(t))s=this.addOutPt(t,r),this.setZ(e,t,s.pt),this.swapOutrecs(e,t);else{let u,c;switch(this.fillrule){case V.Positive:u=e.windCount2,c=t.windCount2;break;case V.Negative:u=-e.windCount2,c=-t.windCount2;break;default:u=Math.abs(e.windCount2),c=Math.abs(t.windCount2);break}if(!m.isSamePolyType(e,t))s=this.addLocalMinPoly(e,t,r),this.setZ(e,t,s.pt);else if(i===1&&o===1){switch(s=null,this.cliptype){case Q.Union:if(u>0&&c>0)return;s=this.addLocalMinPoly(e,t,r);break;case Q.Difference:(m.getPolyType(e)===ke.Clip&&u>0&&c>0||m.getPolyType(e)===ke.Subject&&u<=0&&c<=0)&&(s=this.addLocalMinPoly(e,t,r));break;case Q.Xor:s=this.addLocalMinPoly(e,t,r);break;default:if(u<=0||c<=0)return;s=this.addLocalMinPoly(e,t,r);break}s&&this.setZ(e,t,s.pt)}}}swapPositionsInAEL(e,t){let r=t.nextInAEL;r!==null&&(r.prevInAEL=e);let s=e.prevInAEL;s!==null&&(s.nextInAEL=t),t.prevInAEL=s,t.nextInAEL=e,e.prevInAEL=t,e.nextInAEL=r,t.prevInAEL===null&&(this.actives=t)}isValidAelOrder(e,t){if(t.curX!==e.curX)return t.curX>e.curX;let r=$.crossProductSign(e.top,t.bot,t.top);if(r!==0)return r<0;if(!m.isMaximaEdge(e)&&e.top.y>t.top.y)return $.crossProductSign(t.bot,e.top,m.nextVertex(e).pt)<=0;if(!m.isMaximaEdge(t)&&t.top.y>e.top.y)return $.crossProductSign(t.bot,t.top,m.nextVertex(t).pt)>=0;let s=t.bot.y,i=t.isLeftBound;return e.bot.y!==s||e.localMin.vertex.pt.y!==s?t.isLeftBound:e.isLeftBound!==i?i:$.isCollinear(m.prevPrevVertex(e).pt,e.bot,e.top)?!0:$.crossProductSign(m.prevPrevVertex(e).pt,t.bot,m.prevPrevVertex(t).pt)>0===i}isJoined(e){return e.joinWith!==Te.None}split(e,t){e.joinWith===Te.Right?(e.joinWith=Te.None,e.nextInAEL.joinWith=Te.None,this.addLocalMinPoly(e,e.nextInAEL,t,!0)):(e.joinWith=Te.None,e.prevInAEL.joinWith=Te.None,this.addLocalMinPoly(e.prevInAEL,e,t,!0))}setSides(e,t,r){e.frontEdge=t,e.backEdge=r}findEdgeWithMatchingLocMin(e){let t=e.nextInAEL;for(;t!==null;){if(t.localMin?.equals(e.localMin))return t;!m.isHorizontal(t)&&!(e.bot.x===t.bot.x&&e.bot.y===t.bot.y)?t=null:t=t.nextInAEL}for(t=e.prevInAEL;t!==null;){if(t.localMin?.equals(e.localMin))return t;if(!m.isHorizontal(t)&&!(e.bot.x===t.bot.x&&e.bot.y===t.bot.y))return null;t=t.prevInAEL}return t}addOutPt(e,t){let r=e.outrec,s=m.isFront(e),i=r.pts,o=i.next;if(s&&t.x===i.pt.x&&t.y===i.pt.y)return i;if(!s&&t.x===o.pt.x&&t.y===o.pt.y)return o;let a=new nt(t,r);return o.prev=a,a.prev=i,a.next=o,i.next=a,s&&(r.pts=a),a}addLocalMaxPoly(e,t,r){if(this.isJoined(e)&&this.split(e,r),this.isJoined(t)&&this.split(t,r),m.isFront(e)===m.isFront(t))if(m.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(m.isOpenEnd(t))this.swapFrontBackSides(t.outrec);else return this.succeeded=!1,null;let s=this.addOutPt(e,r);if(e.outrec===t.outrec){let i=e.outrec;if(i.pts=s,this.usingPolytree){let o=m.getPrevHotEdge(e);o===null?i.owner=null:this.setOwner(i,o.outrec)}this.uncoupleOutRec(e)}else m.isOpen(e)?e.windDx<0?this.joinOutrecPaths(e,t):this.joinOutrecPaths(t,e):e.outrec.idx<t.outrec.idx?this.joinOutrecPaths(e,t):this.joinOutrecPaths(t,e);return s}swapFrontBackSides(e){let t=e.frontEdge;e.frontEdge=e.backEdge,e.backEdge=t,e.pts=e.pts.next}setOwner(e,t){for(;t.owner!==null&&t.owner.pts===null;)t.owner=t.owner.owner;let r=t;for(;r!==null&&r!==e;)r=r.owner;r!==null&&(t.owner=e.owner),e.owner=t}uncoupleOutRec(e){let t=e.outrec;t!==null&&(t.frontEdge.outrec=null,t.backEdge.outrec=null,t.frontEdge=null,t.backEdge=null)}joinOutrecPaths(e,t){let r=e.outrec.pts,s=t.outrec.pts,i=r.next,o=s.next;m.isFront(e)?(o.prev=r,r.next=o,s.next=i,i.prev=s,e.outrec.pts=s,e.outrec.frontEdge=t.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(i.prev=s,s.next=i,r.next=o,o.prev=r,e.outrec.backEdge=t.outrec.backEdge,e.outrec.backEdge!==null&&(e.outrec.backEdge.outrec=e.outrec)),t.outrec.frontEdge=null,t.outrec.backEdge=null,t.outrec.pts=null,this.setOwner(t.outrec,e.outrec),m.isOpenEnd(e)&&(t.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,t.outrec=null}swapOutrecs(e,t){let r=e.outrec,s=t.outrec;if(r===s){let i=r.frontEdge;r.frontEdge=r.backEdge,r.backEdge=i;return}r!==null&&(e===r.frontEdge?r.frontEdge=t:r.backEdge=t),s!==null&&(t===s.frontEdge?s.frontEdge=e:s.backEdge=e),e.outrec=s,t.outrec=r}disposeIntersectNodes(){this.intersectList.length=0}static ptsReallyClose(e,t){return Math.abs(e.x-t.x)<2&&Math.abs(e.y-t.y)<2}static isVerySmallTriangle(e){return e.next.next===e.prev&&(m.ptsReallyClose(e.prev.pt,e.next.pt)||m.ptsReallyClose(e.pt,e.next.pt)||m.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,t,r,s){if(e===null||e.next===e||!r&&e.next===e.prev)return!1;s.length=0;let i,o;for(t?(i=e.pt,o=e.prev):(e=e.next,i=e.pt,o=e.next),s.push(i);o!==e;)o.pt.x===i.x&&o.pt.y===i.y||(i=o.pt,s.push(i)),t?o=o.prev:o=o.next;return s.length!==3||r||!m.isVerySmallTriangle(o)}buildPaths(e,t){e.length=0,t.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts===null)continue;let i=[];s.isOpen?m.buildPath(s.pts,this.reverseSolution,!0,i)&&t.push(i):(this.cleanCollinear(s),m.buildPath(s.pts,this.reverseSolution,!1,i)&&e.push(i))}return!0}buildTree(e,t){e.clear(),t.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts!==null){if(s.isOpen){let i=[];m.buildPath(s.pts,this.reverseSolution,!0,i)&&t.push(i);continue}this.checkBounds(s)&&this.recursiveCheckOwners(s,e)}}}checkBounds(e){return e.pts===null?!1:bt.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!m.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=$.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,t){if(!(e.polypath!==null||bt.isEmpty(e.bounds))){for(;e.owner!==null&&!(e.owner.splits!==null&&this.checkSplitOwner(e,e.owner.splits)||e.owner.pts!==null&&this.checkBounds(e.owner)&&this.containsRect(e.owner.bounds,e.bounds)&&this.path1InsidePath2(e.pts,e.owner.pts));)e.owner=e.owner.owner;e.owner!==null?(e.owner.polypath===null&&this.recursiveCheckOwners(e.owner,t),e.polypath=e.owner.polypath.addChild(e.path)):e.polypath=t.addChild(e.path)}}cleanCollinear(e){if(e=this.getRealOutRec(e),e===null||e.isOpen)return;if(!this.isValidClosedPath(e.pts)){e.pts=null;return}let t=e.pts,r=t;for(;;){if(r!==null&&$.isCollinear(r.prev.pt,r.pt,r.next.pt)&&(r.pt.x===r.prev.pt.x&&r.pt.y===r.prev.pt.y||r.pt.x===r.next.pt.x&&r.pt.y===r.next.pt.y||!this.preserveCollinear||$.dotProductSign(r.prev.pt,r.pt,r.next.pt)<0)){if(r===e.pts&&(e.pts=r.prev),r=this.disposeOutPt(r),!this.isValidClosedPath(r)){e.pts=null;return}t=r;continue}if(r===null||(r=r.next,r===t))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!m.isVerySmallTriangle(e))}disposeOutPt(e){let t=e.next===e?null:e.next;return e.prev.next=e.next,e.next.prev=e.prev,t}fixSelfIntersects(e){let t=e.pts;if(t.prev!==t.next.next)for(;;){if(t.next&&t.next.next&&this.boundingBoxesOverlap(t.prev.pt,t.pt,t.next.pt,t.next.next.pt)&&$.segsIntersect(t.prev.pt,t.pt,t.next.pt,t.next.next.pt)){if((t===e.pts||t.next===e.pts)&&(e.pts=e.pts.prev),this.doSplitOp(e,t),e.pts===null)return;if(t=e.pts,t.prev===t.next.next)break;continue}if(t=t.next,t===e.pts)break}}doSplitOp(e,t){let r=t.prev,s=t.next.next;e.pts=r;let i=$.getLineIntersectPt(r.pt,t.pt,t.next.pt,s.pt);this.zCallbackInternal&&this.zCallbackInternal(r.pt,t.pt,t.next.pt,s.pt,i);let o=m.areaOutPt(r),a=o<Kt?-o:o;if(a<ei){e.pts=null;return}let l=this.areaTriangle(i,t.pt,t.next.pt),u=l<Kt?-l:l;if(i.x===r.pt.x&&i.y===r.pt.y||i.x===s.pt.x&&i.y===s.pt.y)s.prev=r,r.next=s;else{let f=new nt(i,e);f.prev=r,f.next=s,s.prev=f,r.next=f}if(!(u>dl)||!(u>a)&&l>Kt!=o>Kt)return;let c=this.newOutRec();c.owner=e.owner,t.outrec=c,t.next.outrec=c;let h=new nt(i,c);h.prev=t.next,h.next=t,c.pts=h,t.prev=h,t.next.next=h,this.usingPolytree&&(this.path1InsidePath2(r,h)?(c.splits===null&&(c.splits=[]),c.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(c.idx)))}static areaOutPt(e){let t=$.maxCoordForSafeAreaProduct,r=0,s=!0,i=e;do{let a=i.prev,l=i.pt;if(Math.abs(a.pt.x)>=t||Math.abs(a.pt.y)>=t||Math.abs(l.x)>=t||Math.abs(l.y)>=t){s=!1;break}r+=(a.pt.y+l.y)*(a.pt.x-l.x),i=i.next}while(i!==e);if(s)return BigInt(Math.round(r));let o=Kt;i=e;do{let a=i.prev;if(Number.isSafeInteger(a.pt.y)&&Number.isSafeInteger(i.pt.y)&&Number.isSafeInteger(a.pt.x)&&Number.isSafeInteger(i.pt.x)){let l=BigInt(a.pt.y)+BigInt(i.pt.y),u=BigInt(a.pt.x)-BigInt(i.pt.x);o+=l*u}else{let l=a.pt.y+i.pt.y,u=a.pt.x-i.pt.x;o+=BigInt(Math.round(l*u))}i=i.next}while(i!==e);return o}areaTriangle(e,t,r){let s=$.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<s&&Math.abs(e.y)<s&&Math.abs(t.x)<s&&Math.abs(t.y)<s&&Math.abs(r.x)<s&&Math.abs(r.y)<s){let o=(r.y+e.y)*(r.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+r.y)*(t.x-r.x);return BigInt(Math.round(o))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(r.y)){let o=(BigInt(r.y)+BigInt(e.y))*(BigInt(r.x)-BigInt(e.x)),a=(BigInt(e.y)+BigInt(t.y))*(BigInt(e.x)-BigInt(t.x)),l=(BigInt(t.y)+BigInt(r.y))*(BigInt(t.x)-BigInt(r.x));return o+a+l}let i=(r.y+e.y)*(r.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+r.y)*(t.x-r.x);return BigInt(Math.round(i))}isValidOwner(e,t){for(;t!==null&&t!==e;)t=t.owner;return t===null}containsRect(e,t){return t.left>=e.left&&t.right<=e.right&&t.top>=e.top&&t.bottom<=e.bottom}checkSplitOwner(e,t){for(let r=0;r<t.length;r++){let s=this.outrecList[t[r]];if(s.pts===null&&s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(s=this.getRealOutRec(s),!(s===null||s===e||s.recursiveSplit===e)){if(s.recursiveSplit=e,s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(!(!this.checkBounds(s)||!this.containsRect(s.bounds,e.bounds)||!this.path1InsidePath2(e.pts,s.pts)))return this.isValidOwner(e,s)||(s.owner=e.owner),e.owner=s,!0}}return!1}};b(m,"openPathsEnabled",!0);var Nn=m,Ve=class extends Nn{constructor(){super(...arguments);b(this,"zCallback")}getZCallback(){return this.zCallback}addPath(t,r,s=!1){super.addPath(t,r,s)}addReuseableData(t){super.addReuseableData(t)}addPaths(t,r,s=!1){super.addPaths(t,r,s)}addSubject(t){this.addPaths(t,ke.Subject)}addOpenSubject(t){this.addPaths(t,ke.Subject,!0)}addClip(t){this.addPaths(t,ke.Clip)}execute(t,r,s,i){if(Array.isArray(s)){let o=s,a=i;o.length=0,a&&(a.length=0);try{this.executeInternal(t,r),this.buildPaths(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}else{let o=s,a=i;o.clear(),a&&(a.length=0),this.usingPolytree=!0;try{this.executeInternal(t,r),this.buildTree(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var Rr={area(n){return $.area(n)},areaD(n){let e=0,t=n.length;if(t<3)return 0;let r=n[t-1];for(let s of n)e+=(r.y+s.y)*(r.x-s.x),r=s;return e*.5},scalePath64(n,e){let t=$.maxSafeCoordinateForScale(e),r=[];for(let s of n)$.checkSafeScaleValue(s.x,t,"scalePath64"),$.checkSafeScaleValue(s.y,t,"scalePath64"),r.push({x:Math.round(s.x*e),y:Math.round(s.y*e)});return r},scalePaths64(n,e){let t=[];for(let r of n)t.push(Rr.scalePath64(r,e));return t},scalePathD(n,e){let t=[];for(let r of n)t.push({x:r.x*e,y:r.y*e});return t},scalePathsD(n,e){let t=[];for(let r of n)t.push(Rr.scalePathD(r,e));return t}};var Ie;(function(n){n[n.Miter=0]="Miter",n[n.Square=1]="Square",n[n.Bevel=2]="Bevel",n[n.Round=3]="Round"})(Ie||(Ie={}));var ue;(function(n){n[n.Polygon=0]="Polygon",n[n.Joined=1]="Joined",n[n.Butt=2]="Butt",n[n.Square=3]="Square",n[n.Round=4]="Round"})(ue||(ue={}));var Ur=class{constructor(e,t,r=ue.Polygon){b(this,"inPaths");b(this,"joinType");b(this,"endType");b(this,"pathsReversed");b(this,"lowestPathIdx");this.joinType=t,this.endType=r;let s=r===ue.Polygon||r===ue.Joined;this.inPaths=[];for(let i of e)this.inPaths.push(St.stripDuplicates(i,s));if(r===ue.Polygon){let i=St.getLowestPathInfo(this.inPaths);this.lowestPathIdx=i.idx,this.pathsReversed=this.lowestPathIdx>=0&&i.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},le=class le{constructor(e=2,t=0,r=!1,s=!1){b(this,"groupList",[]);b(this,"pathOut",[]);b(this,"normals",[]);b(this,"solution",[]);b(this,"solutionTree",null);b(this,"groupDelta",0);b(this,"delta",0);b(this,"mitLimSqr",0);b(this,"stepsPerRad",0);b(this,"stepSin",0);b(this,"stepCos",0);b(this,"joinType",Ie.Bevel);b(this,"endType",ue.Polygon);b(this,"arcTolerance",0);b(this,"mergeGroups",!0);b(this,"miterLimit",2);b(this,"preserveCollinear",!1);b(this,"reverseSolution",!1);b(this,"zCallback");b(this,"deltaCallback",null);b(this,"ZCB",(e,t,r,s,i)=>{(e.z||0)!==0&&(e.z===r.z||e.z===s.z)?i.z=e.z:(r.z||0)!==0&&r.z===t.z?i.z=r.z:(t.z||0)!==0&&t.z===s.z?i.z=t.z:this.zCallback&&this.zCallback(e,t,r,s,i)});this.miterLimit=e,this.arcTolerance=t,this.mergeGroups=!0,this.preserveCollinear=r,this.reverseSolution=s}clear(){this.groupList.length=0}addPath(e,t,r){if(e.length===0)return;let s=[e];this.addPaths(s,t,r)}addPaths(e,t,r){e.length!==0&&this.groupList.push(new Ur(e,t,r))}calcSolutionCapacity(){let e=0;for(let t of this.groupList)e+=t.endType===ue.Joined?t.inPaths.length*2:t.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let t of this.groupList)if(t.endType===ue.Polygon){e=t.pathsReversed;break}return e}executeInternal(e){if(this.groupList.length===0)return;if(Math.abs(e)<.5){for(let i of this.groupList)for(let o of i.inPaths)this.solution.push(o);return}this.delta=e,this.mitLimSqr=this.miterLimit<=1?2:2/le.sqr(this.miterLimit);for(let i of this.groupList)this.doGroupOffset(i);if(this.groupList.length===0)return;let t=this.checkPathsReversed(),r=t?V.Negative:V.Positive,s=new Ve;s.preserveCollinear=this.preserveCollinear,s.reverseSolution=this.reverseSolution!==t,s.zCallback=this.ZCB,s.addSubject(this.solution),this.solutionTree!==null?s.execute(Q.Union,r,this.solutionTree):s.execute(Q.Union,r,this.solution)}execute(e,t){if(Array.isArray(t)){let r=t;r.length=0,this.solution=r,this.executeInternal(e)}else{let r=t;r.clear(),this.solutionTree=r,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,t){this.deltaCallback=e,this.execute(1,t)}static getUnitNormal(e,t){let r=t.x-e.x,s=t.y-e.y;if(r===0&&s===0)return{x:0,y:0};let i=1/Math.sqrt(r*r+s*s);return{x:s*i,y:-r*i}}static getLowestPathInfo(e){let t=-1,r=!1,s={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let i=0;i<e.length;++i){let o=Number.MAX_VALUE;for(let a of e[i])if(!(a.y<s.y||a.y===s.y&&a.x>=s.x)){if(o===Number.MAX_VALUE){if(o=le.area(e[i]),o===0)break;r=o<0}t=i,s.x=a.x,s.y=a.y}}return{idx:t,isNegArea:r}}static translatePoint(e,t,r){return{x:e.x+t,y:e.y+r,z:e.z}}static reflectPoint(e,t){return{x:t.x+(t.x-e.x),y:t.y+(t.y-e.y),z:e.z}}static almostZero(e,t=.001){return Math.abs(e)<t}static hypotenuse(e,t){return Math.sqrt(e*e+t*t)}static normalizeVector(e){let t=le.hypotenuse(e.x,e.y);if(le.almostZero(t))return{x:0,y:0};let r=1/t;return{x:e.x*r,y:e.y*r}}static getAvgUnitVector(e,t){return le.normalizeVector({x:e.x+t.x,y:e.y+t.y})}static intersectPoint(e,t,r,s){if($.isAlmostZero(e.x-t.x)){if($.isAlmostZero(r.x-s.x))return{x:0,y:0};let i=(s.y-r.y)/(s.x-r.x),o=r.y-i*r.x;return{x:e.x,y:i*e.x+o}}if($.isAlmostZero(r.x-s.x)){let i=(t.y-e.y)/(t.x-e.x),o=e.y-i*e.x;return{x:r.x,y:i*r.x+o}}else{let i=(t.y-e.y)/(t.x-e.x),o=e.y-i*e.x,a=(s.y-r.y)/(s.x-r.x),l=r.y-a*r.x;if($.isAlmostZero(i-a))return{x:0,y:0};let u=(l-o)/(i-a);return{x:u,y:i*u+o}}}getPerpendic(e,t){return{x:Math.round(e.x+t.x*this.groupDelta),y:Math.round(e.y+t.y*this.groupDelta),z:e.z||0}}getPerpendicD(e,t){return{x:e.x+t.x*this.groupDelta,y:e.y+t.y*this.groupDelta,z:e.z||0}}doBevel(e,t,r){let s,i,o=e[t].z||0;if(t===r){let a=Math.abs(this.groupDelta);s={x:Math.round(e[t].x-a*this.normals[t].x),y:Math.round(e[t].y-a*this.normals[t].y),z:o},i={x:Math.round(e[t].x+a*this.normals[t].x),y:Math.round(e[t].y+a*this.normals[t].y),z:o}}else s={x:Math.round(e[t].x+this.groupDelta*this.normals[r].x),y:Math.round(e[t].y+this.groupDelta*this.normals[r].y),z:o},i={x:Math.round(e[t].x+this.groupDelta*this.normals[t].x),y:Math.round(e[t].y+this.groupDelta*this.normals[t].y),z:o};this.pathOut.push(s),this.pathOut.push(i)}doSquare(e,t,r){let s;t===r?s={x:this.normals[t].y,y:-this.normals[t].x}:s=le.getAvgUnitVector({x:-this.normals[r].y,y:this.normals[r].x},{x:this.normals[t].y,y:-this.normals[t].x});let i=Math.abs(this.groupDelta),o={x:e[t].x,y:e[t].y,z:e[t].z||0};o=le.translatePoint(o,i*s.x,i*s.y);let a=le.translatePoint(o,this.groupDelta*s.y,this.groupDelta*-s.x),l=le.translatePoint(o,this.groupDelta*-s.y,this.groupDelta*s.x),u=this.getPerpendicD(e[r],this.normals[r]);if(t===r){let c={x:u.x+s.x*this.groupDelta,y:u.y+s.y*this.groupDelta},h=le.intersectPoint(a,l,u,c);h.z=o.z,this.pathOut.push(Ye.fromPointD(le.reflectPoint(h,o))),this.pathOut.push(Ye.fromPointD(h))}else{let c=this.getPerpendicD(e[t],this.normals[r]),h=le.intersectPoint(a,l,u,c);h.z=o.z,this.pathOut.push(Ye.fromPointD(h)),this.pathOut.push(Ye.fromPointD(le.reflectPoint(h,o)))}}doMiter(e,t,r,s){let i=this.groupDelta/(s+1);this.pathOut.push({x:Math.round(e[t].x+(this.normals[r].x+this.normals[t].x)*i),y:Math.round(e[t].y+(this.normals[r].y+this.normals[t].y)*i),z:e[t].z||0})}doRound(e,t,r,s){if(this.deltaCallback!==null){let u=Math.abs(this.groupDelta),c=this.arcTolerance>.01?this.arcTolerance:u*le.arc_const,h=Math.PI/Math.acos(1-c/u);this.stepSin=Math.sin(2*Math.PI/h),this.stepCos=Math.cos(2*Math.PI/h),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=h/(2*Math.PI)}let i=e[t],o=i.z||0,a={x:this.normals[r].x*this.groupDelta,y:this.normals[r].y*this.groupDelta};t===r&&On.negate(a),this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});let l=Math.ceil(this.stepsPerRad*Math.abs(s));for(let u=1;u<l;u++)a={x:a.x*this.stepCos-this.stepSin*a.y,y:a.x*this.stepSin+a.y*this.stepCos},this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});this.pathOut.push(this.getPerpendic(e[t],this.normals[t]))}buildNormals(e){let t=e.length;if(this.normals.length=0,t!==0){for(let r=0;r<t-1;r++)this.normals.push(le.getUnitNormal(e[r],e[r+1]));this.normals.push(le.getUnitNormal(e[t-1],e[0]))}}offsetPoint(e,t,r,s){if(Ye.equals(t[r],t[s]))return;let i=$.crossProductD(this.normals[r],this.normals[s]),o=$.dotProductD(this.normals[r],this.normals[s]);if(i>1?i=1:i<-1&&(i=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,r,s),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<le.Tolerance){this.pathOut.push(t[r]);return}if(o>-.999&&i*this.groupDelta<0)this.pathOut.push(this.getPerpendic(t[r],this.normals[s])),this.pathOut.push(t[r]),this.pathOut.push(this.getPerpendic(t[r],this.normals[r]));else if(o>.999&&this.joinType!==Ie.Round)this.doMiter(t,r,s,o);else switch(this.joinType){case Ie.Miter:o>this.mitLimSqr-1?this.doMiter(t,r,s,o):this.doSquare(t,r,s);break;case Ie.Round:this.doRound(t,r,s,Math.atan2(i,o));break;case Ie.Bevel:this.doBevel(t,r,s);break;default:this.doSquare(t,r,s);break}}offsetPolygon(e,t){this.pathOut=[];let r=t.length,s=r-1;for(let i=0;i<r;i++)this.offsetPoint(e,t,i,s),s=i;this.solution.push(this.pathOut)}offsetOpenJoined(e,t){this.offsetPolygon(e,t);let r=[...t].reverse();this.buildNormals(r),this.offsetPolygon(e,r)}offsetOpenPath(e,t){this.pathOut=[];let r=t.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,0,0)),Math.abs(this.groupDelta)<le.Tolerance)this.pathOut.push(t[0]);else switch(this.endType){case ue.Butt:this.doBevel(t,0,0);break;case ue.Round:this.doRound(t,0,0,Math.PI);break;default:this.doSquare(t,0,0);break}for(let s=1,i=0;s<r;s++)this.offsetPoint(e,t,s,i),i=s;for(let s=r;s>0;s--)this.normals[s]={x:-this.normals[s-1].x,y:-this.normals[s-1].y};if(this.normals[0]=this.normals[r],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,r,r)),Math.abs(this.groupDelta)<le.Tolerance)this.pathOut.push(t[r]);else switch(this.endType){case ue.Butt:this.doBevel(t,r,r);break;case ue.Round:this.doRound(t,r,r,Math.PI);break;default:this.doSquare(t,r,r);break}for(let s=r-1,i=r;s>0;s--)this.offsetPoint(e,t,s,i),i=s;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===ue.Polygon?(e.lowestPathIdx<0&&(this.delta=Math.abs(this.delta)),this.groupDelta=e.pathsReversed?-this.delta:this.delta):this.groupDelta=Math.abs(this.delta);let t=Math.abs(this.groupDelta);if(this.joinType=e.joinType,this.endType=e.endType,e.joinType===Ie.Round||e.endType===ue.Round){let r=this.arcTolerance>.01?this.arcTolerance:t*le.arc_const,s=Math.PI/Math.acos(1-r/t);this.stepSin=Math.sin(2*Math.PI/s),this.stepCos=Math.cos(2*Math.PI/s),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=s/(2*Math.PI)}for(let r of e.inPaths){this.pathOut=[];let s=r.length;if(s===1){let i=r[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let o=i.z||0;if(e.endType===ue.Round){let a=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=le.ellipse(i,Math.abs(this.groupDelta),Math.abs(this.groupDelta),a),o!==0)for(let l=0;l<this.pathOut.length;l++)this.pathOut[l].z=o}else{let a=Math.ceil(Math.abs(this.groupDelta)),l={left:i.x-a,top:i.y-a,right:i.x+a,bottom:i.y+a};this.pathOut=[{x:l.left,y:l.top,z:o},{x:l.right,y:l.top,z:o},{x:l.right,y:l.bottom,z:o},{x:l.left,y:l.bottom,z:o}]}this.solution.push(this.pathOut);continue}switch(s===2&&e.endType===ue.Joined&&(this.endType=e.joinType===Ie.Round?ue.Round:ue.Square),this.buildNormals(r),this.endType){case ue.Polygon:this.offsetPolygon(e,r);break;case ue.Joined:this.offsetOpenJoined(e,r);break;default:this.offsetOpenPath(e,r);break}}}static stripDuplicates(e,t){let r=e.length,s=[];if(r===0)return s;let i=e[0];s.push(i);for(let o=1;o<r;o++)Ye.equals(i,e[o])||(i=e[o],s.push(i));return t&&Ye.equals(i,s[0])&&s.pop(),s}static area(e){return $.area(e)}static sqr(e){return e*e}static ellipse(e,t,r=0,s=0){if(t<=0)return[];r<=0&&(r=t),s<=2&&(s=Math.ceil(Math.PI*Math.sqrt((t+r)/2)));let i=Math.sin(2*Math.PI/s),o=Math.cos(2*Math.PI/s),a=o,l=i,u=[{x:Math.round(e.x+t),y:e.y}];for(let c=1;c<s;++c){u.push({x:Math.round(e.x+t*a),y:Math.round(e.y+r*l)});let h=a*o-l*i;l=l*o+a*i,a=h}return u}};b(le,"Tolerance",1e-12),b(le,"arc_const",.002);var St=le;var Op=BigInt(2);function Br(n,e,t){return typeof e=="number"?Nr(Q.Union,n,null,e):Nr(Q.Union,n,e,t)}function Nr(n,e,t,r){let s=[];if(e===null)return s;let i=new Ve;return i.addPaths(e,ke.Subject),t!==null&&i.addPaths(t,ke.Clip),i.execute(n,r,s),s}function Bn(n,e,t,r,s=2,i=0){let o=new St(s,i);o.addPaths(n,t,r);let a=[];return o.execute(e,a),a}var at=1e4;function wt(){return{layers:new Map,parts:[]}}function Ge(n,e="cut"){return{layers:new Map([[e,{regions:n,lines:[]}]]),parts:[]}}function Nt(n,e="cut"){return{layers:new Map([[e,{regions:[],lines:n}]]),parts:[]}}function ii(n){if(n.parts.length)return!1;for(let e of n.layers.values())if(e.regions.length||e.lines.length)return!1;return!0}var lt=n=>n.map(e=>e.map(([t,r])=>({x:Math.round(t*at),y:Math.round(r*at)}))),Bt=n=>n.filter(e=>e.length>=2).map(e=>e.map(t=>[t.x/at,t.y/at]));function be(n,e="nonzero"){if(!n.length)return[];let t=e==="evenodd"?V.EvenOdd:V.NonZero;return Bt(Br(lt(n),t)).filter(r=>r.length>=3)}function oi(n,e,t){if(!e.length)return[];let r=new Ve;r.addSubject(lt(e)),t.length&&r.addClip(lt(t));let s=[];return r.execute(n,V.NonZero,s),Bt(s).filter(i=>i.length>=3)}var Gn=(n,e)=>e.length?oi(Q.Difference,n,e):be(n),$n=(n,e)=>oi(Q.Intersection,n,e);function rn(n,e,t){if(!n.length)return[];if(!e.length)return t==="outside"?n:[];let r=new Ve;r.addOpenSubject(lt(n)),r.addClip(lt(e));let s=[],i=[];return r.execute(t==="inside"?Q.Intersection:Q.Difference,V.NonZero,s,i),Bt(i)}function zn(n,e,t="round",r=.01){if(!n.length)return[];if(e===0)return be(n);let s=t==="round"?Ie.Round:t==="square"?Ie.Square:Ie.Miter,i=Bn(lt(be(n)),e*at,s,ue.Polygon,2,r*at);return Bt(i).filter(o=>o.length>=3)}function ai(n,e){if(!n.length||e<=0)return[];let t=Bn(lt(n),e/2*at,Ie.Round,ue.Round,2,.01*at);return Bt(t)}function li(n){if(!n.length)return[];let e=new nn,t=new Ve;t.addSubject(lt(n)),t.execute(Q.Union,V.NonZero,e);let r=[],s=i=>{for(let o=0;o<i.count;o++){let a=i.child(o),l=[a.poly];for(let u=0;u<a.count;u++){let c=a.child(u);l.push(c.poly),s(c)}r.push(Bt(l))}};return s(e),r}function ut(n){let e=0;for(let t=0,r=n.length-1;t<n.length;r=t++)e+=(n[r][0]+n[t][0])*(n[r][1]-n[t][1]);return-e/2}function ni(n,[e,t]){return[n[0]*e+n[2]*t+n[4],n[1]*e+n[3]*t+n[5]]}function ri(n,e){let t=e[0]*e[3]-e[1]*e[2]<0,r=new Map;for(let[s,i]of n)r.set(s,{regions:i.regions.map(o=>{let a=o.map(l=>ni(e,l));return t?a.reverse():a}),lines:i.lines.map(o=>o.map(a=>ni(e,a)))});return r}function Hn(n,e){return{layers:ri(n.layers,e),parts:n.parts.map(t=>({...t,layers:ri(t.layers,e)}))}}function sn(n){let e=wt();for(let t of n){for(let[r,s]of t.layers){let i=e.layers.get(r)??{regions:[],lines:[]};for(let o of s.regions)i.regions.push(o);for(let o of s.lines)i.lines.push(o);e.layers.set(r,i)}for(let r of t.parts)e.parts.push(r)}return e}function si(n,e){let t={regions:[],lines:[]};for(let r of n.values()){for(let s of r.regions)t.regions.push(s);for(let s of r.lines)t.lines.push(s)}return new Map([[e,t]])}function Vn(n,e){if(n.parts.length&&e!=="guide")throw new Error(`a part cannot go on the ${e} layer as a whole. Put ${e}() inside part() instead.`);return{layers:si(n.layers,e),parts:n.parts.map(t=>({...t,layers:si(t.layers,e)}))}}function Xn(n){let e=1/0,t=1/0,r=-1/0,s=-1/0;for(let i of n)for(let[o,a]of i)o<e&&(e=o),a<t&&(t=a),o>r&&(r=o),a>s&&(s=a);return e===1/0?null:[e,t,r,s]}function Gr(n,e){let t=[];for(let[r,s]of n)if(!e?.(r))for(let i of[...s.regions,...s.lines])t.push(i);return Xn(t)}function ui(n){let e=[...n].sort((i,o)=>i[0]-o[0]||i[1]-o[1]);if(e.length<3)return e;let t=(i,o,a)=>(o[0]-i[0])*(a[1]-i[1])-(o[1]-i[1])*(a[0]-i[0]),r=[];for(let i of e){for(;r.length>=2&&t(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}let s=[];for(let i=e.length-1;i>=0;i--){let o=e[i];for(;s.length>=2&&t(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return s.pop(),r.pop(),r.concat(s)}function ci(n,e,t,r){return n<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/t,n*2*Math.PI/r)),5)}function qn(n,e,t){let r=[];for(let s=0;s<t;s++){let i=2*Math.PI*s/t;r.push([n*Math.cos(i),e*Math.sin(i)])}return r}function fi(n,e,t,r){if(t=Math.min(t,n/2,e/2),t<=0)return[[0,0],[n,0],[n,e],[0,e]];let s=Math.max(1,Math.ceil(r(t)/4)),i=[],o=[[n-t,t,-90],[n-t,e-t,0],[t,e-t,90],[t,t,180]];for(let[a,l,u]of o)for(let c=0;c<=s;c++){let h=(u+90*c/s)*Math.PI/180;i.push([a+t*Math.cos(h),l+t*Math.sin(h)])}return i}function Wn(n,e){let t=Math.round(n/e);return t%2===0&&(t+=n/e>t?1:-1),Math.max(3,t)}var on=(n,e,t,r)=>[[n,e],[t,e],[t,r],[n,r]];function yl(n,e,t,r){if(e==="flat")return[];let s=Wn(n,r),i=n/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===1:a%2===0)&&o.push(on(a*i,-1,(a+1)*i,t));return o}function hi(n,e,t,r,s){let i=[([l,u])=>[l,u],([l,u])=>[n-u,l],([l,u])=>[n-l,e-u],([l,u])=>[u,e-l]],o=[n,e,n,e],a=[];return t.forEach((l,u)=>{for(let c of yl(o[u],l,r,s))a.push(c.map(i[u]))}),Gn([on(0,0,n,e)],a)}function pi(n,e,t,r){let s=Wn(n,r),i=n/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===0:a%2===1)&&o.push(on(a*i,-t/2,(a+1)*i,t/2));return o}function di(n,e,t,r,s){let i=on(-n/2,-1,n/2,e),o=on(-t/2,s,t/2,s+r);return[i,o]}function gi(n,e,t,r,s){let i=[],o=s+r,a=Math.floor(n/t),l=(n-a*t)/2;for(let u=0;u<=a;u++){let c=l+u*t,h=u%2===0?r:r-o/2;for(let f=h;f<e;f+=o){let p=Math.max(f,u%2===0?r:0),d=Math.min(f+s,e-(u%2===0?r:0));d-p>=r/2&&i.push([[c,p],[c,d]])}}return i}function _n(n,e=.02){let t=[],r=[],s=[],i=[0,0],o=[0,0],a=u=>{s.length>=2&&(u?t:r).push(s),s=[]},l=u=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(u/e))));for(let u of n)if(u.type==="M")a(!1),i=o=[u.x,u.y],s=[o];else if(u.type==="L")o=[u.x,u.y],s.push(o);else if(u.type==="Q"){let[c,h]=o,f=l(Math.hypot(u.x1-c,u.y1-h)+Math.hypot(u.x-u.x1,u.y-u.y1));for(let p=1;p<=f;p++){let d=p/f,g=1-d;s.push([g*g*c+2*g*d*u.x1+d*d*u.x,g*g*h+2*g*d*u.y1+d*d*u.y])}o=[u.x,u.y]}else if(u.type==="C"){let[c,h]=o,f=l(Math.hypot(u.x1-c,u.y1-h)+Math.hypot(u.x2-u.x1,u.y2-u.y1)+Math.hypot(u.x-u.x2,u.y-u.y2));for(let p=1;p<=f;p++){let d=p/f,g=1-d;s.push([g*g*g*c+3*g*g*d*u.x1+3*g*d*d*u.x2+d*d*d*u.x,g*g*g*h+3*g*g*d*u.y1+3*g*d*d*u.y2+d*d*d*u.y])}o=[u.x,u.y]}else a(!0),o=i,s=[i];return a(!1),{closed:t,open:r}}function mi(n){let e=x=>/^[a-zA-Z]$/.test(x),t=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],r=[],s=0,i="",o=0,a=0,l=0,u=0,c=0,h=0,f=0,p=0,d="",g=()=>{let x=t[s++];if(x===void 0||e(x))throw new Error(`Bad path data near "${x??"end"}"`);return Number(x)},y=()=>{let x=t[s];if(x===void 0)throw new Error("Bad path data: missing arc flag");return x.length>1&&(x[0]==="0"||x[0]==="1")&&!x.includes(".")?(t[s]=x.slice(1),Number(x[0])):(s++,Number(x))};for(;s<t.length;){if(e(t[s]))i=t[s++];else if(i){if(i==="Z"||i==="z")throw new Error(`Bad path data near "${t[s]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let x=i===i.toLowerCase(),I=i.toUpperCase(),k=x?o:0,F=x?a:0;if(I==="M")o=k+g(),a=F+g(),l=o,u=a,r.push({type:"M",x:o,y:a}),i=x?"l":"L";else if(I==="L")o=k+g(),a=F+g(),r.push({type:"L",x:o,y:a});else if(I==="H")o=k+g(),r.push({type:"L",x:o,y:a});else if(I==="V")a=F+g(),r.push({type:"L",x:o,y:a});else if(I==="C"||I==="S"){let L,U;if(I==="C")L=k+g(),U=F+g();else{let H=d==="C"||d==="S";L=H?2*o-c:o,U=H?2*a-h:a}let P=k+g(),T=F+g();o=k+g(),a=F+g(),c=P,h=T,r.push({type:"C",x1:L,y1:U,x2:P,y2:T,x:o,y:a})}else if(I==="Q"||I==="T"){let L,U;if(I==="Q")L=k+g(),U=F+g();else{let P=d==="Q"||d==="T";L=P?2*o-f:o,U=P?2*a-p:a}o=k+g(),a=F+g(),f=L,p=U,r.push({type:"Q",x1:L,y1:U,x:o,y:a})}else if(I==="A"){let L=g(),U=g(),P=g(),T=y(),H=y(),S=k+g(),D=F+g();r.push(...bl(o,a,L,U,P,T,H,S,D)),o=S,a=D}else if(I==="Z")r.push({type:"Z"}),o=l,a=u;else throw new Error(`Unknown path command "${i}"`);d=I}return r}function bl(n,e,t,r,s,i,o,a,l){if(t===0||r===0||n===a&&e===l)return[{type:"L",x:a,y:l}];t=Math.abs(t),r=Math.abs(r);let u=s*Math.PI/180,c=Math.cos(u),h=Math.sin(u),f=(n-a)/2,p=(e-l)/2,d=c*f+h*p,g=-h*f+c*p,y=d*d/(t*t)+g*g/(r*r);y>1&&(t*=Math.sqrt(y),r*=Math.sqrt(y));let x=t*t*r*r-t*t*g*g-r*r*d*d,I=t*t*g*g+r*r*d*d,k=Math.sqrt(Math.max(0,x/I));i===o&&(k=-k);let F=k*t*g/r,L=-k*r*d/t,U=c*F-h*L+(n+a)/2,P=h*F+c*L+(e+l)/2,T=(z,_,te,ee)=>Math.atan2(z*ee-_*te,z*te+_*ee),H=T(1,0,(d-F)/t,(g-L)/r),S=T((d-F)/t,(g-L)/r,(-d-F)/t,(-g-L)/r);!o&&S>0&&(S-=2*Math.PI),o&&S<0&&(S+=2*Math.PI);let D=Math.ceil(Math.abs(S)/(Math.PI/2)),ce=[],ge=z=>[U+t*Math.cos(z)*c-r*Math.sin(z)*h,P+t*Math.cos(z)*h+r*Math.sin(z)*c],q=z=>[-t*Math.sin(z)*c-r*Math.cos(z)*h,-t*Math.sin(z)*h+r*Math.cos(z)*c];for(let z=0;z<D;z++){let _=H+S*z/D,te=H+S*(z+1)/D,ee=4/3*Math.tan((te-_)/4),ie=ge(_),fe=ge(te),J=q(_),E=q(te);ce.push({type:"C",x1:ie[0]+ee*J[0],y1:ie[1]+ee*J[1],x2:fe[0]-ee*E[0],y2:fe[1]-ee*E[1],x:fe[0],y:fe[1]})}return ce}String.prototype.codePointAt||(function(){var n=(function(){try{var t={},r=Object.defineProperty,s=r(t,t,t)&&r}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var r=String(this),s=r.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=s)){var o=r.charCodeAt(i),a;return o>=55296&&o<=56319&&s>i+1&&(a=r.charCodeAt(i+1),a>=56320&&a<=57343)?(o-55296)*1024+a-56320+65536:o}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();var ss=0,so=-3;function un(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Sl(n,e){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new un,this.dtree=new un}var io=new un,oo=new un,is=new Uint8Array(30),os=new Uint16Array(30),ao=new Uint8Array(30),lo=new Uint16Array(30),wl=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yi=new un,Ke=new Uint8Array(320);function uo(n,e,t,r){var s,i;for(s=0;s<t;++s)n[s]=0;for(s=0;s<30-t;++s)n[s+t]=s/t|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<n[s]}function kl(n,e){var t;for(t=0;t<7;++t)n.table[t]=0;for(n.table[7]=24,n.table[8]=152,n.table[9]=112,t=0;t<24;++t)n.trans[t]=256+t;for(t=0;t<144;++t)n.trans[24+t]=t;for(t=0;t<8;++t)n.trans[168+t]=280+t;for(t=0;t<112;++t)n.trans[176+t]=144+t;for(t=0;t<5;++t)e.table[t]=0;for(e.table[5]=32,t=0;t<32;++t)e.trans[t]=t}var bi=new Uint16Array(16);function $r(n,e,t,r){var s,i;for(s=0;s<16;++s)n.table[s]=0;for(s=0;s<r;++s)n.table[e[t+s]]++;for(n.table[0]=0,i=0,s=0;s<16;++s)bi[s]=i,i+=n.table[s];for(s=0;s<r;++s)e[t+s]&&(n.trans[bi[e[t+s]]++]=s)}function El(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var e=n.tag&1;return n.tag>>>=1,e}function Je(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var r=n.tag&65535>>>16-e;return n.tag>>>=e,n.bitcount-=e,r+t}function Zr(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var t=0,r=0,s=0,i=n.tag;do r=2*r+(i&1),i>>>=1,++s,t+=e.table[s],r-=e.table[s];while(r>=0);return n.tag=i,n.bitcount-=s,e.trans[t+r]}function Pl(n,e,t){var r,s,i,o,a,l;for(r=Je(n,5,257),s=Je(n,5,1),i=Je(n,4,4),o=0;o<19;++o)Ke[o]=0;for(o=0;o<i;++o){var u=Je(n,3,0);Ke[wl[o]]=u}for($r(yi,Ke,0,19),a=0;a<r+s;){var c=Zr(n,yi);switch(c){case 16:var h=Ke[a-1];for(l=Je(n,2,3);l;--l)Ke[a++]=h;break;case 17:for(l=Je(n,3,3);l;--l)Ke[a++]=0;break;case 18:for(l=Je(n,7,11);l;--l)Ke[a++]=0;break;default:Ke[a++]=c;break}}$r(e,Ke,0,r),$r(t,Ke,r,s)}function Si(n,e,t){for(;;){var r=Zr(n,e);if(r===256)return ss;if(r<256)n.dest[n.destLen++]=r;else{var s,i,o,a;for(r-=257,s=Je(n,is[r],os[r]),i=Zr(n,t),o=n.destLen-Je(n,ao[i],lo[i]),a=o;a<o+s;++a)n.dest[n.destLen++]=n.dest[a]}}}function Ll(n){for(var e,t,r;n.bitcount>8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return so;for(n.sourceIndex+=4,r=e;r;--r)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,ss}function Tl(n,e){var t=new Sl(n,e),r,s,i;do{switch(r=El(t),s=Je(t,2,0),s){case 0:i=Ll(t);break;case 1:i=Si(t,io,oo);break;case 2:Pl(t,t.ltree,t.dtree),i=Si(t,t.ltree,t.dtree);break;default:i=so}if(i!==ss)throw new Error("Data error")}while(!r);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}kl(io,oo);uo(is,os,4,3);uo(ao,lo,2,1);is[28]=0;os[28]=258;var Il=Tl;function Gt(n,e,t,r,s){return Math.pow(1-s,3)*n+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*r}function mt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}mt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};mt.prototype.addPoint=function(n,e){typeof n=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=n,this.x2=n),n<this.x1&&(this.x1=n),n>this.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))};mt.prototype.addX=function(n){this.addPoint(n,null)};mt.prototype.addY=function(n){this.addPoint(null,n)};mt.prototype.addBezier=function(n,e,t,r,s,i,o,a){var l=[n,e],u=[t,r],c=[s,i],h=[o,a];this.addPoint(n,e),this.addPoint(o,a);for(var f=0;f<=1;f++){var p=6*l[f]-12*u[f]+6*c[f],d=-3*l[f]+9*u[f]-9*c[f]+3*h[f],g=3*u[f]-3*l[f];if(d===0){if(p===0)continue;var y=-g/p;0<y&&y<1&&(f===0&&this.addX(Gt(l[f],u[f],c[f],h[f],y)),f===1&&this.addY(Gt(l[f],u[f],c[f],h[f],y)));continue}var x=Math.pow(p,2)-4*g*d;if(!(x<0)){var I=(-p+Math.sqrt(x))/(2*d);0<I&&I<1&&(f===0&&this.addX(Gt(l[f],u[f],c[f],h[f],I)),f===1&&this.addY(Gt(l[f],u[f],c[f],h[f],I)));var k=(-p-Math.sqrt(x))/(2*d);0<k&&k<1&&(f===0&&this.addX(Gt(l[f],u[f],c[f],h[f],k)),f===1&&this.addY(Gt(l[f],u[f],c[f],h[f],k)))}}};mt.prototype.addQuad=function(n,e,t,r,s,i){var o=n+.6666666666666666*(t-n),a=e+2/3*(r-e),l=o+1/3*(s-n),u=a+1/3*(i-e);this.addBezier(n,e,o,a,l,u,s,i)};function ye(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}ye.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};ye.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};ye.prototype.curveTo=ye.prototype.bezierCurveTo=function(n,e,t,r,s,i){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:r,x:s,y:i})};ye.prototype.quadTo=ye.prototype.quadraticCurveTo=function(n,e,t,r){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:r})};ye.prototype.close=ye.prototype.closePath=function(){this.commands.push({type:"Z"})};ye.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof mt){var e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};ye.prototype.getBoundingBox=function(){for(var n=new mt,e=0,t=0,r=0,s=0,i=0;i<this.commands.length;i++){var o=this.commands[i];switch(o.type){case"M":n.addPoint(o.x,o.y),e=r=o.x,t=s=o.y;break;case"L":n.addPoint(o.x,o.y),r=o.x,s=o.y;break;case"Q":n.addQuad(r,s,o.x1,o.y1,o.x,o.y),r=o.x,s=o.y;break;case"C":n.addBezier(r,s,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,s=o.y;break;case"Z":r=e,s=t;break;default:throw new Error("Unexpected path command "+o.type)}}return n.isEmpty()&&n.addPoint(0,0),n};ye.prototype.draw=function(n){n.beginPath();for(var e=0;e<this.commands.length;e+=1){var t=this.commands[e];t.type==="M"?n.moveTo(t.x,t.y):t.type==="L"?n.lineTo(t.x,t.y):t.type==="C"?n.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?n.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&n.closePath()}this.fill&&(n.fillStyle=this.fill,n.fill()),this.stroke&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeWidth,n.stroke())};ye.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(o){return Math.round(o)===o?""+Math.round(o):o.toFixed(n)}function t(){for(var o=arguments,a="",l=0;l<arguments.length;l+=1){var u=o[l];u>=0&&l>0&&(a+=" "),a+=e(u)}return a}for(var r="",s=0;s<this.commands.length;s+=1){var i=this.commands[s];i.type==="M"?r+="M"+t(i.x,i.y):i.type==="L"?r+="L"+t(i.x,i.y):i.type==="C"?r+="C"+t(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type==="Q"?r+="Q"+t(i.x1,i.y1,i.x,i.y):i.type==="Z"&&(r+="Z")}return r};ye.prototype.toSVG=function(n){var e='<path d="';return e+=this.toPathData(n),e+='"',this.fill&&this.fill!=="black"&&(this.fill===null?e+=' fill="none"':e+=' fill="'+this.fill+'"'),this.stroke&&(e+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),e+="/>",e};ye.prototype.toDOMElement=function(n){var e=this.toPathData(n),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function co(n){throw new Error(n)}function wi(n,e){n||co(e)}var N={fail:co,argument:wi,assert:wi},ki=32768,Ei=2147483648,zt={},C={},G={};function _e(n){return function(){return n}}C.BYTE=function(n){return N.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]};G.BYTE=_e(1);C.CHAR=function(n){return[n.charCodeAt(0)]};G.CHAR=_e(1);C.CHARARRAY=function(n){typeof n>"u"&&(n="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var e=[],t=0;t<n.length;t+=1)e[t]=n.charCodeAt(t);return e};G.CHARARRAY=function(n){return typeof n>"u"?0:n.length};C.USHORT=function(n){return[n>>8&255,n&255]};G.USHORT=_e(2);C.SHORT=function(n){return n>=ki&&(n=-(2*ki-n)),[n>>8&255,n&255]};G.SHORT=_e(2);C.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};G.UINT24=_e(3);C.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};G.ULONG=_e(4);C.LONG=function(n){return n>=Ei&&(n=-(2*Ei-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};G.LONG=_e(4);C.FIXED=C.ULONG;G.FIXED=G.ULONG;C.FWORD=C.SHORT;G.FWORD=G.SHORT;C.UFWORD=C.USHORT;G.UFWORD=G.USHORT;C.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]};G.LONGDATETIME=_e(8);C.TAG=function(n){return N.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};G.TAG=_e(4);C.Card8=C.BYTE;G.Card8=G.BYTE;C.Card16=C.USHORT;G.Card16=G.USHORT;C.OffSize=C.BYTE;G.OffSize=G.BYTE;C.SID=C.USHORT;G.SID=G.USHORT;C.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?C.NUMBER16(n):C.NUMBER32(n)};G.NUMBER=function(n){return C.NUMBER(n).length};C.NUMBER16=function(n){return[28,n>>8&255,n&255]};G.NUMBER16=_e(3);C.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};G.NUMBER32=_e(5);C.REAL=function(n){var e=n.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}for(var s="",i=0,o=e.length;i<o;i+=1){var a=e[i];a==="e"?s+=e[++i]==="-"?"c":"b":a==="."?s+="a":a==="-"?s+="e":s+=a}s+=s.length&1?"f":"ff";for(var l=[30],u=0,c=s.length;u<c;u+=2)l.push(parseInt(s.substr(u,2),16));return l};G.REAL=function(n){return C.REAL(n).length};C.NAME=C.CHARARRAY;G.NAME=G.CHARARRAY;C.STRING=C.CHARARRAY;G.STRING=G.CHARARRAY;zt.UTF8=function(n,e,t){for(var r=[],s=t,i=0;i<s;i++,e+=1)r[i]=n.getUint8(e);return String.fromCharCode.apply(null,r)};zt.UTF16=function(n,e,t){for(var r=[],s=t/2,i=0;i<s;i++,e+=2)r[i]=n.getUint16(e);return String.fromCharCode.apply(null,r)};C.UTF16=function(n){for(var e=[],t=0;t<n.length;t+=1){var r=n.charCodeAt(t);e[e.length]=r>>8&255,e[e.length]=r&255}return e};G.UTF16=function(n){return n.length*2};var Yr={"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"};zt.MACSTRING=function(n,e,t,r){var s=Yr[r];if(s!==void 0){for(var i="",o=0;o<t;o++){var a=n.getUint8(e+o);a<=127?i+=String.fromCharCode(a):i+=s[a&127]}return i}};var jn=typeof WeakMap=="function"&&new WeakMap,Zn,Cl=function(n){if(!Zn){Zn={};for(var e in Yr)Zn[e]=new String(e)}var t=Zn[n];if(t!==void 0){if(jn){var r=jn.get(t);if(r!==void 0)return r}var s=Yr[n];if(s!==void 0){for(var i={},o=0;o<s.length;o++)i[s.charCodeAt(o)]=o+128;return jn&&jn.set(t,i),i}}};C.MACSTRING=function(n,e){var t=Cl(e);if(t!==void 0){for(var r=[],s=0;s<n.length;s++){var i=n.charCodeAt(s);if(i>=128&&(i=t[i],i===void 0))return;r[s]=i}return r}};G.MACSTRING=function(n,e){var t=C.MACSTRING(n,e);return t!==void 0?t.length:0};function Kr(n){return n>=-128&&n<=127}function Ml(n,e,t){for(var r=0,s=n.length;e<s&&r<64&&n[e]===0;)++e,++r;return t.push(128|r-1),e}function Al(n,e,t){for(var r=0,s=n.length,i=e;i<s&&r<64;){var o=n[i];if(!Kr(o)||o===0&&i+1<s&&n[i+1]===0)break;++i,++r}t.push(r-1);for(var a=e;a<i;++a)t.push(n[a]+256&255);return i}function Ol(n,e,t){for(var r=0,s=n.length,i=e;i<s&&r<64;){var o=n[i];if(o===0||Kr(o)&&i+1<s&&Kr(n[i+1]))break;++i,++r}t.push(64|r-1);for(var a=e;a<i;++a){var l=n[a];t.push(l+65536>>8&255,l+256&255)}return i}C.VARDELTAS=function(n){for(var e=0,t=[];e<n.length;){var r=n[e];r===0?e=Ml(n,e,t):r>=-128&&r<=127?e=Al(n,e,t):e=Ol(n,e,t)}return t};C.INDEX=function(n){for(var e=1,t=[e],r=[],s=0;s<n.length;s+=1){var i=C.OBJECT(n[s]);Array.prototype.push.apply(r,i),e+=i.length,t.push(e)}if(r.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,l=[void 0,C.BYTE,C.USHORT,C.UINT24,C.ULONG][a],u=0;u<t.length;u+=1){var c=l(t[u]);Array.prototype.push.apply(o,c)}return Array.prototype.concat(C.Card16(n.length),C.OffSize(a),o,r)};G.INDEX=function(n){return C.INDEX(n).length};C.DICT=function(n){for(var e=[],t=Object.keys(n),r=t.length,s=0;s<r;s+=1){var i=parseInt(t[s],0),o=n[i];e=e.concat(C.OPERAND(o.value,o.type)),e=e.concat(C.OPERATOR(i))}return e};G.DICT=function(n){return C.DICT(n).length};C.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]};C.OPERAND=function(n,e){var t=[];if(Array.isArray(e))for(var r=0;r<e.length;r+=1)N.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(C.OPERAND(n[r],e[r]));else if(e==="SID")t=t.concat(C.NUMBER(n));else if(e==="offset")t=t.concat(C.NUMBER32(n));else if(e==="number")t=t.concat(C.NUMBER(n));else if(e==="real")t=t.concat(C.REAL(n));else throw new Error("Unknown operand type "+e);return t};C.OP=C.BYTE;G.OP=G.BYTE;var Yn=typeof WeakMap=="function"&&new WeakMap;C.CHARSTRING=function(n){if(Yn){var e=Yn.get(n);if(e!==void 0)return e}for(var t=[],r=n.length,s=0;s<r;s+=1){var i=n[s];t=t.concat(C[i.type](i.value))}return Yn&&Yn.set(n,t),t};G.CHARSTRING=function(n){return C.CHARSTRING(n).length};C.OBJECT=function(n){var e=C[n.type];return N.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)};G.OBJECT=function(n){var e=G[n.type];return N.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)};C.TABLE=function(n){for(var e=[],t=n.fields.length,r=[],s=[],i=0;i<t;i+=1){var o=n.fields[i],a=C[o.type];N.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var l=n[o.name];l===void 0&&(l=o.value);var u=a(l);o.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),r.push(u)):e=e.concat(u)}for(var c=0;c<r.length;c+=1){var h=s[c],f=e.length;N.argument(f<65536,"Table "+n.tableName+" too big."),e[h]=f>>8,e[h+1]=f&255,e=e.concat(r[c])}return e};G.TABLE=function(n){for(var e=0,t=n.fields.length,r=0;r<t;r+=1){var s=n.fields[r],i=G[s.type];N.argument(i!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");var o=n[s.name];o===void 0&&(o=s.value),e+=i(o),s.type==="TABLE"&&(e+=2)}return e};C.RECORD=C.TABLE;G.RECORD=G.TABLE;C.LITERAL=function(n){return n};G.LITERAL=function(n){return n.length};function Se(n,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var r=0;r<e.length;r+=1){var s=e[r];this[s.name]=s.value}if(this.tableName=n,this.fields=e,t)for(var i=Object.keys(t),o=0;o<i.length;o+=1){var a=i[o],l=t[a];this[a]!==void 0&&(this[a]=l)}}Se.prototype.encode=function(){return C.TABLE(this)};Se.prototype.sizeOf=function(){return G.TABLE(this)};function cn(n,e,t){t===void 0&&(t=e.length);var r=new Array(e.length+1);r[0]={name:n+"Count",type:"USHORT",value:t};for(var s=0;s<e.length;s++)r[s+1]={name:n+s,type:"USHORT",value:e[s]};return r}function Jr(n,e,t){var r=e.length,s=new Array(r+1);s[0]={name:n+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s[i+1]={name:n+i,type:"TABLE",value:t(e[i],i)};return s}function fn(n,e,t){var r=e.length,s=[];s[0]={name:n+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s=s.concat(t(e[i],i));return s}function tr(n){n.format===1?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(cn("glyph",n.glyphs))):n.format===2?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(fn("rangeRecord",n.ranges,function(e){return[{name:"startGlyphID",type:"USHORT",value:e.start},{name:"endGlyphID",type:"USHORT",value:e.end},{name:"startCoverageIndex",type:"USHORT",value:e.index}]}))):N.assert(!1,"Coverage format must be 1 or 2.")}tr.prototype=Object.create(Se.prototype);tr.prototype.constructor=tr;function nr(n){Se.call(this,"scriptListTable",fn("scriptRecord",n,function(e,t){var r=e.script,s=r.defaultLangSys;return N.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Se("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Se("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(cn("featureIndex",s.featureIndexes)))}].concat(fn("langSys",r.langSysRecords,function(i,o){var a=i.langSys;return[{name:"langSysTag"+o,type:"TAG",value:i.tag},{name:"langSys"+o,type:"TABLE",value:new Se("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(cn("featureIndex",a.featureIndexes)))}]})))}]}))}nr.prototype=Object.create(Se.prototype);nr.prototype.constructor=nr;function rr(n){Se.call(this,"featureListTable",fn("featureRecord",n,function(e,t){var r=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Se("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(cn("lookupListIndex",r.lookupListIndexes)))}]}))}rr.prototype=Object.create(Se.prototype);rr.prototype.constructor=rr;function sr(n,e){Se.call(this,"lookupListTable",Jr("lookup",n,function(t){var r=e[t.lookupType];return N.assert(!!r,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new Se("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Jr("subtable",t.subtables,r)))}))}sr.prototype=Object.create(Se.prototype);sr.prototype.constructor=sr;var M={Table:Se,Record:Se,Coverage:tr,ScriptList:nr,FeatureList:rr,LookupList:sr,ushortList:cn,tableList:Jr,recordList:fn};function Pi(n,e){return n.getUint8(e)}function ir(n,e){return n.getUint16(e,!1)}function Fl(n,e){return n.getInt16(e,!1)}function as(n,e){return n.getUint32(e,!1)}function fo(n,e){var t=n.getInt16(e,!1),r=n.getUint16(e+2,!1);return t+r/65535}function Dl(n,e){for(var t="",r=e;r<e+4;r+=1)t+=String.fromCharCode(n.getInt8(r));return t}function Rl(n,e,t){for(var r=0,s=0;s<t;s+=1)r<<=8,r+=n.getUint8(e+s);return r}function Ul(n,e,t){for(var r=[],s=e;s<t;s+=1)r.push(n.getUint8(s));return r}function Nl(n){for(var e="",t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}var Bl={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function v(n,e){this.data=n,this.offset=e,this.relativeOffset=0}v.prototype.parseByte=function(){var n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};v.prototype.parseChar=function(){var n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};v.prototype.parseCard8=v.prototype.parseByte;v.prototype.parseUShort=function(){var n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};v.prototype.parseCard16=v.prototype.parseUShort;v.prototype.parseSID=v.prototype.parseUShort;v.prototype.parseOffset16=v.prototype.parseUShort;v.prototype.parseShort=function(){var n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};v.prototype.parseF2Dot14=function(){var n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n};v.prototype.parseULong=function(){var n=as(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};v.prototype.parseOffset32=v.prototype.parseULong;v.prototype.parseFixed=function(){var n=fo(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};v.prototype.parseString=function(n){var e=this.data,t=this.offset+this.relativeOffset,r="";this.relativeOffset+=n;for(var s=0;s<n;s++)r+=String.fromCharCode(e.getUint8(t+s));return r};v.prototype.parseTag=function(){return this.parseString(4)};v.prototype.parseLongDateTime=function(){var n=as(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n};v.prototype.parseVersion=function(n){var e=ir(this.data,this.offset+this.relativeOffset),t=ir(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10};v.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=Bl[n]*e};v.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getUint32(r),r+=4;return this.relativeOffset+=n*4,e};v.prototype.parseOffset16List=v.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getUint16(r),r+=2;return this.relativeOffset+=n*2,e};v.prototype.parseShortList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getInt16(r),r+=2;return this.relativeOffset+=n*2,e};v.prototype.parseByteList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getUint8(r++);return this.relativeOffset+=n,e};v.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t};v.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t};v.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=Object.keys(e),s=0;s<n;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}t[s]=i}return t};v.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=Object.keys(e),s=0;s<n;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}t[s]=i}return t};v.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);for(var e=Object.keys(n),t={},r=0;r<e.length;r++){var s=e[r],i=n[s];t[s]=i.call(this)}return t};v.prototype.parseValueRecord=function(n){if(n===void 0&&(n=this.parseUShort()),n!==0){var e={};return n&1&&(e.xPlacement=this.parseShort()),n&2&&(e.yPlacement=this.parseShort()),n&4&&(e.xAdvance=this.parseShort()),n&8&&(e.yAdvance=this.parseShort()),n&16&&(e.xPlaDevice=void 0,this.parseShort()),n&32&&(e.yPlaDevice=void 0,this.parseShort()),n&64&&(e.xAdvDevice=void 0,this.parseShort()),n&128&&(e.yAdvDevice=void 0,this.parseShort()),e}};v.prototype.parseValueRecordList=function(){for(var n=this.parseUShort(),e=this.parseUShort(),t=new Array(e),r=0;r<e;r++)t[r]=this.parseValueRecord(n);return t};v.prototype.parsePointer=function(n){var e=this.parseOffset16();if(e>0)return new v(this.data,this.offset+e).parseStruct(n)};v.prototype.parsePointer32=function(n){var e=this.parseOffset32();if(e>0)return new v(this.data,this.offset+e).parseStruct(n)};v.prototype.parseListOfLists=function(n){for(var e=this.parseOffset16List(),t=e.length,r=this.relativeOffset,s=new Array(t),i=0;i<t;i++){var o=e[i];if(o===0){s[i]=void 0;continue}if(this.relativeOffset=o,n){for(var a=this.parseOffset16List(),l=new Array(a.length),u=0;u<a.length;u++)this.relativeOffset=o+a[u],l[u]=n.call(this);s[i]=l}else s[i]=this.parseUShortList()}return this.relativeOffset=r,s};v.prototype.parseCoverage=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){for(var r=new Array(t),s=0;s<t;s++)r[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")};v.prototype.parseClassDef=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(e===2)return{format:2,ranges:this.parseRecordList({start:v.uShort,end:v.uShort,classId:v.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")};v.list=function(n,e){return function(){return this.parseList(n,e)}};v.list32=function(n,e){return function(){return this.parseList32(n,e)}};v.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}};v.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}};v.pointer=function(n){return function(){return this.parsePointer(n)}};v.pointer32=function(n){return function(){return this.parsePointer32(n)}};v.tag=v.prototype.parseTag;v.byte=v.prototype.parseByte;v.uShort=v.offset16=v.prototype.parseUShort;v.uShortList=v.prototype.parseUShortList;v.uLong=v.offset32=v.prototype.parseULong;v.uLongList=v.prototype.parseULongList;v.struct=v.prototype.parseStruct;v.coverage=v.prototype.parseCoverage;v.classDef=v.prototype.parseClassDef;var Li={reserved:v.uShort,reqFeatureIndex:v.uShort,featureIndexes:v.uShortList};v.prototype.parseScriptList=function(){return this.parsePointer(v.recordList({tag:v.tag,script:v.pointer({defaultLangSys:v.pointer(Li),langSysRecords:v.recordList({tag:v.tag,langSys:v.pointer(Li)})})}))||[]};v.prototype.parseFeatureList=function(){return this.parsePointer(v.recordList({tag:v.tag,feature:v.pointer({featureParams:v.offset16,lookupListIndexes:v.uShortList})}))||[]};v.prototype.parseLookupList=function(n){return this.parsePointer(v.list(v.pointer(function(){var e=this.parseUShort();N.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),r=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(v.pointer(n[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]};v.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var n=this.parseUShort(),e=this.parseUShort();N.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:v.offset32,featureTableSubstitutionOffset:v.offset32});return t})||[]};var O={getByte:Pi,getCard8:Pi,getUShort:ir,getCard16:ir,getShort:Fl,getULong:as,getFixed:fo,getTag:Dl,getOffset:Rl,getBytes:Ul,bytesToString:Nl,Parser:v};function Gl(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();var t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(var r=0;r<t;r+=1)for(var s=e.parseULong(),i=e.parseULong(),o=e.parseULong(),a=s;a<=i;a+=1)n.glyphIndexMap[a]=o,o++}function $l(n,e,t,r,s){n.length=e.parseUShort(),n.language=e.parseUShort();var i;n.segCount=i=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};for(var o=new O.Parser(t,r+s+14),a=new O.Parser(t,r+s+16+i*2),l=new O.Parser(t,r+s+16+i*4),u=new O.Parser(t,r+s+16+i*6),c=r+s+16+i*8,h=0;h<i-1;h+=1)for(var f=void 0,p=o.parseUShort(),d=a.parseUShort(),g=l.parseShort(),y=u.parseUShort(),x=d;x<=p;x+=1)y!==0?(c=u.offset+u.relativeOffset-2,c+=y,c+=(x-d)*2,f=O.getUShort(t,c),f!==0&&(f=f+g&65535)):f=x+g&65535,n.glyphIndexMap[x]=f}function zl(n,e){var t={};t.version=O.getUShort(n,e),N.argument(t.version===0,"cmap table version should be 0."),t.numTables=O.getUShort(n,e+2);for(var r=-1,s=t.numTables-1;s>=0;s-=1){var i=O.getUShort(n,e+4+s*8),o=O.getUShort(n,e+4+s*8+2);if(i===3&&(o===0||o===1||o===10)||i===0&&(o===0||o===1||o===2||o===3||o===4)){r=O.getULong(n,e+4+s*8+4);break}}if(r===-1)throw new Error("No valid cmap sub-tables found.");var a=new O.Parser(n,e+r);if(t.format=a.parseUShort(),t.format===12)Gl(t,a);else if(t.format===4)$l(t,a,n,e,r);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function Hl(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Vl(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Xl(n){var e=!0,t;for(t=n.length-1;t>0;t-=1){var r=n.get(t);if(r.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var s=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||(s=s.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),s=s.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var i=new M.Table("cmap",s);for(i.segments=[],t=0;t<n.length;t+=1){for(var o=n.get(t),a=0;a<o.unicodes.length;a+=1)Hl(i,o.unicodes[a],t);i.segments=i.segments.sort(function(I,k){return I.start-k.start})}Vl(i);var l=i.segments.length,u=0,c=[],h=[],f=[],p=[],d=[],g=[];for(t=0;t<l;t+=1){var y=i.segments[t];y.end<=65535&&y.start<=65535?(c=c.concat({name:"end_"+t,type:"USHORT",value:y.end}),h=h.concat({name:"start_"+t,type:"USHORT",value:y.start}),f=f.concat({name:"idDelta_"+t,type:"SHORT",value:y.delta}),p=p.concat({name:"idRangeOffset_"+t,type:"USHORT",value:y.offset}),y.glyphId!==void 0&&(d=d.concat({name:"glyph_"+t,type:"USHORT",value:y.glyphId}))):u+=1,!e&&y.glyphIndex!==void 0&&(g=g.concat({name:"cmap12Start_"+t,type:"ULONG",value:y.start}),g=g.concat({name:"cmap12End_"+t,type:"ULONG",value:y.end}),g=g.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:y.glyphIndex}))}if(i.segCountX2=(l-u)*2,i.searchRange=Math.pow(2,Math.floor(Math.log(l-u)/Math.log(2)))*2,i.entrySelector=Math.log(i.searchRange/2)/Math.log(2),i.rangeShift=i.segCountX2-i.searchRange,i.fields=i.fields.concat(c),i.fields.push({name:"reservedPad",type:"USHORT",value:0}),i.fields=i.fields.concat(h),i.fields=i.fields.concat(f),i.fields=i.fields.concat(p),i.fields=i.fields.concat(d),i.cmap4Length=14+c.length*2+2+h.length*2+f.length*2+p.length*2+d.length*2,!e){var x=16+g.length*4;i.cmap12Offset=20+i.cmap4Length,i.fields=i.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:x},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:g.length/3}]),i.fields=i.fields.concat(g)}return i}var ho={parse:zl,make:Xl},Qn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],ql=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Wl=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Et=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function po(n){this.font=n}po.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.font.glyphs;if(t){for(var r=0;r<t.length;r+=1)for(var s=t.get(r),i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return r}return null};function go(n){this.cmap=n}go.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function or(n,e){this.encoding=n,this.charset=e}or.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function ls(n){switch(n.version){case 1:this.names=Et.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(var e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<Et.length?this.names[e]=Et[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-Et.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(var t=0;t<n.numberOfGlyphs;t++)this.names[t]=Et[t+n.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}ls.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)};ls.prototype.glyphIndexToName=function(n){return this.names[n]};function _l(n){for(var e,t=n.tables.cmap.glyphIndexMap,r=Object.keys(t),s=0;s<r.length;s+=1){var i=r[s],o=t[i];e=n.glyphs.get(o),e.addUnicode(parseInt(i))}for(var a=0;a<n.glyphs.length;a+=1)e=n.glyphs.get(a),n.cffEncoding?n.isCIDFont?e.name="gid"+a:e.name=n.cffEncoding.charset[a]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(a))}function jl(n){n._IndexToUnicodeMap={};for(var e=n.tables.cmap.glyphIndexMap,t=Object.keys(e),r=0;r<t.length;r+=1){var s=t[r],i=e[s];n._IndexToUnicodeMap[i]===void 0?n._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:n._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function Zl(n,e){e.lowMemory?jl(n):_l(n)}function Yl(n,e,t,r,s){n.beginPath(),n.moveTo(e,t),n.lineTo(r,s),n.stroke()}var kt={line:Yl};function Kl(n,e){var t=e||new ye;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(r){t=r}}}function $e(n){this.bindConstructorValues(n)}$e.prototype.bindConstructorValues=function(n){this.index=n.index||0,this.name=n.name||null,this.unicode=n.unicode||void 0,this.unicodes=n.unicodes||n.unicode!==void 0?[n.unicode]:[],"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),Object.defineProperty(this,"path",Kl(this,n.path))};$e.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};$e.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};$e.prototype.getPath=function(n,e,t,r,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var i,o;r||(r={});var a=r.xScale,l=r.yScale;if(r.hinting&&s&&s.hinting&&(o=this.path&&s.hinting.exec(this,t)),o)i=s.hinting.getCommands(o),n=Math.round(n),e=Math.round(e),a=l=1;else{i=this.path.commands;var u=1/(this.path.unitsPerEm||1e3)*t;a===void 0&&(a=u),l===void 0&&(l=u)}for(var c=new ye,h=0;h<i.length;h+=1){var f=i[h];f.type==="M"?c.moveTo(n+f.x*a,e+-f.y*l):f.type==="L"?c.lineTo(n+f.x*a,e+-f.y*l):f.type==="Q"?c.quadraticCurveTo(n+f.x1*a,e+-f.y1*l,n+f.x*a,e+-f.y*l):f.type==="C"?c.curveTo(n+f.x1*a,e+-f.y1*l,n+f.x2*a,e+-f.y2*l,n+f.x*a,e+-f.y*l):f.type==="Z"&&c.closePath()}return c};$e.prototype.getContours=function(){if(this.points===void 0)return[];for(var n=[],e=[],t=0;t<this.points.length;t+=1){var r=this.points[t];e.push(r),r.lastPointOfContour&&(n.push(e),e=[])}return N.argument(e.length===0,"There are still points left in the current contour."),n};$e.prototype.getMetrics=function(){for(var n=this.path.commands,e=[],t=[],r=0;r<n.length;r+=1){var s=n[r];s.type!=="Z"&&(e.push(s.x),t.push(s.y)),(s.type==="Q"||s.type==="C")&&(e.push(s.x1),t.push(s.y1)),s.type==="C"&&(e.push(s.x2),t.push(s.y2))}var i={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,t),leftSideBearing:this.leftSideBearing};return isFinite(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i};$e.prototype.draw=function(n,e,t,r,s){this.getPath(e,t,r,s).draw(n)};$e.prototype.drawPoints=function(n,e,t,r){function s(h,f,p,d){n.beginPath();for(var g=0;g<h.length;g+=1)n.moveTo(f+h[g].x*d,p+h[g].y*d),n.arc(f+h[g].x*d,p+h[g].y*d,2,0,Math.PI*2,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24;for(var i=1/this.path.unitsPerEm*r,o=[],a=[],l=this.path,u=0;u<l.commands.length;u+=1){var c=l.commands[u];c.x!==void 0&&o.push({x:c.x,y:-c.y}),c.x1!==void 0&&a.push({x:c.x1,y:-c.y1}),c.x2!==void 0&&a.push({x:c.x2,y:-c.y2})}n.fillStyle="blue",s(o,e,t,i),n.fillStyle="red",s(a,e,t,i)};$e.prototype.drawMetrics=function(n,e,t,r){var s;e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24,s=1/this.path.unitsPerEm*r,n.lineWidth=1,n.strokeStyle="black",kt.line(n,e,-1e4,e,1e4),kt.line(n,-1e4,t,1e4,t);var i=this.xMin||0,o=this.yMin||0,a=this.xMax||0,l=this.yMax||0,u=this.advanceWidth||0;n.strokeStyle="blue",kt.line(n,e+i*s,-1e4,e+i*s,1e4),kt.line(n,e+a*s,-1e4,e+a*s,1e4),kt.line(n,-1e4,t+-o*s,1e4,t+-o*s),kt.line(n,-1e4,t+-l*s,1e4,t+-l*s),n.strokeStyle="green",kt.line(n,e+u*s,-1e4,e+u*s,1e4)};function Kn(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(r){n[t]=r},enumerable:!0,configurable:!0})}function us(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var r=e[t];r.path.unitsPerEm=n.unitsPerEm,this.glyphs[t]=r}this.length=e&&e.length||0}us.prototype.get=function(n){if(this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());var e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(var r=0;r<t.unicodes.length;r++)e.addUnicode(t.unicodes[r]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+n:e.name=this.font.cffEncoding.charset[n]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(n)),this.glyphs[n].advanceWidth=this.font._hmtxTableData[n].advanceWidth,this.glyphs[n].leftSideBearing=this.font._hmtxTableData[n].leftSideBearing}else typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());return this.glyphs[n]};us.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function Jl(n,e){return new $e({index:e,font:n})}function Ql(n,e,t,r,s,i){return function(){var o=new $e({index:e,font:n});return o.path=function(){t(o,r,s);var a=i(n.glyphs,o);return a.unitsPerEm=n.unitsPerEm,a},Kn(o,"xMin","_xMin"),Kn(o,"xMax","_xMax"),Kn(o,"yMin","_yMin"),Kn(o,"yMax","_yMax"),o}}function eu(n,e,t,r){return function(){var s=new $e({index:e,font:n});return s.path=function(){var i=t(n,s,r);return i.unitsPerEm=n.unitsPerEm,i},s}}var et={GlyphSet:us,glyphLoader:Jl,ttfGlyphLoader:Ql,cffGlyphLoader:eu};function mo(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;for(var t=0;t<n.length;t+=1)if(!mo(n[t],e[t]))return!1;return!0}else return!1}function Qr(n){var e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function ht(n,e,t){var r=[],s=[],i=O.getCard16(n,e),o,a;if(i!==0){var l=O.getByte(n,e+2);o=e+(i+1)*l+2;for(var u=e+3,c=0;c<i+1;c+=1)r.push(O.getOffset(n,u,l)),u+=l;a=o+r[i]}else a=e+2;for(var h=0;h<r.length-1;h+=1){var f=O.getBytes(n,o+r[h],o+r[h+1]);t&&(f=t(f)),s.push(f)}return{objects:s,startOffset:e,endOffset:a}}function tu(n,e){var t=[],r=O.getCard16(n,e),s,i;if(r!==0){var o=O.getByte(n,e+2);s=e+(r+1)*o+2;for(var a=e+3,l=0;l<r+1;l+=1)t.push(O.getOffset(n,a,o)),a+=o;i=s+t[r]}else i=e+2;return{offsets:t,startOffset:e,endOffset:i}}function nu(n,e,t,r,s){var i=O.getCard16(t,r),o=0;if(i!==0){var a=O.getByte(t,r+2);o=r+(i+1)*a+2}var l=O.getBytes(t,o+e[n],o+e[n+1]);return s&&(l=s(l)),l}function ru(n){for(var e="",t=15,r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var s=n.parseByte(),i=s>>4,o=s&15;if(i===t||(e+=r[i],o===t))break;e+=r[o]}return parseFloat(e)}function su(n,e){var t,r,s,i;if(e===28)return t=n.parseByte(),r=n.parseByte(),t<<8|r;if(e===29)return t=n.parseByte(),r=n.parseByte(),s=n.parseByte(),i=n.parseByte(),t<<24|r<<16|s<<8|i;if(e===30)return ru(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function iu(n){for(var e={},t=0;t<n.length;t+=1){var r=n[t][0],s=n[t][1],i=void 0;if(s.length===1?i=s[0]:i=s,e.hasOwnProperty(r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=i}return e}function vo(n,e,t){e=e!==void 0?e:0;var r=new O.Parser(n,e),s=[],i=[];for(t=t!==void 0?t:n.length;r.relativeOffset<t;){var o=r.parseByte();o<=21?(o===12&&(o=1200+r.parseByte()),s.push([o,i]),i=[]):i.push(su(r,o))}return iu(s)}function ln(n,e){return e<=390?e=Qn[e]:e=n[e-391],e}function xo(n,e,t){for(var r={},s,i=0;i<e.length;i+=1){var o=e[i];if(Array.isArray(o.type)){var a=[];a.length=o.type.length;for(var l=0;l<o.type.length;l++)s=n[o.op]!==void 0?n[o.op][l]:void 0,s===void 0&&(s=o.value!==void 0&&o.value[l]!==void 0?o.value[l]:null),o.type[l]==="SID"&&(s=ln(t,s)),a[l]=s;r[o.name]=a}else s=n[o.op],s===void 0&&(s=o.value!==void 0?o.value:null),o.type==="SID"&&(s=ln(t,s)),r[o.name]=s}return r}function ou(n,e){var t={};return t.formatMajor=O.getCard8(n,e),t.formatMinor=O.getCard8(n,e+1),t.size=O.getCard8(n,e+2),t.offsetSize=O.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}var yo=[{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"}],bo=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function au(n,e){var t=vo(n,0,n.byteLength);return xo(t,yo,e)}function So(n,e,t,r){var s=vo(n,e,t);return xo(s,bo,r)}function Ti(n,e,t,r){for(var s=[],i=0;i<t.length;i+=1){var o=new DataView(new Uint8Array(t[i]).buffer),a=au(o,r);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var l=a.private[0],u=a.private[1];if(l!==0&&u!==0){var c=So(n,u+e,l,r);if(a._defaultWidthX=c.defaultWidthX,a._nominalWidthX=c.nominalWidthX,c.subrs!==0){var h=u+c.subrs,f=ht(n,h+e);a._subrs=f.objects,a._subrsBias=Qr(a._subrs)}a._privateDict=c}s.push(a)}return s}function lu(n,e,t,r){var s,i,o=new O.Parser(n,e);t-=1;var a=[".notdef"],l=o.parseCard8();if(l===0)for(var u=0;u<t;u+=1)s=o.parseSID(),a.push(ln(r,s));else if(l===1)for(;a.length<=t;){s=o.parseSID(),i=o.parseCard8();for(var c=0;c<=i;c+=1)a.push(ln(r,s)),s+=1}else if(l===2)for(;a.length<=t;){s=o.parseSID(),i=o.parseCard16();for(var h=0;h<=i;h+=1)a.push(ln(r,s)),s+=1}else throw new Error("Unknown charset format "+l);return a}function uu(n,e,t){var r,s={},i=new O.Parser(n,e),o=i.parseCard8();if(o===0)for(var a=i.parseCard8(),l=0;l<a;l+=1)r=i.parseCard8(),s[r]=l;else if(o===1){var u=i.parseCard8();r=1;for(var c=0;c<u;c+=1)for(var h=i.parseCard8(),f=i.parseCard8(),p=h;p<=h+f;p+=1)s[p]=r,r+=1}else throw new Error("Unknown encoding format "+o);return new or(s,t)}function Ii(n,e,t){var r,s,i,o,a=new ye,l=[],u=0,c=!1,h=!1,f=0,p=0,d,g,y,x;if(n.isCIDFont){var I=n.tables.cff.topDict._fdSelect[e.index],k=n.tables.cff.topDict._fdArray[I];d=k._subrs,g=k._subrsBias,y=k._defaultWidthX,x=k._nominalWidthX}else d=n.tables.cff.topDict._subrs,g=n.tables.cff.topDict._subrsBias,y=n.tables.cff.topDict._defaultWidthX,x=n.tables.cff.topDict._nominalWidthX;var F=y;function L(T,H){h&&a.closePath(),a.moveTo(T,H),h=!0}function U(){var T;T=l.length%2!==0,T&&!c&&(F=l.shift()+x),u+=l.length>>1,l.length=0,c=!0}function P(T){for(var H,S,D,ce,ge,q,z,_,te,ee,ie,fe,J=0;J<T.length;){var E=T[J];switch(J+=1,E){case 1:U();break;case 3:U();break;case 4:l.length>1&&!c&&(F=l.shift()+x,c=!0),p+=l.pop(),L(f,p);break;case 5:for(;l.length>0;)f+=l.shift(),p+=l.shift(),a.lineTo(f,p);break;case 6:for(;l.length>0&&(f+=l.shift(),a.lineTo(f,p),l.length!==0);)p+=l.shift(),a.lineTo(f,p);break;case 7:for(;l.length>0&&(p+=l.shift(),a.lineTo(f,p),l.length!==0);)f+=l.shift(),a.lineTo(f,p);break;case 8:for(;l.length>0;)r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,f,p);break;case 10:ge=l.pop()+g,q=d[ge],q&&P(q);break;case 11:return;case 12:switch(E=T[J],J+=1,E){case 35:r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),z=i+l.shift(),_=o+l.shift(),te=z+l.shift(),ee=_+l.shift(),ie=te+l.shift(),fe=ee+l.shift(),f=ie+l.shift(),p=fe+l.shift(),l.shift(),a.curveTo(r,s,i,o,z,_),a.curveTo(te,ee,ie,fe,f,p);break;case 34:r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),z=i+l.shift(),_=o,te=z+l.shift(),ee=o,ie=te+l.shift(),fe=p,f=ie+l.shift(),a.curveTo(r,s,i,o,z,_),a.curveTo(te,ee,ie,fe,f,p);break;case 36:r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),z=i+l.shift(),_=o,te=z+l.shift(),ee=o,ie=te+l.shift(),fe=ee+l.shift(),f=ie+l.shift(),a.curveTo(r,s,i,o,z,_),a.curveTo(te,ee,ie,fe,f,p);break;case 37:r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),z=i+l.shift(),_=o+l.shift(),te=z+l.shift(),ee=_+l.shift(),ie=te+l.shift(),fe=ee+l.shift(),Math.abs(ie-f)>Math.abs(fe-p)?f=ie+l.shift():p=fe+l.shift(),a.curveTo(r,s,i,o,z,_),a.curveTo(te,ee,ie,fe,f,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+E),l.length=0}break;case 14:l.length>0&&!c&&(F=l.shift()+x,c=!0),h&&(a.closePath(),h=!1);break;case 18:U();break;case 19:case 20:U(),J+=u+7>>3;break;case 21:l.length>2&&!c&&(F=l.shift()+x,c=!0),p+=l.pop(),f+=l.pop(),L(f,p);break;case 22:l.length>1&&!c&&(F=l.shift()+x,c=!0),f+=l.pop(),L(f,p);break;case 23:U();break;case 24:for(;l.length>2;)r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,f,p);f+=l.shift(),p+=l.shift(),a.lineTo(f,p);break;case 25:for(;l.length>6;)f+=l.shift(),p+=l.shift(),a.lineTo(f,p);r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,f,p);break;case 26:for(l.length%2&&(f+=l.shift());l.length>0;)r=f,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i,p=o+l.shift(),a.curveTo(r,s,i,o,f,p);break;case 27:for(l.length%2&&(p+=l.shift());l.length>0;)r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o,a.curveTo(r,s,i,o,f,p);break;case 28:H=T[J],S=T[J+1],l.push((H<<24|S<<16)>>16),J+=2;break;case 29:ge=l.pop()+n.gsubrsBias,q=n.gsubrs[ge],q&&P(q);break;case 30:for(;l.length>0&&(r=f,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p),l.length!==0);)r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),f=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p);break;case 31:for(;l.length>0&&(r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),f=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p),l.length!==0);)r=f,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p);break;default:E<32?console.log("Glyph "+e.index+": unknown operator "+E):E<247?l.push(E-139):E<251?(H=T[J],J+=1,l.push((E-247)*256+H+108)):E<255?(H=T[J],J+=1,l.push(-(E-251)*256-H-108)):(H=T[J],S=T[J+1],D=T[J+2],ce=T[J+3],J+=4,l.push((H<<24|S<<16|D<<8|ce)/65536))}}}return P(t),e.advanceWidth=F,a}function cu(n,e,t,r){var s=[],i,o=new O.Parser(n,e),a=o.parseCard8();if(a===0)for(var l=0;l<t;l++){if(i=o.parseCard8(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");s.push(i)}else if(a===3){var u=o.parseCard16(),c=o.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var h,f=0;f<u;f++){if(i=o.parseCard8(),h=o.parseCard16(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");if(h>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+h);for(;c<h;c++)s.push(i);c=h}if(h!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+h)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return s}function fu(n,e,t,r){t.tables.cff={};var s=ou(n,e),i=ht(n,s.endOffset,O.bytesToString),o=ht(n,i.endOffset),a=ht(n,o.endOffset,O.bytesToString),l=ht(n,a.endOffset);t.gsubrs=l.objects,t.gsubrsBias=Qr(t.gsubrs);var u=Ti(n,e,o.objects,a.objects);if(u.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+u.length);var c=u[0];if(t.tables.cff.topDict=c,c._privateDict&&(t.defaultWidthX=c._privateDict.defaultWidthX,t.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){var h=c.fdArray,f=c.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;var p=ht(n,h),d=Ti(n,e,p.objects,a.objects);c._fdArray=d,f+=e,c._fdSelect=cu(n,f,t.numGlyphs,d.length)}var g=e+c.private[1],y=So(n,g,c.private[0],a.objects);if(t.defaultWidthX=y.defaultWidthX,t.nominalWidthX=y.nominalWidthX,y.subrs!==0){var x=g+y.subrs,I=ht(n,x);t.subrs=I.objects,t.subrsBias=Qr(t.subrs)}else t.subrs=[],t.subrsBias=0;var k;r.lowMemory?(k=tu(n,e+c.charStrings),t.nGlyphs=k.offsets.length):(k=ht(n,e+c.charStrings),t.nGlyphs=k.objects.length);var F=lu(n,e+c.charset,t.nGlyphs,a.objects);if(c.encoding===0?t.cffEncoding=new or(ql,F):c.encoding===1?t.cffEncoding=new or(Wl,F):t.cffEncoding=uu(n,e+c.encoding,F),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new et.GlyphSet(t),r.lowMemory)t._push=function(P){var T=nu(P,k.offsets,n,e+c.charStrings);t.glyphs.push(P,et.cffGlyphLoader(t,P,Ii,T))};else for(var L=0;L<t.nGlyphs;L+=1){var U=k.objects[L];t.glyphs.push(L,et.cffGlyphLoader(t,L,Ii,U))}}function wo(n,e){var t,r=Qn.indexOf(n);return r>=0&&(t=r),r=e.indexOf(n),r>=0?t=r+Qn.length:(t=Qn.length+e.length,e.push(n)),t}function hu(){return new M.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 pu(n){var e=new M.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var t=0;t<n.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:n[t]});return e}function ko(n,e,t){for(var r={},s=0;s<n.length;s+=1){var i=n[s],o=e[i.name];o!==void 0&&!mo(o,i.value)&&(i.type==="SID"&&(o=wo(o,t)),r[i.op]={name:i.name,type:i.type,value:o})}return r}function Ci(n,e){var t=new M.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=ko(yo,n,e),t}function Mi(n){var e=new M.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function du(n){var e=new M.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var t=0;t<n.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:n[t]});return e}function gu(){return new M.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function mu(n,e){for(var t=new M.Record("Charsets",[{name:"format",type:"Card8",value:0}]),r=0;r<n.length;r+=1){var s=n[r],i=wo(s,e);t.fields.push({name:"glyph_"+r,type:"SID",value:i})}return t}function vu(n){var e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});for(var r=0,s=0,i=0;i<t.commands.length;i+=1){var o=void 0,a=void 0,l=t.commands[i];if(l.type==="Q"){var u=.3333333333333333,c=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(u*r+c*l.x1),y1:Math.round(u*s+c*l.y1),x2:Math.round(u*l.x+c*l.x1),y2:Math.round(u*l.y+c*l.y1)}}if(l.type==="M")o=Math.round(l.x-r),a=Math.round(l.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rmoveto",type:"OP",value:21}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="L")o=Math.round(l.x-r),a=Math.round(l.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rlineto",type:"OP",value:5}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="C"){var h=Math.round(l.x1-r),f=Math.round(l.y1-s),p=Math.round(l.x2-l.x1),d=Math.round(l.y2-l.y1);o=Math.round(l.x-l.x2),a=Math.round(l.y-l.y2),e.push({name:"dx1",type:"NUMBER",value:h}),e.push({name:"dy1",type:"NUMBER",value:f}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:d}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),r=Math.round(l.x),s=Math.round(l.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function xu(n){for(var e=new M.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<n.length;t+=1){var r=n.get(t),s=vu(r);e.charStrings.push({name:r.name,type:"CHARSTRING",value:s})}return e}function yu(n,e){var t=new M.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=ko(bo,n,e),t}function bu(n,e){for(var t=new M.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i={},o=[],a,l=1;l<n.length;l+=1)a=n.get(l),o.push(a.name);var u=[];t.header=hu(),t.nameIndex=pu([e.postScriptName]);var c=Ci(s,u);t.topDictIndex=Mi(c),t.globalSubrIndex=gu(),t.charsets=mu(o,u),t.charStringsIndex=xu(n),t.privateDict=yu(i,u),t.stringIndex=du(u);var h=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=h,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),c=Ci(s,u),t.topDictIndex=Mi(c),t}var Eo={parse:fu,make:bu};function Su(n,e){var t={},r=new O.Parser(n,e);return t.version=r.parseVersion(),t.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,t.checkSumAdjustment=r.parseULong(),t.magicNumber=r.parseULong(),N.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=r.parseUShort(),t.unitsPerEm=r.parseUShort(),t.created=r.parseLongDateTime(),t.modified=r.parseLongDateTime(),t.xMin=r.parseShort(),t.yMin=r.parseShort(),t.xMax=r.parseShort(),t.yMax=r.parseShort(),t.macStyle=r.parseUShort(),t.lowestRecPPEM=r.parseUShort(),t.fontDirectionHint=r.parseShort(),t.indexToLocFormat=r.parseShort(),t.glyphDataFormat=r.parseShort(),t}function wu(n){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new M.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:t},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],n)}var Po={parse:Su,make:wu};function ku(n,e){var t={},r=new O.Parser(n,e);return t.version=r.parseVersion(),t.ascender=r.parseShort(),t.descender=r.parseShort(),t.lineGap=r.parseShort(),t.advanceWidthMax=r.parseUShort(),t.minLeftSideBearing=r.parseShort(),t.minRightSideBearing=r.parseShort(),t.xMaxExtent=r.parseShort(),t.caretSlopeRise=r.parseShort(),t.caretSlopeRun=r.parseShort(),t.caretOffset=r.parseShort(),r.relativeOffset+=8,t.metricDataFormat=r.parseShort(),t.numberOfHMetrics=r.parseUShort(),t}function Eu(n){return new M.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],n)}var Lo={parse:ku,make:Eu};function Pu(n,e,t,r,s){for(var i,o,a=new O.Parser(n,e),l=0;l<r;l+=1){l<t&&(i=a.parseUShort(),o=a.parseShort());var u=s.get(l);u.advanceWidth=i,u.leftSideBearing=o}}function Lu(n,e,t,r,s){n._hmtxTableData={};for(var i,o,a=new O.Parser(e,t),l=0;l<s;l+=1)l<r&&(i=a.parseUShort(),o=a.parseShort()),n._hmtxTableData[l]={advanceWidth:i,leftSideBearing:o}}function Tu(n,e,t,r,s,i,o){o.lowMemory?Lu(n,e,t,r,s):Pu(e,t,r,s,i)}function Iu(n){for(var e=new M.Table("hmtx",[]),t=0;t<n.length;t+=1){var r=n.get(t),s=r.advanceWidth||0,i=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:i})}return e}var To={parse:Tu,make:Iu};function Cu(n){for(var e=new M.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]),t="",r=12+n.length*4,s=0;s<n.length;++s){var i=t.indexOf(n[s]);i<0&&(i=t.length,t+=n[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:r+i}),e.fields.push({name:"length "+s,type:"USHORT",value:n[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function Mu(n,e){var t=new O.Parser(n,e),r=t.parseULong();N.argument(r===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var s=t.parseULong(),i=[],o=0;o<s;o++){for(var a="",l=e+t.parseUShort(),u=t.parseUShort(),c=l;c<l+u;++c)a+=String.fromCharCode(n.getInt8(c));i.push(a)}return i}var Io={make:Cu,parse:Mu};function Au(n,e){var t={},r=new O.Parser(n,e);return t.version=r.parseVersion(),t.numGlyphs=r.parseUShort(),t.version===1&&(t.maxPoints=r.parseUShort(),t.maxContours=r.parseUShort(),t.maxCompositePoints=r.parseUShort(),t.maxCompositeContours=r.parseUShort(),t.maxZones=r.parseUShort(),t.maxTwilightPoints=r.parseUShort(),t.maxStorage=r.parseUShort(),t.maxFunctionDefs=r.parseUShort(),t.maxInstructionDefs=r.parseUShort(),t.maxStackElements=r.parseUShort(),t.maxSizeOfInstructions=r.parseUShort(),t.maxComponentElements=r.parseUShort(),t.maxComponentDepth=r.parseUShort()),t}function Ou(n){return new M.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var Co={parse:Au,make:Ou},Mo=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Ao={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Fu={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Oo={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Du(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return Ao[e];case 3:return Oo[e]}}var es="utf-16",Ru={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Uu={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Fo(n,e,t){switch(n){case 0:return es;case 1:return Uu[t]||Ru[e];case 3:if(e===1||e===10)return es;break}}function Nu(n,e,t){for(var r={},s=new O.Parser(n,e),i=s.parseUShort(),o=s.parseUShort(),a=s.offset+s.parseUShort(),l=0;l<o;l++){var u=s.parseUShort(),c=s.parseUShort(),h=s.parseUShort(),f=s.parseUShort(),p=Mo[f]||f,d=s.parseUShort(),g=s.parseUShort(),y=Du(u,h,t),x=Fo(u,c,h);if(x!==void 0&&y!==void 0){var I=void 0;if(x===es?I=zt.UTF16(n,a+g,d):I=zt.MACSTRING(n,a+g,d,x),I){var k=r[p];k===void 0&&(k=r[p]={}),k[y]=I}}}var F=0;return i===1&&(F=s.parseUShort()),r}function zr(n){var e={};for(var t in n)e[n[t]]=parseInt(t);return e}function Ai(n,e,t,r,s,i){return new M.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function Bu(n,e){var t=n.length,r=e.length-t+1;e:for(var s=0;s<r;s++)for(;s<r;s++){for(var i=0;i<t;i++)if(e[s+i]!==n[i])continue e;return s}return-1}function Oi(n,e){var t=Bu(n,e);if(t<0){t=e.length;for(var r=0,s=n.length;r<s;++r)e.push(n[r])}return t}function Gu(n,e){var t,r=[],s={},i=zr(Mo);for(var o in n){var a=i[o];if(a===void 0&&(a=o),t=parseInt(a),isNaN(t))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');s[t]=n[o],r.push(t)}for(var l=zr(Ao),u=zr(Oo),c=[],h=[],f=0;f<r.length;f++){t=r[f];var p=s[t];for(var d in p){var g=p[d],y=1,x=l[d],I=Fu[x],k=Fo(y,I,x),F=C.MACSTRING(g,k);F===void 0&&(y=0,x=e.indexOf(d),x<0&&(x=e.length,e.push(d)),I=4,F=C.UTF16(g));var L=Oi(F,h);c.push(Ai(y,I,x,t,F.length,L));var U=u[d];if(U!==void 0){var P=C.UTF16(g),T=Oi(P,h);c.push(Ai(3,1,U,t,P.length,T))}}}c.sort(function(D,ce){return D.platformID-ce.platformID||D.encodingID-ce.encodingID||D.languageID-ce.languageID||D.nameID-ce.nameID});for(var H=new M.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+c.length*12}]),S=0;S<c.length;S++)H.fields.push({name:"record_"+S,type:"RECORD",value:c[S]});return H.fields.push({name:"strings",type:"LITERAL",value:h}),H}var Do={parse:Nu,make:Gu},ts=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function $u(n){for(var e=0;e<ts.length;e+=1){var t=ts[e];if(n>=t.begin&&n<t.end)return e}return-1}function zu(n,e){var t={},r=new O.Parser(n,e);t.version=r.parseUShort(),t.xAvgCharWidth=r.parseShort(),t.usWeightClass=r.parseUShort(),t.usWidthClass=r.parseUShort(),t.fsType=r.parseUShort(),t.ySubscriptXSize=r.parseShort(),t.ySubscriptYSize=r.parseShort(),t.ySubscriptXOffset=r.parseShort(),t.ySubscriptYOffset=r.parseShort(),t.ySuperscriptXSize=r.parseShort(),t.ySuperscriptYSize=r.parseShort(),t.ySuperscriptXOffset=r.parseShort(),t.ySuperscriptYOffset=r.parseShort(),t.yStrikeoutSize=r.parseShort(),t.yStrikeoutPosition=r.parseShort(),t.sFamilyClass=r.parseShort(),t.panose=[];for(var s=0;s<10;s++)t.panose[s]=r.parseByte();return t.ulUnicodeRange1=r.parseULong(),t.ulUnicodeRange2=r.parseULong(),t.ulUnicodeRange3=r.parseULong(),t.ulUnicodeRange4=r.parseULong(),t.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),t.fsSelection=r.parseUShort(),t.usFirstCharIndex=r.parseUShort(),t.usLastCharIndex=r.parseUShort(),t.sTypoAscender=r.parseShort(),t.sTypoDescender=r.parseShort(),t.sTypoLineGap=r.parseShort(),t.usWinAscent=r.parseUShort(),t.usWinDescent=r.parseUShort(),t.version>=1&&(t.ulCodePageRange1=r.parseULong(),t.ulCodePageRange2=r.parseULong()),t.version>=2&&(t.sxHeight=r.parseShort(),t.sCapHeight=r.parseShort(),t.usDefaultChar=r.parseUShort(),t.usBreakChar=r.parseUShort(),t.usMaxContent=r.parseUShort()),t}function Hu(n){return new M.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}],n)}var ns={parse:zu,make:Hu,unicodeRanges:ts,getUnicodeRange:$u};function Vu(n,e){var t={},r=new O.Parser(n,e);switch(t.version=r.parseVersion(),t.italicAngle=r.parseFixed(),t.underlinePosition=r.parseShort(),t.underlineThickness=r.parseShort(),t.isFixedPitch=r.parseULong(),t.minMemType42=r.parseULong(),t.maxMemType42=r.parseULong(),t.minMemType1=r.parseULong(),t.maxMemType1=r.parseULong(),t.version){case 1:t.names=Et.slice();break;case 2:t.numberOfGlyphs=r.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=r.parseUShort();t.names=[];for(var i=0;i<t.numberOfGlyphs;i++)if(t.glyphNameIndex[i]>=Et.length){var o=r.parseChar();t.names.push(r.parseString(o))}break;case 2.5:t.numberOfGlyphs=r.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.offset[a]=r.parseChar();break}return t}function Xu(){return new M.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}var Ro={parse:Vu,make:Xu},Xe=new Array(9);Xe[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(v.coverage),substitute:this.parseOffset16List()};N.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};Xe[2]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),sequences:this.parseListOfLists()}};Xe[3]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),alternateSets:this.parseListOfLists()}};Xe[4]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var $t={sequenceIndex:v.uShort,lookupListIndex:v.uShort};Xe[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(v.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,$t)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(v.coverage),classDef:this.parsePointer(v.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,$t)}})};if(t===3){var r=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(r,v.pointer(v.coverage)),lookupRecords:this.parseRecordList(s,$t)}}N.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};Xe[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(v.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList($t)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(v.coverage),backtrackClassDef:this.parsePointer(v.classDef),inputClassDef:this.parsePointer(v.classDef),lookaheadClassDef:this.parsePointer(v.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList($t)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(v.pointer(v.coverage)),inputCoverage:this.parseList(v.pointer(v.coverage)),lookaheadCoverage:this.parseList(v.pointer(v.coverage)),lookupRecords:this.parseRecordList($t)};N.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};Xe[7]=function(){var e=this.parseUShort();N.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),r=new v(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Xe[t].call(r)}};Xe[8]=function(){var e=this.parseUShort();return N.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(v.coverage),backtrackCoverage:this.parseList(v.pointer(v.coverage)),lookaheadCoverage:this.parseList(v.pointer(v.coverage)),substitutes:this.parseUShortList()}};function qu(n,e){e=e||0;var t=new v(n,e),r=t.parseVersion(1);return N.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Xe)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(Xe),variations:t.parseFeatureVariationsList()}}var Ht=new Array(9);Ht[1]=function(e){return e.substFormat===1?new M.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new M.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new M.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new M.Coverage(e.coverage)}].concat(M.ushortList("substitute",e.substitute)))};Ht[2]=function(e){return N.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new M.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new M.Coverage(e.coverage)}].concat(M.tableList("seqSet",e.sequences,function(t){return new M.Table("sequenceSetTable",M.ushortList("sequence",t))})))};Ht[3]=function(e){return N.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new M.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new M.Coverage(e.coverage)}].concat(M.tableList("altSet",e.alternateSets,function(t){return new M.Table("alternateSetTable",M.ushortList("alternate",t))})))};Ht[4]=function(e){return N.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new M.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new M.Coverage(e.coverage)}].concat(M.tableList("ligSet",e.ligatureSets,function(t){return new M.Table("ligatureSetTable",M.tableList("ligature",t,function(r){return new M.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:r.ligGlyph}].concat(M.ushortList("component",r.components,r.components.length+1)))}))})))};Ht[6]=function(e){if(e.substFormat===1){var t=new M.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new M.Coverage(e.coverage)}].concat(M.tableList("chainRuleSet",e.chainRuleSets,function(i){return new M.Table("chainRuleSetTable",M.tableList("chainRule",i,function(o){var a=M.ushortList("backtrackGlyph",o.backtrack,o.backtrack.length).concat(M.ushortList("inputGlyph",o.input,o.input.length+1)).concat(M.ushortList("lookaheadGlyph",o.lookahead,o.lookahead.length)).concat(M.ushortList("substitution",[],o.lookupRecords.length));return o.lookupRecords.forEach(function(l,u){a=a.concat({name:"sequenceIndex"+u,type:"USHORT",value:l.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:l.lookupListIndex})}),new M.Table("chainRuleTable",a)}))})));return t}else if(e.substFormat===2)N.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var r=[{name:"substFormat",type:"USHORT",value:e.substFormat}];r.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(i,o){r.push({name:"backtrackCoverage"+o,type:"TABLE",value:new M.Coverage(i)})}),r.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(i,o){r.push({name:"inputCoverage"+o,type:"TABLE",value:new M.Coverage(i)})}),r.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(i,o){r.push({name:"lookaheadCoverage"+o,type:"TABLE",value:new M.Coverage(i)})}),r.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(i,o){r=r.concat({name:"sequenceIndex"+o,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:i.lookupListIndex})});var s=new M.Table("chainContextTable",r);return s}N.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Wu(n){return new M.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new M.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new M.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new M.LookupList(n.lookups,Ht)}])}var Uo={parse:qu,make:Wu};function _u(n,e){var t=new O.Parser(n,e),r=t.parseULong();N.argument(r===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var s=t.parseULong(),i={},o=0;o<s;o++){var a=t.parseTag(),l=t.parseULong(),u=t.parseULong(),c=zt.UTF8(n,e+l,u);i[a]=c}return i}function ju(n){var e=Object.keys(n).length,t="",r=16+e*12,s=new M.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(var i in n){var o=t.length;t+=n[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:r+o}),s.fields.push({name:"length "+i,type:"ULONG",value:n[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}var No={parse:_u,make:ju};function Fi(n){return Math.log(n)/Math.log(2)|0}function cs(n){for(;n.length%4!==0;)n.push(0);for(var e=0,t=0;t<n.length;t+=4)e+=(n[t]<<24)+(n[t+1]<<16)+(n[t+2]<<8)+n[t+3];return e%=Math.pow(2,32),e}function Di(n,e,t,r){return new M.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function Bo(n){var e=new M.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=n,e.numTables=n.length;var t=Math.pow(2,Fi(e.numTables));e.searchRange=16*t,e.entrySelector=Fi(t),e.rangeShift=e.numTables*16-e.searchRange;for(var r=[],s=[],i=e.sizeOf()+Di().sizeOf()*e.numTables;i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0});for(var o=0;o<n.length;o+=1){var a=n[o];N.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var l=a.sizeOf(),u=Di(a.tableName,cs(a.encode()),i,l);for(r.push({name:u.tag+" Table Record",type:"RECORD",value:u}),s.push({name:a.tableName+" table",type:"RECORD",value:a}),i+=l,N.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(c,h){return c.value.tag>h.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(s),e}function Ri(n,e,t){for(var r=0;r<e.length;r+=1){var s=n.charToGlyphIndex(e[r]);if(s>0){var i=n.glyphs.get(s);return i.getMetrics()}}return t}function Zu(n){for(var e=0,t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function Yu(n){for(var e=[],t=[],r=[],s=[],i=[],o=[],a=[],l,u=0,c=0,h=0,f=0,p=0,d=0;d<n.glyphs.length;d+=1){var g=n.glyphs.get(d),y=g.unicode|0;if(isNaN(g.advanceWidth))throw new Error("Glyph "+g.name+" ("+d+"): advanceWidth is not a number.");(l>y||l===void 0)&&y>0&&(l=y),u<y&&(u=y);var x=ns.getUnicodeRange(y);if(x<32)c|=1<<x;else if(x<64)h|=1<<x-32;else if(x<96)f|=1<<x-64;else if(x<123)p|=1<<x-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(g.name!==".notdef"){var I=g.getMetrics();e.push(I.xMin),t.push(I.yMin),r.push(I.xMax),s.push(I.yMax),o.push(I.leftSideBearing),a.push(I.rightSideBearing),i.push(g.advanceWidth)}}var k={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:Zu(i),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};k.ascender=n.ascender,k.descender=n.descender;var F=Po.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:k.xMin,yMin:k.yMin,xMax:k.xMax,yMax:k.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),L=Lo.make({ascender:k.ascender,descender:k.descender,advanceWidthMax:k.advanceWidthMax,minLeftSideBearing:k.minLeftSideBearing,minRightSideBearing:k.minRightSideBearing,xMaxExtent:k.maxLeftSideBearing+(k.xMax-k.xMin),numberOfHMetrics:n.glyphs.length}),U=Co.make(n.glyphs.length),P=ns.make(Object.assign({xAvgCharWidth:Math.round(k.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:u,ulUnicodeRange1:c,ulUnicodeRange2:h,ulUnicodeRange3:f,ulUnicodeRange4:p,sTypoAscender:k.ascender,sTypoDescender:k.descender,sTypoLineGap:0,usWinAscent:k.yMax,usWinDescent:Math.abs(k.yMin),ulCodePageRange1:1,sxHeight:Ri(n,"xyvw",{yMax:Math.round(k.ascender/2)}).yMax,sCapHeight:Ri(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",k).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),T=To.make(n.glyphs),H=ho.make(n.glyphs),S=n.getEnglishName("fontFamily"),D=n.getEnglishName("fontSubfamily"),ce=S+" "+D,ge=n.getEnglishName("postScriptName");ge||(ge=S.replace(/\s/g,"")+"-"+D);var q={};for(var z in n.names)q[z]=n.names[z];q.uniqueID||(q.uniqueID={en:n.getEnglishName("manufacturer")+":"+ce}),q.postScriptName||(q.postScriptName={en:ge}),q.preferredFamily||(q.preferredFamily=n.names.fontFamily),q.preferredSubfamily||(q.preferredSubfamily=n.names.fontSubfamily);var _=[],te=Do.make(q,_),ee=_.length>0?Io.make(_):void 0,ie=Ro.make(),fe=Eo.make(n.glyphs,{version:n.getEnglishName("version"),fullName:ce,familyName:S,weightName:D,postScriptName:ge,unitsPerEm:n.unitsPerEm,fontBBox:[0,k.yMin,k.ascender,k.advanceWidthMax]}),J=n.metas&&Object.keys(n.metas).length>0?No.make(n.metas):void 0,E=[F,L,U,P,te,H,ie,fe,T];ee&&E.push(ee),n.tables.gsub&&E.push(Uo.make(n.tables.gsub)),J&&E.push(J);for(var B=Bo(E),j=B.encode(),oe=cs(j),se=B.fields,ae=!1,he=0;he<se.length;he+=1)if(se[he].name==="head table"){se[he].value.checkSumAdjustment=2981146554-oe,ae=!0;break}if(!ae)throw new Error("Could not find head table with checkSum to adjust.");return B}var Ku={make:Bo,fontToTable:Yu,computeCheckSum:cs};function Hr(n,e){for(var t=0,r=n.length-1;t<=r;){var s=t+r>>>1,i=n[s].tag;if(i===e)return s;i<e?t=s+1:r=s-1}return-t-1}function Ui(n,e){for(var t=0,r=n.length-1;t<=r;){var s=t+r>>>1,i=n[s];if(i===e)return s;i<e?t=s+1:r=s-1}return-t-1}function Ni(n,e){for(var t,r=0,s=n.length-1;r<=s;){var i=r+s>>>1;t=n[i];var o=t.start;if(o===e)return t;o<e?r=i+1:s=i-1}if(r>0)return t=n[r-1],e>t.end?0:t}function pn(n,e){this.font=n,this.tableName=e}pn.prototype={searchTag:Hr,binSearch:Ui,getTable:function(n){var e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var n=this.getTable();if(n){for(var e=!1,t=0;t<n.scripts.length;t++){var r=n.scripts[t].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(n,e){var t=this.getTable(e);if(t){n=n||"DFLT";var r=t.scripts,s=Hr(t.scripts,n);if(s>=0)return r[s].script;if(e){var i={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-s,0,i),i.script}}},getLangSysTable:function(n,e,t){var r=this.getScriptTable(n,t);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;var s=Hr(r.langSysRecords,e);if(s>=0)return r.langSysRecords[s].langSys;if(t){var i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(n,e,t,r){var s=this.getLangSysTable(n,e,r);if(s){for(var i,o=s.featureIndexes,a=this.font.tables[this.tableName].features,l=0;l<o.length;l++)if(i=a[o[l]],i.tag===t)return i.feature;if(r){var u=a.length;return N.assert(u===0||t>=a[u-1].tag,"Features must be added in alphabetical order."),i={tag:t,feature:{params:0,lookupListIndexes:[]}},a.push(i),o.push(u),i.feature}}},getLookupTables:function(n,e,t,r,s){var i=this.getFeatureTable(n,e,t,s),o=[];if(i){for(var a,l=i.lookupListIndexes,u=this.font.tables[this.tableName].lookups,c=0;c<l.length;c++)a=u[l[c]],a.lookupType===r&&o.push(a);if(o.length===0&&s){a={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};var h=u.length;return u.push(a),l.push(h),[a]}}return o},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:var t=Ni(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:var t=Ui(n.glyphs,e);return t>=0?t:-1;case 2:var r=Ni(n.ranges,e);return r?r.index+e-r.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;for(var e=[],t=n.ranges,r=0;r<t.length;r++)for(var s=t[r],i=s.start,o=s.end,a=i;a<=o;a++)e.push(a);return e}};function dn(n){pn.call(this,n,"gpos")}dn.prototype=pn.prototype;dn.prototype.init=function(){var n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)};dn.prototype.getKerningValue=function(n,e,t){for(var r=0;r<n.length;r++)for(var s=n[r].subtables,i=0;i<s.length;i++){var o=s[i],a=this.getCoverageIndex(o.coverage,e);if(!(a<0))switch(o.posFormat){case 1:for(var l=o.pairSets[a],u=0;u<l.length;u++){var c=l[u];if(c.secondGlyph===t)return c.value1&&c.value1.xAdvance||0}break;case 2:var h=this.getGlyphClass(o.classDef1,e),f=this.getGlyphClass(o.classDef2,t),p=o.classRecords[h][f];return p.value1&&p.value1.xAdvance||0}}return 0};dn.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function De(n){pn.call(this,n,"gsub")}function Ju(n,e){var t=n.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(n[r]!==e[r])return!1;return!0}function fs(n,e,t){for(var r=n.subtables,s=0;s<r.length;s++){var i=r[s];if(i.substFormat===e)return i}if(t)return r.push(t),t}De.prototype=pn.prototype;De.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};De.prototype.getSingle=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,1),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;if(l.substFormat===1){var h=l.deltaGlyphId;for(c=0;c<u.length;c++){var f=u[c];r.push({sub:f,by:f+h})}}else{var p=l.substitute;for(c=0;c<u.length;c++)r.push({sub:u[c],by:p[c]})}}return r};De.prototype.getMultiple=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,2),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;for(c=0;c<u.length;c++){var h=u[c],f=l.sequences[c];r.push({sub:h,by:f})}}return r};De.prototype.getAlternates=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,3),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.alternateSets,h=0;h<u.length;h++)r.push({sub:u[h],by:c[h]});return r};De.prototype.getLigatures=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,4),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.ligatureSets,h=0;h<u.length;h++)for(var f=u[h],p=c[h],d=0;d<p.length;d++){var g=p[d];r.push({sub:[f].concat(g.components),by:g.ligGlyph})}return r};De.prototype.addSingle=function(n,e,t,r){var s=this.getLookupTables(t,r,n,1,!0)[0],i=fs(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});N.assert(i.coverage.format===1,"Single: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.substitute.splice(a,0,0)),i.substitute[a]=e.by};De.prototype.addMultiple=function(n,e,t,r){N.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var s=this.getLookupTables(t,r,n,2,!0)[0],i=fs(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});N.assert(i.coverage.format===1,"Multiple: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.sequences.splice(a,0,0)),i.sequences[a]=e.by};De.prototype.addAlternate=function(n,e,t,r){var s=this.getLookupTables(t,r,n,3,!0)[0],i=fs(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});N.assert(i.coverage.format===1,"Alternate: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.alternateSets.splice(a,0,0)),i.alternateSets[a]=e.by};De.prototype.addLigature=function(n,e,t,r){var s=this.getLookupTables(t,r,n,4,!0)[0],i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),N.assert(i.coverage.format===1,"Ligature: unable to modify coverage table format "+i.coverage.format);var o=e.sub[0],a=e.sub.slice(1),l={ligGlyph:e.by,components:a},u=this.binSearch(i.coverage.glyphs,o);if(u>=0){for(var c=i.ligatureSets[u],h=0;h<c.length;h++)if(Ju(c[h].components,a))return;c.push(l)}else u=-1-u,i.coverage.glyphs.splice(u,0,o),i.ligatureSets.splice(u,0,[l])};De.prototype.getFeature=function(n,e,t){if(/ss\d\d/.test(n))return this.getSingle(n,e,t);switch(n){case"aalt":case"salt":return this.getSingle(n,e,t).concat(this.getAlternates(n,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(n,e,t);case"ccmp":return this.getMultiple(n,e,t).concat(this.getLigatures(n,e,t));case"stch":return this.getMultiple(n,e,t)}};De.prototype.add=function(n,e,t,r){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,r);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,r):this.addAlternate(n,e,t,r);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,r);case"ccmp":return e.by instanceof Array?this.addMultiple(n,e,t,r):this.addLigature(n,e,t,r)}};function Qu(){return typeof window<"u"}function ec(n){for(var e=new Buffer(n.byteLength),t=new Uint8Array(n),r=0;r<e.length;++r)e[r]=t[r];return e}function an(n,e){if(!n)throw e}function Bi(n,e,t,r,s){var i;return(e&r)>0?(i=n.parseByte(),(e&s)===0&&(i=-i),i=t+i):(e&s)>0?i=t:i=t+n.parseShort(),i}function Go(n,e,t){var r=new O.Parser(e,t);n.numberOfContours=r.parseShort(),n._xMin=r.parseShort(),n._yMin=r.parseShort(),n._xMax=r.parseShort(),n._yMax=r.parseShort();var s,i;if(n.numberOfContours>0){for(var o=n.endPointIndices=[],a=0;a<n.numberOfContours;a+=1)o.push(r.parseUShort());n.instructionLength=r.parseUShort(),n.instructions=[];for(var l=0;l<n.instructionLength;l+=1)n.instructions.push(r.parseByte());var u=o[o.length-1]+1;s=[];for(var c=0;c<u;c+=1)if(i=r.parseByte(),s.push(i),(i&8)>0)for(var h=r.parseByte(),f=0;f<h;f+=1)s.push(i),c+=1;if(N.argument(s.length===u,"Bad flags."),o.length>0){var p=[],d;if(u>0){for(var g=0;g<u;g+=1)i=s[g],d={},d.onCurve=!!(i&1),d.lastPointOfContour=o.indexOf(g)>=0,p.push(d);for(var y=0,x=0;x<u;x+=1)i=s[x],d=p[x],d.x=Bi(r,i,y,2,16),y=d.x;for(var I=0,k=0;k<u;k+=1)i=s[k],d=p[k],d.y=Bi(r,i,I,4,32),I=d.y}n.points=p}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];for(var F=!0;F;){s=r.parseUShort();var L={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(L.dx=r.parseShort(),L.dy=r.parseShort()):L.matchedPoints=[r.parseUShort(),r.parseUShort()]:(s&2)>0?(L.dx=r.parseChar(),L.dy=r.parseChar()):L.matchedPoints=[r.parseByte(),r.parseByte()],(s&8)>0?L.xScale=L.yScale=r.parseF2Dot14():(s&64)>0?(L.xScale=r.parseF2Dot14(),L.yScale=r.parseF2Dot14()):(s&128)>0&&(L.xScale=r.parseF2Dot14(),L.scale01=r.parseF2Dot14(),L.scale10=r.parseF2Dot14(),L.yScale=r.parseF2Dot14()),n.components.push(L),F=!!(s&32)}if(s&256){n.instructionLength=r.parseUShort(),n.instructions=[];for(var U=0;U<n.instructionLength;U+=1)n.instructions.push(r.parseByte())}}}function Vr(n,e){for(var t=[],r=0;r<n.length;r+=1){var s=n[r],i={x:e.xScale*s.x+e.scale01*s.y+e.dx,y:e.scale10*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(i)}return t}function tc(n){for(var e=[],t=[],r=0;r<n.length;r+=1){var s=n[r];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return N.argument(t.length===0,"There are still points left in the current contour."),e}function $o(n){var e=new ye;if(!n)return e;for(var t=tc(n),r=0;r<t.length;++r){var s=t[r],i=null,o=s[s.length-1],a=s[0];if(o.onCurve)e.moveTo(o.x,o.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{var l={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(l.x,l.y)}for(var u=0;u<s.length;++u)if(i=o,o=a,a=s[(u+1)%s.length],o.onCurve)e.lineTo(o.x,o.y);else{var c=i,h=a;i.onCurve||(c={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5}),a.onCurve||(h={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,h.x,h.y)}e.closePath()}return e}function zo(n,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var r=e.components[t],s=n.get(r.glyphIndex);if(s.getPath(),s.points){var i=void 0;if(r.matchedPoints===void 0)i=Vr(s.points,r);else{if(r.matchedPoints[0]>e.points.length-1||r.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[r.matchedPoints[0]],a=s.points[r.matchedPoints[1]],l={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};a=Vr([a],l)[0],l.dx=o.x-a.x,l.dy=o.y-a.y,i=Vr(s.points,l)}e.points=e.points.concat(i)}}return $o(e.points)}function nc(n,e,t,r){for(var s=new et.GlyphSet(r),i=0;i<t.length-1;i+=1){var o=t[i],a=t[i+1];o!==a?s.push(i,et.ttfGlyphLoader(r,i,Go,n,e+o,zo)):s.push(i,et.glyphLoader(r,i))}return s}function rc(n,e,t,r){var s=new et.GlyphSet(r);return r._push=function(i){var o=t[i],a=t[i+1];o!==a?s.push(i,et.ttfGlyphLoader(r,i,Go,n,e+o,zo)):s.push(i,et.glyphLoader(r,i))},s}function sc(n,e,t,r,s){return s.lowMemory?rc(n,e,t,r):nc(n,e,t,r)}var Ho={getPath:$o,parse:sc},Vo,Lt,Xo,rs;function qo(n){this.font=n,this.getCommands=function(e){return Ho.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function ic(n){return n}function Wo(n){return Math.sign(n)*Math.round(Math.abs(n))}function oc(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function ac(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function lc(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function uc(n){return Math.sign(n)*Math.floor(Math.abs(n))}var _o=function(n){var e=this.srPeriod,t=this.srPhase,r=this.srThreshold,s=1;return n<0&&(n=-n,s=-1),n+=r-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},Qe={x:1,y:0,axis:"x",distance:function(n,e,t,r){return(t?n.xo:n.x)-(r?e.xo:e.x)},interpolate:function(n,e,t,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=n.xo-e.xo,i=n.xo-t.xo,l=e.x-e.xo,u=t.x-t.xo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){n.x=n.xo+(l+u)/2;return}n.x=n.xo+(l*a+u*o)/c;return}if(s=r.distance(n,e,!0,!0),i=r.distance(n,t,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(t,t,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){Qe.setRelative(n,n,(l+u)/2,r,!0);return}Qe.setRelative(n,n,(l*a+u*o)/c,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,r,s){if(!r||r===this){n.x=(s?e.xo:e.x)+t;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*r.x,l=o+t*r.y;n.x=a+(n.y-l)/r.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},rt={x:0,y:1,axis:"y",distance:function(n,e,t,r){return(t?n.yo:n.y)-(r?e.yo:e.y)},interpolate:function(n,e,t,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=n.yo-e.yo,i=n.yo-t.yo,l=e.y-e.yo,u=t.y-t.yo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){n.y=n.yo+(l+u)/2;return}n.y=n.yo+(l*a+u*o)/c;return}if(s=r.distance(n,e,!0,!0),i=r.distance(n,t,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(t,t,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){rt.setRelative(n,n,(l+u)/2,r,!0);return}rt.setRelative(n,n,(l*a+u*o)/c,r,!0)},normalSlope:0,setRelative:function(n,e,t,r,s){if(!r||r===this){n.y=(s?e.yo:e.y)+t;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*r.x,l=o+t*r.y;n.y=l+r.normalSlope*(n.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(Qe);Object.freeze(rt);function gn(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}gn.prototype.distance=function(n,e,t,r){return this.x*Qe.distance(n,e,t,r)+this.y*rt.distance(n,e,t,r)};gn.prototype.interpolate=function(n,e,t,r){var s,i,o,a,l,u,c;if(o=r.distance(n,e,!0,!0),a=r.distance(n,t,!0,!0),s=r.distance(e,e,!1,!0),i=r.distance(t,t,!1,!0),l=Math.abs(o),u=Math.abs(a),c=l+u,c===0){this.setRelative(n,n,(s+i)/2,r,!0);return}this.setRelative(n,n,(s*u+i*l)/c,r,!0)};gn.prototype.setRelative=function(n,e,t,r,s){r=r||this;var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*r.x,l=o+t*r.y,u=r.normalSlope,c=this.slope,h=n.x,f=n.y;n.x=(c*h-u*a+l-f)/(c-u),n.y=c*(n.x-h)+f};gn.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function mn(n,e){var t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?Qe:n===0&&e===1?rt:new gn(n,e)}function st(n,e,t,r){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}st.prototype.nextTouched=function(n){for(var e=this.nextPointOnContour;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};st.prototype.prevTouched=function(n){for(var e=this.prevPointOnContour;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var hn=Object.freeze(new st(0,0)),cc={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function pt(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Qe,this.round=Wo}}qo.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var t=this.font,r=this._prepState;if(!r||r.ppem!==e){var s=this._fpgmState;if(!s){pt.prototype=cc,s=this._fpgmState=new pt("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,exports.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{Lt(s)}catch(u){console.log("Hinting error in FPGM:"+u),this._errorState=3;return}}pt.prototype=s,r=this._prepState=new pt("prep",t.tables.prep),r.ppem=e;var i=t.tables.cvt;if(i)for(var o=r.cvt=new Array(i.length),a=e/t.unitsPerEm,l=0;l<i.length;l++)o[l]=i[l]*a;else r.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),r.step=-1);try{Lt(r)}catch(u){this._errorState<2&&console.log("Hinting error in PREP:"+u),this._errorState=2}}if(!(this._errorState>1))try{return Xo(n,r)}catch(u){this._errorState<1&&(console.log("Hinting error:"+u),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};Xo=function(n,e){var t=e.ppem/e.font.unitsPerEm,r=t,s=n.components,i,o,a;if(pt.prototype=e,!s)a=new pt("glyf",n.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),rs(n,a,t,r),o=a.gZone;else{var l=e.font;o=[],i=[];for(var u=0;u<s.length;u++){var c=s[u],h=l.glyphs.get(c.glyphIndex);a=new pt("glyf",h.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+u+"---"),a.step=-1),rs(h,a,t,r);for(var f=Math.round(c.dx*t),p=Math.round(c.dy*r),d=a.gZone,g=a.contours,y=0;y<d.length;y++){var x=d[y];x.xTouched=x.yTouched=!1,x.xo=x.x=x.x+f,x.yo=x.y=x.y+p}var I=o.length;o.push.apply(o,d);for(var k=0;k<g.length;k++)i.push(g[k]+I)}n.instructions&&!a.inhibitGridFit&&(a=new pt("glyf",n.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=i,o.push(new st(0,0),new st(Math.round(n.advanceWidth*t),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),Lt(a),o.length-=2)}return o};rs=function(n,e,t,r){for(var s=n.points||[],i=s.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],l,u=0;u<i;u++)l=s[u],o[u]=new st(l.x*t,l.y*r,l.lastPointOfContour,l.onCurve);for(var c,h,f=0;f<i;f++)l=o[f],c||(c=l,a.push(f)),l.lastPointOfContour?(l.nextPointOnContour=c,c.prevPointOnContour=l,c=void 0):(h=o[f+1],l.nextPointOnContour=h,h.prevPointOnContour=l);if(!e.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<i;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new st(0,0),new st(Math.round(n.advanceWidth*t),0)),Lt(e),o.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var d=0;d<i;d++)console.log(d,o[d].x,o[d].y)}}};Lt=function(n){var e=n.prog;if(e){var t=e.length,r;for(n.ip=0;n.ip<t;n.ip++){if(exports.DEBUG&&n.step++,r=Vo[e[n.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));r(n)}}};function ar(n){for(var e=n.tZone=new Array(n.gZone.length),t=0;t<e.length;t++)e[t]=new st(0,0)}function jo(n,e){var t=n.prog,r=n.ip,s=1,i;do if(i=t[++r],i===88)s++;else if(i===89)s--;else if(i===64)r+=t[r+1]+1;else if(i===65)r+=2*t[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);n.ip=r}function Gi(n,e){exports.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function $i(n,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function zi(n,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function Hi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SPVTL["+n+"]",r,s);var a,l;n?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.pv=e.dpv=mn(a,l)}function Vi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SFVTL["+n+"]",r,s);var a,l;n?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.fv=mn(a,l)}function fc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.pv=n.dpv=mn(r,t)}function hc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.fv=mn(r,t)}function pc(n){var e=n.stack,t=n.pv;exports.DEBUG&&console.log(n.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function dc(n){var e=n.stack,t=n.fv;exports.DEBUG&&console.log(n.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function gc(n){n.fv=n.pv,exports.DEBUG&&console.log(n.step,"SFVTPV[]")}function mc(n){var e=n.stack,t=e.pop(),r=e.pop(),s=e.pop(),i=e.pop(),o=e.pop(),a=n.z0,l=n.z1,u=a[t],c=a[r],h=l[s],f=l[i],p=n.z2[o];exports.DEBUG&&console.log("ISECT[], ",t,r,s,i,o);var d=u.x,g=u.y,y=c.x,x=c.y,I=h.x,k=h.y,F=f.x,L=f.y,U=(d-y)*(k-L)-(g-x)*(I-F),P=d*x-g*y,T=I*L-k*F;p.x=(P*(I-F)-T*(d-y))/U,p.y=(P*(k-L)-T*(g-x))/U}function vc(n){n.rp0=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function xc(n){n.rp1=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function yc(n){n.rp2=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function bc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||ar(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Sc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||ar(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function wc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||ar(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function kc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZPS[]",e),n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||ar(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ec(n){n.loop=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function Pc(n){exports.DEBUG&&console.log(n.step,"RTG[]"),n.round=Wo}function Lc(n){exports.DEBUG&&console.log(n.step,"RTHG[]"),n.round=ac}function Tc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function Ic(n){exports.DEBUG&&console.log(n.step,"ELSE[]"),jo(n,!1)}function Cc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function Mc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function Ac(n){var e=n.stack;exports.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function Xr(n){exports.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function Oc(n){exports.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function Fc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(r)}function Dc(n){var e=n.stack;exports.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function Rc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"LOOPCALL[]",t,r);var s=n.ip,i=n.prog;n.prog=n.funcs[t];for(var o=0;o<r;o++)Lt(n),exports.DEBUG&&console.log(++n.step,o+1<r?"next loopcall":"done loopcall",o);n.ip=s,n.prog=i}function Uc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"CALL[]",e);var t=n.ip,r=n.prog;n.prog=n.funcs[e],Lt(n),n.ip=t,n.prog=r,exports.DEBUG&&console.log(++n.step,"returning from",e)}function Nc(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function Bc(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function Gc(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");var e=n.stack,t=n.prog,r=n.ip,s=e.pop(),i=r;for(exports.DEBUG&&console.log(n.step,"FDEF[]",s);t[++r]!==45;);n.ip=r,n.funcs[s]=t.slice(i+1,r)}function Xi(n,e){var t=e.stack.pop(),r=e.z0[t],s=e.fv,i=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);var o=i.distance(r,hn);n&&(o=e.round(o)),s.setRelative(r,hn,o,i),s.touch(r),e.rp0=e.rp1=t}function qi(n,e){var t=e.z2,r=t.length-2,s,i,o;exports.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(var a=0;a<r;a++)s=t[a],!n.touched(s)&&(i=s.prevTouched(n),i!==s&&(o=s.nextTouched(n),i===o&&n.setRelative(s,s,n.distance(i,i,!1,!0),n,!0),n.interpolate(s,i,o,n)))}function Wi(n,e){for(var t=e.stack,r=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=e.loop,l=e.z2;a--;){var u=t.pop(),c=l[u],h=o.distance(s,s,!1,!0);i.setRelative(c,c,h,o),i.touch(c),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",u)}e.loop=1}function _i(n,e){var t=e.stack,r=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=t.pop(),l=e.z2[e.contours[a]],u=l;exports.DEBUG&&console.log(e.step,"SHC["+n+"]",a);var c=o.distance(s,s,!1,!0);do u!==s&&i.setRelative(u,u,c,o),u=u.nextPointOnContour;while(u!==l)}function ji(n,e){var t=e.stack,r=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=t.pop();exports.DEBUG&&console.log(e.step,"SHZ["+n+"]",a);var l;switch(a){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}for(var u,c=o.distance(s,s,!1,!0),h=l.length-2,f=0;f<h;f++)u=l[f],i.setRelative(u,u,c,o)}function $c(n){for(var e=n.stack,t=n.loop,r=n.fv,s=e.pop()/64,i=n.z2;t--;){var o=e.pop(),a=i[o];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",o,s),r.setRelative(a,a,s),r.touch(a)}n.loop=1}function zc(n){for(var e=n.stack,t=n.rp1,r=n.rp2,s=n.loop,i=n.z0[t],o=n.z1[r],a=n.fv,l=n.dpv,u=n.z2;s--;){var c=e.pop(),h=u[c];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"IP[]",c,t,"<->",r),a.interpolate(h,i,o,l),a.touch(h)}n.loop=1}function Zi(n,e){var t=e.stack,r=t.pop()/64,s=t.pop(),i=e.z1[s],o=e.z0[e.rp0],a=e.fv,l=e.pv;a.setRelative(i,o,r,l),a.touch(i),exports.DEBUG&&console.log(e.step,"MSIRP["+n+"]",r,s),e.rp1=e.rp0,e.rp2=s,n&&(e.rp0=s)}function Hc(n){for(var e=n.stack,t=n.rp0,r=n.z0[t],s=n.loop,i=n.fv,o=n.pv,a=n.z1;s--;){var l=e.pop(),u=a[l];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"ALIGNRP[]",l),i.setRelative(u,r,0,o),i.touch(u)}n.loop=1}function Vc(n){exports.DEBUG&&console.log(n.step,"RTDG[]"),n.round=oc}function Yi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z0[s],o=e.fv,a=e.pv,l=e.cvt[r];exports.DEBUG&&console.log(e.step,"MIAP["+n+"]",r,"(",l,")",s);var u=a.distance(i,hn);n&&(Math.abs(u-l)<e.cvCutIn&&(u=l),u=e.round(u)),o.setRelative(i,hn,u,a),e.zp0===0&&(i.xo=i.x,i.yo=i.y),o.touch(i),e.rp0=e.rp1=s}function Xc(n){var e=n.prog,t=n.ip,r=n.stack,s=e[++t];exports.DEBUG&&console.log(n.step,"NPUSHB[]",s);for(var i=0;i<s;i++)r.push(e[++t]);n.ip=t}function qc(n){var e=n.ip,t=n.prog,r=n.stack,s=t[++e];exports.DEBUG&&console.log(n.step,"NPUSHW[]",s);for(var i=0;i<s;i++){var o=t[++e]<<8|t[++e];o&32768&&(o=-((o^65535)+1)),r.push(o)}n.ip=e}function Wc(n){var e=n.stack,t=n.store;t||(t=n.store=[]);var r=e.pop(),s=e.pop();exports.DEBUG&&console.log(n.step,"WS",r,s),t[s]=r}function _c(n){var e=n.stack,t=n.store,r=e.pop();exports.DEBUG&&console.log(n.step,"RS",r);var s=t&&t[r]||0;e.push(s)}function jc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"WCVTP",t,r),n.cvt[r]=t/64}function Zc(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function Ki(n,e){var t=e.stack,r=t.pop(),s=e.z2[r];exports.DEBUG&&console.log(e.step,"GC["+n+"]",r),t.push(e.dpv.distance(s,hn,n,!1)*64)}function Ji(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z1[r],o=e.z0[s],a=e.dpv.distance(o,i,n,n);exports.DEBUG&&console.log(e.step,"MD["+n+"]",r,s,"->",a),e.stack.push(Math.round(a*64))}function Yc(n){exports.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function Kc(n){exports.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function Jc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"LT[]",t,r),e.push(r<t?1:0)}function Qc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"LTEQ[]",t,r),e.push(r<=t?1:0)}function ef(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"GT[]",t,r),e.push(r>t?1:0)}function tf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"GTEQ[]",t,r),e.push(r>=t?1:0)}function nf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"EQ[]",t,r),e.push(t===r?1:0)}function rf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"NEQ[]",t,r),e.push(t!==r?1:0)}function sf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function of(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function af(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"IF[]",e),e||(jo(n,!0),exports.DEBUG&&console.log(n.step,"EIF[]"))}function lf(n){exports.DEBUG&&console.log(n.step,"EIF[]")}function uf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"AND[]",t,r),e.push(t&&r?1:0)}function cf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"OR[]",t,r),e.push(t||r?1:0)}function ff(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function qr(n,e){var t=e.stack,r=t.pop(),s=e.fv,i=e.pv,o=e.ppem,a=e.deltaBase+(n-1)*16,l=e.deltaShift,u=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+n+"]",r,t);for(var c=0;c<r;c++){var h=t.pop(),f=t.pop(),p=a+((f&240)>>4);if(p===o){var d=(f&15)-8;d>=0&&d++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",h,"by",d*l);var g=u[h];s.setRelative(g,g,d*l,i)}}}function hf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function pf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function df(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"ADD[]",t,r),e.push(r+t)}function gf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SUB[]",t,r),e.push(r-t)}function mf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"DIV[]",t,r),e.push(r*64/t)}function vf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"MUL[]",t,r),e.push(r*t/64)}function xf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function yf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function bf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function Sf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Jn(n,e){var t=e.stack,r=t.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(r/64)*64)}function wf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"WCVTF[]",t,r),n.cvt[r]=t*n.ppem/n.font.unitsPerEm}function Wr(n,e){var t=e.stack,r=t.pop(),s=e.ppem,i=e.deltaBase+(n-1)*16,o=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+n+"]",r,t);for(var a=0;a<r;a++){var l=t.pop(),u=t.pop(),c=i+((u&240)>>4);if(c===s){var h=(u&15)-8;h>=0&&h++;var f=h*o;exports.DEBUG&&console.log(e.step,"DELTACFIX",l,"by",f),e.cvt[l]+=f}}}function kf(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=_o;var t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Ef(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=_o;var t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Pf(n){exports.DEBUG&&console.log(n.step,"ROFF[]"),n.round=ic}function Lf(n){exports.DEBUG&&console.log(n.step,"RUTG[]"),n.round=lc}function Tf(n){exports.DEBUG&&console.log(n.step,"RDTG[]"),n.round=uc}function If(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function Qi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",r,s);var a,l;n?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.dpv=mn(a,l)}function Cf(n){var e=n.stack,t=e.pop(),r=0;exports.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(r=35),t&32&&(r|=4096),e.push(r)}function Mf(n){var e=n.stack,t=e.pop(),r=e.pop(),s=e.pop();exports.DEBUG&&console.log(n.step,"ROLL[]"),e.push(r),e.push(t),e.push(s)}function Af(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"MAX[]",t,r),e.push(Math.max(r,t))}function Of(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"MIN[]",t,r),e.push(Math.min(r,t))}function Ff(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function Df(n){var e=n.stack.pop(),t=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"INSTCTRL[]",e,t),e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function ct(n,e){var t=e.stack,r=e.prog,s=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(var i=0;i<n;i++)t.push(r[++s]);e.ip=s}function ft(n,e){var t=e.ip,r=e.prog,s=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(var i=0;i<n;i++){var o=r[++t]<<8|r[++t];o&32768&&(o=-((o^65535)+1)),s.push(o)}e.ip=t}function A(n,e,t,r,s,i){var o=i.stack,a=n&&o.pop(),l=o.pop(),u=i.rp0,c=i.z0[u],h=i.z1[l],f=i.minDis,p=i.fv,d=i.dpv,g,y,x,I;y=g=d.distance(h,c,!0,!0),x=y>=0?1:-1,y=Math.abs(y),n&&(I=i.cvt[a],r&&Math.abs(y-I)<i.cvCutIn&&(y=I)),t&&y<f&&(y=f),r&&(y=i.round(y)),p.setRelative(h,c,x*y,d),p.touch(h),exports.DEBUG&&console.log(i.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(r?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",n?a+"("+i.cvt[a]+","+I+")":"",l,"(d =",g,"->",x*y,")"),i.rp1=i.rp0,i.rp2=l,e&&(i.rp0=l)}Vo=[Gi.bind(void 0,rt),Gi.bind(void 0,Qe),$i.bind(void 0,rt),$i.bind(void 0,Qe),zi.bind(void 0,rt),zi.bind(void 0,Qe),Hi.bind(void 0,0),Hi.bind(void 0,1),Vi.bind(void 0,0),Vi.bind(void 0,1),fc,hc,pc,dc,gc,mc,vc,xc,yc,bc,Sc,wc,kc,Ec,Pc,Lc,Tc,Ic,Cc,Mc,void 0,void 0,Ac,Xr,Oc,Fc,Dc,Nc,Bc,void 0,void 0,void 0,Rc,Uc,Gc,void 0,Xi.bind(void 0,0),Xi.bind(void 0,1),qi.bind(void 0,rt),qi.bind(void 0,Qe),Wi.bind(void 0,0),Wi.bind(void 0,1),_i.bind(void 0,0),_i.bind(void 0,1),ji.bind(void 0,0),ji.bind(void 0,1),$c,zc,Zi.bind(void 0,0),Zi.bind(void 0,1),Hc,Vc,Yi.bind(void 0,0),Yi.bind(void 0,1),Xc,qc,Wc,_c,jc,Zc,Ki.bind(void 0,0),Ki.bind(void 0,1),void 0,Ji.bind(void 0,0),Ji.bind(void 0,1),Yc,void 0,Kc,void 0,void 0,Jc,Qc,ef,tf,nf,rf,sf,of,af,lf,uf,cf,ff,qr.bind(void 0,1),hf,pf,df,gf,mf,vf,xf,yf,bf,Sf,Jn.bind(void 0,0),Jn.bind(void 0,1),Jn.bind(void 0,2),Jn.bind(void 0,3),void 0,void 0,void 0,void 0,wf,qr.bind(void 0,2),qr.bind(void 0,3),Wr.bind(void 0,1),Wr.bind(void 0,2),Wr.bind(void 0,3),kf,Ef,void 0,void 0,Pf,void 0,Lf,Tf,Xr,Xr,void 0,void 0,void 0,void 0,void 0,If,Qi.bind(void 0,0),Qi.bind(void 0,1),Cf,void 0,Mf,Af,Of,Ff,Df,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ct.bind(void 0,1),ct.bind(void 0,2),ct.bind(void 0,3),ct.bind(void 0,4),ct.bind(void 0,5),ct.bind(void 0,6),ct.bind(void 0,7),ct.bind(void 0,8),ft.bind(void 0,1),ft.bind(void 0,2),ft.bind(void 0,3),ft.bind(void 0,4),ft.bind(void 0,5),ft.bind(void 0,6),ft.bind(void 0,7),ft.bind(void 0,8),A.bind(void 0,0,0,0,0,0),A.bind(void 0,0,0,0,0,1),A.bind(void 0,0,0,0,0,2),A.bind(void 0,0,0,0,0,3),A.bind(void 0,0,0,0,1,0),A.bind(void 0,0,0,0,1,1),A.bind(void 0,0,0,0,1,2),A.bind(void 0,0,0,0,1,3),A.bind(void 0,0,0,1,0,0),A.bind(void 0,0,0,1,0,1),A.bind(void 0,0,0,1,0,2),A.bind(void 0,0,0,1,0,3),A.bind(void 0,0,0,1,1,0),A.bind(void 0,0,0,1,1,1),A.bind(void 0,0,0,1,1,2),A.bind(void 0,0,0,1,1,3),A.bind(void 0,0,1,0,0,0),A.bind(void 0,0,1,0,0,1),A.bind(void 0,0,1,0,0,2),A.bind(void 0,0,1,0,0,3),A.bind(void 0,0,1,0,1,0),A.bind(void 0,0,1,0,1,1),A.bind(void 0,0,1,0,1,2),A.bind(void 0,0,1,0,1,3),A.bind(void 0,0,1,1,0,0),A.bind(void 0,0,1,1,0,1),A.bind(void 0,0,1,1,0,2),A.bind(void 0,0,1,1,0,3),A.bind(void 0,0,1,1,1,0),A.bind(void 0,0,1,1,1,1),A.bind(void 0,0,1,1,1,2),A.bind(void 0,0,1,1,1,3),A.bind(void 0,1,0,0,0,0),A.bind(void 0,1,0,0,0,1),A.bind(void 0,1,0,0,0,2),A.bind(void 0,1,0,0,0,3),A.bind(void 0,1,0,0,1,0),A.bind(void 0,1,0,0,1,1),A.bind(void 0,1,0,0,1,2),A.bind(void 0,1,0,0,1,3),A.bind(void 0,1,0,1,0,0),A.bind(void 0,1,0,1,0,1),A.bind(void 0,1,0,1,0,2),A.bind(void 0,1,0,1,0,3),A.bind(void 0,1,0,1,1,0),A.bind(void 0,1,0,1,1,1),A.bind(void 0,1,0,1,1,2),A.bind(void 0,1,0,1,1,3),A.bind(void 0,1,1,0,0,0),A.bind(void 0,1,1,0,0,1),A.bind(void 0,1,1,0,0,2),A.bind(void 0,1,1,0,0,3),A.bind(void 0,1,1,0,1,0),A.bind(void 0,1,1,0,1,1),A.bind(void 0,1,1,0,1,2),A.bind(void 0,1,1,0,1,3),A.bind(void 0,1,1,1,0,0),A.bind(void 0,1,1,1,0,1),A.bind(void 0,1,1,1,0,2),A.bind(void 0,1,1,1,0,3),A.bind(void 0,1,1,1,1,0),A.bind(void 0,1,1,1,1,1),A.bind(void 0,1,1,1,1,2),A.bind(void 0,1,1,1,1,3)];function Vt(n){this.char=n,this.state={},this.activeState=null}function hs(n,e,t){this.contextName=t,this.startIndex=n,this.endOffset=e}function Rf(n,e,t){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function qe(n,e){this.context=n,this.index=e,this.length=n.length,this.current=n[e],this.backtrack=n.slice(0,e),this.lookahead=n.slice(e+1)}function lr(n){this.eventId=n,this.subscribers=[]}function Uf(n){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(s){Object.defineProperty(e.events,s,{value:new lr(s)})}),n&&t.forEach(function(s){var i=n[s];typeof i=="function"&&e.events[s].subscribe(i)});var r=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];r.forEach(function(s){e.events[s].subscribe(e.updateContextsRanges)})}function de(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Uf.call(this,n)}Vt.prototype.setState=function(n,e){return this.state[n]=e,this.activeState={key:n,value:this.state[n]},this.activeState};Vt.prototype.getState=function(n){return this.state[n]||null};de.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length};de.prototype.composeRUD=function(n){var e=this,t=!0,r=n.map(function(i){return e[i[0]].apply(e,i.slice(1).concat(t))}),s=function(i){return typeof i=="object"&&i.hasOwnProperty("FAIL")};if(r.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:r.filter(s)};this.dispatch("composeRUD",[r.filter(function(i){return!s(i)})])};de.prototype.replaceRange=function(n,e,t,r){e=e!==null?e:this.tokens.length;var s=t.every(function(o){return o instanceof Vt});if(!isNaN(n)&&this.inboundIndex(n)&&s){var i=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return r||this.dispatch("replaceToken",[n,e,t]),[i,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};de.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof Vt){var r=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};de.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;var r=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[r,n,e]),r};de.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){var t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};de.prototype.insertToken=function(n,e,t){var r=n.every(function(s){return s instanceof Vt});return r?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};de.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(r,s){var i=[r,s],o=e===null||e.apply(this,i)===!0,a=[r,s];if(o){var l=t.apply(this,a);r.setState(n,l)}}),this.registeredModifiers.push(n)};lr.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};lr.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};qe.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};qe.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};de.prototype.rangeToText=function(n){if(n instanceof hs)return this.getRangeTokens(n).map(function(e){return e.char}).join("")};de.prototype.getText=function(){return this.tokens.map(function(n){return n.char}).join("")};de.prototype.getContext=function(n){var e=this.registeredContexts[n];return e||null};de.prototype.on=function(n,e){var t=this.events[n];return t?t.subscribe(e):null};de.prototype.dispatch=function(n,e){var t=this,r=this.events[n];r instanceof lr&&r.subscribers.forEach(function(s){s.apply(t,e||[])})};de.prototype.registerContextChecker=function(n,e,t){if(this.getContext(n))return{FAIL:"context name '"+n+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};var r=new Rf(n,e,t);return this.registeredContexts[n]=r,this.contextCheckers.push(r),r};de.prototype.getRangeTokens=function(n){var e=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,e))};de.prototype.getContextRanges=function(n){var e=this.getContext(n);return e?e.ranges:{FAIL:"context checker '"+n+"' is not registered."}};de.prototype.resetContextsRanges=function(){var n=this.registeredContexts;for(var e in n)if(n.hasOwnProperty(e)){var t=n[e];t.ranges=[]}};de.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var n=this.tokens.map(function(r){return r.char}),e=0;e<n.length;e++){var t=new qe(n,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])};de.prototype.setEndOffset=function(n,e){var t=this.getContext(e).openRange.startIndex,r=new hs(t,n,e),s=this.getContext(e).ranges;return r.rangeId=e+"."+s.length,s.push(r),this.getContext(e).openRange=null,r};de.prototype.runContextCheck=function(n){var e=this,t=n.index;this.contextCheckers.forEach(function(r){var s=r.contextName,i=e.getContext(s).openRange;if(!i&&r.checkStart(n)&&(i=new hs(t,null,s),e.getContext(s).openRange=i,e.dispatch("contextStart",[s,t])),i&&r.checkEnd(n)){var o=t-i.startIndex+1,a=e.setEndOffset(o,s);e.dispatch("contextEnd",[s,a])}})};de.prototype.tokenize=function(n){this.tokens=[],this.resetContextsRanges();var e=Array.from(n);this.dispatch("start");for(var t=0;t<e.length;t++){var r=e[t],s=new qe(e,t);this.dispatch("next",[s]),this.runContextCheck(s);var i=new Vt(r);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};function dt(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function Zo(n){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(n)}function gt(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function er(n){return/[A-z]/.test(n)}function Nf(n){return/\s/.test(n)}function Re(n){this.font=n,this.features={}}function Pt(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function vn(n,e){if(!n)return-1;switch(e.format){case 1:return e.glyphs.indexOf(n);case 2:for(var t=e.ranges,r=0;r<t.length;r++){var s=t[r];if(n>=s.start&&n<=s.end){var i=n-s.start;return s.index+i}}break;default:return-1}return-1}function Bf(n,e){var t=vn(n,e.coverage);return t===-1?null:n+e.deltaGlyphId}function Gf(n,e){var t=vn(n,e.coverage);return t===-1?null:e.substitute[t]}function _r(n,e){for(var t=[],r=0;r<n.length;r++){var s=n[r],i=e.current;i=Array.isArray(i)?i[0]:i;var o=vn(i,s);o!==-1&&t.push(o)}return t.length!==n.length?-1:t}function $f(n,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(n.context.length<t)return[];var r=_r(e.inputCoverage,n);if(r===-1)return[];var s=e.inputCoverage.length-1;if(n.lookahead.length<e.lookaheadCoverage.length)return[];for(var i=n.lookahead.slice(s);i.length&&gt(i[0].char);)i.shift();var o=new qe(i,0),a=_r(e.lookaheadCoverage,o),l=[].concat(n.backtrack);for(l.reverse();l.length&&gt(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];var u=new qe(l,0),c=_r(e.backtrackCoverage,u),h=r.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&c.length===e.backtrackCoverage.length,f=[];if(h)for(var p=0;p<e.lookupRecords.length;p++)for(var d=e.lookupRecords[p],g=d.lookupListIndex,y=this.getLookupByIndex(g),x=0;x<y.subtables.length;x++){var I=y.subtables[x],k=this.getLookupMethod(y,I),F=this.getSubstitutionType(y,I);if(F==="12")for(var L=0;L<r.length;L++){var U=n.get(L),P=k(U);P&&f.push(P)}}return f}function zf(n,e){var t=n.current,r=vn(t,e.coverage);if(r===-1)return null;for(var s,i=e.ligatureSets[r],o=0;o<i.length;o++){s=i[o];for(var a=0;a<s.components.length;a++){var l=n.lookahead[a],u=s.components[a];if(l!==u)break;if(a===s.components.length-1)return s}}return null}function Hf(n,e){var t=vn(n,e.coverage);return t===-1?null:e.sequences[t]}Re.prototype.getDefaultScriptFeaturesIndexes=function(){for(var n=this.font.tables.gsub.scripts,e=0;e<n.length;e++){var t=n[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]};Re.prototype.getScriptFeaturesIndexes=function(n){var e=this.font.tables;if(!e.gsub)return[];if(!n)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,r=0;r<t.length;r++){var s=t[r];if(s.tag===n&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;var i=s.langSysRecords;if(i)for(var o=0;o<i.length;o++){var a=i[o];if(a.tag===n){var l=a.langSys;return l.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};Re.prototype.mapTagsToFeatures=function(n,e){for(var t={},r=0;r<n.length;r++){var s=n[r].tag,i=n[r].feature;t[s]=i}this.features[e].tags=t};Re.prototype.getScriptFeatures=function(n){var e=this.features[n];if(this.features.hasOwnProperty(n))return e;var t=this.getScriptFeaturesIndexes(n);if(!t)return null;var r=this.font.tables.gsub;return e=t.map(function(s){return r.features[s]}),this.features[n]=e,this.mapTagsToFeatures(e,n),e};Re.prototype.getSubstitutionType=function(n,e){var t=n.lookupType.toString(),r=e.substFormat.toString();return t+r};Re.prototype.getLookupMethod=function(n,e){var t=this,r=this.getSubstitutionType(n,e);switch(r){case"11":return function(s){return Bf.apply(t,[s,e])};case"12":return function(s){return Gf.apply(t,[s,e])};case"63":return function(s){return $f.apply(t,[s,e])};case"41":return function(s){return zf.apply(t,[s,e])};case"21":return function(s){return Hf.apply(t,[s,e])};default:throw new Error("lookupType: "+n.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};Re.prototype.lookupFeature=function(n){var e=n.contextParams,t=e.index,r=this.getFeature({tag:n.tag,script:n.script});if(!r)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+n.tag+"' for script '"+n.script+"'.");for(var s=this.getFeatureLookups(r),i=[].concat(e.context),o=0;o<s.length;o++)for(var a=s[o],l=this.getLookupSubtables(a),u=0;u<l.length;u++){var c=l[u],h=this.getSubstitutionType(a,c),f=this.getLookupMethod(a,c),p=void 0;switch(h){case"11":p=f(e.current),p&&i.splice(t,1,new Pt({id:11,tag:n.tag,substitution:p}));break;case"12":p=f(e.current),p&&i.splice(t,1,new Pt({id:12,tag:n.tag,substitution:p}));break;case"63":p=f(e),Array.isArray(p)&&p.length&&i.splice(t,1,new Pt({id:63,tag:n.tag,substitution:p}));break;case"41":p=f(e),p&&i.splice(t,1,new Pt({id:41,tag:n.tag,substitution:p}));break;case"21":p=f(e.current),p&&i.splice(t,1,new Pt({id:21,tag:n.tag,substitution:p}));break}e=new qe(i,t),!(Array.isArray(p)&&!p.length)&&(p=null)}return i.length?i:null};Re.prototype.supports=function(n){if(!n.script)return!1;this.getScriptFeatures(n.script);var e=this.features.hasOwnProperty(n.script);if(!n.tag)return e;var t=this.features[n.script].some(function(r){return r.tag===n.tag});return e&&t};Re.prototype.getLookupSubtables=function(n){return n.subtables||null};Re.prototype.getLookupByIndex=function(n){var e=this.font.tables.gsub.lookups;return e[n]||null};Re.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};Re.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function Vf(n){var e=n.current,t=n.get(-1);return t===null&&dt(e)||!dt(t)&&dt(e)}function Xf(n){var e=n.get(1);return e===null||!dt(e)}var qf={startCheck:Vf,endCheck:Xf};function Wf(n){var e=n.current,t=n.get(-1);return(dt(e)||gt(e))&&!dt(t)}function _f(n){var e=n.get(1);switch(!0){case e===null:return!0;case(!dt(e)&&!gt(e)):var t=Nf(e);if(!t)return!0;if(t){var r=!1;if(r=n.lookahead.some(function(s){return dt(s)||gt(s)}),!r)return!0}break;default:return!1}}var jf={startCheck:Wf,endCheck:_f};function Zf(n,e,t){e[t].setState(n.tag,n.substitution)}function Yf(n,e,t){e[t].setState(n.tag,n.substitution)}function Kf(n,e,t){n.substitution.forEach(function(r,s){var i=e[t+s];i.setState(n.tag,r)})}function Jf(n,e,t){var r=e[t];r.setState(n.tag,n.substitution.ligGlyph);for(var s=n.substitution.components.length,i=0;i<s;i++)r=e[t+i+1],r.setState("deleted",!0)}var eo={11:Zf,12:Yf,63:Kf,41:Jf};function ps(n,e,t){n instanceof Pt&&eo[n.id]&&eo[n.id](n,e,t)}function Qf(n){for(var e=[].concat(n.backtrack),t=e.length-1;t>=0;t--){var r=e[t],s=Zo(r),i=gt(r);if(!s&&!i)return!0;if(s)return!1}return!1}function eh(n){if(Zo(n.current))return!1;for(var e=0;e<n.lookahead.length;e++){var t=n.lookahead[e],r=gt(t);if(!r)return!0}return!1}function th(n){var e=this,t="arab",r=this.featuresTags[t],s=this.tokenizer.getRangeTokens(n);if(s.length!==1){var i=new qe(s.map(function(a){return a.getState("glyphIndex")}),0),o=new qe(s.map(function(a){return a.char}),0);s.forEach(function(a,l){if(!gt(a.char)){i.setCurrentIndex(l),o.setCurrentIndex(l);var u=0;Qf(o)&&(u|=1),eh(o)&&(u|=2);var c;switch(u){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(r.indexOf(c)!==-1){var h=e.query.lookupFeature({tag:c,script:t,contextParams:i});if(h instanceof Error)return console.info(h.message);h.forEach(function(f,p){f instanceof Pt&&(ps(f,s,p),i.context[p]=f.substitution)})}}})}}function to(n,e){var t=n.map(function(r){return r.activeState.value});return new qe(t,e||0)}function nh(n){var e=this,t="arab",r=this.tokenizer.getRangeTokens(n),s=to(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:t,contextParams:s});a.length&&(a.forEach(function(l){return ps(l,r,o)}),s=to(r))})}function rh(n){var e=n.current,t=n.get(-1);return t===null&&er(e)||!er(t)&&er(e)}function sh(n){var e=n.get(1);return e===null||!er(e)}var ih={startCheck:rh,endCheck:sh};function no(n,e){var t=n.map(function(r){return r.activeState.value});return new qe(t,e||0)}function oh(n){var e=this,t="latn",r=this.tokenizer.getRangeTokens(n),s=no(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:t,contextParams:s});a.length&&(a.forEach(function(l){return ps(l,r,o)}),s=no(r))})}function je(n){this.baseDir=n||"ltr",this.tokenizer=new de,this.featuresTags={}}je.prototype.setText=function(n){this.text=n};je.prototype.contextChecks={latinWordCheck:ih,arabicWordCheck:qf,arabicSentenceCheck:jf};function jr(n){var e=this.contextChecks[n+"Check"];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function ah(){return jr.call(this,"latinWord"),jr.call(this,"arabicWord"),jr.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function lh(){var n=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var r=n.tokenizer.getRangeTokens(t);n.tokenizer.replaceRange(t.startIndex,t.endOffset,r.reverse())})}je.prototype.registerFeatures=function(n,e){var t=this,r=e.filter(function(s){return t.query.supports({script:n,tag:s})});this.featuresTags.hasOwnProperty(n)?this.featuresTags[n]=this.featuresTags[n].concat(r):this.featuresTags[n]=r};je.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Re(n));for(var t=0;t<e.length;t++){var r=e[t];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}};je.prototype.registerModifier=function(n,e,t){this.tokenizer.registerModifier(n,e,t)};function ds(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function uh(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){ds.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(r){th.call(n,r)})}}function ch(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){ds.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(s){nh.call(n,s)})}}}function fh(){var n=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){ds.call(this);var r=this.tokenizer.getContextRanges("latinWord");r.forEach(function(s){oh.call(n,s)})}}}je.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)};je.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(uh.call(this),ch.call(this)),this.checkContextReady("latinWord")&&fh.call(this),this.checkContextReady("arabicSentence")&&lh.call(this)};je.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),ah.call(this),this.applyFeaturesToContexts())};je.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()};je.prototype.getTextGlyphs=function(n){this.processText(n);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var r=this.tokenizer.tokens[t];if(!r.state.deleted){var s=r.activeState.value;e.push(Array.isArray(s)?s[0]:s)}}return e};function re(n){n=n||{},n.tables=n.tables||{},n.empty||(an(n.familyName,"When creating a new Font object, familyName is required."),an(n.styleName,"When creating a new Font object, styleName is required."),an(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),an(n.ascender,"When creating a new Font object, ascender is required."),an(n.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={fontFamily:{en:n.familyName||" "},fontSubfamily:{en:n.styleName||" "},fullName:{en:n.fullName||n.familyName+" "+n.styleName},postScriptName:{en:n.postScriptName||(n.familyName+n.styleName).replace(/\s/g,"")},designer:{en:n.designer||" "},designerURL:{en:n.designerURL||" "},manufacturer:{en:n.manufacturer||" "},manufacturerURL:{en:n.manufacturerURL||" "},license:{en:n.license||" "},licenseURL:{en:n.licenseURL||" "},version:{en:n.version||"Version 0.1"},description:{en:n.description||" "},copyright:{en:n.copyright||" "},trademark:{en:n.trademark||" "}},this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,fsSelection:n.fsSelection||this.fsSelectionValues.REGULAR},n.tables.os2)})),this.supported=!0,this.glyphs=new et.GlyphSet(this,n.glyphs||[]),this.encoding=new po(this),this.position=new dn(this),this.substitution=new De(this),this.tables=this.tables||{},this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){if(this._hinting)return this._hinting;if(this.outlinesFormat==="truetype")return this._hinting=new qo(this)}})}re.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null};re.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};re.prototype.charToGlyph=function(n){var e=this.charToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};re.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(t){return n[t]})}:e})};re.prototype.stringToGlyphs=function(n,e){var t=this,r=new je,s=function(h){return t.charToGlyphIndex(h.char)};r.registerModifier("glyphIndex",null,s);var i=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;r.applyFeatures(this,i);for(var o=r.getTextGlyphs(n),a=o.length,l=new Array(a),u=this.glyphs.get(0),c=0;c<a;c+=1)l[c]=this.glyphs.get(o[c])||u;return l};re.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)};re.prototype.nameToGlyph=function(n){var e=this.nameToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};re.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""};re.prototype.getKerningValue=function(n,e){n=n.index||n,e=e.index||e;var t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,n,e):this.kerningPairs[n+","+e]||0};re.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};re.prototype.forEachGlyph=function(n,e,t,r,s,i){e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:72,s=Object.assign({},this.defaultRenderOptions,s);var o=1/this.unitsPerEm*r,a=this.stringToGlyphs(n,s),l;if(s.kerning){var u=s.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(u,s.language)}for(var c=0;c<a.length;c+=1){var h=a[c];if(i.call(this,h,e,t,r,s),h.advanceWidth&&(e+=h.advanceWidth*o),s.kerning&&c<a.length-1){var f=l?this.position.getKerningValue(l,h.index,a[c+1].index):this.getKerningValue(h,a[c+1]);e+=f*o}s.letterSpacing?e+=s.letterSpacing*r:s.tracking&&(e+=s.tracking/1e3*r)}return e};re.prototype.getPath=function(n,e,t,r,s){var i=new ye;return this.forEachGlyph(n,e,t,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.extend(c)}),i};re.prototype.getPaths=function(n,e,t,r,s){var i=[];return this.forEachGlyph(n,e,t,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.push(c)}),i};re.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})};re.prototype.draw=function(n,e,t,r,s,i){this.getPath(e,t,r,s,i).draw(n)};re.prototype.drawPoints=function(n,e,t,r,s,i){this.forEachGlyph(e,t,r,s,i,function(o,a,l,u){o.drawPoints(n,a,l,u)})};re.prototype.drawMetrics=function(n,e,t,r,s,i){this.forEachGlyph(e,t,r,s,i,function(o,a,l,u){o.drawMetrics(n,a,l,u)})};re.prototype.getEnglishName=function(n){var e=this.names[n];if(e)return e.en};re.prototype.validate=function(){var n=this;function e(r,s){}function t(r){var s=n.getEnglishName(r);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0};re.prototype.toTables=function(){return Ku.fontToTable(this)};re.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};re.prototype.toArrayBuffer=function(){for(var n=this.toTables(),e=n.encode(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),s=0;s<e.length;s++)r[s]=e[s];return t};re.prototype.download=function(n){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";var r=this.toArrayBuffer();if(Qu())if(window.URL=window.URL||window.webkitURL,window.URL){var s=new DataView(r),i=new Blob([s],{type:"font/opentype"}),o=document.createElement("a");o.href=window.URL.createObjectURL(i),o.download=n;var a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),o.dispatchEvent(a)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var l=xi(),u=ec(r);l.writeFileSync(n,u)}};re.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};re.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9};re.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Yo(n,e){var t=JSON.stringify(n),r=256;for(var s in e){var i=parseInt(s);if(!(!i||i<256)){if(JSON.stringify(e[s])===t)return i;r<=i&&(r=i+1)}}return e[r]=n,r}function hh(n,e,t){var r=Yo(e.name,t);return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:r}]}function ph(n,e,t){var r={},s=new O.Parser(n,e);return r.tag=s.parseTag(),r.minValue=s.parseFixed(),r.defaultValue=s.parseFixed(),r.maxValue=s.parseFixed(),s.skip("uShort",1),r.name=t[s.parseUShort()]||{},r}function dh(n,e,t,r){for(var s=Yo(e.name,r),i=[{name:"nameID_"+n,type:"USHORT",value:s},{name:"flags_"+n,type:"USHORT",value:0}],o=0;o<t.length;++o){var a=t[o].tag;i.push({name:"axis_"+n+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i}function gh(n,e,t,r){var s={},i=new O.Parser(n,e);s.name=r[i.parseUShort()]||{},i.skip("uShort",1),s.coordinates={};for(var o=0;o<t.length;++o)s.coordinates[t[o].tag]=i.parseFixed();return s}function mh(n,e){var t=new M.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(var r=0;r<n.axes.length;r++)t.fields=t.fields.concat(hh(r,n.axes[r],e));for(var s=0;s<n.instances.length;s++)t.fields=t.fields.concat(dh(s,n.instances[s],n.axes,e));return t}function vh(n,e,t){var r=new O.Parser(n,e),s=r.parseULong();N.argument(s===65536,"Unsupported fvar table version.");var i=r.parseOffset16();r.skip("uShort",1);for(var o=r.parseUShort(),a=r.parseUShort(),l=r.parseUShort(),u=r.parseUShort(),c=[],h=0;h<o;h++)c.push(ph(n,e+i+h*a,t));for(var f=[],p=e+i+o*a,d=0;d<l;d++)f.push(gh(n,p+d*u,c,t));return{axes:c,instances:f}}var xh={make:mh,parse:vh},yh=function(){return{coverage:this.parsePointer(v.coverage),attachPoints:this.parseList(v.pointer(v.uShortList))}},bh=function(){var n=this.parseUShort();if(N.argument(n===1||n===2||n===3,"Unsupported CaretValue table version."),n===1)return{coordinate:this.parseShort()};if(n===2)return{pointindex:this.parseShort()};if(n===3)return{coordinate:this.parseShort()}},Sh=function(){return this.parseList(v.pointer(bh))},wh=function(){return{coverage:this.parsePointer(v.coverage),ligGlyphs:this.parseList(v.pointer(Sh))}},kh=function(){return this.parseUShort(),this.parseList(v.pointer(v.coverage))};function Eh(n,e){e=e||0;var t=new v(n,e),r=t.parseVersion(1);N.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var s={version:r,classDef:t.parsePointer(v.classDef),attachList:t.parsePointer(yh),ligCaretList:t.parsePointer(wh),markAttachClassDef:t.parsePointer(v.classDef)};return r>=1.2&&(s.markGlyphSets=t.parsePointer(kh)),s}var Ph={parse:Eh},We=new Array(10);We[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(v.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(v.coverage),values:this.parseValueRecordList()};N.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};We[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();N.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var r=this.parsePointer(v.coverage),s=this.parseUShort(),i=this.parseUShort();if(t===1)return{posFormat:t,coverage:r,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(v.pointer(v.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(t===2){var o=this.parsePointer(v.classDef),a=this.parsePointer(v.classDef),l=this.parseUShort(),u=this.parseUShort();return{posFormat:t,coverage:r,valueFormat1:s,valueFormat2:i,classDef1:o,classDef2:a,class1Count:l,class2Count:u,classRecords:this.parseList(l,v.list(u,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}};We[3]=function(){return{error:"GPOS Lookup 3 not supported"}};We[4]=function(){return{error:"GPOS Lookup 4 not supported"}};We[5]=function(){return{error:"GPOS Lookup 5 not supported"}};We[6]=function(){return{error:"GPOS Lookup 6 not supported"}};We[7]=function(){return{error:"GPOS Lookup 7 not supported"}};We[8]=function(){return{error:"GPOS Lookup 8 not supported"}};We[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Lh(n,e){e=e||0;var t=new v(n,e),r=t.parseVersion(1);return N.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We),variations:t.parseFeatureVariationsList()}}var Th=new Array(10);function Ih(n){return new M.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new M.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new M.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new M.LookupList(n.lookups,Th)}])}var Ch={parse:Lh,make:Ih};function Mh(n){var e={};n.skip("uShort");var t=n.parseUShort();N.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);var r=n.parseUShort();n.skip("uShort",3);for(var s=0;s<r;s+=1){var i=n.parseUShort(),o=n.parseUShort(),a=n.parseShort();e[i+","+o]=a}return e}function Ah(n){var e={};n.skip("uShort");var t=n.parseULong();t>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");var r=n.parseUShort(),s=r&255;if(n.skip("uShort"),s===0){var i=n.parseUShort();n.skip("uShort",3);for(var o=0;o<i;o+=1){var a=n.parseUShort(),l=n.parseUShort(),u=n.parseShort();e[a+","+l]=u}}return e}function Oh(n,e){var t=new O.Parser(n,e),r=t.parseUShort();if(r===0)return Mh(t);if(r===1)return Ah(t);throw new Error("Unsupported kern table version ("+r+").")}var Fh={parse:Oh};function Dh(n,e,t,r){for(var s=new O.Parser(n,e),i=r?s.parseUShort:s.parseULong,o=[],a=0;a<t+1;a+=1){var l=i.call(s);r&&(l*=2),o.push(l)}return o}var Rh={parse:Dh};function ro(n,e){for(var t=[],r=12,s=0;s<e;s+=1){var i=O.getTag(n,r),o=O.getULong(n,r+4),a=O.getULong(n,r+8),l=O.getULong(n,r+12);t.push({tag:i,checksum:o,offset:a,length:l,compression:!1}),r+=16}return t}function Uh(n,e){for(var t=[],r=44,s=0;s<e;s+=1){var i=O.getTag(n,r),o=O.getULong(n,r+4),a=O.getULong(n,r+8),l=O.getULong(n,r+12),u=void 0;a<l?u="WOFF":u=!1,t.push({tag:i,offset:o,compression:u,compressedLength:a,length:l}),r+=20}return t}function ve(n,e){if(e.compression==="WOFF"){var t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(Il(t,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var s=new DataView(r.buffer,0);return{data:s,offset:0}}else return{data:n,offset:e.offset}}function Ko(n,e){e=e??{};var t,r,s=new re({empty:!0}),i=new DataView(n,0),o,a=[],l=O.getTag(i,0);if(l==="\0\0\0"||l==="true"||l==="typ1")s.outlinesFormat="truetype",o=O.getUShort(i,4),a=ro(i,o);else if(l==="OTTO")s.outlinesFormat="cff",o=O.getUShort(i,4),a=ro(i,o);else if(l==="wOFF"){var u=O.getTag(i,4);if(u==="\0\0\0")s.outlinesFormat="truetype";else if(u==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=O.getUShort(i,12),a=Uh(i,o)}else throw new Error("Unsupported OpenType signature "+l);for(var c,h,f,p,d,g,y,x,I,k,F,L,U=0;U<o;U+=1){var P=a[U],T=void 0;switch(P.tag){case"cmap":T=ve(i,P),s.tables.cmap=ho.parse(T.data,T.offset),s.encoding=new go(s.tables.cmap);break;case"cvt ":T=ve(i,P),L=new O.Parser(T.data,T.offset),s.tables.cvt=L.parseShortList(P.length/2);break;case"fvar":h=P;break;case"fpgm":T=ve(i,P),L=new O.Parser(T.data,T.offset),s.tables.fpgm=L.parseByteList(P.length);break;case"head":T=ve(i,P),s.tables.head=Po.parse(T.data,T.offset),s.unitsPerEm=s.tables.head.unitsPerEm,t=s.tables.head.indexToLocFormat;break;case"hhea":T=ve(i,P),s.tables.hhea=Lo.parse(T.data,T.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"hmtx":y=P;break;case"ltag":T=ve(i,P),r=Io.parse(T.data,T.offset);break;case"maxp":T=ve(i,P),s.tables.maxp=Co.parse(T.data,T.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":k=P;break;case"OS/2":T=ve(i,P),s.tables.os2=ns.parse(T.data,T.offset);break;case"post":T=ve(i,P),s.tables.post=Ro.parse(T.data,T.offset),s.glyphNames=new ls(s.tables.post);break;case"prep":T=ve(i,P),L=new O.Parser(T.data,T.offset),s.tables.prep=L.parseByteList(P.length);break;case"glyf":f=P;break;case"loca":I=P;break;case"CFF ":c=P;break;case"kern":x=P;break;case"GDEF":p=P;break;case"GPOS":d=P;break;case"GSUB":g=P;break;case"meta":F=P;break}}var H=ve(i,k);if(s.tables.name=Do.parse(H.data,H.offset,r),s.names=s.tables.name,f&&I){var S=t===0,D=ve(i,I),ce=Rh.parse(D.data,D.offset,s.numGlyphs,S),ge=ve(i,f);s.glyphs=Ho.parse(ge.data,ge.offset,ce,s,e)}else if(c){var q=ve(i,c);Eo.parse(q.data,q.offset,s,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var z=ve(i,y);if(To.parse(s,z.data,z.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),Zl(s,e),x){var _=ve(i,x);s.kerningPairs=Fh.parse(_.data,_.offset)}else s.kerningPairs={};if(p){var te=ve(i,p);s.tables.gdef=Ph.parse(te.data,te.offset)}if(d){var ee=ve(i,d);s.tables.gpos=Ch.parse(ee.data,ee.offset),s.position.init()}if(g){var ie=ve(i,g);s.tables.gsub=Uo.parse(ie.data,ie.offset)}if(h){var fe=ve(i,h);s.tables.fvar=xh.parse(fe.data,fe.offset,s.names)}if(F){var J=ve(i,F);s.tables.meta=No.parse(J.data,J.offset),s.metas=s.tables.meta}return s}var ur=class{constructor(e,t){this.sources=e;this.fallback=t;this.parsed=new Map;this.missing=new Set}names(){return Object.keys(this.sources)}get(e){let t=e||this.fallback||Object.keys(this.sources)[0];if(!t)throw this.missing.add(""),new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let r=this.parsed.get(t);if(r)return r;let s=Ft(this.sources,t);if(!s)throw this.missing.add(t),new Error(`Font "${t}" is not available.${this.names().length?` Available fonts: ${this.names().join(", ")}`:""}`);let i=s instanceof Uint8Array?s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength):s,o=Ko(i);return this.parsed.set(t,o),o}};function Nh(n,e,t){let r={kerning:!0};if(t.spacing===1)return{cmds:n.getPath(e,0,0,t.size,r).commands,advance:n.getAdvanceWidth(e,t.size,r)};let s=[],i=0,o=[...e];return o.forEach((a,l)=>{s.push(...n.getPath(a,i,0,t.size,r).commands),i+=n.getAdvanceWidth(a,t.size,r)*(l<o.length-1?t.spacing:1)}),{cmds:s,advance:i}}function Jo(n,e,t){let{cmds:r,advance:s}=Nh(n,e,t),i=r.map(a=>a.type==="Z"?a:a.type==="C"?{...a,y1:-a.y1,y2:-a.y2,y:-a.y}:a.type==="Q"?{...a,y1:-a.y1,y:-a.y}:{...a,y:-a.y}),o=_n(i,Math.max(.005,t.size/2e3));return{polys:[...o.closed,...o.open.filter(a=>a.length>=3)],advance:s}}function Qo(n,e,t){if(!e)return[];let r=n.get(t.font),{polys:s,advance:i}=Jo(r,e,t),o=be(s),a=Xn(o);if(!a)return[];let l=t.halign==="center"?-i/2:t.halign==="right"?-i:0,u=t.valign==="top"?-a[3]:t.valign==="center"?-(a[1]+a[3])/2:t.valign==="bottom"?-a[1]:0;return o.map(c=>c.map(([h,f])=>[h+l,f+u]))}function ea(n,e,t){let r=n.get(t.font),{polys:s,advance:i}=Jo(r,e,t),o=Xn(s)??[0,0,0,0];return{advance:i,bounds:[[o[0],o[1]],[o[2],o[3]]],ascent:r.ascender/r.unitsPerEm*t.size,descent:r.descender/r.unitsPerEm*t.size}}var ms=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],Bh={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4},Gh=100,Xt=4,ta=8,$h=n=>{let e=Gh,t=r=>{for(let s of r.values()){for(let i of s.regions)e+=i.length;for(let i of s.lines)e+=i.length}};t(n.layers);for(let r of n.parts)t(r.layers);return e},we=class{constructor(e,t){this.parent=e;this.caller=t;this.vars=new Map;this.fns=new Map;this.mods=new Map}get(e){let t=this,r=e.startsWith("$");for(;t;){if(t.vars.has(e))return{found:!0,value:t.vars.get(e)};t=r?t.caller??t.parent:t.parent}return{found:!1}}fn(e){for(let t=this;t;t=t.parent){let r=t.fns.get(e);if(r)return r}}mod(e){for(let t=this;t;t=t.parent){let r=t.mods.get(e);if(r)return r}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}names(e){let t=[];for(let r=this;r;r=r.parent)t.push(...r[e].keys());return t}},gs=n=>n?`.${n}`:"",zh=["echo","assert","text_width","text_metrics","finger_count"];function cr(n,e){let t="",r=Math.min(2,Math.floor(n.length/3))+.5;for(let s of new Set(e)){if(s===n)continue;let i=s.toLowerCase()===n.toLowerCase()?0:Hh(n,s);i<r&&([t,r]=[s,i])}return t?` Did you mean "${t}"?`:""}function Hh(n,e){if(Math.abs(n.length-e.length)>2)return 3;let t=Array.from({length:n.length+1},(r,s)=>[s,...Array(e.length).fill(0)]);for(let r=1;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=n.length;r++)for(let s=1;s<=e.length;s++)t[r][s]=Math.min(t[r-1][s]+1,t[r][s-1]+1,t[r-1][s-1]+(n[r-1]===e[s-1]?0:1)),r>1&&s>1&&n[r-1]===e[s-2]&&n[r-2]===e[s-1]&&(t[r][s]=Math.min(t[r][s],t[r-2][s-2]+1));return t[n.length][e.length]}var Vh=tt,fr=class{constructor(e={}){this.opts=e;this.steps=0;this.depth=0;this.pointCount=0;this.itemCount=0;this.copies=0;this.echoes=[];this.warnings=[];this.layers=new Map(ms.map(e=>[e.name,e]));this.loaded=new Map;this.using=[];this.including=[];this.maxSteps=e.maxSteps??5e6,this.limits={...Bh,...e.limits},this.builtins=this.makeBuiltins()}run(e){let t=new we,r={$fn:0,$fa:2,$fs:.2,$thickness:3,$kerf:0,$material:"material",$sheet:[600,400],$gap:3,$layout:"pack",PI:Math.PI};for(let[o,a]of Object.entries(r))t.vars.set(o,a);let s=new we(t);return{shape:this.block(e.body,s,!0),globals:s,layers:this.layers,echoes:this.echoes,warnings:this.warnings}}tick(e,t=1){if(!((this.steps+=t)<=this.maxSteps))throw new R(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,t){let r=this.loaded.get(e);if(r)return r;let s=Ft(Vh,e)??this.opts.resolve?.(e);if(typeof s!="string")throw new R(`Library <${e}> not found`,t);this.loaded.set(e,{body:[]});let{program:i}=it(s,e);return this.loaded.set(e,i),i}hoist(e,t){for(let r of e)if(r.kind==="module")t.mods.set(r.name,{params:r.params,body:r.body,env:t});else if(r.kind==="function")t.fns.set(r.name,{params:r.params,body:r.body,env:t});else if(r.kind==="use"&&!r.include){this.enter(this.using,r.path,r.pos,"use");try{let s=this.included(this.load(r.path,r.pos).body,new Set([r.path])),i=new we(t);this.hoist(s,i);for(let o of s)o.kind==="assign"&&this.assign(o.name,this.expr(o.value,i),i);for(let[o,a]of i.mods)t.mods.set(o,a);for(let[o,a]of i.fns)t.fns.set(o,a)}finally{this.using.pop()}}}enter(e,t,r,s){if(e.includes(t)){let i=[...e.slice(e.indexOf(t)),t].map(o=>`<${o}>`);throw new R(i.length===2?`Library ${i[0]} ${s}s itself`:`Libraries ${s} each other in a loop: ${i.join(" \u2192 ")}`,r)}e.push(t)}included(e,t){let r=[];for(let s of e)if(s.kind!=="use"||!s.include)r.push(s);else if(!t.has(s.path)){t.add(s.path);for(let i of this.included(this.load(s.path,s.pos).body,t))r.push(i)}return r}assign(e,t,r){r.vars.set(e,t)}block(e,t,r=!1){this.hoist(e,t);let s=[];for(let i of e){let o=this.stmt(i,t,r);o&&!ii(o)&&s.push(o)}return s.length===1?s[0]:sn(s)}stmt(e,t,r=!1){switch(this.tick(e.pos),e.kind){case"assign":{let s=this.opts.overrides,i=r&&s&&Object.prototype.hasOwnProperty.call(s,e.name)?s[e.name]:this.expr(e.value,t);return this.assign(e.name,i,t),null}case"module":case"function":return null;case"use":{if(!e.include)return null;this.enter(this.including,e.path,e.pos,"include");try{return this.block(this.load(e.path,e.pos).body,t)}finally{this.including.pop()}}case"block":return this.block(e.body,new we(t));case"if":return Fe(this.expr(e.cond,t))?this.block(e.then,new we(t)):this.block(e.else,new we(t));case"let":{let s=new we(t);return this.bindSeq(e.assigns,s),this.block(e.body,s)}case"for":{let s=[];return this.loop(e.assigns,t,i=>s.push(this.block(e.body,i))),sn(s)}case"call":if(e.modifier==="*")return null;{let s=this.callModule(e,t);return e.modifier==="#"||e.modifier==="%"?Vn(s,"guide"):s}}}bindSeq(e,t){for(let r of e)this.assign(r.name,this.expr(r.value,t),t)}iterable(e,t){if(ze(e))try{return Cn(e,this.limits.maxListLength)}catch(r){throw new R(r.message,t)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,t,r,s=0,i=new we(t)){if(s===e.length)return r(i);let o=e[s];for(let a of this.iterable(this.expr(o.value,i),o.pos)){this.tick(o.pos);let l=new we(i);l.vars.set(o.name,a),this.loop(e,t,r,s+1,l)}}evalArgs(e,t,r){let s=[],i=new Map,o=[];for(let a of e){let l=this.expr(a.value,t);a.name===null?s.push(l):i.set(a.name,l),o.push({name:a.name,value:l})}return{pos:s,named:i,all:o,at:r}}bindParams(e,t,r,s,i){let o=e.map(a=>a.name);e.forEach((a,l)=>{let u;t.named.has(a.name)?u=t.named.get(a.name):l<t.pos.length?u=t.pos[l]:u=a.default?this.expr(a.default,r):void 0,r.vars.set(a.name,u)});for(let a of t.named.keys())a.startsWith("$")?r.vars.set(a,t.named.get(a)):o.includes(a)||this.unknownArg(i,a,t.at,o);this.checkCount(i,e.length,t)}checkArgs(e,t){let r=At(e);if(!r)return;let s=r.params.map(i=>i.name);if(!r.anyNamed)for(let i of t.named.keys())!i.startsWith("$")&&!s.includes(i)&&this.unknownArg(`${e}()`,i,t.at,s);r.rest||this.checkCount(`${e}()`,r.params.filter(i=>!i.named).length,t)}checkCount(e,t,r){r.pos.length>t&&this.warn(`${e}: takes ${t===0?"no":`at most ${t}`} positional argument${t===1?"":"s"}, got ${r.pos.length}; the rest are ignored (${_t(r.at,!1)})`)}unknownArg(e,t,r,s){this.warn(`${e}: unknown argument "${t}"${gs(cr(t,s))} (${_t(r,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callModule(e,t){let r=this.evalArgs(e.args,t,e.pos),s=t.mod(e.name);if(s){if(++this.depth>1e3)throw new R(`Recursion too deep in module ${e.name}(): it calls itself without stopping`,e.pos);try{let h=new we(s.env,t);return this.bindParams(s.params,r,h,s.env,`${e.name}()`),h.children={stmts:e.children,env:t},h.vars.set("$children",this.childStmts(e.children).length),this.block(s.body,h)}catch(h){throw this.inCall(h,"module",e.name,e.pos)}finally{this.depth--}}let i=Ft(this.builtins,e.name);if(!i){let h=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":cr(e.name,[...t.names("mods"),...Object.keys(this.builtins)]);throw new R(`Unknown module ${e.name}().${h}`,e.pos)}this.checkArgs(e.name,r);let o=new we(t,t);for(let[h,f]of r.named)h.startsWith("$")&&o.vars.set(h,f);let a=this.childStmts(e.children),l=()=>new we(t,o),u={args:r,env:o,children:()=>e.children.length?this.block(e.children,l()):wt(),childList:()=>{let h=l();this.hoist(e.children,h);let f=[];for(let p of e.children){let d=this.stmt(p,h);a.includes(p)&&f.push(d??wt())}return f}},c;try{c=i(u)}catch(h){if(h instanceof R||h instanceof RangeError)throw h;let f=new R(`${e.name}(): ${h.message}`,e.pos);throw f.call=e.name,f}if(this.pointCount+=$h(c),this.pointCount>this.limits.maxPoints)throw new R(`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return c}childStmts(e){return e.filter(t=>t.kind!=="assign"&&t.kind!=="module"&&t.kind!=="function"&&t.kind!=="use")}callFunction(e,t,r,s){if(++this.depth>2e3)throw new R(`Recursion too deep in ${s}(): it calls itself without stopping`,t.at);try{this.tick(t.at);let i=ot(e)?e.scope:e.env,o=new we(i,r);return this.bindParams(e.params,t,o,i,`${s}()`),this.expr(e.body,o)}catch(i){throw this.inCall(i,"function",s,t.at)}finally{this.depth--}}inCall(e,t,r,s){return e instanceof Error&&!(e instanceof R)&&e.message.includes("call stack")?new R(`Recursion too deep in ${t==="module"?"module ":""}${r}(): it calls itself without stopping`,s):(e instanceof R&&e.addFrame(t,r,s),e)}expr(e,t){switch(e.kind){case"num":case"str":case"bool":return e.value;case"undef":return;case"var":{let r=t.get(e.name);if(r.found)return r.value;let s=t.fn(e.name);if(s)return{type:"function",params:s.params,body:s.body,scope:s.env,name:e.name};if(e.name.startsWith("$"))return;throw new R(`Unknown variable "${e.name}"${gs(cr(e.name,[...t.names("vars"),...t.names("fns")]))}`,e.pos)}case"list":{let r=[];for(let s of e.items)this.listItem(s,t,r,e.pos);return this.charge(Xt,e.pos),r}case"range":{let r=this.expr(e.start,t),s=this.expr(e.end,t),i=e.step?this.expr(e.step,t):1;if(typeof r!="number"||typeof s!="number"||typeof i!="number")throw new R("Range values must be numbers",e.pos);return{type:"range",start:r,step:i,end:s}}case"unary":{let r=this.expr(e.arg,t);return e.op==="!"?!Fe(r):e.op==="+"?r:this.arith("*",-1,r,e.pos)}case"binary":{if(e.op==="&&")return Fe(this.expr(e.left,t))&&Fe(this.expr(e.right,t));if(e.op==="||")return Fe(this.expr(e.left,t))||Fe(this.expr(e.right,t));let r=this.expr(e.left,t),s=this.expr(e.right,t);if(e.op==="=="||e.op==="!=")return Zt(r,s,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof r=="number"&&typeof s=="number"||typeof r=="string"&&typeof s=="string"))throw new R(`Can't compare ${Ne(r)} ${e.op} ${Ne(s)}`,e.pos);return e.op==="<"?r<s:e.op==="<="?r<=s:e.op===">"?r>s:r>=s}return this.arith(e.op,r,s,e.pos)}case"ternary":return Fe(this.expr(e.cond,t))?this.expr(e.then,t):this.expr(e.else,t);case"index":{let r=this.expr(e.target,t),s=this.expr(e.index,t);if(typeof s!="number")throw new R(`List index must be a number, got ${Ne(s)}`,e.pos);return Array.isArray(r)?r[Math.floor(s)]:typeof r=="string"?[...r][Math.floor(s)]:ze(r)?[r.start,r.step,r.end][Math.floor(s)]:void 0}case"member":{let r=this.expr(e.target,t),s={x:0,y:1,z:2}[e.name];return Array.isArray(r)&&s!==void 0?r[s]:ze(r)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?r.start:e.name==="step"?r.step:r.end:void 0}case"call":return this.call(e,t);case"lambda":return{type:"function",params:e.params,body:e.body,scope:t};case"let":{let r=new we(t);return this.bindSeq(e.assigns,r),this.expr(e.body,r)}}}listItem(e,t,r,s){switch(e.kind){case"item":{let i=this.expr(e.expr,t);this.grow(r,1,s),r.push(i);return}case"each":{let i=this.iterable(this.expr(e.expr,t),s);this.grow(r,i.length,s);for(let o of i)r.push(o);return}case"for":this.loop(e.assigns,t,i=>this.listItem(e.body,i,r,s));return;case"if":Fe(this.expr(e.cond,t))?this.listItem(e.then,t,r,s):e.else&&this.listItem(e.else,t,r,s);return;case"let":{let i=new we(t);this.bindSeq(e.assigns,i),this.listItem(e.body,i,r,s)}}}grow(e,t,r){if(e.length+t>this.limits.maxListLength)throw new R(`a list of ${e.length+t} items is more than the limit of ${this.limits.maxListLength}`,r);this.charge(t,r)}charge(e,t){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new R(`The lists and strings hold more than ${this.limits.maxListItems} items in all, the limit. Is a loop building more than it needs?`,t)}call(e,t){if(e.callee.kind==="var"){let s=e.callee.name,i=t.get(s);if(!i.found){let o=t.fn(s);if(o)return this.callFunction(o,this.evalArgs(e.args,t,e.pos),t,s);let a=this.specialFunction(s,e,t);if(a.handled)return a.value;let l=Ft(Pr,s);if(l){let u=this.evalArgs(e.args,t,e.pos);this.checkArgs(s,u);for(let p of Xs(l,u.pos,u.named))this.warn(`${s}(): "${p}" is given by position and by name; the named value is used (${_t(e.pos,!1)})`);let c={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:u.pos.length+l.params.filter(p=>u.named.has(p)).length},h=qs(l,u.pos,u.named);this.tick(e.pos,Ws(s,h,this.limits.maxListLength));let f;try{f=l.run(h,c)}catch(p){if(p instanceof R)throw p;let d=new R(p instanceof RangeError?`${s}(): the result is too large`:p.message,e.pos);throw d.call=s,d}return this.checkValue(f,e.pos,s),f}throw new R(`Unknown function ${s}()${gs(cr(s,[...t.names("fns"),...t.names("vars"),...Object.keys(Pr),...zh]))}`,e.pos)}if(!ot(i.value))throw new R(`"${s}" is a ${Ne(i.value)}, not a function`,e.pos);return this.callFunction(i.value,this.evalArgs(e.args,t,e.pos),t,s)}let r=this.expr(e.callee,t);if(!ot(r))throw new R(`Can't call a ${Ne(r)}`,e.pos);return this.callFunction(r,this.evalArgs(e.args,t,e.pos),t,"function")}specialFunction(e,t,r){if(e==="echo"){let s=this.evalArgs(t.args,r,t.pos);return this.echo(this.echoText(s),t.pos),{handled:!0,value:void 0}}if(e==="assert"){let s=this.evalArgs(t.args,r,t.pos);return this.checkArgs(e,s),this.assert(s),{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let s=this.evalArgs(t.args,r,t.pos);this.checkArgs(e,s);let i=this.measure(s,r);return e==="text_width"?{handled:!0,value:i.advance}:{handled:!0,value:[i.advance,i.bounds,i.ascent,i.descent]}}if(e==="finger_count"){let s=this.evalArgs(t.args,r,t.pos);this.checkArgs(e,s);let i=this.num(this.arg(s,"length",0),"finger_count","length");return{handled:!0,value:Wn(i,this.fingerWidth(s,r,1))}}return{handled:!1}}assert(e){if(Fe(this.arg(e,"condition",0)))return;let t=this.arg(e,"message",1);throw new R(`Assertion failed${t===void 0?"":": "+He(t)}`,e.at)}echo(e,t){this.charge(Math.ceil(e.length/ta),t),this.echoes.push(e)}echoText(e){let t=this.limits.maxListLength,r=[],s=0,i=(o,a,l)=>{r.length&&(s+=2);let u=Dt(a,t-s-o.length,l);if(s+=o.length+u.text.length,!u.whole)throw new R(`echo(): the text would be longer than the limit of ${t} characters`,e.at);r.push(o+u.text)};for(let{name:o,value:a}of e.all)o===null?i("",a,!1):i(`${o} = `,a,!0);return r.join(", ")}arith(e,t,r,s){if(typeof t=="number"&&typeof r=="number")switch(e){case"+":return t+r;case"-":return t-r;case"*":return t*r;case"/":return t/r;case"%":return t%r;case"^":return Math.pow(t,r)}if(e==="+"&&typeof t=="string"&&typeof r=="string")return this.checkSize(t.length+r.length,!0,s),t+r;if(Array.isArray(t)&&Array.isArray(r)){if(e==="+"||e==="-"){if(t.length!==r.length)throw new R(`Can't ${e==="+"?"add":"subtract"} lists of length ${t.length} and ${r.length}`,s);return this.charge(t.length+Xt,s),t.map((o,a)=>this.arith(e,o,r[a],s))}if(e==="*"){if(Array.isArray(t[0]))return this.charge(t.length+Xt,s),t.map(a=>this.arith("*",a,r,s));let o=(a,l)=>{let u=this.arith("*",a,l,s);if(typeof u!="number")throw new R("Can't multiply these lists: an item times an item is not a number",s);return u};if(Array.isArray(r[0])){let a=r[0].length;if(t.length!==r.length||r.some(l=>!Array.isArray(l)||l.length!==a))throw new R(`Can't multiply a list of length ${t.length} by a matrix: it needs ${t.length} rows of the same length`,s);return this.checkSize(a,!1,s),this.tick(s,a*t.length),Array.from({length:a},(l,u)=>t.reduce((c,h,f)=>c+o(h,r[f][u]),0))}if(t.length!==r.length)throw new R(`Can't multiply lists of length ${t.length} and ${r.length}`,s);return this.tick(s,t.length),t.reduce((a,l,u)=>a+o(l,r[u]),0)}}if(Array.isArray(t)&&typeof r=="number"&&(e==="*"||e==="/"))return this.charge(t.length+Xt,s),t.map(o=>this.arith(e,o,r,s));if(typeof t=="number"&&Array.isArray(r)&&e==="*")return this.charge(r.length+Xt,s),r.map(o=>this.arith(e,t,o,s));let i={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new R(`Can't ${i[e]??e} ${Ne(t)} and ${Ne(r)}`,s)}arg(e,t,r,s){return e.named.has(t)?e.named.get(t):r>=0&&r<e.pos.length?e.pos[r]:s}num(e,t,r){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} must be a finite number, got ${xt(e)}`);return e}vec2(e,t,r=!0){let s=i=>typeof i=="number"&&Number.isFinite(i);if(s(e)&&r)return[e,e];if(Array.isArray(e)&&s(e[0])&&(e[1]===void 0||s(e[1])))return[e[0],e[1]??0];throw new Error(`${t} must be a number or [x, y], got ${xt(e)}`)}vec3(e,t){let r=s=>typeof s=="number"&&Number.isFinite(s);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(r))return[e[0],e[1],e[2]??0];throw new Error(`${t} must be [x, y, z], got ${xt(e)}`)}placements(e,t,r){let s=(a,l)=>a===void 0?[[0,0,0]]:Array.isArray(a)&&a.length>0&&Array.isArray(a[0])?a.map((u,c)=>this.vec3(u,`${l}[${c}]`)):[this.vec3(a,l)],i=s(e,"at"),o=s(t,"rotate");for(let[a,l]of[[i,"at"],[o,"rotate"]])if(a.length!==1&&a.length!==r)throw new Error(`${l} needs one placement per copy: qty is ${r} but ${l} has ${a.length}`);return Array.from({length:r},(a,l)=>({at:i[i.length===1?0:l],rotate:o[o.length===1?0:l]}))}points(e,t){if(!Array.isArray(e))throw new Error(`${t} must be a list of [x, y] points`);return e.map((r,s)=>{if(!Array.isArray(r)||!Number.isFinite(r[0])||!Number.isFinite(r[1]))throw new Error(`${t}[${s}] must be an [x, y] point, got ${xt(r)}`);return[r[0],r[1]]})}dyn(e,t){return e.get(t).value}spend(e){if(this.pointCount+=e,!(this.pointCount<=this.limits.maxPoints))throw new Error(`the shapes need more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes.`)}checkValue(e,t,r){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",t,r)}checkSize(e,t,r,s){if(e>this.limits.maxListLength)throw new R(`${s?`${s}(): `:""}${t?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,r);this.charge(t?Math.ceil(e/ta):e+Xt,r)}segs(e){let t=Ee(this.dyn(e,"$fn"))||0,r=Ee(this.dyn(e,"$fa"))||2,s=Ee(this.dyn(e,"$fs"))||.2,i=this.limits.maxSegments;return o=>{let a=ci(o,t,r,s);if(!(a<=i))throw new Error(`a circle with ${a} segments is more than the limit of ${i}. Lower $fn, or raise $fa or $fs.`);return a}}thickness(e){let t=this.dyn(e,"$thickness");if(typeof t!="number"||t<=0)throw new Error("$thickness must be a positive number");return t}fingerWidth(e,t,r){let s=this.arg(e,"finger",r);return typeof s=="number"&&s>0?s:Math.max(3*this.thickness(t),6)}measure(e,t){if(!this.opts.fonts)throw new R("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let r=Dt(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!r.whole)throw new R(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,r.text.length);try{return ea(this.opts.fonts,r.text,this.textOpts(e,t))}catch(s){throw s instanceof R?s:new R(s.message,e.at)}}textOpts(e,t){return{size:this.num(this.arg(e,"size",1,10),"text","size"),font:He(this.arg(e,"font",2,this.dyn(t,"$font")??"")),halign:He(this.arg(e,"halign",-1,"left")),valign:He(this.arg(e,"valign",-1,"baseline")),spacing:Ee(this.arg(e,"spacing",-1,1))}}edges(e){let t=r=>{if(r==="out"||r==="in"||r==="flat")return r;throw new Error(`edges must be "out", "in" or "flat", got ${xt(r)}`)};if(typeof e=="string")return[t(e),t(e),t(e),t(e)];if(Array.isArray(e)&&e.length===4)return e.map(t);throw new Error("edges must be one value or a list of 4: [bottom, right, top, left]")}makeBuiltins(){let e=(i,o)=>Hn(i.children(),o),t=i=>o=>Vn(o.children(),i);return{rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0,1),"size"),l=Ee(this.arg(i.args,"r",-1,0))||0,u=Fe(this.arg(i.args,"center",1,!1)),c=fi(o,a,l,this.segs(i.env));return Ge(be([u?c.map(([h,f])=>[h-o/2,f-a/2]):c]))},square:i=>this.builtins.rect(i),circle:i=>{let o=this.arg(i.args,"d",-1),a=o!==void 0?this.num(o,"circle","d")/2:this.num(this.arg(i.args,"r",0,1),"circle","r");return Ge([qn(a,a,this.segs(i.env)(a))])},ellipse:i=>{let[o,a]=this.vec2(this.arg(i.args,"r",0,1),"r");return Ge([qn(o,a,this.segs(i.env)(Math.max(o,a)))])},regular_polygon:i=>{let o=Math.max(3,Math.floor(this.num(this.arg(i.args,"n",0,6),"regular_polygon","n"))),a=this.num(this.arg(i.args,"r",1,10),"regular_polygon","r");if(!(o<=this.limits.maxSegments))throw new Error(`${o} corners is more than the limit of ${this.limits.maxSegments}`);return Ge([qn(a,a,o)])},star:i=>{let o=Math.max(2,Math.floor(this.num(this.arg(i.args,"n",0,5),"star","n"))),a=this.num(this.arg(i.args,"r",1,10),"star","r"),l=this.num(this.arg(i.args,"inner",2,a*.45),"star","inner");if(!(o*2<=this.limits.maxSegments))throw new Error(`${o} points is more than the limit of ${this.limits.maxSegments/2}`);let u=[];for(let c=0;c<o*2;c++){let h=Math.PI/2+Math.PI*c/o,f=c%2?l:a;u.push([f*Math.cos(h),f*Math.sin(h)])}return Ge(be([u]))},polygon:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=this.arg(i.args,"paths",1),l=Array.isArray(a)?a.map(u=>(Array.isArray(u)?u:[]).map(c=>o[Ee(c)]).filter(Boolean)):[o];return Ge(be(l,"evenodd"))},path:i=>{let o=this.arg(i.args,"d",0);if(typeof o!="string")throw new Error('path() needs SVG path data, like path("M0 0 L10 0 L5 8 Z")');let a=_n(mi(o),.01),l=this.arg(i.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return sn([Ge(be(a.closed,l)),Nt(a.open)])},line:i=>{let o=this.vec2(this.arg(i.args,"from",0,[0,0]),"from",!1),a=this.vec2(this.arg(i.args,"to",1,[10,0]),"to",!1);return Nt([[o,a]])},polyline:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=Fe(this.arg(i.args,"closed",1,!1));return Nt([a&&o.length?[...o,o[0]]:o])},arc:i=>{let o=this.num(this.arg(i.args,"r",0,10),"arc","r"),a=this.num(this.arg(i.args,"start",1,0),"arc","start"),l=this.num(this.arg(i.args,"end",2,90),"arc","end"),u=Math.max(2,Math.ceil(this.segs(i.env)(o)*Math.abs(l-a)/360));if(!(u<=this.limits.maxSegments))throw new Error(`an arc with ${u} segments is more than the limit of ${this.limits.maxSegments}`);let c=[];for(let h=0;h<=u;h++){let f=(a+(l-a)*h/u)*Math.PI/180;c.push([o*Math.cos(f),o*Math.sin(f)])}return Nt([c])},text:i=>{if(!this.opts.fonts)throw new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let o=this.arg(i.args,"text",0,""),a=Dt(o,this.limits.maxTextLength);if(!a.whole)throw new Error(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`);return this.tick(i.args.at,a.text.length),Ge(Qo(this.opts.fonts,a.text,this.textOpts(i.args,i.env)))},translate:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[0,0]),"v",!1);return e(i,[1,0,0,1,o,a])},rotate:i=>{let o=this.arg(i.args,"a",0,0),l=(Array.isArray(o)?Ee(o[2]??0):this.num(o,"rotate","a"))*Math.PI/180,u=Math.cos(l),c=Math.sin(l),h=this.arg(i.args,"center",-1),f=[u,c,-c,u,0,0];if(h!==void 0){let[p,d]=this.vec2(h,"center",!1);f=[u,c,-c,u,p-u*p+c*d,d-c*p-u*d]}return e(i,f)},scale:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,1),"v");return e(i,[o,0,0,a,0,0])},mirror:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[1,0]),"v",!1),l=Math.hypot(o,a)||1,u=o/l,c=a/l;return e(i,[1-2*u*u,-2*u*c,-2*u*c,1-2*c*c,0,0])},multmatrix:i=>{let o=this.arg(i.args,"m",0);if(!Array.isArray(o)||o.length<2)throw new Error("m must be a 2x3 or 3x3 matrix");let a=o[0],l=o[1];return e(i,[a[0],l[0],a[1],l[1],a[2]??0,l[2]??0])},union:i=>i.children(),group:i=>i.children(),difference:i=>{let[o,...a]=i.childList();if(!o)return wt();let l=r(a,"difference");return s(o,u=>({regions:Gn(u.regions,l.regions),lines:rn(u.lines,be(l.regions),"outside")}))},intersection:i=>{let[o,...a]=i.childList();if(!o)return wt();let l=o;for(let u of a){let c=be(r([u],"intersection").regions);l=s(l,h=>({regions:$n(h.regions,c),lines:rn(h.lines,c,"inside")}))}return l},hull:i=>{let o=i.children(),a=l=>{let u=[],c="cut",h=!0;for(let[p,d]of l){h&&(d.regions.length||d.lines.length)&&(c=p,h=!1);for(let g of[...d.regions,...d.lines])for(let y of g)u.push(y)}let f=ui(u);return new Map([[c,{regions:f.length>=3?[f]:[],lines:[]}]])};return{layers:a(o.layers),parts:o.parts.map(l=>({...l,layers:a(l.layers)}))}},offset:i=>{let o=this.arg(i.args,"r",0),a=this.arg(i.args,"delta",-1),l=Fe(this.arg(i.args,"chamfer",-1,!1)),u=o!==void 0?this.num(o,"offset","r"):this.num(a??0,"offset","delta"),c=o!==void 0?"round":l?"square":"miter";return s(i.children(),h=>({regions:zn(h.regions,u,c),lines:h.lines}))},stroke:i=>{let o=this.num(this.arg(i.args,"width",0,1),"stroke","width");return s(i.children(),a=>({regions:be([...a.regions,...ai(a.lines,o)]),lines:[]}))},outline:i=>s(i.children(),o=>({regions:[],lines:[...o.lines,...be(o.regions).map(a=>[...a,a[0]])]})),cut:t("cut"),score:t("score"),engrave:t("engrave"),guide:t("guide"),layer:i=>{let o=this.arg(i.args,"name",0);if(typeof o!="string"||!o)throw new Error("layer() needs a name");let a=this.arg(i.args,"mode",1),l=this.arg(i.args,"color",2),u=this.layers.get(o);if(a!==void 0||l!==void 0||!u){let c=a??u?.mode??"line";if(!["cut","line","fill","guide"].includes(c))throw new Error('mode must be "cut", "line", "fill" or "guide"');let h=He(l??u?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(h))throw new Error('color must look like "#00aa00"');this.layers.set(o,{name:o,mode:c,color:h})}return Vn(i.children(),o)},part:i=>{let o=He(this.arg(i.args,"name",0,"part")),a=Math.max(1,Math.floor(Ee(this.arg(i.args,"qty",1,1))||1));if(this.copies+=a,!(this.copies<=this.limits.maxParts))throw new Error(`more than ${this.limits.maxParts} part copies in total, the limit`);let l=this.arg(i.args,"at",-1),u=this.arg(i.args,"rotate",-1),c=l===void 0&&u===void 0?void 0:this.placements(l,u,a),h=i.children();return{layers:new Map,parts:[...h.parts,{name:o,qty:a,layers:h.layers,thickness:this.thickness(i.env),kerf:Ee(this.dyn(i.env,"$kerf"))||0,material:He(this.dyn(i.env,"$material")??"material"),...c?{placements:c}:{}}]}},material:i=>{let o=this.arg(i.args,"thickness",0),a=this.arg(i.args,"kerf",1),l=this.arg(i.args,"name",2);return o!==void 0&&i.env.vars.set("$thickness",this.num(o,"material","thickness")),a!==void 0&&i.env.vars.set("$kerf",this.num(a,"material","kerf")),l!==void 0&&i.env.vars.set("$material",He(l)),i.children()},children:i=>{let o=i.env.childCtx();if(!o)return wt();let a=this.childStmts(o.stmts),l=this.arg(i.args,"index",0),u=new we(o.env,i.env);this.hoist(o.stmts,u);let c=new Set;if(l===void 0)a.forEach(f=>c.add(f));else for(let f of this.iterable(l,i.args.at))a[Ee(f)]&&c.add(a[Ee(f)]);let h=[];for(let f of o.stmts)if(f.kind==="assign")this.stmt(f,u);else if(c.has(f)){let p=this.stmt(f,u);p&&h.push(p)}return sn(h)},echo:i=>(this.echo(this.echoText(i.args),i.args.at),i.children()),assert:i=>(this.assert(i.args),i.children()),finger_rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),l=this.edges(this.arg(i.args,"edges",1,"out")),u=this.thickness(i.env),c=this.fingerWidth(i.args,i.env,2);return this.spend(2*(Math.abs(o)+Math.abs(a))/c*4),Ge(hi(o,a,l,u,c))},finger_holes:i=>{let o=this.num(this.arg(i.args,"length",0),"finger_holes","length"),a=this.edges(this.arg(i.args,"edge",1,"out"))[0];if(a==="flat")throw new Error('edge must be "out" or "in"');let l=this.fingerWidth(i.args,i.env,2);return this.spend(Math.abs(o)/l*4),Ge(pi(o,a,this.thickness(i.env),l))},tslot:i=>{let o=this.num(this.arg(i.args,"d",0,3),"tslot","d"),a=this.num(this.arg(i.args,"length",1,12),"tslot","length"),[l,u]=this.vec2(this.arg(i.args,"nut",2,[o*1.85,o*.8]),"nut",!1),c=this.num(this.arg(i.args,"nut_at",3,a/2),"tslot","nut_at");return Ge(be(di(o,a,l,u,c)))},living_hinge:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),l=this.num(this.arg(i.args,"spacing",1,1.5),"living_hinge","spacing"),u=this.num(this.arg(i.args,"bridge",2,3),"living_hinge","bridge"),c=this.num(this.arg(i.args,"cut",3,Math.max(u*2,(a-3*u)/2)),"living_hinge","cut");if(l<=0||u<=0||c<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(o)/l+1)*(Math.abs(a)/(c+u)+2)*2),Nt(gi(o,a,l,u,c))}};function r(i,o){let a={regions:[],lines:[]};for(let l of i){if(l.parts.length)throw new Error(`part() can only be the first child of ${o}()`);for(let u of l.layers.values())for(let c of u.regions)a.regions.push(c)}return a}function s(i,o){let a=l=>{let u=new Map;for(let[c,h]of l)u.set(c,o(h));return u};return{layers:a(i.layers),parts:i.parts.map(l=>({...l,layers:a(l.layers)}))}}}};var qt=n=>{let e=Math.round(n*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},vs=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");function xs(n,e){let t=[];for(let[r,s]of n){let i=[qt(r),qt(s)],o=t[t.length-1];(!o||o[0]!==i[0]||o[1]!==i[1])&&t.push(i)}for(;e&&t.length>1&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1];)t.pop();return t}var Wt=(n,e)=>`M${xs(n,e).map(([t,r])=>`${t} ${r}`).join("L")}${e?"Z":""}`;function ys(n,e){let t=[];for(let r of e){let s=[],i=[],o=[];for(let a of n){let l=a.layers.get(r.name);if(l){for(let u of l.lines)s.push(Wt(u,!1));for(let u of l.regions)(ut(u)<0?i:o).push(Wt(u,!0))}}(s.length||i.length||o.length)&&t.push({name:r.name,mode:r.mode,color:r.color,d:[...s,...i,...o].join(""),regions:[...i,...o].join(""),lines:s.join("")})}return t}function bs(n,e,t,r){let s=['<?xml version="1.0" encoding="UTF-8"?>',`<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${qt(e)}mm" height="${qt(t)}mm" viewBox="0 0 ${qt(e)} ${qt(t)}">`];for(let i of r){let o=[],a=[];for(let u of n){let c=u.layers.get(i.name);if(!c)continue;let h=` data-part="${vs(u.part)}"`;if(i.mode==="fill"){c.regions.length&&a.push(`<path${h} d="${c.regions.map(f=>Wt(f,!0)).join("")}"/>`);for(let f of c.lines)a.push(`<path${h} fill="none" stroke="${i.color}" stroke-width="0.1" d="${Wt(f,!1)}"/>`);continue}for(let f of c.lines)o.push(`<path${h} d="${Wt(f,!1)}"/>`);for(let f of c.regions)(ut(f)<0?o:a).push(`<path${h} d="${Wt(f,!0)}"/>`)}if(!o.length&&!a.length)continue;let l=i.mode==="fill"?`fill="${i.color}" fill-rule="evenodd" stroke="none"`:`fill="none" stroke="${i.color}" stroke-width="0.1"${i.mode==="guide"?' stroke-dasharray="1 1"':""}`;s.push(`<g id="${vs(i.name)}" inkscape:groupmode="layer" inkscape:label="${vs(i.name)}" data-mode="${i.mode}" ${l}>`,...o,...a,"</g>")}return s.push("</svg>",""),s.join(`
379
- `)}var Xh={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},qh=n=>{let e=Xh[n.toLowerCase()];if(e)return e;let[t,r,s]=[1,3,5].map(i=>parseInt(n.slice(i,i+2),16));return t>r&&t>s?1:r>t&&r>s?3:s>t&&s>r?5:7};function Wh(n){let e=a=>a.toUpperCase().replace(/[^A-Z0-9_-]/g,"_"),t=new Set(ms.map(a=>a.name)),r=new Set(n.map(a=>e(a.name))),s=new Set,i=new Map,o=[...n.filter(a=>t.has(a.name)),...n.filter(a=>!t.has(a.name))];for(let a of o){let l=e(a.name);if(s.has(l)){let u=2;for(;r.has(`${l}_${u}`)||s.has(`${l}_${u}`);)u++;l=`${l}_${u}`}s.add(l),i.set(a.name,l)}return i}function na(n,e,t,r){let s=[],i=(l,u)=>s.push(String(l),String(u)),o=Wh(r);i(0,"SECTION"),i(2,"HEADER"),i(9,"$ACADVER"),i(1,"AC1009"),i(9,"$INSUNITS"),i(70,4),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"TABLES"),i(0,"TABLE"),i(2,"LAYER"),i(70,r.length);for(let l of r)i(0,"LAYER"),i(2,o.get(l.name)),i(70,0),i(62,qh(l.color)),i(6,"CONTINUOUS");i(0,"ENDTAB"),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"ENTITIES");let a=(l,u,c)=>{i(0,"POLYLINE"),i(8,l),i(66,1),i(10,0),i(20,0),i(30,0),i(70,c?1:0);for(let[h,f]of xs(u.map(([p,d])=>[p,t-d]),c))i(0,"VERTEX"),i(8,l),i(10,h),i(20,f),i(30,0);i(0,"SEQEND"),i(8,l)};for(let l of r){let u=o.get(l.name),c=[];for(let h of n){let f=h.layers.get(l.name);if(f){for(let p of f.lines)a(u,p,!1);for(let p of f.regions)ut(p)<0?a(u,p,!0):c.push(p)}}for(let h of c)a(u,h,!0)}return i(0,"ENDSEC"),i(0,"EOF"),s.join(`
378
+ `}},Nn=class n extends Un{constructor(t=null){super(t);k(this,"polygon",null)}get poly(){return this.polygon}addChild(t){let r=new n(this);return r.polygon=t,this.children.push(r),r}child(t){if(t<0||t>=this.children.length)throw new Error("Index out of range");return this.children[t]}area(){let t=this.polygon===null?0:Rr.area(this.polygon);for(let r of this.children)t+=r.area();return t}};var en=class extends Nn{};var v=class v{constructor(){k(this,"cliptype",ie.NoClip);k(this,"fillrule",q.EvenOdd);k(this,"actives",null);k(this,"sel",null);k(this,"minimaList",[]);k(this,"intersectList",[]);k(this,"vertexList",[]);k(this,"outrecList",[]);k(this,"scanlineHeap",new Fr);k(this,"scanlineSet",new Set);k(this,"scanlineArr",[]);k(this,"useScanlineArray",!1);k(this,"horzSegList",[]);k(this,"horzJoinList",[]);k(this,"currentLocMin",0);k(this,"currentBotY",0);k(this,"curXValidAtTop",!1);k(this,"isSortedMinimaList",!1);k(this,"hasOpenPaths",!1);k(this,"usingPolytree",!1);k(this,"succeeded",!1);k(this,"zCallbackInternal");k(this,"preserveCollinear",!0);k(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,t){return e.x===t.x&&e.y===t.y}setZ(e,t,r){let s=this.zCallbackInternal;s&&(v.getPolyType(e)===ke.Subject?(this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:this.xyEqual(r,t.bot)?r.z=t.bot.z??0:this.xyEqual(r,t.top)?r.z=t.top.z??0:r.z=0,s(e.bot,e.top,t.bot,t.top,r)):(this.xyEqual(r,t.bot)?r.z=t.bot.z??0:this.xyEqual(r,t.top)?r.z=t.top.z??0:this.xyEqual(r,e.bot)?r.z=e.bot.z??0:this.xyEqual(r,e.top)?r.z=e.top.z??0:r.z=0,s(t.bot,t.top,e.bot,e.top,r)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return v.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return v.openPathsEnabled&&e.localMin.isOpen&&v.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(J.OpenStart|J.OpenEnd))!==J.None}static getPrevHotEdge(e){let t=e.prevInAEL;if(!v.openPathsEnabled){for(;t!==null&&!v.isHotEdge(t);)t=t.prevInAEL;return t}for(;t!==null&&(t.localMin.isOpen||!v.isHotEdge(t));)t=t.prevInAEL;return t}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,t){let r=t.y-e.y;return r!==0?(t.x-e.x)/r:t.x>e.x?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}static topX(e,t){return t===e.top.y||e.top.x===e.bot.x?e.top.x:t===e.bot.y?e.bot.x:V.roundToEven(e.bot.x+e.dx*(t-e.bot.y))}static isHorizontal(e){return e.dx===Number.NEGATIVE_INFINITY||e.dx===Number.POSITIVE_INFINITY}static isHeadingRightHorz(e){return e.dx===Number.NEGATIVE_INFINITY}static isHeadingLeftHorz(e){return e.dx===Number.POSITIVE_INFINITY}static getPolyType(e){return e.localMin.polytype}static isSamePolyType(e,t){return e.localMin.polytype===t.localMin.polytype}static setDx(e){e.dx=v.getDx(e.bot,e.top)}static nextVertex(e){return e.windDx>0?e.vertexTop.next:e.vertexTop.prev}static prevPrevVertex(e){return e.windDx>0?e.vertexTop.prev.prev:e.vertexTop.next.next}static isMaximaVertex(e){return(e.flags&J.LocalMax)!==J.None}static isMaximaEdge(e){return(e.vertexTop.flags&J.LocalMax)!==J.None}static getMaximaPair(e){let t=e.nextInAEL;for(;t!==null;){if(t.vertexTop===e.vertexTop)return t;t=t.nextInAEL}return null}boundingBoxesOverlap(e,t,r,s){let i=e.x<t.x?e.x:t.x;if((r.x>s.x?r.x:s.x)<i)return!1;let a=e.x>t.x?e.x:t.x,l=r.x<s.x?r.x:s.x;if(a<l)return!1;let u=e.y<t.y?e.y:t.y;if((r.y>s.y?r.y:s.y)<u)return!1;let h=e.y>t.y?e.y:t.y,f=r.y<s.y?r.y:s.y;return h>=f}clearSolutionOnly(){for(;this.actives!==null;)this.deleteFromAEL(this.actives);this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.disposeIntersectNodes(),this.outrecList.length=0,this.horzSegList.length=0,this.horzJoinList.length=0}clear(){this.clearSolutionOnly(),this.minimaList.length=0,this.vertexList.length=0,this.currentLocMin=0,this.isSortedMinimaList=!1,this.hasOpenPaths=!1}reset(){this.isSortedMinimaList||(this.minimaList.sort((e,t)=>t.vertex.pt.y-e.vertex.pt.y),this.isSortedMinimaList=!0),this.scanlineHeap.clear(),this.scanlineSet.clear(),this.scanlineArr.length=0,this.useScanlineArray=this.minimaList.length<=16;for(let e=this.minimaList.length-1;e>=0;e--)this.insertScanline(this.minimaList[e].vertex.pt.y);this.currentBotY=0,this.currentLocMin=0,this.actives=null,this.sel=null,this.curXValidAtTop=!1,this.succeeded=!0}upgradeScanlineStructureFromArray(){let e=this.scanlineArr;for(let t=0,r=e.length;t<r;t++){let s=e[t];this.scanlineSet.add(s),this.scanlineHeap.push(s)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let t=this.scanlineArr;for(let r=0,s=t.length;r<s;r++)if(t[r]===e)return;t.push(e),t.length>64&&this.upgradeScanlineStructureFromArray();return}this.scanlineSet.has(e)||(this.scanlineSet.add(e),this.scanlineHeap.push(e))}popScanline(){if(this.useScanlineArray){let t=this.scanlineArr,r=t.length;if(r===0)return null;let s=0,i=t[0];for(let o=1;o<r;o++){let a=t[o];a>i&&(i=a,s=o)}return t[s]=t[r-1],t.pop(),i}let e=this.scanlineHeap.pop();return e===null?null:(this.scanlineSet.delete(e),e)}hasLocMinAtY(e){return this.currentLocMin<this.minimaList.length&&this.minimaList[this.currentLocMin].vertex.pt.y===e}popLocalMinima(){return this.minimaList[this.currentLocMin++]}addPath(e,t,r=!1){let s=[e];this.addPaths(s,t,r)}addPaths(e,t,r=!1){r&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,Rt.addPathsToVertexList(e,t,r,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let t of e.minimaList)this.minimaList.push(new Kt(t.vertex,t.polytype,t.isOpen)),t.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let t=e.prevInAEL,r=e.nextInAEL;t===null&&r===null&&e!==this.actives||(t!==null?t.nextInAEL=r:this.actives=r,r!==null&&(r.prevInAEL=t))}getBounds(){let e={left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER};for(let t of this.vertexList){let r=t;do r.pt.x<e.left&&(e.left=r.pt.x),r.pt.x>e.right&&(e.right=r.pt.x),r.pt.y<e.top&&(e.top=r.pt.y),r.pt.y>e.bottom&&(e.bottom=r.pt.y),r=r.next;while(r!==t)}return yt.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,t){if(e===ie.NoClip)return;v.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=t,this.cliptype=e,this.reset();let r=this.popScanline();if(r!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(r);let s;for(;(s=this.popHorz())!==null;)this.doHorizontal(s);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=r;let i=this.popScanline();if(i===null)break;for(r=i,this.doIntersections(r),this.doTopOfScanbeam(r);(s=this.popHorz())!==null;)this.doHorizontal(s)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let t=this.popLocalMinima(),r;(t.vertex.flags&J.OpenStart)!==J.None?r=null:(r=new Qt,r.bot=t.vertex.pt,r.curX=t.vertex.pt.x,r.windDx=-1,r.vertexTop=t.vertex.prev,r.top=t.vertex.prev.pt,r.outrec=null,r.localMin=t,v.setDx(r));let s;if((t.vertex.flags&J.OpenEnd)!==J.None?s=null:(s=new Qt,s.bot=t.vertex.pt,s.curX=t.vertex.pt.x,s.windDx=1,s.vertexTop=t.vertex.next,s.top=t.vertex.next.pt,s.outrec=null,s.localMin=t,v.setDx(s)),r!==null&&s!==null){if(v.isHorizontal(r)){if(v.isHeadingRightHorz(r)){let o=r;r=s,s=o}}else if(v.isHorizontal(s)){if(v.isHeadingLeftHorz(s)){let o=r;r=s,s=o}}else if(r.dx<s.dx){let o=r;r=s,s=o}}else r===null&&(r=s,s=null);let i;if(r.isLeftBound=!0,this.insertLeftEdge(r),v.openPathsEnabled?v.isOpen(r)?(this.setWindCountForOpenPathEdge(r),i=this.isContributingOpen(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)):(this.setWindCountForClosedPathEdge(r),i=this.isContributingClosed(r)),s!==null){for(s.windCount=r.windCount,s.windCount2=r.windCount2,this.insertRightEdge(r,s),i&&(this.addLocalMinPoly(r,s,r.bot,!0),v.isHorizontal(r)||this.checkJoinLeft(r,r.bot));s.nextInAEL!==null&&this.isValidAelOrder(s.nextInAEL,s);)this.intersectEdges(s,s.nextInAEL,s.bot),this.swapPositionsInAEL(s,s.nextInAEL);v.isHorizontal(s)?this.pushHorz(s):(this.checkJoinRight(s,s.bot),this.insertScanline(s.top.y))}else i&&v.openPathsEnabled&&this.startOpenPath(r,r.bot);v.isHorizontal(r)?this.pushHorz(r):this.insertScanline(r.top.y)}}pushHorz(e){e.nextInSEL=this.sel,this.sel=e}popHorz(){let e=this.sel;return e===null?null:(this.sel=this.sel.nextInSEL,e)}doHorizontal(e){if(!v.openPathsEnabled){this.doHorizontalClosed(e);return}let t=v.isOpen(e),r=e.bot.y,s=t?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:i,leftX:o,rightX:a}=this.resetHorzDirection(e,s),l=o,u=a;if(v.isHotEdge(e)){let c=this.addOutPt(e,{x:e.curX,y:r});this.addToHorzSegList(c)}for(;;){let c=i?e.nextInAEL:e.prevInAEL;for(;c!==null;){if(c.vertexTop===s){if(v.isHotEdge(e)&&this.isJoined(c)&&this.split(c,c.top),v.isHotEdge(e)){for(;e.vertexTop!==s;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);i?this.addLocalMaxPoly(e,c,e.top):this.addLocalMaxPoly(c,e,e.top)}this.deleteFromAEL(c),this.deleteFromAEL(e);return}if(s!==e.vertexTop||v.isOpenEnd(e)){if(i&&c.curX>u||!i&&c.curX<l)break;if(c.curX===e.top.x&&!v.isHorizontal(c)){let p=v.nextVertex(e).pt;if(v.isOpen(c)&&!v.isSamePolyType(c,e)&&!v.isHotEdge(c)){if(i&&v.topX(c,p.y)>p.x||!i&&v.topX(c,p.y)<p.x)break}else if(i&&v.topX(c,p.y)>=p.x||!i&&v.topX(c,p.y)<=p.x)break}}let f={x:c.curX,y:r};i?(this.intersectEdges(e,c,f),this.swapPositionsInAEL(e,c),this.checkJoinLeft(c,f),e.curX=c.curX,c=e.nextInAEL):(this.intersectEdges(c,e,f),this.swapPositionsInAEL(c,e),this.checkJoinRight(c,f),e.curX=c.curX,c=e.prevInAEL),v.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(t&&v.isOpenEnd(e)){v.isHotEdge(e)&&(this.addOutPt(e,e.top),v.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(v.nextVertex(e).pt.y!==e.top.y)break;v.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let h=this.resetHorzDirection(e,s);l=h.leftX,u=h.rightX}if(v.isHotEdge(e)){let c=this.addOutPt(e,e.top);this.addToHorzSegList(c)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let t=e.bot.y,r=this.getCurrYMaximaVertex(e),{isLeftToRight:s,leftX:i,rightX:o}=this.resetHorzDirection(e,r),a=i,l=o;if(v.isHotEdge(e)){let u=this.addOutPt(e,{x:e.curX,y:t});this.addToHorzSegList(u)}for(;;){let u=s?e.nextInAEL:e.prevInAEL;for(;u!==null;){if(u.vertexTop===r){if(v.isHotEdge(e)&&this.isJoined(u)&&this.split(u,u.top),v.isHotEdge(e)){for(;e.vertexTop!==r;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);s?this.addLocalMaxPoly(e,u,e.top):this.addLocalMaxPoly(u,e,e.top)}this.deleteFromAEL(u),this.deleteFromAEL(e);return}if(r!==e.vertexTop){if(s&&u.curX>l||!s&&u.curX<a)break;if(u.curX===e.top.x&&!v.isHorizontal(u)){let f=v.nextVertex(e).pt,p=v.topX(u,f.y);if(s&&p>=f.x||!s&&p<=f.x)break}}let h={x:u.curX,y:t};s?(this.intersectEdges(e,u,h),this.swapPositionsInAEL(e,u),this.checkJoinLeft(u,h),e.curX=u.curX,u=e.nextInAEL):(this.intersectEdges(u,e,h),this.swapPositionsInAEL(u,e),this.checkJoinRight(u,h),e.curX=u.curX,u=e.prevInAEL),v.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(v.nextVertex(e).pt.y!==e.top.y)break;v.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let c=this.resetHorzDirection(e,r);a=c.leftX,l=c.rightX}if(v.isHotEdge(e)){let u=this.addOutPt(e,e.top);this.addToHorzSegList(u)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,t=0;for(let r=0,s=e.length;r<s;r++){let i=e[r];this.updateHorzSegment(i)&&(e[t++]=i)}if(!(t<2)){e.length=t,this.horzSegList.sort(ml);for(let r=0;r<t-1;r++){let s=this.horzSegList[r];for(let i=r+1;i<t;i++){let o=this.horzSegList[i];if(o.leftOp.pt.x>=s.rightOp.pt.x||o.leftToRight===s.leftToRight||o.rightOp.pt.x<=s.leftOp.pt.x)continue;let a=s.leftOp.pt.y;if(s.leftToRight){for(;s.leftOp.next.pt.y===a&&s.leftOp.next.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.next;for(;o.leftOp.prev.pt.y===a&&o.leftOp.prev.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.prev;let l=new Jt(this.duplicateOp(s.leftOp,!0),this.duplicateOp(o.leftOp,!1));this.horzJoinList.push(l)}else{for(;s.leftOp.prev.pt.y===a&&s.leftOp.prev.pt.x<=o.leftOp.pt.x;)s.leftOp=s.leftOp.prev;for(;o.leftOp.next.pt.y===a&&o.leftOp.next.pt.x<=s.leftOp.pt.x;)o.leftOp=o.leftOp.next;let l=new Jt(this.duplicateOp(o.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(l)}}}}}updateHorzSegment(e){let t=e.leftOp,r=this.getRealOutRec(t.outrec),s=r.frontEdge!==null,i=t.pt.y,o=t,a=t;if(s){let u=r.pts,c=u.next;for(;o!==c&&o.prev.pt.y===i;)o=o.prev;for(;a!==u&&a.next.pt.y===i;)a=a.next}else{for(;o.prev!==a&&o.prev.pt.y===i;)o=o.prev;for(;a.next!==o&&a.next.pt.y===i;)a=a.next}let l=this.setHorzSegHeadingForward(e,o,a)&&e.leftOp.horz===null;return l?e.leftOp.horz=e:e.rightOp=null,l}setHorzSegHeadingForward(e,t,r){return t.pt.x===r.pt.x?!1:(t.pt.x<r.pt.x?(e.leftOp=t,e.rightOp=r,e.leftToRight=!0):(e.leftOp=r,e.rightOp=t,e.leftToRight=!1),!0)}duplicateOp(e,t){let r=new rt(e.pt,e.outrec);return t?(r.next=e.next,r.next.prev=r,r.prev=e,e.next=r):(r.prev=e.prev,r.prev.next=r,r.next=e,e.prev=r),r}getRealOutRec(e){for(;e!==null&&e.pts===null;)e=e.owner;return e}doIntersections(e){this.buildIntersectList(e)&&(this.processIntersectList(),this.disposeIntersectNodes())}doTopOfScanbeam(e){let t=this.curXValidAtTop;this.curXValidAtTop=!1,this.sel=null;let r=this.actives;for(;r!==null;){if(r.top.y===e)if(r.curX=r.top.x,v.isMaximaEdge(r)){r=this.doMaxima(r);continue}else v.isHotEdge(r)&&this.addOutPt(r,r.top),this.updateEdgeIntoAEL(r),v.isHorizontal(r)&&this.pushHorz(r);else t||(r.curX=v.topX(r,e));r=r.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let t=this.getRealOutRec(e.op1.outrec),r=this.getRealOutRec(e.op2.outrec),s=e.op1.next,i=e.op2.prev;if(e.op1.next=e.op2,e.op2.prev=e.op1,s.prev=i,i.next=s,t===r){let o=this.newOutRec();o.pts=s,this.fixOutRecPts(o),t.pts.outrec===o&&(t.pts=e.op1,t.pts.outrec=t),this.usingPolytree?(this.path1InsidePath2(t.pts,o.pts)?([o.pts,t.pts]=[t.pts,o.pts],this.fixOutRecPts(t),this.fixOutRecPts(o),o.owner=t):this.path1InsidePath2(o.pts,t.pts)?o.owner=t:o.owner=t.owner,t.splits===null&&(t.splits=[]),t.splits.push(o.idx)):o.owner=t}else r.pts=null,this.usingPolytree?(this.setOwner(r,t),this.moveSplits(r,t)):r.owner=t}}fixOutRecPts(e){let t=e.pts;do t.outrec=e,t=t.next;while(t!==e.pts)}path1InsidePath2(e,t){let r=X.IsOn,s=e;do{switch(this.pointInOpPolygon(s.pt,t)){case X.IsOutside:if(r===X.IsOutside)return!1;r=X.IsOutside;break;case X.IsInside:if(r===X.IsInside)return!0;r=X.IsInside;break;default:break}s=s.next}while(s!==e);return V.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(t))}pointInOpPolygon(e,t){if(t===t.next||t.prev===t.next)return X.IsOutside;let r=t;do{if(t.pt.y!==e.y)break;t=t.next}while(t!==r);if(t.pt.y===e.y)return X.IsOutside;let s=t.pt.y<e.y,i=s,o=0;for(r=t.next;r!==t;){if(s)for(;r!==t&&r.pt.y<e.y;)r=r.next;else for(;r!==t&&r.pt.y>e.y;)r=r.next;if(r===t)break;if(r.pt.y===e.y){if(r.pt.x===e.x||r.pt.y===r.prev.pt.y&&e.x<r.prev.pt.x!=e.x<r.pt.x)return X.IsOn;if(r=r.next,r===t)break;continue}if(r.pt.x<=e.x||r.prev.pt.x<=e.x)if(r.prev.pt.x<e.x&&r.pt.x<e.x)o=1-o;else{let a=V.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return X.IsOn;a<0===s&&(o=1-o)}s=!s,r=r.next}if(s===i)return o===0?X.IsOutside:X.IsInside;{let a=V.crossProductSign(r.prev.pt,r.pt,e);if(a===0)return X.IsOn;a<0===s&&(o=1-o)}return o===0?X.IsOutside:X.IsInside}getCleanPath(e){let t=[],r=e;for(;r.next!==e&&(r.pt.x===r.next.pt.x&&r.pt.x===r.prev.pt.x||r.pt.y===r.next.pt.y&&r.pt.y===r.prev.pt.y);)r=r.next;t.push(r.pt);let s=r;for(r=r.next;r!==e;)(r.pt.x!==r.next.pt.x||r.pt.x!==s.pt.x)&&(r.pt.y!==r.next.pt.y||r.pt.y!==s.pt.y)&&(t.push(r.pt),s=r),r=r.next;return t}moveSplits(e,t){if(e.splits!==null){t.splits===null&&(t.splits=[]);for(let r of e.splits)r!==t.idx&&t.splits.push(r);e.splits=null}}buildIntersectList(e){if(this.actives?.nextInAEL===null)return!1;if(!this.adjustCurrXAndCopyToSEL(e))return this.curXValidAtTop=!0,!1;let t=this.sel;for(;t!==null&&t.jump!==null;){let r=null;for(;t!==null&&t.jump!==null;){let s=t,i=t.jump,o=i,a=i?.jump||null;for(t.jump=a;t!==o&&i!==a;)if(i.curX<t.curX){let l=i.prevInSEL;for(;this.addNewIntersectNode(l,i,e),l!==t;)l=l.prevInSEL;if(l=i,i=this.extractFromSEL(l),o=i,t!==null&&this.insert1Before2InSEL(l,t),t!==s)continue;s=l,s.jump=a,r===null?this.sel=s:r.jump=s}else t=t.nextInSEL;r=s,t=a}t=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(vl);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let r=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[r]);)r++;[this.intersectList[r],this.intersectList[e]]=[this.intersectList[e],this.intersectList[r]]}let t=this.intersectList[e];this.intersectEdges(t.edge1,t.edge2,t.pt),this.swapPositionsInAEL(t.edge1,t.edge2),t.edge1.curX=t.pt.x,t.edge2.curX=t.pt.x,this.checkJoinLeft(t.edge2,t.pt,!0),this.checkJoinRight(t.edge1,t.pt,!0)}}edgesAdjacentInAEL(e){return e.edge1.nextInAEL===e.edge2||e.edge1.prevInAEL===e.edge2}adjustCurrXAndCopyToSEL(e){let t=this.actives;this.sel=t;let r=Number.NEGATIVE_INFINITY,s=!1;for(;t!==null;){t.prevInSEL=t.prevInAEL,t.nextInSEL=t.nextInAEL,t.jump=t.nextInSEL;let i=v.topX(t,e);t.curX=i,i<r&&(s=!0),r=i,t=t.nextInAEL}return s}doMaxima(e){let t=e.prevInAEL,r=e.nextInAEL;if(v.isOpenEnd(e))return v.isHotEdge(e)&&this.addOutPt(e,e.top),v.isHorizontal(e)||(v.isHotEdge(e)&&(v.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),r;let s=v.getMaximaPair(e);if(s===null)return r;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(s)&&this.split(s,s.top);r!==s;)this.intersectEdges(e,r,e.top),this.swapPositionsInAEL(e,r),r=e.nextInAEL;return v.isOpen(e)?(v.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(s),this.deleteFromAEL(e),t!==null?t.nextInAEL:this.actives):(v.isHotEdge(e)&&this.addLocalMaxPoly(e,s,e.top),this.deleteFromAEL(e),this.deleteFromAEL(s),t!==null?t.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=v.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,v.setDx(e),this.isJoined(e)&&this.split(e,e.bot),v.isHorizontal(e)){v.openPathsEnabled?v.isOpen(e)||this.trimHorz(e,this.preserveCollinear):this.trimHorz(e,this.preserveCollinear);return}this.insertScanline(e.top.y),this.checkJoinLeft(e,e.bot),this.checkJoinRight(e,e.bot,!0)}trimHorz(e,t){let r=!1,s=v.nextVertex(e).pt;for(;s.y===e.top.y&&!(t&&s.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=v.nextVertex(e),e.top=s,r=!0,v.isMaximaVertex(e.vertexTop)));)s=v.nextVertex(e).pt;r&&v.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new Rn(e))}addNewIntersectNode(e,t,r){let s=V.getLineIntersectPt(e.bot,e.top,t.bot,t.top);if(s===null&&(s={x:e.curX,y:r}),s.y>this.currentBotY||s.y<r){let o=Math.abs(e.dx),a=Math.abs(t.dx);o>100&&a>100?o>a?s=V.getClosestPtOnSegment(s,e.bot,e.top):s=V.getClosestPtOnSegment(s,t.bot,t.top):o>100?s=V.getClosestPtOnSegment(s,e.bot,e.top):a>100?s=V.getClosestPtOnSegment(s,t.bot,t.top):(s.y<r?s.y=r:s.y=this.currentBotY,o<a?s.x=v.topX(e,s.y):s.x=v.topX(t,s.y))}let i=ti(s,e,t);this.intersectList.push(i)}extractFromSEL(e){let t=e.nextInSEL;return t!==null&&(t.prevInSEL=e.prevInSEL),e.prevInSEL.nextInSEL=t,t}insert1Before2InSEL(e,t){e.prevInSEL=t.prevInSEL,e.prevInSEL!==null&&(e.prevInSEL.nextInSEL=e),e.nextInSEL=t,t.prevInSEL=e}getCurrYMaximaVertexOpen(e){let t=e.vertexTop;if(e.windDx>0)for(;t.next.pt.y===t.pt.y&&(t.flags&(J.OpenEnd|J.LocalMax))===J.None;)t=t.next;else for(;t.prev.pt.y===t.pt.y&&(t.flags&(J.OpenEnd|J.LocalMax))===J.None;)t=t.prev;return v.isMaximaVertex(t)||(t=null),t}getCurrYMaximaVertex(e){let t=e.vertexTop;if(e.windDx>0)for(;t.next.pt.y===t.pt.y;)t=t.next;else for(;t.prev.pt.y===t.pt.y;)t=t.prev;return v.isMaximaVertex(t)||(t=null),t}resetHorzDirection(e,t){if(e.bot.x===e.top.x){let r=e.curX,s=e.curX,i=e.nextInAEL;for(;i!==null&&i.vertexTop!==t;)i=i.nextInAEL;return{isLeftToRight:i!==null,leftX:r,rightX:s}}return e.curX<e.top.x?{isLeftToRight:!0,leftX:e.curX,rightX:e.top.x}:{isLeftToRight:!1,leftX:e.top.x,rightX:e.curX}}getLastOp(e){let t=e.outrec;return e===t.frontEdge?t.pts:t.pts.next}insertLeftEdge(e){if(this.actives===null)e.prevInAEL=null,e.nextInAEL=null,this.actives=e;else if(!this.isValidAelOrder(this.actives,e))e.prevInAEL=null,e.nextInAEL=this.actives,this.actives.prevInAEL=e,this.actives=e;else{let t=this.actives;for(;t.nextInAEL!==null&&this.isValidAelOrder(t.nextInAEL,e);)t=t.nextInAEL;t.joinWith===Te.Right&&(t=t.nextInAEL),e.nextInAEL=t.nextInAEL,t.nextInAEL!==null&&(t.nextInAEL.prevInAEL=e),e.prevInAEL=t,t.nextInAEL=e}}insertRightEdge(e,t){t.nextInAEL=e.nextInAEL,e.nextInAEL!==null&&(e.nextInAEL.prevInAEL=t),t.prevInAEL=e,e.nextInAEL=t}setWindCountForOpenPathEdge(e){let t=this.actives;if(this.fillrule===q.EvenOdd){let r=0,s=0;for(;t!==e;)v.getPolyType(t)===ke.Clip?s++:v.isOpen(t)||r++,t=t.nextInAEL;e.windCount=v.isOdd(r)?1:0,e.windCount2=v.isOdd(s)?1:0}else for(;t!==e;)v.getPolyType(t)===ke.Clip?e.windCount2+=t.windDx:v.isOpen(t)||(e.windCount+=t.windDx),t=t.nextInAEL}setWindCountForClosedPathEdge(e){let t=e.prevInAEL,r=v.getPolyType(e);if(!v.openPathsEnabled){for(;t!==null&&v.getPolyType(t)!==r;)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===q.EvenOdd?(e.windCount=e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL):(t.windCount*t.windDx<0?Math.abs(t.windCount)>1?t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx:e.windCount=e.windDx:t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL),this.fillrule===q.EvenOdd)for(;t!==e;)v.getPolyType(t)!==r&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)v.getPolyType(t)!==r&&(e.windCount2+=t.windDx),t=t.nextInAEL;return}for(;t!==null&&(v.getPolyType(t)!==r||v.isOpen(t));)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===q.EvenOdd?(e.windCount=e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL):(t.windCount*t.windDx<0?Math.abs(t.windCount)>1?t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx:e.windCount=v.isOpen(e)?1:e.windDx:t.windDx*e.windDx<0?e.windCount=t.windCount:e.windCount=t.windCount+e.windDx,e.windCount2=t.windCount2,t=t.nextInAEL),this.fillrule===q.EvenOdd)for(;t!==e;)v.getPolyType(t)!==r&&!v.isOpen(t)&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)v.getPolyType(t)!==r&&!v.isOpen(t)&&(e.windCount2+=t.windDx),t=t.nextInAEL}isContributingOpen(e){let t,r;switch(this.fillrule){case q.Positive:r=e.windCount>0,t=e.windCount2>0;break;case q.Negative:r=e.windCount<0,t=e.windCount2<0;break;default:r=e.windCount!==0,t=e.windCount2!==0;break}switch(this.cliptype){case ie.Intersection:return t;case ie.Union:return!r&&!t;default:return!t}}isContributingClosed(e){switch(this.fillrule){case q.Positive:if(e.windCount!==1)return!1;break;case q.Negative:if(e.windCount!==-1)return!1;break;case q.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case ie.Intersection:return this.fillrule===q.Positive?e.windCount2>0:this.fillrule===q.Negative?e.windCount2<0:e.windCount2!==0;case ie.Union:return this.fillrule===q.Positive?e.windCount2<=0:this.fillrule===q.Negative?e.windCount2>=0:e.windCount2===0;case ie.Difference:{let t=this.fillrule===q.Positive?e.windCount2<=0:this.fillrule===q.Negative?e.windCount2>=0:e.windCount2===0;return v.getPolyType(e)===ke.Subject?t:!t}case ie.Xor:return!0;default:return!1}}addLocalMinPoly(e,t,r,s=!1){let i=this.newOutRec();if(e.outrec=i,t.outrec=i,v.isOpen(e))i.owner=null,i.isOpen=!0,e.windDx>0?this.setSides(i,e,t):this.setSides(i,t,e);else{i.isOpen=!1;let a=v.getPrevHotEdge(e);a!==null?(this.usingPolytree&&this.setOwner(i,a.outrec),i.owner=a.outrec,this.outrecIsAscending(a)===s?this.setSides(i,t,e):this.setSides(i,e,t)):(i.owner=null,s?this.setSides(i,e,t):this.setSides(i,t,e))}let o=new rt(r,i);return i.pts=o,o}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new Dn;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,t){let r=this.newOutRec();r.isOpen=!0,e.windDx>0?(r.frontEdge=e,r.backEdge=null):(r.frontEdge=null,r.backEdge=e),e.outrec=r;let s=new rt(t,r);return r.pts=s,s}checkJoinLeft(e,t,r=!1){let s=e.prevInAEL;s!==null&&(!r&&e.curX!==s.curX||!v.isHotEdge(e)||!v.isHotEdge(s)||v.isHorizontal(e)||v.isHorizontal(s)||v.isOpen(e)||v.isOpen(s)||(t.y<e.top.y+2||t.y<s.top.y+2)&&(e.bot.y>t.y||s.bot.y>t.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,s.bot,s.top)||V.isCollinear(e.top,t,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(s,e,t):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),s.joinWith=Te.Right,e.joinWith=Te.Left))}checkJoinRight(e,t,r=!1){let s=e.nextInAEL;s!==null&&(!r&&e.curX!==s.curX||!v.isHotEdge(e)||!v.isHotEdge(s)||v.isHorizontal(e)||v.isHorizontal(s)||v.isOpen(e)||v.isOpen(s)||(t.y<e.top.y+2||t.y<s.top.y+2)&&(e.bot.y>t.y||s.bot.y>t.y)||r&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,s.bot,s.top)||V.isCollinear(e.top,t,s.top)&&(e.outrec.idx===s.outrec.idx?this.addLocalMaxPoly(e,s,t):e.outrec.idx<s.outrec.idx?this.joinOutrecPaths(e,s):this.joinOutrecPaths(s,e),e.joinWith=Te.Right,s.joinWith=Te.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,t,r){let s=e.x-t.x,i=e.y-t.y,o=r.x-t.x,a=r.y-t.y;if(o===0&&a===0)return!1;let l=V.maxCoordForSafeCrossSq;if(Math.abs(s)<l&&Math.abs(i)<l&&Math.abs(o)<l&&Math.abs(a)<l){let c=s*a-o*i;return c*c/(o*o+a*a)>.25}if(Number.isSafeInteger(s)&&Number.isSafeInteger(i)&&Number.isSafeInteger(o)&&Number.isSafeInteger(a)){let c=BigInt(s)*BigInt(a)-BigInt(o)*BigInt(i),h=c*c,f=BigInt(o)*BigInt(o)+BigInt(a)*BigInt(a);return ei*h>f}let u=s*a-o*i;return u*u/(o*o+a*a)>.25}intersectEdges(e,t,r){let s;if(this.hasOpenPaths&&(v.isOpen(e)||v.isOpen(t))){if(v.isOpen(e)&&v.isOpen(t))return;if(v.isOpen(t)){let u=e;e=t,t=u}if(this.isJoined(t)&&this.split(t,r),this.cliptype===ie.Union){if(!v.isHotEdge(t))return}else if(t.localMin.polytype===ke.Subject)return;switch(this.fillrule){case q.Positive:if(t.windCount!==1)return;break;case q.Negative:if(t.windCount!==-1)return;break;default:if(Math.abs(t.windCount)!==1)return;break}if(v.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,t,s.pt),v.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(r.x===e.localMin.vertex.pt.x&&r.y===e.localMin.vertex.pt.y&&!v.isOpenEndVertex(e.localMin.vertex)){let u=this.findEdgeWithMatchingLocMin(e);if(u!==null&&v.isHotEdge(u)){e.outrec=u.outrec,e.windDx>0?this.setSides(u.outrec,e,u):this.setSides(u.outrec,u,e);return}s=this.startOpenPath(e,r)}else s=this.startOpenPath(e,r);this.setZ(e,t,s.pt);return}this.isJoined(e)&&this.split(e,r),this.isJoined(t)&&this.split(t,r);let i,o;switch(e.localMin.polytype===t.localMin.polytype?this.fillrule===q.EvenOdd?(i=e.windCount,e.windCount=t.windCount,t.windCount=i):(e.windCount+t.windDx===0?e.windCount=-e.windCount:e.windCount+=t.windDx,t.windCount-e.windDx===0?t.windCount=-t.windCount:t.windCount-=e.windDx):(this.fillrule!==q.EvenOdd?e.windCount2+=t.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==q.EvenOdd?t.windCount2-=e.windDx:t.windCount2=t.windCount2===0?1:0),this.fillrule){case q.Positive:i=e.windCount,o=t.windCount;break;case q.Negative:i=-e.windCount,o=-t.windCount;break;default:i=Math.abs(e.windCount),o=Math.abs(t.windCount);break}let a=i===0||i===1,l=o===0||o===1;if(!(!v.isHotEdge(e)&&!a||!v.isHotEdge(t)&&!l))if(v.isHotEdge(e)&&v.isHotEdge(t))if(i!==0&&i!==1||o!==0&&o!==1||e.localMin.polytype!==t.localMin.polytype&&this.cliptype!==ie.Xor)s=this.addLocalMaxPoly(e,t,r),s&&this.setZ(e,t,s.pt);else if(v.isFront(e)||e.outrec===t.outrec){s=this.addLocalMaxPoly(e,t,r),s&&this.setZ(e,t,s.pt);let u=this.addLocalMinPoly(e,t,r);this.setZ(e,t,u.pt)}else{s=this.addOutPt(e,r),this.setZ(e,t,s.pt);let u=this.addOutPt(t,r);this.setZ(e,t,u.pt),this.swapOutrecs(e,t)}else if(v.isHotEdge(e))s=this.addOutPt(e,r),this.setZ(e,t,s.pt),this.swapOutrecs(e,t);else if(v.isHotEdge(t))s=this.addOutPt(t,r),this.setZ(e,t,s.pt),this.swapOutrecs(e,t);else{let u,c;switch(this.fillrule){case q.Positive:u=e.windCount2,c=t.windCount2;break;case q.Negative:u=-e.windCount2,c=-t.windCount2;break;default:u=Math.abs(e.windCount2),c=Math.abs(t.windCount2);break}if(!v.isSamePolyType(e,t))s=this.addLocalMinPoly(e,t,r),this.setZ(e,t,s.pt);else if(i===1&&o===1){switch(s=null,this.cliptype){case ie.Union:if(u>0&&c>0)return;s=this.addLocalMinPoly(e,t,r);break;case ie.Difference:(v.getPolyType(e)===ke.Clip&&u>0&&c>0||v.getPolyType(e)===ke.Subject&&u<=0&&c<=0)&&(s=this.addLocalMinPoly(e,t,r));break;case ie.Xor:s=this.addLocalMinPoly(e,t,r);break;default:if(u<=0||c<=0)return;s=this.addLocalMinPoly(e,t,r);break}s&&this.setZ(e,t,s.pt)}}}swapPositionsInAEL(e,t){let r=t.nextInAEL;r!==null&&(r.prevInAEL=e);let s=e.prevInAEL;s!==null&&(s.nextInAEL=t),t.prevInAEL=s,t.nextInAEL=e,e.prevInAEL=t,e.nextInAEL=r,t.prevInAEL===null&&(this.actives=t)}isValidAelOrder(e,t){if(t.curX!==e.curX)return t.curX>e.curX;let r=V.crossProductSign(e.top,t.bot,t.top);if(r!==0)return r<0;if(!v.isMaximaEdge(e)&&e.top.y>t.top.y)return V.crossProductSign(t.bot,e.top,v.nextVertex(e).pt)<=0;if(!v.isMaximaEdge(t)&&t.top.y>e.top.y)return V.crossProductSign(t.bot,t.top,v.nextVertex(t).pt)>=0;let s=t.bot.y,i=t.isLeftBound;return e.bot.y!==s||e.localMin.vertex.pt.y!==s?t.isLeftBound:e.isLeftBound!==i?i:V.isCollinear(v.prevPrevVertex(e).pt,e.bot,e.top)?!0:V.crossProductSign(v.prevPrevVertex(e).pt,t.bot,v.prevPrevVertex(t).pt)>0===i}isJoined(e){return e.joinWith!==Te.None}split(e,t){e.joinWith===Te.Right?(e.joinWith=Te.None,e.nextInAEL.joinWith=Te.None,this.addLocalMinPoly(e,e.nextInAEL,t,!0)):(e.joinWith=Te.None,e.prevInAEL.joinWith=Te.None,this.addLocalMinPoly(e.prevInAEL,e,t,!0))}setSides(e,t,r){e.frontEdge=t,e.backEdge=r}findEdgeWithMatchingLocMin(e){let t=e.nextInAEL;for(;t!==null;){if(t.localMin?.equals(e.localMin))return t;!v.isHorizontal(t)&&!(e.bot.x===t.bot.x&&e.bot.y===t.bot.y)?t=null:t=t.nextInAEL}for(t=e.prevInAEL;t!==null;){if(t.localMin?.equals(e.localMin))return t;if(!v.isHorizontal(t)&&!(e.bot.x===t.bot.x&&e.bot.y===t.bot.y))return null;t=t.prevInAEL}return t}addOutPt(e,t){let r=e.outrec,s=v.isFront(e),i=r.pts,o=i.next;if(s&&t.x===i.pt.x&&t.y===i.pt.y)return i;if(!s&&t.x===o.pt.x&&t.y===o.pt.y)return o;let a=new rt(t,r);return o.prev=a,a.prev=i,a.next=o,i.next=a,s&&(r.pts=a),a}addLocalMaxPoly(e,t,r){if(this.isJoined(e)&&this.split(e,r),this.isJoined(t)&&this.split(t,r),v.isFront(e)===v.isFront(t))if(v.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(v.isOpenEnd(t))this.swapFrontBackSides(t.outrec);else return this.succeeded=!1,null;let s=this.addOutPt(e,r);if(e.outrec===t.outrec){let i=e.outrec;if(i.pts=s,this.usingPolytree){let o=v.getPrevHotEdge(e);o===null?i.owner=null:this.setOwner(i,o.outrec)}this.uncoupleOutRec(e)}else v.isOpen(e)?e.windDx<0?this.joinOutrecPaths(e,t):this.joinOutrecPaths(t,e):e.outrec.idx<t.outrec.idx?this.joinOutrecPaths(e,t):this.joinOutrecPaths(t,e);return s}swapFrontBackSides(e){let t=e.frontEdge;e.frontEdge=e.backEdge,e.backEdge=t,e.pts=e.pts.next}setOwner(e,t){for(;t.owner!==null&&t.owner.pts===null;)t.owner=t.owner.owner;let r=t;for(;r!==null&&r!==e;)r=r.owner;r!==null&&(t.owner=e.owner),e.owner=t}uncoupleOutRec(e){let t=e.outrec;t!==null&&(t.frontEdge.outrec=null,t.backEdge.outrec=null,t.frontEdge=null,t.backEdge=null)}joinOutrecPaths(e,t){let r=e.outrec.pts,s=t.outrec.pts,i=r.next,o=s.next;v.isFront(e)?(o.prev=r,r.next=o,s.next=i,i.prev=s,e.outrec.pts=s,e.outrec.frontEdge=t.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(i.prev=s,s.next=i,r.next=o,o.prev=r,e.outrec.backEdge=t.outrec.backEdge,e.outrec.backEdge!==null&&(e.outrec.backEdge.outrec=e.outrec)),t.outrec.frontEdge=null,t.outrec.backEdge=null,t.outrec.pts=null,this.setOwner(t.outrec,e.outrec),v.isOpenEnd(e)&&(t.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,t.outrec=null}swapOutrecs(e,t){let r=e.outrec,s=t.outrec;if(r===s){let i=r.frontEdge;r.frontEdge=r.backEdge,r.backEdge=i;return}r!==null&&(e===r.frontEdge?r.frontEdge=t:r.backEdge=t),s!==null&&(t===s.frontEdge?s.frontEdge=e:s.backEdge=e),e.outrec=s,t.outrec=r}disposeIntersectNodes(){this.intersectList.length=0}static ptsReallyClose(e,t){return Math.abs(e.x-t.x)<2&&Math.abs(e.y-t.y)<2}static isVerySmallTriangle(e){return e.next.next===e.prev&&(v.ptsReallyClose(e.prev.pt,e.next.pt)||v.ptsReallyClose(e.pt,e.next.pt)||v.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,t,r,s){if(e===null||e.next===e||!r&&e.next===e.prev)return!1;s.length=0;let i,o;for(t?(i=e.pt,o=e.prev):(e=e.next,i=e.pt,o=e.next),s.push(i);o!==e;)o.pt.x===i.x&&o.pt.y===i.y||(i=o.pt,s.push(i)),t?o=o.prev:o=o.next;return s.length!==3||r||!v.isVerySmallTriangle(o)}buildPaths(e,t){e.length=0,t.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts===null)continue;let i=[];s.isOpen?v.buildPath(s.pts,this.reverseSolution,!0,i)&&t.push(i):(this.cleanCollinear(s),v.buildPath(s.pts,this.reverseSolution,!1,i)&&e.push(i))}return!0}buildTree(e,t){e.clear(),t.length=0;let r=0;for(;r<this.outrecList.length;){let s=this.outrecList[r++];if(s.pts!==null){if(s.isOpen){let i=[];v.buildPath(s.pts,this.reverseSolution,!0,i)&&t.push(i);continue}this.checkBounds(s)&&this.recursiveCheckOwners(s,e)}}}checkBounds(e){return e.pts===null?!1:yt.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!v.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=V.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,t){if(!(e.polypath!==null||yt.isEmpty(e.bounds))){for(;e.owner!==null&&!(e.owner.splits!==null&&this.checkSplitOwner(e,e.owner.splits)||e.owner.pts!==null&&this.checkBounds(e.owner)&&this.containsRect(e.owner.bounds,e.bounds)&&this.path1InsidePath2(e.pts,e.owner.pts));)e.owner=e.owner.owner;e.owner!==null?(e.owner.polypath===null&&this.recursiveCheckOwners(e.owner,t),e.polypath=e.owner.polypath.addChild(e.path)):e.polypath=t.addChild(e.path)}}cleanCollinear(e){if(e=this.getRealOutRec(e),e===null||e.isOpen)return;if(!this.isValidClosedPath(e.pts)){e.pts=null;return}let t=e.pts,r=t;for(;;){if(r!==null&&V.isCollinear(r.prev.pt,r.pt,r.next.pt)&&(r.pt.x===r.prev.pt.x&&r.pt.y===r.prev.pt.y||r.pt.x===r.next.pt.x&&r.pt.y===r.next.pt.y||!this.preserveCollinear||V.dotProductSign(r.prev.pt,r.pt,r.next.pt)<0)){if(r===e.pts&&(e.pts=r.prev),r=this.disposeOutPt(r),!this.isValidClosedPath(r)){e.pts=null;return}t=r;continue}if(r===null||(r=r.next,r===t))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!v.isVerySmallTriangle(e))}disposeOutPt(e){let t=e.next===e?null:e.next;return e.prev.next=e.next,e.next.prev=e.prev,t}fixSelfIntersects(e){let t=e.pts;if(t.prev!==t.next.next)for(;;){if(t.next&&t.next.next&&this.boundingBoxesOverlap(t.prev.pt,t.pt,t.next.pt,t.next.next.pt)&&V.segsIntersect(t.prev.pt,t.pt,t.next.pt,t.next.next.pt)){if((t===e.pts||t.next===e.pts)&&(e.pts=e.pts.prev),this.doSplitOp(e,t),e.pts===null)return;if(t=e.pts,t.prev===t.next.next)break;continue}if(t=t.next,t===e.pts)break}}doSplitOp(e,t){let r=t.prev,s=t.next.next;e.pts=r;let i=V.getLineIntersectPt(r.pt,t.pt,t.next.pt,s.pt);this.zCallbackInternal&&this.zCallbackInternal(r.pt,t.pt,t.next.pt,s.pt,i);let o=v.areaOutPt(r),a=o<Zt?-o:o;if(a<ei){e.pts=null;return}let l=this.areaTriangle(i,t.pt,t.next.pt),u=l<Zt?-l:l;if(i.x===r.pt.x&&i.y===r.pt.y||i.x===s.pt.x&&i.y===s.pt.y)s.prev=r,r.next=s;else{let f=new rt(i,e);f.prev=r,f.next=s,s.prev=f,r.next=f}if(!(u>gl)||!(u>a)&&l>Zt!=o>Zt)return;let c=this.newOutRec();c.owner=e.owner,t.outrec=c,t.next.outrec=c;let h=new rt(i,c);h.prev=t.next,h.next=t,c.pts=h,t.prev=h,t.next.next=h,this.usingPolytree&&(this.path1InsidePath2(r,h)?(c.splits===null&&(c.splits=[]),c.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(c.idx)))}static areaOutPt(e){let t=V.maxCoordForSafeAreaProduct,r=0,s=!0,i=e;do{let a=i.prev,l=i.pt;if(Math.abs(a.pt.x)>=t||Math.abs(a.pt.y)>=t||Math.abs(l.x)>=t||Math.abs(l.y)>=t){s=!1;break}r+=(a.pt.y+l.y)*(a.pt.x-l.x),i=i.next}while(i!==e);if(s)return BigInt(Math.round(r));let o=Zt;i=e;do{let a=i.prev;if(Number.isSafeInteger(a.pt.y)&&Number.isSafeInteger(i.pt.y)&&Number.isSafeInteger(a.pt.x)&&Number.isSafeInteger(i.pt.x)){let l=BigInt(a.pt.y)+BigInt(i.pt.y),u=BigInt(a.pt.x)-BigInt(i.pt.x);o+=l*u}else{let l=a.pt.y+i.pt.y,u=a.pt.x-i.pt.x;o+=BigInt(Math.round(l*u))}i=i.next}while(i!==e);return o}areaTriangle(e,t,r){let s=V.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<s&&Math.abs(e.y)<s&&Math.abs(t.x)<s&&Math.abs(t.y)<s&&Math.abs(r.x)<s&&Math.abs(r.y)<s){let o=(r.y+e.y)*(r.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+r.y)*(t.x-r.x);return BigInt(Math.round(o))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y)&&Number.isSafeInteger(r.x)&&Number.isSafeInteger(r.y)){let o=(BigInt(r.y)+BigInt(e.y))*(BigInt(r.x)-BigInt(e.x)),a=(BigInt(e.y)+BigInt(t.y))*(BigInt(e.x)-BigInt(t.x)),l=(BigInt(t.y)+BigInt(r.y))*(BigInt(t.x)-BigInt(r.x));return o+a+l}let i=(r.y+e.y)*(r.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+r.y)*(t.x-r.x);return BigInt(Math.round(i))}isValidOwner(e,t){for(;t!==null&&t!==e;)t=t.owner;return t===null}containsRect(e,t){return t.left>=e.left&&t.right<=e.right&&t.top>=e.top&&t.bottom<=e.bottom}checkSplitOwner(e,t){for(let r=0;r<t.length;r++){let s=this.outrecList[t[r]];if(s.pts===null&&s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(s=this.getRealOutRec(s),!(s===null||s===e||s.recursiveSplit===e)){if(s.recursiveSplit=e,s.splits!==null&&this.checkSplitOwner(e,s.splits))return!0;if(!(!this.checkBounds(s)||!this.containsRect(s.bounds,e.bounds)||!this.path1InsidePath2(e.pts,s.pts)))return this.isValidOwner(e,s)||(s.owner=e.owner),e.owner=s,!0}}return!1}};k(v,"openPathsEnabled",!0);var Bn=v,Ke=class extends Bn{constructor(){super(...arguments);k(this,"zCallback")}getZCallback(){return this.zCallback}addPath(t,r,s=!1){super.addPath(t,r,s)}addReuseableData(t){super.addReuseableData(t)}addPaths(t,r,s=!1){super.addPaths(t,r,s)}addSubject(t){this.addPaths(t,ke.Subject)}addOpenSubject(t){this.addPaths(t,ke.Subject,!0)}addClip(t){this.addPaths(t,ke.Clip)}execute(t,r,s,i){if(Array.isArray(s)){let o=s,a=i;o.length=0,a&&(a.length=0);try{this.executeInternal(t,r),this.buildPaths(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}else{let o=s,a=i;o.clear(),a&&(a.length=0),this.usingPolytree=!0;try{this.executeInternal(t,r),this.buildTree(o,a||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var Rr={area(n){return V.area(n)},areaD(n){let e=0,t=n.length;if(t<3)return 0;let r=n[t-1];for(let s of n)e+=(r.y+s.y)*(r.x-s.x),r=s;return e*.5},scalePath64(n,e){let t=V.maxSafeCoordinateForScale(e),r=[];for(let s of n)V.checkSafeScaleValue(s.x,t,"scalePath64"),V.checkSafeScaleValue(s.y,t,"scalePath64"),r.push({x:Math.round(s.x*e),y:Math.round(s.y*e)});return r},scalePaths64(n,e){let t=[];for(let r of n)t.push(Rr.scalePath64(r,e));return t},scalePathD(n,e){let t=[];for(let r of n)t.push({x:r.x*e,y:r.y*e});return t},scalePathsD(n,e){let t=[];for(let r of n)t.push(Rr.scalePathD(r,e));return t}};var Ie;(function(n){n[n.Miter=0]="Miter",n[n.Square=1]="Square",n[n.Bevel=2]="Bevel",n[n.Round=3]="Round"})(Ie||(Ie={}));var fe;(function(n){n[n.Polygon=0]="Polygon",n[n.Joined=1]="Joined",n[n.Butt=2]="Butt",n[n.Square=3]="Square",n[n.Round=4]="Round"})(fe||(fe={}));var Ur=class{constructor(e,t,r=fe.Polygon){k(this,"inPaths");k(this,"joinType");k(this,"endType");k(this,"pathsReversed");k(this,"lowestPathIdx");this.joinType=t,this.endType=r;let s=r===fe.Polygon||r===fe.Joined;this.inPaths=[];for(let i of e)this.inPaths.push(bt.stripDuplicates(i,s));if(r===fe.Polygon){let i=bt.getLowestPathInfo(this.inPaths);this.lowestPathIdx=i.idx,this.pathsReversed=this.lowestPathIdx>=0&&i.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},ce=class ce{constructor(e=2,t=0,r=!1,s=!1){k(this,"groupList",[]);k(this,"pathOut",[]);k(this,"normals",[]);k(this,"solution",[]);k(this,"solutionTree",null);k(this,"groupDelta",0);k(this,"delta",0);k(this,"mitLimSqr",0);k(this,"stepsPerRad",0);k(this,"stepSin",0);k(this,"stepCos",0);k(this,"joinType",Ie.Bevel);k(this,"endType",fe.Polygon);k(this,"arcTolerance",0);k(this,"mergeGroups",!0);k(this,"miterLimit",2);k(this,"preserveCollinear",!1);k(this,"reverseSolution",!1);k(this,"zCallback");k(this,"deltaCallback",null);k(this,"ZCB",(e,t,r,s,i)=>{(e.z||0)!==0&&(e.z===r.z||e.z===s.z)?i.z=e.z:(r.z||0)!==0&&r.z===t.z?i.z=r.z:(t.z||0)!==0&&t.z===s.z?i.z=t.z:this.zCallback&&this.zCallback(e,t,r,s,i)});this.miterLimit=e,this.arcTolerance=t,this.mergeGroups=!0,this.preserveCollinear=r,this.reverseSolution=s}clear(){this.groupList.length=0}addPath(e,t,r){if(e.length===0)return;let s=[e];this.addPaths(s,t,r)}addPaths(e,t,r){e.length!==0&&this.groupList.push(new Ur(e,t,r))}calcSolutionCapacity(){let e=0;for(let t of this.groupList)e+=t.endType===fe.Joined?t.inPaths.length*2:t.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let t of this.groupList)if(t.endType===fe.Polygon){e=t.pathsReversed;break}return e}executeInternal(e){if(this.groupList.length===0)return;if(Math.abs(e)<.5){for(let i of this.groupList)for(let o of i.inPaths)this.solution.push(o);return}this.delta=e,this.mitLimSqr=this.miterLimit<=1?2:2/ce.sqr(this.miterLimit);for(let i of this.groupList)this.doGroupOffset(i);if(this.groupList.length===0)return;let t=this.checkPathsReversed(),r=t?q.Negative:q.Positive,s=new Ke;s.preserveCollinear=this.preserveCollinear,s.reverseSolution=this.reverseSolution!==t,s.zCallback=this.ZCB,s.addSubject(this.solution),this.solutionTree!==null?s.execute(ie.Union,r,this.solutionTree):s.execute(ie.Union,r,this.solution)}execute(e,t){if(Array.isArray(t)){let r=t;r.length=0,this.solution=r,this.executeInternal(e)}else{let r=t;r.clear(),this.solutionTree=r,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,t){this.deltaCallback=e,this.execute(1,t)}static getUnitNormal(e,t){let r=t.x-e.x,s=t.y-e.y;if(r===0&&s===0)return{x:0,y:0};let i=1/Math.sqrt(r*r+s*s);return{x:s*i,y:-r*i}}static getLowestPathInfo(e){let t=-1,r=!1,s={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let i=0;i<e.length;++i){let o=Number.MAX_VALUE;for(let a of e[i])if(!(a.y<s.y||a.y===s.y&&a.x>=s.x)){if(o===Number.MAX_VALUE){if(o=ce.area(e[i]),o===0)break;r=o<0}t=i,s.x=a.x,s.y=a.y}}return{idx:t,isNegArea:r}}static translatePoint(e,t,r){return{x:e.x+t,y:e.y+r,z:e.z}}static reflectPoint(e,t){return{x:t.x+(t.x-e.x),y:t.y+(t.y-e.y),z:e.z}}static almostZero(e,t=.001){return Math.abs(e)<t}static hypotenuse(e,t){return Math.sqrt(e*e+t*t)}static normalizeVector(e){let t=ce.hypotenuse(e.x,e.y);if(ce.almostZero(t))return{x:0,y:0};let r=1/t;return{x:e.x*r,y:e.y*r}}static getAvgUnitVector(e,t){return ce.normalizeVector({x:e.x+t.x,y:e.y+t.y})}static intersectPoint(e,t,r,s){if(V.isAlmostZero(e.x-t.x)){if(V.isAlmostZero(r.x-s.x))return{x:0,y:0};let i=(s.y-r.y)/(s.x-r.x),o=r.y-i*r.x;return{x:e.x,y:i*e.x+o}}if(V.isAlmostZero(r.x-s.x)){let i=(t.y-e.y)/(t.x-e.x),o=e.y-i*e.x;return{x:r.x,y:i*r.x+o}}else{let i=(t.y-e.y)/(t.x-e.x),o=e.y-i*e.x,a=(s.y-r.y)/(s.x-r.x),l=r.y-a*r.x;if(V.isAlmostZero(i-a))return{x:0,y:0};let u=(l-o)/(i-a);return{x:u,y:i*u+o}}}getPerpendic(e,t){return{x:Math.round(e.x+t.x*this.groupDelta),y:Math.round(e.y+t.y*this.groupDelta),z:e.z||0}}getPerpendicD(e,t){return{x:e.x+t.x*this.groupDelta,y:e.y+t.y*this.groupDelta,z:e.z||0}}doBevel(e,t,r){let s,i,o=e[t].z||0;if(t===r){let a=Math.abs(this.groupDelta);s={x:Math.round(e[t].x-a*this.normals[t].x),y:Math.round(e[t].y-a*this.normals[t].y),z:o},i={x:Math.round(e[t].x+a*this.normals[t].x),y:Math.round(e[t].y+a*this.normals[t].y),z:o}}else s={x:Math.round(e[t].x+this.groupDelta*this.normals[r].x),y:Math.round(e[t].y+this.groupDelta*this.normals[r].y),z:o},i={x:Math.round(e[t].x+this.groupDelta*this.normals[t].x),y:Math.round(e[t].y+this.groupDelta*this.normals[t].y),z:o};this.pathOut.push(s),this.pathOut.push(i)}doSquare(e,t,r){let s;t===r?s={x:this.normals[t].y,y:-this.normals[t].x}:s=ce.getAvgUnitVector({x:-this.normals[r].y,y:this.normals[r].x},{x:this.normals[t].y,y:-this.normals[t].x});let i=Math.abs(this.groupDelta),o={x:e[t].x,y:e[t].y,z:e[t].z||0};o=ce.translatePoint(o,i*s.x,i*s.y);let a=ce.translatePoint(o,this.groupDelta*s.y,this.groupDelta*-s.x),l=ce.translatePoint(o,this.groupDelta*-s.y,this.groupDelta*s.x),u=this.getPerpendicD(e[r],this.normals[r]);if(t===r){let c={x:u.x+s.x*this.groupDelta,y:u.y+s.y*this.groupDelta},h=ce.intersectPoint(a,l,u,c);h.z=o.z,this.pathOut.push(Ye.fromPointD(ce.reflectPoint(h,o))),this.pathOut.push(Ye.fromPointD(h))}else{let c=this.getPerpendicD(e[t],this.normals[r]),h=ce.intersectPoint(a,l,u,c);h.z=o.z,this.pathOut.push(Ye.fromPointD(h)),this.pathOut.push(Ye.fromPointD(ce.reflectPoint(h,o)))}}doMiter(e,t,r,s){let i=this.groupDelta/(s+1);this.pathOut.push({x:Math.round(e[t].x+(this.normals[r].x+this.normals[t].x)*i),y:Math.round(e[t].y+(this.normals[r].y+this.normals[t].y)*i),z:e[t].z||0})}doRound(e,t,r,s){if(this.deltaCallback!==null){let u=Math.abs(this.groupDelta),c=this.arcTolerance>.01?this.arcTolerance:u*ce.arc_const,h=Math.PI/Math.acos(1-c/u);this.stepSin=Math.sin(2*Math.PI/h),this.stepCos=Math.cos(2*Math.PI/h),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=h/(2*Math.PI)}let i=e[t],o=i.z||0,a={x:this.normals[r].x*this.groupDelta,y:this.normals[r].y*this.groupDelta};t===r&&Fn.negate(a),this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});let l=Math.ceil(this.stepsPerRad*Math.abs(s));for(let u=1;u<l;u++)a={x:a.x*this.stepCos-this.stepSin*a.y,y:a.x*this.stepSin+a.y*this.stepCos},this.pathOut.push({x:Math.round(i.x+a.x),y:Math.round(i.y+a.y),z:o});this.pathOut.push(this.getPerpendic(e[t],this.normals[t]))}buildNormals(e){let t=e.length;if(this.normals.length=0,t!==0){for(let r=0;r<t-1;r++)this.normals.push(ce.getUnitNormal(e[r],e[r+1]));this.normals.push(ce.getUnitNormal(e[t-1],e[0]))}}offsetPoint(e,t,r,s){if(Ye.equals(t[r],t[s]))return;let i=V.crossProductD(this.normals[r],this.normals[s]),o=V.dotProductD(this.normals[r],this.normals[s]);if(i>1?i=1:i<-1&&(i=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,r,s),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<ce.Tolerance){this.pathOut.push(t[r]);return}if(o>-.999&&i*this.groupDelta<0)this.pathOut.push(this.getPerpendic(t[r],this.normals[s])),this.pathOut.push(t[r]),this.pathOut.push(this.getPerpendic(t[r],this.normals[r]));else if(o>.999&&this.joinType!==Ie.Round)this.doMiter(t,r,s,o);else switch(this.joinType){case Ie.Miter:o>this.mitLimSqr-1?this.doMiter(t,r,s,o):this.doSquare(t,r,s);break;case Ie.Round:this.doRound(t,r,s,Math.atan2(i,o));break;case Ie.Bevel:this.doBevel(t,r,s);break;default:this.doSquare(t,r,s);break}}offsetPolygon(e,t){this.pathOut=[];let r=t.length,s=r-1;for(let i=0;i<r;i++)this.offsetPoint(e,t,i,s),s=i;this.solution.push(this.pathOut)}offsetOpenJoined(e,t){this.offsetPolygon(e,t);let r=[...t].reverse();this.buildNormals(r),this.offsetPolygon(e,r)}offsetOpenPath(e,t){this.pathOut=[];let r=t.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,0,0)),Math.abs(this.groupDelta)<ce.Tolerance)this.pathOut.push(t[0]);else switch(this.endType){case fe.Butt:this.doBevel(t,0,0);break;case fe.Round:this.doRound(t,0,0,Math.PI);break;default:this.doSquare(t,0,0);break}for(let s=1,i=0;s<r;s++)this.offsetPoint(e,t,s,i),i=s;for(let s=r;s>0;s--)this.normals[s]={x:-this.normals[s-1].x,y:-this.normals[s-1].y};if(this.normals[0]=this.normals[r],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,r,r)),Math.abs(this.groupDelta)<ce.Tolerance)this.pathOut.push(t[r]);else switch(this.endType){case fe.Butt:this.doBevel(t,r,r);break;case fe.Round:this.doRound(t,r,r,Math.PI);break;default:this.doSquare(t,r,r);break}for(let s=r-1,i=r;s>0;s--)this.offsetPoint(e,t,s,i),i=s;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===fe.Polygon?(e.lowestPathIdx<0&&(this.delta=Math.abs(this.delta)),this.groupDelta=e.pathsReversed?-this.delta:this.delta):this.groupDelta=Math.abs(this.delta);let t=Math.abs(this.groupDelta);if(this.joinType=e.joinType,this.endType=e.endType,e.joinType===Ie.Round||e.endType===fe.Round){let r=this.arcTolerance>.01?this.arcTolerance:t*ce.arc_const,s=Math.PI/Math.acos(1-r/t);this.stepSin=Math.sin(2*Math.PI/s),this.stepCos=Math.cos(2*Math.PI/s),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=s/(2*Math.PI)}for(let r of e.inPaths){this.pathOut=[];let s=r.length;if(s===1){let i=r[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(r,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let o=i.z||0;if(e.endType===fe.Round){let a=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=ce.ellipse(i,Math.abs(this.groupDelta),Math.abs(this.groupDelta),a),o!==0)for(let l=0;l<this.pathOut.length;l++)this.pathOut[l].z=o}else{let a=Math.ceil(Math.abs(this.groupDelta)),l={left:i.x-a,top:i.y-a,right:i.x+a,bottom:i.y+a};this.pathOut=[{x:l.left,y:l.top,z:o},{x:l.right,y:l.top,z:o},{x:l.right,y:l.bottom,z:o},{x:l.left,y:l.bottom,z:o}]}this.solution.push(this.pathOut);continue}switch(s===2&&e.endType===fe.Joined&&(this.endType=e.joinType===Ie.Round?fe.Round:fe.Square),this.buildNormals(r),this.endType){case fe.Polygon:this.offsetPolygon(e,r);break;case fe.Joined:this.offsetOpenJoined(e,r);break;default:this.offsetOpenPath(e,r);break}}}static stripDuplicates(e,t){let r=e.length,s=[];if(r===0)return s;let i=e[0];s.push(i);for(let o=1;o<r;o++)Ye.equals(i,e[o])||(i=e[o],s.push(i));return t&&Ye.equals(i,s[0])&&s.pop(),s}static area(e){return V.area(e)}static sqr(e){return e*e}static ellipse(e,t,r=0,s=0){if(t<=0)return[];r<=0&&(r=t),s<=2&&(s=Math.ceil(Math.PI*Math.sqrt((t+r)/2)));let i=Math.sin(2*Math.PI/s),o=Math.cos(2*Math.PI/s),a=o,l=i,u=[{x:Math.round(e.x+t),y:e.y}];for(let c=1;c<s;++c){u.push({x:Math.round(e.x+t*a),y:Math.round(e.y+r*l)});let h=a*o-l*i;l=l*o+a*i,a=h}return u}};k(ce,"Tolerance",1e-12),k(ce,"arc_const",.002);var bt=ce;var Dp=BigInt(2);function Br(n,e,t){return typeof e=="number"?Nr(ie.Union,n,null,e):Nr(ie.Union,n,e,t)}function Nr(n,e,t,r){let s=[];if(e===null)return s;let i=new Ke;return i.addPaths(e,ke.Subject),t!==null&&i.addPaths(t,ke.Clip),i.execute(n,r,s),s}function Gn(n,e,t,r,s=2,i=0){let o=new bt(s,i);o.addPaths(n,t,r);let a=[];return o.execute(e,a),a}var Ve=1e4;function St(){return{layers:new Map,parts:[]}}function Ge(n,e="cut"){return{layers:new Map([[e,{regions:n,lines:[]}]]),parts:[]}}function Ut(n,e="cut"){return{layers:new Map([[e,{regions:[],lines:n}]]),parts:[]}}function ii(n){if(n.parts.length)return!1;for(let e of n.layers.values())if(e.regions.length||e.lines.length)return!1;return!0}var oi=n=>n.map(e=>e.map(([t,r])=>({x:Math.round(t*Ve),y:Math.round(r*Ve)})));function bl(n){let e=(r,s,i)=>(s.x-r.x)*(i.y-s.y)-(s.y-r.y)*(i.x-s.x)===0,t=[];for(let r of n){for(;t.length>=2&&e(t[t.length-2],t[t.length-1],r);)t.pop();let s=t[t.length-1];(!s||s.x!==r.x||s.y!==r.y)&&t.push(r)}for(let r=!0;r&&t.length>=3;){let s=t.length;r=!0,t[s-1].x===t[0].x&&t[s-1].y===t[0].y||e(t[s-2],t[s-1],t[0])?t.pop():e(t[s-1],t[0],t[1])?t.shift():r=!1}return t}var tn=n=>oi(n).map(bl),nn=n=>n.filter(e=>e.length>=2).map(e=>e.map(t=>[t.x/Ve,t.y/Ve]));function be(n,e="nonzero"){if(!n.length)return[];let t=e==="evenodd"?q.EvenOdd:q.NonZero;return nn(Br(tn(n),t)).filter(r=>r.length>=3)}function ai(n,e,t){if(!e.length)return[];let r=new Ke;r.addSubject(tn(e)),t.length&&r.addClip(tn(t));let s=[];return r.execute(n,q.NonZero,s),nn(s).filter(i=>i.length>=3)}var $n=(n,e)=>e.length?ai(ie.Difference,n,e):be(n),zn=(n,e)=>ai(ie.Intersection,n,e);function rn(n,e,t){if(!n.length)return[];if(!e.length)return t==="outside"?n:[];let r=[];for(let g of e)for(let m=0;m<g.length;m++){let x=g[m],L=g[(m+1)%g.length];(x[0]!==L[0]||x[1]!==L[1])&&r.push([x,L])}if(!r.length)return t==="outside"?n:[];let s=on(e),i=Math.max(s[2]-s[0],s[3]-s[1],1e-6)/Math.max(1,Math.sqrt(r.length)),o=g=>Math.floor(g/i),a=new Map,l=new Map,u=(g,m,x)=>{let L=g.get(m);L?L[L.length-1]!==x&&L.push(x):g.set(m,[x])};r.forEach(([g,m],x)=>{let L=Math.max(1,Math.ceil(Math.hypot(m[0]-g[0],m[1]-g[1])/i*2));for(let b=0;b<=L;b++){let M=g[0]+(m[0]-g[0])*b/L,E=g[1]+(m[1]-g[1])*b/L;for(let O of[-1,0,1])for(let w of[-1,0,1])u(a,`${o(M)+O},${o(E)+w}`,x)}for(let b=o(Math.min(g[1],m[1]));b<=o(Math.max(g[1],m[1]));b++)u(l,b,x)});let c=(g,m)=>{let x=new Set,L=Math.max(1,Math.ceil(Math.hypot(m[0]-g[0],m[1]-g[1])/i*2));for(let b=0;b<=L;b++){let M=g[0]+(m[0]-g[0])*b/L,E=g[1]+(m[1]-g[1])*b/L;for(let O of a.get(`${o(M)},${o(E)}`)??[])x.add(O)}return x},h=.5/Ve,f=g=>{for(let x of a.get(`${o(g[0])},${o(g[1])}`)??[]){let[L,b]=r[x],M=b[0]-L[0],E=b[1]-L[1],O=Math.max(0,Math.min(1,((g[0]-L[0])*M+(g[1]-L[1])*E)/(M*M+E*E)));if(Math.hypot(g[0]-L[0]-O*M,g[1]-L[1]-O*E)<=h)return}let m=0;for(let x of l.get(o(g[1]))??[]){let[L,b]=r[x],M=(b[0]-L[0])*(g[1]-L[1])-(g[0]-L[0])*(b[1]-L[1]);L[1]<=g[1]?b[1]>g[1]&&M>0&&m++:b[1]<=g[1]&&M<0&&m--}return m!==0},p=g=>Math.round(g*Ve)/Ve,d=[];for(let g of n){let m=null,x=()=>{m&&m.length>=2&&d.push(m),m=null};for(let L=1;L<g.length;L++){let b=g[L-1],M=g[L],E=M[0]-b[0],O=M[1]-b[1];if(!E&&!O)continue;let w=[0,1];for(let T of c(b,M)){let[U,S]=r[T],A=S[0]-U[0],W=S[1]-U[1],j=E*W-O*A;if(Math.abs(j)>1e-15){let H=((U[0]-b[0])*W-(U[1]-b[1])*A)/j,_=((U[0]-b[0])*O-(U[1]-b[1])*E)/j;H>0&&H<1&&_>=0&&_<=1&&w.push(H)}else{let H=E*E+O*O;for(let _ of[U,S]){let $=((_[0]-b[0])*E+(_[1]-b[1])*O)/H,te=Math.abs((_[0]-b[0])*O-(_[1]-b[1])*E)/Math.sqrt(H);$>0&&$<1&&te<=h&&w.push($)}}}w.sort((T,U)=>T-U);for(let T=1;T<w.length;T++){if(w[T]-w[T-1]<1e-12)continue;let U=[p(b[0]+E*w[T-1]),p(b[1]+O*w[T-1])],S=[p(b[0]+E*w[T]),p(b[1]+O*w[T])],A=(w[T-1]+w[T])/2,W=f([b[0]+E*A,b[1]+O*A]);if(W!==void 0&&W===(t==="inside")){let j=m?m[m.length-1]:void 0;m&&j&&j[0]===U[0]&&j[1]===U[1]?(S[0]!==j[0]||S[1]!==j[1])&&m.push(S):(x(),m=[U,S])}else x()}}x()}return d}function Hn(n,e,t="round",r=.01){if(!n.length)return[];if(e===0)return be(n);let s=t==="round"?Ie.Round:t==="square"?Ie.Square:Ie.Miter,i=Gn(tn(be(n)),e*Ve,s,fe.Polygon,2,r*Ve);return nn(i).filter(o=>o.length>=3)}function li(n,e){if(!n.length||e<=0)return[];let t=Gn(oi(n),e/2*Ve,Ie.Round,fe.Round,2,.01*Ve);return nn(t)}function ui(n){if(!n.length)return[];let e=new en,t=new Ke;t.addSubject(tn(n)),t.execute(ie.Union,q.NonZero,e);let r=[],s=i=>{for(let o=0;o<i.count;o++){let a=i.child(o),l=[a.poly];for(let u=0;u<a.count;u++){let c=a.child(u);l.push(c.poly),s(c)}r.push(nn(l))}};return s(e),r}function lt(n){let e=0;for(let t=0,r=n.length-1;t<n.length;r=t++)e+=(n[r][0]+n[t][0])*(n[r][1]-n[t][1]);return-e/2}function ni(n,[e,t]){return[n[0]*e+n[2]*t+n[4],n[1]*e+n[3]*t+n[5]]}function ri(n,e){let t=e[0]*e[3]-e[1]*e[2]<0,r=new Map;for(let[s,i]of n)r.set(s,{regions:i.regions.map(o=>{let a=o.map(l=>ni(e,l));return t?a.reverse():a}),lines:i.lines.map(o=>o.map(a=>ni(e,a)))});return r}function Vn(n,e){return{layers:ri(n.layers,e),parts:n.parts.map(t=>({...t,layers:ri(t.layers,e)}))}}function sn(n){let e=St();for(let t of n){for(let[r,s]of t.layers){let i=e.layers.get(r)??{regions:[],lines:[]};for(let o of s.regions)i.regions.push(o);for(let o of s.lines)i.lines.push(o);e.layers.set(r,i)}for(let r of t.parts)e.parts.push(r)}return e}function si(n,e){let t={regions:[],lines:[]};for(let r of n.values()){for(let s of r.regions)t.regions.push(s);for(let s of r.lines)t.lines.push(s)}return new Map([[e,t]])}function qn(n,e){if(n.parts.length&&e!=="guide")throw new Error(`a part cannot go on the ${e} layer as a whole. Put ${e}() inside part() instead.`);return{layers:si(n.layers,e),parts:n.parts.map(t=>({...t,layers:si(t.layers,e)}))}}function on(n){let e=1/0,t=1/0,r=-1/0,s=-1/0;for(let i of n)for(let[o,a]of i)o<e&&(e=o),a<t&&(t=a),o>r&&(r=o),a>s&&(s=a);return e===1/0?null:[e,t,r,s]}function Gr(n,e){let t=[];for(let[r,s]of n)if(!e?.(r))for(let i of[...s.regions,...s.lines])t.push(i);return on(t)}function ci(n){let e=[...n].sort((i,o)=>i[0]-o[0]||i[1]-o[1]);if(e.length<3)return e;let t=(i,o,a)=>(o[0]-i[0])*(a[1]-i[1])-(o[1]-i[1])*(a[0]-i[0]),r=[];for(let i of e){for(;r.length>=2&&t(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}let s=[];for(let i=e.length-1;i>=0;i--){let o=e[i];for(;s.length>=2&&t(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return s.pop(),r.pop(),r.concat(s)}function fi(n,e,t,r){return n<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/t,n*2*Math.PI/r)),5)}function Xn(n,e,t){let r=[];for(let s=0;s<t;s++){let i=2*Math.PI*s/t;r.push([n*Math.cos(i),e*Math.sin(i)])}return r}function hi(n,e,t,r){if(t=Math.min(t,n/2,e/2),t<=0)return[[0,0],[n,0],[n,e],[0,e]];let s=Math.max(1,Math.ceil(r(t)/4)),i=[],o=[[n-t,t,-90],[n-t,e-t,0],[t,e-t,90],[t,t,180]];for(let[a,l,u]of o)for(let c=0;c<=s;c++){let h=(u+90*c/s)*Math.PI/180;i.push([a+t*Math.cos(h),l+t*Math.sin(h)])}return i}function Wn(n,e){let t=Math.round(n/e);return t%2===0&&(t+=n/e>t?1:-1),Math.max(3,t)}var an=(n,e,t,r)=>[[n,e],[t,e],[t,r],[n,r]];function Sl(n,e,t,r){if(e==="flat")return[];let s=Wn(n,r),i=n/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===1:a%2===0)&&o.push(an(a*i,-1,(a+1)*i,t));return o}function pi(n,e,t,r,s){let i=[([l,u])=>[l,u],([l,u])=>[n-u,l],([l,u])=>[n-l,e-u],([l,u])=>[u,e-l]],o=[n,e,n,e],a=[];return t.forEach((l,u)=>{for(let c of Sl(o[u],l,r,s))a.push(c.map(i[u]))}),$n([an(0,0,n,e)],a)}function di(n,e,t,r){let s=Wn(n,r),i=n/s,o=[];for(let a=0;a<s;a++)(e==="out"?a%2===0:a%2===1)&&o.push(an(a*i,-t/2,(a+1)*i,t/2));return o}function gi(n,e,t,r,s){let i=an(-n/2,-1,n/2,e),o=an(-t/2,s,t/2,s+r);return[i,o]}function mi(n,e,t,r,s){let i=[],o=s+r,a=Math.floor(n/t),l=(n-a*t)/2;for(let u=0;u<=a;u++){let c=l+u*t,h=u%2===0?r:r-o/2;for(let f=h;f<e;f+=o){let p=Math.max(f,u%2===0?r:0),d=Math.min(f+s,e-(u%2===0?r:0));d-p>=r/2&&i.push([[c,p],[c,d]])}}return i}function _n(n,e=.02){let t=[],r=[],s=[],i=[0,0],o=[0,0],a=u=>{s.length>=2&&(u?t:r).push(s),s=[]},l=u=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(u/e))));for(let u of n)if(u.type==="M")a(!1),i=o=[u.x,u.y],s=[o];else if(u.type==="L")o=[u.x,u.y],s.push(o);else if(u.type==="Q"){let[c,h]=o,f=l(Math.hypot(u.x1-c,u.y1-h)+Math.hypot(u.x-u.x1,u.y-u.y1));for(let p=1;p<=f;p++){let d=p/f,g=1-d;s.push([g*g*c+2*g*d*u.x1+d*d*u.x,g*g*h+2*g*d*u.y1+d*d*u.y])}o=[u.x,u.y]}else if(u.type==="C"){let[c,h]=o,f=l(Math.hypot(u.x1-c,u.y1-h)+Math.hypot(u.x2-u.x1,u.y2-u.y1)+Math.hypot(u.x-u.x2,u.y-u.y2));for(let p=1;p<=f;p++){let d=p/f,g=1-d;s.push([g*g*g*c+3*g*g*d*u.x1+3*g*d*d*u.x2+d*d*d*u.x,g*g*g*h+3*g*g*d*u.y1+3*g*d*d*u.y2+d*d*d*u.y])}o=[u.x,u.y]}else a(!0),o=i,s=[i];return a(!1),{closed:t,open:r}}function vi(n,e=Math.PI/2,t){let r=M=>/^[a-zA-Z]$/.test(M),s=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],i=[],o=0,a="",l=0,u=0,c=0,h=0,f=0,p=0,d=0,g=0,m="",x=()=>{let M=s[o++];if(M===void 0||r(M))throw new Error(`Bad path data near "${M??"end"}"`);return Number(M)},L=()=>{let M=s[o];if(M===void 0)throw new Error("Bad path data: missing arc flag");return M.length>1&&(M[0]==="0"||M[0]==="1")&&!M.includes(".")?(s[o]=M.slice(1),Number(M[0])):(o++,Number(M))};try{b()}catch(M){if(!t)throw M;t(M.message)}return i;function b(){for(;o<s.length;){if(r(s[o]))a=s[o++];else if(a){if(a==="Z"||a==="z")throw new Error(`Bad path data near "${s[o]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let M=a===a.toLowerCase(),E=a.toUpperCase(),O=M?l:0,w=M?u:0;if(E==="M")l=O+x(),u=w+x(),c=l,h=u,i.push({type:"M",x:l,y:u}),a=M?"l":"L";else if(E==="L")l=O+x(),u=w+x(),i.push({type:"L",x:l,y:u});else if(E==="H")l=O+x(),i.push({type:"L",x:l,y:u});else if(E==="V")u=w+x(),i.push({type:"L",x:l,y:u});else if(E==="C"||E==="S"){let T,U;if(E==="C")T=O+x(),U=w+x();else{let W=m==="C"||m==="S";T=W?2*l-f:l,U=W?2*u-p:u}let S=O+x(),A=w+x();l=O+x(),u=w+x(),f=S,p=A,i.push({type:"C",x1:T,y1:U,x2:S,y2:A,x:l,y:u})}else if(E==="Q"||E==="T"){let T,U;if(E==="Q")T=O+x(),U=w+x();else{let S=m==="Q"||m==="T";T=S?2*l-d:l,U=S?2*u-g:u}l=O+x(),u=w+x(),d=T,g=U,i.push({type:"Q",x1:T,y1:U,x:l,y:u})}else if(E==="A"){let T=x(),U=x(),S=x(),A=L(),W=L(),j=O+x(),H=w+x();i.push(...wl(l,u,T,U,S,A,W,j,H,e)),l=j,u=H}else if(E==="Z")i.push({type:"Z"}),l=c,u=h;else throw new Error(`Unknown path command "${a}"`);m=E}}}function wl(n,e,t,r,s,i,o,a,l,u=Math.PI/2){if(t===0||r===0||n===a&&e===l)return[{type:"L",x:a,y:l}];t=Math.abs(t),r=Math.abs(r);let c=s*Math.PI/180,h=Math.cos(c),f=Math.sin(c),p=(n-a)/2,d=(e-l)/2,g=h*p+f*d,m=-f*p+h*d,x=g*g/(t*t)+m*m/(r*r);x>1&&(t*=Math.sqrt(x),r*=Math.sqrt(x));let L=t*t*r*r-t*t*m*m-r*r*g*g,b=t*t*m*m+r*r*g*g,M=Math.sqrt(Math.max(0,L/b));i===o&&(M=-M);let E=M*t*m/r,O=-M*r*g/t,w=h*E-f*O+(n+a)/2,T=f*E+h*O+(e+l)/2,U=($,te,re,ne)=>Math.atan2($*ne-te*re,$*re+te*ne),S=U(1,0,(g-E)/t,(m-O)/r),A=U((g-E)/t,(m-O)/r,(-g-E)/t,(-m-O)/r);!o&&A>0&&(A-=2*Math.PI),o&&A<0&&(A+=2*Math.PI);let W=Math.ceil(Math.abs(A)/u),j=[],H=$=>[w+t*Math.cos($)*h-r*Math.sin($)*f,T+t*Math.cos($)*f+r*Math.sin($)*h],_=$=>[-t*Math.sin($)*h-r*Math.cos($)*f,-t*Math.sin($)*f+r*Math.cos($)*h];for(let $=0;$<W;$++){let te=S+A*$/W,re=S+A*($+1)/W,ne=4/3*Math.tan((re-te)/4),de=H(te),Q=H(re),I=_(te),B=_(re);j.push({type:"C",x1:de[0]+ne*I[0],y1:de[1]+ne*I[1],x2:Q[0]-ne*B[0],y2:Q[1]-ne*B[1],x:Q[0],y:Q[1]})}return j}String.prototype.codePointAt||(function(){var n=(function(){try{var t={},r=Object.defineProperty,s=r(t,t,t)&&r}catch{}return s})(),e=function(t){if(this==null)throw TypeError();var r=String(this),s=r.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=s)){var o=r.charCodeAt(i),a;return o>=55296&&o<=56319&&s>i+1&&(a=r.charCodeAt(i+1),a>=56320&&a<=57343)?(o-55296)*1024+a-56320+65536:o}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();var ss=0,io=-3;function cn(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function kl(n,e){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new cn,this.dtree=new cn}var oo=new cn,ao=new cn,is=new Uint8Array(30),os=new Uint16Array(30),lo=new Uint8Array(30),uo=new Uint16Array(30),El=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bi=new cn,Je=new Uint8Array(320);function co(n,e,t,r){var s,i;for(s=0;s<t;++s)n[s]=0;for(s=0;s<30-t;++s)n[s+t]=s/t|0;for(i=r,s=0;s<30;++s)e[s]=i,i+=1<<n[s]}function Pl(n,e){var t;for(t=0;t<7;++t)n.table[t]=0;for(n.table[7]=24,n.table[8]=152,n.table[9]=112,t=0;t<24;++t)n.trans[t]=256+t;for(t=0;t<144;++t)n.trans[24+t]=t;for(t=0;t<8;++t)n.trans[168+t]=280+t;for(t=0;t<112;++t)n.trans[176+t]=144+t;for(t=0;t<5;++t)e.table[t]=0;for(e.table[5]=32,t=0;t<32;++t)e.trans[t]=t}var Si=new Uint16Array(16);function $r(n,e,t,r){var s,i;for(s=0;s<16;++s)n.table[s]=0;for(s=0;s<r;++s)n.table[e[t+s]]++;for(n.table[0]=0,i=0,s=0;s<16;++s)Si[s]=i,i+=n.table[s];for(s=0;s<r;++s)e[t+s]&&(n.trans[Si[e[t+s]]++]=s)}function Ll(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var e=n.tag&1;return n.tag>>>=1,e}function Qe(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var r=n.tag&65535>>>16-e;return n.tag>>>=e,n.bitcount-=e,r+t}function Zr(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var t=0,r=0,s=0,i=n.tag;do r=2*r+(i&1),i>>>=1,++s,t+=e.table[s],r-=e.table[s];while(r>=0);return n.tag=i,n.bitcount-=s,e.trans[t+r]}function Tl(n,e,t){var r,s,i,o,a,l;for(r=Qe(n,5,257),s=Qe(n,5,1),i=Qe(n,4,4),o=0;o<19;++o)Je[o]=0;for(o=0;o<i;++o){var u=Qe(n,3,0);Je[El[o]]=u}for($r(bi,Je,0,19),a=0;a<r+s;){var c=Zr(n,bi);switch(c){case 16:var h=Je[a-1];for(l=Qe(n,2,3);l;--l)Je[a++]=h;break;case 17:for(l=Qe(n,3,3);l;--l)Je[a++]=0;break;case 18:for(l=Qe(n,7,11);l;--l)Je[a++]=0;break;default:Je[a++]=c;break}}$r(e,Je,0,r),$r(t,Je,r,s)}function wi(n,e,t){for(;;){var r=Zr(n,e);if(r===256)return ss;if(r<256)n.dest[n.destLen++]=r;else{var s,i,o,a;for(r-=257,s=Qe(n,is[r],os[r]),i=Zr(n,t),o=n.destLen-Qe(n,lo[i],uo[i]),a=o;a<o+s;++a)n.dest[n.destLen++]=n.dest[a]}}}function Il(n){for(var e,t,r;n.bitcount>8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return io;for(n.sourceIndex+=4,r=e;r;--r)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,ss}function Ml(n,e){var t=new kl(n,e),r,s,i;do{switch(r=Ll(t),s=Qe(t,2,0),s){case 0:i=Il(t);break;case 1:i=wi(t,oo,ao);break;case 2:Tl(t,t.ltree,t.dtree),i=wi(t,t.ltree,t.dtree);break;default:i=io}if(i!==ss)throw new Error("Data error")}while(!r);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}Pl(oo,ao);co(is,os,4,3);co(lo,uo,2,1);is[28]=0;os[28]=258;var Cl=Ml;function Nt(n,e,t,r,s){return Math.pow(1-s,3)*n+3*Math.pow(1-s,2)*s*e+3*(1-s)*Math.pow(s,2)*t+Math.pow(s,3)*r}function gt(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}gt.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};gt.prototype.addPoint=function(n,e){typeof n=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=n,this.x2=n),n<this.x1&&(this.x1=n),n>this.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))};gt.prototype.addX=function(n){this.addPoint(n,null)};gt.prototype.addY=function(n){this.addPoint(null,n)};gt.prototype.addBezier=function(n,e,t,r,s,i,o,a){var l=[n,e],u=[t,r],c=[s,i],h=[o,a];this.addPoint(n,e),this.addPoint(o,a);for(var f=0;f<=1;f++){var p=6*l[f]-12*u[f]+6*c[f],d=-3*l[f]+9*u[f]-9*c[f]+3*h[f],g=3*u[f]-3*l[f];if(d===0){if(p===0)continue;var m=-g/p;0<m&&m<1&&(f===0&&this.addX(Nt(l[f],u[f],c[f],h[f],m)),f===1&&this.addY(Nt(l[f],u[f],c[f],h[f],m)));continue}var x=Math.pow(p,2)-4*g*d;if(!(x<0)){var L=(-p+Math.sqrt(x))/(2*d);0<L&&L<1&&(f===0&&this.addX(Nt(l[f],u[f],c[f],h[f],L)),f===1&&this.addY(Nt(l[f],u[f],c[f],h[f],L)));var b=(-p-Math.sqrt(x))/(2*d);0<b&&b<1&&(f===0&&this.addX(Nt(l[f],u[f],c[f],h[f],b)),f===1&&this.addY(Nt(l[f],u[f],c[f],h[f],b)))}}};gt.prototype.addQuad=function(n,e,t,r,s,i){var o=n+.6666666666666666*(t-n),a=e+2/3*(r-e),l=o+1/3*(s-n),u=a+1/3*(i-e);this.addBezier(n,e,o,a,l,u,s,i)};function ye(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}ye.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};ye.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};ye.prototype.curveTo=ye.prototype.bezierCurveTo=function(n,e,t,r,s,i){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:r,x:s,y:i})};ye.prototype.quadTo=ye.prototype.quadraticCurveTo=function(n,e,t,r){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:r})};ye.prototype.close=ye.prototype.closePath=function(){this.commands.push({type:"Z"})};ye.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof gt){var e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};ye.prototype.getBoundingBox=function(){for(var n=new gt,e=0,t=0,r=0,s=0,i=0;i<this.commands.length;i++){var o=this.commands[i];switch(o.type){case"M":n.addPoint(o.x,o.y),e=r=o.x,t=s=o.y;break;case"L":n.addPoint(o.x,o.y),r=o.x,s=o.y;break;case"Q":n.addQuad(r,s,o.x1,o.y1,o.x,o.y),r=o.x,s=o.y;break;case"C":n.addBezier(r,s,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,s=o.y;break;case"Z":r=e,s=t;break;default:throw new Error("Unexpected path command "+o.type)}}return n.isEmpty()&&n.addPoint(0,0),n};ye.prototype.draw=function(n){n.beginPath();for(var e=0;e<this.commands.length;e+=1){var t=this.commands[e];t.type==="M"?n.moveTo(t.x,t.y):t.type==="L"?n.lineTo(t.x,t.y):t.type==="C"?n.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?n.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&n.closePath()}this.fill&&(n.fillStyle=this.fill,n.fill()),this.stroke&&(n.strokeStyle=this.stroke,n.lineWidth=this.strokeWidth,n.stroke())};ye.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(o){return Math.round(o)===o?""+Math.round(o):o.toFixed(n)}function t(){for(var o=arguments,a="",l=0;l<arguments.length;l+=1){var u=o[l];u>=0&&l>0&&(a+=" "),a+=e(u)}return a}for(var r="",s=0;s<this.commands.length;s+=1){var i=this.commands[s];i.type==="M"?r+="M"+t(i.x,i.y):i.type==="L"?r+="L"+t(i.x,i.y):i.type==="C"?r+="C"+t(i.x1,i.y1,i.x2,i.y2,i.x,i.y):i.type==="Q"?r+="Q"+t(i.x1,i.y1,i.x,i.y):i.type==="Z"&&(r+="Z")}return r};ye.prototype.toSVG=function(n){var e='<path d="';return e+=this.toPathData(n),e+='"',this.fill&&this.fill!=="black"&&(this.fill===null?e+=' fill="none"':e+=' fill="'+this.fill+'"'),this.stroke&&(e+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),e+="/>",e};ye.prototype.toDOMElement=function(n){var e=this.toPathData(n),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function fo(n){throw new Error(n)}function ki(n,e){n||fo(e)}var G={fail:fo,argument:ki,assert:ki},Ei=32768,Pi=2147483648,Gt={},C={},z={};function _e(n){return function(){return n}}C.BYTE=function(n){return G.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]};z.BYTE=_e(1);C.CHAR=function(n){return[n.charCodeAt(0)]};z.CHAR=_e(1);C.CHARARRAY=function(n){typeof n>"u"&&(n="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var e=[],t=0;t<n.length;t+=1)e[t]=n.charCodeAt(t);return e};z.CHARARRAY=function(n){return typeof n>"u"?0:n.length};C.USHORT=function(n){return[n>>8&255,n&255]};z.USHORT=_e(2);C.SHORT=function(n){return n>=Ei&&(n=-(2*Ei-n)),[n>>8&255,n&255]};z.SHORT=_e(2);C.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};z.UINT24=_e(3);C.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};z.ULONG=_e(4);C.LONG=function(n){return n>=Pi&&(n=-(2*Pi-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};z.LONG=_e(4);C.FIXED=C.ULONG;z.FIXED=z.ULONG;C.FWORD=C.SHORT;z.FWORD=z.SHORT;C.UFWORD=C.USHORT;z.UFWORD=z.USHORT;C.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]};z.LONGDATETIME=_e(8);C.TAG=function(n){return G.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};z.TAG=_e(4);C.Card8=C.BYTE;z.Card8=z.BYTE;C.Card16=C.USHORT;z.Card16=z.USHORT;C.OffSize=C.BYTE;z.OffSize=z.BYTE;C.SID=C.USHORT;z.SID=z.USHORT;C.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?C.NUMBER16(n):C.NUMBER32(n)};z.NUMBER=function(n){return C.NUMBER(n).length};C.NUMBER16=function(n){return[28,n>>8&255,n&255]};z.NUMBER16=_e(3);C.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};z.NUMBER32=_e(5);C.REAL=function(n){var e=n.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}for(var s="",i=0,o=e.length;i<o;i+=1){var a=e[i];a==="e"?s+=e[++i]==="-"?"c":"b":a==="."?s+="a":a==="-"?s+="e":s+=a}s+=s.length&1?"f":"ff";for(var l=[30],u=0,c=s.length;u<c;u+=2)l.push(parseInt(s.substr(u,2),16));return l};z.REAL=function(n){return C.REAL(n).length};C.NAME=C.CHARARRAY;z.NAME=z.CHARARRAY;C.STRING=C.CHARARRAY;z.STRING=z.CHARARRAY;Gt.UTF8=function(n,e,t){for(var r=[],s=t,i=0;i<s;i++,e+=1)r[i]=n.getUint8(e);return String.fromCharCode.apply(null,r)};Gt.UTF16=function(n,e,t){for(var r=[],s=t/2,i=0;i<s;i++,e+=2)r[i]=n.getUint16(e);return String.fromCharCode.apply(null,r)};C.UTF16=function(n){for(var e=[],t=0;t<n.length;t+=1){var r=n.charCodeAt(t);e[e.length]=r>>8&255,e[e.length]=r&255}return e};z.UTF16=function(n){return n.length*2};var Yr={"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"};Gt.MACSTRING=function(n,e,t,r){var s=Yr[r];if(s!==void 0){for(var i="",o=0;o<t;o++){var a=n.getUint8(e+o);a<=127?i+=String.fromCharCode(a):i+=s[a&127]}return i}};var jn=typeof WeakMap=="function"&&new WeakMap,Zn,Al=function(n){if(!Zn){Zn={};for(var e in Yr)Zn[e]=new String(e)}var t=Zn[n];if(t!==void 0){if(jn){var r=jn.get(t);if(r!==void 0)return r}var s=Yr[n];if(s!==void 0){for(var i={},o=0;o<s.length;o++)i[s.charCodeAt(o)]=o+128;return jn&&jn.set(t,i),i}}};C.MACSTRING=function(n,e){var t=Al(e);if(t!==void 0){for(var r=[],s=0;s<n.length;s++){var i=n.charCodeAt(s);if(i>=128&&(i=t[i],i===void 0))return;r[s]=i}return r}};z.MACSTRING=function(n,e){var t=C.MACSTRING(n,e);return t!==void 0?t.length:0};function Kr(n){return n>=-128&&n<=127}function Ol(n,e,t){for(var r=0,s=n.length;e<s&&r<64&&n[e]===0;)++e,++r;return t.push(128|r-1),e}function Fl(n,e,t){for(var r=0,s=n.length,i=e;i<s&&r<64;){var o=n[i];if(!Kr(o)||o===0&&i+1<s&&n[i+1]===0)break;++i,++r}t.push(r-1);for(var a=e;a<i;++a)t.push(n[a]+256&255);return i}function Dl(n,e,t){for(var r=0,s=n.length,i=e;i<s&&r<64;){var o=n[i];if(o===0||Kr(o)&&i+1<s&&Kr(n[i+1]))break;++i,++r}t.push(64|r-1);for(var a=e;a<i;++a){var l=n[a];t.push(l+65536>>8&255,l+256&255)}return i}C.VARDELTAS=function(n){for(var e=0,t=[];e<n.length;){var r=n[e];r===0?e=Ol(n,e,t):r>=-128&&r<=127?e=Fl(n,e,t):e=Dl(n,e,t)}return t};C.INDEX=function(n){for(var e=1,t=[e],r=[],s=0;s<n.length;s+=1){var i=C.OBJECT(n[s]);Array.prototype.push.apply(r,i),e+=i.length,t.push(e)}if(r.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,l=[void 0,C.BYTE,C.USHORT,C.UINT24,C.ULONG][a],u=0;u<t.length;u+=1){var c=l(t[u]);Array.prototype.push.apply(o,c)}return Array.prototype.concat(C.Card16(n.length),C.OffSize(a),o,r)};z.INDEX=function(n){return C.INDEX(n).length};C.DICT=function(n){for(var e=[],t=Object.keys(n),r=t.length,s=0;s<r;s+=1){var i=parseInt(t[s],0),o=n[i];e=e.concat(C.OPERAND(o.value,o.type)),e=e.concat(C.OPERATOR(i))}return e};z.DICT=function(n){return C.DICT(n).length};C.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]};C.OPERAND=function(n,e){var t=[];if(Array.isArray(e))for(var r=0;r<e.length;r+=1)G.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(C.OPERAND(n[r],e[r]));else if(e==="SID")t=t.concat(C.NUMBER(n));else if(e==="offset")t=t.concat(C.NUMBER32(n));else if(e==="number")t=t.concat(C.NUMBER(n));else if(e==="real")t=t.concat(C.REAL(n));else throw new Error("Unknown operand type "+e);return t};C.OP=C.BYTE;z.OP=z.BYTE;var Yn=typeof WeakMap=="function"&&new WeakMap;C.CHARSTRING=function(n){if(Yn){var e=Yn.get(n);if(e!==void 0)return e}for(var t=[],r=n.length,s=0;s<r;s+=1){var i=n[s];t=t.concat(C[i.type](i.value))}return Yn&&Yn.set(n,t),t};z.CHARSTRING=function(n){return C.CHARSTRING(n).length};C.OBJECT=function(n){var e=C[n.type];return G.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)};z.OBJECT=function(n){var e=z[n.type];return G.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)};C.TABLE=function(n){for(var e=[],t=n.fields.length,r=[],s=[],i=0;i<t;i+=1){var o=n.fields[i],a=C[o.type];G.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var l=n[o.name];l===void 0&&(l=o.value);var u=a(l);o.type==="TABLE"?(s.push(e.length),e=e.concat([0,0]),r.push(u)):e=e.concat(u)}for(var c=0;c<r.length;c+=1){var h=s[c],f=e.length;G.argument(f<65536,"Table "+n.tableName+" too big."),e[h]=f>>8,e[h+1]=f&255,e=e.concat(r[c])}return e};z.TABLE=function(n){for(var e=0,t=n.fields.length,r=0;r<t;r+=1){var s=n.fields[r],i=z[s.type];G.argument(i!==void 0,"No sizeOf function for field type "+s.type+" ("+s.name+")");var o=n[s.name];o===void 0&&(o=s.value),e+=i(o),s.type==="TABLE"&&(e+=2)}return e};C.RECORD=C.TABLE;z.RECORD=z.TABLE;C.LITERAL=function(n){return n};z.LITERAL=function(n){return n.length};function Se(n,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var r=0;r<e.length;r+=1){var s=e[r];this[s.name]=s.value}if(this.tableName=n,this.fields=e,t)for(var i=Object.keys(t),o=0;o<i.length;o+=1){var a=i[o],l=t[a];this[a]!==void 0&&(this[a]=l)}}Se.prototype.encode=function(){return C.TABLE(this)};Se.prototype.sizeOf=function(){return z.TABLE(this)};function fn(n,e,t){t===void 0&&(t=e.length);var r=new Array(e.length+1);r[0]={name:n+"Count",type:"USHORT",value:t};for(var s=0;s<e.length;s++)r[s+1]={name:n+s,type:"USHORT",value:e[s]};return r}function Jr(n,e,t){var r=e.length,s=new Array(r+1);s[0]={name:n+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s[i+1]={name:n+i,type:"TABLE",value:t(e[i],i)};return s}function hn(n,e,t){var r=e.length,s=[];s[0]={name:n+"Count",type:"USHORT",value:r};for(var i=0;i<r;i++)s=s.concat(t(e[i],i));return s}function tr(n){n.format===1?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(fn("glyph",n.glyphs))):n.format===2?Se.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(hn("rangeRecord",n.ranges,function(e){return[{name:"startGlyphID",type:"USHORT",value:e.start},{name:"endGlyphID",type:"USHORT",value:e.end},{name:"startCoverageIndex",type:"USHORT",value:e.index}]}))):G.assert(!1,"Coverage format must be 1 or 2.")}tr.prototype=Object.create(Se.prototype);tr.prototype.constructor=tr;function nr(n){Se.call(this,"scriptListTable",hn("scriptRecord",n,function(e,t){var r=e.script,s=r.defaultLangSys;return G.assert(!!s,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Se("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Se("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:s.reqFeatureIndex}].concat(fn("featureIndex",s.featureIndexes)))}].concat(hn("langSys",r.langSysRecords,function(i,o){var a=i.langSys;return[{name:"langSysTag"+o,type:"TAG",value:i.tag},{name:"langSys"+o,type:"TABLE",value:new Se("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(fn("featureIndex",a.featureIndexes)))}]})))}]}))}nr.prototype=Object.create(Se.prototype);nr.prototype.constructor=nr;function rr(n){Se.call(this,"featureListTable",hn("featureRecord",n,function(e,t){var r=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Se("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(fn("lookupListIndex",r.lookupListIndexes)))}]}))}rr.prototype=Object.create(Se.prototype);rr.prototype.constructor=rr;function sr(n,e){Se.call(this,"lookupListTable",Jr("lookup",n,function(t){var r=e[t.lookupType];return G.assert(!!r,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new Se("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Jr("subtable",t.subtables,r)))}))}sr.prototype=Object.create(Se.prototype);sr.prototype.constructor=sr;var F={Table:Se,Record:Se,Coverage:tr,ScriptList:nr,FeatureList:rr,LookupList:sr,ushortList:fn,tableList:Jr,recordList:hn};function Li(n,e){return n.getUint8(e)}function ir(n,e){return n.getUint16(e,!1)}function Rl(n,e){return n.getInt16(e,!1)}function as(n,e){return n.getUint32(e,!1)}function ho(n,e){var t=n.getInt16(e,!1),r=n.getUint16(e+2,!1);return t+r/65535}function Ul(n,e){for(var t="",r=e;r<e+4;r+=1)t+=String.fromCharCode(n.getInt8(r));return t}function Nl(n,e,t){for(var r=0,s=0;s<t;s+=1)r<<=8,r+=n.getUint8(e+s);return r}function Bl(n,e,t){for(var r=[],s=e;s<t;s+=1)r.push(n.getUint8(s));return r}function Gl(n){for(var e="",t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}var $l={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function y(n,e){this.data=n,this.offset=e,this.relativeOffset=0}y.prototype.parseByte=function(){var n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};y.prototype.parseChar=function(){var n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};y.prototype.parseCard8=y.prototype.parseByte;y.prototype.parseUShort=function(){var n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};y.prototype.parseCard16=y.prototype.parseUShort;y.prototype.parseSID=y.prototype.parseUShort;y.prototype.parseOffset16=y.prototype.parseUShort;y.prototype.parseShort=function(){var n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};y.prototype.parseF2Dot14=function(){var n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n};y.prototype.parseULong=function(){var n=as(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};y.prototype.parseOffset32=y.prototype.parseULong;y.prototype.parseFixed=function(){var n=ho(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};y.prototype.parseString=function(n){var e=this.data,t=this.offset+this.relativeOffset,r="";this.relativeOffset+=n;for(var s=0;s<n;s++)r+=String.fromCharCode(e.getUint8(t+s));return r};y.prototype.parseTag=function(){return this.parseString(4)};y.prototype.parseLongDateTime=function(){var n=as(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n};y.prototype.parseVersion=function(n){var e=ir(this.data,this.offset+this.relativeOffset),t=ir(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10};y.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=$l[n]*e};y.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getUint32(r),r+=4;return this.relativeOffset+=n*4,e};y.prototype.parseOffset16List=y.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getUint16(r),r+=2;return this.relativeOffset+=n*2,e};y.prototype.parseShortList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getInt16(r),r+=2;return this.relativeOffset+=n*2,e};y.prototype.parseByteList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,s=0;s<n;s++)e[s]=t.getUint8(r++);return this.relativeOffset+=n,e};y.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t};y.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t};y.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=Object.keys(e),s=0;s<n;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}t[s]=i}return t};y.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=Object.keys(e),s=0;s<n;s++){for(var i={},o=0;o<r.length;o++){var a=r[o],l=e[a];i[a]=l.call(this)}t[s]=i}return t};y.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);for(var e=Object.keys(n),t={},r=0;r<e.length;r++){var s=e[r],i=n[s];t[s]=i.call(this)}return t};y.prototype.parseValueRecord=function(n){if(n===void 0&&(n=this.parseUShort()),n!==0){var e={};return n&1&&(e.xPlacement=this.parseShort()),n&2&&(e.yPlacement=this.parseShort()),n&4&&(e.xAdvance=this.parseShort()),n&8&&(e.yAdvance=this.parseShort()),n&16&&(e.xPlaDevice=void 0,this.parseShort()),n&32&&(e.yPlaDevice=void 0,this.parseShort()),n&64&&(e.xAdvDevice=void 0,this.parseShort()),n&128&&(e.yAdvDevice=void 0,this.parseShort()),e}};y.prototype.parseValueRecordList=function(){for(var n=this.parseUShort(),e=this.parseUShort(),t=new Array(e),r=0;r<e;r++)t[r]=this.parseValueRecord(n);return t};y.prototype.parsePointer=function(n){var e=this.parseOffset16();if(e>0)return new y(this.data,this.offset+e).parseStruct(n)};y.prototype.parsePointer32=function(n){var e=this.parseOffset32();if(e>0)return new y(this.data,this.offset+e).parseStruct(n)};y.prototype.parseListOfLists=function(n){for(var e=this.parseOffset16List(),t=e.length,r=this.relativeOffset,s=new Array(t),i=0;i<t;i++){var o=e[i];if(o===0){s[i]=void 0;continue}if(this.relativeOffset=o,n){for(var a=this.parseOffset16List(),l=new Array(a.length),u=0;u<a.length;u++)this.relativeOffset=o+a[u],l[u]=n.call(this);s[i]=l}else s[i]=this.parseUShortList()}return this.relativeOffset=r,s};y.prototype.parseCoverage=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){for(var r=new Array(t),s=0;s<t;s++)r[s]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")};y.prototype.parseClassDef=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(e===2)return{format:2,ranges:this.parseRecordList({start:y.uShort,end:y.uShort,classId:y.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")};y.list=function(n,e){return function(){return this.parseList(n,e)}};y.list32=function(n,e){return function(){return this.parseList32(n,e)}};y.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}};y.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}};y.pointer=function(n){return function(){return this.parsePointer(n)}};y.pointer32=function(n){return function(){return this.parsePointer32(n)}};y.tag=y.prototype.parseTag;y.byte=y.prototype.parseByte;y.uShort=y.offset16=y.prototype.parseUShort;y.uShortList=y.prototype.parseUShortList;y.uLong=y.offset32=y.prototype.parseULong;y.uLongList=y.prototype.parseULongList;y.struct=y.prototype.parseStruct;y.coverage=y.prototype.parseCoverage;y.classDef=y.prototype.parseClassDef;var Ti={reserved:y.uShort,reqFeatureIndex:y.uShort,featureIndexes:y.uShortList};y.prototype.parseScriptList=function(){return this.parsePointer(y.recordList({tag:y.tag,script:y.pointer({defaultLangSys:y.pointer(Ti),langSysRecords:y.recordList({tag:y.tag,langSys:y.pointer(Ti)})})}))||[]};y.prototype.parseFeatureList=function(){return this.parsePointer(y.recordList({tag:y.tag,feature:y.pointer({featureParams:y.offset16,lookupListIndexes:y.uShortList})}))||[]};y.prototype.parseLookupList=function(n){return this.parsePointer(y.list(y.pointer(function(){var e=this.parseUShort();G.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),r=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(y.pointer(n[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]};y.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var n=this.parseUShort(),e=this.parseUShort();G.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:y.offset32,featureTableSubstitutionOffset:y.offset32});return t})||[]};var R={getByte:Li,getCard8:Li,getUShort:ir,getCard16:ir,getShort:Rl,getULong:as,getFixed:ho,getTag:Ul,getOffset:Nl,getBytes:Bl,bytesToString:Gl,Parser:y};function zl(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();var t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(var r=0;r<t;r+=1)for(var s=e.parseULong(),i=e.parseULong(),o=e.parseULong(),a=s;a<=i;a+=1)n.glyphIndexMap[a]=o,o++}function Hl(n,e,t,r,s){n.length=e.parseUShort(),n.language=e.parseUShort();var i;n.segCount=i=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};for(var o=new R.Parser(t,r+s+14),a=new R.Parser(t,r+s+16+i*2),l=new R.Parser(t,r+s+16+i*4),u=new R.Parser(t,r+s+16+i*6),c=r+s+16+i*8,h=0;h<i-1;h+=1)for(var f=void 0,p=o.parseUShort(),d=a.parseUShort(),g=l.parseShort(),m=u.parseUShort(),x=d;x<=p;x+=1)m!==0?(c=u.offset+u.relativeOffset-2,c+=m,c+=(x-d)*2,f=R.getUShort(t,c),f!==0&&(f=f+g&65535)):f=x+g&65535,n.glyphIndexMap[x]=f}function Vl(n,e){var t={};t.version=R.getUShort(n,e),G.argument(t.version===0,"cmap table version should be 0."),t.numTables=R.getUShort(n,e+2);for(var r=-1,s=t.numTables-1;s>=0;s-=1){var i=R.getUShort(n,e+4+s*8),o=R.getUShort(n,e+4+s*8+2);if(i===3&&(o===0||o===1||o===10)||i===0&&(o===0||o===1||o===2||o===3||o===4)){r=R.getULong(n,e+4+s*8+4);break}}if(r===-1)throw new Error("No valid cmap sub-tables found.");var a=new R.Parser(n,e+r);if(t.format=a.parseUShort(),t.format===12)zl(t,a);else if(t.format===4)Hl(t,a,n,e,r);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function ql(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Xl(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Wl(n){var e=!0,t;for(t=n.length-1;t>0;t-=1){var r=n.get(t);if(r.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var s=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||(s=s.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),s=s.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var i=new F.Table("cmap",s);for(i.segments=[],t=0;t<n.length;t+=1){for(var o=n.get(t),a=0;a<o.unicodes.length;a+=1)ql(i,o.unicodes[a],t);i.segments=i.segments.sort(function(L,b){return L.start-b.start})}Xl(i);var l=i.segments.length,u=0,c=[],h=[],f=[],p=[],d=[],g=[];for(t=0;t<l;t+=1){var m=i.segments[t];m.end<=65535&&m.start<=65535?(c=c.concat({name:"end_"+t,type:"USHORT",value:m.end}),h=h.concat({name:"start_"+t,type:"USHORT",value:m.start}),f=f.concat({name:"idDelta_"+t,type:"SHORT",value:m.delta}),p=p.concat({name:"idRangeOffset_"+t,type:"USHORT",value:m.offset}),m.glyphId!==void 0&&(d=d.concat({name:"glyph_"+t,type:"USHORT",value:m.glyphId}))):u+=1,!e&&m.glyphIndex!==void 0&&(g=g.concat({name:"cmap12Start_"+t,type:"ULONG",value:m.start}),g=g.concat({name:"cmap12End_"+t,type:"ULONG",value:m.end}),g=g.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:m.glyphIndex}))}if(i.segCountX2=(l-u)*2,i.searchRange=Math.pow(2,Math.floor(Math.log(l-u)/Math.log(2)))*2,i.entrySelector=Math.log(i.searchRange/2)/Math.log(2),i.rangeShift=i.segCountX2-i.searchRange,i.fields=i.fields.concat(c),i.fields.push({name:"reservedPad",type:"USHORT",value:0}),i.fields=i.fields.concat(h),i.fields=i.fields.concat(f),i.fields=i.fields.concat(p),i.fields=i.fields.concat(d),i.cmap4Length=14+c.length*2+2+h.length*2+f.length*2+p.length*2+d.length*2,!e){var x=16+g.length*4;i.cmap12Offset=20+i.cmap4Length,i.fields=i.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:x},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:g.length/3}]),i.fields=i.fields.concat(g)}return i}var po={parse:Vl,make:Wl},Qn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],_l=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],jl=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],kt=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function go(n){this.font=n}go.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.font.glyphs;if(t){for(var r=0;r<t.length;r+=1)for(var s=t.get(r),i=0;i<s.unicodes.length;i+=1)if(s.unicodes[i]===e)return r}return null};function mo(n){this.cmap=n}mo.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function or(n,e){this.encoding=n,this.charset=e}or.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function ls(n){switch(n.version){case 1:this.names=kt.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(var e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<kt.length?this.names[e]=kt[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-kt.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(var t=0;t<n.numberOfGlyphs;t++)this.names[t]=kt[t+n.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}ls.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)};ls.prototype.glyphIndexToName=function(n){return this.names[n]};function Zl(n){for(var e,t=n.tables.cmap.glyphIndexMap,r=Object.keys(t),s=0;s<r.length;s+=1){var i=r[s],o=t[i];e=n.glyphs.get(o),e.addUnicode(parseInt(i))}for(var a=0;a<n.glyphs.length;a+=1)e=n.glyphs.get(a),n.cffEncoding?n.isCIDFont?e.name="gid"+a:e.name=n.cffEncoding.charset[a]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(a))}function Yl(n){n._IndexToUnicodeMap={};for(var e=n.tables.cmap.glyphIndexMap,t=Object.keys(e),r=0;r<t.length;r+=1){var s=t[r],i=e[s];n._IndexToUnicodeMap[i]===void 0?n._IndexToUnicodeMap[i]={unicodes:[parseInt(s)]}:n._IndexToUnicodeMap[i].unicodes.push(parseInt(s))}}function Kl(n,e){e.lowMemory?Yl(n):Zl(n)}function Jl(n,e,t,r,s){n.beginPath(),n.moveTo(e,t),n.lineTo(r,s),n.stroke()}var wt={line:Jl};function Ql(n,e){var t=e||new ye;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(r){t=r}}}function $e(n){this.bindConstructorValues(n)}$e.prototype.bindConstructorValues=function(n){this.index=n.index||0,this.name=n.name||null,this.unicode=n.unicode||void 0,this.unicodes=n.unicodes||n.unicode!==void 0?[n.unicode]:[],"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),Object.defineProperty(this,"path",Ql(this,n.path))};$e.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};$e.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};$e.prototype.getPath=function(n,e,t,r,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var i,o;r||(r={});var a=r.xScale,l=r.yScale;if(r.hinting&&s&&s.hinting&&(o=this.path&&s.hinting.exec(this,t)),o)i=s.hinting.getCommands(o),n=Math.round(n),e=Math.round(e),a=l=1;else{i=this.path.commands;var u=1/(this.path.unitsPerEm||1e3)*t;a===void 0&&(a=u),l===void 0&&(l=u)}for(var c=new ye,h=0;h<i.length;h+=1){var f=i[h];f.type==="M"?c.moveTo(n+f.x*a,e+-f.y*l):f.type==="L"?c.lineTo(n+f.x*a,e+-f.y*l):f.type==="Q"?c.quadraticCurveTo(n+f.x1*a,e+-f.y1*l,n+f.x*a,e+-f.y*l):f.type==="C"?c.curveTo(n+f.x1*a,e+-f.y1*l,n+f.x2*a,e+-f.y2*l,n+f.x*a,e+-f.y*l):f.type==="Z"&&c.closePath()}return c};$e.prototype.getContours=function(){if(this.points===void 0)return[];for(var n=[],e=[],t=0;t<this.points.length;t+=1){var r=this.points[t];e.push(r),r.lastPointOfContour&&(n.push(e),e=[])}return G.argument(e.length===0,"There are still points left in the current contour."),n};$e.prototype.getMetrics=function(){for(var n=this.path.commands,e=[],t=[],r=0;r<n.length;r+=1){var s=n[r];s.type!=="Z"&&(e.push(s.x),t.push(s.y)),(s.type==="Q"||s.type==="C")&&(e.push(s.x1),t.push(s.y1)),s.type==="C"&&(e.push(s.x2),t.push(s.y2))}var i={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,e),yMax:Math.max.apply(null,t),leftSideBearing:this.leftSideBearing};return isFinite(i.xMin)||(i.xMin=0),isFinite(i.xMax)||(i.xMax=this.advanceWidth),isFinite(i.yMin)||(i.yMin=0),isFinite(i.yMax)||(i.yMax=0),i.rightSideBearing=this.advanceWidth-i.leftSideBearing-(i.xMax-i.xMin),i};$e.prototype.draw=function(n,e,t,r,s){this.getPath(e,t,r,s).draw(n)};$e.prototype.drawPoints=function(n,e,t,r){function s(h,f,p,d){n.beginPath();for(var g=0;g<h.length;g+=1)n.moveTo(f+h[g].x*d,p+h[g].y*d),n.arc(f+h[g].x*d,p+h[g].y*d,2,0,Math.PI*2,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24;for(var i=1/this.path.unitsPerEm*r,o=[],a=[],l=this.path,u=0;u<l.commands.length;u+=1){var c=l.commands[u];c.x!==void 0&&o.push({x:c.x,y:-c.y}),c.x1!==void 0&&a.push({x:c.x1,y:-c.y1}),c.x2!==void 0&&a.push({x:c.x2,y:-c.y2})}n.fillStyle="blue",s(o,e,t,i),n.fillStyle="red",s(a,e,t,i)};$e.prototype.drawMetrics=function(n,e,t,r){var s;e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24,s=1/this.path.unitsPerEm*r,n.lineWidth=1,n.strokeStyle="black",wt.line(n,e,-1e4,e,1e4),wt.line(n,-1e4,t,1e4,t);var i=this.xMin||0,o=this.yMin||0,a=this.xMax||0,l=this.yMax||0,u=this.advanceWidth||0;n.strokeStyle="blue",wt.line(n,e+i*s,-1e4,e+i*s,1e4),wt.line(n,e+a*s,-1e4,e+a*s,1e4),wt.line(n,-1e4,t+-o*s,1e4,t+-o*s),wt.line(n,-1e4,t+-l*s,1e4,t+-l*s),n.strokeStyle="green",wt.line(n,e+u*s,-1e4,e+u*s,1e4)};function Kn(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(r){n[t]=r},enumerable:!0,configurable:!0})}function us(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var r=e[t];r.path.unitsPerEm=n.unitsPerEm,this.glyphs[t]=r}this.length=e&&e.length||0}us.prototype.get=function(n){if(this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());var e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(var r=0;r<t.unicodes.length;r++)e.addUnicode(t.unicodes[r]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+n:e.name=this.font.cffEncoding.charset[n]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(n)),this.glyphs[n].advanceWidth=this.font._hmtxTableData[n].advanceWidth,this.glyphs[n].leftSideBearing=this.font._hmtxTableData[n].leftSideBearing}else typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());return this.glyphs[n]};us.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function eu(n,e){return new $e({index:e,font:n})}function tu(n,e,t,r,s,i){return function(){var o=new $e({index:e,font:n});return o.path=function(){t(o,r,s);var a=i(n.glyphs,o);return a.unitsPerEm=n.unitsPerEm,a},Kn(o,"xMin","_xMin"),Kn(o,"xMax","_xMax"),Kn(o,"yMin","_yMin"),Kn(o,"yMax","_yMax"),o}}function nu(n,e,t,r){return function(){var s=new $e({index:e,font:n});return s.path=function(){var i=t(n,s,r);return i.unitsPerEm=n.unitsPerEm,i},s}}var tt={GlyphSet:us,glyphLoader:eu,ttfGlyphLoader:tu,cffGlyphLoader:nu};function vo(n,e){if(n===e)return!0;if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;for(var t=0;t<n.length;t+=1)if(!vo(n[t],e[t]))return!1;return!0}else return!1}function Qr(n){var e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function ft(n,e,t){var r=[],s=[],i=R.getCard16(n,e),o,a;if(i!==0){var l=R.getByte(n,e+2);o=e+(i+1)*l+2;for(var u=e+3,c=0;c<i+1;c+=1)r.push(R.getOffset(n,u,l)),u+=l;a=o+r[i]}else a=e+2;for(var h=0;h<r.length-1;h+=1){var f=R.getBytes(n,o+r[h],o+r[h+1]);t&&(f=t(f)),s.push(f)}return{objects:s,startOffset:e,endOffset:a}}function ru(n,e){var t=[],r=R.getCard16(n,e),s,i;if(r!==0){var o=R.getByte(n,e+2);s=e+(r+1)*o+2;for(var a=e+3,l=0;l<r+1;l+=1)t.push(R.getOffset(n,a,o)),a+=o;i=s+t[r]}else i=e+2;return{offsets:t,startOffset:e,endOffset:i}}function su(n,e,t,r,s){var i=R.getCard16(t,r),o=0;if(i!==0){var a=R.getByte(t,r+2);o=r+(i+1)*a+2}var l=R.getBytes(t,o+e[n],o+e[n+1]);return s&&(l=s(l)),l}function iu(n){for(var e="",t=15,r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var s=n.parseByte(),i=s>>4,o=s&15;if(i===t||(e+=r[i],o===t))break;e+=r[o]}return parseFloat(e)}function ou(n,e){var t,r,s,i;if(e===28)return t=n.parseByte(),r=n.parseByte(),t<<8|r;if(e===29)return t=n.parseByte(),r=n.parseByte(),s=n.parseByte(),i=n.parseByte(),t<<24|r<<16|s<<8|i;if(e===30)return iu(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function au(n){for(var e={},t=0;t<n.length;t+=1){var r=n[t][0],s=n[t][1],i=void 0;if(s.length===1?i=s[0]:i=s,e.hasOwnProperty(r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=i}return e}function xo(n,e,t){e=e!==void 0?e:0;var r=new R.Parser(n,e),s=[],i=[];for(t=t!==void 0?t:n.length;r.relativeOffset<t;){var o=r.parseByte();o<=21?(o===12&&(o=1200+r.parseByte()),s.push([o,i]),i=[]):i.push(ou(r,o))}return au(s)}function un(n,e){return e<=390?e=Qn[e]:e=n[e-391],e}function yo(n,e,t){for(var r={},s,i=0;i<e.length;i+=1){var o=e[i];if(Array.isArray(o.type)){var a=[];a.length=o.type.length;for(var l=0;l<o.type.length;l++)s=n[o.op]!==void 0?n[o.op][l]:void 0,s===void 0&&(s=o.value!==void 0&&o.value[l]!==void 0?o.value[l]:null),o.type[l]==="SID"&&(s=un(t,s)),a[l]=s;r[o.name]=a}else s=n[o.op],s===void 0&&(s=o.value!==void 0?o.value:null),o.type==="SID"&&(s=un(t,s)),r[o.name]=s}return r}function lu(n,e){var t={};return t.formatMajor=R.getCard8(n,e),t.formatMinor=R.getCard8(n,e+1),t.size=R.getCard8(n,e+2),t.offsetSize=R.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}var bo=[{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"}],So=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function uu(n,e){var t=xo(n,0,n.byteLength);return yo(t,bo,e)}function wo(n,e,t,r){var s=xo(n,e,t);return yo(s,So,r)}function Ii(n,e,t,r){for(var s=[],i=0;i<t.length;i+=1){var o=new DataView(new Uint8Array(t[i]).buffer),a=uu(o,r);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var l=a.private[0],u=a.private[1];if(l!==0&&u!==0){var c=wo(n,u+e,l,r);if(a._defaultWidthX=c.defaultWidthX,a._nominalWidthX=c.nominalWidthX,c.subrs!==0){var h=u+c.subrs,f=ft(n,h+e);a._subrs=f.objects,a._subrsBias=Qr(a._subrs)}a._privateDict=c}s.push(a)}return s}function cu(n,e,t,r){var s,i,o=new R.Parser(n,e);t-=1;var a=[".notdef"],l=o.parseCard8();if(l===0)for(var u=0;u<t;u+=1)s=o.parseSID(),a.push(un(r,s));else if(l===1)for(;a.length<=t;){s=o.parseSID(),i=o.parseCard8();for(var c=0;c<=i;c+=1)a.push(un(r,s)),s+=1}else if(l===2)for(;a.length<=t;){s=o.parseSID(),i=o.parseCard16();for(var h=0;h<=i;h+=1)a.push(un(r,s)),s+=1}else throw new Error("Unknown charset format "+l);return a}function fu(n,e,t){var r,s={},i=new R.Parser(n,e),o=i.parseCard8();if(o===0)for(var a=i.parseCard8(),l=0;l<a;l+=1)r=i.parseCard8(),s[r]=l;else if(o===1){var u=i.parseCard8();r=1;for(var c=0;c<u;c+=1)for(var h=i.parseCard8(),f=i.parseCard8(),p=h;p<=h+f;p+=1)s[p]=r,r+=1}else throw new Error("Unknown encoding format "+o);return new or(s,t)}function Mi(n,e,t){var r,s,i,o,a=new ye,l=[],u=0,c=!1,h=!1,f=0,p=0,d,g,m,x;if(n.isCIDFont){var L=n.tables.cff.topDict._fdSelect[e.index],b=n.tables.cff.topDict._fdArray[L];d=b._subrs,g=b._subrsBias,m=b._defaultWidthX,x=b._nominalWidthX}else d=n.tables.cff.topDict._subrs,g=n.tables.cff.topDict._subrsBias,m=n.tables.cff.topDict._defaultWidthX,x=n.tables.cff.topDict._nominalWidthX;var M=m;function E(T,U){h&&a.closePath(),a.moveTo(T,U),h=!0}function O(){var T;T=l.length%2!==0,T&&!c&&(M=l.shift()+x),u+=l.length>>1,l.length=0,c=!0}function w(T){for(var U,S,A,W,j,H,_,$,te,re,ne,de,Q=0;Q<T.length;){var I=T[Q];switch(Q+=1,I){case 1:O();break;case 3:O();break;case 4:l.length>1&&!c&&(M=l.shift()+x,c=!0),p+=l.pop(),E(f,p);break;case 5:for(;l.length>0;)f+=l.shift(),p+=l.shift(),a.lineTo(f,p);break;case 6:for(;l.length>0&&(f+=l.shift(),a.lineTo(f,p),l.length!==0);)p+=l.shift(),a.lineTo(f,p);break;case 7:for(;l.length>0&&(p+=l.shift(),a.lineTo(f,p),l.length!==0);)f+=l.shift(),a.lineTo(f,p);break;case 8:for(;l.length>0;)r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,f,p);break;case 10:j=l.pop()+g,H=d[j],H&&w(H);break;case 11:return;case 12:switch(I=T[Q],Q+=1,I){case 35:r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),_=i+l.shift(),$=o+l.shift(),te=_+l.shift(),re=$+l.shift(),ne=te+l.shift(),de=re+l.shift(),f=ne+l.shift(),p=de+l.shift(),l.shift(),a.curveTo(r,s,i,o,_,$),a.curveTo(te,re,ne,de,f,p);break;case 34:r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),_=i+l.shift(),$=o,te=_+l.shift(),re=o,ne=te+l.shift(),de=p,f=ne+l.shift(),a.curveTo(r,s,i,o,_,$),a.curveTo(te,re,ne,de,f,p);break;case 36:r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),_=i+l.shift(),$=o,te=_+l.shift(),re=o,ne=te+l.shift(),de=re+l.shift(),f=ne+l.shift(),a.curveTo(r,s,i,o,_,$),a.curveTo(te,re,ne,de,f,p);break;case 37:r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),_=i+l.shift(),$=o+l.shift(),te=_+l.shift(),re=$+l.shift(),ne=te+l.shift(),de=re+l.shift(),Math.abs(ne-f)>Math.abs(de-p)?f=ne+l.shift():p=de+l.shift(),a.curveTo(r,s,i,o,_,$),a.curveTo(te,re,ne,de,f,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+I),l.length=0}break;case 14:l.length>0&&!c&&(M=l.shift()+x,c=!0),h&&(a.closePath(),h=!1);break;case 18:O();break;case 19:case 20:O(),Q+=u+7>>3;break;case 21:l.length>2&&!c&&(M=l.shift()+x,c=!0),p+=l.pop(),f+=l.pop(),E(f,p);break;case 22:l.length>1&&!c&&(M=l.shift()+x,c=!0),f+=l.pop(),E(f,p);break;case 23:O();break;case 24:for(;l.length>2;)r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,f,p);f+=l.shift(),p+=l.shift(),a.lineTo(f,p);break;case 25:for(;l.length>6;)f+=l.shift(),p+=l.shift(),a.lineTo(f,p);r=f+l.shift(),s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+l.shift(),a.curveTo(r,s,i,o,f,p);break;case 26:for(l.length%2&&(f+=l.shift());l.length>0;)r=f,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i,p=o+l.shift(),a.curveTo(r,s,i,o,f,p);break;case 27:for(l.length%2&&(p+=l.shift());l.length>0;)r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o,a.curveTo(r,s,i,o,f,p);break;case 28:U=T[Q],S=T[Q+1],l.push((U<<24|S<<16)>>16),Q+=2;break;case 29:j=l.pop()+n.gsubrsBias,H=n.gsubrs[j],H&&w(H);break;case 30:for(;l.length>0&&(r=f,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p),l.length!==0);)r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),f=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p);break;case 31:for(;l.length>0&&(r=f+l.shift(),s=p,i=r+l.shift(),o=s+l.shift(),p=o+l.shift(),f=i+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p),l.length!==0);)r=f,s=p+l.shift(),i=r+l.shift(),o=s+l.shift(),f=i+l.shift(),p=o+(l.length===1?l.shift():0),a.curveTo(r,s,i,o,f,p);break;default:I<32?console.log("Glyph "+e.index+": unknown operator "+I):I<247?l.push(I-139):I<251?(U=T[Q],Q+=1,l.push((I-247)*256+U+108)):I<255?(U=T[Q],Q+=1,l.push(-(I-251)*256-U-108)):(U=T[Q],S=T[Q+1],A=T[Q+2],W=T[Q+3],Q+=4,l.push((U<<24|S<<16|A<<8|W)/65536))}}}return w(t),e.advanceWidth=M,a}function hu(n,e,t,r){var s=[],i,o=new R.Parser(n,e),a=o.parseCard8();if(a===0)for(var l=0;l<t;l++){if(i=o.parseCard8(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");s.push(i)}else if(a===3){var u=o.parseCard16(),c=o.parseCard16();if(c!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var h,f=0;f<u;f++){if(i=o.parseCard8(),h=o.parseCard16(),i>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+i+" (FD count "+r+")");if(h>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+h);for(;c<h;c++)s.push(i);c=h}if(h!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+h)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return s}function pu(n,e,t,r){t.tables.cff={};var s=lu(n,e),i=ft(n,s.endOffset,R.bytesToString),o=ft(n,i.endOffset),a=ft(n,o.endOffset,R.bytesToString),l=ft(n,a.endOffset);t.gsubrs=l.objects,t.gsubrsBias=Qr(t.gsubrs);var u=Ii(n,e,o.objects,a.objects);if(u.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+u.length);var c=u[0];if(t.tables.cff.topDict=c,c._privateDict&&(t.defaultWidthX=c._privateDict.defaultWidthX,t.nominalWidthX=c._privateDict.nominalWidthX),c.ros[0]!==void 0&&c.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){var h=c.fdArray,f=c.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;var p=ft(n,h),d=Ii(n,e,p.objects,a.objects);c._fdArray=d,f+=e,c._fdSelect=hu(n,f,t.numGlyphs,d.length)}var g=e+c.private[1],m=wo(n,g,c.private[0],a.objects);if(t.defaultWidthX=m.defaultWidthX,t.nominalWidthX=m.nominalWidthX,m.subrs!==0){var x=g+m.subrs,L=ft(n,x);t.subrs=L.objects,t.subrsBias=Qr(t.subrs)}else t.subrs=[],t.subrsBias=0;var b;r.lowMemory?(b=ru(n,e+c.charStrings),t.nGlyphs=b.offsets.length):(b=ft(n,e+c.charStrings),t.nGlyphs=b.objects.length);var M=cu(n,e+c.charset,t.nGlyphs,a.objects);if(c.encoding===0?t.cffEncoding=new or(_l,M):c.encoding===1?t.cffEncoding=new or(jl,M):t.cffEncoding=fu(n,e+c.encoding,M),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new tt.GlyphSet(t),r.lowMemory)t._push=function(w){var T=su(w,b.offsets,n,e+c.charStrings);t.glyphs.push(w,tt.cffGlyphLoader(t,w,Mi,T))};else for(var E=0;E<t.nGlyphs;E+=1){var O=b.objects[E];t.glyphs.push(E,tt.cffGlyphLoader(t,E,Mi,O))}}function ko(n,e){var t,r=Qn.indexOf(n);return r>=0&&(t=r),r=e.indexOf(n),r>=0?t=r+Qn.length:(t=Qn.length+e.length,e.push(n)),t}function du(){return new F.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 gu(n){var e=new F.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var t=0;t<n.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:n[t]});return e}function Eo(n,e,t){for(var r={},s=0;s<n.length;s+=1){var i=n[s],o=e[i.name];o!==void 0&&!vo(o,i.value)&&(i.type==="SID"&&(o=ko(o,t)),r[i.op]={name:i.name,type:i.type,value:o})}return r}function Ci(n,e){var t=new F.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=Eo(bo,n,e),t}function Ai(n){var e=new F.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function mu(n){var e=new F.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var t=0;t<n.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:n[t]});return e}function vu(){return new F.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function xu(n,e){for(var t=new F.Record("Charsets",[{name:"format",type:"Card8",value:0}]),r=0;r<n.length;r+=1){var s=n[r],i=ko(s,e);t.fields.push({name:"glyph_"+r,type:"SID",value:i})}return t}function yu(n){var e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});for(var r=0,s=0,i=0;i<t.commands.length;i+=1){var o=void 0,a=void 0,l=t.commands[i];if(l.type==="Q"){var u=.3333333333333333,c=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(u*r+c*l.x1),y1:Math.round(u*s+c*l.y1),x2:Math.round(u*l.x+c*l.x1),y2:Math.round(u*l.y+c*l.y1)}}if(l.type==="M")o=Math.round(l.x-r),a=Math.round(l.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rmoveto",type:"OP",value:21}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="L")o=Math.round(l.x-r),a=Math.round(l.y-s),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rlineto",type:"OP",value:5}),r=Math.round(l.x),s=Math.round(l.y);else if(l.type==="C"){var h=Math.round(l.x1-r),f=Math.round(l.y1-s),p=Math.round(l.x2-l.x1),d=Math.round(l.y2-l.y1);o=Math.round(l.x-l.x2),a=Math.round(l.y-l.y2),e.push({name:"dx1",type:"NUMBER",value:h}),e.push({name:"dy1",type:"NUMBER",value:f}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:d}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),r=Math.round(l.x),s=Math.round(l.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function bu(n){for(var e=new F.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<n.length;t+=1){var r=n.get(t),s=yu(r);e.charStrings.push({name:r.name,type:"CHARSTRING",value:s})}return e}function Su(n,e){var t=new F.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=Eo(So,n,e),t}function wu(n,e){for(var t=new F.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,s={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},i={},o=[],a,l=1;l<n.length;l+=1)a=n.get(l),o.push(a.name);var u=[];t.header=du(),t.nameIndex=gu([e.postScriptName]);var c=Ci(s,u);t.topDictIndex=Ai(c),t.globalSubrIndex=vu(),t.charsets=xu(o,u),t.charStringsIndex=bu(n),t.privateDict=Su(i,u),t.stringIndex=mu(u);var h=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return s.charset=h,s.encoding=0,s.charStrings=s.charset+t.charsets.sizeOf(),s.private[1]=s.charStrings+t.charStringsIndex.sizeOf(),c=Ci(s,u),t.topDictIndex=Ai(c),t}var Po={parse:pu,make:wu};function ku(n,e){var t={},r=new R.Parser(n,e);return t.version=r.parseVersion(),t.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,t.checkSumAdjustment=r.parseULong(),t.magicNumber=r.parseULong(),G.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=r.parseUShort(),t.unitsPerEm=r.parseUShort(),t.created=r.parseLongDateTime(),t.modified=r.parseLongDateTime(),t.xMin=r.parseShort(),t.yMin=r.parseShort(),t.xMax=r.parseShort(),t.yMax=r.parseShort(),t.macStyle=r.parseUShort(),t.lowestRecPPEM=r.parseUShort(),t.fontDirectionHint=r.parseShort(),t.indexToLocFormat=r.parseShort(),t.glyphDataFormat=r.parseShort(),t}function Eu(n){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new F.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:t},{name:"modified",type:"LONGDATETIME",value:e},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],n)}var Lo={parse:ku,make:Eu};function Pu(n,e){var t={},r=new R.Parser(n,e);return t.version=r.parseVersion(),t.ascender=r.parseShort(),t.descender=r.parseShort(),t.lineGap=r.parseShort(),t.advanceWidthMax=r.parseUShort(),t.minLeftSideBearing=r.parseShort(),t.minRightSideBearing=r.parseShort(),t.xMaxExtent=r.parseShort(),t.caretSlopeRise=r.parseShort(),t.caretSlopeRun=r.parseShort(),t.caretOffset=r.parseShort(),r.relativeOffset+=8,t.metricDataFormat=r.parseShort(),t.numberOfHMetrics=r.parseUShort(),t}function Lu(n){return new F.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],n)}var To={parse:Pu,make:Lu};function Tu(n,e,t,r,s){for(var i,o,a=new R.Parser(n,e),l=0;l<r;l+=1){l<t&&(i=a.parseUShort(),o=a.parseShort());var u=s.get(l);u.advanceWidth=i,u.leftSideBearing=o}}function Iu(n,e,t,r,s){n._hmtxTableData={};for(var i,o,a=new R.Parser(e,t),l=0;l<s;l+=1)l<r&&(i=a.parseUShort(),o=a.parseShort()),n._hmtxTableData[l]={advanceWidth:i,leftSideBearing:o}}function Mu(n,e,t,r,s,i,o){o.lowMemory?Iu(n,e,t,r,s):Tu(e,t,r,s,i)}function Cu(n){for(var e=new F.Table("hmtx",[]),t=0;t<n.length;t+=1){var r=n.get(t),s=r.advanceWidth||0,i=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:s}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:i})}return e}var Io={parse:Mu,make:Cu};function Au(n){for(var e=new F.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]),t="",r=12+n.length*4,s=0;s<n.length;++s){var i=t.indexOf(n[s]);i<0&&(i=t.length,t+=n[s]),e.fields.push({name:"offset "+s,type:"USHORT",value:r+i}),e.fields.push({name:"length "+s,type:"USHORT",value:n[s].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function Ou(n,e){var t=new R.Parser(n,e),r=t.parseULong();G.argument(r===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var s=t.parseULong(),i=[],o=0;o<s;o++){for(var a="",l=e+t.parseUShort(),u=t.parseUShort(),c=l;c<l+u;++c)a+=String.fromCharCode(n.getInt8(c));i.push(a)}return i}var Mo={make:Au,parse:Ou};function Fu(n,e){var t={},r=new R.Parser(n,e);return t.version=r.parseVersion(),t.numGlyphs=r.parseUShort(),t.version===1&&(t.maxPoints=r.parseUShort(),t.maxContours=r.parseUShort(),t.maxCompositePoints=r.parseUShort(),t.maxCompositeContours=r.parseUShort(),t.maxZones=r.parseUShort(),t.maxTwilightPoints=r.parseUShort(),t.maxStorage=r.parseUShort(),t.maxFunctionDefs=r.parseUShort(),t.maxInstructionDefs=r.parseUShort(),t.maxStackElements=r.parseUShort(),t.maxSizeOfInstructions=r.parseUShort(),t.maxComponentElements=r.parseUShort(),t.maxComponentDepth=r.parseUShort()),t}function Du(n){return new F.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var Co={parse:Fu,make:Du},Ao=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Oo={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Ru={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Fo={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Uu(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return Oo[e];case 3:return Fo[e]}}var es="utf-16",Nu={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Bu={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Do(n,e,t){switch(n){case 0:return es;case 1:return Bu[t]||Nu[e];case 3:if(e===1||e===10)return es;break}}function Gu(n,e,t){for(var r={},s=new R.Parser(n,e),i=s.parseUShort(),o=s.parseUShort(),a=s.offset+s.parseUShort(),l=0;l<o;l++){var u=s.parseUShort(),c=s.parseUShort(),h=s.parseUShort(),f=s.parseUShort(),p=Ao[f]||f,d=s.parseUShort(),g=s.parseUShort(),m=Uu(u,h,t),x=Do(u,c,h);if(x!==void 0&&m!==void 0){var L=void 0;if(x===es?L=Gt.UTF16(n,a+g,d):L=Gt.MACSTRING(n,a+g,d,x),L){var b=r[p];b===void 0&&(b=r[p]={}),b[m]=L}}}var M=0;return i===1&&(M=s.parseUShort()),r}function zr(n){var e={};for(var t in n)e[n[t]]=parseInt(t);return e}function Oi(n,e,t,r,s,i){return new F.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:s},{name:"offset",type:"USHORT",value:i}])}function $u(n,e){var t=n.length,r=e.length-t+1;e:for(var s=0;s<r;s++)for(;s<r;s++){for(var i=0;i<t;i++)if(e[s+i]!==n[i])continue e;return s}return-1}function Fi(n,e){var t=$u(n,e);if(t<0){t=e.length;for(var r=0,s=n.length;r<s;++r)e.push(n[r])}return t}function zu(n,e){var t,r=[],s={},i=zr(Ao);for(var o in n){var a=i[o];if(a===void 0&&(a=o),t=parseInt(a),isNaN(t))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');s[t]=n[o],r.push(t)}for(var l=zr(Oo),u=zr(Fo),c=[],h=[],f=0;f<r.length;f++){t=r[f];var p=s[t];for(var d in p){var g=p[d],m=1,x=l[d],L=Ru[x],b=Do(m,L,x),M=C.MACSTRING(g,b);M===void 0&&(m=0,x=e.indexOf(d),x<0&&(x=e.length,e.push(d)),L=4,M=C.UTF16(g));var E=Fi(M,h);c.push(Oi(m,L,x,t,M.length,E));var O=u[d];if(O!==void 0){var w=C.UTF16(g),T=Fi(w,h);c.push(Oi(3,1,O,t,w.length,T))}}}c.sort(function(A,W){return A.platformID-W.platformID||A.encodingID-W.encodingID||A.languageID-W.languageID||A.nameID-W.nameID});for(var U=new F.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+c.length*12}]),S=0;S<c.length;S++)U.fields.push({name:"record_"+S,type:"RECORD",value:c[S]});return U.fields.push({name:"strings",type:"LITERAL",value:h}),U}var Ro={parse:Gu,make:zu},ts=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function Hu(n){for(var e=0;e<ts.length;e+=1){var t=ts[e];if(n>=t.begin&&n<t.end)return e}return-1}function Vu(n,e){var t={},r=new R.Parser(n,e);t.version=r.parseUShort(),t.xAvgCharWidth=r.parseShort(),t.usWeightClass=r.parseUShort(),t.usWidthClass=r.parseUShort(),t.fsType=r.parseUShort(),t.ySubscriptXSize=r.parseShort(),t.ySubscriptYSize=r.parseShort(),t.ySubscriptXOffset=r.parseShort(),t.ySubscriptYOffset=r.parseShort(),t.ySuperscriptXSize=r.parseShort(),t.ySuperscriptYSize=r.parseShort(),t.ySuperscriptXOffset=r.parseShort(),t.ySuperscriptYOffset=r.parseShort(),t.yStrikeoutSize=r.parseShort(),t.yStrikeoutPosition=r.parseShort(),t.sFamilyClass=r.parseShort(),t.panose=[];for(var s=0;s<10;s++)t.panose[s]=r.parseByte();return t.ulUnicodeRange1=r.parseULong(),t.ulUnicodeRange2=r.parseULong(),t.ulUnicodeRange3=r.parseULong(),t.ulUnicodeRange4=r.parseULong(),t.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),t.fsSelection=r.parseUShort(),t.usFirstCharIndex=r.parseUShort(),t.usLastCharIndex=r.parseUShort(),t.sTypoAscender=r.parseShort(),t.sTypoDescender=r.parseShort(),t.sTypoLineGap=r.parseShort(),t.usWinAscent=r.parseUShort(),t.usWinDescent=r.parseUShort(),t.version>=1&&(t.ulCodePageRange1=r.parseULong(),t.ulCodePageRange2=r.parseULong()),t.version>=2&&(t.sxHeight=r.parseShort(),t.sCapHeight=r.parseShort(),t.usDefaultChar=r.parseUShort(),t.usBreakChar=r.parseUShort(),t.usMaxContent=r.parseUShort()),t}function qu(n){return new F.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}],n)}var ns={parse:Vu,make:qu,unicodeRanges:ts,getUnicodeRange:Hu};function Xu(n,e){var t={},r=new R.Parser(n,e);switch(t.version=r.parseVersion(),t.italicAngle=r.parseFixed(),t.underlinePosition=r.parseShort(),t.underlineThickness=r.parseShort(),t.isFixedPitch=r.parseULong(),t.minMemType42=r.parseULong(),t.maxMemType42=r.parseULong(),t.minMemType1=r.parseULong(),t.maxMemType1=r.parseULong(),t.version){case 1:t.names=kt.slice();break;case 2:t.numberOfGlyphs=r.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var s=0;s<t.numberOfGlyphs;s++)t.glyphNameIndex[s]=r.parseUShort();t.names=[];for(var i=0;i<t.numberOfGlyphs;i++)if(t.glyphNameIndex[i]>=kt.length){var o=r.parseChar();t.names.push(r.parseString(o))}break;case 2.5:t.numberOfGlyphs=r.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.offset[a]=r.parseChar();break}return t}function Wu(){return new F.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}var Uo={parse:Xu,make:Wu},qe=new Array(9);qe[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(y.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(y.coverage),substitute:this.parseOffset16List()};G.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};qe[2]=function(){var e=this.parseUShort();return G.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(y.coverage),sequences:this.parseListOfLists()}};qe[3]=function(){var e=this.parseUShort();return G.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(y.coverage),alternateSets:this.parseListOfLists()}};qe[4]=function(){var e=this.parseUShort();return G.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(y.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Bt={sequenceIndex:y.uShort,lookupListIndex:y.uShort};qe[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(y.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,Bt)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(y.coverage),classDef:this.parsePointer(y.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),o=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(o,Bt)}})};if(t===3){var r=this.parseUShort(),s=this.parseUShort();return{substFormat:t,coverages:this.parseList(r,y.pointer(y.coverage)),lookupRecords:this.parseRecordList(s,Bt)}}G.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};qe[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(y.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Bt)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(y.coverage),backtrackClassDef:this.parsePointer(y.classDef),inputClassDef:this.parsePointer(y.classDef),lookaheadClassDef:this.parsePointer(y.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Bt)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(y.pointer(y.coverage)),inputCoverage:this.parseList(y.pointer(y.coverage)),lookaheadCoverage:this.parseList(y.pointer(y.coverage)),lookupRecords:this.parseRecordList(Bt)};G.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};qe[7]=function(){var e=this.parseUShort();G.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),r=new y(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:qe[t].call(r)}};qe[8]=function(){var e=this.parseUShort();return G.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(y.coverage),backtrackCoverage:this.parseList(y.pointer(y.coverage)),lookaheadCoverage:this.parseList(y.pointer(y.coverage)),substitutes:this.parseUShortList()}};function _u(n,e){e=e||0;var t=new y(n,e),r=t.parseVersion(1);return G.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(qe)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(qe),variations:t.parseFeatureVariationsList()}}var $t=new Array(9);$t[1]=function(e){return e.substFormat===1?new F.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new F.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new F.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new F.Coverage(e.coverage)}].concat(F.ushortList("substitute",e.substitute)))};$t[2]=function(e){return G.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new F.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new F.Coverage(e.coverage)}].concat(F.tableList("seqSet",e.sequences,function(t){return new F.Table("sequenceSetTable",F.ushortList("sequence",t))})))};$t[3]=function(e){return G.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new F.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new F.Coverage(e.coverage)}].concat(F.tableList("altSet",e.alternateSets,function(t){return new F.Table("alternateSetTable",F.ushortList("alternate",t))})))};$t[4]=function(e){return G.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new F.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new F.Coverage(e.coverage)}].concat(F.tableList("ligSet",e.ligatureSets,function(t){return new F.Table("ligatureSetTable",F.tableList("ligature",t,function(r){return new F.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:r.ligGlyph}].concat(F.ushortList("component",r.components,r.components.length+1)))}))})))};$t[6]=function(e){if(e.substFormat===1){var t=new F.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new F.Coverage(e.coverage)}].concat(F.tableList("chainRuleSet",e.chainRuleSets,function(i){return new F.Table("chainRuleSetTable",F.tableList("chainRule",i,function(o){var a=F.ushortList("backtrackGlyph",o.backtrack,o.backtrack.length).concat(F.ushortList("inputGlyph",o.input,o.input.length+1)).concat(F.ushortList("lookaheadGlyph",o.lookahead,o.lookahead.length)).concat(F.ushortList("substitution",[],o.lookupRecords.length));return o.lookupRecords.forEach(function(l,u){a=a.concat({name:"sequenceIndex"+u,type:"USHORT",value:l.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:l.lookupListIndex})}),new F.Table("chainRuleTable",a)}))})));return t}else if(e.substFormat===2)G.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var r=[{name:"substFormat",type:"USHORT",value:e.substFormat}];r.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(i,o){r.push({name:"backtrackCoverage"+o,type:"TABLE",value:new F.Coverage(i)})}),r.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(i,o){r.push({name:"inputCoverage"+o,type:"TABLE",value:new F.Coverage(i)})}),r.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(i,o){r.push({name:"lookaheadCoverage"+o,type:"TABLE",value:new F.Coverage(i)})}),r.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(i,o){r=r.concat({name:"sequenceIndex"+o,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:i.lookupListIndex})});var s=new F.Table("chainContextTable",r);return s}G.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function ju(n){return new F.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new F.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new F.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new F.LookupList(n.lookups,$t)}])}var No={parse:_u,make:ju};function Zu(n,e){var t=new R.Parser(n,e),r=t.parseULong();G.argument(r===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var s=t.parseULong(),i={},o=0;o<s;o++){var a=t.parseTag(),l=t.parseULong(),u=t.parseULong(),c=Gt.UTF8(n,e+l,u);i[a]=c}return i}function Yu(n){var e=Object.keys(n).length,t="",r=16+e*12,s=new F.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(var i in n){var o=t.length;t+=n[i],s.fields.push({name:"tag "+i,type:"TAG",value:i}),s.fields.push({name:"offset "+i,type:"ULONG",value:r+o}),s.fields.push({name:"length "+i,type:"ULONG",value:n[i].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),s}var Bo={parse:Zu,make:Yu};function Di(n){return Math.log(n)/Math.log(2)|0}function cs(n){for(;n.length%4!==0;)n.push(0);for(var e=0,t=0;t<n.length;t+=4)e+=(n[t]<<24)+(n[t+1]<<16)+(n[t+2]<<8)+n[t+3];return e%=Math.pow(2,32),e}function Ri(n,e,t,r){return new F.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function Go(n){var e=new F.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);e.tables=n,e.numTables=n.length;var t=Math.pow(2,Di(e.numTables));e.searchRange=16*t,e.entrySelector=Di(t),e.rangeShift=e.numTables*16-e.searchRange;for(var r=[],s=[],i=e.sizeOf()+Ri().sizeOf()*e.numTables;i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0});for(var o=0;o<n.length;o+=1){var a=n[o];G.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var l=a.sizeOf(),u=Ri(a.tableName,cs(a.encode()),i,l);for(r.push({name:u.tag+" Table Record",type:"RECORD",value:u}),s.push({name:a.tableName+" table",type:"RECORD",value:a}),i+=l,G.argument(!isNaN(i),"Something went wrong calculating the offset.");i%4!==0;)i+=1,s.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(c,h){return c.value.tag>h.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(s),e}function Ui(n,e,t){for(var r=0;r<e.length;r+=1){var s=n.charToGlyphIndex(e[r]);if(s>0){var i=n.glyphs.get(s);return i.getMetrics()}}return t}function Ku(n){for(var e=0,t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function Ju(n){for(var e=[],t=[],r=[],s=[],i=[],o=[],a=[],l,u=0,c=0,h=0,f=0,p=0,d=0;d<n.glyphs.length;d+=1){var g=n.glyphs.get(d),m=g.unicode|0;if(isNaN(g.advanceWidth))throw new Error("Glyph "+g.name+" ("+d+"): advanceWidth is not a number.");(l>m||l===void 0)&&m>0&&(l=m),u<m&&(u=m);var x=ns.getUnicodeRange(m);if(x<32)c|=1<<x;else if(x<64)h|=1<<x-32;else if(x<96)f|=1<<x-64;else if(x<123)p|=1<<x-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(g.name!==".notdef"){var L=g.getMetrics();e.push(L.xMin),t.push(L.yMin),r.push(L.xMax),s.push(L.yMax),o.push(L.leftSideBearing),a.push(L.rightSideBearing),i.push(g.advanceWidth)}}var b={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,i),advanceWidthAvg:Ku(i),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};b.ascender=n.ascender,b.descender=n.descender;var M=Lo.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:b.xMin,yMin:b.yMin,xMax:b.xMax,yMax:b.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),E=To.make({ascender:b.ascender,descender:b.descender,advanceWidthMax:b.advanceWidthMax,minLeftSideBearing:b.minLeftSideBearing,minRightSideBearing:b.minRightSideBearing,xMaxExtent:b.maxLeftSideBearing+(b.xMax-b.xMin),numberOfHMetrics:n.glyphs.length}),O=Co.make(n.glyphs.length),w=ns.make(Object.assign({xAvgCharWidth:Math.round(b.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:u,ulUnicodeRange1:c,ulUnicodeRange2:h,ulUnicodeRange3:f,ulUnicodeRange4:p,sTypoAscender:b.ascender,sTypoDescender:b.descender,sTypoLineGap:0,usWinAscent:b.yMax,usWinDescent:Math.abs(b.yMin),ulCodePageRange1:1,sxHeight:Ui(n,"xyvw",{yMax:Math.round(b.ascender/2)}).yMax,sCapHeight:Ui(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",b).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),T=Io.make(n.glyphs),U=po.make(n.glyphs),S=n.getEnglishName("fontFamily"),A=n.getEnglishName("fontSubfamily"),W=S+" "+A,j=n.getEnglishName("postScriptName");j||(j=S.replace(/\s/g,"")+"-"+A);var H={};for(var _ in n.names)H[_]=n.names[_];H.uniqueID||(H.uniqueID={en:n.getEnglishName("manufacturer")+":"+W}),H.postScriptName||(H.postScriptName={en:j}),H.preferredFamily||(H.preferredFamily=n.names.fontFamily),H.preferredSubfamily||(H.preferredSubfamily=n.names.fontSubfamily);var $=[],te=Ro.make(H,$),re=$.length>0?Mo.make($):void 0,ne=Uo.make(),de=Po.make(n.glyphs,{version:n.getEnglishName("version"),fullName:W,familyName:S,weightName:A,postScriptName:j,unitsPerEm:n.unitsPerEm,fontBBox:[0,b.yMin,b.ascender,b.advanceWidthMax]}),Q=n.metas&&Object.keys(n.metas).length>0?Bo.make(n.metas):void 0,I=[M,E,O,w,te,U,ne,de,T];re&&I.push(re),n.tables.gsub&&I.push(No.make(n.tables.gsub)),Q&&I.push(Q);for(var B=Go(I),Y=B.encode(),le=cs(Y),ae=B.fields,ue=!1,he=0;he<ae.length;he+=1)if(ae[he].name==="head table"){ae[he].value.checkSumAdjustment=2981146554-le,ue=!0;break}if(!ue)throw new Error("Could not find head table with checkSum to adjust.");return B}var Qu={make:Go,fontToTable:Ju,computeCheckSum:cs};function Hr(n,e){for(var t=0,r=n.length-1;t<=r;){var s=t+r>>>1,i=n[s].tag;if(i===e)return s;i<e?t=s+1:r=s-1}return-t-1}function Ni(n,e){for(var t=0,r=n.length-1;t<=r;){var s=t+r>>>1,i=n[s];if(i===e)return s;i<e?t=s+1:r=s-1}return-t-1}function Bi(n,e){for(var t,r=0,s=n.length-1;r<=s;){var i=r+s>>>1;t=n[i];var o=t.start;if(o===e)return t;o<e?r=i+1:s=i-1}if(r>0)return t=n[r-1],e>t.end?0:t}function dn(n,e){this.font=n,this.tableName=e}dn.prototype={searchTag:Hr,binSearch:Ni,getTable:function(n){var e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var n=this.getTable();if(n){for(var e=!1,t=0;t<n.scripts.length;t++){var r=n.scripts[t].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(n,e){var t=this.getTable(e);if(t){n=n||"DFLT";var r=t.scripts,s=Hr(t.scripts,n);if(s>=0)return r[s].script;if(e){var i={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-s,0,i),i.script}}},getLangSysTable:function(n,e,t){var r=this.getScriptTable(n,t);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;var s=Hr(r.langSysRecords,e);if(s>=0)return r.langSysRecords[s].langSys;if(t){var i={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-s,0,i),i.langSys}}},getFeatureTable:function(n,e,t,r){var s=this.getLangSysTable(n,e,r);if(s){for(var i,o=s.featureIndexes,a=this.font.tables[this.tableName].features,l=0;l<o.length;l++)if(i=a[o[l]],i.tag===t)return i.feature;if(r){var u=a.length;return G.assert(u===0||t>=a[u-1].tag,"Features must be added in alphabetical order."),i={tag:t,feature:{params:0,lookupListIndexes:[]}},a.push(i),o.push(u),i.feature}}},getLookupTables:function(n,e,t,r,s){var i=this.getFeatureTable(n,e,t,s),o=[];if(i){for(var a,l=i.lookupListIndexes,u=this.font.tables[this.tableName].lookups,c=0;c<l.length;c++)a=u[l[c]],a.lookupType===r&&o.push(a);if(o.length===0&&s){a={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};var h=u.length;return u.push(a),l.push(h),[a]}}return o},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:var t=Bi(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:var t=Ni(n.glyphs,e);return t>=0?t:-1;case 2:var r=Bi(n.ranges,e);return r?r.index+e-r.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;for(var e=[],t=n.ranges,r=0;r<t.length;r++)for(var s=t[r],i=s.start,o=s.end,a=i;a<=o;a++)e.push(a);return e}};function gn(n){dn.call(this,n,"gpos")}gn.prototype=dn.prototype;gn.prototype.init=function(){var n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)};gn.prototype.getKerningValue=function(n,e,t){for(var r=0;r<n.length;r++)for(var s=n[r].subtables,i=0;i<s.length;i++){var o=s[i],a=this.getCoverageIndex(o.coverage,e);if(!(a<0))switch(o.posFormat){case 1:for(var l=o.pairSets[a],u=0;u<l.length;u++){var c=l[u];if(c.secondGlyph===t)return c.value1&&c.value1.xAdvance||0}break;case 2:var h=this.getGlyphClass(o.classDef1,e),f=this.getGlyphClass(o.classDef2,t),p=o.classRecords[h][f];return p.value1&&p.value1.xAdvance||0}}return 0};gn.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function De(n){dn.call(this,n,"gsub")}function ec(n,e){var t=n.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(n[r]!==e[r])return!1;return!0}function fs(n,e,t){for(var r=n.subtables,s=0;s<r.length;s++){var i=r[s];if(i.substFormat===e)return i}if(t)return r.push(t),t}De.prototype=dn.prototype;De.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};De.prototype.getSingle=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,1),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;if(l.substFormat===1){var h=l.deltaGlyphId;for(c=0;c<u.length;c++){var f=u[c];r.push({sub:f,by:f+h})}}else{var p=l.substitute;for(c=0;c<u.length;c++)r.push({sub:u[c],by:p[c]})}}return r};De.prototype.getMultiple=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,2),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++){var l=o[a],u=this.expandCoverage(l.coverage),c=void 0;for(c=0;c<u.length;c++){var h=u[c],f=l.sequences[c];r.push({sub:h,by:f})}}return r};De.prototype.getAlternates=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,3),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.alternateSets,h=0;h<u.length;h++)r.push({sub:u[h],by:c[h]});return r};De.prototype.getLigatures=function(n,e,t){for(var r=[],s=this.getLookupTables(e,t,n,4),i=0;i<s.length;i++)for(var o=s[i].subtables,a=0;a<o.length;a++)for(var l=o[a],u=this.expandCoverage(l.coverage),c=l.ligatureSets,h=0;h<u.length;h++)for(var f=u[h],p=c[h],d=0;d<p.length;d++){var g=p[d];r.push({sub:[f].concat(g.components),by:g.ligGlyph})}return r};De.prototype.addSingle=function(n,e,t,r){var s=this.getLookupTables(t,r,n,1,!0)[0],i=fs(s,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});G.assert(i.coverage.format===1,"Single: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.substitute.splice(a,0,0)),i.substitute[a]=e.by};De.prototype.addMultiple=function(n,e,t,r){G.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var s=this.getLookupTables(t,r,n,2,!0)[0],i=fs(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});G.assert(i.coverage.format===1,"Multiple: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.sequences.splice(a,0,0)),i.sequences[a]=e.by};De.prototype.addAlternate=function(n,e,t,r){var s=this.getLookupTables(t,r,n,3,!0)[0],i=fs(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});G.assert(i.coverage.format===1,"Alternate: unable to modify coverage table format "+i.coverage.format);var o=e.sub,a=this.binSearch(i.coverage.glyphs,o);a<0&&(a=-1-a,i.coverage.glyphs.splice(a,0,o),i.alternateSets.splice(a,0,0)),i.alternateSets[a]=e.by};De.prototype.addLigature=function(n,e,t,r){var s=this.getLookupTables(t,r,n,4,!0)[0],i=s.subtables[0];i||(i={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=i),G.assert(i.coverage.format===1,"Ligature: unable to modify coverage table format "+i.coverage.format);var o=e.sub[0],a=e.sub.slice(1),l={ligGlyph:e.by,components:a},u=this.binSearch(i.coverage.glyphs,o);if(u>=0){for(var c=i.ligatureSets[u],h=0;h<c.length;h++)if(ec(c[h].components,a))return;c.push(l)}else u=-1-u,i.coverage.glyphs.splice(u,0,o),i.ligatureSets.splice(u,0,[l])};De.prototype.getFeature=function(n,e,t){if(/ss\d\d/.test(n))return this.getSingle(n,e,t);switch(n){case"aalt":case"salt":return this.getSingle(n,e,t).concat(this.getAlternates(n,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(n,e,t);case"ccmp":return this.getMultiple(n,e,t).concat(this.getLigatures(n,e,t));case"stch":return this.getMultiple(n,e,t)}};De.prototype.add=function(n,e,t,r){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,r);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,r):this.addAlternate(n,e,t,r);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,r);case"ccmp":return e.by instanceof Array?this.addMultiple(n,e,t,r):this.addLigature(n,e,t,r)}};function tc(){return typeof window<"u"}function nc(n){for(var e=new Buffer(n.byteLength),t=new Uint8Array(n),r=0;r<e.length;++r)e[r]=t[r];return e}function ln(n,e){if(!n)throw e}function Gi(n,e,t,r,s){var i;return(e&r)>0?(i=n.parseByte(),(e&s)===0&&(i=-i),i=t+i):(e&s)>0?i=t:i=t+n.parseShort(),i}function $o(n,e,t){var r=new R.Parser(e,t);n.numberOfContours=r.parseShort(),n._xMin=r.parseShort(),n._yMin=r.parseShort(),n._xMax=r.parseShort(),n._yMax=r.parseShort();var s,i;if(n.numberOfContours>0){for(var o=n.endPointIndices=[],a=0;a<n.numberOfContours;a+=1)o.push(r.parseUShort());n.instructionLength=r.parseUShort(),n.instructions=[];for(var l=0;l<n.instructionLength;l+=1)n.instructions.push(r.parseByte());var u=o[o.length-1]+1;s=[];for(var c=0;c<u;c+=1)if(i=r.parseByte(),s.push(i),(i&8)>0)for(var h=r.parseByte(),f=0;f<h;f+=1)s.push(i),c+=1;if(G.argument(s.length===u,"Bad flags."),o.length>0){var p=[],d;if(u>0){for(var g=0;g<u;g+=1)i=s[g],d={},d.onCurve=!!(i&1),d.lastPointOfContour=o.indexOf(g)>=0,p.push(d);for(var m=0,x=0;x<u;x+=1)i=s[x],d=p[x],d.x=Gi(r,i,m,2,16),m=d.x;for(var L=0,b=0;b<u;b+=1)i=s[b],d=p[b],d.y=Gi(r,i,L,4,32),L=d.y}n.points=p}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];for(var M=!0;M;){s=r.parseUShort();var E={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(s&1)>0?(s&2)>0?(E.dx=r.parseShort(),E.dy=r.parseShort()):E.matchedPoints=[r.parseUShort(),r.parseUShort()]:(s&2)>0?(E.dx=r.parseChar(),E.dy=r.parseChar()):E.matchedPoints=[r.parseByte(),r.parseByte()],(s&8)>0?E.xScale=E.yScale=r.parseF2Dot14():(s&64)>0?(E.xScale=r.parseF2Dot14(),E.yScale=r.parseF2Dot14()):(s&128)>0&&(E.xScale=r.parseF2Dot14(),E.scale01=r.parseF2Dot14(),E.scale10=r.parseF2Dot14(),E.yScale=r.parseF2Dot14()),n.components.push(E),M=!!(s&32)}if(s&256){n.instructionLength=r.parseUShort(),n.instructions=[];for(var O=0;O<n.instructionLength;O+=1)n.instructions.push(r.parseByte())}}}function Vr(n,e){for(var t=[],r=0;r<n.length;r+=1){var s=n[r],i={x:e.xScale*s.x+e.scale01*s.y+e.dx,y:e.scale10*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(i)}return t}function rc(n){for(var e=[],t=[],r=0;r<n.length;r+=1){var s=n[r];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return G.argument(t.length===0,"There are still points left in the current contour."),e}function zo(n){var e=new ye;if(!n)return e;for(var t=rc(n),r=0;r<t.length;++r){var s=t[r],i=null,o=s[s.length-1],a=s[0];if(o.onCurve)e.moveTo(o.x,o.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{var l={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(l.x,l.y)}for(var u=0;u<s.length;++u)if(i=o,o=a,a=s[(u+1)%s.length],o.onCurve)e.lineTo(o.x,o.y);else{var c=i,h=a;i.onCurve||(c={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5}),a.onCurve||(h={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,h.x,h.y)}e.closePath()}return e}function Ho(n,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var r=e.components[t],s=n.get(r.glyphIndex);if(s.getPath(),s.points){var i=void 0;if(r.matchedPoints===void 0)i=Vr(s.points,r);else{if(r.matchedPoints[0]>e.points.length-1||r.matchedPoints[1]>s.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[r.matchedPoints[0]],a=s.points[r.matchedPoints[1]],l={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};a=Vr([a],l)[0],l.dx=o.x-a.x,l.dy=o.y-a.y,i=Vr(s.points,l)}e.points=e.points.concat(i)}}return zo(e.points)}function sc(n,e,t,r){for(var s=new tt.GlyphSet(r),i=0;i<t.length-1;i+=1){var o=t[i],a=t[i+1];o!==a?s.push(i,tt.ttfGlyphLoader(r,i,$o,n,e+o,Ho)):s.push(i,tt.glyphLoader(r,i))}return s}function ic(n,e,t,r){var s=new tt.GlyphSet(r);return r._push=function(i){var o=t[i],a=t[i+1];o!==a?s.push(i,tt.ttfGlyphLoader(r,i,$o,n,e+o,Ho)):s.push(i,tt.glyphLoader(r,i))},s}function oc(n,e,t,r,s){return s.lowMemory?ic(n,e,t,r):sc(n,e,t,r)}var Vo={getPath:zo,parse:oc},qo,Pt,Xo,rs;function Wo(n){this.font=n,this.getCommands=function(e){return Vo.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function ac(n){return n}function _o(n){return Math.sign(n)*Math.round(Math.abs(n))}function lc(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function uc(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function cc(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function fc(n){return Math.sign(n)*Math.floor(Math.abs(n))}var jo=function(n){var e=this.srPeriod,t=this.srPhase,r=this.srThreshold,s=1;return n<0&&(n=-n,s=-1),n+=r-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},et={x:1,y:0,axis:"x",distance:function(n,e,t,r){return(t?n.xo:n.x)-(r?e.xo:e.x)},interpolate:function(n,e,t,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=n.xo-e.xo,i=n.xo-t.xo,l=e.x-e.xo,u=t.x-t.xo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){n.x=n.xo+(l+u)/2;return}n.x=n.xo+(l*a+u*o)/c;return}if(s=r.distance(n,e,!0,!0),i=r.distance(n,t,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(t,t,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){et.setRelative(n,n,(l+u)/2,r,!0);return}et.setRelative(n,n,(l*a+u*o)/c,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,r,s){if(!r||r===this){n.x=(s?e.xo:e.x)+t;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*r.x,l=o+t*r.y;n.x=a+(n.y-l)/r.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},st={x:0,y:1,axis:"y",distance:function(n,e,t,r){return(t?n.yo:n.y)-(r?e.yo:e.y)},interpolate:function(n,e,t,r){var s,i,o,a,l,u,c;if(!r||r===this){if(s=n.yo-e.yo,i=n.yo-t.yo,l=e.y-e.yo,u=t.y-t.yo,o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){n.y=n.yo+(l+u)/2;return}n.y=n.yo+(l*a+u*o)/c;return}if(s=r.distance(n,e,!0,!0),i=r.distance(n,t,!0,!0),l=r.distance(e,e,!1,!0),u=r.distance(t,t,!1,!0),o=Math.abs(s),a=Math.abs(i),c=o+a,c===0){st.setRelative(n,n,(l+u)/2,r,!0);return}st.setRelative(n,n,(l*a+u*o)/c,r,!0)},normalSlope:0,setRelative:function(n,e,t,r,s){if(!r||r===this){n.y=(s?e.yo:e.y)+t;return}var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*r.x,l=o+t*r.y;n.y=l+r.normalSlope*(n.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(et);Object.freeze(st);function mn(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}mn.prototype.distance=function(n,e,t,r){return this.x*et.distance(n,e,t,r)+this.y*st.distance(n,e,t,r)};mn.prototype.interpolate=function(n,e,t,r){var s,i,o,a,l,u,c;if(o=r.distance(n,e,!0,!0),a=r.distance(n,t,!0,!0),s=r.distance(e,e,!1,!0),i=r.distance(t,t,!1,!0),l=Math.abs(o),u=Math.abs(a),c=l+u,c===0){this.setRelative(n,n,(s+i)/2,r,!0);return}this.setRelative(n,n,(s*u+i*l)/c,r,!0)};mn.prototype.setRelative=function(n,e,t,r,s){r=r||this;var i=s?e.xo:e.x,o=s?e.yo:e.y,a=i+t*r.x,l=o+t*r.y,u=r.normalSlope,c=this.slope,h=n.x,f=n.y;n.x=(c*h-u*a+l-f)/(c-u),n.y=c*(n.x-h)+f};mn.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function vn(n,e){var t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?et:n===0&&e===1?st:new mn(n,e)}function it(n,e,t,r){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}it.prototype.nextTouched=function(n){for(var e=this.nextPointOnContour;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};it.prototype.prevTouched=function(n){for(var e=this.prevPointOnContour;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var pn=Object.freeze(new it(0,0)),hc={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ht(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=et,this.round=_o}}Wo.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var t=this.font,r=this._prepState;if(!r||r.ppem!==e){var s=this._fpgmState;if(!s){ht.prototype=hc,s=this._fpgmState=new ht("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,exports.DEBUG&&(console.log("---EXEC FPGM---"),s.step=-1);try{Pt(s)}catch(u){console.log("Hinting error in FPGM:"+u),this._errorState=3;return}}ht.prototype=s,r=this._prepState=new ht("prep",t.tables.prep),r.ppem=e;var i=t.tables.cvt;if(i)for(var o=r.cvt=new Array(i.length),a=e/t.unitsPerEm,l=0;l<i.length;l++)o[l]=i[l]*a;else r.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),r.step=-1);try{Pt(r)}catch(u){this._errorState<2&&console.log("Hinting error in PREP:"+u),this._errorState=2}}if(!(this._errorState>1))try{return Xo(n,r)}catch(u){this._errorState<1&&(console.log("Hinting error:"+u),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};Xo=function(n,e){var t=e.ppem/e.font.unitsPerEm,r=t,s=n.components,i,o,a;if(ht.prototype=e,!s)a=new ht("glyf",n.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),rs(n,a,t,r),o=a.gZone;else{var l=e.font;o=[],i=[];for(var u=0;u<s.length;u++){var c=s[u],h=l.glyphs.get(c.glyphIndex);a=new ht("glyf",h.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+u+"---"),a.step=-1),rs(h,a,t,r);for(var f=Math.round(c.dx*t),p=Math.round(c.dy*r),d=a.gZone,g=a.contours,m=0;m<d.length;m++){var x=d[m];x.xTouched=x.yTouched=!1,x.xo=x.x=x.x+f,x.yo=x.y=x.y+p}var L=o.length;o.push.apply(o,d);for(var b=0;b<g.length;b++)i.push(g[b]+L)}n.instructions&&!a.inhibitGridFit&&(a=new ht("glyf",n.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=i,o.push(new it(0,0),new it(Math.round(n.advanceWidth*t),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),Pt(a),o.length-=2)}return o};rs=function(n,e,t,r){for(var s=n.points||[],i=s.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],l,u=0;u<i;u++)l=s[u],o[u]=new it(l.x*t,l.y*r,l.lastPointOfContour,l.onCurve);for(var c,h,f=0;f<i;f++)l=o[f],c||(c=l,a.push(f)),l.lastPointOfContour?(l.nextPointOnContour=c,c.prevPointOnContour=l,c=void 0):(h=o[f+1],l.nextPointOnContour=h,h.prevPointOnContour=l);if(!e.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<i;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new it(0,0),new it(Math.round(n.advanceWidth*t),0)),Pt(e),o.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var d=0;d<i;d++)console.log(d,o[d].x,o[d].y)}}};Pt=function(n){var e=n.prog;if(e){var t=e.length,r;for(n.ip=0;n.ip<t;n.ip++){if(exports.DEBUG&&n.step++,r=qo[e[n.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));r(n)}}};function ar(n){for(var e=n.tZone=new Array(n.gZone.length),t=0;t<e.length;t++)e[t]=new it(0,0)}function Zo(n,e){var t=n.prog,r=n.ip,s=1,i;do if(i=t[++r],i===88)s++;else if(i===89)s--;else if(i===64)r+=t[r+1]+1;else if(i===65)r+=2*t[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=(i-184+1)*2;else if(e&&s===1&&i===27)break;while(s>0);n.ip=r}function $i(n,e){exports.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function zi(n,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function Hi(n,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function Vi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SPVTL["+n+"]",r,s);var a,l;n?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.pv=e.dpv=vn(a,l)}function qi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log("SFVTL["+n+"]",r,s);var a,l;n?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.fv=vn(a,l)}function pc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.pv=n.dpv=vn(r,t)}function dc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.fv=vn(r,t)}function gc(n){var e=n.stack,t=n.pv;exports.DEBUG&&console.log(n.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function mc(n){var e=n.stack,t=n.fv;exports.DEBUG&&console.log(n.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function vc(n){n.fv=n.pv,exports.DEBUG&&console.log(n.step,"SFVTPV[]")}function xc(n){var e=n.stack,t=e.pop(),r=e.pop(),s=e.pop(),i=e.pop(),o=e.pop(),a=n.z0,l=n.z1,u=a[t],c=a[r],h=l[s],f=l[i],p=n.z2[o];exports.DEBUG&&console.log("ISECT[], ",t,r,s,i,o);var d=u.x,g=u.y,m=c.x,x=c.y,L=h.x,b=h.y,M=f.x,E=f.y,O=(d-m)*(b-E)-(g-x)*(L-M),w=d*x-g*m,T=L*E-b*M;p.x=(w*(L-M)-T*(d-m))/O,p.y=(w*(b-E)-T*(g-x))/O}function yc(n){n.rp0=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function bc(n){n.rp1=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function Sc(n){n.rp2=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function wc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||ar(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function kc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||ar(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ec(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||ar(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Pc(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZPS[]",e),n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||ar(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Lc(n){n.loop=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function Tc(n){exports.DEBUG&&console.log(n.step,"RTG[]"),n.round=_o}function Ic(n){exports.DEBUG&&console.log(n.step,"RTHG[]"),n.round=uc}function Mc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function Cc(n){exports.DEBUG&&console.log(n.step,"ELSE[]"),Zo(n,!1)}function Ac(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function Oc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function Fc(n){var e=n.stack;exports.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function qr(n){exports.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function Dc(n){exports.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function Rc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(r)}function Uc(n){var e=n.stack;exports.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function Nc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"LOOPCALL[]",t,r);var s=n.ip,i=n.prog;n.prog=n.funcs[t];for(var o=0;o<r;o++)Pt(n),exports.DEBUG&&console.log(++n.step,o+1<r?"next loopcall":"done loopcall",o);n.ip=s,n.prog=i}function Bc(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"CALL[]",e);var t=n.ip,r=n.prog;n.prog=n.funcs[e],Pt(n),n.ip=t,n.prog=r,exports.DEBUG&&console.log(++n.step,"returning from",e)}function Gc(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function $c(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function zc(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");var e=n.stack,t=n.prog,r=n.ip,s=e.pop(),i=r;for(exports.DEBUG&&console.log(n.step,"FDEF[]",s);t[++r]!==45;);n.ip=r,n.funcs[s]=t.slice(i+1,r)}function Xi(n,e){var t=e.stack.pop(),r=e.z0[t],s=e.fv,i=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);var o=i.distance(r,pn);n&&(o=e.round(o)),s.setRelative(r,pn,o,i),s.touch(r),e.rp0=e.rp1=t}function Wi(n,e){var t=e.z2,r=t.length-2,s,i,o;exports.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(var a=0;a<r;a++)s=t[a],!n.touched(s)&&(i=s.prevTouched(n),i!==s&&(o=s.nextTouched(n),i===o&&n.setRelative(s,s,n.distance(i,i,!1,!0),n,!0),n.interpolate(s,i,o,n)))}function _i(n,e){for(var t=e.stack,r=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=e.loop,l=e.z2;a--;){var u=t.pop(),c=l[u],h=o.distance(s,s,!1,!0);i.setRelative(c,c,h,o),i.touch(c),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",u)}e.loop=1}function ji(n,e){var t=e.stack,r=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=t.pop(),l=e.z2[e.contours[a]],u=l;exports.DEBUG&&console.log(e.step,"SHC["+n+"]",a);var c=o.distance(s,s,!1,!0);do u!==s&&i.setRelative(u,u,c,o),u=u.nextPointOnContour;while(u!==l)}function Zi(n,e){var t=e.stack,r=n?e.rp1:e.rp2,s=(n?e.z0:e.z1)[r],i=e.fv,o=e.pv,a=t.pop();exports.DEBUG&&console.log(e.step,"SHZ["+n+"]",a);var l;switch(a){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}for(var u,c=o.distance(s,s,!1,!0),h=l.length-2,f=0;f<h;f++)u=l[f],i.setRelative(u,u,c,o)}function Hc(n){for(var e=n.stack,t=n.loop,r=n.fv,s=e.pop()/64,i=n.z2;t--;){var o=e.pop(),a=i[o];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",o,s),r.setRelative(a,a,s),r.touch(a)}n.loop=1}function Vc(n){for(var e=n.stack,t=n.rp1,r=n.rp2,s=n.loop,i=n.z0[t],o=n.z1[r],a=n.fv,l=n.dpv,u=n.z2;s--;){var c=e.pop(),h=u[c];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"IP[]",c,t,"<->",r),a.interpolate(h,i,o,l),a.touch(h)}n.loop=1}function Yi(n,e){var t=e.stack,r=t.pop()/64,s=t.pop(),i=e.z1[s],o=e.z0[e.rp0],a=e.fv,l=e.pv;a.setRelative(i,o,r,l),a.touch(i),exports.DEBUG&&console.log(e.step,"MSIRP["+n+"]",r,s),e.rp1=e.rp0,e.rp2=s,n&&(e.rp0=s)}function qc(n){for(var e=n.stack,t=n.rp0,r=n.z0[t],s=n.loop,i=n.fv,o=n.pv,a=n.z1;s--;){var l=e.pop(),u=a[l];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-s)+": ":"")+"ALIGNRP[]",l),i.setRelative(u,r,0,o),i.touch(u)}n.loop=1}function Xc(n){exports.DEBUG&&console.log(n.step,"RTDG[]"),n.round=lc}function Ki(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z0[s],o=e.fv,a=e.pv,l=e.cvt[r];exports.DEBUG&&console.log(e.step,"MIAP["+n+"]",r,"(",l,")",s);var u=a.distance(i,pn);n&&(Math.abs(u-l)<e.cvCutIn&&(u=l),u=e.round(u)),o.setRelative(i,pn,u,a),e.zp0===0&&(i.xo=i.x,i.yo=i.y),o.touch(i),e.rp0=e.rp1=s}function Wc(n){var e=n.prog,t=n.ip,r=n.stack,s=e[++t];exports.DEBUG&&console.log(n.step,"NPUSHB[]",s);for(var i=0;i<s;i++)r.push(e[++t]);n.ip=t}function _c(n){var e=n.ip,t=n.prog,r=n.stack,s=t[++e];exports.DEBUG&&console.log(n.step,"NPUSHW[]",s);for(var i=0;i<s;i++){var o=t[++e]<<8|t[++e];o&32768&&(o=-((o^65535)+1)),r.push(o)}n.ip=e}function jc(n){var e=n.stack,t=n.store;t||(t=n.store=[]);var r=e.pop(),s=e.pop();exports.DEBUG&&console.log(n.step,"WS",r,s),t[s]=r}function Zc(n){var e=n.stack,t=n.store,r=e.pop();exports.DEBUG&&console.log(n.step,"RS",r);var s=t&&t[r]||0;e.push(s)}function Yc(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"WCVTP",t,r),n.cvt[r]=t/64}function Kc(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function Ji(n,e){var t=e.stack,r=t.pop(),s=e.z2[r];exports.DEBUG&&console.log(e.step,"GC["+n+"]",r),t.push(e.dpv.distance(s,pn,n,!1)*64)}function Qi(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z1[r],o=e.z0[s],a=e.dpv.distance(o,i,n,n);exports.DEBUG&&console.log(e.step,"MD["+n+"]",r,s,"->",a),e.stack.push(Math.round(a*64))}function Jc(n){exports.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function Qc(n){exports.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function ef(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"LT[]",t,r),e.push(r<t?1:0)}function tf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"LTEQ[]",t,r),e.push(r<=t?1:0)}function nf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"GT[]",t,r),e.push(r>t?1:0)}function rf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"GTEQ[]",t,r),e.push(r>=t?1:0)}function sf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"EQ[]",t,r),e.push(t===r?1:0)}function of(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"NEQ[]",t,r),e.push(t!==r?1:0)}function af(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function lf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function uf(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"IF[]",e),e||(Zo(n,!0),exports.DEBUG&&console.log(n.step,"EIF[]"))}function cf(n){exports.DEBUG&&console.log(n.step,"EIF[]")}function ff(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"AND[]",t,r),e.push(t&&r?1:0)}function hf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"OR[]",t,r),e.push(t||r?1:0)}function pf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function Xr(n,e){var t=e.stack,r=t.pop(),s=e.fv,i=e.pv,o=e.ppem,a=e.deltaBase+(n-1)*16,l=e.deltaShift,u=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+n+"]",r,t);for(var c=0;c<r;c++){var h=t.pop(),f=t.pop(),p=a+((f&240)>>4);if(p===o){var d=(f&15)-8;d>=0&&d++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",h,"by",d*l);var g=u[h];s.setRelative(g,g,d*l,i)}}}function df(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function gf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function mf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"ADD[]",t,r),e.push(r+t)}function vf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"SUB[]",t,r),e.push(r-t)}function xf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"DIV[]",t,r),e.push(r*64/t)}function yf(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"MUL[]",t,r),e.push(r*t/64)}function bf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function Sf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function wf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function kf(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Jn(n,e){var t=e.stack,r=t.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(r/64)*64)}function Ef(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"WCVTF[]",t,r),n.cvt[r]=t*n.ppem/n.font.unitsPerEm}function Wr(n,e){var t=e.stack,r=t.pop(),s=e.ppem,i=e.deltaBase+(n-1)*16,o=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+n+"]",r,t);for(var a=0;a<r;a++){var l=t.pop(),u=t.pop(),c=i+((u&240)>>4);if(c===s){var h=(u&15)-8;h>=0&&h++;var f=h*o;exports.DEBUG&&console.log(e.step,"DELTACFIX",l,"by",f),e.cvt[l]+=f}}}function Pf(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=jo;var t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Lf(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=jo;var t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function Tf(n){exports.DEBUG&&console.log(n.step,"ROFF[]"),n.round=ac}function If(n){exports.DEBUG&&console.log(n.step,"RUTG[]"),n.round=cc}function Mf(n){exports.DEBUG&&console.log(n.step,"RDTG[]"),n.round=fc}function Cf(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function eo(n,e){var t=e.stack,r=t.pop(),s=t.pop(),i=e.z2[r],o=e.z1[s];exports.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",r,s);var a,l;n?(a=i.y-o.y,l=o.x-i.x):(a=o.x-i.x,l=o.y-i.y),e.dpv=vn(a,l)}function Af(n){var e=n.stack,t=e.pop(),r=0;exports.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(r=35),t&32&&(r|=4096),e.push(r)}function Of(n){var e=n.stack,t=e.pop(),r=e.pop(),s=e.pop();exports.DEBUG&&console.log(n.step,"ROLL[]"),e.push(r),e.push(t),e.push(s)}function Ff(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"MAX[]",t,r),e.push(Math.max(r,t))}function Df(n){var e=n.stack,t=e.pop(),r=e.pop();exports.DEBUG&&console.log(n.step,"MIN[]",t,r),e.push(Math.min(r,t))}function Rf(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function Uf(n){var e=n.stack.pop(),t=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"INSTCTRL[]",e,t),e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function ut(n,e){var t=e.stack,r=e.prog,s=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(var i=0;i<n;i++)t.push(r[++s]);e.ip=s}function ct(n,e){var t=e.ip,r=e.prog,s=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(var i=0;i<n;i++){var o=r[++t]<<8|r[++t];o&32768&&(o=-((o^65535)+1)),s.push(o)}e.ip=t}function D(n,e,t,r,s,i){var o=i.stack,a=n&&o.pop(),l=o.pop(),u=i.rp0,c=i.z0[u],h=i.z1[l],f=i.minDis,p=i.fv,d=i.dpv,g,m,x,L;m=g=d.distance(h,c,!0,!0),x=m>=0?1:-1,m=Math.abs(m),n&&(L=i.cvt[a],r&&Math.abs(m-L)<i.cvCutIn&&(m=L)),t&&m<f&&(m=f),r&&(m=i.round(m)),p.setRelative(h,c,x*m,d),p.touch(h),exports.DEBUG&&console.log(i.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(r?"R":"_")+(s===0?"Gr":s===1?"Bl":s===2?"Wh":"")+"]",n?a+"("+i.cvt[a]+","+L+")":"",l,"(d =",g,"->",x*m,")"),i.rp1=i.rp0,i.rp2=l,e&&(i.rp0=l)}qo=[$i.bind(void 0,st),$i.bind(void 0,et),zi.bind(void 0,st),zi.bind(void 0,et),Hi.bind(void 0,st),Hi.bind(void 0,et),Vi.bind(void 0,0),Vi.bind(void 0,1),qi.bind(void 0,0),qi.bind(void 0,1),pc,dc,gc,mc,vc,xc,yc,bc,Sc,wc,kc,Ec,Pc,Lc,Tc,Ic,Mc,Cc,Ac,Oc,void 0,void 0,Fc,qr,Dc,Rc,Uc,Gc,$c,void 0,void 0,void 0,Nc,Bc,zc,void 0,Xi.bind(void 0,0),Xi.bind(void 0,1),Wi.bind(void 0,st),Wi.bind(void 0,et),_i.bind(void 0,0),_i.bind(void 0,1),ji.bind(void 0,0),ji.bind(void 0,1),Zi.bind(void 0,0),Zi.bind(void 0,1),Hc,Vc,Yi.bind(void 0,0),Yi.bind(void 0,1),qc,Xc,Ki.bind(void 0,0),Ki.bind(void 0,1),Wc,_c,jc,Zc,Yc,Kc,Ji.bind(void 0,0),Ji.bind(void 0,1),void 0,Qi.bind(void 0,0),Qi.bind(void 0,1),Jc,void 0,Qc,void 0,void 0,ef,tf,nf,rf,sf,of,af,lf,uf,cf,ff,hf,pf,Xr.bind(void 0,1),df,gf,mf,vf,xf,yf,bf,Sf,wf,kf,Jn.bind(void 0,0),Jn.bind(void 0,1),Jn.bind(void 0,2),Jn.bind(void 0,3),void 0,void 0,void 0,void 0,Ef,Xr.bind(void 0,2),Xr.bind(void 0,3),Wr.bind(void 0,1),Wr.bind(void 0,2),Wr.bind(void 0,3),Pf,Lf,void 0,void 0,Tf,void 0,If,Mf,qr,qr,void 0,void 0,void 0,void 0,void 0,Cf,eo.bind(void 0,0),eo.bind(void 0,1),Af,void 0,Of,Ff,Df,Rf,Uf,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ut.bind(void 0,1),ut.bind(void 0,2),ut.bind(void 0,3),ut.bind(void 0,4),ut.bind(void 0,5),ut.bind(void 0,6),ut.bind(void 0,7),ut.bind(void 0,8),ct.bind(void 0,1),ct.bind(void 0,2),ct.bind(void 0,3),ct.bind(void 0,4),ct.bind(void 0,5),ct.bind(void 0,6),ct.bind(void 0,7),ct.bind(void 0,8),D.bind(void 0,0,0,0,0,0),D.bind(void 0,0,0,0,0,1),D.bind(void 0,0,0,0,0,2),D.bind(void 0,0,0,0,0,3),D.bind(void 0,0,0,0,1,0),D.bind(void 0,0,0,0,1,1),D.bind(void 0,0,0,0,1,2),D.bind(void 0,0,0,0,1,3),D.bind(void 0,0,0,1,0,0),D.bind(void 0,0,0,1,0,1),D.bind(void 0,0,0,1,0,2),D.bind(void 0,0,0,1,0,3),D.bind(void 0,0,0,1,1,0),D.bind(void 0,0,0,1,1,1),D.bind(void 0,0,0,1,1,2),D.bind(void 0,0,0,1,1,3),D.bind(void 0,0,1,0,0,0),D.bind(void 0,0,1,0,0,1),D.bind(void 0,0,1,0,0,2),D.bind(void 0,0,1,0,0,3),D.bind(void 0,0,1,0,1,0),D.bind(void 0,0,1,0,1,1),D.bind(void 0,0,1,0,1,2),D.bind(void 0,0,1,0,1,3),D.bind(void 0,0,1,1,0,0),D.bind(void 0,0,1,1,0,1),D.bind(void 0,0,1,1,0,2),D.bind(void 0,0,1,1,0,3),D.bind(void 0,0,1,1,1,0),D.bind(void 0,0,1,1,1,1),D.bind(void 0,0,1,1,1,2),D.bind(void 0,0,1,1,1,3),D.bind(void 0,1,0,0,0,0),D.bind(void 0,1,0,0,0,1),D.bind(void 0,1,0,0,0,2),D.bind(void 0,1,0,0,0,3),D.bind(void 0,1,0,0,1,0),D.bind(void 0,1,0,0,1,1),D.bind(void 0,1,0,0,1,2),D.bind(void 0,1,0,0,1,3),D.bind(void 0,1,0,1,0,0),D.bind(void 0,1,0,1,0,1),D.bind(void 0,1,0,1,0,2),D.bind(void 0,1,0,1,0,3),D.bind(void 0,1,0,1,1,0),D.bind(void 0,1,0,1,1,1),D.bind(void 0,1,0,1,1,2),D.bind(void 0,1,0,1,1,3),D.bind(void 0,1,1,0,0,0),D.bind(void 0,1,1,0,0,1),D.bind(void 0,1,1,0,0,2),D.bind(void 0,1,1,0,0,3),D.bind(void 0,1,1,0,1,0),D.bind(void 0,1,1,0,1,1),D.bind(void 0,1,1,0,1,2),D.bind(void 0,1,1,0,1,3),D.bind(void 0,1,1,1,0,0),D.bind(void 0,1,1,1,0,1),D.bind(void 0,1,1,1,0,2),D.bind(void 0,1,1,1,0,3),D.bind(void 0,1,1,1,1,0),D.bind(void 0,1,1,1,1,1),D.bind(void 0,1,1,1,1,2),D.bind(void 0,1,1,1,1,3)];function zt(n){this.char=n,this.state={},this.activeState=null}function hs(n,e,t){this.contextName=t,this.startIndex=n,this.endOffset=e}function Nf(n,e,t){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function Xe(n,e){this.context=n,this.index=e,this.length=n.length,this.current=n[e],this.backtrack=n.slice(0,e),this.lookahead=n.slice(e+1)}function lr(n){this.eventId=n,this.subscribers=[]}function Bf(n){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(s){Object.defineProperty(e.events,s,{value:new lr(s)})}),n&&t.forEach(function(s){var i=n[s];typeof i=="function"&&e.events[s].subscribe(i)});var r=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];r.forEach(function(s){e.events[s].subscribe(e.updateContextsRanges)})}function ge(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Bf.call(this,n)}zt.prototype.setState=function(n,e){return this.state[n]=e,this.activeState={key:n,value:this.state[n]},this.activeState};zt.prototype.getState=function(n){return this.state[n]||null};ge.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length};ge.prototype.composeRUD=function(n){var e=this,t=!0,r=n.map(function(i){return e[i[0]].apply(e,i.slice(1).concat(t))}),s=function(i){return typeof i=="object"&&i.hasOwnProperty("FAIL")};if(r.every(s))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:r.filter(s)};this.dispatch("composeRUD",[r.filter(function(i){return!s(i)})])};ge.prototype.replaceRange=function(n,e,t,r){e=e!==null?e:this.tokens.length;var s=t.every(function(o){return o instanceof zt});if(!isNaN(n)&&this.inboundIndex(n)&&s){var i=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return r||this.dispatch("replaceToken",[n,e,t]),[i,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};ge.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof zt){var r=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};ge.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;var r=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[r,n,e]),r};ge.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){var t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};ge.prototype.insertToken=function(n,e,t){var r=n.every(function(s){return s instanceof zt});return r?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};ge.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(r,s){var i=[r,s],o=e===null||e.apply(this,i)===!0,a=[r,s];if(o){var l=t.apply(this,a);r.setState(n,l)}}),this.registeredModifiers.push(n)};lr.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};lr.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};Xe.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};Xe.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};ge.prototype.rangeToText=function(n){if(n instanceof hs)return this.getRangeTokens(n).map(function(e){return e.char}).join("")};ge.prototype.getText=function(){return this.tokens.map(function(n){return n.char}).join("")};ge.prototype.getContext=function(n){var e=this.registeredContexts[n];return e||null};ge.prototype.on=function(n,e){var t=this.events[n];return t?t.subscribe(e):null};ge.prototype.dispatch=function(n,e){var t=this,r=this.events[n];r instanceof lr&&r.subscribers.forEach(function(s){s.apply(t,e||[])})};ge.prototype.registerContextChecker=function(n,e,t){if(this.getContext(n))return{FAIL:"context name '"+n+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};var r=new Nf(n,e,t);return this.registeredContexts[n]=r,this.contextCheckers.push(r),r};ge.prototype.getRangeTokens=function(n){var e=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,e))};ge.prototype.getContextRanges=function(n){var e=this.getContext(n);return e?e.ranges:{FAIL:"context checker '"+n+"' is not registered."}};ge.prototype.resetContextsRanges=function(){var n=this.registeredContexts;for(var e in n)if(n.hasOwnProperty(e)){var t=n[e];t.ranges=[]}};ge.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var n=this.tokens.map(function(r){return r.char}),e=0;e<n.length;e++){var t=new Xe(n,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])};ge.prototype.setEndOffset=function(n,e){var t=this.getContext(e).openRange.startIndex,r=new hs(t,n,e),s=this.getContext(e).ranges;return r.rangeId=e+"."+s.length,s.push(r),this.getContext(e).openRange=null,r};ge.prototype.runContextCheck=function(n){var e=this,t=n.index;this.contextCheckers.forEach(function(r){var s=r.contextName,i=e.getContext(s).openRange;if(!i&&r.checkStart(n)&&(i=new hs(t,null,s),e.getContext(s).openRange=i,e.dispatch("contextStart",[s,t])),i&&r.checkEnd(n)){var o=t-i.startIndex+1,a=e.setEndOffset(o,s);e.dispatch("contextEnd",[s,a])}})};ge.prototype.tokenize=function(n){this.tokens=[],this.resetContextsRanges();var e=Array.from(n);this.dispatch("start");for(var t=0;t<e.length;t++){var r=e[t],s=new Xe(e,t);this.dispatch("next",[s]),this.runContextCheck(s);var i=new zt(r);this.tokens.push(i),this.dispatch("newToken",[i,s])}return this.dispatch("end",[this.tokens]),this.tokens};function pt(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function Yo(n){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(n)}function dt(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function er(n){return/[A-z]/.test(n)}function Gf(n){return/\s/.test(n)}function Re(n){this.font=n,this.features={}}function Et(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function xn(n,e){if(!n)return-1;switch(e.format){case 1:return e.glyphs.indexOf(n);case 2:for(var t=e.ranges,r=0;r<t.length;r++){var s=t[r];if(n>=s.start&&n<=s.end){var i=n-s.start;return s.index+i}}break;default:return-1}return-1}function $f(n,e){var t=xn(n,e.coverage);return t===-1?null:n+e.deltaGlyphId}function zf(n,e){var t=xn(n,e.coverage);return t===-1?null:e.substitute[t]}function _r(n,e){for(var t=[],r=0;r<n.length;r++){var s=n[r],i=e.current;i=Array.isArray(i)?i[0]:i;var o=xn(i,s);o!==-1&&t.push(o)}return t.length!==n.length?-1:t}function Hf(n,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(n.context.length<t)return[];var r=_r(e.inputCoverage,n);if(r===-1)return[];var s=e.inputCoverage.length-1;if(n.lookahead.length<e.lookaheadCoverage.length)return[];for(var i=n.lookahead.slice(s);i.length&&dt(i[0].char);)i.shift();var o=new Xe(i,0),a=_r(e.lookaheadCoverage,o),l=[].concat(n.backtrack);for(l.reverse();l.length&&dt(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];var u=new Xe(l,0),c=_r(e.backtrackCoverage,u),h=r.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&c.length===e.backtrackCoverage.length,f=[];if(h)for(var p=0;p<e.lookupRecords.length;p++)for(var d=e.lookupRecords[p],g=d.lookupListIndex,m=this.getLookupByIndex(g),x=0;x<m.subtables.length;x++){var L=m.subtables[x],b=this.getLookupMethod(m,L),M=this.getSubstitutionType(m,L);if(M==="12")for(var E=0;E<r.length;E++){var O=n.get(E),w=b(O);w&&f.push(w)}}return f}function Vf(n,e){var t=n.current,r=xn(t,e.coverage);if(r===-1)return null;for(var s,i=e.ligatureSets[r],o=0;o<i.length;o++){s=i[o];for(var a=0;a<s.components.length;a++){var l=n.lookahead[a],u=s.components[a];if(l!==u)break;if(a===s.components.length-1)return s}}return null}function qf(n,e){var t=xn(n,e.coverage);return t===-1?null:e.sequences[t]}Re.prototype.getDefaultScriptFeaturesIndexes=function(){for(var n=this.font.tables.gsub.scripts,e=0;e<n.length;e++){var t=n[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]};Re.prototype.getScriptFeaturesIndexes=function(n){var e=this.font.tables;if(!e.gsub)return[];if(!n)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,r=0;r<t.length;r++){var s=t[r];if(s.tag===n&&s.script.defaultLangSys)return s.script.defaultLangSys.featureIndexes;var i=s.langSysRecords;if(i)for(var o=0;o<i.length;o++){var a=i[o];if(a.tag===n){var l=a.langSys;return l.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};Re.prototype.mapTagsToFeatures=function(n,e){for(var t={},r=0;r<n.length;r++){var s=n[r].tag,i=n[r].feature;t[s]=i}this.features[e].tags=t};Re.prototype.getScriptFeatures=function(n){var e=this.features[n];if(this.features.hasOwnProperty(n))return e;var t=this.getScriptFeaturesIndexes(n);if(!t)return null;var r=this.font.tables.gsub;return e=t.map(function(s){return r.features[s]}),this.features[n]=e,this.mapTagsToFeatures(e,n),e};Re.prototype.getSubstitutionType=function(n,e){var t=n.lookupType.toString(),r=e.substFormat.toString();return t+r};Re.prototype.getLookupMethod=function(n,e){var t=this,r=this.getSubstitutionType(n,e);switch(r){case"11":return function(s){return $f.apply(t,[s,e])};case"12":return function(s){return zf.apply(t,[s,e])};case"63":return function(s){return Hf.apply(t,[s,e])};case"41":return function(s){return Vf.apply(t,[s,e])};case"21":return function(s){return qf.apply(t,[s,e])};default:throw new Error("lookupType: "+n.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};Re.prototype.lookupFeature=function(n){var e=n.contextParams,t=e.index,r=this.getFeature({tag:n.tag,script:n.script});if(!r)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+n.tag+"' for script '"+n.script+"'.");for(var s=this.getFeatureLookups(r),i=[].concat(e.context),o=0;o<s.length;o++)for(var a=s[o],l=this.getLookupSubtables(a),u=0;u<l.length;u++){var c=l[u],h=this.getSubstitutionType(a,c),f=this.getLookupMethod(a,c),p=void 0;switch(h){case"11":p=f(e.current),p&&i.splice(t,1,new Et({id:11,tag:n.tag,substitution:p}));break;case"12":p=f(e.current),p&&i.splice(t,1,new Et({id:12,tag:n.tag,substitution:p}));break;case"63":p=f(e),Array.isArray(p)&&p.length&&i.splice(t,1,new Et({id:63,tag:n.tag,substitution:p}));break;case"41":p=f(e),p&&i.splice(t,1,new Et({id:41,tag:n.tag,substitution:p}));break;case"21":p=f(e.current),p&&i.splice(t,1,new Et({id:21,tag:n.tag,substitution:p}));break}e=new Xe(i,t),!(Array.isArray(p)&&!p.length)&&(p=null)}return i.length?i:null};Re.prototype.supports=function(n){if(!n.script)return!1;this.getScriptFeatures(n.script);var e=this.features.hasOwnProperty(n.script);if(!n.tag)return e;var t=this.features[n.script].some(function(r){return r.tag===n.tag});return e&&t};Re.prototype.getLookupSubtables=function(n){return n.subtables||null};Re.prototype.getLookupByIndex=function(n){var e=this.font.tables.gsub.lookups;return e[n]||null};Re.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};Re.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};function Xf(n){var e=n.current,t=n.get(-1);return t===null&&pt(e)||!pt(t)&&pt(e)}function Wf(n){var e=n.get(1);return e===null||!pt(e)}var _f={startCheck:Xf,endCheck:Wf};function jf(n){var e=n.current,t=n.get(-1);return(pt(e)||dt(e))&&!pt(t)}function Zf(n){var e=n.get(1);switch(!0){case e===null:return!0;case(!pt(e)&&!dt(e)):var t=Gf(e);if(!t)return!0;if(t){var r=!1;if(r=n.lookahead.some(function(s){return pt(s)||dt(s)}),!r)return!0}break;default:return!1}}var Yf={startCheck:jf,endCheck:Zf};function Kf(n,e,t){e[t].setState(n.tag,n.substitution)}function Jf(n,e,t){e[t].setState(n.tag,n.substitution)}function Qf(n,e,t){n.substitution.forEach(function(r,s){var i=e[t+s];i.setState(n.tag,r)})}function eh(n,e,t){var r=e[t];r.setState(n.tag,n.substitution.ligGlyph);for(var s=n.substitution.components.length,i=0;i<s;i++)r=e[t+i+1],r.setState("deleted",!0)}var to={11:Kf,12:Jf,63:Qf,41:eh};function ps(n,e,t){n instanceof Et&&to[n.id]&&to[n.id](n,e,t)}function th(n){for(var e=[].concat(n.backtrack),t=e.length-1;t>=0;t--){var r=e[t],s=Yo(r),i=dt(r);if(!s&&!i)return!0;if(s)return!1}return!1}function nh(n){if(Yo(n.current))return!1;for(var e=0;e<n.lookahead.length;e++){var t=n.lookahead[e],r=dt(t);if(!r)return!0}return!1}function rh(n){var e=this,t="arab",r=this.featuresTags[t],s=this.tokenizer.getRangeTokens(n);if(s.length!==1){var i=new Xe(s.map(function(a){return a.getState("glyphIndex")}),0),o=new Xe(s.map(function(a){return a.char}),0);s.forEach(function(a,l){if(!dt(a.char)){i.setCurrentIndex(l),o.setCurrentIndex(l);var u=0;th(o)&&(u|=1),nh(o)&&(u|=2);var c;switch(u){case 1:c="fina";break;case 2:c="init";break;case 3:c="medi";break}if(r.indexOf(c)!==-1){var h=e.query.lookupFeature({tag:c,script:t,contextParams:i});if(h instanceof Error)return console.info(h.message);h.forEach(function(f,p){f instanceof Et&&(ps(f,s,p),i.context[p]=f.substitution)})}}})}}function no(n,e){var t=n.map(function(r){return r.activeState.value});return new Xe(t,e||0)}function sh(n){var e=this,t="arab",r=this.tokenizer.getRangeTokens(n),s=no(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:t,contextParams:s});a.length&&(a.forEach(function(l){return ps(l,r,o)}),s=no(r))})}function ih(n){var e=n.current,t=n.get(-1);return t===null&&er(e)||!er(t)&&er(e)}function oh(n){var e=n.get(1);return e===null||!er(e)}var ah={startCheck:ih,endCheck:oh};function ro(n,e){var t=n.map(function(r){return r.activeState.value});return new Xe(t,e||0)}function lh(n){var e=this,t="latn",r=this.tokenizer.getRangeTokens(n),s=ro(r);s.context.forEach(function(i,o){s.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:t,contextParams:s});a.length&&(a.forEach(function(l){return ps(l,r,o)}),s=ro(r))})}function je(n){this.baseDir=n||"ltr",this.tokenizer=new ge,this.featuresTags={}}je.prototype.setText=function(n){this.text=n};je.prototype.contextChecks={latinWordCheck:ah,arabicWordCheck:_f,arabicSentenceCheck:Yf};function jr(n){var e=this.contextChecks[n+"Check"];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function uh(){return jr.call(this,"latinWord"),jr.call(this,"arabicWord"),jr.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function ch(){var n=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var r=n.tokenizer.getRangeTokens(t);n.tokenizer.replaceRange(t.startIndex,t.endOffset,r.reverse())})}je.prototype.registerFeatures=function(n,e){var t=this,r=e.filter(function(s){return t.query.supports({script:n,tag:s})});this.featuresTags.hasOwnProperty(n)?this.featuresTags[n]=this.featuresTags[n].concat(r):this.featuresTags[n]=r};je.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Re(n));for(var t=0;t<e.length;t++){var r=e[t];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}};je.prototype.registerModifier=function(n,e,t){this.tokenizer.registerModifier(n,e,t)};function ds(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function fh(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){ds.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(r){rh.call(n,r)})}}function hh(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){ds.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(s){sh.call(n,s)})}}}function ph(){var n=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){ds.call(this);var r=this.tokenizer.getContextRanges("latinWord");r.forEach(function(s){lh.call(n,s)})}}}je.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)};je.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(fh.call(this),hh.call(this)),this.checkContextReady("latinWord")&&ph.call(this),this.checkContextReady("arabicSentence")&&ch.call(this)};je.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),uh.call(this),this.applyFeaturesToContexts())};je.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()};je.prototype.getTextGlyphs=function(n){this.processText(n);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var r=this.tokenizer.tokens[t];if(!r.state.deleted){var s=r.activeState.value;e.push(Array.isArray(s)?s[0]:s)}}return e};function oe(n){n=n||{},n.tables=n.tables||{},n.empty||(ln(n.familyName,"When creating a new Font object, familyName is required."),ln(n.styleName,"When creating a new Font object, styleName is required."),ln(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),ln(n.ascender,"When creating a new Font object, ascender is required."),ln(n.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={fontFamily:{en:n.familyName||" "},fontSubfamily:{en:n.styleName||" "},fullName:{en:n.fullName||n.familyName+" "+n.styleName},postScriptName:{en:n.postScriptName||(n.familyName+n.styleName).replace(/\s/g,"")},designer:{en:n.designer||" "},designerURL:{en:n.designerURL||" "},manufacturer:{en:n.manufacturer||" "},manufacturerURL:{en:n.manufacturerURL||" "},license:{en:n.license||" "},licenseURL:{en:n.licenseURL||" "},version:{en:n.version||"Version 0.1"},description:{en:n.description||" "},copyright:{en:n.copyright||" "},trademark:{en:n.trademark||" "}},this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,fsSelection:n.fsSelection||this.fsSelectionValues.REGULAR},n.tables.os2)})),this.supported=!0,this.glyphs=new tt.GlyphSet(this,n.glyphs||[]),this.encoding=new go(this),this.position=new gn(this),this.substitution=new De(this),this.tables=this.tables||{},this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){if(this._hinting)return this._hinting;if(this.outlinesFormat==="truetype")return this._hinting=new Wo(this)}})}oe.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null};oe.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};oe.prototype.charToGlyph=function(n){var e=this.charToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};oe.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(t){return n[t]})}:e})};oe.prototype.stringToGlyphs=function(n,e){var t=this,r=new je,s=function(h){return t.charToGlyphIndex(h.char)};r.registerModifier("glyphIndex",null,s);var i=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;r.applyFeatures(this,i);for(var o=r.getTextGlyphs(n),a=o.length,l=new Array(a),u=this.glyphs.get(0),c=0;c<a;c+=1)l[c]=this.glyphs.get(o[c])||u;return l};oe.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)};oe.prototype.nameToGlyph=function(n){var e=this.nameToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};oe.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""};oe.prototype.getKerningValue=function(n,e){n=n.index||n,e=e.index||e;var t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,n,e):this.kerningPairs[n+","+e]||0};oe.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};oe.prototype.forEachGlyph=function(n,e,t,r,s,i){e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:72,s=Object.assign({},this.defaultRenderOptions,s);var o=1/this.unitsPerEm*r,a=this.stringToGlyphs(n,s),l;if(s.kerning){var u=s.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(u,s.language)}for(var c=0;c<a.length;c+=1){var h=a[c];if(i.call(this,h,e,t,r,s),h.advanceWidth&&(e+=h.advanceWidth*o),s.kerning&&c<a.length-1){var f=l?this.position.getKerningValue(l,h.index,a[c+1].index):this.getKerningValue(h,a[c+1]);e+=f*o}s.letterSpacing?e+=s.letterSpacing*r:s.tracking&&(e+=s.tracking/1e3*r)}return e};oe.prototype.getPath=function(n,e,t,r,s){var i=new ye;return this.forEachGlyph(n,e,t,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.extend(c)}),i};oe.prototype.getPaths=function(n,e,t,r,s){var i=[];return this.forEachGlyph(n,e,t,r,s,function(o,a,l,u){var c=o.getPath(a,l,u,s,this);i.push(c)}),i};oe.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})};oe.prototype.draw=function(n,e,t,r,s,i){this.getPath(e,t,r,s,i).draw(n)};oe.prototype.drawPoints=function(n,e,t,r,s,i){this.forEachGlyph(e,t,r,s,i,function(o,a,l,u){o.drawPoints(n,a,l,u)})};oe.prototype.drawMetrics=function(n,e,t,r,s,i){this.forEachGlyph(e,t,r,s,i,function(o,a,l,u){o.drawMetrics(n,a,l,u)})};oe.prototype.getEnglishName=function(n){var e=this.names[n];if(e)return e.en};oe.prototype.validate=function(){var n=this;function e(r,s){}function t(r){var s=n.getEnglishName(r);s&&s.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0};oe.prototype.toTables=function(){return Qu.fontToTable(this)};oe.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};oe.prototype.toArrayBuffer=function(){for(var n=this.toTables(),e=n.encode(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),s=0;s<e.length;s++)r[s]=e[s];return t};oe.prototype.download=function(n){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";var r=this.toArrayBuffer();if(tc())if(window.URL=window.URL||window.webkitURL,window.URL){var s=new DataView(r),i=new Blob([s],{type:"font/opentype"}),o=document.createElement("a");o.href=window.URL.createObjectURL(i),o.download=n;var a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),o.dispatchEvent(a)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var l=yi(),u=nc(r);l.writeFileSync(n,u)}};oe.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};oe.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9};oe.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Ko(n,e){var t=JSON.stringify(n),r=256;for(var s in e){var i=parseInt(s);if(!(!i||i<256)){if(JSON.stringify(e[s])===t)return i;r<=i&&(r=i+1)}}return e[r]=n,r}function dh(n,e,t){var r=Ko(e.name,t);return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:r}]}function gh(n,e,t){var r={},s=new R.Parser(n,e);return r.tag=s.parseTag(),r.minValue=s.parseFixed(),r.defaultValue=s.parseFixed(),r.maxValue=s.parseFixed(),s.skip("uShort",1),r.name=t[s.parseUShort()]||{},r}function mh(n,e,t,r){for(var s=Ko(e.name,r),i=[{name:"nameID_"+n,type:"USHORT",value:s},{name:"flags_"+n,type:"USHORT",value:0}],o=0;o<t.length;++o){var a=t[o].tag;i.push({name:"axis_"+n+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return i}function vh(n,e,t,r){var s={},i=new R.Parser(n,e);s.name=r[i.parseUShort()]||{},i.skip("uShort",1),s.coordinates={};for(var o=0;o<t.length;++o)s.coordinates[t[o].tag]=i.parseFixed();return s}function xh(n,e){var t=new F.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(var r=0;r<n.axes.length;r++)t.fields=t.fields.concat(dh(r,n.axes[r],e));for(var s=0;s<n.instances.length;s++)t.fields=t.fields.concat(mh(s,n.instances[s],n.axes,e));return t}function yh(n,e,t){var r=new R.Parser(n,e),s=r.parseULong();G.argument(s===65536,"Unsupported fvar table version.");var i=r.parseOffset16();r.skip("uShort",1);for(var o=r.parseUShort(),a=r.parseUShort(),l=r.parseUShort(),u=r.parseUShort(),c=[],h=0;h<o;h++)c.push(gh(n,e+i+h*a,t));for(var f=[],p=e+i+o*a,d=0;d<l;d++)f.push(vh(n,p+d*u,c,t));return{axes:c,instances:f}}var bh={make:xh,parse:yh},Sh=function(){return{coverage:this.parsePointer(y.coverage),attachPoints:this.parseList(y.pointer(y.uShortList))}},wh=function(){var n=this.parseUShort();if(G.argument(n===1||n===2||n===3,"Unsupported CaretValue table version."),n===1)return{coordinate:this.parseShort()};if(n===2)return{pointindex:this.parseShort()};if(n===3)return{coordinate:this.parseShort()}},kh=function(){return this.parseList(y.pointer(wh))},Eh=function(){return{coverage:this.parsePointer(y.coverage),ligGlyphs:this.parseList(y.pointer(kh))}},Ph=function(){return this.parseUShort(),this.parseList(y.pointer(y.coverage))};function Lh(n,e){e=e||0;var t=new y(n,e),r=t.parseVersion(1);G.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var s={version:r,classDef:t.parsePointer(y.classDef),attachList:t.parsePointer(Sh),ligCaretList:t.parsePointer(Eh),markAttachClassDef:t.parsePointer(y.classDef)};return r>=1.2&&(s.markGlyphSets=t.parsePointer(Ph)),s}var Th={parse:Lh},We=new Array(10);We[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(y.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(y.coverage),values:this.parseValueRecordList()};G.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};We[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();G.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var r=this.parsePointer(y.coverage),s=this.parseUShort(),i=this.parseUShort();if(t===1)return{posFormat:t,coverage:r,valueFormat1:s,valueFormat2:i,pairSets:this.parseList(y.pointer(y.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}})))};if(t===2){var o=this.parsePointer(y.classDef),a=this.parsePointer(y.classDef),l=this.parseUShort(),u=this.parseUShort();return{posFormat:t,coverage:r,valueFormat1:s,valueFormat2:i,classDef1:o,classDef2:a,class1Count:l,class2Count:u,classRecords:this.parseList(l,y.list(u,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(i)}}))}}};We[3]=function(){return{error:"GPOS Lookup 3 not supported"}};We[4]=function(){return{error:"GPOS Lookup 4 not supported"}};We[5]=function(){return{error:"GPOS Lookup 5 not supported"}};We[6]=function(){return{error:"GPOS Lookup 6 not supported"}};We[7]=function(){return{error:"GPOS Lookup 7 not supported"}};We[8]=function(){return{error:"GPOS Lookup 8 not supported"}};We[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Ih(n,e){e=e||0;var t=new y(n,e),r=t.parseVersion(1);return G.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(We),variations:t.parseFeatureVariationsList()}}var Mh=new Array(10);function Ch(n){return new F.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new F.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new F.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new F.LookupList(n.lookups,Mh)}])}var Ah={parse:Ih,make:Ch};function Oh(n){var e={};n.skip("uShort");var t=n.parseUShort();G.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);var r=n.parseUShort();n.skip("uShort",3);for(var s=0;s<r;s+=1){var i=n.parseUShort(),o=n.parseUShort(),a=n.parseShort();e[i+","+o]=a}return e}function Fh(n){var e={};n.skip("uShort");var t=n.parseULong();t>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");var r=n.parseUShort(),s=r&255;if(n.skip("uShort"),s===0){var i=n.parseUShort();n.skip("uShort",3);for(var o=0;o<i;o+=1){var a=n.parseUShort(),l=n.parseUShort(),u=n.parseShort();e[a+","+l]=u}}return e}function Dh(n,e){var t=new R.Parser(n,e),r=t.parseUShort();if(r===0)return Oh(t);if(r===1)return Fh(t);throw new Error("Unsupported kern table version ("+r+").")}var Rh={parse:Dh};function Uh(n,e,t,r){for(var s=new R.Parser(n,e),i=r?s.parseUShort:s.parseULong,o=[],a=0;a<t+1;a+=1){var l=i.call(s);r&&(l*=2),o.push(l)}return o}var Nh={parse:Uh};function so(n,e){for(var t=[],r=12,s=0;s<e;s+=1){var i=R.getTag(n,r),o=R.getULong(n,r+4),a=R.getULong(n,r+8),l=R.getULong(n,r+12);t.push({tag:i,checksum:o,offset:a,length:l,compression:!1}),r+=16}return t}function Bh(n,e){for(var t=[],r=44,s=0;s<e;s+=1){var i=R.getTag(n,r),o=R.getULong(n,r+4),a=R.getULong(n,r+8),l=R.getULong(n,r+12),u=void 0;a<l?u="WOFF":u=!1,t.push({tag:i,offset:o,compression:u,compressedLength:a,length:l}),r+=20}return t}function ve(n,e){if(e.compression==="WOFF"){var t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(Cl(t,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var s=new DataView(r.buffer,0);return{data:s,offset:0}}else return{data:n,offset:e.offset}}function Jo(n,e){e=e??{};var t,r,s=new oe({empty:!0}),i=new DataView(n,0),o,a=[],l=R.getTag(i,0);if(l==="\0\0\0"||l==="true"||l==="typ1")s.outlinesFormat="truetype",o=R.getUShort(i,4),a=so(i,o);else if(l==="OTTO")s.outlinesFormat="cff",o=R.getUShort(i,4),a=so(i,o);else if(l==="wOFF"){var u=R.getTag(i,4);if(u==="\0\0\0")s.outlinesFormat="truetype";else if(u==="OTTO")s.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);o=R.getUShort(i,12),a=Bh(i,o)}else throw new Error("Unsupported OpenType signature "+l);for(var c,h,f,p,d,g,m,x,L,b,M,E,O=0;O<o;O+=1){var w=a[O],T=void 0;switch(w.tag){case"cmap":T=ve(i,w),s.tables.cmap=po.parse(T.data,T.offset),s.encoding=new mo(s.tables.cmap);break;case"cvt ":T=ve(i,w),E=new R.Parser(T.data,T.offset),s.tables.cvt=E.parseShortList(w.length/2);break;case"fvar":h=w;break;case"fpgm":T=ve(i,w),E=new R.Parser(T.data,T.offset),s.tables.fpgm=E.parseByteList(w.length);break;case"head":T=ve(i,w),s.tables.head=Lo.parse(T.data,T.offset),s.unitsPerEm=s.tables.head.unitsPerEm,t=s.tables.head.indexToLocFormat;break;case"hhea":T=ve(i,w),s.tables.hhea=To.parse(T.data,T.offset),s.ascender=s.tables.hhea.ascender,s.descender=s.tables.hhea.descender,s.numberOfHMetrics=s.tables.hhea.numberOfHMetrics;break;case"hmtx":m=w;break;case"ltag":T=ve(i,w),r=Mo.parse(T.data,T.offset);break;case"maxp":T=ve(i,w),s.tables.maxp=Co.parse(T.data,T.offset),s.numGlyphs=s.tables.maxp.numGlyphs;break;case"name":b=w;break;case"OS/2":T=ve(i,w),s.tables.os2=ns.parse(T.data,T.offset);break;case"post":T=ve(i,w),s.tables.post=Uo.parse(T.data,T.offset),s.glyphNames=new ls(s.tables.post);break;case"prep":T=ve(i,w),E=new R.Parser(T.data,T.offset),s.tables.prep=E.parseByteList(w.length);break;case"glyf":f=w;break;case"loca":L=w;break;case"CFF ":c=w;break;case"kern":x=w;break;case"GDEF":p=w;break;case"GPOS":d=w;break;case"GSUB":g=w;break;case"meta":M=w;break}}var U=ve(i,b);if(s.tables.name=Ro.parse(U.data,U.offset,r),s.names=s.tables.name,f&&L){var S=t===0,A=ve(i,L),W=Nh.parse(A.data,A.offset,s.numGlyphs,S),j=ve(i,f);s.glyphs=Vo.parse(j.data,j.offset,W,s,e)}else if(c){var H=ve(i,c);Po.parse(H.data,H.offset,s,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var _=ve(i,m);if(Io.parse(s,_.data,_.offset,s.numberOfHMetrics,s.numGlyphs,s.glyphs,e),Kl(s,e),x){var $=ve(i,x);s.kerningPairs=Rh.parse($.data,$.offset)}else s.kerningPairs={};if(p){var te=ve(i,p);s.tables.gdef=Th.parse(te.data,te.offset)}if(d){var re=ve(i,d);s.tables.gpos=Ah.parse(re.data,re.offset),s.position.init()}if(g){var ne=ve(i,g);s.tables.gsub=No.parse(ne.data,ne.offset)}if(h){var de=ve(i,h);s.tables.fvar=bh.parse(de.data,de.offset,s.names)}if(M){var Q=ve(i,M);s.tables.meta=Bo.parse(Q.data,Q.offset),s.metas=s.tables.meta}return s}var ur=class{constructor(e,t){this.sources=e;this.fallback=t;this.parsed=new Map;this.missing=new Set}names(){return Object.keys(this.sources)}get(e){let t=e||this.fallback||Object.keys(this.sources)[0];if(!t)throw this.missing.add(""),new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let r=this.parsed.get(t);if(r)return r;let s=Ot(this.sources,t);if(!s)throw this.missing.add(t),new Error(`Font "${t}" is not available.${this.names().length?` Available fonts: ${this.names().join(", ")}`:""}`);let i=s instanceof Uint8Array?s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength):s,o=Jo(i);return this.parsed.set(t,o),o}};function Gh(n,e,t){let r={kerning:!0};if(t.spacing===1)return{cmds:n.getPath(e,0,0,t.size,r).commands,advance:n.getAdvanceWidth(e,t.size,r)};let s=[],i=0,o=[...e];return o.forEach((a,l)=>{s.push(...n.getPath(a,i,0,t.size,r).commands),i+=n.getAdvanceWidth(a,t.size,r)*(l<o.length-1?t.spacing:1)}),{cmds:s,advance:i}}function Qo(n,e,t){let{cmds:r,advance:s}=Gh(n,e,t),i=r.map(a=>a.type==="Z"?a:a.type==="C"?{...a,y1:-a.y1,y2:-a.y2,y:-a.y}:a.type==="Q"?{...a,y1:-a.y1,y:-a.y}:{...a,y:-a.y}),o=_n(i,Math.max(.005,t.size/2e3));return{polys:[...o.closed,...o.open.filter(a=>a.length>=3)],advance:s}}function ea(n,e,t){if(!e)return[];let r=n.get(t.font),{polys:s,advance:i}=Qo(r,e,t),o=be(s),a=on(o);if(!a)return[];let l=t.halign==="center"?-i/2:t.halign==="right"?-i:0,u=t.valign==="top"?-a[3]:t.valign==="center"?-(a[1]+a[3])/2:t.valign==="bottom"?-a[1]:0;return o.map(c=>c.map(([h,f])=>[h+l,f+u]))}function ta(n,e,t){let r=n.get(t.font),{polys:s,advance:i}=Qo(r,e,t),o=on(s)??[0,0,0,0];return{advance:i,bounds:[[o[0],o[1]],[o[2],o[3]]],ascent:r.ascender/r.unitsPerEm*t.size,descent:r.descender/r.unitsPerEm*t.size}}var ms=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],$h={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4},zh=100,Ht=4,na=8,Hh=n=>{let e=zh,t=r=>{for(let s of r.values()){for(let i of s.regions)e+=i.length;for(let i of s.lines)e+=i.length}};t(n.layers);for(let r of n.parts)t(r.layers);return e},we=class{constructor(e,t){this.parent=e;this.caller=t;this.vars=new Map;this.fns=new Map;this.mods=new Map}get(e){let t=this,r=e.startsWith("$");for(;t;){if(t.vars.has(e))return{found:!0,value:t.vars.get(e)};t=r?t.caller??t.parent:t.parent}return{found:!1}}fn(e){for(let t=this;t;t=t.parent){let r=t.fns.get(e);if(r)return r}}mod(e){for(let t=this;t;t=t.parent){let r=t.mods.get(e);if(r)return r}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}names(e){let t=[];for(let r=this;r;r=r.parent)t.push(...r[e].keys());return t}},gs=n=>n?`.${n}`:"",Vh=["echo","assert","text_width","text_metrics","finger_count"];function cr(n,e){let t="",r=Math.min(2,Math.floor(n.length/3))+.5;for(let s of new Set(e)){if(s===n)continue;let i=s.toLowerCase()===n.toLowerCase()?0:qh(n,s);i<r&&([t,r]=[s,i])}return t?` Did you mean "${t}"?`:""}function qh(n,e){if(Math.abs(n.length-e.length)>2)return 3;let t=Array.from({length:n.length+1},(r,s)=>[s,...Array(e.length).fill(0)]);for(let r=1;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=n.length;r++)for(let s=1;s<=e.length;s++)t[r][s]=Math.min(t[r-1][s]+1,t[r][s-1]+1,t[r-1][s-1]+(n[r-1]===e[s-1]?0:1)),r>1&&s>1&&n[r-1]===e[s-2]&&n[r-2]===e[s-1]&&(t[r][s]=Math.min(t[r][s],t[r-2][s-2]+1));return t[n.length][e.length]}var Xh=nt,fr=class{constructor(e={}){this.opts=e;this.steps=0;this.depth=0;this.pointCount=0;this.itemCount=0;this.copies=0;this.echoes=[];this.warnings=[];this.layers=new Map(ms.map(e=>[e.name,e]));this.loaded=new Map;this.using=[];this.including=[];this.maxSteps=e.maxSteps??5e6,this.limits={...$h,...e.limits},this.builtins=this.makeBuiltins()}run(e){let t=new we,r={$fn:0,$fa:2,$fs:.2,$thickness:3,$kerf:0,$material:"material",$sheet:[600,400],$gap:3,$layout:"pack",PI:Math.PI};for(let[o,a]of Object.entries(r))t.vars.set(o,a);let s=new we(t);return{shape:this.block(e.body,s,!0),globals:s,layers:this.layers,echoes:this.echoes,warnings:this.warnings}}tick(e,t=1){if(!((this.steps+=t)<=this.maxSteps))throw new N(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,t){let r=this.loaded.get(e);if(r)return r;let s=Ot(Xh,e)??this.opts.resolve?.(e);if(typeof s!="string")throw new N(`Library <${e}> not found`,t);this.loaded.set(e,{body:[]});let{program:i}=ot(s,e);return this.loaded.set(e,i),i}hoist(e,t){for(let r of e)if(r.kind==="module")t.mods.set(r.name,{params:r.params,body:r.body,env:t});else if(r.kind==="function")t.fns.set(r.name,{params:r.params,body:r.body,env:t});else if(r.kind==="use"&&!r.include){this.enter(this.using,r.path,r.pos,"use");try{let s=this.included(this.load(r.path,r.pos).body,new Set([r.path])),i=new we(t);this.hoist(s,i);for(let o of s)o.kind==="assign"&&this.assign(o.name,this.expr(o.value,i),i);for(let[o,a]of i.mods)t.mods.set(o,a);for(let[o,a]of i.fns)t.fns.set(o,a)}finally{this.using.pop()}}}enter(e,t,r,s){if(e.includes(t)){let i=[...e.slice(e.indexOf(t)),t].map(o=>`<${o}>`);throw new N(i.length===2?`Library ${i[0]} ${s}s itself`:`Libraries ${s} each other in a loop: ${i.join(" \u2192 ")}`,r)}e.push(t)}included(e,t){let r=[];for(let s of e)if(s.kind!=="use"||!s.include)r.push(s);else if(!t.has(s.path)){t.add(s.path);for(let i of this.included(this.load(s.path,s.pos).body,t))r.push(i)}return r}assign(e,t,r){r.vars.set(e,t)}block(e,t,r=!1){this.hoist(e,t);let s=[];for(let i of e){let o=this.stmt(i,t,r);o&&!ii(o)&&s.push(o)}return s.length===1?s[0]:sn(s)}stmt(e,t,r=!1){switch(this.tick(e.pos),e.kind){case"assign":{let s=this.opts.overrides,i=r&&s&&Object.prototype.hasOwnProperty.call(s,e.name)?s[e.name]:this.expr(e.value,t);return this.assign(e.name,i,t),null}case"module":case"function":return null;case"use":{if(!e.include)return null;this.enter(this.including,e.path,e.pos,"include");try{return this.block(this.load(e.path,e.pos).body,t)}finally{this.including.pop()}}case"block":return this.block(e.body,new we(t));case"if":return Fe(this.expr(e.cond,t))?this.block(e.then,new we(t)):this.block(e.else,new we(t));case"let":{let s=new we(t);return this.bindSeq(e.assigns,s),this.block(e.body,s)}case"for":{let s=[];return this.loop(e.assigns,t,i=>s.push(this.block(e.body,i))),sn(s)}case"call":if(e.modifier==="*")return null;{let s=this.callModule(e,t);return e.modifier==="#"||e.modifier==="%"?qn(s,"guide"):s}}}bindSeq(e,t){for(let r of e)this.assign(r.name,this.expr(r.value,t),t)}iterable(e,t){if(ze(e))try{return Cn(e,this.limits.maxListLength)}catch(r){throw new N(r.message,t)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,t,r,s=0,i=new we(t)){if(s===e.length)return r(i);let o=e[s];for(let a of this.iterable(this.expr(o.value,i),o.pos)){this.tick(o.pos);let l=new we(i);l.vars.set(o.name,a),this.loop(e,t,r,s+1,l)}}evalArgs(e,t,r){let s=[],i=new Map,o=[];for(let a of e){let l=this.expr(a.value,t);a.name===null?s.push(l):i.set(a.name,l),o.push({name:a.name,value:l})}return{pos:s,named:i,all:o,at:r}}bindParams(e,t,r,s,i){let o=e.map(a=>a.name);e.forEach((a,l)=>{let u;t.named.has(a.name)?u=t.named.get(a.name):l<t.pos.length?u=t.pos[l]:u=a.default?this.expr(a.default,r):void 0,r.vars.set(a.name,u)});for(let a of t.named.keys())a.startsWith("$")?r.vars.set(a,t.named.get(a)):o.includes(a)||this.unknownArg(i,a,t.at,o);this.checkCount(i,e.length,t)}checkArgs(e,t){let r=Ct(e);if(!r)return;let s=r.params.map(i=>i.name);if(!r.anyNamed)for(let i of t.named.keys())!i.startsWith("$")&&!s.includes(i)&&this.unknownArg(`${e}()`,i,t.at,s);r.rest||this.checkCount(`${e}()`,r.params.filter(i=>!i.named).length,t)}checkCount(e,t,r){r.pos.length>t&&this.warn(`${e}: takes ${t===0?"no":`at most ${t}`} positional argument${t===1?"":"s"}, got ${r.pos.length}; the rest are ignored (${Xt(r.at,!1)})`)}unknownArg(e,t,r,s){this.warn(`${e}: unknown argument "${t}"${gs(cr(t,s))} (${Xt(r,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callModule(e,t){let r=this.evalArgs(e.args,t,e.pos),s=t.mod(e.name);if(s){if(++this.depth>1e3)throw new N(`Recursion too deep in module ${e.name}(): it calls itself without stopping`,e.pos);try{let h=new we(s.env,t);return this.bindParams(s.params,r,h,s.env,`${e.name}()`),h.children={stmts:e.children,env:t},h.vars.set("$children",this.childStmts(e.children).length),this.block(s.body,h)}catch(h){throw this.inCall(h,"module",e.name,e.pos)}finally{this.depth--}}let i=Ot(this.builtins,e.name);if(!i){let h=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":cr(e.name,[...t.names("mods"),...Object.keys(this.builtins)]);throw new N(`Unknown module ${e.name}().${h}`,e.pos)}this.checkArgs(e.name,r);let o=new we(t,t);for(let[h,f]of r.named)h.startsWith("$")&&o.vars.set(h,f);let a=this.childStmts(e.children),l=()=>new we(t,o),u={args:r,env:o,children:()=>e.children.length?this.block(e.children,l()):St(),childList:()=>{let h=l();this.hoist(e.children,h);let f=[];for(let p of e.children){let d=this.stmt(p,h);a.includes(p)&&f.push(d??St())}return f}},c;try{c=i(u)}catch(h){if(h instanceof N||h instanceof RangeError)throw h;let f=new N(`${e.name}(): ${h.message}`,e.pos);throw f.call=e.name,f}if(this.pointCount+=Hh(c),this.pointCount>this.limits.maxPoints)throw new N(`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return c}childStmts(e){return e.filter(t=>t.kind!=="assign"&&t.kind!=="module"&&t.kind!=="function"&&t.kind!=="use")}callFunction(e,t,r,s){if(++this.depth>2e3)throw new N(`Recursion too deep in ${s}(): it calls itself without stopping`,t.at);try{this.tick(t.at);let i=at(e)?e.scope:e.env,o=new we(i,r);return this.bindParams(e.params,t,o,i,`${s}()`),this.expr(e.body,o)}catch(i){throw this.inCall(i,"function",s,t.at)}finally{this.depth--}}inCall(e,t,r,s){return e instanceof Error&&!(e instanceof N)&&e.message.includes("call stack")?new N(`Recursion too deep in ${t==="module"?"module ":""}${r}(): it calls itself without stopping`,s):(e instanceof N&&e.addFrame(t,r,s),e)}expr(e,t){switch(e.kind){case"num":case"str":case"bool":return e.value;case"undef":return;case"var":{let r=t.get(e.name);if(r.found)return r.value;let s=t.fn(e.name);if(s)return{type:"function",params:s.params,body:s.body,scope:s.env,name:e.name};if(e.name.startsWith("$"))return;throw new N(`Unknown variable "${e.name}"${gs(cr(e.name,[...t.names("vars"),...t.names("fns")]))}`,e.pos)}case"list":{let r=[];for(let s of e.items)this.listItem(s,t,r,e.pos);return this.charge(Ht,e.pos),r}case"range":{let r=this.expr(e.start,t),s=this.expr(e.end,t),i=e.step?this.expr(e.step,t):1;if(typeof r!="number"||typeof s!="number"||typeof i!="number")throw new N("Range values must be numbers",e.pos);return{type:"range",start:r,step:i,end:s}}case"unary":{let r=this.expr(e.arg,t);return e.op==="!"?!Fe(r):e.op==="+"?r:this.arith("*",-1,r,e.pos)}case"binary":{if(e.op==="&&")return Fe(this.expr(e.left,t))&&Fe(this.expr(e.right,t));if(e.op==="||")return Fe(this.expr(e.left,t))||Fe(this.expr(e.right,t));let r=this.expr(e.left,t),s=this.expr(e.right,t);if(e.op==="=="||e.op==="!=")return _t(r,s,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof r=="number"&&typeof s=="number"||typeof r=="string"&&typeof s=="string"))throw new N(`Can't compare ${Ne(r)} ${e.op} ${Ne(s)}`,e.pos);return e.op==="<"?r<s:e.op==="<="?r<=s:e.op===">"?r>s:r>=s}return this.arith(e.op,r,s,e.pos)}case"ternary":return Fe(this.expr(e.cond,t))?this.expr(e.then,t):this.expr(e.else,t);case"index":{let r=this.expr(e.target,t),s=this.expr(e.index,t);if(typeof s!="number")throw new N(`List index must be a number, got ${Ne(s)}`,e.pos);return Array.isArray(r)?r[Math.floor(s)]:typeof r=="string"?[...r][Math.floor(s)]:ze(r)?[r.start,r.step,r.end][Math.floor(s)]:void 0}case"member":{let r=this.expr(e.target,t),s={x:0,y:1,z:2}[e.name];return Array.isArray(r)&&s!==void 0?r[s]:ze(r)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?r.start:e.name==="step"?r.step:r.end:void 0}case"call":return this.call(e,t);case"lambda":return{type:"function",params:e.params,body:e.body,scope:t};case"let":{let r=new we(t);return this.bindSeq(e.assigns,r),this.expr(e.body,r)}}}listItem(e,t,r,s){switch(e.kind){case"item":{let i=this.expr(e.expr,t);this.grow(r,1,s),r.push(i);return}case"each":{let i=this.iterable(this.expr(e.expr,t),s);this.grow(r,i.length,s);for(let o of i)r.push(o);return}case"for":this.loop(e.assigns,t,i=>this.listItem(e.body,i,r,s));return;case"if":Fe(this.expr(e.cond,t))?this.listItem(e.then,t,r,s):e.else&&this.listItem(e.else,t,r,s);return;case"let":{let i=new we(t);this.bindSeq(e.assigns,i),this.listItem(e.body,i,r,s)}}}grow(e,t,r){if(e.length+t>this.limits.maxListLength)throw new N(`a list of ${e.length+t} items is more than the limit of ${this.limits.maxListLength}`,r);this.charge(t,r)}charge(e,t){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new N(`The lists and strings hold more than ${this.limits.maxListItems} items in all, the limit. Is a loop building more than it needs?`,t)}call(e,t){if(e.callee.kind==="var"){let s=e.callee.name,i=t.get(s);if(!i.found){let o=t.fn(s);if(o)return this.callFunction(o,this.evalArgs(e.args,t,e.pos),t,s);let a=this.specialFunction(s,e,t);if(a.handled)return a.value;let l=Ot(Pr,s);if(l){let u=this.evalArgs(e.args,t,e.pos);this.checkArgs(s,u);for(let p of qs(l,u.pos,u.named))this.warn(`${s}(): "${p}" is given by position and by name; the named value is used (${Xt(e.pos,!1)})`);let c={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:u.pos.length+l.params.filter(p=>u.named.has(p)).length},h=Xs(l,u.pos,u.named);this.tick(e.pos,Ws(s,h,this.limits.maxListLength));let f;try{f=l.run(h,c)}catch(p){if(p instanceof N)throw p;let d=new N(p instanceof RangeError?`${s}(): the result is too large`:p.message,e.pos);throw d.call=s,d}return this.checkValue(f,e.pos,s),f}throw new N(`Unknown function ${s}()${gs(cr(s,[...t.names("fns"),...t.names("vars"),...Object.keys(Pr),...Vh]))}`,e.pos)}if(!at(i.value))throw new N(`"${s}" is a ${Ne(i.value)}, not a function`,e.pos);return this.callFunction(i.value,this.evalArgs(e.args,t,e.pos),t,s)}let r=this.expr(e.callee,t);if(!at(r))throw new N(`Can't call a ${Ne(r)}`,e.pos);return this.callFunction(r,this.evalArgs(e.args,t,e.pos),t,"function")}specialFunction(e,t,r){if(e==="echo"){let s=this.evalArgs(t.args,r,t.pos);return this.echo(this.echoText(s),t.pos),{handled:!0,value:void 0}}if(e==="assert"){let s=this.evalArgs(t.args,r,t.pos);return this.checkArgs(e,s),this.assert(s),{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let s=this.evalArgs(t.args,r,t.pos);this.checkArgs(e,s);let i=this.measure(s,r);return e==="text_width"?{handled:!0,value:i.advance}:{handled:!0,value:[i.advance,i.bounds,i.ascent,i.descent]}}if(e==="finger_count"){let s=this.evalArgs(t.args,r,t.pos);this.checkArgs(e,s);let i=this.num(this.arg(s,"length",0),"finger_count","length");return{handled:!0,value:Wn(i,this.fingerWidth(s,r,1))}}return{handled:!1}}assert(e){if(Fe(this.arg(e,"condition",0)))return;let t=this.arg(e,"message",1);throw new N(`Assertion failed${t===void 0?"":": "+He(t)}`,e.at)}echo(e,t){this.charge(Math.ceil(e.length/na),t),this.echoes.push(e)}echoText(e){let t=this.limits.maxListLength,r=[],s=0,i=(o,a,l)=>{r.length&&(s+=2);let u=Ft(a,t-s-o.length,l);if(s+=o.length+u.text.length,!u.whole)throw new N(`echo(): the text would be longer than the limit of ${t} characters`,e.at);r.push(o+u.text)};for(let{name:o,value:a}of e.all)o===null?i("",a,!1):i(`${o} = `,a,!0);return r.join(", ")}arith(e,t,r,s){if(typeof t=="number"&&typeof r=="number")switch(e){case"+":return t+r;case"-":return t-r;case"*":return t*r;case"/":return t/r;case"%":return t%r;case"^":return Math.pow(t,r)}if(e==="+"&&typeof t=="string"&&typeof r=="string")return this.checkSize(t.length+r.length,!0,s),t+r;if(Array.isArray(t)&&Array.isArray(r)){if(e==="+"||e==="-"){if(t.length!==r.length)throw new N(`Can't ${e==="+"?"add":"subtract"} lists of length ${t.length} and ${r.length}`,s);return this.charge(t.length+Ht,s),t.map((o,a)=>this.arith(e,o,r[a],s))}if(e==="*"){if(Array.isArray(t[0]))return this.charge(t.length+Ht,s),t.map(a=>this.arith("*",a,r,s));let o=(a,l)=>{let u=this.arith("*",a,l,s);if(typeof u!="number")throw new N("Can't multiply these lists: an item times an item is not a number",s);return u};if(Array.isArray(r[0])){let a=r[0].length;if(t.length!==r.length||r.some(l=>!Array.isArray(l)||l.length!==a))throw new N(`Can't multiply a list of length ${t.length} by a matrix: it needs ${t.length} rows of the same length`,s);return this.checkSize(a,!1,s),this.tick(s,a*t.length),Array.from({length:a},(l,u)=>t.reduce((c,h,f)=>c+o(h,r[f][u]),0))}if(t.length!==r.length)throw new N(`Can't multiply lists of length ${t.length} and ${r.length}`,s);return this.tick(s,t.length),t.reduce((a,l,u)=>a+o(l,r[u]),0)}}if(Array.isArray(t)&&typeof r=="number"&&(e==="*"||e==="/"))return this.charge(t.length+Ht,s),t.map(o=>this.arith(e,o,r,s));if(typeof t=="number"&&Array.isArray(r)&&e==="*")return this.charge(r.length+Ht,s),r.map(o=>this.arith(e,t,o,s));let i={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new N(`Can't ${i[e]??e} ${Ne(t)} and ${Ne(r)}`,s)}arg(e,t,r,s){return e.named.has(t)?e.named.get(t):r>=0&&r<e.pos.length?e.pos[r]:s}num(e,t,r){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} must be a finite number, got ${vt(e)}`);return e}vec2(e,t,r=!0){let s=i=>typeof i=="number"&&Number.isFinite(i);if(s(e)&&r)return[e,e];if(Array.isArray(e)&&s(e[0])&&(e[1]===void 0||s(e[1])))return[e[0],e[1]??0];throw new Error(`${t} must be a number or [x, y], got ${vt(e)}`)}vec3(e,t){let r=s=>typeof s=="number"&&Number.isFinite(s);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(r))return[e[0],e[1],e[2]??0];throw new Error(`${t} must be [x, y, z], got ${vt(e)}`)}placements(e,t,r){let s=(a,l)=>a===void 0?[[0,0,0]]:Array.isArray(a)&&a.length>0&&Array.isArray(a[0])?a.map((u,c)=>this.vec3(u,`${l}[${c}]`)):[this.vec3(a,l)],i=s(e,"at"),o=s(t,"rotate");for(let[a,l]of[[i,"at"],[o,"rotate"]])if(a.length!==1&&a.length!==r)throw new Error(`${l} needs one placement per copy: qty is ${r} but ${l} has ${a.length}`);return Array.from({length:r},(a,l)=>({at:i[i.length===1?0:l],rotate:o[o.length===1?0:l]}))}points(e,t){if(!Array.isArray(e))throw new Error(`${t} must be a list of [x, y] points`);return e.map((r,s)=>{if(!Array.isArray(r)||!Number.isFinite(r[0])||!Number.isFinite(r[1]))throw new Error(`${t}[${s}] must be an [x, y] point, got ${vt(r)}`);return[r[0],r[1]]})}dyn(e,t){return e.get(t).value}spend(e){if(this.pointCount+=e,!(this.pointCount<=this.limits.maxPoints))throw new Error(`the shapes need more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes.`)}checkValue(e,t,r){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",t,r)}checkSize(e,t,r,s){if(e>this.limits.maxListLength)throw new N(`${s?`${s}(): `:""}${t?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,r);this.charge(t?Math.ceil(e/na):e+Ht,r)}segs(e){let t=Ee(this.dyn(e,"$fn"))||0,r=Ee(this.dyn(e,"$fa"))||2,s=Ee(this.dyn(e,"$fs"))||.2,i=this.limits.maxSegments;return o=>{let a=fi(o,t,r,s);if(!(a<=i))throw new Error(`a circle with ${a} segments is more than the limit of ${i}. Lower $fn, or raise $fa or $fs.`);return a}}thickness(e){let t=this.dyn(e,"$thickness");if(typeof t!="number"||t<=0)throw new Error("$thickness must be a positive number");return t}fingerWidth(e,t,r){let s=this.arg(e,"finger",r);return typeof s=="number"&&s>0?s:Math.max(3*this.thickness(t),6)}measure(e,t){if(!this.opts.fonts)throw new N("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let r=Ft(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!r.whole)throw new N(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,r.text.length);try{return ta(this.opts.fonts,r.text,this.textOpts(e,t))}catch(s){throw s instanceof N?s:new N(s.message,e.at)}}textOpts(e,t){return{size:this.num(this.arg(e,"size",1,10),"text","size"),font:He(this.arg(e,"font",2,this.dyn(t,"$font")??"")),halign:He(this.arg(e,"halign",-1,"left")),valign:He(this.arg(e,"valign",-1,"baseline")),spacing:Ee(this.arg(e,"spacing",-1,1))}}edges(e){let t=r=>{if(r==="out"||r==="in"||r==="flat")return r;throw new Error(`edges must be "out", "in" or "flat", got ${vt(r)}`)};if(typeof e=="string")return[t(e),t(e),t(e),t(e)];if(Array.isArray(e)&&e.length===4)return e.map(t);throw new Error("edges must be one value or a list of 4: [bottom, right, top, left]")}makeBuiltins(){let e=(i,o)=>Vn(i.children(),o),t=i=>o=>qn(o.children(),i);return{rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0,1),"size"),l=Ee(this.arg(i.args,"r",-1,0))||0,u=Fe(this.arg(i.args,"center",1,!1)),c=hi(o,a,l,this.segs(i.env));return Ge(be([u?c.map(([h,f])=>[h-o/2,f-a/2]):c]))},square:i=>this.builtins.rect(i),circle:i=>{let o=this.arg(i.args,"d",-1),a=o!==void 0?this.num(o,"circle","d")/2:this.num(this.arg(i.args,"r",0,1),"circle","r");return Ge([Xn(a,a,this.segs(i.env)(a))])},ellipse:i=>{let[o,a]=this.vec2(this.arg(i.args,"r",0,1),"r");return Ge([Xn(o,a,this.segs(i.env)(Math.max(o,a)))])},regular_polygon:i=>{let o=Math.max(3,Math.floor(this.num(this.arg(i.args,"n",0,6),"regular_polygon","n"))),a=this.num(this.arg(i.args,"r",1,10),"regular_polygon","r");if(!(o<=this.limits.maxSegments))throw new Error(`${o} corners is more than the limit of ${this.limits.maxSegments}`);return Ge([Xn(a,a,o)])},star:i=>{let o=Math.max(2,Math.floor(this.num(this.arg(i.args,"n",0,5),"star","n"))),a=this.num(this.arg(i.args,"r",1,10),"star","r"),l=this.num(this.arg(i.args,"inner",2,a*.45),"star","inner");if(!(o*2<=this.limits.maxSegments))throw new Error(`${o} points is more than the limit of ${this.limits.maxSegments/2}`);let u=[];for(let c=0;c<o*2;c++){let h=Math.PI/2+Math.PI*c/o,f=c%2?l:a;u.push([f*Math.cos(h),f*Math.sin(h)])}return Ge(be([u]))},polygon:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=this.arg(i.args,"paths",1),l=Array.isArray(a)?a.map(u=>(Array.isArray(u)?u:[]).map(c=>o[Ee(c)]).filter(Boolean)):[o];return Ge(be(l,"evenodd"))},path:i=>{let o=this.arg(i.args,"d",0);if(typeof o!="string")throw new Error('path() needs SVG path data, like path("M0 0 L10 0 L5 8 Z")');let a=_n(vi(o),.01),l=this.arg(i.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return sn([Ge(be(a.closed,l)),Ut(a.open)])},line:i=>{let o=this.vec2(this.arg(i.args,"from",0,[0,0]),"from",!1),a=this.vec2(this.arg(i.args,"to",1,[10,0]),"to",!1);return Ut([[o,a]])},polyline:i=>{let o=this.points(this.arg(i.args,"points",0),"points"),a=Fe(this.arg(i.args,"closed",1,!1));return Ut([a&&o.length?[...o,o[0]]:o])},arc:i=>{let o=this.num(this.arg(i.args,"r",0,10),"arc","r"),a=this.num(this.arg(i.args,"start",1,0),"arc","start"),l=this.num(this.arg(i.args,"end",2,90),"arc","end"),u=Math.max(2,Math.ceil(this.segs(i.env)(o)*Math.abs(l-a)/360));if(!(u<=this.limits.maxSegments))throw new Error(`an arc with ${u} segments is more than the limit of ${this.limits.maxSegments}`);let c=[];for(let h=0;h<=u;h++){let f=(a+(l-a)*h/u)*Math.PI/180;c.push([o*Math.cos(f),o*Math.sin(f)])}return Ut([c])},text:i=>{if(!this.opts.fonts)throw new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let o=this.arg(i.args,"text",0,""),a=Ft(o,this.limits.maxTextLength);if(!a.whole)throw new Error(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`);return this.tick(i.args.at,a.text.length),Ge(ea(this.opts.fonts,a.text,this.textOpts(i.args,i.env)))},translate:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[0,0]),"v",!1);return e(i,[1,0,0,1,o,a])},rotate:i=>{let o=this.arg(i.args,"a",0,0),l=(Array.isArray(o)?Ee(o[2]??0):this.num(o,"rotate","a"))*Math.PI/180,u=Math.cos(l),c=Math.sin(l),h=this.arg(i.args,"center",-1),f=[u,c,-c,u,0,0];if(h!==void 0){let[p,d]=this.vec2(h,"center",!1);f=[u,c,-c,u,p-u*p+c*d,d-c*p-u*d]}return e(i,f)},scale:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,1),"v");return e(i,[o,0,0,a,0,0])},mirror:i=>{let[o,a]=this.vec2(this.arg(i.args,"v",0,[1,0]),"v",!1),l=Math.hypot(o,a)||1,u=o/l,c=a/l;return e(i,[1-2*u*u,-2*u*c,-2*u*c,1-2*c*c,0,0])},multmatrix:i=>{let o=this.arg(i.args,"m",0);if(!Array.isArray(o)||o.length<2)throw new Error("m must be a 2x3 or 3x3 matrix");let a=o[0],l=o[1];return e(i,[a[0],l[0],a[1],l[1],a[2]??0,l[2]??0])},union:i=>i.children(),group:i=>i.children(),difference:i=>{let[o,...a]=i.childList();if(!o)return St();let l=r(a,"difference");return s(o,u=>({regions:$n(u.regions,l.regions),lines:rn(u.lines,be(l.regions),"outside")}))},intersection:i=>{let[o,...a]=i.childList();if(!o)return St();let l=o;for(let u of a){let c=be(r([u],"intersection").regions);l=s(l,h=>({regions:zn(h.regions,c),lines:rn(h.lines,c,"inside")}))}return l},hull:i=>{let o=i.children(),a=l=>{let u=[],c="cut",h=!0;for(let[p,d]of l){h&&(d.regions.length||d.lines.length)&&(c=p,h=!1);for(let g of[...d.regions,...d.lines])for(let m of g)u.push(m)}let f=ci(u);return new Map([[c,{regions:f.length>=3?[f]:[],lines:[]}]])};return{layers:a(o.layers),parts:o.parts.map(l=>({...l,layers:a(l.layers)}))}},offset:i=>{let o=this.arg(i.args,"r",0),a=this.arg(i.args,"delta",-1),l=Fe(this.arg(i.args,"chamfer",-1,!1)),u=o!==void 0?this.num(o,"offset","r"):this.num(a??0,"offset","delta"),c=o!==void 0?"round":l?"square":"miter";return s(i.children(),h=>({regions:Hn(h.regions,u,c),lines:h.lines}))},stroke:i=>{let o=this.num(this.arg(i.args,"width",0,1),"stroke","width");return s(i.children(),a=>({regions:be([...a.regions,...li(a.lines,o)]),lines:[]}))},outline:i=>s(i.children(),o=>({regions:[],lines:[...o.lines,...be(o.regions).map(a=>[...a,a[0]])]})),cut:t("cut"),score:t("score"),engrave:t("engrave"),guide:t("guide"),layer:i=>{let o=this.arg(i.args,"name",0);if(typeof o!="string"||!o)throw new Error("layer() needs a name");let a=this.arg(i.args,"mode",1),l=this.arg(i.args,"color",2),u=this.layers.get(o);if(a!==void 0||l!==void 0||!u){let c=a??u?.mode??"line";if(!["cut","line","fill","guide"].includes(c))throw new Error('mode must be "cut", "line", "fill" or "guide"');let h=He(l??u?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(h))throw new Error('color must look like "#00aa00"');this.layers.set(o,{name:o,mode:c,color:h})}return qn(i.children(),o)},part:i=>{let o=He(this.arg(i.args,"name",0,"part")),a=Math.max(1,Math.floor(Ee(this.arg(i.args,"qty",1,1))||1));if(this.copies+=a,!(this.copies<=this.limits.maxParts))throw new Error(`more than ${this.limits.maxParts} part copies in total, the limit`);let l=this.arg(i.args,"at",-1),u=this.arg(i.args,"rotate",-1),c=l===void 0&&u===void 0?void 0:this.placements(l,u,a),h=i.children();return{layers:new Map,parts:[...h.parts,{name:o,qty:a,layers:h.layers,thickness:this.thickness(i.env),kerf:Ee(this.dyn(i.env,"$kerf"))||0,material:He(this.dyn(i.env,"$material")??"material"),...c?{placements:c}:{}}]}},material:i=>{let o=this.arg(i.args,"thickness",0),a=this.arg(i.args,"kerf",1),l=this.arg(i.args,"name",2);return o!==void 0&&i.env.vars.set("$thickness",this.num(o,"material","thickness")),a!==void 0&&i.env.vars.set("$kerf",this.num(a,"material","kerf")),l!==void 0&&i.env.vars.set("$material",He(l)),i.children()},children:i=>{let o=i.env.childCtx();if(!o)return St();let a=this.childStmts(o.stmts),l=this.arg(i.args,"index",0),u=new we(o.env,i.env);this.hoist(o.stmts,u);let c=new Set;if(l===void 0)a.forEach(f=>c.add(f));else for(let f of this.iterable(l,i.args.at))a[Ee(f)]&&c.add(a[Ee(f)]);let h=[];for(let f of o.stmts)if(f.kind==="assign")this.stmt(f,u);else if(c.has(f)){let p=this.stmt(f,u);p&&h.push(p)}return sn(h)},echo:i=>(this.echo(this.echoText(i.args),i.args.at),i.children()),assert:i=>(this.assert(i.args),i.children()),finger_rect:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),l=this.edges(this.arg(i.args,"edges",1,"out")),u=this.thickness(i.env),c=this.fingerWidth(i.args,i.env,2);return this.spend(2*(Math.abs(o)+Math.abs(a))/c*4),Ge(pi(o,a,l,u,c))},finger_holes:i=>{let o=this.num(this.arg(i.args,"length",0),"finger_holes","length"),a=this.edges(this.arg(i.args,"edge",1,"out"))[0];if(a==="flat")throw new Error('edge must be "out" or "in"');let l=this.fingerWidth(i.args,i.env,2);return this.spend(Math.abs(o)/l*4),Ge(di(o,a,this.thickness(i.env),l))},tslot:i=>{let o=this.num(this.arg(i.args,"d",0,3),"tslot","d"),a=this.num(this.arg(i.args,"length",1,12),"tslot","length"),[l,u]=this.vec2(this.arg(i.args,"nut",2,[o*1.85,o*.8]),"nut",!1),c=this.num(this.arg(i.args,"nut_at",3,a/2),"tslot","nut_at");return Ge(be(gi(o,a,l,u,c)))},living_hinge:i=>{let[o,a]=this.vec2(this.arg(i.args,"size",0),"size"),l=this.num(this.arg(i.args,"spacing",1,1.5),"living_hinge","spacing"),u=this.num(this.arg(i.args,"bridge",2,3),"living_hinge","bridge"),c=this.num(this.arg(i.args,"cut",3,Math.max(u*2,(a-3*u)/2)),"living_hinge","cut");if(l<=0||u<=0||c<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(o)/l+1)*(Math.abs(a)/(c+u)+2)*2),Ut(mi(o,a,l,u,c))}};function r(i,o){let a={regions:[],lines:[]};for(let l of i){if(l.parts.length)throw new Error(`part() can only be the first child of ${o}()`);for(let u of l.layers.values())for(let c of u.regions)a.regions.push(c)}return a}function s(i,o){let a=l=>{let u=new Map;for(let[c,h]of l)u.set(c,o(h));return u};return{layers:a(i.layers),parts:i.parts.map(l=>({...l,layers:a(l.layers)}))}}}};var Vt=n=>{let e=Math.round(n*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},vs=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");function xs(n,e){let t=[];for(let[r,s]of n){let i=[Vt(r),Vt(s)],o=t[t.length-1];(!o||o[0]!==i[0]||o[1]!==i[1])&&t.push(i)}for(;e&&t.length>1&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1];)t.pop();return t}var qt=(n,e)=>`M${xs(n,e).map(([t,r])=>`${t} ${r}`).join("L")}${e?"Z":""}`;function ys(n,e){let t=[];for(let r of e){let s=[],i=[],o=[];for(let a of n){let l=a.layers.get(r.name);if(l){for(let u of l.lines)s.push(qt(u,!1));for(let u of l.regions)(lt(u)<0?i:o).push(qt(u,!0))}}(s.length||i.length||o.length)&&t.push({name:r.name,mode:r.mode,color:r.color,d:[...s,...i,...o].join(""),regions:[...i,...o].join(""),lines:s.join("")})}return t}function bs(n,e,t,r){let s=['<?xml version="1.0" encoding="UTF-8"?>',`<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${Vt(e)}mm" height="${Vt(t)}mm" viewBox="0 0 ${Vt(e)} ${Vt(t)}">`];for(let i of r){let o=[],a=[];for(let u of n){let c=u.layers.get(i.name);if(!c)continue;let h=` data-part="${vs(u.part)}"`;if(i.mode==="fill"){c.regions.length&&a.push(`<path${h} d="${c.regions.map(f=>qt(f,!0)).join("")}"/>`);for(let f of c.lines)a.push(`<path${h} fill="none" stroke="${i.color}" stroke-width="0.1" d="${qt(f,!1)}"/>`);continue}for(let f of c.lines)o.push(`<path${h} d="${qt(f,!1)}"/>`);for(let f of c.regions)(lt(f)<0?o:a).push(`<path${h} d="${qt(f,!0)}"/>`)}if(!o.length&&!a.length)continue;let l=i.mode==="fill"?`fill="${i.color}" fill-rule="evenodd" stroke="none"`:`fill="none" stroke="${i.color}" stroke-width="0.1"${i.mode==="guide"?' stroke-dasharray="1 1"':""}`;s.push(`<g id="${vs(i.name)}" inkscape:groupmode="layer" inkscape:label="${vs(i.name)}" data-mode="${i.mode}" ${l}>`,...o,...a,"</g>")}return s.push("</svg>",""),s.join(`
379
+ `)}var Wh={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},_h=n=>{let e=Wh[n.toLowerCase()];if(e)return e;let[t,r,s]=[1,3,5].map(i=>parseInt(n.slice(i,i+2),16));return t>r&&t>s?1:r>t&&r>s?3:s>t&&s>r?5:7};function jh(n){let e=a=>a.toUpperCase().replace(/[^A-Z0-9_-]/g,"_"),t=new Set(ms.map(a=>a.name)),r=new Set(n.map(a=>e(a.name))),s=new Set,i=new Map,o=[...n.filter(a=>t.has(a.name)),...n.filter(a=>!t.has(a.name))];for(let a of o){let l=e(a.name);if(s.has(l)){let u=2;for(;r.has(`${l}_${u}`)||s.has(`${l}_${u}`);)u++;l=`${l}_${u}`}s.add(l),i.set(a.name,l)}return i}function ra(n,e,t,r){let s=[],i=(l,u)=>s.push(String(l),String(u)),o=jh(r);i(0,"SECTION"),i(2,"HEADER"),i(9,"$ACADVER"),i(1,"AC1009"),i(9,"$INSUNITS"),i(70,4),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"TABLES"),i(0,"TABLE"),i(2,"LAYER"),i(70,r.length);for(let l of r)i(0,"LAYER"),i(2,o.get(l.name)),i(70,0),i(62,_h(l.color)),i(6,"CONTINUOUS");i(0,"ENDTAB"),i(0,"ENDSEC"),i(0,"SECTION"),i(2,"ENTITIES");let a=(l,u,c)=>{i(0,"POLYLINE"),i(8,l),i(66,1),i(10,0),i(20,0),i(30,0),i(70,c?1:0);for(let[h,f]of xs(u.map(([p,d])=>[p,t-d]),c))i(0,"VERTEX"),i(8,l),i(10,h),i(20,f),i(30,0);i(0,"SEQEND"),i(8,l)};for(let l of r){let u=o.get(l.name),c=[];for(let h of n){let f=h.layers.get(l.name);if(f){for(let p of f.lines)a(u,p,!1);for(let p of f.regions)lt(p)<0?a(u,p,!0):c.push(p)}}for(let h of c)a(u,h,!0)}return i(0,"ENDSEC"),i(0,"EOF"),s.join(`
380
380
  `)+`
381
- `}var ra=(n,e)=>{let t=0;for(let r=1;r<n.length;r++)t+=Math.hypot(n[r][0]-n[r-1][0],n[r][1]-n[r-1][1]);return e&&n.length>2&&(t+=Math.hypot(n[0][0]-n[n.length-1][0],n[0][1]-n[n.length-1][1])),t},vt=n=>Math.round(n*100)/100;function sa(n,e={}){for(let[E,B]of Object.entries(e.params??{}))try{wr(E,B)}catch(j){throw new R(j.message)}let{program:t}=it(n),r=e.fonts?new ur(e.fonts,e.defaultFont):void 0,s=new fr({overrides:e.params,resolve:e.resolve,fonts:r,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,o;try{o=s.run(t)}catch(E){let B=E instanceof RangeError?new R(/call stack/i.test(E.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):E;throw B instanceof R&&(B.echoes=s.echoes,B.warnings=[...s.warnings],r?.missing.size&&(B.missingFonts=[...r.missing])),B}let a=E=>o.globals.get(E).value,l=o.warnings,u=o.layers,c=E=>u.get(E)?.mode??"line",h=[...o.shape.parts];[...o.shape.layers.values()].some(E=>E.regions.length||E.lines.length)&&h.unshift({name:"part",qty:1,layers:o.shape.layers,thickness:Ee(a("$thickness"))||3,kerf:Ee(a("$kerf"))||0,material:He(a("$material")??"material")}),h.length||l.push("Nothing to cut: the program made no shapes.");let p=[],d=[],g=[],y=new Set,x=[];for(let E of h){let B=be([...E.layers].filter(([ne])=>c(ne)==="cut").flatMap(([,ne])=>ne.regions)),j=new Map;for(let[ne,pe]of E.layers){if(c(ne)==="guide"&&!e.guides)continue;let xe=be(pe.regions),Pe=pe.lines.filter(K=>K.length>=2);(c(ne)==="line"||c(ne)==="guide")&&(Pe=[...Pe,...xe.map(K=>[...K,K[0]])],xe=[]),B.length&&c(ne)!=="guide"&&(c(ne)!=="cut"&&(xe=$n(xe,B)),Pe=rn(Pe,B,"inside")),(xe.length||Pe.length)&&j.set(ne,{regions:xe,lines:Pe})}if(B.length){let ne={name:E.name,thickness:E.thickness,outline:B};if(E.placements){let pe=new Set;E.placements.forEach((xe,Pe)=>{let K={...ne,copy:Pe+1,matrix:Sr(xe),placed:!0};d.push(K);let Ae=K.matrix.map(Oe=>Oe.toFixed(6)).join(",");pe.has(Ae)&&y.add(K),pe.add(Ae)}),pe.size<E.placements.length&&l.push(`Copies of part "${E.name}" are in the same place in the assembly. Give at a list with one placement per copy to spread them out.`)}else for(let pe=0;pe<E.qty;pe++)g.push({...ne,copy:pe+1,matrix:Sr({at:[0,0,0],rotate:[0,0,0]}),placed:!1})}let oe=li(B).length;oe>1&&l.push(`Part "${E.name}" cuts into ${oe} separate pieces. Join them, or make them separate parts.`);let se=0;for(let[ne,pe]of j)if(c(ne)==="cut"){for(let xe of pe.regions)se+=ra(xe,!0);for(let xe of pe.lines)se+=ra(xe,!1)}let ae=Gr(j)??[0,0,0,0],he=e.kerf??E.kerf;if(!(Number.isFinite(he)&&he>=0))throw new R("$kerf must be a number, 0 or more");let Ue={name:E.name,qty:E.qty,width:vt(ae[2]-ae[0]),height:vt(ae[3]-ae[1]),pieces:oe,cutLength:Math.round(se),thickness:E.thickness,kerf:he,material:E.material};if(he>0){for(let[ne,pe]of j)if(c(ne)==="cut"){let xe=pe.regions.filter(K=>ut(K)<0).length;pe.regions=zn(pe.regions,he/2,"round",Math.min(.01,he/20));let Pe=xe-pe.regions.filter(K=>ut(K)<0).length;Pe>0&&l.push(`Part "${E.name}": ${Pe} hole${Pe===1?" is":"s are"} narrower than the ${he} mm kerf and will not be cut.`)}}p.push(Ue),x.push({info:Ue,layers:j})}let{found:I,complete:k}=Gs(d.filter(E=>!y.has(E)),i.maxCollisionPairs);k||l.push(`The assembly has more than ${i.maxCollisionPairs} pairs of touching parts, the limit, so only those were checked for collisions.`);for(let[E,B]of I.slice(0,5))l.push(`Parts "${E.name}"${E.copy>1?` (copy ${E.copy})`:""} and "${B.name}"${B.copy>1?` (copy ${B.copy})`:""} collide in the assembly. Check their edges and where they are placed.`);if(I.length>5&&l.push(`${I.length-5} more pairs of parts collide in the assembly.`),d.length&&g.length){let E=[...new Set(g.map(B=>`"${B.name}"`))];l.push(`${E.length===1?"Part":"Parts"} ${E.slice(0,5).join(", ")}${E.length>5?` and ${E.length-5} more`:""} ${E.length===1?"has":"have"} no at or rotate, so ${E.length===1?"it lies":"they lie"} flat beside the assembly.`),d.push(...Bs(d,g))}let F=0;for(let E of x){let B=0;for(let j of E.layers.values()){for(let oe of j.regions)B+=oe.length;for(let oe of j.lines)B+=oe.length}F+=B*E.info.qty}if(F>i.maxOutputPoints)throw new R(`The files would have ${F} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let L=e.sheet??a("$sheet");if(!Array.isArray(L)||!(Number.isFinite(L[0])&&L[0]>0)||!(Number.isFinite(L[1])&&L[1]>0))throw new R("$sheet must be [width, height], both more than 0");let U=e.gap??Ee(a("$gap")??3),P=e.margin??U;if(!(Number.isFinite(U)&&U>=0))throw new R("$gap must be a number, 0 or more");if(!(Number.isFinite(P)&&P>=0))throw new R("margin must be a number, 0 or more");let T=e.layout??(a("$layout")==="none"?"none":"pack"),S=["engrave",...[...u.keys()].filter(E=>!["engrave","score","cut","guide"].includes(E)),"score","cut","guide"].map(E=>u.get(E)).filter(Boolean),D=[],ce=[1,0,0,-1,0,0],ge=E=>Gr(E)??[0,0,0,0],q=(E,B)=>Hn({layers:E,parts:[]},B).layers;if(T==="none"){let E=[];for(let se of x)for(let ae=0;ae<se.info.qty;ae++)E.push({part:se.info.name,copy:ae+1,layers:q(se.layers,ce),rotated:!1});let B=new Map;for(let se of E)for(let[ae,he]of se.layers){let Ue=B.get(ae)??{regions:[],lines:[]};for(let ne of he.regions)Ue.regions.push(ne);for(let ne of he.lines)Ue.lines.push(ne);B.set(ae,Ue)}let j=ge(B),oe=[1,0,0,1,P-j[0],P-j[1]];for(let se of E)se.layers=q(se.layers,oe);D.push(z(E,j[2]-j[0]+2*P,j[3]-j[1]+2*P,x[0]?.info))}else{let E=new Map;for(let B of x){let j=`${B.info.material}|${B.info.thickness}`;E.set(j,[...E.get(j)??[],B])}for(let B of E.values()){let[j,oe]=L,se=[];for(let K of B){let Ae=q(K.layers,ce),Oe=ge(Ae),Tt=Oe[2]-Oe[0],It=Oe[3]-Oe[1],Es=!1;(Tt>j-2*P||It>oe-2*P)&&It<=j-2*P&&Tt<=oe-2*P&&(Ae=q(Ae,[0,1,-1,0,0,0]),Oe=ge(Ae),Tt=Oe[2]-Oe[0],It=Oe[3]-Oe[1],Es=!0),(Tt>j-2*P||It>oe-2*P)&&l.push(`Part "${K.info.name}" (${vt(Tt)} x ${vt(It)} mm) is bigger than the ${j} x ${oe} mm sheet.`),Ae=q(Ae,[1,0,0,1,-Oe[0],-Oe[1]]);for(let dr=0;dr<K.info.qty;dr++)se.push({info:K.info,layers:Ae,w:Tt,h:It,copy:dr+1,rotated:Es})}se.sort((K,Ae)=>Ae.h-K.h||Ae.w-K.w);let ae=[],he=P,Ue=P,ne=0,pe=0,xe=0,Pe=()=>{if(ae.length&&D.length>=i.maxSheets)throw new R(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);ae.length&&D.push(z(ae,Math.max(pe+P,1),Math.max(xe+P,1),B[0].info)),ae=[],he=P,Ue=P,ne=0,pe=0,xe=0};for(let K of se)he>P&&he+K.w>j-P&&(he=P,Ue+=ne+U,ne=0),ae.length&&Ue+K.h>oe-P&&Pe(),ae.push({part:K.info.name,copy:K.copy,layers:q(K.layers,[1,0,0,1,he,Ue]),rotated:K.rotated}),pe=Math.max(pe,he+K.w),xe=Math.max(xe,Ue+K.h),he+=K.w+U,ne=Math.max(ne,K.h);Pe()}}function z(E,B,j,oe){let se=vt(B),ae=vt(j);return{width:se,height:ae,material:oe?.material??"material",thickness:oe?.thickness??0,items:E,paths:ys(E,S),svg:bs(E,se,ae,S),dxf:na(E,se,ae,S)}}let _=D.length===1?D[0]:void 0,te=_?[]:D.flatMap((E,B)=>{let j=D.slice(0,B).reduce((oe,se)=>oe+se.height+10,0);return E.items.map(oe=>({...oe,layers:q(oe.layers,[1,0,0,1,0,j])}))}),ee=vt(Math.max(1,...D.map(E=>E.width))),ie=vt(Math.max(1,D.reduce((E,B)=>E+B.height,0)+10*Math.max(0,D.length-1))),fe=_?_.svg:bs(te,ee,ie,S),J=_?_.paths:ys(te,S);return{sheets:D,width:_?.width??ee,height:_?.height??ie,paths:J,svg:fe,parts:p,assembly:d,layers:S,warnings:l,echoes:o.echoes}}var fa=new WeakMap,Ss=new WeakSet,ha=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]),pa={$thickness:{value:"3",doc:"Material thickness, used by joinery and stored on parts"},$kerf:{value:"0",doc:"Beam width; cut outlines are offset by half of it"},$material:{value:'"material"',doc:"Material name; parts are packed per material and thickness"},$sheet:{value:"[600, 400]",doc:"Sheet size for packing"},$gap:{value:"3",doc:"Space between packed parts and around the sheet edge"},$layout:{value:'"pack"',doc:'`"pack"` packs parts onto sheets, `"none"` keeps your placement'},$fn:{value:"0",doc:"Segments in a full circle; 0 uses `$fa` and `$fs`"},$fa:{value:"2",doc:"Largest angle of a curve segment, in degrees"},$fs:{value:"0.2",doc:"Largest length of a curve segment, in mm"},$font:{doc:"Default font name for `text()`"},$children:{doc:"How many child statements the module was called with"},PI:{value:"3.141592653589793",doc:"\u03C0, half a turn in radians"}},_h=["true","false","undef"],jh="https://kerfscript.mylasertools.com/docs/reference/",Zh=n=>n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),xn=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function ia(n){let t=n.split(`
381
+ `}var sa=(n,e)=>{let t=0;for(let r=1;r<n.length;r++)t+=Math.hypot(n[r][0]-n[r-1][0],n[r][1]-n[r-1][1]);return e&&n.length>2&&(t+=Math.hypot(n[0][0]-n[n.length-1][0],n[0][1]-n[n.length-1][1])),t},mt=n=>Math.round(n*100)/100;function ia(n,e={}){for(let[I,B]of Object.entries(e.params??{}))try{wr(I,B)}catch(Y){throw new N(Y.message)}let{program:t}=ot(n),r=e.fonts?new ur(e.fonts,e.defaultFont):void 0,s=new fr({overrides:e.params,resolve:e.resolve,fonts:r,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,o;try{o=s.run(t)}catch(I){let B=I instanceof RangeError?new N(/call stack/i.test(I.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):I;throw B instanceof N&&(B.echoes=s.echoes,B.warnings=[...s.warnings],r?.missing.size&&(B.missingFonts=[...r.missing])),B}let a=I=>o.globals.get(I).value,l=o.warnings,u=o.layers,c=I=>u.get(I)?.mode??"line",h=[...o.shape.parts];[...o.shape.layers.values()].some(I=>I.regions.length||I.lines.length)&&h.unshift({name:"part",qty:1,layers:o.shape.layers,thickness:Ee(a("$thickness"))||3,kerf:Ee(a("$kerf"))||0,material:He(a("$material")??"material")}),h.length||l.push("Nothing to cut: the program made no shapes.");let p=[],d=[],g=[],m=new Set,x=[];for(let I of h){let B=be([...I.layers].filter(([se])=>c(se)==="cut").flatMap(([,se])=>se.regions)),Y=new Map;for(let[se,pe]of I.layers){if(c(se)==="guide"&&!e.guides)continue;let xe=be(pe.regions),Pe=pe.lines.filter(ee=>ee.length>=2);(c(se)==="line"||c(se)==="guide")&&(Pe=[...Pe,...xe.map(ee=>[...ee,ee[0]])],xe=[]),B.length&&c(se)!=="guide"&&(c(se)!=="cut"&&(xe=zn(xe,B)),Pe=rn(Pe,B,"inside")),(xe.length||Pe.length)&&Y.set(se,{regions:xe,lines:Pe})}if(B.length){let se={name:I.name,thickness:I.thickness,outline:B};if(I.placements){let pe=new Set;I.placements.forEach((xe,Pe)=>{let ee={...se,copy:Pe+1,matrix:Sr(xe),placed:!0};d.push(ee);let Ae=ee.matrix.map(Oe=>Oe.toFixed(6)).join(",");pe.has(Ae)&&m.add(ee),pe.add(Ae)}),pe.size<I.placements.length&&l.push(`Copies of part "${I.name}" are in the same place in the assembly. Give at a list with one placement per copy to spread them out.`)}else for(let pe=0;pe<I.qty;pe++)g.push({...se,copy:pe+1,matrix:Sr({at:[0,0,0],rotate:[0,0,0]}),placed:!1})}let le=ui(B).length;le>1&&l.push(`Part "${I.name}" cuts into ${le} separate pieces. Join them, or make them separate parts.`);let ae=0;for(let[se,pe]of Y)if(c(se)==="cut"){for(let xe of pe.regions)ae+=sa(xe,!0);for(let xe of pe.lines)ae+=sa(xe,!1)}let ue=Gr(Y)??[0,0,0,0],he=e.kerf??I.kerf;if(!(Number.isFinite(he)&&he>=0))throw new N("$kerf must be a number, 0 or more");let Ue={name:I.name,qty:I.qty,width:mt(ue[2]-ue[0]),height:mt(ue[3]-ue[1]),pieces:le,cutLength:Math.round(ae),thickness:I.thickness,kerf:he,material:I.material};if(he>0){for(let[se,pe]of Y)if(c(se)==="cut"){let xe=pe.regions.filter(ee=>lt(ee)<0).length;pe.regions=Hn(pe.regions,he/2,"round",Math.min(.01,he/20));let Pe=xe-pe.regions.filter(ee=>lt(ee)<0).length;Pe>0&&l.push(`Part "${I.name}": ${Pe} hole${Pe===1?" is":"s are"} narrower than the ${he} mm kerf and will not be cut.`)}}p.push(Ue),x.push({info:Ue,layers:Y})}let{found:L,complete:b}=Gs(d.filter(I=>!m.has(I)),i.maxCollisionPairs);b||l.push(`The assembly has more than ${i.maxCollisionPairs} pairs of touching parts, the limit, so only those were checked for collisions.`);for(let[I,B]of L.slice(0,5))l.push(`Parts "${I.name}"${I.copy>1?` (copy ${I.copy})`:""} and "${B.name}"${B.copy>1?` (copy ${B.copy})`:""} collide in the assembly. Check their edges and where they are placed.`);if(L.length>5&&l.push(`${L.length-5} more pairs of parts collide in the assembly.`),d.length&&g.length){let I=[...new Set(g.map(B=>`"${B.name}"`))];l.push(`${I.length===1?"Part":"Parts"} ${I.slice(0,5).join(", ")}${I.length>5?` and ${I.length-5} more`:""} ${I.length===1?"has":"have"} no at or rotate, so ${I.length===1?"it lies":"they lie"} flat beside the assembly.`),d.push(...Bs(d,g))}let M=0;for(let I of x){let B=0;for(let Y of I.layers.values()){for(let le of Y.regions)B+=le.length;for(let le of Y.lines)B+=le.length}M+=B*I.info.qty}if(M>i.maxOutputPoints)throw new N(`The files would have ${M} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let E=e.sheet??a("$sheet");if(!Array.isArray(E)||!(Number.isFinite(E[0])&&E[0]>0)||!(Number.isFinite(E[1])&&E[1]>0))throw new N("$sheet must be [width, height], both more than 0");let O=e.gap??Ee(a("$gap")??3),w=e.margin??O;if(!(Number.isFinite(O)&&O>=0))throw new N("$gap must be a number, 0 or more");if(!(Number.isFinite(w)&&w>=0))throw new N("margin must be a number, 0 or more");let T=e.layout??(a("$layout")==="none"?"none":"pack"),S=["engrave",...[...u.keys()].filter(I=>!["engrave","score","cut","guide"].includes(I)),"score","cut","guide"].map(I=>u.get(I)).filter(Boolean),A=[],W=[1,0,0,-1,0,0],j=I=>Gr(I)??[0,0,0,0],H=(I,B)=>Vn({layers:I,parts:[]},B).layers;if(T==="none"){let I=[];for(let ae of x)for(let ue=0;ue<ae.info.qty;ue++)I.push({part:ae.info.name,copy:ue+1,layers:H(ae.layers,W),rotated:!1});let B=new Map;for(let ae of I)for(let[ue,he]of ae.layers){let Ue=B.get(ue)??{regions:[],lines:[]};for(let se of he.regions)Ue.regions.push(se);for(let se of he.lines)Ue.lines.push(se);B.set(ue,Ue)}let Y=j(B),le=[1,0,0,1,w-Y[0],w-Y[1]];for(let ae of I)ae.layers=H(ae.layers,le);A.push(_(I,Y[2]-Y[0]+2*w,Y[3]-Y[1]+2*w,x[0]?.info))}else{let I=new Map;for(let B of x){let Y=`${B.info.material}|${B.info.thickness}`;I.set(Y,[...I.get(Y)??[],B])}for(let B of I.values()){let[Y,le]=E,ae=[];for(let ee of B){let Ae=H(ee.layers,W),Oe=j(Ae),Lt=Oe[2]-Oe[0],Tt=Oe[3]-Oe[1],Es=!1;(Lt>Y-2*w||Tt>le-2*w)&&Tt<=Y-2*w&&Lt<=le-2*w&&(Ae=H(Ae,[0,1,-1,0,0,0]),Oe=j(Ae),Lt=Oe[2]-Oe[0],Tt=Oe[3]-Oe[1],Es=!0),(Lt>Y-2*w||Tt>le-2*w)&&l.push(`Part "${ee.info.name}" (${mt(Lt)} x ${mt(Tt)} mm) is bigger than the ${Y} x ${le} mm sheet.`),Ae=H(Ae,[1,0,0,1,-Oe[0],-Oe[1]]);for(let dr=0;dr<ee.info.qty;dr++)ae.push({info:ee.info,layers:Ae,w:Lt,h:Tt,copy:dr+1,rotated:Es})}ae.sort((ee,Ae)=>Ae.h-ee.h||Ae.w-ee.w);let ue=[],he=w,Ue=w,se=0,pe=0,xe=0,Pe=()=>{if(ue.length&&A.length>=i.maxSheets)throw new N(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);ue.length&&A.push(_(ue,Math.max(pe+w,1),Math.max(xe+w,1),B[0].info)),ue=[],he=w,Ue=w,se=0,pe=0,xe=0};for(let ee of ae)he>w&&he+ee.w>Y-w&&(he=w,Ue+=se+O,se=0),ue.length&&Ue+ee.h>le-w&&Pe(),ue.push({part:ee.info.name,copy:ee.copy,layers:H(ee.layers,[1,0,0,1,he,Ue]),rotated:ee.rotated}),pe=Math.max(pe,he+ee.w),xe=Math.max(xe,Ue+ee.h),he+=ee.w+O,se=Math.max(se,ee.h);Pe()}}function _(I,B,Y,le){let ae=mt(B),ue=mt(Y);return{width:ae,height:ue,material:le?.material??"material",thickness:le?.thickness??0,items:I,paths:ys(I,S),svg:bs(I,ae,ue,S),dxf:ra(I,ae,ue,S)}}let $=A.length===1?A[0]:void 0,te=$?[]:A.flatMap((I,B)=>{let Y=A.slice(0,B).reduce((le,ae)=>le+ae.height+10,0);return I.items.map(le=>({...le,layers:H(le.layers,[1,0,0,1,0,Y])}))}),re=mt(Math.max(1,...A.map(I=>I.width))),ne=mt(Math.max(1,A.reduce((I,B)=>I+B.height,0)+10*Math.max(0,A.length-1))),de=$?$.svg:bs(te,re,ne,S),Q=$?$.paths:ys(te,S);return{sheets:A,width:$?.width??re,height:$?.height??ne,paths:Q,svg:de,parts:p,assembly:d,layers:S,warnings:l,echoes:o.echoes}}var ha=new WeakMap,Ss=new WeakSet,pa=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]),da={$thickness:{value:"3",doc:"Material thickness, used by joinery and stored on parts"},$kerf:{value:"0",doc:"Beam width; cut outlines are offset by half of it"},$material:{value:'"material"',doc:"Material name; parts are packed per material and thickness"},$sheet:{value:"[600, 400]",doc:"Sheet size for packing"},$gap:{value:"3",doc:"Space between packed parts and around the sheet edge"},$layout:{value:'"pack"',doc:'`"pack"` packs parts onto sheets, `"none"` keeps your placement'},$fn:{value:"0",doc:"Segments in a full circle; 0 uses `$fa` and `$fs`"},$fa:{value:"2",doc:"Largest angle of a curve segment, in degrees"},$fs:{value:"0.2",doc:"Largest length of a curve segment, in mm"},$font:{doc:"Default font name for `text()`"},$children:{doc:"How many child statements the module was called with"},PI:{value:"3.141592653589793",doc:"\u03C0, half a turn in radians"}},Zh=["true","false","undef"],Yh="https://kerfscript.mylasertools.com/docs/reference/",Kh=n=>n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),yn=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function oa(n){let t=n.split(`
382
382
  `).slice(0,8).join(`
383
- `);return t.length>400&&(t=t.slice(0,400)),t.length<n.length?t+" \u2026":t}var hr=class{constructor(e,t,r,s,i){this.src=e;this.tokens=t;this.comments=r;this.file=s;this.load=i;this.definitions=[];this.references=[];this.scopes=[];this.libraries=[];this.seq=0;this.order=new Map;this.pending=[];this.stmtDefs=new Map;this.tokenAt=new Map;t.forEach((o,a)=>this.tokenAt.set(o.pos.offset,a))}run(e){let t=this.scope(void 0,0,this.src.length);this.block(e,t);for(let r of this.pending)this.resolve(r);return t}scope(e,t,r){let s={start:t,end:r,parent:e,vars:new Map,fns:new Map,mods:new Map};return this.scopes.push(s),s}define(e,t,r){let s=e[t].get(r.name);s?s.push(r):e[t].set(r.name,[r]),this.order.set(r,this.seq++),r.file===this.file&&(this.definitions.push(r),fa.set(r,{scope:e,ns:t}))}def(e,t,r,s){return{name:t,kind:e,start:r.offset,end:r.offset+t.length,range:s,...this.file!==void 0&&{file:this.file}}}ref(e,t,r,s,i,o){let a={name:e,start:t.offset,end:t.offset+e.length};return this.references.push(a),this.pending.push({ref:a,scope:r,ns:s,builtin:i,callee:o,seq:this.seq++}),a}find(e,t,r,s){for(let i=e;i;i=i.parent){let o=i[t].get(r);if(!o)continue;if(t!=="vars")return o[o.length-1];let a=o.filter(l=>this.order.get(l)<s);if(a.length)return a[a.length-1]}if(t==="vars")for(let i=e;i;i=i.parent){let o=i.vars.get(r);if(o)return o[o.length-1]}}resolve(e){let{ref:t}=e;if(e.callee){let s=e.callee.def?.params,i=e.callee.builtin,o=s?.find(a=>a.name===t.name);o?t.def=o:i?.params.some(a=>a.name===t.name)&&(t.builtin=i,t.arg=t.name);return}for(let s of e.ns){let i=this.find(e.scope,s,t.name,e.seq);if(i){t.def=i;return}}let r=e.builtin&&At(t.name);r&&(r.kind===e.builtin||r.kind==="both")&&(t.builtin=r)}docAbove(e){let t=[],r=e-1;for(let s=this.comments.length-1;s>=0;s--){let i=this.comments[s];if(i.line>r)continue;let o=i.line+(this.src.slice(i.start,i.end).match(/\n/g)?.length??0);if(!i.own||o!==r||/^\[[^\]]*\]$/.test(i.text))break;t.unshift(i.block?i.text.replace(/^[ \t]*\* ?/gm,""):i.text),r=i.line-1}return t.length?t.join(`
384
- `):void 0}valueAfter(e){let t=this.tokenAt.get(e);if(t===void 0||this.tokens[t+1]?.value!=="=")return;let r=0,s=t+2;for(;s<this.tokens.length;s++){let i=this.tokens[s];if(i.type==="eof")break;if(i.type==="punct"){if(i.value==="("||i.value==="["||i.value==="{")r++;else if(i.value===")"||i.value==="]"||i.value==="}"){if(!r)break;r--}else if((i.value===","||i.value===";")&&!r)break}}if(s!==t+2)return ia(this.src.slice(this.tokens[t+2].pos.offset,this.tokens[s-1].end))}end(e){return e.end??e.pos.offset}block(e,t){for(let r of e)if(r.kind==="module"||r.kind==="function"){let s=this.def(r.kind,r.name,r.namePos??r.pos,[r.pos.offset,this.end(r)]),i=this.docAbove(r.pos.line);i&&(s.doc=i),Ss.add(s),this.stmtDefs.set(r,s),this.define(t,r.kind==="module"?"mods":"fns",s)}else r.kind==="use"&&!r.include&&this.library(r,t);for(let r of e)this.stmt(r,t)}inner(e,t){return this.scope(e,t.pos.offset,this.end(t))}stmt(e,t){switch(e.kind){case"assign":{this.expr(e.value,t);let r=this.def("variable",e.name,e.pos,[e.pos.offset,this.end(e)]);r.value=ia(this.src.slice(e.span[0],e.span[1]));let s=this.docAbove(e.pos.line);s&&(r.doc=s),Ss.add(r),this.define(t,"vars",r);return}case"module":{let r=this.inner(t,e),s=this.stmtDefs.get(e);s.params=this.params(e.params,r,s),this.block(e.body,r);return}case"function":{let r=this.inner(t,e),s=this.stmtDefs.get(e);s.params=this.params(e.params,r,s),this.expr(e.body,r);return}case"use":e.include&&this.library(e,t);return;case"call":{let r=this.ref(e.name,e.pos,t,["mods"],"module");this.args(e.args,t,r),e.children.length&&this.block(e.children,this.inner(t,e));return}case"for":case"let":{let r=this.inner(t,e);this.assigns(e.assigns,r),this.block(e.body,r);return}case"if":this.expr(e.cond,t),this.block(e.then,this.inner(t,e)),this.block(e.else,this.inner(t,e));return;case"block":this.block(e.body,this.inner(t,e));return}}library(e,t){let r=this.tokenAt.get(e.pos.offset),s=r===void 0?void 0:this.tokens[r+1],i=this.load(e.path);if(s?.type==="str"&&this.libraries.push({path:e.path,include:e.include,start:s.pos.offset,end:s.end,found:!!i}),!!i){for(let o of i.mods)this.define(t,"mods",o);for(let o of i.fns)this.define(t,"fns",o);if(e.include)for(let o of i.vars)this.define(t,"vars",o)}}params(e,t,r){let s=e.map(i=>{let o=i.pos??{line:0,col:0,offset:r?.range[0]??0},a=this.def("parameter",i.name,o,[o.offset,o.offset+i.name.length]);if(i.default&&i.pos){let l=this.valueAfter(i.pos.offset);l!==void 0&&(a.value=l)}return r&&(a.owner=r),this.define(t,"vars",a),a});for(let i of e)i.default&&this.expr(i.default,t);return s}assigns(e,t){for(let r of e){this.expr(r.value,t);let s=this.def("variable",r.name,r.pos,[r.pos.offset,r.pos.offset+r.name.length]),i=this.valueAfter(r.pos.offset);i!==void 0&&(s.value=i),this.define(t,"vars",s)}}args(e,t,r){for(let s of e)s.name&&s.pos&&this.ref(s.name,s.pos,t,[],void 0,r),this.expr(s.value,t)}expr(e,t){switch(e.kind){case"var":this.ref(e.name,e.pos,t,["vars"]);return;case"list":for(let r of e.items)this.item(r,t);return;case"range":this.expr(e.start,t),e.step&&this.expr(e.step,t),this.expr(e.end,t);return;case"unary":this.expr(e.arg,t);return;case"binary":this.expr(e.left,t),this.expr(e.right,t);return;case"ternary":this.expr(e.cond,t),this.expr(e.then,t),this.expr(e.else,t);return;case"index":this.expr(e.target,t),this.expr(e.index,t);return;case"member":this.expr(e.target,t);return;case"call":{let r;e.callee.kind==="var"?r=this.ref(e.callee.name,e.callee.pos,t,["vars","fns"],"function"):this.expr(e.callee,t),this.args(e.args,t,r);return}case"lambda":{let r=this.inner(t,e);this.params(e.params,r),this.expr(e.body,r);return}case"let":{let r=this.inner(t,e);this.assigns(e.assigns,r),this.expr(e.body,r);return}}}item(e,t){switch(e.kind){case"item":case"each":this.expr(e.expr,t);return;case"if":this.expr(e.cond,t),this.item(e.then,t),e.else&&this.item(e.else,t);return;case"for":case"let":{let r=e.pos?this.scope(t,e.pos.offset,e.end??e.pos.offset):t;this.assigns(e.assigns,r),this.item(e.body,r);return}}}};function da(n){let e=n,t=!1;for(let r=0;r<12;r++)try{let{tokens:s,comments:i}=Ct(e),{program:o}=it(e);return{text:e,tokens:s,comments:i,body:o.body,parsed:r===0}}catch(s){if(!(s instanceof R)||s.line===void 0)return;if(s.reason==="Unclosed block comment"){e+="*/";continue}let i=/found end of file$/.test(s.reason);if(t&&(i||s.line>oa(n))){e=e.slice(0,n.length),t=!1;let a=e.trimEnd().split(`
385
- `).length;e=aa(e,a);continue}if(i){let a=Yh(e);if(a){e+=`
386
- `+a+";",t=!0;continue}}let o=aa(e,Math.min(s.line,oa(e)));if(o===e)return;e=o}}var oa=n=>n.split(`
387
- `).length;function aa(n,e){let t=0;for(let s=1;s<e;s++)t=n.indexOf(`
383
+ `);return t.length>400&&(t=t.slice(0,400)),t.length<n.length?t+" \u2026":t}var hr=class{constructor(e,t,r,s,i){this.src=e;this.tokens=t;this.comments=r;this.file=s;this.load=i;this.definitions=[];this.references=[];this.scopes=[];this.libraries=[];this.seq=0;this.order=new Map;this.pending=[];this.stmtDefs=new Map;this.tokenAt=new Map;t.forEach((o,a)=>this.tokenAt.set(o.pos.offset,a))}run(e){let t=this.scope(void 0,0,this.src.length);this.block(e,t);for(let r of this.pending)this.resolve(r);return t}scope(e,t,r){let s={start:t,end:r,parent:e,vars:new Map,fns:new Map,mods:new Map};return this.scopes.push(s),s}define(e,t,r){let s=e[t].get(r.name);s?s.push(r):e[t].set(r.name,[r]),this.order.set(r,this.seq++),r.file===this.file&&(this.definitions.push(r),ha.set(r,{scope:e,ns:t}))}def(e,t,r,s){return{name:t,kind:e,start:r.offset,end:r.offset+t.length,range:s,...this.file!==void 0&&{file:this.file}}}ref(e,t,r,s,i,o){let a={name:e,start:t.offset,end:t.offset+e.length};return this.references.push(a),this.pending.push({ref:a,scope:r,ns:s,builtin:i,callee:o,seq:this.seq++}),a}find(e,t,r,s){for(let i=e;i;i=i.parent){let o=i[t].get(r);if(!o)continue;if(t!=="vars")return o[o.length-1];let a=o.filter(l=>this.order.get(l)<s);if(a.length)return a[a.length-1]}if(t==="vars")for(let i=e;i;i=i.parent){let o=i.vars.get(r);if(o)return o[o.length-1]}}resolve(e){let{ref:t}=e;if(e.callee){let s=e.callee.def?.params,i=e.callee.builtin,o=s?.find(a=>a.name===t.name);o?t.def=o:i?.params.some(a=>a.name===t.name)&&(t.builtin=i,t.arg=t.name);return}for(let s of e.ns){let i=this.find(e.scope,s,t.name,e.seq);if(i){t.def=i;return}}let r=e.builtin&&Ct(t.name);r&&(r.kind===e.builtin||r.kind==="both")&&(t.builtin=r)}docAbove(e){let t=[],r=e-1;for(let s=this.comments.length-1;s>=0;s--){let i=this.comments[s];if(i.line>r)continue;let o=i.line+(this.src.slice(i.start,i.end).match(/\n/g)?.length??0);if(!i.own||o!==r||/^\[[^\]]*\]$/.test(i.text))break;t.unshift(i.block?i.text.replace(/^[ \t]*\* ?/gm,""):i.text),r=i.line-1}return t.length?t.join(`
384
+ `):void 0}valueAfter(e){let t=this.tokenAt.get(e);if(t===void 0||this.tokens[t+1]?.value!=="=")return;let r=0,s=t+2;for(;s<this.tokens.length;s++){let i=this.tokens[s];if(i.type==="eof")break;if(i.type==="punct"){if(i.value==="("||i.value==="["||i.value==="{")r++;else if(i.value===")"||i.value==="]"||i.value==="}"){if(!r)break;r--}else if((i.value===","||i.value===";")&&!r)break}}if(s!==t+2)return oa(this.src.slice(this.tokens[t+2].pos.offset,this.tokens[s-1].end))}end(e){return e.end??e.pos.offset}block(e,t){for(let r of e)if(r.kind==="module"||r.kind==="function"){let s=this.def(r.kind,r.name,r.namePos??r.pos,[r.pos.offset,this.end(r)]),i=this.docAbove(r.pos.line);i&&(s.doc=i),Ss.add(s),this.stmtDefs.set(r,s),this.define(t,r.kind==="module"?"mods":"fns",s)}else r.kind==="use"&&!r.include&&this.library(r,t);for(let r of e)this.stmt(r,t)}inner(e,t){return this.scope(e,t.pos.offset,this.end(t))}stmt(e,t){switch(e.kind){case"assign":{this.expr(e.value,t);let r=this.def("variable",e.name,e.pos,[e.pos.offset,this.end(e)]);r.value=oa(this.src.slice(e.span[0],e.span[1]));let s=this.docAbove(e.pos.line);s&&(r.doc=s),Ss.add(r),this.define(t,"vars",r);return}case"module":{let r=this.inner(t,e),s=this.stmtDefs.get(e);s.params=this.params(e.params,r,s),this.block(e.body,r);return}case"function":{let r=this.inner(t,e),s=this.stmtDefs.get(e);s.params=this.params(e.params,r,s),this.expr(e.body,r);return}case"use":e.include&&this.library(e,t);return;case"call":{let r=this.ref(e.name,e.pos,t,["mods"],"module");this.args(e.args,t,r),e.children.length&&this.block(e.children,this.inner(t,e));return}case"for":case"let":{let r=this.inner(t,e);this.assigns(e.assigns,r),this.block(e.body,r);return}case"if":this.expr(e.cond,t),this.block(e.then,this.inner(t,e)),this.block(e.else,this.inner(t,e));return;case"block":this.block(e.body,this.inner(t,e));return}}library(e,t){let r=this.tokenAt.get(e.pos.offset),s=r===void 0?void 0:this.tokens[r+1],i=this.load(e.path);if(s?.type==="str"&&this.libraries.push({path:e.path,include:e.include,start:s.pos.offset,end:s.end,found:!!i}),!!i){for(let o of i.mods)this.define(t,"mods",o);for(let o of i.fns)this.define(t,"fns",o);if(e.include)for(let o of i.vars)this.define(t,"vars",o)}}params(e,t,r){let s=e.map(i=>{let o=i.pos??{line:0,col:0,offset:r?.range[0]??0},a=this.def("parameter",i.name,o,[o.offset,o.offset+i.name.length]);if(i.default&&i.pos){let l=this.valueAfter(i.pos.offset);l!==void 0&&(a.value=l)}return r&&(a.owner=r),this.define(t,"vars",a),a});for(let i of e)i.default&&this.expr(i.default,t);return s}assigns(e,t){for(let r of e){this.expr(r.value,t);let s=this.def("variable",r.name,r.pos,[r.pos.offset,r.pos.offset+r.name.length]),i=this.valueAfter(r.pos.offset);i!==void 0&&(s.value=i),this.define(t,"vars",s)}}args(e,t,r){for(let s of e)s.name&&s.pos&&this.ref(s.name,s.pos,t,[],void 0,r),this.expr(s.value,t)}expr(e,t){switch(e.kind){case"var":this.ref(e.name,e.pos,t,["vars"]);return;case"list":for(let r of e.items)this.item(r,t);return;case"range":this.expr(e.start,t),e.step&&this.expr(e.step,t),this.expr(e.end,t);return;case"unary":this.expr(e.arg,t);return;case"binary":this.expr(e.left,t),this.expr(e.right,t);return;case"ternary":this.expr(e.cond,t),this.expr(e.then,t),this.expr(e.else,t);return;case"index":this.expr(e.target,t),this.expr(e.index,t);return;case"member":this.expr(e.target,t);return;case"call":{let r;e.callee.kind==="var"?r=this.ref(e.callee.name,e.callee.pos,t,["vars","fns"],"function"):this.expr(e.callee,t),this.args(e.args,t,r);return}case"lambda":{let r=this.inner(t,e);this.params(e.params,r),this.expr(e.body,r);return}case"let":{let r=this.inner(t,e);this.assigns(e.assigns,r),this.expr(e.body,r);return}}}item(e,t){switch(e.kind){case"item":case"each":this.expr(e.expr,t);return;case"if":this.expr(e.cond,t),this.item(e.then,t),e.else&&this.item(e.else,t);return;case"for":case"let":{let r=e.pos?this.scope(t,e.pos.offset,e.end??e.pos.offset):t;this.assigns(e.assigns,r),this.item(e.body,r);return}}}};function ga(n){let e=n,t=!1;for(let r=0;r<12;r++)try{let{tokens:s,comments:i}=It(e),{program:o}=ot(e);return{text:e,tokens:s,comments:i,body:o.body,parsed:r===0}}catch(s){if(!(s instanceof N)||s.line===void 0)return;if(s.reason==="Unclosed block comment"){e+="*/";continue}let i=/found end of file$/.test(s.reason);if(t&&(i||s.line>aa(n))){e=e.slice(0,n.length),t=!1;let a=e.trimEnd().split(`
385
+ `).length;e=la(e,a);continue}if(i){let a=Jh(e);if(a){e+=`
386
+ `+a+";",t=!0;continue}}let o=la(e,Math.min(s.line,aa(e)));if(o===e)return;e=o}}var aa=n=>n.split(`
387
+ `).length;function la(n,e){let t=0;for(let s=1;s<e;s++)t=n.indexOf(`
388
388
  `,t)+1;let r=n.indexOf(`
389
- `,t);return r<0&&(r=n.length),n.slice(0,t)+n.slice(t,r).replace(/\S/g," ")+n.slice(r)}function Yh(n){let e;try{e=Ct(n).tokens}catch{return""}let t=[];for(let r of e)r.type==="punct"&&(r.value==="("||r.value==="["||r.value==="{"?t.push(r.value):(r.value===")"||r.value==="]"||r.value==="}")&&t.pop());return t.reverse().map(r=>r==="("?")":r==="["?"]":";}").join("")}var la=new Map;function ga(n,e){return t=>{if(e.includes(t))return;let r=xn(tt,t),s=r??n?.(t);if(typeof s!="string")return;let i=r!==void 0?la.get(t):void 0;if(i)return i;let o=da(s),a={mods:[],fns:[],vars:[]};if(o){let u=new hr(o.text,o.tokens,o.comments,t,ga(n,[...e,t])).run(o.body),c=h=>[...h.values()].map(f=>f[f.length-1]);a.mods=c(u.mods),a.fns=c(u.fns),a.vars=c(u.vars)}return r!==void 0&&la.set(t,a),a}}function Kh(n,e={}){let t=da(n),r=[...Object.keys(tt),...e.libraries??[]];if(!t){let o={start:0,end:n.length,vars:new Map,fns:new Map,mods:new Map};return{source:n,parsed:!1,definitions:[],references:[],scopes:[o],libraries:[],available:r,settings:[]}}let s=new hr(t.text,t.tokens,t.comments,void 0,ga(e.resolve,[]));s.run(t.body);let i=[];if(t.parsed)try{i=Ts(n).parameters}catch{}return{source:n,parsed:t.parsed,definitions:s.definitions,references:s.references,scopes:s.scopes,libraries:s.libraries,available:r,settings:i}}function ws(n,e){let t=[...n.references,...n.definitions].filter(r=>r.start<=e&&e<=r.end);return t.find(r=>e<r.end)??t[0]}var pr=n=>"kind"in n;function ma(n,e){let t=ws(n,e);if(t)return pr(t)?t:t.def}function va(n,e,t=!0){let r=ma(n,e);if(!r)return[];let s=fa.get(r),i=new Set(s?s.scope[s.ns].get(r.name):[r]),o=[];if(t)for(let a of i)a.file===void 0&&n.definitions.includes(a)&&o.push({start:a.start,end:a.end,definition:!0});for(let a of n.references)a.def&&i.has(a.def)&&o.push({start:a.start,end:a.end,definition:!1});return o.sort((a,l)=>a.start-l.start)}function xa(n,e){let t=ws(n,e),r=t&&(pr(t)?t:t.def);return!t||!r?t&&!pr(t)&&t.builtin?{error:`${t.name} is built in`}:{error:"There is no name here that the program defines"}:r.file!==void 0?{error:`${r.name} is defined in <${r.file}>`}:{start:t.start,end:t.end,name:t.name}}function Jh(n,e,t){let r=xa(n,e);return"error"in r?r:!/^\$?[A-Za-z_][A-Za-z0-9_]*$/.test(t)||ha.has(t)?{error:`"${t}" is not a name`}:t.startsWith("$")!==r.name.startsWith("$")?{error:"Names with $ are special variables, seen by every module called, so $ stays or goes"}:va(n,e).map(({start:s,end:i})=>({start:s,end:i}))}function ks(n){let e=(n.params??[]).map(t=>t.value?`${t.name} = ${t.value}`:t.name);return`${n.kind} ${n.name}(${e.join(", ")})`}var yn=n=>"```kerfscript\n"+n+"\n```";function Qh(n){let e=["Setting"];return n.group&&(e[0]+=` in **${n.group}**`),n.options?e.push(n.options.map(t=>`\`${t.name}\``).join(", ")):n.min!==void 0&&n.max!==void 0&&e.push(`${n.min} to ${n.max}${n.step!==void 0?`, in steps of ${n.step}`:""}`),e.join(": ")}function ua(n,e){let t=[];e.kind==="module"||e.kind==="function"?t.push(yn(ks(e))):t.push(yn(e.value!==void 0?`${e.name} = ${e.value}`:e.name)),e.kind==="parameter"&&t.push(e.owner?`Parameter of ${e.owner.kind} \`${e.owner.name}()\``:"Parameter of a function"),e.doc&&t.push(e.doc);let r=e.file===void 0&&n.settings.find(s=>s.name===e.name&&s.span[0]>=e.start);return r&&e.kind==="variable"&&t.push(Qh(r)),e.file!==void 0&&t.push(`From \`<${e.file}>\``),t.join(`
389
+ `,t);return r<0&&(r=n.length),n.slice(0,t)+n.slice(t,r).replace(/\S/g," ")+n.slice(r)}function Jh(n){let e;try{e=It(n).tokens}catch{return""}let t=[];for(let r of e)r.type==="punct"&&(r.value==="("||r.value==="["||r.value==="{"?t.push(r.value):(r.value===")"||r.value==="]"||r.value==="}")&&t.pop());return t.reverse().map(r=>r==="("?")":r==="["?"]":";}").join("")}var ua=new Map;function ma(n,e){return t=>{if(e.includes(t))return;let r=yn(nt,t),s=r??n?.(t);if(typeof s!="string")return;let i=r!==void 0?ua.get(t):void 0;if(i)return i;let o=ga(s),a={mods:[],fns:[],vars:[]};if(o){let u=new hr(o.text,o.tokens,o.comments,t,ma(n,[...e,t])).run(o.body),c=h=>[...h.values()].map(f=>f[f.length-1]);a.mods=c(u.mods),a.fns=c(u.fns),a.vars=c(u.vars)}return r!==void 0&&ua.set(t,a),a}}function Qh(n,e={}){let t=ga(n),r=[...Object.keys(nt),...e.libraries??[]];if(!t){let o={start:0,end:n.length,vars:new Map,fns:new Map,mods:new Map};return{source:n,parsed:!1,definitions:[],references:[],scopes:[o],libraries:[],available:r,settings:[]}}let s=new hr(t.text,t.tokens,t.comments,void 0,ma(e.resolve,[]));s.run(t.body);let i=[];if(t.parsed)try{i=Ts(n).parameters}catch{}return{source:n,parsed:t.parsed,definitions:s.definitions,references:s.references,scopes:s.scopes,libraries:s.libraries,available:r,settings:i}}function ws(n,e){let t=[...n.references,...n.definitions].filter(r=>r.start<=e&&e<=r.end);return t.find(r=>e<r.end)??t[0]}var pr=n=>"kind"in n;function va(n,e){let t=ws(n,e);if(t)return pr(t)?t:t.def}function xa(n,e,t=!0){let r=va(n,e);if(!r)return[];let s=ha.get(r),i=new Set(s?s.scope[s.ns].get(r.name):[r]),o=[];if(t)for(let a of i)a.file===void 0&&n.definitions.includes(a)&&o.push({start:a.start,end:a.end,definition:!0});for(let a of n.references)a.def&&i.has(a.def)&&o.push({start:a.start,end:a.end,definition:!1});return o.sort((a,l)=>a.start-l.start)}function ya(n,e){let t=ws(n,e),r=t&&(pr(t)?t:t.def);return!t||!r?t&&!pr(t)&&t.builtin?{error:`${t.name} is built in`}:{error:"There is no name here that the program defines"}:r.file!==void 0?{error:`${r.name} is defined in <${r.file}>`}:{start:t.start,end:t.end,name:t.name}}function ep(n,e,t){let r=ya(n,e);return"error"in r?r:!/^\$?[A-Za-z_][A-Za-z0-9_]*$/.test(t)||pa.has(t)?{error:`"${t}" is not a name`}:t.startsWith("$")!==r.name.startsWith("$")?{error:"Names with $ are special variables, seen by every module called, so $ stays or goes"}:xa(n,e).map(({start:s,end:i})=>({start:s,end:i}))}function ks(n){let e=(n.params??[]).map(t=>t.value?`${t.name} = ${t.value}`:t.name);return`${n.kind} ${n.name}(${e.join(", ")})`}var bn=n=>"```kerfscript\n"+n+"\n```";function tp(n){let e=["Setting"];return n.group&&(e[0]+=` in **${n.group}**`),n.options?e.push(n.options.map(t=>`\`${t.name}\``).join(", ")):n.min!==void 0&&n.max!==void 0&&e.push(`${n.min} to ${n.max}${n.step!==void 0?`, in steps of ${n.step}`:""}`),e.join(": ")}function ca(n,e){let t=[];e.kind==="module"||e.kind==="function"?t.push(bn(ks(e))):t.push(bn(e.value!==void 0?`${e.name} = ${e.value}`:e.name)),e.kind==="parameter"&&t.push(e.owner?`Parameter of ${e.owner.kind} \`${e.owner.name}()\``:"Parameter of a function"),e.doc&&t.push(e.doc);let r=e.file===void 0&&n.settings.find(s=>s.name===e.name&&s.span[0]>=e.start);return r&&e.kind==="variable"&&t.push(tp(r)),e.file!==void 0&&t.push(`From \`<${e.file}>\``),t.join(`
390
390
 
391
- `)}function ep(n,e){let t=`[Reference](${jh}#${Zh(n.section)})`;if(e){let i=n.params.find(o=>o.name===e);return[yn(i.default!==void 0?`${i.name} = ${i.default}`:i.name),`Parameter of \`${n.name}()\`${i.doc?`: ${i.doc}`:""}`].join(`
391
+ `)}function np(n,e){let t=`[Reference](${Yh}#${Kh(n.section)})`;if(e){let i=n.params.find(o=>o.name===e);return[bn(i.default!==void 0?`${i.name} = ${i.default}`:i.name),`Parameter of \`${n.name}()\`${i.doc?`: ${i.doc}`:""}`].join(`
392
392
 
393
- `)}let r=[kn(n),...n.forms??[]],s=n.params.filter(i=>i.doc).map(i=>`- \`${i.name}\`: ${i.doc}${i.named?" (by name only)":""}`);return[yn(r.join(`
393
+ `)}let r=[En(n),...n.forms??[]],s=n.params.filter(i=>i.doc).map(i=>`- \`${i.name}\`: ${i.doc}${i.named?" (by name only)":""}`);return[bn(r.join(`
394
394
  `)),n.doc,s.join(`
395
395
  `),t].filter(Boolean).join(`
396
396
 
397
- `)}function ya(n){let e=[];for(let t of n.split(`
397
+ `)}function ba(n){let e=[];for(let t of n.split(`
398
398
  `)){let r=/^\s*\/\/\s?(.*)$/.exec(t);if(!r)break;/copyright|spdx/i.test(r[1])||e.push(r[1])}return e.join(`
399
- `).trim()}function tp(n,e,t={}){let r=n.libraries.find(a=>a.start<=e&&e<=a.end);if(r){let a=xn(tt,r.path)??t.resolve?.(r.path),l=xn(tt,r.path)?"Standard library":"Library",u=a===void 0?`Library <${r.path}> not found`:ya(a)||l;return{start:r.start,end:r.end,text:u}}let s=ws(n,e);if(!s)return;let i={start:s.start,end:s.end};if(pr(s))return{...i,text:ua(n,s)};if(s.def)return{...i,text:ua(n,s.def)};if(s.builtin)return{...i,text:ep(s.builtin,s.arg)};let o=xn(pa,s.name);if(o)return{...i,text:[yn(o.value!==void 0?`${s.name} = ${o.value}`:s.name),o.doc].join(`
399
+ `).trim()}function rp(n,e,t={}){let r=n.libraries.find(a=>a.start<=e&&e<=a.end);if(r){let a=yn(nt,r.path)??t.resolve?.(r.path),l=yn(nt,r.path)?"Standard library":"Library",u=a===void 0?`Library <${r.path}> not found`:ba(a)||l;return{start:r.start,end:r.end,text:u}}let s=ws(n,e);if(!s)return;let i={start:s.start,end:s.end};if(pr(s))return{...i,text:ca(n,s)};if(s.def)return{...i,text:ca(n,s.def)};if(s.builtin)return{...i,text:np(s.builtin,s.arg)};let o=yn(da,s.name);if(o)return{...i,text:[bn(o.value!==void 0?`${s.name} = ${o.value}`:s.name),o.doc].join(`
400
400
 
401
- `)}}function ba(n,e){let t=/[A-Za-z0-9_$]*$/.exec(n.slice(0,e))[0],r=e-t.length,s;try{s=Ct(n.slice(0,r)).tokens.slice(0,-1)}catch{return}let i=s.length?s[s.length-1].end:0;if(/\/\/[^\n]*$/.test(n.slice(i,r)))return;let o=[],a=0;return s.forEach((l,u)=>{if(l.type!=="punct")return;let c=o[o.length-1];if(l.value==="("||l.value==="["||l.value==="{"){let h={token:l,index:u,commas:[]},f=s[u-1];if(l.value==="("&&f?.type==="id"){let p=s[u-2];f.value==="for"||f.value==="if"||f.value==="let"?h.header=!0:f.value==="function"?h.params=!0:ha.has(f.value)||(h.callee=f,p?.type==="id"&&(p.value==="module"||p.value==="function")&&(h.params=!0))}o.push(h),l.value==="{"&&(a=u+1)}else l.value===")"||l.value==="]"||l.value==="}"?(o.pop(),l.value==="}"&&(a=u+1)):l.value===","&&c?c.commas.push(u):l.value===";"&&(!c||c.token.value==="{")&&(a=u+1)}),{word:t,from:r,tokens:s,stack:o,stmtStart:a,prev:s[s.length-1]}}function Sa(n,e){let t=n.references.find(s=>s.start===e.pos.offset);if(t?.def?.params)return{def:t.def};if(t?.builtin)return{sig:t.builtin};let r=At(e.value);return r?{sig:r}:void 0}function np(n,e){let t=n.scopes.filter(s=>s.start<=e&&e<=s.end).sort((s,i)=>s.end-s.start-(i.end-i.start))[0],r=[];for(let s=t??n.scopes[0];s;s=s.parent)r.push(s);return r}function rp(n,e){let t=n.source,r=t.slice(t.lastIndexOf(`
402
- `,e-1)+1,e),s=/\b(?:use|include)\s*<([A-Za-z0-9_./-]*)$/.exec(r);if(s){let S=[...new Set(n.available)].map(D=>({label:D,kind:"library",...xn(tt,D)!==void 0&&{detail:"Standard library",doc:ya(tt[D])}}));return{from:e-s[1].length,to:e,items:S}}let i={from:e,to:e,items:[]},o=ba(t,e);if(!o||/^\d/.test(o.word))return i;let{tokens:a,stack:l,stmtStart:u,prev:c,from:h}=o,f=S=>({from:h,to:e,items:S});if(c?.type==="punct"&&c.value===".")return f(["x","y","z"].map(S=>({label:S,kind:"property",detail:`item ${S}`})));if(c?.type==="id"&&(c.value==="module"||c.value==="function"))return i;let p=l[l.length-1],d=p&&c&&(c===p.token||c.type==="punct"&&c.value===",");if(p?.params&&d)return i;let g=[],y=new Set,x=S=>{y.has(S.kind+" "+S.label)||(y.add(S.kind+" "+S.label),g.push(S))};if(p?.callee&&d){let S=Sa(n,p.callee);if(S?.def)for(let D of S.def.params)x({label:D.name,kind:"argument",insert:`${D.name} = `,...D.value!==void 0&&{detail:`${D.name} = ${D.value}`},...D.doc&&{doc:D.doc},first:!0});if(S?.sig)for(let D of S.sig.params)x({label:D.name,kind:"argument",insert:`${D.name} = `,...D.default!==void 0&&{detail:`${D.name} = ${D.default}`},...D.doc&&{doc:D.doc},first:!0})}let I=!p||p.token.value==="{",F=a[u]?.type==="id"&&a[u+1]?.value==="="&&a.length>u+1,L=I&&!F&&(!c||c.type==="punct"&&[";","{","}",")","*","#","%","!"].includes(c.value)||c.type==="id"&&c.value==="else"),U=np(n,h),P=S=>{let D=[],ce=new Set;for(let ge of U)for(let[q,z]of ge[S])ce.has(q)||(ce.add(q),D.push(z[z.length-1]));return D},T=S=>({label:S.name,kind:S.kind,detail:S.kind==="module"||S.kind==="function"?ks(S):S.value!==void 0?`${S.name} = ${S.value.split(`
401
+ `)}}function Sa(n,e){let t=/[A-Za-z0-9_$]*$/.exec(n.slice(0,e))[0],r=e-t.length,s;try{s=It(n.slice(0,r)).tokens.slice(0,-1)}catch{return}let i=s.length?s[s.length-1].end:0;if(/\/\/[^\n]*$/.test(n.slice(i,r)))return;let o=[],a=0;return s.forEach((l,u)=>{if(l.type!=="punct")return;let c=o[o.length-1];if(l.value==="("||l.value==="["||l.value==="{"){let h={token:l,index:u,commas:[]},f=s[u-1];if(l.value==="("&&f?.type==="id"){let p=s[u-2];f.value==="for"||f.value==="if"||f.value==="let"?h.header=!0:f.value==="function"?h.params=!0:pa.has(f.value)||(h.callee=f,p?.type==="id"&&(p.value==="module"||p.value==="function")&&(h.params=!0))}o.push(h),l.value==="{"&&(a=u+1)}else l.value===")"||l.value==="]"||l.value==="}"?(o.pop(),l.value==="}"&&(a=u+1)):l.value===","&&c?c.commas.push(u):l.value===";"&&(!c||c.token.value==="{")&&(a=u+1)}),{word:t,from:r,tokens:s,stack:o,stmtStart:a,prev:s[s.length-1]}}function wa(n,e){let t=n.references.find(s=>s.start===e.pos.offset);if(t?.def?.params)return{def:t.def};if(t?.builtin)return{sig:t.builtin};let r=Ct(e.value);return r?{sig:r}:void 0}function sp(n,e){let t=n.scopes.filter(s=>s.start<=e&&e<=s.end).sort((s,i)=>s.end-s.start-(i.end-i.start))[0],r=[];for(let s=t??n.scopes[0];s;s=s.parent)r.push(s);return r}function ip(n,e){let t=n.source,r=t.slice(t.lastIndexOf(`
402
+ `,e-1)+1,e),s=/\b(?:use|include)\s*<([A-Za-z0-9_./-]*)$/.exec(r);if(s){let S=[...new Set(n.available)].map(A=>({label:A,kind:"library",...yn(nt,A)!==void 0&&{detail:"Standard library",doc:ba(nt[A])}}));return{from:e-s[1].length,to:e,items:S}}let i={from:e,to:e,items:[]},o=Sa(t,e);if(!o||/^\d/.test(o.word))return i;let{tokens:a,stack:l,stmtStart:u,prev:c,from:h}=o,f=S=>({from:h,to:e,items:S});if(c?.type==="punct"&&c.value===".")return f(["x","y","z"].map(S=>({label:S,kind:"property",detail:`item ${S}`})));if(c?.type==="id"&&(c.value==="module"||c.value==="function"))return i;let p=l[l.length-1],d=p&&c&&(c===p.token||c.type==="punct"&&c.value===",");if(p?.params&&d)return i;let g=[],m=new Set,x=S=>{m.has(S.kind+" "+S.label)||(m.add(S.kind+" "+S.label),g.push(S))};if(p?.callee&&d){let S=wa(n,p.callee);if(S?.def)for(let A of S.def.params)x({label:A.name,kind:"argument",insert:`${A.name} = `,...A.value!==void 0&&{detail:`${A.name} = ${A.value}`},...A.doc&&{doc:A.doc},first:!0});if(S?.sig)for(let A of S.sig.params)x({label:A.name,kind:"argument",insert:`${A.name} = `,...A.default!==void 0&&{detail:`${A.name} = ${A.default}`},...A.doc&&{doc:A.doc},first:!0})}let L=!p||p.token.value==="{",M=a[u]?.type==="id"&&a[u+1]?.value==="="&&a.length>u+1,E=L&&!M&&(!c||c.type==="punct"&&[";","{","}",")","*","#","%","!"].includes(c.value)||c.type==="id"&&c.value==="else"),O=sp(n,h),w=S=>{let A=[],W=new Set;for(let j of O)for(let[H,_]of j[S])W.has(H)||(W.add(H),A.push(_[_.length-1]));return A},T=S=>({label:S.name,kind:S.kind,detail:S.kind==="module"||S.kind==="function"?ks(S):S.value!==void 0?`${S.name} = ${S.value.split(`
403
403
  `)[0]}`:S.name,...(S.doc||S.file)&&{doc:[S.doc,S.file!==void 0&&`From \`<${S.file}>\``].filter(Boolean).join(`
404
404
 
405
- `)}}),H=S=>({label:S.name,kind:L?"module":"function",detail:kn(S),doc:S.doc,builtin:!0});for(let S of P("vars"))(S.name!==o.word||S.start<h)&&x(T(S));for(let[S,D]of Object.entries(pa))x({label:S,kind:S==="PI"?"constant":"variable",detail:D.value!==void 0?`${S} = ${D.value}`:S,doc:D.doc,builtin:!0});if(L){for(let S of P("mods"))x(T(S));for(let S of wn)S.kind!=="function"&&x(H(S));for(let S of["module","function","for","if","let","use","include"])x({label:S,kind:"keyword"});c?.type==="punct"&&c.value==="}"&&x({label:"else",kind:"keyword"})}else{for(let S of P("fns"))x(T(S));for(let S of wn)S.kind!=="module"&&x(H(S));for(let S of _h)x({label:S,kind:"constant",builtin:!0});if(x({label:"let",kind:"keyword"}),x({label:"function",kind:"keyword"}),p?.token.value==="[")for(let S of["for","if","else","each"])x({label:S,kind:"keyword"})}return f(g)}function sp(n,e){let t=ba(n.source,e);if(!t)return;let r;for(let d=t.stack.length-1;d>=0;d--){let g=t.stack[d];if(g.token.value==="{"||g.params)return;if(g.callee){r=g;break}}if(!r)return;let s=Sa(n,r.callee);if(!s)return;let i=r.callee.value,o=s.def?s.def.params.map(d=>({text:d.value!==void 0?`${d.name} = ${d.value.split(`
406
- `)[0]}`:d.name,name:d.name,doc:d.doc})):s.sig.params.map(d=>({text:d.default!==void 0?`${d.name} = ${d.default}`:d.name,name:d.name,doc:d.doc}));s.sig?.rest&&o.push({text:"...",name:"...",doc:"Any number of values"});let a=`${i}(`,l=o.map((d,g)=>{g&&(a+=", ");let y=a.length;return a+=d.text,{start:y,end:a.length,...d.doc&&{doc:d.doc}}});a+=")";let u=r.commas.length,c=u?r.commas[u-1]+1:r.index+1,h=t.tokens.slice(c),f=u;h[0]?.type==="id"&&h[1]?.value==="="?f=o.findIndex(d=>d.name===h[0].value):t.tokens.slice(r.index+1).some((d,g,y)=>d.type==="id"&&y[g+1]?.value==="="&&(g===0||y[g-1].value===","))&&(f=-1),s.sig?.rest&&f>=o.length&&(f=o.length-1),f>=o.length&&(f=-1);let p=s.def?[s.def.doc,s.def.file!==void 0&&`From \`<${s.def.file}>\``].filter(Boolean).join(`
405
+ `)}}),U=S=>({label:S.name,kind:E?"module":"function",detail:En(S),doc:S.doc,builtin:!0});for(let S of w("vars"))(S.name!==o.word||S.start<h)&&x(T(S));for(let[S,A]of Object.entries(da))x({label:S,kind:S==="PI"?"constant":"variable",detail:A.value!==void 0?`${S} = ${A.value}`:S,doc:A.doc,builtin:!0});if(E){for(let S of w("mods"))x(T(S));for(let S of kn)S.kind!=="function"&&x(U(S));for(let S of["module","function","for","if","let","use","include"])x({label:S,kind:"keyword"});c?.type==="punct"&&c.value==="}"&&x({label:"else",kind:"keyword"})}else{for(let S of w("fns"))x(T(S));for(let S of kn)S.kind!=="module"&&x(U(S));for(let S of Zh)x({label:S,kind:"constant",builtin:!0});if(x({label:"let",kind:"keyword"}),x({label:"function",kind:"keyword"}),p?.token.value==="[")for(let S of["for","if","else","each"])x({label:S,kind:"keyword"})}return f(g)}function op(n,e){let t=Sa(n.source,e);if(!t)return;let r;for(let d=t.stack.length-1;d>=0;d--){let g=t.stack[d];if(g.token.value==="{"||g.params)return;if(g.callee){r=g;break}}if(!r)return;let s=wa(n,r.callee);if(!s)return;let i=r.callee.value,o=s.def?s.def.params.map(d=>({text:d.value!==void 0?`${d.name} = ${d.value.split(`
406
+ `)[0]}`:d.name,name:d.name,doc:d.doc})):s.sig.params.map(d=>({text:d.default!==void 0?`${d.name} = ${d.default}`:d.name,name:d.name,doc:d.doc}));s.sig?.rest&&o.push({text:"...",name:"...",doc:"Any number of values"});let a=`${i}(`,l=o.map((d,g)=>{g&&(a+=", ");let m=a.length;return a+=d.text,{start:m,end:a.length,...d.doc&&{doc:d.doc}}});a+=")";let u=r.commas.length,c=u?r.commas[u-1]+1:r.index+1,h=t.tokens.slice(c),f=u;h[0]?.type==="id"&&h[1]?.value==="="?f=o.findIndex(d=>d.name===h[0].value):t.tokens.slice(r.index+1).some((d,g,m)=>d.type==="id"&&m[g+1]?.value==="="&&(g===0||m[g-1].value===","))&&(f=-1),s.sig?.rest&&f>=o.length&&(f=o.length-1),f>=o.length&&(f=-1);let p=s.def?[s.def.doc,s.def.file!==void 0&&`From \`<${s.def.file}>\``].filter(Boolean).join(`
407
407
 
408
- `):s.sig.doc;return{label:a,...p&&{doc:p},params:l,active:f}}function ip(n){let e=n.definitions.filter(s=>Ss.has(s)).sort((s,i)=>s.range[0]-i.range[0]),t=[],r=[];for(let s of e){let i={name:s.name,kind:s.kind,...s.kind==="variable"&&s.value!==void 0?{detail:s.value.split(`
409
- `)[0]}:s.kind!=="variable"&&{detail:ks(s)},range:s.range,start:s.start,end:s.end,children:[]};for(;r.length&&r[r.length-1].range[1]<s.range[0];)r.pop();(r.length?r[r.length-1].children:t).push(i),s.kind!=="variable"&&r.push(i)}return t}var ca=/\s*\(line (\d+)(?:, column (\d+))?(?: in <([^>]+)>)?\)/;function op(n,e={}){let t=[0];for(let l=n.indexOf(`
408
+ `):s.sig.doc;return{label:a,...p&&{doc:p},params:l,active:f}}function ap(n){let e=n.definitions.filter(s=>Ss.has(s)).sort((s,i)=>s.range[0]-i.range[0]),t=[],r=[];for(let s of e){let i={name:s.name,kind:s.kind,...s.kind==="variable"&&s.value!==void 0?{detail:s.value.split(`
409
+ `)[0]}:s.kind!=="variable"&&{detail:ks(s)},range:s.range,start:s.start,end:s.end,children:[]};for(;r.length&&r[r.length-1].range[1]<s.range[0];)r.pop();(r.length?r[r.length-1].children:t).push(i),s.kind!=="variable"&&r.push(i)}return t}var fa=/\s*\(line (\d+)(?:, column (\d+))?(?: in <([^>]+)>)?\)/;function lp(n,e={}){let t=[0];for(let l=n.indexOf(`
410
410
  `);l>=0;l=n.indexOf(`
411
- `,l+1))t.push(l+1);let r=l=>n.slice(t[l-1],(t[l]??n.length+1)-1).replace(/\r$/,""),s=(l,u)=>{if(l<1||l>t.length)return{start:0,end:0};let c=r(l);if(u===void 0){let f=c.length-c.trimStart().length;return{start:t[l-1]+f,end:t[l-1]+c.trimEnd().length}}let h=t[l-1]+Math.min(u-1,c.length);return{start:h,end:Math.min(h+Cs(c,u),t[l-1]+c.length)}},i=l=>{let u=new RegExp(`\\b(?:use|include)\\s*<${l.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}>`).exec(n);return u?{start:u.index,end:u.index+u[0].length}:{start:0,end:0}},o=[],a=l=>{if(l.startsWith("Nothing to cut"))return;let u=ca.exec(l);u?u[3]?o.push({severity:"warning",message:l,...i(u[3])}):o.push({severity:"warning",message:l.replace(ca,""),...s(Number(u[1]),u[2]===void 0?void 0:Number(u[2]))}):o.push({severity:"warning",message:l,start:0,end:0})};try{sa(n,e).warnings.forEach(a)}catch(l){if(!(l instanceof R))return o.push({severity:"error",message:l instanceof Error?l.message:String(l),start:0,end:0}),o;l.warnings.forEach(a);let u=l.trace.filter(d=>d.file===void 0),c=l.reason,h={start:0,end:0};if(l.file===void 0&&l.line!==void 0)h=s(l.line,l.col);else if(l.file!==void 0){c+=` (in <${l.file}>${l.line!==void 0?`, line ${l.line}`:""})`;let d=u.shift();h=d?s(d.line,d.col):i(l.file)}let f=l.call?At(l.call):void 0;f&&(c+=`
412
- ${kn(f)}: ${f.doc}`);let p=u.map(d=>({message:`in ${d.kind==="module"?"module ":""}${d.name}(), called here${d.count>1?` (${d.count} times)`:""}`,...s(d.line,d.col)}));o.push({severity:"error",message:c,...h,...p.length&&{related:p}})}return o}
411
+ `,l+1))t.push(l+1);let r=l=>n.slice(t[l-1],(t[l]??n.length+1)-1).replace(/\r$/,""),s=(l,u)=>{if(l<1||l>t.length)return{start:0,end:0};let c=r(l);if(u===void 0){let f=c.length-c.trimStart().length;return{start:t[l-1]+f,end:t[l-1]+c.trimEnd().length}}let h=t[l-1]+Math.min(u-1,c.length);return{start:h,end:Math.min(h+Ms(c,u),t[l-1]+c.length)}},i=l=>{let u=new RegExp(`\\b(?:use|include)\\s*<${l.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}>`).exec(n);return u?{start:u.index,end:u.index+u[0].length}:{start:0,end:0}},o=[],a=l=>{if(l.startsWith("Nothing to cut"))return;let u=fa.exec(l);u?u[3]?o.push({severity:"warning",message:l,...i(u[3])}):o.push({severity:"warning",message:l.replace(fa,""),...s(Number(u[1]),u[2]===void 0?void 0:Number(u[2]))}):o.push({severity:"warning",message:l,start:0,end:0})};try{ia(n,e).warnings.forEach(a)}catch(l){if(!(l instanceof N))return o.push({severity:"error",message:l instanceof Error?l.message:String(l),start:0,end:0}),o;l.warnings.forEach(a);let u=l.trace.filter(d=>d.file===void 0),c=l.reason,h={start:0,end:0};if(l.file===void 0&&l.line!==void 0)h=s(l.line,l.col);else if(l.file!==void 0){c+=` (in <${l.file}>${l.line!==void 0?`, line ${l.line}`:""})`;let d=u.shift();h=d?s(d.line,d.col):i(l.file)}let f=l.call?Ct(l.call):void 0;f&&(c+=`
412
+ ${En(f)}: ${f.doc}`);let p=u.map(d=>({message:`in ${d.kind==="module"?"module ":""}${d.name}(), called here${d.count>1?` (${d.count} times)`:""}`,...s(d.line,d.col)}));o.push({severity:"error",message:c,...h,...p.length&&{related:p}})}return o}
413
413
  /*! Bundled license information:
414
414
 
415
415
  opentype.js/dist/opentype.module.js: